import {z} from 'zod' export type ResumeData = {picture: {hidden: boolean, url: string, size: number, rotation: number, aspectRatio: number, borderRadius: number, borderColor: string, borderWidth: number, shadowColor: string, shadowWidth: number}, basics: {name: string, headline: string, email: string, phone: string, location: string, website: {url: string, label: string}, customFields: Array<{id: string, icon: string, text: string, link: string}>}, summary: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, content: string}, sections: {profiles: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, icon: string, iconColor: string, network: string, username: string, website: {url: string, label: string, inlineLink: boolean}}>}, experience: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, company: string, position: string, location: string, period: string, website: {url: string, label: string, inlineLink: boolean}, description: string, roles: Array<{id: string, position: string, period: string, description: string}>}>}, education: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, school: string, degree: string, area: string, grade: string, location: string, period: string, website: {url: string, label: string, inlineLink: boolean}, description: string}>}, projects: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, name: string, period: string, website: {url: string, label: string, inlineLink: boolean}, description: string}>}, skills: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, icon: string, iconColor: string, name: string, proficiency: string, level: number, keywords: Array}>}, languages: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, language: string, fluency: string, level: number}>}, interests: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, icon: string, iconColor: string, name: string, keywords: Array}>}, awards: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, title: string, awarder: string, date: string, website: {url: string, label: string, inlineLink: boolean}, description: string}>}, certifications: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, title: string, issuer: string, date: string, website: {url: string, label: string, inlineLink: boolean}, description: string}>}, publications: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, title: string, publisher: string, date: string, website: {url: string, label: string, inlineLink: boolean}, description: string}>}, volunteer: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, organization: string, location: string, period: string, website: {url: string, label: string, inlineLink: boolean}, description: string}>}, references: {title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, items: Array<{id: string, hidden: boolean, name: string, position: string, website: {url: string, label: string, inlineLink: boolean}, phone: string, description: string}>}}, customSections: Array<{title: string, icon: string, columns: number, hidden: boolean, keepTogether: boolean, startOnNewPage: boolean, id: string, type: 'summary' | 'profiles' | 'experience' | 'education' | 'projects' | 'skills' | 'languages' | 'interests' | 'awards' | 'certifications' | 'publications' | 'volunteer' | 'references' | 'cover-letter', items: Array<{id: string, hidden: boolean, recipient: string, content: string} | {id: string, hidden: boolean, content: string} | {id: string, hidden: boolean, icon: string, iconColor: string, network: string, username: string, website: {url: string, label: string, inlineLink: boolean}} | {id: string, hidden: boolean, company: string, position: string, location: string, period: string, website: {url: string, label: string, inlineLink: boolean}, description: string, roles: Array<{id: string, position: string, period: string, description: string}>} | {id: string, hidden: boolean, school: string, degree: string, area: string, grade: string, location: string, period: string, website: {url: string, label: string, inlineLink: boolean}, description: string} | {id: string, hidden: boolean, name: string, period: string, website: {url: string, label: string, inlineLink: boolean}, description: string} | {id: string, hidden: boolean, icon: string, iconColor: string, name: string, proficiency: string, level: number, keywords: Array} | {id: string, hidden: boolean, language: string, fluency: string, level: number} | {id: string, hidden: boolean, icon: string, iconColor: string, name: string, keywords: Array} | {id: string, hidden: boolean, title: string, awarder: string, date: string, website: {url: string, label: string, inlineLink: boolean}, description: string} | {id: string, hidden: boolean, title: string, issuer: string, date: string, website: {url: string, label: string, inlineLink: boolean}, description: string} | {id: string, hidden: boolean, title: string, publisher: string, date: string, website: {url: string, label: string, inlineLink: boolean}, description: string} | {id: string, hidden: boolean, organization: string, location: string, period: string, website: {url: string, label: string, inlineLink: boolean}, description: string} | {id: string, hidden: boolean, name: string, position: string, website: {url: string, label: string, inlineLink: boolean}, phone: string, description: string}>}>, metadata: {template: 'azurill' | 'bronzor' | 'chikorita' | 'ditgar' | 'ditto' | 'gengar' | 'glalie' | 'kakuna' | 'lapras' | 'leafish' | 'meowth' | 'onyx' | 'pikachu' | 'rhyhorn' | 'scizor', layout: {sidebarWidth: number, pages: Array<{fullWidth: boolean, main: Array, sidebar: Array}>}, page: {gapX: number, gapY: number, marginX: number, marginY: number, format: 'a4' | 'letter' | 'free-form', locale: string, hideLinkUnderline: boolean, hideIcons: boolean, hideSectionIcons: boolean}, design: {level: {icon: string, type: 'hidden' | 'circle' | 'square' | 'rectangle' | 'rectangle-full' | 'progress-bar' | 'icon'}, colors: {primary: string, text: string, background: string}}, typography: {body: {fontFamily: string, fontWeights: Array<'100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'>, fontSize: number, lineHeight: number}, heading: {fontFamily: string, fontWeights: Array<'100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'>, fontSize: number, lineHeight: number}}, notes: string, styleRules: Array<{id: string, label: string, enabled: boolean, target: {scope: 'global'} | {scope: 'sectionType', sectionType: 'summary' | 'profiles' | 'experience' | 'education' | 'projects' | 'skills' | 'languages' | 'interests' | 'awards' | 'certifications' | 'publications' | 'volunteer' | 'references' | 'cover-letter'} | {scope: 'sectionId', sectionId: string}, slots: {[key: string]: {color?: string | undefined, backgroundColor?: string | undefined, borderColor?: string | undefined, textDecorationColor?: string | undefined, opacity?: number | undefined, fontSize?: number | undefined, fontWeight?: ('100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900') | undefined, fontStyle?: ('normal' | 'italic') | undefined, lineHeight?: number | undefined, letterSpacing?: number | undefined, textDecoration?: ('none' | 'underline' | 'line-through') | undefined, textDecorationStyle?: ('solid' | 'dashed' | 'dotted') | undefined, textAlign?: ('left' | 'center' | 'right' | 'justify') | undefined, textTransform?: ('none' | 'uppercase' | 'lowercase' | 'capitalize') | undefined, padding?: number | undefined, paddingTop?: number | undefined, paddingRight?: number | undefined, paddingBottom?: number | undefined, paddingLeft?: number | undefined, marginTop?: number | undefined, marginRight?: number | undefined, marginBottom?: number | undefined, marginLeft?: number | undefined, rowGap?: number | undefined, columnGap?: number | undefined, borderStyle?: ('solid' | 'dashed' | 'dotted') | undefined, borderWidth?: number | undefined, borderRadius?: number | undefined}}}>}} | {[key: string]: unknown}; export type CreateApiResumesImportArgs = {body: {data: ResumeData}}; export type CreateApiResumesImportOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiResumesImportResponse = 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 }; /** * Import a resume * * POST /resumes/import */ export const createApiResumesImport = async (args: CreateApiResumesImportArgs, options?: CreateApiResumesImportOptions) => { const {baseUrl = "http://localhost:3000/api/openapi", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (apiKey !== undefined) headers.set("x-api-key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/resumes/import${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(createApiResumesImportResponse, await res.json()) };