outbound-sdk 0.8.0 → 0.9.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.
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-4PA526S7.js";
16
16
  import {
17
17
  createOutbound
18
- } from "./chunk-RQLOPMMR.js";
18
+ } from "./chunk-MEEJIIIA.js";
19
19
  import {
20
20
  plural
21
21
  } from "./chunk-PTZO4QXR.js";
@@ -25,7 +25,7 @@ import {
25
25
  } from "./chunk-QGRZDTX4.js";
26
26
  import {
27
27
  fromEnv
28
- } from "./chunk-7TASUWPC.js";
28
+ } from "./chunk-5XLR6XVV.js";
29
29
  import {
30
30
  OutboundError
31
31
  } from "./chunk-XYHM4KHC.js";
@@ -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-II7GXAOM.js");
759
+ const { insightLeftOutReason } = await import("./tools-ATY622UC.js");
760
760
  const why = leftOutReason(outbound, name) ?? insightLeftOutReason(outbound, name);
761
761
  if (why !== void 0) {
762
762
  throw new OutboundError("Unsupported", why, {
@@ -29,6 +29,7 @@ var NO_CAPABILITIES = {
29
29
  "leads.byCampaign": false,
30
30
  "leads.byDomain": false,
31
31
  "leads.byInterest": false,
32
+ "leads.byStatus": false,
32
33
  "leads.engagement": false,
33
34
  "leads.get": false,
34
35
  "leads.list": false,
@@ -18,7 +18,7 @@ import {
18
18
  senderHealthSchema,
19
19
  tagSchema,
20
20
  webhookSubscriptionSchema
21
- } from "./chunk-RMAHQ2OZ.js";
21
+ } from "./chunk-A7DLJUA6.js";
22
22
  import {
23
23
  plural
24
24
  } from "./chunk-PTZO4QXR.js";
@@ -1361,6 +1361,28 @@ var checkInterest = (core, interest) => {
1361
1361
  );
1362
1362
  }
1363
1363
  };
1364
+ var checkStatus = (core, filters) => {
1365
+ if (filters.status === void 0) {
1366
+ return;
1367
+ }
1368
+ requireCapability(
1369
+ core.gate,
1370
+ "leads.byStatus",
1371
+ "Listing only the active leads"
1372
+ );
1373
+ if (filters.status !== "active") {
1374
+ throw new OutboundError(
1375
+ "Invalid",
1376
+ `status takes "active", not "${String(filters.status)}"`
1377
+ );
1378
+ }
1379
+ if (filters.interest !== void 0) {
1380
+ throw new OutboundError(
1381
+ "Invalid",
1382
+ "Leads can be listed by interest or by status, not both at once"
1383
+ );
1384
+ }
1385
+ };
1364
1386
  var leadList = (core) => ({
1365
1387
  action: "leads.list",
1366
1388
  takes: {
@@ -1372,6 +1394,7 @@ var leadList = (core) => ({
1372
1394
  linkedinUrl: true,
1373
1395
  listId: true,
1374
1396
  since: true,
1397
+ status: true,
1375
1398
  until: true
1376
1399
  },
1377
1400
  // A lookup returns one record per campaign the person is in. On a vendor
@@ -1395,6 +1418,7 @@ var leadList = (core) => ({
1395
1418
  }
1396
1419
  const emails = manyAddresses(core, filters.emails);
1397
1420
  checkInterest(core, filters.interest);
1421
+ checkStatus(core, filters);
1398
1422
  const domain = filters.domain?.trim().toLowerCase();
1399
1423
  if (domain !== void 0) {
1400
1424
  requireCapability(
@@ -1431,6 +1455,7 @@ var leadList = (core) => ({
1431
1455
  interest: filters.interest,
1432
1456
  linkedinUrl: filters.linkedinUrl?.trim(),
1433
1457
  listId: filters.listId,
1458
+ status: filters.status,
1434
1459
  ...normalizeRange(filters)
1435
1460
  };
1436
1461
  },
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  run
3
- } from "./chunk-4GK56PRO.js";
3
+ } from "./chunk-4BH5LRCS.js";
4
4
 
5
5
  // src/cli/bin.ts
6
6
  import process from "node:process";
@@ -3813,10 +3813,13 @@ var describe2 = ({ complete, daysLeft, inSequence, remaining }, forecast) => {
3813
3813
  const range = low === high ? "" : ` (between ${low} and ${high})`;
3814
3814
  return `${leads}; expect about ${expected} ${noun(Number(expected), "reply", "replies")}${range}. This is an estimate.`;
3815
3815
  };
3816
+ var ownerOf = (context, campaign) => context.outbound.provider === "combined" ? context.outbound.workspace(`${campaign.provider}:${campaign.workspaceId}`) : context.outbound;
3816
3817
  var runwayOf = async (context, campaign, options) => {
3818
+ const owner = ownerOf(context, campaign);
3819
+ const status = options.activeOnly === true && owner.capabilities["leads.byStatus"] ? "active" : void 0;
3817
3820
  const { capped: capped2, items: leads } = await readCapped(
3818
3821
  context,
3819
- (max) => context.outbound.campaign(campaign.ref).leads.listAll({ max }),
3822
+ (max) => owner.campaign(campaign.ref).leads.listAll({ max, status }),
3820
3823
  {
3821
3824
  input: options.leadsInput,
3822
3825
  max: options.maxLeads,
@@ -3901,7 +3904,9 @@ var input13 = z16.object({
3901
3904
  days: z16.number().int().min(1).max(90).default(7).describe("The length of the period, in complete days ending yesterday"),
3902
3905
  limit: z16.number().int().min(1).max(20).default(3).describe("How many best and worst campaigns to show"),
3903
3906
  max_bounce_rate: z16.number().min(0).max(1).default(0.03).describe("A campaign bounce rate over this is a bounce problem"),
3904
- max_leads_per_campaign: z16.number().int().min(1).max(5e4).default(500).describe("The most leads to read per active campaign, for leads left"),
3907
+ max_leads_per_campaign: z16.number().int().min(1).max(5e4).default(5e3).describe(
3908
+ "The most leads to read per active campaign, for leads left. Where the tool lists active leads alone (leads.byStatus), only those are read."
3909
+ ),
3905
3910
  min_baseline_points: z16.number().int().min(2).default(5).describe("The fewest baseline days with data a day needs to be tested"),
3906
3911
  min_sent: z16.number().int().min(0).default(50).describe("Campaigns under this many sends in the period are not judged"),
3907
3912
  runway_days: z16.number().min(0).default(7).describe(
@@ -3963,6 +3968,7 @@ var readRunways = async (context, campaigns, options) => {
3963
3968
  async (campaign) => ({
3964
3969
  campaign,
3965
3970
  forecast: await runwayOf(context, campaign, {
3971
+ activeOnly: true,
3966
3972
  days: options.days,
3967
3973
  leadsInput: "max_leads_per_campaign",
3968
3974
  leadsWhat: "leads of a campaign",
@@ -4040,7 +4046,7 @@ var actionsOf = (report) => {
4040
4046
  ];
4041
4047
  };
4042
4048
  var clientReport = defineInsight({
4043
- description: "One report for one client or workspace over the last `days` complete days: totals and the change from the period before, the best and worst campaigns by the low end of the interval of the reply rate, campaigns with a bounce problem, unusual days, active campaigns running out of leads, and a short list of action items in plain language, each naming the campaign and the number behind it. Reply rates divide by messages sent (`replyRateBasis`), since a period's replies also answer leads contacted before it, and by leads contacted for both periods only when a period does not report messages sent. Use it for a weekly client update. A section the adapter cannot serve is null and named in `leftOut`, and a null count is one the vendor does not report. Costs two stats requests per campaign, one for the workspace, and for each active campaign one more plus its pages of leads. On Instantly a stats read is 2 requests, since it also reads the campaign's tracking settings, so each active campaign costs about 7.",
4049
+ description: "One report for one client or workspace over the last `days` complete days: totals and the change from the period before, the best and worst campaigns by the low end of the interval of the reply rate, campaigns with a bounce problem, unusual days, active campaigns running out of leads, and a short list of action items in plain language, each naming the campaign and the number behind it. Reply rates divide by messages sent (`replyRateBasis`), since a period's replies also answer leads contacted before it, and by leads contacted for both periods only when a period does not report messages sent. Use it for a weekly client update. A section the adapter cannot serve is null and named in `leftOut`, and a null count is one the vendor does not report. Costs two stats requests per campaign, one for the workspace, and for each active campaign one more plus its pages of leads, its active leads only where the tool lists them alone (leads.byStatus). On Instantly a stats read is 2 requests, since it also reads the campaign's tracking settings, so each active campaign costs about 7.",
4044
4050
  inputSchema: input13,
4045
4051
  key: "clientReport",
4046
4052
  cost: (values, price) => {
@@ -2,7 +2,7 @@ import {
2
2
  INSIGHT_TOOL_CEILING,
3
3
  insightLeftOutReason,
4
4
  insightTools
5
- } from "./chunk-XMCNRU4H.js";
5
+ } from "./chunk-REDFBY74.js";
6
6
  import "./chunk-FTK4JS65.js";
7
7
  import "./chunk-4PA526S7.js";
8
8
  import "./chunk-HZCTYL22.js";
package/dist/cli/bin.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import "../chunks/chunk-IKKCMWBK.js";
3
- import "../chunks/chunk-4GK56PRO.js";
2
+ import "../chunks/chunk-QTWJ5FO7.js";
3
+ import "../chunks/chunk-4BH5LRCS.js";
4
4
  import "../chunks/chunk-OMCDMELK.js";
5
5
  import "../chunks/chunk-OVTYA3IB.js";
6
6
  import "../chunks/chunk-FTK4JS65.js";
7
7
  import "../chunks/chunk-4PA526S7.js";
8
8
  import "../chunks/chunk-HZCTYL22.js";
9
- import "../chunks/chunk-RQLOPMMR.js";
9
+ import "../chunks/chunk-MEEJIIIA.js";
10
10
  import "../chunks/chunk-4O2HRTTI.js";
11
11
  import "../chunks/chunk-HPNGSG5E.js";
12
- import "../chunks/chunk-RMAHQ2OZ.js";
12
+ import "../chunks/chunk-A7DLJUA6.js";
13
13
  import "../chunks/chunk-PTZO4QXR.js";
14
14
  import "../chunks/chunk-POBAY3TI.js";
15
15
  import "../chunks/chunk-CPACP4YD.js";
@@ -17,7 +17,7 @@ import "../chunks/chunk-QGRZDTX4.js";
17
17
  import "../chunks/chunk-HXB2IOJJ.js";
18
18
  import "../chunks/chunk-YFJ3OQZS.js";
19
19
  import "../chunks/chunk-KVAG5GM2.js";
20
- import "../chunks/chunk-7TASUWPC.js";
20
+ import "../chunks/chunk-5XLR6XVV.js";
21
21
  import "../chunks/chunk-NFWWA7MI.js";
22
22
  import "../chunks/chunk-XYHM4KHC.js";
23
23
  import "../chunks/chunk-45TXPJW7.js";
package/dist/cli/index.js CHANGED
@@ -6,16 +6,16 @@ import {
6
6
  run,
7
7
  serveStdio,
8
8
  throttleMonitor
9
- } from "../chunks/chunk-4GK56PRO.js";
9
+ } from "../chunks/chunk-4BH5LRCS.js";
10
10
  import "../chunks/chunk-OMCDMELK.js";
11
11
  import "../chunks/chunk-OVTYA3IB.js";
12
12
  import "../chunks/chunk-FTK4JS65.js";
13
13
  import "../chunks/chunk-4PA526S7.js";
14
14
  import "../chunks/chunk-HZCTYL22.js";
15
- import "../chunks/chunk-RQLOPMMR.js";
15
+ import "../chunks/chunk-MEEJIIIA.js";
16
16
  import "../chunks/chunk-4O2HRTTI.js";
17
17
  import "../chunks/chunk-HPNGSG5E.js";
18
- import "../chunks/chunk-RMAHQ2OZ.js";
18
+ import "../chunks/chunk-A7DLJUA6.js";
19
19
  import "../chunks/chunk-PTZO4QXR.js";
20
20
  import "../chunks/chunk-POBAY3TI.js";
21
21
  import "../chunks/chunk-CPACP4YD.js";
@@ -23,7 +23,7 @@ import "../chunks/chunk-QGRZDTX4.js";
23
23
  import "../chunks/chunk-HXB2IOJJ.js";
24
24
  import "../chunks/chunk-YFJ3OQZS.js";
25
25
  import "../chunks/chunk-KVAG5GM2.js";
26
- import "../chunks/chunk-7TASUWPC.js";
26
+ import "../chunks/chunk-5XLR6XVV.js";
27
27
  import "../chunks/chunk-NFWWA7MI.js";
28
28
  import "../chunks/chunk-XYHM4KHC.js";
29
29
  import "../chunks/chunk-45TXPJW7.js";
@@ -3,7 +3,7 @@ import {
3
3
  mergeFields,
4
4
  resolveCapabilities,
5
5
  resolveFields
6
- } from "../chunks/chunk-RMAHQ2OZ.js";
6
+ } from "../chunks/chunk-A7DLJUA6.js";
7
7
  import {
8
8
  recordBase
9
9
  } from "../chunks/chunk-U5AK6OJM.js";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Outbound,
4
4
  createOutbound,
5
5
  fullJitterBackoff
6
- } from "./chunks/chunk-RQLOPMMR.js";
6
+ } from "./chunks/chunk-MEEJIIIA.js";
7
7
  import {
8
8
  MemoryRateLimitStore
9
9
  } from "./chunks/chunk-4O2HRTTI.js";
@@ -22,7 +22,7 @@ import {
22
22
  senderHealthSchema,
23
23
  tagSchema,
24
24
  webhookSubscriptionSchema
25
- } from "./chunks/chunk-RMAHQ2OZ.js";
25
+ } from "./chunks/chunk-A7DLJUA6.js";
26
26
  import "./chunks/chunk-PTZO4QXR.js";
27
27
  import {
28
28
  defineNative
@@ -18,7 +18,7 @@ import {
18
18
  total,
19
19
  wilson,
20
20
  zScore
21
- } from "../chunks/chunk-XMCNRU4H.js";
21
+ } from "../chunks/chunk-REDFBY74.js";
22
22
  import "../chunks/chunk-FTK4JS65.js";
23
23
  import "../chunks/chunk-4PA526S7.js";
24
24
  import "../chunks/chunk-HZCTYL22.js";
@@ -993,9 +993,9 @@ export interface InsightInputs {
993
993
  */
994
994
  readonly max_bounce_rate?: number | undefined;
995
995
  /**
996
- * The most leads to read per active campaign, for leads left
996
+ * The most leads to read per active campaign, for leads left. Where the tool lists active leads alone (leads.byStatus), only those are read.
997
997
  *
998
- * A whole number from 1 to 50,000. Defaults to `500`.
998
+ * A whole number from 1 to 50,000. Defaults to `5000`.
999
999
  */
1000
1000
  readonly max_leads_per_campaign?: number | undefined;
1001
1001
  /**
@@ -51,6 +51,12 @@ export interface ForecastOptions {
51
51
  readonly leadsInput: string;
52
52
  /** What `maxLeads` counts, for that note: `leads`, or `leads of a campaign`. */
53
53
  readonly leadsWhat: string;
54
+ /**
55
+ * Read only the active leads where the campaign's tool can list them
56
+ * (`leads.byStatus`), since only they decide the runway. `byStatus` then
57
+ * counts the active leads alone.
58
+ */
59
+ readonly activeOnly?: boolean | undefined;
54
60
  }
55
61
  /** Reads one campaign's leads, totals and recent pace, and projects what is left. */
56
62
  /** How long a campaign's leads last: its leads by status and the recent pace of new leads started. */
@@ -463,6 +463,9 @@ var capabilities = {
463
463
  // The `filter` field of POST /leads/list, one positive interest status
464
464
  // (FILTER_LEAD_INTERESTED and the rest) after another.
465
465
  "leads.byInterest": true,
466
+ // The `filter` FILTER_VAL_ACTIVE of POST /leads/list; the adapter keeps
467
+ // only the leads it maps to active, so the answer is exact either way.
468
+ "leads.byStatus": true,
466
469
  "leads.engagement": true,
467
470
  "leads.get": true,
468
471
  "leads.list": true,
@@ -1428,6 +1431,9 @@ var leadListBody = (query) => {
1428
1431
  if (query.domain !== void 0) {
1429
1432
  body.search = query.domain;
1430
1433
  }
1434
+ if (query.status === "active") {
1435
+ body.filter = "FILTER_VAL_ACTIVE";
1436
+ }
1431
1437
  if (query.interest === "positive") {
1432
1438
  const { after: after2, at } = interestAt(query.next);
1433
1439
  body.filter = POSITIVE_FILTERS[at] ?? null;
@@ -1464,7 +1470,7 @@ var listLeads = async (client, query, ctx) => {
1464
1470
  var chosen = (query, leads) => {
1465
1471
  const wanted = new Set(query.emails);
1466
1472
  return leads.filter(
1467
- (lead) => (query.email === void 0 || lead.email === query.email) && (query.emails === void 0 || lead.email !== null && wanted.has(lead.email)) && (query.domain === void 0 || lead.email?.split("@").at(-1) === query.domain) && (query.interest === void 0 || lead.interestCategory === "positive")
1473
+ (lead) => (query.email === void 0 || lead.email === query.email) && (query.emails === void 0 || lead.email !== null && wanted.has(lead.email)) && (query.domain === void 0 || lead.email?.split("@").at(-1) === query.domain) && (query.interest === void 0 || lead.interestCategory === "positive") && (query.status === void 0 || lead.status === query.status)
1468
1474
  );
1469
1475
  };
1470
1476
  var nextOf = (query, envelope) => {
@@ -74,6 +74,8 @@ export interface LeadQuery extends PageQuery, TimeRange {
74
74
  readonly emails?: readonly string[] | undefined;
75
75
  /** `positive`: only the leads the vendor labels positive, whose `interestCategory` is `positive`. */
76
76
  readonly interest?: "positive" | undefined;
77
+ /** `active`: only the leads whose `status` is `active`. Never set together with `interest`. */
78
+ readonly status?: "active" | undefined;
77
79
  }
78
80
  export interface MessageQuery extends PageQuery, TimeRange {
79
81
  readonly campaignId?: string | undefined;
@@ -37,6 +37,8 @@ export interface Capabilities {
37
37
  "leads.lookupMany": boolean;
38
38
  /** List only the leads the vendor labels positive, without walking every lead. */
39
39
  "leads.byInterest": boolean;
40
+ /** List only the active leads, those still in the sequence, without walking every lead. */
41
+ "leads.byStatus": boolean;
40
42
  /** Leads carry open, click and reply counts. */
41
43
  "leads.engagement": boolean;
42
44
  /** List the saved lead lists. */
@@ -108,6 +108,8 @@ export interface LeadFilters extends TimeRange {
108
108
  readonly emails?: readonly string[] | undefined;
109
109
  /** `positive`: only the leads the vendor labels positive (`interestCategory` `positive`). Needs `leads.byInterest`. */
110
110
  readonly interest?: "positive" | undefined;
111
+ /** `active`: only the leads still in the sequence (`status` `active`). Needs `leads.byStatus`. Not together with `interest`. */
112
+ readonly status?: "active" | undefined;
111
113
  }
112
114
  export interface WebhookFilters {
113
115
  readonly campaignId?: string | undefined;
@@ -3,7 +3,7 @@ import {
3
3
  configuredProviders,
4
4
  fromEnv,
5
5
  loadableProviders
6
- } from "../chunks/chunk-7TASUWPC.js";
6
+ } from "../chunks/chunk-5XLR6XVV.js";
7
7
  import "../chunks/chunk-NFWWA7MI.js";
8
8
  import "../chunks/chunk-XYHM4KHC.js";
9
9
  import "../chunks/chunk-45TXPJW7.js";
@@ -424,6 +424,7 @@ var FULL_CAPABILITIES = {
424
424
  "campaigns.status": "server",
425
425
  "leads.byCampaign": true,
426
426
  "leads.byDomain": true,
427
+ "leads.byStatus": true,
427
428
  "leads.engagement": true,
428
429
  "leads.get": true,
429
430
  "leads.list": true,
@@ -468,6 +469,9 @@ var selectMessages = (store, query, key) => (store.data.messages ?? []).filter(
468
469
  var selectLeads = (store, query) => (store.data.leads ?? []).filter(
469
470
  (lead) => (query.campaignId === void 0 || lead.campaignId === query.campaignId) && (query.listId === void 0 || (lead.listIds ?? []).includes(query.listId)) && (query.email === void 0 || lead.email?.trim().toLowerCase() === query.email) && (query.domain === void 0 || lead.email?.trim().toLowerCase().split("@").at(-1) === query.domain) && (query.linkedinUrl === void 0 || profileSlug(lead.linkedinUrl) !== null && profileSlug(lead.linkedinUrl) === profileSlug(query.linkedinUrl)) && (!filtersByTime(store, "leads.since") || within(lead.createdAt, query))
470
471
  );
472
+ var selectedLeads = (store, query) => selectLeads(store, query).map((seed) => toLead(store.identity, seed)).filter(
473
+ (lead) => query.status === void 0 || lead.status === query.status
474
+ );
471
475
  var getters = (store) => {
472
476
  const { data, identity } = store;
473
477
  return {
@@ -503,16 +507,7 @@ var listers = (store) => {
503
507
  pageSize
504
508
  )
505
509
  ),
506
- listLeads: (query) => {
507
- const seeds = selectLeads(store, query);
508
- return Promise.resolve(
509
- paginate(
510
- seeds.map((seed) => toLead(identity, seed)),
511
- query,
512
- pageSize
513
- )
514
- );
515
- },
510
+ listLeads: (query) => Promise.resolve(paginate(selectedLeads(store, query), query, pageSize)),
516
511
  listMessages: (query) => Promise.resolve(
517
512
  paginate(
518
513
  selectMessages(store, query, "messages.since").map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "outbound-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "One small, typed, read-only API over outbound sending tools.",
5
5
  "keywords": [
6
6
  "cold-email",