import {z} from 'zod' export type Role = {id?: string | undefined, title?: (string | null) | undefined, technical?: boolean | undefined, company?: (string | null) | undefined}; export type Company = {id?: string | undefined, title?: string | undefined, email?: (string | null) | undefined, slack_workspace?: string | undefined, max_users?: string | undefined, plan_title?: string | undefined, plan_price?: string | undefined, all_content?: string | undefined, custom_content?: string | undefined, has_workflows?: string | undefined, has_paid_streams?: string | undefined, hris_integration?: string | undefined, has_vanta?: string | undefined, has_api_access?: string | undefined, has_docebo?: string | undefined, has_seismic?: string | undefined, has_phishing_access?: string | undefined, icon?: (string | null) | undefined, domain?: (string | null) | undefined, active_employees_trainings?: string | undefined, total_employees?: string | undefined, guest_accounts_included?: string | undefined, is_global_content_maker?: string | undefined}; export type EmployeeNotifications = {id?: string | undefined, created?: string | undefined, modified?: string | undefined, email_notification?: boolean | undefined, slack_notification?: boolean | undefined}; export type Employee = {id?: string | undefined, name: string, email: string, slack_uid: string | null, role?: (string | null) | undefined, role_serialized: Role, company?: string | undefined, user?: string | undefined, is_admin?: boolean | undefined, is_manager?: string | undefined, company_details: Company, avatar_image?: (string | null) | undefined, points?: number | undefined, level?: string | undefined, notifications: EmployeeNotifications, google_id?: string | undefined}; export type PatchApiApiCompaniesIdEmployeesEmployeeIdAdminArgs = {body: Employee}; export type PatchApiApiCompaniesIdEmployeesEmployeeIdAdminOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const role = z.object({id: z.string().optional(), title: z.string().max(60).nullable().optional(), technical: z.boolean().optional(), company: z.string().nullable().optional()}); export const company = z.object({id: z.string().optional(), title: z.string().min(1).optional(), email: z.string().min(1).max(254).nullable().optional(), slack_workspace: z.string().min(1).optional(), max_users: z.string().optional(), plan_title: z.string().optional(), plan_price: z.string().optional(), all_content: z.string().optional(), custom_content: z.string().optional(), has_workflows: z.string().optional(), has_paid_streams: z.string().optional(), hris_integration: z.string().optional(), has_vanta: z.string().optional(), has_api_access: z.string().optional(), has_docebo: z.string().optional(), has_seismic: z.string().optional(), has_phishing_access: z.string().optional(), icon: z.string().max(200).nullable().optional(), domain: z.string().max(256).nullable().optional(), active_employees_trainings: z.string().optional(), total_employees: z.string().optional(), guest_accounts_included: z.string().optional(), is_global_content_maker: z.string().optional()}); export const employeeNotifications = z.object({id: z.string().optional(), created: z.string().optional(), modified: z.string().optional(), email_notification: z.boolean().optional(), slack_notification: z.boolean().optional()}); export const employee = z.object({id: z.string().optional(), name: z.string().min(1).max(80), email: z.string().min(1).max(254), slack_uid: z.string().max(254).nullable(), role: z.string().nullable().optional(), role_serialized: role, company: z.string().optional(), user: z.string().optional(), is_admin: z.boolean().optional(), is_manager: z.string().optional(), company_details: company, avatar_image: z.string().max(200).nullable().optional(), points: z.number().int().gte(-2147483648).lte(2147483647).optional(), level: z.string().optional(), notifications: employeeNotifications, google_id: z.string().min(1).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 employee admin status. Requires admin privileges and company access. * * PATCH /api/companies/{id}/employees/{employee_id}/admin */ export const patchApiApiCompaniesIdEmployeesEmployeeIdAdmin = async (args: PatchApiApiCompaniesIdEmployeesEmployeeIdAdminArgs, options?: PatchApiApiCompaniesIdEmployeesEmployeeIdAdminOptions) => { 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/companies/${encodeURIComponent(String(args.id))}/employees/${encodeURIComponent(String(args.employee_id))}/admin${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(employee, await res.json()) };