import {z} from 'zod' export type GetApiApiV2CareerhubProfileEncIdUpskillPlanAssignmentPlanIdArgs = {Authorization: string, profileEncId: string, planId: string, exclude?: string | undefined, keyList?: string | undefined}; export type GetApiApiV2CareerhubProfileEncIdUpskillPlanAssignmentPlanIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const upskillingPlanEntityStatus = z.object({completed: z.array(z.number().int()).nullable().optional(), notStarted: z.array(z.number().int()).nullable().optional(), inProgress: z.array(z.number().int()).nullable().optional(), entityType: z.string().nullable().optional()}); export const upskillingPlanMetadata = z.object({planSubtype: z.string().nullable().optional(), visibility: z.string().nullable().optional(), tasks: z.object({}).nullable().optional(), planDurationDays: z.number().int().nullable().optional(), planSections: z.array(z.object({})).nullable().optional(), planSectionsLayout: z.array(z.object({})).nullable().optional(), planType: z.string().nullable().optional(), permissions: z.array(z.object({})).nullable().optional(), lastUpdateProfileId: z.string().nullable().optional(), tPublish: z.number().int().nullable().optional(), description: z.string().nullable().optional()}); export const upskillingPlanCalibrationData = z.object({jobFunctions: z.array(z.string()).nullable().optional(), associatedRoleId: z.array(z.string()).nullable().optional(), skills: z.array(z.string()).nullable().optional(), locations: z.array(z.string()).nullable().optional(), businessUnits: z.array(z.string()).nullable().optional()}); export const upskillingPlanAssignmentSchema = z.object({createdAt: z.number().int().nullable().optional(), id: z.number().int().nullable().optional(), planStatus: z.string().nullable().optional(), externalId: z.string().nullable().optional(), entityStatuses: z.array(upskillingPlanEntityStatus).nullable().optional(), name: z.string().nullable(), userId: z.string().nullable().optional(), completionPercentage: z.number().int().nullable().optional(), metadata: upskillingPlanMetadata.nullable().optional(), profileId: z.number().int().nullable().optional(), startDate: z.number().int().nullable().optional(), lastProgressTs: z.number().int().nullable().optional(), calibrationData: upskillingPlanCalibrationData.nullable().optional(), groupId: z.string().nullable().optional(), updatedAt: z.number().int().nullable().optional(), lastNotifiedTs: z.number().int().nullable().optional(), targetDate: z.number().int().nullable().optional(), parentPlanId: z.number().int().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 }; /** * Get Upskill Plan Assignment * * GET /api/v2/careerhub/{profileEncId}/upskill-plan-assignment/{planId} */ export const getApiApiV2CareerhubProfileEncIdUpskillPlanAssignmentPlanId = async (args: GetApiApiV2CareerhubProfileEncIdUpskillPlanAssignmentPlanIdArgs, options?: GetApiApiV2CareerhubProfileEncIdUpskillPlanAssignmentPlanIdOptions) => { 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/${encodeURIComponent(String(args.profileEncId))}/upskill-plan-assignment/${encodeURIComponent(String(args.planId))}${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(upskillingPlanAssignmentSchema, await res.json()) };