@rebuy/rebuy 2.34.0 → 2.35.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.
Files changed (43) hide show
  1. package/dist/index.js +204 -23
  2. package/dist/index.js.map +4 -4
  3. package/dist/index.mjs +204 -23
  4. package/dist/index.mjs.map +4 -4
  5. package/dist/schema/checkout-and-beyond/constants.js +2 -0
  6. package/dist/schema/checkout-and-beyond/constants.js.map +2 -2
  7. package/dist/schema/checkout-and-beyond/constants.mjs +2 -0
  8. package/dist/schema/checkout-and-beyond/constants.mjs.map +2 -2
  9. package/dist/schema/checkout-and-beyond/index.js +183 -6
  10. package/dist/schema/checkout-and-beyond/index.js.map +3 -3
  11. package/dist/schema/checkout-and-beyond/index.mjs +183 -6
  12. package/dist/schema/checkout-and-beyond/index.mjs.map +3 -3
  13. package/dist/schema/widget-data.js +197 -23
  14. package/dist/schema/widget-data.js.map +4 -4
  15. package/dist/schema/widget-data.mjs +197 -23
  16. package/dist/schema/widget-data.mjs.map +3 -3
  17. package/dist/schema/widgets/checkout-and-beyond/banner.d.ts +27 -25
  18. package/dist/schema/widgets/checkout-and-beyond/banner.d.ts.map +1 -1
  19. package/dist/schema/widgets/checkout-and-beyond/button.d.ts +5 -0
  20. package/dist/schema/widgets/checkout-and-beyond/button.d.ts.map +1 -1
  21. package/dist/schema/widgets/checkout-and-beyond/carousel.d.ts +25 -25
  22. package/dist/schema/widgets/checkout-and-beyond/cartLine.d.ts +25 -25
  23. package/dist/schema/widgets/checkout-and-beyond/common.d.ts +3 -1
  24. package/dist/schema/widgets/checkout-and-beyond/common.d.ts.map +1 -1
  25. package/dist/schema/widgets/checkout-and-beyond/icons.d.ts +124 -0
  26. package/dist/schema/widgets/checkout-and-beyond/icons.d.ts.map +1 -0
  27. package/dist/schema/widgets/checkout-and-beyond/image.d.ts +319 -2
  28. package/dist/schema/widgets/checkout-and-beyond/image.d.ts.map +1 -1
  29. package/dist/schema/widgets/checkout-and-beyond/index.d.ts +1 -0
  30. package/dist/schema/widgets/checkout-and-beyond/index.d.ts.map +1 -1
  31. package/dist/schema/widgets/checkout-and-beyond/offers.d.ts +25 -25
  32. package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts +25 -25
  33. package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts.map +1 -1
  34. package/dist/server/index.js +193 -25
  35. package/dist/server/index.js.map +4 -4
  36. package/dist/server/index.mjs +193 -25
  37. package/dist/server/index.mjs.map +4 -4
  38. package/dist/transforms/index.js +193 -25
  39. package/dist/transforms/index.js.map +3 -3
  40. package/dist/transforms/index.mjs +193 -25
  41. package/dist/transforms/index.mjs.map +3 -3
  42. package/dist/transforms/smartCart/convertSmartCartProgressBarToV2.d.ts.map +1 -1
  43. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ __export(src_exports, {
42
42
  CABDiscountSection: () => CABDiscountSection,
43
43
  CABExperiment: () => CABExperiment,
44
44
  CABImageSection: () => CABImageSection,
45
+ CABImageSectionFields: () => CABImageSectionFields,
45
46
  CABIntegrations: () => CABIntegrations,
46
47
  CABLayoutSection: () => CABLayoutSection,
47
48
  CABMonetizeSection: () => CABMonetizeSection,
@@ -83,6 +84,9 @@ __export(src_exports, {
83
84
  HEX_COLOR_REGEX: () => HEX_COLOR_REGEX,
84
85
  HTML_TAGS_REGEX: () => HTML_TAGS_REGEX,
85
86
  HorizontalAlignment: () => HorizontalAlignment,
87
+ IconName: () => IconName,
88
+ IconSize: () => IconSize,
89
+ IconTone: () => IconTone,
86
90
  Identity: () => Identity,
87
91
  ImageBlock: () => ImageBlock,
88
92
  ImageContentBlock: () => ImageContentBlock,
@@ -177,6 +181,9 @@ __export(src_exports, {
177
181
  getIdFromGraphUrl: () => getIdFromGraphUrl,
178
182
  hasHTMLInDoc: () => hasHTMLInDoc,
179
183
  horizontalAlignments: () => horizontalAlignments,
184
+ iconNames: () => iconNames,
185
+ iconSizes: () => iconSizes,
186
+ iconTones: () => iconTones,
180
187
  isBannerType: () => isBannerType,
181
188
  isBase64Encoded: () => isBase64Encoded,
182
189
  isButtonType: () => isButtonType,
@@ -1515,6 +1522,7 @@ var borderWidths = ["base", "medium", "thick"];
1515
1522
  var BorderWidth = freezeEnum(borderWidths);
1516
1523
  var buttonActions = [
1517
1524
  "acceptOffer",
1525
+ "addGift",
1518
1526
  "addToOrder",
1519
1527
  "declineAllOffers",
1520
1528
  "declineOffer",
@@ -1524,6 +1532,7 @@ var buttonActions = [
1524
1532
  "goToPrevPage",
1525
1533
  "goToURL",
1526
1534
  "removeFromOrder",
1535
+ "removeGift",
1527
1536
  "selectVariant",
1528
1537
  "showPagination",
1529
1538
  "switchToSubscription",
@@ -1822,22 +1831,10 @@ var import_zod27 = require("zod");
1822
1831
 
1823
1832
  // src/schema/widgets/checkout-and-beyond/banner.ts
1824
1833
  var import_zod11 = require("zod");
1825
- var CABBannerSection = import_zod11.z.lazy(
1826
- () => CABLayoutSection.omit({ sectionType: true }).extend({
1827
- buttonField: import_zod11.z.enum(buttonFields).optional(),
1828
- color: import_zod11.z.enum(bannerColors).default("info"),
1829
- dismissible: import_zod11.z.boolean().default(true),
1830
- sectionType: import_zod11.z.literal(SectionType.banner).default(SectionType.banner)
1831
- })
1832
- );
1833
1834
 
1834
- // src/schema/widgets/checkout-and-beyond/button.ts
1835
- var import_uuid3 = require("uuid");
1836
- var import_zod14 = require("zod");
1837
-
1838
- // src/schema/widgets/checkout-and-beyond/image.ts
1839
- var import_uuid = require("uuid");
1840
- var import_zod12 = require("zod");
1835
+ // src/schema/widgets/checkout-and-beyond/utils.ts
1836
+ var import_es_toolkit2 = require("es-toolkit");
1837
+ var import_compat = require("es-toolkit/compat");
1841
1838
 
1842
1839
  // src/schema/widgets/checkout-and-beyond/regex.ts
1843
1840
  var ARRAY_INDEX_STRING = /^(0|[1-9]\d*)$/;
@@ -1847,8 +1844,6 @@ var ROOT_RELATIVE_PATH_REGEX = /^\/(?!\/)/;
1847
1844
  var HTML_TAGS_REGEX = /<\/?[a-zA-Z][^>]*>/g;
1848
1845
 
1849
1846
  // src/schema/widgets/checkout-and-beyond/utils.ts
1850
- var import_es_toolkit2 = require("es-toolkit");
1851
- var import_compat = require("es-toolkit/compat");
1852
1847
  var isHTML = (html = "") => {
1853
1848
  if (typeof window !== "undefined") {
1854
1849
  const parser = new DOMParser();
@@ -1890,13 +1885,158 @@ var convertNumericObjects = (input) => {
1890
1885
  return input;
1891
1886
  };
1892
1887
 
1888
+ // src/schema/widgets/checkout-and-beyond/banner.ts
1889
+ var CABBannerSection = import_zod11.z.lazy(
1890
+ () => CABLayoutSection.omit({ sectionType: true }).extend({
1891
+ buttonField: import_zod11.z.enum(buttonFields).optional(),
1892
+ color: import_zod11.z.enum(bannerColors).default("info"),
1893
+ dismissible: import_zod11.z.boolean().default(true),
1894
+ /**
1895
+ * The `s-banner` heading — localized content (a buyer can see a merchant-composed banner). Absent OR
1896
+ * blank ⇒ no heading; the renderer emits no heading slot for `''` rather than an empty one.
1897
+ *
1898
+ * Merchant-composed buyer-facing plain text, so it rejects HTML at the boundary the same way
1899
+ * `CABImageSection.altText` and `CABTextSection.content` do (the unchecked localized records elsewhere —
1900
+ * `progressBar`'s gift labels, `reviews`' plurals — are converter/constant-sourced, not merchant input).
1901
+ *
1902
+ * The refinement is a last-resort ASSERTION, not the normalization boundary: `normalizeTextContent` only
1903
+ * rewrites `sectionType: 'text'` nodes' `content`, so nothing strips markup or canonicalizes `{token}`
1904
+ * here. A producer must strip upstream the way `composeOffer` does for `altText`. Get it wrong and
1905
+ * `salvageSections` stubs the whole banner (children included) with a drift report — degraded, reported,
1906
+ * not a 500. Nothing emits `heading` yet; the first converter that maps merchant banner copy into it
1907
+ * either strips first or teaches `normalizeTextContent` to strip this field.
1908
+ */
1909
+ heading: import_zod11.z.record(import_zod11.z.string(), import_zod11.z.string().refine(checkForHTML, NO_HTML)).optional(),
1910
+ sectionType: import_zod11.z.literal(SectionType.banner).default(SectionType.banner)
1911
+ })
1912
+ );
1913
+
1914
+ // src/schema/widgets/checkout-and-beyond/button.ts
1915
+ var import_uuid3 = require("uuid");
1916
+ var import_zod14 = require("zod");
1917
+
1918
+ // src/schema/widgets/checkout-and-beyond/image.ts
1919
+ var import_uuid = require("uuid");
1920
+ var import_zod12 = require("zod");
1921
+
1922
+ // src/schema/widgets/checkout-and-beyond/icons.ts
1923
+ var iconNames = [
1924
+ "alert-circle",
1925
+ "alert-triangle",
1926
+ "alert-triangle-filled",
1927
+ "arrow-down",
1928
+ "arrow-left",
1929
+ "arrow-right",
1930
+ "arrow-up",
1931
+ "arrow-up-right",
1932
+ "bag",
1933
+ "bullet",
1934
+ "calendar",
1935
+ "camera",
1936
+ "caret-down",
1937
+ "cart",
1938
+ "cash-dollar",
1939
+ "categories",
1940
+ "check",
1941
+ "check-circle",
1942
+ "check-circle-filled",
1943
+ "chevron-down",
1944
+ "chevron-left",
1945
+ "chevron-right",
1946
+ "chevron-up",
1947
+ "circle",
1948
+ "clipboard",
1949
+ "clock",
1950
+ "credit-card",
1951
+ "delete",
1952
+ "delivered",
1953
+ "delivery",
1954
+ "disabled",
1955
+ "discount",
1956
+ "edit",
1957
+ "email",
1958
+ "empty",
1959
+ "external",
1960
+ "filter",
1961
+ "geolocation",
1962
+ "gift-card",
1963
+ "globe",
1964
+ "grid",
1965
+ "image",
1966
+ "info",
1967
+ "info-filled",
1968
+ "list-bulleted",
1969
+ "location",
1970
+ "lock",
1971
+ "map",
1972
+ "menu",
1973
+ "menu-horizontal",
1974
+ "menu-vertical",
1975
+ "minus",
1976
+ "mobile",
1977
+ "note",
1978
+ "order",
1979
+ "organization",
1980
+ "plus",
1981
+ "profile",
1982
+ "question-circle",
1983
+ "question-circle-filled",
1984
+ "reorder",
1985
+ "reset",
1986
+ "return",
1987
+ "savings",
1988
+ "search",
1989
+ "settings",
1990
+ "star",
1991
+ "star-filled",
1992
+ "star-half",
1993
+ "store",
1994
+ "truck",
1995
+ "upload",
1996
+ "x",
1997
+ "x-circle",
1998
+ "x-circle-filled"
1999
+ ];
2000
+ var IconName = freezeEnum(iconNames);
2001
+ var iconSizes = ["base", "large", "large-100", "small", "small-100", "small-200"];
2002
+ var IconSize = freezeEnum(iconSizes);
2003
+ var iconTones = ["auto", "critical", "custom", "info", "neutral", "success", "warning"];
2004
+ var IconTone = freezeEnum(iconTones);
2005
+
1893
2006
  // src/schema/widgets/checkout-and-beyond/image.ts
1894
- var CABImageSection = import_zod12.z.object({
2007
+ var CABImageSectionFields = import_zod12.z.object({
1895
2008
  altText: import_zod12.z.string().refine(checkForHTML, NO_HTML).default(""),
1896
- aspectRatio: import_zod12.z.literal(1).nullable().default(null),
2009
+ /**
2010
+ * Image width÷height (e.g. `46` for the progress-bar fill); `null` renders at natural size. Any POSITIVE
2011
+ * ratio — never limited to 1, but never `0`/negative either: a renderer dividing by it would get `Infinity`,
2012
+ * and CSS `aspect-ratio` drops a negative value and silently reverts to natural size.
2013
+ */
2014
+ aspectRatio: import_zod12.z.number().positive().nullable().default(null),
1897
2015
  border: import_zod12.z.lazy(() => CABBorder),
1898
2016
  buttonField: import_zod12.z.enum(buttonFields).optional(),
1899
- category: import_zod12.z.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
2017
+ /**
2018
+ * `icon` renders `source` as a single `s-icon` by name (the uber-image path covers icons too), reading
2019
+ * `iconSize`/`iconTone`. The other values are a harmless informational holdover from the previous
2020
+ * implementation — they were never significant to rendering (`icons`, plural, is NOT deprecated, just one of
2021
+ * those inert legacy tags); `icon` is the first value that means anything.
2022
+ *
2023
+ * INVARIANT, encoded by the `.superRefine` below (a refined object IS a valid `z.discriminatedUnion` member
2024
+ * in zod 4 — see `CABTextSection`): `category: 'icon'` ⇒ `source` is an icon name or `''` (icon not yet
2025
+ * chosen); any other category ⇒ `source` is NOT a bare icon name, so it stays a URL/token/`''`.
2026
+ *
2027
+ * Encoded rather than left to the renderer because `source` is ONE union with no category gate, so widening
2028
+ * it with `iconNames` also widened what a STORED payload may contain: 14 of the names are plain English
2029
+ * words (`image`, `x`, `search`, `note`, `order`, `globe`, …), and a legacy `source: 'image'` used to fail
2030
+ * parse — which `salvageSections` turns into a null-rendering stub PLUS a drift report. Ungated it would
2031
+ * instead parse and reach the renderer as `<img src="image">`: a broken image, silently, where the old
2032
+ * behavior degraded gracefully and told us about it. The client-assembled half of the invariant was never
2033
+ * the risky half.
2034
+ */
2035
+ category: import_zod12.z.enum(["gallery", "icon", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
2036
+ /** `icon`-mode only: the `s-icon` `size`; `null` ⇒ the component default (`base`). Ignored by image treatments. */
2037
+ iconSize: import_zod12.z.enum(iconSizes).nullable().default(null),
2038
+ /** `icon`-mode only: the `s-icon` `tone`; `null` ⇒ the component default (`auto`). Ignored by image treatments. */
2039
+ iconTone: import_zod12.z.enum(iconTones).nullable().default(null),
1900
2040
  name: import_zod12.z.string().optional(),
1901
2041
  naturalHeight: import_zod12.z.number().default(0),
1902
2042
  naturalWidth: import_zod12.z.number().default(0),
@@ -1908,9 +2048,31 @@ var CABImageSection = import_zod12.z.object({
1908
2048
  rule: CABRule.optional(),
1909
2049
  sectionId: import_zod12.z.uuid().default(() => (0, import_uuid.v7)()),
1910
2050
  sectionType: import_zod12.z.literal(SectionType.image).default(SectionType.image),
1911
- source: import_zod12.z.union([import_zod12.z.url(), import_zod12.z.literal(""), import_zod12.z.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
2051
+ /**
2052
+ * An image URL or dynamic token, an empty default, or — when `category: 'icon'` — an icon NAME. Icon mode
2053
+ * takes a name or `''` only, NOT a token: no renderer resolves a token to an icon today, so accepting one
2054
+ * would promise a capability that doesn't exist. Widen the refine's carve-out to `DYNAMIC_TOKEN_REGEX` when a
2055
+ * server-chosen tier icon actually needs it.
2056
+ */
2057
+ source: import_zod12.z.union([import_zod12.z.url(), import_zod12.z.literal(""), import_zod12.z.string().regex(DYNAMIC_TOKEN_REGEX), import_zod12.z.enum(iconNames)]).default(""),
1912
2058
  width: import_zod12.z.number().default(100)
1913
2059
  });
2060
+ var iconNameSet = new Set(iconNames);
2061
+ var isIconName = (source) => iconNameSet.has(source);
2062
+ var CABImageSection = CABImageSectionFields.superRefine(({ category, source }, ctx) => {
2063
+ if (category === "icon" && source !== "" && !isIconName(source))
2064
+ ctx.addIssue({
2065
+ code: "custom",
2066
+ message: "icon-mode source must be an icon name",
2067
+ path: ["source"]
2068
+ });
2069
+ if (category !== "icon" && isIconName(source))
2070
+ ctx.addIssue({
2071
+ code: "custom",
2072
+ message: "source must be a URL or dynamic token unless category is `icon`",
2073
+ path: ["source"]
2074
+ });
2075
+ });
1914
2076
 
1915
2077
  // src/schema/widgets/checkout-and-beyond/text.ts
1916
2078
  var import_compat2 = require("es-toolkit/compat");
@@ -2030,6 +2192,21 @@ var CABButtonSection = import_zod14.z.object({
2030
2192
  sectionId: import_zod14.z.uuid().default(() => (0, import_uuid3.v7)()),
2031
2193
  sections: import_zod14.z.union([import_zod14.z.array(CABButtonContent), import_zod14.z.strictObject({}).transform(() => [])]).default(() => []),
2032
2194
  sectionType: import_zod14.z.literal(SectionType.button).default(SectionType.button),
2195
+ /**
2196
+ * The smart-cart tier this button acts on (`addGift`/`removeGift`): scopes the click to one tier's gift. The
2197
+ * client resolves the tier's gift (productId) from the progress-bar context by this `tierId` — the button node
2198
+ * stays data, no bespoke per-tier wiring. Absent on non-gift buttons (offer add/remove, navigation, links).
2199
+ *
2200
+ * Deliberately NOT `CABTextTier` (the shape `CABTextSection.tier` uses): a gift button acts on a tier the bar
2201
+ * already resolved, so it needs the id and nothing else. Reusing the text tier would make `threshold`
2202
+ * required, leave `tierId` optional, and DEFAULT `tierType` to `'shipping'` — a schema-supplied wrong answer
2203
+ * on a gift button. Unknown keys are stripped, so a client spreading a whole tier in still parses.
2204
+ *
2205
+ * `.min(1)` because an empty id IS the silently-id-less state this shape exists to prevent: the client's
2206
+ * lookup finds no tier and the click resolves to nothing. Safe to bound — the field is new, so there are no
2207
+ * stored payloads to grandfather, and the producer is client code, not a merchant form.
2208
+ */
2209
+ tier: import_zod14.z.object({ tierId: import_zod14.z.string().min(1) }).optional(),
2033
2210
  /** Fire-and-forget pixel POSTed when the button is clicked (e.g. a Monetize decline). */
2034
2211
  trackingUrl: import_zod14.z.string().optional()
2035
2212
  });
@@ -2325,8 +2502,12 @@ var CABProgressTier = import_zod23.z.object({
2325
2502
  }).optional(),
2326
2503
  /**
2327
2504
  * The step-row label at this tier's slot (onsite `getTierLabel`): the merchant custom label, else the
2328
- * type default ('Free Shipping' / product title / '{n}% Discount'). Localized content; blank no
2329
- * label under the tier's icon. Plain text the step row is a compact icon+label, not rich copy.
2505
+ * type default 'Free Shipping' or '{n}% Discount'. A PRODUCT tier gets NO converter label: its name is
2506
+ * the gift PRODUCT title, which the converter can't supply (config carries only product IDs), so the
2507
+ * client resolves it (authoritative Shopify title, React parity) with its own localized generic fallback.
2508
+ * Localized content; absent OR blank ⇒ no label under the tier's icon (the converter's `toTierMeta` already
2509
+ * turns a blank label into an absent key, and a client-authored blank means the same thing — the renderer
2510
+ * emits no caption slot rather than an empty one). Plain text — a compact icon+label.
2330
2511
  */
2331
2512
  label: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.string()).optional(),
2332
2513
  /**