mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-04-11 18:28:15 +00:00
fix: all 7 GraphQL queries — correct field names and LINKS/PHONES subfields
Leads: landingPage → { primaryLinkUrl }, remove duplicateOfLeadId
Ads: adFormat → format, destinationUrl/previewUrl → { primaryLinkUrl }
FollowUps: remove non-existent callId field
LeadActivities: durationSeconds → durationSec
All transforms updated to match query changes
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// GraphQL queries for platform entities
|
||||
// Platform remaps some SDK field names — queries use platform names
|
||||
// Platform remaps SDK field names — all LINKS/PHONES fields need subfield selection
|
||||
|
||||
export const LEADS_QUERY = `{ leads(first: 100, orderBy: [{ createdAt: DescNullsLast }]) { edges { node {
|
||||
id name createdAt updatedAt
|
||||
@@ -7,8 +7,8 @@ export const LEADS_QUERY = `{ leads(first: 100, orderBy: [{ createdAt: DescNulls
|
||||
contactPhone { primaryPhoneNumber primaryPhoneCallingCode }
|
||||
contactEmail { primaryEmail }
|
||||
source status priority interestedService assignedAgent
|
||||
utmSource utmMedium utmCampaign utmContent utmTerm landingPage referrerUrl
|
||||
leadScore spamScore isSpam isDuplicate duplicateOfLeadId
|
||||
utmSource utmMedium utmCampaign utmContent utmTerm landingPage { primaryLinkUrl } referrerUrl
|
||||
leadScore spamScore isSpam isDuplicate
|
||||
firstContacted lastContacted contactAttempts convertedAt
|
||||
patientId campaignId
|
||||
aiSummary aiSuggestedAction
|
||||
@@ -26,8 +26,8 @@ export const CAMPAIGNS_QUERY = `{ campaigns(first: 50, orderBy: [{ createdAt: De
|
||||
|
||||
export const ADS_QUERY = `{ ads(first: 100, orderBy: [{ createdAt: DescNullsLast }]) { edges { node {
|
||||
id name createdAt updatedAt
|
||||
adName externalAdId status adFormat
|
||||
headline adDescription destinationUrl previewUrl
|
||||
adName externalAdId status format
|
||||
headline adDescription destinationUrl { primaryLinkUrl } previewUrl { primaryLinkUrl }
|
||||
impressions clicks conversions
|
||||
spend { amountMicros currencyCode }
|
||||
campaignId
|
||||
@@ -37,14 +37,14 @@ export const FOLLOW_UPS_QUERY = `{ followUps(first: 50, orderBy: [{ scheduledAt:
|
||||
id name createdAt
|
||||
typeCustom status scheduledAt completedAt
|
||||
priority assignedAgent
|
||||
patientId callId
|
||||
patientId
|
||||
} } } }`;
|
||||
|
||||
export const LEAD_ACTIVITIES_QUERY = `{ leadActivities(first: 200, orderBy: [{ occurredAt: DescNullsLast }]) { edges { node {
|
||||
id name createdAt
|
||||
activityType summary occurredAt performedBy
|
||||
previousValue newValue
|
||||
channel durationSeconds outcome
|
||||
channel durationSec outcome
|
||||
leadId
|
||||
} } } }`;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Transform platform GraphQL responses → frontend entity types
|
||||
// Platform remaps some field names during sync
|
||||
// Platform remaps field names during sync — this layer normalizes them
|
||||
|
||||
import type { Lead, Campaign, Ad, FollowUp, LeadActivity, Call, Patient } from '@/types/entities';
|
||||
|
||||
@@ -31,13 +31,13 @@ export function transformLeads(data: any): Lead[] {
|
||||
utmCampaign: n.utmCampaign,
|
||||
utmContent: n.utmContent,
|
||||
utmTerm: n.utmTerm,
|
||||
landingPageUrl: n.landingPage,
|
||||
landingPageUrl: n.landingPage?.primaryLinkUrl ?? null,
|
||||
referrerUrl: n.referrerUrl,
|
||||
leadScore: n.leadScore,
|
||||
spamScore: n.spamScore ?? 0,
|
||||
isSpam: n.isSpam ?? false,
|
||||
isDuplicate: n.isDuplicate ?? false,
|
||||
duplicateOfLeadId: n.duplicateOfLeadId,
|
||||
duplicateOfLeadId: null,
|
||||
firstContactedAt: n.firstContacted,
|
||||
lastContactedAt: n.lastContacted,
|
||||
contactAttempts: n.contactAttempts ?? 0,
|
||||
@@ -82,11 +82,11 @@ export function transformAds(data: any): Ad[] {
|
||||
adName: n.adName ?? n.name,
|
||||
externalAdId: n.externalAdId,
|
||||
adStatus: n.status,
|
||||
adFormat: n.adFormat,
|
||||
adFormat: n.format,
|
||||
headline: n.headline,
|
||||
adDescription: n.adDescription,
|
||||
destinationUrl: n.destinationUrl,
|
||||
previewUrl: n.previewUrl,
|
||||
destinationUrl: n.destinationUrl?.primaryLinkUrl ?? null,
|
||||
previewUrl: n.previewUrl?.primaryLinkUrl ?? null,
|
||||
impressions: n.impressions ?? 0,
|
||||
clicks: n.clicks ?? 0,
|
||||
conversions: n.conversions ?? 0,
|
||||
@@ -106,7 +106,7 @@ export function transformFollowUps(data: any): FollowUp[] {
|
||||
priority: n.priority ?? 'NORMAL',
|
||||
assignedAgent: n.assignedAgent,
|
||||
patientId: n.patientId,
|
||||
callId: n.callId,
|
||||
callId: null,
|
||||
patientName: undefined,
|
||||
patientPhone: undefined,
|
||||
description: n.name,
|
||||
@@ -124,7 +124,7 @@ export function transformLeadActivities(data: any): LeadActivity[] {
|
||||
previousValue: n.previousValue,
|
||||
newValue: n.newValue,
|
||||
channel: n.channel,
|
||||
durationSeconds: n.durationSeconds,
|
||||
durationSeconds: n.durationSec ?? 0,
|
||||
outcome: n.outcome,
|
||||
activityNotes: null,
|
||||
leadId: n.leadId,
|
||||
|
||||
Reference in New Issue
Block a user