@rebuy/rebuy 2.30.0-rc.4 → 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 (60) 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 +29 -12
  4. package/dist/index.js.map +2 -2
  5. package/dist/index.mjs +29 -12
  6. package/dist/index.mjs.map +2 -2
  7. package/dist/schema/cabShopConfig.d.ts +20 -20
  8. package/dist/schema/cabShopConfig.d.ts.map +1 -1
  9. package/dist/schema/checkout-and-beyond/index.js +18 -11
  10. package/dist/schema/checkout-and-beyond/index.js.map +2 -2
  11. package/dist/schema/checkout-and-beyond/index.mjs +18 -11
  12. package/dist/schema/checkout-and-beyond/index.mjs.map +2 -2
  13. package/dist/schema/widget-data.js +17 -11
  14. package/dist/schema/widget-data.js.map +2 -2
  15. package/dist/schema/widget-data.mjs +17 -11
  16. package/dist/schema/widget-data.mjs.map +2 -2
  17. package/dist/schema/widgetData.d.ts +27 -27
  18. package/dist/schema/widgets/checkout-and-beyond/regex.d.ts +5 -0
  19. package/dist/schema/widgets/checkout-and-beyond/regex.d.ts.map +1 -1
  20. package/dist/schema/widgets/checkout-and-beyond/root.d.ts +18 -18
  21. package/dist/schema/widgets/checkout-and-beyond/root.d.ts.map +1 -1
  22. package/dist/schema/widgets/checkout-and-beyond/text.d.ts +4 -4
  23. package/dist/schema/widgets/checkout-and-beyond/text.d.ts.map +1 -1
  24. package/dist/schema/widgets/contentBlock.d.ts +9 -9
  25. package/dist/schema/widgets/lineItemEditor.d.ts +9 -9
  26. package/dist/schema/widgets/post-purchase-offer/postPurchaseBlocks.d.ts +18 -18
  27. package/dist/schema/widgets/post-purchase-offer/postPurchaseOffer.d.ts +9 -9
  28. package/dist/schema/widgets/post-purchase-offer/postPurchaseSettings.d.ts +9 -9
  29. package/dist/schema/widgets/post-purchase-offer/postPurchaseWidget.d.ts +9 -9
  30. package/dist/schema/widgets/rebuyButton.d.ts +9 -9
  31. package/dist/server/adsEngine.d.ts +5 -4
  32. package/dist/server/adsEngine.d.ts.map +1 -1
  33. package/dist/server/analytics.d.ts +4 -2
  34. package/dist/server/analytics.d.ts.map +1 -1
  35. package/dist/server/composeOffer.d.ts +1 -1
  36. package/dist/server/composeOffer.d.ts.map +1 -1
  37. package/dist/server/dataSourceResults.d.ts.map +1 -1
  38. package/dist/server/giftValidation.d.ts +6 -0
  39. package/dist/server/giftValidation.d.ts.map +1 -1
  40. package/dist/server/index.js +124 -57
  41. package/dist/server/index.js.map +2 -2
  42. package/dist/server/index.mjs +124 -57
  43. package/dist/server/index.mjs.map +2 -2
  44. package/dist/server/monetizeOffers.d.ts.map +1 -1
  45. package/dist/server/salvageSections.d.ts.map +1 -1
  46. package/dist/server/shared.d.ts +2 -0
  47. package/dist/server/shared.d.ts.map +1 -1
  48. package/dist/transforms/experiments/resolveExperiment.d.ts.map +1 -1
  49. package/dist/transforms/htmlToTiptap/isValidHref.d.ts +4 -3
  50. package/dist/transforms/htmlToTiptap/isValidHref.d.ts.map +1 -1
  51. package/dist/transforms/index.js +39 -23
  52. package/dist/transforms/index.js.map +2 -2
  53. package/dist/transforms/index.mjs +39 -23
  54. package/dist/transforms/index.mjs.map +2 -2
  55. package/dist/transforms/progressBarV1/convertProgressBarToV2.d.ts.map +1 -1
  56. package/dist/transforms/progressBarV1/types.d.ts +8 -2
  57. package/dist/transforms/progressBarV1/types.d.ts.map +1 -1
  58. package/dist/transforms/smartCart/convertSmartCartProgressBarToV2.d.ts +3 -1
  59. package/dist/transforms/smartCart/convertSmartCartProgressBarToV2.d.ts.map +1 -1
  60. 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,7 +1067,17 @@ 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(),
1071
1082
  /**
1072
1083
  * The shop's base-currency ISO code (e.g. `'USD'`). CAB derives the shop minor-unit exponent from it
@@ -1807,6 +1818,7 @@ var import_zod12 = require("zod");
1807
1818
  var ARRAY_INDEX_STRING = /^(0|[1-9]\d*)$/;
1808
1819
  var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
1809
1820
  var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
1821
+ var ROOT_RELATIVE_PATH_REGEX = /^\/(?!\/)/;
1810
1822
  var HTML_TAGS_REGEX = /<\/?[a-zA-Z][^>]*>/g;
1811
1823
 
1812
1824
  // src/schema/widgets/checkout-and-beyond/utils.ts
@@ -1889,7 +1901,12 @@ var TiptapText = import_zod13.z.object({
1889
1901
  import_zod13.z.object({
1890
1902
  attrs: import_zod13.z.object({
1891
1903
  class: import_zod13.z.string().nullable(),
1892
- 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
+ ]),
1893
1910
  rel: import_zod13.z.string().default("noopener noreferrer nofollow"),
1894
1911
  target: import_zod13.z.string().default("_blank")
1895
1912
  }),
@@ -2565,17 +2582,17 @@ var UI_LABELS = {
2565
2582
  };
2566
2583
 
2567
2584
  // src/schema/widgets/checkout-and-beyond/root.ts
2568
- 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 });
2569
2586
  var CABUILabels = import_zod29.z.object({
2570
- currentPage: localized().default(() => ({ ...UI_LABELS.currentPage })),
2571
- loadingOptions: localized().default(() => ({ ...UI_LABELS.loadingOptions })),
2572
- nextPage: localized().default(() => ({ ...UI_LABELS.nextPage })),
2573
- offerDialog: localized().default(() => ({ ...UI_LABELS.offerDialog })),
2574
- page: localized().default(() => ({ ...UI_LABELS.page })),
2575
- previousPage: localized().default(() => ({ ...UI_LABELS.previousPage })),
2576
- selected: localized().default(() => ({ ...UI_LABELS.selected })),
2577
- subscriptionOptions: localized().default(() => ({ ...UI_LABELS.subscriptionOptions })),
2578
- 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)
2579
2596
  }).default(() => ({
2580
2597
  currentPage: { ...UI_LABELS.currentPage },
2581
2598
  loadingOptions: { ...UI_LABELS.loadingOptions },