import {z} from 'zod' export type ATSScheduledInterview = {organizer?: (string | null) | undefined, status?: (string | null) | undefined, endTs?: (number | null) | undefined, interviewType?: (string | null) | undefined, interviewers?: (Array | null) | undefined, startTs?: (number | null) | undefined, location?: (string | null) | undefined, comment?: (string | null) | undefined, referenceId?: (string | null) | undefined}; export type AtsTag = {tag: string | null, jobId?: (string | null) | undefined, creator?: (string | null) | undefined, tagSubtype?: (string | null) | undefined, tagType?: (string | null) | undefined, creationTs?: (number | null) | undefined}; export type AtsAttachmentApplicationMetadata = {applicationId: string}; export type AtsAttachment = {isBase64?: (boolean | null) | undefined, fileName: string, lastModifiedTs?: (number | null) | undefined, applicationMetadata?: (Array | null) | undefined, attachmentContent: string | null, attachmentId: string, attachmentType: string | null}; export type AtsContent = {extension?: (string | null) | undefined, content?: (string | null) | undefined, isBase64?: (boolean | null) | undefined}; export type AtsEducation = {endTs?: (number | null) | undefined, verificationStatus?: (string | null) | undefined, degreeExternalId?: (string | null) | undefined, attachmentIds?: (Array | null) | undefined, startTs: number | null, degree: string | null, major: string | null, verificationBy?: (string | null) | undefined, location: string | null, isCurrent?: (boolean | null) | undefined, schoolExternalId?: (string | null) | undefined, majorExternalId?: (string | null) | undefined, verificationTs?: (number | null) | undefined, school: string | null, nameAlias?: (string | null) | undefined, isGraduated?: (boolean | null) | undefined, description: string | null}; export type LmsCourseAttendance = {durationHours?: (number | null) | undefined, percentageCompletion?: (number | null) | undefined, isInternal?: (boolean | null) | undefined, pointsEarned?: (number | null) | undefined, courseType?: (string | null) | undefined, difficulty?: (string | null) | undefined, courseUrl?: (string | null) | undefined, title?: (string | null) | undefined, completionTs?: (number | null) | undefined, lmsCourseId?: (string | null) | undefined, medium?: (string | null) | undefined, language?: (string | null) | undefined, dueTs?: (number | null) | undefined, assignedBy?: (string | null) | undefined, status?: (string | null) | undefined, startTs?: (number | null) | undefined, isMandatory?: (boolean | null) | undefined, provider?: (string | null) | undefined, verified?: (string | null) | undefined, description?: (string | null) | undefined}; export type AtsCertification = {locationCountry?: (string | null) | undefined, verificationStatus?: (string | null) | undefined, licenseNo?: (string | null) | undefined, skills?: (Array | null) | undefined, validFromTs?: (number | null) | undefined, comments?: (string | null) | undefined, allText?: (string | null) | undefined, endTs?: (number | null) | undefined, verificationBy?: (string | null) | undefined, certificateName: string | null, verificationTs?: (number | null) | undefined, status?: (string | null) | undefined, certificateType?: (string | null) | undefined, proficiency?: (string | null) | undefined, validToTs?: (number | null) | undefined, attachmentIds?: (Array | null) | undefined, startTs?: (number | null) | undefined, certificateExternalId?: (string | null) | undefined, locationState?: (string | null) | undefined, issuingAuthority?: (string | null) | undefined, description?: (string | null) | undefined}; export type Jobs = {atsJobId?: (string | null) | undefined, name?: (string | null) | undefined}; export type AtsNote = {subject?: (string | null) | undefined, to?: (string | null) | undefined, noteType?: (string | null) | undefined, visibility?: (string | null) | undefined, creator?: (string | null) | undefined, cc?: (Array | null) | undefined, body?: (string | null) | undefined, sender?: (string | null) | undefined, creationTs?: (number | null) | undefined}; export type AtsUser = {userId?: (string | null) | undefined, email?: (string | null) | undefined, name?: (string | null) | undefined, atsRoles?: (Array | null) | undefined}; export type AtsStage = {stage?: (string | null) | undefined, user: AtsUser, reason: string, wfSubStage: string, wfStage: string, stageTs: number}; export type ATSScoreCardAttribute = {rating?: (string | null) | undefined, answer?: (string | null) | undefined, note?: (string | null) | undefined, question?: (string | null) | undefined, rating_label?: (string | null) | undefined}; export type AtsScorecard = {overallRatingLabel?: (string | null) | undefined, overallRating?: (string | null) | undefined, submittedBy?: (AtsUser | null) | undefined, submittedAt?: (number | null) | undefined, interviewedAt?: (number | null) | undefined, attributes?: (Array | null) | undefined, description?: (string | null) | undefined, interviewName?: (string | null) | undefined}; export type AtsQuestionAnswer = {formName?: (string | null) | undefined, choices?: (Array | null) | undefined, explanation?: (string | null) | undefined, answer?: (Array | null) | undefined, formType?: (string | null) | undefined, questionId: string, displayOrder?: (string | null) | undefined, formId?: (string | null) | undefined, type?: (string | null) | undefined, question?: (string | null) | undefined}; export type AtsApplication = {locationCountry?: (string | null) | undefined, reason?: (string | null) | undefined, location?: (string | null) | undefined, visaStatuses?: (Array | null) | undefined, veteranStatusStr?: (string | null) | undefined, jobs?: (Array | null) | undefined, hiredTs?: (number | null) | undefined, lastModifiedTs: number | null, customInfo?: (Record | null) | undefined, note?: (AtsNote | null) | undefined, systemId?: (string | null) | undefined, creditor?: (string | null) | undefined, candidateId: string | null, rejectedTs?: (number | null) | undefined, veteranStatus?: (boolean | null) | undefined, applicationTs: number | null, pastStages?: (Array | null) | undefined, sourceName?: (string | null) | undefined, isProspect?: (boolean | null) | undefined, scorecards?: (Array | null) | undefined, jobSystemId?: (string | null) | undefined, disabilityStatus?: (boolean | null) | undefined, currentStage?: (AtsStage | null) | undefined, status?: (string | null) | undefined, races?: (Array | null) | undefined, sourceType?: (string | null) | undefined, gender?: (string | null) | undefined, questions?: (Array | null) | undefined, rejectedBy?: (string | null) | undefined, disabilityStatusStr?: (string | null) | undefined, applicationId: string}; export type AtsExperience = {endTs?: (number | null) | undefined, industry?: (string | null) | undefined, isInternal: boolean | null, department?: (string | null) | undefined, startTs: number | null, location: string | null, company: string | null, isCurrent: boolean | null, description?: (string | null) | undefined, title: string | null}; export type AtsProject = {endTs?: (number | null) | undefined, links?: (Array | null) | undefined, startTs: number | null, skills?: (Array | null) | undefined, company: string | null, contributors?: (Array | null) | undefined, description?: (string | null) | undefined, title: string | null}; export type ATSSkillGroup = {proficiency?: (string | null) | undefined, skillGroup?: (string | null) | undefined}; export type ATSSkillDetail = {skillGroups?: (Array | null) | undefined, proficiency?: (string | null) | undefined, evaluationTimestamp?: (number | null) | undefined, dataSource?: (string | null) | undefined, skill?: (string | null) | undefined}; export type CreateATSProfileSchema = {locationCountry?: (string | null) | undefined, contactConsent?: (string | null) | undefined, isAnonymized?: (boolean | null) | undefined, scheduledInterviews?: (Array | null) | undefined, skills?: (Array | null) | undefined, location?: (string | null) | undefined, address?: (string | null) | undefined, firstName: string, emails: string | null, detailTags?: (Array | null) | undefined, attachments?: (Array | null) | undefined, resumeContent?: (AtsContent | null) | undefined, visaStatuses?: (Array | null) | undefined, veteranStatusStr?: (string | null) | undefined, education?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, customInfo?: (Record | null) | undefined, autoGenerateCandidateId?: (boolean | null) | undefined, courseAttendance?: (Array | null) | undefined, systemId?: (string | null) | undefined, urls?: (Array | null) | undefined, candidateId?: (string | null) | undefined, title?: (string | null) | undefined, displayTags?: (Array | null) | undefined, tags?: (Array | null) | undefined, veteranStatus?: (boolean | null) | undefined, highestEducationLevel?: (string | null) | undefined, certifications?: (Array | null) | undefined, lastActivityTs: number | null, summary?: (string | null) | undefined, photoContent?: (AtsContent | null) | undefined, applications?: (Array | null) | undefined, disabilityStatus?: (boolean | null) | undefined, phones?: (string | null) | undefined, experience?: (Array | null) | undefined, races?: (Array | null) | undefined, dateOfBirth?: (string | null) | undefined, project?: (Array | null) | undefined, notes?: (Array | null) | undefined, gender?: (string | null) | undefined, questions?: (Array | null) | undefined, skillDetails?: (Array | null) | undefined, disabilityStatusStr?: (string | null) | undefined, lastName?: (string | null) | undefined}; export type CreateApiApiV2CoreAtsSystemsSystemIdAtsCandidatesArgs = {Authorization: string, systemId: string, body: CreateATSProfileSchema}; export type CreateApiApiV2CoreAtsSystemsSystemIdAtsCandidatesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const profileAsyncSchema = z.object({transactionId: z.string().nullable().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 }; /** * Create ATS Candidate * * POST /api/v2/core/ats-systems/{systemId}/ats-candidates */ export const createApiApiV2CoreAtsSystemsSystemIdAtsCandidates = async (args: CreateApiApiV2CoreAtsSystemsSystemIdAtsCandidatesArgs, options?: CreateApiApiV2CoreAtsSystemsSystemIdAtsCandidatesOptions) => { const {baseUrl = "https://apiv2.eightfold.ai", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/core/ats-systems/${encodeURIComponent(String(args.systemId))}/ats-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(profileAsyncSchema, await res.json()) };