import * as z from "zod" export const APOLLO_REFERENCE_SCHEMA = z.union([ z.string().trim().min(1), z.object({ id: z.string().trim().min(1) }), ]) export const APOLLO_ORGANIZATION_REFERENCE_SCHEMA = z.object({ /** Stable Apollo organization ID, omitted in privacy-limited search results. */ id: z.string().optional(), /** Human-readable organization name. */ name: z.string(), }) export const APOLLO_PAGINATION_SCHEMA = z.object({ /** Current one-based page number. */ page: z.number().int().nonnegative(), /** Requested number of results per page. */ perPage: z.number().int().nonnegative(), /** Total matching resources. */ totalEntries: z.number().int().nonnegative(), /** Total available pages. */ totalPages: z.number().int().nonnegative(), }) export const APOLLO_ORGANIZATION_SCHEMA = z.object({ /** Estimated annual revenue in US dollars, when available. */ annualRevenue: z.number().optional(), /** Headquarters city. */ city: z.string().optional(), /** Headquarters country. */ country: z.string().optional(), /** Estimated employee count. */ estimatedEmployeeCount: z.number().int().nonnegative().optional(), /** Founding year. */ foundedYear: z.number().int().optional(), /** Stable Apollo organization ID. */ id: z.string(), /** Primary provider-assigned industry. */ industry: z.string().optional(), /** All returned industries. */ industries: z.string().array(), /** Search and classification keywords. */ keywords: z.string().array(), /** LinkedIn company URL. */ linkedinUrl: z.string().optional(), /** Organization logo URL. */ logoUrl: z.string().optional(), /** Human-readable organization name. */ name: z.string(), /** Main organization phone number. */ phone: z.string().optional(), /** Primary organization domain. */ primaryDomain: z.string().optional(), /** Short provider description. */ shortDescription: z.string().optional(), /** Headquarters state or region. */ state: z.string().optional(), /** Technology names detected by Apollo. */ technologyNames: z.string().array(), /** Total funding in US dollars, when available. */ totalFunding: z.number().optional(), /** Organization website URL. */ websiteUrl: z.string().optional(), }) export const APOLLO_PERSON_SCHEMA = z.object({ /** Person's city. */ city: z.string().optional(), /** Apollo contact created from this person, when returned. */ contactId: z.string().optional(), /** Person's country. */ country: z.string().optional(), /** Departments associated with the person's role. */ departments: z.string().array(), /** Enriched email address, when revealed. */ email: z.string().optional(), /** Apollo's email deliverability classification. */ emailStatus: z.string().optional(), /** Person's first name. */ firstName: z.string().optional(), /** Current professional headline. */ headline: z.string().optional(), /** Stable Apollo person ID. */ id: z.string(), /** Whether Apollo considers the person likely to engage. */ likelyToEngage: z.boolean().optional(), /** Person's last name. */ lastName: z.string().optional(), /** LinkedIn profile URL. */ linkedinUrl: z.string().optional(), /** Full name. */ name: z.string().optional(), /** Current employer, when returned. */ organization: APOLLO_ORGANIZATION_REFERENCE_SCHEMA.optional(), /** Stable current-employer organization ID. */ organizationId: z.string().optional(), /** Profile photo URL. */ photoUrl: z.string().optional(), /** Apollo seniority classification. */ seniority: z.string().optional(), /** Person's state or region. */ state: z.string().optional(), /** Current job title. */ title: z.string().optional(), }) export const APOLLO_CONTACT_SCHEMA = z.object({ /** Saved Apollo account associated with the contact. */ accountId: z.string().optional(), /** Contact stage ID. */ contactStageId: z.string().optional(), /** Time the contact was created. */ createdAt: z.string().optional(), /** Provider-native typed custom fields keyed by field ID. */ customFields: z.record(z.string(), z.json()), /** Contact email address. */ email: z.string().optional(), /** Apollo's email deliverability classification. */ emailStatus: z.string().optional(), /** Contact first name. */ firstName: z.string().optional(), /** Stable Apollo contact ID. */ id: z.string(), /** IDs of Apollo lists applied to this contact. */ labelIds: z.string().array(), /** Contact last name. */ lastName: z.string().optional(), /** LinkedIn profile URL. */ linkedinUrl: z.string().optional(), /** Contact full name. */ name: z.string().optional(), /** Enriched employer organization, when returned. */ organization: APOLLO_ORGANIZATION_SCHEMA.optional(), /** Employer organization ID. */ organizationId: z.string().optional(), /** Employer organization name. */ organizationName: z.string().optional(), /** Workspace owner user ID. */ ownerId: z.string().optional(), /** Source Apollo person ID. */ personId: z.string().optional(), /** IDs of sequences containing the contact. */ sequenceIds: z.string().array(), /** Current job title. */ title: z.string().optional(), /** Time the contact was last updated. */ updatedAt: z.string().optional(), }) export const APOLLO_ACCOUNT_SCHEMA = z.object({ /** Account stage ID. */ accountStageId: z.string().optional(), /** Time the account was created. */ createdAt: z.string().optional(), /** Provider-native typed custom fields keyed by field ID. */ customFields: z.record(z.string(), z.json()), /** Primary account domain. */ domain: z.string().optional(), /** Stable Apollo account ID. */ id: z.string(), /** IDs of Apollo lists applied to this account. */ labelIds: z.string().array(), /** Last recorded activity date. */ lastActivityAt: z.string().optional(), /** LinkedIn company URL. */ linkedinUrl: z.string().optional(), /** Human-readable account name. */ name: z.string(), /** Number of contacts attached to the account. */ numContacts: z.number().int().nonnegative().optional(), /** Linked Apollo organization ID. */ organizationId: z.string().optional(), /** Workspace owner user ID. */ ownerId: z.string().optional(), /** Main account phone number. */ phone: z.string().optional(), }) export const APOLLO_LIST_SCHEMA = z.object({ /** Cached number of resources in the list. */ cachedCount: z.number().int().nonnegative(), /** Time the list was created. */ createdAt: z.string().optional(), /** Stable Apollo list ID. */ id: z.string(), /** Resource modality stored by this list. */ modality: z.string().optional(), /** Human-readable list name. */ name: z.string(), /** Workspace team ID. */ teamId: z.string().optional(), /** Time the list was last updated. */ updatedAt: z.string().optional(), /** User who owns the list. */ userId: z.string().optional(), }) export const APOLLO_STAGE_SCHEMA = z.object({ /** Provider stage category, when configured. */ category: z.string().optional(), /** Human-readable stage label. */ displayName: z.string(), /** Workspace display order. */ displayOrder: z.number().int().nonnegative(), /** Stable Apollo stage ID. */ id: z.string(), /** Whether this stage represents a booked meeting. */ isMeetingSet: z.boolean().optional(), /** Provider stage name. */ name: z.string(), /** Workspace team ID. */ teamId: z.string().optional(), }) export const APOLLO_USER_SCHEMA = z.object({ /** Time the user was created. */ createdAt: z.string().optional(), /** Whether the user has been deleted. */ deleted: z.boolean(), /** User email address. */ email: z.string().optional(), /** User first name. */ firstName: z.string().optional(), /** Stable Apollo user ID. */ id: z.string(), /** User last name. */ lastName: z.string().optional(), /** Connected CRM provider name. */ linkedCrmName: z.string().optional(), /** User display name. */ name: z.string(), /** Workspace team ID. */ teamId: z.string().optional(), /** User job title. */ title: z.string().optional(), }) export const APOLLO_EMAIL_ACCOUNT_SCHEMA = z.object({ /** Whether the mailbox can currently send. */ active: z.boolean(), /** Alternate addresses associated with the mailbox. */ aliases: z.string().array(), /** Daily outbound email threshold. */ dailyThreshold: z.number().int().nonnegative().optional(), /** Whether this is the user's default mailbox. */ default: z.boolean(), /** Provider deliverability score. */ deliverabilityScore: z.number().optional(), /** Mailbox email address. */ email: z.string(), /** Stable Apollo email-account ID. */ id: z.string(), /** Reason the mailbox is inactive. */ inactiveReason: z.string().optional(), /** Last mailbox synchronization time. */ lastSyncedAt: z.string().optional(), /** Maximum outbound emails per hour. */ maxOutboundEmailsPerHour: z.number().int().nonnegative().optional(), /** Apollo's underlying mailbox provider identifier. */ provider: z.string().optional(), /** Human-readable mailbox provider name. */ providerDisplayName: z.string().optional(), /** Time mailbox authorization was revoked. */ revokedAt: z.string().optional(), /** Delay between outbound emails, in seconds. */ secondsDelayBetweenEmails: z.number().nonnegative().optional(), /** Apollo user who owns the mailbox. */ userId: z.string().optional(), }) export const APOLLO_SEQUENCE_SCHEMA = z.object({ /** Whether the sequence is active. */ active: z.boolean(), /** Whether the sequence is archived. */ archived: z.boolean(), /** Aggregate bounce rate. */ bounceRate: z.number().optional(), /** Aggregate click rate. */ clickRate: z.number().optional(), /** Time the sequence was created. */ createdAt: z.string().optional(), /** Folder containing the sequence. */ folderId: z.string().optional(), /** Stable Apollo sequence ID. */ id: z.string(), /** IDs of Apollo lists applied to the sequence. */ labelIds: z.string().array(), /** Last time the sequence was used. */ lastUsedAt: z.string().optional(), /** Maximum emails sent per day. */ maxEmailsPerDay: z.number().int().nonnegative().optional(), /** Human-readable sequence name. */ name: z.string(), /** Number of sequence steps. */ numSteps: z.number().int().nonnegative(), /** Aggregate open rate. */ openRate: z.number().optional(), /** Aggregate reply rate. */ replyRate: z.number().optional(), /** User who owns the sequence. */ userId: z.string().optional(), }) export const APOLLO_TASK_SCHEMA = z.object({ /** Related saved account ID. */ accountId: z.string().optional(), /** Time the task was completed. */ completedAt: z.string().optional(), /** Related contact ID. */ contactId: z.string().optional(), /** Time the task was created. */ createdAt: z.string().optional(), /** User Apollo considers the task creator. */ creatorId: z.string().optional(), /** Time the task is due. */ dueAt: z.string().optional(), /** Related sequence ID. */ emailerCampaignId: z.string().optional(), /** Stable Apollo task ID. */ id: z.string(), /** Free-form task note. */ note: z.string().optional(), /** Related enriched organization ID. */ organizationId: z.string().optional(), /** Related person ID. */ personId: z.string().optional(), /** Provider priority value. */ priority: z.string().optional(), /** Time the task was skipped. */ skippedAt: z.string().optional(), /** Current provider task status. */ status: z.string().optional(), /** Task subject. */ subject: z.string().optional(), /** Task display title. */ title: z.string().optional(), /** Provider task type. */ type: z.string().optional(), /** User assigned to the task. */ userId: z.string().optional(), }) export const APOLLO_PROVIDER_PAGINATION_SCHEMA = z.looseObject({ page: z.coerce.number().int().nonnegative().prefault(0), per_page: z.coerce.number().int().nonnegative().prefault(0), total_entries: z.coerce.number().int().nonnegative().prefault(0), total_pages: z.coerce.number().int().nonnegative().prefault(0), }) export const APOLLO_PROVIDER_ORGANIZATION_SCHEMA = z.looseObject({ annual_revenue: z.number().nullish(), city: z.string().nullish(), country: z.string().nullish(), estimated_num_employees: z.number().int().nonnegative().nullish(), founded_year: z.number().int().nullish(), id: z.string(), industries: z.string().array().nullish(), industry: z.string().nullish(), keywords: z.string().array().nullish(), linkedin_url: z.string().nullish(), logo_url: z.string().nullish(), name: z.string(), phone: z.string().nullish(), primary_domain: z.string().nullish(), short_description: z.string().nullish(), state: z.string().nullish(), technology_names: z.string().array().nullish(), total_funding: z.number().nullish(), website_url: z.string().nullish(), }) export const APOLLO_PROVIDER_ORGANIZATION_REFERENCE_SCHEMA = z.looseObject({ id: z.string().optional(), name: z.string(), }) export const APOLLO_PROVIDER_PERSON_SCHEMA = z.looseObject({ city: z.string().nullish(), contact_id: z.string().nullish(), country: z.string().nullish(), departments: z.string().array().nullish(), email: z.string().nullish(), email_status: z.string().nullish(), first_name: z.string().nullish(), headline: z.string().nullish(), id: z.string(), is_likely_to_engage: z.boolean().nullish(), last_name: z.string().nullish(), last_name_obfuscated: z.string().nullish(), linkedin_url: z.string().nullish(), name: z.string().nullish(), organization: APOLLO_PROVIDER_ORGANIZATION_REFERENCE_SCHEMA.nullish(), organization_id: z.string().nullish(), photo_url: z.string().nullish(), seniority: z.string().nullish(), state: z.string().nullish(), title: z.string().nullish(), }) export const APOLLO_PROVIDER_CONTACT_SCHEMA = z.looseObject({ account_id: z.string().nullish(), contact_stage_id: z.string().nullish(), created_at: z.string().nullish(), email: z.string().nullish(), email_status: z.string().nullish(), emailer_campaign_ids: z.string().array().nullish(), first_name: z.string().nullish(), id: z.string(), label_ids: z.string().array().nullish(), last_name: z.string().nullish(), linkedin_url: z.string().nullish(), name: z.string().nullish(), organization: APOLLO_PROVIDER_ORGANIZATION_SCHEMA.nullish(), organization_id: z.string().nullish(), organization_name: z.string().nullish(), owner_id: z.string().nullish(), person_id: z.string().nullish(), title: z.string().nullish(), typed_custom_fields: z.record(z.string(), z.json()).nullish(), updated_at: z.string().nullish(), }) export const APOLLO_PROVIDER_ACCOUNT_SCHEMA = z.looseObject({ account_stage_id: z.string().nullish(), created_at: z.string().nullish(), domain: z.string().nullish(), id: z.string(), label_ids: z.string().array().nullish(), last_activity_date: z.string().nullish(), linkedin_url: z.string().nullish(), name: z.string(), num_contacts: z.number().int().nonnegative().nullish(), organization_id: z.string().nullish(), owner_id: z.string().nullish(), phone: z.string().nullish(), typed_custom_fields: z.record(z.string(), z.json()).nullish(), }) export const APOLLO_PROVIDER_LIST_SCHEMA = z.looseObject({ _id: z.string().optional(), cached_count: z.number().int().nonnegative().nullish(), created_at: z.string().nullish(), id: z.string(), modality: z.string().nullish(), name: z.string(), team_id: z.string().nullish(), updated_at: z.string().nullish(), user_id: z.string().nullish(), }) export const APOLLO_PROVIDER_STAGE_SCHEMA = z.looseObject({ category: z.string().nullish(), display_name: z.string().nullish(), display_order: z.number().int().nonnegative().nullish(), id: z.string(), is_meeting_set: z.boolean().nullish(), name: z.string().nullish(), team_id: z.string().nullish(), }) export const APOLLO_PROVIDER_USER_SCHEMA = z.looseObject({ created_at: z.string().nullish(), deleted: z.boolean().nullish(), email: z.string().nullish(), first_name: z.string().nullish(), id: z.string(), last_name: z.string().nullish(), linked_crm_name: z.string().nullish(), name: z.string().nullish(), team_id: z.string().nullish(), title: z.string().nullish(), }) export const APOLLO_PROVIDER_EMAIL_ACCOUNT_SCHEMA = z.looseObject({ active: z.boolean().nullish(), aliases: z.string().array().nullish(), default: z.boolean().nullish(), deliverability_score: z.number().nullish(), email: z.string(), email_daily_threshold: z.number().int().nonnegative().nullish(), id: z.string(), inactive_reason: z.string().nullish(), last_synced_at: z.string().nullish(), max_outbound_emails_per_hour: z.number().int().nonnegative().nullish(), nylas_provider: z.string().nullish(), provider_display_name: z.string().nullish(), revoked_at: z.string().nullish(), seconds_delay_between_emails: z.number().nonnegative().nullish(), user_id: z.string().nullish(), }) export const APOLLO_PROVIDER_SEQUENCE_SCHEMA = z.looseObject({ active: z.boolean().nullish(), archived: z.boolean().nullish(), bounce_rate: z.union([z.number(), z.literal("loading")]).nullish(), click_rate: z.union([z.number(), z.literal("loading")]).nullish(), created_at: z.string().nullish(), folder_id: z.string().nullish(), id: z.string(), label_ids: z.string().array().nullish(), last_used_at: z.string().nullish(), max_emails_per_day: z.number().int().nonnegative().nullish(), name: z.string(), num_steps: z.number().int().nonnegative().nullish(), open_rate: z.union([z.number(), z.literal("loading")]).nullish(), reply_rate: z.union([z.number(), z.literal("loading")]).nullish(), user_id: z.string().nullish(), }) export const APOLLO_PROVIDER_TASK_SCHEMA = z.looseObject({ account_id: z.string().nullish(), completed_at: z.string().nullish(), contact_id: z.string().nullish(), created_at: z.string().nullish(), creator_id: z.string().nullish(), due_at: z.string().nullish(), emailer_campaign_id: z.string().nullish(), id: z.string(), note: z.string().nullish(), organization_id: z.string().nullish(), person_id: z.string().nullish(), priority: z.union([z.string(), z.number()]).nullish(), skipped_at: z.string().nullish(), status: z.string().nullish(), subject: z.string().nullish(), title: z.string().nullish(), type: z.string().nullish(), user_id: z.string().nullish(), }) /** * Converts Apollo's pagination envelope to stable camelCase fields. * * @param value - Provider pagination envelope. */ export function toApolloPagination( value: z.output, ) { return APOLLO_PAGINATION_SCHEMA.parse({ page: value.page, perPage: value.per_page, totalEntries: value.total_entries, totalPages: value.total_pages, }) } /** * Converts an Apollo organization to the public representation. * * @param value - Provider organization. */ export function toApolloOrganization( value: z.output, ) { return APOLLO_ORGANIZATION_SCHEMA.parse({ annualRevenue: value.annual_revenue ?? undefined, city: value.city ?? undefined, country: value.country ?? undefined, estimatedEmployeeCount: value.estimated_num_employees ?? undefined, foundedYear: value.founded_year ?? undefined, id: value.id, industries: value.industries ?? [], industry: value.industry ?? undefined, keywords: value.keywords ?? [], linkedinUrl: value.linkedin_url ?? undefined, logoUrl: value.logo_url ?? undefined, name: value.name, phone: value.phone ?? undefined, primaryDomain: value.primary_domain ?? undefined, shortDescription: value.short_description ?? undefined, state: value.state ?? undefined, technologyNames: value.technology_names ?? [], totalFunding: value.total_funding ?? undefined, websiteUrl: value.website_url ?? undefined, }) } /** * Converts an Apollo person to the public representation. * * @param value - Provider person. */ export function toApolloPerson( value: z.output, ) { return APOLLO_PERSON_SCHEMA.parse({ city: value.city ?? undefined, contactId: value.contact_id ?? undefined, country: value.country ?? undefined, departments: value.departments ?? [], email: value.email ?? undefined, emailStatus: value.email_status ?? undefined, firstName: value.first_name ?? undefined, headline: value.headline ?? undefined, id: value.id, lastName: value.last_name ?? value.last_name_obfuscated ?? undefined, likelyToEngage: value.is_likely_to_engage ?? undefined, linkedinUrl: value.linkedin_url ?? undefined, name: value.name ?? undefined, organization: value.organization ? APOLLO_ORGANIZATION_REFERENCE_SCHEMA.parse(value.organization) : undefined, organizationId: value.organization_id ?? undefined, photoUrl: value.photo_url ?? undefined, seniority: value.seniority ?? undefined, state: value.state ?? undefined, title: value.title ?? undefined, }) } /** * Converts an Apollo contact to the public representation. * * @param value - Provider contact. */ export function toApolloContact( value: z.output, ) { return APOLLO_CONTACT_SCHEMA.parse({ accountId: value.account_id ?? undefined, contactStageId: value.contact_stage_id ?? undefined, createdAt: value.created_at ?? undefined, creatorId: value.creator_id ?? undefined, customFields: value.typed_custom_fields ?? {}, email: value.email ?? undefined, emailStatus: value.email_status ?? undefined, firstName: value.first_name ?? undefined, id: value.id, labelIds: value.label_ids ?? [], lastName: value.last_name ?? undefined, linkedinUrl: value.linkedin_url ?? undefined, name: value.name ?? undefined, organization: value.organization ? toApolloOrganization(value.organization) : undefined, organizationId: value.organization_id ?? undefined, organizationName: value.organization_name ?? undefined, ownerId: value.owner_id ?? undefined, personId: value.person_id ?? undefined, sequenceIds: value.emailer_campaign_ids ?? [], title: value.title ?? undefined, updatedAt: value.updated_at ?? undefined, }) } /** * Converts an Apollo account to the public representation. * * @param value - Provider account. */ export function toApolloAccount( value: z.output, ) { return APOLLO_ACCOUNT_SCHEMA.parse({ accountStageId: value.account_stage_id ?? undefined, createdAt: value.created_at ?? undefined, customFields: value.typed_custom_fields ?? {}, domain: value.domain ?? undefined, id: value.id, labelIds: value.label_ids ?? [], lastActivityAt: value.last_activity_date ?? undefined, linkedinUrl: value.linkedin_url ?? undefined, name: value.name, numContacts: value.num_contacts ?? undefined, organizationId: value.organization_id ?? undefined, ownerId: value.owner_id ?? undefined, phone: value.phone ?? undefined, }) } /** * Converts an Apollo list to the public representation. * * @param value - Provider list. */ export function toApolloList( value: z.output, ) { return APOLLO_LIST_SCHEMA.parse({ cachedCount: value.cached_count ?? 0, createdAt: value.created_at ?? undefined, id: value.id, modality: value.modality ?? undefined, name: value.name, teamId: value.team_id ?? undefined, updatedAt: value.updated_at ?? undefined, userId: value.user_id ?? undefined, }) } /** * Converts an Apollo contact or account stage to the public representation. * * @param value - Provider contact or account stage. */ export function toApolloStage( value: z.output, ) { return APOLLO_STAGE_SCHEMA.parse({ category: value.category ?? undefined, displayName: value.display_name ?? value.name ?? value.id, displayOrder: value.display_order ?? 0, id: value.id, isMeetingSet: value.is_meeting_set ?? undefined, name: value.name ?? value.display_name ?? value.id, teamId: value.team_id ?? undefined, }) } /** * Converts an Apollo workspace user to the public representation. * * @param value - Provider workspace user. */ export function toApolloUser( value: z.output, ) { return APOLLO_USER_SCHEMA.parse({ createdAt: value.created_at ?? undefined, deleted: value.deleted ?? false, email: value.email ?? undefined, firstName: value.first_name ?? undefined, id: value.id, lastName: value.last_name ?? undefined, linkedCrmName: value.linked_crm_name ?? undefined, name: (value.name ?? [value.first_name, value.last_name].filter(Boolean).join(" ")) || value.email || value.id, teamId: value.team_id ?? undefined, title: value.title ?? undefined, }) } /** * Converts an Apollo linked mailbox to the public representation. * * @param value - Provider email account. */ export function toApolloEmailAccount( value: z.output, ) { return APOLLO_EMAIL_ACCOUNT_SCHEMA.parse({ active: value.active ?? false, aliases: value.aliases ?? [], dailyThreshold: value.email_daily_threshold ?? undefined, default: value.default ?? false, deliverabilityScore: value.deliverability_score ?? undefined, email: value.email, id: value.id, inactiveReason: value.inactive_reason ?? undefined, lastSyncedAt: value.last_synced_at ?? undefined, maxOutboundEmailsPerHour: value.max_outbound_emails_per_hour ?? undefined, provider: value.nylas_provider ?? undefined, providerDisplayName: value.provider_display_name ?? undefined, revokedAt: value.revoked_at ?? undefined, secondsDelayBetweenEmails: value.seconds_delay_between_emails ?? undefined, userId: value.user_id ?? undefined, }) } /** * Converts an Apollo sequence to the public representation. * * @param value - Provider sequence. */ export function toApolloSequence( value: z.output, ) { return APOLLO_SEQUENCE_SCHEMA.parse({ active: value.active ?? false, archived: value.archived ?? false, bounceRate: typeof value.bounce_rate === "number" ? value.bounce_rate : undefined, clickRate: typeof value.click_rate === "number" ? value.click_rate : undefined, createdAt: value.created_at ?? undefined, folderId: value.folder_id ?? undefined, id: value.id, labelIds: value.label_ids ?? [], lastUsedAt: value.last_used_at ?? undefined, maxEmailsPerDay: value.max_emails_per_day ?? undefined, name: value.name, numSteps: value.num_steps ?? 0, openRate: typeof value.open_rate === "number" ? value.open_rate : undefined, replyRate: typeof value.reply_rate === "number" ? value.reply_rate : undefined, userId: value.user_id ?? undefined, }) } /** * Converts an Apollo task to the public representation. * * @param value - Provider task. */ export function toApolloTask( value: z.output, ) { return APOLLO_TASK_SCHEMA.parse({ accountId: value.account_id ?? undefined, completedAt: value.completed_at ?? undefined, contactId: value.contact_id ?? undefined, createdAt: value.created_at ?? undefined, creatorId: value.creator_id ?? undefined, dueAt: value.due_at ?? undefined, emailerCampaignId: value.emailer_campaign_id ?? undefined, id: value.id, note: value.note ?? undefined, organizationId: value.organization_id ?? undefined, personId: value.person_id ?? undefined, priority: value.priority === null || value.priority === undefined ? undefined : String(value.priority), skippedAt: value.skipped_at ?? undefined, status: value.status ?? undefined, subject: value.subject ?? undefined, title: value.title ?? undefined, type: value.type ?? undefined, userId: value.user_id ?? undefined, }) }