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,34 @@
1
+ export interface RateWindow {
2
+ /** Requests allowed in the window. */
3
+ readonly requests: number;
4
+ /** Window length in milliseconds. */
5
+ readonly perMs: number;
6
+ }
7
+ export interface RateLimitHeaders {
8
+ /** Header holding the requests left in the current window. */
9
+ readonly remaining?: string | undefined;
10
+ /** Header holding when the window resets. */
11
+ readonly reset?: string | undefined;
12
+ /** How to read `reset`: seconds until reset, or an epoch in seconds. */
13
+ readonly resetUnit?: "epoch-seconds" | "seconds" | undefined;
14
+ }
15
+ export interface LimitDeclaration {
16
+ /** The vendor's published limits. A request must fit every window. */
17
+ readonly windows: readonly RateWindow[];
18
+ /** Requests in flight at once for one credential. Defaults to 8. */
19
+ readonly concurrency?: number | undefined;
20
+ /** Endpoints with their own stricter cap, on top of `windows`. */
21
+ readonly lanes?: Readonly<Record<string, readonly RateWindow[]>> | undefined;
22
+ /** Rate-limit headers the vendor sends, when it sends any. */
23
+ readonly headers?: RateLimitHeaders | undefined;
24
+ /** Where the numbers came from, and whether they were confirmed. */
25
+ readonly source: string;
26
+ }
27
+ export declare const DEFAULT_CONCURRENCY = 8;
28
+ /**
29
+ * The fraction of a vendor's published limit the SDK uses by default. The
30
+ * limit is shared with the customer's other tools, so we leave room for them.
31
+ */
32
+ export declare const DEFAULT_SHARE = 0.5;
33
+ /** Scales a window by `share`, never below one request. */
34
+ export declare const scaleWindow: (window: RateWindow, share: number) => RateWindow;
@@ -0,0 +1,64 @@
1
+ import type { MetricRow, MetricScope } from "./entities.ts";
2
+ import type { Identity } from "./record.ts";
3
+ export interface MetricDefinition {
4
+ readonly name: string;
5
+ readonly description: string;
6
+ }
7
+ /** The metric dictionary. Each number an agent sees has one written meaning. */
8
+ export declare const METRIC_DEFINITIONS: {
9
+ readonly acceptanceRate: {
10
+ readonly description: "LinkedIn connection requests accepted, divided by connection requests sent.";
11
+ readonly name: "Connection acceptance rate";
12
+ };
13
+ readonly bounceRate: {
14
+ readonly description: "Messages that bounced, divided by messages sent.";
15
+ readonly name: "Bounce rate";
16
+ };
17
+ readonly openRate: {
18
+ readonly description: "Unique opens divided by messages delivered (or sent when delivered is unknown). Null when open tracking is off. Mail privacy features inflate opens.";
19
+ readonly name: "Open rate";
20
+ };
21
+ readonly positiveReplyRate: {
22
+ readonly description: "Replies the vendor marked positive, divided by unique leads contacted (or messages sent when contacted is unknown).";
23
+ readonly name: "Positive reply rate";
24
+ };
25
+ readonly replyRate: {
26
+ readonly description: "Replies from people, excluding auto-replies where the vendor separates them, divided by unique leads contacted (or messages sent when contacted is unknown).";
27
+ readonly name: "Reply rate";
28
+ };
29
+ readonly unsubscribeRate: {
30
+ readonly description: "Unsubscribes divided by unique leads contacted (or messages sent).";
31
+ readonly name: "Unsubscribe rate";
32
+ };
33
+ };
34
+ export type MetricName = keyof typeof METRIC_DEFINITIONS;
35
+ export interface Rate {
36
+ /** Between 0 and 1, or `null` when either count is missing or the base is 0. */
37
+ readonly value: number | null;
38
+ /** Which count the rate was divided by. */
39
+ readonly basis: "connectionsSent" | "contacted" | "delivered" | "sent" | null;
40
+ }
41
+ /** Computes every rate for one row of counts. */
42
+ export declare const computeRates: (row: MetricRow) => Record<MetricName, Rate>;
43
+ declare const COUNT_KEYS: readonly ["bounced", "clicked", "clickedTotal", "connectionsAccepted", "connectionsSent", "contacted", "delivered", "inmailsSent", "opened", "openedTotal", "positive", "replied", "repliedAuto", "sent", "unsubscribed"];
44
+ export type MetricCounts = Pick<MetricRow, (typeof COUNT_KEYS)[number]>;
45
+ /** A row of counts with every value unknown. */
46
+ export declare const emptyCounts: () => MetricCounts;
47
+ /**
48
+ * Adds rows together. A count stays `null` only when no row reports it, so a
49
+ * missing value is never turned into 0. Unique counts (opened, contacted)
50
+ * are summed, which over-counts people who appear in more than one row.
51
+ */
52
+ export declare const sumCounts: (rows: readonly MetricCounts[]) => MetricCounts;
53
+ /** What a row of counts is for: a workspace, a campaign, a step or a sender. */
54
+ export interface RowScope extends Identity {
55
+ readonly scope: MetricScope;
56
+ readonly scopeId: string;
57
+ }
58
+ /**
59
+ * One `MetricRow` from the counts an adapter read. A total with nothing else
60
+ * to say needs only the scope and the counts; a daily, step or derived row
61
+ * says so in `extra`.
62
+ */
63
+ export declare const metricRow: (scope: RowScope, counts: MetricCounts, extra?: Partial<Pick<MetricRow, "date" | "evidence" | "stepIndex" | "timezone" | "variantKey">>) => MetricRow;
64
+ export {};
@@ -0,0 +1,81 @@
1
+ import type { Json } from "./json.ts";
2
+ export interface NativeParam {
3
+ /** Where the value goes in the request. */
4
+ readonly in: "body" | "path" | "query";
5
+ /** `list` is several plain values: a repeated key in the query, an array in the body. */
6
+ readonly type: "boolean" | "json" | "list" | "number" | "string";
7
+ /** Path parameters are always required. */
8
+ readonly required?: boolean | undefined;
9
+ readonly description: string;
10
+ }
11
+ export interface NativeRead {
12
+ /** What the read answers, in one sentence. */
13
+ readonly description: string;
14
+ readonly method: "GET" | "POST";
15
+ /** The vendor's path, with `{name}` for each path parameter. */
16
+ readonly path: string;
17
+ readonly params?: Readonly<Record<string, NativeParam>> | undefined;
18
+ /** A rate lane declared in the adapter's limits. */
19
+ readonly lane?: string | undefined;
20
+ /** A different host, for a vendor's sister service. Defaults to the adapter's base URL. */
21
+ readonly baseUrl?: string | undefined;
22
+ /** The vendor's documentation page for the read. */
23
+ readonly docs?: string | undefined;
24
+ /**
25
+ * `true` when the response can hold a credential, for example the headers a
26
+ * webhook sends. The read stays available to code, and is left out of what
27
+ * the `vendor_read` agent tool lists and runs.
28
+ */
29
+ readonly sensitive?: boolean | undefined;
30
+ }
31
+ /** The reads by name. Names are camelCase, for example `inboxUnread`. */
32
+ export type NativeCatalog = Readonly<Record<string, NativeRead>>;
33
+ /** An adapter with no native reads. */
34
+ export type NoNative = Record<never, never>;
35
+ /** Keeps each read's name and parameters as literal types. */
36
+ export declare const defineNative: <const Catalog extends NativeCatalog>(catalog: Catalog) => Catalog;
37
+ /** A parameter and where it goes. Exported so a catalog's type can be named. */
38
+ export interface PlacedParam<Place extends NativeParam["in"], Type extends NativeParam["type"]> {
39
+ readonly description: string;
40
+ readonly in: Place;
41
+ readonly type: Type;
42
+ }
43
+ export interface NeededParam<Place extends NativeParam["in"], Type extends NativeParam["type"]> extends PlacedParam<Place, Type> {
44
+ readonly required: true;
45
+ }
46
+ export declare const inQuery: <const Type extends NativeParam["type"]>(type: Type, description: string) => PlacedParam<"query", Type>;
47
+ export declare const inQueryRequired: <const Type extends NativeParam["type"]>(type: Type, description: string) => NeededParam<"query", Type>;
48
+ export declare const inBody: <const Type extends NativeParam["type"]>(type: Type, description: string) => PlacedParam<"body", Type>;
49
+ export declare const inBodyRequired: <const Type extends NativeParam["type"]>(type: Type, description: string) => NeededParam<"body", Type>;
50
+ /** A path parameter. Ids are strings in the SDK, whatever the vendor uses. */
51
+ export declare const inPath: (description: string) => PlacedParam<"path", "string">;
52
+ interface ValueTypes {
53
+ readonly boolean: boolean;
54
+ readonly json: Json;
55
+ readonly list: readonly (boolean | number | string)[];
56
+ readonly number: number;
57
+ readonly string: string;
58
+ }
59
+ type Declared<Read> = Read extends {
60
+ readonly params: infer Params extends Readonly<Record<string, NativeParam>>;
61
+ } ? Params : NoNative;
62
+ type RequiredNames<Params> = {
63
+ [Name in keyof Params]: Params[Name] extends {
64
+ readonly required: true;
65
+ } | {
66
+ readonly in: "path";
67
+ } ? Name : never;
68
+ }[keyof Params];
69
+ type ValueOf<Param> = Param extends {
70
+ readonly type: infer Type;
71
+ } ? Type extends keyof ValueTypes ? ValueTypes[Type] : Json : Json;
72
+ type TypedParams<Params> = {
73
+ readonly [Name in RequiredNames<Params>]: ValueOf<Params[Name]>;
74
+ } & {
75
+ readonly [Name in Exclude<keyof Params, RequiredNames<Params>>]?: ValueOf<Params[Name]> | undefined;
76
+ };
77
+ /** The parameters one catalogued read takes, as a typed object. */
78
+ export type NativeParamsOf<Read> = TypedParams<Declared<Read>>;
79
+ /** `true` when the read cannot be called without parameters. */
80
+ export type NeedsParams<Read> = [RequiredNames<Declared<Read>>] extends [never] ? false : true;
81
+ export {};
@@ -0,0 +1,292 @@
1
+ import type { TimeRange } from "../adapter.ts";
2
+ import type { Capabilities } from "../capabilities.ts";
3
+ import type { LimitsSnapshot, OperationOptions } from "../engine/engine.ts";
4
+ import type { BlockEntry, CampaignProgress, CampaignSettings, LeadList, PlacementTest, SenderHealth, Tag, WebhookSubscription } from "../entities-account.ts";
5
+ import type { Campaign, CampaignStatus, Evidence, Lead, Message, MetricRow, MetricScope, Reply, ReplyCategory, Sender, Sequence, Workspace } from "../entities.ts";
6
+ import type { OutboundError } from "../errors.ts";
7
+ import type { FieldCoverage } from "../fields.ts";
8
+ import type { Json } from "../json.ts";
9
+ import type { NativeCatalog, NativeParamsOf, NeedsParams, NoNative } from "../native.ts";
10
+ export interface ResultMeta {
11
+ /** `exact` from the vendor, `sampled` when partial, `derived` when we computed or filtered it. */
12
+ readonly evidence: Evidence;
13
+ /** When the SDK got the answer, ISO 8601 UTC. */
14
+ readonly fetchedAt: string;
15
+ /** `false` when more pages exist or a filter could not see everything. */
16
+ readonly complete: boolean;
17
+ /** Milliseconds spent waiting for the rate budget. */
18
+ readonly throttledMs: number;
19
+ /** Vendor requests the call made. */
20
+ readonly requests: number;
21
+ readonly provider: string;
22
+ readonly workspaceId: string;
23
+ /** `true` when an older answer was served because the vendor was down. */
24
+ readonly stale: boolean;
25
+ }
26
+ export type WithMeta<Item> = Item & {
27
+ readonly meta: ResultMeta;
28
+ };
29
+ export interface PageResult<Item> {
30
+ readonly items: readonly Item[];
31
+ /** Pass back to `list` or `listAll` to continue. Absent on the last page. */
32
+ readonly cursor?: string | undefined;
33
+ readonly complete: boolean;
34
+ readonly meta: ResultMeta;
35
+ }
36
+ export interface ListOptions extends OperationOptions {
37
+ /** A page size hint. Adapters clamp it to what the vendor allows. */
38
+ readonly limit?: number | undefined;
39
+ /** A cursor from an earlier page of the same listing. */
40
+ readonly cursor?: string | undefined;
41
+ }
42
+ export interface ListAllOptions extends ListOptions {
43
+ /** Stop after this many records. */
44
+ readonly max?: number | undefined;
45
+ }
46
+ /** An async iterator over every page, with a cursor you can resume from. */
47
+ export interface ListAll<Item> extends AsyncIterable<Item> {
48
+ /** The cursor after the last page fetched. `undefined` before the first page and at the end. */
49
+ readonly cursor: string | undefined;
50
+ /** The meta of the last page fetched. */
51
+ readonly meta: ResultMeta | undefined;
52
+ /** `true` once `max` stopped the walk while more records existed. */
53
+ readonly truncated: boolean;
54
+ /** Collects every record into an array. */
55
+ readonly toArray: () => Promise<Item[]>;
56
+ }
57
+ export interface BulkOptions extends OperationOptions {
58
+ /** How many records to fetch at once. Defaults to 4. */
59
+ readonly concurrency?: number | undefined;
60
+ }
61
+ /** Partial failure is data, not an exception. */
62
+ export interface BulkResult<Item> {
63
+ readonly results: readonly {
64
+ readonly id: string;
65
+ readonly value: WithMeta<Item>;
66
+ }[];
67
+ readonly errors: readonly {
68
+ readonly id: string;
69
+ readonly error: OutboundError;
70
+ }[];
71
+ }
72
+ export interface ReadCollection<Item, Filters> {
73
+ /** One page. */
74
+ readonly list: (options?: Filters & ListOptions) => Promise<PageResult<Item>>;
75
+ /** Every page, fetched under the rate budget as you iterate. */
76
+ readonly listAll: (options?: Filters & ListAllOptions) => ListAll<Item>;
77
+ }
78
+ export interface Collection<Item, Filters> extends ReadCollection<Item, Filters> {
79
+ /** Throws `NotFound` for a missing record. */
80
+ readonly get: (id: string, options?: OperationOptions) => Promise<WithMeta<Item>>;
81
+ /** Never throws for a missing record. */
82
+ readonly exists: (id: string, options?: OperationOptions) => Promise<boolean>;
83
+ readonly getMany: (ids: readonly string[], options?: BulkOptions) => Promise<BulkResult<Item>>;
84
+ }
85
+ /** Fields that cost extra vendor requests and are fetched only when asked for. */
86
+ export type Include = "body";
87
+ export interface CampaignFilters {
88
+ readonly status?: CampaignStatus | undefined;
89
+ /** Only the campaigns this sender is attached to. */
90
+ readonly senderId?: string | undefined;
91
+ }
92
+ export interface SenderFilters {
93
+ readonly campaignId?: string | undefined;
94
+ }
95
+ export interface LeadFilters extends TimeRange {
96
+ readonly campaignId?: string | undefined;
97
+ /** A saved lead list. Not together with `campaignId`. */
98
+ readonly listId?: string | undefined;
99
+ /** Only the records of the person with exactly this email address. */
100
+ readonly email?: string | undefined;
101
+ /** Only the records of the person with exactly this LinkedIn profile. */
102
+ readonly linkedinUrl?: string | undefined;
103
+ }
104
+ export interface WebhookFilters {
105
+ readonly campaignId?: string | undefined;
106
+ }
107
+ export interface MessageFilters extends TimeRange {
108
+ readonly campaignId?: string | undefined;
109
+ readonly leadId?: string | undefined;
110
+ /** A `threadId` from an earlier message. */
111
+ readonly threadId?: string | undefined;
112
+ readonly include?: readonly Include[] | undefined;
113
+ }
114
+ export interface ReplyFilters extends TimeRange {
115
+ readonly campaignId?: string | undefined;
116
+ readonly category?: ReplyCategory | undefined;
117
+ /** `true` for unread replies only, `false` for read ones only. */
118
+ readonly unread?: boolean | undefined;
119
+ readonly include?: readonly Include[] | undefined;
120
+ }
121
+ export interface StatsOptions extends OperationOptions {
122
+ /** Inclusive `YYYY-MM-DD`. */
123
+ readonly from?: string | undefined;
124
+ /** Inclusive `YYYY-MM-DD`. */
125
+ readonly to?: string | undefined;
126
+ /** `total` for one row over the range, `day` for one row per day. */
127
+ readonly by?: "day" | "total" | undefined;
128
+ }
129
+ export interface TopLevelStatsOptions extends StatsOptions {
130
+ readonly scope?: MetricScope | undefined;
131
+ /**
132
+ * The campaign or sender, for the `campaign`, `step` and `sender` scopes.
133
+ * The `campaign` scope without one returns a row per campaign, in one call.
134
+ */
135
+ readonly scopeId?: string | undefined;
136
+ }
137
+ export interface StatsResult {
138
+ readonly rows: readonly MetricRow[];
139
+ readonly meta: ResultMeta;
140
+ }
141
+ type Scoped<Filters, Key extends keyof Filters> = Omit<Filters, Key>;
142
+ export interface CampaignHandle {
143
+ readonly id: string;
144
+ readonly get: (options?: OperationOptions) => Promise<WithMeta<Campaign>>;
145
+ readonly sequence: (options?: OperationOptions) => Promise<WithMeta<Sequence>>;
146
+ /** The schedule, daily caps, tracking and stop rules. */
147
+ readonly settings: (options?: OperationOptions) => Promise<WithMeta<CampaignSettings>>;
148
+ /** How many of the campaign's leads are waiting, in progress, finished or stopped. */
149
+ readonly progress: (options?: OperationOptions) => Promise<WithMeta<CampaignProgress>>;
150
+ /** The follow-up sequences attached to the campaign. */
151
+ readonly subsequences: ReadCollection<Sequence, Record<never, never>>;
152
+ readonly webhooks: ReadCollection<WebhookSubscription, Record<never, never>>;
153
+ readonly senders: ReadCollection<Sender, Scoped<SenderFilters, "campaignId">>;
154
+ readonly leads: ReadCollection<Lead, Scoped<LeadFilters, "campaignId" | "listId">>;
155
+ readonly messages: ReadCollection<Message, Scoped<MessageFilters, "campaignId">>;
156
+ readonly replies: ReadCollection<Reply, Scoped<ReplyFilters, "campaignId">>;
157
+ /** Totals, or one row per day or per step. */
158
+ readonly stats: (options?: StatsOptions & {
159
+ readonly scope?: "campaign" | "step" | undefined;
160
+ }) => Promise<StatsResult>;
161
+ }
162
+ export interface SenderHandle {
163
+ readonly id: string;
164
+ readonly get: (options?: OperationOptions) => Promise<WithMeta<Sender>>;
165
+ /** The campaigns the sender is attached to. */
166
+ readonly campaigns: ReadCollection<Campaign, Scoped<CampaignFilters, "senderId">>;
167
+ readonly stats: (options?: StatsOptions) => Promise<StatsResult>;
168
+ readonly warmup: (options?: OperationOptions) => Promise<NonNullable<Sender["warmup"]>>;
169
+ /** DNS records, connection state and warmup traffic. */
170
+ readonly health: (options?: OperationOptions) => Promise<WithMeta<SenderHealth>>;
171
+ }
172
+ export interface ListHandle {
173
+ readonly id: string;
174
+ readonly get: (options?: OperationOptions) => Promise<WithMeta<LeadList>>;
175
+ readonly leads: ReadCollection<Lead, Scoped<LeadFilters, "campaignId" | "listId">>;
176
+ }
177
+ export interface ThreadHandle {
178
+ readonly id: string;
179
+ /** Every message of the conversation, oldest first. */
180
+ readonly messages: (options?: OperationOptions & {
181
+ readonly include?: readonly Include[] | undefined;
182
+ }) => Promise<PageResult<Message>>;
183
+ }
184
+ export interface LeadHandle {
185
+ readonly id: string;
186
+ readonly get: (options?: OperationOptions) => Promise<WithMeta<Lead>>;
187
+ /** Every message to and from the lead, oldest first. */
188
+ readonly timeline: (options?: OperationOptions & {
189
+ readonly include?: readonly Include[] | undefined;
190
+ }) => Promise<PageResult<Message>>;
191
+ }
192
+ export interface RawRequestOptions extends OperationOptions {
193
+ readonly query?: Readonly<Record<string, string | number | boolean | undefined>> | undefined;
194
+ readonly body?: Json | undefined;
195
+ readonly lane?: string | undefined;
196
+ }
197
+ /** The vendor's own API, for anything not normalized yet. Reads only unless `allowWrites` is set. */
198
+ export interface RawClient {
199
+ readonly provider: string;
200
+ readonly get: (path: string, options?: RawRequestOptions) => Promise<Json>;
201
+ readonly request: (method: "DELETE" | "GET" | "PATCH" | "POST" | "PUT", path: string, options?: RawRequestOptions) => Promise<Json>;
202
+ }
203
+ export type NativeParams = Readonly<Record<string, Json | undefined>>;
204
+ export interface NativeResult {
205
+ /** The vendor's response, as it was sent. Not normalized and not redacted. */
206
+ readonly data: Json;
207
+ readonly meta: ResultMeta;
208
+ }
209
+ type NativeArguments<Read> = NeedsParams<Read> extends true ? [params: NativeParamsOf<Read>, options?: OperationOptions] : [params?: NativeParamsOf<Read>, options?: OperationOptions];
210
+ /** One function per catalogued read, typed from the adapter's catalog. */
211
+ export type NativeReads<Native> = {
212
+ readonly [Name in keyof Native]: (...args: NativeArguments<Native[Name]>) => Promise<NativeResult>;
213
+ };
214
+ /**
215
+ * The vendor's own reads that have no normalized form. Every one is a read:
216
+ * the catalog holds nothing that changes vendor data. Each call is one vendor
217
+ * request; pass the vendor's own paging parameters to page.
218
+ */
219
+ export interface NativeClient<Native extends NativeCatalog = NoNative> {
220
+ readonly provider: string;
221
+ /** What this vendor offers beyond the normalized reads, with each read's parameters. */
222
+ readonly catalog: Native;
223
+ /** The reads as typed functions: `outbound.native.reads.inboxUnread({ limit: 20 })`. */
224
+ readonly reads: NativeReads<Native>;
225
+ /** A read by name, for callers that learn the name at run time. */
226
+ readonly read: (name: string, params?: NativeParams, options?: OperationOptions) => Promise<NativeResult>;
227
+ }
228
+ export interface EstimateQuery {
229
+ /** The listing or lookup to estimate, for example `leads.list`. */
230
+ readonly action: string;
231
+ /** How many records you expect to read. */
232
+ readonly records?: number | undefined;
233
+ readonly limit?: number | undefined;
234
+ }
235
+ export interface Estimate {
236
+ /** Expected vendor requests, or `null` when it cannot be known up front. */
237
+ readonly requests: number | null;
238
+ readonly basis: string;
239
+ }
240
+ export interface OutboundApi {
241
+ readonly provider: string;
242
+ readonly workspaceId: string;
243
+ /** What this instance can do, after plugins narrowed it. */
244
+ readonly capabilities: Capabilities;
245
+ /** The plugins on this instance, outermost first. */
246
+ readonly plugins: readonly {
247
+ readonly name: string;
248
+ }[];
249
+ /** How far the adapter has been verified. */
250
+ readonly maturity: "beta" | "stable" | "unverified";
251
+ /** What the adapter assumes and has not confirmed against the live API. */
252
+ readonly caveats: readonly string[];
253
+ /**
254
+ * Which fields of each record this adapter fills: `exact` from the vendor,
255
+ * `derived` by the adapter, or `false` when a `null` means the vendor has no
256
+ * such field.
257
+ */
258
+ readonly fields: FieldCoverage;
259
+ readonly campaigns: Collection<Campaign, CampaignFilters>;
260
+ readonly senders: Collection<Sender, SenderFilters>;
261
+ readonly leads: Collection<Lead, LeadFilters>;
262
+ readonly messages: ReadCollection<Message, MessageFilters>;
263
+ readonly replies: ReadCollection<Reply, ReplyFilters>;
264
+ readonly workspaces: ReadCollection<Workspace, Record<never, never>>;
265
+ /** Saved lead lists. */
266
+ readonly lists: Collection<LeadList, Record<never, never>>;
267
+ /** The addresses, domains and profiles the account never contacts. */
268
+ readonly blocklist: ReadCollection<BlockEntry, Record<never, never>>;
269
+ readonly tags: ReadCollection<Tag, Record<never, never>>;
270
+ /** The inbox placement tests the account has set up. Their results are native reads. */
271
+ readonly placementTests: ReadCollection<PlacementTest, Record<never, never>>;
272
+ /** The webhooks registered with the vendor. */
273
+ readonly webhooks: Collection<WebhookSubscription, WebhookFilters>;
274
+ readonly raw: RawClient;
275
+ /** The vendor's own reads, by name, for what has no normalized form. */
276
+ readonly native: NativeClient;
277
+ readonly campaign: (id: string) => CampaignHandle;
278
+ readonly sender: (id: string) => SenderHandle;
279
+ readonly lead: (id: string) => LeadHandle;
280
+ /** One saved lead list. */
281
+ readonly list: (id: string) => ListHandle;
282
+ /** One conversation, by the `threadId` a message carries. */
283
+ readonly thread: (id: string) => ThreadHandle;
284
+ /** The same API scoped to one client or workspace. */
285
+ readonly workspace: (id: string) => OutboundApi;
286
+ readonly stats: (options?: TopLevelStatsOptions) => Promise<StatsResult>;
287
+ /** The current rate budget for this credential. */
288
+ readonly limits: () => Promise<LimitsSnapshot[]>;
289
+ /** How many vendor requests a read would cost, before making it. */
290
+ readonly estimate: (query: EstimateQuery) => Estimate;
291
+ }
292
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { ZodType } from "zod";
2
+ import type { OperationOptions } from "../engine/engine.ts";
3
+ import type { Json } from "../json.ts";
4
+ import type { Collection, ListOptions, ReadCollection, WithMeta } from "./api.ts";
5
+ import type { Core } from "./core.ts";
6
+ import type { Operation, OperationKind } from "./operations.ts";
7
+ export interface PageRequest {
8
+ readonly limit: number | undefined;
9
+ readonly next: Json | undefined;
10
+ }
11
+ export interface ListSpec<Item, Filters> {
12
+ readonly action: OperationKind;
13
+ readonly schema: ZodType<Item>;
14
+ /** Checks the filters and the capabilities they need. Returns clean filters. */
15
+ readonly prepare: (filters: Filters) => Filters;
16
+ readonly toOperation: (filters: Filters, page: PageRequest) => Operation;
17
+ /** What makes a record the same record on a later page. The filters are given because they can change that. */
18
+ readonly keyOf: (item: Item, filters: Filters) => string | undefined;
19
+ }
20
+ export interface GetSpec<Item> {
21
+ readonly action: OperationKind;
22
+ readonly what: string;
23
+ readonly schema: ZodType<Item>;
24
+ /** Checks the capability the lookup needs. */
25
+ readonly prepare: () => void;
26
+ readonly toOperation: (id: string) => Operation;
27
+ }
28
+ export declare const makeReadCollection: <Item, Filters>(core: Core, spec: ListSpec<Item, Filters>) => ReadCollection<Item, Filters>;
29
+ export declare const makeGetter: <Item>(core: Core, spec: GetSpec<Item>) => (id: string, options?: OperationOptions) => Promise<WithMeta<Item>>;
30
+ export declare const makeCollection: <Item, Filters>(core: Core, listSpec: ListSpec<Item, Filters>, getSpec: GetSpec<Item>) => Collection<Item, Filters>;
31
+ export type { ListOptions };
@@ -0,0 +1,36 @@
1
+ import type { ZodType } from "zod";
2
+ import type { Adapter } from "../adapter.ts";
3
+ import type { CapabilityGate } from "../capabilities.ts";
4
+ import type { OperationOptions, RequestEngine } from "../engine/engine.ts";
5
+ import type { CallState } from "../engine/request.ts";
6
+ import type { Evidence } from "../entities.ts";
7
+ import { OutboundError } from "../errors.ts";
8
+ import type { ResultMeta } from "./api.ts";
9
+ import type { Operation, OperationOutput, OutboundRecord } from "./operations.ts";
10
+ import type { OperationInfo } from "./plugins.ts";
11
+ export interface Core {
12
+ readonly adapter: Adapter;
13
+ readonly engine: RequestEngine;
14
+ readonly gate: CapabilityGate;
15
+ readonly allowWrites: boolean;
16
+ /** One operation through every plugin and then the adapter. */
17
+ readonly run: (operation: Operation, info: OperationInfo) => Promise<OperationOutput>;
18
+ }
19
+ export declare const infoFor: (core: Core, state: CallState) => OperationInfo;
20
+ export declare const toOutboundError: (core: Core, cause: unknown) => OutboundError;
21
+ /** Runs one SDK call with accounting, hooks and error normalization around it. */
22
+ export declare const perform: <Result>(core: Core, action: string, options: OperationOptions | undefined, body: (state: CallState) => Promise<Result>, shared?: CallState,
23
+ /** Says whether a failure is an answer to the caller, not an error: `onError` is not told of it. */
24
+ isAnswer?: (error: OutboundError) => boolean) => Promise<Result>;
25
+ export interface MetaInput {
26
+ readonly evidence: Evidence;
27
+ readonly complete: boolean;
28
+ readonly stale?: boolean | undefined;
29
+ readonly fetchedAt?: string | undefined;
30
+ }
31
+ export declare const metaFor: (core: Core, state: CallState, input: MetaInput) => ResultMeta;
32
+ /**
33
+ * Checks what came back against the schema. An adapter or plugin that
34
+ * returns a malformed record fails here, loudly, and not in the caller.
35
+ */
36
+ export declare const checked: <Item>(core: Core, schema: ZodType<Item>, records: readonly OutboundRecord[], action: string) => Item[];
@@ -0,0 +1,16 @@
1
+ import type { NativeCatalog, NoNative } from "../native.ts";
2
+ import { Outbound } from "./outbound.ts";
3
+ import type { OutboundOptions } from "./outbound.ts";
4
+ import type { OutboundPlugin } from "./plugins.ts";
5
+ type ExtensionOf<Plugin> = Plugin extends OutboundPlugin<infer Extension> ? unknown extends Extension ? Record<never, never> : Extension : never;
6
+ type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (value: infer Intersection) => void ? Intersection : never;
7
+ /** The methods a list of plugins adds to the instance. */
8
+ export type ExtensionsOf<Plugins extends readonly OutboundPlugin[]> = UnionToIntersection<ExtensionOf<Plugins[number]>>;
9
+ /**
10
+ * Creates the client. One instance wraps one adapter; `combine()` puts
11
+ * several adapters behind one.
12
+ */
13
+ export declare const createOutbound: <const Plugins extends readonly OutboundPlugin[] = [], Native extends NativeCatalog = NoNative>(options: OutboundOptions<Native> & {
14
+ readonly plugins?: Plugins | undefined;
15
+ }) => Outbound<Native> & ExtensionsOf<Plugins>;
16
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { CampaignHandle, LeadHandle, ListHandle, SenderHandle, ThreadHandle } from "./api.ts";
2
+ import type { Core } from "./core.ts";
3
+ export declare const makeCampaignHandle: (core: Core, id: string) => CampaignHandle;
4
+ export declare const makeSenderHandle: (core: Core, id: string) => SenderHandle;
5
+ export declare const makeLeadHandle: (core: Core, id: string) => LeadHandle;
6
+ export declare const makeListHandle: (core: Core, id: string) => ListHandle;
7
+ export declare const makeThreadHandle: (core: Core, id: string) => ThreadHandle;
@@ -0,0 +1,4 @@
1
+ import type { NativeCatalog } from "../native.ts";
2
+ import type { NativeClient } from "./api.ts";
3
+ import type { Core } from "./core.ts";
4
+ export declare const makeNativeClient: <Native extends NativeCatalog>(core: Core) => NativeClient<Native>;
@@ -0,0 +1,28 @@
1
+ import type { Adapter, AdapterContext, Page } from "../adapter.ts";
2
+ import type { Capabilities } from "../capabilities.ts";
3
+ import type { Entity } from "../entities-account.ts";
4
+ import type { Evidence, MetricRow } from "../entities.ts";
5
+ import { OutboundError } from "../errors.ts";
6
+ import type { Json } from "../json.ts";
7
+ /** A record an operation returns. */
8
+ export type OutboundRecord = Entity | MetricRow;
9
+ export interface OperationOutput {
10
+ readonly items: readonly OutboundRecord[];
11
+ /** The adapter's continuation value, when there is another page. */
12
+ readonly next?: Json | undefined;
13
+ readonly evidence: Evidence;
14
+ /** `true` when a plugin served an older answer because the vendor was down. */
15
+ readonly stale?: boolean | undefined;
16
+ /** When the answer was fetched, if a plugin served it from a store. ISO 8601 UTC. */
17
+ readonly fetchedAt?: string | undefined;
18
+ }
19
+ export declare const unsupported: (adapter: Adapter, kind: string) => OutboundError;
20
+ export declare const idFor: (adapter: Adapter, id: string) => string;
21
+ export declare const optionalId: (adapter: Adapter, id: string | undefined) => string | undefined;
22
+ export declare const output: (page: Page<OutboundRecord>, derived?: boolean) => OperationOutput;
23
+ export declare const single: (item: OutboundRecord) => OperationOutput;
24
+ export interface DispatchTarget {
25
+ readonly adapter: Adapter;
26
+ readonly capabilities: Capabilities;
27
+ readonly ctx: AdapterContext;
28
+ }
@@ -0,0 +1,41 @@
1
+ import type { PageQuery, SubsequenceQuery, WebhookQuery } from "../adapter.ts";
2
+ import type { DispatchTarget, OperationOutput } from "./operation-shared.ts";
3
+ export type AccountOperation = {
4
+ readonly kind: "blocklist.list";
5
+ readonly query: PageQuery;
6
+ } | {
7
+ readonly kind: "campaigns.progress";
8
+ readonly id: string;
9
+ } | {
10
+ readonly kind: "campaigns.settings";
11
+ readonly id: string;
12
+ } | {
13
+ readonly kind: "lists.get";
14
+ readonly id: string;
15
+ } | {
16
+ readonly kind: "lists.list";
17
+ readonly query: PageQuery;
18
+ } | {
19
+ readonly kind: "placementTests.list";
20
+ readonly query: PageQuery;
21
+ } | {
22
+ readonly kind: "senders.health";
23
+ readonly id: string;
24
+ } | {
25
+ readonly kind: "sequence.subsequences";
26
+ readonly query: SubsequenceQuery;
27
+ } | {
28
+ readonly kind: "tags.list";
29
+ readonly query: PageQuery;
30
+ } | {
31
+ readonly kind: "webhooks.get";
32
+ readonly id: string;
33
+ } | {
34
+ readonly kind: "webhooks.list";
35
+ readonly query: WebhookQuery;
36
+ };
37
+ export declare const isAccountOperation: <Other extends {
38
+ readonly kind: string;
39
+ }>(operation: AccountOperation | Other) => operation is AccountOperation;
40
+ /** Hands one account-level operation to the adapter. */
41
+ export declare const dispatchAccount: (target: DispatchTarget, operation: AccountOperation) => Promise<OperationOutput>;