@modainteract/moda-interact-shared 5.6.0 → 5.7.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/{chunk-QVPEX7KY.js → chunk-GCCT2BDE.js} +4 -4
- package/dist/chunk-QFUK7FIO.js +16 -0
- package/dist/chunk-QFUK7FIO.js.map +1 -0
- package/dist/{chunk-S42O2OCG.js → chunk-WF2BDUPZ.js} +428 -320
- package/dist/chunk-WF2BDUPZ.js.map +1 -0
- package/dist/chunk-WHZAAF2Q.js +25 -0
- package/dist/chunk-WHZAAF2Q.js.map +1 -0
- package/dist/{chunk-KIHGDO35.js → chunk-WK7QSBHJ.js} +3 -3
- package/dist/commerce/index.d.ts +33 -5
- package/dist/commerce/index.js +17 -16
- package/dist/commerce/index.js.map +1 -1
- package/dist/commerce/model/node.d.ts +3 -3
- package/dist/commerce/model/node.js +3 -3
- package/dist/commerce/outreach/index.d.ts +1094 -0
- package/dist/commerce/outreach/index.js +1355 -0
- package/dist/commerce/outreach/index.js.map +1 -0
- package/dist/commerce/presentation/index.d.ts +103 -6
- package/dist/commerce/presentation/index.js +80 -13
- package/dist/commerce/presentation/index.js.map +1 -1
- package/dist/commerce/runner/index.d.ts +4 -4
- package/dist/commerce/runner/index.js +12 -28
- package/dist/commerce/runner/index.js.map +1 -1
- package/dist/{product-context-D3FuI6ah.d.ts → product-context-Bh74WGOo.d.ts} +1 -1
- package/dist/recovery-offer-proof.js +2 -2
- package/dist/{response-Cs4zC3d3.d.ts → response-DFDEw4K0.d.ts} +115 -1
- package/dist/{types-ByoKuP90.d.ts → types-vIMrj5J4.d.ts} +2 -2
- package/package.json +12 -6
- package/dist/chunk-S42O2OCG.js.map +0 -1
- /package/dist/{chunk-QVPEX7KY.js.map → chunk-GCCT2BDE.js.map} +0 -0
- /package/dist/{chunk-KIHGDO35.js.map → chunk-WK7QSBHJ.js.map} +0 -0
|
@@ -8,18 +8,119 @@ import {
|
|
|
8
8
|
SemverSchema,
|
|
9
9
|
boundedJson,
|
|
10
10
|
distinct
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GCCT2BDE.js";
|
|
12
|
+
import {
|
|
13
|
+
canonicaliseLanguageTag
|
|
14
|
+
} from "./chunk-4KSODB2R.js";
|
|
12
15
|
import {
|
|
13
16
|
canonicalJson,
|
|
14
17
|
jsonBytes,
|
|
15
18
|
responseContractCanonicalJson
|
|
16
19
|
} from "./chunk-AUS3WQIW.js";
|
|
17
|
-
import {
|
|
18
|
-
canonicaliseLanguageTag
|
|
19
|
-
} from "./chunk-4KSODB2R.js";
|
|
20
20
|
|
|
21
|
-
// src/commerce/
|
|
21
|
+
// src/commerce/product-facts.ts
|
|
22
22
|
import { z } from "zod";
|
|
23
|
+
import { parseFragment } from "parse5";
|
|
24
|
+
var codePoints = (value) => Array.from(value).length;
|
|
25
|
+
var controls = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/u;
|
|
26
|
+
var label = z.string().min(1).refine((value) => codePoints(value) <= 128 && value === value.trim() && !/[\r\n\t]/u.test(value) && !controls.test(value));
|
|
27
|
+
var status = z.enum(["AVAILABLE", "NOT_PROVIDED", "PARTIAL"]);
|
|
28
|
+
var CommerceProductDescriptionSchema = z.strictObject({ status, text: z.string().refine((value) => codePoints(value) <= 4096 && !controls.test(value)) }).refine((value) => (value.status !== "NOT_PROVIDED" || value.text === "") && (value.status !== "AVAILABLE" || value.text.trim().length > 0));
|
|
29
|
+
var CommerceProductAttributesSchema = z.strictObject({ status, items: z.array(z.strictObject({ name: label, values: z.array(label).max(64) })).max(16) }).refine((value) => (value.status !== "NOT_PROVIDED" || value.items.length === 0) && (value.status !== "AVAILABLE" || value.items.length > 0)).refine((value) => new Set(value.items.map((item) => item.name)).size === value.items.length && value.items.every((item) => new Set(item.values).size === item.values.length));
|
|
30
|
+
function normalizeCommerceProductDescription(source, format) {
|
|
31
|
+
if (source === null || source === void 0 || source === "") return { status: "NOT_PROVIDED", text: "" };
|
|
32
|
+
if (typeof source !== "string" || !["PLAIN_TEXT", "HTML"].includes(format)) return { status: "PARTIAL", text: "" };
|
|
33
|
+
if (new TextEncoder().encode(source).length > 65536) return { status: "PARTIAL", text: "" };
|
|
34
|
+
let partial = controls.test(source);
|
|
35
|
+
let text = source;
|
|
36
|
+
if (format === "HTML") {
|
|
37
|
+
const lines = [];
|
|
38
|
+
const boundaries = /* @__PURE__ */ new Set(["br", "p", "div", "li", "ul", "ol", "h1", "h2", "h3", "h4", "h5", "h6", "table", "tr"]);
|
|
39
|
+
const skip = /* @__PURE__ */ new Set(["script", "style", "template", "noscript"]);
|
|
40
|
+
const walk = (node) => {
|
|
41
|
+
if ("tagName" in node && skip.has(node.tagName)) return;
|
|
42
|
+
const boundary = "tagName" in node && boundaries.has(node.tagName);
|
|
43
|
+
if (boundary) lines.push("\n");
|
|
44
|
+
if (node.nodeName === "#text" && "value" in node) lines.push(node.value);
|
|
45
|
+
if ("childNodes" in node) for (const child of node.childNodes) walk(child);
|
|
46
|
+
if (boundary && !("tagName" in node && node.tagName === "br")) lines.push("\n");
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
walk(parseFragment(source, { onParseError: () => {
|
|
50
|
+
partial = true;
|
|
51
|
+
} }));
|
|
52
|
+
text = lines.join("");
|
|
53
|
+
} catch {
|
|
54
|
+
return { status: "PARTIAL", text: "" };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
partial ||= controls.test(text);
|
|
58
|
+
text = text.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/gu, "").replace(/\r\n?/gu, "\n").replace(/[^\S\n]+/gu, " ").replace(/\n{3,}/gu, "\n\n").trim();
|
|
59
|
+
if (codePoints(text) > 4096) {
|
|
60
|
+
text = Array.from(text).slice(0, 4096).join("");
|
|
61
|
+
partial = true;
|
|
62
|
+
}
|
|
63
|
+
return { status: partial ? "PARTIAL" : text ? "AVAILABLE" : "NOT_PROVIDED", text };
|
|
64
|
+
}
|
|
65
|
+
function normalizeCommerceProductAttributes(source) {
|
|
66
|
+
if (source === void 0 || source === null) return { status: "NOT_PROVIDED", items: [] };
|
|
67
|
+
const canonical = source && typeof source === "object" && !Array.isArray(source) ? source : null;
|
|
68
|
+
const rows = canonical ? canonical.items : source;
|
|
69
|
+
if (!Array.isArray(rows)) return { status: "PARTIAL", items: [] };
|
|
70
|
+
let partial = !!canonical && (!["AVAILABLE", "NOT_PROVIDED"].includes(String(canonical.status)) || canonical.status === "NOT_PROVIDED" && rows.length > 0);
|
|
71
|
+
const items = [];
|
|
72
|
+
const clean = (raw) => {
|
|
73
|
+
if (typeof raw !== "string" || controls.test(raw)) return null;
|
|
74
|
+
const value = raw.replace(/[\r\n\t]/gu, " ").replace(/\s+/gu, " ").trim();
|
|
75
|
+
return value && codePoints(value) <= 128 ? value : null;
|
|
76
|
+
};
|
|
77
|
+
for (const raw of rows) {
|
|
78
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
79
|
+
partial = true;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const row = raw;
|
|
83
|
+
const name = clean(row.name);
|
|
84
|
+
if (!name || !Array.isArray(row.values)) {
|
|
85
|
+
partial = true;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
let item = items.find((value) => value.name === name);
|
|
89
|
+
if (!item) {
|
|
90
|
+
if (items.length >= 16) {
|
|
91
|
+
partial = true;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
item = { name, values: [] };
|
|
95
|
+
items.push(item);
|
|
96
|
+
}
|
|
97
|
+
for (const rawValue of row.values) {
|
|
98
|
+
const value = clean(rawValue);
|
|
99
|
+
if (!value) {
|
|
100
|
+
partial = true;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (item.values.includes(value)) continue;
|
|
104
|
+
if (item.values.length >= 64) {
|
|
105
|
+
partial = true;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
item.values.push(value);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return { status: partial ? "PARTIAL" : items.length ? "AVAILABLE" : "NOT_PROVIDED", items };
|
|
112
|
+
}
|
|
113
|
+
function normalizeCommerceProductDescriptionField(source) {
|
|
114
|
+
if (!source || typeof source !== "object" || Array.isArray(source)) return { status: "PARTIAL", text: "" };
|
|
115
|
+
const value = source;
|
|
116
|
+
if (typeof value.text !== "string") return { status: "PARTIAL", text: "" };
|
|
117
|
+
const normalized = normalizeCommerceProductDescription(value.text, "PLAIN_TEXT");
|
|
118
|
+
if (!status.safeParse(value.status).success || value.status === "PARTIAL" || value.status === "NOT_PROVIDED" && normalized.text) normalized.status = "PARTIAL";
|
|
119
|
+
return normalized;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/commerce/subset.ts
|
|
123
|
+
import { z as z2 } from "zod";
|
|
23
124
|
var MONEY_PATTERN = "^[0-9]{1,18}(\\.[0-9]{1,6})?$";
|
|
24
125
|
var safeName = (name) => /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) && !["__proto__", "prototype", "constructor"].includes(name);
|
|
25
126
|
var safePath = (path) => path.length <= 256 && path.split(".").every(safeName);
|
|
@@ -119,10 +220,10 @@ function validateSubset(value, mode) {
|
|
|
119
220
|
return false;
|
|
120
221
|
}
|
|
121
222
|
}
|
|
122
|
-
var InputSchemaSchema =
|
|
223
|
+
var InputSchemaSchema = z2.custom(
|
|
123
224
|
(v) => validateSubset(v, "input")
|
|
124
225
|
);
|
|
125
|
-
var DetailsSchemaSchema =
|
|
226
|
+
var DetailsSchemaSchema = z2.custom(
|
|
126
227
|
(v) => validateSubset(v, "details")
|
|
127
228
|
);
|
|
128
229
|
function matchesSubset(schema, value) {
|
|
@@ -146,7 +247,7 @@ function matchesSubset(schema, value) {
|
|
|
146
247
|
}
|
|
147
248
|
function compileSubset(schema, mode) {
|
|
148
249
|
if (!validateSubset(schema, mode)) throw new TypeError("Unsupported schema");
|
|
149
|
-
return
|
|
250
|
+
return z2.custom((value) => {
|
|
150
251
|
try {
|
|
151
252
|
return jsonBytes(value) <= (mode === "details" ? 16384 : 131072) && matchesSubset(schema, value);
|
|
152
253
|
} catch {
|
|
@@ -156,7 +257,7 @@ function compileSubset(schema, mode) {
|
|
|
156
257
|
}
|
|
157
258
|
|
|
158
259
|
// src/commerce/purpose-output.ts
|
|
159
|
-
import { z as
|
|
260
|
+
import { z as z3 } from "zod";
|
|
160
261
|
var CANONICAL_PATTERNS = [
|
|
161
262
|
"^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\\.[0-9]+)?Z(?![\\s\\S])",
|
|
162
263
|
"^[0-9]{1,18}(\\.[0-9]{1,6})?$",
|
|
@@ -223,7 +324,7 @@ function validateCommercePurposeOutputSchema(value) {
|
|
|
223
324
|
return false;
|
|
224
325
|
}
|
|
225
326
|
}
|
|
226
|
-
var CommercePurposeOutputSchemaSchema =
|
|
327
|
+
var CommercePurposeOutputSchemaSchema = z3.custom(validateCommercePurposeOutputSchema);
|
|
227
328
|
function matches(schema, value) {
|
|
228
329
|
if (schema.anyOf) return schema.anyOf.some((branch) => matches(branch, value));
|
|
229
330
|
const nullable = Array.isArray(schema.type);
|
|
@@ -254,7 +355,7 @@ function matches(schema, value) {
|
|
|
254
355
|
function compileCommercePurposeOutputSchema(raw) {
|
|
255
356
|
if (!validateCommercePurposeOutputSchema(raw)) throw new TypeError("Unsupported purpose output schema");
|
|
256
357
|
const snapshot = structuredClone(raw);
|
|
257
|
-
return
|
|
358
|
+
return z3.custom((value) => {
|
|
258
359
|
try {
|
|
259
360
|
return jsonBytes(value) <= 32768 && matches(snapshot, value);
|
|
260
361
|
} catch {
|
|
@@ -264,39 +365,39 @@ function compileCommercePurposeOutputSchema(raw) {
|
|
|
264
365
|
}
|
|
265
366
|
|
|
266
367
|
// src/commerce/external.ts
|
|
267
|
-
import { z as
|
|
368
|
+
import { z as z4 } from "zod";
|
|
268
369
|
var utf8 = (value, maximum) => new TextEncoder().encode(value).length <= maximum;
|
|
269
|
-
var scalar =
|
|
370
|
+
var scalar = z4.union([z4.string().refine((value) => utf8(value, 2048)), z4.number().finite(), z4.boolean()]);
|
|
270
371
|
var ExternalQueryValueSchema = scalar;
|
|
271
|
-
var scalarOrNull =
|
|
272
|
-
var record2 = (item, max) =>
|
|
273
|
-
var ExternalQueryMappingSchema =
|
|
274
|
-
|
|
275
|
-
|
|
372
|
+
var scalarOrNull = z4.union([scalar, z4.null()]);
|
|
373
|
+
var record2 = (item, max) => z4.record(z4.string().refine(safeName), item).refine((value) => Object.keys(value).length <= max);
|
|
374
|
+
var ExternalQueryMappingSchema = z4.union([
|
|
375
|
+
z4.strictObject({ input: z4.string().refine(safeName), omitIfMissing: z4.literal(true).optional() }),
|
|
376
|
+
z4.strictObject({ literal: scalar })
|
|
276
377
|
]);
|
|
277
378
|
var ExternalQueryMappingsSchema = record2(ExternalQueryMappingSchema, 32).superRefine((value, ctx) => {
|
|
278
379
|
const reserved = /^(authorization|cookie|set-cookie|host|x-api-key|api_key|apikey|access_token|token|secret|password)$/i;
|
|
279
380
|
for (const key of Object.keys(value)) if (reserved.test(key)) ctx.addIssue({ code: "custom", path: [key], message: "Reserved query key" });
|
|
280
381
|
});
|
|
281
|
-
var ExternalPathSchema =
|
|
382
|
+
var ExternalPathSchema = z4.string().max(1024).refine(
|
|
282
383
|
(value) => utf8(value, 1024) && /^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]*\/?$/.test(value) && !value.includes("//") && !value.includes("%") && !value.includes("\\") && !value.includes("?") && !value.includes("#") && !value.includes("{") && !value.includes("}") && value.split("/").every((segment) => segment !== "." && segment !== "..")
|
|
283
384
|
);
|
|
284
|
-
var mediaType =
|
|
385
|
+
var mediaType = z4.string().min(1).max(128).refine((value) => value === value.toLowerCase() && /^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/.test(value));
|
|
285
386
|
var jsonMime = (value) => value === "application/json" || /^application\/[a-z0-9!#$&^_.+-]+\+json$/.test(value);
|
|
286
387
|
var textMime = (value) => /^text\/[a-z0-9!#$&^_.+-]+$/.test(value) || value === "application/xml" || /^application\/[a-z0-9!#$&^_.+-]+\+xml$/.test(value) || jsonMime(value);
|
|
287
|
-
var ExternalResponseFormatSchema =
|
|
288
|
-
var FieldProjectionSchema = record2(
|
|
289
|
-
var ResponseFilterSchema =
|
|
290
|
-
|
|
291
|
-
|
|
388
|
+
var ExternalResponseFormatSchema = z4.strictObject({ mode: z4.enum(["JSON", "TEXT"]), mediaTypes: z4.array(mediaType).min(1).max(8).refine((values) => new Set(values).size === values.length) }).refine((value) => value.mediaTypes.every(value.mode === "JSON" ? jsonMime : textMime));
|
|
389
|
+
var FieldProjectionSchema = record2(z4.strictObject({ path: z4.string().refine(safePath), omitIfMissing: z4.literal(true).optional() }), 32).refine((value) => Object.keys(value).length >= 1);
|
|
390
|
+
var ResponseFilterSchema = z4.discriminatedUnion("op", [
|
|
391
|
+
z4.strictObject({ path: z4.string().refine(safePath), op: z4.enum(["EQ", "NE", "GT", "GTE", "LT", "LTE", "CONTAINS", "STARTS_WITH"]), value: scalarOrNull }),
|
|
392
|
+
z4.strictObject({ path: z4.string().refine(safePath), op: z4.literal("IN"), values: z4.array(scalarOrNull).min(1).max(20) })
|
|
292
393
|
]);
|
|
293
|
-
var visualObject =
|
|
294
|
-
var visualList =
|
|
295
|
-
var VisualResponseProcessingSchema =
|
|
296
|
-
var ResponseProcessingSchema =
|
|
297
|
-
var TransformResponseSchema =
|
|
298
|
-
var TransformSampleSchema =
|
|
299
|
-
var boundedValues =
|
|
394
|
+
var visualObject = z4.strictObject({ kind: z4.literal("OBJECT"), fields: FieldProjectionSchema });
|
|
395
|
+
var visualList = z4.strictObject({ kind: z4.literal("LIST"), fields: FieldProjectionSchema, filters: z4.array(ResponseFilterSchema).max(8), sort: z4.union([z4.null(), z4.strictObject({ path: z4.string().refine(safePath), direction: z4.enum(["ASC", "DESC"]) })]), limit: z4.int().min(1).max(20) });
|
|
396
|
+
var VisualResponseProcessingSchema = z4.union([visualObject, visualList]);
|
|
397
|
+
var ResponseProcessingSchema = z4.union([VisualResponseProcessingSchema, z4.strictObject({ kind: z4.literal("JAVASCRIPT"), runtimeVersion: z4.literal("quickjs-sync.v1"), source: z4.string().min(1).refine((value) => utf8(value, 16384)) })]);
|
|
398
|
+
var TransformResponseSchema = z4.strictObject({ status: z4.int().min(200).max(299), contentType: z4.string().min(1).max(128), bodyText: z4.string().refine((value) => utf8(value, 262144)), json: z4.union([z4.null(), z4.json()]) });
|
|
399
|
+
var TransformSampleSchema = z4.strictObject({ status: z4.int().min(200).max(299), contentType: z4.string().min(1).max(128), bodyText: z4.string().refine((value) => utf8(value, 262144)) }).refine((value) => jsonBytes(value) <= 524288);
|
|
400
|
+
var boundedValues = z4.custom((value) => {
|
|
300
401
|
const visit = (node, depth) => depth <= 20 && (node === null || typeof node === "string" || typeof node === "boolean" || typeof node === "number" && Number.isFinite(node) || Array.isArray(node) && node.every((child) => visit(child, depth + 1)) || !!node && typeof node === "object" && !Array.isArray(node) && Object.getPrototypeOf(node) === Object.prototype && Object.entries(node).every(([key, child]) => !["__proto__", "prototype", "constructor"].includes(key) && visit(child, depth + 1)));
|
|
301
402
|
try {
|
|
302
403
|
return !!value && typeof value === "object" && !Array.isArray(value) && visit(value, 1) && jsonBytes(value) <= 49152;
|
|
@@ -304,24 +405,24 @@ var boundedValues = z3.custom((value) => {
|
|
|
304
405
|
return false;
|
|
305
406
|
}
|
|
306
407
|
});
|
|
307
|
-
var ExternalHttpResultDataSchema =
|
|
308
|
-
var ConnectionRevisionViewSchema =
|
|
309
|
-
var ConnectionViewSchema =
|
|
310
|
-
var CredentialStatusSchema =
|
|
311
|
-
var ConnectionCommandSchema =
|
|
312
|
-
var RevisionInputSchema =
|
|
313
|
-
var ConnectionIssueSchema =
|
|
314
|
-
var ConnectionResultSchema = (value) =>
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
408
|
+
var ExternalHttpResultDataSchema = z4.strictObject({ source: z4.literal("EXTERNAL_HTTP"), connectionRevisionId: IdSchema, observedAt: DateSchema, values: boundedValues });
|
|
409
|
+
var ConnectionRevisionViewSchema = z4.strictObject({ id: IdSchema, connectionId: IdSchema, revisionNumber: z4.int().positive(), origin: z4.string().min(1).max(2048), scope: z4.enum(["PLATFORM", "PER_SHOP"]), authMode: z4.enum(["NONE", "BEARER", "API_KEY"]), authHeader: z4.string().min(1).max(128).nullable(), documentation: z4.string().max(16e3), createdAt: z4.iso.datetime({ offset: false }) });
|
|
410
|
+
var ConnectionViewSchema = z4.strictObject({ id: IdSchema, key: z4.string().regex(/^[a-z][a-z0-9_]{0,127}$/), displayName: z4.string().min(1).max(255), description: z4.string().max(4096), enabled: z4.boolean(), editVersion: z4.int().positive(), revisions: z4.array(ConnectionRevisionViewSchema) });
|
|
411
|
+
var CredentialStatusSchema = z4.strictObject({ connectionRevisionId: IdSchema, shopId: IdSchema.nullable(), configured: z4.boolean(), editVersion: z4.int().positive().nullable(), updatedAt: z4.iso.datetime({ offset: false }).nullable() });
|
|
412
|
+
var ConnectionCommandSchema = z4.strictObject({ operationId: IdSchema, reason: z4.string().trim().min(1).max(1e3) });
|
|
413
|
+
var RevisionInputSchema = z4.strictObject({ origin: z4.string().min(1).max(2048), scope: z4.enum(["PLATFORM", "PER_SHOP"]), authMode: z4.enum(["NONE", "BEARER", "API_KEY"]), authHeader: z4.string().min(1).max(128).nullable(), documentation: z4.string().max(16e3) });
|
|
414
|
+
var ConnectionIssueSchema = z4.strictObject({ path: z4.string().max(256), message: z4.string().min(1).max(512) });
|
|
415
|
+
var ConnectionResultSchema = (value) => z4.discriminatedUnion("kind", [
|
|
416
|
+
z4.strictObject({ kind: z4.literal("ok"), value }),
|
|
417
|
+
z4.strictObject({ kind: z4.literal("not-found") }),
|
|
418
|
+
z4.strictObject({ kind: z4.literal("forbidden") }),
|
|
419
|
+
z4.strictObject({ kind: z4.literal("unavailable") }),
|
|
420
|
+
z4.strictObject({ kind: z4.literal("invalid"), issues: z4.array(ConnectionIssueSchema).max(32) }),
|
|
421
|
+
z4.strictObject({ kind: z4.literal("conflict"), code: z4.enum(["STALE_CAS", "CONFLICTING_REPLAY"]) })
|
|
321
422
|
]);
|
|
322
423
|
|
|
323
424
|
// src/commerce/definitions.ts
|
|
324
|
-
import { z as
|
|
425
|
+
import { z as z5 } from "zod";
|
|
325
426
|
import { gt } from "semver";
|
|
326
427
|
|
|
327
428
|
// src/commerce/definition-size.ts
|
|
@@ -362,19 +463,19 @@ var definitionFitsStorage = (value) => {
|
|
|
362
463
|
var DEFINITION_SIZE_MESSAGE = "Definition exceeds the 65536-byte jsonb text limit";
|
|
363
464
|
|
|
364
465
|
// src/commerce/definitions.ts
|
|
365
|
-
var ToolNameSchema =
|
|
366
|
-
var CommerceExecutionPurposeSchema =
|
|
367
|
-
var CommercePurposeProfileSchema =
|
|
466
|
+
var ToolNameSchema = z5.string().regex(/^[a-z][a-z0-9_]{0,127}$/).refine((n) => n !== "finalResponse");
|
|
467
|
+
var CommerceExecutionPurposeSchema = z5.literal("INITIAL_RECOVERY_OUTREACH");
|
|
468
|
+
var CommercePurposeProfileSchema = z5.strictObject({
|
|
368
469
|
purpose: CommerceExecutionPurposeSchema,
|
|
369
470
|
featureId: IdSchema,
|
|
370
471
|
releaseId: IdSchema,
|
|
371
|
-
behaviourPrompt:
|
|
372
|
-
capabilities:
|
|
472
|
+
behaviourPrompt: z5.string().refine((value) => new TextEncoder().encode(value).length <= 32768),
|
|
473
|
+
capabilities: z5.array(z5.strictObject({
|
|
373
474
|
capabilityId: IdSchema,
|
|
374
475
|
toolId: IdSchema,
|
|
375
476
|
revisionId: IdSchema,
|
|
376
477
|
name: ToolNameSchema,
|
|
377
|
-
position:
|
|
478
|
+
position: z5.number().int().nonnegative(),
|
|
378
479
|
inputSchema: InputSchemaSchema,
|
|
379
480
|
outputSchema: CommercePurposeOutputSchemaSchema
|
|
380
481
|
})).min(1, { message: "PROFILE_EMPTY" }).max(32)
|
|
@@ -396,52 +497,52 @@ var CommercePurposeProfileSchema = z4.strictObject({
|
|
|
396
497
|
function requireCommercePurposeProfile(raw) {
|
|
397
498
|
return CommercePurposeProfileSchema.parse(raw);
|
|
398
499
|
}
|
|
399
|
-
var PublishedGrantedToolSchema =
|
|
500
|
+
var PublishedGrantedToolSchema = z5.strictObject({
|
|
400
501
|
toolId: IdSchema,
|
|
401
502
|
toolRevisionId: IdSchema,
|
|
402
503
|
toolName: ToolNameSchema,
|
|
403
504
|
definitionVersion: SemverSchema,
|
|
404
|
-
capabilityKeys:
|
|
505
|
+
capabilityKeys: z5.array(IdSchema).min(1).max(32).refine((v) => distinct(v) && v.join("\0") === [...v].sort().join("\0"))
|
|
405
506
|
});
|
|
406
|
-
var PublishedToolDescriptorSchema =
|
|
507
|
+
var PublishedToolDescriptorSchema = z5.strictObject({
|
|
407
508
|
toolId: IdSchema,
|
|
408
509
|
toolRevisionId: IdSchema,
|
|
409
510
|
name: ToolNameSchema,
|
|
410
511
|
definitionVersion: SemverSchema,
|
|
411
|
-
description:
|
|
512
|
+
description: z5.string().min(1).max(4096),
|
|
412
513
|
inputSchema: InputSchemaSchema
|
|
413
514
|
});
|
|
414
|
-
var CommerceBuiltInToolNameSchema =
|
|
515
|
+
var CommerceBuiltInToolNameSchema = z5.enum([
|
|
415
516
|
"commerce_get_discount_options",
|
|
416
517
|
"commerce_get_discount_details"
|
|
417
518
|
]).meta({ maxLength: 29 });
|
|
418
|
-
var CommerceBuiltInToolGrantSchema =
|
|
419
|
-
kind:
|
|
519
|
+
var CommerceBuiltInToolGrantSchema = z5.strictObject({
|
|
520
|
+
kind: z5.enum(["BUILT_IN"]).meta({ maxLength: 8 }),
|
|
420
521
|
toolName: CommerceBuiltInToolNameSchema,
|
|
421
|
-
definitionVersion:
|
|
522
|
+
definitionVersion: z5.enum(["2.0.0"]).meta({ maxLength: 5 })
|
|
422
523
|
});
|
|
423
|
-
var CommerceBuiltInToolDescriptorSchema =
|
|
424
|
-
kind:
|
|
524
|
+
var CommerceBuiltInToolDescriptorSchema = z5.strictObject({
|
|
525
|
+
kind: z5.enum(["BUILT_IN"]).meta({ maxLength: 8 }),
|
|
425
526
|
name: CommerceBuiltInToolNameSchema,
|
|
426
|
-
definitionVersion:
|
|
427
|
-
description:
|
|
527
|
+
definitionVersion: z5.enum(["2.0.0"]).meta({ maxLength: 5 }),
|
|
528
|
+
description: z5.string().min(1).max(4096),
|
|
428
529
|
inputSchema: InputSchemaSchema
|
|
429
530
|
});
|
|
430
|
-
var GrantedToolSchema =
|
|
431
|
-
var ToolDescriptorSchema =
|
|
432
|
-
var GrantedToolsSchema =
|
|
531
|
+
var GrantedToolSchema = z5.union([PublishedGrantedToolSchema, CommerceBuiltInToolGrantSchema]);
|
|
532
|
+
var ToolDescriptorSchema = z5.union([PublishedToolDescriptorSchema, CommerceBuiltInToolDescriptorSchema]);
|
|
533
|
+
var GrantedToolsSchema = z5.array(GrantedToolSchema).max(32).refine((values) => {
|
|
433
534
|
const published = values.filter((value) => !("kind" in value));
|
|
434
535
|
return distinct(values.map((value) => value.toolName)) && distinct(published.map((value) => value.toolId));
|
|
435
536
|
});
|
|
436
537
|
var isBuiltInTool = (value) => "kind" in value && value.kind === "BUILT_IN";
|
|
437
|
-
var MappingSchema =
|
|
438
|
-
|
|
439
|
-
input:
|
|
440
|
-
omitIfMissing:
|
|
538
|
+
var MappingSchema = z5.union([
|
|
539
|
+
z5.strictObject({
|
|
540
|
+
input: z5.string().refine(safeName),
|
|
541
|
+
omitIfMissing: z5.literal(true).optional()
|
|
441
542
|
}),
|
|
442
|
-
|
|
543
|
+
z5.strictObject({ literal: boundedJson(8192) })
|
|
443
544
|
]);
|
|
444
|
-
var MappingsSchema =
|
|
545
|
+
var MappingsSchema = z5.record(z5.string().refine(safeName), MappingSchema).refine((v) => Object.keys(v).length <= 32);
|
|
445
546
|
var POLICY_OPERATIONS = [
|
|
446
547
|
"taxonomy.resolveCategories",
|
|
447
548
|
"products.search",
|
|
@@ -455,15 +556,15 @@ var POLICY_OPERATIONS = [
|
|
|
455
556
|
"products.findQualifying",
|
|
456
557
|
"products.findSimilar"
|
|
457
558
|
];
|
|
458
|
-
var ExternalHttpExecutionSchema =
|
|
459
|
-
kind:
|
|
460
|
-
executorVersion:
|
|
559
|
+
var ExternalHttpExecutionSchema = z5.strictObject({
|
|
560
|
+
kind: z5.literal("EXTERNAL_HTTP"),
|
|
561
|
+
executorVersion: z5.literal("1.0.0"),
|
|
461
562
|
connectionRevisionId: IdSchema,
|
|
462
|
-
method:
|
|
563
|
+
method: z5.literal("GET"),
|
|
463
564
|
path: ExternalPathSchema,
|
|
464
565
|
query: ExternalQueryMappingsSchema,
|
|
465
566
|
responseFormat: ExternalResponseFormatSchema,
|
|
466
|
-
resultPath:
|
|
567
|
+
resultPath: z5.string().refine((value) => value === "" || safePath(value)),
|
|
467
568
|
responseProcessing: ResponseProcessingSchema,
|
|
468
569
|
resultSchema: DetailsSchemaSchema
|
|
469
570
|
}).superRefine((value, ctx) => {
|
|
@@ -472,21 +573,21 @@ var ExternalHttpExecutionSchema = z4.strictObject({
|
|
|
472
573
|
if (value.responseProcessing.kind !== "JAVASCRIPT" && value.responseFormat.mode !== "JSON")
|
|
473
574
|
ctx.addIssue({ code: "custom", path: ["responseFormat", "mode"], message: "Visual processing requires JSON" });
|
|
474
575
|
});
|
|
475
|
-
var CommerceExecutionSchema =
|
|
476
|
-
|
|
477
|
-
kind:
|
|
478
|
-
executorVersion:
|
|
479
|
-
apiVersion:
|
|
576
|
+
var CommerceExecutionSchema = z5.discriminatedUnion("kind", [
|
|
577
|
+
z5.strictObject({
|
|
578
|
+
kind: z5.literal("SHOPIFY_STOREFRONT_QUERY"),
|
|
579
|
+
executorVersion: z5.literal("1.0.0"),
|
|
580
|
+
apiVersion: z5.literal("2026-07"),
|
|
480
581
|
schemaHash: HashSchema,
|
|
481
|
-
document:
|
|
482
|
-
operationName:
|
|
582
|
+
document: z5.string().min(1).refine((v) => new TextEncoder().encode(v).length <= 16384),
|
|
583
|
+
operationName: z5.string().refine(safeName),
|
|
483
584
|
variables: MappingsSchema,
|
|
484
|
-
resultPath:
|
|
585
|
+
resultPath: z5.string().refine(safePath)
|
|
485
586
|
}),
|
|
486
|
-
|
|
487
|
-
kind:
|
|
488
|
-
operation:
|
|
489
|
-
operationVersion:
|
|
587
|
+
z5.strictObject({
|
|
588
|
+
kind: z5.literal("POLICY_OPERATION"),
|
|
589
|
+
operation: z5.enum(POLICY_OPERATIONS),
|
|
590
|
+
operationVersion: z5.literal("1.0.0"),
|
|
490
591
|
arguments: MappingsSchema
|
|
491
592
|
}),
|
|
492
593
|
ExternalHttpExecutionSchema
|
|
@@ -499,17 +600,17 @@ function tokensValid(text, root) {
|
|
|
499
600
|
);
|
|
500
601
|
return !residue.includes("{{") && !residue.includes("}}");
|
|
501
602
|
}
|
|
502
|
-
var fixed =
|
|
503
|
-
var ResponseTemplateSchema =
|
|
504
|
-
|
|
505
|
-
kind:
|
|
506
|
-
text:
|
|
603
|
+
var fixed = z5.string().max(4096).refine((v) => !/[<>]|\{\{|\}\}/.test(v));
|
|
604
|
+
var ResponseTemplateSchema = z5.discriminatedUnion("kind", [
|
|
605
|
+
z5.strictObject({
|
|
606
|
+
kind: z5.literal("text"),
|
|
607
|
+
text: z5.string().max(4096).refine((v) => tokensValid(v, "result")),
|
|
507
608
|
unavailable: fixed
|
|
508
609
|
}),
|
|
509
|
-
|
|
510
|
-
kind:
|
|
511
|
-
itemsPath:
|
|
512
|
-
item:
|
|
610
|
+
z5.strictObject({
|
|
611
|
+
kind: z5.literal("items"),
|
|
612
|
+
itemsPath: z5.string().refine(safePath),
|
|
613
|
+
item: z5.string().max(4096).refine((v) => tokensValid(v, "item")),
|
|
513
614
|
empty: fixed,
|
|
514
615
|
unavailable: fixed
|
|
515
616
|
})
|
|
@@ -517,11 +618,11 @@ var ResponseTemplateSchema = z4.discriminatedUnion("kind", [
|
|
|
517
618
|
var identity = {
|
|
518
619
|
name: ToolNameSchema,
|
|
519
620
|
definitionVersion: SemverSchema,
|
|
520
|
-
description:
|
|
621
|
+
description: z5.string().min(1).max(4096)
|
|
521
622
|
};
|
|
522
623
|
var forbiddenInput = /^(shopid|customerid|checkoutrecoveryid|conversationid|grantid|releaseid|token|accesstoken|domain|headers|url|graphql|document|authorization)$/i;
|
|
523
624
|
var forbiddenExternalInput = /^(authorization|cookie|set-cookie|host|x-api-key|api_key|apikey|access_token|token|secret|password)$/i;
|
|
524
|
-
var CommerceToolDefinitionSchema =
|
|
625
|
+
var CommerceToolDefinitionSchema = z5.strictObject({
|
|
525
626
|
...identity,
|
|
526
627
|
inputSchema: InputSchemaSchema,
|
|
527
628
|
execution: CommerceExecutionSchema,
|
|
@@ -557,7 +658,7 @@ var CommerceToolDefinitionSchema = z4.strictObject({
|
|
|
557
658
|
var draftObject = boundedJson(65536).refine(
|
|
558
659
|
(v) => !!v && typeof v === "object" && !Array.isArray(v)
|
|
559
660
|
);
|
|
560
|
-
var CommerceToolDraftDefinitionSchema =
|
|
661
|
+
var CommerceToolDraftDefinitionSchema = z5.strictObject({
|
|
561
662
|
...identity,
|
|
562
663
|
inputSchema: draftObject,
|
|
563
664
|
execution: draftObject,
|
|
@@ -650,12 +751,12 @@ function validateDefinitionVersion(proposed, highestPublished) {
|
|
|
650
751
|
SemverSchema.parse(highestPublished);
|
|
651
752
|
return gt(proposed, highestPublished);
|
|
652
753
|
}
|
|
653
|
-
var CommerceToolIdentitySchema =
|
|
754
|
+
var CommerceToolIdentitySchema = z5.strictObject({
|
|
654
755
|
id: IdSchema,
|
|
655
756
|
name: ToolNameSchema,
|
|
656
|
-
enabled:
|
|
757
|
+
enabled: z5.boolean()
|
|
657
758
|
});
|
|
658
|
-
var CommerceToolRevisionIdentitySchema =
|
|
759
|
+
var CommerceToolRevisionIdentitySchema = z5.strictObject({
|
|
659
760
|
toolId: IdSchema,
|
|
660
761
|
toolRevisionId: IdSchema,
|
|
661
762
|
definitionVersion: SemverSchema,
|
|
@@ -707,10 +808,10 @@ function isTrustedCommerceBuiltInGrant(value) {
|
|
|
707
808
|
}
|
|
708
809
|
|
|
709
810
|
// src/commerce/response.ts
|
|
710
|
-
import { z as
|
|
711
|
-
var CommerceResponseContractSchema =
|
|
712
|
-
version:
|
|
713
|
-
instructions:
|
|
811
|
+
import { z as z6 } from "zod";
|
|
812
|
+
var CommerceResponseContractSchema = z6.strictObject({
|
|
813
|
+
version: z6.literal("response.v1"),
|
|
814
|
+
instructions: z6.string().min(1).max(8e3),
|
|
714
815
|
detailsSchema: DetailsSchemaSchema
|
|
715
816
|
}).refine((v) => jsonBytes(v) <= 32768);
|
|
716
817
|
var EMPTY_RESPONSE_CONTRACT = {
|
|
@@ -723,31 +824,31 @@ var EMPTY_RESPONSE_CONTRACT = {
|
|
|
723
824
|
additionalProperties: false
|
|
724
825
|
}
|
|
725
826
|
};
|
|
726
|
-
var ReferralReasonSchema =
|
|
827
|
+
var ReferralReasonSchema = z6.enum([
|
|
727
828
|
"INSUFFICIENT_TOOLS",
|
|
728
829
|
"UNVERIFIABLE_FACTS",
|
|
729
830
|
"TOOL_UNAVAILABLE",
|
|
730
831
|
"TOOL_REVOKED"
|
|
731
832
|
]);
|
|
732
|
-
var DetectedLanguageTagSchema =
|
|
833
|
+
var DetectedLanguageTagSchema = z6.string().min(1).max(128).transform((value, ctx) => {
|
|
733
834
|
const canonical = canonicaliseLanguageTag(value);
|
|
734
835
|
if (!canonical) {
|
|
735
836
|
ctx.addIssue({
|
|
736
837
|
code: "custom",
|
|
737
838
|
message: "Invalid detected language tag"
|
|
738
839
|
});
|
|
739
|
-
return
|
|
840
|
+
return z6.NEVER;
|
|
740
841
|
}
|
|
741
842
|
return canonical;
|
|
742
843
|
});
|
|
743
|
-
var CommerceFinalResponseSchema =
|
|
744
|
-
answerKind:
|
|
745
|
-
replyText:
|
|
844
|
+
var CommerceFinalResponseSchema = z6.strictObject({
|
|
845
|
+
answerKind: z6.enum(["ANSWER", "REFER_TO_STORE"]),
|
|
846
|
+
replyText: z6.string().min(1).max(4096),
|
|
746
847
|
referralReason: ReferralReasonSchema.nullable(),
|
|
747
848
|
detectedLanguageTag: DetectedLanguageTagSchema.nullable(),
|
|
748
|
-
detectedLanguageConfidence:
|
|
749
|
-
evidenceIds:
|
|
750
|
-
details:
|
|
849
|
+
detectedLanguageConfidence: z6.number().min(0).max(1).nullable(),
|
|
850
|
+
evidenceIds: z6.array(IdSchema).max(3).refine((v) => new Set(v).size === v.length),
|
|
851
|
+
details: z6.record(z6.string(), z6.unknown()).refine((v) => {
|
|
751
852
|
try {
|
|
752
853
|
return jsonBytes(v) <= 16384;
|
|
753
854
|
} catch {
|
|
@@ -883,22 +984,22 @@ function finalResponseToolSchema(definition) {
|
|
|
883
984
|
}
|
|
884
985
|
|
|
885
986
|
// src/commerce/schemas.ts
|
|
886
|
-
import { z as
|
|
987
|
+
import { z as z7 } from "zod";
|
|
887
988
|
import { validRange } from "semver";
|
|
888
|
-
var CommerceTurnIdentitySchema =
|
|
989
|
+
var CommerceTurnIdentitySchema = z7.strictObject({
|
|
889
990
|
contractVersion: ContractVersionSchema,
|
|
890
991
|
shopId: IdSchema,
|
|
891
992
|
checkoutRecoveryId: IdSchema,
|
|
892
993
|
conversationId: IdSchema,
|
|
893
|
-
inboundVersion:
|
|
994
|
+
inboundVersion: z7.number().int().positive()
|
|
894
995
|
});
|
|
895
|
-
var CommerceConversationGrantSchema =
|
|
996
|
+
var CommerceConversationGrantSchema = z7.strictObject({
|
|
896
997
|
id: IdSchema,
|
|
897
998
|
shopId: IdSchema,
|
|
898
999
|
conversationId: IdSchema,
|
|
899
|
-
initialInboundVersion:
|
|
1000
|
+
initialInboundVersion: z7.number().int().positive(),
|
|
900
1001
|
releaseId: IdSchema,
|
|
901
|
-
selectedCapabilityKeys:
|
|
1002
|
+
selectedCapabilityKeys: z7.array(IdSchema).max(32).refine(distinct),
|
|
902
1003
|
purposeProfile: CommercePurposeProfileSchema.optional(),
|
|
903
1004
|
grantedTools: GrantedToolsSchema,
|
|
904
1005
|
runnerVersion: SemverSchema,
|
|
@@ -914,27 +1015,27 @@ var CommerceConversationGrantSchema = z6.strictObject({
|
|
|
914
1015
|
))
|
|
915
1016
|
c.addIssue({ code: "custom", message: "Unselected grant provenance" });
|
|
916
1017
|
});
|
|
917
|
-
var CommerceManifestSchema =
|
|
1018
|
+
var CommerceManifestSchema = z7.strictObject({
|
|
918
1019
|
contractVersion: ContractVersionSchema,
|
|
919
1020
|
releaseId: IdSchema,
|
|
920
|
-
runnerCompatibility:
|
|
921
|
-
capabilities:
|
|
922
|
-
|
|
1021
|
+
runnerCompatibility: z7.string().min(1).max(128).refine((v) => !!validRange(v)),
|
|
1022
|
+
capabilities: z7.array(
|
|
1023
|
+
z7.strictObject({
|
|
923
1024
|
capabilityId: IdSchema,
|
|
924
1025
|
key: IdSchema,
|
|
925
1026
|
featureId: IdSchema,
|
|
926
|
-
position:
|
|
1027
|
+
position: z7.number().int().nonnegative(),
|
|
927
1028
|
toolDescriptor: PublishedToolDescriptorSchema
|
|
928
1029
|
})
|
|
929
1030
|
).max(32),
|
|
930
|
-
featureBehaviours:
|
|
931
|
-
|
|
1031
|
+
featureBehaviours: z7.array(
|
|
1032
|
+
z7.strictObject({
|
|
932
1033
|
featureId: IdSchema,
|
|
933
|
-
behaviourPrompt:
|
|
1034
|
+
behaviourPrompt: z7.string().max(32e3)
|
|
934
1035
|
})
|
|
935
1036
|
).max(32),
|
|
936
|
-
selectedCapabilityKeys:
|
|
937
|
-
builtInTools:
|
|
1037
|
+
selectedCapabilityKeys: z7.array(IdSchema).max(32).refine(distinct),
|
|
1038
|
+
builtInTools: z7.array(CommerceBuiltInToolDescriptorSchema).max(2).default([]),
|
|
938
1039
|
purposeProfile: CommercePurposeProfileSchema.optional(),
|
|
939
1040
|
grantedTools: GrantedToolsSchema,
|
|
940
1041
|
responseContract: CommerceResponseContractSchema,
|
|
@@ -989,32 +1090,32 @@ var CommerceManifestSchema = z6.strictObject({
|
|
|
989
1090
|
message: "Grant must equal selected capability set"
|
|
990
1091
|
});
|
|
991
1092
|
});
|
|
992
|
-
var CommerceReleaseIdentitySchema =
|
|
1093
|
+
var CommerceReleaseIdentitySchema = z7.strictObject({
|
|
993
1094
|
contractVersion: ContractVersionSchema,
|
|
994
1095
|
releaseId: IdSchema,
|
|
995
|
-
runnerCompatibility:
|
|
1096
|
+
runnerCompatibility: z7.string().min(1).max(128).refine((v) => !!validRange(v))
|
|
996
1097
|
});
|
|
997
1098
|
var CommerceResolveAssertionSchema = CommerceTurnIdentitySchema.extend(
|
|
998
|
-
{ purpose:
|
|
1099
|
+
{ purpose: z7.literal("resolve") }
|
|
999
1100
|
);
|
|
1000
1101
|
var CommerceExecuteAssertionSchema = CommerceTurnIdentitySchema.extend(
|
|
1001
|
-
{ purpose:
|
|
1102
|
+
{ purpose: z7.literal("execute"), grantId: IdSchema, releaseId: IdSchema }
|
|
1002
1103
|
);
|
|
1003
|
-
var CommerceAssertionSchema =
|
|
1104
|
+
var CommerceAssertionSchema = z7.discriminatedUnion("purpose", [
|
|
1004
1105
|
CommerceResolveAssertionSchema,
|
|
1005
1106
|
CommerceExecuteAssertionSchema
|
|
1006
1107
|
]);
|
|
1007
|
-
var qty =
|
|
1008
|
-
var CommerceProposalSchema =
|
|
1009
|
-
operations:
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
kind:
|
|
1108
|
+
var qty = z7.number().int().min(1).max(999);
|
|
1109
|
+
var CommerceProposalSchema = z7.strictObject({
|
|
1110
|
+
operations: z7.array(
|
|
1111
|
+
z7.discriminatedUnion("kind", [
|
|
1112
|
+
z7.strictObject({
|
|
1113
|
+
kind: z7.literal("ADD"),
|
|
1013
1114
|
variantId: IdSchema,
|
|
1014
1115
|
quantity: qty
|
|
1015
1116
|
}),
|
|
1016
|
-
|
|
1017
|
-
kind:
|
|
1117
|
+
z7.strictObject({
|
|
1118
|
+
kind: z7.literal("REPLACE"),
|
|
1018
1119
|
lineId: IdSchema,
|
|
1019
1120
|
variantId: IdSchema,
|
|
1020
1121
|
quantity: qty
|
|
@@ -1026,13 +1127,13 @@ var CommerceProposalSchema = z6.strictObject({
|
|
|
1026
1127
|
v.operations.flatMap((o) => o.kind === "REPLACE" ? [o.lineId] : [])
|
|
1027
1128
|
)
|
|
1028
1129
|
);
|
|
1029
|
-
var CommerceBasketSchema =
|
|
1130
|
+
var CommerceBasketSchema = z7.strictObject({
|
|
1030
1131
|
basketId: IdSchema,
|
|
1031
|
-
source:
|
|
1132
|
+
source: z7.enum(["RECOVERY_SNAPSHOT", "PROPOSED"]),
|
|
1032
1133
|
observedAt: DateSchema,
|
|
1033
1134
|
currency: CurrencySchema.nullable(),
|
|
1034
|
-
lines:
|
|
1035
|
-
|
|
1135
|
+
lines: z7.array(
|
|
1136
|
+
z7.strictObject({
|
|
1036
1137
|
lineId: IdSchema,
|
|
1037
1138
|
productId: IdSchema.nullable(),
|
|
1038
1139
|
variantId: IdSchema.nullable(),
|
|
@@ -1041,14 +1142,14 @@ var CommerceBasketSchema = z6.strictObject({
|
|
|
1041
1142
|
})
|
|
1042
1143
|
).max(100),
|
|
1043
1144
|
fingerprint: HashSchema,
|
|
1044
|
-
unknownFields:
|
|
1145
|
+
unknownFields: z7.array(z7.string().min(1).max(256)).max(128)
|
|
1045
1146
|
}).refine((v) => distinct(v.lines.map((line) => line.lineId)));
|
|
1046
|
-
var CommerceProductSaleEvidenceSchema =
|
|
1147
|
+
var CommerceProductSaleEvidenceSchema = z7.strictObject({
|
|
1047
1148
|
regularPrice: MoneySchema.nullable(),
|
|
1048
1149
|
salePrice: MoneySchema.nullable(),
|
|
1049
1150
|
observedAt: DateSchema
|
|
1050
1151
|
});
|
|
1051
|
-
var optionLabel =
|
|
1152
|
+
var optionLabel = z7.string().transform((value) => value.replace(/[\r\n\t]+/g, " ").trim()).pipe(z7.string().min(1).max(128).refine((value) => !/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/.test(value)));
|
|
1052
1153
|
function normalizeCommerceProductOptions(raw) {
|
|
1053
1154
|
if (raw === void 0 || raw === null) return { status: "NOT_PROVIDED", items: [] };
|
|
1054
1155
|
const source = raw;
|
|
@@ -1084,9 +1185,9 @@ function normalizeCommerceProductOptions(raw) {
|
|
|
1084
1185
|
}
|
|
1085
1186
|
return { status: partial ? "PARTIAL" : items.length ? "AVAILABLE" : "NOT_PROVIDED", items };
|
|
1086
1187
|
}
|
|
1087
|
-
var CommerceProductOptionsSchema =
|
|
1088
|
-
status:
|
|
1089
|
-
items:
|
|
1188
|
+
var CommerceProductOptionsSchema = z7.preprocess(normalizeCommerceProductOptions, z7.strictObject({
|
|
1189
|
+
status: z7.enum(["AVAILABLE", "NOT_PROVIDED", "PARTIAL"]),
|
|
1190
|
+
items: z7.array(z7.strictObject({ name: optionLabel, values: z7.array(optionLabel).max(64), usedForVariants: z7.boolean().nullable() })).max(16)
|
|
1090
1191
|
}));
|
|
1091
1192
|
function normalizeCommerceProductSelectedOptions(raw) {
|
|
1092
1193
|
if (!Array.isArray(raw)) return [];
|
|
@@ -1099,31 +1200,33 @@ function normalizeCommerceProductSelectedOptions(raw) {
|
|
|
1099
1200
|
}
|
|
1100
1201
|
return result;
|
|
1101
1202
|
}
|
|
1102
|
-
var CommerceProductSelectedOptionsSchema =
|
|
1103
|
-
var CommerceProductSchema =
|
|
1203
|
+
var CommerceProductSelectedOptionsSchema = z7.preprocess(normalizeCommerceProductSelectedOptions, z7.array(z7.strictObject({ name: optionLabel, value: optionLabel })).max(16));
|
|
1204
|
+
var CommerceProductSchema = z7.strictObject({
|
|
1205
|
+
description: z7.preprocess(normalizeCommerceProductDescriptionField, CommerceProductDescriptionSchema).optional(),
|
|
1206
|
+
attributes: z7.preprocess(normalizeCommerceProductAttributes, CommerceProductAttributesSchema).optional(),
|
|
1104
1207
|
options: CommerceProductOptionsSchema.optional(),
|
|
1105
1208
|
selectedOptions: CommerceProductSelectedOptionsSchema.optional(),
|
|
1106
1209
|
productId: IdSchema,
|
|
1107
1210
|
variantId: IdSchema.nullable(),
|
|
1108
|
-
title:
|
|
1109
|
-
url:
|
|
1211
|
+
title: z7.string().min(1).max(512),
|
|
1212
|
+
url: z7.url({ protocol: /^https$/ }).refine((v) => {
|
|
1110
1213
|
const u = new URL(v);
|
|
1111
1214
|
return !u.username && !u.password && !u.port;
|
|
1112
1215
|
}).nullable(),
|
|
1113
|
-
available:
|
|
1216
|
+
available: z7.boolean().nullable(),
|
|
1114
1217
|
unitPrice: MoneySchema.nullable(),
|
|
1115
1218
|
currency: CurrencySchema.nullable(),
|
|
1116
|
-
productType:
|
|
1117
|
-
vendor:
|
|
1118
|
-
categories:
|
|
1119
|
-
categoryIds:
|
|
1120
|
-
collectionIds:
|
|
1121
|
-
imageUrl:
|
|
1219
|
+
productType: z7.string().max(512).nullable(),
|
|
1220
|
+
vendor: z7.string().max(512).nullable(),
|
|
1221
|
+
categories: z7.array(z7.string()).optional(),
|
|
1222
|
+
categoryIds: z7.array(IdSchema).max(128).optional(),
|
|
1223
|
+
collectionIds: z7.array(IdSchema).max(128).optional(),
|
|
1224
|
+
imageUrl: z7.string().nullable().optional(),
|
|
1122
1225
|
saleEvidence: CommerceProductSaleEvidenceSchema.nullable().optional(),
|
|
1123
1226
|
observedAt: DateSchema
|
|
1124
1227
|
});
|
|
1125
1228
|
var discountUtcPattern = /^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.[0-9]+)?Z(?![\s\S])/;
|
|
1126
|
-
var CommerceDiscountDateTimeSchema =
|
|
1229
|
+
var CommerceDiscountDateTimeSchema = z7.string().regex(discountUtcPattern).refine((value) => {
|
|
1127
1230
|
const match = discountUtcPattern.exec(value);
|
|
1128
1231
|
if (!match) return false;
|
|
1129
1232
|
const [year, month, day, hour, minute, second] = match.slice(1).map(Number);
|
|
@@ -1132,36 +1235,36 @@ var CommerceDiscountDateTimeSchema = z6.string().regex(discountUtcPattern).refin
|
|
|
1132
1235
|
const daysInMonth = [31, leapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
1133
1236
|
return day >= 1 && day <= daysInMonth[month - 1];
|
|
1134
1237
|
}, "Expected a valid UTC discount timestamp with seconds");
|
|
1135
|
-
var CommerceOfferSchema =
|
|
1238
|
+
var CommerceOfferSchema = z7.strictObject({
|
|
1136
1239
|
offerId: IdSchema,
|
|
1137
|
-
title:
|
|
1138
|
-
method:
|
|
1139
|
-
code:
|
|
1240
|
+
title: z7.string().min(1).max(512),
|
|
1241
|
+
method: z7.enum(["AUTOMATIC", "CODE"]),
|
|
1242
|
+
code: z7.string().min(1).max(128).nullable(),
|
|
1140
1243
|
startsAt: CommerceDiscountDateTimeSchema.nullable(),
|
|
1141
1244
|
endsAt: CommerceDiscountDateTimeSchema.nullable(),
|
|
1142
|
-
support:
|
|
1143
|
-
reasonCodes:
|
|
1245
|
+
support: z7.enum(["SUPPORTED", "UNSUPPORTED", "UNKNOWN"]),
|
|
1246
|
+
reasonCodes: z7.array(z7.string().min(1).max(64)).max(16)
|
|
1144
1247
|
}).refine(
|
|
1145
1248
|
(v) => (v.startsAt === null || v.endsAt === null || Date.parse(v.startsAt) < Date.parse(v.endsAt)) && (v.method !== "AUTOMATIC" || v.code === null)
|
|
1146
1249
|
);
|
|
1147
|
-
var CommerceDiscountCombinationFactsSchema =
|
|
1148
|
-
discountClasses:
|
|
1149
|
-
shopifyPlus:
|
|
1150
|
-
combinesWith:
|
|
1151
|
-
orderDiscounts:
|
|
1152
|
-
productDiscounts:
|
|
1153
|
-
shippingDiscounts:
|
|
1250
|
+
var CommerceDiscountCombinationFactsSchema = z7.strictObject({
|
|
1251
|
+
discountClasses: z7.array(z7.enum(["ORDER", "PRODUCT", "SHIPPING"])).max(3).nullable(),
|
|
1252
|
+
shopifyPlus: z7.boolean().nullable(),
|
|
1253
|
+
combinesWith: z7.strictObject({
|
|
1254
|
+
orderDiscounts: z7.boolean().nullable(),
|
|
1255
|
+
productDiscounts: z7.boolean().nullable(),
|
|
1256
|
+
shippingDiscounts: z7.boolean().nullable()
|
|
1154
1257
|
}).nullable(),
|
|
1155
|
-
discountTags:
|
|
1156
|
-
allowedSameLineProductTags:
|
|
1258
|
+
discountTags: z7.array(z7.string().min(1).max(128)).max(64).nullable(),
|
|
1259
|
+
allowedSameLineProductTags: z7.array(z7.string().min(1).max(128)).max(64).nullable()
|
|
1157
1260
|
});
|
|
1158
|
-
var CommerceDiscountConditionFactsSchema =
|
|
1159
|
-
provider:
|
|
1160
|
-
completeness:
|
|
1261
|
+
var CommerceDiscountConditionFactsSchema = z7.strictObject({
|
|
1262
|
+
provider: z7.enum(["SHOPIFY", "WOOCOMMERCE"]),
|
|
1263
|
+
completeness: z7.enum(["COMPLETE", "PARTIAL", "UNKNOWN"]),
|
|
1161
1264
|
observedAt: CommerceDiscountDateTimeSchema,
|
|
1162
|
-
providerStatus:
|
|
1265
|
+
providerStatus: z7.string().max(64),
|
|
1163
1266
|
unavailableAt: CommerceDiscountDateTimeSchema.nullable(),
|
|
1164
|
-
discountKind:
|
|
1267
|
+
discountKind: z7.enum([
|
|
1165
1268
|
"PERCENTAGE",
|
|
1166
1269
|
"FIXED_AMOUNT",
|
|
1167
1270
|
"FREE_SHIPPING",
|
|
@@ -1171,8 +1274,8 @@ var CommerceDiscountConditionFactsSchema = z6.strictObject({
|
|
|
1171
1274
|
]),
|
|
1172
1275
|
discountValue: MoneySchema.nullable(),
|
|
1173
1276
|
discountCurrency: CurrencySchema.nullable(),
|
|
1174
|
-
targeting:
|
|
1175
|
-
kind:
|
|
1277
|
+
targeting: z7.strictObject({
|
|
1278
|
+
kind: z7.enum([
|
|
1176
1279
|
"ALL",
|
|
1177
1280
|
"PRODUCTS",
|
|
1178
1281
|
"VARIANTS",
|
|
@@ -1181,38 +1284,38 @@ var CommerceDiscountConditionFactsSchema = z6.strictObject({
|
|
|
1181
1284
|
"MIXED",
|
|
1182
1285
|
"UNKNOWN"
|
|
1183
1286
|
]),
|
|
1184
|
-
includedProductIds:
|
|
1185
|
-
includedVariantIds:
|
|
1186
|
-
includedCategoryIds:
|
|
1187
|
-
includedCollectionIds:
|
|
1188
|
-
excludedProductIds:
|
|
1189
|
-
excludedVariantIds:
|
|
1190
|
-
excludedCategoryIds:
|
|
1191
|
-
excludedCollectionIds:
|
|
1287
|
+
includedProductIds: z7.array(IdSchema).max(128),
|
|
1288
|
+
includedVariantIds: z7.array(IdSchema).max(128),
|
|
1289
|
+
includedCategoryIds: z7.array(IdSchema).max(128),
|
|
1290
|
+
includedCollectionIds: z7.array(IdSchema).max(128),
|
|
1291
|
+
excludedProductIds: z7.array(IdSchema).max(128),
|
|
1292
|
+
excludedVariantIds: z7.array(IdSchema).max(128),
|
|
1293
|
+
excludedCategoryIds: z7.array(IdSchema).max(128),
|
|
1294
|
+
excludedCollectionIds: z7.array(IdSchema).max(128)
|
|
1192
1295
|
}),
|
|
1193
1296
|
minimumSubtotal: MoneySchema.nullable(),
|
|
1194
1297
|
maximumSubtotal: MoneySchema.nullable(),
|
|
1195
1298
|
subtotalRequirementCurrency: CurrencySchema.nullable(),
|
|
1196
|
-
minimumQuantity:
|
|
1197
|
-
usageLimit:
|
|
1198
|
-
usageCount:
|
|
1199
|
-
perCustomerLimit:
|
|
1200
|
-
customerScope:
|
|
1201
|
-
excludesSaleItems:
|
|
1202
|
-
individualUse:
|
|
1299
|
+
minimumQuantity: z7.number().int().nonnegative().nullable(),
|
|
1300
|
+
usageLimit: z7.number().int().nonnegative().nullable(),
|
|
1301
|
+
usageCount: z7.number().int().nonnegative().nullable(),
|
|
1302
|
+
perCustomerLimit: z7.number().int().nonnegative().nullable(),
|
|
1303
|
+
customerScope: z7.enum(["ALL", "RESTRICTED", "UNKNOWN"]),
|
|
1304
|
+
excludesSaleItems: z7.boolean().nullable(),
|
|
1305
|
+
individualUse: z7.boolean().nullable(),
|
|
1203
1306
|
combination: CommerceDiscountCombinationFactsSchema,
|
|
1204
|
-
unrepresentedConditions:
|
|
1307
|
+
unrepresentedConditions: z7.array(z7.string().min(1).max(128)).max(24)
|
|
1205
1308
|
});
|
|
1206
|
-
var CommerceDiscountDetailsSchema =
|
|
1309
|
+
var CommerceDiscountDetailsSchema = z7.strictObject({
|
|
1207
1310
|
offer: CommerceOfferSchema,
|
|
1208
1311
|
facts: CommerceDiscountConditionFactsSchema,
|
|
1209
|
-
providerDiscountId:
|
|
1312
|
+
providerDiscountId: z7.string().min(1).max(191).nullable()
|
|
1210
1313
|
});
|
|
1211
|
-
var condition =
|
|
1212
|
-
code:
|
|
1213
|
-
description:
|
|
1314
|
+
var condition = z7.strictObject({
|
|
1315
|
+
code: z7.string().min(1).max(64),
|
|
1316
|
+
description: z7.string().max(256)
|
|
1214
1317
|
});
|
|
1215
|
-
var CommerceEvidenceSchema =
|
|
1318
|
+
var CommerceEvidenceSchema = z7.strictObject({
|
|
1216
1319
|
evidenceId: HashSchema,
|
|
1217
1320
|
turn: CommerceTurnIdentitySchema,
|
|
1218
1321
|
grantId: IdSchema,
|
|
@@ -1223,7 +1326,7 @@ var CommerceEvidenceSchema = z6.strictObject({
|
|
|
1223
1326
|
ruleFingerprint: HashSchema,
|
|
1224
1327
|
evaluatedAt: DateSchema,
|
|
1225
1328
|
expiresAt: DateSchema,
|
|
1226
|
-
outcome:
|
|
1329
|
+
outcome: z7.enum([
|
|
1227
1330
|
"QUALIFIES_FOR_KNOWN_RULES",
|
|
1228
1331
|
"DOES_NOT_QUALIFY",
|
|
1229
1332
|
"UNKNOWN",
|
|
@@ -1232,8 +1335,8 @@ var CommerceEvidenceSchema = z6.strictObject({
|
|
|
1232
1335
|
currency: CurrencySchema.nullable(),
|
|
1233
1336
|
savings: MoneySchema.nullable(),
|
|
1234
1337
|
resultingTotal: MoneySchema.nullable(),
|
|
1235
|
-
evaluatedConditions:
|
|
1236
|
-
unresolvedConditions:
|
|
1338
|
+
evaluatedConditions: z7.array(condition).max(32),
|
|
1339
|
+
unresolvedConditions: z7.array(condition).max(32)
|
|
1237
1340
|
}).superRefine((v, c) => {
|
|
1238
1341
|
if (Date.parse(v.expiresAt) - Date.parse(v.evaluatedAt) > 6e4)
|
|
1239
1342
|
c.addIssue({
|
|
@@ -1243,16 +1346,16 @@ var CommerceEvidenceSchema = z6.strictObject({
|
|
|
1243
1346
|
if (v.outcome === "QUALIFIES_FOR_KNOWN_RULES" && (v.unresolvedConditions.length || Date.parse(v.expiresAt) <= Date.parse(v.evaluatedAt) || v.currency === null || v.savings === null || v.resultingTotal === null))
|
|
1244
1347
|
c.addIssue({ code: "custom", message: "Unsupported qualifying claim" });
|
|
1245
1348
|
});
|
|
1246
|
-
var CommerceAlternativeSchema =
|
|
1349
|
+
var CommerceAlternativeSchema = z7.strictObject({
|
|
1247
1350
|
product: CommerceProductSchema,
|
|
1248
1351
|
proposal: CommerceProposalSchema,
|
|
1249
1352
|
extraSpend: MoneySchema.nullable(),
|
|
1250
1353
|
resultingTotal: MoneySchema.nullable(),
|
|
1251
1354
|
currency: CurrencySchema.nullable(),
|
|
1252
1355
|
evidence: CommerceEvidenceSchema.nullable(),
|
|
1253
|
-
similarityReasons:
|
|
1356
|
+
similarityReasons: z7.array(z7.string().max(256)).max(3)
|
|
1254
1357
|
}).refine((v) => v.product.available === true);
|
|
1255
|
-
var CommerceErrorCodeSchema =
|
|
1358
|
+
var CommerceErrorCodeSchema = z7.enum([
|
|
1256
1359
|
"INVALID_INPUT",
|
|
1257
1360
|
"DENIED",
|
|
1258
1361
|
"STALE_TURN",
|
|
@@ -1263,184 +1366,184 @@ var CommerceErrorCodeSchema = z6.enum([
|
|
|
1263
1366
|
"INCOMPATIBLE_VERSION"
|
|
1264
1367
|
]);
|
|
1265
1368
|
function commerceToolResultSchema(data) {
|
|
1266
|
-
return
|
|
1267
|
-
|
|
1369
|
+
return z7.union([
|
|
1370
|
+
z7.strictObject({
|
|
1268
1371
|
contractVersion: ContractVersionSchema,
|
|
1269
|
-
status:
|
|
1372
|
+
status: z7.literal("OK"),
|
|
1270
1373
|
data,
|
|
1271
|
-
renderedText:
|
|
1374
|
+
renderedText: z7.string().max(4096)
|
|
1272
1375
|
}),
|
|
1273
|
-
|
|
1376
|
+
z7.strictObject({
|
|
1274
1377
|
contractVersion: ContractVersionSchema,
|
|
1275
|
-
status:
|
|
1378
|
+
status: z7.literal("ERROR"),
|
|
1276
1379
|
code: CommerceErrorCodeSchema,
|
|
1277
|
-
retryable:
|
|
1278
|
-
renderedText:
|
|
1380
|
+
retryable: z7.boolean(),
|
|
1381
|
+
renderedText: z7.string().max(4096).optional()
|
|
1279
1382
|
})
|
|
1280
1383
|
]);
|
|
1281
1384
|
}
|
|
1282
1385
|
var CommerceToolResultSchema = commerceToolResultSchema(
|
|
1283
1386
|
boundedJson(262144)
|
|
1284
1387
|
);
|
|
1285
|
-
var wireId =
|
|
1286
|
-
var taxonomySource =
|
|
1287
|
-
var CommerceCategoryCandidateSchema =
|
|
1388
|
+
var wireId = z7.string().min(1).max(128);
|
|
1389
|
+
var taxonomySource = z7.enum(["SHOPIFY_STANDARD_PRODUCT_TAXONOMY"]).meta({ maxLength: 33 });
|
|
1390
|
+
var CommerceCategoryCandidateSchema = z7.strictObject({
|
|
1288
1391
|
categoryId: wireId,
|
|
1289
|
-
name:
|
|
1290
|
-
fullName:
|
|
1392
|
+
name: z7.string().min(1).max(512),
|
|
1393
|
+
fullName: z7.string().min(1).max(4096),
|
|
1291
1394
|
parentId: wireId.nullable(),
|
|
1292
|
-
level:
|
|
1293
|
-
ancestorIds:
|
|
1294
|
-
distance:
|
|
1395
|
+
level: z7.number().int().min(0).max(32),
|
|
1396
|
+
ancestorIds: z7.array(wireId).max(32),
|
|
1397
|
+
distance: z7.number().min(0).max(2)
|
|
1295
1398
|
});
|
|
1296
|
-
var CommerceCategoryResolutionSchema =
|
|
1297
|
-
|
|
1298
|
-
outcome:
|
|
1399
|
+
var CommerceCategoryResolutionSchema = z7.union([
|
|
1400
|
+
z7.strictObject({
|
|
1401
|
+
outcome: z7.enum(["CANDIDATES", "NO_CANDIDATES"]).meta({ maxLength: 13 }),
|
|
1299
1402
|
generationId: wireId,
|
|
1300
1403
|
source: taxonomySource,
|
|
1301
|
-
taxonomyVersion:
|
|
1302
|
-
languageTag:
|
|
1303
|
-
candidates:
|
|
1404
|
+
taxonomyVersion: z7.string().min(1).max(64),
|
|
1405
|
+
languageTag: z7.string().min(1).max(35),
|
|
1406
|
+
candidates: z7.array(CommerceCategoryCandidateSchema).max(10)
|
|
1304
1407
|
}),
|
|
1305
|
-
|
|
1306
|
-
outcome:
|
|
1307
|
-
reasonCode:
|
|
1408
|
+
z7.strictObject({
|
|
1409
|
+
outcome: z7.enum(["UNAVAILABLE"]).meta({ maxLength: 11 }),
|
|
1410
|
+
reasonCode: z7.enum(["NOT_READY", "TEMPORARY_UNAVAILABLE"]).meta({ maxLength: 21 })
|
|
1308
1411
|
})
|
|
1309
1412
|
]);
|
|
1310
|
-
var CommerceOptionalLookupUnavailableSchema =
|
|
1311
|
-
outcome:
|
|
1312
|
-
reasonCode:
|
|
1413
|
+
var CommerceOptionalLookupUnavailableSchema = z7.strictObject({
|
|
1414
|
+
outcome: z7.enum(["UNAVAILABLE"]).meta({ maxLength: 11 }),
|
|
1415
|
+
reasonCode: z7.enum(["TEMPORARY_UNAVAILABLE"]).meta({ maxLength: 21 })
|
|
1313
1416
|
});
|
|
1314
|
-
var CommerceProductRecommendationSelectionSchema =
|
|
1315
|
-
productRecommendationVersion:
|
|
1316
|
-
productRecommendations:
|
|
1317
|
-
scope:
|
|
1417
|
+
var CommerceProductRecommendationSelectionSchema = z7.strictObject({
|
|
1418
|
+
productRecommendationVersion: z7.enum(["1"]).meta({ maxLength: 1 }).optional(),
|
|
1419
|
+
productRecommendations: z7.array(z7.strictObject({
|
|
1420
|
+
scope: z7.enum(["PRODUCT_ONLY", "ADD_TO_BASKET", "REPLACE_BASKET_LINE"]).meta({ maxLength: 19 }),
|
|
1318
1421
|
basketLineId: wireId.nullable(),
|
|
1319
1422
|
productId: wireId,
|
|
1320
1423
|
variantId: wireId.nullable(),
|
|
1321
|
-
quantity:
|
|
1322
|
-
promotionKind:
|
|
1323
|
-
offerIds:
|
|
1424
|
+
quantity: z7.number().int().min(1).max(99),
|
|
1425
|
+
promotionKind: z7.enum(["NONE", "NATIVE_SALE", "DISCOUNT"]).meta({ maxLength: 11 }),
|
|
1426
|
+
offerIds: z7.array(wireId).max(3)
|
|
1324
1427
|
})).min(1).max(3).optional()
|
|
1325
1428
|
});
|
|
1326
|
-
var CommerceResponseDispositionSchema =
|
|
1429
|
+
var CommerceResponseDispositionSchema = z7.enum([
|
|
1327
1430
|
"STANDARD",
|
|
1328
1431
|
"OUT_OF_SCOPE_REDIRECT",
|
|
1329
1432
|
"SHIPPING_INFORMATION_UNVERIFIED",
|
|
1330
1433
|
"PRODUCT_OPTIONS"
|
|
1331
1434
|
]).meta({ maxLength: 31 });
|
|
1332
|
-
var CommerceAnswerPresentationSelectionSchema =
|
|
1333
|
-
productOptionSelections:
|
|
1435
|
+
var CommerceAnswerPresentationSelectionSchema = z7.strictObject({
|
|
1436
|
+
productOptionSelections: z7.array(z7.strictObject({ productId: wireId, variantId: wireId.nullable() })).max(3).optional(),
|
|
1334
1437
|
responseDisposition: CommerceResponseDispositionSchema.optional(),
|
|
1335
|
-
shippingInformationSelection:
|
|
1438
|
+
shippingInformationSelection: z7.strictObject({
|
|
1336
1439
|
productId: wireId.nullable(),
|
|
1337
1440
|
variantId: wireId.nullable()
|
|
1338
1441
|
}).optional()
|
|
1339
1442
|
});
|
|
1340
|
-
var CommerceShippingInformationInputSchema =
|
|
1443
|
+
var CommerceShippingInformationInputSchema = z7.strictObject({
|
|
1341
1444
|
productId: wireId.nullable().default(null),
|
|
1342
1445
|
variantId: wireId.nullable().default(null)
|
|
1343
1446
|
});
|
|
1344
|
-
var CommerceShippingInformationSchema =
|
|
1345
|
-
provider:
|
|
1447
|
+
var CommerceShippingInformationSchema = z7.strictObject({
|
|
1448
|
+
provider: z7.enum(["SHOPIFY", "WOOCOMMERCE"]).meta({ maxLength: 11 }),
|
|
1346
1449
|
observedAt: DateSchema,
|
|
1347
|
-
product:
|
|
1348
|
-
status:
|
|
1450
|
+
product: z7.strictObject({
|
|
1451
|
+
status: z7.enum(["NOT_REQUESTED", "VARIANT_REQUIRED", "AVAILABLE"]).meta({ maxLength: 16 }),
|
|
1349
1452
|
productId: wireId.nullable(),
|
|
1350
1453
|
variantId: wireId.nullable(),
|
|
1351
|
-
requiresShipping:
|
|
1352
|
-
virtual:
|
|
1353
|
-
weight:
|
|
1354
|
-
value:
|
|
1355
|
-
unit:
|
|
1454
|
+
requiresShipping: z7.boolean().nullable(),
|
|
1455
|
+
virtual: z7.boolean().nullable(),
|
|
1456
|
+
weight: z7.strictObject({
|
|
1457
|
+
value: z7.number().min(0),
|
|
1458
|
+
unit: z7.enum(["GRAMS", "KILOGRAMS", "OUNCES", "POUNDS"]).meta({ maxLength: 9 }).nullable()
|
|
1356
1459
|
}).nullable(),
|
|
1357
|
-
dimensions:
|
|
1358
|
-
length:
|
|
1359
|
-
width:
|
|
1360
|
-
height:
|
|
1361
|
-
unit:
|
|
1460
|
+
dimensions: z7.strictObject({
|
|
1461
|
+
length: z7.number().min(0).nullable(),
|
|
1462
|
+
width: z7.number().min(0).nullable(),
|
|
1463
|
+
height: z7.number().min(0).nullable(),
|
|
1464
|
+
unit: z7.string().min(1).max(16).nullable()
|
|
1362
1465
|
}).nullable(),
|
|
1363
1466
|
shippingClassId: wireId.nullable(),
|
|
1364
|
-
shippingClassSlug:
|
|
1467
|
+
shippingClassSlug: z7.string().min(1).max(512).nullable()
|
|
1365
1468
|
}),
|
|
1366
|
-
policy:
|
|
1367
|
-
status:
|
|
1368
|
-
trust:
|
|
1369
|
-
title:
|
|
1370
|
-
bodyStatus:
|
|
1371
|
-
bodyHtml:
|
|
1372
|
-
url:
|
|
1469
|
+
policy: z7.strictObject({
|
|
1470
|
+
status: z7.enum(["AVAILABLE", "NOT_CONFIGURED", "SCOPE_NOT_GRANTED", "UNSUPPORTED"]).meta({ maxLength: 17 }),
|
|
1471
|
+
trust: z7.enum(["UNTRUSTED_REFERENCE"]).meta({ maxLength: 19 }),
|
|
1472
|
+
title: z7.string().min(1).max(512).nullable(),
|
|
1473
|
+
bodyStatus: z7.enum(["AVAILABLE", "EMPTY", "TOO_LARGE", "NOT_AVAILABLE"]).meta({ maxLength: 13 }),
|
|
1474
|
+
bodyHtml: z7.string().min(1).max(8e3).nullable(),
|
|
1475
|
+
url: z7.url({ protocol: /^https$/ }).min(1).max(2048).nullable(),
|
|
1373
1476
|
updatedAt: DateSchema.nullable()
|
|
1374
1477
|
})
|
|
1375
1478
|
});
|
|
1376
|
-
var limit =
|
|
1479
|
+
var limit = z7.number().int().min(1).max(3).default(3);
|
|
1377
1480
|
var CommerceToolInputs = {
|
|
1378
|
-
commerce_resolve_product_categories:
|
|
1379
|
-
query:
|
|
1380
|
-
limit:
|
|
1481
|
+
commerce_resolve_product_categories: z7.strictObject({
|
|
1482
|
+
query: z7.string().min(1).max(200),
|
|
1483
|
+
limit: z7.number().int().min(1).max(10).default(5)
|
|
1381
1484
|
}),
|
|
1382
1485
|
commerce_get_shipping_information: CommerceShippingInformationInputSchema,
|
|
1383
|
-
commerce_get_basket:
|
|
1384
|
-
commerce_search_products:
|
|
1385
|
-
query:
|
|
1386
|
-
category:
|
|
1387
|
-
system:
|
|
1486
|
+
commerce_get_basket: z7.strictObject({}),
|
|
1487
|
+
commerce_search_products: z7.strictObject({
|
|
1488
|
+
query: z7.string().min(1).max(200).nullable().default(null),
|
|
1489
|
+
category: z7.strictObject({
|
|
1490
|
+
system: z7.enum(["SHOPIFY_STANDARD_PRODUCT_TAXONOMY", "WOOCOMMERCE_PRODUCT_CATEGORY"]).meta({ maxLength: 33 }),
|
|
1388
1491
|
id: wireId,
|
|
1389
|
-
taxonomyVersion:
|
|
1492
|
+
taxonomyVersion: z7.string().min(1).max(64).nullable()
|
|
1390
1493
|
}).optional(),
|
|
1391
|
-
browse:
|
|
1494
|
+
browse: z7.boolean().default(false),
|
|
1392
1495
|
maximumPrice: MoneySchema.optional(),
|
|
1393
|
-
availableOnly:
|
|
1394
|
-
limit:
|
|
1395
|
-
cursor:
|
|
1496
|
+
availableOnly: z7.boolean().default(true),
|
|
1497
|
+
limit: z7.number().int().min(1).max(20).default(10),
|
|
1498
|
+
cursor: z7.string().max(2048).nullable().default(null)
|
|
1396
1499
|
}),
|
|
1397
|
-
commerce_get_product:
|
|
1500
|
+
commerce_get_product: z7.strictObject({
|
|
1398
1501
|
productId: IdSchema,
|
|
1399
1502
|
variantId: IdSchema.nullable()
|
|
1400
1503
|
}),
|
|
1401
|
-
commerce_get_discount_options:
|
|
1402
|
-
limit:
|
|
1403
|
-
cursor:
|
|
1504
|
+
commerce_get_discount_options: z7.strictObject({
|
|
1505
|
+
limit: z7.number().int().min(1).max(50).default(20),
|
|
1506
|
+
cursor: z7.string().max(2048).nullable().default(null)
|
|
1404
1507
|
}),
|
|
1405
|
-
commerce_get_discount_details:
|
|
1406
|
-
commerce_evaluate_discount:
|
|
1508
|
+
commerce_get_discount_details: z7.strictObject({ offerId: IdSchema }),
|
|
1509
|
+
commerce_evaluate_discount: z7.strictObject({
|
|
1407
1510
|
offerId: IdSchema,
|
|
1408
1511
|
proposal: CommerceProposalSchema.nullable()
|
|
1409
1512
|
}),
|
|
1410
|
-
commerce_find_qualifying_products:
|
|
1513
|
+
commerce_find_qualifying_products: z7.strictObject({
|
|
1411
1514
|
offerId: IdSchema,
|
|
1412
|
-
query:
|
|
1515
|
+
query: z7.string().min(1).max(200).nullable(),
|
|
1413
1516
|
limit
|
|
1414
1517
|
}),
|
|
1415
|
-
commerce_find_similar_products:
|
|
1518
|
+
commerce_find_similar_products: z7.strictObject({
|
|
1416
1519
|
variantId: IdSchema,
|
|
1417
1520
|
offerId: IdSchema.nullable(),
|
|
1418
1521
|
limit
|
|
1419
1522
|
})
|
|
1420
1523
|
};
|
|
1421
|
-
var alternatives =
|
|
1422
|
-
alternatives:
|
|
1423
|
-
truncated:
|
|
1524
|
+
var alternatives = z7.strictObject({
|
|
1525
|
+
alternatives: z7.array(CommerceAlternativeSchema).max(3),
|
|
1526
|
+
truncated: z7.boolean()
|
|
1424
1527
|
});
|
|
1425
1528
|
var CommerceToolOutputs = {
|
|
1426
1529
|
commerce_resolve_product_categories: CommerceCategoryResolutionSchema,
|
|
1427
1530
|
commerce_get_shipping_information: CommerceShippingInformationSchema,
|
|
1428
1531
|
commerce_get_basket: CommerceBasketSchema,
|
|
1429
|
-
commerce_search_products:
|
|
1430
|
-
products:
|
|
1431
|
-
cursor:
|
|
1432
|
-
truncated:
|
|
1532
|
+
commerce_search_products: z7.strictObject({
|
|
1533
|
+
products: z7.array(CommerceProductSchema).max(20),
|
|
1534
|
+
cursor: z7.string().max(2048).nullable(),
|
|
1535
|
+
truncated: z7.boolean()
|
|
1433
1536
|
}),
|
|
1434
|
-
commerce_get_product:
|
|
1537
|
+
commerce_get_product: z7.strictObject({
|
|
1435
1538
|
product: CommerceProductSchema.nullable()
|
|
1436
1539
|
}),
|
|
1437
|
-
commerce_get_discount_options:
|
|
1438
|
-
mode:
|
|
1439
|
-
offers:
|
|
1440
|
-
truncated:
|
|
1441
|
-
cursor:
|
|
1540
|
+
commerce_get_discount_options: z7.union([CommerceOptionalLookupUnavailableSchema, z7.strictObject({
|
|
1541
|
+
mode: z7.enum(["NONE", "FIXED", "AI_BEST_APPLICABLE"]),
|
|
1542
|
+
offers: z7.array(CommerceOfferSchema).max(50),
|
|
1543
|
+
truncated: z7.boolean(),
|
|
1544
|
+
cursor: z7.string().max(2048).nullable().optional()
|
|
1442
1545
|
})]),
|
|
1443
|
-
commerce_get_discount_details:
|
|
1546
|
+
commerce_get_discount_details: z7.union([CommerceOptionalLookupUnavailableSchema, z7.strictObject({
|
|
1444
1547
|
details: CommerceDiscountDetailsSchema.nullable()
|
|
1445
1548
|
})]),
|
|
1446
1549
|
commerce_evaluate_discount: CommerceEvidenceSchema,
|
|
@@ -1456,6 +1559,11 @@ function productBelongsToDomain(product, verifiedDomain) {
|
|
|
1456
1559
|
}
|
|
1457
1560
|
|
|
1458
1561
|
export {
|
|
1562
|
+
CommerceProductDescriptionSchema,
|
|
1563
|
+
CommerceProductAttributesSchema,
|
|
1564
|
+
normalizeCommerceProductDescription,
|
|
1565
|
+
normalizeCommerceProductAttributes,
|
|
1566
|
+
normalizeCommerceProductDescriptionField,
|
|
1459
1567
|
MONEY_PATTERN,
|
|
1460
1568
|
safeName,
|
|
1461
1569
|
safePath,
|
|
@@ -1559,4 +1667,4 @@ export {
|
|
|
1559
1667
|
CommerceToolOutputs,
|
|
1560
1668
|
productBelongsToDomain
|
|
1561
1669
|
};
|
|
1562
|
-
//# sourceMappingURL=chunk-
|
|
1670
|
+
//# sourceMappingURL=chunk-WF2BDUPZ.js.map
|