Commit 1c380ea3 by Finley Ge Committed by GitHub

fix(plugin): normalize debug channel routes (#7237)

parent a1bd28d0
...@@ -380,13 +380,13 @@ Scripts and Agents can use non-interactive mode: ...@@ -380,13 +380,13 @@ Scripts and Agents can use non-interactive mode:
```bash ```bash
fastgpt-plugin dev --no-interactive \ fastgpt-plugin dev --no-interactive \
--connect "https://fastgpt.example.com/api/plugin/debug-channel/connection-key:exchange?connectionKey=fpg_dbg_..." --connect "https://fastgpt.example.com/api/plugin/debug-channel/connection-key/exchange?connectionKey=fpg_dbg_..."
``` ```
When passing only a raw connection key, tell the CLI where the exchange endpoint is: When passing only a raw connection key, tell the CLI where the exchange endpoint is:
```bash ```bash
FASTGPT_PLUGIN_DEBUG_CONNECT_URL=https://fastgpt.example.com/api/plugin/debug-channel/connection-key:exchange \ FASTGPT_PLUGIN_DEBUG_CONNECT_URL=https://fastgpt.example.com/api/plugin/debug-channel/connection-key/exchange \
fastgpt-plugin dev --no-interactive --connect "fpg_dbg_..." fastgpt-plugin dev --no-interactive --connect "fpg_dbg_..."
``` ```
......
...@@ -380,13 +380,13 @@ fastgpt-plugin dev ...@@ -380,13 +380,13 @@ fastgpt-plugin dev
```bash ```bash
fastgpt-plugin dev --no-interactive \ fastgpt-plugin dev --no-interactive \
--connect "https://fastgpt.example.com/api/plugin/debug-channel/connection-key:exchange?connectionKey=fpg_dbg_..." --connect "https://fastgpt.example.com/api/plugin/debug-channel/connection-key/exchange?connectionKey=fpg_dbg_..."
``` ```
如果只传入裸 connection key,需要让 CLI 知道 exchange 接口地址: 如果只传入裸 connection key,需要让 CLI 知道 exchange 接口地址:
```bash ```bash
FASTGPT_PLUGIN_DEBUG_CONNECT_URL=https://fastgpt.example.com/api/plugin/debug-channel/connection-key:exchange \ FASTGPT_PLUGIN_DEBUG_CONNECT_URL=https://fastgpt.example.com/api/plugin/debug-channel/connection-key/exchange \
fastgpt-plugin dev --no-interactive --connect "fpg_dbg_..." fastgpt-plugin dev --no-interactive --connect "fpg_dbg_..."
``` ```
......
...@@ -69,7 +69,7 @@ export const EnablePluginDebugChannelResponseSchema = PluginDebugChannelBaseSche ...@@ -69,7 +69,7 @@ export const EnablePluginDebugChannelResponseSchema = PluginDebugChannelBaseSche
}), }),
connectionUrl: z.string().url().optional().meta({ connectionUrl: z.string().url().optional().meta({
example: example:
'https://fastgpt.example.com/api/plugin/debug-channel/connection-key:exchange?connectionKey=fgdbg_xxx', 'https://fastgpt.example.com/api/plugin/debug-channel/connection-key/exchange?connectionKey=fgdbg_xxx',
description: '本地 CLI 可直接访问的 FastGPT HTTP 调试连接链接' description: '本地 CLI 可直接访问的 FastGPT HTTP 调试连接链接'
}) })
}).required({ }).required({
...@@ -82,7 +82,7 @@ export type EnablePluginDebugChannelResponseType = z.infer< ...@@ -82,7 +82,7 @@ export type EnablePluginDebugChannelResponseType = z.infer<
/* ============================================================================ /* ============================================================================
* API: 刷新插件调试连接密钥 * API: 刷新插件调试连接密钥
* Route: POST /api/plugin/debug-channel/key:refresh * Route: POST /api/plugin/debug-channel/key/refresh
* Method: POST * Method: POST
* Description: 刷新当前登录团队成员的插件调试 connectionKey,旧连接密钥会失效 * Description: 刷新当前登录团队成员的插件调试 connectionKey,旧连接密钥会失效
* Tags: ['插件调试', 'Write'] * Tags: ['插件调试', 'Write']
...@@ -212,7 +212,7 @@ export type RevokePluginDebugChannelResponseType = z.infer< ...@@ -212,7 +212,7 @@ export type RevokePluginDebugChannelResponseType = z.infer<
/* ============================================================================ /* ============================================================================
* API: 兑换插件调试连接信息 * API: 兑换插件调试连接信息
* Route: GET/POST /api/plugin/debug-channel/connection-key:exchange * Route: GET/POST /api/plugin/debug-channel/connection-key/exchange
* Method: GET/POST * Method: GET/POST
* Description: CLI 使用 HTTP 连接链接或 connectionKey 兑换短期 WSS connectToken 和 gateway 连接信息 * Description: CLI 使用 HTTP 连接链接或 connectionKey 兑换短期 WSS connectToken 和 gateway 连接信息
* Tags: ['插件调试', 'Public', 'Write'] * Tags: ['插件调试', 'Public', 'Write']
......
...@@ -39,7 +39,7 @@ export const PluginDebugPath: OpenAPIPath = { ...@@ -39,7 +39,7 @@ export const PluginDebugPath: OpenAPIPath = {
} }
} }
}, },
'/plugin/debug-channel/key:refresh': { '/plugin/debug-channel/key/refresh': {
post: { post: {
summary: '刷新插件调试连接密钥', summary: '刷新插件调试连接密钥',
description: '刷新当前登录团队成员的插件调试 connectionKey,旧连接密钥会失效', description: '刷新当前登录团队成员的插件调试 connectionKey,旧连接密钥会失效',
...@@ -104,7 +104,7 @@ export const PluginDebugPath: OpenAPIPath = { ...@@ -104,7 +104,7 @@ export const PluginDebugPath: OpenAPIPath = {
} }
} }
}, },
'/plugin/debug-channel/connection-key:exchange': { '/plugin/debug-channel/connection-key/exchange': {
get: { get: {
summary: '通过连接链接兑换插件调试连接信息', summary: '通过连接链接兑换插件调试连接信息',
description: description:
......
...@@ -415,7 +415,7 @@ function buildPluginDebugConnectionLink(connectionKey?: string) { ...@@ -415,7 +415,7 @@ function buildPluginDebugConnectionLink(connectionKey?: string) {
if (!connectionKey || typeof window === 'undefined') return ''; if (!connectionKey || typeof window === 'undefined') return '';
const url = new URL( const url = new URL(
getWebReqUrl('/api/plugin/debug-channel/connection-key:exchange'), getWebReqUrl('/api/plugin/debug-channel/connection-key/exchange'),
window.location.origin window.location.origin
); );
url.searchParams.set('connectionKey', connectionKey); url.searchParams.set('connectionKey', connectionKey);
......
...@@ -37,7 +37,7 @@ export const buildPluginDebugConnectionUrl = ({ ...@@ -37,7 +37,7 @@ export const buildPluginDebugConnectionUrl = ({
if (!origin) return; if (!origin) return;
const url = new URL( const url = new URL(
`${serviceEnv.NEXT_PUBLIC_BASE_URL || ''}/api/plugin/debug-channel/connection-key:exchange`, `${serviceEnv.NEXT_PUBLIC_BASE_URL || ''}/api/plugin/debug-channel/connection-key/exchange`,
origin origin
); );
url.searchParams.set('connectionKey', connectionKey); url.searchParams.set('connectionKey', connectionKey);
......
...@@ -13,7 +13,7 @@ export const enablePluginDebugChannel = (data: EnablePluginDebugChannelBodyType ...@@ -13,7 +13,7 @@ export const enablePluginDebugChannel = (data: EnablePluginDebugChannelBodyType
export const refreshPluginDebugConnectionKey = ( export const refreshPluginDebugConnectionKey = (
data: RefreshPluginDebugConnectionKeyBodyType = {} data: RefreshPluginDebugConnectionKeyBodyType = {}
) => POST<RefreshPluginDebugConnectionKeyResponseType>('/plugin/debug-channel/key:refresh', data); ) => POST<RefreshPluginDebugConnectionKeyResponseType>('/plugin/debug-channel/key/refresh', data);
export const getPluginDebugChannel = () => export const getPluginDebugChannel = () =>
GET<GetPluginDebugChannelResponseType>('/plugin/debug-channel', {}); GET<GetPluginDebugChannelResponseType>('/plugin/debug-channel', {});
......
...@@ -16,7 +16,7 @@ vi.mock('@fastgpt/service/thirdProvider/fastgptPlugin', () => ({ ...@@ -16,7 +16,7 @@ vi.mock('@fastgpt/service/thirdProvider/fastgptPlugin', () => ({
pluginClient: mocks.pluginClient pluginClient: mocks.pluginClient
})); }));
import handler from '@/pages/api/plugin/debug-channel/connection-key:exchange'; import handler from '@/pages/api/plugin/debug-channel/connection-key/exchange';
describe('plugin debug channel connection key exchange handler', () => { describe('plugin debug channel connection key exchange handler', () => {
let originalIsPlus: unknown; let originalIsPlus: unknown;
......
...@@ -16,7 +16,7 @@ vi.mock('@fastgpt/service/thirdProvider/fastgptPlugin', () => ({ ...@@ -16,7 +16,7 @@ vi.mock('@fastgpt/service/thirdProvider/fastgptPlugin', () => ({
pluginClient: mocks.pluginClient pluginClient: mocks.pluginClient
})); }));
import handler from '@/pages/api/plugin/debug-channel/key:refresh'; import handler from '@/pages/api/plugin/debug-channel/key/refresh';
describe('plugin debug channel key refresh handler', () => { describe('plugin debug channel key refresh handler', () => {
let originalIsPlus: unknown; let originalIsPlus: unknown;
...@@ -74,7 +74,7 @@ describe('plugin debug channel key refresh handler', () => { ...@@ -74,7 +74,7 @@ describe('plugin debug channel key refresh handler', () => {
keyId: 'key_refreshed', keyId: 'key_refreshed',
connectionKey: 'connection_key_refreshed', connectionKey: 'connection_key_refreshed',
connectionUrl: connectionUrl:
'https://fastgpt.example.com/api/plugin/debug-channel/connection-key:exchange?connectionKey=connection_key_refreshed', 'https://fastgpt.example.com/api/plugin/debug-channel/connection-key/exchange?connectionKey=connection_key_refreshed',
createdAt: 1_781_500_000_000, createdAt: 1_781_500_000_000,
updatedAt: 1_781_500_100_000, updatedAt: 1_781_500_100_000,
refreshedAt: 1_781_500_100_000 refreshedAt: 1_781_500_100_000
......
...@@ -80,7 +80,7 @@ describe('plugin debug channel enable handler', () => { ...@@ -80,7 +80,7 @@ describe('plugin debug channel enable handler', () => {
keyId: 'key_test', keyId: 'key_test',
connectionKey: 'connection_key', connectionKey: 'connection_key',
connectionUrl: connectionUrl:
'https://fastgpt.example.com/api/plugin/debug-channel/connection-key:exchange?connectionKey=connection_key', 'https://fastgpt.example.com/api/plugin/debug-channel/connection-key/exchange?connectionKey=connection_key',
createdAt: 1_781_500_000_000, createdAt: 1_781_500_000_000,
updatedAt: 1_781_500_000_000 updatedAt: 1_781_500_000_000
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment