import {z} from 'zod' export type PostHrisEmployeesRequestBody = {first_name: string, last_name: string, work_email?: string | undefined, gender?: ('MALE' | 'FEMALE' | 'NON_BINARY' | 'NOT_SPECIFIED') | undefined, job_title?: string | undefined, home_address?: ({street_1?: string | undefined, street_2?: string | undefined, city?: string | undefined, state?: string | undefined, zip_code?: string | undefined, country?: string | undefined}) | undefined, date_of_birth?: string | undefined, mobile_phone_number?: string | undefined, home_phone_number?: string | undefined, nationality?: string | undefined, start_date?: string | undefined, legal_entity_id?: string | undefined, location_id?: string | undefined, remote_fields?: ({humaans?: ({employee?: {[key: string]: unknown} | undefined}) | undefined, hibob?: ({employee?: {[key: string]: unknown} | undefined}) | undefined, sympa?: ({GenericNewHire?: {[key: string]: unknown} | undefined}) | undefined, silae?: ({siret?: string | undefined, employee?: {[key: string]: unknown} | undefined, employment?: {[key: string]: unknown} | undefined}) | undefined, sagehr?: ({employee?: ({[key: string]: string | number | boolean}) | undefined, team_id?: string | undefined, leader_id?: string | undefined, position_id?: string | undefined, location_id?: string | undefined, employee_number?: string | undefined, approver_ids?: Array | undefined, selected_leave_types?: Array | undefined, custom_fields?: {[key: string]: string} | undefined}) | undefined, peoplehr?: ({job_role_effective_date?: string | undefined, department?: string | undefined}) | undefined, zohopeople?: ({employee_id?: string | undefined}) | undefined, workday?: ({job_requisition_id?: string | undefined, position_id?: string | undefined, ssn?: string | undefined, bank_account?: {iban: string, bic: string, bank_name: string} | undefined}) | undefined, deel?: {candidate_id: string, candidate_link: string} | undefined, bamboohr?: ({employee?: {[key: string]: unknown} | undefined}) | undefined, oracle?: {group_id: string, department_id: string} | undefined, adpworkforcenow?: ({onboarding_template_code: string, applicant_payroll_profile_group_code: string, manager_position_id?: string | undefined, home_organization_unit_code?: string | undefined, personal_email?: string | undefined}) | undefined, azuread?: {password: string} | undefined, paycor?: {paygroupRemoteId: string, departmentRemoteId: string} | undefined, planday?: {department_remote_id: string} | undefined, dayforce?: {social_security_number: string, pay_type: string, pay_class: string, pay_group: string, base_rate: number, role: string, location: string, department: string, job: string, country: string} | undefined}) | undefined}; export type CreateApiHrisEmployeesArgs = {'X-Integration-Id': string, body: PostHrisEmployeesRequestBody}; export type CreateApiHrisEmployeesOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const postHrisEmployeesPositiveResponse = z.object({status: z.literal("success"), data: z.object({id: z.string(), remote_id: z.string(), employee_number: z.string().nullable(), first_name: z.string().nullable(), last_name: z.string().nullable(), nationality: z.string().nullable(), display_full_name: z.string().nullable(), job_title: z.string().nullable(), work_email: z.string().nullable().optional(), personal_email: z.string().nullable().optional(), mobile_phone_number: z.string().nullable(), ssn: z.string().nullable(), tax_id: z.string().nullable(), gender: z.union([z.enum(["MALE", "FEMALE", "NON_BINARY", "NOT_SPECIFIED"]), z.string()]).nullable().optional(), ethnicity: z.union([z.enum(["WHITE", "ASIAN", "HISPANIC_LATINO", "HAWAIIAN", "NATIVE_AMERICAN", "BLACK_AFRICAN_AMERICAN", "MULTIPLE_ETHNICITIES", "DECLINE_TO_SPECIFY"]), z.string()]).nullable().optional(), marital_status: z.union([z.enum(["SINGLE", "MARRIED", "DOMESTIC_PARTNERSHIP", "WIDOWED", "DIVORCED", "SEPARATED", "NOT_MARRIED"]), z.string()]).nullable().optional(), employment_status: z.union([z.enum(["ACTIVE", "PENDING", "INACTIVE", "LEAVE"]), z.string()]).nullable().optional(), employment_type: z.union([z.enum(["FULL_TIME", "PART_TIME", "CONTRACT", "INTERNSHIP", "FREELANCE", "WORKING_STUDENT", "APPRENTICESHIP", "TRAINING"]), z.string()]).nullable().optional(), weekly_hours: z.number().nullable(), avatar: z.string().nullable(), work_location_id: z.string().nullable(), legal_entity_id: z.string().nullable(), manager_id: z.string().nullable(), home_address: z.object({city: z.string().nullable().optional(), country: z.string().nullable().optional(), raw: z.string().nullable().optional(), state: z.string().nullable().optional(), street_1: z.string().nullable().optional(), street_2: z.string().nullable().optional(), zip_code: z.string().nullable().optional()}).nullable().optional(), bank_accounts: z.array(z.object({iban: z.string().nullable().optional(), bic: z.string().nullable().optional(), account_number: z.string().nullable().optional(), holder_name: z.string().nullable().optional(), bank_name: z.string().nullable().optional(), domestic_bank_routing: z.object({number: z.string(), type: z.enum(["GB_SORT_CODE", "DE_BANKLEITZAHL", "US_ABA_ROUTING_TRANSIT_NUMBER", "CA_ROUTING_NUMBER", "AU_BSB_CODE", "FR_RIB", "SG_BANK_BRANCH_CODE"]).nullable()}).nullable().optional()})).nullable().optional(), date_of_birth: z.string().nullable(), start_date: z.string().nullable(), termination_date: z.string().nullable(), remote_created_at: z.string().nullable(), changed_at: z.string(), remote_deleted_at: z.string().nullable(), custom_fields: z.record(z.string(), z.unknown()).nullable(), integration_fields: z.array(z.object({id: z.string(), key: z.string(), type: z.enum(["DEFAULT", "CUSTOM"]), value: z.unknown(), label: z.string().nullable()})), remote_data: z.record(z.string(), z.unknown()).nullable()}), warnings: z.array(z.object({message: z.string()}))}); 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 }; /** * [DEPRECATED] Create employee * * POST /hris/employees */ export const createApiHrisEmployees = async (args: CreateApiHrisEmployeesArgs, options?: CreateApiHrisEmployeesOptions) => { const {baseUrl = "https://api.kombo.dev/v1", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['X-Integration-Id'] != null) headers.set("X-Integration-Id", String(args['X-Integration-Id'])) if (ApiKey !== undefined) headers.set('authorization', `Bearer ${ApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/hris/employees${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(postHrisEmployeesPositiveResponse, await res.json()) };