@aranova/tracking-react 1.16.1 → 1.18.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/README.md +16 -0
- package/dist/{bookings-CkfA5XOM.d.ts → bookings-CCGpXhYE.d.ts} +52 -5
- package/dist/{bookings-DFz3BUiP.d.mts → bookings-CVvpj_8K.d.mts} +52 -5
- package/dist/client.d.mts +4 -4
- package/dist/client.d.ts +4 -4
- package/dist/client.js +274 -189
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +274 -189
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +60 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -36
- package/dist/index.mjs.map +1 -1
- package/dist/{ingest-typed-BO6Arbw-.d.mts → ingest-typed-C3XAjHlH.d.ts} +92 -2
- package/dist/{ingest-typed-D7I4aQ7p.d.ts → ingest-typed-CoCjTqJs.d.mts} +92 -2
- package/dist/{phone-utils-CYr6AmEP.d.mts → phone-utils-BlWj8oxq.d.mts} +1 -0
- package/dist/{phone-utils-CYr6AmEP.d.ts → phone-utils-BlWj8oxq.d.ts} +1 -0
- package/dist/phone.d.mts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/{sales-J_ItVjgE.d.mts → sales-B1ONR-Yi.d.mts} +1 -1
- package/dist/{sales-DGSi7IqU.d.ts → sales-Dlc_umAV.d.ts} +1 -1
- package/dist/sales.d.mts +3 -3
- package/dist/sales.d.ts +3 -3
- package/dist/sales.js +51 -35
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +51 -35
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
package/dist/sales.mjs
CHANGED
|
@@ -230,7 +230,6 @@ var jsonValueSchema = z.lazy(
|
|
|
230
230
|
])
|
|
231
231
|
).register(z.globalRegistry, { id: "JsonSerializableValue" });
|
|
232
232
|
var contractNameSchema = z.string().check(z.regex(/^[a-z][a-z0-9_]{0,47}(:[a-z0-9_-]{1,48})?$/));
|
|
233
|
-
var contractName = contractNameSchema;
|
|
234
233
|
var violationRole = z.string().check(
|
|
235
234
|
z.maxLength(200),
|
|
236
235
|
z.regex(
|
|
@@ -242,38 +241,41 @@ var contractViolationSchema = z.strictObject({
|
|
|
242
241
|
role: z.nullable(violationRole),
|
|
243
242
|
rule: z.string().check(z.regex(/^[a-z][a-z_]{0,47}$/))
|
|
244
243
|
});
|
|
244
|
+
var formFieldSchema = z.strictObject({
|
|
245
|
+
name: z.string(),
|
|
246
|
+
type: z.string(),
|
|
247
|
+
label: z.nullable(z.string()),
|
|
248
|
+
value: jsonValueSchema,
|
|
249
|
+
role: z.optional(z.nullable(contractNameSchema))
|
|
250
|
+
});
|
|
251
|
+
var formExtraSchema = z.optional(
|
|
252
|
+
z.nullable(
|
|
253
|
+
z.array(
|
|
254
|
+
z.strictObject({
|
|
255
|
+
key: z.string().check(z.maxLength(64)),
|
|
256
|
+
label: z.string().check(z.maxLength(200)),
|
|
257
|
+
value: jsonValueSchema
|
|
258
|
+
})
|
|
259
|
+
).check(z.maxLength(20))
|
|
260
|
+
)
|
|
261
|
+
);
|
|
262
|
+
var contractVersionSchema = z.optional(z.nullable(z.int().check(z.gte(1))));
|
|
263
|
+
var contractHashSchema = z.optional(z.nullable(z.string().check(z.maxLength(64))));
|
|
264
|
+
var formContractViolationsSchema = z.optional(
|
|
265
|
+
z.nullable(z.array(contractViolationSchema).check(z.maxLength(MAX_CONTRACT_VIOLATIONS)))
|
|
266
|
+
);
|
|
245
267
|
var formSubmitMetadataSchema = z.strictObject({
|
|
246
268
|
form: z.strictObject({
|
|
247
269
|
id: z.string(),
|
|
248
270
|
action: z.nullable(z.string()),
|
|
249
|
-
fields: z.optional(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
})
|
|
258
|
-
)
|
|
259
|
-
),
|
|
260
|
-
kind: z.optional(z.nullable(contractName)),
|
|
261
|
-
contract_version: z.optional(z.nullable(z.int().check(z.gte(1)))),
|
|
262
|
-
contract_hash: z.optional(z.nullable(z.string().check(z.maxLength(64)))),
|
|
263
|
-
extra: z.optional(
|
|
264
|
-
z.nullable(
|
|
265
|
-
z.array(
|
|
266
|
-
z.strictObject({
|
|
267
|
-
key: z.string().check(z.maxLength(64)),
|
|
268
|
-
label: z.string().check(z.maxLength(200)),
|
|
269
|
-
value: jsonValueSchema
|
|
270
|
-
})
|
|
271
|
-
).check(z.maxLength(20))
|
|
272
|
-
)
|
|
273
|
-
),
|
|
274
|
-
contract_violations: z.optional(
|
|
275
|
-
z.nullable(z.array(contractViolationSchema).check(z.maxLength(MAX_CONTRACT_VIOLATIONS)))
|
|
276
|
-
)
|
|
271
|
+
fields: z.optional(z.array(formFieldSchema)),
|
|
272
|
+
kind: z.optional(z.nullable(contractNameSchema)),
|
|
273
|
+
contract_version: contractVersionSchema,
|
|
274
|
+
contract_hash: contractHashSchema,
|
|
275
|
+
extra: formExtraSchema,
|
|
276
|
+
contract_violations: formContractViolationsSchema,
|
|
277
|
+
// Minted per submit; a later `form_details` names it to add answers to this lead.
|
|
278
|
+
submission_id: z.optional(z.nullable(z.uuidv4()))
|
|
277
279
|
}),
|
|
278
280
|
page: z.strictObject({
|
|
279
281
|
path: z.string()
|
|
@@ -325,7 +327,8 @@ function camelRules(rules) {
|
|
|
325
327
|
specialHours: rules.special_hours,
|
|
326
328
|
vehicleRequired: rules.vehicle_required,
|
|
327
329
|
vehicleDeferred: rules.vehicle_deferred,
|
|
328
|
-
dropOffOptions: rules.drop_off_options
|
|
330
|
+
dropOffOptions: rules.drop_off_options,
|
|
331
|
+
bookedCounts: rules.booked_counts ?? {}
|
|
329
332
|
};
|
|
330
333
|
}
|
|
331
334
|
function buildBookingHandoffUrl(fallbackUrl, prefill = {}) {
|
|
@@ -587,9 +590,18 @@ function parseBookingRules(value) {
|
|
|
587
590
|
special_hours: parseWindowsMap(r.special_hours),
|
|
588
591
|
vehicle_required: r.vehicle_required === true,
|
|
589
592
|
vehicle_deferred: r.vehicle_deferred === true,
|
|
590
|
-
drop_off_options: isStringList(r.drop_off_options) ? r.drop_off_options : []
|
|
593
|
+
drop_off_options: isStringList(r.drop_off_options) ? r.drop_off_options : [],
|
|
594
|
+
booked_counts: parseCounts(r.booked_counts)
|
|
591
595
|
};
|
|
592
596
|
}
|
|
597
|
+
function parseCounts(value) {
|
|
598
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
599
|
+
const counts = {};
|
|
600
|
+
for (const [date, count] of Object.entries(value)) {
|
|
601
|
+
if (typeof count === "number" && Number.isInteger(count) && count >= 0) counts[date] = count;
|
|
602
|
+
}
|
|
603
|
+
return counts;
|
|
604
|
+
}
|
|
593
605
|
function parseBookingOption(value) {
|
|
594
606
|
if (!value || typeof value !== "object") return [];
|
|
595
607
|
const o = value;
|
|
@@ -1277,10 +1289,10 @@ var KNOWN_ROLES = new Set(LEAD_FORM_ROLES);
|
|
|
1277
1289
|
var ROLE_ORDER = new Map(LEAD_FORM_ROLES.map((role, index) => [role, index]));
|
|
1278
1290
|
var ADD_ON = /^add_on:[a-z0-9_-]{1,48}$/;
|
|
1279
1291
|
var CONTRACT_NAME = /^[a-z][a-z0-9_]{0,47}(:[a-z0-9_-]{1,48})?$/;
|
|
1280
|
-
function judgeLeadForm(kind, formId, fields, contracts, settings) {
|
|
1292
|
+
function judgeLeadForm(kind, formId, fields, contracts, settings, { partial = false } = {}) {
|
|
1281
1293
|
const generated = contracts?.contracts[kind];
|
|
1282
1294
|
const live = liveContract(settings.trackingConfig, kind);
|
|
1283
|
-
const violations = check(live === void 0 ? generated : fromLive(live), fields);
|
|
1295
|
+
const violations = check(live === void 0 ? generated : fromLive(live), fields, partial);
|
|
1284
1296
|
const liveHash = live === void 0 ? void 0 : live?.contract_hash ?? null;
|
|
1285
1297
|
if (contracts && (liveHash !== void 0 && (generated?.hash ?? null) !== liveHash || contracts.registryVersion !== LEAD_FORM_REGISTRY_VERSION)) {
|
|
1286
1298
|
violations.push({ role: null, rule: "contract_behind" });
|
|
@@ -1312,7 +1324,7 @@ function fromLive(live) {
|
|
|
1312
1324
|
options: Object.fromEntries(live.options.map((o) => [o.role, o.options.map((x) => x.key)]))
|
|
1313
1325
|
};
|
|
1314
1326
|
}
|
|
1315
|
-
function check(contract, fields) {
|
|
1327
|
+
function check(contract, fields, partial) {
|
|
1316
1328
|
const answered = new Map(fields);
|
|
1317
1329
|
const violations = [];
|
|
1318
1330
|
for (const [role, value] of fields) {
|
|
@@ -1330,6 +1342,7 @@ function check(contract, fields) {
|
|
|
1330
1342
|
violations.push({ role, rule: "unknown_option" });
|
|
1331
1343
|
}
|
|
1332
1344
|
}
|
|
1345
|
+
if (partial) return violations;
|
|
1333
1346
|
for (const { role, requiredWhen } of contract?.requires ?? []) {
|
|
1334
1347
|
const owing = requiredWhen === null || optionKeys(answered.get(requiredWhen.role)).some((key) => requiredWhen.anyOf.includes(key));
|
|
1335
1348
|
if (owing && !answered.has(role)) violations.push({ role, rule: "missing_required" });
|
|
@@ -1993,12 +2006,15 @@ var zSmsWithheldReason = z4.enum([
|
|
|
1993
2006
|
"test_or_bot_session",
|
|
1994
2007
|
"invalid_phone",
|
|
1995
2008
|
"recently_texted",
|
|
2009
|
+
"owner_not_alerted",
|
|
2010
|
+
"no_new_details",
|
|
1996
2011
|
"do_not_contact",
|
|
1997
2012
|
"do_not_text_tag",
|
|
1998
2013
|
"missing_value",
|
|
1999
2014
|
"us_texting_pending",
|
|
2000
2015
|
"us_texting_rejected",
|
|
2001
|
-
"texts_paused"
|
|
2016
|
+
"texts_paused",
|
|
2017
|
+
"outside_nanp"
|
|
2002
2018
|
]);
|
|
2003
2019
|
var zSaleSmsStatusSchema = z4.object({
|
|
2004
2020
|
can_send_now: z4._default(z4.boolean(), false),
|