@rebuy/rebuy 3.27.0 → 3.28.1
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/index.cjs +383 -347
- package/dist/index.mjs +382 -346
- package/dist/schema/checkout-and-beyond/constants.cjs +5 -0
- package/dist/schema/checkout-and-beyond/constants.mjs +5 -0
- package/dist/schema/checkout-and-beyond/index.cjs +104 -68
- package/dist/schema/checkout-and-beyond/index.mjs +104 -68
- package/dist/schema/widget-data.cjs +167 -135
- package/dist/schema/widget-data.mjs +167 -135
- package/dist/schema/widgetData.d.ts +24 -0
- package/dist/schema/widgets/checkout-and-beyond/banner.d.ts +8 -0
- package/dist/schema/widgets/checkout-and-beyond/carousel.d.ts +8 -0
- package/dist/schema/widgets/checkout-and-beyond/cartLine.d.ts +8 -0
- package/dist/schema/widgets/checkout-and-beyond/common.d.ts +13 -1
- package/dist/schema/widgets/checkout-and-beyond/index.d.ts +1 -0
- package/dist/schema/widgets/checkout-and-beyond/layout.d.ts +17 -1
- package/dist/schema/widgets/checkout-and-beyond/offers.d.ts +8 -0
- package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts +8 -0
- package/dist/schema/widgets/checkout-and-beyond/reviews.d.ts +2 -0
- package/dist/schema/widgets/checkout-and-beyond/root.d.ts +8 -0
- package/dist/schema/widgets/checkout-and-beyond/separator.d.ts +192 -0
- package/dist/schema/widgets/checkout-and-beyond/shared.d.ts +2 -1
- package/dist/schema/widgets/contentBlock.d.ts +8 -0
- package/dist/schema/widgets/lineItemEditor.d.ts +8 -0
- package/dist/schema/widgets/post-purchase-offer/constants.d.ts +2 -2
- package/dist/schema/widgets/rebuyButton.d.ts +8 -0
- package/dist/server/index.cjs +606 -188
- package/dist/server/index.mjs +606 -188
- package/dist/transforms/index.cjs +486 -59
- package/dist/transforms/index.d.ts +2 -0
- package/dist/transforms/index.mjs +486 -59
- package/dist/transforms/postPurchase/convertCalloutBlock.d.ts +8 -0
- package/dist/transforms/postPurchase/convertMessagePreview.d.ts +8 -0
- package/dist/transforms/postPurchase/convertPayButtonBlock.d.ts +4 -0
- package/dist/transforms/postPurchase/convertSeparatorBlock.d.ts +4 -0
- package/dist/transforms/postPurchase/convertTextBlock.d.ts +4 -0
- package/dist/transforms/postPurchase/convertTimerBlock.d.ts +4 -0
- package/dist/transforms/postPurchase/styledTextRun.d.ts +3 -0
- package/dist/transforms/postPurchase/types.d.ts +14 -0
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -674,8 +674,8 @@ var CabUserConfig = import_zod6.z.object({
|
|
|
674
674
|
});
|
|
675
675
|
|
|
676
676
|
// src/schema/widgets/checkout-and-beyond/image.ts
|
|
677
|
-
var
|
|
678
|
-
var
|
|
677
|
+
var import_uuid13 = require("uuid");
|
|
678
|
+
var import_zod27 = require("zod");
|
|
679
679
|
|
|
680
680
|
// src/schema/widgets/checkout-and-beyond/common.ts
|
|
681
681
|
var freezeEnum = (values) => Object.freeze(Object.fromEntries(values.map((v) => [v, v])));
|
|
@@ -784,6 +784,8 @@ var languageKeys = [
|
|
|
784
784
|
"zh"
|
|
785
785
|
];
|
|
786
786
|
var LanguageKey = freezeEnum(languageKeys);
|
|
787
|
+
var layoutFrames = ["callout", "offer-content"];
|
|
788
|
+
var LayoutFrame = freezeEnum(layoutFrames);
|
|
787
789
|
var mutatorEvents = ["item_added", "quantity_changed", "variant_selected"];
|
|
788
790
|
var MutatorEvent = freezeEnum(mutatorEvents);
|
|
789
791
|
var objectFits = ["cover", "contain"];
|
|
@@ -822,6 +824,7 @@ var sectionTypes = [
|
|
|
822
824
|
"progressBar",
|
|
823
825
|
"quantity",
|
|
824
826
|
"reviews",
|
|
827
|
+
"separator",
|
|
825
828
|
"text",
|
|
826
829
|
"variants"
|
|
827
830
|
];
|
|
@@ -965,7 +968,7 @@ var ROOT_RELATIVE_PATH_REGEX = /^\/(?!\/)/;
|
|
|
965
968
|
var HTML_TAGS_REGEX = /<\/?[a-zA-Z][^>]*>/g;
|
|
966
969
|
|
|
967
970
|
// src/schema/widgets/checkout-and-beyond/shared.ts
|
|
968
|
-
var
|
|
971
|
+
var import_zod26 = require("zod");
|
|
969
972
|
|
|
970
973
|
// src/schema/widgets/checkout-and-beyond/banner.ts
|
|
971
974
|
var import_zod10 = require("zod");
|
|
@@ -1120,6 +1123,10 @@ var CABVariableFields = {
|
|
|
1120
1123
|
|
|
1121
1124
|
// src/schema/widgets/checkout-and-beyond/layout.ts
|
|
1122
1125
|
var GridItem = import_zod9.z.union([import_zod9.z.literal("auto"), import_zod9.z.literal("fill"), import_zod9.z.string().regex(/^\d+%$/), import_zod9.z.number()]);
|
|
1126
|
+
var CABLayoutWrapping = import_zod9.z.object({
|
|
1127
|
+
breakAt: import_zod9.z.number().positive(),
|
|
1128
|
+
maxPerLine: import_zod9.z.number().int().positive()
|
|
1129
|
+
});
|
|
1123
1130
|
var CABLayoutSection = import_zod9.z.object({
|
|
1124
1131
|
...CABVariableFields,
|
|
1125
1132
|
alignment: import_zod9.z.object({
|
|
@@ -1132,6 +1139,11 @@ var CABLayoutSection = import_zod9.z.object({
|
|
|
1132
1139
|
border: import_zod9.z.lazy(() => CABBorder),
|
|
1133
1140
|
buttonField: import_zod9.z.enum(buttonFields).optional(),
|
|
1134
1141
|
direction: import_zod9.z.enum(directions).default(Direction.rows),
|
|
1142
|
+
/**
|
|
1143
|
+
* Platform chrome around the section, not a layout behavior: `callout` is a subdued box with block borders
|
|
1144
|
+
* (the legacy post-purchase callout banner), `offer-content` the post-purchase offer's own content card.
|
|
1145
|
+
*/
|
|
1146
|
+
frame: import_zod9.z.enum(layoutFrames).optional(),
|
|
1135
1147
|
grid: import_zod9.z.object({
|
|
1136
1148
|
columns: import_zod9.z.union([import_zod9.z.array(GridItem), import_zod9.z.undefined()]).default(() => ["auto"]),
|
|
1137
1149
|
rows: import_zod9.z.union([import_zod9.z.array(GridItem), import_zod9.z.undefined()]).default(() => ["auto"])
|
|
@@ -1144,7 +1156,8 @@ var CABLayoutSection = import_zod9.z.object({
|
|
|
1144
1156
|
spacing: import_zod9.z.enum(spacings).default(Spacing.base),
|
|
1145
1157
|
/** Fire-and-forget impression pixel POSTed once when the section is shown (e.g. a Monetize offer view). */
|
|
1146
1158
|
viewUrl: import_zod9.z.string().optional(),
|
|
1147
|
-
width: import_zod9.z.number().default(100)
|
|
1159
|
+
width: import_zod9.z.number().default(100),
|
|
1160
|
+
wrapping: CABLayoutWrapping.optional()
|
|
1148
1161
|
});
|
|
1149
1162
|
|
|
1150
1163
|
// src/schema/widgets/checkout-and-beyond/utils.ts
|
|
@@ -2008,35 +2021,53 @@ var CABReviewsSection = import_zod23.z.object({
|
|
|
2008
2021
|
name: import_zod23.z.string().optional(),
|
|
2009
2022
|
sectionId: import_zod23.z.uuid().default(() => (0, import_uuid10.v7)()),
|
|
2010
2023
|
sectionType: import_zod23.z.literal(SectionType.reviews).default(SectionType.reviews),
|
|
2011
|
-
size: import_zod23.z.enum(reviewsSizes).default(ReviewsSize.default)
|
|
2024
|
+
size: import_zod23.z.enum(reviewsSizes).default(ReviewsSize.default),
|
|
2025
|
+
/**
|
|
2026
|
+
* Star outline color, interpolated into a style by the renderer, so it is hex-constrained like
|
|
2027
|
+
* `CABButtonSection.color`. The legacy source (`PostPurchaseSettings.styles.starStrokeColor`) is a free
|
|
2028
|
+
* string: its converter must validate and fall back to this default rather than let one odd value drop
|
|
2029
|
+
* the whole reviews section.
|
|
2030
|
+
*/
|
|
2031
|
+
strokeColor: import_zod23.z.string().regex(HEX_COLOR_REGEX).default("#fadb14"),
|
|
2032
|
+
/** Star outline width in px; `0` draws no outline. The legacy `styles.strokeWidth` is a STRING ('1') — its converter coerces. */
|
|
2033
|
+
strokeWidth: import_zod23.z.number().nonnegative().default(0)
|
|
2012
2034
|
});
|
|
2013
2035
|
|
|
2014
|
-
// src/schema/widgets/checkout-and-beyond/
|
|
2015
|
-
var import_compat3 = require("es-toolkit/compat");
|
|
2036
|
+
// src/schema/widgets/checkout-and-beyond/separator.ts
|
|
2016
2037
|
var import_uuid11 = require("uuid");
|
|
2017
2038
|
var import_zod24 = require("zod");
|
|
2018
|
-
var
|
|
2039
|
+
var CABSeparatorSection = import_zod24.z.object({
|
|
2019
2040
|
...CABVariableFields,
|
|
2020
|
-
hideOutOfStockVariants: import_zod24.z.boolean().default(false),
|
|
2021
|
-
name: import_zod24.z.string().optional(),
|
|
2022
2041
|
sectionId: import_zod24.z.uuid().default(() => (0, import_uuid11.v7)()),
|
|
2023
|
-
sectionType: import_zod24.z.literal(SectionType.
|
|
2024
|
-
|
|
2025
|
-
|
|
2042
|
+
sectionType: import_zod24.z.literal(SectionType.separator).default(SectionType.separator)
|
|
2043
|
+
});
|
|
2044
|
+
|
|
2045
|
+
// src/schema/widgets/checkout-and-beyond/variants.ts
|
|
2046
|
+
var import_compat3 = require("es-toolkit/compat");
|
|
2047
|
+
var import_uuid12 = require("uuid");
|
|
2048
|
+
var import_zod25 = require("zod");
|
|
2049
|
+
var CABVariantsSection = import_zod25.z.object({
|
|
2050
|
+
...CABVariableFields,
|
|
2051
|
+
hideOutOfStockVariants: import_zod25.z.boolean().default(false),
|
|
2052
|
+
name: import_zod25.z.string().optional(),
|
|
2053
|
+
sectionId: import_zod25.z.uuid().default(() => (0, import_uuid12.v7)()),
|
|
2054
|
+
sectionType: import_zod25.z.literal(SectionType.variants).default(SectionType.variants),
|
|
2055
|
+
selector: import_zod25.z.enum((0, import_compat3.slice)(variantSelectors, 0, 3)).default(VariantSelector.menu),
|
|
2056
|
+
variantMode: import_zod25.z.enum(variantModes).default(VariantMode.multiple)
|
|
2026
2057
|
});
|
|
2027
2058
|
|
|
2028
2059
|
// src/schema/widgets/checkout-and-beyond/shared.ts
|
|
2029
|
-
var CABBorder =
|
|
2030
|
-
radius:
|
|
2031
|
-
style:
|
|
2032
|
-
width:
|
|
2060
|
+
var CABBorder = import_zod26.z.object({
|
|
2061
|
+
radius: import_zod26.z.enum(borderRadii).default(BorderRadius.base),
|
|
2062
|
+
style: import_zod26.z.enum(borderStyles).default(BorderStyle.none),
|
|
2063
|
+
width: import_zod26.z.enum(borderWidths).default(BorderWidth.base)
|
|
2033
2064
|
}).default({
|
|
2034
2065
|
radius: BorderRadius.base,
|
|
2035
2066
|
style: BorderStyle.none,
|
|
2036
2067
|
width: BorderWidth.base
|
|
2037
2068
|
});
|
|
2038
|
-
var CABSection =
|
|
2039
|
-
() =>
|
|
2069
|
+
var CABSection = import_zod26.z.lazy(
|
|
2070
|
+
() => import_zod26.z.discriminatedUnion("sectionType", [
|
|
2040
2071
|
CABBannerSection,
|
|
2041
2072
|
CABButtonSection,
|
|
2042
2073
|
CABCarouselSection,
|
|
@@ -2052,23 +2083,24 @@ var CABSection = import_zod25.z.lazy(
|
|
|
2052
2083
|
CABProgressBarSection,
|
|
2053
2084
|
CABQuantitySection,
|
|
2054
2085
|
CABReviewsSection,
|
|
2086
|
+
CABSeparatorSection,
|
|
2055
2087
|
CABTextSection,
|
|
2056
2088
|
CABVariantsSection
|
|
2057
2089
|
])
|
|
2058
2090
|
);
|
|
2059
2091
|
|
|
2060
2092
|
// src/schema/widgets/checkout-and-beyond/image.ts
|
|
2061
|
-
var CABImageSectionFields =
|
|
2093
|
+
var CABImageSectionFields = import_zod27.z.object({
|
|
2062
2094
|
...CABVariableFields,
|
|
2063
|
-
altText:
|
|
2095
|
+
altText: import_zod27.z.string().refine(checkForHTML, NO_HTML).default(""),
|
|
2064
2096
|
/**
|
|
2065
2097
|
* Image width÷height (e.g. `46` for the progress-bar fill); `null` renders at natural size. Any POSITIVE
|
|
2066
2098
|
* ratio — never limited to 1, but never `0`/negative either: a renderer dividing by it would get `Infinity`,
|
|
2067
2099
|
* and CSS `aspect-ratio` drops a negative value and silently reverts to natural size.
|
|
2068
2100
|
*/
|
|
2069
|
-
aspectRatio:
|
|
2070
|
-
border:
|
|
2071
|
-
buttonField:
|
|
2101
|
+
aspectRatio: import_zod27.z.number().positive().nullable().default(null),
|
|
2102
|
+
border: import_zod27.z.lazy(() => CABBorder),
|
|
2103
|
+
buttonField: import_zod27.z.enum(buttonFields).optional(),
|
|
2072
2104
|
/**
|
|
2073
2105
|
* `icon` renders `source` as a single `s-icon` by name (the uber-image path covers icons too), reading
|
|
2074
2106
|
* `iconSize`/`iconTone`. The other values are a harmless informational holdover from the previous
|
|
@@ -2087,29 +2119,29 @@ var CABImageSectionFields = import_zod26.z.object({
|
|
|
2087
2119
|
* behavior degraded gracefully and told us about it. The client-assembled half of the invariant was never
|
|
2088
2120
|
* the risky half.
|
|
2089
2121
|
*/
|
|
2090
|
-
category:
|
|
2122
|
+
category: import_zod27.z.enum(["gallery", "icon", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
|
|
2091
2123
|
/** `icon`-mode only: the `s-icon` `size`; `null` ⇒ the component default (`base`). Ignored by image treatments. */
|
|
2092
|
-
iconSize:
|
|
2124
|
+
iconSize: import_zod27.z.enum(iconSizes).nullable().default(null),
|
|
2093
2125
|
/** `icon`-mode only: the `s-icon` `tone`; `null` ⇒ the component default (`auto`). Ignored by image treatments. */
|
|
2094
|
-
iconTone:
|
|
2095
|
-
name:
|
|
2096
|
-
naturalHeight:
|
|
2097
|
-
naturalWidth:
|
|
2126
|
+
iconTone: import_zod27.z.enum(iconTones).nullable().default(null),
|
|
2127
|
+
name: import_zod27.z.string().optional(),
|
|
2128
|
+
naturalHeight: import_zod27.z.number().default(0),
|
|
2129
|
+
naturalWidth: import_zod27.z.number().default(0),
|
|
2098
2130
|
/**
|
|
2099
2131
|
* `contain` (the component default): dimensionless images render in s-image's 1/1 default frame, and
|
|
2100
2132
|
* `cover` would crop non-square art (payment badges lost their edges — 15993); `contain` letterboxes.
|
|
2101
2133
|
*/
|
|
2102
|
-
objectFit:
|
|
2103
|
-
sectionId:
|
|
2104
|
-
sectionType:
|
|
2134
|
+
objectFit: import_zod27.z.enum(objectFits).default(ObjectFit.contain),
|
|
2135
|
+
sectionId: import_zod27.z.uuid().default(() => (0, import_uuid13.v7)()),
|
|
2136
|
+
sectionType: import_zod27.z.literal(SectionType.image).default(SectionType.image),
|
|
2105
2137
|
/**
|
|
2106
2138
|
* An image URL or dynamic token, an empty default, or — when `category: 'icon'` — an icon NAME. Icon mode
|
|
2107
2139
|
* takes a name or `''` only, NOT a token: no renderer resolves a token to an icon today, so accepting one
|
|
2108
2140
|
* would promise a capability that doesn't exist. Widen the refine's carve-out to `DYNAMIC_TOKEN_REGEX` when a
|
|
2109
2141
|
* server-chosen tier icon actually needs it.
|
|
2110
2142
|
*/
|
|
2111
|
-
source:
|
|
2112
|
-
width:
|
|
2143
|
+
source: import_zod27.z.union([import_zod27.z.url(), import_zod27.z.literal(""), import_zod27.z.string().regex(DYNAMIC_TOKEN_REGEX), import_zod27.z.enum(iconNames)]).default(""),
|
|
2144
|
+
width: import_zod27.z.number().default(100)
|
|
2113
2145
|
});
|
|
2114
2146
|
var iconNameSet = new Set(iconNames);
|
|
2115
2147
|
var isIconName = (source) => iconNameSet.has(source);
|
|
@@ -2260,7 +2292,7 @@ var convertContentBlockTextToV2 = (language, text2 = literalText, textAlign = "c
|
|
|
2260
2292
|
};
|
|
2261
2293
|
|
|
2262
2294
|
// src/schema/widgets/checkout-and-beyond/root.ts
|
|
2263
|
-
var
|
|
2295
|
+
var import_zod28 = require("zod");
|
|
2264
2296
|
|
|
2265
2297
|
// src/schema/widgets/checkout-and-beyond/uiLabels.ts
|
|
2266
2298
|
var UI_LABELS = {
|
|
@@ -2280,8 +2312,8 @@ var UI_LABELS = {
|
|
|
2280
2312
|
};
|
|
2281
2313
|
|
|
2282
2314
|
// src/schema/widgets/checkout-and-beyond/root.ts
|
|
2283
|
-
var localized = (fallback) =>
|
|
2284
|
-
var CABUILabels =
|
|
2315
|
+
var localized = (fallback) => import_zod28.z.record(import_zod28.z.string(), import_zod28.z.string()).default(() => ({ ...fallback })).transform((labels) => Object.keys(labels).length > 0 ? labels : { ...fallback });
|
|
2316
|
+
var CABUILabels = import_zod28.z.object({
|
|
2285
2317
|
currentPage: localized(UI_LABELS.currentPage),
|
|
2286
2318
|
guest: localized(UI_LABELS.guest),
|
|
2287
2319
|
loadingOptions: localized(UI_LABELS.loadingOptions),
|
|
@@ -2306,37 +2338,37 @@ var CABUILabels = import_zod27.z.object({
|
|
|
2306
2338
|
subscriptionOptions: { ...UI_LABELS.subscriptionOptions },
|
|
2307
2339
|
updating: { ...UI_LABELS.updating }
|
|
2308
2340
|
}));
|
|
2309
|
-
var TargetArea =
|
|
2310
|
-
fill:
|
|
2311
|
-
flip:
|
|
2312
|
-
icon:
|
|
2313
|
-
label:
|
|
2314
|
-
width:
|
|
2341
|
+
var TargetArea = import_zod28.z.object({
|
|
2342
|
+
fill: import_zod28.z.boolean().optional(),
|
|
2343
|
+
flip: import_zod28.z.enum(["both", "horizontal", "vertical"]).optional(),
|
|
2344
|
+
icon: import_zod28.z.string(),
|
|
2345
|
+
label: import_zod28.z.string(),
|
|
2346
|
+
width: import_zod28.z.string()
|
|
2315
2347
|
}).default(targetAreas[EditorMode.checkoutExtension][1]);
|
|
2316
|
-
var CABTracking =
|
|
2317
|
-
enableAttribution:
|
|
2318
|
-
enableSource:
|
|
2319
|
-
enableWidget:
|
|
2348
|
+
var CABTracking = import_zod28.z.object({
|
|
2349
|
+
enableAttribution: import_zod28.z.boolean().nullish().transform((value) => value ?? true),
|
|
2350
|
+
enableSource: import_zod28.z.boolean().nullish().transform((value) => value ?? true),
|
|
2351
|
+
enableWidget: import_zod28.z.boolean().nullish().transform((value) => value ?? true)
|
|
2320
2352
|
}).nullish().transform((value) => value ?? { enableAttribution: true, enableSource: true, enableWidget: true });
|
|
2321
|
-
var CABExperiment =
|
|
2322
|
-
elementId:
|
|
2323
|
-
experimentId:
|
|
2324
|
-
experimentType:
|
|
2325
|
-
selectedId:
|
|
2353
|
+
var CABExperiment = import_zod28.z.object({
|
|
2354
|
+
elementId: import_zod28.z.number(),
|
|
2355
|
+
experimentId: import_zod28.z.number(),
|
|
2356
|
+
experimentType: import_zod28.z.string(),
|
|
2357
|
+
selectedId: import_zod28.z.number()
|
|
2326
2358
|
});
|
|
2327
2359
|
var CABRootSection = CABLayoutSection.extend({
|
|
2328
|
-
editorMode:
|
|
2360
|
+
editorMode: import_zod28.z.enum(editorModes).default(EditorMode.checkoutExtension),
|
|
2329
2361
|
experiment: CABExperiment.optional(),
|
|
2330
2362
|
// Same rule as CABTracking above: the v1 converters pass raw legacy `previewMode` through, so a
|
|
2331
2363
|
// `null` must fall back rather than throw the widget; malformed values still throw.
|
|
2332
|
-
previewMode:
|
|
2333
|
-
storeId:
|
|
2364
|
+
previewMode: import_zod28.z.boolean().nullish().transform((value) => value ?? false),
|
|
2365
|
+
storeId: import_zod28.z.number().nullable().default(null),
|
|
2334
2366
|
targetArea: TargetArea.nullable(),
|
|
2335
2367
|
tracking: CABTracking,
|
|
2336
|
-
type:
|
|
2368
|
+
type: import_zod28.z.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
|
|
2337
2369
|
uiLabels: CABUILabels,
|
|
2338
|
-
version:
|
|
2339
|
-
widgetId:
|
|
2370
|
+
version: import_zod28.z.literal(2).default(2),
|
|
2371
|
+
widgetId: import_zod28.z.number().nullable().default(null)
|
|
2340
2372
|
});
|
|
2341
2373
|
|
|
2342
2374
|
// src/transforms/v1Location.ts
|
|
@@ -3745,6 +3777,391 @@ var convertOfferToV2 = ({ id, name, settings }) => {
|
|
|
3745
3777
|
// src/transforms/parseShielded.ts
|
|
3746
3778
|
var parseShielded = (schema, raw, transform = (input) => input) => schema.parse(transform(convertNumericObjects(deepCamelCase(raw))));
|
|
3747
3779
|
|
|
3780
|
+
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
3781
|
+
var import_zod33 = require("zod");
|
|
3782
|
+
|
|
3783
|
+
// src/transforms/postPurchase/convertCalloutBlock.ts
|
|
3784
|
+
var import_zod31 = require("zod");
|
|
3785
|
+
|
|
3786
|
+
// src/schema/widgets/post-purchase-offer/postPurchaseBlocks.ts
|
|
3787
|
+
var import_compat4 = require("es-toolkit/compat");
|
|
3788
|
+
var import_uuid14 = require("uuid");
|
|
3789
|
+
var import_zod30 = require("zod");
|
|
3790
|
+
|
|
3791
|
+
// src/schema/widgets/post-purchase-offer/constants.ts
|
|
3792
|
+
var import_zod29 = require("zod");
|
|
3793
|
+
var blockTypes = [
|
|
3794
|
+
"callout_banner",
|
|
3795
|
+
"image",
|
|
3796
|
+
"image_content",
|
|
3797
|
+
"pay_button",
|
|
3798
|
+
"product_information",
|
|
3799
|
+
"separator",
|
|
3800
|
+
"text",
|
|
3801
|
+
"timer"
|
|
3802
|
+
];
|
|
3803
|
+
var blockType = import_zod29.z.enum(blockTypes);
|
|
3804
|
+
var BlockType = blockType.enum;
|
|
3805
|
+
|
|
3806
|
+
// src/schema/widgets/post-purchase-offer/postPurchaseBlocks.ts
|
|
3807
|
+
var TextAlignment2 = import_zod30.z.union([import_zod30.z.enum(["leading", "center", "trailing"]), import_zod30.z.unknown().transform(() => "leading")]);
|
|
3808
|
+
var TextSize = import_zod30.z.union([
|
|
3809
|
+
import_zod30.z.enum(["xsmall", "small", "base", "default", "medium", "large", "xlarge"]),
|
|
3810
|
+
import_zod30.z.unknown().transform(() => "medium")
|
|
3811
|
+
]);
|
|
3812
|
+
var CalloutBannerBlock = import_zod30.z.object({
|
|
3813
|
+
id: import_zod30.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3814
|
+
name: import_zod30.z.string().optional(),
|
|
3815
|
+
settings: import_zod30.z.object({
|
|
3816
|
+
superTitle: import_zod30.z.union([import_zod30.z.string(), TiptapDocument]).default(() => "Limited-time Offer"),
|
|
3817
|
+
title: import_zod30.z.union([import_zod30.z.string(), TiptapDocument]).default(() => "Add this customer favorite to your order")
|
|
3818
|
+
}),
|
|
3819
|
+
styles: import_zod30.z.object({
|
|
3820
|
+
superTitleEmphasized: import_zod30.z.boolean().default(false),
|
|
3821
|
+
superTitleSize: TextSize.default("large"),
|
|
3822
|
+
textAlignment: TextAlignment2.default("center"),
|
|
3823
|
+
titleEmphasized: import_zod30.z.boolean().default(true),
|
|
3824
|
+
titleSize: TextSize.default("large")
|
|
3825
|
+
}),
|
|
3826
|
+
type: import_zod30.z.literal(BlockType.callout_banner).default(BlockType.callout_banner)
|
|
3827
|
+
});
|
|
3828
|
+
var ImageBlock = import_zod30.z.object({
|
|
3829
|
+
id: import_zod30.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3830
|
+
name: import_zod30.z.string().optional(),
|
|
3831
|
+
settings: import_zod30.z.union([
|
|
3832
|
+
import_zod30.z.object({
|
|
3833
|
+
/** This isn't used in the post-purchase offer widget */
|
|
3834
|
+
alt: import_zod30.z.string().optional().default(""),
|
|
3835
|
+
image: import_zod30.z.union([import_zod30.z.literal(""), import_zod30.z.url()]).default(""),
|
|
3836
|
+
imageSize: import_zod30.z.number().default(20),
|
|
3837
|
+
imageType: import_zod30.z.enum(["URL", "UPLOAD"]).default("URL")
|
|
3838
|
+
}),
|
|
3839
|
+
import_zod30.z.array(import_zod30.z.never()).transform(() => ({}))
|
|
3840
|
+
]),
|
|
3841
|
+
type: import_zod30.z.literal(BlockType.image).default(BlockType.image)
|
|
3842
|
+
});
|
|
3843
|
+
var ImageContentBlock = import_zod30.z.object({
|
|
3844
|
+
id: import_zod30.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3845
|
+
name: import_zod30.z.string().optional(),
|
|
3846
|
+
settings: import_zod30.z.object({
|
|
3847
|
+
alt: import_zod30.z.string().optional().default(""),
|
|
3848
|
+
description: import_zod30.z.union([import_zod30.z.string(), TiptapDocument, import_zod30.z.null()]).default(
|
|
3849
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
|
3850
|
+
),
|
|
3851
|
+
descriptionSize: TextSize.default("medium"),
|
|
3852
|
+
horizontalAlignment: TextAlignment2.default("leading"),
|
|
3853
|
+
image: import_zod30.z.union([import_zod30.z.literal(""), import_zod30.z.url()]).default(""),
|
|
3854
|
+
imagePlacement: import_zod30.z.enum(["bottom", "left", "right", "top"]).optional().default("left"),
|
|
3855
|
+
imageSize: import_zod30.z.number().default(20),
|
|
3856
|
+
superTitle: import_zod30.z.union([import_zod30.z.string(), TiptapDocument]).default("Lorem Ipsum!"),
|
|
3857
|
+
superTitleSize: TextSize.default("medium"),
|
|
3858
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
3859
|
+
swapContent: import_zod30.z.boolean().optional().default(false),
|
|
3860
|
+
title: import_zod30.z.union([import_zod30.z.string(), TiptapDocument]).nullable().default("Lorem ipsum dolor sit amet"),
|
|
3861
|
+
titleSize: TextSize.default("medium")
|
|
3862
|
+
}),
|
|
3863
|
+
type: import_zod30.z.literal(BlockType.image_content).default(BlockType.image_content)
|
|
3864
|
+
});
|
|
3865
|
+
var PayButtonBlock = import_zod30.z.object({
|
|
3866
|
+
id: import_zod30.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3867
|
+
name: import_zod30.z.string().optional(),
|
|
3868
|
+
settings: import_zod30.z.union([
|
|
3869
|
+
import_zod30.z.object({
|
|
3870
|
+
label: import_zod30.z.string().default("Pay Now")
|
|
3871
|
+
}),
|
|
3872
|
+
import_zod30.z.array(import_zod30.z.never()).transform(() => ({
|
|
3873
|
+
label: "Pay Now"
|
|
3874
|
+
}))
|
|
3875
|
+
]),
|
|
3876
|
+
styles: import_zod30.z.union([
|
|
3877
|
+
import_zod30.z.object({
|
|
3878
|
+
buttonWidth: import_zod30.z.number().min(10).max(100).default(50)
|
|
3879
|
+
}),
|
|
3880
|
+
import_zod30.z.array(import_zod30.z.never()).transform(() => ({
|
|
3881
|
+
buttonWidth: 50
|
|
3882
|
+
}))
|
|
3883
|
+
]),
|
|
3884
|
+
type: import_zod30.z.literal(BlockType.pay_button).default(BlockType.pay_button)
|
|
3885
|
+
});
|
|
3886
|
+
var ProductInformationBlock = import_zod30.z.object({
|
|
3887
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
3888
|
+
hideProductImage: import_zod30.z.boolean().optional().default(false),
|
|
3889
|
+
id: import_zod30.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3890
|
+
name: import_zod30.z.string().optional(),
|
|
3891
|
+
type: import_zod30.z.literal(BlockType.product_information).default(BlockType.product_information)
|
|
3892
|
+
});
|
|
3893
|
+
var SeparatorBlock = import_zod30.z.object({
|
|
3894
|
+
id: import_zod30.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3895
|
+
name: import_zod30.z.string().optional(),
|
|
3896
|
+
type: import_zod30.z.literal(BlockType.separator).default(BlockType.separator)
|
|
3897
|
+
});
|
|
3898
|
+
var TextBlock = import_zod30.z.object({
|
|
3899
|
+
id: import_zod30.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3900
|
+
name: import_zod30.z.string().optional(),
|
|
3901
|
+
settings: import_zod30.z.object({
|
|
3902
|
+
description: import_zod30.z.union([import_zod30.z.string(), TiptapDocument]).optional().default(
|
|
3903
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
|
3904
|
+
),
|
|
3905
|
+
/** This isn't used in the post-purchase offer widget */
|
|
3906
|
+
descriptionSize: TextSize.default("medium"),
|
|
3907
|
+
horizontalAlignment: TextAlignment2.default("leading"),
|
|
3908
|
+
superTitle: import_zod30.z.union([import_zod30.z.string(), TiptapDocument]).default("Super Title"),
|
|
3909
|
+
/** This isn't used in the post-purchase offer widget */
|
|
3910
|
+
superTitleSize: TextSize.default("medium"),
|
|
3911
|
+
title: import_zod30.z.union([import_zod30.z.string(), TiptapDocument]).nullable().default("Lorem ipsum dolor sit amet."),
|
|
3912
|
+
/** This isn't used in the post-purchase offer widget */
|
|
3913
|
+
titleSize: TextSize.default("medium")
|
|
3914
|
+
}),
|
|
3915
|
+
type: import_zod30.z.literal(BlockType.text).default(BlockType.text)
|
|
3916
|
+
});
|
|
3917
|
+
var TimerBlock = import_zod30.z.object({
|
|
3918
|
+
id: import_zod30.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3919
|
+
name: import_zod30.z.string().optional(),
|
|
3920
|
+
settings: import_zod30.z.object({
|
|
3921
|
+
durationMinutes: import_zod30.z.number().min(0).default(10),
|
|
3922
|
+
durationSeconds: import_zod30.z.union([import_zod30.z.number().min(0), import_zod30.z.unknown().transform(() => 0)]).default(0),
|
|
3923
|
+
endOffer: import_zod30.z.boolean().default(true),
|
|
3924
|
+
title: import_zod30.z.union([import_zod30.z.string(), TiptapDocument]).default("Hurry \u2014 your special offer ends in:")
|
|
3925
|
+
}),
|
|
3926
|
+
styles: import_zod30.z.object({
|
|
3927
|
+
textAlignment: TextAlignment2.default("center"),
|
|
3928
|
+
timerBackgroundColor: import_zod30.z.enum(["info", "warning", "success", "critical"]).default("warning"),
|
|
3929
|
+
timerEmphasized: import_zod30.z.union([import_zod30.z.boolean(), import_zod30.z.unknown().transform(() => true)]).default(true),
|
|
3930
|
+
timerSize: TextSize.default("medium"),
|
|
3931
|
+
timerWidth: import_zod30.z.number().min(10).max(100).optional().default(100),
|
|
3932
|
+
titleEmphasized: import_zod30.z.union([import_zod30.z.boolean(), import_zod30.z.unknown().transform(() => true)]).default(false),
|
|
3933
|
+
titleSize: TextSize.default("medium")
|
|
3934
|
+
}),
|
|
3935
|
+
type: import_zod30.z.literal(BlockType.timer).default(BlockType.timer)
|
|
3936
|
+
});
|
|
3937
|
+
var PostPurchaseBlock = import_zod30.z.discriminatedUnion("type", [
|
|
3938
|
+
CalloutBannerBlock,
|
|
3939
|
+
ImageBlock,
|
|
3940
|
+
ImageContentBlock,
|
|
3941
|
+
PayButtonBlock,
|
|
3942
|
+
ProductInformationBlock,
|
|
3943
|
+
SeparatorBlock,
|
|
3944
|
+
TextBlock,
|
|
3945
|
+
TimerBlock
|
|
3946
|
+
]);
|
|
3947
|
+
|
|
3948
|
+
// src/transforms/postPurchase/styledTextRun.ts
|
|
3949
|
+
var sizes = {
|
|
3950
|
+
base: "base",
|
|
3951
|
+
default: "base",
|
|
3952
|
+
large: "large",
|
|
3953
|
+
medium: "medium",
|
|
3954
|
+
small: "small",
|
|
3955
|
+
xlarge: "extraLarge",
|
|
3956
|
+
xsmall: "extraSmall"
|
|
3957
|
+
};
|
|
3958
|
+
var styledTextRun = (text2, emphasized, size) => ({
|
|
3959
|
+
marks: [
|
|
3960
|
+
...emphasized ? [{ type: "bold" }] : [],
|
|
3961
|
+
{ attrs: { color: "base", fontSize: sizes[size] }, type: "textStyle" }
|
|
3962
|
+
],
|
|
3963
|
+
text: text2,
|
|
3964
|
+
type: "text"
|
|
3965
|
+
});
|
|
3966
|
+
|
|
3967
|
+
// src/transforms/postPurchase/convertCalloutBlock.ts
|
|
3968
|
+
var fields = ["superTitle", "title"];
|
|
3969
|
+
var Shell = CalloutBannerBlock.pick({ styles: true }).extend({
|
|
3970
|
+
settings: import_zod31.z.object({ superTitle: import_zod31.z.unknown().optional(), title: import_zod31.z.unknown().optional() })
|
|
3971
|
+
});
|
|
3972
|
+
var convertCalloutBlock = (raw, report) => {
|
|
3973
|
+
const omit = (detail) => {
|
|
3974
|
+
report?.({ detail, kind: "section" });
|
|
3975
|
+
return [];
|
|
3976
|
+
};
|
|
3977
|
+
const shell = Shell.safeParse(raw);
|
|
3978
|
+
if (!shell.success) return omit("Unreadable post-purchase callout");
|
|
3979
|
+
const values = fields.map((field) => ({
|
|
3980
|
+
field,
|
|
3981
|
+
result: CalloutBannerBlock.shape.settings.shape[field].safeParse(shell.data.settings[field])
|
|
3982
|
+
}));
|
|
3983
|
+
const styled2 = values.every(({ result }) => result.success && typeof result.data === "string");
|
|
3984
|
+
const styles2 = shell.data.styles;
|
|
3985
|
+
const horizontal = styled2 ? { center: "center", leading: "start", trailing: "end" }[styles2.textAlignment] : "center";
|
|
3986
|
+
const sections = values.flatMap(({ field, result }) => {
|
|
3987
|
+
if (!result.success) return omit(`Unreadable post-purchase callout field: ${field}`);
|
|
3988
|
+
const text2 = result.data;
|
|
3989
|
+
if (text2 === "") return [];
|
|
3990
|
+
const content = styled2 && typeof text2 === "string" ? {
|
|
3991
|
+
content: [
|
|
3992
|
+
{
|
|
3993
|
+
attrs: { textAlign: horizontal },
|
|
3994
|
+
content: [styledTextRun(text2, styles2[`${field}Emphasized`], styles2[`${field}Size`])]
|
|
3995
|
+
}
|
|
3996
|
+
]
|
|
3997
|
+
} : text2;
|
|
3998
|
+
const section = CABTextSection.safeParse({ content: { en: content } });
|
|
3999
|
+
return section.success ? [section.data] : omit(`Unreadable post-purchase callout field: ${field}`);
|
|
4000
|
+
});
|
|
4001
|
+
return sections.length ? [CABLayoutSection.parse({ alignment: { horizontal }, frame: "callout", sections })] : [];
|
|
4002
|
+
};
|
|
4003
|
+
|
|
4004
|
+
// src/transforms/postPurchase/convertPayButtonBlock.ts
|
|
4005
|
+
var convertPayButtonBlock = (raw, report) => {
|
|
4006
|
+
const omit = () => {
|
|
4007
|
+
report?.({ detail: "Unreadable post-purchase Pay block", kind: "section" });
|
|
4008
|
+
return [];
|
|
4009
|
+
};
|
|
4010
|
+
const parsed = PayButtonBlock.safeParse(raw);
|
|
4011
|
+
if (!parsed.success) return omit();
|
|
4012
|
+
const { settings, styles: styles2 } = parsed.data;
|
|
4013
|
+
const label2 = settings.label ? `${settings.label} \xB7 {{total}}` : "{{total}}";
|
|
4014
|
+
const text2 = CABTextSection.safeParse({ content: { en: label2 } });
|
|
4015
|
+
if (!text2.success) return omit();
|
|
4016
|
+
return [
|
|
4017
|
+
CABLayoutSection.parse({
|
|
4018
|
+
alignment: { horizontal: "center" },
|
|
4019
|
+
direction: "grid",
|
|
4020
|
+
grid: { columns: ["100%"] },
|
|
4021
|
+
sections: [
|
|
4022
|
+
CABButtonSection.parse({
|
|
4023
|
+
action: "addToOrder",
|
|
4024
|
+
sections: [text2.data]
|
|
4025
|
+
})
|
|
4026
|
+
],
|
|
4027
|
+
width: styles2.buttonWidth
|
|
4028
|
+
})
|
|
4029
|
+
];
|
|
4030
|
+
};
|
|
4031
|
+
|
|
4032
|
+
// src/transforms/postPurchase/convertSeparatorBlock.ts
|
|
4033
|
+
var convertSeparatorBlock = (raw, report) => {
|
|
4034
|
+
if (!SeparatorBlock.safeParse(raw).success) {
|
|
4035
|
+
report?.({ detail: "Unreadable post-purchase separator", kind: "section" });
|
|
4036
|
+
return [];
|
|
4037
|
+
}
|
|
4038
|
+
return [CABSeparatorSection.parse({})];
|
|
4039
|
+
};
|
|
4040
|
+
|
|
4041
|
+
// src/transforms/postPurchase/convertTextBlock.ts
|
|
4042
|
+
var import_zod32 = require("zod");
|
|
4043
|
+
var fields2 = ["superTitle", "title", "description"];
|
|
4044
|
+
var styles = {
|
|
4045
|
+
description: [{ attrs: { color: "base", fontSize: "small" }, type: "textStyle" }],
|
|
4046
|
+
superTitle: [{ attrs: { color: "subdued", fontSize: "small" }, type: "textStyle" }],
|
|
4047
|
+
title: [{ type: "bold" }, { attrs: { color: "base", fontSize: "large" }, type: "textStyle" }]
|
|
4048
|
+
};
|
|
4049
|
+
var settingsSchema = TextBlock.shape.settings;
|
|
4050
|
+
var Shell2 = import_zod32.z.object({
|
|
4051
|
+
settings: settingsSchema.pick({ horizontalAlignment: true }).extend({
|
|
4052
|
+
description: import_zod32.z.unknown().optional(),
|
|
4053
|
+
superTitle: import_zod32.z.unknown().optional(),
|
|
4054
|
+
title: import_zod32.z.unknown().optional()
|
|
4055
|
+
}),
|
|
4056
|
+
type: import_zod32.z.literal("text")
|
|
4057
|
+
});
|
|
4058
|
+
var convertTextBlock = (raw, report) => {
|
|
4059
|
+
const shell = Shell2.safeParse(raw);
|
|
4060
|
+
if (!shell.success) {
|
|
4061
|
+
report?.({ detail: "Unreadable post-purchase text block", kind: "section" });
|
|
4062
|
+
return [];
|
|
4063
|
+
}
|
|
4064
|
+
const values = fields2.map((field) => ({
|
|
4065
|
+
field,
|
|
4066
|
+
result: settingsSchema.shape[field].safeParse(shell.data.settings[field])
|
|
4067
|
+
}));
|
|
4068
|
+
const horizontal = { center: "center", leading: "start", trailing: "end" }[shell.data.settings.horizontalAlignment];
|
|
4069
|
+
const styled2 = values.every(
|
|
4070
|
+
({ result }) => result.success && (result.data === null || typeof result.data === "string")
|
|
4071
|
+
);
|
|
4072
|
+
const omit = (field) => {
|
|
4073
|
+
report?.({ detail: `Unreadable post-purchase text field: ${field}`, kind: "section" });
|
|
4074
|
+
return [];
|
|
4075
|
+
};
|
|
4076
|
+
const sections = values.flatMap(({ field, result }) => {
|
|
4077
|
+
if (!result.success) return omit(field);
|
|
4078
|
+
const text2 = result.data;
|
|
4079
|
+
if (text2 === null || text2 === "") return [];
|
|
4080
|
+
const content = styled2 ? { content: [{ attrs: { textAlign: horizontal }, content: [{ marks: styles[field], text: text2 }] }] } : text2;
|
|
4081
|
+
const section = CABTextSection.safeParse({ content: { en: content } });
|
|
4082
|
+
return section.success ? [section.data] : omit(field);
|
|
4083
|
+
});
|
|
4084
|
+
return sections.length ? [CABLayoutSection.parse({ alignment: { horizontal }, sections })] : [];
|
|
4085
|
+
};
|
|
4086
|
+
|
|
4087
|
+
// src/transforms/postPurchase/convertTimerBlock.ts
|
|
4088
|
+
var Presentation = TimerBlock.pick({ styles: true }).extend({
|
|
4089
|
+
settings: TimerBlock.shape.settings.pick({ title: true })
|
|
4090
|
+
});
|
|
4091
|
+
var withCountdown = (doc, run, textAlign) => {
|
|
4092
|
+
const paragraphs = doc.content.length ? doc.content : [TiptapParagraph.parse({ attrs: { textAlign } })];
|
|
4093
|
+
const last = paragraphs[paragraphs.length - 1];
|
|
4094
|
+
return { ...doc, content: [...paragraphs.slice(0, -1), { ...last, content: [...last.content, run] }] };
|
|
4095
|
+
};
|
|
4096
|
+
var convertTimerBlock = (raw, report) => {
|
|
4097
|
+
const omit = () => {
|
|
4098
|
+
report?.({ detail: "Unreadable post-purchase timer display", kind: "section" });
|
|
4099
|
+
return [];
|
|
4100
|
+
};
|
|
4101
|
+
const parsed = Presentation.safeParse(raw);
|
|
4102
|
+
if (!parsed.success) return omit();
|
|
4103
|
+
const { title } = parsed.data.settings;
|
|
4104
|
+
const styles2 = parsed.data.styles;
|
|
4105
|
+
const horizontal = { center: "center", leading: "start", trailing: "end" }[styles2.textAlignment];
|
|
4106
|
+
const countdown = styledTextRun(" {{timeRemaining}}", styles2.timerEmphasized, styles2.timerSize);
|
|
4107
|
+
const content = typeof title === "string" ? {
|
|
4108
|
+
content: [
|
|
4109
|
+
{
|
|
4110
|
+
attrs: { textAlign: horizontal },
|
|
4111
|
+
content: [styledTextRun(title, styles2.titleEmphasized, styles2.titleSize), countdown]
|
|
4112
|
+
}
|
|
4113
|
+
]
|
|
4114
|
+
} : withCountdown(title, countdown, horizontal);
|
|
4115
|
+
const text2 = CABTextSection.safeParse({ content: { en: content } });
|
|
4116
|
+
if (!text2.success) return omit();
|
|
4117
|
+
return [
|
|
4118
|
+
CABBannerSection.parse({
|
|
4119
|
+
color: styles2.timerBackgroundColor,
|
|
4120
|
+
dismissible: false,
|
|
4121
|
+
sections: [text2.data],
|
|
4122
|
+
width: styles2.timerWidth
|
|
4123
|
+
})
|
|
4124
|
+
];
|
|
4125
|
+
};
|
|
4126
|
+
|
|
4127
|
+
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
4128
|
+
var MessageWidget = import_zod33.z.object({
|
|
4129
|
+
blocks: import_zod33.z.array(import_zod33.z.unknown()).min(1),
|
|
4130
|
+
type: import_zod33.z.literal(WidgetType.shopify_post_purchase_extension)
|
|
4131
|
+
});
|
|
4132
|
+
var BlockType2 = import_zod33.z.object({ type: import_zod33.z.string() });
|
|
4133
|
+
var converters = {
|
|
4134
|
+
callout_banner: convertCalloutBlock,
|
|
4135
|
+
pay_button: convertPayButtonBlock,
|
|
4136
|
+
separator: convertSeparatorBlock,
|
|
4137
|
+
text: convertTextBlock,
|
|
4138
|
+
timer: convertTimerBlock
|
|
4139
|
+
};
|
|
4140
|
+
var convertMessagePreview = (id, settings, report) => {
|
|
4141
|
+
const parsed = MessageWidget.safeParse(settings);
|
|
4142
|
+
if (!parsed.success) throw new NotFoundError("Unsupported post-purchase message preview");
|
|
4143
|
+
return CABRootSection.parse({
|
|
4144
|
+
editorMode: "postPurchaseOffer",
|
|
4145
|
+
previewMode: true,
|
|
4146
|
+
sections: parsed.data.blocks.flatMap((block) => {
|
|
4147
|
+
const type = BlockType2.safeParse(block);
|
|
4148
|
+
const kind = type.success ? type.data.type : void 0;
|
|
4149
|
+
const convert2 = kind && Object.hasOwn(converters, kind) ? converters[kind] : void 0;
|
|
4150
|
+
if (convert2) return convert2(block, report);
|
|
4151
|
+
report?.({
|
|
4152
|
+
detail: kind ? `Unsupported post-purchase block type: ${kind}` : "Unreadable post-purchase block: missing type",
|
|
4153
|
+
kind: "section"
|
|
4154
|
+
});
|
|
4155
|
+
return [];
|
|
4156
|
+
}),
|
|
4157
|
+
sectionType: "layout",
|
|
4158
|
+
widgetId: id
|
|
4159
|
+
});
|
|
4160
|
+
};
|
|
4161
|
+
|
|
4162
|
+
// src/transforms/postPurchase/types.ts
|
|
4163
|
+
var isPostPurchaseV1 = (data) => !!data && typeof data === "object" && data.type === WidgetType.shopify_post_purchase_extension && Array.isArray(data.blocks);
|
|
4164
|
+
|
|
3748
4165
|
// src/transforms/presentmentThresholds.ts
|
|
3749
4166
|
var presentmentThresholds = (presentment) => {
|
|
3750
4167
|
if (!presentment?.enabled) return {};
|
|
@@ -4129,7 +4546,7 @@ var fetchUserConfig = async (input, ctx) => {
|
|
|
4129
4546
|
};
|
|
4130
4547
|
|
|
4131
4548
|
// src/utilities.ts
|
|
4132
|
-
var
|
|
4549
|
+
var import_uuid15 = require("uuid");
|
|
4133
4550
|
function serialize(obj) {
|
|
4134
4551
|
const serialized = [];
|
|
4135
4552
|
const add = (key, value) => {
|
|
@@ -4257,7 +4674,7 @@ var fetchDataSourceResults = async (input, ctx) => {
|
|
|
4257
4674
|
};
|
|
4258
4675
|
|
|
4259
4676
|
// src/server/adsEngine.ts
|
|
4260
|
-
var
|
|
4677
|
+
var import_zod34 = require("zod");
|
|
4261
4678
|
var SUPPLY_KEY = { production: "AQF5RKLR", staging: "Z56LQ7PS" };
|
|
4262
4679
|
var OFFER_LIMIT = 4;
|
|
4263
4680
|
var SUPPORTED_COUNTRIES = /* @__PURE__ */ new Set(["US", "CA"]);
|
|
@@ -4270,28 +4687,28 @@ var transactionItems = (input) => (input.transactionItems?.map(({ id, priceCents
|
|
|
4270
4687
|
title,
|
|
4271
4688
|
type
|
|
4272
4689
|
})) ?? input.cart.items.map(({ productId, quantity }) => ({ id: productId, quantity }))).slice(0, MAX_TRANSACTION_ITEMS);
|
|
4273
|
-
var AdsEngineOffer =
|
|
4690
|
+
var AdsEngineOffer = import_zod34.z.object({
|
|
4274
4691
|
/** Pill-style value prop ("Get $45 Cashback"). Carried through the parse; the card does not render it yet (REB-24429 — pill design pending). */
|
|
4275
|
-
callout:
|
|
4276
|
-
click_url:
|
|
4277
|
-
cta:
|
|
4692
|
+
callout: import_zod34.z.string().catch(""),
|
|
4693
|
+
click_url: import_zod34.z.string(),
|
|
4694
|
+
cta: import_zod34.z.string(),
|
|
4278
4695
|
/** `omitempty` on the ad server — a bid without it must not fail the parse and drop the whole batch (composeOffer falls back to 'No Thanks'). */
|
|
4279
|
-
decline_cta:
|
|
4280
|
-
decline_url:
|
|
4281
|
-
description:
|
|
4696
|
+
decline_cta: import_zod34.z.string().catch(""),
|
|
4697
|
+
decline_url: import_zod34.z.string(),
|
|
4698
|
+
description: import_zod34.z.string(),
|
|
4282
4699
|
/** Short legal disclosure (FDIC / auto-renewal / FTC-affiliation lines). Rendered subdued under the CTAs. */
|
|
4283
|
-
disclaimer:
|
|
4700
|
+
disclaimer: import_zod34.z.string().catch(""),
|
|
4284
4701
|
/** Long legal text behind the disclosure toggle in the composed card (REB-24429). */
|
|
4285
|
-
extended_disclaimer:
|
|
4286
|
-
headline:
|
|
4287
|
-
id:
|
|
4702
|
+
extended_disclaimer: import_zod34.z.string().catch(""),
|
|
4703
|
+
headline: import_zod34.z.string(),
|
|
4704
|
+
id: import_zod34.z.string(),
|
|
4288
4705
|
/** Advertiser-supplied image alt; the composed card falls back to the stripped headline when empty. */
|
|
4289
|
-
image_alt:
|
|
4290
|
-
image_url:
|
|
4291
|
-
view_url:
|
|
4706
|
+
image_alt: import_zod34.z.string().catch(""),
|
|
4707
|
+
image_url: import_zod34.z.string().optional(),
|
|
4708
|
+
view_url: import_zod34.z.string()
|
|
4292
4709
|
});
|
|
4293
|
-
var AdsEngineResponse =
|
|
4294
|
-
offers:
|
|
4710
|
+
var AdsEngineResponse = import_zod34.z.object({
|
|
4711
|
+
offers: import_zod34.z.array(import_zod34.z.unknown()).default([]).transform(
|
|
4295
4712
|
(offers) => offers.flatMap((offer) => {
|
|
4296
4713
|
const result = AdsEngineOffer.safeParse(offer);
|
|
4297
4714
|
return result.success ? [result.data] : [];
|
|
@@ -4303,8 +4720,8 @@ var AdsEngineResponse = import_zod28.z.object({
|
|
|
4303
4720
|
* offers-testing fixture on a test store forces it, REB-24467). Both optional: an older engine or a
|
|
4304
4721
|
* non-JSON body must not fail the parse and drop the offers.
|
|
4305
4722
|
*/
|
|
4306
|
-
request_id:
|
|
4307
|
-
testing:
|
|
4723
|
+
request_id: import_zod34.z.string().optional().catch(void 0),
|
|
4724
|
+
testing: import_zod34.z.boolean().optional().catch(void 0)
|
|
4308
4725
|
});
|
|
4309
4726
|
var adsHost = (host) => `offers.${host}`;
|
|
4310
4727
|
var isTestingRequest = (input, isProduction) => !isProduction || !!input.testing || input.customerEmail?.toLowerCase() === TEST_CUSTOMER_EMAIL;
|
|
@@ -4577,7 +4994,7 @@ var fetchMonetizeOffers = async (input, ctx, prefetched) => {
|
|
|
4577
4994
|
};
|
|
4578
4995
|
|
|
4579
4996
|
// src/server/salvageSections.ts
|
|
4580
|
-
var
|
|
4997
|
+
var import_uuid16 = require("uuid");
|
|
4581
4998
|
var STUB_SECTION_TYPE = "unknown";
|
|
4582
4999
|
var knownSectionTypes = new Set(sectionTypes);
|
|
4583
5000
|
var hasSectionsArray = (raw) => typeof raw === "object" && raw !== null && Array.isArray(raw.sections);
|
|
@@ -4590,7 +5007,7 @@ var stubSection = (raw, report) => {
|
|
|
4590
5007
|
kind: "section"
|
|
4591
5008
|
});
|
|
4592
5009
|
return {
|
|
4593
|
-
sectionId: typeof rawId === "string" && rawId ? rawId : (0,
|
|
5010
|
+
sectionId: typeof rawId === "string" && rawId ? rawId : (0, import_uuid16.v7)(),
|
|
4594
5011
|
sectionType: typeof original === "string" && !knownSectionTypes.has(original) ? original : STUB_SECTION_TYPE
|
|
4595
5012
|
};
|
|
4596
5013
|
};
|
|
@@ -4619,6 +5036,7 @@ var dispatchWidgetTransform = (id, normalized, report) => {
|
|
|
4619
5036
|
if (isLineItemEditorV1(normalized)) return convertLineItemEditorToV2({ id, settings: normalized });
|
|
4620
5037
|
if (isMonetizeV1(normalized)) return convertMonetizeToV2({ id, settings: normalized });
|
|
4621
5038
|
if (isPlaceholderV1(normalized)) return convertPlaceholderToV2({ id, settings: normalized });
|
|
5039
|
+
if (isPostPurchaseV1(normalized)) return convertMessagePreview(id, normalized, report);
|
|
4622
5040
|
if (isOfferV1(normalized)) return convertOfferToV2({ id, name: normalized.name, settings: normalized });
|
|
4623
5041
|
return normalized;
|
|
4624
5042
|
};
|
|
@@ -4733,13 +5151,13 @@ var convertWidgetSettings = async (input, ctx) => {
|
|
|
4733
5151
|
};
|
|
4734
5152
|
|
|
4735
5153
|
// src/server/giftWidgets.ts
|
|
4736
|
-
var
|
|
4737
|
-
var SettingsNumber =
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
]).pipe(
|
|
4741
|
-
var SgwpMilestoneSchema =
|
|
4742
|
-
selectable_product_quantity: SettingsNumber.pipe(
|
|
5154
|
+
var import_zod35 = require("zod");
|
|
5155
|
+
var SettingsNumber = import_zod35.z.union([
|
|
5156
|
+
import_zod35.z.number(),
|
|
5157
|
+
import_zod35.z.string().trim().regex(/^-?\d+(\.\d+)?$/)
|
|
5158
|
+
]).pipe(import_zod35.z.coerce.number());
|
|
5159
|
+
var SgwpMilestoneSchema = import_zod35.z.object({
|
|
5160
|
+
selectable_product_quantity: SettingsNumber.pipe(import_zod35.z.number().int().nonnegative()),
|
|
4743
5161
|
unlock_price: SettingsNumber
|
|
4744
5162
|
});
|
|
4745
5163
|
var fetchGiftWidgetSettings = async (widgetId, shop, ctx) => unwrapData(await ctx.fetchUpstream("/api/v1/widgets/settings", { id: String(widgetId), shop }, { host: ctx.host }));
|
|
@@ -4750,7 +5168,7 @@ var readDataSourcePath = (settings) => {
|
|
|
4750
5168
|
var readMilestones = (settings, report) => {
|
|
4751
5169
|
const raw = settings && typeof settings === "object" ? settings.milestones : void 0;
|
|
4752
5170
|
if (raw == null) return [];
|
|
4753
|
-
const parsed =
|
|
5171
|
+
const parsed = import_zod35.z.array(SgwpMilestoneSchema).safeParse(raw);
|
|
4754
5172
|
if (parsed.success) return parsed.data;
|
|
4755
5173
|
report?.({
|
|
4756
5174
|
detail: [
|
|
@@ -4999,7 +5417,7 @@ var postAnalyticsEvents = async (input, ctx) => {
|
|
|
4999
5417
|
};
|
|
5000
5418
|
|
|
5001
5419
|
// src/server/requestSchemas.ts
|
|
5002
|
-
var
|
|
5420
|
+
var import_zod36 = require("zod");
|
|
5003
5421
|
var REQUEST_BOUNDS = {
|
|
5004
5422
|
/** Cart-level attributes per cart. */
|
|
5005
5423
|
CART_ATTRIBUTES_MAX: 100,
|
|
@@ -5030,42 +5448,42 @@ var REQUEST_BOUNDS = {
|
|
|
5030
5448
|
/** Rich ads transaction lines — the engine's ads contract. */
|
|
5031
5449
|
TRANSACTION_ITEMS_MAX: 50
|
|
5032
5450
|
};
|
|
5033
|
-
var KeyValue =
|
|
5034
|
-
key:
|
|
5035
|
-
value:
|
|
5451
|
+
var KeyValue = import_zod36.z.object({
|
|
5452
|
+
key: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
5453
|
+
value: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_VALUE_MAX).optional()
|
|
5036
5454
|
});
|
|
5037
|
-
var CartLineInputSchema =
|
|
5038
|
-
productId:
|
|
5039
|
-
properties:
|
|
5040
|
-
quantity:
|
|
5041
|
-
subscriptionId:
|
|
5042
|
-
variantId:
|
|
5455
|
+
var CartLineInputSchema = import_zod36.z.object({
|
|
5456
|
+
productId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5457
|
+
properties: import_zod36.z.array(KeyValue).max(REQUEST_BOUNDS.LINE_PROPERTIES_MAX).optional(),
|
|
5458
|
+
quantity: import_zod36.z.number(),
|
|
5459
|
+
subscriptionId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5460
|
+
variantId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX)
|
|
5043
5461
|
});
|
|
5044
|
-
var CartInputSchema =
|
|
5045
|
-
attributes:
|
|
5462
|
+
var CartInputSchema = import_zod36.z.object({
|
|
5463
|
+
attributes: import_zod36.z.array(KeyValue).max(REQUEST_BOUNDS.CART_ATTRIBUTES_MAX).optional(),
|
|
5046
5464
|
/**
|
|
5047
5465
|
* Presentment-per-shop-currency FX rate (buyer price ÷ shop price, e.g. `1.35` for a USD shop
|
|
5048
5466
|
* selling in CAD). Money rule thresholds are authored in SHOP currency, so the engine subtotal is
|
|
5049
5467
|
* divided by this before evaluation. Omit (or send 1) when the cart is already in the shop's currency.
|
|
5050
5468
|
*/
|
|
5051
|
-
currencyRate:
|
|
5469
|
+
currencyRate: import_zod36.z.number().optional(),
|
|
5052
5470
|
/** Applied discount codes; the engine evaluates `discount_code` rules against them (sent as `[{code}]`). */
|
|
5053
|
-
discountCodes:
|
|
5471
|
+
discountCodes: import_zod36.z.array(import_zod36.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX)).max(REQUEST_BOUNDS.DISCOUNT_CODES_MAX).optional(),
|
|
5054
5472
|
/** Presentment cents of cart-level discount allocations, subtracted from `subtotal` for the engine. */
|
|
5055
|
-
discountTotal:
|
|
5056
|
-
items:
|
|
5473
|
+
discountTotal: import_zod36.z.number().optional(),
|
|
5474
|
+
items: import_zod36.z.array(CartLineInputSchema).max(REQUEST_BOUNDS.CART_ITEMS_MAX),
|
|
5057
5475
|
/** Presentment subtotal in cents. */
|
|
5058
|
-
subtotal:
|
|
5476
|
+
subtotal: import_zod36.z.number()
|
|
5059
5477
|
});
|
|
5060
|
-
var UserConfigInputSchema =
|
|
5061
|
-
var DataSourceInputSchema =
|
|
5478
|
+
var UserConfigInputSchema = import_zod36.z.object({ shop: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX) });
|
|
5479
|
+
var DataSourceInputSchema = import_zod36.z.object({
|
|
5062
5480
|
cart: CartInputSchema,
|
|
5063
5481
|
/**
|
|
5064
5482
|
* Numeric Shopify company-location id when the buyer is a B2B session (`buyerIdentity.purchasingCompany`).
|
|
5065
5483
|
* Present ⇒ the orchestrator filters results by the location's catalog via admin-api (REB-23713); the
|
|
5066
5484
|
* client's country-context market check is bypassed for B2B (it false-negatives B2B-catalog products).
|
|
5067
5485
|
*/
|
|
5068
|
-
companyLocationId:
|
|
5486
|
+
companyLocationId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5069
5487
|
/**
|
|
5070
5488
|
* Buyer's market country (ISO 3166-1 alpha-2) — forwarded to the engine as the `country_code` PARAM
|
|
5071
5489
|
* when the shop's markets toggle is on (REB-21688; the sink was the `X-Country-Code` header under
|
|
@@ -5074,16 +5492,16 @@ var DataSourceInputSchema = import_zod30.z.object({
|
|
|
5074
5492
|
* uppercase (the wire value is forwarded verbatim as the param) so a case-sensitive engine lookup
|
|
5075
5493
|
* can't silently miss a lowercase code — `adsEngine.ts` uppercases for the same reason.
|
|
5076
5494
|
*/
|
|
5077
|
-
country:
|
|
5078
|
-
customerId:
|
|
5079
|
-
dataSourcePath:
|
|
5495
|
+
country: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z]{2}$/, "must be an ISO 3166-1 alpha-2 country code (e.g. CA)").transform((value) => value.toUpperCase()).optional(),
|
|
5496
|
+
customerId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5497
|
+
dataSourcePath: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
5080
5498
|
/**
|
|
5081
5499
|
* Engine `filter_inputs` override: `'no'` keeps in-cart (input) products in the results/rule
|
|
5082
5500
|
* outputs — gift validation sends it so a gift's own product can appear in its answer. Omitted = the
|
|
5083
5501
|
* engine's default filtering.
|
|
5084
5502
|
*/
|
|
5085
|
-
filterInputs:
|
|
5086
|
-
integrations:
|
|
5503
|
+
filterInputs: import_zod36.z.enum(["no", "yes"]).optional(),
|
|
5504
|
+
integrations: import_zod36.z.record(import_zod36.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), import_zod36.z.boolean()).refine((record) => Object.keys(record).length <= REQUEST_BOUNDS.INTEGRATION_KEYS_MAX, {
|
|
5087
5505
|
message: `Too many integration keys (max ${REQUEST_BOUNDS.INTEGRATION_KEYS_MAX})`
|
|
5088
5506
|
}).optional(),
|
|
5089
5507
|
/**
|
|
@@ -5096,31 +5514,31 @@ var DataSourceInputSchema = import_zod30.z.object({
|
|
|
5096
5514
|
* request header) fails the regex. Callers should send the buyer's resolved locale (e.g. Shopify
|
|
5097
5515
|
* checkout's `localization.language.isoCode`), not the request header verbatim.
|
|
5098
5516
|
*/
|
|
5099
|
-
language:
|
|
5100
|
-
limit:
|
|
5101
|
-
productType:
|
|
5102
|
-
shop:
|
|
5103
|
-
visitorId:
|
|
5517
|
+
language: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z0-9-]+$/, "must be a single BCP-47 tag (e.g. fr-CA), not a q-value list").optional(),
|
|
5518
|
+
limit: import_zod36.z.number().max(REQUEST_BOUNDS.LIMIT_MAX),
|
|
5519
|
+
productType: import_zod36.z.enum(["both", "one-time", "subscription"]).optional(),
|
|
5520
|
+
shop: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5521
|
+
visitorId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5104
5522
|
});
|
|
5105
|
-
var GiftInputSchema =
|
|
5106
|
-
cost:
|
|
5107
|
-
discounted:
|
|
5523
|
+
var GiftInputSchema = import_zod36.z.object({
|
|
5524
|
+
cost: import_zod36.z.number(),
|
|
5525
|
+
discounted: import_zod36.z.boolean(),
|
|
5108
5526
|
/**
|
|
5109
5527
|
* Which gift attribution the line carries (REB-24363). Defaults to `gwp` because a client that predates
|
|
5110
5528
|
* the field only ever sent GWP lines — without the default an older extension's request would 422.
|
|
5111
5529
|
*/
|
|
5112
|
-
kind:
|
|
5113
|
-
lineId:
|
|
5114
|
-
productId:
|
|
5530
|
+
kind: import_zod36.z.enum(GIFT_KINDS).default("gwp"),
|
|
5531
|
+
lineId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5532
|
+
productId: import_zod36.z.number(),
|
|
5115
5533
|
/**
|
|
5116
5534
|
* The line's unit count (REB-24363) — the selectable-GWP verdict trims surplus units against milestone
|
|
5117
5535
|
* capacity. The second deliberate default: a client predating the field sent only GWP lines, whose
|
|
5118
5536
|
* verdict is whole-line, so a missing quantity reads as one unit rather than 422ing the older request.
|
|
5119
5537
|
*/
|
|
5120
|
-
quantity:
|
|
5121
|
-
widgetId:
|
|
5538
|
+
quantity: import_zod36.z.number().int().min(1).default(1),
|
|
5539
|
+
widgetId: import_zod36.z.number()
|
|
5122
5540
|
});
|
|
5123
|
-
var GiftValidationInputSchema =
|
|
5541
|
+
var GiftValidationInputSchema = import_zod36.z.object({
|
|
5124
5542
|
cart: CartInputSchema,
|
|
5125
5543
|
/**
|
|
5126
5544
|
* Buyer's market country — threaded into the per-widget data-source evaluations, which forward it to
|
|
@@ -5129,25 +5547,25 @@ var GiftValidationInputSchema = import_zod30.z.object({
|
|
|
5129
5547
|
* turns markets off); regex-bound and uppercase-normalized for the same reasons as
|
|
5130
5548
|
* `DataSourceInputSchema`'s `country`.
|
|
5131
5549
|
*/
|
|
5132
|
-
country:
|
|
5133
|
-
customerId:
|
|
5134
|
-
gifts:
|
|
5550
|
+
country: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z]{2}$/, "must be an ISO 3166-1 alpha-2 country code (e.g. CA)").transform((value) => value.toUpperCase()).optional(),
|
|
5551
|
+
customerId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5552
|
+
gifts: import_zod36.z.array(GiftInputSchema).max(REQUEST_BOUNDS.GIFTS_MAX),
|
|
5135
5553
|
/**
|
|
5136
5554
|
* Buyer's checkout language — threaded into the per-widget data-source evaluations, which normalize
|
|
5137
5555
|
* and forward it as the engine `locale` param under the same markets-toggle gate (REB-21688). MUST be
|
|
5138
5556
|
* a single BCP-47 tag, for the same reason as `DataSourceInputSchema`'s `language` above.
|
|
5139
5557
|
*/
|
|
5140
|
-
language:
|
|
5141
|
-
shop:
|
|
5142
|
-
visitorId:
|
|
5558
|
+
language: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z0-9-]+$/, "must be a single BCP-47 tag (e.g. fr-CA), not a q-value list").optional(),
|
|
5559
|
+
shop: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5560
|
+
visitorId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5143
5561
|
});
|
|
5144
|
-
var GiftAdjustmentSchema =
|
|
5145
|
-
lineId:
|
|
5146
|
-
quantity:
|
|
5562
|
+
var GiftAdjustmentSchema = import_zod36.z.object({
|
|
5563
|
+
lineId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5564
|
+
quantity: import_zod36.z.number().int().nonnegative()
|
|
5147
5565
|
});
|
|
5148
|
-
var GiftValidationResponseSchema =
|
|
5149
|
-
adjust:
|
|
5150
|
-
remove:
|
|
5566
|
+
var GiftValidationResponseSchema = import_zod36.z.object({
|
|
5567
|
+
adjust: import_zod36.z.array(GiftAdjustmentSchema).max(REQUEST_BOUNDS.GIFTS_MAX).default([]),
|
|
5568
|
+
remove: import_zod36.z.array(import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX)).max(REQUEST_BOUNDS.GIFTS_MAX).refine(
|
|
5151
5569
|
(remove) => new Set(remove).size === remove.length,
|
|
5152
5570
|
"a line id may appear at most once in `remove`"
|
|
5153
5571
|
)
|
|
@@ -5158,47 +5576,47 @@ var GiftValidationResponseSchema = import_zod30.z.object({
|
|
|
5158
5576
|
({ adjust }) => new Set(adjust.map(({ lineId }) => lineId)).size === adjust.length,
|
|
5159
5577
|
"a line id may appear at most once in `adjust`"
|
|
5160
5578
|
);
|
|
5161
|
-
var MonetizeTransactionItemSchema =
|
|
5162
|
-
id:
|
|
5163
|
-
priceCents:
|
|
5164
|
-
quantity:
|
|
5165
|
-
title:
|
|
5166
|
-
type:
|
|
5579
|
+
var MonetizeTransactionItemSchema = import_zod36.z.object({
|
|
5580
|
+
id: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5581
|
+
priceCents: import_zod36.z.number(),
|
|
5582
|
+
quantity: import_zod36.z.number(),
|
|
5583
|
+
title: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX),
|
|
5584
|
+
type: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX)
|
|
5167
5585
|
});
|
|
5168
|
-
var MonetizeInputSchema =
|
|
5586
|
+
var MonetizeInputSchema = import_zod36.z.object({
|
|
5169
5587
|
cart: CartInputSchema,
|
|
5170
5588
|
/** Client-minted render-beacon correlation id; forwarded to the ads engine as `client_request_id`. */
|
|
5171
|
-
clientRequestId:
|
|
5172
|
-
country:
|
|
5173
|
-
currency:
|
|
5589
|
+
clientRequestId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5590
|
+
country: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5591
|
+
currency: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5174
5592
|
/** Ads-targeting identity/geo/locale fields (React parity); folded into the engine query verbatim. */
|
|
5175
|
-
customerEmail:
|
|
5176
|
-
customerFirstName:
|
|
5177
|
-
customerId:
|
|
5178
|
-
customerLastName:
|
|
5179
|
-
language:
|
|
5593
|
+
customerEmail: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5594
|
+
customerFirstName: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5595
|
+
customerId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5596
|
+
customerLastName: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5597
|
+
language: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5180
5598
|
/** Buyer-facing order name (e.g. `#1001`) for the server-composed "Order … Confirmed" chrome line. */
|
|
5181
|
-
orderName:
|
|
5599
|
+
orderName: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5182
5600
|
/** Ads surface label, forwarded verbatim; `customer_account` is measured/floored as its own surface (the account-area order list). */
|
|
5183
|
-
placement:
|
|
5601
|
+
placement: import_zod36.z.enum(["customer_account", "order_status", "thank_you_page"]),
|
|
5184
5602
|
/** Privacy Policy footer href — the Monetize widget's `privacy_policy_url` setting (React parity). */
|
|
5185
|
-
privacyPolicyUrl:
|
|
5603
|
+
privacyPolicyUrl: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_URL_MAX).optional(),
|
|
5186
5604
|
/** 30-min rolling session id (React parity); used for the ads `session_id`, else the visitor id. */
|
|
5187
|
-
sessionId:
|
|
5188
|
-
shop:
|
|
5605
|
+
sessionId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5606
|
+
shop: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5189
5607
|
/** Editor/QA indicator; OR-ed into the ads-engine `testing` flag so it stays out of billing/reporting. */
|
|
5190
|
-
testing:
|
|
5191
|
-
timezone:
|
|
5608
|
+
testing: import_zod36.z.boolean().optional(),
|
|
5609
|
+
timezone: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5192
5610
|
/** Decorated (numeric) order id → the ads `transaction_id`. */
|
|
5193
|
-
transactionId:
|
|
5611
|
+
transactionId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5194
5612
|
/** Rich per-line ads items; capped at the engine's ads contract. Preferred over `cart.items`. */
|
|
5195
|
-
transactionItems:
|
|
5613
|
+
transactionItems: import_zod36.z.array(MonetizeTransactionItemSchema).max(REQUEST_BOUNDS.TRANSACTION_ITEMS_MAX).optional(),
|
|
5196
5614
|
/** Order total in presentment cents (React prefers total over subtotal); else `cart.subtotal`. */
|
|
5197
|
-
transactionTotal:
|
|
5198
|
-
visitorId:
|
|
5199
|
-
zipCode:
|
|
5615
|
+
transactionTotal: import_zod36.z.number().optional(),
|
|
5616
|
+
visitorId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5617
|
+
zipCode: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5200
5618
|
});
|
|
5201
|
-
var WidgetSettingsInputSchema =
|
|
5619
|
+
var WidgetSettingsInputSchema = import_zod36.z.object({
|
|
5202
5620
|
/**
|
|
5203
5621
|
* Same domain as `CabShopConfig.cacheKey`, for the same reason: this side WINS the orchestrator's
|
|
5204
5622
|
* `input.cacheKey ?? config.shop.cacheKey` (and an explicit value skips the config read entirely), so
|
|
@@ -5206,9 +5624,9 @@ var WidgetSettingsInputSchema = import_zod30.z.object({
|
|
|
5206
5624
|
* and pin the edge copy permanently stale. `.catch(undefined)` because a bogus buster should degrade
|
|
5207
5625
|
* the read to un-busted, never 400 a widget render.
|
|
5208
5626
|
*/
|
|
5209
|
-
cacheKey:
|
|
5210
|
-
id:
|
|
5211
|
-
key:
|
|
5627
|
+
cacheKey: import_zod36.z.number().int().positive().optional().catch(void 0),
|
|
5628
|
+
id: import_zod36.z.number(),
|
|
5629
|
+
key: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5212
5630
|
/**
|
|
5213
5631
|
* Monetize context for inline hydration: when present AND the widget converts to a Monetize marker,
|
|
5214
5632
|
* the server fetches/composes the offer cards inside this same request (no second `/cab/monetize`
|
|
@@ -5217,34 +5635,34 @@ var WidgetSettingsInputSchema = import_zod30.z.object({
|
|
|
5217
5635
|
* `privacyPolicyUrl` comes from the widget settings server-side (more authoritative than a relay).
|
|
5218
5636
|
*/
|
|
5219
5637
|
monetize: MonetizeInputSchema.omit({ privacyPolicyUrl: true, shop: true }).optional(),
|
|
5220
|
-
shop:
|
|
5638
|
+
shop: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5221
5639
|
/** Stable per-buyer id; when present, enables sticky server-side A/B variant selection. */
|
|
5222
|
-
visitorId:
|
|
5640
|
+
visitorId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5223
5641
|
});
|
|
5224
|
-
var AnalyticsEventInputSchema =
|
|
5225
|
-
name:
|
|
5226
|
-
properties:
|
|
5227
|
-
sentAt:
|
|
5642
|
+
var AnalyticsEventInputSchema = import_zod36.z.object({
|
|
5643
|
+
name: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
5644
|
+
properties: import_zod36.z.record(import_zod36.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), import_zod36.z.unknown()).optional(),
|
|
5645
|
+
sentAt: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5228
5646
|
});
|
|
5229
|
-
var AnalyticsSegmentsInputSchema =
|
|
5230
|
-
device:
|
|
5231
|
-
source:
|
|
5232
|
-
visitor:
|
|
5647
|
+
var AnalyticsSegmentsInputSchema = import_zod36.z.object({
|
|
5648
|
+
device: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
5649
|
+
source: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
5650
|
+
visitor: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0)
|
|
5233
5651
|
});
|
|
5234
|
-
var AnalyticsInputSchema =
|
|
5652
|
+
var AnalyticsInputSchema = import_zod36.z.object({
|
|
5235
5653
|
/** Rebuy cart token (the `r_cart_token` cart attribute), when available — primary aggregation key. */
|
|
5236
|
-
cartToken:
|
|
5654
|
+
cartToken: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5237
5655
|
/** Shopify checkout token, when available — drives cart/checkout aggregation downstream. */
|
|
5238
|
-
checkoutToken:
|
|
5239
|
-
events:
|
|
5656
|
+
checkoutToken: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5657
|
+
events: import_zod36.z.array(AnalyticsEventInputSchema).max(REQUEST_BOUNDS.EVENTS_MAX),
|
|
5240
5658
|
/**
|
|
5241
5659
|
* Request-scoped like the tokens: one visitor's segments apply to every event in the batch. The container
|
|
5242
5660
|
* degrades too (`null` is a realistic wire artifact of `attributes ? {…} : null`), so the degrade rule is
|
|
5243
5661
|
* total: nothing about `segments` can cost the envelope.
|
|
5244
5662
|
*/
|
|
5245
5663
|
segments: AnalyticsSegmentsInputSchema.optional().catch(void 0),
|
|
5246
|
-
shop:
|
|
5247
|
-
visitorId:
|
|
5664
|
+
shop: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5665
|
+
visitorId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5248
5666
|
/** The widget id (smartBlockId) the events belong to. */
|
|
5249
|
-
widgetId:
|
|
5667
|
+
widgetId: import_zod36.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5250
5668
|
});
|