import {z} from 'zod' export type CreateApiPublicUserProxyListByIdArgs = {'Content-Type': string, body: {list_authentication?: ('username_and_password' | 'ip_address' | 'proxy_specific') | undefined, list_format?: ('standard' | 'http' | 'socks5' | 'socks5h') | undefined, list_protocol?: ('http' | 'socks5') | undefined, list_version?: ('ipv4' | 'ipv6') | undefined, proxy_ids?: Array | undefined, proxy_user_id?: string | undefined}}; export type CreateApiPublicUserProxyListByIdOptions = {baseUrl?: string | undefined, APIPrivateKey?: string | undefined, APIPublicKey?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiPublicUserProxyListByIdResponse = z.object({data: z.array(z.string()).optional(), message: z.string().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 }; /** * Generate Proxy List By ID * * POST /public/user/proxy/list_by_id */ export const createApiPublicUserProxyListById = async (args: CreateApiPublicUserProxyListByIdArgs, options?: CreateApiPublicUserProxyListByIdOptions) => { const {baseUrl = "https://api.byteful.com/1.0", fetch: fetchFn = fetch, APIPrivateKey, APIPublicKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (APIPrivateKey !== undefined) headers.set("X-API-Private-Key", APIPrivateKey) if (APIPublicKey !== undefined) headers.set("X-API-Public-Key", APIPublicKey) const url = `${baseUrl.replace(/\/+$/, '')}/public/user/proxy/list_by_id${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(createApiPublicUserProxyListByIdResponse, await res.json()) };