import {z} from 'zod' export type CategoryIDModel = 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 28 | 30 | 31; export type CurrencyModel = 'rub' | 'uah' | 'kzt' | 'byn' | 'usd' | 'eur' | 'gbp' | 'cny' | 'try' | 'jpy' | 'brl'; export type ItemOriginModel = 'brute' | 'phishing' | 'stealer' | 'autoreg' | 'personal' | 'resale' | 'dummy' | 'self_registration' | 'retrieve_via_support'; export type ExtraModel = {proxy?: string | undefined, close_item?: boolean | undefined, region?: string | undefined, service?: ('windscribeVPN' | 'tunnelbearVPN' | 'vanishVPN' | 'mullvadVPN' | 'PIAVPN' | 'AdguardVPN' | 'pureVPN' | 'ultraVPN' | 'cyberghostVPN' | 'vyprVPN' | 'hotspotShieldVPN' | 'planetVPN' | 'telegram' | 'discord' | 'discord_trial' | 'chatgpt' | 'claude' | 'cursor' | 'grok' | 'kimi' | 'openrouter' | 'perplexity' | 'windsurf') | undefined, system?: ('laser' | 'scroll' | 'magic') | undefined, confirmationCode?: string | undefined, cookies?: string | undefined, login_without_cookies?: boolean | undefined, cookie_login?: boolean | undefined, mfa_file?: string | undefined, parse_dota2?: boolean | undefined, uplay_games?: boolean | undefined, ea_games?: boolean | undefined, ark?: boolean | undefined, ark_ascended?: boolean | undefined, warframe?: boolean | undefined, the_quarry?: boolean | undefined, brawlhalla?: boolean | undefined, genshin_currency?: number | undefined, honkai_currency?: number | undefined, zenless_currency?: number | undefined, password?: string | undefined, telegramClient?: string | undefined, telegramJson?: string | undefined, checkChannels?: boolean | undefined, checkSpam?: boolean | undefined, checkHypixelBan?: boolean | undefined}; export type CreateApiItemFastSellArgs = {body: {title?: string | undefined, title_en?: string | undefined, auto_generate_title?: boolean | undefined, price: number, category_id: CategoryIDModel, currency: CurrencyModel, item_origin: ItemOriginModel, guarantee_duration?: (0 | 43200 | 86400 | 259200) | undefined, allow_ask_discount?: boolean | undefined, proxy_id?: number | undefined, random_proxy?: unknown, description?: string | undefined, information?: string | undefined, login?: string | undefined, password?: string | undefined, login_password?: string | undefined, resell_item_id?: number | undefined, tag_id?: Array | undefined, has_email_login_data?: boolean | undefined, email_login_data?: string | undefined, email_type?: ('native' | 'autoreg') | undefined, tfa_secret?: string | undefined, extra?: ExtraModel | undefined}}; export type CreateApiItemFastSellOptions = {baseUrl?: string | undefined, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const itemModel = z.object({item_id: z.number().int(), item_state: z.string(), category_id: z.number().int(), published_date: z.number().int(), title: z.string(), description: z.string(), price: z.number().int(), update_stat_date: z.number().int(), refreshed_date: z.number().int(), edit_date: z.number().int(), pending_deletion_date: z.number().int(), view_count: z.number().int(), is_sticky: z.number().int(), item_origin: z.string(), extended_guarantee: z.number().int(), nsb: z.number().int(), allow_ask_discount: z.number().int(), title_en: z.string(), description_en: z.string(), email_type: z.string(), email_provider: z.string(), item_domain: z.string(), resale_item_origin: z.string(), auto_bump_period: z.number().int(), guarantee_duration: z.number().int(), rub_price: z.number().int(), discount: z.boolean(), feedback_data: z.string(), max_discount_percent: z.number().int(), priceWithSellerFee: z.number(), category: z.object({category_id: z.number().int(), category_title: z.string(), category_name: z.string(), category_url: z.string()}), guarantee: z.object({duration: z.number().int(), class: z.string(), durationPhrase: z.string(), endDate: z.unknown(), active: z.unknown(), cancelled: z.unknown(), remainingTime: z.unknown()}), canViewLoginData: z.boolean(), canViewTempEmail: z.boolean(), canUpdateItemStats: z.boolean(), canReportItem: z.boolean(), canViewItemViews: z.boolean(), canManagePublicTag: z.boolean(), canViewEmailLoginData: z.boolean(), copyFormatData: z.object({title_link: z.string()}), showGetEmailCodeButton: z.boolean(), canOpenItem: z.boolean(), canCloseItem: z.boolean(), canEditItem: z.boolean(), canDeleteItem: z.boolean(), canStickItem: z.boolean(), canUnstickItem: z.boolean(), canBumpItem: z.boolean(), canNotBumpItemReason: z.string(), canAutoBump: z.boolean(), buyer: z.object({user_id: z.number().int(), operation_date: z.number().int(), visitorIsBuyer: z.boolean()}), isPersonalAccount: z.boolean(), canBuyItem: z.boolean(), price_currency: z.string(), priceWithSellerFeeLabel: z.string(), canValidateAccount: z.boolean(), canResellItem: z.boolean(), canViewAccountLink: z.boolean().optional(), accountLinks: z.array(z.object({link: z.string(), text: z.string(), iconClass: z.string()})), accountLink: z.string(), imagePreviewLinks: z.object({download: z.object({games: z.string()})}), emailLoginUrl: z.string(), canChangePassword: z.boolean(), canChangeEmailPassword: z.boolean(), uniqueKeyExists: z.boolean(), itemOriginPhrase: z.string(), sold_items_category_count: z.number().int(), restore_items_category_count: z.number().int(), tags: z.array(z.unknown()), public_tag: z.object({background_color: z.string(), tag_id: z.number().int(), title: z.string()}), note_text: z.string(), descriptionHtml: z.string(), descriptionEnHtml: z.string(), descriptionPlain: z.string(), descriptionEnPlain: z.string(), seller: z.object({user_id: z.number().int(), sold_items_count: z.number().int(), active_items_count: z.number().int(), restore_data: z.string(), username: z.string(), avatar_date: z.number().int(), is_banned: z.number().int(), display_style_group_id: z.number().int(), restore_percents: z.number().int()})}); export const respSystemInfo = z.object({rate_limit: z.object({limit: z.number().int(), remaining: z.number().int(), reset: z.number().int(), bucket: z.string().optional()}), visitor_id: z.number().int(), time: z.number().int(), log_id: z.number().int()}); export const createApiItemFastSellResponse = z.object({item: itemModel, itemLink: z.string(), system_info: respSystemInfo}); 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 }; /** * Fast Account Upload * * POST /item/fast-sell */ export const createApiItemFastSell = async (args: CreateApiItemFastSellArgs, options?: CreateApiItemFastSellOptions) => { const {baseUrl = "https://api.lzt.market", fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/item/fast-sell${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(createApiItemFastSellResponse, await res.json()) };