import {z} from 'zod' export type CreateCandidateEmailDto = {email: string, purpose: 'personal' | 'work' | null, isPrimary?: boolean | undefined}; export type CreateCandidatePhoneNumberDto = {phoneNumber: string, purpose: 'personal' | 'work' | null, isPrimary?: boolean | undefined}; export type LocationType = 'primary_home' | 'secondary_home' | 'primary_work' | 'headquarters' | 'regional_office'; export type CreateLocationDto = {street1: string | null, street2: string | null, postalCode: string | null, city: string | null, region: string | null, state: string | null, country: string | null, latitude?: (number | null) | undefined, longitude?: (number | null) | undefined, type: LocationType | null}; export type DateISO = string; export type CandidateCompanyCreateDto = {name: string, linkedInId?: string | undefined, domain?: string | undefined}; export type CreateCandidateEducationRequestDto = {degree: 'High School' | 'Certificate' | 'Diploma' | 'Associate' | 'Professional' | 'Vocational' | 'Bachelor' | 'Master' | 'Postgraduate Diploma' | 'MBA' | 'LLM' | 'PhD' | 'Postdoctoral' | null, fieldOfStudy: string | null, grade: string | null, description: string | null, startDate: DateISO | null, endDate: DateISO | null, companyId: string} | {degree: 'High School' | 'Certificate' | 'Diploma' | 'Associate' | 'Professional' | 'Vocational' | 'Bachelor' | 'Master' | 'Postgraduate Diploma' | 'MBA' | 'LLM' | 'PhD' | 'Postdoctoral' | null, fieldOfStudy: string | null, grade: string | null, description: string | null, startDate: DateISO | null, endDate: DateISO | null, company: CandidateCompanyCreateDto}; export type LocationDto = {street1: string | null, street2: string | null, postalCode: string | null, city: string | null, region: string | null, state: string | null, country: string | null, rawCityCountry: string | null, latitude: number | null, longitude: number | null, formattedAddress: string | null, type: LocationType | null}; export type CreateCandidateWorkExperienceRequestDto = {jobTitle: string, location: LocationDto | null, description: string | null, startDate: DateISO | null, endDate: DateISO | null, companyId: string} | {jobTitle: string, location: LocationDto | null, description: string | null, startDate: DateISO | null, endDate: DateISO | null, company: CandidateCompanyCreateDto}; export type CreateCandidateCertificationDto = {name: string, url: string | null, issueDate: DateISO | null, expirationDate: DateISO | null, companyId: string | null} | {name: string, url: string | null, issueDate: DateISO | null, expirationDate: DateISO | null, company: CandidateCompanyCreateDto}; export type DmCurrency = 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BRL' | 'BSD' | 'BTC' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHF' | 'CLF' | 'CLP' | 'CNH' | 'CNY' | 'COP' | 'CRC' | 'CUC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GGP' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HRK' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'IMP' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JEP' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLE' | 'SLL' | 'SOS' | 'SRD' | 'SSP' | 'STD' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'UYU' | 'UZS' | 'VEF' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XAG' | 'XAU' | 'XCD' | 'XCG' | 'XDR' | 'XOF' | 'XPD' | 'XPF' | 'XPT' | 'YER' | 'ZAR' | 'ZMW' | 'ZWG' | 'ZWL'; export type MonetaryAmountDto = {currency: DmCurrency, amount: number}; export type DateRangeDto = {startDate: DateISO, endDate: DateISO | null}; export type UserBadgeDto = {id: string, name: string, avatarUrl: string | null, deactivatedAt: DateISO | null}; export type SharedCustomAttributeTypeDto = {viewType: 'customText', text: string | null} | {viewType: 'customNumber', number: number | null} | {viewType: 'customCheckbox', checked: boolean | null} | {viewType: 'customDate', date: DateISO | null} | {viewType: 'customTimestamp', timestamp: DateISO | null} | {viewType: 'customRating', rating: number | null} | {viewType: 'customSelect', select: string | null} | {viewType: 'customMultiSelect', multiSelect: Array} | {viewType: 'customCurrency', monetaryAmount: MonetaryAmountDto | null} | {viewType: 'customDateRange', dateRange: DateRangeDto | null} | {viewType: 'customDuration', duration: number | null} | {viewType: 'customUrl', url: string | null} | {viewType: 'customEntity', type: 'user', id: string | null, entity?: (UserBadgeDto | null) | undefined} | {viewType: 'customMultiEntity', type: 'user', ids: Array, entities?: Array | undefined}; export type UpdateAttributeValueDto = {attributeDefinitionId: string, value: SharedCustomAttributeTypeDto}; export type CreateCandidateMainContactRequestDto = {userId: string}; export type CandidateLanguage = 'Afrikaans' | 'Albanian' | 'Amharic' | 'Arabic' | 'Armenian' | 'Assamese' | 'Aymara' | 'Azerbaijani' | 'Bangla' | 'Basque' | 'Belarusian' | 'Bemba' | 'Berber' | 'Bislama' | 'Bosnian' | 'Bulgarian' | 'Burman' | 'Catalan' | 'Chechen' | 'Chewa' | 'Chinese (Mandarin)' | 'Chinese (Cantonese)' | 'Chittagonian' | 'Croatian' | 'Czech' | 'Danish' | 'Dari' | 'Dhivehi' | 'Dutch' | 'Dzongkha' | 'English' | 'Estonian' | 'Ewe' | 'Fijian' | 'Filipino' | 'Finnish' | 'French' | 'Galician' | 'Georgian' | 'German' | 'Greek' | 'Guarani' | 'Gujarati' | 'Haitian Creole' | 'Hausa' | 'Hebrew' | 'Hindi' | 'Hungarian' | 'Icelandic' | 'Igbo' | 'Indonesian' | 'Irish' | 'Italian' | 'Japanese' | 'Kannada' | 'Kazakh' | 'Khmer' | 'Kinyarwanda' | 'Kirundi' | 'Korean' | 'Kurdish' | 'Kyrgyz' | 'Lao' | 'Latvian' | 'Lingala' | 'Lithuanian' | 'Luganda' | 'Luxembourgish' | 'Macedonian' | 'Malagasy' | 'Malay' | 'Malayalam' | 'Maltese' | 'Maori' | 'Marathi' | 'Moldovan' | 'Mongolian' | 'Montenegrin' | 'Ndebele' | 'Nepali' | 'Norwegian' | 'Odia' | 'Oromo' | 'Pashto' | 'Persian' | 'Polish' | 'Portuguese' | 'Punjabi' | 'Quechua' | 'Romanian' | 'Russian' | 'Samoan' | 'Sango' | 'Serbian' | 'Sesotho' | 'Setswana' | 'Shona' | 'Sindhi' | 'Sinhala' | 'Slovak' | 'Slovenian' | 'Somali' | 'Spanish' | 'Swahili' | 'Swedish' | 'Tajik' | 'Tamil' | 'Telugu' | 'Tetum' | 'Thai' | 'Tigrinya' | 'Tok Pisin' | 'Tongan' | 'Tsonga' | 'Tswana' | 'Turkish' | 'Turkmen' | 'Ukrainian' | 'Urdu' | 'Uzbek' | 'Venda' | 'Vietnamese' | 'Welsh' | 'Xhosa' | 'Yoruba' | 'Zulu'; export type CandidateFluency = 'Elementary proficiency' | 'Limited working proficiency' | 'Professional working proficiency' | 'Full professional proficiency' | 'Native or bilingual proficiency' | null; export type LanguageDto = {id?: string | undefined, language: CandidateLanguage, fluency?: CandidateFluency | undefined}; export type CandidateCurrency = 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BRL' | 'BSD' | 'BTC' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHF' | 'CLF' | 'CLP' | 'CNH' | 'CNY' | 'COP' | 'CRC' | 'CUC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GGP' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HRK' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'IMP' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JEP' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLE' | 'SLL' | 'SOS' | 'SRD' | 'SSP' | 'STD' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'UYU' | 'UZS' | 'VEF' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XAG' | 'XAU' | 'XCD' | 'XCG' | 'XDR' | 'XOF' | 'XPD' | 'XPF' | 'XPT' | 'YER' | 'ZAR' | 'ZMW' | 'ZWG' | 'ZWL'; export type CompensationDto = {id?: string | undefined, currency: CandidateCurrency, totalCompensation?: (number | null) | undefined, baseCompensation?: (number | null) | undefined}; export type CandidateSkillReferenceDto = {id: string}; export type CreateCandidateDto = {firstName: string, lastName: string, gender?: ('male' | 'female' | 'x' | null) | undefined, nationality?: (Array<'Afghan' | 'Albanian' | 'Algerian' | 'American' | 'Andorran' | 'Angolan' | 'Antiguan' | 'Argentinean' | 'Armenian' | 'Australian' | 'Austrian' | 'Azerbaijani' | 'Bahamian' | 'Bahraini' | 'Bangladeshi' | 'Barbadian' | 'Barbudan' | 'Batswana' | 'Belarusian' | 'Belgian' | 'Belizean' | 'Beninese' | 'Bhutanese' | 'Bolivian' | 'Bosnian' | 'Brazilian' | 'British' | 'Bruneian' | 'Bulgarian' | 'Burkinabe' | 'Burmese' | 'Burundian' | 'Cambodian' | 'Cameroonian' | 'Canadian' | 'Cape Verdean' | 'Central African' | 'Chadian' | 'Chilean' | 'Chinese' | 'Colombian' | 'Comoran' | 'Congolese' | 'Costa Rican' | 'Croatian' | 'Cuban' | 'Cypriot' | 'Czech' | 'Danish' | 'Djibouti' | 'Dominican' | 'Dutch' | 'East Timorese' | 'Ecuadorean' | 'Egyptian' | 'Emirian' | 'Equatorial Guinean' | 'Eritrean' | 'Estonian' | 'Ethiopian' | 'Fijian' | 'Filipino' | 'Finnish' | 'French' | 'Gabonese' | 'Gambian' | 'Georgian' | 'German' | 'Ghanaian' | 'Greek' | 'Grenadian' | 'Guatemalan' | 'Guinea-Bissauan' | 'Guinean' | 'Guyanese' | 'Haitian' | 'Herzegovinian' | 'Honduran' | 'Hungarian' | 'I-Kiribati' | 'Icelander' | 'Indian' | 'Indonesian' | 'Iranian' | 'Iraqi' | 'Irish' | 'Israeli' | 'Italian' | 'Ivorian' | 'Jamaican' | 'Japanese' | 'Jordanian' | 'Kazakhstani' | 'Kenyan' | 'Kittian and Nevisian' | 'Kuwaiti' | 'Kyrgyz' | 'Laotian' | 'Latvian' | 'Lebanese' | 'Liberian' | 'Libyan' | 'Liechtensteiner' | 'Lithuanian' | 'Luxembourger' | 'Macedonian' | 'Malagasy' | 'Malawian' | 'Malaysian' | 'Maldivian' | 'Malian' | 'Maltese' | 'Marshallese' | 'Mauritanian' | 'Mauritian' | 'Mexican' | 'Micronesian' | 'Moldovan' | 'Monacan' | 'Mongolian' | 'Moroccan' | 'Mosotho' | 'Motswana' | 'Mozambican' | 'Namibian' | 'Nauruan' | 'Nepalese' | 'New Zealander' | 'Ni-Vanuatu' | 'Nicaraguan' | 'Nigerian' | 'Nigerien' | 'North Korean' | 'Northern Irish' | 'Norwegian' | 'Omani' | 'Pakistani' | 'Palauan' | 'Panamanian' | 'Papua New Guinean' | 'Paraguayan' | 'Peruvian' | 'Polish' | 'Portuguese' | 'Qatari' | 'Romanian' | 'Russian' | 'Rwandan' | 'Saint Lucian' | 'Salvadoran' | 'Samoan' | 'San Marinese' | 'Sao Tomean' | 'Saudi' | 'Scottish' | 'Senegalese' | 'Serbian' | 'Seychellois' | 'Sierra Leonean' | 'Singaporean' | 'Slovakian' | 'Slovenian' | 'Solomon Islander' | 'Somali' | 'South African' | 'South Korean' | 'Spanish' | 'Sri Lankan' | 'Sudanese' | 'Surinamer' | 'Swazi' | 'Swedish' | 'Swiss' | 'Syrian' | 'Taiwanese' | 'Tajik' | 'Tanzanian' | 'Thai' | 'Togolese' | 'Tongan' | 'Trinidadian or Tobagonian' | 'Tunisian' | 'Turkish' | 'Tuvaluan' | 'Ugandan' | 'Ukrainian' | 'Uruguayan' | 'Uzbekistani' | 'Venezuelan' | 'Vietnamese' | 'Welsh' | 'Yemenite' | 'Zambian' | 'Zimbabwean'>) | undefined, status?: (Array<'actively_looking' | 'approachable_but_not_actively_looking' | 'do_not_contact' | 'do_not_poach' | 'not_actively_looking'>) | undefined, emails?: Array | undefined, phoneNumbers?: Array | undefined, locations?: Array | undefined, dateOfBirth?: (DateISO | null) | undefined, socialMedia?: (Array<{url: string, type: 'LINKEDIN' | 'TWITTER' | 'FACEBOOK' | 'INSTAGRAM', isPrimary?: boolean | undefined}>) | undefined, education?: Array | undefined, workExperiences?: Array | undefined, certifications?: Array | undefined, customAttributes?: Array | undefined, mainContact?: (CreateCandidateMainContactRequestDto | null) | undefined, languages?: Array | undefined, compensation?: (CompensationDto | null) | undefined, skills?: Array | undefined, acquisitionSource?: ('juicebox' | 'pin') | undefined}; export type CreateApiCandidatesArgs = {body: CreateCandidateDto}; export type CreateApiCandidatesOptions = {baseUrl: string, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiCandidatesResponse = 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 }; /** * Create a candidate * * POST /candidates */ export const createApiCandidates = async (args: CreateApiCandidatesArgs, options: CreateApiCandidatesOptions) => { const {baseUrl, fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/candidates${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(createApiCandidatesResponse, await res.json()) };