Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d33d99d94 | ||
|
|
15fe7b4aff | ||
|
|
8f340cb3d5 | ||
|
|
dab04242e6 | ||
|
|
a1740ab227 | ||
|
|
8abc7469cd | ||
|
|
2309de4025 | ||
|
|
c675b273a8 | ||
|
|
fbb06d3c53 | ||
|
|
ab04738aff | ||
|
|
0ae8a4037d | ||
|
|
5fa4d25e44 | ||
|
|
5fd1025340 | ||
|
|
a744f5a6c4 | ||
|
|
d518efb843 | ||
|
|
924bee4a96 | ||
|
|
2dcd42a546 | ||
|
|
f416f4c278 | ||
|
|
1b6d3bc5bd | ||
|
|
5d30306ad7 | ||
|
|
127327e226 | ||
|
|
c82718e155 | ||
|
|
6ad1e01814 | ||
|
|
1c6773a95b | ||
|
|
b74a042f75 | ||
|
|
c5a020c65c | ||
|
|
61004e4686 | ||
|
|
ff870630fa | ||
|
|
1da7e2a618 | ||
|
|
de4b1bef32 | ||
|
|
f5ba03ca33 | ||
|
|
b00fca810d | ||
|
|
132f26e565 | ||
|
|
c5854a1d6f | ||
|
|
d0caf957fe | ||
|
|
fc3f633141 | ||
|
|
ada170e525 | ||
|
|
95ec31d5c0 | ||
|
|
a6242af7b1 | ||
|
|
028de0338e | ||
|
|
e6a197e709 | ||
|
|
61a313d8ff | ||
|
|
bbe94deedb | ||
|
|
5c90b8e1ca | ||
|
|
23f3c07d6b | ||
|
|
27f76d5cf0 | ||
|
|
732fefeb7e | ||
|
|
6fb71a48fe | ||
|
|
3daa8eaec1 | ||
|
|
811618d8e6 | ||
|
|
67819ad4d6 | ||
|
|
6405713314 | ||
|
|
60a6318663 | ||
|
|
3e83446a2c | ||
|
|
d725e9d896 | ||
|
|
68c4b2fcc2 | ||
|
|
96db00418c | ||
|
|
2def6457fe | ||
|
|
b9123d68a0 | ||
|
|
ebbf9b22da | ||
|
|
eace543d74 | ||
|
|
73cd1a01a0 | ||
|
|
8186b4c0b5 | ||
|
|
5023e4494c | ||
|
|
e2d360d5de | ||
|
|
948046948a | ||
|
|
4e3fd1afaf | ||
|
|
e2ae502b48 | ||
|
|
6561435a38 | ||
|
|
1846aafc1e | ||
|
|
54654b386d |
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
/mcp.json
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
"immer": "^10.0.3",
|
"immer": "^10.0.3",
|
||||||
"lottie-react": "^2.4.1",
|
"lottie-react": "^2.4.1",
|
||||||
"lucide-react": "^0.475.0",
|
"lucide-react": "^0.475.0",
|
||||||
"next": "^15.3.4",
|
"next": "^15.3.6",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-hook-form": "^7.49.3",
|
"react-hook-form": "^7.49.3",
|
||||||
|
|||||||
Generated
+416
-14
@@ -63,8 +63,8 @@ importers:
|
|||||||
specifier: ^0.475.0
|
specifier: ^0.475.0
|
||||||
version: 0.475.0(react@18.3.1)
|
version: 0.475.0(react@18.3.1)
|
||||||
next:
|
next:
|
||||||
specifier: ^15.3.4
|
specifier: ^15.3.6
|
||||||
version: 15.3.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
version: 15.5.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
react:
|
react:
|
||||||
specifier: ^18.2.0
|
specifier: ^18.2.0
|
||||||
version: 18.3.1
|
version: 18.3.1
|
||||||
@@ -879,6 +879,9 @@ packages:
|
|||||||
'@emnapi/runtime@1.4.3':
|
'@emnapi/runtime@1.4.3':
|
||||||
resolution: {integrity: sha512-pBPWdu6MLKROBX05wSNKcNb++m5Er+KQ9QkB+WVM+pW2Kx9hoSrVTnu3BdkI5eBLZoKu/J6mW/B6i6bJB2ytXQ==}
|
resolution: {integrity: sha512-pBPWdu6MLKROBX05wSNKcNb++m5Er+KQ9QkB+WVM+pW2Kx9hoSrVTnu3BdkI5eBLZoKu/J6mW/B6i6bJB2ytXQ==}
|
||||||
|
|
||||||
|
'@emnapi/runtime@1.7.1':
|
||||||
|
resolution: {integrity: sha512-PVtJr5CmLwYAU9PZDMITZoR5iAOShYREoR45EyyLrbntV50mdePTgUn4AmOw90Ifcj+x2kRjdzr1HP3RrNiHGA==}
|
||||||
|
|
||||||
'@emnapi/wasi-threads@1.0.2':
|
'@emnapi/wasi-threads@1.0.2':
|
||||||
resolution: {integrity: sha512-5n3nTJblwRi8LlXkJ9eBzu+kZR8Yxcc7ubakyQTFzPMtIhFpUBRbsnc2Dv88IZDIbCDlBiWrknhB4Lsz7mg6BA==}
|
resolution: {integrity: sha512-5n3nTJblwRi8LlXkJ9eBzu+kZR8Yxcc7ubakyQTFzPMtIhFpUBRbsnc2Dv88IZDIbCDlBiWrknhB4Lsz7mg6BA==}
|
||||||
|
|
||||||
@@ -1196,70 +1199,136 @@ packages:
|
|||||||
'@iconify/types@2.0.0':
|
'@iconify/types@2.0.0':
|
||||||
resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==}
|
resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==}
|
||||||
|
|
||||||
|
'@img/colour@1.0.0':
|
||||||
|
resolution: {integrity: sha512-A5P/LfWGFSl6nsckYtjw9da+19jB8hkJ6ACTGcDfEJ0aE+l2n2El7dsVM7UVHZQ9s2lmYMWlrS21YLy2IR1LUw==}
|
||||||
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
'@img/sharp-darwin-arm64@0.34.2':
|
'@img/sharp-darwin-arm64@0.34.2':
|
||||||
resolution: {integrity: sha512-OfXHZPppddivUJnqyKoi5YVeHRkkNE2zUFT2gbpKxp/JZCFYEYubnMg+gOp6lWfasPrTS+KPosKqdI+ELYVDtg==}
|
resolution: {integrity: sha512-OfXHZPppddivUJnqyKoi5YVeHRkkNE2zUFT2gbpKxp/JZCFYEYubnMg+gOp6lWfasPrTS+KPosKqdI+ELYVDtg==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
|
'@img/sharp-darwin-arm64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
'@img/sharp-darwin-x64@0.34.2':
|
'@img/sharp-darwin-x64@0.34.2':
|
||||||
resolution: {integrity: sha512-dYvWqmjU9VxqXmjEtjmvHnGqF8GrVjM2Epj9rJ6BUIXvk8slvNDJbhGFvIoXzkDhrJC2jUxNLz/GUjjvSzfw+g==}
|
resolution: {integrity: sha512-dYvWqmjU9VxqXmjEtjmvHnGqF8GrVjM2Epj9rJ6BUIXvk8slvNDJbhGFvIoXzkDhrJC2jUxNLz/GUjjvSzfw+g==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
|
'@img/sharp-darwin-x64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
'@img/sharp-libvips-darwin-arm64@1.1.0':
|
'@img/sharp-libvips-darwin-arm64@1.1.0':
|
||||||
resolution: {integrity: sha512-HZ/JUmPwrJSoM4DIQPv/BfNh9yrOA8tlBbqbLz4JZ5uew2+o22Ik+tHQJcih7QJuSa0zo5coHTfD5J8inqj9DA==}
|
resolution: {integrity: sha512-HZ/JUmPwrJSoM4DIQPv/BfNh9yrOA8tlBbqbLz4JZ5uew2+o22Ik+tHQJcih7QJuSa0zo5coHTfD5J8inqj9DA==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-darwin-arm64@1.2.4':
|
||||||
|
resolution: {integrity: sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
'@img/sharp-libvips-darwin-x64@1.1.0':
|
'@img/sharp-libvips-darwin-x64@1.1.0':
|
||||||
resolution: {integrity: sha512-Xzc2ToEmHN+hfvsl9wja0RlnXEgpKNmftriQp6XzY/RaSfwD9th+MSh0WQKzUreLKKINb3afirxW7A0fz2YWuQ==}
|
resolution: {integrity: sha512-Xzc2ToEmHN+hfvsl9wja0RlnXEgpKNmftriQp6XzY/RaSfwD9th+MSh0WQKzUreLKKINb3afirxW7A0fz2YWuQ==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-darwin-x64@1.2.4':
|
||||||
|
resolution: {integrity: sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-arm64@1.1.0':
|
'@img/sharp-libvips-linux-arm64@1.1.0':
|
||||||
resolution: {integrity: sha512-IVfGJa7gjChDET1dK9SekxFFdflarnUB8PwW8aGwEoF3oAsSDuNUTYS+SKDOyOJxQyDC1aPFMuRYLoDInyV9Ew==}
|
resolution: {integrity: sha512-IVfGJa7gjChDET1dK9SekxFFdflarnUB8PwW8aGwEoF3oAsSDuNUTYS+SKDOyOJxQyDC1aPFMuRYLoDInyV9Ew==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-arm64@1.2.4':
|
||||||
|
resolution: {integrity: sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-arm@1.1.0':
|
'@img/sharp-libvips-linux-arm@1.1.0':
|
||||||
resolution: {integrity: sha512-s8BAd0lwUIvYCJyRdFqvsj+BJIpDBSxs6ivrOPm/R7piTs5UIwY5OjXrP2bqXC9/moGsyRa37eYWYCOGVXxVrA==}
|
resolution: {integrity: sha512-s8BAd0lwUIvYCJyRdFqvsj+BJIpDBSxs6ivrOPm/R7piTs5UIwY5OjXrP2bqXC9/moGsyRa37eYWYCOGVXxVrA==}
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-arm@1.2.4':
|
||||||
|
resolution: {integrity: sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==}
|
||||||
|
cpu: [arm]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-ppc64@1.1.0':
|
'@img/sharp-libvips-linux-ppc64@1.1.0':
|
||||||
resolution: {integrity: sha512-tiXxFZFbhnkWE2LA8oQj7KYR+bWBkiV2nilRldT7bqoEZ4HiDOcePr9wVDAZPi/Id5fT1oY9iGnDq20cwUz8lQ==}
|
resolution: {integrity: sha512-tiXxFZFbhnkWE2LA8oQj7KYR+bWBkiV2nilRldT7bqoEZ4HiDOcePr9wVDAZPi/Id5fT1oY9iGnDq20cwUz8lQ==}
|
||||||
cpu: [ppc64]
|
cpu: [ppc64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-ppc64@1.2.4':
|
||||||
|
resolution: {integrity: sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==}
|
||||||
|
cpu: [ppc64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-riscv64@1.2.4':
|
||||||
|
resolution: {integrity: sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==}
|
||||||
|
cpu: [riscv64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-s390x@1.1.0':
|
'@img/sharp-libvips-linux-s390x@1.1.0':
|
||||||
resolution: {integrity: sha512-xukSwvhguw7COyzvmjydRb3x/09+21HykyapcZchiCUkTThEQEOMtBj9UhkaBRLuBrgLFzQ2wbxdeCCJW/jgJA==}
|
resolution: {integrity: sha512-xukSwvhguw7COyzvmjydRb3x/09+21HykyapcZchiCUkTThEQEOMtBj9UhkaBRLuBrgLFzQ2wbxdeCCJW/jgJA==}
|
||||||
cpu: [s390x]
|
cpu: [s390x]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-s390x@1.2.4':
|
||||||
|
resolution: {integrity: sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==}
|
||||||
|
cpu: [s390x]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-x64@1.1.0':
|
'@img/sharp-libvips-linux-x64@1.1.0':
|
||||||
resolution: {integrity: sha512-yRj2+reB8iMg9W5sULM3S74jVS7zqSzHG3Ol/twnAAkAhnGQnpjj6e4ayUz7V+FpKypwgs82xbRdYtchTTUB+Q==}
|
resolution: {integrity: sha512-yRj2+reB8iMg9W5sULM3S74jVS7zqSzHG3Ol/twnAAkAhnGQnpjj6e4ayUz7V+FpKypwgs82xbRdYtchTTUB+Q==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-x64@1.2.4':
|
||||||
|
resolution: {integrity: sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-libvips-linuxmusl-arm64@1.1.0':
|
'@img/sharp-libvips-linuxmusl-arm64@1.1.0':
|
||||||
resolution: {integrity: sha512-jYZdG+whg0MDK+q2COKbYidaqW/WTz0cc1E+tMAusiDygrM4ypmSCjOJPmFTvHHJ8j/6cAGyeDWZOsK06tP33w==}
|
resolution: {integrity: sha512-jYZdG+whg0MDK+q2COKbYidaqW/WTz0cc1E+tMAusiDygrM4ypmSCjOJPmFTvHHJ8j/6cAGyeDWZOsK06tP33w==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
libc: [musl]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linuxmusl-arm64@1.2.4':
|
||||||
|
resolution: {integrity: sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-libvips-linuxmusl-x64@1.1.0':
|
'@img/sharp-libvips-linuxmusl-x64@1.1.0':
|
||||||
resolution: {integrity: sha512-wK7SBdwrAiycjXdkPnGCPLjYb9lD4l6Ze2gSdAGVZrEL05AOUJESWU2lhlC+Ffn5/G+VKuSm6zzbQSzFX/P65A==}
|
resolution: {integrity: sha512-wK7SBdwrAiycjXdkPnGCPLjYb9lD4l6Ze2gSdAGVZrEL05AOUJESWU2lhlC+Ffn5/G+VKuSm6zzbQSzFX/P65A==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
libc: [musl]
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linuxmusl-x64@1.2.4':
|
||||||
|
resolution: {integrity: sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-linux-arm64@0.34.2':
|
'@img/sharp-linux-arm64@0.34.2':
|
||||||
resolution: {integrity: sha512-D8n8wgWmPDakc83LORcfJepdOSN6MvWNzzz2ux0MnIbOqdieRZwVYY32zxVx+IFUT8er5KPcyU3XXsn+GzG/0Q==}
|
resolution: {integrity: sha512-D8n8wgWmPDakc83LORcfJepdOSN6MvWNzzz2ux0MnIbOqdieRZwVYY32zxVx+IFUT8er5KPcyU3XXsn+GzG/0Q==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
@@ -1267,6 +1336,12 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@img/sharp-linux-arm64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-linux-arm@0.34.2':
|
'@img/sharp-linux-arm@0.34.2':
|
||||||
resolution: {integrity: sha512-0DZzkvuEOqQUP9mo2kjjKNok5AmnOr1jB2XYjkaoNRwpAYMDzRmAqUIa1nRi58S2WswqSfPOWLNOr0FDT3H5RQ==}
|
resolution: {integrity: sha512-0DZzkvuEOqQUP9mo2kjjKNok5AmnOr1jB2XYjkaoNRwpAYMDzRmAqUIa1nRi58S2WswqSfPOWLNOr0FDT3H5RQ==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
@@ -1274,6 +1349,24 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@img/sharp-linux-arm@0.34.5':
|
||||||
|
resolution: {integrity: sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [arm]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
|
'@img/sharp-linux-ppc64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [ppc64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
|
'@img/sharp-linux-riscv64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [riscv64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-linux-s390x@0.34.2':
|
'@img/sharp-linux-s390x@0.34.2':
|
||||||
resolution: {integrity: sha512-EGZ1xwhBI7dNISwxjChqBGELCWMGDvmxZXKjQRuqMrakhO8QoMgqCrdjnAqJq/CScxfRn+Bb7suXBElKQpPDiw==}
|
resolution: {integrity: sha512-EGZ1xwhBI7dNISwxjChqBGELCWMGDvmxZXKjQRuqMrakhO8QoMgqCrdjnAqJq/CScxfRn+Bb7suXBElKQpPDiw==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
@@ -1281,6 +1374,12 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@img/sharp-linux-s390x@0.34.5':
|
||||||
|
resolution: {integrity: sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [s390x]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-linux-x64@0.34.2':
|
'@img/sharp-linux-x64@0.34.2':
|
||||||
resolution: {integrity: sha512-sD7J+h5nFLMMmOXYH4DD9UtSNBD05tWSSdWAcEyzqW8Cn5UxXvsHAxmxSesYUsTOBmUnjtxghKDl15EvfqLFbQ==}
|
resolution: {integrity: sha512-sD7J+h5nFLMMmOXYH4DD9UtSNBD05tWSSdWAcEyzqW8Cn5UxXvsHAxmxSesYUsTOBmUnjtxghKDl15EvfqLFbQ==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
@@ -1288,6 +1387,12 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@img/sharp-linux-x64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-linuxmusl-arm64@0.34.2':
|
'@img/sharp-linuxmusl-arm64@0.34.2':
|
||||||
resolution: {integrity: sha512-NEE2vQ6wcxYav1/A22OOxoSOGiKnNmDzCYFOZ949xFmrWZOVII1Bp3NqVVpvj+3UeHMFyN5eP/V5hzViQ5CZNA==}
|
resolution: {integrity: sha512-NEE2vQ6wcxYav1/A22OOxoSOGiKnNmDzCYFOZ949xFmrWZOVII1Bp3NqVVpvj+3UeHMFyN5eP/V5hzViQ5CZNA==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
@@ -1295,6 +1400,12 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
libc: [musl]
|
||||||
|
|
||||||
|
'@img/sharp-linuxmusl-arm64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-linuxmusl-x64@0.34.2':
|
'@img/sharp-linuxmusl-x64@0.34.2':
|
||||||
resolution: {integrity: sha512-DOYMrDm5E6/8bm/yQLCWyuDJwUnlevR8xtF8bs+gjZ7cyUNYXiSf/E8Kp0Ss5xasIaXSHzb888V1BE4i1hFhAA==}
|
resolution: {integrity: sha512-DOYMrDm5E6/8bm/yQLCWyuDJwUnlevR8xtF8bs+gjZ7cyUNYXiSf/E8Kp0Ss5xasIaXSHzb888V1BE4i1hFhAA==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
@@ -1302,29 +1413,58 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
libc: [musl]
|
||||||
|
|
||||||
|
'@img/sharp-linuxmusl-x64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@img/sharp-wasm32@0.34.2':
|
'@img/sharp-wasm32@0.34.2':
|
||||||
resolution: {integrity: sha512-/VI4mdlJ9zkaq53MbIG6rZY+QRN3MLbR6usYlgITEzi4Rpx5S6LFKsycOQjkOGmqTNmkIdLjEvooFKwww6OpdQ==}
|
resolution: {integrity: sha512-/VI4mdlJ9zkaq53MbIG6rZY+QRN3MLbR6usYlgITEzi4Rpx5S6LFKsycOQjkOGmqTNmkIdLjEvooFKwww6OpdQ==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
cpu: [wasm32]
|
cpu: [wasm32]
|
||||||
|
|
||||||
|
'@img/sharp-wasm32@0.34.5':
|
||||||
|
resolution: {integrity: sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [wasm32]
|
||||||
|
|
||||||
'@img/sharp-win32-arm64@0.34.2':
|
'@img/sharp-win32-arm64@0.34.2':
|
||||||
resolution: {integrity: sha512-cfP/r9FdS63VA5k0xiqaNaEoGxBg9k7uE+RQGzuK9fHt7jib4zAVVseR9LsE4gJcNWgT6APKMNnCcnyOtmSEUQ==}
|
resolution: {integrity: sha512-cfP/r9FdS63VA5k0xiqaNaEoGxBg9k7uE+RQGzuK9fHt7jib4zAVVseR9LsE4gJcNWgT6APKMNnCcnyOtmSEUQ==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
|
'@img/sharp-win32-arm64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
'@img/sharp-win32-ia32@0.34.2':
|
'@img/sharp-win32-ia32@0.34.2':
|
||||||
resolution: {integrity: sha512-QLjGGvAbj0X/FXl8n1WbtQ6iVBpWU7JO94u/P2M4a8CFYsvQi4GW2mRy/JqkRx0qpBzaOdKJKw8uc930EX2AHw==}
|
resolution: {integrity: sha512-QLjGGvAbj0X/FXl8n1WbtQ6iVBpWU7JO94u/P2M4a8CFYsvQi4GW2mRy/JqkRx0qpBzaOdKJKw8uc930EX2AHw==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
|
'@img/sharp-win32-ia32@0.34.5':
|
||||||
|
resolution: {integrity: sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [ia32]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
'@img/sharp-win32-x64@0.34.2':
|
'@img/sharp-win32-x64@0.34.2':
|
||||||
resolution: {integrity: sha512-aUdT6zEYtDKCaxkofmmJDJYGCf0+pJg3eU9/oBuqvEeoB9dKI6ZLc/1iLJCTuJQDO4ptntAlkUmHgGjyuobZbw==}
|
resolution: {integrity: sha512-aUdT6zEYtDKCaxkofmmJDJYGCf0+pJg3eU9/oBuqvEeoB9dKI6ZLc/1iLJCTuJQDO4ptntAlkUmHgGjyuobZbw==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
|
'@img/sharp-win32-x64@0.34.5':
|
||||||
|
resolution: {integrity: sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
'@internationalized/date@3.6.0':
|
'@internationalized/date@3.6.0':
|
||||||
resolution: {integrity: sha512-+z6ti+CcJnRlLHok/emGEsWQhe7kfSmEW+/6qCzvKY67YPh7YOBfvc7+/+NXq+zJlbArg30tYpqLjNgcAYv2YQ==}
|
resolution: {integrity: sha512-+z6ti+CcJnRlLHok/emGEsWQhe7kfSmEW+/6qCzvKY67YPh7YOBfvc7+/+NXq+zJlbArg30tYpqLjNgcAYv2YQ==}
|
||||||
|
|
||||||
@@ -1384,6 +1524,9 @@ packages:
|
|||||||
'@next/env@15.3.4':
|
'@next/env@15.3.4':
|
||||||
resolution: {integrity: sha512-ZkdYzBseS6UjYzz6ylVKPOK+//zLWvD6Ta+vpoye8cW11AjiQjGYVibF0xuvT4L0iJfAPfZLFidaEzAOywyOAQ==}
|
resolution: {integrity: sha512-ZkdYzBseS6UjYzz6ylVKPOK+//zLWvD6Ta+vpoye8cW11AjiQjGYVibF0xuvT4L0iJfAPfZLFidaEzAOywyOAQ==}
|
||||||
|
|
||||||
|
'@next/env@15.5.7':
|
||||||
|
resolution: {integrity: sha512-4h6Y2NyEkIEN7Z8YxkA27pq6zTkS09bUSYC0xjd0NpwFxjnIKeZEeH591o5WECSmjpUhLn3H2QLJcDye3Uzcvg==}
|
||||||
|
|
||||||
'@next/eslint-plugin-next@15.0.3':
|
'@next/eslint-plugin-next@15.0.3':
|
||||||
resolution: {integrity: sha512-3Ln/nHq2V+v8uIaxCR6YfYo7ceRgZNXfTd3yW1ukTaFbO+/I8jNakrjYWODvG9BuR2v5kgVtH/C8r0i11quOgw==}
|
resolution: {integrity: sha512-3Ln/nHq2V+v8uIaxCR6YfYo7ceRgZNXfTd3yW1ukTaFbO+/I8jNakrjYWODvG9BuR2v5kgVtH/C8r0i11quOgw==}
|
||||||
|
|
||||||
@@ -1396,12 +1539,24 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
|
'@next/swc-darwin-arm64@15.5.7':
|
||||||
|
resolution: {integrity: sha512-IZwtxCEpI91HVU/rAUOOobWSZv4P2DeTtNaCdHqLcTJU4wdNXgAySvKa/qJCgR5m6KI8UsKDXtO2B31jcaw1Yw==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
'@next/swc-darwin-x64@15.3.4':
|
'@next/swc-darwin-x64@15.3.4':
|
||||||
resolution: {integrity: sha512-Z0FYJM8lritw5Wq+vpHYuCIzIlEMjewG2aRkc3Hi2rcbULknYL/xqfpBL23jQnCSrDUGAo/AEv0Z+s2bff9Zkw==}
|
resolution: {integrity: sha512-Z0FYJM8lritw5Wq+vpHYuCIzIlEMjewG2aRkc3Hi2rcbULknYL/xqfpBL23jQnCSrDUGAo/AEv0Z+s2bff9Zkw==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
|
'@next/swc-darwin-x64@15.5.7':
|
||||||
|
resolution: {integrity: sha512-UP6CaDBcqaCBuiq/gfCEJw7sPEoX1aIjZHnBWN9v9qYHQdMKvCKcAVs4OX1vIjeE+tC5EIuwDTVIoXpUes29lg==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
'@next/swc-linux-arm64-gnu@15.3.4':
|
'@next/swc-linux-arm64-gnu@15.3.4':
|
||||||
resolution: {integrity: sha512-l8ZQOCCg7adwmsnFm8m5q9eIPAHdaB2F3cxhufYtVo84pymwKuWfpYTKcUiFcutJdp9xGHC+F1Uq3xnFU1B/7g==}
|
resolution: {integrity: sha512-l8ZQOCCg7adwmsnFm8m5q9eIPAHdaB2F3cxhufYtVo84pymwKuWfpYTKcUiFcutJdp9xGHC+F1Uq3xnFU1B/7g==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
@@ -1409,6 +1564,12 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@next/swc-linux-arm64-gnu@15.5.7':
|
||||||
|
resolution: {integrity: sha512-NCslw3GrNIw7OgmRBxHtdWFQYhexoUCq+0oS2ccjyYLtcn1SzGzeM54jpTFonIMUjNbHmpKpziXnpxhSWLcmBA==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@next/swc-linux-arm64-musl@15.3.4':
|
'@next/swc-linux-arm64-musl@15.3.4':
|
||||||
resolution: {integrity: sha512-wFyZ7X470YJQtpKot4xCY3gpdn8lE9nTlldG07/kJYexCUpX1piX+MBfZdvulo+t1yADFVEuzFfVHfklfEx8kw==}
|
resolution: {integrity: sha512-wFyZ7X470YJQtpKot4xCY3gpdn8lE9nTlldG07/kJYexCUpX1piX+MBfZdvulo+t1yADFVEuzFfVHfklfEx8kw==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
@@ -1416,6 +1577,12 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
libc: [musl]
|
||||||
|
|
||||||
|
'@next/swc-linux-arm64-musl@15.5.7':
|
||||||
|
resolution: {integrity: sha512-nfymt+SE5cvtTrG9u1wdoxBr9bVB7mtKTcj0ltRn6gkP/2Nu1zM5ei8rwP9qKQP0Y//umK+TtkKgNtfboBxRrw==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@next/swc-linux-x64-gnu@15.3.4':
|
'@next/swc-linux-x64-gnu@15.3.4':
|
||||||
resolution: {integrity: sha512-gEbH9rv9o7I12qPyvZNVTyP/PWKqOp8clvnoYZQiX800KkqsaJZuOXkWgMa7ANCCh/oEN2ZQheh3yH8/kWPSEg==}
|
resolution: {integrity: sha512-gEbH9rv9o7I12qPyvZNVTyP/PWKqOp8clvnoYZQiX800KkqsaJZuOXkWgMa7ANCCh/oEN2ZQheh3yH8/kWPSEg==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
@@ -1423,6 +1590,12 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@next/swc-linux-x64-gnu@15.5.7':
|
||||||
|
resolution: {integrity: sha512-hvXcZvCaaEbCZcVzcY7E1uXN9xWZfFvkNHwbe/n4OkRhFWrs1J1QV+4U1BN06tXLdaS4DazEGXwgqnu/VMcmqw==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@next/swc-linux-x64-musl@15.3.4':
|
'@next/swc-linux-x64-musl@15.3.4':
|
||||||
resolution: {integrity: sha512-Cf8sr0ufuC/nu/yQ76AnarbSAXcwG/wj+1xFPNbyNo8ltA6kw5d5YqO8kQuwVIxk13SBdtgXrNyom3ZosHAy4A==}
|
resolution: {integrity: sha512-Cf8sr0ufuC/nu/yQ76AnarbSAXcwG/wj+1xFPNbyNo8ltA6kw5d5YqO8kQuwVIxk13SBdtgXrNyom3ZosHAy4A==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
@@ -1430,18 +1603,36 @@ packages:
|
|||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
libc: [musl]
|
||||||
|
|
||||||
|
'@next/swc-linux-x64-musl@15.5.7':
|
||||||
|
resolution: {integrity: sha512-4IUO539b8FmF0odY6/SqANJdgwn1xs1GkPO5doZugwZ3ETF6JUdckk7RGmsfSf7ws8Qb2YB5It33mvNL/0acqA==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
'@next/swc-win32-arm64-msvc@15.3.4':
|
'@next/swc-win32-arm64-msvc@15.3.4':
|
||||||
resolution: {integrity: sha512-ay5+qADDN3rwRbRpEhTOreOn1OyJIXS60tg9WMYTWCy3fB6rGoyjLVxc4dR9PYjEdR2iDYsaF5h03NA+XuYPQQ==}
|
resolution: {integrity: sha512-ay5+qADDN3rwRbRpEhTOreOn1OyJIXS60tg9WMYTWCy3fB6rGoyjLVxc4dR9PYjEdR2iDYsaF5h03NA+XuYPQQ==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
|
'@next/swc-win32-arm64-msvc@15.5.7':
|
||||||
|
resolution: {integrity: sha512-CpJVTkYI3ZajQkC5vajM7/ApKJUOlm6uP4BknM3XKvJ7VXAvCqSjSLmM0LKdYzn6nBJVSjdclx8nYJSa3xlTgQ==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
'@next/swc-win32-x64-msvc@15.3.4':
|
'@next/swc-win32-x64-msvc@15.3.4':
|
||||||
resolution: {integrity: sha512-4kDt31Bc9DGyYs41FTL1/kNpDeHyha2TC0j5sRRoKCyrhNcfZ/nRQkAUlF27mETwm8QyHqIjHJitfcza2Iykfg==}
|
resolution: {integrity: sha512-4kDt31Bc9DGyYs41FTL1/kNpDeHyha2TC0j5sRRoKCyrhNcfZ/nRQkAUlF27mETwm8QyHqIjHJitfcza2Iykfg==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
|
'@next/swc-win32-x64-msvc@15.5.7':
|
||||||
|
resolution: {integrity: sha512-gMzgBX164I6DN+9/PGA+9dQiwmTkE4TloBNx8Kv9UiGARsr9Nba7IpcBRA1iTV9vwlYnrE3Uy6I7Aj6qLjQuqw==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
'@nextui-org/accordion@2.2.7':
|
'@nextui-org/accordion@2.2.7':
|
||||||
resolution: {integrity: sha512-jdobOwUxSi617m+LpxHFzg64UhDuOfDJI2CMk3MP+b2WBJ7SNW4hmN2NW5Scx5JiY+kyBGmlxJ4Y++jZpZgQjQ==}
|
resolution: {integrity: sha512-jdobOwUxSi617m+LpxHFzg64UhDuOfDJI2CMk3MP+b2WBJ7SNW4hmN2NW5Scx5JiY+kyBGmlxJ4Y++jZpZgQjQ==}
|
||||||
deprecated: This package has been deprecated. Please use @heroui/accordion instead.
|
deprecated: This package has been deprecated. Please use @heroui/accordion instead.
|
||||||
@@ -2732,28 +2923,24 @@ packages:
|
|||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
|
||||||
|
|
||||||
'@swc/core-linux-arm64-musl@1.10.18':
|
'@swc/core-linux-arm64-musl@1.10.18':
|
||||||
resolution: {integrity: sha512-4rv+E4VLdgQw6zjbTAauCAEExxChvxMpBUMCiZweTNPKbJJ2dY6BX2WGJ1ea8+RcgqR/Xysj3AFbOz1LBz6dGA==}
|
resolution: {integrity: sha512-4rv+E4VLdgQw6zjbTAauCAEExxChvxMpBUMCiZweTNPKbJJ2dY6BX2WGJ1ea8+RcgqR/Xysj3AFbOz1LBz6dGA==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
|
||||||
|
|
||||||
'@swc/core-linux-x64-gnu@1.10.18':
|
'@swc/core-linux-x64-gnu@1.10.18':
|
||||||
resolution: {integrity: sha512-vTNmyRBVP+sZca+vtwygYPGTNudTU6Gl6XhaZZ7cEUTBr8xvSTgEmYXoK/2uzyXpaTUI4Bmtp1x81cGN0mMoLQ==}
|
resolution: {integrity: sha512-vTNmyRBVP+sZca+vtwygYPGTNudTU6Gl6XhaZZ7cEUTBr8xvSTgEmYXoK/2uzyXpaTUI4Bmtp1x81cGN0mMoLQ==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
|
||||||
|
|
||||||
'@swc/core-linux-x64-musl@1.10.18':
|
'@swc/core-linux-x64-musl@1.10.18':
|
||||||
resolution: {integrity: sha512-1TZPReKhFCeX776XaT6wegknfg+g3zODve+r4oslFHI+g7cInfWlxoGNDS3niPKyuafgCdOjme2g3OF+zzxfsQ==}
|
resolution: {integrity: sha512-1TZPReKhFCeX776XaT6wegknfg+g3zODve+r4oslFHI+g7cInfWlxoGNDS3niPKyuafgCdOjme2g3OF+zzxfsQ==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
|
||||||
|
|
||||||
'@swc/core-win32-arm64-msvc@1.10.18':
|
'@swc/core-win32-arm64-msvc@1.10.18':
|
||||||
resolution: {integrity: sha512-o/2CsaWSN3bkzVQ6DA+BiFKSVEYvhWGA1h+wnL2zWmIDs2Knag54sOEXZkCaf8YQyZesGeXJtPEy9hh/vjJgkA==}
|
resolution: {integrity: sha512-o/2CsaWSN3bkzVQ6DA+BiFKSVEYvhWGA1h+wnL2zWmIDs2Knag54sOEXZkCaf8YQyZesGeXJtPEy9hh/vjJgkA==}
|
||||||
@@ -3161,49 +3348,41 @@ packages:
|
|||||||
resolution: {integrity: sha512-UYA0MA8ajkEDCFRQdng/FVx3F6szBvk3EPnkTTQuuO9lV1kPGuTB+V9TmbDxy5ikaEgyWKxa4CI3ySjklZ9lFA==}
|
resolution: {integrity: sha512-UYA0MA8ajkEDCFRQdng/FVx3F6szBvk3EPnkTTQuuO9lV1kPGuTB+V9TmbDxy5ikaEgyWKxa4CI3ySjklZ9lFA==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
|
||||||
|
|
||||||
'@unrs/resolver-binding-linux-arm64-musl@1.9.2':
|
'@unrs/resolver-binding-linux-arm64-musl@1.9.2':
|
||||||
resolution: {integrity: sha512-P/CO3ODU9YJIHFqAkHbquKtFst0COxdphc8TKGL5yCX75GOiVpGqd1d15ahpqu8xXVsqP4MGFP2C3LRZnnL5MA==}
|
resolution: {integrity: sha512-P/CO3ODU9YJIHFqAkHbquKtFst0COxdphc8TKGL5yCX75GOiVpGqd1d15ahpqu8xXVsqP4MGFP2C3LRZnnL5MA==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
|
||||||
|
|
||||||
'@unrs/resolver-binding-linux-ppc64-gnu@1.9.2':
|
'@unrs/resolver-binding-linux-ppc64-gnu@1.9.2':
|
||||||
resolution: {integrity: sha512-uKStFlOELBxBum2s1hODPtgJhY4NxYJE9pAeyBgNEzHgTqTiVBPjfTlPFJkfxyTjQEuxZbbJlJnMCrRgD7ubzw==}
|
resolution: {integrity: sha512-uKStFlOELBxBum2s1hODPtgJhY4NxYJE9pAeyBgNEzHgTqTiVBPjfTlPFJkfxyTjQEuxZbbJlJnMCrRgD7ubzw==}
|
||||||
cpu: [ppc64]
|
cpu: [ppc64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
|
||||||
|
|
||||||
'@unrs/resolver-binding-linux-riscv64-gnu@1.9.2':
|
'@unrs/resolver-binding-linux-riscv64-gnu@1.9.2':
|
||||||
resolution: {integrity: sha512-LkbNnZlhINfY9gK30AHs26IIVEZ9PEl9qOScYdmY2o81imJYI4IMnJiW0vJVtXaDHvBvxeAgEy5CflwJFIl3tQ==}
|
resolution: {integrity: sha512-LkbNnZlhINfY9gK30AHs26IIVEZ9PEl9qOScYdmY2o81imJYI4IMnJiW0vJVtXaDHvBvxeAgEy5CflwJFIl3tQ==}
|
||||||
cpu: [riscv64]
|
cpu: [riscv64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
|
||||||
|
|
||||||
'@unrs/resolver-binding-linux-riscv64-musl@1.9.2':
|
'@unrs/resolver-binding-linux-riscv64-musl@1.9.2':
|
||||||
resolution: {integrity: sha512-vI+e6FzLyZHSLFNomPi+nT+qUWN4YSj8pFtQZSFTtmgFoxqB6NyjxSjAxEC1m93qn6hUXhIsh8WMp+fGgxCoRg==}
|
resolution: {integrity: sha512-vI+e6FzLyZHSLFNomPi+nT+qUWN4YSj8pFtQZSFTtmgFoxqB6NyjxSjAxEC1m93qn6hUXhIsh8WMp+fGgxCoRg==}
|
||||||
cpu: [riscv64]
|
cpu: [riscv64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
|
||||||
|
|
||||||
'@unrs/resolver-binding-linux-s390x-gnu@1.9.2':
|
'@unrs/resolver-binding-linux-s390x-gnu@1.9.2':
|
||||||
resolution: {integrity: sha512-sSO4AlAYhSM2RAzBsRpahcJB1msc6uYLAtP6pesPbZtptF8OU/CbCPhSRW6cnYOGuVmEmWVW5xVboAqCnWTeHQ==}
|
resolution: {integrity: sha512-sSO4AlAYhSM2RAzBsRpahcJB1msc6uYLAtP6pesPbZtptF8OU/CbCPhSRW6cnYOGuVmEmWVW5xVboAqCnWTeHQ==}
|
||||||
cpu: [s390x]
|
cpu: [s390x]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
|
||||||
|
|
||||||
'@unrs/resolver-binding-linux-x64-gnu@1.9.2':
|
'@unrs/resolver-binding-linux-x64-gnu@1.9.2':
|
||||||
resolution: {integrity: sha512-jkSkwch0uPFva20Mdu8orbQjv2A3G88NExTN2oPTI1AJ+7mZfYW3cDCTyoH6OnctBKbBVeJCEqh0U02lTkqD5w==}
|
resolution: {integrity: sha512-jkSkwch0uPFva20Mdu8orbQjv2A3G88NExTN2oPTI1AJ+7mZfYW3cDCTyoH6OnctBKbBVeJCEqh0U02lTkqD5w==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [glibc]
|
|
||||||
|
|
||||||
'@unrs/resolver-binding-linux-x64-musl@1.9.2':
|
'@unrs/resolver-binding-linux-x64-musl@1.9.2':
|
||||||
resolution: {integrity: sha512-Uk64NoiTpQbkpl+bXsbeyOPRpUoMdcUqa+hDC1KhMW7aN1lfW8PBlBH4mJ3n3Y47dYE8qi0XTxy1mBACruYBaw==}
|
resolution: {integrity: sha512-Uk64NoiTpQbkpl+bXsbeyOPRpUoMdcUqa+hDC1KhMW7aN1lfW8PBlBH4mJ3n3Y47dYE8qi0XTxy1mBACruYBaw==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
libc: [musl]
|
|
||||||
|
|
||||||
'@unrs/resolver-binding-wasm32-wasi@1.9.2':
|
'@unrs/resolver-binding-wasm32-wasi@1.9.2':
|
||||||
resolution: {integrity: sha512-EpBGwkcjDicjR/ybC0g8wO5adPNdVuMrNalVgYcWi+gYtC1XYNuxe3rufcO7dA76OHGeVabcO6cSkPJKVcbCXQ==}
|
resolution: {integrity: sha512-EpBGwkcjDicjR/ybC0g8wO5adPNdVuMrNalVgYcWi+gYtC1XYNuxe3rufcO7dA76OHGeVabcO6cSkPJKVcbCXQ==}
|
||||||
@@ -3818,6 +3997,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==}
|
resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
detect-libc@2.1.2:
|
||||||
|
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
devlop@1.1.0:
|
devlop@1.1.0:
|
||||||
resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}
|
resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}
|
||||||
|
|
||||||
@@ -5302,6 +5485,27 @@ packages:
|
|||||||
sass:
|
sass:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
next@15.5.7:
|
||||||
|
resolution: {integrity: sha512-+t2/0jIJ48kUpGKkdlhgkv+zPTEOoXyr60qXe68eB/pl3CMJaLeIGjzp5D6Oqt25hCBiBTt8wEeeAzfJvUKnPQ==}
|
||||||
|
engines: {node: ^18.18.0 || ^19.8.0 || >= 20.0.0}
|
||||||
|
hasBin: true
|
||||||
|
peerDependencies:
|
||||||
|
'@opentelemetry/api': ^1.1.0
|
||||||
|
'@playwright/test': ^1.51.1
|
||||||
|
babel-plugin-react-compiler: '*'
|
||||||
|
react: ^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0
|
||||||
|
react-dom: ^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0
|
||||||
|
sass: ^1.3.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@opentelemetry/api':
|
||||||
|
optional: true
|
||||||
|
'@playwright/test':
|
||||||
|
optional: true
|
||||||
|
babel-plugin-react-compiler:
|
||||||
|
optional: true
|
||||||
|
sass:
|
||||||
|
optional: true
|
||||||
|
|
||||||
no-case@2.3.2:
|
no-case@2.3.2:
|
||||||
resolution: {integrity: sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==}
|
resolution: {integrity: sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==}
|
||||||
|
|
||||||
@@ -6022,6 +6226,11 @@ packages:
|
|||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
semver@7.7.3:
|
||||||
|
resolution: {integrity: sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
sentence-case@2.1.1:
|
sentence-case@2.1.1:
|
||||||
resolution: {integrity: sha512-ENl7cYHaK/Ktwk5OTD+aDbQ3uC8IByu/6Bkg+HDv8Mm+XnBnppVNalcfJTNsp1ibstKh030/JKQQWglDvtKwEQ==}
|
resolution: {integrity: sha512-ENl7cYHaK/Ktwk5OTD+aDbQ3uC8IByu/6Bkg+HDv8Mm+XnBnppVNalcfJTNsp1ibstKh030/JKQQWglDvtKwEQ==}
|
||||||
|
|
||||||
@@ -6048,6 +6257,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-lszvBmB9QURERtyKT2bNmsgxXK0ShJrL/fvqlonCo7e6xBF8nT8xU6pW+PMIbLsz0RxQk3rgH9kd8UmvOzlMJg==}
|
resolution: {integrity: sha512-lszvBmB9QURERtyKT2bNmsgxXK0ShJrL/fvqlonCo7e6xBF8nT8xU6pW+PMIbLsz0RxQk3rgH9kd8UmvOzlMJg==}
|
||||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
|
||||||
|
sharp@0.34.5:
|
||||||
|
resolution: {integrity: sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==}
|
||||||
|
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||||
|
|
||||||
shebang-command@2.0.0:
|
shebang-command@2.0.0:
|
||||||
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
|
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@@ -7003,6 +7216,11 @@ snapshots:
|
|||||||
tslib: 2.8.1
|
tslib: 2.8.1
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@emnapi/runtime@1.7.1':
|
||||||
|
dependencies:
|
||||||
|
tslib: 2.8.1
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@emnapi/wasi-threads@1.0.2':
|
'@emnapi/wasi-threads@1.0.2':
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.8.1
|
tslib: 2.8.1
|
||||||
@@ -7320,87 +7538,184 @@ snapshots:
|
|||||||
|
|
||||||
'@iconify/types@2.0.0': {}
|
'@iconify/types@2.0.0': {}
|
||||||
|
|
||||||
|
'@img/colour@1.0.0':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-darwin-arm64@0.34.2':
|
'@img/sharp-darwin-arm64@0.34.2':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@img/sharp-libvips-darwin-arm64': 1.1.0
|
'@img/sharp-libvips-darwin-arm64': 1.1.0
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-darwin-arm64@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-darwin-arm64': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-darwin-x64@0.34.2':
|
'@img/sharp-darwin-x64@0.34.2':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@img/sharp-libvips-darwin-x64': 1.1.0
|
'@img/sharp-libvips-darwin-x64': 1.1.0
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-darwin-x64@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-darwin-x64': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-libvips-darwin-arm64@1.1.0':
|
'@img/sharp-libvips-darwin-arm64@1.1.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-darwin-arm64@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-libvips-darwin-x64@1.1.0':
|
'@img/sharp-libvips-darwin-x64@1.1.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-darwin-x64@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-arm64@1.1.0':
|
'@img/sharp-libvips-linux-arm64@1.1.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-arm64@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-arm@1.1.0':
|
'@img/sharp-libvips-linux-arm@1.1.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-arm@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-ppc64@1.1.0':
|
'@img/sharp-libvips-linux-ppc64@1.1.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-ppc64@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-riscv64@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-s390x@1.1.0':
|
'@img/sharp-libvips-linux-s390x@1.1.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-s390x@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-libvips-linux-x64@1.1.0':
|
'@img/sharp-libvips-linux-x64@1.1.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linux-x64@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-libvips-linuxmusl-arm64@1.1.0':
|
'@img/sharp-libvips-linuxmusl-arm64@1.1.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linuxmusl-arm64@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-libvips-linuxmusl-x64@1.1.0':
|
'@img/sharp-libvips-linuxmusl-x64@1.1.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-libvips-linuxmusl-x64@1.2.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-linux-arm64@0.34.2':
|
'@img/sharp-linux-arm64@0.34.2':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@img/sharp-libvips-linux-arm64': 1.1.0
|
'@img/sharp-libvips-linux-arm64': 1.1.0
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-linux-arm64@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-linux-arm64': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-linux-arm@0.34.2':
|
'@img/sharp-linux-arm@0.34.2':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@img/sharp-libvips-linux-arm': 1.1.0
|
'@img/sharp-libvips-linux-arm': 1.1.0
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-linux-arm@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-linux-arm': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-linux-ppc64@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-linux-ppc64': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-linux-riscv64@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-linux-riscv64': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-linux-s390x@0.34.2':
|
'@img/sharp-linux-s390x@0.34.2':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@img/sharp-libvips-linux-s390x': 1.1.0
|
'@img/sharp-libvips-linux-s390x': 1.1.0
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-linux-s390x@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-linux-s390x': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-linux-x64@0.34.2':
|
'@img/sharp-linux-x64@0.34.2':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@img/sharp-libvips-linux-x64': 1.1.0
|
'@img/sharp-libvips-linux-x64': 1.1.0
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-linux-x64@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-linux-x64': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-linuxmusl-arm64@0.34.2':
|
'@img/sharp-linuxmusl-arm64@0.34.2':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@img/sharp-libvips-linuxmusl-arm64': 1.1.0
|
'@img/sharp-libvips-linuxmusl-arm64': 1.1.0
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-linuxmusl-arm64@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-linuxmusl-arm64': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-linuxmusl-x64@0.34.2':
|
'@img/sharp-linuxmusl-x64@0.34.2':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@img/sharp-libvips-linuxmusl-x64': 1.1.0
|
'@img/sharp-libvips-linuxmusl-x64': 1.1.0
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-linuxmusl-x64@0.34.5':
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-libvips-linuxmusl-x64': 1.2.4
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-wasm32@0.34.2':
|
'@img/sharp-wasm32@0.34.2':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@emnapi/runtime': 1.4.3
|
'@emnapi/runtime': 1.4.3
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-wasm32@0.34.5':
|
||||||
|
dependencies:
|
||||||
|
'@emnapi/runtime': 1.7.1
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-win32-arm64@0.34.2':
|
'@img/sharp-win32-arm64@0.34.2':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-win32-arm64@0.34.5':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-win32-ia32@0.34.2':
|
'@img/sharp-win32-ia32@0.34.2':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-win32-ia32@0.34.5':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@img/sharp-win32-x64@0.34.2':
|
'@img/sharp-win32-x64@0.34.2':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@img/sharp-win32-x64@0.34.5':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@internationalized/date@3.6.0':
|
'@internationalized/date@3.6.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@swc/helpers': 0.5.15
|
'@swc/helpers': 0.5.15
|
||||||
@@ -7475,6 +7790,8 @@ snapshots:
|
|||||||
|
|
||||||
'@next/env@15.3.4': {}
|
'@next/env@15.3.4': {}
|
||||||
|
|
||||||
|
'@next/env@15.5.7': {}
|
||||||
|
|
||||||
'@next/eslint-plugin-next@15.0.3':
|
'@next/eslint-plugin-next@15.0.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
fast-glob: 3.3.1
|
fast-glob: 3.3.1
|
||||||
@@ -7486,27 +7803,51 @@ snapshots:
|
|||||||
'@next/swc-darwin-arm64@15.3.4':
|
'@next/swc-darwin-arm64@15.3.4':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@next/swc-darwin-arm64@15.5.7':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@next/swc-darwin-x64@15.3.4':
|
'@next/swc-darwin-x64@15.3.4':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@next/swc-darwin-x64@15.5.7':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@next/swc-linux-arm64-gnu@15.3.4':
|
'@next/swc-linux-arm64-gnu@15.3.4':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@next/swc-linux-arm64-gnu@15.5.7':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@next/swc-linux-arm64-musl@15.3.4':
|
'@next/swc-linux-arm64-musl@15.3.4':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@next/swc-linux-arm64-musl@15.5.7':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@next/swc-linux-x64-gnu@15.3.4':
|
'@next/swc-linux-x64-gnu@15.3.4':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@next/swc-linux-x64-gnu@15.5.7':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@next/swc-linux-x64-musl@15.3.4':
|
'@next/swc-linux-x64-musl@15.3.4':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@next/swc-linux-x64-musl@15.5.7':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@next/swc-win32-arm64-msvc@15.3.4':
|
'@next/swc-win32-arm64-msvc@15.3.4':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@next/swc-win32-arm64-msvc@15.5.7':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@next/swc-win32-x64-msvc@15.3.4':
|
'@next/swc-win32-x64-msvc@15.3.4':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@next/swc-win32-x64-msvc@15.5.7':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@nextui-org/accordion@2.2.7(@nextui-org/system@2.4.6(@nextui-org/theme@2.4.5(tailwindcss@3.4.17(ts-node@10.9.2(@swc/core@1.10.18(@swc/helpers@0.5.15))(@types/node@20.19.1)(typescript@5.7.3))))(framer-motion@11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@nextui-org/theme@2.4.5(tailwindcss@3.4.17(ts-node@10.9.2(@swc/core@1.10.18(@swc/helpers@0.5.15))(@types/node@20.19.1)(typescript@5.7.3))))(framer-motion@11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
'@nextui-org/accordion@2.2.7(@nextui-org/system@2.4.6(@nextui-org/theme@2.4.5(tailwindcss@3.4.17(ts-node@10.9.2(@swc/core@1.10.18(@swc/helpers@0.5.15))(@types/node@20.19.1)(typescript@5.7.3))))(framer-motion@11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@nextui-org/theme@2.4.5(tailwindcss@3.4.17(ts-node@10.9.2(@swc/core@1.10.18(@swc/helpers@0.5.15))(@types/node@20.19.1)(typescript@5.7.3))))(framer-motion@11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@nextui-org/aria-utils': 2.2.7(@nextui-org/theme@2.4.5(tailwindcss@3.4.17(ts-node@10.9.2(@swc/core@1.10.18(@swc/helpers@0.5.15))(@types/node@20.19.1)(typescript@5.7.3))))(framer-motion@11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
'@nextui-org/aria-utils': 2.2.7(@nextui-org/theme@2.4.5(tailwindcss@3.4.17(ts-node@10.9.2(@swc/core@1.10.18(@swc/helpers@0.5.15))(@types/node@20.19.1)(typescript@5.7.3))))(framer-motion@11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
@@ -11917,6 +12258,9 @@ snapshots:
|
|||||||
detect-libc@2.0.4:
|
detect-libc@2.0.4:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
detect-libc@2.1.2:
|
||||||
|
optional: true
|
||||||
|
|
||||||
devlop@1.1.0:
|
devlop@1.1.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
dequal: 2.0.3
|
dequal: 2.0.3
|
||||||
@@ -13998,6 +14342,29 @@ snapshots:
|
|||||||
- '@babel/core'
|
- '@babel/core'
|
||||||
- babel-plugin-macros
|
- babel-plugin-macros
|
||||||
|
|
||||||
|
next@15.5.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
||||||
|
dependencies:
|
||||||
|
'@next/env': 15.5.7
|
||||||
|
'@swc/helpers': 0.5.15
|
||||||
|
caniuse-lite: 1.0.30001724
|
||||||
|
postcss: 8.4.31
|
||||||
|
react: 18.3.1
|
||||||
|
react-dom: 18.3.1(react@18.3.1)
|
||||||
|
styled-jsx: 5.1.6(react@18.3.1)
|
||||||
|
optionalDependencies:
|
||||||
|
'@next/swc-darwin-arm64': 15.5.7
|
||||||
|
'@next/swc-darwin-x64': 15.5.7
|
||||||
|
'@next/swc-linux-arm64-gnu': 15.5.7
|
||||||
|
'@next/swc-linux-arm64-musl': 15.5.7
|
||||||
|
'@next/swc-linux-x64-gnu': 15.5.7
|
||||||
|
'@next/swc-linux-x64-musl': 15.5.7
|
||||||
|
'@next/swc-win32-arm64-msvc': 15.5.7
|
||||||
|
'@next/swc-win32-x64-msvc': 15.5.7
|
||||||
|
sharp: 0.34.5
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@babel/core'
|
||||||
|
- babel-plugin-macros
|
||||||
|
|
||||||
no-case@2.3.2:
|
no-case@2.3.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
lower-case: 1.1.4
|
lower-case: 1.1.4
|
||||||
@@ -14953,6 +15320,9 @@ snapshots:
|
|||||||
|
|
||||||
semver@7.7.2: {}
|
semver@7.7.2: {}
|
||||||
|
|
||||||
|
semver@7.7.3:
|
||||||
|
optional: true
|
||||||
|
|
||||||
sentence-case@2.1.1:
|
sentence-case@2.1.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
no-case: 2.3.2
|
no-case: 2.3.2
|
||||||
@@ -15013,6 +15383,38 @@ snapshots:
|
|||||||
'@img/sharp-win32-x64': 0.34.2
|
'@img/sharp-win32-x64': 0.34.2
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
sharp@0.34.5:
|
||||||
|
dependencies:
|
||||||
|
'@img/colour': 1.0.0
|
||||||
|
detect-libc: 2.1.2
|
||||||
|
semver: 7.7.3
|
||||||
|
optionalDependencies:
|
||||||
|
'@img/sharp-darwin-arm64': 0.34.5
|
||||||
|
'@img/sharp-darwin-x64': 0.34.5
|
||||||
|
'@img/sharp-libvips-darwin-arm64': 1.2.4
|
||||||
|
'@img/sharp-libvips-darwin-x64': 1.2.4
|
||||||
|
'@img/sharp-libvips-linux-arm': 1.2.4
|
||||||
|
'@img/sharp-libvips-linux-arm64': 1.2.4
|
||||||
|
'@img/sharp-libvips-linux-ppc64': 1.2.4
|
||||||
|
'@img/sharp-libvips-linux-riscv64': 1.2.4
|
||||||
|
'@img/sharp-libvips-linux-s390x': 1.2.4
|
||||||
|
'@img/sharp-libvips-linux-x64': 1.2.4
|
||||||
|
'@img/sharp-libvips-linuxmusl-arm64': 1.2.4
|
||||||
|
'@img/sharp-libvips-linuxmusl-x64': 1.2.4
|
||||||
|
'@img/sharp-linux-arm': 0.34.5
|
||||||
|
'@img/sharp-linux-arm64': 0.34.5
|
||||||
|
'@img/sharp-linux-ppc64': 0.34.5
|
||||||
|
'@img/sharp-linux-riscv64': 0.34.5
|
||||||
|
'@img/sharp-linux-s390x': 0.34.5
|
||||||
|
'@img/sharp-linux-x64': 0.34.5
|
||||||
|
'@img/sharp-linuxmusl-arm64': 0.34.5
|
||||||
|
'@img/sharp-linuxmusl-x64': 0.34.5
|
||||||
|
'@img/sharp-wasm32': 0.34.5
|
||||||
|
'@img/sharp-win32-arm64': 0.34.5
|
||||||
|
'@img/sharp-win32-ia32': 0.34.5
|
||||||
|
'@img/sharp-win32-x64': 0.34.5
|
||||||
|
optional: true
|
||||||
|
|
||||||
shebang-command@2.0.0:
|
shebang-command@2.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
shebang-regex: 3.0.0
|
shebang-regex: 3.0.0
|
||||||
|
|||||||
@@ -380,7 +380,6 @@
|
|||||||
"Enter your password": "Enter your password",
|
"Enter your password": "Enter your password",
|
||||||
"Confirm your password": "Confirm your password",
|
"Confirm your password": "Confirm your password",
|
||||||
"Passwords do not match": "Passwords do not match",
|
"Passwords do not match": "Passwords do not match",
|
||||||
"Password must be at least 8 characters": "Password must be at least 8 characters",
|
|
||||||
"Registration successful": "Registration successful",
|
"Registration successful": "Registration successful",
|
||||||
"Registration failed": "Registration failed",
|
"Registration failed": "Registration failed",
|
||||||
"Email already exists": "Email already exists",
|
"Email already exists": "Email already exists",
|
||||||
@@ -509,7 +508,7 @@
|
|||||||
"API Key Header Name": "API Key Header Name",
|
"API Key Header Name": "API Key Header Name",
|
||||||
"Secret Key format is incorrect, should start with sk_": "Secret Key format is incorrect, should start with sk_",
|
"Secret Key format is incorrect, should start with sk_": "Secret Key format is incorrect, should start with sk_",
|
||||||
"Webhook Secret format is incorrect, should start with whsec_": "Webhook Secret format is incorrect, should start with whsec_",
|
"Webhook Secret format is incorrect, should start with whsec_": "Webhook Secret format is incorrect, should start with whsec_",
|
||||||
"Password must be at least 8 characters long": "Password must be at least 8 characters long",
|
"Password must be at least 6 characters long": "Password must be at least 6 characters long",
|
||||||
"OAuth 2.0 Client Secret (optional, for server-side verification)": "OAuth 2.0 Client Secret (optional, for server-side verification)",
|
"OAuth 2.0 Client Secret (optional, for server-side verification)": "OAuth 2.0 Client Secret (optional, for server-side verification)",
|
||||||
"Authorized redirect URI configured in Google Cloud Console": "Authorized redirect URI configured in Google Cloud Console",
|
"Authorized redirect URI configured in Google Cloud Console": "Authorized redirect URI configured in Google Cloud Console",
|
||||||
"Webhook signing secret for verifying Stripe events": "Webhook signing secret for verifying Stripe events",
|
"Webhook signing secret for verifying Stripe events": "Webhook signing secret for verifying Stripe events",
|
||||||
@@ -774,7 +773,7 @@
|
|||||||
"Re-enter new password": "Re-enter new password",
|
"Re-enter new password": "Re-enter new password",
|
||||||
"Confirm new password": "Confirm new password",
|
"Confirm new password": "Confirm new password",
|
||||||
"New password and confirm password do not match": "New password and confirm password do not match",
|
"New password and confirm password do not match": "New password and confirm password do not match",
|
||||||
"New password must be at least 8 characters long": "New password must be at least 8 characters long",
|
"New password must be at least 6 characters long": "New password must be at least 6 characters long",
|
||||||
"New password and confirm password must be the same": "New password and confirm password must be the same",
|
"New password and confirm password must be the same": "New password and confirm password must be the same",
|
||||||
"New Password": "New Password",
|
"New Password": "New Password",
|
||||||
"Confirm New Password": "Confirm New Password",
|
"Confirm New Password": "Confirm New Password",
|
||||||
@@ -877,5 +876,10 @@
|
|||||||
"Email is required": "Email is required",
|
"Email is required": "Email is required",
|
||||||
"No servers available": "No servers available",
|
"No servers available": "No servers available",
|
||||||
"(Deleted)": "(Deleted)",
|
"(Deleted)": "(Deleted)",
|
||||||
"Transport Type": "Transport Type"
|
"Transport Type": "Transport Type",
|
||||||
|
"Server ID must be less than 255 characters": "Server ID must be less than 255 characters",
|
||||||
|
"Server Name must be less than 255 characters": "Server Name must be less than 255 characters",
|
||||||
|
"API Endpoint must be a valid HTTP/HTTPS URL": "API Endpoint must be a valid HTTP/HTTPS URL",
|
||||||
|
"Server ID is required": "Server ID is required",
|
||||||
|
"Short description is required": "Short description is required"
|
||||||
}
|
}
|
||||||
@@ -300,6 +300,7 @@
|
|||||||
"Overview and analytics": "概览和分析",
|
"Overview and analytics": "概览和分析",
|
||||||
"Manage MCP servers and API tools": "管理MCP服务及API工具",
|
"Manage MCP servers and API tools": "管理MCP服务及API工具",
|
||||||
"Manage registered users": "管理注册用户",
|
"Manage registered users": "管理注册用户",
|
||||||
|
"Manage resource groups": "管理资源组",
|
||||||
"View user recharge history": "查看用户充值历史",
|
"View user recharge history": "查看用户充值历史",
|
||||||
"Configure payment channels": "配置支付渠道",
|
"Configure payment channels": "配置支付渠道",
|
||||||
"Platform basic configuration": "平台基础配置",
|
"Platform basic configuration": "平台基础配置",
|
||||||
@@ -381,7 +382,6 @@
|
|||||||
"Enter your password": "请输入密码",
|
"Enter your password": "请输入密码",
|
||||||
"Confirm your password": "请确认密码",
|
"Confirm your password": "请确认密码",
|
||||||
"Passwords do not match": "密码不匹配",
|
"Passwords do not match": "密码不匹配",
|
||||||
"Password must be at least 8 characters": "密码至少需要8个字符",
|
|
||||||
"Registration successful": "注册成功",
|
"Registration successful": "注册成功",
|
||||||
"Registration failed": "注册失败",
|
"Registration failed": "注册失败",
|
||||||
"Email already exists": "邮箱已存在",
|
"Email already exists": "邮箱已存在",
|
||||||
@@ -510,7 +510,7 @@
|
|||||||
"API Key Header Name": "API密钥头部名称",
|
"API Key Header Name": "API密钥头部名称",
|
||||||
"Secret Key format is incorrect, should start with sk_": "密钥格式不正确,应以sk_开头",
|
"Secret Key format is incorrect, should start with sk_": "密钥格式不正确,应以sk_开头",
|
||||||
"Webhook Secret format is incorrect, should start with whsec_": "Webhook密钥格式不正确,应以whsec_开头",
|
"Webhook Secret format is incorrect, should start with whsec_": "Webhook密钥格式不正确,应以whsec_开头",
|
||||||
"Password must be at least 8 characters long": "密码至少需要8个字符",
|
"Password must be at least 6 characters long": "密码至少需要6个字符",
|
||||||
"OAuth 2.0 Client Secret (optional, for server-side verification)": "OAuth 2.0 客户端密钥(可选,用于服务端验证)",
|
"OAuth 2.0 Client Secret (optional, for server-side verification)": "OAuth 2.0 客户端密钥(可选,用于服务端验证)",
|
||||||
"Authorized redirect URI configured in Google Cloud Console": "在Google Cloud Console中配置的授权重定向URI",
|
"Authorized redirect URI configured in Google Cloud Console": "在Google Cloud Console中配置的授权重定向URI",
|
||||||
"Webhook signing secret for verifying Stripe events": "用于验证Stripe事件的Webhook签名密钥",
|
"Webhook signing secret for verifying Stripe events": "用于验证Stripe事件的Webhook签名密钥",
|
||||||
@@ -625,6 +625,8 @@
|
|||||||
"MCP Config": "MCP配置",
|
"MCP Config": "MCP配置",
|
||||||
"Copy full config": "复制完整配置",
|
"Copy full config": "复制完整配置",
|
||||||
"Analytics": "分析",
|
"Analytics": "分析",
|
||||||
|
"Resource Group": "资源组",
|
||||||
|
"Manage Your Resource Groups": "管理您的资源组",
|
||||||
"Times": "次",
|
"Times": "次",
|
||||||
"No analytics data available": "无可用分析数据",
|
"No analytics data available": "无可用分析数据",
|
||||||
"Delete Auth Key": "删除认证密钥",
|
"Delete Auth Key": "删除认证密钥",
|
||||||
@@ -776,7 +778,7 @@
|
|||||||
"Re-enter new password": "重新输入新密码",
|
"Re-enter new password": "重新输入新密码",
|
||||||
"Confirm new password": "确认新密码",
|
"Confirm new password": "确认新密码",
|
||||||
"New password and confirm password do not match": "新密码和确认密码不匹配",
|
"New password and confirm password do not match": "新密码和确认密码不匹配",
|
||||||
"New password must be at least 8 characters long": "新密码至少需要8个字符",
|
"New password must be at least 6 characters long": "新密码至少需要6个字符",
|
||||||
"New password and confirm password must be the same": "新密码和确认密码必须相同",
|
"New password and confirm password must be the same": "新密码和确认密码必须相同",
|
||||||
"New Password": "新密码",
|
"New Password": "新密码",
|
||||||
"Confirm New Password": "确认新密码",
|
"Confirm New Password": "确认新密码",
|
||||||
@@ -879,5 +881,61 @@
|
|||||||
"Email is required": "邮箱为必填项",
|
"Email is required": "邮箱为必填项",
|
||||||
"No servers available": "没有可用服务",
|
"No servers available": "没有可用服务",
|
||||||
"(Deleted)": "(已删除)",
|
"(Deleted)": "(已删除)",
|
||||||
"Transport Type": "传输方式"
|
"Transport Type": "传输方式",
|
||||||
|
"Server ID must be less than 255 characters": "Server ID 必须少于255个字符",
|
||||||
|
"Server Name must be less than 255 characters": "Server Name 必须少于255个字符",
|
||||||
|
"API Endpoint must be a valid HTTP/HTTPS URL": "API Endpoint 必须是一个有效的HTTP/HTTPS URL",
|
||||||
|
"Server ID is required": "Server ID 为必填项",
|
||||||
|
"Short description is required": "简短描述为必填项",
|
||||||
|
"Add": "添加",
|
||||||
|
"Add to Groups": "添加到资源组",
|
||||||
|
"Group Name": "资源组名称",
|
||||||
|
"No resource groups available": "没有可用资源组",
|
||||||
|
"Failed to load group services": "加载资源组服务失败",
|
||||||
|
"Resource group deleted successfully": "资源组删除成功",
|
||||||
|
"Added Time": "添加时间",
|
||||||
|
"No services in this group": "此资源组没有服务",
|
||||||
|
"Open Resource Group Page": "打开资源组页面",
|
||||||
|
"Remove": "删除",
|
||||||
|
"Confirm Remove": "确认删除",
|
||||||
|
"Are you sure you want to remove this \"{{name}}\" mcp server from \"{{groupName}}\" resource group?": "您确定要从 \"{{groupName}}\" 资源组中移除 \"{{name}}\" MCP 服务吗?",
|
||||||
|
"Users associated with this resource group will not be able to call the removed MCP server": "与该资源组关联的用户将无法调用已移除的 MCP 服务",
|
||||||
|
"You don't have permission to access this MCP server.": "您没有权限访问此 MCP 服务。",
|
||||||
|
"Failed to load resource groups": "加载资源组失败",
|
||||||
|
"Failed to delete resource group": "删除资源组失败",
|
||||||
|
"Failed to add service to group": "添加服务到资源组失败",
|
||||||
|
"Resource group created successfully": "资源组创建成功",
|
||||||
|
"Resource group updated successfully": "资源组更新成功",
|
||||||
|
"Services added successfully": "服务添加成功",
|
||||||
|
"Service removed successfully": "服务移除成功",
|
||||||
|
"Select resource group": "选择资源组",
|
||||||
|
"Manage your resource group. Each user has a resource group and can only access resources within their resource group": "管理您的资源组。每个用户都有一个资源组,并且只能访问其资源组内的资源",
|
||||||
|
"Please select a group to view services": "请选择一个资源组来查看服务",
|
||||||
|
"Are you sure you want to remove this \"{{name}}\" Resource Group?": "您确定要删除这个 \"{{name}}\" 资源组吗?",
|
||||||
|
"The bound users have been transferred to the following resource group": "与该资源组关联的用户已转移至以下资源组",
|
||||||
|
"Service Name": "服务名称",
|
||||||
|
"Group List": "资源组列表",
|
||||||
|
"No groups found": "没有找到资源组",
|
||||||
|
"No more groups": "没有更多资源组",
|
||||||
|
"Are you sure you want to delete this item? This action cannot be undone.": "您确定要删除这个项目吗?此操作无法撤销。",
|
||||||
|
"Create New Resource Group": "创建新资源组",
|
||||||
|
"Edit Resource Group": "编辑资源组",
|
||||||
|
"Edit Resource Group Name": "编辑资源组名称",
|
||||||
|
"Set as default": "设置为默认",
|
||||||
|
"Automatically bind default resource groups when adding users": "添加用户时自动绑定默认资源组",
|
||||||
|
"Add MCP Server": "添加 MCP 服务",
|
||||||
|
"No MCP services available": "没有可用的 MCP 服务",
|
||||||
|
"Resource Groups": "资源组",
|
||||||
|
"Resource Group Name": "资源组名称",
|
||||||
|
"Failed to remove service from group": "从资源组中移除服务失败",
|
||||||
|
"Failed to update resource group": "更新资源组失败",
|
||||||
|
"Failed to create resource group": "创建资源组失败",
|
||||||
|
"Failed to fetch simple mcp services": "获取简易MCP服务失败",
|
||||||
|
"Failed to fetch group services": "获取资源组服务失败",
|
||||||
|
"Failed to update user resource group": "更新用户资源组失败",
|
||||||
|
"Failed to load simple resource groups": "获取简易资源组失败",
|
||||||
|
"Failed to load resource group detail": "获取资源组详情失败",
|
||||||
|
"Resource Group Detail": "资源组详情",
|
||||||
|
"Current display time is UTC time": "当前显示时间为UTC时间",
|
||||||
|
"View Resource Group Detail": "查看资源组详情"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,291 @@
|
|||||||
|
import { SimpleMcpService } from "@/components/resource-group/AddMcpServerModal";
|
||||||
|
import { GroupService } from "@/components/resource-group/GroupServiceTable";
|
||||||
|
import { fetchAdminAPI } from "@/rpc/admin-api";
|
||||||
|
import { toast } from "react-hot-toast";
|
||||||
|
import i18n from "@/shared/lib/i18n";
|
||||||
|
|
||||||
|
export interface ResourceGroupResponse {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
is_default: boolean;
|
||||||
|
service_count: number;
|
||||||
|
create_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResourceGroupDetailResponse {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
is_default: boolean;
|
||||||
|
update_at: number;
|
||||||
|
create_at: string;
|
||||||
|
}
|
||||||
|
export interface ResourceGroupListResponse {
|
||||||
|
data: ResourceGroupResponse[];
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
page_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GroupServiceListResponse {
|
||||||
|
data: GroupService[];
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
page_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SimpleMcpServiceListResponse {
|
||||||
|
data: SimpleMcpService[];
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
page_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const fetchResourceGroupDetail = async (groupId: string): Promise<ResourceGroupDetailResponse | null> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<ResourceGroupDetailResponse>(`/api/resource_group/info?id=${groupId}`);
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to load resource group detail"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return response.data || null;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching resource group detail:", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 获取资源组列表
|
||||||
|
*/
|
||||||
|
export const fetchResourceGroups = async (page: number, page_size: number, keyword: string): Promise<ResourceGroupListResponse> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<ResourceGroupResponse[]>(`/api/resource_group/list?page=${page}&page_size=${page_size}&keyword=${keyword}`);
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to load resource groups"));
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
total: 0,
|
||||||
|
page,
|
||||||
|
page_size,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
data: response.data || [],
|
||||||
|
total: response.page?.total || 0,
|
||||||
|
page: response.page?.page || page,
|
||||||
|
page_size: response.page?.page_size || page_size,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching auth keys:", error);
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
total: 0,
|
||||||
|
page,
|
||||||
|
page_size,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 获取简易资源组列表
|
||||||
|
*/
|
||||||
|
export const fetchSimpleResourceGroups = async (): Promise<{ id: string, name: string }[]> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<{ id: string, name: string }[]>(`/api/resource_group/list/simple`);
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to load simple resource groups"));
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return response.data || []
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching auth keys:", error);
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户资源组
|
||||||
|
*/
|
||||||
|
export const updateUserResourceGroup = async (userId: string, resourceGroupId: string): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<boolean>(`/api/user_manager/resource_group`, {
|
||||||
|
method: "PUT",
|
||||||
|
body: { user_id: userId, resource_group: resourceGroupId } as unknown as BodyInit,
|
||||||
|
});
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to update user resource group"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating user resource group:", error);
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定资源组下的服务列表
|
||||||
|
*/
|
||||||
|
export const fetchGroupServices = async (id: string,page: number, page_size: number, keyword: string): Promise<GroupServiceListResponse> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<GroupService[]>(`/api/resource_group/service/list?id=${id}&page=${page}&page_size=${page_size}&keyword=${keyword}`);
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to fetch group services"));
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
total: 0,
|
||||||
|
page,
|
||||||
|
page_size,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
data: response.data || [],
|
||||||
|
total: response.page?.total || 0,
|
||||||
|
page: response.page?.page || page,
|
||||||
|
page_size: response.page?.page_size || page_size,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching auth keys:", error);
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
total: 0,
|
||||||
|
page,
|
||||||
|
page_size,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取简易指定资源组下的服务列表
|
||||||
|
*/
|
||||||
|
export const fetchSimpleMcpServices = async (id: string): Promise<SimpleMcpService[]> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<SimpleMcpService[]>(`/api/resource_group/service/list/unbind?id=${id}`);
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to fetch simple mcp services"));
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return response.data || []
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching auth keys:", error);
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建资源组
|
||||||
|
*/
|
||||||
|
export const createResourceGroup = async (name: string, isDefault: boolean): Promise<{success: boolean, id: string}> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<{id: string}>(`/api/resource_group`, {
|
||||||
|
method: "POST",
|
||||||
|
body: { name: name, is_default: isDefault } as unknown as BodyInit,
|
||||||
|
});
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to create resource group"));
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
id: "",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
id: response.data?.id || "",
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
id: "",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新资源组
|
||||||
|
*/
|
||||||
|
export const updateResourceGroup = async (
|
||||||
|
groupId: string,
|
||||||
|
name: string,
|
||||||
|
isDefault: boolean
|
||||||
|
): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<boolean>(`/api/resource_group?id=${groupId}`, {
|
||||||
|
method: "PUT",
|
||||||
|
body: { name: name, is_default: isDefault } as unknown as BodyInit,
|
||||||
|
});
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to update resource group"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资源组
|
||||||
|
*/
|
||||||
|
export const deleteResourceGroup = async (
|
||||||
|
groupId: string,
|
||||||
|
transferToGroupId: string
|
||||||
|
): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<boolean>(`/api/resource_group?id=${groupId}&migrate_id=${transferToGroupId}`, {
|
||||||
|
method: "DELETE"
|
||||||
|
});
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to delete resource group"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从资源组中移除服务
|
||||||
|
*/
|
||||||
|
export const removeServiceFromGroup = async (
|
||||||
|
groupId: string,
|
||||||
|
serviceIds: string[]
|
||||||
|
): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<boolean>(`/api/resource_group/service?id=${groupId}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
body: { services: serviceIds } as unknown as BodyInit,
|
||||||
|
});
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to remove service from group"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加服务到资源组
|
||||||
|
*/
|
||||||
|
export const addServiceToGroup = async (
|
||||||
|
groupId: string,
|
||||||
|
services: string[]
|
||||||
|
): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<boolean>(`/api/resource_group/service?id=${groupId}`, {
|
||||||
|
method: "PUT",
|
||||||
|
body: { services: services } as unknown as BodyInit,
|
||||||
|
});
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to add service to group"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@@ -48,8 +48,8 @@ export const ChangePasswordModal: React.FC<ChangePasswordModalProps> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newPassword.length < 8) {
|
if (newPassword.length < 6) {
|
||||||
toast.error(t("Password must be at least 8 characters long"));
|
toast.error(t("Password must be at least 6 characters long"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ export const ChangePasswordModal: React.FC<ChangePasswordModalProps> = ({
|
|||||||
newPassword.trim() !== "" &&
|
newPassword.trim() !== "" &&
|
||||||
confirmPassword.trim() !== "" &&
|
confirmPassword.trim() !== "" &&
|
||||||
newPassword === confirmPassword &&
|
newPassword === confirmPassword &&
|
||||||
newPassword.length >= 8;
|
newPassword.length >= 6;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} onClose={handleClose} size="md">
|
<Modal isOpen={isOpen} onClose={handleClose} size="md">
|
||||||
@@ -90,7 +90,7 @@ export const ChangePasswordModal: React.FC<ChangePasswordModalProps> = ({
|
|||||||
type={showNewPassword ? "text" : "password"}
|
type={showNewPassword ? "text" : "password"}
|
||||||
value={newPassword}
|
value={newPassword}
|
||||||
onChange={(e) => setNewPassword(e.target.value)}
|
onChange={(e) => setNewPassword(e.target.value)}
|
||||||
description={t("Password must be at least 8 characters long")}
|
description={t("Password must be at least 6 characters long")}
|
||||||
endContent={
|
endContent={
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ const formSchema = z.object({
|
|||||||
.string()
|
.string()
|
||||||
.min(1, "Password is required")
|
.min(1, "Password is required")
|
||||||
.max(100, "Password is too long")
|
.max(100, "Password is too long")
|
||||||
.min(8, "Password must be at least 8 characters"),
|
.min(6, "Password must be at least 6 characters"),
|
||||||
confirmPassword: z
|
confirmPassword: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, "Confirm password is required")
|
.min(1, "Confirm password is required")
|
||||||
.max(100, "Confirm password is too long")
|
.max(100, "Confirm password is too long")
|
||||||
.min(8, "Confirm password must be at least 8 characters"),
|
.min(6, "Confirm password must be at least 6 characters"),
|
||||||
});
|
});
|
||||||
type FormData = z.infer<typeof formSchema>;
|
type FormData = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({ onSave }) => {
|
|||||||
{...field}
|
{...field}
|
||||||
label={t("Administrator Password")}
|
label={t("Administrator Password")}
|
||||||
placeholder={t("Enter administrator password")}
|
placeholder={t("Enter administrator password")}
|
||||||
description={t("Password must be at least 8 characters long")}
|
description={t("Password must be at least 6 characters long")}
|
||||||
isInvalid={!!errors.password}
|
isInvalid={!!errors.password}
|
||||||
errorMessage={errors.password?.message}
|
errorMessage={errors.password?.message}
|
||||||
type={showPassword ? "text" : "password"}
|
type={showPassword ? "text" : "password"}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import UserManagement from "@/components/user-management/UserManagement";
|
|||||||
import RevenueManagement from "@/components/revenue-management/RevenueManagement";
|
import RevenueManagement from "@/components/revenue-management/RevenueManagement";
|
||||||
import ConsoleSidebar from "./Sidebar";
|
import ConsoleSidebar from "./Sidebar";
|
||||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||||
import { DollarSign, Home, ServerIcon, Users } from "lucide-react";
|
import { Boxes, DollarSign, Home, ServerIcon, Users } from "lucide-react";
|
||||||
import OnboardingWelcome, { REQUIRED_TASK_KEYS } from "./OnboardingWelcome";
|
import OnboardingWelcome, { REQUIRED_TASK_KEYS } from "./OnboardingWelcome";
|
||||||
import ConsoleStats from "./ConsoleStats";
|
import ConsoleStats from "./ConsoleStats";
|
||||||
import SystemSettingsModal from "./SystemSettingsModal";
|
import SystemSettingsModal from "./SystemSettingsModal";
|
||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
TaskStatusEnum,
|
TaskStatusEnum,
|
||||||
updateAdminOnboardingTasks,
|
updateAdminOnboardingTasks,
|
||||||
} from "@/api/onboard.api";
|
} from "@/api/onboard.api";
|
||||||
|
import ResourceGroupManagement from "../resource-group/resourceGroup";
|
||||||
|
|
||||||
const ConsoleContent: React.FC = () => {
|
const ConsoleContent: React.FC = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -36,7 +37,7 @@ const ConsoleContent: React.FC = () => {
|
|||||||
const tabFromUrl = searchParams.get("tab") as TabKey;
|
const tabFromUrl = searchParams.get("tab") as TabKey;
|
||||||
if (
|
if (
|
||||||
tabFromUrl &&
|
tabFromUrl &&
|
||||||
["mcp-services", "user-management", "revenue-management"].includes(
|
["mcp-services", "user-management", "revenue-management", "resource-group"].includes(
|
||||||
tabFromUrl
|
tabFromUrl
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -74,6 +75,12 @@ const ConsoleContent: React.FC = () => {
|
|||||||
label: t("User"),
|
label: t("User"),
|
||||||
description: t("Manage registered users"),
|
description: t("Manage registered users"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: TabKey.RESOURCE_GROUP,
|
||||||
|
icon: <Boxes size={18} />,
|
||||||
|
label: t("Resource Group"),
|
||||||
|
description: t("Manage resource groups"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: TabKey.REVENUE_MANAGEMENT,
|
key: TabKey.REVENUE_MANAGEMENT,
|
||||||
icon: <DollarSign size={18} />,
|
icon: <DollarSign size={18} />,
|
||||||
@@ -218,6 +225,12 @@ const ConsoleContent: React.FC = () => {
|
|||||||
<RevenueManagement />
|
<RevenueManagement />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
case TabKey.RESOURCE_GROUP:
|
||||||
|
return (
|
||||||
|
<div className="h-full overflow-auto">
|
||||||
|
<ResourceGroupManagement />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return showOnboarding ? (
|
return showOnboarding ? (
|
||||||
<OnboardingWelcome
|
<OnboardingWelcome
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ import { useTranslation } from "@/shared/lib/useTranslation";
|
|||||||
interface CustomDomainPanelProps {
|
interface CustomDomainPanelProps {
|
||||||
domain: string;
|
domain: string;
|
||||||
setDomain: (domain: string) => void;
|
setDomain: (domain: string) => void;
|
||||||
|
onValidationChange?: (isValid: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CustomDomainPanel: React.FC<CustomDomainPanelProps> = ({
|
const CustomDomainPanel: React.FC<CustomDomainPanelProps> = ({
|
||||||
domain,
|
domain,
|
||||||
setDomain,
|
setDomain,
|
||||||
|
onValidationChange,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [validationError, setValidationError] = useState<string | undefined>();
|
const [validationError, setValidationError] = useState<string | undefined>();
|
||||||
@@ -24,7 +26,7 @@ const CustomDomainPanel: React.FC<CustomDomainPanelProps> = ({
|
|||||||
|
|
||||||
// Basic domain format validation ,like www.example.com
|
// Basic domain format validation ,like www.example.com
|
||||||
const domainRegex =
|
const domainRegex =
|
||||||
/(?=.{1,255}$)(?:(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,}/;
|
/^(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,})$/;
|
||||||
if (!domainRegex.test(value)) {
|
if (!domainRegex.test(value)) {
|
||||||
return t("Please enter a valid domain");
|
return t("Please enter a valid domain");
|
||||||
}
|
}
|
||||||
@@ -34,6 +36,17 @@ const CustomDomainPanel: React.FC<CustomDomainPanelProps> = ({
|
|||||||
const handleBlur = () => {
|
const handleBlur = () => {
|
||||||
const error = validateDomain(domain);
|
const error = validateDomain(domain);
|
||||||
setValidationError(error);
|
setValidationError(error);
|
||||||
|
// 通知父组件校验状态
|
||||||
|
onValidationChange?.(!error);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const value = e.target.value;
|
||||||
|
setDomain(value);
|
||||||
|
// 实时校验
|
||||||
|
const error = validateDomain(value);
|
||||||
|
setValidationError(error);
|
||||||
|
onValidationChange?.(!error);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -48,7 +61,7 @@ const CustomDomainPanel: React.FC<CustomDomainPanelProps> = ({
|
|||||||
label={t("Domain")}
|
label={t("Domain")}
|
||||||
placeholder={t("Enter your full domain name (e.g., www.example.com)")}
|
placeholder={t("Enter your full domain name (e.g., www.example.com)")}
|
||||||
value={domain}
|
value={domain}
|
||||||
onChange={(e) => setDomain(e.target.value)}
|
onChange={handleChange}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
isInvalid={!!validationError}
|
isInvalid={!!validationError}
|
||||||
errorMessage={validationError}
|
errorMessage={validationError}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ const DomainActivationPanel: React.FC<DomainActivationPanelProps> = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [domain, setDomain] = useState(config.domain || "");
|
const [domain, setDomain] = useState(config.domain || "");
|
||||||
|
const [isValidDomain, setIsValidDomain] = useState(false);
|
||||||
|
|
||||||
const handleActivate = async () => {
|
const handleActivate = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
@@ -54,7 +56,11 @@ const DomainActivationPanel: React.FC<DomainActivationPanelProps> = ({
|
|||||||
<ModalContent>
|
<ModalContent>
|
||||||
<ModalHeader>{t("Set Custom Domain")}</ModalHeader>
|
<ModalHeader>{t("Set Custom Domain")}</ModalHeader>
|
||||||
<ModalBody className="flex flex-col gap-4">
|
<ModalBody className="flex flex-col gap-4">
|
||||||
<CustomDomainPanel domain={domain} setDomain={setDomain} />
|
<CustomDomainPanel
|
||||||
|
domain={domain}
|
||||||
|
setDomain={setDomain}
|
||||||
|
onValidationChange={setIsValidDomain}
|
||||||
|
/>
|
||||||
<DNSRecordsPanel
|
<DNSRecordsPanel
|
||||||
cnameTarget={`${config.subdomain || ""}${process.env.NEXT_PUBLIC_DOMAIN_HOST || ""}`}
|
cnameTarget={`${config.subdomain || ""}${process.env.NEXT_PUBLIC_DOMAIN_HOST || ""}`}
|
||||||
apexATarget={config.cname_a_ip}
|
apexATarget={config.cname_a_ip}
|
||||||
@@ -67,7 +73,7 @@ const DomainActivationPanel: React.FC<DomainActivationPanelProps> = ({
|
|||||||
</h3>
|
</h3>
|
||||||
<Button
|
<Button
|
||||||
color="primary"
|
color="primary"
|
||||||
isDisabled={!domain}
|
isDisabled={!domain || !isValidDomain}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
onPress={handleActivate}
|
onPress={handleActivate}
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { ToolsTab } from "@/shared/components/mcp-services/ToolsTab";
|
|||||||
import { OpenAPIGeneratorModal } from "@/shared/components/mcp-services/OpenAPIGeneratorModal";
|
import { OpenAPIGeneratorModal } from "@/shared/components/mcp-services/OpenAPIGeneratorModal";
|
||||||
import { ChargeType } from "@/shared/types/marketplace";
|
import { ChargeType } from "@/shared/types/marketplace";
|
||||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||||
|
import ResourceGroup from "@/shared/components/mcp-services/ResourceGroup";
|
||||||
|
|
||||||
const _DefaultFormData: MCPServiceFormData = {
|
const _DefaultFormData: MCPServiceFormData = {
|
||||||
id: "",
|
id: "",
|
||||||
@@ -34,6 +35,60 @@ const _DefaultFormData: MCPServiceFormData = {
|
|||||||
apis: [],
|
apis: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper function to validate URL
|
||||||
|
const isValidUrl = (url: string) => {
|
||||||
|
if (!url) return false;
|
||||||
|
try {
|
||||||
|
const parsed = new URL(url);
|
||||||
|
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper function to validate domain format
|
||||||
|
const isValidDomain = (url: string) => {
|
||||||
|
if (!url) return false;
|
||||||
|
try {
|
||||||
|
const parsed = new URL(url);
|
||||||
|
const hostname = parsed.hostname;
|
||||||
|
const domainRegex = /^(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,})$/;
|
||||||
|
return domainRegex.test(hostname);
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const validateServiceForm = (data: MCPServiceFormData, t: any) => {
|
||||||
|
const errors: Record<string, string> = {};
|
||||||
|
|
||||||
|
if (!data.slug_name?.trim()) {
|
||||||
|
errors.slug_name = t("Server ID is required");
|
||||||
|
} else if (data.slug_name.length > 255) {
|
||||||
|
errors.slug_name = t("Server ID must be less than 255 characters");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.name?.trim()) {
|
||||||
|
errors.name = t("Server name is required");
|
||||||
|
} else if (data.name.length > 255) {
|
||||||
|
errors.name = t("Server Name must be less than 255 characters");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.base_url?.trim()) {
|
||||||
|
errors.base_url = t("API Endpoint is required");
|
||||||
|
} else if (!isValidUrl(data.base_url)) {
|
||||||
|
errors.base_url = t("API Endpoint must be a valid HTTP/HTTPS URL");
|
||||||
|
} else if (!isValidDomain(data.base_url)) {
|
||||||
|
errors.base_url = t("API Endpoint must contain a valid domain name");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.short_description?.trim()) {
|
||||||
|
errors.short_description = t("Short description is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors;
|
||||||
|
};
|
||||||
|
|
||||||
interface ServiceEditPageProps {
|
interface ServiceEditPageProps {
|
||||||
serviceId?: string;
|
serviceId?: string;
|
||||||
onSave: (data: MCPServiceFormData, isDraft?: boolean) => void;
|
onSave: (data: MCPServiceFormData, isDraft?: boolean) => void;
|
||||||
@@ -59,6 +114,9 @@ const BaseServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
|||||||
getServiceDetail,
|
getServiceDetail,
|
||||||
clearServiceDetail,
|
clearServiceDetail,
|
||||||
parseOpenAPIDocumentForUpdate,
|
parseOpenAPIDocumentForUpdate,
|
||||||
|
fetchMCPResourceGroups,
|
||||||
|
deleteResourceGroup,
|
||||||
|
addServiceToGroup,
|
||||||
updateLoading,
|
updateLoading,
|
||||||
} = useMCPServiceDetail();
|
} = useMCPServiceDetail();
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
@@ -193,24 +251,41 @@ const BaseServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper function to validate price string
|
||||||
|
const isValidPrice = (priceStr: string | undefined): boolean => {
|
||||||
|
if (!priceStr || priceStr.trim() === "") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const numValue = parseFloat(priceStr);
|
||||||
|
return !isNaN(numValue) && numValue >= 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const validationErrors = validateServiceForm(formData, t);
|
||||||
|
|
||||||
const isFormValid = () => {
|
const isFormValid = () => {
|
||||||
const hasBasicInfo =
|
if (Object.keys(validationErrors).length > 0) {
|
||||||
formData.name.trim() &&
|
return false;
|
||||||
formData.short_description?.trim() &&
|
}
|
||||||
formData.slug_name?.trim() &&
|
|
||||||
formData.base_url?.trim();
|
|
||||||
|
|
||||||
// if free, no need to validate price
|
// if free, no need to validate price
|
||||||
if (formData.charge_type === ChargeType.Free) {
|
if (formData.charge_type === ChargeType.Free) {
|
||||||
return hasBasicInfo;
|
return true;
|
||||||
|
}
|
||||||
|
// if PerCall, validate price
|
||||||
|
if (formData.charge_type === ChargeType.PerCall) {
|
||||||
|
return isValidPrice(formData.price);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if PerToken, validate both input and output token prices
|
||||||
|
if (formData.charge_type === ChargeType.PerToken) {
|
||||||
|
return (
|
||||||
|
isValidPrice(formData.input_token_price) &&
|
||||||
|
isValidPrice(formData.output_token_price)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if paid, need to validate price
|
// if paid, need to validate price
|
||||||
return (
|
return formData.price !== undefined && formData.price.trim() !== "";
|
||||||
hasBasicInfo &&
|
|
||||||
formData.price !== undefined &&
|
|
||||||
formData.price.trim() !== ""
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -299,6 +374,7 @@ const BaseServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
|||||||
onInputChange={handleInputChange}
|
onInputChange={handleInputChange}
|
||||||
onAddTag={handleAddTag}
|
onAddTag={handleAddTag}
|
||||||
onRemoveTag={handleRemoveTag}
|
onRemoveTag={handleRemoveTag}
|
||||||
|
errors={validationErrors}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-[400px] max-w-[1/2]">
|
<div className="w-[400px] max-w-[1/2]">
|
||||||
@@ -324,6 +400,16 @@ const BaseServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
<Tab key="ResourceGroups" title={t("Resource Groups")}>
|
||||||
|
<div className="pt-2 h-full">
|
||||||
|
<ResourceGroup
|
||||||
|
formData={formData}
|
||||||
|
deleteResourceGroup={deleteResourceGroup}
|
||||||
|
fetchMCPResourceGroups={fetchMCPResourceGroups}
|
||||||
|
addServiceToGroup={addServiceToGroup}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,175 @@
|
|||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Modal,
|
||||||
|
ModalBody,
|
||||||
|
ModalContent,
|
||||||
|
ModalFooter,
|
||||||
|
ModalHeader,
|
||||||
|
Table,
|
||||||
|
TableHeader,
|
||||||
|
TableColumn,
|
||||||
|
TableBody,
|
||||||
|
TableRow,
|
||||||
|
TableCell,
|
||||||
|
Chip,
|
||||||
|
Spinner,
|
||||||
|
} from "@nextui-org/react";
|
||||||
|
import { useState, useEffect, useCallback } from "react";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
import { ChargeType } from "@/shared/types/marketplace";
|
||||||
|
import { fetchSimpleMcpServices } from "@/api/resourceGroup.api";
|
||||||
|
import { Price } from "@/shared/components/marketplace/Price";
|
||||||
|
|
||||||
|
interface AddMcpServerModalProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
onSaveMcpServer: (serverIds: string[]) => Promise<void>;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SimpleMcpService {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
base_url: string;
|
||||||
|
charge_type: ChargeType;
|
||||||
|
price: string;
|
||||||
|
enabled: boolean;
|
||||||
|
input_token_price?: string;
|
||||||
|
output_token_price?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AddMcpServerModal: React.FC<AddMcpServerModalProps> = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
onSaveMcpServer,
|
||||||
|
id,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [services, setServices] = useState<SimpleMcpService[]>([]);
|
||||||
|
const [selectedKeys, setSelectedKeys] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
|
// 加载服务列表
|
||||||
|
const loadServices = useCallback(async (id: string) => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await fetchSimpleMcpServices(id);
|
||||||
|
setServices(response);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load MCP services:", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 当模态框打开时加载数据
|
||||||
|
useEffect(() => {
|
||||||
|
if (isOpen) {
|
||||||
|
setSelectedKeys(new Set());
|
||||||
|
loadServices(id);
|
||||||
|
}
|
||||||
|
}, [isOpen, loadServices]);
|
||||||
|
|
||||||
|
// 处理保存
|
||||||
|
const handleSave = async () => {
|
||||||
|
const serverIds = typeof selectedKeys === 'string' && selectedKeys === 'all' ? services.map((service) => service.id) : Array.from(selectedKeys);
|
||||||
|
if (serverIds.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLoading(true);
|
||||||
|
try {
|
||||||
|
await onSaveMcpServer(serverIds);
|
||||||
|
onClose();
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal isOpen={isOpen} onClose={onClose} size="5xl" scrollBehavior="inside">
|
||||||
|
<ModalContent>
|
||||||
|
{() => (
|
||||||
|
<>
|
||||||
|
<ModalHeader className="flex flex-col gap-1">
|
||||||
|
{t("Add MCP Server")}
|
||||||
|
</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<Table
|
||||||
|
aria-label="MCP services selection table"
|
||||||
|
selectionMode="multiple"
|
||||||
|
selectedKeys={selectedKeys}
|
||||||
|
onSelectionChange={(keys) => setSelectedKeys(keys as Set<string>)}
|
||||||
|
removeWrapper
|
||||||
|
classNames={{
|
||||||
|
wrapper: "min-h-[400px]",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TableHeader>
|
||||||
|
<TableColumn>{t("Service Name")}</TableColumn>
|
||||||
|
<TableColumn>{t("API Endpoint")}</TableColumn>
|
||||||
|
<TableColumn>{t("Status")}</TableColumn>
|
||||||
|
<TableColumn>{t("Pricing")}</TableColumn>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody
|
||||||
|
items={services}
|
||||||
|
isLoading={loading}
|
||||||
|
loadingContent={<Spinner />}
|
||||||
|
emptyContent={t("No MCP services available")}
|
||||||
|
>
|
||||||
|
{(service) => (
|
||||||
|
<TableRow key={service.id}>
|
||||||
|
<TableCell>
|
||||||
|
<span className="text-sm">{service.name}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<span className="text-sm">{service.base_url}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Chip
|
||||||
|
className="capitalize"
|
||||||
|
color={service.enabled ? "success" : "danger"}
|
||||||
|
size="sm"
|
||||||
|
variant="flat"
|
||||||
|
>
|
||||||
|
{t(service.enabled ? "Published" : "Unpublished")}
|
||||||
|
</Chip>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Price
|
||||||
|
price={service.price}
|
||||||
|
charge_type={service.charge_type}
|
||||||
|
input_token_price={service.input_token_price}
|
||||||
|
output_token_price={service.output_token_price}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button
|
||||||
|
color="danger"
|
||||||
|
variant="light"
|
||||||
|
onPress={onClose}
|
||||||
|
isDisabled={isLoading}
|
||||||
|
>
|
||||||
|
{t("Close")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
onPress={handleSave}
|
||||||
|
isLoading={isLoading}
|
||||||
|
isDisabled={selectedKeys.size === 0}
|
||||||
|
>
|
||||||
|
{t("Add")}
|
||||||
|
</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import { Button, Input, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Switch } from "@nextui-org/react"
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
interface AddServerModalProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
name: string;
|
||||||
|
onSaveServer: (name: string, isDefault: boolean) => Promise<void>;
|
||||||
|
type: "add" | "edit";
|
||||||
|
isDefault: boolean;
|
||||||
|
}
|
||||||
|
export const AddServerModal: React.FC<AddServerModalProps> = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
name,
|
||||||
|
onSaveServer,
|
||||||
|
type,
|
||||||
|
isDefault,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [serverName, setServerName] = useState(name);
|
||||||
|
const [isEnabledState, setIsEnabledState] = useState(isDefault);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
// 当 name prop 或 isOpen 变化时,更新内部状态
|
||||||
|
useEffect(() => {
|
||||||
|
if (isOpen) {
|
||||||
|
setServerName(name);
|
||||||
|
setIsEnabledState(isDefault);
|
||||||
|
setIsLoading(false); // 重置 loading 状态
|
||||||
|
}
|
||||||
|
}, [name, isOpen, isDefault]);
|
||||||
|
|
||||||
|
// 处理保存
|
||||||
|
const handleSave = async () => {
|
||||||
|
setIsLoading(true);
|
||||||
|
try {
|
||||||
|
await onSaveServer(serverName, isEnabledState);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Modal isOpen={isOpen} onClose={onClose} size="2xl">
|
||||||
|
<ModalContent>
|
||||||
|
{() => (
|
||||||
|
<>
|
||||||
|
<ModalHeader className="flex flex-col gap-1">
|
||||||
|
{type === "add" ? t("Create New Resource Group") : t("Edit Resource Group")}
|
||||||
|
</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<Input
|
||||||
|
label={t("Resource Group Name")}
|
||||||
|
value={serverName}
|
||||||
|
placeholder={t("Edit Resource Group Name")}
|
||||||
|
onChange={(e) => setServerName(e.target.value)}
|
||||||
|
/>
|
||||||
|
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<span className="text-sm font-medium">
|
||||||
|
{t("Set as default")}
|
||||||
|
</span>
|
||||||
|
<span className="text-xs text-gray-500">
|
||||||
|
{t("Automatically bind default resource groups when adding users")}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
isSelected={isEnabledState || false}
|
||||||
|
onValueChange={setIsEnabledState}
|
||||||
|
color="primary"
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button
|
||||||
|
color="danger"
|
||||||
|
variant="light"
|
||||||
|
onPress={onClose}
|
||||||
|
isDisabled={isLoading}
|
||||||
|
>
|
||||||
|
{t("Cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
onPress={handleSave}
|
||||||
|
isLoading={isLoading}
|
||||||
|
>
|
||||||
|
{t("Save")}
|
||||||
|
</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import {
|
||||||
|
Modal,
|
||||||
|
ModalContent,
|
||||||
|
ModalHeader,
|
||||||
|
ModalBody,
|
||||||
|
ModalFooter,
|
||||||
|
Button,
|
||||||
|
Alert,
|
||||||
|
} from "@nextui-org/react";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
|
||||||
|
interface DeleteServerModalProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
onConfirm: () => void | Promise<void>;
|
||||||
|
title?: string | React.ReactNode;
|
||||||
|
description?: string | React.ReactNode;
|
||||||
|
alertDescription?: string;
|
||||||
|
customAlertContent?: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DeleteServerModal: React.FC<DeleteServerModalProps> = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
onConfirm,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
alertDescription,
|
||||||
|
customAlertContent,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleConfirm = async () => {
|
||||||
|
setIsLoading(true);
|
||||||
|
try {
|
||||||
|
await onConfirm();
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultTitle = t("Confirm Delete");
|
||||||
|
const defaultDescription = t("Are you sure you want to delete this item? This action cannot be undone.");
|
||||||
|
const defaultAlertDescription= t("This action cannot be undone.");
|
||||||
|
return (
|
||||||
|
<Modal isOpen={isOpen} onClose={onClose} size="xl">
|
||||||
|
<ModalContent>
|
||||||
|
{() => (
|
||||||
|
<>
|
||||||
|
<ModalHeader className="flex flex-col gap-1">
|
||||||
|
{title || defaultTitle}
|
||||||
|
</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Description */}
|
||||||
|
<div className="text-default-600">
|
||||||
|
{description || defaultDescription}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Warning message */}
|
||||||
|
<Alert title={alertDescription || defaultAlertDescription} color="danger" classNames={{mainWrapper: "w-[calc(100%-60px)]"}}>
|
||||||
|
{customAlertContent && customAlertContent}
|
||||||
|
</Alert>
|
||||||
|
</div>
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button
|
||||||
|
color="default"
|
||||||
|
variant="light"
|
||||||
|
onPress={onClose}
|
||||||
|
isDisabled={isLoading}
|
||||||
|
>
|
||||||
|
{t("Cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
color="danger"
|
||||||
|
onPress={handleConfirm}
|
||||||
|
isLoading={isLoading}
|
||||||
|
>
|
||||||
|
{t("Remove")}
|
||||||
|
</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</ModalContent>
|
||||||
|
</Modal >
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DeleteServerModal;
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useRef, useCallback, useEffect } from "react";
|
||||||
|
import { Button, Card, CardBody, CardHeader, Chip, Divider, Listbox, ListboxItem, Spinner } from "@nextui-org/react";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
import { Plus } from "lucide-react";
|
||||||
|
|
||||||
|
// 资源组类型定义
|
||||||
|
export interface ResourceGroup {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
isDefault?: boolean;
|
||||||
|
serviceCount?: number;
|
||||||
|
createdAt?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GroupListProps {
|
||||||
|
groups: ResourceGroup[];
|
||||||
|
selectedGroup: ResourceGroup | null;
|
||||||
|
onSelectGroup: (group: ResourceGroup) => void;
|
||||||
|
onCreateGroup: () => void;
|
||||||
|
onLoadMore?: () => void;
|
||||||
|
hasMore?: boolean;
|
||||||
|
loading?: boolean;
|
||||||
|
shouldScrollToTop?: boolean;
|
||||||
|
onScrolledToTop?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GroupList: React.FC<GroupListProps> = ({
|
||||||
|
groups,
|
||||||
|
selectedGroup,
|
||||||
|
onSelectGroup,
|
||||||
|
onCreateGroup,
|
||||||
|
onLoadMore,
|
||||||
|
hasMore = false,
|
||||||
|
loading = false,
|
||||||
|
shouldScrollToTop = false,
|
||||||
|
onScrolledToTop,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
const observerRef = useRef<IntersectionObserver | null>(null);
|
||||||
|
const loadMoreTriggerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const hasLoadedMoreRef = useRef(false);
|
||||||
|
|
||||||
|
// 使用 IntersectionObserver 监听滚动到底部
|
||||||
|
const handleObserver = useCallback(
|
||||||
|
(entries: IntersectionObserverEntry[]) => {
|
||||||
|
const [target] = entries;
|
||||||
|
if (target.isIntersecting && hasMore && !loading && onLoadMore) {
|
||||||
|
hasLoadedMoreRef.current = true; // 标记已触发过加载更多
|
||||||
|
onLoadMore();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[hasMore, loading, onLoadMore]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const element = loadMoreTriggerRef.current;
|
||||||
|
if (!element || !onLoadMore) return;
|
||||||
|
|
||||||
|
// 创建 IntersectionObserver
|
||||||
|
observerRef.current = new IntersectionObserver(handleObserver, {
|
||||||
|
root: scrollRef.current,
|
||||||
|
rootMargin: "100px", // 提前 100px 触发加载
|
||||||
|
threshold: 0.1,
|
||||||
|
});
|
||||||
|
|
||||||
|
observerRef.current.observe(element);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (observerRef.current && element) {
|
||||||
|
observerRef.current.unobserve(element);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [handleObserver, onLoadMore]);
|
||||||
|
|
||||||
|
// 监听 shouldScrollToTop 变化,滚动到顶部
|
||||||
|
useEffect(() => {
|
||||||
|
if (shouldScrollToTop && scrollRef.current) {
|
||||||
|
scrollRef.current.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
// 通知父组件已完成滚动
|
||||||
|
onScrolledToTop?.();
|
||||||
|
}
|
||||||
|
}, [shouldScrollToTop, onScrolledToTop]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-w-[300px] w-[300px] bg-default-100/50 h-full">
|
||||||
|
<Card shadow="none"
|
||||||
|
radius="none"
|
||||||
|
className="bg-transparent flex flex-col h-full">
|
||||||
|
<CardHeader className="flex justify-between items-center px-6 py-4">
|
||||||
|
<h2 className="text-xl font-semibold text-gray-900">{t("Group List")}</h2>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
color="primary"
|
||||||
|
startContent={<Plus size={16} />}
|
||||||
|
onPress={onCreateGroup}
|
||||||
|
>
|
||||||
|
{t("New")}
|
||||||
|
</Button>
|
||||||
|
</CardHeader>
|
||||||
|
<Divider />
|
||||||
|
<CardBody className="flex-grow p-0">
|
||||||
|
<div ref={scrollRef} className="overflow-y-auto h-full px-4 py-4">
|
||||||
|
<Listbox
|
||||||
|
aria-label="Group list"
|
||||||
|
items={groups || []}
|
||||||
|
emptyContent={loading ? <></> : <div className="flex items-center justify-center h-full">{t("No groups found")}</div>}
|
||||||
|
selectionMode="single"
|
||||||
|
selectedKeys={selectedGroup ? [selectedGroup.id] : []}
|
||||||
|
onSelectionChange={(keys) => {
|
||||||
|
const selectedId = Array.from(keys)[0];
|
||||||
|
const selectedKey = (groups || []).find(
|
||||||
|
(k) => k.id === selectedId
|
||||||
|
);
|
||||||
|
if (selectedKey) onSelectGroup(selectedKey);
|
||||||
|
}}
|
||||||
|
itemClasses={{
|
||||||
|
title: "text-md font-medium",
|
||||||
|
base: "bg-white p-6 transition-colors border-1 data-[selected=true]:focus:bg-primary-50 data-[selected=true]:data-[hover=true]:bg-primary-50 data-[selected=true]:border-primary-500 data-[selected=true]:bg-primary-50 data-[hover=true]:bg-default/50 data-[selectable=true]:focus:bg-default/50 [&>span]:w-full",
|
||||||
|
}}
|
||||||
|
classNames={{
|
||||||
|
list: "gap-4",
|
||||||
|
}}
|
||||||
|
hideSelectedIcon
|
||||||
|
>
|
||||||
|
{(group) => (
|
||||||
|
<ListboxItem key={group.id} textValue={group.name}>
|
||||||
|
<div className="flex items-center gap-2 w-full overflow-hidden">
|
||||||
|
<span className="truncate flex-1 min-w-0">{group.name}</span>
|
||||||
|
{group.isDefault && (
|
||||||
|
<Chip size="sm" color="warning" variant="flat" className="shrink-0 ml-auto">
|
||||||
|
{t("Default")}
|
||||||
|
</Chip>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ListboxItem>
|
||||||
|
)}
|
||||||
|
</Listbox>
|
||||||
|
|
||||||
|
{/* 加载更多触发器 */}
|
||||||
|
{onLoadMore && (
|
||||||
|
<div ref={loadMoreTriggerRef} className="py-4 flex justify-center">
|
||||||
|
{loading && hasMore && (
|
||||||
|
<Spinner size="sm" color="primary" />
|
||||||
|
)}
|
||||||
|
{!hasMore && groups.length > 0 && hasLoadedMoreRef.current && (
|
||||||
|
<p className="text-sm text-default-400">{t("No more groups")}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GroupList;
|
||||||
|
|
||||||
@@ -0,0 +1,250 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useEffect, useState, useMemo } from "react";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Chip,
|
||||||
|
Table,
|
||||||
|
TableHeader,
|
||||||
|
TableColumn,
|
||||||
|
TableBody,
|
||||||
|
TableRow,
|
||||||
|
TableCell,
|
||||||
|
Tooltip,
|
||||||
|
Spinner,
|
||||||
|
Divider,
|
||||||
|
CardHeader,
|
||||||
|
CardBody,
|
||||||
|
Pagination,
|
||||||
|
} from "@nextui-org/react";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
import { Plus, Trash2, Edit2 } from "lucide-react";
|
||||||
|
import { Price } from "@/shared/components/marketplace/Price";
|
||||||
|
import { ChargeType } from "@/shared/types/marketplace";
|
||||||
|
import { fetchResourceGroupDetail, ResourceGroupDetailResponse } from "@/api/resourceGroup.api";
|
||||||
|
import { useSearchParams } from "next/navigation";
|
||||||
|
|
||||||
|
// 组内服务类型定义
|
||||||
|
export interface GroupService {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
base_url: string;
|
||||||
|
charge_type: ChargeType;
|
||||||
|
price: string;
|
||||||
|
enabled: boolean;
|
||||||
|
slug_name?: string;
|
||||||
|
input_token_price?: string;
|
||||||
|
output_token_price?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GroupServiceTableProps {
|
||||||
|
groupId?: string; // 可选,因为可能从 URL 获取
|
||||||
|
services: GroupService[];
|
||||||
|
loading?: boolean;
|
||||||
|
pagination: {
|
||||||
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
total: number;
|
||||||
|
};
|
||||||
|
onPageChange: (page: number) => void;
|
||||||
|
onAddService: () => void;
|
||||||
|
onRemoveService: (serviceId: string) => void;
|
||||||
|
onEditGroup: (groupId: string) => void;
|
||||||
|
onDeleteGroup: (groupId: string) => void;
|
||||||
|
refreshTrigger?: number; // 用于触发刷新
|
||||||
|
}
|
||||||
|
|
||||||
|
const GroupServiceTable: React.FC<GroupServiceTableProps> = ({
|
||||||
|
groupId: propGroupId,
|
||||||
|
services,
|
||||||
|
loading = false,
|
||||||
|
pagination,
|
||||||
|
onPageChange,
|
||||||
|
onAddService,
|
||||||
|
onRemoveService,
|
||||||
|
onEditGroup,
|
||||||
|
onDeleteGroup,
|
||||||
|
refreshTrigger,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const pages = Math.ceil(pagination.total / pagination.pageSize);
|
||||||
|
const currentPage = pagination.page;
|
||||||
|
const [resourceGroupDetail, setResourceGroupDetail] = useState<ResourceGroupDetailResponse | null>(null);
|
||||||
|
|
||||||
|
// 优先使用 props 传入的 groupId,如果没有则从 URL 参数获取
|
||||||
|
const urlGroupId = searchParams.get('groupId');
|
||||||
|
const currentGroupId = propGroupId || urlGroupId || null;
|
||||||
|
|
||||||
|
// 使用 useMemo 计算 showOptions,确保响应式更新
|
||||||
|
const showOptions = useMemo(() => {
|
||||||
|
if (!resourceGroupDetail) return false;
|
||||||
|
return !['allow-all', 'deny-all'].includes(resourceGroupDetail.id);
|
||||||
|
}, [resourceGroupDetail]);
|
||||||
|
|
||||||
|
const getResourceGroup = async (groupId: string) => {
|
||||||
|
const response = await fetchResourceGroupDetail(groupId);
|
||||||
|
if (response) {
|
||||||
|
setResourceGroupDetail(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (currentGroupId) {
|
||||||
|
getResourceGroup(currentGroupId);
|
||||||
|
}
|
||||||
|
}, [currentGroupId, refreshTrigger]); // 当 refreshTrigger 变化时也会刷新
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Card className="flex-1" radius="none" shadow="sm">
|
||||||
|
<CardHeader className="px-6 py-4">
|
||||||
|
<div className="flex justify-between items-center w-full">
|
||||||
|
<h2 className="text-xl font-semibold text-gray-900 truncate" title={resourceGroupDetail?.name}>
|
||||||
|
{resourceGroupDetail?.name}
|
||||||
|
</h2>
|
||||||
|
<div className="flex gap-2 h-[32px]">
|
||||||
|
{showOptions && currentGroupId && <>
|
||||||
|
<Button
|
||||||
|
isIconOnly
|
||||||
|
size="sm"
|
||||||
|
variant="bordered"
|
||||||
|
onPress={() => onEditGroup(currentGroupId)}
|
||||||
|
>
|
||||||
|
<Edit2 size={18} />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
isIconOnly
|
||||||
|
size="sm"
|
||||||
|
variant="bordered"
|
||||||
|
color="danger"
|
||||||
|
onPress={() => onDeleteGroup(currentGroupId)}
|
||||||
|
>
|
||||||
|
<Trash2 size={18} />
|
||||||
|
</Button></>
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</CardHeader>
|
||||||
|
<Divider />
|
||||||
|
<CardBody className="px-6 py-6">
|
||||||
|
{
|
||||||
|
showOptions && (<>
|
||||||
|
<div className="flex flex-col sm:flex-row gap-4 mb-6">
|
||||||
|
<div className="flex-1">
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
onPress={onAddService}
|
||||||
|
startContent={<Plus size={16} />}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
{t("Add Server")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex gap-2"></div>
|
||||||
|
</div>
|
||||||
|
</>)
|
||||||
|
}
|
||||||
|
|
||||||
|
<Table
|
||||||
|
key={`table-${showOptions}`}
|
||||||
|
aria-label="Group services table"
|
||||||
|
removeWrapper
|
||||||
|
classNames={{
|
||||||
|
wrapper: "min-h-[400px]",
|
||||||
|
}}
|
||||||
|
bottomContent={
|
||||||
|
pages > 1 ? (
|
||||||
|
<div className="flex w-full justify-center">
|
||||||
|
<Pagination
|
||||||
|
showControls
|
||||||
|
variant="light"
|
||||||
|
color="primary"
|
||||||
|
page={currentPage}
|
||||||
|
total={pages}
|
||||||
|
onChange={onPageChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<TableHeader>
|
||||||
|
<TableColumn>{t("Service Name")}</TableColumn>
|
||||||
|
<TableColumn>{t("API Endpoint")}</TableColumn>
|
||||||
|
<TableColumn>{t("Status")}</TableColumn>
|
||||||
|
<TableColumn>{t("Pricing")}</TableColumn>
|
||||||
|
<TableColumn className={showOptions ? "w-20" : "hidden"}>{t("Actions")}</TableColumn>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody
|
||||||
|
items={services}
|
||||||
|
isLoading={loading}
|
||||||
|
loadingContent={<Spinner />}
|
||||||
|
emptyContent={t("No services in this group")}
|
||||||
|
>
|
||||||
|
{(service) => {
|
||||||
|
// 在渲染函数内部使用 showOptions,确保使用最新值
|
||||||
|
const cellClassName = showOptions ? "" : "hidden";
|
||||||
|
return (
|
||||||
|
<TableRow key={service.id}>
|
||||||
|
<TableCell>
|
||||||
|
<span className="text-sm">{service.name}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<span className="text-sm">{service.base_url}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Chip
|
||||||
|
className="capitalize"
|
||||||
|
color={service.enabled ? "success" : "danger"}
|
||||||
|
size="sm"
|
||||||
|
variant="flat"
|
||||||
|
>
|
||||||
|
{t(service.enabled ? "Published" : "Unpublished")}
|
||||||
|
</Chip>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<Price
|
||||||
|
price={service.price}
|
||||||
|
charge_type={service.charge_type}
|
||||||
|
input_token_price={service.input_token_price}
|
||||||
|
output_token_price={service.output_token_price}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className={cellClassName}>
|
||||||
|
<Tooltip
|
||||||
|
content={t("Remove")}
|
||||||
|
color="danger"
|
||||||
|
closeDelay={0}
|
||||||
|
disableAnimation
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
isIconOnly
|
||||||
|
size="sm"
|
||||||
|
variant="light"
|
||||||
|
color="danger"
|
||||||
|
onPress={() => onRemoveService(service.id)}
|
||||||
|
>
|
||||||
|
<Trash2 className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GroupServiceTable;
|
||||||
|
|
||||||
@@ -0,0 +1,349 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
import DashboardDemoContent from "@/shared/components/DashboardDemoContent";
|
||||||
|
import GroupList, { ResourceGroup } from "./GroupList";
|
||||||
|
import GroupServiceTable, { GroupService } from "./GroupServiceTable";
|
||||||
|
import { AddServerModal } from "./AddServerModal";
|
||||||
|
import { DeleteServerModal } from "./DeleteServerModal";
|
||||||
|
import { Divider, Select, SelectItem } from "@nextui-org/react";
|
||||||
|
import { useResourceGroups } from "@/hooks/useResourceGroups";
|
||||||
|
import { AddMcpServerModal } from "./AddMcpServerModal";
|
||||||
|
|
||||||
|
const ResourceGroupManagement: React.FC = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
// 使用自定义 Hook 管理资源组
|
||||||
|
const {
|
||||||
|
groups,
|
||||||
|
simpleResourceGroups,
|
||||||
|
loadSimpleResourceGroups,
|
||||||
|
groupServices,
|
||||||
|
serviceTablePagination,
|
||||||
|
serviceTableParams,
|
||||||
|
loading,
|
||||||
|
servicesLoading,
|
||||||
|
hasMore,
|
||||||
|
shouldScrollToTop,
|
||||||
|
setShouldScrollToTop,
|
||||||
|
loadGroupServices,
|
||||||
|
loadMoreGroups,
|
||||||
|
handleServicePageChange,
|
||||||
|
handleAddServiceToGroup,
|
||||||
|
handleCreateGroup: createGroup,
|
||||||
|
handleUpdateGroup: updateGroup,
|
||||||
|
handleDeleteGroup: deleteGroup,
|
||||||
|
handleRemoveService: removeService,
|
||||||
|
} = useResourceGroups();
|
||||||
|
|
||||||
|
// 当前选中的资源组
|
||||||
|
const [selectedGroup, setSelectedGroup] = useState<ResourceGroup | null>(null);
|
||||||
|
|
||||||
|
// 删除组确认模态框
|
||||||
|
const [isDeleteGroupModalOpen, setIsDeleteGroupModalOpen] = useState(false);
|
||||||
|
const [groupToDelete, setGroupToDelete] = useState<ResourceGroup | null>(null);
|
||||||
|
const [transferToGroupId, setTransferToGroupId] = useState<string | null>(null);
|
||||||
|
const [simpleResourceGroupsLoading, setSimpleResourceGroupsLoading] = useState(false);
|
||||||
|
|
||||||
|
// 删除服务确认模态框
|
||||||
|
const [isDeleteServiceModalOpen, setIsDeleteServiceModalOpen] = useState(false);
|
||||||
|
const [serviceToDelete, setServiceToDelete] = useState<GroupService | null>(null);
|
||||||
|
|
||||||
|
// 创建/编辑组模态框
|
||||||
|
const [isGroupModalOpen, setIsGroupModalOpen] = useState(false);
|
||||||
|
const [editingGroup, setEditingGroup] = useState<ResourceGroup | null>(null);
|
||||||
|
|
||||||
|
// 添加 MCP 服务模态框
|
||||||
|
const [isAddMcpServerModalOpen, setIsAddMcpServerModalOpen] = useState(false);
|
||||||
|
|
||||||
|
// 刷新触发器,用于触发 GroupServiceTable 刷新
|
||||||
|
const [refreshTrigger, setRefreshTrigger] = useState(0);
|
||||||
|
const [newGroupId, setNewGroupId] = useState<string | null>(null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存 MCP 服务
|
||||||
|
* @param serverIds 服务ID列表
|
||||||
|
* @returns 是否保存成功
|
||||||
|
*/
|
||||||
|
const handleSaveMcpServer = async (serverIds: string[]) => {
|
||||||
|
if (!selectedGroup) return;
|
||||||
|
|
||||||
|
const success = await handleAddServiceToGroup(selectedGroup.id, serverIds);
|
||||||
|
if (success) {
|
||||||
|
setIsAddMcpServerModalOpen(false);
|
||||||
|
await loadGroupServices(selectedGroup.id, 1, serviceTableParams.current.pageSize, serviceTableParams.current.keyword);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 初始化选中第一个组,或在滚动到顶部时选中第一个
|
||||||
|
useEffect(() => {
|
||||||
|
if (groups.length > 0 && (shouldScrollToTop || !selectedGroup)) {
|
||||||
|
const index = shouldScrollToTop && newGroupId ? groups.findIndex((group) => group.id === newGroupId) : 0;
|
||||||
|
setSelectedGroup(groups[index]);
|
||||||
|
loadGroupServices(groups[index].id);
|
||||||
|
}
|
||||||
|
}, [groups, selectedGroup, loadGroupServices, shouldScrollToTop]);
|
||||||
|
|
||||||
|
// 选择组
|
||||||
|
const handleSelectGroup = (group: ResourceGroup) => {
|
||||||
|
setSelectedGroup(group);
|
||||||
|
loadGroupServices(group.id);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 创建新组
|
||||||
|
const handleCreateGroup = () => {
|
||||||
|
setEditingGroup(null);
|
||||||
|
setIsGroupModalOpen(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 保存组(创建或编辑)
|
||||||
|
const handleSaveGroup = async (name: string, isDefault: boolean) => {
|
||||||
|
let success = false;
|
||||||
|
|
||||||
|
if (editingGroup) {
|
||||||
|
// 编辑现有组
|
||||||
|
success = await updateGroup(editingGroup.id, name, isDefault);
|
||||||
|
if (success && selectedGroup?.id === editingGroup.id) {
|
||||||
|
setSelectedGroup({ ...selectedGroup, name, isDefault });
|
||||||
|
// 触发 GroupServiceTable 刷新
|
||||||
|
setRefreshTrigger(prev => prev + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 创建新组
|
||||||
|
const newGroupId = await createGroup(name, isDefault);
|
||||||
|
success = !!newGroupId;
|
||||||
|
if (newGroupId) {
|
||||||
|
setNewGroupId(newGroupId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
setIsGroupModalOpen(false);
|
||||||
|
setEditingGroup(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 编辑组
|
||||||
|
const handleEditGroup = (groupId: string) => {
|
||||||
|
const group = groups.find((g) => g.id === groupId);
|
||||||
|
if (group) {
|
||||||
|
setEditingGroup(group);
|
||||||
|
setIsGroupModalOpen(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除组
|
||||||
|
const handleDeleteGroup = async (groupId: string) => {
|
||||||
|
const group = groups.find((g) => g.id === groupId);
|
||||||
|
if (group) {
|
||||||
|
setSimpleResourceGroupsLoading(true);
|
||||||
|
const simpleResourceGroups = await loadSimpleResourceGroups();
|
||||||
|
setTransferToGroupId(simpleResourceGroups.filter((group) => group.id !== groupId)[0].id);
|
||||||
|
setSimpleResourceGroupsLoading(false);
|
||||||
|
setGroupToDelete(group);
|
||||||
|
setIsDeleteGroupModalOpen(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 确认删除组
|
||||||
|
const handleConfirmDeleteGroup = async () => {
|
||||||
|
if (groupToDelete && transferToGroupId) {
|
||||||
|
// 在删除前找到要选中的目标组
|
||||||
|
let targetGroup: ResourceGroup | null = null;
|
||||||
|
if (selectedGroup?.id === groupToDelete.id) {
|
||||||
|
const currentIndex = groups.findIndex((g) => g.id === groupToDelete.id);
|
||||||
|
if (currentIndex !== -1) {
|
||||||
|
// 优先选择上一个,如果没有上一个则选择下一个
|
||||||
|
if (currentIndex > 0) {
|
||||||
|
targetGroup = groups[currentIndex - 1];
|
||||||
|
} else if (currentIndex < groups.length - 1) {
|
||||||
|
targetGroup = groups[currentIndex + 1];
|
||||||
|
}
|
||||||
|
// 如果既没有上一个也没有下一个(只有一个元素),targetGroup 保持为 null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const success = await deleteGroup(groupToDelete.id, transferToGroupId);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
// 等待列表刷新后选中目标组
|
||||||
|
setTimeout(() => {
|
||||||
|
if (groups.length === 0) {
|
||||||
|
// 删除后没有任何资源组了
|
||||||
|
setSelectedGroup(null);
|
||||||
|
} else if (targetGroup) {
|
||||||
|
// 在新列表中找到目标组(因为列表已经刷新了)
|
||||||
|
const newTarget = groups.find((g) => g.id === targetGroup.id);
|
||||||
|
if (newTarget) {
|
||||||
|
setSelectedGroup(newTarget);
|
||||||
|
loadGroupServices(newTarget.id);
|
||||||
|
} else {
|
||||||
|
// 如果目标组不存在了,选择第一个
|
||||||
|
setSelectedGroup(groups[0]);
|
||||||
|
loadGroupServices(groups[0].id);
|
||||||
|
}
|
||||||
|
} else if (selectedGroup?.id === groupToDelete.id) {
|
||||||
|
// 如果删除的是当前选中的组,且没有找到目标组(理论上不应该发生)
|
||||||
|
setSelectedGroup(groups[0]);
|
||||||
|
loadGroupServices(groups[0].id);
|
||||||
|
}
|
||||||
|
// 如果删除的不是当前选中的组,保持原有选中状态
|
||||||
|
}, 200);
|
||||||
|
|
||||||
|
setIsDeleteGroupModalOpen(false);
|
||||||
|
setGroupToDelete(null);
|
||||||
|
setTransferToGroupId(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加服务到组
|
||||||
|
const handleAddService = () => {
|
||||||
|
setIsAddMcpServerModalOpen(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 从组中移除服务
|
||||||
|
const handleRemoveService = (serviceId: string) => {
|
||||||
|
const service = groupServices.find((s) => s.id === serviceId);
|
||||||
|
if (service) {
|
||||||
|
setServiceToDelete(service);
|
||||||
|
setIsDeleteServiceModalOpen(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 确认删除服务
|
||||||
|
const handleConfirmDeleteService = async () => {
|
||||||
|
if (serviceToDelete && selectedGroup) {
|
||||||
|
const success = await removeService(selectedGroup.id, serviceToDelete.id);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
setIsDeleteServiceModalOpen(false);
|
||||||
|
setServiceToDelete(null);
|
||||||
|
await loadGroupServices(selectedGroup.id, 1, serviceTableParams.current.pageSize, serviceTableParams.current.keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DashboardDemoContent
|
||||||
|
title={t("Resource Group")}
|
||||||
|
description={t("Manage your resource group. Each user has a resource group and can only access resources within their resource group")}
|
||||||
|
>
|
||||||
|
<div className="flex border-1 border-gray-200 rounded-lg items-stretch overflow-hidden h-full">
|
||||||
|
{/* 左侧组列表 */}
|
||||||
|
<GroupList
|
||||||
|
groups={groups}
|
||||||
|
selectedGroup={selectedGroup}
|
||||||
|
onSelectGroup={handleSelectGroup}
|
||||||
|
onCreateGroup={handleCreateGroup}
|
||||||
|
onLoadMore={loadMoreGroups}
|
||||||
|
hasMore={hasMore}
|
||||||
|
loading={loading}
|
||||||
|
shouldScrollToTop={shouldScrollToTop}
|
||||||
|
onScrolledToTop={() => setShouldScrollToTop(false)}
|
||||||
|
/>
|
||||||
|
<Divider orientation="vertical" className="h-auto" />
|
||||||
|
{/* 右侧服务列表 */}
|
||||||
|
{selectedGroup ? (
|
||||||
|
<GroupServiceTable
|
||||||
|
groupId={selectedGroup.id}
|
||||||
|
services={groupServices}
|
||||||
|
loading={servicesLoading}
|
||||||
|
pagination={serviceTablePagination}
|
||||||
|
onPageChange={(page) => handleServicePageChange(selectedGroup.id, page)}
|
||||||
|
onAddService={handleAddService}
|
||||||
|
onRemoveService={handleRemoveService}
|
||||||
|
onEditGroup={handleEditGroup}
|
||||||
|
onDeleteGroup={handleDeleteGroup}
|
||||||
|
refreshTrigger={refreshTrigger}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="flex-1 flex items-center justify-center text-default-400">
|
||||||
|
{t("Please select a group to view services")}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 删除资源组模态框 */}
|
||||||
|
<DeleteServerModal
|
||||||
|
isOpen={isDeleteGroupModalOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsDeleteGroupModalOpen(false);
|
||||||
|
setGroupToDelete(null);
|
||||||
|
setTransferToGroupId(null);
|
||||||
|
}}
|
||||||
|
onConfirm={handleConfirmDeleteGroup}
|
||||||
|
title={t("Confirm Remove")}
|
||||||
|
description={t(
|
||||||
|
'Are you sure you want to remove this "{{name}}" Resource Group?',
|
||||||
|
{
|
||||||
|
name: groupToDelete?.name || "",
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
alertDescription={t("The bound users have been transferred to the following resource group")}
|
||||||
|
customAlertContent={<div className="w-full mt-[10px]">
|
||||||
|
<Select
|
||||||
|
placeholder={t("Select resource group")}
|
||||||
|
isLoading={simpleResourceGroupsLoading}
|
||||||
|
selectedKeys={transferToGroupId ? [transferToGroupId] : simpleResourceGroups.length > 0 ? [simpleResourceGroups.filter((group) => group.id !== groupToDelete?.id)[0].id] : []}
|
||||||
|
onSelectionChange={(keys) => {
|
||||||
|
const selectedKey = Array.from(keys)[0] as string;
|
||||||
|
if (selectedKey) {
|
||||||
|
setTransferToGroupId(selectedKey);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
labelPlacement="outside"
|
||||||
|
>
|
||||||
|
{simpleResourceGroups.filter((group) => group.id !== groupToDelete?.id).map((group) => (
|
||||||
|
<SelectItem key={group.id} value={group.id}>
|
||||||
|
{group.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</div>}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 删除服务模态框 */}
|
||||||
|
<DeleteServerModal
|
||||||
|
isOpen={isDeleteServiceModalOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsDeleteServiceModalOpen(false);
|
||||||
|
setServiceToDelete(null);
|
||||||
|
}}
|
||||||
|
onConfirm={handleConfirmDeleteService}
|
||||||
|
title={t("Confirm Remove")}
|
||||||
|
description={t(
|
||||||
|
'Are you sure you want to remove this "{{name}}" mcp server from "{{groupName}}" resource group?',
|
||||||
|
{
|
||||||
|
name: serviceToDelete?.name || "",
|
||||||
|
groupName: selectedGroup?.name || "",
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
alertDescription={t("Users associated with this resource group will not be able to call the removed MCP server")}
|
||||||
|
/>
|
||||||
|
{/* 创建/编辑组模态框 */}
|
||||||
|
<AddServerModal
|
||||||
|
isOpen={isGroupModalOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsGroupModalOpen(false);
|
||||||
|
setEditingGroup(null);
|
||||||
|
}}
|
||||||
|
name={editingGroup?.name || ""}
|
||||||
|
isDefault={editingGroup?.isDefault || false}
|
||||||
|
onSaveServer={handleSaveGroup}
|
||||||
|
type={editingGroup ? "edit" : "add"}
|
||||||
|
/>
|
||||||
|
<AddMcpServerModal
|
||||||
|
id={selectedGroup?.id || ""}
|
||||||
|
isOpen={isAddMcpServerModalOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsAddMcpServerModalOpen(false);
|
||||||
|
}}
|
||||||
|
onSaveMcpServer={handleSaveMcpServer}
|
||||||
|
/>
|
||||||
|
</DashboardDemoContent>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ResourceGroupManagement;
|
||||||
@@ -10,11 +10,12 @@ import {
|
|||||||
TableCell,
|
TableCell,
|
||||||
Pagination,
|
Pagination,
|
||||||
Chip,
|
Chip,
|
||||||
Spinner
|
Spinner,
|
||||||
|
Tooltip
|
||||||
} from '@nextui-org/react';
|
} from '@nextui-org/react';
|
||||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||||
import { PaymentState, RevenueRecord } from '@/types/revenue';
|
import { PaymentState, RevenueRecord } from '@/types/revenue';
|
||||||
import { Calendar, CreditCard } from 'lucide-react';
|
import { Calendar, CreditCard, HelpCircle } from 'lucide-react';
|
||||||
import { formatCurrency } from '@/shared/utils/currency';
|
import { formatCurrency } from '@/shared/utils/currency';
|
||||||
|
|
||||||
interface RevenueTableProps {
|
interface RevenueTableProps {
|
||||||
@@ -122,7 +123,19 @@ export const RevenueTable: React.FC<RevenueTableProps> = ({
|
|||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableColumn>{t('Account (Email)')}</TableColumn>
|
<TableColumn>{t('Account (Email)')}</TableColumn>
|
||||||
<TableColumn>{t('Recharge Amount')}</TableColumn>
|
<TableColumn>{t('Recharge Amount')}</TableColumn>
|
||||||
<TableColumn>{t('Recharge Time')}</TableColumn>
|
<TableColumn>
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<span>{t('Recharge Time')}</span>
|
||||||
|
<Tooltip
|
||||||
|
content={t("Current display time is UTC time")}
|
||||||
|
color="default"
|
||||||
|
closeDelay={0}
|
||||||
|
disableAnimation
|
||||||
|
>
|
||||||
|
<HelpCircle className="w-4 h-4" />
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</TableColumn>
|
||||||
<TableColumn>{t('Payment Method')}</TableColumn>
|
<TableColumn>{t('Payment Method')}</TableColumn>
|
||||||
<TableColumn>{t('Transaction ID')}</TableColumn>
|
<TableColumn>{t('Transaction ID')}</TableColumn>
|
||||||
<TableColumn>{t('Status')}</TableColumn>
|
<TableColumn>{t('Status')}</TableColumn>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({
|
|||||||
formData.username.trim() !== "" &&
|
formData.username.trim() !== "" &&
|
||||||
formData.password?.trim() !== "" &&
|
formData.password?.trim() !== "" &&
|
||||||
formData.password === confirmPassword &&
|
formData.password === confirmPassword &&
|
||||||
formData.password?.length >= 8;
|
formData.password?.length >= 6;
|
||||||
|
|
||||||
const passwordsMatch = formData.password === confirmPassword;
|
const passwordsMatch = formData.password === confirmPassword;
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({
|
|||||||
<Input
|
<Input
|
||||||
label={t("Administrator Password")}
|
label={t("Administrator Password")}
|
||||||
placeholder={t("Enter administrator password")}
|
placeholder={t("Enter administrator password")}
|
||||||
description={t("Password must be at least 8 characters long")}
|
description={t("Password must be at least 6 characters long")}
|
||||||
value={formData.password}
|
value={formData.password}
|
||||||
onChange={(e) => handleInputChange("password", e.target.value)}
|
onChange={(e) => handleInputChange("password", e.target.value)}
|
||||||
type={showPassword ? "text" : "password"}
|
type={showPassword ? "text" : "password"}
|
||||||
@@ -106,13 +106,13 @@ export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({
|
|||||||
isRequired
|
isRequired
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
color={
|
color={
|
||||||
formData.password?.length > 0 && formData.password?.length < 8
|
formData.password?.length > 0 && formData.password?.length < 6
|
||||||
? "danger"
|
? "danger"
|
||||||
: "default"
|
: "default"
|
||||||
}
|
}
|
||||||
errorMessage={
|
errorMessage={
|
||||||
formData.password?.length > 0 && formData.password?.length < 8
|
formData.password?.length > 0 && formData.password?.length < 6
|
||||||
? t("Password must be at least 8 characters")
|
? t("Password must be at least 6 characters")
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { sanitizeMCPServerName } from "@/shared/utils/mcp";
|
import { sanitizeMCPServerName } from "@/shared/utils/mcp";
|
||||||
import { useNavigationItems } from "@/shared/providers/ConfigProvider";
|
import { useNavigationItems } from "@/shared/providers/ConfigProvider";
|
||||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||||
|
import { useSharedStore } from "@/shared/store/share";
|
||||||
|
|
||||||
interface ProductDetailThemeSelectorProps {
|
interface ProductDetailThemeSelectorProps {
|
||||||
product: ServiceData;
|
product: ServiceData;
|
||||||
@@ -36,9 +37,14 @@ const BasicProductDetailThemeSelector: React.FC<
|
|||||||
platformConfig.mcp_server_prefix || process.env.NEXT_PUBLIC_MCP_URL || "";
|
platformConfig.mcp_server_prefix || process.env.NEXT_PUBLIC_MCP_URL || "";
|
||||||
const [url, setUrl] = useState<string>("");
|
const [url, setUrl] = useState<string>("");
|
||||||
const [mcpName, setMcpName] = useState<string>("");
|
const [mcpName, setMcpName] = useState<string>("");
|
||||||
|
const [can_invoke, setCanInvoke] = useState<boolean>(false);
|
||||||
|
const [visitor, setVisitor] = useState<boolean>(false);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const configNavigation = useNavigationItems() || NavigationItems;
|
const configNavigation = useNavigationItems() || NavigationItems;
|
||||||
|
|
||||||
|
// 使用 Zustand hook 正确订阅 user 状态
|
||||||
|
const user = useSharedStore((state) => state.user);
|
||||||
|
|
||||||
const navigationItems = [
|
const navigationItems = [
|
||||||
...configNavigation,
|
...configNavigation,
|
||||||
...topNavigation.map((item) => ({
|
...topNavigation.map((item) => ({
|
||||||
@@ -56,6 +62,24 @@ const BasicProductDetailThemeSelector: React.FC<
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setMcpName(sanitizeMCPServerName(product.name));
|
setMcpName(sanitizeMCPServerName(product.name));
|
||||||
}, [product.name]);
|
}, [product.name]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (user) {
|
||||||
|
if (user?.allow_all) {
|
||||||
|
setCanInvoke(true)
|
||||||
|
} else {
|
||||||
|
const serviceId = product.id
|
||||||
|
const allowIds = user.service_ids
|
||||||
|
if (!allowIds?.includes(serviceId)) {
|
||||||
|
setCanInvoke(false)
|
||||||
|
} else {
|
||||||
|
setCanInvoke(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setCanInvoke(true);
|
||||||
|
setVisitor(true);
|
||||||
|
}
|
||||||
|
}, [user, product.id]);
|
||||||
const getCodeContent = () => {
|
const getCodeContent = () => {
|
||||||
return `{
|
return `{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
@@ -82,6 +106,8 @@ const BasicProductDetailThemeSelector: React.FC<
|
|||||||
case Theme.MODERN:
|
case Theme.MODERN:
|
||||||
return (
|
return (
|
||||||
<ModernDetail
|
<ModernDetail
|
||||||
|
can_invoke={can_invoke}
|
||||||
|
visitor={visitor}
|
||||||
product={product}
|
product={product}
|
||||||
breadcrumbs={breadcrumbs}
|
breadcrumbs={breadcrumbs}
|
||||||
url={url}
|
url={url}
|
||||||
@@ -93,6 +119,8 @@ const BasicProductDetailThemeSelector: React.FC<
|
|||||||
case Theme.CLASSIC:
|
case Theme.CLASSIC:
|
||||||
return (
|
return (
|
||||||
<ClassicDetail
|
<ClassicDetail
|
||||||
|
can_invoke={can_invoke}
|
||||||
|
visitor={visitor}
|
||||||
product={product}
|
product={product}
|
||||||
breadcrumbs={breadcrumbs}
|
breadcrumbs={breadcrumbs}
|
||||||
url={url}
|
url={url}
|
||||||
@@ -104,6 +132,8 @@ const BasicProductDetailThemeSelector: React.FC<
|
|||||||
case Theme.CREATIVE:
|
case Theme.CREATIVE:
|
||||||
return (
|
return (
|
||||||
<CreativeDetail
|
<CreativeDetail
|
||||||
|
can_invoke={can_invoke}
|
||||||
|
visitor={visitor}
|
||||||
product={product}
|
product={product}
|
||||||
breadcrumbs={breadcrumbs}
|
breadcrumbs={breadcrumbs}
|
||||||
url={url}
|
url={url}
|
||||||
@@ -115,6 +145,8 @@ const BasicProductDetailThemeSelector: React.FC<
|
|||||||
case Theme.TEMU:
|
case Theme.TEMU:
|
||||||
return (
|
return (
|
||||||
<TemuDetail
|
<TemuDetail
|
||||||
|
can_invoke={can_invoke}
|
||||||
|
visitor={visitor}
|
||||||
product={product}
|
product={product}
|
||||||
breadcrumbs={breadcrumbs}
|
breadcrumbs={breadcrumbs}
|
||||||
url={url}
|
url={url}
|
||||||
@@ -131,6 +163,8 @@ const BasicProductDetailThemeSelector: React.FC<
|
|||||||
<main className="flex-1">
|
<main className="flex-1">
|
||||||
<ProductDetailClient
|
<ProductDetailClient
|
||||||
product={product}
|
product={product}
|
||||||
|
can_invoke={can_invoke}
|
||||||
|
visitor={visitor}
|
||||||
mcpName={mcpName}
|
mcpName={mcpName}
|
||||||
url={url}
|
url={url}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import { NavigationItem } from "@/shared/components/Navigation";
|
|||||||
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||||
|
|
||||||
interface DetailProps {
|
interface DetailProps {
|
||||||
|
can_invoke?: boolean;
|
||||||
|
visitor?: boolean;
|
||||||
product: ServiceData;
|
product: ServiceData;
|
||||||
breadcrumbs?: {
|
breadcrumbs?: {
|
||||||
link: string;
|
link: string;
|
||||||
@@ -30,6 +32,8 @@ interface DetailProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Detail: React.FC<DetailProps> = ({
|
export const Detail: React.FC<DetailProps> = ({
|
||||||
|
can_invoke,
|
||||||
|
visitor,
|
||||||
product,
|
product,
|
||||||
url,
|
url,
|
||||||
mcpName,
|
mcpName,
|
||||||
@@ -216,6 +220,8 @@ export const Detail: React.FC<DetailProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
{/* Code Snippet */}
|
{/* Code Snippet */}
|
||||||
<ServerConfig
|
<ServerConfig
|
||||||
|
can_invoke={can_invoke}
|
||||||
|
visitor={visitor}
|
||||||
mcpName={mcpName}
|
mcpName={mcpName}
|
||||||
url={url}
|
url={url}
|
||||||
className="w-full max-w-2xl"
|
className="w-full max-w-2xl"
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import { NavigationItem } from "@/shared/components/Navigation";
|
|||||||
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||||
|
|
||||||
interface DetailProps {
|
interface DetailProps {
|
||||||
|
can_invoke?: boolean;
|
||||||
|
visitor?: boolean;
|
||||||
product: ServiceData;
|
product: ServiceData;
|
||||||
breadcrumbs?: {
|
breadcrumbs?: {
|
||||||
link: string;
|
link: string;
|
||||||
@@ -29,6 +31,8 @@ interface DetailProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Detail: React.FC<DetailProps> = ({
|
export const Detail: React.FC<DetailProps> = ({
|
||||||
|
can_invoke,
|
||||||
|
visitor,
|
||||||
product,
|
product,
|
||||||
breadcrumbs,
|
breadcrumbs,
|
||||||
url,
|
url,
|
||||||
@@ -176,6 +180,8 @@ export const Detail: React.FC<DetailProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
{/* Code Snippet */}
|
{/* Code Snippet */}
|
||||||
<ServerConfig
|
<ServerConfig
|
||||||
|
can_invoke={can_invoke}
|
||||||
|
visitor={visitor}
|
||||||
mcpName={mcpName}
|
mcpName={mcpName}
|
||||||
url={url}
|
url={url}
|
||||||
className="w-full max-w-2xl"
|
className="w-full max-w-2xl"
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import { NavigationItem } from "@/shared/components/Navigation";
|
|||||||
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||||
|
|
||||||
interface DetailProps {
|
interface DetailProps {
|
||||||
|
can_invoke?: boolean;
|
||||||
|
visitor?: boolean;
|
||||||
product: ServiceData;
|
product: ServiceData;
|
||||||
breadcrumbs?: {
|
breadcrumbs?: {
|
||||||
link: string;
|
link: string;
|
||||||
@@ -30,6 +32,8 @@ interface DetailProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Detail: React.FC<DetailProps> = ({
|
export const Detail: React.FC<DetailProps> = ({
|
||||||
|
can_invoke,
|
||||||
|
visitor,
|
||||||
product,
|
product,
|
||||||
breadcrumbs,
|
breadcrumbs,
|
||||||
url,
|
url,
|
||||||
@@ -144,6 +148,8 @@ export const Detail: React.FC<DetailProps> = ({
|
|||||||
{/* Code Snippet */}
|
{/* Code Snippet */}
|
||||||
<ServerConfig
|
<ServerConfig
|
||||||
mcpName={mcpName}
|
mcpName={mcpName}
|
||||||
|
can_invoke={can_invoke}
|
||||||
|
visitor={visitor}
|
||||||
url={url}
|
url={url}
|
||||||
className="w-full max-w-2xl"
|
className="w-full max-w-2xl"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import { NavigationItem } from "@/shared/components/Navigation";
|
|||||||
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||||
|
|
||||||
interface DetailProps {
|
interface DetailProps {
|
||||||
|
can_invoke?: boolean;
|
||||||
|
visitor?: boolean;
|
||||||
product: ServiceData;
|
product: ServiceData;
|
||||||
breadcrumbs?: {
|
breadcrumbs?: {
|
||||||
link: string;
|
link: string;
|
||||||
@@ -29,6 +31,8 @@ interface DetailProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Detail: React.FC<DetailProps> = ({
|
export const Detail: React.FC<DetailProps> = ({
|
||||||
|
can_invoke,
|
||||||
|
visitor,
|
||||||
product,
|
product,
|
||||||
breadcrumbs,
|
breadcrumbs,
|
||||||
url,
|
url,
|
||||||
@@ -163,6 +167,8 @@ export const Detail: React.FC<DetailProps> = ({
|
|||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
{/* Code Snippet */}
|
{/* Code Snippet */}
|
||||||
<ServerConfig
|
<ServerConfig
|
||||||
|
can_invoke={can_invoke}
|
||||||
|
visitor={visitor}
|
||||||
mcpName={mcpName}
|
mcpName={mcpName}
|
||||||
url={url}
|
url={url}
|
||||||
className="w-full max-w-2xl"
|
className="w-full max-w-2xl"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const UserManagement: React.FC = () => {
|
|||||||
// use custom hook to manage user data
|
// use custom hook to manage user data
|
||||||
const {
|
const {
|
||||||
users,
|
users,
|
||||||
|
fetchUsers,
|
||||||
loading,
|
loading,
|
||||||
pagination,
|
pagination,
|
||||||
handleDeleteUser,
|
handleDeleteUser,
|
||||||
@@ -70,6 +71,7 @@ const UserManagement: React.FC = () => {
|
|||||||
<div className="space-y-6 w-full">
|
<div className="space-y-6 w-full">
|
||||||
<UserTable
|
<UserTable
|
||||||
users={users}
|
users={users}
|
||||||
|
fetchUsers={fetchUsers}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onDelete={handleDeleteUserClick}
|
onDelete={handleDeleteUserClick}
|
||||||
onRecharge={handleRecharge}
|
onRecharge={handleRecharge}
|
||||||
@@ -79,6 +81,7 @@ const UserManagement: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DeleteConfirmModal
|
<DeleteConfirmModal
|
||||||
|
user={deleteModal.user}
|
||||||
isOpen={deleteModal.isOpen}
|
isOpen={deleteModal.isOpen}
|
||||||
onClose={handleCloseDeleteModal}
|
onClose={handleCloseDeleteModal}
|
||||||
onConfirm={handleConfirmDelete}
|
onConfirm={handleConfirmDelete}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React from "react";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
@@ -12,14 +12,19 @@ import {
|
|||||||
Pagination,
|
Pagination,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Spinner,
|
Spinner,
|
||||||
|
Select,
|
||||||
|
SelectItem,
|
||||||
} from "@nextui-org/react";
|
} from "@nextui-org/react";
|
||||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
import { User } from "@/types/user";
|
import { User } from "@/types/user";
|
||||||
import { Trash2, CreditCard } from "lucide-react";
|
import { Trash2, CreditCard, Calendar, HelpCircle } from "lucide-react";
|
||||||
import { AdminRechargeModal } from "@/components/user-management/AdminRechargeModal";
|
import { AdminRechargeModal } from "@/components/user-management/AdminRechargeModal";
|
||||||
|
import { fetchSimpleResourceGroups, updateUserResourceGroup } from "@/api/resourceGroup.api";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
interface UserTableProps {
|
interface UserTableProps {
|
||||||
users: User[];
|
users: User[];
|
||||||
|
fetchUsers: () => void;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
onDelete: (user: User) => void;
|
onDelete: (user: User) => void;
|
||||||
onRecharge: (id: string, amount: number) => Promise<boolean>;
|
onRecharge: (id: string, amount: number) => Promise<boolean>;
|
||||||
@@ -33,6 +38,7 @@ interface UserTableProps {
|
|||||||
|
|
||||||
export const UserTable: React.FC<UserTableProps> = ({
|
export const UserTable: React.FC<UserTableProps> = ({
|
||||||
users,
|
users,
|
||||||
|
fetchUsers,
|
||||||
loading = false,
|
loading = false,
|
||||||
onDelete,
|
onDelete,
|
||||||
onRecharge,
|
onRecharge,
|
||||||
@@ -51,6 +57,9 @@ export const UserTable: React.FC<UserTableProps> = ({
|
|||||||
const [isRechargeModalOpen, setIsRechargeModalOpen] = React.useState(false);
|
const [isRechargeModalOpen, setIsRechargeModalOpen] = React.useState(false);
|
||||||
const [selectedUser, setSelectedUser] = React.useState<User | null>(null);
|
const [selectedUser, setSelectedUser] = React.useState<User | null>(null);
|
||||||
|
|
||||||
|
const [simpleResourceGroups, setSimpleResourceGroups] = useState<{ id: string, name: string }[]>([]);
|
||||||
|
const [groupsLoading, setGroupsLoading] = useState(true);
|
||||||
|
|
||||||
const handleDelete = React.useCallback(
|
const handleDelete = React.useCallback(
|
||||||
(user: User) => {
|
(user: User) => {
|
||||||
onDelete(user);
|
onDelete(user);
|
||||||
@@ -68,7 +77,45 @@ export const UserTable: React.FC<UserTableProps> = ({
|
|||||||
setSelectedUser(null);
|
setSelectedUser(null);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (loading && users.length === 0) {
|
// 加载简易资源组列表
|
||||||
|
const loadSimpleResourceGroups = useCallback(async () => {
|
||||||
|
setGroupsLoading(true);
|
||||||
|
try {
|
||||||
|
const data = await fetchSimpleResourceGroups();
|
||||||
|
setSimpleResourceGroups(data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load simple resource groups:", error);
|
||||||
|
} finally {
|
||||||
|
setGroupsLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const changeResourceGroup = async (user: User, resourceGroupId: string) => {
|
||||||
|
const success = await updateUserResourceGroup(user.id, resourceGroupId);
|
||||||
|
if (success) {
|
||||||
|
toast.success(t("Resource group updated successfully"));
|
||||||
|
fetchUsers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatDate = (dateString: string) => {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<Calendar className="w-3 h-3 text-gray-500" />
|
||||||
|
<span className="text-sm text-gray-600">
|
||||||
|
{new Date(dateString).toLocaleString()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 初始加载简易资源组列表
|
||||||
|
useEffect(() => {
|
||||||
|
loadSimpleResourceGroups();
|
||||||
|
}, [loadSimpleResourceGroups]);
|
||||||
|
|
||||||
|
// 等待用户数据或资源组数据加载
|
||||||
|
if ((loading && users.length === 0) || groupsLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-center h-64">
|
<div className="flex justify-center items-center h-64">
|
||||||
<Spinner size="lg" />
|
<Spinner size="lg" />
|
||||||
@@ -87,7 +134,20 @@ export const UserTable: React.FC<UserTableProps> = ({
|
|||||||
>
|
>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableColumn>{t("Email")}</TableColumn>
|
<TableColumn>{t("Email")}</TableColumn>
|
||||||
<TableColumn>{t("Register Date")}</TableColumn>
|
<TableColumn width={250}>{t("Resource Group")}</TableColumn>
|
||||||
|
<TableColumn>
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<span>{t("Register Date")}</span>
|
||||||
|
<Tooltip
|
||||||
|
content={t("Current display time is UTC time")}
|
||||||
|
color="default"
|
||||||
|
closeDelay={0}
|
||||||
|
disableAnimation
|
||||||
|
>
|
||||||
|
<HelpCircle className="w-4 h-4" />
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</TableColumn>
|
||||||
<TableColumn>{t("Balance")}</TableColumn>
|
<TableColumn>{t("Balance")}</TableColumn>
|
||||||
<TableColumn>{t("Actions")}</TableColumn>
|
<TableColumn>{t("Actions")}</TableColumn>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
@@ -102,7 +162,29 @@ export const UserTable: React.FC<UserTableProps> = ({
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<span className="text-sm">{user.email}</span>
|
<span className="text-sm">{user.email}</span>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{user.created_at || "-"}</TableCell>
|
<TableCell>
|
||||||
|
<Select
|
||||||
|
items={simpleResourceGroups}
|
||||||
|
placeholder={t("Select resource group")}
|
||||||
|
selectedKeys={user.group_id ? [user.group_id] : []}
|
||||||
|
onSelectionChange={(keys) => {
|
||||||
|
const selectedKey = Array.from(keys)[0] as string;
|
||||||
|
if (selectedKey) {
|
||||||
|
changeResourceGroup(user, selectedKey);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
size="sm"
|
||||||
|
className="max-w-[250px]"
|
||||||
|
aria-label={t("Select resource group")}
|
||||||
|
>
|
||||||
|
{(group) => (
|
||||||
|
<SelectItem key={group.id} value={group.id}>
|
||||||
|
{group.name}
|
||||||
|
</SelectItem>
|
||||||
|
)}
|
||||||
|
</Select>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>{formatDate(user.created_at)}</TableCell>
|
||||||
<TableCell>{user.balance.toFixed(2) || "-"}</TableCell>
|
<TableCell>{user.balance.toFixed(2) || "-"}</TableCell>
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
|
|||||||
@@ -3,8 +3,13 @@
|
|||||||
import { useState, useCallback } from "react";
|
import { useState, useCallback } from "react";
|
||||||
import { MCPService } from "@/shared/types/mcp-service";
|
import { MCPService } from "@/shared/types/mcp-service";
|
||||||
import {
|
import {
|
||||||
|
GetMCPResourceGroupsParams,
|
||||||
getMCPServiceDetail,
|
getMCPServiceDetail,
|
||||||
parseOpenAPIDocumentForUpdate as parseOpenAPIDocumentForUpdateAPI,
|
parseOpenAPIDocumentForUpdate as parseOpenAPIDocumentForUpdateAPI,
|
||||||
|
fetchMCPResourceGroups as fetchMCPResourceGroupsAPI,
|
||||||
|
deleteResourceGroup as deleteResourceGroupAPI,
|
||||||
|
addServiceToGroup as addServiceToGroupAPI,
|
||||||
|
fetchUnboundResourceGroups as fetchUnboundResourceGroupsAPI,
|
||||||
} from "@/services/mcpService";
|
} from "@/services/mcpService";
|
||||||
|
|
||||||
export const useMCPServiceDetail = () => {
|
export const useMCPServiceDetail = () => {
|
||||||
@@ -81,7 +86,7 @@ export const useMCPServiceDetail = () => {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
response.error_message ||
|
response.error_message ||
|
||||||
"Failed to parse OpenAPI document for update"
|
"Failed to parse OpenAPI document for update"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -98,6 +103,40 @@ export const useMCPServiceDetail = () => {
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资源组列表
|
||||||
|
* @param page 页码
|
||||||
|
* @param page_size 每页条数
|
||||||
|
* @param keyword 关键词
|
||||||
|
* @returns 资源组列表
|
||||||
|
*/
|
||||||
|
const fetchMCPResourceGroups = useCallback(async (id: string, page: number, page_size: number, keyword: string): Promise<GetMCPResourceGroupsParams> => {
|
||||||
|
const response = await fetchMCPResourceGroupsAPI(id, page, page_size, keyword);
|
||||||
|
return response;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资源组
|
||||||
|
* @param serviceById 服务ID
|
||||||
|
* @param resourceGroupId 资源组ID
|
||||||
|
* @returns 是否删除成功
|
||||||
|
*/
|
||||||
|
const deleteResourceGroup = useCallback(async (serviceById: string, resourceGroupId: string[]): Promise<boolean> => {
|
||||||
|
const response = await deleteResourceGroupAPI(serviceById, resourceGroupId);
|
||||||
|
return response;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加服务到资源组
|
||||||
|
* @param groupId 资源组ID
|
||||||
|
* @param serverIds 服务ID列表
|
||||||
|
* @returns 是否添加成功
|
||||||
|
*/
|
||||||
|
const addServiceToGroup = useCallback(async (groupId: string, serverIds: string[]): Promise<boolean> => {
|
||||||
|
const response = await addServiceToGroupAPI(groupId, serverIds);
|
||||||
|
return response;
|
||||||
|
}, []);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
serviceDetail,
|
serviceDetail,
|
||||||
detailLoading,
|
detailLoading,
|
||||||
@@ -107,5 +146,8 @@ export const useMCPServiceDetail = () => {
|
|||||||
getServiceDetail,
|
getServiceDetail,
|
||||||
clearServiceDetail,
|
clearServiceDetail,
|
||||||
parseOpenAPIDocumentForUpdate,
|
parseOpenAPIDocumentForUpdate,
|
||||||
|
fetchMCPResourceGroups,
|
||||||
|
deleteResourceGroup,
|
||||||
|
addServiceToGroup
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,269 @@
|
|||||||
|
import { useState, useEffect, useCallback, useRef } from "react";
|
||||||
|
import { ResourceGroup } from "@/components/resource-group/GroupList";
|
||||||
|
import { GroupService } from "@/components/resource-group/GroupServiceTable";
|
||||||
|
import {
|
||||||
|
fetchResourceGroups,
|
||||||
|
fetchGroupServices,
|
||||||
|
createResourceGroup,
|
||||||
|
updateResourceGroup,
|
||||||
|
deleteResourceGroup,
|
||||||
|
removeServiceFromGroup,
|
||||||
|
fetchSimpleResourceGroups,
|
||||||
|
addServiceToGroup,
|
||||||
|
} from "@/api/resourceGroup.api";
|
||||||
|
import { toast } from "react-hot-toast";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
|
||||||
|
|
||||||
|
export const useResourceGroups = () => {
|
||||||
|
const [groups, setGroups] = useState<ResourceGroup[]>([]);
|
||||||
|
const [groupServices, setGroupServices] = useState<GroupService[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [servicesLoading, setServicesLoading] = useState(false);
|
||||||
|
const [hasMore, setHasMore] = useState(true);
|
||||||
|
const [shouldScrollToTop, setShouldScrollToTop] = useState(false);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const [simpleResourceGroups, setSimpleResourceGroups] = useState<{ id: string, name: string }[]>([]);
|
||||||
|
|
||||||
|
// 菜单列表(GroupList)的分页和搜索状态
|
||||||
|
const groupListParams = useRef({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
keyword: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
// 服务列表(GroupServiceTable)的分页状态
|
||||||
|
const [serviceTablePagination, setServiceTablePagination] = useState({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 0,
|
||||||
|
});
|
||||||
|
const serviceTableParams = useRef({
|
||||||
|
pageSize: 10,
|
||||||
|
keyword: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
// 加载资源组列表(支持初始加载和追加加载)
|
||||||
|
const loadGroups = useCallback(async (page: number, page_size: number, search_keyword: string, append: boolean = false) => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
groupListParams.current = {
|
||||||
|
page,
|
||||||
|
pageSize: page_size,
|
||||||
|
keyword: search_keyword
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await fetchResourceGroups(page, page_size, search_keyword);
|
||||||
|
const mappedData = response.data.map((item) => ({
|
||||||
|
id: item.id,
|
||||||
|
name: item.name,
|
||||||
|
description: item.description,
|
||||||
|
isDefault: item.is_default,
|
||||||
|
serviceCount: item.service_count,
|
||||||
|
createdAt: item.create_at,
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (append) {
|
||||||
|
// 追加模式:将新数据追加到现有数据后面
|
||||||
|
setGroups((prev) => {
|
||||||
|
const newGroups = [...prev, ...mappedData];
|
||||||
|
setHasMore(newGroups.length < response.total);
|
||||||
|
return newGroups;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 重置模式:替换所有数据
|
||||||
|
setGroups(mappedData);
|
||||||
|
setHasMore(mappedData.length < response.total);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 加载更多资源组(追加数据)
|
||||||
|
const loadMoreGroups = useCallback(async () => {
|
||||||
|
if (loading || !hasMore) return;
|
||||||
|
|
||||||
|
const { page, pageSize, keyword } = groupListParams.current;
|
||||||
|
await loadGroups(page + 1, pageSize, keyword, true);
|
||||||
|
}, [loading, hasMore, loadGroups]);
|
||||||
|
|
||||||
|
// 加载指定组的服务列表(支持分页)
|
||||||
|
const loadGroupServices = useCallback(async (
|
||||||
|
groupId: string,
|
||||||
|
page: number = 1,
|
||||||
|
pageSize: number = 10,
|
||||||
|
keyword: string = ""
|
||||||
|
) => {
|
||||||
|
setServicesLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await fetchGroupServices(groupId, page, pageSize, keyword);
|
||||||
|
setGroupServices(response.data);
|
||||||
|
setServiceTablePagination({
|
||||||
|
page: response.page,
|
||||||
|
pageSize: response.page_size,
|
||||||
|
total: response.total,
|
||||||
|
});
|
||||||
|
// 保存当前的 pageSize 和 keyword 到 ref
|
||||||
|
serviceTableParams.current = {
|
||||||
|
pageSize: response.page_size,
|
||||||
|
keyword
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(t("Failed to load group services"), error);
|
||||||
|
} finally {
|
||||||
|
setServicesLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 创建资源组
|
||||||
|
const handleCreateGroup = useCallback(
|
||||||
|
async (name: string, isDefault: boolean): Promise<string> => {
|
||||||
|
try {
|
||||||
|
const result = await createResourceGroup(name, isDefault);
|
||||||
|
if (!result.success) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
// 创建成功后重新加载列表(重置到第1页)
|
||||||
|
toast.success(t("Resource group created successfully"));
|
||||||
|
const { pageSize, keyword } = groupListParams.current;
|
||||||
|
await loadGroups(1, pageSize, keyword, false);
|
||||||
|
// 触发滚动到顶部
|
||||||
|
setShouldScrollToTop(true);
|
||||||
|
return result.id;
|
||||||
|
} catch {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[loadGroups]
|
||||||
|
);
|
||||||
|
|
||||||
|
// 更新资源组
|
||||||
|
const handleUpdateGroup = useCallback(
|
||||||
|
async (groupId: string, name: string, isDefault: boolean): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const result = await updateResourceGroup(groupId, name, isDefault);
|
||||||
|
if (!result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 更新成功后重新加载列表(重置到第1页)
|
||||||
|
const { pageSize, keyword } = groupListParams.current;
|
||||||
|
await loadGroups(1, pageSize, keyword, false);
|
||||||
|
toast.success(t("Resource group updated successfully"));
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[loadGroups]
|
||||||
|
);
|
||||||
|
|
||||||
|
// 删除资源组
|
||||||
|
const handleDeleteGroup = useCallback(
|
||||||
|
async (groupId: string, transferToGroupId: string): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const result = await deleteResourceGroup(groupId, transferToGroupId);
|
||||||
|
if (!result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 删除成功后重新加载列表(重置到第1页)
|
||||||
|
const { pageSize, keyword } = groupListParams.current;
|
||||||
|
await loadGroups(1, pageSize, keyword, false);
|
||||||
|
toast.success(t("Resource group deleted successfully"));
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[loadGroups]
|
||||||
|
);
|
||||||
|
|
||||||
|
// 服务列表翻页
|
||||||
|
const handleServicePageChange = useCallback(
|
||||||
|
async (groupId: string, page: number) => {
|
||||||
|
await loadGroupServices(
|
||||||
|
groupId,
|
||||||
|
page,
|
||||||
|
serviceTableParams.current.pageSize,
|
||||||
|
serviceTableParams.current.keyword
|
||||||
|
);
|
||||||
|
},
|
||||||
|
[loadGroupServices]
|
||||||
|
);
|
||||||
|
|
||||||
|
// 添加服务到组
|
||||||
|
const handleAddServiceToGroup = useCallback(
|
||||||
|
async (groupId: string, serviceIds: string[]): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const success = await addServiceToGroup(groupId, serviceIds);
|
||||||
|
if (!success) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
toast.success(t("Services added successfully"));
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[loadGroupServices, serviceTablePagination.page]
|
||||||
|
);
|
||||||
|
|
||||||
|
// 从组中移除服务
|
||||||
|
const handleRemoveService = useCallback(
|
||||||
|
async (groupId: string, serviceId: string): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const success = await removeServiceFromGroup(groupId, [serviceId]);
|
||||||
|
if (!success) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
toast.success(t("Service removed successfully"));
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[loadGroupServices, serviceTablePagination.page]
|
||||||
|
);
|
||||||
|
|
||||||
|
// 加载简单资源组列表(用于下拉选择)
|
||||||
|
const loadSimpleResourceGroups = useCallback(async () => {
|
||||||
|
try {
|
||||||
|
const data = await fetchSimpleResourceGroups();
|
||||||
|
setSimpleResourceGroups(data);
|
||||||
|
return data
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load simple resource groups:", error);
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 初始加载
|
||||||
|
useEffect(() => {
|
||||||
|
loadGroups(1, 10, "");
|
||||||
|
}, [loadGroups]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
groups,
|
||||||
|
simpleResourceGroups,
|
||||||
|
groupServices,
|
||||||
|
serviceTablePagination,
|
||||||
|
serviceTableParams,
|
||||||
|
loading,
|
||||||
|
servicesLoading,
|
||||||
|
hasMore,
|
||||||
|
shouldScrollToTop,
|
||||||
|
setShouldScrollToTop,
|
||||||
|
loadGroups,
|
||||||
|
loadMoreGroups,
|
||||||
|
loadGroupServices,
|
||||||
|
loadSimpleResourceGroups,
|
||||||
|
handleServicePageChange,
|
||||||
|
handleAddServiceToGroup,
|
||||||
|
handleCreateGroup,
|
||||||
|
handleUpdateGroup,
|
||||||
|
handleDeleteGroup,
|
||||||
|
handleRemoveService,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ApiArrayResponse, ApiObjectResponse } from "@/shared/types";
|
import { ApiArrayResponse, ApiObjectResponse } from "@/shared/types";
|
||||||
import { fetchAdminAPI } from "@/rpc/admin-api";
|
import { fetchAdminAPI } from "@/rpc/admin-api";
|
||||||
import {
|
import {
|
||||||
|
MCPResourceGroupResponse,
|
||||||
MCPService,
|
MCPService,
|
||||||
MCPServiceFormData,
|
MCPServiceFormData,
|
||||||
OpenAPIParseResponse,
|
OpenAPIParseResponse,
|
||||||
@@ -10,15 +11,15 @@ import i18n from "@/shared/lib/i18n";
|
|||||||
|
|
||||||
// MCP server list API response interface
|
// MCP server list API response interface
|
||||||
export interface MCPServiceListApiResponse
|
export interface MCPServiceListApiResponse
|
||||||
extends ApiArrayResponse<MCPService> {}
|
extends ApiArrayResponse<MCPService> { }
|
||||||
|
|
||||||
// MCP server detail API response interface
|
// MCP server detail API response interface
|
||||||
export interface MCPServiceDetailApiResponse
|
export interface MCPServiceDetailApiResponse
|
||||||
extends ApiObjectResponse<MCPService> {}
|
extends ApiObjectResponse<MCPService> { }
|
||||||
|
|
||||||
// OpenAPI parse API response interface
|
// OpenAPI parse API response interface
|
||||||
export interface OpenAPIParseApiResponse
|
export interface OpenAPIParseApiResponse
|
||||||
extends ApiObjectResponse<OpenAPIParseResponse> {}
|
extends ApiObjectResponse<OpenAPIParseResponse> { }
|
||||||
|
|
||||||
// get MCP server list params interface
|
// get MCP server list params interface
|
||||||
export interface GetMCPServiceListParams {
|
export interface GetMCPServiceListParams {
|
||||||
@@ -28,6 +29,13 @@ export interface GetMCPServiceListParams {
|
|||||||
status?: string;
|
status?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface GetMCPResourceGroupsParams {
|
||||||
|
data: MCPResourceGroupResponse[];
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
page_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
// get MCP server detail params interface
|
// get MCP server detail params interface
|
||||||
export interface GetMCPServiceDetailParams {
|
export interface GetMCPServiceDetailParams {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -217,3 +225,97 @@ export const parseOpenAPIDocumentForUpdate = async (
|
|||||||
|
|
||||||
return response as ApiObjectResponse<MCPService>;
|
return response as ApiObjectResponse<MCPService>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资源组列表
|
||||||
|
*/
|
||||||
|
export const fetchMCPResourceGroups = async (id: string, page: number, page_size: number, keyword: string): Promise<GetMCPResourceGroupsParams> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<MCPResourceGroupResponse[]>(`/api/mcp/service/resource_group/list?id=${id}&page=${page}&page_size=${page_size}&keyword=${keyword}`);
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to load resource groups"));
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
total: 0,
|
||||||
|
page,
|
||||||
|
page_size,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
data: response.data || [],
|
||||||
|
total: response.page?.total || 0,
|
||||||
|
page: response.page?.page || page,
|
||||||
|
page_size: response.page?.page_size || page_size,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching auth keys:", error);
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
total: 0,
|
||||||
|
page,
|
||||||
|
page_size,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取未加入的资源组
|
||||||
|
*/
|
||||||
|
export const fetchUnboundResourceGroups = async (id: string): Promise<{ id: string, name: string }[]> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<{ id: string, name: string }[]>(`/api/mcp/service/resource_group/list/unbind?id=${id}`);
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response.error_message || i18n.t("Failed to load resource groups"));
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return response.data || []
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching auth keys:", error);
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资源组
|
||||||
|
*/
|
||||||
|
export const deleteResourceGroup = async (serviceById: string, resourceGroupId: string[]): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<boolean>(`/api/mcp/service/resource_group?id=${serviceById}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
body: { resource_groups: resourceGroupId } as unknown as BodyInit,
|
||||||
|
});
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response?.error_message || i18n.t("Failed to delete resource group"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching auth keys:", error);
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加服务到资源组
|
||||||
|
*/
|
||||||
|
export const addServiceToGroup = async (
|
||||||
|
groupId: string,
|
||||||
|
services: string[]
|
||||||
|
): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const response = await fetchAdminAPI<boolean>(`/api/mcp/service/resource_group?id=${groupId}`, {
|
||||||
|
method: "PUT",
|
||||||
|
body: { resource_groups: services } as unknown as BodyInit,
|
||||||
|
});
|
||||||
|
if (!response.success) {
|
||||||
|
toast.error(response?.error_message || i18n.t("Failed to add service to group"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching auth keys:", error);
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
import { Tabs, Tab, Chip } from "@nextui-org/react";
|
import { Tabs, Tab, Chip } from "@nextui-org/react";
|
||||||
import { ProductHeader } from "./ProductHeader";
|
import { ProductHeader } from "./ProductHeader";
|
||||||
@@ -9,27 +9,40 @@ import { ProductTools } from "./ProductTools";
|
|||||||
import { ProductNotFound } from "./ProductNotFound";
|
import { ProductNotFound } from "./ProductNotFound";
|
||||||
import { ServerConfig } from "./ServerConfig";
|
import { ServerConfig } from "./ServerConfig";
|
||||||
import { ServiceData } from "@/shared/types/marketplace";
|
import { ServiceData } from "@/shared/types/marketplace";
|
||||||
|
import { useGlobalStore } from "@/shared/store/global";
|
||||||
|
import { useSharedStore } from "@/shared/store/share";
|
||||||
|
|
||||||
interface ProductDetailClientProps {
|
interface ProductDetailClientProps {
|
||||||
product: ServiceData;
|
product: ServiceData;
|
||||||
|
visitor?: boolean;
|
||||||
breadcrumbs?: {
|
breadcrumbs?: {
|
||||||
link: string;
|
link: string;
|
||||||
name: string;
|
name: string;
|
||||||
}[];
|
}[];
|
||||||
mcpName?: string;
|
mcpName?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
|
can_invoke?: boolean;
|
||||||
innerHeaderNode?: React.ReactNode;
|
innerHeaderNode?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProductDetailClient: React.FC<ProductDetailClientProps> = ({
|
export const ProductDetailClient: React.FC<ProductDetailClientProps> = ({
|
||||||
product,
|
product,
|
||||||
|
visitor,
|
||||||
breadcrumbs,
|
breadcrumbs,
|
||||||
mcpName,
|
mcpName,
|
||||||
url,
|
url,
|
||||||
|
can_invoke,
|
||||||
innerHeaderNode,
|
innerHeaderNode,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [getUser] = useGlobalStore((state) => [state.getUser]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const userToken = useSharedStore?.getState?.().user_token
|
||||||
|
if (userToken) {
|
||||||
|
getUser();
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
const [activeTab, setActiveTab] = useState("overview");
|
const [activeTab, setActiveTab] = useState("overview");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -69,7 +82,7 @@ export const ProductDetailClient: React.FC<ProductDetailClientProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right side - Server Config */}
|
{/* Right side - Server Config */}
|
||||||
<ServerConfig mcpName={mcpName} url={url} />
|
<ServerConfig mcpName={mcpName} url={url} can_invoke={can_invoke} visitor={visitor} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* SEO-friendly: Simple text content for search engines */}
|
{/* SEO-friendly: Simple text content for search engines */}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ interface ServerConfigProps {
|
|||||||
mcpName?: string;
|
mcpName?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
can_invoke?: boolean;
|
||||||
|
visitor?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type McpType = "sse" | "streamable-http";
|
type McpType = "sse" | "streamable-http";
|
||||||
@@ -22,6 +24,8 @@ export const ServerConfig: React.FC<ServerConfigProps> = ({
|
|||||||
mcpName,
|
mcpName,
|
||||||
url = process.env.NEXT_PUBLIC_MCP_URL,
|
url = process.env.NEXT_PUBLIC_MCP_URL,
|
||||||
className = "md:min-w-[40%] w-[40%] max-w-100 mt-12",
|
className = "md:min-w-[40%] w-[40%] max-w-100 mt-12",
|
||||||
|
can_invoke,
|
||||||
|
visitor,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { handleLogin } = useAuth();
|
const { handleLogin } = useAuth();
|
||||||
@@ -62,11 +66,22 @@ export const ServerConfig: React.FC<ServerConfigProps> = ({
|
|||||||
return (
|
return (
|
||||||
<div className={`min-w-full ${className} flex-shrink-0`}>
|
<div className={`min-w-full ${className} flex-shrink-0`}>
|
||||||
<div className="mb-2 mt-1">
|
<div className="mb-2 mt-1">
|
||||||
<FlipButton
|
{
|
||||||
className="w-full rounded-md"
|
visitor || can_invoke ? <>
|
||||||
text={t("Sign up to get the auth key")}
|
<FlipButton
|
||||||
onPress={handleLogin}
|
className="w-full rounded-md"
|
||||||
/>
|
text={t("Sign up to get the auth key")}
|
||||||
|
onPress={handleLogin}
|
||||||
|
/>
|
||||||
|
</> : <>
|
||||||
|
<div className="w-full rounded-lg bg-[#F3126033] md:pr-2 h-[40px] md:h-[50px] shadow-lg flex items-center justify-center">
|
||||||
|
<p className="text-[#C20E4D] text-center font-bold text-lg leading-none">
|
||||||
|
{t("You don't have permission to access this MCP server.")}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* MCP Type Selection */}
|
{/* MCP Type Selection */}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ interface BasicInfoTabProps {
|
|||||||
onInputChange: (field: keyof MCPServiceFormData, value: any) => void;
|
onInputChange: (field: keyof MCPServiceFormData, value: any) => void;
|
||||||
onAddTag: () => void;
|
onAddTag: () => void;
|
||||||
onRemoveTag: (tag: string) => void;
|
onRemoveTag: (tag: string) => void;
|
||||||
|
errors?: Record<string, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
||||||
@@ -22,6 +23,7 @@ export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
|||||||
onInputChange,
|
onInputChange,
|
||||||
onAddTag,
|
onAddTag,
|
||||||
onRemoveTag,
|
onRemoveTag,
|
||||||
|
errors,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -41,7 +43,9 @@ export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
|||||||
)}
|
)}
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
isRequired
|
isRequired
|
||||||
errorMessage={t("Server ID is required")}
|
maxLength={255}
|
||||||
|
isInvalid={!!errors?.slug_name}
|
||||||
|
errorMessage={errors?.slug_name || t("Server ID is required")}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
label={t("Server Name")}
|
label={t("Server Name")}
|
||||||
@@ -50,7 +54,9 @@ export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
|||||||
onChange={(e) => onInputChange("name", e.target.value)}
|
onChange={(e) => onInputChange("name", e.target.value)}
|
||||||
isRequired
|
isRequired
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
errorMessage={t("Server name is required")}
|
maxLength={255}
|
||||||
|
isInvalid={!!errors?.name}
|
||||||
|
errorMessage={errors?.name || t("Server name is required")}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
label={t("Short Description")}
|
label={t("Short Description")}
|
||||||
@@ -59,7 +65,10 @@ export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
|||||||
onChange={(e) => onInputChange("short_description", e.target.value)}
|
onChange={(e) => onInputChange("short_description", e.target.value)}
|
||||||
isRequired
|
isRequired
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
errorMessage={t("Short description is required")}
|
isInvalid={!!errors?.short_description}
|
||||||
|
errorMessage={
|
||||||
|
errors?.short_description || t("Short description is required")
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
@@ -69,7 +78,8 @@ export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
|||||||
onChange={(e) => onInputChange("base_url", e.target.value)}
|
onChange={(e) => onInputChange("base_url", e.target.value)}
|
||||||
isRequired
|
isRequired
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
errorMessage={t("API Endpoint is required")}
|
isInvalid={!!errors?.base_url}
|
||||||
|
errorMessage={errors?.base_url || t("API Endpoint is required")}
|
||||||
/>
|
/>
|
||||||
{/* headers input fields */}
|
{/* headers input fields */}
|
||||||
<HeadersManagementSettings
|
<HeadersManagementSettings
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ export const PricingTab: React.FC<PricingTabProps> = ({
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
@@ -102,6 +103,7 @@ export const PricingTab: React.FC<PricingTabProps> = ({
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -118,6 +120,7 @@ export const PricingTab: React.FC<PricingTabProps> = ({
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -0,0 +1,316 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Table,
|
||||||
|
TableHeader,
|
||||||
|
TableColumn,
|
||||||
|
TableBody,
|
||||||
|
TableRow,
|
||||||
|
TableCell,
|
||||||
|
Tooltip,
|
||||||
|
Spinner,
|
||||||
|
Pagination,
|
||||||
|
} from "@nextui-org/react";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
import { Calendar, Plus, Trash2, HelpCircle, Eye } from "lucide-react";
|
||||||
|
import { MCPServiceFormData } from "@/shared/types/mcp-service";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
|
import { GetMCPResourceGroupsParams } from "@/services/mcpService";
|
||||||
|
import DeleteServerModal from "@/components/resource-group/DeleteServerModal";
|
||||||
|
import { McpAddGroupModal } from "../modal/McpAddGroup";
|
||||||
|
import ResourceGroupDetailModal from "../modal/ResourceGroupDetailModal";
|
||||||
|
|
||||||
|
// 组内服务类型定义
|
||||||
|
export interface ResourceGroup {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
join_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ResourceGroupProps {
|
||||||
|
deleteResourceGroup: (serviceById: string, resourceGroupId: string[]) => Promise<boolean>;
|
||||||
|
fetchMCPResourceGroups: (id: string, page: number, page_size: number, keyword: string) => Promise<GetMCPResourceGroupsParams>;
|
||||||
|
addServiceToGroup: (groupId: string, serverIds: string[]) => Promise<boolean>;
|
||||||
|
formData: MCPServiceFormData;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ResourceGroup: React.FC<ResourceGroupProps> = ({
|
||||||
|
deleteResourceGroup,
|
||||||
|
fetchMCPResourceGroups,
|
||||||
|
addServiceToGroup,
|
||||||
|
formData
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [resourceGroups, setResourceGroups] = useState<ResourceGroup[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [pagination, setPagination] = useState({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 0,
|
||||||
|
});
|
||||||
|
const resourceGroupsParams = useRef({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
keyword: "",
|
||||||
|
});
|
||||||
|
const [isDeleteResourceGroupModalOpen, setIsDeleteResourceGroupModalOpen] = useState(false);
|
||||||
|
const [resourceGroupToDelete, setResourceGroupToDelete] = useState<ResourceGroup | null>(null);
|
||||||
|
|
||||||
|
// 资源组详情模态框
|
||||||
|
const [isResourceGroupDetailModalOpen, setIsResourceGroupDetailModalOpen] = useState(false);
|
||||||
|
const [resourceGroupDetailId, setResourceGroupDetailId] = useState<string | null>(null);
|
||||||
|
// 添加 MCP 服务模态框
|
||||||
|
const [isAddMcpGroupModalOpen, setIsAddMcpGroupModalOpen] = useState(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载资源组列表
|
||||||
|
*/
|
||||||
|
const loadResourceGroups = useCallback(async (
|
||||||
|
page: number = 1,
|
||||||
|
pageSize: number = 10,
|
||||||
|
keyword: string = ""
|
||||||
|
) => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await fetchMCPResourceGroups(formData?.id || "", page, pageSize, keyword);
|
||||||
|
setResourceGroups(response.data);
|
||||||
|
setPagination({
|
||||||
|
page: response.page,
|
||||||
|
pageSize: response.page_size,
|
||||||
|
total: response.total,
|
||||||
|
});
|
||||||
|
// 保存当前的 pageSize 和 keyword 到 ref
|
||||||
|
resourceGroupsParams.current = {
|
||||||
|
page: response.page,
|
||||||
|
pageSize: response.page_size,
|
||||||
|
keyword
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(t("Failed to load group services"), error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onAddService = () => {
|
||||||
|
setIsAddMcpGroupModalOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatDate = (dateString: string) => {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<Calendar className="w-3 h-3 text-gray-500" />
|
||||||
|
<span className="text-sm text-gray-600">
|
||||||
|
{new Date(dateString).toLocaleString()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 保存 MCP 服务
|
||||||
|
const handleSaveMcpServer = async (serverIds: string[]) => {
|
||||||
|
if (!formData?.id) return;
|
||||||
|
|
||||||
|
const success = await addServiceToGroup(formData?.id, serverIds);
|
||||||
|
if (success) {
|
||||||
|
setIsAddMcpGroupModalOpen(false);
|
||||||
|
await loadResourceGroups(1, resourceGroupsParams.current.pageSize, resourceGroupsParams.current.keyword);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 确认删除资源组
|
||||||
|
*/
|
||||||
|
const handleConfirmDeleteResourceGroup = async () => {
|
||||||
|
const result = await deleteResourceGroup(formData?.id || "", [resourceGroupToDelete?.id || ""]);
|
||||||
|
if (result) {
|
||||||
|
loadResourceGroups(1, 10, "");
|
||||||
|
setIsDeleteResourceGroupModalOpen(false);
|
||||||
|
setResourceGroupToDelete(null);
|
||||||
|
toast.success(t("Resource group deleted successfully"));
|
||||||
|
} else {
|
||||||
|
setIsDeleteResourceGroupModalOpen(false);
|
||||||
|
setResourceGroupToDelete(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资源组
|
||||||
|
* @param groupId 删除资源组
|
||||||
|
*/
|
||||||
|
const onRemoveResourceGroup = async (groupId: string) => {
|
||||||
|
const group = resourceGroups.find((group) => group.id === groupId);
|
||||||
|
if (group) {
|
||||||
|
setResourceGroupToDelete(group);
|
||||||
|
setIsDeleteResourceGroupModalOpen(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const onPageChange = (page: number) => {
|
||||||
|
const { pageSize, keyword } = resourceGroupsParams.current;
|
||||||
|
loadResourceGroups(page, pageSize, keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
const openResourceGroupPage = (group: ResourceGroup) => {
|
||||||
|
setResourceGroupDetailId(group.id);
|
||||||
|
setIsResourceGroupDetailModalOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadResourceGroups(1, 10, "");
|
||||||
|
}, [loadResourceGroups]);
|
||||||
|
|
||||||
|
const pages = Math.ceil(pagination.total / pagination.pageSize);
|
||||||
|
const currentPage = Number(pagination.page);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="flex flex-col sm:flex-row gap-4 mb-6">
|
||||||
|
<div className="flex-1">
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
onPress={onAddService}
|
||||||
|
startContent={<Plus size={16} />}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
{t("Add to Groups")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex gap-2"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Table
|
||||||
|
aria-label="Group services table"
|
||||||
|
removeWrapper
|
||||||
|
classNames={{
|
||||||
|
wrapper: "min-h-[400px]",
|
||||||
|
}}
|
||||||
|
bottomContent={
|
||||||
|
pages > 1 ? (
|
||||||
|
<div className="flex w-full justify-center">
|
||||||
|
<Pagination
|
||||||
|
showControls
|
||||||
|
variant="light"
|
||||||
|
color="primary"
|
||||||
|
page={currentPage}
|
||||||
|
total={pages}
|
||||||
|
onChange={onPageChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<TableHeader>
|
||||||
|
<TableColumn>{t("Group Name")}</TableColumn>
|
||||||
|
<TableColumn>
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<span>{t("Added Time")}</span>
|
||||||
|
<Tooltip
|
||||||
|
content={t("Current display time is UTC time")}
|
||||||
|
color="default"
|
||||||
|
closeDelay={0}
|
||||||
|
disableAnimation
|
||||||
|
>
|
||||||
|
<HelpCircle className="w-4 h-4" />
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn className="w-20">{t("Actions")}</TableColumn>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody
|
||||||
|
items={resourceGroups}
|
||||||
|
isLoading={loading}
|
||||||
|
loadingContent={<Spinner />}
|
||||||
|
emptyContent={t("No services in this group")}
|
||||||
|
>
|
||||||
|
{(group) => (
|
||||||
|
<TableRow key={group.id}>
|
||||||
|
<TableCell>
|
||||||
|
<span className="text-sm">{group.name}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{formatDate(group.join_at)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<div className="relative flex items-center gap-2">
|
||||||
|
<Tooltip
|
||||||
|
content={t("View Resource Group Detail")}
|
||||||
|
color="primary"
|
||||||
|
closeDelay={0}
|
||||||
|
disableAnimation
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
isIconOnly
|
||||||
|
size="sm"
|
||||||
|
variant="light"
|
||||||
|
color="primary"
|
||||||
|
onPress={() => openResourceGroupPage(group)}
|
||||||
|
>
|
||||||
|
<Eye className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip
|
||||||
|
content={t("Remove")}
|
||||||
|
color="danger"
|
||||||
|
closeDelay={0}
|
||||||
|
disableAnimation
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
isIconOnly
|
||||||
|
size="sm"
|
||||||
|
variant="light"
|
||||||
|
color="danger"
|
||||||
|
onPress={() => onRemoveResourceGroup(group.id)}
|
||||||
|
>
|
||||||
|
<Trash2 className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
{/* 删除服务模态框 */}
|
||||||
|
<DeleteServerModal
|
||||||
|
isOpen={isDeleteResourceGroupModalOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsDeleteResourceGroupModalOpen(false);
|
||||||
|
setResourceGroupToDelete(null);
|
||||||
|
}}
|
||||||
|
onConfirm={handleConfirmDeleteResourceGroup}
|
||||||
|
title={t("Confirm Remove")}
|
||||||
|
description={t(
|
||||||
|
'Are you sure you want to remove this "{{name}}" mcp server from "{{groupName}}" resource group?',
|
||||||
|
{
|
||||||
|
name: resourceGroupToDelete?.name || "",
|
||||||
|
groupName: formData?.name || "",
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
alertDescription={t("Users associated with this resource group will not be able to call the removed MCP server")}
|
||||||
|
/>
|
||||||
|
<McpAddGroupModal
|
||||||
|
id={formData.id || ""}
|
||||||
|
isOpen={isAddMcpGroupModalOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsAddMcpGroupModalOpen(false);
|
||||||
|
}}
|
||||||
|
onSaveMcpServer={handleSaveMcpServer}
|
||||||
|
/>
|
||||||
|
<ResourceGroupDetailModal
|
||||||
|
groupId={resourceGroupDetailId || ""}
|
||||||
|
isOpen={isResourceGroupDetailModalOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsResourceGroupDetailModalOpen(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ResourceGroup
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
} from "@nextui-org/react";
|
} from "@nextui-org/react";
|
||||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
import { EnabledEnum, MCPService } from "@/shared/types/mcp-service";
|
import { EnabledEnum, MCPService } from "@/shared/types/mcp-service";
|
||||||
import { Trash2, PencilIcon } from "lucide-react";
|
import { Trash2, PencilIcon, Calendar } from "lucide-react";
|
||||||
import { Price } from "@/shared/components/marketplace/Price";
|
import { Price } from "@/shared/components/marketplace/Price";
|
||||||
import { MdOutlineUnpublished, MdOutlineCheckCircle } from "react-icons/md";
|
import { MdOutlineUnpublished, MdOutlineCheckCircle } from "react-icons/md";
|
||||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||||
@@ -78,7 +78,16 @@ const BaseServiceTable: React.FC<ServiceTableProps> = ({
|
|||||||
},
|
},
|
||||||
[onToggleStatus]
|
[onToggleStatus]
|
||||||
);
|
);
|
||||||
|
const formatDate = (dateString: string) => {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<Calendar className="w-3 h-3 text-gray-500" />
|
||||||
|
<span className="text-sm text-gray-600">
|
||||||
|
{new Date(dateString).toLocaleString()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
if (loading && services.length === 0) {
|
if (loading && services.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-center h-64">
|
<div className="flex justify-center items-center h-64">
|
||||||
@@ -117,6 +126,7 @@ const BaseServiceTable: React.FC<ServiceTableProps> = ({
|
|||||||
<TableColumn hidden={!columns.includes("pricing")}>
|
<TableColumn hidden={!columns.includes("pricing")}>
|
||||||
{t("Pricing")}
|
{t("Pricing")}
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
|
<TableColumn>{t("Created_at")}</TableColumn>
|
||||||
<TableColumn className="w-20">{t("Actions")}</TableColumn>
|
<TableColumn className="w-20">{t("Actions")}</TableColumn>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody
|
<TableBody
|
||||||
@@ -153,6 +163,7 @@ const BaseServiceTable: React.FC<ServiceTableProps> = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell>{formatDate(service.created_at)}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<div className="relative flex items-center gap-2">
|
<div className="relative flex items-center gap-2">
|
||||||
<Tooltip content={t("Edit")} closeDelay={0} disableAnimation>
|
<Tooltip content={t("Edit")} closeDelay={0} disableAnimation>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
Alert,
|
Alert,
|
||||||
} from "@nextui-org/react";
|
} from "@nextui-org/react";
|
||||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
import { User } from "@/types/user";
|
||||||
|
|
||||||
interface DeleteConfirmModalProps {
|
interface DeleteConfirmModalProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@@ -23,6 +24,7 @@ interface DeleteConfirmModalProps {
|
|||||||
requireNameConfirmation?: boolean;
|
requireNameConfirmation?: boolean;
|
||||||
confirmationName?: string;
|
confirmationName?: string;
|
||||||
confirmationPlaceholder?: string;
|
confirmationPlaceholder?: string;
|
||||||
|
user?: User | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DeleteConfirmModal: React.FC<DeleteConfirmModalProps> = ({
|
export const DeleteConfirmModal: React.FC<DeleteConfirmModalProps> = ({
|
||||||
@@ -35,6 +37,7 @@ export const DeleteConfirmModal: React.FC<DeleteConfirmModalProps> = ({
|
|||||||
requireNameConfirmation = false,
|
requireNameConfirmation = false,
|
||||||
confirmationName = "",
|
confirmationName = "",
|
||||||
confirmationPlaceholder,
|
confirmationPlaceholder,
|
||||||
|
user,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
@@ -83,7 +86,16 @@ export const DeleteConfirmModal: React.FC<DeleteConfirmModalProps> = ({
|
|||||||
<div className="text-default-600">
|
<div className="text-default-600">
|
||||||
{description || defaultDescription}
|
{description || defaultDescription}
|
||||||
</div>
|
</div>
|
||||||
|
{user && (
|
||||||
|
<div className="mb-4 p-3 bg-gray-50 rounded-lg">
|
||||||
|
<p className="text-sm text-gray-600">
|
||||||
|
{t("User")}: {user.email}
|
||||||
|
</p>
|
||||||
|
<p className="text-sm text-gray-600">
|
||||||
|
{t("Current Balance")}: ${user.balance.toFixed(2)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{/* Warning message */}
|
{/* Warning message */}
|
||||||
<Alert title={t("This action cannot be undone.")} color="danger" />
|
<Alert title={t("This action cannot be undone.")} color="danger" />
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Modal,
|
||||||
|
ModalBody,
|
||||||
|
ModalContent,
|
||||||
|
ModalFooter,
|
||||||
|
ModalHeader,
|
||||||
|
Table,
|
||||||
|
TableHeader,
|
||||||
|
TableColumn,
|
||||||
|
TableBody,
|
||||||
|
TableRow,
|
||||||
|
TableCell,
|
||||||
|
Spinner,
|
||||||
|
} from "@nextui-org/react";
|
||||||
|
import { useState, useEffect, useCallback } from "react";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
import { fetchUnboundResourceGroups } from "@/services/mcpService";
|
||||||
|
|
||||||
|
interface McpAddGroupModalProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
id: string;
|
||||||
|
onSaveMcpServer: (serverIds: string[]) => Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ResourceGroup {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const McpAddGroupModal: React.FC<McpAddGroupModalProps> = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
id,
|
||||||
|
onSaveMcpServer,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [resourceGroups, setResourceGroups] = useState<ResourceGroup[]>([]);
|
||||||
|
const [selectedKeys, setSelectedKeys] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
|
// 加载服务列表
|
||||||
|
const loadServices = useCallback(async () => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await fetchUnboundResourceGroups(id);
|
||||||
|
setResourceGroups(response);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load resource groups:", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 当模态框打开时加载数据
|
||||||
|
useEffect(() => {
|
||||||
|
if (isOpen) {
|
||||||
|
setSelectedKeys(new Set());
|
||||||
|
loadServices();
|
||||||
|
}
|
||||||
|
}, [isOpen, loadServices]);
|
||||||
|
|
||||||
|
// 处理保存
|
||||||
|
const handleSave = async () => {
|
||||||
|
const serverIds = typeof selectedKeys === 'string' && selectedKeys === 'all' ? resourceGroups.map((group) => group.id) : Array.from(selectedKeys);
|
||||||
|
if (serverIds.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLoading(true);
|
||||||
|
try {
|
||||||
|
await onSaveMcpServer(serverIds);
|
||||||
|
onClose();
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal isOpen={isOpen} onClose={onClose} size="5xl" scrollBehavior="inside">
|
||||||
|
<ModalContent>
|
||||||
|
{() => (
|
||||||
|
<>
|
||||||
|
<ModalHeader className="flex flex-col gap-1">
|
||||||
|
{t("Add to Groups")}
|
||||||
|
</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<Table
|
||||||
|
aria-label="Resource groups selection table"
|
||||||
|
selectionMode="multiple"
|
||||||
|
selectedKeys={selectedKeys}
|
||||||
|
onSelectionChange={(keys) => setSelectedKeys(keys as Set<string>)}
|
||||||
|
removeWrapper
|
||||||
|
classNames={{
|
||||||
|
wrapper: "min-h-[400px]",
|
||||||
|
}}
|
||||||
|
className="[&_td:first-child]:w-[30px] [&_th:first-child]:w-[30px]"
|
||||||
|
>
|
||||||
|
<TableHeader>
|
||||||
|
<TableColumn>{t("Group Name")}</TableColumn>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody
|
||||||
|
items={resourceGroups}
|
||||||
|
isLoading={loading}
|
||||||
|
loadingContent={<Spinner />}
|
||||||
|
emptyContent={t("No resource groups available")}
|
||||||
|
>
|
||||||
|
{(resourceGroup) => (
|
||||||
|
<TableRow key={resourceGroup.id}>
|
||||||
|
<TableCell>
|
||||||
|
<span className="text-sm">{resourceGroup.name}</span>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button
|
||||||
|
color="danger"
|
||||||
|
variant="light"
|
||||||
|
onPress={onClose}
|
||||||
|
isDisabled={isLoading}
|
||||||
|
>
|
||||||
|
{t("Close")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
onPress={handleSave}
|
||||||
|
isLoading={isLoading}
|
||||||
|
isDisabled={selectedKeys.size === 0}
|
||||||
|
>
|
||||||
|
{t("Add")}
|
||||||
|
</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Chip,
|
||||||
|
Table,
|
||||||
|
TableHeader,
|
||||||
|
TableColumn,
|
||||||
|
TableBody,
|
||||||
|
TableRow,
|
||||||
|
TableCell,
|
||||||
|
Tooltip,
|
||||||
|
Spinner,
|
||||||
|
Divider,
|
||||||
|
CardHeader,
|
||||||
|
CardBody,
|
||||||
|
Pagination,
|
||||||
|
ModalContent,
|
||||||
|
Modal,
|
||||||
|
ModalHeader,
|
||||||
|
ModalBody,
|
||||||
|
} from "@nextui-org/react";
|
||||||
|
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||||
|
import { Plus, Trash2, Edit2 } from "lucide-react";
|
||||||
|
import { Price } from "@/shared/components/marketplace/Price";
|
||||||
|
import { ChargeType } from "@/shared/types/marketplace";
|
||||||
|
import { fetchGroupServices, fetchResourceGroupDetail, ResourceGroupDetailResponse } from "@/api/resourceGroup.api";
|
||||||
|
import { useSearchParams } from "next/navigation";
|
||||||
|
|
||||||
|
// 组内服务类型定义
|
||||||
|
export interface GroupService {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
base_url: string;
|
||||||
|
charge_type: ChargeType;
|
||||||
|
price: string;
|
||||||
|
enabled: boolean;
|
||||||
|
slug_name?: string;
|
||||||
|
input_token_price?: string;
|
||||||
|
output_token_price?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ResourceGroupDetailModalProps {
|
||||||
|
groupId?: string; // 可选,因为可能从 URL 获取
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ResourceGroupDetailModal: React.FC<ResourceGroupDetailModalProps> = ({
|
||||||
|
groupId,
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const [services, setServices] = useState<GroupService[]>([]);
|
||||||
|
const [serviceTablePagination, setServiceTablePagination] = useState({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 0,
|
||||||
|
});
|
||||||
|
const serviceTableParams = useRef({
|
||||||
|
pageSize: 10,
|
||||||
|
keyword: ""
|
||||||
|
});
|
||||||
|
const [pages, setPages] = useState(0);
|
||||||
|
const [servicesLoading, setServicesLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setPages(Math.ceil(serviceTablePagination.total / serviceTablePagination.pageSize));
|
||||||
|
}, [serviceTablePagination.total, serviceTablePagination.pageSize]);
|
||||||
|
|
||||||
|
// 加载指定组的服务列表(支持分页)
|
||||||
|
const loadGroupServices = useCallback(async (
|
||||||
|
groupId: string,
|
||||||
|
page: number = 1,
|
||||||
|
pageSize: number = 10,
|
||||||
|
keyword: string = ""
|
||||||
|
) => {
|
||||||
|
setServicesLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await fetchGroupServices(groupId, page, pageSize, keyword);
|
||||||
|
setServices(response.data);
|
||||||
|
setServiceTablePagination({
|
||||||
|
page: response.page,
|
||||||
|
pageSize: response.page_size,
|
||||||
|
total: response.total,
|
||||||
|
});
|
||||||
|
// 保存当前的 pageSize 和 keyword 到 ref
|
||||||
|
serviceTableParams.current = {
|
||||||
|
pageSize: response.page_size,
|
||||||
|
keyword
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(t("Failed to load group services"), error);
|
||||||
|
} finally {
|
||||||
|
setServicesLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 服务列表翻页
|
||||||
|
const handleServicePageChange = async (page: number) => {
|
||||||
|
await loadGroupServices(
|
||||||
|
groupId || "",
|
||||||
|
page,
|
||||||
|
serviceTableParams.current.pageSize,
|
||||||
|
serviceTableParams.current.keyword
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isOpen && groupId) {
|
||||||
|
loadGroupServices(groupId, 1, 10, "");
|
||||||
|
}
|
||||||
|
}, [isOpen, groupId, loadGroupServices]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal isOpen={isOpen} onClose={onClose} size="4xl">
|
||||||
|
<ModalContent>
|
||||||
|
{() => (
|
||||||
|
<>
|
||||||
|
<ModalHeader className="flex flex-col gap-1">
|
||||||
|
{t("Resource Group Detail")}
|
||||||
|
</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<div className="space-y-4">
|
||||||
|
<Table
|
||||||
|
aria-label="Group services table"
|
||||||
|
removeWrapper
|
||||||
|
classNames={{
|
||||||
|
wrapper: "min-h-[400px]",
|
||||||
|
}}
|
||||||
|
bottomContent={
|
||||||
|
pages > 1 ? (
|
||||||
|
<div className="flex w-full justify-center">
|
||||||
|
<Pagination
|
||||||
|
showControls
|
||||||
|
variant="light"
|
||||||
|
color="primary"
|
||||||
|
page={serviceTablePagination.page}
|
||||||
|
total={pages}
|
||||||
|
onChange={(page) => handleServicePageChange(page)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<TableHeader>
|
||||||
|
<TableColumn>{t("Service Name")}</TableColumn>
|
||||||
|
<TableColumn>{t("API Endpoint")}</TableColumn>
|
||||||
|
<TableColumn>{t("Status")}</TableColumn>
|
||||||
|
<TableColumn>{t("Pricing")}</TableColumn>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody
|
||||||
|
items={services}
|
||||||
|
isLoading={servicesLoading}
|
||||||
|
loadingContent={<Spinner />}
|
||||||
|
emptyContent={t("No services in this group")}
|
||||||
|
>
|
||||||
|
{(service) => (
|
||||||
|
<TableRow key={service.id}>
|
||||||
|
<TableCell>
|
||||||
|
<span className="text-sm">{service.name}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<span className="text-sm">{service.base_url}</span>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Chip
|
||||||
|
className="capitalize"
|
||||||
|
color={service.enabled ? "success" : "danger"}
|
||||||
|
size="sm"
|
||||||
|
variant="flat"
|
||||||
|
>
|
||||||
|
{t(service.enabled ? "Published" : "Unpublished")}
|
||||||
|
</Chip>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<Price
|
||||||
|
price={service.price}
|
||||||
|
charge_type={service.charge_type}
|
||||||
|
input_token_price={service.input_token_price}
|
||||||
|
output_token_price={service.output_token_price}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
</ModalBody>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</ModalContent>
|
||||||
|
</Modal >
|
||||||
|
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ResourceGroupDetailModal;
|
||||||
|
|
||||||
@@ -14,6 +14,8 @@ export interface User {
|
|||||||
user_email: string;
|
user_email: string;
|
||||||
user_name: string;
|
user_name: string;
|
||||||
avatar?: string;
|
avatar?: string;
|
||||||
|
allow_all?: boolean;
|
||||||
|
service_ids?: string[];
|
||||||
nick_name?: string;
|
nick_name?: string;
|
||||||
language: NavigatorLanguage | "en" | "zh-CN";
|
language: NavigatorLanguage | "en" | "zh-CN";
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export enum TabKey {
|
|||||||
CONSOLE = "console",
|
CONSOLE = "console",
|
||||||
MCP_SERVICES = "mcp-services",
|
MCP_SERVICES = "mcp-services",
|
||||||
USER_MANAGEMENT = "user-management",
|
USER_MANAGEMENT = "user-management",
|
||||||
|
RESOURCE_GROUP = "resource-group",
|
||||||
REVENUE_MANAGEMENT = "revenue-management",
|
REVENUE_MANAGEMENT = "revenue-management",
|
||||||
PAYMENT_CHANNELS = "payment-channels",
|
PAYMENT_CHANNELS = "payment-channels",
|
||||||
LOGIN_SETTINGS = "login-settings",
|
LOGIN_SETTINGS = "login-settings",
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export interface BaseMCPService {
|
|||||||
output_token_price?: string;
|
output_token_price?: string;
|
||||||
apis: MCPServiceAPIItem[];
|
apis: MCPServiceAPIItem[];
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
|
can_invoke?: boolean
|
||||||
}
|
}
|
||||||
export interface MCPService extends BaseMCPService {
|
export interface MCPService extends BaseMCPService {
|
||||||
base_url: string;
|
base_url: string;
|
||||||
@@ -135,3 +136,9 @@ export function convertFormToAPI(
|
|||||||
update_type: formData.update_type,
|
update_type: formData.update_type,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MCPResourceGroupResponse {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
join_at: string;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ export interface User {
|
|||||||
id: string;
|
id: string;
|
||||||
email: string;
|
email: string;
|
||||||
balance: number;
|
balance: number;
|
||||||
|
group_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// user management related filter interface
|
// user management related filter interface
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
SET FOREIGN_KEY_CHECKS=0;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `resource_group` (
|
||||||
|
`id` char(36) NOT NULL COMMENT 'Primary key, group UUID',
|
||||||
|
`name` varchar(255) NOT NULL COMMENT 'Group name',
|
||||||
|
`description` text NULL COMMENT 'Group description',
|
||||||
|
`enabled` tinyint NOT NULL DEFAULT 1 COMMENT 'Group status: 0=disabled, 1=enabled',
|
||||||
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
|
`updated_at` timestamp NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Resource group table';
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `resource_group_service_map` (
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
||||||
|
`group_id` char(36) NOT NULL COMMENT 'Resource group UUID',
|
||||||
|
`service_id` char(36) NOT NULL COMMENT 'MCP service UUID',
|
||||||
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uq_group_service` (`group_id`, `service_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Resource group to MCP service mapping';
|
||||||
|
|
||||||
|
ALTER TABLE `user` ADD `group_id` char(36) NULL COMMENT 'Resource group UUID';
|
||||||
|
UPDATE `user` SET `group_id` = 'allow-all' WHERE `group_id` IS NULL;
|
||||||
|
|
||||||
|
INSERT INTO `sys_config` (`id`,`key`, `value`,`description`,`created_at`,`updated_at`)
|
||||||
|
VALUES ('xpack-resource-group-version','default_resource_group', 'allow-all', 'Default resource group for new users', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
|
||||||
|
ON DUPLICATE KEY UPDATE `value` = VALUES(`value`), `description` = VALUES(`description`), `updated_at` = CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO `sys_config` (`id`,`key`, `value`,`description`,`created_at`,`updated_at`)
|
||||||
|
VALUES ('xpack-version','version', '1.2.0', 'Add resource group tables', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
|
||||||
|
ON DUPLICATE KEY UPDATE `value` = VALUES(`value`), `description` = VALUES(`description`), `updated_at` = CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS=1;
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"version": "v1.1",
|
"version": "v1.2",
|
||||||
"releaseDate": "2025-10-17",
|
"releaseDate": "2025-12-22",
|
||||||
"description": "This is the latest release of the application.",
|
"description": "This is the latest release of the application.",
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"program": {
|
"program": {
|
||||||
"xpack_mcp_market": {
|
"xpack_mcp_market": {
|
||||||
"version": "v1.1.1",
|
"version": "v1.2.0",
|
||||||
"docker": "xpackai/xpack-mcp-market",
|
"docker": "xpackai/xpack-mcp-market",
|
||||||
"tar": "xpack-mcp-market.tar.gz",
|
"tar": "xpack-mcp-market.tar.gz",
|
||||||
"url": "https://public.eolinker.com/xpack/images/xpack-mcp-market.${VERSION}.${ARCH}.tar.gz"
|
"url": "https://public.eolinker.com/xpack/images/xpack-mcp-market.${VERSION}.${ARCH}.tar.gz"
|
||||||
|
|||||||
@@ -42,3 +42,5 @@ KEY_SOCIAL_ACCOUNT_FACEBOOK_URL = "social_account_facebook_url"
|
|||||||
KEY_SOCIAL_ACCOUNT_X_URL = "social_account_x_url"
|
KEY_SOCIAL_ACCOUNT_X_URL = "social_account_x_url"
|
||||||
|
|
||||||
KEY_CNAME_A_IP = "cname_a_ip"
|
KEY_CNAME_A_IP = "cname_a_ip"
|
||||||
|
|
||||||
|
KEY_DEFAULT_RESOURCE_GROUP = "default_resource_group"
|
||||||
@@ -38,15 +38,21 @@ def email_login(
|
|||||||
if not email or not password:
|
if not email or not password:
|
||||||
return ResponseUtils.error(message="email and password required", code=400)
|
return ResponseUtils.error(message="email and password required", code=400)
|
||||||
token = auth_service.email_login_by_password(email=email, password=password)
|
token = auth_service.email_login_by_password(email=email, password=password)
|
||||||
|
if token:
|
||||||
|
return ResponseUtils.success({"user_token": token})
|
||||||
|
else:
|
||||||
|
return ResponseUtils.error(message="login failed, please enter the correct account or password", code=401)
|
||||||
case "captcha":
|
case "captcha":
|
||||||
captcha = body.get("captcha")
|
captcha = body.get("captcha")
|
||||||
if not email or not captcha:
|
if not email or not captcha:
|
||||||
return ResponseUtils.error(message="email and captcha required", code=400)
|
return ResponseUtils.error(message="email and captcha required", code=400)
|
||||||
token = auth_service.email_login_by_captcha(email=email, captcha=captcha)
|
token = auth_service.email_login_by_captcha(email=email, captcha=captcha)
|
||||||
if token:
|
if token:
|
||||||
return ResponseUtils.success({"user_token": token})
|
return ResponseUtils.success({"user_token": token})
|
||||||
else:
|
else:
|
||||||
return ResponseUtils.error(message="login failed", code=401)
|
return ResponseUtils.error(message="login failed, please enter the correct captcha", code=401)
|
||||||
|
case _:
|
||||||
|
return ResponseUtils.error(message="email login mode not supported", code=400)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/email/send_captcha", response_model=dict)
|
@router.post("/email/send_captcha", response_model=dict)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
Includes endpoints to enable/disable services, update/delete services,
|
Includes endpoints to enable/disable services, update/delete services,
|
||||||
import OpenAPI definitions, and query service info and lists.
|
import OpenAPI definitions, and query service info and lists.
|
||||||
"""
|
"""
|
||||||
import uuid
|
|
||||||
import logging
|
import logging
|
||||||
from fastapi import APIRouter, Depends, Request, Body, UploadFile, File, HTTPException, Form
|
from fastapi import APIRouter, Depends, Request, Body, UploadFile, File, HTTPException, Form
|
||||||
from pydantic import BaseModel, HttpUrl
|
from pydantic import BaseModel, HttpUrl
|
||||||
@@ -11,14 +10,13 @@ from typing import Optional
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from services.common.database import get_db
|
from services.common.database import get_db
|
||||||
from services.common.utils.response_utils import ResponseUtils
|
from services.common.utils.response_utils import ResponseUtils
|
||||||
|
from services.common.utils.validation_utils import ValidationUtils
|
||||||
from services.admin_service.services.openapi_manager import openapi_manager
|
from services.admin_service.services.openapi_manager import openapi_manager
|
||||||
from services.admin_service.services.mcp_manager_service import McpManagerService, parse_tags_to_array
|
from services.admin_service.services.mcp_manager_service import McpManagerService, parse_tags_to_array
|
||||||
from services.common.utils.cache_utils import CacheUtils
|
|
||||||
from services.common.redis_keys import RedisKeys
|
|
||||||
from services.admin_service.utils.user_utils import UserUtils
|
from services.admin_service.utils.user_utils import UserUtils
|
||||||
from services.common import error_msg
|
from services.common import error_msg
|
||||||
from services.common.models.mcp_service import ChargeType
|
from services.common.models.mcp_service import ChargeType
|
||||||
|
from services.admin_service.services.resource_group_service import ResourceGroupService
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -33,6 +31,8 @@ class OpenApiRequest(BaseModel):
|
|||||||
def get_mcp_manager(db: Session = Depends(get_db)) -> McpManagerService:
|
def get_mcp_manager(db: Session = Depends(get_db)) -> McpManagerService:
|
||||||
return McpManagerService(db)
|
return McpManagerService(db)
|
||||||
|
|
||||||
|
def get_resource_group_service(db: Session = Depends(get_db)) -> ResourceGroupService:
|
||||||
|
return ResourceGroupService(db)
|
||||||
|
|
||||||
@router.put("/service/enabled", summary="On/Off MCP service")
|
@router.put("/service/enabled", summary="On/Off MCP service")
|
||||||
def update_mcp_service_enabled(request: Request, body: dict = Body(...), mcp_manager_service: McpManagerService = Depends(get_mcp_manager)):
|
def update_mcp_service_enabled(request: Request, body: dict = Body(...), mcp_manager_service: McpManagerService = Depends(get_mcp_manager)):
|
||||||
@@ -58,6 +58,26 @@ def update_mcp_service_info(request: Request, body: dict = Body(...), mcp_manage
|
|||||||
# Validate ID is required
|
# Validate ID is required
|
||||||
if not body.get("id"):
|
if not body.get("id"):
|
||||||
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
# Validate price is a positive number if charge_type is per_token
|
||||||
|
if body.get("charge_type") == ChargeType.PER_CALL:
|
||||||
|
price = body.get("price")
|
||||||
|
if price is None or price < 0:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INVALID_PRICE)
|
||||||
|
if body.get("charge_type") == ChargeType.PER_TOKEN:
|
||||||
|
input_token = body.get("input_token")
|
||||||
|
output_token = body.get("output_token")
|
||||||
|
|
||||||
|
if input_token is None or input_token < 0:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INVALID_INPUT_TOKEN)
|
||||||
|
if output_token is None or output_token < 0:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INVALID_OUTPUT_TOKEN)
|
||||||
|
|
||||||
|
base_url = body.get("base_url")
|
||||||
|
if base_url is not None:
|
||||||
|
try:
|
||||||
|
ValidationUtils.validate_url(base_url, "url")
|
||||||
|
except Exception:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INVALID_URL)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mcp_manager_service.update(body)
|
mcp_manager_service.update(body)
|
||||||
@@ -106,7 +126,8 @@ async def openapi_parse(
|
|||||||
|
|
||||||
return ResponseUtils.success(data=result)
|
return ResponseUtils.success(data=result)
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
return ResponseUtils.error(message=f"Request failed: {e.detail}", code=e.status_code)
|
logger.error(f"Request failed: {e.detail}")
|
||||||
|
return ResponseUtils.error(message=f"Request failed, please contact the administrator.", code=e.status_code)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
||||||
|
|
||||||
@@ -147,7 +168,8 @@ async def openapi_parse_update(
|
|||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return ResponseUtils.error(message=str(e))
|
return ResponseUtils.error(message=str(e))
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
return ResponseUtils.error(message=f"Request failed: {e.detail}", code=e.status_code)
|
logger.error(f"Request failed: {e.detail}")
|
||||||
|
return ResponseUtils.error(message=f"Request failed, please contact the administrator.", code=e.status_code)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to update service from OpenAPI: {str(e)}")
|
logger.error(f"Failed to update service from OpenAPI: {str(e)}")
|
||||||
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
||||||
@@ -201,11 +223,7 @@ def get_mcp_service_list(
|
|||||||
"slug_name": service.slug_name,
|
"slug_name": service.slug_name,
|
||||||
"short_description": service.short_description,
|
"short_description": service.short_description,
|
||||||
"long_description": service.long_description,
|
"long_description": service.long_description,
|
||||||
# "auth_method": service.auth_method.value if service.auth_method else None,
|
|
||||||
"base_url": service.base_url,
|
"base_url": service.base_url,
|
||||||
# "headers": json.loads(service.headers) if service.headers else [],
|
|
||||||
# "auth_header": service.auth_header,
|
|
||||||
# "auth_token": service.auth_token,
|
|
||||||
"charge_type": service.charge_type.value if service.charge_type else None,
|
"charge_type": service.charge_type.value if service.charge_type else None,
|
||||||
"price": str(float(service.price)) if service.price and service.charge_type == ChargeType.PER_CALL else "0.00",
|
"price": str(float(service.price)) if service.price and service.charge_type == ChargeType.PER_CALL else "0.00",
|
||||||
"input_token_price": str(float(service.input_token_price)) if service.input_token_price and service.charge_type == ChargeType.PER_TOKEN else "0.00",
|
"input_token_price": str(float(service.input_token_price)) if service.input_token_price and service.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
@@ -221,3 +239,125 @@ def get_mcp_service_list(
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to get service list: {str(e)}")
|
logger.error(f"Failed to get service list: {str(e)}")
|
||||||
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
||||||
|
|
||||||
|
@router.get("/service/list/simple", summary="Get MCP service simple list")
|
||||||
|
def get_mcp_service_simple_list(
|
||||||
|
request: Request, mcp_manager_service: McpManagerService = Depends(get_mcp_manager)
|
||||||
|
):
|
||||||
|
"""Get paginated list of all MCP services."""
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Fetch paginated data
|
||||||
|
services = mcp_manager_service.get_all()
|
||||||
|
service_list = [
|
||||||
|
{
|
||||||
|
"id": service.id,
|
||||||
|
"name": service.name,
|
||||||
|
"slug_name": service.slug_name,
|
||||||
|
"base_url": service.base_url,
|
||||||
|
"charge_type": service.charge_type.value if service.charge_type else None,
|
||||||
|
"price": str(float(service.price)) if service.price and service.charge_type == ChargeType.PER_CALL else "0.00",
|
||||||
|
"input_token_price": str(float(service.input_token_price)) if service.input_token_price and service.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"output_token_price": str(float(service.output_token_price)) if service.output_token_price and service.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"enabled": service.enabled,
|
||||||
|
}
|
||||||
|
for service in services
|
||||||
|
]
|
||||||
|
return ResponseUtils.success(data=service_list)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to get service simple list: {str(e)}")
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
||||||
|
|
||||||
|
@router.get("/service/resource_group/list", summary="Get MCP service's resource group list")
|
||||||
|
def get_mcp_service_resource_group_list(
|
||||||
|
request: Request,
|
||||||
|
id: str,
|
||||||
|
page: int = 1,
|
||||||
|
page_size: int = 10,
|
||||||
|
keyword: Optional[str] = None,
|
||||||
|
resource_group_service: ResourceGroupService = Depends(get_resource_group_service),
|
||||||
|
):
|
||||||
|
"""Get paginated list of all MCP services' resource groups."""
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
if not id:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
try:
|
||||||
|
# Fetch paginated data
|
||||||
|
list,total = resource_group_service.get_bind_groups(id, page=page, page_size=page_size, keyword=keyword)
|
||||||
|
|
||||||
|
return ResponseUtils.success_page(data=list, page_num=page, page_size=page_size, total=total)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to get service simple list: {str(e)}")
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
||||||
|
|
||||||
|
@router.get("/service/resource_group/list/unbind", summary="Get MCP service's unbind resource group list")
|
||||||
|
def get_mcp_service_unbind_resource_group_list(
|
||||||
|
request: Request,
|
||||||
|
id: str,
|
||||||
|
resource_group_service: ResourceGroupService = Depends(get_resource_group_service),
|
||||||
|
):
|
||||||
|
"""Get paginated list of all MCP services' unbind resource groups."""
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
if not id:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
try:
|
||||||
|
# Fetch paginated data
|
||||||
|
list = resource_group_service.get_unbind_groups(id)
|
||||||
|
|
||||||
|
return ResponseUtils.success(data=list)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to get unbind resource group list: {str(e)}")
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
||||||
|
|
||||||
|
|
||||||
|
@router.put("/service/resource_group", summary="Bind resource groups to MCP service")
|
||||||
|
def bind_group(
|
||||||
|
request: Request,
|
||||||
|
id: str,
|
||||||
|
body: dict = Body(...),
|
||||||
|
resource_group_service: ResourceGroupService = Depends(get_resource_group_service),
|
||||||
|
):
|
||||||
|
"""Bind resource groups to MCP service."""
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
if not id:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
group_ids = body.get("resource_groups")
|
||||||
|
if not group_ids:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
try:
|
||||||
|
# Fetch paginated data
|
||||||
|
resource_group_service.bind_groups(id, group_ids)
|
||||||
|
|
||||||
|
return ResponseUtils.success()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to bind resource groups: {str(e)}")
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
||||||
|
|
||||||
|
@router.delete("/service/resource_group", summary="Unbind resource groups from MCP service")
|
||||||
|
def unbind_group(
|
||||||
|
request: Request,
|
||||||
|
id: str,
|
||||||
|
body: dict = Body(...),
|
||||||
|
resource_group_service: ResourceGroupService = Depends(get_resource_group_service),
|
||||||
|
):
|
||||||
|
"""Unbind resource groups from MCP service."""
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
if not id:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
group_ids = body.get("resource_groups")
|
||||||
|
if not group_ids:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
try:
|
||||||
|
# Fetch paginated data
|
||||||
|
resource_group_service.unbind_groups(id, group_ids)
|
||||||
|
|
||||||
|
return ResponseUtils.success()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to unbind resource groups: {str(e)}")
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
import logging
|
||||||
|
import uuid
|
||||||
|
from fastapi import APIRouter, Depends, Request, Body
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from services.common.database import get_db
|
||||||
|
from services.common.utils.response_utils import ResponseUtils
|
||||||
|
from services.admin_service.utils.user_utils import UserUtils
|
||||||
|
from services.common import error_msg
|
||||||
|
from services.admin_service.services.resource_group_service import ResourceGroupService
|
||||||
|
from services.admin_service.services.sys_config_service import SysConfigService
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
def get_sysconfig_service(db: Session = Depends(get_db)) -> SysConfigService:
|
||||||
|
return SysConfigService(db)
|
||||||
|
|
||||||
|
def get_resource_group_service(db: Session = Depends(get_db)) -> ResourceGroupService:
|
||||||
|
return ResourceGroupService(db)
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("", summary="Create resource group")
|
||||||
|
def create_group(request: Request, body: dict = Body(...), svc: ResourceGroupService = Depends(get_resource_group_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
gid = body.get("id")
|
||||||
|
if not gid:
|
||||||
|
gid = str(uuid.uuid4())
|
||||||
|
name = body.get("name")
|
||||||
|
description = body.get("description")
|
||||||
|
if not name:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
is_default = body.get("is_default", False)
|
||||||
|
try:
|
||||||
|
gid = svc.create_group(gid=gid, name=name, description=description, is_default=is_default)
|
||||||
|
except ValueError as e:
|
||||||
|
return ResponseUtils.error(message=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
return ResponseUtils.success(data={"id": gid})
|
||||||
|
|
||||||
|
|
||||||
|
@router.put("", summary="Update resource group")
|
||||||
|
def update_group(request: Request,id: str, body: dict = Body(...), svc: ResourceGroupService = Depends(get_resource_group_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
try:
|
||||||
|
svc.update_group(id, body)
|
||||||
|
return ResponseUtils.success()
|
||||||
|
except ValueError as e:
|
||||||
|
return ResponseUtils.error(message=str(e))
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Failed to update group")
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR)
|
||||||
|
|
||||||
|
|
||||||
|
@router.delete("", summary="Delete resource group")
|
||||||
|
def delete_group(request: Request, id: str, migrate_id: str | None = None, svc: ResourceGroupService = Depends(get_resource_group_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
if not id:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
|
||||||
|
ok = svc.delete_group(id, migrate_id)
|
||||||
|
if not ok:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NOT_FOUND)
|
||||||
|
return ResponseUtils.success()
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/info", summary="Get resource group info")
|
||||||
|
def get_group_info(request: Request, id: str, svc: ResourceGroupService = Depends(get_resource_group_service), sys_svc: SysConfigService = Depends(get_sysconfig_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
info = svc.get_info(id)
|
||||||
|
if not info:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NOT_FOUND)
|
||||||
|
return ResponseUtils.success(data=info)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/list", summary="Get resource group list")
|
||||||
|
def get_group_list(request: Request, page: int = 1, page_size: int = 10, keyword: str | None = None, svc: ResourceGroupService = Depends(get_resource_group_service), sys_svc: SysConfigService = Depends(get_sysconfig_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
|
||||||
|
groups, total = svc.list_groups(page=page, page_size=page_size, keyword=keyword)
|
||||||
|
|
||||||
|
return ResponseUtils.success_page(data=groups, page_num=page, page_size=page_size, total=total)
|
||||||
|
|
||||||
|
@router.get("/list/simple", summary="Get resource group simple list")
|
||||||
|
def get_simple_group_list(request: Request, svc: ResourceGroupService = Depends(get_resource_group_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
|
||||||
|
groups = svc.simple_list_groups()
|
||||||
|
data = [
|
||||||
|
{
|
||||||
|
"id": g.id,
|
||||||
|
"name": g.name,
|
||||||
|
"created_at": str(g.created_at) if g.created_at else None,
|
||||||
|
}
|
||||||
|
for g in groups
|
||||||
|
]
|
||||||
|
return ResponseUtils.success(data=data)
|
||||||
|
|
||||||
|
@router.put("/service", summary="Bind services to group")
|
||||||
|
def bind_services(request: Request,id:str, body: dict = Body(...), svc: ResourceGroupService = Depends(get_resource_group_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
if not id:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
sids = body.get("services") or []
|
||||||
|
svc.bind_services(id, list(map(str, sids)))
|
||||||
|
return ResponseUtils.success()
|
||||||
|
|
||||||
|
@router.get("/service/list", summary="List services bound to group")
|
||||||
|
def list_bind_services(request: Request, id: str, page: int = 1, page_size: int = 10, keyword: str | None = None, svc: ResourceGroupService = Depends(get_resource_group_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
services,total = svc.get_bind_services(id, page=page, page_size=page_size, keyword=keyword)
|
||||||
|
|
||||||
|
return ResponseUtils.success_page(data=services, page_num=page, page_size=page_size, total=total)
|
||||||
|
|
||||||
|
@router.get("/service/list/unbind", summary="List services bound to group")
|
||||||
|
def list_unbind_services(request: Request, id: str, svc: ResourceGroupService = Depends(get_resource_group_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
services = svc.get_unbind_services(id)
|
||||||
|
|
||||||
|
return ResponseUtils.success(data=services)
|
||||||
|
|
||||||
|
|
||||||
|
@router.delete("/service", summary="Unbind one service from group")
|
||||||
|
def unbind_service(request: Request,id: str, body: dict = Body(...), svc: ResourceGroupService = Depends(get_resource_group_service)):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
sids = body.get("services")
|
||||||
|
if not id or not sids:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
svc.unbind_service(id, sids)
|
||||||
|
return ResponseUtils.success()
|
||||||
|
|
||||||
|
|
||||||
@@ -5,10 +5,6 @@ and to test email settings. All responses and comments are standardized in Engli
|
|||||||
"""
|
"""
|
||||||
from fastapi import APIRouter, Depends, Body
|
from fastapi import APIRouter, Depends, Body
|
||||||
import json
|
import json
|
||||||
import socket
|
|
||||||
import urllib.request
|
|
||||||
from typing import Optional
|
|
||||||
from sqlalchemy import false, table
|
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from services.common.database import get_db
|
from services.common.database import get_db
|
||||||
from services.common.utils.response_utils import ResponseUtils
|
from services.common.utils.response_utils import ResponseUtils
|
||||||
@@ -19,6 +15,10 @@ from services.admin_service.services.platform_report_service import PlatformRepo
|
|||||||
from services.admin_service.constants import sys_config_key
|
from services.admin_service.constants import sys_config_key
|
||||||
from services.common.logging_config import get_logger
|
from services.common.logging_config import get_logger
|
||||||
from services.admin_service.utils.ip import get_public_ip, get_local_ip
|
from services.admin_service.utils.ip import get_public_ip, get_local_ip
|
||||||
|
from services.common.utils.validation_utils import ValidationUtils
|
||||||
|
from services.common.exceptions import ValidationException
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
@@ -241,7 +241,12 @@ def set_sysconfig(
|
|||||||
email_smtp_password = email_config.get("smtp_password")
|
email_smtp_password = email_config.get("smtp_password")
|
||||||
email_smtp_sender = email_config.get("smtp_sender")
|
email_smtp_sender = email_config.get("smtp_sender")
|
||||||
|
|
||||||
|
if not domain:
|
||||||
|
# 正则检查domain格式
|
||||||
|
try:
|
||||||
|
domain = ValidationUtils.validate_domain(domain)
|
||||||
|
except ValidationException as e:
|
||||||
|
return ResponseUtils.error(message=str(e), code=400)
|
||||||
|
|
||||||
# Batch update configuration
|
# Batch update configuration
|
||||||
configs = [
|
configs = [
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ async def upload(
|
|||||||
filename = os.path.basename(filename)
|
filename = os.path.basename(filename)
|
||||||
|
|
||||||
# enforce content type and size limits
|
# enforce content type and size limits
|
||||||
allowed_types = {"image/jpeg", "image/png", "image/webp"}
|
allowed_types = {"image/jpeg", "image/png", "image/webp", "image/gif", "image/svg+xml"}
|
||||||
if img.content_type not in allowed_types:
|
if img.content_type not in allowed_types:
|
||||||
return ResponseUtils.error(message="Unsupported file type", code=400)
|
return ResponseUtils.error(message="Unsupported file type", code=400)
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from services.admin_service.utils.user_utils import UserUtils
|
|||||||
from services.admin_service.services.user_wallet_service import UserWalletService
|
from services.admin_service.services.user_wallet_service import UserWalletService
|
||||||
from services.admin_service.services.user_task_service import UserTaskService
|
from services.admin_service.services.user_task_service import UserTaskService
|
||||||
from services.admin_service.services.auth_service import AuthService
|
from services.admin_service.services.auth_service import AuthService
|
||||||
|
from services.admin_service.services.resource_group_service import ResourceGroupService
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@@ -23,8 +24,11 @@ def get_auth_service(db: Session = Depends(get_db)) -> AuthService:
|
|||||||
def get_user_task_service(db: Session = Depends(get_db)) -> UserTaskService:
|
def get_user_task_service(db: Session = Depends(get_db)) -> UserTaskService:
|
||||||
return UserTaskService(db)
|
return UserTaskService(db)
|
||||||
|
|
||||||
|
def get_resource_group_service(db: Session = Depends(get_db)) -> ResourceGroupService:
|
||||||
|
return ResourceGroupService(db)
|
||||||
|
|
||||||
@router.get("/info", response_model=dict)
|
@router.get("/info", response_model=dict)
|
||||||
def get_user(request: Request, user_wallet: UserWalletService = Depends(get_user_wallet), user_task: UserTaskService = Depends(get_user_task_service)):
|
def get_user(request: Request, user_wallet: UserWalletService = Depends(get_user_wallet), user_task: UserTaskService = Depends(get_user_task_service), resource_group_service: ResourceGroupService = Depends(get_resource_group_service)):
|
||||||
"""Get current user information and wallet balance."""
|
"""Get current user information and wallet balance."""
|
||||||
user_response = UserResponse()
|
user_response = UserResponse()
|
||||||
user_wallet_resp = UserWalletResponse()
|
user_wallet_resp = UserWalletResponse()
|
||||||
@@ -35,7 +39,15 @@ def get_user(request: Request, user_wallet: UserWalletService = Depends(get_user
|
|||||||
user_wallet_info = user_wallet.get_by_user_id(user.id)
|
user_wallet_info = user_wallet.get_by_user_id(user.id)
|
||||||
if user_wallet_info:
|
if user_wallet_info:
|
||||||
user_wallet_resp.balance = user_wallet_info.balance
|
user_wallet_resp.balance = user_wallet_info.balance
|
||||||
|
if not user.group_id:
|
||||||
|
user.group_id = "allow-all"
|
||||||
|
if user.group_id == "allow-all":
|
||||||
|
user_response.allow_all = True
|
||||||
|
elif user.group_id == "deny-all":
|
||||||
|
user_response.allow_all = False
|
||||||
|
else:
|
||||||
|
service_ids = resource_group_service.get_bind_service_ids(user.group_id)
|
||||||
|
user_response.service_ids = service_ids
|
||||||
user_response.user_id = user.id
|
user_response.user_id = user.id
|
||||||
user_response.user_name = user.name
|
user_response.user_name = user.name
|
||||||
user_response.user_email = user.email
|
user_response.user_email = user.email
|
||||||
|
|||||||
@@ -3,13 +3,18 @@ from sqlalchemy.orm import Session
|
|||||||
from fastapi import Depends
|
from fastapi import Depends
|
||||||
from services.admin_service.services.user_service import UserService
|
from services.admin_service.services.user_service import UserService
|
||||||
from services.admin_service.services.user_wallet_service import UserWalletService
|
from services.admin_service.services.user_wallet_service import UserWalletService
|
||||||
|
from services.admin_service.services.resource_group_service import ResourceGroupService
|
||||||
from services.common.database import get_db
|
from services.common.database import get_db
|
||||||
from services.common.response.user_manager_response import UserManagerResponse
|
from services.common.response.user_manager_response import UserManagerResponse
|
||||||
from services.common.utils.response_utils import ResponseUtils
|
from services.common.utils.response_utils import ResponseUtils
|
||||||
from services.common.utils.validation_utils import ValidationUtils
|
from services.common.utils.validation_utils import ValidationUtils
|
||||||
from services.common.logging_config import get_logger
|
from services.common.logging_config import get_logger
|
||||||
import json,hashlib
|
import json,hashlib
|
||||||
|
from services.common import error_msg
|
||||||
from services.admin_service.services.payment_service import PaymentService
|
from services.admin_service.services.payment_service import PaymentService
|
||||||
|
from services.admin_service.utils.user_utils import UserUtils
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
@@ -20,6 +25,10 @@ def get_user_wallet_service(db: Session = Depends(get_db)) -> UserWalletService:
|
|||||||
return UserWalletService(db)
|
return UserWalletService(db)
|
||||||
|
|
||||||
|
|
||||||
|
def get_resource_group_service(db: Session = Depends(get_db)) -> ResourceGroupService:
|
||||||
|
return ResourceGroupService(db)
|
||||||
|
|
||||||
|
|
||||||
def get_user_service(db: Session = Depends(get_db)) -> UserService:
|
def get_user_service(db: Session = Depends(get_db)) -> UserService:
|
||||||
return UserService(db)
|
return UserService(db)
|
||||||
|
|
||||||
@@ -27,6 +36,31 @@ def get_payment_service(db: Session = Depends(get_db)) -> PaymentService:
|
|||||||
return PaymentService(db)
|
return PaymentService(db)
|
||||||
|
|
||||||
|
|
||||||
|
@router.put("/resource_group", summary="update user resource group")
|
||||||
|
async def update_user_resource_group(
|
||||||
|
request: Request,
|
||||||
|
body: dict = Body(...),
|
||||||
|
user_service: UserService = Depends(get_user_service),
|
||||||
|
resource_group_service: ResourceGroupService = Depends(get_resource_group_service),
|
||||||
|
):
|
||||||
|
if not UserUtils.is_admin(request):
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION)
|
||||||
|
"""Update user resource group."""
|
||||||
|
user_id = body.get("user_id")
|
||||||
|
group_id = body.get("resource_group")
|
||||||
|
if not user_id or not group_id:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.MISSING_PARAMETER)
|
||||||
|
group = resource_group_service.get_info(group_id)
|
||||||
|
if not group:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.RESOURCE_NOT_FOUND)
|
||||||
|
user = user_service.get_by_id(user_id)
|
||||||
|
if not user:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.USER_NOT_FOUND)
|
||||||
|
user_service.update_resource_group(user_id, group_id)
|
||||||
|
return ResponseUtils.success()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/account", summary="Delete user account")
|
@router.delete("/account", summary="Delete user account")
|
||||||
async def delete_user(
|
async def delete_user(
|
||||||
id: str,
|
id: str,
|
||||||
@@ -76,7 +110,13 @@ async def get_user_list(
|
|||||||
user_list = []
|
user_list = []
|
||||||
for user in users:
|
for user in users:
|
||||||
wallet = user_wallet_service.get_by_user_id(user.id)
|
wallet = user_wallet_service.get_by_user_id(user.id)
|
||||||
user_list.append({"id": user.id, "email": user.email, "created_at": user.created_at, "balance": wallet.balance if wallet else 0})
|
user_list.append(
|
||||||
|
{"id": user.id,
|
||||||
|
"email": user.email,
|
||||||
|
"created_at": user.created_at,
|
||||||
|
"balance": wallet.balance if wallet else 0,
|
||||||
|
"group_id": user.group_id if user.group_id else "allow-all",
|
||||||
|
})
|
||||||
|
|
||||||
return ResponseUtils.success_page(data=user_list, total=total, page_num=page, page_size=page_size)
|
return ResponseUtils.success_page(data=user_list, total=total, page_num=page, page_size=page_size)
|
||||||
|
|
||||||
@@ -92,7 +132,6 @@ async def recharge_balance(
|
|||||||
# calculate md5 hash of the body and timestamp
|
# calculate md5 hash of the body and timestamp
|
||||||
md5_hash = hashlib.md5(f"{timestamp}{body_str}".encode('utf-8')).hexdigest()
|
md5_hash = hashlib.md5(f"{timestamp}{body_str}".encode('utf-8')).hexdigest()
|
||||||
calculated_sign = hashlib.sha256(md5_hash.encode('utf-8')).hexdigest()
|
calculated_sign = hashlib.sha256(md5_hash.encode('utf-8')).hexdigest()
|
||||||
print(f"sign: {sign}, calculated_sign: {calculated_sign},md5_hash: {md5_hash}")
|
|
||||||
if sign != calculated_sign:
|
if sign != calculated_sign:
|
||||||
return ResponseUtils.error(message="Invalid signature")
|
return ResponseUtils.error(message="Invalid signature")
|
||||||
try:
|
try:
|
||||||
@@ -107,7 +146,6 @@ async def recharge_balance(
|
|||||||
transaction_id = hashlib.md5(f"{timestamp}{user_id}{balance}{typ}".encode('utf-8')).hexdigest()
|
transaction_id = hashlib.md5(f"{timestamp}{user_id}{balance}{typ}".encode('utf-8')).hexdigest()
|
||||||
if payment_service.check_transaction_id_exists(transaction_id):
|
if payment_service.check_transaction_id_exists(transaction_id):
|
||||||
return ResponseUtils.error(message="Transaction ID already exists")
|
return ResponseUtils.error(message="Transaction ID already exists")
|
||||||
print(f"user_id: {user_id}, amount: {balance}, typ: {typ}, transaction_id: {transaction_id}")
|
|
||||||
success = payment_service.platform_payment(user_id=user_id, amount=balance, typ=typ, transaction_id=transaction_id)
|
success = payment_service.platform_payment(user_id=user_id, amount=balance, typ=typ, transaction_id=transaction_id)
|
||||||
if not success:
|
if not success:
|
||||||
return ResponseUtils.error(message="Failed to recharge wallet balance")
|
return ResponseUtils.error(message="Failed to recharge wallet balance")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from fastapi import APIRouter, Depends, Query
|
from fastapi import APIRouter, Depends, Query, Request
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from services.common.database import get_db
|
from services.common.database import get_db
|
||||||
@@ -6,6 +6,11 @@ from services.common.utils.response_utils import ResponseUtils
|
|||||||
from services.common.utils.validation_utils import ValidationUtils
|
from services.common.utils.validation_utils import ValidationUtils
|
||||||
from services.admin_service.services.mcp_manager_service import McpManagerService
|
from services.admin_service.services.mcp_manager_service import McpManagerService
|
||||||
from services.common.logging_config import get_logger
|
from services.common.logging_config import get_logger
|
||||||
|
from services.admin_service.utils.user_utils import UserUtils
|
||||||
|
from services.admin_service.services.resource_group_service import ResourceGroupService
|
||||||
|
from services.common import error_msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
@@ -15,6 +20,9 @@ router = APIRouter(tags=["front"])
|
|||||||
def get_mcp_manager(db: Session = Depends(get_db)) -> McpManagerService:
|
def get_mcp_manager(db: Session = Depends(get_db)) -> McpManagerService:
|
||||||
return McpManagerService(db)
|
return McpManagerService(db)
|
||||||
|
|
||||||
|
def get_resource_group_service(db: Session = Depends(get_db)) -> ResourceGroupService:
|
||||||
|
return ResourceGroupService(db)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/mcp_services", summary="Get public MCP services list")
|
@router.get("/mcp_services", summary="Get public MCP services list")
|
||||||
def get_public_mcp_services(
|
def get_public_mcp_services(
|
||||||
@@ -44,8 +52,10 @@ def get_public_mcp_services(
|
|||||||
|
|
||||||
@router.get("/mcp_service_info", summary="Get public MCP service information")
|
@router.get("/mcp_service_info", summary="Get public MCP service information")
|
||||||
def get_public_mcp_service_info(
|
def get_public_mcp_service_info(
|
||||||
|
request: Request,
|
||||||
id: str = Query(..., description="Service ID"),
|
id: str = Query(..., description="Service ID"),
|
||||||
mcp_manager_service: McpManagerService = Depends(get_mcp_manager),
|
mcp_manager_service: McpManagerService = Depends(get_mcp_manager),
|
||||||
|
resource_group_service: ResourceGroupService = Depends(get_resource_group_service),
|
||||||
):
|
):
|
||||||
"""Get detailed information of a public MCP service by ID."""
|
"""Get detailed information of a public MCP service by ID."""
|
||||||
|
|
||||||
@@ -56,6 +66,8 @@ def get_public_mcp_service_info(
|
|||||||
|
|
||||||
# Get service information - let any exception bubble up to middleware
|
# Get service information - let any exception bubble up to middleware
|
||||||
service_info = mcp_manager_service.get_public_service_info(id)
|
service_info = mcp_manager_service.get_public_service_info(id)
|
||||||
|
if not service_info:
|
||||||
|
return ResponseUtils.error(error_msg=error_msg.RESOURCE_NOT_FOUND)
|
||||||
|
|
||||||
# Validate that service exists
|
# Validate that service exists
|
||||||
ValidationUtils.require_resource_exists(service_info, "service")
|
ValidationUtils.require_resource_exists(service_info, "service")
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ from services.admin_service.controllers import user_stats
|
|||||||
from services.admin_service.controllers import email_test
|
from services.admin_service.controllers import email_test
|
||||||
from services.admin_service.controllers import upload
|
from services.admin_service.controllers import upload
|
||||||
from services.admin_service.controllers import user_task
|
from services.admin_service.controllers import user_task
|
||||||
|
from services.admin_service.controllers import resource_group
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -168,6 +169,7 @@ app.include_router(user_stats.router, prefix="/api/stats")
|
|||||||
app.include_router(email_test.router, prefix="/api/email_test")
|
app.include_router(email_test.router, prefix="/api/email_test")
|
||||||
app.include_router(upload.router, prefix="/api/upload")
|
app.include_router(upload.router, prefix="/api/upload")
|
||||||
app.include_router(user_task.router, prefix="/api/onboarding")
|
app.include_router(user_task.router, prefix="/api/onboarding")
|
||||||
|
app.include_router(resource_group.router, prefix="/api/resource_group")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,25 +54,41 @@ class McpServiceRepository:
|
|||||||
def get_by_id(self, id: str) -> Optional[McpService]:
|
def get_by_id(self, id: str) -> Optional[McpService]:
|
||||||
"""Get a service by primary ID."""
|
"""Get a service by primary ID."""
|
||||||
return self.db.query(McpService).filter(McpService.id == id).first()
|
return self.db.query(McpService).filter(McpService.id == id).first()
|
||||||
|
def get_by_ids(self, ids: List[str]) -> List[McpService]:
|
||||||
|
"""Get services by primary IDs."""
|
||||||
|
return self.db.query(McpService).filter(McpService.id.in_(ids)).all()
|
||||||
|
|
||||||
def get_by_slug_name(self, slug_name: str) -> Optional[McpService]:
|
def get_by_slug_name(self, slug_name: str) -> Optional[McpService]:
|
||||||
"""Get a service by unique slug name."""
|
"""Get a service by unique slug name."""
|
||||||
return self.db.query(McpService).filter(McpService.slug_name == slug_name).first()
|
return self.db.query(McpService).filter(McpService.slug_name == slug_name).first()
|
||||||
|
|
||||||
def get_all(self) -> List[McpService]:
|
def get_all(self, keyword: Optional[str] = None) -> List[McpService]:
|
||||||
"""List all services ordered by creation time descending."""
|
"""List all services ordered by creation time descending."""
|
||||||
return self.db.query(McpService).order_by(McpService.created_at.desc()).all()
|
query = self.db.query(McpService).order_by(McpService.created_at.desc())
|
||||||
|
if keyword:
|
||||||
|
keyword = f"%{keyword}%"
|
||||||
|
query = query.filter((McpService.name.like(keyword)) | (McpService.short_description.like(keyword)))
|
||||||
|
return query.all()
|
||||||
|
|
||||||
def get_all_paginated(self, page: int = 1, page_size: int = 10) -> Tuple[List[McpService], int]:
|
def get_all_paginated(self, page: int = 1, page_size: int = 10, keyword: Optional[str] = None) -> Tuple[List[McpService], int]:
|
||||||
"""Get service list with pagination"""
|
"""Get service list with pagination"""
|
||||||
offset = (page - 1) * page_size
|
offset = (page - 1) * page_size
|
||||||
|
|
||||||
total = self.db.query(McpService).count()
|
total = self.db.query(McpService).count()
|
||||||
|
|
||||||
services = self.db.query(McpService).order_by(McpService.created_at.desc()).offset(offset).limit(page_size).all()
|
query = self.db.query(McpService).order_by(McpService.created_at.desc()).offset(offset).limit(page_size)
|
||||||
|
if keyword:
|
||||||
|
keyword = f"%{keyword}%"
|
||||||
|
query = query.filter((McpService.name.like(keyword)) | (McpService.short_description.like(keyword)))
|
||||||
|
|
||||||
|
services = query.all()
|
||||||
|
|
||||||
return services, total
|
return services, total
|
||||||
|
|
||||||
|
def get_all_not_include(self, ids: List[str]) -> List[McpService]:
|
||||||
|
"""Get all services not include in ids"""
|
||||||
|
return self.db.query(McpService).order_by(McpService.created_at.desc()).filter(McpService.id.not_in(ids)).all()
|
||||||
|
|
||||||
def create(self, mcp_service: McpService) -> McpService:
|
def create(self, mcp_service: McpService) -> McpService:
|
||||||
"""Create a service; set timestamps if missing and persist."""
|
"""Create a service; set timestamps if missing and persist."""
|
||||||
# Set timestamps explicitly if not already set
|
# Set timestamps explicitly if not already set
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
from datetime import datetime, timezone
|
||||||
|
from typing import List, Optional, Tuple
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from services.common.models.resource_group import ResourceGroup
|
||||||
|
|
||||||
|
|
||||||
|
class ResourceGroupRepository:
|
||||||
|
def __init__(self, db: Session):
|
||||||
|
self.db = db
|
||||||
|
|
||||||
|
def create(self, group: ResourceGroup, commit: bool = True) -> ResourceGroup:
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
|
if not getattr(group, "created_at", None):
|
||||||
|
group.created_at = now
|
||||||
|
if not getattr(group, "updated_at", None):
|
||||||
|
group.updated_at = now
|
||||||
|
self.db.add(group)
|
||||||
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
|
self.db.refresh(group)
|
||||||
|
return group
|
||||||
|
|
||||||
|
def update(self, group: ResourceGroup, commit: bool = True) -> ResourceGroup:
|
||||||
|
existing = self.db.query(ResourceGroup).filter(ResourceGroup.id == group.id).first()
|
||||||
|
if not existing:
|
||||||
|
raise ValueError("Resource group not found")
|
||||||
|
if group.name is not None:
|
||||||
|
existing.name = group.name
|
||||||
|
if group.description is not None:
|
||||||
|
existing.description = group.description
|
||||||
|
if group.enabled is not None:
|
||||||
|
existing.enabled = group.enabled
|
||||||
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
|
self.db.refresh(existing)
|
||||||
|
return existing
|
||||||
|
|
||||||
|
def delete(self, id: str, commit: bool = True) -> Optional[ResourceGroup]:
|
||||||
|
existing = self.db.query(ResourceGroup).filter(ResourceGroup.id == id).first()
|
||||||
|
if not existing:
|
||||||
|
return None
|
||||||
|
self.db.delete(existing)
|
||||||
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
|
return existing
|
||||||
|
|
||||||
|
def get_by_id(self, id: str) -> Optional[ResourceGroup]:
|
||||||
|
return self.db.query(ResourceGroup).filter(ResourceGroup.id == id).first()
|
||||||
|
|
||||||
|
def get_all_not_include(self, ids: List[str]) -> List[ResourceGroup]:
|
||||||
|
"""Get all groups not include in ids"""
|
||||||
|
return self.db.query(ResourceGroup).filter(ResourceGroup.id.not_in(ids)).all()
|
||||||
|
|
||||||
|
def get_all_paginated(self, page: int = 1, page_size: int = 10, keyword: Optional[str] = None) -> Tuple[List[ResourceGroup], int]:
|
||||||
|
offset = (page - 1) * page_size
|
||||||
|
query = self.db.query(ResourceGroup)
|
||||||
|
if keyword:
|
||||||
|
query = query.filter(ResourceGroup.name.like(f"%{keyword}%"))
|
||||||
|
total = query.count()
|
||||||
|
groups = (
|
||||||
|
query.order_by(ResourceGroup.created_at.desc()).offset(offset).limit(page_size).all()
|
||||||
|
)
|
||||||
|
return groups, total
|
||||||
|
|
||||||
|
def get_all(self,keyword: Optional[str] = None) -> List[ResourceGroup]:
|
||||||
|
query = self.db.query(ResourceGroup)
|
||||||
|
if keyword:
|
||||||
|
query = query.filter(ResourceGroup.name.like(f"%{keyword}%"))
|
||||||
|
return query.order_by(ResourceGroup.created_at.desc()).all()
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
from typing import List, Tuple, Optional
|
||||||
|
from datetime import datetime
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from services.common.models.resource_group import ResourceGroupServiceMap
|
||||||
|
|
||||||
|
|
||||||
|
class ResourceGroupServiceMapRepository:
|
||||||
|
def __init__(self, db: Session):
|
||||||
|
self.db = db
|
||||||
|
|
||||||
|
def bind_group(self, service_id: str, group_ids: List[str], commit: bool = True) -> int:
|
||||||
|
created = 0
|
||||||
|
now = datetime.now()
|
||||||
|
for gid in group_ids:
|
||||||
|
exists = (
|
||||||
|
self.db.query(ResourceGroupServiceMap)
|
||||||
|
.filter(ResourceGroupServiceMap.group_id == gid, ResourceGroupServiceMap.service_id == service_id)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if exists:
|
||||||
|
continue
|
||||||
|
mapping = ResourceGroupServiceMap(group_id=gid, service_id=service_id, created_at=now)
|
||||||
|
self.db.add(mapping)
|
||||||
|
created += 1
|
||||||
|
if created and commit:
|
||||||
|
self.db.commit()
|
||||||
|
return created
|
||||||
|
|
||||||
|
def unbind_group(self, service_id: str, group_ids: List[str], commit: bool = True) -> int:
|
||||||
|
q = (
|
||||||
|
self.db.query(ResourceGroupServiceMap)
|
||||||
|
.filter(ResourceGroupServiceMap.group_id.in_(group_ids), ResourceGroupServiceMap.service_id == service_id)
|
||||||
|
)
|
||||||
|
count = q.count()
|
||||||
|
if count:
|
||||||
|
q.delete()
|
||||||
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
|
return count
|
||||||
|
|
||||||
|
def bind_services(self, group_id: str, service_ids: List[str], commit: bool = True) -> int:
|
||||||
|
created = 0
|
||||||
|
now = datetime.now()
|
||||||
|
for sid in service_ids:
|
||||||
|
exists = (
|
||||||
|
self.db.query(ResourceGroupServiceMap)
|
||||||
|
.filter(ResourceGroupServiceMap.group_id == group_id, ResourceGroupServiceMap.service_id == sid)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if exists:
|
||||||
|
continue
|
||||||
|
mapping = ResourceGroupServiceMap(group_id=group_id, service_id=sid, created_at=now)
|
||||||
|
self.db.add(mapping)
|
||||||
|
created += 1
|
||||||
|
if created and commit:
|
||||||
|
self.db.commit()
|
||||||
|
return created
|
||||||
|
|
||||||
|
def unbind_service(self, group_id: str, service_id: str, commit: bool = True) -> int:
|
||||||
|
q = (
|
||||||
|
self.db.query(ResourceGroupServiceMap)
|
||||||
|
.filter(ResourceGroupServiceMap.group_id == group_id, ResourceGroupServiceMap.service_id == service_id)
|
||||||
|
)
|
||||||
|
count = q.count()
|
||||||
|
if count:
|
||||||
|
q.delete()
|
||||||
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
|
return count
|
||||||
|
|
||||||
|
def list_group_ids_paginated(self, service_id: str, page: int = 1, page_size: int = 10, group_ids: Optional[List[str]] = None) -> Tuple[List[dict], int]:
|
||||||
|
offset = (page - 1) * page_size
|
||||||
|
query = self.db.query(ResourceGroupServiceMap).filter(ResourceGroupServiceMap.service_id == service_id)
|
||||||
|
if group_ids:
|
||||||
|
query = query.filter(ResourceGroupServiceMap.group_id.in_(group_ids))
|
||||||
|
total = query.count()
|
||||||
|
groups = (
|
||||||
|
query.order_by(ResourceGroupServiceMap.created_at.desc()).offset(offset).limit(page_size).all()
|
||||||
|
)
|
||||||
|
return [{"id": r.group_id, "join_at": r.created_at} for r in groups], total
|
||||||
|
|
||||||
|
def list_service_ids_paginated(self, group_id: str, page: int = 1, page_size: int = 10,service_ids: Optional[List[str]] = None) -> Tuple[List[str], int]:
|
||||||
|
offset = (page - 1) * page_size
|
||||||
|
query = self.db.query(ResourceGroupServiceMap).filter(ResourceGroupServiceMap.group_id == group_id)
|
||||||
|
if service_ids:
|
||||||
|
query = query.filter(ResourceGroupServiceMap.service_id.in_(service_ids))
|
||||||
|
total = query.count()
|
||||||
|
groups = (
|
||||||
|
query.order_by(ResourceGroupServiceMap.created_at.desc()).offset(offset).limit(page_size).all()
|
||||||
|
)
|
||||||
|
return [r.service_id for r in groups], total
|
||||||
|
|
||||||
|
def list_service_ids(self, group_id: str) -> List[str]:
|
||||||
|
return [r.service_id for r in self.db.query(ResourceGroupServiceMap.service_id).order_by(ResourceGroupServiceMap.created_at.desc()).filter(ResourceGroupServiceMap.group_id == group_id).all()]
|
||||||
|
|
||||||
|
def list_group_ids(self, service_id: str) -> List[str]:
|
||||||
|
return [r.group_id for r in self.db.query(ResourceGroupServiceMap.group_id).filter(ResourceGroupServiceMap.service_id == service_id).all()]
|
||||||
|
|
||||||
|
def migrate_services(self, from_group_id: str, to_group_id: str, commit: bool = True) -> int:
|
||||||
|
# 过滤已经在新分组的服务
|
||||||
|
existing_services = (
|
||||||
|
self.db.query(ResourceGroupServiceMap.service_id)
|
||||||
|
.filter(ResourceGroupServiceMap.group_id == to_group_id)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
existing_service_ids = [item.service_id for item in existing_services]
|
||||||
|
q = (
|
||||||
|
self.db.query(ResourceGroupServiceMap)
|
||||||
|
.filter(ResourceGroupServiceMap.group_id == from_group_id, ~ResourceGroupServiceMap.service_id.in_(existing_service_ids))
|
||||||
|
)
|
||||||
|
count = q.count()
|
||||||
|
# 获取当前时间
|
||||||
|
now = datetime.now()
|
||||||
|
if count:
|
||||||
|
q.update({ResourceGroupServiceMap.group_id: to_group_id, ResourceGroupServiceMap.created_at: now})
|
||||||
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
|
return count
|
||||||
|
|
||||||
|
def delete_by_group_id(self, group_id: str, commit: bool = True) -> int:
|
||||||
|
q = self.db.query(ResourceGroupServiceMap).filter(ResourceGroupServiceMap.group_id == group_id)
|
||||||
|
count = q.count()
|
||||||
|
if count:
|
||||||
|
q.delete()
|
||||||
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
|
return count
|
||||||
@@ -24,14 +24,15 @@ class SysConfigRepository:
|
|||||||
if sys_config:
|
if sys_config:
|
||||||
return sys_config.value
|
return sys_config.value
|
||||||
return None
|
return None
|
||||||
def set_value_by_key(self, key: str, value: str,description:str) -> Optional[SysConfig]:
|
def set_value_by_key(self, key: str, value: str, description: str, commit: bool = True) -> Optional[SysConfig]:
|
||||||
"""Set or create value and description for a key; returns entity."""
|
"""Set or create value and description for a key; returns entity."""
|
||||||
sys_config = self.get_by_key(key)
|
sys_config = self.get_by_key(key)
|
||||||
if sys_config:
|
if sys_config:
|
||||||
sys_config.value = value
|
sys_config.value = value
|
||||||
sys_config.description = description
|
sys_config.description = description
|
||||||
self.db.commit()
|
if commit:
|
||||||
self.db.refresh(sys_config)
|
self.db.commit()
|
||||||
|
self.db.refresh(sys_config)
|
||||||
return sys_config
|
return sys_config
|
||||||
sys_config = SysConfig(
|
sys_config = SysConfig(
|
||||||
id=str(uuid.uuid4()),
|
id=str(uuid.uuid4()),
|
||||||
@@ -42,13 +43,15 @@ class SysConfigRepository:
|
|||||||
updated_at=datetime.now(timezone.utc),
|
updated_at=datetime.now(timezone.utc),
|
||||||
)
|
)
|
||||||
self.db.add(sys_config)
|
self.db.add(sys_config)
|
||||||
self.db.commit()
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
return sys_config
|
return sys_config
|
||||||
def delete_by_key(self, key: str) -> bool:
|
def delete_by_key(self, key: str, commit: bool = True) -> bool:
|
||||||
"""Delete config by key; returns True if deleted, else False."""
|
"""Delete config by key; returns True if deleted, else False."""
|
||||||
sys_config = self.get_by_key(key)
|
sys_config = self.get_by_key(key)
|
||||||
if sys_config:
|
if sys_config:
|
||||||
self.db.delete(sys_config)
|
self.db.delete(sys_config)
|
||||||
self.db.commit()
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@@ -28,7 +28,7 @@ class UserRepository:
|
|||||||
self.db.refresh(user)
|
self.db.refresh(user)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
def create(self, email: str, register_type: str, role_id: int = 2, password: Optional[str] = None) -> Optional[User]:
|
def create(self, email: str, register_type: str, role_id: int = 2, group_id: str = "", password: Optional[str] = None) -> Optional[User]:
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from services.common.models.user import RegisterType
|
from services.common.models.user import RegisterType
|
||||||
|
|
||||||
@@ -44,6 +44,7 @@ class UserRepository:
|
|||||||
is_deleted=0,
|
is_deleted=0,
|
||||||
register_type=RegisterType(register_type),
|
register_type=RegisterType(register_type),
|
||||||
role_id=role_id,
|
role_id=role_id,
|
||||||
|
group_id=group_id,
|
||||||
created_at=now,
|
created_at=now,
|
||||||
updated_at=now
|
updated_at=now
|
||||||
)
|
)
|
||||||
@@ -84,7 +85,7 @@ class UserRepository:
|
|||||||
def get_user_list(self, offset: int, limit: int) -> Tuple[int, List[User]]:
|
def get_user_list(self, offset: int, limit: int) -> Tuple[int, List[User]]:
|
||||||
total = self.db.query(User).filter(User.is_deleted == 0, User.role_id == 2).count()
|
total = self.db.query(User).filter(User.is_deleted == 0, User.role_id == 2).count()
|
||||||
|
|
||||||
users = self.db.query(User).filter(User.is_deleted == 0, User.role_id == 2).offset(offset).limit(limit).all()
|
users = self.db.query(User).filter(User.is_deleted == 0, User.role_id == 2).order_by(User.created_at.desc()).offset(offset).limit(limit).all()
|
||||||
return total, users
|
return total, users
|
||||||
|
|
||||||
def get_admin_user(self) -> Optional[User]:
|
def get_admin_user(self) -> Optional[User]:
|
||||||
@@ -188,3 +189,22 @@ class UserRepository:
|
|||||||
current_day += timedelta(days=1)
|
current_day += timedelta(days=1)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def update_resource_group(self, user_id: str, group_id: str) -> Optional[User]:
|
||||||
|
"""Update user resource group"""
|
||||||
|
user = self.db.query(User).filter(User.id == user_id, User.is_deleted == 0).first()
|
||||||
|
if not user:
|
||||||
|
return None
|
||||||
|
user.group_id = group_id
|
||||||
|
self.db.commit()
|
||||||
|
self.db.refresh(user)
|
||||||
|
return user
|
||||||
|
def update_resource_group_by_group_id(self, group_id: str, new_group_id: str, commit: bool = True) -> List[User]:
|
||||||
|
"""Update user resource group"""
|
||||||
|
users = self.db.query(User).filter(User.group_id == group_id, User.is_deleted == 0).all()
|
||||||
|
if not users:
|
||||||
|
return []
|
||||||
|
for user in users:
|
||||||
|
user.group_id = new_group_id
|
||||||
|
if commit:
|
||||||
|
self.db.commit()
|
||||||
|
return users
|
||||||
@@ -42,6 +42,7 @@ class UserWalletHistoryRepository:
|
|||||||
amount=amount,
|
amount=amount,
|
||||||
balance_after=0.00,
|
balance_after=0.00,
|
||||||
type=TransactionType.DEPOSIT,
|
type=TransactionType.DEPOSIT,
|
||||||
|
transaction_id=transaction_id,
|
||||||
status=status,
|
status=status,
|
||||||
created_at=now,
|
created_at=now,
|
||||||
updated_at=now,
|
updated_at=now,
|
||||||
@@ -201,7 +202,7 @@ class UserWalletHistoryRepository:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Update wallet balance and order status
|
# Update wallet balance and order status
|
||||||
wallet.balance = float(wallet.balance) + float(obj.amount)
|
# wallet.balance = float(wallet.balance) + float(obj.amount)
|
||||||
obj.status = 1 # 1=completed
|
obj.status = 1 # 1=completed
|
||||||
obj.balance_after = float(wallet.balance)
|
obj.balance_after = float(wallet.balance)
|
||||||
obj.transaction_id = transaction_id
|
obj.transaction_id = transaction_id
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from services.admin_service.services.sys_config_service import SysConfigService
|
|||||||
from services.admin_service.constants.sys_config_key import (
|
from services.admin_service.constants.sys_config_key import (
|
||||||
KEY_LOGIN_GOOGLE_CLIENT,
|
KEY_LOGIN_GOOGLE_CLIENT,
|
||||||
KEY_LOGIN_GOOGLE_SECRET,
|
KEY_LOGIN_GOOGLE_SECRET,
|
||||||
|
KEY_DEFAULT_RESOURCE_GROUP,
|
||||||
)
|
)
|
||||||
from services.common.utils.auth import delete_token
|
from services.common.utils.auth import delete_token
|
||||||
|
|
||||||
@@ -76,7 +77,8 @@ class AuthService:
|
|||||||
|
|
||||||
# User doesn't exist, register first
|
# User doesn't exist, register first
|
||||||
if user is None:
|
if user is None:
|
||||||
user = self.user_repository.create(email=email, register_type="email", role_id=2)
|
group_id = self.sys_config_service.get_value_by_key(KEY_DEFAULT_RESOURCE_GROUP)
|
||||||
|
user = self.user_repository.create(email=email, register_type="email", role_id=2, group_id=group_id)
|
||||||
if user is None:
|
if user is None:
|
||||||
logger.warning(f"Failed to register user with email: {email}")
|
logger.warning(f"Failed to register user with email: {email}")
|
||||||
return None
|
return None
|
||||||
@@ -94,7 +96,8 @@ class AuthService:
|
|||||||
user = self.user_repository.get_by_email(email)
|
user = self.user_repository.get_by_email(email)
|
||||||
# User doesn't exist, register first
|
# User doesn't exist, register first
|
||||||
if user is None:
|
if user is None:
|
||||||
user = self.user_repository.create(email=email, register_type="email", role_id=2,password=password)
|
group_id = self.sys_config_service.get_value_by_key(KEY_DEFAULT_RESOURCE_GROUP)
|
||||||
|
user = self.user_repository.create(email=email, register_type="email", role_id=2, group_id=group_id, password=password)
|
||||||
|
|
||||||
if user is None:
|
if user is None:
|
||||||
logger.warning(f"Failed to register user with email: {email}")
|
logger.warning(f"Failed to register user with email: {email}")
|
||||||
@@ -134,10 +137,17 @@ class AuthService:
|
|||||||
|
|
||||||
def account_login(self, account: str, password: str) -> Optional[str]:
|
def account_login(self, account: str, password: str) -> Optional[str]:
|
||||||
user = self.user_repository.get_by_account(account)
|
user = self.user_repository.get_by_account(account)
|
||||||
if user and user.password == password:
|
if user is None:
|
||||||
token = self.create_user_token(user.id)
|
logger.warning(f"not found user, account: {account}")
|
||||||
if token:
|
return None
|
||||||
return token
|
if user.password != password:
|
||||||
|
logger.warning(f"password not match, account: {account}, password: {password}, user password: {user.password}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
token = self.create_user_token(user.id)
|
||||||
|
if token:
|
||||||
|
return token
|
||||||
|
logger.warning(f"Failed to create user token for user_id: {user.id}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def logout(self, token: str) -> bool:
|
def logout(self, token: str) -> bool:
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import logging
|
|||||||
import uuid
|
import uuid
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from datetime import datetime, timezone
|
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from typing import Optional, Tuple, List
|
from typing import Optional, Tuple, List
|
||||||
from services.admin_service.repositories.mcp_service_repository import McpServiceRepository
|
from services.admin_service.repositories.mcp_service_repository import McpServiceRepository
|
||||||
@@ -143,10 +142,7 @@ class McpManagerService:
|
|||||||
existing_service.short_description = temp_service.short_description
|
existing_service.short_description = temp_service.short_description
|
||||||
existing_service.long_description = temp_service.long_description
|
existing_service.long_description = temp_service.long_description
|
||||||
existing_service.headers = temp_service.headers
|
existing_service.headers = temp_service.headers
|
||||||
# existing_service.auth_method = AuthMethod(temp_service.auth_method.value)
|
|
||||||
existing_service.base_url = temp_service.base_url
|
existing_service.base_url = temp_service.base_url
|
||||||
# existing_service.auth_header = temp_service.auth_header
|
|
||||||
# existing_service.auth_token = temp_service.auth_token
|
|
||||||
existing_service.charge_type = ChargeType(temp_service.charge_type.value)
|
existing_service.charge_type = ChargeType(temp_service.charge_type.value)
|
||||||
existing_service.price = temp_service.price
|
existing_service.price = temp_service.price
|
||||||
existing_service.input_token_price = temp_service.input_token_price
|
existing_service.input_token_price = temp_service.input_token_price
|
||||||
@@ -239,7 +235,8 @@ class McpManagerService:
|
|||||||
else:
|
else:
|
||||||
# If provided as string, store directly
|
# If provided as string, store directly
|
||||||
existing_service.tags = body["tags"]
|
existing_service.tags = body["tags"]
|
||||||
|
if not existing_service.service_type:
|
||||||
|
existing_service.service_type = "openapi"
|
||||||
# Commit changes
|
# Commit changes
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
self.db.refresh(existing_service)
|
self.db.refresh(existing_service)
|
||||||
@@ -369,6 +366,7 @@ class McpManagerService:
|
|||||||
mcp_service.charge_type = ChargeType.FREE # Default to free
|
mcp_service.charge_type = ChargeType.FREE # Default to free
|
||||||
mcp_service.price = 0.0
|
mcp_service.price = 0.0
|
||||||
mcp_service.enabled = 0 # Default disabled, requires manual activation by user
|
mcp_service.enabled = 0 # Default disabled, requires manual activation by user
|
||||||
|
mcp_service.service_type = "openapi"
|
||||||
|
|
||||||
# Save service
|
# Save service
|
||||||
self.mcp_service_repository.create(mcp_service)
|
self.mcp_service_repository.create(mcp_service)
|
||||||
@@ -433,15 +431,13 @@ class McpManagerService:
|
|||||||
temp_service.slug_name = existing_service.slug_name # Keep original slug_name
|
temp_service.slug_name = existing_service.slug_name # Keep original slug_name
|
||||||
temp_service.short_description = openapi_data.description or existing_service.short_description
|
temp_service.short_description = openapi_data.description or existing_service.short_description
|
||||||
temp_service.long_description = openapi_data.description or existing_service.long_description
|
temp_service.long_description = openapi_data.description or existing_service.long_description
|
||||||
# temp_service.auth_method = TempAuthMethod(existing_service.auth_method.value) # Keep original auth method
|
|
||||||
temp_service.base_url = existing_service.base_url # Keep original base_url
|
temp_service.base_url = existing_service.base_url # Keep original base_url
|
||||||
# temp_service.auth_header = existing_service.auth_header
|
|
||||||
# temp_service.auth_token = existing_service.auth_token
|
|
||||||
temp_service.headers = existing_service.headers # Keep original headers
|
temp_service.headers = existing_service.headers # Keep original headers
|
||||||
temp_service.charge_type = TempChargeType(existing_service.charge_type.value) # Keep original charge type
|
temp_service.charge_type = TempChargeType(existing_service.charge_type.value) # Keep original charge type
|
||||||
temp_service.price = existing_service.price # Keep original price
|
temp_service.price = existing_service.price # Keep original price
|
||||||
temp_service.enabled = existing_service.enabled # Keep original enabled status
|
temp_service.enabled = existing_service.enabled # Keep original enabled status
|
||||||
temp_service.tags = existing_service.tags # Keep original tags
|
temp_service.tags = existing_service.tags # Keep original tags
|
||||||
|
# temp_service.service_type = existing_service.service_type # Keep original service type
|
||||||
|
|
||||||
# Save temporary service record
|
# Save temporary service record
|
||||||
self.temp_mcp_service_repository.create(temp_service)
|
self.temp_mcp_service_repository.create(temp_service)
|
||||||
@@ -476,7 +472,7 @@ class McpManagerService:
|
|||||||
# 5. Build return data
|
# 5. Build return data
|
||||||
apis_list = []
|
apis_list = []
|
||||||
for temp_api in temp_apis:
|
for temp_api in temp_apis:
|
||||||
api_dict = {"id": temp_api.id, "name": temp_api.name, "description": temp_api.description}
|
api_dict = {"id": temp_api.id, "name": temp_api.name,"url": temp_api.path, "description": temp_api.description}
|
||||||
apis_list.append(api_dict)
|
apis_list.append(api_dict)
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
@@ -484,22 +480,13 @@ class McpManagerService:
|
|||||||
"name": temp_service.name,
|
"name": temp_service.name,
|
||||||
"short_description": temp_service.short_description,
|
"short_description": temp_service.short_description,
|
||||||
"long_description": temp_service.long_description,
|
"long_description": temp_service.long_description,
|
||||||
"base_url": temp_service.base_url,
|
|
||||||
"headers": json.loads(temp_service.headers) if temp_service.headers else [],
|
|
||||||
"charge_type": temp_service.charge_type.value if temp_service.charge_type else None,
|
|
||||||
"price": str(float(temp_service.price)) if temp_service.price and temp_service.charge_type == ChargeType.PER_CALL else "0.00",
|
|
||||||
"input_token_price": str(float(temp_service.input_token_price)) if temp_service.input_token_price and temp_service.charge_type == ChargeType.PER_TOKEN else "0.00",
|
|
||||||
"output_token_price": str(float(temp_service.output_token_price)) if temp_service.output_token_price and temp_service.charge_type == ChargeType.PER_TOKEN else "0.00",
|
|
||||||
"enabled": temp_service.enabled,
|
|
||||||
"tags": parse_tags_to_array(temp_service.tags),
|
|
||||||
"apis": apis_list,
|
"apis": apis_list,
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to update service from OpenAPI: {str(e)}")
|
logger.error(f"Failed to update service from OpenAPI: {str(e)}")
|
||||||
raise ValueError(f"Failed to update service from OpenAPI: {str(e)}")
|
raise ValueError(f"Failed to update service from OpenAPI.")
|
||||||
|
|
||||||
def get_public_services_paginated(self, keyword: str, page: int = 1, page_size: int = 10) -> Tuple[List[dict], int]:
|
def get_public_services_paginated(self, keyword: str, page: int = 1, page_size: int = 10) -> Tuple[List[dict], int]:
|
||||||
"""Get public services list with pagination, returns formatted data with API info"""
|
"""Get public services list with pagination, returns formatted data with API info"""
|
||||||
@@ -558,7 +545,7 @@ class McpManagerService:
|
|||||||
|
|
||||||
# Build return data (according to API specification format)
|
# Build return data (according to API specification format)
|
||||||
service_info = {
|
service_info = {
|
||||||
"id": service.slug_name,
|
"id": service.id,
|
||||||
"name": service.name,
|
"name": service.name,
|
||||||
"short_description": service.short_description,
|
"short_description": service.short_description,
|
||||||
"long_description": service.long_description,
|
"long_description": service.long_description,
|
||||||
|
|||||||
@@ -313,6 +313,7 @@ class PaymentService:
|
|||||||
new_balance=new_balance,
|
new_balance=new_balance,
|
||||||
expected_balance=current_wallet.balance
|
expected_balance=current_wallet.balance
|
||||||
)
|
)
|
||||||
|
logger.info(f"Attempt {attempt + 1}: Balance update successful for user_id {user_id}, new balance: {new_balance},success:{success}")
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
self._delete_wallet_cache(user_id)
|
self._delete_wallet_cache(user_id)
|
||||||
|
|||||||
@@ -0,0 +1,388 @@
|
|||||||
|
import uuid
|
||||||
|
from typing import Dict, List, Optional, Tuple
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from services.common.models.resource_group import ResourceGroup
|
||||||
|
from services.admin_service.repositories.resource_group_repository import ResourceGroupRepository
|
||||||
|
from services.admin_service.repositories.resource_group_service_map_repository import ResourceGroupServiceMapRepository
|
||||||
|
from services.admin_service.repositories.user_repository import UserRepository
|
||||||
|
from services.admin_service.repositories.mcp_service_repository import McpServiceRepository
|
||||||
|
from services.admin_service.repositories.sys_config_repository import SysConfigRepository
|
||||||
|
from services.admin_service.constants.sys_config_key import KEY_DEFAULT_RESOURCE_GROUP
|
||||||
|
from services.common.models.mcp_service import ChargeType
|
||||||
|
from services.common.redis import redis_client
|
||||||
|
|
||||||
|
|
||||||
|
class ResourceGroupService:
|
||||||
|
def __init__(self, db: Session):
|
||||||
|
self.db = db
|
||||||
|
self.redis = redis_client
|
||||||
|
self.group_repo = ResourceGroupRepository(db)
|
||||||
|
self.user_repo = UserRepository(db)
|
||||||
|
self.map_repo = ResourceGroupServiceMapRepository(db)
|
||||||
|
self.mcp_repo = McpServiceRepository(db)
|
||||||
|
self.sys_repo = SysConfigRepository(db)
|
||||||
|
|
||||||
|
def create_group(self, gid: str, name: str, description: Optional[str], is_default: bool = False) -> str:
|
||||||
|
try:
|
||||||
|
if gid != "deny-all" and gid != "allow-all":
|
||||||
|
group = ResourceGroup()
|
||||||
|
group.id = gid
|
||||||
|
group.name = name
|
||||||
|
group.description = description or ""
|
||||||
|
group.enabled = 1
|
||||||
|
result = self.group_repo.create(group, commit=False)
|
||||||
|
if result is None:
|
||||||
|
raise ValueError("Failed to create resource group")
|
||||||
|
|
||||||
|
if is_default:
|
||||||
|
self.sys_repo.set_value_by_key(key=KEY_DEFAULT_RESOURCE_GROUP, value=gid, description="Default resource group", commit=False)
|
||||||
|
self.db.commit()
|
||||||
|
return gid
|
||||||
|
except Exception:
|
||||||
|
self.db.rollback()
|
||||||
|
raise
|
||||||
|
|
||||||
|
def update_group(self, gid: str, body: dict) -> bool:
|
||||||
|
if not gid:
|
||||||
|
raise ValueError("Group ID is required")
|
||||||
|
existing = self.group_repo.get_by_id(gid)
|
||||||
|
if not existing:
|
||||||
|
raise ValueError("Resource group not found")
|
||||||
|
try:
|
||||||
|
if gid != "deny-all" and gid != "allow-all":
|
||||||
|
patch = ResourceGroup()
|
||||||
|
patch.id = gid
|
||||||
|
patch.name = body.get("name", existing.name)
|
||||||
|
patch.description = body.get("description", existing.description)
|
||||||
|
patch.enabled = body.get("enabled", existing.enabled)
|
||||||
|
self.group_repo.update(patch, commit=False)
|
||||||
|
is_default = body.get("is_default", False)
|
||||||
|
if is_default:
|
||||||
|
self.sys_repo.set_value_by_key(key=KEY_DEFAULT_RESOURCE_GROUP, value=gid, description="Default resource group", commit=False)
|
||||||
|
self.db.commit()
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
self.db.rollback()
|
||||||
|
raise
|
||||||
|
|
||||||
|
def delete_group(self, gid: str, migrate_id: Optional[str] = None) -> bool:
|
||||||
|
try:
|
||||||
|
if migrate_id:
|
||||||
|
migrate_group = self.group_repo.get_by_id(migrate_id)
|
||||||
|
if not migrate_group:
|
||||||
|
raise ValueError("Migrate resource group not found")
|
||||||
|
self.map_repo.migrate_services(gid, migrate_id, commit=False)
|
||||||
|
current_default = self.sys_repo.get_value_by_key(KEY_DEFAULT_RESOURCE_GROUP)
|
||||||
|
if current_default == gid:
|
||||||
|
self.sys_repo.set_value_by_key(KEY_DEFAULT_RESOURCE_GROUP, migrate_id, "Default resource group", commit=False)
|
||||||
|
else:
|
||||||
|
self.map_repo.delete_by_group_id(gid, commit=False)
|
||||||
|
current_default = self.sys_repo.get_value_by_key(KEY_DEFAULT_RESOURCE_GROUP)
|
||||||
|
if current_default == gid:
|
||||||
|
self.sys_repo.set_value_by_key(KEY_DEFAULT_RESOURCE_GROUP, "", "Default resource group", commit=False)
|
||||||
|
deleted = self.group_repo.delete(gid, commit=False)
|
||||||
|
if deleted is None:
|
||||||
|
raise ValueError("Resource group not found")
|
||||||
|
users = self.user_repo.update_resource_group_by_group_id(gid, migrate_id or "deny-all", commit=False)
|
||||||
|
if not users:
|
||||||
|
raise ValueError("Failed to update user resource group")
|
||||||
|
for user in users:
|
||||||
|
cache_key = f"xpack:user:{user.id}"
|
||||||
|
self.redis.set(cache_key, user, 600)
|
||||||
|
cache_key = f"xpack:resource_group:id:{gid}"
|
||||||
|
self.redis.delete(cache_key)
|
||||||
|
self.db.commit()
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
self.db.rollback()
|
||||||
|
raise
|
||||||
|
|
||||||
|
def get_info(self, gid: str) -> Optional[dict]:
|
||||||
|
default_group = self.sys_repo.get_value_by_key(KEY_DEFAULT_RESOURCE_GROUP)
|
||||||
|
if gid == "allow-all":
|
||||||
|
return {
|
||||||
|
"id":"allow-all",
|
||||||
|
"name":"Allow All",
|
||||||
|
"description":"Allow all services",
|
||||||
|
"enabled": 1,
|
||||||
|
"is_default": default_group == "allow-all" or default_group == "",
|
||||||
|
}
|
||||||
|
elif gid == "deny-all":
|
||||||
|
return {
|
||||||
|
"id":"deny-all",
|
||||||
|
"name":"Deny All",
|
||||||
|
"description":"Deny all services",
|
||||||
|
"enabled": 1,
|
||||||
|
"is_default": default_group == "deny-all",
|
||||||
|
}
|
||||||
|
g = self.group_repo.get_by_id(gid)
|
||||||
|
if not g:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return {
|
||||||
|
"id": g.id,
|
||||||
|
"name": g.name,
|
||||||
|
"description": g.description,
|
||||||
|
"enabled": g.enabled,
|
||||||
|
"is_default": g.id == default_group,
|
||||||
|
}
|
||||||
|
|
||||||
|
def list_groups(self, page: int = 1, page_size: int = 10, keyword: Optional[str] = None) -> Tuple[List[dict], int]:
|
||||||
|
default_group = self.sys_repo.get_value_by_key(KEY_DEFAULT_RESOURCE_GROUP)
|
||||||
|
groups,total = self.group_repo.get_all_paginated(page=page, page_size=page_size, keyword=keyword)
|
||||||
|
if total == 0:
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id":"allow-all",
|
||||||
|
"name":"Allow All",
|
||||||
|
"description":"Allow all services",
|
||||||
|
"enabled": 1,
|
||||||
|
"is_default": "allow-all" == default_group or default_group == "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id":"deny-all",
|
||||||
|
"name":"Deny All",
|
||||||
|
"description":"Deny all services",
|
||||||
|
"enabled": 1,
|
||||||
|
"is_default": "deny-all" == default_group,
|
||||||
|
},
|
||||||
|
],2
|
||||||
|
data = []
|
||||||
|
# data拼接
|
||||||
|
data.extend(
|
||||||
|
{
|
||||||
|
"id": g.id,
|
||||||
|
"name": g.name,
|
||||||
|
"description": g.description,
|
||||||
|
"enabled": bool(g.enabled), # 统一类型
|
||||||
|
"created_at": str(g.created_at) if g.created_at else None,
|
||||||
|
"updated_at": str(g.updated_at) if g.updated_at else None,
|
||||||
|
"is_default": g.id == default_group,
|
||||||
|
}
|
||||||
|
for g in groups
|
||||||
|
)
|
||||||
|
# 默认项(统一为 dict)
|
||||||
|
allow_all = {
|
||||||
|
"id": "allow-all",
|
||||||
|
"name": "Allow All",
|
||||||
|
"description": "Allow all services",
|
||||||
|
"enabled": True, # 统一为 bool
|
||||||
|
"is_default": "allow-all" == default_group or default_group == "",
|
||||||
|
}
|
||||||
|
|
||||||
|
deny_all = {
|
||||||
|
"id": "deny-all",
|
||||||
|
"name": "Deny All",
|
||||||
|
"description": "Deny all services",
|
||||||
|
"enabled": True, # 统一为 bool
|
||||||
|
"is_default": "deny-all" == default_group,
|
||||||
|
}
|
||||||
|
if len(data) < page_size:
|
||||||
|
data.append(allow_all)
|
||||||
|
if len(data) < page_size:
|
||||||
|
data.append(deny_all)
|
||||||
|
|
||||||
|
return data,total+2
|
||||||
|
|
||||||
|
def simple_list_groups(self) -> List[ResourceGroup]:
|
||||||
|
data = self.group_repo.get_all()
|
||||||
|
data.append(ResourceGroup(id="allow-all", name="Allow All", description="Allow all services", enabled=True))
|
||||||
|
data.append(ResourceGroup(id="deny-all", name="Deny All", description="Deny all services", enabled=True))
|
||||||
|
return data
|
||||||
|
|
||||||
|
def bind_groups(self, service_id: str, group_ids: List[str]) -> int:
|
||||||
|
created = self.map_repo.bind_group(service_id, group_ids, commit=False)
|
||||||
|
for gid in group_ids:
|
||||||
|
cache_key = f"xpack:resource_group:id:{gid}"
|
||||||
|
self.redis.delete(cache_key)
|
||||||
|
self.db.commit()
|
||||||
|
return created
|
||||||
|
|
||||||
|
def unbind_groups(self, service_id: str, group_ids: List[str]) -> int:
|
||||||
|
count = self.map_repo.unbind_group(service_id, group_ids, commit=False)
|
||||||
|
for gid in group_ids:
|
||||||
|
cache_key = f"xpack:resource_group:id:{gid}"
|
||||||
|
self.redis.delete(cache_key)
|
||||||
|
self.db.commit()
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
def bind_services(self, gid: str, service_ids: List[str]) -> int:
|
||||||
|
valid_ids: List[str] = []
|
||||||
|
group = self.group_repo.get_by_id(gid)
|
||||||
|
if not group:
|
||||||
|
raise ValueError("Resource group not found")
|
||||||
|
for sid in service_ids:
|
||||||
|
if self.mcp_repo.get_by_id(sid):
|
||||||
|
valid_ids.append(sid)
|
||||||
|
try:
|
||||||
|
created = self.map_repo.bind_services(gid, valid_ids, commit=False)
|
||||||
|
cache_key = f"xpack:resource_group:id:{gid}"
|
||||||
|
self.redis.delete(cache_key)
|
||||||
|
self.db.commit()
|
||||||
|
return created
|
||||||
|
except Exception:
|
||||||
|
self.db.rollback()
|
||||||
|
raise
|
||||||
|
|
||||||
|
def unbind_service(self, gid: str, sids: List[str]) -> int:
|
||||||
|
try:
|
||||||
|
for sid in sids:
|
||||||
|
self.map_repo.unbind_service(gid, sid, commit=False)
|
||||||
|
cache_key = f"xpack:resource_group:id:{gid}"
|
||||||
|
self.redis.delete(cache_key)
|
||||||
|
self.db.commit()
|
||||||
|
return len(sids)
|
||||||
|
except Exception:
|
||||||
|
self.db.rollback()
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def get_bind_groups(self, sid: str, page: int = 1, page_size: int = 10, keyword: Optional[str] = None) -> Tuple[List[dict], int]:
|
||||||
|
groups = self.group_repo.get_all(keyword=keyword)
|
||||||
|
if not groups:
|
||||||
|
if keyword and keyword.lower() not in "allow-all".lower():
|
||||||
|
return [],0
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id":"allow-all",
|
||||||
|
"name":"Allow All",
|
||||||
|
"join_at": "2025-12-16 00:00:00"
|
||||||
|
}
|
||||||
|
],1
|
||||||
|
group_map = {g.id: g for g in groups}
|
||||||
|
group_ids = None
|
||||||
|
if keyword:
|
||||||
|
group_ids = [g.id for g in groups]
|
||||||
|
|
||||||
|
groups,total = self.map_repo.list_group_ids_paginated(sid, page=page, page_size=page_size, group_ids=group_ids)
|
||||||
|
result = []
|
||||||
|
for group in groups:
|
||||||
|
result.append({
|
||||||
|
"id": group["id"],
|
||||||
|
"name": group_map[group["id"]].name if group["id"] in group_map else "",
|
||||||
|
"join_at": str(group["join_at"]) if group["join_at"] else None,
|
||||||
|
})
|
||||||
|
if len(result) < page_size:
|
||||||
|
if keyword and keyword.lower() not in "allow-all".lower():
|
||||||
|
return result,total
|
||||||
|
result.append({
|
||||||
|
"id":"allow-all",
|
||||||
|
"name":"Allow All",
|
||||||
|
"join_at": "2025-12-16 00:00:00"
|
||||||
|
})
|
||||||
|
total += 1
|
||||||
|
|
||||||
|
return result,total
|
||||||
|
def get_bind_service_ids(self, gid: str) -> List[str]:
|
||||||
|
if gid == "deny-all":
|
||||||
|
return []
|
||||||
|
elif gid == "allow-all":
|
||||||
|
return [s.id for s in self.mcp_repo.get_all()]
|
||||||
|
return self.map_repo.list_service_ids(gid)
|
||||||
|
|
||||||
|
def get_bind_services(self, gid: str, page: int = 1, page_size: int = 10, keyword: Optional[str] = None) -> Tuple[List[dict], int]:
|
||||||
|
if gid == "deny-all":
|
||||||
|
return [],0
|
||||||
|
elif gid == "allow-all":
|
||||||
|
services,total = self.mcp_repo.get_all_paginated(page=page, page_size=page_size, keyword=keyword)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id": s.id,
|
||||||
|
"name": s.name,
|
||||||
|
"base_url":s.base_url,
|
||||||
|
"slug_name": s.slug_name,
|
||||||
|
"short_description": s.short_description,
|
||||||
|
"long_description": s.long_description,
|
||||||
|
"base_url": s.base_url,
|
||||||
|
"charge_type": s.charge_type.value if s.charge_type else None,
|
||||||
|
"price": str(float(s.price)) if s.price and s.charge_type == ChargeType.PER_CALL else "0.00",
|
||||||
|
"input_token_price": str(float(s.input_token_price)) if s.input_token_price and s.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"output_token_price": str(float(s.output_token_price)) if s.output_token_price and s.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"enabled": s.enabled,
|
||||||
|
"created_at": str(s.created_at) if s.created_at else None,
|
||||||
|
"updated_at": str(s.updated_at) if s.updated_at else None,
|
||||||
|
}
|
||||||
|
for s in services
|
||||||
|
],total
|
||||||
|
if keyword:
|
||||||
|
|
||||||
|
services = self.mcp_repo.get_all(keyword=keyword)
|
||||||
|
if not services:
|
||||||
|
return [],0
|
||||||
|
service_map = {s.id: s for s in services}
|
||||||
|
sids = [s.id for s in services]
|
||||||
|
sids,total = self.map_repo.list_service_ids_paginated(gid, page=page, page_size=page_size,service_ids=sids)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id": s.id,
|
||||||
|
"name": s.name,
|
||||||
|
"base_url":s.base_url,
|
||||||
|
"slug_name": s.slug_name,
|
||||||
|
"short_description": s.short_description,
|
||||||
|
"long_description": s.long_description,
|
||||||
|
"base_url": s.base_url,
|
||||||
|
"charge_type": s.charge_type.value if s.charge_type else None,
|
||||||
|
"price": str(float(s.price)) if s.price and s.charge_type == ChargeType.PER_CALL else "0.00",
|
||||||
|
"input_token_price": str(float(s.input_token_price)) if s.input_token_price and s.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"output_token_price": str(float(s.output_token_price)) if s.output_token_price and s.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"enabled": s.enabled,
|
||||||
|
"created_at": str(s.created_at) if s.created_at else None,
|
||||||
|
"updated_at": str(s.updated_at) if s.updated_at else None,
|
||||||
|
}
|
||||||
|
for s in (service_map[sid] for sid in sids)
|
||||||
|
],total
|
||||||
|
else:
|
||||||
|
sids,total = self.map_repo.list_service_ids_paginated(gid, page=page, page_size=page_size)
|
||||||
|
services = self.mcp_repo.get_by_ids(ids=sids)
|
||||||
|
service_map = {s.id: s for s in services}
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id": s.id,
|
||||||
|
"name": s.name,
|
||||||
|
"base_url":s.base_url,
|
||||||
|
"slug_name": s.slug_name,
|
||||||
|
"short_description": s.short_description,
|
||||||
|
"long_description": s.long_description,
|
||||||
|
"base_url": s.base_url,
|
||||||
|
"charge_type": s.charge_type.value if s.charge_type else None,
|
||||||
|
"price": str(float(s.price)) if s.price and s.charge_type == ChargeType.PER_CALL else "0.00",
|
||||||
|
"input_token_price": str(float(s.input_token_price)) if s.input_token_price and s.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"output_token_price": str(float(s.output_token_price)) if s.output_token_price and s.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"enabled": s.enabled,
|
||||||
|
"created_at": str(s.created_at) if s.created_at else None,
|
||||||
|
"updated_at": str(s.updated_at) if s.updated_at else None,
|
||||||
|
}
|
||||||
|
for s in (service_map[sid] for sid in sids)
|
||||||
|
],total
|
||||||
|
def get_unbind_services(self, gid: str) -> List[dict]:
|
||||||
|
if gid == "deny-all" or gid == "allow-all":
|
||||||
|
return []
|
||||||
|
sids = self.map_repo.list_service_ids(gid)
|
||||||
|
services = self.mcp_repo.get_all_not_include(ids=sids)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id": s.id,
|
||||||
|
"name": s.name,
|
||||||
|
"base_url":s.base_url,
|
||||||
|
"charge_type": s.charge_type.value if s.charge_type else None,
|
||||||
|
"price": str(float(s.price)) if s.price and s.charge_type == ChargeType.PER_CALL else "0.00",
|
||||||
|
"input_token_price": str(float(s.input_token_price)) if s.input_token_price and s.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"output_token_price": str(float(s.output_token_price)) if s.output_token_price and s.charge_type == ChargeType.PER_TOKEN else "0.00",
|
||||||
|
"enabled": s.enabled,
|
||||||
|
}
|
||||||
|
for s in services
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_unbind_groups(self, sid: str) -> List[dict]:
|
||||||
|
"""Get all groups not bind to service"""
|
||||||
|
gids = self.map_repo.list_group_ids(sid)
|
||||||
|
groups = self.group_repo.get_all_not_include(ids=gids)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id": g.id,
|
||||||
|
"name": g.name,
|
||||||
|
}
|
||||||
|
for g in groups
|
||||||
|
]
|
||||||
|
|
||||||
@@ -5,6 +5,8 @@ from services.common.models.user_apikey import UserApiKey
|
|||||||
from services.common.database import SessionLocal
|
from services.common.database import SessionLocal
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from services.admin_service.repositories.user_apikey_repository import UserApiKeyRepository
|
from services.admin_service.repositories.user_apikey_repository import UserApiKeyRepository
|
||||||
|
from services.common.utils.cache_utils import CacheUtils
|
||||||
|
from services.common.redis_keys import RedisKeys
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -31,6 +33,10 @@ class UserApiKeyService:
|
|||||||
if not user_apikey or user_apikey.user_id != user_id:
|
if not user_apikey or user_apikey.user_id != user_id:
|
||||||
return None
|
return None
|
||||||
self.user_apikey_repository.delete(id)
|
self.user_apikey_repository.delete(id)
|
||||||
|
try:
|
||||||
|
CacheUtils.delete_cache(RedisKeys.user_apikey_key(user_apikey.apikey))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return user_apikey
|
return user_apikey
|
||||||
|
|
||||||
def get_by_user_id(self, user_id: str) -> List[UserApiKey]:
|
def get_by_user_id(self, user_id: str) -> List[UserApiKey]:
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ from services.common.database import SessionLocal
|
|||||||
|
|
||||||
from services.admin_service.repositories.user_repository import UserRepository
|
from services.admin_service.repositories.user_repository import UserRepository
|
||||||
from services.admin_service.repositories.user_wallet_repository import UserWalletRepository
|
from services.admin_service.repositories.user_wallet_repository import UserWalletRepository
|
||||||
|
from services.common.redis_keys import RedisKeys
|
||||||
|
from services.common.utils.cache import get_model_cache, set_model_cache, delete_cache
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class UserService:
|
class UserService:
|
||||||
@@ -43,3 +48,15 @@ class UserService:
|
|||||||
def update_admin(self, name: str, password: str) -> Optional[User]:
|
def update_admin(self, name: str, password: str) -> Optional[User]:
|
||||||
"""Update admin user info"""
|
"""Update admin user info"""
|
||||||
return self.user_repository.update_admin_user(name=name, password=password)
|
return self.user_repository.update_admin_user(name=name, password=password)
|
||||||
|
|
||||||
|
def update_resource_group(self, user_id: str, group_id: str) -> Optional[User]:
|
||||||
|
"""Update user resource group"""
|
||||||
|
try:
|
||||||
|
user = self.user_repository.update_resource_group(user_id=user_id, group_id=group_id)
|
||||||
|
cache_key = RedisKeys.user_key(user_id)
|
||||||
|
set_model_cache(cache_key, user)
|
||||||
|
return self.get_by_id(user_id)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to update user resource group for user_id {user_id}: {e}", exc_info=True)
|
||||||
|
return None
|
||||||
|
|
||||||
@@ -61,6 +61,7 @@ class UserStatsService:
|
|||||||
UserApiKey.id == apikey_id,
|
UserApiKey.id == apikey_id,
|
||||||
func.date(McpCallLog.call_start_time) >= start_date,
|
func.date(McpCallLog.call_start_time) >= start_date,
|
||||||
func.date(McpCallLog.call_start_time) <= end_date,
|
func.date(McpCallLog.call_start_time) <= end_date,
|
||||||
|
McpCallLog.call_success == True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.group_by(func.date(McpCallLog.call_start_time))
|
.group_by(func.date(McpCallLog.call_start_time))
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Supports both service_id (UUID) and slug_name service identifiers
|
|||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
from sqlalchemy import false
|
||||||
from starlette.requests import Request
|
from starlette.requests import Request
|
||||||
from starlette.responses import Response
|
from starlette.responses import Response
|
||||||
import asyncio
|
import asyncio
|
||||||
@@ -17,6 +18,9 @@ from mcp.server.lowlevel import Server
|
|||||||
from services.api_service.services.mcp_server_factory import McpServerFactory
|
from services.api_service.services.mcp_server_factory import McpServerFactory
|
||||||
from services.common.logging_config import get_logger
|
from services.common.logging_config import get_logger
|
||||||
from services.api_service.repositories.user_apikey_repository import UserApiKeyRepository
|
from services.api_service.repositories.user_apikey_repository import UserApiKeyRepository
|
||||||
|
from services.api_service.repositories.user_repository import UserRepository
|
||||||
|
from services.api_service.repositories.resource_group_repository import ResourceGroupMapRepository
|
||||||
|
|
||||||
from services.api_service.utils.connection_manager import connection_manager
|
from services.api_service.utils.connection_manager import connection_manager
|
||||||
from services.common.database import get_db
|
from services.common.database import get_db
|
||||||
from services.common.config import Config
|
from services.common.config import Config
|
||||||
@@ -178,6 +182,20 @@ class McpController:
|
|||||||
|
|
||||||
user_id, apikey_id = user_info
|
user_id, apikey_id = user_info
|
||||||
|
|
||||||
|
# Check invoke permission
|
||||||
|
if not self._check_invoke_permission(user_id, service_id):
|
||||||
|
response_body = b"Invoke permission denied"
|
||||||
|
await send({
|
||||||
|
'type': 'http.response.start',
|
||||||
|
'status': 403,
|
||||||
|
'headers': [
|
||||||
|
[b'content-type', b'text/plain'],
|
||||||
|
[b'content-length', str(len(response_body)).encode()],
|
||||||
|
],
|
||||||
|
})
|
||||||
|
await send({'type': 'http.response.body', 'body': response_body})
|
||||||
|
return
|
||||||
|
|
||||||
# Create MCP server instance (pass user_id and apikey_id for billing and logging)
|
# Create MCP server instance (pass user_id and apikey_id for billing and logging)
|
||||||
mcp_server = await self.server_factory.create_server(service_id, user_id, apikey_id)
|
mcp_server = await self.server_factory.create_server(service_id, user_id, apikey_id)
|
||||||
|
|
||||||
@@ -347,8 +365,19 @@ class McpController:
|
|||||||
})
|
})
|
||||||
await send({'type': 'http.response.body', 'body': response_body})
|
await send({'type': 'http.response.body', 'body': response_body})
|
||||||
return
|
return
|
||||||
|
|
||||||
user_id, apikey_id = user_info
|
user_id, apikey_id = user_info
|
||||||
|
if not self._check_invoke_permission(user_id, service_id):
|
||||||
|
response_body = b"Invoke permission denied"
|
||||||
|
await send({
|
||||||
|
'type': 'http.response.start',
|
||||||
|
'status': 403,
|
||||||
|
'headers': [
|
||||||
|
[b'content-type', b'text/plain'],
|
||||||
|
[b'content-length', str(len(response_body)).encode()],
|
||||||
|
],
|
||||||
|
})
|
||||||
|
await send({'type': 'http.response.body', 'body': response_body})
|
||||||
|
return
|
||||||
raw_client_id = req.headers.get('x-client-instance-id') or req.headers.get('x-client-id')
|
raw_client_id = req.headers.get('x-client-instance-id') or req.headers.get('x-client-id')
|
||||||
client_instance_id = (re.sub(r'[^a-zA-Z0-9._-]', '', raw_client_id)[:32]) if raw_client_id else None
|
client_instance_id = (re.sub(r'[^a-zA-Z0-9._-]', '', raw_client_id)[:32]) if raw_client_id else None
|
||||||
ua = user_agent or ""
|
ua = user_agent or ""
|
||||||
@@ -611,6 +640,43 @@ class McpController:
|
|||||||
finally:
|
finally:
|
||||||
if db is not None:
|
if db is not None:
|
||||||
db.close()
|
db.close()
|
||||||
|
def _check_invoke_permission(self, user_id: str, service_id: str) -> bool:
|
||||||
|
db = None
|
||||||
|
try:
|
||||||
|
# Create database session
|
||||||
|
db = next(get_db())
|
||||||
|
user_repo = UserRepository(db)
|
||||||
|
# Query user info by apikey
|
||||||
|
user = user_repo.get_by_id(user_id)
|
||||||
|
if not user:
|
||||||
|
logger.warning(f"User not found in database: {user_id[:10]}...")
|
||||||
|
return False
|
||||||
|
logger.debug(f"Found user record - User ID: {user.id}, group id is: {user.group_id}")
|
||||||
|
if user.group_id == "allow-all":
|
||||||
|
return True
|
||||||
|
elif user.group_id == "deny-all":
|
||||||
|
return False
|
||||||
|
|
||||||
|
resource_group_map_repo = ResourceGroupMapRepository(db)
|
||||||
|
resource_groups = resource_group_map_repo.get_by_id(user.group_id)
|
||||||
|
if not resource_groups:
|
||||||
|
logger.warning(f"Resource group not found for user: {user_id[:10]}...")
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Check if service_id is in resource_groups
|
||||||
|
if service_id not in resource_groups:
|
||||||
|
logger.warning(f"Service {service_id} not found in user's resource groups: {user_id[:10]}...")
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error occurred while querying user apikey: {str(e)}", exc_info=True)
|
||||||
|
return False
|
||||||
|
finally:
|
||||||
|
if db is not None:
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
def _extract_user_info(self, request: Request) -> Optional[tuple[str, str]]:
|
def _extract_user_info(self, request: Request) -> Optional[tuple[str, str]]:
|
||||||
"""Extract user ID and apikey ID from request by validating apikey parameter."""
|
"""Extract user ID and apikey ID from request by validating apikey parameter."""
|
||||||
@@ -650,6 +716,7 @@ class McpController:
|
|||||||
logger.warning(f"Apikey has expired: {apikey[:10]}..., expiry time: {user_apikey.expire_at}")
|
logger.warning(f"Apikey has expired: {apikey[:10]}..., expiry time: {user_apikey.expire_at}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
logger.info(f"Apikey validation successful - User ID: {user_apikey.user_id}, API Key ID: {user_apikey.id}")
|
logger.info(f"Apikey validation successful - User ID: {user_apikey.user_id}, API Key ID: {user_apikey.id}")
|
||||||
return (user_apikey.user_id, user_apikey.id)
|
return (user_apikey.user_id, user_apikey.id)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
"""
|
||||||
|
Resource group service map repository class - used in API service
|
||||||
|
"""
|
||||||
|
from typing import List
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from services.common.models.resource_group import ResourceGroupServiceMap
|
||||||
|
from services.common.utils.cache_utils import CacheUtils
|
||||||
|
|
||||||
|
|
||||||
|
class ResourceGroupMapRepository:
|
||||||
|
"""Resource group service map repository class"""
|
||||||
|
|
||||||
|
def __init__(self, db: Session):
|
||||||
|
self.db = db
|
||||||
|
|
||||||
|
def get_by_id(self, group_id: str, force_update: bool = False) -> List[str]:
|
||||||
|
"""
|
||||||
|
Get resource group service map by ID
|
||||||
|
|
||||||
|
Args:
|
||||||
|
group_id: Resource group ID
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List[str]: Resource group service map instance, returns None if not exists
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
Get resource group service map by ID
|
||||||
|
"""
|
||||||
|
cache_key = f"xpack:resource_group:id:{group_id}"
|
||||||
|
if not force_update:
|
||||||
|
# Try to get from cache using SQLAlchemy-specific method
|
||||||
|
cached_model = CacheUtils.get_sqlalchemy_cache(cache_key, List[str])
|
||||||
|
if cached_model:
|
||||||
|
return cached_model
|
||||||
|
|
||||||
|
# Query from database if not in cache
|
||||||
|
service_ids = [item.service_id for item in self.db.query(ResourceGroupServiceMap).filter(ResourceGroupServiceMap.group_id == group_id).all()]
|
||||||
|
if service_ids:
|
||||||
|
# Cache the result for 10 minutes
|
||||||
|
CacheUtils.set_sqlalchemy_cache(cache_key, service_ids, 600)
|
||||||
|
return service_ids
|
||||||
|
|
||||||
|
return []
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
"""
|
||||||
|
User repository class - used in API service
|
||||||
|
"""
|
||||||
|
from typing import Optional
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from services.common.models.user import User
|
||||||
|
from services.common.utils.cache_utils import CacheUtils
|
||||||
|
from services.common.redis_keys import RedisKeys
|
||||||
|
|
||||||
|
|
||||||
|
class UserRepository:
|
||||||
|
"""User repository class"""
|
||||||
|
|
||||||
|
def __init__(self, db: Session):
|
||||||
|
self.db = db
|
||||||
|
|
||||||
|
def get_by_id(self, user_id: str, force_update: bool = False) -> Optional[User]:
|
||||||
|
"""
|
||||||
|
Get user by ID
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id: User ID
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
User: User instance, returns None if not exists
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
Get user by ID
|
||||||
|
"""
|
||||||
|
cache_key = RedisKeys.user_key(user_id)
|
||||||
|
if not force_update:
|
||||||
|
# Try to get from cache using SQLAlchemy-specific method
|
||||||
|
cached_model = CacheUtils.get_sqlalchemy_cache(cache_key, User)
|
||||||
|
if cached_model:
|
||||||
|
return cached_model
|
||||||
|
|
||||||
|
# Query from database if not in cache
|
||||||
|
user = self.db.query(User).filter(User.id == user_id).first()
|
||||||
|
if user:
|
||||||
|
# Cache the result for 10 minutes
|
||||||
|
CacheUtils.set_sqlalchemy_cache(cache_key, user, 600)
|
||||||
|
return user
|
||||||
|
|
||||||
|
return None
|
||||||
@@ -206,12 +206,19 @@ class McpServerFactory:
|
|||||||
logger.debug(f"Call params: {call_params}")
|
logger.debug(f"Call params: {call_params}")
|
||||||
|
|
||||||
# Execute tool
|
# Execute tool
|
||||||
result,response_data = await self.tool_service.execute_tool(tool_config, arguments, call_params)
|
result,response_data,call_success = await self.tool_service.execute_tool(tool_config, arguments, call_params)
|
||||||
call_success = True
|
if call_success:
|
||||||
logger.info(f"Tool call successful - User ID: {user_id}, Tool: {name}")
|
validation_ok, validation_msg = self._validate_output_schema(tool_config, response_data)
|
||||||
|
|
||||||
# Calculate output token amount after tool execution
|
if not validation_ok:
|
||||||
if pre_deduct_result.charge_type == "per_token" and result:
|
call_success = False
|
||||||
|
error_text = f"Response validation failed: {validation_msg}"
|
||||||
|
result = [types.TextContent(type="text", text=error_text)]
|
||||||
|
response_data = {}
|
||||||
|
if call_success:
|
||||||
|
logger.info(f"Tool call successful - User ID: {user_id}, Tool: {name}")
|
||||||
|
|
||||||
|
if pre_deduct_result.charge_type == "per_token" and result and call_success:
|
||||||
output_text = ""
|
output_text = ""
|
||||||
for content in result:
|
for content in result:
|
||||||
if isinstance(content, types.TextContent):
|
if isinstance(content, types.TextContent):
|
||||||
@@ -257,6 +264,57 @@ class McpServerFactory:
|
|||||||
# Ensure return type is correct
|
# Ensure return type is correct
|
||||||
return result,response_data
|
return result,response_data
|
||||||
|
|
||||||
|
def _validate_output_schema(self, tool_config, response_data: dict) -> tuple[bool, str]:
|
||||||
|
try:
|
||||||
|
schema_str = getattr(tool_config, "response_schema", None)
|
||||||
|
if not schema_str:
|
||||||
|
return True, ""
|
||||||
|
try:
|
||||||
|
schema = json.loads(schema_str)
|
||||||
|
except Exception:
|
||||||
|
return False, "Invalid response_schema JSON"
|
||||||
|
|
||||||
|
def check(schema_obj, data_obj) -> tuple[bool, str]:
|
||||||
|
t = schema_obj.get("type")
|
||||||
|
if t == "object":
|
||||||
|
if not isinstance(data_obj, dict):
|
||||||
|
return False, "Expected object"
|
||||||
|
req = schema_obj.get("required", [])
|
||||||
|
for k in req:
|
||||||
|
if k not in data_obj:
|
||||||
|
return False, f"Missing required field: {k}"
|
||||||
|
props = schema_obj.get("properties", {})
|
||||||
|
for k, sub in props.items():
|
||||||
|
if k in data_obj:
|
||||||
|
ok, msg = check(sub, data_obj[k])
|
||||||
|
if not ok:
|
||||||
|
return False, f"Field {k}: {msg}"
|
||||||
|
return True, ""
|
||||||
|
if t == "array":
|
||||||
|
if not isinstance(data_obj, list):
|
||||||
|
return False, "Expected array"
|
||||||
|
items = schema_obj.get("items")
|
||||||
|
if items:
|
||||||
|
for i, it in enumerate(data_obj):
|
||||||
|
ok, msg = check(items, it)
|
||||||
|
if not ok:
|
||||||
|
return False, f"Item {i}: {msg}"
|
||||||
|
return True, ""
|
||||||
|
if t == "string":
|
||||||
|
return (isinstance(data_obj, str), "Expected string")
|
||||||
|
if t == "integer":
|
||||||
|
return (isinstance(data_obj, int), "Expected integer")
|
||||||
|
if t == "number":
|
||||||
|
return ((isinstance(data_obj, (int, float))), "Expected number")
|
||||||
|
if t == "boolean":
|
||||||
|
return (isinstance(data_obj, bool), "Expected boolean")
|
||||||
|
return True, ""
|
||||||
|
|
||||||
|
ok, msg = check(schema, response_data)
|
||||||
|
return ok, msg
|
||||||
|
except Exception as e:
|
||||||
|
return False, str(e)
|
||||||
|
|
||||||
def _create_mcp_service(self, db) -> McpService:
|
def _create_mcp_service(self, db) -> McpService:
|
||||||
"""
|
"""
|
||||||
Create MCP service instance
|
Create MCP service instance
|
||||||
|
|||||||
@@ -185,14 +185,20 @@ class McpService:
|
|||||||
for param in query_params:
|
for param in query_params:
|
||||||
if isinstance(param, dict) and "name" in param:
|
if isinstance(param, dict) and "name" in param:
|
||||||
# Handle both direct type and schema.type formats
|
# Handle both direct type and schema.type formats
|
||||||
|
extend_properties = {}
|
||||||
param_type = "string" # default
|
param_type = "string" # default
|
||||||
if "type" in param:
|
if "type" in param:
|
||||||
param_type = param["type"]
|
param_type = param["type"]
|
||||||
elif "schema" in param and isinstance(param["schema"], dict) and "type" in param["schema"]:
|
elif "schema" in param and isinstance(param["schema"], dict) and "type" in param["schema"]:
|
||||||
param_type = param["schema"]["type"]
|
param_type = param["schema"]["type"]
|
||||||
|
if param_type == "array":
|
||||||
|
extend_properties["items"] = param["schema"]["items"]
|
||||||
|
elif param_type == "object":
|
||||||
|
extend_properties["properties"] = param["schema"]["properties"]
|
||||||
|
|
||||||
schema["properties"][param["name"]] = {
|
schema["properties"][param["name"]] = {
|
||||||
"type": param_type,
|
"type": param_type,
|
||||||
|
**extend_properties,
|
||||||
"description": param.get("description", f"Query parameter: {param['name']}")
|
"description": param.get("description", f"Query parameter: {param['name']}")
|
||||||
}
|
}
|
||||||
if param.get("required", False):
|
if param.get("required", False):
|
||||||
@@ -202,34 +208,34 @@ class McpService:
|
|||||||
if tool_api.request_body_schema:
|
if tool_api.request_body_schema:
|
||||||
# Try to parse as parameters list first, then as schema object
|
# Try to parse as parameters list first, then as schema object
|
||||||
try:
|
try:
|
||||||
# First try to parse as parameters list (similar to query/path parameters)
|
# # First try to parse as parameters list (similar to query/path parameters)
|
||||||
body_params = self._safe_parse_params(tool_api.request_body_schema, tool_api.name, 'body')
|
# body_params = self._safe_parse_params(tool_api.request_body_schema, tool_api.name, 'body')
|
||||||
if body_params:
|
# if body_params:
|
||||||
# If it's a list of parameters, process them like query parameters
|
# # If it's a list of parameters, process them like query parameters
|
||||||
for param in body_params:
|
# for param in body_params:
|
||||||
if isinstance(param, dict) and "name" in param:
|
# if isinstance(param, dict) and "name" in param:
|
||||||
param_type = "string" # default
|
# param_type = "string" # default
|
||||||
if "type" in param:
|
# if "type" in param:
|
||||||
param_type = param["type"]
|
# param_type = param["type"]
|
||||||
elif "schema" in param and isinstance(param["schema"], dict) and "type" in param["schema"]:
|
# elif "schema" in param and isinstance(param["schema"], dict) and "type" in param["schema"]:
|
||||||
param_type = param["schema"]["type"]
|
# param_type = param["schema"]["type"]
|
||||||
|
|
||||||
schema["properties"][param["name"]] = {
|
# schema["properties"][param["name"]] = {
|
||||||
"type": param_type,
|
# "type": param_type,
|
||||||
"description": param.get("description", f"Body parameter: {param['name']}")
|
# "description": param.get("description", f"Body parameter: {param['name']}")
|
||||||
}
|
# }
|
||||||
if param.get("required", False):
|
# if param.get("required", False):
|
||||||
schema["required"].append(param["name"])
|
# schema["required"].append(param["name"])
|
||||||
else:
|
# else:
|
||||||
# If not a parameters list, try to parse as JSON schema object
|
# If not a parameters list, try to parse as JSON schema object
|
||||||
try:
|
try:
|
||||||
body_schema = json.loads(tool_api.request_body_schema)
|
body_schema = json.loads(tool_api.request_body_schema)
|
||||||
if isinstance(body_schema, dict) and "properties" in body_schema:
|
if isinstance(body_schema, dict) and "properties" in body_schema:
|
||||||
schema["properties"].update(body_schema["properties"])
|
schema["properties"].update(body_schema["properties"])
|
||||||
if "required" in body_schema:
|
if "required" in body_schema:
|
||||||
schema["required"].extend(body_schema["required"])
|
schema["required"].extend(body_schema["required"])
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
pass # Already logged by _safe_parse_params
|
pass # Already logged by _safe_parse_params
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning(f"Failed to parse request body schema for {tool_api.name}: {e}")
|
self.logger.warning(f"Failed to parse request body schema for {tool_api.name}: {e}")
|
||||||
|
|
||||||
@@ -291,7 +297,15 @@ class McpService:
|
|||||||
if tool_api.response_schema:
|
if tool_api.response_schema:
|
||||||
parsed = json.loads(tool_api.response_schema)
|
parsed = json.loads(tool_api.response_schema)
|
||||||
if isinstance(parsed, dict):
|
if isinstance(parsed, dict):
|
||||||
return parsed
|
if parsed["type"] != "object":
|
||||||
|
return {
|
||||||
|
"type":"object",
|
||||||
|
"properties":{
|
||||||
|
"data":parsed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return parsed
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning(f"Failed to parse response_schema for {tool_api.name}: {e}")
|
self.logger.warning(f"Failed to parse response_schema for {tool_api.name}: {e}")
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class McpToolService:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.http_builder = HttpRequestBuilder()
|
self.http_builder = HttpRequestBuilder()
|
||||||
|
|
||||||
async def execute_tool(self, tool_config, arguments: dict, call_params: dict) -> tuple[List[types.Content],dict]:
|
async def execute_tool(self, tool_config, arguments: dict, call_params: dict) -> tuple[List[types.Content],dict,bool]:
|
||||||
"""
|
"""
|
||||||
Execute tool call
|
Execute tool call
|
||||||
|
|
||||||
@@ -42,12 +42,12 @@ class McpToolService:
|
|||||||
else:
|
else:
|
||||||
response_data = {}
|
response_data = {}
|
||||||
logger.info("Tool execution completed successfully")
|
logger.info("Tool execution completed successfully")
|
||||||
return [types.TextContent(type="text", text=response_text)],response_data
|
return [types.TextContent(type="text", text=response_text)],response_data,True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = f"Tool execution failed: {str(e)}"
|
error_msg = f"Tool execution failed: {str(e)}"
|
||||||
logger.error(f"Tool execution failed: {error_msg}", exc_info=True)
|
logger.error(f"Tool execution failed: {error_msg}", exc_info=True)
|
||||||
return [types.TextContent(type="text", text=error_msg)],{}
|
return [types.TextContent(type="text", text=error_msg)],{},False
|
||||||
|
|
||||||
async def _send_http_request(self, request_info: Dict[str, Any]) -> str:
|
async def _send_http_request(self, request_info: Dict[str, Any]) -> str:
|
||||||
"""
|
"""
|
||||||
@@ -67,7 +67,7 @@ class McpToolService:
|
|||||||
|
|
||||||
logger.info(f"Sending HTTP request: {method} {url}")
|
logger.info(f"Sending HTTP request: {method} {url}")
|
||||||
logger.debug(f"Query parameters: {query_params}")
|
logger.debug(f"Query parameters: {query_params}")
|
||||||
logger.debug(f"Request body: {request_body}")
|
# logger.debug(f"Request body: {request_body}")
|
||||||
|
|
||||||
async with create_mcp_http_client(headers=headers) as client:
|
async with create_mcp_http_client(headers=headers) as client:
|
||||||
if method == "GET":
|
if method == "GET":
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class HttpRequestBuilder:
|
|||||||
request_body[param_name] = arguments[param_name]
|
request_body[param_name] = arguments[param_name]
|
||||||
|
|
||||||
if request_body:
|
if request_body:
|
||||||
logger.debug(f"Built request body from parameters: {request_body}")
|
# logger.debug(f"Built request body from parameters: {request_body}")
|
||||||
return request_body
|
return request_body
|
||||||
else:
|
else:
|
||||||
# If not a parameters list, try to parse as JSON schema object
|
# If not a parameters list, try to parse as JSON schema object
|
||||||
@@ -322,7 +322,7 @@ class HttpRequestBuilder:
|
|||||||
request_body[prop_name] = arguments[prop_name]
|
request_body[prop_name] = arguments[prop_name]
|
||||||
|
|
||||||
if request_body:
|
if request_body:
|
||||||
logger.debug(f"Built request body from schema: {request_body}")
|
# logger.debug(f"Built request body from schema: {request_body}")
|
||||||
return request_body
|
return request_body
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
logger.warning(f"Failed to parse request body schema as JSON")
|
logger.warning(f"Failed to parse request body schema as JSON")
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ def init_db():
|
|||||||
"""Initialize database and create all tables"""
|
"""Initialize database and create all tables"""
|
||||||
try:
|
try:
|
||||||
# Import all models to ensure they are registered
|
# Import all models to ensure they are registered
|
||||||
from .models import user, user_wallet, user_wallet_history, user_access_token, sys_config, mcp_service, mcp_tool_api, user_apikey
|
from .models import user, user_wallet, user_wallet_history, user_access_token, sys_config, mcp_service, mcp_tool_api, user_apikey, resource_group
|
||||||
|
|
||||||
# Create all tables
|
# Create all tables
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
|
|||||||
@@ -4,8 +4,13 @@
|
|||||||
# 4xx Client Errors
|
# 4xx Client Errors
|
||||||
INVALID_REQUEST = {"code": 400, "message": "Invalid request parameters"}
|
INVALID_REQUEST = {"code": 400, "message": "Invalid request parameters"}
|
||||||
MISSING_PARAMETER = {"code": 400, "message": "Required parameter is missing"}
|
MISSING_PARAMETER = {"code": 400, "message": "Required parameter is missing"}
|
||||||
|
INVALID_PRICE = {"code": 400, "message": "Price must be a non-negative number"}
|
||||||
|
INVALID_INPUT_TOKEN = {"code": 400, "message": "Input token must be a non-negative number"}
|
||||||
|
INVALID_OUTPUT_TOKEN = {"code": 400, "message": "Output token must be a non-negative number"}
|
||||||
INVALID_URL = {"code": 400, "message": "Invalid URL provided"}
|
INVALID_URL = {"code": 400, "message": "Invalid URL provided"}
|
||||||
INVALID_FORMAT = {"code": 400, "message": "Invalid data format"}
|
INVALID_FORMAT = {"code": 400, "message": "Invalid data format"}
|
||||||
|
USER_NOT_FOUND = {"code": 400, "message": "User not found"}
|
||||||
|
RESOURCE_NOT_FOUND = {"code": 400, "message": "Resource Group not found"}
|
||||||
|
|
||||||
UNAUTHORIZED = {"code": 401, "message": "Authentication required"}
|
UNAUTHORIZED = {"code": 401, "message": "Authentication required"}
|
||||||
INVALID_TOKEN = {"code": 401, "message": "Invalid or expired token"}
|
INVALID_TOKEN = {"code": 401, "message": "Invalid or expired token"}
|
||||||
|
|||||||
@@ -1,4 +1,17 @@
|
|||||||
from sqlalchemy.orm import DeclarativeBase
|
from sqlalchemy.orm import DeclarativeBase
|
||||||
|
from enum import Enum as PyEnum
|
||||||
|
|
||||||
class Base(DeclarativeBase):
|
class Base(DeclarativeBase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AuthMethod(PyEnum):
|
||||||
|
FREE = "free"
|
||||||
|
APIKEY = "apikey"
|
||||||
|
TOKEN = "token"
|
||||||
|
|
||||||
|
|
||||||
|
class ChargeType(PyEnum):
|
||||||
|
FREE = "free"
|
||||||
|
PER_CALL = "per_call"
|
||||||
|
PER_TOKEN = "per_token"
|
||||||
@@ -1,21 +1,8 @@
|
|||||||
from sqlalchemy import String, Enum, Numeric, Integer, DateTime
|
from sqlalchemy import String, Enum, Numeric, Integer, DateTime
|
||||||
from sqlalchemy.sql import func
|
from sqlalchemy.sql import func
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
from enum import Enum as PyEnum
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from services.common.models.base import Base
|
from services.common.models.base import Base,ChargeType
|
||||||
|
|
||||||
|
|
||||||
class AuthMethod(PyEnum):
|
|
||||||
FREE = "free"
|
|
||||||
APIKEY = "apikey"
|
|
||||||
TOKEN = "token"
|
|
||||||
|
|
||||||
|
|
||||||
class ChargeType(PyEnum):
|
|
||||||
FREE = "free"
|
|
||||||
PER_CALL = "per_call"
|
|
||||||
PER_TOKEN = "per_token"
|
|
||||||
|
|
||||||
|
|
||||||
class McpService(Base):
|
class McpService(Base):
|
||||||
@@ -31,14 +18,7 @@ class McpService(Base):
|
|||||||
slug_name: Mapped[str] = mapped_column(String(255), unique=True, nullable=False, comment="Unique slug name for the service")
|
slug_name: Mapped[str] = mapped_column(String(255), unique=True, nullable=False, comment="Unique slug name for the service")
|
||||||
short_description: Mapped[str] = mapped_column(String, nullable=False, comment="Short description of the service")
|
short_description: Mapped[str] = mapped_column(String, nullable=False, comment="Short description of the service")
|
||||||
long_description: Mapped[str] = mapped_column(String, nullable=True, comment="Detailed description of the service (Markdown format)")
|
long_description: Mapped[str] = mapped_column(String, nullable=True, comment="Detailed description of the service (Markdown format)")
|
||||||
# auth_method: Mapped[AuthMethod] = mapped_column(
|
|
||||||
# Enum(AuthMethod, values_callable=lambda obj: [e.value for e in obj]),
|
|
||||||
# nullable=False,
|
|
||||||
# comment="Authentication method: free, apikey, token",
|
|
||||||
# )
|
|
||||||
base_url: Mapped[str] = mapped_column(String(512), nullable=True, comment="api url")
|
base_url: Mapped[str] = mapped_column(String(512), nullable=True, comment="api url")
|
||||||
# auth_header: Mapped[str] = mapped_column(String(255), nullable=True, comment="Authentication header name")
|
|
||||||
# auth_token: Mapped[str] = mapped_column(String(255), nullable=True, comment="Authentication token value")
|
|
||||||
headers: Mapped[str] = mapped_column(String, nullable=True, comment="Additional headers for requests (JSON Array format)")
|
headers: Mapped[str] = mapped_column(String, nullable=True, comment="Additional headers for requests (JSON Array format)")
|
||||||
charge_type: Mapped[ChargeType] = mapped_column(
|
charge_type: Mapped[ChargeType] = mapped_column(
|
||||||
Enum(ChargeType, values_callable=lambda obj: [e.value for e in obj]),
|
Enum(ChargeType, values_callable=lambda obj: [e.value for e in obj]),
|
||||||
@@ -54,6 +34,7 @@ class McpService(Base):
|
|||||||
)
|
)
|
||||||
enabled: Mapped[int] = mapped_column(Integer, nullable=True, comment="Service status: 0=disabled, 1=enabled")
|
enabled: Mapped[int] = mapped_column(Integer, nullable=True, comment="Service status: 0=disabled, 1=enabled")
|
||||||
tags: Mapped[str] = mapped_column(String, nullable=True, comment="Tags")
|
tags: Mapped[str] = mapped_column(String, nullable=True, comment="Tags")
|
||||||
|
service_type: Mapped[str] = mapped_column(String(255), nullable=True, comment="Service type",default="openapi")
|
||||||
created_at: Mapped[datetime] = mapped_column(
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
DateTime,
|
DateTime,
|
||||||
nullable=True,
|
nullable=True,
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
from sqlalchemy import String, Integer, DateTime, UniqueConstraint
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
from datetime import datetime
|
||||||
|
from services.common.models.base import Base
|
||||||
|
|
||||||
|
|
||||||
|
class ResourceGroup(Base):
|
||||||
|
__tablename__ = "resource_group"
|
||||||
|
|
||||||
|
id: Mapped[str] = mapped_column(
|
||||||
|
String(36),
|
||||||
|
primary_key=True,
|
||||||
|
autoincrement=False,
|
||||||
|
comment="Primary key, group UUID",
|
||||||
|
)
|
||||||
|
name: Mapped[str] = mapped_column(String(255), nullable=False, comment="Group name")
|
||||||
|
description: Mapped[str] = mapped_column(String, nullable=True, comment="Group description")
|
||||||
|
enabled: Mapped[int] = mapped_column(Integer, nullable=False, default=1, comment="Group status: 0=disabled, 1=enabled")
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime,
|
||||||
|
nullable=True,
|
||||||
|
server_default=func.current_timestamp(),
|
||||||
|
comment="Creation timestamp",
|
||||||
|
)
|
||||||
|
updated_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime,
|
||||||
|
nullable=True,
|
||||||
|
server_default=func.current_timestamp(),
|
||||||
|
server_onupdate=func.current_timestamp(),
|
||||||
|
comment="Last update timestamp",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ResourceGroupServiceMap(Base):
|
||||||
|
__tablename__ = "resource_group_service_map"
|
||||||
|
|
||||||
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True, comment="Primary key")
|
||||||
|
group_id: Mapped[str] = mapped_column(String(36), nullable=False, comment="Resource group UUID")
|
||||||
|
service_id: Mapped[str] = mapped_column(String(36), nullable=False, comment="MCP service UUID")
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime,
|
||||||
|
nullable=True,
|
||||||
|
server_default=func.current_timestamp(),
|
||||||
|
comment="Creation timestamp",
|
||||||
|
)
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
UniqueConstraint("group_id", "service_id", name="uq_group_service"),
|
||||||
|
)
|
||||||
|
|
||||||
@@ -1,23 +1,10 @@
|
|||||||
from sqlalchemy import String, Enum, Numeric, Integer, DateTime
|
from sqlalchemy import String, Enum, Numeric, Integer, DateTime
|
||||||
from sqlalchemy.sql import func
|
from sqlalchemy.sql import func
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
from enum import Enum as PyEnum
|
from services.common.models.base import Base,ChargeType
|
||||||
from services.common.models.base import Base
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
class AuthMethod(PyEnum):
|
|
||||||
FREE = "free"
|
|
||||||
APIKEY = "apikey"
|
|
||||||
TOKEN = "token"
|
|
||||||
|
|
||||||
|
|
||||||
class ChargeType(PyEnum):
|
|
||||||
FREE = "free"
|
|
||||||
PER_CALL = "per_call"
|
|
||||||
PER_TOKEN = "per_token"
|
|
||||||
|
|
||||||
|
|
||||||
class TempMcpService(Base):
|
class TempMcpService(Base):
|
||||||
__tablename__ = "temp_mcp_service"
|
__tablename__ = "temp_mcp_service"
|
||||||
|
|
||||||
@@ -31,15 +18,8 @@ class TempMcpService(Base):
|
|||||||
slug_name: Mapped[str] = mapped_column(String(255), unique=True, nullable=False, comment="Unique slug name for the service")
|
slug_name: Mapped[str] = mapped_column(String(255), unique=True, nullable=False, comment="Unique slug name for the service")
|
||||||
short_description: Mapped[str] = mapped_column(String, nullable=False, comment="Short description of the service")
|
short_description: Mapped[str] = mapped_column(String, nullable=False, comment="Short description of the service")
|
||||||
long_description: Mapped[str] = mapped_column(String, nullable=True, comment="Detailed description of the service (Markdown format)")
|
long_description: Mapped[str] = mapped_column(String, nullable=True, comment="Detailed description of the service (Markdown format)")
|
||||||
# auth_method: Mapped[AuthMethod] = mapped_column(
|
|
||||||
# Enum(AuthMethod, values_callable=lambda obj: [e.value for e in obj]),
|
|
||||||
# nullable=False,
|
|
||||||
# comment="Authentication method: free, apikey, token",
|
|
||||||
# )
|
|
||||||
base_url: Mapped[str] = mapped_column(String(512), nullable=True, comment="api url")
|
base_url: Mapped[str] = mapped_column(String(512), nullable=True, comment="api url")
|
||||||
headers: Mapped[str] = mapped_column(String, nullable=True, comment="Additional headers for requests (JSON Array format)")
|
headers: Mapped[str] = mapped_column(String, nullable=True, comment="Additional headers for requests (JSON Array format)")
|
||||||
# auth_header: Mapped[str] = mapped_column(String(255), nullable=True, comment="Authentication header name")
|
|
||||||
# auth_token: Mapped[str] = mapped_column(String(255), nullable=True, comment="Authentication token value")
|
|
||||||
charge_type: Mapped[ChargeType] = mapped_column(
|
charge_type: Mapped[ChargeType] = mapped_column(
|
||||||
Enum(ChargeType, values_callable=lambda obj: [e.value for e in obj]),
|
Enum(ChargeType, values_callable=lambda obj: [e.value for e in obj]),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ class User(Base):
|
|||||||
default=False,
|
default=False,
|
||||||
comment="1: admin, 2: user",
|
comment="1: admin, 2: user",
|
||||||
)
|
)
|
||||||
|
group_id: Mapped[str] = mapped_column(
|
||||||
|
String(36),
|
||||||
|
nullable=True,
|
||||||
|
default="",
|
||||||
|
comment="Group ID",
|
||||||
|
)
|
||||||
last_login_at: Mapped[datetime] = mapped_column(
|
last_login_at: Mapped[datetime] = mapped_column(
|
||||||
DateTime,
|
DateTime,
|
||||||
nullable=True,
|
nullable=True,
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, field_serializer
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
class UserManagerResponse(BaseModel):
|
class UserManagerResponse(BaseModel):
|
||||||
user_id: Optional[str] = None
|
user_id: Optional[str] = None
|
||||||
email: Optional[str] = None
|
email: Optional[str] = None
|
||||||
balance: Optional[float] = None
|
balance: Optional[Decimal] = None
|
||||||
created_at: Optional[datetime.datetime] = None
|
created_at: Optional[datetime.datetime] = None
|
||||||
|
|
||||||
|
@field_serializer('balance', when_used='json')
|
||||||
|
def serialize_balance(self, v: Optional[Decimal]) -> Optional[float]:
|
||||||
|
return float(v) if v is not None else None
|
||||||
@@ -9,6 +9,8 @@ class UserResponse(BaseModel):
|
|||||||
user_name: Optional[str] = None
|
user_name: Optional[str] = None
|
||||||
user_email: Optional[str] = None
|
user_email: Optional[str] = None
|
||||||
role_id: Optional[int] = None
|
role_id: Optional[int] = None
|
||||||
|
allow_all: Optional[bool] = None
|
||||||
|
service_ids: Optional[list] = None
|
||||||
created_at: Optional[datetime.datetime] = None
|
created_at: Optional[datetime.datetime] = None
|
||||||
wallet: Optional[UserWalletResponse] = None
|
wallet: Optional[UserWalletResponse] = None
|
||||||
register_type: Optional[str] = None
|
register_type: Optional[str] = None
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, field_serializer
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
|
||||||
class UserWalletResponse(BaseModel):
|
class UserWalletResponse(BaseModel):
|
||||||
balance: Optional[float] = None
|
balance: Optional[Decimal] = None
|
||||||
|
|
||||||
|
@field_serializer('balance', when_used='json')
|
||||||
|
def serialize_balance(self, v: Optional[Decimal]) -> Optional[float]:
|
||||||
|
return float(v) if v is not None else None
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
from typing import get_origin, get_args
|
from typing import get_origin, get_args
|
||||||
from enum import Enum as PyEnum
|
from enum import Enum as PyEnum
|
||||||
|
from decimal import Decimal
|
||||||
|
from datetime import datetime
|
||||||
|
from sqlalchemy import DateTime, Numeric
|
||||||
|
|
||||||
|
|
||||||
class SqlalchemyUtils:
|
class SqlalchemyUtils:
|
||||||
@@ -7,10 +10,13 @@ class SqlalchemyUtils:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def model_to_dict(model):
|
def model_to_dict(model):
|
||||||
result = {column.name: getattr(model, column.name) for column in model.__table__.columns}
|
result = {column.name: getattr(model, column.name) for column in model.__table__.columns}
|
||||||
# Normalize Enum values to primitive for safe serialization
|
|
||||||
for key, value in list(result.items()):
|
for key, value in list(result.items()):
|
||||||
if isinstance(value, PyEnum):
|
if isinstance(value, PyEnum):
|
||||||
result[key] = value.value
|
result[key] = value.value
|
||||||
|
elif isinstance(value, Decimal):
|
||||||
|
result[key] = str(value)
|
||||||
|
elif isinstance(value, datetime):
|
||||||
|
result[key] = value.isoformat()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -27,31 +33,42 @@ class SqlalchemyUtils:
|
|||||||
"""
|
"""
|
||||||
instance = model_class()
|
instance = model_class()
|
||||||
|
|
||||||
# Get all column names for the model
|
# Map column definitions by name for type-aware restoration
|
||||||
column_names = {column.name for column in model_class.__table__.columns}
|
columns_by_name = {column.name: column for column in model_class.__table__.columns}
|
||||||
|
|
||||||
# Set attributes that exist in both the dictionary and the model
|
|
||||||
for key, value in data_dict.items():
|
for key, value in data_dict.items():
|
||||||
if key in column_names and hasattr(instance, key):
|
column = columns_by_name.get(key)
|
||||||
# Attempt to restore Enum types from strings using type annotations
|
if column is None:
|
||||||
annotations = getattr(model_class, "__annotations__", {})
|
continue
|
||||||
ann = annotations.get(key)
|
|
||||||
target_type = None
|
|
||||||
if ann is not None:
|
|
||||||
origin = get_origin(ann)
|
|
||||||
if origin is None:
|
|
||||||
target_type = ann
|
|
||||||
else:
|
|
||||||
args = get_args(ann)
|
|
||||||
if args:
|
|
||||||
target_type = args[0]
|
|
||||||
|
|
||||||
if isinstance(target_type, type) and issubclass(target_type, PyEnum) and isinstance(value, str):
|
# Restore Enum from string using annotations if available
|
||||||
try:
|
annotations = getattr(model_class, "__annotations__", {})
|
||||||
value = target_type(value)
|
ann = annotations.get(key)
|
||||||
except Exception:
|
target_type = None
|
||||||
pass
|
if ann is not None:
|
||||||
|
origin = get_origin(ann)
|
||||||
|
if origin is None:
|
||||||
|
target_type = ann
|
||||||
|
else:
|
||||||
|
args = get_args(ann)
|
||||||
|
if args:
|
||||||
|
target_type = args[0]
|
||||||
|
if isinstance(target_type, type) and issubclass(target_type, PyEnum) and isinstance(value, str):
|
||||||
|
try:
|
||||||
|
value = target_type(value)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
setattr(instance, key, value)
|
# Restore Numeric and DateTime types from JSON-friendly forms
|
||||||
|
try:
|
||||||
|
if isinstance(column.type, Numeric) and value is not None:
|
||||||
|
if not isinstance(value, Decimal):
|
||||||
|
value = Decimal(str(value))
|
||||||
|
elif isinstance(column.type, DateTime) and isinstance(value, str):
|
||||||
|
value = datetime.fromisoformat(value)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
setattr(instance, key, value)
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
@@ -120,6 +120,31 @@ class ValidationUtils:
|
|||||||
raise ValidationException(f"Parameter '{param_name}' must be a valid HTTP/HTTPS URL")
|
raise ValidationException(f"Parameter '{param_name}' must be a valid HTTP/HTTPS URL")
|
||||||
|
|
||||||
return url
|
return url
|
||||||
|
@staticmethod
|
||||||
|
def validate_domain(domain: str, param_name: str = "domain") -> str:
|
||||||
|
"""
|
||||||
|
Validate domain format
|
||||||
|
|
||||||
|
Args:
|
||||||
|
domain: The domain to validate
|
||||||
|
param_name: Name of the parameter for error message
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The validated domain
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValidationException: If domain format is invalid
|
||||||
|
"""
|
||||||
|
if not domain or not isinstance(domain, str):
|
||||||
|
raise ValidationException(f"Parameter '{param_name}' must be a valid domain name")
|
||||||
|
|
||||||
|
domain = domain.strip().lower()
|
||||||
|
domain_pattern = r'^(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,})$'
|
||||||
|
|
||||||
|
if not re.match(domain_pattern, domain):
|
||||||
|
raise ValidationException(f"Parameter '{param_name}' must be a valid domain name")
|
||||||
|
|
||||||
|
return domain
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def validate_pagination(page: Any, page_size: Any) -> Tuple[int, int]:
|
def validate_pagination(page: Any, page_size: Any) -> Tuple[int, int]:
|
||||||
|
|||||||
Reference in new issue
Block a user