@enlitt/protocol 0.1.0 → 0.1.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/CHANGELOG.md +8 -0
- package/dist/dashboard.d.cts +50 -2
- package/dist/dashboard.d.ts +50 -2
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/errors.d.cts +2 -1
- package/dist/errors.d.ts +2 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.cjs +254 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +244 -11
- package/dist/index.js.map +1 -1
- package/dist/outreach.d.cts +73 -0
- package/dist/outreach.d.ts +74 -0
- package/dist/outreach.d.ts.map +1 -0
- package/generated/contract.json +9 -0
- package/package.json +10 -1
package/dist/index.cjs
CHANGED
|
@@ -166,6 +166,12 @@ var ENLITT_ERROR_CODES = Object.freeze({
|
|
|
166
166
|
...forbidden
|
|
167
167
|
}),
|
|
168
168
|
insufficient_permissions: definition({ type: "permission_error", status: 403, retryable: false, ...forbidden }),
|
|
169
|
+
// The application's premium switch (`applications.premium_enabled`) refuses
|
|
170
|
+
// premium: a premium start while it is off, or a terminal report for an
|
|
171
|
+
// operation that started before the switch last changed. It is the
|
|
172
|
+
// business's configuration to fix, never a credit refusal, so it carries no
|
|
173
|
+
// `authorize_url` and no other extension field (owner decision 2026-10-25).
|
|
174
|
+
premium_not_enabled: definition({ type: "permission_error", status: 403, retryable: false, ...forbidden }),
|
|
169
175
|
not_found: definition({ type: "invalid_request_error", status: 404, retryable: false, ...forbidden }),
|
|
170
176
|
request_too_large: definition({ type: "invalid_request_error", status: 413, retryable: false, ...forbidden }),
|
|
171
177
|
server_error: definition({ type: "server_error", status: 500, retryable: true, ...forbidden }),
|
|
@@ -346,21 +352,21 @@ function classifyEnlittErrorResponse(status, body) {
|
|
|
346
352
|
var COOKIE_VALUE = /^[\x21\x23-\x2b\x2d-\x3a\x3c-\x5b\x5d-\x7e]{1,4096}$/;
|
|
347
353
|
var SUBJECT = /^[A-Za-z0-9_-]{1,255}$/;
|
|
348
354
|
function validateAuthorizationExchangeResponse(payload, options) {
|
|
349
|
-
const
|
|
355
|
+
const invalid4 = (param) => ({
|
|
350
356
|
ok: false,
|
|
351
357
|
error: { code: ENLITT_ERROR_CODE.invalid_value, param, message: "Invalid authorization exchange response" }
|
|
352
358
|
});
|
|
353
|
-
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return
|
|
359
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return invalid4("body");
|
|
354
360
|
const body = payload;
|
|
355
361
|
if (options?.mode !== "tolerant") {
|
|
356
362
|
for (const key of Object.keys(body)) {
|
|
357
|
-
if (key !== "session_token" && key !== "subject") return
|
|
363
|
+
if (key !== "session_token" && key !== "subject") return invalid4(key);
|
|
358
364
|
}
|
|
359
365
|
}
|
|
360
366
|
if (typeof body.session_token !== "string" || !COOKIE_VALUE.test(body.session_token)) {
|
|
361
|
-
return
|
|
367
|
+
return invalid4("session_token");
|
|
362
368
|
}
|
|
363
|
-
if (typeof body.subject !== "string" || !SUBJECT.test(body.subject)) return
|
|
369
|
+
if (typeof body.subject !== "string" || !SUBJECT.test(body.subject)) return invalid4("subject");
|
|
364
370
|
return { ok: true, value: { session_token: body.session_token, subject: body.subject } };
|
|
365
371
|
}
|
|
366
372
|
|
|
@@ -1999,13 +2005,54 @@ function validatePersonalApplicationUsage(value) {
|
|
|
1999
2005
|
}
|
|
2000
2006
|
return ok3({ range: range.value, data_fresh_at: dataFreshAt.value, daily });
|
|
2001
2007
|
}
|
|
2008
|
+
function premiumUnitsHistogramBinCount(upperUnits) {
|
|
2009
|
+
const credits = upperUnits / 1000n;
|
|
2010
|
+
if (credits < 50n) return 50;
|
|
2011
|
+
if (credits > 1000n) return 1e3;
|
|
2012
|
+
return Number(credits);
|
|
2013
|
+
}
|
|
2002
2014
|
function validateApplicationCostProfile(value, param = "cost_profile", options) {
|
|
2003
2015
|
return withResponseOptions(value, options, () => validateApplicationCostProfileShape(value, param));
|
|
2004
2016
|
}
|
|
2017
|
+
function isHistogramSpanUnits(units) {
|
|
2018
|
+
for (let decade = 10000n; decade <= units; decade *= 10n) {
|
|
2019
|
+
if (units === decade || units === decade * 2n || units === decade * 5n) return true;
|
|
2020
|
+
}
|
|
2021
|
+
return false;
|
|
2022
|
+
}
|
|
2023
|
+
function validatePremiumUnitsHistogram(value, param) {
|
|
2024
|
+
if (!isPlainObject4(value)) return invalidValue3(param, "must be an object");
|
|
2025
|
+
const upper = expectCanonicalAmount(value.upper_units, `${param}.upper_units`);
|
|
2026
|
+
if (!upper.ok) return upper;
|
|
2027
|
+
if (!isHistogramSpanUnits(BigInt(upper.value))) {
|
|
2028
|
+
return invalidValue3(`${param}.upper_units`, "must be a 1-2-5 credit span of at least 10 credits");
|
|
2029
|
+
}
|
|
2030
|
+
const binCount = premiumUnitsHistogramBinCount(BigInt(upper.value));
|
|
2031
|
+
if (!Array.isArray(value.bin_shares_permille) || value.bin_shares_permille.length !== binCount) {
|
|
2032
|
+
return invalidValue3(
|
|
2033
|
+
`${param}.bin_shares_permille`,
|
|
2034
|
+
`must be an array of ${binCount} integers for this upper_units`
|
|
2035
|
+
);
|
|
2036
|
+
}
|
|
2037
|
+
const shares = [];
|
|
2038
|
+
for (const [index, item] of value.bin_shares_permille.entries()) {
|
|
2039
|
+
const share = expectNonNegativeInteger(item, `${param}.bin_shares_permille[${index}]`);
|
|
2040
|
+
if (!share.ok) return share;
|
|
2041
|
+
shares.push(share.value);
|
|
2042
|
+
}
|
|
2043
|
+
const above = expectNonNegativeInteger(value.above_share_permille, `${param}.above_share_permille`);
|
|
2044
|
+
if (!above.ok) return above;
|
|
2045
|
+
if (shares.reduce((sum, share) => sum + share, 0) + above.value !== 1e3) {
|
|
2046
|
+
return invalidValue3(param, "the bin and above shares must sum to exactly 1000");
|
|
2047
|
+
}
|
|
2048
|
+
return ok3({ upper_units: upper.value, bin_shares_permille: shares, above_share_permille: above.value });
|
|
2049
|
+
}
|
|
2005
2050
|
function validateApplicationCostProfileShape(value, param) {
|
|
2006
2051
|
if (!isPlainObject4(value)) return invalidValue3(param, "must be an object");
|
|
2007
2052
|
const disclosed = expectBoolean(value.disclosed, `${param}.disclosed`);
|
|
2008
2053
|
if (!disclosed.ok) return disclosed;
|
|
2054
|
+
const premiumEnabled = expectBoolean(value.premium_enabled, `${param}.premium_enabled`);
|
|
2055
|
+
if (!premiumEnabled.ok) return premiumEnabled;
|
|
2009
2056
|
const usesPremium = expectBoolean(value.uses_premium, `${param}.uses_premium`);
|
|
2010
2057
|
if (!usesPremium.ok) return usesPremium;
|
|
2011
2058
|
const median = expectOptionalCanonicalAmount(
|
|
@@ -2023,6 +2070,8 @@ function validateApplicationCostProfileShape(value, param) {
|
|
|
2023
2070
|
`${param}.max_premium_units_per_charged_call`
|
|
2024
2071
|
);
|
|
2025
2072
|
if (!max.ok) return max;
|
|
2073
|
+
const histogram = value.premium_units_histogram === void 0 ? ok3(void 0) : validatePremiumUnitsHistogram(value.premium_units_histogram, `${param}.premium_units_histogram`);
|
|
2074
|
+
if (!histogram.ok) return histogram;
|
|
2026
2075
|
const estimated = expectOptionalCanonicalAmount(
|
|
2027
2076
|
value.estimated_premium_units_per_charged_call,
|
|
2028
2077
|
`${param}.estimated_premium_units_per_charged_call`
|
|
@@ -2034,22 +2083,26 @@ function validateApplicationCostProfileShape(value, param) {
|
|
|
2034
2083
|
if (!windowEnd.ok) return windowEnd;
|
|
2035
2084
|
const computedAt = expectRfc33392(value.computed_at, `${param}.computed_at`);
|
|
2036
2085
|
if (!computedAt.ok) return computedAt;
|
|
2037
|
-
const present = [median.value, p90.value, max.value].filter(
|
|
2086
|
+
const present = [median.value, p90.value, max.value, histogram.value].filter(
|
|
2087
|
+
(figure) => figure !== void 0
|
|
2088
|
+
).length;
|
|
2038
2089
|
if (disclosed.value === false && present > 0) {
|
|
2039
|
-
return invalidValue3(param, "the three figures must be absent when disclosed is false");
|
|
2090
|
+
return invalidValue3(param, "the three figures and the histogram must be absent when disclosed is false");
|
|
2040
2091
|
}
|
|
2041
|
-
if (disclosed.value === true && present !==
|
|
2042
|
-
return invalidValue3(param, "the three figures must all be present when disclosed is true");
|
|
2092
|
+
if (disclosed.value === true && present !== 4) {
|
|
2093
|
+
return invalidValue3(param, "the three figures and the histogram must all be present when disclosed is true");
|
|
2043
2094
|
}
|
|
2044
2095
|
if (disclosed.value === true && estimated.value !== void 0) {
|
|
2045
2096
|
return invalidValue3(param, "the estimate must be absent when disclosed is true");
|
|
2046
2097
|
}
|
|
2047
2098
|
return ok3({
|
|
2048
2099
|
disclosed: disclosed.value,
|
|
2100
|
+
premium_enabled: premiumEnabled.value,
|
|
2049
2101
|
uses_premium: usesPremium.value,
|
|
2050
2102
|
...median.value !== void 0 ? { median_premium_units_per_charged_call: median.value } : {},
|
|
2051
2103
|
...p90.value !== void 0 ? { p90_premium_units_per_charged_call: p90.value } : {},
|
|
2052
2104
|
...max.value !== void 0 ? { max_premium_units_per_charged_call: max.value } : {},
|
|
2105
|
+
...histogram.value !== void 0 ? { premium_units_histogram: histogram.value } : {},
|
|
2053
2106
|
...estimated.value !== void 0 ? { estimated_premium_units_per_charged_call: estimated.value } : {},
|
|
2054
2107
|
window_start: windowStart.value,
|
|
2055
2108
|
window_end: windowEnd.value,
|
|
@@ -2215,12 +2268,15 @@ function validateConsentInfoShape(value) {
|
|
|
2215
2268
|
if (!existing.ok) return existing;
|
|
2216
2269
|
const isReauthorization = expectBoolean(value.is_reauthorization, "is_reauthorization");
|
|
2217
2270
|
if (!isReauthorization.ok) return isReauthorization;
|
|
2271
|
+
const standardUnmetered = expectBoolean(value.standard_unmetered, "standard_unmetered");
|
|
2272
|
+
if (!standardUnmetered.ok) return standardUnmetered;
|
|
2218
2273
|
return ok3({
|
|
2219
2274
|
application: application.value,
|
|
2220
2275
|
cost_profile: costProfile.value,
|
|
2221
2276
|
prefill_limits: prefill.value,
|
|
2222
2277
|
...existing.value !== void 0 ? { existing_limits: existing.value } : {},
|
|
2223
|
-
is_reauthorization: isReauthorization.value
|
|
2278
|
+
is_reauthorization: isReauthorization.value,
|
|
2279
|
+
standard_unmetered: standardUnmetered.value
|
|
2224
2280
|
});
|
|
2225
2281
|
}
|
|
2226
2282
|
function validateConsentCompletionRequest(value) {
|
|
@@ -2804,6 +2860,7 @@ var BUSINESS_PERMISSIONS = [
|
|
|
2804
2860
|
"payouts.manage",
|
|
2805
2861
|
"payout_billing.manage",
|
|
2806
2862
|
"members.manage",
|
|
2863
|
+
"premium.manage",
|
|
2807
2864
|
"ownership.transfer"
|
|
2808
2865
|
];
|
|
2809
2866
|
var BUSINESS_ROLE_NAMES = ["owner", "admin", "developer", "viewer"];
|
|
@@ -3214,6 +3271,8 @@ function validateBusinessApplicationDetailShape(value) {
|
|
|
3214
3271
|
if (!environment.ok) return environment;
|
|
3215
3272
|
const status = expectLiteral(value.status, APPLICATION_STATUSES, "status");
|
|
3216
3273
|
if (!status.ok) return status;
|
|
3274
|
+
const premiumEnabled = expectBoolean(value.premium_enabled, "premium_enabled");
|
|
3275
|
+
if (!premiumEnabled.ok) return premiumEnabled;
|
|
3217
3276
|
const info = validateBusinessApplicationInfoShape(value.info, "info");
|
|
3218
3277
|
if (!info.ok) return info;
|
|
3219
3278
|
const redirectUris = validateUniqueStringList(
|
|
@@ -3240,6 +3299,7 @@ function validateBusinessApplicationDetailShape(value) {
|
|
|
3240
3299
|
name: name.value,
|
|
3241
3300
|
environment: environment.value,
|
|
3242
3301
|
status: status.value,
|
|
3302
|
+
premium_enabled: premiumEnabled.value,
|
|
3243
3303
|
info: info.value,
|
|
3244
3304
|
redirect_uris: redirectUris.value,
|
|
3245
3305
|
allowed_origins: allowedOrigins.value,
|
|
@@ -3248,6 +3308,15 @@ function validateBusinessApplicationDetailShape(value) {
|
|
|
3248
3308
|
api_keys: apiKeys.value
|
|
3249
3309
|
});
|
|
3250
3310
|
}
|
|
3311
|
+
function validateBusinessApplicationPremiumRequest(value) {
|
|
3312
|
+
if (!isPlainObject4(value)) return invalidValue3("body", "must be an object");
|
|
3313
|
+
for (const key of Object.keys(value)) {
|
|
3314
|
+
if (key !== "enabled") return invalidValue3(key, "is not accepted");
|
|
3315
|
+
}
|
|
3316
|
+
const enabled = expectBoolean(value.enabled, "enabled");
|
|
3317
|
+
if (!enabled.ok) return enabled;
|
|
3318
|
+
return ok3({ enabled: enabled.value });
|
|
3319
|
+
}
|
|
3251
3320
|
function validateCreateBusinessKeyRequest(value) {
|
|
3252
3321
|
if (!isPlainObject4(value)) return invalidValue3("body", "must be an object");
|
|
3253
3322
|
const rejected = rejectUnknownKeys(value, ["scope", "name", "application_id", "expires_at"]);
|
|
@@ -4621,6 +4690,170 @@ function validateAdminActionSummary(value, options) {
|
|
|
4621
4690
|
return parsed.ok ? parsed : parsed;
|
|
4622
4691
|
}
|
|
4623
4692
|
|
|
4693
|
+
// src/outreach.ts
|
|
4694
|
+
var OUTREACH_TRACKING_ID_PATTERN = /^[0-9a-f]{32}$/;
|
|
4695
|
+
var OUTREACH_VISIT_REQUEST_MAX_BYTES = 1024;
|
|
4696
|
+
var OUTREACH_VISIT_EVENTS = ["view", "engaged"];
|
|
4697
|
+
var OUTREACH_AUTOMATED_SIGNALS = ["user_agent", "webdriver", "hosting_network"];
|
|
4698
|
+
var OUTREACH_VISIT_LIST_DEFAULT_LIMIT = 200;
|
|
4699
|
+
var OUTREACH_VISIT_LIST_MAX_LIMIT = 500;
|
|
4700
|
+
var RFC33392 = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|z|[+-]\d{2}:\d{2})$/;
|
|
4701
|
+
var UUID2 = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
4702
|
+
var COUNTRY = /^[A-Z]{2}$/;
|
|
4703
|
+
function ok6(value) {
|
|
4704
|
+
return { ok: true, value };
|
|
4705
|
+
}
|
|
4706
|
+
function fail4(code, param, message) {
|
|
4707
|
+
return { ok: false, error: { code, param, message } };
|
|
4708
|
+
}
|
|
4709
|
+
function invalid3(param, message) {
|
|
4710
|
+
return fail4(ENLITT_ERROR_CODE.invalid_value, param, message);
|
|
4711
|
+
}
|
|
4712
|
+
function isObject3(value) {
|
|
4713
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4714
|
+
}
|
|
4715
|
+
function isRfc3339(value) {
|
|
4716
|
+
return typeof value === "string" && RFC33392.test(value) && !Number.isNaN(Date.parse(value));
|
|
4717
|
+
}
|
|
4718
|
+
function rejectUnknown2(value, allowed, prefix) {
|
|
4719
|
+
for (const key of Object.keys(value)) {
|
|
4720
|
+
if (!allowed.includes(key)) {
|
|
4721
|
+
return fail4(ENLITT_ERROR_CODE.unsupported_parameter, `${prefix}${key}`, `"${key}" is not accepted`);
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4724
|
+
return null;
|
|
4725
|
+
}
|
|
4726
|
+
function validateOutreachVisitRequest(value) {
|
|
4727
|
+
if (!isObject3(value)) return invalid3("body", "must be a JSON object");
|
|
4728
|
+
const unknown = rejectUnknown2(value, ["tracking_id", "event", "visitor_key", "webdriver"], "");
|
|
4729
|
+
if (unknown) return unknown;
|
|
4730
|
+
const { tracking_id, event, visitor_key, webdriver } = value;
|
|
4731
|
+
if (typeof tracking_id !== "string" || !OUTREACH_TRACKING_ID_PATTERN.test(tracking_id)) {
|
|
4732
|
+
return invalid3("tracking_id", "must be 32 lowercase hexadecimal characters");
|
|
4733
|
+
}
|
|
4734
|
+
if (typeof event !== "string" || !OUTREACH_VISIT_EVENTS.includes(event)) {
|
|
4735
|
+
return invalid3("event", `must be one of: ${OUTREACH_VISIT_EVENTS.join(", ")}`);
|
|
4736
|
+
}
|
|
4737
|
+
if (typeof visitor_key !== "string" || !OUTREACH_TRACKING_ID_PATTERN.test(visitor_key)) {
|
|
4738
|
+
return invalid3("visitor_key", "must be 32 lowercase hexadecimal characters");
|
|
4739
|
+
}
|
|
4740
|
+
if (typeof webdriver !== "boolean") return invalid3("webdriver", "must be a boolean");
|
|
4741
|
+
return ok6({ tracking_id, event, visitor_key, webdriver });
|
|
4742
|
+
}
|
|
4743
|
+
var LIST_PARAMS = ["tracking_id", "since", "cursor", "limit"];
|
|
4744
|
+
function validateOutreachVisitListQuery(params) {
|
|
4745
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4746
|
+
for (const key of params.keys()) {
|
|
4747
|
+
if (!LIST_PARAMS.includes(key)) {
|
|
4748
|
+
return fail4(ENLITT_ERROR_CODE.unsupported_parameter, key, `"${key}" is not accepted`);
|
|
4749
|
+
}
|
|
4750
|
+
if (seen.has(key)) return invalid3(key, "must appear at most once");
|
|
4751
|
+
seen.add(key);
|
|
4752
|
+
}
|
|
4753
|
+
const trackingId = params.get("tracking_id");
|
|
4754
|
+
const since = params.get("since");
|
|
4755
|
+
const cursor = params.get("cursor");
|
|
4756
|
+
const limit = params.get("limit");
|
|
4757
|
+
if (trackingId === null === (since === null)) {
|
|
4758
|
+
return invalid3(trackingId === null ? "since" : "tracking_id", "send exactly one of tracking_id or since");
|
|
4759
|
+
}
|
|
4760
|
+
if (trackingId !== null) {
|
|
4761
|
+
if (!OUTREACH_TRACKING_ID_PATTERN.test(trackingId)) {
|
|
4762
|
+
return invalid3("tracking_id", "must be 32 lowercase hexadecimal characters");
|
|
4763
|
+
}
|
|
4764
|
+
if (cursor !== null) return invalid3("cursor", "is accepted only with since");
|
|
4765
|
+
if (limit !== null) return invalid3("limit", "is accepted only with since");
|
|
4766
|
+
return ok6({ kind: "tracking_id", tracking_id: trackingId });
|
|
4767
|
+
}
|
|
4768
|
+
if (!isRfc3339(since)) return invalid3("since", "must be an RFC 3339 timestamp");
|
|
4769
|
+
if (cursor !== null && cursor.length === 0) return invalid3("cursor", "must not be empty");
|
|
4770
|
+
let parsedLimit = OUTREACH_VISIT_LIST_DEFAULT_LIMIT;
|
|
4771
|
+
if (limit !== null) {
|
|
4772
|
+
if (!/^[1-9][0-9]{0,2}$/.test(limit) || Number(limit) > OUTREACH_VISIT_LIST_MAX_LIMIT) {
|
|
4773
|
+
return invalid3("limit", `must be an integer between 1 and ${OUTREACH_VISIT_LIST_MAX_LIMIT}`);
|
|
4774
|
+
}
|
|
4775
|
+
parsedLimit = Number(limit);
|
|
4776
|
+
}
|
|
4777
|
+
return ok6({ kind: "since", since, cursor, limit: parsedLimit });
|
|
4778
|
+
}
|
|
4779
|
+
function validateVisit(value, param) {
|
|
4780
|
+
if (!isObject3(value)) return invalid3(param, "must be an object");
|
|
4781
|
+
const unknown = rejectUnknown2(
|
|
4782
|
+
value,
|
|
4783
|
+
[
|
|
4784
|
+
"id",
|
|
4785
|
+
"tracking_id",
|
|
4786
|
+
"event",
|
|
4787
|
+
"visitor_key",
|
|
4788
|
+
"visited_at",
|
|
4789
|
+
"user_agent",
|
|
4790
|
+
"webdriver",
|
|
4791
|
+
"country",
|
|
4792
|
+
"asn",
|
|
4793
|
+
"as_organization",
|
|
4794
|
+
"automated_signals"
|
|
4795
|
+
],
|
|
4796
|
+
`${param}.`
|
|
4797
|
+
);
|
|
4798
|
+
if (unknown) return unknown;
|
|
4799
|
+
const v = value;
|
|
4800
|
+
const at = (key) => `${param}.${key}`;
|
|
4801
|
+
if (typeof v.id !== "string" || !UUID2.test(v.id)) return invalid3(at("id"), "must be a UUID");
|
|
4802
|
+
if (typeof v.tracking_id !== "string" || !OUTREACH_TRACKING_ID_PATTERN.test(v.tracking_id)) {
|
|
4803
|
+
return invalid3(at("tracking_id"), "must be 32 lowercase hexadecimal characters");
|
|
4804
|
+
}
|
|
4805
|
+
if (typeof v.event !== "string" || !OUTREACH_VISIT_EVENTS.includes(v.event)) {
|
|
4806
|
+
return invalid3(at("event"), `must be one of: ${OUTREACH_VISIT_EVENTS.join(", ")}`);
|
|
4807
|
+
}
|
|
4808
|
+
if (typeof v.visitor_key !== "string" || !OUTREACH_TRACKING_ID_PATTERN.test(v.visitor_key)) {
|
|
4809
|
+
return invalid3(at("visitor_key"), "must be 32 lowercase hexadecimal characters");
|
|
4810
|
+
}
|
|
4811
|
+
if (!isRfc3339(v.visited_at)) return invalid3(at("visited_at"), "must be an RFC 3339 timestamp");
|
|
4812
|
+
if (v.user_agent !== null && (typeof v.user_agent !== "string" || v.user_agent.length > 512)) {
|
|
4813
|
+
return invalid3(at("user_agent"), "must be null or a string of at most 512 characters");
|
|
4814
|
+
}
|
|
4815
|
+
if (typeof v.webdriver !== "boolean") return invalid3(at("webdriver"), "must be a boolean");
|
|
4816
|
+
if (v.country !== null && (typeof v.country !== "string" || !COUNTRY.test(v.country))) {
|
|
4817
|
+
return invalid3(at("country"), "must be null or two uppercase letters");
|
|
4818
|
+
}
|
|
4819
|
+
if (v.asn !== null && !(Number.isSafeInteger(v.asn) && v.asn > 0)) {
|
|
4820
|
+
return invalid3(at("asn"), "must be null or a positive integer");
|
|
4821
|
+
}
|
|
4822
|
+
if (v.as_organization !== null && (typeof v.as_organization !== "string" || v.as_organization.length > 128)) {
|
|
4823
|
+
return invalid3(at("as_organization"), "must be null or a string of at most 128 characters");
|
|
4824
|
+
}
|
|
4825
|
+
if (!Array.isArray(v.automated_signals)) return invalid3(at("automated_signals"), "must be an array");
|
|
4826
|
+
let previous = -1;
|
|
4827
|
+
for (const [index, signal] of v.automated_signals.entries()) {
|
|
4828
|
+
const position = OUTREACH_AUTOMATED_SIGNALS.indexOf(signal);
|
|
4829
|
+
if (position === -1) {
|
|
4830
|
+
return invalid3(`${at("automated_signals")}[${index}]`, `must be one of: ${OUTREACH_AUTOMATED_SIGNALS.join(", ")}`);
|
|
4831
|
+
}
|
|
4832
|
+
if (position <= previous) {
|
|
4833
|
+
return invalid3(at("automated_signals"), "must be in vocabulary order without duplicates");
|
|
4834
|
+
}
|
|
4835
|
+
previous = position;
|
|
4836
|
+
}
|
|
4837
|
+
return ok6(v);
|
|
4838
|
+
}
|
|
4839
|
+
function validateOutreachVisitList(value) {
|
|
4840
|
+
if (!isObject3(value)) return invalid3("body", "must be an object");
|
|
4841
|
+
const unknown = rejectUnknown2(value, ["visits", "next_cursor"], "");
|
|
4842
|
+
if (unknown) return unknown;
|
|
4843
|
+
if (!Array.isArray(value.visits)) return invalid3("visits", "must be an array");
|
|
4844
|
+
const visits = [];
|
|
4845
|
+
for (const [index, entry] of value.visits.entries()) {
|
|
4846
|
+
const parsed = validateVisit(entry, `visits[${index}]`);
|
|
4847
|
+
if (!parsed.ok) return parsed;
|
|
4848
|
+
visits.push(parsed.value);
|
|
4849
|
+
}
|
|
4850
|
+
const nextCursor = value.next_cursor;
|
|
4851
|
+
if (nextCursor !== null && (typeof nextCursor !== "string" || nextCursor.length === 0)) {
|
|
4852
|
+
return invalid3("next_cursor", "must be null or a non-empty string");
|
|
4853
|
+
}
|
|
4854
|
+
return ok6({ visits, next_cursor: nextCursor });
|
|
4855
|
+
}
|
|
4856
|
+
|
|
4624
4857
|
exports.ADMIN_ACTION_KINDS = ADMIN_ACTION_KINDS;
|
|
4625
4858
|
exports.ADMIN_ACTION_STATUSES = ADMIN_ACTION_STATUSES;
|
|
4626
4859
|
exports.ADMIN_COMMAND_NAMES = ADMIN_COMMAND_NAMES;
|
|
@@ -4669,6 +4902,12 @@ exports.IdempotencyKeyError = IdempotencyKeyError;
|
|
|
4669
4902
|
exports.LOCKED_DOWNGRADE_MODES = LOCKED_DOWNGRADE_MODES;
|
|
4670
4903
|
exports.ORDER_KINDS = ORDER_KINDS;
|
|
4671
4904
|
exports.ORDER_STATUSES = ORDER_STATUSES;
|
|
4905
|
+
exports.OUTREACH_AUTOMATED_SIGNALS = OUTREACH_AUTOMATED_SIGNALS;
|
|
4906
|
+
exports.OUTREACH_TRACKING_ID_PATTERN = OUTREACH_TRACKING_ID_PATTERN;
|
|
4907
|
+
exports.OUTREACH_VISIT_EVENTS = OUTREACH_VISIT_EVENTS;
|
|
4908
|
+
exports.OUTREACH_VISIT_LIST_DEFAULT_LIMIT = OUTREACH_VISIT_LIST_DEFAULT_LIMIT;
|
|
4909
|
+
exports.OUTREACH_VISIT_LIST_MAX_LIMIT = OUTREACH_VISIT_LIST_MAX_LIMIT;
|
|
4910
|
+
exports.OUTREACH_VISIT_REQUEST_MAX_BYTES = OUTREACH_VISIT_REQUEST_MAX_BYTES;
|
|
4672
4911
|
exports.PAYOUT_BLOCKED_REASONS = PAYOUT_BLOCKED_REASONS;
|
|
4673
4912
|
exports.PERSONAL_APPLICATION_CALLS_DEFAULT_LIMIT = PERSONAL_APPLICATION_CALLS_DEFAULT_LIMIT;
|
|
4674
4913
|
exports.PERSONAL_APPLICATION_CALLS_MAX_LIMIT = PERSONAL_APPLICATION_CALLS_MAX_LIMIT;
|
|
@@ -4709,6 +4948,7 @@ exports.isValidIdempotencyKey = isValidIdempotencyKey;
|
|
|
4709
4948
|
exports.normalizeCliUserCode = normalizeCliUserCode;
|
|
4710
4949
|
exports.parseCanonicalInteger = parseCanonicalInteger;
|
|
4711
4950
|
exports.parsePositiveCanonicalInteger = parsePositiveCanonicalInteger;
|
|
4951
|
+
exports.premiumUnitsHistogramBinCount = premiumUnitsHistogramBinCount;
|
|
4712
4952
|
exports.renderEnlittError = renderEnlittError;
|
|
4713
4953
|
exports.serializeWireContract = serializeWireContract;
|
|
4714
4954
|
exports.validateAdminActionErrorResponse = validateAdminActionErrorResponse;
|
|
@@ -4727,6 +4967,7 @@ exports.validateBeginPremiumOperationResponse = validateBeginPremiumOperationRes
|
|
|
4727
4967
|
exports.validateBusinessAccess = validateBusinessAccess;
|
|
4728
4968
|
exports.validateBusinessApplicationDetail = validateBusinessApplicationDetail;
|
|
4729
4969
|
exports.validateBusinessApplicationInfo = validateBusinessApplicationInfo;
|
|
4970
|
+
exports.validateBusinessApplicationPremiumRequest = validateBusinessApplicationPremiumRequest;
|
|
4730
4971
|
exports.validateBusinessDashboardInfo = validateBusinessDashboardInfo;
|
|
4731
4972
|
exports.validateBusinessInvitationRequest = validateBusinessInvitationRequest;
|
|
4732
4973
|
exports.validateBusinessInvitationResult = validateBusinessInvitationResult;
|
|
@@ -4766,6 +5007,9 @@ exports.validateEmptyRequestBody = validateEmptyRequestBody;
|
|
|
4766
5007
|
exports.validateEnlittStandardRequest = validateEnlittStandardRequest;
|
|
4767
5008
|
exports.validateOpenAIResponse = validateOpenAIResponse;
|
|
4768
5009
|
exports.validateOutputTextPart = validateOutputTextPart;
|
|
5010
|
+
exports.validateOutreachVisitList = validateOutreachVisitList;
|
|
5011
|
+
exports.validateOutreachVisitListQuery = validateOutreachVisitListQuery;
|
|
5012
|
+
exports.validateOutreachVisitRequest = validateOutreachVisitRequest;
|
|
4769
5013
|
exports.validatePatchPersonalApplicationLimitRequest = validatePatchPersonalApplicationLimitRequest;
|
|
4770
5014
|
exports.validatePatchPersonalSettingsRequest = validatePatchPersonalSettingsRequest;
|
|
4771
5015
|
exports.validatePaymentMethodSetupResponse = validatePaymentMethodSetupResponse;
|