@basedone/core 0.2.2 → 0.2.4
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/{chunk-Z5OW2FDP.mjs → chunk-NVL2HX2H.mjs} +602 -1
- package/dist/ecommerce.d.mts +1321 -8
- package/dist/ecommerce.d.ts +1321 -8
- package/dist/ecommerce.js +602 -1
- package/dist/ecommerce.mjs +1 -1
- package/dist/index.d.mts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +609 -1
- package/dist/index.mjs +8 -2
- package/lib/ecommerce/client/base.ts +7 -1
- package/lib/ecommerce/client/customer.ts +217 -0
- package/lib/ecommerce/client/merchant.ts +783 -0
- package/lib/ecommerce/types/entities.ts +94 -0
- package/lib/ecommerce/types/enums.ts +7 -1
- package/lib/ecommerce/types/requests.ts +151 -0
- package/lib/ecommerce/types/responses.ts +314 -0
- package/lib/utils/formatter.ts +1 -1
- package/lib/utils/time.ts +24 -0
- package/package.json +3 -2
|
@@ -37,6 +37,12 @@ import type {
|
|
|
37
37
|
GetAnalyticsParams,
|
|
38
38
|
RespondToReviewRequest,
|
|
39
39
|
PaginationParams,
|
|
40
|
+
// Shipping request types
|
|
41
|
+
UpdateShippingSettingsRequest,
|
|
42
|
+
CreateShippingZoneRequest,
|
|
43
|
+
UpdateShippingZoneRequest,
|
|
44
|
+
CreateShippingRateRequest,
|
|
45
|
+
UpdateShippingRateRequest,
|
|
40
46
|
|
|
41
47
|
// Response types
|
|
42
48
|
MerchantProfileResponse,
|
|
@@ -79,6 +85,12 @@ import type {
|
|
|
79
85
|
GetTaxReportResponse,
|
|
80
86
|
TaxReportResponse,
|
|
81
87
|
SuccessResponse,
|
|
88
|
+
// Shipping response types
|
|
89
|
+
ShippingSettingsResponse,
|
|
90
|
+
ListShippingZonesResponse,
|
|
91
|
+
ShippingZoneResponse,
|
|
92
|
+
ListShippingRatesResponse,
|
|
93
|
+
ShippingRateResponse,
|
|
82
94
|
} from "../types";
|
|
83
95
|
|
|
84
96
|
/**
|
|
@@ -691,6 +703,204 @@ export class MerchantEcommerceClient extends BaseEcommerceClient {
|
|
|
691
703
|
async updateShipment(shipmentId: string, request: UpdateShipmentRequest): Promise<ShipmentResponse> {
|
|
692
704
|
return this.patch(`/api/marketplace/merchant/shipping/shipments/${shipmentId}`, request);
|
|
693
705
|
}
|
|
706
|
+
|
|
707
|
+
// ============================================================================
|
|
708
|
+
// Shipping Settings (Zones & Rates)
|
|
709
|
+
// ============================================================================
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Get merchant shipping settings
|
|
713
|
+
*
|
|
714
|
+
* @returns Shipping settings
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* ```typescript
|
|
718
|
+
* const { settings } = await client.getShippingSettings();
|
|
719
|
+
* console.log("Handling fee:", settings.defaultHandlingFee);
|
|
720
|
+
* ```
|
|
721
|
+
*/
|
|
722
|
+
async getShippingSettings(): Promise<ShippingSettingsResponse> {
|
|
723
|
+
return this.get("/api/marketplace/merchant/shipping/settings");
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Update merchant shipping settings
|
|
728
|
+
*
|
|
729
|
+
* @param request - Settings to update
|
|
730
|
+
* @returns Updated settings
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* ```typescript
|
|
734
|
+
* await client.updateShippingSettings({
|
|
735
|
+
* defaultHandlingFee: 2.50,
|
|
736
|
+
* freeShippingEnabled: true,
|
|
737
|
+
* freeShippingThreshold: 100
|
|
738
|
+
* });
|
|
739
|
+
* ```
|
|
740
|
+
*/
|
|
741
|
+
async updateShippingSettings(request: UpdateShippingSettingsRequest): Promise<ShippingSettingsResponse> {
|
|
742
|
+
return this.post("/api/marketplace/merchant/shipping/settings", request);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* List all shipping zones
|
|
747
|
+
*
|
|
748
|
+
* @returns List of shipping zones with rate counts
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* ```typescript
|
|
752
|
+
* const { zones } = await client.listShippingZones();
|
|
753
|
+
* zones.forEach(z => console.log(z.name, z.countries.length, "countries"));
|
|
754
|
+
* ```
|
|
755
|
+
*/
|
|
756
|
+
async listShippingZones(): Promise<ListShippingZonesResponse> {
|
|
757
|
+
return this.get("/api/marketplace/merchant/shipping/zones");
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Get a shipping zone by ID
|
|
762
|
+
*
|
|
763
|
+
* @param zoneId - Zone ID
|
|
764
|
+
* @returns Zone with rates
|
|
765
|
+
*
|
|
766
|
+
* @example
|
|
767
|
+
* ```typescript
|
|
768
|
+
* const { zone } = await client.getShippingZone("zone_123");
|
|
769
|
+
* console.log(zone.name, zone.rates?.length, "rates");
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
772
|
+
async getShippingZone(zoneId: string): Promise<ShippingZoneResponse> {
|
|
773
|
+
return this.get(`/api/marketplace/merchant/shipping/zones/${zoneId}`);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Create a shipping zone
|
|
778
|
+
*
|
|
779
|
+
* @param request - Zone data
|
|
780
|
+
* @returns Created zone
|
|
781
|
+
*
|
|
782
|
+
* @example
|
|
783
|
+
* ```typescript
|
|
784
|
+
* const { zone } = await client.createShippingZone({
|
|
785
|
+
* name: "Southeast Asia",
|
|
786
|
+
* countries: ["SG", "MY", "TH", "ID", "PH", "VN"],
|
|
787
|
+
* isDefault: false,
|
|
788
|
+
* priority: 10
|
|
789
|
+
* });
|
|
790
|
+
* ```
|
|
791
|
+
*/
|
|
792
|
+
async createShippingZone(request: CreateShippingZoneRequest): Promise<ShippingZoneResponse> {
|
|
793
|
+
return this.post("/api/marketplace/merchant/shipping/zones", request);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Update a shipping zone
|
|
798
|
+
*
|
|
799
|
+
* @param zoneId - Zone ID
|
|
800
|
+
* @param request - Updated zone data
|
|
801
|
+
* @returns Updated zone
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* ```typescript
|
|
805
|
+
* await client.updateShippingZone("zone_123", {
|
|
806
|
+
* countries: ["SG", "MY", "TH", "ID", "PH", "VN", "BN"]
|
|
807
|
+
* });
|
|
808
|
+
* ```
|
|
809
|
+
*/
|
|
810
|
+
async updateShippingZone(zoneId: string, request: UpdateShippingZoneRequest): Promise<ShippingZoneResponse> {
|
|
811
|
+
return this.put(`/api/marketplace/merchant/shipping/zones/${zoneId}`, request);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Delete a shipping zone
|
|
816
|
+
*
|
|
817
|
+
* @param zoneId - Zone ID
|
|
818
|
+
* @returns Success response
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* ```typescript
|
|
822
|
+
* await client.deleteShippingZone("zone_123");
|
|
823
|
+
* ```
|
|
824
|
+
*/
|
|
825
|
+
async deleteShippingZone(zoneId: string): Promise<SuccessResponse> {
|
|
826
|
+
return this.delete(`/api/marketplace/merchant/shipping/zones/${zoneId}`);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* List shipping rates
|
|
831
|
+
*
|
|
832
|
+
* @param zoneId - Optional zone ID to filter by
|
|
833
|
+
* @returns List of shipping rates
|
|
834
|
+
*
|
|
835
|
+
* @example
|
|
836
|
+
* ```typescript
|
|
837
|
+
* // All rates
|
|
838
|
+
* const { rates } = await client.listShippingRates();
|
|
839
|
+
*
|
|
840
|
+
* // Rates for a specific zone
|
|
841
|
+
* const { rates: zoneRates } = await client.listShippingRates("zone_123");
|
|
842
|
+
* ```
|
|
843
|
+
*/
|
|
844
|
+
async listShippingRates(zoneId?: string): Promise<ListShippingRatesResponse> {
|
|
845
|
+
const query = zoneId ? `?zoneId=${zoneId}` : "";
|
|
846
|
+
return this.get(`/api/marketplace/merchant/shipping/rates${query}`);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Create a shipping rate
|
|
851
|
+
*
|
|
852
|
+
* @param request - Rate data
|
|
853
|
+
* @returns Created rate
|
|
854
|
+
*
|
|
855
|
+
* @example
|
|
856
|
+
* ```typescript
|
|
857
|
+
* const { rate } = await client.createShippingRate({
|
|
858
|
+
* zoneId: "zone_123",
|
|
859
|
+
* name: "Standard Shipping",
|
|
860
|
+
* baseRate: 5.00,
|
|
861
|
+
* perKgRate: 1.50,
|
|
862
|
+
* minDeliveryDays: 7,
|
|
863
|
+
* maxDeliveryDays: 14
|
|
864
|
+
* });
|
|
865
|
+
* ```
|
|
866
|
+
*/
|
|
867
|
+
async createShippingRate(request: CreateShippingRateRequest): Promise<ShippingRateResponse> {
|
|
868
|
+
return this.post("/api/marketplace/merchant/shipping/rates", request);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Update a shipping rate
|
|
873
|
+
*
|
|
874
|
+
* @param rateId - Rate ID
|
|
875
|
+
* @param request - Updated rate data
|
|
876
|
+
* @returns Updated rate
|
|
877
|
+
*
|
|
878
|
+
* @example
|
|
879
|
+
* ```typescript
|
|
880
|
+
* await client.updateShippingRate("rate_123", {
|
|
881
|
+
* baseRate: 6.00,
|
|
882
|
+
* freeAboveAmount: 75
|
|
883
|
+
* });
|
|
884
|
+
* ```
|
|
885
|
+
*/
|
|
886
|
+
async updateShippingRate(rateId: string, request: UpdateShippingRateRequest): Promise<ShippingRateResponse> {
|
|
887
|
+
return this.put(`/api/marketplace/merchant/shipping/rates/${rateId}`, request);
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Delete a shipping rate
|
|
892
|
+
*
|
|
893
|
+
* @param rateId - Rate ID
|
|
894
|
+
* @returns Success response
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* ```typescript
|
|
898
|
+
* await client.deleteShippingRate("rate_123");
|
|
899
|
+
* ```
|
|
900
|
+
*/
|
|
901
|
+
async deleteShippingRate(rateId: string): Promise<SuccessResponse> {
|
|
902
|
+
return this.delete(`/api/marketplace/merchant/shipping/rates/${rateId}`);
|
|
903
|
+
}
|
|
694
904
|
|
|
695
905
|
// ============================================================================
|
|
696
906
|
// Returns & Refunds
|
|
@@ -1337,5 +1547,578 @@ export class MerchantEcommerceClient extends BaseEcommerceClient {
|
|
|
1337
1547
|
async exportTaxReport(reportId: string): Promise<string> {
|
|
1338
1548
|
return this.get(`/api/marketplace/merchant/tax-reports/${reportId}/export`);
|
|
1339
1549
|
}
|
|
1550
|
+
|
|
1551
|
+
// ============================================
|
|
1552
|
+
// DROPSHIPPING APIs
|
|
1553
|
+
// ============================================
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* List connected dropship suppliers
|
|
1557
|
+
*
|
|
1558
|
+
* @returns Connected and available suppliers
|
|
1559
|
+
*
|
|
1560
|
+
* @example
|
|
1561
|
+
* ```typescript
|
|
1562
|
+
* const { connected, available } = await client.listDropshipSuppliers();
|
|
1563
|
+
* ```
|
|
1564
|
+
*/
|
|
1565
|
+
async listDropshipSuppliers(): Promise<{
|
|
1566
|
+
connected: DropshipSupplier[];
|
|
1567
|
+
available: DropshipSupplierInfo[];
|
|
1568
|
+
}> {
|
|
1569
|
+
return this.get("/api/marketplace/merchant/dropship/suppliers");
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
/**
|
|
1573
|
+
* Connect a new dropship supplier
|
|
1574
|
+
*
|
|
1575
|
+
* @param request - Supplier credentials
|
|
1576
|
+
* @returns Connected supplier
|
|
1577
|
+
*
|
|
1578
|
+
* @example
|
|
1579
|
+
* ```typescript
|
|
1580
|
+
* const supplier = await client.connectDropshipSupplier({
|
|
1581
|
+
* code: "CJ_DROPSHIPPING",
|
|
1582
|
+
* apiKey: "your-api-key"
|
|
1583
|
+
* });
|
|
1584
|
+
* ```
|
|
1585
|
+
*/
|
|
1586
|
+
async connectDropshipSupplier(request: ConnectDropshipSupplierRequest): Promise<{
|
|
1587
|
+
supplier: DropshipSupplier;
|
|
1588
|
+
message: string;
|
|
1589
|
+
}> {
|
|
1590
|
+
return this.post("/api/marketplace/merchant/dropship/suppliers", request);
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
/**
|
|
1594
|
+
* Update dropship supplier settings
|
|
1595
|
+
*
|
|
1596
|
+
* @param supplierId - Supplier ID
|
|
1597
|
+
* @param request - Settings to update
|
|
1598
|
+
* @returns Updated supplier
|
|
1599
|
+
*/
|
|
1600
|
+
async updateDropshipSupplier(
|
|
1601
|
+
supplierId: string,
|
|
1602
|
+
request: UpdateDropshipSupplierRequest
|
|
1603
|
+
): Promise<{ supplier: DropshipSupplier }> {
|
|
1604
|
+
return this.put(`/api/marketplace/merchant/dropship/suppliers/${supplierId}`, request);
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
/**
|
|
1608
|
+
* Disconnect a dropship supplier
|
|
1609
|
+
*
|
|
1610
|
+
* @param supplierId - Supplier ID
|
|
1611
|
+
*/
|
|
1612
|
+
async disconnectDropshipSupplier(supplierId: string): Promise<SuccessResponse> {
|
|
1613
|
+
return this.delete(`/api/marketplace/merchant/dropship/suppliers/${supplierId}`);
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* Search products from connected suppliers
|
|
1618
|
+
*
|
|
1619
|
+
* @param request - Search parameters
|
|
1620
|
+
* @returns Search results with pagination
|
|
1621
|
+
*
|
|
1622
|
+
* @example
|
|
1623
|
+
* ```typescript
|
|
1624
|
+
* const results = await client.searchDropshipProducts({
|
|
1625
|
+
* supplierId: "supplier_123",
|
|
1626
|
+
* query: "wireless headphones",
|
|
1627
|
+
* limit: 20
|
|
1628
|
+
* });
|
|
1629
|
+
* ```
|
|
1630
|
+
*/
|
|
1631
|
+
async searchDropshipProducts(request: SearchDropshipProductsRequest): Promise<{
|
|
1632
|
+
products: SupplierProduct[];
|
|
1633
|
+
pagination: { total: number; page: number; limit: number; hasMore: boolean };
|
|
1634
|
+
supplier?: string;
|
|
1635
|
+
}> {
|
|
1636
|
+
return this.post("/api/marketplace/merchant/dropship/search", request);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
/**
|
|
1640
|
+
* Get dropship supplier categories
|
|
1641
|
+
*
|
|
1642
|
+
* @param supplierId - Supplier ID
|
|
1643
|
+
* @returns Category list
|
|
1644
|
+
*/
|
|
1645
|
+
async getDropshipCategories(supplierId: string): Promise<{ categories: SupplierCategory[] }> {
|
|
1646
|
+
return this.get(`/api/marketplace/merchant/dropship/categories?supplierId=${supplierId}`);
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Get detailed product info from supplier
|
|
1651
|
+
*
|
|
1652
|
+
* @param supplierId - Supplier ID
|
|
1653
|
+
* @param externalProductId - Supplier's product ID
|
|
1654
|
+
* @returns Product details with suggested pricing
|
|
1655
|
+
*/
|
|
1656
|
+
async getDropshipProductDetails(
|
|
1657
|
+
supplierId: string,
|
|
1658
|
+
externalProductId: string
|
|
1659
|
+
): Promise<{
|
|
1660
|
+
product: SupplierProduct;
|
|
1661
|
+
suggestedPrice: number;
|
|
1662
|
+
estimatedMargin: number;
|
|
1663
|
+
}> {
|
|
1664
|
+
return this.get(
|
|
1665
|
+
`/api/marketplace/merchant/dropship/products/${encodeURIComponent(externalProductId)}?supplierId=${supplierId}`
|
|
1666
|
+
);
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
/**
|
|
1670
|
+
* Import a product from supplier to your store
|
|
1671
|
+
*
|
|
1672
|
+
* @param request - Import parameters
|
|
1673
|
+
* @returns Created product IDs
|
|
1674
|
+
*
|
|
1675
|
+
* @example
|
|
1676
|
+
* ```typescript
|
|
1677
|
+
* const result = await client.importDropshipProduct({
|
|
1678
|
+
* supplierId: "supplier_123",
|
|
1679
|
+
* externalProductId: "ext_product_456",
|
|
1680
|
+
* priceUSDC: 29.99,
|
|
1681
|
+
* title: "Custom Title"
|
|
1682
|
+
* });
|
|
1683
|
+
* ```
|
|
1684
|
+
*/
|
|
1685
|
+
async importDropshipProduct(request: ImportDropshipProductRequest): Promise<{
|
|
1686
|
+
success: boolean;
|
|
1687
|
+
productId?: string;
|
|
1688
|
+
dropshipProductId?: string;
|
|
1689
|
+
error?: string;
|
|
1690
|
+
}> {
|
|
1691
|
+
return this.post("/api/marketplace/merchant/dropship/import", request);
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
/**
|
|
1695
|
+
* Bulk import products from supplier
|
|
1696
|
+
*
|
|
1697
|
+
* @param request - Bulk import parameters
|
|
1698
|
+
* @returns Import results
|
|
1699
|
+
*/
|
|
1700
|
+
async bulkImportDropshipProducts(request: BulkImportDropshipProductsRequest): Promise<{
|
|
1701
|
+
success: boolean;
|
|
1702
|
+
imported: number;
|
|
1703
|
+
failed: number;
|
|
1704
|
+
results: Array<{
|
|
1705
|
+
externalProductId: string;
|
|
1706
|
+
success: boolean;
|
|
1707
|
+
productId?: string;
|
|
1708
|
+
error?: string;
|
|
1709
|
+
}>;
|
|
1710
|
+
}> {
|
|
1711
|
+
return this.post("/api/marketplace/merchant/dropship/import", request);
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
/**
|
|
1715
|
+
* List imported dropship products
|
|
1716
|
+
*
|
|
1717
|
+
* @param params - Filter parameters
|
|
1718
|
+
* @returns Imported products list
|
|
1719
|
+
*/
|
|
1720
|
+
async listDropshipProducts(params?: {
|
|
1721
|
+
supplierId?: string;
|
|
1722
|
+
isActive?: boolean;
|
|
1723
|
+
limit?: number;
|
|
1724
|
+
offset?: number;
|
|
1725
|
+
}): Promise<{
|
|
1726
|
+
items: DropshipProduct[];
|
|
1727
|
+
pagination: { total: number; limit: number; offset: number; hasMore: boolean };
|
|
1728
|
+
}> {
|
|
1729
|
+
const query = params ? `?${buildQueryString(params)}` : "";
|
|
1730
|
+
return this.get(`/api/marketplace/merchant/dropship/import${query}`);
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
/**
|
|
1734
|
+
* List dropship order links
|
|
1735
|
+
*
|
|
1736
|
+
* @param params - Filter parameters
|
|
1737
|
+
* @returns Order links with status summary
|
|
1738
|
+
*/
|
|
1739
|
+
async listDropshipOrders(params?: {
|
|
1740
|
+
status?: string | string[];
|
|
1741
|
+
limit?: number;
|
|
1742
|
+
offset?: number;
|
|
1743
|
+
}): Promise<{
|
|
1744
|
+
items: DropshipOrderLink[];
|
|
1745
|
+
pagination: { total: number; limit: number; offset: number; hasMore: boolean };
|
|
1746
|
+
summary: {
|
|
1747
|
+
pending: number;
|
|
1748
|
+
forwarded: number;
|
|
1749
|
+
processing: number;
|
|
1750
|
+
shipped: number;
|
|
1751
|
+
delivered: number;
|
|
1752
|
+
failed: number;
|
|
1753
|
+
};
|
|
1754
|
+
}> {
|
|
1755
|
+
let query = "";
|
|
1756
|
+
if (params) {
|
|
1757
|
+
const queryParams: Record<string, string> = {};
|
|
1758
|
+
if (params.status) {
|
|
1759
|
+
queryParams.status = Array.isArray(params.status) ? params.status.join(",") : params.status;
|
|
1760
|
+
}
|
|
1761
|
+
if (params.limit) queryParams.limit = params.limit.toString();
|
|
1762
|
+
if (params.offset) queryParams.offset = params.offset.toString();
|
|
1763
|
+
query = `?${buildQueryString(queryParams)}`;
|
|
1764
|
+
}
|
|
1765
|
+
return this.get(`/api/marketplace/merchant/dropship/orders${query}`);
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* Forward orders to supplier
|
|
1770
|
+
*
|
|
1771
|
+
* @param orderItemIds - Order item IDs to forward
|
|
1772
|
+
* @returns Forward results
|
|
1773
|
+
*/
|
|
1774
|
+
async forwardDropshipOrders(orderItemIds: string[]): Promise<{
|
|
1775
|
+
success: boolean;
|
|
1776
|
+
forwarded: number;
|
|
1777
|
+
failed: number;
|
|
1778
|
+
results: Array<{
|
|
1779
|
+
orderItemId: string;
|
|
1780
|
+
success: boolean;
|
|
1781
|
+
externalOrderId?: string;
|
|
1782
|
+
error?: string;
|
|
1783
|
+
}>;
|
|
1784
|
+
}> {
|
|
1785
|
+
return this.post("/api/marketplace/merchant/dropship/orders", {
|
|
1786
|
+
action: "forward",
|
|
1787
|
+
orderItemIds,
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
/**
|
|
1792
|
+
* Sync tracking for all pending dropship orders
|
|
1793
|
+
*
|
|
1794
|
+
* @returns Sync results
|
|
1795
|
+
*/
|
|
1796
|
+
async syncDropshipTracking(): Promise<{
|
|
1797
|
+
success: boolean;
|
|
1798
|
+
total: number;
|
|
1799
|
+
synced: number;
|
|
1800
|
+
updated: number;
|
|
1801
|
+
failed: number;
|
|
1802
|
+
}> {
|
|
1803
|
+
return this.post("/api/marketplace/merchant/dropship/orders", {
|
|
1804
|
+
action: "sync",
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* Get order forwarding details for manual forwarding
|
|
1810
|
+
*
|
|
1811
|
+
* @param orderItemId - Order item ID
|
|
1812
|
+
* @returns Forwarding details
|
|
1813
|
+
*/
|
|
1814
|
+
async getDropshipOrderDetails(orderItemId: string): Promise<{
|
|
1815
|
+
details: {
|
|
1816
|
+
orderId: string;
|
|
1817
|
+
orderItemId: string;
|
|
1818
|
+
productTitle: string;
|
|
1819
|
+
quantity: number;
|
|
1820
|
+
supplierName: string;
|
|
1821
|
+
supplierProductId: string;
|
|
1822
|
+
supplierPrice: number;
|
|
1823
|
+
shippingAddress: ShippingAddress;
|
|
1824
|
+
estimatedCost: number;
|
|
1825
|
+
status: string;
|
|
1826
|
+
};
|
|
1827
|
+
}> {
|
|
1828
|
+
return this.get(`/api/marketplace/merchant/dropship/orders/${orderItemId}/forward`);
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
/**
|
|
1832
|
+
* Forward a single order item to supplier
|
|
1833
|
+
*
|
|
1834
|
+
* @param orderItemId - Order item ID
|
|
1835
|
+
* @returns Forward result
|
|
1836
|
+
*/
|
|
1837
|
+
async forwardDropshipOrder(orderItemId: string): Promise<{
|
|
1838
|
+
success: boolean;
|
|
1839
|
+
dropshipOrderLinkId?: string;
|
|
1840
|
+
externalOrderId?: string;
|
|
1841
|
+
error?: string;
|
|
1842
|
+
}> {
|
|
1843
|
+
return this.post(`/api/marketplace/merchant/dropship/orders/${orderItemId}/forward`, {});
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
/**
|
|
1847
|
+
* Get dropship settings
|
|
1848
|
+
*
|
|
1849
|
+
* @returns Merchant dropship settings
|
|
1850
|
+
*/
|
|
1851
|
+
async getDropshipSettings(): Promise<{ settings: DropshipMerchantSettings }> {
|
|
1852
|
+
return this.get("/api/marketplace/merchant/dropship/settings");
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* Update dropship settings
|
|
1857
|
+
*
|
|
1858
|
+
* @param request - Settings to update
|
|
1859
|
+
* @returns Updated settings
|
|
1860
|
+
*/
|
|
1861
|
+
async updateDropshipSettings(request: UpdateDropshipSettingsRequest): Promise<{
|
|
1862
|
+
settings: DropshipMerchantSettings;
|
|
1863
|
+
}> {
|
|
1864
|
+
return this.put("/api/marketplace/merchant/dropship/settings", request);
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* Sync dropship products and/or orders
|
|
1869
|
+
*
|
|
1870
|
+
* @param type - Sync type (products, orders, all, single)
|
|
1871
|
+
* @param dropshipProductId - For single product sync
|
|
1872
|
+
* @returns Sync results
|
|
1873
|
+
*/
|
|
1874
|
+
async syncDropship(
|
|
1875
|
+
type: "products" | "orders" | "all" | "single",
|
|
1876
|
+
dropshipProductId?: string
|
|
1877
|
+
): Promise<{
|
|
1878
|
+
success: boolean;
|
|
1879
|
+
type: string;
|
|
1880
|
+
results: {
|
|
1881
|
+
products?: { total: number; synced: number; failed: number };
|
|
1882
|
+
orders?: { total: number; synced: number; updated: number; failed: number };
|
|
1883
|
+
product?: { success: boolean; updated: boolean; error?: string };
|
|
1884
|
+
};
|
|
1885
|
+
}> {
|
|
1886
|
+
return this.post("/api/marketplace/merchant/dropship/sync", {
|
|
1887
|
+
type,
|
|
1888
|
+
dropshipProductId,
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
// ============================================
|
|
1894
|
+
// DROPSHIPPING TYPES
|
|
1895
|
+
// ============================================
|
|
1896
|
+
|
|
1897
|
+
export interface DropshipSupplier {
|
|
1898
|
+
id: string;
|
|
1899
|
+
code: string;
|
|
1900
|
+
name: string;
|
|
1901
|
+
isActive: boolean;
|
|
1902
|
+
autoForward: boolean;
|
|
1903
|
+
settings?: Record<string, any>;
|
|
1904
|
+
createdAt: string;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
export interface DropshipSupplierInfo {
|
|
1908
|
+
code: string;
|
|
1909
|
+
name: string;
|
|
1910
|
+
description: string;
|
|
1911
|
+
features: string[];
|
|
1912
|
+
isConnected: boolean;
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
export interface ConnectDropshipSupplierRequest {
|
|
1916
|
+
code: string;
|
|
1917
|
+
apiKey?: string;
|
|
1918
|
+
apiSecret?: string;
|
|
1919
|
+
accessToken?: string;
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
export interface UpdateDropshipSupplierRequest {
|
|
1923
|
+
autoForward?: boolean;
|
|
1924
|
+
settings?: Record<string, any>;
|
|
1925
|
+
apiKey?: string;
|
|
1926
|
+
apiSecret?: string;
|
|
1927
|
+
accessToken?: string;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
export interface SearchDropshipProductsRequest {
|
|
1931
|
+
supplierId?: string;
|
|
1932
|
+
supplierCode?: string;
|
|
1933
|
+
query?: string;
|
|
1934
|
+
category?: string;
|
|
1935
|
+
minPrice?: number;
|
|
1936
|
+
maxPrice?: number;
|
|
1937
|
+
page?: number;
|
|
1938
|
+
limit?: number;
|
|
1939
|
+
sortBy?: "price_asc" | "price_desc" | "rating" | "orders" | "newest";
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
export interface SupplierProduct {
|
|
1943
|
+
externalProductId: string;
|
|
1944
|
+
externalUrl?: string;
|
|
1945
|
+
externalSku?: string;
|
|
1946
|
+
title: string;
|
|
1947
|
+
description: string;
|
|
1948
|
+
images: string[];
|
|
1949
|
+
price: number;
|
|
1950
|
+
currency: string;
|
|
1951
|
+
shippingCost?: number;
|
|
1952
|
+
processingDays?: number;
|
|
1953
|
+
shippingDays?: number;
|
|
1954
|
+
warehouseLocation?: string;
|
|
1955
|
+
category?: string;
|
|
1956
|
+
variants?: SupplierProductVariant[];
|
|
1957
|
+
rating?: number;
|
|
1958
|
+
reviewCount?: number;
|
|
1959
|
+
minOrderQuantity?: number;
|
|
1960
|
+
inventory?: number;
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
export interface SupplierProductVariant {
|
|
1964
|
+
externalVariantId: string;
|
|
1965
|
+
name: string;
|
|
1966
|
+
sku?: string;
|
|
1967
|
+
price: number;
|
|
1968
|
+
inventory?: number;
|
|
1969
|
+
attributes: Record<string, string>;
|
|
1970
|
+
image?: string;
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
export interface SupplierCategory {
|
|
1974
|
+
id: string;
|
|
1975
|
+
name: string;
|
|
1976
|
+
parentId?: string;
|
|
1977
|
+
children?: SupplierCategory[];
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
export interface ImportDropshipProductRequest {
|
|
1981
|
+
supplierId: string;
|
|
1982
|
+
externalProductId: string;
|
|
1983
|
+
priceUSDC: number;
|
|
1984
|
+
compareAtPrice?: number;
|
|
1985
|
+
title?: string;
|
|
1986
|
+
richDescription?: string;
|
|
1987
|
+
category?: string;
|
|
1988
|
+
categoryId?: string;
|
|
1989
|
+
tags?: string[];
|
|
1990
|
+
isActive?: boolean;
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
export interface BulkImportDropshipProductsRequest {
|
|
1994
|
+
supplierId: string;
|
|
1995
|
+
products: Array<{
|
|
1996
|
+
externalProductId: string;
|
|
1997
|
+
priceUSDC: number;
|
|
1998
|
+
compareAtPrice?: number;
|
|
1999
|
+
title?: string;
|
|
2000
|
+
category?: string;
|
|
2001
|
+
categoryId?: string;
|
|
2002
|
+
}>;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
export interface DropshipProduct {
|
|
2006
|
+
id: string;
|
|
2007
|
+
supplierId: string;
|
|
2008
|
+
externalProductId: string;
|
|
2009
|
+
externalUrl?: string;
|
|
2010
|
+
supplierPrice: string;
|
|
2011
|
+
supplierCurrency: string;
|
|
2012
|
+
shippingCost?: string;
|
|
2013
|
+
processingDays?: number;
|
|
2014
|
+
shippingDays?: number;
|
|
2015
|
+
warehouseLocation?: string;
|
|
2016
|
+
productSnapshot: any;
|
|
2017
|
+
lastSyncedAt?: string;
|
|
2018
|
+
syncError?: string;
|
|
2019
|
+
localProductId?: string;
|
|
2020
|
+
localProduct?: {
|
|
2021
|
+
id: string;
|
|
2022
|
+
title: string;
|
|
2023
|
+
priceUSDC: string;
|
|
2024
|
+
images: string[];
|
|
2025
|
+
isActive: boolean;
|
|
2026
|
+
inventory?: number;
|
|
2027
|
+
soldCount: number;
|
|
2028
|
+
};
|
|
2029
|
+
supplier?: {
|
|
2030
|
+
id: string;
|
|
2031
|
+
name: string;
|
|
2032
|
+
code: string;
|
|
2033
|
+
};
|
|
2034
|
+
isActive: boolean;
|
|
2035
|
+
createdAt: string;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
export interface DropshipOrderLink {
|
|
2039
|
+
id: string;
|
|
2040
|
+
orderId: string;
|
|
2041
|
+
orderItemId: string;
|
|
2042
|
+
supplierId: string;
|
|
2043
|
+
dropshipProductId?: string;
|
|
2044
|
+
externalOrderId?: string;
|
|
2045
|
+
externalStatus?: string;
|
|
2046
|
+
status: string;
|
|
2047
|
+
forwardedAt?: string;
|
|
2048
|
+
processedAt?: string;
|
|
2049
|
+
shippedAt?: string;
|
|
2050
|
+
deliveredAt?: string;
|
|
2051
|
+
trackingNumber?: string;
|
|
2052
|
+
trackingUrl?: string;
|
|
2053
|
+
carrier?: string;
|
|
2054
|
+
supplierCost?: string;
|
|
2055
|
+
shippingCost?: string;
|
|
2056
|
+
lastError?: string;
|
|
2057
|
+
order?: {
|
|
2058
|
+
id: string;
|
|
2059
|
+
status: string;
|
|
2060
|
+
totalUSDC: string;
|
|
2061
|
+
shippingAddress: any;
|
|
2062
|
+
createdAt: string;
|
|
2063
|
+
};
|
|
2064
|
+
orderItem?: {
|
|
2065
|
+
id: string;
|
|
2066
|
+
titleSnapshot: string;
|
|
2067
|
+
quantity: number;
|
|
2068
|
+
unitPriceUSDC: string;
|
|
2069
|
+
};
|
|
2070
|
+
supplier?: {
|
|
2071
|
+
id: string;
|
|
2072
|
+
name: string;
|
|
2073
|
+
code: string;
|
|
2074
|
+
};
|
|
2075
|
+
createdAt: string;
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
export interface DropshipMerchantSettings {
|
|
2079
|
+
merchantId: string;
|
|
2080
|
+
defaultMarkupType: string;
|
|
2081
|
+
defaultMarkupValue: string;
|
|
2082
|
+
roundPriceTo?: string;
|
|
2083
|
+
autoForwardOrders: boolean;
|
|
2084
|
+
autoSyncTracking: boolean;
|
|
2085
|
+
syncIntervalMinutes: number;
|
|
2086
|
+
autoSyncInventory: boolean;
|
|
2087
|
+
lowStockThreshold: number;
|
|
2088
|
+
outOfStockBehavior: string;
|
|
2089
|
+
defaultShippingMethod?: string;
|
|
2090
|
+
freeShippingThreshold?: string;
|
|
2091
|
+
notifyOnNewOrder: boolean;
|
|
2092
|
+
notifyOnLowStock: boolean;
|
|
2093
|
+
notifyOnShipment: boolean;
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
export interface UpdateDropshipSettingsRequest {
|
|
2097
|
+
defaultMarkupType?: string;
|
|
2098
|
+
defaultMarkupValue?: number;
|
|
2099
|
+
roundPriceTo?: number | null;
|
|
2100
|
+
autoForwardOrders?: boolean;
|
|
2101
|
+
autoSyncTracking?: boolean;
|
|
2102
|
+
syncIntervalMinutes?: number;
|
|
2103
|
+
autoSyncInventory?: boolean;
|
|
2104
|
+
lowStockThreshold?: number;
|
|
2105
|
+
outOfStockBehavior?: string;
|
|
2106
|
+
defaultShippingMethod?: string | null;
|
|
2107
|
+
freeShippingThreshold?: number | null;
|
|
2108
|
+
notifyOnNewOrder?: boolean;
|
|
2109
|
+
notifyOnLowStock?: boolean;
|
|
2110
|
+
notifyOnShipment?: boolean;
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
interface ShippingAddress {
|
|
2114
|
+
fullName: string;
|
|
2115
|
+
phone: string;
|
|
2116
|
+
email?: string;
|
|
2117
|
+
addressLine1: string;
|
|
2118
|
+
addressLine2?: string;
|
|
2119
|
+
city: string;
|
|
2120
|
+
state?: string;
|
|
2121
|
+
postalCode: string;
|
|
2122
|
+
country: string;
|
|
1340
2123
|
}
|
|
1341
2124
|
|