@rebuy/rebuy 3.49.0 → 3.50.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/server/index.cjs +68 -36
- package/dist/server/index.mjs +68 -36
- package/dist/server/postPurchaseJudgeMeReviews.d.ts +1 -1
- package/dist/server/postPurchaseOkendoReviews.d.ts +1 -1
- package/dist/server/postPurchaseReviewData.d.ts +1 -1
- package/dist/server/postPurchaseReviewFields.d.ts +7 -0
- package/dist/server/postPurchaseReviews.d.ts +9 -2
- package/dist/server/postPurchaseScalarReviews.d.ts +1 -1
- package/dist/server/shared.d.ts +9 -2
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -6635,45 +6635,76 @@ var projectPostPurchaseProductDisplay = (effective, metadata, product) => PostPu
|
|
|
6635
6635
|
});
|
|
6636
6636
|
|
|
6637
6637
|
// src/server/postPurchaseReviewData.ts
|
|
6638
|
-
var
|
|
6638
|
+
var import_zod64 = require("zod");
|
|
6639
6639
|
|
|
6640
6640
|
// src/server/postPurchaseJudgeMeReviews.ts
|
|
6641
|
+
var import_zod61 = require("zod");
|
|
6642
|
+
|
|
6643
|
+
// src/server/postPurchaseReviewFields.ts
|
|
6641
6644
|
var import_zod60 = require("zod");
|
|
6645
|
+
var Field = import_zod60.z.object({ key: import_zod60.z.string(), namespace: import_zod60.z.string(), value: import_zod60.z.unknown().optional() });
|
|
6646
|
+
var reviewFields = (raw) => {
|
|
6647
|
+
const fields4 = import_zod60.z.array(import_zod60.z.unknown()).parse(raw).flatMap((field) => {
|
|
6648
|
+
const parsed = Field.safeParse(field);
|
|
6649
|
+
return parsed.success ? [parsed.data] : [];
|
|
6650
|
+
});
|
|
6651
|
+
return (namespace, key) => fields4.find((field) => field.namespace === namespace && field.key === key);
|
|
6652
|
+
};
|
|
6653
|
+
var ReviewFieldError = class extends Error {
|
|
6654
|
+
constructor(field) {
|
|
6655
|
+
super(`Unreadable review field ${field}`);
|
|
6656
|
+
this.field = field;
|
|
6657
|
+
}
|
|
6658
|
+
};
|
|
6659
|
+
var readReviewField = (field, read) => {
|
|
6660
|
+
try {
|
|
6661
|
+
return read(field.value);
|
|
6662
|
+
} catch {
|
|
6663
|
+
throw new ReviewFieldError(`${field.namespace}.${field.key}`);
|
|
6664
|
+
}
|
|
6665
|
+
};
|
|
6666
|
+
|
|
6667
|
+
// src/server/postPurchaseJudgeMeReviews.ts
|
|
6642
6668
|
var readJudgeMeReviews = (find) => {
|
|
6643
6669
|
const field = find("judgeme", "badge");
|
|
6644
6670
|
if (!field) return null;
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6671
|
+
return readReviewField(field, (value) => {
|
|
6672
|
+
const html = import_zod61.z.string().parse(value);
|
|
6673
|
+
const rating = html.match(/data-average-rating=['"](\d+(?:\.\d+)?)['"]/);
|
|
6674
|
+
const count = html.match(/data-number-of-reviews=['"](\d+)['"]/);
|
|
6675
|
+
if (!rating || !count) throw new Error("Unreadable Judge.me attributes");
|
|
6676
|
+
return {
|
|
6677
|
+
rating: PostPurchaseCommonReviewRating.parse({ value: rating[1] }).value,
|
|
6678
|
+
reviewCount: PostPurchaseReviewCount.parse(count[1])
|
|
6679
|
+
};
|
|
6680
|
+
});
|
|
6653
6681
|
};
|
|
6654
6682
|
|
|
6655
6683
|
// src/server/postPurchaseOkendoReviews.ts
|
|
6656
|
-
var
|
|
6657
|
-
var Summary =
|
|
6684
|
+
var import_zod62 = require("zod");
|
|
6685
|
+
var Summary = import_zod62.z.object({
|
|
6658
6686
|
reviewAverageValue: PostPurchaseCommonReviewRating.shape.value,
|
|
6659
|
-
reviewCount:
|
|
6687
|
+
reviewCount: import_zod62.z.union([PostPurchaseProductReviews.shape.reviewCount, PostPurchaseReviewCount])
|
|
6660
6688
|
});
|
|
6661
6689
|
var readOkendoReviews = (find) => {
|
|
6662
6690
|
const field = find("okendo", "summaryData");
|
|
6663
6691
|
if (!field) return null;
|
|
6664
|
-
const summary = Summary.parse(JSON.parse(
|
|
6692
|
+
const summary = readReviewField(field, (value) => Summary.parse(JSON.parse(import_zod62.z.string().parse(value))));
|
|
6665
6693
|
return { rating: summary.reviewAverageValue, reviewCount: summary.reviewCount };
|
|
6666
6694
|
};
|
|
6667
6695
|
|
|
6668
6696
|
// src/server/postPurchaseScalarReviews.ts
|
|
6669
|
-
var
|
|
6697
|
+
var import_zod63 = require("zod");
|
|
6670
6698
|
var readScalarReviews = (find, namespace, ratingKey, countKey) => {
|
|
6671
6699
|
const rating = find(namespace, ratingKey);
|
|
6672
6700
|
const count = find(namespace, countKey);
|
|
6673
6701
|
if (!rating || !count) return null;
|
|
6674
6702
|
return {
|
|
6675
|
-
rating:
|
|
6676
|
-
|
|
6703
|
+
rating: readReviewField(
|
|
6704
|
+
rating,
|
|
6705
|
+
(value) => PostPurchaseCommonReviewRating.parse({ value: import_zod63.z.string().parse(value) }).value
|
|
6706
|
+
),
|
|
6707
|
+
reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
|
|
6677
6708
|
};
|
|
6678
6709
|
};
|
|
6679
6710
|
|
|
@@ -6682,10 +6713,12 @@ var readStandardReviews = (find) => {
|
|
|
6682
6713
|
const rating = find("reviews", "rating");
|
|
6683
6714
|
const count = find("reviews", "rating_count");
|
|
6684
6715
|
if (!rating || !count) return null;
|
|
6685
|
-
const value = import_zod63.z.string().parse(rating.value);
|
|
6686
6716
|
return {
|
|
6687
|
-
rating:
|
|
6688
|
-
|
|
6717
|
+
rating: readReviewField(rating, (raw) => {
|
|
6718
|
+
const value = import_zod64.z.string().parse(raw);
|
|
6719
|
+
return PostPurchaseCommonReviewRating.parse(/^\d+(?:\.\d+)?$/.test(value) ? { value } : JSON.parse(value)).value;
|
|
6720
|
+
}),
|
|
6721
|
+
reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
|
|
6689
6722
|
};
|
|
6690
6723
|
};
|
|
6691
6724
|
var readPostPurchaseReviewData = (provider, find) => {
|
|
@@ -6702,22 +6735,14 @@ var readPostPurchaseReviewData = (provider, find) => {
|
|
|
6702
6735
|
const count = find("reviews", "rating_count");
|
|
6703
6736
|
if (!rating || !count) return null;
|
|
6704
6737
|
return {
|
|
6705
|
-
rating:
|
|
6706
|
-
|
|
6738
|
+
rating: readReviewField(
|
|
6739
|
+
rating,
|
|
6740
|
+
(value) => PostPurchaseKlaviyoReviewRating.parse(JSON.parse(import_zod64.z.string().parse(value))).value
|
|
6741
|
+
),
|
|
6742
|
+
reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
|
|
6707
6743
|
};
|
|
6708
6744
|
};
|
|
6709
6745
|
|
|
6710
|
-
// src/server/postPurchaseReviewFields.ts
|
|
6711
|
-
var import_zod64 = require("zod");
|
|
6712
|
-
var Field = import_zod64.z.object({ key: import_zod64.z.string(), namespace: import_zod64.z.string(), value: import_zod64.z.unknown().optional() });
|
|
6713
|
-
var reviewFields = (raw) => {
|
|
6714
|
-
const fields4 = import_zod64.z.array(import_zod64.z.unknown()).parse(raw).flatMap((field) => {
|
|
6715
|
-
const parsed = Field.safeParse(field);
|
|
6716
|
-
return parsed.success ? [parsed.data] : [];
|
|
6717
|
-
});
|
|
6718
|
-
return (namespace, key) => fields4.find((field) => field.namespace === namespace && field.key === key);
|
|
6719
|
-
};
|
|
6720
|
-
|
|
6721
6746
|
// src/server/postPurchaseReviewProvider.ts
|
|
6722
6747
|
var import_zod65 = require("zod");
|
|
6723
6748
|
var IntegrationInput = import_zod65.z.record(import_zod65.z.string(), import_zod65.z.unknown()).prefault({});
|
|
@@ -6750,7 +6775,7 @@ var selectPostPurchaseReviewProvider = (raw) => {
|
|
|
6750
6775
|
};
|
|
6751
6776
|
|
|
6752
6777
|
// src/server/postPurchaseReviews.ts
|
|
6753
|
-
var projectPostPurchaseReviews = (settings, metafields, report) => {
|
|
6778
|
+
var projectPostPurchaseReviews = (settings, { id: productId2, metafields }, report) => {
|
|
6754
6779
|
try {
|
|
6755
6780
|
const provider = selectPostPurchaseReviewProvider(settings.integrations);
|
|
6756
6781
|
if (!provider || metafields == null) return null;
|
|
@@ -6766,8 +6791,15 @@ var projectPostPurchaseReviews = (settings, metafields, report) => {
|
|
|
6766
6791
|
strokeColor: styles2.starStrokeColor,
|
|
6767
6792
|
strokeWidth: styles2.strokeWidth
|
|
6768
6793
|
});
|
|
6769
|
-
} catch {
|
|
6770
|
-
report?.(
|
|
6794
|
+
} catch (error) {
|
|
6795
|
+
report?.(
|
|
6796
|
+
error instanceof ReviewFieldError ? {
|
|
6797
|
+
detail: "Unreadable post-purchase reviews metafield",
|
|
6798
|
+
field: error.field,
|
|
6799
|
+
kind: "reviews",
|
|
6800
|
+
productId: productId2
|
|
6801
|
+
} : { detail: "Unreadable post-purchase reviews", kind: "product" }
|
|
6802
|
+
);
|
|
6771
6803
|
return null;
|
|
6772
6804
|
}
|
|
6773
6805
|
};
|
|
@@ -6779,7 +6811,7 @@ var projectPostPurchaseProduct = ({ data, effective, metadata, original }, repor
|
|
|
6779
6811
|
return {
|
|
6780
6812
|
display: {
|
|
6781
6813
|
...projectPostPurchaseProductDisplay(effective, metadata, product),
|
|
6782
|
-
reviews: projectPostPurchaseReviews(effective, product
|
|
6814
|
+
reviews: projectPostPurchaseReviews(effective, product, report)
|
|
6783
6815
|
},
|
|
6784
6816
|
labels: effective.language.global,
|
|
6785
6817
|
product: { ...product, variant: variant2 },
|
package/dist/server/index.mjs
CHANGED
|
@@ -6563,45 +6563,76 @@ var projectPostPurchaseProductDisplay = (effective, metadata, product) => PostPu
|
|
|
6563
6563
|
});
|
|
6564
6564
|
|
|
6565
6565
|
// src/server/postPurchaseReviewData.ts
|
|
6566
|
-
import { z as
|
|
6566
|
+
import { z as z64 } from "zod";
|
|
6567
6567
|
|
|
6568
6568
|
// src/server/postPurchaseJudgeMeReviews.ts
|
|
6569
|
+
import { z as z61 } from "zod";
|
|
6570
|
+
|
|
6571
|
+
// src/server/postPurchaseReviewFields.ts
|
|
6569
6572
|
import { z as z60 } from "zod";
|
|
6573
|
+
var Field = z60.object({ key: z60.string(), namespace: z60.string(), value: z60.unknown().optional() });
|
|
6574
|
+
var reviewFields = (raw) => {
|
|
6575
|
+
const fields4 = z60.array(z60.unknown()).parse(raw).flatMap((field) => {
|
|
6576
|
+
const parsed = Field.safeParse(field);
|
|
6577
|
+
return parsed.success ? [parsed.data] : [];
|
|
6578
|
+
});
|
|
6579
|
+
return (namespace, key) => fields4.find((field) => field.namespace === namespace && field.key === key);
|
|
6580
|
+
};
|
|
6581
|
+
var ReviewFieldError = class extends Error {
|
|
6582
|
+
constructor(field) {
|
|
6583
|
+
super(`Unreadable review field ${field}`);
|
|
6584
|
+
this.field = field;
|
|
6585
|
+
}
|
|
6586
|
+
};
|
|
6587
|
+
var readReviewField = (field, read) => {
|
|
6588
|
+
try {
|
|
6589
|
+
return read(field.value);
|
|
6590
|
+
} catch {
|
|
6591
|
+
throw new ReviewFieldError(`${field.namespace}.${field.key}`);
|
|
6592
|
+
}
|
|
6593
|
+
};
|
|
6594
|
+
|
|
6595
|
+
// src/server/postPurchaseJudgeMeReviews.ts
|
|
6570
6596
|
var readJudgeMeReviews = (find) => {
|
|
6571
6597
|
const field = find("judgeme", "badge");
|
|
6572
6598
|
if (!field) return null;
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6599
|
+
return readReviewField(field, (value) => {
|
|
6600
|
+
const html = z61.string().parse(value);
|
|
6601
|
+
const rating = html.match(/data-average-rating=['"](\d+(?:\.\d+)?)['"]/);
|
|
6602
|
+
const count = html.match(/data-number-of-reviews=['"](\d+)['"]/);
|
|
6603
|
+
if (!rating || !count) throw new Error("Unreadable Judge.me attributes");
|
|
6604
|
+
return {
|
|
6605
|
+
rating: PostPurchaseCommonReviewRating.parse({ value: rating[1] }).value,
|
|
6606
|
+
reviewCount: PostPurchaseReviewCount.parse(count[1])
|
|
6607
|
+
};
|
|
6608
|
+
});
|
|
6581
6609
|
};
|
|
6582
6610
|
|
|
6583
6611
|
// src/server/postPurchaseOkendoReviews.ts
|
|
6584
|
-
import { z as
|
|
6585
|
-
var Summary =
|
|
6612
|
+
import { z as z62 } from "zod";
|
|
6613
|
+
var Summary = z62.object({
|
|
6586
6614
|
reviewAverageValue: PostPurchaseCommonReviewRating.shape.value,
|
|
6587
|
-
reviewCount:
|
|
6615
|
+
reviewCount: z62.union([PostPurchaseProductReviews.shape.reviewCount, PostPurchaseReviewCount])
|
|
6588
6616
|
});
|
|
6589
6617
|
var readOkendoReviews = (find) => {
|
|
6590
6618
|
const field = find("okendo", "summaryData");
|
|
6591
6619
|
if (!field) return null;
|
|
6592
|
-
const summary = Summary.parse(JSON.parse(
|
|
6620
|
+
const summary = readReviewField(field, (value) => Summary.parse(JSON.parse(z62.string().parse(value))));
|
|
6593
6621
|
return { rating: summary.reviewAverageValue, reviewCount: summary.reviewCount };
|
|
6594
6622
|
};
|
|
6595
6623
|
|
|
6596
6624
|
// src/server/postPurchaseScalarReviews.ts
|
|
6597
|
-
import { z as
|
|
6625
|
+
import { z as z63 } from "zod";
|
|
6598
6626
|
var readScalarReviews = (find, namespace, ratingKey, countKey) => {
|
|
6599
6627
|
const rating = find(namespace, ratingKey);
|
|
6600
6628
|
const count = find(namespace, countKey);
|
|
6601
6629
|
if (!rating || !count) return null;
|
|
6602
6630
|
return {
|
|
6603
|
-
rating:
|
|
6604
|
-
|
|
6631
|
+
rating: readReviewField(
|
|
6632
|
+
rating,
|
|
6633
|
+
(value) => PostPurchaseCommonReviewRating.parse({ value: z63.string().parse(value) }).value
|
|
6634
|
+
),
|
|
6635
|
+
reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
|
|
6605
6636
|
};
|
|
6606
6637
|
};
|
|
6607
6638
|
|
|
@@ -6610,10 +6641,12 @@ var readStandardReviews = (find) => {
|
|
|
6610
6641
|
const rating = find("reviews", "rating");
|
|
6611
6642
|
const count = find("reviews", "rating_count");
|
|
6612
6643
|
if (!rating || !count) return null;
|
|
6613
|
-
const value = z63.string().parse(rating.value);
|
|
6614
6644
|
return {
|
|
6615
|
-
rating:
|
|
6616
|
-
|
|
6645
|
+
rating: readReviewField(rating, (raw) => {
|
|
6646
|
+
const value = z64.string().parse(raw);
|
|
6647
|
+
return PostPurchaseCommonReviewRating.parse(/^\d+(?:\.\d+)?$/.test(value) ? { value } : JSON.parse(value)).value;
|
|
6648
|
+
}),
|
|
6649
|
+
reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
|
|
6617
6650
|
};
|
|
6618
6651
|
};
|
|
6619
6652
|
var readPostPurchaseReviewData = (provider, find) => {
|
|
@@ -6630,22 +6663,14 @@ var readPostPurchaseReviewData = (provider, find) => {
|
|
|
6630
6663
|
const count = find("reviews", "rating_count");
|
|
6631
6664
|
if (!rating || !count) return null;
|
|
6632
6665
|
return {
|
|
6633
|
-
rating:
|
|
6634
|
-
|
|
6666
|
+
rating: readReviewField(
|
|
6667
|
+
rating,
|
|
6668
|
+
(value) => PostPurchaseKlaviyoReviewRating.parse(JSON.parse(z64.string().parse(value))).value
|
|
6669
|
+
),
|
|
6670
|
+
reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
|
|
6635
6671
|
};
|
|
6636
6672
|
};
|
|
6637
6673
|
|
|
6638
|
-
// src/server/postPurchaseReviewFields.ts
|
|
6639
|
-
import { z as z64 } from "zod";
|
|
6640
|
-
var Field = z64.object({ key: z64.string(), namespace: z64.string(), value: z64.unknown().optional() });
|
|
6641
|
-
var reviewFields = (raw) => {
|
|
6642
|
-
const fields4 = z64.array(z64.unknown()).parse(raw).flatMap((field) => {
|
|
6643
|
-
const parsed = Field.safeParse(field);
|
|
6644
|
-
return parsed.success ? [parsed.data] : [];
|
|
6645
|
-
});
|
|
6646
|
-
return (namespace, key) => fields4.find((field) => field.namespace === namespace && field.key === key);
|
|
6647
|
-
};
|
|
6648
|
-
|
|
6649
6674
|
// src/server/postPurchaseReviewProvider.ts
|
|
6650
6675
|
import { z as z65 } from "zod";
|
|
6651
6676
|
var IntegrationInput = z65.record(z65.string(), z65.unknown()).prefault({});
|
|
@@ -6678,7 +6703,7 @@ var selectPostPurchaseReviewProvider = (raw) => {
|
|
|
6678
6703
|
};
|
|
6679
6704
|
|
|
6680
6705
|
// src/server/postPurchaseReviews.ts
|
|
6681
|
-
var projectPostPurchaseReviews = (settings, metafields, report) => {
|
|
6706
|
+
var projectPostPurchaseReviews = (settings, { id: productId2, metafields }, report) => {
|
|
6682
6707
|
try {
|
|
6683
6708
|
const provider = selectPostPurchaseReviewProvider(settings.integrations);
|
|
6684
6709
|
if (!provider || metafields == null) return null;
|
|
@@ -6694,8 +6719,15 @@ var projectPostPurchaseReviews = (settings, metafields, report) => {
|
|
|
6694
6719
|
strokeColor: styles2.starStrokeColor,
|
|
6695
6720
|
strokeWidth: styles2.strokeWidth
|
|
6696
6721
|
});
|
|
6697
|
-
} catch {
|
|
6698
|
-
report?.(
|
|
6722
|
+
} catch (error) {
|
|
6723
|
+
report?.(
|
|
6724
|
+
error instanceof ReviewFieldError ? {
|
|
6725
|
+
detail: "Unreadable post-purchase reviews metafield",
|
|
6726
|
+
field: error.field,
|
|
6727
|
+
kind: "reviews",
|
|
6728
|
+
productId: productId2
|
|
6729
|
+
} : { detail: "Unreadable post-purchase reviews", kind: "product" }
|
|
6730
|
+
);
|
|
6699
6731
|
return null;
|
|
6700
6732
|
}
|
|
6701
6733
|
};
|
|
@@ -6707,7 +6739,7 @@ var projectPostPurchaseProduct = ({ data, effective, metadata, original }, repor
|
|
|
6707
6739
|
return {
|
|
6708
6740
|
display: {
|
|
6709
6741
|
...projectPostPurchaseProductDisplay(effective, metadata, product),
|
|
6710
|
-
reviews: projectPostPurchaseReviews(effective, product
|
|
6742
|
+
reviews: projectPostPurchaseReviews(effective, product, report)
|
|
6711
6743
|
},
|
|
6712
6744
|
labels: effective.language.global,
|
|
6713
6745
|
product: { ...product, variant: variant2 },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReviewFields } from '../server/postPurchaseReviewFields';
|
|
2
2
|
/** Read attributes only; merchant badge HTML never enters the prepared display or section tree. */
|
|
3
3
|
export declare const readJudgeMeReviews: (find: ReviewFields) => {
|
|
4
4
|
rating: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReviewFields } from '../server/postPurchaseReviewFields';
|
|
2
2
|
/** Only the selected aggregate's two numeric members enter the prepared review display. */
|
|
3
3
|
export declare const readOkendoReviews: (find: ReviewFields) => {
|
|
4
4
|
rating: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReviewFields } from '../server/postPurchaseReviewFields';
|
|
2
2
|
import type { selectPostPurchaseReviewProvider } from '../server/postPurchaseReviewProvider';
|
|
3
3
|
/**
|
|
4
4
|
* Selection is complete before reading data; a missing selected aggregate cannot fall through. Reviews.io reading
|
|
@@ -5,3 +5,10 @@ export declare const reviewFields: (raw: unknown) => (namespace: string, key: st
|
|
|
5
5
|
value?: unknown;
|
|
6
6
|
} | undefined;
|
|
7
7
|
export type ReviewFields = ReturnType<typeof reviewFields>;
|
|
8
|
+
/** A selected review field whose value failed its read. It names the field (`namespace.key`), never the value. */
|
|
9
|
+
export declare class ReviewFieldError extends Error {
|
|
10
|
+
readonly field: string;
|
|
11
|
+
constructor(field: string);
|
|
12
|
+
}
|
|
13
|
+
/** Reads one matched field's value; any failure is rethrown naming only that field. */
|
|
14
|
+
export declare const readReviewField: <T>(field: NonNullable<ReturnType<ReviewFields>>, read: (value: unknown) => T) => T;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { PostPurchaseProductReviews } from '../schema/postPurchaseProductReviews';
|
|
2
2
|
import type { PostPurchaseProductSettings } from '../schema/postPurchaseProductSettings';
|
|
3
3
|
import type { Reporter } from '../server/shared';
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Reviews are optional display data; neither missing nor malformed aggregates invalidate the offer. A malformed
|
|
6
|
+
* selected review field reports `reviews` drift naming the product and the field (`namespace.key`, never the
|
|
7
|
+
* value); unreadable flags, metafield containers, styles or output stay sanitized `product` drift.
|
|
8
|
+
*/
|
|
9
|
+
export declare const projectPostPurchaseReviews: (settings: PostPurchaseProductSettings, { id: productId, metafields }: {
|
|
10
|
+
id: number;
|
|
11
|
+
metafields?: unknown;
|
|
12
|
+
}, report?: Reporter) => PostPurchaseProductReviews | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReviewFields } from '../server/postPurchaseReviewFields';
|
|
2
2
|
/** Pair absence is ordinary; invalid selected values throw to the single local recovery boundary. */
|
|
3
3
|
export declare const readScalarReviews: (find: ReviewFields, namespace: string, ratingKey: string, countKey: string) => {
|
|
4
4
|
rating: number;
|
package/dist/server/shared.d.ts
CHANGED
|
@@ -28,14 +28,21 @@ export type UpstreamFetch = (path: string, params: Record<string, string>, optio
|
|
|
28
28
|
/**
|
|
29
29
|
* A drift signal the orchestrators emit when a per-item payload salvage drops something: a malformed
|
|
30
30
|
* offer product, an invalid/unknown section stubbed out, an unreadable rule verdict, a shop-config
|
|
31
|
-
* entry the shared schema inerted (`shopConfig`),
|
|
32
|
-
* (`giftMilestones` — the widget's gifts are then kept)
|
|
31
|
+
* entry the shared schema inerted (`shopConfig`), unreadable selectable-gift milestones
|
|
32
|
+
* (`giftMilestones` — the widget's gifts are then kept), or a post-purchase product's malformed selected review
|
|
33
|
+
* metafield (`reviews` — the reviews are then omitted; it names the product and the field, never the value). Distinct from a hard {@link UpstreamError} — the
|
|
33
34
|
* request still succeeds (degraded), so this is the only trace that an upstream contract moved. Optional
|
|
34
35
|
* on {@link ServerContext}; the host (rebuy-api) wires it to its logger.
|
|
35
36
|
*/
|
|
36
37
|
export type ServerDrift = {
|
|
37
38
|
detail: string;
|
|
38
39
|
kind: 'b2bAvailability' | 'dataSource' | 'giftMilestones' | 'monetizeOffer' | 'product' | 'ruleVerdict' | 'section' | 'shopConfig';
|
|
40
|
+
} | {
|
|
41
|
+
detail: string;
|
|
42
|
+
/** The malformed selected review metafield as `namespace.key`; never its value. */
|
|
43
|
+
field: string;
|
|
44
|
+
kind: 'reviews';
|
|
45
|
+
productId: number;
|
|
39
46
|
};
|
|
40
47
|
/** A {@link ServerDrift} sink, as the orchestrators pass it around internally. */
|
|
41
48
|
export type Reporter = (event: ServerDrift) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.50.0",
|
|
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.",
|