@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.
Files changed (39) hide show
  1. package/dist/index.cjs +383 -347
  2. package/dist/index.mjs +382 -346
  3. package/dist/schema/checkout-and-beyond/constants.cjs +5 -0
  4. package/dist/schema/checkout-and-beyond/constants.mjs +5 -0
  5. package/dist/schema/checkout-and-beyond/index.cjs +104 -68
  6. package/dist/schema/checkout-and-beyond/index.mjs +104 -68
  7. package/dist/schema/widget-data.cjs +167 -135
  8. package/dist/schema/widget-data.mjs +167 -135
  9. package/dist/schema/widgetData.d.ts +24 -0
  10. package/dist/schema/widgets/checkout-and-beyond/banner.d.ts +8 -0
  11. package/dist/schema/widgets/checkout-and-beyond/carousel.d.ts +8 -0
  12. package/dist/schema/widgets/checkout-and-beyond/cartLine.d.ts +8 -0
  13. package/dist/schema/widgets/checkout-and-beyond/common.d.ts +13 -1
  14. package/dist/schema/widgets/checkout-and-beyond/index.d.ts +1 -0
  15. package/dist/schema/widgets/checkout-and-beyond/layout.d.ts +17 -1
  16. package/dist/schema/widgets/checkout-and-beyond/offers.d.ts +8 -0
  17. package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts +8 -0
  18. package/dist/schema/widgets/checkout-and-beyond/reviews.d.ts +2 -0
  19. package/dist/schema/widgets/checkout-and-beyond/root.d.ts +8 -0
  20. package/dist/schema/widgets/checkout-and-beyond/separator.d.ts +192 -0
  21. package/dist/schema/widgets/checkout-and-beyond/shared.d.ts +2 -1
  22. package/dist/schema/widgets/contentBlock.d.ts +8 -0
  23. package/dist/schema/widgets/lineItemEditor.d.ts +8 -0
  24. package/dist/schema/widgets/post-purchase-offer/constants.d.ts +2 -2
  25. package/dist/schema/widgets/rebuyButton.d.ts +8 -0
  26. package/dist/server/index.cjs +606 -188
  27. package/dist/server/index.mjs +606 -188
  28. package/dist/transforms/index.cjs +486 -59
  29. package/dist/transforms/index.d.ts +2 -0
  30. package/dist/transforms/index.mjs +486 -59
  31. package/dist/transforms/postPurchase/convertCalloutBlock.d.ts +8 -0
  32. package/dist/transforms/postPurchase/convertMessagePreview.d.ts +8 -0
  33. package/dist/transforms/postPurchase/convertPayButtonBlock.d.ts +4 -0
  34. package/dist/transforms/postPurchase/convertSeparatorBlock.d.ts +4 -0
  35. package/dist/transforms/postPurchase/convertTextBlock.d.ts +4 -0
  36. package/dist/transforms/postPurchase/convertTimerBlock.d.ts +4 -0
  37. package/dist/transforms/postPurchase/styledTextRun.d.ts +3 -0
  38. package/dist/transforms/postPurchase/types.d.ts +14 -0
  39. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  // src/schema/widgets/checkout-and-beyond/banner.ts
2
- import { z as z20 } from "zod";
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 uuidv712 } from "uuid";
209
- import { z as z19 } from "zod";
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 z18 } from "zod";
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/variants.ts
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 CABVariantsSection = z17.object({
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.variants).default(SectionType.variants),
1374
- selector: z17.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu),
1375
- variantMode: z17.enum(variantModes).default(VariantMode.multiple)
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 = z18.object({
1380
- radius: z18.enum(borderRadii).default(BorderRadius.base),
1381
- style: z18.enum(borderStyles).default(BorderStyle.none),
1382
- width: z18.enum(borderWidths).default(BorderWidth.base)
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 = z18.lazy(
1389
- () => z18.discriminatedUnion("sectionType", [
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 = z19.union([z19.literal("auto"), z19.literal("fill"), z19.string().regex(/^\d+%$/), z19.number()]);
1412
- var CABLayoutSection = z19.object({
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: z19.object({
1415
- horizontal: z19.enum(horizontalAlignments).default(HorizontalAlignment.start),
1416
- vertical: z19.enum(verticalAlignments).default(VerticalAlignment.top)
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: z19.lazy(() => CABBorder),
1422
- buttonField: z19.enum(buttonFields).optional(),
1423
- direction: z19.enum(directions).default(Direction.rows),
1424
- grid: z19.object({
1425
- columns: z19.union([z19.array(GridItem), z19.undefined()]).default(() => ["auto"]),
1426
- rows: z19.union([z19.array(GridItem), z19.undefined()]).default(() => ["auto"])
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: z19.string().optional(),
1429
- padding: z19.enum(spacings).default(Spacing.none),
1430
- sectionId: z19.uuid().default(() => uuidv712()),
1431
- sections: z19.union([z19.array(z19.lazy(() => CABSection)), z19.strictObject({}).transform(() => [])]).default(() => []),
1432
- sectionType: z19.literal(SectionType.layout).default(SectionType.layout),
1433
- spacing: z19.enum(spacings).default(Spacing.base),
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: z19.string().optional(),
1436
- width: z19.number().default(100)
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 = z20.lazy(
1472
+ var CABBannerSection = z21.lazy(
1441
1473
  () => CABLayoutSection.omit({ sectionType: true }).extend({
1442
- buttonField: z20.enum(buttonFields).optional(),
1443
- color: z20.enum(bannerColors).default("info"),
1444
- dismissible: z20.boolean().default(true),
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: z20.record(z20.string(), z20.string().refine(checkForHTML, NO_HTML)).optional(),
1461
- sectionType: z20.literal(SectionType.banner).default(SectionType.banner)
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 z21 } from "zod";
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) => z21.record(z21.string(), z21.string()).default(() => ({ ...fallback })).transform((labels) => Object.keys(labels).length > 0 ? labels : { ...fallback });
1719
- var CABUILabels = z21.object({
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 = z21.object({
1745
- fill: z21.boolean().optional(),
1746
- flip: z21.enum(["both", "horizontal", "vertical"]).optional(),
1747
- icon: z21.string(),
1748
- label: z21.string(),
1749
- width: z21.string()
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 = z21.object({
1752
- enableAttribution: z21.boolean().nullish().transform((value) => value ?? true),
1753
- enableSource: z21.boolean().nullish().transform((value) => value ?? true),
1754
- enableWidget: z21.boolean().nullish().transform((value) => value ?? true)
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 = z21.object({
1757
- elementId: z21.number(),
1758
- experimentId: z21.number(),
1759
- experimentType: z21.string(),
1760
- selectedId: z21.number()
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: z21.enum(editorModes).default(EditorMode.checkoutExtension),
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: z21.boolean().nullish().transform((value) => value ?? false),
1768
- storeId: z21.number().nullable().default(null),
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: z21.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
1803
+ type: z22.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
1772
1804
  uiLabels: CABUILabels,
1773
- version: z21.literal(2).default(2),
1774
- widgetId: z21.number().nullable().default(null)
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,