brainerce 1.10.0 → 1.10.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.
Files changed (3) hide show
  1. package/dist/index.js +23 -17
  2. package/dist/index.mjs +23 -17
  3. package/package.json +77 -77
package/dist/index.js CHANGED
@@ -1770,7 +1770,7 @@ var BrainerceClient = class {
1770
1770
  if (!provider) {
1771
1771
  throw new BrainerceError("provider is required (e.g., 'GOOGLE', 'FACEBOOK', 'GITHUB')", 400);
1772
1772
  }
1773
- if (!this.customerToken) {
1773
+ if (!this.customerToken && !this.proxyMode) {
1774
1774
  throw new BrainerceError("Customer token is required. Call setCustomerToken() first.", 401);
1775
1775
  }
1776
1776
  const params = new URLSearchParams();
@@ -1803,7 +1803,7 @@ var BrainerceClient = class {
1803
1803
  if (!provider) {
1804
1804
  throw new BrainerceError("provider is required (e.g., 'GOOGLE', 'FACEBOOK', 'GITHUB')", 400);
1805
1805
  }
1806
- if (!this.customerToken) {
1806
+ if (!this.customerToken && !this.proxyMode) {
1807
1807
  throw new BrainerceError("Customer token is required. Call setCustomerToken() first.", 401);
1808
1808
  }
1809
1809
  if (this.isVibeCodedMode()) {
@@ -1826,7 +1826,7 @@ var BrainerceClient = class {
1826
1826
  * ```
1827
1827
  */
1828
1828
  async getOAuthConnections() {
1829
- if (!this.customerToken) {
1829
+ if (!this.customerToken && !this.proxyMode) {
1830
1830
  throw new BrainerceError("Customer token is required. Call setCustomerToken() first.", 401);
1831
1831
  }
1832
1832
  if (this.isVibeCodedMode()) {
@@ -1859,7 +1859,7 @@ var BrainerceClient = class {
1859
1859
  * ```
1860
1860
  */
1861
1861
  async getCustomerProfile() {
1862
- if (!this.customerToken) {
1862
+ if (!this.customerToken && !this.proxyMode) {
1863
1863
  throw new BrainerceError("Customer token is required. Call setCustomerToken() first.", 401);
1864
1864
  }
1865
1865
  if (this.isVibeCodedMode()) {
@@ -2221,7 +2221,7 @@ var BrainerceClient = class {
2221
2221
  * ```
2222
2222
  */
2223
2223
  async linkCart(cartId) {
2224
- if (!this.customerToken) {
2224
+ if (!this.customerToken && !this.proxyMode) {
2225
2225
  throw new BrainerceError(
2226
2226
  "Customer must be logged in to link cart. Call setCustomerToken() first.",
2227
2227
  401
@@ -2415,7 +2415,13 @@ var BrainerceClient = class {
2415
2415
  * ```
2416
2416
  */
2417
2417
  isCustomerLoggedIn() {
2418
- return this.proxyMode || !!this.customerToken;
2418
+ if (this.proxyMode) {
2419
+ if (typeof document !== "undefined") {
2420
+ return document.cookie.includes("brainerce_logged_in=1");
2421
+ }
2422
+ return false;
2423
+ }
2424
+ return !!this.customerToken;
2419
2425
  }
2420
2426
  // -------------------- Session Cart Helpers --------------------
2421
2427
  /**
@@ -2681,7 +2687,7 @@ var BrainerceClient = class {
2681
2687
  * @internal
2682
2688
  */
2683
2689
  async fetchCustomerCart() {
2684
- if (!this.customerToken) {
2690
+ if (!this.customerToken && !this.proxyMode) {
2685
2691
  throw new BrainerceError("Customer token required", 401);
2686
2692
  }
2687
2693
  if (this.isVibeCodedMode()) {
@@ -4318,7 +4324,7 @@ var BrainerceClient = class {
4318
4324
  * ```
4319
4325
  */
4320
4326
  async getMyProfile() {
4321
- if (!this.customerToken) {
4327
+ if (!this.customerToken && !this.proxyMode) {
4322
4328
  throw new BrainerceError(
4323
4329
  "Customer token required. Call setCustomerToken() after login.",
4324
4330
  401
@@ -4357,7 +4363,7 @@ var BrainerceClient = class {
4357
4363
  * ```
4358
4364
  */
4359
4365
  async getCheckoutPrefillData() {
4360
- if (!this.customerToken) {
4366
+ if (!this.customerToken && !this.proxyMode) {
4361
4367
  throw new BrainerceError(
4362
4368
  "Customer token required. Call setCustomerToken() after login.",
4363
4369
  401
@@ -4379,7 +4385,7 @@ var BrainerceClient = class {
4379
4385
  * Only available in storefront mode
4380
4386
  */
4381
4387
  async updateMyProfile(data) {
4382
- if (!this.customerToken) {
4388
+ if (!this.customerToken && !this.proxyMode) {
4383
4389
  throw new BrainerceError(
4384
4390
  "Customer token required. Call setCustomerToken() after login.",
4385
4391
  401
@@ -4401,7 +4407,7 @@ var BrainerceClient = class {
4401
4407
  * Works in vibe-coded and storefront modes
4402
4408
  */
4403
4409
  async getMyOrders(params) {
4404
- if (!this.customerToken) {
4410
+ if (!this.customerToken && !this.proxyMode) {
4405
4411
  throw new BrainerceError(
4406
4412
  "Customer token required. Call setCustomerToken() after login.",
4407
4413
  401
@@ -4448,7 +4454,7 @@ var BrainerceClient = class {
4448
4454
  * ```
4449
4455
  */
4450
4456
  async getOrderDownloads(orderId) {
4451
- if (!this.customerToken) {
4457
+ if (!this.customerToken && !this.proxyMode) {
4452
4458
  throw new BrainerceError(
4453
4459
  "Customer token required. Call setCustomerToken() after login.",
4454
4460
  401
@@ -4503,7 +4509,7 @@ var BrainerceClient = class {
4503
4509
  * Works in vibe-coded and storefront modes
4504
4510
  */
4505
4511
  async getMyAddresses() {
4506
- if (!this.customerToken) {
4512
+ if (!this.customerToken && !this.proxyMode) {
4507
4513
  throw new BrainerceError(
4508
4514
  "Customer token required. Call setCustomerToken() after login.",
4509
4515
  401
@@ -4525,7 +4531,7 @@ var BrainerceClient = class {
4525
4531
  * Works in vibe-coded and storefront modes
4526
4532
  */
4527
4533
  async addMyAddress(address) {
4528
- if (!this.customerToken) {
4534
+ if (!this.customerToken && !this.proxyMode) {
4529
4535
  throw new BrainerceError(
4530
4536
  "Customer token required. Call setCustomerToken() after login.",
4531
4537
  401
@@ -4547,7 +4553,7 @@ var BrainerceClient = class {
4547
4553
  * Works in vibe-coded and storefront modes
4548
4554
  */
4549
4555
  async updateMyAddress(addressId, data) {
4550
- if (!this.customerToken) {
4556
+ if (!this.customerToken && !this.proxyMode) {
4551
4557
  throw new BrainerceError(
4552
4558
  "Customer token required. Call setCustomerToken() after login.",
4553
4559
  401
@@ -4577,7 +4583,7 @@ var BrainerceClient = class {
4577
4583
  * Works in vibe-coded and storefront modes
4578
4584
  */
4579
4585
  async deleteMyAddress(addressId) {
4580
- if (!this.customerToken) {
4586
+ if (!this.customerToken && !this.proxyMode) {
4581
4587
  throw new BrainerceError(
4582
4588
  "Customer token required. Call setCustomerToken() after login.",
4583
4589
  401
@@ -4605,7 +4611,7 @@ var BrainerceClient = class {
4605
4611
  if (!this.storeId) {
4606
4612
  throw new BrainerceError("getMyCart is only available in storefront mode", 400);
4607
4613
  }
4608
- if (!this.customerToken) {
4614
+ if (!this.customerToken && !this.proxyMode) {
4609
4615
  throw new BrainerceError(
4610
4616
  "Customer token required. Call setCustomerToken() after login.",
4611
4617
  401
package/dist/index.mjs CHANGED
@@ -1712,7 +1712,7 @@ var BrainerceClient = class {
1712
1712
  if (!provider) {
1713
1713
  throw new BrainerceError("provider is required (e.g., 'GOOGLE', 'FACEBOOK', 'GITHUB')", 400);
1714
1714
  }
1715
- if (!this.customerToken) {
1715
+ if (!this.customerToken && !this.proxyMode) {
1716
1716
  throw new BrainerceError("Customer token is required. Call setCustomerToken() first.", 401);
1717
1717
  }
1718
1718
  const params = new URLSearchParams();
@@ -1745,7 +1745,7 @@ var BrainerceClient = class {
1745
1745
  if (!provider) {
1746
1746
  throw new BrainerceError("provider is required (e.g., 'GOOGLE', 'FACEBOOK', 'GITHUB')", 400);
1747
1747
  }
1748
- if (!this.customerToken) {
1748
+ if (!this.customerToken && !this.proxyMode) {
1749
1749
  throw new BrainerceError("Customer token is required. Call setCustomerToken() first.", 401);
1750
1750
  }
1751
1751
  if (this.isVibeCodedMode()) {
@@ -1768,7 +1768,7 @@ var BrainerceClient = class {
1768
1768
  * ```
1769
1769
  */
1770
1770
  async getOAuthConnections() {
1771
- if (!this.customerToken) {
1771
+ if (!this.customerToken && !this.proxyMode) {
1772
1772
  throw new BrainerceError("Customer token is required. Call setCustomerToken() first.", 401);
1773
1773
  }
1774
1774
  if (this.isVibeCodedMode()) {
@@ -1801,7 +1801,7 @@ var BrainerceClient = class {
1801
1801
  * ```
1802
1802
  */
1803
1803
  async getCustomerProfile() {
1804
- if (!this.customerToken) {
1804
+ if (!this.customerToken && !this.proxyMode) {
1805
1805
  throw new BrainerceError("Customer token is required. Call setCustomerToken() first.", 401);
1806
1806
  }
1807
1807
  if (this.isVibeCodedMode()) {
@@ -2163,7 +2163,7 @@ var BrainerceClient = class {
2163
2163
  * ```
2164
2164
  */
2165
2165
  async linkCart(cartId) {
2166
- if (!this.customerToken) {
2166
+ if (!this.customerToken && !this.proxyMode) {
2167
2167
  throw new BrainerceError(
2168
2168
  "Customer must be logged in to link cart. Call setCustomerToken() first.",
2169
2169
  401
@@ -2357,7 +2357,13 @@ var BrainerceClient = class {
2357
2357
  * ```
2358
2358
  */
2359
2359
  isCustomerLoggedIn() {
2360
- return this.proxyMode || !!this.customerToken;
2360
+ if (this.proxyMode) {
2361
+ if (typeof document !== "undefined") {
2362
+ return document.cookie.includes("brainerce_logged_in=1");
2363
+ }
2364
+ return false;
2365
+ }
2366
+ return !!this.customerToken;
2361
2367
  }
2362
2368
  // -------------------- Session Cart Helpers --------------------
2363
2369
  /**
@@ -2623,7 +2629,7 @@ var BrainerceClient = class {
2623
2629
  * @internal
2624
2630
  */
2625
2631
  async fetchCustomerCart() {
2626
- if (!this.customerToken) {
2632
+ if (!this.customerToken && !this.proxyMode) {
2627
2633
  throw new BrainerceError("Customer token required", 401);
2628
2634
  }
2629
2635
  if (this.isVibeCodedMode()) {
@@ -4260,7 +4266,7 @@ var BrainerceClient = class {
4260
4266
  * ```
4261
4267
  */
4262
4268
  async getMyProfile() {
4263
- if (!this.customerToken) {
4269
+ if (!this.customerToken && !this.proxyMode) {
4264
4270
  throw new BrainerceError(
4265
4271
  "Customer token required. Call setCustomerToken() after login.",
4266
4272
  401
@@ -4299,7 +4305,7 @@ var BrainerceClient = class {
4299
4305
  * ```
4300
4306
  */
4301
4307
  async getCheckoutPrefillData() {
4302
- if (!this.customerToken) {
4308
+ if (!this.customerToken && !this.proxyMode) {
4303
4309
  throw new BrainerceError(
4304
4310
  "Customer token required. Call setCustomerToken() after login.",
4305
4311
  401
@@ -4321,7 +4327,7 @@ var BrainerceClient = class {
4321
4327
  * Only available in storefront mode
4322
4328
  */
4323
4329
  async updateMyProfile(data) {
4324
- if (!this.customerToken) {
4330
+ if (!this.customerToken && !this.proxyMode) {
4325
4331
  throw new BrainerceError(
4326
4332
  "Customer token required. Call setCustomerToken() after login.",
4327
4333
  401
@@ -4343,7 +4349,7 @@ var BrainerceClient = class {
4343
4349
  * Works in vibe-coded and storefront modes
4344
4350
  */
4345
4351
  async getMyOrders(params) {
4346
- if (!this.customerToken) {
4352
+ if (!this.customerToken && !this.proxyMode) {
4347
4353
  throw new BrainerceError(
4348
4354
  "Customer token required. Call setCustomerToken() after login.",
4349
4355
  401
@@ -4390,7 +4396,7 @@ var BrainerceClient = class {
4390
4396
  * ```
4391
4397
  */
4392
4398
  async getOrderDownloads(orderId) {
4393
- if (!this.customerToken) {
4399
+ if (!this.customerToken && !this.proxyMode) {
4394
4400
  throw new BrainerceError(
4395
4401
  "Customer token required. Call setCustomerToken() after login.",
4396
4402
  401
@@ -4445,7 +4451,7 @@ var BrainerceClient = class {
4445
4451
  * Works in vibe-coded and storefront modes
4446
4452
  */
4447
4453
  async getMyAddresses() {
4448
- if (!this.customerToken) {
4454
+ if (!this.customerToken && !this.proxyMode) {
4449
4455
  throw new BrainerceError(
4450
4456
  "Customer token required. Call setCustomerToken() after login.",
4451
4457
  401
@@ -4467,7 +4473,7 @@ var BrainerceClient = class {
4467
4473
  * Works in vibe-coded and storefront modes
4468
4474
  */
4469
4475
  async addMyAddress(address) {
4470
- if (!this.customerToken) {
4476
+ if (!this.customerToken && !this.proxyMode) {
4471
4477
  throw new BrainerceError(
4472
4478
  "Customer token required. Call setCustomerToken() after login.",
4473
4479
  401
@@ -4489,7 +4495,7 @@ var BrainerceClient = class {
4489
4495
  * Works in vibe-coded and storefront modes
4490
4496
  */
4491
4497
  async updateMyAddress(addressId, data) {
4492
- if (!this.customerToken) {
4498
+ if (!this.customerToken && !this.proxyMode) {
4493
4499
  throw new BrainerceError(
4494
4500
  "Customer token required. Call setCustomerToken() after login.",
4495
4501
  401
@@ -4519,7 +4525,7 @@ var BrainerceClient = class {
4519
4525
  * Works in vibe-coded and storefront modes
4520
4526
  */
4521
4527
  async deleteMyAddress(addressId) {
4522
- if (!this.customerToken) {
4528
+ if (!this.customerToken && !this.proxyMode) {
4523
4529
  throw new BrainerceError(
4524
4530
  "Customer token required. Call setCustomerToken() after login.",
4525
4531
  401
@@ -4547,7 +4553,7 @@ var BrainerceClient = class {
4547
4553
  if (!this.storeId) {
4548
4554
  throw new BrainerceError("getMyCart is only available in storefront mode", 400);
4549
4555
  }
4550
- if (!this.customerToken) {
4556
+ if (!this.customerToken && !this.proxyMode) {
4551
4557
  throw new BrainerceError(
4552
4558
  "Customer token required. Call setCustomerToken() after login.",
4553
4559
  401
package/package.json CHANGED
@@ -1,77 +1,77 @@
1
- {
2
- "name": "brainerce",
3
- "version": "1.10.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
- },
15
- "files": [
16
- "dist",
17
- "README.md",
18
- "AI_BUILDER_PROMPT.md"
19
- ],
20
- "scripts": {
21
- "build": "tsup src/index.ts --format cjs,esm --dts",
22
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
23
- "lint": "eslint \"src/**/*.ts\"",
24
- "test": "vitest run",
25
- "test:watch": "vitest",
26
- "prepublishOnly": "pnpm build"
27
- },
28
- "keywords": [
29
- "brainerce",
30
- "e-commerce",
31
- "ecommerce",
32
- "sdk",
33
- "vibe-coding",
34
- "vibe-coded",
35
- "ai-commerce",
36
- "storefront",
37
- "headless-commerce",
38
- "multi-platform",
39
- "shopify",
40
- "tiktok",
41
- "cursor",
42
- "lovable",
43
- "v0",
44
- "cart",
45
- "checkout",
46
- "products",
47
- "sync"
48
- ],
49
- "author": "Brainerce",
50
- "license": "MIT",
51
- "repository": {
52
- "type": "git",
53
- "url": "https://github.com/brainerce/brainerce.git",
54
- "directory": "packages/sdk"
55
- },
56
- "homepage": "https://brainerce.com",
57
- "bugs": {
58
- "url": "https://github.com/brainerce/brainerce/issues"
59
- },
60
- "devDependencies": {
61
- "@types/node": "^25.0.3",
62
- "@typescript-eslint/eslint-plugin": "^8.50.1",
63
- "@typescript-eslint/parser": "^8.50.1",
64
- "eslint": "^9.39.2",
65
- "tsup": "^8.0.0",
66
- "typescript": "^5.3.0",
67
- "vitest": "^1.0.0"
68
- },
69
- "peerDependencies": {
70
- "typescript": ">=4.7.0"
71
- },
72
- "peerDependenciesMeta": {
73
- "typescript": {
74
- "optional": true
75
- }
76
- }
77
- }
1
+ {
2
+ "name": "brainerce",
3
+ "version": "1.10.2",
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
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "AI_BUILDER_PROMPT.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsup src/index.ts --format cjs,esm --dts",
22
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
23
+ "lint": "eslint \"src/**/*.ts\"",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "prepublishOnly": "pnpm build"
27
+ },
28
+ "keywords": [
29
+ "brainerce",
30
+ "e-commerce",
31
+ "ecommerce",
32
+ "sdk",
33
+ "vibe-coding",
34
+ "vibe-coded",
35
+ "ai-commerce",
36
+ "storefront",
37
+ "headless-commerce",
38
+ "multi-platform",
39
+ "shopify",
40
+ "tiktok",
41
+ "cursor",
42
+ "lovable",
43
+ "v0",
44
+ "cart",
45
+ "checkout",
46
+ "products",
47
+ "sync"
48
+ ],
49
+ "author": "Brainerce",
50
+ "license": "MIT",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "https://github.com/brainerce/brainerce.git",
54
+ "directory": "packages/sdk"
55
+ },
56
+ "homepage": "https://brainerce.com",
57
+ "bugs": {
58
+ "url": "https://github.com/brainerce/brainerce/issues"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^25.0.3",
62
+ "@typescript-eslint/eslint-plugin": "^8.50.1",
63
+ "@typescript-eslint/parser": "^8.50.1",
64
+ "eslint": "^9.39.2",
65
+ "tsup": "^8.0.0",
66
+ "typescript": "^5.3.0",
67
+ "vitest": "^1.0.0"
68
+ },
69
+ "peerDependencies": {
70
+ "typescript": ">=4.7.0"
71
+ },
72
+ "peerDependenciesMeta": {
73
+ "typescript": {
74
+ "optional": true
75
+ }
76
+ }
77
+ }