mirror of
https://github.com/langgenius/dify.git
synced 2026-06-17 06:21:07 +08:00
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import type {
|
|
MemberActionResponse,
|
|
MemberInvitePayload,
|
|
MemberInviteResponse,
|
|
MemberListResponse,
|
|
MemberRoleUpdatePayload,
|
|
} from '@dify/contracts/api/openapi/types.gen'
|
|
import type { OpenApiClient } from '@/http/orpc'
|
|
import type { HttpClient } from '@/http/types'
|
|
import { createOpenApiClient } from '@/http/orpc'
|
|
|
|
/**
|
|
* Thin client for /openapi/v1/workspaces/<id>/members, over the generated oRPC contract.
|
|
*
|
|
* Non-2xx (400/403/404/422) surface as BaseError — the oRPC client maps them at the transport
|
|
* seam. The CLI's AuthedCommand base layer renders those for the user; clients never swallow codes.
|
|
*/
|
|
export class MembersClient {
|
|
private readonly orpc: OpenApiClient
|
|
|
|
constructor(http: HttpClient) {
|
|
this.orpc = createOpenApiClient(http)
|
|
}
|
|
|
|
async list(workspaceId: string, q?: { page?: number, limit?: number }): Promise<MemberListResponse> {
|
|
return this.orpc.workspaces.byWorkspaceId.members.get({
|
|
params: { workspace_id: workspaceId },
|
|
query: { page: q?.page, limit: q?.limit },
|
|
})
|
|
}
|
|
|
|
async invite(workspaceId: string, payload: MemberInvitePayload): Promise<MemberInviteResponse> {
|
|
return this.orpc.workspaces.byWorkspaceId.members.post({
|
|
params: { workspace_id: workspaceId },
|
|
body: payload,
|
|
})
|
|
}
|
|
|
|
async remove(workspaceId: string, memberId: string): Promise<MemberActionResponse> {
|
|
return this.orpc.workspaces.byWorkspaceId.members.byMemberId.delete({
|
|
params: { workspace_id: workspaceId, member_id: memberId },
|
|
})
|
|
}
|
|
|
|
async updateRole(
|
|
workspaceId: string,
|
|
memberId: string,
|
|
payload: MemberRoleUpdatePayload,
|
|
): Promise<MemberActionResponse> {
|
|
return this.orpc.workspaces.byWorkspaceId.members.byMemberId.role.put({
|
|
params: { workspace_id: workspaceId, member_id: memberId },
|
|
body: payload,
|
|
})
|
|
}
|
|
}
|