outbound-sdk 0.0.0-stage → 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 (284) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -2
  3. package/dist/alerts/index.d.ts +2 -0
  4. package/dist/alerts/index.js +140 -0
  5. package/dist/alerts/plugin.d.ts +58 -0
  6. package/dist/audit/index.d.ts +33 -0
  7. package/dist/audit/index.js +60 -0
  8. package/dist/benchmarks/index.d.ts +29 -0
  9. package/dist/benchmarks/index.js +72 -0
  10. package/dist/budget/index.d.ts +21 -0
  11. package/dist/budget/index.js +71 -0
  12. package/dist/cache/index.d.ts +31 -0
  13. package/dist/cache/index.js +11 -0
  14. package/dist/cards/content.d.ts +43 -0
  15. package/dist/cards/copy-cards.d.ts +2 -0
  16. package/dist/cards/format.d.ts +39 -0
  17. package/dist/cards/index.d.ts +9 -0
  18. package/dist/cards/index.js +2070 -0
  19. package/dist/cards/notify-cards.d.ts +14 -0
  20. package/dist/cards/ops-cards.d.ts +2 -0
  21. package/dist/cards/parts.d.ts +22 -0
  22. package/dist/cards/people-cards.d.ts +2 -0
  23. package/dist/cards/render.d.ts +28 -0
  24. package/dist/cards/sender-cards.d.ts +2 -0
  25. package/dist/cards/slack-rich.d.ts +19 -0
  26. package/dist/cards/slack-text.d.ts +10 -0
  27. package/dist/cards/slack.d.ts +21 -0
  28. package/dist/cards/spec.d.ts +86 -0
  29. package/dist/cards/tool-cards.d.ts +4 -0
  30. package/dist/chunks/chunk-4O2HRTTI.js +75 -0
  31. package/dist/chunks/chunk-4PSO6JEK.js +357 -0
  32. package/dist/chunks/chunk-6CVZOUHB.js +152 -0
  33. package/dist/chunks/chunk-AFU5E5QB.js +714 -0
  34. package/dist/chunks/chunk-DJ2IUQEU.js +111 -0
  35. package/dist/chunks/chunk-E7JHLNLG.js +187 -0
  36. package/dist/chunks/chunk-FHKSLCVW.js +154 -0
  37. package/dist/chunks/chunk-FKH5N47I.js +40 -0
  38. package/dist/chunks/chunk-HZCTYL22.js +29 -0
  39. package/dist/chunks/chunk-IPUYZD4O.js +25 -0
  40. package/dist/chunks/chunk-IVH3NMQZ.js +61 -0
  41. package/dist/chunks/chunk-LVYG7XZJ.js +45 -0
  42. package/dist/chunks/chunk-NAKXLBA6.js +30 -0
  43. package/dist/chunks/chunk-NAWZ73QS.js +22 -0
  44. package/dist/chunks/chunk-PMSSUWD7.js +636 -0
  45. package/dist/chunks/chunk-PURHK3JU.js +432 -0
  46. package/dist/chunks/chunk-R3Y56YVF.js +43 -0
  47. package/dist/chunks/chunk-RCZ7ZZFU.js +92 -0
  48. package/dist/chunks/chunk-SBIZDCRY.js +106 -0
  49. package/dist/chunks/chunk-U2D34ARZ.js +41 -0
  50. package/dist/chunks/chunk-UAT3JSJZ.js +331 -0
  51. package/dist/chunks/chunk-VQSCHOBV.js +111 -0
  52. package/dist/chunks/chunk-XC6CZP73.js +80 -0
  53. package/dist/chunks/chunk-XNFESPZH.js +2307 -0
  54. package/dist/chunks/chunk-YOTW5ESM.js +118 -0
  55. package/dist/cli/bin.d.ts +2 -0
  56. package/dist/cli/bin.js +35 -0
  57. package/dist/cli/commands.d.ts +19 -0
  58. package/dist/cli/config.d.ts +22 -0
  59. package/dist/cli/index.d.ts +17 -0
  60. package/dist/cli/index.js +30 -0
  61. package/dist/cli/mcp.d.ts +14 -0
  62. package/dist/cli/stdio.d.ts +9 -0
  63. package/dist/clients/index.d.ts +2 -0
  64. package/dist/clients/index.js +117 -0
  65. package/dist/clients/plugin.d.ts +42 -0
  66. package/dist/combine/account.d.ts +4 -0
  67. package/dist/combine/adapter.d.ts +9 -0
  68. package/dist/combine/index.d.ts +2 -0
  69. package/dist/combine/index.js +420 -0
  70. package/dist/combine/route.d.ts +24 -0
  71. package/dist/exporter/index.d.ts +29 -0
  72. package/dist/exporter/index.js +77 -0
  73. package/dist/failover/index.d.ts +11 -0
  74. package/dist/failover/index.js +45 -0
  75. package/dist/fixtures/index.d.ts +27 -0
  76. package/dist/fixtures/index.js +260 -0
  77. package/dist/fixtures/scrub.d.ts +5 -0
  78. package/dist/heyreach/account.d.ts +11 -0
  79. package/dist/heyreach/adapter.d.ts +5 -0
  80. package/dist/heyreach/capabilities.d.ts +70 -0
  81. package/dist/heyreach/client.d.ts +18 -0
  82. package/dist/heyreach/inbox.d.ts +7 -0
  83. package/dist/heyreach/index.d.ts +25 -0
  84. package/dist/heyreach/index.js +1931 -0
  85. package/dist/heyreach/leads.d.ts +4 -0
  86. package/dist/heyreach/lookup.d.ts +15 -0
  87. package/dist/heyreach/map-account.d.ts +31 -0
  88. package/dist/heyreach/map-sequence.d.ts +5 -0
  89. package/dist/heyreach/map-stats.d.ts +13 -0
  90. package/dist/heyreach/map.d.ts +37 -0
  91. package/dist/heyreach/native-organization.d.ts +128 -0
  92. package/dist/heyreach/native-voice.d.ts +106 -0
  93. package/dist/heyreach/native.d.ts +496 -0
  94. package/dist/heyreach/paging.d.ts +7 -0
  95. package/dist/heyreach/webhooks.d.ts +3 -0
  96. package/dist/identity/index.d.ts +3 -0
  97. package/dist/identity/index.js +159 -0
  98. package/dist/identity/keys.d.ts +9 -0
  99. package/dist/identity/plugin.d.ts +34 -0
  100. package/dist/index.d.ts +33 -0
  101. package/dist/index.js +131 -0
  102. package/dist/insights/copy/copy-audit.d.ts +55 -0
  103. package/dist/insights/copy/copy-checks.d.ts +44 -0
  104. package/dist/insights/copy/copy-reuse.d.ts +59 -0
  105. package/dist/insights/copy/index.d.ts +67 -0
  106. package/dist/insights/copy/reply-timing.d.ts +63 -0
  107. package/dist/insights/copy/shared.d.ts +53 -0
  108. package/dist/insights/copy/step-funnel.d.ts +66 -0
  109. package/dist/insights/copy/variant-test.d.ts +64 -0
  110. package/dist/insights/define.d.ts +98 -0
  111. package/dist/insights/index.d.ts +10 -0
  112. package/dist/insights/index.js +4937 -0
  113. package/dist/insights/ops/anomalies.d.ts +80 -0
  114. package/dist/insights/ops/campaign-diagnosis.d.ts +39 -0
  115. package/dist/insights/ops/campaign-ranking.d.ts +56 -0
  116. package/dist/insights/ops/channel-mix.d.ts +44 -0
  117. package/dist/insights/ops/client-report.d.ts +76 -0
  118. package/dist/insights/ops/diagnosis-checks.d.ts +48 -0
  119. package/dist/insights/ops/index.d.ts +135 -0
  120. package/dist/insights/ops/period-comparison.d.ts +86 -0
  121. package/dist/insights/ops/pipeline-forecast.d.ts +44 -0
  122. package/dist/insights/ops/shared.d.ts +155 -0
  123. package/dist/insights/ops/tag-rollup.d.ts +32 -0
  124. package/dist/insights/people/account-summary.d.ts +68 -0
  125. package/dist/insights/people/dropped-replies.d.ts +51 -0
  126. package/dist/insights/people/find.d.ts +18 -0
  127. package/dist/insights/people/hot-leads.d.ts +67 -0
  128. package/dist/insights/people/index.d.ts +88 -0
  129. package/dist/insights/people/lead-collisions.d.ts +43 -0
  130. package/dist/insights/people/person-summary.d.ts +46 -0
  131. package/dist/insights/people/personalization-gaps.d.ts +60 -0
  132. package/dist/insights/people/read.d.ts +40 -0
  133. package/dist/insights/people/suppression-check.d.ts +53 -0
  134. package/dist/insights/plugin.d.ts +40 -0
  135. package/dist/insights/registry.d.ts +335 -0
  136. package/dist/insights/senders/bounce-watch.d.ts +70 -0
  137. package/dist/insights/senders/domain-health.d.ts +69 -0
  138. package/dist/insights/senders/index.d.ts +74 -0
  139. package/dist/insights/senders/read.d.ts +37 -0
  140. package/dist/insights/senders/sender-capacity.d.ts +67 -0
  141. package/dist/insights/senders/sender-load.d.ts +52 -0
  142. package/dist/insights/senders/settings-audit.d.ts +48 -0
  143. package/dist/insights/senders/warmup-readiness.d.ts +39 -0
  144. package/dist/insights/stats.d.ts +45 -0
  145. package/dist/insights/tools.d.ts +16 -0
  146. package/dist/insights/types.d.ts +4 -0
  147. package/dist/instantly/adapter-account.d.ts +5 -0
  148. package/dist/instantly/adapter-mail.d.ts +3 -0
  149. package/dist/instantly/adapter.d.ts +7 -0
  150. package/dist/instantly/capabilities.d.ts +85 -0
  151. package/dist/instantly/client.d.ts +24 -0
  152. package/dist/instantly/index.d.ts +27 -0
  153. package/dist/instantly/index.js +2627 -0
  154. package/dist/instantly/map-account.d.ts +38 -0
  155. package/dist/instantly/map-lead.d.ts +18 -0
  156. package/dist/instantly/map-stats.d.ts +25 -0
  157. package/dist/instantly/map.d.ts +22 -0
  158. package/dist/instantly/native-agents-sales.d.ts +161 -0
  159. package/dist/instantly/native-agents.d.ts +156 -0
  160. package/dist/instantly/native-campaigns.d.ts +101 -0
  161. package/dist/instantly/native-leads.d.ts +93 -0
  162. package/dist/instantly/native-params.d.ts +7 -0
  163. package/dist/instantly/native-search.d.ts +82 -0
  164. package/dist/instantly/native-senders.d.ts +182 -0
  165. package/dist/instantly/native-supersearch.d.ts +149 -0
  166. package/dist/instantly/native-workspace.d.ts +170 -0
  167. package/dist/instantly/native.d.ts +1081 -0
  168. package/dist/instantly/pages.d.ts +29 -0
  169. package/dist/instantly/stats.d.ts +5 -0
  170. package/dist/instantly/webhooks.d.ts +3 -0
  171. package/dist/internal/adapter.d.ts +211 -0
  172. package/dist/internal/capabilities.d.ts +104 -0
  173. package/dist/internal/client.d.ts +15 -0
  174. package/dist/internal/concurrency.d.ts +8 -0
  175. package/dist/internal/cursor.d.ts +10 -0
  176. package/dist/internal/engine/budget.d.ts +44 -0
  177. package/dist/internal/engine/engine.d.ts +45 -0
  178. package/dist/internal/engine/rate-store.d.ts +25 -0
  179. package/dist/internal/engine/request.d.ts +34 -0
  180. package/dist/internal/engine/retry.d.ts +21 -0
  181. package/dist/internal/engine/runtime.d.ts +13 -0
  182. package/dist/internal/entities-account.d.ts +205 -0
  183. package/dist/internal/entities.d.ts +493 -0
  184. package/dist/internal/env.d.ts +4 -0
  185. package/dist/internal/errors.d.ts +62 -0
  186. package/dist/internal/fields.d.ts +462 -0
  187. package/dist/internal/hooks.d.ts +55 -0
  188. package/dist/internal/json.d.ts +49 -0
  189. package/dist/internal/lead-fields.d.ts +21 -0
  190. package/dist/internal/lead-status.d.ts +13 -0
  191. package/dist/internal/limits.d.ts +34 -0
  192. package/dist/internal/metrics.d.ts +64 -0
  193. package/dist/internal/native.d.ts +81 -0
  194. package/dist/internal/outbound/api.d.ts +292 -0
  195. package/dist/internal/outbound/collections.d.ts +31 -0
  196. package/dist/internal/outbound/core.d.ts +36 -0
  197. package/dist/internal/outbound/create.d.ts +16 -0
  198. package/dist/internal/outbound/handles.d.ts +7 -0
  199. package/dist/internal/outbound/native.d.ts +4 -0
  200. package/dist/internal/outbound/operation-shared.d.ts +28 -0
  201. package/dist/internal/outbound/operations-account.d.ts +41 -0
  202. package/dist/internal/outbound/operations.d.ts +42 -0
  203. package/dist/internal/outbound/outbound.d.ts +67 -0
  204. package/dist/internal/outbound/plugins.d.ts +40 -0
  205. package/dist/internal/outbound/raw.d.ts +9 -0
  206. package/dist/internal/outbound/specs-account.d.ts +20 -0
  207. package/dist/internal/outbound/specs.d.ts +14 -0
  208. package/dist/internal/outbound/stats.d.ts +7 -0
  209. package/dist/internal/outbound/validate.d.ts +5 -0
  210. package/dist/internal/outbound/walker.d.ts +22 -0
  211. package/dist/internal/page.d.ts +14 -0
  212. package/dist/internal/record.d.ts +36 -0
  213. package/dist/internal/records.d.ts +7 -0
  214. package/dist/internal/redact.d.ts +18 -0
  215. package/dist/internal/ref.d.ts +16 -0
  216. package/dist/internal/sequence.d.ts +14 -0
  217. package/dist/internal/sha256.d.ts +6 -0
  218. package/dist/internal/text.d.ts +11 -0
  219. package/dist/internal/url.d.ts +9 -0
  220. package/dist/loader/index.d.ts +24 -0
  221. package/dist/loader/index.js +16 -0
  222. package/dist/memory/account-reads.d.ts +5 -0
  223. package/dist/memory/account.d.ts +81 -0
  224. package/dist/memory/adapter.d.ts +16 -0
  225. package/dist/memory/data.d.ts +137 -0
  226. package/dist/memory/demo.d.ts +7 -0
  227. package/dist/memory/index.d.ts +5 -0
  228. package/dist/memory/index.js +867 -0
  229. package/dist/memory/stats.d.ts +6 -0
  230. package/dist/memory/store.d.ts +18 -0
  231. package/dist/providers/index.d.ts +22 -0
  232. package/dist/providers/index.js +10 -0
  233. package/dist/reconcile/index.d.ts +2 -0
  234. package/dist/reconcile/index.js +72 -0
  235. package/dist/reconcile/plugin.d.ts +55 -0
  236. package/dist/redact/index.d.ts +2 -0
  237. package/dist/redact/index.js +197 -0
  238. package/dist/redact/plugin.d.ts +22 -0
  239. package/dist/redis/index.d.ts +41 -0
  240. package/dist/redis/index.js +114 -0
  241. package/dist/smartlead/account.d.ts +5 -0
  242. package/dist/smartlead/adapter.d.ts +5 -0
  243. package/dist/smartlead/capabilities.d.ts +87 -0
  244. package/dist/smartlead/client.d.ts +18 -0
  245. package/dist/smartlead/hmac.d.ts +7 -0
  246. package/dist/smartlead/index.d.ts +24 -0
  247. package/dist/smartlead/index.js +2329 -0
  248. package/dist/smartlead/leads.d.ts +9 -0
  249. package/dist/smartlead/lookup.d.ts +8 -0
  250. package/dist/smartlead/mail.d.ts +5 -0
  251. package/dist/smartlead/map-account.d.ts +34 -0
  252. package/dist/smartlead/map-messages.d.ts +31 -0
  253. package/dist/smartlead/map-stats.d.ts +36 -0
  254. package/dist/smartlead/map.d.ts +62 -0
  255. package/dist/smartlead/native-analytics.d.ts +242 -0
  256. package/dist/smartlead/native-campaigns.d.ts +211 -0
  257. package/dist/smartlead/native-inbox.d.ts +141 -0
  258. package/dist/smartlead/native-params.d.ts +12 -0
  259. package/dist/smartlead/native-services.d.ts +204 -0
  260. package/dist/smartlead/native.d.ts +785 -0
  261. package/dist/smartlead/shared.d.ts +29 -0
  262. package/dist/smartlead/stats.d.ts +5 -0
  263. package/dist/smartlead/webhooks.d.ts +3 -0
  264. package/dist/sync/index.d.ts +2 -0
  265. package/dist/sync/index.js +158 -0
  266. package/dist/sync/plugin.d.ts +58 -0
  267. package/dist/tools/account-tools.d.ts +21 -0
  268. package/dist/tools/ai-sdk.d.ts +8 -0
  269. package/dist/tools/ai-sdk.js +28 -0
  270. package/dist/tools/campaign-tools.d.ts +59 -0
  271. package/dist/tools/claude-agent.d.ts +18 -0
  272. package/dist/tools/claude-agent.js +42 -0
  273. package/dist/tools/index.d.ts +28 -0
  274. package/dist/tools/index.js +22 -0
  275. package/dist/tools/people-tools.d.ts +19 -0
  276. package/dist/tools/registry.d.ts +34 -0
  277. package/dist/tools/shared.d.ts +75 -0
  278. package/dist/tracing/index.d.ts +25 -0
  279. package/dist/tracing/index.js +69 -0
  280. package/dist/webhooks/index.d.ts +3 -0
  281. package/dist/webhooks/index.js +227 -0
  282. package/dist/webhooks/parse.d.ts +41 -0
  283. package/dist/webhooks/secret.d.ts +4 -0
  284. package/package.json +181 -4
@@ -0,0 +1,42 @@
1
+ import type { CampaignQuery, LeadQuery, MessageQuery, PageQuery, ReplyQuery, SenderQuery, StatsQuery } from "../adapter.ts";
2
+ import type { DispatchTarget, OperationOutput } from "./operation-shared.ts";
3
+ import type { AccountOperation } from "./operations-account.ts";
4
+ export type { DispatchTarget, OperationOutput, OutboundRecord, } from "./operation-shared.ts";
5
+ type CoreOperation = {
6
+ readonly kind: "campaigns.get";
7
+ readonly id: string;
8
+ } | {
9
+ readonly kind: "campaigns.list";
10
+ readonly query: CampaignQuery;
11
+ } | {
12
+ readonly kind: "leads.get";
13
+ readonly id: string;
14
+ } | {
15
+ readonly kind: "leads.list";
16
+ readonly query: LeadQuery;
17
+ } | {
18
+ readonly kind: "messages.list";
19
+ readonly query: MessageQuery;
20
+ } | {
21
+ readonly kind: "replies.list";
22
+ readonly query: ReplyQuery;
23
+ } | {
24
+ readonly kind: "senders.get";
25
+ readonly id: string;
26
+ } | {
27
+ readonly kind: "senders.list";
28
+ readonly query: SenderQuery;
29
+ } | {
30
+ readonly kind: "sequence.get";
31
+ readonly id: string;
32
+ } | {
33
+ readonly kind: "stats";
34
+ readonly query: StatsQuery;
35
+ } | {
36
+ readonly kind: "workspaces.list";
37
+ readonly query: PageQuery;
38
+ };
39
+ export type Operation = AccountOperation | CoreOperation;
40
+ export type OperationKind = Operation["kind"];
41
+ /** The innermost step: hands one operation to the adapter. */
42
+ export declare const dispatch: (target: DispatchTarget, operation: Operation) => Promise<OperationOutput>;
@@ -0,0 +1,67 @@
1
+ import type { Adapter } from "../adapter.ts";
2
+ import type { Capabilities } from "../capabilities.ts";
3
+ import { RequestEngine } from "../engine/engine.ts";
4
+ import type { LimitsSnapshot, OperationOptions } from "../engine/engine.ts";
5
+ import type { RateLimitStore } from "../engine/rate-store.ts";
6
+ import type { Runtime } from "../engine/runtime.ts";
7
+ import type { BlockEntry, LeadList, PlacementTest, Tag, WebhookSubscription } from "../entities-account.ts";
8
+ import type { Campaign, Lead, Message, Reply, Sender, Workspace } from "../entities.ts";
9
+ import type { FieldCoverage } from "../fields.ts";
10
+ import type { OutboundHooks } from "../hooks.ts";
11
+ import type { NativeCatalog, NoNative } from "../native.ts";
12
+ import type { CampaignFilters, CampaignHandle, Collection, Estimate, EstimateQuery, LeadFilters, LeadHandle, ListHandle, MessageFilters, NativeClient, OutboundApi, RawClient, ReadCollection, ReplyFilters, SenderFilters, SenderHandle, StatsResult, ThreadHandle, TopLevelStatsOptions, WebhookFilters } from "./api.ts";
13
+ import type { OutboundPlugin } from "./plugins.ts";
14
+ export interface OutboundOptions<Native extends NativeCatalog = NoNative> extends OperationOptions {
15
+ readonly adapter: Adapter<Native>;
16
+ /** `plugins[0]` is the outermost layer. */
17
+ readonly plugins?: readonly OutboundPlugin[] | undefined;
18
+ readonly hooks?: OutboundHooks | undefined;
19
+ /** Where rate budgets are counted. Defaults to this process's memory. */
20
+ readonly rateLimitStore?: RateLimitStore | undefined;
21
+ /** The fraction of each vendor's published limit to use. Defaults to 0.5. */
22
+ readonly share?: number | undefined;
23
+ /** Lets `raw` send requests that are not reads. Off by default. */
24
+ readonly allowWrites?: boolean | undefined;
25
+ /** A replacement for the global `fetch`. */
26
+ readonly fetch?: typeof fetch | undefined;
27
+ /** Replaces the clock, timers and randomness. Meant for tests. */
28
+ readonly runtime?: Partial<Runtime> | undefined;
29
+ }
30
+ export declare class Outbound<Native extends NativeCatalog = NoNative> implements OutboundApi {
31
+ #private;
32
+ readonly campaigns: Collection<Campaign, CampaignFilters>;
33
+ readonly senders: Collection<Sender, SenderFilters>;
34
+ readonly leads: Collection<Lead, LeadFilters>;
35
+ readonly messages: ReadCollection<Message, MessageFilters>;
36
+ readonly replies: ReadCollection<Reply, ReplyFilters>;
37
+ readonly workspaces: ReadCollection<Workspace, Record<never, never>>;
38
+ readonly lists: Collection<LeadList, Record<never, never>>;
39
+ readonly blocklist: ReadCollection<BlockEntry, Record<never, never>>;
40
+ readonly tags: ReadCollection<Tag, Record<never, never>>;
41
+ readonly placementTests: ReadCollection<PlacementTest, Record<never, never>>;
42
+ readonly webhooks: Collection<WebhookSubscription, WebhookFilters>;
43
+ readonly raw: RawClient;
44
+ readonly native: NativeClient<Native>;
45
+ constructor(options: OutboundOptions<Native>, engine?: RequestEngine);
46
+ get provider(): string;
47
+ get workspaceId(): string;
48
+ get capabilities(): Capabilities;
49
+ get maturity(): Adapter["maturity"];
50
+ get caveats(): readonly string[];
51
+ get fields(): FieldCoverage;
52
+ /** The plugins on this instance, outermost first. */
53
+ get plugins(): readonly OutboundPlugin[];
54
+ campaign(id: string): CampaignHandle;
55
+ sender(id: string): SenderHandle;
56
+ lead(id: string): LeadHandle;
57
+ list(id: string): ListHandle;
58
+ thread(id: string): ThreadHandle;
59
+ /**
60
+ * The same instance scoped to one client or workspace. It keeps the
61
+ * plugins and what they add, so `outbound.workspace(id).insights` works.
62
+ */
63
+ workspace(id: string): this;
64
+ stats(options?: TopLevelStatsOptions): Promise<StatsResult>;
65
+ limits(): Promise<LimitsSnapshot[]>;
66
+ estimate(query: EstimateQuery): Estimate;
67
+ }
@@ -0,0 +1,40 @@
1
+ import type { Adapter } from "../adapter.ts";
2
+ import type { Capabilities, CapabilityKey } from "../capabilities.ts";
3
+ import type { CallState } from "../engine/request.ts";
4
+ import type { OutboundEvent } from "../entities.ts";
5
+ import type { OutboundHooks } from "../hooks.ts";
6
+ import type { OutboundApi } from "./api.ts";
7
+ import type { Operation, OperationOutput } from "./operations.ts";
8
+ export interface OperationInfo {
9
+ readonly provider: string;
10
+ readonly workspaceId: string;
11
+ readonly adapter: Adapter;
12
+ /** What the call has used so far. Plugins may read it and may add to it. */
13
+ readonly state: CallState;
14
+ }
15
+ export type NextOperation = (operation: Operation) => Promise<OperationOutput>;
16
+ export interface OutboundPlugin<Extension = unknown> {
17
+ /** Names the plugin in errors and diagnostics. */
18
+ readonly name: string;
19
+ /** Intercepts an operation. Call `next` to continue inward. */
20
+ readonly wrap?: (operation: Operation, next: NextOperation, info: OperationInfo) => Promise<OperationOutput>;
21
+ /** Returns the capabilities to advertise. Anything it widens is ignored. */
22
+ readonly capabilities?: (capabilities: Capabilities) => Capabilities;
23
+ /** Adds methods to the instance. A name that already exists is an error. */
24
+ readonly extend?: (outbound: OutboundApi) => Extension;
25
+ /** Observes calls and HTTP requests, alongside the instance's own hooks. */
26
+ readonly hooks?: OutboundHooks | undefined;
27
+ /** Rewrites a webhook event, or returns `null` to drop it. */
28
+ readonly event?: (event: OutboundEvent) => OutboundEvent | null;
29
+ }
30
+ export interface NarrowedCapabilities {
31
+ readonly capabilities: Capabilities;
32
+ readonly narrowedBy: ReadonlyMap<CapabilityKey, string>;
33
+ }
34
+ /** Applies each plugin's `capabilities` hook, recording who turned what off. */
35
+ export declare const narrowCapabilities: (declared: Capabilities, plugins: readonly OutboundPlugin[]) => NarrowedCapabilities;
36
+ /** Folds the plugins' `wrap` functions around the innermost step. */
37
+ export declare const composeOperations: (plugins: readonly OutboundPlugin[], innermost: (operation: Operation, info: OperationInfo) => Promise<OperationOutput>) => ((operation: Operation, info: OperationInfo) => Promise<OperationOutput>);
38
+ export declare const assertUniquePluginNames: (plugins: readonly OutboundPlugin[]) => void;
39
+ /** Defines on the instance what each plugin's `extend` returns. */
40
+ export declare const installExtensions: (outbound: OutboundApi, plugins: readonly OutboundPlugin[]) => void;
@@ -0,0 +1,9 @@
1
+ import type { RawClient } from "./api.ts";
2
+ import type { Core } from "./core.ts";
3
+ /**
4
+ * `nativeOffBy` names the plugin that turns the `native` capability off, when
5
+ * one does. It is asked for apart from the gate, because the gate records a
6
+ * plugin only for a capability the adapter declared, and raw exists on every
7
+ * adapter.
8
+ */
9
+ export declare const makeRawClient: (core: Core, nativeOffBy?: string | undefined) => RawClient;
@@ -0,0 +1,20 @@
1
+ import type { BlockEntry, CampaignProgress, CampaignSettings, LeadList, PlacementTest, SenderHealth, Tag, WebhookSubscription } from "../entities-account.ts";
2
+ import type { Sequence } from "../entities.ts";
3
+ import type { WebhookFilters } from "./api.ts";
4
+ import type { GetSpec, ListSpec } from "./collections.ts";
5
+ import type { Core } from "./core.ts";
6
+ type NoFilters = Record<never, never>;
7
+ export declare const settingsGet: (core: Core) => GetSpec<CampaignSettings>;
8
+ export declare const progressGet: (core: Core) => GetSpec<CampaignProgress>;
9
+ export declare const healthGet: (core: Core) => GetSpec<SenderHealth>;
10
+ export declare const subsequenceList: (core: Core) => ListSpec<Sequence, {
11
+ readonly campaignId?: string | undefined;
12
+ }>;
13
+ export declare const listList: (core: Core) => ListSpec<LeadList, NoFilters>;
14
+ export declare const listGet: (core: Core) => GetSpec<LeadList>;
15
+ export declare const webhookGet: (core: Core) => GetSpec<WebhookSubscription>;
16
+ export declare const blocklistList: (core: Core) => ListSpec<BlockEntry, NoFilters>;
17
+ export declare const placementTestList: (core: Core) => ListSpec<PlacementTest, NoFilters>;
18
+ export declare const tagList: (core: Core) => ListSpec<Tag, NoFilters>;
19
+ export declare const webhookList: (core: Core) => ListSpec<WebhookSubscription, WebhookFilters>;
20
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { Campaign, Lead, Message, Reply, Sender, Sequence, Workspace } from "../entities.ts";
2
+ import type { CampaignFilters, LeadFilters, MessageFilters, ReplyFilters, SenderFilters } from "./api.ts";
3
+ import type { GetSpec, ListSpec } from "./collections.ts";
4
+ import type { Core } from "./core.ts";
5
+ export declare const campaignList: (core: Core) => ListSpec<Campaign, CampaignFilters>;
6
+ export declare const campaignGet: () => GetSpec<Campaign>;
7
+ export declare const sequenceGet: (core: Core) => GetSpec<Sequence>;
8
+ export declare const senderList: (core: Core) => ListSpec<Sender, SenderFilters>;
9
+ export declare const senderGet: (core: Core) => GetSpec<Sender>;
10
+ export declare const leadList: (core: Core) => ListSpec<Lead, LeadFilters>;
11
+ export declare const leadGet: (core: Core) => GetSpec<Lead>;
12
+ export declare const messageList: (core: Core) => ListSpec<Message, MessageFilters>;
13
+ export declare const replyList: (core: Core) => ListSpec<Reply, ReplyFilters>;
14
+ export declare const workspaceList: (core: Core) => ListSpec<Workspace, Record<never, never>>;
@@ -0,0 +1,7 @@
1
+ import type { StatsResult, TopLevelStatsOptions } from "./api.ts";
2
+ import type { Core } from "./core.ts";
3
+ /**
4
+ * Counts for a scope, as totals or one row per day. Async, so a refused
5
+ * input or capability rejects like every other failure of the call.
6
+ */
7
+ export declare const readStats: (core: Core, options?: TopLevelStatsOptions) => Promise<StatsResult>;
@@ -0,0 +1,5 @@
1
+ import type { TimeRange } from "../adapter.ts";
2
+ export declare const normalizeRange: (range: TimeRange) => TimeRange;
3
+ export declare const assertDay: (value: string | undefined, name: string) => string | undefined;
4
+ export declare const assertLimit: (limit: number | undefined) => number | undefined;
5
+ export declare const assertId: (id: string, what: string) => string;
@@ -0,0 +1,22 @@
1
+ import type { CallState } from "../engine/request.ts";
2
+ import type { ListAll, PageResult, ResultMeta } from "./api.ts";
3
+ export interface WalkerOptions<Item> {
4
+ readonly cursor: string | undefined;
5
+ readonly max: number | undefined;
6
+ /** Fetches one page. `state` is shared by every page of the walk. */
7
+ readonly fetchPage: (cursor: string | undefined, state: CallState | undefined) => Promise<{
8
+ readonly page: PageResult<Item>;
9
+ readonly state: CallState;
10
+ }>;
11
+ /** A stable key used to drop records a shifting page returned twice. */
12
+ readonly keyOf: (item: Item) => string | undefined;
13
+ }
14
+ export declare class PageWalker<Item> implements ListAll<Item> {
15
+ #private;
16
+ constructor(options: WalkerOptions<Item>);
17
+ get cursor(): string | undefined;
18
+ get meta(): ResultMeta | undefined;
19
+ get truncated(): boolean;
20
+ [Symbol.asyncIterator](): AsyncGenerator<Item, void, undefined>;
21
+ toArray(): Promise<Item[]>;
22
+ }
@@ -0,0 +1,14 @@
1
+ import type { Page } from "./adapter.ts";
2
+ import type { Json, JsonObject } from "./json.ts";
3
+ /** The rows of one vendor page as they came, and where the next page starts. */
4
+ export interface RawPage {
5
+ readonly items: readonly JsonObject[];
6
+ readonly next?: Json | undefined;
7
+ }
8
+ /** Maps each row of a vendor page to a record and keeps the page's cursor. */
9
+ export declare const mapPage: <Item>(page: RawPage, toItem: (raw: JsonObject) => Item) => Page<Item>;
10
+ /**
11
+ * `mapPage` for a mapper that may skip a row: a row that maps to nothing,
12
+ * such as a block entry with no value, is left out and not returned empty.
13
+ */
14
+ export declare const flatMapPage: <Item>(page: RawPage, toItems: (raw: JsonObject) => readonly Item[]) => Page<Item>;
@@ -0,0 +1,36 @@
1
+ import type { EventData, EventType } from "./entities.ts";
2
+ import type { Json } from "./json.ts";
3
+ /** Which provider and workspace a record belongs to. */
4
+ export interface Identity {
5
+ readonly provider: string;
6
+ readonly workspaceId: string;
7
+ }
8
+ /** The fields every entity shares. Adapters spread this into each record. */
9
+ export declare const recordBase: (identity: Identity, sourceId: string | number, raw: Json) => {
10
+ provider: string;
11
+ raw: Json;
12
+ ref: string;
13
+ schemaVersion: 1;
14
+ sourceId: string;
15
+ workspaceId: string;
16
+ };
17
+ /** A ref to another record of the same provider and workspace, or `null`. */
18
+ export declare const refTo: (identity: Identity, sourceId: string | number | null | undefined) => string | null;
19
+ /** Refs to other records of the same provider and workspace, skipping empty ids. */
20
+ export declare const refsTo: (identity: Identity, sourceIds: readonly (string | number | null | undefined)[]) => string[];
21
+ /**
22
+ * The event types a webhook's vendor event names become, without repeats and
23
+ * in a fixed order. A name the adapter does not know, or maps to `unknown`,
24
+ * adds nothing.
25
+ */
26
+ export declare const eventTypesOf: (names: readonly string[], known: ReadonlyMap<string, EventType>) => EventType[];
27
+ /** The shared keys of an event's data, each with the type it must have. */
28
+ type SharedEventData = {
29
+ readonly [Key in keyof EventData as string extends Key ? never : Key]?: EventData[Key];
30
+ };
31
+ /**
32
+ * An event's `data` from what an adapter read: the shared keys are typed, a
33
+ * vendor's extras are any JSON, and a key with no value is left out.
34
+ */
35
+ export declare const eventData: (shared: SharedEventData, extras?: Readonly<Record<string, Json | undefined>>) => EventData;
36
+ export {};
@@ -0,0 +1,7 @@
1
+ export { campaignSchema, campaignStatusSchema, channelSchema, eventDataSchema, eventTypeSchema, evidenceSchema, leadProgressSchema, leadSchema, leadStatusSchema, mailProviderSchema, messageSchema, metricRowSchema, metricScopeSchema, outboundEventSchema, replyCategorySchema, replySchema, SCHEMA_VERSION, senderSchema, senderStatusSchema, sequenceSchema, workspaceSchema, } from "./entities.ts";
2
+ export type { Campaign, CampaignStatus, Channel, EventData, EventType, Evidence, Lead, LeadEngagement, LeadProgress, LeadStatus, MailProvider, Message, MetricRow, MetricScope, OutboundEvent, Reply, ReplyCategory, Sender, SenderStatus, Sequence, SequenceStep, SequenceVariant, Workspace, } from "./entities.ts";
3
+ export { blockEntrySchema, campaignProgressSchema, campaignSettingsSchema, leadListSchema, placementTestSchema, senderHealthSchema, tagSchema, webhookSubscriptionSchema, } from "./entities-account.ts";
4
+ export type { BlockEntry, CampaignProgress, CampaignSettings, Entity, LeadList, PlacementTest, SenderHealth, SendingWindow, Tag, WebhookSubscription, } from "./entities-account.ts";
5
+ export { resolveFields } from "./fields.ts";
6
+ export type { FieldCoverage, FieldDeclaration, FieldGrade, RecordName, } from "./fields.ts";
7
+ export type { LeadFieldMap } from "./lead-fields.ts";
@@ -0,0 +1,18 @@
1
+ export declare const REDACTED_KEY = "[redacted-key]";
2
+ export declare const REDACTED_EMAIL = "[redacted-email]";
3
+ /** Replaces every secret and every email address in `value`. */
4
+ export declare const redactText: (value: string, secrets?: readonly string[]) => string;
5
+ /** A URL safe to log: secrets and emails removed, including from the query. */
6
+ export declare const redactUrl: (url: string, secrets?: readonly string[]) => string;
7
+ /** A plain copy of a cause with every secret and email address removed. */
8
+ export type RedactedJson = boolean | number | string | null | readonly RedactedJson[] | {
9
+ readonly [key: string]: RedactedJson;
10
+ };
11
+ /**
12
+ * What an error keeps as its `cause`: a copy with every secret and email
13
+ * address removed. Loggers print the cause chain, and a vendor's error body
14
+ * or a network error can hold an address or echo the key. A vendor response
15
+ * becomes plain data; another Error becomes a new Error with the same name,
16
+ * message and stack, redacted.
17
+ */
18
+ export declare const redactCause: (cause: unknown, secrets?: readonly string[]) => Error | RedactedJson | undefined;
@@ -0,0 +1,16 @@
1
+ export interface RefParts {
2
+ readonly provider: string;
3
+ readonly workspaceId: string;
4
+ readonly sourceId: string;
5
+ }
6
+ /** Builds `provider:workspaceId:sourceId`. */
7
+ export declare const makeRef: (provider: string, workspaceId: string, sourceId: string | number) => string;
8
+ /** Splits a ref. The source id may itself contain colons. */
9
+ export declare const parseRef: (ref: string) => RefParts | null;
10
+ /**
11
+ * Accepts a ref or a bare vendor id and returns the vendor id for this
12
+ * adapter. A ref that belongs to another provider or workspace is rejected.
13
+ */
14
+ export declare const sourceIdFor: (id: string, provider: string, workspaceId: string) => string;
15
+ /** Workspace labels become part of every ref, so they cannot hold the separator. */
16
+ export declare const assertWorkspaceId: (workspaceId: string, provider: string) => string;
@@ -0,0 +1,14 @@
1
+ import type { SequenceVariant } from "./entities.ts";
2
+ import type { Json } from "./json.ts";
3
+ /** The key of a variant the vendor does not label: 0 is "A", 1 is "B". */
4
+ export declare const variantKey: (index: number) => string;
5
+ /**
6
+ * One variant of a step. `contentHash` is a hash of subject and body, so
7
+ * stats can tell old copy from new.
8
+ */
9
+ export declare const toVariant: (subject: string | null, body: string | null, key: string) => SequenceVariant;
10
+ /**
11
+ * A step or variant the vendor numbers from 1, as an index from 0. `null`
12
+ * when the value is not a number of 1 or more.
13
+ */
14
+ export declare const fromOne: (value: Json | undefined) => number | null;
@@ -0,0 +1,6 @@
1
+ /** The SHA-256 digest of `bytes`, as 32 bytes. */
2
+ export declare const sha256: (bytes: Uint8Array) => Uint8Array;
3
+ /** The SHA-256 digest of a UTF-8 string, as lowercase hex. */
4
+ export declare const sha256Hex: (input: string) => string;
5
+ /** A short stable id derived from the parts, for refs, event ids and cache keys. */
6
+ export declare const stableId: (...parts: (string | number | null | undefined)[]) => string;
@@ -0,0 +1,11 @@
1
+ export declare const looksLikeHtml: (value: string) => boolean;
2
+ /** Converts HTML to readable plain text. */
3
+ export declare const htmlToText: (html: string) => string;
4
+ /** Removes quoted history from a plain-text reply. */
5
+ export declare const stripQuotedHistory: (text: string) => string;
6
+ export interface MessageBody {
7
+ readonly bodyHtml: string | null;
8
+ readonly bodyText: string | null;
9
+ }
10
+ /** Normalizes a vendor body into kept HTML plus derived plain text. */
11
+ export declare const normalizeBody: (body: string | null, includeBody: boolean) => MessageBody;
@@ -0,0 +1,9 @@
1
+ export type QueryValue = string | number | boolean | null | undefined;
2
+ /** Joins a base URL and a path and appends the defined query values. */
3
+ export declare const buildUrl: (baseUrl: string, path: string, query?: Readonly<Record<string, QueryValue>>) => string;
4
+ /**
5
+ * The part of a LinkedIn profile URL that names the person, lowercased, or
6
+ * `null` when the text is not a profile URL. Two URLs for the same person can
7
+ * differ in scheme, host prefix, trailing slash and query; the slug does not.
8
+ */
9
+ export declare const profileSlug: (url: string | null | undefined) => string | null;
@@ -0,0 +1,24 @@
1
+ import type { Adapter } from "../internal/adapter.ts";
2
+ export interface FromEnvOptions {
3
+ /** Overrides `OUTBOUND_SDK_PROVIDER`. A provider id, or `all`, which is also the default. */
4
+ readonly provider?: string | undefined;
5
+ }
6
+ /** The provider ids `fromEnv` can load. */
7
+ export declare const loadableProviders: () => string[];
8
+ /**
9
+ * In place of a provider id: every provider whose key is set, behind one
10
+ * instance. A key added to the environment adds its tool; no code changes.
11
+ */
12
+ export declare const ALL_PROVIDERS = "all";
13
+ /**
14
+ * The providers whose every required variable is set, in catalog order. A
15
+ * provider that needs no key, such as `memory`, is never among them.
16
+ */
17
+ export declare const configuredProviders: () => string[];
18
+ /**
19
+ * Builds the adapter named by `OUTBOUND_SDK_PROVIDER`, reading its key from
20
+ * that adapter's own environment variables. `all` builds every provider whose
21
+ * key is set: one adapter alone, or several combined. With no provider named,
22
+ * it does the same as `all`.
23
+ */
24
+ export declare const fromEnv: (options?: FromEnvOptions) => Promise<Adapter>;
@@ -0,0 +1,16 @@
1
+ import {
2
+ ALL_PROVIDERS,
3
+ configuredProviders,
4
+ fromEnv,
5
+ loadableProviders
6
+ } from "../chunks/chunk-RCZ7ZZFU.js";
7
+ import "../chunks/chunk-IPUYZD4O.js";
8
+ import "../chunks/chunk-XC6CZP73.js";
9
+ import "../chunks/chunk-E7JHLNLG.js";
10
+ import "../chunks/chunk-VQSCHOBV.js";
11
+ export {
12
+ ALL_PROVIDERS,
13
+ configuredProviders,
14
+ fromEnv,
15
+ loadableProviders
16
+ };
@@ -0,0 +1,5 @@
1
+ import type { Adapter } from "../internal/adapter.ts";
2
+ import type { Store } from "./store.ts";
3
+ type AccountReads = Pick<Adapter, "getCampaignProgress" | "getCampaignSettings" | "getList" | "getSenderHealth" | "getWebhook" | "listBlocklist" | "listLists" | "listPlacementTests" | "listSubsequences" | "listTags" | "listWebhooks">;
4
+ export declare const accountReads: (store: Store) => AccountReads;
5
+ export {};
@@ -0,0 +1,81 @@
1
+ import type { BlockEntry, CampaignSettings, LeadList, PlacementTest, SenderHealth, SendingWindow, Tag, WebhookSubscription } from "../internal/entities-account.ts";
2
+ import type { EventType } from "../internal/entities.ts";
3
+ import type { Identity } from "../internal/record.ts";
4
+ export interface MemorySettings {
5
+ readonly schedule?: readonly Partial<SendingWindow>[];
6
+ readonly dailyLimit?: number;
7
+ readonly dailyNewLeads?: number;
8
+ readonly gapMinutes?: number;
9
+ readonly startDate?: string;
10
+ readonly endDate?: string;
11
+ readonly trackOpens?: boolean;
12
+ readonly trackClicks?: boolean;
13
+ readonly stopOnReply?: boolean;
14
+ readonly stopOnAutoReply?: boolean;
15
+ readonly plainText?: boolean;
16
+ }
17
+ export interface MemoryHealth {
18
+ readonly spf?: boolean;
19
+ readonly dkim?: boolean;
20
+ readonly dmarc?: boolean;
21
+ readonly mx?: boolean;
22
+ readonly connected?: boolean;
23
+ readonly blacklisted?: boolean;
24
+ readonly issues?: readonly string[];
25
+ readonly checkedAt?: string;
26
+ readonly warmup?: {
27
+ readonly sent?: number;
28
+ readonly received?: number;
29
+ readonly inbox?: number;
30
+ readonly spam?: number;
31
+ readonly score?: number;
32
+ };
33
+ }
34
+ export interface MemoryList {
35
+ readonly id: string;
36
+ readonly name?: string;
37
+ readonly kind?: LeadList["kind"];
38
+ readonly createdAt?: string;
39
+ }
40
+ export interface MemoryBlockEntry {
41
+ readonly id: string;
42
+ readonly value: string;
43
+ readonly kind?: BlockEntry["kind"];
44
+ readonly createdAt?: string;
45
+ }
46
+ export interface MemoryTag {
47
+ readonly id: string;
48
+ readonly name?: string;
49
+ readonly description?: string;
50
+ }
51
+ export interface MemoryPlacementTest {
52
+ readonly id: string;
53
+ readonly name?: string;
54
+ readonly status?: PlacementTest["status"];
55
+ readonly kind?: NonNullable<PlacementTest["kind"]>;
56
+ readonly campaignId?: string;
57
+ readonly createdAt?: string;
58
+ readonly nextRunAt?: string;
59
+ readonly startsAt?: string;
60
+ readonly endsAt?: string;
61
+ }
62
+ export interface MemoryWebhook {
63
+ readonly id: string;
64
+ readonly url: string;
65
+ readonly name?: string;
66
+ readonly events?: readonly string[];
67
+ readonly eventTypes?: readonly EventType[];
68
+ readonly active?: boolean;
69
+ readonly campaignId?: string;
70
+ readonly createdAt?: string;
71
+ }
72
+ export declare const toSettings: (identity: Identity, campaignId: string, seed: MemorySettings) => CampaignSettings;
73
+ export declare const toHealth: (identity: Identity, sender: {
74
+ readonly id: string;
75
+ readonly address?: string | undefined;
76
+ }, seed: MemoryHealth) => SenderHealth;
77
+ export declare const toList: (identity: Identity, seed: MemoryList, size: number) => LeadList;
78
+ export declare const toBlockEntry: (identity: Identity, seed: MemoryBlockEntry) => BlockEntry;
79
+ export declare const toTag: (identity: Identity, seed: MemoryTag) => Tag;
80
+ export declare const toWebhook: (identity: Identity, seed: MemoryWebhook) => WebhookSubscription;
81
+ export declare const toPlacementTest: (identity: Identity, seed: MemoryPlacementTest) => PlacementTest;
@@ -0,0 +1,16 @@
1
+ import type { Adapter } from "../internal/adapter.ts";
2
+ import type { CapabilityDeclaration } from "../internal/capabilities.ts";
3
+ import type { MemoryData } from "./data.ts";
4
+ export interface MemoryOptions {
5
+ readonly data?: MemoryData | undefined;
6
+ /** A label for this workspace. Defaults to `default`. */
7
+ readonly workspaceId?: string | undefined;
8
+ /** The provider name records carry. Defaults to `memory`. */
9
+ readonly name?: string | undefined;
10
+ /** Records per page. Defaults to 50. */
11
+ readonly pageSize?: number | undefined;
12
+ /** Overrides what the adapter declares, to exercise gating and fallbacks. */
13
+ readonly capabilities?: CapabilityDeclaration | undefined;
14
+ }
15
+ /** An adapter over data held in memory. */
16
+ export declare const memory: (options?: MemoryOptions) => Adapter;