outbound-sdk 0.1.0 → 0.2.1
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/README.md +0 -2
- package/dist/alerts/index.js +5 -1
- package/dist/audit/index.js +2 -2
- package/dist/benchmarks/index.js +5 -3
- package/dist/budget/index.js +31 -10
- package/dist/cache/index.js +2 -2
- package/dist/cards/index.js +1 -1
- package/dist/chunks/{chunk-WAM6N4OF.js → chunk-4PSO6JEK.js} +107 -19
- package/dist/chunks/chunk-6CVZOUHB.js +152 -0
- package/dist/chunks/{chunk-OCV66TS2.js → chunk-AFU5E5QB.js} +17 -8
- package/dist/chunks/{chunk-R6AM4GJR.js → chunk-DJ2IUQEU.js} +24 -18
- package/dist/chunks/{chunk-LOXBLQ3I.js → chunk-E7JHLNLG.js} +9 -2
- package/dist/chunks/{chunk-LNCOGBMI.js → chunk-FHKSLCVW.js} +13 -3
- package/dist/chunks/chunk-FKH5N47I.js +40 -0
- package/dist/chunks/chunk-HZCTYL22.js +29 -0
- package/dist/chunks/{chunk-CMQ5ZHLZ.js → chunk-IPUYZD4O.js} +1 -1
- package/dist/chunks/{chunk-VURTOVGI.js → chunk-IVH3NMQZ.js} +1 -1
- package/dist/chunks/{chunk-ZGHQYZEH.js → chunk-LVYG7XZJ.js} +1 -1
- package/dist/chunks/chunk-NAKXLBA6.js +30 -0
- package/dist/chunks/{chunk-7BCYLIDG.js → chunk-P3IJBJUI.js} +203 -34
- package/dist/chunks/{chunk-Q465X22Y.js → chunk-PURHK3JU.js} +93 -209
- package/dist/chunks/{chunk-F7MKFVIG.js → chunk-R3Y56YVF.js} +2 -2
- package/dist/chunks/chunk-RCZ7ZZFU.js +92 -0
- package/dist/chunks/chunk-SBIZDCRY.js +106 -0
- package/dist/chunks/{chunk-IBC52BX3.js → chunk-U2D34ARZ.js} +20 -3
- package/dist/chunks/chunk-UAT3JSJZ.js +331 -0
- package/dist/chunks/{chunk-QZNNCXXD.js → chunk-VQSCHOBV.js} +20 -1
- package/dist/chunks/{chunk-B7V6EOAC.js → chunk-XNFESPZH.js} +160 -126
- package/dist/chunks/{chunk-WW746NJF.js → chunk-YOTW5ESM.js} +25 -1
- package/dist/cli/bin.js +14 -13
- package/dist/cli/commands.d.ts +3 -0
- package/dist/cli/config.d.ts +22 -0
- package/dist/cli/index.d.ts +5 -1
- package/dist/cli/index.js +20 -15
- package/dist/cli/stdio.d.ts +9 -0
- package/dist/cli/version.d.ts +2 -0
- package/dist/clients/index.js +13 -3
- package/dist/combine/account.d.ts +1 -1
- package/dist/combine/index.js +90 -15
- package/dist/combine/route.d.ts +7 -0
- package/dist/exporter/index.js +2 -2
- package/dist/failover/index.js +4 -4
- package/dist/fixtures/index.js +40 -21
- package/dist/heyreach/account.d.ts +1 -1
- package/dist/heyreach/adapter.d.ts +1 -1
- package/dist/heyreach/capabilities.d.ts +2 -0
- package/dist/heyreach/client.d.ts +3 -5
- package/dist/heyreach/index.d.ts +7 -0
- package/dist/heyreach/index.js +428 -205
- package/dist/heyreach/leads.d.ts +4 -0
- package/dist/heyreach/map-account.d.ts +7 -1
- package/dist/heyreach/map-stats.d.ts +8 -5
- package/dist/heyreach/map.d.ts +3 -1
- package/dist/heyreach/webhooks.d.ts +1 -0
- package/dist/identity/index.js +22 -11
- package/dist/index.d.ts +1 -4
- package/dist/index.js +29 -17
- package/dist/insights/copy/index.d.ts +2 -2
- package/dist/insights/copy/variant-test.d.ts +2 -2
- package/dist/insights/index.js +248 -184
- package/dist/insights/ops/anomalies.d.ts +3 -3
- package/dist/insights/ops/index.d.ts +2 -2
- package/dist/insights/ops/shared.d.ts +7 -1
- package/dist/insights/registry.d.ts +4 -4
- package/dist/instantly/adapter-account.d.ts +1 -1
- package/dist/instantly/capabilities.d.ts +2 -0
- package/dist/instantly/client.d.ts +4 -9
- package/dist/instantly/index.d.ts +7 -0
- package/dist/instantly/index.js +410 -155
- package/dist/instantly/map-account.d.ts +20 -5
- package/dist/instantly/map-stats.d.ts +9 -6
- package/dist/instantly/map.d.ts +0 -2
- package/dist/instantly/native-agents-sales.d.ts +41 -41
- package/dist/instantly/native-agents.d.ts +44 -44
- package/dist/instantly/native-campaigns.d.ts +21 -21
- package/dist/instantly/native-leads.d.ts +12 -12
- package/dist/instantly/native-params.d.ts +2 -19
- package/dist/instantly/native-search.d.ts +10 -10
- package/dist/instantly/native-senders.d.ts +56 -56
- package/dist/instantly/native-supersearch.d.ts +33 -33
- package/dist/instantly/native-workspace.d.ts +45 -45
- package/dist/instantly/native.d.ts +262 -262
- package/dist/instantly/webhooks.d.ts +1 -0
- package/dist/internal/adapter.d.ts +24 -2
- package/dist/internal/capabilities.d.ts +18 -0
- package/dist/internal/client.d.ts +15 -0
- package/dist/internal/concurrency.d.ts +8 -0
- package/dist/internal/engine/request.d.ts +7 -0
- package/dist/internal/entities-account.d.ts +73 -3
- package/dist/internal/entities.d.ts +116 -12
- package/dist/internal/errors.d.ts +6 -1
- package/dist/internal/fields.d.ts +462 -0
- package/dist/internal/json.d.ts +9 -0
- package/dist/internal/lead-fields.d.ts +21 -0
- package/dist/internal/lead-status.d.ts +13 -0
- package/dist/internal/metrics.d.ts +14 -2
- package/dist/internal/native.d.ts +15 -0
- package/dist/internal/outbound/api.d.ts +29 -4
- package/dist/internal/outbound/operations-account.d.ts +12 -0
- package/dist/internal/outbound/outbound.d.ts +6 -3
- package/dist/internal/outbound/specs-account.d.ts +5 -1
- package/dist/internal/page.d.ts +14 -0
- package/dist/internal/record.d.ts +17 -0
- package/dist/internal/records.d.ts +7 -0
- package/dist/internal/sequence.d.ts +14 -0
- package/dist/internal/sha256.d.ts +2 -0
- package/dist/loader/index.d.ts +14 -2
- package/dist/loader/index.js +8 -4
- package/dist/memory/account-reads.d.ts +1 -1
- package/dist/memory/account.d.ts +15 -1
- package/dist/memory/data.d.ts +17 -2
- package/dist/memory/index.js +110 -35
- package/dist/redact/index.js +11 -6
- package/dist/redact/plugin.d.ts +1 -1
- package/dist/smartlead/account.d.ts +1 -1
- package/dist/smartlead/adapter.d.ts +1 -1
- package/dist/smartlead/capabilities.d.ts +2 -0
- package/dist/smartlead/client.d.ts +6 -11
- package/dist/smartlead/hmac.d.ts +0 -2
- package/dist/smartlead/index.d.ts +7 -0
- package/dist/smartlead/index.js +731 -572
- package/dist/smartlead/leads.d.ts +4 -1
- package/dist/smartlead/map-account.d.ts +17 -5
- package/dist/smartlead/map-stats.d.ts +9 -10
- package/dist/smartlead/map.d.ts +15 -5
- package/dist/smartlead/native-analytics.d.ts +87 -87
- package/dist/smartlead/native-campaigns.d.ts +64 -64
- package/dist/smartlead/native-inbox.d.ts +51 -51
- package/dist/smartlead/native-params.d.ts +2 -23
- package/dist/smartlead/native-services.d.ts +34 -34
- package/dist/smartlead/native.d.ts +236 -236
- package/dist/smartlead/shared.d.ts +6 -5
- package/dist/smartlead/webhooks.d.ts +1 -0
- package/dist/sync/index.js +3 -3
- package/dist/tools/ai-sdk.js +7 -5
- package/dist/tools/campaign-tools.d.ts +1 -1
- package/dist/tools/claude-agent.js +7 -5
- package/dist/tools/index.js +8 -6
- package/dist/tracing/index.js +2 -2
- package/dist/webhooks/index.js +10 -9
- package/package.json +1 -1
- package/dist/chunks/chunk-FZF6CLPX.js +0 -232
- package/dist/chunks/chunk-GPEJG34O.js +0 -53
- package/dist/chunks/chunk-HEC7XFFH.js +0 -65
- package/dist/chunks/chunk-QTB747K4.js +0 -100
- package/dist/chunks/chunk-TIJKJJDW.js +0 -6
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SCHEMA_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4PSO6JEK.js";
|
|
4
4
|
import {
|
|
5
5
|
makeRef
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LVYG7XZJ.js";
|
|
7
|
+
import {
|
|
8
|
+
compactObject
|
|
9
|
+
} from "./chunk-VQSCHOBV.js";
|
|
7
10
|
|
|
8
11
|
// src/internal/record.ts
|
|
9
12
|
var recordBase = (identity, sourceId, raw) => ({
|
|
@@ -16,9 +19,23 @@ var recordBase = (identity, sourceId, raw) => ({
|
|
|
16
19
|
});
|
|
17
20
|
var refTo = (identity, sourceId) => sourceId === null || sourceId === void 0 || sourceId === "" ? null : makeRef(identity.provider, identity.workspaceId, sourceId);
|
|
18
21
|
var refsTo = (identity, sourceIds) => sourceIds.flatMap((sourceId) => refTo(identity, sourceId) ?? []);
|
|
22
|
+
var eventTypesOf = (names, known) => [
|
|
23
|
+
...new Set(
|
|
24
|
+
names.flatMap((name) => {
|
|
25
|
+
const type = known.get(name);
|
|
26
|
+
return type === void 0 || type === "unknown" ? [] : [type];
|
|
27
|
+
})
|
|
28
|
+
)
|
|
29
|
+
].toSorted();
|
|
30
|
+
var eventData = (shared, extras = {}) => (
|
|
31
|
+
// SAFETY: the shared keys were typed on the way in and only absent values are dropped.
|
|
32
|
+
compactObject({ ...extras, ...shared })
|
|
33
|
+
);
|
|
19
34
|
|
|
20
35
|
export {
|
|
21
36
|
recordBase,
|
|
22
37
|
refTo,
|
|
23
|
-
refsTo
|
|
38
|
+
refsTo,
|
|
39
|
+
eventTypesOf,
|
|
40
|
+
eventData
|
|
24
41
|
};
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import {
|
|
2
|
+
baseFields,
|
|
3
|
+
campaignSchema,
|
|
4
|
+
count,
|
|
5
|
+
eventTypeSchema,
|
|
6
|
+
isoDateTime,
|
|
7
|
+
leadSchema,
|
|
8
|
+
messageSchema,
|
|
9
|
+
metricRowSchema,
|
|
10
|
+
replySchema,
|
|
11
|
+
senderSchema,
|
|
12
|
+
sequenceSchema,
|
|
13
|
+
workspaceSchema
|
|
14
|
+
} from "./chunk-4PSO6JEK.js";
|
|
15
|
+
import {
|
|
16
|
+
OutboundError
|
|
17
|
+
} from "./chunk-E7JHLNLG.js";
|
|
18
|
+
|
|
19
|
+
// src/internal/capabilities.ts
|
|
20
|
+
var NO_CAPABILITIES = {
|
|
21
|
+
blocklist: false,
|
|
22
|
+
"campaigns.bySender": false,
|
|
23
|
+
"campaigns.progress": false,
|
|
24
|
+
"campaigns.settings": false,
|
|
25
|
+
"campaigns.status": false,
|
|
26
|
+
deletionDetection: false,
|
|
27
|
+
"events.parse": false,
|
|
28
|
+
"events.verify": false,
|
|
29
|
+
"leads.byCampaign": false,
|
|
30
|
+
"leads.engagement": false,
|
|
31
|
+
"leads.get": false,
|
|
32
|
+
"leads.list": false,
|
|
33
|
+
"leads.lookup": false,
|
|
34
|
+
"leads.since": false,
|
|
35
|
+
"leads.timeline": false,
|
|
36
|
+
"lists.get": false,
|
|
37
|
+
"lists.leads": false,
|
|
38
|
+
"lists.list": false,
|
|
39
|
+
"messages.body": false,
|
|
40
|
+
"messages.byThread": false,
|
|
41
|
+
"messages.list": false,
|
|
42
|
+
"messages.since": false,
|
|
43
|
+
native: false,
|
|
44
|
+
"placementTests.list": false,
|
|
45
|
+
"replies.category": false,
|
|
46
|
+
"replies.list": false,
|
|
47
|
+
"replies.since": false,
|
|
48
|
+
"replies.unread": false,
|
|
49
|
+
"senders.byCampaign": false,
|
|
50
|
+
"senders.get": false,
|
|
51
|
+
"senders.health": false,
|
|
52
|
+
"senders.list": false,
|
|
53
|
+
"senders.warmup": false,
|
|
54
|
+
sequence: false,
|
|
55
|
+
"sequence.subsequences": false,
|
|
56
|
+
"stats.byDay": false,
|
|
57
|
+
"stats.bySender": false,
|
|
58
|
+
"stats.byStep": false,
|
|
59
|
+
"stats.allCampaigns": false,
|
|
60
|
+
"stats.campaign": false,
|
|
61
|
+
"stats.workspace": false,
|
|
62
|
+
tags: false,
|
|
63
|
+
"webhooks.get": false,
|
|
64
|
+
"webhooks.list": false,
|
|
65
|
+
workspaces: false
|
|
66
|
+
};
|
|
67
|
+
var RANK = /* @__PURE__ */ new Map([
|
|
68
|
+
["client", 1],
|
|
69
|
+
["derived", 1],
|
|
70
|
+
["exact", 2],
|
|
71
|
+
["false", 0],
|
|
72
|
+
["full", 2],
|
|
73
|
+
["partial", 1],
|
|
74
|
+
["sampled", 1],
|
|
75
|
+
["secret", 1],
|
|
76
|
+
["server", 2],
|
|
77
|
+
["signature", 2],
|
|
78
|
+
["true", 2],
|
|
79
|
+
["vendor", 2]
|
|
80
|
+
]);
|
|
81
|
+
var rank = (value) => RANK.get(String(value)) ?? 0;
|
|
82
|
+
var resolveCapabilities = (declared = {}) => ({
|
|
83
|
+
...NO_CAPABILITIES,
|
|
84
|
+
...declared
|
|
85
|
+
});
|
|
86
|
+
var weaker = (left, right) => rank(right) < rank(left) ? right : left;
|
|
87
|
+
var narrowKey = (target, key, other) => {
|
|
88
|
+
target[key] = weaker(target[key], other[key]);
|
|
89
|
+
};
|
|
90
|
+
var CAPABILITY_KEYS = Object.keys(NO_CAPABILITIES);
|
|
91
|
+
var intersectCapabilities = (first, ...rest) => {
|
|
92
|
+
const result = { ...first };
|
|
93
|
+
for (const other of rest) {
|
|
94
|
+
for (const key of CAPABILITY_KEYS) {
|
|
95
|
+
narrowKey(result, key, other);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
var requireCapability = (gate, key, what) => {
|
|
101
|
+
const value = gate.capabilities[key];
|
|
102
|
+
if (value === false) {
|
|
103
|
+
const plugin = gate.narrowedBy.get(key);
|
|
104
|
+
const reason = plugin === void 0 ? `the ${gate.provider} adapter does not support it` : `the ${plugin} plugin turned it off`;
|
|
105
|
+
throw new OutboundError(
|
|
106
|
+
"Unsupported",
|
|
107
|
+
`${what} is not available: ${reason} (${key})`,
|
|
108
|
+
{
|
|
109
|
+
provider: gate.provider
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return value;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// src/internal/entities-account.ts
|
|
117
|
+
import { z } from "zod";
|
|
118
|
+
var clock = z.string().regex(/^\d{2}:\d{2}$/u).nullable();
|
|
119
|
+
var flag = z.boolean().nullable();
|
|
120
|
+
var sendingWindowSchema = z.object({
|
|
121
|
+
/** Days of the week the window is open, 0 for Sunday to 6 for Saturday. */
|
|
122
|
+
days: z.array(z.number().int().min(0).max(6)),
|
|
123
|
+
/** `HH:MM` in `timezone`. */
|
|
124
|
+
from: clock,
|
|
125
|
+
name: z.string().nullable(),
|
|
126
|
+
/** An IANA name where the vendor gives one, otherwise the vendor's own label. */
|
|
127
|
+
timezone: z.string().nullable(),
|
|
128
|
+
/** `HH:MM` in `timezone`. */
|
|
129
|
+
to: clock
|
|
130
|
+
});
|
|
131
|
+
var campaignSettingsSchema = z.object({
|
|
132
|
+
...baseFields,
|
|
133
|
+
campaignRef: z.string(),
|
|
134
|
+
/** The most messages (or LinkedIn actions) the campaign sends per day. */
|
|
135
|
+
dailyLimit: count,
|
|
136
|
+
/** The most new leads the campaign contacts per day. */
|
|
137
|
+
dailyNewLeads: count,
|
|
138
|
+
endDate: z.iso.date().nullable(),
|
|
139
|
+
/** The shortest wait between two sends, in minutes. */
|
|
140
|
+
gapMinutes: z.number().nonnegative().nullable(),
|
|
141
|
+
/** `true` when emails are sent without HTML. */
|
|
142
|
+
plainText: flag,
|
|
143
|
+
schedule: z.array(sendingWindowSchema),
|
|
144
|
+
startDate: z.iso.date().nullable(),
|
|
145
|
+
/** `true` when a lead who sends an automatic reply gets no more steps. */
|
|
146
|
+
stopOnAutoReply: flag,
|
|
147
|
+
/** `true` when a lead who replies gets no more steps. */
|
|
148
|
+
stopOnReply: flag,
|
|
149
|
+
tracking: z.object({ clicks: flag, opens: flag })
|
|
150
|
+
});
|
|
151
|
+
var campaignProgressSchema = z.object({
|
|
152
|
+
...baseFields,
|
|
153
|
+
/** Leads the vendor stopped for a bounce or a block list. */
|
|
154
|
+
blocked: count,
|
|
155
|
+
campaignRef: z.string(),
|
|
156
|
+
/** Leads who reached the end of the sequence. */
|
|
157
|
+
completed: count,
|
|
158
|
+
/** Leads the campaign could not run for. */
|
|
159
|
+
failed: count,
|
|
160
|
+
/** Leads who have had a step and have more to come. */
|
|
161
|
+
inProgress: count,
|
|
162
|
+
/** Every lead in the campaign. */
|
|
163
|
+
leads: count,
|
|
164
|
+
/** Leads still waiting for their first step. */
|
|
165
|
+
notStarted: count,
|
|
166
|
+
/** Leads taken out of the sequence before its end. */
|
|
167
|
+
stopped: count
|
|
168
|
+
});
|
|
169
|
+
var senderHealthSchema = z.object({
|
|
170
|
+
...baseFields,
|
|
171
|
+
/** `true` when the domain or address is on a block list the vendor checks. */
|
|
172
|
+
blacklisted: flag,
|
|
173
|
+
/** When the vendor last checked. */
|
|
174
|
+
checkedAt: isoDateTime,
|
|
175
|
+
/** `true` when the vendor can sign in to the mailbox or the LinkedIn seat. */
|
|
176
|
+
connected: flag,
|
|
177
|
+
/** Whether each DNS record is present and valid. */
|
|
178
|
+
dns: z.object({ dkim: flag, dmarc: flag, mx: flag, spf: flag }),
|
|
179
|
+
/** The mailbox's domain, lowercased. `null` for a LinkedIn seat. */
|
|
180
|
+
domain: z.string().nullable(),
|
|
181
|
+
/** Problems in the vendor's own words. */
|
|
182
|
+
issues: z.array(z.string()),
|
|
183
|
+
senderRef: z.string(),
|
|
184
|
+
/** Warmup traffic over the vendor's reporting window. `null` when there is none. */
|
|
185
|
+
warmup: z.object({
|
|
186
|
+
inbox: count,
|
|
187
|
+
received: count,
|
|
188
|
+
score: z.number().nullable(),
|
|
189
|
+
sent: count,
|
|
190
|
+
spam: count
|
|
191
|
+
}).nullable()
|
|
192
|
+
});
|
|
193
|
+
var leadListSchema = z.object({
|
|
194
|
+
...baseFields,
|
|
195
|
+
createdAt: isoDateTime,
|
|
196
|
+
kind: z.enum(["companies", "leads"]),
|
|
197
|
+
/** The vendor's name for it, or its id when the vendor gave none. Never empty. */
|
|
198
|
+
name: z.string().min(1),
|
|
199
|
+
/** How many records the list holds. */
|
|
200
|
+
size: count
|
|
201
|
+
});
|
|
202
|
+
var blockEntrySchema = z.object({
|
|
203
|
+
...baseFields,
|
|
204
|
+
createdAt: isoDateTime,
|
|
205
|
+
kind: z.enum(["company", "domain", "email", "linkedin", "other"]),
|
|
206
|
+
/** Lowercased for emails and domains. Never empty. */
|
|
207
|
+
value: z.string().min(1)
|
|
208
|
+
});
|
|
209
|
+
var tagSchema = z.object({
|
|
210
|
+
...baseFields,
|
|
211
|
+
description: z.string().nullable(),
|
|
212
|
+
name: z.string().min(1)
|
|
213
|
+
});
|
|
214
|
+
var placementTestSchema = z.object({
|
|
215
|
+
...baseFields,
|
|
216
|
+
/** The campaign whose email the test sends. */
|
|
217
|
+
campaignRef: z.string().nullable(),
|
|
218
|
+
createdAt: isoDateTime,
|
|
219
|
+
/** When a scheduled test stops running. */
|
|
220
|
+
endsAt: isoDateTime,
|
|
221
|
+
/** `one_time` for a test run once, `automated` for one on a schedule. */
|
|
222
|
+
kind: z.enum(["automated", "one_time"]).nullable(),
|
|
223
|
+
name: z.string().min(1),
|
|
224
|
+
/** When an automated test runs next. */
|
|
225
|
+
nextRunAt: isoDateTime,
|
|
226
|
+
/** When a scheduled test starts running. */
|
|
227
|
+
startsAt: isoDateTime,
|
|
228
|
+
status: z.enum(["active", "completed", "paused", "unknown"])
|
|
229
|
+
});
|
|
230
|
+
var webhookSubscriptionSchema = z.object({
|
|
231
|
+
...baseFields,
|
|
232
|
+
active: flag,
|
|
233
|
+
/** The campaigns the webhook is limited to. Empty for every campaign. */
|
|
234
|
+
campaignRefs: z.array(z.string()),
|
|
235
|
+
createdAt: isoDateTime,
|
|
236
|
+
/**
|
|
237
|
+
* What those events become when they arrive: the SDK's own event types,
|
|
238
|
+
* without repeats. Empty when no event name is one the adapter knows.
|
|
239
|
+
*/
|
|
240
|
+
eventTypes: z.array(eventTypeSchema),
|
|
241
|
+
/** Event names in the vendor's own words. */
|
|
242
|
+
events: z.array(z.string()),
|
|
243
|
+
name: z.string().nullable(),
|
|
244
|
+
/** Where the vendor posts. It can hold a secret in its path or query. */
|
|
245
|
+
url: z.string()
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// src/internal/fields.ts
|
|
249
|
+
var RECORD_SCHEMAS = {
|
|
250
|
+
blockEntry: blockEntrySchema,
|
|
251
|
+
campaign: campaignSchema,
|
|
252
|
+
campaignProgress: campaignProgressSchema,
|
|
253
|
+
campaignSettings: campaignSettingsSchema,
|
|
254
|
+
lead: leadSchema,
|
|
255
|
+
leadList: leadListSchema,
|
|
256
|
+
message: messageSchema,
|
|
257
|
+
metricRow: metricRowSchema,
|
|
258
|
+
placementTest: placementTestSchema,
|
|
259
|
+
reply: replySchema,
|
|
260
|
+
sender: senderSchema,
|
|
261
|
+
senderHealth: senderHealthSchema,
|
|
262
|
+
sequence: sequenceSchema,
|
|
263
|
+
tag: tagSchema,
|
|
264
|
+
webhook: webhookSubscriptionSchema,
|
|
265
|
+
workspace: workspaceSchema
|
|
266
|
+
};
|
|
267
|
+
var IDENTITY = /* @__PURE__ */ new Set([
|
|
268
|
+
"provider",
|
|
269
|
+
"raw",
|
|
270
|
+
"ref",
|
|
271
|
+
"schemaVersion",
|
|
272
|
+
"sourceId",
|
|
273
|
+
"workspaceId"
|
|
274
|
+
]);
|
|
275
|
+
var RECORD_NAMES = Object.keys(RECORD_SCHEMAS);
|
|
276
|
+
var fieldsOf = (name) => Object.keys(RECORD_SCHEMAS[name].shape).filter(
|
|
277
|
+
(field) => !IDENTITY.has(field)
|
|
278
|
+
);
|
|
279
|
+
var gradesOf = (name, declared) => {
|
|
280
|
+
const stated = declared === false || declared === void 0 ? {} : declared;
|
|
281
|
+
return Object.fromEntries(
|
|
282
|
+
fieldsOf(name).map((field) => [
|
|
283
|
+
field,
|
|
284
|
+
declared === false ? false : stated[field] ?? "exact"
|
|
285
|
+
])
|
|
286
|
+
);
|
|
287
|
+
};
|
|
288
|
+
var resolveFields = (declared = {}) => (
|
|
289
|
+
// SAFETY: every RecordName is mapped, so the entries are a FieldCoverage.
|
|
290
|
+
Object.fromEntries(
|
|
291
|
+
RECORD_NAMES.map((name) => [name, gradesOf(name, declared[name])])
|
|
292
|
+
)
|
|
293
|
+
);
|
|
294
|
+
var best = (grades) => {
|
|
295
|
+
if (grades.includes("exact")) {
|
|
296
|
+
return "exact";
|
|
297
|
+
}
|
|
298
|
+
return grades.includes("derived") ? "derived" : false;
|
|
299
|
+
};
|
|
300
|
+
var mergeFields = (coverages) => (
|
|
301
|
+
// SAFETY: every RecordName is mapped, so the entries are a FieldCoverage.
|
|
302
|
+
Object.fromEntries(
|
|
303
|
+
RECORD_NAMES.map((name) => [
|
|
304
|
+
name,
|
|
305
|
+
Object.fromEntries(
|
|
306
|
+
fieldsOf(name).map((field) => [
|
|
307
|
+
field,
|
|
308
|
+
best(coverages.map((coverage) => coverage[name][field] ?? false))
|
|
309
|
+
])
|
|
310
|
+
)
|
|
311
|
+
])
|
|
312
|
+
)
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
export {
|
|
316
|
+
NO_CAPABILITIES,
|
|
317
|
+
resolveCapabilities,
|
|
318
|
+
CAPABILITY_KEYS,
|
|
319
|
+
intersectCapabilities,
|
|
320
|
+
requireCapability,
|
|
321
|
+
campaignSettingsSchema,
|
|
322
|
+
campaignProgressSchema,
|
|
323
|
+
senderHealthSchema,
|
|
324
|
+
leadListSchema,
|
|
325
|
+
blockEntrySchema,
|
|
326
|
+
tagSchema,
|
|
327
|
+
placementTestSchema,
|
|
328
|
+
webhookSubscriptionSchema,
|
|
329
|
+
resolveFields,
|
|
330
|
+
mergeFields
|
|
331
|
+
};
|
|
@@ -25,6 +25,10 @@ var count = (value) => {
|
|
|
25
25
|
}
|
|
26
26
|
return null;
|
|
27
27
|
};
|
|
28
|
+
var fullName = (first, last) => {
|
|
29
|
+
const name = [text(first), text(last)].filter((part) => part !== null).join(" ");
|
|
30
|
+
return name === "" ? null : name;
|
|
31
|
+
};
|
|
28
32
|
var flag = (value) => isBoolean(value) ? value : null;
|
|
29
33
|
var list = (value) => isJsonArray(value) ? value : [];
|
|
30
34
|
var objects = (value) => list(value).filter((item) => isJsonObject(item));
|
|
@@ -70,6 +74,19 @@ var unknownKey = (known, input) => {
|
|
|
70
74
|
const stray = Object.keys(input).find((key) => !known.includes(key));
|
|
71
75
|
return stray === void 0 ? void 0 : `"${stray}" is not an input. It takes: ${known.toSorted().join(", ") || "nothing"}`;
|
|
72
76
|
};
|
|
77
|
+
var withoutKeys = (value, secret) => {
|
|
78
|
+
if (isJsonArray(value)) {
|
|
79
|
+
return value.map((entry) => withoutKeys(entry, secret));
|
|
80
|
+
}
|
|
81
|
+
if (!isJsonObject(value)) {
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
return Object.fromEntries(
|
|
85
|
+
Object.entries(value).flatMap(
|
|
86
|
+
([key, entry]) => secret.test(key) ? [] : [[key, withoutKeys(entry, secret)]]
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
};
|
|
73
90
|
|
|
74
91
|
export {
|
|
75
92
|
isJsonObject,
|
|
@@ -79,6 +96,7 @@ export {
|
|
|
79
96
|
field,
|
|
80
97
|
text,
|
|
81
98
|
count,
|
|
99
|
+
fullName,
|
|
82
100
|
flag,
|
|
83
101
|
list,
|
|
84
102
|
objects,
|
|
@@ -88,5 +106,6 @@ export {
|
|
|
88
106
|
stringMap,
|
|
89
107
|
compactObject,
|
|
90
108
|
toJson,
|
|
91
|
-
unknownKey
|
|
109
|
+
unknownKey,
|
|
110
|
+
withoutKeys
|
|
92
111
|
};
|