outbound-sdk 0.1.0 → 0.2.1
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/README.md +0 -2
- package/dist/alerts/index.js +5 -1
- package/dist/audit/index.js +2 -2
- package/dist/benchmarks/index.js +5 -3
- package/dist/budget/index.js +31 -10
- package/dist/cache/index.js +2 -2
- package/dist/cards/index.js +1 -1
- package/dist/chunks/{chunk-WAM6N4OF.js → chunk-4PSO6JEK.js} +107 -19
- package/dist/chunks/chunk-6CVZOUHB.js +152 -0
- package/dist/chunks/{chunk-OCV66TS2.js → chunk-AFU5E5QB.js} +17 -8
- package/dist/chunks/{chunk-R6AM4GJR.js → chunk-DJ2IUQEU.js} +24 -18
- package/dist/chunks/{chunk-LOXBLQ3I.js → chunk-E7JHLNLG.js} +9 -2
- package/dist/chunks/{chunk-LNCOGBMI.js → chunk-FHKSLCVW.js} +13 -3
- package/dist/chunks/chunk-FKH5N47I.js +40 -0
- package/dist/chunks/chunk-HZCTYL22.js +29 -0
- package/dist/chunks/{chunk-CMQ5ZHLZ.js → chunk-IPUYZD4O.js} +1 -1
- package/dist/chunks/{chunk-VURTOVGI.js → chunk-IVH3NMQZ.js} +1 -1
- package/dist/chunks/{chunk-ZGHQYZEH.js → chunk-LVYG7XZJ.js} +1 -1
- package/dist/chunks/chunk-NAKXLBA6.js +30 -0
- package/dist/chunks/{chunk-7BCYLIDG.js → chunk-P3IJBJUI.js} +203 -34
- package/dist/chunks/{chunk-Q465X22Y.js → chunk-PURHK3JU.js} +93 -209
- package/dist/chunks/{chunk-F7MKFVIG.js → chunk-R3Y56YVF.js} +2 -2
- package/dist/chunks/chunk-RCZ7ZZFU.js +92 -0
- package/dist/chunks/chunk-SBIZDCRY.js +106 -0
- package/dist/chunks/{chunk-IBC52BX3.js → chunk-U2D34ARZ.js} +20 -3
- package/dist/chunks/chunk-UAT3JSJZ.js +331 -0
- package/dist/chunks/{chunk-QZNNCXXD.js → chunk-VQSCHOBV.js} +20 -1
- package/dist/chunks/{chunk-B7V6EOAC.js → chunk-XNFESPZH.js} +160 -126
- package/dist/chunks/{chunk-WW746NJF.js → chunk-YOTW5ESM.js} +25 -1
- package/dist/cli/bin.js +14 -13
- package/dist/cli/commands.d.ts +3 -0
- package/dist/cli/config.d.ts +22 -0
- package/dist/cli/index.d.ts +5 -1
- package/dist/cli/index.js +20 -15
- package/dist/cli/stdio.d.ts +9 -0
- package/dist/cli/version.d.ts +2 -0
- package/dist/clients/index.js +13 -3
- package/dist/combine/account.d.ts +1 -1
- package/dist/combine/index.js +90 -15
- package/dist/combine/route.d.ts +7 -0
- package/dist/exporter/index.js +2 -2
- package/dist/failover/index.js +4 -4
- package/dist/fixtures/index.js +40 -21
- package/dist/heyreach/account.d.ts +1 -1
- package/dist/heyreach/adapter.d.ts +1 -1
- package/dist/heyreach/capabilities.d.ts +2 -0
- package/dist/heyreach/client.d.ts +3 -5
- package/dist/heyreach/index.d.ts +7 -0
- package/dist/heyreach/index.js +428 -205
- package/dist/heyreach/leads.d.ts +4 -0
- package/dist/heyreach/map-account.d.ts +7 -1
- package/dist/heyreach/map-stats.d.ts +8 -5
- package/dist/heyreach/map.d.ts +3 -1
- package/dist/heyreach/webhooks.d.ts +1 -0
- package/dist/identity/index.js +22 -11
- package/dist/index.d.ts +1 -4
- package/dist/index.js +29 -17
- package/dist/insights/copy/index.d.ts +2 -2
- package/dist/insights/copy/variant-test.d.ts +2 -2
- package/dist/insights/index.js +248 -184
- package/dist/insights/ops/anomalies.d.ts +3 -3
- package/dist/insights/ops/index.d.ts +2 -2
- package/dist/insights/ops/shared.d.ts +7 -1
- package/dist/insights/registry.d.ts +4 -4
- package/dist/instantly/adapter-account.d.ts +1 -1
- package/dist/instantly/capabilities.d.ts +2 -0
- package/dist/instantly/client.d.ts +4 -9
- package/dist/instantly/index.d.ts +7 -0
- package/dist/instantly/index.js +410 -155
- package/dist/instantly/map-account.d.ts +20 -5
- package/dist/instantly/map-stats.d.ts +9 -6
- package/dist/instantly/map.d.ts +0 -2
- package/dist/instantly/native-agents-sales.d.ts +41 -41
- package/dist/instantly/native-agents.d.ts +44 -44
- package/dist/instantly/native-campaigns.d.ts +21 -21
- package/dist/instantly/native-leads.d.ts +12 -12
- package/dist/instantly/native-params.d.ts +2 -19
- package/dist/instantly/native-search.d.ts +10 -10
- package/dist/instantly/native-senders.d.ts +56 -56
- package/dist/instantly/native-supersearch.d.ts +33 -33
- package/dist/instantly/native-workspace.d.ts +45 -45
- package/dist/instantly/native.d.ts +262 -262
- package/dist/instantly/webhooks.d.ts +1 -0
- package/dist/internal/adapter.d.ts +24 -2
- package/dist/internal/capabilities.d.ts +18 -0
- package/dist/internal/client.d.ts +15 -0
- package/dist/internal/concurrency.d.ts +8 -0
- package/dist/internal/engine/request.d.ts +7 -0
- package/dist/internal/entities-account.d.ts +73 -3
- package/dist/internal/entities.d.ts +116 -12
- package/dist/internal/errors.d.ts +6 -1
- package/dist/internal/fields.d.ts +462 -0
- package/dist/internal/json.d.ts +9 -0
- package/dist/internal/lead-fields.d.ts +21 -0
- package/dist/internal/lead-status.d.ts +13 -0
- package/dist/internal/metrics.d.ts +14 -2
- package/dist/internal/native.d.ts +15 -0
- package/dist/internal/outbound/api.d.ts +29 -4
- package/dist/internal/outbound/operations-account.d.ts +12 -0
- package/dist/internal/outbound/outbound.d.ts +6 -3
- package/dist/internal/outbound/specs-account.d.ts +5 -1
- package/dist/internal/page.d.ts +14 -0
- package/dist/internal/record.d.ts +17 -0
- package/dist/internal/records.d.ts +7 -0
- package/dist/internal/sequence.d.ts +14 -0
- package/dist/internal/sha256.d.ts +2 -0
- package/dist/loader/index.d.ts +14 -2
- package/dist/loader/index.js +8 -4
- package/dist/memory/account-reads.d.ts +1 -1
- package/dist/memory/account.d.ts +15 -1
- package/dist/memory/data.d.ts +17 -2
- package/dist/memory/index.js +110 -35
- package/dist/redact/index.js +11 -6
- package/dist/redact/plugin.d.ts +1 -1
- package/dist/smartlead/account.d.ts +1 -1
- package/dist/smartlead/adapter.d.ts +1 -1
- package/dist/smartlead/capabilities.d.ts +2 -0
- package/dist/smartlead/client.d.ts +6 -11
- package/dist/smartlead/hmac.d.ts +0 -2
- package/dist/smartlead/index.d.ts +7 -0
- package/dist/smartlead/index.js +731 -572
- package/dist/smartlead/leads.d.ts +4 -1
- package/dist/smartlead/map-account.d.ts +17 -5
- package/dist/smartlead/map-stats.d.ts +9 -10
- package/dist/smartlead/map.d.ts +15 -5
- package/dist/smartlead/native-analytics.d.ts +87 -87
- package/dist/smartlead/native-campaigns.d.ts +64 -64
- package/dist/smartlead/native-inbox.d.ts +51 -51
- package/dist/smartlead/native-params.d.ts +2 -23
- package/dist/smartlead/native-services.d.ts +34 -34
- package/dist/smartlead/native.d.ts +236 -236
- package/dist/smartlead/shared.d.ts +6 -5
- package/dist/smartlead/webhooks.d.ts +1 -0
- package/dist/sync/index.js +3 -3
- package/dist/tools/ai-sdk.js +7 -5
- package/dist/tools/campaign-tools.d.ts +1 -1
- package/dist/tools/claude-agent.js +7 -5
- package/dist/tools/index.js +8 -6
- package/dist/tracing/index.js +2 -2
- package/dist/webhooks/index.js +10 -9
- package/package.json +1 -1
- package/dist/chunks/chunk-FZF6CLPX.js +0 -232
- package/dist/chunks/chunk-GPEJG34O.js +0 -53
- package/dist/chunks/chunk-HEC7XFFH.js +0 -65
- package/dist/chunks/chunk-QTB747K4.js +0 -100
- package/dist/chunks/chunk-TIJKJJDW.js +0 -6
package/dist/heyreach/index.js
CHANGED
|
@@ -1,48 +1,58 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EVENT_TYPES,
|
|
2
3
|
heyreachEvents
|
|
3
|
-
} from "../chunks/chunk-
|
|
4
|
+
} from "../chunks/chunk-DJ2IUQEU.js";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
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";
|
|
7
17
|
import {
|
|
8
18
|
defineNative
|
|
9
|
-
} from "../chunks/chunk-
|
|
19
|
+
} from "../chunks/chunk-NAKXLBA6.js";
|
|
10
20
|
import {
|
|
11
|
-
emptyCounts
|
|
12
|
-
|
|
21
|
+
emptyCounts,
|
|
22
|
+
metricRow
|
|
23
|
+
} from "../chunks/chunk-YOTW5ESM.js";
|
|
13
24
|
import {
|
|
14
|
-
buildUrl,
|
|
15
25
|
profileSlug
|
|
16
26
|
} from "../chunks/chunk-NAWZ73QS.js";
|
|
17
27
|
import {
|
|
18
28
|
stableId
|
|
19
|
-
} from "../chunks/chunk-
|
|
29
|
+
} from "../chunks/chunk-FHKSLCVW.js";
|
|
20
30
|
import {
|
|
21
31
|
readEnv,
|
|
22
32
|
requireCredential
|
|
23
|
-
} from "../chunks/chunk-
|
|
33
|
+
} from "../chunks/chunk-IPUYZD4O.js";
|
|
24
34
|
import {
|
|
35
|
+
eventTypesOf,
|
|
25
36
|
recordBase,
|
|
26
37
|
refTo,
|
|
27
38
|
refsTo
|
|
28
|
-
} from "../chunks/chunk-
|
|
29
|
-
import
|
|
30
|
-
SCHEMA_VERSION
|
|
31
|
-
} from "../chunks/chunk-WAM6N4OF.js";
|
|
39
|
+
} from "../chunks/chunk-U2D34ARZ.js";
|
|
40
|
+
import "../chunks/chunk-4PSO6JEK.js";
|
|
32
41
|
import {
|
|
33
|
-
assertWorkspaceId
|
|
34
|
-
|
|
35
|
-
} from "../chunks/chunk-ZGHQYZEH.js";
|
|
42
|
+
assertWorkspaceId
|
|
43
|
+
} from "../chunks/chunk-LVYG7XZJ.js";
|
|
36
44
|
import {
|
|
37
45
|
OutboundError,
|
|
38
46
|
isHttpFailure,
|
|
39
|
-
makeErrorMapper
|
|
40
|
-
|
|
47
|
+
makeErrorMapper,
|
|
48
|
+
requireObject
|
|
49
|
+
} from "../chunks/chunk-E7JHLNLG.js";
|
|
41
50
|
import {
|
|
42
51
|
count,
|
|
43
52
|
emailAddress,
|
|
44
53
|
field,
|
|
45
54
|
flag,
|
|
55
|
+
fullName,
|
|
46
56
|
isJsonObject,
|
|
47
57
|
isNumber,
|
|
48
58
|
isString,
|
|
@@ -50,14 +60,29 @@ import {
|
|
|
50
60
|
objects,
|
|
51
61
|
text,
|
|
52
62
|
timestamp
|
|
53
|
-
} from "../chunks/chunk-
|
|
63
|
+
} from "../chunks/chunk-VQSCHOBV.js";
|
|
54
64
|
|
|
55
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
|
+
};
|
|
56
81
|
var toLeadList = (identity, raw) => ({
|
|
57
82
|
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
58
83
|
createdAt: timestamp(raw.creationTime),
|
|
59
84
|
kind: text(raw.listType) === "COMPANY_LIST" ? "companies" : "leads",
|
|
60
|
-
name: text(raw.name) ?? "",
|
|
85
|
+
name: text(raw.name) ?? text(raw.id) ?? "",
|
|
61
86
|
size: count(raw.totalItemsCount)
|
|
62
87
|
});
|
|
63
88
|
var blockedLead = (raw) => {
|
|
@@ -107,6 +132,11 @@ var toWebhook = (identity, raw) => {
|
|
|
107
132
|
active: flag(raw.isActive),
|
|
108
133
|
campaignRefs: refsTo(identity, campaigns),
|
|
109
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
|
+
),
|
|
110
140
|
events: event === null ? [] : [event],
|
|
111
141
|
name: text(raw.webhookName),
|
|
112
142
|
url: text(raw.webhookUrl) ?? ""
|
|
@@ -148,14 +178,10 @@ var toCampaign = (identity, raw) => ({
|
|
|
148
178
|
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
149
179
|
channel: "linkedin",
|
|
150
180
|
createdAt: timestamp(raw.creationTime),
|
|
151
|
-
name: text(raw.name) ?? "",
|
|
181
|
+
name: text(raw.name) ?? text(raw.id) ?? "",
|
|
152
182
|
status: CAMPAIGN_STATUS.get(text(raw.status) ?? "") ?? "unknown",
|
|
153
183
|
tags: []
|
|
154
184
|
});
|
|
155
|
-
var fullName = (raw) => {
|
|
156
|
-
const name = [text(raw.firstName), text(raw.lastName)].filter((part) => part !== null).join(" ");
|
|
157
|
-
return name === "" ? null : name;
|
|
158
|
-
};
|
|
159
185
|
var senderStatus = (raw) => {
|
|
160
186
|
if (flag(raw.authIsValid) === false) {
|
|
161
187
|
return "disconnected";
|
|
@@ -173,18 +199,28 @@ var toSender = (identity, raw) => ({
|
|
|
173
199
|
dailyLimit: null,
|
|
174
200
|
kind: "linkedin",
|
|
175
201
|
linkedinUrl: text(raw.profileUrl),
|
|
176
|
-
|
|
202
|
+
mailProvider: null,
|
|
203
|
+
name: fullName(raw.firstName, raw.lastName),
|
|
177
204
|
status: senderStatus(raw),
|
|
205
|
+
// HeyReach has no tags on a LinkedIn account.
|
|
206
|
+
tags: [],
|
|
178
207
|
warmup: null
|
|
179
208
|
});
|
|
180
|
-
var
|
|
209
|
+
var LEAD_PROGRESS = /* @__PURE__ */ new Map([
|
|
181
210
|
["Finished", "completed"],
|
|
182
211
|
["InSequence", "active"],
|
|
183
212
|
["Paused", "paused"],
|
|
184
213
|
["Pending", "active"]
|
|
185
214
|
]);
|
|
186
|
-
var
|
|
187
|
-
var
|
|
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
|
+
};
|
|
188
224
|
var tagNames = (value) => list(value).flatMap((tag) => {
|
|
189
225
|
const name = text(tag);
|
|
190
226
|
return name === null ? [] : [name];
|
|
@@ -197,6 +233,12 @@ var interest = (profile) => {
|
|
|
197
233
|
);
|
|
198
234
|
return text(newest?.name);
|
|
199
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;
|
|
200
242
|
var customFields = (profile) => Object.fromEntries(
|
|
201
243
|
objects(field(profile, "customFields")).flatMap((pair) => {
|
|
202
244
|
const name = text(pair.name);
|
|
@@ -211,32 +253,42 @@ var profileFields = (identity, profile, raw) => ({
|
|
|
211
253
|
raw
|
|
212
254
|
),
|
|
213
255
|
company: text(field(profile, "companyName")),
|
|
256
|
+
// `companyUrl` is the company's LinkedIn page, not its website.
|
|
257
|
+
companyLinkedinUrl: text(field(profile, "companyUrl")),
|
|
214
258
|
custom: customFields(profile),
|
|
215
259
|
email: emailAddress(field(profile, "emailAddress")) ?? emailAddress(field(profile, "enrichedEmailAddress")) ?? emailAddress(field(profile, "customEmailAddress")),
|
|
216
260
|
// HeyReach reports no per-lead open, click or reply counts.
|
|
217
261
|
engagement: null,
|
|
218
262
|
firstName: text(field(profile, "firstName")),
|
|
219
263
|
interest: interest(profile),
|
|
264
|
+
interestCategory: interestCategory(profile),
|
|
220
265
|
lastName: text(field(profile, "lastName")),
|
|
221
266
|
tags: tagNames(field(profile, "tags")),
|
|
222
267
|
linkedinUrl: text(field(profile, "profileUrl")),
|
|
223
|
-
|
|
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
|
|
224
273
|
});
|
|
225
274
|
var toLead = (identity, raw, tags) => {
|
|
226
275
|
const lead = profileFields(identity, raw, raw);
|
|
227
276
|
return {
|
|
228
277
|
...lead,
|
|
278
|
+
...standing("unknown"),
|
|
229
279
|
campaignRef: null,
|
|
230
280
|
createdAt: null,
|
|
231
|
-
status: "unknown",
|
|
232
281
|
tags: tags === void 0 ? lead.tags : tagNames(tags)
|
|
233
282
|
};
|
|
234
283
|
};
|
|
235
284
|
var toCampaignLead = (identity, raw, campaignId) => ({
|
|
236
285
|
...profileFields(identity, raw.linkedInUserProfile, raw),
|
|
286
|
+
...standing(
|
|
287
|
+
campaignProgress(raw.leadCampaignStatus),
|
|
288
|
+
raw.leadMessageStatus ?? null
|
|
289
|
+
),
|
|
237
290
|
campaignRef: refTo(identity, campaignId),
|
|
238
|
-
createdAt: timestamp(raw.creationTime)
|
|
239
|
-
status: leadStatus(raw)
|
|
291
|
+
createdAt: timestamp(raw.creationTime)
|
|
240
292
|
});
|
|
241
293
|
var profileEmails = (profile) => [
|
|
242
294
|
profile.emailAddress,
|
|
@@ -249,10 +301,10 @@ var toLookupLead = (identity, profile, campaign, email) => {
|
|
|
249
301
|
const lead = profileFields(identity, profile, raw);
|
|
250
302
|
return {
|
|
251
303
|
...lead,
|
|
304
|
+
...standing(campaignProgress(campaign?.leadStatus)),
|
|
252
305
|
campaignRef: refTo(identity, text(campaign?.campaignId)),
|
|
253
306
|
createdAt: null,
|
|
254
|
-
email: email ?? lead.email
|
|
255
|
-
status: campaignLeadStatus(campaign?.leadStatus)
|
|
307
|
+
email: email ?? lead.email
|
|
256
308
|
};
|
|
257
309
|
};
|
|
258
310
|
var listEnvelope = (body, offset) => {
|
|
@@ -274,6 +326,10 @@ var LIST_LEADS_PAGE_SIZE = 1e3;
|
|
|
274
326
|
var capabilities = {
|
|
275
327
|
// POST /blacklist/GetLeads, then POST /blacklist/GetCompanies.
|
|
276
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,
|
|
277
333
|
// A campaign's schedule can only be written (POST /campaign/UpdateSchedule).
|
|
278
334
|
// GET /campaign/GetById returns no schedule, limits or stop rules.
|
|
279
335
|
"campaigns.settings": false,
|
|
@@ -287,8 +343,9 @@ var capabilities = {
|
|
|
287
343
|
// No lead shape carries open, click or reply counts.
|
|
288
344
|
"leads.engagement": false,
|
|
289
345
|
"leads.get": true,
|
|
290
|
-
//
|
|
291
|
-
|
|
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,
|
|
292
349
|
// POST /campaign/GetCampaignsForLead takes an email or a profile URL, and
|
|
293
350
|
// POST /lead/GetLead gives the profile.
|
|
294
351
|
"leads.lookup": true,
|
|
@@ -297,6 +354,8 @@ var capabilities = {
|
|
|
297
354
|
// Messages live inside conversations (POST /inbox/GetConversationsV3). A
|
|
298
355
|
// lead's timeline is the conversations filtered to its profile URL.
|
|
299
356
|
"leads.timeline": true,
|
|
357
|
+
// GET /list/GetById.
|
|
358
|
+
"lists.get": true,
|
|
300
359
|
// POST /list/GetLeadsFromList.
|
|
301
360
|
"lists.leads": true,
|
|
302
361
|
// POST /list/GetAll.
|
|
@@ -308,8 +367,11 @@ var capabilities = {
|
|
|
308
367
|
// GetConversationsV3 bounds conversations by the time of their newest
|
|
309
368
|
// message (`from`); the adapter then drops the older messages inside them.
|
|
310
369
|
"messages.since": "server",
|
|
311
|
-
//
|
|
312
|
-
|
|
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",
|
|
313
375
|
"replies.list": true,
|
|
314
376
|
"replies.since": "server",
|
|
315
377
|
// GET /campaign/GetById names the campaign's account ids; the account list
|
|
@@ -328,6 +390,9 @@ var capabilities = {
|
|
|
328
390
|
// GetOverallStats filtered to one account id.
|
|
329
391
|
"stats.bySender": "exact",
|
|
330
392
|
"stats.byStep": false,
|
|
393
|
+
// POST /stats/GetOverallStatsByCampaign: the counts of GetOverallStats,
|
|
394
|
+
// a row per campaign.
|
|
395
|
+
"stats.allCampaigns": "full",
|
|
331
396
|
"stats.campaign": "exact",
|
|
332
397
|
"stats.workspace": "exact",
|
|
333
398
|
// Tags can be created (POST /lead_tags/CreateTags) and read per lead
|
|
@@ -335,11 +400,69 @@ var capabilities = {
|
|
|
335
400
|
tags: false,
|
|
336
401
|
// Every other documented read, by name: see native.ts.
|
|
337
402
|
native: true,
|
|
403
|
+
// GET /webhooks/GetWebhookById, always asked for without custom headers.
|
|
404
|
+
"webhooks.get": true,
|
|
338
405
|
// POST /webhooks/GetAllWebhooks.
|
|
339
406
|
"webhooks.list": true,
|
|
340
407
|
// CheckApiKey returns no identity and only an organization key can list workspaces.
|
|
341
408
|
workspaces: false
|
|
342
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
|
+
};
|
|
343
466
|
var limits = {
|
|
344
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",
|
|
345
468
|
// The Organization Management API has a separate limit of 300 requests a
|
|
@@ -359,7 +482,8 @@ var costs = {
|
|
|
359
482
|
"campaigns.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
360
483
|
// The profile and its tags are two requests.
|
|
361
484
|
"leads.get": { perPage: 2 },
|
|
362
|
-
// A campaign's leads. A saved list's leads come up to 1000 a page.
|
|
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.
|
|
363
487
|
"leads.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
364
488
|
// One person by profile URL: the campaigns and the profile, two requests.
|
|
365
489
|
// By email it is three (campaigns, the lists the address is in, a name
|
|
@@ -380,6 +504,7 @@ var costs = {
|
|
|
380
504
|
};
|
|
381
505
|
var caveats = [
|
|
382
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.",
|
|
383
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.",
|
|
384
509
|
"Lists return totalCount and no next marker, so the end of a list is computed as offset plus page length reaching totalCount.",
|
|
385
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.",
|
|
@@ -395,7 +520,7 @@ var caveats = [
|
|
|
395
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.",
|
|
396
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.",
|
|
397
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.",
|
|
398
|
-
"
|
|
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.",
|
|
399
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.",
|
|
400
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.",
|
|
401
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.",
|
|
@@ -414,7 +539,7 @@ var caveats = [
|
|
|
414
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.",
|
|
415
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.",
|
|
416
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.",
|
|
417
|
-
"
|
|
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.",
|
|
418
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.",
|
|
419
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.",
|
|
420
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.",
|
|
@@ -475,6 +600,43 @@ var accountReaders = (client) => ({
|
|
|
475
600
|
client.object(await client.get(ctx, path), path)
|
|
476
601
|
);
|
|
477
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
|
+
},
|
|
478
640
|
listBlocklist: listBlocklist(client),
|
|
479
641
|
listLists: async (query, ctx) => {
|
|
480
642
|
const offset = offsetOf(query.next);
|
|
@@ -485,10 +647,7 @@ var accountReaders = (client) => ({
|
|
|
485
647
|
}),
|
|
486
648
|
offset
|
|
487
649
|
);
|
|
488
|
-
return
|
|
489
|
-
items: envelope.items.map((item) => toLeadList(client.identity, item)),
|
|
490
|
-
next: envelope.next
|
|
491
|
-
};
|
|
650
|
+
return mapPage(envelope, (item) => toLeadList(client.identity, item));
|
|
492
651
|
},
|
|
493
652
|
listWebhooks: async (query, ctx) => {
|
|
494
653
|
const offset = offsetOf(query.next);
|
|
@@ -521,7 +680,7 @@ var campaignAccountIds = async (client, ctx, query) => {
|
|
|
521
680
|
const path = "/campaign/GetById";
|
|
522
681
|
const campaign = client.object(
|
|
523
682
|
await client.get(ctx, path, {
|
|
524
|
-
campaignId: numericId(client, query.campaignId, "campaign")
|
|
683
|
+
query: { campaignId: numericId(client, query.campaignId, "campaign") }
|
|
525
684
|
}),
|
|
526
685
|
path
|
|
527
686
|
);
|
|
@@ -580,14 +739,19 @@ var toMessage = (scope, conversation, raw) => ({
|
|
|
580
739
|
...messageFields(scope, conversation, raw),
|
|
581
740
|
direction: isFromLead(raw) ? "in" : "out"
|
|
582
741
|
});
|
|
583
|
-
var toReply = (scope, conversation, raw) =>
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
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
|
+
};
|
|
591
755
|
var numeric = (id) => /^\d+$/u.test(id) ? Number(id) : null;
|
|
592
756
|
var readConversations = async (client, ctx, query) => {
|
|
593
757
|
const filters = {};
|
|
@@ -595,6 +759,9 @@ var readConversations = async (client, ctx, query) => {
|
|
|
595
759
|
if (campaign !== null) {
|
|
596
760
|
filters.campaignIds = [campaign];
|
|
597
761
|
}
|
|
762
|
+
if ("unread" in query && query.unread !== void 0) {
|
|
763
|
+
filters.seen = !query.unread;
|
|
764
|
+
}
|
|
598
765
|
if ("leadId" in query && query.leadId !== void 0) {
|
|
599
766
|
filters.leadProfileUrl = query.leadId;
|
|
600
767
|
}
|
|
@@ -677,7 +844,12 @@ var inboxReaders = (client) => ({
|
|
|
677
844
|
(conversation) => objects(conversation.messages).flatMap(
|
|
678
845
|
(raw) => isFromLead(raw) ? [toReply(scope, conversation, raw)] : []
|
|
679
846
|
)
|
|
680
|
-
).filter(
|
|
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
|
+
),
|
|
681
853
|
next: page2.next
|
|
682
854
|
};
|
|
683
855
|
}
|
|
@@ -804,6 +976,142 @@ var lookupLeads = async (client, ctx, query) => {
|
|
|
804
976
|
};
|
|
805
977
|
};
|
|
806
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
|
+
|
|
807
1115
|
// src/heyreach/map-sequence.ts
|
|
808
1116
|
var DELAY_DAYS = /* @__PURE__ */ new Map([
|
|
809
1117
|
["DAY", 1],
|
|
@@ -842,13 +1150,10 @@ var toStep = (node, index, position) => {
|
|
|
842
1150
|
delayDays: own === null ? null : own + position.waited,
|
|
843
1151
|
index,
|
|
844
1152
|
parentIndex: position.parentIndex,
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
// Variants are positional: 0 is "A".
|
|
850
|
-
variantKey: String.fromCodePoint(65 + variantIndex)
|
|
851
|
-
}))
|
|
1153
|
+
// Variants are positional and have no subject.
|
|
1154
|
+
variants: variantBodies(node.payload).map(
|
|
1155
|
+
(body, variantIndex) => toVariant(null, body, variantKey(variantIndex))
|
|
1156
|
+
)
|
|
852
1157
|
};
|
|
853
1158
|
};
|
|
854
1159
|
var walk = (node, position, steps) => {
|
|
@@ -906,21 +1211,13 @@ var counts = (stats) => ({
|
|
|
906
1211
|
replied: replies(stats),
|
|
907
1212
|
sent: count(field(stats, "messagesSent"))
|
|
908
1213
|
});
|
|
909
|
-
var row = (scope, stats, date) => (
|
|
910
|
-
...counts(stats),
|
|
911
|
-
contentHash: null,
|
|
912
|
-
date,
|
|
913
|
-
evidence: "exact",
|
|
914
|
-
provider: scope.provider,
|
|
915
|
-
schemaVersion: SCHEMA_VERSION,
|
|
916
|
-
scope: scope.scope,
|
|
917
|
-
scopeRef: makeRef(scope.provider, scope.workspaceId, scope.scopeId),
|
|
918
|
-
stepIndex: null,
|
|
1214
|
+
var row = (scope, stats, date) => (
|
|
919
1215
|
// Days are keyed by UTC midnight.
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
})
|
|
1216
|
+
metricRow(scope, counts(stats), {
|
|
1217
|
+
date,
|
|
1218
|
+
timezone: date === null ? null : "UTC"
|
|
1219
|
+
})
|
|
1220
|
+
);
|
|
924
1221
|
var totalRow = (scope, body) => row(scope, field(body, "overallStats"), null);
|
|
925
1222
|
var dailyRows = (scope, body) => {
|
|
926
1223
|
const days = field(body, "byDayStats");
|
|
@@ -929,6 +1226,24 @@ var dailyRows = (scope, body) => {
|
|
|
929
1226
|
return date === void 0 ? [] : [row(scope, stats, date)];
|
|
930
1227
|
});
|
|
931
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
|
+
};
|
|
932
1247
|
|
|
933
1248
|
// src/heyreach/adapter.ts
|
|
934
1249
|
var statsBody = (client, query) => {
|
|
@@ -945,10 +1260,10 @@ var statsBody = (client, query) => {
|
|
|
945
1260
|
{ provider }
|
|
946
1261
|
);
|
|
947
1262
|
}
|
|
948
|
-
const id = query.scopeId
|
|
1263
|
+
const id = query.scopeId;
|
|
949
1264
|
const body = {
|
|
950
|
-
accountIds: query.scope === "sender" ? [numericId(client, id, "account")] : [],
|
|
951
|
-
campaignIds: query.scope === "campaign" ? [numericId(client, id, "campaign")] : []
|
|
1265
|
+
accountIds: query.scope === "sender" ? [numericId(client, id ?? "", "account")] : [],
|
|
1266
|
+
campaignIds: query.scope === "campaign" && id !== void 0 ? [numericId(client, id, "campaign")] : []
|
|
952
1267
|
};
|
|
953
1268
|
if (query.from !== void 0 && query.to !== void 0) {
|
|
954
1269
|
body.startDate = `${query.from}T00:00:00.000Z`;
|
|
@@ -957,6 +1272,17 @@ var statsBody = (client, query) => {
|
|
|
957
1272
|
return body;
|
|
958
1273
|
};
|
|
959
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
|
+
}
|
|
960
1286
|
const body = await client.post(
|
|
961
1287
|
ctx,
|
|
962
1288
|
"/stats/GetOverallStats",
|
|
@@ -969,97 +1295,6 @@ var readStats = async (client, ctx, query) => {
|
|
|
969
1295
|
};
|
|
970
1296
|
return query.by === "day" ? dailyRows(scope, body) : [totalRow(scope, body)];
|
|
971
1297
|
};
|
|
972
|
-
var listLeadsBody = (client, query, offset) => {
|
|
973
|
-
const body = {
|
|
974
|
-
limit: pageSize(query.limit, LIST_LEADS_PAGE_SIZE),
|
|
975
|
-
listId: numericId(client, query.listId, "list"),
|
|
976
|
-
offset
|
|
977
|
-
};
|
|
978
|
-
if (query.since !== void 0) {
|
|
979
|
-
body.createdFrom = query.since;
|
|
980
|
-
}
|
|
981
|
-
if (query.until !== void 0) {
|
|
982
|
-
body.createdTo = query.until;
|
|
983
|
-
}
|
|
984
|
-
return body;
|
|
985
|
-
};
|
|
986
|
-
var campaignLeadsBody = (client, query, offset) => {
|
|
987
|
-
const body = {
|
|
988
|
-
campaignId: numericId(client, query.campaignId, "campaign"),
|
|
989
|
-
limit: pageSize(query.limit),
|
|
990
|
-
offset
|
|
991
|
-
};
|
|
992
|
-
if (query.since !== void 0 || query.until !== void 0) {
|
|
993
|
-
body.timeFilter = "CreationTime";
|
|
994
|
-
}
|
|
995
|
-
if (query.since !== void 0) {
|
|
996
|
-
body.timeFrom = query.since;
|
|
997
|
-
}
|
|
998
|
-
if (query.until !== void 0) {
|
|
999
|
-
body.timeTo = query.until;
|
|
1000
|
-
}
|
|
1001
|
-
return body;
|
|
1002
|
-
};
|
|
1003
|
-
var leadReaders = (client) => ({
|
|
1004
|
-
// The lead's id is its LinkedIn profile URL, the only key GetLead takes.
|
|
1005
|
-
// GetLead carries no tags, so they are read beside it. A looked-up lead's
|
|
1006
|
-
// id also names its campaign, which is dropped here.
|
|
1007
|
-
getLead: async (id, ctx) => {
|
|
1008
|
-
const path = "/lead/GetLead";
|
|
1009
|
-
const profileUrl = id;
|
|
1010
|
-
const [lead, tags] = await Promise.all([
|
|
1011
|
-
client.post(ctx, path, { profileUrl }),
|
|
1012
|
-
client.post(ctx, "/lead/GetTags", { profileUrl })
|
|
1013
|
-
]);
|
|
1014
|
-
return toLead(
|
|
1015
|
-
client.identity,
|
|
1016
|
-
client.object(lead, path),
|
|
1017
|
-
field(tags, "tags") ?? []
|
|
1018
|
-
);
|
|
1019
|
-
},
|
|
1020
|
-
listLeads: async (query, ctx) => {
|
|
1021
|
-
if (query.email !== void 0 || query.linkedinUrl !== void 0) {
|
|
1022
|
-
return await lookupLeads(client, ctx, query);
|
|
1023
|
-
}
|
|
1024
|
-
const offset = offsetOf(query.next);
|
|
1025
|
-
const { campaignId, listId } = query;
|
|
1026
|
-
if (listId !== void 0) {
|
|
1027
|
-
const envelope2 = listEnvelope(
|
|
1028
|
-
await client.post(
|
|
1029
|
-
ctx,
|
|
1030
|
-
"/list/GetLeadsFromList",
|
|
1031
|
-
listLeadsBody(client, { ...query, listId }, offset)
|
|
1032
|
-
),
|
|
1033
|
-
offset
|
|
1034
|
-
);
|
|
1035
|
-
return {
|
|
1036
|
-
items: envelope2.items.map((item) => toLead(client.identity, item)),
|
|
1037
|
-
next: envelope2.next
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
if (campaignId === void 0) {
|
|
1041
|
-
throw new OutboundError(
|
|
1042
|
-
"Unsupported",
|
|
1043
|
-
"HeyReach has no list of every lead. List a campaign's leads, outbound.campaign(id).leads.list(), or a saved list's, outbound.list(id).leads.list()",
|
|
1044
|
-
{ provider: client.identity.provider }
|
|
1045
|
-
);
|
|
1046
|
-
}
|
|
1047
|
-
const envelope = listEnvelope(
|
|
1048
|
-
await client.post(
|
|
1049
|
-
ctx,
|
|
1050
|
-
"/campaign/GetLeadsFromCampaign",
|
|
1051
|
-
campaignLeadsBody(client, { ...query, campaignId }, offset)
|
|
1052
|
-
),
|
|
1053
|
-
offset
|
|
1054
|
-
);
|
|
1055
|
-
return {
|
|
1056
|
-
items: envelope.items.map(
|
|
1057
|
-
(item) => toCampaignLead(client.identity, item, campaignId)
|
|
1058
|
-
),
|
|
1059
|
-
next: envelope.next
|
|
1060
|
-
};
|
|
1061
|
-
}
|
|
1062
|
-
});
|
|
1063
1298
|
var readers = (client) => {
|
|
1064
1299
|
const { identity } = client;
|
|
1065
1300
|
return {
|
|
@@ -1070,21 +1305,27 @@ var readers = (client) => {
|
|
|
1070
1305
|
const path = "/campaign/GetById";
|
|
1071
1306
|
return toCampaign(
|
|
1072
1307
|
identity,
|
|
1073
|
-
client.object(
|
|
1308
|
+
client.object(
|
|
1309
|
+
await client.get(ctx, path, { query: { campaignId: id } }),
|
|
1310
|
+
path
|
|
1311
|
+
)
|
|
1074
1312
|
);
|
|
1075
1313
|
},
|
|
1076
1314
|
getSender: async (id, ctx) => {
|
|
1077
1315
|
const path = "/li_account/GetById";
|
|
1078
1316
|
return toSender(
|
|
1079
1317
|
identity,
|
|
1080
|
-
client.object(
|
|
1318
|
+
client.object(
|
|
1319
|
+
await client.get(ctx, path, { query: { accountId: id } }),
|
|
1320
|
+
path
|
|
1321
|
+
)
|
|
1081
1322
|
);
|
|
1082
1323
|
},
|
|
1083
1324
|
getSequence: async (id, ctx) => toSequence(
|
|
1084
1325
|
identity,
|
|
1085
1326
|
id,
|
|
1086
1327
|
await client.get(ctx, "/campaign/GetCampaignSequence", {
|
|
1087
|
-
campaignId: id
|
|
1328
|
+
query: { campaignId: id }
|
|
1088
1329
|
})
|
|
1089
1330
|
),
|
|
1090
1331
|
listCampaigns: async (query, ctx) => {
|
|
@@ -1097,14 +1338,14 @@ var readers = (client) => {
|
|
|
1097
1338
|
}
|
|
1098
1339
|
body.statuses = statuses;
|
|
1099
1340
|
}
|
|
1341
|
+
if (query.senderId !== void 0) {
|
|
1342
|
+
body.accountIds = [numericId(client, query.senderId, "account")];
|
|
1343
|
+
}
|
|
1100
1344
|
const envelope = listEnvelope(
|
|
1101
1345
|
await client.post(ctx, "/campaign/GetAll", body),
|
|
1102
1346
|
offset
|
|
1103
1347
|
);
|
|
1104
|
-
return
|
|
1105
|
-
items: envelope.items.map((item) => toCampaign(identity, item)),
|
|
1106
|
-
next: envelope.next
|
|
1107
|
-
};
|
|
1348
|
+
return mapPage(envelope, (item) => toCampaign(identity, item));
|
|
1108
1349
|
},
|
|
1109
1350
|
listSenders: async (query, ctx) => {
|
|
1110
1351
|
const { campaignId } = query;
|
|
@@ -1119,10 +1360,7 @@ var readers = (client) => {
|
|
|
1119
1360
|
}),
|
|
1120
1361
|
offset
|
|
1121
1362
|
);
|
|
1122
|
-
return
|
|
1123
|
-
items: envelope.items.map((item) => toSender(identity, item)),
|
|
1124
|
-
next: envelope.next
|
|
1125
|
-
};
|
|
1363
|
+
return mapPage(envelope, (item) => toSender(identity, item));
|
|
1126
1364
|
},
|
|
1127
1365
|
stats: (query, ctx) => readStats(client, ctx, query)
|
|
1128
1366
|
};
|
|
@@ -1179,29 +1417,13 @@ var createClient = (options) => {
|
|
|
1179
1417
|
headers: { ...spec.headers, "X-API-KEY": options.apiKey }
|
|
1180
1418
|
});
|
|
1181
1419
|
return {
|
|
1182
|
-
|
|
1183
|
-
const response = await ctx.request(
|
|
1184
|
-
authorize({ method: "GET", url: buildUrl(baseUrl, path, query) })
|
|
1185
|
-
);
|
|
1186
|
-
return response.body;
|
|
1187
|
-
},
|
|
1420
|
+
...createVendorClient(baseUrl, authorize),
|
|
1188
1421
|
identity: options.identity,
|
|
1189
|
-
object: (body, path) =>
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
{ provider: options.identity.provider }
|
|
1195
|
-
);
|
|
1196
|
-
}
|
|
1197
|
-
return body;
|
|
1198
|
-
},
|
|
1199
|
-
post: async (ctx, path, body) => {
|
|
1200
|
-
const response = await ctx.request(
|
|
1201
|
-
authorize({ body, method: "POST", url: buildUrl(baseUrl, path) })
|
|
1202
|
-
);
|
|
1203
|
-
return response.body;
|
|
1204
|
-
},
|
|
1422
|
+
object: (body, path) => requireObject(
|
|
1423
|
+
body,
|
|
1424
|
+
options.identity.provider,
|
|
1425
|
+
`HeyReach returned no object for ${path}`
|
|
1426
|
+
),
|
|
1205
1427
|
raw: { authorize, baseUrl, isRead, isSecret }
|
|
1206
1428
|
};
|
|
1207
1429
|
};
|
|
@@ -1684,11 +1906,12 @@ var heyreach = (options = {}) => {
|
|
|
1684
1906
|
identity: { provider: PROVIDER, workspaceId }
|
|
1685
1907
|
});
|
|
1686
1908
|
return {
|
|
1687
|
-
...readers(client),
|
|
1909
|
+
...withLeadFields(readers(client), options.leadFields),
|
|
1688
1910
|
capabilities: { ...capabilities, ...options.capabilities },
|
|
1689
1911
|
caveats,
|
|
1690
1912
|
costs,
|
|
1691
1913
|
events: heyreachEvents(PROVIDER),
|
|
1914
|
+
fields: withMappedFields(fields, options.leadFields),
|
|
1692
1915
|
limits,
|
|
1693
1916
|
mapError: errorMapper(apiKey),
|
|
1694
1917
|
// Read-only checks passed against one live workspace on 2026-11-14.
|