import {z} from 'zod' export type UpdateApiApiV1TeamsRolesRoleIdArgs = {roleId: number, body: {name?: string | undefined, description?: string | undefined, type?: ('local' | 'global') | undefined, is_chat_only?: boolean | undefined, permissions?: (Array<'Add team member' | 'Remove team member' | 'Update team name' | 'Create Project' | 'Delete Project' | 'View Project Stats' | 'View Project Logs' | 'Read Project Settings' | 'Update Project Settings' | 'View Project Source' | 'Create Project Source' | 'Update Project Source' | 'Delete Project Source' | 'View Subscription' | 'Create Conversation' | 'Delete Team Conversations' | 'Delete Anonymous Conversations' | 'Update Team Conversations' | 'Update Anonymous Conversations' | 'Read Team Conversations' | 'Read Anonymous Conversations' | 'Export Conversation'>) | undefined, agents?: Array | undefined, allow_create_agents?: boolean | undefined}}; export type UpdateApiApiV1TeamsRolesRoleIdOptions = {baseUrl?: string | undefined, BearerToken?: string | undefined, fetch?: typeof fetch | undefined}; export const teamRole = z.object({id: z.number().int().optional(), name: z.string().optional(), description: z.string().optional(), type: z.enum(["local", "global"]).optional(), is_chat_only: z.boolean().optional(), has_access_to_projects: z.boolean().optional(), allow_create_agents: z.boolean().optional(), agents: z.array(z.number().int()).optional(), permissions: z.array(z.enum(["Add team member", "Remove team member", "Update team name", "Create Project", "Delete Project", "View Project Stats", "View Project Logs", "Read Project Settings", "Update Project Settings", "View Project Source", "Create Project Source", "Update Project Source", "Delete Project Source", "View Subscription", "Create Conversation", "Delete Team Conversations", "Delete Anonymous Conversations", "Update Team Conversations", "Update Anonymous Conversations", "Read Team Conversations", "Read Anonymous Conversations", "Export Conversation"])).optional(), created_at: z.string().optional(), updated_at: z.string().optional()}); export const updateApiApiV1TeamsRolesRoleIdResponse = z.object({status: z.enum(["error", "success"]).optional(), data: teamRole.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update a custom role. * * PUT /api/v1/teams/roles/{roleId} */ export const updateApiApiV1TeamsRolesRoleId = async (args: UpdateApiApiV1TeamsRolesRoleIdArgs, options?: UpdateApiApiV1TeamsRolesRoleIdOptions) => { const {baseUrl = "https://app.customgpt.ai", fetch: fetchFn = fetch, BearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerToken !== undefined) headers.set('authorization', `Bearer ${BearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/teams/roles/${encodeURIComponent(String(args.roleId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(updateApiApiV1TeamsRolesRoleIdResponse, await res.json()) };