brainerce 1.23.14 → 1.24.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/README.md CHANGED
@@ -48,6 +48,7 @@ Every Brainerce storefront must include **all mandatory features** below. Featur
48
48
  | Account area (profile + order history) | `client.getMyProfile()`, `client.getMyOrders()` | ✅ |
49
49
  | Global header: cart count + search autocomplete | `client.getCart()`, `client.getSearchSuggestions(query)` | ✅ |
50
50
  | Discount banners + product badges | `client.getDiscountBanners()`, `client.getProductDiscountBadge(productId)` | ✅ |
51
+ | Product reviews on PDP + JSON-LD aggregateRating | `client.listProductReviews(id)`, `client.submitProductReview(id, …)` | ✅ |
51
52
  | Multi-language + RTL (when i18n enabled) | `client.setLocale()` | conditional |
52
53
 
53
54
  ---
package/dist/index.d.mts CHANGED
@@ -323,9 +323,42 @@ interface Product {
323
323
  * (`getProductBySlug`, `getProductById`); omitted from list responses.
324
324
  */
325
325
  modifierGroups?: ModifierGroup[];
326
+ /** Average rating across visible reviews (0 when reviewCount is 0). */
327
+ avgRating?: number;
328
+ /** Count of visible reviews (non-hidden). */
329
+ reviewCount?: number;
326
330
  createdAt: string;
327
331
  updatedAt: string;
328
332
  }
333
+ /**
334
+ * Product review submitted by a customer.
335
+ * Reviews publish immediately (no PENDING state). Merchants hide via the admin
336
+ * surface — hiddenAt is null for visible reviews.
337
+ */
338
+ interface ProductReview {
339
+ id: string;
340
+ productId: string;
341
+ authorName: string;
342
+ rating: number;
343
+ body: string | null;
344
+ verifiedPurchase: boolean;
345
+ /** Only present in admin responses; null on storefront responses. */
346
+ hiddenAt?: string | null;
347
+ createdAt: string;
348
+ }
349
+ /** Admin-mode review with full PII. Returned by `client.adminReviews.*`. */
350
+ interface ProductReviewAdmin extends ProductReview {
351
+ customerId: string | null;
352
+ authorEmail: string | null;
353
+ orderId: string | null;
354
+ updatedAt: string;
355
+ }
356
+ interface SubmitProductReviewInput {
357
+ authorName: string;
358
+ authorEmail?: string;
359
+ rating: number;
360
+ body?: string;
361
+ }
329
362
  interface ProductImage {
330
363
  url: string;
331
364
  position?: number;
@@ -6081,6 +6114,48 @@ declare class BrainerceClient {
6081
6114
  * ```
6082
6115
  */
6083
6116
  getProductRecommendations(productId: string, type?: ProductRelationType): Promise<ProductRecommendationsResponse>;
6117
+ /**
6118
+ * List visible reviews for a product (storefront / sales-channel modes).
6119
+ * Reviews that the merchant has hidden are excluded.
6120
+ *
6121
+ * @example
6122
+ * ```typescript
6123
+ * const { data, meta } = await client.listProductReviews('prod_123', { page: 1, limit: 20 });
6124
+ * data.forEach(r => console.log(r.rating, r.body, r.verifiedPurchase));
6125
+ * ```
6126
+ */
6127
+ listProductReviews(productId: string, params?: {
6128
+ page?: number;
6129
+ limit?: number;
6130
+ }): Promise<PaginatedResponse<ProductReview>>;
6131
+ /**
6132
+ * Submit a customer review for a product (storefront / sales-channel modes).
6133
+ * Publishes immediately. Duplicate submissions from the same email return 409.
6134
+ *
6135
+ * @example
6136
+ * ```typescript
6137
+ * const review = await client.submitProductReview('prod_123', {
6138
+ * authorName: 'Jane Doe',
6139
+ * authorEmail: 'jane@example.com',
6140
+ * rating: 5,
6141
+ * body: 'Loved it!',
6142
+ * });
6143
+ * ```
6144
+ */
6145
+ submitProductReview(productId: string, input: SubmitProductReviewInput): Promise<ProductReview>;
6146
+ /**
6147
+ * Admin: list all reviews for a product (incl. hidden). Requires API key with `reviews:read`.
6148
+ */
6149
+ adminListProductReviews(productId: string, params?: {
6150
+ storeId?: string;
6151
+ page?: number;
6152
+ limit?: number;
6153
+ visibility?: 'visible' | 'hidden' | 'all';
6154
+ }): Promise<PaginatedResponse<ProductReviewAdmin>>;
6155
+ /** Admin: hide a review (sets hiddenAt). */
6156
+ hideProductReview(reviewId: string, storeId?: string): Promise<ProductReviewAdmin>;
6157
+ /** Admin: unhide a previously hidden review. */
6158
+ showProductReview(reviewId: string, storeId?: string): Promise<ProductReviewAdmin>;
6084
6159
  /**
6085
6160
  * Get cross-sell recommendations based on cart contents.
6086
6161
  * Returns products that complement items already in the cart.
package/dist/index.d.ts CHANGED
@@ -323,9 +323,42 @@ interface Product {
323
323
  * (`getProductBySlug`, `getProductById`); omitted from list responses.
324
324
  */
325
325
  modifierGroups?: ModifierGroup[];
326
+ /** Average rating across visible reviews (0 when reviewCount is 0). */
327
+ avgRating?: number;
328
+ /** Count of visible reviews (non-hidden). */
329
+ reviewCount?: number;
326
330
  createdAt: string;
327
331
  updatedAt: string;
328
332
  }
333
+ /**
334
+ * Product review submitted by a customer.
335
+ * Reviews publish immediately (no PENDING state). Merchants hide via the admin
336
+ * surface — hiddenAt is null for visible reviews.
337
+ */
338
+ interface ProductReview {
339
+ id: string;
340
+ productId: string;
341
+ authorName: string;
342
+ rating: number;
343
+ body: string | null;
344
+ verifiedPurchase: boolean;
345
+ /** Only present in admin responses; null on storefront responses. */
346
+ hiddenAt?: string | null;
347
+ createdAt: string;
348
+ }
349
+ /** Admin-mode review with full PII. Returned by `client.adminReviews.*`. */
350
+ interface ProductReviewAdmin extends ProductReview {
351
+ customerId: string | null;
352
+ authorEmail: string | null;
353
+ orderId: string | null;
354
+ updatedAt: string;
355
+ }
356
+ interface SubmitProductReviewInput {
357
+ authorName: string;
358
+ authorEmail?: string;
359
+ rating: number;
360
+ body?: string;
361
+ }
329
362
  interface ProductImage {
330
363
  url: string;
331
364
  position?: number;
@@ -6081,6 +6114,48 @@ declare class BrainerceClient {
6081
6114
  * ```
6082
6115
  */
6083
6116
  getProductRecommendations(productId: string, type?: ProductRelationType): Promise<ProductRecommendationsResponse>;
6117
+ /**
6118
+ * List visible reviews for a product (storefront / sales-channel modes).
6119
+ * Reviews that the merchant has hidden are excluded.
6120
+ *
6121
+ * @example
6122
+ * ```typescript
6123
+ * const { data, meta } = await client.listProductReviews('prod_123', { page: 1, limit: 20 });
6124
+ * data.forEach(r => console.log(r.rating, r.body, r.verifiedPurchase));
6125
+ * ```
6126
+ */
6127
+ listProductReviews(productId: string, params?: {
6128
+ page?: number;
6129
+ limit?: number;
6130
+ }): Promise<PaginatedResponse<ProductReview>>;
6131
+ /**
6132
+ * Submit a customer review for a product (storefront / sales-channel modes).
6133
+ * Publishes immediately. Duplicate submissions from the same email return 409.
6134
+ *
6135
+ * @example
6136
+ * ```typescript
6137
+ * const review = await client.submitProductReview('prod_123', {
6138
+ * authorName: 'Jane Doe',
6139
+ * authorEmail: 'jane@example.com',
6140
+ * rating: 5,
6141
+ * body: 'Loved it!',
6142
+ * });
6143
+ * ```
6144
+ */
6145
+ submitProductReview(productId: string, input: SubmitProductReviewInput): Promise<ProductReview>;
6146
+ /**
6147
+ * Admin: list all reviews for a product (incl. hidden). Requires API key with `reviews:read`.
6148
+ */
6149
+ adminListProductReviews(productId: string, params?: {
6150
+ storeId?: string;
6151
+ page?: number;
6152
+ limit?: number;
6153
+ visibility?: 'visible' | 'hidden' | 'all';
6154
+ }): Promise<PaginatedResponse<ProductReviewAdmin>>;
6155
+ /** Admin: hide a review (sets hiddenAt). */
6156
+ hideProductReview(reviewId: string, storeId?: string): Promise<ProductReviewAdmin>;
6157
+ /** Admin: unhide a previously hidden review. */
6158
+ showProductReview(reviewId: string, storeId?: string): Promise<ProductReviewAdmin>;
6084
6159
  /**
6085
6160
  * Get cross-sell recommendations based on cart contents.
6086
6161
  * Returns products that complement items already in the cart.
package/dist/index.js CHANGED
@@ -2790,6 +2790,107 @@ var BrainerceClient = class {
2790
2790
  400
2791
2791
  );
2792
2792
  }
2793
+ // ===================================================
2794
+ // Product Reviews
2795
+ // ===================================================
2796
+ /**
2797
+ * List visible reviews for a product (storefront / sales-channel modes).
2798
+ * Reviews that the merchant has hidden are excluded.
2799
+ *
2800
+ * @example
2801
+ * ```typescript
2802
+ * const { data, meta } = await client.listProductReviews('prod_123', { page: 1, limit: 20 });
2803
+ * data.forEach(r => console.log(r.rating, r.body, r.verifiedPurchase));
2804
+ * ```
2805
+ */
2806
+ async listProductReviews(productId, params) {
2807
+ const queryParams = {};
2808
+ if (params?.page) queryParams.page = params.page;
2809
+ if (params?.limit) queryParams.limit = params.limit;
2810
+ if (this.isVibeCodedMode()) {
2811
+ return this.vibeCodedRequest(
2812
+ "GET",
2813
+ `/products/${productId}/reviews`,
2814
+ void 0,
2815
+ queryParams
2816
+ );
2817
+ }
2818
+ if (this.storeId && !this.apiKey) {
2819
+ return this.storefrontRequest(
2820
+ "GET",
2821
+ `/products/${productId}/reviews`,
2822
+ void 0,
2823
+ queryParams
2824
+ );
2825
+ }
2826
+ throw new BrainerceError("listProductReviews() requires vibe-coded or storefront mode", 400);
2827
+ }
2828
+ /**
2829
+ * Submit a customer review for a product (storefront / sales-channel modes).
2830
+ * Publishes immediately. Duplicate submissions from the same email return 409.
2831
+ *
2832
+ * @example
2833
+ * ```typescript
2834
+ * const review = await client.submitProductReview('prod_123', {
2835
+ * authorName: 'Jane Doe',
2836
+ * authorEmail: 'jane@example.com',
2837
+ * rating: 5,
2838
+ * body: 'Loved it!',
2839
+ * });
2840
+ * ```
2841
+ */
2842
+ async submitProductReview(productId, input) {
2843
+ if (this.isVibeCodedMode()) {
2844
+ return this.vibeCodedRequest("POST", `/products/${productId}/reviews`, input);
2845
+ }
2846
+ if (this.storeId && !this.apiKey) {
2847
+ return this.storefrontRequest("POST", `/products/${productId}/reviews`, input);
2848
+ }
2849
+ throw new BrainerceError("submitProductReview() requires vibe-coded or storefront mode", 400);
2850
+ }
2851
+ /**
2852
+ * Admin: list all reviews for a product (incl. hidden). Requires API key with `reviews:read`.
2853
+ */
2854
+ async adminListProductReviews(productId, params) {
2855
+ if (!this.apiKey) {
2856
+ throw new BrainerceError("adminListProductReviews() requires admin (API key) mode", 400);
2857
+ }
2858
+ const queryParams = {};
2859
+ if (params?.storeId) queryParams.storeId = params.storeId;
2860
+ if (params?.page) queryParams.page = params.page;
2861
+ if (params?.limit) queryParams.limit = params.limit;
2862
+ if (params?.visibility) queryParams.visibility = params.visibility;
2863
+ return this.adminRequest(
2864
+ "GET",
2865
+ `/api/v1/products/${productId}/reviews`,
2866
+ void 0,
2867
+ queryParams
2868
+ );
2869
+ }
2870
+ /** Admin: hide a review (sets hiddenAt). */
2871
+ async hideProductReview(reviewId, storeId) {
2872
+ if (!this.apiKey) {
2873
+ throw new BrainerceError("hideProductReview() requires admin (API key) mode", 400);
2874
+ }
2875
+ return this.adminRequest(
2876
+ "PATCH",
2877
+ `/api/v1/reviews/${reviewId}/hide`,
2878
+ void 0,
2879
+ storeId ? { storeId } : void 0
2880
+ );
2881
+ }
2882
+ /** Admin: unhide a previously hidden review. */
2883
+ async showProductReview(reviewId, storeId) {
2884
+ if (!this.apiKey) {
2885
+ throw new BrainerceError("showProductReview() requires admin (API key) mode", 400);
2886
+ }
2887
+ return this.adminRequest(
2888
+ "PATCH",
2889
+ `/api/v1/reviews/${reviewId}/show`,
2890
+ void 0,
2891
+ storeId ? { storeId } : void 0
2892
+ );
2893
+ }
2793
2894
  /**
2794
2895
  * Get cross-sell recommendations based on cart contents.
2795
2896
  * Returns products that complement items already in the cart.
package/dist/index.mjs CHANGED
@@ -2727,6 +2727,107 @@ var BrainerceClient = class {
2727
2727
  400
2728
2728
  );
2729
2729
  }
2730
+ // ===================================================
2731
+ // Product Reviews
2732
+ // ===================================================
2733
+ /**
2734
+ * List visible reviews for a product (storefront / sales-channel modes).
2735
+ * Reviews that the merchant has hidden are excluded.
2736
+ *
2737
+ * @example
2738
+ * ```typescript
2739
+ * const { data, meta } = await client.listProductReviews('prod_123', { page: 1, limit: 20 });
2740
+ * data.forEach(r => console.log(r.rating, r.body, r.verifiedPurchase));
2741
+ * ```
2742
+ */
2743
+ async listProductReviews(productId, params) {
2744
+ const queryParams = {};
2745
+ if (params?.page) queryParams.page = params.page;
2746
+ if (params?.limit) queryParams.limit = params.limit;
2747
+ if (this.isVibeCodedMode()) {
2748
+ return this.vibeCodedRequest(
2749
+ "GET",
2750
+ `/products/${productId}/reviews`,
2751
+ void 0,
2752
+ queryParams
2753
+ );
2754
+ }
2755
+ if (this.storeId && !this.apiKey) {
2756
+ return this.storefrontRequest(
2757
+ "GET",
2758
+ `/products/${productId}/reviews`,
2759
+ void 0,
2760
+ queryParams
2761
+ );
2762
+ }
2763
+ throw new BrainerceError("listProductReviews() requires vibe-coded or storefront mode", 400);
2764
+ }
2765
+ /**
2766
+ * Submit a customer review for a product (storefront / sales-channel modes).
2767
+ * Publishes immediately. Duplicate submissions from the same email return 409.
2768
+ *
2769
+ * @example
2770
+ * ```typescript
2771
+ * const review = await client.submitProductReview('prod_123', {
2772
+ * authorName: 'Jane Doe',
2773
+ * authorEmail: 'jane@example.com',
2774
+ * rating: 5,
2775
+ * body: 'Loved it!',
2776
+ * });
2777
+ * ```
2778
+ */
2779
+ async submitProductReview(productId, input) {
2780
+ if (this.isVibeCodedMode()) {
2781
+ return this.vibeCodedRequest("POST", `/products/${productId}/reviews`, input);
2782
+ }
2783
+ if (this.storeId && !this.apiKey) {
2784
+ return this.storefrontRequest("POST", `/products/${productId}/reviews`, input);
2785
+ }
2786
+ throw new BrainerceError("submitProductReview() requires vibe-coded or storefront mode", 400);
2787
+ }
2788
+ /**
2789
+ * Admin: list all reviews for a product (incl. hidden). Requires API key with `reviews:read`.
2790
+ */
2791
+ async adminListProductReviews(productId, params) {
2792
+ if (!this.apiKey) {
2793
+ throw new BrainerceError("adminListProductReviews() requires admin (API key) mode", 400);
2794
+ }
2795
+ const queryParams = {};
2796
+ if (params?.storeId) queryParams.storeId = params.storeId;
2797
+ if (params?.page) queryParams.page = params.page;
2798
+ if (params?.limit) queryParams.limit = params.limit;
2799
+ if (params?.visibility) queryParams.visibility = params.visibility;
2800
+ return this.adminRequest(
2801
+ "GET",
2802
+ `/api/v1/products/${productId}/reviews`,
2803
+ void 0,
2804
+ queryParams
2805
+ );
2806
+ }
2807
+ /** Admin: hide a review (sets hiddenAt). */
2808
+ async hideProductReview(reviewId, storeId) {
2809
+ if (!this.apiKey) {
2810
+ throw new BrainerceError("hideProductReview() requires admin (API key) mode", 400);
2811
+ }
2812
+ return this.adminRequest(
2813
+ "PATCH",
2814
+ `/api/v1/reviews/${reviewId}/hide`,
2815
+ void 0,
2816
+ storeId ? { storeId } : void 0
2817
+ );
2818
+ }
2819
+ /** Admin: unhide a previously hidden review. */
2820
+ async showProductReview(reviewId, storeId) {
2821
+ if (!this.apiKey) {
2822
+ throw new BrainerceError("showProductReview() requires admin (API key) mode", 400);
2823
+ }
2824
+ return this.adminRequest(
2825
+ "PATCH",
2826
+ `/api/v1/reviews/${reviewId}/show`,
2827
+ void 0,
2828
+ storeId ? { storeId } : void 0
2829
+ );
2830
+ }
2730
2831
  /**
2731
2832
  * Get cross-sell recommendations based on cart contents.
2732
2833
  * Returns products that complement items already in the cart.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.23.14",
3
+ "version": "1.24.0",
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",