@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
package/dist/ecommerce.js
CHANGED
|
@@ -140,11 +140,13 @@ var BaseEcommerceClient = class {
|
|
|
140
140
|
maxRetries: config.maxRetries || 3,
|
|
141
141
|
retryBaseDelay: config.retryBaseDelay || 1e3,
|
|
142
142
|
headers: config.headers,
|
|
143
|
-
enableRetry: config.enableRetry !== false
|
|
143
|
+
enableRetry: config.enableRetry !== false,
|
|
144
|
+
withCredentials: config.withCredentials || false
|
|
144
145
|
};
|
|
145
146
|
this.axiosInstance = axios__default.default.create({
|
|
146
147
|
baseURL: this.config.baseURL,
|
|
147
148
|
timeout: this.config.timeout,
|
|
149
|
+
withCredentials: this.config.withCredentials,
|
|
148
150
|
headers: {
|
|
149
151
|
"Content-Type": "application/json",
|
|
150
152
|
...this.config.headers
|
|
@@ -688,6 +690,34 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
688
690
|
return this.post("/api/marketplace/tax/calculate", request);
|
|
689
691
|
}
|
|
690
692
|
// ============================================================================
|
|
693
|
+
// Shipping Calculation API
|
|
694
|
+
// ============================================================================
|
|
695
|
+
/**
|
|
696
|
+
* Calculate shipping options for cart items
|
|
697
|
+
*
|
|
698
|
+
* @param request - Cart items, merchant, and destination
|
|
699
|
+
* @returns Available shipping options with costs
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* ```typescript
|
|
703
|
+
* const result = await client.calculateShippingOptions({
|
|
704
|
+
* merchantId: "merchant_123",
|
|
705
|
+
* cartItems: [
|
|
706
|
+
* { productId: "prod_123", quantity: 2 }
|
|
707
|
+
* ],
|
|
708
|
+
* destinationCountry: "US",
|
|
709
|
+
* orderSubtotal: 99.99
|
|
710
|
+
* });
|
|
711
|
+
*
|
|
712
|
+
* result.shippingOptions.forEach(opt => {
|
|
713
|
+
* console.log(opt.name, opt.cost, opt.estimatedDelivery);
|
|
714
|
+
* });
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
717
|
+
async calculateShippingOptions(request) {
|
|
718
|
+
return this.post("/api/marketplace/shipping/calculate", request);
|
|
719
|
+
}
|
|
720
|
+
// ============================================================================
|
|
691
721
|
// Banners API
|
|
692
722
|
// ============================================================================
|
|
693
723
|
/**
|
|
@@ -945,6 +975,171 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
945
975
|
const queryString = params ? buildQueryString(params) : "";
|
|
946
976
|
return this.get(`/api/marketplace/following${queryString}`);
|
|
947
977
|
}
|
|
978
|
+
// ============================================================================
|
|
979
|
+
// Payment Methods
|
|
980
|
+
// ============================================================================
|
|
981
|
+
/**
|
|
982
|
+
* Get available payment methods
|
|
983
|
+
*
|
|
984
|
+
* Returns the list of enabled payment methods that can be used during checkout.
|
|
985
|
+
*
|
|
986
|
+
* @returns List of available payment methods with display info
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* ```typescript
|
|
990
|
+
* const result = await client.getPaymentMethods();
|
|
991
|
+
* if (result.paymentsEnabled) {
|
|
992
|
+
* result.methods.forEach(method => {
|
|
993
|
+
* console.log(`${method.name}: ${method.description}`);
|
|
994
|
+
* });
|
|
995
|
+
* }
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
async getPaymentMethods() {
|
|
999
|
+
return this.get("/api/marketplace/payments/methods");
|
|
1000
|
+
}
|
|
1001
|
+
// ============================================================================
|
|
1002
|
+
// GEM System API
|
|
1003
|
+
// ============================================================================
|
|
1004
|
+
/**
|
|
1005
|
+
* Get user's gem balance
|
|
1006
|
+
*
|
|
1007
|
+
* Returns the current gem balance including total gems, available gems,
|
|
1008
|
+
* and gems expiring soon. Gems are earned at 100 per $1 of revenue.
|
|
1009
|
+
*
|
|
1010
|
+
* @returns Current gem balance with USD equivalent
|
|
1011
|
+
*
|
|
1012
|
+
* @example
|
|
1013
|
+
* ```typescript
|
|
1014
|
+
* const balance = await client.getGemBalance();
|
|
1015
|
+
* console.log(`You have ${balance.totalGems} gems (${balance.usdEquivalent} USD)`);
|
|
1016
|
+
* console.log(`${balance.expiringSoon} gems expiring soon`);
|
|
1017
|
+
* ```
|
|
1018
|
+
*/
|
|
1019
|
+
async getGemBalance() {
|
|
1020
|
+
return this.get("/api/gems/balance");
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Get gem transaction history
|
|
1024
|
+
*
|
|
1025
|
+
* Returns paginated history of gem transactions including earning,
|
|
1026
|
+
* spending, and expiration events.
|
|
1027
|
+
*
|
|
1028
|
+
* @param params - Query parameters for filtering and pagination
|
|
1029
|
+
* @returns Paginated gem history
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```typescript
|
|
1033
|
+
* // Get all history
|
|
1034
|
+
* const history = await client.getGemHistory({ limit: 20, offset: 0 });
|
|
1035
|
+
*
|
|
1036
|
+
* // Get only earned gems
|
|
1037
|
+
* const earned = await client.getGemHistory({ type: "earn", limit: 10 });
|
|
1038
|
+
*
|
|
1039
|
+
* // Get only spent gems
|
|
1040
|
+
* const spent = await client.getGemHistory({ type: "spend", limit: 10 });
|
|
1041
|
+
*
|
|
1042
|
+
* history.items.forEach(item => {
|
|
1043
|
+
* console.log(`${item.type}: ${item.amount} gems - ${item.createdAt}`);
|
|
1044
|
+
* });
|
|
1045
|
+
* ```
|
|
1046
|
+
*/
|
|
1047
|
+
async getGemHistory(params) {
|
|
1048
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
1049
|
+
return this.get(`/api/gems/history${queryString}`);
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Get gems that are expiring soon
|
|
1053
|
+
*
|
|
1054
|
+
* Returns gem batches that will expire within the specified number of days.
|
|
1055
|
+
* Useful for prompting users to spend gems before they expire.
|
|
1056
|
+
*
|
|
1057
|
+
* @param params - Query parameters (days: default 30, max 180)
|
|
1058
|
+
* @returns Expiring gem batches with countdown info
|
|
1059
|
+
*
|
|
1060
|
+
* @example
|
|
1061
|
+
* ```typescript
|
|
1062
|
+
* // Get gems expiring in next 30 days (default)
|
|
1063
|
+
* const expiring = await client.getExpiringGems();
|
|
1064
|
+
*
|
|
1065
|
+
* // Get gems expiring in next 7 days
|
|
1066
|
+
* const urgent = await client.getExpiringGems({ days: 7 });
|
|
1067
|
+
*
|
|
1068
|
+
* if (expiring.totalExpiring > 0) {
|
|
1069
|
+
* console.log(`${expiring.totalExpiring} gems expiring soon!`);
|
|
1070
|
+
* expiring.batches.forEach(batch => {
|
|
1071
|
+
* console.log(`${batch.amount} gems expire in ${batch.daysUntilExpiry} days`);
|
|
1072
|
+
* });
|
|
1073
|
+
* }
|
|
1074
|
+
* ```
|
|
1075
|
+
*/
|
|
1076
|
+
async getExpiringGems(params) {
|
|
1077
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
1078
|
+
return this.get(`/api/gems/expiring${queryString}`);
|
|
1079
|
+
}
|
|
1080
|
+
// ============================================================================
|
|
1081
|
+
// Browsing Location API
|
|
1082
|
+
// ============================================================================
|
|
1083
|
+
/**
|
|
1084
|
+
* Get user's browsing location
|
|
1085
|
+
*
|
|
1086
|
+
* Returns the user's saved delivery location for geo-based product filtering.
|
|
1087
|
+
* This location is used to show products from merchants that ship to the area.
|
|
1088
|
+
*
|
|
1089
|
+
* @returns Current browsing location or null if not set
|
|
1090
|
+
*
|
|
1091
|
+
* @example
|
|
1092
|
+
* ```typescript
|
|
1093
|
+
* const result = await client.getBrowsingLocation();
|
|
1094
|
+
* if (result.location) {
|
|
1095
|
+
* console.log(`Delivery to: ${result.location.city}, ${result.location.country}`);
|
|
1096
|
+
* }
|
|
1097
|
+
* ```
|
|
1098
|
+
*/
|
|
1099
|
+
async getBrowsingLocation() {
|
|
1100
|
+
return this.get("/api/user/browsing-location");
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Save user's browsing location
|
|
1104
|
+
*
|
|
1105
|
+
* Sets the user's delivery location for geo-based product filtering.
|
|
1106
|
+
* Products will be filtered to show only items from merchants that ship to this location.
|
|
1107
|
+
*
|
|
1108
|
+
* @param request - Location data from Google Places or manual input
|
|
1109
|
+
* @returns The saved location
|
|
1110
|
+
*
|
|
1111
|
+
* @example
|
|
1112
|
+
* ```typescript
|
|
1113
|
+
* const result = await client.saveBrowsingLocation({
|
|
1114
|
+
* formattedAddress: "Singapore, Singapore",
|
|
1115
|
+
* city: "Singapore",
|
|
1116
|
+
* country: "SG",
|
|
1117
|
+
* latitude: 1.3521,
|
|
1118
|
+
* longitude: 103.8198
|
|
1119
|
+
* });
|
|
1120
|
+
* console.log(`Location saved: ${result.location.formattedAddress}`);
|
|
1121
|
+
* ```
|
|
1122
|
+
*/
|
|
1123
|
+
async saveBrowsingLocation(request) {
|
|
1124
|
+
return this.post("/api/user/browsing-location", request);
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Clear user's browsing location
|
|
1128
|
+
*
|
|
1129
|
+
* Removes the user's saved delivery location. Products will no longer
|
|
1130
|
+
* be filtered by shipping destination.
|
|
1131
|
+
*
|
|
1132
|
+
* @returns Success response
|
|
1133
|
+
*
|
|
1134
|
+
* @example
|
|
1135
|
+
* ```typescript
|
|
1136
|
+
* await client.clearBrowsingLocation();
|
|
1137
|
+
* console.log("Location cleared - showing all products");
|
|
1138
|
+
* ```
|
|
1139
|
+
*/
|
|
1140
|
+
async clearBrowsingLocation() {
|
|
1141
|
+
return this.delete("/api/user/browsing-location");
|
|
1142
|
+
}
|
|
948
1143
|
};
|
|
949
1144
|
|
|
950
1145
|
// lib/ecommerce/client/merchant.ts
|
|
@@ -1479,6 +1674,192 @@ var MerchantEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1479
1674
|
return this.patch(`/api/marketplace/merchant/shipping/shipments/${shipmentId}`, request);
|
|
1480
1675
|
}
|
|
1481
1676
|
// ============================================================================
|
|
1677
|
+
// Shipping Settings (Zones & Rates)
|
|
1678
|
+
// ============================================================================
|
|
1679
|
+
/**
|
|
1680
|
+
* Get merchant shipping settings
|
|
1681
|
+
*
|
|
1682
|
+
* @returns Shipping settings
|
|
1683
|
+
*
|
|
1684
|
+
* @example
|
|
1685
|
+
* ```typescript
|
|
1686
|
+
* const { settings } = await client.getShippingSettings();
|
|
1687
|
+
* console.log("Handling fee:", settings.defaultHandlingFee);
|
|
1688
|
+
* ```
|
|
1689
|
+
*/
|
|
1690
|
+
async getShippingSettings() {
|
|
1691
|
+
return this.get("/api/marketplace/merchant/shipping/settings");
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Update merchant shipping settings
|
|
1695
|
+
*
|
|
1696
|
+
* @param request - Settings to update
|
|
1697
|
+
* @returns Updated settings
|
|
1698
|
+
*
|
|
1699
|
+
* @example
|
|
1700
|
+
* ```typescript
|
|
1701
|
+
* await client.updateShippingSettings({
|
|
1702
|
+
* defaultHandlingFee: 2.50,
|
|
1703
|
+
* freeShippingEnabled: true,
|
|
1704
|
+
* freeShippingThreshold: 100
|
|
1705
|
+
* });
|
|
1706
|
+
* ```
|
|
1707
|
+
*/
|
|
1708
|
+
async updateShippingSettings(request) {
|
|
1709
|
+
return this.post("/api/marketplace/merchant/shipping/settings", request);
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* List all shipping zones
|
|
1713
|
+
*
|
|
1714
|
+
* @returns List of shipping zones with rate counts
|
|
1715
|
+
*
|
|
1716
|
+
* @example
|
|
1717
|
+
* ```typescript
|
|
1718
|
+
* const { zones } = await client.listShippingZones();
|
|
1719
|
+
* zones.forEach(z => console.log(z.name, z.countries.length, "countries"));
|
|
1720
|
+
* ```
|
|
1721
|
+
*/
|
|
1722
|
+
async listShippingZones() {
|
|
1723
|
+
return this.get("/api/marketplace/merchant/shipping/zones");
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Get a shipping zone by ID
|
|
1727
|
+
*
|
|
1728
|
+
* @param zoneId - Zone ID
|
|
1729
|
+
* @returns Zone with rates
|
|
1730
|
+
*
|
|
1731
|
+
* @example
|
|
1732
|
+
* ```typescript
|
|
1733
|
+
* const { zone } = await client.getShippingZone("zone_123");
|
|
1734
|
+
* console.log(zone.name, zone.rates?.length, "rates");
|
|
1735
|
+
* ```
|
|
1736
|
+
*/
|
|
1737
|
+
async getShippingZone(zoneId) {
|
|
1738
|
+
return this.get(`/api/marketplace/merchant/shipping/zones/${zoneId}`);
|
|
1739
|
+
}
|
|
1740
|
+
/**
|
|
1741
|
+
* Create a shipping zone
|
|
1742
|
+
*
|
|
1743
|
+
* @param request - Zone data
|
|
1744
|
+
* @returns Created zone
|
|
1745
|
+
*
|
|
1746
|
+
* @example
|
|
1747
|
+
* ```typescript
|
|
1748
|
+
* const { zone } = await client.createShippingZone({
|
|
1749
|
+
* name: "Southeast Asia",
|
|
1750
|
+
* countries: ["SG", "MY", "TH", "ID", "PH", "VN"],
|
|
1751
|
+
* isDefault: false,
|
|
1752
|
+
* priority: 10
|
|
1753
|
+
* });
|
|
1754
|
+
* ```
|
|
1755
|
+
*/
|
|
1756
|
+
async createShippingZone(request) {
|
|
1757
|
+
return this.post("/api/marketplace/merchant/shipping/zones", request);
|
|
1758
|
+
}
|
|
1759
|
+
/**
|
|
1760
|
+
* Update a shipping zone
|
|
1761
|
+
*
|
|
1762
|
+
* @param zoneId - Zone ID
|
|
1763
|
+
* @param request - Updated zone data
|
|
1764
|
+
* @returns Updated zone
|
|
1765
|
+
*
|
|
1766
|
+
* @example
|
|
1767
|
+
* ```typescript
|
|
1768
|
+
* await client.updateShippingZone("zone_123", {
|
|
1769
|
+
* countries: ["SG", "MY", "TH", "ID", "PH", "VN", "BN"]
|
|
1770
|
+
* });
|
|
1771
|
+
* ```
|
|
1772
|
+
*/
|
|
1773
|
+
async updateShippingZone(zoneId, request) {
|
|
1774
|
+
return this.put(`/api/marketplace/merchant/shipping/zones/${zoneId}`, request);
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Delete a shipping zone
|
|
1778
|
+
*
|
|
1779
|
+
* @param zoneId - Zone ID
|
|
1780
|
+
* @returns Success response
|
|
1781
|
+
*
|
|
1782
|
+
* @example
|
|
1783
|
+
* ```typescript
|
|
1784
|
+
* await client.deleteShippingZone("zone_123");
|
|
1785
|
+
* ```
|
|
1786
|
+
*/
|
|
1787
|
+
async deleteShippingZone(zoneId) {
|
|
1788
|
+
return this.delete(`/api/marketplace/merchant/shipping/zones/${zoneId}`);
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* List shipping rates
|
|
1792
|
+
*
|
|
1793
|
+
* @param zoneId - Optional zone ID to filter by
|
|
1794
|
+
* @returns List of shipping rates
|
|
1795
|
+
*
|
|
1796
|
+
* @example
|
|
1797
|
+
* ```typescript
|
|
1798
|
+
* // All rates
|
|
1799
|
+
* const { rates } = await client.listShippingRates();
|
|
1800
|
+
*
|
|
1801
|
+
* // Rates for a specific zone
|
|
1802
|
+
* const { rates: zoneRates } = await client.listShippingRates("zone_123");
|
|
1803
|
+
* ```
|
|
1804
|
+
*/
|
|
1805
|
+
async listShippingRates(zoneId) {
|
|
1806
|
+
const query = zoneId ? `?zoneId=${zoneId}` : "";
|
|
1807
|
+
return this.get(`/api/marketplace/merchant/shipping/rates${query}`);
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* Create a shipping rate
|
|
1811
|
+
*
|
|
1812
|
+
* @param request - Rate data
|
|
1813
|
+
* @returns Created rate
|
|
1814
|
+
*
|
|
1815
|
+
* @example
|
|
1816
|
+
* ```typescript
|
|
1817
|
+
* const { rate } = await client.createShippingRate({
|
|
1818
|
+
* zoneId: "zone_123",
|
|
1819
|
+
* name: "Standard Shipping",
|
|
1820
|
+
* baseRate: 5.00,
|
|
1821
|
+
* perKgRate: 1.50,
|
|
1822
|
+
* minDeliveryDays: 7,
|
|
1823
|
+
* maxDeliveryDays: 14
|
|
1824
|
+
* });
|
|
1825
|
+
* ```
|
|
1826
|
+
*/
|
|
1827
|
+
async createShippingRate(request) {
|
|
1828
|
+
return this.post("/api/marketplace/merchant/shipping/rates", request);
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Update a shipping rate
|
|
1832
|
+
*
|
|
1833
|
+
* @param rateId - Rate ID
|
|
1834
|
+
* @param request - Updated rate data
|
|
1835
|
+
* @returns Updated rate
|
|
1836
|
+
*
|
|
1837
|
+
* @example
|
|
1838
|
+
* ```typescript
|
|
1839
|
+
* await client.updateShippingRate("rate_123", {
|
|
1840
|
+
* baseRate: 6.00,
|
|
1841
|
+
* freeAboveAmount: 75
|
|
1842
|
+
* });
|
|
1843
|
+
* ```
|
|
1844
|
+
*/
|
|
1845
|
+
async updateShippingRate(rateId, request) {
|
|
1846
|
+
return this.put(`/api/marketplace/merchant/shipping/rates/${rateId}`, request);
|
|
1847
|
+
}
|
|
1848
|
+
/**
|
|
1849
|
+
* Delete a shipping rate
|
|
1850
|
+
*
|
|
1851
|
+
* @param rateId - Rate ID
|
|
1852
|
+
* @returns Success response
|
|
1853
|
+
*
|
|
1854
|
+
* @example
|
|
1855
|
+
* ```typescript
|
|
1856
|
+
* await client.deleteShippingRate("rate_123");
|
|
1857
|
+
* ```
|
|
1858
|
+
*/
|
|
1859
|
+
async deleteShippingRate(rateId) {
|
|
1860
|
+
return this.delete(`/api/marketplace/merchant/shipping/rates/${rateId}`);
|
|
1861
|
+
}
|
|
1862
|
+
// ============================================================================
|
|
1482
1863
|
// Returns & Refunds
|
|
1483
1864
|
// ============================================================================
|
|
1484
1865
|
/**
|
|
@@ -2076,6 +2457,223 @@ var MerchantEcommerceClient = class extends BaseEcommerceClient {
|
|
|
2076
2457
|
async exportTaxReport(reportId) {
|
|
2077
2458
|
return this.get(`/api/marketplace/merchant/tax-reports/${reportId}/export`);
|
|
2078
2459
|
}
|
|
2460
|
+
// ============================================
|
|
2461
|
+
// DROPSHIPPING APIs
|
|
2462
|
+
// ============================================
|
|
2463
|
+
/**
|
|
2464
|
+
* List connected dropship suppliers
|
|
2465
|
+
*
|
|
2466
|
+
* @returns Connected and available suppliers
|
|
2467
|
+
*
|
|
2468
|
+
* @example
|
|
2469
|
+
* ```typescript
|
|
2470
|
+
* const { connected, available } = await client.listDropshipSuppliers();
|
|
2471
|
+
* ```
|
|
2472
|
+
*/
|
|
2473
|
+
async listDropshipSuppliers() {
|
|
2474
|
+
return this.get("/api/marketplace/merchant/dropship/suppliers");
|
|
2475
|
+
}
|
|
2476
|
+
/**
|
|
2477
|
+
* Connect a new dropship supplier
|
|
2478
|
+
*
|
|
2479
|
+
* @param request - Supplier credentials
|
|
2480
|
+
* @returns Connected supplier
|
|
2481
|
+
*
|
|
2482
|
+
* @example
|
|
2483
|
+
* ```typescript
|
|
2484
|
+
* const supplier = await client.connectDropshipSupplier({
|
|
2485
|
+
* code: "CJ_DROPSHIPPING",
|
|
2486
|
+
* apiKey: "your-api-key"
|
|
2487
|
+
* });
|
|
2488
|
+
* ```
|
|
2489
|
+
*/
|
|
2490
|
+
async connectDropshipSupplier(request) {
|
|
2491
|
+
return this.post("/api/marketplace/merchant/dropship/suppliers", request);
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
* Update dropship supplier settings
|
|
2495
|
+
*
|
|
2496
|
+
* @param supplierId - Supplier ID
|
|
2497
|
+
* @param request - Settings to update
|
|
2498
|
+
* @returns Updated supplier
|
|
2499
|
+
*/
|
|
2500
|
+
async updateDropshipSupplier(supplierId, request) {
|
|
2501
|
+
return this.put(`/api/marketplace/merchant/dropship/suppliers/${supplierId}`, request);
|
|
2502
|
+
}
|
|
2503
|
+
/**
|
|
2504
|
+
* Disconnect a dropship supplier
|
|
2505
|
+
*
|
|
2506
|
+
* @param supplierId - Supplier ID
|
|
2507
|
+
*/
|
|
2508
|
+
async disconnectDropshipSupplier(supplierId) {
|
|
2509
|
+
return this.delete(`/api/marketplace/merchant/dropship/suppliers/${supplierId}`);
|
|
2510
|
+
}
|
|
2511
|
+
/**
|
|
2512
|
+
* Search products from connected suppliers
|
|
2513
|
+
*
|
|
2514
|
+
* @param request - Search parameters
|
|
2515
|
+
* @returns Search results with pagination
|
|
2516
|
+
*
|
|
2517
|
+
* @example
|
|
2518
|
+
* ```typescript
|
|
2519
|
+
* const results = await client.searchDropshipProducts({
|
|
2520
|
+
* supplierId: "supplier_123",
|
|
2521
|
+
* query: "wireless headphones",
|
|
2522
|
+
* limit: 20
|
|
2523
|
+
* });
|
|
2524
|
+
* ```
|
|
2525
|
+
*/
|
|
2526
|
+
async searchDropshipProducts(request) {
|
|
2527
|
+
return this.post("/api/marketplace/merchant/dropship/search", request);
|
|
2528
|
+
}
|
|
2529
|
+
/**
|
|
2530
|
+
* Get dropship supplier categories
|
|
2531
|
+
*
|
|
2532
|
+
* @param supplierId - Supplier ID
|
|
2533
|
+
* @returns Category list
|
|
2534
|
+
*/
|
|
2535
|
+
async getDropshipCategories(supplierId) {
|
|
2536
|
+
return this.get(`/api/marketplace/merchant/dropship/categories?supplierId=${supplierId}`);
|
|
2537
|
+
}
|
|
2538
|
+
/**
|
|
2539
|
+
* Get detailed product info from supplier
|
|
2540
|
+
*
|
|
2541
|
+
* @param supplierId - Supplier ID
|
|
2542
|
+
* @param externalProductId - Supplier's product ID
|
|
2543
|
+
* @returns Product details with suggested pricing
|
|
2544
|
+
*/
|
|
2545
|
+
async getDropshipProductDetails(supplierId, externalProductId) {
|
|
2546
|
+
return this.get(
|
|
2547
|
+
`/api/marketplace/merchant/dropship/products/${encodeURIComponent(externalProductId)}?supplierId=${supplierId}`
|
|
2548
|
+
);
|
|
2549
|
+
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Import a product from supplier to your store
|
|
2552
|
+
*
|
|
2553
|
+
* @param request - Import parameters
|
|
2554
|
+
* @returns Created product IDs
|
|
2555
|
+
*
|
|
2556
|
+
* @example
|
|
2557
|
+
* ```typescript
|
|
2558
|
+
* const result = await client.importDropshipProduct({
|
|
2559
|
+
* supplierId: "supplier_123",
|
|
2560
|
+
* externalProductId: "ext_product_456",
|
|
2561
|
+
* priceUSDC: 29.99,
|
|
2562
|
+
* title: "Custom Title"
|
|
2563
|
+
* });
|
|
2564
|
+
* ```
|
|
2565
|
+
*/
|
|
2566
|
+
async importDropshipProduct(request) {
|
|
2567
|
+
return this.post("/api/marketplace/merchant/dropship/import", request);
|
|
2568
|
+
}
|
|
2569
|
+
/**
|
|
2570
|
+
* Bulk import products from supplier
|
|
2571
|
+
*
|
|
2572
|
+
* @param request - Bulk import parameters
|
|
2573
|
+
* @returns Import results
|
|
2574
|
+
*/
|
|
2575
|
+
async bulkImportDropshipProducts(request) {
|
|
2576
|
+
return this.post("/api/marketplace/merchant/dropship/import", request);
|
|
2577
|
+
}
|
|
2578
|
+
/**
|
|
2579
|
+
* List imported dropship products
|
|
2580
|
+
*
|
|
2581
|
+
* @param params - Filter parameters
|
|
2582
|
+
* @returns Imported products list
|
|
2583
|
+
*/
|
|
2584
|
+
async listDropshipProducts(params) {
|
|
2585
|
+
const query = params ? `?${buildQueryString(params)}` : "";
|
|
2586
|
+
return this.get(`/api/marketplace/merchant/dropship/import${query}`);
|
|
2587
|
+
}
|
|
2588
|
+
/**
|
|
2589
|
+
* List dropship order links
|
|
2590
|
+
*
|
|
2591
|
+
* @param params - Filter parameters
|
|
2592
|
+
* @returns Order links with status summary
|
|
2593
|
+
*/
|
|
2594
|
+
async listDropshipOrders(params) {
|
|
2595
|
+
let query = "";
|
|
2596
|
+
if (params) {
|
|
2597
|
+
const queryParams = {};
|
|
2598
|
+
if (params.status) {
|
|
2599
|
+
queryParams.status = Array.isArray(params.status) ? params.status.join(",") : params.status;
|
|
2600
|
+
}
|
|
2601
|
+
if (params.limit) queryParams.limit = params.limit.toString();
|
|
2602
|
+
if (params.offset) queryParams.offset = params.offset.toString();
|
|
2603
|
+
query = `?${buildQueryString(queryParams)}`;
|
|
2604
|
+
}
|
|
2605
|
+
return this.get(`/api/marketplace/merchant/dropship/orders${query}`);
|
|
2606
|
+
}
|
|
2607
|
+
/**
|
|
2608
|
+
* Forward orders to supplier
|
|
2609
|
+
*
|
|
2610
|
+
* @param orderItemIds - Order item IDs to forward
|
|
2611
|
+
* @returns Forward results
|
|
2612
|
+
*/
|
|
2613
|
+
async forwardDropshipOrders(orderItemIds) {
|
|
2614
|
+
return this.post("/api/marketplace/merchant/dropship/orders", {
|
|
2615
|
+
action: "forward",
|
|
2616
|
+
orderItemIds
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
* Sync tracking for all pending dropship orders
|
|
2621
|
+
*
|
|
2622
|
+
* @returns Sync results
|
|
2623
|
+
*/
|
|
2624
|
+
async syncDropshipTracking() {
|
|
2625
|
+
return this.post("/api/marketplace/merchant/dropship/orders", {
|
|
2626
|
+
action: "sync"
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
/**
|
|
2630
|
+
* Get order forwarding details for manual forwarding
|
|
2631
|
+
*
|
|
2632
|
+
* @param orderItemId - Order item ID
|
|
2633
|
+
* @returns Forwarding details
|
|
2634
|
+
*/
|
|
2635
|
+
async getDropshipOrderDetails(orderItemId) {
|
|
2636
|
+
return this.get(`/api/marketplace/merchant/dropship/orders/${orderItemId}/forward`);
|
|
2637
|
+
}
|
|
2638
|
+
/**
|
|
2639
|
+
* Forward a single order item to supplier
|
|
2640
|
+
*
|
|
2641
|
+
* @param orderItemId - Order item ID
|
|
2642
|
+
* @returns Forward result
|
|
2643
|
+
*/
|
|
2644
|
+
async forwardDropshipOrder(orderItemId) {
|
|
2645
|
+
return this.post(`/api/marketplace/merchant/dropship/orders/${orderItemId}/forward`, {});
|
|
2646
|
+
}
|
|
2647
|
+
/**
|
|
2648
|
+
* Get dropship settings
|
|
2649
|
+
*
|
|
2650
|
+
* @returns Merchant dropship settings
|
|
2651
|
+
*/
|
|
2652
|
+
async getDropshipSettings() {
|
|
2653
|
+
return this.get("/api/marketplace/merchant/dropship/settings");
|
|
2654
|
+
}
|
|
2655
|
+
/**
|
|
2656
|
+
* Update dropship settings
|
|
2657
|
+
*
|
|
2658
|
+
* @param request - Settings to update
|
|
2659
|
+
* @returns Updated settings
|
|
2660
|
+
*/
|
|
2661
|
+
async updateDropshipSettings(request) {
|
|
2662
|
+
return this.put("/api/marketplace/merchant/dropship/settings", request);
|
|
2663
|
+
}
|
|
2664
|
+
/**
|
|
2665
|
+
* Sync dropship products and/or orders
|
|
2666
|
+
*
|
|
2667
|
+
* @param type - Sync type (products, orders, all, single)
|
|
2668
|
+
* @param dropshipProductId - For single product sync
|
|
2669
|
+
* @returns Sync results
|
|
2670
|
+
*/
|
|
2671
|
+
async syncDropship(type, dropshipProductId) {
|
|
2672
|
+
return this.post("/api/marketplace/merchant/dropship/sync", {
|
|
2673
|
+
type,
|
|
2674
|
+
dropshipProductId
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2079
2677
|
};
|
|
2080
2678
|
|
|
2081
2679
|
// lib/ecommerce/types/enums.ts
|
|
@@ -2093,6 +2691,8 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
|
2093
2691
|
})(OrderStatus || {});
|
|
2094
2692
|
var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
|
|
2095
2693
|
PaymentMethod2["USDC_ESCROW"] = "USDC_ESCROW";
|
|
2694
|
+
PaymentMethod2["BASEDPAY"] = "BASEDPAY";
|
|
2695
|
+
PaymentMethod2["STRIPE"] = "STRIPE";
|
|
2096
2696
|
PaymentMethod2["POINTS"] = "POINTS";
|
|
2097
2697
|
return PaymentMethod2;
|
|
2098
2698
|
})(PaymentMethod || {});
|
|
@@ -2203,6 +2803,7 @@ var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
|
|
|
2203
2803
|
ProductSortBy2["PRICE_DESC"] = "price_desc";
|
|
2204
2804
|
ProductSortBy2["POPULAR"] = "popular";
|
|
2205
2805
|
ProductSortBy2["FEATURED"] = "featured";
|
|
2806
|
+
ProductSortBy2["NEARBY"] = "nearby";
|
|
2206
2807
|
return ProductSortBy2;
|
|
2207
2808
|
})(ProductSortBy || {});
|
|
2208
2809
|
var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
|
package/dist/ecommerce.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantEcommerceClient, MerchantStatus, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './chunk-
|
|
1
|
+
export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantEcommerceClient, MerchantStatus, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './chunk-NVL2HX2H.mjs';
|
|
2
2
|
import './chunk-4UEJOM6W.mjs';
|