brainerce 1.36.3 → 1.36.5

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
@@ -100,6 +100,8 @@ Violating any of these causes production incidents or broken orders. Read them b
100
100
  - NEVER hardcode currency, locale, or language strings — read them from `getStoreInfo()`.
101
101
  - NEVER format prices with `toFixed(2)` — use `formatPrice()` from the SDK.
102
102
  - When i18n is enabled, call `client.setLocale(locale)` at app init and include a language switcher. For RTL locales (`he`, `ar`), set `<html dir="rtl">` — do NOT add `flex-row-reverse` on top.
103
+ - Call `setLocale()` **before `createCheckout()`** — the order captures the active locale (`order.locale`), which drives the confirmation-email language AND the product names shown in order history. Without it, orders and their emails fall back to the store default language. Search also needs the locale active to match translated names.
104
+ - Built-in order emails are localized for English and Hebrew; for other languages the merchant must add a custom email template per language (otherwise the email falls back to English).
103
105
 
104
106
  ### Type safety
105
107
 
@@ -2206,7 +2208,8 @@ interface Checkout {
2206
2208
  subtotal: string;
2207
2209
  discountAmount: string;
2208
2210
  shippingAmount: string;
2209
- taxAmount: string;
2211
+ taxAmount: string; // "0" in inclusive (VAT) mode — see taxBreakdown.totalTax
2212
+ taxBreakdown?: TaxBreakdown | null; // { totalTax, pricesIncludeTax, breakdown[] }
2210
2213
  total: string;
2211
2214
  couponCode?: string | null;
2212
2215
  items: CheckoutLineItem[];
package/dist/index.d.mts CHANGED
@@ -1139,8 +1139,15 @@ interface Order {
1139
1139
  }> | null;
1140
1140
  /** Shipping cost */
1141
1141
  shippingAmount?: string | null;
1142
- /** Tax amount */
1142
+ /** Tax amount. In inclusive (VAT) mode this is `"0"` — read the included VAT
1143
+ * from {@link Order.taxBreakdown}.totalTax instead. */
1143
1144
  taxAmount?: string | null;
1145
+ /**
1146
+ * Frozen tax breakdown snapshot. In inclusive (VAT) pricing `taxAmount` is 0
1147
+ * and the real VAT lives here (`taxBreakdown.totalTax`, with
1148
+ * `pricesIncludeTax: true`). Use it to display "incl. VAT" on receipts.
1149
+ */
1150
+ taxBreakdown?: TaxBreakdown | null;
1144
1151
  createdAt: string;
1145
1152
  /** Payment method used (e.g., "card", "paypal", "cash_on_delivery"). */
1146
1153
  paymentMethod?: string | null;
@@ -2204,6 +2211,12 @@ interface TaxBreakdown {
2204
2211
  total: number;
2205
2212
  /** Itemized tax breakdown */
2206
2213
  breakdown: TaxBreakdownItem[];
2214
+ /**
2215
+ * True when the store's prices already include tax (inclusive/VAT mode). In
2216
+ * that mode `totalTax` is the VAT backed out of the displayed price — it is
2217
+ * already part of `total`, not added on top. Display it as "incl. VAT".
2218
+ */
2219
+ pricesIncludeTax?: boolean;
2207
2220
  /** Currency code */
2208
2221
  currency?: string;
2209
2222
  }
package/dist/index.d.ts CHANGED
@@ -1139,8 +1139,15 @@ interface Order {
1139
1139
  }> | null;
1140
1140
  /** Shipping cost */
1141
1141
  shippingAmount?: string | null;
1142
- /** Tax amount */
1142
+ /** Tax amount. In inclusive (VAT) mode this is `"0"` — read the included VAT
1143
+ * from {@link Order.taxBreakdown}.totalTax instead. */
1143
1144
  taxAmount?: string | null;
1145
+ /**
1146
+ * Frozen tax breakdown snapshot. In inclusive (VAT) pricing `taxAmount` is 0
1147
+ * and the real VAT lives here (`taxBreakdown.totalTax`, with
1148
+ * `pricesIncludeTax: true`). Use it to display "incl. VAT" on receipts.
1149
+ */
1150
+ taxBreakdown?: TaxBreakdown | null;
1144
1151
  createdAt: string;
1145
1152
  /** Payment method used (e.g., "card", "paypal", "cash_on_delivery"). */
1146
1153
  paymentMethod?: string | null;
@@ -2204,6 +2211,12 @@ interface TaxBreakdown {
2204
2211
  total: number;
2205
2212
  /** Itemized tax breakdown */
2206
2213
  breakdown: TaxBreakdownItem[];
2214
+ /**
2215
+ * True when the store's prices already include tax (inclusive/VAT mode). In
2216
+ * that mode `totalTax` is the VAT backed out of the displayed price — it is
2217
+ * already part of `total`, not added on top. Display it as "incl. VAT".
2218
+ */
2219
+ pricesIncludeTax?: boolean;
2207
2220
  /** Currency code */
2208
2221
  currency?: string;
2209
2222
  }
package/dist/index.js CHANGED
@@ -955,7 +955,7 @@ var BrainerceClient = class {
955
955
  if (!this.storeId) {
956
956
  throw new BrainerceError("storeId is required for storefront requests", 400);
957
957
  }
958
- const url = new URL(`${this.baseUrl}/stores/${encodePathSegment(this.storeId)}${path}`);
958
+ const url = new URL(`${this.baseUrl}/api/stores/${encodePathSegment(this.storeId)}${path}`);
959
959
  if (queryParams) {
960
960
  Object.entries(queryParams).forEach(([key, value]) => {
961
961
  if (value !== void 0) {
package/dist/index.mjs CHANGED
@@ -885,7 +885,7 @@ var BrainerceClient = class {
885
885
  if (!this.storeId) {
886
886
  throw new BrainerceError("storeId is required for storefront requests", 400);
887
887
  }
888
- const url = new URL(`${this.baseUrl}/stores/${encodePathSegment(this.storeId)}${path}`);
888
+ const url = new URL(`${this.baseUrl}/api/stores/${encodePathSegment(this.storeId)}${path}`);
889
889
  if (queryParams) {
890
890
  Object.entries(queryParams).forEach(([key, value]) => {
891
891
  if (value !== void 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.36.3",
3
+ "version": "1.36.5",
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",