@rebuy/rebuy 3.62.0 → 3.62.2

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.
@@ -1433,16 +1433,19 @@ var readOkendoReviews = (find) => {
1433
1433
 
1434
1434
  // src/server/postPurchaseScalarReviews.ts
1435
1435
  var import_zod16 = require("zod");
1436
+ var NO_RATING = "null";
1437
+ var readCount = (value) => PostPurchaseReviewCount.parse(value);
1436
1438
  var readScalarReviews = (find, namespace, ratingKey, countKey) => {
1437
1439
  const rating = find(namespace, ratingKey);
1438
1440
  const count = find(namespace, countKey);
1439
1441
  if (!rating || !count) return null;
1442
+ if (rating.value === NO_RATING && readReviewField(count, readCount) === 0) return null;
1440
1443
  return {
1441
1444
  rating: readReviewField(
1442
1445
  rating,
1443
1446
  (value) => PostPurchaseCommonReviewRating.parse({ value: import_zod16.z.string().parse(value) }).value
1444
1447
  ),
1445
- reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
1448
+ reviewCount: readReviewField(count, readCount)
1446
1449
  };
1447
1450
  };
1448
1451
 
@@ -6210,10 +6213,22 @@ var findMonetizeMarker = (section) => {
6210
6213
  }
6211
6214
  return void 0;
6212
6215
  };
6216
+ var HYDRATION_LEGS = {
6217
+ "/api/v1/offers": "ads-offers",
6218
+ "/api/v1/user/config": "user-config"
6219
+ };
6213
6220
  var hydrateMonetizeMarkers = async (converted, input, ctx, config) => {
6214
6221
  if (!input.monetize || !isCABTree(converted)) return;
6215
6222
  const first = findMonetizeMarker(converted);
6216
6223
  if (!first) return;
6224
+ let leg = "none";
6225
+ const tracked = {
6226
+ ...ctx,
6227
+ fetchUpstream: (path, ...rest) => {
6228
+ leg = HYDRATION_LEGS[path];
6229
+ return ctx.fetchUpstream(path, ...rest);
6230
+ }
6231
+ };
6217
6232
  try {
6218
6233
  const { ads, offers } = await fetchMonetizeOffers(
6219
6234
  {
@@ -6222,14 +6237,15 @@ var hydrateMonetizeMarkers = async (converted, input, ctx, config) => {
6222
6237
  shop: input.shop,
6223
6238
  visitorId: input.monetize.visitorId || input.visitorId
6224
6239
  },
6225
- ctx,
6240
+ tracked,
6226
6241
  config ?? void 0
6227
6242
  );
6228
6243
  first.offers = offers;
6229
6244
  if (ads) first.ads = ads;
6230
6245
  } catch (err) {
6246
+ const message = err instanceof Error ? err.message : String(err);
6231
6247
  ctx.reportDrift?.({
6232
- detail: `inline hydration failed: ${err instanceof Error ? err.message : String(err)}`,
6248
+ detail: `inline hydration failed (${String(leg)}): ${message}`,
6233
6249
  kind: "monetizeOffer"
6234
6250
  });
6235
6251
  }
@@ -1360,16 +1360,19 @@ var readOkendoReviews = (find) => {
1360
1360
 
1361
1361
  // src/server/postPurchaseScalarReviews.ts
1362
1362
  import { z as z16 } from "zod";
1363
+ var NO_RATING = "null";
1364
+ var readCount = (value) => PostPurchaseReviewCount.parse(value);
1363
1365
  var readScalarReviews = (find, namespace, ratingKey, countKey) => {
1364
1366
  const rating = find(namespace, ratingKey);
1365
1367
  const count = find(namespace, countKey);
1366
1368
  if (!rating || !count) return null;
1369
+ if (rating.value === NO_RATING && readReviewField(count, readCount) === 0) return null;
1367
1370
  return {
1368
1371
  rating: readReviewField(
1369
1372
  rating,
1370
1373
  (value) => PostPurchaseCommonReviewRating.parse({ value: z16.string().parse(value) }).value
1371
1374
  ),
1372
- reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
1375
+ reviewCount: readReviewField(count, readCount)
1373
1376
  };
1374
1377
  };
1375
1378
 
@@ -6137,10 +6140,22 @@ var findMonetizeMarker = (section) => {
6137
6140
  }
6138
6141
  return void 0;
6139
6142
  };
6143
+ var HYDRATION_LEGS = {
6144
+ "/api/v1/offers": "ads-offers",
6145
+ "/api/v1/user/config": "user-config"
6146
+ };
6140
6147
  var hydrateMonetizeMarkers = async (converted, input, ctx, config) => {
6141
6148
  if (!input.monetize || !isCABTree(converted)) return;
6142
6149
  const first = findMonetizeMarker(converted);
6143
6150
  if (!first) return;
6151
+ let leg = "none";
6152
+ const tracked = {
6153
+ ...ctx,
6154
+ fetchUpstream: (path, ...rest) => {
6155
+ leg = HYDRATION_LEGS[path];
6156
+ return ctx.fetchUpstream(path, ...rest);
6157
+ }
6158
+ };
6144
6159
  try {
6145
6160
  const { ads, offers } = await fetchMonetizeOffers(
6146
6161
  {
@@ -6149,14 +6164,15 @@ var hydrateMonetizeMarkers = async (converted, input, ctx, config) => {
6149
6164
  shop: input.shop,
6150
6165
  visitorId: input.monetize.visitorId || input.visitorId
6151
6166
  },
6152
- ctx,
6167
+ tracked,
6153
6168
  config ?? void 0
6154
6169
  );
6155
6170
  first.offers = offers;
6156
6171
  if (ads) first.ads = ads;
6157
6172
  } catch (err) {
6173
+ const message = err instanceof Error ? err.message : String(err);
6158
6174
  ctx.reportDrift?.({
6159
- detail: `inline hydration failed: ${err instanceof Error ? err.message : String(err)}`,
6175
+ detail: `inline hydration failed (${String(leg)}): ${message}`,
6160
6176
  kind: "monetizeOffer"
6161
6177
  });
6162
6178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebuy/rebuy",
3
- "version": "3.62.0",
3
+ "version": "3.62.2",
4
4
  "description": "Shared zod schemas, legacy-to-CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers (rebuy-api, admin-nextjs, rebuy-shopify-extensions)",
5
5
  "license": "MIT",
6
6
  "author": "Rebuy, Inc.",