outbound-sdk 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +119 -2
- package/dist/alerts/index.d.ts +2 -0
- package/dist/alerts/index.js +140 -0
- package/dist/alerts/plugin.d.ts +58 -0
- package/dist/audit/index.d.ts +33 -0
- package/dist/audit/index.js +60 -0
- package/dist/benchmarks/index.d.ts +29 -0
- package/dist/benchmarks/index.js +72 -0
- package/dist/budget/index.d.ts +21 -0
- package/dist/budget/index.js +71 -0
- package/dist/cache/index.d.ts +31 -0
- package/dist/cache/index.js +11 -0
- package/dist/cards/content.d.ts +43 -0
- package/dist/cards/copy-cards.d.ts +2 -0
- package/dist/cards/format.d.ts +39 -0
- package/dist/cards/index.d.ts +9 -0
- package/dist/cards/index.js +2070 -0
- package/dist/cards/notify-cards.d.ts +14 -0
- package/dist/cards/ops-cards.d.ts +2 -0
- package/dist/cards/parts.d.ts +22 -0
- package/dist/cards/people-cards.d.ts +2 -0
- package/dist/cards/render.d.ts +28 -0
- package/dist/cards/sender-cards.d.ts +2 -0
- package/dist/cards/slack-rich.d.ts +19 -0
- package/dist/cards/slack-text.d.ts +10 -0
- package/dist/cards/slack.d.ts +21 -0
- package/dist/cards/spec.d.ts +86 -0
- package/dist/cards/tool-cards.d.ts +4 -0
- package/dist/chunks/chunk-4O2HRTTI.js +75 -0
- package/dist/chunks/chunk-4PSO6JEK.js +357 -0
- package/dist/chunks/chunk-6CVZOUHB.js +152 -0
- package/dist/chunks/chunk-AFU5E5QB.js +714 -0
- package/dist/chunks/chunk-DJ2IUQEU.js +111 -0
- package/dist/chunks/chunk-E7JHLNLG.js +187 -0
- package/dist/chunks/chunk-FHKSLCVW.js +154 -0
- package/dist/chunks/chunk-FKH5N47I.js +40 -0
- package/dist/chunks/chunk-HZCTYL22.js +29 -0
- package/dist/chunks/chunk-IPUYZD4O.js +25 -0
- package/dist/chunks/chunk-IVH3NMQZ.js +61 -0
- package/dist/chunks/chunk-LVYG7XZJ.js +45 -0
- package/dist/chunks/chunk-NAKXLBA6.js +30 -0
- package/dist/chunks/chunk-NAWZ73QS.js +22 -0
- package/dist/chunks/chunk-PMSSUWD7.js +636 -0
- package/dist/chunks/chunk-PURHK3JU.js +432 -0
- package/dist/chunks/chunk-R3Y56YVF.js +43 -0
- package/dist/chunks/chunk-RCZ7ZZFU.js +92 -0
- package/dist/chunks/chunk-SBIZDCRY.js +106 -0
- package/dist/chunks/chunk-U2D34ARZ.js +41 -0
- package/dist/chunks/chunk-UAT3JSJZ.js +331 -0
- package/dist/chunks/chunk-VQSCHOBV.js +111 -0
- package/dist/chunks/chunk-XC6CZP73.js +80 -0
- package/dist/chunks/chunk-XNFESPZH.js +2307 -0
- package/dist/chunks/chunk-YOTW5ESM.js +118 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +35 -0
- package/dist/cli/commands.d.ts +19 -0
- package/dist/cli/config.d.ts +22 -0
- package/dist/cli/index.d.ts +17 -0
- package/dist/cli/index.js +30 -0
- package/dist/cli/mcp.d.ts +14 -0
- package/dist/cli/stdio.d.ts +9 -0
- package/dist/clients/index.d.ts +2 -0
- package/dist/clients/index.js +117 -0
- package/dist/clients/plugin.d.ts +42 -0
- package/dist/combine/account.d.ts +4 -0
- package/dist/combine/adapter.d.ts +9 -0
- package/dist/combine/index.d.ts +2 -0
- package/dist/combine/index.js +420 -0
- package/dist/combine/route.d.ts +24 -0
- package/dist/exporter/index.d.ts +29 -0
- package/dist/exporter/index.js +77 -0
- package/dist/failover/index.d.ts +11 -0
- package/dist/failover/index.js +45 -0
- package/dist/fixtures/index.d.ts +27 -0
- package/dist/fixtures/index.js +260 -0
- package/dist/fixtures/scrub.d.ts +5 -0
- package/dist/heyreach/account.d.ts +11 -0
- package/dist/heyreach/adapter.d.ts +5 -0
- package/dist/heyreach/capabilities.d.ts +70 -0
- package/dist/heyreach/client.d.ts +18 -0
- package/dist/heyreach/inbox.d.ts +7 -0
- package/dist/heyreach/index.d.ts +25 -0
- package/dist/heyreach/index.js +1931 -0
- package/dist/heyreach/leads.d.ts +4 -0
- package/dist/heyreach/lookup.d.ts +15 -0
- package/dist/heyreach/map-account.d.ts +31 -0
- package/dist/heyreach/map-sequence.d.ts +5 -0
- package/dist/heyreach/map-stats.d.ts +13 -0
- package/dist/heyreach/map.d.ts +37 -0
- package/dist/heyreach/native-organization.d.ts +128 -0
- package/dist/heyreach/native-voice.d.ts +106 -0
- package/dist/heyreach/native.d.ts +496 -0
- package/dist/heyreach/paging.d.ts +7 -0
- package/dist/heyreach/webhooks.d.ts +3 -0
- package/dist/identity/index.d.ts +3 -0
- package/dist/identity/index.js +159 -0
- package/dist/identity/keys.d.ts +9 -0
- package/dist/identity/plugin.d.ts +34 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +131 -0
- package/dist/insights/copy/copy-audit.d.ts +55 -0
- package/dist/insights/copy/copy-checks.d.ts +44 -0
- package/dist/insights/copy/copy-reuse.d.ts +59 -0
- package/dist/insights/copy/index.d.ts +67 -0
- package/dist/insights/copy/reply-timing.d.ts +63 -0
- package/dist/insights/copy/shared.d.ts +53 -0
- package/dist/insights/copy/step-funnel.d.ts +66 -0
- package/dist/insights/copy/variant-test.d.ts +64 -0
- package/dist/insights/define.d.ts +98 -0
- package/dist/insights/index.d.ts +10 -0
- package/dist/insights/index.js +4937 -0
- package/dist/insights/ops/anomalies.d.ts +80 -0
- package/dist/insights/ops/campaign-diagnosis.d.ts +39 -0
- package/dist/insights/ops/campaign-ranking.d.ts +56 -0
- package/dist/insights/ops/channel-mix.d.ts +44 -0
- package/dist/insights/ops/client-report.d.ts +76 -0
- package/dist/insights/ops/diagnosis-checks.d.ts +48 -0
- package/dist/insights/ops/index.d.ts +135 -0
- package/dist/insights/ops/period-comparison.d.ts +86 -0
- package/dist/insights/ops/pipeline-forecast.d.ts +44 -0
- package/dist/insights/ops/shared.d.ts +155 -0
- package/dist/insights/ops/tag-rollup.d.ts +32 -0
- package/dist/insights/people/account-summary.d.ts +68 -0
- package/dist/insights/people/dropped-replies.d.ts +51 -0
- package/dist/insights/people/find.d.ts +18 -0
- package/dist/insights/people/hot-leads.d.ts +67 -0
- package/dist/insights/people/index.d.ts +88 -0
- package/dist/insights/people/lead-collisions.d.ts +43 -0
- package/dist/insights/people/person-summary.d.ts +46 -0
- package/dist/insights/people/personalization-gaps.d.ts +60 -0
- package/dist/insights/people/read.d.ts +40 -0
- package/dist/insights/people/suppression-check.d.ts +53 -0
- package/dist/insights/plugin.d.ts +40 -0
- package/dist/insights/registry.d.ts +335 -0
- package/dist/insights/senders/bounce-watch.d.ts +70 -0
- package/dist/insights/senders/domain-health.d.ts +69 -0
- package/dist/insights/senders/index.d.ts +74 -0
- package/dist/insights/senders/read.d.ts +37 -0
- package/dist/insights/senders/sender-capacity.d.ts +67 -0
- package/dist/insights/senders/sender-load.d.ts +52 -0
- package/dist/insights/senders/settings-audit.d.ts +48 -0
- package/dist/insights/senders/warmup-readiness.d.ts +39 -0
- package/dist/insights/stats.d.ts +45 -0
- package/dist/insights/tools.d.ts +16 -0
- package/dist/insights/types.d.ts +4 -0
- package/dist/instantly/adapter-account.d.ts +5 -0
- package/dist/instantly/adapter-mail.d.ts +3 -0
- package/dist/instantly/adapter.d.ts +7 -0
- package/dist/instantly/capabilities.d.ts +85 -0
- package/dist/instantly/client.d.ts +24 -0
- package/dist/instantly/index.d.ts +27 -0
- package/dist/instantly/index.js +2627 -0
- package/dist/instantly/map-account.d.ts +38 -0
- package/dist/instantly/map-lead.d.ts +18 -0
- package/dist/instantly/map-stats.d.ts +25 -0
- package/dist/instantly/map.d.ts +22 -0
- package/dist/instantly/native-agents-sales.d.ts +161 -0
- package/dist/instantly/native-agents.d.ts +156 -0
- package/dist/instantly/native-campaigns.d.ts +101 -0
- package/dist/instantly/native-leads.d.ts +93 -0
- package/dist/instantly/native-params.d.ts +7 -0
- package/dist/instantly/native-search.d.ts +82 -0
- package/dist/instantly/native-senders.d.ts +182 -0
- package/dist/instantly/native-supersearch.d.ts +149 -0
- package/dist/instantly/native-workspace.d.ts +170 -0
- package/dist/instantly/native.d.ts +1081 -0
- package/dist/instantly/pages.d.ts +29 -0
- package/dist/instantly/stats.d.ts +5 -0
- package/dist/instantly/webhooks.d.ts +3 -0
- package/dist/internal/adapter.d.ts +211 -0
- package/dist/internal/capabilities.d.ts +104 -0
- package/dist/internal/client.d.ts +15 -0
- package/dist/internal/concurrency.d.ts +8 -0
- package/dist/internal/cursor.d.ts +10 -0
- package/dist/internal/engine/budget.d.ts +44 -0
- package/dist/internal/engine/engine.d.ts +45 -0
- package/dist/internal/engine/rate-store.d.ts +25 -0
- package/dist/internal/engine/request.d.ts +34 -0
- package/dist/internal/engine/retry.d.ts +21 -0
- package/dist/internal/engine/runtime.d.ts +13 -0
- package/dist/internal/entities-account.d.ts +205 -0
- package/dist/internal/entities.d.ts +493 -0
- package/dist/internal/env.d.ts +4 -0
- package/dist/internal/errors.d.ts +62 -0
- package/dist/internal/fields.d.ts +462 -0
- package/dist/internal/hooks.d.ts +55 -0
- package/dist/internal/json.d.ts +49 -0
- package/dist/internal/lead-fields.d.ts +21 -0
- package/dist/internal/lead-status.d.ts +13 -0
- package/dist/internal/limits.d.ts +34 -0
- package/dist/internal/metrics.d.ts +64 -0
- package/dist/internal/native.d.ts +81 -0
- package/dist/internal/outbound/api.d.ts +292 -0
- package/dist/internal/outbound/collections.d.ts +31 -0
- package/dist/internal/outbound/core.d.ts +36 -0
- package/dist/internal/outbound/create.d.ts +16 -0
- package/dist/internal/outbound/handles.d.ts +7 -0
- package/dist/internal/outbound/native.d.ts +4 -0
- package/dist/internal/outbound/operation-shared.d.ts +28 -0
- package/dist/internal/outbound/operations-account.d.ts +41 -0
- package/dist/internal/outbound/operations.d.ts +42 -0
- package/dist/internal/outbound/outbound.d.ts +67 -0
- package/dist/internal/outbound/plugins.d.ts +40 -0
- package/dist/internal/outbound/raw.d.ts +9 -0
- package/dist/internal/outbound/specs-account.d.ts +20 -0
- package/dist/internal/outbound/specs.d.ts +14 -0
- package/dist/internal/outbound/stats.d.ts +7 -0
- package/dist/internal/outbound/validate.d.ts +5 -0
- package/dist/internal/outbound/walker.d.ts +22 -0
- package/dist/internal/page.d.ts +14 -0
- package/dist/internal/record.d.ts +36 -0
- package/dist/internal/records.d.ts +7 -0
- package/dist/internal/redact.d.ts +18 -0
- package/dist/internal/ref.d.ts +16 -0
- package/dist/internal/sequence.d.ts +14 -0
- package/dist/internal/sha256.d.ts +6 -0
- package/dist/internal/text.d.ts +11 -0
- package/dist/internal/url.d.ts +9 -0
- package/dist/loader/index.d.ts +24 -0
- package/dist/loader/index.js +16 -0
- package/dist/memory/account-reads.d.ts +5 -0
- package/dist/memory/account.d.ts +81 -0
- package/dist/memory/adapter.d.ts +16 -0
- package/dist/memory/data.d.ts +137 -0
- package/dist/memory/demo.d.ts +7 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.js +867 -0
- package/dist/memory/stats.d.ts +6 -0
- package/dist/memory/store.d.ts +18 -0
- package/dist/providers/index.d.ts +22 -0
- package/dist/providers/index.js +10 -0
- package/dist/reconcile/index.d.ts +2 -0
- package/dist/reconcile/index.js +72 -0
- package/dist/reconcile/plugin.d.ts +55 -0
- package/dist/redact/index.d.ts +2 -0
- package/dist/redact/index.js +197 -0
- package/dist/redact/plugin.d.ts +22 -0
- package/dist/redis/index.d.ts +41 -0
- package/dist/redis/index.js +114 -0
- package/dist/smartlead/account.d.ts +5 -0
- package/dist/smartlead/adapter.d.ts +5 -0
- package/dist/smartlead/capabilities.d.ts +87 -0
- package/dist/smartlead/client.d.ts +18 -0
- package/dist/smartlead/hmac.d.ts +7 -0
- package/dist/smartlead/index.d.ts +24 -0
- package/dist/smartlead/index.js +2329 -0
- package/dist/smartlead/leads.d.ts +9 -0
- package/dist/smartlead/lookup.d.ts +8 -0
- package/dist/smartlead/mail.d.ts +5 -0
- package/dist/smartlead/map-account.d.ts +34 -0
- package/dist/smartlead/map-messages.d.ts +31 -0
- package/dist/smartlead/map-stats.d.ts +36 -0
- package/dist/smartlead/map.d.ts +62 -0
- package/dist/smartlead/native-analytics.d.ts +242 -0
- package/dist/smartlead/native-campaigns.d.ts +211 -0
- package/dist/smartlead/native-inbox.d.ts +141 -0
- package/dist/smartlead/native-params.d.ts +12 -0
- package/dist/smartlead/native-services.d.ts +204 -0
- package/dist/smartlead/native.d.ts +785 -0
- package/dist/smartlead/shared.d.ts +29 -0
- package/dist/smartlead/stats.d.ts +5 -0
- package/dist/smartlead/webhooks.d.ts +3 -0
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.js +158 -0
- package/dist/sync/plugin.d.ts +58 -0
- package/dist/tools/account-tools.d.ts +21 -0
- package/dist/tools/ai-sdk.d.ts +8 -0
- package/dist/tools/ai-sdk.js +28 -0
- package/dist/tools/campaign-tools.d.ts +59 -0
- package/dist/tools/claude-agent.d.ts +18 -0
- package/dist/tools/claude-agent.js +42 -0
- package/dist/tools/index.d.ts +28 -0
- package/dist/tools/index.js +22 -0
- package/dist/tools/people-tools.d.ts +19 -0
- package/dist/tools/registry.d.ts +34 -0
- package/dist/tools/shared.d.ts +75 -0
- package/dist/tracing/index.d.ts +25 -0
- package/dist/tracing/index.js +69 -0
- package/dist/webhooks/index.d.ts +3 -0
- package/dist/webhooks/index.js +227 -0
- package/dist/webhooks/parse.d.ts +41 -0
- package/dist/webhooks/secret.d.ts +4 -0
- package/package.json +181 -4
|
@@ -0,0 +1,1931 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EVENT_TYPES,
|
|
3
|
+
heyreachEvents
|
|
4
|
+
} from "../chunks/chunk-DJ2IUQEU.js";
|
|
5
|
+
import {
|
|
6
|
+
createVendorClient,
|
|
7
|
+
mapPage,
|
|
8
|
+
normalizeBody,
|
|
9
|
+
withLeadFields,
|
|
10
|
+
withMappedFields
|
|
11
|
+
} from "../chunks/chunk-6CVZOUHB.js";
|
|
12
|
+
import {
|
|
13
|
+
leadStanding,
|
|
14
|
+
toVariant,
|
|
15
|
+
variantKey
|
|
16
|
+
} from "../chunks/chunk-FKH5N47I.js";
|
|
17
|
+
import {
|
|
18
|
+
defineNative
|
|
19
|
+
} from "../chunks/chunk-NAKXLBA6.js";
|
|
20
|
+
import {
|
|
21
|
+
emptyCounts,
|
|
22
|
+
metricRow
|
|
23
|
+
} from "../chunks/chunk-YOTW5ESM.js";
|
|
24
|
+
import {
|
|
25
|
+
profileSlug
|
|
26
|
+
} from "../chunks/chunk-NAWZ73QS.js";
|
|
27
|
+
import {
|
|
28
|
+
stableId
|
|
29
|
+
} from "../chunks/chunk-FHKSLCVW.js";
|
|
30
|
+
import {
|
|
31
|
+
readEnv,
|
|
32
|
+
requireCredential
|
|
33
|
+
} from "../chunks/chunk-IPUYZD4O.js";
|
|
34
|
+
import {
|
|
35
|
+
eventTypesOf,
|
|
36
|
+
recordBase,
|
|
37
|
+
refTo,
|
|
38
|
+
refsTo
|
|
39
|
+
} from "../chunks/chunk-U2D34ARZ.js";
|
|
40
|
+
import "../chunks/chunk-4PSO6JEK.js";
|
|
41
|
+
import {
|
|
42
|
+
assertWorkspaceId
|
|
43
|
+
} from "../chunks/chunk-LVYG7XZJ.js";
|
|
44
|
+
import {
|
|
45
|
+
OutboundError,
|
|
46
|
+
isHttpFailure,
|
|
47
|
+
makeErrorMapper,
|
|
48
|
+
requireObject
|
|
49
|
+
} from "../chunks/chunk-E7JHLNLG.js";
|
|
50
|
+
import {
|
|
51
|
+
count,
|
|
52
|
+
emailAddress,
|
|
53
|
+
field,
|
|
54
|
+
flag,
|
|
55
|
+
fullName,
|
|
56
|
+
isJsonObject,
|
|
57
|
+
isNumber,
|
|
58
|
+
isString,
|
|
59
|
+
list,
|
|
60
|
+
objects,
|
|
61
|
+
text,
|
|
62
|
+
timestamp
|
|
63
|
+
} from "../chunks/chunk-VQSCHOBV.js";
|
|
64
|
+
|
|
65
|
+
// src/heyreach/map-account.ts
|
|
66
|
+
var toCampaignProgress = (identity, campaignId, raw) => {
|
|
67
|
+
const stats = raw.progressStats;
|
|
68
|
+
return {
|
|
69
|
+
...recordBase(identity, campaignId, raw),
|
|
70
|
+
// HeyReach has no bounce and no block list for a campaign's leads.
|
|
71
|
+
blocked: null,
|
|
72
|
+
campaignRef: refTo(identity, campaignId) ?? "",
|
|
73
|
+
completed: count(field(stats, "totalUsersFinished")),
|
|
74
|
+
failed: count(field(stats, "totalUsersFailed")),
|
|
75
|
+
inProgress: count(field(stats, "totalUsersInProgress")),
|
|
76
|
+
leads: count(field(stats, "totalUsers")),
|
|
77
|
+
notStarted: count(field(stats, "totalUsersPending")),
|
|
78
|
+
stopped: count(field(stats, "totalUsersManuallyStopped"))
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
var toLeadList = (identity, raw) => ({
|
|
82
|
+
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
83
|
+
createdAt: timestamp(raw.creationTime),
|
|
84
|
+
kind: text(raw.listType) === "COMPANY_LIST" ? "companies" : "leads",
|
|
85
|
+
name: text(raw.name) ?? text(raw.id) ?? "",
|
|
86
|
+
size: count(raw.totalItemsCount)
|
|
87
|
+
});
|
|
88
|
+
var blockedLead = (raw) => {
|
|
89
|
+
const profileUrl = text(raw.profileUrl);
|
|
90
|
+
if (profileUrl !== null) {
|
|
91
|
+
return { kind: "linkedin", value: profileUrl };
|
|
92
|
+
}
|
|
93
|
+
const email = emailAddress(raw.email);
|
|
94
|
+
if (email !== null) {
|
|
95
|
+
return { kind: "email", value: email };
|
|
96
|
+
}
|
|
97
|
+
const name = text(raw.fullName);
|
|
98
|
+
return name === null ? null : { kind: "other", value: name };
|
|
99
|
+
};
|
|
100
|
+
var toBlockedLead = (identity, raw) => {
|
|
101
|
+
const entry = blockedLead(raw);
|
|
102
|
+
const id = text(raw.id);
|
|
103
|
+
return entry === null || id === null ? [] : [
|
|
104
|
+
{
|
|
105
|
+
...recordBase(identity, `lead-${id}`, raw),
|
|
106
|
+
...entry,
|
|
107
|
+
createdAt: timestamp(raw.creationTime)
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
};
|
|
111
|
+
var toBlockedCompany = (identity, raw) => {
|
|
112
|
+
const value = text(raw.companyName) ?? text(raw.linkedInUrl);
|
|
113
|
+
const id = text(raw.id);
|
|
114
|
+
return value === null || id === null ? [] : [
|
|
115
|
+
{
|
|
116
|
+
...recordBase(identity, `company-${id}`, raw),
|
|
117
|
+
createdAt: timestamp(raw.creationTime),
|
|
118
|
+
kind: "company",
|
|
119
|
+
value
|
|
120
|
+
}
|
|
121
|
+
];
|
|
122
|
+
};
|
|
123
|
+
var webhookCampaigns = (raw) => list(raw.campaignIds).flatMap((id) => {
|
|
124
|
+
const campaign = text(id);
|
|
125
|
+
return campaign === null ? [] : [campaign];
|
|
126
|
+
});
|
|
127
|
+
var toWebhook = (identity, raw) => {
|
|
128
|
+
const campaigns = webhookCampaigns(raw);
|
|
129
|
+
const event = text(raw.eventType);
|
|
130
|
+
return {
|
|
131
|
+
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
132
|
+
active: flag(raw.isActive),
|
|
133
|
+
campaignRefs: refsTo(identity, campaigns),
|
|
134
|
+
createdAt: null,
|
|
135
|
+
// The list names an event in upper case; a payload names it in lower.
|
|
136
|
+
eventTypes: eventTypesOf(
|
|
137
|
+
event === null ? [] : [event.toLowerCase()],
|
|
138
|
+
EVENT_TYPES
|
|
139
|
+
),
|
|
140
|
+
events: event === null ? [] : [event],
|
|
141
|
+
name: text(raw.webhookName),
|
|
142
|
+
url: text(raw.webhookUrl) ?? ""
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
var CONNECTED = /* @__PURE__ */ new Map([
|
|
146
|
+
["Connected", true],
|
|
147
|
+
["Disconnected", false]
|
|
148
|
+
]);
|
|
149
|
+
var toSenderHealth = (identity, senderId, raw) => {
|
|
150
|
+
const reason = text(raw.failureReason);
|
|
151
|
+
return {
|
|
152
|
+
...recordBase(identity, senderId, raw),
|
|
153
|
+
blacklisted: null,
|
|
154
|
+
checkedAt: null,
|
|
155
|
+
connected: CONNECTED.get(text(raw.status) ?? "") ?? null,
|
|
156
|
+
dns: { dkim: null, dmarc: null, mx: null, spf: null },
|
|
157
|
+
domain: null,
|
|
158
|
+
issues: reason === null ? [] : [reason],
|
|
159
|
+
senderRef: refTo(identity, senderId) ?? "",
|
|
160
|
+
warmup: null
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// src/heyreach/map.ts
|
|
165
|
+
var CAMPAIGN_STATUS = /* @__PURE__ */ new Map([
|
|
166
|
+
["CANCELED", "completed"],
|
|
167
|
+
["DRAFT", "draft"],
|
|
168
|
+
["FINISHED", "completed"],
|
|
169
|
+
["IN_PROGRESS", "active"],
|
|
170
|
+
["PAUSED", "paused"],
|
|
171
|
+
["SCHEDULED", "draft"],
|
|
172
|
+
["STARTING", "active"]
|
|
173
|
+
]);
|
|
174
|
+
var vendorStatuses = (status) => status === "unknown" ? ["FAILED"] : [...CAMPAIGN_STATUS.entries()].flatMap(
|
|
175
|
+
([vendor, mapped]) => mapped === status ? [vendor] : []
|
|
176
|
+
);
|
|
177
|
+
var toCampaign = (identity, raw) => ({
|
|
178
|
+
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
179
|
+
channel: "linkedin",
|
|
180
|
+
createdAt: timestamp(raw.creationTime),
|
|
181
|
+
name: text(raw.name) ?? text(raw.id) ?? "",
|
|
182
|
+
status: CAMPAIGN_STATUS.get(text(raw.status) ?? "") ?? "unknown",
|
|
183
|
+
tags: []
|
|
184
|
+
});
|
|
185
|
+
var senderStatus = (raw) => {
|
|
186
|
+
if (flag(raw.authIsValid) === false) {
|
|
187
|
+
return "disconnected";
|
|
188
|
+
}
|
|
189
|
+
const active = flag(raw.isActive);
|
|
190
|
+
if (active === null) {
|
|
191
|
+
return "unknown";
|
|
192
|
+
}
|
|
193
|
+
return active ? "active" : "paused";
|
|
194
|
+
};
|
|
195
|
+
var toSender = (identity, raw) => ({
|
|
196
|
+
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
197
|
+
// `emailAddress` is the account's login, not an address mail is sent from.
|
|
198
|
+
address: null,
|
|
199
|
+
dailyLimit: null,
|
|
200
|
+
kind: "linkedin",
|
|
201
|
+
linkedinUrl: text(raw.profileUrl),
|
|
202
|
+
mailProvider: null,
|
|
203
|
+
name: fullName(raw.firstName, raw.lastName),
|
|
204
|
+
status: senderStatus(raw),
|
|
205
|
+
// HeyReach has no tags on a LinkedIn account.
|
|
206
|
+
tags: [],
|
|
207
|
+
warmup: null
|
|
208
|
+
});
|
|
209
|
+
var LEAD_PROGRESS = /* @__PURE__ */ new Map([
|
|
210
|
+
["Finished", "completed"],
|
|
211
|
+
["InSequence", "active"],
|
|
212
|
+
["Paused", "paused"],
|
|
213
|
+
["Pending", "active"]
|
|
214
|
+
]);
|
|
215
|
+
var campaignProgress = (value) => LEAD_PROGRESS.get(text(value) ?? "") ?? "unknown";
|
|
216
|
+
var standing = (progress, messageStatus) => {
|
|
217
|
+
const said = text(messageStatus);
|
|
218
|
+
return leadStanding(progress, {
|
|
219
|
+
bounced: null,
|
|
220
|
+
replied: said === null ? null : said === "MessageReply",
|
|
221
|
+
unsubscribed: null
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
var tagNames = (value) => list(value).flatMap((tag) => {
|
|
225
|
+
const name = text(tag);
|
|
226
|
+
return name === null ? [] : [name];
|
|
227
|
+
});
|
|
228
|
+
var interest = (profile) => {
|
|
229
|
+
const [newest] = objects(field(profile, "autoTags")).toSorted(
|
|
230
|
+
(left, right) => (timestamp(right.creationTime) ?? "").localeCompare(
|
|
231
|
+
timestamp(left.creationTime) ?? ""
|
|
232
|
+
)
|
|
233
|
+
);
|
|
234
|
+
return text(newest?.name);
|
|
235
|
+
};
|
|
236
|
+
var AUTO_TAG = /* @__PURE__ */ new Map([
|
|
237
|
+
["generic", "neutral"],
|
|
238
|
+
["interested", "positive"],
|
|
239
|
+
["not interested", "negative"]
|
|
240
|
+
]);
|
|
241
|
+
var interestCategory = (profile) => AUTO_TAG.get(interest(profile)?.toLowerCase() ?? "") ?? null;
|
|
242
|
+
var customFields = (profile) => Object.fromEntries(
|
|
243
|
+
objects(field(profile, "customFields")).flatMap((pair) => {
|
|
244
|
+
const name = text(pair.name);
|
|
245
|
+
const value = text(pair.value);
|
|
246
|
+
return name === null || value === null ? [] : [[name, value]];
|
|
247
|
+
})
|
|
248
|
+
);
|
|
249
|
+
var profileFields = (identity, profile, raw) => ({
|
|
250
|
+
...recordBase(
|
|
251
|
+
identity,
|
|
252
|
+
text(field(profile, "profileUrl")) ?? text(field(profile, "linkedin_id")) ?? "",
|
|
253
|
+
raw
|
|
254
|
+
),
|
|
255
|
+
company: text(field(profile, "companyName")),
|
|
256
|
+
// `companyUrl` is the company's LinkedIn page, not its website.
|
|
257
|
+
companyLinkedinUrl: text(field(profile, "companyUrl")),
|
|
258
|
+
custom: customFields(profile),
|
|
259
|
+
email: emailAddress(field(profile, "emailAddress")) ?? emailAddress(field(profile, "enrichedEmailAddress")) ?? emailAddress(field(profile, "customEmailAddress")),
|
|
260
|
+
// HeyReach reports no per-lead open, click or reply counts.
|
|
261
|
+
engagement: null,
|
|
262
|
+
firstName: text(field(profile, "firstName")),
|
|
263
|
+
interest: interest(profile),
|
|
264
|
+
interestCategory: interestCategory(profile),
|
|
265
|
+
lastName: text(field(profile, "lastName")),
|
|
266
|
+
tags: tagNames(field(profile, "tags")),
|
|
267
|
+
linkedinUrl: text(field(profile, "profileUrl")),
|
|
268
|
+
location: text(field(profile, "location")),
|
|
269
|
+
// HeyReach profiles carry no phone number and no company website.
|
|
270
|
+
phone: null,
|
|
271
|
+
title: text(field(profile, "position")),
|
|
272
|
+
website: null
|
|
273
|
+
});
|
|
274
|
+
var toLead = (identity, raw, tags) => {
|
|
275
|
+
const lead = profileFields(identity, raw, raw);
|
|
276
|
+
return {
|
|
277
|
+
...lead,
|
|
278
|
+
...standing("unknown"),
|
|
279
|
+
campaignRef: null,
|
|
280
|
+
createdAt: null,
|
|
281
|
+
tags: tags === void 0 ? lead.tags : tagNames(tags)
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
var toCampaignLead = (identity, raw, campaignId) => ({
|
|
285
|
+
...profileFields(identity, raw.linkedInUserProfile, raw),
|
|
286
|
+
...standing(
|
|
287
|
+
campaignProgress(raw.leadCampaignStatus),
|
|
288
|
+
raw.leadMessageStatus ?? null
|
|
289
|
+
),
|
|
290
|
+
campaignRef: refTo(identity, campaignId),
|
|
291
|
+
createdAt: timestamp(raw.creationTime)
|
|
292
|
+
});
|
|
293
|
+
var profileEmails = (profile) => [
|
|
294
|
+
profile.emailAddress,
|
|
295
|
+
profile.enrichedEmailAddress,
|
|
296
|
+
profile.customEmailAddress,
|
|
297
|
+
...list(profile.emailEnrichments)
|
|
298
|
+
].flatMap((value) => emailAddress(value) ?? []);
|
|
299
|
+
var toLookupLead = (identity, profile, campaign, email) => {
|
|
300
|
+
const raw = { campaign, lead: profile };
|
|
301
|
+
const lead = profileFields(identity, profile, raw);
|
|
302
|
+
return {
|
|
303
|
+
...lead,
|
|
304
|
+
...standing(campaignProgress(campaign?.leadStatus)),
|
|
305
|
+
campaignRef: refTo(identity, text(campaign?.campaignId)),
|
|
306
|
+
createdAt: null,
|
|
307
|
+
email: email ?? lead.email
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
var listEnvelope = (body, offset) => {
|
|
311
|
+
const items = objects(isJsonObject(body) ? body.items : void 0);
|
|
312
|
+
const total = count(field(body, "totalCount"));
|
|
313
|
+
const end = offset + items.length;
|
|
314
|
+
return {
|
|
315
|
+
items,
|
|
316
|
+
next: items.length > 0 && total !== null && end < total ? end : void 0
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// src/heyreach/capabilities.ts
|
|
321
|
+
var BASE_URL = "https://api.heyreach.io/api/public";
|
|
322
|
+
var API_KEY_ENV = "HEYREACH_API_KEY";
|
|
323
|
+
var WORKSPACE_ENV = "HEYREACH_WORKSPACE_ID";
|
|
324
|
+
var PAGE_SIZE = 100;
|
|
325
|
+
var LIST_LEADS_PAGE_SIZE = 1e3;
|
|
326
|
+
var capabilities = {
|
|
327
|
+
// POST /blacklist/GetLeads, then POST /blacklist/GetCompanies.
|
|
328
|
+
blocklist: true,
|
|
329
|
+
// POST /campaign/GetAll takes an `accountIds` array.
|
|
330
|
+
"campaigns.bySender": true,
|
|
331
|
+
// GET /campaign/GetById carries progressStats.
|
|
332
|
+
"campaigns.progress": true,
|
|
333
|
+
// A campaign's schedule can only be written (POST /campaign/UpdateSchedule).
|
|
334
|
+
// GET /campaign/GetById returns no schedule, limits or stop rules.
|
|
335
|
+
"campaigns.settings": false,
|
|
336
|
+
// POST /campaign/GetAll takes a `statuses` array.
|
|
337
|
+
"campaigns.status": "server",
|
|
338
|
+
"events.parse": true,
|
|
339
|
+
// HeyReach documents no signature. A webhook can carry a static custom header.
|
|
340
|
+
"events.verify": "secret",
|
|
341
|
+
// POST /campaign/GetLeadsFromCampaign.
|
|
342
|
+
"leads.byCampaign": true,
|
|
343
|
+
// No lead shape carries open, click or reply counts.
|
|
344
|
+
"leads.engagement": false,
|
|
345
|
+
"leads.get": true,
|
|
346
|
+
// No endpoint lists every lead, so the adapter walks the campaigns and
|
|
347
|
+
// reads each one's leads, as it does for a vendor that lists per campaign.
|
|
348
|
+
"leads.list": true,
|
|
349
|
+
// POST /campaign/GetCampaignsForLead takes an email or a profile URL, and
|
|
350
|
+
// POST /lead/GetLead gives the profile.
|
|
351
|
+
"leads.lookup": true,
|
|
352
|
+
// GetLeadsFromCampaign and GetLeadsFromList both filter by creation time.
|
|
353
|
+
"leads.since": "server",
|
|
354
|
+
// Messages live inside conversations (POST /inbox/GetConversationsV3). A
|
|
355
|
+
// lead's timeline is the conversations filtered to its profile URL.
|
|
356
|
+
"leads.timeline": true,
|
|
357
|
+
// GET /list/GetById.
|
|
358
|
+
"lists.get": true,
|
|
359
|
+
// POST /list/GetLeadsFromList.
|
|
360
|
+
"lists.leads": true,
|
|
361
|
+
// POST /list/GetAll.
|
|
362
|
+
"lists.list": true,
|
|
363
|
+
"messages.body": "full",
|
|
364
|
+
// GET /inbox/GetChatroom/{accountId}/{conversationId}.
|
|
365
|
+
"messages.byThread": true,
|
|
366
|
+
"messages.list": true,
|
|
367
|
+
// GetConversationsV3 bounds conversations by the time of their newest
|
|
368
|
+
// message (`from`); the adapter then drops the older messages inside them.
|
|
369
|
+
"messages.since": "server",
|
|
370
|
+
// A reply takes the meaning of its lead's newest auto-tag, and the filter
|
|
371
|
+
// is applied to that after fetching.
|
|
372
|
+
"replies.category": "vendor",
|
|
373
|
+
// GetConversationsV3 takes `seen`.
|
|
374
|
+
"replies.unread": "server",
|
|
375
|
+
"replies.list": true,
|
|
376
|
+
"replies.since": "server",
|
|
377
|
+
// GET /campaign/GetById names the campaign's account ids; the account list
|
|
378
|
+
// is narrowed to them.
|
|
379
|
+
"senders.byCampaign": true,
|
|
380
|
+
"senders.get": true,
|
|
381
|
+
// GET /li_account/GetAccountStatus/{accountId}.
|
|
382
|
+
"senders.health": true,
|
|
383
|
+
"senders.list": true,
|
|
384
|
+
// LinkedIn accounts have no warmup.
|
|
385
|
+
"senders.warmup": false,
|
|
386
|
+
sequence: true,
|
|
387
|
+
// A campaign has one sequence tree and nothing attached to it.
|
|
388
|
+
"sequence.subsequences": false,
|
|
389
|
+
"stats.byDay": "exact",
|
|
390
|
+
// GetOverallStats filtered to one account id.
|
|
391
|
+
"stats.bySender": "exact",
|
|
392
|
+
"stats.byStep": false,
|
|
393
|
+
// POST /stats/GetOverallStatsByCampaign: the counts of GetOverallStats,
|
|
394
|
+
// a row per campaign.
|
|
395
|
+
"stats.allCampaigns": "full",
|
|
396
|
+
"stats.campaign": "exact",
|
|
397
|
+
"stats.workspace": "exact",
|
|
398
|
+
// Tags can be created (POST /lead_tags/CreateTags) and read per lead
|
|
399
|
+
// (POST /lead/GetTags), but no endpoint lists the workspace's tags.
|
|
400
|
+
tags: false,
|
|
401
|
+
// Every other documented read, by name: see native.ts.
|
|
402
|
+
native: true,
|
|
403
|
+
// GET /webhooks/GetWebhookById, always asked for without custom headers.
|
|
404
|
+
"webhooks.get": true,
|
|
405
|
+
// POST /webhooks/GetAllWebhooks.
|
|
406
|
+
"webhooks.list": true,
|
|
407
|
+
// CheckApiKey returns no identity and only an organization key can list workspaces.
|
|
408
|
+
workspaces: false
|
|
409
|
+
};
|
|
410
|
+
var fields = {
|
|
411
|
+
campaign: { tags: false },
|
|
412
|
+
campaignProgress: { blocked: false },
|
|
413
|
+
campaignSettings: false,
|
|
414
|
+
lead: {
|
|
415
|
+
// LinkedIn has no bounce and no unsubscribe.
|
|
416
|
+
bounced: false,
|
|
417
|
+
engagement: false,
|
|
418
|
+
phone: false,
|
|
419
|
+
unsubscribed: false,
|
|
420
|
+
website: false
|
|
421
|
+
},
|
|
422
|
+
message: { bodyHtml: false, stepIndex: false, variantKey: false },
|
|
423
|
+
metricRow: {
|
|
424
|
+
bounced: false,
|
|
425
|
+
clicked: false,
|
|
426
|
+
clickedTotal: false,
|
|
427
|
+
contentHash: false,
|
|
428
|
+
delivered: false,
|
|
429
|
+
opened: false,
|
|
430
|
+
openedTotal: false,
|
|
431
|
+
repliedAuto: false,
|
|
432
|
+
stepIndex: false,
|
|
433
|
+
unsubscribed: false,
|
|
434
|
+
variantKey: false
|
|
435
|
+
},
|
|
436
|
+
// LinkedIn has no inbox placement.
|
|
437
|
+
placementTest: false,
|
|
438
|
+
reply: {
|
|
439
|
+
bodyHtml: false,
|
|
440
|
+
// The lead's newest auto-tag, not a label on the message.
|
|
441
|
+
category: "derived",
|
|
442
|
+
categorySource: "derived",
|
|
443
|
+
isAuto: false,
|
|
444
|
+
stepIndex: false,
|
|
445
|
+
variantKey: false
|
|
446
|
+
},
|
|
447
|
+
sender: {
|
|
448
|
+
address: false,
|
|
449
|
+
dailyLimit: false,
|
|
450
|
+
mailProvider: false,
|
|
451
|
+
tags: false,
|
|
452
|
+
warmup: false
|
|
453
|
+
},
|
|
454
|
+
senderHealth: {
|
|
455
|
+
blacklisted: false,
|
|
456
|
+
checkedAt: false,
|
|
457
|
+
dns: false,
|
|
458
|
+
domain: false,
|
|
459
|
+
warmup: false
|
|
460
|
+
},
|
|
461
|
+
sequence: { name: false },
|
|
462
|
+
tag: false,
|
|
463
|
+
webhook: { createdAt: false },
|
|
464
|
+
workspace: false
|
|
465
|
+
};
|
|
466
|
+
var limits = {
|
|
467
|
+
source: "https://docs.heyreach.io/hey-reach-api.md (300 requests per minute, all requests on one limit); read 2026-11-14. Seen live the same day: a burst limit of 15 requests per 2 seconds, which the docs do not mention. The docs do not say whether the limit is per key, per workspace or per organization, and document no rate-limit headers or Retry-After",
|
|
468
|
+
// The Organization Management API has a separate limit of 300 requests a
|
|
469
|
+
// minute (https://docs.heyreach.io/hey-reach-api/organization.md).
|
|
470
|
+
lanes: { organization: [{ perMs: 6e4, requests: 300 }] },
|
|
471
|
+
// The burst limit is not documented. The live API answers 429 with "Limit
|
|
472
|
+
// is 15 requests per 2 second(s)" (seen 2026-11-14), well before the
|
|
473
|
+
// documented 300 a minute is reached.
|
|
474
|
+
windows: [
|
|
475
|
+
{ perMs: 2e3, requests: 15 },
|
|
476
|
+
{ perMs: 6e4, requests: 300 }
|
|
477
|
+
]
|
|
478
|
+
};
|
|
479
|
+
var costs = {
|
|
480
|
+
"blocklist.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
481
|
+
"campaigns.get": { perPage: 1 },
|
|
482
|
+
"campaigns.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
483
|
+
// The profile and its tags are two requests.
|
|
484
|
+
"leads.get": { perPage: 2 },
|
|
485
|
+
// A campaign's leads. A saved list's leads come up to 1000 a page. Without
|
|
486
|
+
// a campaign or a list, each new page of campaigns costs one more request.
|
|
487
|
+
"leads.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
488
|
+
// One person by profile URL: the campaigns and the profile, two requests.
|
|
489
|
+
// By email it is three (campaigns, the lists the address is in, a name
|
|
490
|
+
// search in one list) and one more per profile read to find the address,
|
|
491
|
+
// eight at most; a later page is two again.
|
|
492
|
+
"leads.lookup": { pageSize: PAGE_SIZE, perPage: 2 },
|
|
493
|
+
"lists.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
494
|
+
// One conversation by thread id is a single request.
|
|
495
|
+
"messages.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
496
|
+
"replies.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
497
|
+
"senders.get": { perPage: 1 },
|
|
498
|
+
"senders.health": { perPage: 1 },
|
|
499
|
+
// A campaign's senders cost one more request, once, to read the campaign.
|
|
500
|
+
"senders.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
501
|
+
"sequence.get": { perPage: 1 },
|
|
502
|
+
stats: { perPage: 1 },
|
|
503
|
+
"webhooks.list": { pageSize: PAGE_SIZE, perPage: 1 }
|
|
504
|
+
};
|
|
505
|
+
var caveats = [
|
|
506
|
+
"Checked read-only against one live HeyReach workspace on 2026-11-14: campaigns, sequences, senders, a campaign's senders, sender health, a campaign's leads, lead lists, a list's leads, lead lookup, the blacklist, the webhook list, stats, messages, replies, one conversation by thread id and a lead's timeline all returned valid records. Other workspaces, plans and campaign layouts have not been seen. That workspace had no webhooks, no blacklisted leads and no company lists, so those three shapes come from the documentation alone. Webhook payloads were not checked. The fixtures are built by hand from documented and observed field names, not captured responses.",
|
|
507
|
+
"Added from the API reference after that live check and not run against a live workspace: leads.list without a campaign (the walk over campaigns), a sender's campaigns (accountIds on the campaign list), stats for every campaign as normalized rows, the unread filter (seen), a reply's category from its lead's auto-tag, lists.get and webhooks.get.",
|
|
508
|
+
"The 300 requests per minute limit is documented without a scope (key, workspace or organization) and without rate-limit headers, and the workspace's n8n, Make, Zapier and MCP keys may draw on the same budget.",
|
|
509
|
+
"Lists return totalCount and no next marker, so the end of a list is computed as offset plus page length reaching totalCount.",
|
|
510
|
+
"The campaign list's item fields come from a schema that disagrees with the documented GetById example; only id, name, creationTime and status are read. HeyReach campaigns have no tags.",
|
|
511
|
+
"A campaign's settings cannot be read: the schedule, start and end dates are write-only (UpdateSchedule) and GetById returns none of them. Sending limits belong to the LinkedIn account, not the campaign. The exclusion switches GetById does return stay in raw.",
|
|
512
|
+
"A campaign's senders are the account list narrowed to the campaign's campaignAccountIds, so an account that was removed from the workspace is left out and a page can come back short or empty.",
|
|
513
|
+
"A sender's health is its connection state only: connected is true for the status Connected and false for Disconnected, the two values seen; any other status is null. failureReason is the one issue reported. HeyReach caches the status for 10 seconds and gives no check time.",
|
|
514
|
+
"Campaign statuses are documented by name only. STARTING is mapped to active, SCHEDULED to draft, CANCELED to completed and FAILED to unknown.",
|
|
515
|
+
"A sender's status is derived from two undefined booleans: authIsValid false is disconnected, otherwise isActive true is active and false is paused.",
|
|
516
|
+
"A sender's dailyLimit is null: accountLimits holds several limit pairs and the docs do not say which are daily or what Limit and Max mean. They stay in raw.",
|
|
517
|
+
"A lead's id is its LinkedIn profile URL, the only key GetLead accepts and the only one present in every lead shape. The docs do not say the URL has one canonical form.",
|
|
518
|
+
"A lead is looked up by profile URL with two requests (GetCampaignsForLead and GetLead) and returned once per campaign it is in. A lead's id is its profile URL in every campaign, so a person's records share one ref and differ by campaignRef. The timeline is the lead's whole conversation history, the same on each of its records.",
|
|
519
|
+
"A looked-up lead's status follows leadStatus and never says replied, because GetCampaignsForLead reports no message status; Excluded and PendingOrExcludedToBeCalculated are unknown. createdAt is null (the creationTime beside a campaign is the campaign's), tags are empty and interest is null. A lookup cannot be combined with a saved list or a date range.",
|
|
520
|
+
"HeyReach matches a profile URL whatever its scheme, www prefix, trailing slash or query, but by exact case: seen live, a slug sent in upper case is not found. The lookup sends the slug lowercased, so a profile HeyReach stores with upper-case letters would not be found. A slug with non-ASCII letters is sent percent-encoded; how HeyReach stores one is not known.",
|
|
521
|
+
"No HeyReach read returns a profile for an email address. An email lookup asks for the campaigns (which names the person), then one saved list the address is in, searches that list for the name (5 rows at most) and reads each match's profile until one carries the address: four requests in the usual case. An address that is in no saved list, or whose profile is not among those rows, gives an empty page although HeyReach knows it. The record's email is the address asked for, which the profile may hold as its enriched or custom address.",
|
|
522
|
+
"Lookup was checked against one live lead in one campaign. A person in several campaigns (and so a second page of campaigns) and a known person in no campaign were not seen; an empty campaign answer and a 404 from GetCampaignsForLead are both read as no campaigns.",
|
|
523
|
+
"No endpoint lists every lead. leads.list without a campaign or a saved list walks every campaign and reads its leads: a lead in no campaign is never returned, one in several campaigns comes once per campaign from list and once from listAll, and the walk costs a request per page of campaigns on top of the lead pages. Saved lists are not walked: a list row carries no campaign or status, and a lead can sit in several lists.",
|
|
524
|
+
"A saved list's leads carry tags, custom fields and the auto-tag but no status, campaign or creation time, although the list can be filtered by when a lead was added. A company list's rows are companies, not leads, and are not mapped: read them with outbound.native.reads.companiesFromList.",
|
|
525
|
+
"A lead's interest is the name of its newest auto-tag (Interested, Not interested and Generic were seen live; the API reference does not list the names). It is present on a list's leads and absent from a campaign's leads and from lead lookup, where it is null.",
|
|
526
|
+
"A lead's tags come from the list row, or from a second request (POST /lead/GetTags) on lead lookup. A campaign's leads carry no tags, so theirs are empty.",
|
|
527
|
+
"No lead shape carries open, click or reply counts, so engagement is always null. lastActionTime, leadConnectionStatus and leadMessageStatus stay in raw.",
|
|
528
|
+
"A campaign's lead list was seen live to include finished leads, although the documentation describes it as pending leads only.",
|
|
529
|
+
"A lead's status is replied when leadMessageStatus is MessageReply, otherwise it follows leadCampaignStatus with Pending as active. Failed has no equivalent and is unknown.",
|
|
530
|
+
"A lead's email falls back from emailAddress to enrichedEmailAddress to customEmailAddress. The docs do not say which of the three is the newest.",
|
|
531
|
+
"A sequence is a node tree and every node that acts on the lead is a step. Steps are numbered node first, then its conditional branch, then its unconditional branch, so an index is stable until the tree is edited. CHECK_ nodes are conditions, not steps: the steps under one share its parent and carry its outcome as their branch, so a campaign that opens with CHECK_IS_CONNECTION has two steps with no parent.",
|
|
532
|
+
"Branch names are ours for the documented conditions: accepted and not_accepted after CONNECTION_REQUEST, connected and not_connected after CHECK_IS_CONNECTION, open_profile and not_open_profile after CHECK_IS_OPEN_PROFILE, email_found and email_not_found after FIND_EMAIL. Two conditions in a row are joined with a plus sign. Any other node with steps on its conditional branch uses HeyReach's own words, conditional and unconditional. Only the CONNECTION_REQUEST and CHECK_IS_CONNECTION layouts were seen live.",
|
|
533
|
+
"The step after a MESSAGE or INMAIL has no branch: a reply ends the sequence, so every later step already means the lead has not replied. A step's delayDays includes the wait of any CHECK_ node between it and its parent.",
|
|
534
|
+
"Sequence variants come from payload.messages (or messageVersions), which the docs describe as A/B variants for MESSAGE nodes only; INMAIL and LIKE_POST payloads are not documented.",
|
|
535
|
+
"Stats: replied is totalMessageReplies plus totalInmailReplies. contacted is uniqueLeadsContacted and positive is autoTaggedInterested; the live API returns both but the API reference lists neither, so they are null when absent. totalMessageStarted and totalInmailStarted are not defined in the docs and are not read.",
|
|
536
|
+
"Daily stats are keyed by UTC midnight; the docs do not say which timezone buckets a day or whether endDate is inclusive. Stats need both from and to, or neither.",
|
|
537
|
+
"Messages and replies are read from conversations. Checked against one live workspace on 2026-11-14: sender is ME or CORRESPONDENT, and each of 257 conversations carried its whole thread (longest read: 40 messages). Whether a longer thread is cut short is not known.",
|
|
538
|
+
"Conversations are listed with GetConversationsV3, which pages by cursor and bounds a conversation by the time of its newest message. A since filter is sent as that lower bound and the older messages inside each conversation are then dropped, so a page can hold fewer messages than its conversations do. An until filter cannot be sent, because a conversation that continued past it still holds earlier messages; it is applied after fetching. A page marker saved from before the move to V3 (a number) is not valid and starts from the first page.",
|
|
539
|
+
"A message's id is built from the conversation, the time, the side and the text, so an edited message gets a new id. The live API now returns a messageId the API reference does not list; it stays in raw so that existing ids do not change.",
|
|
540
|
+
"A message's threadId is the LinkedIn account id and the conversation id joined by a colon, because one conversation can only be read back with both. A thread read returns the whole conversation in one page and does not know its campaign, so campaignRef is null.",
|
|
541
|
+
"A message's campaign is known only when the listing is filtered to one campaign; otherwise campaignRef is null. A page is a page of conversations, so it can hold more messages than the limit asked for.",
|
|
542
|
+
"A reply's category is its lead's: HeyReach's auto-tag is made from a lead's first campaign reply and stored on the lead, with no link to a message, so every reply of a conversation takes the lead's newest one (categorySource: lead). Interested is positive, Not Interested negative and Generic neutral, matched without case; any other name is unknown. Filtering replies by category is done after fetching, so a page can come back short. unread is the conversation's read flag, the same on each of its replies.",
|
|
543
|
+
"The blacklist is two lists read one after the other, leads then companies. An entry's id is prefixed lead- or company- because the two are numbered separately. A blacklisted lead's value is its profile URL, else its email, else its name (kind other); a company's is its name, else its LinkedIn page. matchingStatus and resolutionStage stay in raw.",
|
|
544
|
+
"A webhook subscription lists one event type. Filtering webhooks by campaign is done after fetching and keeps webhooks that cover every campaign. Custom headers are never requested, because they can hold a secret; a request for one webhook by id (native webhookById, or raw) is always sent with includeCustomHeaders=false. HeyReach gives a webhook no creation time.",
|
|
545
|
+
"Native reads return HeyReach's own payloads. Checked read-only against the same live workspace on 2026-11-14: checkApiKey, listById, campaignsForLead, myNetworkForSender, isConnection, campaignSequenceV2, statsByCampaign, proxyCountries, conversationsV2, voices, staticClips, elevenLabsConnection, elevenLabsVoices and voiceUsage answered 200; listsForLead, staticClip, senderVoice, webhookById and enrichEmailJob answered a documented 404 because the workspace had nothing to return; companiesFromList answered 400 for a lead list, the workspace having no company list. The five organization reads answer 401 with a workspace key and were not seen with an organization key.",
|
|
546
|
+
"Three documented reads are not offered: the workspace API keys and a LinkedIn account's proxy (both return secrets, and raw refuses them), and a voice message's audio file, which is not JSON and would not survive the request engine, which reads every body as text. A voice message's transcript and duration are in its conversation.",
|
|
547
|
+
"The workspace's tags cannot be listed: the API creates tags and reads one lead's tags, nothing more. A tag has a name and a colour and no id.",
|
|
548
|
+
"Only the voice_note_received webhook payload is documented. Other events are assumed to share its skeleton, and the lowercase event_type names are inferred from two examples.",
|
|
549
|
+
"Webhooks are not signed; correlation_id is the only identifier and is assumed to be stable across redelivery."
|
|
550
|
+
];
|
|
551
|
+
|
|
552
|
+
// src/heyreach/paging.ts
|
|
553
|
+
var pageSize = (limit, max = PAGE_SIZE) => Math.min(limit ?? max, max);
|
|
554
|
+
var offsetOf = (next) => isNumber(next) ? next : 0;
|
|
555
|
+
var numericId = (client, id, what) => {
|
|
556
|
+
if (!/^\d+$/u.test(id)) {
|
|
557
|
+
throw new OutboundError(
|
|
558
|
+
"Invalid",
|
|
559
|
+
`HeyReach ${what} ids are whole numbers, got "${id}"`,
|
|
560
|
+
{ provider: client.identity.provider }
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
return Number(id);
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// src/heyreach/account.ts
|
|
567
|
+
var COMPANIES = "companies";
|
|
568
|
+
var blocklistCursor = (next) => ({
|
|
569
|
+
companies: field(next, "list") === COMPANIES,
|
|
570
|
+
offset: count(field(next, "offset")) ?? 0
|
|
571
|
+
});
|
|
572
|
+
var listBlocklist = (client) => async (query, ctx) => {
|
|
573
|
+
const { companies, offset } = blocklistCursor(query.next);
|
|
574
|
+
const envelope = listEnvelope(
|
|
575
|
+
await client.post(
|
|
576
|
+
ctx,
|
|
577
|
+
companies ? "/blacklist/GetCompanies" : "/blacklist/GetLeads",
|
|
578
|
+
{ limit: pageSize(query.limit), offset }
|
|
579
|
+
),
|
|
580
|
+
offset
|
|
581
|
+
);
|
|
582
|
+
const toEntries = companies ? toBlockedCompany : toBlockedLead;
|
|
583
|
+
const items = envelope.items.flatMap(
|
|
584
|
+
(item) => toEntries(client.identity, item)
|
|
585
|
+
);
|
|
586
|
+
if (envelope.next !== void 0) {
|
|
587
|
+
return {
|
|
588
|
+
items,
|
|
589
|
+
next: { list: companies ? COMPANIES : "leads", offset: envelope.next }
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
return companies ? { items } : { items, next: { list: COMPANIES, offset: 0 } };
|
|
593
|
+
};
|
|
594
|
+
var accountReaders = (client) => ({
|
|
595
|
+
getSenderHealth: async (id, ctx) => {
|
|
596
|
+
const path = `/li_account/GetAccountStatus/${numericId(client, id, "account")}`;
|
|
597
|
+
return toSenderHealth(
|
|
598
|
+
client.identity,
|
|
599
|
+
id,
|
|
600
|
+
client.object(await client.get(ctx, path), path)
|
|
601
|
+
);
|
|
602
|
+
},
|
|
603
|
+
getCampaignProgress: async (id, ctx) => {
|
|
604
|
+
const path = "/campaign/GetById";
|
|
605
|
+
return toCampaignProgress(
|
|
606
|
+
client.identity,
|
|
607
|
+
id,
|
|
608
|
+
client.object(
|
|
609
|
+
await client.get(ctx, path, {
|
|
610
|
+
query: { campaignId: numericId(client, id, "campaign") }
|
|
611
|
+
}),
|
|
612
|
+
path
|
|
613
|
+
)
|
|
614
|
+
);
|
|
615
|
+
},
|
|
616
|
+
getList: async (id, ctx) => {
|
|
617
|
+
const path = "/list/GetById";
|
|
618
|
+
return toLeadList(
|
|
619
|
+
client.identity,
|
|
620
|
+
client.object(
|
|
621
|
+
await client.get(ctx, path, {
|
|
622
|
+
query: { listId: numericId(client, id, "list") }
|
|
623
|
+
}),
|
|
624
|
+
path
|
|
625
|
+
)
|
|
626
|
+
);
|
|
627
|
+
},
|
|
628
|
+
getWebhook: async (id, ctx) => {
|
|
629
|
+
const path = "/webhooks/GetWebhookById";
|
|
630
|
+
return toWebhook(
|
|
631
|
+
client.identity,
|
|
632
|
+
client.object(
|
|
633
|
+
await client.get(ctx, path, {
|
|
634
|
+
query: { webhookId: numericId(client, id, "webhook") }
|
|
635
|
+
}),
|
|
636
|
+
path
|
|
637
|
+
)
|
|
638
|
+
);
|
|
639
|
+
},
|
|
640
|
+
listBlocklist: listBlocklist(client),
|
|
641
|
+
listLists: async (query, ctx) => {
|
|
642
|
+
const offset = offsetOf(query.next);
|
|
643
|
+
const envelope = listEnvelope(
|
|
644
|
+
await client.post(ctx, "/list/GetAll", {
|
|
645
|
+
limit: pageSize(query.limit),
|
|
646
|
+
offset
|
|
647
|
+
}),
|
|
648
|
+
offset
|
|
649
|
+
);
|
|
650
|
+
return mapPage(envelope, (item) => toLeadList(client.identity, item));
|
|
651
|
+
},
|
|
652
|
+
listWebhooks: async (query, ctx) => {
|
|
653
|
+
const offset = offsetOf(query.next);
|
|
654
|
+
const envelope = listEnvelope(
|
|
655
|
+
await client.post(ctx, "/webhooks/GetAllWebhooks", {
|
|
656
|
+
// Custom headers can hold a shared secret, so they are never asked for.
|
|
657
|
+
includeCustomHeaders: false,
|
|
658
|
+
limit: pageSize(query.limit),
|
|
659
|
+
offset
|
|
660
|
+
}),
|
|
661
|
+
offset
|
|
662
|
+
);
|
|
663
|
+
const { campaignId } = query;
|
|
664
|
+
return {
|
|
665
|
+
// The endpoint has no campaign filter. A webhook with no campaign ids
|
|
666
|
+
// fires for every campaign, so it belongs to each one.
|
|
667
|
+
items: envelope.items.filter((item) => {
|
|
668
|
+
const campaigns = webhookCampaigns(item);
|
|
669
|
+
return campaignId === void 0 || campaigns.length === 0 || campaigns.includes(campaignId);
|
|
670
|
+
}).map((item) => toWebhook(client.identity, item)),
|
|
671
|
+
next: envelope.next
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
var campaignAccountIds = async (client, ctx, query) => {
|
|
676
|
+
const carried = field(query.next, "accountIds");
|
|
677
|
+
if (carried !== void 0) {
|
|
678
|
+
return list(carried).filter((id) => isNumber(id));
|
|
679
|
+
}
|
|
680
|
+
const path = "/campaign/GetById";
|
|
681
|
+
const campaign = client.object(
|
|
682
|
+
await client.get(ctx, path, {
|
|
683
|
+
query: { campaignId: numericId(client, query.campaignId, "campaign") }
|
|
684
|
+
}),
|
|
685
|
+
path
|
|
686
|
+
);
|
|
687
|
+
return list(campaign.campaignAccountIds).filter((id) => isNumber(id));
|
|
688
|
+
};
|
|
689
|
+
var campaignSenders = async (client, ctx, query) => {
|
|
690
|
+
const accountIds = await campaignAccountIds(client, ctx, query);
|
|
691
|
+
if (accountIds.length === 0) {
|
|
692
|
+
return { items: [] };
|
|
693
|
+
}
|
|
694
|
+
const cursor = isJsonObject(query.next) ? query.next.offset : void 0;
|
|
695
|
+
const offset = offsetOf(cursor);
|
|
696
|
+
const envelope = listEnvelope(
|
|
697
|
+
await client.post(ctx, "/li_account/GetAll", {
|
|
698
|
+
limit: pageSize(query.limit),
|
|
699
|
+
offset
|
|
700
|
+
}),
|
|
701
|
+
offset
|
|
702
|
+
);
|
|
703
|
+
return {
|
|
704
|
+
items: envelope.items.filter((item) => isNumber(item.id) && accountIds.includes(item.id)).map((item) => toSender(client.identity, item)),
|
|
705
|
+
next: envelope.next === void 0 ? void 0 : { accountIds, offset: envelope.next }
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
// src/heyreach/inbox.ts
|
|
710
|
+
var CONVERSATIONS_PATH = "/inbox/GetConversationsV3";
|
|
711
|
+
var FROM_LEAD = "CORRESPONDENT";
|
|
712
|
+
var messageFields = (scope, conversation, raw) => {
|
|
713
|
+
const conversationId = text(conversation.id) ?? "";
|
|
714
|
+
const accountId = text(conversation.linkedInAccountId);
|
|
715
|
+
const sentAt = timestamp(raw.createdAt);
|
|
716
|
+
const id = stableId(conversationId, sentAt, text(raw.sender), text(raw.body));
|
|
717
|
+
return {
|
|
718
|
+
...recordBase(scope.identity, id, raw),
|
|
719
|
+
...normalizeBody(text(raw.body), scope.includeBody),
|
|
720
|
+
campaignRef: refTo(scope.identity, scope.campaignId),
|
|
721
|
+
channel: "linkedin",
|
|
722
|
+
// A lead's id is its LinkedIn profile URL, as in leads.get.
|
|
723
|
+
leadRef: refTo(
|
|
724
|
+
scope.identity,
|
|
725
|
+
text(field(conversation.correspondentProfile, "profileUrl"))
|
|
726
|
+
),
|
|
727
|
+
senderRef: refTo(scope.identity, accountId),
|
|
728
|
+
sentAt,
|
|
729
|
+
stepIndex: null,
|
|
730
|
+
// Only InMails have a subject.
|
|
731
|
+
subject: text(raw.subject),
|
|
732
|
+
// Without the account the conversation cannot be read back, so no thread.
|
|
733
|
+
threadId: conversationId === "" || accountId === null ? null : `${accountId}:${conversationId}`,
|
|
734
|
+
variantKey: null
|
|
735
|
+
};
|
|
736
|
+
};
|
|
737
|
+
var isFromLead = (raw) => text(raw.sender) === FROM_LEAD;
|
|
738
|
+
var toMessage = (scope, conversation, raw) => ({
|
|
739
|
+
...messageFields(scope, conversation, raw),
|
|
740
|
+
direction: isFromLead(raw) ? "in" : "out"
|
|
741
|
+
});
|
|
742
|
+
var toReply = (scope, conversation, raw) => {
|
|
743
|
+
const category = interestCategory(conversation.correspondentProfile);
|
|
744
|
+
const read = flag(conversation.read);
|
|
745
|
+
return {
|
|
746
|
+
...messageFields(scope, conversation, raw),
|
|
747
|
+
category: category ?? "unknown",
|
|
748
|
+
categorySource: category === null ? null : "lead",
|
|
749
|
+
direction: "in",
|
|
750
|
+
isAuto: null,
|
|
751
|
+
// `read` is the conversation's, not one message's.
|
|
752
|
+
unread: read === null ? null : !read
|
|
753
|
+
};
|
|
754
|
+
};
|
|
755
|
+
var numeric = (id) => /^\d+$/u.test(id) ? Number(id) : null;
|
|
756
|
+
var readConversations = async (client, ctx, query) => {
|
|
757
|
+
const filters = {};
|
|
758
|
+
const campaign = query.campaignId === void 0 ? null : numeric(query.campaignId);
|
|
759
|
+
if (campaign !== null) {
|
|
760
|
+
filters.campaignIds = [campaign];
|
|
761
|
+
}
|
|
762
|
+
if ("unread" in query && query.unread !== void 0) {
|
|
763
|
+
filters.seen = !query.unread;
|
|
764
|
+
}
|
|
765
|
+
if ("leadId" in query && query.leadId !== void 0) {
|
|
766
|
+
filters.leadProfileUrl = query.leadId;
|
|
767
|
+
}
|
|
768
|
+
const request = {
|
|
769
|
+
filters,
|
|
770
|
+
limit: Math.min(query.limit ?? PAGE_SIZE, PAGE_SIZE)
|
|
771
|
+
};
|
|
772
|
+
if (isString(query.next) && query.next !== "") {
|
|
773
|
+
request.cursor = query.next;
|
|
774
|
+
}
|
|
775
|
+
if (query.since !== void 0) {
|
|
776
|
+
request.from = query.since;
|
|
777
|
+
}
|
|
778
|
+
const body = await client.post(ctx, CONVERSATIONS_PATH, request);
|
|
779
|
+
const next = text(field(body, "nextCursor"));
|
|
780
|
+
return {
|
|
781
|
+
conversations: objects(field(body, "items")),
|
|
782
|
+
next: field(body, "hasNextPage") === true && next !== null ? next : void 0
|
|
783
|
+
};
|
|
784
|
+
};
|
|
785
|
+
var inRange = (sentAt, range) => {
|
|
786
|
+
if (range.since === void 0 && range.until === void 0) {
|
|
787
|
+
return true;
|
|
788
|
+
}
|
|
789
|
+
if (sentAt === null) {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
const time = Date.parse(sentAt);
|
|
793
|
+
return (range.since === void 0 || time >= Date.parse(range.since)) && (range.until === void 0 || time <= Date.parse(range.until));
|
|
794
|
+
};
|
|
795
|
+
var readThread = async (client, ctx, threadId) => {
|
|
796
|
+
const [, accountId, conversationId] = /^(?<account>\d+):(?<conversation>.+)$/u.exec(threadId) ?? [];
|
|
797
|
+
if (accountId === void 0 || conversationId === void 0) {
|
|
798
|
+
throw new OutboundError(
|
|
799
|
+
"Invalid",
|
|
800
|
+
`A HeyReach thread id is "<accountId>:<conversationId>", as a message's threadId gives it, got "${threadId}"`,
|
|
801
|
+
{ provider: client.identity.provider }
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
const path = `/inbox/GetChatroom/${accountId}/${encodeURIComponent(conversationId)}`;
|
|
805
|
+
return client.object(await client.get(ctx, path), path);
|
|
806
|
+
};
|
|
807
|
+
var inboxReaders = (client) => ({
|
|
808
|
+
listMessages: async (query, ctx) => {
|
|
809
|
+
if (query.threadId !== void 0) {
|
|
810
|
+
const conversation = await readThread(client, ctx, query.threadId);
|
|
811
|
+
const scope2 = {
|
|
812
|
+
campaignId: void 0,
|
|
813
|
+
identity: client.identity,
|
|
814
|
+
includeBody: query.includeBody
|
|
815
|
+
};
|
|
816
|
+
return {
|
|
817
|
+
items: objects(conversation.messages).map((raw) => toMessage(scope2, conversation, raw)).filter((message) => inRange(message.sentAt, query))
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
const page2 = await readConversations(client, ctx, query);
|
|
821
|
+
const scope = {
|
|
822
|
+
campaignId: query.campaignId,
|
|
823
|
+
identity: client.identity,
|
|
824
|
+
includeBody: query.includeBody
|
|
825
|
+
};
|
|
826
|
+
return {
|
|
827
|
+
items: page2.conversations.flatMap(
|
|
828
|
+
(conversation) => objects(conversation.messages).map(
|
|
829
|
+
(raw) => toMessage(scope, conversation, raw)
|
|
830
|
+
)
|
|
831
|
+
).filter((message) => inRange(message.sentAt, query)),
|
|
832
|
+
next: page2.next
|
|
833
|
+
};
|
|
834
|
+
},
|
|
835
|
+
listReplies: async (query, ctx) => {
|
|
836
|
+
const page2 = await readConversations(client, ctx, query);
|
|
837
|
+
const scope = {
|
|
838
|
+
campaignId: query.campaignId,
|
|
839
|
+
identity: client.identity,
|
|
840
|
+
includeBody: query.includeBody
|
|
841
|
+
};
|
|
842
|
+
return {
|
|
843
|
+
items: page2.conversations.flatMap(
|
|
844
|
+
(conversation) => objects(conversation.messages).flatMap(
|
|
845
|
+
(raw) => isFromLead(raw) ? [toReply(scope, conversation, raw)] : []
|
|
846
|
+
)
|
|
847
|
+
).filter(
|
|
848
|
+
(reply) => inRange(reply.sentAt, query) && // The auto-tag filter of the listing takes HeyReach's own tag
|
|
849
|
+
// names, which the reference does not list, so the category is
|
|
850
|
+
// matched here on the mapped value.
|
|
851
|
+
(query.category === void 0 || reply.category === query.category)
|
|
852
|
+
),
|
|
853
|
+
next: page2.next
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
// src/heyreach/lookup.ts
|
|
859
|
+
var CAMPAIGNS_PATH = "/campaign/GetCampaignsForLead";
|
|
860
|
+
var MAX_CANDIDATES = 5;
|
|
861
|
+
var canonicalProfileUrl = (url) => {
|
|
862
|
+
const slug = profileSlug(url);
|
|
863
|
+
return slug === null ? null : `https://www.linkedin.com/in/${encodeURIComponent(slug)}`;
|
|
864
|
+
};
|
|
865
|
+
var found = async (request) => {
|
|
866
|
+
try {
|
|
867
|
+
return await request;
|
|
868
|
+
} catch (error) {
|
|
869
|
+
if (OutboundError.is(error) && error.code === "NotFound") {
|
|
870
|
+
return void 0;
|
|
871
|
+
}
|
|
872
|
+
throw error;
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
var readProfile = async (client, ctx, profileUrl) => {
|
|
876
|
+
const body = await found(client.post(ctx, "/lead/GetLead", { profileUrl }));
|
|
877
|
+
return isJsonObject(body) ? body : void 0;
|
|
878
|
+
};
|
|
879
|
+
var profileByEmail = async (client, ctx, email, fullName2) => {
|
|
880
|
+
if (fullName2 === null) {
|
|
881
|
+
return void 0;
|
|
882
|
+
}
|
|
883
|
+
const lists = await found(
|
|
884
|
+
client.post(ctx, "/list/GetListsForLead", { email, limit: 1, offset: 0 })
|
|
885
|
+
);
|
|
886
|
+
const listId = field(objects(field(lists, "items"))[0], "listId");
|
|
887
|
+
if (!isNumber(listId)) {
|
|
888
|
+
return void 0;
|
|
889
|
+
}
|
|
890
|
+
const rows = objects(
|
|
891
|
+
field(
|
|
892
|
+
await client.post(ctx, "/list/GetLeadsFromList", {
|
|
893
|
+
keyword: fullName2,
|
|
894
|
+
limit: MAX_CANDIDATES,
|
|
895
|
+
listId,
|
|
896
|
+
offset: 0
|
|
897
|
+
}),
|
|
898
|
+
"items"
|
|
899
|
+
)
|
|
900
|
+
);
|
|
901
|
+
for (const row2 of rows) {
|
|
902
|
+
const profileUrl = text(row2.profileUrl);
|
|
903
|
+
const profile = profileUrl === null ? void 0 : (
|
|
904
|
+
// oxlint-disable-next-line no-await-in-loop -- stops at the first profile that carries the address.
|
|
905
|
+
await readProfile(client, ctx, profileUrl)
|
|
906
|
+
);
|
|
907
|
+
if (profile !== void 0 && profileEmails(profile).includes(email)) {
|
|
908
|
+
return profile;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
return void 0;
|
|
912
|
+
};
|
|
913
|
+
var isPerson = (profile, query) => (query.linkedinUrl === void 0 || profileSlug(text(profile.profileUrl)) === profileSlug(query.linkedinUrl)) && (query.email === void 0 || profileEmails(profile).includes(query.email));
|
|
914
|
+
var ask = async (client, ctx, query, offset) => {
|
|
915
|
+
const paging = { limit: pageSize(query.limit), offset };
|
|
916
|
+
const profileUrl = query.linkedinUrl === void 0 ? text(field(query.next, "profileUrl")) : canonicalProfileUrl(query.linkedinUrl);
|
|
917
|
+
if (profileUrl !== null) {
|
|
918
|
+
const key = query.linkedinUrl === void 0 ? { email: query.email ?? "" } : { profileUrl };
|
|
919
|
+
const [campaigns2, profile] = await Promise.all([
|
|
920
|
+
found(client.post(ctx, CAMPAIGNS_PATH, { ...key, ...paging })),
|
|
921
|
+
readProfile(client, ctx, profileUrl)
|
|
922
|
+
]);
|
|
923
|
+
return { campaigns: campaigns2, profile };
|
|
924
|
+
}
|
|
925
|
+
const { email } = query;
|
|
926
|
+
if (email === void 0) {
|
|
927
|
+
return { campaigns: void 0, profile: void 0 };
|
|
928
|
+
}
|
|
929
|
+
const campaigns = await found(
|
|
930
|
+
client.post(ctx, CAMPAIGNS_PATH, { email, ...paging })
|
|
931
|
+
);
|
|
932
|
+
return {
|
|
933
|
+
campaigns,
|
|
934
|
+
profile: campaigns === void 0 ? void 0 : await profileByEmail(
|
|
935
|
+
client,
|
|
936
|
+
ctx,
|
|
937
|
+
email,
|
|
938
|
+
text(field(campaigns, "leadFullName"))
|
|
939
|
+
)
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
var lookupLeads = async (client, ctx, query) => {
|
|
943
|
+
const { provider } = client.identity;
|
|
944
|
+
if (query.listId !== void 0) {
|
|
945
|
+
throw new OutboundError(
|
|
946
|
+
"Unsupported",
|
|
947
|
+
"HeyReach cannot look a lead up inside one saved list. Look the lead up without the list",
|
|
948
|
+
{ provider }
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
if (query.since !== void 0 || query.until !== void 0) {
|
|
952
|
+
throw new OutboundError(
|
|
953
|
+
"Unsupported",
|
|
954
|
+
"HeyReach does not say when a looked-up lead joined a campaign, so a lookup cannot be bounded by date",
|
|
955
|
+
{ provider }
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
const offset = offsetOf(field(query.next, "offset"));
|
|
959
|
+
const { campaigns, profile } = await ask(client, ctx, query, offset);
|
|
960
|
+
if (profile === void 0 || !isPerson(profile, query)) {
|
|
961
|
+
return { items: [] };
|
|
962
|
+
}
|
|
963
|
+
const envelope = listEnvelope(campaigns ?? null, offset);
|
|
964
|
+
if (envelope.items.length === 0 && offset === 0) {
|
|
965
|
+
return {
|
|
966
|
+
items: query.campaignId === void 0 ? [toLookupLead(client.identity, profile, null, query.email)] : []
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
return {
|
|
970
|
+
items: envelope.items.filter(
|
|
971
|
+
(campaign) => query.campaignId === void 0 || text(campaign.campaignId) === query.campaignId
|
|
972
|
+
).map(
|
|
973
|
+
(campaign) => toLookupLead(client.identity, profile, campaign, query.email)
|
|
974
|
+
),
|
|
975
|
+
next: envelope.next === void 0 ? void 0 : { offset: envelope.next, profileUrl: text(profile.profileUrl) }
|
|
976
|
+
};
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
// src/heyreach/leads.ts
|
|
980
|
+
var listLeadsBody = (client, query, offset) => {
|
|
981
|
+
const body = {
|
|
982
|
+
limit: pageSize(query.limit, LIST_LEADS_PAGE_SIZE),
|
|
983
|
+
listId: numericId(client, query.listId, "list"),
|
|
984
|
+
offset
|
|
985
|
+
};
|
|
986
|
+
if (query.since !== void 0) {
|
|
987
|
+
body.createdFrom = query.since;
|
|
988
|
+
}
|
|
989
|
+
if (query.until !== void 0) {
|
|
990
|
+
body.createdTo = query.until;
|
|
991
|
+
}
|
|
992
|
+
return body;
|
|
993
|
+
};
|
|
994
|
+
var campaignLeadsBody = (client, query, offset) => {
|
|
995
|
+
const body = {
|
|
996
|
+
campaignId: numericId(client, query.campaignId, "campaign"),
|
|
997
|
+
limit: pageSize(query.limit),
|
|
998
|
+
offset
|
|
999
|
+
};
|
|
1000
|
+
if (query.since !== void 0 || query.until !== void 0) {
|
|
1001
|
+
body.timeFilter = "CreationTime";
|
|
1002
|
+
}
|
|
1003
|
+
if (query.since !== void 0) {
|
|
1004
|
+
body.timeFrom = query.since;
|
|
1005
|
+
}
|
|
1006
|
+
if (query.until !== void 0) {
|
|
1007
|
+
body.timeTo = query.until;
|
|
1008
|
+
}
|
|
1009
|
+
return body;
|
|
1010
|
+
};
|
|
1011
|
+
var campaignLeads = async (client, ctx, query, offset) => {
|
|
1012
|
+
const envelope = listEnvelope(
|
|
1013
|
+
await client.post(
|
|
1014
|
+
ctx,
|
|
1015
|
+
"/campaign/GetLeadsFromCampaign",
|
|
1016
|
+
campaignLeadsBody(client, query, offset)
|
|
1017
|
+
),
|
|
1018
|
+
offset
|
|
1019
|
+
);
|
|
1020
|
+
return {
|
|
1021
|
+
items: envelope.items.map(
|
|
1022
|
+
(item) => toCampaignLead(client.identity, item, query.campaignId)
|
|
1023
|
+
),
|
|
1024
|
+
next: envelope.next
|
|
1025
|
+
};
|
|
1026
|
+
};
|
|
1027
|
+
var walkOf = (next) => isJsonObject(next) ? {
|
|
1028
|
+
campaignOffset: count(next.campaignOffset) ?? void 0,
|
|
1029
|
+
campaigns: list(next.campaigns).flatMap((id) => text(id) ?? []),
|
|
1030
|
+
offset: count(next.offset) ?? 0
|
|
1031
|
+
} : void 0;
|
|
1032
|
+
var walkCursor = (walk2) => walk2.campaigns.length === 0 && walk2.campaignOffset === void 0 ? void 0 : {
|
|
1033
|
+
campaignOffset: walk2.campaignOffset ?? null,
|
|
1034
|
+
campaigns: [...walk2.campaigns],
|
|
1035
|
+
offset: walk2.offset
|
|
1036
|
+
};
|
|
1037
|
+
var nextCampaigns = async (client, ctx, walk2) => {
|
|
1038
|
+
if (walk2 !== void 0 && walk2.campaigns.length > 0) {
|
|
1039
|
+
return walk2;
|
|
1040
|
+
}
|
|
1041
|
+
const offset = walk2 === void 0 ? 0 : walk2.campaignOffset;
|
|
1042
|
+
if (offset === void 0) {
|
|
1043
|
+
return { campaignOffset: void 0, campaigns: [], offset: 0 };
|
|
1044
|
+
}
|
|
1045
|
+
const envelope = listEnvelope(
|
|
1046
|
+
await client.post(ctx, "/campaign/GetAll", { limit: PAGE_SIZE, offset }),
|
|
1047
|
+
offset
|
|
1048
|
+
);
|
|
1049
|
+
return {
|
|
1050
|
+
campaignOffset: envelope.next,
|
|
1051
|
+
campaigns: envelope.items.flatMap((item) => text(item.id) ?? []),
|
|
1052
|
+
offset: 0
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
var allLeads = async (client, ctx, query) => {
|
|
1056
|
+
const walk2 = await nextCampaigns(client, ctx, walkOf(query.next));
|
|
1057
|
+
const [campaignId, ...rest] = walk2.campaigns;
|
|
1058
|
+
if (campaignId === void 0) {
|
|
1059
|
+
return { items: [] };
|
|
1060
|
+
}
|
|
1061
|
+
const page2 = await campaignLeads(
|
|
1062
|
+
client,
|
|
1063
|
+
ctx,
|
|
1064
|
+
{ ...query, campaignId },
|
|
1065
|
+
walk2.offset
|
|
1066
|
+
);
|
|
1067
|
+
return {
|
|
1068
|
+
items: page2.items,
|
|
1069
|
+
next: walkCursor(
|
|
1070
|
+
page2.next === void 0 ? { ...walk2, campaigns: rest, offset: 0 } : { ...walk2, offset: page2.next }
|
|
1071
|
+
)
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1074
|
+
var leadReaders = (client) => ({
|
|
1075
|
+
// The lead's id is its LinkedIn profile URL, the only key GetLead takes.
|
|
1076
|
+
// GetLead carries no tags, so they are read beside it. A looked-up lead's
|
|
1077
|
+
// id also names its campaign, which is dropped here.
|
|
1078
|
+
getLead: async (id, ctx) => {
|
|
1079
|
+
const path = "/lead/GetLead";
|
|
1080
|
+
const profileUrl = id;
|
|
1081
|
+
const [lead, tags] = await Promise.all([
|
|
1082
|
+
client.post(ctx, path, { profileUrl }),
|
|
1083
|
+
client.post(ctx, "/lead/GetTags", { profileUrl })
|
|
1084
|
+
]);
|
|
1085
|
+
return toLead(
|
|
1086
|
+
client.identity,
|
|
1087
|
+
client.object(lead, path),
|
|
1088
|
+
field(tags, "tags") ?? []
|
|
1089
|
+
);
|
|
1090
|
+
},
|
|
1091
|
+
listLeads: async (query, ctx) => {
|
|
1092
|
+
if (query.email !== void 0 || query.linkedinUrl !== void 0) {
|
|
1093
|
+
return await lookupLeads(client, ctx, query);
|
|
1094
|
+
}
|
|
1095
|
+
const offset = offsetOf(query.next);
|
|
1096
|
+
const { campaignId, listId } = query;
|
|
1097
|
+
if (listId !== void 0) {
|
|
1098
|
+
const envelope = listEnvelope(
|
|
1099
|
+
await client.post(
|
|
1100
|
+
ctx,
|
|
1101
|
+
"/list/GetLeadsFromList",
|
|
1102
|
+
listLeadsBody(client, { ...query, listId }, offset)
|
|
1103
|
+
),
|
|
1104
|
+
offset
|
|
1105
|
+
);
|
|
1106
|
+
return mapPage(envelope, (item) => toLead(client.identity, item));
|
|
1107
|
+
}
|
|
1108
|
+
if (campaignId === void 0) {
|
|
1109
|
+
return await allLeads(client, ctx, query);
|
|
1110
|
+
}
|
|
1111
|
+
return await campaignLeads(client, ctx, { ...query, campaignId }, offset);
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
// src/heyreach/map-sequence.ts
|
|
1116
|
+
var DELAY_DAYS = /* @__PURE__ */ new Map([
|
|
1117
|
+
["DAY", 1],
|
|
1118
|
+
["HOUR", 1 / 24]
|
|
1119
|
+
]);
|
|
1120
|
+
var delayDays = (node) => {
|
|
1121
|
+
const delay = count(node.actionDelay);
|
|
1122
|
+
const perUnit = DELAY_DAYS.get(text(node.actionDelayUnit) ?? "");
|
|
1123
|
+
return delay === null || perUnit === void 0 ? null : delay * perUnit;
|
|
1124
|
+
};
|
|
1125
|
+
var variantBodies = (payload) => {
|
|
1126
|
+
if (!isJsonObject(payload)) {
|
|
1127
|
+
return [];
|
|
1128
|
+
}
|
|
1129
|
+
const versions = objects(payload.messageVersions);
|
|
1130
|
+
return versions.length > 0 ? versions.map((version) => text(version.message)) : list(payload.messages).map((message) => text(message));
|
|
1131
|
+
};
|
|
1132
|
+
var typeOf = (node) => text(node.nodeType) ?? "unknown";
|
|
1133
|
+
var isCondition = (node) => typeOf(node).startsWith("CHECK_");
|
|
1134
|
+
var OUTCOMES = /* @__PURE__ */ new Map([
|
|
1135
|
+
["CHECK_IS_CONNECTION", ["connected", "not_connected"]],
|
|
1136
|
+
["CHECK_IS_OPEN_PROFILE", ["open_profile", "not_open_profile"]],
|
|
1137
|
+
["CONNECTION_REQUEST", ["accepted", "not_accepted"]],
|
|
1138
|
+
["FIND_EMAIL", ["email_found", "email_not_found"]],
|
|
1139
|
+
["INMAIL", ["replied", "not_replied"]],
|
|
1140
|
+
["MESSAGE", ["replied", "not_replied"]]
|
|
1141
|
+
]);
|
|
1142
|
+
var UNNAMED = ["conditional", "unconditional"];
|
|
1143
|
+
var SPLITS = /* @__PURE__ */ new Set(["CONNECTION_REQUEST", "FIND_EMAIL"]);
|
|
1144
|
+
var hasSteps = (node) => isJsonObject(node) && typeOf(node) !== "END" && (!isCondition(node) || hasSteps(node.conditionalNode) || hasSteps(node.unconditionalNode));
|
|
1145
|
+
var toStep = (node, index, position) => {
|
|
1146
|
+
const own = delayDays(node);
|
|
1147
|
+
return {
|
|
1148
|
+
action: typeOf(node).toLowerCase(),
|
|
1149
|
+
branch: position.outcomes.length === 0 ? null : position.outcomes.join("+"),
|
|
1150
|
+
delayDays: own === null ? null : own + position.waited,
|
|
1151
|
+
index,
|
|
1152
|
+
parentIndex: position.parentIndex,
|
|
1153
|
+
// Variants are positional and have no subject.
|
|
1154
|
+
variants: variantBodies(node.payload).map(
|
|
1155
|
+
(body, variantIndex) => toVariant(null, body, variantKey(variantIndex))
|
|
1156
|
+
)
|
|
1157
|
+
};
|
|
1158
|
+
};
|
|
1159
|
+
var walk = (node, position, steps) => {
|
|
1160
|
+
if (!isJsonObject(node) || typeOf(node) === "END") {
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
const [yes, no] = OUTCOMES.get(typeOf(node)) ?? UNNAMED;
|
|
1164
|
+
if (isCondition(node)) {
|
|
1165
|
+
const waited = position.waited + (delayDays(node) ?? 0);
|
|
1166
|
+
const under = (outcome) => ({
|
|
1167
|
+
outcomes: [...position.outcomes, outcome],
|
|
1168
|
+
parentIndex: position.parentIndex,
|
|
1169
|
+
waited
|
|
1170
|
+
});
|
|
1171
|
+
walk(node.conditionalNode, under(yes), steps);
|
|
1172
|
+
walk(node.unconditionalNode, under(no), steps);
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
const index = steps.length;
|
|
1176
|
+
steps.push(toStep(node, index, position));
|
|
1177
|
+
const splits = SPLITS.has(typeOf(node)) || hasSteps(node.conditionalNode);
|
|
1178
|
+
const after = { parentIndex: index, waited: 0 };
|
|
1179
|
+
walk(node.conditionalNode, { ...after, outcomes: [yes] }, steps);
|
|
1180
|
+
walk(
|
|
1181
|
+
node.unconditionalNode,
|
|
1182
|
+
{ ...after, outcomes: splits ? [no] : [] },
|
|
1183
|
+
steps
|
|
1184
|
+
);
|
|
1185
|
+
};
|
|
1186
|
+
var toSequence = (identity, campaignId, raw) => {
|
|
1187
|
+
const steps = [];
|
|
1188
|
+
walk(raw, { outcomes: [], parentIndex: null, waited: 0 }, steps);
|
|
1189
|
+
return {
|
|
1190
|
+
...recordBase(identity, campaignId, raw),
|
|
1191
|
+
campaignRef: refTo(identity, campaignId) ?? "",
|
|
1192
|
+
kind: "main",
|
|
1193
|
+
name: null,
|
|
1194
|
+
steps
|
|
1195
|
+
};
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
// src/heyreach/map-stats.ts
|
|
1199
|
+
var replies = (stats) => {
|
|
1200
|
+
const messages = count(field(stats, "totalMessageReplies"));
|
|
1201
|
+
const inmails = count(field(stats, "totalInmailReplies"));
|
|
1202
|
+
return messages === null && inmails === null ? null : (messages ?? 0) + (inmails ?? 0);
|
|
1203
|
+
};
|
|
1204
|
+
var counts = (stats) => ({
|
|
1205
|
+
...emptyCounts(),
|
|
1206
|
+
connectionsAccepted: count(field(stats, "connectionsAccepted")),
|
|
1207
|
+
connectionsSent: count(field(stats, "connectionsSent")),
|
|
1208
|
+
contacted: count(field(stats, "uniqueLeadsContacted")),
|
|
1209
|
+
inmailsSent: count(field(stats, "inmailMessagesSent")),
|
|
1210
|
+
positive: count(field(stats, "autoTaggedInterested")),
|
|
1211
|
+
replied: replies(stats),
|
|
1212
|
+
sent: count(field(stats, "messagesSent"))
|
|
1213
|
+
});
|
|
1214
|
+
var row = (scope, stats, date) => (
|
|
1215
|
+
// Days are keyed by UTC midnight.
|
|
1216
|
+
metricRow(scope, counts(stats), {
|
|
1217
|
+
date,
|
|
1218
|
+
timezone: date === null ? null : "UTC"
|
|
1219
|
+
})
|
|
1220
|
+
);
|
|
1221
|
+
var totalRow = (scope, body) => row(scope, field(body, "overallStats"), null);
|
|
1222
|
+
var dailyRows = (scope, body) => {
|
|
1223
|
+
const days = field(body, "byDayStats");
|
|
1224
|
+
return Object.entries(isJsonObject(days) ? days : {}).toSorted(([left], [right]) => left.localeCompare(right)).flatMap(([day, stats]) => {
|
|
1225
|
+
const date = timestamp(day)?.slice(0, 10);
|
|
1226
|
+
return date === void 0 ? [] : [row(scope, stats, date)];
|
|
1227
|
+
});
|
|
1228
|
+
};
|
|
1229
|
+
var campaignRow = (identity, stats, date) => {
|
|
1230
|
+
const scopeId = text(stats.campaignId);
|
|
1231
|
+
return scopeId === null ? [] : [row({ ...identity, scope: "campaign", scopeId }, stats, date)];
|
|
1232
|
+
};
|
|
1233
|
+
var campaignRows = (identity, body, by) => {
|
|
1234
|
+
if (by === "total") {
|
|
1235
|
+
return objects(field(body, "overallStats")).flatMap(
|
|
1236
|
+
(stats) => campaignRow(identity, stats, null)
|
|
1237
|
+
);
|
|
1238
|
+
}
|
|
1239
|
+
const days = field(body, "byDayStats");
|
|
1240
|
+
return Object.entries(isJsonObject(days) ? days : {}).toSorted(([left], [right]) => left.localeCompare(right)).flatMap(([day, perCampaign]) => {
|
|
1241
|
+
const date = timestamp(day)?.slice(0, 10);
|
|
1242
|
+
return date === void 0 ? [] : objects(perCampaign).flatMap(
|
|
1243
|
+
(stats) => campaignRow(identity, stats, date)
|
|
1244
|
+
);
|
|
1245
|
+
});
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
// src/heyreach/adapter.ts
|
|
1249
|
+
var statsBody = (client, query) => {
|
|
1250
|
+
const { provider } = client.identity;
|
|
1251
|
+
if (query.scope === "step") {
|
|
1252
|
+
throw new OutboundError("Unsupported", "HeyReach has no step analytics", {
|
|
1253
|
+
provider
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
if (query.from === void 0 !== (query.to === void 0)) {
|
|
1257
|
+
throw new OutboundError(
|
|
1258
|
+
"Invalid",
|
|
1259
|
+
"HeyReach stats need both from and to, or neither",
|
|
1260
|
+
{ provider }
|
|
1261
|
+
);
|
|
1262
|
+
}
|
|
1263
|
+
const id = query.scopeId;
|
|
1264
|
+
const body = {
|
|
1265
|
+
accountIds: query.scope === "sender" ? [numericId(client, id ?? "", "account")] : [],
|
|
1266
|
+
campaignIds: query.scope === "campaign" && id !== void 0 ? [numericId(client, id, "campaign")] : []
|
|
1267
|
+
};
|
|
1268
|
+
if (query.from !== void 0 && query.to !== void 0) {
|
|
1269
|
+
body.startDate = `${query.from}T00:00:00.000Z`;
|
|
1270
|
+
body.endDate = `${query.to}T23:59:59.999Z`;
|
|
1271
|
+
}
|
|
1272
|
+
return body;
|
|
1273
|
+
};
|
|
1274
|
+
var readStats = async (client, ctx, query) => {
|
|
1275
|
+
if (query.scope === "campaign" && query.scopeId === void 0) {
|
|
1276
|
+
return campaignRows(
|
|
1277
|
+
client.identity,
|
|
1278
|
+
await client.post(
|
|
1279
|
+
ctx,
|
|
1280
|
+
"/stats/GetOverallStatsByCampaign",
|
|
1281
|
+
statsBody(client, query)
|
|
1282
|
+
),
|
|
1283
|
+
query.by
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
1286
|
+
const body = await client.post(
|
|
1287
|
+
ctx,
|
|
1288
|
+
"/stats/GetOverallStats",
|
|
1289
|
+
statsBody(client, query)
|
|
1290
|
+
);
|
|
1291
|
+
const scope = {
|
|
1292
|
+
...client.identity,
|
|
1293
|
+
scope: query.scope,
|
|
1294
|
+
scopeId: query.scopeId ?? client.identity.workspaceId
|
|
1295
|
+
};
|
|
1296
|
+
return query.by === "day" ? dailyRows(scope, body) : [totalRow(scope, body)];
|
|
1297
|
+
};
|
|
1298
|
+
var readers = (client) => {
|
|
1299
|
+
const { identity } = client;
|
|
1300
|
+
return {
|
|
1301
|
+
...accountReaders(client),
|
|
1302
|
+
...inboxReaders(client),
|
|
1303
|
+
...leadReaders(client),
|
|
1304
|
+
getCampaign: async (id, ctx) => {
|
|
1305
|
+
const path = "/campaign/GetById";
|
|
1306
|
+
return toCampaign(
|
|
1307
|
+
identity,
|
|
1308
|
+
client.object(
|
|
1309
|
+
await client.get(ctx, path, { query: { campaignId: id } }),
|
|
1310
|
+
path
|
|
1311
|
+
)
|
|
1312
|
+
);
|
|
1313
|
+
},
|
|
1314
|
+
getSender: async (id, ctx) => {
|
|
1315
|
+
const path = "/li_account/GetById";
|
|
1316
|
+
return toSender(
|
|
1317
|
+
identity,
|
|
1318
|
+
client.object(
|
|
1319
|
+
await client.get(ctx, path, { query: { accountId: id } }),
|
|
1320
|
+
path
|
|
1321
|
+
)
|
|
1322
|
+
);
|
|
1323
|
+
},
|
|
1324
|
+
getSequence: async (id, ctx) => toSequence(
|
|
1325
|
+
identity,
|
|
1326
|
+
id,
|
|
1327
|
+
await client.get(ctx, "/campaign/GetCampaignSequence", {
|
|
1328
|
+
query: { campaignId: id }
|
|
1329
|
+
})
|
|
1330
|
+
),
|
|
1331
|
+
listCampaigns: async (query, ctx) => {
|
|
1332
|
+
const offset = offsetOf(query.next);
|
|
1333
|
+
const body = { limit: pageSize(query.limit), offset };
|
|
1334
|
+
if (query.status !== void 0) {
|
|
1335
|
+
const statuses = vendorStatuses(query.status);
|
|
1336
|
+
if (statuses.length === 0) {
|
|
1337
|
+
return { items: [] };
|
|
1338
|
+
}
|
|
1339
|
+
body.statuses = statuses;
|
|
1340
|
+
}
|
|
1341
|
+
if (query.senderId !== void 0) {
|
|
1342
|
+
body.accountIds = [numericId(client, query.senderId, "account")];
|
|
1343
|
+
}
|
|
1344
|
+
const envelope = listEnvelope(
|
|
1345
|
+
await client.post(ctx, "/campaign/GetAll", body),
|
|
1346
|
+
offset
|
|
1347
|
+
);
|
|
1348
|
+
return mapPage(envelope, (item) => toCampaign(identity, item));
|
|
1349
|
+
},
|
|
1350
|
+
listSenders: async (query, ctx) => {
|
|
1351
|
+
const { campaignId } = query;
|
|
1352
|
+
if (campaignId !== void 0) {
|
|
1353
|
+
return await campaignSenders(client, ctx, { ...query, campaignId });
|
|
1354
|
+
}
|
|
1355
|
+
const offset = offsetOf(query.next);
|
|
1356
|
+
const envelope = listEnvelope(
|
|
1357
|
+
await client.post(ctx, "/li_account/GetAll", {
|
|
1358
|
+
limit: pageSize(query.limit),
|
|
1359
|
+
offset
|
|
1360
|
+
}),
|
|
1361
|
+
offset
|
|
1362
|
+
);
|
|
1363
|
+
return mapPage(envelope, (item) => toSender(identity, item));
|
|
1364
|
+
},
|
|
1365
|
+
stats: (query, ctx) => readStats(client, ctx, query)
|
|
1366
|
+
};
|
|
1367
|
+
};
|
|
1368
|
+
|
|
1369
|
+
// src/heyreach/client.ts
|
|
1370
|
+
var READ_POSTS = /* @__PURE__ */ new Set([
|
|
1371
|
+
"/MyNetwork/GetMyNetworkForSender",
|
|
1372
|
+
"/MyNetwork/IsConnection",
|
|
1373
|
+
"/blacklist/GetCompanies",
|
|
1374
|
+
"/blacklist/GetLeads",
|
|
1375
|
+
"/campaign/GetAll",
|
|
1376
|
+
"/campaign/GetCampaignsForLead",
|
|
1377
|
+
"/campaign/GetLeadsFromCampaign",
|
|
1378
|
+
"/inbox/GetConversationsV2",
|
|
1379
|
+
"/inbox/GetConversationsV3",
|
|
1380
|
+
"/lead/GetLead",
|
|
1381
|
+
"/lead/GetTags",
|
|
1382
|
+
"/li_account/GetAll",
|
|
1383
|
+
"/list/GetAll",
|
|
1384
|
+
"/list/GetCompaniesFromList",
|
|
1385
|
+
"/list/GetLeadsFromList",
|
|
1386
|
+
"/list/GetListsForLead",
|
|
1387
|
+
"/management/organizations/linkedin-accounts",
|
|
1388
|
+
"/management/organizations/users",
|
|
1389
|
+
"/stats/GetOverallStats",
|
|
1390
|
+
"/stats/GetOverallStatsByCampaign",
|
|
1391
|
+
"/webhooks/GetAllWebhooks"
|
|
1392
|
+
]);
|
|
1393
|
+
var READ_POST_PATTERN = /^\/management\/organizations\/users\/workspaces\/[^/]+$/u;
|
|
1394
|
+
var SECRET_GET_PATTERN = /^\/(?:management\/organizations\/api-keys|li_account\/GetAccountProxy)(?:\/|$)/iu;
|
|
1395
|
+
var WEBHOOK_BY_ID = /\/webhooks\/GetWebhookById\/?$/iu;
|
|
1396
|
+
var withoutWebhookHeaders = (spec) => {
|
|
1397
|
+
const url = new URL(spec.url);
|
|
1398
|
+
if (!WEBHOOK_BY_ID.test(url.pathname)) {
|
|
1399
|
+
return spec;
|
|
1400
|
+
}
|
|
1401
|
+
url.searchParams.set("includeCustomHeaders", "false");
|
|
1402
|
+
return { ...spec, url: url.toString() };
|
|
1403
|
+
};
|
|
1404
|
+
var normalizePath = (path) => `/${path.replace(/\?.*$/u, "").replace(/^\/+/u, "").replace(/\/+$/u, "")}`.replace(/^\/api\/public/u, "");
|
|
1405
|
+
var isSecret = (path) => SECRET_GET_PATTERN.test(normalizePath(path));
|
|
1406
|
+
var isRead = (method, path) => {
|
|
1407
|
+
const normalized = normalizePath(path);
|
|
1408
|
+
if (method === "GET") {
|
|
1409
|
+
return !isSecret(normalized);
|
|
1410
|
+
}
|
|
1411
|
+
return method === "POST" && (READ_POSTS.has(normalized) || READ_POST_PATTERN.test(normalized));
|
|
1412
|
+
};
|
|
1413
|
+
var createClient = (options) => {
|
|
1414
|
+
const baseUrl = options.baseUrl ?? BASE_URL;
|
|
1415
|
+
const authorize = (spec) => ({
|
|
1416
|
+
...withoutWebhookHeaders(spec),
|
|
1417
|
+
headers: { ...spec.headers, "X-API-KEY": options.apiKey }
|
|
1418
|
+
});
|
|
1419
|
+
return {
|
|
1420
|
+
...createVendorClient(baseUrl, authorize),
|
|
1421
|
+
identity: options.identity,
|
|
1422
|
+
object: (body, path) => requireObject(
|
|
1423
|
+
body,
|
|
1424
|
+
options.identity.provider,
|
|
1425
|
+
`HeyReach returned no object for ${path}`
|
|
1426
|
+
),
|
|
1427
|
+
raw: { authorize, baseUrl, isRead, isSecret }
|
|
1428
|
+
};
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
// src/heyreach/native-organization.ts
|
|
1432
|
+
var DOCS = "https://docs.heyreach.io/hey-reach-api/organization";
|
|
1433
|
+
var ORGANIZATION_LANE = "organization";
|
|
1434
|
+
var NEEDS_KEY = "Needs the organization API key.";
|
|
1435
|
+
var userFilters = {
|
|
1436
|
+
invitationStatus: {
|
|
1437
|
+
description: "Only users whose invitation has one of these statuses, as an array of names.",
|
|
1438
|
+
in: "body",
|
|
1439
|
+
type: "json"
|
|
1440
|
+
},
|
|
1441
|
+
limit: {
|
|
1442
|
+
description: "How many users to return.",
|
|
1443
|
+
in: "body",
|
|
1444
|
+
type: "number"
|
|
1445
|
+
},
|
|
1446
|
+
offset: {
|
|
1447
|
+
description: "How many users to skip.",
|
|
1448
|
+
in: "body",
|
|
1449
|
+
type: "number"
|
|
1450
|
+
},
|
|
1451
|
+
role: {
|
|
1452
|
+
description: "Only users with this role.",
|
|
1453
|
+
in: "body",
|
|
1454
|
+
type: "string"
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
var ORGANIZATION_NATIVE = defineNative({
|
|
1458
|
+
organizationLinkedInAccounts: {
|
|
1459
|
+
description: `LinkedIn accounts across every workspace of the organization, each with its workspace, connection state and count of active campaigns. ${NEEDS_KEY}`,
|
|
1460
|
+
docs: `${DOCS}/linked-in-accounts/get-linked-in-accounts`,
|
|
1461
|
+
lane: ORGANIZATION_LANE,
|
|
1462
|
+
method: "POST",
|
|
1463
|
+
params: {
|
|
1464
|
+
keyword: {
|
|
1465
|
+
description: "Search text.",
|
|
1466
|
+
in: "body",
|
|
1467
|
+
type: "string"
|
|
1468
|
+
},
|
|
1469
|
+
limit: {
|
|
1470
|
+
description: "How many accounts to return.",
|
|
1471
|
+
in: "body",
|
|
1472
|
+
type: "number"
|
|
1473
|
+
},
|
|
1474
|
+
offset: {
|
|
1475
|
+
description: "How many accounts to skip.",
|
|
1476
|
+
in: "body",
|
|
1477
|
+
type: "number"
|
|
1478
|
+
},
|
|
1479
|
+
workspaceIds: {
|
|
1480
|
+
description: "Only accounts in these workspaces, as an array of ids. Empty or left out means every workspace.",
|
|
1481
|
+
in: "body",
|
|
1482
|
+
type: "json"
|
|
1483
|
+
}
|
|
1484
|
+
},
|
|
1485
|
+
path: "/management/organizations/linkedin-accounts"
|
|
1486
|
+
},
|
|
1487
|
+
organizationUser: {
|
|
1488
|
+
description: `One user of the organization: name, email, roles and permissions. ${NEEDS_KEY}`,
|
|
1489
|
+
docs: `${DOCS}/workspace-users/get-user-by-id`,
|
|
1490
|
+
lane: ORGANIZATION_LANE,
|
|
1491
|
+
method: "GET",
|
|
1492
|
+
params: {
|
|
1493
|
+
userId: {
|
|
1494
|
+
description: "The user's id.",
|
|
1495
|
+
in: "path",
|
|
1496
|
+
type: "number"
|
|
1497
|
+
}
|
|
1498
|
+
},
|
|
1499
|
+
path: "/management/organizations/users/{userId}"
|
|
1500
|
+
},
|
|
1501
|
+
organizationUsers: {
|
|
1502
|
+
description: `Every existing and invited user of the organization, with roles, invitation state and permissions per workspace. ${NEEDS_KEY}`,
|
|
1503
|
+
docs: `${DOCS}/workspace-users/get-all-users`,
|
|
1504
|
+
lane: ORGANIZATION_LANE,
|
|
1505
|
+
method: "POST",
|
|
1506
|
+
params: userFilters,
|
|
1507
|
+
path: "/management/organizations/users"
|
|
1508
|
+
},
|
|
1509
|
+
organizationWorkspaces: {
|
|
1510
|
+
description: `The organization's workspaces, each with its name, seat limit and seats used. ${NEEDS_KEY}`,
|
|
1511
|
+
docs: `${DOCS}/workspaces/get-all-workspaces`,
|
|
1512
|
+
lane: ORGANIZATION_LANE,
|
|
1513
|
+
method: "GET",
|
|
1514
|
+
params: {
|
|
1515
|
+
Limit: {
|
|
1516
|
+
description: "How many workspaces to return.",
|
|
1517
|
+
in: "query",
|
|
1518
|
+
type: "number"
|
|
1519
|
+
},
|
|
1520
|
+
Offset: {
|
|
1521
|
+
description: "How many workspaces to skip.",
|
|
1522
|
+
in: "query",
|
|
1523
|
+
type: "number"
|
|
1524
|
+
}
|
|
1525
|
+
},
|
|
1526
|
+
path: "/management/organizations/workspaces"
|
|
1527
|
+
},
|
|
1528
|
+
workspaceUsers: {
|
|
1529
|
+
description: `The users of one workspace, with their role and permissions. ${NEEDS_KEY}`,
|
|
1530
|
+
docs: `${DOCS}/workspace-users/get-workspace-users`,
|
|
1531
|
+
lane: ORGANIZATION_LANE,
|
|
1532
|
+
method: "POST",
|
|
1533
|
+
params: {
|
|
1534
|
+
...userFilters,
|
|
1535
|
+
workspaceId: {
|
|
1536
|
+
description: "The workspace's id.",
|
|
1537
|
+
in: "path",
|
|
1538
|
+
type: "number"
|
|
1539
|
+
}
|
|
1540
|
+
},
|
|
1541
|
+
path: "/management/organizations/users/workspaces/{workspaceId}"
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
|
|
1545
|
+
// src/heyreach/native-voice.ts
|
|
1546
|
+
var DOCS2 = "https://docs.heyreach.io/hey-reach-api/voice";
|
|
1547
|
+
var VOICE_NATIVE = defineNative({
|
|
1548
|
+
elevenLabsConnection: {
|
|
1549
|
+
description: "The workspace's ElevenLabs connection: whether a key is connected, its status, the last four characters of the key, the last library sync and how many imported voices it offers. The key itself is never returned.",
|
|
1550
|
+
docs: `${DOCS2}/get-eleven-labs-connection`,
|
|
1551
|
+
method: "GET",
|
|
1552
|
+
path: "/voice/GetElevenLabsConnection"
|
|
1553
|
+
},
|
|
1554
|
+
elevenLabsVoices: {
|
|
1555
|
+
description: "The ElevenLabs voices imported into the workspace, ordered by name, as the last library sync stored them.",
|
|
1556
|
+
docs: `${DOCS2}/get-eleven-labs-voices`,
|
|
1557
|
+
method: "GET",
|
|
1558
|
+
params: {
|
|
1559
|
+
limit: {
|
|
1560
|
+
description: "How many voices to return, 1 to 500. Defaults to 100.",
|
|
1561
|
+
in: "query",
|
|
1562
|
+
type: "number"
|
|
1563
|
+
},
|
|
1564
|
+
offset: {
|
|
1565
|
+
description: "How many voices to skip. Defaults to 0.",
|
|
1566
|
+
in: "query",
|
|
1567
|
+
type: "number"
|
|
1568
|
+
},
|
|
1569
|
+
search: {
|
|
1570
|
+
description: "Case-insensitive match on the voice name.",
|
|
1571
|
+
in: "query",
|
|
1572
|
+
type: "string"
|
|
1573
|
+
}
|
|
1574
|
+
},
|
|
1575
|
+
path: "/voice/GetElevenLabsVoices"
|
|
1576
|
+
},
|
|
1577
|
+
senderVoice: {
|
|
1578
|
+
description: "The voice assigned to one LinkedIn account. Answers 404 SENDER_VOICE_NOT_ASSIGNED when the account has none.",
|
|
1579
|
+
docs: `${DOCS2}/get-sender-voice`,
|
|
1580
|
+
method: "GET",
|
|
1581
|
+
params: {
|
|
1582
|
+
accountId: {
|
|
1583
|
+
description: "The LinkedIn account's id.",
|
|
1584
|
+
in: "path",
|
|
1585
|
+
type: "number"
|
|
1586
|
+
}
|
|
1587
|
+
},
|
|
1588
|
+
path: "/voice/GetSenderVoice/{accountId}"
|
|
1589
|
+
},
|
|
1590
|
+
staticClip: {
|
|
1591
|
+
description: "One uploaded voice clip: its duration, its transcript and why a transcript is absent. Metadata only; the audio is not returned.",
|
|
1592
|
+
docs: `${DOCS2}/get-static-clip`,
|
|
1593
|
+
method: "GET",
|
|
1594
|
+
params: {
|
|
1595
|
+
clipId: {
|
|
1596
|
+
description: "The clip's id, as staticClips lists it.",
|
|
1597
|
+
in: "path",
|
|
1598
|
+
type: "number"
|
|
1599
|
+
}
|
|
1600
|
+
},
|
|
1601
|
+
path: "/voice/GetStaticClip/{clipId}"
|
|
1602
|
+
},
|
|
1603
|
+
staticClips: {
|
|
1604
|
+
description: "The workspace's uploaded voice clips, newest first, with duration and transcript. Metadata only.",
|
|
1605
|
+
docs: `${DOCS2}/get-static-clips`,
|
|
1606
|
+
method: "GET",
|
|
1607
|
+
params: {
|
|
1608
|
+
limit: {
|
|
1609
|
+
description: "How many clips to return, 1 to 100. Defaults to 50.",
|
|
1610
|
+
in: "query",
|
|
1611
|
+
type: "number"
|
|
1612
|
+
},
|
|
1613
|
+
offset: {
|
|
1614
|
+
description: "How many clips to skip. Defaults to 0.",
|
|
1615
|
+
in: "query",
|
|
1616
|
+
type: "number"
|
|
1617
|
+
}
|
|
1618
|
+
},
|
|
1619
|
+
path: "/voice/GetStaticClips"
|
|
1620
|
+
},
|
|
1621
|
+
voiceUsage: {
|
|
1622
|
+
description: "Where one voice is in use: the LinkedIn accounts it is assigned to and whether any of them is in a running campaign.",
|
|
1623
|
+
docs: `${DOCS2}/get-voice-usage`,
|
|
1624
|
+
method: "GET",
|
|
1625
|
+
params: {
|
|
1626
|
+
id: {
|
|
1627
|
+
description: "The voice's id, as voices lists it.",
|
|
1628
|
+
in: "path",
|
|
1629
|
+
type: "number"
|
|
1630
|
+
},
|
|
1631
|
+
kind: {
|
|
1632
|
+
description: "PREDEFINED or CUSTOM. Defaults to CUSTOM.",
|
|
1633
|
+
in: "query",
|
|
1634
|
+
type: "string"
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1637
|
+
path: "/voice/GetVoiceUsage/{id}"
|
|
1638
|
+
},
|
|
1639
|
+
voices: {
|
|
1640
|
+
description: "The workspace's voice library: every predefined voice and the workspace's own cloned voices, each with the LinkedIn accounts it is assigned to.",
|
|
1641
|
+
docs: `${DOCS2}/get-voices`,
|
|
1642
|
+
method: "GET",
|
|
1643
|
+
params: {
|
|
1644
|
+
gender: {
|
|
1645
|
+
description: "Only voices of this gender: MALE or FEMALE.",
|
|
1646
|
+
in: "query",
|
|
1647
|
+
type: "string"
|
|
1648
|
+
}
|
|
1649
|
+
},
|
|
1650
|
+
path: "/voice/GetVoices"
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
|
|
1654
|
+
// src/heyreach/native.ts
|
|
1655
|
+
var DOCS3 = "https://docs.heyreach.io/hey-reach-api";
|
|
1656
|
+
var page = (what, max) => ({
|
|
1657
|
+
limit: {
|
|
1658
|
+
description: `How many ${what} to return${max === void 0 ? "" : `, up to ${max}`}.`,
|
|
1659
|
+
in: "body",
|
|
1660
|
+
type: "number"
|
|
1661
|
+
},
|
|
1662
|
+
offset: {
|
|
1663
|
+
description: `How many ${what} to skip.`,
|
|
1664
|
+
in: "body",
|
|
1665
|
+
type: "number"
|
|
1666
|
+
}
|
|
1667
|
+
});
|
|
1668
|
+
var leadKeys = {
|
|
1669
|
+
email: {
|
|
1670
|
+
description: "The lead's email address.",
|
|
1671
|
+
in: "body",
|
|
1672
|
+
type: "string"
|
|
1673
|
+
},
|
|
1674
|
+
linkedinId: {
|
|
1675
|
+
description: "The lead's LinkedIn id, `linkedin_id` in lead payloads.",
|
|
1676
|
+
in: "body",
|
|
1677
|
+
type: "string"
|
|
1678
|
+
},
|
|
1679
|
+
profileUrl: {
|
|
1680
|
+
description: "The lead's LinkedIn profile URL.",
|
|
1681
|
+
in: "body",
|
|
1682
|
+
type: "string"
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
var WORKSPACE_NATIVE = defineNative({
|
|
1686
|
+
campaignSequenceV2: {
|
|
1687
|
+
description: "A campaign's sequence tree with every message version in full, voice versions included, each with the length and transcript of its recording. Empty when the campaign has no sequence.",
|
|
1688
|
+
docs: `${DOCS3}/campaigns/get-campaign-sequence-v-2`,
|
|
1689
|
+
method: "GET",
|
|
1690
|
+
params: {
|
|
1691
|
+
campaignId: {
|
|
1692
|
+
description: "The campaign's id.",
|
|
1693
|
+
in: "query",
|
|
1694
|
+
required: true,
|
|
1695
|
+
type: "number"
|
|
1696
|
+
}
|
|
1697
|
+
},
|
|
1698
|
+
path: "/campaign/GetCampaignSequenceV2"
|
|
1699
|
+
},
|
|
1700
|
+
campaignsForLead: {
|
|
1701
|
+
description: "The campaigns one lead is in, each with the campaign's status and the lead's status in it. Name the lead by email, LinkedIn id or profile URL.",
|
|
1702
|
+
docs: `${DOCS3}/campaigns/get-campaigns-for-lead`,
|
|
1703
|
+
method: "POST",
|
|
1704
|
+
params: { ...leadKeys, ...page("campaigns") },
|
|
1705
|
+
path: "/campaign/GetCampaignsForLead"
|
|
1706
|
+
},
|
|
1707
|
+
checkApiKey: {
|
|
1708
|
+
description: "Whether the API key works. Answers 200 with an empty body, and nothing about who the key belongs to.",
|
|
1709
|
+
docs: `${DOCS3}/authentication/check-api-key`,
|
|
1710
|
+
method: "GET",
|
|
1711
|
+
path: "/auth/CheckApiKey"
|
|
1712
|
+
},
|
|
1713
|
+
companiesFromList: {
|
|
1714
|
+
description: "The companies in one company list: name, industry, size, location and website.",
|
|
1715
|
+
docs: `${DOCS3}/lists/get-companies-from-list`,
|
|
1716
|
+
method: "POST",
|
|
1717
|
+
params: {
|
|
1718
|
+
...page("companies", 1e3),
|
|
1719
|
+
keyword: {
|
|
1720
|
+
description: "Search text.",
|
|
1721
|
+
in: "body",
|
|
1722
|
+
type: "string"
|
|
1723
|
+
},
|
|
1724
|
+
listId: {
|
|
1725
|
+
description: "The company list's id.",
|
|
1726
|
+
in: "body",
|
|
1727
|
+
required: true,
|
|
1728
|
+
type: "number"
|
|
1729
|
+
}
|
|
1730
|
+
},
|
|
1731
|
+
path: "/list/GetCompaniesFromList"
|
|
1732
|
+
},
|
|
1733
|
+
conversationsV2: {
|
|
1734
|
+
description: "Conversations with their messages, paged by offset. Unlike the newer listing the normalized reads use, each lead profile here carries its custom fields. Deep pages are refused on a large inbox.",
|
|
1735
|
+
docs: `${DOCS3}/inbox/get-conversations-v-2`,
|
|
1736
|
+
method: "POST",
|
|
1737
|
+
params: {
|
|
1738
|
+
...page("conversations", 100),
|
|
1739
|
+
filters: {
|
|
1740
|
+
description: "An object of filters: linkedInAccountIds, campaignIds, searchString, leadLinkedInId, leadProfileUrl, tags, seen.",
|
|
1741
|
+
in: "body",
|
|
1742
|
+
type: "json"
|
|
1743
|
+
}
|
|
1744
|
+
},
|
|
1745
|
+
path: "/inbox/GetConversationsV2"
|
|
1746
|
+
},
|
|
1747
|
+
enrichEmailJob: {
|
|
1748
|
+
description: "The state of one email-enrichment job, and the email found once it has completed. The job itself is started in HeyReach.",
|
|
1749
|
+
docs: `${DOCS3}/enrichment/check-enrich-email-job`,
|
|
1750
|
+
method: "GET",
|
|
1751
|
+
params: {
|
|
1752
|
+
jobId: {
|
|
1753
|
+
description: "The job's id.",
|
|
1754
|
+
in: "path",
|
|
1755
|
+
type: "number"
|
|
1756
|
+
}
|
|
1757
|
+
},
|
|
1758
|
+
path: "/enrichment/enrich-email/check-job/{jobId}"
|
|
1759
|
+
},
|
|
1760
|
+
isConnection: {
|
|
1761
|
+
description: "Whether a lead is a LinkedIn connection of one sender. Name the lead by profile URL or LinkedIn id, never both.",
|
|
1762
|
+
docs: `${DOCS3}/my-network/is-connection`,
|
|
1763
|
+
method: "POST",
|
|
1764
|
+
params: {
|
|
1765
|
+
leadLinkedInId: {
|
|
1766
|
+
description: "The lead's LinkedIn id.",
|
|
1767
|
+
in: "body",
|
|
1768
|
+
type: "string"
|
|
1769
|
+
},
|
|
1770
|
+
leadProfileUrl: {
|
|
1771
|
+
description: "The lead's LinkedIn profile URL.",
|
|
1772
|
+
in: "body",
|
|
1773
|
+
type: "string"
|
|
1774
|
+
},
|
|
1775
|
+
senderAccountId: {
|
|
1776
|
+
description: "The LinkedIn account's id.",
|
|
1777
|
+
in: "body",
|
|
1778
|
+
required: true,
|
|
1779
|
+
type: "number"
|
|
1780
|
+
}
|
|
1781
|
+
},
|
|
1782
|
+
path: "/MyNetwork/IsConnection"
|
|
1783
|
+
},
|
|
1784
|
+
listById: {
|
|
1785
|
+
description: "One lead or company list: name, type, item count, creation time and the campaigns that use it.",
|
|
1786
|
+
docs: `${DOCS3}/lists/get-by-id`,
|
|
1787
|
+
method: "GET",
|
|
1788
|
+
params: {
|
|
1789
|
+
listId: {
|
|
1790
|
+
description: "The list's id.",
|
|
1791
|
+
in: "query",
|
|
1792
|
+
required: true,
|
|
1793
|
+
type: "number"
|
|
1794
|
+
}
|
|
1795
|
+
},
|
|
1796
|
+
path: "/list/GetById"
|
|
1797
|
+
},
|
|
1798
|
+
listsForLead: {
|
|
1799
|
+
description: "The lead lists one lead is in. Name the lead by email, LinkedIn id or profile URL. Answers 404 when the lead is in none.",
|
|
1800
|
+
docs: `${DOCS3}/lists/get-lists-for-lead`,
|
|
1801
|
+
method: "POST",
|
|
1802
|
+
params: { ...leadKeys, ...page("lists") },
|
|
1803
|
+
path: "/list/GetListsForLead"
|
|
1804
|
+
},
|
|
1805
|
+
myNetworkForSender: {
|
|
1806
|
+
description: "The LinkedIn connections of one sender, as lead profiles. Pages by pageNumber and pageSize.",
|
|
1807
|
+
docs: `${DOCS3}/my-network/get-my-network-for-sender`,
|
|
1808
|
+
method: "POST",
|
|
1809
|
+
params: {
|
|
1810
|
+
pageNumber: {
|
|
1811
|
+
description: "The page to read, starting at 0.",
|
|
1812
|
+
in: "body",
|
|
1813
|
+
type: "number"
|
|
1814
|
+
},
|
|
1815
|
+
pageSize: {
|
|
1816
|
+
description: "How many connections a page holds. The documented example uses 100.",
|
|
1817
|
+
in: "body",
|
|
1818
|
+
type: "number"
|
|
1819
|
+
},
|
|
1820
|
+
senderId: {
|
|
1821
|
+
description: "The LinkedIn account's id.",
|
|
1822
|
+
in: "body",
|
|
1823
|
+
required: true,
|
|
1824
|
+
type: "number"
|
|
1825
|
+
}
|
|
1826
|
+
},
|
|
1827
|
+
path: "/MyNetwork/GetMyNetworkForSender"
|
|
1828
|
+
},
|
|
1829
|
+
proxyCountries: {
|
|
1830
|
+
description: "The proxy countries a LinkedIn account can be connected through.",
|
|
1831
|
+
docs: `${DOCS3}/linked-in-accounts/get-proxy-countries`,
|
|
1832
|
+
method: "GET",
|
|
1833
|
+
path: "/li_account/GetProxyCountries"
|
|
1834
|
+
},
|
|
1835
|
+
statsByCampaign: {
|
|
1836
|
+
description: "The workspace's stats broken down per campaign: one row of counts for each campaign, in total and for each day, deleted campaigns included.",
|
|
1837
|
+
docs: `${DOCS3}/analytics/get-overall-stats-by-campaign`,
|
|
1838
|
+
method: "POST",
|
|
1839
|
+
params: {
|
|
1840
|
+
accountIds: {
|
|
1841
|
+
description: "Only these LinkedIn accounts, as an array of ids. Empty means every account.",
|
|
1842
|
+
in: "body",
|
|
1843
|
+
required: true,
|
|
1844
|
+
type: "json"
|
|
1845
|
+
},
|
|
1846
|
+
campaignIds: {
|
|
1847
|
+
description: "Only these campaigns, as an array of ids. Empty means every campaign.",
|
|
1848
|
+
in: "body",
|
|
1849
|
+
required: true,
|
|
1850
|
+
type: "json"
|
|
1851
|
+
},
|
|
1852
|
+
endDate: {
|
|
1853
|
+
description: "The end of the range, as an ISO 8601 time.",
|
|
1854
|
+
in: "body",
|
|
1855
|
+
type: "string"
|
|
1856
|
+
},
|
|
1857
|
+
startDate: {
|
|
1858
|
+
description: "The start of the range, as an ISO 8601 time.",
|
|
1859
|
+
in: "body",
|
|
1860
|
+
type: "string"
|
|
1861
|
+
}
|
|
1862
|
+
},
|
|
1863
|
+
path: "/stats/GetOverallStatsByCampaign"
|
|
1864
|
+
},
|
|
1865
|
+
webhookById: {
|
|
1866
|
+
description: "One webhook: name, URL, event type, campaigns and whether it is active. Its custom headers can hold a secret, so they are never requested.",
|
|
1867
|
+
docs: `${DOCS3}/webhooks/get-webhook-by-id`,
|
|
1868
|
+
method: "GET",
|
|
1869
|
+
params: {
|
|
1870
|
+
webhookId: {
|
|
1871
|
+
description: "The webhook's id.",
|
|
1872
|
+
in: "query",
|
|
1873
|
+
required: true,
|
|
1874
|
+
type: "number"
|
|
1875
|
+
}
|
|
1876
|
+
},
|
|
1877
|
+
path: "/webhooks/GetWebhookById"
|
|
1878
|
+
}
|
|
1879
|
+
});
|
|
1880
|
+
var NATIVE = defineNative({
|
|
1881
|
+
...WORKSPACE_NATIVE,
|
|
1882
|
+
...ORGANIZATION_NATIVE,
|
|
1883
|
+
...VOICE_NATIVE
|
|
1884
|
+
});
|
|
1885
|
+
|
|
1886
|
+
// src/heyreach/index.ts
|
|
1887
|
+
var PROVIDER = "heyreach";
|
|
1888
|
+
var envVars = [API_KEY_ENV, WORKSPACE_ENV];
|
|
1889
|
+
var errorMapper = (apiKey) => {
|
|
1890
|
+
const byStatus = makeErrorMapper(PROVIDER, { secrets: [apiKey] });
|
|
1891
|
+
return (cause) => isHttpFailure(cause) && field(cause.body, "errorCode") === "CAMPAIGN_API_NOT_ENABLED" ? new OutboundError(
|
|
1892
|
+
"Unsupported",
|
|
1893
|
+
"HeyReach's campaign API is not enabled for this account (CAMPAIGN_API_NOT_ENABLED), so sequences cannot be read",
|
|
1894
|
+
{ cause, provider: PROVIDER, status: cause.status }
|
|
1895
|
+
) : byStatus(cause);
|
|
1896
|
+
};
|
|
1897
|
+
var heyreach = (options = {}) => {
|
|
1898
|
+
const apiKey = requireCredential(options.apiKey, API_KEY_ENV, PROVIDER);
|
|
1899
|
+
const workspaceId = assertWorkspaceId(
|
|
1900
|
+
options.workspaceId ?? readEnv(WORKSPACE_ENV) ?? "default",
|
|
1901
|
+
PROVIDER
|
|
1902
|
+
);
|
|
1903
|
+
const client = createClient({
|
|
1904
|
+
apiKey,
|
|
1905
|
+
baseUrl: options.baseUrl,
|
|
1906
|
+
identity: { provider: PROVIDER, workspaceId }
|
|
1907
|
+
});
|
|
1908
|
+
return {
|
|
1909
|
+
...withLeadFields(readers(client), options.leadFields),
|
|
1910
|
+
capabilities: { ...capabilities, ...options.capabilities },
|
|
1911
|
+
caveats,
|
|
1912
|
+
costs,
|
|
1913
|
+
events: heyreachEvents(PROVIDER),
|
|
1914
|
+
fields: withMappedFields(fields, options.leadFields),
|
|
1915
|
+
limits,
|
|
1916
|
+
mapError: errorMapper(apiKey),
|
|
1917
|
+
// Read-only checks passed against one live workspace on 2026-11-14.
|
|
1918
|
+
maturity: "beta",
|
|
1919
|
+
name: PROVIDER,
|
|
1920
|
+
native: NATIVE,
|
|
1921
|
+
raw: client.raw,
|
|
1922
|
+
secrets: [apiKey],
|
|
1923
|
+
workspaceId
|
|
1924
|
+
};
|
|
1925
|
+
};
|
|
1926
|
+
export {
|
|
1927
|
+
NATIVE,
|
|
1928
|
+
PROVIDER,
|
|
1929
|
+
envVars,
|
|
1930
|
+
heyreach
|
|
1931
|
+
};
|