outbound-sdk 0.5.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 (130) 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/format.d.ts +1 -1
  7. package/dist/cards/index.js +101 -62
  8. package/dist/cards/parts.d.ts +1 -6
  9. package/dist/chunks/{chunk-BLCJHP5H.js → chunk-45TXPJW7.js} +1 -0
  10. package/dist/chunks/chunk-4AVYRVN5.js +239 -0
  11. package/dist/chunks/{chunk-YYCT3NGV.js → chunk-65YAGEWZ.js} +24 -7
  12. package/dist/chunks/{chunk-BN6WCAWX.js → chunk-7I3EPR23.js} +3 -3
  13. package/dist/chunks/{chunk-3S32R2MH.js → chunk-BNDHEDHD.js} +2 -53
  14. package/dist/chunks/chunk-DNPNTD5W.js +81 -0
  15. package/dist/chunks/chunk-FALWG5U3.js +56 -0
  16. package/dist/chunks/{chunk-OLPMBRXM.js → chunk-GL7BABF2.js} +2 -2
  17. package/dist/chunks/{chunk-ZOAG2C6V.js → chunk-HIAK2GCI.js} +9 -2
  18. package/dist/chunks/{chunk-6TKFISG4.js → chunk-I7DXXGNZ.js} +42 -9
  19. package/dist/chunks/{chunk-BK5SLY32.js → chunk-JRL3QRBS.js} +264 -76
  20. package/dist/chunks/{chunk-EHSJGQ5K.js → chunk-KTYTE2BU.js} +4 -3
  21. package/dist/chunks/{chunk-JWGSB7PT.js → chunk-LD6F46UT.js} +2 -2
  22. package/dist/chunks/{chunk-2D42TQFU.js → chunk-LVZGIKNF.js} +2 -2
  23. package/dist/chunks/{chunk-PQSTQKRD.js → chunk-M2VXGLLZ.js} +35 -2
  24. package/dist/chunks/{chunk-5J7GGV62.js → chunk-MW4C6LTN.js} +2 -2
  25. package/dist/chunks/chunk-OK3GAZMT.js +51 -0
  26. package/dist/chunks/{chunk-BOWXGMN3.js → chunk-POBAY3TI.js} +80 -4
  27. package/dist/chunks/{chunk-J7DDZ4C2.js → chunk-QFC4ZHD3.js} +1 -1
  28. package/dist/chunks/{chunk-GFDNRWR3.js → chunk-UFQ4WMLU.js} +1 -1
  29. package/dist/chunks/{chunk-WGW3ROLY.js → chunk-Y7KECJAV.js} +1 -1
  30. package/dist/chunks/{chunk-QAKJ76HB.js → chunk-YW6FFVSZ.js} +1 -1
  31. package/dist/chunks/{chunk-X4RDBD4J.js → chunk-ZJCVLBAE.js} +445 -119
  32. package/dist/cli/bin.js +14 -14
  33. package/dist/cli/by-name.d.ts +28 -0
  34. package/dist/cli/commands.d.ts +2 -1
  35. package/dist/cli/config.d.ts +3 -2
  36. package/dist/cli/envelope.d.ts +50 -0
  37. package/dist/cli/index.d.ts +3 -0
  38. package/dist/cli/index.js +13 -13
  39. package/dist/cli/listing.d.ts +13 -0
  40. package/dist/cli/native.d.ts +4 -0
  41. package/dist/cli/options.d.ts +88 -0
  42. package/dist/cli/output.d.ts +21 -0
  43. package/dist/cli/suggest.d.ts +10 -0
  44. package/dist/clients/index.js +6 -6
  45. package/dist/combine/index.js +7 -7
  46. package/dist/emailbison/capabilities.d.ts +1 -0
  47. package/dist/emailbison/index.js +38 -13
  48. package/dist/emailbison/map-stats.d.ts +10 -0
  49. package/dist/exporter/index.js +2 -2
  50. package/dist/failover/index.js +2 -2
  51. package/dist/fixtures/index.js +4 -4
  52. package/dist/heyreach/capabilities.d.ts +3 -0
  53. package/dist/heyreach/index.js +36 -12
  54. package/dist/heyreach/map-account.d.ts +2 -2
  55. package/dist/identity/index.js +2 -2
  56. package/dist/index.js +9 -7
  57. package/dist/insights/copy/audit-samples.d.ts +24 -0
  58. package/dist/insights/copy/audit-variant.d.ts +34 -0
  59. package/dist/insights/copy/copy-audit.d.ts +26 -12
  60. package/dist/insights/copy/copy-preview.d.ts +71 -0
  61. package/dist/insights/copy/copy-reuse.d.ts +0 -13
  62. package/dist/insights/copy/index.d.ts +15 -0
  63. package/dist/insights/copy/reply-timing.d.ts +4 -0
  64. package/dist/insights/copy/reuse-base.d.ts +0 -2
  65. package/dist/insights/copy/shared.d.ts +7 -9
  66. package/dist/insights/copy/step-funnel.d.ts +21 -18
  67. package/dist/insights/copy/variant-test.d.ts +2 -8
  68. package/dist/insights/index.js +1357 -717
  69. package/dist/insights/inputs.generated.d.ts +67 -34
  70. package/dist/insights/ops/campaign-diagnosis.d.ts +2 -2
  71. package/dist/insights/ops/client-report.d.ts +0 -2
  72. package/dist/insights/ops/diagnosis-checks.d.ts +20 -1
  73. package/dist/insights/ops/index.d.ts +2 -4
  74. package/dist/insights/ops/pipeline-forecast.d.ts +17 -6
  75. package/dist/insights/ops/shared.d.ts +0 -2
  76. package/dist/insights/people/account-summary.d.ts +14 -1
  77. package/dist/insights/people/auto-replies.d.ts +14 -0
  78. package/dist/insights/people/dropped-replies.d.ts +1 -1
  79. package/dist/insights/people/hot-leads.d.ts +5 -1
  80. package/dist/insights/people/index.d.ts +4 -0
  81. package/dist/insights/people/lead-collisions.d.ts +11 -2
  82. package/dist/insights/people/person-summary.d.ts +19 -3
  83. package/dist/insights/people/personalization-gaps.d.ts +14 -8
  84. package/dist/insights/people/suppression-check.d.ts +9 -0
  85. package/dist/insights/registry.d.ts +20 -8
  86. package/dist/insights/senders/bounce-watch.d.ts +0 -11
  87. package/dist/insights/senders/domain-health.d.ts +0 -7
  88. package/dist/insights/senders/index.d.ts +0 -4
  89. package/dist/insights/senders/sender-load.d.ts +0 -2
  90. package/dist/insights/step.d.ts +15 -0
  91. package/dist/insights/types.d.ts +1 -1
  92. package/dist/insights/variables.d.ts +35 -0
  93. package/dist/instantly/capabilities.d.ts +4 -0
  94. package/dist/instantly/index.js +265 -53
  95. package/dist/instantly/map-stats.d.ts +4 -0
  96. package/dist/instantly/stats-tracking.d.ts +19 -0
  97. package/dist/instantly/thread.d.ts +9 -0
  98. package/dist/internal/adapter.d.ts +5 -0
  99. package/dist/internal/auto-reply.d.ts +20 -0
  100. package/dist/internal/capabilities.d.ts +2 -0
  101. package/dist/internal/entities-account.d.ts +1 -0
  102. package/dist/internal/entities.d.ts +79 -2
  103. package/dist/internal/fields.d.ts +37 -1
  104. package/dist/internal/metrics.d.ts +23 -1
  105. package/dist/internal/outbound/api.d.ts +2 -0
  106. package/dist/internal/records.d.ts +2 -2
  107. package/dist/internal/reply-people.d.ts +37 -0
  108. package/dist/internal/runway.d.ts +42 -0
  109. package/dist/internal/sender-screen.d.ts +9 -0
  110. package/dist/internal/tracking.d.ts +33 -0
  111. package/dist/loader/index.js +4 -4
  112. package/dist/memory/data.d.ts +2 -1
  113. package/dist/memory/index.js +23 -12
  114. package/dist/redact/index.js +3 -3
  115. package/dist/smartlead/capabilities.d.ts +4 -0
  116. package/dist/smartlead/index.js +154 -38
  117. package/dist/smartlead/map-account.d.ts +3 -0
  118. package/dist/smartlead/stats-tracking.d.ts +22 -0
  119. package/dist/sync/index.js +2 -2
  120. package/dist/tools/ai-sdk.js +8 -7
  121. package/dist/tools/by-name.d.ts +18 -0
  122. package/dist/tools/campaign-tools.d.ts +6 -2
  123. package/dist/tools/claude-agent.js +8 -7
  124. package/dist/tools/index.js +9 -8
  125. package/dist/tools/shared.d.ts +7 -0
  126. package/dist/tracing/index.js +2 -2
  127. package/dist/webhooks/index.js +12 -10
  128. package/package.json +1 -1
  129. package/dist/chunks/chunk-HWHI4LFY.js +0 -102
  130. package/dist/internal/renamed.d.ts +0 -28
@@ -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,
@@ -11,10 +11,12 @@ import {
11
11
  createVendorClient,
12
12
  leadStanding,
13
13
  listIn,
14
- normalizeBody,
15
14
  toVariant,
16
15
  variantKey
17
- } from "../chunks/chunk-3S32R2MH.js";
16
+ } from "../chunks/chunk-BNDHEDHD.js";
17
+ import {
18
+ normalizeBody
19
+ } from "../chunks/chunk-FALWG5U3.js";
18
20
  import {
19
21
  defineNative
20
22
  } from "../chunks/chunk-NAKXLBA6.js";
@@ -23,16 +25,16 @@ import {
23
25
  recordBase,
24
26
  refTo,
25
27
  refsTo
26
- } from "../chunks/chunk-2D42TQFU.js";
27
- import "../chunks/chunk-BOWXGMN3.js";
28
+ } from "../chunks/chunk-LVZGIKNF.js";
29
+ import "../chunks/chunk-POBAY3TI.js";
28
30
  import {
29
31
  emptyCounts,
30
32
  metricRow
31
- } from "../chunks/chunk-PQSTQKRD.js";
33
+ } from "../chunks/chunk-M2VXGLLZ.js";
32
34
  import "../chunks/chunk-QGRZDTX4.js";
33
35
  import {
34
36
  assertWorkspaceId
35
- } from "../chunks/chunk-QAKJ76HB.js";
37
+ } from "../chunks/chunk-YW6FFVSZ.js";
36
38
  import {
37
39
  profileSlug
38
40
  } from "../chunks/chunk-NAWZ73QS.js";
@@ -42,13 +44,13 @@ import {
42
44
  import {
43
45
  readEnv,
44
46
  requireCredential
45
- } from "../chunks/chunk-GFDNRWR3.js";
47
+ } from "../chunks/chunk-UFQ4WMLU.js";
46
48
  import {
47
49
  OutboundError,
48
50
  isHttpFailure,
49
51
  makeErrorMapper,
50
52
  requireObject
51
- } from "../chunks/chunk-J7DDZ4C2.js";
53
+ } from "../chunks/chunk-QFC4ZHD3.js";
52
54
  import {
53
55
  count,
54
56
  emailAddress,
@@ -62,7 +64,7 @@ import {
62
64
  objects,
63
65
  text,
64
66
  timestamp
65
- } from "../chunks/chunk-BLCJHP5H.js";
67
+ } from "../chunks/chunk-45TXPJW7.js";
66
68
 
67
69
  // src/heyreach/map-account.ts
68
70
  var toCampaignProgress = (identity, campaignId, raw) => {
@@ -77,6 +79,7 @@ var toCampaignProgress = (identity, campaignId, raw) => {
77
79
  inProgress: count(field(stats, "totalUsersInProgress")),
78
80
  leads: count(field(stats, "totalUsers")),
79
81
  notStarted: count(field(stats, "totalUsersPending")),
82
+ skipped: count(field(stats, "totalUsersExcluded")),
80
83
  stopped: count(field(stats, "totalUsersManuallyStopped"))
81
84
  };
82
85
  };
@@ -209,6 +212,7 @@ var toSender = (identity, raw) => ({
209
212
  warmup: null
210
213
  });
211
214
  var LEAD_PROGRESS = /* @__PURE__ */ new Map([
215
+ ["Excluded", "skipped"],
212
216
  ["Finished", "completed"],
213
217
  ["InSequence", "active"],
214
218
  ["Paused", "paused"],
@@ -270,6 +274,7 @@ var profileFields = (identity, profile, raw) => ({
270
274
  location: text(field(profile, "location")),
271
275
  // HeyReach profiles carry no phone number and no company website.
272
276
  phone: null,
277
+ recipientMailProvider: null,
273
278
  title: text(field(profile, "position")),
274
279
  website: null
275
280
  });
@@ -420,20 +425,35 @@ var fields = {
420
425
  bounced: false,
421
426
  engagement: false,
422
427
  phone: false,
428
+ recipientMailProvider: false,
423
429
  unsubscribed: false,
424
430
  website: false
425
431
  },
426
- 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
+ },
427
439
  metricRow: {
428
440
  bounced: false,
429
441
  clicked: false,
430
442
  clickedTotal: false,
443
+ completed: false,
431
444
  contentHash: false,
432
445
  delivered: false,
446
+ leads: false,
433
447
  opened: false,
434
448
  openedTotal: false,
449
+ opportunities: false,
450
+ opportunityValue: false,
451
+ repliedAutoTotal: false,
452
+ repliedTotal: false,
435
453
  repliedAuto: false,
436
454
  stepIndex: false,
455
+ // LinkedIn has no open or click tracking.
456
+ tracking: false,
437
457
  unsubscribed: false,
438
458
  variantKey: false
439
459
  },
@@ -445,6 +465,8 @@ var fields = {
445
465
  category: "derived",
446
466
  categorySource: "derived",
447
467
  isAuto: false,
468
+ isAutoSource: false,
469
+ leftCompany: false,
448
470
  stepIndex: false,
449
471
  variantKey: false
450
472
  },
@@ -484,6 +506,8 @@ var costs = {
484
506
  "blocklist.list": { pageSize: PAGE_SIZE, perPage: 1 },
485
507
  "campaigns.get": { perPage: 1 },
486
508
  "campaigns.list": { pageSize: PAGE_SIZE, perPage: 1 },
509
+ // The campaign object, which carries its lead counts.
510
+ "campaigns.progress": { perPage: 1 },
487
511
  // The profile and its tags are two requests.
488
512
  "leads.get": { perPage: 2 },
489
513
  // A campaign's leads. A saved list's leads come up to 1000 a page. Without
@@ -520,7 +544,7 @@ var caveats = [
520
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.",
521
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.",
522
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.",
523
- "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.",
524
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.",
525
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.",
526
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
  }>;
@@ -0,0 +1,71 @@
1
+ import type { Lead, Sequence, SequenceVariant } from "../../internal/entities.ts";
2
+ import type { StepPosition } from "../step.ts";
3
+ export interface CopyText {
4
+ readonly subject: string | null;
5
+ readonly body: string | null;
6
+ }
7
+ export interface RenderedCopy extends CopyText {
8
+ /** The rendered body as plain text, with HTML tags removed. `null` when there is no body. */
9
+ readonly bodyText: string | null;
10
+ }
11
+ export interface PreviewVariant {
12
+ readonly variantKey: string;
13
+ /** The copy exactly as the campaign stores it. */
14
+ readonly template: CopyText;
15
+ /** The copy with the lead's values, or each variable's fallback, put in. */
16
+ readonly rendered: RenderedCopy;
17
+ /**
18
+ * Variables left as written because the lead has no value and the copy no
19
+ * fallback. A sender signature or another variable the tool fills itself
20
+ * at send time is listed here too.
21
+ */
22
+ readonly unfilled: readonly string[];
23
+ }
24
+ export interface PreviewStep extends StepPosition {
25
+ readonly action: string;
26
+ readonly delayDays: number | null;
27
+ readonly variants: readonly PreviewVariant[];
28
+ }
29
+ export interface PreviewLead {
30
+ readonly lead: string;
31
+ readonly email: string | null;
32
+ readonly linkedinUrl: string | null;
33
+ /** How many of the copy's variables this lead has a value for. */
34
+ readonly variablesFilled: number;
35
+ }
36
+ export interface CopyPreview {
37
+ readonly campaign: string;
38
+ /** The lead the copy is rendered for. `null` when no lead was read. */
39
+ readonly lead: PreviewLead | null;
40
+ readonly steps: readonly PreviewStep[];
41
+ readonly totals: {
42
+ readonly steps: number;
43
+ readonly variants: number;
44
+ /** Distinct variables in the copy. */
45
+ readonly variables: number;
46
+ /** Distinct variables left as written in at least one variant. */
47
+ readonly unfilled: number;
48
+ };
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;
63
+ export declare const copyPreview: import("../define.ts").InsightDefinition<"copyPreview", {
64
+ campaign: string;
65
+ lead: string | null;
66
+ max_leads: number;
67
+ }, CopyPreview, {
68
+ campaign: string;
69
+ lead?: string | null | undefined;
70
+ max_leads?: number | undefined;
71
+ }>;
@@ -1,4 +1,3 @@
1
- import type { Interval } from "../stats.ts";
2
1
  import type { BasedRate, RateBasis } from "./shared.ts";
3
2
  export interface CopyUse {
4
3
  readonly campaign: string;
@@ -14,12 +13,6 @@ export interface CopyUse {
14
13
  };
15
14
  /** What the rate divides by: leads contacted or messages sent. */
16
15
  readonly basis: RateBasis | null;
17
- /** @deprecated Use `rates.replyRate.of`. Removed in 0.6.0. */
18
- readonly trials: number | null;
19
- /** @deprecated Use `rates.replyRate.rate`. Removed in 0.6.0. */
20
- readonly replyRate: number | null;
21
- /** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.6.0. */
22
- readonly replyRateInterval: Interval | null;
23
16
  }
24
17
  export interface CopyPiece {
25
18
  readonly contentHash: string;
@@ -34,12 +27,6 @@ export interface CopyPiece {
34
27
  readonly replyRate: BasedRate;
35
28
  };
36
29
  readonly basis: RateBasis | null;
37
- /** @deprecated Use `rates.replyRate.of`. Removed in 0.6.0. */
38
- readonly trials: number | null;
39
- /** @deprecated Use `rates.replyRate.rate`. Removed in 0.6.0. */
40
- readonly replyRate: number | null;
41
- /** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.6.0. */
42
- readonly replyRateInterval: Interval | null;
43
30
  }
44
31
  export interface ReusedCopy extends CopyPiece {
45
32
  /** Best reply rate first; a campaign with no known rate is last. */
@@ -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,8 +40,18 @@ 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;
47
+ }>, import("../define.ts").InsightDefinition<"copyPreview", {
48
+ campaign: string;
49
+ lead: string | null;
50
+ max_leads: number;
51
+ }, import("./copy-preview.ts").CopyPreview, {
52
+ campaign: string;
53
+ lead?: string | null | undefined;
54
+ max_leads?: number | undefined;
43
55
  }>, import("../define.ts").InsightDefinition<"copyReuse", {
44
56
  max_campaigns: number;
45
57
  min_sent: number;
@@ -50,17 +62,20 @@ export declare const COPY_INSIGHTS: readonly [import("../define.ts").InsightDefi
50
62
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
51
63
  }>, import("../define.ts").InsightDefinition<"replyTiming", {
52
64
  campaign: string | null;
65
+ include_auto: boolean;
53
66
  max_messages: number;
54
67
  since: string | null;
55
68
  timezone_offset_minutes: number;
56
69
  }, import("./reply-timing.ts").ReplyTiming, {
57
70
  campaign?: string | null | undefined;
71
+ include_auto?: boolean | undefined;
58
72
  max_messages?: number | undefined;
59
73
  since?: string | null | undefined;
60
74
  timezone_offset_minutes?: number | undefined;
61
75
  }>];
62
76
  export type { CheckName, Severity } from "./copy-checks.ts";
63
77
  export type { CheckCount, CopyAudit, CopyFinding } from "./copy-audit.ts";
78
+ export type { CopyPreview, CopyText, PreviewLead, PreviewStep, PreviewVariant, RenderedCopy, } from "./copy-preview.ts";
64
79
  export type { CopyPiece, CopyReuse, CopyUse, ReusedCopy, } from "./copy-reuse.ts";
65
80
  export type { HourCount, ReplyTiming, TimeTable, WeekdayCount, } from "./reply-timing.ts";
66
81
  export type { FunnelStep, FunnelVariant, StepFunnel } from "./step-funnel.ts";
@@ -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;
@@ -6,8 +6,6 @@ import type { Base, RateBasis } from "./shared.ts";
6
6
  export type BaseOf = (counts: MetricCounts) => Base;
7
7
  export declare const pooled: (counts: readonly (MetricCounts | null)[], baseOf: BaseOf) => {
8
8
  sent: number | null;
9
- trials: number | null;
10
- interval: import("../stats.ts").Interval | null;
11
9
  basis: RateBasis | null;
12
10
  count: number | null;
13
11
  of: number | null;
@@ -1,7 +1,6 @@
1
1
  import type { MetricRow } from "../../internal/entities.ts";
2
2
  import type { MetricCounts } from "../../internal/metrics.ts";
3
3
  import type { Measured as Rate } from "../ops/shared.ts";
4
- import type { Interval } from "../stats.ts";
5
4
  export interface DayRange {
6
5
  readonly from: string | undefined;
7
6
  readonly to: string | undefined;
@@ -48,16 +47,15 @@ export interface BasedRate extends Rate {
48
47
  /** What `of` counts. */
49
48
  readonly basis: RateBasis | null;
50
49
  }
51
- export interface Measured extends BasedRate {
52
- /** @deprecated Use `of`. Removed in 0.6.0. */
53
- readonly trials: number | null;
54
- /** @deprecated Use `low` and `high`. Removed in 0.6.0. */
55
- readonly interval: Interval | null;
56
- }
50
+ /** A measured rate. */
51
+ export type Measured = BasedRate;
57
52
  export declare const measure: (count: number | null, base: Base) => Measured;
58
- /** The rate alone, without the deprecated `trials` and `interval`. */
53
+ /** The rate alone, without any field a caller added beside it. */
59
54
  export declare const replyRateOf: (measured: Measured | null) => BasedRate;
60
- /** 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
+ */
61
59
  export declare const sumRows: (rows: readonly MetricRow[]) => MetricCounts;
62
60
  /** Groups values by a key, in first-seen order. */
63
61
  export declare const groupBy: <Value, Key>(values: readonly Value[], keyOf: (value: Value) => Key) => Map<Key, Value[]>;
@@ -1,5 +1,7 @@
1
- import type { Interval } from "../stats.ts";
2
- import type { BasedRate, RateBasis } from "./shared.ts";
1
+ import type { StepPosition } from "../step.ts";
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;
3
5
  export interface FunnelVariant {
4
6
  readonly variantKey: string;
5
7
  /** The hash of the variant's current copy. `null` when the sequence no longer has the variant. */
@@ -9,14 +11,8 @@ export interface FunnelVariant {
9
11
  readonly rates: {
10
12
  readonly replyRate: BasedRate;
11
13
  };
12
- /** @deprecated Use `rates.replyRate.rate`. Removed in 0.6.0. */
13
- readonly replyRate: number | null;
14
- /** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.6.0. */
15
- readonly replyRateInterval: Interval | null;
16
14
  }
17
- export interface FunnelStep {
18
- /** Counted from 0. */
19
- readonly step: number;
15
+ export interface FunnelStep extends StepPosition {
20
16
  /** `null` when the stats name a step the sequence no longer has. */
21
17
  readonly action: string | null;
22
18
  readonly delayDays: number | null;
@@ -27,19 +23,18 @@ export interface FunnelStep {
27
23
  readonly rates: {
28
24
  readonly replyRate: BasedRate;
29
25
  };
30
- /** @deprecated Use `rates.replyRate.rate`. Removed in 0.6.0. */
31
- readonly replyRate: number | null;
32
- /** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.6.0. */
33
- readonly replyRateInterval: Interval | null;
34
- /** @deprecated Use `rates.replyRate.basis`. Removed in 0.6.0. */
35
- readonly replyRateBasis: RateBasis | null;
36
26
  /** This step's replies divided by every reply in the campaign, unattributed ones included. */
37
27
  readonly shareOfReplies: number | null;
38
28
  /** Sends of the step before minus this step's sends. `null` for the first step or an unknown count. */
39
29
  readonly sentDrop: number | null;
40
30
  /** `sentDrop` divided by the sends of the step before. */
41
31
  readonly sentDropRate: number | null;
42
- /** `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
+ */
43
38
  readonly earnsPlace: boolean | null;
44
39
  /** Empty when the vendor does not split step stats by variant. */
45
40
  readonly variants: readonly FunnelVariant[];
@@ -48,9 +43,17 @@ export interface StepFunnel {
48
43
  readonly campaign: string;
49
44
  /** What the numbers say, in one or two sentences. */
50
45
  readonly finding: string;
51
- /** 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. */
52
51
  readonly topStep: number | null;
53
- /** 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. */
54
57
  readonly lastStepEarningPlace: number | null;
55
58
  readonly steps: readonly FunnelStep[];
56
59
  readonly totals: {