@modainteract/moda-interact-shared 5.3.0 → 5.5.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-6OBYUIQ3.js → chunk-BDGLKOCW.js} +452 -299
- package/dist/chunk-BDGLKOCW.js.map +1 -0
- package/dist/{chunk-C2PCRWOW.js → chunk-BYAI6W7T.js} +3 -3
- package/dist/{chunk-C2PCRWOW.js.map → chunk-BYAI6W7T.js.map} +1 -1
- package/dist/commerce/index.d.ts +18 -3
- package/dist/commerce/index.js +14 -2
- package/dist/commerce/index.js.map +1 -1
- package/dist/commerce/model/node.d.ts +2 -2
- package/dist/commerce/model/node.js +1 -1
- package/dist/commerce/runner/index.d.ts +3 -3
- package/dist/commerce/runner/index.js +16 -4
- package/dist/commerce/runner/index.js.map +1 -1
- package/dist/{response-k0hO3yus.d.ts → response-C1JsiFoO.d.ts} +176 -1
- package/dist/{types-BaLq_Wz6.d.ts → types-Ds5QJ621.d.ts} +3 -1
- package/package.json +1 -1
- package/dist/chunk-6OBYUIQ3.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,53 +362,86 @@ 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
|
|
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({
|
|
368
|
+
purpose: CommerceExecutionPurposeSchema,
|
|
369
|
+
featureId: IdSchema,
|
|
370
|
+
releaseId: IdSchema,
|
|
371
|
+
behaviourPrompt: z4.string().refine((value) => new TextEncoder().encode(value).length <= 32768),
|
|
372
|
+
capabilities: z4.array(z4.strictObject({
|
|
373
|
+
capabilityId: IdSchema,
|
|
374
|
+
toolId: IdSchema,
|
|
375
|
+
revisionId: IdSchema,
|
|
376
|
+
name: ToolNameSchema,
|
|
377
|
+
position: z4.number().int().nonnegative(),
|
|
378
|
+
inputSchema: InputSchemaSchema,
|
|
379
|
+
outputSchema: CommercePurposeOutputSchemaSchema
|
|
380
|
+
})).min(1, { message: "PROFILE_EMPTY" }).max(32)
|
|
381
|
+
}).superRefine((profile, ctx) => {
|
|
382
|
+
const members = profile.capabilities;
|
|
383
|
+
if (!distinct(members.map((member) => member.name)) || !distinct(members.map((member) => member.capabilityId)) || members.some((member, index) => index > 0 && member.position <= members[index - 1].position))
|
|
384
|
+
ctx.addIssue({ code: "custom", message: "Invalid purpose profile membership/order" });
|
|
385
|
+
}).transform((profile) => {
|
|
386
|
+
const snapshot = structuredClone(profile);
|
|
387
|
+
const freeze = (value) => {
|
|
388
|
+
if (value && typeof value === "object") {
|
|
389
|
+
Object.values(value).forEach(freeze);
|
|
390
|
+
Object.freeze(value);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
freeze(snapshot);
|
|
394
|
+
return snapshot;
|
|
395
|
+
});
|
|
396
|
+
function requireCommercePurposeProfile(raw) {
|
|
397
|
+
return CommercePurposeProfileSchema.parse(raw);
|
|
398
|
+
}
|
|
399
|
+
var PublishedGrantedToolSchema = z4.strictObject({
|
|
259
400
|
toolId: IdSchema,
|
|
260
401
|
toolRevisionId: IdSchema,
|
|
261
402
|
toolName: ToolNameSchema,
|
|
262
403
|
definitionVersion: SemverSchema,
|
|
263
|
-
capabilityKeys:
|
|
404
|
+
capabilityKeys: z4.array(IdSchema).min(1).max(32).refine((v) => distinct(v) && v.join("\0") === [...v].sort().join("\0"))
|
|
264
405
|
});
|
|
265
|
-
var PublishedToolDescriptorSchema =
|
|
406
|
+
var PublishedToolDescriptorSchema = z4.strictObject({
|
|
266
407
|
toolId: IdSchema,
|
|
267
408
|
toolRevisionId: IdSchema,
|
|
268
409
|
name: ToolNameSchema,
|
|
269
410
|
definitionVersion: SemverSchema,
|
|
270
|
-
description:
|
|
411
|
+
description: z4.string().min(1).max(4096),
|
|
271
412
|
inputSchema: InputSchemaSchema
|
|
272
413
|
});
|
|
273
|
-
var CommerceBuiltInToolNameSchema =
|
|
414
|
+
var CommerceBuiltInToolNameSchema = z4.enum([
|
|
274
415
|
"commerce_get_discount_options",
|
|
275
416
|
"commerce_get_discount_details"
|
|
276
417
|
]).meta({ maxLength: 29 });
|
|
277
|
-
var CommerceBuiltInToolGrantSchema =
|
|
278
|
-
kind:
|
|
418
|
+
var CommerceBuiltInToolGrantSchema = z4.strictObject({
|
|
419
|
+
kind: z4.enum(["BUILT_IN"]).meta({ maxLength: 8 }),
|
|
279
420
|
toolName: CommerceBuiltInToolNameSchema,
|
|
280
|
-
definitionVersion:
|
|
421
|
+
definitionVersion: z4.enum(["2.0.0"]).meta({ maxLength: 5 })
|
|
281
422
|
});
|
|
282
|
-
var CommerceBuiltInToolDescriptorSchema =
|
|
283
|
-
kind:
|
|
423
|
+
var CommerceBuiltInToolDescriptorSchema = z4.strictObject({
|
|
424
|
+
kind: z4.enum(["BUILT_IN"]).meta({ maxLength: 8 }),
|
|
284
425
|
name: CommerceBuiltInToolNameSchema,
|
|
285
|
-
definitionVersion:
|
|
286
|
-
description:
|
|
426
|
+
definitionVersion: z4.enum(["2.0.0"]).meta({ maxLength: 5 }),
|
|
427
|
+
description: z4.string().min(1).max(4096),
|
|
287
428
|
inputSchema: InputSchemaSchema
|
|
288
429
|
});
|
|
289
|
-
var GrantedToolSchema =
|
|
290
|
-
var ToolDescriptorSchema =
|
|
291
|
-
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) => {
|
|
292
433
|
const published = values.filter((value) => !("kind" in value));
|
|
293
434
|
return distinct(values.map((value) => value.toolName)) && distinct(published.map((value) => value.toolId));
|
|
294
435
|
});
|
|
295
436
|
var isBuiltInTool = (value) => "kind" in value && value.kind === "BUILT_IN";
|
|
296
|
-
var MappingSchema =
|
|
297
|
-
|
|
298
|
-
input:
|
|
299
|
-
omitIfMissing:
|
|
437
|
+
var MappingSchema = z4.union([
|
|
438
|
+
z4.strictObject({
|
|
439
|
+
input: z4.string().refine(safeName),
|
|
440
|
+
omitIfMissing: z4.literal(true).optional()
|
|
300
441
|
}),
|
|
301
|
-
|
|
442
|
+
z4.strictObject({ literal: boundedJson(8192) })
|
|
302
443
|
]);
|
|
303
|
-
var MappingsSchema =
|
|
444
|
+
var MappingsSchema = z4.record(z4.string().refine(safeName), MappingSchema).refine((v) => Object.keys(v).length <= 32);
|
|
304
445
|
var POLICY_OPERATIONS = [
|
|
305
446
|
"taxonomy.resolveCategories",
|
|
306
447
|
"products.search",
|
|
@@ -314,15 +455,15 @@ var POLICY_OPERATIONS = [
|
|
|
314
455
|
"products.findQualifying",
|
|
315
456
|
"products.findSimilar"
|
|
316
457
|
];
|
|
317
|
-
var ExternalHttpExecutionSchema =
|
|
318
|
-
kind:
|
|
319
|
-
executorVersion:
|
|
458
|
+
var ExternalHttpExecutionSchema = z4.strictObject({
|
|
459
|
+
kind: z4.literal("EXTERNAL_HTTP"),
|
|
460
|
+
executorVersion: z4.literal("1.0.0"),
|
|
320
461
|
connectionRevisionId: IdSchema,
|
|
321
|
-
method:
|
|
462
|
+
method: z4.literal("GET"),
|
|
322
463
|
path: ExternalPathSchema,
|
|
323
464
|
query: ExternalQueryMappingsSchema,
|
|
324
465
|
responseFormat: ExternalResponseFormatSchema,
|
|
325
|
-
resultPath:
|
|
466
|
+
resultPath: z4.string().refine((value) => value === "" || safePath(value)),
|
|
326
467
|
responseProcessing: ResponseProcessingSchema,
|
|
327
468
|
resultSchema: DetailsSchemaSchema
|
|
328
469
|
}).superRefine((value, ctx) => {
|
|
@@ -331,21 +472,21 @@ var ExternalHttpExecutionSchema = z3.strictObject({
|
|
|
331
472
|
if (value.responseProcessing.kind !== "JAVASCRIPT" && value.responseFormat.mode !== "JSON")
|
|
332
473
|
ctx.addIssue({ code: "custom", path: ["responseFormat", "mode"], message: "Visual processing requires JSON" });
|
|
333
474
|
});
|
|
334
|
-
var CommerceExecutionSchema =
|
|
335
|
-
|
|
336
|
-
kind:
|
|
337
|
-
executorVersion:
|
|
338
|
-
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"),
|
|
339
480
|
schemaHash: HashSchema,
|
|
340
|
-
document:
|
|
341
|
-
operationName:
|
|
481
|
+
document: z4.string().min(1).refine((v) => new TextEncoder().encode(v).length <= 16384),
|
|
482
|
+
operationName: z4.string().refine(safeName),
|
|
342
483
|
variables: MappingsSchema,
|
|
343
|
-
resultPath:
|
|
484
|
+
resultPath: z4.string().refine(safePath)
|
|
344
485
|
}),
|
|
345
|
-
|
|
346
|
-
kind:
|
|
347
|
-
operation:
|
|
348
|
-
operationVersion:
|
|
486
|
+
z4.strictObject({
|
|
487
|
+
kind: z4.literal("POLICY_OPERATION"),
|
|
488
|
+
operation: z4.enum(POLICY_OPERATIONS),
|
|
489
|
+
operationVersion: z4.literal("1.0.0"),
|
|
349
490
|
arguments: MappingsSchema
|
|
350
491
|
}),
|
|
351
492
|
ExternalHttpExecutionSchema
|
|
@@ -358,17 +499,17 @@ function tokensValid(text, root) {
|
|
|
358
499
|
);
|
|
359
500
|
return !residue.includes("{{") && !residue.includes("}}");
|
|
360
501
|
}
|
|
361
|
-
var fixed =
|
|
362
|
-
var ResponseTemplateSchema =
|
|
363
|
-
|
|
364
|
-
kind:
|
|
365
|
-
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")),
|
|
366
507
|
unavailable: fixed
|
|
367
508
|
}),
|
|
368
|
-
|
|
369
|
-
kind:
|
|
370
|
-
itemsPath:
|
|
371
|
-
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")),
|
|
372
513
|
empty: fixed,
|
|
373
514
|
unavailable: fixed
|
|
374
515
|
})
|
|
@@ -376,11 +517,11 @@ var ResponseTemplateSchema = z3.discriminatedUnion("kind", [
|
|
|
376
517
|
var identity = {
|
|
377
518
|
name: ToolNameSchema,
|
|
378
519
|
definitionVersion: SemverSchema,
|
|
379
|
-
description:
|
|
520
|
+
description: z4.string().min(1).max(4096)
|
|
380
521
|
};
|
|
381
522
|
var forbiddenInput = /^(shopid|customerid|checkoutrecoveryid|conversationid|grantid|releaseid|token|accesstoken|domain|headers|url|graphql|document|authorization)$/i;
|
|
382
523
|
var forbiddenExternalInput = /^(authorization|cookie|set-cookie|host|x-api-key|api_key|apikey|access_token|token|secret|password)$/i;
|
|
383
|
-
var CommerceToolDefinitionSchema =
|
|
524
|
+
var CommerceToolDefinitionSchema = z4.strictObject({
|
|
384
525
|
...identity,
|
|
385
526
|
inputSchema: InputSchemaSchema,
|
|
386
527
|
execution: CommerceExecutionSchema,
|
|
@@ -416,7 +557,7 @@ var CommerceToolDefinitionSchema = z3.strictObject({
|
|
|
416
557
|
var draftObject = boundedJson(65536).refine(
|
|
417
558
|
(v) => !!v && typeof v === "object" && !Array.isArray(v)
|
|
418
559
|
);
|
|
419
|
-
var CommerceToolDraftDefinitionSchema =
|
|
560
|
+
var CommerceToolDraftDefinitionSchema = z4.strictObject({
|
|
420
561
|
...identity,
|
|
421
562
|
inputSchema: draftObject,
|
|
422
563
|
execution: draftObject,
|
|
@@ -509,12 +650,12 @@ function validateDefinitionVersion(proposed, highestPublished) {
|
|
|
509
650
|
SemverSchema.parse(highestPublished);
|
|
510
651
|
return gt(proposed, highestPublished);
|
|
511
652
|
}
|
|
512
|
-
var CommerceToolIdentitySchema =
|
|
653
|
+
var CommerceToolIdentitySchema = z4.strictObject({
|
|
513
654
|
id: IdSchema,
|
|
514
655
|
name: ToolNameSchema,
|
|
515
|
-
enabled:
|
|
656
|
+
enabled: z4.boolean()
|
|
516
657
|
});
|
|
517
|
-
var CommerceToolRevisionIdentitySchema =
|
|
658
|
+
var CommerceToolRevisionIdentitySchema = z4.strictObject({
|
|
518
659
|
toolId: IdSchema,
|
|
519
660
|
toolRevisionId: IdSchema,
|
|
520
661
|
definitionVersion: SemverSchema,
|
|
@@ -566,10 +707,10 @@ function isTrustedCommerceBuiltInGrant(value) {
|
|
|
566
707
|
}
|
|
567
708
|
|
|
568
709
|
// src/commerce/response.ts
|
|
569
|
-
import { z as
|
|
570
|
-
var CommerceResponseContractSchema =
|
|
571
|
-
version:
|
|
572
|
-
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),
|
|
573
714
|
detailsSchema: DetailsSchemaSchema
|
|
574
715
|
}).refine((v) => jsonBytes(v) <= 32768);
|
|
575
716
|
var EMPTY_RESPONSE_CONTRACT = {
|
|
@@ -582,31 +723,31 @@ var EMPTY_RESPONSE_CONTRACT = {
|
|
|
582
723
|
additionalProperties: false
|
|
583
724
|
}
|
|
584
725
|
};
|
|
585
|
-
var ReferralReasonSchema =
|
|
726
|
+
var ReferralReasonSchema = z5.enum([
|
|
586
727
|
"INSUFFICIENT_TOOLS",
|
|
587
728
|
"UNVERIFIABLE_FACTS",
|
|
588
729
|
"TOOL_UNAVAILABLE",
|
|
589
730
|
"TOOL_REVOKED"
|
|
590
731
|
]);
|
|
591
|
-
var DetectedLanguageTagSchema =
|
|
732
|
+
var DetectedLanguageTagSchema = z5.string().min(1).max(128).transform((value, ctx) => {
|
|
592
733
|
const canonical = canonicaliseLanguageTag(value);
|
|
593
734
|
if (!canonical) {
|
|
594
735
|
ctx.addIssue({
|
|
595
736
|
code: "custom",
|
|
596
737
|
message: "Invalid detected language tag"
|
|
597
738
|
});
|
|
598
|
-
return
|
|
739
|
+
return z5.NEVER;
|
|
599
740
|
}
|
|
600
741
|
return canonical;
|
|
601
742
|
});
|
|
602
|
-
var CommerceFinalResponseSchema =
|
|
603
|
-
answerKind:
|
|
604
|
-
replyText:
|
|
743
|
+
var CommerceFinalResponseSchema = z5.strictObject({
|
|
744
|
+
answerKind: z5.enum(["ANSWER", "REFER_TO_STORE"]),
|
|
745
|
+
replyText: z5.string().min(1).max(4096),
|
|
605
746
|
referralReason: ReferralReasonSchema.nullable(),
|
|
606
747
|
detectedLanguageTag: DetectedLanguageTagSchema.nullable(),
|
|
607
|
-
detectedLanguageConfidence:
|
|
608
|
-
evidenceIds:
|
|
609
|
-
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) => {
|
|
610
751
|
try {
|
|
611
752
|
return jsonBytes(v) <= 16384;
|
|
612
753
|
} catch {
|
|
@@ -742,27 +883,30 @@ function finalResponseToolSchema(definition) {
|
|
|
742
883
|
}
|
|
743
884
|
|
|
744
885
|
// src/commerce/schemas.ts
|
|
745
|
-
import { z as
|
|
886
|
+
import { z as z6 } from "zod";
|
|
746
887
|
import { validRange } from "semver";
|
|
747
|
-
var CommerceTurnIdentitySchema =
|
|
888
|
+
var CommerceTurnIdentitySchema = z6.strictObject({
|
|
748
889
|
contractVersion: ContractVersionSchema,
|
|
749
890
|
shopId: IdSchema,
|
|
750
891
|
checkoutRecoveryId: IdSchema,
|
|
751
892
|
conversationId: IdSchema,
|
|
752
|
-
inboundVersion:
|
|
893
|
+
inboundVersion: z6.number().int().positive()
|
|
753
894
|
});
|
|
754
|
-
var CommerceConversationGrantSchema =
|
|
895
|
+
var CommerceConversationGrantSchema = z6.strictObject({
|
|
755
896
|
id: IdSchema,
|
|
756
897
|
shopId: IdSchema,
|
|
757
898
|
conversationId: IdSchema,
|
|
758
|
-
initialInboundVersion:
|
|
899
|
+
initialInboundVersion: z6.number().int().positive(),
|
|
759
900
|
releaseId: IdSchema,
|
|
760
|
-
selectedCapabilityKeys:
|
|
901
|
+
selectedCapabilityKeys: z6.array(IdSchema).max(32).refine(distinct),
|
|
902
|
+
purposeProfile: CommercePurposeProfileSchema.optional(),
|
|
761
903
|
grantedTools: GrantedToolsSchema,
|
|
762
904
|
runnerVersion: SemverSchema,
|
|
763
905
|
createdAt: DateSchema,
|
|
764
906
|
expiresAt: DateSchema.nullable()
|
|
765
907
|
}).superRefine((v, c) => {
|
|
908
|
+
if (v.purposeProfile && (v.purposeProfile.releaseId !== v.releaseId || v.purposeProfile.capabilities.some((member) => !v.grantedTools.some((tool) => !isBuiltInTool(tool) && tool.toolId === member.toolId && tool.toolRevisionId === member.revisionId && tool.toolName === member.name))))
|
|
909
|
+
c.addIssue({ code: "custom", message: "Purpose profile grant mismatch" });
|
|
766
910
|
if (v.expiresAt && Date.parse(v.expiresAt) <= Date.parse(v.createdAt))
|
|
767
911
|
c.addIssue({ code: "custom", message: "Invalid grant retention date" });
|
|
768
912
|
if (jsonBytes(v.grantedTools) > 65536 || jsonBytes(v.selectedCapabilityKeys) > 8192 || v.grantedTools.some(
|
|
@@ -770,33 +914,36 @@ var CommerceConversationGrantSchema = z5.strictObject({
|
|
|
770
914
|
))
|
|
771
915
|
c.addIssue({ code: "custom", message: "Unselected grant provenance" });
|
|
772
916
|
});
|
|
773
|
-
var CommerceManifestSchema =
|
|
917
|
+
var CommerceManifestSchema = z6.strictObject({
|
|
774
918
|
contractVersion: ContractVersionSchema,
|
|
775
919
|
releaseId: IdSchema,
|
|
776
|
-
runnerCompatibility:
|
|
777
|
-
capabilities:
|
|
778
|
-
|
|
920
|
+
runnerCompatibility: z6.string().min(1).max(128).refine((v) => !!validRange(v)),
|
|
921
|
+
capabilities: z6.array(
|
|
922
|
+
z6.strictObject({
|
|
779
923
|
capabilityId: IdSchema,
|
|
780
924
|
key: IdSchema,
|
|
781
925
|
featureId: IdSchema,
|
|
782
|
-
position:
|
|
926
|
+
position: z6.number().int().nonnegative(),
|
|
783
927
|
toolDescriptor: PublishedToolDescriptorSchema
|
|
784
928
|
})
|
|
785
929
|
).max(32),
|
|
786
|
-
featureBehaviours:
|
|
787
|
-
|
|
930
|
+
featureBehaviours: z6.array(
|
|
931
|
+
z6.strictObject({
|
|
788
932
|
featureId: IdSchema,
|
|
789
|
-
behaviourPrompt:
|
|
933
|
+
behaviourPrompt: z6.string().max(32e3)
|
|
790
934
|
})
|
|
791
935
|
).max(32),
|
|
792
|
-
selectedCapabilityKeys:
|
|
793
|
-
builtInTools:
|
|
936
|
+
selectedCapabilityKeys: z6.array(IdSchema).max(32).refine(distinct),
|
|
937
|
+
builtInTools: z6.array(CommerceBuiltInToolDescriptorSchema).max(2).default([]),
|
|
938
|
+
purposeProfile: CommercePurposeProfileSchema.optional(),
|
|
794
939
|
grantedTools: GrantedToolsSchema,
|
|
795
940
|
responseContract: CommerceResponseContractSchema,
|
|
796
941
|
responseContractHash: HashSchema
|
|
797
942
|
}).superRefine((v, c) => {
|
|
798
943
|
if (jsonBytes(v) > 262144)
|
|
799
944
|
c.addIssue({ code: "custom", message: "Manifest exceeds output limit" });
|
|
945
|
+
if (v.purposeProfile && (v.purposeProfile.releaseId !== v.releaseId || v.purposeProfile.capabilities.some((member) => !v.capabilities.some((capability) => capability.capabilityId === member.capabilityId && capability.toolDescriptor.toolId === member.toolId && capability.toolDescriptor.toolRevisionId === member.revisionId && capability.toolDescriptor.name === member.name && canonicalJson(capability.toolDescriptor.inputSchema) === canonicalJson(member.inputSchema)))))
|
|
946
|
+
c.addIssue({ code: "custom", message: "Purpose profile release membership mismatch" });
|
|
800
947
|
const keys = v.capabilities.map((x) => x.key);
|
|
801
948
|
const capabilityIds = v.capabilities.map((x) => x.capabilityId);
|
|
802
949
|
const representedFeatures = [...new Set(v.capabilities.map((x) => x.featureId))];
|
|
@@ -842,32 +989,32 @@ var CommerceManifestSchema = z5.strictObject({
|
|
|
842
989
|
message: "Grant must equal selected capability set"
|
|
843
990
|
});
|
|
844
991
|
});
|
|
845
|
-
var CommerceReleaseIdentitySchema =
|
|
992
|
+
var CommerceReleaseIdentitySchema = z6.strictObject({
|
|
846
993
|
contractVersion: ContractVersionSchema,
|
|
847
994
|
releaseId: IdSchema,
|
|
848
|
-
runnerCompatibility:
|
|
995
|
+
runnerCompatibility: z6.string().min(1).max(128).refine((v) => !!validRange(v))
|
|
849
996
|
});
|
|
850
997
|
var CommerceResolveAssertionSchema = CommerceTurnIdentitySchema.extend(
|
|
851
|
-
{ purpose:
|
|
998
|
+
{ purpose: z6.literal("resolve") }
|
|
852
999
|
);
|
|
853
1000
|
var CommerceExecuteAssertionSchema = CommerceTurnIdentitySchema.extend(
|
|
854
|
-
{ purpose:
|
|
1001
|
+
{ purpose: z6.literal("execute"), grantId: IdSchema, releaseId: IdSchema }
|
|
855
1002
|
);
|
|
856
|
-
var CommerceAssertionSchema =
|
|
1003
|
+
var CommerceAssertionSchema = z6.discriminatedUnion("purpose", [
|
|
857
1004
|
CommerceResolveAssertionSchema,
|
|
858
1005
|
CommerceExecuteAssertionSchema
|
|
859
1006
|
]);
|
|
860
|
-
var qty =
|
|
861
|
-
var CommerceProposalSchema =
|
|
862
|
-
operations:
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
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"),
|
|
866
1013
|
variantId: IdSchema,
|
|
867
1014
|
quantity: qty
|
|
868
1015
|
}),
|
|
869
|
-
|
|
870
|
-
kind:
|
|
1016
|
+
z6.strictObject({
|
|
1017
|
+
kind: z6.literal("REPLACE"),
|
|
871
1018
|
lineId: IdSchema,
|
|
872
1019
|
variantId: IdSchema,
|
|
873
1020
|
quantity: qty
|
|
@@ -879,13 +1026,13 @@ var CommerceProposalSchema = z5.strictObject({
|
|
|
879
1026
|
v.operations.flatMap((o) => o.kind === "REPLACE" ? [o.lineId] : [])
|
|
880
1027
|
)
|
|
881
1028
|
);
|
|
882
|
-
var CommerceBasketSchema =
|
|
1029
|
+
var CommerceBasketSchema = z6.strictObject({
|
|
883
1030
|
basketId: IdSchema,
|
|
884
|
-
source:
|
|
1031
|
+
source: z6.enum(["RECOVERY_SNAPSHOT", "PROPOSED"]),
|
|
885
1032
|
observedAt: DateSchema,
|
|
886
1033
|
currency: CurrencySchema.nullable(),
|
|
887
|
-
lines:
|
|
888
|
-
|
|
1034
|
+
lines: z6.array(
|
|
1035
|
+
z6.strictObject({
|
|
889
1036
|
lineId: IdSchema,
|
|
890
1037
|
productId: IdSchema.nullable(),
|
|
891
1038
|
variantId: IdSchema.nullable(),
|
|
@@ -894,35 +1041,35 @@ var CommerceBasketSchema = z5.strictObject({
|
|
|
894
1041
|
})
|
|
895
1042
|
).max(100),
|
|
896
1043
|
fingerprint: HashSchema,
|
|
897
|
-
unknownFields:
|
|
1044
|
+
unknownFields: z6.array(z6.string().min(1).max(256)).max(128)
|
|
898
1045
|
}).refine((v) => distinct(v.lines.map((line) => line.lineId)));
|
|
899
|
-
var CommerceProductSaleEvidenceSchema =
|
|
1046
|
+
var CommerceProductSaleEvidenceSchema = z6.strictObject({
|
|
900
1047
|
regularPrice: MoneySchema.nullable(),
|
|
901
1048
|
salePrice: MoneySchema.nullable(),
|
|
902
1049
|
observedAt: DateSchema
|
|
903
1050
|
});
|
|
904
|
-
var CommerceProductSchema =
|
|
1051
|
+
var CommerceProductSchema = z6.strictObject({
|
|
905
1052
|
productId: IdSchema,
|
|
906
1053
|
variantId: IdSchema.nullable(),
|
|
907
|
-
title:
|
|
908
|
-
url:
|
|
1054
|
+
title: z6.string().min(1).max(512),
|
|
1055
|
+
url: z6.url({ protocol: /^https$/ }).refine((v) => {
|
|
909
1056
|
const u = new URL(v);
|
|
910
1057
|
return !u.username && !u.password && !u.port;
|
|
911
1058
|
}).nullable(),
|
|
912
|
-
available:
|
|
1059
|
+
available: z6.boolean().nullable(),
|
|
913
1060
|
unitPrice: MoneySchema.nullable(),
|
|
914
1061
|
currency: CurrencySchema.nullable(),
|
|
915
|
-
productType:
|
|
916
|
-
vendor:
|
|
917
|
-
categories:
|
|
918
|
-
categoryIds:
|
|
919
|
-
collectionIds:
|
|
920
|
-
imageUrl:
|
|
1062
|
+
productType: z6.string().max(512).nullable(),
|
|
1063
|
+
vendor: z6.string().max(512).nullable(),
|
|
1064
|
+
categories: z6.array(z6.string()).optional(),
|
|
1065
|
+
categoryIds: z6.array(IdSchema).max(128).optional(),
|
|
1066
|
+
collectionIds: z6.array(IdSchema).max(128).optional(),
|
|
1067
|
+
imageUrl: z6.string().nullable().optional(),
|
|
921
1068
|
saleEvidence: CommerceProductSaleEvidenceSchema.nullable().optional(),
|
|
922
1069
|
observedAt: DateSchema
|
|
923
1070
|
});
|
|
924
1071
|
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])/;
|
|
925
|
-
var CommerceDiscountDateTimeSchema =
|
|
1072
|
+
var CommerceDiscountDateTimeSchema = z6.string().regex(discountUtcPattern).refine((value) => {
|
|
926
1073
|
const match = discountUtcPattern.exec(value);
|
|
927
1074
|
if (!match) return false;
|
|
928
1075
|
const [year, month, day, hour, minute, second] = match.slice(1).map(Number);
|
|
@@ -931,36 +1078,36 @@ var CommerceDiscountDateTimeSchema = z5.string().regex(discountUtcPattern).refin
|
|
|
931
1078
|
const daysInMonth = [31, leapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
932
1079
|
return day >= 1 && day <= daysInMonth[month - 1];
|
|
933
1080
|
}, "Expected a valid UTC discount timestamp with seconds");
|
|
934
|
-
var CommerceOfferSchema =
|
|
1081
|
+
var CommerceOfferSchema = z6.strictObject({
|
|
935
1082
|
offerId: IdSchema,
|
|
936
|
-
title:
|
|
937
|
-
method:
|
|
938
|
-
code:
|
|
1083
|
+
title: z6.string().min(1).max(512),
|
|
1084
|
+
method: z6.enum(["AUTOMATIC", "CODE"]),
|
|
1085
|
+
code: z6.string().min(1).max(128).nullable(),
|
|
939
1086
|
startsAt: CommerceDiscountDateTimeSchema.nullable(),
|
|
940
1087
|
endsAt: CommerceDiscountDateTimeSchema.nullable(),
|
|
941
|
-
support:
|
|
942
|
-
reasonCodes:
|
|
1088
|
+
support: z6.enum(["SUPPORTED", "UNSUPPORTED", "UNKNOWN"]),
|
|
1089
|
+
reasonCodes: z6.array(z6.string().min(1).max(64)).max(16)
|
|
943
1090
|
}).refine(
|
|
944
1091
|
(v) => (v.startsAt === null || v.endsAt === null || Date.parse(v.startsAt) < Date.parse(v.endsAt)) && (v.method !== "AUTOMATIC" || v.code === null)
|
|
945
1092
|
);
|
|
946
|
-
var CommerceDiscountCombinationFactsSchema =
|
|
947
|
-
discountClasses:
|
|
948
|
-
shopifyPlus:
|
|
949
|
-
combinesWith:
|
|
950
|
-
orderDiscounts:
|
|
951
|
-
productDiscounts:
|
|
952
|
-
shippingDiscounts:
|
|
1093
|
+
var CommerceDiscountCombinationFactsSchema = z6.strictObject({
|
|
1094
|
+
discountClasses: z6.array(z6.enum(["ORDER", "PRODUCT", "SHIPPING"])).max(3).nullable(),
|
|
1095
|
+
shopifyPlus: z6.boolean().nullable(),
|
|
1096
|
+
combinesWith: z6.strictObject({
|
|
1097
|
+
orderDiscounts: z6.boolean().nullable(),
|
|
1098
|
+
productDiscounts: z6.boolean().nullable(),
|
|
1099
|
+
shippingDiscounts: z6.boolean().nullable()
|
|
953
1100
|
}).nullable(),
|
|
954
|
-
discountTags:
|
|
955
|
-
allowedSameLineProductTags:
|
|
1101
|
+
discountTags: z6.array(z6.string().min(1).max(128)).max(64).nullable(),
|
|
1102
|
+
allowedSameLineProductTags: z6.array(z6.string().min(1).max(128)).max(64).nullable()
|
|
956
1103
|
});
|
|
957
|
-
var CommerceDiscountConditionFactsSchema =
|
|
958
|
-
provider:
|
|
959
|
-
completeness:
|
|
1104
|
+
var CommerceDiscountConditionFactsSchema = z6.strictObject({
|
|
1105
|
+
provider: z6.enum(["SHOPIFY", "WOOCOMMERCE"]),
|
|
1106
|
+
completeness: z6.enum(["COMPLETE", "PARTIAL", "UNKNOWN"]),
|
|
960
1107
|
observedAt: CommerceDiscountDateTimeSchema,
|
|
961
|
-
providerStatus:
|
|
1108
|
+
providerStatus: z6.string().max(64),
|
|
962
1109
|
unavailableAt: CommerceDiscountDateTimeSchema.nullable(),
|
|
963
|
-
discountKind:
|
|
1110
|
+
discountKind: z6.enum([
|
|
964
1111
|
"PERCENTAGE",
|
|
965
1112
|
"FIXED_AMOUNT",
|
|
966
1113
|
"FREE_SHIPPING",
|
|
@@ -970,8 +1117,8 @@ var CommerceDiscountConditionFactsSchema = z5.strictObject({
|
|
|
970
1117
|
]),
|
|
971
1118
|
discountValue: MoneySchema.nullable(),
|
|
972
1119
|
discountCurrency: CurrencySchema.nullable(),
|
|
973
|
-
targeting:
|
|
974
|
-
kind:
|
|
1120
|
+
targeting: z6.strictObject({
|
|
1121
|
+
kind: z6.enum([
|
|
975
1122
|
"ALL",
|
|
976
1123
|
"PRODUCTS",
|
|
977
1124
|
"VARIANTS",
|
|
@@ -980,38 +1127,38 @@ var CommerceDiscountConditionFactsSchema = z5.strictObject({
|
|
|
980
1127
|
"MIXED",
|
|
981
1128
|
"UNKNOWN"
|
|
982
1129
|
]),
|
|
983
|
-
includedProductIds:
|
|
984
|
-
includedVariantIds:
|
|
985
|
-
includedCategoryIds:
|
|
986
|
-
includedCollectionIds:
|
|
987
|
-
excludedProductIds:
|
|
988
|
-
excludedVariantIds:
|
|
989
|
-
excludedCategoryIds:
|
|
990
|
-
excludedCollectionIds:
|
|
1130
|
+
includedProductIds: z6.array(IdSchema).max(128),
|
|
1131
|
+
includedVariantIds: z6.array(IdSchema).max(128),
|
|
1132
|
+
includedCategoryIds: z6.array(IdSchema).max(128),
|
|
1133
|
+
includedCollectionIds: z6.array(IdSchema).max(128),
|
|
1134
|
+
excludedProductIds: z6.array(IdSchema).max(128),
|
|
1135
|
+
excludedVariantIds: z6.array(IdSchema).max(128),
|
|
1136
|
+
excludedCategoryIds: z6.array(IdSchema).max(128),
|
|
1137
|
+
excludedCollectionIds: z6.array(IdSchema).max(128)
|
|
991
1138
|
}),
|
|
992
1139
|
minimumSubtotal: MoneySchema.nullable(),
|
|
993
1140
|
maximumSubtotal: MoneySchema.nullable(),
|
|
994
1141
|
subtotalRequirementCurrency: CurrencySchema.nullable(),
|
|
995
|
-
minimumQuantity:
|
|
996
|
-
usageLimit:
|
|
997
|
-
usageCount:
|
|
998
|
-
perCustomerLimit:
|
|
999
|
-
customerScope:
|
|
1000
|
-
excludesSaleItems:
|
|
1001
|
-
individualUse:
|
|
1142
|
+
minimumQuantity: z6.number().int().nonnegative().nullable(),
|
|
1143
|
+
usageLimit: z6.number().int().nonnegative().nullable(),
|
|
1144
|
+
usageCount: z6.number().int().nonnegative().nullable(),
|
|
1145
|
+
perCustomerLimit: z6.number().int().nonnegative().nullable(),
|
|
1146
|
+
customerScope: z6.enum(["ALL", "RESTRICTED", "UNKNOWN"]),
|
|
1147
|
+
excludesSaleItems: z6.boolean().nullable(),
|
|
1148
|
+
individualUse: z6.boolean().nullable(),
|
|
1002
1149
|
combination: CommerceDiscountCombinationFactsSchema,
|
|
1003
|
-
unrepresentedConditions:
|
|
1150
|
+
unrepresentedConditions: z6.array(z6.string().min(1).max(128)).max(24)
|
|
1004
1151
|
});
|
|
1005
|
-
var CommerceDiscountDetailsSchema =
|
|
1152
|
+
var CommerceDiscountDetailsSchema = z6.strictObject({
|
|
1006
1153
|
offer: CommerceOfferSchema,
|
|
1007
1154
|
facts: CommerceDiscountConditionFactsSchema,
|
|
1008
|
-
providerDiscountId:
|
|
1155
|
+
providerDiscountId: z6.string().min(1).max(191).nullable()
|
|
1009
1156
|
});
|
|
1010
|
-
var condition =
|
|
1011
|
-
code:
|
|
1012
|
-
description:
|
|
1157
|
+
var condition = z6.strictObject({
|
|
1158
|
+
code: z6.string().min(1).max(64),
|
|
1159
|
+
description: z6.string().max(256)
|
|
1013
1160
|
});
|
|
1014
|
-
var CommerceEvidenceSchema =
|
|
1161
|
+
var CommerceEvidenceSchema = z6.strictObject({
|
|
1015
1162
|
evidenceId: HashSchema,
|
|
1016
1163
|
turn: CommerceTurnIdentitySchema,
|
|
1017
1164
|
grantId: IdSchema,
|
|
@@ -1022,7 +1169,7 @@ var CommerceEvidenceSchema = z5.strictObject({
|
|
|
1022
1169
|
ruleFingerprint: HashSchema,
|
|
1023
1170
|
evaluatedAt: DateSchema,
|
|
1024
1171
|
expiresAt: DateSchema,
|
|
1025
|
-
outcome:
|
|
1172
|
+
outcome: z6.enum([
|
|
1026
1173
|
"QUALIFIES_FOR_KNOWN_RULES",
|
|
1027
1174
|
"DOES_NOT_QUALIFY",
|
|
1028
1175
|
"UNKNOWN",
|
|
@@ -1031,8 +1178,8 @@ var CommerceEvidenceSchema = z5.strictObject({
|
|
|
1031
1178
|
currency: CurrencySchema.nullable(),
|
|
1032
1179
|
savings: MoneySchema.nullable(),
|
|
1033
1180
|
resultingTotal: MoneySchema.nullable(),
|
|
1034
|
-
evaluatedConditions:
|
|
1035
|
-
unresolvedConditions:
|
|
1181
|
+
evaluatedConditions: z6.array(condition).max(32),
|
|
1182
|
+
unresolvedConditions: z6.array(condition).max(32)
|
|
1036
1183
|
}).superRefine((v, c) => {
|
|
1037
1184
|
if (Date.parse(v.expiresAt) - Date.parse(v.evaluatedAt) > 6e4)
|
|
1038
1185
|
c.addIssue({
|
|
@@ -1042,16 +1189,16 @@ var CommerceEvidenceSchema = z5.strictObject({
|
|
|
1042
1189
|
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))
|
|
1043
1190
|
c.addIssue({ code: "custom", message: "Unsupported qualifying claim" });
|
|
1044
1191
|
});
|
|
1045
|
-
var CommerceAlternativeSchema =
|
|
1192
|
+
var CommerceAlternativeSchema = z6.strictObject({
|
|
1046
1193
|
product: CommerceProductSchema,
|
|
1047
1194
|
proposal: CommerceProposalSchema,
|
|
1048
1195
|
extraSpend: MoneySchema.nullable(),
|
|
1049
1196
|
resultingTotal: MoneySchema.nullable(),
|
|
1050
1197
|
currency: CurrencySchema.nullable(),
|
|
1051
1198
|
evidence: CommerceEvidenceSchema.nullable(),
|
|
1052
|
-
similarityReasons:
|
|
1199
|
+
similarityReasons: z6.array(z6.string().max(256)).max(3)
|
|
1053
1200
|
}).refine((v) => v.product.available === true);
|
|
1054
|
-
var CommerceErrorCodeSchema =
|
|
1201
|
+
var CommerceErrorCodeSchema = z6.enum([
|
|
1055
1202
|
"INVALID_INPUT",
|
|
1056
1203
|
"DENIED",
|
|
1057
1204
|
"STALE_TURN",
|
|
@@ -1062,182 +1209,182 @@ var CommerceErrorCodeSchema = z5.enum([
|
|
|
1062
1209
|
"INCOMPATIBLE_VERSION"
|
|
1063
1210
|
]);
|
|
1064
1211
|
function commerceToolResultSchema(data) {
|
|
1065
|
-
return
|
|
1066
|
-
|
|
1212
|
+
return z6.union([
|
|
1213
|
+
z6.strictObject({
|
|
1067
1214
|
contractVersion: ContractVersionSchema,
|
|
1068
|
-
status:
|
|
1215
|
+
status: z6.literal("OK"),
|
|
1069
1216
|
data,
|
|
1070
|
-
renderedText:
|
|
1217
|
+
renderedText: z6.string().max(4096)
|
|
1071
1218
|
}),
|
|
1072
|
-
|
|
1219
|
+
z6.strictObject({
|
|
1073
1220
|
contractVersion: ContractVersionSchema,
|
|
1074
|
-
status:
|
|
1221
|
+
status: z6.literal("ERROR"),
|
|
1075
1222
|
code: CommerceErrorCodeSchema,
|
|
1076
|
-
retryable:
|
|
1077
|
-
renderedText:
|
|
1223
|
+
retryable: z6.boolean(),
|
|
1224
|
+
renderedText: z6.string().max(4096).optional()
|
|
1078
1225
|
})
|
|
1079
1226
|
]);
|
|
1080
1227
|
}
|
|
1081
1228
|
var CommerceToolResultSchema = commerceToolResultSchema(
|
|
1082
1229
|
boundedJson(262144)
|
|
1083
1230
|
);
|
|
1084
|
-
var wireId =
|
|
1085
|
-
var taxonomySource =
|
|
1086
|
-
var CommerceCategoryCandidateSchema =
|
|
1231
|
+
var wireId = z6.string().min(1).max(128);
|
|
1232
|
+
var taxonomySource = z6.enum(["SHOPIFY_STANDARD_PRODUCT_TAXONOMY"]).meta({ maxLength: 33 });
|
|
1233
|
+
var CommerceCategoryCandidateSchema = z6.strictObject({
|
|
1087
1234
|
categoryId: wireId,
|
|
1088
|
-
name:
|
|
1089
|
-
fullName:
|
|
1235
|
+
name: z6.string().min(1).max(512),
|
|
1236
|
+
fullName: z6.string().min(1).max(4096),
|
|
1090
1237
|
parentId: wireId.nullable(),
|
|
1091
|
-
level:
|
|
1092
|
-
ancestorIds:
|
|
1093
|
-
distance:
|
|
1238
|
+
level: z6.number().int().min(0).max(32),
|
|
1239
|
+
ancestorIds: z6.array(wireId).max(32),
|
|
1240
|
+
distance: z6.number().min(0).max(2)
|
|
1094
1241
|
});
|
|
1095
|
-
var CommerceCategoryResolutionSchema =
|
|
1096
|
-
|
|
1097
|
-
outcome:
|
|
1242
|
+
var CommerceCategoryResolutionSchema = z6.union([
|
|
1243
|
+
z6.strictObject({
|
|
1244
|
+
outcome: z6.enum(["CANDIDATES", "NO_CANDIDATES"]).meta({ maxLength: 13 }),
|
|
1098
1245
|
generationId: wireId,
|
|
1099
1246
|
source: taxonomySource,
|
|
1100
|
-
taxonomyVersion:
|
|
1101
|
-
languageTag:
|
|
1102
|
-
candidates:
|
|
1247
|
+
taxonomyVersion: z6.string().min(1).max(64),
|
|
1248
|
+
languageTag: z6.string().min(1).max(35),
|
|
1249
|
+
candidates: z6.array(CommerceCategoryCandidateSchema).max(10)
|
|
1103
1250
|
}),
|
|
1104
|
-
|
|
1105
|
-
outcome:
|
|
1106
|
-
reasonCode:
|
|
1251
|
+
z6.strictObject({
|
|
1252
|
+
outcome: z6.enum(["UNAVAILABLE"]).meta({ maxLength: 11 }),
|
|
1253
|
+
reasonCode: z6.enum(["NOT_READY", "TEMPORARY_UNAVAILABLE"]).meta({ maxLength: 21 })
|
|
1107
1254
|
})
|
|
1108
1255
|
]);
|
|
1109
|
-
var CommerceOptionalLookupUnavailableSchema =
|
|
1110
|
-
outcome:
|
|
1111
|
-
reasonCode:
|
|
1256
|
+
var CommerceOptionalLookupUnavailableSchema = z6.strictObject({
|
|
1257
|
+
outcome: z6.enum(["UNAVAILABLE"]).meta({ maxLength: 11 }),
|
|
1258
|
+
reasonCode: z6.enum(["TEMPORARY_UNAVAILABLE"]).meta({ maxLength: 21 })
|
|
1112
1259
|
});
|
|
1113
|
-
var CommerceProductRecommendationSelectionSchema =
|
|
1114
|
-
productRecommendationVersion:
|
|
1115
|
-
productRecommendations:
|
|
1116
|
-
scope:
|
|
1260
|
+
var CommerceProductRecommendationSelectionSchema = z6.strictObject({
|
|
1261
|
+
productRecommendationVersion: z6.enum(["1"]).meta({ maxLength: 1 }).optional(),
|
|
1262
|
+
productRecommendations: z6.array(z6.strictObject({
|
|
1263
|
+
scope: z6.enum(["PRODUCT_ONLY", "ADD_TO_BASKET", "REPLACE_BASKET_LINE"]).meta({ maxLength: 19 }),
|
|
1117
1264
|
basketLineId: wireId.nullable(),
|
|
1118
1265
|
productId: wireId,
|
|
1119
1266
|
variantId: wireId.nullable(),
|
|
1120
|
-
quantity:
|
|
1121
|
-
promotionKind:
|
|
1122
|
-
offerIds:
|
|
1267
|
+
quantity: z6.number().int().min(1).max(99),
|
|
1268
|
+
promotionKind: z6.enum(["NONE", "NATIVE_SALE", "DISCOUNT"]).meta({ maxLength: 11 }),
|
|
1269
|
+
offerIds: z6.array(wireId).max(3)
|
|
1123
1270
|
})).min(1).max(3).optional()
|
|
1124
1271
|
});
|
|
1125
|
-
var CommerceResponseDispositionSchema =
|
|
1272
|
+
var CommerceResponseDispositionSchema = z6.enum([
|
|
1126
1273
|
"STANDARD",
|
|
1127
1274
|
"OUT_OF_SCOPE_REDIRECT",
|
|
1128
1275
|
"SHIPPING_INFORMATION_UNVERIFIED"
|
|
1129
1276
|
]).meta({ maxLength: 31 });
|
|
1130
|
-
var CommerceAnswerPresentationSelectionSchema =
|
|
1277
|
+
var CommerceAnswerPresentationSelectionSchema = z6.strictObject({
|
|
1131
1278
|
responseDisposition: CommerceResponseDispositionSchema.optional(),
|
|
1132
|
-
shippingInformationSelection:
|
|
1279
|
+
shippingInformationSelection: z6.strictObject({
|
|
1133
1280
|
productId: wireId.nullable(),
|
|
1134
1281
|
variantId: wireId.nullable()
|
|
1135
1282
|
}).optional()
|
|
1136
1283
|
});
|
|
1137
|
-
var CommerceShippingInformationInputSchema =
|
|
1284
|
+
var CommerceShippingInformationInputSchema = z6.strictObject({
|
|
1138
1285
|
productId: wireId.nullable().default(null),
|
|
1139
1286
|
variantId: wireId.nullable().default(null)
|
|
1140
1287
|
});
|
|
1141
|
-
var CommerceShippingInformationSchema =
|
|
1142
|
-
provider:
|
|
1288
|
+
var CommerceShippingInformationSchema = z6.strictObject({
|
|
1289
|
+
provider: z6.enum(["SHOPIFY", "WOOCOMMERCE"]).meta({ maxLength: 11 }),
|
|
1143
1290
|
observedAt: DateSchema,
|
|
1144
|
-
product:
|
|
1145
|
-
status:
|
|
1291
|
+
product: z6.strictObject({
|
|
1292
|
+
status: z6.enum(["NOT_REQUESTED", "VARIANT_REQUIRED", "AVAILABLE"]).meta({ maxLength: 16 }),
|
|
1146
1293
|
productId: wireId.nullable(),
|
|
1147
1294
|
variantId: wireId.nullable(),
|
|
1148
|
-
requiresShipping:
|
|
1149
|
-
virtual:
|
|
1150
|
-
weight:
|
|
1151
|
-
value:
|
|
1152
|
-
unit:
|
|
1295
|
+
requiresShipping: z6.boolean().nullable(),
|
|
1296
|
+
virtual: z6.boolean().nullable(),
|
|
1297
|
+
weight: z6.strictObject({
|
|
1298
|
+
value: z6.number().min(0),
|
|
1299
|
+
unit: z6.enum(["GRAMS", "KILOGRAMS", "OUNCES", "POUNDS"]).meta({ maxLength: 9 }).nullable()
|
|
1153
1300
|
}).nullable(),
|
|
1154
|
-
dimensions:
|
|
1155
|
-
length:
|
|
1156
|
-
width:
|
|
1157
|
-
height:
|
|
1158
|
-
unit:
|
|
1301
|
+
dimensions: z6.strictObject({
|
|
1302
|
+
length: z6.number().min(0).nullable(),
|
|
1303
|
+
width: z6.number().min(0).nullable(),
|
|
1304
|
+
height: z6.number().min(0).nullable(),
|
|
1305
|
+
unit: z6.string().min(1).max(16).nullable()
|
|
1159
1306
|
}).nullable(),
|
|
1160
1307
|
shippingClassId: wireId.nullable(),
|
|
1161
|
-
shippingClassSlug:
|
|
1308
|
+
shippingClassSlug: z6.string().min(1).max(512).nullable()
|
|
1162
1309
|
}),
|
|
1163
|
-
policy:
|
|
1164
|
-
status:
|
|
1165
|
-
trust:
|
|
1166
|
-
title:
|
|
1167
|
-
bodyStatus:
|
|
1168
|
-
bodyHtml:
|
|
1169
|
-
url:
|
|
1310
|
+
policy: z6.strictObject({
|
|
1311
|
+
status: z6.enum(["AVAILABLE", "NOT_CONFIGURED", "SCOPE_NOT_GRANTED", "UNSUPPORTED"]).meta({ maxLength: 17 }),
|
|
1312
|
+
trust: z6.enum(["UNTRUSTED_REFERENCE"]).meta({ maxLength: 19 }),
|
|
1313
|
+
title: z6.string().min(1).max(512).nullable(),
|
|
1314
|
+
bodyStatus: z6.enum(["AVAILABLE", "EMPTY", "TOO_LARGE", "NOT_AVAILABLE"]).meta({ maxLength: 13 }),
|
|
1315
|
+
bodyHtml: z6.string().min(1).max(8e3).nullable(),
|
|
1316
|
+
url: z6.url({ protocol: /^https$/ }).min(1).max(2048).nullable(),
|
|
1170
1317
|
updatedAt: DateSchema.nullable()
|
|
1171
1318
|
})
|
|
1172
1319
|
});
|
|
1173
|
-
var limit =
|
|
1320
|
+
var limit = z6.number().int().min(1).max(3).default(3);
|
|
1174
1321
|
var CommerceToolInputs = {
|
|
1175
|
-
commerce_resolve_product_categories:
|
|
1176
|
-
query:
|
|
1177
|
-
limit:
|
|
1322
|
+
commerce_resolve_product_categories: z6.strictObject({
|
|
1323
|
+
query: z6.string().min(1).max(200),
|
|
1324
|
+
limit: z6.number().int().min(1).max(10).default(5)
|
|
1178
1325
|
}),
|
|
1179
1326
|
commerce_get_shipping_information: CommerceShippingInformationInputSchema,
|
|
1180
|
-
commerce_get_basket:
|
|
1181
|
-
commerce_search_products:
|
|
1182
|
-
query:
|
|
1183
|
-
category:
|
|
1184
|
-
system:
|
|
1327
|
+
commerce_get_basket: z6.strictObject({}),
|
|
1328
|
+
commerce_search_products: z6.strictObject({
|
|
1329
|
+
query: z6.string().min(1).max(200).nullable().default(null),
|
|
1330
|
+
category: z6.strictObject({
|
|
1331
|
+
system: z6.enum(["SHOPIFY_STANDARD_PRODUCT_TAXONOMY", "WOOCOMMERCE_PRODUCT_CATEGORY"]).meta({ maxLength: 33 }),
|
|
1185
1332
|
id: wireId,
|
|
1186
|
-
taxonomyVersion:
|
|
1333
|
+
taxonomyVersion: z6.string().min(1).max(64).nullable()
|
|
1187
1334
|
}).optional(),
|
|
1188
|
-
browse:
|
|
1335
|
+
browse: z6.boolean().default(false),
|
|
1189
1336
|
maximumPrice: MoneySchema.optional(),
|
|
1190
|
-
availableOnly:
|
|
1191
|
-
limit:
|
|
1192
|
-
cursor:
|
|
1337
|
+
availableOnly: z6.boolean().default(true),
|
|
1338
|
+
limit: z6.number().int().min(1).max(20).default(10),
|
|
1339
|
+
cursor: z6.string().max(2048).nullable().default(null)
|
|
1193
1340
|
}),
|
|
1194
|
-
commerce_get_product:
|
|
1341
|
+
commerce_get_product: z6.strictObject({
|
|
1195
1342
|
productId: IdSchema,
|
|
1196
1343
|
variantId: IdSchema.nullable()
|
|
1197
1344
|
}),
|
|
1198
|
-
commerce_get_discount_options:
|
|
1199
|
-
limit:
|
|
1200
|
-
cursor:
|
|
1345
|
+
commerce_get_discount_options: z6.strictObject({
|
|
1346
|
+
limit: z6.number().int().min(1).max(50).default(20),
|
|
1347
|
+
cursor: z6.string().max(2048).nullable().default(null)
|
|
1201
1348
|
}),
|
|
1202
|
-
commerce_get_discount_details:
|
|
1203
|
-
commerce_evaluate_discount:
|
|
1349
|
+
commerce_get_discount_details: z6.strictObject({ offerId: IdSchema }),
|
|
1350
|
+
commerce_evaluate_discount: z6.strictObject({
|
|
1204
1351
|
offerId: IdSchema,
|
|
1205
1352
|
proposal: CommerceProposalSchema.nullable()
|
|
1206
1353
|
}),
|
|
1207
|
-
commerce_find_qualifying_products:
|
|
1354
|
+
commerce_find_qualifying_products: z6.strictObject({
|
|
1208
1355
|
offerId: IdSchema,
|
|
1209
|
-
query:
|
|
1356
|
+
query: z6.string().min(1).max(200).nullable(),
|
|
1210
1357
|
limit
|
|
1211
1358
|
}),
|
|
1212
|
-
commerce_find_similar_products:
|
|
1359
|
+
commerce_find_similar_products: z6.strictObject({
|
|
1213
1360
|
variantId: IdSchema,
|
|
1214
1361
|
offerId: IdSchema.nullable(),
|
|
1215
1362
|
limit
|
|
1216
1363
|
})
|
|
1217
1364
|
};
|
|
1218
|
-
var alternatives =
|
|
1219
|
-
alternatives:
|
|
1220
|
-
truncated:
|
|
1365
|
+
var alternatives = z6.strictObject({
|
|
1366
|
+
alternatives: z6.array(CommerceAlternativeSchema).max(3),
|
|
1367
|
+
truncated: z6.boolean()
|
|
1221
1368
|
});
|
|
1222
1369
|
var CommerceToolOutputs = {
|
|
1223
1370
|
commerce_resolve_product_categories: CommerceCategoryResolutionSchema,
|
|
1224
1371
|
commerce_get_shipping_information: CommerceShippingInformationSchema,
|
|
1225
1372
|
commerce_get_basket: CommerceBasketSchema,
|
|
1226
|
-
commerce_search_products:
|
|
1227
|
-
products:
|
|
1228
|
-
cursor:
|
|
1229
|
-
truncated:
|
|
1373
|
+
commerce_search_products: z6.strictObject({
|
|
1374
|
+
products: z6.array(CommerceProductSchema).max(20),
|
|
1375
|
+
cursor: z6.string().max(2048).nullable(),
|
|
1376
|
+
truncated: z6.boolean()
|
|
1230
1377
|
}),
|
|
1231
|
-
commerce_get_product:
|
|
1378
|
+
commerce_get_product: z6.strictObject({
|
|
1232
1379
|
product: CommerceProductSchema.nullable()
|
|
1233
1380
|
}),
|
|
1234
|
-
commerce_get_discount_options:
|
|
1235
|
-
mode:
|
|
1236
|
-
offers:
|
|
1237
|
-
truncated:
|
|
1238
|
-
cursor:
|
|
1381
|
+
commerce_get_discount_options: z6.union([CommerceOptionalLookupUnavailableSchema, z6.strictObject({
|
|
1382
|
+
mode: z6.enum(["NONE", "FIXED", "AI_BEST_APPLICABLE"]),
|
|
1383
|
+
offers: z6.array(CommerceOfferSchema).max(50),
|
|
1384
|
+
truncated: z6.boolean(),
|
|
1385
|
+
cursor: z6.string().max(2048).nullable().optional()
|
|
1239
1386
|
})]),
|
|
1240
|
-
commerce_get_discount_details:
|
|
1387
|
+
commerce_get_discount_details: z6.union([CommerceOptionalLookupUnavailableSchema, z6.strictObject({
|
|
1241
1388
|
details: CommerceDiscountDetailsSchema.nullable()
|
|
1242
1389
|
})]),
|
|
1243
1390
|
commerce_evaluate_discount: CommerceEvidenceSchema,
|
|
@@ -1261,6 +1408,9 @@ export {
|
|
|
1261
1408
|
DetailsSchemaSchema,
|
|
1262
1409
|
matchesSubset,
|
|
1263
1410
|
compileSubset,
|
|
1411
|
+
validateCommercePurposeOutputSchema,
|
|
1412
|
+
CommercePurposeOutputSchemaSchema,
|
|
1413
|
+
compileCommercePurposeOutputSchema,
|
|
1264
1414
|
ExternalQueryValueSchema,
|
|
1265
1415
|
ExternalQueryMappingSchema,
|
|
1266
1416
|
ExternalQueryMappingsSchema,
|
|
@@ -1281,6 +1431,9 @@ export {
|
|
|
1281
1431
|
ConnectionIssueSchema,
|
|
1282
1432
|
ConnectionResultSchema,
|
|
1283
1433
|
ToolNameSchema,
|
|
1434
|
+
CommerceExecutionPurposeSchema,
|
|
1435
|
+
CommercePurposeProfileSchema,
|
|
1436
|
+
requireCommercePurposeProfile,
|
|
1284
1437
|
PublishedGrantedToolSchema,
|
|
1285
1438
|
PublishedToolDescriptorSchema,
|
|
1286
1439
|
CommerceBuiltInToolNameSchema,
|
|
@@ -1346,4 +1499,4 @@ export {
|
|
|
1346
1499
|
CommerceToolOutputs,
|
|
1347
1500
|
productBelongsToDomain
|
|
1348
1501
|
};
|
|
1349
|
-
//# sourceMappingURL=chunk-
|
|
1502
|
+
//# sourceMappingURL=chunk-BDGLKOCW.js.map
|