import {z} from 'zod' export type EntityType = 'business' | 'prospect'; export type BusinessesEventIdentifier = 'ipo_announcement' | 'new_funding_round' | 'new_investment' | 'new_product' | 'new_office' | 'closing_office' | 'new_partnership' | 'increase_in_engineering_department' | 'increase_in_sales_department' | 'increase_in_marketing_department' | 'increase_in_operations_department' | 'increase_in_customer_service_department' | 'increase_in_all_departments' | 'decrease_in_engineering_department' | 'decrease_in_sales_department' | 'decrease_in_marketing_department' | 'decrease_in_operations_department' | 'decrease_in_customer_service_department' | 'decrease_in_all_departments' | 'employee_joined_company' | 'hiring_in_creative_department' | 'hiring_in_education_department' | 'hiring_in_engineering_department' | 'hiring_in_finance_department' | 'hiring_in_health_department' | 'hiring_in_human_resources_department' | 'hiring_in_legal_department' | 'hiring_in_marketing_department' | 'hiring_in_operations_department' | 'hiring_in_professional_service_department' | 'hiring_in_sales_department' | 'hiring_in_support_department' | 'hiring_in_trade_department' | 'hiring_in_unknown_department' | 'company_award' | 'outages_and_security_breaches' | 'cost_cutting' | 'merger_and_acquisitions' | 'lawsuits_and_legal_issues'; export type BusinessesEventsRequest = {request_context?: (Record | null) | undefined, entity_type?: EntityType | undefined, event_types: Array, timestamp_to?: (string | string | null) | undefined, timestamp_from?: (string | string | null) | undefined, business_ids: Array}; export type CreateApiV1BusinessesEventsArgs = {tenant?: string | undefined, body: BusinessesEventsRequest}; export type CreateApiV1BusinessesEventsOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiV1BusinessesEventsResponse = 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 }; /** * Fetch Businesses Events * * POST /v1/businesses/events * * Also accepts auth: APIKeyHeader */ export const createApiV1BusinessesEvents = async (args: CreateApiV1BusinessesEventsArgs, options?: CreateApiV1BusinessesEventsOptions) => { const {baseUrl = "https://api.explorium.ai", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.tenant != null) headers.set("tenant", String(args.tenant)) if (APIKeyHeader !== undefined) headers.set("api_key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/v1/businesses/events${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(createApiV1BusinessesEventsResponse, await res.json()) };