@modainteract/moda-interact-shared 5.5.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-QVPEX7KY.js → chunk-GCCT2BDE.js} +4 -4
- package/dist/chunk-QFUK7FIO.js +16 -0
- package/dist/chunk-QFUK7FIO.js.map +1 -0
- package/dist/{chunk-BDGLKOCW.js → chunk-WF2BDUPZ.js} +483 -315
- package/dist/chunk-WF2BDUPZ.js.map +1 -0
- package/dist/chunk-WHZAAF2Q.js +25 -0
- package/dist/chunk-WHZAAF2Q.js.map +1 -0
- package/dist/chunk-WK7QSBHJ.js +148 -0
- package/dist/chunk-WK7QSBHJ.js.map +1 -0
- package/dist/{chunk-XB5NIOKJ.js → chunk-WONND3OK.js} +3 -1
- package/dist/chunk-WONND3OK.js.map +1 -0
- package/dist/commerce/index.d.ts +34 -4
- package/dist/commerce/index.js +31 -16
- package/dist/commerce/index.js.map +1 -1
- package/dist/commerce/model/node.d.ts +3 -2
- package/dist/commerce/model/node.js +4 -4
- package/dist/commerce/outreach/index.d.ts +1094 -0
- package/dist/commerce/outreach/index.js +1355 -0
- package/dist/commerce/outreach/index.js.map +1 -0
- package/dist/commerce/presentation/index.d.ts +420 -0
- package/dist/commerce/presentation/index.js +661 -0
- package/dist/commerce/presentation/index.js.map +1 -0
- package/dist/commerce/runner/index.d.ts +4 -3
- package/dist/commerce/runner/index.js +69 -43
- package/dist/commerce/runner/index.js.map +1 -1
- package/dist/product-context-Bh74WGOo.d.ts +746 -0
- package/dist/recovery-offer-proof.js +2 -2
- package/dist/{response-C1JsiFoO.d.ts → response-DFDEw4K0.d.ts} +254 -707
- package/dist/{types-Ds5QJ621.d.ts → types-vIMrj5J4.d.ts} +6 -2
- package/package.json +17 -6
- package/dist/chunk-BDGLKOCW.js.map +0 -1
- package/dist/chunk-BYAI6W7T.js +0 -97
- package/dist/chunk-BYAI6W7T.js.map +0 -1
- package/dist/chunk-XB5NIOKJ.js.map +0 -1
- /package/dist/{chunk-QVPEX7KY.js.map → chunk-GCCT2BDE.js.map} +0 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import * as zod from 'zod';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { ModaSupportedLanguageTag, IcuMessageCatalogue, InternationalizationRuntime } from '../../internationalization.js';
|
|
4
|
+
import { Y as CommerceShippingInformation, d as CommerceFinalResponse } from '../../response-DFDEw4K0.js';
|
|
5
|
+
import 'intl-messageformat';
|
|
6
|
+
|
|
7
|
+
declare const CommerceVerifiedPresentationSchema: z.ZodObject<{
|
|
8
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
9
|
+
brandName: z.ZodNullable<z.ZodString>;
|
|
10
|
+
locale: z.ZodEnum<{
|
|
11
|
+
tr: "tr";
|
|
12
|
+
"zh-Hans": "zh-Hans";
|
|
13
|
+
"zh-Hant": "zh-Hant";
|
|
14
|
+
cs: "cs";
|
|
15
|
+
da: "da";
|
|
16
|
+
nl: "nl";
|
|
17
|
+
en: "en";
|
|
18
|
+
fi: "fi";
|
|
19
|
+
fr: "fr";
|
|
20
|
+
de: "de";
|
|
21
|
+
it: "it";
|
|
22
|
+
ja: "ja";
|
|
23
|
+
ko: "ko";
|
|
24
|
+
nb: "nb";
|
|
25
|
+
pl: "pl";
|
|
26
|
+
"pt-BR": "pt-BR";
|
|
27
|
+
"pt-PT": "pt-PT";
|
|
28
|
+
es: "es";
|
|
29
|
+
sv: "sv";
|
|
30
|
+
th: "th";
|
|
31
|
+
}>;
|
|
32
|
+
disposition: z.ZodEnum<{
|
|
33
|
+
STANDARD: "STANDARD";
|
|
34
|
+
OUT_OF_SCOPE_REDIRECT: "OUT_OF_SCOPE_REDIRECT";
|
|
35
|
+
SHIPPING_INFORMATION_UNVERIFIED: "SHIPPING_INFORMATION_UNVERIFIED";
|
|
36
|
+
PRODUCT_OPTIONS: "PRODUCT_OPTIONS";
|
|
37
|
+
PRODUCT_DETAILS: "PRODUCT_DETAILS";
|
|
38
|
+
}>;
|
|
39
|
+
storeUrl: z.ZodString;
|
|
40
|
+
products: z.ZodArray<z.ZodObject<{
|
|
41
|
+
title: z.ZodString;
|
|
42
|
+
url: z.ZodString;
|
|
43
|
+
quantity: z.ZodNumber;
|
|
44
|
+
scope: z.ZodEnum<{
|
|
45
|
+
PRODUCT_ONLY: "PRODUCT_ONLY";
|
|
46
|
+
ADD_TO_BASKET: "ADD_TO_BASKET";
|
|
47
|
+
REPLACE_BASKET_LINE: "REPLACE_BASKET_LINE";
|
|
48
|
+
}>;
|
|
49
|
+
currentPrice: z.ZodNullable<z.ZodString>;
|
|
50
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
51
|
+
regularPrice: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
|
+
offerTerms: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
53
|
+
kind: z.ZodEnum<{
|
|
54
|
+
percent: "percent";
|
|
55
|
+
amount: "amount";
|
|
56
|
+
"free-shipping": "free-shipping";
|
|
57
|
+
}>;
|
|
58
|
+
value: z.ZodOptional<z.ZodString>;
|
|
59
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
60
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
61
|
+
automatic: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
}, z.core.$strict>>>;
|
|
63
|
+
}, z.core.$strict>>;
|
|
64
|
+
productFacts: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
65
|
+
productId: z.ZodString;
|
|
66
|
+
variantId: z.ZodNullable<z.ZodString>;
|
|
67
|
+
title: z.ZodString;
|
|
68
|
+
description: z.ZodObject<{
|
|
69
|
+
status: z.ZodEnum<{
|
|
70
|
+
AVAILABLE: "AVAILABLE";
|
|
71
|
+
NOT_PROVIDED: "NOT_PROVIDED";
|
|
72
|
+
PARTIAL: "PARTIAL";
|
|
73
|
+
}>;
|
|
74
|
+
text: z.ZodString;
|
|
75
|
+
}, z.core.$strict>;
|
|
76
|
+
attributes: z.ZodObject<{
|
|
77
|
+
status: z.ZodEnum<{
|
|
78
|
+
AVAILABLE: "AVAILABLE";
|
|
79
|
+
NOT_PROVIDED: "NOT_PROVIDED";
|
|
80
|
+
PARTIAL: "PARTIAL";
|
|
81
|
+
}>;
|
|
82
|
+
items: z.ZodArray<z.ZodObject<{
|
|
83
|
+
name: z.ZodString;
|
|
84
|
+
values: z.ZodArray<z.ZodString>;
|
|
85
|
+
}, z.core.$strict>>;
|
|
86
|
+
}, z.core.$strict>;
|
|
87
|
+
options: z.ZodPreprocess<z.ZodObject<{
|
|
88
|
+
status: z.ZodEnum<{
|
|
89
|
+
AVAILABLE: "AVAILABLE";
|
|
90
|
+
NOT_PROVIDED: "NOT_PROVIDED";
|
|
91
|
+
PARTIAL: "PARTIAL";
|
|
92
|
+
}>;
|
|
93
|
+
items: z.ZodArray<z.ZodObject<{
|
|
94
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
95
|
+
values: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
96
|
+
usedForVariants: z.ZodNullable<z.ZodBoolean>;
|
|
97
|
+
}, z.core.$strict>>;
|
|
98
|
+
}, z.core.$strict>>;
|
|
99
|
+
selectedOptions: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
|
|
100
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
101
|
+
value: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
102
|
+
}, z.core.$strict>>>;
|
|
103
|
+
}, z.core.$strict>>>;
|
|
104
|
+
optionFacts: z.ZodArray<z.ZodObject<{
|
|
105
|
+
productId: z.ZodString;
|
|
106
|
+
variantId: z.ZodNullable<z.ZodString>;
|
|
107
|
+
title: z.ZodString;
|
|
108
|
+
options: z.ZodPreprocess<z.ZodObject<{
|
|
109
|
+
status: z.ZodEnum<{
|
|
110
|
+
AVAILABLE: "AVAILABLE";
|
|
111
|
+
NOT_PROVIDED: "NOT_PROVIDED";
|
|
112
|
+
PARTIAL: "PARTIAL";
|
|
113
|
+
}>;
|
|
114
|
+
items: z.ZodArray<z.ZodObject<{
|
|
115
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
116
|
+
values: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
117
|
+
usedForVariants: z.ZodNullable<z.ZodBoolean>;
|
|
118
|
+
}, z.core.$strict>>;
|
|
119
|
+
}, z.core.$strict>>;
|
|
120
|
+
selectedOptions: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
|
|
121
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
122
|
+
value: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
123
|
+
}, z.core.$strict>>>;
|
|
124
|
+
}, z.core.$strict>>;
|
|
125
|
+
requiresShipping: z.ZodNullable<z.ZodBoolean>;
|
|
126
|
+
policyUrl: z.ZodNullable<z.ZodString>;
|
|
127
|
+
includeNoVerifiedOffer: z.ZodBoolean;
|
|
128
|
+
}, z.core.$strict>;
|
|
129
|
+
type CommerceVerifiedPresentation = z.input<typeof CommerceVerifiedPresentationSchema>;
|
|
130
|
+
|
|
131
|
+
declare const CommerceOptionFactSchema: z.ZodObject<{
|
|
132
|
+
productId: z.ZodString;
|
|
133
|
+
variantId: z.ZodNullable<z.ZodString>;
|
|
134
|
+
title: z.ZodString;
|
|
135
|
+
options: z.ZodPreprocess<z.ZodObject<{
|
|
136
|
+
status: z.ZodEnum<{
|
|
137
|
+
AVAILABLE: "AVAILABLE";
|
|
138
|
+
NOT_PROVIDED: "NOT_PROVIDED";
|
|
139
|
+
PARTIAL: "PARTIAL";
|
|
140
|
+
}>;
|
|
141
|
+
items: z.ZodArray<z.ZodObject<{
|
|
142
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
143
|
+
values: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
144
|
+
usedForVariants: z.ZodNullable<z.ZodBoolean>;
|
|
145
|
+
}, z.core.$strict>>;
|
|
146
|
+
}, z.core.$strict>>;
|
|
147
|
+
selectedOptions: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
|
|
148
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
149
|
+
value: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
150
|
+
}, z.core.$strict>>>;
|
|
151
|
+
}, z.core.$strict>;
|
|
152
|
+
type CommerceOptionFact = z.infer<typeof CommerceOptionFactSchema>;
|
|
153
|
+
declare function verifyCommerceOptionFacts(selection: readonly {
|
|
154
|
+
productId: string;
|
|
155
|
+
variantId: string | null;
|
|
156
|
+
}[], currentProducts: readonly unknown[]): {
|
|
157
|
+
kind: "verified";
|
|
158
|
+
optionFacts: CommerceOptionFact[];
|
|
159
|
+
} | {
|
|
160
|
+
kind: "limitation";
|
|
161
|
+
reason: "INVALID_SELECTION" | "PRODUCT_NOT_FOUND" | "PRODUCT_INVALID";
|
|
162
|
+
};
|
|
163
|
+
declare function renderProductOptionFacts(facts: readonly CommerceOptionFact[], locale: ModaSupportedLanguageTag): string;
|
|
164
|
+
|
|
165
|
+
declare const productOptionMessages: Readonly<Record<"tr" | "zh-Hans" | "zh-Hant" | "cs" | "da" | "nl" | "en" | "fi" | "fr" | "de" | "it" | "ja" | "ko" | "nb" | "pl" | "pt-BR" | "pt-PT" | "es" | "sv" | "th", readonly [string, string, string]>>;
|
|
166
|
+
|
|
167
|
+
/** Plain text only. Unbalanced markers and non-HTTPS links remain literal. */
|
|
168
|
+
declare function normalizeCommerceReplyText(value: string): string;
|
|
169
|
+
|
|
170
|
+
type RenderRecommendationProduct = Readonly<{
|
|
171
|
+
title: string;
|
|
172
|
+
url: string;
|
|
173
|
+
quantity: number;
|
|
174
|
+
scope: "PRODUCT_ONLY" | "ADD_TO_BASKET" | "REPLACE_BASKET_LINE";
|
|
175
|
+
currentPrice: string | null;
|
|
176
|
+
currency: string | null;
|
|
177
|
+
regularPrice?: string | null;
|
|
178
|
+
offerTerms?: readonly Readonly<{
|
|
179
|
+
kind: "percent" | "amount" | "free-shipping";
|
|
180
|
+
value?: string;
|
|
181
|
+
currency?: string;
|
|
182
|
+
code?: string | null;
|
|
183
|
+
automatic?: boolean;
|
|
184
|
+
}>[];
|
|
185
|
+
}>;
|
|
186
|
+
declare function renderRecommendationReply(input: {
|
|
187
|
+
locale: ModaSupportedLanguageTag;
|
|
188
|
+
disposition: "STANDARD" | "OUT_OF_SCOPE_REDIRECT" | "SHIPPING_INFORMATION_UNVERIFIED";
|
|
189
|
+
storeUrl: string;
|
|
190
|
+
policyUrl?: string | null;
|
|
191
|
+
requiresShipping?: boolean | null;
|
|
192
|
+
products?: readonly RenderRecommendationProduct[];
|
|
193
|
+
includeNoVerifiedOffer?: boolean;
|
|
194
|
+
}): string;
|
|
195
|
+
|
|
196
|
+
declare const recommendationMessageKeys: readonly ["scopeLimit", "shippingUnverified", "shippingRequired", "shippingNotRequired", "policyLink", "storeLink", "productOption", "proposedQuantity", "addProposal", "replaceProposal", "currentPrice", "regularPrice", "percentTerms", "amountTerms", "freeShippingTerms", "code", "automatic", "checkoutQualification", "productLink", "noVerifiedOffer", "optionsUnavailable", "optionsPartial", "optionsSelected"];
|
|
197
|
+
type MessageKey = typeof recommendationMessageKeys[number];
|
|
198
|
+
declare const recommendationMessages: Readonly<Record<ModaSupportedLanguageTag, IcuMessageCatalogue>>;
|
|
199
|
+
declare function recommendationMessage(locale: ModaSupportedLanguageTag, key: MessageKey, values?: Record<string, string | number>): string;
|
|
200
|
+
|
|
201
|
+
declare function isValidDecimal(value: string): boolean;
|
|
202
|
+
declare function currencyExponent(currency: string): number | null;
|
|
203
|
+
declare function minorUnitsToDecimal(value: bigint, currency: string): string | null;
|
|
204
|
+
declare function decimalToMinorUnits(value: string, currency: string): bigint | null;
|
|
205
|
+
declare function sumPurchaseSubtotal(lines: readonly Readonly<{
|
|
206
|
+
amountDecimal: string;
|
|
207
|
+
quantity: number;
|
|
208
|
+
}>[], currency: string): bigint | null;
|
|
209
|
+
declare function formatObservedMoney(value: string, currency: string, runtime: InternationalizationRuntime): string | null;
|
|
210
|
+
|
|
211
|
+
declare function buildReplyCandidates(input: {
|
|
212
|
+
fullBody: string;
|
|
213
|
+
firstProductBody?: string | null;
|
|
214
|
+
minimalBody: string;
|
|
215
|
+
}): readonly string[];
|
|
216
|
+
|
|
217
|
+
type ShippingPresentation = Readonly<{
|
|
218
|
+
requiresShipping: boolean | null;
|
|
219
|
+
policyUrl: string | null;
|
|
220
|
+
limitation: boolean;
|
|
221
|
+
}>;
|
|
222
|
+
declare function selectShippingPresentation(input: {
|
|
223
|
+
selection: Readonly<{
|
|
224
|
+
productId: string | null;
|
|
225
|
+
variantId: string | null;
|
|
226
|
+
}>;
|
|
227
|
+
observation: CommerceShippingInformation | null;
|
|
228
|
+
refreshed: CommerceShippingInformation | null;
|
|
229
|
+
}): ShippingPresentation;
|
|
230
|
+
|
|
231
|
+
/** Pure immutable wrapper projections. Host-owned persistence and sending stay outside Shared. */
|
|
232
|
+
type WrapperSource = "AI" | "HUMAN";
|
|
233
|
+
type WrapperAudience = "SHARED" | WrapperSource;
|
|
234
|
+
type WrapperVariable = "customer.firstName" | "shop.name" | "checkout.url" | "shopBrand.brandName" | "shopBrand.logoUrl" | "shopBrand.logoAltText" | "shopBrand.logoWidth" | "shopBrand.logoHeight" | "shopBrand.squareLogoUrl" | "shopBrand.squareLogoAltText" | "shopBrand.coverImageUrl";
|
|
235
|
+
type PreparedToken = Readonly<{
|
|
236
|
+
kind: "text";
|
|
237
|
+
value: string;
|
|
238
|
+
}> | Readonly<{
|
|
239
|
+
kind: "variable";
|
|
240
|
+
name: WrapperVariable;
|
|
241
|
+
}> | Readonly<{
|
|
242
|
+
kind: "responseSlot";
|
|
243
|
+
name: "response.body";
|
|
244
|
+
}>;
|
|
245
|
+
/** Admin emits this immutable projection in WhatsAppTemplateLocale.localeAst.prepared. */
|
|
246
|
+
type PreparedWrapper = Readonly<{
|
|
247
|
+
schemaVersion: 1;
|
|
248
|
+
family: "MODA_CONVERSATION_WRAPPER";
|
|
249
|
+
responseSlot: "response.body";
|
|
250
|
+
header: readonly PreparedToken[];
|
|
251
|
+
body: readonly PreparedToken[];
|
|
252
|
+
footer: readonly PreparedToken[];
|
|
253
|
+
conditionals: readonly Readonly<{
|
|
254
|
+
when: "checkout.available";
|
|
255
|
+
tokens: readonly PreparedToken[];
|
|
256
|
+
}>[];
|
|
257
|
+
}>;
|
|
258
|
+
type VerifiedWrapperContext = Readonly<{
|
|
259
|
+
conversationId: string;
|
|
260
|
+
shopId: string;
|
|
261
|
+
conversationLanguageTag: string | null;
|
|
262
|
+
merchantLanguageTag: string | null;
|
|
263
|
+
variables: Partial<Record<WrapperVariable, string>>;
|
|
264
|
+
checkoutAvailable: boolean;
|
|
265
|
+
}>;
|
|
266
|
+
type WrapperDefinition = Readonly<{
|
|
267
|
+
id: string;
|
|
268
|
+
kind: string;
|
|
269
|
+
audience: string | null;
|
|
270
|
+
status: string;
|
|
271
|
+
sourceLanguageTag: string;
|
|
272
|
+
astSchemaVersion: number;
|
|
273
|
+
sourceHash: string;
|
|
274
|
+
publishedAt: Date | null;
|
|
275
|
+
retiredAt: Date | null;
|
|
276
|
+
createdByAdminId: string;
|
|
277
|
+
locales: readonly Readonly<{
|
|
278
|
+
id: string;
|
|
279
|
+
languageTag: string;
|
|
280
|
+
status: string;
|
|
281
|
+
providerLanguageCode: string | null;
|
|
282
|
+
localeAst: unknown;
|
|
283
|
+
contentHash: string | null;
|
|
284
|
+
reviewedAt: Date | null;
|
|
285
|
+
reviewedByAdminId: string | null;
|
|
286
|
+
}>[];
|
|
287
|
+
}>;
|
|
288
|
+
type WrapperSlot = Readonly<{
|
|
289
|
+
audience: string;
|
|
290
|
+
definitionId: string;
|
|
291
|
+
editVersion: number;
|
|
292
|
+
definition: WrapperDefinition;
|
|
293
|
+
}>;
|
|
294
|
+
type WrapperRefusal = "INVALID_INPUT" | "INVALID_LANGUAGE" | "CONVERSATION_UNAVAILABLE" | "TENANT_MISMATCH" | "NOT_CONFIGURED" | "DEFINITION_UNAVAILABLE" | "LOCALE_UNAVAILABLE" | "PREPARED_MISSING" | "PREPARED_INVALID" | "VARIABLE_UNAVAILABLE" | "ALREADY_WRAPPED" | "OUTPUT_TOO_LONG" | "REPLAY_MISMATCH";
|
|
295
|
+
|
|
296
|
+
/** Admin's documented stable JSON hashing protocol, without importing its AST/compiler. */
|
|
297
|
+
declare function stableJson(value: unknown): string;
|
|
298
|
+
type PresentationDigest = (value: string) => string;
|
|
299
|
+
declare function digest(value: string, sha256: PresentationDigest): string;
|
|
300
|
+
/** Never parse localeAst.authoring. Fail closed if the compiled runtime projection is absent. */
|
|
301
|
+
declare function readPreparedWrapper(localeAst: unknown, contentHash: string | null, sha256: PresentationDigest): {
|
|
302
|
+
kind: "ok";
|
|
303
|
+
prepared: PreparedWrapper;
|
|
304
|
+
} | {
|
|
305
|
+
kind: "missing" | "invalid";
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
/** WhatsApp plain-text message maximum; reject before moderation and provider calls. */
|
|
309
|
+
declare const MAX_WHATSAPP_TEXT_LENGTH = 4096;
|
|
310
|
+
/** No AST reads, external dependencies, side effects, network, billing or sending. */
|
|
311
|
+
declare function renderPreparedWrapper(input: {
|
|
312
|
+
prepared: PreparedWrapper;
|
|
313
|
+
context: VerifiedWrapperContext;
|
|
314
|
+
responseBody: string;
|
|
315
|
+
}): {
|
|
316
|
+
kind: "rendered";
|
|
317
|
+
body: string;
|
|
318
|
+
} | {
|
|
319
|
+
kind: "rejected";
|
|
320
|
+
reason: WrapperRefusal;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
declare function canonicalTag(value: string | null | undefined): string | null;
|
|
324
|
+
/** Explicit precedence. Invalid override never silently falls back to SHARED. */
|
|
325
|
+
declare function chooseSlot(slots: readonly WrapperSlot[], source: "AI" | "HUMAN"): WrapperSlot | "invalid" | null;
|
|
326
|
+
declare function validDefinition(def: WrapperDefinition, slot: WrapperSlot): boolean;
|
|
327
|
+
declare function languageChoices(input: {
|
|
328
|
+
conversationTag: string | null;
|
|
329
|
+
merchantTag: string | null;
|
|
330
|
+
preferredTag: string | null | undefined;
|
|
331
|
+
platformFallbackTag: string | null;
|
|
332
|
+
}, onInvalid?: (error: unknown) => void): string[] | "invalid";
|
|
333
|
+
|
|
334
|
+
type CommerceWhatsAppPreviewInput = {
|
|
335
|
+
envelope: CommerceFinalResponse;
|
|
336
|
+
presentation: zod.input<typeof CommerceVerifiedPresentationSchema>;
|
|
337
|
+
/** Must agree with the host-verified projection. */
|
|
338
|
+
locale?: string;
|
|
339
|
+
brandName?: string | null;
|
|
340
|
+
wrapper?: {
|
|
341
|
+
slots: readonly WrapperSlot[];
|
|
342
|
+
context: VerifiedWrapperContext;
|
|
343
|
+
digest: PresentationDigest;
|
|
344
|
+
platformFallbackLanguageTag?: string | null;
|
|
345
|
+
languageTag?: string | null;
|
|
346
|
+
} | null;
|
|
347
|
+
};
|
|
348
|
+
type CommerceWhatsAppPreviewResult = {
|
|
349
|
+
kind: "ready";
|
|
350
|
+
body: string;
|
|
351
|
+
candidates: readonly string[];
|
|
352
|
+
wrapper: {
|
|
353
|
+
definitionId: string;
|
|
354
|
+
localeId: string;
|
|
355
|
+
contentHash: string;
|
|
356
|
+
slotEditVersion: number;
|
|
357
|
+
} | null;
|
|
358
|
+
} | {
|
|
359
|
+
kind: "refused";
|
|
360
|
+
reason: string;
|
|
361
|
+
};
|
|
362
|
+
/** Pure formatting/projection only; never moderation, billing or send admission. */
|
|
363
|
+
declare function composeCommerceWhatsAppPreview(input: CommerceWhatsAppPreviewInput): CommerceWhatsAppPreviewResult;
|
|
364
|
+
|
|
365
|
+
declare const CommerceProductFactSchema: z.ZodObject<{
|
|
366
|
+
productId: z.ZodString;
|
|
367
|
+
variantId: z.ZodNullable<z.ZodString>;
|
|
368
|
+
title: z.ZodString;
|
|
369
|
+
description: z.ZodObject<{
|
|
370
|
+
status: z.ZodEnum<{
|
|
371
|
+
AVAILABLE: "AVAILABLE";
|
|
372
|
+
NOT_PROVIDED: "NOT_PROVIDED";
|
|
373
|
+
PARTIAL: "PARTIAL";
|
|
374
|
+
}>;
|
|
375
|
+
text: z.ZodString;
|
|
376
|
+
}, z.core.$strict>;
|
|
377
|
+
attributes: z.ZodObject<{
|
|
378
|
+
status: z.ZodEnum<{
|
|
379
|
+
AVAILABLE: "AVAILABLE";
|
|
380
|
+
NOT_PROVIDED: "NOT_PROVIDED";
|
|
381
|
+
PARTIAL: "PARTIAL";
|
|
382
|
+
}>;
|
|
383
|
+
items: z.ZodArray<z.ZodObject<{
|
|
384
|
+
name: z.ZodString;
|
|
385
|
+
values: z.ZodArray<z.ZodString>;
|
|
386
|
+
}, z.core.$strict>>;
|
|
387
|
+
}, z.core.$strict>;
|
|
388
|
+
options: z.ZodPreprocess<z.ZodObject<{
|
|
389
|
+
status: z.ZodEnum<{
|
|
390
|
+
AVAILABLE: "AVAILABLE";
|
|
391
|
+
NOT_PROVIDED: "NOT_PROVIDED";
|
|
392
|
+
PARTIAL: "PARTIAL";
|
|
393
|
+
}>;
|
|
394
|
+
items: z.ZodArray<z.ZodObject<{
|
|
395
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
396
|
+
values: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
397
|
+
usedForVariants: z.ZodNullable<z.ZodBoolean>;
|
|
398
|
+
}, z.core.$strict>>;
|
|
399
|
+
}, z.core.$strict>>;
|
|
400
|
+
selectedOptions: z.ZodPreprocess<z.ZodArray<z.ZodObject<{
|
|
401
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
402
|
+
value: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
403
|
+
}, z.core.$strict>>>;
|
|
404
|
+
}, z.core.$strict>;
|
|
405
|
+
type CommerceProductFact = z.infer<typeof CommerceProductFactSchema>;
|
|
406
|
+
declare function verifyCommerceProductFacts(selection: readonly {
|
|
407
|
+
productId: string;
|
|
408
|
+
variantId: string | null;
|
|
409
|
+
}[], currentProducts: readonly unknown[]): {
|
|
410
|
+
kind: "verified";
|
|
411
|
+
productFacts: CommerceProductFact[];
|
|
412
|
+
} | {
|
|
413
|
+
kind: "limitation";
|
|
414
|
+
reason: "INVALID_SELECTION" | "PRODUCT_NOT_FOUND" | "PRODUCT_INVALID";
|
|
415
|
+
};
|
|
416
|
+
declare function renderCommerceProductFacts(facts: readonly CommerceProductFact[], locale: ModaSupportedLanguageTag): string;
|
|
417
|
+
|
|
418
|
+
declare const productFactMessages: Readonly<Record<"tr" | "zh-Hans" | "zh-Hant" | "cs" | "da" | "nl" | "en" | "fi" | "fr" | "de" | "it" | "ja" | "ko" | "nb" | "pl" | "pt-BR" | "pt-PT" | "es" | "sv" | "th", readonly [string, string, string]>>;
|
|
419
|
+
|
|
420
|
+
export { type CommerceOptionFact, CommerceOptionFactSchema, type CommerceProductFact, CommerceProductFactSchema, type CommerceVerifiedPresentation, CommerceVerifiedPresentationSchema, type CommerceWhatsAppPreviewInput, type CommerceWhatsAppPreviewResult, MAX_WHATSAPP_TEXT_LENGTH, type PreparedToken, type PreparedWrapper, type PresentationDigest, type RenderRecommendationProduct, type ShippingPresentation, type VerifiedWrapperContext, type WrapperAudience, type WrapperDefinition, type WrapperRefusal, type WrapperSlot, type WrapperSource, type WrapperVariable, buildReplyCandidates, canonicalTag, chooseSlot, composeCommerceWhatsAppPreview, currencyExponent, decimalToMinorUnits, digest, formatObservedMoney, isValidDecimal, languageChoices, minorUnitsToDecimal, normalizeCommerceReplyText, productFactMessages, productOptionMessages, readPreparedWrapper, recommendationMessage, recommendationMessageKeys, recommendationMessages, renderCommerceProductFacts, renderPreparedWrapper, renderProductOptionFacts, renderRecommendationReply, selectShippingPresentation, stableJson, sumPurchaseSubtotal, validDefinition, verifyCommerceOptionFacts, verifyCommerceProductFacts };
|