mirror of
https://github.com/langgenius/dify.git
synced 2026-06-08 00:41:55 +08:00
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>
30 lines
966 B
TypeScript
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')
|
|
}
|
|
}
|