import {z} from 'zod' export type GetApiApiV2CareerhubCareerNavigatorRecommendedPathsUserEmailArgs = {Authorization: string, userEmail: string, exclude?: string | undefined, keyList?: string | undefined}; export type GetApiApiV2CareerhubCareerNavigatorRecommendedPathsUserEmailOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const careerNavigatorAssociatedEmployee = z.object({currentTitle: z.string().nullable().optional(), imageUrl: z.string().nullable().optional(), encId: z.string().nullable().optional(), name: z.string().nullable().optional()}); export const careerNavigatorRoleEmployee = z.object({associatedEmployeesCount: z.number().int().nullable().optional(), associatedEmployeesProfiles: z.array(careerNavigatorAssociatedEmployee).nullable().optional()}); export const careerNavigatorSkillData = z.object({requiredSkills: z.array(z.string()).nullable().optional(), roleSkills: z.array(z.string()).nullable().optional(), matchingSkills: z.array(z.string()).nullable().optional(), matchingRequiredSkills: z.array(z.string()).nullable().optional()}); export const careerNavigatorRole = z.object({entityId: z.number().int().nullable(), associatedEmployeesData: careerNavigatorRoleEmployee.nullable().optional(), isCareerInterest: z.boolean().nullable().optional(), encEntityId: z.string().nullable().optional(), highlights: z.array(z.string()).nullable().optional(), recommendedPositionsCount: z.number().int().nullable().optional(), title: z.string().nullable(), skillData: careerNavigatorSkillData.nullable().optional()}); export const careerNavigatorPath = z.object({pathHighlights: z.array(z.string()).nullable(), roleList: z.array(careerNavigatorRole).nullable()}); export const careerNavigatorUserAdditionalData = z.object({currentRole: careerNavigatorRole.nullable(), currentTenure: z.string().nullable().optional()}); export const careerNavigatorSearchResponseSchema = z.object({careerPaths: z.array(careerNavigatorPath).nullable(), userAdditionalData: careerNavigatorUserAdditionalData.nullable()}); 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 }; /** * Search Career Paths * * GET /api/v2/careerhub/career-navigator/recommended-paths/{userEmail} */ export const getApiApiV2CareerhubCareerNavigatorRecommendedPathsUserEmail = async (args: GetApiApiV2CareerhubCareerNavigatorRecommendedPathsUserEmailArgs, options?: GetApiApiV2CareerhubCareerNavigatorRecommendedPathsUserEmailOptions) => { const {baseUrl = "https://apiv2.eightfold.ai", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.exclude != null) query.append("exclude", String(args.exclude)) if (args.keyList != null) query.append("keyList", String(args.keyList)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/careerhub/career-navigator/recommended-paths/${encodeURIComponent(String(args.userEmail))}${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(careerNavigatorSearchResponseSchema, await res.json()) };