import {z} from 'zod' export type GetHrisEmployeesFormParameterStaffingEntityId = string; export type GetApiHrisEmployeesFormArgs = {'X-Integration-Id': string, staffing_entity_id?: GetHrisEmployeesFormParameterStaffingEntityId | undefined}; export type GetApiHrisEmployeesFormOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const schema2: z.ZodType = z.discriminatedUnion("type", [z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("text"), min_length: z.number().nullable().optional(), max_length: z.number().nullable().optional(), reg_exp: z.string().nullable().optional()}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("number"), min: z.number().nullable().optional(), max: z.number().nullable().optional()}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("date")}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("single_select"), options: z.discriminatedUnion("type", [z.object({type: z.literal("inline"), entries: z.array(z.object({id: z.string(), label: z.string(), unified_value: z.string().optional(), remote_id: z.union([z.string(), z.number()])}))}), z.object({type: z.literal("referenced"), link: z.string()})])}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.string().nullable().optional(), type: z.literal("multi_select"), min_items: z.number().nullable().optional(), max_items: z.number().nullable().optional(), options: z.discriminatedUnion("type", [z.object({type: z.literal("inline"), entries: z.array(z.object({id: z.string(), label: z.string(), unified_value: z.string().optional(), remote_id: z.union([z.string(), z.number()])}))}), z.object({type: z.literal("referenced"), link: z.string()})])}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("checkbox")}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("object"), properties: z.lazy(() => schema1)}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("array"), item_type: z.lazy(() => schema2), min_items: z.number().nullable().optional(), max_items: z.number().nullable().optional()}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("file"), file_restrictions: z.object({accepted_mime_types: z.array(z.string()), max_file_size: z.number().nullable().optional()})})]); export const schema1: z.ZodType = z.record(z.string(), z.discriminatedUnion("type", [z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("text"), min_length: z.number().nullable().optional(), max_length: z.number().nullable().optional(), reg_exp: z.string().nullable().optional()}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("number"), min: z.number().nullable().optional(), max: z.number().nullable().optional()}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("date")}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("single_select"), options: z.discriminatedUnion("type", [z.object({type: z.literal("inline"), entries: z.array(z.object({id: z.string(), label: z.string(), unified_value: z.string().optional(), remote_id: z.union([z.string(), z.number()])}))}), z.object({type: z.literal("referenced"), link: z.string()})])}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.string().nullable().optional(), type: z.literal("multi_select"), min_items: z.number().nullable().optional(), max_items: z.number().nullable().optional(), options: z.discriminatedUnion("type", [z.object({type: z.literal("inline"), entries: z.array(z.object({id: z.string(), label: z.string(), unified_value: z.string().optional(), remote_id: z.union([z.string(), z.number()])}))}), z.object({type: z.literal("referenced"), link: z.string()})])}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("checkbox")}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("object"), properties: z.lazy(() => schema1)}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("array"), item_type: schema2, min_items: z.number().nullable().optional(), max_items: z.number().nullable().optional()}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("file"), file_restrictions: z.object({accepted_mime_types: z.array(z.string()), max_file_size: z.number().nullable().optional()})})])); export const getHrisEmployeesFormPositiveResponse = z.object({status: z.literal("success"), data: z.object({properties: z.record(z.string(), z.discriminatedUnion("type", [z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("text"), min_length: z.number().nullable().optional(), max_length: z.number().nullable().optional(), reg_exp: z.string().nullable().optional()}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("number"), min: z.number().nullable().optional(), max: z.number().nullable().optional()}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("date")}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("single_select"), options: z.discriminatedUnion("type", [z.object({type: z.literal("inline"), entries: z.array(z.object({id: z.string(), label: z.string(), unified_value: z.string().optional(), remote_id: z.union([z.string(), z.number()])}))}), z.object({type: z.literal("referenced"), link: z.string()})])}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.string().nullable().optional(), type: z.literal("multi_select"), min_items: z.number().nullable().optional(), max_items: z.number().nullable().optional(), options: z.discriminatedUnion("type", [z.object({type: z.literal("inline"), entries: z.array(z.object({id: z.string(), label: z.string(), unified_value: z.string().optional(), remote_id: z.union([z.string(), z.number()])}))}), z.object({type: z.literal("referenced"), link: z.string()})])}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("checkbox")}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("object"), properties: schema1}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("array"), item_type: schema2, min_items: z.number().nullable().optional(), max_items: z.number().nullable().optional()}), z.object({label: z.string(), required: z.boolean(), description: z.string().nullable().optional(), unified_key: z.enum(["first_name", "last_name", "date_of_birth", "gender", "home_address.city", "home_address.country", "home_address.state", "home_address.street_1", "home_address.street_2", "home_address.zip_code", "job_title", "legal_entity_id", "location_id", "mobile_phone_number", "home_phone_number", "nationality", "start_date", "work_email", "private_email", "yearly_salary"]).nullable().optional(), type: z.literal("file"), file_restrictions: z.object({accepted_mime_types: z.array(z.string()), max_file_size: z.number().nullable().optional()})})]))}), 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 }; /** * Get employee form * * GET /hris/employees/form */ export const getApiHrisEmployeesForm = async (args: GetApiHrisEmployeesFormArgs, options?: GetApiHrisEmployeesFormOptions) => { const {baseUrl = "https://api.kombo.dev/v1", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['X-Integration-Id'] != null) headers.set("X-Integration-Id", String(args['X-Integration-Id'])) if (args.staffing_entity_id != null) query.append("staffing_entity_id", String(args.staffing_entity_id)) if (ApiKey !== undefined) headers.set('authorization', `Bearer ${ApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/hris/employees/form${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getHrisEmployeesFormPositiveResponse, await res.json()) };