@rebuy/rebuy 3.43.0 → 3.43.1
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/server/index.cjs
CHANGED
|
@@ -6537,13 +6537,24 @@ var readScalarReviews = (find, namespace, ratingKey, countKey) => {
|
|
|
6537
6537
|
};
|
|
6538
6538
|
|
|
6539
6539
|
// src/server/postPurchaseReviewData.ts
|
|
6540
|
+
var readStandardReviews = (find) => {
|
|
6541
|
+
const rating = find("reviews", "rating");
|
|
6542
|
+
const count = find("reviews", "rating_count");
|
|
6543
|
+
if (!rating || !count) return null;
|
|
6544
|
+
const value = import_zod63.z.string().parse(rating.value);
|
|
6545
|
+
return {
|
|
6546
|
+
rating: PostPurchaseCommonReviewRating.parse(/^\d+(?:\.\d+)?$/.test(value) ? { value } : JSON.parse(value)).value,
|
|
6547
|
+
reviewCount: PostPurchaseReviewCount.parse(count.value)
|
|
6548
|
+
};
|
|
6549
|
+
};
|
|
6540
6550
|
var readPostPurchaseReviewData = (provider, find) => {
|
|
6541
6551
|
if (provider === "yotpo") return readScalarReviews(find, "yotpo", "reviews_average", "reviews_count");
|
|
6542
6552
|
if (provider === "stamped") return readScalarReviews(find, "stamped", "reviews_average", "reviews_count");
|
|
6543
6553
|
if (provider === "judgeme") return readJudgeMeReviews(find);
|
|
6544
6554
|
if (provider === "okendo") return readOkendoReviews(find);
|
|
6545
6555
|
if (provider === "opinew") return readScalarReviews(find, "opinew_metafields", "reviews_average", "reviews_count");
|
|
6546
|
-
if (provider === "reviewsio")
|
|
6556
|
+
if (provider === "reviewsio")
|
|
6557
|
+
return readScalarReviews(find, "reviewscouk", "rating", "total") ?? readStandardReviews(find);
|
|
6547
6558
|
if (provider === "loox") return readScalarReviews(find, "loox", "avg_rating", "num_reviews");
|
|
6548
6559
|
if (provider === "junip") return readScalarReviews(find, "junip", "rating_average", "rating_count");
|
|
6549
6560
|
const rating = find("reviews", "rating");
|
package/dist/server/index.mjs
CHANGED
|
@@ -6466,13 +6466,24 @@ var readScalarReviews = (find, namespace, ratingKey, countKey) => {
|
|
|
6466
6466
|
};
|
|
6467
6467
|
|
|
6468
6468
|
// src/server/postPurchaseReviewData.ts
|
|
6469
|
+
var readStandardReviews = (find) => {
|
|
6470
|
+
const rating = find("reviews", "rating");
|
|
6471
|
+
const count = find("reviews", "rating_count");
|
|
6472
|
+
if (!rating || !count) return null;
|
|
6473
|
+
const value = z63.string().parse(rating.value);
|
|
6474
|
+
return {
|
|
6475
|
+
rating: PostPurchaseCommonReviewRating.parse(/^\d+(?:\.\d+)?$/.test(value) ? { value } : JSON.parse(value)).value,
|
|
6476
|
+
reviewCount: PostPurchaseReviewCount.parse(count.value)
|
|
6477
|
+
};
|
|
6478
|
+
};
|
|
6469
6479
|
var readPostPurchaseReviewData = (provider, find) => {
|
|
6470
6480
|
if (provider === "yotpo") return readScalarReviews(find, "yotpo", "reviews_average", "reviews_count");
|
|
6471
6481
|
if (provider === "stamped") return readScalarReviews(find, "stamped", "reviews_average", "reviews_count");
|
|
6472
6482
|
if (provider === "judgeme") return readJudgeMeReviews(find);
|
|
6473
6483
|
if (provider === "okendo") return readOkendoReviews(find);
|
|
6474
6484
|
if (provider === "opinew") return readScalarReviews(find, "opinew_metafields", "reviews_average", "reviews_count");
|
|
6475
|
-
if (provider === "reviewsio")
|
|
6485
|
+
if (provider === "reviewsio")
|
|
6486
|
+
return readScalarReviews(find, "reviewscouk", "rating", "total") ?? readStandardReviews(find);
|
|
6476
6487
|
if (provider === "loox") return readScalarReviews(find, "loox", "avg_rating", "num_reviews");
|
|
6477
6488
|
if (provider === "junip") return readScalarReviews(find, "junip", "rating_average", "rating_count");
|
|
6478
6489
|
const rating = find("reviews", "rating");
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ReviewFields } from '../server/postPurchaseReviewFields';
|
|
2
2
|
import type { selectPostPurchaseReviewProvider } from '../server/postPurchaseReviewProvider';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Selection is complete before reading data; a missing selected aggregate cannot fall through. Reviews.io reading
|
|
5
|
+
* its own fields before Shopify's standard ones is one provider's data, not a fall-through: an incomplete reviewscouk
|
|
6
|
+
* pair is unusable and reads as absent, while a complete but malformed one throws rather than falling back.
|
|
7
|
+
*/
|
|
4
8
|
export declare const readPostPurchaseReviewData: (provider: NonNullable<ReturnType<typeof selectPostPurchaseReviewProvider>>, find: ReviewFields) => {
|
|
5
9
|
rating: number;
|
|
6
10
|
reviewCount: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.43.
|
|
3
|
+
"version": "3.43.1",
|
|
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.",
|