@rebuy/rebuy 3.27.0 → 3.28.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/index.cjs +376 -347
- package/dist/index.mjs +375 -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 +97 -68
- package/dist/schema/checkout-and-beyond/index.mjs +97 -68
- package/dist/schema/widget-data.cjs +160 -135
- package/dist/schema/widget-data.mjs +160 -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 +601 -188
- package/dist/server/index.mjs +601 -188
- package/dist/transforms/index.cjs +481 -59
- package/dist/transforms/index.d.ts +2 -0
- package/dist/transforms/index.mjs +481 -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 +8 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/schema/widgets/checkout-and-beyond/banner.ts
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as z21 } from "zod";
|
|
3
3
|
|
|
4
4
|
// src/schema/widgets/checkout-and-beyond/common.ts
|
|
5
5
|
var freezeEnum = (values) => Object.freeze(Object.fromEntries(values.map((v) => [v, v])));
|
|
@@ -108,6 +108,8 @@ var languageKeys = [
|
|
|
108
108
|
"zh"
|
|
109
109
|
];
|
|
110
110
|
var LanguageKey = freezeEnum(languageKeys);
|
|
111
|
+
var layoutFrames = ["callout", "offer-content"];
|
|
112
|
+
var LayoutFrame = freezeEnum(layoutFrames);
|
|
111
113
|
var mutatorEvents = ["item_added", "quantity_changed", "variant_selected"];
|
|
112
114
|
var MutatorEvent = freezeEnum(mutatorEvents);
|
|
113
115
|
var objectFits = ["cover", "contain"];
|
|
@@ -152,6 +154,7 @@ var sectionTypes = [
|
|
|
152
154
|
"progressBar",
|
|
153
155
|
"quantity",
|
|
154
156
|
"reviews",
|
|
157
|
+
"separator",
|
|
155
158
|
"text",
|
|
156
159
|
"variants"
|
|
157
160
|
];
|
|
@@ -205,11 +208,11 @@ var widgetTypes = [
|
|
|
205
208
|
var WidgetType = freezeEnum(widgetTypes);
|
|
206
209
|
|
|
207
210
|
// src/schema/widgets/checkout-and-beyond/layout.ts
|
|
208
|
-
import { v7 as
|
|
209
|
-
import { z as
|
|
211
|
+
import { v7 as uuidv713 } from "uuid";
|
|
212
|
+
import { z as z20 } from "zod";
|
|
210
213
|
|
|
211
214
|
// src/schema/widgets/checkout-and-beyond/shared.ts
|
|
212
|
-
import { z as
|
|
215
|
+
import { z as z19 } from "zod";
|
|
213
216
|
|
|
214
217
|
// src/schema/widgets/checkout-and-beyond/button.ts
|
|
215
218
|
import { v7 as uuidv73 } from "uuid";
|
|
@@ -1358,35 +1361,46 @@ var CABReviewsSection = z16.object({
|
|
|
1358
1361
|
name: z16.string().optional(),
|
|
1359
1362
|
sectionId: z16.uuid().default(() => uuidv710()),
|
|
1360
1363
|
sectionType: z16.literal(SectionType.reviews).default(SectionType.reviews),
|
|
1361
|
-
size: z16.enum(reviewsSizes).default(ReviewsSize.default)
|
|
1364
|
+
size: z16.enum(reviewsSizes).default(ReviewsSize.default),
|
|
1365
|
+
strokeColor: z16.string().default("#fadb14"),
|
|
1366
|
+
strokeWidth: z16.number().nonnegative().default(0)
|
|
1362
1367
|
});
|
|
1363
1368
|
|
|
1364
|
-
// src/schema/widgets/checkout-and-beyond/
|
|
1365
|
-
import { slice } from "es-toolkit/compat";
|
|
1369
|
+
// src/schema/widgets/checkout-and-beyond/separator.ts
|
|
1366
1370
|
import { v7 as uuidv711 } from "uuid";
|
|
1367
1371
|
import { z as z17 } from "zod";
|
|
1368
|
-
var
|
|
1372
|
+
var CABSeparatorSection = z17.object({
|
|
1369
1373
|
...CABVariableFields,
|
|
1370
|
-
hideOutOfStockVariants: z17.boolean().default(false),
|
|
1371
|
-
name: z17.string().optional(),
|
|
1372
1374
|
sectionId: z17.uuid().default(() => uuidv711()),
|
|
1373
|
-
sectionType: z17.literal(SectionType.
|
|
1374
|
-
|
|
1375
|
-
|
|
1375
|
+
sectionType: z17.literal(SectionType.separator).default(SectionType.separator)
|
|
1376
|
+
});
|
|
1377
|
+
|
|
1378
|
+
// src/schema/widgets/checkout-and-beyond/variants.ts
|
|
1379
|
+
import { slice } from "es-toolkit/compat";
|
|
1380
|
+
import { v7 as uuidv712 } from "uuid";
|
|
1381
|
+
import { z as z18 } from "zod";
|
|
1382
|
+
var CABVariantsSection = z18.object({
|
|
1383
|
+
...CABVariableFields,
|
|
1384
|
+
hideOutOfStockVariants: z18.boolean().default(false),
|
|
1385
|
+
name: z18.string().optional(),
|
|
1386
|
+
sectionId: z18.uuid().default(() => uuidv712()),
|
|
1387
|
+
sectionType: z18.literal(SectionType.variants).default(SectionType.variants),
|
|
1388
|
+
selector: z18.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu),
|
|
1389
|
+
variantMode: z18.enum(variantModes).default(VariantMode.multiple)
|
|
1376
1390
|
});
|
|
1377
1391
|
|
|
1378
1392
|
// src/schema/widgets/checkout-and-beyond/shared.ts
|
|
1379
|
-
var CABBorder =
|
|
1380
|
-
radius:
|
|
1381
|
-
style:
|
|
1382
|
-
width:
|
|
1393
|
+
var CABBorder = z19.object({
|
|
1394
|
+
radius: z19.enum(borderRadii).default(BorderRadius.base),
|
|
1395
|
+
style: z19.enum(borderStyles).default(BorderStyle.none),
|
|
1396
|
+
width: z19.enum(borderWidths).default(BorderWidth.base)
|
|
1383
1397
|
}).default({
|
|
1384
1398
|
radius: BorderRadius.base,
|
|
1385
1399
|
style: BorderStyle.none,
|
|
1386
1400
|
width: BorderWidth.base
|
|
1387
1401
|
});
|
|
1388
|
-
var CABSection =
|
|
1389
|
-
() =>
|
|
1402
|
+
var CABSection = z19.lazy(
|
|
1403
|
+
() => z19.discriminatedUnion("sectionType", [
|
|
1390
1404
|
CABBannerSection,
|
|
1391
1405
|
CABButtonSection,
|
|
1392
1406
|
CABCarouselSection,
|
|
@@ -1402,46 +1416,57 @@ var CABSection = z18.lazy(
|
|
|
1402
1416
|
CABProgressBarSection,
|
|
1403
1417
|
CABQuantitySection,
|
|
1404
1418
|
CABReviewsSection,
|
|
1419
|
+
CABSeparatorSection,
|
|
1405
1420
|
CABTextSection,
|
|
1406
1421
|
CABVariantsSection
|
|
1407
1422
|
])
|
|
1408
1423
|
);
|
|
1409
1424
|
|
|
1410
1425
|
// src/schema/widgets/checkout-and-beyond/layout.ts
|
|
1411
|
-
var GridItem =
|
|
1412
|
-
var
|
|
1426
|
+
var GridItem = z20.union([z20.literal("auto"), z20.literal("fill"), z20.string().regex(/^\d+%$/), z20.number()]);
|
|
1427
|
+
var CABLayoutWrapping = z20.object({
|
|
1428
|
+
breakAt: z20.number().positive(),
|
|
1429
|
+
maxPerLine: z20.number().int().positive()
|
|
1430
|
+
});
|
|
1431
|
+
var CABLayoutSection = z20.object({
|
|
1413
1432
|
...CABVariableFields,
|
|
1414
|
-
alignment:
|
|
1415
|
-
horizontal:
|
|
1416
|
-
vertical:
|
|
1433
|
+
alignment: z20.object({
|
|
1434
|
+
horizontal: z20.enum(horizontalAlignments).default(HorizontalAlignment.start),
|
|
1435
|
+
vertical: z20.enum(verticalAlignments).default(VerticalAlignment.top)
|
|
1417
1436
|
}).default({
|
|
1418
1437
|
horizontal: HorizontalAlignment.start,
|
|
1419
1438
|
vertical: VerticalAlignment.top
|
|
1420
1439
|
}),
|
|
1421
|
-
border:
|
|
1422
|
-
buttonField:
|
|
1423
|
-
direction:
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1440
|
+
border: z20.lazy(() => CABBorder),
|
|
1441
|
+
buttonField: z20.enum(buttonFields).optional(),
|
|
1442
|
+
direction: z20.enum(directions).default(Direction.rows),
|
|
1443
|
+
/**
|
|
1444
|
+
* Platform chrome around the section, not a layout behavior: `callout` is a subdued box with block borders
|
|
1445
|
+
* (the legacy post-purchase callout banner), `offer-content` the post-purchase offer's own content card.
|
|
1446
|
+
*/
|
|
1447
|
+
frame: z20.enum(layoutFrames).optional(),
|
|
1448
|
+
grid: z20.object({
|
|
1449
|
+
columns: z20.union([z20.array(GridItem), z20.undefined()]).default(() => ["auto"]),
|
|
1450
|
+
rows: z20.union([z20.array(GridItem), z20.undefined()]).default(() => ["auto"])
|
|
1427
1451
|
}).default({ columns: ["auto"], rows: ["auto"] }).optional(),
|
|
1428
|
-
name:
|
|
1429
|
-
padding:
|
|
1430
|
-
sectionId:
|
|
1431
|
-
sections:
|
|
1432
|
-
sectionType:
|
|
1433
|
-
spacing:
|
|
1452
|
+
name: z20.string().optional(),
|
|
1453
|
+
padding: z20.enum(spacings).default(Spacing.none),
|
|
1454
|
+
sectionId: z20.uuid().default(() => uuidv713()),
|
|
1455
|
+
sections: z20.union([z20.array(z20.lazy(() => CABSection)), z20.strictObject({}).transform(() => [])]).default(() => []),
|
|
1456
|
+
sectionType: z20.literal(SectionType.layout).default(SectionType.layout),
|
|
1457
|
+
spacing: z20.enum(spacings).default(Spacing.base),
|
|
1434
1458
|
/** Fire-and-forget impression pixel POSTed once when the section is shown (e.g. a Monetize offer view). */
|
|
1435
|
-
viewUrl:
|
|
1436
|
-
width:
|
|
1459
|
+
viewUrl: z20.string().optional(),
|
|
1460
|
+
width: z20.number().default(100),
|
|
1461
|
+
wrapping: CABLayoutWrapping.optional()
|
|
1437
1462
|
});
|
|
1438
1463
|
|
|
1439
1464
|
// src/schema/widgets/checkout-and-beyond/banner.ts
|
|
1440
|
-
var CABBannerSection =
|
|
1465
|
+
var CABBannerSection = z21.lazy(
|
|
1441
1466
|
() => CABLayoutSection.omit({ sectionType: true }).extend({
|
|
1442
|
-
buttonField:
|
|
1443
|
-
color:
|
|
1444
|
-
dismissible:
|
|
1467
|
+
buttonField: z21.enum(buttonFields).optional(),
|
|
1468
|
+
color: z21.enum(bannerColors).default("info"),
|
|
1469
|
+
dismissible: z21.boolean().default(true),
|
|
1445
1470
|
/**
|
|
1446
1471
|
* The `s-banner` heading — localized content (a buyer can see a merchant-composed banner). Absent OR
|
|
1447
1472
|
* blank ⇒ no heading; the renderer emits no heading slot for `''` rather than an empty one.
|
|
@@ -1457,8 +1482,8 @@ var CABBannerSection = z20.lazy(
|
|
|
1457
1482
|
* not a 500. Nothing emits `heading` yet; the first converter that maps merchant banner copy into it
|
|
1458
1483
|
* either strips first or teaches `normalizeTextContent` to strip this field.
|
|
1459
1484
|
*/
|
|
1460
|
-
heading:
|
|
1461
|
-
sectionType:
|
|
1485
|
+
heading: z21.record(z21.string(), z21.string().refine(checkForHTML, NO_HTML)).optional(),
|
|
1486
|
+
sectionType: z21.literal(SectionType.banner).default(SectionType.banner)
|
|
1462
1487
|
})
|
|
1463
1488
|
);
|
|
1464
1489
|
|
|
@@ -1695,7 +1720,7 @@ var OFFER_LABELS = {
|
|
|
1695
1720
|
};
|
|
1696
1721
|
|
|
1697
1722
|
// src/schema/widgets/checkout-and-beyond/root.ts
|
|
1698
|
-
import { z as
|
|
1723
|
+
import { z as z22 } from "zod";
|
|
1699
1724
|
|
|
1700
1725
|
// src/schema/widgets/checkout-and-beyond/uiLabels.ts
|
|
1701
1726
|
var UI_LABELS = {
|
|
@@ -1715,8 +1740,8 @@ var UI_LABELS = {
|
|
|
1715
1740
|
};
|
|
1716
1741
|
|
|
1717
1742
|
// src/schema/widgets/checkout-and-beyond/root.ts
|
|
1718
|
-
var localized = (fallback) =>
|
|
1719
|
-
var CABUILabels =
|
|
1743
|
+
var localized = (fallback) => z22.record(z22.string(), z22.string()).default(() => ({ ...fallback })).transform((labels) => Object.keys(labels).length > 0 ? labels : { ...fallback });
|
|
1744
|
+
var CABUILabels = z22.object({
|
|
1720
1745
|
currentPage: localized(UI_LABELS.currentPage),
|
|
1721
1746
|
guest: localized(UI_LABELS.guest),
|
|
1722
1747
|
loadingOptions: localized(UI_LABELS.loadingOptions),
|
|
@@ -1741,37 +1766,37 @@ var CABUILabels = z21.object({
|
|
|
1741
1766
|
subscriptionOptions: { ...UI_LABELS.subscriptionOptions },
|
|
1742
1767
|
updating: { ...UI_LABELS.updating }
|
|
1743
1768
|
}));
|
|
1744
|
-
var TargetArea =
|
|
1745
|
-
fill:
|
|
1746
|
-
flip:
|
|
1747
|
-
icon:
|
|
1748
|
-
label:
|
|
1749
|
-
width:
|
|
1769
|
+
var TargetArea = z22.object({
|
|
1770
|
+
fill: z22.boolean().optional(),
|
|
1771
|
+
flip: z22.enum(["both", "horizontal", "vertical"]).optional(),
|
|
1772
|
+
icon: z22.string(),
|
|
1773
|
+
label: z22.string(),
|
|
1774
|
+
width: z22.string()
|
|
1750
1775
|
}).default(targetAreas[EditorMode.checkoutExtension][1]);
|
|
1751
|
-
var CABTracking =
|
|
1752
|
-
enableAttribution:
|
|
1753
|
-
enableSource:
|
|
1754
|
-
enableWidget:
|
|
1776
|
+
var CABTracking = z22.object({
|
|
1777
|
+
enableAttribution: z22.boolean().nullish().transform((value) => value ?? true),
|
|
1778
|
+
enableSource: z22.boolean().nullish().transform((value) => value ?? true),
|
|
1779
|
+
enableWidget: z22.boolean().nullish().transform((value) => value ?? true)
|
|
1755
1780
|
}).nullish().transform((value) => value ?? { enableAttribution: true, enableSource: true, enableWidget: true });
|
|
1756
|
-
var CABExperiment =
|
|
1757
|
-
elementId:
|
|
1758
|
-
experimentId:
|
|
1759
|
-
experimentType:
|
|
1760
|
-
selectedId:
|
|
1781
|
+
var CABExperiment = z22.object({
|
|
1782
|
+
elementId: z22.number(),
|
|
1783
|
+
experimentId: z22.number(),
|
|
1784
|
+
experimentType: z22.string(),
|
|
1785
|
+
selectedId: z22.number()
|
|
1761
1786
|
});
|
|
1762
1787
|
var CABRootSection = CABLayoutSection.extend({
|
|
1763
|
-
editorMode:
|
|
1788
|
+
editorMode: z22.enum(editorModes).default(EditorMode.checkoutExtension),
|
|
1764
1789
|
experiment: CABExperiment.optional(),
|
|
1765
1790
|
// Same rule as CABTracking above: the v1 converters pass raw legacy `previewMode` through, so a
|
|
1766
1791
|
// `null` must fall back rather than throw the widget; malformed values still throw.
|
|
1767
|
-
previewMode:
|
|
1768
|
-
storeId:
|
|
1792
|
+
previewMode: z22.boolean().nullish().transform((value) => value ?? false),
|
|
1793
|
+
storeId: z22.number().nullable().default(null),
|
|
1769
1794
|
targetArea: TargetArea.nullable(),
|
|
1770
1795
|
tracking: CABTracking,
|
|
1771
|
-
type:
|
|
1796
|
+
type: z22.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
|
|
1772
1797
|
uiLabels: CABUILabels,
|
|
1773
|
-
version:
|
|
1774
|
-
widgetId:
|
|
1798
|
+
version: z22.literal(2).default(2),
|
|
1799
|
+
widgetId: z22.number().nullable().default(null)
|
|
1775
1800
|
});
|
|
1776
1801
|
|
|
1777
1802
|
// src/schema/widgets/checkout-and-beyond/switchLabels.ts
|
|
@@ -1915,6 +1940,7 @@ export {
|
|
|
1915
1940
|
CABImageSectionFields,
|
|
1916
1941
|
CABIntegrations,
|
|
1917
1942
|
CABLayoutSection,
|
|
1943
|
+
CABLayoutWrapping,
|
|
1918
1944
|
CABMonetizeAds,
|
|
1919
1945
|
CABMonetizeSection,
|
|
1920
1946
|
CABNumberVariable,
|
|
@@ -1932,6 +1958,7 @@ export {
|
|
|
1932
1958
|
CABRuleset,
|
|
1933
1959
|
CABRulesetEntry,
|
|
1934
1960
|
CABSection,
|
|
1961
|
+
CABSeparatorSection,
|
|
1935
1962
|
CABTextSection,
|
|
1936
1963
|
CABTextTier,
|
|
1937
1964
|
CABTextVariable,
|
|
@@ -1966,6 +1993,7 @@ export {
|
|
|
1966
1993
|
IconTone,
|
|
1967
1994
|
InlineTextSizeName,
|
|
1968
1995
|
LanguageKey,
|
|
1996
|
+
LayoutFrame,
|
|
1969
1997
|
MutatorEvent,
|
|
1970
1998
|
NO_HTML,
|
|
1971
1999
|
OFFER_LABELS,
|
|
@@ -2044,6 +2072,7 @@ export {
|
|
|
2044
2072
|
isTextType,
|
|
2045
2073
|
isVariantsType,
|
|
2046
2074
|
languageKeys,
|
|
2075
|
+
layoutFrames,
|
|
2047
2076
|
mutatorEvents,
|
|
2048
2077
|
objectFits,
|
|
2049
2078
|
offersDirections,
|