import {z} from 'zod' export type SignalName = string; export type DuplicateSignalPublicInput = {name?: (SignalName | null) | undefined}; export type CreateApiV1SignalsSignalIdDuplicateArgs = {signal_id: string, body: DuplicateSignalPublicInput}; export type CreateApiV1SignalsSignalIdDuplicateOptions = {baseUrl?: string | undefined, BearerApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const signalType = z.enum(["LINKEDIN_OWN_POST_ENGAGEMENT", "LINKEDIN_COMPETITOR_POST_ENGAGEMENT", "LINKEDIN_PERSON_POST_ENGAGEMENT", "LINKEDIN_KEYWORD_MENTION", "LINKEDIN_OWN_COMPANY_FOLLOWERS", "LINKEDIN_COMPETITOR_FOLLOWERS", "LINKEDIN_COMPANY_PAGE_FOLLOWERS", "HIRING_SIGNALS", "JOB_DESCRIPTION_KEYWORD", "FUNDING_EVENTS", "TECH_ADOPTION", "NEWS_EVENTS", "NEW_JOB", "CUSTOM_EVENT", "LINKEDIN_PARTNER_FOLLOWERS", "LINKEDIN_CUSTOMER_FOLLOWERS", "LINKEDIN_PARTNER_POST_ENGAGEMENT", "LINKEDIN_CUSTOMER_POST_ENGAGEMENT", "LINKEDIN_COMPANY_PAGE_POST_ENGAGEMENT", "LINKEDIN_OWN_PROFILE_POST_ENGAGEMENT", "LINKEDIN_OWN_EMPLOYEES_POST_ENGAGEMENT", "LINKEDIN_COMPETITOR_EMPLOYEES_POST_ENGAGEMENT", "LINKEDIN_PARTNER_EMPLOYEES_POST_ENGAGEMENT", "LINKEDIN_CUSTOMER_EMPLOYEES_POST_ENGAGEMENT", "LINKEDIN_OWN_BRAND_MENTION", "LINKEDIN_COMPETITOR_MENTION", "LINKEDIN_PARTNER_MENTION", "LINKEDIN_CUSTOMER_MENTION", "LINKEDIN_EVENT_MENTION", "COMPETITOR_TECH_ADOPTION", "INTEGRATION_TECH_ADOPTION", "LINKEDIN_EVENT_PAGE_FOLLOWERS", "CHAMPION_CHANGED_JOB", "CRM_LIST_ENTRY"]); export const signalRunStatus = z.enum(["ACTIVE", "PAUSED", "ARCHIVED"]); export const refillFrequency = z.enum(["DAILY", "WEEKLY"]); export const signalPublicOutput = z.object({id: z.string(), name: z.string().nullable(), signal_type: signalType, status: signalRunStatus, cadence: refillFrequency.nullable(), max_per_run: z.number().int().nullable(), max_companies_per_run: z.number().int().nullable(), max_contacts_per_company: z.number().int().nullable(), max_per_day: z.number().int(), enrich_email: z.boolean(), enrich_phones: z.boolean(), imported_count: z.number().int(), contact_list_id: z.string().nullable(), account_list_id: z.string().nullable(), created_at: z.string(), archived_at: z.string().nullable(), url: z.string(), list_url: z.string().nullable()}); 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 }; /** * Duplicate Signal * * POST /v1/signals/{signal_id}/duplicate */ export const createApiV1SignalsSignalIdDuplicate = async (args: CreateApiV1SignalsSignalIdDuplicateArgs, options?: CreateApiV1SignalsSignalIdDuplicateOptions) => { const {baseUrl = "https://api.topo.io", fetch: fetchFn = fetch, BearerApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerApiKey !== undefined) headers.set('authorization', `Bearer ${BearerApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/signals/${encodeURIComponent(String(args.signal_id))}/duplicate${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(signalPublicOutput, await res.json()) };