@rebuy/rebuy 2.30.0-rc.3 → 2.30.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 (71) hide show
  1. package/dist/gwp/types.d.ts +6 -1
  2. package/dist/gwp/types.d.ts.map +1 -1
  3. package/dist/index.js +36 -12
  4. package/dist/index.js.map +2 -2
  5. package/dist/index.mjs +36 -12
  6. package/dist/index.mjs.map +2 -2
  7. package/dist/pricing/computeDisplayPrice.d.ts +8 -1
  8. package/dist/pricing/computeDisplayPrice.d.ts.map +1 -1
  9. package/dist/pricing/index.js +7 -4
  10. package/dist/pricing/index.js.map +2 -2
  11. package/dist/pricing/index.mjs +7 -4
  12. package/dist/pricing/index.mjs.map +2 -2
  13. package/dist/pricing/priceVariant.d.ts +3 -1
  14. package/dist/pricing/priceVariant.d.ts.map +1 -1
  15. package/dist/pricing/types.d.ts +5 -0
  16. package/dist/pricing/types.d.ts.map +1 -1
  17. package/dist/schema/cabShopConfig.d.ts +22 -20
  18. package/dist/schema/cabShopConfig.d.ts.map +1 -1
  19. package/dist/schema/checkout-and-beyond/index.js +18 -11
  20. package/dist/schema/checkout-and-beyond/index.js.map +2 -2
  21. package/dist/schema/checkout-and-beyond/index.mjs +18 -11
  22. package/dist/schema/checkout-and-beyond/index.mjs.map +2 -2
  23. package/dist/schema/widget-data.js +17 -11
  24. package/dist/schema/widget-data.js.map +2 -2
  25. package/dist/schema/widget-data.mjs +17 -11
  26. package/dist/schema/widget-data.mjs.map +2 -2
  27. package/dist/schema/widgetData.d.ts +27 -27
  28. package/dist/schema/widgets/checkout-and-beyond/regex.d.ts +5 -0
  29. package/dist/schema/widgets/checkout-and-beyond/regex.d.ts.map +1 -1
  30. package/dist/schema/widgets/checkout-and-beyond/root.d.ts +18 -18
  31. package/dist/schema/widgets/checkout-and-beyond/root.d.ts.map +1 -1
  32. package/dist/schema/widgets/checkout-and-beyond/text.d.ts +4 -4
  33. package/dist/schema/widgets/checkout-and-beyond/text.d.ts.map +1 -1
  34. package/dist/schema/widgets/contentBlock.d.ts +9 -9
  35. package/dist/schema/widgets/lineItemEditor.d.ts +9 -9
  36. package/dist/schema/widgets/post-purchase-offer/postPurchaseBlocks.d.ts +18 -18
  37. package/dist/schema/widgets/post-purchase-offer/postPurchaseOffer.d.ts +9 -9
  38. package/dist/schema/widgets/post-purchase-offer/postPurchaseSettings.d.ts +9 -9
  39. package/dist/schema/widgets/post-purchase-offer/postPurchaseWidget.d.ts +9 -9
  40. package/dist/schema/widgets/rebuyButton.d.ts +9 -9
  41. package/dist/server/adsEngine.d.ts +5 -4
  42. package/dist/server/adsEngine.d.ts.map +1 -1
  43. package/dist/server/analytics.d.ts +4 -2
  44. package/dist/server/analytics.d.ts.map +1 -1
  45. package/dist/server/composeOffer.d.ts +1 -1
  46. package/dist/server/composeOffer.d.ts.map +1 -1
  47. package/dist/server/dataSourceResults.d.ts +6 -0
  48. package/dist/server/dataSourceResults.d.ts.map +1 -1
  49. package/dist/server/giftValidation.d.ts +6 -0
  50. package/dist/server/giftValidation.d.ts.map +1 -1
  51. package/dist/server/index.js +133 -58
  52. package/dist/server/index.js.map +2 -2
  53. package/dist/server/index.mjs +133 -58
  54. package/dist/server/index.mjs.map +2 -2
  55. package/dist/server/monetizeOffers.d.ts.map +1 -1
  56. package/dist/server/salvageSections.d.ts.map +1 -1
  57. package/dist/server/shared.d.ts +2 -0
  58. package/dist/server/shared.d.ts.map +1 -1
  59. package/dist/transforms/experiments/resolveExperiment.d.ts.map +1 -1
  60. package/dist/transforms/htmlToTiptap/isValidHref.d.ts +4 -3
  61. package/dist/transforms/htmlToTiptap/isValidHref.d.ts.map +1 -1
  62. package/dist/transforms/index.js +39 -23
  63. package/dist/transforms/index.js.map +2 -2
  64. package/dist/transforms/index.mjs +39 -23
  65. package/dist/transforms/index.mjs.map +2 -2
  66. package/dist/transforms/progressBarV1/convertProgressBarToV2.d.ts.map +1 -1
  67. package/dist/transforms/progressBarV1/types.d.ts +8 -2
  68. package/dist/transforms/progressBarV1/types.d.ts.map +1 -1
  69. package/dist/transforms/smartCart/convertSmartCartProgressBarToV2.d.ts +3 -1
  70. package/dist/transforms/smartCart/convertSmartCartProgressBarToV2.d.ts.map +1 -1
  71. package/package.json +1 -1
@@ -1,6 +1,11 @@
1
1
  /** A gift-with-purchase cart line the client asks the server to validate. */
2
2
  export type GwpGift = {
3
- /** The line's total amount (market currency); a discounted gift is 0. */
3
+ /**
4
+ * The gift line's total in the buyer's MARKET currency, MAJOR units (e.g. `19.99`) — a
5
+ * Function-discounted (free) gift is `0`. Only the zero/non-zero distinction is read
6
+ * (`cost > 0` ⇒ the gift lost its discount), so the exact unit isn't load-bearing; send the
7
+ * Shopify cart-line total as-is.
8
+ */
4
9
  cost: number;
5
10
  /** Whether the Shopify Function discount is currently allocated to the line. */
6
11
  discounted: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/gwp/types.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,MAAM,OAAO,GAAG;IAClB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,UAAU,EAAE,OAAO,CAAC;IACpB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,EAAE,CAAC;IAC1C,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE;YAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,EAAE,CAAC;CAC/D,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,WAAW,GAAG;IACtB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,cAAc,CAAC,EAAE,WAAW,EAAE,CAAC;CAClC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/gwp/types.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,MAAM,OAAO,GAAG;IAClB;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,UAAU,EAAE,OAAO,CAAC;IACpB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,EAAE,CAAC;IAC1C,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE;YAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,EAAE,CAAC;CAC/D,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,WAAW,GAAG;IACtB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,cAAc,CAAC,EAAE,WAAW,EAAE,CAAC;CAClC,CAAC"}
package/dist/index.js CHANGED
@@ -110,6 +110,7 @@ __export(src_exports, {
110
110
  ProgressTierUnit: () => ProgressTierUnit,
111
111
  QuantityInput: () => QuantityInput,
112
112
  REVIEW_LABELS: () => REVIEW_LABELS,
113
+ ROOT_RELATIVE_PATH_REGEX: () => ROOT_RELATIVE_PATH_REGEX,
113
114
  RebuyButton: () => RebuyButton,
114
115
  RebuyButtonV1: () => RebuyButtonV1,
115
116
  RebuyClient: () => RebuyClient,
@@ -1066,8 +1067,25 @@ var CabActiveExperiment = import_zod2.z.object({
1066
1067
  type: import_zod2.z.string()
1067
1068
  });
1068
1069
  var CabShopConfig = import_zod2.z.object({
1069
- activeExperiments: import_zod2.z.array(CabActiveExperiment).catch([]).default([]),
1070
+ /**
1071
+ * Per-element resilient: parse as `unknown[]` (non-array → `[]`), then keep only the experiments that
1072
+ * validate. A single drifted experiment drops itself instead of `.catch`-ing the WHOLE array to `[]` and
1073
+ * silently disabling every live A/B test fleet-wide.
1074
+ */
1075
+ activeExperiments: import_zod2.z.array(import_zod2.z.unknown()).catch([]).default([]).transform(
1076
+ (experiments) => experiments.flatMap((experiment) => {
1077
+ const result = CabActiveExperiment.safeParse(experiment);
1078
+ return result.success ? [result.data] : [];
1079
+ })
1080
+ ),
1070
1081
  apiKey: import_zod2.z.string(),
1082
+ /**
1083
+ * The shop's base-currency ISO code (e.g. `'USD'`). CAB derives the shop minor-unit exponent from it
1084
+ * (`currencyDecimals`) so a Functions-applied fixed discount — whose amount is in shop minor units —
1085
+ * converts to the buyer's currency exactly in a cross-decimal market. `.catch()` like its siblings: a
1086
+ * missing/renamed currency degrades to "unknown" (client falls back to buyer decimals), never a parse fail.
1087
+ */
1088
+ currency: import_zod2.z.string().optional().catch(void 0),
1071
1089
  monetize: import_zod2.z.object({ publisherKey: import_zod2.z.string().nullable() }).nullish().catch(void 0),
1072
1090
  shopId: import_zod2.z.number().optional().catch(void 0)
1073
1091
  });
@@ -1800,6 +1818,7 @@ var import_zod12 = require("zod");
1800
1818
  var ARRAY_INDEX_STRING = /^(0|[1-9]\d*)$/;
1801
1819
  var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
1802
1820
  var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
1821
+ var ROOT_RELATIVE_PATH_REGEX = /^\/(?!\/)/;
1803
1822
  var HTML_TAGS_REGEX = /<\/?[a-zA-Z][^>]*>/g;
1804
1823
 
1805
1824
  // src/schema/widgets/checkout-and-beyond/utils.ts
@@ -1882,7 +1901,12 @@ var TiptapText = import_zod13.z.object({
1882
1901
  import_zod13.z.object({
1883
1902
  attrs: import_zod13.z.object({
1884
1903
  class: import_zod13.z.string().nullable(),
1885
- href: import_zod13.z.union([import_zod13.z.url(), import_zod13.z.literal("#"), import_zod13.z.string().regex(DYNAMIC_TOKEN_REGEX)]),
1904
+ href: import_zod13.z.union([
1905
+ import_zod13.z.url(),
1906
+ import_zod13.z.literal("#"),
1907
+ import_zod13.z.string().regex(DYNAMIC_TOKEN_REGEX),
1908
+ import_zod13.z.string().regex(ROOT_RELATIVE_PATH_REGEX)
1909
+ ]),
1886
1910
  rel: import_zod13.z.string().default("noopener noreferrer nofollow"),
1887
1911
  target: import_zod13.z.string().default("_blank")
1888
1912
  }),
@@ -2558,17 +2582,17 @@ var UI_LABELS = {
2558
2582
  };
2559
2583
 
2560
2584
  // src/schema/widgets/checkout-and-beyond/root.ts
2561
- var localized = () => import_zod29.z.record(import_zod29.z.string(), import_zod29.z.string());
2585
+ var localized = (fallback) => import_zod29.z.record(import_zod29.z.string(), import_zod29.z.string()).default(() => ({ ...fallback })).transform((labels) => Object.keys(labels).length > 0 ? labels : { ...fallback });
2562
2586
  var CABUILabels = import_zod29.z.object({
2563
- currentPage: localized().default(() => ({ ...UI_LABELS.currentPage })),
2564
- loadingOptions: localized().default(() => ({ ...UI_LABELS.loadingOptions })),
2565
- nextPage: localized().default(() => ({ ...UI_LABELS.nextPage })),
2566
- offerDialog: localized().default(() => ({ ...UI_LABELS.offerDialog })),
2567
- page: localized().default(() => ({ ...UI_LABELS.page })),
2568
- previousPage: localized().default(() => ({ ...UI_LABELS.previousPage })),
2569
- selected: localized().default(() => ({ ...UI_LABELS.selected })),
2570
- subscriptionOptions: localized().default(() => ({ ...UI_LABELS.subscriptionOptions })),
2571
- updating: localized().default(() => ({ ...UI_LABELS.updating }))
2587
+ currentPage: localized(UI_LABELS.currentPage),
2588
+ loadingOptions: localized(UI_LABELS.loadingOptions),
2589
+ nextPage: localized(UI_LABELS.nextPage),
2590
+ offerDialog: localized(UI_LABELS.offerDialog),
2591
+ page: localized(UI_LABELS.page),
2592
+ previousPage: localized(UI_LABELS.previousPage),
2593
+ selected: localized(UI_LABELS.selected),
2594
+ subscriptionOptions: localized(UI_LABELS.subscriptionOptions),
2595
+ updating: localized(UI_LABELS.updating)
2572
2596
  }).default(() => ({
2573
2597
  currentPage: { ...UI_LABELS.currentPage },
2574
2598
  loadingOptions: { ...UI_LABELS.loadingOptions },