import {z} from 'zod' export type GetHrisSkillProficiencyRatingsParameterCursor = string; export type GetHrisSkillProficiencyRatingsParameterPageSize = number; export type GetHrisSkillProficiencyRatingsParameterUpdatedAfter = string; export type GetHrisSkillProficiencyRatingsParameterIncludeDeleted = 'true' | 'false'; export type GetHrisSkillProficiencyRatingsParameterIgnoreUnsupportedFilters = 'true' | 'false'; export type GetHrisSkillProficiencyRatingsParameterIds = string; export type GetHrisSkillProficiencyRatingsParameterRemoteIds = string; export type GetHrisSkillProficiencyRatingsParameterEmployeeIds = string; export type GetHrisSkillProficiencyRatingsParameterSkillIds = string; export type GetApiHrisSkillProficiencyRatingsArgs = {'X-Integration-Id': string, cursor?: GetHrisSkillProficiencyRatingsParameterCursor | undefined, page_size?: GetHrisSkillProficiencyRatingsParameterPageSize | undefined, updated_after?: GetHrisSkillProficiencyRatingsParameterUpdatedAfter | undefined, include_deleted?: GetHrisSkillProficiencyRatingsParameterIncludeDeleted | undefined, ignore_unsupported_filters?: GetHrisSkillProficiencyRatingsParameterIgnoreUnsupportedFilters | undefined, ids?: GetHrisSkillProficiencyRatingsParameterIds | undefined, remote_ids?: GetHrisSkillProficiencyRatingsParameterRemoteIds | undefined, employee_ids?: GetHrisSkillProficiencyRatingsParameterEmployeeIds | undefined, skill_ids?: GetHrisSkillProficiencyRatingsParameterSkillIds | undefined}; export type GetApiHrisSkillProficiencyRatingsOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const getHrisSkillProficiencyRatingsPositiveResponse = z.object({status: z.literal("success"), data: z.object({next: z.string().nullable(), results: z.array(z.discriminatedUnion("rating_source", [z.object({id: z.string(), remote_id: z.string(), employee_id: z.string(), skill_id: z.string(), proficiency: z.discriminatedUnion("type", [z.object({type: z.literal("NUMERIC"), value: z.number()}), z.object({type: z.literal("SINGLE_SELECT"), selected_option_id: z.string()})]).nullable().optional(), changed_at: z.string(), remote_deleted_at: z.string().nullable(), remote_data: z.record(z.string(), z.unknown()).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()})), employee: z.object({id: z.string(), remote_id: z.string(), first_name: z.string().nullable(), last_name: z.string().nullable(), display_full_name: z.string().nullable(), work_email: z.string().nullable().optional(), remote_deleted_at: z.string().nullable()}), skill: z.object({id: z.string(), remote_id: z.string(), name: z.string().nullable(), proficiency_scale: z.discriminatedUnion("type", [z.object({id: z.string(), remote_id: z.string(), type: z.literal("NUMERIC"), min: z.number().nullable(), max: z.number().nullable(), step: z.number().nullable()}), z.object({id: z.string(), remote_id: z.string(), type: z.literal("SINGLE_SELECT"), ordered_options: z.array(z.object({id: z.string(), remote_id: z.string().nullable(), name: z.string()}))})]).nullable()}), rating_source: z.literal("EXTERNAL"), rating_provider_id: z.string().nullable(), rating_provider: z.object({id: z.string(), remote_id: z.string(), name: z.string().nullable()}).nullable()}), z.object({id: z.string(), remote_id: z.string(), employee_id: z.string(), skill_id: z.string(), proficiency: z.discriminatedUnion("type", [z.object({type: z.literal("NUMERIC"), value: z.number()}), z.object({type: z.literal("SINGLE_SELECT"), selected_option_id: z.string()})]).nullable().optional(), changed_at: z.string(), remote_deleted_at: z.string().nullable(), remote_data: z.record(z.string(), z.unknown()).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()})), employee: z.object({id: z.string(), remote_id: z.string(), first_name: z.string().nullable(), last_name: z.string().nullable(), display_full_name: z.string().nullable(), work_email: z.string().nullable().optional(), remote_deleted_at: z.string().nullable()}), skill: z.object({id: z.string(), remote_id: z.string(), name: z.string().nullable(), proficiency_scale: z.discriminatedUnion("type", [z.object({id: z.string(), remote_id: z.string(), type: z.literal("NUMERIC"), min: z.number().nullable(), max: z.number().nullable(), step: z.number().nullable()}), z.object({id: z.string(), remote_id: z.string(), type: z.literal("SINGLE_SELECT"), ordered_options: z.array(z.object({id: z.string(), remote_id: z.string().nullable(), name: z.string()}))})]).nullable()}), rating_source: z.literal("SELF")}), z.object({id: z.string(), remote_id: z.string(), employee_id: z.string(), skill_id: z.string(), proficiency: z.discriminatedUnion("type", [z.object({type: z.literal("NUMERIC"), value: z.number()}), z.object({type: z.literal("SINGLE_SELECT"), selected_option_id: z.string()})]).nullable().optional(), changed_at: z.string(), remote_deleted_at: z.string().nullable(), remote_data: z.record(z.string(), z.unknown()).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()})), employee: z.object({id: z.string(), remote_id: z.string(), first_name: z.string().nullable(), last_name: z.string().nullable(), display_full_name: z.string().nullable(), work_email: z.string().nullable().optional(), remote_deleted_at: z.string().nullable()}), skill: z.object({id: z.string(), remote_id: z.string(), name: z.string().nullable(), proficiency_scale: z.discriminatedUnion("type", [z.object({id: z.string(), remote_id: z.string(), type: z.literal("NUMERIC"), min: z.number().nullable(), max: z.number().nullable(), step: z.number().nullable()}), z.object({id: z.string(), remote_id: z.string(), type: z.literal("SINGLE_SELECT"), ordered_options: z.array(z.object({id: z.string(), remote_id: z.string().nullable(), name: z.string()}))})]).nullable()}), rating_source: z.literal("MANAGER")}), z.object({id: z.string(), remote_id: z.string(), employee_id: z.string(), skill_id: z.string(), proficiency: z.discriminatedUnion("type", [z.object({type: z.literal("NUMERIC"), value: z.number()}), z.object({type: z.literal("SINGLE_SELECT"), selected_option_id: z.string()})]).nullable().optional(), changed_at: z.string(), remote_deleted_at: z.string().nullable(), remote_data: z.record(z.string(), z.unknown()).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()})), employee: z.object({id: z.string(), remote_id: z.string(), first_name: z.string().nullable(), last_name: z.string().nullable(), display_full_name: z.string().nullable(), work_email: z.string().nullable().optional(), remote_deleted_at: z.string().nullable()}), skill: z.object({id: z.string(), remote_id: z.string(), name: z.string().nullable(), proficiency_scale: z.discriminatedUnion("type", [z.object({id: z.string(), remote_id: z.string(), type: z.literal("NUMERIC"), min: z.number().nullable(), max: z.number().nullable(), step: z.number().nullable()}), z.object({id: z.string(), remote_id: z.string(), type: z.literal("SINGLE_SELECT"), ordered_options: z.array(z.object({id: z.string(), remote_id: z.string().nullable(), name: z.string()}))})]).nullable()}), rating_source: z.literal("EXPECTED")}), z.object({id: z.string(), remote_id: z.string(), employee_id: z.string(), skill_id: z.string(), proficiency: z.discriminatedUnion("type", [z.object({type: z.literal("NUMERIC"), value: z.number()}), z.object({type: z.literal("SINGLE_SELECT"), selected_option_id: z.string()})]).nullable().optional(), changed_at: z.string(), remote_deleted_at: z.string().nullable(), remote_data: z.record(z.string(), z.unknown()).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()})), employee: z.object({id: z.string(), remote_id: z.string(), first_name: z.string().nullable(), last_name: z.string().nullable(), display_full_name: z.string().nullable(), work_email: z.string().nullable().optional(), remote_deleted_at: z.string().nullable()}), skill: z.object({id: z.string(), remote_id: z.string(), name: z.string().nullable(), proficiency_scale: z.discriminatedUnion("type", [z.object({id: z.string(), remote_id: z.string(), type: z.literal("NUMERIC"), min: z.number().nullable(), max: z.number().nullable(), step: z.number().nullable()}), z.object({id: z.string(), remote_id: z.string(), type: z.literal("SINGLE_SELECT"), ordered_options: z.array(z.object({id: z.string(), remote_id: z.string().nullable(), name: z.string()}))})]).nullable()}), rating_source: z.unknown()})]))})}); 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 skill proficiency ratings * * GET /hris/skill-proficiency-ratings */ export const getApiHrisSkillProficiencyRatings = async (args: GetApiHrisSkillProficiencyRatingsArgs, options?: GetApiHrisSkillProficiencyRatingsOptions) => { 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.cursor != null) query.append("cursor", String(args.cursor)) if (args.page_size != null) query.append("page_size", String(args.page_size)) if (args.updated_after != null) query.append("updated_after", String(args.updated_after)) if (args.include_deleted != null) query.append("include_deleted", String(args.include_deleted)) if (args.ignore_unsupported_filters != null) query.append("ignore_unsupported_filters", String(args.ignore_unsupported_filters)) if (args.ids != null) query.append("ids", String(args.ids)) if (args.remote_ids != null) query.append("remote_ids", String(args.remote_ids)) if (args.employee_ids != null) query.append("employee_ids", String(args.employee_ids)) if (args.skill_ids != null) query.append("skill_ids", String(args.skill_ids)) if (ApiKey !== undefined) headers.set('authorization', `Bearer ${ApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/hris/skill-proficiency-ratings${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(getHrisSkillProficiencyRatingsPositiveResponse, await res.json()) };