@modainteract/moda-interact-shared 5.4.0 → 5.6.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-KIHGDO35.js +148 -0
- package/dist/chunk-KIHGDO35.js.map +1 -0
- package/dist/{chunk-232YZOKK.js → chunk-S42O2OCG.js} +477 -306
- package/dist/chunk-S42O2OCG.js.map +1 -0
- package/dist/{chunk-XB5NIOKJ.js → chunk-WONND3OK.js} +3 -1
- package/dist/chunk-WONND3OK.js.map +1 -0
- package/dist/commerce/index.d.ts +7 -5
- package/dist/commerce/index.js +22 -2
- package/dist/commerce/index.js.map +1 -1
- package/dist/commerce/model/node.d.ts +3 -2
- package/dist/commerce/model/node.js +2 -2
- package/dist/commerce/presentation/index.d.ts +323 -0
- package/dist/commerce/presentation/index.js +594 -0
- package/dist/commerce/presentation/index.js.map +1 -0
- package/dist/commerce/runner/index.d.ts +4 -3
- package/dist/commerce/runner/index.js +63 -20
- package/dist/commerce/runner/index.js.map +1 -1
- package/dist/product-context-D3FuI6ah.d.ts +746 -0
- package/dist/{response-Bh-KzXOQ.d.ts → response-Cs4zC3d3.d.ts} +171 -711
- package/dist/{types-Bcrs9622.d.ts → types-ByoKuP90.d.ts} +6 -2
- package/package.json +7 -2
- package/dist/chunk-232YZOKK.js.map +0 -1
- package/dist/chunk-XB5NIOKJ.js.map +0 -1
- package/dist/chunk-XE2YVPQV.js +0 -97
- package/dist/chunk-XE2YVPQV.js.map +0 -1
|
@@ -155,40 +155,148 @@ function compileSubset(schema, mode) {
|
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
// src/commerce/
|
|
158
|
+
// src/commerce/purpose-output.ts
|
|
159
159
|
import { z as z2 } from "zod";
|
|
160
|
+
var CANONICAL_PATTERNS = [
|
|
161
|
+
"^([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
|
+
"^[0-9]{1,18}(\\.[0-9]{1,6})?$",
|
|
163
|
+
"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
|
|
164
|
+
"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
|
|
165
|
+
];
|
|
166
|
+
var MONEY = CANONICAL_PATTERNS.find((pattern) => pattern.includes("1,18"));
|
|
167
|
+
var STRICT_DATETIME = CANONICAL_PATTERNS.find((pattern) => pattern.includes("2468"));
|
|
168
|
+
var DATETIME = CANONICAL_PATTERNS.find((pattern) => pattern !== MONEY && pattern !== STRICT_DATETIME);
|
|
169
|
+
var MINUTE_DATETIME = CANONICAL_PATTERNS[3];
|
|
170
|
+
var scalarTypes = ["string", "number", "integer", "boolean", "object", "array"];
|
|
171
|
+
var baseKeys = ["type", "description", "enum"];
|
|
172
|
+
var typeKeys = {
|
|
173
|
+
object: ["properties", "required", "additionalProperties"],
|
|
174
|
+
array: ["items", "minItems", "maxItems"],
|
|
175
|
+
string: ["minLength", "maxLength", "pattern", "format"],
|
|
176
|
+
number: ["minimum", "maximum"],
|
|
177
|
+
integer: ["minimum", "maximum"],
|
|
178
|
+
boolean: []
|
|
179
|
+
};
|
|
180
|
+
function record(value) {
|
|
181
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value) && [Object.prototype, null].includes(Object.getPrototypeOf(value)));
|
|
182
|
+
}
|
|
183
|
+
function datetime(value, allowMinutes = false) {
|
|
184
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?Z$/.exec(value);
|
|
185
|
+
if (!match || match[0].length !== value.length) return false;
|
|
186
|
+
const [, y, m, d, h, minute, second] = match;
|
|
187
|
+
if (!allowMinutes && second === void 0) return false;
|
|
188
|
+
const year = Number(y), month = Number(m), day = Number(d);
|
|
189
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
190
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
191
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= days[month - 1] && Number(h) <= 23 && Number(minute) <= 59 && Number(second ?? 0) <= 59;
|
|
192
|
+
}
|
|
193
|
+
function validateCommercePurposeOutputSchema(value) {
|
|
194
|
+
let nodes = 0, properties = 0;
|
|
195
|
+
function walk(raw, depth, root = false) {
|
|
196
|
+
if (depth > 8 || ++nodes > 256 || !record(raw)) return false;
|
|
197
|
+
const s = raw;
|
|
198
|
+
if (s.description !== void 0 && (typeof s.description !== "string" || s.description.length > 1e3)) return false;
|
|
199
|
+
if (Object.hasOwn(s, "anyOf")) return Object.keys(s).every((key) => ["anyOf", "description"].includes(key)) && Array.isArray(s.anyOf) && s.anyOf.length >= 2 && s.anyOf.length <= 4 && s.anyOf.every((branch) => walk(branch, depth + 1, root));
|
|
200
|
+
const nullable = Array.isArray(s.type);
|
|
201
|
+
if (nullable && (s.type.length !== 2 || s.type[1] !== "null")) return false;
|
|
202
|
+
const type = nullable ? s.type[0] : s.type;
|
|
203
|
+
if (typeof type !== "string" || !scalarTypes.includes(type) || root && (type !== "object" || nullable)) return false;
|
|
204
|
+
if (Object.keys(s).some((key) => ![...baseKeys, ...typeKeys[type]].includes(key))) return false;
|
|
205
|
+
if (s.enum !== void 0 && (!Array.isArray(s.enum) || s.enum.length < 1 || s.enum.length > 32 || new Set(s.enum.map((v) => canonicalJson(v))).size !== s.enum.length || s.enum.some((v) => v === null ? !nullable : typeof v !== (type === "integer" ? "number" : type) || type === "integer" && !Number.isSafeInteger(v) || typeof v === "object"))) return false;
|
|
206
|
+
for (const [min, max] of [["minLength", "maxLength"], ["minItems", "maxItems"], ["minimum", "maximum"]]) {
|
|
207
|
+
if ([s[min], s[max]].some((v) => v !== void 0 && (typeof v !== "number" || !Number.isFinite(v) || min !== "minimum" && (!Number.isSafeInteger(v) || v < 0)))) return false;
|
|
208
|
+
if (s[min] !== void 0 && s[max] !== void 0 && s[min] > s[max]) return false;
|
|
209
|
+
}
|
|
210
|
+
if (type === "string") return (s.maxLength === void 0 || s.maxLength <= 4096) && (s.minLength ?? 0) <= (s.maxLength ?? 4096) && (s.pattern === void 0 || CANONICAL_PATTERNS.includes(s.pattern)) && (s.format === void 0 || s.format === "uri" || s.format === "date-time");
|
|
211
|
+
if (type === "array") return (s.maxItems === void 0 || s.maxItems <= 128) && (s.minItems ?? 0) <= (s.maxItems ?? 128) && walk(s.items, depth + 1);
|
|
212
|
+
if (type === "object") {
|
|
213
|
+
if (s.additionalProperties !== false || !record(s.properties)) return false;
|
|
214
|
+
const names = Object.keys(s.properties);
|
|
215
|
+
properties += names.length;
|
|
216
|
+
return properties <= 128 && names.every(safeName) && (s.required === void 0 || Array.isArray(s.required) && new Set(s.required).size === s.required.length && s.required.every((name) => typeof name === "string" && names.includes(name))) && Object.values(s.properties).every((child) => walk(child, depth + 1));
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
return jsonBytes(value) <= 32768 && walk(value, 1, true);
|
|
222
|
+
} catch {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
var CommercePurposeOutputSchemaSchema = z2.custom(validateCommercePurposeOutputSchema);
|
|
227
|
+
function matches(schema, value) {
|
|
228
|
+
if (schema.anyOf) return schema.anyOf.some((branch) => matches(branch, value));
|
|
229
|
+
const nullable = Array.isArray(schema.type);
|
|
230
|
+
const type = nullable ? schema.type[0] : schema.type;
|
|
231
|
+
if (value === null) return nullable && (!schema.enum || schema.enum.includes(null));
|
|
232
|
+
if (schema.enum && !schema.enum.includes(value)) return false;
|
|
233
|
+
if (type === "string") {
|
|
234
|
+
if (typeof value !== "string" || value.length < (schema.minLength ?? 0) || value.length > (schema.maxLength ?? 4096)) return false;
|
|
235
|
+
if (schema.pattern === MONEY && (!/^[0-9]{1,18}(\.[0-9]{1,6})?$/.test(value) || /[\r\n]/.test(value))) return false;
|
|
236
|
+
if (schema.pattern === DATETIME && !datetime(value)) return false;
|
|
237
|
+
if ((schema.pattern === STRICT_DATETIME || schema.pattern === MINUTE_DATETIME || schema.format === "date-time") && !datetime(value, schema.pattern !== STRICT_DATETIME)) return false;
|
|
238
|
+
if (schema.format === "uri") {
|
|
239
|
+
try {
|
|
240
|
+
const url = new URL(value);
|
|
241
|
+
if (url.protocol !== "https:" || url.username || url.password || url.port) return false;
|
|
242
|
+
} catch {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
if (type === "boolean") return typeof value === "boolean";
|
|
249
|
+
if (type === "number" || type === "integer") return typeof value === "number" && Number.isFinite(value) && (type !== "integer" || Number.isSafeInteger(value)) && value >= (schema.minimum ?? -Infinity) && value <= (schema.maximum ?? Infinity);
|
|
250
|
+
if (type === "array") return Array.isArray(value) && value.length >= (schema.minItems ?? 0) && value.length <= (schema.maxItems ?? 128) && value.every((item) => matches(schema.items, item));
|
|
251
|
+
if (!record(value)) return false;
|
|
252
|
+
return Object.keys(value).every((key) => Object.hasOwn(schema.properties, key)) && (schema.required ?? []).every((key) => Object.hasOwn(value, key)) && Object.entries(value).every(([key, child]) => matches(schema.properties[key], child));
|
|
253
|
+
}
|
|
254
|
+
function compileCommercePurposeOutputSchema(raw) {
|
|
255
|
+
if (!validateCommercePurposeOutputSchema(raw)) throw new TypeError("Unsupported purpose output schema");
|
|
256
|
+
const snapshot = structuredClone(raw);
|
|
257
|
+
return z2.custom((value) => {
|
|
258
|
+
try {
|
|
259
|
+
return jsonBytes(value) <= 32768 && matches(snapshot, value);
|
|
260
|
+
} catch {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// src/commerce/external.ts
|
|
267
|
+
import { z as z3 } from "zod";
|
|
160
268
|
var utf8 = (value, maximum) => new TextEncoder().encode(value).length <= maximum;
|
|
161
|
-
var scalar =
|
|
269
|
+
var scalar = z3.union([z3.string().refine((value) => utf8(value, 2048)), z3.number().finite(), z3.boolean()]);
|
|
162
270
|
var ExternalQueryValueSchema = scalar;
|
|
163
|
-
var scalarOrNull =
|
|
164
|
-
var
|
|
165
|
-
var ExternalQueryMappingSchema =
|
|
166
|
-
|
|
167
|
-
|
|
271
|
+
var scalarOrNull = z3.union([scalar, z3.null()]);
|
|
272
|
+
var record2 = (item, max) => z3.record(z3.string().refine(safeName), item).refine((value) => Object.keys(value).length <= max);
|
|
273
|
+
var ExternalQueryMappingSchema = z3.union([
|
|
274
|
+
z3.strictObject({ input: z3.string().refine(safeName), omitIfMissing: z3.literal(true).optional() }),
|
|
275
|
+
z3.strictObject({ literal: scalar })
|
|
168
276
|
]);
|
|
169
|
-
var ExternalQueryMappingsSchema =
|
|
277
|
+
var ExternalQueryMappingsSchema = record2(ExternalQueryMappingSchema, 32).superRefine((value, ctx) => {
|
|
170
278
|
const reserved = /^(authorization|cookie|set-cookie|host|x-api-key|api_key|apikey|access_token|token|secret|password)$/i;
|
|
171
279
|
for (const key of Object.keys(value)) if (reserved.test(key)) ctx.addIssue({ code: "custom", path: [key], message: "Reserved query key" });
|
|
172
280
|
});
|
|
173
|
-
var ExternalPathSchema =
|
|
281
|
+
var ExternalPathSchema = z3.string().max(1024).refine(
|
|
174
282
|
(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 !== "..")
|
|
175
283
|
);
|
|
176
|
-
var mediaType =
|
|
284
|
+
var mediaType = z3.string().min(1).max(128).refine((value) => value === value.toLowerCase() && /^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/.test(value));
|
|
177
285
|
var jsonMime = (value) => value === "application/json" || /^application\/[a-z0-9!#$&^_.+-]+\+json$/.test(value);
|
|
178
286
|
var textMime = (value) => /^text\/[a-z0-9!#$&^_.+-]+$/.test(value) || value === "application/xml" || /^application\/[a-z0-9!#$&^_.+-]+\+xml$/.test(value) || jsonMime(value);
|
|
179
|
-
var ExternalResponseFormatSchema =
|
|
180
|
-
var FieldProjectionSchema =
|
|
181
|
-
var ResponseFilterSchema =
|
|
182
|
-
|
|
183
|
-
|
|
287
|
+
var ExternalResponseFormatSchema = z3.strictObject({ mode: z3.enum(["JSON", "TEXT"]), mediaTypes: z3.array(mediaType).min(1).max(8).refine((values) => new Set(values).size === values.length) }).refine((value) => value.mediaTypes.every(value.mode === "JSON" ? jsonMime : textMime));
|
|
288
|
+
var FieldProjectionSchema = record2(z3.strictObject({ path: z3.string().refine(safePath), omitIfMissing: z3.literal(true).optional() }), 32).refine((value) => Object.keys(value).length >= 1);
|
|
289
|
+
var ResponseFilterSchema = z3.discriminatedUnion("op", [
|
|
290
|
+
z3.strictObject({ path: z3.string().refine(safePath), op: z3.enum(["EQ", "NE", "GT", "GTE", "LT", "LTE", "CONTAINS", "STARTS_WITH"]), value: scalarOrNull }),
|
|
291
|
+
z3.strictObject({ path: z3.string().refine(safePath), op: z3.literal("IN"), values: z3.array(scalarOrNull).min(1).max(20) })
|
|
184
292
|
]);
|
|
185
|
-
var visualObject =
|
|
186
|
-
var visualList =
|
|
187
|
-
var VisualResponseProcessingSchema =
|
|
188
|
-
var ResponseProcessingSchema =
|
|
189
|
-
var TransformResponseSchema =
|
|
190
|
-
var TransformSampleSchema =
|
|
191
|
-
var boundedValues =
|
|
293
|
+
var visualObject = z3.strictObject({ kind: z3.literal("OBJECT"), fields: FieldProjectionSchema });
|
|
294
|
+
var visualList = z3.strictObject({ kind: z3.literal("LIST"), fields: FieldProjectionSchema, filters: z3.array(ResponseFilterSchema).max(8), sort: z3.union([z3.null(), z3.strictObject({ path: z3.string().refine(safePath), direction: z3.enum(["ASC", "DESC"]) })]), limit: z3.int().min(1).max(20) });
|
|
295
|
+
var VisualResponseProcessingSchema = z3.union([visualObject, visualList]);
|
|
296
|
+
var ResponseProcessingSchema = z3.union([VisualResponseProcessingSchema, z3.strictObject({ kind: z3.literal("JAVASCRIPT"), runtimeVersion: z3.literal("quickjs-sync.v1"), source: z3.string().min(1).refine((value) => utf8(value, 16384)) })]);
|
|
297
|
+
var TransformResponseSchema = z3.strictObject({ status: z3.int().min(200).max(299), contentType: z3.string().min(1).max(128), bodyText: z3.string().refine((value) => utf8(value, 262144)), json: z3.union([z3.null(), z3.json()]) });
|
|
298
|
+
var TransformSampleSchema = z3.strictObject({ status: z3.int().min(200).max(299), contentType: z3.string().min(1).max(128), bodyText: z3.string().refine((value) => utf8(value, 262144)) }).refine((value) => jsonBytes(value) <= 524288);
|
|
299
|
+
var boundedValues = z3.custom((value) => {
|
|
192
300
|
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)));
|
|
193
301
|
try {
|
|
194
302
|
return !!value && typeof value === "object" && !Array.isArray(value) && visit(value, 1) && jsonBytes(value) <= 49152;
|
|
@@ -196,24 +304,24 @@ var boundedValues = z2.custom((value) => {
|
|
|
196
304
|
return false;
|
|
197
305
|
}
|
|
198
306
|
});
|
|
199
|
-
var ExternalHttpResultDataSchema =
|
|
200
|
-
var ConnectionRevisionViewSchema =
|
|
201
|
-
var ConnectionViewSchema =
|
|
202
|
-
var CredentialStatusSchema =
|
|
203
|
-
var ConnectionCommandSchema =
|
|
204
|
-
var RevisionInputSchema =
|
|
205
|
-
var ConnectionIssueSchema =
|
|
206
|
-
var ConnectionResultSchema = (value) =>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
307
|
+
var ExternalHttpResultDataSchema = z3.strictObject({ source: z3.literal("EXTERNAL_HTTP"), connectionRevisionId: IdSchema, observedAt: DateSchema, values: boundedValues });
|
|
308
|
+
var ConnectionRevisionViewSchema = z3.strictObject({ id: IdSchema, connectionId: IdSchema, revisionNumber: z3.int().positive(), origin: z3.string().min(1).max(2048), scope: z3.enum(["PLATFORM", "PER_SHOP"]), authMode: z3.enum(["NONE", "BEARER", "API_KEY"]), authHeader: z3.string().min(1).max(128).nullable(), documentation: z3.string().max(16e3), createdAt: z3.iso.datetime({ offset: false }) });
|
|
309
|
+
var ConnectionViewSchema = z3.strictObject({ id: IdSchema, key: z3.string().regex(/^[a-z][a-z0-9_]{0,127}$/), displayName: z3.string().min(1).max(255), description: z3.string().max(4096), enabled: z3.boolean(), editVersion: z3.int().positive(), revisions: z3.array(ConnectionRevisionViewSchema) });
|
|
310
|
+
var CredentialStatusSchema = z3.strictObject({ connectionRevisionId: IdSchema, shopId: IdSchema.nullable(), configured: z3.boolean(), editVersion: z3.int().positive().nullable(), updatedAt: z3.iso.datetime({ offset: false }).nullable() });
|
|
311
|
+
var ConnectionCommandSchema = z3.strictObject({ operationId: IdSchema, reason: z3.string().trim().min(1).max(1e3) });
|
|
312
|
+
var RevisionInputSchema = z3.strictObject({ origin: z3.string().min(1).max(2048), scope: z3.enum(["PLATFORM", "PER_SHOP"]), authMode: z3.enum(["NONE", "BEARER", "API_KEY"]), authHeader: z3.string().min(1).max(128).nullable(), documentation: z3.string().max(16e3) });
|
|
313
|
+
var ConnectionIssueSchema = z3.strictObject({ path: z3.string().max(256), message: z3.string().min(1).max(512) });
|
|
314
|
+
var ConnectionResultSchema = (value) => z3.discriminatedUnion("kind", [
|
|
315
|
+
z3.strictObject({ kind: z3.literal("ok"), value }),
|
|
316
|
+
z3.strictObject({ kind: z3.literal("not-found") }),
|
|
317
|
+
z3.strictObject({ kind: z3.literal("forbidden") }),
|
|
318
|
+
z3.strictObject({ kind: z3.literal("unavailable") }),
|
|
319
|
+
z3.strictObject({ kind: z3.literal("invalid"), issues: z3.array(ConnectionIssueSchema).max(32) }),
|
|
320
|
+
z3.strictObject({ kind: z3.literal("conflict"), code: z3.enum(["STALE_CAS", "CONFLICTING_REPLAY"]) })
|
|
213
321
|
]);
|
|
214
322
|
|
|
215
323
|
// src/commerce/definitions.ts
|
|
216
|
-
import { z as
|
|
324
|
+
import { z as z4 } from "zod";
|
|
217
325
|
import { gt } from "semver";
|
|
218
326
|
|
|
219
327
|
// src/commerce/definition-size.ts
|
|
@@ -254,21 +362,21 @@ var definitionFitsStorage = (value) => {
|
|
|
254
362
|
var DEFINITION_SIZE_MESSAGE = "Definition exceeds the 65536-byte jsonb text limit";
|
|
255
363
|
|
|
256
364
|
// src/commerce/definitions.ts
|
|
257
|
-
var ToolNameSchema =
|
|
258
|
-
var CommerceExecutionPurposeSchema =
|
|
259
|
-
var CommercePurposeProfileSchema =
|
|
365
|
+
var ToolNameSchema = z4.string().regex(/^[a-z][a-z0-9_]{0,127}$/).refine((n) => n !== "finalResponse");
|
|
366
|
+
var CommerceExecutionPurposeSchema = z4.literal("INITIAL_RECOVERY_OUTREACH");
|
|
367
|
+
var CommercePurposeProfileSchema = z4.strictObject({
|
|
260
368
|
purpose: CommerceExecutionPurposeSchema,
|
|
261
369
|
featureId: IdSchema,
|
|
262
370
|
releaseId: IdSchema,
|
|
263
|
-
behaviourPrompt:
|
|
264
|
-
capabilities:
|
|
371
|
+
behaviourPrompt: z4.string().refine((value) => new TextEncoder().encode(value).length <= 32768),
|
|
372
|
+
capabilities: z4.array(z4.strictObject({
|
|
265
373
|
capabilityId: IdSchema,
|
|
266
374
|
toolId: IdSchema,
|
|
267
375
|
revisionId: IdSchema,
|
|
268
376
|
name: ToolNameSchema,
|
|
269
|
-
position:
|
|
377
|
+
position: z4.number().int().nonnegative(),
|
|
270
378
|
inputSchema: InputSchemaSchema,
|
|
271
|
-
outputSchema:
|
|
379
|
+
outputSchema: CommercePurposeOutputSchemaSchema
|
|
272
380
|
})).min(1, { message: "PROFILE_EMPTY" }).max(32)
|
|
273
381
|
}).superRefine((profile, ctx) => {
|
|
274
382
|
const members = profile.capabilities;
|
|
@@ -288,52 +396,52 @@ var CommercePurposeProfileSchema = z3.strictObject({
|
|
|
288
396
|
function requireCommercePurposeProfile(raw) {
|
|
289
397
|
return CommercePurposeProfileSchema.parse(raw);
|
|
290
398
|
}
|
|
291
|
-
var PublishedGrantedToolSchema =
|
|
399
|
+
var PublishedGrantedToolSchema = z4.strictObject({
|
|
292
400
|
toolId: IdSchema,
|
|
293
401
|
toolRevisionId: IdSchema,
|
|
294
402
|
toolName: ToolNameSchema,
|
|
295
403
|
definitionVersion: SemverSchema,
|
|
296
|
-
capabilityKeys:
|
|
404
|
+
capabilityKeys: z4.array(IdSchema).min(1).max(32).refine((v) => distinct(v) && v.join("\0") === [...v].sort().join("\0"))
|
|
297
405
|
});
|
|
298
|
-
var PublishedToolDescriptorSchema =
|
|
406
|
+
var PublishedToolDescriptorSchema = z4.strictObject({
|
|
299
407
|
toolId: IdSchema,
|
|
300
408
|
toolRevisionId: IdSchema,
|
|
301
409
|
name: ToolNameSchema,
|
|
302
410
|
definitionVersion: SemverSchema,
|
|
303
|
-
description:
|
|
411
|
+
description: z4.string().min(1).max(4096),
|
|
304
412
|
inputSchema: InputSchemaSchema
|
|
305
413
|
});
|
|
306
|
-
var CommerceBuiltInToolNameSchema =
|
|
414
|
+
var CommerceBuiltInToolNameSchema = z4.enum([
|
|
307
415
|
"commerce_get_discount_options",
|
|
308
416
|
"commerce_get_discount_details"
|
|
309
417
|
]).meta({ maxLength: 29 });
|
|
310
|
-
var CommerceBuiltInToolGrantSchema =
|
|
311
|
-
kind:
|
|
418
|
+
var CommerceBuiltInToolGrantSchema = z4.strictObject({
|
|
419
|
+
kind: z4.enum(["BUILT_IN"]).meta({ maxLength: 8 }),
|
|
312
420
|
toolName: CommerceBuiltInToolNameSchema,
|
|
313
|
-
definitionVersion:
|
|
421
|
+
definitionVersion: z4.enum(["2.0.0"]).meta({ maxLength: 5 })
|
|
314
422
|
});
|
|
315
|
-
var CommerceBuiltInToolDescriptorSchema =
|
|
316
|
-
kind:
|
|
423
|
+
var CommerceBuiltInToolDescriptorSchema = z4.strictObject({
|
|
424
|
+
kind: z4.enum(["BUILT_IN"]).meta({ maxLength: 8 }),
|
|
317
425
|
name: CommerceBuiltInToolNameSchema,
|
|
318
|
-
definitionVersion:
|
|
319
|
-
description:
|
|
426
|
+
definitionVersion: z4.enum(["2.0.0"]).meta({ maxLength: 5 }),
|
|
427
|
+
description: z4.string().min(1).max(4096),
|
|
320
428
|
inputSchema: InputSchemaSchema
|
|
321
429
|
});
|
|
322
|
-
var GrantedToolSchema =
|
|
323
|
-
var ToolDescriptorSchema =
|
|
324
|
-
var GrantedToolsSchema =
|
|
430
|
+
var GrantedToolSchema = z4.union([PublishedGrantedToolSchema, CommerceBuiltInToolGrantSchema]);
|
|
431
|
+
var ToolDescriptorSchema = z4.union([PublishedToolDescriptorSchema, CommerceBuiltInToolDescriptorSchema]);
|
|
432
|
+
var GrantedToolsSchema = z4.array(GrantedToolSchema).max(32).refine((values) => {
|
|
325
433
|
const published = values.filter((value) => !("kind" in value));
|
|
326
434
|
return distinct(values.map((value) => value.toolName)) && distinct(published.map((value) => value.toolId));
|
|
327
435
|
});
|
|
328
436
|
var isBuiltInTool = (value) => "kind" in value && value.kind === "BUILT_IN";
|
|
329
|
-
var MappingSchema =
|
|
330
|
-
|
|
331
|
-
input:
|
|
332
|
-
omitIfMissing:
|
|
437
|
+
var MappingSchema = z4.union([
|
|
438
|
+
z4.strictObject({
|
|
439
|
+
input: z4.string().refine(safeName),
|
|
440
|
+
omitIfMissing: z4.literal(true).optional()
|
|
333
441
|
}),
|
|
334
|
-
|
|
442
|
+
z4.strictObject({ literal: boundedJson(8192) })
|
|
335
443
|
]);
|
|
336
|
-
var MappingsSchema =
|
|
444
|
+
var MappingsSchema = z4.record(z4.string().refine(safeName), MappingSchema).refine((v) => Object.keys(v).length <= 32);
|
|
337
445
|
var POLICY_OPERATIONS = [
|
|
338
446
|
"taxonomy.resolveCategories",
|
|
339
447
|
"products.search",
|
|
@@ -347,15 +455,15 @@ var POLICY_OPERATIONS = [
|
|
|
347
455
|
"products.findQualifying",
|
|
348
456
|
"products.findSimilar"
|
|
349
457
|
];
|
|
350
|
-
var ExternalHttpExecutionSchema =
|
|
351
|
-
kind:
|
|
352
|
-
executorVersion:
|
|
458
|
+
var ExternalHttpExecutionSchema = z4.strictObject({
|
|
459
|
+
kind: z4.literal("EXTERNAL_HTTP"),
|
|
460
|
+
executorVersion: z4.literal("1.0.0"),
|
|
353
461
|
connectionRevisionId: IdSchema,
|
|
354
|
-
method:
|
|
462
|
+
method: z4.literal("GET"),
|
|
355
463
|
path: ExternalPathSchema,
|
|
356
464
|
query: ExternalQueryMappingsSchema,
|
|
357
465
|
responseFormat: ExternalResponseFormatSchema,
|
|
358
|
-
resultPath:
|
|
466
|
+
resultPath: z4.string().refine((value) => value === "" || safePath(value)),
|
|
359
467
|
responseProcessing: ResponseProcessingSchema,
|
|
360
468
|
resultSchema: DetailsSchemaSchema
|
|
361
469
|
}).superRefine((value, ctx) => {
|
|
@@ -364,21 +472,21 @@ var ExternalHttpExecutionSchema = z3.strictObject({
|
|
|
364
472
|
if (value.responseProcessing.kind !== "JAVASCRIPT" && value.responseFormat.mode !== "JSON")
|
|
365
473
|
ctx.addIssue({ code: "custom", path: ["responseFormat", "mode"], message: "Visual processing requires JSON" });
|
|
366
474
|
});
|
|
367
|
-
var CommerceExecutionSchema =
|
|
368
|
-
|
|
369
|
-
kind:
|
|
370
|
-
executorVersion:
|
|
371
|
-
apiVersion:
|
|
475
|
+
var CommerceExecutionSchema = z4.discriminatedUnion("kind", [
|
|
476
|
+
z4.strictObject({
|
|
477
|
+
kind: z4.literal("SHOPIFY_STOREFRONT_QUERY"),
|
|
478
|
+
executorVersion: z4.literal("1.0.0"),
|
|
479
|
+
apiVersion: z4.literal("2026-07"),
|
|
372
480
|
schemaHash: HashSchema,
|
|
373
|
-
document:
|
|
374
|
-
operationName:
|
|
481
|
+
document: z4.string().min(1).refine((v) => new TextEncoder().encode(v).length <= 16384),
|
|
482
|
+
operationName: z4.string().refine(safeName),
|
|
375
483
|
variables: MappingsSchema,
|
|
376
|
-
resultPath:
|
|
484
|
+
resultPath: z4.string().refine(safePath)
|
|
377
485
|
}),
|
|
378
|
-
|
|
379
|
-
kind:
|
|
380
|
-
operation:
|
|
381
|
-
operationVersion:
|
|
486
|
+
z4.strictObject({
|
|
487
|
+
kind: z4.literal("POLICY_OPERATION"),
|
|
488
|
+
operation: z4.enum(POLICY_OPERATIONS),
|
|
489
|
+
operationVersion: z4.literal("1.0.0"),
|
|
382
490
|
arguments: MappingsSchema
|
|
383
491
|
}),
|
|
384
492
|
ExternalHttpExecutionSchema
|
|
@@ -391,17 +499,17 @@ function tokensValid(text, root) {
|
|
|
391
499
|
);
|
|
392
500
|
return !residue.includes("{{") && !residue.includes("}}");
|
|
393
501
|
}
|
|
394
|
-
var fixed =
|
|
395
|
-
var ResponseTemplateSchema =
|
|
396
|
-
|
|
397
|
-
kind:
|
|
398
|
-
text:
|
|
502
|
+
var fixed = z4.string().max(4096).refine((v) => !/[<>]|\{\{|\}\}/.test(v));
|
|
503
|
+
var ResponseTemplateSchema = z4.discriminatedUnion("kind", [
|
|
504
|
+
z4.strictObject({
|
|
505
|
+
kind: z4.literal("text"),
|
|
506
|
+
text: z4.string().max(4096).refine((v) => tokensValid(v, "result")),
|
|
399
507
|
unavailable: fixed
|
|
400
508
|
}),
|
|
401
|
-
|
|
402
|
-
kind:
|
|
403
|
-
itemsPath:
|
|
404
|
-
item:
|
|
509
|
+
z4.strictObject({
|
|
510
|
+
kind: z4.literal("items"),
|
|
511
|
+
itemsPath: z4.string().refine(safePath),
|
|
512
|
+
item: z4.string().max(4096).refine((v) => tokensValid(v, "item")),
|
|
405
513
|
empty: fixed,
|
|
406
514
|
unavailable: fixed
|
|
407
515
|
})
|
|
@@ -409,11 +517,11 @@ var ResponseTemplateSchema = z3.discriminatedUnion("kind", [
|
|
|
409
517
|
var identity = {
|
|
410
518
|
name: ToolNameSchema,
|
|
411
519
|
definitionVersion: SemverSchema,
|
|
412
|
-
description:
|
|
520
|
+
description: z4.string().min(1).max(4096)
|
|
413
521
|
};
|
|
414
522
|
var forbiddenInput = /^(shopid|customerid|checkoutrecoveryid|conversationid|grantid|releaseid|token|accesstoken|domain|headers|url|graphql|document|authorization)$/i;
|
|
415
523
|
var forbiddenExternalInput = /^(authorization|cookie|set-cookie|host|x-api-key|api_key|apikey|access_token|token|secret|password)$/i;
|
|
416
|
-
var CommerceToolDefinitionSchema =
|
|
524
|
+
var CommerceToolDefinitionSchema = z4.strictObject({
|
|
417
525
|
...identity,
|
|
418
526
|
inputSchema: InputSchemaSchema,
|
|
419
527
|
execution: CommerceExecutionSchema,
|
|
@@ -449,7 +557,7 @@ var CommerceToolDefinitionSchema = z3.strictObject({
|
|
|
449
557
|
var draftObject = boundedJson(65536).refine(
|
|
450
558
|
(v) => !!v && typeof v === "object" && !Array.isArray(v)
|
|
451
559
|
);
|
|
452
|
-
var CommerceToolDraftDefinitionSchema =
|
|
560
|
+
var CommerceToolDraftDefinitionSchema = z4.strictObject({
|
|
453
561
|
...identity,
|
|
454
562
|
inputSchema: draftObject,
|
|
455
563
|
execution: draftObject,
|
|
@@ -542,12 +650,12 @@ function validateDefinitionVersion(proposed, highestPublished) {
|
|
|
542
650
|
SemverSchema.parse(highestPublished);
|
|
543
651
|
return gt(proposed, highestPublished);
|
|
544
652
|
}
|
|
545
|
-
var CommerceToolIdentitySchema =
|
|
653
|
+
var CommerceToolIdentitySchema = z4.strictObject({
|
|
546
654
|
id: IdSchema,
|
|
547
655
|
name: ToolNameSchema,
|
|
548
|
-
enabled:
|
|
656
|
+
enabled: z4.boolean()
|
|
549
657
|
});
|
|
550
|
-
var CommerceToolRevisionIdentitySchema =
|
|
658
|
+
var CommerceToolRevisionIdentitySchema = z4.strictObject({
|
|
551
659
|
toolId: IdSchema,
|
|
552
660
|
toolRevisionId: IdSchema,
|
|
553
661
|
definitionVersion: SemverSchema,
|
|
@@ -599,10 +707,10 @@ function isTrustedCommerceBuiltInGrant(value) {
|
|
|
599
707
|
}
|
|
600
708
|
|
|
601
709
|
// src/commerce/response.ts
|
|
602
|
-
import { z as
|
|
603
|
-
var CommerceResponseContractSchema =
|
|
604
|
-
version:
|
|
605
|
-
instructions:
|
|
710
|
+
import { z as z5 } from "zod";
|
|
711
|
+
var CommerceResponseContractSchema = z5.strictObject({
|
|
712
|
+
version: z5.literal("response.v1"),
|
|
713
|
+
instructions: z5.string().min(1).max(8e3),
|
|
606
714
|
detailsSchema: DetailsSchemaSchema
|
|
607
715
|
}).refine((v) => jsonBytes(v) <= 32768);
|
|
608
716
|
var EMPTY_RESPONSE_CONTRACT = {
|
|
@@ -615,31 +723,31 @@ var EMPTY_RESPONSE_CONTRACT = {
|
|
|
615
723
|
additionalProperties: false
|
|
616
724
|
}
|
|
617
725
|
};
|
|
618
|
-
var ReferralReasonSchema =
|
|
726
|
+
var ReferralReasonSchema = z5.enum([
|
|
619
727
|
"INSUFFICIENT_TOOLS",
|
|
620
728
|
"UNVERIFIABLE_FACTS",
|
|
621
729
|
"TOOL_UNAVAILABLE",
|
|
622
730
|
"TOOL_REVOKED"
|
|
623
731
|
]);
|
|
624
|
-
var DetectedLanguageTagSchema =
|
|
732
|
+
var DetectedLanguageTagSchema = z5.string().min(1).max(128).transform((value, ctx) => {
|
|
625
733
|
const canonical = canonicaliseLanguageTag(value);
|
|
626
734
|
if (!canonical) {
|
|
627
735
|
ctx.addIssue({
|
|
628
736
|
code: "custom",
|
|
629
737
|
message: "Invalid detected language tag"
|
|
630
738
|
});
|
|
631
|
-
return
|
|
739
|
+
return z5.NEVER;
|
|
632
740
|
}
|
|
633
741
|
return canonical;
|
|
634
742
|
});
|
|
635
|
-
var CommerceFinalResponseSchema =
|
|
636
|
-
answerKind:
|
|
637
|
-
replyText:
|
|
743
|
+
var CommerceFinalResponseSchema = z5.strictObject({
|
|
744
|
+
answerKind: z5.enum(["ANSWER", "REFER_TO_STORE"]),
|
|
745
|
+
replyText: z5.string().min(1).max(4096),
|
|
638
746
|
referralReason: ReferralReasonSchema.nullable(),
|
|
639
747
|
detectedLanguageTag: DetectedLanguageTagSchema.nullable(),
|
|
640
|
-
detectedLanguageConfidence:
|
|
641
|
-
evidenceIds:
|
|
642
|
-
details:
|
|
748
|
+
detectedLanguageConfidence: z5.number().min(0).max(1).nullable(),
|
|
749
|
+
evidenceIds: z5.array(IdSchema).max(3).refine((v) => new Set(v).size === v.length),
|
|
750
|
+
details: z5.record(z5.string(), z5.unknown()).refine((v) => {
|
|
643
751
|
try {
|
|
644
752
|
return jsonBytes(v) <= 16384;
|
|
645
753
|
} catch {
|
|
@@ -775,22 +883,22 @@ function finalResponseToolSchema(definition) {
|
|
|
775
883
|
}
|
|
776
884
|
|
|
777
885
|
// src/commerce/schemas.ts
|
|
778
|
-
import { z as
|
|
886
|
+
import { z as z6 } from "zod";
|
|
779
887
|
import { validRange } from "semver";
|
|
780
|
-
var CommerceTurnIdentitySchema =
|
|
888
|
+
var CommerceTurnIdentitySchema = z6.strictObject({
|
|
781
889
|
contractVersion: ContractVersionSchema,
|
|
782
890
|
shopId: IdSchema,
|
|
783
891
|
checkoutRecoveryId: IdSchema,
|
|
784
892
|
conversationId: IdSchema,
|
|
785
|
-
inboundVersion:
|
|
893
|
+
inboundVersion: z6.number().int().positive()
|
|
786
894
|
});
|
|
787
|
-
var CommerceConversationGrantSchema =
|
|
895
|
+
var CommerceConversationGrantSchema = z6.strictObject({
|
|
788
896
|
id: IdSchema,
|
|
789
897
|
shopId: IdSchema,
|
|
790
898
|
conversationId: IdSchema,
|
|
791
|
-
initialInboundVersion:
|
|
899
|
+
initialInboundVersion: z6.number().int().positive(),
|
|
792
900
|
releaseId: IdSchema,
|
|
793
|
-
selectedCapabilityKeys:
|
|
901
|
+
selectedCapabilityKeys: z6.array(IdSchema).max(32).refine(distinct),
|
|
794
902
|
purposeProfile: CommercePurposeProfileSchema.optional(),
|
|
795
903
|
grantedTools: GrantedToolsSchema,
|
|
796
904
|
runnerVersion: SemverSchema,
|
|
@@ -806,27 +914,27 @@ var CommerceConversationGrantSchema = z5.strictObject({
|
|
|
806
914
|
))
|
|
807
915
|
c.addIssue({ code: "custom", message: "Unselected grant provenance" });
|
|
808
916
|
});
|
|
809
|
-
var CommerceManifestSchema =
|
|
917
|
+
var CommerceManifestSchema = z6.strictObject({
|
|
810
918
|
contractVersion: ContractVersionSchema,
|
|
811
919
|
releaseId: IdSchema,
|
|
812
|
-
runnerCompatibility:
|
|
813
|
-
capabilities:
|
|
814
|
-
|
|
920
|
+
runnerCompatibility: z6.string().min(1).max(128).refine((v) => !!validRange(v)),
|
|
921
|
+
capabilities: z6.array(
|
|
922
|
+
z6.strictObject({
|
|
815
923
|
capabilityId: IdSchema,
|
|
816
924
|
key: IdSchema,
|
|
817
925
|
featureId: IdSchema,
|
|
818
|
-
position:
|
|
926
|
+
position: z6.number().int().nonnegative(),
|
|
819
927
|
toolDescriptor: PublishedToolDescriptorSchema
|
|
820
928
|
})
|
|
821
929
|
).max(32),
|
|
822
|
-
featureBehaviours:
|
|
823
|
-
|
|
930
|
+
featureBehaviours: z6.array(
|
|
931
|
+
z6.strictObject({
|
|
824
932
|
featureId: IdSchema,
|
|
825
|
-
behaviourPrompt:
|
|
933
|
+
behaviourPrompt: z6.string().max(32e3)
|
|
826
934
|
})
|
|
827
935
|
).max(32),
|
|
828
|
-
selectedCapabilityKeys:
|
|
829
|
-
builtInTools:
|
|
936
|
+
selectedCapabilityKeys: z6.array(IdSchema).max(32).refine(distinct),
|
|
937
|
+
builtInTools: z6.array(CommerceBuiltInToolDescriptorSchema).max(2).default([]),
|
|
830
938
|
purposeProfile: CommercePurposeProfileSchema.optional(),
|
|
831
939
|
grantedTools: GrantedToolsSchema,
|
|
832
940
|
responseContract: CommerceResponseContractSchema,
|
|
@@ -881,32 +989,32 @@ var CommerceManifestSchema = z5.strictObject({
|
|
|
881
989
|
message: "Grant must equal selected capability set"
|
|
882
990
|
});
|
|
883
991
|
});
|
|
884
|
-
var CommerceReleaseIdentitySchema =
|
|
992
|
+
var CommerceReleaseIdentitySchema = z6.strictObject({
|
|
885
993
|
contractVersion: ContractVersionSchema,
|
|
886
994
|
releaseId: IdSchema,
|
|
887
|
-
runnerCompatibility:
|
|
995
|
+
runnerCompatibility: z6.string().min(1).max(128).refine((v) => !!validRange(v))
|
|
888
996
|
});
|
|
889
997
|
var CommerceResolveAssertionSchema = CommerceTurnIdentitySchema.extend(
|
|
890
|
-
{ purpose:
|
|
998
|
+
{ purpose: z6.literal("resolve") }
|
|
891
999
|
);
|
|
892
1000
|
var CommerceExecuteAssertionSchema = CommerceTurnIdentitySchema.extend(
|
|
893
|
-
{ purpose:
|
|
1001
|
+
{ purpose: z6.literal("execute"), grantId: IdSchema, releaseId: IdSchema }
|
|
894
1002
|
);
|
|
895
|
-
var CommerceAssertionSchema =
|
|
1003
|
+
var CommerceAssertionSchema = z6.discriminatedUnion("purpose", [
|
|
896
1004
|
CommerceResolveAssertionSchema,
|
|
897
1005
|
CommerceExecuteAssertionSchema
|
|
898
1006
|
]);
|
|
899
|
-
var qty =
|
|
900
|
-
var CommerceProposalSchema =
|
|
901
|
-
operations:
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
kind:
|
|
1007
|
+
var qty = z6.number().int().min(1).max(999);
|
|
1008
|
+
var CommerceProposalSchema = z6.strictObject({
|
|
1009
|
+
operations: z6.array(
|
|
1010
|
+
z6.discriminatedUnion("kind", [
|
|
1011
|
+
z6.strictObject({
|
|
1012
|
+
kind: z6.literal("ADD"),
|
|
905
1013
|
variantId: IdSchema,
|
|
906
1014
|
quantity: qty
|
|
907
1015
|
}),
|
|
908
|
-
|
|
909
|
-
kind:
|
|
1016
|
+
z6.strictObject({
|
|
1017
|
+
kind: z6.literal("REPLACE"),
|
|
910
1018
|
lineId: IdSchema,
|
|
911
1019
|
variantId: IdSchema,
|
|
912
1020
|
quantity: qty
|
|
@@ -918,13 +1026,13 @@ var CommerceProposalSchema = z5.strictObject({
|
|
|
918
1026
|
v.operations.flatMap((o) => o.kind === "REPLACE" ? [o.lineId] : [])
|
|
919
1027
|
)
|
|
920
1028
|
);
|
|
921
|
-
var CommerceBasketSchema =
|
|
1029
|
+
var CommerceBasketSchema = z6.strictObject({
|
|
922
1030
|
basketId: IdSchema,
|
|
923
|
-
source:
|
|
1031
|
+
source: z6.enum(["RECOVERY_SNAPSHOT", "PROPOSED"]),
|
|
924
1032
|
observedAt: DateSchema,
|
|
925
1033
|
currency: CurrencySchema.nullable(),
|
|
926
|
-
lines:
|
|
927
|
-
|
|
1034
|
+
lines: z6.array(
|
|
1035
|
+
z6.strictObject({
|
|
928
1036
|
lineId: IdSchema,
|
|
929
1037
|
productId: IdSchema.nullable(),
|
|
930
1038
|
variantId: IdSchema.nullable(),
|
|
@@ -933,35 +1041,89 @@ var CommerceBasketSchema = z5.strictObject({
|
|
|
933
1041
|
})
|
|
934
1042
|
).max(100),
|
|
935
1043
|
fingerprint: HashSchema,
|
|
936
|
-
unknownFields:
|
|
1044
|
+
unknownFields: z6.array(z6.string().min(1).max(256)).max(128)
|
|
937
1045
|
}).refine((v) => distinct(v.lines.map((line) => line.lineId)));
|
|
938
|
-
var CommerceProductSaleEvidenceSchema =
|
|
1046
|
+
var CommerceProductSaleEvidenceSchema = z6.strictObject({
|
|
939
1047
|
regularPrice: MoneySchema.nullable(),
|
|
940
1048
|
salePrice: MoneySchema.nullable(),
|
|
941
1049
|
observedAt: DateSchema
|
|
942
1050
|
});
|
|
943
|
-
var
|
|
1051
|
+
var optionLabel = z6.string().transform((value) => value.replace(/[\r\n\t]+/g, " ").trim()).pipe(z6.string().min(1).max(128).refine((value) => !/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/.test(value)));
|
|
1052
|
+
function normalizeCommerceProductOptions(raw) {
|
|
1053
|
+
if (raw === void 0 || raw === null) return { status: "NOT_PROVIDED", items: [] };
|
|
1054
|
+
const source = raw;
|
|
1055
|
+
if (!Array.isArray(source.items)) return { status: "PARTIAL", items: [] };
|
|
1056
|
+
let partial = !["AVAILABLE", "NOT_PROVIDED"].includes(String(source.status)) || source.items.length > 16 || source.status === "NOT_PROVIDED" && source.items.length > 0;
|
|
1057
|
+
const items = [];
|
|
1058
|
+
const names = /* @__PURE__ */ new Set();
|
|
1059
|
+
for (const value of source.items.slice(0, 16)) {
|
|
1060
|
+
if (!value || typeof value !== "object") {
|
|
1061
|
+
partial = true;
|
|
1062
|
+
continue;
|
|
1063
|
+
}
|
|
1064
|
+
const item = value;
|
|
1065
|
+
const name = optionLabel.safeParse(item.name);
|
|
1066
|
+
if (!name.success || !Array.isArray(item.values)) {
|
|
1067
|
+
partial = true;
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
if (names.has(name.data)) continue;
|
|
1071
|
+
names.add(name.data);
|
|
1072
|
+
const values = [];
|
|
1073
|
+
if (item.values.length > 64) partial = true;
|
|
1074
|
+
for (const rawValue of item.values.slice(0, 64)) {
|
|
1075
|
+
const parsed = optionLabel.safeParse(rawValue);
|
|
1076
|
+
if (!parsed.success) {
|
|
1077
|
+
if (!(typeof rawValue === "string" && rawValue.trim() === "")) partial = true;
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
if (!values.includes(parsed.data)) values.push(parsed.data);
|
|
1081
|
+
}
|
|
1082
|
+
if (item.usedForVariants !== null && typeof item.usedForVariants !== "boolean") partial = true;
|
|
1083
|
+
items.push({ name: name.data, values, usedForVariants: typeof item.usedForVariants === "boolean" ? item.usedForVariants : null });
|
|
1084
|
+
}
|
|
1085
|
+
return { status: partial ? "PARTIAL" : items.length ? "AVAILABLE" : "NOT_PROVIDED", items };
|
|
1086
|
+
}
|
|
1087
|
+
var CommerceProductOptionsSchema = z6.preprocess(normalizeCommerceProductOptions, z6.strictObject({
|
|
1088
|
+
status: z6.enum(["AVAILABLE", "NOT_PROVIDED", "PARTIAL"]),
|
|
1089
|
+
items: z6.array(z6.strictObject({ name: optionLabel, values: z6.array(optionLabel).max(64), usedForVariants: z6.boolean().nullable() })).max(16)
|
|
1090
|
+
}));
|
|
1091
|
+
function normalizeCommerceProductSelectedOptions(raw) {
|
|
1092
|
+
if (!Array.isArray(raw)) return [];
|
|
1093
|
+
const result = [];
|
|
1094
|
+
for (const entry of raw.slice(0, 16)) {
|
|
1095
|
+
if (!entry || typeof entry !== "object") continue;
|
|
1096
|
+
const item = entry;
|
|
1097
|
+
const name = optionLabel.safeParse(item.name), value = optionLabel.safeParse(item.value);
|
|
1098
|
+
if (name.success && value.success && !result.some((e) => e.name === name.data && e.value === value.data)) result.push({ name: name.data, value: value.data });
|
|
1099
|
+
}
|
|
1100
|
+
return result;
|
|
1101
|
+
}
|
|
1102
|
+
var CommerceProductSelectedOptionsSchema = z6.preprocess(normalizeCommerceProductSelectedOptions, z6.array(z6.strictObject({ name: optionLabel, value: optionLabel })).max(16));
|
|
1103
|
+
var CommerceProductSchema = z6.strictObject({
|
|
1104
|
+
options: CommerceProductOptionsSchema.optional(),
|
|
1105
|
+
selectedOptions: CommerceProductSelectedOptionsSchema.optional(),
|
|
944
1106
|
productId: IdSchema,
|
|
945
1107
|
variantId: IdSchema.nullable(),
|
|
946
|
-
title:
|
|
947
|
-
url:
|
|
1108
|
+
title: z6.string().min(1).max(512),
|
|
1109
|
+
url: z6.url({ protocol: /^https$/ }).refine((v) => {
|
|
948
1110
|
const u = new URL(v);
|
|
949
1111
|
return !u.username && !u.password && !u.port;
|
|
950
1112
|
}).nullable(),
|
|
951
|
-
available:
|
|
1113
|
+
available: z6.boolean().nullable(),
|
|
952
1114
|
unitPrice: MoneySchema.nullable(),
|
|
953
1115
|
currency: CurrencySchema.nullable(),
|
|
954
|
-
productType:
|
|
955
|
-
vendor:
|
|
956
|
-
categories:
|
|
957
|
-
categoryIds:
|
|
958
|
-
collectionIds:
|
|
959
|
-
imageUrl:
|
|
1116
|
+
productType: z6.string().max(512).nullable(),
|
|
1117
|
+
vendor: z6.string().max(512).nullable(),
|
|
1118
|
+
categories: z6.array(z6.string()).optional(),
|
|
1119
|
+
categoryIds: z6.array(IdSchema).max(128).optional(),
|
|
1120
|
+
collectionIds: z6.array(IdSchema).max(128).optional(),
|
|
1121
|
+
imageUrl: z6.string().nullable().optional(),
|
|
960
1122
|
saleEvidence: CommerceProductSaleEvidenceSchema.nullable().optional(),
|
|
961
1123
|
observedAt: DateSchema
|
|
962
1124
|
});
|
|
963
1125
|
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])/;
|
|
964
|
-
var CommerceDiscountDateTimeSchema =
|
|
1126
|
+
var CommerceDiscountDateTimeSchema = z6.string().regex(discountUtcPattern).refine((value) => {
|
|
965
1127
|
const match = discountUtcPattern.exec(value);
|
|
966
1128
|
if (!match) return false;
|
|
967
1129
|
const [year, month, day, hour, minute, second] = match.slice(1).map(Number);
|
|
@@ -970,36 +1132,36 @@ var CommerceDiscountDateTimeSchema = z5.string().regex(discountUtcPattern).refin
|
|
|
970
1132
|
const daysInMonth = [31, leapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
971
1133
|
return day >= 1 && day <= daysInMonth[month - 1];
|
|
972
1134
|
}, "Expected a valid UTC discount timestamp with seconds");
|
|
973
|
-
var CommerceOfferSchema =
|
|
1135
|
+
var CommerceOfferSchema = z6.strictObject({
|
|
974
1136
|
offerId: IdSchema,
|
|
975
|
-
title:
|
|
976
|
-
method:
|
|
977
|
-
code:
|
|
1137
|
+
title: z6.string().min(1).max(512),
|
|
1138
|
+
method: z6.enum(["AUTOMATIC", "CODE"]),
|
|
1139
|
+
code: z6.string().min(1).max(128).nullable(),
|
|
978
1140
|
startsAt: CommerceDiscountDateTimeSchema.nullable(),
|
|
979
1141
|
endsAt: CommerceDiscountDateTimeSchema.nullable(),
|
|
980
|
-
support:
|
|
981
|
-
reasonCodes:
|
|
1142
|
+
support: z6.enum(["SUPPORTED", "UNSUPPORTED", "UNKNOWN"]),
|
|
1143
|
+
reasonCodes: z6.array(z6.string().min(1).max(64)).max(16)
|
|
982
1144
|
}).refine(
|
|
983
1145
|
(v) => (v.startsAt === null || v.endsAt === null || Date.parse(v.startsAt) < Date.parse(v.endsAt)) && (v.method !== "AUTOMATIC" || v.code === null)
|
|
984
1146
|
);
|
|
985
|
-
var CommerceDiscountCombinationFactsSchema =
|
|
986
|
-
discountClasses:
|
|
987
|
-
shopifyPlus:
|
|
988
|
-
combinesWith:
|
|
989
|
-
orderDiscounts:
|
|
990
|
-
productDiscounts:
|
|
991
|
-
shippingDiscounts:
|
|
1147
|
+
var CommerceDiscountCombinationFactsSchema = z6.strictObject({
|
|
1148
|
+
discountClasses: z6.array(z6.enum(["ORDER", "PRODUCT", "SHIPPING"])).max(3).nullable(),
|
|
1149
|
+
shopifyPlus: z6.boolean().nullable(),
|
|
1150
|
+
combinesWith: z6.strictObject({
|
|
1151
|
+
orderDiscounts: z6.boolean().nullable(),
|
|
1152
|
+
productDiscounts: z6.boolean().nullable(),
|
|
1153
|
+
shippingDiscounts: z6.boolean().nullable()
|
|
992
1154
|
}).nullable(),
|
|
993
|
-
discountTags:
|
|
994
|
-
allowedSameLineProductTags:
|
|
1155
|
+
discountTags: z6.array(z6.string().min(1).max(128)).max(64).nullable(),
|
|
1156
|
+
allowedSameLineProductTags: z6.array(z6.string().min(1).max(128)).max(64).nullable()
|
|
995
1157
|
});
|
|
996
|
-
var CommerceDiscountConditionFactsSchema =
|
|
997
|
-
provider:
|
|
998
|
-
completeness:
|
|
1158
|
+
var CommerceDiscountConditionFactsSchema = z6.strictObject({
|
|
1159
|
+
provider: z6.enum(["SHOPIFY", "WOOCOMMERCE"]),
|
|
1160
|
+
completeness: z6.enum(["COMPLETE", "PARTIAL", "UNKNOWN"]),
|
|
999
1161
|
observedAt: CommerceDiscountDateTimeSchema,
|
|
1000
|
-
providerStatus:
|
|
1162
|
+
providerStatus: z6.string().max(64),
|
|
1001
1163
|
unavailableAt: CommerceDiscountDateTimeSchema.nullable(),
|
|
1002
|
-
discountKind:
|
|
1164
|
+
discountKind: z6.enum([
|
|
1003
1165
|
"PERCENTAGE",
|
|
1004
1166
|
"FIXED_AMOUNT",
|
|
1005
1167
|
"FREE_SHIPPING",
|
|
@@ -1009,8 +1171,8 @@ var CommerceDiscountConditionFactsSchema = z5.strictObject({
|
|
|
1009
1171
|
]),
|
|
1010
1172
|
discountValue: MoneySchema.nullable(),
|
|
1011
1173
|
discountCurrency: CurrencySchema.nullable(),
|
|
1012
|
-
targeting:
|
|
1013
|
-
kind:
|
|
1174
|
+
targeting: z6.strictObject({
|
|
1175
|
+
kind: z6.enum([
|
|
1014
1176
|
"ALL",
|
|
1015
1177
|
"PRODUCTS",
|
|
1016
1178
|
"VARIANTS",
|
|
@@ -1019,38 +1181,38 @@ var CommerceDiscountConditionFactsSchema = z5.strictObject({
|
|
|
1019
1181
|
"MIXED",
|
|
1020
1182
|
"UNKNOWN"
|
|
1021
1183
|
]),
|
|
1022
|
-
includedProductIds:
|
|
1023
|
-
includedVariantIds:
|
|
1024
|
-
includedCategoryIds:
|
|
1025
|
-
includedCollectionIds:
|
|
1026
|
-
excludedProductIds:
|
|
1027
|
-
excludedVariantIds:
|
|
1028
|
-
excludedCategoryIds:
|
|
1029
|
-
excludedCollectionIds:
|
|
1184
|
+
includedProductIds: z6.array(IdSchema).max(128),
|
|
1185
|
+
includedVariantIds: z6.array(IdSchema).max(128),
|
|
1186
|
+
includedCategoryIds: z6.array(IdSchema).max(128),
|
|
1187
|
+
includedCollectionIds: z6.array(IdSchema).max(128),
|
|
1188
|
+
excludedProductIds: z6.array(IdSchema).max(128),
|
|
1189
|
+
excludedVariantIds: z6.array(IdSchema).max(128),
|
|
1190
|
+
excludedCategoryIds: z6.array(IdSchema).max(128),
|
|
1191
|
+
excludedCollectionIds: z6.array(IdSchema).max(128)
|
|
1030
1192
|
}),
|
|
1031
1193
|
minimumSubtotal: MoneySchema.nullable(),
|
|
1032
1194
|
maximumSubtotal: MoneySchema.nullable(),
|
|
1033
1195
|
subtotalRequirementCurrency: CurrencySchema.nullable(),
|
|
1034
|
-
minimumQuantity:
|
|
1035
|
-
usageLimit:
|
|
1036
|
-
usageCount:
|
|
1037
|
-
perCustomerLimit:
|
|
1038
|
-
customerScope:
|
|
1039
|
-
excludesSaleItems:
|
|
1040
|
-
individualUse:
|
|
1196
|
+
minimumQuantity: z6.number().int().nonnegative().nullable(),
|
|
1197
|
+
usageLimit: z6.number().int().nonnegative().nullable(),
|
|
1198
|
+
usageCount: z6.number().int().nonnegative().nullable(),
|
|
1199
|
+
perCustomerLimit: z6.number().int().nonnegative().nullable(),
|
|
1200
|
+
customerScope: z6.enum(["ALL", "RESTRICTED", "UNKNOWN"]),
|
|
1201
|
+
excludesSaleItems: z6.boolean().nullable(),
|
|
1202
|
+
individualUse: z6.boolean().nullable(),
|
|
1041
1203
|
combination: CommerceDiscountCombinationFactsSchema,
|
|
1042
|
-
unrepresentedConditions:
|
|
1204
|
+
unrepresentedConditions: z6.array(z6.string().min(1).max(128)).max(24)
|
|
1043
1205
|
});
|
|
1044
|
-
var CommerceDiscountDetailsSchema =
|
|
1206
|
+
var CommerceDiscountDetailsSchema = z6.strictObject({
|
|
1045
1207
|
offer: CommerceOfferSchema,
|
|
1046
1208
|
facts: CommerceDiscountConditionFactsSchema,
|
|
1047
|
-
providerDiscountId:
|
|
1209
|
+
providerDiscountId: z6.string().min(1).max(191).nullable()
|
|
1048
1210
|
});
|
|
1049
|
-
var condition =
|
|
1050
|
-
code:
|
|
1051
|
-
description:
|
|
1211
|
+
var condition = z6.strictObject({
|
|
1212
|
+
code: z6.string().min(1).max(64),
|
|
1213
|
+
description: z6.string().max(256)
|
|
1052
1214
|
});
|
|
1053
|
-
var CommerceEvidenceSchema =
|
|
1215
|
+
var CommerceEvidenceSchema = z6.strictObject({
|
|
1054
1216
|
evidenceId: HashSchema,
|
|
1055
1217
|
turn: CommerceTurnIdentitySchema,
|
|
1056
1218
|
grantId: IdSchema,
|
|
@@ -1061,7 +1223,7 @@ var CommerceEvidenceSchema = z5.strictObject({
|
|
|
1061
1223
|
ruleFingerprint: HashSchema,
|
|
1062
1224
|
evaluatedAt: DateSchema,
|
|
1063
1225
|
expiresAt: DateSchema,
|
|
1064
|
-
outcome:
|
|
1226
|
+
outcome: z6.enum([
|
|
1065
1227
|
"QUALIFIES_FOR_KNOWN_RULES",
|
|
1066
1228
|
"DOES_NOT_QUALIFY",
|
|
1067
1229
|
"UNKNOWN",
|
|
@@ -1070,8 +1232,8 @@ var CommerceEvidenceSchema = z5.strictObject({
|
|
|
1070
1232
|
currency: CurrencySchema.nullable(),
|
|
1071
1233
|
savings: MoneySchema.nullable(),
|
|
1072
1234
|
resultingTotal: MoneySchema.nullable(),
|
|
1073
|
-
evaluatedConditions:
|
|
1074
|
-
unresolvedConditions:
|
|
1235
|
+
evaluatedConditions: z6.array(condition).max(32),
|
|
1236
|
+
unresolvedConditions: z6.array(condition).max(32)
|
|
1075
1237
|
}).superRefine((v, c) => {
|
|
1076
1238
|
if (Date.parse(v.expiresAt) - Date.parse(v.evaluatedAt) > 6e4)
|
|
1077
1239
|
c.addIssue({
|
|
@@ -1081,16 +1243,16 @@ var CommerceEvidenceSchema = z5.strictObject({
|
|
|
1081
1243
|
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))
|
|
1082
1244
|
c.addIssue({ code: "custom", message: "Unsupported qualifying claim" });
|
|
1083
1245
|
});
|
|
1084
|
-
var CommerceAlternativeSchema =
|
|
1246
|
+
var CommerceAlternativeSchema = z6.strictObject({
|
|
1085
1247
|
product: CommerceProductSchema,
|
|
1086
1248
|
proposal: CommerceProposalSchema,
|
|
1087
1249
|
extraSpend: MoneySchema.nullable(),
|
|
1088
1250
|
resultingTotal: MoneySchema.nullable(),
|
|
1089
1251
|
currency: CurrencySchema.nullable(),
|
|
1090
1252
|
evidence: CommerceEvidenceSchema.nullable(),
|
|
1091
|
-
similarityReasons:
|
|
1253
|
+
similarityReasons: z6.array(z6.string().max(256)).max(3)
|
|
1092
1254
|
}).refine((v) => v.product.available === true);
|
|
1093
|
-
var CommerceErrorCodeSchema =
|
|
1255
|
+
var CommerceErrorCodeSchema = z6.enum([
|
|
1094
1256
|
"INVALID_INPUT",
|
|
1095
1257
|
"DENIED",
|
|
1096
1258
|
"STALE_TURN",
|
|
@@ -1101,182 +1263,184 @@ var CommerceErrorCodeSchema = z5.enum([
|
|
|
1101
1263
|
"INCOMPATIBLE_VERSION"
|
|
1102
1264
|
]);
|
|
1103
1265
|
function commerceToolResultSchema(data) {
|
|
1104
|
-
return
|
|
1105
|
-
|
|
1266
|
+
return z6.union([
|
|
1267
|
+
z6.strictObject({
|
|
1106
1268
|
contractVersion: ContractVersionSchema,
|
|
1107
|
-
status:
|
|
1269
|
+
status: z6.literal("OK"),
|
|
1108
1270
|
data,
|
|
1109
|
-
renderedText:
|
|
1271
|
+
renderedText: z6.string().max(4096)
|
|
1110
1272
|
}),
|
|
1111
|
-
|
|
1273
|
+
z6.strictObject({
|
|
1112
1274
|
contractVersion: ContractVersionSchema,
|
|
1113
|
-
status:
|
|
1275
|
+
status: z6.literal("ERROR"),
|
|
1114
1276
|
code: CommerceErrorCodeSchema,
|
|
1115
|
-
retryable:
|
|
1116
|
-
renderedText:
|
|
1277
|
+
retryable: z6.boolean(),
|
|
1278
|
+
renderedText: z6.string().max(4096).optional()
|
|
1117
1279
|
})
|
|
1118
1280
|
]);
|
|
1119
1281
|
}
|
|
1120
1282
|
var CommerceToolResultSchema = commerceToolResultSchema(
|
|
1121
1283
|
boundedJson(262144)
|
|
1122
1284
|
);
|
|
1123
|
-
var wireId =
|
|
1124
|
-
var taxonomySource =
|
|
1125
|
-
var CommerceCategoryCandidateSchema =
|
|
1285
|
+
var wireId = z6.string().min(1).max(128);
|
|
1286
|
+
var taxonomySource = z6.enum(["SHOPIFY_STANDARD_PRODUCT_TAXONOMY"]).meta({ maxLength: 33 });
|
|
1287
|
+
var CommerceCategoryCandidateSchema = z6.strictObject({
|
|
1126
1288
|
categoryId: wireId,
|
|
1127
|
-
name:
|
|
1128
|
-
fullName:
|
|
1289
|
+
name: z6.string().min(1).max(512),
|
|
1290
|
+
fullName: z6.string().min(1).max(4096),
|
|
1129
1291
|
parentId: wireId.nullable(),
|
|
1130
|
-
level:
|
|
1131
|
-
ancestorIds:
|
|
1132
|
-
distance:
|
|
1292
|
+
level: z6.number().int().min(0).max(32),
|
|
1293
|
+
ancestorIds: z6.array(wireId).max(32),
|
|
1294
|
+
distance: z6.number().min(0).max(2)
|
|
1133
1295
|
});
|
|
1134
|
-
var CommerceCategoryResolutionSchema =
|
|
1135
|
-
|
|
1136
|
-
outcome:
|
|
1296
|
+
var CommerceCategoryResolutionSchema = z6.union([
|
|
1297
|
+
z6.strictObject({
|
|
1298
|
+
outcome: z6.enum(["CANDIDATES", "NO_CANDIDATES"]).meta({ maxLength: 13 }),
|
|
1137
1299
|
generationId: wireId,
|
|
1138
1300
|
source: taxonomySource,
|
|
1139
|
-
taxonomyVersion:
|
|
1140
|
-
languageTag:
|
|
1141
|
-
candidates:
|
|
1301
|
+
taxonomyVersion: z6.string().min(1).max(64),
|
|
1302
|
+
languageTag: z6.string().min(1).max(35),
|
|
1303
|
+
candidates: z6.array(CommerceCategoryCandidateSchema).max(10)
|
|
1142
1304
|
}),
|
|
1143
|
-
|
|
1144
|
-
outcome:
|
|
1145
|
-
reasonCode:
|
|
1305
|
+
z6.strictObject({
|
|
1306
|
+
outcome: z6.enum(["UNAVAILABLE"]).meta({ maxLength: 11 }),
|
|
1307
|
+
reasonCode: z6.enum(["NOT_READY", "TEMPORARY_UNAVAILABLE"]).meta({ maxLength: 21 })
|
|
1146
1308
|
})
|
|
1147
1309
|
]);
|
|
1148
|
-
var CommerceOptionalLookupUnavailableSchema =
|
|
1149
|
-
outcome:
|
|
1150
|
-
reasonCode:
|
|
1310
|
+
var CommerceOptionalLookupUnavailableSchema = z6.strictObject({
|
|
1311
|
+
outcome: z6.enum(["UNAVAILABLE"]).meta({ maxLength: 11 }),
|
|
1312
|
+
reasonCode: z6.enum(["TEMPORARY_UNAVAILABLE"]).meta({ maxLength: 21 })
|
|
1151
1313
|
});
|
|
1152
|
-
var CommerceProductRecommendationSelectionSchema =
|
|
1153
|
-
productRecommendationVersion:
|
|
1154
|
-
productRecommendations:
|
|
1155
|
-
scope:
|
|
1314
|
+
var CommerceProductRecommendationSelectionSchema = z6.strictObject({
|
|
1315
|
+
productRecommendationVersion: z6.enum(["1"]).meta({ maxLength: 1 }).optional(),
|
|
1316
|
+
productRecommendations: z6.array(z6.strictObject({
|
|
1317
|
+
scope: z6.enum(["PRODUCT_ONLY", "ADD_TO_BASKET", "REPLACE_BASKET_LINE"]).meta({ maxLength: 19 }),
|
|
1156
1318
|
basketLineId: wireId.nullable(),
|
|
1157
1319
|
productId: wireId,
|
|
1158
1320
|
variantId: wireId.nullable(),
|
|
1159
|
-
quantity:
|
|
1160
|
-
promotionKind:
|
|
1161
|
-
offerIds:
|
|
1321
|
+
quantity: z6.number().int().min(1).max(99),
|
|
1322
|
+
promotionKind: z6.enum(["NONE", "NATIVE_SALE", "DISCOUNT"]).meta({ maxLength: 11 }),
|
|
1323
|
+
offerIds: z6.array(wireId).max(3)
|
|
1162
1324
|
})).min(1).max(3).optional()
|
|
1163
1325
|
});
|
|
1164
|
-
var CommerceResponseDispositionSchema =
|
|
1326
|
+
var CommerceResponseDispositionSchema = z6.enum([
|
|
1165
1327
|
"STANDARD",
|
|
1166
1328
|
"OUT_OF_SCOPE_REDIRECT",
|
|
1167
|
-
"SHIPPING_INFORMATION_UNVERIFIED"
|
|
1329
|
+
"SHIPPING_INFORMATION_UNVERIFIED",
|
|
1330
|
+
"PRODUCT_OPTIONS"
|
|
1168
1331
|
]).meta({ maxLength: 31 });
|
|
1169
|
-
var CommerceAnswerPresentationSelectionSchema =
|
|
1332
|
+
var CommerceAnswerPresentationSelectionSchema = z6.strictObject({
|
|
1333
|
+
productOptionSelections: z6.array(z6.strictObject({ productId: wireId, variantId: wireId.nullable() })).max(3).optional(),
|
|
1170
1334
|
responseDisposition: CommerceResponseDispositionSchema.optional(),
|
|
1171
|
-
shippingInformationSelection:
|
|
1335
|
+
shippingInformationSelection: z6.strictObject({
|
|
1172
1336
|
productId: wireId.nullable(),
|
|
1173
1337
|
variantId: wireId.nullable()
|
|
1174
1338
|
}).optional()
|
|
1175
1339
|
});
|
|
1176
|
-
var CommerceShippingInformationInputSchema =
|
|
1340
|
+
var CommerceShippingInformationInputSchema = z6.strictObject({
|
|
1177
1341
|
productId: wireId.nullable().default(null),
|
|
1178
1342
|
variantId: wireId.nullable().default(null)
|
|
1179
1343
|
});
|
|
1180
|
-
var CommerceShippingInformationSchema =
|
|
1181
|
-
provider:
|
|
1344
|
+
var CommerceShippingInformationSchema = z6.strictObject({
|
|
1345
|
+
provider: z6.enum(["SHOPIFY", "WOOCOMMERCE"]).meta({ maxLength: 11 }),
|
|
1182
1346
|
observedAt: DateSchema,
|
|
1183
|
-
product:
|
|
1184
|
-
status:
|
|
1347
|
+
product: z6.strictObject({
|
|
1348
|
+
status: z6.enum(["NOT_REQUESTED", "VARIANT_REQUIRED", "AVAILABLE"]).meta({ maxLength: 16 }),
|
|
1185
1349
|
productId: wireId.nullable(),
|
|
1186
1350
|
variantId: wireId.nullable(),
|
|
1187
|
-
requiresShipping:
|
|
1188
|
-
virtual:
|
|
1189
|
-
weight:
|
|
1190
|
-
value:
|
|
1191
|
-
unit:
|
|
1351
|
+
requiresShipping: z6.boolean().nullable(),
|
|
1352
|
+
virtual: z6.boolean().nullable(),
|
|
1353
|
+
weight: z6.strictObject({
|
|
1354
|
+
value: z6.number().min(0),
|
|
1355
|
+
unit: z6.enum(["GRAMS", "KILOGRAMS", "OUNCES", "POUNDS"]).meta({ maxLength: 9 }).nullable()
|
|
1192
1356
|
}).nullable(),
|
|
1193
|
-
dimensions:
|
|
1194
|
-
length:
|
|
1195
|
-
width:
|
|
1196
|
-
height:
|
|
1197
|
-
unit:
|
|
1357
|
+
dimensions: z6.strictObject({
|
|
1358
|
+
length: z6.number().min(0).nullable(),
|
|
1359
|
+
width: z6.number().min(0).nullable(),
|
|
1360
|
+
height: z6.number().min(0).nullable(),
|
|
1361
|
+
unit: z6.string().min(1).max(16).nullable()
|
|
1198
1362
|
}).nullable(),
|
|
1199
1363
|
shippingClassId: wireId.nullable(),
|
|
1200
|
-
shippingClassSlug:
|
|
1364
|
+
shippingClassSlug: z6.string().min(1).max(512).nullable()
|
|
1201
1365
|
}),
|
|
1202
|
-
policy:
|
|
1203
|
-
status:
|
|
1204
|
-
trust:
|
|
1205
|
-
title:
|
|
1206
|
-
bodyStatus:
|
|
1207
|
-
bodyHtml:
|
|
1208
|
-
url:
|
|
1366
|
+
policy: z6.strictObject({
|
|
1367
|
+
status: z6.enum(["AVAILABLE", "NOT_CONFIGURED", "SCOPE_NOT_GRANTED", "UNSUPPORTED"]).meta({ maxLength: 17 }),
|
|
1368
|
+
trust: z6.enum(["UNTRUSTED_REFERENCE"]).meta({ maxLength: 19 }),
|
|
1369
|
+
title: z6.string().min(1).max(512).nullable(),
|
|
1370
|
+
bodyStatus: z6.enum(["AVAILABLE", "EMPTY", "TOO_LARGE", "NOT_AVAILABLE"]).meta({ maxLength: 13 }),
|
|
1371
|
+
bodyHtml: z6.string().min(1).max(8e3).nullable(),
|
|
1372
|
+
url: z6.url({ protocol: /^https$/ }).min(1).max(2048).nullable(),
|
|
1209
1373
|
updatedAt: DateSchema.nullable()
|
|
1210
1374
|
})
|
|
1211
1375
|
});
|
|
1212
|
-
var limit =
|
|
1376
|
+
var limit = z6.number().int().min(1).max(3).default(3);
|
|
1213
1377
|
var CommerceToolInputs = {
|
|
1214
|
-
commerce_resolve_product_categories:
|
|
1215
|
-
query:
|
|
1216
|
-
limit:
|
|
1378
|
+
commerce_resolve_product_categories: z6.strictObject({
|
|
1379
|
+
query: z6.string().min(1).max(200),
|
|
1380
|
+
limit: z6.number().int().min(1).max(10).default(5)
|
|
1217
1381
|
}),
|
|
1218
1382
|
commerce_get_shipping_information: CommerceShippingInformationInputSchema,
|
|
1219
|
-
commerce_get_basket:
|
|
1220
|
-
commerce_search_products:
|
|
1221
|
-
query:
|
|
1222
|
-
category:
|
|
1223
|
-
system:
|
|
1383
|
+
commerce_get_basket: z6.strictObject({}),
|
|
1384
|
+
commerce_search_products: z6.strictObject({
|
|
1385
|
+
query: z6.string().min(1).max(200).nullable().default(null),
|
|
1386
|
+
category: z6.strictObject({
|
|
1387
|
+
system: z6.enum(["SHOPIFY_STANDARD_PRODUCT_TAXONOMY", "WOOCOMMERCE_PRODUCT_CATEGORY"]).meta({ maxLength: 33 }),
|
|
1224
1388
|
id: wireId,
|
|
1225
|
-
taxonomyVersion:
|
|
1389
|
+
taxonomyVersion: z6.string().min(1).max(64).nullable()
|
|
1226
1390
|
}).optional(),
|
|
1227
|
-
browse:
|
|
1391
|
+
browse: z6.boolean().default(false),
|
|
1228
1392
|
maximumPrice: MoneySchema.optional(),
|
|
1229
|
-
availableOnly:
|
|
1230
|
-
limit:
|
|
1231
|
-
cursor:
|
|
1393
|
+
availableOnly: z6.boolean().default(true),
|
|
1394
|
+
limit: z6.number().int().min(1).max(20).default(10),
|
|
1395
|
+
cursor: z6.string().max(2048).nullable().default(null)
|
|
1232
1396
|
}),
|
|
1233
|
-
commerce_get_product:
|
|
1397
|
+
commerce_get_product: z6.strictObject({
|
|
1234
1398
|
productId: IdSchema,
|
|
1235
1399
|
variantId: IdSchema.nullable()
|
|
1236
1400
|
}),
|
|
1237
|
-
commerce_get_discount_options:
|
|
1238
|
-
limit:
|
|
1239
|
-
cursor:
|
|
1401
|
+
commerce_get_discount_options: z6.strictObject({
|
|
1402
|
+
limit: z6.number().int().min(1).max(50).default(20),
|
|
1403
|
+
cursor: z6.string().max(2048).nullable().default(null)
|
|
1240
1404
|
}),
|
|
1241
|
-
commerce_get_discount_details:
|
|
1242
|
-
commerce_evaluate_discount:
|
|
1405
|
+
commerce_get_discount_details: z6.strictObject({ offerId: IdSchema }),
|
|
1406
|
+
commerce_evaluate_discount: z6.strictObject({
|
|
1243
1407
|
offerId: IdSchema,
|
|
1244
1408
|
proposal: CommerceProposalSchema.nullable()
|
|
1245
1409
|
}),
|
|
1246
|
-
commerce_find_qualifying_products:
|
|
1410
|
+
commerce_find_qualifying_products: z6.strictObject({
|
|
1247
1411
|
offerId: IdSchema,
|
|
1248
|
-
query:
|
|
1412
|
+
query: z6.string().min(1).max(200).nullable(),
|
|
1249
1413
|
limit
|
|
1250
1414
|
}),
|
|
1251
|
-
commerce_find_similar_products:
|
|
1415
|
+
commerce_find_similar_products: z6.strictObject({
|
|
1252
1416
|
variantId: IdSchema,
|
|
1253
1417
|
offerId: IdSchema.nullable(),
|
|
1254
1418
|
limit
|
|
1255
1419
|
})
|
|
1256
1420
|
};
|
|
1257
|
-
var alternatives =
|
|
1258
|
-
alternatives:
|
|
1259
|
-
truncated:
|
|
1421
|
+
var alternatives = z6.strictObject({
|
|
1422
|
+
alternatives: z6.array(CommerceAlternativeSchema).max(3),
|
|
1423
|
+
truncated: z6.boolean()
|
|
1260
1424
|
});
|
|
1261
1425
|
var CommerceToolOutputs = {
|
|
1262
1426
|
commerce_resolve_product_categories: CommerceCategoryResolutionSchema,
|
|
1263
1427
|
commerce_get_shipping_information: CommerceShippingInformationSchema,
|
|
1264
1428
|
commerce_get_basket: CommerceBasketSchema,
|
|
1265
|
-
commerce_search_products:
|
|
1266
|
-
products:
|
|
1267
|
-
cursor:
|
|
1268
|
-
truncated:
|
|
1429
|
+
commerce_search_products: z6.strictObject({
|
|
1430
|
+
products: z6.array(CommerceProductSchema).max(20),
|
|
1431
|
+
cursor: z6.string().max(2048).nullable(),
|
|
1432
|
+
truncated: z6.boolean()
|
|
1269
1433
|
}),
|
|
1270
|
-
commerce_get_product:
|
|
1434
|
+
commerce_get_product: z6.strictObject({
|
|
1271
1435
|
product: CommerceProductSchema.nullable()
|
|
1272
1436
|
}),
|
|
1273
|
-
commerce_get_discount_options:
|
|
1274
|
-
mode:
|
|
1275
|
-
offers:
|
|
1276
|
-
truncated:
|
|
1277
|
-
cursor:
|
|
1437
|
+
commerce_get_discount_options: z6.union([CommerceOptionalLookupUnavailableSchema, z6.strictObject({
|
|
1438
|
+
mode: z6.enum(["NONE", "FIXED", "AI_BEST_APPLICABLE"]),
|
|
1439
|
+
offers: z6.array(CommerceOfferSchema).max(50),
|
|
1440
|
+
truncated: z6.boolean(),
|
|
1441
|
+
cursor: z6.string().max(2048).nullable().optional()
|
|
1278
1442
|
})]),
|
|
1279
|
-
commerce_get_discount_details:
|
|
1443
|
+
commerce_get_discount_details: z6.union([CommerceOptionalLookupUnavailableSchema, z6.strictObject({
|
|
1280
1444
|
details: CommerceDiscountDetailsSchema.nullable()
|
|
1281
1445
|
})]),
|
|
1282
1446
|
commerce_evaluate_discount: CommerceEvidenceSchema,
|
|
@@ -1300,6 +1464,9 @@ export {
|
|
|
1300
1464
|
DetailsSchemaSchema,
|
|
1301
1465
|
matchesSubset,
|
|
1302
1466
|
compileSubset,
|
|
1467
|
+
validateCommercePurposeOutputSchema,
|
|
1468
|
+
CommercePurposeOutputSchemaSchema,
|
|
1469
|
+
compileCommercePurposeOutputSchema,
|
|
1303
1470
|
ExternalQueryValueSchema,
|
|
1304
1471
|
ExternalQueryMappingSchema,
|
|
1305
1472
|
ExternalQueryMappingsSchema,
|
|
@@ -1366,6 +1533,10 @@ export {
|
|
|
1366
1533
|
CommerceProposalSchema,
|
|
1367
1534
|
CommerceBasketSchema,
|
|
1368
1535
|
CommerceProductSaleEvidenceSchema,
|
|
1536
|
+
normalizeCommerceProductOptions,
|
|
1537
|
+
CommerceProductOptionsSchema,
|
|
1538
|
+
normalizeCommerceProductSelectedOptions,
|
|
1539
|
+
CommerceProductSelectedOptionsSchema,
|
|
1369
1540
|
CommerceProductSchema,
|
|
1370
1541
|
CommerceOfferSchema,
|
|
1371
1542
|
CommerceDiscountCombinationFactsSchema,
|
|
@@ -1388,4 +1559,4 @@ export {
|
|
|
1388
1559
|
CommerceToolOutputs,
|
|
1389
1560
|
productBelongsToDomain
|
|
1390
1561
|
};
|
|
1391
|
-
//# sourceMappingURL=chunk-
|
|
1562
|
+
//# sourceMappingURL=chunk-S42O2OCG.js.map
|