@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
|
@@ -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,53 @@ 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
|
+
/**
|
|
1366
|
+
* Star outline color, interpolated into a style by the renderer, so it is hex-constrained like
|
|
1367
|
+
* `CABButtonSection.color`. The legacy source (`PostPurchaseSettings.styles.starStrokeColor`) is a free
|
|
1368
|
+
* string: its converter must validate and fall back to this default rather than let one odd value drop
|
|
1369
|
+
* the whole reviews section.
|
|
1370
|
+
*/
|
|
1371
|
+
strokeColor: z16.string().regex(HEX_COLOR_REGEX).default("#fadb14"),
|
|
1372
|
+
/** Star outline width in px; `0` draws no outline. The legacy `styles.strokeWidth` is a STRING ('1') — its converter coerces. */
|
|
1373
|
+
strokeWidth: z16.number().nonnegative().default(0)
|
|
1362
1374
|
});
|
|
1363
1375
|
|
|
1364
|
-
// src/schema/widgets/checkout-and-beyond/
|
|
1365
|
-
import { slice } from "es-toolkit/compat";
|
|
1376
|
+
// src/schema/widgets/checkout-and-beyond/separator.ts
|
|
1366
1377
|
import { v7 as uuidv711 } from "uuid";
|
|
1367
1378
|
import { z as z17 } from "zod";
|
|
1368
|
-
var
|
|
1379
|
+
var CABSeparatorSection = z17.object({
|
|
1369
1380
|
...CABVariableFields,
|
|
1370
|
-
hideOutOfStockVariants: z17.boolean().default(false),
|
|
1371
|
-
name: z17.string().optional(),
|
|
1372
1381
|
sectionId: z17.uuid().default(() => uuidv711()),
|
|
1373
|
-
sectionType: z17.literal(SectionType.
|
|
1374
|
-
|
|
1375
|
-
|
|
1382
|
+
sectionType: z17.literal(SectionType.separator).default(SectionType.separator)
|
|
1383
|
+
});
|
|
1384
|
+
|
|
1385
|
+
// src/schema/widgets/checkout-and-beyond/variants.ts
|
|
1386
|
+
import { slice } from "es-toolkit/compat";
|
|
1387
|
+
import { v7 as uuidv712 } from "uuid";
|
|
1388
|
+
import { z as z18 } from "zod";
|
|
1389
|
+
var CABVariantsSection = z18.object({
|
|
1390
|
+
...CABVariableFields,
|
|
1391
|
+
hideOutOfStockVariants: z18.boolean().default(false),
|
|
1392
|
+
name: z18.string().optional(),
|
|
1393
|
+
sectionId: z18.uuid().default(() => uuidv712()),
|
|
1394
|
+
sectionType: z18.literal(SectionType.variants).default(SectionType.variants),
|
|
1395
|
+
selector: z18.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu),
|
|
1396
|
+
variantMode: z18.enum(variantModes).default(VariantMode.multiple)
|
|
1376
1397
|
});
|
|
1377
1398
|
|
|
1378
1399
|
// src/schema/widgets/checkout-and-beyond/shared.ts
|
|
1379
|
-
var CABBorder =
|
|
1380
|
-
radius:
|
|
1381
|
-
style:
|
|
1382
|
-
width:
|
|
1400
|
+
var CABBorder = z19.object({
|
|
1401
|
+
radius: z19.enum(borderRadii).default(BorderRadius.base),
|
|
1402
|
+
style: z19.enum(borderStyles).default(BorderStyle.none),
|
|
1403
|
+
width: z19.enum(borderWidths).default(BorderWidth.base)
|
|
1383
1404
|
}).default({
|
|
1384
1405
|
radius: BorderRadius.base,
|
|
1385
1406
|
style: BorderStyle.none,
|
|
1386
1407
|
width: BorderWidth.base
|
|
1387
1408
|
});
|
|
1388
|
-
var CABSection =
|
|
1389
|
-
() =>
|
|
1409
|
+
var CABSection = z19.lazy(
|
|
1410
|
+
() => z19.discriminatedUnion("sectionType", [
|
|
1390
1411
|
CABBannerSection,
|
|
1391
1412
|
CABButtonSection,
|
|
1392
1413
|
CABCarouselSection,
|
|
@@ -1402,46 +1423,57 @@ var CABSection = z18.lazy(
|
|
|
1402
1423
|
CABProgressBarSection,
|
|
1403
1424
|
CABQuantitySection,
|
|
1404
1425
|
CABReviewsSection,
|
|
1426
|
+
CABSeparatorSection,
|
|
1405
1427
|
CABTextSection,
|
|
1406
1428
|
CABVariantsSection
|
|
1407
1429
|
])
|
|
1408
1430
|
);
|
|
1409
1431
|
|
|
1410
1432
|
// src/schema/widgets/checkout-and-beyond/layout.ts
|
|
1411
|
-
var GridItem =
|
|
1412
|
-
var
|
|
1433
|
+
var GridItem = z20.union([z20.literal("auto"), z20.literal("fill"), z20.string().regex(/^\d+%$/), z20.number()]);
|
|
1434
|
+
var CABLayoutWrapping = z20.object({
|
|
1435
|
+
breakAt: z20.number().positive(),
|
|
1436
|
+
maxPerLine: z20.number().int().positive()
|
|
1437
|
+
});
|
|
1438
|
+
var CABLayoutSection = z20.object({
|
|
1413
1439
|
...CABVariableFields,
|
|
1414
|
-
alignment:
|
|
1415
|
-
horizontal:
|
|
1416
|
-
vertical:
|
|
1440
|
+
alignment: z20.object({
|
|
1441
|
+
horizontal: z20.enum(horizontalAlignments).default(HorizontalAlignment.start),
|
|
1442
|
+
vertical: z20.enum(verticalAlignments).default(VerticalAlignment.top)
|
|
1417
1443
|
}).default({
|
|
1418
1444
|
horizontal: HorizontalAlignment.start,
|
|
1419
1445
|
vertical: VerticalAlignment.top
|
|
1420
1446
|
}),
|
|
1421
|
-
border:
|
|
1422
|
-
buttonField:
|
|
1423
|
-
direction:
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1447
|
+
border: z20.lazy(() => CABBorder),
|
|
1448
|
+
buttonField: z20.enum(buttonFields).optional(),
|
|
1449
|
+
direction: z20.enum(directions).default(Direction.rows),
|
|
1450
|
+
/**
|
|
1451
|
+
* Platform chrome around the section, not a layout behavior: `callout` is a subdued box with block borders
|
|
1452
|
+
* (the legacy post-purchase callout banner), `offer-content` the post-purchase offer's own content card.
|
|
1453
|
+
*/
|
|
1454
|
+
frame: z20.enum(layoutFrames).optional(),
|
|
1455
|
+
grid: z20.object({
|
|
1456
|
+
columns: z20.union([z20.array(GridItem), z20.undefined()]).default(() => ["auto"]),
|
|
1457
|
+
rows: z20.union([z20.array(GridItem), z20.undefined()]).default(() => ["auto"])
|
|
1427
1458
|
}).default({ columns: ["auto"], rows: ["auto"] }).optional(),
|
|
1428
|
-
name:
|
|
1429
|
-
padding:
|
|
1430
|
-
sectionId:
|
|
1431
|
-
sections:
|
|
1432
|
-
sectionType:
|
|
1433
|
-
spacing:
|
|
1459
|
+
name: z20.string().optional(),
|
|
1460
|
+
padding: z20.enum(spacings).default(Spacing.none),
|
|
1461
|
+
sectionId: z20.uuid().default(() => uuidv713()),
|
|
1462
|
+
sections: z20.union([z20.array(z20.lazy(() => CABSection)), z20.strictObject({}).transform(() => [])]).default(() => []),
|
|
1463
|
+
sectionType: z20.literal(SectionType.layout).default(SectionType.layout),
|
|
1464
|
+
spacing: z20.enum(spacings).default(Spacing.base),
|
|
1434
1465
|
/** Fire-and-forget impression pixel POSTed once when the section is shown (e.g. a Monetize offer view). */
|
|
1435
|
-
viewUrl:
|
|
1436
|
-
width:
|
|
1466
|
+
viewUrl: z20.string().optional(),
|
|
1467
|
+
width: z20.number().default(100),
|
|
1468
|
+
wrapping: CABLayoutWrapping.optional()
|
|
1437
1469
|
});
|
|
1438
1470
|
|
|
1439
1471
|
// src/schema/widgets/checkout-and-beyond/banner.ts
|
|
1440
|
-
var CABBannerSection =
|
|
1472
|
+
var CABBannerSection = z21.lazy(
|
|
1441
1473
|
() => CABLayoutSection.omit({ sectionType: true }).extend({
|
|
1442
|
-
buttonField:
|
|
1443
|
-
color:
|
|
1444
|
-
dismissible:
|
|
1474
|
+
buttonField: z21.enum(buttonFields).optional(),
|
|
1475
|
+
color: z21.enum(bannerColors).default("info"),
|
|
1476
|
+
dismissible: z21.boolean().default(true),
|
|
1445
1477
|
/**
|
|
1446
1478
|
* The `s-banner` heading — localized content (a buyer can see a merchant-composed banner). Absent OR
|
|
1447
1479
|
* blank ⇒ no heading; the renderer emits no heading slot for `''` rather than an empty one.
|
|
@@ -1457,8 +1489,8 @@ var CABBannerSection = z20.lazy(
|
|
|
1457
1489
|
* not a 500. Nothing emits `heading` yet; the first converter that maps merchant banner copy into it
|
|
1458
1490
|
* either strips first or teaches `normalizeTextContent` to strip this field.
|
|
1459
1491
|
*/
|
|
1460
|
-
heading:
|
|
1461
|
-
sectionType:
|
|
1492
|
+
heading: z21.record(z21.string(), z21.string().refine(checkForHTML, NO_HTML)).optional(),
|
|
1493
|
+
sectionType: z21.literal(SectionType.banner).default(SectionType.banner)
|
|
1462
1494
|
})
|
|
1463
1495
|
);
|
|
1464
1496
|
|
|
@@ -1695,7 +1727,7 @@ var OFFER_LABELS = {
|
|
|
1695
1727
|
};
|
|
1696
1728
|
|
|
1697
1729
|
// src/schema/widgets/checkout-and-beyond/root.ts
|
|
1698
|
-
import { z as
|
|
1730
|
+
import { z as z22 } from "zod";
|
|
1699
1731
|
|
|
1700
1732
|
// src/schema/widgets/checkout-and-beyond/uiLabels.ts
|
|
1701
1733
|
var UI_LABELS = {
|
|
@@ -1715,8 +1747,8 @@ var UI_LABELS = {
|
|
|
1715
1747
|
};
|
|
1716
1748
|
|
|
1717
1749
|
// src/schema/widgets/checkout-and-beyond/root.ts
|
|
1718
|
-
var localized = (fallback) =>
|
|
1719
|
-
var CABUILabels =
|
|
1750
|
+
var localized = (fallback) => z22.record(z22.string(), z22.string()).default(() => ({ ...fallback })).transform((labels) => Object.keys(labels).length > 0 ? labels : { ...fallback });
|
|
1751
|
+
var CABUILabels = z22.object({
|
|
1720
1752
|
currentPage: localized(UI_LABELS.currentPage),
|
|
1721
1753
|
guest: localized(UI_LABELS.guest),
|
|
1722
1754
|
loadingOptions: localized(UI_LABELS.loadingOptions),
|
|
@@ -1741,37 +1773,37 @@ var CABUILabels = z21.object({
|
|
|
1741
1773
|
subscriptionOptions: { ...UI_LABELS.subscriptionOptions },
|
|
1742
1774
|
updating: { ...UI_LABELS.updating }
|
|
1743
1775
|
}));
|
|
1744
|
-
var TargetArea =
|
|
1745
|
-
fill:
|
|
1746
|
-
flip:
|
|
1747
|
-
icon:
|
|
1748
|
-
label:
|
|
1749
|
-
width:
|
|
1776
|
+
var TargetArea = z22.object({
|
|
1777
|
+
fill: z22.boolean().optional(),
|
|
1778
|
+
flip: z22.enum(["both", "horizontal", "vertical"]).optional(),
|
|
1779
|
+
icon: z22.string(),
|
|
1780
|
+
label: z22.string(),
|
|
1781
|
+
width: z22.string()
|
|
1750
1782
|
}).default(targetAreas[EditorMode.checkoutExtension][1]);
|
|
1751
|
-
var CABTracking =
|
|
1752
|
-
enableAttribution:
|
|
1753
|
-
enableSource:
|
|
1754
|
-
enableWidget:
|
|
1783
|
+
var CABTracking = z22.object({
|
|
1784
|
+
enableAttribution: z22.boolean().nullish().transform((value) => value ?? true),
|
|
1785
|
+
enableSource: z22.boolean().nullish().transform((value) => value ?? true),
|
|
1786
|
+
enableWidget: z22.boolean().nullish().transform((value) => value ?? true)
|
|
1755
1787
|
}).nullish().transform((value) => value ?? { enableAttribution: true, enableSource: true, enableWidget: true });
|
|
1756
|
-
var CABExperiment =
|
|
1757
|
-
elementId:
|
|
1758
|
-
experimentId:
|
|
1759
|
-
experimentType:
|
|
1760
|
-
selectedId:
|
|
1788
|
+
var CABExperiment = z22.object({
|
|
1789
|
+
elementId: z22.number(),
|
|
1790
|
+
experimentId: z22.number(),
|
|
1791
|
+
experimentType: z22.string(),
|
|
1792
|
+
selectedId: z22.number()
|
|
1761
1793
|
});
|
|
1762
1794
|
var CABRootSection = CABLayoutSection.extend({
|
|
1763
|
-
editorMode:
|
|
1795
|
+
editorMode: z22.enum(editorModes).default(EditorMode.checkoutExtension),
|
|
1764
1796
|
experiment: CABExperiment.optional(),
|
|
1765
1797
|
// Same rule as CABTracking above: the v1 converters pass raw legacy `previewMode` through, so a
|
|
1766
1798
|
// `null` must fall back rather than throw the widget; malformed values still throw.
|
|
1767
|
-
previewMode:
|
|
1768
|
-
storeId:
|
|
1799
|
+
previewMode: z22.boolean().nullish().transform((value) => value ?? false),
|
|
1800
|
+
storeId: z22.number().nullable().default(null),
|
|
1769
1801
|
targetArea: TargetArea.nullable(),
|
|
1770
1802
|
tracking: CABTracking,
|
|
1771
|
-
type:
|
|
1803
|
+
type: z22.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
|
|
1772
1804
|
uiLabels: CABUILabels,
|
|
1773
|
-
version:
|
|
1774
|
-
widgetId:
|
|
1805
|
+
version: z22.literal(2).default(2),
|
|
1806
|
+
widgetId: z22.number().nullable().default(null)
|
|
1775
1807
|
});
|
|
1776
1808
|
|
|
1777
1809
|
// src/schema/widgets/checkout-and-beyond/switchLabels.ts
|
|
@@ -1915,6 +1947,7 @@ export {
|
|
|
1915
1947
|
CABImageSectionFields,
|
|
1916
1948
|
CABIntegrations,
|
|
1917
1949
|
CABLayoutSection,
|
|
1950
|
+
CABLayoutWrapping,
|
|
1918
1951
|
CABMonetizeAds,
|
|
1919
1952
|
CABMonetizeSection,
|
|
1920
1953
|
CABNumberVariable,
|
|
@@ -1932,6 +1965,7 @@ export {
|
|
|
1932
1965
|
CABRuleset,
|
|
1933
1966
|
CABRulesetEntry,
|
|
1934
1967
|
CABSection,
|
|
1968
|
+
CABSeparatorSection,
|
|
1935
1969
|
CABTextSection,
|
|
1936
1970
|
CABTextTier,
|
|
1937
1971
|
CABTextVariable,
|
|
@@ -1966,6 +2000,7 @@ export {
|
|
|
1966
2000
|
IconTone,
|
|
1967
2001
|
InlineTextSizeName,
|
|
1968
2002
|
LanguageKey,
|
|
2003
|
+
LayoutFrame,
|
|
1969
2004
|
MutatorEvent,
|
|
1970
2005
|
NO_HTML,
|
|
1971
2006
|
OFFER_LABELS,
|
|
@@ -2044,6 +2079,7 @@ export {
|
|
|
2044
2079
|
isTextType,
|
|
2045
2080
|
isVariantsType,
|
|
2046
2081
|
languageKeys,
|
|
2082
|
+
layoutFrames,
|
|
2047
2083
|
mutatorEvents,
|
|
2048
2084
|
objectFits,
|
|
2049
2085
|
offersDirections,
|