brainerce 1.24.0 → 1.25.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/index.d.mts +51 -7
- package/dist/index.d.ts +51 -7
- package/dist/index.js +68 -3
- package/dist/index.mjs +68 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -353,12 +353,25 @@ interface ProductReviewAdmin extends ProductReview {
|
|
|
353
353
|
orderId: string | null;
|
|
354
354
|
updatedAt: string;
|
|
355
355
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Body for customer-authenticated submit / update.
|
|
358
|
+
* Author name + email are derived server-side from the customer profile.
|
|
359
|
+
*/
|
|
360
|
+
interface WriteProductReviewInput {
|
|
359
361
|
rating: number;
|
|
360
362
|
body?: string;
|
|
361
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Returned by `client.getMyProductReview(productId)`. Tells the storefront which
|
|
366
|
+
* UI to render: sign-in / not-eligible / submit / edit.
|
|
367
|
+
*/
|
|
368
|
+
interface MyProductReview {
|
|
369
|
+
eligible: boolean;
|
|
370
|
+
/** Machine-readable reason when not eligible. null when eligible=true. */
|
|
371
|
+
reason: 'no_eligible_order' | 'reviews_disabled' | 'product_not_found' | null;
|
|
372
|
+
/** The customer's existing review for this product, or null. */
|
|
373
|
+
myReview: ProductReview | null;
|
|
374
|
+
}
|
|
362
375
|
interface ProductImage {
|
|
363
376
|
url: string;
|
|
364
377
|
position?: number;
|
|
@@ -6128,21 +6141,52 @@ declare class BrainerceClient {
|
|
|
6128
6141
|
page?: number;
|
|
6129
6142
|
limit?: number;
|
|
6130
6143
|
}): Promise<PaginatedResponse<ProductReview>>;
|
|
6144
|
+
/**
|
|
6145
|
+
* Get the current customer's review state for a product (storefront / sales-channel modes).
|
|
6146
|
+
* Requires a customer token (`setCustomerToken(...)` after login).
|
|
6147
|
+
*
|
|
6148
|
+
* Returns whether the customer is *eligible* to review (only purchasers are),
|
|
6149
|
+
* and their existing review for this product if any.
|
|
6150
|
+
*
|
|
6151
|
+
* @example
|
|
6152
|
+
* ```typescript
|
|
6153
|
+
* const { eligible, reason, myReview } = await client.getMyProductReview('prod_123');
|
|
6154
|
+
* if (!eligible) showMessage(reason); // 'no_eligible_order' | 'reviews_disabled' | …
|
|
6155
|
+
* else if (myReview) renderEditForm(myReview);
|
|
6156
|
+
* else renderSubmitForm();
|
|
6157
|
+
* ```
|
|
6158
|
+
*/
|
|
6159
|
+
getMyProductReview(productId: string): Promise<MyProductReview>;
|
|
6131
6160
|
/**
|
|
6132
6161
|
* Submit a customer review for a product (storefront / sales-channel modes).
|
|
6133
|
-
*
|
|
6162
|
+
* Requires customer authentication AND that the customer has purchased the
|
|
6163
|
+
* product (SHIPPED for physical, PAID for downloadable).
|
|
6164
|
+
*
|
|
6165
|
+
* 403 `no_eligible_order` if the customer didn't purchase the product.
|
|
6166
|
+
* 409 `Conflict` if they already submitted a review (use `updateMyProductReview` instead).
|
|
6167
|
+
*
|
|
6168
|
+
* Author name + email are derived server-side from the customer profile.
|
|
6134
6169
|
*
|
|
6135
6170
|
* @example
|
|
6136
6171
|
* ```typescript
|
|
6137
6172
|
* const review = await client.submitProductReview('prod_123', {
|
|
6138
|
-
* authorName: 'Jane Doe',
|
|
6139
|
-
* authorEmail: 'jane@example.com',
|
|
6140
6173
|
* rating: 5,
|
|
6141
6174
|
* body: 'Loved it!',
|
|
6142
6175
|
* });
|
|
6143
6176
|
* ```
|
|
6144
6177
|
*/
|
|
6145
|
-
submitProductReview(productId: string, input:
|
|
6178
|
+
submitProductReview(productId: string, input: WriteProductReviewInput): Promise<ProductReview>;
|
|
6179
|
+
/**
|
|
6180
|
+
* Edit your own review on a product (storefront / sales-channel modes).
|
|
6181
|
+
* Only updates rating + body; the author name/email and verifiedPurchase flag
|
|
6182
|
+
* are preserved from the original submit.
|
|
6183
|
+
*/
|
|
6184
|
+
updateMyProductReview(productId: string, input: WriteProductReviewInput): Promise<ProductReview>;
|
|
6185
|
+
/**
|
|
6186
|
+
* Delete your own review on a product (storefront / sales-channel modes).
|
|
6187
|
+
* After deletion the customer is free to submit a new review (subject to eligibility).
|
|
6188
|
+
*/
|
|
6189
|
+
deleteMyProductReview(productId: string): Promise<void>;
|
|
6146
6190
|
/**
|
|
6147
6191
|
* Admin: list all reviews for a product (incl. hidden). Requires API key with `reviews:read`.
|
|
6148
6192
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -353,12 +353,25 @@ interface ProductReviewAdmin extends ProductReview {
|
|
|
353
353
|
orderId: string | null;
|
|
354
354
|
updatedAt: string;
|
|
355
355
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Body for customer-authenticated submit / update.
|
|
358
|
+
* Author name + email are derived server-side from the customer profile.
|
|
359
|
+
*/
|
|
360
|
+
interface WriteProductReviewInput {
|
|
359
361
|
rating: number;
|
|
360
362
|
body?: string;
|
|
361
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Returned by `client.getMyProductReview(productId)`. Tells the storefront which
|
|
366
|
+
* UI to render: sign-in / not-eligible / submit / edit.
|
|
367
|
+
*/
|
|
368
|
+
interface MyProductReview {
|
|
369
|
+
eligible: boolean;
|
|
370
|
+
/** Machine-readable reason when not eligible. null when eligible=true. */
|
|
371
|
+
reason: 'no_eligible_order' | 'reviews_disabled' | 'product_not_found' | null;
|
|
372
|
+
/** The customer's existing review for this product, or null. */
|
|
373
|
+
myReview: ProductReview | null;
|
|
374
|
+
}
|
|
362
375
|
interface ProductImage {
|
|
363
376
|
url: string;
|
|
364
377
|
position?: number;
|
|
@@ -6128,21 +6141,52 @@ declare class BrainerceClient {
|
|
|
6128
6141
|
page?: number;
|
|
6129
6142
|
limit?: number;
|
|
6130
6143
|
}): Promise<PaginatedResponse<ProductReview>>;
|
|
6144
|
+
/**
|
|
6145
|
+
* Get the current customer's review state for a product (storefront / sales-channel modes).
|
|
6146
|
+
* Requires a customer token (`setCustomerToken(...)` after login).
|
|
6147
|
+
*
|
|
6148
|
+
* Returns whether the customer is *eligible* to review (only purchasers are),
|
|
6149
|
+
* and their existing review for this product if any.
|
|
6150
|
+
*
|
|
6151
|
+
* @example
|
|
6152
|
+
* ```typescript
|
|
6153
|
+
* const { eligible, reason, myReview } = await client.getMyProductReview('prod_123');
|
|
6154
|
+
* if (!eligible) showMessage(reason); // 'no_eligible_order' | 'reviews_disabled' | …
|
|
6155
|
+
* else if (myReview) renderEditForm(myReview);
|
|
6156
|
+
* else renderSubmitForm();
|
|
6157
|
+
* ```
|
|
6158
|
+
*/
|
|
6159
|
+
getMyProductReview(productId: string): Promise<MyProductReview>;
|
|
6131
6160
|
/**
|
|
6132
6161
|
* Submit a customer review for a product (storefront / sales-channel modes).
|
|
6133
|
-
*
|
|
6162
|
+
* Requires customer authentication AND that the customer has purchased the
|
|
6163
|
+
* product (SHIPPED for physical, PAID for downloadable).
|
|
6164
|
+
*
|
|
6165
|
+
* 403 `no_eligible_order` if the customer didn't purchase the product.
|
|
6166
|
+
* 409 `Conflict` if they already submitted a review (use `updateMyProductReview` instead).
|
|
6167
|
+
*
|
|
6168
|
+
* Author name + email are derived server-side from the customer profile.
|
|
6134
6169
|
*
|
|
6135
6170
|
* @example
|
|
6136
6171
|
* ```typescript
|
|
6137
6172
|
* const review = await client.submitProductReview('prod_123', {
|
|
6138
|
-
* authorName: 'Jane Doe',
|
|
6139
|
-
* authorEmail: 'jane@example.com',
|
|
6140
6173
|
* rating: 5,
|
|
6141
6174
|
* body: 'Loved it!',
|
|
6142
6175
|
* });
|
|
6143
6176
|
* ```
|
|
6144
6177
|
*/
|
|
6145
|
-
submitProductReview(productId: string, input:
|
|
6178
|
+
submitProductReview(productId: string, input: WriteProductReviewInput): Promise<ProductReview>;
|
|
6179
|
+
/**
|
|
6180
|
+
* Edit your own review on a product (storefront / sales-channel modes).
|
|
6181
|
+
* Only updates rating + body; the author name/email and verifiedPurchase flag
|
|
6182
|
+
* are preserved from the original submit.
|
|
6183
|
+
*/
|
|
6184
|
+
updateMyProductReview(productId: string, input: WriteProductReviewInput): Promise<ProductReview>;
|
|
6185
|
+
/**
|
|
6186
|
+
* Delete your own review on a product (storefront / sales-channel modes).
|
|
6187
|
+
* After deletion the customer is free to submit a new review (subject to eligibility).
|
|
6188
|
+
*/
|
|
6189
|
+
deleteMyProductReview(productId: string): Promise<void>;
|
|
6146
6190
|
/**
|
|
6147
6191
|
* Admin: list all reviews for a product (incl. hidden). Requires API key with `reviews:read`.
|
|
6148
6192
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2825,15 +2825,43 @@ var BrainerceClient = class {
|
|
|
2825
2825
|
}
|
|
2826
2826
|
throw new BrainerceError("listProductReviews() requires vibe-coded or storefront mode", 400);
|
|
2827
2827
|
}
|
|
2828
|
+
/**
|
|
2829
|
+
* Get the current customer's review state for a product (storefront / sales-channel modes).
|
|
2830
|
+
* Requires a customer token (`setCustomerToken(...)` after login).
|
|
2831
|
+
*
|
|
2832
|
+
* Returns whether the customer is *eligible* to review (only purchasers are),
|
|
2833
|
+
* and their existing review for this product if any.
|
|
2834
|
+
*
|
|
2835
|
+
* @example
|
|
2836
|
+
* ```typescript
|
|
2837
|
+
* const { eligible, reason, myReview } = await client.getMyProductReview('prod_123');
|
|
2838
|
+
* if (!eligible) showMessage(reason); // 'no_eligible_order' | 'reviews_disabled' | …
|
|
2839
|
+
* else if (myReview) renderEditForm(myReview);
|
|
2840
|
+
* else renderSubmitForm();
|
|
2841
|
+
* ```
|
|
2842
|
+
*/
|
|
2843
|
+
async getMyProductReview(productId) {
|
|
2844
|
+
if (this.isVibeCodedMode()) {
|
|
2845
|
+
return this.vibeCodedRequest("GET", `/products/${productId}/reviews/me`);
|
|
2846
|
+
}
|
|
2847
|
+
if (this.storeId && !this.apiKey) {
|
|
2848
|
+
return this.storefrontRequest("GET", `/products/${productId}/reviews/me`);
|
|
2849
|
+
}
|
|
2850
|
+
throw new BrainerceError("getMyProductReview() requires vibe-coded or storefront mode", 400);
|
|
2851
|
+
}
|
|
2828
2852
|
/**
|
|
2829
2853
|
* Submit a customer review for a product (storefront / sales-channel modes).
|
|
2830
|
-
*
|
|
2854
|
+
* Requires customer authentication AND that the customer has purchased the
|
|
2855
|
+
* product (SHIPPED for physical, PAID for downloadable).
|
|
2856
|
+
*
|
|
2857
|
+
* 403 `no_eligible_order` if the customer didn't purchase the product.
|
|
2858
|
+
* 409 `Conflict` if they already submitted a review (use `updateMyProductReview` instead).
|
|
2859
|
+
*
|
|
2860
|
+
* Author name + email are derived server-side from the customer profile.
|
|
2831
2861
|
*
|
|
2832
2862
|
* @example
|
|
2833
2863
|
* ```typescript
|
|
2834
2864
|
* const review = await client.submitProductReview('prod_123', {
|
|
2835
|
-
* authorName: 'Jane Doe',
|
|
2836
|
-
* authorEmail: 'jane@example.com',
|
|
2837
2865
|
* rating: 5,
|
|
2838
2866
|
* body: 'Loved it!',
|
|
2839
2867
|
* });
|
|
@@ -2848,6 +2876,43 @@ var BrainerceClient = class {
|
|
|
2848
2876
|
}
|
|
2849
2877
|
throw new BrainerceError("submitProductReview() requires vibe-coded or storefront mode", 400);
|
|
2850
2878
|
}
|
|
2879
|
+
/**
|
|
2880
|
+
* Edit your own review on a product (storefront / sales-channel modes).
|
|
2881
|
+
* Only updates rating + body; the author name/email and verifiedPurchase flag
|
|
2882
|
+
* are preserved from the original submit.
|
|
2883
|
+
*/
|
|
2884
|
+
async updateMyProductReview(productId, input) {
|
|
2885
|
+
if (this.isVibeCodedMode()) {
|
|
2886
|
+
return this.vibeCodedRequest(
|
|
2887
|
+
"PATCH",
|
|
2888
|
+
`/products/${productId}/reviews/me`,
|
|
2889
|
+
input
|
|
2890
|
+
);
|
|
2891
|
+
}
|
|
2892
|
+
if (this.storeId && !this.apiKey) {
|
|
2893
|
+
return this.storefrontRequest(
|
|
2894
|
+
"PATCH",
|
|
2895
|
+
`/products/${productId}/reviews/me`,
|
|
2896
|
+
input
|
|
2897
|
+
);
|
|
2898
|
+
}
|
|
2899
|
+
throw new BrainerceError("updateMyProductReview() requires vibe-coded or storefront mode", 400);
|
|
2900
|
+
}
|
|
2901
|
+
/**
|
|
2902
|
+
* Delete your own review on a product (storefront / sales-channel modes).
|
|
2903
|
+
* After deletion the customer is free to submit a new review (subject to eligibility).
|
|
2904
|
+
*/
|
|
2905
|
+
async deleteMyProductReview(productId) {
|
|
2906
|
+
if (this.isVibeCodedMode()) {
|
|
2907
|
+
await this.vibeCodedRequest("DELETE", `/products/${productId}/reviews/me`);
|
|
2908
|
+
return;
|
|
2909
|
+
}
|
|
2910
|
+
if (this.storeId && !this.apiKey) {
|
|
2911
|
+
await this.storefrontRequest("DELETE", `/products/${productId}/reviews/me`);
|
|
2912
|
+
return;
|
|
2913
|
+
}
|
|
2914
|
+
throw new BrainerceError("deleteMyProductReview() requires vibe-coded or storefront mode", 400);
|
|
2915
|
+
}
|
|
2851
2916
|
/**
|
|
2852
2917
|
* Admin: list all reviews for a product (incl. hidden). Requires API key with `reviews:read`.
|
|
2853
2918
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -2762,15 +2762,43 @@ var BrainerceClient = class {
|
|
|
2762
2762
|
}
|
|
2763
2763
|
throw new BrainerceError("listProductReviews() requires vibe-coded or storefront mode", 400);
|
|
2764
2764
|
}
|
|
2765
|
+
/**
|
|
2766
|
+
* Get the current customer's review state for a product (storefront / sales-channel modes).
|
|
2767
|
+
* Requires a customer token (`setCustomerToken(...)` after login).
|
|
2768
|
+
*
|
|
2769
|
+
* Returns whether the customer is *eligible* to review (only purchasers are),
|
|
2770
|
+
* and their existing review for this product if any.
|
|
2771
|
+
*
|
|
2772
|
+
* @example
|
|
2773
|
+
* ```typescript
|
|
2774
|
+
* const { eligible, reason, myReview } = await client.getMyProductReview('prod_123');
|
|
2775
|
+
* if (!eligible) showMessage(reason); // 'no_eligible_order' | 'reviews_disabled' | …
|
|
2776
|
+
* else if (myReview) renderEditForm(myReview);
|
|
2777
|
+
* else renderSubmitForm();
|
|
2778
|
+
* ```
|
|
2779
|
+
*/
|
|
2780
|
+
async getMyProductReview(productId) {
|
|
2781
|
+
if (this.isVibeCodedMode()) {
|
|
2782
|
+
return this.vibeCodedRequest("GET", `/products/${productId}/reviews/me`);
|
|
2783
|
+
}
|
|
2784
|
+
if (this.storeId && !this.apiKey) {
|
|
2785
|
+
return this.storefrontRequest("GET", `/products/${productId}/reviews/me`);
|
|
2786
|
+
}
|
|
2787
|
+
throw new BrainerceError("getMyProductReview() requires vibe-coded or storefront mode", 400);
|
|
2788
|
+
}
|
|
2765
2789
|
/**
|
|
2766
2790
|
* Submit a customer review for a product (storefront / sales-channel modes).
|
|
2767
|
-
*
|
|
2791
|
+
* Requires customer authentication AND that the customer has purchased the
|
|
2792
|
+
* product (SHIPPED for physical, PAID for downloadable).
|
|
2793
|
+
*
|
|
2794
|
+
* 403 `no_eligible_order` if the customer didn't purchase the product.
|
|
2795
|
+
* 409 `Conflict` if they already submitted a review (use `updateMyProductReview` instead).
|
|
2796
|
+
*
|
|
2797
|
+
* Author name + email are derived server-side from the customer profile.
|
|
2768
2798
|
*
|
|
2769
2799
|
* @example
|
|
2770
2800
|
* ```typescript
|
|
2771
2801
|
* const review = await client.submitProductReview('prod_123', {
|
|
2772
|
-
* authorName: 'Jane Doe',
|
|
2773
|
-
* authorEmail: 'jane@example.com',
|
|
2774
2802
|
* rating: 5,
|
|
2775
2803
|
* body: 'Loved it!',
|
|
2776
2804
|
* });
|
|
@@ -2785,6 +2813,43 @@ var BrainerceClient = class {
|
|
|
2785
2813
|
}
|
|
2786
2814
|
throw new BrainerceError("submitProductReview() requires vibe-coded or storefront mode", 400);
|
|
2787
2815
|
}
|
|
2816
|
+
/**
|
|
2817
|
+
* Edit your own review on a product (storefront / sales-channel modes).
|
|
2818
|
+
* Only updates rating + body; the author name/email and verifiedPurchase flag
|
|
2819
|
+
* are preserved from the original submit.
|
|
2820
|
+
*/
|
|
2821
|
+
async updateMyProductReview(productId, input) {
|
|
2822
|
+
if (this.isVibeCodedMode()) {
|
|
2823
|
+
return this.vibeCodedRequest(
|
|
2824
|
+
"PATCH",
|
|
2825
|
+
`/products/${productId}/reviews/me`,
|
|
2826
|
+
input
|
|
2827
|
+
);
|
|
2828
|
+
}
|
|
2829
|
+
if (this.storeId && !this.apiKey) {
|
|
2830
|
+
return this.storefrontRequest(
|
|
2831
|
+
"PATCH",
|
|
2832
|
+
`/products/${productId}/reviews/me`,
|
|
2833
|
+
input
|
|
2834
|
+
);
|
|
2835
|
+
}
|
|
2836
|
+
throw new BrainerceError("updateMyProductReview() requires vibe-coded or storefront mode", 400);
|
|
2837
|
+
}
|
|
2838
|
+
/**
|
|
2839
|
+
* Delete your own review on a product (storefront / sales-channel modes).
|
|
2840
|
+
* After deletion the customer is free to submit a new review (subject to eligibility).
|
|
2841
|
+
*/
|
|
2842
|
+
async deleteMyProductReview(productId) {
|
|
2843
|
+
if (this.isVibeCodedMode()) {
|
|
2844
|
+
await this.vibeCodedRequest("DELETE", `/products/${productId}/reviews/me`);
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2847
|
+
if (this.storeId && !this.apiKey) {
|
|
2848
|
+
await this.storefrontRequest("DELETE", `/products/${productId}/reviews/me`);
|
|
2849
|
+
return;
|
|
2850
|
+
}
|
|
2851
|
+
throw new BrainerceError("deleteMyProductReview() requires vibe-coded or storefront mode", 400);
|
|
2852
|
+
}
|
|
2788
2853
|
/**
|
|
2789
2854
|
* Admin: list all reviews for a product (incl. hidden). Requires API key with `reviews:read`.
|
|
2790
2855
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.1",
|
|
4
4
|
"description": "Official SDK for building e-commerce storefronts with Brainerce Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|