@rebuy/rebuy 3.59.0 → 3.60.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.
package/dist/index.cjs CHANGED
@@ -172,6 +172,7 @@ __export(src_exports, {
172
172
  OfferPresentationRequestSchema: () => OfferPresentationRequestSchema,
173
173
  OfferPresentationResponseSchema: () => OfferPresentationResponseSchema,
174
174
  OfferProduct: () => OfferProduct,
175
+ OfferProductReviews: () => OfferProductReviews,
175
176
  OfferTransitionRequestSchema: () => OfferTransitionRequestSchema,
176
177
  OfferTransitionResponseSchema: () => OfferTransitionResponseSchema,
177
178
  OffersDirection: () => OffersDirection,
@@ -306,6 +307,7 @@ __export(src_exports, {
306
307
  RuleOperator: () => RuleOperator,
307
308
  RuleType: () => RuleType,
308
309
  RuleVerdict: () => RuleVerdict,
310
+ SALVAGED_SECTION_TYPE: () => SALVAGED_SECTION_TYPE,
309
311
  STATIC_ENDPOINTS: () => STATIC_ENDPOINTS,
310
312
  SWITCH_LABELS: () => SWITCH_LABELS,
311
313
  SectionType: () => SectionType,
@@ -1717,6 +1719,10 @@ var OfferProductVariant = import_zod5.z.object({
1717
1719
  price: import_zod5.z.string(),
1718
1720
  title: import_zod5.z.string()
1719
1721
  });
1722
+ var OfferProductReviews = import_zod5.z.object({
1723
+ rating: import_zod5.z.number().positive().max(5),
1724
+ reviewCount: import_zod5.z.number().int().nonnegative()
1725
+ });
1720
1726
  var OfferProduct = import_zod5.z.object({
1721
1727
  description: import_zod5.z.string().optional(),
1722
1728
  discount: OfferProductDiscount.optional(),
@@ -1732,6 +1738,7 @@ var OfferProduct = import_zod5.z.object({
1732
1738
  link: import_zod5.z.string().optional(),
1733
1739
  metafields: import_zod5.z.array(import_zod5.z.object({ key: import_zod5.z.string(), namespace: import_zod5.z.string(), value: import_zod5.z.string() })).optional(),
1734
1740
  options: import_zod5.z.array(OfferProductOption),
1741
+ reviews: OfferProductReviews.nullish().catch(void 0),
1735
1742
  sellingPlanGroups: import_zod5.z.array(import_zod5.z.object({ requiresSellingPlan: import_zod5.z.boolean().optional() })).optional(),
1736
1743
  title: import_zod5.z.string(),
1737
1744
  /** At least one variant — a zero-variant product renders an offer card with no addable merchandise (no Add CTA). `keepValidProduct` drops it with a `variants` drift signal rather than shipping a dead card. */
@@ -2006,6 +2013,7 @@ var sectionTypes = [
2006
2013
  "variants"
2007
2014
  ];
2008
2015
  var SectionType = freezeEnum(sectionTypes);
2016
+ var SALVAGED_SECTION_TYPE = "unknown";
2009
2017
  var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
2010
2018
  var Spacing = freezeEnum(spacings);
2011
2019
  var textAlignments = ["start", "center", "end"];
@@ -2552,6 +2560,8 @@ var PostPurchaseSettings = import_zod16.z.object({
2552
2560
  declineThisOffer: import_zod16.z.string().default("Decline this offer"),
2553
2561
  free: import_zod16.z.string().optional().default("Free"),
2554
2562
  notAvailable: import_zod16.z.string().optional().default("Not available"),
2563
+ /** Label for the one-time choice beside `subscriptionOption` in the purchase-type selector */
2564
+ oneTimePurchase: import_zod16.z.string().optional().default("One-time Purchase"),
2555
2565
  payNow: import_zod16.z.string().default("Pay Now"),
2556
2566
  payNowUpgradeToSubscription: import_zod16.z.string().optional().default("Upgrade to Subscription"),
2557
2567
  quantity: import_zod16.z.string().default("Quantity"),
@@ -2571,6 +2581,7 @@ var PostPurchaseSettings = import_zod16.z.object({
2571
2581
  declineThisOffer: "Decline this offer",
2572
2582
  free: "Free",
2573
2583
  notAvailable: "Not available",
2584
+ oneTimePurchase: "One-time Purchase",
2574
2585
  payNow: "Pay Now",
2575
2586
  payNowUpgradeToSubscription: "Upgrade to Subscription",
2576
2587
  quantity: "Quantity",
@@ -6893,6 +6904,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
6893
6904
  };
6894
6905
 
6895
6906
  // src/pricing/postPurchaseChangeset.ts
6907
+ var DEFAULT_SHIPPING_TITLE = "Shipping Fees";
6896
6908
  var postPurchaseChangeset = (prepared) => {
6897
6909
  const { selection: selection3, terms } = prepared;
6898
6910
  const subscription = readPostPurchaseSubscription(prepared);
@@ -6928,7 +6940,11 @@ var postPurchaseChangeset = (prepared) => {
6928
6940
  }
6929
6941
  ];
6930
6942
  if (shipping.type === "fixed_amount")
6931
- changes.push({ price: shipping.amount, title: shipping.title, type: "add_shipping_line" });
6943
+ changes.push({
6944
+ price: shipping.amount,
6945
+ title: shipping.title.trim() || DEFAULT_SHIPPING_TITLE,
6946
+ type: "add_shipping_line"
6947
+ });
6932
6948
  return PostPurchaseProductChangeset.parse({ changes });
6933
6949
  };
6934
6950
 
package/dist/index.mjs CHANGED
@@ -1237,6 +1237,10 @@ var OfferProductVariant = z5.object({
1237
1237
  price: z5.string(),
1238
1238
  title: z5.string()
1239
1239
  });
1240
+ var OfferProductReviews = z5.object({
1241
+ rating: z5.number().positive().max(5),
1242
+ reviewCount: z5.number().int().nonnegative()
1243
+ });
1240
1244
  var OfferProduct = z5.object({
1241
1245
  description: z5.string().optional(),
1242
1246
  discount: OfferProductDiscount.optional(),
@@ -1252,6 +1256,7 @@ var OfferProduct = z5.object({
1252
1256
  link: z5.string().optional(),
1253
1257
  metafields: z5.array(z5.object({ key: z5.string(), namespace: z5.string(), value: z5.string() })).optional(),
1254
1258
  options: z5.array(OfferProductOption),
1259
+ reviews: OfferProductReviews.nullish().catch(void 0),
1255
1260
  sellingPlanGroups: z5.array(z5.object({ requiresSellingPlan: z5.boolean().optional() })).optional(),
1256
1261
  title: z5.string(),
1257
1262
  /** At least one variant — a zero-variant product renders an offer card with no addable merchandise (no Add CTA). `keepValidProduct` drops it with a `variants` drift signal rather than shipping a dead card. */
@@ -1526,6 +1531,7 @@ var sectionTypes = [
1526
1531
  "variants"
1527
1532
  ];
1528
1533
  var SectionType = freezeEnum(sectionTypes);
1534
+ var SALVAGED_SECTION_TYPE = "unknown";
1529
1535
  var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
1530
1536
  var Spacing = freezeEnum(spacings);
1531
1537
  var textAlignments = ["start", "center", "end"];
@@ -2072,6 +2078,8 @@ var PostPurchaseSettings = z16.object({
2072
2078
  declineThisOffer: z16.string().default("Decline this offer"),
2073
2079
  free: z16.string().optional().default("Free"),
2074
2080
  notAvailable: z16.string().optional().default("Not available"),
2081
+ /** Label for the one-time choice beside `subscriptionOption` in the purchase-type selector */
2082
+ oneTimePurchase: z16.string().optional().default("One-time Purchase"),
2075
2083
  payNow: z16.string().default("Pay Now"),
2076
2084
  payNowUpgradeToSubscription: z16.string().optional().default("Upgrade to Subscription"),
2077
2085
  quantity: z16.string().default("Quantity"),
@@ -2091,6 +2099,7 @@ var PostPurchaseSettings = z16.object({
2091
2099
  declineThisOffer: "Decline this offer",
2092
2100
  free: "Free",
2093
2101
  notAvailable: "Not available",
2102
+ oneTimePurchase: "One-time Purchase",
2094
2103
  payNow: "Pay Now",
2095
2104
  payNowUpgradeToSubscription: "Upgrade to Subscription",
2096
2105
  quantity: "Quantity",
@@ -6413,6 +6422,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
6413
6422
  };
6414
6423
 
6415
6424
  // src/pricing/postPurchaseChangeset.ts
6425
+ var DEFAULT_SHIPPING_TITLE = "Shipping Fees";
6416
6426
  var postPurchaseChangeset = (prepared) => {
6417
6427
  const { selection: selection3, terms } = prepared;
6418
6428
  const subscription = readPostPurchaseSubscription(prepared);
@@ -6448,7 +6458,11 @@ var postPurchaseChangeset = (prepared) => {
6448
6458
  }
6449
6459
  ];
6450
6460
  if (shipping.type === "fixed_amount")
6451
- changes.push({ price: shipping.amount, title: shipping.title, type: "add_shipping_line" });
6461
+ changes.push({
6462
+ price: shipping.amount,
6463
+ title: shipping.title.trim() || DEFAULT_SHIPPING_TITLE,
6464
+ type: "add_shipping_line"
6465
+ });
6452
6466
  return PostPurchaseProductChangeset.parse({ changes });
6453
6467
  };
6454
6468
 
@@ -6762,6 +6776,7 @@ export {
6762
6776
  OfferPresentationRequestSchema,
6763
6777
  OfferPresentationResponseSchema,
6764
6778
  OfferProduct,
6779
+ OfferProductReviews,
6765
6780
  OfferTransitionRequestSchema,
6766
6781
  OfferTransitionResponseSchema,
6767
6782
  OffersDirection,
@@ -6896,6 +6911,7 @@ export {
6896
6911
  RuleOperator,
6897
6912
  RuleType,
6898
6913
  RuleVerdict,
6914
+ SALVAGED_SECTION_TYPE,
6899
6915
  STATIC_ENDPOINTS,
6900
6916
  SWITCH_LABELS,
6901
6917
  SectionType,
@@ -48,6 +48,7 @@ __export(common_exports, {
48
48
  ResultCountOperator: () => ResultCountOperator,
49
49
  ResultTagOperator: () => ResultTagOperator,
50
50
  ReviewsSize: () => ReviewsSize,
51
+ SALVAGED_SECTION_TYPE: () => SALVAGED_SECTION_TYPE,
51
52
  SectionType: () => SectionType,
52
53
  Spacing: () => Spacing,
53
54
  TextAlignment: () => TextAlignment,
@@ -261,6 +262,7 @@ var sectionTypes = [
261
262
  "variants"
262
263
  ];
263
264
  var SectionType = freezeEnum(sectionTypes);
265
+ var SALVAGED_SECTION_TYPE = "unknown";
264
266
  var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
265
267
  var Spacing = freezeEnum(spacings);
266
268
  var textAlignments = ["start", "center", "end"];
@@ -156,6 +156,7 @@ var sectionTypes = [
156
156
  "variants"
157
157
  ];
158
158
  var SectionType = freezeEnum(sectionTypes);
159
+ var SALVAGED_SECTION_TYPE = "unknown";
159
160
  var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
160
161
  var Spacing = freezeEnum(spacings);
161
162
  var textAlignments = ["start", "center", "end"];
@@ -234,6 +235,7 @@ export {
234
235
  ResultCountOperator,
235
236
  ResultTagOperator,
236
237
  ReviewsSize,
238
+ SALVAGED_SECTION_TYPE,
237
239
  SectionType,
238
240
  Spacing,
239
241
  TextAlignment,
@@ -121,6 +121,7 @@ __export(checkout_and_beyond_exports, {
121
121
  RuleLogicBlock: () => RuleLogicBlock,
122
122
  RuleOperator: () => RuleOperator,
123
123
  RuleType: () => RuleType,
124
+ SALVAGED_SECTION_TYPE: () => SALVAGED_SECTION_TYPE,
124
125
  STATIC_ENDPOINTS: () => STATIC_ENDPOINTS,
125
126
  SWITCH_LABELS: () => SWITCH_LABELS,
126
127
  SectionType: () => SectionType,
@@ -373,6 +374,7 @@ var sectionTypes = [
373
374
  "variants"
374
375
  ];
375
376
  var SectionType = freezeEnum(sectionTypes);
377
+ var SALVAGED_SECTION_TYPE = "unknown";
376
378
  var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
377
379
  var Spacing = freezeEnum(spacings);
378
380
  var textAlignments = ["start", "center", "end"];
@@ -159,6 +159,7 @@ var sectionTypes = [
159
159
  "variants"
160
160
  ];
161
161
  var SectionType = freezeEnum(sectionTypes);
162
+ var SALVAGED_SECTION_TYPE = "unknown";
162
163
  var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
163
164
  var Spacing = freezeEnum(spacings);
164
165
  var textAlignments = ["start", "center", "end"];
@@ -2060,6 +2061,7 @@ export {
2060
2061
  RuleLogicBlock,
2061
2062
  RuleOperator,
2062
2063
  RuleType,
2064
+ SALVAGED_SECTION_TYPE,
2063
2065
  STATIC_ENDPOINTS,
2064
2066
  SWITCH_LABELS,
2065
2067
  SectionType,
@@ -1,4 +1,16 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * The aggregate star rating the proxy projects from the widget's review integration (REB-16699), so the
4
+ * extension never parses provider metafields. Set by `fetchDataSourceResults` after validation: present
5
+ * (`{…}` or `null`) only when a review integration is on. `.catch` keeps an engine field that happens to
6
+ * share the name from ever dropping a product; the projection overwrites it, or strips it when no review
7
+ * integration is on.
8
+ */
9
+ export declare const OfferProductReviews: z.ZodObject<{
10
+ rating: z.ZodNumber;
11
+ reviewCount: z.ZodNumber;
12
+ }, z.core.$strip>;
13
+ export type OfferProductReviews = z.infer<typeof OfferProductReviews>;
2
14
  /**
3
15
  * The lean server-side offer-product schema — exactly the fields the extension's `toProduct` consumes,
4
16
  * with the over-strict validators of the editor-facing `Product` (required `cacheInfo`, ISO
@@ -35,6 +47,10 @@ export declare const OfferProduct: z.ZodObject<{
35
47
  position: z.ZodNumber;
36
48
  values: z.ZodArray<z.ZodString>;
37
49
  }, z.core.$strip>>;
50
+ reviews: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodObject<{
51
+ rating: z.ZodNumber;
52
+ reviewCount: z.ZodNumber;
53
+ }, z.core.$strip>>>>;
38
54
  sellingPlanGroups: z.ZodOptional<z.ZodArray<z.ZodObject<{
39
55
  requiresSellingPlan: z.ZodOptional<z.ZodBoolean>;
40
56
  }, z.core.$strip>>>;
@@ -27,6 +27,7 @@ export declare const PostPurchaseProductSettings: z.ZodObject<{
27
27
  declineThisOffer: z.ZodDefault<z.ZodString>;
28
28
  free: z.ZodDefault<z.ZodOptional<z.ZodString>>;
29
29
  notAvailable: z.ZodDefault<z.ZodOptional<z.ZodString>>;
30
+ oneTimePurchase: z.ZodDefault<z.ZodOptional<z.ZodString>>;
30
31
  payNow: z.ZodDefault<z.ZodString>;
31
32
  payNowUpgradeToSubscription: z.ZodDefault<z.ZodOptional<z.ZodString>>;
32
33
  quantity: z.ZodDefault<z.ZodString>;
@@ -274,6 +274,7 @@ export declare const SectionType: {
274
274
  readonly variants: "variants";
275
275
  readonly image: "image";
276
276
  readonly discount: "discount";
277
+ readonly reviews: "reviews";
277
278
  readonly separator: "separator";
278
279
  readonly text: "text";
279
280
  readonly banner: "banner";
@@ -285,9 +286,17 @@ export declare const SectionType: {
285
286
  readonly offers: "offers";
286
287
  readonly progressBar: "progressBar";
287
288
  readonly quantity: "quantity";
288
- readonly reviews: "reviews";
289
289
  };
290
290
  export type SectionType = (typeof sectionTypes)[number];
291
+ /**
292
+ * The placeholder `sectionType` the server's per-section salvage (`@rebuy/rebuy/server`) writes in place of
293
+ * a section it could not validate and whose real type it would not pass through: a known type with bad data,
294
+ * a missing or non-string `sectionType`, or a raw type that is literally `'unknown'`. Deliberately not a
295
+ * `SectionType`, so every renderer dispatches it to `null`. What the value guarantees is that the server has
296
+ * already reported the section as drift, so a renderer should count it but not report it again as an error.
297
+ * Any other unrecognized type is passed through unchanged (and reported by the server too).
298
+ */
299
+ export declare const SALVAGED_SECTION_TYPE: "unknown";
291
300
  export declare const spacings: readonly ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
292
301
  export declare const Spacing: {
293
302
  readonly none: "none";
@@ -604,6 +604,7 @@ export declare const PostPurchaseOffer: z.ZodDiscriminatedUnion<[z.ZodObject<{
604
604
  declineThisOffer: z.ZodDefault<z.ZodString>;
605
605
  free: z.ZodDefault<z.ZodOptional<z.ZodString>>;
606
606
  notAvailable: z.ZodDefault<z.ZodOptional<z.ZodString>>;
607
+ oneTimePurchase: z.ZodDefault<z.ZodOptional<z.ZodString>>;
607
608
  payNow: z.ZodDefault<z.ZodString>;
608
609
  payNowUpgradeToSubscription: z.ZodDefault<z.ZodOptional<z.ZodString>>;
609
610
  quantity: z.ZodDefault<z.ZodString>;
@@ -583,6 +583,7 @@ export declare const PostPurchaseSettings: z.ZodObject<{
583
583
  declineThisOffer: z.ZodDefault<z.ZodString>;
584
584
  free: z.ZodDefault<z.ZodOptional<z.ZodString>>;
585
585
  notAvailable: z.ZodDefault<z.ZodOptional<z.ZodString>>;
586
+ oneTimePurchase: z.ZodDefault<z.ZodOptional<z.ZodString>>;
586
587
  payNow: z.ZodDefault<z.ZodString>;
587
588
  payNowUpgradeToSubscription: z.ZodDefault<z.ZodOptional<z.ZodString>>;
588
589
  quantity: z.ZodDefault<z.ZodString>;
@@ -601,6 +601,7 @@ export declare const PostPurchaseWidget: z.ZodObject<{
601
601
  declineThisOffer: z.ZodDefault<z.ZodString>;
602
602
  free: z.ZodDefault<z.ZodOptional<z.ZodString>>;
603
603
  notAvailable: z.ZodDefault<z.ZodOptional<z.ZodString>>;
604
+ oneTimePurchase: z.ZodDefault<z.ZodOptional<z.ZodString>>;
604
605
  payNow: z.ZodDefault<z.ZodString>;
605
606
  payNowUpgradeToSubscription: z.ZodDefault<z.ZodOptional<z.ZodString>>;
606
607
  quantity: z.ZodDefault<z.ZodString>;