import {z} from 'zod' export type GetApiApiV1WorkspaceCompaniesExportCsvArgs = {stage?: (string | null) | undefined, q?: (string | null) | undefined, collection_id?: (number | null) | undefined, funnel_stage?: (string | null) | undefined, has_location?: (string | null) | undefined, has_rating?: (string | null) | undefined, min_rating?: (number | null) | undefined, max_rating?: (number | null) | undefined, ai_column_id?: (number | null) | undefined, ai_value?: (string | null) | undefined, exclude_business_ids?: (string | null) | undefined, include_business_ids?: (string | null) | undefined}; export type GetApiApiV1WorkspaceCompaniesExportCsvOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const getApiApiV1WorkspaceCompaniesExportCsvResponse = z.unknown(); 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 }; /** * Export Companies Csv * * GET /api/v1/workspace/companies/export.csv */ export const getApiApiV1WorkspaceCompaniesExportCsv = async (args: GetApiApiV1WorkspaceCompaniesExportCsvArgs, options: GetApiApiV1WorkspaceCompaniesExportCsvOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.stage != null) query.append("stage", String(args.stage)) if (args.q != null) query.append("q", String(args.q)) if (args.collection_id != null) query.append("collection_id", String(args.collection_id)) if (args.funnel_stage != null) query.append("funnel_stage", String(args.funnel_stage)) if (args.has_location != null) query.append("has_location", String(args.has_location)) if (args.has_rating != null) query.append("has_rating", String(args.has_rating)) if (args.min_rating != null) query.append("min_rating", String(args.min_rating)) if (args.max_rating != null) query.append("max_rating", String(args.max_rating)) if (args.ai_column_id != null) query.append("ai_column_id", String(args.ai_column_id)) if (args.ai_value != null) query.append("ai_value", String(args.ai_value)) if (args.exclude_business_ids != null) query.append("exclude_business_ids", String(args.exclude_business_ids)) if (args.include_business_ids != null) query.append("include_business_ids", String(args.include_business_ids)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/workspace/companies/export.csv${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(getApiApiV1WorkspaceCompaniesExportCsvResponse, await res.json()) };