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,14 @@
|
|
|
1
|
+
import type { Alert } from "../alerts/index.ts";
|
|
2
|
+
import type { OutboundEvent } from "../internal/entities.ts";
|
|
3
|
+
import type { CardSpec } from "./spec.ts";
|
|
4
|
+
export interface EventCardOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Show the message text. It was written by a prospect, so it is off unless
|
|
7
|
+
* asked for, cut to 500 characters and shown as a quote.
|
|
8
|
+
*/
|
|
9
|
+
readonly includeText?: boolean | undefined;
|
|
10
|
+
}
|
|
11
|
+
/** A card for one webhook event, for posting to a channel as it arrives. */
|
|
12
|
+
export declare const eventCard: (event: OutboundEvent, options?: EventCardOptions) => CardSpec;
|
|
13
|
+
/** A card for one alert from the alerts plugin's `notify`. */
|
|
14
|
+
export declare const alertCard: (alert: Alert) => CardSpec;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Json, JsonObject } from "../internal/json.ts";
|
|
2
|
+
import type { Stat } from "./content.ts";
|
|
3
|
+
export declare const LEFT = "left";
|
|
4
|
+
export declare const RIGHT = "right";
|
|
5
|
+
/** A rate with `low` and `high` beside it, as the ops insights report one. */
|
|
6
|
+
export declare const measured: (value: Json | undefined) => string;
|
|
7
|
+
/** A rate with an `interval` object beside it, as the copy insights report one. */
|
|
8
|
+
export declare const withInterval: (value: JsonObject, rateKey: string, intervalKey: string) => string;
|
|
9
|
+
/** Sent, replies, positive and bounced, as fields. */
|
|
10
|
+
export declare const totalStats: (totals: Json | undefined) => Stat[];
|
|
11
|
+
/** `🔴 finding` for an item with a `severity` and a `finding`. */
|
|
12
|
+
export declare const flagged: (item: JsonObject, prefix?: string) => string;
|
|
13
|
+
/** The counts in an object as fields, biggest first, zeroes left out. */
|
|
14
|
+
export declare const countStats: (counts: JsonObject) => Stat[];
|
|
15
|
+
/**
|
|
16
|
+
* The headline of a check. Says so when nothing was read, since a check that
|
|
17
|
+
* read nothing has not passed.
|
|
18
|
+
*/
|
|
19
|
+
export declare const verdict: (checked: number | null, problem: string | null, clean: string) => string;
|
|
20
|
+
export declare const range: (period: Json | undefined) => string;
|
|
21
|
+
/** `4.2%` as a chart value: one decimal, or `null`. */
|
|
22
|
+
export declare const percentPoint: (rate: number | null) => number | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ToolResult } from "../tools/index.ts";
|
|
2
|
+
import type { CardOptions } from "./content.ts";
|
|
3
|
+
import type { CardSpec } from "./spec.ts";
|
|
4
|
+
/** Every tool and insight that has a card of its own. */
|
|
5
|
+
export declare const CARD_NAMES: readonly string[];
|
|
6
|
+
/**
|
|
7
|
+
* The card for one tool or insight result. `name` is the tool's name, such as
|
|
8
|
+
* `campaign_overview` or `hot_leads`. Never throws: a failed result becomes a
|
|
9
|
+
* card that says what failed.
|
|
10
|
+
*/
|
|
11
|
+
export declare const cardFor: (name: string, result: ToolResult, options?: CardOptions) => CardSpec;
|
|
12
|
+
export interface DigestSection {
|
|
13
|
+
/** The tool's name, such as `bounce_watch`. */
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly result: ToolResult;
|
|
16
|
+
}
|
|
17
|
+
export interface DigestOptions {
|
|
18
|
+
readonly title: string;
|
|
19
|
+
readonly subtitle?: string | undefined;
|
|
20
|
+
/** At most nine are shown, so the message stays inside a chat platform's limits. */
|
|
21
|
+
readonly sections: readonly DigestSection[];
|
|
22
|
+
readonly links?: CardOptions["links"];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* One message made of several results, each cut down to its finding, its
|
|
26
|
+
* first numbers and its first lines. For a morning summary in a channel.
|
|
27
|
+
*/
|
|
28
|
+
export declare const digest: (options: DigestOptions) => CardSpec;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { JsonObject } from "../internal/json.ts";
|
|
2
|
+
import type { CardElement } from "./spec.ts";
|
|
3
|
+
type Lookup = (key: string) => CardElement | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* A card's numbers as a bordered grid of tiles. A client that cannot draw a
|
|
6
|
+
* layout shows `plain`, the two-column list.
|
|
7
|
+
*/
|
|
8
|
+
export declare const richFields: (element: CardElement, find: Lookup, plain: JsonObject) => JsonObject[];
|
|
9
|
+
/** A data table with typed cells, every row on one page. */
|
|
10
|
+
export declare const richTable: (caption: string, headers: readonly string[], rows: readonly (readonly string[])[]) => JsonObject;
|
|
11
|
+
/**
|
|
12
|
+
* A short table as cards side by side, when the table says which columns are
|
|
13
|
+
* a card's title, subtitle and body. `null` when it does not, or has too
|
|
14
|
+
* many rows to read as cards.
|
|
15
|
+
*/
|
|
16
|
+
export declare const richPeople: (element: CardElement, headers: readonly string[], rows: readonly (readonly string[])[], plain: JsonObject) => JsonObject[] | null;
|
|
17
|
+
/** Link buttons, the first one in Slack's primary colour. */
|
|
18
|
+
export declare const richActions: (element: CardElement, find: Lookup) => JsonObject;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Json, JsonObject } from "../internal/json.ts";
|
|
2
|
+
import type { CardElement } from "./spec.ts";
|
|
3
|
+
export declare const cut: (value: string, max: number) => string;
|
|
4
|
+
export declare const filled: (value: string) => string;
|
|
5
|
+
/** The card format's `**bold**` is `*bold*` in Slack. */
|
|
6
|
+
export declare const bold: (value: string) => string;
|
|
7
|
+
export declare const mrkdwn: (value: string, max: number) => JsonObject;
|
|
8
|
+
export declare const plainText: (value: string, max: number) => JsonObject;
|
|
9
|
+
export declare const prop: (element: CardElement, key: string) => string;
|
|
10
|
+
export declare const cells: (row: Json) => string[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JsonObject } from "../internal/json.ts";
|
|
2
|
+
import type { CardSpec } from "./spec.ts";
|
|
3
|
+
export interface SlackOptions {
|
|
4
|
+
/**
|
|
5
|
+
* `rich` (the default) uses Slack's layout, card and typed table cells.
|
|
6
|
+
* `plain` writes exactly what Chat SDK's Slack adapter writes for the card.
|
|
7
|
+
*/
|
|
8
|
+
readonly style?: "plain" | "rich" | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The card as Slack blocks, for `chat.postMessage({ blocks })` or an incoming
|
|
12
|
+
* webhook. Slack draws one table and two charts per message; a card with more
|
|
13
|
+
* shows the rest as aligned text.
|
|
14
|
+
*/
|
|
15
|
+
export declare const toSlackBlocks: (spec: CardSpec, options?: SlackOptions) => JsonObject[];
|
|
16
|
+
export interface SlackMessage {
|
|
17
|
+
readonly text: string;
|
|
18
|
+
readonly blocks: JsonObject[];
|
|
19
|
+
}
|
|
20
|
+
/** A whole Slack message: spread it into `chat.postMessage` or post it to a webhook. */
|
|
21
|
+
export declare const toSlackMessage: (spec: CardSpec, options?: SlackOptions) => SlackMessage;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { JsonObject } from "../internal/json.ts";
|
|
2
|
+
export type CardComponent = "Actions" | "Card" | "Chart" | "Divider" | "Field" | "Fields" | "LinkButton" | "Table" | "Text";
|
|
3
|
+
export interface CardElement {
|
|
4
|
+
readonly type: CardComponent;
|
|
5
|
+
readonly props: JsonObject;
|
|
6
|
+
readonly children: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
/** A json-render spec whose root is a `Card` from the chat catalog. */
|
|
9
|
+
export interface CardSpec {
|
|
10
|
+
readonly root: string;
|
|
11
|
+
readonly elements: Readonly<Record<string, CardElement>>;
|
|
12
|
+
}
|
|
13
|
+
export type TextStyle = "bold" | "muted" | "plain";
|
|
14
|
+
export type Align = "center" | "left" | "right";
|
|
15
|
+
export interface TableData {
|
|
16
|
+
readonly headers: readonly string[];
|
|
17
|
+
readonly rows: readonly (readonly string[])[];
|
|
18
|
+
readonly align?: readonly Align[] | undefined;
|
|
19
|
+
/** What the table is, for a screen reader and for Slack's table title. */
|
|
20
|
+
readonly caption?: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Which columns make a card when each row is a person or a thing: Slack
|
|
23
|
+
* then draws a short table as cards side by side.
|
|
24
|
+
*/
|
|
25
|
+
readonly cards?: TableCards | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface TableCards {
|
|
28
|
+
readonly title: number;
|
|
29
|
+
readonly subtitle: readonly number[];
|
|
30
|
+
readonly body?: number | undefined;
|
|
31
|
+
}
|
|
32
|
+
export interface PieChart {
|
|
33
|
+
readonly type: "pie";
|
|
34
|
+
readonly segments: readonly {
|
|
35
|
+
readonly label: string;
|
|
36
|
+
readonly value: number;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
39
|
+
export interface SeriesChart {
|
|
40
|
+
readonly type: "area" | "bar" | "line";
|
|
41
|
+
readonly categories: readonly string[];
|
|
42
|
+
readonly series: readonly {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly values: readonly number[];
|
|
45
|
+
}[];
|
|
46
|
+
readonly yLabel?: string | undefined;
|
|
47
|
+
}
|
|
48
|
+
export interface ChartData {
|
|
49
|
+
readonly title: string;
|
|
50
|
+
readonly chart: PieChart | SeriesChart;
|
|
51
|
+
}
|
|
52
|
+
export interface CardLink {
|
|
53
|
+
readonly label: string;
|
|
54
|
+
readonly url: string;
|
|
55
|
+
}
|
|
56
|
+
/** One piece of a card, before it is flattened into a spec. */
|
|
57
|
+
export type CardNode = {
|
|
58
|
+
readonly type: "Chart";
|
|
59
|
+
readonly chart: ChartData;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: "Divider";
|
|
62
|
+
} | {
|
|
63
|
+
readonly type: "Fields";
|
|
64
|
+
readonly fields: readonly (readonly [label: string, value: string])[];
|
|
65
|
+
} | {
|
|
66
|
+
readonly type: "Links";
|
|
67
|
+
readonly links: readonly CardLink[];
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: "Section";
|
|
70
|
+
readonly title: string;
|
|
71
|
+
readonly children: readonly CardNode[];
|
|
72
|
+
} | {
|
|
73
|
+
readonly type: "Table";
|
|
74
|
+
readonly table: TableData;
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: "Text";
|
|
77
|
+
readonly content: string;
|
|
78
|
+
readonly style: TextStyle;
|
|
79
|
+
};
|
|
80
|
+
export interface CardFrame {
|
|
81
|
+
readonly title: string;
|
|
82
|
+
readonly subtitle?: string | null | undefined;
|
|
83
|
+
readonly children: readonly CardNode[];
|
|
84
|
+
}
|
|
85
|
+
/** Flattens a card into a json-render spec. Element keys are stable. */
|
|
86
|
+
export declare const buildSpec: (frame: CardFrame) => CardSpec;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/internal/engine/rate-store.ts
|
|
2
|
+
var firstInside = (times, cutoff) => {
|
|
3
|
+
let low = 0;
|
|
4
|
+
let high = times.length;
|
|
5
|
+
while (low < high) {
|
|
6
|
+
const middle = Math.floor((low + high) / 2);
|
|
7
|
+
if ((times[middle] ?? 0) > cutoff) {
|
|
8
|
+
high = middle;
|
|
9
|
+
} else {
|
|
10
|
+
low = middle + 1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return low;
|
|
14
|
+
};
|
|
15
|
+
var waitFor = (bucket, window, now) => {
|
|
16
|
+
const start = firstInside(bucket.times, now - window.perMs);
|
|
17
|
+
const used = bucket.times.length - start;
|
|
18
|
+
if (used < window.requests) {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
const blocker = bucket.times[bucket.times.length - window.requests] ?? now;
|
|
22
|
+
return Math.max(1, blocker + window.perMs - now);
|
|
23
|
+
};
|
|
24
|
+
var MemoryRateLimitStore = class {
|
|
25
|
+
#buckets = /* @__PURE__ */ new Map();
|
|
26
|
+
#bucket(key) {
|
|
27
|
+
let bucket = this.#buckets.get(key);
|
|
28
|
+
if (bucket === void 0) {
|
|
29
|
+
bucket = { pausedUntil: 0, times: [] };
|
|
30
|
+
this.#buckets.set(key, bucket);
|
|
31
|
+
}
|
|
32
|
+
return bucket;
|
|
33
|
+
}
|
|
34
|
+
reserve(key, windows, now) {
|
|
35
|
+
const bucket = this.#bucket(key);
|
|
36
|
+
if (bucket.pausedUntil > now) {
|
|
37
|
+
return Promise.resolve(bucket.pausedUntil - now);
|
|
38
|
+
}
|
|
39
|
+
const wait = Math.max(
|
|
40
|
+
0,
|
|
41
|
+
...windows.map((window) => waitFor(bucket, window, now))
|
|
42
|
+
);
|
|
43
|
+
if (wait > 0) {
|
|
44
|
+
return Promise.resolve(wait);
|
|
45
|
+
}
|
|
46
|
+
const longest = Math.max(0, ...windows.map((window) => window.perMs));
|
|
47
|
+
bucket.times = bucket.times.slice(firstInside(bucket.times, now - longest));
|
|
48
|
+
bucket.times.push(now);
|
|
49
|
+
return Promise.resolve(0);
|
|
50
|
+
}
|
|
51
|
+
pause(key, until) {
|
|
52
|
+
const bucket = this.#bucket(key);
|
|
53
|
+
bucket.pausedUntil = Math.max(bucket.pausedUntil, until);
|
|
54
|
+
return Promise.resolve();
|
|
55
|
+
}
|
|
56
|
+
usage(key, windows, now) {
|
|
57
|
+
const bucket = this.#bucket(key);
|
|
58
|
+
return Promise.resolve(
|
|
59
|
+
windows.map(
|
|
60
|
+
(window) => bucket.times.length - firstInside(bucket.times, now - window.perMs)
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var GLOBAL_STORE = /* @__PURE__ */ Symbol.for("outbound-sdk.rate-limit-store");
|
|
66
|
+
var defaultRateLimitStore = () => {
|
|
67
|
+
const scope = globalThis;
|
|
68
|
+
scope[GLOBAL_STORE] ??= new MemoryRateLimitStore();
|
|
69
|
+
return scope[GLOBAL_STORE];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
MemoryRateLimitStore,
|
|
74
|
+
defaultRateLimitStore
|
|
75
|
+
};
|