outbound-sdk 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +121 -2
- package/dist/alerts/index.d.ts +2 -0
- package/dist/alerts/index.js +136 -0
- package/dist/alerts/plugin.d.ts +58 -0
- package/dist/audit/index.d.ts +33 -0
- package/dist/audit/index.js +60 -0
- package/dist/benchmarks/index.d.ts +29 -0
- package/dist/benchmarks/index.js +70 -0
- package/dist/budget/index.d.ts +21 -0
- package/dist/budget/index.js +50 -0
- package/dist/cache/index.d.ts +31 -0
- package/dist/cache/index.js +11 -0
- package/dist/cards/content.d.ts +43 -0
- package/dist/cards/copy-cards.d.ts +2 -0
- package/dist/cards/format.d.ts +39 -0
- package/dist/cards/index.d.ts +9 -0
- package/dist/cards/index.js +2070 -0
- package/dist/cards/notify-cards.d.ts +14 -0
- package/dist/cards/ops-cards.d.ts +2 -0
- package/dist/cards/parts.d.ts +22 -0
- package/dist/cards/people-cards.d.ts +2 -0
- package/dist/cards/render.d.ts +28 -0
- package/dist/cards/sender-cards.d.ts +2 -0
- package/dist/cards/slack-rich.d.ts +19 -0
- package/dist/cards/slack-text.d.ts +10 -0
- package/dist/cards/slack.d.ts +21 -0
- package/dist/cards/spec.d.ts +86 -0
- package/dist/cards/tool-cards.d.ts +4 -0
- package/dist/chunks/chunk-4O2HRTTI.js +75 -0
- package/dist/chunks/chunk-7BCYLIDG.js +483 -0
- package/dist/chunks/chunk-B7V6EOAC.js +2273 -0
- package/dist/chunks/chunk-CMQ5ZHLZ.js +25 -0
- package/dist/chunks/chunk-F7MKFVIG.js +43 -0
- package/dist/chunks/chunk-FZF6CLPX.js +232 -0
- package/dist/chunks/chunk-GPEJG34O.js +53 -0
- package/dist/chunks/chunk-HEC7XFFH.js +65 -0
- package/dist/chunks/chunk-IBC52BX3.js +24 -0
- package/dist/chunks/chunk-LNCOGBMI.js +144 -0
- package/dist/chunks/chunk-LOXBLQ3I.js +180 -0
- package/dist/chunks/chunk-NAWZ73QS.js +22 -0
- package/dist/chunks/chunk-OCV66TS2.js +705 -0
- package/dist/chunks/chunk-Q465X22Y.js +548 -0
- package/dist/chunks/chunk-QTB747K4.js +100 -0
- package/dist/chunks/chunk-QZNNCXXD.js +92 -0
- package/dist/chunks/chunk-R6AM4GJR.js +105 -0
- package/dist/chunks/chunk-TIJKJJDW.js +6 -0
- package/dist/chunks/chunk-VURTOVGI.js +61 -0
- package/dist/chunks/chunk-WAM6N4OF.js +269 -0
- package/dist/chunks/chunk-WW746NJF.js +94 -0
- package/dist/chunks/chunk-XC6CZP73.js +80 -0
- package/dist/chunks/chunk-ZGHQYZEH.js +45 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +34 -0
- package/dist/cli/commands.d.ts +16 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.js +25 -0
- package/dist/cli/mcp.d.ts +14 -0
- package/dist/clients/index.d.ts +2 -0
- package/dist/clients/index.js +107 -0
- package/dist/clients/plugin.d.ts +42 -0
- package/dist/combine/account.d.ts +4 -0
- package/dist/combine/adapter.d.ts +9 -0
- package/dist/combine/index.d.ts +2 -0
- package/dist/combine/index.js +345 -0
- package/dist/combine/route.d.ts +17 -0
- package/dist/exporter/index.d.ts +29 -0
- package/dist/exporter/index.js +77 -0
- package/dist/failover/index.d.ts +11 -0
- package/dist/failover/index.js +45 -0
- package/dist/fixtures/index.d.ts +27 -0
- package/dist/fixtures/index.js +241 -0
- package/dist/fixtures/scrub.d.ts +5 -0
- package/dist/heyreach/account.d.ts +11 -0
- package/dist/heyreach/adapter.d.ts +5 -0
- package/dist/heyreach/capabilities.d.ts +68 -0
- package/dist/heyreach/client.d.ts +20 -0
- package/dist/heyreach/inbox.d.ts +7 -0
- package/dist/heyreach/index.d.ts +18 -0
- package/dist/heyreach/index.js +1708 -0
- package/dist/heyreach/lookup.d.ts +15 -0
- package/dist/heyreach/map-account.d.ts +25 -0
- package/dist/heyreach/map-sequence.d.ts +5 -0
- package/dist/heyreach/map-stats.d.ts +10 -0
- package/dist/heyreach/map.d.ts +35 -0
- package/dist/heyreach/native-organization.d.ts +128 -0
- package/dist/heyreach/native-voice.d.ts +106 -0
- package/dist/heyreach/native.d.ts +496 -0
- package/dist/heyreach/paging.d.ts +7 -0
- package/dist/heyreach/webhooks.d.ts +2 -0
- package/dist/identity/index.d.ts +3 -0
- package/dist/identity/index.js +148 -0
- package/dist/identity/keys.d.ts +9 -0
- package/dist/identity/plugin.d.ts +34 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +119 -0
- package/dist/insights/copy/copy-audit.d.ts +55 -0
- package/dist/insights/copy/copy-checks.d.ts +44 -0
- package/dist/insights/copy/copy-reuse.d.ts +59 -0
- package/dist/insights/copy/index.d.ts +67 -0
- package/dist/insights/copy/reply-timing.d.ts +63 -0
- package/dist/insights/copy/shared.d.ts +53 -0
- package/dist/insights/copy/step-funnel.d.ts +66 -0
- package/dist/insights/copy/variant-test.d.ts +64 -0
- package/dist/insights/define.d.ts +98 -0
- package/dist/insights/index.d.ts +10 -0
- package/dist/insights/index.js +4873 -0
- package/dist/insights/ops/anomalies.d.ts +80 -0
- package/dist/insights/ops/campaign-diagnosis.d.ts +39 -0
- package/dist/insights/ops/campaign-ranking.d.ts +56 -0
- package/dist/insights/ops/channel-mix.d.ts +44 -0
- package/dist/insights/ops/client-report.d.ts +76 -0
- package/dist/insights/ops/diagnosis-checks.d.ts +48 -0
- package/dist/insights/ops/index.d.ts +135 -0
- package/dist/insights/ops/period-comparison.d.ts +86 -0
- package/dist/insights/ops/pipeline-forecast.d.ts +44 -0
- package/dist/insights/ops/shared.d.ts +149 -0
- package/dist/insights/ops/tag-rollup.d.ts +32 -0
- package/dist/insights/people/account-summary.d.ts +68 -0
- package/dist/insights/people/dropped-replies.d.ts +51 -0
- package/dist/insights/people/find.d.ts +18 -0
- package/dist/insights/people/hot-leads.d.ts +67 -0
- package/dist/insights/people/index.d.ts +88 -0
- package/dist/insights/people/lead-collisions.d.ts +43 -0
- package/dist/insights/people/person-summary.d.ts +46 -0
- package/dist/insights/people/personalization-gaps.d.ts +60 -0
- package/dist/insights/people/read.d.ts +40 -0
- package/dist/insights/people/suppression-check.d.ts +53 -0
- package/dist/insights/plugin.d.ts +40 -0
- package/dist/insights/registry.d.ts +335 -0
- package/dist/insights/senders/bounce-watch.d.ts +70 -0
- package/dist/insights/senders/domain-health.d.ts +69 -0
- package/dist/insights/senders/index.d.ts +74 -0
- package/dist/insights/senders/read.d.ts +37 -0
- package/dist/insights/senders/sender-capacity.d.ts +67 -0
- package/dist/insights/senders/sender-load.d.ts +52 -0
- package/dist/insights/senders/settings-audit.d.ts +48 -0
- package/dist/insights/senders/warmup-readiness.d.ts +39 -0
- package/dist/insights/stats.d.ts +45 -0
- package/dist/insights/tools.d.ts +16 -0
- package/dist/insights/types.d.ts +4 -0
- package/dist/instantly/adapter-account.d.ts +5 -0
- package/dist/instantly/adapter-mail.d.ts +3 -0
- package/dist/instantly/adapter.d.ts +7 -0
- package/dist/instantly/capabilities.d.ts +83 -0
- package/dist/instantly/client.d.ts +29 -0
- package/dist/instantly/index.d.ts +20 -0
- package/dist/instantly/index.js +2372 -0
- package/dist/instantly/map-account.d.ts +23 -0
- package/dist/instantly/map-lead.d.ts +18 -0
- package/dist/instantly/map-stats.d.ts +22 -0
- package/dist/instantly/map.d.ts +24 -0
- package/dist/instantly/native-agents-sales.d.ts +161 -0
- package/dist/instantly/native-agents.d.ts +156 -0
- package/dist/instantly/native-campaigns.d.ts +101 -0
- package/dist/instantly/native-leads.d.ts +93 -0
- package/dist/instantly/native-params.d.ts +24 -0
- package/dist/instantly/native-search.d.ts +82 -0
- package/dist/instantly/native-senders.d.ts +182 -0
- package/dist/instantly/native-supersearch.d.ts +149 -0
- package/dist/instantly/native-workspace.d.ts +170 -0
- package/dist/instantly/native.d.ts +1081 -0
- package/dist/instantly/pages.d.ts +29 -0
- package/dist/instantly/stats.d.ts +5 -0
- package/dist/instantly/webhooks.d.ts +2 -0
- package/dist/internal/adapter.d.ts +189 -0
- package/dist/internal/capabilities.d.ts +86 -0
- package/dist/internal/cursor.d.ts +10 -0
- package/dist/internal/engine/budget.d.ts +44 -0
- package/dist/internal/engine/engine.d.ts +45 -0
- package/dist/internal/engine/rate-store.d.ts +25 -0
- package/dist/internal/engine/request.d.ts +27 -0
- package/dist/internal/engine/retry.d.ts +21 -0
- package/dist/internal/engine/runtime.d.ts +13 -0
- package/dist/internal/entities-account.d.ts +135 -0
- package/dist/internal/entities.d.ts +389 -0
- package/dist/internal/env.d.ts +4 -0
- package/dist/internal/errors.d.ts +57 -0
- package/dist/internal/hooks.d.ts +55 -0
- package/dist/internal/json.d.ts +40 -0
- package/dist/internal/limits.d.ts +34 -0
- package/dist/internal/metrics.d.ts +52 -0
- package/dist/internal/native.d.ts +66 -0
- package/dist/internal/outbound/api.d.ts +267 -0
- package/dist/internal/outbound/collections.d.ts +31 -0
- package/dist/internal/outbound/core.d.ts +36 -0
- package/dist/internal/outbound/create.d.ts +16 -0
- package/dist/internal/outbound/handles.d.ts +7 -0
- package/dist/internal/outbound/native.d.ts +4 -0
- package/dist/internal/outbound/operation-shared.d.ts +28 -0
- package/dist/internal/outbound/operations-account.d.ts +29 -0
- package/dist/internal/outbound/operations.d.ts +42 -0
- package/dist/internal/outbound/outbound.d.ts +64 -0
- package/dist/internal/outbound/plugins.d.ts +40 -0
- package/dist/internal/outbound/raw.d.ts +9 -0
- package/dist/internal/outbound/specs-account.d.ts +16 -0
- package/dist/internal/outbound/specs.d.ts +14 -0
- package/dist/internal/outbound/stats.d.ts +7 -0
- package/dist/internal/outbound/validate.d.ts +5 -0
- package/dist/internal/outbound/walker.d.ts +22 -0
- package/dist/internal/record.d.ts +19 -0
- package/dist/internal/redact.d.ts +18 -0
- package/dist/internal/ref.d.ts +16 -0
- package/dist/internal/sha256.d.ts +4 -0
- package/dist/internal/text.d.ts +11 -0
- package/dist/internal/url.d.ts +9 -0
- package/dist/loader/index.d.ts +12 -0
- package/dist/loader/index.js +12 -0
- package/dist/memory/account-reads.d.ts +5 -0
- package/dist/memory/account.d.ts +67 -0
- package/dist/memory/adapter.d.ts +16 -0
- package/dist/memory/data.d.ts +122 -0
- package/dist/memory/demo.d.ts +7 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.js +792 -0
- package/dist/memory/stats.d.ts +6 -0
- package/dist/memory/store.d.ts +18 -0
- package/dist/providers/index.d.ts +22 -0
- package/dist/providers/index.js +10 -0
- package/dist/reconcile/index.d.ts +2 -0
- package/dist/reconcile/index.js +72 -0
- package/dist/reconcile/plugin.d.ts +55 -0
- package/dist/redact/index.d.ts +2 -0
- package/dist/redact/index.js +192 -0
- package/dist/redact/plugin.d.ts +22 -0
- package/dist/redis/index.d.ts +41 -0
- package/dist/redis/index.js +114 -0
- package/dist/smartlead/account.d.ts +5 -0
- package/dist/smartlead/adapter.d.ts +5 -0
- package/dist/smartlead/capabilities.d.ts +85 -0
- package/dist/smartlead/client.d.ts +23 -0
- package/dist/smartlead/hmac.d.ts +9 -0
- package/dist/smartlead/index.d.ts +17 -0
- package/dist/smartlead/index.js +2170 -0
- package/dist/smartlead/leads.d.ts +6 -0
- package/dist/smartlead/lookup.d.ts +8 -0
- package/dist/smartlead/mail.d.ts +5 -0
- package/dist/smartlead/map-account.d.ts +22 -0
- package/dist/smartlead/map-messages.d.ts +31 -0
- package/dist/smartlead/map-stats.d.ts +37 -0
- package/dist/smartlead/map.d.ts +52 -0
- package/dist/smartlead/native-analytics.d.ts +242 -0
- package/dist/smartlead/native-campaigns.d.ts +211 -0
- package/dist/smartlead/native-inbox.d.ts +141 -0
- package/dist/smartlead/native-params.d.ts +33 -0
- package/dist/smartlead/native-services.d.ts +204 -0
- package/dist/smartlead/native.d.ts +785 -0
- package/dist/smartlead/shared.d.ts +28 -0
- package/dist/smartlead/stats.d.ts +5 -0
- package/dist/smartlead/webhooks.d.ts +2 -0
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.js +158 -0
- package/dist/sync/plugin.d.ts +58 -0
- package/dist/tools/account-tools.d.ts +21 -0
- package/dist/tools/ai-sdk.d.ts +8 -0
- package/dist/tools/ai-sdk.js +26 -0
- package/dist/tools/campaign-tools.d.ts +59 -0
- package/dist/tools/claude-agent.d.ts +18 -0
- package/dist/tools/claude-agent.js +40 -0
- package/dist/tools/index.d.ts +28 -0
- package/dist/tools/index.js +20 -0
- package/dist/tools/people-tools.d.ts +19 -0
- package/dist/tools/registry.d.ts +34 -0
- package/dist/tools/shared.d.ts +75 -0
- package/dist/tracing/index.d.ts +25 -0
- package/dist/tracing/index.js +69 -0
- package/dist/webhooks/index.d.ts +3 -0
- package/dist/webhooks/index.js +226 -0
- package/dist/webhooks/parse.d.ts +41 -0
- package/dist/webhooks/secret.d.ts +4 -0
- package/package.json +181 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AdapterContext, PageQuery } from "../internal/adapter.ts";
|
|
2
|
+
import type { Json, JsonObject } from "../internal/json.ts";
|
|
3
|
+
import type { QueryValue } from "../internal/url.ts";
|
|
4
|
+
import type { InstantlyClient } from "./client.ts";
|
|
5
|
+
import type { Labels } from "./map-lead.ts";
|
|
6
|
+
import type { ListEnvelope } from "./map.ts";
|
|
7
|
+
type Filters = Readonly<Record<string, QueryValue>>;
|
|
8
|
+
export declare const pageSize: (limit: number | undefined) => number;
|
|
9
|
+
export declare const after: (next: Json | undefined) => string | undefined;
|
|
10
|
+
/** One page of a GET list. */
|
|
11
|
+
export declare const listPage: (client: InstantlyClient, ctx: AdapterContext, path: string, query: PageQuery, filters?: Filters) => Promise<ListEnvelope>;
|
|
12
|
+
interface Lookup {
|
|
13
|
+
readonly path: string;
|
|
14
|
+
readonly filters: Filters;
|
|
15
|
+
/** How many pages may still be read. */
|
|
16
|
+
readonly pages: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Every record of a small lookup that belongs to one page of results, such
|
|
20
|
+
* as the tag assignments of 100 campaigns. It stops at `pages` requests and
|
|
21
|
+
* refuses to return a cut-off answer.
|
|
22
|
+
*/
|
|
23
|
+
export declare const readLookup: (client: InstantlyClient, ctx: AdapterContext, lookup: Lookup, next?: string) => Promise<JsonObject[]>;
|
|
24
|
+
/**
|
|
25
|
+
* The workspace's custom lead labels, read only when one of `statuses` is
|
|
26
|
+
* not a built-in interest status. One page: the first 100 labels.
|
|
27
|
+
*/
|
|
28
|
+
export declare const readLabels: (client: InstantlyClient, ctx: AdapterContext, statuses: readonly (Json | undefined)[]) => Promise<Labels>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AdapterContext, StatsQuery } from "../internal/adapter.ts";
|
|
2
|
+
import type { MetricRow } from "../internal/entities.ts";
|
|
3
|
+
import type { InstantlyClient } from "./client.ts";
|
|
4
|
+
/** Reads the analytics endpoint that matches the scope and grouping. */
|
|
5
|
+
export declare const readStats: (client: InstantlyClient, ctx: AdapterContext, query: StatsQuery) => Promise<MetricRow[]>;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { CapabilityDeclaration } from "./capabilities.ts";
|
|
2
|
+
import type { BlockEntry, CampaignSettings, LeadList, SenderHealth, Tag, WebhookSubscription } from "./entities-account.ts";
|
|
3
|
+
import type { Campaign, CampaignStatus, Lead, Message, MetricRow, MetricScope, OutboundEvent, Reply, ReplyCategory, Sender, Sequence, Workspace } from "./entities.ts";
|
|
4
|
+
import type { ErrorMapper } from "./errors.ts";
|
|
5
|
+
import type { Json } from "./json.ts";
|
|
6
|
+
import type { LimitDeclaration } from "./limits.ts";
|
|
7
|
+
import type { NativeCatalog, NoNative } from "./native.ts";
|
|
8
|
+
export type HttpMethod = "DELETE" | "GET" | "PATCH" | "POST" | "PUT";
|
|
9
|
+
export interface RequestSpec {
|
|
10
|
+
readonly method: HttpMethod;
|
|
11
|
+
readonly url: string;
|
|
12
|
+
readonly headers?: Readonly<Record<string, string>> | undefined;
|
|
13
|
+
readonly body?: Json | undefined;
|
|
14
|
+
/** A rate lane declared in the adapter's limits. Defaults to the global budget. */
|
|
15
|
+
readonly lane?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface VendorResponse {
|
|
18
|
+
readonly status: number;
|
|
19
|
+
readonly headers: Headers;
|
|
20
|
+
readonly body: Json;
|
|
21
|
+
}
|
|
22
|
+
export interface AdapterContext {
|
|
23
|
+
/** The only way an adapter touches the network. */
|
|
24
|
+
readonly request: (spec: RequestSpec) => Promise<VendorResponse>;
|
|
25
|
+
/** The context for another adapter, with that adapter's own rate budget. */
|
|
26
|
+
readonly forAdapter: (adapter: Adapter) => AdapterContext;
|
|
27
|
+
}
|
|
28
|
+
/** One page from the vendor. `next` is whatever the adapter needs to continue. */
|
|
29
|
+
export interface Page<Item> {
|
|
30
|
+
readonly items: readonly Item[];
|
|
31
|
+
readonly next?: Json | undefined;
|
|
32
|
+
}
|
|
33
|
+
export interface PageQuery {
|
|
34
|
+
/** A page size hint. Adapters clamp it to what the vendor allows. */
|
|
35
|
+
readonly limit?: number | undefined;
|
|
36
|
+
/** The `next` value from the previous page. */
|
|
37
|
+
readonly next?: Json | undefined;
|
|
38
|
+
}
|
|
39
|
+
export interface CampaignQuery extends PageQuery {
|
|
40
|
+
readonly status?: CampaignStatus | undefined;
|
|
41
|
+
}
|
|
42
|
+
export interface SenderQuery extends PageQuery {
|
|
43
|
+
readonly campaignId?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
export interface TimeRange {
|
|
46
|
+
/** Inclusive, ISO 8601 UTC. */
|
|
47
|
+
readonly since?: string | undefined;
|
|
48
|
+
/** Inclusive, ISO 8601 UTC. */
|
|
49
|
+
readonly until?: string | undefined;
|
|
50
|
+
}
|
|
51
|
+
export interface LeadQuery extends PageQuery, TimeRange {
|
|
52
|
+
readonly campaignId?: string | undefined;
|
|
53
|
+
/** A saved lead list. Never set together with `campaignId`. */
|
|
54
|
+
readonly listId?: string | undefined;
|
|
55
|
+
/** Only the lead records with exactly this address, lowercased. One per campaign the person is in. */
|
|
56
|
+
readonly email?: string | undefined;
|
|
57
|
+
/** Only the lead records with exactly this LinkedIn profile URL. */
|
|
58
|
+
readonly linkedinUrl?: string | undefined;
|
|
59
|
+
}
|
|
60
|
+
export interface MessageQuery extends PageQuery, TimeRange {
|
|
61
|
+
readonly campaignId?: string | undefined;
|
|
62
|
+
readonly leadId?: string | undefined;
|
|
63
|
+
/** A `threadId` from an earlier message. */
|
|
64
|
+
readonly threadId?: string | undefined;
|
|
65
|
+
/** Bodies are expensive on some vendors, so they are fetched only on request. */
|
|
66
|
+
readonly includeBody: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface ReplyQuery extends PageQuery, TimeRange {
|
|
69
|
+
readonly campaignId?: string | undefined;
|
|
70
|
+
readonly category?: ReplyCategory | undefined;
|
|
71
|
+
readonly includeBody: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface SubsequenceQuery extends PageQuery {
|
|
74
|
+
readonly campaignId: string;
|
|
75
|
+
}
|
|
76
|
+
export interface WebhookQuery extends PageQuery {
|
|
77
|
+
readonly campaignId?: string | undefined;
|
|
78
|
+
}
|
|
79
|
+
export interface StatsQuery {
|
|
80
|
+
readonly scope: MetricScope;
|
|
81
|
+
/** The campaign or sender id. Not used for the workspace scope. */
|
|
82
|
+
readonly scopeId?: string | undefined;
|
|
83
|
+
/** Inclusive `YYYY-MM-DD`. */
|
|
84
|
+
readonly from?: string | undefined;
|
|
85
|
+
/** Inclusive `YYYY-MM-DD`. */
|
|
86
|
+
readonly to?: string | undefined;
|
|
87
|
+
readonly by: "day" | "total";
|
|
88
|
+
}
|
|
89
|
+
/** What a webhook request looks like to a parser, read once by the caller. */
|
|
90
|
+
export interface WebhookRequest {
|
|
91
|
+
readonly headers: Headers;
|
|
92
|
+
readonly url: string;
|
|
93
|
+
readonly rawBody: string;
|
|
94
|
+
readonly body: Json;
|
|
95
|
+
}
|
|
96
|
+
export interface EventFormat {
|
|
97
|
+
/** `true` when the payload looks like this vendor's webhook. */
|
|
98
|
+
readonly detect: (request: WebhookRequest) => boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Checks the vendor's signature. Omitted when the vendor does not sign;
|
|
101
|
+
* the caller then relies on a shared secret in the URL or a header.
|
|
102
|
+
*/
|
|
103
|
+
readonly verify?: ((request: WebhookRequest, secret: string) => boolean) | undefined;
|
|
104
|
+
readonly parse: (request: WebhookRequest, workspaceId: string) => OutboundEvent[];
|
|
105
|
+
}
|
|
106
|
+
/** How the wrapper builds `outbound.raw`, the vendor's own API. */
|
|
107
|
+
export interface RawDescriptor {
|
|
108
|
+
readonly baseUrl: string;
|
|
109
|
+
/** Adds the credential to a request. */
|
|
110
|
+
readonly authorize: (spec: RequestSpec) => RequestSpec;
|
|
111
|
+
/**
|
|
112
|
+
* `true` for a request that only reads. Some vendors list with POST, so the
|
|
113
|
+
* method alone does not decide it. `path` is the path that will be sent,
|
|
114
|
+
* relative to `baseUrl`: dot segments are resolved, repeated slashes are
|
|
115
|
+
* collapsed and it has no query.
|
|
116
|
+
*/
|
|
117
|
+
readonly isRead: (method: HttpMethod, path: string) => boolean;
|
|
118
|
+
/**
|
|
119
|
+
* `true` for a read whose response holds secrets: API keys, mailbox
|
|
120
|
+
* passwords, proxy credentials. `raw` returns a response as it is, so these
|
|
121
|
+
* are refused whatever the method and even when writes are allowed.
|
|
122
|
+
*/
|
|
123
|
+
readonly isSecret?: ((path: string, query: URLSearchParams) => boolean) | undefined;
|
|
124
|
+
}
|
|
125
|
+
export type Maturity = "beta" | "stable" | "unverified";
|
|
126
|
+
/** What a read costs in vendor requests, so a caller can estimate before reading. */
|
|
127
|
+
export interface OperationCost {
|
|
128
|
+
/** Requests per page of a listing, or per lookup. */
|
|
129
|
+
readonly perPage: number;
|
|
130
|
+
/** The page size the adapter asks the vendor for. */
|
|
131
|
+
readonly pageSize?: number | undefined;
|
|
132
|
+
/** Extra requests per record, for example one per lead to fetch a body. */
|
|
133
|
+
readonly perRecord?: number | undefined;
|
|
134
|
+
}
|
|
135
|
+
export interface Adapter<Native extends NativeCatalog = NoNative> {
|
|
136
|
+
readonly name: string;
|
|
137
|
+
/** A label for this credential's client or workspace. Part of every ref. */
|
|
138
|
+
readonly workspaceId: string;
|
|
139
|
+
/**
|
|
140
|
+
* `unverified`: written from documentation and tested offline. `beta`: its
|
|
141
|
+
* reads were run against a live account. `stable`: its fixtures are captured
|
|
142
|
+
* responses and the live checks pass on a schedule.
|
|
143
|
+
*/
|
|
144
|
+
readonly maturity: Maturity;
|
|
145
|
+
/** Secrets the request engine must keep out of errors, hooks and logs. */
|
|
146
|
+
readonly secrets: readonly string[];
|
|
147
|
+
/** Omitted or partial: anything not declared is unsupported. */
|
|
148
|
+
readonly capabilities?: CapabilityDeclaration | undefined;
|
|
149
|
+
readonly limits: LimitDeclaration;
|
|
150
|
+
readonly raw: RawDescriptor;
|
|
151
|
+
readonly mapError: ErrorMapper;
|
|
152
|
+
readonly events?: EventFormat | undefined;
|
|
153
|
+
/** What is assumed and not yet confirmed against the live API. */
|
|
154
|
+
readonly caveats?: readonly string[] | undefined;
|
|
155
|
+
/** Request costs by operation kind, for `outbound.estimate()`. */
|
|
156
|
+
readonly costs?: Readonly<Record<string, OperationCost>> | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* The vendor's reads that have no normalized form, by name. With the
|
|
159
|
+
* normalized reads they cover everything the vendor's API can report.
|
|
160
|
+
*/
|
|
161
|
+
readonly native?: Native | undefined;
|
|
162
|
+
/** Set by `combine()`: the adapters behind this one. */
|
|
163
|
+
readonly members?: readonly Adapter[] | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Set by `combine()`: the adapter for one workspace label, or for one
|
|
166
|
+
* member named as `provider:workspace`. When several members carry the
|
|
167
|
+
* label, as a client on two tools does, it is those members combined.
|
|
168
|
+
* `undefined` when no member matches.
|
|
169
|
+
*/
|
|
170
|
+
readonly scope?: ((workspaceId: string) => Adapter | undefined) | undefined;
|
|
171
|
+
readonly listCampaigns: (query: CampaignQuery, ctx: AdapterContext) => Promise<Page<Campaign>>;
|
|
172
|
+
readonly getCampaign: (id: string, ctx: AdapterContext) => Promise<Campaign>;
|
|
173
|
+
readonly getSequence?: (campaignId: string, ctx: AdapterContext) => Promise<Sequence>;
|
|
174
|
+
readonly listSenders?: (query: SenderQuery, ctx: AdapterContext) => Promise<Page<Sender>>;
|
|
175
|
+
readonly getSender?: (id: string, ctx: AdapterContext) => Promise<Sender>;
|
|
176
|
+
readonly listLeads?: (query: LeadQuery, ctx: AdapterContext) => Promise<Page<Lead>>;
|
|
177
|
+
readonly getLead?: (id: string, ctx: AdapterContext) => Promise<Lead>;
|
|
178
|
+
readonly listMessages?: (query: MessageQuery, ctx: AdapterContext) => Promise<Page<Message>>;
|
|
179
|
+
readonly listReplies?: (query: ReplyQuery, ctx: AdapterContext) => Promise<Page<Reply>>;
|
|
180
|
+
readonly stats?: (query: StatsQuery, ctx: AdapterContext) => Promise<readonly MetricRow[]>;
|
|
181
|
+
readonly listWorkspaces?: (query: PageQuery, ctx: AdapterContext) => Promise<Page<Workspace>>;
|
|
182
|
+
readonly getCampaignSettings?: (campaignId: string, ctx: AdapterContext) => Promise<CampaignSettings>;
|
|
183
|
+
readonly listSubsequences?: (query: SubsequenceQuery, ctx: AdapterContext) => Promise<Page<Sequence>>;
|
|
184
|
+
readonly getSenderHealth?: (senderId: string, ctx: AdapterContext) => Promise<SenderHealth>;
|
|
185
|
+
readonly listLists?: (query: PageQuery, ctx: AdapterContext) => Promise<Page<LeadList>>;
|
|
186
|
+
readonly listBlocklist?: (query: PageQuery, ctx: AdapterContext) => Promise<Page<BlockEntry>>;
|
|
187
|
+
readonly listTags?: (query: PageQuery, ctx: AdapterContext) => Promise<Page<Tag>>;
|
|
188
|
+
readonly listWebhooks?: (query: WebhookQuery, ctx: AdapterContext) => Promise<Page<WebhookSubscription>>;
|
|
189
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** Whether the vendor filters for us, we filter after fetching, or neither. */
|
|
2
|
+
export type FilterGrade = "client" | "server" | false;
|
|
3
|
+
/** Whether numbers come straight from the vendor or are computed by us. */
|
|
4
|
+
export type StatGrade = "derived" | "exact" | false;
|
|
5
|
+
export interface Capabilities {
|
|
6
|
+
/** Filter campaigns by status. */
|
|
7
|
+
"campaigns.status": FilterGrade;
|
|
8
|
+
/** A campaign's schedule, daily caps, tracking and stop rules. */
|
|
9
|
+
"campaigns.settings": boolean;
|
|
10
|
+
/** A campaign's steps and variants. */
|
|
11
|
+
sequence: boolean;
|
|
12
|
+
/** The follow-up sequences attached to a campaign. */
|
|
13
|
+
"sequence.subsequences": boolean;
|
|
14
|
+
/** List every sender on the credential. */
|
|
15
|
+
"senders.list": boolean;
|
|
16
|
+
"senders.get": boolean;
|
|
17
|
+
/** List the senders attached to one campaign. Does not need `senders.list`. */
|
|
18
|
+
"senders.byCampaign": boolean;
|
|
19
|
+
"senders.warmup": boolean;
|
|
20
|
+
/** DNS records, connection state and warmup traffic for one sender. */
|
|
21
|
+
"senders.health": boolean;
|
|
22
|
+
/** List every lead on the credential, across campaigns. */
|
|
23
|
+
"leads.list": boolean;
|
|
24
|
+
"leads.get": boolean;
|
|
25
|
+
/** List the leads of one campaign. Does not need `leads.list`. */
|
|
26
|
+
"leads.byCampaign": boolean;
|
|
27
|
+
"leads.since": FilterGrade;
|
|
28
|
+
/** Find a lead by its exact email address or LinkedIn profile, without walking every lead. */
|
|
29
|
+
"leads.lookup": boolean;
|
|
30
|
+
/** Leads carry open, click and reply counts. */
|
|
31
|
+
"leads.engagement": boolean;
|
|
32
|
+
/** List the saved lead lists. */
|
|
33
|
+
"lists.list": boolean;
|
|
34
|
+
/** List the leads of one saved list. */
|
|
35
|
+
"lists.leads": boolean;
|
|
36
|
+
/** Every message for one lead, in order. */
|
|
37
|
+
"leads.timeline": boolean;
|
|
38
|
+
"messages.list": boolean;
|
|
39
|
+
/** Whether message bodies are returned: all, some, or none. */
|
|
40
|
+
"messages.body": "full" | "sampled" | false;
|
|
41
|
+
"messages.since": FilterGrade;
|
|
42
|
+
/** Every message of one conversation, by its thread id. */
|
|
43
|
+
"messages.byThread": boolean;
|
|
44
|
+
"replies.list": boolean;
|
|
45
|
+
/** Reply categories come from the vendor, or are not available. */
|
|
46
|
+
"replies.category": "vendor" | false;
|
|
47
|
+
"replies.since": FilterGrade;
|
|
48
|
+
"stats.workspace": StatGrade;
|
|
49
|
+
"stats.campaign": StatGrade;
|
|
50
|
+
"stats.byDay": StatGrade;
|
|
51
|
+
"stats.byStep": StatGrade;
|
|
52
|
+
"stats.bySender": StatGrade;
|
|
53
|
+
workspaces: boolean;
|
|
54
|
+
/** The addresses, domains and profiles the account never contacts. */
|
|
55
|
+
blocklist: boolean;
|
|
56
|
+
tags: boolean;
|
|
57
|
+
/** The webhooks registered with the vendor. */
|
|
58
|
+
"webhooks.list": boolean;
|
|
59
|
+
/** The vendor's own reads are available by name through `outbound.native`. */
|
|
60
|
+
native: boolean;
|
|
61
|
+
/** Webhook payloads can be parsed into `OutboundEvent`s. */
|
|
62
|
+
"events.parse": boolean;
|
|
63
|
+
/** How a webhook is authenticated. */
|
|
64
|
+
"events.verify": "secret" | "signature" | false;
|
|
65
|
+
/** Whether list calls reveal deleted records. */
|
|
66
|
+
deletionDetection: boolean;
|
|
67
|
+
}
|
|
68
|
+
export type CapabilityKey = keyof Capabilities;
|
|
69
|
+
export type CapabilityDeclaration = Partial<Capabilities>;
|
|
70
|
+
export declare const NO_CAPABILITIES: Capabilities;
|
|
71
|
+
/** Fills every undeclared key with `false`. */
|
|
72
|
+
export declare const resolveCapabilities: (declared?: CapabilityDeclaration) => Capabilities;
|
|
73
|
+
export declare const CAPABILITY_KEYS: CapabilityKey[];
|
|
74
|
+
/**
|
|
75
|
+
* What every backend can do. Used when several adapters sit behind one
|
|
76
|
+
* instance, and to stop a plugin widening what the adapter declared.
|
|
77
|
+
*/
|
|
78
|
+
export declare const intersectCapabilities: (first: Capabilities, ...rest: readonly Capabilities[]) => Capabilities;
|
|
79
|
+
export interface CapabilityGate {
|
|
80
|
+
readonly capabilities: Capabilities;
|
|
81
|
+
readonly provider: string;
|
|
82
|
+
/** The plugin that turned a capability off, by key. */
|
|
83
|
+
readonly narrowedBy: ReadonlyMap<CapabilityKey, string>;
|
|
84
|
+
}
|
|
85
|
+
/** Throws `Unsupported` unless the capability is available. */
|
|
86
|
+
export declare const requireCapability: <Key extends CapabilityKey>(gate: CapabilityGate, key: Key, what: string) => Exclude<Capabilities[Key], false>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Json } from "./json.ts";
|
|
2
|
+
export interface CursorScope {
|
|
3
|
+
readonly provider: string;
|
|
4
|
+
readonly workspaceId: string;
|
|
5
|
+
/** The listing the cursor belongs to, for example `campaigns.list`. */
|
|
6
|
+
readonly action: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const encodeCursor: (scope: CursorScope, next: Json) => string;
|
|
9
|
+
/** Returns the adapter's `next` value, or throws `Invalid` for a foreign cursor. */
|
|
10
|
+
export declare const decodeCursor: (scope: CursorScope, cursor: string) => Json;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { OutboundHooks } from "../hooks.ts";
|
|
2
|
+
import type { LimitDeclaration } from "../limits.ts";
|
|
3
|
+
import type { RateLimitStore } from "./rate-store.ts";
|
|
4
|
+
import type { Runtime } from "./runtime.ts";
|
|
5
|
+
export declare const DEFAULT_LANE = "default";
|
|
6
|
+
export interface AcquireOptions {
|
|
7
|
+
readonly lane: string;
|
|
8
|
+
readonly runtime: Runtime;
|
|
9
|
+
readonly hooks: OutboundHooks;
|
|
10
|
+
readonly signal?: AbortSignal | undefined;
|
|
11
|
+
/** An epoch in milliseconds after which waiting is pointless. */
|
|
12
|
+
readonly deadlineAt?: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface BudgetWindowUsage {
|
|
15
|
+
readonly lane: string;
|
|
16
|
+
/** Requests allowed in the window after `share` and any slowdown. */
|
|
17
|
+
readonly requests: number;
|
|
18
|
+
readonly perMs: number;
|
|
19
|
+
readonly used: number;
|
|
20
|
+
}
|
|
21
|
+
export interface BudgetOptions {
|
|
22
|
+
readonly key: string;
|
|
23
|
+
readonly provider: string;
|
|
24
|
+
readonly limits: LimitDeclaration;
|
|
25
|
+
readonly share: number;
|
|
26
|
+
readonly store: RateLimitStore;
|
|
27
|
+
}
|
|
28
|
+
export declare class Budget {
|
|
29
|
+
#private;
|
|
30
|
+
constructor(options: BudgetOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Waits for a concurrency slot and for room in every window. Returns how
|
|
33
|
+
* long it waited. The caller must call `release()` afterwards.
|
|
34
|
+
*/
|
|
35
|
+
acquire(options: AcquireOptions): Promise<number>;
|
|
36
|
+
release(): void;
|
|
37
|
+
/** Called on a 429: pause the lane and halve the rate. */
|
|
38
|
+
rateLimited(lane: string, retryAfterMs: number, now: number): Promise<void>;
|
|
39
|
+
/** Called when the vendor's headers say the window is spent. */
|
|
40
|
+
exhausted(resetInMs: number, now: number): Promise<void>;
|
|
41
|
+
/** Called on a success: climb back toward the declared rate. */
|
|
42
|
+
succeeded(): void;
|
|
43
|
+
usage(now: number): Promise<BudgetWindowUsage[]>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Adapter, AdapterContext } from "../adapter.ts";
|
|
2
|
+
import type { OutboundHooks } from "../hooks.ts";
|
|
3
|
+
import type { BudgetWindowUsage } from "./budget.ts";
|
|
4
|
+
import type { RateLimitStore } from "./rate-store.ts";
|
|
5
|
+
import type { CallState } from "./request.ts";
|
|
6
|
+
import type { RetriesOption } from "./retry.ts";
|
|
7
|
+
import type { Runtime } from "./runtime.ts";
|
|
8
|
+
/** Options every call accepts. Set defaults on the constructor. */
|
|
9
|
+
export interface OperationOptions {
|
|
10
|
+
readonly signal?: AbortSignal | undefined;
|
|
11
|
+
/** Milliseconds allowed for each attempt. Defaults to 30,000. */
|
|
12
|
+
readonly timeout?: number | undefined;
|
|
13
|
+
/** Retries after the first attempt, or a policy. Defaults to 4. */
|
|
14
|
+
readonly retries?: RetriesOption | undefined;
|
|
15
|
+
/** A total time budget in milliseconds, across retries and throttle waits. */
|
|
16
|
+
readonly deadline?: number | undefined;
|
|
17
|
+
/** Stop after this many vendor requests, so one question cannot spend the limit. */
|
|
18
|
+
readonly maxRequests?: number | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface EngineOptions {
|
|
21
|
+
readonly runtime?: Partial<Runtime> | undefined;
|
|
22
|
+
readonly store?: RateLimitStore | undefined;
|
|
23
|
+
readonly hooks?: OutboundHooks | undefined;
|
|
24
|
+
/** The fraction of each vendor's published limit to use. Defaults to 0.5. */
|
|
25
|
+
readonly share?: number | undefined;
|
|
26
|
+
readonly defaults?: OperationOptions | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface LimitsSnapshot {
|
|
29
|
+
readonly provider: string;
|
|
30
|
+
readonly workspaceId: string;
|
|
31
|
+
readonly share: number;
|
|
32
|
+
readonly windows: readonly BudgetWindowUsage[];
|
|
33
|
+
/** Where the adapter's declared numbers came from. */
|
|
34
|
+
readonly source: string;
|
|
35
|
+
}
|
|
36
|
+
export declare class RequestEngine {
|
|
37
|
+
#private;
|
|
38
|
+
constructor(options?: EngineOptions);
|
|
39
|
+
get hooks(): OutboundHooks;
|
|
40
|
+
now(): number;
|
|
41
|
+
/** Starts the accounting for one SDK call. */
|
|
42
|
+
begin(options?: OperationOptions): CallState;
|
|
43
|
+
contextFor(adapter: Adapter, state: CallState): AdapterContext;
|
|
44
|
+
limits(adapter: Adapter): Promise<LimitsSnapshot>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RateWindow } from "../limits.ts";
|
|
2
|
+
export interface RateLimitStore {
|
|
3
|
+
/**
|
|
4
|
+
* Reserves one request in every window for `key`. Returns 0 when the
|
|
5
|
+
* request may go now, otherwise how many milliseconds to wait before
|
|
6
|
+
* trying again. Nothing is reserved when it returns a wait.
|
|
7
|
+
*/
|
|
8
|
+
readonly reserve: (key: string, windows: readonly RateWindow[], now: number) => Promise<number>;
|
|
9
|
+
/** Blocks `key` until `until` (an epoch in milliseconds), after a 429. */
|
|
10
|
+
readonly pause: (key: string, until: number) => Promise<void>;
|
|
11
|
+
/** Requests counted in each window right now, in the order given. */
|
|
12
|
+
readonly usage: (key: string, windows: readonly RateWindow[], now: number) => Promise<number[]>;
|
|
13
|
+
}
|
|
14
|
+
/** A sliding-window log per key, held in this process. */
|
|
15
|
+
export declare class MemoryRateLimitStore implements RateLimitStore {
|
|
16
|
+
#private;
|
|
17
|
+
reserve(key: string, windows: readonly RateWindow[], now: number): Promise<number>;
|
|
18
|
+
pause(key: string, until: number): Promise<void>;
|
|
19
|
+
usage(key: string, windows: readonly RateWindow[], now: number): Promise<number[]>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The process-wide store, so every instance on one credential shares one
|
|
23
|
+
* budget even when the package is bundled more than once.
|
|
24
|
+
*/
|
|
25
|
+
export declare const defaultRateLimitStore: () => RateLimitStore;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Adapter, RequestSpec, VendorResponse } from "../adapter.ts";
|
|
2
|
+
import type { OutboundHooks } from "../hooks.ts";
|
|
3
|
+
import type { Budget } from "./budget.ts";
|
|
4
|
+
import type { RetryPolicy } from "./retry.ts";
|
|
5
|
+
import type { Runtime } from "./runtime.ts";
|
|
6
|
+
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
7
|
+
/** What one SDK call has used so far. Shared by every request it makes. */
|
|
8
|
+
export interface CallState {
|
|
9
|
+
requests: number;
|
|
10
|
+
throttledMs: number;
|
|
11
|
+
readonly signal: AbortSignal | undefined;
|
|
12
|
+
readonly timeoutMs: number;
|
|
13
|
+
readonly retry: RetryPolicy;
|
|
14
|
+
/** An epoch in milliseconds: the total budget across retries and waits. */
|
|
15
|
+
readonly deadlineAt: number | undefined;
|
|
16
|
+
/** Stop after this many vendor requests. A plugin may lower it. */
|
|
17
|
+
maxRequests: number | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface RequestEnvironment {
|
|
20
|
+
readonly adapter: Adapter;
|
|
21
|
+
readonly budget: Budget;
|
|
22
|
+
readonly runtime: Runtime;
|
|
23
|
+
readonly hooks: OutboundHooks;
|
|
24
|
+
readonly state: CallState;
|
|
25
|
+
}
|
|
26
|
+
/** Sends one request, retrying what is safe to retry. */
|
|
27
|
+
export declare const execute: (spec: RequestSpec, environment: RequestEnvironment) => Promise<VendorResponse>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Json } from "../json.ts";
|
|
2
|
+
export interface RetryPolicy {
|
|
3
|
+
/** Retries after the first attempt. */
|
|
4
|
+
readonly max: number;
|
|
5
|
+
/** Delay before retry `attempt` (starting at 1), given a random number in [0, 1). */
|
|
6
|
+
readonly backoff: (attempt: number, random: number) => number;
|
|
7
|
+
}
|
|
8
|
+
/** Exponential backoff with full jitter: 1 s base, 60 s cap. */
|
|
9
|
+
export declare const fullJitterBackoff: (attempt: number, random: number) => number;
|
|
10
|
+
export declare const DEFAULT_RETRIES = 4;
|
|
11
|
+
export type RetriesOption = number | {
|
|
12
|
+
readonly max: number;
|
|
13
|
+
readonly backoff?: RetryPolicy["backoff"] | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare const resolveRetryPolicy: (option: RetriesOption | undefined) => RetryPolicy;
|
|
16
|
+
/**
|
|
17
|
+
* How long the vendor asked us to wait: `Retry-After` as seconds or an HTTP
|
|
18
|
+
* date, or seconds found in the response body.
|
|
19
|
+
*/
|
|
20
|
+
export declare const parseRetryAfter: (headers: Headers, body: Json | undefined, now: number) => number | undefined;
|
|
21
|
+
export declare const isRetryableStatus: (status: number) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OutboundError } from "../errors.ts";
|
|
2
|
+
export interface Runtime {
|
|
3
|
+
readonly now: () => number;
|
|
4
|
+
/** Runs `onFire` after `ms`. Returns a function that cancels it. */
|
|
5
|
+
readonly timer: (ms: number, onFire: () => void) => () => void;
|
|
6
|
+
/** A number in [0, 1), used for backoff jitter. */
|
|
7
|
+
readonly random: () => number;
|
|
8
|
+
readonly fetch: typeof fetch;
|
|
9
|
+
}
|
|
10
|
+
export declare const defaultRuntime: Runtime;
|
|
11
|
+
export declare const abortedError: (provider: string) => OutboundError;
|
|
12
|
+
/** Waits `ms`, or rejects as soon as `signal` aborts. */
|
|
13
|
+
export declare const sleep: (runtime: Runtime, ms: number, provider: string, signal?: AbortSignal) => Promise<void>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Campaign, Lead, Message, Reply, Sender, Sequence, Workspace } from "./entities.ts";
|
|
3
|
+
/** One window in which a campaign may send. */
|
|
4
|
+
export declare const sendingWindowSchema: z.ZodObject<{
|
|
5
|
+
days: z.ZodArray<z.ZodNumber>;
|
|
6
|
+
from: z.ZodNullable<z.ZodString>;
|
|
7
|
+
name: z.ZodNullable<z.ZodString>;
|
|
8
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
9
|
+
to: z.ZodNullable<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type SendingWindow = z.infer<typeof sendingWindowSchema>;
|
|
12
|
+
/** How a campaign is set up to send. `sourceId` is the campaign's id. */
|
|
13
|
+
export declare const campaignSettingsSchema: z.ZodObject<{
|
|
14
|
+
campaignRef: z.ZodString;
|
|
15
|
+
dailyLimit: z.ZodNullable<z.ZodNumber>;
|
|
16
|
+
dailyNewLeads: z.ZodNullable<z.ZodNumber>;
|
|
17
|
+
endDate: z.ZodNullable<z.ZodISODate>;
|
|
18
|
+
gapMinutes: z.ZodNullable<z.ZodNumber>;
|
|
19
|
+
plainText: z.ZodNullable<z.ZodBoolean>;
|
|
20
|
+
schedule: z.ZodArray<z.ZodObject<{
|
|
21
|
+
days: z.ZodArray<z.ZodNumber>;
|
|
22
|
+
from: z.ZodNullable<z.ZodString>;
|
|
23
|
+
name: z.ZodNullable<z.ZodString>;
|
|
24
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
25
|
+
to: z.ZodNullable<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>>;
|
|
27
|
+
startDate: z.ZodNullable<z.ZodISODate>;
|
|
28
|
+
stopOnAutoReply: z.ZodNullable<z.ZodBoolean>;
|
|
29
|
+
stopOnReply: z.ZodNullable<z.ZodBoolean>;
|
|
30
|
+
tracking: z.ZodObject<{
|
|
31
|
+
clicks: z.ZodNullable<z.ZodBoolean>;
|
|
32
|
+
opens: z.ZodNullable<z.ZodBoolean>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
provider: z.ZodString;
|
|
35
|
+
raw: z.ZodJSONSchema;
|
|
36
|
+
ref: z.ZodString;
|
|
37
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
38
|
+
sourceId: z.ZodString;
|
|
39
|
+
workspaceId: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
export type CampaignSettings = z.infer<typeof campaignSettingsSchema>;
|
|
42
|
+
/** What the vendor knows about a sender's deliverability. `sourceId` is the sender's id. */
|
|
43
|
+
export declare const senderHealthSchema: z.ZodObject<{
|
|
44
|
+
blacklisted: z.ZodNullable<z.ZodBoolean>;
|
|
45
|
+
checkedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
46
|
+
connected: z.ZodNullable<z.ZodBoolean>;
|
|
47
|
+
dns: z.ZodObject<{
|
|
48
|
+
dkim: z.ZodNullable<z.ZodBoolean>;
|
|
49
|
+
dmarc: z.ZodNullable<z.ZodBoolean>;
|
|
50
|
+
mx: z.ZodNullable<z.ZodBoolean>;
|
|
51
|
+
spf: z.ZodNullable<z.ZodBoolean>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
domain: z.ZodNullable<z.ZodString>;
|
|
54
|
+
issues: z.ZodArray<z.ZodString>;
|
|
55
|
+
senderRef: z.ZodString;
|
|
56
|
+
warmup: z.ZodNullable<z.ZodObject<{
|
|
57
|
+
inbox: z.ZodNullable<z.ZodNumber>;
|
|
58
|
+
received: z.ZodNullable<z.ZodNumber>;
|
|
59
|
+
score: z.ZodNullable<z.ZodNumber>;
|
|
60
|
+
sent: z.ZodNullable<z.ZodNumber>;
|
|
61
|
+
spam: z.ZodNullable<z.ZodNumber>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
provider: z.ZodString;
|
|
64
|
+
raw: z.ZodJSONSchema;
|
|
65
|
+
ref: z.ZodString;
|
|
66
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
67
|
+
sourceId: z.ZodString;
|
|
68
|
+
workspaceId: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export type SenderHealth = z.infer<typeof senderHealthSchema>;
|
|
71
|
+
/** A saved list of leads or companies that campaigns draw from. */
|
|
72
|
+
export declare const leadListSchema: z.ZodObject<{
|
|
73
|
+
createdAt: z.ZodNullable<z.ZodISODateTime>;
|
|
74
|
+
kind: z.ZodEnum<{
|
|
75
|
+
companies: "companies";
|
|
76
|
+
leads: "leads";
|
|
77
|
+
}>;
|
|
78
|
+
name: z.ZodString;
|
|
79
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
80
|
+
provider: z.ZodString;
|
|
81
|
+
raw: z.ZodJSONSchema;
|
|
82
|
+
ref: z.ZodString;
|
|
83
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
84
|
+
sourceId: z.ZodString;
|
|
85
|
+
workspaceId: z.ZodString;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
export type LeadList = z.infer<typeof leadListSchema>;
|
|
88
|
+
/** One address, domain or profile the account never contacts. */
|
|
89
|
+
export declare const blockEntrySchema: z.ZodObject<{
|
|
90
|
+
createdAt: z.ZodNullable<z.ZodISODateTime>;
|
|
91
|
+
kind: z.ZodEnum<{
|
|
92
|
+
email: "email";
|
|
93
|
+
linkedin: "linkedin";
|
|
94
|
+
company: "company";
|
|
95
|
+
domain: "domain";
|
|
96
|
+
other: "other";
|
|
97
|
+
}>;
|
|
98
|
+
value: z.ZodString;
|
|
99
|
+
provider: z.ZodString;
|
|
100
|
+
raw: z.ZodJSONSchema;
|
|
101
|
+
ref: z.ZodString;
|
|
102
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
103
|
+
sourceId: z.ZodString;
|
|
104
|
+
workspaceId: z.ZodString;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
export type BlockEntry = z.infer<typeof blockEntrySchema>;
|
|
107
|
+
export declare const tagSchema: z.ZodObject<{
|
|
108
|
+
description: z.ZodNullable<z.ZodString>;
|
|
109
|
+
name: z.ZodString;
|
|
110
|
+
provider: z.ZodString;
|
|
111
|
+
raw: z.ZodJSONSchema;
|
|
112
|
+
ref: z.ZodString;
|
|
113
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
114
|
+
sourceId: z.ZodString;
|
|
115
|
+
workspaceId: z.ZodString;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export type Tag = z.infer<typeof tagSchema>;
|
|
118
|
+
/** A webhook registered with the vendor. */
|
|
119
|
+
export declare const webhookSubscriptionSchema: z.ZodObject<{
|
|
120
|
+
active: z.ZodNullable<z.ZodBoolean>;
|
|
121
|
+
campaignRefs: z.ZodArray<z.ZodString>;
|
|
122
|
+
createdAt: z.ZodNullable<z.ZodISODateTime>;
|
|
123
|
+
events: z.ZodArray<z.ZodString>;
|
|
124
|
+
name: z.ZodNullable<z.ZodString>;
|
|
125
|
+
url: z.ZodString;
|
|
126
|
+
provider: z.ZodString;
|
|
127
|
+
raw: z.ZodJSONSchema;
|
|
128
|
+
ref: z.ZodString;
|
|
129
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
130
|
+
sourceId: z.ZodString;
|
|
131
|
+
workspaceId: z.ZodString;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
export type WebhookSubscription = z.infer<typeof webhookSubscriptionSchema>;
|
|
134
|
+
/** Any record a list or get call returns. */
|
|
135
|
+
export type Entity = BlockEntry | Campaign | CampaignSettings | Lead | LeadList | Message | Reply | Sender | SenderHealth | Sequence | Tag | WebhookSubscription | Workspace;
|