fix(gateway): support claude_code cross-format Claude messages

This commit is contained in:
zhefox
2026-08-05 13:57:20 +08:00
parent 1aab31a148
commit 4d67569873
13 changed files with 349 additions and 46 deletions
+34
View File
@@ -0,0 +1,34 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const { patchMock } = vi.hoisted(() => ({
patchMock: vi.fn(),
}))
vi.mock('@/api/client', () => ({
default: {
patch: patchMock,
},
}))
import { meApi } from '@/api/me'
describe('meApi API key status', () => {
beforeEach(() => {
patchMock.mockReset()
patchMock.mockResolvedValue({
data: {
id: 'user-key-1',
is_active: false,
},
})
})
it('sends the desired disabled state in the patch body', async () => {
await meApi.toggleApiKey('user-key-1', false)
expect(patchMock).toHaveBeenCalledWith(
'/api/users/me/api-keys/user-key-1',
{ is_active: false },
)
})
})
+4 -2
View File
@@ -300,8 +300,10 @@ export const meApi = {
return response.data
},
async toggleApiKey(keyId: string): Promise<ApiKey> {
const response = await apiClient.patch<ApiKey>(`/api/users/me/api-keys/${keyId}`)
async toggleApiKey(keyId: string, isActive: boolean): Promise<ApiKey> {
const response = await apiClient.patch<ApiKey>(`/api/users/me/api-keys/${keyId}`, {
is_active: isActive,
})
return response.data
},