import {z} from 'zod' export type Award = {entity?: (string | null) | undefined, date: string, allText?: (string | null) | undefined, skills?: (Array | null) | undefined, description?: (string | null) | undefined, title: string}; export type ExperienceSchema = {industry?: (string | null) | undefined, endTime: number | null, durationMonths?: (number | null) | undefined, isInternal: boolean | null, addlJson?: (Record | null) | undefined, department?: (string | null) | undefined, work: string | null, userVerifiedSkills?: (boolean | null) | undefined, experienceKey?: (string | null) | undefined, skills?: Array | undefined, location: string | null, startTime: number | null, edited: boolean | null, isCurrent: boolean | null, description: string | null, title: string | null}; export type EmployeeEmploymentDate = {date?: (string | null) | undefined, type: 'original_hire' | 'continuous_service' | 'internal_transfer' | 'probation_end' | 'employment_confirmation' | 'last_working_day' | 'resignation'}; export type EmployeeLanguageProficiency = {read?: (string | null) | undefined, speak?: (string | null) | undefined, overall?: (string | null) | undefined, language?: (string | null) | undefined, write?: (string | null) | undefined}; export type EmployeeExternalSystemId = {type: 'paylocity' | 'greythr', value?: (string | null) | undefined}; export type EmployeeMobility = {comments?: (string | null) | undefined, travelPercentageMin?: (number | null) | undefined, relocationLocations?: (Array | null) | undefined, relocation?: (string | null) | undefined, travel?: (string | null) | undefined, travelPercentageMax?: (number | null) | undefined}; export type TemporalFieldValue = {endDate?: (number | null) | undefined, createTs: number | null, value: string | null, startDate: number}; export type TemporalField = {valueTimeline: Array, name: string}; export type RmUserGroup = {userGroupId?: (string | null) | undefined}; export type AdditionalManager = {capacityManagerEmail?: (string | null) | undefined, employeeId?: (string | null) | undefined, type?: (string | null) | undefined, email?: (string | null) | undefined}; export type EmployeeAssociatedRole = {roleVariantId?: (string | null) | undefined, roleVariantName?: (string | null) | undefined, updateAt?: (number | null) | undefined, primaryRoleId?: (string | null) | undefined, externalVariantId?: (string | null) | undefined, primaryRoleName?: (string | null) | undefined}; export type PhotoContent = {extension?: (string | null) | undefined, content?: (string | null) | undefined, isBase64?: (boolean | null) | undefined}; export type EmployeeBadge = {badgeId?: (string | null) | undefined, userId?: (string | null) | undefined, creator?: (string | null) | undefined, photoUrl?: (string | null) | undefined, lastModifiedTs?: (number | null) | undefined, photoContent?: (PhotoContent | null) | undefined, comment?: (string | null) | undefined, title?: (string | null) | undefined}; export type Pay = {frequency?: (string | null) | undefined, amount?: (number | null) | undefined, currency?: (string | null) | undefined}; export type CandidateEducation = {verificationStatus?: (string | null) | undefined, location: string | null, school: string | null, isCurrent?: (boolean | null) | undefined, isGraduated?: (boolean | null) | undefined, endTime: number | null, awards?: (Array | null) | undefined, source?: (string | null) | undefined, degree: string | null, startTime: number | null, verificationBy?: (string | null) | undefined, major: string | null, majorExternalId?: (string | null) | undefined, verificationTs?: (number | null) | undefined, degreeExternalId?: (string | null) | undefined, attachmentIds?: (Array | null) | undefined, schoolExternalId?: (string | null) | undefined, nameAlias?: (string | null) | undefined, description: string | null}; export type UserGroup = {userGroupId?: (string | null) | undefined}; export type User = {atsUserGroups?: (Array | null) | undefined, name?: (string | null) | undefined, atsRoles?: (Array | null) | undefined, userId?: (string | null) | undefined, firstName?: (string | null) | undefined, lastName?: (string | null) | undefined, email?: (string | null) | undefined}; export type EmployeeSuccessor = {employeeDetails?: (User | null) | undefined, readiness?: (string | null) | undefined, rank?: (number | null) | undefined, comments?: (string | null) | undefined}; export type EmployeeSuccessionPlanLinks = {comments?: (string | null) | undefined, successionPlanId?: (number | null) | undefined, planName?: (string | null) | undefined, successors?: (Array | null) | undefined, successorInPlanIds?: (Array | null) | undefined, planDate?: (string | null) | undefined}; export type Patent = {date: string, allText?: (string | null) | undefined, skills?: (Array | null) | undefined, description?: (string | null) | undefined, title: string}; export type CertificateSchema = {verificationStatus?: (string | null) | undefined, country?: (string | null) | undefined, skills?: (Array | null) | undefined, comments?: (string | null) | undefined, validFromDate?: (string | null) | undefined, date?: (string | null) | undefined, allText?: (Array | null) | undefined, source?: (string | null) | undefined, startDate?: (string | null) | undefined, validToDate?: (string | null) | undefined, certificateId?: (string | null) | undefined, state?: (string | null) | undefined, title: string | null, endDate?: (string | null) | undefined, verificationBy?: (string | null) | undefined, externalKey?: (string | null) | undefined, verificationTs?: (number | null) | undefined, status?: (string | null) | undefined, certificateType?: (string | null) | undefined, proficiency?: (string | null) | undefined, attachmentIds?: (Array | null) | undefined, certificateExternalId?: (string | null) | undefined, issuingAuthority?: (string | null) | undefined, description?: (string | null) | undefined}; export type SkillAssessmentMetadata = {last_manager_assessment_by?: (number | null) | undefined, last_manager_assessment_ts?: (number | null) | undefined, last_self_assessment_by?: (number | null) | undefined, last_self_assessment_ts?: (number | null) | undefined}; export type AtsAttachmentApplicationMetadataSchema = {applicationId: string}; export type AtsAttachmentSchema = {isBase64?: (boolean | null) | undefined, fileName: string, lastModifiedTs?: (number | null) | undefined, applicationMetadata?: (Array | null) | undefined, attachmentContent: string | null, attachmentId: string, attachmentType: string | null}; export type AtsEducationSchema = {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 AtsCertificationSchema = {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 AtsContent = {extension?: (string | null) | undefined, content?: (string | null) | undefined, isBase64?: (boolean | null) | undefined}; export type Jobs = {atsJobId?: (string | null) | undefined, name?: (string | null) | undefined}; export type AtsNoteSchema = {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 AtsApplicationSchema = {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?: (AtsNoteSchema | 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 AtsExperienceSchema = {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 Publication = {date?: (string | null) | undefined, skills?: (Array | null) | undefined, publisher?: (string | null) | undefined, description: string, title?: (string | null) | undefined}; export type AtsProjectSchema = {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 EmployeeCandidateData = {locationCountry?: (string | null) | undefined, skills?: (Array | null) | undefined, location?: (string | null) | undefined, address?: (string | null) | undefined, attachments?: (Array | null) | undefined, education?: (Array | null) | undefined, awards?: (Array | null) | undefined, customInfo?: (Record | null) | undefined, courseAttendance?: (Array | null) | undefined, candidateId?: (string | null) | undefined, urls?: (Array | null) | undefined, tags?: (Array | null) | undefined, displayTags?: (Array | null) | undefined, patents?: (Array | null) | undefined, certifications?: (Array | null) | undefined, summary?: (string | null) | undefined, photoContent?: (AtsContent | null) | undefined, applications?: (Array | null) | undefined, experience?: (Array | null) | undefined, races?: (Array | null) | undefined, publications?: (Array | null) | undefined, dateOfBirth?: (string | null) | undefined, project?: (Array | null) | undefined, gender?: (string | null) | undefined, skillDetails?: (Array | null) | undefined}; export type EmployeeCriticality = {riskOfLoss?: (string | null) | undefined, impactOfLoss?: (string | null) | undefined}; export type EmployeePerformanceRating = {periodEndDate?: (string | null) | undefined, rating?: (number | null) | undefined, reviewedBy?: (User | null) | undefined, ratingLabel?: (string | null) | undefined, reviewComments?: (string | null) | undefined, periodStartDate?: (string | null) | undefined, reviewType?: (string | null) | undefined}; export type ProjectFeedback = {imageUrl: string | null, rating: string | null, name: string | null, projectId: number | null, timestamp: number | null, profileId: number | null, comment: string | null}; export type Project = {addlJson?: (Record | null) | undefined, projectId: string, duration: number, links?: (Array | null) | undefined, personal_description?: (string | null) | undefined, skills: Array, time: string, feedback?: (Array | null) | undefined, company: string | null, contributors: Array | null, description?: (string | null) | undefined, title: string}; export type ProfileSkillEvaluation = {skillSubGroup?: (string | null) | undefined, level?: (number | null) | undefined, proficiency?: (string | null) | undefined, skillGroup?: (string | null) | undefined, skillGroupDescription?: (string | null) | undefined, source?: (string | null) | undefined, skillCategoryDescription?: (string | null) | undefined, assessmentProvider?: (string | null) | undefined, skillCategory?: (string | null) | undefined}; export type Source1 = {entityId?: (string | null) | undefined, name?: (string | null) | undefined}; export type ProfileSkillSchema = {displayName?: (string | null) | undefined, evaluations?: (Array | null) | undefined, source?: (Source1 | null) | undefined, name?: (string | null) | undefined}; export type EmployeeSchema = {managerEmail?: (string | null) | undefined, location?: (string | null) | undefined, awards?: (Array | null) | undefined, experiences?: (Array | null) | undefined, customInfo?: (Record | null) | undefined, employmentDates?: (Array | null) | undefined, systemId?: (string | null) | undefined, languages?: (Array | null) | undefined, pronouns?: (string | null) | undefined, externalSystemIds?: (Array | null) | undefined, terminationRegrettable?: (string | null) | undefined, lastActivityTs?: (number | null) | undefined, terminationTs?: (number | null) | undefined, jobCode?: (string | null) | undefined, timezone?: (string | null) | undefined, preferredFirstName?: (string | null) | undefined, role?: (string | null) | undefined, workplaceModel?: (string | null) | undefined, personalEmail?: (string | null) | undefined, isContingent?: (boolean | null) | undefined, mobility?: (EmployeeMobility | null) | undefined, bu?: (string | null) | undefined, temporalFields?: Array | undefined, rmUserGroups?: (Array | null) | undefined, maritalStatus?: (string | null) | undefined, externalJobId?: (string | null) | undefined, additionalManagers?: (Array | null) | undefined, associatedRole?: (EmployeeAssociatedRole | null) | undefined, demandExperiences?: (Array | null) | undefined, companyName?: (string | null) | undefined, phone?: (string | null) | undefined, managerUserId?: (string | null) | undefined, eligibleForTransfer?: (boolean | null) | undefined, lastName?: (string | null) | undefined, employeeType?: (string | null) | undefined, middleName?: (string | null) | undefined, employmentStatus?: (string | null) | undefined, badges?: (Array | null) | undefined, firstName?: (string | null) | undefined, basePay?: (Pay | null) | undefined, education?: (Array | null) | undefined, userId?: (string | null) | undefined, businessEmail?: (string | null) | undefined, lastReviewRating?: (string | null) | undefined, employmentBasis?: (string | null) | undefined, lastUpdatedTs?: (number | null) | undefined, successionPlan?: (EmployeeSuccessionPlanLinks | null) | undefined, patents?: (Array | null) | undefined, bonus?: (Pay | null) | undefined, managerFullname?: (string | null) | undefined, rehireEligibility?: (string | null) | undefined, userHighlightedSkills?: (Array | null) | undefined, certificates?: (Array | null) | undefined, locationCountry?: (string | null) | undefined, skillAssessmentMetadata?: (SkillAssessmentMetadata | null) | undefined, candidateData?: (EmployeeCandidateData | null) | undefined, positionCriticality?: (Array | null) | undefined, email: string, level?: (string | null) | undefined, terminationType?: (string | null) | undefined, employeeId: string, employeeCriticality?: (EmployeeCriticality | null) | undefined, performanceRatings?: (Array | null) | undefined, title?: (string | null) | undefined, id?: (string | null) | undefined, citizenship?: (Array | null) | undefined, preferredLastName?: (string | null) | undefined, managerContactEmail?: (string | null) | undefined, hiringTs?: (number | null) | undefined, projects?: (Array | null) | undefined, roleChangeTs?: (number | null) | undefined, publications?: (Array | null) | undefined, shift?: (string | null) | undefined, lob?: (string | null) | undefined, skillDetails?: (Array | null) | undefined, salutation?: (string | null) | undefined}; export type CreateApiApiV2CoreEmployeesArgs = {Authorization: string, body: EmployeeSchema}; export type CreateApiApiV2CoreEmployeesOptions = {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 Employee * * POST /api/v2/core/employees */ export const createApiApiV2CoreEmployees = async (args: CreateApiApiV2CoreEmployeesArgs, options?: CreateApiApiV2CoreEmployeesOptions) => { 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/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(profileAsyncSchema, await res.json()) };