brainerce 1.0.0 → 1.0.1

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.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -22,8 +32,6 @@ var index_exports = {};
22
32
  __export(index_exports, {
23
33
  BrainerceClient: () => BrainerceClient,
24
34
  BrainerceError: () => BrainerceError,
25
- OmniSyncClient: () => OmniSyncClient,
26
- OmniSyncError: () => OmniSyncError,
27
35
  createWebhookHandler: () => createWebhookHandler,
28
36
  enableDevGuards: () => enableDevGuards,
29
37
  formatPrice: () => formatPrice,
@@ -180,15 +188,15 @@ var BrainerceClient = class {
180
188
  * localStorage key for persisting active checkout across page redirects.
181
189
  * This is needed because Stripe redirects lose in-memory state.
182
190
  */
183
- this.ACTIVE_CHECKOUT_KEY = "omni_active_checkout";
191
+ this.ACTIVE_CHECKOUT_KEY = "brainerce_active_checkout";
184
192
  // -------------------- Local Cart (Client-Side for Guests) --------------------
185
193
  // These methods store cart data in localStorage - NO API calls!
186
194
  // Use for guest users in vibe-coded sites
187
- this.LOCAL_CART_KEY = "omni_cart";
195
+ this.LOCAL_CART_KEY = "brainerce_cart";
188
196
  if (!options.apiKey && !options.storeId && !options.connectionId) {
189
197
  throw new Error("BrainerceClient: either connectionId, apiKey, or storeId is required");
190
198
  }
191
- if (options.apiKey && !options.apiKey.startsWith("brainerce_") && !options.apiKey.startsWith("omni_")) {
199
+ if (options.apiKey && !options.apiKey.startsWith("brainerce_")) {
192
200
  console.warn('BrainerceClient: apiKey should start with "brainerce_"');
193
201
  }
194
202
  if (options.connectionId && !options.connectionId.startsWith("vc_")) {
@@ -262,11 +270,11 @@ var BrainerceClient = class {
262
270
  *
263
271
  * @example
264
272
  * ```typescript
265
- * const auth = await omni.loginCustomer('user@example.com', 'password');
266
- * omni.setCustomerToken(auth.token);
273
+ * const auth = await client.loginCustomer('user@example.com', 'password');
274
+ * client.setCustomerToken(auth.token);
267
275
  *
268
276
  * // Now can access customer data
269
- * const profile = await omni.getMyProfile();
277
+ * const profile = await client.getMyProfile();
270
278
  * ```
271
279
  */
272
280
  setCustomerToken(token) {
@@ -504,10 +512,10 @@ var BrainerceClient = class {
504
512
  * @example
505
513
  * ```typescript
506
514
  * // Basic usage
507
- * const products = await omni.getProducts({ page: 1, limit: 20 });
515
+ * const products = await client.getProducts({ page: 1, limit: 20 });
508
516
  *
509
517
  * // With filters (vibe-coded mode)
510
- * const filtered = await omni.getProducts({
518
+ * const filtered = await client.getProducts({
511
519
  * categories: ['cat_123', 'cat_456'],
512
520
  * minPrice: 10,
513
521
  * maxPrice: 100,
@@ -578,7 +586,7 @@ var BrainerceClient = class {
578
586
  * @example
579
587
  * ```typescript
580
588
  * // Get product by its URL-friendly slug
581
- * const product = await omni.getProductBySlug('awesome-product-name');
589
+ * const product = await client.getProductBySlug('awesome-product-name');
582
590
  * ```
583
591
  */
584
592
  async getProductBySlug(slug) {
@@ -596,7 +604,7 @@ var BrainerceClient = class {
596
604
  *
597
605
  * @example
598
606
  * ```typescript
599
- * const { categories } = await omni.getCategories();
607
+ * const { categories } = await client.getCategories();
600
608
  * // categories is a tree structure with children
601
609
  * ```
602
610
  */
@@ -612,7 +620,7 @@ var BrainerceClient = class {
612
620
  *
613
621
  * @example
614
622
  * ```typescript
615
- * const { brands } = await omni.getBrands();
623
+ * const { brands } = await client.getBrands();
616
624
  * // Use brand IDs in getProducts({ brands: ['brand_id'] })
617
625
  * ```
618
626
  */
@@ -628,7 +636,7 @@ var BrainerceClient = class {
628
636
  *
629
637
  * @example
630
638
  * ```typescript
631
- * const { tags } = await omni.getTags();
639
+ * const { tags } = await client.getTags();
632
640
  * // Use tag IDs in getProducts({ tags: ['tag_id'] })
633
641
  * ```
634
642
  */
@@ -650,12 +658,12 @@ var BrainerceClient = class {
650
658
  * @example
651
659
  * ```typescript
652
660
  * // Basic autocomplete
653
- * const suggestions = await omni.getSearchSuggestions('shirt');
661
+ * const suggestions = await client.getSearchSuggestions('shirt');
654
662
  * console.log(suggestions.products); // [{ id, name, image, basePrice, type }]
655
663
  * console.log(suggestions.categories); // [{ id, name, productCount }]
656
664
  *
657
665
  * // With custom limit
658
- * const suggestions = await omni.getSearchSuggestions('dress', 3);
666
+ * const suggestions = await client.getSearchSuggestions('dress', 3);
659
667
  * ```
660
668
  */
661
669
  async getSearchSuggestions(query, limit) {
@@ -708,11 +716,11 @@ var BrainerceClient = class {
708
716
  *
709
717
  * @example
710
718
  * ```typescript
711
- * // Delete from Omni only
712
- * const result = await omni.deleteProduct('prod_123');
719
+ * // Delete from Brainerce only
720
+ * const result = await client.deleteProduct('prod_123');
713
721
  *
714
- * // Delete from Omni and connected platforms
715
- * const result = await omni.deleteProduct('prod_123', {
722
+ * // Delete from Brainerce and connected platforms
723
+ * const result = await client.deleteProduct('prod_123', {
716
724
  * platforms: ['SHOPIFY', 'WOOCOMMERCE']
717
725
  * });
718
726
  * console.log(result.success); // true
@@ -734,7 +742,7 @@ var BrainerceClient = class {
734
742
  *
735
743
  * @example
736
744
  * ```typescript
737
- * const product = await omni.convertToVariable('prod_123');
745
+ * const product = await client.convertToVariable('prod_123');
738
746
  * console.log('Product type:', product.type); // 'VARIABLE'
739
747
  * ```
740
748
  */
@@ -747,7 +755,7 @@ var BrainerceClient = class {
747
755
  *
748
756
  * @example
749
757
  * ```typescript
750
- * const product = await omni.convertToSimple('prod_123');
758
+ * const product = await client.convertToSimple('prod_123');
751
759
  * console.log('Product type:', product.type); // 'SIMPLE'
752
760
  * ```
753
761
  */
@@ -759,7 +767,7 @@ var BrainerceClient = class {
759
767
  *
760
768
  * @example
761
769
  * ```typescript
762
- * const result = await omni.publishProduct('prod_123', ['SHOPIFY', 'WOOCOMMERCE']);
770
+ * const result = await client.publishProduct('prod_123', ['SHOPIFY', 'WOOCOMMERCE']);
763
771
  * console.log('Publish results:', result.results);
764
772
  * ```
765
773
  */
@@ -774,7 +782,7 @@ var BrainerceClient = class {
774
782
  *
775
783
  * @example
776
784
  * ```typescript
777
- * const variant = await omni.createVariant('prod_123', {
785
+ * const variant = await client.createVariant('prod_123', {
778
786
  * sku: 'PROD-SM-RED',
779
787
  * name: 'Small / Red',
780
788
  * attributes: { size: 'S', color: 'Red' },
@@ -791,7 +799,7 @@ var BrainerceClient = class {
791
799
  *
792
800
  * @example
793
801
  * ```typescript
794
- * const result = await omni.bulkSaveVariants('prod_123', {
802
+ * const result = await client.bulkSaveVariants('prod_123', {
795
803
  * variants: [
796
804
  * { sku: 'SM-RED', attributes: { size: 'S', color: 'Red' }, stock: 10, isEnabled: true },
797
805
  * { id: 'var_456', sku: 'MD-BLUE', attributes: { size: 'M', color: 'Blue' }, stock: 5, isEnabled: true },
@@ -813,7 +821,7 @@ var BrainerceClient = class {
813
821
  *
814
822
  * @example
815
823
  * ```typescript
816
- * const variant = await omni.updateVariant('prod_123', 'var_456', {
824
+ * const variant = await client.updateVariant('prod_123', 'var_456', {
817
825
  * price: 34.99,
818
826
  * salePrice: 29.99,
819
827
  * });
@@ -831,7 +839,7 @@ var BrainerceClient = class {
831
839
  *
832
840
  * @example
833
841
  * ```typescript
834
- * await omni.deleteVariant('prod_123', 'var_456');
842
+ * await client.deleteVariant('prod_123', 'var_456');
835
843
  * ```
836
844
  */
837
845
  async deleteVariant(productId, variantId) {
@@ -842,7 +850,7 @@ var BrainerceClient = class {
842
850
  *
843
851
  * @example
844
852
  * ```typescript
845
- * const inventory = await omni.getVariantInventory('prod_123', 'var_456');
853
+ * const inventory = await client.getVariantInventory('prod_123', 'var_456');
846
854
  * console.log('Available:', inventory.available);
847
855
  * ```
848
856
  */
@@ -857,7 +865,7 @@ var BrainerceClient = class {
857
865
  *
858
866
  * @example
859
867
  * ```typescript
860
- * const inventory = await omni.updateVariantInventory('prod_123', 'var_456', {
868
+ * const inventory = await client.updateVariantInventory('prod_123', 'var_456', {
861
869
  * newTotal: 50,
862
870
  * reason: 'Restocked from supplier',
863
871
  * });
@@ -910,7 +918,7 @@ var BrainerceClient = class {
910
918
  *
911
919
  * @example
912
920
  * ```typescript
913
- * const order = await omni.updateOrderStatus('order_123', 'shipped');
921
+ * const order = await client.updateOrderStatus('order_123', 'shipped');
914
922
  * ```
915
923
  */
916
924
  async updateOrderStatus(orderId, status) {
@@ -922,7 +930,7 @@ var BrainerceClient = class {
922
930
  *
923
931
  * @example
924
932
  * ```typescript
925
- * const order = await omni.updatePaymentMethod('order_123', 'credit_card');
933
+ * const order = await client.updatePaymentMethod('order_123', 'credit_card');
926
934
  * ```
927
935
  */
928
936
  async updatePaymentMethod(orderId, paymentMethod) {
@@ -935,7 +943,7 @@ var BrainerceClient = class {
935
943
  *
936
944
  * @example
937
945
  * ```typescript
938
- * const order = await omni.updateOrderNotes('order_123', 'Customer requested gift wrapping');
946
+ * const order = await client.updateOrderNotes('order_123', 'Customer requested gift wrapping');
939
947
  * ```
940
948
  */
941
949
  async updateOrderNotes(orderId, notes) {
@@ -947,7 +955,7 @@ var BrainerceClient = class {
947
955
  *
948
956
  * @example
949
957
  * ```typescript
950
- * const refunds = await omni.getOrderRefunds('order_123');
958
+ * const refunds = await client.getOrderRefunds('order_123');
951
959
  * console.log('Total refunds:', refunds.length);
952
960
  * ```
953
961
  */
@@ -961,7 +969,7 @@ var BrainerceClient = class {
961
969
  * @example
962
970
  * ```typescript
963
971
  * // Full refund
964
- * const refund = await omni.createRefund('order_123', {
972
+ * const refund = await client.createRefund('order_123', {
965
973
  * type: 'full',
966
974
  * restockInventory: true,
967
975
  * notifyCustomer: true,
@@ -969,7 +977,7 @@ var BrainerceClient = class {
969
977
  * });
970
978
  *
971
979
  * // Partial refund
972
- * const partialRefund = await omni.createRefund('order_123', {
980
+ * const partialRefund = await client.createRefund('order_123', {
973
981
  * type: 'partial',
974
982
  * items: [
975
983
  * { lineItemId: 'item_456', quantity: 1 },
@@ -987,7 +995,7 @@ var BrainerceClient = class {
987
995
  *
988
996
  * @example
989
997
  * ```typescript
990
- * const order = await omni.updateOrderShipping('order_123', {
998
+ * const order = await client.updateOrderShipping('order_123', {
991
999
  * firstName: 'John',
992
1000
  * lastName: 'Doe',
993
1001
  * line1: '456 New Address',
@@ -1007,7 +1015,7 @@ var BrainerceClient = class {
1007
1015
  *
1008
1016
  * @example
1009
1017
  * ```typescript
1010
- * const order = await omni.cancelOrder('order_123');
1018
+ * const order = await client.cancelOrder('order_123');
1011
1019
  * console.log('Order status:', order.status); // 'cancelled'
1012
1020
  * ```
1013
1021
  */
@@ -1020,7 +1028,7 @@ var BrainerceClient = class {
1020
1028
  *
1021
1029
  * @example
1022
1030
  * ```typescript
1023
- * const order = await omni.fulfillOrder('order_123', {
1031
+ * const order = await client.fulfillOrder('order_123', {
1024
1032
  * trackingNumber: '1Z999AA10123456784',
1025
1033
  * trackingCompany: 'UPS',
1026
1034
  * notifyCustomer: true,
@@ -1035,7 +1043,7 @@ var BrainerceClient = class {
1035
1043
  *
1036
1044
  * @example
1037
1045
  * ```typescript
1038
- * const result = await omni.syncDraftOrders();
1046
+ * const result = await client.syncDraftOrders();
1039
1047
  * console.log('Draft orders synced');
1040
1048
  * ```
1041
1049
  */
@@ -1047,7 +1055,7 @@ var BrainerceClient = class {
1047
1055
  *
1048
1056
  * @example
1049
1057
  * ```typescript
1050
- * const order = await omni.completeDraftOrder('draft_123', {
1058
+ * const order = await client.completeDraftOrder('draft_123', {
1051
1059
  * paymentPending: false,
1052
1060
  * });
1053
1061
  * ```
@@ -1060,7 +1068,7 @@ var BrainerceClient = class {
1060
1068
  *
1061
1069
  * @example
1062
1070
  * ```typescript
1063
- * await omni.sendDraftInvoice('draft_123', {
1071
+ * await client.sendDraftInvoice('draft_123', {
1064
1072
  * to: 'customer@example.com',
1065
1073
  * subject: 'Your Invoice',
1066
1074
  * customMessage: 'Thank you for your order!',
@@ -1079,7 +1087,7 @@ var BrainerceClient = class {
1079
1087
  *
1080
1088
  * @example
1081
1089
  * ```typescript
1082
- * await omni.deleteDraftOrder('draft_123');
1090
+ * await client.deleteDraftOrder('draft_123');
1083
1091
  * ```
1084
1092
  */
1085
1093
  async deleteDraftOrder(orderId) {
@@ -1090,7 +1098,7 @@ var BrainerceClient = class {
1090
1098
  *
1091
1099
  * @example
1092
1100
  * ```typescript
1093
- * const order = await omni.updateDraftOrder('draft_123', {
1101
+ * const order = await client.updateDraftOrder('draft_123', {
1094
1102
  * note: 'Updated customer note',
1095
1103
  * email: 'newemail@example.com',
1096
1104
  * shippingAddress: {
@@ -1127,7 +1135,7 @@ var BrainerceClient = class {
1127
1135
  *
1128
1136
  * @example
1129
1137
  * ```typescript
1130
- * const inventory = await omni.editInventory({
1138
+ * const inventory = await client.editInventory({
1131
1139
  * productId: 'prod_123',
1132
1140
  * newTotal: 100,
1133
1141
  * reason: 'Restocked from warehouse',
@@ -1142,7 +1150,7 @@ var BrainerceClient = class {
1142
1150
  *
1143
1151
  * @example
1144
1152
  * ```typescript
1145
- * const status = await omni.getInventorySyncStatus();
1153
+ * const status = await client.getInventorySyncStatus();
1146
1154
  * console.log(`${status.pending} products pending sync`);
1147
1155
  * console.log(`Last sync: ${status.lastSyncAt}`);
1148
1156
  * ```
@@ -1155,7 +1163,7 @@ var BrainerceClient = class {
1155
1163
  *
1156
1164
  * @example
1157
1165
  * ```typescript
1158
- * const inventories = await omni.getBulkInventory(['prod_123', 'prod_456', 'prod_789']);
1166
+ * const inventories = await client.getBulkInventory(['prod_123', 'prod_456', 'prod_789']);
1159
1167
  * inventories.forEach(inv => {
1160
1168
  * console.log(`${inv.productId}: ${inv.available} available`);
1161
1169
  * });
@@ -1171,10 +1179,10 @@ var BrainerceClient = class {
1171
1179
  * @example
1172
1180
  * ```typescript
1173
1181
  * // Reconcile single product (dry run)
1174
- * const result = await omni.reconcileInventory({ productId: 'prod_123' });
1182
+ * const result = await client.reconcileInventory({ productId: 'prod_123' });
1175
1183
  *
1176
1184
  * // Reconcile all products with auto-fix
1177
- * const summary = await omni.reconcileInventory({ autoFix: true });
1185
+ * const summary = await client.reconcileInventory({ autoFix: true });
1178
1186
  * console.log(`Reconciled ${summary.reconciled} products`);
1179
1187
  * ```
1180
1188
  */
@@ -1196,7 +1204,7 @@ var BrainerceClient = class {
1196
1204
  * @example
1197
1205
  * ```typescript
1198
1206
  * // Check if items are available before adding to cart
1199
- * const result = await omni.checkStockAvailability([
1207
+ * const result = await client.checkStockAvailability([
1200
1208
  * { productId: 'prod_123', quantity: 2 },
1201
1209
  * { productId: 'prod_456', variantId: 'var_789', quantity: 1 }
1202
1210
  * ]);
@@ -1246,10 +1254,10 @@ var BrainerceClient = class {
1246
1254
  * @example
1247
1255
  * ```typescript
1248
1256
  * // Check all cart items (full checkout)
1249
- * const result = await omni.checkCartStock(cart);
1257
+ * const result = await client.checkCartStock(cart);
1250
1258
  *
1251
1259
  * // Check only selected items (partial checkout - server cart only)
1252
- * const result = await omni.checkCartStock(cart, ['item_1', 'item_3']);
1260
+ * const result = await client.checkCartStock(cart, ['item_1', 'item_3']);
1253
1261
  *
1254
1262
  * if (!result.allAvailable) {
1255
1263
  * const unavailable = result.results.filter(r => !r.isAvailable);
@@ -1311,7 +1319,7 @@ var BrainerceClient = class {
1311
1319
  *
1312
1320
  * @example
1313
1321
  * ```typescript
1314
- * const coupon = await omni.createCoupon({
1322
+ * const coupon = await client.createCoupon({
1315
1323
  * code: 'SUMMER20',
1316
1324
  * type: 'PERCENTAGE',
1317
1325
  * value: 20,
@@ -1355,7 +1363,7 @@ var BrainerceClient = class {
1355
1363
  * @example
1356
1364
  * ```typescript
1357
1365
  * // Only sync to WooCommerce and Shopify
1358
- * await omni.publishCoupon('coupon_123', ['WOOCOMMERCE', 'SHOPIFY']);
1366
+ * await client.publishCoupon('coupon_123', ['WOOCOMMERCE', 'SHOPIFY']);
1359
1367
  * ```
1360
1368
  */
1361
1369
  async publishCoupon(couponId, platforms) {
@@ -1367,7 +1375,7 @@ var BrainerceClient = class {
1367
1375
  *
1368
1376
  * @example
1369
1377
  * ```typescript
1370
- * const capabilities = await omni.getCouponPlatformCapabilities();
1378
+ * const capabilities = await client.getCouponPlatformCapabilities();
1371
1379
  * if (!capabilities.SHOPIFY.supportsProductExclusions) {
1372
1380
  * console.log('Shopify does not support product exclusions');
1373
1381
  * }
@@ -1385,7 +1393,7 @@ var BrainerceClient = class {
1385
1393
  *
1386
1394
  * @example
1387
1395
  * ```typescript
1388
- * const customer = await omni.createCustomer({
1396
+ * const customer = await client.createCustomer({
1389
1397
  * email: 'customer@example.com',
1390
1398
  * firstName: 'John',
1391
1399
  * lastName: 'Doe',
@@ -1420,7 +1428,7 @@ var BrainerceClient = class {
1420
1428
  *
1421
1429
  * @example
1422
1430
  * ```typescript
1423
- * const auth = await omni.loginCustomer('customer@example.com', 'password123');
1431
+ * const auth = await client.loginCustomer('customer@example.com', 'password123');
1424
1432
  * console.log('Customer logged in:', auth.customer.email);
1425
1433
  * // Store auth.token for subsequent authenticated requests
1426
1434
  * ```
@@ -1449,7 +1457,7 @@ var BrainerceClient = class {
1449
1457
  *
1450
1458
  * @example
1451
1459
  * ```typescript
1452
- * const auth = await omni.registerCustomer({
1460
+ * const auth = await client.registerCustomer({
1453
1461
  * email: 'newcustomer@example.com',
1454
1462
  * password: 'securepassword123',
1455
1463
  * firstName: 'Jane',
@@ -1495,14 +1503,14 @@ var BrainerceClient = class {
1495
1503
  * @example
1496
1504
  * ```typescript
1497
1505
  * // Option 1: Pass token directly (recommended for verification flow)
1498
- * const auth = await omni.registerCustomer({...});
1506
+ * const auth = await client.registerCustomer({...});
1499
1507
  * if (auth.requiresVerification) {
1500
- * const result = await omni.verifyEmail('123456', auth.token);
1508
+ * const result = await client.verifyEmail('123456', auth.token);
1501
1509
  * }
1502
1510
  *
1503
1511
  * // Option 2: Use setCustomerToken first
1504
- * omni.setCustomerToken(auth.token);
1505
- * const result = await omni.verifyEmail('123456');
1512
+ * client.setCustomerToken(auth.token);
1513
+ * const result = await client.verifyEmail('123456');
1506
1514
  * ```
1507
1515
  */
1508
1516
  async verifyEmail(code, token) {
@@ -1544,11 +1552,11 @@ var BrainerceClient = class {
1544
1552
  * @example
1545
1553
  * ```typescript
1546
1554
  * // Option 1: Pass token directly
1547
- * await omni.resendVerificationEmail(auth.token);
1555
+ * await client.resendVerificationEmail(auth.token);
1548
1556
  *
1549
1557
  * // Option 2: Use setCustomerToken first
1550
- * omni.setCustomerToken(auth.token);
1551
- * await omni.resendVerificationEmail();
1558
+ * client.setCustomerToken(auth.token);
1559
+ * await client.resendVerificationEmail();
1552
1560
  * ```
1553
1561
  */
1554
1562
  async resendVerificationEmail(token) {
@@ -1589,7 +1597,7 @@ var BrainerceClient = class {
1589
1597
  *
1590
1598
  * @example
1591
1599
  * ```typescript
1592
- * const { providers } = await omni.getAvailableOAuthProviders();
1600
+ * const { providers } = await client.getAvailableOAuthProviders();
1593
1601
  * // providers: ['GOOGLE', 'FACEBOOK'] - array of strings, not objects!
1594
1602
  *
1595
1603
  * // To display with friendly names:
@@ -1629,7 +1637,7 @@ var BrainerceClient = class {
1629
1637
  * @example
1630
1638
  * ```typescript
1631
1639
  * // Get authorization URL (redirectUrl MUST be absolute with origin)
1632
- * const { authorizationUrl } = await omni.getOAuthAuthorizeUrl('GOOGLE', {
1640
+ * const { authorizationUrl } = await client.getOAuthAuthorizeUrl('GOOGLE', {
1633
1641
  * redirectUrl: window.location.origin + '/auth/callback'
1634
1642
  * });
1635
1643
  *
@@ -1640,7 +1648,7 @@ var BrainerceClient = class {
1640
1648
  * const params = new URLSearchParams(window.location.search);
1641
1649
  * if (params.get('oauth_success') === 'true') {
1642
1650
  * const token = params.get('token');
1643
- * omni.setCustomerToken(token);
1651
+ * client.setCustomerToken(token);
1644
1652
  * // Also available: customer_id, customer_email, is_new
1645
1653
  * } else if (params.get('oauth_error')) {
1646
1654
  * // Show error
@@ -1709,10 +1717,10 @@ var BrainerceClient = class {
1709
1717
  * @example
1710
1718
  * ```typescript
1711
1719
  * // Customer must be logged in first
1712
- * omni.setCustomerToken(auth.token);
1720
+ * client.setCustomerToken(auth.token);
1713
1721
  *
1714
1722
  * // Get authorization URL for linking
1715
- * const { authorizationUrl } = await omni.linkOAuthProvider('GITHUB', {
1723
+ * const { authorizationUrl } = await client.linkOAuthProvider('GITHUB', {
1716
1724
  * redirectUrl: '/settings'
1717
1725
  * });
1718
1726
  *
@@ -1749,8 +1757,8 @@ var BrainerceClient = class {
1749
1757
  *
1750
1758
  * @example
1751
1759
  * ```typescript
1752
- * omni.setCustomerToken(auth.token);
1753
- * await omni.unlinkOAuthProvider('FACEBOOK');
1760
+ * client.setCustomerToken(auth.token);
1761
+ * await client.unlinkOAuthProvider('FACEBOOK');
1754
1762
  * ```
1755
1763
  */
1756
1764
  async unlinkOAuthProvider(provider) {
@@ -1774,8 +1782,8 @@ var BrainerceClient = class {
1774
1782
  *
1775
1783
  * @example
1776
1784
  * ```typescript
1777
- * omni.setCustomerToken(auth.token);
1778
- * const { connections } = await omni.getOAuthConnections();
1785
+ * client.setCustomerToken(auth.token);
1786
+ * const { connections } = await client.getOAuthConnections();
1779
1787
  * // connections: [{ id: '...', provider: 'GOOGLE', email: 'user@gmail.com', createdAt: '...' }]
1780
1788
  * ```
1781
1789
  */
@@ -1805,10 +1813,10 @@ var BrainerceClient = class {
1805
1813
  * @example
1806
1814
  * ```typescript
1807
1815
  * // After login/register, set the token
1808
- * omni.setCustomerToken(auth.token);
1816
+ * client.setCustomerToken(auth.token);
1809
1817
  *
1810
1818
  * // Then get the profile
1811
- * const profile = await omni.getCustomerProfile();
1819
+ * const profile = await client.getCustomerProfile();
1812
1820
  * console.log('Customer:', profile.email);
1813
1821
  * ```
1814
1822
  */
@@ -1838,7 +1846,7 @@ var BrainerceClient = class {
1838
1846
  *
1839
1847
  * @example
1840
1848
  * ```typescript
1841
- * const address = await omni.addCustomerAddress('cust_123', {
1849
+ * const address = await client.addCustomerAddress('cust_123', {
1842
1850
  * firstName: 'John',
1843
1851
  * lastName: 'Doe',
1844
1852
  * line1: '123 Main St',
@@ -1878,7 +1886,7 @@ var BrainerceClient = class {
1878
1886
  *
1879
1887
  * @example
1880
1888
  * ```typescript
1881
- * const orders = await omni.getCustomerOrders('cust_123', { page: 1, limit: 10 });
1889
+ * const orders = await client.getCustomerOrders('cust_123', { page: 1, limit: 10 });
1882
1890
  * console.log(`Customer has ${orders.meta.total} total orders`);
1883
1891
  * ```
1884
1892
  */
@@ -1897,7 +1905,7 @@ var BrainerceClient = class {
1897
1905
  *
1898
1906
  * @example
1899
1907
  * ```typescript
1900
- * const cart = await omni.createCart();
1908
+ * const cart = await client.createCart();
1901
1909
  * console.log('Cart session:', cart.sessionToken);
1902
1910
  * // Store sessionToken in localStorage or cookie
1903
1911
  * ```
@@ -1920,7 +1928,7 @@ var BrainerceClient = class {
1920
1928
  *
1921
1929
  * @example
1922
1930
  * ```typescript
1923
- * const cart = await omni.getCartBySession('sess_abc123');
1931
+ * const cart = await client.getCartBySession('sess_abc123');
1924
1932
  * console.log('Items in cart:', cart.itemCount);
1925
1933
  * ```
1926
1934
  */
@@ -1935,7 +1943,7 @@ var BrainerceClient = class {
1935
1943
  *
1936
1944
  * @example
1937
1945
  * ```typescript
1938
- * const cart = await omni.getCartByCustomer('cust_123');
1946
+ * const cart = await client.getCartByCustomer('cust_123');
1939
1947
  * console.log('Customer cart total:', cart.subtotal);
1940
1948
  * ```
1941
1949
  */
@@ -1965,7 +1973,7 @@ var BrainerceClient = class {
1965
1973
  *
1966
1974
  * @example
1967
1975
  * ```typescript
1968
- * const cart = await omni.addToCart('cart_123', {
1976
+ * const cart = await client.addToCart('cart_123', {
1969
1977
  * productId: 'prod_abc',
1970
1978
  * quantity: 2,
1971
1979
  * notes: 'Gift wrap please',
@@ -2031,7 +2039,7 @@ var BrainerceClient = class {
2031
2039
  *
2032
2040
  * @example
2033
2041
  * ```typescript
2034
- * const cart = await omni.updateCartItem('cart_123', 'item_456', { quantity: 3 });
2042
+ * const cart = await client.updateCartItem('cart_123', 'item_456', { quantity: 3 });
2035
2043
  * ```
2036
2044
  */
2037
2045
  async updateCartItem(cartId, itemId, data) {
@@ -2066,7 +2074,7 @@ var BrainerceClient = class {
2066
2074
  *
2067
2075
  * @example
2068
2076
  * ```typescript
2069
- * const cart = await omni.removeCartItem('cart_123', 'item_456');
2077
+ * const cart = await client.removeCartItem('cart_123', 'item_456');
2070
2078
  * ```
2071
2079
  */
2072
2080
  async removeCartItem(cartId, itemId) {
@@ -2101,7 +2109,7 @@ var BrainerceClient = class {
2101
2109
  *
2102
2110
  * @example
2103
2111
  * ```typescript
2104
- * await omni.clearCart('cart_123');
2112
+ * await client.clearCart('cart_123');
2105
2113
  * ```
2106
2114
  */
2107
2115
  async clearCart(cartId) {
@@ -2124,7 +2132,7 @@ var BrainerceClient = class {
2124
2132
  *
2125
2133
  * @example
2126
2134
  * ```typescript
2127
- * const cart = await omni.applyCoupon('cart_123', 'SAVE20');
2135
+ * const cart = await client.applyCoupon('cart_123', 'SAVE20');
2128
2136
  * console.log('Discount:', cart.discountAmount);
2129
2137
  * ```
2130
2138
  */
@@ -2151,7 +2159,7 @@ var BrainerceClient = class {
2151
2159
  *
2152
2160
  * @example
2153
2161
  * ```typescript
2154
- * const cart = await omni.removeCoupon('cart_123');
2162
+ * const cart = await client.removeCoupon('cart_123');
2155
2163
  * ```
2156
2164
  */
2157
2165
  async removeCoupon(cartId) {
@@ -2184,8 +2192,8 @@ var BrainerceClient = class {
2184
2192
  * @example
2185
2193
  * ```typescript
2186
2194
  * // After customer logs in
2187
- * omni.setCustomerToken(authResponse.token);
2188
- * const cart = await omni.linkCart('cart_123'); // cartId is REQUIRED
2195
+ * client.setCustomerToken(authResponse.token);
2196
+ * const cart = await client.linkCart('cart_123'); // cartId is REQUIRED
2189
2197
  * // Cart is now linked to the customer
2190
2198
  * ```
2191
2199
  */
@@ -2211,7 +2219,7 @@ var BrainerceClient = class {
2211
2219
  * @example
2212
2220
  * ```typescript
2213
2221
  * // After customer logs in, merge their guest cart
2214
- * const mergedCart = await omni.mergeCarts({
2222
+ * const mergedCart = await client.mergeCarts({
2215
2223
  * sourceSessionToken: 'sess_guest_abc',
2216
2224
  * targetCustomerId: 'cust_123',
2217
2225
  * });
@@ -2230,7 +2238,7 @@ var BrainerceClient = class {
2230
2238
  *
2231
2239
  * @example
2232
2240
  * ```typescript
2233
- * const banners = await omni.getDiscountBanners();
2241
+ * const banners = await client.getDiscountBanners();
2234
2242
  * banners.forEach(b => console.log(b.text));
2235
2243
  * ```
2236
2244
  */
@@ -2252,7 +2260,7 @@ var BrainerceClient = class {
2252
2260
  *
2253
2261
  * @example
2254
2262
  * ```typescript
2255
- * const badge = await omni.getProductDiscountBadge('prod_123');
2263
+ * const badge = await client.getProductDiscountBadge('prod_123');
2256
2264
  * if (badge) {
2257
2265
  * console.log(badge.badgeText); // e.g., "20% OFF"
2258
2266
  * console.log(badge.discountedPrice); // e.g., "39.99"
@@ -2285,7 +2293,7 @@ var BrainerceClient = class {
2285
2293
  *
2286
2294
  * @example
2287
2295
  * ```typescript
2288
- * const nudges = await omni.getCartNudges('cart_123');
2296
+ * const nudges = await client.getCartNudges('cart_123');
2289
2297
  * nudges.forEach(n => {
2290
2298
  * console.log(n.text); // e.g., "Add $12.50 more for free shipping!"
2291
2299
  * });
@@ -2310,7 +2318,7 @@ var BrainerceClient = class {
2310
2318
  *
2311
2319
  * @example
2312
2320
  * ```typescript
2313
- * const recs = await omni.getProductRecommendations('prod_123');
2321
+ * const recs = await client.getProductRecommendations('prod_123');
2314
2322
  * console.log(recs.crossSells); // complementary products
2315
2323
  * console.log(recs.upsells); // premium alternatives
2316
2324
  * console.log(recs.related); // related products
@@ -2344,7 +2352,7 @@ var BrainerceClient = class {
2344
2352
  *
2345
2353
  * @example
2346
2354
  * ```typescript
2347
- * const recs = await omni.getCartRecommendations('cart_123', 6);
2355
+ * const recs = await client.getCartRecommendations('cart_123', 6);
2348
2356
  * recs.recommendations.forEach(product => {
2349
2357
  * console.log(product.name, product.basePrice);
2350
2358
  * });
@@ -2376,7 +2384,7 @@ var BrainerceClient = class {
2376
2384
  *
2377
2385
  * @example
2378
2386
  * ```typescript
2379
- * if (omni.isCustomerLoggedIn()) {
2387
+ * if (client.isCustomerLoggedIn()) {
2380
2388
  * console.log('Cart will be stored on server');
2381
2389
  * } else {
2382
2390
  * console.log('Cart will be stored in localStorage');
@@ -2446,7 +2454,7 @@ var BrainerceClient = class {
2446
2454
  * @example
2447
2455
  * ```typescript
2448
2456
  * // Works the same whether logged in or not
2449
- * await omni.smartAddToCart({
2457
+ * await client.smartAddToCart({
2450
2458
  * productId: 'prod_123',
2451
2459
  * quantity: 2,
2452
2460
  * name: 'Cool Product', // Optional: for localStorage display
@@ -2471,7 +2479,7 @@ var BrainerceClient = class {
2471
2479
  *
2472
2480
  * @example
2473
2481
  * ```typescript
2474
- * const cart = await omni.smartGetCart();
2482
+ * const cart = await client.smartGetCart();
2475
2483
  * console.log('Items:', cart.items.length);
2476
2484
  * ```
2477
2485
  */
@@ -2487,8 +2495,8 @@ var BrainerceClient = class {
2487
2495
  *
2488
2496
  * @example
2489
2497
  * ```typescript
2490
- * await omni.smartUpdateCartItem('prod_123', 3); // Set quantity to 3
2491
- * await omni.smartUpdateCartItem('prod_123', 0); // Remove item
2498
+ * await client.smartUpdateCartItem('prod_123', 3); // Set quantity to 3
2499
+ * await client.smartUpdateCartItem('prod_123', 0); // Remove item
2492
2500
  * ```
2493
2501
  */
2494
2502
  async smartUpdateCartItem(productId, quantity, variantId) {
@@ -2513,8 +2521,8 @@ var BrainerceClient = class {
2513
2521
  *
2514
2522
  * @example
2515
2523
  * ```typescript
2516
- * await omni.smartRemoveFromCart('prod_123');
2517
- * await omni.smartRemoveFromCart('prod_456', 'variant_789');
2524
+ * await client.smartRemoveFromCart('prod_123');
2525
+ * await client.smartRemoveFromCart('prod_456', 'variant_789');
2518
2526
  * ```
2519
2527
  */
2520
2528
  async smartRemoveFromCart(productId, variantId) {
@@ -2534,11 +2542,11 @@ var BrainerceClient = class {
2534
2542
  * @example
2535
2543
  * ```typescript
2536
2544
  * // Customer logs in
2537
- * const auth = await omni.login(email, password);
2538
- * omni.setCustomerToken(auth.token);
2545
+ * const auth = await client.login(email, password);
2546
+ * client.setCustomerToken(auth.token);
2539
2547
  *
2540
2548
  * // Sync their local cart to server
2541
- * const cart = await omni.syncCartOnLogin();
2549
+ * const cart = await client.syncCartOnLogin();
2542
2550
  * console.log('Cart synced, items:', cart.items.length);
2543
2551
  * ```
2544
2552
  */
@@ -2575,11 +2583,11 @@ var BrainerceClient = class {
2575
2583
  *
2576
2584
  * @example
2577
2585
  * ```typescript
2578
- * omni.clearCustomerToken();
2579
- * omni.onLogout();
2586
+ * client.clearCustomerToken();
2587
+ * client.onLogout();
2580
2588
  *
2581
2589
  * // Now back to guest mode - cart uses localStorage
2582
- * await omni.smartAddToCart({ productId: 'prod_123', quantity: 1 });
2590
+ * await client.smartAddToCart({ productId: 'prod_123', quantity: 1 });
2583
2591
  * ```
2584
2592
  */
2585
2593
  onLogout() {
@@ -2595,8 +2603,8 @@ var BrainerceClient = class {
2595
2603
  * ```typescript
2596
2604
  * // After payment success
2597
2605
  * if (paymentStatus === 'succeeded') {
2598
- * omni.onCheckoutComplete();
2599
- * omni.clearLocalCart(); // Also clear localStorage for guests
2606
+ * client.onCheckoutComplete();
2607
+ * client.clearLocalCart(); // Also clear localStorage for guests
2600
2608
  * }
2601
2609
  * ```
2602
2610
  */
@@ -2616,10 +2624,10 @@ var BrainerceClient = class {
2616
2624
  * @example
2617
2625
  * ```typescript
2618
2626
  * // Full cart checkout (default)
2619
- * const checkout = await omni.createCheckout({ cartId: 'cart_123' });
2627
+ * const checkout = await client.createCheckout({ cartId: 'cart_123' });
2620
2628
  *
2621
2629
  * // Partial checkout - only buy selected items
2622
- * const checkout = await omni.createCheckout({
2630
+ * const checkout = await client.createCheckout({
2623
2631
  * cartId: 'cart_123',
2624
2632
  * selectedItemIds: ['item_1', 'item_3'], // Only these items will be purchased
2625
2633
  * });
@@ -2654,7 +2662,7 @@ var BrainerceClient = class {
2654
2662
  *
2655
2663
  * @example
2656
2664
  * ```typescript
2657
- * const checkout = await omni.getCheckout('checkout_123');
2665
+ * const checkout = await client.getCheckout('checkout_123');
2658
2666
  * console.log('Status:', checkout.status);
2659
2667
  * ```
2660
2668
  */
@@ -2681,7 +2689,7 @@ var BrainerceClient = class {
2681
2689
  *
2682
2690
  * @example
2683
2691
  * ```typescript
2684
- * const checkout = await omni.setCheckoutCustomer('checkout_123', {
2692
+ * const checkout = await client.setCheckoutCustomer('checkout_123', {
2685
2693
  * email: 'customer@example.com',
2686
2694
  * firstName: 'John',
2687
2695
  * lastName: 'Doe',
@@ -2706,7 +2714,7 @@ var BrainerceClient = class {
2706
2714
  *
2707
2715
  * @example
2708
2716
  * ```typescript
2709
- * const { checkout, rates } = await omni.setShippingAddress('checkout_123', {
2717
+ * const { checkout, rates } = await client.setShippingAddress('checkout_123', {
2710
2718
  * email: 'customer@example.com', // Required!
2711
2719
  * firstName: 'John',
2712
2720
  * lastName: 'Doe',
@@ -2746,7 +2754,7 @@ var BrainerceClient = class {
2746
2754
  *
2747
2755
  * @example
2748
2756
  * ```typescript
2749
- * const rates = await omni.getShippingRates('checkout_123');
2757
+ * const rates = await client.getShippingRates('checkout_123');
2750
2758
  * console.log('Shipping options:', rates);
2751
2759
  * ```
2752
2760
  */
@@ -2774,7 +2782,7 @@ var BrainerceClient = class {
2774
2782
  *
2775
2783
  * @example
2776
2784
  * ```typescript
2777
- * const checkout = await omni.selectShippingMethod('checkout_123', 'rate_express');
2785
+ * const checkout = await client.selectShippingMethod('checkout_123', 'rate_express');
2778
2786
  * console.log('Shipping cost:', checkout.shippingAmount);
2779
2787
  * ```
2780
2788
  */
@@ -2809,13 +2817,13 @@ var BrainerceClient = class {
2809
2817
  * @example
2810
2818
  * ```typescript
2811
2819
  * // Use same as shipping
2812
- * const checkout = await omni.setBillingAddress('checkout_123', {
2820
+ * const checkout = await client.setBillingAddress('checkout_123', {
2813
2821
  * ...shippingAddress,
2814
2822
  * sameAsShipping: true,
2815
2823
  * });
2816
2824
  *
2817
2825
  * // Or set different billing address
2818
- * const checkout = await omni.setBillingAddress('checkout_123', {
2826
+ * const checkout = await client.setBillingAddress('checkout_123', {
2819
2827
  * firstName: 'John',
2820
2828
  * lastName: 'Doe',
2821
2829
  * line1: '456 Business Ave',
@@ -2853,7 +2861,7 @@ var BrainerceClient = class {
2853
2861
  *
2854
2862
  * @example
2855
2863
  * ```typescript
2856
- * const { orderId } = await omni.completeCheckout('checkout_123');
2864
+ * const { orderId } = await client.completeCheckout('checkout_123');
2857
2865
  * console.log('Order created:', orderId);
2858
2866
  * ```
2859
2867
  */
@@ -2892,7 +2900,7 @@ var BrainerceClient = class {
2892
2900
  *
2893
2901
  * @example
2894
2902
  * ```typescript
2895
- * const config = await omni.getPaymentConfig();
2903
+ * const config = await client.getPaymentConfig();
2896
2904
  *
2897
2905
  * // Initialize Stripe.js with the public key
2898
2906
  * const stripe = Stripe(config.publicKey);
@@ -2925,7 +2933,7 @@ var BrainerceClient = class {
2925
2933
  *
2926
2934
  * @example
2927
2935
  * ```typescript
2928
- * const { providers, hasPayments, defaultProvider } = await omni.getPaymentProviders();
2936
+ * const { providers, hasPayments, defaultProvider } = await client.getPaymentProviders();
2929
2937
  *
2930
2938
  * if (!hasPayments) {
2931
2939
  * // Show error: "Payment is not configured for this store"
@@ -2977,7 +2985,7 @@ var BrainerceClient = class {
2977
2985
  * @example
2978
2986
  * ```typescript
2979
2987
  * // After completing checkout steps (shipping address, method, etc.)
2980
- * const intent = await omni.createPaymentIntent(checkout.id, {
2988
+ * const intent = await client.createPaymentIntent(checkout.id, {
2981
2989
  * successUrl: `${window.location.origin}/order-confirmation?checkout_id=${checkout.id}`,
2982
2990
  * cancelUrl: `${window.location.origin}/checkout?error=cancelled`,
2983
2991
  * });
@@ -3024,7 +3032,7 @@ var BrainerceClient = class {
3024
3032
  * @example
3025
3033
  * ```typescript
3026
3034
  * // After returning from Stripe redirect
3027
- * const status = await omni.getPaymentStatus(checkoutId);
3035
+ * const status = await client.getPaymentStatus(checkoutId);
3028
3036
  *
3029
3037
  * if (status.status === 'succeeded') {
3030
3038
  * // Redirect to order confirmation
@@ -3074,7 +3082,7 @@ var BrainerceClient = class {
3074
3082
  * @example
3075
3083
  * ```typescript
3076
3084
  * // Basic usage - wait up to 30 seconds
3077
- * const result = await omni.waitForOrder(checkoutId);
3085
+ * const result = await client.waitForOrder(checkoutId);
3078
3086
  *
3079
3087
  * if (result.success) {
3080
3088
  * console.log('Order created:', result.status.orderNumber);
@@ -3087,7 +3095,7 @@ var BrainerceClient = class {
3087
3095
  * @example
3088
3096
  * ```typescript
3089
3097
  * // With progress callback for UI updates
3090
- * const result = await omni.waitForOrder(checkoutId, {
3098
+ * const result = await client.waitForOrder(checkoutId, {
3091
3099
  * maxWaitMs: 20000,
3092
3100
  * onPollAttempt: (attempt, status) => {
3093
3101
  * setLoadingMessage(`Confirming order... (attempt ${attempt})`);
@@ -3155,7 +3163,7 @@ var BrainerceClient = class {
3155
3163
  if (typeof window === "undefined" || !window.localStorage) {
3156
3164
  return false;
3157
3165
  }
3158
- const test = "__omni_test__";
3166
+ const test = "__brainerce_test__";
3159
3167
  window.localStorage.setItem(test, test);
3160
3168
  window.localStorage.removeItem(test);
3161
3169
  return true;
@@ -3169,7 +3177,7 @@ var BrainerceClient = class {
3169
3177
  *
3170
3178
  * @example
3171
3179
  * ```typescript
3172
- * const cart = omni.getLocalCart();
3180
+ * const cart = client.getLocalCart();
3173
3181
  * console.log('Items in cart:', cart.items.length);
3174
3182
  * ```
3175
3183
  */
@@ -3258,7 +3266,7 @@ var BrainerceClient = class {
3258
3266
  *
3259
3267
  * @example
3260
3268
  * ```typescript
3261
- * omni.addToLocalCart({
3269
+ * client.addToLocalCart({
3262
3270
  * productId: 'prod_123',
3263
3271
  * quantity: 2,
3264
3272
  * name: 'Cool Shirt',
@@ -3291,8 +3299,8 @@ var BrainerceClient = class {
3291
3299
  *
3292
3300
  * @example
3293
3301
  * ```typescript
3294
- * omni.updateLocalCartItem('prod_123', 3); // Set quantity to 3
3295
- * omni.updateLocalCartItem('prod_123', 0); // Remove item
3302
+ * client.updateLocalCartItem('prod_123', 3); // Set quantity to 3
3303
+ * client.updateLocalCartItem('prod_123', 0); // Remove item
3296
3304
  * ```
3297
3305
  */
3298
3306
  updateLocalCartItem(productId, quantity, variantId) {
@@ -3315,8 +3323,8 @@ var BrainerceClient = class {
3315
3323
  *
3316
3324
  * @example
3317
3325
  * ```typescript
3318
- * omni.removeFromLocalCart('prod_123');
3319
- * omni.removeFromLocalCart('prod_456', 'variant_789');
3326
+ * client.removeFromLocalCart('prod_123');
3327
+ * client.removeFromLocalCart('prod_456', 'variant_789');
3320
3328
  * ```
3321
3329
  */
3322
3330
  removeFromLocalCart(productId, variantId) {
@@ -3327,7 +3335,7 @@ var BrainerceClient = class {
3327
3335
  *
3328
3336
  * @example
3329
3337
  * ```typescript
3330
- * omni.clearLocalCart();
3338
+ * client.clearLocalCart();
3331
3339
  * ```
3332
3340
  */
3333
3341
  clearLocalCart() {
@@ -3340,7 +3348,7 @@ var BrainerceClient = class {
3340
3348
  *
3341
3349
  * @example
3342
3350
  * ```typescript
3343
- * omni.setLocalCartCustomer({
3351
+ * client.setLocalCartCustomer({
3344
3352
  * email: 'john@example.com',
3345
3353
  * firstName: 'John',
3346
3354
  * lastName: 'Doe',
@@ -3358,7 +3366,7 @@ var BrainerceClient = class {
3358
3366
  *
3359
3367
  * @example
3360
3368
  * ```typescript
3361
- * omni.setLocalCartShippingAddress({
3369
+ * client.setLocalCartShippingAddress({
3362
3370
  * firstName: 'John',
3363
3371
  * lastName: 'Doe',
3364
3372
  * line1: '123 Main St',
@@ -3411,12 +3419,12 @@ var BrainerceClient = class {
3411
3419
  * @example
3412
3420
  * ```typescript
3413
3421
  * // Build up the local cart first
3414
- * omni.addToLocalCart({ productId: 'prod_123', quantity: 2 });
3415
- * omni.setLocalCartCustomer({ email: 'john@example.com', firstName: 'John' });
3416
- * omni.setLocalCartShippingAddress({ ... });
3422
+ * client.addToLocalCart({ productId: 'prod_123', quantity: 2 });
3423
+ * client.setLocalCartCustomer({ email: 'john@example.com', firstName: 'John' });
3424
+ * client.setLocalCartShippingAddress({ ... });
3417
3425
  *
3418
3426
  * // Then submit the order - tracking is automatic if enabled in admin!
3419
- * const result = await omni.submitGuestOrder();
3427
+ * const result = await client.submitGuestOrder();
3420
3428
  * console.log('Order created:', result.orderId);
3421
3429
  *
3422
3430
  * // Cart is automatically cleared on success
@@ -3499,14 +3507,14 @@ var BrainerceClient = class {
3499
3507
  * @example
3500
3508
  * ```typescript
3501
3509
  * // Full checkout (all items)
3502
- * const result = await omni.startGuestCheckout();
3510
+ * const result = await client.startGuestCheckout();
3503
3511
  *
3504
3512
  * // Partial checkout (only items at index 0 and 2)
3505
- * const result = await omni.startGuestCheckout({ selectedIndices: [0, 2] });
3513
+ * const result = await client.startGuestCheckout({ selectedIndices: [0, 2] });
3506
3514
  *
3507
3515
  * if (result.tracked) {
3508
3516
  * // IMPORTANT: Fetch checkout and use checkout.lineItems for Order Summary!
3509
- * const checkout = await omni.getCheckout(result.checkoutId);
3517
+ * const checkout = await client.getCheckout(result.checkoutId);
3510
3518
  *
3511
3519
  * // Display Order Summary using checkout.lineItems (NOT localCart.items!)
3512
3520
  * // checkout.lineItems contains ONLY the selected items
@@ -3515,15 +3523,15 @@ var BrainerceClient = class {
3515
3523
  * });
3516
3524
  *
3517
3525
  * // Update checkout with address
3518
- * await omni.updateGuestCheckoutAddress(result.checkoutId, {
3526
+ * await client.updateGuestCheckoutAddress(result.checkoutId, {
3519
3527
  * shippingAddress: { ... },
3520
3528
  * });
3521
3529
  *
3522
3530
  * // After payment success, call handlePaymentSuccess() to clear cart
3523
- * omni.handlePaymentSuccess(result.checkoutId);
3531
+ * client.handlePaymentSuccess(result.checkoutId);
3524
3532
  * } else {
3525
3533
  * // Tracking not enabled, use regular submitGuestOrder
3526
- * const order = await omni.submitGuestOrder();
3534
+ * const order = await client.submitGuestOrder();
3527
3535
  * }
3528
3536
  * ```
3529
3537
  */
@@ -3599,7 +3607,7 @@ var BrainerceClient = class {
3599
3607
  * @example
3600
3608
  * ```typescript
3601
3609
  * // After partial checkout success, remove purchased items
3602
- * omni.removeLocalCartItemsByIndex([0, 2]); // Removes items at index 0 and 2
3610
+ * client.removeLocalCartItemsByIndex([0, 2]); // Removes items at index 0 and 2
3603
3611
  * ```
3604
3612
  */
3605
3613
  removeLocalCartItemsByIndex(indices) {
@@ -3655,13 +3663,13 @@ var BrainerceClient = class {
3655
3663
  *
3656
3664
  * @example Full checkout (clears entire cart):
3657
3665
  * ```typescript
3658
- * await omni.completeGuestCheckout(checkoutId);
3666
+ * await client.completeGuestCheckout(checkoutId);
3659
3667
  * ```
3660
3668
  *
3661
3669
  * @example Partial checkout (removes only purchased items):
3662
3670
  * ```typescript
3663
3671
  * // User selected items at indices 0 and 2 for checkout
3664
- * await omni.completeGuestCheckout(checkoutId, { selectedIndices: [0, 2] });
3672
+ * await client.completeGuestCheckout(checkoutId, { selectedIndices: [0, 2] });
3665
3673
  * // Items at indices 1, 3, etc. remain in cart
3666
3674
  * ```
3667
3675
  */
@@ -3691,7 +3699,7 @@ var BrainerceClient = class {
3691
3699
  *
3692
3700
  * @example
3693
3701
  * ```typescript
3694
- * const activeCheckout = omni.getActiveGuestCheckout();
3702
+ * const activeCheckout = client.getActiveGuestCheckout();
3695
3703
  * if (activeCheckout) {
3696
3704
  * console.log('Active checkout:', activeCheckout.checkoutId);
3697
3705
  * console.log('Partial checkout:', activeCheckout.selectedIndices?.length);
@@ -3732,7 +3740,7 @@ var BrainerceClient = class {
3732
3740
  *
3733
3741
  * if (!error && paymentIntent?.status === 'succeeded') {
3734
3742
  * // Clear the cart automatically - handles all scenarios!
3735
- * const result = omni.handlePaymentSuccess(checkoutId);
3743
+ * const result = client.handlePaymentSuccess(checkoutId);
3736
3744
  * console.log('Cart cleared:', result.cleared);
3737
3745
  * console.log('User type:', result.userType); // 'guest' or 'customer'
3738
3746
  * }
@@ -3743,13 +3751,13 @@ var BrainerceClient = class {
3743
3751
  * // On success page (after redirect)
3744
3752
  * const checkoutId = new URLSearchParams(location.search).get('checkout_id');
3745
3753
  * if (checkoutId) {
3746
- * omni.handlePaymentSuccess(checkoutId);
3754
+ * client.handlePaymentSuccess(checkoutId);
3747
3755
  * }
3748
3756
  * ```
3749
3757
  */
3750
3758
  handlePaymentSuccess(checkoutId) {
3751
3759
  const isLoggedIn = this.isCustomerLoggedIn();
3752
- const handledKey = `omni_payment_handled_${checkoutId || "latest"}`;
3760
+ const handledKey = `brainerce_payment_handled_${checkoutId || "latest"}`;
3753
3761
  if (typeof window !== "undefined" && window.sessionStorage) {
3754
3762
  if (sessionStorage.getItem(handledKey)) {
3755
3763
  return {
@@ -3809,7 +3817,7 @@ var BrainerceClient = class {
3809
3817
  *
3810
3818
  * @example
3811
3819
  * ```typescript
3812
- * const result = await omni.createGuestOrder({
3820
+ * const result = await client.createGuestOrder({
3813
3821
  * items: [{ productId: 'prod_123', quantity: 2 }],
3814
3822
  * customer: { email: 'john@example.com' },
3815
3823
  * shippingAddress: { firstName: 'John', ... },
@@ -3827,9 +3835,9 @@ var BrainerceClient = class {
3827
3835
  *
3828
3836
  * @example
3829
3837
  * ```typescript
3830
- * const auth = await omni.loginCustomer('user@example.com', 'password');
3831
- * omni.setCustomerToken(auth.token);
3832
- * const profile = await omni.getMyProfile();
3838
+ * const auth = await client.loginCustomer('user@example.com', 'password');
3839
+ * client.setCustomerToken(auth.token);
3840
+ * const profile = await client.getMyProfile();
3833
3841
  * ```
3834
3842
  */
3835
3843
  async getMyProfile() {
@@ -3857,9 +3865,9 @@ var BrainerceClient = class {
3857
3865
  *
3858
3866
  * @example
3859
3867
  * ```typescript
3860
- * omni.setCustomerToken(auth.token);
3868
+ * client.setCustomerToken(auth.token);
3861
3869
  *
3862
- * const prefill = await omni.getCheckoutPrefillData();
3870
+ * const prefill = await client.getCheckoutPrefillData();
3863
3871
  *
3864
3872
  * if (prefill.shippingAddress) {
3865
3873
  * // Pre-fill shipping form with customer's default address
@@ -3956,7 +3964,7 @@ var BrainerceClient = class {
3956
3964
  *
3957
3965
  * @example
3958
3966
  * ```typescript
3959
- * const links = await omni.getOrderDownloads('order_123');
3967
+ * const links = await client.getOrderDownloads('order_123');
3960
3968
  * for (const link of links) {
3961
3969
  * console.log(`${link.productName}: ${link.downloadUrl}`);
3962
3970
  * }
@@ -4109,7 +4117,7 @@ var BrainerceClient = class {
4109
4117
  *
4110
4118
  * @example
4111
4119
  * ```typescript
4112
- * const integrations = await omni.getCustomApiIntegrations();
4120
+ * const integrations = await client.getCustomApiIntegrations();
4113
4121
  * integrations.forEach(api => {
4114
4122
  * console.log(`${api.name}: ${api.status}`);
4115
4123
  * });
@@ -4124,7 +4132,7 @@ var BrainerceClient = class {
4124
4132
  *
4125
4133
  * @example
4126
4134
  * ```typescript
4127
- * const api = await omni.getCustomApiIntegration('api_123');
4135
+ * const api = await client.getCustomApiIntegration('api_123');
4128
4136
  * console.log(`API: ${api.name}, URL: ${api.baseUrl}`);
4129
4137
  * ```
4130
4138
  */
@@ -4137,7 +4145,7 @@ var BrainerceClient = class {
4137
4145
  *
4138
4146
  * @example
4139
4147
  * ```typescript
4140
- * const api = await omni.createCustomApiIntegration({
4148
+ * const api = await client.createCustomApiIntegration({
4141
4149
  * name: 'My External API',
4142
4150
  * baseUrl: 'https://api.example.com',
4143
4151
  * authType: 'api_key',
@@ -4163,7 +4171,7 @@ var BrainerceClient = class {
4163
4171
  *
4164
4172
  * @example
4165
4173
  * ```typescript
4166
- * const api = await omni.updateCustomApiIntegration('api_123', {
4174
+ * const api = await client.updateCustomApiIntegration('api_123', {
4167
4175
  * enabled: false,
4168
4176
  * syncConfig: { products: true, orders: false, inventory: true },
4169
4177
  * });
@@ -4182,7 +4190,7 @@ var BrainerceClient = class {
4182
4190
  *
4183
4191
  * @example
4184
4192
  * ```typescript
4185
- * await omni.deleteCustomApiIntegration('api_123');
4193
+ * await client.deleteCustomApiIntegration('api_123');
4186
4194
  * ```
4187
4195
  */
4188
4196
  async deleteCustomApiIntegration(integrationId) {
@@ -4194,7 +4202,7 @@ var BrainerceClient = class {
4194
4202
  *
4195
4203
  * @example
4196
4204
  * ```typescript
4197
- * const result = await omni.testCustomApiConnection('api_123');
4205
+ * const result = await client.testCustomApiConnection('api_123');
4198
4206
  * if (result.success) {
4199
4207
  * console.log(`Connection OK, latency: ${result.latency}ms`);
4200
4208
  * } else {
@@ -4222,7 +4230,7 @@ var BrainerceClient = class {
4222
4230
  *
4223
4231
  * @example
4224
4232
  * ```typescript
4225
- * const availability = await omni.getAvailability(['prod_123', 'prod_456']);
4233
+ * const availability = await client.getAvailability(['prod_123', 'prod_456']);
4226
4234
  * availability.forEach(item => {
4227
4235
  * if (!item.canPurchase) {
4228
4236
  * console.log(`${item.productId}: Cannot purchase`);
@@ -4256,7 +4264,7 @@ var BrainerceClient = class {
4256
4264
  * @example
4257
4265
  * ```typescript
4258
4266
  * // Extend reservation when customer shows activity
4259
- * const result = await omni.extendReservation({ checkoutId: 'chk_123' });
4267
+ * const result = await client.extendReservation({ checkoutId: 'chk_123' });
4260
4268
  * if (result.success) {
4261
4269
  * console.log(`Reservation extended until ${result.reservation.expiresAt}`);
4262
4270
  * }
@@ -4286,7 +4294,7 @@ var BrainerceClient = class {
4286
4294
  * @example
4287
4295
  * ```typescript
4288
4296
  * // Release reservation when customer abandons checkout
4289
- * await omni.releaseReservation({ checkoutId: 'chk_123' });
4297
+ * await client.releaseReservation({ checkoutId: 'chk_123' });
4290
4298
  * ```
4291
4299
  */
4292
4300
  async releaseReservation(options) {
@@ -4309,7 +4317,7 @@ var BrainerceClient = class {
4309
4317
  *
4310
4318
  * @example
4311
4319
  * ```typescript
4312
- * const categories = await omni.listCategories({ page: 1, limit: 20 });
4320
+ * const categories = await client.listCategories({ page: 1, limit: 20 });
4313
4321
  * console.log(`Found ${categories.meta.total} categories`);
4314
4322
  * ```
4315
4323
  */
@@ -4334,7 +4342,7 @@ var BrainerceClient = class {
4334
4342
  *
4335
4343
  * @example
4336
4344
  * ```typescript
4337
- * const category = await omni.createCategory({
4345
+ * const category = await client.createCategory({
4338
4346
  * name: 'Electronics',
4339
4347
  * slug: 'electronics',
4340
4348
  * description: 'Electronic devices and accessories',
@@ -4380,7 +4388,7 @@ var BrainerceClient = class {
4380
4388
  *
4381
4389
  * @example
4382
4390
  * ```typescript
4383
- * const brand = await omni.createBrand({
4391
+ * const brand = await client.createBrand({
4384
4392
  * name: 'Nike',
4385
4393
  * slug: 'nike',
4386
4394
  * logoUrl: 'https://example.com/nike-logo.png',
@@ -4426,7 +4434,7 @@ var BrainerceClient = class {
4426
4434
  *
4427
4435
  * @example
4428
4436
  * ```typescript
4429
- * const tag = await omni.createTag({
4437
+ * const tag = await client.createTag({
4430
4438
  * name: 'New Arrival',
4431
4439
  * slug: 'new-arrival',
4432
4440
  * });
@@ -4476,7 +4484,7 @@ var BrainerceClient = class {
4476
4484
  *
4477
4485
  * @example
4478
4486
  * ```typescript
4479
- * const attribute = await omni.createAttribute({
4487
+ * const attribute = await client.createAttribute({
4480
4488
  * name: 'Color',
4481
4489
  * slug: 'color',
4482
4490
  * source: 'custom',
@@ -4513,7 +4521,7 @@ var BrainerceClient = class {
4513
4521
  *
4514
4522
  * @example
4515
4523
  * ```typescript
4516
- * const option = await omni.createAttributeOption('attr_123', {
4524
+ * const option = await client.createAttributeOption('attr_123', {
4517
4525
  * value: 'Red',
4518
4526
  * slug: 'red',
4519
4527
  * sortOrder: 1,
@@ -4575,7 +4583,7 @@ var BrainerceClient = class {
4575
4583
  *
4576
4584
  * @example
4577
4585
  * ```typescript
4578
- * const zone = await omni.createShippingZone({
4586
+ * const zone = await client.createShippingZone({
4579
4587
  * name: 'US Domestic',
4580
4588
  * countries: ['US'],
4581
4589
  * regions: ['CA', 'NY', 'TX'],
@@ -4612,7 +4620,7 @@ var BrainerceClient = class {
4612
4620
  *
4613
4621
  * @example
4614
4622
  * ```typescript
4615
- * const rate = await omni.createZoneShippingRate('zone_123', {
4623
+ * const rate = await client.createZoneShippingRate('zone_123', {
4616
4624
  * name: 'Standard Shipping',
4617
4625
  * type: 'flat',
4618
4626
  * price: 5.99,
@@ -4668,7 +4676,7 @@ var BrainerceClient = class {
4668
4676
  *
4669
4677
  * @example
4670
4678
  * ```typescript
4671
- * const rate = await omni.createTaxRate({
4679
+ * const rate = await client.createTaxRate({
4672
4680
  * name: 'California Sales Tax',
4673
4681
  * rate: 7.25,
4674
4682
  * country: 'US',
@@ -4754,7 +4762,7 @@ var BrainerceClient = class {
4754
4762
  *
4755
4763
  * @example
4756
4764
  * ```typescript
4757
- * const definition = await omni.createMetafieldDefinition({
4765
+ * const definition = await client.createMetafieldDefinition({
4758
4766
  * name: 'Care Instructions',
4759
4767
  * key: 'care_instructions',
4760
4768
  * type: 'multi_line_text',
@@ -4801,7 +4809,7 @@ var BrainerceClient = class {
4801
4809
  *
4802
4810
  * @example
4803
4811
  * ```typescript
4804
- * const metafield = await omni.setProductMetafield('prod_123', 'def_456', {
4812
+ * const metafield = await client.setProductMetafield('prod_123', 'def_456', {
4805
4813
  * value: 'Machine wash cold, tumble dry low',
4806
4814
  * });
4807
4815
  * ```
@@ -4878,7 +4886,7 @@ var BrainerceClient = class {
4878
4886
  *
4879
4887
  * @example
4880
4888
  * ```typescript
4881
- * const { members, invitations } = await omni.getStoreTeam('store_id');
4889
+ * const { members, invitations } = await client.getStoreTeam('store_id');
4882
4890
  * ```
4883
4891
  */
4884
4892
  async getStoreTeam(storeId) {
@@ -4890,7 +4898,7 @@ var BrainerceClient = class {
4890
4898
  *
4891
4899
  * @example
4892
4900
  * ```typescript
4893
- * const invitation = await omni.inviteStoreMember('store_id', {
4901
+ * const invitation = await client.inviteStoreMember('store_id', {
4894
4902
  * email: 'newmember@example.com',
4895
4903
  * role: 'MANAGER', // 'MANAGER' | 'STAFF' | 'VIEWER'
4896
4904
  * });
@@ -4910,10 +4918,10 @@ var BrainerceClient = class {
4910
4918
  * @example
4911
4919
  * ```typescript
4912
4920
  * // Update role
4913
- * await omni.updateStoreMember('store_id', 'member_id', { role: 'MANAGER' });
4921
+ * await client.updateStoreMember('store_id', 'member_id', { role: 'MANAGER' });
4914
4922
  *
4915
4923
  * // Set custom permissions (overrides role defaults)
4916
- * await omni.updateStoreMember('store_id', 'member_id', {
4924
+ * await client.updateStoreMember('store_id', 'member_id', {
4917
4925
  * permissions: ['VIEW_PRODUCTS', 'VIEW_ORDERS', 'FULFILL_ORDERS'],
4918
4926
  * });
4919
4927
  * ```
@@ -4972,7 +4980,7 @@ var BrainerceClient = class {
4972
4980
  *
4973
4981
  * @example
4974
4982
  * ```typescript
4975
- * const stores = await omni.getMyStores();
4983
+ * const stores = await client.getMyStores();
4976
4984
  * // Returns stores from all accounts where user is owner or team member
4977
4985
  * stores.forEach(store => {
4978
4986
  * console.log(`${store.name} - ${store.role} (${store.context})`);
@@ -4988,7 +4996,7 @@ var BrainerceClient = class {
4988
4996
  *
4989
4997
  * @example
4990
4998
  * ```typescript
4991
- * const { role, permissions } = await omni.getMyStorePermissions('store_id');
4999
+ * const { role, permissions } = await client.getMyStorePermissions('store_id');
4992
5000
  * if (permissions.includes('MANAGE_TEAM')) {
4993
5001
  * // Show team management UI
4994
5002
  * }
@@ -5036,7 +5044,7 @@ var BrainerceClient = class {
5036
5044
  *
5037
5045
  * @example
5038
5046
  * ```typescript
5039
- * const template = await omni.createEmailTemplate({
5047
+ * const template = await client.createEmailTemplate({
5040
5048
  * name: 'Order Confirmation',
5041
5049
  * eventType: 'ORDER_CONFIRMATION',
5042
5050
  * subject: 'Your order #{{orderNumber}} has been confirmed',
@@ -5148,7 +5156,7 @@ var BrainerceClient = class {
5148
5156
  *
5149
5157
  * @example
5150
5158
  * ```typescript
5151
- * const config = await omni.configureOAuthProvider({
5159
+ * const config = await client.configureOAuthProvider({
5152
5160
  * provider: 'GOOGLE',
5153
5161
  * clientId: 'your-google-client-id',
5154
5162
  * clientSecret: 'your-google-client-secret',
@@ -5188,6 +5196,7 @@ var BrainerceError = class extends Error {
5188
5196
  };
5189
5197
 
5190
5198
  // src/webhooks.ts
5199
+ var import_crypto = __toESM(require("crypto"));
5191
5200
  function verifyWebhook(payload, signature, secret) {
5192
5201
  if (!signature || !secret) {
5193
5202
  return false;
@@ -5197,13 +5206,7 @@ function verifyWebhook(payload, signature, secret) {
5197
5206
  }
5198
5207
  function verifyHmacSignature(payload, signature, secret) {
5199
5208
  try {
5200
- if (typeof globalThis.crypto === "undefined") {
5201
- const crypto2 = require("crypto");
5202
- const expectedSignature2 = crypto2.createHmac("sha256", secret).update(payload).digest("hex");
5203
- return timingSafeEqual(signature, expectedSignature2);
5204
- }
5205
- const crypto = require("crypto");
5206
- const expectedSignature = crypto.createHmac("sha256", secret).update(payload).digest("hex");
5209
+ const expectedSignature = import_crypto.default.createHmac("sha256", secret).update(payload).digest("hex");
5207
5210
  return timingSafeEqual(signature, expectedSignature);
5208
5211
  } catch (error) {
5209
5212
  console.error("Webhook signature verification failed:", error);
@@ -5428,16 +5431,10 @@ function isCouponApplicableToProduct(coupon, productId) {
5428
5431
  }
5429
5432
  return true;
5430
5433
  }
5431
-
5432
- // src/index.ts
5433
- var OmniSyncClient = BrainerceClient;
5434
- var OmniSyncError = BrainerceError;
5435
5434
  // Annotate the CommonJS export names for ESM import in node:
5436
5435
  0 && (module.exports = {
5437
5436
  BrainerceClient,
5438
5437
  BrainerceError,
5439
- OmniSyncClient,
5440
- OmniSyncError,
5441
5438
  createWebhookHandler,
5442
5439
  enableDevGuards,
5443
5440
  formatPrice,