@shoppexio/storefront 1.0.85 → 1.0.87

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.87
4
+
5
+ - `getPage()`, `getPages()` and `getShopReviewsPage()` keep the transport `status` (and `code`) on a failure, like the other modules, so a storefront can tell a page that does not exist (404) from an API it could not reach.
6
+ - `getShopReviewsPage(cursor, { product })` narrows a page to one product by its public id (the catalog `id`). The page's `summary` then counts that product's reviews only, so a product's review list can page on demand with a correct breakdown.
7
+
3
8
  ## 1.0.85
4
9
 
5
10
  - Cart reporting keeps two shared values: the cart state the server confirmed (written only after a 2xx response) and a short-lived in-flight claim that lets another tab skip the `storage` echo while a send runs. Only the newest claim settles: a send whose claim was replaced confirms and clears nothing, and a failed send (network error, non-OK response, or no answer within 10 seconds) writes nothing, so an unsent cart can never look reported. A tab sends its cart states one at a time and in order, dropping a waiting state once a newer one is asked for, so an older cart cannot reach the server after a newer one. Whether a change is already reported is decided when its turn comes, so reverting to the confirmed cart while another state is being sent still goes out.
package/README.md CHANGED
@@ -151,6 +151,8 @@ await refreshLiveUsers();
151
151
  setInterval(refreshLiveUsers, 30_000);
152
152
  ```
153
153
 
154
+ `getShopReviewsPage(cursor, { product })` pages the shop's reviews on demand; pass a product's `id` to page only its reviews, with a `summary` for that product.
155
+
154
156
  `touchStorefrontPresence()` keeps the visitor online but never counts as a page view, so it is safe on a timer. Report page views with `trackPageView()` (once per page load or navigation) and later cart changes with `trackCartActivity(cartValue, itemCount)`, which updates the live visitor map without counting a view.
155
157
 
156
158
  ## Not this package
package/dist/index.cjs CHANGED
@@ -25924,13 +25924,17 @@ function normalizeFeedback(raw, index) {
25924
25924
  created_at
25925
25925
  };
25926
25926
  }
25927
- async function getShopReviewsPage(cursor) {
25927
+ async function getShopReviewsPage(cursor, options = {}) {
25928
25928
  const config2 = getConfig();
25929
25929
  const query = new URLSearchParams();
25930
25930
  query.set("limit", String(REVIEWS_PAGE_LIMIT));
25931
25931
  if (typeof cursor === "string" && cursor.trim().length > 0) {
25932
25932
  query.set("cursor", cursor);
25933
25933
  }
25934
+ const product = typeof options.product === "string" ? options.product.trim() : "";
25935
+ if (product) {
25936
+ query.set("product", product);
25937
+ }
25934
25938
  const querySuffix = `?${query.toString()}`;
25935
25939
  const response = await get(
25936
25940
  `${buildEndpoint("/v1/storefront/feedback/shop/:storeSlug", {
@@ -25938,7 +25942,7 @@ async function getShopReviewsPage(cursor) {
25938
25942
  })}${querySuffix}`,
25939
25943
  {
25940
25944
  cache: {
25941
- key: `reviews:${config2.storeSlug}:${cursor ?? "start"}:${REVIEWS_PAGE_LIMIT}`,
25945
+ key: `reviews:${config2.storeSlug}:${product || "all"}:${cursor ?? "start"}:${REVIEWS_PAGE_LIMIT}`,
25942
25946
  ttl: REVIEWS_CACHE_TTL,
25943
25947
  staleWhileRevalidate: true
25944
25948
  }
@@ -25953,10 +25957,7 @@ async function getShopReviewsPage(cursor) {
25953
25957
  }
25954
25958
  };
25955
25959
  }
25956
- return {
25957
- success: false,
25958
- message: response.message
25959
- };
25960
+ return forwardFailure(response);
25960
25961
  }
25961
25962
  async function getShopReviews() {
25962
25963
  const allFeedback = [];
@@ -26426,10 +26427,7 @@ async function getPages() {
26426
26427
  data: response.data.pages
26427
26428
  };
26428
26429
  }
26429
- return {
26430
- success: false,
26431
- message: response.message
26432
- };
26430
+ return forwardFailure(response);
26433
26431
  }
26434
26432
  async function getPage(slug) {
26435
26433
  const config2 = getConfig();
@@ -26452,10 +26450,7 @@ async function getPage(slug) {
26452
26450
  data: response.data.page
26453
26451
  };
26454
26452
  }
26455
- return {
26456
- success: false,
26457
- message: response.message
26458
- };
26453
+ return forwardFailure(response);
26459
26454
  }
26460
26455
 
26461
26456
  // ../sdk/src/modules/navigation.ts