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
|
// 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 {
|
export const LEADS_QUERY = `{ leads(first: 100, orderBy: [{ createdAt: DescNullsLast }]) { edges { node {
|
||||||
id name createdAt updatedAt
|
id name createdAt updatedAt
|
||||||
@@ -7,8 +7,8 @@ export const LEADS_QUERY = `{ leads(first: 100, orderBy: [{ createdAt: DescNulls
|
|||||||
contactPhone { primaryPhoneNumber primaryPhoneCallingCode }
|
contactPhone { primaryPhoneNumber primaryPhoneCallingCode }
|
||||||
contactEmail { primaryEmail }
|
contactEmail { primaryEmail }
|
||||||
source status priority interestedService assignedAgent
|
source status priority interestedService assignedAgent
|
||||||
utmSource utmMedium utmCampaign utmContent utmTerm landingPage referrerUrl
|
utmSource utmMedium utmCampaign utmContent utmTerm landingPage { primaryLinkUrl } referrerUrl
|
||||||
leadScore spamScore isSpam isDuplicate duplicateOfLeadId
|
leadScore spamScore isSpam isDuplicate
|
||||||
firstContacted lastContacted contactAttempts convertedAt
|
firstContacted lastContacted contactAttempts convertedAt
|
||||||
patientId campaignId
|
patientId campaignId
|
||||||
aiSummary aiSuggestedAction
|
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 {
|
export const ADS_QUERY = `{ ads(first: 100, orderBy: [{ createdAt: DescNullsLast }]) { edges { node {
|
||||||
id name createdAt updatedAt
|
id name createdAt updatedAt
|
||||||
adName externalAdId status adFormat
|
adName externalAdId status format
|
||||||
headline adDescription destinationUrl previewUrl
|
headline adDescription destinationUrl { primaryLinkUrl } previewUrl { primaryLinkUrl }
|
||||||
impressions clicks conversions
|
impressions clicks conversions
|
||||||
spend { amountMicros currencyCode }
|
spend { amountMicros currencyCode }
|
||||||
campaignId
|
campaignId
|
||||||
@@ -37,14 +37,14 @@ export const FOLLOW_UPS_QUERY = `{ followUps(first: 50, orderBy: [{ scheduledAt:
|
|||||||
id name createdAt
|
id name createdAt
|
||||||
typeCustom status scheduledAt completedAt
|
typeCustom status scheduledAt completedAt
|
||||||
priority assignedAgent
|
priority assignedAgent
|
||||||
patientId callId
|
patientId
|
||||||
} } } }`;
|
} } } }`;
|
||||||
|
|
||||||
export const LEAD_ACTIVITIES_QUERY = `{ leadActivities(first: 200, orderBy: [{ occurredAt: DescNullsLast }]) { edges { node {
|
export const LEAD_ACTIVITIES_QUERY = `{ leadActivities(first: 200, orderBy: [{ occurredAt: DescNullsLast }]) { edges { node {
|
||||||
id name createdAt
|
id name createdAt
|
||||||
activityType summary occurredAt performedBy
|
activityType summary occurredAt performedBy
|
||||||
previousValue newValue
|
previousValue newValue
|
||||||
channel durationSeconds outcome
|
channel durationSec outcome
|
||||||
leadId
|
leadId
|
||||||
} } } }`;
|
} } } }`;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Transform platform GraphQL responses → frontend entity types
|
// 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';
|
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,
|
utmCampaign: n.utmCampaign,
|
||||||
utmContent: n.utmContent,
|
utmContent: n.utmContent,
|
||||||
utmTerm: n.utmTerm,
|
utmTerm: n.utmTerm,
|
||||||
landingPageUrl: n.landingPage,
|
landingPageUrl: n.landingPage?.primaryLinkUrl ?? null,
|
||||||
referrerUrl: n.referrerUrl,
|
referrerUrl: n.referrerUrl,
|
||||||
leadScore: n.leadScore,
|
leadScore: n.leadScore,
|
||||||
spamScore: n.spamScore ?? 0,
|
spamScore: n.spamScore ?? 0,
|
||||||
isSpam: n.isSpam ?? false,
|
isSpam: n.isSpam ?? false,
|
||||||
isDuplicate: n.isDuplicate ?? false,
|
isDuplicate: n.isDuplicate ?? false,
|
||||||
duplicateOfLeadId: n.duplicateOfLeadId,
|
duplicateOfLeadId: null,
|
||||||
firstContactedAt: n.firstContacted,
|
firstContactedAt: n.firstContacted,
|
||||||
lastContactedAt: n.lastContacted,
|
lastContactedAt: n.lastContacted,
|
||||||
contactAttempts: n.contactAttempts ?? 0,
|
contactAttempts: n.contactAttempts ?? 0,
|
||||||
@@ -82,11 +82,11 @@ export function transformAds(data: any): Ad[] {
|
|||||||
adName: n.adName ?? n.name,
|
adName: n.adName ?? n.name,
|
||||||
externalAdId: n.externalAdId,
|
externalAdId: n.externalAdId,
|
||||||
adStatus: n.status,
|
adStatus: n.status,
|
||||||
adFormat: n.adFormat,
|
adFormat: n.format,
|
||||||
headline: n.headline,
|
headline: n.headline,
|
||||||
adDescription: n.adDescription,
|
adDescription: n.adDescription,
|
||||||
destinationUrl: n.destinationUrl,
|
destinationUrl: n.destinationUrl?.primaryLinkUrl ?? null,
|
||||||
previewUrl: n.previewUrl,
|
previewUrl: n.previewUrl?.primaryLinkUrl ?? null,
|
||||||
impressions: n.impressions ?? 0,
|
impressions: n.impressions ?? 0,
|
||||||
clicks: n.clicks ?? 0,
|
clicks: n.clicks ?? 0,
|
||||||
conversions: n.conversions ?? 0,
|
conversions: n.conversions ?? 0,
|
||||||
@@ -106,7 +106,7 @@ export function transformFollowUps(data: any): FollowUp[] {
|
|||||||
priority: n.priority ?? 'NORMAL',
|
priority: n.priority ?? 'NORMAL',
|
||||||
assignedAgent: n.assignedAgent,
|
assignedAgent: n.assignedAgent,
|
||||||
patientId: n.patientId,
|
patientId: n.patientId,
|
||||||
callId: n.callId,
|
callId: null,
|
||||||
patientName: undefined,
|
patientName: undefined,
|
||||||
patientPhone: undefined,
|
patientPhone: undefined,
|
||||||
description: n.name,
|
description: n.name,
|
||||||
@@ -124,7 +124,7 @@ export function transformLeadActivities(data: any): LeadActivity[] {
|
|||||||
previousValue: n.previousValue,
|
previousValue: n.previousValue,
|
||||||
newValue: n.newValue,
|
newValue: n.newValue,
|
||||||
channel: n.channel,
|
channel: n.channel,
|
||||||
durationSeconds: n.durationSeconds,
|
durationSeconds: n.durationSec ?? 0,
|
||||||
outcome: n.outcome,
|
outcome: n.outcome,
|
||||||
activityNotes: null,
|
activityNotes: null,
|
||||||
leadId: n.leadId,
|
leadId: n.leadId,
|
||||||
|
|||||||
Reference in New Issue
Block a user