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
@@ -2,6 +2,7 @@ import type { AdapterContext } from "../internal/adapter.ts";
2
2
  import { OutboundError } from "../internal/errors.ts";
3
3
  import type { Json, JsonObject } from "../internal/json.ts";
4
4
  import type { SmartleadClient } from "./client.ts";
5
+ import type { LeadCategories } from "./map.ts";
5
6
  export declare const pageSize: (limit: number | undefined, max?: number) => number;
6
7
  export declare const segment: (id: string) => string;
7
8
  /** The ids in a cursor or a vendor list, as strings. */
@@ -12,17 +13,17 @@ export declare const objectOf: (client: SmartleadClient, body: Json, what: strin
12
13
  export declare const campaignList: (client: SmartleadClient, ctx: AdapterContext) => Promise<JsonObject[]>;
13
14
  export declare const campaignIds: (client: SmartleadClient, ctx: AdapterContext) => Promise<string[]>;
14
15
  export interface OffsetPage {
15
- readonly rows: JsonObject[];
16
+ readonly items: JsonObject[];
16
17
  readonly next: number | undefined;
17
18
  }
18
19
  export declare const offsetPage: (client: SmartleadClient, ctx: AdapterContext, path: string, page: {
19
20
  readonly limit: number;
20
21
  readonly offset: number;
21
22
  }) => Promise<OffsetPage>;
22
- /** Lead category id -> the account's own name for it. */
23
- export type CategoryNames = Readonly<Record<string, string>>;
24
23
  /**
25
- * The category names, read from `GET /leads/fetch-categories` once per walk
24
+ * The lead categories, read from `GET /leads/fetch-categories` once per walk
26
25
  * and then carried in the cursor.
27
26
  */
28
- export declare const categoryNames: (client: SmartleadClient, ctx: AdapterContext, next: Json | undefined) => Promise<CategoryNames>;
27
+ export declare const leadCategories: (client: SmartleadClient, ctx: AdapterContext, next: Json | undefined) => Promise<LeadCategories>;
28
+ /** The categories as they travel in a lead cursor. */
29
+ export declare const categoriesCursor: (categories: LeadCategories) => JsonObject;
@@ -1,2 +1,3 @@
1
1
  import type { EventFormat } from "../internal/adapter.ts";
2
+ export declare const EVENT_TYPES: Map<string, "unknown" | "campaign.status_changed" | "lead.status_changed" | "lead.unsubscribed" | "linkedin.connection_accepted" | "linkedin.connection_sent" | "linkedin.message_received" | "linkedin.message_sent" | "meeting.booked" | "message.bounced" | "message.clicked" | "message.opened" | "message.sent" | "reply.categorized" | "reply.received" | "sender.status_changed">;
2
3
  export declare const smartleadEvents: (provider: string) => EventFormat;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  stableId
3
- } from "../chunks/chunk-LNCOGBMI.js";
3
+ } from "../chunks/chunk-FHKSLCVW.js";
4
4
  import {
5
5
  OutboundError
6
- } from "../chunks/chunk-LOXBLQ3I.js";
7
- import "../chunks/chunk-QZNNCXXD.js";
6
+ } from "../chunks/chunk-E7JHLNLG.js";
7
+ import "../chunks/chunk-VQSCHOBV.js";
8
8
 
9
9
  // src/sync/plugin.ts
10
10
  var memoryCheckpointStore = () => {
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  createTools
3
- } from "../chunks/chunk-OCV66TS2.js";
4
- import "../chunks/chunk-WW746NJF.js";
5
- import "../chunks/chunk-WAM6N4OF.js";
6
- import "../chunks/chunk-LOXBLQ3I.js";
7
- import "../chunks/chunk-QZNNCXXD.js";
3
+ } from "../chunks/chunk-AFU5E5QB.js";
4
+ import "../chunks/chunk-HZCTYL22.js";
5
+ import "../chunks/chunk-YOTW5ESM.js";
6
+ import "../chunks/chunk-4PSO6JEK.js";
7
+ import "../chunks/chunk-LVYG7XZJ.js";
8
+ import "../chunks/chunk-E7JHLNLG.js";
9
+ import "../chunks/chunk-VQSCHOBV.js";
8
10
 
9
11
  // src/tools/ai-sdk.ts
10
12
  import { jsonSchema, tool } from "ai";
@@ -18,9 +18,9 @@ declare const trendInput: z.ZodObject<{
18
18
  campaign: z.ZodString;
19
19
  from: z.ZodString;
20
20
  metric: z.ZodDefault<z.ZodEnum<{
21
+ positive: "positive";
21
22
  bounced: "bounced";
22
23
  replied: "replied";
23
- positive: "positive";
24
24
  connectionsAccepted: "connectionsAccepted";
25
25
  connectionsSent: "connectionsSent";
26
26
  contacted: "contacted";
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  createTools
3
- } from "../chunks/chunk-OCV66TS2.js";
4
- import "../chunks/chunk-WW746NJF.js";
5
- import "../chunks/chunk-WAM6N4OF.js";
6
- import "../chunks/chunk-LOXBLQ3I.js";
7
- import "../chunks/chunk-QZNNCXXD.js";
3
+ } from "../chunks/chunk-AFU5E5QB.js";
4
+ import "../chunks/chunk-HZCTYL22.js";
5
+ import "../chunks/chunk-YOTW5ESM.js";
6
+ import "../chunks/chunk-4PSO6JEK.js";
7
+ import "../chunks/chunk-LVYG7XZJ.js";
8
+ import "../chunks/chunk-E7JHLNLG.js";
9
+ import "../chunks/chunk-VQSCHOBV.js";
8
10
 
9
11
  // src/tools/claude-agent.ts
10
12
  import { createSdkMcpServer, tool } from "@anthropic-ai/claude-agent-sdk";
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  openaiTools
3
- } from "../chunks/chunk-F7MKFVIG.js";
3
+ } from "../chunks/chunk-R3Y56YVF.js";
4
4
  import {
5
5
  DEFAULT_BODY_CHARS,
6
6
  TOOL_NAMES,
7
7
  UNTRUSTED_NOTE,
8
8
  createTools
9
- } from "../chunks/chunk-OCV66TS2.js";
10
- import "../chunks/chunk-WW746NJF.js";
11
- import "../chunks/chunk-WAM6N4OF.js";
12
- import "../chunks/chunk-LOXBLQ3I.js";
13
- import "../chunks/chunk-QZNNCXXD.js";
9
+ } from "../chunks/chunk-AFU5E5QB.js";
10
+ import "../chunks/chunk-HZCTYL22.js";
11
+ import "../chunks/chunk-YOTW5ESM.js";
12
+ import "../chunks/chunk-4PSO6JEK.js";
13
+ import "../chunks/chunk-LVYG7XZJ.js";
14
+ import "../chunks/chunk-E7JHLNLG.js";
15
+ import "../chunks/chunk-VQSCHOBV.js";
14
16
  export {
15
17
  DEFAULT_BODY_CHARS,
16
18
  TOOL_NAMES,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OutboundError
3
- } from "../chunks/chunk-LOXBLQ3I.js";
4
- import "../chunks/chunk-QZNNCXXD.js";
3
+ } from "../chunks/chunk-E7JHLNLG.js";
4
+ import "../chunks/chunk-VQSCHOBV.js";
5
5
 
6
6
  // src/tracing/index.ts
7
7
  var OK = 1;
@@ -1,26 +1,27 @@
1
1
  import {
2
2
  instantlyEvents
3
- } from "../chunks/chunk-FZF6CLPX.js";
3
+ } from "../chunks/chunk-SBIZDCRY.js";
4
4
  import {
5
5
  smartleadEvents
6
- } from "../chunks/chunk-Q465X22Y.js";
6
+ } from "../chunks/chunk-PURHK3JU.js";
7
7
  import {
8
8
  heyreachEvents
9
- } from "../chunks/chunk-R6AM4GJR.js";
9
+ } from "../chunks/chunk-DJ2IUQEU.js";
10
+ import "../chunks/chunk-FKH5N47I.js";
10
11
  import {
11
12
  stableId
12
- } from "../chunks/chunk-LNCOGBMI.js";
13
- import "../chunks/chunk-IBC52BX3.js";
13
+ } from "../chunks/chunk-FHKSLCVW.js";
14
+ import "../chunks/chunk-U2D34ARZ.js";
14
15
  import {
15
16
  SCHEMA_VERSION
16
- } from "../chunks/chunk-WAM6N4OF.js";
17
- import "../chunks/chunk-ZGHQYZEH.js";
17
+ } from "../chunks/chunk-4PSO6JEK.js";
18
+ import "../chunks/chunk-LVYG7XZJ.js";
18
19
  import {
19
20
  OutboundError
20
- } from "../chunks/chunk-LOXBLQ3I.js";
21
+ } from "../chunks/chunk-E7JHLNLG.js";
21
22
  import {
22
23
  parseJson
23
- } from "../chunks/chunk-QZNNCXXD.js";
24
+ } from "../chunks/chunk-VQSCHOBV.js";
24
25
 
25
26
  // src/webhooks/secret.ts
26
27
  var encoder = new TextEncoder();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "outbound-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "One small, typed, read-only API over outbound sending tools.",
5
5
  "keywords": [
6
6
  "cold-email",
@@ -1,232 +0,0 @@
1
- import {
2
- stableId
3
- } from "./chunk-LNCOGBMI.js";
4
- import {
5
- recordBase,
6
- refTo
7
- } from "./chunk-IBC52BX3.js";
8
- import {
9
- SCHEMA_VERSION
10
- } from "./chunk-WAM6N4OF.js";
11
- import {
12
- compactObject,
13
- count,
14
- emailAddress,
15
- field,
16
- flag,
17
- isJsonObject,
18
- isString,
19
- objects,
20
- text,
21
- timestamp
22
- } from "./chunk-QZNNCXXD.js";
23
-
24
- // src/instantly/map.ts
25
- var CAMPAIGN_STATUS = /* @__PURE__ */ new Map([
26
- [-99, "paused"],
27
- [-2, "paused"],
28
- [-1, "paused"],
29
- [0, "draft"],
30
- [1, "active"],
31
- [2, "paused"],
32
- [3, "completed"],
33
- [4, "active"]
34
- ]);
35
- var campaignStatusCode = (status) => (/* @__PURE__ */ new Map([
36
- ["completed", 3],
37
- ["draft", 0]
38
- ])).get(status);
39
- var toCampaign = (identity, raw, tags = []) => ({
40
- ...recordBase(identity, text(raw.id) ?? "", raw),
41
- channel: "email",
42
- createdAt: timestamp(raw.timestamp_created),
43
- name: text(raw.name) ?? "",
44
- status: CAMPAIGN_STATUS.get(count(raw.status) ?? Number.NaN) ?? "unknown",
45
- tags: [...tags]
46
- });
47
- var DELAY_DAYS = /* @__PURE__ */ new Map([
48
- ["days", 1],
49
- ["hours", 1 / 24],
50
- ["minutes", 1 / 1440]
51
- ]);
52
- var days = (value, unit) => {
53
- const delay = count(value);
54
- const perUnit = DELAY_DAYS.get(text(unit) ?? "days");
55
- return delay === null || perUnit === void 0 ? null : delay * perUnit;
56
- };
57
- var variantKey = (index) => String.fromCodePoint(65 + index);
58
- var waitBefore = (step, previous, subsequence) => {
59
- if (previous !== void 0) {
60
- return days(previous.delay, previous.delay_unit);
61
- }
62
- return subsequence ? days(step.pre_delay, step.pre_delay_unit) : 0;
63
- };
64
- var toSteps = (sequences, subsequence) => {
65
- const steps = objects(objects(sequences)[0]?.steps);
66
- return steps.map((step, index) => ({
67
- action: text(step.type) ?? "email",
68
- branch: null,
69
- delayDays: waitBefore(step, steps[index - 1], subsequence),
70
- index,
71
- parentIndex: index === 0 ? null : index - 1,
72
- variants: objects(step.variants).map((variant, variantIndex) => {
73
- const subject = text(variant.subject);
74
- const body = text(variant.body);
75
- return {
76
- body,
77
- contentHash: stableId(subject, body),
78
- subject,
79
- variantKey: variantKey(variantIndex)
80
- };
81
- })
82
- }));
83
- };
84
- var toSequence = (identity, raw) => {
85
- const id = text(raw.id) ?? "";
86
- return {
87
- ...recordBase(identity, id, raw.sequences ?? null),
88
- campaignRef: refTo(identity, id) ?? "",
89
- kind: "main",
90
- name: null,
91
- steps: toSteps(raw.sequences, false)
92
- };
93
- };
94
- var toSubsequence = (identity, raw, campaignId) => ({
95
- ...recordBase(identity, text(raw.id) ?? "", raw),
96
- campaignRef: refTo(identity, text(raw.parent_campaign) ?? campaignId) ?? "",
97
- kind: "subsequence",
98
- name: text(raw.name),
99
- steps: toSteps(raw.sequences, true)
100
- });
101
- var SENDER_STATUS = /* @__PURE__ */ new Map([
102
- [-3, "error"],
103
- [-2, "error"],
104
- [-1, "disconnected"],
105
- [1, "active"],
106
- [2, "paused"],
107
- [3, "paused"]
108
- ]);
109
- var fullName = (raw) => {
110
- const name = [text(raw.first_name), text(raw.last_name)].filter((part) => part !== null).join(" ");
111
- return name === "" ? null : name;
112
- };
113
- var toSender = (identity, raw) => {
114
- const address = emailAddress(raw.email);
115
- const warmupStatus = count(raw.warmup_status);
116
- return {
117
- ...recordBase(identity, address ?? "", raw),
118
- address,
119
- dailyLimit: count(raw.daily_limit),
120
- kind: "mailbox",
121
- linkedinUrl: null,
122
- name: fullName(raw),
123
- status: SENDER_STATUS.get(count(raw.status) ?? Number.NaN) ?? "unknown",
124
- warmup: warmupStatus === null && count(raw.stat_warmup_score) === null ? null : {
125
- enabled: warmupStatus === null ? null : warmupStatus === 1,
126
- score: count(raw.stat_warmup_score)
127
- }
128
- };
129
- };
130
- var toWorkspace = (identity, raw) => ({
131
- ...recordBase(identity, text(raw.id) ?? identity.workspaceId, raw),
132
- name: text(raw.name) ?? identity.workspaceId
133
- });
134
- var listEnvelope = (body) => ({
135
- items: objects(isJsonObject(body) ? body.items : body),
136
- next: text(field(body, "next_starting_after")) ?? void 0
137
- });
138
-
139
- // src/instantly/webhooks.ts
140
- var EVENT_TYPES = /* @__PURE__ */ new Map([
141
- ["account_error", "sender.status_changed"],
142
- ["auto_reply_received", "reply.received"],
143
- ["campaign_completed", "campaign.status_changed"],
144
- ["email_bounced", "message.bounced"],
145
- ["email_link_clicked", "message.clicked"],
146
- ["email_opened", "message.opened"],
147
- ["email_sent", "message.sent"],
148
- ["lead_closed", "reply.categorized"],
149
- ["lead_interested", "reply.categorized"],
150
- ["lead_meeting_booked", "meeting.booked"],
151
- ["lead_meeting_completed", "lead.status_changed"],
152
- ["lead_neutral", "reply.categorized"],
153
- ["lead_not_interested", "reply.categorized"],
154
- ["lead_out_of_office", "reply.categorized"],
155
- ["lead_unsubscribed", "lead.unsubscribed"],
156
- ["lead_wrong_person", "reply.categorized"],
157
- ["link_clicked", "message.clicked"],
158
- ["reply_received", "reply.received"]
159
- ]);
160
- var CATEGORIES = /* @__PURE__ */ new Map([
161
- ["lead_closed", "positive"],
162
- ["lead_interested", "positive"],
163
- ["lead_neutral", "neutral"],
164
- ["lead_not_interested", "negative"],
165
- ["lead_out_of_office", "ooo"],
166
- ["lead_wrong_person", "negative"]
167
- ]);
168
- var fromOne = (value) => {
169
- const number = count(value);
170
- return number === null || number < 1 ? null : number - 1;
171
- };
172
- var eventData = (name, body) => {
173
- const variant = fromOne(body.variant);
174
- return compactObject({
175
- campaignName: text(body.campaign_name),
176
- category: CATEGORIES.get(name),
177
- isAuto: name === "auto_reply_received" ? true : void 0,
178
- isFirst: flag(body.is_first),
179
- leadEmail: emailAddress(body.lead_email),
180
- stepIndex: fromOne(body.step),
181
- subject: text(body.reply_subject) ?? text(body.email_subject),
182
- text: text(body.reply_text) ?? text(body.email_text),
183
- variantKey: variant === null ? null : variantKey(variant),
184
- vendorEvent: name
185
- });
186
- };
187
- var toEvent = (identity, body) => {
188
- const name = text(body.event_type) ?? "";
189
- const occurredAt = timestamp(body.timestamp);
190
- const campaignId = text(body.campaign_id);
191
- const messageId = text(body.email_id);
192
- return {
193
- campaignRef: refTo(identity, campaignId),
194
- data: eventData(name, body),
195
- // Instantly sends no event id, so the id is built from what identifies the event.
196
- id: stableId(
197
- identity.provider,
198
- name,
199
- campaignId,
200
- text(body.lead_email),
201
- messageId,
202
- occurredAt
203
- ),
204
- // A webhook names the lead by address only, so there is no lead ref.
205
- leadRef: null,
206
- messageRef: refTo(identity, messageId),
207
- occurredAt,
208
- provider: identity.provider,
209
- raw: body,
210
- schemaVersion: SCHEMA_VERSION,
211
- senderRef: refTo(identity, emailAddress(body.email_account)),
212
- type: EVENT_TYPES.get(name) ?? "unknown",
213
- workspaceId: identity.workspaceId
214
- };
215
- };
216
- var detect = (request) => isJsonObject(request.body) && isString(request.body.event_type) && request.body.event_type === request.body.event_type.toLowerCase() && "workspace" in request.body && "timestamp" in request.body;
217
- var instantlyEvents = (provider) => ({
218
- detect,
219
- parse: (request, workspaceId) => isJsonObject(request.body) ? [toEvent({ provider, workspaceId }, request.body)] : []
220
- });
221
-
222
- export {
223
- campaignStatusCode,
224
- toCampaign,
225
- variantKey,
226
- toSequence,
227
- toSubsequence,
228
- toSender,
229
- toWorkspace,
230
- listEnvelope,
231
- instantlyEvents
232
- };
@@ -1,53 +0,0 @@
1
- // src/internal/text.ts
2
- var ENTITIES = /* @__PURE__ */ new Map([
3
- ["amp", "&"],
4
- ["apos", "'"],
5
- ["gt", ">"],
6
- ["lt", "<"],
7
- ["nbsp", " "],
8
- ["quot", '"']
9
- ]);
10
- var decodeEntity = (match, body) => {
11
- if (body.startsWith("#")) {
12
- const code = body[1]?.toLowerCase() === "x" ? Number.parseInt(body.slice(2), 16) : Number(body.slice(1));
13
- return Number.isInteger(code) && code > 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
14
- }
15
- return ENTITIES.get(body.toLowerCase()) ?? match;
16
- };
17
- var looksLikeHtml = (value) => /<[a-z!/][^>]*>/iu.test(value);
18
- var htmlToText = (html) => html.replaceAll(/<(?:script|style)\b[^>]*>[\s\S]*?<\/(?:script|style)>/giu, "").replaceAll(/<br\s*\/?>/giu, "\n").replaceAll(/<\/(?:p|div|li|tr|h[1-6])>/giu, "\n").replaceAll(/<[^>]+>/gu, "").replaceAll(
19
- /&(?<body>#x?[\da-f]+|[a-z]+);/giu,
20
- (match, body) => decodeEntity(match, body)
21
- ).replaceAll(/[ \t]+\n/gu, "\n").replaceAll(/\n{3,}/gu, "\n\n").trim();
22
- var QUOTE_MARKERS = [
23
- /^On .{0,200}wrote:\s*$/u,
24
- /^-{2,}\s*Original Message\s*-{2,}\s*$/iu,
25
- /^From:\s.+$/u,
26
- /^Sent from my \w+/u,
27
- /^_{10,}\s*$/u
28
- ];
29
- var stripQuotedHistory = (text) => {
30
- const lines = text.split(/\r?\n/u);
31
- const cut = lines.findIndex(
32
- (line, index) => QUOTE_MARKERS.some((marker) => marker.test(line.trim())) || // A run of ">" lines to the end of the message is the quoted thread.
33
- line.trimStart().startsWith(">") && lines.slice(index).every(
34
- (rest) => rest.trim() === "" || rest.trimStart().startsWith(">")
35
- )
36
- );
37
- return (cut === -1 ? lines : lines.slice(0, cut)).join("\n").trim();
38
- };
39
- var normalizeBody = (body, includeBody) => {
40
- if (!includeBody || body === null || body.trim() === "") {
41
- return { bodyHtml: null, bodyText: null };
42
- }
43
- const isHtml = looksLikeHtml(body);
44
- const plain = stripQuotedHistory(isHtml ? htmlToText(body) : body);
45
- return {
46
- bodyHtml: isHtml ? body : null,
47
- bodyText: plain === "" ? null : plain
48
- };
49
- };
50
-
51
- export {
52
- normalizeBody
53
- };
@@ -1,65 +0,0 @@
1
- import {
2
- readEnv
3
- } from "./chunk-CMQ5ZHLZ.js";
4
- import {
5
- PROVIDER_ENV,
6
- providers
7
- } from "./chunk-XC6CZP73.js";
8
- import {
9
- OutboundError
10
- } from "./chunk-LOXBLQ3I.js";
11
-
12
- // src/loader/index.ts
13
- var LOADERS = /* @__PURE__ */ new Map([
14
- [
15
- "instantly",
16
- async () => {
17
- const { instantly } = await import("../instantly/index.js");
18
- return instantly();
19
- }
20
- ],
21
- [
22
- "smartlead",
23
- async () => {
24
- const { smartlead } = await import("../smartlead/index.js");
25
- return smartlead();
26
- }
27
- ],
28
- [
29
- "heyreach",
30
- async () => {
31
- const { heyreach } = await import("../heyreach/index.js");
32
- return heyreach();
33
- }
34
- ],
35
- [
36
- "memory",
37
- async () => {
38
- const { demoData, memory } = await import("../memory/index.js");
39
- return memory({ data: demoData() });
40
- }
41
- ]
42
- ]);
43
- var loadableProviders = () => [...LOADERS.keys()].toSorted();
44
- var fromEnv = async (options = {}) => {
45
- const id = options.provider ?? readEnv(PROVIDER_ENV);
46
- if (id === void 0) {
47
- throw new OutboundError(
48
- "Invalid",
49
- `Set ${PROVIDER_ENV} to one of: ${providers.map((provider) => provider.id).join(", ")}`
50
- );
51
- }
52
- const load = LOADERS.get(id);
53
- if (load === void 0) {
54
- throw new OutboundError(
55
- "Invalid",
56
- `Unknown provider "${id}". Known providers: ${loadableProviders().join(", ")}`
57
- );
58
- }
59
- return await load();
60
- };
61
-
62
- export {
63
- loadableProviders,
64
- fromEnv
65
- };
@@ -1,100 +0,0 @@
1
- import {
2
- OutboundError
3
- } from "./chunk-LOXBLQ3I.js";
4
-
5
- // src/internal/capabilities.ts
6
- var NO_CAPABILITIES = {
7
- blocklist: false,
8
- "campaigns.settings": false,
9
- "campaigns.status": false,
10
- deletionDetection: false,
11
- "events.parse": false,
12
- "events.verify": false,
13
- "leads.byCampaign": false,
14
- "leads.engagement": false,
15
- "leads.get": false,
16
- "leads.list": false,
17
- "leads.lookup": false,
18
- "leads.since": false,
19
- "leads.timeline": false,
20
- "lists.leads": false,
21
- "lists.list": false,
22
- "messages.body": false,
23
- "messages.byThread": false,
24
- "messages.list": false,
25
- "messages.since": false,
26
- native: false,
27
- "replies.category": false,
28
- "replies.list": false,
29
- "replies.since": false,
30
- "senders.byCampaign": false,
31
- "senders.get": false,
32
- "senders.health": false,
33
- "senders.list": false,
34
- "senders.warmup": false,
35
- sequence: false,
36
- "sequence.subsequences": false,
37
- "stats.byDay": false,
38
- "stats.bySender": false,
39
- "stats.byStep": false,
40
- "stats.campaign": false,
41
- "stats.workspace": false,
42
- tags: false,
43
- "webhooks.list": false,
44
- workspaces: false
45
- };
46
- var RANK = /* @__PURE__ */ new Map([
47
- ["client", 1],
48
- ["derived", 1],
49
- ["exact", 2],
50
- ["false", 0],
51
- ["full", 2],
52
- ["sampled", 1],
53
- ["secret", 1],
54
- ["server", 2],
55
- ["signature", 2],
56
- ["true", 2],
57
- ["vendor", 2]
58
- ]);
59
- var rank = (value) => RANK.get(String(value)) ?? 0;
60
- var resolveCapabilities = (declared = {}) => ({
61
- ...NO_CAPABILITIES,
62
- ...declared
63
- });
64
- var weaker = (left, right) => rank(right) < rank(left) ? right : left;
65
- var narrowKey = (target, key, other) => {
66
- target[key] = weaker(target[key], other[key]);
67
- };
68
- var CAPABILITY_KEYS = Object.keys(NO_CAPABILITIES);
69
- var intersectCapabilities = (first, ...rest) => {
70
- const result = { ...first };
71
- for (const other of rest) {
72
- for (const key of CAPABILITY_KEYS) {
73
- narrowKey(result, key, other);
74
- }
75
- }
76
- return result;
77
- };
78
- var requireCapability = (gate, key, what) => {
79
- const value = gate.capabilities[key];
80
- if (value === false) {
81
- const plugin = gate.narrowedBy.get(key);
82
- const reason = plugin === void 0 ? `the ${gate.provider} adapter does not support it` : `the ${plugin} plugin turned it off`;
83
- throw new OutboundError(
84
- "Unsupported",
85
- `${what} is not available: ${reason} (${key})`,
86
- {
87
- provider: gate.provider
88
- }
89
- );
90
- }
91
- return value;
92
- };
93
-
94
- export {
95
- NO_CAPABILITIES,
96
- resolveCapabilities,
97
- CAPABILITY_KEYS,
98
- intersectCapabilities,
99
- requireCapability
100
- };
@@ -1,6 +0,0 @@
1
- // src/internal/native.ts
2
- var defineNative = (catalog) => catalog;
3
-
4
- export {
5
- defineNative
6
- };