outbound-sdk 0.9.0 → 0.10.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/dist/chunks/{chunk-REDFBY74.js → chunk-KMQHXFIZ.js} +156 -121
- package/dist/chunks/{chunk-4BH5LRCS.js → chunk-KQCIF5IT.js} +1 -1
- package/dist/chunks/{chunk-QTWJ5FO7.js → chunk-NAYVG7SI.js} +1 -1
- package/dist/chunks/{tools-ATY622UC.js → tools-AVJ3XJ5A.js} +1 -1
- package/dist/cli/bin.js +2 -2
- package/dist/cli/index.js +1 -1
- package/dist/insights/index.js +1 -1
- package/dist/insights/people/dropped-replies-check.d.ts +62 -0
- package/dist/insights/people/dropped-replies.d.ts +2 -24
- package/dist/insights/people/index.d.ts +2 -1
- package/dist/redact/index.js +17 -4
- package/package.json +1 -1
|
@@ -4441,9 +4441,135 @@ var accountSummary = defineInsight({
|
|
|
4441
4441
|
|
|
4442
4442
|
// src/insights/people/dropped-replies.ts
|
|
4443
4443
|
import { z as z19 } from "zod";
|
|
4444
|
+
|
|
4445
|
+
// src/insights/people/dropped-replies-check.ts
|
|
4444
4446
|
var HOUR = 36e5;
|
|
4445
|
-
var DAY = 24 * HOUR;
|
|
4446
4447
|
var waited = (hours) => hours >= 48 ? plural(Math.floor(hours / 24), "day") : plural(Math.floor(hours), "hour");
|
|
4448
|
+
var unanswered = (replies2, messages) => {
|
|
4449
|
+
const lastSent = Math.max(
|
|
4450
|
+
Number.NEGATIVE_INFINITY,
|
|
4451
|
+
...messages.flatMap(
|
|
4452
|
+
(message) => message.direction === "out" && message.sentAt !== null ? [Date.parse(message.sentAt)] : []
|
|
4453
|
+
)
|
|
4454
|
+
);
|
|
4455
|
+
return replies2.filter(
|
|
4456
|
+
(reply) => reply.sentAt !== null && Date.parse(reply.sentAt) > lastSent
|
|
4457
|
+
).toSorted(
|
|
4458
|
+
(left, right) => (left.sentAt ?? "").localeCompare(right.sentAt ?? "")
|
|
4459
|
+
);
|
|
4460
|
+
};
|
|
4461
|
+
var toDropped = (open, by, now) => {
|
|
4462
|
+
const [first] = open;
|
|
4463
|
+
if (first === void 0 || first.sentAt === null) {
|
|
4464
|
+
return [];
|
|
4465
|
+
}
|
|
4466
|
+
const hoursWaiting = round((now - Date.parse(first.sentAt)) / HOUR) ?? 0;
|
|
4467
|
+
return [
|
|
4468
|
+
{
|
|
4469
|
+
campaign: first.campaignRef,
|
|
4470
|
+
campaignName: null,
|
|
4471
|
+
category: first.category,
|
|
4472
|
+
channel: first.channel,
|
|
4473
|
+
checkedBy: by,
|
|
4474
|
+
finding: `${/^[aeiou]/u.test(first.category) ? "An" : "A"} ${first.category} reply has waited ${waited(hoursWaiting)} with nothing sent after it.`,
|
|
4475
|
+
hoursWaiting,
|
|
4476
|
+
email: null,
|
|
4477
|
+
lead: first.leadRef,
|
|
4478
|
+
linkedinUrl: null,
|
|
4479
|
+
name: null,
|
|
4480
|
+
provider: first.provider,
|
|
4481
|
+
receivedAt: first.sentAt,
|
|
4482
|
+
reply: first.ref,
|
|
4483
|
+
subject: first.subject,
|
|
4484
|
+
unansweredReplies: open.length
|
|
4485
|
+
}
|
|
4486
|
+
];
|
|
4487
|
+
};
|
|
4488
|
+
var sentByHand = async (context, since, max) => {
|
|
4489
|
+
const { capabilities, messages } = context.outbound;
|
|
4490
|
+
if (!capabilities["messages.byHand"] || capabilities["messages.since"] !== "server") {
|
|
4491
|
+
return null;
|
|
4492
|
+
}
|
|
4493
|
+
const walk = messages.listAll({ byHand: true, max, since });
|
|
4494
|
+
const found = await walk.toArray();
|
|
4495
|
+
if (walk.meta !== void 0) {
|
|
4496
|
+
context.one({ meta: walk.meta });
|
|
4497
|
+
}
|
|
4498
|
+
if (walk.truncated) {
|
|
4499
|
+
context.note(
|
|
4500
|
+
`The messages sent by hand stopped at ${max}, so each conversation they did not settle was read in full.`
|
|
4501
|
+
);
|
|
4502
|
+
}
|
|
4503
|
+
return { messages: found, whole: !walk.truncated };
|
|
4504
|
+
};
|
|
4505
|
+
var answersIn = (conversation, sent) => sent.filter(
|
|
4506
|
+
(message) => conversation.by === "thread" ? message.threadId === conversation.id : message.leadRef === conversation.id
|
|
4507
|
+
);
|
|
4508
|
+
var check = async (context, checkable, sent, olderThanHours) => {
|
|
4509
|
+
const checked = {
|
|
4510
|
+
answered: 0,
|
|
4511
|
+
dropped: [],
|
|
4512
|
+
tooRecent: 0,
|
|
4513
|
+
unread: 0
|
|
4514
|
+
};
|
|
4515
|
+
const openIn = (conversation, messages) => toDropped(
|
|
4516
|
+
unanswered(conversation.replies, messages),
|
|
4517
|
+
conversation.by,
|
|
4518
|
+
context.now
|
|
4519
|
+
);
|
|
4520
|
+
const settle = (found, whole) => {
|
|
4521
|
+
if (found.length === 0) {
|
|
4522
|
+
checked.answered += 1;
|
|
4523
|
+
} else if (found.every((each) => each.hoursWaiting < olderThanHours)) {
|
|
4524
|
+
checked.tooRecent += 1;
|
|
4525
|
+
} else if (whole) {
|
|
4526
|
+
checked.dropped.push(...found);
|
|
4527
|
+
} else {
|
|
4528
|
+
return false;
|
|
4529
|
+
}
|
|
4530
|
+
return true;
|
|
4531
|
+
};
|
|
4532
|
+
const toRead = sent === null ? checkable : checkable.filter((conversation) => {
|
|
4533
|
+
const found = openIn(
|
|
4534
|
+
conversation,
|
|
4535
|
+
answersIn(conversation, sent.messages)
|
|
4536
|
+
);
|
|
4537
|
+
return !((found.length === 0 || sent.whole) && settle(found, false));
|
|
4538
|
+
});
|
|
4539
|
+
const threads = await mapConcurrent(toRead, async (conversation) => {
|
|
4540
|
+
try {
|
|
4541
|
+
const read = await (conversation.by === "thread" ? context.outbound.thread(conversation.id).messages() : context.outbound.lead(conversation.id).timeline());
|
|
4542
|
+
return { conversation, failed: null, messages: context.page(read) };
|
|
4543
|
+
} catch (error) {
|
|
4544
|
+
if (isCapStop(error)) {
|
|
4545
|
+
throw error;
|
|
4546
|
+
}
|
|
4547
|
+
return {
|
|
4548
|
+
conversation,
|
|
4549
|
+
failed: OutboundError.is(error) ? error.code : "an unexpected error",
|
|
4550
|
+
messages: []
|
|
4551
|
+
};
|
|
4552
|
+
}
|
|
4553
|
+
});
|
|
4554
|
+
const reasons = /* @__PURE__ */ new Set();
|
|
4555
|
+
for (const { conversation, failed, messages } of threads) {
|
|
4556
|
+
if (failed === null) {
|
|
4557
|
+
settle(openIn(conversation, messages), true);
|
|
4558
|
+
} else {
|
|
4559
|
+
checked.unread += 1;
|
|
4560
|
+
reasons.add(failed);
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
if (checked.unread > 0) {
|
|
4564
|
+
context.note(
|
|
4565
|
+
`${plural(checked.unread, "conversation")} could not be read, so ${noun(checked.unread, "it is", "they are")} counted in totals.unchecked, not as dropped (${[...reasons].join("; ")}).`
|
|
4566
|
+
);
|
|
4567
|
+
}
|
|
4568
|
+
return checked;
|
|
4569
|
+
};
|
|
4570
|
+
|
|
4571
|
+
// src/insights/people/dropped-replies.ts
|
|
4572
|
+
var DAY = 24 * HOUR;
|
|
4447
4573
|
var DEFAULT_DAYS = 14;
|
|
4448
4574
|
var WINDOW_REPLIES = 2e3;
|
|
4449
4575
|
var input16 = z19.object({
|
|
@@ -4492,46 +4618,6 @@ var conversationsOf = (replies2, readers) => {
|
|
|
4492
4618
|
}
|
|
4493
4619
|
return [...groups.values()];
|
|
4494
4620
|
};
|
|
4495
|
-
var unanswered = (replies2, messages) => {
|
|
4496
|
-
const lastSent = Math.max(
|
|
4497
|
-
Number.NEGATIVE_INFINITY,
|
|
4498
|
-
...messages.flatMap(
|
|
4499
|
-
(message) => message.direction === "out" && message.sentAt !== null ? [Date.parse(message.sentAt)] : []
|
|
4500
|
-
)
|
|
4501
|
-
);
|
|
4502
|
-
return replies2.filter(
|
|
4503
|
-
(reply) => reply.sentAt !== null && Date.parse(reply.sentAt) > lastSent
|
|
4504
|
-
).toSorted(
|
|
4505
|
-
(left, right) => (left.sentAt ?? "").localeCompare(right.sentAt ?? "")
|
|
4506
|
-
);
|
|
4507
|
-
};
|
|
4508
|
-
var toDropped = (open, by, now) => {
|
|
4509
|
-
const [first] = open;
|
|
4510
|
-
if (first === void 0 || first.sentAt === null) {
|
|
4511
|
-
return [];
|
|
4512
|
-
}
|
|
4513
|
-
const hoursWaiting = round((now - Date.parse(first.sentAt)) / HOUR) ?? 0;
|
|
4514
|
-
return [
|
|
4515
|
-
{
|
|
4516
|
-
campaign: first.campaignRef,
|
|
4517
|
-
campaignName: null,
|
|
4518
|
-
category: first.category,
|
|
4519
|
-
channel: first.channel,
|
|
4520
|
-
checkedBy: by,
|
|
4521
|
-
finding: `${/^[aeiou]/u.test(first.category) ? "An" : "A"} ${first.category} reply has waited ${waited(hoursWaiting)} with nothing sent after it.`,
|
|
4522
|
-
hoursWaiting,
|
|
4523
|
-
email: null,
|
|
4524
|
-
lead: first.leadRef,
|
|
4525
|
-
linkedinUrl: null,
|
|
4526
|
-
name: null,
|
|
4527
|
-
provider: first.provider,
|
|
4528
|
-
receivedAt: first.sentAt,
|
|
4529
|
-
reply: first.ref,
|
|
4530
|
-
subject: first.subject,
|
|
4531
|
-
unansweredReplies: open.length
|
|
4532
|
-
}
|
|
4533
|
-
];
|
|
4534
|
-
};
|
|
4535
4621
|
var refsOf = (refs) => [
|
|
4536
4622
|
...new Set(refs.flatMap((ref) => ref === null ? [] : [ref]))
|
|
4537
4623
|
];
|
|
@@ -4596,65 +4682,8 @@ var readReplies = (context, since, given) => {
|
|
|
4596
4682
|
given === null ? "the most one window reads; pass a later since" : "max_replies"
|
|
4597
4683
|
);
|
|
4598
4684
|
};
|
|
4599
|
-
var sentByHand = async (context, since, max) => {
|
|
4600
|
-
const { capabilities, messages } = context.outbound;
|
|
4601
|
-
if (!capabilities["messages.byHand"] || capabilities["messages.since"] !== "server") {
|
|
4602
|
-
return null;
|
|
4603
|
-
}
|
|
4604
|
-
const walk = messages.listAll({ byHand: true, max, since });
|
|
4605
|
-
const found = await walk.toArray();
|
|
4606
|
-
if (walk.meta !== void 0) {
|
|
4607
|
-
context.one({ meta: walk.meta });
|
|
4608
|
-
}
|
|
4609
|
-
if (walk.truncated) {
|
|
4610
|
-
context.note(
|
|
4611
|
-
`The messages sent by hand stopped at ${max}, so each conversation they did not settle was read in full.`
|
|
4612
|
-
);
|
|
4613
|
-
}
|
|
4614
|
-
return { messages: found, whole: !walk.truncated };
|
|
4615
|
-
};
|
|
4616
|
-
var answersIn = (conversation, sent) => sent.filter(
|
|
4617
|
-
(message) => conversation.by === "thread" ? message.threadId === conversation.id : message.leadRef === conversation.id
|
|
4618
|
-
);
|
|
4619
|
-
var check = async (context, checkable, sent, olderThanHours) => {
|
|
4620
|
-
const checked = { answered: 0, dropped: [], tooRecent: 0 };
|
|
4621
|
-
const openIn = (conversation, messages) => toDropped(
|
|
4622
|
-
unanswered(conversation.replies, messages),
|
|
4623
|
-
conversation.by,
|
|
4624
|
-
context.now
|
|
4625
|
-
);
|
|
4626
|
-
const settle = (found, whole) => {
|
|
4627
|
-
if (found.length === 0) {
|
|
4628
|
-
checked.answered += 1;
|
|
4629
|
-
} else if (found.every((each) => each.hoursWaiting < olderThanHours)) {
|
|
4630
|
-
checked.tooRecent += 1;
|
|
4631
|
-
} else if (whole) {
|
|
4632
|
-
checked.dropped.push(...found);
|
|
4633
|
-
} else {
|
|
4634
|
-
return false;
|
|
4635
|
-
}
|
|
4636
|
-
return true;
|
|
4637
|
-
};
|
|
4638
|
-
const toRead = sent === null ? checkable : checkable.filter((conversation) => {
|
|
4639
|
-
const found = openIn(
|
|
4640
|
-
conversation,
|
|
4641
|
-
answersIn(conversation, sent.messages)
|
|
4642
|
-
);
|
|
4643
|
-
return !((found.length === 0 || sent.whole) && settle(found, false));
|
|
4644
|
-
});
|
|
4645
|
-
const threads = await mapConcurrent(toRead, async (conversation) => ({
|
|
4646
|
-
conversation,
|
|
4647
|
-
messages: context.page(
|
|
4648
|
-
await (conversation.by === "thread" ? context.outbound.thread(conversation.id).messages() : context.outbound.lead(conversation.id).timeline())
|
|
4649
|
-
)
|
|
4650
|
-
}));
|
|
4651
|
-
for (const { conversation, messages } of threads) {
|
|
4652
|
-
settle(openIn(conversation, messages), true);
|
|
4653
|
-
}
|
|
4654
|
-
return checked;
|
|
4655
|
-
};
|
|
4656
4685
|
var droppedReplies = defineInsight({
|
|
4657
|
-
description: "Replies from prospects that nobody answered. Reads every reply since a date (14 days before now by default, up to 2,000 or max_replies), keeps the categories that need an answer, and reports a conversation as dropped when nothing was sent after the reply and it has waited longer than older_than_hours. Where the tool lists the messages sent by hand (messages.byHand), one listing of those in the window settles every answered conversation; a conversation is read in full, by its thread or the lead's timeline, only when it may be dropped, or when that listing stopped at its max and did not answer it. Replies in conversations that belong to no campaign, such as a LinkedIn account's own messages on HeyReach, are set aside and counted in totals.notInCampaign unless include_inbox is true. Returns the dropped replies longest waiting first with hours waiting, category, the campaign and its name, and the lead with their name, email and LinkedIn profile. A reply that could not be checked is counted in totals.unchecked, never reported as dropped. Costs one request per page of replies and of messages sent by hand, one per conversation read in full, and one per lead and per campaign among the dropped replies to name them. totals.moreRepliesExist is true when the read stopped with replies left unread.",
|
|
4686
|
+
description: "Replies from prospects that nobody answered. Reads every reply since a date (14 days before now by default, up to 2,000 or max_replies), keeps the categories that need an answer, and reports a conversation as dropped when nothing was sent after the reply and it has waited longer than older_than_hours. Where the tool lists the messages sent by hand (messages.byHand), one listing of those in the window settles every answered conversation; a conversation is read in full, by its thread or the lead's timeline, only when it may be dropped, or when that listing stopped at its max and did not answer it. Replies in conversations that belong to no campaign, such as a LinkedIn account's own messages on HeyReach, are set aside and counted in totals.notInCampaign unless include_inbox is true. Returns the dropped replies longest waiting first with hours waiting, category, the campaign and its name, and the lead with their name, email and LinkedIn profile. A reply that could not be checked, including one whose conversation could not be read, is counted in totals.unchecked with a note, never reported as dropped. Costs one request per page of replies and of messages sent by hand, one per conversation read in full, and one per lead and per campaign among the dropped replies to name them. totals.moreRepliesExist is true when the read stopped with replies left unread.",
|
|
4658
4687
|
inputSchema: input16,
|
|
4659
4688
|
key: "droppedReplies",
|
|
4660
4689
|
cost: (values, price) => {
|
|
@@ -4701,7 +4730,7 @@ var droppedReplies = defineInsight({
|
|
|
4701
4730
|
since,
|
|
4702
4731
|
values.max_replies ?? WINDOW_REPLIES
|
|
4703
4732
|
);
|
|
4704
|
-
const { answered, dropped, tooRecent } = await check(
|
|
4733
|
+
const { answered, dropped, tooRecent, unread } = await check(
|
|
4705
4734
|
context,
|
|
4706
4735
|
checkable,
|
|
4707
4736
|
sent,
|
|
@@ -4724,7 +4753,7 @@ var droppedReplies = defineInsight({
|
|
|
4724
4753
|
skippedAuto: wanted.length - kept.length,
|
|
4725
4754
|
skippedByCategory: replies2.length - wanted.length,
|
|
4726
4755
|
tooRecent,
|
|
4727
|
-
unchecked
|
|
4756
|
+
unchecked: unchecked + unread
|
|
4728
4757
|
}
|
|
4729
4758
|
};
|
|
4730
4759
|
return answer;
|
|
@@ -5396,10 +5425,14 @@ var input18 = z21.object({
|
|
|
5396
5425
|
max_leads_per_campaign: z21.number().int().min(1).max(2e4).default(500).describe("The most leads to read from each campaign"),
|
|
5397
5426
|
statuses: statusesField
|
|
5398
5427
|
});
|
|
5399
|
-
var
|
|
5428
|
+
var keysFor = (masking) => masking?.strategy === "mask" && masking.fields.includes("linkedin") ? (lead) => [
|
|
5429
|
+
...lead.email === null ? [] : [`email:${lead.email}`],
|
|
5430
|
+
...lead.linkedinUrl === null ? [] : [`linkedin:${lead.linkedinUrl}`]
|
|
5431
|
+
] : keysOfLead;
|
|
5432
|
+
var groupPeople = (entries, keysOf) => {
|
|
5400
5433
|
const byKey = /* @__PURE__ */ new Map();
|
|
5401
5434
|
for (const entry of entries) {
|
|
5402
|
-
const keys =
|
|
5435
|
+
const keys = keysOf(entry.lead);
|
|
5403
5436
|
const found = new Set(keys.flatMap((key) => byKey.get(key) ?? []));
|
|
5404
5437
|
const group = { entries: [entry], keys: new Set(keys) };
|
|
5405
5438
|
for (const other of found) {
|
|
@@ -5470,17 +5503,15 @@ var leadCollisions = defineInsight({
|
|
|
5470
5503
|
description: "People who are in two or more campaigns at once, so they get overlapping outreach. Reads the campaigns in the given statuses (active by default) and their leads, matches people by exact email address or LinkedIn profile, and returns each person with their campaigns, channel and tool, most active campaigns first. By default a person counts only when their own status is active in two or more of the campaigns; include_past also reports people who finished, replied to or left one campaign and are in another, counted in totals.pastOverlaps either way. A collision across tools (for example email in one and LinkedIn in another) is marked across_tools; one inside a tool is within_tool. Costs one request per page of campaigns plus one per page of each campaign's leads; the caps make the answer incomplete rather than slow.",
|
|
5471
5504
|
inputSchema: input18,
|
|
5472
5505
|
key: "leadCollisions",
|
|
5473
|
-
// Under mask an address is a token keyed for the plugin. Whether people
|
|
5474
|
-
// tools match by it is OUT-107's decision, so it stays refused until then.
|
|
5475
|
-
// A hashed one tells people apart.
|
|
5476
|
-
maskedOut: ({ fields, strategy }) => fields.includes("email") && strategy === "mask" ? "email addresses, which it matches people by" : null,
|
|
5477
5506
|
cost: (values, price) => price.campaignsIn(new Set(values.statuses).size, values.max_campaigns) + price.campaigns(values.max_campaigns) * price.list("leads.list", values.max_leads_per_campaign),
|
|
5478
5507
|
scales: "max_campaigns",
|
|
5479
5508
|
name: "lead_collisions",
|
|
5480
5509
|
needs: ["leads.byCampaign"],
|
|
5481
5510
|
next: "Use person_summary with one of the identifiers or lead refs to see what that person was sent and whether they replied.",
|
|
5482
5511
|
run: async (context, values) => {
|
|
5483
|
-
|
|
5512
|
+
const masking = maskingOf(context.outbound);
|
|
5513
|
+
const keysOf = keysFor(masking);
|
|
5514
|
+
if (masking?.strategy === "hash" && masking.fields.includes("linkedin")) {
|
|
5484
5515
|
context.partial(
|
|
5485
5516
|
"The redact plugin masks LinkedIn profiles, so people were matched by email address only."
|
|
5486
5517
|
);
|
|
@@ -5500,7 +5531,7 @@ var leadCollisions = defineInsight({
|
|
|
5500
5531
|
return leads.map((lead) => ({ campaign, lead }));
|
|
5501
5532
|
});
|
|
5502
5533
|
const entries = perCampaign.flat();
|
|
5503
|
-
const overlaps = groupPeople(entries).flatMap(toCollision);
|
|
5534
|
+
const overlaps = groupPeople(entries, keysOf).flatMap(toCollision);
|
|
5504
5535
|
const pastOverlaps = overlaps.filter((each) => each.stillActive < 2).length;
|
|
5505
5536
|
const collisions = overlaps.filter((each) => values.include_past || each.stillActive >= 2).toSorted(worstFirst);
|
|
5506
5537
|
const acrossTools = collisions.filter(
|
|
@@ -5515,7 +5546,7 @@ var leadCollisions = defineInsight({
|
|
|
5515
5546
|
concurrent: collisions.filter((each) => each.stillActive >= 2).length,
|
|
5516
5547
|
leadsRead: entries.length,
|
|
5517
5548
|
leadsWithoutIdentifier: entries.filter(
|
|
5518
|
-
(entry) =>
|
|
5549
|
+
(entry) => keysOf(entry.lead).length === 0
|
|
5519
5550
|
).length,
|
|
5520
5551
|
pastOverlaps,
|
|
5521
5552
|
withinTool: collisions.length - acrossTools
|
|
@@ -5863,7 +5894,11 @@ var input21 = z24.object({
|
|
|
5863
5894
|
statuses: statusesField
|
|
5864
5895
|
});
|
|
5865
5896
|
var slugOfEntry = (value) => profileSlug(value) ?? value.trim().replaceAll(/^\/+|\/+$/gu, "").toLowerCase();
|
|
5866
|
-
var
|
|
5897
|
+
var profileTokens = (outbound) => {
|
|
5898
|
+
const masking = maskingOf(outbound);
|
|
5899
|
+
return masking?.strategy === "mask" && masking.fields.includes("linkedin");
|
|
5900
|
+
};
|
|
5901
|
+
var indexEntries = (entries, tokens) => {
|
|
5867
5902
|
const blocked = {
|
|
5868
5903
|
domain: /* @__PURE__ */ new Map(),
|
|
5869
5904
|
email: /* @__PURE__ */ new Map(),
|
|
@@ -5881,13 +5916,16 @@ var indexEntries = (entries) => {
|
|
|
5881
5916
|
entry
|
|
5882
5917
|
);
|
|
5883
5918
|
} else if (entry.kind === "linkedin") {
|
|
5884
|
-
blocked.linkedin.set(
|
|
5919
|
+
blocked.linkedin.set(
|
|
5920
|
+
tokens ? entry.value : slugOfEntry(entry.value),
|
|
5921
|
+
entry
|
|
5922
|
+
);
|
|
5885
5923
|
}
|
|
5886
5924
|
}
|
|
5887
5925
|
return blocked;
|
|
5888
5926
|
};
|
|
5889
|
-
var matchLead = (lead, blocked) => {
|
|
5890
|
-
const slug = profileSlug(lead.linkedinUrl);
|
|
5927
|
+
var matchLead = (lead, blocked, tokens) => {
|
|
5928
|
+
const slug = tokens ? lead.linkedinUrl : profileSlug(lead.linkedinUrl);
|
|
5891
5929
|
const candidates = [
|
|
5892
5930
|
["email", blocked.email.get(lead.email ?? "")],
|
|
5893
5931
|
["linkedin", blocked.linkedin.get(slug ?? "")],
|
|
@@ -5914,7 +5952,7 @@ var toViolation = (lead, campaign, { entry, matchedBy }) => ({
|
|
|
5914
5952
|
var maskNote = (outbound) => {
|
|
5915
5953
|
const fields = maskingOf(outbound)?.fields ?? [];
|
|
5916
5954
|
const email = fields.includes("email");
|
|
5917
|
-
const linkedin = fields.includes("linkedin");
|
|
5955
|
+
const linkedin = fields.includes("linkedin") && !profileTokens(outbound);
|
|
5918
5956
|
const masked = [
|
|
5919
5957
|
...email ? ["email addresses"] : [],
|
|
5920
5958
|
...linkedin ? ["LinkedIn profiles"] : []
|
|
@@ -5930,10 +5968,6 @@ var suppressionCheck = defineInsight({
|
|
|
5930
5968
|
description: "Leads sitting in campaigns although they are on the block list. Reads the block list, then the leads of each campaign in the given statuses (active by default), and matches a lead by exact email address, by email domain against domain entries, and by LinkedIn profile against profile entries. A match is a violation only when the lead's own status is in lead_statuses (active, paused or unknown by default, the leads still being sent to); a lead that already unsubscribed, bounced, replied or completed is counted in totals.alreadyStopped instead. Returns each violation with the lead, the campaign, the entry and how it matched, counts per campaign, and how many block entries were read; totals.moreBlockEntriesExist is true when max_block_entries left entries unread, which were not checked. On several tools an entry on one tool's list is also matched against the other tools' leads and marked sameTool false. Costs one request per page of block entries plus one per page of each campaign's leads.",
|
|
5931
5969
|
inputSchema: input21,
|
|
5932
5970
|
key: "suppressionCheck",
|
|
5933
|
-
// Under mask an address is a token keyed for the plugin. Whether people
|
|
5934
|
-
// tools match by it is OUT-107's decision, so it stays refused until then.
|
|
5935
|
-
// A hashed one still matches the same address on the list.
|
|
5936
|
-
maskedOut: ({ fields, strategy }) => fields.includes("email") && strategy === "mask" ? "email addresses, which it matches leads to the block list by" : null,
|
|
5937
5971
|
cost: (values, price) => price.list("blocklist.list", values.max_block_entries) + price.campaignsIn(new Set(values.statuses).size, values.max_campaigns) + price.campaigns(values.max_campaigns) * price.list("leads.list", values.max_leads_per_campaign),
|
|
5938
5972
|
scales: "max_campaigns",
|
|
5939
5973
|
name: "suppression_check",
|
|
@@ -5948,7 +5982,8 @@ var suppressionCheck = defineInsight({
|
|
|
5948
5982
|
"max_block_entries"
|
|
5949
5983
|
);
|
|
5950
5984
|
const entries = listed2.items;
|
|
5951
|
-
const
|
|
5985
|
+
const tokens = profileTokens(context.outbound);
|
|
5986
|
+
const blocked = indexEntries(entries, tokens);
|
|
5952
5987
|
const unmatched = maskNote(context.outbound);
|
|
5953
5988
|
if (unmatched !== null) {
|
|
5954
5989
|
context.partial(unmatched);
|
|
@@ -5974,7 +6009,7 @@ var suppressionCheck = defineInsight({
|
|
|
5974
6009
|
}));
|
|
5975
6010
|
for (const { campaign, items: leads } of read) {
|
|
5976
6011
|
const matched = leads.flatMap((lead) => {
|
|
5977
|
-
const hit = matchLead(lead, blocked);
|
|
6012
|
+
const hit = matchLead(lead, blocked, tokens);
|
|
5978
6013
|
return hit === null ? [] : [toViolation(lead, campaign, hit)];
|
|
5979
6014
|
});
|
|
5980
6015
|
const found = matched.filter((each) => sendable.has(each.leadStatus));
|
|
@@ -756,7 +756,7 @@ var COMMAND_TABLE = {
|
|
|
756
756
|
const offered = await offeredTools(outbound, input.flags);
|
|
757
757
|
const tool = offered.find((candidate) => candidate.name === name);
|
|
758
758
|
if (tool === void 0) {
|
|
759
|
-
const { insightLeftOutReason } = await import("./tools-
|
|
759
|
+
const { insightLeftOutReason } = await import("./tools-AVJ3XJ5A.js");
|
|
760
760
|
const why = leftOutReason(outbound, name) ?? insightLeftOutReason(outbound, name);
|
|
761
761
|
if (why !== void 0) {
|
|
762
762
|
throw new OutboundError("Unsupported", why, {
|
package/dist/cli/bin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "../chunks/chunk-
|
|
3
|
-
import "../chunks/chunk-
|
|
2
|
+
import "../chunks/chunk-NAYVG7SI.js";
|
|
3
|
+
import "../chunks/chunk-KQCIF5IT.js";
|
|
4
4
|
import "../chunks/chunk-OMCDMELK.js";
|
|
5
5
|
import "../chunks/chunk-OVTYA3IB.js";
|
|
6
6
|
import "../chunks/chunk-FTK4JS65.js";
|
package/dist/cli/index.js
CHANGED
package/dist/insights/index.js
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Message, Reply } from "../../internal/entities.ts";
|
|
2
|
+
import type { InsightContext } from "../define.ts";
|
|
3
|
+
export declare const HOUR = 3600000;
|
|
4
|
+
export interface DroppedReply {
|
|
5
|
+
/** The oldest reply in the conversation that got no answer. */
|
|
6
|
+
readonly reply: string;
|
|
7
|
+
readonly lead: string | null;
|
|
8
|
+
/** The person's first and last name. `null` when the lead could not be read or has neither. */
|
|
9
|
+
readonly name: string | null;
|
|
10
|
+
readonly email: string | null;
|
|
11
|
+
readonly linkedinUrl: string | null;
|
|
12
|
+
readonly campaign: string | null;
|
|
13
|
+
/** The campaign's name. `null` when the reply names no campaign or it could not be read. */
|
|
14
|
+
readonly campaignName: string | null;
|
|
15
|
+
readonly channel: "email" | "linkedin";
|
|
16
|
+
readonly provider: string;
|
|
17
|
+
readonly category: string;
|
|
18
|
+
readonly subject: string | null;
|
|
19
|
+
readonly receivedAt: string;
|
|
20
|
+
readonly hoursWaiting: number;
|
|
21
|
+
/** Replies in the conversation since the last message sent to the person. */
|
|
22
|
+
readonly unansweredReplies: number;
|
|
23
|
+
/** Whether the conversation was read by its thread or by the lead's timeline. */
|
|
24
|
+
readonly checkedBy: "thread" | "timeline";
|
|
25
|
+
readonly finding: string;
|
|
26
|
+
}
|
|
27
|
+
export interface Conversation {
|
|
28
|
+
readonly by: "thread" | "timeline" | null;
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly replies: Reply[];
|
|
31
|
+
}
|
|
32
|
+
interface SentByHand {
|
|
33
|
+
readonly messages: readonly Message[];
|
|
34
|
+
/** `false` when the listing stopped at its max with more left. */
|
|
35
|
+
readonly whole: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The messages sent by hand since `since`, up to `max`, where the tool can
|
|
39
|
+
* list them by date on its side: one request per page. `null` where it
|
|
40
|
+
* cannot. Only an answer is read from them, so stopping at `max` leaves the
|
|
41
|
+
* rest to be read by thread and loses nothing.
|
|
42
|
+
*/
|
|
43
|
+
export declare const sentByHand: (context: InsightContext, since: string, max: number) => Promise<SentByHand | null>;
|
|
44
|
+
export interface Checkable extends Conversation {
|
|
45
|
+
readonly by: "thread" | "timeline";
|
|
46
|
+
}
|
|
47
|
+
interface Checked {
|
|
48
|
+
answered: number;
|
|
49
|
+
readonly dropped: DroppedReply[];
|
|
50
|
+
tooRecent: number;
|
|
51
|
+
/** Conversations whose read failed. */
|
|
52
|
+
unread: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Settles each conversation as answered, too recent or dropped. An answer
|
|
56
|
+
* sent by hand after the replies settles one without reading it, and so does
|
|
57
|
+
* an open reply too recent to count, unless the listing stopped at its max
|
|
58
|
+
* and its answer may lie past the stop. The rest are read in full, since a
|
|
59
|
+
* campaign send after the reply counts as an answer too.
|
|
60
|
+
*/
|
|
61
|
+
export declare const check: (context: InsightContext, checkable: readonly Checkable[], sent: SentByHand | null, olderThanHours: number) => Promise<Checked>;
|
|
62
|
+
export {};
|
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/** The oldest reply in the conversation that got no answer. */
|
|
3
|
-
readonly reply: string;
|
|
4
|
-
readonly lead: string | null;
|
|
5
|
-
/** The person's first and last name. `null` when the lead could not be read or has neither. */
|
|
6
|
-
readonly name: string | null;
|
|
7
|
-
readonly email: string | null;
|
|
8
|
-
readonly linkedinUrl: string | null;
|
|
9
|
-
readonly campaign: string | null;
|
|
10
|
-
/** The campaign's name. `null` when the reply names no campaign or it could not be read. */
|
|
11
|
-
readonly campaignName: string | null;
|
|
12
|
-
readonly channel: "email" | "linkedin";
|
|
13
|
-
readonly provider: string;
|
|
14
|
-
readonly category: string;
|
|
15
|
-
readonly subject: string | null;
|
|
16
|
-
readonly receivedAt: string;
|
|
17
|
-
readonly hoursWaiting: number;
|
|
18
|
-
/** Replies in the conversation since the last message sent to the person. */
|
|
19
|
-
readonly unansweredReplies: number;
|
|
20
|
-
/** Whether the conversation was read by its thread or by the lead's timeline. */
|
|
21
|
-
readonly checkedBy: "thread" | "timeline";
|
|
22
|
-
readonly finding: string;
|
|
23
|
-
}
|
|
1
|
+
import type { DroppedReply } from "./dropped-replies-check.ts";
|
|
24
2
|
export interface DroppedReplies {
|
|
25
3
|
/** Longest waiting first. */
|
|
26
4
|
readonly dropped: readonly DroppedReply[];
|
|
@@ -43,7 +21,7 @@ export interface DroppedReplies {
|
|
|
43
21
|
readonly dropped: number;
|
|
44
22
|
/** Unanswered, as far as was read, but waiting less than `older_than_hours`. */
|
|
45
23
|
readonly tooRecent: number;
|
|
46
|
-
/** Could not be checked: no thread or lead to read, or no time on the reply. Not counted as dropped. */
|
|
24
|
+
/** Could not be checked: no thread or lead to read, a read that failed, or no time on the reply. Not counted as dropped. */
|
|
47
25
|
readonly unchecked: number;
|
|
48
26
|
/** `true` when `max_replies`, or the 2,000 replies one window reads, stopped the read with more replies left, so dropped ones may be missing. */
|
|
49
27
|
readonly moreRepliesExist: boolean;
|
|
@@ -92,7 +92,8 @@ export declare const PEOPLE_INSIGHTS: readonly [import("../define.ts").InsightDe
|
|
|
92
92
|
max_leads?: number | undefined;
|
|
93
93
|
}>];
|
|
94
94
|
export type { AccountPerson, AccountRecord, AccountSummary, } from "./account-summary.ts";
|
|
95
|
-
export type {
|
|
95
|
+
export type { DroppedReply } from "./dropped-replies-check.ts";
|
|
96
|
+
export type { DroppedReplies } from "./dropped-replies.ts";
|
|
96
97
|
export type { HotLead, HotLeadParts, HotLeads } from "./hot-leads.ts";
|
|
97
98
|
export type { CollisionCampaign, LeadCollision, LeadCollisions, } from "./lead-collisions.ts";
|
|
98
99
|
export type { PersonCampaign, PersonSummary } from "./person-summary.ts";
|
package/dist/redact/index.js
CHANGED
|
@@ -232,12 +232,25 @@ var remasked = (known, error) => new OutboundError(error.code, known.remask(erro
|
|
|
232
232
|
status: error.status,
|
|
233
233
|
timedOut: error.timedOut
|
|
234
234
|
});
|
|
235
|
+
var unmaskedQuery = (known, query) => {
|
|
236
|
+
if (JSON.stringify(query).match(TOKEN) === null) {
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
239
|
+
const fields = query;
|
|
240
|
+
return Object.fromEntries(
|
|
241
|
+
Object.entries(fields).map(([key, value]) => [
|
|
242
|
+
key,
|
|
243
|
+
maskEach(value, (text) => known.unmask(text))
|
|
244
|
+
])
|
|
245
|
+
);
|
|
246
|
+
};
|
|
235
247
|
var unmasked = (known, operation) => {
|
|
236
|
-
if (
|
|
237
|
-
|
|
248
|
+
if ("id" in operation) {
|
|
249
|
+
const id = known.unmask(operation.id);
|
|
250
|
+
return id === operation.id ? operation : { ...operation, id };
|
|
238
251
|
}
|
|
239
|
-
const
|
|
240
|
-
return
|
|
252
|
+
const query = unmaskedQuery(known, operation.query);
|
|
253
|
+
return query === void 0 ? operation : { ...operation, query };
|
|
241
254
|
};
|
|
242
255
|
var redact = (options = {}) => {
|
|
243
256
|
const fields = new Set(options.fields ?? ALL_FIELDS);
|