outbound-sdk 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/alerts/index.js +3 -3
  2. package/dist/audit/index.js +1 -1
  3. package/dist/benchmarks/index.js +3 -3
  4. package/dist/budget/index.d.ts +7 -0
  5. package/dist/budget/index.js +3 -3
  6. package/dist/cache/index.js +2 -2
  7. package/dist/cards/index.js +17 -5
  8. package/dist/chunks/{chunk-6NSCPTOY.js → chunk-4BH5LRCS.js} +691 -441
  9. package/dist/chunks/{chunk-MW4C6LTN.js → chunk-5XLR6XVV.js} +2 -2
  10. package/dist/chunks/{chunk-HIAK2GCI.js → chunk-A7DLJUA6.js} +6 -1
  11. package/dist/chunks/{chunk-M2VXGLLZ.js → chunk-CPACP4YD.js} +1 -1
  12. package/dist/chunks/{chunk-4AVYRVN5.js → chunk-FTK4JS65.js} +31 -10
  13. package/dist/chunks/{chunk-YW6FFVSZ.js → chunk-HXB2IOJJ.js} +1 -1
  14. package/dist/chunks/{chunk-FHKSLCVW.js → chunk-KVAG5GM2.js} +19 -0
  15. package/dist/chunks/{chunk-65YAGEWZ.js → chunk-MEEJIIIA.js} +178 -39
  16. package/dist/chunks/{chunk-7I3EPR23.js → chunk-MPE6VLLY.js} +3 -3
  17. package/dist/chunks/{chunk-UFQ4WMLU.js → chunk-NFWWA7MI.js} +1 -1
  18. package/dist/chunks/{chunk-GL7BABF2.js → chunk-OMCDMELK.js} +1 -1
  19. package/dist/chunks/{chunk-JRL3QRBS.js → chunk-OVTYA3IB.js} +88 -28
  20. package/dist/chunks/{chunk-T5MJMW3R.js → chunk-QTWJ5FO7.js} +1 -1
  21. package/dist/chunks/chunk-REDFBY74.js +7285 -0
  22. package/dist/chunks/{chunk-OK3GAZMT.js → chunk-SYUMA3CP.js} +12 -0
  23. package/dist/chunks/{chunk-LVZGIKNF.js → chunk-U5AK6OJM.js} +1 -1
  24. package/dist/chunks/{chunk-KTYTE2BU.js → chunk-UAHYPASH.js} +20 -11
  25. package/dist/chunks/{chunk-BNDHEDHD.js → chunk-UOJG4VYF.js} +3 -3
  26. package/dist/chunks/{chunk-LD6F46UT.js → chunk-UWD65SK7.js} +2 -2
  27. package/dist/chunks/{chunk-I7DXXGNZ.js → chunk-UZLFZZ2U.js} +5 -5
  28. package/dist/chunks/{chunk-DNPNTD5W.js → chunk-VVDBCQLK.js} +1 -1
  29. package/dist/chunks/{chunk-IVH3NMQZ.js → chunk-WROJO6XB.js} +1 -1
  30. package/dist/chunks/{chunk-QFC4ZHD3.js → chunk-XYHM4KHC.js} +1 -1
  31. package/dist/chunks/{chunk-NAWZ73QS.js → chunk-YFJ3OQZS.js} +8 -1
  32. package/dist/chunks/tools-ATY622UC.js +23 -0
  33. package/dist/cli/args.d.ts +48 -0
  34. package/dist/cli/bin.js +14 -14
  35. package/dist/cli/commands.d.ts +0 -7
  36. package/dist/cli/config.d.ts +31 -2
  37. package/dist/cli/envelope.d.ts +2 -0
  38. package/dist/cli/index.d.ts +4 -0
  39. package/dist/cli/index.js +19 -15
  40. package/dist/cli/listing.d.ts +5 -2
  41. package/dist/cli/mcp.d.ts +9 -0
  42. package/dist/cli/offered.d.ts +10 -0
  43. package/dist/cli/options.d.ts +6 -0
  44. package/dist/cli/progress.d.ts +27 -0
  45. package/dist/cli/serve.d.ts +17 -0
  46. package/dist/clients/index.js +3 -3
  47. package/dist/combine/index.js +154 -35
  48. package/dist/combine/newest.d.ts +18 -0
  49. package/dist/combine/route.d.ts +19 -5
  50. package/dist/emailbison/index.js +22 -14
  51. package/dist/emailbison/map-sequence.d.ts +2 -1
  52. package/dist/exporter/index.js +1 -1
  53. package/dist/failover/index.js +3 -3
  54. package/dist/fixtures/index.js +4 -4
  55. package/dist/heyreach/capabilities.d.ts +4 -0
  56. package/dist/heyreach/conversations.d.ts +23 -0
  57. package/dist/heyreach/inbox.d.ts +0 -1
  58. package/dist/heyreach/index.js +251 -92
  59. package/dist/identity/index.js +2 -2
  60. package/dist/index.js +7 -7
  61. package/dist/insights/capped.d.ts +6 -6
  62. package/dist/insights/copy/index.d.ts +2 -0
  63. package/dist/insights/copy/reply-timing.d.ts +4 -0
  64. package/dist/insights/cost.d.ts +11 -1
  65. package/dist/insights/define.d.ts +25 -16
  66. package/dist/insights/inbox.d.ts +12 -0
  67. package/dist/insights/index.js +42 -6578
  68. package/dist/insights/inputs.generated.d.ts +62 -26
  69. package/dist/insights/ops/anomalies.d.ts +9 -0
  70. package/dist/insights/ops/index.d.ts +2 -0
  71. package/dist/insights/ops/period-comparison.d.ts +7 -8
  72. package/dist/insights/ops/pipeline-forecast.d.ts +16 -0
  73. package/dist/insights/ops/shared.d.ts +6 -1
  74. package/dist/insights/people/auto-replies.d.ts +11 -7
  75. package/dist/insights/people/dropped-replies.d.ts +13 -4
  76. package/dist/insights/people/hot-leads-read.d.ts +31 -0
  77. package/dist/insights/people/hot-leads.d.ts +15 -3
  78. package/dist/insights/people/index.d.ts +10 -2
  79. package/dist/insights/people/read.d.ts +1 -1
  80. package/dist/insights/registry.d.ts +14 -2
  81. package/dist/insights/run-cap.d.ts +10 -0
  82. package/dist/insights/senders/read.d.ts +0 -3
  83. package/dist/insights/tools.d.ts +12 -0
  84. package/dist/insights/tracked-reads.d.ts +53 -0
  85. package/dist/instantly/capabilities.d.ts +13 -1
  86. package/dist/instantly/index.js +128 -46
  87. package/dist/instantly/map-account.d.ts +2 -1
  88. package/dist/instantly/map-lead.d.ts +1 -0
  89. package/dist/instantly/map.d.ts +4 -3
  90. package/dist/internal/adapter.d.ts +19 -0
  91. package/dist/internal/capabilities.d.ts +15 -0
  92. package/dist/internal/engine/budget.d.ts +9 -1
  93. package/dist/internal/engine/engine.d.ts +2 -1
  94. package/dist/internal/engine/request.d.ts +2 -0
  95. package/dist/internal/errors.d.ts +5 -0
  96. package/dist/internal/hooks.d.ts +11 -0
  97. package/dist/internal/notes.d.ts +16 -0
  98. package/dist/internal/outbound/api.d.ts +16 -0
  99. package/dist/internal/outbound/core.d.ts +4 -1
  100. package/dist/internal/outbound/operation-shared.d.ts +2 -0
  101. package/dist/internal/sha256.d.ts +2 -0
  102. package/dist/internal/url.d.ts +1 -0
  103. package/dist/loader/index.js +3 -3
  104. package/dist/memory/index.js +11 -16
  105. package/dist/redact/index.d.ts +1 -1
  106. package/dist/redact/index.js +107 -19
  107. package/dist/redact/plugin.d.ts +26 -3
  108. package/dist/smartlead/index.js +22 -13
  109. package/dist/smartlead/map.d.ts +3 -2
  110. package/dist/sync/index.js +2 -2
  111. package/dist/tools/ai-sdk.js +5 -5
  112. package/dist/tools/by-name.d.ts +9 -1
  113. package/dist/tools/campaign-tools.d.ts +3 -1
  114. package/dist/tools/claude-agent.js +5 -5
  115. package/dist/tools/index.js +6 -6
  116. package/dist/tools/registry.d.ts +6 -0
  117. package/dist/tools/shared.d.ts +5 -1
  118. package/dist/tracing/index.js +1 -1
  119. package/dist/webhooks/index.js +11 -11
  120. package/package.json +1 -1
@@ -3,22 +3,23 @@ import {
3
3
  mergeFields,
4
4
  resolveCapabilities,
5
5
  resolveFields
6
- } from "../chunks/chunk-HIAK2GCI.js";
6
+ } from "../chunks/chunk-A7DLJUA6.js";
7
7
  import {
8
8
  recordBase
9
- } from "../chunks/chunk-LVZGIKNF.js";
9
+ } from "../chunks/chunk-U5AK6OJM.js";
10
10
  import "../chunks/chunk-POBAY3TI.js";
11
11
  import "../chunks/chunk-QGRZDTX4.js";
12
12
  import {
13
13
  parseRef
14
- } from "../chunks/chunk-YW6FFVSZ.js";
14
+ } from "../chunks/chunk-HXB2IOJJ.js";
15
15
  import {
16
16
  OutboundError,
17
17
  makeErrorMapper
18
- } from "../chunks/chunk-QFC4ZHD3.js";
18
+ } from "../chunks/chunk-XYHM4KHC.js";
19
19
  import {
20
20
  count,
21
- field
21
+ field,
22
+ text
22
23
  } from "../chunks/chunk-45TXPJW7.js";
23
24
 
24
25
  // src/combine/route.ts
@@ -66,7 +67,15 @@ var waiting = (next, size) => {
66
67
  return index === null || index >= size ? [] : [{ index, next: field(entry, "next") ?? void 0 }];
67
68
  });
68
69
  };
69
- var pageTogether = async (members, ctx, query, read) => {
70
+ var inOrder = (pages) => pages.flat();
71
+ var inTurn = (pages) => {
72
+ const longest = Math.max(0, ...pages.map((items) => items.length));
73
+ return Array.from(
74
+ { length: longest },
75
+ (_, at) => pages.flatMap((items) => items.slice(at, at + 1))
76
+ ).flat();
77
+ };
78
+ var pageTogether = async (members, ctx, query, read, merge = inOrder) => {
70
79
  const pages = await Promise.all(
71
80
  waiting(query.next, members.length).flatMap((at) => {
72
81
  const member = members[at.index];
@@ -81,9 +90,10 @@ var pageTogether = async (members, ctx, query, read) => {
81
90
  const unfinished = pages.flatMap(
82
91
  ({ index, page }) => page.next === void 0 ? [] : [{ member: index, next: page.next }]
83
92
  );
84
- const items = pages.flatMap(({ page }) => page.items);
93
+ const items = merge(pages.map(({ page }) => page.items));
85
94
  return unfinished.length === 0 ? { items } : { items, next: { together: unfinished } };
86
95
  };
96
+ var takeInTurn = (members, ctx, query, read) => pageTogether(members, ctx, query, read, inTurn);
87
97
 
88
98
  // src/combine/account.ts
89
99
  var missing = (member, method) => new OutboundError(
@@ -167,6 +177,99 @@ var accountReads = (members) => ({
167
177
  }
168
178
  });
169
179
 
180
+ // src/combine/newest.ts
181
+ var spotsOf = (next, size) => {
182
+ const listed = field(next, "newest");
183
+ if (!Array.isArray(listed)) {
184
+ return Array.from({ length: size }, (_, index) => ({
185
+ after: void 0,
186
+ at: void 0,
187
+ index
188
+ }));
189
+ }
190
+ return listed.flatMap((entry) => {
191
+ const index = count(field(entry, "member"));
192
+ const ref = text(field(entry, "afterRef"));
193
+ return index === null || index >= size ? [] : [
194
+ {
195
+ after: ref === null ? void 0 : { ref, sentAt: text(field(entry, "afterSentAt")) },
196
+ at: field(entry, "at") ?? void 0,
197
+ index
198
+ }
199
+ ];
200
+ });
201
+ };
202
+ var timeOf = (item) => item.sentAt === null ? 0 : Date.parse(item.sentAt);
203
+ var resumeAt = (items, spot) => {
204
+ const { after } = spot;
205
+ if (after === void 0) {
206
+ return 0;
207
+ }
208
+ const given = items.findIndex((item) => item.ref === after.ref);
209
+ if (given !== -1) {
210
+ return given + 1;
211
+ }
212
+ const older = items.findIndex((item) => timeOf(item) < timeOf(after));
213
+ return older === -1 ? items.length : older;
214
+ };
215
+ var pageNewestFirst = async (members, ctx, query, readPage) => {
216
+ const read = await Promise.all(
217
+ spotsOf(query.next, members.length).flatMap((spot) => {
218
+ const member = members[spot.index];
219
+ return member === void 0 ? [] : [
220
+ readPage(member, ctx.forAdapter(member), spot.at).then((page) => {
221
+ const sorted = page.items.toSorted(
222
+ (a, b) => timeOf(b) - timeOf(a)
223
+ );
224
+ return {
225
+ left: sorted.slice(resumeAt(sorted, spot)),
226
+ page: { ...page, items: sorted },
227
+ spot
228
+ };
229
+ })
230
+ ];
231
+ })
232
+ );
233
+ const floor = Math.max(
234
+ -Infinity,
235
+ ...read.flatMap(({ page }) => {
236
+ if (page.next === void 0) {
237
+ return [];
238
+ }
239
+ const last = page.items.at(-1);
240
+ return [last === void 0 ? Infinity : timeOf(last)];
241
+ })
242
+ );
243
+ const given = read.map(({ left }) => {
244
+ const waits = left.findIndex((item) => timeOf(item) < floor);
245
+ return left.slice(0, waits === -1 ? left.length : waits);
246
+ });
247
+ const items = given.flat().toSorted((a, b) => timeOf(b) - timeOf(a));
248
+ const waiting2 = read.flatMap(({ left, page, spot }, at) => {
249
+ const out = given[at] ?? [];
250
+ const last = out.at(-1);
251
+ if (out.length < left.length) {
252
+ return [
253
+ {
254
+ afterRef: last?.ref ?? spot.after?.ref ?? null,
255
+ afterSentAt: last === void 0 ? spot.after?.sentAt ?? null : last.sentAt,
256
+ at: spot.at ?? null,
257
+ member: spot.index
258
+ }
259
+ ];
260
+ }
261
+ return page.next === void 0 ? [] : [
262
+ {
263
+ afterRef: null,
264
+ afterSentAt: null,
265
+ at: page.next,
266
+ member: spot.index
267
+ }
268
+ ];
269
+ });
270
+ return waiting2.length === 0 ? { items } : { items, next: { newest: waiting2 } };
271
+ };
272
+
170
273
  // src/combine/adapter.ts
171
274
  var MATURITY_ORDER = ["unverified", "beta", "stable"];
172
275
  var weakestMaturity = (members) => MATURITY_ORDER.find(
@@ -207,9 +310,9 @@ var missing2 = (member, method) => new OutboundError(
207
310
  provider: member.name
208
311
  }
209
312
  );
210
- var scopedOrAcross = (members, ctx, query, read) => {
313
+ var scopedOrAcross = (members, ctx, query, read, across) => {
211
314
  if (query.campaignId === void 0) {
212
- return pageAcross(
315
+ return across(
213
316
  members,
214
317
  ctx,
215
318
  query,
@@ -228,7 +331,7 @@ var lists = (members) => ({
228
331
  routed.ctx
229
332
  );
230
333
  }
231
- return pageAcross(
334
+ return takeInTurn(
232
335
  members,
233
336
  ctx,
234
337
  query,
@@ -261,8 +364,21 @@ var lists = (members) => ({
261
364
  async (member, memberCtx, next) => await readLeads(member, memberCtx, { ...query, next })
262
365
  );
263
366
  }
264
- return scopedOrAcross(members, ctx, query, readLeads);
367
+ return scopedOrAcross(members, ctx, query, readLeads, takeInTurn);
265
368
  },
369
+ // One workspace per member, named by its label. No request is made.
370
+ listWorkspaces: () => Promise.resolve({
371
+ items: members.map((member) => ({
372
+ ...recordBase(
373
+ { provider: member.name, workspaceId: member.workspaceId },
374
+ member.workspaceId,
375
+ null
376
+ ),
377
+ name: member.workspaceId
378
+ }))
379
+ })
380
+ });
381
+ var messageLists = (members) => ({
266
382
  listMessages: (query, ctx) => {
267
383
  const lead = query.leadId === void 0 ? void 0 : routeRef(members, ctx, query.leadId, "Lead");
268
384
  return scopedOrAcross(
@@ -274,32 +390,34 @@ var lists = (members) => ({
274
390
  throw missing2(member, "listMessages");
275
391
  }
276
392
  return member.listMessages({ ...scoped, leadId: lead?.id }, memberCtx);
277
- }
393
+ },
394
+ pageNewestFirst
278
395
  );
279
396
  },
280
- listReplies: (query, ctx) => scopedOrAcross(members, ctx, query, (member, memberCtx, scoped) => {
281
- if (member.listReplies === void 0) {
282
- throw missing2(member, "listReplies");
283
- }
284
- return member.listReplies(scoped, memberCtx);
285
- }),
286
- listSenders: (query, ctx) => scopedOrAcross(members, ctx, query, (member, memberCtx, scoped) => {
287
- if (member.listSenders === void 0) {
288
- throw missing2(member, "listSenders");
289
- }
290
- return member.listSenders(scoped, memberCtx);
291
- }),
292
- // One workspace per member, named by its label. No request is made.
293
- listWorkspaces: () => Promise.resolve({
294
- items: members.map((member) => ({
295
- ...recordBase(
296
- { provider: member.name, workspaceId: member.workspaceId },
297
- member.workspaceId,
298
- null
299
- ),
300
- name: member.workspaceId
301
- }))
302
- })
397
+ listReplies: (query, ctx) => scopedOrAcross(
398
+ members,
399
+ ctx,
400
+ query,
401
+ (member, memberCtx, scoped) => {
402
+ if (member.listReplies === void 0) {
403
+ throw missing2(member, "listReplies");
404
+ }
405
+ return member.listReplies(scoped, memberCtx);
406
+ },
407
+ pageNewestFirst
408
+ ),
409
+ listSenders: (query, ctx) => scopedOrAcross(
410
+ members,
411
+ ctx,
412
+ query,
413
+ (member, memberCtx, scoped) => {
414
+ if (member.listSenders === void 0) {
415
+ throw missing2(member, "listSenders");
416
+ }
417
+ return member.listSenders(scoped, memberCtx);
418
+ },
419
+ takeInTurn
420
+ )
303
421
  });
304
422
  var lookups = (members) => ({
305
423
  getCampaign: (id, ctx) => {
@@ -356,6 +474,7 @@ var combine = (members) => {
356
474
  );
357
475
  return {
358
476
  ...lists(members),
477
+ ...messageLists(members),
359
478
  ...lookups(members),
360
479
  ...accountReads(members),
361
480
  capabilities: {
@@ -0,0 +1,18 @@
1
+ import type { Adapter, AdapterContext, Page, PageQuery } from "../internal/adapter.ts";
2
+ import type { ReadPage } from "./route.ts";
3
+ interface Dated {
4
+ readonly ref: string;
5
+ readonly sentAt: string | null;
6
+ }
7
+ /**
8
+ * One page of messages or replies across every member, newest first. Each
9
+ * member's page is put in that order first: a vendor that lists by another
10
+ * time, or by conversation, can hand out a page whose records are not. Each
11
+ * member lists newest first, so a member with more pages has nothing newer
12
+ * left than the oldest record of its page. A record is given out only once no
13
+ * member with more pages can still hold a newer one; the rest wait, and the
14
+ * cursor reads their page again and resumes after the last record given out.
15
+ * A cap on the walk therefore keeps exactly the newest records of all.
16
+ */
17
+ export declare const pageNewestFirst: <Item extends Dated>(members: readonly Adapter[], ctx: AdapterContext, query: PageQuery, readPage: ReadPage<Item>) => Promise<Page<Item>>;
18
+ export {};
@@ -15,10 +15,24 @@ 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
+ /** How the pages of several members, in the members' order, become one page. */
19
+ export type Merge<Item> = (pages: readonly (readonly Item[])[]) => Item[];
18
20
  /**
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.
21
+ * The members' items taken in turn, one from each, so a cap on the walk
22
+ * (`max_campaigns`, `--limit`) leaves every member its share instead of
23
+ * filling up on the first one.
23
24
  */
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>>;
25
+ export declare const inTurn: <Item>(pages: readonly (readonly Item[])[]) => Item[];
26
+ /** Reads one member's page from `next`, its own cursor. */
27
+ export type ReadPage<Item> = (member: Adapter, memberCtx: AdapterContext, next: Json | undefined) => Promise<Page<Item>>;
28
+ /** How a listing that spans every member reads them and makes one page. */
29
+ export type Across<Item> = (members: readonly Adapter[], ctx: AdapterContext, query: PageQuery, read: ReadPage<Item>) => Promise<Page<Item>>;
30
+ /**
31
+ * One page of a listing read from every member at the same time. `merge`
32
+ * says how their items become one page; by default they keep the members'
33
+ * order, as a lookup by exact address wants. The cursor holds each member
34
+ * still to finish, so the next page asks only those, again side by side.
35
+ */
36
+ export declare const pageTogether: <Item>(members: readonly Adapter[], ctx: AdapterContext, query: PageQuery, read: (member: Adapter, memberCtx: AdapterContext, next: Json | undefined) => Promise<Page<Item>>, merge?: Merge<Item>) => Promise<Page<Item>>;
37
+ /** Every member read at once, their records taken one from each in turn. */
38
+ export declare const takeInTurn: <Item>(members: readonly Adapter[], ctx: AdapterContext, query: PageQuery, read: ReadPage<Item>) => Promise<Page<Item>>;
@@ -22,13 +22,15 @@ import {
22
22
  toTag,
23
23
  toWebhook,
24
24
  toWorkspace
25
- } from "../chunks/chunk-I7DXXGNZ.js";
25
+ } from "../chunks/chunk-UZLFZZ2U.js";
26
26
  import {
27
27
  applyTracking,
28
28
  ownTracking,
29
29
  unlessFailed
30
- } from "../chunks/chunk-DNPNTD5W.js";
31
- import "../chunks/chunk-OK3GAZMT.js";
30
+ } from "../chunks/chunk-VVDBCQLK.js";
31
+ import {
32
+ notNegative
33
+ } from "../chunks/chunk-SYUMA3CP.js";
32
34
  import {
33
35
  flatMapPage,
34
36
  mapPage,
@@ -38,7 +40,7 @@ import {
38
40
  import {
39
41
  toVariant,
40
42
  variantKey
41
- } from "../chunks/chunk-BNDHEDHD.js";
43
+ } from "../chunks/chunk-UOJG4VYF.js";
42
44
  import "../chunks/chunk-FALWG5U3.js";
43
45
  import {
44
46
  defineNative,
@@ -49,27 +51,27 @@ import {
49
51
  import {
50
52
  recordBase,
51
53
  refTo
52
- } from "../chunks/chunk-LVZGIKNF.js";
54
+ } from "../chunks/chunk-U5AK6OJM.js";
53
55
  import "../chunks/chunk-POBAY3TI.js";
54
56
  import {
55
57
  emptyCounts,
56
58
  metricRow,
57
59
  sumCounts
58
- } from "../chunks/chunk-M2VXGLLZ.js";
60
+ } from "../chunks/chunk-CPACP4YD.js";
59
61
  import "../chunks/chunk-QGRZDTX4.js";
60
62
  import {
61
63
  assertWorkspaceId
62
- } from "../chunks/chunk-YW6FFVSZ.js";
63
- import "../chunks/chunk-NAWZ73QS.js";
64
- import "../chunks/chunk-FHKSLCVW.js";
64
+ } from "../chunks/chunk-HXB2IOJJ.js";
65
+ import "../chunks/chunk-YFJ3OQZS.js";
66
+ import "../chunks/chunk-KVAG5GM2.js";
65
67
  import {
66
68
  readEnv,
67
69
  requireCredential
68
- } from "../chunks/chunk-UFQ4WMLU.js";
70
+ } from "../chunks/chunk-NFWWA7MI.js";
69
71
  import {
70
72
  OutboundError,
71
73
  makeErrorMapper
72
- } from "../chunks/chunk-QFC4ZHD3.js";
74
+ } from "../chunks/chunk-XYHM4KHC.js";
73
75
  import {
74
76
  count,
75
77
  field,
@@ -313,12 +315,17 @@ var groupSteps = (rows) => {
313
315
  );
314
316
  };
315
317
  var stepRows = (body) => objects(field(field(body, "data"), "sequence_steps"));
316
- var toSequence = (identity, campaignId, body) => {
318
+ var toSequence = (identity, campaignId, body, note) => {
317
319
  const steps = groupSteps(stepRows(body)).map(
318
320
  (group, index) => ({
319
321
  action: "email",
320
322
  branch: null,
321
- delayDays: count(group.head.wait_in_days),
323
+ delayDays: notNegative(count(group.head.wait_in_days), {
324
+ note,
325
+ unit: "days",
326
+ vendor: "EmailBison",
327
+ what: `Step ${index + 1}'s wait`
328
+ }),
322
329
  index,
323
330
  parentIndex: index === 0 ? null : index - 1,
324
331
  variants: group.variants.map(
@@ -603,7 +610,8 @@ var readers = (client) => {
603
610
  await client.get(
604
611
  ctx,
605
612
  `/api/campaigns/v1.1/${segment3(id2)}/sequence-steps`
606
- )
613
+ ),
614
+ ctx.note
607
615
  ),
608
616
  listCampaigns: async (query, ctx) => {
609
617
  if (query.senderId !== void 0) {
@@ -1,9 +1,10 @@
1
1
  import type { Sequence } from "../internal/entities.ts";
2
2
  import type { Json, JsonObject } from "../internal/json.ts";
3
+ import type { Note } from "../internal/notes.ts";
3
4
  import type { Identity } from "../internal/record.ts";
4
5
  /** The step list of a sequence answer: `data.sequence_steps`. */
5
6
  export declare const stepRows: (body: Json | undefined) => JsonObject[];
6
- export declare const toSequence: (identity: Identity, campaignId: string, body: Json) => Sequence;
7
+ export declare const toSequence: (identity: Identity, campaignId: string, body: Json, note: Note) => Sequence;
7
8
  export interface StepPlace {
8
9
  readonly stepIndex: number;
9
10
  readonly variantKey: string;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OutboundError
3
- } from "../chunks/chunk-QFC4ZHD3.js";
3
+ } from "../chunks/chunk-XYHM4KHC.js";
4
4
  import {
5
5
  isJsonObject,
6
6
  toJson
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  cacheKey
3
- } from "../chunks/chunk-IVH3NMQZ.js";
4
- import "../chunks/chunk-FHKSLCVW.js";
3
+ } from "../chunks/chunk-WROJO6XB.js";
4
+ import "../chunks/chunk-KVAG5GM2.js";
5
5
  import {
6
6
  OutboundError
7
- } from "../chunks/chunk-QFC4ZHD3.js";
7
+ } from "../chunks/chunk-XYHM4KHC.js";
8
8
  import "../chunks/chunk-45TXPJW7.js";
9
9
 
10
10
  // src/failover/index.ts
@@ -5,16 +5,16 @@ import "../chunks/chunk-QGRZDTX4.js";
5
5
  import {
6
6
  makeRef,
7
7
  parseRef
8
- } from "../chunks/chunk-YW6FFVSZ.js";
8
+ } from "../chunks/chunk-HXB2IOJJ.js";
9
9
  import {
10
10
  profileSlug
11
- } from "../chunks/chunk-NAWZ73QS.js";
11
+ } from "../chunks/chunk-YFJ3OQZS.js";
12
12
  import {
13
13
  stableId
14
- } from "../chunks/chunk-FHKSLCVW.js";
14
+ } from "../chunks/chunk-KVAG5GM2.js";
15
15
  import {
16
16
  OutboundError
17
- } from "../chunks/chunk-QFC4ZHD3.js";
17
+ } from "../chunks/chunk-XYHM4KHC.js";
18
18
  import {
19
19
  field,
20
20
  objects,
@@ -46,10 +46,14 @@ export declare const costs: {
46
46
  "messages.list": {
47
47
  pageSize: number;
48
48
  perPage: number;
49
+ perPageAtMost: number;
50
+ perWalk: number;
49
51
  };
50
52
  "replies.list": {
51
53
  pageSize: number;
52
54
  perPage: number;
55
+ perPageAtMost: number;
56
+ perWalk: number;
53
57
  };
54
58
  "senders.get": {
55
59
  perPage: number;
@@ -0,0 +1,23 @@
1
+ import type { AdapterContext, MessageQuery, ReplyQuery } from "../internal/adapter.ts";
2
+ import type { Json, JsonObject } from "../internal/json.ts";
3
+ import type { HeyReachClient } from "./client.ts";
4
+ export declare const CONVERSATIONS_PATH = "/inbox/GetConversationsV3";
5
+ export type ConversationQuery = MessageQuery | ReplyQuery;
6
+ /** A conversation and the campaign it was listed under, if any. */
7
+ export interface Listed {
8
+ readonly conversation: JsonObject;
9
+ readonly campaignId: string | null;
10
+ }
11
+ export interface ConversationPage {
12
+ readonly items: readonly Listed[];
13
+ readonly next: Json | undefined;
14
+ }
15
+ /** One page of one campaign's conversations, as HeyReach filters them. */
16
+ export declare const campaignConversations: (client: HeyReachClient, ctx: AdapterContext, query: ConversationQuery & {
17
+ readonly campaignId: string;
18
+ }) => Promise<ConversationPage>;
19
+ /**
20
+ * One page of every campaign's conversations, one campaign after the other,
21
+ * then with `inbox` one page of the conversations that belong to none.
22
+ */
23
+ export declare const everyConversation: (client: HeyReachClient, ctx: AdapterContext, query: ConversationQuery, inbox: boolean) => Promise<ConversationPage>;
@@ -1,6 +1,5 @@
1
1
  import type { Adapter } from "../internal/adapter.ts";
2
2
  import type { HeyReachClient } from "./client.ts";
3
- export declare const CONVERSATIONS_PATH = "/inbox/GetConversationsV3";
4
3
  type InboxReaders = Pick<Adapter, "listMessages" | "listReplies">;
5
4
  /** Messages and replies, read from one page of conversations at a time. */
6
5
  export declare const inboxReaders: (client: HeyReachClient) => InboxReaders;