brainerce 1.36.4 → 1.37.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 +17 -4
- package/dist/index.d.mts +33 -6
- package/dist/index.d.ts +33 -6
- package/dist/index.js +43 -20
- package/dist/index.mjs +43 -20
- package/package.json +1 -1
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
|
|
|
@@ -2074,8 +2076,11 @@ await client.getProduct('prod_tshirt', { regionId: 'region_eu' });
|
|
|
2074
2076
|
|
|
2075
2077
|
> **Display-only** — like checkout, `regionId` here does not charge the region
|
|
2076
2078
|
> price; it only changes what you render until currency-lock ships. **Mode note:**
|
|
2077
|
-
>
|
|
2078
|
-
>
|
|
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.
|
|
2079
2084
|
|
|
2080
2085
|
#### Partial Checkout (AliExpress-style)
|
|
2081
2086
|
|
|
@@ -3564,10 +3569,13 @@ await client.deleteTaxClass(food.id);
|
|
|
3564
3569
|
```
|
|
3565
3570
|
|
|
3566
3571
|
**Storefront (public, no API key).** A storefront lists classes in `storeId`
|
|
3567
|
-
mode
|
|
3572
|
+
mode **or** vibe-coded mode (`salesChannelId: 'vc_*'`, gated on the
|
|
3573
|
+
`products:read` scope every connection already has) — storefront-safe fields
|
|
3574
|
+
only (for a "9% VAT" transparency badge):
|
|
3568
3575
|
|
|
3569
3576
|
```typescript
|
|
3570
3577
|
const store = new BrainerceClient({ storeId: 'store_123' });
|
|
3578
|
+
// — or — new BrainerceClient({ salesChannelId: 'vc_abc123' });
|
|
3571
3579
|
const { data: classes } = await store.getStoreTaxClasses();
|
|
3572
3580
|
```
|
|
3573
3581
|
|
|
@@ -3612,14 +3620,19 @@ await client.deleteRegion(eu.id);
|
|
|
3612
3620
|
```
|
|
3613
3621
|
|
|
3614
3622
|
**Storefront (public, no API key).** A storefront fetches regions in `storeId`
|
|
3615
|
-
mode
|
|
3623
|
+
mode **or** vibe-coded mode (`salesChannelId: 'vc_*'`, gated on the
|
|
3624
|
+
`products:read` scope every connection already has) — only active regions, only
|
|
3625
|
+
storefront-safe fields. `getStoreRegions()`, `getStoreRegion()`, and
|
|
3626
|
+
`getAutoRegion()` all work in both modes:
|
|
3616
3627
|
|
|
3617
3628
|
```typescript
|
|
3618
3629
|
const store = new BrainerceClient({ storeId: 'store_123' });
|
|
3630
|
+
// — or — new BrainerceClient({ salesChannelId: 'vc_abc123' });
|
|
3619
3631
|
|
|
3620
3632
|
const { data: regions } = await store.getStoreRegions();
|
|
3621
3633
|
const region = await store.getStoreRegion(regions[0].id); // + paymentProviders
|
|
3622
3634
|
const dest = store.detectRegion('DE', regions); // pick by country, client-side
|
|
3635
|
+
const { region: resolved } = await store.getAutoRegion('DE'); // server-side, one round trip
|
|
3623
3636
|
```
|
|
3624
3637
|
|
|
3625
3638
|
> **Multi-region checkout:** pass a `regionId` to `createCheckout` to associate the
|
package/dist/index.d.mts
CHANGED
|
@@ -4556,12 +4556,27 @@ interface ProductRecommendation {
|
|
|
4556
4556
|
id: string;
|
|
4557
4557
|
name: string;
|
|
4558
4558
|
slug: string | null;
|
|
4559
|
+
/**
|
|
4560
|
+
* Effective price. For a VARIABLE target this is the pinned variant's price
|
|
4561
|
+
* (when `targetVariantId` is set) or the "from {min variant}" range price —
|
|
4562
|
+
* never a stale 0 parent price.
|
|
4563
|
+
*/
|
|
4559
4564
|
basePrice: string;
|
|
4560
4565
|
salePrice: string | null;
|
|
4561
4566
|
images: ProductImage[];
|
|
4562
4567
|
type: 'SIMPLE' | 'VARIABLE';
|
|
4563
4568
|
inventory?: InventoryInfo | null;
|
|
4564
4569
|
relationType: ProductRelationType;
|
|
4570
|
+
/** Pinned variant of the target (VARIABLE only); null = customer chooses. */
|
|
4571
|
+
targetVariantId?: string | null;
|
|
4572
|
+
/**
|
|
4573
|
+
* True when the target is VARIABLE with no pinned variant — the customer must
|
|
4574
|
+
* pick a variation (use `variants`) before this can be added to the cart.
|
|
4575
|
+
*/
|
|
4576
|
+
requiresVariantSelection?: boolean;
|
|
4577
|
+
/** The pinned variation when `targetVariantId` is set. */
|
|
4578
|
+
pinnedVariant?: LockedVariant | null;
|
|
4579
|
+
/** Selectable variations, present when `requiresVariantSelection` is true. */
|
|
4565
4580
|
variants?: RecommendationVariant[];
|
|
4566
4581
|
}
|
|
4567
4582
|
interface ProductRecommendationsResponse {
|
|
@@ -4596,6 +4611,15 @@ interface CartBundleOfferOfferedProduct {
|
|
|
4596
4611
|
url: string;
|
|
4597
4612
|
}>;
|
|
4598
4613
|
type: string;
|
|
4614
|
+
/** Pinned variant for this slot (VARIABLE only); null = customer chooses. */
|
|
4615
|
+
variantId?: string | null;
|
|
4616
|
+
/** True when the offered product is VARIABLE with no pinned variant. */
|
|
4617
|
+
requiresVariantSelection?: boolean;
|
|
4618
|
+
/** The pinned variation when `variantId` is set. */
|
|
4619
|
+
pinnedVariant?: LockedVariant | null;
|
|
4620
|
+
/** Selectable variations, present when `requiresVariantSelection` is true. */
|
|
4621
|
+
variants?: RecommendationVariant[];
|
|
4622
|
+
/** Effective pre-discount unit price (pinned/cheapest variant for VARIABLE). */
|
|
4599
4623
|
originalPrice: string;
|
|
4600
4624
|
discountedPrice: string;
|
|
4601
4625
|
}
|
|
@@ -8851,15 +8875,17 @@ declare class BrainerceClient {
|
|
|
8851
8875
|
name?: string | null;
|
|
8852
8876
|
}>>;
|
|
8853
8877
|
/**
|
|
8854
|
-
* List the store's ACTIVE regions (public, no apiKey).
|
|
8855
|
-
* Returns only storefront-safe fields (no internal flags).
|
|
8878
|
+
* List the store's ACTIVE regions (public, no apiKey). Works in storeId and
|
|
8879
|
+
* vibe-coded modes. Returns only storefront-safe fields (no internal flags).
|
|
8880
|
+
* Default region first.
|
|
8856
8881
|
*/
|
|
8857
8882
|
getStoreRegions(): Promise<{
|
|
8858
8883
|
data: PublicRegion[];
|
|
8859
8884
|
}>;
|
|
8860
8885
|
/**
|
|
8861
8886
|
* Get one active public region plus its enabled payment providers (public).
|
|
8862
|
-
*
|
|
8887
|
+
* Works in storeId and vibe-coded modes. Throws 404 if the region is inactive
|
|
8888
|
+
* or not found.
|
|
8863
8889
|
*/
|
|
8864
8890
|
getStoreRegion(regionId: string): Promise<PublicRegionDetail>;
|
|
8865
8891
|
/**
|
|
@@ -8895,9 +8921,10 @@ declare class BrainerceClient {
|
|
|
8895
8921
|
subtotal: number;
|
|
8896
8922
|
}): Promise<TaxEstimateResponse>;
|
|
8897
8923
|
/**
|
|
8898
|
-
* List the store's tax classes (public, no apiKey — storeId
|
|
8899
|
-
* safe fields only (id/name/slug/description/isDefault) for
|
|
8900
|
-
* such as a "9% VAT" badge. Admin/api-key callers use
|
|
8924
|
+
* List the store's tax classes (public, no apiKey — storeId or vibe-coded
|
|
8925
|
+
* mode). Storefront-safe fields only (id/name/slug/description/isDefault) for
|
|
8926
|
+
* transparency UIs such as a "9% VAT" badge. Admin/api-key callers use
|
|
8927
|
+
* getTaxClasses().
|
|
8901
8928
|
*/
|
|
8902
8929
|
getStoreTaxClasses(): Promise<{
|
|
8903
8930
|
data: PublicTaxClass[];
|
package/dist/index.d.ts
CHANGED
|
@@ -4556,12 +4556,27 @@ interface ProductRecommendation {
|
|
|
4556
4556
|
id: string;
|
|
4557
4557
|
name: string;
|
|
4558
4558
|
slug: string | null;
|
|
4559
|
+
/**
|
|
4560
|
+
* Effective price. For a VARIABLE target this is the pinned variant's price
|
|
4561
|
+
* (when `targetVariantId` is set) or the "from {min variant}" range price —
|
|
4562
|
+
* never a stale 0 parent price.
|
|
4563
|
+
*/
|
|
4559
4564
|
basePrice: string;
|
|
4560
4565
|
salePrice: string | null;
|
|
4561
4566
|
images: ProductImage[];
|
|
4562
4567
|
type: 'SIMPLE' | 'VARIABLE';
|
|
4563
4568
|
inventory?: InventoryInfo | null;
|
|
4564
4569
|
relationType: ProductRelationType;
|
|
4570
|
+
/** Pinned variant of the target (VARIABLE only); null = customer chooses. */
|
|
4571
|
+
targetVariantId?: string | null;
|
|
4572
|
+
/**
|
|
4573
|
+
* True when the target is VARIABLE with no pinned variant — the customer must
|
|
4574
|
+
* pick a variation (use `variants`) before this can be added to the cart.
|
|
4575
|
+
*/
|
|
4576
|
+
requiresVariantSelection?: boolean;
|
|
4577
|
+
/** The pinned variation when `targetVariantId` is set. */
|
|
4578
|
+
pinnedVariant?: LockedVariant | null;
|
|
4579
|
+
/** Selectable variations, present when `requiresVariantSelection` is true. */
|
|
4565
4580
|
variants?: RecommendationVariant[];
|
|
4566
4581
|
}
|
|
4567
4582
|
interface ProductRecommendationsResponse {
|
|
@@ -4596,6 +4611,15 @@ interface CartBundleOfferOfferedProduct {
|
|
|
4596
4611
|
url: string;
|
|
4597
4612
|
}>;
|
|
4598
4613
|
type: string;
|
|
4614
|
+
/** Pinned variant for this slot (VARIABLE only); null = customer chooses. */
|
|
4615
|
+
variantId?: string | null;
|
|
4616
|
+
/** True when the offered product is VARIABLE with no pinned variant. */
|
|
4617
|
+
requiresVariantSelection?: boolean;
|
|
4618
|
+
/** The pinned variation when `variantId` is set. */
|
|
4619
|
+
pinnedVariant?: LockedVariant | null;
|
|
4620
|
+
/** Selectable variations, present when `requiresVariantSelection` is true. */
|
|
4621
|
+
variants?: RecommendationVariant[];
|
|
4622
|
+
/** Effective pre-discount unit price (pinned/cheapest variant for VARIABLE). */
|
|
4599
4623
|
originalPrice: string;
|
|
4600
4624
|
discountedPrice: string;
|
|
4601
4625
|
}
|
|
@@ -8851,15 +8875,17 @@ declare class BrainerceClient {
|
|
|
8851
8875
|
name?: string | null;
|
|
8852
8876
|
}>>;
|
|
8853
8877
|
/**
|
|
8854
|
-
* List the store's ACTIVE regions (public, no apiKey).
|
|
8855
|
-
* Returns only storefront-safe fields (no internal flags).
|
|
8878
|
+
* List the store's ACTIVE regions (public, no apiKey). Works in storeId and
|
|
8879
|
+
* vibe-coded modes. Returns only storefront-safe fields (no internal flags).
|
|
8880
|
+
* Default region first.
|
|
8856
8881
|
*/
|
|
8857
8882
|
getStoreRegions(): Promise<{
|
|
8858
8883
|
data: PublicRegion[];
|
|
8859
8884
|
}>;
|
|
8860
8885
|
/**
|
|
8861
8886
|
* Get one active public region plus its enabled payment providers (public).
|
|
8862
|
-
*
|
|
8887
|
+
* Works in storeId and vibe-coded modes. Throws 404 if the region is inactive
|
|
8888
|
+
* or not found.
|
|
8863
8889
|
*/
|
|
8864
8890
|
getStoreRegion(regionId: string): Promise<PublicRegionDetail>;
|
|
8865
8891
|
/**
|
|
@@ -8895,9 +8921,10 @@ declare class BrainerceClient {
|
|
|
8895
8921
|
subtotal: number;
|
|
8896
8922
|
}): Promise<TaxEstimateResponse>;
|
|
8897
8923
|
/**
|
|
8898
|
-
* List the store's tax classes (public, no apiKey — storeId
|
|
8899
|
-
* safe fields only (id/name/slug/description/isDefault) for
|
|
8900
|
-
* such as a "9% VAT" badge. Admin/api-key callers use
|
|
8924
|
+
* List the store's tax classes (public, no apiKey — storeId or vibe-coded
|
|
8925
|
+
* mode). Storefront-safe fields only (id/name/slug/description/isDefault) for
|
|
8926
|
+
* transparency UIs such as a "9% VAT" badge. Admin/api-key callers use
|
|
8927
|
+
* getTaxClasses().
|
|
8901
8928
|
*/
|
|
8902
8929
|
getStoreTaxClasses(): Promise<{
|
|
8903
8930
|
data: PublicTaxClass[];
|
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) {
|
|
@@ -1130,7 +1130,7 @@ var BrainerceClient = class {
|
|
|
1130
1130
|
"GET",
|
|
1131
1131
|
"/products",
|
|
1132
1132
|
void 0,
|
|
1133
|
-
|
|
1133
|
+
queryParamsWithRegion
|
|
1134
1134
|
);
|
|
1135
1135
|
}
|
|
1136
1136
|
if (this.storeId && !this.apiKey) {
|
|
@@ -1160,7 +1160,7 @@ var BrainerceClient = class {
|
|
|
1160
1160
|
"GET",
|
|
1161
1161
|
`/products/${encodePathSegment(productId)}`,
|
|
1162
1162
|
void 0,
|
|
1163
|
-
|
|
1163
|
+
queryParams,
|
|
1164
1164
|
headerOverrides
|
|
1165
1165
|
);
|
|
1166
1166
|
}
|
|
@@ -7275,22 +7275,34 @@ var BrainerceClient = class {
|
|
|
7275
7275
|
`/api/v1/regions/${encodePathSegment(regionId)}/compatible-providers`
|
|
7276
7276
|
);
|
|
7277
7277
|
}
|
|
7278
|
-
// -------------------- Regions (Storefront
|
|
7279
|
-
// storeId-based, no auth. Call these from a storefront to
|
|
7280
|
-
// region (story S1), then pair with detectRegion().
|
|
7281
|
-
//
|
|
7278
|
+
// -------------------- Regions (Storefront + vibe-coded, public — no apiKey) --------------------
|
|
7279
|
+
// storeId- or connectionId-based, no auth. Call these from a storefront to
|
|
7280
|
+
// detect the buyer's region (story S1), then pair with detectRegion(). Then
|
|
7281
|
+
// pass the resolved regionId to getProducts({ regionId }) for display pricing.
|
|
7282
|
+
// Admin/api-key callers use getRegions()/getRegion() instead.
|
|
7282
7283
|
/**
|
|
7283
|
-
* List the store's ACTIVE regions (public, no apiKey).
|
|
7284
|
-
* Returns only storefront-safe fields (no internal flags).
|
|
7284
|
+
* List the store's ACTIVE regions (public, no apiKey). Works in storeId and
|
|
7285
|
+
* vibe-coded modes. Returns only storefront-safe fields (no internal flags).
|
|
7286
|
+
* Default region first.
|
|
7285
7287
|
*/
|
|
7286
7288
|
async getStoreRegions() {
|
|
7289
|
+
if (this.isVibeCodedMode()) {
|
|
7290
|
+
return this.vibeCodedRequest("GET", "/regions");
|
|
7291
|
+
}
|
|
7287
7292
|
return this.storefrontRequest("GET", "/regions");
|
|
7288
7293
|
}
|
|
7289
7294
|
/**
|
|
7290
7295
|
* Get one active public region plus its enabled payment providers (public).
|
|
7291
|
-
*
|
|
7296
|
+
* Works in storeId and vibe-coded modes. Throws 404 if the region is inactive
|
|
7297
|
+
* or not found.
|
|
7292
7298
|
*/
|
|
7293
7299
|
async getStoreRegion(regionId) {
|
|
7300
|
+
if (this.isVibeCodedMode()) {
|
|
7301
|
+
return this.vibeCodedRequest(
|
|
7302
|
+
"GET",
|
|
7303
|
+
`/regions/${encodePathSegment(regionId)}`
|
|
7304
|
+
);
|
|
7305
|
+
}
|
|
7294
7306
|
return this.storefrontRequest(
|
|
7295
7307
|
"GET",
|
|
7296
7308
|
`/regions/${encodePathSegment(regionId)}`
|
|
@@ -7318,6 +7330,14 @@ var BrainerceClient = class {
|
|
|
7318
7330
|
* default region (or `region=null` if no default exists either).
|
|
7319
7331
|
*/
|
|
7320
7332
|
async getAutoRegion(country) {
|
|
7333
|
+
if (this.isVibeCodedMode()) {
|
|
7334
|
+
return this.vibeCodedRequest(
|
|
7335
|
+
"GET",
|
|
7336
|
+
"/regions/auto",
|
|
7337
|
+
void 0,
|
|
7338
|
+
country ? { country } : void 0
|
|
7339
|
+
);
|
|
7340
|
+
}
|
|
7321
7341
|
return this.storefrontRequest(
|
|
7322
7342
|
"GET",
|
|
7323
7343
|
"/regions/auto",
|
|
@@ -7335,20 +7355,23 @@ var BrainerceClient = class {
|
|
|
7335
7355
|
* or no active rate covers it.
|
|
7336
7356
|
*/
|
|
7337
7357
|
async estimateTax(params) {
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
"/tax/estimate",
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
);
|
|
7358
|
+
const query = params.country ? { country: params.country, subtotal: params.subtotal } : { subtotal: params.subtotal };
|
|
7359
|
+
if (this.isVibeCodedMode()) {
|
|
7360
|
+
return this.vibeCodedRequest("GET", "/tax/estimate", void 0, query);
|
|
7361
|
+
}
|
|
7362
|
+
return this.storefrontRequest("GET", "/tax/estimate", void 0, query);
|
|
7344
7363
|
}
|
|
7345
|
-
// -------------------- Tax Classes (Storefront
|
|
7364
|
+
// -------------------- Tax Classes (Storefront + vibe-coded, public — no apiKey) --------------------
|
|
7346
7365
|
/**
|
|
7347
|
-
* List the store's tax classes (public, no apiKey — storeId
|
|
7348
|
-
* safe fields only (id/name/slug/description/isDefault) for
|
|
7349
|
-
* such as a "9% VAT" badge. Admin/api-key callers use
|
|
7366
|
+
* List the store's tax classes (public, no apiKey — storeId or vibe-coded
|
|
7367
|
+
* mode). Storefront-safe fields only (id/name/slug/description/isDefault) for
|
|
7368
|
+
* transparency UIs such as a "9% VAT" badge. Admin/api-key callers use
|
|
7369
|
+
* getTaxClasses().
|
|
7350
7370
|
*/
|
|
7351
7371
|
async getStoreTaxClasses() {
|
|
7372
|
+
if (this.isVibeCodedMode()) {
|
|
7373
|
+
return this.vibeCodedRequest("GET", "/tax-classes");
|
|
7374
|
+
}
|
|
7352
7375
|
return this.storefrontRequest("GET", "/tax-classes");
|
|
7353
7376
|
}
|
|
7354
7377
|
// -------------------- Tax Classes (Admin mode, apiKey) --------------------
|
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) {
|
|
@@ -1060,7 +1060,7 @@ var BrainerceClient = class {
|
|
|
1060
1060
|
"GET",
|
|
1061
1061
|
"/products",
|
|
1062
1062
|
void 0,
|
|
1063
|
-
|
|
1063
|
+
queryParamsWithRegion
|
|
1064
1064
|
);
|
|
1065
1065
|
}
|
|
1066
1066
|
if (this.storeId && !this.apiKey) {
|
|
@@ -1090,7 +1090,7 @@ var BrainerceClient = class {
|
|
|
1090
1090
|
"GET",
|
|
1091
1091
|
`/products/${encodePathSegment(productId)}`,
|
|
1092
1092
|
void 0,
|
|
1093
|
-
|
|
1093
|
+
queryParams,
|
|
1094
1094
|
headerOverrides
|
|
1095
1095
|
);
|
|
1096
1096
|
}
|
|
@@ -7205,22 +7205,34 @@ var BrainerceClient = class {
|
|
|
7205
7205
|
`/api/v1/regions/${encodePathSegment(regionId)}/compatible-providers`
|
|
7206
7206
|
);
|
|
7207
7207
|
}
|
|
7208
|
-
// -------------------- Regions (Storefront
|
|
7209
|
-
// storeId-based, no auth. Call these from a storefront to
|
|
7210
|
-
// region (story S1), then pair with detectRegion().
|
|
7211
|
-
//
|
|
7208
|
+
// -------------------- Regions (Storefront + vibe-coded, public — no apiKey) --------------------
|
|
7209
|
+
// storeId- or connectionId-based, no auth. Call these from a storefront to
|
|
7210
|
+
// detect the buyer's region (story S1), then pair with detectRegion(). Then
|
|
7211
|
+
// pass the resolved regionId to getProducts({ regionId }) for display pricing.
|
|
7212
|
+
// Admin/api-key callers use getRegions()/getRegion() instead.
|
|
7212
7213
|
/**
|
|
7213
|
-
* List the store's ACTIVE regions (public, no apiKey).
|
|
7214
|
-
* Returns only storefront-safe fields (no internal flags).
|
|
7214
|
+
* List the store's ACTIVE regions (public, no apiKey). Works in storeId and
|
|
7215
|
+
* vibe-coded modes. Returns only storefront-safe fields (no internal flags).
|
|
7216
|
+
* Default region first.
|
|
7215
7217
|
*/
|
|
7216
7218
|
async getStoreRegions() {
|
|
7219
|
+
if (this.isVibeCodedMode()) {
|
|
7220
|
+
return this.vibeCodedRequest("GET", "/regions");
|
|
7221
|
+
}
|
|
7217
7222
|
return this.storefrontRequest("GET", "/regions");
|
|
7218
7223
|
}
|
|
7219
7224
|
/**
|
|
7220
7225
|
* Get one active public region plus its enabled payment providers (public).
|
|
7221
|
-
*
|
|
7226
|
+
* Works in storeId and vibe-coded modes. Throws 404 if the region is inactive
|
|
7227
|
+
* or not found.
|
|
7222
7228
|
*/
|
|
7223
7229
|
async getStoreRegion(regionId) {
|
|
7230
|
+
if (this.isVibeCodedMode()) {
|
|
7231
|
+
return this.vibeCodedRequest(
|
|
7232
|
+
"GET",
|
|
7233
|
+
`/regions/${encodePathSegment(regionId)}`
|
|
7234
|
+
);
|
|
7235
|
+
}
|
|
7224
7236
|
return this.storefrontRequest(
|
|
7225
7237
|
"GET",
|
|
7226
7238
|
`/regions/${encodePathSegment(regionId)}`
|
|
@@ -7248,6 +7260,14 @@ var BrainerceClient = class {
|
|
|
7248
7260
|
* default region (or `region=null` if no default exists either).
|
|
7249
7261
|
*/
|
|
7250
7262
|
async getAutoRegion(country) {
|
|
7263
|
+
if (this.isVibeCodedMode()) {
|
|
7264
|
+
return this.vibeCodedRequest(
|
|
7265
|
+
"GET",
|
|
7266
|
+
"/regions/auto",
|
|
7267
|
+
void 0,
|
|
7268
|
+
country ? { country } : void 0
|
|
7269
|
+
);
|
|
7270
|
+
}
|
|
7251
7271
|
return this.storefrontRequest(
|
|
7252
7272
|
"GET",
|
|
7253
7273
|
"/regions/auto",
|
|
@@ -7265,20 +7285,23 @@ var BrainerceClient = class {
|
|
|
7265
7285
|
* or no active rate covers it.
|
|
7266
7286
|
*/
|
|
7267
7287
|
async estimateTax(params) {
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
"/tax/estimate",
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
);
|
|
7288
|
+
const query = params.country ? { country: params.country, subtotal: params.subtotal } : { subtotal: params.subtotal };
|
|
7289
|
+
if (this.isVibeCodedMode()) {
|
|
7290
|
+
return this.vibeCodedRequest("GET", "/tax/estimate", void 0, query);
|
|
7291
|
+
}
|
|
7292
|
+
return this.storefrontRequest("GET", "/tax/estimate", void 0, query);
|
|
7274
7293
|
}
|
|
7275
|
-
// -------------------- Tax Classes (Storefront
|
|
7294
|
+
// -------------------- Tax Classes (Storefront + vibe-coded, public — no apiKey) --------------------
|
|
7276
7295
|
/**
|
|
7277
|
-
* List the store's tax classes (public, no apiKey — storeId
|
|
7278
|
-
* safe fields only (id/name/slug/description/isDefault) for
|
|
7279
|
-
* such as a "9% VAT" badge. Admin/api-key callers use
|
|
7296
|
+
* List the store's tax classes (public, no apiKey — storeId or vibe-coded
|
|
7297
|
+
* mode). Storefront-safe fields only (id/name/slug/description/isDefault) for
|
|
7298
|
+
* transparency UIs such as a "9% VAT" badge. Admin/api-key callers use
|
|
7299
|
+
* getTaxClasses().
|
|
7280
7300
|
*/
|
|
7281
7301
|
async getStoreTaxClasses() {
|
|
7302
|
+
if (this.isVibeCodedMode()) {
|
|
7303
|
+
return this.vibeCodedRequest("GET", "/tax-classes");
|
|
7304
|
+
}
|
|
7282
7305
|
return this.storefrontRequest("GET", "/tax-classes");
|
|
7283
7306
|
}
|
|
7284
7307
|
// -------------------- Tax Classes (Admin mode, apiKey) --------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.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",
|