outbound-sdk 0.4.0 → 0.6.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 +2 -2
- package/dist/alerts/check-evaluate.d.ts +53 -0
- package/dist/alerts/check-measure.d.ts +100 -0
- package/dist/alerts/check-schema.d.ts +184 -0
- package/dist/alerts/check-validate.d.ts +18 -0
- package/dist/alerts/index.d.ts +7 -0
- package/dist/alerts/index.js +635 -2
- package/dist/budget/index.d.ts +2 -0
- package/dist/budget/index.js +1 -0
- package/dist/cards/format.d.ts +1 -1
- package/dist/cards/index.js +49 -19
- package/dist/cards/parts.d.ts +1 -6
- package/dist/chunks/{chunk-7LNJJ2RO.js → chunk-3JOC5DGD.js} +127 -17
- package/dist/chunks/chunk-53DCVFUB.js +55 -0
- package/dist/chunks/{chunk-E6DSDCPI.js → chunk-BK5SLY32.js} +92 -101
- package/dist/chunks/chunk-HPNGSG5E.js +51 -0
- package/dist/chunks/chunk-HWHI4LFY.js +102 -0
- package/dist/chunks/chunk-MGR6HREO.js +91 -0
- package/dist/chunks/{chunk-Y5RAJ6PZ.js → chunk-OLPMBRXM.js} +3 -2
- package/dist/chunks/{chunk-IZFTTMJP.js → chunk-PHNQ3WC2.js} +5 -5
- package/dist/chunks/chunk-SXGCKCAR.js +678 -0
- package/dist/chunks/chunk-TFICTGM2.js +18 -0
- package/dist/chunks/{chunk-ZFVHM5JI.js → chunk-UWUPUMM2.js} +11 -4
- package/dist/chunks/{chunk-A6WVOCA4.js → chunk-W22SDX6S.js} +4 -4
- package/dist/chunks/{chunk-7ZDS6SZD.js → chunk-WH6V3YNN.js} +25 -0
- package/dist/chunks/chunk-XL6LJVHJ.js +71 -0
- package/dist/chunks/{chunk-5FVKRIEJ.js → chunk-YYCT3NGV.js} +35 -11
- package/dist/cli/bin.js +13 -28
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +12 -11
- package/dist/cli/output.d.ts +9 -0
- package/dist/cli/update.d.ts +15 -0
- package/dist/emailbison/account.d.ts +7 -0
- package/dist/emailbison/adapter.d.ts +5 -0
- package/dist/emailbison/capabilities.d.ts +78 -0
- package/dist/emailbison/client.d.ts +29 -0
- package/dist/emailbison/index.d.ts +30 -0
- package/dist/emailbison/index.js +1018 -0
- package/dist/emailbison/mail.d.ts +5 -0
- package/dist/emailbison/map-mail.d.ts +13 -0
- package/dist/emailbison/map-sequence.d.ts +12 -0
- package/dist/emailbison/map-stats.d.ts +47 -0
- package/dist/emailbison/map.d.ts +24 -0
- package/dist/emailbison/native-params.d.ts +5 -0
- package/dist/emailbison/native-workspace.d.ts +167 -0
- package/dist/emailbison/native.d.ts +327 -0
- package/dist/emailbison/stats.d.ts +4 -0
- package/dist/emailbison/webhooks.d.ts +2 -0
- package/dist/fixtures/index.js +6 -6
- package/dist/heyreach/capabilities.d.ts +3 -0
- package/dist/heyreach/index.js +22 -20
- package/dist/index.js +19 -18
- package/dist/insights/copy/copy-preview.d.ts +58 -0
- package/dist/insights/copy/copy-reuse.d.ts +0 -13
- package/dist/insights/copy/index.d.ts +9 -0
- package/dist/insights/copy/reuse-base.d.ts +0 -2
- package/dist/insights/copy/shared.d.ts +3 -8
- package/dist/insights/copy/step-funnel.d.ts +1 -12
- package/dist/insights/copy/variant-test.d.ts +0 -5
- package/dist/insights/cost.d.ts +91 -0
- package/dist/insights/define.d.ts +22 -1
- package/dist/insights/index.d.ts +4 -3
- package/dist/insights/index.js +810 -415
- package/dist/insights/inputs.generated.d.ts +21 -24
- package/dist/insights/ops/campaign-diagnosis.d.ts +0 -2
- package/dist/insights/ops/campaign-ranking.d.ts +3 -3
- package/dist/insights/ops/client-report.d.ts +0 -2
- package/dist/insights/ops/index.d.ts +2 -6
- package/dist/insights/ops/shared.d.ts +10 -2
- package/dist/insights/plugin.d.ts +19 -0
- package/dist/insights/registry.d.ts +10 -10
- package/dist/insights/run-cap.d.ts +35 -0
- package/dist/insights/senders/bounce-watch.d.ts +0 -11
- package/dist/insights/senders/domain-health.d.ts +0 -7
- package/dist/insights/senders/index.d.ts +0 -4
- package/dist/insights/senders/sender-load.d.ts +0 -2
- package/dist/insights/tools.d.ts +10 -0
- package/dist/insights/types.d.ts +1 -1
- package/dist/insights/variables.d.ts +33 -0
- package/dist/instantly/capabilities.d.ts +13 -0
- package/dist/instantly/index.js +43 -28
- package/dist/internal/adapter.d.ts +12 -0
- package/dist/internal/outbound/outbound.d.ts +5 -1
- package/dist/internal/request-cap.d.ts +35 -0
- package/dist/loader/index.js +2 -2
- package/dist/memory/index.js +10 -10
- package/dist/providers/index.d.ts +21 -1
- package/dist/providers/index.js +1 -1
- package/dist/redact/index.js +4 -4
- package/dist/smartlead/capabilities.d.ts +5 -0
- package/dist/smartlead/index.js +26 -24
- package/dist/tools/ai-sdk.js +5 -3
- package/dist/tools/claude-agent.js +5 -3
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +11 -6
- package/dist/tools/registry.d.ts +20 -1
- package/dist/tools/shared.d.ts +20 -1
- package/dist/webhooks/index.js +17 -7
- package/package.json +8 -2
- package/dist/chunks/chunk-5CFO3CXG.js +0 -176
- package/dist/chunks/chunk-K4USHN4C.js +0 -40
- package/dist/chunks/chunk-LVQUSKEX.js +0 -17
- package/dist/internal/renamed.d.ts +0 -28
- package/dist/chunks/{chunk-C4LS2HNV.js → chunk-JWGSB7PT.js} +3 -3
|
@@ -0,0 +1,1018 @@
|
|
|
1
|
+
import {
|
|
2
|
+
API_KEY_ENV,
|
|
3
|
+
BASE_URL_ENV,
|
|
4
|
+
WORKSPACE_ENV,
|
|
5
|
+
capabilities,
|
|
6
|
+
caveats,
|
|
7
|
+
costs,
|
|
8
|
+
createClient,
|
|
9
|
+
emailbisonEvents,
|
|
10
|
+
fields,
|
|
11
|
+
limits,
|
|
12
|
+
senderStatus,
|
|
13
|
+
toBlockEntry,
|
|
14
|
+
toCampaign,
|
|
15
|
+
toInboxMessage,
|
|
16
|
+
toLead,
|
|
17
|
+
toLeadList,
|
|
18
|
+
toReply,
|
|
19
|
+
toSender,
|
|
20
|
+
toSentMessage,
|
|
21
|
+
toSettings,
|
|
22
|
+
toTag,
|
|
23
|
+
toWebhook,
|
|
24
|
+
toWorkspace
|
|
25
|
+
} from "../chunks/chunk-SXGCKCAR.js";
|
|
26
|
+
import {
|
|
27
|
+
flatMapPage,
|
|
28
|
+
mapPage,
|
|
29
|
+
withLeadFields,
|
|
30
|
+
withMappedFields
|
|
31
|
+
} from "../chunks/chunk-XL6LJVHJ.js";
|
|
32
|
+
import {
|
|
33
|
+
toVariant,
|
|
34
|
+
variantKey
|
|
35
|
+
} from "../chunks/chunk-MGR6HREO.js";
|
|
36
|
+
import "../chunks/chunk-53DCVFUB.js";
|
|
37
|
+
import {
|
|
38
|
+
defineNative,
|
|
39
|
+
inPath,
|
|
40
|
+
inQuery,
|
|
41
|
+
inQueryRequired
|
|
42
|
+
} from "../chunks/chunk-NAKXLBA6.js";
|
|
43
|
+
import {
|
|
44
|
+
recordBase,
|
|
45
|
+
refTo
|
|
46
|
+
} from "../chunks/chunk-2D42TQFU.js";
|
|
47
|
+
import "../chunks/chunk-BOWXGMN3.js";
|
|
48
|
+
import {
|
|
49
|
+
emptyCounts,
|
|
50
|
+
metricRow,
|
|
51
|
+
sumCounts
|
|
52
|
+
} from "../chunks/chunk-PQSTQKRD.js";
|
|
53
|
+
import "../chunks/chunk-QGRZDTX4.js";
|
|
54
|
+
import {
|
|
55
|
+
assertWorkspaceId
|
|
56
|
+
} from "../chunks/chunk-QAKJ76HB.js";
|
|
57
|
+
import "../chunks/chunk-NAWZ73QS.js";
|
|
58
|
+
import "../chunks/chunk-FHKSLCVW.js";
|
|
59
|
+
import {
|
|
60
|
+
readEnv,
|
|
61
|
+
requireCredential
|
|
62
|
+
} from "../chunks/chunk-GFDNRWR3.js";
|
|
63
|
+
import {
|
|
64
|
+
OutboundError,
|
|
65
|
+
makeErrorMapper
|
|
66
|
+
} from "../chunks/chunk-J7DDZ4C2.js";
|
|
67
|
+
import {
|
|
68
|
+
count,
|
|
69
|
+
field,
|
|
70
|
+
isJsonArray,
|
|
71
|
+
objects,
|
|
72
|
+
text
|
|
73
|
+
} from "../chunks/chunk-BLCJHP5H.js";
|
|
74
|
+
|
|
75
|
+
// src/emailbison/account.ts
|
|
76
|
+
var DAY_MS = 864e5;
|
|
77
|
+
var WARMUP_DAYS = 7;
|
|
78
|
+
var day = (time) => new Date(time).toISOString().slice(0, 10);
|
|
79
|
+
var segment = (id2) => encodeURIComponent(id2);
|
|
80
|
+
var toHealth = (client, sender, warmup, senderId) => {
|
|
81
|
+
const status = senderStatus(sender);
|
|
82
|
+
const domain = text(warmup.domain) ?? text(sender.email)?.split("@")[1];
|
|
83
|
+
return {
|
|
84
|
+
...recordBase(client.identity, senderId, { sender, warmup }),
|
|
85
|
+
blacklisted: null,
|
|
86
|
+
checkedAt: null,
|
|
87
|
+
connected: status === "unknown" ? null : status === "active",
|
|
88
|
+
dns: { dkim: null, dmarc: null, mx: null, spf: null },
|
|
89
|
+
domain: domain?.toLowerCase() ?? null,
|
|
90
|
+
issues: [],
|
|
91
|
+
senderRef: refTo(client.identity, senderId) ?? "",
|
|
92
|
+
warmup: {
|
|
93
|
+
// Inbox placement of warmup mail is not reported.
|
|
94
|
+
inbox: null,
|
|
95
|
+
received: count(warmup.warmup_replies_received),
|
|
96
|
+
score: count(warmup.warmup_score),
|
|
97
|
+
sent: count(warmup.warmup_emails_sent),
|
|
98
|
+
spam: count(warmup.warmup_emails_saved_from_spam)
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
var listBlocklist = async (client, ctx, at) => {
|
|
103
|
+
const { identity } = client;
|
|
104
|
+
if (field(at, "list") !== "domains") {
|
|
105
|
+
const page3 = flatMapPage(
|
|
106
|
+
await client.page(ctx, "/api/blacklisted-emails", field(at, "page"), {
|
|
107
|
+
cursor: true
|
|
108
|
+
}),
|
|
109
|
+
(row) => toBlockEntry(identity, row, "email")
|
|
110
|
+
);
|
|
111
|
+
return {
|
|
112
|
+
items: page3.items,
|
|
113
|
+
next: page3.next === void 0 ? { list: "domains" } : { list: "emails", page: page3.next }
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const page2 = flatMapPage(
|
|
117
|
+
await client.page(ctx, "/api/blacklisted-domains", field(at, "page")),
|
|
118
|
+
(row) => toBlockEntry(identity, row, "domain")
|
|
119
|
+
);
|
|
120
|
+
return {
|
|
121
|
+
items: page2.items,
|
|
122
|
+
next: page2.next === void 0 ? void 0 : { list: "domains", page: page2.next }
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
var accountReaders = (client, now = Date.now) => {
|
|
126
|
+
const { identity } = client;
|
|
127
|
+
return {
|
|
128
|
+
getCampaignSettings: async (id2, ctx) => {
|
|
129
|
+
const path = `/api/campaigns/${segment(id2)}`;
|
|
130
|
+
const campaign = client.one(await client.get(ctx, path), path);
|
|
131
|
+
const schedulePath = `${path}/schedule`;
|
|
132
|
+
let schedule = null;
|
|
133
|
+
try {
|
|
134
|
+
schedule = client.one(
|
|
135
|
+
await client.get(ctx, schedulePath),
|
|
136
|
+
schedulePath
|
|
137
|
+
);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
if (!OutboundError.is(error) || error.code !== "NotFound") {
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return toSettings(identity, campaign, schedule);
|
|
144
|
+
},
|
|
145
|
+
getList: async (id2, ctx) => {
|
|
146
|
+
const path = `/api/lead-lists/${segment(id2)}`;
|
|
147
|
+
return toLeadList(
|
|
148
|
+
identity,
|
|
149
|
+
client.one(await client.get(ctx, path), path)
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
getSenderHealth: async (id2, ctx) => {
|
|
153
|
+
const path = `/api/sender-emails/${segment(id2)}`;
|
|
154
|
+
const sender = client.one(await client.get(ctx, path), path);
|
|
155
|
+
const end = now();
|
|
156
|
+
const warmupPath = `/api/warmup/sender-emails/${segment(id2)}`;
|
|
157
|
+
const warmup = client.one(
|
|
158
|
+
await client.get(ctx, warmupPath, {
|
|
159
|
+
query: {
|
|
160
|
+
end_date: day(end),
|
|
161
|
+
start_date: day(end - WARMUP_DAYS * DAY_MS)
|
|
162
|
+
}
|
|
163
|
+
}),
|
|
164
|
+
warmupPath
|
|
165
|
+
);
|
|
166
|
+
return toHealth(client, sender, warmup, id2);
|
|
167
|
+
},
|
|
168
|
+
getWebhook: async (id2, ctx) => {
|
|
169
|
+
const path = `/api/webhook-url/${segment(id2)}`;
|
|
170
|
+
return toWebhook(identity, client.one(await client.get(ctx, path), path));
|
|
171
|
+
},
|
|
172
|
+
listBlocklist: async (query, ctx) => await listBlocklist(client, ctx, query.next),
|
|
173
|
+
listLists: async (query, ctx) => mapPage(
|
|
174
|
+
await client.page(ctx, "/api/lead-lists", query.next),
|
|
175
|
+
(row) => toLeadList(identity, row)
|
|
176
|
+
),
|
|
177
|
+
listTags: async (_query, ctx) => {
|
|
178
|
+
const path = "/api/tags";
|
|
179
|
+
return {
|
|
180
|
+
items: client.rows(await client.get(ctx, path), path).flatMap((row) => toTag(identity, row))
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
listWebhooks: async (query, ctx) => mapPage(
|
|
184
|
+
await client.page(ctx, "/api/webhook-url", query.next),
|
|
185
|
+
(row) => toWebhook(identity, row)
|
|
186
|
+
),
|
|
187
|
+
listWorkspaces: async (_query, ctx) => {
|
|
188
|
+
const path = "/api/workspaces/v1.1";
|
|
189
|
+
return {
|
|
190
|
+
items: objects(client.rows(await client.get(ctx, path), path)).map(
|
|
191
|
+
(row) => toWorkspace(identity, row)
|
|
192
|
+
)
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/emailbison/mail.ts
|
|
199
|
+
var segment2 = (id2) => encodeURIComponent(id2);
|
|
200
|
+
var byTime = (left, right) => (left.sentAt ?? "").localeCompare(right.sentAt ?? "");
|
|
201
|
+
var thread = async (client, ctx, replyId, includeBody) => {
|
|
202
|
+
const path = `/api/replies/${segment2(replyId)}/conversation-thread`;
|
|
203
|
+
const data = client.one(await client.get(ctx, path), path);
|
|
204
|
+
const rows = [
|
|
205
|
+
...objects(data.older_messages),
|
|
206
|
+
...objects([data.current_reply ?? null]),
|
|
207
|
+
...objects(data.newer_messages)
|
|
208
|
+
];
|
|
209
|
+
return {
|
|
210
|
+
items: rows.map((row) => toInboxMessage(client.identity, row, includeBody)).toSorted(byTime)
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
var timeline = async (client, ctx, leadId, query) => {
|
|
214
|
+
const { identity } = client;
|
|
215
|
+
const lead = segment2(leadId);
|
|
216
|
+
if (field(query.next, "phase") !== "inbox") {
|
|
217
|
+
const path = `/api/leads/${lead}/sent-emails`;
|
|
218
|
+
const sent = client.rows(await client.get(ctx, path), path).filter((row) => text(row.status)?.toLowerCase() === "sent").map((row) => toSentMessage(identity, row, query.includeBody));
|
|
219
|
+
return { items: sent, next: { phase: "inbox" } };
|
|
220
|
+
}
|
|
221
|
+
const page2 = await client.page(
|
|
222
|
+
ctx,
|
|
223
|
+
`/api/leads/${lead}/replies`,
|
|
224
|
+
field(query.next, "page"),
|
|
225
|
+
{
|
|
226
|
+
cursor: true,
|
|
227
|
+
query: {
|
|
228
|
+
campaign_id: query.campaignId,
|
|
229
|
+
folder: "all"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
return {
|
|
234
|
+
items: page2.items.map(
|
|
235
|
+
(row) => toInboxMessage(identity, row, query.includeBody)
|
|
236
|
+
),
|
|
237
|
+
next: page2.next === void 0 ? void 0 : { page: page2.next, phase: "inbox" }
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
var listMessages = async (client, ctx, query) => {
|
|
241
|
+
if (query.threadId !== void 0) {
|
|
242
|
+
return await thread(client, ctx, query.threadId, query.includeBody);
|
|
243
|
+
}
|
|
244
|
+
if (query.leadId !== void 0) {
|
|
245
|
+
return await timeline(client, ctx, query.leadId, query);
|
|
246
|
+
}
|
|
247
|
+
const page2 = await client.page(ctx, "/api/scheduled-emails", query.next, {
|
|
248
|
+
cursor: true,
|
|
249
|
+
query: { "campaign_ids[]": query.campaignId, status: "sent" }
|
|
250
|
+
});
|
|
251
|
+
return mapPage(
|
|
252
|
+
page2,
|
|
253
|
+
(row) => toSentMessage(client.identity, row, query.includeBody)
|
|
254
|
+
);
|
|
255
|
+
};
|
|
256
|
+
var STATUS_FILTER = /* @__PURE__ */ new Map([
|
|
257
|
+
["ooo", "automated_reply"],
|
|
258
|
+
["positive", "interested"]
|
|
259
|
+
]);
|
|
260
|
+
var readFlag = (unread) => {
|
|
261
|
+
if (unread === void 0) {
|
|
262
|
+
return void 0;
|
|
263
|
+
}
|
|
264
|
+
return unread ? 0 : 1;
|
|
265
|
+
};
|
|
266
|
+
var listReplies = async (client, ctx, query) => {
|
|
267
|
+
const filters = {
|
|
268
|
+
campaign_id: query.campaignId,
|
|
269
|
+
folder: "inbox",
|
|
270
|
+
// 1 or 0: the reference is generated from a Laravel app, whose boolean
|
|
271
|
+
// rule refuses the words true and false in a query.
|
|
272
|
+
read: readFlag(query.unread),
|
|
273
|
+
status: query.category === void 0 ? void 0 : STATUS_FILTER.get(query.category)
|
|
274
|
+
};
|
|
275
|
+
const page2 = await client.page(ctx, "/api/replies", query.next, {
|
|
276
|
+
cursor: true,
|
|
277
|
+
query: filters
|
|
278
|
+
});
|
|
279
|
+
const replies = page2.items.map(
|
|
280
|
+
(row) => toReply(client.identity, row, query.includeBody)
|
|
281
|
+
);
|
|
282
|
+
return {
|
|
283
|
+
items: query.category === void 0 ? replies : replies.filter((reply) => reply.category === query.category),
|
|
284
|
+
next: page2.next
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// src/emailbison/map-sequence.ts
|
|
289
|
+
var orderOf = (step) => count(step.order) ?? Number.MAX_SAFE_INTEGER;
|
|
290
|
+
var groupSteps = (rows) => {
|
|
291
|
+
const heads = rows.filter((row) => row.variant !== true).toSorted((left, right) => orderOf(left) - orderOf(right));
|
|
292
|
+
const groups = heads.map((head) => ({ head, variants: [head] }));
|
|
293
|
+
for (const row of rows.filter((candidate) => candidate.variant === true)) {
|
|
294
|
+
const parent = text(row.variant_from_step_id);
|
|
295
|
+
const group = groups.find(
|
|
296
|
+
(candidate) => parent === null ? orderOf(candidate.head) === orderOf(row) : text(candidate.head.id) === parent
|
|
297
|
+
) ?? void 0;
|
|
298
|
+
if (group === void 0) {
|
|
299
|
+
groups.push({ head: row, variants: [row] });
|
|
300
|
+
} else {
|
|
301
|
+
group.variants.push(row);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return groups.toSorted(
|
|
305
|
+
(left, right) => orderOf(left.head) - orderOf(right.head)
|
|
306
|
+
);
|
|
307
|
+
};
|
|
308
|
+
var stepRows = (body) => objects(field(field(body, "data"), "sequence_steps"));
|
|
309
|
+
var toSequence = (identity, campaignId, body) => {
|
|
310
|
+
const steps = groupSteps(stepRows(body)).map(
|
|
311
|
+
(group, index) => ({
|
|
312
|
+
action: "email",
|
|
313
|
+
branch: null,
|
|
314
|
+
delayDays: count(group.head.wait_in_days),
|
|
315
|
+
index,
|
|
316
|
+
parentIndex: index === 0 ? null : index - 1,
|
|
317
|
+
variants: group.variants.map(
|
|
318
|
+
(variant, position) => toVariant(
|
|
319
|
+
text(variant.email_subject),
|
|
320
|
+
text(variant.email_body),
|
|
321
|
+
variantKey(position)
|
|
322
|
+
)
|
|
323
|
+
)
|
|
324
|
+
})
|
|
325
|
+
);
|
|
326
|
+
return {
|
|
327
|
+
...recordBase(identity, campaignId, body),
|
|
328
|
+
campaignRef: refTo(identity, campaignId) ?? "",
|
|
329
|
+
kind: "main",
|
|
330
|
+
name: null,
|
|
331
|
+
steps
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
var stepPlaces = (body) => new Map(
|
|
335
|
+
groupSteps(stepRows(body)).flatMap(
|
|
336
|
+
(group, stepIndex) => group.variants.flatMap((variant, position) => {
|
|
337
|
+
const id2 = text(variant.id);
|
|
338
|
+
return id2 === null ? [] : [[id2, { stepIndex, variantKey: variantKey(position) }]];
|
|
339
|
+
})
|
|
340
|
+
)
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
// src/emailbison/map-stats.ts
|
|
344
|
+
var summaryCounts = (summary) => ({
|
|
345
|
+
...emptyCounts(),
|
|
346
|
+
bounced: count(field(summary, "bounced")),
|
|
347
|
+
contacted: count(field(summary, "total_leads_contacted")),
|
|
348
|
+
opened: count(field(summary, "unique_opens_per_contact")),
|
|
349
|
+
openedTotal: count(field(summary, "opened")),
|
|
350
|
+
positive: count(field(summary, "interested")),
|
|
351
|
+
replied: count(field(summary, "unique_replies_per_contact")),
|
|
352
|
+
sent: count(field(summary, "emails_sent")),
|
|
353
|
+
unsubscribed: count(field(summary, "unsubscribed"))
|
|
354
|
+
});
|
|
355
|
+
var senderCounts = (sender) => ({
|
|
356
|
+
...emptyCounts(),
|
|
357
|
+
bounced: count(sender.bounced_count),
|
|
358
|
+
contacted: count(sender.total_leads_contacted_count),
|
|
359
|
+
opened: count(sender.unique_opened_count),
|
|
360
|
+
openedTotal: count(sender.total_opened_count),
|
|
361
|
+
positive: count(sender.interested_leads_count),
|
|
362
|
+
replied: count(sender.unique_replied_count),
|
|
363
|
+
sent: count(sender.emails_sent_count),
|
|
364
|
+
unsubscribed: count(sender.unsubscribed_count)
|
|
365
|
+
});
|
|
366
|
+
var SERIES = /* @__PURE__ */ new Map([
|
|
367
|
+
["bounced", "bounced"],
|
|
368
|
+
["interested", "positive"],
|
|
369
|
+
["replied", "replied"],
|
|
370
|
+
["sent", "sent"],
|
|
371
|
+
["total opens", "openedTotal"],
|
|
372
|
+
["unique opens", "opened"],
|
|
373
|
+
["unsubscribed", "unsubscribed"]
|
|
374
|
+
]);
|
|
375
|
+
var dailyRows = (scope, body) => {
|
|
376
|
+
const days = /* @__PURE__ */ new Map();
|
|
377
|
+
for (const series of objects(field(body, "data"))) {
|
|
378
|
+
const key = SERIES.get((text(series.label) ?? "").toLowerCase());
|
|
379
|
+
if (key === void 0) {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
for (const point of Array.isArray(series.dates) ? series.dates : []) {
|
|
383
|
+
const day3 = isJsonArray(point) ? text(point[0]) : null;
|
|
384
|
+
if (day3 === null || !/^\d{4}-\d{2}-\d{2}$/u.test(day3)) {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const counts = days.get(day3) ?? emptyCounts();
|
|
388
|
+
counts[key] = count(isJsonArray(point) ? point[1] : void 0);
|
|
389
|
+
days.set(day3, counts);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return [...days.entries()].toSorted(([left], [right]) => left.localeCompare(right)).map(([date, counts]) => metricRow(scope, counts, { date }));
|
|
393
|
+
};
|
|
394
|
+
var summedRow = (scope, rows) => metricRow(scope, sumCounts(rows), { evidence: "derived" });
|
|
395
|
+
var stepRows2 = (scope, summary, places) => objects(field(summary, "sequence_step_stats")).flatMap((step) => {
|
|
396
|
+
const place = places.get(text(step.sequence_step_id) ?? "");
|
|
397
|
+
if (place === void 0) {
|
|
398
|
+
return [];
|
|
399
|
+
}
|
|
400
|
+
return [
|
|
401
|
+
metricRow(
|
|
402
|
+
scope,
|
|
403
|
+
{
|
|
404
|
+
...emptyCounts(),
|
|
405
|
+
bounced: count(step.bounced),
|
|
406
|
+
contacted: count(step.leads_contacted),
|
|
407
|
+
opened: count(step.unique_opens),
|
|
408
|
+
positive: count(step.interested),
|
|
409
|
+
replied: count(step.unique_replies),
|
|
410
|
+
sent: count(step.sent),
|
|
411
|
+
unsubscribed: count(step.unsubscribed)
|
|
412
|
+
},
|
|
413
|
+
{ stepIndex: place.stepIndex, variantKey: place.variantKey }
|
|
414
|
+
)
|
|
415
|
+
];
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
// src/emailbison/stats.ts
|
|
419
|
+
var DAY_MS2 = 864e5;
|
|
420
|
+
var EARLIEST = "2000-01-01";
|
|
421
|
+
var day2 = (time) => new Date(time).toISOString().slice(0, 10);
|
|
422
|
+
var rangeOf = (query, daily, now) => {
|
|
423
|
+
const end = query.to ?? day2(now);
|
|
424
|
+
const start = query.from ?? (daily ? day2(Date.parse(`${end}T00:00:00Z`) - 30 * DAY_MS2) : EARLIEST);
|
|
425
|
+
return { end_date: end, start_date: start };
|
|
426
|
+
};
|
|
427
|
+
var id = (scope) => encodeURIComponent(scope.scopeId);
|
|
428
|
+
var campaignSummary = async (client, ctx, scope, range2) => {
|
|
429
|
+
const path = `/api/campaigns/${id(scope)}/stats`;
|
|
430
|
+
return client.one(await client.post(ctx, path, { ...range2 }), path);
|
|
431
|
+
};
|
|
432
|
+
var senderDays = async (client, ctx, scope, range2) => dailyRows(
|
|
433
|
+
scope,
|
|
434
|
+
await client.get(ctx, "/api/campaign-events/stats", {
|
|
435
|
+
query: { ...range2, "sender_email_ids[]": scope.scopeId }
|
|
436
|
+
})
|
|
437
|
+
);
|
|
438
|
+
var dailyPath = (scope) => scope.scope === "campaign" ? `/api/campaigns/${id(scope)}/line-area-chart-stats` : "/api/workspaces/v1.1/line-area-chart-stats";
|
|
439
|
+
var readDaily = async (client, ctx, scope, range2) => scope.scope === "sender" ? await senderDays(client, ctx, scope, range2) : dailyRows(
|
|
440
|
+
scope,
|
|
441
|
+
await client.get(ctx, dailyPath(scope), { query: { ...range2 } })
|
|
442
|
+
);
|
|
443
|
+
var readSender = async (client, ctx, scope, query, now) => {
|
|
444
|
+
if (query.from === void 0 && query.to === void 0) {
|
|
445
|
+
const path = `/api/sender-emails/${id(scope)}`;
|
|
446
|
+
return [
|
|
447
|
+
metricRow(
|
|
448
|
+
scope,
|
|
449
|
+
senderCounts(client.one(await client.get(ctx, path), path))
|
|
450
|
+
)
|
|
451
|
+
];
|
|
452
|
+
}
|
|
453
|
+
return [
|
|
454
|
+
summedRow(
|
|
455
|
+
scope,
|
|
456
|
+
await senderDays(client, ctx, scope, rangeOf(query, false, now))
|
|
457
|
+
)
|
|
458
|
+
];
|
|
459
|
+
};
|
|
460
|
+
var readSteps = async (client, ctx, scope, range2) => {
|
|
461
|
+
const summary = await campaignSummary(client, ctx, scope, range2);
|
|
462
|
+
const steps = await client.get(
|
|
463
|
+
ctx,
|
|
464
|
+
`/api/campaigns/v1.1/${id(scope)}/sequence-steps`
|
|
465
|
+
);
|
|
466
|
+
return stepRows2(scope, summary, stepPlaces(steps));
|
|
467
|
+
};
|
|
468
|
+
var readStats = async (client, ctx, query, now = Date.now()) => {
|
|
469
|
+
const { provider } = client.identity;
|
|
470
|
+
if (query.scope === "campaign" && query.scopeId === void 0) {
|
|
471
|
+
throw new OutboundError(
|
|
472
|
+
"Unsupported",
|
|
473
|
+
"EmailBison has no read with a row per campaign",
|
|
474
|
+
{ provider }
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
const scope = {
|
|
478
|
+
...client.identity,
|
|
479
|
+
scope: query.scope,
|
|
480
|
+
scopeId: query.scopeId ?? client.identity.workspaceId
|
|
481
|
+
};
|
|
482
|
+
if (query.by === "day") {
|
|
483
|
+
if (query.scope === "step") {
|
|
484
|
+
throw new OutboundError(
|
|
485
|
+
"Unsupported",
|
|
486
|
+
"EmailBison reports a step's counts as totals only",
|
|
487
|
+
{ provider }
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
return await readDaily(client, ctx, scope, rangeOf(query, true, now));
|
|
491
|
+
}
|
|
492
|
+
const range2 = rangeOf(query, false, now);
|
|
493
|
+
if (query.scope === "sender") {
|
|
494
|
+
return await readSender(client, ctx, scope, query, now);
|
|
495
|
+
}
|
|
496
|
+
if (query.scope === "step") {
|
|
497
|
+
return await readSteps(client, ctx, scope, range2);
|
|
498
|
+
}
|
|
499
|
+
if (query.scope === "campaign") {
|
|
500
|
+
return [
|
|
501
|
+
metricRow(
|
|
502
|
+
scope,
|
|
503
|
+
summaryCounts(await campaignSummary(client, ctx, scope, range2))
|
|
504
|
+
)
|
|
505
|
+
];
|
|
506
|
+
}
|
|
507
|
+
const path = "/api/workspaces/v1.1/stats";
|
|
508
|
+
return [
|
|
509
|
+
metricRow(
|
|
510
|
+
scope,
|
|
511
|
+
summaryCounts(
|
|
512
|
+
client.one(await client.get(ctx, path, { query: { ...range2 } }), path)
|
|
513
|
+
)
|
|
514
|
+
)
|
|
515
|
+
];
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
// src/emailbison/adapter.ts
|
|
519
|
+
var segment3 = (id2) => encodeURIComponent(id2);
|
|
520
|
+
var lookup = async (client, ctx, email) => {
|
|
521
|
+
const path = `/api/leads/${segment3(email)}`;
|
|
522
|
+
try {
|
|
523
|
+
const lead = toLead(
|
|
524
|
+
client.identity,
|
|
525
|
+
client.one(await client.get(ctx, path), path)
|
|
526
|
+
);
|
|
527
|
+
return { items: lead.email === email ? [lead] : [] };
|
|
528
|
+
} catch (error) {
|
|
529
|
+
if (OutboundError.is(error) && error.code === "NotFound") {
|
|
530
|
+
return { items: [] };
|
|
531
|
+
}
|
|
532
|
+
throw error;
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
var listLeads = async (client, ctx, query) => {
|
|
536
|
+
if (query.email !== void 0) {
|
|
537
|
+
return await lookup(client, ctx, query.email);
|
|
538
|
+
}
|
|
539
|
+
if (query.linkedinUrl !== void 0) {
|
|
540
|
+
return { items: [] };
|
|
541
|
+
}
|
|
542
|
+
const { campaignId } = query;
|
|
543
|
+
if (campaignId !== void 0) {
|
|
544
|
+
const page2 = await client.page(
|
|
545
|
+
ctx,
|
|
546
|
+
`/api/campaigns/${segment3(campaignId)}/leads`,
|
|
547
|
+
query.next,
|
|
548
|
+
{ cursor: true }
|
|
549
|
+
);
|
|
550
|
+
return mapPage(page2, (row) => toLead(client.identity, row, campaignId));
|
|
551
|
+
}
|
|
552
|
+
return mapPage(
|
|
553
|
+
await client.page(ctx, "/api/leads", query.next, { cursor: true }),
|
|
554
|
+
(row) => toLead(client.identity, row)
|
|
555
|
+
);
|
|
556
|
+
};
|
|
557
|
+
var readers = (client) => {
|
|
558
|
+
const { identity } = client;
|
|
559
|
+
return {
|
|
560
|
+
...accountReaders(client),
|
|
561
|
+
getCampaign: async (id2, ctx) => {
|
|
562
|
+
const path = `/api/campaigns/${segment3(id2)}`;
|
|
563
|
+
return toCampaign(
|
|
564
|
+
identity,
|
|
565
|
+
client.one(await client.get(ctx, path), path)
|
|
566
|
+
);
|
|
567
|
+
},
|
|
568
|
+
getLead: async (id2, ctx) => {
|
|
569
|
+
const path = `/api/leads/${segment3(id2)}`;
|
|
570
|
+
return toLead(identity, client.one(await client.get(ctx, path), path));
|
|
571
|
+
},
|
|
572
|
+
getSender: async (id2, ctx) => {
|
|
573
|
+
const path = `/api/sender-emails/${segment3(id2)}`;
|
|
574
|
+
return toSender(identity, client.one(await client.get(ctx, path), path));
|
|
575
|
+
},
|
|
576
|
+
getSequence: async (id2, ctx) => toSequence(
|
|
577
|
+
identity,
|
|
578
|
+
id2,
|
|
579
|
+
await client.get(
|
|
580
|
+
ctx,
|
|
581
|
+
`/api/campaigns/v1.1/${segment3(id2)}/sequence-steps`
|
|
582
|
+
)
|
|
583
|
+
),
|
|
584
|
+
listCampaigns: async (query, ctx) => {
|
|
585
|
+
if (query.senderId !== void 0) {
|
|
586
|
+
const page2 = await client.page(
|
|
587
|
+
ctx,
|
|
588
|
+
`/api/sender-emails/${segment3(query.senderId)}/campaigns`,
|
|
589
|
+
query.next
|
|
590
|
+
);
|
|
591
|
+
return mapPage(page2, (row) => toCampaign(identity, row));
|
|
592
|
+
}
|
|
593
|
+
return mapPage(
|
|
594
|
+
await client.page(ctx, "/api/campaigns", query.next, { cursor: true }),
|
|
595
|
+
(row) => toCampaign(identity, row)
|
|
596
|
+
);
|
|
597
|
+
},
|
|
598
|
+
listLeads: (query, ctx) => listLeads(client, ctx, query),
|
|
599
|
+
listMessages: (query, ctx) => listMessages(client, ctx, query),
|
|
600
|
+
listReplies: (query, ctx) => listReplies(client, ctx, query),
|
|
601
|
+
listSenders: async (query, ctx) => {
|
|
602
|
+
const path = query.campaignId === void 0 ? "/api/sender-emails" : `/api/campaigns/${segment3(query.campaignId)}/sender-emails`;
|
|
603
|
+
return mapPage(
|
|
604
|
+
await client.page(ctx, path, query.next, { cursor: true }),
|
|
605
|
+
(row) => toSender(identity, row)
|
|
606
|
+
);
|
|
607
|
+
},
|
|
608
|
+
stats: (query, ctx) => readStats(client, ctx, query)
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
// src/emailbison/native-params.ts
|
|
613
|
+
var REFERENCE = "https://dedi.emailbison.com/api/reference";
|
|
614
|
+
var docs = (tag, method, path) => `${REFERENCE}#tag/${tag}/${method}${path}`;
|
|
615
|
+
var page = {
|
|
616
|
+
page: inQuery("number", "The page to read, from 1. 15 records per page.")
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
// src/emailbison/native-workspace.ts
|
|
620
|
+
var WORKSPACE_NATIVE = defineNative({
|
|
621
|
+
account: {
|
|
622
|
+
description: "The user the key belongs to and the workspace it is scoped to.",
|
|
623
|
+
docs: docs("account-management", "get", "/api/users"),
|
|
624
|
+
method: "GET",
|
|
625
|
+
path: "/api/users"
|
|
626
|
+
},
|
|
627
|
+
blacklistedDomain: {
|
|
628
|
+
description: "One blocked domain, by its id.",
|
|
629
|
+
docs: docs(
|
|
630
|
+
"domain-blacklist",
|
|
631
|
+
"get",
|
|
632
|
+
"/api/blacklisted-domains/{blacklisted_domain_id}"
|
|
633
|
+
),
|
|
634
|
+
method: "GET",
|
|
635
|
+
params: { blacklisted_domain_id: inPath("The entry's id.") },
|
|
636
|
+
path: "/api/blacklisted-domains/{blacklisted_domain_id}"
|
|
637
|
+
},
|
|
638
|
+
blacklistedEmail: {
|
|
639
|
+
description: "One blocked address, by its id.",
|
|
640
|
+
docs: docs(
|
|
641
|
+
"email-blacklist",
|
|
642
|
+
"get",
|
|
643
|
+
"/api/blacklisted-emails/{blacklisted_email_id}"
|
|
644
|
+
),
|
|
645
|
+
method: "GET",
|
|
646
|
+
params: { blacklisted_email_id: inPath("The entry's id.") },
|
|
647
|
+
path: "/api/blacklisted-emails/{blacklisted_email_id}"
|
|
648
|
+
},
|
|
649
|
+
customVariables: {
|
|
650
|
+
description: "The custom lead variables the workspace has defined.",
|
|
651
|
+
docs: docs("custom-lead-variables", "get", "/api/custom-variables"),
|
|
652
|
+
method: "GET",
|
|
653
|
+
path: "/api/custom-variables"
|
|
654
|
+
},
|
|
655
|
+
event: {
|
|
656
|
+
description: "One workspace event with its payload and webhook deliveries. Deliveries name the webhook URL, which can hold a secret.",
|
|
657
|
+
docs: docs("events", "get", "/api/events/{id}"),
|
|
658
|
+
method: "GET",
|
|
659
|
+
params: { id: inPath("The event's id.") },
|
|
660
|
+
path: "/api/events/{id}",
|
|
661
|
+
sensitive: true
|
|
662
|
+
},
|
|
663
|
+
events: {
|
|
664
|
+
description: "The workspace's events of the last 10 days, each with its webhook payload and deliveries. Pages by cursor only.",
|
|
665
|
+
docs: docs("events", "get", "/api/events"),
|
|
666
|
+
method: "GET",
|
|
667
|
+
params: {
|
|
668
|
+
cursor: inQuery("string", "meta.next_cursor of the previous page."),
|
|
669
|
+
end_date: inQuery("string", "Only events before this day."),
|
|
670
|
+
start_date: inQuery("string", "Only events after this day."),
|
|
671
|
+
type: inQuery(
|
|
672
|
+
"string",
|
|
673
|
+
"Only events of this type, such as lead_replied."
|
|
674
|
+
)
|
|
675
|
+
},
|
|
676
|
+
path: "/api/events",
|
|
677
|
+
sensitive: true
|
|
678
|
+
},
|
|
679
|
+
ignorePhrase: {
|
|
680
|
+
description: "One phrase that keeps matching emails out of the inbox.",
|
|
681
|
+
docs: docs(
|
|
682
|
+
"ignore-phrases",
|
|
683
|
+
"get",
|
|
684
|
+
"/api/ignore-phrases/{ignore_phrase_id}"
|
|
685
|
+
),
|
|
686
|
+
method: "GET",
|
|
687
|
+
params: { ignore_phrase_id: inPath("The phrase's id.") },
|
|
688
|
+
path: "/api/ignore-phrases/{ignore_phrase_id}"
|
|
689
|
+
},
|
|
690
|
+
ignorePhrases: {
|
|
691
|
+
description: "The phrases that keep matching emails, such as other tools' warmup mail, out of the inbox.",
|
|
692
|
+
docs: docs("ignore-phrases", "get", "/api/ignore-phrases"),
|
|
693
|
+
method: "GET",
|
|
694
|
+
path: "/api/ignore-phrases"
|
|
695
|
+
},
|
|
696
|
+
masterInboxSettings: {
|
|
697
|
+
description: "Whether the inbox syncs every email, filters warmup mail and marks interested replies automatically.",
|
|
698
|
+
docs: docs(
|
|
699
|
+
"workspaces-v11",
|
|
700
|
+
"get",
|
|
701
|
+
"/api/workspaces/v1.1/master-inbox-settings"
|
|
702
|
+
),
|
|
703
|
+
method: "GET",
|
|
704
|
+
path: "/api/workspaces/v1.1/master-inbox-settings"
|
|
705
|
+
},
|
|
706
|
+
oauthSession: {
|
|
707
|
+
description: "The state of a Google or Microsoft sign-in session for connecting a sender. Holds the sign-in link.",
|
|
708
|
+
docs: docs("oauth-sessions-beta", "get", "/api/oauth-sessions/{id}"),
|
|
709
|
+
method: "GET",
|
|
710
|
+
params: { id: inPath("The session's id.") },
|
|
711
|
+
path: "/api/oauth-sessions/{id}",
|
|
712
|
+
sensitive: true
|
|
713
|
+
},
|
|
714
|
+
replyTemplate: {
|
|
715
|
+
description: "One saved reply template.",
|
|
716
|
+
docs: docs("reply-templates", "get", "/api/reply-templates/{id}"),
|
|
717
|
+
method: "GET",
|
|
718
|
+
params: { id: inPath("The template's id.") },
|
|
719
|
+
path: "/api/reply-templates/{id}"
|
|
720
|
+
},
|
|
721
|
+
replyTemplates: {
|
|
722
|
+
description: "The workspace's saved reply templates.",
|
|
723
|
+
docs: docs("reply-templates", "get", "/api/reply-templates"),
|
|
724
|
+
method: "GET",
|
|
725
|
+
params: { ...page, search: inQuery("string", "Text to search for.") },
|
|
726
|
+
path: "/api/reply-templates"
|
|
727
|
+
},
|
|
728
|
+
tag: {
|
|
729
|
+
description: "One tag, by its id.",
|
|
730
|
+
docs: docs("custom-tags", "get", "/api/tags/{id}"),
|
|
731
|
+
method: "GET",
|
|
732
|
+
params: { id: inPath("The tag's id.") },
|
|
733
|
+
path: "/api/tags/{id}"
|
|
734
|
+
},
|
|
735
|
+
trackingDomain: {
|
|
736
|
+
description: "One custom tracking domain and its state.",
|
|
737
|
+
docs: docs(
|
|
738
|
+
"custom-tracking-domains",
|
|
739
|
+
"get",
|
|
740
|
+
"/api/custom-tracking-domain/{id}"
|
|
741
|
+
),
|
|
742
|
+
method: "GET",
|
|
743
|
+
params: { id: inPath("The domain's id.") },
|
|
744
|
+
path: "/api/custom-tracking-domain/{id}"
|
|
745
|
+
},
|
|
746
|
+
trackingDomains: {
|
|
747
|
+
description: "The custom tracking domains for opens and clicks, and their state.",
|
|
748
|
+
docs: docs("custom-tracking-domains", "get", "/api/custom-tracking-domain"),
|
|
749
|
+
method: "GET",
|
|
750
|
+
params: page,
|
|
751
|
+
path: "/api/custom-tracking-domain"
|
|
752
|
+
},
|
|
753
|
+
webhookAttempt: {
|
|
754
|
+
description: "One attempt to deliver a webhook: the URL, the response code and the event. The URL can hold a secret.",
|
|
755
|
+
docs: docs("webhook-attempts", "get", "/api/webhook-attempts/{id}"),
|
|
756
|
+
method: "GET",
|
|
757
|
+
params: { id: inPath("The attempt's id.") },
|
|
758
|
+
path: "/api/webhook-attempts/{id}",
|
|
759
|
+
sensitive: true
|
|
760
|
+
},
|
|
761
|
+
webhookDelivery: {
|
|
762
|
+
description: "One webhook delivery and its attempts. The URL can hold a secret.",
|
|
763
|
+
docs: docs("webhook-deliveries", "get", "/api/webhook-deliveries/{id}"),
|
|
764
|
+
method: "GET",
|
|
765
|
+
params: { id: inPath("The delivery's id.") },
|
|
766
|
+
path: "/api/webhook-deliveries/{id}",
|
|
767
|
+
sensitive: true
|
|
768
|
+
},
|
|
769
|
+
webhookEventTypes: {
|
|
770
|
+
description: "The webhook event types, with the id each is subscribed by.",
|
|
771
|
+
docs: docs("webhook-events", "get", "/api/webhook-events/event-types"),
|
|
772
|
+
method: "GET",
|
|
773
|
+
path: "/api/webhook-events/event-types"
|
|
774
|
+
},
|
|
775
|
+
webhookSamplePayload: {
|
|
776
|
+
description: "A sample webhook payload for one event type.",
|
|
777
|
+
docs: docs("webhook-events", "get", "/api/webhook-events/sample-payload"),
|
|
778
|
+
method: "GET",
|
|
779
|
+
params: {
|
|
780
|
+
event_type: inQueryRequired(
|
|
781
|
+
"string",
|
|
782
|
+
"The event type, such as email_sent."
|
|
783
|
+
)
|
|
784
|
+
},
|
|
785
|
+
path: "/api/webhook-events/sample-payload"
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
// src/emailbison/native.ts
|
|
790
|
+
var cursor = {
|
|
791
|
+
cursor: inQuery("string", "meta.next_cursor of the previous page."),
|
|
792
|
+
pagination_type: inQuery(
|
|
793
|
+
"string",
|
|
794
|
+
"cursor to page by cursor, length_aware (the default) to page by number."
|
|
795
|
+
),
|
|
796
|
+
...page
|
|
797
|
+
};
|
|
798
|
+
var range = {
|
|
799
|
+
end_date: inQueryRequired("string", "The last day, as YYYY-MM-DD."),
|
|
800
|
+
start_date: inQueryRequired("string", "The first day, as YYYY-MM-DD.")
|
|
801
|
+
};
|
|
802
|
+
var replyFilters = {
|
|
803
|
+
...cursor,
|
|
804
|
+
folder: inQuery("string", "inbox, sent, spam, bounced or all."),
|
|
805
|
+
lead_id: inQuery("number", "Only this lead's messages."),
|
|
806
|
+
read: inQuery("boolean", "true for read messages, false for unread ones."),
|
|
807
|
+
search: inQuery("string", "Text to search for."),
|
|
808
|
+
status: inQuery(
|
|
809
|
+
"string",
|
|
810
|
+
"interested, automated_reply or not_automated_reply."
|
|
811
|
+
),
|
|
812
|
+
"tag_ids[]": inQuery("list", "Only messages from leads with these tag ids.")
|
|
813
|
+
};
|
|
814
|
+
var scheduleDay = {
|
|
815
|
+
day: inQuery("string", "The day to show: today, tomorrow, or a date.")
|
|
816
|
+
};
|
|
817
|
+
var CAMPAIGN_NATIVE = defineNative({
|
|
818
|
+
campaignReplies: {
|
|
819
|
+
description: "A campaign's master inbox messages, filtered by folder, status, read state, sender, lead or lead tag.",
|
|
820
|
+
docs: docs("campaigns", "get", "/api/campaigns/{campaign_id}/replies"),
|
|
821
|
+
method: "GET",
|
|
822
|
+
params: {
|
|
823
|
+
campaign_id: inPath("The campaign's id."),
|
|
824
|
+
...replyFilters,
|
|
825
|
+
sender_email_id: inQuery("number", "Only this sender's messages.")
|
|
826
|
+
},
|
|
827
|
+
path: "/api/campaigns/{campaign_id}/replies"
|
|
828
|
+
},
|
|
829
|
+
campaignScheduledEmails: {
|
|
830
|
+
description: "A campaign's emails in every state (scheduled, sent, failed, paused, stopped, bounced, unsubscribed), each with its lead and sender.",
|
|
831
|
+
docs: docs(
|
|
832
|
+
"campaigns",
|
|
833
|
+
"get",
|
|
834
|
+
"/api/campaigns/{campaign_id}/scheduled-emails"
|
|
835
|
+
),
|
|
836
|
+
method: "GET",
|
|
837
|
+
params: {
|
|
838
|
+
campaign_id: inPath("The campaign's id."),
|
|
839
|
+
...cursor,
|
|
840
|
+
scheduled_date: inQuery("string", "Only emails scheduled for this date."),
|
|
841
|
+
scheduled_date_local: inQuery(
|
|
842
|
+
"string",
|
|
843
|
+
"Only emails scheduled for this date, in the campaign's timezone."
|
|
844
|
+
),
|
|
845
|
+
status: inQuery("string", "Only emails in this state.")
|
|
846
|
+
},
|
|
847
|
+
path: "/api/campaigns/{campaign_id}/scheduled-emails"
|
|
848
|
+
},
|
|
849
|
+
campaignSendingSchedule: {
|
|
850
|
+
description: "How many emails one campaign is set to send on a day, by sender.",
|
|
851
|
+
docs: docs(
|
|
852
|
+
"campaigns",
|
|
853
|
+
"get",
|
|
854
|
+
"/api/campaigns/{campaign_id}/sending-schedule"
|
|
855
|
+
),
|
|
856
|
+
method: "GET",
|
|
857
|
+
params: { campaign_id: inPath("The campaign's id."), ...scheduleDay },
|
|
858
|
+
path: "/api/campaigns/{campaign_id}/sending-schedule"
|
|
859
|
+
},
|
|
860
|
+
scheduleTemplates: {
|
|
861
|
+
description: "The saved schedule templates a campaign's sending window can be made from.",
|
|
862
|
+
docs: docs("campaigns", "get", "/api/campaigns/schedule/templates"),
|
|
863
|
+
method: "GET",
|
|
864
|
+
path: "/api/campaigns/schedule/templates"
|
|
865
|
+
},
|
|
866
|
+
scheduleTimezones: {
|
|
867
|
+
description: "The timezones a campaign schedule accepts, with their ids.",
|
|
868
|
+
docs: docs(
|
|
869
|
+
"campaigns",
|
|
870
|
+
"get",
|
|
871
|
+
"/api/campaigns/schedule/available-timezones"
|
|
872
|
+
),
|
|
873
|
+
method: "GET",
|
|
874
|
+
path: "/api/campaigns/schedule/available-timezones"
|
|
875
|
+
},
|
|
876
|
+
sendingSchedules: {
|
|
877
|
+
description: "How many emails each campaign is set to send on a day, by sender.",
|
|
878
|
+
docs: docs("campaigns", "get", "/api/campaigns/sending-schedules"),
|
|
879
|
+
method: "GET",
|
|
880
|
+
params: scheduleDay,
|
|
881
|
+
path: "/api/campaigns/sending-schedules"
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
var MAIL_NATIVE = defineNative({
|
|
885
|
+
campaignEventStats: {
|
|
886
|
+
description: "Daily counts of sends, opens, replies, bounces, unsubscribes and interested leads, for chosen campaigns and senders.",
|
|
887
|
+
docs: docs("campaign-events", "get", "/api/campaign-events/stats"),
|
|
888
|
+
method: "GET",
|
|
889
|
+
params: {
|
|
890
|
+
...range,
|
|
891
|
+
"campaign_ids[]": inQuery("list", "Only these campaigns."),
|
|
892
|
+
"sender_email_ids[]": inQuery("list", "Only these senders.")
|
|
893
|
+
},
|
|
894
|
+
path: "/api/campaign-events/stats"
|
|
895
|
+
},
|
|
896
|
+
leadScheduledEmails: {
|
|
897
|
+
description: "A lead's campaign emails in every state: scheduled, paused, stopped, bounced, unsubscribed or replied.",
|
|
898
|
+
docs: docs("leads", "get", "/api/leads/{lead_id}/scheduled-emails"),
|
|
899
|
+
method: "GET",
|
|
900
|
+
params: { lead_id: inPath("The lead's id or email.") },
|
|
901
|
+
path: "/api/leads/{lead_id}/scheduled-emails"
|
|
902
|
+
},
|
|
903
|
+
reply: {
|
|
904
|
+
description: "One master inbox message with its lead, bodies, recipients and attachments.",
|
|
905
|
+
docs: docs("replies", "get", "/api/replies/{id}"),
|
|
906
|
+
method: "GET",
|
|
907
|
+
params: { id: inPath("The reply's id.") },
|
|
908
|
+
path: "/api/replies/{id}"
|
|
909
|
+
},
|
|
910
|
+
scheduledEmail: {
|
|
911
|
+
description: "One campaign email: its state, times, counts, and the campaign, lead and sender it belongs to.",
|
|
912
|
+
docs: docs("scheduled-emails", "get", "/api/scheduled-emails/{id}"),
|
|
913
|
+
method: "GET",
|
|
914
|
+
params: { id: inPath("The scheduled email's id.") },
|
|
915
|
+
path: "/api/scheduled-emails/{id}"
|
|
916
|
+
},
|
|
917
|
+
scheduledEmails: {
|
|
918
|
+
description: "Campaign emails across the workspace in any state, filtered by campaign, lead, sender and scheduled day.",
|
|
919
|
+
docs: docs("scheduled-emails", "get", "/api/scheduled-emails"),
|
|
920
|
+
method: "GET",
|
|
921
|
+
params: {
|
|
922
|
+
...cursor,
|
|
923
|
+
"campaign_ids[]": inQuery("list", "Only these campaigns."),
|
|
924
|
+
"lead_ids[]": inQuery("list", "Only these leads."),
|
|
925
|
+
"scheduled_date_local[criteria]": inQuery(
|
|
926
|
+
"string",
|
|
927
|
+
"How to compare the day: <, <=, =, >= or >."
|
|
928
|
+
),
|
|
929
|
+
"scheduled_date_local[value]": inQuery(
|
|
930
|
+
"string",
|
|
931
|
+
"The day, as YYYY-MM-DD in the campaign's timezone."
|
|
932
|
+
),
|
|
933
|
+
"sender_email_ids[]": inQuery("list", "Only these senders."),
|
|
934
|
+
status: inQuery(
|
|
935
|
+
"string",
|
|
936
|
+
"sent, scheduled, failed, paused, stopped, bounced or unsubscribed."
|
|
937
|
+
)
|
|
938
|
+
},
|
|
939
|
+
path: "/api/scheduled-emails"
|
|
940
|
+
},
|
|
941
|
+
senderReplies: {
|
|
942
|
+
description: "One sender's master inbox messages, with the same filters as the inbox.",
|
|
943
|
+
docs: docs(
|
|
944
|
+
"email-accounts",
|
|
945
|
+
"get",
|
|
946
|
+
"/api/sender-emails/{senderEmailId}/replies"
|
|
947
|
+
),
|
|
948
|
+
method: "GET",
|
|
949
|
+
params: {
|
|
950
|
+
senderEmailId: inPath("The sender's id."),
|
|
951
|
+
...replyFilters,
|
|
952
|
+
campaign_id: inQuery("number", "Only this campaign's messages.")
|
|
953
|
+
},
|
|
954
|
+
path: "/api/sender-emails/{senderEmailId}/replies"
|
|
955
|
+
},
|
|
956
|
+
warmupSenders: {
|
|
957
|
+
description: "Every sender with its warmup counts and score between two days, filtered by tag, warmup state and MX records.",
|
|
958
|
+
docs: docs("warmup", "get", "/api/warmup/sender-emails"),
|
|
959
|
+
method: "GET",
|
|
960
|
+
params: {
|
|
961
|
+
...cursor,
|
|
962
|
+
...range,
|
|
963
|
+
"excluded_tag_ids[]": inQuery(
|
|
964
|
+
"list",
|
|
965
|
+
"Leave out senders with these tags."
|
|
966
|
+
),
|
|
967
|
+
mx_records_status: inQuery("string", "records missing or records valid."),
|
|
968
|
+
search: inQuery("string", "Text to search for."),
|
|
969
|
+
"tag_ids[]": inQuery("list", "Only senders with these tag ids."),
|
|
970
|
+
warmup_status: inQuery("string", "enabled or disabled."),
|
|
971
|
+
without_tags: inQuery("boolean", "Only senders with no tags.")
|
|
972
|
+
},
|
|
973
|
+
path: "/api/warmup/sender-emails"
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
var NATIVE = defineNative({
|
|
977
|
+
...CAMPAIGN_NATIVE,
|
|
978
|
+
...MAIL_NATIVE,
|
|
979
|
+
...WORKSPACE_NATIVE
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
// src/emailbison/index.ts
|
|
983
|
+
var PROVIDER = "emailbison";
|
|
984
|
+
var envVars = [API_KEY_ENV, BASE_URL_ENV, WORKSPACE_ENV];
|
|
985
|
+
var emailbison = (options = {}) => {
|
|
986
|
+
const apiKey = requireCredential(options.apiKey, API_KEY_ENV, PROVIDER);
|
|
987
|
+
const workspaceId = assertWorkspaceId(
|
|
988
|
+
options.workspaceId ?? readEnv(WORKSPACE_ENV) ?? "default",
|
|
989
|
+
PROVIDER
|
|
990
|
+
);
|
|
991
|
+
const client = createClient({
|
|
992
|
+
apiKey,
|
|
993
|
+
baseUrl: options.baseUrl ?? readEnv(BASE_URL_ENV),
|
|
994
|
+
identity: { provider: PROVIDER, workspaceId }
|
|
995
|
+
});
|
|
996
|
+
return {
|
|
997
|
+
...withLeadFields(readers(client), options.leadFields),
|
|
998
|
+
capabilities: { ...capabilities, ...options.capabilities },
|
|
999
|
+
caveats,
|
|
1000
|
+
costs,
|
|
1001
|
+
events: emailbisonEvents(PROVIDER),
|
|
1002
|
+
fields: withMappedFields(fields, options.leadFields),
|
|
1003
|
+
limits,
|
|
1004
|
+
mapError: makeErrorMapper(PROVIDER, { secrets: [apiKey] }),
|
|
1005
|
+
maturity: "unverified",
|
|
1006
|
+
name: PROVIDER,
|
|
1007
|
+
native: NATIVE,
|
|
1008
|
+
raw: client.raw,
|
|
1009
|
+
secrets: [apiKey],
|
|
1010
|
+
workspaceId
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
export {
|
|
1014
|
+
NATIVE,
|
|
1015
|
+
PROVIDER,
|
|
1016
|
+
emailbison,
|
|
1017
|
+
envVars
|
|
1018
|
+
};
|