outbound-sdk 0.6.0 → 0.7.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 (118) hide show
  1. package/dist/alerts/check-schema.d.ts +1 -1
  2. package/dist/alerts/index.js +6 -6
  3. package/dist/audit/index.js +2 -2
  4. package/dist/benchmarks/index.js +4 -4
  5. package/dist/budget/index.js +2 -2
  6. package/dist/cards/index.js +54 -44
  7. package/dist/chunks/{chunk-BLCJHP5H.js → chunk-45TXPJW7.js} +1 -0
  8. package/dist/chunks/chunk-4AVYRVN5.js +239 -0
  9. package/dist/chunks/{chunk-YYCT3NGV.js → chunk-65YAGEWZ.js} +24 -7
  10. package/dist/chunks/{chunk-W22SDX6S.js → chunk-7I3EPR23.js} +3 -3
  11. package/dist/chunks/{chunk-MGR6HREO.js → chunk-BNDHEDHD.js} +2 -2
  12. package/dist/chunks/chunk-DNPNTD5W.js +81 -0
  13. package/dist/chunks/{chunk-53DCVFUB.js → chunk-FALWG5U3.js} +1 -0
  14. package/dist/chunks/{chunk-OLPMBRXM.js → chunk-GL7BABF2.js} +2 -2
  15. package/dist/chunks/{chunk-ZOAG2C6V.js → chunk-HIAK2GCI.js} +9 -2
  16. package/dist/chunks/{chunk-SXGCKCAR.js → chunk-I7DXXGNZ.js} +40 -9
  17. package/dist/chunks/{chunk-BK5SLY32.js → chunk-JRL3QRBS.js} +264 -76
  18. package/dist/chunks/{chunk-PHNQ3WC2.js → chunk-KTYTE2BU.js} +4 -3
  19. package/dist/chunks/{chunk-JWGSB7PT.js → chunk-LD6F46UT.js} +2 -2
  20. package/dist/chunks/{chunk-2D42TQFU.js → chunk-LVZGIKNF.js} +2 -2
  21. package/dist/chunks/{chunk-PQSTQKRD.js → chunk-M2VXGLLZ.js} +35 -2
  22. package/dist/chunks/{chunk-UWUPUMM2.js → chunk-MW4C6LTN.js} +2 -2
  23. package/dist/chunks/chunk-OK3GAZMT.js +51 -0
  24. package/dist/chunks/{chunk-BOWXGMN3.js → chunk-POBAY3TI.js} +80 -4
  25. package/dist/chunks/{chunk-J7DDZ4C2.js → chunk-QFC4ZHD3.js} +1 -1
  26. package/dist/chunks/{chunk-GFDNRWR3.js → chunk-UFQ4WMLU.js} +1 -1
  27. package/dist/chunks/{chunk-TFICTGM2.js → chunk-Y7KECJAV.js} +1 -1
  28. package/dist/chunks/{chunk-QAKJ76HB.js → chunk-YW6FFVSZ.js} +1 -1
  29. package/dist/chunks/{chunk-3JOC5DGD.js → chunk-ZJCVLBAE.js} +424 -117
  30. package/dist/cli/bin.js +14 -14
  31. package/dist/cli/by-name.d.ts +28 -0
  32. package/dist/cli/commands.d.ts +2 -1
  33. package/dist/cli/config.d.ts +3 -2
  34. package/dist/cli/envelope.d.ts +50 -0
  35. package/dist/cli/index.d.ts +3 -0
  36. package/dist/cli/index.js +13 -13
  37. package/dist/cli/listing.d.ts +13 -0
  38. package/dist/cli/native.d.ts +4 -0
  39. package/dist/cli/options.d.ts +88 -0
  40. package/dist/cli/output.d.ts +13 -1
  41. package/dist/cli/suggest.d.ts +10 -0
  42. package/dist/clients/index.js +6 -6
  43. package/dist/combine/index.js +7 -7
  44. package/dist/emailbison/capabilities.d.ts +1 -0
  45. package/dist/emailbison/index.js +38 -14
  46. package/dist/emailbison/map-stats.d.ts +10 -0
  47. package/dist/exporter/index.js +2 -2
  48. package/dist/failover/index.js +2 -2
  49. package/dist/fixtures/index.js +4 -4
  50. package/dist/heyreach/capabilities.d.ts +3 -0
  51. package/dist/heyreach/index.js +34 -12
  52. package/dist/heyreach/map-account.d.ts +2 -2
  53. package/dist/identity/index.js +2 -2
  54. package/dist/index.js +9 -7
  55. package/dist/insights/copy/audit-samples.d.ts +24 -0
  56. package/dist/insights/copy/audit-variant.d.ts +34 -0
  57. package/dist/insights/copy/copy-audit.d.ts +26 -12
  58. package/dist/insights/copy/copy-preview.d.ts +16 -3
  59. package/dist/insights/copy/index.d.ts +6 -0
  60. package/dist/insights/copy/reply-timing.d.ts +4 -0
  61. package/dist/insights/copy/shared.d.ts +4 -1
  62. package/dist/insights/copy/step-funnel.d.ts +20 -6
  63. package/dist/insights/copy/variant-test.d.ts +2 -3
  64. package/dist/insights/index.js +1138 -589
  65. package/dist/insights/inputs.generated.d.ts +47 -11
  66. package/dist/insights/ops/campaign-diagnosis.d.ts +2 -0
  67. package/dist/insights/ops/diagnosis-checks.d.ts +20 -1
  68. package/dist/insights/ops/index.d.ts +2 -0
  69. package/dist/insights/ops/pipeline-forecast.d.ts +17 -6
  70. package/dist/insights/people/account-summary.d.ts +14 -1
  71. package/dist/insights/people/auto-replies.d.ts +14 -0
  72. package/dist/insights/people/dropped-replies.d.ts +1 -1
  73. package/dist/insights/people/hot-leads.d.ts +5 -1
  74. package/dist/insights/people/index.d.ts +4 -0
  75. package/dist/insights/people/lead-collisions.d.ts +11 -2
  76. package/dist/insights/people/person-summary.d.ts +19 -3
  77. package/dist/insights/people/personalization-gaps.d.ts +14 -8
  78. package/dist/insights/people/suppression-check.d.ts +9 -0
  79. package/dist/insights/registry.d.ts +12 -0
  80. package/dist/insights/step.d.ts +15 -0
  81. package/dist/insights/variables.d.ts +2 -0
  82. package/dist/instantly/capabilities.d.ts +4 -0
  83. package/dist/instantly/index.js +263 -53
  84. package/dist/instantly/map-stats.d.ts +4 -0
  85. package/dist/instantly/stats-tracking.d.ts +19 -0
  86. package/dist/instantly/thread.d.ts +9 -0
  87. package/dist/internal/adapter.d.ts +5 -0
  88. package/dist/internal/auto-reply.d.ts +20 -0
  89. package/dist/internal/capabilities.d.ts +2 -0
  90. package/dist/internal/entities-account.d.ts +1 -0
  91. package/dist/internal/entities.d.ts +79 -2
  92. package/dist/internal/fields.d.ts +37 -1
  93. package/dist/internal/metrics.d.ts +23 -1
  94. package/dist/internal/outbound/api.d.ts +2 -0
  95. package/dist/internal/records.d.ts +2 -2
  96. package/dist/internal/reply-people.d.ts +37 -0
  97. package/dist/internal/runway.d.ts +42 -0
  98. package/dist/internal/sender-screen.d.ts +9 -0
  99. package/dist/internal/tracking.d.ts +33 -0
  100. package/dist/loader/index.js +4 -4
  101. package/dist/memory/data.d.ts +2 -1
  102. package/dist/memory/index.js +23 -12
  103. package/dist/redact/index.js +3 -3
  104. package/dist/smartlead/capabilities.d.ts +4 -0
  105. package/dist/smartlead/index.js +152 -38
  106. package/dist/smartlead/map-account.d.ts +3 -0
  107. package/dist/smartlead/stats-tracking.d.ts +22 -0
  108. package/dist/sync/index.js +2 -2
  109. package/dist/tools/ai-sdk.js +8 -7
  110. package/dist/tools/by-name.d.ts +18 -0
  111. package/dist/tools/campaign-tools.d.ts +6 -2
  112. package/dist/tools/claude-agent.js +8 -7
  113. package/dist/tools/index.js +9 -8
  114. package/dist/tools/shared.d.ts +7 -0
  115. package/dist/tracing/index.js +2 -2
  116. package/dist/webhooks/index.js +12 -11
  117. package/package.json +1 -1
  118. package/dist/chunks/chunk-HWHI4LFY.js +0 -102
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  EVENT_TYPES,
3
3
  heyreachEvents
4
- } from "../chunks/chunk-JWGSB7PT.js";
4
+ } from "../chunks/chunk-LD6F46UT.js";
5
5
  import {
6
6
  mapPage,
7
7
  withLeadFields,
@@ -13,10 +13,10 @@ import {
13
13
  listIn,
14
14
  toVariant,
15
15
  variantKey
16
- } from "../chunks/chunk-MGR6HREO.js";
16
+ } from "../chunks/chunk-BNDHEDHD.js";
17
17
  import {
18
18
  normalizeBody
19
- } from "../chunks/chunk-53DCVFUB.js";
19
+ } from "../chunks/chunk-FALWG5U3.js";
20
20
  import {
21
21
  defineNative
22
22
  } from "../chunks/chunk-NAKXLBA6.js";
@@ -25,16 +25,16 @@ import {
25
25
  recordBase,
26
26
  refTo,
27
27
  refsTo
28
- } from "../chunks/chunk-2D42TQFU.js";
29
- import "../chunks/chunk-BOWXGMN3.js";
28
+ } from "../chunks/chunk-LVZGIKNF.js";
29
+ import "../chunks/chunk-POBAY3TI.js";
30
30
  import {
31
31
  emptyCounts,
32
32
  metricRow
33
- } from "../chunks/chunk-PQSTQKRD.js";
33
+ } from "../chunks/chunk-M2VXGLLZ.js";
34
34
  import "../chunks/chunk-QGRZDTX4.js";
35
35
  import {
36
36
  assertWorkspaceId
37
- } from "../chunks/chunk-QAKJ76HB.js";
37
+ } from "../chunks/chunk-YW6FFVSZ.js";
38
38
  import {
39
39
  profileSlug
40
40
  } from "../chunks/chunk-NAWZ73QS.js";
@@ -44,13 +44,13 @@ import {
44
44
  import {
45
45
  readEnv,
46
46
  requireCredential
47
- } from "../chunks/chunk-GFDNRWR3.js";
47
+ } from "../chunks/chunk-UFQ4WMLU.js";
48
48
  import {
49
49
  OutboundError,
50
50
  isHttpFailure,
51
51
  makeErrorMapper,
52
52
  requireObject
53
- } from "../chunks/chunk-J7DDZ4C2.js";
53
+ } from "../chunks/chunk-QFC4ZHD3.js";
54
54
  import {
55
55
  count,
56
56
  emailAddress,
@@ -64,7 +64,7 @@ import {
64
64
  objects,
65
65
  text,
66
66
  timestamp
67
- } from "../chunks/chunk-BLCJHP5H.js";
67
+ } from "../chunks/chunk-45TXPJW7.js";
68
68
 
69
69
  // src/heyreach/map-account.ts
70
70
  var toCampaignProgress = (identity, campaignId, raw) => {
@@ -79,6 +79,7 @@ var toCampaignProgress = (identity, campaignId, raw) => {
79
79
  inProgress: count(field(stats, "totalUsersInProgress")),
80
80
  leads: count(field(stats, "totalUsers")),
81
81
  notStarted: count(field(stats, "totalUsersPending")),
82
+ skipped: count(field(stats, "totalUsersExcluded")),
82
83
  stopped: count(field(stats, "totalUsersManuallyStopped"))
83
84
  };
84
85
  };
@@ -211,6 +212,7 @@ var toSender = (identity, raw) => ({
211
212
  warmup: null
212
213
  });
213
214
  var LEAD_PROGRESS = /* @__PURE__ */ new Map([
215
+ ["Excluded", "skipped"],
214
216
  ["Finished", "completed"],
215
217
  ["InSequence", "active"],
216
218
  ["Paused", "paused"],
@@ -272,6 +274,7 @@ var profileFields = (identity, profile, raw) => ({
272
274
  location: text(field(profile, "location")),
273
275
  // HeyReach profiles carry no phone number and no company website.
274
276
  phone: null,
277
+ recipientMailProvider: null,
275
278
  title: text(field(profile, "position")),
276
279
  website: null
277
280
  });
@@ -422,20 +425,35 @@ var fields = {
422
425
  bounced: false,
423
426
  engagement: false,
424
427
  phone: false,
428
+ recipientMailProvider: false,
425
429
  unsubscribed: false,
426
430
  website: false
427
431
  },
428
- message: { bodyHtml: false, stepIndex: false, variantKey: false },
432
+ message: {
433
+ bodyHtml: false,
434
+ isAuto: false,
435
+ isAutoSource: false,
436
+ stepIndex: false,
437
+ variantKey: false
438
+ },
429
439
  metricRow: {
430
440
  bounced: false,
431
441
  clicked: false,
432
442
  clickedTotal: false,
443
+ completed: false,
433
444
  contentHash: false,
434
445
  delivered: false,
446
+ leads: false,
435
447
  opened: false,
436
448
  openedTotal: false,
449
+ opportunities: false,
450
+ opportunityValue: false,
451
+ repliedAutoTotal: false,
452
+ repliedTotal: false,
437
453
  repliedAuto: false,
438
454
  stepIndex: false,
455
+ // LinkedIn has no open or click tracking.
456
+ tracking: false,
439
457
  unsubscribed: false,
440
458
  variantKey: false
441
459
  },
@@ -447,6 +465,8 @@ var fields = {
447
465
  category: "derived",
448
466
  categorySource: "derived",
449
467
  isAuto: false,
468
+ isAutoSource: false,
469
+ leftCompany: false,
450
470
  stepIndex: false,
451
471
  variantKey: false
452
472
  },
@@ -486,6 +506,8 @@ var costs = {
486
506
  "blocklist.list": { pageSize: PAGE_SIZE, perPage: 1 },
487
507
  "campaigns.get": { perPage: 1 },
488
508
  "campaigns.list": { pageSize: PAGE_SIZE, perPage: 1 },
509
+ // The campaign object, which carries its lead counts.
510
+ "campaigns.progress": { perPage: 1 },
489
511
  // The profile and its tags are two requests.
490
512
  "leads.get": { perPage: 2 },
491
513
  // A campaign's leads. A saved list's leads come up to 1000 a page. Without
@@ -522,7 +544,7 @@ var caveats = [
522
544
  "A sender's dailyLimit is null: accountLimits holds several limit pairs and the docs do not say which are daily or what Limit and Max mean. They stay in raw.",
523
545
  "A lead's id is its LinkedIn profile URL, the only key GetLead accepts and the only one present in every lead shape. The docs do not say the URL has one canonical form.",
524
546
  "A lead is looked up by profile URL with two requests (GetCampaignsForLead and GetLead) and returned once per campaign it is in. A lead's id is its profile URL in every campaign, so a person's records share one ref and differ by campaignRef. The timeline is the lead's whole conversation history, the same on each of its records.",
525
- "A looked-up lead's status follows leadStatus and never says replied, because GetCampaignsForLead reports no message status; Excluded and PendingOrExcludedToBeCalculated are unknown. createdAt is null (the creationTime beside a campaign is the campaign's), tags are empty and interest is null. A lookup cannot be combined with a saved list or a date range.",
547
+ "A looked-up lead's status follows leadStatus and never says replied, because GetCampaignsForLead reports no message status; Excluded (kept out by an exclusion filter or exclusion list) is skipped, and PendingOrExcludedToBeCalculated, not decided yet, is unknown. createdAt is null (the creationTime beside a campaign is the campaign's), tags are empty and interest is null. A lookup cannot be combined with a saved list or a date range.",
526
548
  "HeyReach matches a profile URL whatever its scheme, www prefix, trailing slash or query, but by exact case: seen live, a slug sent in upper case is not found. The lookup sends the slug lowercased, so a profile HeyReach stores with upper-case letters would not be found. A slug with non-ASCII letters is sent percent-encoded; how HeyReach stores one is not known.",
527
549
  "No HeyReach read returns a profile for an email address. An email lookup asks for the campaigns (which names the person), then one saved list the address is in, searches that list for the name (5 rows at most) and reads each match's profile until one carries the address: four requests in the usual case. An address that is in no saved list, or whose profile is not among those rows, gives an empty page although HeyReach knows it. The record's email is the address asked for, which the profile may hold as its enriched or custom address.",
528
550
  "Lookup was checked against one live lead in one campaign. A person in several campaigns (and so a second page of campaigns) and a known person in no campaign were not seen; an empty campaign answer and a 404 from GetCampaignsForLead are both read as no campaigns.",
@@ -3,8 +3,8 @@ import type { JsonObject } from "../internal/json.ts";
3
3
  import type { Identity } from "../internal/record.ts";
4
4
  /**
5
5
  * `GET /campaign/GetById`: `progressStats` counts the campaign's leads by how
6
- * far they got. `totalUsersExcluded` (leads kept out by an exclusion rule) has
7
- * no equivalent and stays in raw.
6
+ * far they got. `totalUsersExcluded` counts the leads an exclusion filter or
7
+ * exclusion list kept out, which are skipped.
8
8
  */
9
9
  export declare const toCampaignProgress: (identity: Identity, campaignId: string, raw: JsonObject) => CampaignProgress;
10
10
  /** `POST /list/GetAll`: `listType` is `USER_LIST` or `COMPANY_LIST`. */
@@ -6,8 +6,8 @@ import {
6
6
  } from "../chunks/chunk-NAWZ73QS.js";
7
7
  import {
8
8
  OutboundError
9
- } from "../chunks/chunk-J7DDZ4C2.js";
10
- import "../chunks/chunk-BLCJHP5H.js";
9
+ } from "../chunks/chunk-QFC4ZHD3.js";
10
+ import "../chunks/chunk-45TXPJW7.js";
11
11
 
12
12
  // src/identity/keys.ts
13
13
  var emailKey = (email) => {
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Outbound,
4
4
  createOutbound,
5
5
  fullJitterBackoff
6
- } from "./chunks/chunk-YYCT3NGV.js";
6
+ } from "./chunks/chunk-65YAGEWZ.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-ZOAG2C6V.js";
25
+ } from "./chunks/chunk-HIAK2GCI.js";
26
26
  import "./chunks/chunk-PTZO4QXR.js";
27
27
  import {
28
28
  defineNative
@@ -41,18 +41,19 @@ import {
41
41
  metricRowSchema,
42
42
  metricScopeSchema,
43
43
  outboundEventSchema,
44
+ recipientMailProviderSchema,
44
45
  replySchema,
45
46
  senderSchema,
46
47
  senderStatusSchema,
47
48
  sequenceSchema,
48
49
  workspaceSchema
49
- } from "./chunks/chunk-BOWXGMN3.js";
50
+ } from "./chunks/chunk-POBAY3TI.js";
50
51
  import {
51
52
  METRIC_DEFINITIONS,
52
53
  computeRates,
53
54
  emptyCounts,
54
55
  sumCounts
55
- } from "./chunks/chunk-PQSTQKRD.js";
56
+ } from "./chunks/chunk-M2VXGLLZ.js";
56
57
  import {
57
58
  SCHEMA_VERSION,
58
59
  campaignStatusSchema,
@@ -61,7 +62,7 @@ import {
61
62
  import {
62
63
  makeRef,
63
64
  parseRef
64
- } from "./chunks/chunk-QAKJ76HB.js";
65
+ } from "./chunks/chunk-YW6FFVSZ.js";
65
66
  import {
66
67
  profileSlug
67
68
  } from "./chunks/chunk-NAWZ73QS.js";
@@ -75,8 +76,8 @@ import {
75
76
  REDACTED_KEY,
76
77
  makeErrorMapper,
77
78
  redactText
78
- } from "./chunks/chunk-J7DDZ4C2.js";
79
- import "./chunks/chunk-BLCJHP5H.js";
79
+ } from "./chunks/chunk-QFC4ZHD3.js";
80
+ import "./chunks/chunk-45TXPJW7.js";
80
81
  export {
81
82
  CAPABILITY_KEYS,
82
83
  DEFAULT_SHARE,
@@ -117,6 +118,7 @@ export {
117
118
  parseRef,
118
119
  placementTestSchema,
119
120
  profileSlug,
121
+ recipientMailProviderSchema,
120
122
  redactText,
121
123
  replyCategorySchema,
122
124
  replySchema,
@@ -0,0 +1,24 @@
1
+ import type { Lead, SequenceStep, SequenceVariant } from "../../internal/entities.ts";
2
+ import type { CopyFinding } from "./audit-variant.ts";
3
+ import type { Limits } from "./copy-checks.ts";
4
+ type Copy = Pick<SequenceVariant, "body" | "subject">;
5
+ /** Whether the variant's subject or body is mostly variables. */
6
+ export declare const writtenPerLead: (variant: Copy) => boolean;
7
+ /** The variable keys in the variants written per lead. */
8
+ export declare const perLeadKeys: (steps: readonly SequenceStep[]) => Set<string>;
9
+ /** The `samples` leads that fill the most of `keys`. */
10
+ export declare const pickSamples: (leads: readonly Lead[], keys: ReadonlySet<string>, samples: number) => Lead[];
11
+ export interface SampleAudit {
12
+ readonly findings: readonly CopyFinding[];
13
+ /** The leads whose rendered copy was audited in at least one variant. */
14
+ readonly leads: readonly string[];
15
+ /** Variants written per lead that no sample lead's values filled. */
16
+ readonly unaudited: number;
17
+ }
18
+ /**
19
+ * Audits each variant written per lead as each lead receives it. A lead
20
+ * whose values leave the copy mostly variables still is skipped for that
21
+ * variant: its gaps are personalization_gaps' to report.
22
+ */
23
+ export declare const auditSamples: (steps: readonly SequenceStep[], leads: readonly Lead[], limits: Limits, isEmail: boolean) => SampleAudit;
24
+ export {};
@@ -0,0 +1,34 @@
1
+ import type { SequenceStep, SequenceVariant } from "../../internal/entities.ts";
2
+ import type { StepPosition } from "../step.ts";
3
+ import type { CheckName, Limits, Severity } from "./copy-checks.ts";
4
+ export interface CopyFinding extends StepPosition {
5
+ readonly variantKey: string;
6
+ readonly action: string;
7
+ readonly check: CheckName;
8
+ readonly severity: Severity;
9
+ readonly finding: string;
10
+ /** The text that triggered the check. */
11
+ readonly text: string;
12
+ /**
13
+ * The lead whose rendered copy triggered it, for copy written per lead in
14
+ * variables. `null` when the finding is in the copy as the campaign stores
15
+ * it. Always set; optional in the type so a finding built by hand still fits.
16
+ */
17
+ readonly lead?: string | null;
18
+ }
19
+ export interface Thread {
20
+ /** The first email step. `null` when the sequence has none. */
21
+ readonly first: number | null;
22
+ /**
23
+ * The subjects the first email step sends under. `null` when they are
24
+ * written per lead and not known, so no follow-up is judged against them.
25
+ */
26
+ readonly subjects: ReadonlySet<string> | null;
27
+ }
28
+ /** Every finding in one variant. `thread` is `null` on a LinkedIn campaign. */
29
+ export declare const auditVariant: (step: SequenceStep, variant: SequenceVariant, limits: Limits, thread: Thread | null, lead: string | null) => CopyFinding[];
30
+ /**
31
+ * The first step and its subjects. `perLead` says whether a variant of it is
32
+ * written per lead; then its subjects are not known from the template.
33
+ */
34
+ export declare const threadOf: (steps: readonly SequenceStep[], perLead: (variant: SequenceVariant) => boolean) => Thread;
@@ -1,15 +1,6 @@
1
+ import type { CopyFinding } from "./audit-variant.ts";
1
2
  import type { CheckName, Severity } from "./copy-checks.ts";
2
- export interface CopyFinding {
3
- /** Counted from 0. */
4
- readonly step: number;
5
- readonly variantKey: string;
6
- readonly action: string;
7
- readonly check: CheckName;
8
- readonly severity: Severity;
9
- readonly finding: string;
10
- /** The text that triggered the check. */
11
- readonly text: string;
12
- }
3
+ export type { CopyFinding } from "./audit-variant.ts";
13
4
  export interface CheckCount {
14
5
  readonly check: CheckName;
15
6
  readonly severity: Severity;
@@ -20,7 +11,12 @@ export interface CopyAudit {
20
11
  /** The campaign's name, from the campaign record the audit reads. */
21
12
  readonly campaignName: string;
22
13
  readonly channel: "email" | "linkedin";
23
- /** `true` when no check found anything in the copy that could be read. */
14
+ /**
15
+ * `true` when no check found anything and every variant was audited.
16
+ * `false` on any finding, and also when copy written per lead could not be
17
+ * audited for every variant: then `variantsNotAudited` is above 0 and a
18
+ * note says why, and no finding does not mean a problem was found.
19
+ */
24
20
  readonly clean: boolean;
25
21
  /** High severity first, then by step and variant. */
26
22
  readonly findings: readonly CopyFinding[];
@@ -35,6 +31,20 @@ export interface CopyAudit {
35
31
  readonly variantsChecked: number;
36
32
  /** Variants whose body the vendor did not return; their body checks were skipped. */
37
33
  readonly variantsWithoutBody: number;
34
+ /**
35
+ * Variants whose subject or body is mostly variables, such as `{{body_1}}`.
36
+ * They are audited as sample leads receive them, not as stored. This and
37
+ * `leadsAudited` are always set; optional in the type so an audit built by
38
+ * hand still fits.
39
+ */
40
+ readonly variantsWrittenPerLead?: number;
41
+ /** The leads whose rendered copy was audited. Empty when no copy is written per lead. */
42
+ readonly leadsAudited?: readonly string[];
43
+ /**
44
+ * Variants written per lead that no sample lead's copy could be rendered
45
+ * for, so they were not audited at all. Above 0 makes `clean` `false`.
46
+ */
47
+ readonly variantsNotAudited?: number;
38
48
  }
39
49
  export declare const copyAudit: import("../define.ts").InsightDefinition<"copyAudit", {
40
50
  campaign: string;
@@ -43,7 +53,9 @@ export declare const copyAudit: import("../define.ts").InsightDefinition<"copyAu
43
53
  max_connection_chars: number;
44
54
  max_exclamations: number;
45
55
  max_links: number;
56
+ max_leads: number;
46
57
  max_subject_chars: number;
58
+ samples: number;
47
59
  spam_words: string[];
48
60
  }, CopyAudit, {
49
61
  campaign: string;
@@ -52,6 +64,8 @@ export declare const copyAudit: import("../define.ts").InsightDefinition<"copyAu
52
64
  max_connection_chars?: number | undefined;
53
65
  max_exclamations?: number | undefined;
54
66
  max_links?: number | undefined;
67
+ max_leads?: number | undefined;
55
68
  max_subject_chars?: number | undefined;
69
+ samples?: number | undefined;
56
70
  spam_words?: string[] | undefined;
57
71
  }>;
@@ -1,3 +1,5 @@
1
+ import type { Lead, Sequence, SequenceVariant } from "../../internal/entities.ts";
2
+ import type { StepPosition } from "../step.ts";
1
3
  export interface CopyText {
2
4
  readonly subject: string | null;
3
5
  readonly body: string | null;
@@ -19,9 +21,7 @@ export interface PreviewVariant {
19
21
  */
20
22
  readonly unfilled: readonly string[];
21
23
  }
22
- export interface PreviewStep {
23
- /** The step, counted from 0. */
24
- readonly step: number;
24
+ export interface PreviewStep extends StepPosition {
25
25
  readonly action: string;
26
26
  readonly delayDays: number | null;
27
27
  readonly variants: readonly PreviewVariant[];
@@ -47,6 +47,19 @@ export interface CopyPreview {
47
47
  readonly unfilled: number;
48
48
  };
49
49
  }
50
+ /** Distinct variable keys across every subject and body. */
51
+ export declare const keysIn: (sequence: Sequence) => Set<string>;
52
+ /** Leads by how many of `keys` they fill, most first; the first read wins a tie. */
53
+ export declare const rankLeads: (leads: readonly Lead[], keys: ReadonlySet<string>) => Lead[];
54
+ export interface RenderedVariant extends CopyText {
55
+ /** Variables left as written, as the copy writes them. */
56
+ readonly unfilled: readonly string[];
57
+ }
58
+ /**
59
+ * One variant's subject and body as `lead` receives them. With no lead, the
60
+ * copy comes back as written and every variable without a fallback is unfilled.
61
+ */
62
+ export declare const renderVariant: (variant: Pick<SequenceVariant, "body" | "subject">, lead: Lead | undefined) => RenderedVariant;
50
63
  export declare const copyPreview: import("../define.ts").InsightDefinition<"copyPreview", {
51
64
  campaign: string;
52
65
  lead: string | null;
@@ -29,7 +29,9 @@ export declare const COPY_INSIGHTS: readonly [import("../define.ts").InsightDefi
29
29
  max_connection_chars: number;
30
30
  max_exclamations: number;
31
31
  max_links: number;
32
+ max_leads: number;
32
33
  max_subject_chars: number;
34
+ samples: number;
33
35
  spam_words: string[];
34
36
  }, import("./copy-audit.ts").CopyAudit, {
35
37
  campaign: string;
@@ -38,7 +40,9 @@ export declare const COPY_INSIGHTS: readonly [import("../define.ts").InsightDefi
38
40
  max_connection_chars?: number | undefined;
39
41
  max_exclamations?: number | undefined;
40
42
  max_links?: number | undefined;
43
+ max_leads?: number | undefined;
41
44
  max_subject_chars?: number | undefined;
45
+ samples?: number | undefined;
42
46
  spam_words?: string[] | undefined;
43
47
  }>, import("../define.ts").InsightDefinition<"copyPreview", {
44
48
  campaign: string;
@@ -58,11 +62,13 @@ export declare const COPY_INSIGHTS: readonly [import("../define.ts").InsightDefi
58
62
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
59
63
  }>, import("../define.ts").InsightDefinition<"replyTiming", {
60
64
  campaign: string | null;
65
+ include_auto: boolean;
61
66
  max_messages: number;
62
67
  since: string | null;
63
68
  timezone_offset_minutes: number;
64
69
  }, import("./reply-timing.ts").ReplyTiming, {
65
70
  campaign?: string | null | undefined;
71
+ include_auto?: boolean | undefined;
66
72
  max_messages?: number | undefined;
67
73
  since?: string | null | undefined;
68
74
  timezone_offset_minutes?: number | undefined;
@@ -55,15 +55,19 @@ export interface ReplyTiming {
55
55
  readonly unpaired: number;
56
56
  /** `unpaired` over `received`. Over 0.25 the answer is marked partial. `null` with no reply. */
57
57
  readonly unpairedShare: number | null;
58
+ /** Received messages flagged automatic and left out of every figure; 0 with `include_auto`. Always set by reply_timing; optional so a value built by hand stays valid. */
59
+ readonly autoReplies?: number;
58
60
  };
59
61
  }
60
62
  export declare const replyTiming: import("../define.ts").InsightDefinition<"replyTiming", {
61
63
  campaign: string | null;
64
+ include_auto: boolean;
62
65
  max_messages: number;
63
66
  since: string | null;
64
67
  timezone_offset_minutes: number;
65
68
  }, ReplyTiming, {
66
69
  campaign?: string | null | undefined;
70
+ include_auto?: boolean | undefined;
67
71
  max_messages?: number | undefined;
68
72
  since?: string | null | undefined;
69
73
  timezone_offset_minutes?: number | undefined;
@@ -52,7 +52,10 @@ export type Measured = BasedRate;
52
52
  export declare const measure: (count: number | null, base: Base) => Measured;
53
53
  /** The rate alone, without any field a caller added beside it. */
54
54
  export declare const replyRateOf: (measured: Measured | null) => BasedRate;
55
- /** Adds rows of counts; a count no row reports stays `null`. */
55
+ /**
56
+ * Adds rows of counts; a count no row reports stays `null`, and an open or
57
+ * click count is `null` when any row that sent did not measure it.
58
+ */
56
59
  export declare const sumRows: (rows: readonly MetricRow[]) => MetricCounts;
57
60
  /** Groups values by a key, in first-seen order. */
58
61
  export declare const groupBy: <Value, Key>(values: readonly Value[], keyOf: (value: Value) => Key) => Map<Key, Value[]>;
@@ -1,4 +1,7 @@
1
+ import type { StepPosition } from "../step.ts";
1
2
  import type { BasedRate } from "./shared.ts";
3
+ /** Below this many replies a step's rate is too uncertain to call it reliably above the bar. */
4
+ export declare const MIN_REPLIES = 5;
2
5
  export interface FunnelVariant {
3
6
  readonly variantKey: string;
4
7
  /** The hash of the variant's current copy. `null` when the sequence no longer has the variant. */
@@ -9,9 +12,7 @@ export interface FunnelVariant {
9
12
  readonly replyRate: BasedRate;
10
13
  };
11
14
  }
12
- export interface FunnelStep {
13
- /** Counted from 0. */
14
- readonly step: number;
15
+ export interface FunnelStep extends StepPosition {
15
16
  /** `null` when the stats name a step the sequence no longer has. */
16
17
  readonly action: string | null;
17
18
  readonly delayDays: number | null;
@@ -28,7 +29,12 @@ export interface FunnelStep {
28
29
  readonly sentDrop: number | null;
29
30
  /** `sentDrop` divided by the sends of the step before. */
30
31
  readonly sentDropRate: number | null;
31
- /** `true` when the low end of the reply rate interval is above `min_reply_rate`. `null` when the rate is unknown. */
32
+ /**
33
+ * `true` when the low end of the reply rate interval is above
34
+ * `min_reply_rate` and the step has at least `MIN_REPLIES` (5) replies;
35
+ * `false` when the low end is at or under it. `null` when the rate is
36
+ * unknown, or it is above the bar on too few replies to tell.
37
+ */
32
38
  readonly earnsPlace: boolean | null;
33
39
  /** Empty when the vendor does not split step stats by variant. */
34
40
  readonly variants: readonly FunnelVariant[];
@@ -37,9 +43,17 @@ export interface StepFunnel {
37
43
  readonly campaign: string;
38
44
  /** What the numbers say, in one or two sentences. */
39
45
  readonly finding: string;
40
- /** The step with the most replies. `null` when no step has a reply. */
46
+ /** The step with the most replies, counted from 0. `null` when no step has a reply. */
47
+ readonly topStepIndex: number | null;
48
+ /** `topStepIndex` counted from 1, as a person counts. */
49
+ readonly topStepNumber: number | null;
50
+ /** @deprecated Use `topStepIndex` (the same value, counted from 0) or `topStepNumber`. Removed in 0.8.0. */
41
51
  readonly topStep: number | null;
42
- /** The last step whose reply rate is reliably above `min_reply_rate`. `null` when none is. */
52
+ /** The last step that earns its place (see `earnsPlace`), counted from 0. `null` when none does. */
53
+ readonly lastStepEarningPlaceIndex: number | null;
54
+ /** `lastStepEarningPlaceIndex` counted from 1, as a person counts. */
55
+ readonly lastStepEarningPlaceNumber: number | null;
56
+ /** @deprecated Use `lastStepEarningPlaceIndex` (the same value, counted from 0) or `lastStepEarningPlaceNumber`. Removed in 0.8.0. */
43
57
  readonly lastStepEarningPlace: number | null;
44
58
  readonly steps: readonly FunnelStep[];
45
59
  readonly totals: {
@@ -1,3 +1,4 @@
1
+ import type { StepPosition } from "../step.ts";
1
2
  import type { RateBasis } from "./shared.ts";
2
3
  declare const METRICS: readonly ["replied", "positive", "opened", "clicked"];
3
4
  type Metric = (typeof METRICS)[number];
@@ -20,9 +21,7 @@ export interface TestedVariant {
20
21
  /** Two-sided p-value against the leader. `null` for the leader, a variant not compared, and two rates that are both 0 or both 1. */
21
22
  readonly pValueVsLeader: number | null;
22
23
  }
23
- export interface VariantStepTest {
24
- /** Counted from 0. */
25
- readonly step: number;
24
+ export interface VariantStepTest extends StepPosition {
26
25
  readonly verdict: VariantVerdict;
27
26
  /** The variant with the highest rate among those with enough data. `null` when fewer than two have enough. */
28
27
  readonly leader: string | null;