import {z} from 'zod' export type GetApiApiV1WorkspaceCompaniesArgs = {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, unenriched_column_id?: (number | null) | undefined, sort_by?: string | undefined, order?: string | undefined, page?: number | undefined, per_page?: number | undefined}; export type GetApiApiV1WorkspaceCompaniesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const getApiApiV1WorkspaceCompaniesResponse = 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 }; /** * List Companies * * GET /api/v1/workspace/companies */ export const getApiApiV1WorkspaceCompanies = async (args: GetApiApiV1WorkspaceCompaniesArgs, options: GetApiApiV1WorkspaceCompaniesOptions) => { 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.unenriched_column_id != null) query.append("unenriched_column_id", String(args.unenriched_column_id)) if (args.sort_by != null) query.append("sort_by", String(args.sort_by)) if (args.order != null) query.append("order", String(args.order)) if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/workspace/companies${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(getApiApiV1WorkspaceCompaniesResponse, await res.json()) };