brainerce 1.28.1 → 1.30.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 +20 -0
- package/dist/bot/bootstrap.global.js +57 -0
- package/dist/bot/index.d.mts +63 -0
- package/dist/bot/index.d.ts +63 -0
- package/dist/bot/index.js +532 -0
- package/dist/bot/index.mjs +505 -0
- package/dist/index.d.mts +56 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +38 -0
- package/dist/index.mjs +38 -0
- package/package.json +7 -2
package/dist/index.mjs
CHANGED
|
@@ -6984,6 +6984,44 @@ var BrainerceClient = class {
|
|
|
6984
6984
|
const code = country.toUpperCase();
|
|
6985
6985
|
return regions.find((r) => r.countries.includes(code)) ?? regions.find((r) => r.isDefault) ?? null;
|
|
6986
6986
|
}
|
|
6987
|
+
/**
|
|
6988
|
+
* Server-side region resolution in one round trip (storefront seam). Pair
|
|
6989
|
+
* with the country your edge runtime extracts — Cloudflare `CF-IPCountry`,
|
|
6990
|
+
* Vercel `request.geo?.country`, Fastly `client-geo-country`, etc.
|
|
6991
|
+
*
|
|
6992
|
+
* Brainerce does NOT derive the country from the request IP server-side
|
|
6993
|
+
* because the storefront server is what reaches the backend (not the end-
|
|
6994
|
+
* customer). The storefront must extract + forward the country.
|
|
6995
|
+
*
|
|
6996
|
+
* Returns `{ region, matched, country }` — `matched=true` means the country
|
|
6997
|
+
* was explicitly listed by a region; `false` means we fell back to the
|
|
6998
|
+
* default region (or `region=null` if no default exists either).
|
|
6999
|
+
*/
|
|
7000
|
+
async getAutoRegion(country) {
|
|
7001
|
+
return this.storefrontRequest(
|
|
7002
|
+
"GET",
|
|
7003
|
+
"/regions/auto",
|
|
7004
|
+
void 0,
|
|
7005
|
+
country ? { country } : void 0
|
|
7006
|
+
);
|
|
7007
|
+
}
|
|
7008
|
+
/**
|
|
7009
|
+
* Non-binding tax preview for PDP / PLP / cart. Pass the buyer's country
|
|
7010
|
+
* (from your edge runtime — same source as `getAutoRegion`) and the current
|
|
7011
|
+
* items subtotal in the store currency. The authoritative tax still runs
|
|
7012
|
+
* at checkout — render with an "Estimate" affordance.
|
|
7013
|
+
*
|
|
7014
|
+
* Returns `appliesTax=false` when tax is disabled, the country is missing,
|
|
7015
|
+
* or no active rate covers it.
|
|
7016
|
+
*/
|
|
7017
|
+
async estimateTax(params) {
|
|
7018
|
+
return this.storefrontRequest(
|
|
7019
|
+
"GET",
|
|
7020
|
+
"/tax/estimate",
|
|
7021
|
+
void 0,
|
|
7022
|
+
params.country ? { country: params.country, subtotal: params.subtotal } : { subtotal: params.subtotal }
|
|
7023
|
+
);
|
|
7024
|
+
}
|
|
6987
7025
|
// -------------------- Tax Classes (Storefront mode, public — no apiKey) --------------------
|
|
6988
7026
|
/**
|
|
6989
7027
|
* List the store's tax classes (public, no apiKey — storeId mode). Storefront-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.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",
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"require": "./dist/index.js",
|
|
12
12
|
"import": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./bot": {
|
|
15
|
+
"types": "./dist/bot/index.d.ts",
|
|
16
|
+
"require": "./dist/bot/index.js",
|
|
17
|
+
"import": "./dist/bot/index.mjs"
|
|
13
18
|
}
|
|
14
19
|
},
|
|
15
20
|
"files": [
|
|
@@ -17,7 +22,7 @@
|
|
|
17
22
|
"README.md"
|
|
18
23
|
],
|
|
19
24
|
"scripts": {
|
|
20
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
25
|
+
"build": "tsup src/index.ts --format cjs,esm --dts && tsup src/bot/index.ts --format cjs,esm --dts --out-dir dist/bot && tsup src/bot/bootstrap.ts --format iife --minify --out-dir dist/bot",
|
|
21
26
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
22
27
|
"lint": "eslint \"src/**/*.ts\"",
|
|
23
28
|
"test": "vitest run",
|