outbound-sdk 0.1.0 → 0.2.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 (145) hide show
  1. package/README.md +0 -2
  2. package/dist/alerts/index.js +5 -1
  3. package/dist/audit/index.js +2 -2
  4. package/dist/benchmarks/index.js +5 -3
  5. package/dist/budget/index.js +31 -10
  6. package/dist/cache/index.js +2 -2
  7. package/dist/cards/index.js +1 -1
  8. package/dist/chunks/{chunk-WAM6N4OF.js → chunk-4PSO6JEK.js} +107 -19
  9. package/dist/chunks/chunk-6CVZOUHB.js +152 -0
  10. package/dist/chunks/{chunk-OCV66TS2.js → chunk-AFU5E5QB.js} +17 -8
  11. package/dist/chunks/{chunk-R6AM4GJR.js → chunk-DJ2IUQEU.js} +24 -18
  12. package/dist/chunks/{chunk-LOXBLQ3I.js → chunk-E7JHLNLG.js} +9 -2
  13. package/dist/chunks/{chunk-LNCOGBMI.js → chunk-FHKSLCVW.js} +13 -3
  14. package/dist/chunks/chunk-FKH5N47I.js +40 -0
  15. package/dist/chunks/chunk-HZCTYL22.js +29 -0
  16. package/dist/chunks/{chunk-CMQ5ZHLZ.js → chunk-IPUYZD4O.js} +1 -1
  17. package/dist/chunks/{chunk-VURTOVGI.js → chunk-IVH3NMQZ.js} +1 -1
  18. package/dist/chunks/{chunk-ZGHQYZEH.js → chunk-LVYG7XZJ.js} +1 -1
  19. package/dist/chunks/chunk-NAKXLBA6.js +30 -0
  20. package/dist/chunks/{chunk-7BCYLIDG.js → chunk-PMSSUWD7.js} +186 -33
  21. package/dist/chunks/{chunk-Q465X22Y.js → chunk-PURHK3JU.js} +93 -209
  22. package/dist/chunks/{chunk-F7MKFVIG.js → chunk-R3Y56YVF.js} +2 -2
  23. package/dist/chunks/chunk-RCZ7ZZFU.js +92 -0
  24. package/dist/chunks/chunk-SBIZDCRY.js +106 -0
  25. package/dist/chunks/{chunk-IBC52BX3.js → chunk-U2D34ARZ.js} +20 -3
  26. package/dist/chunks/chunk-UAT3JSJZ.js +331 -0
  27. package/dist/chunks/{chunk-QZNNCXXD.js → chunk-VQSCHOBV.js} +20 -1
  28. package/dist/chunks/{chunk-B7V6EOAC.js → chunk-XNFESPZH.js} +160 -126
  29. package/dist/chunks/{chunk-WW746NJF.js → chunk-YOTW5ESM.js} +25 -1
  30. package/dist/cli/bin.js +14 -13
  31. package/dist/cli/commands.d.ts +3 -0
  32. package/dist/cli/config.d.ts +22 -0
  33. package/dist/cli/index.d.ts +5 -1
  34. package/dist/cli/index.js +20 -15
  35. package/dist/cli/stdio.d.ts +9 -0
  36. package/dist/clients/index.js +13 -3
  37. package/dist/combine/account.d.ts +1 -1
  38. package/dist/combine/index.js +90 -15
  39. package/dist/combine/route.d.ts +7 -0
  40. package/dist/exporter/index.js +2 -2
  41. package/dist/failover/index.js +4 -4
  42. package/dist/fixtures/index.js +40 -21
  43. package/dist/heyreach/account.d.ts +1 -1
  44. package/dist/heyreach/adapter.d.ts +1 -1
  45. package/dist/heyreach/capabilities.d.ts +2 -0
  46. package/dist/heyreach/client.d.ts +3 -5
  47. package/dist/heyreach/index.d.ts +7 -0
  48. package/dist/heyreach/index.js +428 -205
  49. package/dist/heyreach/leads.d.ts +4 -0
  50. package/dist/heyreach/map-account.d.ts +7 -1
  51. package/dist/heyreach/map-stats.d.ts +8 -5
  52. package/dist/heyreach/map.d.ts +3 -1
  53. package/dist/heyreach/webhooks.d.ts +1 -0
  54. package/dist/identity/index.js +22 -11
  55. package/dist/index.d.ts +1 -4
  56. package/dist/index.js +29 -17
  57. package/dist/insights/copy/index.d.ts +2 -2
  58. package/dist/insights/copy/variant-test.d.ts +2 -2
  59. package/dist/insights/index.js +248 -184
  60. package/dist/insights/ops/anomalies.d.ts +3 -3
  61. package/dist/insights/ops/index.d.ts +2 -2
  62. package/dist/insights/ops/shared.d.ts +7 -1
  63. package/dist/insights/registry.d.ts +4 -4
  64. package/dist/instantly/adapter-account.d.ts +1 -1
  65. package/dist/instantly/capabilities.d.ts +2 -0
  66. package/dist/instantly/client.d.ts +4 -9
  67. package/dist/instantly/index.d.ts +7 -0
  68. package/dist/instantly/index.js +410 -155
  69. package/dist/instantly/map-account.d.ts +20 -5
  70. package/dist/instantly/map-stats.d.ts +9 -6
  71. package/dist/instantly/map.d.ts +0 -2
  72. package/dist/instantly/native-agents-sales.d.ts +41 -41
  73. package/dist/instantly/native-agents.d.ts +44 -44
  74. package/dist/instantly/native-campaigns.d.ts +21 -21
  75. package/dist/instantly/native-leads.d.ts +12 -12
  76. package/dist/instantly/native-params.d.ts +2 -19
  77. package/dist/instantly/native-search.d.ts +10 -10
  78. package/dist/instantly/native-senders.d.ts +56 -56
  79. package/dist/instantly/native-supersearch.d.ts +33 -33
  80. package/dist/instantly/native-workspace.d.ts +45 -45
  81. package/dist/instantly/native.d.ts +262 -262
  82. package/dist/instantly/webhooks.d.ts +1 -0
  83. package/dist/internal/adapter.d.ts +24 -2
  84. package/dist/internal/capabilities.d.ts +18 -0
  85. package/dist/internal/client.d.ts +15 -0
  86. package/dist/internal/concurrency.d.ts +8 -0
  87. package/dist/internal/engine/request.d.ts +7 -0
  88. package/dist/internal/entities-account.d.ts +73 -3
  89. package/dist/internal/entities.d.ts +116 -12
  90. package/dist/internal/errors.d.ts +6 -1
  91. package/dist/internal/fields.d.ts +462 -0
  92. package/dist/internal/json.d.ts +9 -0
  93. package/dist/internal/lead-fields.d.ts +21 -0
  94. package/dist/internal/lead-status.d.ts +13 -0
  95. package/dist/internal/metrics.d.ts +14 -2
  96. package/dist/internal/native.d.ts +15 -0
  97. package/dist/internal/outbound/api.d.ts +29 -4
  98. package/dist/internal/outbound/operations-account.d.ts +12 -0
  99. package/dist/internal/outbound/outbound.d.ts +6 -3
  100. package/dist/internal/outbound/specs-account.d.ts +5 -1
  101. package/dist/internal/page.d.ts +14 -0
  102. package/dist/internal/record.d.ts +17 -0
  103. package/dist/internal/records.d.ts +7 -0
  104. package/dist/internal/sequence.d.ts +14 -0
  105. package/dist/internal/sha256.d.ts +2 -0
  106. package/dist/loader/index.d.ts +14 -2
  107. package/dist/loader/index.js +8 -4
  108. package/dist/memory/account-reads.d.ts +1 -1
  109. package/dist/memory/account.d.ts +15 -1
  110. package/dist/memory/data.d.ts +17 -2
  111. package/dist/memory/index.js +110 -35
  112. package/dist/redact/index.js +11 -6
  113. package/dist/redact/plugin.d.ts +1 -1
  114. package/dist/smartlead/account.d.ts +1 -1
  115. package/dist/smartlead/adapter.d.ts +1 -1
  116. package/dist/smartlead/capabilities.d.ts +2 -0
  117. package/dist/smartlead/client.d.ts +6 -11
  118. package/dist/smartlead/hmac.d.ts +0 -2
  119. package/dist/smartlead/index.d.ts +7 -0
  120. package/dist/smartlead/index.js +731 -572
  121. package/dist/smartlead/leads.d.ts +4 -1
  122. package/dist/smartlead/map-account.d.ts +17 -5
  123. package/dist/smartlead/map-stats.d.ts +9 -10
  124. package/dist/smartlead/map.d.ts +15 -5
  125. package/dist/smartlead/native-analytics.d.ts +87 -87
  126. package/dist/smartlead/native-campaigns.d.ts +64 -64
  127. package/dist/smartlead/native-inbox.d.ts +51 -51
  128. package/dist/smartlead/native-params.d.ts +2 -23
  129. package/dist/smartlead/native-services.d.ts +34 -34
  130. package/dist/smartlead/native.d.ts +236 -236
  131. package/dist/smartlead/shared.d.ts +6 -5
  132. package/dist/smartlead/webhooks.d.ts +1 -0
  133. package/dist/sync/index.js +3 -3
  134. package/dist/tools/ai-sdk.js +7 -5
  135. package/dist/tools/campaign-tools.d.ts +1 -1
  136. package/dist/tools/claude-agent.js +7 -5
  137. package/dist/tools/index.js +8 -6
  138. package/dist/tracing/index.js +2 -2
  139. package/dist/webhooks/index.js +10 -9
  140. package/package.json +1 -1
  141. package/dist/chunks/chunk-FZF6CLPX.js +0 -232
  142. package/dist/chunks/chunk-GPEJG34O.js +0 -53
  143. package/dist/chunks/chunk-HEC7XFFH.js +0 -65
  144. package/dist/chunks/chunk-QTB747K4.js +0 -100
  145. package/dist/chunks/chunk-TIJKJJDW.js +0 -6
@@ -0,0 +1,9 @@
1
+ import type { McpServer } from "./mcp.ts";
2
+ export interface StdioOptions {
3
+ /** Lines to answer. Defaults to standard input. */
4
+ readonly input?: AsyncIterable<string> | Iterable<string> | undefined;
5
+ /** Receives each response line. Defaults to standard output. */
6
+ readonly write?: ((line: string) => void) | undefined;
7
+ }
8
+ /** Answers one JSON-RPC message per line, in order, until the input ends. */
9
+ export declare const serveStdio: (server: McpServer, options?: StdioOptions) => Promise<void>;
@@ -1,7 +1,14 @@
1
+ import {
2
+ mapConcurrent
3
+ } from "../chunks/chunk-HZCTYL22.js";
1
4
  import {
2
5
  emptyCounts,
3
6
  sumCounts
4
- } from "../chunks/chunk-WW746NJF.js";
7
+ } from "../chunks/chunk-YOTW5ESM.js";
8
+ import "../chunks/chunk-4PSO6JEK.js";
9
+ import "../chunks/chunk-LVYG7XZJ.js";
10
+ import "../chunks/chunk-E7JHLNLG.js";
11
+ import "../chunks/chunk-VQSCHOBV.js";
5
12
 
6
13
  // src/clients/plugin.ts
7
14
  var UNASSIGNED = "unassigned";
@@ -62,8 +69,11 @@ var Assigner = class {
62
69
  var clientStats = async (outbound, options) => {
63
70
  const campaigns = await outbound.campaigns.listAll(options).toArray();
64
71
  const byClient = /* @__PURE__ */ new Map();
65
- for (const campaign of campaigns) {
66
- const stats = await outbound.campaign(campaign.ref).stats(options);
72
+ const read = await mapConcurrent(campaigns, async (campaign) => ({
73
+ campaign,
74
+ stats: await outbound.campaign(campaign.ref).stats(options)
75
+ }));
76
+ for (const { campaign, stats } of read) {
67
77
  const { client } = campaign;
68
78
  byClient.set(client, [...byClient.get(client) ?? [], ...stats.rows]);
69
79
  }
@@ -1,4 +1,4 @@
1
1
  import type { Adapter } from "../internal/adapter.ts";
2
- type AccountReads = Pick<Adapter, "getCampaignSettings" | "getSenderHealth" | "listBlocklist" | "listLists" | "listSubsequences" | "listTags" | "listWebhooks">;
2
+ type AccountReads = Pick<Adapter, "getCampaignProgress" | "getCampaignSettings" | "getList" | "getSenderHealth" | "getWebhook" | "listBlocklist" | "listLists" | "listPlacementTests" | "listSubsequences" | "listTags" | "listWebhooks">;
3
3
  export declare const accountReads: (members: readonly Adapter[]) => AccountReads;
4
4
  export {};
@@ -1,22 +1,24 @@
1
1
  import {
2
2
  intersectCapabilities,
3
- resolveCapabilities
4
- } from "../chunks/chunk-QTB747K4.js";
3
+ mergeFields,
4
+ resolveCapabilities,
5
+ resolveFields
6
+ } from "../chunks/chunk-UAT3JSJZ.js";
5
7
  import {
6
8
  recordBase
7
- } from "../chunks/chunk-IBC52BX3.js";
8
- import "../chunks/chunk-WAM6N4OF.js";
9
+ } from "../chunks/chunk-U2D34ARZ.js";
10
+ import "../chunks/chunk-4PSO6JEK.js";
9
11
  import {
10
12
  parseRef
11
- } from "../chunks/chunk-ZGHQYZEH.js";
13
+ } from "../chunks/chunk-LVYG7XZJ.js";
12
14
  import {
13
15
  OutboundError,
14
16
  makeErrorMapper
15
- } from "../chunks/chunk-LOXBLQ3I.js";
17
+ } from "../chunks/chunk-E7JHLNLG.js";
16
18
  import {
17
19
  count,
18
20
  field
19
- } from "../chunks/chunk-QZNNCXXD.js";
21
+ } from "../chunks/chunk-VQSCHOBV.js";
20
22
 
21
23
  // src/combine/route.ts
22
24
  var COMBINED = "combined";
@@ -50,6 +52,37 @@ var pageAcross = async (members, ctx, query, read) => {
50
52
  }
51
53
  return at.index + 1 < members.length ? { items: page.items, next: { member: at.index + 1 } } : { items: page.items };
52
54
  };
55
+ var waiting = (next, size) => {
56
+ const listed = field(next, "together");
57
+ if (!Array.isArray(listed)) {
58
+ return Array.from({ length: size }, (_, index) => ({
59
+ index,
60
+ next: void 0
61
+ }));
62
+ }
63
+ return listed.flatMap((entry) => {
64
+ const index = count(field(entry, "member"));
65
+ return index === null || index >= size ? [] : [{ index, next: field(entry, "next") ?? void 0 }];
66
+ });
67
+ };
68
+ var pageTogether = async (members, ctx, query, read) => {
69
+ const pages = await Promise.all(
70
+ waiting(query.next, members.length).flatMap((at) => {
71
+ const member = members[at.index];
72
+ return member === void 0 ? [] : [
73
+ read(member, ctx.forAdapter(member), at.next).then((page) => ({
74
+ index: at.index,
75
+ page
76
+ }))
77
+ ];
78
+ })
79
+ );
80
+ const unfinished = pages.flatMap(
81
+ ({ index, page }) => page.next === void 0 ? [] : [{ member: index, next: page.next }]
82
+ );
83
+ const items = pages.flatMap(({ page }) => page.items);
84
+ return unfinished.length === 0 ? { items } : { items, next: { together: unfinished } };
85
+ };
53
86
 
54
87
  // src/combine/account.ts
55
88
  var missing = (member, method) => new OutboundError(
@@ -65,14 +98,26 @@ var need = (member, method) => {
65
98
  return found;
66
99
  };
67
100
  var accountReads = (members) => ({
101
+ getCampaignProgress: (id, ctx) => {
102
+ const routed = routeRef(members, ctx, id, "Campaign");
103
+ return need(routed.member, "getCampaignProgress")(routed.id, routed.ctx);
104
+ },
68
105
  getCampaignSettings: (id, ctx) => {
69
106
  const routed = routeRef(members, ctx, id, "Campaign");
70
107
  return need(routed.member, "getCampaignSettings")(routed.id, routed.ctx);
71
108
  },
109
+ getList: (id, ctx) => {
110
+ const routed = routeRef(members, ctx, id, "List");
111
+ return need(routed.member, "getList")(routed.id, routed.ctx);
112
+ },
72
113
  getSenderHealth: (id, ctx) => {
73
114
  const routed = routeRef(members, ctx, id, "Sender");
74
115
  return need(routed.member, "getSenderHealth")(routed.id, routed.ctx);
75
116
  },
117
+ getWebhook: (id, ctx) => {
118
+ const routed = routeRef(members, ctx, id, "Webhook");
119
+ return need(routed.member, "getWebhook")(routed.id, routed.ctx);
120
+ },
76
121
  listBlocklist: (query, ctx) => pageAcross(
77
122
  members,
78
123
  ctx,
@@ -85,6 +130,12 @@ var accountReads = (members) => ({
85
130
  query,
86
131
  (member, memberCtx, next) => need(member, "listLists")({ ...query, next }, memberCtx)
87
132
  ),
133
+ listPlacementTests: (query, ctx) => pageAcross(
134
+ members,
135
+ ctx,
136
+ query,
137
+ (member, memberCtx, next) => need(member, "listPlacementTests")({ ...query, next }, memberCtx)
138
+ ),
88
139
  listSubsequences: (query, ctx) => {
89
140
  const routed = routeRef(members, ctx, query.campaignId, "Campaign");
90
141
  return need(routed.member, "listSubsequences")(
@@ -168,12 +219,21 @@ var scopedOrAcross = (members, ctx, query, read) => {
168
219
  return read(routed.member, routed.ctx, { ...query, campaignId: routed.id });
169
220
  };
170
221
  var lists = (members) => ({
171
- listCampaigns: (query, ctx) => pageAcross(
172
- members,
173
- ctx,
174
- query,
175
- (member, memberCtx, next) => member.listCampaigns({ ...query, next }, memberCtx)
176
- ),
222
+ listCampaigns: (query, ctx) => {
223
+ if (query.senderId !== void 0) {
224
+ const routed = routeRef(members, ctx, query.senderId, "Sender");
225
+ return routed.member.listCampaigns(
226
+ { ...query, senderId: routed.id },
227
+ routed.ctx
228
+ );
229
+ }
230
+ return pageAcross(
231
+ members,
232
+ ctx,
233
+ query,
234
+ (member, memberCtx, next) => member.listCampaigns({ ...query, next }, memberCtx)
235
+ );
236
+ },
177
237
  listLeads: (query, ctx) => {
178
238
  if (query.listId !== void 0) {
179
239
  const routed = routeRef(members, ctx, query.listId, "List");
@@ -185,12 +245,22 @@ var lists = (members) => ({
185
245
  routed.ctx
186
246
  );
187
247
  }
188
- return scopedOrAcross(members, ctx, query, (member, memberCtx, scoped) => {
248
+ const readLeads = (member, memberCtx, scoped) => {
189
249
  if (member.listLeads === void 0) {
190
250
  throw missing2(member, "listLeads");
191
251
  }
192
252
  return member.listLeads(scoped, memberCtx);
193
- });
253
+ };
254
+ const lookup = query.email !== void 0 || query.linkedinUrl !== void 0;
255
+ if (lookup && query.campaignId === void 0) {
256
+ return pageTogether(
257
+ members,
258
+ ctx,
259
+ query,
260
+ async (member, memberCtx, next) => await readLeads(member, memberCtx, { ...query, next })
261
+ );
262
+ }
263
+ return scopedOrAcross(members, ctx, query, readLeads);
194
264
  },
195
265
  listMessages: (query, ctx) => {
196
266
  const lead = query.leadId === void 0 ? void 0 : routeRef(members, ctx, query.leadId, "Lead");
@@ -296,6 +366,11 @@ var combine = (members) => {
296
366
  // A combined instance always knows its workspaces: they are its members.
297
367
  workspaces: true
298
368
  },
369
+ fieldCoverage: mergeFields(
370
+ members.map(
371
+ (member) => member.fieldCoverage ?? resolveFields(member.fields)
372
+ )
373
+ ),
299
374
  caveats: members.flatMap(
300
375
  (member) => (member.caveats ?? []).map(
301
376
  (caveat) => `${member.name} (${member.workspaceId}): ${caveat}`
@@ -15,3 +15,10 @@ export declare const routeRef: (members: readonly Adapter[], ctx: AdapterContext
15
15
  * walk is in, so it resumes exactly.
16
16
  */
17
17
  export declare const pageAcross: <Item>(members: readonly Adapter[], ctx: AdapterContext, query: PageQuery, read: (member: Adapter, memberCtx: AdapterContext, next: Json | undefined) => Promise<Page<Item>>) => Promise<Page<Item>>;
18
+ /**
19
+ * One page of a listing read from every member at the same time, for reads
20
+ * that return few records, such as a lookup by exact address. Items keep the
21
+ * members' order. The cursor holds each member still to finish, so the next
22
+ * page asks only those, again side by side.
23
+ */
24
+ export declare const pageTogether: <Item>(members: readonly Adapter[], ctx: AdapterContext, query: PageQuery, read: (member: Adapter, memberCtx: AdapterContext, next: Json | undefined) => Promise<Page<Item>>) => Promise<Page<Item>>;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  OutboundError
3
- } from "../chunks/chunk-LOXBLQ3I.js";
3
+ } from "../chunks/chunk-E7JHLNLG.js";
4
4
  import {
5
5
  isJsonObject,
6
6
  toJson
7
- } from "../chunks/chunk-QZNNCXXD.js";
7
+ } from "../chunks/chunk-VQSCHOBV.js";
8
8
 
9
9
  // src/exporter/index.ts
10
10
  import { open } from "node:fs/promises";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  cacheKey
3
- } from "../chunks/chunk-VURTOVGI.js";
4
- import "../chunks/chunk-LNCOGBMI.js";
3
+ } from "../chunks/chunk-IVH3NMQZ.js";
4
+ import "../chunks/chunk-FHKSLCVW.js";
5
5
  import {
6
6
  OutboundError
7
- } from "../chunks/chunk-LOXBLQ3I.js";
8
- import "../chunks/chunk-QZNNCXXD.js";
7
+ } from "../chunks/chunk-E7JHLNLG.js";
8
+ import "../chunks/chunk-VQSCHOBV.js";
9
9
 
10
10
  // src/failover/index.ts
11
11
  var WEEK_SECONDS = 7 * 24 * 60 * 60;
@@ -3,23 +3,23 @@ import {
3
3
  } from "../chunks/chunk-NAWZ73QS.js";
4
4
  import {
5
5
  stableId
6
- } from "../chunks/chunk-LNCOGBMI.js";
6
+ } from "../chunks/chunk-FHKSLCVW.js";
7
7
  import {
8
8
  evidenceSchema
9
- } from "../chunks/chunk-WAM6N4OF.js";
9
+ } from "../chunks/chunk-4PSO6JEK.js";
10
10
  import {
11
11
  makeRef,
12
12
  parseRef
13
- } from "../chunks/chunk-ZGHQYZEH.js";
13
+ } from "../chunks/chunk-LVYG7XZJ.js";
14
14
  import {
15
15
  OutboundError
16
- } from "../chunks/chunk-LOXBLQ3I.js";
16
+ } from "../chunks/chunk-E7JHLNLG.js";
17
17
  import {
18
18
  field,
19
19
  objects,
20
20
  parseJson,
21
21
  toJson
22
- } from "../chunks/chunk-QZNNCXXD.js";
22
+ } from "../chunks/chunk-VQSCHOBV.js";
23
23
 
24
24
  // src/fixtures/index.ts
25
25
  import { mkdir, readFile, writeFile } from "node:fs/promises";
@@ -35,17 +35,24 @@ var FORMAT = {
35
35
  value: (index) => `value-${index}`,
36
36
  workspace: (index) => `Workspace ${index}`
37
37
  };
38
- var isAccountRecord = (record) => "steps" in record || "description" in record || "schedule" in record || "dns" in record || "value" in record || "size" in record || "url" in record;
38
+ var isAccountRecord = (record) => "steps" in record || "description" in record || "inProgress" in record || "nextRunAt" in record || "schedule" in record || "dns" in record || "value" in record || "size" in record || "url" in record;
39
39
  var accountRecord = ({ base, placeholder, scrubRef }, record) => {
40
40
  if ("steps" in record || "description" in record) {
41
41
  return base(record);
42
42
  }
43
- if ("schedule" in record) {
43
+ if ("schedule" in record || "inProgress" in record) {
44
44
  return {
45
45
  ...base(record),
46
46
  campaignRef: scrubRef(record.campaignRef) ?? record.campaignRef
47
47
  };
48
48
  }
49
+ if ("nextRunAt" in record) {
50
+ return {
51
+ ...base(record),
52
+ campaignRef: scrubRef(record.campaignRef),
53
+ name: placeholder("value", record.name) ?? record.name
54
+ };
55
+ }
49
56
  if ("dns" in record) {
50
57
  return {
51
58
  ...base(record),
@@ -72,6 +79,28 @@ var accountRecord = ({ base, placeholder, scrubRef }, record) => {
72
79
  url: "https://example.com/webhook"
73
80
  };
74
81
  };
82
+ var standIn = (value, fake) => value === null ? null : fake;
83
+ var leadRecord = ({ base, placeholder }, record) => ({
84
+ ...base(record),
85
+ company: placeholder("company", record.company),
86
+ companyLinkedinUrl: standIn(
87
+ record.companyLinkedinUrl,
88
+ "https://www.linkedin.com/company/example-co"
89
+ ),
90
+ custom: Object.fromEntries(
91
+ Object.entries(record.custom).map(([key, value]) => [
92
+ key,
93
+ placeholder("value", value) ?? ""
94
+ ])
95
+ ),
96
+ email: placeholder("email", record.email),
97
+ firstName: standIn(record.firstName, "Person"),
98
+ lastName: placeholder("person", record.lastName)?.replace("Person ", "") ?? null,
99
+ linkedinUrl: placeholder("linkedin", record.linkedinUrl),
100
+ location: standIn(record.location, "Example City"),
101
+ phone: standIn(record.phone, "+15550000000"),
102
+ website: standIn(record.website, "https://example.com")
103
+ });
75
104
  var withPersonKeys = (original, scrubbed) => {
76
105
  if (!("personKeys" in original)) {
77
106
  return scrubbed;
@@ -136,20 +165,10 @@ var createScrubber = () => {
136
165
  };
137
166
  }
138
167
  if ("custom" in record) {
139
- return withPersonKeys(record, {
140
- ...base(record),
141
- company: placeholder("company", record.company),
142
- custom: Object.fromEntries(
143
- Object.entries(record.custom).map(([key, value]) => [
144
- key,
145
- placeholder("value", value) ?? ""
146
- ])
147
- ),
148
- email: placeholder("email", record.email),
149
- firstName: record.firstName === null ? null : "Person",
150
- lastName: placeholder("person", record.lastName)?.replace("Person ", "") ?? null,
151
- linkedinUrl: placeholder("linkedin", record.linkedinUrl)
152
- });
168
+ return withPersonKeys(
169
+ record,
170
+ leadRecord({ base, placeholder, scrubRef }, record)
171
+ );
153
172
  }
154
173
  if (isAccountRecord(record)) {
155
174
  return accountRecord({ base, placeholder, scrubRef }, record);
@@ -1,7 +1,7 @@
1
1
  import type { Adapter, AdapterContext, Page, SenderQuery } from "../internal/adapter.ts";
2
2
  import type { Sender } from "../internal/entities.ts";
3
3
  import type { HeyReachClient } from "./client.ts";
4
- type AccountReaders = Required<Pick<Adapter, "getSenderHealth" | "listBlocklist" | "listLists" | "listWebhooks">>;
4
+ type AccountReaders = Required<Pick<Adapter, "getCampaignProgress" | "getList" | "getSenderHealth" | "getWebhook" | "listBlocklist" | "listLists" | "listWebhooks">>;
5
5
  /** Lists, blacklist, webhooks and sender health. */
6
6
  export declare const accountReaders: (client: HeyReachClient) => AccountReaders;
7
7
  /** The LinkedIn accounts attached to one campaign. */
@@ -1,5 +1,5 @@
1
1
  import type { Adapter } from "../internal/adapter.ts";
2
2
  import type { HeyReachClient } from "./client.ts";
3
- type Readers = Pick<Adapter, "getCampaign" | "getLead" | "getSender" | "getSenderHealth" | "getSequence" | "listBlocklist" | "listCampaigns" | "listLeads" | "listLists" | "listMessages" | "listReplies" | "listSenders" | "listWebhooks" | "stats">;
3
+ type Readers = Pick<Adapter, "getCampaign" | "getCampaignProgress" | "getLead" | "getList" | "getSender" | "getSenderHealth" | "getSequence" | "getWebhook" | "listBlocklist" | "listCampaigns" | "listLeads" | "listLists" | "listMessages" | "listReplies" | "listSenders" | "listWebhooks" | "stats">;
4
4
  export declare const readers: (client: HeyReachClient) => Readers;
5
5
  export {};
@@ -1,4 +1,5 @@
1
1
  import type { CapabilityDeclaration } from "../internal/capabilities.ts";
2
+ import type { FieldDeclaration } from "../internal/fields.ts";
2
3
  import type { LimitDeclaration } from "../internal/limits.ts";
3
4
  export declare const BASE_URL = "https://api.heyreach.io/api/public";
4
5
  export declare const API_KEY_ENV = "HEYREACH_API_KEY";
@@ -8,6 +9,7 @@ export declare const PAGE_SIZE = 100;
8
9
  /** `POST /list/GetLeadsFromList` alone returns up to 1000 rows. */
9
10
  export declare const LIST_LEADS_PAGE_SIZE = 1000;
10
11
  export declare const capabilities: CapabilityDeclaration;
12
+ export declare const fields: FieldDeclaration;
11
13
  export declare const limits: LimitDeclaration;
12
14
  export declare const costs: {
13
15
  "blocklist.list": {
@@ -1,17 +1,15 @@
1
- import type { AdapterContext, HttpMethod, RawDescriptor } from "../internal/adapter.ts";
1
+ import type { HttpMethod, RawDescriptor } from "../internal/adapter.ts";
2
+ import type { VendorClient } from "../internal/client.ts";
2
3
  import type { Json, JsonObject } from "../internal/json.ts";
3
4
  import type { Identity } from "../internal/record.ts";
4
- import type { QueryValue } from "../internal/url.ts";
5
5
  export interface ClientOptions {
6
6
  readonly apiKey: string;
7
7
  readonly baseUrl: string | undefined;
8
8
  readonly identity: Identity;
9
9
  }
10
- export interface HeyReachClient {
10
+ export interface HeyReachClient extends VendorClient {
11
11
  readonly identity: Identity;
12
12
  readonly raw: RawDescriptor;
13
- readonly get: (ctx: AdapterContext, path: string, query?: Readonly<Record<string, QueryValue>>) => Promise<Json>;
14
- readonly post: (ctx: AdapterContext, path: string, body: JsonObject) => Promise<Json>;
15
13
  /** Narrows a response to one object, or throws a `Provider` error. */
16
14
  readonly object: (body: Json, path: string) => JsonObject;
17
15
  }
@@ -1,5 +1,6 @@
1
1
  import type { Adapter } from "../internal/adapter.ts";
2
2
  import type { CapabilityDeclaration } from "../internal/capabilities.ts";
3
+ import type { LeadFieldMap } from "../internal/lead-fields.ts";
3
4
  import { NATIVE } from "./native.ts";
4
5
  export { NATIVE } from "./native.ts";
5
6
  export type { HeyReachNative } from "./native.ts";
@@ -14,5 +15,11 @@ export interface HeyReachOptions {
14
15
  readonly baseUrl?: string | undefined;
15
16
  /** Overrides what the adapter declares. */
16
17
  readonly capabilities?: CapabilityDeclaration | undefined;
18
+ /**
19
+ * Which of a lead's custom fields holds a value this vendor has no field
20
+ * for, for example `{ title: "job_title" }`. Read only where the vendor's
21
+ * own field is empty.
22
+ */
23
+ readonly leadFields?: LeadFieldMap | undefined;
17
24
  }
18
25
  export declare const heyreach: (options?: HeyReachOptions) => Adapter<typeof NATIVE>;