brainerce 1.37.0 → 1.37.2

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
@@ -2055,32 +2055,33 @@ const checkout = await client.createCheckout({
2055
2055
 
2056
2056
  #### Region display pricing (`getProducts({ regionId })`)
2057
2057
 
2058
- Product reads accept an optional `regionId`. When set, each product/variant that
2059
- a region [price list](#price-lists) resolves gains additive fields —
2060
- `resolvedPrice`, `resolvedCurrency`, `resolvedCompareAtPrice`, and `priceSource`
2061
- (`'variant-entry'` | `'product-entry'`). Your existing `basePrice` / `salePrice`
2062
- stay in the store currency; the fields appear **only** when a region entry
2063
- actually applies, so an omitted/invalid region (or a catalog-price fallback)
2064
- leaves the response byte-identical.
2058
+ All three product reads accept an optional `regionId` `getProducts`,
2059
+ `getProduct(id)`, **and** `getProductBySlug(slug)` (the PDP path). When set and the
2060
+ region's currency differs from the store currency, each product/variant gains
2061
+ additive FX-display fields `displayPrice`, `displaySalePrice`, and
2062
+ `displayCurrency` (plus `displayPriceMin` / `displayPriceMax` on storefront-mode
2063
+ list reads). Your `basePrice` / `salePrice` stay in the store currency; the
2064
+ display fields appear **only** when an FX rate applies, so an omitted/invalid
2065
+ region or a same-currency region leaves the response byte-identical.
2065
2066
 
2066
2067
  ```typescript
2067
2068
  const { data: products } = await client.getProducts({ regionId: 'region_eu' });
2068
2069
  const p = products[0];
2069
- const display = p.resolvedPrice
2070
- ? `${p.resolvedPrice} ${p.resolvedCurrency}` // e.g. "27.00 EUR"
2071
- : p.basePrice; // store-currency catalog price
2070
+ const display = p.displayPrice
2071
+ ? `${p.displayPrice} ${p.displayCurrency}` // e.g. "27.00 EUR"
2072
+ : p.basePrice; // store-currency price (no FX rate / same currency)
2072
2073
 
2073
- // Single product (id or slug) takes the same option:
2074
+ // Single product by id OR slug takes the same option:
2074
2075
  await client.getProduct('prod_tshirt', { regionId: 'region_eu' });
2076
+ await client.getProductBySlug('blue-shirt', { regionId: 'region_eu' });
2075
2077
  ```
2076
2078
 
2077
2079
  > **Display-only** — like checkout, `regionId` here does not charge the region
2078
- > price; it only changes what you render until currency-lock ships. **Mode note:**
2079
- > the additive FX display overlay (`displayPrice` / `displayCurrency`, see
2080
- > [Regions](/docs/concepts/regions)) now applies in vibe-coded
2081
- > (`vc_*`/`salesChannelId`) mode too previously it was populated on storefront
2082
- > (`storeId`) and admin (`apiKey`) reads only. Pass `regionId` and the response
2083
- > gains `displayPrice` whenever a daily FX rate exists for the store→region pair.
2080
+ > currency; it only changes what you render until currency-lock ships. Works in
2081
+ > **all three modes** vibe-coded (`vc_*`/`salesChannelId`), storefront (`storeId`),
2082
+ > and admin (`apiKey`). The response gains `displayPrice` whenever a daily FX rate
2083
+ > exists for the store/region currency pair in **either** direction (the overlay
2084
+ > inverts the stored rate when needed). See [Regions](/docs/concepts/regions).
2084
2085
 
2085
2086
  #### Partial Checkout (AliExpress-style)
2086
2087
 
package/dist/index.d.mts CHANGED
@@ -5493,6 +5493,7 @@ declare class BrainerceClient {
5493
5493
  */
5494
5494
  getProductBySlug(slug: string, options?: {
5495
5495
  locale?: string;
5496
+ regionId?: string;
5496
5497
  }): Promise<Product>;
5497
5498
  /**
5498
5499
  * Get available categories for filtering products
package/dist/index.d.ts CHANGED
@@ -5493,6 +5493,7 @@ declare class BrainerceClient {
5493
5493
  */
5494
5494
  getProductBySlug(slug: string, options?: {
5495
5495
  locale?: string;
5496
+ regionId?: string;
5496
5497
  }): Promise<Product>;
5497
5498
  /**
5498
5499
  * Get available categories for filtering products
package/dist/index.js CHANGED
@@ -1192,13 +1192,14 @@ var BrainerceClient = class {
1192
1192
  */
1193
1193
  async getProductBySlug(slug, options) {
1194
1194
  const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
1195
+ const queryParams = options?.regionId ? { regionId: options.regionId } : void 0;
1195
1196
  const encodedSlug = encodePathSegment(slug);
1196
1197
  if (this.isVibeCodedMode()) {
1197
1198
  return this.vibeCodedRequest(
1198
1199
  "GET",
1199
1200
  `/products/slug/${encodedSlug}`,
1200
1201
  void 0,
1201
- void 0,
1202
+ queryParams,
1202
1203
  headerOverrides
1203
1204
  );
1204
1205
  }
@@ -1207,11 +1208,16 @@ var BrainerceClient = class {
1207
1208
  "GET",
1208
1209
  `/products/slug/${encodedSlug}`,
1209
1210
  void 0,
1210
- void 0,
1211
+ queryParams,
1211
1212
  headerOverrides
1212
1213
  );
1213
1214
  }
1214
- return this.adminRequest("GET", `/api/v1/products/by-slug/${encodedSlug}`);
1215
+ return this.adminRequest(
1216
+ "GET",
1217
+ `/api/v1/products/by-slug/${encodedSlug}`,
1218
+ void 0,
1219
+ queryParams
1220
+ );
1215
1221
  }
1216
1222
  /**
1217
1223
  * Get available categories for filtering products
package/dist/index.mjs CHANGED
@@ -1122,13 +1122,14 @@ var BrainerceClient = class {
1122
1122
  */
1123
1123
  async getProductBySlug(slug, options) {
1124
1124
  const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
1125
+ const queryParams = options?.regionId ? { regionId: options.regionId } : void 0;
1125
1126
  const encodedSlug = encodePathSegment(slug);
1126
1127
  if (this.isVibeCodedMode()) {
1127
1128
  return this.vibeCodedRequest(
1128
1129
  "GET",
1129
1130
  `/products/slug/${encodedSlug}`,
1130
1131
  void 0,
1131
- void 0,
1132
+ queryParams,
1132
1133
  headerOverrides
1133
1134
  );
1134
1135
  }
@@ -1137,11 +1138,16 @@ var BrainerceClient = class {
1137
1138
  "GET",
1138
1139
  `/products/slug/${encodedSlug}`,
1139
1140
  void 0,
1140
- void 0,
1141
+ queryParams,
1141
1142
  headerOverrides
1142
1143
  );
1143
1144
  }
1144
- return this.adminRequest("GET", `/api/v1/products/by-slug/${encodedSlug}`);
1145
+ return this.adminRequest(
1146
+ "GET",
1147
+ `/api/v1/products/by-slug/${encodedSlug}`,
1148
+ void 0,
1149
+ queryParams
1150
+ );
1145
1151
  }
1146
1152
  /**
1147
1153
  * Get available categories for filtering products
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.37.0",
3
+ "version": "1.37.2",
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",