brainerce 1.63.0 → 2.0.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 +321 -32
- package/dist/index.d.mts +243 -182
- package/dist/index.d.ts +243 -182
- package/dist/index.js +211 -246
- package/dist/index.mjs +211 -246
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -204,7 +204,7 @@ function isDevGuardsEnabled() {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
// src/version.ts
|
|
207
|
-
var SDK_VERSION = "
|
|
207
|
+
var SDK_VERSION = "2.0.0";
|
|
208
208
|
|
|
209
209
|
// src/client.ts
|
|
210
210
|
var DEFAULT_BASE_URL = "https://api.brainerce.com";
|
|
@@ -650,7 +650,7 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
650
650
|
*/
|
|
651
651
|
this.blog = /* @__PURE__ */ (() => {
|
|
652
652
|
const publicBase = "/blog/posts";
|
|
653
|
-
const adminBase = "/blog/posts";
|
|
653
|
+
const adminBase = "/api/blog/posts";
|
|
654
654
|
const requireAdmin = (action) => {
|
|
655
655
|
if (this.isVibeCodedMode() || this.storeId && !this.apiKey) {
|
|
656
656
|
throw new BrainerceError(
|
|
@@ -2484,115 +2484,97 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
2484
2484
|
return this.request("PATCH", `/api/v1/orders/${encodePathSegment(orderId)}`, data);
|
|
2485
2485
|
}
|
|
2486
2486
|
/**
|
|
2487
|
-
* Update order status
|
|
2487
|
+
* Update order status.
|
|
2488
|
+
*
|
|
2489
|
+
* **Not callable — use {@link updateOrder} instead.** Status changes do work
|
|
2490
|
+
* over the API key, just by a different route.
|
|
2491
|
+
*
|
|
2492
|
+
* @deprecated Call `updateOrder(orderId, { status })`.
|
|
2488
2493
|
*
|
|
2489
2494
|
* @example
|
|
2490
2495
|
* ```typescript
|
|
2491
|
-
* const order = await client.
|
|
2496
|
+
* const order = await client.updateOrder('order_123', { status: 'SHIPPED' });
|
|
2492
2497
|
* ```
|
|
2493
2498
|
*/
|
|
2494
2499
|
async updateOrderStatus(orderId, status) {
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2500
|
+
void orderId;
|
|
2501
|
+
void status;
|
|
2502
|
+
throw new BrainerceError(
|
|
2503
|
+
"updateOrderStatus is not a route on the API-key /v1 surface. Status changes go through updateOrder instead: updateOrder(orderId, { status }) PATCHes /api/v1/orders/:id and ends up in the same service call.",
|
|
2504
|
+
400
|
|
2505
|
+
);
|
|
2498
2506
|
}
|
|
2499
2507
|
/**
|
|
2500
|
-
* Update order payment method
|
|
2501
|
-
* Note: Only WooCommerce supports syncing payment method changes back to platform
|
|
2508
|
+
* Update order payment method.
|
|
2502
2509
|
*
|
|
2503
|
-
*
|
|
2504
|
-
*
|
|
2505
|
-
*
|
|
2506
|
-
* ```
|
|
2510
|
+
* **Not callable.** The API-key `/v1` surface has no payment-method route,
|
|
2511
|
+
* so this throws in every mode. Change the payment method from the
|
|
2512
|
+
* dashboard until the route ships.
|
|
2507
2513
|
*/
|
|
2508
2514
|
async updatePaymentMethod(orderId, paymentMethod) {
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
}
|
|
2515
|
+
void orderId;
|
|
2516
|
+
void paymentMethod;
|
|
2517
|
+
throw new BrainerceError(
|
|
2518
|
+
"updatePaymentMethod is not a route on the API-key /v1 surface. There is no orders/:id/payment-method endpoint to call; change the payment method from the Brainerce dashboard.",
|
|
2519
|
+
400
|
|
2515
2520
|
);
|
|
2516
2521
|
}
|
|
2517
2522
|
/**
|
|
2518
|
-
* Update order notes
|
|
2523
|
+
* Update order notes.
|
|
2519
2524
|
*
|
|
2520
|
-
*
|
|
2521
|
-
*
|
|
2522
|
-
*
|
|
2523
|
-
* ```
|
|
2525
|
+
* **Not callable.** The API-key `/v1` surface has no order-notes route, so
|
|
2526
|
+
* this throws in every mode. Edit notes from the dashboard until the route
|
|
2527
|
+
* ships.
|
|
2524
2528
|
*/
|
|
2525
2529
|
async updateOrderNotes(orderId, notes) {
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2530
|
+
void orderId;
|
|
2531
|
+
void notes;
|
|
2532
|
+
throw new BrainerceError(
|
|
2533
|
+
"updateOrderNotes is not a route on the API-key /v1 surface. There is no orders/:id/notes endpoint to call; edit the note from the Brainerce dashboard.",
|
|
2534
|
+
400
|
|
2535
|
+
);
|
|
2529
2536
|
}
|
|
2530
2537
|
/**
|
|
2531
|
-
* Get refunds for an order
|
|
2532
|
-
* Returns refunds from the source platform (Shopify/WooCommerce only)
|
|
2538
|
+
* Get refunds for an order.
|
|
2533
2539
|
*
|
|
2534
|
-
*
|
|
2535
|
-
*
|
|
2536
|
-
*
|
|
2537
|
-
* console.log('Total refunds:', refunds.length);
|
|
2538
|
-
* ```
|
|
2540
|
+
* **Not callable.** The API-key `/v1` surface has no refunds route, so this
|
|
2541
|
+
* throws in every mode. Read refunds from the dashboard until the route
|
|
2542
|
+
* ships.
|
|
2539
2543
|
*/
|
|
2540
2544
|
async getOrderRefunds(orderId) {
|
|
2541
|
-
|
|
2545
|
+
void orderId;
|
|
2546
|
+
throw new BrainerceError(
|
|
2547
|
+
"getOrderRefunds is not a route on the API-key /v1 surface. There is no orders/:id/refunds endpoint to call; view refunds in the Brainerce dashboard.",
|
|
2548
|
+
400
|
|
2549
|
+
);
|
|
2542
2550
|
}
|
|
2543
2551
|
/**
|
|
2544
|
-
* Create a refund for an order
|
|
2545
|
-
* Creates refund on the source platform (Shopify/WooCommerce only)
|
|
2552
|
+
* Create a refund for an order.
|
|
2546
2553
|
*
|
|
2547
|
-
*
|
|
2548
|
-
*
|
|
2549
|
-
* // Full refund
|
|
2550
|
-
* const refund = await client.createRefund('order_123', {
|
|
2551
|
-
* type: 'full',
|
|
2552
|
-
* restockInventory: true,
|
|
2553
|
-
* notifyCustomer: true,
|
|
2554
|
-
* reason: 'Customer request',
|
|
2555
|
-
* });
|
|
2556
|
-
*
|
|
2557
|
-
* // Partial refund
|
|
2558
|
-
* const partialRefund = await client.createRefund('order_123', {
|
|
2559
|
-
* type: 'partial',
|
|
2560
|
-
* items: [
|
|
2561
|
-
* { lineItemId: 'item_456', quantity: 1 },
|
|
2562
|
-
* ],
|
|
2563
|
-
* restockInventory: true,
|
|
2564
|
-
* });
|
|
2565
|
-
* ```
|
|
2554
|
+
* **Not callable.** The API-key `/v1` surface has no refunds route, so this
|
|
2555
|
+
* throws in every mode. Refund from the dashboard until the route ships.
|
|
2566
2556
|
*/
|
|
2567
2557
|
async createRefund(orderId, data) {
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2558
|
+
void orderId;
|
|
2559
|
+
void data;
|
|
2560
|
+
throw new BrainerceError(
|
|
2561
|
+
"createRefund is not a route on the API-key /v1 surface. There is no orders/:id/refunds endpoint to call, so no refund was issued; refund the order from the Brainerce dashboard.",
|
|
2562
|
+
400
|
|
2572
2563
|
);
|
|
2573
2564
|
}
|
|
2574
2565
|
/**
|
|
2575
|
-
* Update order shipping address
|
|
2576
|
-
* Syncs to source platform (Shopify/WooCommerce only)
|
|
2566
|
+
* Update order shipping address.
|
|
2577
2567
|
*
|
|
2578
|
-
*
|
|
2579
|
-
*
|
|
2580
|
-
*
|
|
2581
|
-
* firstName: 'John',
|
|
2582
|
-
* lastName: 'Doe',
|
|
2583
|
-
* line1: '456 New Address',
|
|
2584
|
-
* city: 'Los Angeles',
|
|
2585
|
-
* state: 'CA',
|
|
2586
|
-
* country: 'US',
|
|
2587
|
-
* postalCode: '90001',
|
|
2588
|
-
* });
|
|
2589
|
-
* ```
|
|
2568
|
+
* **Not callable.** The API-key `/v1` surface has no order-shipping route,
|
|
2569
|
+
* so this throws in every mode. Correct the address from the dashboard
|
|
2570
|
+
* until the route ships.
|
|
2590
2571
|
*/
|
|
2591
2572
|
async updateOrderShipping(orderId, data) {
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2573
|
+
void orderId;
|
|
2574
|
+
void data;
|
|
2575
|
+
throw new BrainerceError(
|
|
2576
|
+
"updateOrderShipping is not a route on the API-key /v1 surface. There is no orders/:id/shipping endpoint to call, so the address was not changed; edit it in the Brainerce dashboard.",
|
|
2577
|
+
400
|
|
2596
2578
|
);
|
|
2597
2579
|
}
|
|
2598
2580
|
/**
|
|
@@ -2658,17 +2640,19 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
2658
2640
|
return this.request("GET", `/api/v1/orders/${encodePathSegment(orderId)}/shipments`);
|
|
2659
2641
|
}
|
|
2660
2642
|
/**
|
|
2661
|
-
* Cancel an order
|
|
2662
|
-
* Works for Shopify and WooCommerce orders that haven't been fulfilled
|
|
2643
|
+
* Cancel an order.
|
|
2663
2644
|
*
|
|
2664
|
-
*
|
|
2665
|
-
*
|
|
2666
|
-
*
|
|
2667
|
-
*
|
|
2668
|
-
* ```
|
|
2645
|
+
* **Not callable.** The API-key `/v1` surface has no cancel route, so this
|
|
2646
|
+
* throws in every mode. A status move to cancelled may be reachable through
|
|
2647
|
+
* {@link updateOrder} depending on what the order's state machine allows;
|
|
2648
|
+
* otherwise cancel from the dashboard.
|
|
2669
2649
|
*/
|
|
2670
2650
|
async cancelOrder(orderId) {
|
|
2671
|
-
|
|
2651
|
+
void orderId;
|
|
2652
|
+
throw new BrainerceError(
|
|
2653
|
+
"cancelOrder is not a route on the API-key /v1 surface. There is no orders/:id/cancel endpoint to call, so the order was not cancelled. Try updateOrder(orderId, { status }) for a plain status move, or cancel from the Brainerce dashboard.",
|
|
2654
|
+
400
|
|
2655
|
+
);
|
|
2672
2656
|
}
|
|
2673
2657
|
/**
|
|
2674
2658
|
* Fulfill an order (mark as shipped), or correct the tracking of an order
|
|
@@ -2682,110 +2666,87 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
2682
2666
|
* ship date is not rewritten, and no fulfilment event fires. That is the way
|
|
2683
2667
|
* to fix a mistyped tracking number.
|
|
2684
2668
|
*
|
|
2685
|
-
*
|
|
2686
|
-
*
|
|
2687
|
-
*
|
|
2688
|
-
*
|
|
2689
|
-
*
|
|
2690
|
-
* trackingCompany: 'UPS',
|
|
2691
|
-
* trackingUrl: 'https://www.ups.com/track?tracknum=1Z999AA10123456784',
|
|
2692
|
-
* notifyCustomer: true,
|
|
2693
|
-
* });
|
|
2694
|
-
*
|
|
2695
|
-
* // Correction — silent unless you opt back in.
|
|
2696
|
-
* await client.fulfillOrder('order_123', {
|
|
2697
|
-
* trackingNumber: '1Z999AA10123456785',
|
|
2698
|
-
* });
|
|
2699
|
-
* ```
|
|
2669
|
+
* **Not callable.** The API-key `/v1` surface has no fulfil route, so this
|
|
2670
|
+
* throws in every mode. To ship an order over the API today, buy a label
|
|
2671
|
+
* with {@link createShippingLabel} — the carrier's webhooks then move the
|
|
2672
|
+
* shipment through in-transit and delivered on their own. Otherwise fulfil
|
|
2673
|
+
* from the dashboard.
|
|
2700
2674
|
*/
|
|
2701
2675
|
async fulfillOrder(orderId, data) {
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2676
|
+
void orderId;
|
|
2677
|
+
void data;
|
|
2678
|
+
throw new BrainerceError(
|
|
2679
|
+
"fulfillOrder is not a route on the API-key /v1 surface. There is no orders/:id/fulfill endpoint to call, so nothing was fulfilled and no shipped email went out. Use createShippingLabel to ship over the API, or fulfil from the Brainerce dashboard.",
|
|
2680
|
+
400
|
|
2706
2681
|
);
|
|
2707
2682
|
}
|
|
2708
2683
|
/**
|
|
2709
|
-
* Sync draft orders from connected platforms
|
|
2684
|
+
* Sync draft orders from connected platforms.
|
|
2710
2685
|
*
|
|
2711
|
-
*
|
|
2712
|
-
*
|
|
2713
|
-
*
|
|
2714
|
-
* console.log('Draft orders synced');
|
|
2715
|
-
* ```
|
|
2686
|
+
* **Not callable.** The API-key `/v1` surface has no draft-order routes at
|
|
2687
|
+
* all, so this throws in every mode. {@link triggerSync} covers a general
|
|
2688
|
+
* platform sync; draft orders are managed from the dashboard.
|
|
2716
2689
|
*/
|
|
2717
2690
|
async syncDraftOrders() {
|
|
2718
|
-
|
|
2691
|
+
throw new BrainerceError(
|
|
2692
|
+
"syncDraftOrders is not a route on the API-key /v1 surface. There is no orders/sync-drafts endpoint to call, so nothing was synced. Use triggerSync for a platform sync, or work with drafts in the Brainerce dashboard.",
|
|
2693
|
+
400
|
|
2694
|
+
);
|
|
2719
2695
|
}
|
|
2720
2696
|
/**
|
|
2721
|
-
* Complete a draft order (convert to regular order)
|
|
2697
|
+
* Complete a draft order (convert to regular order).
|
|
2722
2698
|
*
|
|
2723
|
-
*
|
|
2724
|
-
*
|
|
2725
|
-
* const order = await client.completeDraftOrder('draft_123', {
|
|
2726
|
-
* paymentPending: false,
|
|
2727
|
-
* });
|
|
2728
|
-
* ```
|
|
2699
|
+
* **Not callable.** The API-key `/v1` surface has no draft-order routes at
|
|
2700
|
+
* all, so this throws in every mode. Complete drafts from the dashboard.
|
|
2729
2701
|
*/
|
|
2730
2702
|
async completeDraftOrder(orderId, data) {
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2703
|
+
void orderId;
|
|
2704
|
+
void data;
|
|
2705
|
+
throw new BrainerceError(
|
|
2706
|
+
"completeDraftOrder is not a route on the API-key /v1 surface. There is no orders/:id/complete-draft endpoint to call, so the draft was not converted; complete it in the Brainerce dashboard.",
|
|
2707
|
+
400
|
|
2735
2708
|
);
|
|
2736
2709
|
}
|
|
2737
2710
|
/**
|
|
2738
|
-
* Send invoice for a draft order
|
|
2711
|
+
* Send invoice for a draft order.
|
|
2739
2712
|
*
|
|
2740
|
-
*
|
|
2741
|
-
*
|
|
2742
|
-
* await client.sendDraftInvoice('draft_123', {
|
|
2743
|
-
* to: 'customer@example.com',
|
|
2744
|
-
* subject: 'Your Invoice',
|
|
2745
|
-
* customMessage: 'Thank you for your order!',
|
|
2746
|
-
* });
|
|
2747
|
-
* ```
|
|
2713
|
+
* **Not callable.** The API-key `/v1` surface has no draft-order routes at
|
|
2714
|
+
* all, so this throws in every mode. Send the invoice from the dashboard.
|
|
2748
2715
|
*/
|
|
2749
2716
|
async sendDraftInvoice(orderId, data) {
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2717
|
+
void orderId;
|
|
2718
|
+
void data;
|
|
2719
|
+
throw new BrainerceError(
|
|
2720
|
+
"sendDraftInvoice is not a route on the API-key /v1 surface. There is no orders/:id/send-invoice endpoint to call, so no invoice was sent; send it from the Brainerce dashboard.",
|
|
2721
|
+
400
|
|
2754
2722
|
);
|
|
2755
2723
|
}
|
|
2756
2724
|
/**
|
|
2757
|
-
* Delete a draft order
|
|
2725
|
+
* Delete a draft order.
|
|
2758
2726
|
*
|
|
2759
|
-
*
|
|
2760
|
-
*
|
|
2761
|
-
* await client.deleteDraftOrder('draft_123');
|
|
2762
|
-
* ```
|
|
2727
|
+
* **Not callable.** The API-key `/v1` surface has no draft-order routes at
|
|
2728
|
+
* all, so this throws in every mode. Delete drafts from the dashboard.
|
|
2763
2729
|
*/
|
|
2764
2730
|
async deleteDraftOrder(orderId) {
|
|
2765
|
-
|
|
2731
|
+
void orderId;
|
|
2732
|
+
throw new BrainerceError(
|
|
2733
|
+
"deleteDraftOrder is not a route on the API-key /v1 surface. There is no orders/:id/draft endpoint to call, so nothing was deleted; delete the draft in the Brainerce dashboard.",
|
|
2734
|
+
400
|
|
2735
|
+
);
|
|
2766
2736
|
}
|
|
2767
2737
|
/**
|
|
2768
|
-
* Update a draft order
|
|
2738
|
+
* Update a draft order.
|
|
2769
2739
|
*
|
|
2770
|
-
*
|
|
2771
|
-
*
|
|
2772
|
-
* const order = await client.updateDraftOrder('draft_123', {
|
|
2773
|
-
* note: 'Updated customer note',
|
|
2774
|
-
* email: 'newemail@example.com',
|
|
2775
|
-
* shippingAddress: {
|
|
2776
|
-
* firstName: 'John',
|
|
2777
|
-
* lastName: 'Doe',
|
|
2778
|
-
* address1: '123 Main St',
|
|
2779
|
-
* city: 'New York',
|
|
2780
|
-
* province: 'NY',
|
|
2781
|
-
* country: 'US',
|
|
2782
|
-
* zip: '10001',
|
|
2783
|
-
* },
|
|
2784
|
-
* });
|
|
2785
|
-
* ```
|
|
2740
|
+
* **Not callable.** The API-key `/v1` surface has no draft-order routes at
|
|
2741
|
+
* all, so this throws in every mode. Edit drafts from the dashboard.
|
|
2786
2742
|
*/
|
|
2787
2743
|
async updateDraftOrder(orderId, data) {
|
|
2788
|
-
|
|
2744
|
+
void orderId;
|
|
2745
|
+
void data;
|
|
2746
|
+
throw new BrainerceError(
|
|
2747
|
+
"updateDraftOrder is not a route on the API-key /v1 surface. There is no orders/:id/draft endpoint to call, so the draft was not changed; edit it in the Brainerce dashboard.",
|
|
2748
|
+
400
|
|
2749
|
+
);
|
|
2789
2750
|
}
|
|
2790
2751
|
// -------------------- Inventory --------------------
|
|
2791
2752
|
/**
|
|
@@ -2800,82 +2761,91 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
2800
2761
|
);
|
|
2801
2762
|
}
|
|
2802
2763
|
/**
|
|
2803
|
-
* Get current inventory for a product
|
|
2764
|
+
* Get current inventory for a product.
|
|
2765
|
+
*
|
|
2766
|
+
* **Admin mode only** — the API key needs the `inventory:read` scope.
|
|
2767
|
+
*
|
|
2768
|
+
* This used to request `/api/v1/inventory/:productId`, which does not
|
|
2769
|
+
* exist and 404'd silently. The live route is product-scoped:
|
|
2770
|
+
* `GET /api/v1/products/:id/inventory`. A product with no inventory row
|
|
2771
|
+
* reads back as all zeroes rather than 404ing.
|
|
2804
2772
|
*/
|
|
2805
2773
|
async getInventory(productId) {
|
|
2806
|
-
return this.
|
|
2774
|
+
return this.adminRequest(
|
|
2775
|
+
"GET",
|
|
2776
|
+
`/api/v1/products/${encodePathSegment(productId)}/inventory`
|
|
2777
|
+
);
|
|
2807
2778
|
}
|
|
2808
2779
|
/**
|
|
2809
|
-
* Edit inventory manually with reason for audit trail
|
|
2780
|
+
* Edit inventory manually with a reason for the audit trail.
|
|
2810
2781
|
*
|
|
2811
|
-
*
|
|
2812
|
-
*
|
|
2813
|
-
*
|
|
2814
|
-
*
|
|
2815
|
-
*
|
|
2816
|
-
*
|
|
2817
|
-
*
|
|
2818
|
-
*
|
|
2782
|
+
* **Not callable.** The API-key `/v1` surface carries no `inventory`
|
|
2783
|
+
* namespace, so this throws in every mode.
|
|
2784
|
+
*
|
|
2785
|
+
* {@link updateInventory} is the closest working call: it sets the same
|
|
2786
|
+
* absolute stock level over `PUT /api/v1/products/:id/inventory`, but the
|
|
2787
|
+
* reason is not yours to choose — the server records a generic
|
|
2788
|
+
* "Updated via External API" against the audit trail. If the reason text
|
|
2789
|
+
* matters, make the edit from the dashboard.
|
|
2819
2790
|
*/
|
|
2820
2791
|
async editInventory(data) {
|
|
2821
|
-
|
|
2792
|
+
void data;
|
|
2793
|
+
throw new BrainerceError(
|
|
2794
|
+
"editInventory is not a route on the API-key /v1 surface. There is no inventory/edit endpoint to call, so stock was not changed. Use updateInventory(productId, { quantity }) to set the same level, though it records a generic audit reason. Edit from the dashboard when the reason text matters.",
|
|
2795
|
+
400
|
|
2796
|
+
);
|
|
2822
2797
|
}
|
|
2823
2798
|
/**
|
|
2824
|
-
* Get inventory sync status for all products in the store
|
|
2799
|
+
* Get inventory sync status for all products in the store.
|
|
2825
2800
|
*
|
|
2826
|
-
*
|
|
2827
|
-
*
|
|
2828
|
-
*
|
|
2829
|
-
* console.log(`${status.pending} products pending sync`);
|
|
2830
|
-
* console.log(`Last sync: ${status.lastSyncAt}`);
|
|
2831
|
-
* ```
|
|
2801
|
+
* **Not callable.** The API-key `/v1` surface carries no `inventory`
|
|
2802
|
+
* namespace, so this throws in every mode. Sync state is visible in the
|
|
2803
|
+
* dashboard; {@link getSyncStatus} covers platform sync jobs.
|
|
2832
2804
|
*/
|
|
2833
2805
|
async getInventorySyncStatus() {
|
|
2834
|
-
|
|
2806
|
+
throw new BrainerceError(
|
|
2807
|
+
"getInventorySyncStatus is not a route on the API-key /v1 surface. There is no inventory/sync-status endpoint to call; check inventory sync state in the Brainerce dashboard.",
|
|
2808
|
+
400
|
|
2809
|
+
);
|
|
2835
2810
|
}
|
|
2836
2811
|
/**
|
|
2837
|
-
* Get inventory for multiple products at once
|
|
2812
|
+
* Get inventory for multiple products at once.
|
|
2838
2813
|
*
|
|
2839
|
-
*
|
|
2840
|
-
*
|
|
2841
|
-
*
|
|
2842
|
-
*
|
|
2843
|
-
* console.log(`${inv.productId}: ${inv.available} available`);
|
|
2844
|
-
* });
|
|
2845
|
-
* ```
|
|
2814
|
+
* **Not callable.** The API-key `/v1` surface carries no `inventory`
|
|
2815
|
+
* namespace, so this throws in every mode. There is no bulk stock read on
|
|
2816
|
+
* the API key today: fall back to {@link getInventory} per product, or read
|
|
2817
|
+
* the stock that {@link getProducts} already returns on each product.
|
|
2846
2818
|
*/
|
|
2847
2819
|
async getBulkInventory(productIds) {
|
|
2848
|
-
|
|
2820
|
+
void productIds;
|
|
2821
|
+
throw new BrainerceError(
|
|
2822
|
+
"getBulkInventory is not a route on the API-key /v1 surface. There is no inventory/bulk endpoint to call; read stock per product with getInventory, or off the products returned by getProducts.",
|
|
2823
|
+
400
|
|
2824
|
+
);
|
|
2849
2825
|
}
|
|
2850
2826
|
/**
|
|
2851
|
-
* Reconcile inventory between Brainerce and connected platforms
|
|
2852
|
-
* Detects and optionally fixes discrepancies
|
|
2827
|
+
* Reconcile inventory between Brainerce and connected platforms.
|
|
2828
|
+
* Detects and optionally fixes discrepancies.
|
|
2853
2829
|
*
|
|
2854
|
-
*
|
|
2855
|
-
*
|
|
2856
|
-
*
|
|
2857
|
-
* const result = await client.reconcileInventory({ productId: 'prod_123' });
|
|
2858
|
-
*
|
|
2859
|
-
* // Reconcile all products with auto-fix
|
|
2860
|
-
* const summary = await client.reconcileInventory({ autoFix: true });
|
|
2861
|
-
* console.log(`Reconciled ${summary.reconciled} products`);
|
|
2862
|
-
* ```
|
|
2830
|
+
* **Not callable.** The API-key `/v1` surface carries no `inventory`
|
|
2831
|
+
* namespace, so this throws in every mode, `autoFix` included. Reconcile
|
|
2832
|
+
* from the dashboard.
|
|
2863
2833
|
*/
|
|
2864
2834
|
async reconcileInventory(options) {
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
"POST",
|
|
2870
|
-
"/api/v1/inventory/reconcile",
|
|
2871
|
-
void 0,
|
|
2872
|
-
queryParams
|
|
2835
|
+
void options;
|
|
2836
|
+
throw new BrainerceError(
|
|
2837
|
+
"reconcileInventory is not a route on the API-key /v1 surface. There is no inventory/reconcile endpoint to call, so nothing was reconciled or fixed; run reconciliation from the Brainerce dashboard.",
|
|
2838
|
+
400
|
|
2873
2839
|
);
|
|
2874
2840
|
}
|
|
2875
2841
|
/**
|
|
2876
2842
|
* Check stock availability for one or more items before adding to cart or checkout
|
|
2877
2843
|
* Use this to validate stock before operations that might fail due to insufficient inventory
|
|
2878
2844
|
*
|
|
2845
|
+
* **Vibe-coded or storefront mode only.** There is no stock-check route on
|
|
2846
|
+
* the API-key `/v1` surface; in admin mode this throws. The same applies to
|
|
2847
|
+
* {@link checkCartStock}, which routes through here.
|
|
2848
|
+
*
|
|
2879
2849
|
* @example
|
|
2880
2850
|
* ```typescript
|
|
2881
2851
|
* // Check if items are available before adding to cart
|
|
@@ -2907,9 +2877,10 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
2907
2877
|
{ items }
|
|
2908
2878
|
);
|
|
2909
2879
|
}
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2880
|
+
throw new BrainerceError(
|
|
2881
|
+
"checkStockAvailability is only available in vibe-coded or storefront mode. The API-key /v1 surface has no inventory/check-availability route; read stock per product with getInventory instead.",
|
|
2882
|
+
400
|
|
2883
|
+
);
|
|
2913
2884
|
}
|
|
2914
2885
|
/**
|
|
2915
2886
|
* Check stock availability for cart items before checkout.
|
|
@@ -3246,49 +3217,43 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
3246
3217
|
* Request a password reset email for a customer
|
|
3247
3218
|
* Works in vibe-coded, storefront, and admin mode
|
|
3248
3219
|
*
|
|
3249
|
-
* The
|
|
3250
|
-
*
|
|
3251
|
-
*
|
|
3252
|
-
*
|
|
3253
|
-
*
|
|
3254
|
-
*
|
|
3255
|
-
*
|
|
3220
|
+
* The reset link's host is chosen by the server, not by the caller: it is
|
|
3221
|
+
* derived from the sales channel's own domain, falling back to the backend's
|
|
3222
|
+
* configured frontend URL, and the request is rejected if neither resolves.
|
|
3223
|
+
*
|
|
3224
|
+
* The SDK used to send a `resetUrl` in the request body. The backend
|
|
3225
|
+
* deliberately removed that field: any caller could submit an arbitrary URL
|
|
3226
|
+
* and have it emailed, from a Brainerce-domained sender, to the address
|
|
3227
|
+
* holder — a phishing-link injection. `ForgotPasswordDto` now declares
|
|
3228
|
+
* `email` and nothing else, and the API's global validation pipe runs with
|
|
3229
|
+
* `whitelist` + `forbidNonWhitelisted`, so a body carrying `resetUrl` fails
|
|
3230
|
+
* the whole call with `400 property resetUrl should not exist`. Only `email`
|
|
3231
|
+
* is sent.
|
|
3232
|
+
*
|
|
3233
|
+
* The endpoint always answers 200 so it cannot be used to enumerate
|
|
3234
|
+
* accounts; the mail is only sent when a matching customer exists.
|
|
3256
3235
|
*
|
|
3257
3236
|
* @param email - Customer email address
|
|
3258
|
-
* @param options -
|
|
3259
|
-
* @param options.resetUrl - Reset URL the email links should point to.
|
|
3260
|
-
* Required outside the browser; recommended inside it.
|
|
3237
|
+
* @param options - Accepted for source compatibility only. Ignored.
|
|
3261
3238
|
*/
|
|
3262
3239
|
async forgotPassword(email, options) {
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
if (typeof window === "undefined") {
|
|
3266
|
-
throw new BrainerceError(
|
|
3267
|
-
'forgotPassword: `resetUrl` is required outside the browser. Pass `{ resetUrl: "https://your-site.example/reset-password" }` so the email links to the right host.',
|
|
3268
|
-
400
|
|
3269
|
-
);
|
|
3270
|
-
}
|
|
3271
|
-
console.warn(
|
|
3272
|
-
"BrainerceClient.forgotPassword: deriving `resetUrl` from `window.location.origin` \u2014 pass `{ resetUrl }` explicitly to avoid wrong-host links behind proxies or in SSR."
|
|
3273
|
-
);
|
|
3274
|
-
resetUrl = `${window.location.origin}/reset-password`;
|
|
3275
|
-
}
|
|
3240
|
+
void options;
|
|
3241
|
+
const body = { email };
|
|
3276
3242
|
if (this.isVibeCodedMode()) {
|
|
3277
|
-
return this.vibeCodedRequest("POST", "/customers/forgot-password",
|
|
3278
|
-
email,
|
|
3279
|
-
resetUrl
|
|
3280
|
-
});
|
|
3243
|
+
return this.vibeCodedRequest("POST", "/customers/forgot-password", body);
|
|
3281
3244
|
}
|
|
3282
3245
|
if (this.storeId && !this.apiKey) {
|
|
3283
|
-
return this.storefrontRequest(
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3246
|
+
return this.storefrontRequest(
|
|
3247
|
+
"POST",
|
|
3248
|
+
"/customers/forgot-password",
|
|
3249
|
+
body
|
|
3250
|
+
);
|
|
3287
3251
|
}
|
|
3288
|
-
return this.adminRequest(
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3252
|
+
return this.adminRequest(
|
|
3253
|
+
"POST",
|
|
3254
|
+
"/api/v1/customers/forgot-password",
|
|
3255
|
+
body
|
|
3256
|
+
);
|
|
3292
3257
|
}
|
|
3293
3258
|
/**
|
|
3294
3259
|
* Reset customer password using a reset token received via email
|