mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
refactor(cli/http): replace ky with a self-contained HTTP client (#36711)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
055d9b9f0a
commit
cfc1cf2b8c
70 files changed
+1947
-600
No files matched your search
@@ -1,15 +1,15 @@
|
||||
import type { WorkspaceDetailResponse, WorkspaceListResponse } from '@dify/contracts/api/openapi/types.gen'
|
||||
import type { KyInstance } from 'ky'
|
||||
import type { HttpClient } from '@/http/types'
|
||||
|
||||
export class WorkspacesClient {
|
||||
private readonly http: KyInstance
|
||||
private readonly http: HttpClient
|
||||
|
||||
constructor(http: KyInstance) {
|
||||
constructor(http: HttpClient) {
|
||||
this.http = http
|
||||
}
|
||||
|
||||
async list(): Promise<WorkspaceListResponse> {
|
||||
return this.http.get('workspaces').json<WorkspaceListResponse>()
|
||||
return this.http.get<WorkspaceListResponse>('workspaces')
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,8 +22,6 @@ export class WorkspacesClient {
|
||||
* server's state.
|
||||
*/
|
||||
async switch(workspaceId: string): Promise<WorkspaceDetailResponse> {
|
||||
return this.http
|
||||
.post(`workspaces/${encodeURIComponent(workspaceId)}/switch`)
|
||||
.json<WorkspaceDetailResponse>()
|
||||
return this.http.post<WorkspaceDetailResponse>(`workspaces/${encodeURIComponent(workspaceId)}/switch`)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user