outbound-sdk 0.2.1 → 0.5.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.
Files changed (175) hide show
  1. package/README.md +2 -2
  2. package/dist/alerts/check-evaluate.d.ts +53 -0
  3. package/dist/alerts/check-measure.d.ts +100 -0
  4. package/dist/alerts/check-schema.d.ts +184 -0
  5. package/dist/alerts/check-validate.d.ts +18 -0
  6. package/dist/alerts/index.d.ts +7 -0
  7. package/dist/alerts/index.js +684 -20
  8. package/dist/alerts/plugin.d.ts +20 -3
  9. package/dist/audit/index.js +2 -2
  10. package/dist/benchmarks/index.js +5 -5
  11. package/dist/budget/index.d.ts +5 -2
  12. package/dist/budget/index.js +12 -10
  13. package/dist/cards/content.d.ts +6 -1
  14. package/dist/cards/format.d.ts +17 -2
  15. package/dist/cards/index.d.ts +1 -1
  16. package/dist/cards/index.js +298 -132
  17. package/dist/cards/parts.d.ts +9 -2
  18. package/dist/cards/render.d.ts +20 -3
  19. package/dist/chunks/{chunk-U2D34ARZ.js → chunk-2D42TQFU.js} +3 -3
  20. package/dist/chunks/{chunk-6CVZOUHB.js → chunk-3S32R2MH.js} +53 -63
  21. package/dist/chunks/chunk-4PA526S7.js +17 -0
  22. package/dist/chunks/{chunk-RCZ7ZZFU.js → chunk-5J7GGV62.js} +12 -5
  23. package/dist/chunks/chunk-6TKFISG4.js +676 -0
  24. package/dist/chunks/{chunk-AFU5E5QB.js → chunk-BK5SLY32.js} +104 -84
  25. package/dist/chunks/{chunk-VQSCHOBV.js → chunk-BLCJHP5H.js} +11 -4
  26. package/dist/chunks/{chunk-SBIZDCRY.js → chunk-BN6WCAWX.js} +7 -7
  27. package/dist/chunks/{chunk-4PSO6JEK.js → chunk-BOWXGMN3.js} +6 -21
  28. package/dist/chunks/{chunk-PURHK3JU.js → chunk-EHSJGQ5K.js} +8 -8
  29. package/dist/chunks/{chunk-IPUYZD4O.js → chunk-GFDNRWR3.js} +1 -1
  30. package/dist/chunks/chunk-HPNGSG5E.js +51 -0
  31. package/dist/chunks/chunk-HWHI4LFY.js +102 -0
  32. package/dist/chunks/{chunk-E7JHLNLG.js → chunk-J7DDZ4C2.js} +15 -2
  33. package/dist/chunks/{chunk-DJ2IUQEU.js → chunk-JWGSB7PT.js} +6 -6
  34. package/dist/chunks/{chunk-R3Y56YVF.js → chunk-OLPMBRXM.js} +4 -3
  35. package/dist/chunks/{chunk-YOTW5ESM.js → chunk-PQSTQKRD.js} +2 -2
  36. package/dist/chunks/chunk-PTZO4QXR.js +15 -0
  37. package/dist/chunks/{chunk-LVYG7XZJ.js → chunk-QAKJ76HB.js} +1 -1
  38. package/dist/chunks/chunk-QGRZDTX4.js +26 -0
  39. package/dist/chunks/chunk-WGW3ROLY.js +18 -0
  40. package/dist/chunks/{chunk-XC6CZP73.js → chunk-WH6V3YNN.js} +32 -1
  41. package/dist/chunks/{chunk-P3IJBJUI.js → chunk-X4RDBD4J.js} +296 -62
  42. package/dist/chunks/chunk-XL6LJVHJ.js +71 -0
  43. package/dist/chunks/{chunk-XNFESPZH.js → chunk-YYCT3NGV.js} +200 -39
  44. package/dist/chunks/{chunk-UAT3JSJZ.js → chunk-ZOAG2C6V.js} +2 -2
  45. package/dist/cli/bin.js +19 -30
  46. package/dist/cli/commands.d.ts +11 -0
  47. package/dist/cli/index.d.ts +3 -0
  48. package/dist/cli/index.js +18 -13
  49. package/dist/cli/mcp.d.ts +5 -0
  50. package/dist/cli/update.d.ts +15 -0
  51. package/dist/clients/index.d.ts +1 -1
  52. package/dist/clients/index.js +35 -10
  53. package/dist/clients/plugin.d.ts +9 -2
  54. package/dist/combine/index.js +7 -6
  55. package/dist/emailbison/account.d.ts +7 -0
  56. package/dist/emailbison/adapter.d.ts +5 -0
  57. package/dist/emailbison/capabilities.d.ts +78 -0
  58. package/dist/emailbison/client.d.ts +29 -0
  59. package/dist/emailbison/index.d.ts +30 -0
  60. package/dist/emailbison/index.js +1017 -0
  61. package/dist/emailbison/mail.d.ts +5 -0
  62. package/dist/emailbison/map-mail.d.ts +13 -0
  63. package/dist/emailbison/map-sequence.d.ts +12 -0
  64. package/dist/emailbison/map-stats.d.ts +47 -0
  65. package/dist/emailbison/map.d.ts +24 -0
  66. package/dist/emailbison/native-params.d.ts +5 -0
  67. package/dist/emailbison/native-workspace.d.ts +167 -0
  68. package/dist/emailbison/native.d.ts +327 -0
  69. package/dist/emailbison/stats.d.ts +4 -0
  70. package/dist/emailbison/webhooks.d.ts +2 -0
  71. package/dist/exporter/index.d.ts +5 -2
  72. package/dist/exporter/index.js +2 -2
  73. package/dist/failover/index.js +3 -3
  74. package/dist/fixtures/index.js +10 -9
  75. package/dist/heyreach/capabilities.d.ts +3 -0
  76. package/dist/heyreach/client.d.ts +2 -0
  77. package/dist/heyreach/index.js +83 -51
  78. package/dist/heyreach/map.d.ts +5 -2
  79. package/dist/identity/index.js +33 -17
  80. package/dist/identity/plugin.d.ts +2 -0
  81. package/dist/index.d.ts +2 -2
  82. package/dist/index.js +29 -25
  83. package/dist/insights/campaign.d.ts +3 -0
  84. package/dist/insights/capped.d.ts +29 -0
  85. package/dist/insights/copy/copy-audit.d.ts +2 -0
  86. package/dist/insights/copy/copy-reuse.d.ts +27 -3
  87. package/dist/insights/copy/index.d.ts +8 -8
  88. package/dist/insights/copy/reply-timing.d.ts +8 -0
  89. package/dist/insights/copy/reuse-base.d.ts +32 -0
  90. package/dist/insights/copy/shared.d.ts +39 -15
  91. package/dist/insights/copy/step-funnel.d.ts +16 -5
  92. package/dist/insights/copy/variant-test.d.ts +19 -8
  93. package/dist/insights/cost.d.ts +91 -0
  94. package/dist/insights/define.d.ts +78 -3
  95. package/dist/insights/fields.d.ts +16 -0
  96. package/dist/insights/index.d.ts +6 -4
  97. package/dist/insights/index.js +1816 -748
  98. package/dist/insights/inputs.generated.d.ts +951 -0
  99. package/dist/insights/ops/campaign-diagnosis.d.ts +3 -1
  100. package/dist/insights/ops/campaign-ranking.d.ts +15 -7
  101. package/dist/insights/ops/channel-mix.d.ts +2 -1
  102. package/dist/insights/ops/client-report.d.ts +18 -5
  103. package/dist/insights/ops/index.d.ts +8 -4
  104. package/dist/insights/ops/period-comparison.d.ts +14 -3
  105. package/dist/insights/ops/pipeline-forecast.d.ts +14 -4
  106. package/dist/insights/ops/shared.d.ts +39 -24
  107. package/dist/insights/ops/tag-rollup.d.ts +2 -1
  108. package/dist/insights/people/account-summary.d.ts +13 -0
  109. package/dist/insights/people/dropped-replies.d.ts +8 -0
  110. package/dist/insights/people/find.d.ts +7 -1
  111. package/dist/insights/people/hot-leads.d.ts +16 -1
  112. package/dist/insights/people/person-summary.d.ts +6 -0
  113. package/dist/insights/people/read.d.ts +26 -10
  114. package/dist/insights/people/suppression-check.d.ts +11 -2
  115. package/dist/insights/plugin.d.ts +26 -5
  116. package/dist/insights/ref.d.ts +6 -0
  117. package/dist/insights/registry.d.ts +30 -18
  118. package/dist/insights/run-cap.d.ts +35 -0
  119. package/dist/insights/senders/bounce-watch.d.ts +25 -8
  120. package/dist/insights/senders/capacity-sends.d.ts +22 -0
  121. package/dist/insights/senders/domain-health.d.ts +10 -4
  122. package/dist/insights/senders/index.d.ts +14 -6
  123. package/dist/insights/senders/read.d.ts +15 -14
  124. package/dist/insights/senders/sender-capacity.d.ts +5 -13
  125. package/dist/insights/senders/sender-load.d.ts +2 -0
  126. package/dist/insights/stats.d.ts +8 -0
  127. package/dist/insights/tools.d.ts +13 -2
  128. package/dist/instantly/capabilities.d.ts +13 -0
  129. package/dist/instantly/client.d.ts +2 -0
  130. package/dist/instantly/index.js +77 -49
  131. package/dist/instantly/map.d.ts +6 -2
  132. package/dist/internal/adapter.d.ts +12 -0
  133. package/dist/internal/engine/request.d.ts +5 -0
  134. package/dist/internal/entities.d.ts +3 -20
  135. package/dist/internal/errors.d.ts +44 -0
  136. package/dist/internal/fields.d.ts +1 -1
  137. package/dist/internal/json.d.ts +9 -2
  138. package/dist/internal/lists.d.ts +24 -0
  139. package/dist/internal/numbers.d.ts +8 -0
  140. package/dist/internal/outbound/collections.d.ts +4 -0
  141. package/dist/internal/outbound/create.d.ts +24 -3
  142. package/dist/internal/outbound/outbound.d.ts +18 -2
  143. package/dist/internal/outbound/validate.d.ts +4 -0
  144. package/dist/internal/outbound/walker.d.ts +3 -2
  145. package/dist/internal/plural.d.ts +12 -0
  146. package/dist/internal/renamed.d.ts +28 -0
  147. package/dist/internal/request-cap.d.ts +35 -0
  148. package/dist/internal/vocabulary.d.ts +20 -0
  149. package/dist/loader/index.js +5 -5
  150. package/dist/memory/adapter.d.ts +7 -0
  151. package/dist/memory/demo-stats.d.ts +3 -0
  152. package/dist/memory/demo.d.ts +14 -3
  153. package/dist/memory/index.d.ts +1 -0
  154. package/dist/memory/index.js +209 -104
  155. package/dist/providers/index.d.ts +92 -0
  156. package/dist/providers/index.js +3 -1
  157. package/dist/reconcile/index.js +5 -4
  158. package/dist/redact/index.js +13 -7
  159. package/dist/redact/plugin.d.ts +7 -0
  160. package/dist/smartlead/capabilities.d.ts +5 -0
  161. package/dist/smartlead/index.js +119 -66
  162. package/dist/smartlead/shared.d.ts +13 -0
  163. package/dist/sync/index.js +2 -2
  164. package/dist/tools/ai-sdk.js +10 -6
  165. package/dist/tools/campaign-tools.d.ts +1 -1
  166. package/dist/tools/claude-agent.js +10 -6
  167. package/dist/tools/index.d.ts +2 -2
  168. package/dist/tools/index.js +16 -9
  169. package/dist/tools/input-problem.d.ts +8 -0
  170. package/dist/tools/registry.d.ts +26 -2
  171. package/dist/tools/shared.d.ts +27 -1
  172. package/dist/tracing/index.js +2 -2
  173. package/dist/webhooks/index.js +22 -12
  174. package/package.json +8 -2
  175. package/dist/chunks/chunk-FKH5N47I.js +0 -40
@@ -12,6 +12,7 @@ export interface CampaignDiagnosis extends CampaignLabel {
12
12
  }
13
13
  export declare const campaignDiagnosis: import("../define.ts").InsightDefinition<"campaignDiagnosis", {
14
14
  campaign: string;
15
+ days: number;
15
16
  daily_limit_share: number;
16
17
  max_bounce_rate: number;
17
18
  max_send_drop: number;
@@ -20,11 +21,12 @@ export declare const campaignDiagnosis: import("../define.ts").InsightDefinition
20
21
  min_reply_rate: number;
21
22
  min_sent: number;
22
23
  min_weekly_hours: number;
23
- recent_days: number;
24
24
  from: string | null;
25
25
  to: string | null;
26
+ recent_days?: number | undefined;
26
27
  }, CampaignDiagnosis, {
27
28
  campaign: string;
29
+ days?: number | undefined;
28
30
  daily_limit_share?: number | undefined;
29
31
  max_bounce_rate?: number | undefined;
30
32
  max_send_drop?: number | undefined;
@@ -1,14 +1,18 @@
1
1
  import { z } from "zod";
2
- import type { CampaignLabel, CampaignTotals, Measured, OpenRange } from "./shared.ts";
2
+ import type { CampaignsRead } from "../capped.ts";
3
+ import type { CampaignLabel, CampaignTotals, Measured, OpenRange, ReplyBasis } from "./shared.ts";
3
4
  declare const metricSchema: z.ZodEnum<{
4
- reply_rate: "reply_rate";
5
5
  bounce_rate: "bounce_rate";
6
+ reply_rate: "reply_rate";
6
7
  positive_reply_rate: "positive_reply_rate";
7
8
  }>;
8
9
  export type RankingMetric = z.infer<typeof metricSchema>;
9
10
  export interface RankedCampaign extends CampaignLabel, Measured {
10
11
  /** 1 is the best. */
11
12
  readonly rank: number;
13
+ /** What `of` counts: leads contacted or messages sent. Always `sent` for bounce rate. */
14
+ readonly basis: ReplyBasis;
15
+ /** Messages sent. `null` when the vendor does not report them. */
12
16
  readonly sent: number | null;
13
17
  }
14
18
  export interface UnrankedCampaign extends CampaignLabel {
@@ -31,22 +35,26 @@ export interface Ranking {
31
35
  readonly unknown: readonly UnrankedCampaign[];
32
36
  readonly gap: RankingGap;
33
37
  }
34
- export interface CampaignRanking extends Ranking {
38
+ export interface CampaignRanking extends Ranking, CampaignsRead {
35
39
  readonly metric: RankingMetric;
36
40
  readonly better: "higher" | "lower";
37
41
  readonly period: OpenRange;
38
42
  }
39
- /** Ranks campaigns that sent enough, and sets the rest aside with the reason. */
40
- export declare const rankCampaigns: (entries: readonly CampaignTotals[], metric: RankingMetric, minSent: number) => Ranking;
43
+ /**
44
+ * Ranks campaigns that sent enough, and sets the rest aside with the reason.
45
+ * `replyBasis` is what replies are divided by; by default leads contacted,
46
+ * or messages sent for a campaign that does not count leads.
47
+ */
48
+ export declare const rankCampaigns: (entries: readonly CampaignTotals[], metric: RankingMetric, minSent: number, replyBasis?: ReplyBasis) => Ranking;
41
49
  export declare const campaignRanking: import("../define.ts").InsightDefinition<"campaignRanking", {
42
- metric: "reply_rate" | "bounce_rate" | "positive_reply_rate";
50
+ metric: "bounce_rate" | "reply_rate" | "positive_reply_rate";
43
51
  min_sent: number;
44
52
  max_campaigns: number;
45
53
  statuses: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[];
46
54
  from: string | null;
47
55
  to: string | null;
48
56
  }, CampaignRanking, {
49
- metric?: "reply_rate" | "bounce_rate" | "positive_reply_rate" | undefined;
57
+ metric?: "bounce_rate" | "reply_rate" | "positive_reply_rate" | undefined;
50
58
  min_sent?: number | undefined;
51
59
  max_campaigns?: number | undefined;
52
60
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
@@ -1,4 +1,5 @@
1
1
  import type { Channel } from "../../internal/entities.ts";
2
+ import type { CampaignsRead } from "../capped.ts";
2
3
  import type { ProportionTest } from "../stats.ts";
3
4
  import type { Measured, OpenRange, Totals } from "./shared.ts";
4
5
  export interface ChannelGroup extends Totals {
@@ -19,7 +20,7 @@ export interface ChannelComparison {
19
20
  readonly difference: number;
20
21
  readonly test: ProportionTest;
21
22
  }
22
- export interface ChannelMix {
23
+ export interface ChannelMix extends CampaignsRead {
23
24
  readonly period: OpenRange;
24
25
  /** Email first, then LinkedIn; only the channels that have campaigns. */
25
26
  readonly channels: readonly ChannelGroup[];
@@ -1,8 +1,13 @@
1
+ import type { CampaignsRead } from "../capped.ts";
1
2
  import type { Anomaly } from "./anomalies.ts";
2
3
  import type { RankedCampaign } from "./campaign-ranking.ts";
3
4
  import type { Comparison } from "./period-comparison.ts";
4
- import type { CampaignLabel, DayRange } from "./shared.ts";
5
+ import type { CampaignLabel, DayRange, ReplyBasis } from "./shared.ts";
5
6
  export interface BounceProblem extends CampaignLabel {
7
+ /** Bounces. The same as `bounced`. */
8
+ readonly count: number | null;
9
+ /** Messages sent, which the rate divides by. The same as `sent`. */
10
+ readonly of: number | null;
6
11
  readonly bounced: number | null;
7
12
  readonly sent: number | null;
8
13
  readonly rate: number;
@@ -13,7 +18,7 @@ export interface LeadRunway extends CampaignLabel {
13
18
  /** Leads still active in the campaign. */
14
19
  readonly remaining: number;
15
20
  readonly dailyContactRate: number | null;
16
- /** An estimate: `remaining` at the recent daily pace. */
21
+ /** An estimate: `remaining` at the recent daily pace. `0` when no lead is left. */
17
22
  readonly daysLeft: number;
18
23
  }
19
24
  export interface ActionItem {
@@ -25,14 +30,20 @@ export interface ActionItem {
25
30
  /** The number behind the item. */
26
31
  readonly number: number | null;
27
32
  }
28
- export interface ClientReport {
33
+ export interface ClientReport extends CampaignsRead {
29
34
  readonly days: number;
30
35
  readonly period: DayRange;
31
36
  readonly previousPeriod: DayRange;
32
37
  readonly campaigns: number;
33
38
  /** Every campaign read, added together: this period, the one before and the change. */
34
39
  readonly totals: Comparison;
35
- /** Best campaigns by the low end of the reply rate interval. */
40
+ /**
41
+ * What `top`, `bottom` and `totals` divide replies by: messages sent in
42
+ * the period when both periods report them, since a period's replies also
43
+ * answer leads contacted before it, and otherwise leads contacted.
44
+ */
45
+ readonly replyRateBasis: ReplyBasis;
46
+ /** Best campaigns by the low end of the interval of the reply rate, over `replyRateBasis`. */
36
47
  readonly top: readonly RankedCampaign[];
37
48
  /** Worst campaigns, worst first. Never repeats one in `top`. */
38
49
  readonly bottom: readonly RankedCampaign[];
@@ -52,19 +63,21 @@ export declare const clientReport: import("../define.ts").InsightDefinition<"cli
52
63
  anomaly_threshold: number;
53
64
  baseline_days: number;
54
65
  days: number;
66
+ limit: number;
55
67
  max_bounce_rate: number;
56
68
  max_leads_per_campaign: number;
57
69
  min_baseline_points: number;
58
70
  min_sent: number;
59
71
  runway_days: number;
60
- top: number;
61
72
  max_campaigns: number;
62
73
  statuses: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[];
74
+ top?: number | undefined;
63
75
  }, ClientReport, {
64
76
  alpha?: number | undefined;
65
77
  anomaly_threshold?: number | undefined;
66
78
  baseline_days?: number | undefined;
67
79
  days?: number | undefined;
80
+ limit?: number | undefined;
68
81
  max_bounce_rate?: number | undefined;
69
82
  max_leads_per_campaign?: number | undefined;
70
83
  min_baseline_points?: number | undefined;
@@ -1,5 +1,6 @@
1
1
  export declare const OPS_INSIGHTS: readonly [import("../define.ts").InsightDefinition<"campaignDiagnosis", {
2
2
  campaign: string;
3
+ days: number;
3
4
  daily_limit_share: number;
4
5
  max_bounce_rate: number;
5
6
  max_send_drop: number;
@@ -8,11 +9,12 @@ export declare const OPS_INSIGHTS: readonly [import("../define.ts").InsightDefin
8
9
  min_reply_rate: number;
9
10
  min_sent: number;
10
11
  min_weekly_hours: number;
11
- recent_days: number;
12
12
  from: string | null;
13
13
  to: string | null;
14
+ recent_days?: number | undefined;
14
15
  }, import("./campaign-diagnosis.ts").CampaignDiagnosis, {
15
16
  campaign: string;
17
+ days?: number | undefined;
16
18
  daily_limit_share?: number | undefined;
17
19
  max_bounce_rate?: number | undefined;
18
20
  max_send_drop?: number | undefined;
@@ -59,14 +61,14 @@ export declare const OPS_INSIGHTS: readonly [import("../define.ts").InsightDefin
59
61
  max_campaigns?: number | undefined;
60
62
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
61
63
  }>, import("../define.ts").InsightDefinition<"campaignRanking", {
62
- metric: "reply_rate" | "bounce_rate" | "positive_reply_rate";
64
+ metric: "bounce_rate" | "reply_rate" | "positive_reply_rate";
63
65
  min_sent: number;
64
66
  max_campaigns: number;
65
67
  statuses: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[];
66
68
  from: string | null;
67
69
  to: string | null;
68
70
  }, import("./campaign-ranking.ts").CampaignRanking, {
69
- metric?: "reply_rate" | "bounce_rate" | "positive_reply_rate" | undefined;
71
+ metric?: "bounce_rate" | "reply_rate" | "positive_reply_rate" | undefined;
70
72
  min_sent?: number | undefined;
71
73
  max_campaigns?: number | undefined;
72
74
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
@@ -101,19 +103,21 @@ export declare const OPS_INSIGHTS: readonly [import("../define.ts").InsightDefin
101
103
  anomaly_threshold: number;
102
104
  baseline_days: number;
103
105
  days: number;
106
+ limit: number;
104
107
  max_bounce_rate: number;
105
108
  max_leads_per_campaign: number;
106
109
  min_baseline_points: number;
107
110
  min_sent: number;
108
111
  runway_days: number;
109
- top: number;
110
112
  max_campaigns: number;
111
113
  statuses: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[];
114
+ top?: number | undefined;
112
115
  }, import("./client-report.ts").ClientReport, {
113
116
  alpha?: number | undefined;
114
117
  anomaly_threshold?: number | undefined;
115
118
  baseline_days?: number | undefined;
116
119
  days?: number | undefined;
120
+ limit?: number | undefined;
117
121
  max_bounce_rate?: number | undefined;
118
122
  max_leads_per_campaign?: number | undefined;
119
123
  min_baseline_points?: number | undefined;
@@ -1,9 +1,13 @@
1
1
  import type { Campaign, CampaignStatus } from "../../internal/entities.ts";
2
2
  import type { MetricCounts } from "../../internal/metrics.ts";
3
+ import type { CampaignsRead } from "../capped.ts";
3
4
  import type { InsightContext } from "../define.ts";
4
5
  import type { ProportionTest } from "../stats.ts";
5
- import type { CampaignLabel, DayRange, Totals } from "./shared.ts";
6
- /** Counts and rates for one period, or the change between two. `null` is unknown. */
6
+ import type { CampaignLabel, DayRange, ReplyBasis, Totals } from "./shared.ts";
7
+ /**
8
+ * Counts and rates for one period, or the change between two. `null` is
9
+ * unknown. The reply and positive reply rates are over `replyRateBasis`.
10
+ */
7
11
  export interface PeriodNumbers extends Totals {
8
12
  readonly replyRate: number | null;
9
13
  readonly positiveRate: number | null;
@@ -12,6 +16,12 @@ export interface PeriodNumbers extends Totals {
12
16
  export interface Comparison {
13
17
  readonly current: PeriodNumbers;
14
18
  readonly previous: PeriodNumbers;
19
+ /**
20
+ * What replies and positive replies are divided by, the same in both
21
+ * periods: messages sent when both report them, since a period's replies
22
+ * also answer leads contacted before it, and otherwise leads contacted.
23
+ */
24
+ readonly replyRateBasis: ReplyBasis;
15
25
  /** `current` minus `previous`, field by field. Rates change in points: 0.02 is two points. */
16
26
  readonly change: PeriodNumbers;
17
27
  /** The two-proportion test on the reply rate. `null` when it cannot be run. */
@@ -26,7 +36,7 @@ export interface ThinCampaign extends CampaignLabel {
26
36
  readonly currentSent: number | null;
27
37
  readonly previousSent: number | null;
28
38
  }
29
- export interface PeriodComparison {
39
+ export interface PeriodComparison extends CampaignsRead {
30
40
  readonly days: number;
31
41
  readonly current: DayRange;
32
42
  readonly previous: DayRange;
@@ -60,6 +70,7 @@ export interface Periods {
60
70
  readonly current: DayRange;
61
71
  readonly previous: DayRange;
62
72
  readonly campaigns: readonly CampaignPeriods[];
73
+ readonly read: CampaignsRead;
63
74
  }
64
75
  /** Each campaign's totals for the last `days` and the `days` before: two stats requests per campaign. */
65
76
  export declare const readPeriods: (context: InsightContext, options: {
@@ -18,7 +18,12 @@ export interface PipelineForecast extends CampaignLabel {
18
18
  readonly remaining: number;
19
19
  /** New leads contacted per day over the last `days`. `null` when the vendor has no daily contacted count. */
20
20
  readonly dailyContactRate: number | null;
21
- /** `remaining` divided by `dailyContactRate`. */
21
+ /**
22
+ * `remaining` divided by `dailyContactRate`, and `0` when every lead was
23
+ * read and none is left. `null` when the remaining leads are unknown (the
24
+ * cap stopped the read, or a lead's status is unknown) or some remain with
25
+ * no contact rate to divide by.
26
+ */
22
27
  readonly daysLeft: number | null;
23
28
  /** The campaign's reply rate so far, over its whole history. */
24
29
  readonly replyRate: Measured;
@@ -28,11 +33,16 @@ export interface PipelineForecast extends CampaignLabel {
28
33
  readonly assumptions: readonly string[];
29
34
  readonly finding: string;
30
35
  }
31
- /** Reads one campaign's leads, totals and recent pace, and projects what is left. */
32
- export declare const forecastCampaign: (context: InsightContext, campaign: Campaign, options: {
36
+ export interface ForecastOptions {
33
37
  readonly days: number;
34
38
  readonly maxLeads: number;
35
- }) => Promise<PipelineForecast>;
39
+ /** The input `maxLeads` came from, for the note when it stops the read. */
40
+ readonly leadsInput: string;
41
+ /** What `maxLeads` counts, for that note: `leads`, or `leads of a campaign`. */
42
+ readonly leadsWhat: string;
43
+ }
44
+ /** Reads one campaign's leads, totals and recent pace, and projects what is left. */
45
+ export declare const forecastCampaign: (context: InsightContext, campaign: Campaign, options: ForecastOptions) => Promise<PipelineForecast>;
36
46
  export declare const pipelineForecast: import("../define.ts").InsightDefinition<"pipelineForecast", {
37
47
  campaign: string;
38
48
  days: number;
@@ -1,7 +1,8 @@
1
1
  import { z } from "zod";
2
2
  import type { Campaign, CampaignStatus } from "../../internal/entities.ts";
3
3
  import type { MetricCounts } from "../../internal/metrics.ts";
4
- import type { ListAll } from "../../internal/outbound/api.ts";
4
+ import type { CampaignsRead } from "../capped.ts";
5
+ import type { Price } from "../cost.ts";
5
6
  import type { InsightContext } from "../define.ts";
6
7
  /** The UTC day of a time, as `YYYY-MM-DD`. */
7
8
  export declare const dayOf: (time: number) => string;
@@ -25,6 +26,15 @@ export interface OpenRange {
25
26
  readonly to: string | null;
26
27
  }
27
28
  /** Input fields the campaign-listing insights share. */
29
+ /**
30
+ * What `readCampaignTotals` costs: the listing, then one stats read per
31
+ * campaign, or one for all of them where the vendor reports every campaign
32
+ * in one call (and one each for the campaigns that report leaves out).
33
+ */
34
+ export declare const campaignTotalsCost: (input: {
35
+ readonly max_campaigns: number;
36
+ readonly statuses: readonly string[];
37
+ }, price: Price) => number;
28
38
  export declare const listFields: (costPerCampaign: string) => {
29
39
  max_campaigns: z.ZodDefault<z.ZodNumber>;
30
40
  statuses: z.ZodDefault<z.ZodArray<z.ZodEnum<{
@@ -36,13 +46,11 @@ export declare const listFields: (costPerCampaign: string) => {
36
46
  unknown: "unknown";
37
47
  }>>>;
38
48
  };
39
- export declare const rangeFields: {
40
- from: z.ZodDefault<z.ZodNullable<z.ZodISODate>>;
41
- to: z.ZodDefault<z.ZodNullable<z.ZodISODate>>;
42
- };
43
49
  export interface CampaignLabel {
44
50
  /** The campaign's ref. */
45
51
  readonly campaign: string;
52
+ readonly campaignName: string;
53
+ /** @deprecated Use `campaignName`. Removed in 0.6.0. */
46
54
  readonly name: string;
47
55
  readonly status: CampaignStatus;
48
56
  readonly channel: "email" | "linkedin";
@@ -68,17 +76,34 @@ export interface Measured {
68
76
  readonly high: number | null;
69
77
  }
70
78
  export declare const measure: (count: number | null, of: number | null) => Measured;
79
+ /** What a reply rate divides by: leads contacted or messages sent. */
80
+ export type ReplyBasis = "contacted" | "sent";
81
+ /** What a rate's replies are divided by. */
82
+ export type Base = (counts: Totals) => number | null;
83
+ /** The base of one basis: `baseIn("sent")` divides by messages sent. */
84
+ export declare const baseIn: (basis: ReplyBasis) => Base;
71
85
  /** What a per-lead rate divides by: leads contacted, or messages sent when the vendor does not count leads. */
72
- export declare const perLeadBase: (counts: Totals) => number | null;
86
+ export declare const perLeadBasis: (counts: Totals) => ReplyBasis;
87
+ export declare const perLeadBase: Base;
88
+ /**
89
+ * What two periods divide replies by, the same for both: messages sent when
90
+ * both report them, since replies in a week answer messages sent that week
91
+ * to leads first contacted weeks before, so a week's leads contacted can be
92
+ * far fewer than its replies. Otherwise leads contacted for both, so the
93
+ * two rates are never over different bases.
94
+ */
95
+ export declare const periodBasis: (current: Totals, previous: Totals) => ReplyBasis;
96
+ /** The rate's name, to start a sentence: "Replies per message sent". */
97
+ export declare const RATE_WORDS: Readonly<Record<ReplyBasis, string>>;
73
98
  export interface Rates {
74
- /** Replies divided by leads contacted (or messages sent when contacted is unknown). */
99
+ /** Replies divided by the base: leads contacted (or messages sent when contacted is unknown) unless the caller passes another. */
75
100
  readonly replyRate: Measured;
76
101
  /** Positive replies on the same base as the reply rate. */
77
102
  readonly positiveRate: Measured;
78
103
  /** Bounces divided by messages sent. */
79
104
  readonly bounceRate: Measured;
80
105
  }
81
- export declare const ratesOf: (counts: Totals) => Rates;
106
+ export declare const ratesOf: (counts: Totals, base?: Base) => Rates;
82
107
  /** How many of the rows added up are behind a rate. */
83
108
  export interface RateCoverage {
84
109
  /** Rows that report both the rate's count and what it divides by. */
@@ -103,33 +128,23 @@ export interface RatesAcross {
103
128
  /** Names a rate that leaves rows out, or nothing when every row is in it. */
104
129
  export declare const partialRate: (name: string, across: RateCoverage) => string[];
105
130
  /** The three rates over several rows of counts, each over the rows that report it. */
106
- export declare const ratesAcross: (rows: readonly Totals[]) => RatesAcross;
131
+ export declare const ratesAcross: (rows: readonly Totals[], base?: Base) => RatesAcross;
107
132
  /** The note for rates that leave rows out. `where` names the group, for example `Tag saas`. */
108
133
  export declare const partialNote: (where: string, partial: readonly string[], rows?: string) => string;
109
134
  /** How much a campaign sent: messages, or leads contacted when messages are not reported. */
110
135
  export declare const volumeOf: (counts: Totals) => number | null;
111
- /** `0.0525` as `5.3%`. */
112
- export declare const percent: (value: number | null) => string;
113
136
  /** Largest first, with unknown values last. */
114
137
  export declare const descending: (left: number | null, right: number | null) => number;
115
- export interface Capped<Item> {
116
- readonly items: Item[];
117
- /** `false` when more records exist than the cap allowed. */
118
- readonly complete: boolean;
119
- }
120
- /** Reads a listing up to `max` records, and says whether `max` cut it short. */
121
- export declare const readUpTo: <Item>(context: InsightContext, list: (max: number) => ListAll<Item>, max: number) => Promise<Capped<Item>>;
122
- /**
123
- * The campaigns in the given states, up to `max`. Asks the vendor per state
124
- * when it can filter, and filters after reading when it cannot.
125
- */
126
- export declare const readCampaigns: (context: InsightContext, statuses: readonly CampaignStatus[], max: number) => Promise<Campaign[]>;
127
138
  /** One campaign's counts over a range, added up. Every count is `null` when the vendor reports nothing. */
128
139
  export declare const readTotals: (context: InsightContext, campaign: string, range: OpenRange) => Promise<MetricCounts>;
129
140
  export interface CampaignTotals {
130
141
  readonly campaign: Campaign;
131
142
  readonly counts: MetricCounts;
132
143
  }
144
+ export interface EveryCampaignTotals {
145
+ readonly entries: CampaignTotals[];
146
+ readonly read: CampaignsRead;
147
+ }
133
148
  export interface ListInput extends OpenRange {
134
149
  readonly max_campaigns: number;
135
150
  readonly statuses: readonly CampaignStatus[];
@@ -141,7 +156,7 @@ export interface ListInput extends OpenRange {
141
156
  * one-call report leaves out is read on its own, so it is never shown as
142
157
  * having no counts when it has some.
143
158
  */
144
- export declare const readCampaignTotals: (context: InsightContext, input: ListInput) => Promise<CampaignTotals[]>;
159
+ export declare const readCampaignTotals: (context: InsightContext, input: ListInput) => Promise<EveryCampaignTotals>;
145
160
  export interface DayCounts {
146
161
  /** `YYYY-MM-DD`. */
147
162
  readonly date: string;
@@ -1,3 +1,4 @@
1
+ import type { CampaignsRead } from "../capped.ts";
1
2
  import type { OpenRange, Rates, Totals } from "./shared.ts";
2
3
  /**
3
4
  * A tag's counts are every campaign's added up. Each rate counts only the
@@ -9,7 +10,7 @@ export interface TagGroup extends Totals, Rates {
9
10
  readonly tag: string | null;
10
11
  readonly campaigns: number;
11
12
  }
12
- export interface TagRollup {
13
+ export interface TagRollup extends CampaignsRead {
13
14
  readonly period: OpenRange;
14
15
  /** Campaigns read. One with two tags counts in both of its tags. */
15
16
  readonly campaigns: number;
@@ -10,6 +10,11 @@ export interface AccountRecord {
10
10
  readonly replies: number | null;
11
11
  readonly lastContactedAt: string | null;
12
12
  readonly lastRepliedAt: string | null;
13
+ /**
14
+ * `true` when the vendor labels the record out-of-office or bounced: its
15
+ * replies were automatic, so they do not count as the person replying.
16
+ */
17
+ readonly autoReplied: boolean;
13
18
  }
14
19
  export interface AccountPerson {
15
20
  readonly email: string;
@@ -18,13 +23,16 @@ export interface AccountPerson {
18
23
  readonly company: string | null;
19
24
  /** The campaigns the person is in, as refs. */
20
25
  readonly campaigns: readonly string[];
26
+ /** `true` when a record shows a reply that was not automatic. */
21
27
  readonly replied: boolean;
22
28
  /** `true` when one of their labels is a positive one. `null` when they carry no label. */
23
29
  readonly interested: boolean | null;
24
30
  /** Added up over their records. `null` when the vendor reports none. */
25
31
  readonly opens: number | null;
26
32
  readonly clicks: number | null;
33
+ /** Replies on records that are not `autoReplied`. */
27
34
  readonly replies: number | null;
35
+ /** The last reply on a record that is not `autoReplied`. */
28
36
  readonly lastRepliedAt: string | null;
29
37
  /** One entry per campaign the person is in. */
30
38
  readonly records: readonly AccountRecord[];
@@ -43,6 +51,11 @@ export interface AccountSummary {
43
51
  readonly leadsRead: number;
44
52
  /** Leads with no email address, which a domain cannot match. */
45
53
  readonly leadsWithoutEmail: number;
54
+ /**
55
+ * `true` when `max_leads` or `max_campaigns` stopped the read with more
56
+ * leads left, so people at the company may be missing.
57
+ */
58
+ readonly moreLeadsExist: boolean;
46
59
  };
47
60
  /** The most recent reply with a known time. `null` when no reply has one. */
48
61
  readonly lastReply: {
@@ -2,7 +2,13 @@ export interface DroppedReply {
2
2
  /** The oldest reply in the conversation that got no answer. */
3
3
  readonly reply: string;
4
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;
5
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;
6
12
  readonly channel: "email" | "linkedin";
7
13
  readonly provider: string;
8
14
  readonly category: string;
@@ -32,6 +38,8 @@ export interface DroppedReplies {
32
38
  readonly tooRecent: number;
33
39
  /** Could not be checked: no thread or lead to read, or no time on the reply. Not counted as dropped. */
34
40
  readonly unchecked: number;
41
+ /** `true` when `max_replies` stopped the read with more replies left, so dropped ones may be missing. */
42
+ readonly moreRepliesExist: boolean;
35
43
  };
36
44
  readonly since: string;
37
45
  readonly olderThanHours: number;
@@ -10,9 +10,15 @@ export interface FoundPerson {
10
10
  /** One record per campaign the person is in. */
11
11
  readonly records: readonly Lead[];
12
12
  }
13
+ /** A lead ref, as the other people insights return, rather than an identifier. */
14
+ export declare const isLeadRef: (identifier: string) => boolean;
13
15
  /**
14
16
  * Asks the vendor for the person by each identifier. A record that carries a
15
17
  * second identifier is looked up under that one too, so an email address can
16
- * lead to a LinkedIn record. Needs `leads.lookup`.
18
+ * lead to a LinkedIn record. A lead ref is read first (`leads.get`) for its
19
+ * identifiers. Needs `leads.lookup`. While redact masks one kind of
20
+ * identifier the person is looked up by the other, and records found only
21
+ * under the masked one are missed, which the answer says. Under a hashing
22
+ * redact the identifier given is hashed the same way to match the records.
17
23
  */
18
24
  export declare const findPerson: (context: InsightContext, identifier: string, maxRecords: number) => Promise<FoundPerson>;
@@ -26,7 +26,11 @@ export interface HotLead {
26
26
  readonly reason: string;
27
27
  }
28
28
  export interface HotLeads {
29
- /** Highest score first, then most recent reply. Only leads that scored above 0. */
29
+ /**
30
+ * Highest score first, then most recent reply: the leads that scored above
31
+ * 0, then, while `limit` leaves room, the leads labelled negative, which
32
+ * score 0.
33
+ */
30
34
  readonly leads: readonly HotLead[];
31
35
  readonly totals: {
32
36
  readonly leadsRead: number;
@@ -38,6 +42,17 @@ export interface HotLeads {
38
42
  readonly withoutData: number;
39
43
  /** Unsubscribed or bounced leads, left out. */
40
44
  readonly excluded: number;
45
+ /**
46
+ * `true` when `max_leads` stopped the lead listing with more leads left:
47
+ * those were not scored, except the ones found through recent replies.
48
+ */
49
+ readonly moreLeadsExist: boolean;
50
+ /** Leads past the cap, read because they replied within `recency_days`. Counted in `leadsRead`. */
51
+ readonly fromReplies: number;
52
+ /** Leads the vendor labels out-of-office or bounced, whose replies earned no points. */
53
+ readonly autoReplied: number;
54
+ /** Leads the vendor labels negative, such as not interested or wrong person, which earn no points at all and are listed after every lead with a score above 0. A label in `positive_labels` is not counted here. */
55
+ readonly negative: number;
41
56
  };
42
57
  }
43
58
  export declare const hotLeads: import("../define.ts").InsightDefinition<"hotLeads", {
@@ -9,8 +9,14 @@ export interface PersonCampaign {
9
9
  /** The vendor's own label, for example `Interested`. */
10
10
  readonly interest: string | null;
11
11
  readonly messagesSent: number;
12
+ /** Replies from the person. 0 when the vendor labels the lead out-of-office or bounced. */
12
13
  readonly replies: number;
13
14
  readonly replied: boolean;
15
+ /**
16
+ * `true` when the vendor labels the lead out-of-office or bounced: its
17
+ * replies were automatic, so they are not counted as the person replying.
18
+ */
19
+ readonly autoReplied: boolean;
14
20
  /** Steps the person replied to, counted from 0. Empty when the vendor does not tie a reply to a step. */
15
21
  readonly repliedSteps: readonly number[];
16
22
  /** The last step sent, counted from 0. */
@@ -1,9 +1,16 @@
1
1
  import { z } from "zod";
2
- import type { Campaign, CampaignStatus, Lead } from "../../internal/entities.ts";
3
- import type { ListAll } from "../../internal/outbound/api.ts";
2
+ import type { Campaign, CampaignStatus, Lead, ReplyCategory } from "../../internal/entities.ts";
3
+ import type { BulkResult, ListAll } from "../../internal/outbound/api.ts";
4
+ import type { Capped } from "../capped.ts";
4
5
  import type { InsightContext } from "../define.ts";
5
- /** Reads at most `max` records, and says so in a note when more exist. */
6
- export declare const readCapped: <Item>(context: InsightContext, open: (max: number) => ListAll<Item>, max: number, what: string) => Promise<Item[]>;
6
+ /** Reads at most `max` records, and says so in a note naming `input` when more exist. */
7
+ export declare const readCappedFlag: <Item>(context: InsightContext, open: (max: number) => ListAll<Item>, max: number, what: string, input: string) => Promise<Capped<Item>>;
8
+ /**
9
+ * Reads records by ref in one batch and maps them by ref. A record that
10
+ * cannot be read is left out with a note ending in `effect`. Every record of
11
+ * a batch carries the whole batch's cost, so the cost is counted once.
12
+ */
13
+ export declare const readByRef: <Item>(context: InsightContext, refs: readonly string[], read: (refs: readonly string[]) => Promise<BulkResult<Item>>, what: readonly [one: string, many: string], effect: string) => Promise<Map<string, Item>>;
7
14
  export declare const statusesField: z.ZodDefault<z.ZodArray<z.ZodEnum<{
8
15
  active: "active";
9
16
  archived: "archived";
@@ -12,13 +19,10 @@ export declare const statusesField: z.ZodDefault<z.ZodArray<z.ZodEnum<{
12
19
  paused: "paused";
13
20
  unknown: "unknown";
14
21
  }>>>;
15
- /**
16
- * Campaigns in the given statuses, up to `max`. Without a status filter on
17
- * the adapter the first `max` campaigns are read and filtered here.
18
- */
22
+ /** Campaigns in the given statuses, up to `max_campaigns`. */
19
23
  export declare const campaignsIn: (context: InsightContext, statuses: readonly CampaignStatus[], max: number) => Promise<Campaign[]>;
20
- /** The leads of one campaign, up to `max`. Needs `leads.byCampaign`. */
21
- export declare const leadsOf: (context: InsightContext, campaign: string, max: number) => Promise<Lead[]>;
24
+ /** The leads of one campaign, up to `max`, the value of the input named. Needs `leads.byCampaign`. */
25
+ export declare const leadsOf: (context: InsightContext, campaign: string, max: number, input: string) => Promise<Lead[]>;
22
26
  /** First and last name joined, or `null` when the vendor has neither. */
23
27
  export declare const nameOf: (lead: Lead) => string | null;
24
28
  /** The part of an email address after the `@`, or `null`. */
@@ -29,6 +33,18 @@ export declare const positiveLabelsField: z.ZodDefault<z.ZodArray<z.ZodString>>;
29
33
  export declare const isPositive: (label: string | null, labels: readonly string[]) => boolean | null;
30
34
  /** Whether the vendor says the lead replied: a status, a count or a time. */
31
35
  export declare const hasReplied: (lead: Lead) => boolean;
36
+ /**
37
+ * The vendor labels the lead out-of-office or bounced: its reply was an
38
+ * automatic one. A vendor's per-lead reply count may include such replies,
39
+ * so they are not counted as the person replying.
40
+ */
41
+ export declare const isAutoReplied: (lead: Lead) => boolean;
42
+ /** Whether the lead replied, not counting a reply that was automatic. */
43
+ export declare const hasHumanReply: (lead: Lead) => boolean;
44
+ /** Interest categories that say the person does not want to hear more. */
45
+ export declare const NEGATIVE_CATEGORIES: ReadonlySet<ReplyCategory>;
46
+ /** The vendor labels the lead negative: not interested, wrong person, unsubscribed, do not contact. */
47
+ export declare const isNegative: (lead: Lead) => boolean;
32
48
  /**
33
49
  * Says which records lack open, click and reply counts, and only when some
34
50
  * do. One tool: the adapter's own declaration decides. A combined instance
@@ -36,8 +36,17 @@ export interface SuppressionCheck {
36
36
  readonly campaignsRead: number;
37
37
  readonly leadsRead: number;
38
38
  readonly blockEntriesRead: number;
39
- /** Entries of a kind that cannot be matched to a lead: a company name or the vendor's `other`. */
40
- readonly blockEntriesNotChecked: number;
39
+ /**
40
+ * Entries that were not matched to leads: those of a kind that cannot be
41
+ * (a company name or the vendor's `other`). `null` when
42
+ * `moreBlockEntriesExist`, since the entries left unread were not
43
+ * checked either and their number is unknown.
44
+ */
45
+ readonly blockEntriesNotChecked: number | null;
46
+ /** `true` when `max_block_entries` stopped the read with more entries left: a lead on those was not found. */
47
+ readonly moreBlockEntriesExist: boolean;
48
+ /** `true` when `max_leads_per_campaign` stopped a campaign's read with more leads left. */
49
+ readonly moreLeadsExist: boolean;
41
50
  };
42
51
  }
43
52
  export declare const suppressionCheck: import("../define.ts").InsightDefinition<"suppressionCheck", {