dify/cli/src/api/account-sessions.ts
L1nSn0w 6e1e0d9439
feat(openapi,cli): workspace switch + member management (#36651)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-05-27 03:05:47 +00:00

30 lines
966 B
TypeScript

import type { SessionListResponse } from '@dify/contracts/api/openapi/types.gen'
import type { KyInstance } from 'ky'
export class AccountSessionsClient {
private readonly http: KyInstance
constructor(http: KyInstance) {
this.http = http
}
async list(q?: { page?: number, limit?: number }): Promise<SessionListResponse> {
const params = new URLSearchParams()
if (q?.page !== undefined)
params.set('page', String(q.page))
if (q?.limit !== undefined)
params.set('limit', String(q.limit))
const hasParams = Array.from(params.keys()).length > 0
const opts = hasParams ? { searchParams: params } : undefined
return this.http.get('account/sessions', opts).json<SessionListResponse>()
}
async revoke(sessionId: string): Promise<void> {
await this.http.delete(`account/sessions/${encodeURIComponent(sessionId)}`)
}
async revokeSelf(): Promise<void> {
await this.http.delete('account/sessions/self')
}
}