@modainteract/moda-interact-shared 2.8.0 → 3.0.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-XTKCNFLQ.js → chunk-H7AUKACO.js} +17 -2
- package/dist/{chunk-XTKCNFLQ.js.map → chunk-H7AUKACO.js.map} +1 -1
- package/dist/{chunk-FOM6C3JF.js → chunk-PE2JHOJX.js} +2 -2
- package/dist/commerce/index.d.ts +18 -3
- package/dist/commerce/index.js +17 -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 +2 -2
- package/dist/recovery-template-bindings.d.ts +4 -0
- package/dist/recovery-template-bindings.js +1 -0
- package/dist/recovery-template-bindings.js.map +1 -1
- package/dist/{response-C6-kYOel.d.ts → response-CAw8y5nS.d.ts} +67 -1
- package/dist/{types-CGQgT51t.d.ts → types-C0bsVczG.d.ts} +1 -1
- package/dist/woocommerce/index.d.ts +20 -0
- package/dist/woocommerce/index.js +14 -0
- package/dist/woocommerce/index.js.map +1 -1
- package/package.json +1 -1
- package/src/woocommerce/__fixtures__/woo-restore-v1.json +34 -0
- /package/dist/{chunk-FOM6C3JF.js.map → chunk-PE2JHOJX.js.map} +0 -0
package/dist/commerce/index.js
CHANGED
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
manifestMatchesGrant,
|
|
5
5
|
parseCommerceManifest,
|
|
6
6
|
selectCapabilities
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-PE2JHOJX.js";
|
|
8
8
|
import {
|
|
9
9
|
CommerceAlternativeSchema,
|
|
10
10
|
CommerceAssertionSchema,
|
|
11
11
|
CommerceBasketSchema,
|
|
12
12
|
CommerceConversationGrantSchema,
|
|
13
|
+
CommerceDiscountCombinationFactsSchema,
|
|
13
14
|
CommerceDiscountConditionFactsSchema,
|
|
14
15
|
CommerceDiscountDetailsSchema,
|
|
15
16
|
CommerceErrorCodeSchema,
|
|
@@ -80,7 +81,7 @@ import {
|
|
|
80
81
|
validateDefinitionVersion,
|
|
81
82
|
validateSubset,
|
|
82
83
|
verifyResponseContract
|
|
83
|
-
} from "../chunk-
|
|
84
|
+
} from "../chunk-H7AUKACO.js";
|
|
84
85
|
import {
|
|
85
86
|
ContractVersionSchema,
|
|
86
87
|
CurrencySchema,
|
|
@@ -484,6 +485,18 @@ var CommerceOutreachToolContextSchema = z2.strictObject({
|
|
|
484
485
|
purpose: z2.literal("INITIAL_RECOVERY_OUTREACH")
|
|
485
486
|
});
|
|
486
487
|
|
|
488
|
+
// src/commerce/outreach-checkout-offer-set.ts
|
|
489
|
+
import { z as z3 } from "zod";
|
|
490
|
+
var InitialOutreachCheckoutOfferSetSchema = z3.strictObject({
|
|
491
|
+
schemaVersion: z3.literal("moda.outreach.checkout-offers.v1"),
|
|
492
|
+
offers: z3.array(z3.strictObject({
|
|
493
|
+
offerId: z3.string().min(1).max(191),
|
|
494
|
+
providerDiscountId: z3.string().min(1).max(191).nullable(),
|
|
495
|
+
method: z3.enum(["CODE", "AUTOMATIC"]),
|
|
496
|
+
code: z3.string().min(1).max(128).nullable()
|
|
497
|
+
})).min(1).max(3)
|
|
498
|
+
});
|
|
499
|
+
|
|
487
500
|
// src/commerce/fixtures.ts
|
|
488
501
|
var exampleTool = {
|
|
489
502
|
toolId: "tool-fixture",
|
|
@@ -584,6 +597,7 @@ export {
|
|
|
584
597
|
CommerceAssertionSchema,
|
|
585
598
|
CommerceBasketSchema,
|
|
586
599
|
CommerceConversationGrantSchema,
|
|
600
|
+
CommerceDiscountCombinationFactsSchema,
|
|
587
601
|
CommerceDiscountConditionFactsSchema,
|
|
588
602
|
CommerceDiscountDetailsSchema,
|
|
589
603
|
CommerceErrorCodeSchema,
|
|
@@ -631,6 +645,7 @@ export {
|
|
|
631
645
|
GrantedToolsSchema,
|
|
632
646
|
HashSchema,
|
|
633
647
|
IdSchema,
|
|
648
|
+
InitialOutreachCheckoutOfferSetSchema,
|
|
634
649
|
InputSchemaSchema,
|
|
635
650
|
LanguageSchema,
|
|
636
651
|
MAX_STORE_CATEGORY_PROMPT_CONDITIONS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commerce/store-category-prompt.ts","../../src/commerce/outreach-context.ts","../../src/commerce/fixtures.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const STORE_CATEGORY_PROMPT_RUNTIME_VERSION = \"store-category-prompt.v1\" as const;\nexport const MAX_STORE_CATEGORY_PROMPT_SOURCE_CHARS = 100_000;\nexport const MAX_STORE_CATEGORY_PROMPT_RENDERED_CHARS = 100_000;\nexport const MAX_STORE_CATEGORY_PROMPT_CONDITIONS = 256;\nconst MAX_CONTROL_TAGS = 512;\nconst MAX_CONTROL_DEPTH = 8;\nconst MAX_EXPRESSION_CHARS = 1_024;\n\nconst forbiddenConditionKeys = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\nconst conditionKeyPattern = /^[a-z][a-z0-9_]{0,127}$/;\n\nexport const StoreCategoryPromptConditionKeySchema = z\n .string()\n .regex(conditionKeyPattern)\n .refine((value) => !forbiddenConditionKeys.has(value));\n\nexport type StoreCategoryPromptConditionKey = z.infer<typeof StoreCategoryPromptConditionKeySchema>;\n\nexport const StoreCategoryPromptContextSchema = z.strictObject({\n mappings: z\n .record(StoreCategoryPromptConditionKeySchema, z.boolean())\n .refine((value) => Object.keys(value).length <= MAX_STORE_CATEGORY_PROMPT_CONDITIONS),\n});\n\nexport type StoreCategoryPromptContext = z.infer<typeof StoreCategoryPromptContextSchema>;\n\nexport type StoreCategoryPromptTemplateIssue = {\n path: \"/promptText\";\n code:\n | \"invalid_prompt_source\"\n | \"unsupported_template_construct\"\n | \"invalid_template_structure\"\n | \"invalid_template_expression\"\n | \"invalid_mapping_condition\"\n | \"unknown_mapping_condition\"\n | \"template_too_complex\"\n | \"rendered_prompt_too_large\";\n message: string;\n};\n\nexport type StoreCategoryPromptTemplateValidation = {\n valid: boolean;\n issues: StoreCategoryPromptTemplateIssue[];\n referencedConditionKeys: string[];\n};\n\nexport type StoreCategoryPromptRenderResult =\n | { ok: true; promptText: string; referencedConditionKeys: string[] }\n | { ok: false; issues: StoreCategoryPromptTemplateIssue[] };\n\ntype ExpressionNode =\n | { kind: \"condition\"; key: string }\n | { kind: \"not\"; operand: ExpressionNode }\n | { kind: \"and\"; left: ExpressionNode; right: ExpressionNode }\n | { kind: \"or\"; left: ExpressionNode; right: ExpressionNode };\n\ntype TemplateNode =\n | { kind: \"text\"; text: string }\n | {\n kind: \"if\";\n branches: Array<{ expression: ExpressionNode; body: TemplateNode[] }>;\n elseBody: TemplateNode[] | null;\n };\n\ntype TemplateToken =\n | { kind: \"text\"; text: string }\n | { kind: \"control\"; source: string }\n | { kind: \"unsupported\"; source: string; marker: \"interpolation\" | \"comment\" };\n\ntype CompileResult = {\n issues: StoreCategoryPromptTemplateIssue[];\n nodes: TemplateNode[];\n referencedConditionKeys: string[];\n};\n\nfunction issue(code: StoreCategoryPromptTemplateIssue[\"code\"], message: string): StoreCategoryPromptTemplateIssue {\n return { path: \"/promptText\", code, message };\n}\n\nfunction boundedIssues(issues: StoreCategoryPromptTemplateIssue[]): StoreCategoryPromptTemplateIssue[] {\n return issues.slice(0, 32).map((entry) => ({\n path: entry.path,\n code: entry.code,\n message: entry.message.slice(0, 512),\n }));\n}\n\nfunction sourceLength(value: string): number {\n return Array.from(value).length;\n}\n\nfunction findNextMarker(source: string, start: number): { index: number; marker: \"{%\" | \"{{\" | \"{#\" } | null {\n let best: { index: number; marker: \"{%\" | \"{{\" | \"{#\" } | null = null;\n for (const marker of [\"{%\", \"{{\", \"{#\"] as const) {\n const index = source.indexOf(marker, start);\n if (index >= 0 && (!best || index < best.index)) best = { index, marker };\n }\n return best;\n}\n\nfunction tokenizeTemplate(source: string, issues: StoreCategoryPromptTemplateIssue[]): TemplateToken[] {\n const tokens: TemplateToken[] = [];\n let cursor = 0;\n while (cursor < source.length) {\n const next = findNextMarker(source, cursor);\n if (!next) {\n tokens.push({ kind: \"text\", text: source.slice(cursor) });\n break;\n }\n if (next.index > cursor) tokens.push({ kind: \"text\", text: source.slice(cursor, next.index) });\n const closeMarker = next.marker === \"{%\" ? \"%}\" : next.marker === \"{{\" ? \"}}\" : \"#}\";\n const close = source.indexOf(closeMarker, next.index + 2);\n if (close < 0) {\n issues.push(issue(\"invalid_template_structure\", `Unclosed ${next.marker} template construct.`));\n tokens.push({ kind: \"text\", text: source.slice(next.index) });\n break;\n }\n const raw = source.slice(next.index + 2, close).trim();\n if (next.marker === \"{%\") tokens.push({ kind: \"control\", source: raw });\n else tokens.push({ kind: \"unsupported\", source: raw, marker: next.marker === \"{{\" ? \"interpolation\" : \"comment\" });\n cursor = close + 2;\n }\n if (source.length === 0) tokens.push({ kind: \"text\", text: \"\" });\n return tokens;\n}\n\ntype ExprToken = { kind: \"word\"; value: string } | { kind: \"dot\" } | { kind: \"lparen\" } | { kind: \"rparen\" };\n\nfunction lexExpression(source: string, issues: StoreCategoryPromptTemplateIssue[]): ExprToken[] | null {\n if (sourceLength(source) > MAX_EXPRESSION_CHARS) {\n issues.push(issue(\"template_too_complex\", `Conditional expressions must not exceed ${MAX_EXPRESSION_CHARS} characters.`));\n return null;\n }\n const tokens: ExprToken[] = [];\n let cursor = 0;\n while (cursor < source.length) {\n const char = source[cursor];\n if (/\\s/.test(char)) {\n cursor += 1;\n continue;\n }\n if (char === \".\") {\n tokens.push({ kind: \"dot\" });\n cursor += 1;\n continue;\n }\n if (char === \"(\") {\n tokens.push({ kind: \"lparen\" });\n cursor += 1;\n continue;\n }\n if (char === \")\") {\n tokens.push({ kind: \"rparen\" });\n cursor += 1;\n continue;\n }\n const match = /^[A-Za-z_][A-Za-z0-9_]*/.exec(source.slice(cursor));\n if (!match) {\n issues.push(issue(\"invalid_template_expression\", \"Conditional expressions may only use mappings.<conditionKey>, not, and, or, and parentheses.\"));\n return null;\n }\n tokens.push({ kind: \"word\", value: match[0] });\n cursor += match[0].length;\n }\n return tokens;\n}\n\nfunction parseExpression(source: string, issues: StoreCategoryPromptTemplateIssue[], referenced: string[]): ExpressionNode | null {\n const tokens = lexExpression(source, issues);\n if (!tokens || tokens.length === 0) {\n if (tokens?.length === 0) issues.push(issue(\"invalid_template_expression\", \"A conditional expression is required.\"));\n return null;\n }\n let index = 0;\n const peekWord = (word: string) => {\n const token = tokens[index];\n return token?.kind === \"word\" && token.value === word;\n };\n\n const parsePrimary = (): ExpressionNode | null => {\n const token = tokens[index];\n if (token?.kind === \"lparen\") {\n index += 1;\n const inner = parseOr();\n if (tokens[index]?.kind !== \"rparen\") {\n issues.push(issue(\"invalid_template_expression\", \"Conditional expression parentheses are unbalanced.\"));\n return null;\n }\n index += 1;\n return inner;\n }\n if (!peekWord(\"mappings\")) {\n issues.push(issue(\"invalid_template_expression\", \"Conditional expressions must reference mappings.<conditionKey>.\"));\n return null;\n }\n index += 1;\n if (tokens[index]?.kind !== \"dot\") {\n issues.push(issue(\"invalid_template_expression\", \"Mapping conditions must use mappings.<conditionKey>.\"));\n return null;\n }\n index += 1;\n const keyToken = tokens[index];\n if (keyToken?.kind !== \"word\") {\n issues.push(issue(\"invalid_mapping_condition\", \"A valid mapping condition key is required after mappings.\"));\n return null;\n }\n index += 1;\n if (!StoreCategoryPromptConditionKeySchema.safeParse(keyToken.value).success) {\n issues.push(issue(\"invalid_mapping_condition\", `Invalid mapping condition key: ${keyToken.value}.`));\n return null;\n }\n if (!referenced.includes(keyToken.value)) referenced.push(keyToken.value);\n return { kind: \"condition\", key: keyToken.value };\n };\n\n const parseNot = (): ExpressionNode | null => {\n if (peekWord(\"not\")) {\n index += 1;\n const operand = parseNot();\n return operand ? { kind: \"not\", operand } : null;\n }\n return parsePrimary();\n };\n\n const parseAnd = (): ExpressionNode | null => {\n let left = parseNot();\n while (left && peekWord(\"and\")) {\n index += 1;\n const right = parseNot();\n if (!right) return null;\n left = { kind: \"and\", left, right };\n }\n return left;\n };\n\n const parseOr = (): ExpressionNode | null => {\n let left = parseAnd();\n while (left && peekWord(\"or\")) {\n index += 1;\n const right = parseAnd();\n if (!right) return null;\n left = { kind: \"or\", left, right };\n }\n return left;\n };\n\n const expression = parseOr();\n if (expression && index !== tokens.length) {\n issues.push(issue(\"invalid_template_expression\", \"Conditional expression contains unsupported syntax.\"));\n return null;\n }\n return expression;\n}\n\nfunction compileStoreCategoryPromptTemplate(source: string): CompileResult {\n const issues: StoreCategoryPromptTemplateIssue[] = [];\n const referencedConditionKeys: string[] = [];\n const nodes: TemplateNode[] = [];\n\n if (source.trim().length === 0) issues.push(issue(\"invalid_prompt_source\", \"Prompt template must not be blank.\"));\n if (sourceLength(source) > MAX_STORE_CATEGORY_PROMPT_SOURCE_CHARS) {\n issues.push(issue(\"invalid_prompt_source\", `Prompt template must not exceed ${MAX_STORE_CATEGORY_PROMPT_SOURCE_CHARS.toLocaleString()} characters.`));\n }\n\n const tokens = tokenizeTemplate(source, issues);\n type Frame = {\n node: Extract<TemplateNode, { kind: \"if\" }>;\n parentBody: TemplateNode[];\n currentBody: TemplateNode[];\n sawElse: boolean;\n };\n const stack: Frame[] = [];\n let currentBody = nodes;\n let controlCount = 0;\n\n for (const token of tokens) {\n if (token.kind === \"text\") {\n if (token.text) currentBody.push({ kind: \"text\", text: token.text });\n continue;\n }\n if (token.kind === \"unsupported\") {\n issues.push(issue(\n \"unsupported_template_construct\",\n token.marker === \"interpolation\"\n ? \"Variable interpolation is not supported in Store Category prompt templates.\"\n : \"Template comments are not supported in Store Category prompt templates.\",\n ));\n continue;\n }\n\n controlCount += 1;\n if (controlCount > MAX_CONTROL_TAGS) {\n issues.push(issue(\"template_too_complex\", `Prompt template must not contain more than ${MAX_CONTROL_TAGS} control tags.`));\n break;\n }\n\n const ifMatch = /^if\\s+([\\s\\S]+)$/.exec(token.source);\n if (ifMatch) {\n if (stack.length >= MAX_CONTROL_DEPTH) {\n issues.push(issue(\"template_too_complex\", `Conditional nesting must not exceed ${MAX_CONTROL_DEPTH} levels.`));\n continue;\n }\n const expression = parseExpression(ifMatch[1].trim(), issues, referencedConditionKeys);\n if (!expression) continue;\n const branchBody: TemplateNode[] = [];\n const node: Extract<TemplateNode, { kind: \"if\" }> = {\n kind: \"if\",\n branches: [{ expression, body: branchBody }],\n elseBody: null,\n };\n currentBody.push(node);\n const frame: Frame = { node, parentBody: currentBody, currentBody: branchBody, sawElse: false };\n stack.push(frame);\n currentBody = branchBody;\n continue;\n }\n\n const elifMatch = /^elif\\s+([\\s\\S]+)$/.exec(token.source);\n if (elifMatch) {\n const frame = stack.at(-1);\n if (!frame || frame.sawElse) {\n issues.push(issue(\"invalid_template_structure\", \"elif must appear inside an if block and before else.\"));\n continue;\n }\n const expression = parseExpression(elifMatch[1].trim(), issues, referencedConditionKeys);\n if (!expression) continue;\n const branchBody: TemplateNode[] = [];\n frame.node.branches.push({ expression, body: branchBody });\n frame.currentBody = branchBody;\n currentBody = branchBody;\n continue;\n }\n\n if (token.source === \"else\") {\n const frame = stack.at(-1);\n if (!frame || frame.sawElse) {\n issues.push(issue(\"invalid_template_structure\", \"else must appear once inside an if block.\"));\n continue;\n }\n const elseBody: TemplateNode[] = [];\n frame.node.elseBody = elseBody;\n frame.currentBody = elseBody;\n frame.sawElse = true;\n currentBody = elseBody;\n continue;\n }\n\n if (token.source === \"endif\") {\n const frame = stack.pop();\n if (!frame) {\n issues.push(issue(\"invalid_template_structure\", \"endif does not have a matching if block.\"));\n continue;\n }\n currentBody = frame.parentBody;\n continue;\n }\n\n issues.push(issue(\n \"unsupported_template_construct\",\n \"Only if, elif, else, and endif control tags are supported in Store Category prompt templates.\",\n ));\n }\n\n if (stack.length) issues.push(issue(\"invalid_template_structure\", \"Every if block must end with endif.\"));\n return { issues: boundedIssues(issues), nodes, referencedConditionKeys };\n}\n\nfunction validateAvailableConditionKeys(values: readonly string[], issues: StoreCategoryPromptTemplateIssue[]): Set<string> {\n if (values.length > MAX_STORE_CATEGORY_PROMPT_CONDITIONS) {\n issues.push(issue(\"template_too_complex\", `At most ${MAX_STORE_CATEGORY_PROMPT_CONDITIONS} mapping conditions are supported.`));\n }\n const keys = new Set<string>();\n for (const value of values.slice(0, MAX_STORE_CATEGORY_PROMPT_CONDITIONS + 1)) {\n if (!StoreCategoryPromptConditionKeySchema.safeParse(value).success) {\n issues.push(issue(\"invalid_mapping_condition\", `Invalid mapping condition key: ${value}.`));\n continue;\n }\n if (keys.has(value)) {\n issues.push(issue(\"invalid_mapping_condition\", `Duplicate mapping condition key: ${value}.`));\n continue;\n }\n keys.add(value);\n }\n return keys;\n}\n\nexport function validateStoreCategoryPromptTemplate(input: {\n source: string;\n availableConditionKeys: readonly string[];\n}): StoreCategoryPromptTemplateValidation {\n const compiled = compileStoreCategoryPromptTemplate(input.source);\n const issues = [...compiled.issues];\n const available = validateAvailableConditionKeys(input.availableConditionKeys, issues);\n for (const key of compiled.referencedConditionKeys) {\n if (!available.has(key)) issues.push(issue(\"unknown_mapping_condition\", `Prompt template references unavailable mapping condition: mappings.${key}.`));\n }\n const bounded = boundedIssues(issues);\n return { valid: bounded.length === 0, issues: bounded, referencedConditionKeys: compiled.referencedConditionKeys };\n}\n\n\nexport function createStoreCategoryPromptConditionBlock(conditionKey: string): string {\n const parsed = StoreCategoryPromptConditionKeySchema.safeParse(conditionKey);\n if (!parsed.success) throw new TypeError(`Invalid mapping condition key: ${conditionKey}.`);\n return `{% if mappings.${conditionKey} %}\\n\\n{% endif %}`;\n}\n\nexport function createStoreCategoryPromptContext(input: {\n availableConditionKeys: readonly string[];\n selectedConditionKeys: readonly string[];\n}): StoreCategoryPromptContext {\n const issues: StoreCategoryPromptTemplateIssue[] = [];\n const available = validateAvailableConditionKeys(input.availableConditionKeys, issues);\n const selected = validateAvailableConditionKeys(input.selectedConditionKeys, issues);\n for (const key of selected) {\n if (!available.has(key)) issues.push(issue(\"unknown_mapping_condition\", `Selected mapping condition is unavailable: ${key}.`));\n }\n if (issues.length) throw new TypeError(issues[0].message);\n const mappings = Object.create(null) as Record<string, boolean>;\n for (const key of available) mappings[key] = selected.has(key);\n return { mappings };\n}\n\nfunction evaluateExpression(expression: ExpressionNode, mappings: Record<string, boolean>): boolean {\n switch (expression.kind) {\n case \"condition\":\n return mappings[expression.key] === true;\n case \"not\":\n return !evaluateExpression(expression.operand, mappings);\n case \"and\":\n return evaluateExpression(expression.left, mappings) && evaluateExpression(expression.right, mappings);\n case \"or\":\n return evaluateExpression(expression.left, mappings) || evaluateExpression(expression.right, mappings);\n }\n}\n\nfunction renderNodes(nodes: TemplateNode[], mappings: Record<string, boolean>, append: (text: string) => boolean): boolean {\n for (const node of nodes) {\n if (node.kind === \"text\") {\n if (!append(node.text)) return false;\n continue;\n }\n let renderedBranch = false;\n for (const branch of node.branches) {\n if (evaluateExpression(branch.expression, mappings)) {\n if (!renderNodes(branch.body, mappings, append)) return false;\n renderedBranch = true;\n break;\n }\n }\n if (!renderedBranch && node.elseBody && !renderNodes(node.elseBody, mappings, append)) return false;\n }\n return true;\n}\n\nexport function renderStoreCategoryPromptTemplate(input: {\n source: string;\n context: StoreCategoryPromptContext;\n}): StoreCategoryPromptRenderResult {\n const contextResult = StoreCategoryPromptContextSchema.safeParse(input.context);\n if (!contextResult.success) {\n return { ok: false, issues: [issue(\"invalid_mapping_condition\", \"Store Category prompt context contains invalid mapping conditions.\")] };\n }\n const availableConditionKeys = Object.keys(contextResult.data.mappings);\n const validation = validateStoreCategoryPromptTemplate({ source: input.source, availableConditionKeys });\n if (!validation.valid) return { ok: false, issues: validation.issues };\n\n const compiled = compileStoreCategoryPromptTemplate(input.source);\n let output = \"\";\n let outputChars = 0;\n const append = (text: string) => {\n outputChars += sourceLength(text);\n if (outputChars > MAX_STORE_CATEGORY_PROMPT_RENDERED_CHARS) return false;\n output += text;\n return true;\n };\n const rendered = renderNodes(compiled.nodes, contextResult.data.mappings, append);\n if (!rendered) {\n return {\n ok: false,\n issues: [issue(\"rendered_prompt_too_large\", `Rendered prompt must not exceed ${MAX_STORE_CATEGORY_PROMPT_RENDERED_CHARS.toLocaleString()} characters.`)],\n };\n }\n return { ok: true, promptText: output, referencedConditionKeys: validation.referencedConditionKeys };\n}\n","import { z } from \"zod\";\n\nexport const CommerceOutreachToolContextSchema = z.strictObject({\n purpose: z.literal(\"INITIAL_RECOVERY_OUTREACH\"),\n});\n\nexport type CommerceOutreachToolContext =\n z.infer<typeof CommerceOutreachToolContextSchema>;\n","/** Synthetic examples; no provider identity, schema artifact or publication claim. */\nimport type {\n CommerceManifest,\n CommerceConversationGrant,\n CommerceTurnIdentity,\n} from \"./schemas\";\nimport {\n EMPTY_RESPONSE_CONTRACT,\n type CommerceFinalResponse,\n} from \"./response\";\nimport type { Digest } from \"./canonical-json\";\nimport { responseContractCanonicalJson } from \"./canonical-json\";\nimport type { ToolDescriptor, CommerceToolDefinition } from \"./definitions\";\nexport const exampleTool: ToolDescriptor = {\n toolId: \"tool-fixture\",\n toolRevisionId: \"revision-fixture\",\n name: \"never_seeded_catalogue_facts\",\n definitionVersion: \"1.0.0\",\n description: \"Read synthetic catalogue facts.\",\n inputSchema: {\n type: \"object\",\n properties: { handle: { type: \"string\", minLength: 1, maxLength: 255 } },\n required: [\"handle\"],\n additionalProperties: false,\n },\n};\nexport const exampleDefinition: CommerceToolDefinition = {\n name: exampleTool.name,\n definitionVersion: \"1.0.0\",\n description: exampleTool.description,\n inputSchema: exampleTool.inputSchema,\n execution: {\n kind: \"SHOPIFY_STOREFRONT_QUERY\",\n executorVersion: \"1.0.0\",\n apiVersion: \"2026-07\",\n schemaHash: \"a\".repeat(64),\n document:\n \"query ProductDetails($handle: String!) { product(handle: $handle) { title description } }\",\n operationName: \"ProductDetails\",\n variables: { handle: { input: \"handle\" } },\n resultPath: \"product\",\n },\n responseTemplate: {\n kind: \"text\",\n text: \"{{result.values.title}}: {{result.values.description}}\",\n unavailable: \"Product details could not be verified.\",\n },\n};\nexport const exampleTurn: CommerceTurnIdentity = {\n contractVersion: \"commerce.v1\",\n shopId: \"shop-fixture\",\n checkoutRecoveryId: \"recovery-fixture\",\n conversationId: \"conversation-fixture\",\n inboundVersion: 1,\n};\nexport function exampleManifest(\n digest: Digest,\n withTool = false,\n): CommerceManifest {\n const capabilities = withTool\n ? [{\n capabilityId: \"capability-fixture\",\n key: \"feature_product_read\",\n featureId: \"feature-fixture\",\n position: 0,\n toolDescriptor: structuredClone(exampleTool),\n }]\n : [];\n return {\n contractVersion: \"commerce.v1\",\n releaseId: \"release-fixture\",\n runnerCompatibility: \"^1.0.0\",\n capabilities,\n featureBehaviours: withTool\n ? [{ featureId: \"feature-fixture\", behaviourPrompt: \"Synthetic Feature behavior.\" }]\n : [],\n selectedCapabilityKeys: capabilities.map((capability) => capability.key),\n grantedTools: withTool\n ? [\n {\n toolId: exampleTool.toolId,\n toolRevisionId: exampleTool.toolRevisionId,\n toolName: exampleTool.name,\n definitionVersion: \"1.0.0\",\n capabilityKeys: [\"feature_product_read\"],\n },\n ]\n : [],\n responseContract: structuredClone(EMPTY_RESPONSE_CONTRACT),\n responseContractHash: digest(\n responseContractCanonicalJson(EMPTY_RESPONSE_CONTRACT),\n ),\n };\n}\nexport function exampleGrant(\n manifest: CommerceManifest,\n): CommerceConversationGrant {\n return {\n id: \"grant-fixture\",\n shopId: exampleTurn.shopId,\n conversationId: exampleTurn.conversationId,\n initialInboundVersion: 1,\n releaseId: manifest.releaseId,\n selectedCapabilityKeys: [...manifest.selectedCapabilityKeys],\n grantedTools: structuredClone(manifest.grantedTools),\n runnerVersion: \"1.0.0\",\n createdAt: \"2026-09-20T00:00:00.000Z\",\n expiresAt: null,\n };\n}\nexport const exampleFinal: CommerceFinalResponse = {\n answerKind: \"REFER_TO_STORE\",\n replyText:\n \"I cannot verify that information. Please contact the store directly.\",\n referralReason: \"INSUFFICIENT_TOOLS\",\n detectedLanguageTag: null,\n detectedLanguageConfidence: null,\n evidenceIds: [],\n details: {},\n};\n"],"mappings":";;;;;;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CAAC,EAAE,WAAW,mBAAmB,iBAAiB,8BAA8B,CAAC,IACjF,CAAC;AAAA,IACL,wBAAwB,aAAa,IAAI,CAAC,eAAe,WAAW,GAAG;AAAA,IACvE,cAAc,WACV;AAAA,MACE;AAAA,QACE,QAAQ,YAAY;AAAA,QACpB,gBAAgB,YAAY;AAAA,QAC5B,UAAU,YAAY;AAAA,QACtB,mBAAmB;AAAA,QACnB,gBAAgB,CAAC,sBAAsB;AAAA,MACzC;AAAA,IACF,IACA,CAAC;AAAA,IACL,kBAAkB,gBAAgB,uBAAuB;AAAA,IACzD,sBAAsB;AAAA,MACpB,8BAA8B,uBAAuB;AAAA,IACvD;AAAA,EACF;AACF;AACO,SAAS,aACd,UAC2B;AAC3B,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,QAAQ,YAAY;AAAA,IACpB,gBAAgB,YAAY;AAAA,IAC5B,uBAAuB;AAAA,IACvB,WAAW,SAAS;AAAA,IACpB,wBAAwB,CAAC,GAAG,SAAS,sBAAsB;AAAA,IAC3D,cAAc,gBAAgB,SAAS,YAAY;AAAA,IACnD,eAAe;AAAA,IACf,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AACF;AACO,IAAM,eAAsC;AAAA,EACjD,YAAY;AAAA,EACZ,WACE;AAAA,EACF,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,4BAA4B;AAAA,EAC5B,aAAa,CAAC;AAAA,EACd,SAAS,CAAC;AACZ;","names":["z"]}
|
|
1
|
+
{"version":3,"sources":["../../src/commerce/store-category-prompt.ts","../../src/commerce/outreach-context.ts","../../src/commerce/outreach-checkout-offer-set.ts","../../src/commerce/fixtures.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const STORE_CATEGORY_PROMPT_RUNTIME_VERSION = \"store-category-prompt.v1\" as const;\nexport const MAX_STORE_CATEGORY_PROMPT_SOURCE_CHARS = 100_000;\nexport const MAX_STORE_CATEGORY_PROMPT_RENDERED_CHARS = 100_000;\nexport const MAX_STORE_CATEGORY_PROMPT_CONDITIONS = 256;\nconst MAX_CONTROL_TAGS = 512;\nconst MAX_CONTROL_DEPTH = 8;\nconst MAX_EXPRESSION_CHARS = 1_024;\n\nconst forbiddenConditionKeys = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\nconst conditionKeyPattern = /^[a-z][a-z0-9_]{0,127}$/;\n\nexport const StoreCategoryPromptConditionKeySchema = z\n .string()\n .regex(conditionKeyPattern)\n .refine((value) => !forbiddenConditionKeys.has(value));\n\nexport type StoreCategoryPromptConditionKey = z.infer<typeof StoreCategoryPromptConditionKeySchema>;\n\nexport const StoreCategoryPromptContextSchema = z.strictObject({\n mappings: z\n .record(StoreCategoryPromptConditionKeySchema, z.boolean())\n .refine((value) => Object.keys(value).length <= MAX_STORE_CATEGORY_PROMPT_CONDITIONS),\n});\n\nexport type StoreCategoryPromptContext = z.infer<typeof StoreCategoryPromptContextSchema>;\n\nexport type StoreCategoryPromptTemplateIssue = {\n path: \"/promptText\";\n code:\n | \"invalid_prompt_source\"\n | \"unsupported_template_construct\"\n | \"invalid_template_structure\"\n | \"invalid_template_expression\"\n | \"invalid_mapping_condition\"\n | \"unknown_mapping_condition\"\n | \"template_too_complex\"\n | \"rendered_prompt_too_large\";\n message: string;\n};\n\nexport type StoreCategoryPromptTemplateValidation = {\n valid: boolean;\n issues: StoreCategoryPromptTemplateIssue[];\n referencedConditionKeys: string[];\n};\n\nexport type StoreCategoryPromptRenderResult =\n | { ok: true; promptText: string; referencedConditionKeys: string[] }\n | { ok: false; issues: StoreCategoryPromptTemplateIssue[] };\n\ntype ExpressionNode =\n | { kind: \"condition\"; key: string }\n | { kind: \"not\"; operand: ExpressionNode }\n | { kind: \"and\"; left: ExpressionNode; right: ExpressionNode }\n | { kind: \"or\"; left: ExpressionNode; right: ExpressionNode };\n\ntype TemplateNode =\n | { kind: \"text\"; text: string }\n | {\n kind: \"if\";\n branches: Array<{ expression: ExpressionNode; body: TemplateNode[] }>;\n elseBody: TemplateNode[] | null;\n };\n\ntype TemplateToken =\n | { kind: \"text\"; text: string }\n | { kind: \"control\"; source: string }\n | { kind: \"unsupported\"; source: string; marker: \"interpolation\" | \"comment\" };\n\ntype CompileResult = {\n issues: StoreCategoryPromptTemplateIssue[];\n nodes: TemplateNode[];\n referencedConditionKeys: string[];\n};\n\nfunction issue(code: StoreCategoryPromptTemplateIssue[\"code\"], message: string): StoreCategoryPromptTemplateIssue {\n return { path: \"/promptText\", code, message };\n}\n\nfunction boundedIssues(issues: StoreCategoryPromptTemplateIssue[]): StoreCategoryPromptTemplateIssue[] {\n return issues.slice(0, 32).map((entry) => ({\n path: entry.path,\n code: entry.code,\n message: entry.message.slice(0, 512),\n }));\n}\n\nfunction sourceLength(value: string): number {\n return Array.from(value).length;\n}\n\nfunction findNextMarker(source: string, start: number): { index: number; marker: \"{%\" | \"{{\" | \"{#\" } | null {\n let best: { index: number; marker: \"{%\" | \"{{\" | \"{#\" } | null = null;\n for (const marker of [\"{%\", \"{{\", \"{#\"] as const) {\n const index = source.indexOf(marker, start);\n if (index >= 0 && (!best || index < best.index)) best = { index, marker };\n }\n return best;\n}\n\nfunction tokenizeTemplate(source: string, issues: StoreCategoryPromptTemplateIssue[]): TemplateToken[] {\n const tokens: TemplateToken[] = [];\n let cursor = 0;\n while (cursor < source.length) {\n const next = findNextMarker(source, cursor);\n if (!next) {\n tokens.push({ kind: \"text\", text: source.slice(cursor) });\n break;\n }\n if (next.index > cursor) tokens.push({ kind: \"text\", text: source.slice(cursor, next.index) });\n const closeMarker = next.marker === \"{%\" ? \"%}\" : next.marker === \"{{\" ? \"}}\" : \"#}\";\n const close = source.indexOf(closeMarker, next.index + 2);\n if (close < 0) {\n issues.push(issue(\"invalid_template_structure\", `Unclosed ${next.marker} template construct.`));\n tokens.push({ kind: \"text\", text: source.slice(next.index) });\n break;\n }\n const raw = source.slice(next.index + 2, close).trim();\n if (next.marker === \"{%\") tokens.push({ kind: \"control\", source: raw });\n else tokens.push({ kind: \"unsupported\", source: raw, marker: next.marker === \"{{\" ? \"interpolation\" : \"comment\" });\n cursor = close + 2;\n }\n if (source.length === 0) tokens.push({ kind: \"text\", text: \"\" });\n return tokens;\n}\n\ntype ExprToken = { kind: \"word\"; value: string } | { kind: \"dot\" } | { kind: \"lparen\" } | { kind: \"rparen\" };\n\nfunction lexExpression(source: string, issues: StoreCategoryPromptTemplateIssue[]): ExprToken[] | null {\n if (sourceLength(source) > MAX_EXPRESSION_CHARS) {\n issues.push(issue(\"template_too_complex\", `Conditional expressions must not exceed ${MAX_EXPRESSION_CHARS} characters.`));\n return null;\n }\n const tokens: ExprToken[] = [];\n let cursor = 0;\n while (cursor < source.length) {\n const char = source[cursor];\n if (/\\s/.test(char)) {\n cursor += 1;\n continue;\n }\n if (char === \".\") {\n tokens.push({ kind: \"dot\" });\n cursor += 1;\n continue;\n }\n if (char === \"(\") {\n tokens.push({ kind: \"lparen\" });\n cursor += 1;\n continue;\n }\n if (char === \")\") {\n tokens.push({ kind: \"rparen\" });\n cursor += 1;\n continue;\n }\n const match = /^[A-Za-z_][A-Za-z0-9_]*/.exec(source.slice(cursor));\n if (!match) {\n issues.push(issue(\"invalid_template_expression\", \"Conditional expressions may only use mappings.<conditionKey>, not, and, or, and parentheses.\"));\n return null;\n }\n tokens.push({ kind: \"word\", value: match[0] });\n cursor += match[0].length;\n }\n return tokens;\n}\n\nfunction parseExpression(source: string, issues: StoreCategoryPromptTemplateIssue[], referenced: string[]): ExpressionNode | null {\n const tokens = lexExpression(source, issues);\n if (!tokens || tokens.length === 0) {\n if (tokens?.length === 0) issues.push(issue(\"invalid_template_expression\", \"A conditional expression is required.\"));\n return null;\n }\n let index = 0;\n const peekWord = (word: string) => {\n const token = tokens[index];\n return token?.kind === \"word\" && token.value === word;\n };\n\n const parsePrimary = (): ExpressionNode | null => {\n const token = tokens[index];\n if (token?.kind === \"lparen\") {\n index += 1;\n const inner = parseOr();\n if (tokens[index]?.kind !== \"rparen\") {\n issues.push(issue(\"invalid_template_expression\", \"Conditional expression parentheses are unbalanced.\"));\n return null;\n }\n index += 1;\n return inner;\n }\n if (!peekWord(\"mappings\")) {\n issues.push(issue(\"invalid_template_expression\", \"Conditional expressions must reference mappings.<conditionKey>.\"));\n return null;\n }\n index += 1;\n if (tokens[index]?.kind !== \"dot\") {\n issues.push(issue(\"invalid_template_expression\", \"Mapping conditions must use mappings.<conditionKey>.\"));\n return null;\n }\n index += 1;\n const keyToken = tokens[index];\n if (keyToken?.kind !== \"word\") {\n issues.push(issue(\"invalid_mapping_condition\", \"A valid mapping condition key is required after mappings.\"));\n return null;\n }\n index += 1;\n if (!StoreCategoryPromptConditionKeySchema.safeParse(keyToken.value).success) {\n issues.push(issue(\"invalid_mapping_condition\", `Invalid mapping condition key: ${keyToken.value}.`));\n return null;\n }\n if (!referenced.includes(keyToken.value)) referenced.push(keyToken.value);\n return { kind: \"condition\", key: keyToken.value };\n };\n\n const parseNot = (): ExpressionNode | null => {\n if (peekWord(\"not\")) {\n index += 1;\n const operand = parseNot();\n return operand ? { kind: \"not\", operand } : null;\n }\n return parsePrimary();\n };\n\n const parseAnd = (): ExpressionNode | null => {\n let left = parseNot();\n while (left && peekWord(\"and\")) {\n index += 1;\n const right = parseNot();\n if (!right) return null;\n left = { kind: \"and\", left, right };\n }\n return left;\n };\n\n const parseOr = (): ExpressionNode | null => {\n let left = parseAnd();\n while (left && peekWord(\"or\")) {\n index += 1;\n const right = parseAnd();\n if (!right) return null;\n left = { kind: \"or\", left, right };\n }\n return left;\n };\n\n const expression = parseOr();\n if (expression && index !== tokens.length) {\n issues.push(issue(\"invalid_template_expression\", \"Conditional expression contains unsupported syntax.\"));\n return null;\n }\n return expression;\n}\n\nfunction compileStoreCategoryPromptTemplate(source: string): CompileResult {\n const issues: StoreCategoryPromptTemplateIssue[] = [];\n const referencedConditionKeys: string[] = [];\n const nodes: TemplateNode[] = [];\n\n if (source.trim().length === 0) issues.push(issue(\"invalid_prompt_source\", \"Prompt template must not be blank.\"));\n if (sourceLength(source) > MAX_STORE_CATEGORY_PROMPT_SOURCE_CHARS) {\n issues.push(issue(\"invalid_prompt_source\", `Prompt template must not exceed ${MAX_STORE_CATEGORY_PROMPT_SOURCE_CHARS.toLocaleString()} characters.`));\n }\n\n const tokens = tokenizeTemplate(source, issues);\n type Frame = {\n node: Extract<TemplateNode, { kind: \"if\" }>;\n parentBody: TemplateNode[];\n currentBody: TemplateNode[];\n sawElse: boolean;\n };\n const stack: Frame[] = [];\n let currentBody = nodes;\n let controlCount = 0;\n\n for (const token of tokens) {\n if (token.kind === \"text\") {\n if (token.text) currentBody.push({ kind: \"text\", text: token.text });\n continue;\n }\n if (token.kind === \"unsupported\") {\n issues.push(issue(\n \"unsupported_template_construct\",\n token.marker === \"interpolation\"\n ? \"Variable interpolation is not supported in Store Category prompt templates.\"\n : \"Template comments are not supported in Store Category prompt templates.\",\n ));\n continue;\n }\n\n controlCount += 1;\n if (controlCount > MAX_CONTROL_TAGS) {\n issues.push(issue(\"template_too_complex\", `Prompt template must not contain more than ${MAX_CONTROL_TAGS} control tags.`));\n break;\n }\n\n const ifMatch = /^if\\s+([\\s\\S]+)$/.exec(token.source);\n if (ifMatch) {\n if (stack.length >= MAX_CONTROL_DEPTH) {\n issues.push(issue(\"template_too_complex\", `Conditional nesting must not exceed ${MAX_CONTROL_DEPTH} levels.`));\n continue;\n }\n const expression = parseExpression(ifMatch[1].trim(), issues, referencedConditionKeys);\n if (!expression) continue;\n const branchBody: TemplateNode[] = [];\n const node: Extract<TemplateNode, { kind: \"if\" }> = {\n kind: \"if\",\n branches: [{ expression, body: branchBody }],\n elseBody: null,\n };\n currentBody.push(node);\n const frame: Frame = { node, parentBody: currentBody, currentBody: branchBody, sawElse: false };\n stack.push(frame);\n currentBody = branchBody;\n continue;\n }\n\n const elifMatch = /^elif\\s+([\\s\\S]+)$/.exec(token.source);\n if (elifMatch) {\n const frame = stack.at(-1);\n if (!frame || frame.sawElse) {\n issues.push(issue(\"invalid_template_structure\", \"elif must appear inside an if block and before else.\"));\n continue;\n }\n const expression = parseExpression(elifMatch[1].trim(), issues, referencedConditionKeys);\n if (!expression) continue;\n const branchBody: TemplateNode[] = [];\n frame.node.branches.push({ expression, body: branchBody });\n frame.currentBody = branchBody;\n currentBody = branchBody;\n continue;\n }\n\n if (token.source === \"else\") {\n const frame = stack.at(-1);\n if (!frame || frame.sawElse) {\n issues.push(issue(\"invalid_template_structure\", \"else must appear once inside an if block.\"));\n continue;\n }\n const elseBody: TemplateNode[] = [];\n frame.node.elseBody = elseBody;\n frame.currentBody = elseBody;\n frame.sawElse = true;\n currentBody = elseBody;\n continue;\n }\n\n if (token.source === \"endif\") {\n const frame = stack.pop();\n if (!frame) {\n issues.push(issue(\"invalid_template_structure\", \"endif does not have a matching if block.\"));\n continue;\n }\n currentBody = frame.parentBody;\n continue;\n }\n\n issues.push(issue(\n \"unsupported_template_construct\",\n \"Only if, elif, else, and endif control tags are supported in Store Category prompt templates.\",\n ));\n }\n\n if (stack.length) issues.push(issue(\"invalid_template_structure\", \"Every if block must end with endif.\"));\n return { issues: boundedIssues(issues), nodes, referencedConditionKeys };\n}\n\nfunction validateAvailableConditionKeys(values: readonly string[], issues: StoreCategoryPromptTemplateIssue[]): Set<string> {\n if (values.length > MAX_STORE_CATEGORY_PROMPT_CONDITIONS) {\n issues.push(issue(\"template_too_complex\", `At most ${MAX_STORE_CATEGORY_PROMPT_CONDITIONS} mapping conditions are supported.`));\n }\n const keys = new Set<string>();\n for (const value of values.slice(0, MAX_STORE_CATEGORY_PROMPT_CONDITIONS + 1)) {\n if (!StoreCategoryPromptConditionKeySchema.safeParse(value).success) {\n issues.push(issue(\"invalid_mapping_condition\", `Invalid mapping condition key: ${value}.`));\n continue;\n }\n if (keys.has(value)) {\n issues.push(issue(\"invalid_mapping_condition\", `Duplicate mapping condition key: ${value}.`));\n continue;\n }\n keys.add(value);\n }\n return keys;\n}\n\nexport function validateStoreCategoryPromptTemplate(input: {\n source: string;\n availableConditionKeys: readonly string[];\n}): StoreCategoryPromptTemplateValidation {\n const compiled = compileStoreCategoryPromptTemplate(input.source);\n const issues = [...compiled.issues];\n const available = validateAvailableConditionKeys(input.availableConditionKeys, issues);\n for (const key of compiled.referencedConditionKeys) {\n if (!available.has(key)) issues.push(issue(\"unknown_mapping_condition\", `Prompt template references unavailable mapping condition: mappings.${key}.`));\n }\n const bounded = boundedIssues(issues);\n return { valid: bounded.length === 0, issues: bounded, referencedConditionKeys: compiled.referencedConditionKeys };\n}\n\n\nexport function createStoreCategoryPromptConditionBlock(conditionKey: string): string {\n const parsed = StoreCategoryPromptConditionKeySchema.safeParse(conditionKey);\n if (!parsed.success) throw new TypeError(`Invalid mapping condition key: ${conditionKey}.`);\n return `{% if mappings.${conditionKey} %}\\n\\n{% endif %}`;\n}\n\nexport function createStoreCategoryPromptContext(input: {\n availableConditionKeys: readonly string[];\n selectedConditionKeys: readonly string[];\n}): StoreCategoryPromptContext {\n const issues: StoreCategoryPromptTemplateIssue[] = [];\n const available = validateAvailableConditionKeys(input.availableConditionKeys, issues);\n const selected = validateAvailableConditionKeys(input.selectedConditionKeys, issues);\n for (const key of selected) {\n if (!available.has(key)) issues.push(issue(\"unknown_mapping_condition\", `Selected mapping condition is unavailable: ${key}.`));\n }\n if (issues.length) throw new TypeError(issues[0].message);\n const mappings = Object.create(null) as Record<string, boolean>;\n for (const key of available) mappings[key] = selected.has(key);\n return { mappings };\n}\n\nfunction evaluateExpression(expression: ExpressionNode, mappings: Record<string, boolean>): boolean {\n switch (expression.kind) {\n case \"condition\":\n return mappings[expression.key] === true;\n case \"not\":\n return !evaluateExpression(expression.operand, mappings);\n case \"and\":\n return evaluateExpression(expression.left, mappings) && evaluateExpression(expression.right, mappings);\n case \"or\":\n return evaluateExpression(expression.left, mappings) || evaluateExpression(expression.right, mappings);\n }\n}\n\nfunction renderNodes(nodes: TemplateNode[], mappings: Record<string, boolean>, append: (text: string) => boolean): boolean {\n for (const node of nodes) {\n if (node.kind === \"text\") {\n if (!append(node.text)) return false;\n continue;\n }\n let renderedBranch = false;\n for (const branch of node.branches) {\n if (evaluateExpression(branch.expression, mappings)) {\n if (!renderNodes(branch.body, mappings, append)) return false;\n renderedBranch = true;\n break;\n }\n }\n if (!renderedBranch && node.elseBody && !renderNodes(node.elseBody, mappings, append)) return false;\n }\n return true;\n}\n\nexport function renderStoreCategoryPromptTemplate(input: {\n source: string;\n context: StoreCategoryPromptContext;\n}): StoreCategoryPromptRenderResult {\n const contextResult = StoreCategoryPromptContextSchema.safeParse(input.context);\n if (!contextResult.success) {\n return { ok: false, issues: [issue(\"invalid_mapping_condition\", \"Store Category prompt context contains invalid mapping conditions.\")] };\n }\n const availableConditionKeys = Object.keys(contextResult.data.mappings);\n const validation = validateStoreCategoryPromptTemplate({ source: input.source, availableConditionKeys });\n if (!validation.valid) return { ok: false, issues: validation.issues };\n\n const compiled = compileStoreCategoryPromptTemplate(input.source);\n let output = \"\";\n let outputChars = 0;\n const append = (text: string) => {\n outputChars += sourceLength(text);\n if (outputChars > MAX_STORE_CATEGORY_PROMPT_RENDERED_CHARS) return false;\n output += text;\n return true;\n };\n const rendered = renderNodes(compiled.nodes, contextResult.data.mappings, append);\n if (!rendered) {\n return {\n ok: false,\n issues: [issue(\"rendered_prompt_too_large\", `Rendered prompt must not exceed ${MAX_STORE_CATEGORY_PROMPT_RENDERED_CHARS.toLocaleString()} characters.`)],\n };\n }\n return { ok: true, promptText: output, referencedConditionKeys: validation.referencedConditionKeys };\n}\n","import { z } from \"zod\";\n\nexport const CommerceOutreachToolContextSchema = z.strictObject({\n purpose: z.literal(\"INITIAL_RECOVERY_OUTREACH\"),\n});\n\nexport type CommerceOutreachToolContext =\n z.infer<typeof CommerceOutreachToolContextSchema>;\n","import { z } from \"zod\";\n\n/** Ordered source-backed checkout offers confirmed in one initial outreach send. */\nexport const InitialOutreachCheckoutOfferSetSchema = z.strictObject({\n schemaVersion: z.literal(\"moda.outreach.checkout-offers.v1\"),\n offers: z.array(z.strictObject({\n offerId: z.string().min(1).max(191),\n providerDiscountId: z.string().min(1).max(191).nullable(),\n method: z.enum([\"CODE\", \"AUTOMATIC\"]),\n code: z.string().min(1).max(128).nullable(),\n })).min(1).max(3),\n});\nexport type InitialOutreachCheckoutOfferSet = z.infer<\n typeof InitialOutreachCheckoutOfferSetSchema\n>;\n","/** Synthetic examples; no provider identity, schema artifact or publication claim. */\nimport type {\n CommerceManifest,\n CommerceConversationGrant,\n CommerceTurnIdentity,\n} from \"./schemas\";\nimport {\n EMPTY_RESPONSE_CONTRACT,\n type CommerceFinalResponse,\n} from \"./response\";\nimport type { Digest } from \"./canonical-json\";\nimport { responseContractCanonicalJson } from \"./canonical-json\";\nimport type { ToolDescriptor, CommerceToolDefinition } from \"./definitions\";\nexport const exampleTool: ToolDescriptor = {\n toolId: \"tool-fixture\",\n toolRevisionId: \"revision-fixture\",\n name: \"never_seeded_catalogue_facts\",\n definitionVersion: \"1.0.0\",\n description: \"Read synthetic catalogue facts.\",\n inputSchema: {\n type: \"object\",\n properties: { handle: { type: \"string\", minLength: 1, maxLength: 255 } },\n required: [\"handle\"],\n additionalProperties: false,\n },\n};\nexport const exampleDefinition: CommerceToolDefinition = {\n name: exampleTool.name,\n definitionVersion: \"1.0.0\",\n description: exampleTool.description,\n inputSchema: exampleTool.inputSchema,\n execution: {\n kind: \"SHOPIFY_STOREFRONT_QUERY\",\n executorVersion: \"1.0.0\",\n apiVersion: \"2026-07\",\n schemaHash: \"a\".repeat(64),\n document:\n \"query ProductDetails($handle: String!) { product(handle: $handle) { title description } }\",\n operationName: \"ProductDetails\",\n variables: { handle: { input: \"handle\" } },\n resultPath: \"product\",\n },\n responseTemplate: {\n kind: \"text\",\n text: \"{{result.values.title}}: {{result.values.description}}\",\n unavailable: \"Product details could not be verified.\",\n },\n};\nexport const exampleTurn: CommerceTurnIdentity = {\n contractVersion: \"commerce.v1\",\n shopId: \"shop-fixture\",\n checkoutRecoveryId: \"recovery-fixture\",\n conversationId: \"conversation-fixture\",\n inboundVersion: 1,\n};\nexport function exampleManifest(\n digest: Digest,\n withTool = false,\n): CommerceManifest {\n const capabilities = withTool\n ? [{\n capabilityId: \"capability-fixture\",\n key: \"feature_product_read\",\n featureId: \"feature-fixture\",\n position: 0,\n toolDescriptor: structuredClone(exampleTool),\n }]\n : [];\n return {\n contractVersion: \"commerce.v1\",\n releaseId: \"release-fixture\",\n runnerCompatibility: \"^1.0.0\",\n capabilities,\n featureBehaviours: withTool\n ? [{ featureId: \"feature-fixture\", behaviourPrompt: \"Synthetic Feature behavior.\" }]\n : [],\n selectedCapabilityKeys: capabilities.map((capability) => capability.key),\n grantedTools: withTool\n ? [\n {\n toolId: exampleTool.toolId,\n toolRevisionId: exampleTool.toolRevisionId,\n toolName: exampleTool.name,\n definitionVersion: \"1.0.0\",\n capabilityKeys: [\"feature_product_read\"],\n },\n ]\n : [],\n responseContract: structuredClone(EMPTY_RESPONSE_CONTRACT),\n responseContractHash: digest(\n responseContractCanonicalJson(EMPTY_RESPONSE_CONTRACT),\n ),\n };\n}\nexport function exampleGrant(\n manifest: CommerceManifest,\n): CommerceConversationGrant {\n return {\n id: \"grant-fixture\",\n shopId: exampleTurn.shopId,\n conversationId: exampleTurn.conversationId,\n initialInboundVersion: 1,\n releaseId: manifest.releaseId,\n selectedCapabilityKeys: [...manifest.selectedCapabilityKeys],\n grantedTools: structuredClone(manifest.grantedTools),\n runnerVersion: \"1.0.0\",\n createdAt: \"2026-09-20T00:00:00.000Z\",\n expiresAt: null,\n };\n}\nexport const exampleFinal: CommerceFinalResponse = {\n answerKind: \"REFER_TO_STORE\",\n replyText:\n \"I cannot verify that information. Please contact the store directly.\",\n referralReason: \"INSUFFICIENT_TOOLS\",\n detectedLanguageTag: null,\n detectedLanguageConfidence: null,\n evidenceIds: [],\n details: {},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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4BAA4B;AAAA,EAC5B,aAAa,CAAC;AAAA,EACd,SAAS,CAAC;AACZ;","names":["z","z"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as RunnerTransportCode, C as CommerceModelInvoker, M as ModelStep } from '../../types-
|
|
1
|
+
import { R as RunnerTransportCode, C as CommerceModelInvoker, M as ModelStep } from '../../types-C0bsVczG.js';
|
|
2
2
|
import { CommerceModelProvider, CommerceProviderModelId } from './index.js';
|
|
3
|
-
import '../../response-
|
|
3
|
+
import '../../response-CAw8y5nS.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '../../types-B32wDMLO.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as RunnerDiagnostic, b as RunCommerceTurnInput, c as RunCommerceTurnResult } from '../../types-
|
|
2
|
-
export { C as CommerceModelInvoker, d as ModelCall, e as ModelRequest, M as ModelStep, f as RunnerDiagnosticReason, g as RunnerDiagnosticStage, h as RunnerErrorCode, i as RunnerTool } from '../../types-
|
|
3
|
-
import '../../response-
|
|
1
|
+
import { a as RunnerDiagnostic, b as RunCommerceTurnInput, c as RunCommerceTurnResult } from '../../types-C0bsVczG.js';
|
|
2
|
+
export { C as CommerceModelInvoker, d as ModelCall, e as ModelRequest, M as ModelStep, f as RunnerDiagnosticReason, g as RunnerDiagnosticStage, h as RunnerErrorCode, i as RunnerTool } from '../../types-C0bsVczG.js';
|
|
3
|
+
import '../../response-CAw8y5nS.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '../../types-B32wDMLO.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
manifestMatchesGrant
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-PE2JHOJX.js";
|
|
4
4
|
import {
|
|
5
5
|
CommerceModelInvocationFailure,
|
|
6
6
|
RunnerFailure,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
finalResponseSchema,
|
|
18
18
|
finalResponseToolSchema,
|
|
19
19
|
verifyResponseContract
|
|
20
|
-
} from "../../chunk-
|
|
20
|
+
} from "../../chunk-H7AUKACO.js";
|
|
21
21
|
import {
|
|
22
22
|
LanguageSchema
|
|
23
23
|
} from "../../chunk-QVPEX7KY.js";
|
|
@@ -7,6 +7,7 @@ declare const RecoveryTemplateSemanticKeySchema: z.ZodEnum<{
|
|
|
7
7
|
"checkout.url": "checkout.url";
|
|
8
8
|
"checkout.itemsSummary": "checkout.itemsSummary";
|
|
9
9
|
"offer.code": "offer.code";
|
|
10
|
+
"offer.codes": "offer.codes";
|
|
10
11
|
"offer.description": "offer.description";
|
|
11
12
|
"promotion.productName": "promotion.productName";
|
|
12
13
|
"promotion.productUrl": "promotion.productUrl";
|
|
@@ -43,6 +44,7 @@ declare const RecoveryTemplateTextBindingSchema: z.ZodObject<{
|
|
|
43
44
|
"checkout.url": "checkout.url";
|
|
44
45
|
"checkout.itemsSummary": "checkout.itemsSummary";
|
|
45
46
|
"offer.code": "offer.code";
|
|
47
|
+
"offer.codes": "offer.codes";
|
|
46
48
|
"offer.description": "offer.description";
|
|
47
49
|
"promotion.productName": "promotion.productName";
|
|
48
50
|
"promotion.productUrl": "promotion.productUrl";
|
|
@@ -89,6 +91,7 @@ declare const RecoveryTemplateFrozenBindingsSchema: z.ZodObject<{
|
|
|
89
91
|
"checkout.url": "checkout.url";
|
|
90
92
|
"checkout.itemsSummary": "checkout.itemsSummary";
|
|
91
93
|
"offer.code": "offer.code";
|
|
94
|
+
"offer.codes": "offer.codes";
|
|
92
95
|
"offer.description": "offer.description";
|
|
93
96
|
"promotion.productName": "promotion.productName";
|
|
94
97
|
"promotion.productUrl": "promotion.productUrl";
|
|
@@ -113,6 +116,7 @@ declare const RecoveryTemplateFrozenBindingsSchema: z.ZodObject<{
|
|
|
113
116
|
"checkout.url": "checkout.url";
|
|
114
117
|
"checkout.itemsSummary": "checkout.itemsSummary";
|
|
115
118
|
"offer.code": "offer.code";
|
|
119
|
+
"offer.codes": "offer.codes";
|
|
116
120
|
"offer.description": "offer.description";
|
|
117
121
|
"promotion.productName": "promotion.productName";
|
|
118
122
|
"promotion.productUrl": "promotion.productUrl";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/recovery-template-bindings.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const RecoveryTemplateSemanticKeySchema = z.enum([\n \"customer.firstName\",\n \"shop.name\",\n \"shop.categoryName\",\n \"checkout.url\",\n \"checkout.itemsSummary\",\n \"offer.code\",\n \"offer.description\",\n \"promotion.productName\",\n \"promotion.productUrl\",\n \"promotion.offerDescription\",\n \"promotion.code\",\n \"shopBrand.brandName\",\n \"shopBrand.logoUrl\",\n \"shopBrand.logoAltText\",\n \"shopBrand.logoWidth\",\n \"shopBrand.logoHeight\",\n \"shopBrand.squareLogoUrl\",\n \"shopBrand.squareLogoAltText\",\n \"shopBrand.coverImageUrl\",\n]);\nexport type RecoveryTemplateSemanticKey =\n z.infer<typeof RecoveryTemplateSemanticKeySchema>;\n\nexport const RecoveryPromotionTargetSchema = z.enum([\n \"CHECKOUT\",\n \"ALTERNATIVE_PRODUCT\",\n]);\nexport type RecoveryPromotionTarget =\n z.infer<typeof RecoveryPromotionTargetSchema>;\n\nexport const RecoveryTemplateHeaderMediaRoleSchema = z.enum([\n \"LOGO\",\n \"SQUARE_LOGO\",\n \"COVER_IMAGE\",\n \"CHECKOUT_PRODUCT\",\n]);\nexport type RecoveryTemplateHeaderMediaRole =\n z.infer<typeof RecoveryTemplateHeaderMediaRoleSchema>;\n\nexport const RecoveryTemplateTextBindingSchema = z.strictObject({\n position: z.number().int(),\n variable: RecoveryTemplateSemanticKeySchema,\n});\nexport type RecoveryTemplateTextBinding =\n z.infer<typeof RecoveryTemplateTextBindingSchema>;\n\nexport const RecoveryTemplateUrlButtonBindingSchema = z.strictObject({\n index: z.number().int(),\n subType: z.literal(\"url\"),\n variable: z.enum([\n \"checkout.url\",\n \"promotion.productUrl\",\n ]),\n});\nexport type RecoveryTemplateUrlButtonBinding =\n z.infer<typeof RecoveryTemplateUrlButtonBindingSchema>;\n\nexport const RecoveryTemplateFrozenBindingsSchema = z.strictObject({\n schemaVersion: z.literal(1).optional(),\n promotionTarget: RecoveryPromotionTargetSchema.optional(),\n headerMediaRole: RecoveryTemplateHeaderMediaRoleSchema.optional(),\n header: z.array(RecoveryTemplateTextBindingSchema).optional(),\n body: z.array(RecoveryTemplateTextBindingSchema),\n buttons: z.array(RecoveryTemplateUrlButtonBindingSchema),\n});\nexport type RecoveryTemplateFrozenBindings =\n z.infer<typeof RecoveryTemplateFrozenBindingsSchema>;\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,oCAAoC,EAAE,KAAK;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,gCAAgC,EAAE,KAAK;AAAA,EAClD;AAAA,EACA;AACF,CAAC;AAIM,IAAM,wCAAwC,EAAE,KAAK;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,oCAAoC,EAAE,aAAa;AAAA,EAC9D,UAAU,EAAE,OAAO,EAAE,IAAI;AAAA,EACzB,UAAU;AACZ,CAAC;AAIM,IAAM,yCAAyC,EAAE,aAAa;AAAA,EACnE,OAAO,EAAE,OAAO,EAAE,IAAI;AAAA,EACtB,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,UAAU,EAAE,KAAK;AAAA,IACf;AAAA,IACA;AAAA,EACF,CAAC;AACH,CAAC;AAIM,IAAM,uCAAuC,EAAE,aAAa;AAAA,EACjE,eAAe,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA,EACrC,iBAAiB,8BAA8B,SAAS;AAAA,EACxD,iBAAiB,sCAAsC,SAAS;AAAA,EAChE,QAAQ,EAAE,MAAM,iCAAiC,EAAE,SAAS;AAAA,EAC5D,MAAM,EAAE,MAAM,iCAAiC;AAAA,EAC/C,SAAS,EAAE,MAAM,sCAAsC;AACzD,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/recovery-template-bindings.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const RecoveryTemplateSemanticKeySchema = z.enum([\n \"customer.firstName\",\n \"shop.name\",\n \"shop.categoryName\",\n \"checkout.url\",\n \"checkout.itemsSummary\",\n \"offer.code\",\n \"offer.codes\",\n \"offer.description\",\n \"promotion.productName\",\n \"promotion.productUrl\",\n \"promotion.offerDescription\",\n \"promotion.code\",\n \"shopBrand.brandName\",\n \"shopBrand.logoUrl\",\n \"shopBrand.logoAltText\",\n \"shopBrand.logoWidth\",\n \"shopBrand.logoHeight\",\n \"shopBrand.squareLogoUrl\",\n \"shopBrand.squareLogoAltText\",\n \"shopBrand.coverImageUrl\",\n]);\nexport type RecoveryTemplateSemanticKey =\n z.infer<typeof RecoveryTemplateSemanticKeySchema>;\n\nexport const RecoveryPromotionTargetSchema = z.enum([\n \"CHECKOUT\",\n \"ALTERNATIVE_PRODUCT\",\n]);\nexport type RecoveryPromotionTarget =\n z.infer<typeof RecoveryPromotionTargetSchema>;\n\nexport const RecoveryTemplateHeaderMediaRoleSchema = z.enum([\n \"LOGO\",\n \"SQUARE_LOGO\",\n \"COVER_IMAGE\",\n \"CHECKOUT_PRODUCT\",\n]);\nexport type RecoveryTemplateHeaderMediaRole =\n z.infer<typeof RecoveryTemplateHeaderMediaRoleSchema>;\n\nexport const RecoveryTemplateTextBindingSchema = z.strictObject({\n position: z.number().int(),\n variable: RecoveryTemplateSemanticKeySchema,\n});\nexport type RecoveryTemplateTextBinding =\n z.infer<typeof RecoveryTemplateTextBindingSchema>;\n\nexport const RecoveryTemplateUrlButtonBindingSchema = z.strictObject({\n index: z.number().int(),\n subType: z.literal(\"url\"),\n variable: z.enum([\n \"checkout.url\",\n \"promotion.productUrl\",\n ]),\n});\nexport type RecoveryTemplateUrlButtonBinding =\n z.infer<typeof RecoveryTemplateUrlButtonBindingSchema>;\n\nexport const RecoveryTemplateFrozenBindingsSchema = z.strictObject({\n schemaVersion: z.literal(1).optional(),\n promotionTarget: RecoveryPromotionTargetSchema.optional(),\n headerMediaRole: RecoveryTemplateHeaderMediaRoleSchema.optional(),\n header: z.array(RecoveryTemplateTextBindingSchema).optional(),\n body: z.array(RecoveryTemplateTextBindingSchema),\n buttons: z.array(RecoveryTemplateUrlButtonBindingSchema),\n});\nexport type RecoveryTemplateFrozenBindings =\n z.infer<typeof RecoveryTemplateFrozenBindingsSchema>;\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,oCAAoC,EAAE,KAAK;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,gCAAgC,EAAE,KAAK;AAAA,EAClD;AAAA,EACA;AACF,CAAC;AAIM,IAAM,wCAAwC,EAAE,KAAK;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,oCAAoC,EAAE,aAAa;AAAA,EAC9D,UAAU,EAAE,OAAO,EAAE,IAAI;AAAA,EACzB,UAAU;AACZ,CAAC;AAIM,IAAM,yCAAyC,EAAE,aAAa;AAAA,EACnE,OAAO,EAAE,OAAO,EAAE,IAAI;AAAA,EACtB,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,UAAU,EAAE,KAAK;AAAA,IACf;AAAA,IACA;AAAA,EACF,CAAC;AACH,CAAC;AAIM,IAAM,uCAAuC,EAAE,aAAa;AAAA,EACjE,eAAe,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA,EACrC,iBAAiB,8BAA8B,SAAS;AAAA,EACxD,iBAAiB,sCAAsC,SAAS;AAAA,EAChE,QAAQ,EAAE,MAAM,iCAAiC,EAAE,SAAS;AAAA,EAC5D,MAAM,EAAE,MAAM,iCAAiC;AAAA,EAC/C,SAAS,EAAE,MAAM,sCAAsC;AACzD,CAAC;","names":[]}
|
|
@@ -754,6 +754,22 @@ declare const CommerceOfferSchema: z.ZodObject<{
|
|
|
754
754
|
}>;
|
|
755
755
|
reasonCodes: z.ZodArray<z.ZodString>;
|
|
756
756
|
}, z.core.$strict>;
|
|
757
|
+
declare const CommerceDiscountCombinationFactsSchema: z.ZodObject<{
|
|
758
|
+
discountClasses: z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
759
|
+
ORDER: "ORDER";
|
|
760
|
+
PRODUCT: "PRODUCT";
|
|
761
|
+
SHIPPING: "SHIPPING";
|
|
762
|
+
}>>>;
|
|
763
|
+
shopifyPlus: z.ZodNullable<z.ZodBoolean>;
|
|
764
|
+
combinesWith: z.ZodNullable<z.ZodObject<{
|
|
765
|
+
orderDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
766
|
+
productDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
767
|
+
shippingDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
768
|
+
}, z.core.$strict>>;
|
|
769
|
+
discountTags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
770
|
+
allowedSameLineProductTags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
771
|
+
}, z.core.$strict>;
|
|
772
|
+
type CommerceDiscountCombinationFacts = z.infer<typeof CommerceDiscountCombinationFactsSchema>;
|
|
757
773
|
declare const CommerceDiscountConditionFactsSchema: z.ZodObject<{
|
|
758
774
|
provider: z.ZodEnum<{
|
|
759
775
|
SHOPIFY: "SHOPIFY";
|
|
@@ -798,6 +814,7 @@ declare const CommerceDiscountConditionFactsSchema: z.ZodObject<{
|
|
|
798
814
|
}, z.core.$strict>;
|
|
799
815
|
minimumSubtotal: z.ZodNullable<z.ZodString>;
|
|
800
816
|
maximumSubtotal: z.ZodNullable<z.ZodString>;
|
|
817
|
+
subtotalRequirementCurrency: z.ZodNullable<z.ZodString>;
|
|
801
818
|
minimumQuantity: z.ZodNullable<z.ZodNumber>;
|
|
802
819
|
usageLimit: z.ZodNullable<z.ZodNumber>;
|
|
803
820
|
usageCount: z.ZodNullable<z.ZodNumber>;
|
|
@@ -809,6 +826,21 @@ declare const CommerceDiscountConditionFactsSchema: z.ZodObject<{
|
|
|
809
826
|
}>;
|
|
810
827
|
excludesSaleItems: z.ZodNullable<z.ZodBoolean>;
|
|
811
828
|
individualUse: z.ZodNullable<z.ZodBoolean>;
|
|
829
|
+
combination: z.ZodObject<{
|
|
830
|
+
discountClasses: z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
831
|
+
ORDER: "ORDER";
|
|
832
|
+
PRODUCT: "PRODUCT";
|
|
833
|
+
SHIPPING: "SHIPPING";
|
|
834
|
+
}>>>;
|
|
835
|
+
shopifyPlus: z.ZodNullable<z.ZodBoolean>;
|
|
836
|
+
combinesWith: z.ZodNullable<z.ZodObject<{
|
|
837
|
+
orderDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
838
|
+
productDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
839
|
+
shippingDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
840
|
+
}, z.core.$strict>>;
|
|
841
|
+
discountTags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
842
|
+
allowedSameLineProductTags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
843
|
+
}, z.core.$strict>;
|
|
812
844
|
unrepresentedConditions: z.ZodArray<z.ZodString>;
|
|
813
845
|
}, z.core.$strict>;
|
|
814
846
|
type CommerceDiscountConditionFacts = z.infer<typeof CommerceDiscountConditionFactsSchema>;
|
|
@@ -874,6 +906,7 @@ declare const CommerceDiscountDetailsSchema: z.ZodObject<{
|
|
|
874
906
|
}, z.core.$strict>;
|
|
875
907
|
minimumSubtotal: z.ZodNullable<z.ZodString>;
|
|
876
908
|
maximumSubtotal: z.ZodNullable<z.ZodString>;
|
|
909
|
+
subtotalRequirementCurrency: z.ZodNullable<z.ZodString>;
|
|
877
910
|
minimumQuantity: z.ZodNullable<z.ZodNumber>;
|
|
878
911
|
usageLimit: z.ZodNullable<z.ZodNumber>;
|
|
879
912
|
usageCount: z.ZodNullable<z.ZodNumber>;
|
|
@@ -885,8 +918,24 @@ declare const CommerceDiscountDetailsSchema: z.ZodObject<{
|
|
|
885
918
|
}>;
|
|
886
919
|
excludesSaleItems: z.ZodNullable<z.ZodBoolean>;
|
|
887
920
|
individualUse: z.ZodNullable<z.ZodBoolean>;
|
|
921
|
+
combination: z.ZodObject<{
|
|
922
|
+
discountClasses: z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
923
|
+
ORDER: "ORDER";
|
|
924
|
+
PRODUCT: "PRODUCT";
|
|
925
|
+
SHIPPING: "SHIPPING";
|
|
926
|
+
}>>>;
|
|
927
|
+
shopifyPlus: z.ZodNullable<z.ZodBoolean>;
|
|
928
|
+
combinesWith: z.ZodNullable<z.ZodObject<{
|
|
929
|
+
orderDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
930
|
+
productDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
931
|
+
shippingDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
932
|
+
}, z.core.$strict>>;
|
|
933
|
+
discountTags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
934
|
+
allowedSameLineProductTags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
935
|
+
}, z.core.$strict>;
|
|
888
936
|
unrepresentedConditions: z.ZodArray<z.ZodString>;
|
|
889
937
|
}, z.core.$strict>;
|
|
938
|
+
providerDiscountId: z.ZodNullable<z.ZodString>;
|
|
890
939
|
}, z.core.$strict>;
|
|
891
940
|
type CommerceDiscountDetails = z.infer<typeof CommerceDiscountDetailsSchema>;
|
|
892
941
|
declare const CommerceEvidenceSchema: z.ZodObject<{
|
|
@@ -1276,6 +1325,7 @@ declare const CommerceToolOutputs: {
|
|
|
1276
1325
|
}, z.core.$strict>;
|
|
1277
1326
|
minimumSubtotal: z.ZodNullable<z.ZodString>;
|
|
1278
1327
|
maximumSubtotal: z.ZodNullable<z.ZodString>;
|
|
1328
|
+
subtotalRequirementCurrency: z.ZodNullable<z.ZodString>;
|
|
1279
1329
|
minimumQuantity: z.ZodNullable<z.ZodNumber>;
|
|
1280
1330
|
usageLimit: z.ZodNullable<z.ZodNumber>;
|
|
1281
1331
|
usageCount: z.ZodNullable<z.ZodNumber>;
|
|
@@ -1287,8 +1337,24 @@ declare const CommerceToolOutputs: {
|
|
|
1287
1337
|
}>;
|
|
1288
1338
|
excludesSaleItems: z.ZodNullable<z.ZodBoolean>;
|
|
1289
1339
|
individualUse: z.ZodNullable<z.ZodBoolean>;
|
|
1340
|
+
combination: z.ZodObject<{
|
|
1341
|
+
discountClasses: z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
1342
|
+
ORDER: "ORDER";
|
|
1343
|
+
PRODUCT: "PRODUCT";
|
|
1344
|
+
SHIPPING: "SHIPPING";
|
|
1345
|
+
}>>>;
|
|
1346
|
+
shopifyPlus: z.ZodNullable<z.ZodBoolean>;
|
|
1347
|
+
combinesWith: z.ZodNullable<z.ZodObject<{
|
|
1348
|
+
orderDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
1349
|
+
productDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
1350
|
+
shippingDiscounts: z.ZodNullable<z.ZodBoolean>;
|
|
1351
|
+
}, z.core.$strict>>;
|
|
1352
|
+
discountTags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
1353
|
+
allowedSameLineProductTags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
1354
|
+
}, z.core.$strict>;
|
|
1290
1355
|
unrepresentedConditions: z.ZodArray<z.ZodString>;
|
|
1291
1356
|
}, z.core.$strict>;
|
|
1357
|
+
providerDiscountId: z.ZodNullable<z.ZodString>;
|
|
1292
1358
|
}, z.core.$strict>>;
|
|
1293
1359
|
}, z.core.$strict>;
|
|
1294
1360
|
commerce_evaluate_discount: z.ZodObject<{
|
|
@@ -1572,4 +1638,4 @@ declare function verifyResponseContract(definition: unknown, hash: string, diges
|
|
|
1572
1638
|
/** JSON Schema branches retain the immutable envelope; only ANSWER details vary. */
|
|
1573
1639
|
declare function finalResponseToolSchema(definition: CommerceResponseContract): Json;
|
|
1574
1640
|
|
|
1575
|
-
export {
|
|
1641
|
+
export { type Json as $, CommerceProductSchema as A, CommerceProposalSchema as B, type CommerceTurnIdentity as C, type Digest as D, CommerceReleaseIdentitySchema as E, CommerceResolveAssertionSchema as F, type GrantedTool as G, type CommerceResponseContract as H, CommerceResponseContractSchema as I, CommerceToolDefinitionSchema as J, type CommerceToolDraftDefinition as K, CommerceToolDraftDefinitionSchema as L, CommerceToolIdentitySchema as M, CommerceToolInputs as N, CommerceToolOutputs as O, CommerceToolResultSchema as P, CommerceToolRevisionIdentitySchema as Q, CommerceTurnIdentitySchema as R, type SubsetSchema as S, type ToolDescriptor as T, DetailsSchemaSchema as U, EMPTY_RESPONSE_CONTRACT as V, type ExternalHttpExecution as W, ExternalHttpExecutionSchema as X, GrantedToolSchema as Y, GrantedToolsSchema as Z, InputSchemaSchema as _, type CommerceConversationGrant as a, MONEY_PATTERN as a0, POLICY_OPERATIONS as a1, POLICY_OPERATION_DESCRIPTORS as a2, ReferralReasonSchema as a3, ResponseTemplateSchema as a4, ToolDescriptorSchema as a5, ToolNameSchema as a6, canonicalJson as a7, commerceToolResultSchema as a8, compileSubset as a9, definitionToMcpDescriptor as aa, finalResponseSchema as ab, finalResponseToolSchema as ac, jsonBytes as ad, mapToolArguments as ae, matchesSubset as af, productBelongsToDomain as ag, responseContractCanonicalJson as ah, safeName as ai, safePath as aj, toolHashInput as ak, validateDefinitionForPublication as al, validateDefinitionVersion as am, validateSubset as an, verifyResponseContract as ao, type CommerceManifest as b, type CommerceToolResult as c, type CommerceFinalResponse as d, type CommerceToolDefinition as e, CommerceAlternativeSchema as f, CommerceAssertionSchema as g, CommerceBasketSchema as h, CommerceConversationGrantSchema as i, type CommerceDefinitionCompiler as j, type CommerceDiscountCombinationFacts as k, CommerceDiscountCombinationFactsSchema as l, type CommerceDiscountConditionFacts as m, CommerceDiscountConditionFactsSchema as n, type CommerceDiscountDetails as o, CommerceDiscountDetailsSchema as p, CommerceErrorCodeSchema as q, type CommerceEvidence as r, CommerceEvidenceSchema as s, CommerceExecuteAssertionSchema as t, CommerceExecutionSchema as u, CommerceFinalResponseSchema as v, CommerceManifestSchema as w, CommerceOfferSchema as x, type CommerceProductSaleEvidence as y, CommerceProductSaleEvidenceSchema as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommerceTurnIdentity, a as CommerceConversationGrant, b as CommerceManifest, T as ToolDescriptor, G as GrantedTool, c as CommerceToolResult, D as Digest, d as CommerceFinalResponse } from './response-
|
|
1
|
+
import { C as CommerceTurnIdentity, a as CommerceConversationGrant, b as CommerceManifest, T as ToolDescriptor, G as GrantedTool, c as CommerceToolResult, D as Digest, d as CommerceFinalResponse } from './response-CAw8y5nS.js';
|
|
2
2
|
import { S as StructuredLogger } from './types-B32wDMLO.js';
|
|
3
3
|
|
|
4
4
|
/** Finite, non-customer-facing failure taxonomy for Commerce hosts and logs. */
|
|
@@ -113,6 +113,16 @@ declare const WooRestoreOutreachOfferV1Schema: z.ZodDiscriminatedUnion<[z.ZodObj
|
|
|
113
113
|
}, z.core.$strict>, z.ZodObject<{
|
|
114
114
|
kind: z.ZodLiteral<"CHECKOUT_AUTOMATIC">;
|
|
115
115
|
providerDiscountId: z.ZodString;
|
|
116
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
117
|
+
kind: z.ZodLiteral<"CHECKOUT_OFFERS">;
|
|
118
|
+
offers: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
119
|
+
method: z.ZodLiteral<"CODE">;
|
|
120
|
+
code: z.ZodString;
|
|
121
|
+
providerDiscountId: z.ZodString;
|
|
122
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
123
|
+
method: z.ZodLiteral<"AUTOMATIC">;
|
|
124
|
+
providerDiscountId: z.ZodString;
|
|
125
|
+
}, z.core.$strict>], "method">>;
|
|
116
126
|
}, z.core.$strict>, z.ZodObject<{
|
|
117
127
|
kind: z.ZodLiteral<"ALTERNATIVE_PRODUCT">;
|
|
118
128
|
}, z.core.$strict>], "kind">;
|
|
@@ -146,6 +156,16 @@ declare const WooRestoreResolveResponseV1Schema: z.ZodObject<{
|
|
|
146
156
|
}, z.core.$strict>, z.ZodObject<{
|
|
147
157
|
kind: z.ZodLiteral<"CHECKOUT_AUTOMATIC">;
|
|
148
158
|
providerDiscountId: z.ZodString;
|
|
159
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
160
|
+
kind: z.ZodLiteral<"CHECKOUT_OFFERS">;
|
|
161
|
+
offers: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
162
|
+
method: z.ZodLiteral<"CODE">;
|
|
163
|
+
code: z.ZodString;
|
|
164
|
+
providerDiscountId: z.ZodString;
|
|
165
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
166
|
+
method: z.ZodLiteral<"AUTOMATIC">;
|
|
167
|
+
providerDiscountId: z.ZodString;
|
|
168
|
+
}, z.core.$strict>], "method">>;
|
|
149
169
|
}, z.core.$strict>, z.ZodObject<{
|
|
150
170
|
kind: z.ZodLiteral<"ALTERNATIVE_PRODUCT">;
|
|
151
171
|
}, z.core.$strict>], "kind">;
|
|
@@ -66,6 +66,20 @@ var WooRestoreOutreachOfferV1Schema = z.discriminatedUnion("kind", [
|
|
|
66
66
|
kind: z.literal("CHECKOUT_AUTOMATIC"),
|
|
67
67
|
providerDiscountId: WooNoControlTextSchema(191)
|
|
68
68
|
}),
|
|
69
|
+
z.strictObject({
|
|
70
|
+
kind: z.literal("CHECKOUT_OFFERS"),
|
|
71
|
+
offers: z.array(z.discriminatedUnion("method", [
|
|
72
|
+
z.strictObject({
|
|
73
|
+
method: z.literal("CODE"),
|
|
74
|
+
code: WooNoControlTextSchema(128),
|
|
75
|
+
providerDiscountId: WooNoControlTextSchema(191)
|
|
76
|
+
}),
|
|
77
|
+
z.strictObject({
|
|
78
|
+
method: z.literal("AUTOMATIC"),
|
|
79
|
+
providerDiscountId: WooNoControlTextSchema(191)
|
|
80
|
+
})
|
|
81
|
+
])).min(2).max(3)
|
|
82
|
+
}),
|
|
69
83
|
z.strictObject({ kind: z.literal("ALTERNATIVE_PRODUCT") })
|
|
70
84
|
]);
|
|
71
85
|
var WooRestoreResolveResponseV1Schema = z.strictObject({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/woocommerce/contracts.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const WOO_CART_RESTORE_SNAPSHOT_VERSION = \"woo.cart-restore.v1\" as const;\nexport const WOO_RESTORE_RESOLVE_VERSION = \"woo.restore.resolve.v1\" as const;\n\n// Wire IDs remain strings because WordPress/PHP may emit IDs beyond JavaScript's\n// safe-integer range. WooCommerce validates their meaning.\nconst WooPositiveDecimalIdSchema = z.string()\n .min(1).max(20).regex(/^[1-9][0-9]*$/);\nconst WooOpaqueRecoveryIdSchema = z.string()\n .min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._:~-]{0,127}$/);\nconst WooNoControlTextSchema = (max: number) => z.string()\n .min(1).max(max).regex(/^[^\\p{Cc}]+$/u);\n\n// This refinement enforces only the structural ten-property limit.\nconst WooRestoreAttributesV1Schema = z.record(\n WooNoControlTextSchema(80), WooNoControlTextSchema(200),\n).superRefine((value, ctx) => {\n if (Object.keys(value).length > 10) {\n ctx.addIssue({ code: \"custom\", message: \"Too many attributes\" });\n }\n});\n\nconst WooAppliedCouponCodesV1Schema = z.array(WooNoControlTextSchema(128)).max(10);\n\nexport const WooCartRestoreLineV1Schema = z.strictObject({\n productId: WooPositiveDecimalIdSchema,\n variationId: WooPositiveDecimalIdSchema.optional(),\n quantity: z.number().int().min(1).max(100_000),\n attributes: WooRestoreAttributesV1Schema.optional(),\n});\nexport type WooCartRestoreLineV1 = z.infer<typeof WooCartRestoreLineV1Schema>;\n\nexport const WooCartRestoreUnsupportedReasonV1Schema = z.enum([\n \"ITEMS_UNAVAILABLE\",\n \"UNSUPPORTED_PRODUCT_TYPE\",\n \"CUSTOM_CART_ITEM_DATA\",\n \"INVALID_VARIATION\",\n \"COUPONS_UNAVAILABLE\",\n \"LIMIT_EXCEEDED\",\n]);\nexport type WooCartRestoreUnsupportedReasonV1 =\n z.infer<typeof WooCartRestoreUnsupportedReasonV1Schema>;\n\nexport const WooCartRestoreSupportedSnapshotV1Schema = z.strictObject({\n schemaVersion: z.literal(WOO_CART_RESTORE_SNAPSHOT_VERSION),\n kind: z.literal(\"supported\"),\n appliedCouponCodes: WooAppliedCouponCodesV1Schema,\n lines: z.array(WooCartRestoreLineV1Schema).min(1).max(50),\n});\nexport type WooCartRestoreSupportedSnapshotV1 =\n z.infer<typeof WooCartRestoreSupportedSnapshotV1Schema>;\n\nexport const WooCartRestoreUnsupportedSnapshotV1Schema = z.strictObject({\n schemaVersion: z.literal(WOO_CART_RESTORE_SNAPSHOT_VERSION),\n kind: z.literal(\"unsupported\"),\n reason: WooCartRestoreUnsupportedReasonV1Schema,\n appliedCouponCodes: WooAppliedCouponCodesV1Schema,\n});\nexport type WooCartRestoreUnsupportedSnapshotV1 =\n z.infer<typeof WooCartRestoreUnsupportedSnapshotV1Schema>;\n\nexport const WooCartRestoreSnapshotV1Schema = z.discriminatedUnion(\"kind\", [\n WooCartRestoreSupportedSnapshotV1Schema,\n WooCartRestoreUnsupportedSnapshotV1Schema,\n]);\nexport type WooCartRestoreSnapshotV1 = z.infer<typeof WooCartRestoreSnapshotV1Schema>;\n\n// Extension for API-001's canonical v1 checkout object; not a checkout event\n// identity, contact or phone-proof schema.\nexport const WooCheckoutRestoreExtensionV1Schema = z.strictObject({\n restoration: WooCartRestoreSnapshotV1Schema.optional(),\n});\nexport type WooCheckoutRestoreExtensionV1 =\n z.infer<typeof WooCheckoutRestoreExtensionV1Schema>;\n\nexport const WooRestoreResolveRequestV1Schema = z.strictObject({\n schemaVersion: z.literal(WOO_RESTORE_RESOLVE_VERSION),\n recoveryId: WooOpaqueRecoveryIdSchema,\n token: z.string().length(43).regex(/^[A-Za-z0-9_-]{43}$/),\n});\nexport type WooRestoreResolveRequestV1 = z.infer<typeof WooRestoreResolveRequestV1Schema>;\n\n// This describes a previously confirmed offer. Eligibility and provenance are\n// enforced by API-003, not by this wire-shape schema.\nexport const WooRestoreOutreachOfferV1Schema = z.discriminatedUnion(\"kind\", [\n z.strictObject({\n kind: z.literal(\"NONE\"),\n reason: z.enum([\"NO_CONFIRMED_OFFER\", \"UNVERIFIABLE\"]),\n }),\n z.strictObject({\n kind: z.literal(\"CHECKOUT_CODE\"),\n code: WooNoControlTextSchema(128),\n providerDiscountId: WooNoControlTextSchema(191),\n }),\n z.strictObject({\n kind: z.literal(\"CHECKOUT_AUTOMATIC\"),\n providerDiscountId: WooNoControlTextSchema(191),\n }),\n z.strictObject({ kind: z.literal(\"ALTERNATIVE_PRODUCT\") }),\n]);\nexport type WooRestoreOutreachOfferV1 = z.infer<typeof WooRestoreOutreachOfferV1Schema>;\n\nexport const WooRestoreResolveResponseV1Schema = z.strictObject({\n schemaVersion: z.literal(WOO_RESTORE_RESOLVE_VERSION),\n status: z.literal(\"eligible\"),\n recoveryId: WooOpaqueRecoveryIdSchema,\n checkoutKey: WooOpaqueRecoveryIdSchema,\n snapshot: WooCartRestoreSupportedSnapshotV1Schema,\n outreachOffer: WooRestoreOutreachOfferV1Schema,\n});\nexport type WooRestoreResolveResponseV1 =\n z.infer<typeof WooResto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woocommerce/contracts.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const WOO_CART_RESTORE_SNAPSHOT_VERSION = \"woo.cart-restore.v1\" as const;\nexport const WOO_RESTORE_RESOLVE_VERSION = \"woo.restore.resolve.v1\" as const;\n\n// Wire IDs remain strings because WordPress/PHP may emit IDs beyond JavaScript's\n// safe-integer range. WooCommerce validates their meaning.\nconst WooPositiveDecimalIdSchema = z.string()\n .min(1).max(20).regex(/^[1-9][0-9]*$/);\nconst WooOpaqueRecoveryIdSchema = z.string()\n .min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._:~-]{0,127}$/);\nconst WooNoControlTextSchema = (max: number) => z.string()\n .min(1).max(max).regex(/^[^\\p{Cc}]+$/u);\n\n// This refinement enforces only the structural ten-property limit.\nconst WooRestoreAttributesV1Schema = z.record(\n WooNoControlTextSchema(80), WooNoControlTextSchema(200),\n).superRefine((value, ctx) => {\n if (Object.keys(value).length > 10) {\n ctx.addIssue({ code: \"custom\", message: \"Too many attributes\" });\n }\n});\n\nconst WooAppliedCouponCodesV1Schema = z.array(WooNoControlTextSchema(128)).max(10);\n\nexport const WooCartRestoreLineV1Schema = z.strictObject({\n productId: WooPositiveDecimalIdSchema,\n variationId: WooPositiveDecimalIdSchema.optional(),\n quantity: z.number().int().min(1).max(100_000),\n attributes: WooRestoreAttributesV1Schema.optional(),\n});\nexport type WooCartRestoreLineV1 = z.infer<typeof WooCartRestoreLineV1Schema>;\n\nexport const WooCartRestoreUnsupportedReasonV1Schema = z.enum([\n \"ITEMS_UNAVAILABLE\",\n \"UNSUPPORTED_PRODUCT_TYPE\",\n \"CUSTOM_CART_ITEM_DATA\",\n \"INVALID_VARIATION\",\n \"COUPONS_UNAVAILABLE\",\n \"LIMIT_EXCEEDED\",\n]);\nexport type WooCartRestoreUnsupportedReasonV1 =\n z.infer<typeof WooCartRestoreUnsupportedReasonV1Schema>;\n\nexport const WooCartRestoreSupportedSnapshotV1Schema = z.strictObject({\n schemaVersion: z.literal(WOO_CART_RESTORE_SNAPSHOT_VERSION),\n kind: z.literal(\"supported\"),\n appliedCouponCodes: WooAppliedCouponCodesV1Schema,\n lines: z.array(WooCartRestoreLineV1Schema).min(1).max(50),\n});\nexport type WooCartRestoreSupportedSnapshotV1 =\n z.infer<typeof WooCartRestoreSupportedSnapshotV1Schema>;\n\nexport const WooCartRestoreUnsupportedSnapshotV1Schema = z.strictObject({\n schemaVersion: z.literal(WOO_CART_RESTORE_SNAPSHOT_VERSION),\n kind: z.literal(\"unsupported\"),\n reason: WooCartRestoreUnsupportedReasonV1Schema,\n appliedCouponCodes: WooAppliedCouponCodesV1Schema,\n});\nexport type WooCartRestoreUnsupportedSnapshotV1 =\n z.infer<typeof WooCartRestoreUnsupportedSnapshotV1Schema>;\n\nexport const WooCartRestoreSnapshotV1Schema = z.discriminatedUnion(\"kind\", [\n WooCartRestoreSupportedSnapshotV1Schema,\n WooCartRestoreUnsupportedSnapshotV1Schema,\n]);\nexport type WooCartRestoreSnapshotV1 = z.infer<typeof WooCartRestoreSnapshotV1Schema>;\n\n// Extension for API-001's canonical v1 checkout object; not a checkout event\n// identity, contact or phone-proof schema.\nexport const WooCheckoutRestoreExtensionV1Schema = z.strictObject({\n restoration: WooCartRestoreSnapshotV1Schema.optional(),\n});\nexport type WooCheckoutRestoreExtensionV1 =\n z.infer<typeof WooCheckoutRestoreExtensionV1Schema>;\n\nexport const WooRestoreResolveRequestV1Schema = z.strictObject({\n schemaVersion: z.literal(WOO_RESTORE_RESOLVE_VERSION),\n recoveryId: WooOpaqueRecoveryIdSchema,\n token: z.string().length(43).regex(/^[A-Za-z0-9_-]{43}$/),\n});\nexport type WooRestoreResolveRequestV1 = z.infer<typeof WooRestoreResolveRequestV1Schema>;\n\n// This describes a previously confirmed offer. Eligibility and provenance are\n// enforced by API-003, not by this wire-shape schema.\nexport const WooRestoreOutreachOfferV1Schema = z.discriminatedUnion(\"kind\", [\n z.strictObject({\n kind: z.literal(\"NONE\"),\n reason: z.enum([\"NO_CONFIRMED_OFFER\", \"UNVERIFIABLE\"]),\n }),\n z.strictObject({\n kind: z.literal(\"CHECKOUT_CODE\"),\n code: WooNoControlTextSchema(128),\n providerDiscountId: WooNoControlTextSchema(191),\n }),\n z.strictObject({\n kind: z.literal(\"CHECKOUT_AUTOMATIC\"),\n providerDiscountId: WooNoControlTextSchema(191),\n }),\n z.strictObject({\n kind: z.literal(\"CHECKOUT_OFFERS\"),\n offers: z.array(z.discriminatedUnion(\"method\", [\n z.strictObject({\n method: z.literal(\"CODE\"),\n code: WooNoControlTextSchema(128),\n providerDiscountId: WooNoControlTextSchema(191),\n }),\n z.strictObject({\n method: z.literal(\"AUTOMATIC\"),\n providerDiscountId: WooNoControlTextSchema(191),\n }),\n ])).min(2).max(3),\n }),\n z.strictObject({ kind: z.literal(\"ALTERNATIVE_PRODUCT\") }),\n]);\nexport type WooRestoreOutreachOfferV1 = z.infer<typeof WooRestoreOutreachOfferV1Schema>;\n\nexport const WooRestoreResolveResponseV1Schema = z.strictObject({\n schemaVersion: z.literal(WOO_RESTORE_RESOLVE_VERSION),\n status: z.literal(\"eligible\"),\n recoveryId: WooOpaqueRecoveryIdSchema,\n checkoutKey: WooOpaqueRecoveryIdSchema,\n snapshot: WooCartRestoreSupportedSnapshotV1Schema,\n outreachOffer: WooRestoreOutreachOfferV1Schema,\n});\nexport type WooRestoreResolveResponseV1 =\n z.infer<typeof WooRestoreResolveResponseV1Schema>;\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,oCAAoC;AAC1C,IAAM,8BAA8B;AAI3C,IAAM,6BAA6B,EAAE,OAAO,EACzC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,MAAM,eAAe;AACvC,IAAM,4BAA4B,EAAE,OAAO,EACxC,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,MAAM,sCAAsC;AAC/D,IAAM,yBAAyB,CAAC,QAAgB,EAAE,OAAO,EACtD,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,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