Skip to content
// API path: deals posted in the body (any CRM, or a test). Same common shape as the HubSpot mapper.
const body = $input.first().json.body ?? {};
return (body.deals ?? []).map((d, i) => ({
  json: {
    id: String(d.id ?? `deal-${i + 1}`),
    name: String(d.name ?? '(unnamed deal)'),
    stage: String(d.stage ?? 'unknown').toLowerCase(),
    amount: Number(d.amount ?? 0),
    owner: String(d.owner ?? 'Unassigned'),
    contact: String(d.contact ?? ''),
    last_activity: d.last_activity ?? null,
    url: String(d.url ?? ''),
  },
}));