brainerce 1.44.1 → 1.46.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/dist/index.mjs CHANGED
@@ -115,7 +115,7 @@ function isDevGuardsEnabled() {
115
115
  }
116
116
 
117
117
  // src/version.ts
118
- var SDK_VERSION = "1.42.0";
118
+ var SDK_VERSION = "1.45.0";
119
119
 
120
120
  // src/client.ts
121
121
  var DEFAULT_BASE_URL = "https://api.brainerce.com";
@@ -4854,6 +4854,102 @@ var BrainerceClient = class {
4854
4854
  `/api/v1/checkout/${encodePathSegment(checkoutId)}/shipping-rates`
4855
4855
  );
4856
4856
  }
4857
+ /**
4858
+ * Address autocomplete predictions for a checkout address field.
4859
+ *
4860
+ * `sessionToken` groups one address-entry attempt together for billing —
4861
+ * generate a fresh id (e.g. `crypto.randomUUID()`) when the field is
4862
+ * focused, reuse it for every keystroke, then pass the same value once more
4863
+ * to `getAddressDetails()` when the shopper picks a suggestion. Debounce
4864
+ * calls to this method (e.g. 300ms) rather than firing on every keystroke.
4865
+ *
4866
+ * @example
4867
+ * ```typescript
4868
+ * const sessionToken = crypto.randomUUID();
4869
+ * const suggestions = await client.getAddressSuggestions('123 Main', sessionToken);
4870
+ * ```
4871
+ */
4872
+ async getAddressSuggestions(query, sessionToken, near) {
4873
+ const queryParams = {
4874
+ q: query,
4875
+ sessionToken,
4876
+ lat: near?.lat,
4877
+ lng: near?.lng
4878
+ };
4879
+ if (this.isVibeCodedMode()) {
4880
+ const result2 = await this.vibeCodedRequest(
4881
+ "GET",
4882
+ "/checkout/address-suggestions",
4883
+ void 0,
4884
+ queryParams
4885
+ );
4886
+ return result2.suggestions;
4887
+ }
4888
+ if (this.storeId && !this.apiKey) {
4889
+ const result2 = await this.storefrontRequest(
4890
+ "GET",
4891
+ "/checkout/address-suggestions",
4892
+ void 0,
4893
+ queryParams
4894
+ );
4895
+ return result2.suggestions;
4896
+ }
4897
+ const result = await this.adminRequest(
4898
+ "GET",
4899
+ "/api/v1/checkout/address-suggestions",
4900
+ void 0,
4901
+ queryParams
4902
+ );
4903
+ return result.suggestions;
4904
+ }
4905
+ /**
4906
+ * Resolve a predicted place (from `getAddressSuggestions()`) to a full
4907
+ * postal address + coordinates, and whether it falls inside any of the
4908
+ * store's shipping zones. Pass the SAME `sessionToken` used for the
4909
+ * preceding suggestion calls — this is the billed call that ends the
4910
+ * autocomplete session.
4911
+ *
4912
+ * `inZone: false` is a soft signal, not a rejection — pair it with a
4913
+ * banner like "outside our regular delivery zones, we'll confirm by phone"
4914
+ * and still let the shopper continue.
4915
+ *
4916
+ * @example
4917
+ * ```typescript
4918
+ * const details = await client.getAddressDetails(suggestion.placeId, sessionToken);
4919
+ * if (!details.inZone) {
4920
+ * showOutsideZoneBanner();
4921
+ * }
4922
+ * ```
4923
+ */
4924
+ async getAddressDetails(placeId, sessionToken, options) {
4925
+ const queryParams = {
4926
+ placeId,
4927
+ sessionToken,
4928
+ regionId: options?.regionId
4929
+ };
4930
+ if (this.isVibeCodedMode()) {
4931
+ return this.vibeCodedRequest(
4932
+ "GET",
4933
+ "/checkout/address-details",
4934
+ void 0,
4935
+ queryParams
4936
+ );
4937
+ }
4938
+ if (this.storeId && !this.apiKey) {
4939
+ return this.storefrontRequest(
4940
+ "GET",
4941
+ "/checkout/address-details",
4942
+ void 0,
4943
+ queryParams
4944
+ );
4945
+ }
4946
+ return this.adminRequest(
4947
+ "GET",
4948
+ "/api/v1/checkout/address-details",
4949
+ void 0,
4950
+ queryParams
4951
+ );
4952
+ }
4857
4953
  /**
4858
4954
  * Select a shipping method for checkout
4859
4955
  *
@@ -5498,10 +5594,7 @@ var BrainerceClient = class {
5498
5594
  "order"
5499
5595
  );
5500
5596
  }
5501
- throw new BrainerceError(
5502
- "getOrderByCheckout() requires vibe-coded or storefront mode",
5503
- 400
5504
- );
5597
+ throw new BrainerceError("getOrderByCheckout() requires vibe-coded or storefront mode", 400);
5505
5598
  }
5506
5599
  /**
5507
5600
  * Check if localStorage is available (browser environment)
@@ -8322,6 +8415,55 @@ var BrainerceClient = class {
8322
8415
  async updateEmailSettings(data) {
8323
8416
  return this.adminRequest("PUT", "/api/v1/email/settings", data);
8324
8417
  }
8418
+ /**
8419
+ * Get Storefront Bot (AI Shopping Assistant) settings for every connection
8420
+ * on the store — name, avatar, persona, starter questions, guardrails,
8421
+ * capabilities. Requires Admin mode (apiKey).
8422
+ */
8423
+ async getBotSettings() {
8424
+ return this.adminRequest("GET", "/api/v1/storefront-bot/settings");
8425
+ }
8426
+ /**
8427
+ * Create/update one connection's Storefront Bot settings. Only fields
8428
+ * present in `data` are changed (PATCH semantics). Requires Admin mode
8429
+ * (apiKey).
8430
+ */
8431
+ async updateBotSettings(data) {
8432
+ return this.adminRequest("PUT", "/api/v1/storefront-bot/settings", data);
8433
+ }
8434
+ /**
8435
+ * Paginated Storefront Bot conversation inbox, optionally filtered to one
8436
+ * connection. Requires Admin mode (apiKey).
8437
+ */
8438
+ async listBotConversations(opts) {
8439
+ return this.adminRequest(
8440
+ "GET",
8441
+ "/api/v1/storefront-bot/conversations",
8442
+ void 0,
8443
+ opts
8444
+ );
8445
+ }
8446
+ /**
8447
+ * Full transcript for one Storefront Bot conversation, including its
8448
+ * summary if one was generated. Requires Admin mode (apiKey).
8449
+ */
8450
+ async getBotConversation(conversationId) {
8451
+ return this.adminRequest(
8452
+ "GET",
8453
+ `/api/v1/storefront-bot/conversations/${conversationId}`
8454
+ );
8455
+ }
8456
+ /**
8457
+ * Summarize a Storefront Bot conversation on demand and persist the
8458
+ * summary. Short threads (10 or fewer messages) are a graceful no-op — no
8459
+ * credits charged. Requires Admin mode (apiKey).
8460
+ */
8461
+ async summarizeBotConversation(conversationId) {
8462
+ return this.adminRequest(
8463
+ "POST",
8464
+ `/api/v1/storefront-bot/conversations/${conversationId}/summarize`
8465
+ );
8466
+ }
8325
8467
  /**
8326
8468
  * Get all email templates for the store, grouped by (eventType, language).
8327
8469
  * Response includes the store's primary language and supported languages so
package/package.json CHANGED
@@ -1,81 +1,81 @@
1
- {
2
- "name": "brainerce",
3
- "version": "1.44.1",
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
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "require": "./dist/index.js",
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"
18
- }
19
- },
20
- "files": [
21
- "dist",
22
- "README.md"
23
- ],
24
- "scripts": {
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",
26
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
27
- "lint": "eslint \"src/**/*.ts\"",
28
- "test": "vitest run",
29
- "test:watch": "vitest",
30
- "prepublishOnly": "pnpm build"
31
- },
32
- "keywords": [
33
- "brainerce",
34
- "e-commerce",
35
- "ecommerce",
36
- "sdk",
37
- "vibe-coding",
38
- "vibe-coded",
39
- "ai-commerce",
40
- "storefront",
41
- "headless-commerce",
42
- "multi-platform",
43
- "shopify",
44
- "tiktok",
45
- "cursor",
46
- "lovable",
47
- "v0",
48
- "cart",
49
- "checkout",
50
- "products",
51
- "sync"
52
- ],
53
- "author": "Brainerce",
54
- "license": "MIT",
55
- "repository": {
56
- "type": "git",
57
- "url": "https://github.com/brainerce/brainerce.git",
58
- "directory": "packages/sdk"
59
- },
60
- "homepage": "https://brainerce.com",
61
- "bugs": {
62
- "url": "https://github.com/brainerce/brainerce/issues"
63
- },
64
- "devDependencies": {
65
- "@types/node": "^25.0.3",
66
- "@typescript-eslint/eslint-plugin": "^8.50.1",
67
- "@typescript-eslint/parser": "^8.50.1",
68
- "eslint": "^9.39.2",
69
- "tsup": "^8.0.0",
70
- "typescript": "^5.3.0",
71
- "vitest": "^1.0.0"
72
- },
73
- "peerDependencies": {
74
- "typescript": ">=4.7.0"
75
- },
76
- "peerDependenciesMeta": {
77
- "typescript": {
78
- "optional": true
79
- }
80
- }
81
- }
1
+ {
2
+ "name": "brainerce",
3
+ "version": "1.46.0",
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
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
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"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "scripts": {
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",
26
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
27
+ "lint": "eslint \"src/**/*.ts\"",
28
+ "test": "vitest run",
29
+ "test:watch": "vitest",
30
+ "prepublishOnly": "pnpm build"
31
+ },
32
+ "keywords": [
33
+ "brainerce",
34
+ "e-commerce",
35
+ "ecommerce",
36
+ "sdk",
37
+ "vibe-coding",
38
+ "vibe-coded",
39
+ "ai-commerce",
40
+ "storefront",
41
+ "headless-commerce",
42
+ "multi-platform",
43
+ "shopify",
44
+ "tiktok",
45
+ "cursor",
46
+ "lovable",
47
+ "v0",
48
+ "cart",
49
+ "checkout",
50
+ "products",
51
+ "sync"
52
+ ],
53
+ "author": "Brainerce",
54
+ "license": "MIT",
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "https://github.com/brainerce/brainerce.git",
58
+ "directory": "packages/sdk"
59
+ },
60
+ "homepage": "https://brainerce.com",
61
+ "bugs": {
62
+ "url": "https://github.com/brainerce/brainerce/issues"
63
+ },
64
+ "devDependencies": {
65
+ "@types/node": "^25.0.3",
66
+ "@typescript-eslint/eslint-plugin": "^8.50.1",
67
+ "@typescript-eslint/parser": "^8.50.1",
68
+ "eslint": "^9.39.2",
69
+ "tsup": "^8.0.0",
70
+ "typescript": "^5.3.0",
71
+ "vitest": "^1.0.0"
72
+ },
73
+ "peerDependencies": {
74
+ "typescript": ">=4.7.0"
75
+ },
76
+ "peerDependenciesMeta": {
77
+ "typescript": {
78
+ "optional": true
79
+ }
80
+ }
81
+ }