outbound-sdk 0.2.1 → 0.4.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/dist/alerts/index.js +50 -19
- package/dist/alerts/plugin.d.ts +20 -3
- package/dist/audit/index.js +2 -2
- package/dist/benchmarks/index.js +5 -5
- package/dist/budget/index.d.ts +3 -2
- package/dist/budget/index.js +11 -10
- package/dist/cards/content.d.ts +6 -1
- package/dist/cards/format.d.ts +17 -2
- package/dist/cards/index.d.ts +1 -1
- package/dist/cards/index.js +297 -132
- package/dist/cards/parts.d.ts +9 -2
- package/dist/cards/render.d.ts +20 -3
- package/dist/chunks/{chunk-U2D34ARZ.js → chunk-2D42TQFU.js} +3 -3
- package/dist/chunks/chunk-4PA526S7.js +17 -0
- package/dist/chunks/{chunk-6CVZOUHB.js → chunk-5CFO3CXG.js} +24 -0
- package/dist/chunks/{chunk-XNFESPZH.js → chunk-5FVKRIEJ.js} +168 -31
- package/dist/chunks/{chunk-P3IJBJUI.js → chunk-7LNJJ2RO.js} +200 -57
- package/dist/chunks/{chunk-XC6CZP73.js → chunk-7ZDS6SZD.js} +7 -1
- package/dist/chunks/{chunk-SBIZDCRY.js → chunk-A6WVOCA4.js} +4 -4
- package/dist/chunks/{chunk-VQSCHOBV.js → chunk-BLCJHP5H.js} +11 -4
- package/dist/chunks/{chunk-4PSO6JEK.js → chunk-BOWXGMN3.js} +6 -21
- package/dist/chunks/{chunk-DJ2IUQEU.js → chunk-C4LS2HNV.js} +3 -3
- package/dist/chunks/{chunk-AFU5E5QB.js → chunk-E6DSDCPI.js} +98 -69
- package/dist/chunks/{chunk-IPUYZD4O.js → chunk-GFDNRWR3.js} +1 -1
- package/dist/chunks/{chunk-PURHK3JU.js → chunk-IZFTTMJP.js} +4 -4
- package/dist/chunks/{chunk-E7JHLNLG.js → chunk-J7DDZ4C2.js} +15 -2
- package/dist/chunks/{chunk-FKH5N47I.js → chunk-K4USHN4C.js} +1 -1
- package/dist/chunks/chunk-LVQUSKEX.js +17 -0
- package/dist/chunks/{chunk-YOTW5ESM.js → chunk-PQSTQKRD.js} +2 -2
- package/dist/chunks/chunk-PTZO4QXR.js +15 -0
- package/dist/chunks/{chunk-LVYG7XZJ.js → chunk-QAKJ76HB.js} +1 -1
- package/dist/chunks/chunk-QGRZDTX4.js +26 -0
- package/dist/chunks/{chunk-R3Y56YVF.js → chunk-Y5RAJ6PZ.js} +2 -2
- package/dist/chunks/{chunk-RCZ7ZZFU.js → chunk-ZFVHM5JI.js} +3 -3
- package/dist/chunks/{chunk-UAT3JSJZ.js → chunk-ZOAG2C6V.js} +2 -2
- package/dist/cli/bin.js +17 -13
- package/dist/cli/commands.d.ts +11 -0
- package/dist/cli/index.js +17 -13
- package/dist/cli/mcp.d.ts +5 -0
- package/dist/clients/index.d.ts +1 -1
- package/dist/clients/index.js +35 -10
- package/dist/clients/plugin.d.ts +9 -2
- package/dist/combine/index.js +7 -6
- package/dist/exporter/index.d.ts +5 -2
- package/dist/exporter/index.js +2 -2
- package/dist/failover/index.js +3 -3
- package/dist/fixtures/index.js +5 -4
- package/dist/heyreach/client.d.ts +2 -0
- package/dist/heyreach/index.js +71 -39
- package/dist/heyreach/map.d.ts +5 -2
- package/dist/identity/index.js +33 -17
- package/dist/identity/plugin.d.ts +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -10
- package/dist/insights/campaign.d.ts +3 -0
- package/dist/insights/capped.d.ts +29 -0
- package/dist/insights/copy/copy-audit.d.ts +2 -0
- package/dist/insights/copy/copy-reuse.d.ts +27 -3
- package/dist/insights/copy/index.d.ts +8 -8
- package/dist/insights/copy/reply-timing.d.ts +8 -0
- package/dist/insights/copy/reuse-base.d.ts +32 -0
- package/dist/insights/copy/shared.d.ts +39 -15
- package/dist/insights/copy/step-funnel.d.ts +16 -5
- package/dist/insights/copy/variant-test.d.ts +19 -8
- package/dist/insights/define.d.ts +56 -2
- package/dist/insights/fields.d.ts +16 -0
- package/dist/insights/index.d.ts +2 -1
- package/dist/insights/index.js +1494 -730
- package/dist/insights/inputs.generated.d.ts +951 -0
- package/dist/insights/ops/campaign-diagnosis.d.ts +3 -1
- package/dist/insights/ops/campaign-ranking.d.ts +12 -4
- package/dist/insights/ops/channel-mix.d.ts +2 -1
- package/dist/insights/ops/client-report.d.ts +18 -5
- package/dist/insights/ops/index.d.ts +6 -2
- package/dist/insights/ops/period-comparison.d.ts +14 -3
- package/dist/insights/ops/pipeline-forecast.d.ts +14 -4
- package/dist/insights/ops/shared.d.ts +29 -24
- package/dist/insights/ops/tag-rollup.d.ts +2 -1
- package/dist/insights/people/account-summary.d.ts +13 -0
- package/dist/insights/people/dropped-replies.d.ts +8 -0
- package/dist/insights/people/find.d.ts +7 -1
- package/dist/insights/people/hot-leads.d.ts +16 -1
- package/dist/insights/people/person-summary.d.ts +6 -0
- package/dist/insights/people/read.d.ts +26 -10
- package/dist/insights/people/suppression-check.d.ts +11 -2
- package/dist/insights/plugin.d.ts +7 -5
- package/dist/insights/ref.d.ts +6 -0
- package/dist/insights/registry.d.ts +28 -16
- package/dist/insights/senders/bounce-watch.d.ts +25 -8
- package/dist/insights/senders/capacity-sends.d.ts +22 -0
- package/dist/insights/senders/domain-health.d.ts +10 -4
- package/dist/insights/senders/index.d.ts +14 -6
- package/dist/insights/senders/read.d.ts +15 -14
- package/dist/insights/senders/sender-capacity.d.ts +5 -13
- package/dist/insights/senders/sender-load.d.ts +2 -0
- package/dist/insights/stats.d.ts +8 -0
- package/dist/insights/tools.d.ts +3 -2
- package/dist/instantly/client.d.ts +2 -0
- package/dist/instantly/index.js +44 -29
- package/dist/instantly/map.d.ts +6 -2
- package/dist/internal/engine/request.d.ts +5 -0
- package/dist/internal/entities.d.ts +3 -20
- package/dist/internal/errors.d.ts +44 -0
- package/dist/internal/fields.d.ts +1 -1
- package/dist/internal/json.d.ts +9 -2
- package/dist/internal/lists.d.ts +24 -0
- package/dist/internal/numbers.d.ts +8 -0
- package/dist/internal/outbound/collections.d.ts +4 -0
- package/dist/internal/outbound/create.d.ts +24 -3
- package/dist/internal/outbound/outbound.d.ts +13 -1
- package/dist/internal/outbound/validate.d.ts +4 -0
- package/dist/internal/outbound/walker.d.ts +3 -2
- package/dist/internal/plural.d.ts +12 -0
- package/dist/internal/renamed.d.ts +28 -0
- package/dist/internal/vocabulary.d.ts +20 -0
- package/dist/loader/index.js +5 -5
- package/dist/memory/adapter.d.ts +7 -0
- package/dist/memory/demo-stats.d.ts +3 -0
- package/dist/memory/demo.d.ts +14 -3
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.js +200 -95
- package/dist/providers/index.d.ts +72 -0
- package/dist/providers/index.js +3 -1
- package/dist/reconcile/index.js +5 -4
- package/dist/redact/index.js +10 -4
- package/dist/redact/plugin.d.ts +7 -0
- package/dist/smartlead/index.js +102 -49
- package/dist/smartlead/shared.d.ts +13 -0
- package/dist/sync/index.js +2 -2
- package/dist/tools/ai-sdk.js +8 -6
- package/dist/tools/campaign-tools.d.ts +1 -1
- package/dist/tools/claude-agent.js +8 -6
- package/dist/tools/index.js +9 -7
- package/dist/tools/input-problem.d.ts +8 -0
- package/dist/tools/registry.d.ts +7 -2
- package/dist/tools/shared.d.ts +7 -0
- package/dist/tracing/index.js +2 -2
- package/dist/webhooks/index.js +10 -9
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -4,23 +4,27 @@ import {
|
|
|
4
4
|
defineConfig,
|
|
5
5
|
run,
|
|
6
6
|
serveStdio
|
|
7
|
-
} from "../chunks/chunk-
|
|
8
|
-
import "../chunks/chunk-
|
|
9
|
-
import "../chunks/chunk-
|
|
7
|
+
} from "../chunks/chunk-7LNJJ2RO.js";
|
|
8
|
+
import "../chunks/chunk-Y5RAJ6PZ.js";
|
|
9
|
+
import "../chunks/chunk-E6DSDCPI.js";
|
|
10
|
+
import "../chunks/chunk-LVQUSKEX.js";
|
|
11
|
+
import "../chunks/chunk-4PA526S7.js";
|
|
10
12
|
import "../chunks/chunk-HZCTYL22.js";
|
|
11
|
-
import "../chunks/chunk-
|
|
13
|
+
import "../chunks/chunk-5FVKRIEJ.js";
|
|
12
14
|
import "../chunks/chunk-4O2HRTTI.js";
|
|
13
|
-
import "../chunks/chunk-
|
|
15
|
+
import "../chunks/chunk-PTZO4QXR.js";
|
|
16
|
+
import "../chunks/chunk-PQSTQKRD.js";
|
|
14
17
|
import "../chunks/chunk-NAWZ73QS.js";
|
|
15
18
|
import "../chunks/chunk-FHKSLCVW.js";
|
|
16
|
-
import "../chunks/chunk-
|
|
17
|
-
import "../chunks/chunk-
|
|
18
|
-
import "../chunks/chunk-
|
|
19
|
-
import "../chunks/chunk-
|
|
20
|
-
import "../chunks/chunk-
|
|
21
|
-
import "../chunks/chunk-
|
|
22
|
-
import "../chunks/chunk-
|
|
23
|
-
import "../chunks/chunk-
|
|
19
|
+
import "../chunks/chunk-ZFVHM5JI.js";
|
|
20
|
+
import "../chunks/chunk-GFDNRWR3.js";
|
|
21
|
+
import "../chunks/chunk-7ZDS6SZD.js";
|
|
22
|
+
import "../chunks/chunk-ZOAG2C6V.js";
|
|
23
|
+
import "../chunks/chunk-BOWXGMN3.js";
|
|
24
|
+
import "../chunks/chunk-QGRZDTX4.js";
|
|
25
|
+
import "../chunks/chunk-QAKJ76HB.js";
|
|
26
|
+
import "../chunks/chunk-J7DDZ4C2.js";
|
|
27
|
+
import "../chunks/chunk-BLCJHP5H.js";
|
|
24
28
|
export {
|
|
25
29
|
PROTOCOL_VERSIONS,
|
|
26
30
|
createMcpServer,
|
package/dist/cli/mcp.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ import type { ToolsOptions } from "../tools/index.ts";
|
|
|
4
4
|
export declare const PROTOCOL_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
5
5
|
export interface McpServerOptions extends ToolsOptions {
|
|
6
6
|
readonly version?: string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Tools left out of this server, by name, with the reason. A call to one
|
|
9
|
+
* is answered with the reason instead of `Unknown tool`.
|
|
10
|
+
*/
|
|
11
|
+
readonly leftOut?: Readonly<Record<string, string>> | undefined;
|
|
7
12
|
}
|
|
8
13
|
export interface McpServer {
|
|
9
14
|
/** Handles one JSON-RPC message. Returns `undefined` for a notification. */
|
package/dist/clients/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { UNASSIGNED, clients } from "./plugin.ts";
|
|
2
|
-
export type { ClientRule, ClientStats, ClientStatsOptions, ClientsExtension, ClientsOptions, } from "./plugin.ts";
|
|
2
|
+
export type { ClientRule, ClientStats, ClientStatsOptions, ClientStatsRead, ClientsExtension, ClientsOptions, } from "./plugin.ts";
|
package/dist/clients/index.js
CHANGED
|
@@ -4,11 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
emptyCounts,
|
|
6
6
|
sumCounts
|
|
7
|
-
} from "../chunks/chunk-
|
|
8
|
-
import "../chunks/chunk-
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
} from "../chunks/chunk-PQSTQKRD.js";
|
|
8
|
+
import "../chunks/chunk-QGRZDTX4.js";
|
|
9
|
+
import {
|
|
10
|
+
parseRef
|
|
11
|
+
} from "../chunks/chunk-QAKJ76HB.js";
|
|
12
|
+
import "../chunks/chunk-J7DDZ4C2.js";
|
|
13
|
+
import "../chunks/chunk-BLCJHP5H.js";
|
|
12
14
|
|
|
13
15
|
// src/clients/plugin.ts
|
|
14
16
|
var UNASSIGNED = "unassigned";
|
|
@@ -23,13 +25,21 @@ var campaignRefOf = (record) => {
|
|
|
23
25
|
return "scope" in record && record.scope !== "workspace" && record.scope !== "sender" ? record.scopeRef : null;
|
|
24
26
|
};
|
|
25
27
|
var needsCampaign = (rule) => rule.campaignTag !== void 0 || rule.campaignName !== void 0;
|
|
26
|
-
var
|
|
28
|
+
var namesCampaign = (ids, campaign) => ids.includes(campaign.ref) || ids.includes(parseRef(campaign.ref)?.sourceId ?? campaign.ref);
|
|
29
|
+
var withoutState = (rule) => rule.campaignName === void 0 ? rule : {
|
|
30
|
+
...rule,
|
|
31
|
+
campaignName: new RegExp(
|
|
32
|
+
rule.campaignName.source,
|
|
33
|
+
rule.campaignName.flags.replaceAll(/[gy]/gu, "")
|
|
34
|
+
)
|
|
35
|
+
};
|
|
36
|
+
var matches = (rule, record, campaign) => (rule.provider === void 0 || rule.provider === record.provider) && (rule.workspaceId === void 0 || rule.workspaceId === record.workspaceId) && (rule.campaignIds === void 0 || campaign !== null && namesCampaign(rule.campaignIds, campaign)) && (rule.campaignTag === void 0 || campaign !== null && campaign.tags.includes(rule.campaignTag)) && (rule.campaignName === void 0 || campaign !== null && rule.campaignName.test(campaign.name));
|
|
27
37
|
var Assigner = class {
|
|
28
38
|
#rules;
|
|
29
39
|
/** Campaigns seen so far, so a lead can be matched by its campaign's tag. */
|
|
30
40
|
#campaigns = /* @__PURE__ */ new Map();
|
|
31
41
|
constructor(rules) {
|
|
32
|
-
this.#rules = rules;
|
|
42
|
+
this.#rules = rules.map(withoutState);
|
|
33
43
|
}
|
|
34
44
|
names() {
|
|
35
45
|
return [...new Set(this.#rules.map((rule) => rule.client))];
|
|
@@ -67,21 +77,32 @@ var Assigner = class {
|
|
|
67
77
|
}
|
|
68
78
|
};
|
|
69
79
|
var clientStats = async (outbound, options) => {
|
|
70
|
-
const
|
|
80
|
+
const { deadline, maxRequests, retries, signal, timeout } = options;
|
|
81
|
+
const walk = outbound.campaigns.listAll({
|
|
82
|
+
deadline,
|
|
83
|
+
maxRequests,
|
|
84
|
+
retries,
|
|
85
|
+
signal,
|
|
86
|
+
timeout
|
|
87
|
+
});
|
|
88
|
+
const campaigns = await walk.toArray();
|
|
71
89
|
const byClient = /* @__PURE__ */ new Map();
|
|
90
|
+
let requests = walk.meta?.requests ?? 0;
|
|
72
91
|
const read = await mapConcurrent(campaigns, async (campaign) => ({
|
|
73
92
|
campaign,
|
|
74
93
|
stats: await outbound.campaign(campaign.ref).stats(options)
|
|
75
94
|
}));
|
|
76
95
|
for (const { campaign, stats } of read) {
|
|
77
96
|
const { client } = campaign;
|
|
97
|
+
requests += stats.meta.requests;
|
|
78
98
|
byClient.set(client, [...byClient.get(client) ?? [], ...stats.rows]);
|
|
79
99
|
}
|
|
80
|
-
|
|
100
|
+
const clientsRead = [...byClient.entries()].map(([client, rows]) => ({
|
|
81
101
|
campaigns: rows.length,
|
|
82
102
|
client,
|
|
83
103
|
counts: rows.length === 0 ? emptyCounts() : sumCounts(rows)
|
|
84
104
|
})).toSorted((left, right) => left.client.localeCompare(right.client));
|
|
105
|
+
return { clients: clientsRead, requests };
|
|
85
106
|
};
|
|
86
107
|
var clients = (options = {}) => {
|
|
87
108
|
const assigner = new Assigner(options.rules ?? []);
|
|
@@ -89,7 +110,11 @@ var clients = (options = {}) => {
|
|
|
89
110
|
extend: (outbound) => ({
|
|
90
111
|
clients: {
|
|
91
112
|
names: () => assigner.names(),
|
|
92
|
-
|
|
113
|
+
read: (statsOptions = {}) => clientStats(outbound, statsOptions),
|
|
114
|
+
stats: async (statsOptions = {}) => {
|
|
115
|
+
const read = await clientStats(outbound, statsOptions);
|
|
116
|
+
return read.clients;
|
|
117
|
+
}
|
|
93
118
|
}
|
|
94
119
|
}),
|
|
95
120
|
name: "clients",
|
package/dist/clients/plugin.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ export interface ClientRule {
|
|
|
9
9
|
readonly workspaceId?: string | undefined;
|
|
10
10
|
/** Campaigns carrying this tag. */
|
|
11
11
|
readonly campaignTag?: string | undefined;
|
|
12
|
-
/** Campaigns by ref. */
|
|
12
|
+
/** Campaigns by ref or by the vendor's own id. */
|
|
13
13
|
readonly campaignIds?: readonly string[] | undefined;
|
|
14
|
-
/** Campaigns whose name matches. */
|
|
14
|
+
/** Campaigns whose name matches. The `g` and `y` flags make no difference. */
|
|
15
15
|
readonly campaignName?: RegExp | undefined;
|
|
16
16
|
}
|
|
17
17
|
export interface ClientsOptions {
|
|
@@ -36,7 +36,14 @@ export interface ClientsExtension {
|
|
|
36
36
|
* campaigns. It costs one stats request per campaign.
|
|
37
37
|
*/
|
|
38
38
|
readonly stats: (options?: ClientStatsOptions) => Promise<ClientStats[]>;
|
|
39
|
+
/** `stats()` with the vendor requests it made, listing included. */
|
|
40
|
+
readonly read: (options?: ClientStatsOptions) => Promise<ClientStatsRead>;
|
|
39
41
|
};
|
|
40
42
|
}
|
|
43
|
+
export interface ClientStatsRead {
|
|
44
|
+
readonly clients: ClientStats[];
|
|
45
|
+
/** Vendor requests made: the campaign listing and each campaign's stats. */
|
|
46
|
+
readonly requests: number;
|
|
47
|
+
}
|
|
41
48
|
/** Tags every record with the client it belongs to. */
|
|
42
49
|
export declare const clients: (options?: ClientsOptions) => OutboundPlugin<ClientsExtension>;
|
package/dist/combine/index.js
CHANGED
|
@@ -3,22 +3,23 @@ import {
|
|
|
3
3
|
mergeFields,
|
|
4
4
|
resolveCapabilities,
|
|
5
5
|
resolveFields
|
|
6
|
-
} from "../chunks/chunk-
|
|
6
|
+
} from "../chunks/chunk-ZOAG2C6V.js";
|
|
7
7
|
import {
|
|
8
8
|
recordBase
|
|
9
|
-
} from "../chunks/chunk-
|
|
10
|
-
import "../chunks/chunk-
|
|
9
|
+
} from "../chunks/chunk-2D42TQFU.js";
|
|
10
|
+
import "../chunks/chunk-BOWXGMN3.js";
|
|
11
|
+
import "../chunks/chunk-QGRZDTX4.js";
|
|
11
12
|
import {
|
|
12
13
|
parseRef
|
|
13
|
-
} from "../chunks/chunk-
|
|
14
|
+
} from "../chunks/chunk-QAKJ76HB.js";
|
|
14
15
|
import {
|
|
15
16
|
OutboundError,
|
|
16
17
|
makeErrorMapper
|
|
17
|
-
} from "../chunks/chunk-
|
|
18
|
+
} from "../chunks/chunk-J7DDZ4C2.js";
|
|
18
19
|
import {
|
|
19
20
|
count,
|
|
20
21
|
field
|
|
21
|
-
} from "../chunks/chunk-
|
|
22
|
+
} from "../chunks/chunk-BLCJHP5H.js";
|
|
22
23
|
|
|
23
24
|
// src/combine/route.ts
|
|
24
25
|
var COMBINED = "combined";
|
package/dist/exporter/index.d.ts
CHANGED
|
@@ -22,8 +22,11 @@ export interface ExportResult {
|
|
|
22
22
|
readonly columns: readonly string[];
|
|
23
23
|
}
|
|
24
24
|
export interface ExporterExtension {
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Writes every record of a listing, for example `outbound.leads.listAll()`,
|
|
27
|
+
* or of an array or any other iterable.
|
|
28
|
+
*/
|
|
29
|
+
readonly export: <Item>(source: AsyncIterable<Item> | Iterable<Item>, options: ExportOptions) => Promise<ExportResult>;
|
|
27
30
|
}
|
|
28
31
|
/** Adds `outbound.export()`. */
|
|
29
32
|
export declare const exporter: () => OutboundPlugin<ExporterExtension>;
|
package/dist/exporter/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OutboundError
|
|
3
|
-
} from "../chunks/chunk-
|
|
3
|
+
} from "../chunks/chunk-J7DDZ4C2.js";
|
|
4
4
|
import {
|
|
5
5
|
isJsonObject,
|
|
6
6
|
toJson
|
|
7
|
-
} from "../chunks/chunk-
|
|
7
|
+
} from "../chunks/chunk-BLCJHP5H.js";
|
|
8
8
|
|
|
9
9
|
// src/exporter/index.ts
|
|
10
10
|
import { open } from "node:fs/promises";
|
package/dist/failover/index.js
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
import "../chunks/chunk-FHKSLCVW.js";
|
|
5
5
|
import {
|
|
6
6
|
OutboundError
|
|
7
|
-
} from "../chunks/chunk-
|
|
8
|
-
import "../chunks/chunk-
|
|
7
|
+
} from "../chunks/chunk-J7DDZ4C2.js";
|
|
8
|
+
import "../chunks/chunk-BLCJHP5H.js";
|
|
9
9
|
|
|
10
10
|
// src/failover/index.ts
|
|
11
11
|
var WEEK_SECONDS = 7 * 24 * 60 * 60;
|
|
12
|
-
var vendorIsDown = (cause) => OutboundError.is(cause) && !cause.aborted && (cause.code === "Provider" || cause.code === "RateLimited" && cause.
|
|
12
|
+
var vendorIsDown = (cause) => OutboundError.is(cause) && !cause.aborted && (cause.code === "Provider" || cause.code === "RateLimited" && cause.limit === "vendor");
|
|
13
13
|
var fetchedAtOf = (fetchedAt, now) => fetchedAt === void 0 ? now : Date.parse(fetchedAt);
|
|
14
14
|
var failover = (options) => {
|
|
15
15
|
const now = options.now ?? (() => Date.now());
|
package/dist/fixtures/index.js
CHANGED
|
@@ -6,20 +6,21 @@ import {
|
|
|
6
6
|
} from "../chunks/chunk-FHKSLCVW.js";
|
|
7
7
|
import {
|
|
8
8
|
evidenceSchema
|
|
9
|
-
} from "../chunks/chunk-
|
|
9
|
+
} from "../chunks/chunk-BOWXGMN3.js";
|
|
10
|
+
import "../chunks/chunk-QGRZDTX4.js";
|
|
10
11
|
import {
|
|
11
12
|
makeRef,
|
|
12
13
|
parseRef
|
|
13
|
-
} from "../chunks/chunk-
|
|
14
|
+
} from "../chunks/chunk-QAKJ76HB.js";
|
|
14
15
|
import {
|
|
15
16
|
OutboundError
|
|
16
|
-
} from "../chunks/chunk-
|
|
17
|
+
} from "../chunks/chunk-J7DDZ4C2.js";
|
|
17
18
|
import {
|
|
18
19
|
field,
|
|
19
20
|
objects,
|
|
20
21
|
parseJson,
|
|
21
22
|
toJson
|
|
22
|
-
} from "../chunks/chunk-
|
|
23
|
+
} from "../chunks/chunk-BLCJHP5H.js";
|
|
23
24
|
|
|
24
25
|
// src/fixtures/index.ts
|
|
25
26
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
@@ -12,6 +12,8 @@ export interface HeyReachClient extends VendorClient {
|
|
|
12
12
|
readonly raw: RawDescriptor;
|
|
13
13
|
/** Narrows a response to one object, or throws a `Provider` error. */
|
|
14
14
|
readonly object: (body: Json, path: string) => JsonObject;
|
|
15
|
+
/** The `items` array every HeyReach list answers with, or a `Provider` error. */
|
|
16
|
+
readonly items: (body: Json | undefined, path: string) => JsonObject[];
|
|
15
17
|
}
|
|
16
18
|
export declare const isSecret: (path: string) => boolean;
|
|
17
19
|
export declare const isRead: (method: HttpMethod, path: string) => boolean;
|
package/dist/heyreach/index.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EVENT_TYPES,
|
|
3
3
|
heyreachEvents
|
|
4
|
-
} from "../chunks/chunk-
|
|
4
|
+
} from "../chunks/chunk-C4LS2HNV.js";
|
|
5
5
|
import {
|
|
6
6
|
createVendorClient,
|
|
7
|
+
listIn,
|
|
7
8
|
mapPage,
|
|
8
9
|
normalizeBody,
|
|
9
10
|
withLeadFields,
|
|
10
11
|
withMappedFields
|
|
11
|
-
} from "../chunks/chunk-
|
|
12
|
+
} from "../chunks/chunk-5CFO3CXG.js";
|
|
12
13
|
import {
|
|
13
14
|
leadStanding,
|
|
14
15
|
toVariant,
|
|
15
16
|
variantKey
|
|
16
|
-
} from "../chunks/chunk-
|
|
17
|
+
} from "../chunks/chunk-K4USHN4C.js";
|
|
17
18
|
import {
|
|
18
19
|
defineNative
|
|
19
20
|
} from "../chunks/chunk-NAKXLBA6.js";
|
|
20
21
|
import {
|
|
21
22
|
emptyCounts,
|
|
22
23
|
metricRow
|
|
23
|
-
} from "../chunks/chunk-
|
|
24
|
+
} from "../chunks/chunk-PQSTQKRD.js";
|
|
24
25
|
import {
|
|
25
26
|
profileSlug
|
|
26
27
|
} from "../chunks/chunk-NAWZ73QS.js";
|
|
@@ -30,23 +31,24 @@ import {
|
|
|
30
31
|
import {
|
|
31
32
|
readEnv,
|
|
32
33
|
requireCredential
|
|
33
|
-
} from "../chunks/chunk-
|
|
34
|
+
} from "../chunks/chunk-GFDNRWR3.js";
|
|
34
35
|
import {
|
|
35
36
|
eventTypesOf,
|
|
36
37
|
recordBase,
|
|
37
38
|
refTo,
|
|
38
39
|
refsTo
|
|
39
|
-
} from "../chunks/chunk-
|
|
40
|
-
import "../chunks/chunk-
|
|
40
|
+
} from "../chunks/chunk-2D42TQFU.js";
|
|
41
|
+
import "../chunks/chunk-BOWXGMN3.js";
|
|
42
|
+
import "../chunks/chunk-QGRZDTX4.js";
|
|
41
43
|
import {
|
|
42
44
|
assertWorkspaceId
|
|
43
|
-
} from "../chunks/chunk-
|
|
45
|
+
} from "../chunks/chunk-QAKJ76HB.js";
|
|
44
46
|
import {
|
|
45
47
|
OutboundError,
|
|
46
48
|
isHttpFailure,
|
|
47
49
|
makeErrorMapper,
|
|
48
50
|
requireObject
|
|
49
|
-
} from "../chunks/chunk-
|
|
51
|
+
} from "../chunks/chunk-J7DDZ4C2.js";
|
|
50
52
|
import {
|
|
51
53
|
count,
|
|
52
54
|
emailAddress,
|
|
@@ -60,7 +62,7 @@ import {
|
|
|
60
62
|
objects,
|
|
61
63
|
text,
|
|
62
64
|
timestamp
|
|
63
|
-
} from "../chunks/chunk-
|
|
65
|
+
} from "../chunks/chunk-BLCJHP5H.js";
|
|
64
66
|
|
|
65
67
|
// src/heyreach/map-account.ts
|
|
66
68
|
var toCampaignProgress = (identity, campaignId, raw) => {
|
|
@@ -307,8 +309,10 @@ var toLookupLead = (identity, profile, campaign, email) => {
|
|
|
307
309
|
email: email ?? lead.email
|
|
308
310
|
};
|
|
309
311
|
};
|
|
310
|
-
var listEnvelope = (body, offset) => {
|
|
311
|
-
const items = objects(
|
|
312
|
+
var listEnvelope = (body, offset, provider, path) => {
|
|
313
|
+
const items = objects(
|
|
314
|
+
listIn(body, { key: "items", path, provider, vendor: "HeyReach" })
|
|
315
|
+
);
|
|
312
316
|
const total = count(field(body, "totalCount"));
|
|
313
317
|
const end = offset + items.length;
|
|
314
318
|
return {
|
|
@@ -571,13 +575,12 @@ var blocklistCursor = (next) => ({
|
|
|
571
575
|
});
|
|
572
576
|
var listBlocklist = (client) => async (query, ctx) => {
|
|
573
577
|
const { companies, offset } = blocklistCursor(query.next);
|
|
578
|
+
const path = companies ? "/blacklist/GetCompanies" : "/blacklist/GetLeads";
|
|
574
579
|
const envelope = listEnvelope(
|
|
575
|
-
await client.post(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
),
|
|
580
|
-
offset
|
|
580
|
+
await client.post(ctx, path, { limit: pageSize(query.limit), offset }),
|
|
581
|
+
offset,
|
|
582
|
+
client.identity.provider,
|
|
583
|
+
path
|
|
581
584
|
);
|
|
582
585
|
const toEntries = companies ? toBlockedCompany : toBlockedLead;
|
|
583
586
|
const items = envelope.items.flatMap(
|
|
@@ -645,7 +648,9 @@ var accountReaders = (client) => ({
|
|
|
645
648
|
limit: pageSize(query.limit),
|
|
646
649
|
offset
|
|
647
650
|
}),
|
|
648
|
-
offset
|
|
651
|
+
offset,
|
|
652
|
+
client.identity.provider,
|
|
653
|
+
"/list/GetAll"
|
|
649
654
|
);
|
|
650
655
|
return mapPage(envelope, (item) => toLeadList(client.identity, item));
|
|
651
656
|
},
|
|
@@ -658,7 +663,9 @@ var accountReaders = (client) => ({
|
|
|
658
663
|
limit: pageSize(query.limit),
|
|
659
664
|
offset
|
|
660
665
|
}),
|
|
661
|
-
offset
|
|
666
|
+
offset,
|
|
667
|
+
client.identity.provider,
|
|
668
|
+
"/webhooks/GetAllWebhooks"
|
|
662
669
|
);
|
|
663
670
|
const { campaignId } = query;
|
|
664
671
|
return {
|
|
@@ -698,7 +705,9 @@ var campaignSenders = async (client, ctx, query) => {
|
|
|
698
705
|
limit: pageSize(query.limit),
|
|
699
706
|
offset
|
|
700
707
|
}),
|
|
701
|
-
offset
|
|
708
|
+
offset,
|
|
709
|
+
client.identity.provider,
|
|
710
|
+
"/li_account/GetAll"
|
|
702
711
|
);
|
|
703
712
|
return {
|
|
704
713
|
items: envelope.items.filter((item) => isNumber(item.id) && accountIds.includes(item.id)).map((item) => toSender(client.identity, item)),
|
|
@@ -778,7 +787,7 @@ var readConversations = async (client, ctx, query) => {
|
|
|
778
787
|
const body = await client.post(ctx, CONVERSATIONS_PATH, request);
|
|
779
788
|
const next = text(field(body, "nextCursor"));
|
|
780
789
|
return {
|
|
781
|
-
conversations:
|
|
790
|
+
conversations: client.items(body, CONVERSATIONS_PATH),
|
|
782
791
|
next: field(body, "hasNextPage") === true && next !== null ? next : void 0
|
|
783
792
|
};
|
|
784
793
|
};
|
|
@@ -883,20 +892,18 @@ var profileByEmail = async (client, ctx, email, fullName2) => {
|
|
|
883
892
|
const lists = await found(
|
|
884
893
|
client.post(ctx, "/list/GetListsForLead", { email, limit: 1, offset: 0 })
|
|
885
894
|
);
|
|
886
|
-
const listId = field(
|
|
895
|
+
const listId = lists === void 0 ? void 0 : field(client.items(lists, "/list/GetListsForLead")[0], "listId");
|
|
887
896
|
if (!isNumber(listId)) {
|
|
888
897
|
return void 0;
|
|
889
898
|
}
|
|
890
|
-
const rows =
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
"items"
|
|
899
|
-
)
|
|
899
|
+
const rows = client.items(
|
|
900
|
+
await client.post(ctx, "/list/GetLeadsFromList", {
|
|
901
|
+
keyword: fullName2,
|
|
902
|
+
limit: MAX_CANDIDATES,
|
|
903
|
+
listId,
|
|
904
|
+
offset: 0
|
|
905
|
+
}),
|
|
906
|
+
"/list/GetLeadsFromList"
|
|
900
907
|
);
|
|
901
908
|
for (const row2 of rows) {
|
|
902
909
|
const profileUrl = text(row2.profileUrl);
|
|
@@ -960,7 +967,7 @@ var lookupLeads = async (client, ctx, query) => {
|
|
|
960
967
|
if (profile === void 0 || !isPerson(profile, query)) {
|
|
961
968
|
return { items: [] };
|
|
962
969
|
}
|
|
963
|
-
const envelope = listEnvelope(campaigns
|
|
970
|
+
const envelope = campaigns === void 0 ? { items: [], next: void 0 } : listEnvelope(campaigns, offset, provider, CAMPAIGNS_PATH);
|
|
964
971
|
if (envelope.items.length === 0 && offset === 0) {
|
|
965
972
|
return {
|
|
966
973
|
items: query.campaignId === void 0 ? [toLookupLead(client.identity, profile, null, query.email)] : []
|
|
@@ -1015,7 +1022,9 @@ var campaignLeads = async (client, ctx, query, offset) => {
|
|
|
1015
1022
|
"/campaign/GetLeadsFromCampaign",
|
|
1016
1023
|
campaignLeadsBody(client, query, offset)
|
|
1017
1024
|
),
|
|
1018
|
-
offset
|
|
1025
|
+
offset,
|
|
1026
|
+
client.identity.provider,
|
|
1027
|
+
"/campaign/GetLeadsFromCampaign"
|
|
1019
1028
|
);
|
|
1020
1029
|
return {
|
|
1021
1030
|
items: envelope.items.map(
|
|
@@ -1044,7 +1053,9 @@ var nextCampaigns = async (client, ctx, walk2) => {
|
|
|
1044
1053
|
}
|
|
1045
1054
|
const envelope = listEnvelope(
|
|
1046
1055
|
await client.post(ctx, "/campaign/GetAll", { limit: PAGE_SIZE, offset }),
|
|
1047
|
-
offset
|
|
1056
|
+
offset,
|
|
1057
|
+
client.identity.provider,
|
|
1058
|
+
"/campaign/GetAll"
|
|
1048
1059
|
);
|
|
1049
1060
|
return {
|
|
1050
1061
|
campaignOffset: envelope.next,
|
|
@@ -1082,6 +1093,13 @@ var leadReaders = (client) => ({
|
|
|
1082
1093
|
client.post(ctx, path, { profileUrl }),
|
|
1083
1094
|
client.post(ctx, "/lead/GetTags", { profileUrl })
|
|
1084
1095
|
]);
|
|
1096
|
+
if (isString(tags)) {
|
|
1097
|
+
throw new OutboundError(
|
|
1098
|
+
"Provider",
|
|
1099
|
+
"HeyReach returned no JSON for /lead/GetTags",
|
|
1100
|
+
{ provider: client.identity.provider }
|
|
1101
|
+
);
|
|
1102
|
+
}
|
|
1085
1103
|
return toLead(
|
|
1086
1104
|
client.identity,
|
|
1087
1105
|
client.object(lead, path),
|
|
@@ -1101,7 +1119,9 @@ var leadReaders = (client) => ({
|
|
|
1101
1119
|
"/list/GetLeadsFromList",
|
|
1102
1120
|
listLeadsBody(client, { ...query, listId }, offset)
|
|
1103
1121
|
),
|
|
1104
|
-
offset
|
|
1122
|
+
offset,
|
|
1123
|
+
client.identity.provider,
|
|
1124
|
+
"/list/GetLeadsFromList"
|
|
1105
1125
|
);
|
|
1106
1126
|
return mapPage(envelope, (item) => toLead(client.identity, item));
|
|
1107
1127
|
}
|
|
@@ -1343,7 +1363,9 @@ var readers = (client) => {
|
|
|
1343
1363
|
}
|
|
1344
1364
|
const envelope = listEnvelope(
|
|
1345
1365
|
await client.post(ctx, "/campaign/GetAll", body),
|
|
1346
|
-
offset
|
|
1366
|
+
offset,
|
|
1367
|
+
identity.provider,
|
|
1368
|
+
"/campaign/GetAll"
|
|
1347
1369
|
);
|
|
1348
1370
|
return mapPage(envelope, (item) => toCampaign(identity, item));
|
|
1349
1371
|
},
|
|
@@ -1358,7 +1380,9 @@ var readers = (client) => {
|
|
|
1358
1380
|
limit: pageSize(query.limit),
|
|
1359
1381
|
offset
|
|
1360
1382
|
}),
|
|
1361
|
-
offset
|
|
1383
|
+
offset,
|
|
1384
|
+
identity.provider,
|
|
1385
|
+
"/li_account/GetAll"
|
|
1362
1386
|
);
|
|
1363
1387
|
return mapPage(envelope, (item) => toSender(identity, item));
|
|
1364
1388
|
},
|
|
@@ -1419,6 +1443,14 @@ var createClient = (options) => {
|
|
|
1419
1443
|
return {
|
|
1420
1444
|
...createVendorClient(baseUrl, authorize),
|
|
1421
1445
|
identity: options.identity,
|
|
1446
|
+
items: (body, path) => objects(
|
|
1447
|
+
listIn(body, {
|
|
1448
|
+
key: "items",
|
|
1449
|
+
path,
|
|
1450
|
+
provider: options.identity.provider,
|
|
1451
|
+
vendor: "HeyReach"
|
|
1452
|
+
})
|
|
1453
|
+
),
|
|
1422
1454
|
object: (body, path) => requireObject(
|
|
1423
1455
|
body,
|
|
1424
1456
|
options.identity.provider,
|
package/dist/heyreach/map.d.ts
CHANGED
|
@@ -33,5 +33,8 @@ export interface ListEnvelope {
|
|
|
33
33
|
/** The offset of the next page, when there is one. */
|
|
34
34
|
readonly next: number | undefined;
|
|
35
35
|
}
|
|
36
|
-
/**
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* `{ totalCount, items }`: there is no next marker, so it is computed.
|
|
38
|
+
* `items` is required; any other answer is a `Provider` error naming `path`.
|
|
39
|
+
*/
|
|
40
|
+
export declare const listEnvelope: (body: Json, offset: number, provider: string, path: string) => ListEnvelope;
|
package/dist/identity/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
} from "../chunks/chunk-NAWZ73QS.js";
|
|
7
7
|
import {
|
|
8
8
|
OutboundError
|
|
9
|
-
} from "../chunks/chunk-
|
|
10
|
-
import "../chunks/chunk-
|
|
9
|
+
} from "../chunks/chunk-J7DDZ4C2.js";
|
|
10
|
+
import "../chunks/chunk-BLCJHP5H.js";
|
|
11
11
|
|
|
12
12
|
// src/identity/keys.ts
|
|
13
13
|
var emailKey = (email) => {
|
|
@@ -44,20 +44,29 @@ var withKeys = (record) => {
|
|
|
44
44
|
};
|
|
45
45
|
return tagged;
|
|
46
46
|
};
|
|
47
|
-
var scanLeads = async function* scanLeads2(outbound, options) {
|
|
47
|
+
var scanLeads = async function* scanLeads2(outbound, options, tally) {
|
|
48
48
|
if (options.campaignIds === void 0 && outbound.capabilities["leads.list"]) {
|
|
49
|
-
|
|
49
|
+
const walk = outbound.leads.listAll();
|
|
50
|
+
yield* walk;
|
|
51
|
+
tally.requests += walk.meta?.requests ?? 0;
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
let { campaignIds } = options;
|
|
55
|
+
if (campaignIds === void 0) {
|
|
56
|
+
const listing = outbound.campaigns.listAll();
|
|
57
|
+
const campaigns = await listing.toArray();
|
|
58
|
+
campaignIds = campaigns.map((campaign) => campaign.ref);
|
|
59
|
+
tally.requests += listing.meta?.requests ?? 0;
|
|
60
|
+
}
|
|
54
61
|
for (const campaignId of campaignIds) {
|
|
55
|
-
|
|
62
|
+
const walk = outbound.campaign(campaignId).leads.listAll();
|
|
63
|
+
yield* walk;
|
|
64
|
+
tally.requests += walk.meta?.requests ?? 0;
|
|
56
65
|
}
|
|
57
66
|
};
|
|
58
|
-
var collect = async (outbound, options, keys, found) => {
|
|
67
|
+
var collect = async (outbound, options, keys, found, tally) => {
|
|
59
68
|
let grew = false;
|
|
60
|
-
for await (const lead of scanLeads(outbound, options)) {
|
|
69
|
+
for await (const lead of scanLeads(outbound, options, tally)) {
|
|
61
70
|
const leadKeys = keysOf(lead);
|
|
62
71
|
if (!found.has(lead.ref) && leadKeys.some((key) => keys.has(key))) {
|
|
63
72
|
found.set(lead.ref, lead);
|
|
@@ -72,16 +81,18 @@ var collect = async (outbound, options, keys, found) => {
|
|
|
72
81
|
var filterFor = (key) => key.startsWith("email:") ? { email: key.slice("email:".length) } : {
|
|
73
82
|
linkedinUrl: `https://www.linkedin.com/in/${key.slice("linkedin:".length)}`
|
|
74
83
|
};
|
|
75
|
-
var find = async (outbound, keys, found) => {
|
|
84
|
+
var find = async (outbound, keys, found, tally) => {
|
|
76
85
|
const asked = /* @__PURE__ */ new Set();
|
|
77
86
|
for (let round = [...keys].filter((key) => !asked.has(key)); round.length > 0; round = [...keys].filter((key) => !asked.has(key))) {
|
|
78
87
|
for (const key of round) {
|
|
79
88
|
asked.add(key);
|
|
80
89
|
}
|
|
81
|
-
const answers = await mapConcurrent(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
const answers = await mapConcurrent(round, async (key) => {
|
|
91
|
+
const walk = outbound.leads.listAll(filterFor(key));
|
|
92
|
+
const leads = await walk.toArray();
|
|
93
|
+
tally.requests += walk.meta?.requests ?? 0;
|
|
94
|
+
return leads;
|
|
95
|
+
});
|
|
85
96
|
for (const [index, leads] of answers.entries()) {
|
|
86
97
|
const asking = round[index];
|
|
87
98
|
for (const lead of leads) {
|
|
@@ -120,10 +131,11 @@ var lookup = async (outbound, identifier, options) => {
|
|
|
120
131
|
assertIdentifiersReadable(outbound);
|
|
121
132
|
const keys = /* @__PURE__ */ new Set([key]);
|
|
122
133
|
const found = /* @__PURE__ */ new Map();
|
|
134
|
+
const tally = { requests: 0 };
|
|
123
135
|
if (outbound.capabilities["leads.lookup"] && options.campaignIds === void 0) {
|
|
124
|
-
await find(outbound, keys, found);
|
|
125
|
-
} else if (await collect(outbound, options, keys, found)) {
|
|
126
|
-
await collect(outbound, options, keys, found);
|
|
136
|
+
await find(outbound, keys, found, tally);
|
|
137
|
+
} else if (await collect(outbound, options, keys, found, tally)) {
|
|
138
|
+
await collect(outbound, options, keys, found, tally);
|
|
127
139
|
}
|
|
128
140
|
const records = [...found.values()];
|
|
129
141
|
const wantsTimeline = (options.timeline ?? true) && outbound.capabilities["leads.timeline"];
|
|
@@ -137,6 +149,10 @@ var lookup = async (outbound, identifier, options) => {
|
|
|
137
149
|
key,
|
|
138
150
|
keys: [...keys].toSorted(),
|
|
139
151
|
records,
|
|
152
|
+
requests: timelines.reduce(
|
|
153
|
+
(sum, page) => sum + page.meta.requests,
|
|
154
|
+
tally.requests
|
|
155
|
+
),
|
|
140
156
|
timeline: timelines.flatMap((page) => page.items).toSorted(bySentAt)
|
|
141
157
|
};
|
|
142
158
|
};
|