import {z} from 'zod' export type EmployeeWithoutCompanyDetails = {id?: string | undefined, name: string, avatar_image?: (string | null) | undefined, email: string, slack_uid: string | null, role?: (string | null) | undefined, company?: string | undefined, user?: string | undefined, is_admin?: boolean | undefined, is_manager?: string | undefined, points?: number | undefined, level?: string | undefined}; export type CreateApiApiEmployeesIdWorkflowWorkflowIdUnassignArgs = {body: EmployeeWithoutCompanyDetails}; export type CreateApiApiEmployeesIdWorkflowWorkflowIdUnassignOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const employeeWithoutCompanyDetails = z.object({id: z.string().optional(), name: z.string().min(1).max(80), avatar_image: z.string().max(200).nullable().optional(), email: z.string().min(1).max(254), slack_uid: z.string().max(254).nullable(), role: z.string().nullable().optional(), company: z.string().optional(), user: z.string().optional(), is_admin: z.boolean().optional(), is_manager: z.string().optional(), points: z.number().int().gte(-2147483648).lte(2147483647).optional(), level: z.string().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 }; /** * POST /api/employees/{id}/workflow/{workflow_id}/unassign */ export const createApiApiEmployeesIdWorkflowWorkflowIdUnassign = async (args: CreateApiApiEmployeesIdWorkflowWorkflowIdUnassignArgs, options?: CreateApiApiEmployeesIdWorkflowWorkflowIdUnassignOptions) => { const {baseUrl = "https://app.haekka.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/api/employees/${encodeURIComponent(String(args.id))}/workflow/${encodeURIComponent(String(args.workflow_id))}/unassign${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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(employeeWithoutCompanyDetails, await res.json()) };