outbound-sdk 0.1.0 → 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/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-PMSSUWD7.js} +186 -33
- 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/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/instantly/index.js
CHANGED
|
@@ -1,61 +1,69 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
instantlyEvents
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
EVENT_TYPES,
|
|
3
|
+
instantlyEvents
|
|
4
|
+
} from "../chunks/chunk-SBIZDCRY.js";
|
|
5
|
+
import {
|
|
6
|
+
createVendorClient,
|
|
7
|
+
flatMapPage,
|
|
8
|
+
mapPage,
|
|
9
|
+
normalizeBody,
|
|
10
|
+
withLeadFields,
|
|
11
|
+
withMappedFields
|
|
12
|
+
} from "../chunks/chunk-6CVZOUHB.js";
|
|
12
13
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
leadStanding,
|
|
15
|
+
toVariant,
|
|
16
|
+
variantKey
|
|
17
|
+
} from "../chunks/chunk-FKH5N47I.js";
|
|
15
18
|
import {
|
|
16
|
-
defineNative
|
|
17
|
-
|
|
19
|
+
defineNative,
|
|
20
|
+
inBody,
|
|
21
|
+
inBodyRequired,
|
|
22
|
+
inPath,
|
|
23
|
+
inQuery,
|
|
24
|
+
inQueryRequired
|
|
25
|
+
} from "../chunks/chunk-NAKXLBA6.js";
|
|
18
26
|
import {
|
|
19
27
|
emptyCounts,
|
|
28
|
+
metricRow,
|
|
20
29
|
sumCounts
|
|
21
|
-
} from "../chunks/chunk-
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
} from "../chunks/chunk-NAWZ73QS.js";
|
|
25
|
-
import "../chunks/chunk-LNCOGBMI.js";
|
|
30
|
+
} from "../chunks/chunk-YOTW5ESM.js";
|
|
31
|
+
import "../chunks/chunk-NAWZ73QS.js";
|
|
32
|
+
import "../chunks/chunk-FHKSLCVW.js";
|
|
26
33
|
import {
|
|
27
34
|
readEnv,
|
|
28
35
|
requireCredential
|
|
29
|
-
} from "../chunks/chunk-
|
|
36
|
+
} from "../chunks/chunk-IPUYZD4O.js";
|
|
30
37
|
import {
|
|
38
|
+
eventTypesOf,
|
|
31
39
|
recordBase,
|
|
32
40
|
refTo,
|
|
33
41
|
refsTo
|
|
34
|
-
} from "../chunks/chunk-
|
|
35
|
-
import
|
|
36
|
-
SCHEMA_VERSION
|
|
37
|
-
} from "../chunks/chunk-WAM6N4OF.js";
|
|
42
|
+
} from "../chunks/chunk-U2D34ARZ.js";
|
|
43
|
+
import "../chunks/chunk-4PSO6JEK.js";
|
|
38
44
|
import {
|
|
39
|
-
assertWorkspaceId
|
|
40
|
-
|
|
41
|
-
} from "../chunks/chunk-ZGHQYZEH.js";
|
|
45
|
+
assertWorkspaceId
|
|
46
|
+
} from "../chunks/chunk-LVYG7XZJ.js";
|
|
42
47
|
import {
|
|
43
48
|
OutboundError,
|
|
44
|
-
makeErrorMapper
|
|
45
|
-
|
|
49
|
+
makeErrorMapper,
|
|
50
|
+
requireObject
|
|
51
|
+
} from "../chunks/chunk-E7JHLNLG.js";
|
|
46
52
|
import {
|
|
47
53
|
count,
|
|
48
54
|
emailAddress,
|
|
49
55
|
field,
|
|
50
56
|
flag,
|
|
57
|
+
fullName,
|
|
51
58
|
isJsonObject,
|
|
52
59
|
isString,
|
|
53
60
|
list,
|
|
54
61
|
objects,
|
|
55
62
|
stringMap,
|
|
56
63
|
text,
|
|
57
|
-
timestamp
|
|
58
|
-
|
|
64
|
+
timestamp,
|
|
65
|
+
withoutKeys
|
|
66
|
+
} from "../chunks/chunk-VQSCHOBV.js";
|
|
59
67
|
|
|
60
68
|
// src/instantly/map-account.ts
|
|
61
69
|
var CLOCK = /^\d{2}:\d{2}$/u;
|
|
@@ -95,6 +103,17 @@ var toCampaignSettings = (identity, raw) => {
|
|
|
95
103
|
}
|
|
96
104
|
};
|
|
97
105
|
};
|
|
106
|
+
var toCampaignProgress = (identity, campaignId, raw) => ({
|
|
107
|
+
...recordBase(identity, campaignId, raw),
|
|
108
|
+
blocked: null,
|
|
109
|
+
campaignRef: refTo(identity, campaignId) ?? "",
|
|
110
|
+
completed: count(raw.completed_count),
|
|
111
|
+
failed: null,
|
|
112
|
+
inProgress: null,
|
|
113
|
+
leads: count(raw.leads_count),
|
|
114
|
+
notStarted: null,
|
|
115
|
+
stopped: null
|
|
116
|
+
});
|
|
98
117
|
var ACCOUNT_ISSUE = /* @__PURE__ */ new Map([
|
|
99
118
|
[-3, "Sending Error"],
|
|
100
119
|
[-2, "Soft Bounce Error"],
|
|
@@ -169,14 +188,14 @@ var toSenderHealth = (identity, id, parts) => {
|
|
|
169
188
|
warmup: warmupFor(parts.warmup, address)
|
|
170
189
|
};
|
|
171
190
|
};
|
|
172
|
-
var toLeadList = (identity, raw) => {
|
|
191
|
+
var toLeadList = (identity, raw, size = null) => {
|
|
173
192
|
const id = text(raw.id) ?? "";
|
|
174
193
|
return {
|
|
175
194
|
...recordBase(identity, id, raw),
|
|
176
195
|
createdAt: timestamp(raw.timestamp_created),
|
|
177
196
|
kind: "leads",
|
|
178
197
|
name: text(raw.name) ?? id,
|
|
179
|
-
size
|
|
198
|
+
size
|
|
180
199
|
};
|
|
181
200
|
};
|
|
182
201
|
var blockKind = (raw) => {
|
|
@@ -186,12 +205,17 @@ var blockKind = (raw) => {
|
|
|
186
205
|
}
|
|
187
206
|
return isDomain ? "domain" : "email";
|
|
188
207
|
};
|
|
189
|
-
var toBlockEntry = (identity, raw) =>
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
208
|
+
var toBlockEntry = (identity, raw) => {
|
|
209
|
+
const value = text(raw.bl_value)?.toLowerCase();
|
|
210
|
+
return value === void 0 ? [] : [
|
|
211
|
+
{
|
|
212
|
+
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
213
|
+
createdAt: timestamp(raw.timestamp_created),
|
|
214
|
+
kind: blockKind(raw),
|
|
215
|
+
value
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
};
|
|
195
219
|
var toTag = (identity, raw) => {
|
|
196
220
|
const id = text(raw.id) ?? "";
|
|
197
221
|
return {
|
|
@@ -200,6 +224,29 @@ var toTag = (identity, raw) => {
|
|
|
200
224
|
name: text(raw.label) ?? id
|
|
201
225
|
};
|
|
202
226
|
};
|
|
227
|
+
var TEST_STATUS = /* @__PURE__ */ new Map([
|
|
228
|
+
[1, "active"],
|
|
229
|
+
[2, "paused"],
|
|
230
|
+
[3, "completed"]
|
|
231
|
+
]);
|
|
232
|
+
var TEST_KIND = /* @__PURE__ */ new Map([
|
|
233
|
+
[1, "one_time"],
|
|
234
|
+
[2, "automated"]
|
|
235
|
+
]);
|
|
236
|
+
var toPlacementTest = (identity, raw) => {
|
|
237
|
+
const id = text(raw.id) ?? "";
|
|
238
|
+
return {
|
|
239
|
+
...recordBase(identity, id, raw),
|
|
240
|
+
campaignRef: refTo(identity, text(raw.campaign_id)),
|
|
241
|
+
createdAt: timestamp(raw.timestamp_created),
|
|
242
|
+
endsAt: null,
|
|
243
|
+
kind: TEST_KIND.get(count(raw.type) ?? Number.NaN) ?? null,
|
|
244
|
+
name: text(raw.name) ?? id,
|
|
245
|
+
nextRunAt: timestamp(raw.timestamp_next_run),
|
|
246
|
+
startsAt: null,
|
|
247
|
+
status: TEST_STATUS.get(count(raw.status) ?? Number.NaN) ?? "unknown"
|
|
248
|
+
};
|
|
249
|
+
};
|
|
203
250
|
var webhookActive = (raw) => {
|
|
204
251
|
const status = count(raw.status);
|
|
205
252
|
if (status === 1) {
|
|
@@ -207,20 +254,142 @@ var webhookActive = (raw) => {
|
|
|
207
254
|
}
|
|
208
255
|
return status === -1 ? false : null;
|
|
209
256
|
};
|
|
210
|
-
var withoutHeaders = (raw) =>
|
|
211
|
-
Object.entries(raw).filter(([key]) => key.toLowerCase() !== "headers")
|
|
212
|
-
);
|
|
257
|
+
var withoutHeaders = (raw) => withoutKeys(raw, /^headers$/iu);
|
|
213
258
|
var toWebhook = (identity, raw) => ({
|
|
214
259
|
...recordBase(identity, text(raw.id) ?? "", withoutHeaders(raw)),
|
|
215
260
|
active: webhookActive(raw),
|
|
216
261
|
campaignRefs: refsTo(identity, [text(raw.campaign)]),
|
|
217
262
|
createdAt: timestamp(raw.timestamp_created),
|
|
263
|
+
// `all_events` is every event Instantly sends.
|
|
264
|
+
eventTypes: eventTypesOf(
|
|
265
|
+
text(raw.event_type) === "all_events" ? [...EVENT_TYPES.keys()] : [text(raw.event_type) ?? ""],
|
|
266
|
+
EVENT_TYPES
|
|
267
|
+
),
|
|
218
268
|
// A webhook for a custom lead label has no event type.
|
|
219
269
|
events: [text(raw.event_type)].flatMap((event) => event ?? []),
|
|
220
270
|
name: text(raw.name),
|
|
221
271
|
url: text(raw.target_hook_url) ?? ""
|
|
222
272
|
});
|
|
223
273
|
|
|
274
|
+
// src/instantly/map.ts
|
|
275
|
+
var CAMPAIGN_STATUS = /* @__PURE__ */ new Map([
|
|
276
|
+
[-99, "paused"],
|
|
277
|
+
[-2, "paused"],
|
|
278
|
+
[-1, "paused"],
|
|
279
|
+
[0, "draft"],
|
|
280
|
+
[1, "active"],
|
|
281
|
+
[2, "paused"],
|
|
282
|
+
[3, "completed"],
|
|
283
|
+
[4, "active"]
|
|
284
|
+
]);
|
|
285
|
+
var campaignStatusCode = (status) => (/* @__PURE__ */ new Map([
|
|
286
|
+
["completed", 3],
|
|
287
|
+
["draft", 0]
|
|
288
|
+
])).get(status);
|
|
289
|
+
var toCampaign = (identity, raw, tags = []) => ({
|
|
290
|
+
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
291
|
+
channel: "email",
|
|
292
|
+
createdAt: timestamp(raw.timestamp_created),
|
|
293
|
+
name: text(raw.name) ?? text(raw.id) ?? "",
|
|
294
|
+
status: CAMPAIGN_STATUS.get(count(raw.status) ?? Number.NaN) ?? "unknown",
|
|
295
|
+
tags: [...tags]
|
|
296
|
+
});
|
|
297
|
+
var DELAY_DAYS = /* @__PURE__ */ new Map([
|
|
298
|
+
["days", 1],
|
|
299
|
+
["hours", 1 / 24],
|
|
300
|
+
["minutes", 1 / 1440]
|
|
301
|
+
]);
|
|
302
|
+
var days = (value, unit) => {
|
|
303
|
+
const delay = count(value);
|
|
304
|
+
const perUnit = DELAY_DAYS.get(text(unit) ?? "days");
|
|
305
|
+
return delay === null || perUnit === void 0 ? null : delay * perUnit;
|
|
306
|
+
};
|
|
307
|
+
var waitBefore = (step, previous, subsequence) => {
|
|
308
|
+
if (previous !== void 0) {
|
|
309
|
+
return days(previous.delay, previous.delay_unit);
|
|
310
|
+
}
|
|
311
|
+
return subsequence ? days(step.pre_delay, step.pre_delay_unit) : 0;
|
|
312
|
+
};
|
|
313
|
+
var toSteps = (sequences, subsequence) => {
|
|
314
|
+
const steps = objects(objects(sequences)[0]?.steps);
|
|
315
|
+
return steps.map((step, index) => ({
|
|
316
|
+
action: text(step.type) ?? "email",
|
|
317
|
+
branch: null,
|
|
318
|
+
delayDays: waitBefore(step, steps[index - 1], subsequence),
|
|
319
|
+
index,
|
|
320
|
+
parentIndex: index === 0 ? null : index - 1,
|
|
321
|
+
// Variants are positional: Instantly gives them no ids.
|
|
322
|
+
variants: objects(step.variants).map(
|
|
323
|
+
(variant, variantIndex) => toVariant(
|
|
324
|
+
text(variant.subject),
|
|
325
|
+
text(variant.body),
|
|
326
|
+
variantKey(variantIndex)
|
|
327
|
+
)
|
|
328
|
+
)
|
|
329
|
+
}));
|
|
330
|
+
};
|
|
331
|
+
var toSequence = (identity, raw) => {
|
|
332
|
+
const id = text(raw.id) ?? "";
|
|
333
|
+
return {
|
|
334
|
+
...recordBase(identity, id, raw.sequences ?? null),
|
|
335
|
+
campaignRef: refTo(identity, id) ?? "",
|
|
336
|
+
kind: "main",
|
|
337
|
+
name: null,
|
|
338
|
+
steps: toSteps(raw.sequences, false)
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
var toSubsequence = (identity, raw, campaignId) => ({
|
|
342
|
+
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
343
|
+
campaignRef: refTo(identity, text(raw.parent_campaign) ?? campaignId) ?? "",
|
|
344
|
+
kind: "subsequence",
|
|
345
|
+
name: text(raw.name),
|
|
346
|
+
steps: toSteps(raw.sequences, true)
|
|
347
|
+
});
|
|
348
|
+
var SENDER_STATUS = /* @__PURE__ */ new Map([
|
|
349
|
+
[-3, "error"],
|
|
350
|
+
[-2, "error"],
|
|
351
|
+
[-1, "disconnected"],
|
|
352
|
+
[1, "active"],
|
|
353
|
+
[2, "paused"],
|
|
354
|
+
[3, "paused"]
|
|
355
|
+
]);
|
|
356
|
+
var MAIL_PROVIDER = /* @__PURE__ */ new Map([
|
|
357
|
+
[1, "smtp"],
|
|
358
|
+
[2, "google"],
|
|
359
|
+
[3, "microsoft"],
|
|
360
|
+
[4, "other"],
|
|
361
|
+
[8, "other"],
|
|
362
|
+
[11, "other"]
|
|
363
|
+
]);
|
|
364
|
+
var toSender = (identity, raw) => {
|
|
365
|
+
const address = emailAddress(raw.email);
|
|
366
|
+
const warmupStatus = count(raw.warmup_status);
|
|
367
|
+
return {
|
|
368
|
+
...recordBase(identity, address ?? "", raw),
|
|
369
|
+
address,
|
|
370
|
+
dailyLimit: count(raw.daily_limit),
|
|
371
|
+
kind: "mailbox",
|
|
372
|
+
linkedinUrl: null,
|
|
373
|
+
mailProvider: MAIL_PROVIDER.get(count(raw.provider_code) ?? Number.NaN) ?? null,
|
|
374
|
+
name: fullName(raw.first_name, raw.last_name),
|
|
375
|
+
status: SENDER_STATUS.get(count(raw.status) ?? Number.NaN) ?? "unknown",
|
|
376
|
+
// Present only when the request asked for `include_tags`.
|
|
377
|
+
tags: objects(raw.tags).flatMap((tag) => text(tag.label) ?? []),
|
|
378
|
+
warmup: warmupStatus === null && count(raw.stat_warmup_score) === null ? null : {
|
|
379
|
+
enabled: warmupStatus === null ? null : warmupStatus === 1,
|
|
380
|
+
score: count(raw.stat_warmup_score)
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
var toWorkspace = (identity, raw) => ({
|
|
385
|
+
...recordBase(identity, text(raw.id) ?? identity.workspaceId, raw),
|
|
386
|
+
name: text(raw.name) ?? identity.workspaceId
|
|
387
|
+
});
|
|
388
|
+
var listEnvelope = (body) => ({
|
|
389
|
+
items: objects(isJsonObject(body) ? body.items : body),
|
|
390
|
+
next: text(field(body, "next_starting_after")) ?? void 0
|
|
391
|
+
});
|
|
392
|
+
|
|
224
393
|
// src/instantly/capabilities.ts
|
|
225
394
|
var BASE_URL = "https://api.instantly.ai/api/v2";
|
|
226
395
|
var API_KEY_ENV = "INSTANTLY_API_KEY";
|
|
@@ -234,6 +403,10 @@ var DAY_MS = 864e5;
|
|
|
234
403
|
var TAG_PAGES = 10;
|
|
235
404
|
var capabilities = {
|
|
236
405
|
blocklist: true,
|
|
406
|
+
// GET /account-campaign-mappings/{email}.
|
|
407
|
+
"campaigns.bySender": true,
|
|
408
|
+
// GET /campaigns/analytics for one id: leads_count and completed_count.
|
|
409
|
+
"campaigns.progress": true,
|
|
237
410
|
"campaigns.settings": true,
|
|
238
411
|
// Draft and completed are filtered by Instantly. Active and paused each
|
|
239
412
|
// cover several Instantly statuses, so the adapter matches those itself.
|
|
@@ -251,6 +424,10 @@ var capabilities = {
|
|
|
251
424
|
// POST /leads/list has no date filter, so the wrapper filters after fetching.
|
|
252
425
|
"leads.since": "client",
|
|
253
426
|
"leads.timeline": true,
|
|
427
|
+
// GET /inbox-placement-tests.
|
|
428
|
+
"placementTests.list": true,
|
|
429
|
+
// GET /lead-lists/{id}, then its verification-stats for the size.
|
|
430
|
+
"lists.get": true,
|
|
254
431
|
"lists.leads": true,
|
|
255
432
|
"lists.list": true,
|
|
256
433
|
// A list response can cut a large body short (`body_fallback_reason`); the
|
|
@@ -263,6 +440,8 @@ var capabilities = {
|
|
|
263
440
|
native: true,
|
|
264
441
|
"replies.category": "vendor",
|
|
265
442
|
"replies.list": true,
|
|
443
|
+
// GET /emails takes is_unread.
|
|
444
|
+
"replies.unread": "server",
|
|
266
445
|
"replies.since": "server",
|
|
267
446
|
"senders.byCampaign": true,
|
|
268
447
|
"senders.get": true,
|
|
@@ -275,12 +454,45 @@ var capabilities = {
|
|
|
275
454
|
// Per-mailbox numbers exist by day only; a total is summed by the adapter.
|
|
276
455
|
"stats.bySender": "derived",
|
|
277
456
|
"stats.byStep": "exact",
|
|
457
|
+
// GET /campaigns/analytics with no id: a row per campaign, totals only.
|
|
458
|
+
// Partial: it has no count of interested leads and no total of opens.
|
|
459
|
+
"stats.allCampaigns": "partial",
|
|
278
460
|
"stats.campaign": "exact",
|
|
279
461
|
"stats.workspace": "exact",
|
|
280
462
|
tags: true,
|
|
463
|
+
// GET /webhooks/{id}.
|
|
464
|
+
"webhooks.get": true,
|
|
281
465
|
"webhooks.list": true,
|
|
282
466
|
workspaces: true
|
|
283
467
|
};
|
|
468
|
+
var fields = {
|
|
469
|
+
// The per-campaign report counts every lead and the finished ones only.
|
|
470
|
+
campaignProgress: {
|
|
471
|
+
blocked: false,
|
|
472
|
+
failed: false,
|
|
473
|
+
inProgress: false,
|
|
474
|
+
notStarted: false,
|
|
475
|
+
stopped: false
|
|
476
|
+
},
|
|
477
|
+
lead: {
|
|
478
|
+
companyLinkedinUrl: false,
|
|
479
|
+
linkedinUrl: false,
|
|
480
|
+
location: false,
|
|
481
|
+
tags: false
|
|
482
|
+
},
|
|
483
|
+
metricRow: {
|
|
484
|
+
connectionsAccepted: false,
|
|
485
|
+
connectionsSent: false,
|
|
486
|
+
contentHash: false,
|
|
487
|
+
delivered: false,
|
|
488
|
+
inmailsSent: false,
|
|
489
|
+
timezone: false
|
|
490
|
+
},
|
|
491
|
+
// A test has a creation time and a next run, and no start or end date.
|
|
492
|
+
placementTest: { endsAt: false, startsAt: false },
|
|
493
|
+
sender: { linkedinUrl: false },
|
|
494
|
+
senderHealth: { blacklisted: false, checkedAt: false }
|
|
495
|
+
};
|
|
284
496
|
var limits = {
|
|
285
497
|
lanes: {
|
|
286
498
|
[EMAILS_LANE]: [{ perMs: 6e4, requests: 20 }],
|
|
@@ -319,6 +531,9 @@ var costs = {
|
|
|
319
531
|
};
|
|
320
532
|
var caveats = [
|
|
321
533
|
"The reads were run once, read-only, against one live workspace on 2026-11-14. Fixtures are still built from the API V2 documentation, and subsequences, a campaign's own webhooks and a second page of most lists were not exercised because that workspace had none or too few.",
|
|
534
|
+
"Added from the API reference after that live run and not run against a live workspace: stats for every campaign (GET /campaigns/analytics with no id, where open_count is leads and no interested count exists), a mailbox's campaigns (GET /account-campaign-mappings), the unread filter (is_unread), lists.get with its size from verification-stats, webhooks.get, and a sender's tags and mailProvider.",
|
|
535
|
+
"A lead's progress is its status when that is 1 (active), 2 (paused) or 3 (completed). Status -1 is bounced and -2 unsubscribed: they say what came back, so progress is then unknown. replied is email_reply_count above 0, and a lead that replied has the status replied whatever its progress.",
|
|
536
|
+
"A placement test's kind reads type 1 as a one-time test and 2 as an automated one: the reference names the two kinds in that order and gives the numbers no names. A test's results stay native, because Instantly reports them as one row per test email.",
|
|
322
537
|
"Instantly sends next_starting_after on a last page too (seen live), and the page after it is empty. A listing therefore ends one request late; the small lookups for tags and labels stop at the first page that is not full.",
|
|
323
538
|
"A reply's category is read from the email's i_status using the lead interest status values (seen live: 0, 1, -1 and -2). A received email carries the lead's address but no lead id, so a reply's leadRef is null; a sent message has one. Instantly does not mark an email as automatic, so isAuto is null.",
|
|
324
539
|
"An email's step and a lead's last step are ids of the form sequence_step_variant, each counted from 0 (seen live, not documented); any other form gives a null step. Step analytics count steps from 0 too, and can hold a row with no step for counts Instantly could not tie to one.",
|
|
@@ -335,7 +550,7 @@ var caveats = [
|
|
|
335
550
|
"A lead's engagement.stepIndex is the last step sent, read from its status summary; lastOpenedAt is null when open tracking is off. A lead has no tags in Instantly, and the lead object was seen without a job title.",
|
|
336
551
|
"A lead is found by email with the contacts filter of POST /leads/list, documented only as the emails a lead needs to have. Whether it compares whole addresses and ignores case is not documented and was not run live, so the adapter keeps only the records whose address equals the one asked for, and a page can hold fewer records than Instantly returned. One record comes back per campaign or list the address is in. A lead has no LinkedIn profile: a lookup by profile returns nothing and sends no request.",
|
|
337
552
|
"A lead's interest is the documented label for lt_interest_status. A custom label costs one more read (lead-labels, first 100 labels), made only when a page holds a status that is not a built-in one; the same read gives a reply with a custom status its category.",
|
|
338
|
-
"A lead list's size is null: the list object has no count
|
|
553
|
+
"A listed lead list's size is null: the list object has no count. lists.get reads GET /lead-lists/{id}/verification-stats as well and takes total_leads from it, so one list by id costs two requests. kind is always leads.",
|
|
339
554
|
"Native reads return what Instantly sends, unmapped. dfyAccounts never asks for passwords. Instantly refuses per-mailbox daily analytics (413) on a large workspace unless a mailbox is named, which the per-sender stats always do.",
|
|
340
555
|
"The daily limits of leadLabelPrediction, localBusinessFilters and localBusinessSearch are counted in this process only; a restart forgets what was used.",
|
|
341
556
|
"A webhook made for a custom lead label has no event_type, so its events are empty; custom_interest_value stays in raw. The headers Instantly sends with a delivery can carry a credential, so they are left out of a webhook record's raw. The native read webhook returns them and is not offered to the vendor_read tool; outbound.raw returns a response as it is.",
|
|
@@ -386,19 +601,28 @@ var category = (value, labels) => {
|
|
|
386
601
|
}
|
|
387
602
|
return INTEREST.get(code)?.[1] ?? SENTIMENT.get(text(labels.get(code)?.interest_status_label) ?? "");
|
|
388
603
|
};
|
|
389
|
-
var
|
|
390
|
-
[-2, "unsubscribed"],
|
|
391
|
-
[-1, "bounced"],
|
|
604
|
+
var LEAD_PROGRESS = /* @__PURE__ */ new Map([
|
|
392
605
|
[1, "active"],
|
|
393
606
|
[2, "paused"],
|
|
394
607
|
[3, "completed"]
|
|
395
608
|
]);
|
|
609
|
+
var BOUNCED = -1;
|
|
610
|
+
var UNSUBSCRIBED = -2;
|
|
611
|
+
var standing = (raw) => {
|
|
612
|
+
const code = count(raw.status);
|
|
613
|
+
const replies = count(raw.email_reply_count);
|
|
614
|
+
return leadStanding(LEAD_PROGRESS.get(code ?? Number.NaN) ?? "unknown", {
|
|
615
|
+
bounced: code === null ? null : code === BOUNCED,
|
|
616
|
+
replied: replies === null ? null : replies > 0,
|
|
617
|
+
unsubscribed: code === null ? null : code === UNSUBSCRIBED
|
|
618
|
+
});
|
|
619
|
+
};
|
|
396
620
|
var STEP_ID = /^\d+_(?<step>\d+)_(?<variant>\d+)$/u;
|
|
397
621
|
var stepPosition = (value) => {
|
|
398
622
|
const groups = STEP_ID.exec(text(value) ?? "")?.groups;
|
|
399
623
|
return groups === void 0 ? { stepIndex: null, variantKey: null } : {
|
|
400
624
|
stepIndex: Number(groups.step),
|
|
401
|
-
variantKey:
|
|
625
|
+
variantKey: variantKey(Number(groups.variant))
|
|
402
626
|
};
|
|
403
627
|
};
|
|
404
628
|
var wholeStep = (value) => {
|
|
@@ -426,20 +650,26 @@ var engagement = (raw) => {
|
|
|
426
650
|
};
|
|
427
651
|
var toLead = (identity, raw, labels = NO_LABELS) => ({
|
|
428
652
|
...recordBase(identity, text(raw.id) ?? "", raw),
|
|
653
|
+
...standing(raw),
|
|
429
654
|
campaignRef: refTo(identity, text(raw.campaign)),
|
|
430
655
|
company: text(raw.company_name),
|
|
656
|
+
// An Instantly lead has no LinkedIn fields of its own.
|
|
657
|
+
companyLinkedinUrl: null,
|
|
431
658
|
createdAt: timestamp(raw.timestamp_created),
|
|
432
659
|
custom: stringMap(raw.payload),
|
|
433
660
|
email: emailAddress(raw.email),
|
|
434
661
|
engagement: engagement(raw),
|
|
435
662
|
firstName: text(raw.first_name),
|
|
436
663
|
interest: interest(raw.lt_interest_status, labels),
|
|
664
|
+
interestCategory: category(raw.lt_interest_status, labels) ?? null,
|
|
437
665
|
lastName: text(raw.last_name),
|
|
438
666
|
linkedinUrl: null,
|
|
439
|
-
|
|
667
|
+
location: null,
|
|
668
|
+
phone: text(raw.phone),
|
|
440
669
|
// Instantly tags mailboxes and campaigns, never leads.
|
|
441
670
|
tags: [],
|
|
442
|
-
title: text(raw.job_title)
|
|
671
|
+
title: text(raw.job_title),
|
|
672
|
+
website: text(raw.website) ?? text(raw.company_domain)
|
|
443
673
|
});
|
|
444
674
|
var SCHEDULED = 4;
|
|
445
675
|
var RECEIVED = 2;
|
|
@@ -464,10 +694,7 @@ var toMessage = (identity, raw, includeBody) => ({
|
|
|
464
694
|
...messageFields(identity, raw, includeBody),
|
|
465
695
|
direction: count(raw.ue_type) === RECEIVED ? "in" : "out"
|
|
466
696
|
});
|
|
467
|
-
var
|
|
468
|
-
const value = raw.is_auto_reply;
|
|
469
|
-
return flag(value) ?? (count(value) === null ? null : count(value) === 1);
|
|
470
|
-
};
|
|
697
|
+
var oneOrZero = (value) => flag(value) ?? (count(value) === null ? null : count(value) === 1);
|
|
471
698
|
var toReply = (identity, raw, includeBody, labels = NO_LABELS) => {
|
|
472
699
|
const mapped = category(raw.i_status, labels);
|
|
473
700
|
return {
|
|
@@ -475,7 +702,8 @@ var toReply = (identity, raw, includeBody, labels = NO_LABELS) => {
|
|
|
475
702
|
category: mapped ?? "unknown",
|
|
476
703
|
categorySource: mapped === void 0 ? null : "vendor",
|
|
477
704
|
direction: "in",
|
|
478
|
-
isAuto:
|
|
705
|
+
isAuto: oneOrZero(raw.is_auto_reply),
|
|
706
|
+
unread: oneOrZero(raw.is_unread)
|
|
479
707
|
};
|
|
480
708
|
};
|
|
481
709
|
|
|
@@ -529,6 +757,19 @@ var readLabels = async (client, ctx, statuses) => {
|
|
|
529
757
|
var accountReaders = (client) => {
|
|
530
758
|
const { identity } = client;
|
|
531
759
|
return {
|
|
760
|
+
// The per-campaign report, asked for one campaign: an array of one row.
|
|
761
|
+
getCampaignProgress: async (id, ctx) => {
|
|
762
|
+
const rows = objects(
|
|
763
|
+
await client.get(ctx, "/campaigns/analytics", { query: { id } })
|
|
764
|
+
);
|
|
765
|
+
const row = rows.find((each) => text(each.campaign_id) === id) ?? rows[0];
|
|
766
|
+
if (row === void 0) {
|
|
767
|
+
throw new OutboundError("NotFound", `Campaign ${id} was not found`, {
|
|
768
|
+
provider: identity.provider
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
return toCampaignProgress(identity, id, row);
|
|
772
|
+
},
|
|
532
773
|
getCampaignSettings: async (id, ctx) => toCampaignSettings(
|
|
533
774
|
identity,
|
|
534
775
|
await client.getObject(ctx, `/campaigns/${encodeURIComponent(id)}`)
|
|
@@ -547,46 +788,48 @@ var accountReaders = (client) => {
|
|
|
547
788
|
});
|
|
548
789
|
return toSenderHealth(identity, id, { account, vitals, warmup });
|
|
549
790
|
},
|
|
791
|
+
// The list itself carries no count of its leads; its verification
|
|
792
|
+
// statistics do, so a single list costs two requests and has a size.
|
|
793
|
+
getList: async (id, ctx) => {
|
|
794
|
+
const path = `/lead-lists/${encodeURIComponent(id)}`;
|
|
795
|
+
const list2 = await client.getObject(ctx, path);
|
|
796
|
+
const stats = await client.get(ctx, `${path}/verification-stats`);
|
|
797
|
+
return toLeadList(identity, list2, count(field(stats, "total_leads")));
|
|
798
|
+
},
|
|
799
|
+
getWebhook: async (id, ctx) => toWebhook(
|
|
800
|
+
identity,
|
|
801
|
+
await client.getObject(ctx, `/webhooks/${encodeURIComponent(id)}`)
|
|
802
|
+
),
|
|
550
803
|
listBlocklist: async (query, ctx) => {
|
|
551
804
|
const page = await listPage(client, ctx, "/block-lists-entries", query);
|
|
552
|
-
return
|
|
553
|
-
items: page.items.map((item) => toBlockEntry(identity, item)),
|
|
554
|
-
next: page.next
|
|
555
|
-
};
|
|
805
|
+
return flatMapPage(page, (item) => toBlockEntry(identity, item));
|
|
556
806
|
},
|
|
557
807
|
listLists: async (query, ctx) => {
|
|
558
808
|
const page = await listPage(client, ctx, "/lead-lists", query);
|
|
559
|
-
return
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
809
|
+
return mapPage(page, (item) => toLeadList(identity, item));
|
|
810
|
+
},
|
|
811
|
+
listPlacementTests: async (query, ctx) => {
|
|
812
|
+
const page = await listPage(client, ctx, "/inbox-placement-tests", query);
|
|
813
|
+
return mapPage(page, (item) => toPlacementTest(identity, item));
|
|
563
814
|
},
|
|
564
815
|
listSubsequences: async (query, ctx) => {
|
|
565
816
|
const page = await listPage(client, ctx, "/subsequences", query, {
|
|
566
817
|
parent_campaign: query.campaignId
|
|
567
818
|
});
|
|
568
|
-
return
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
next: page.next
|
|
573
|
-
};
|
|
819
|
+
return mapPage(
|
|
820
|
+
page,
|
|
821
|
+
(item) => toSubsequence(identity, item, query.campaignId)
|
|
822
|
+
);
|
|
574
823
|
},
|
|
575
824
|
listTags: async (query, ctx) => {
|
|
576
825
|
const page = await listPage(client, ctx, "/custom-tags", query);
|
|
577
|
-
return
|
|
578
|
-
items: page.items.map((item) => toTag(identity, item)),
|
|
579
|
-
next: page.next
|
|
580
|
-
};
|
|
826
|
+
return mapPage(page, (item) => toTag(identity, item));
|
|
581
827
|
},
|
|
582
828
|
listWebhooks: async (query, ctx) => {
|
|
583
829
|
const page = await listPage(client, ctx, "/webhooks", query, {
|
|
584
830
|
campaign: query.campaignId
|
|
585
831
|
});
|
|
586
|
-
return
|
|
587
|
-
items: page.items.map((item) => toWebhook(identity, item)),
|
|
588
|
-
next: page.next
|
|
589
|
-
};
|
|
832
|
+
return mapPage(page, (item) => toWebhook(identity, item));
|
|
590
833
|
}
|
|
591
834
|
};
|
|
592
835
|
};
|
|
@@ -629,6 +872,7 @@ var listEmails = async (client, ctx, query, received) => {
|
|
|
629
872
|
query: {
|
|
630
873
|
campaign_id: query.campaignId,
|
|
631
874
|
email_type: received ? "received" : void 0,
|
|
875
|
+
is_unread: "unread" in query ? query.unread : void 0,
|
|
632
876
|
lead,
|
|
633
877
|
limit: pageSize(query.limit),
|
|
634
878
|
max_timestamp_created: query.until,
|
|
@@ -649,12 +893,10 @@ var listEmails = async (client, ctx, query, received) => {
|
|
|
649
893
|
var mailReaders = (client) => ({
|
|
650
894
|
listMessages: async (query, ctx) => {
|
|
651
895
|
const page = await listEmails(client, ctx, query, false);
|
|
652
|
-
return
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
next: page.next
|
|
657
|
-
};
|
|
896
|
+
return mapPage(
|
|
897
|
+
page,
|
|
898
|
+
(item) => toMessage(client.identity, item, query.includeBody)
|
|
899
|
+
);
|
|
658
900
|
},
|
|
659
901
|
listReplies: async (query, ctx) => {
|
|
660
902
|
const page = await listEmails(client, ctx, query, true);
|
|
@@ -676,25 +918,11 @@ var mailReaders = (client) => ({
|
|
|
676
918
|
});
|
|
677
919
|
|
|
678
920
|
// src/instantly/map-stats.ts
|
|
679
|
-
var
|
|
680
|
-
...counts,
|
|
681
|
-
contentHash: null,
|
|
682
|
-
date: extra.date ?? null,
|
|
683
|
-
evidence: extra.evidence ?? "exact",
|
|
684
|
-
provider: scope.provider,
|
|
685
|
-
schemaVersion: SCHEMA_VERSION,
|
|
686
|
-
scope: scope.scope,
|
|
687
|
-
scopeRef: makeRef(scope.provider, scope.workspaceId, scope.scopeId),
|
|
688
|
-
stepIndex: extra.stepIndex ?? null,
|
|
689
|
-
// The analytics responses do not state the timezone of a "day".
|
|
690
|
-
timezone: null,
|
|
691
|
-
variantKey: extra.variantKey ?? null,
|
|
692
|
-
workspaceId: scope.workspaceId
|
|
693
|
-
});
|
|
694
|
-
var overviewRow = (scope, raw) => row(scope, {
|
|
921
|
+
var overviewRow = (scope, raw) => metricRow(scope, {
|
|
695
922
|
...emptyCounts(),
|
|
696
923
|
bounced: count(raw.bounced_count),
|
|
697
924
|
clicked: count(raw.link_click_count_unique),
|
|
925
|
+
clickedTotal: count(raw.link_click_count),
|
|
698
926
|
contacted: count(raw.contacted_count),
|
|
699
927
|
opened: count(raw.open_count_unique),
|
|
700
928
|
openedTotal: count(raw.open_count),
|
|
@@ -704,10 +932,23 @@ var overviewRow = (scope, raw) => row(scope, {
|
|
|
704
932
|
sent: count(raw.emails_sent_count),
|
|
705
933
|
unsubscribed: count(raw.unsubscribed_count)
|
|
706
934
|
});
|
|
935
|
+
var campaignRow = (scope, raw) => metricRow(scope, {
|
|
936
|
+
...emptyCounts(),
|
|
937
|
+
bounced: count(raw.bounced_count),
|
|
938
|
+
clicked: count(raw.link_click_count_unique),
|
|
939
|
+
clickedTotal: count(raw.link_click_count),
|
|
940
|
+
contacted: count(raw.contacted_count),
|
|
941
|
+
opened: count(raw.open_count_unique),
|
|
942
|
+
replied: count(raw.reply_count_unique),
|
|
943
|
+
repliedAuto: count(raw.reply_count_automatic_unique),
|
|
944
|
+
sent: count(raw.emails_sent_count),
|
|
945
|
+
unsubscribed: count(raw.unsubscribed_count)
|
|
946
|
+
});
|
|
707
947
|
var dailyCounts = (raw) => ({
|
|
708
948
|
...emptyCounts(),
|
|
709
949
|
bounced: count(raw.bounced),
|
|
710
950
|
clicked: count(raw.unique_clicks),
|
|
951
|
+
clickedTotal: count(raw.clicks),
|
|
711
952
|
contacted: count(raw.contacted),
|
|
712
953
|
opened: count(raw.unique_opened),
|
|
713
954
|
openedTotal: count(raw.opened),
|
|
@@ -715,12 +956,12 @@ var dailyCounts = (raw) => ({
|
|
|
715
956
|
repliedAuto: count(raw.unique_replies_automatic),
|
|
716
957
|
sent: count(raw.sent)
|
|
717
958
|
});
|
|
718
|
-
var dailyRow = (scope, raw) =>
|
|
719
|
-
var summedRow = (scope,
|
|
959
|
+
var dailyRow = (scope, raw) => metricRow(scope, dailyCounts(raw), { date: text(raw.date) });
|
|
960
|
+
var summedRow = (scope, days2) => metricRow(scope, sumCounts(days2.map(dailyCounts)), { evidence: "derived" });
|
|
720
961
|
var stepRow = (scope, raw) => {
|
|
721
962
|
const step = count(raw.step);
|
|
722
963
|
const variant = count(raw.variant);
|
|
723
|
-
return
|
|
964
|
+
return metricRow(scope, dailyCounts(raw), {
|
|
724
965
|
stepIndex: step !== null && Number.isInteger(step) ? step : null,
|
|
725
966
|
variantKey: variant === null ? null : variantKey(variant)
|
|
726
967
|
});
|
|
@@ -732,12 +973,12 @@ var range = (query) => ({
|
|
|
732
973
|
start_date: query.from
|
|
733
974
|
});
|
|
734
975
|
var senderStats = async (client, ctx, scope, query) => {
|
|
735
|
-
const
|
|
976
|
+
const days2 = objects(
|
|
736
977
|
await client.get(ctx, "/accounts/analytics/daily", {
|
|
737
978
|
query: { ...range(query), emails: scope.scopeId }
|
|
738
979
|
})
|
|
739
980
|
);
|
|
740
|
-
return query.by === "day" ?
|
|
981
|
+
return query.by === "day" ? days2.map((day) => dailyRow(scope, day)) : [summedRow(scope, days2)];
|
|
741
982
|
};
|
|
742
983
|
var readStats = async (client, ctx, query) => {
|
|
743
984
|
const { identity } = client;
|
|
@@ -749,6 +990,22 @@ var readStats = async (client, ctx, query) => {
|
|
|
749
990
|
if (query.scope === "sender") {
|
|
750
991
|
return await senderStats(client, ctx, scope, query);
|
|
751
992
|
}
|
|
993
|
+
if (query.scope === "campaign" && query.scopeId === void 0) {
|
|
994
|
+
if (query.by === "day") {
|
|
995
|
+
throw new OutboundError(
|
|
996
|
+
"Unsupported",
|
|
997
|
+
"Instantly reports every campaign in one call as totals only; read one campaign for its days",
|
|
998
|
+
{ provider: identity.provider }
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
const campaigns = await client.get(ctx, "/campaigns/analytics", {
|
|
1002
|
+
query: range(query)
|
|
1003
|
+
});
|
|
1004
|
+
return objects(campaigns).flatMap((campaign) => {
|
|
1005
|
+
const scopeId = text(campaign.campaign_id);
|
|
1006
|
+
return scopeId === null ? [] : [campaignRow({ ...scope, scopeId }, campaign)];
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
752
1009
|
if (query.scope === "step") {
|
|
753
1010
|
if (query.by === "day") {
|
|
754
1011
|
throw new OutboundError(
|
|
@@ -765,10 +1022,10 @@ var readStats = async (client, ctx, query) => {
|
|
|
765
1022
|
return objects(steps).map((step) => stepRow(scope, step));
|
|
766
1023
|
}
|
|
767
1024
|
if (query.by === "day") {
|
|
768
|
-
const
|
|
1025
|
+
const days2 = await client.get(ctx, "/campaigns/analytics/daily", {
|
|
769
1026
|
query: { ...range(query), campaign_id: query.scopeId }
|
|
770
1027
|
});
|
|
771
|
-
return objects(
|
|
1028
|
+
return objects(days2).map((day) => dailyRow(scope, day));
|
|
772
1029
|
}
|
|
773
1030
|
const overview = await client.getObject(
|
|
774
1031
|
ctx,
|
|
@@ -810,10 +1067,45 @@ var campaignTags = async (client, ctx, ids) => {
|
|
|
810
1067
|
}
|
|
811
1068
|
return tags;
|
|
812
1069
|
};
|
|
1070
|
+
var senderCampaigns = async (client, ctx, query) => {
|
|
1071
|
+
const page = await listPage(
|
|
1072
|
+
client,
|
|
1073
|
+
ctx,
|
|
1074
|
+
`/account-campaign-mappings/${encodeURIComponent(query.senderId)}`,
|
|
1075
|
+
query
|
|
1076
|
+
);
|
|
1077
|
+
const tags = await campaignTags(
|
|
1078
|
+
client,
|
|
1079
|
+
ctx,
|
|
1080
|
+
texts(page.items, "campaign_id")
|
|
1081
|
+
);
|
|
1082
|
+
const campaigns = page.items.map(
|
|
1083
|
+
(item) => toCampaign(
|
|
1084
|
+
client.identity,
|
|
1085
|
+
// The mapping names the campaign's id and name with a prefix.
|
|
1086
|
+
{
|
|
1087
|
+
...item,
|
|
1088
|
+
id: item.campaign_id ?? null,
|
|
1089
|
+
name: item.campaign_name ?? null
|
|
1090
|
+
},
|
|
1091
|
+
tags.get(text(item.campaign_id) ?? "")
|
|
1092
|
+
)
|
|
1093
|
+
);
|
|
1094
|
+
return {
|
|
1095
|
+
items: query.status === void 0 ? campaigns : campaigns.filter((campaign) => campaign.status === query.status),
|
|
1096
|
+
next: page.next
|
|
1097
|
+
};
|
|
1098
|
+
};
|
|
813
1099
|
var listCampaigns = async (client, ctx, query) => {
|
|
814
1100
|
if (query.status === "archived" || query.status === "unknown") {
|
|
815
1101
|
return { items: [] };
|
|
816
1102
|
}
|
|
1103
|
+
if (query.senderId !== void 0) {
|
|
1104
|
+
return await senderCampaigns(client, ctx, {
|
|
1105
|
+
...query,
|
|
1106
|
+
senderId: query.senderId
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
817
1109
|
const page = await listPage(client, ctx, "/campaigns", query, {
|
|
818
1110
|
status: query.status === void 0 ? void 0 : campaignStatusCode(query.status)
|
|
819
1111
|
});
|
|
@@ -934,11 +1226,10 @@ var readers = (client) => {
|
|
|
934
1226
|
campaignId: query.campaignId
|
|
935
1227
|
});
|
|
936
1228
|
}
|
|
937
|
-
const page = await listPage(client, ctx, "/accounts", query
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
};
|
|
1229
|
+
const page = await listPage(client, ctx, "/accounts", query, {
|
|
1230
|
+
include_tags: true
|
|
1231
|
+
});
|
|
1232
|
+
return mapPage(page, (item) => toSender(identity, item));
|
|
942
1233
|
},
|
|
943
1234
|
listWorkspaces: async (_query, ctx) => {
|
|
944
1235
|
const workspace = await client.get(ctx, "/workspaces/current");
|
|
@@ -951,20 +1242,6 @@ var readers = (client) => {
|
|
|
951
1242
|
};
|
|
952
1243
|
|
|
953
1244
|
// src/instantly/native-params.ts
|
|
954
|
-
var inQuery = (type, description) => ({ description, in: "query", type });
|
|
955
|
-
var inQueryRequired = (type, description) => ({
|
|
956
|
-
description,
|
|
957
|
-
in: "query",
|
|
958
|
-
required: true,
|
|
959
|
-
type
|
|
960
|
-
});
|
|
961
|
-
var inBody = (type, description) => ({ description, in: "body", type });
|
|
962
|
-
var inBodyRequired = (type, description) => ({ description, in: "body", required: true, type });
|
|
963
|
-
var inPath = (description) => ({
|
|
964
|
-
description,
|
|
965
|
-
in: "path",
|
|
966
|
-
type: "string"
|
|
967
|
-
});
|
|
968
1245
|
var PAGE = {
|
|
969
1246
|
limit: inQuery("number", "Page size, 1 to 100."),
|
|
970
1247
|
starting_after: inQuery(
|
|
@@ -2290,38 +2567,15 @@ var createClient = (options) => {
|
|
|
2290
2567
|
...options.asWorkspace === void 0 ? void 0 : { "x-as-workspace": options.asWorkspace }
|
|
2291
2568
|
}
|
|
2292
2569
|
});
|
|
2293
|
-
const
|
|
2294
|
-
const response = await ctx.request(
|
|
2295
|
-
authorize({
|
|
2296
|
-
lane: request.lane,
|
|
2297
|
-
method: "GET",
|
|
2298
|
-
url: buildUrl(baseUrl, path, request.query)
|
|
2299
|
-
})
|
|
2300
|
-
);
|
|
2301
|
-
return response.body;
|
|
2302
|
-
};
|
|
2570
|
+
const http = createVendorClient(baseUrl, authorize);
|
|
2303
2571
|
return {
|
|
2304
|
-
|
|
2305
|
-
getObject: async (ctx, path, request) =>
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
`Instantly returned no object for ${path}`,
|
|
2311
|
-
{
|
|
2312
|
-
provider: options.identity.provider
|
|
2313
|
-
}
|
|
2314
|
-
);
|
|
2315
|
-
}
|
|
2316
|
-
return body;
|
|
2317
|
-
},
|
|
2572
|
+
...http,
|
|
2573
|
+
getObject: async (ctx, path, request) => requireObject(
|
|
2574
|
+
await http.get(ctx, path, request),
|
|
2575
|
+
options.identity.provider,
|
|
2576
|
+
`Instantly returned no object for ${path}`
|
|
2577
|
+
),
|
|
2318
2578
|
identity: options.identity,
|
|
2319
|
-
post: async (ctx, path, body) => {
|
|
2320
|
-
const response = await ctx.request(
|
|
2321
|
-
authorize({ body, method: "POST", url: buildUrl(baseUrl, path) })
|
|
2322
|
-
);
|
|
2323
|
-
return response.body;
|
|
2324
|
-
},
|
|
2325
2579
|
raw: { authorize, baseUrl, isRead, isSecret },
|
|
2326
2580
|
readTags: options.readTags
|
|
2327
2581
|
};
|
|
@@ -2345,11 +2599,12 @@ var instantly = (options = {}) => {
|
|
|
2345
2599
|
readTags: declared.tags === true
|
|
2346
2600
|
});
|
|
2347
2601
|
return {
|
|
2348
|
-
...readers(client),
|
|
2602
|
+
...withLeadFields(readers(client), options.leadFields),
|
|
2349
2603
|
capabilities: declared,
|
|
2350
2604
|
caveats,
|
|
2351
2605
|
costs,
|
|
2352
2606
|
events: instantlyEvents(PROVIDER),
|
|
2607
|
+
fields: withMappedFields(fields, options.leadFields),
|
|
2353
2608
|
limits,
|
|
2354
2609
|
// Instantly answers 402 when the plan does not include the endpoint.
|
|
2355
2610
|
mapError: makeErrorMapper(PROVIDER, {
|