@basedone/core 0.2.2 → 0.2.3
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-SKX4VGEN.mjs} +459 -1
- package/dist/ecommerce.d.mts +1014 -7
- package/dist/ecommerce.d.ts +1014 -7
- package/dist/ecommerce.js +459 -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 +466 -1
- package/dist/index.mjs +8 -2
- package/lib/ecommerce/client/base.ts +7 -1
- package/lib/ecommerce/client/customer.ts +58 -0
- package/lib/ecommerce/client/merchant.ts +783 -0
- package/lib/ecommerce/types/entities.ts +94 -0
- package/lib/ecommerce/types/enums.ts +5 -1
- package/lib/ecommerce/types/requests.ts +98 -0
- package/lib/ecommerce/types/responses.ts +148 -0
- package/lib/utils/formatter.ts +1 -1
- package/lib/utils/time.ts +24 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -42086,6 +42086,12 @@ function getLatestCompletedWeek(currentTimestamp, offset = 0, weekStartsOn = 4 /
|
|
|
42086
42086
|
const weekNumber = Math.round(msSinceWeek1 / WEEK_IN_MS) + 1;
|
|
42087
42087
|
return { weekNumber, startDate, endDate };
|
|
42088
42088
|
}
|
|
42089
|
+
function getWeekInfoFromNumber(weekNumber, weekStartsOn = 4 /* Thursday */) {
|
|
42090
|
+
const week1StartDate = new Date(process.env.WEEK1_START_DATE || "2025-12-04T00:00:00Z");
|
|
42091
|
+
const startDate = new Date(week1StartDate.getTime() + (weekNumber - 1) * WEEK_IN_MS);
|
|
42092
|
+
const endDate = new Date(startDate.getTime() + WEEK_IN_MS);
|
|
42093
|
+
return { weekNumber, startDate, endDate };
|
|
42094
|
+
}
|
|
42089
42095
|
|
|
42090
42096
|
// lib/hip3/market-info.ts
|
|
42091
42097
|
async function getAllPerpsMeta(infoClient) {
|
|
@@ -42460,11 +42466,13 @@ var BaseEcommerceClient = class {
|
|
|
42460
42466
|
maxRetries: config.maxRetries || 3,
|
|
42461
42467
|
retryBaseDelay: config.retryBaseDelay || 1e3,
|
|
42462
42468
|
headers: config.headers,
|
|
42463
|
-
enableRetry: config.enableRetry !== false
|
|
42469
|
+
enableRetry: config.enableRetry !== false,
|
|
42470
|
+
withCredentials: config.withCredentials || false
|
|
42464
42471
|
};
|
|
42465
42472
|
this.axiosInstance = axios__default.default.create({
|
|
42466
42473
|
baseURL: this.config.baseURL,
|
|
42467
42474
|
timeout: this.config.timeout,
|
|
42475
|
+
withCredentials: this.config.withCredentials,
|
|
42468
42476
|
headers: {
|
|
42469
42477
|
"Content-Type": "application/json",
|
|
42470
42478
|
...this.config.headers
|
|
@@ -43008,6 +43016,34 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43008
43016
|
return this.post("/api/marketplace/tax/calculate", request);
|
|
43009
43017
|
}
|
|
43010
43018
|
// ============================================================================
|
|
43019
|
+
// Shipping Calculation API
|
|
43020
|
+
// ============================================================================
|
|
43021
|
+
/**
|
|
43022
|
+
* Calculate shipping options for cart items
|
|
43023
|
+
*
|
|
43024
|
+
* @param request - Cart items, merchant, and destination
|
|
43025
|
+
* @returns Available shipping options with costs
|
|
43026
|
+
*
|
|
43027
|
+
* @example
|
|
43028
|
+
* ```typescript
|
|
43029
|
+
* const result = await client.calculateShippingOptions({
|
|
43030
|
+
* merchantId: "merchant_123",
|
|
43031
|
+
* cartItems: [
|
|
43032
|
+
* { productId: "prod_123", quantity: 2 }
|
|
43033
|
+
* ],
|
|
43034
|
+
* destinationCountry: "US",
|
|
43035
|
+
* orderSubtotal: 99.99
|
|
43036
|
+
* });
|
|
43037
|
+
*
|
|
43038
|
+
* result.shippingOptions.forEach(opt => {
|
|
43039
|
+
* console.log(opt.name, opt.cost, opt.estimatedDelivery);
|
|
43040
|
+
* });
|
|
43041
|
+
* ```
|
|
43042
|
+
*/
|
|
43043
|
+
async calculateShippingOptions(request) {
|
|
43044
|
+
return this.post("/api/marketplace/shipping/calculate", request);
|
|
43045
|
+
}
|
|
43046
|
+
// ============================================================================
|
|
43011
43047
|
// Banners API
|
|
43012
43048
|
// ============================================================================
|
|
43013
43049
|
/**
|
|
@@ -43265,6 +43301,29 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43265
43301
|
const queryString = params ? buildQueryString(params) : "";
|
|
43266
43302
|
return this.get(`/api/marketplace/following${queryString}`);
|
|
43267
43303
|
}
|
|
43304
|
+
// ============================================================================
|
|
43305
|
+
// Payment Methods
|
|
43306
|
+
// ============================================================================
|
|
43307
|
+
/**
|
|
43308
|
+
* Get available payment methods
|
|
43309
|
+
*
|
|
43310
|
+
* Returns the list of enabled payment methods that can be used during checkout.
|
|
43311
|
+
*
|
|
43312
|
+
* @returns List of available payment methods with display info
|
|
43313
|
+
*
|
|
43314
|
+
* @example
|
|
43315
|
+
* ```typescript
|
|
43316
|
+
* const result = await client.getPaymentMethods();
|
|
43317
|
+
* if (result.paymentsEnabled) {
|
|
43318
|
+
* result.methods.forEach(method => {
|
|
43319
|
+
* console.log(`${method.name}: ${method.description}`);
|
|
43320
|
+
* });
|
|
43321
|
+
* }
|
|
43322
|
+
* ```
|
|
43323
|
+
*/
|
|
43324
|
+
async getPaymentMethods() {
|
|
43325
|
+
return this.get("/api/marketplace/payments/methods");
|
|
43326
|
+
}
|
|
43268
43327
|
};
|
|
43269
43328
|
|
|
43270
43329
|
// lib/ecommerce/client/merchant.ts
|
|
@@ -43799,6 +43858,192 @@ var MerchantEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43799
43858
|
return this.patch(`/api/marketplace/merchant/shipping/shipments/${shipmentId}`, request);
|
|
43800
43859
|
}
|
|
43801
43860
|
// ============================================================================
|
|
43861
|
+
// Shipping Settings (Zones & Rates)
|
|
43862
|
+
// ============================================================================
|
|
43863
|
+
/**
|
|
43864
|
+
* Get merchant shipping settings
|
|
43865
|
+
*
|
|
43866
|
+
* @returns Shipping settings
|
|
43867
|
+
*
|
|
43868
|
+
* @example
|
|
43869
|
+
* ```typescript
|
|
43870
|
+
* const { settings } = await client.getShippingSettings();
|
|
43871
|
+
* console.log("Handling fee:", settings.defaultHandlingFee);
|
|
43872
|
+
* ```
|
|
43873
|
+
*/
|
|
43874
|
+
async getShippingSettings() {
|
|
43875
|
+
return this.get("/api/marketplace/merchant/shipping/settings");
|
|
43876
|
+
}
|
|
43877
|
+
/**
|
|
43878
|
+
* Update merchant shipping settings
|
|
43879
|
+
*
|
|
43880
|
+
* @param request - Settings to update
|
|
43881
|
+
* @returns Updated settings
|
|
43882
|
+
*
|
|
43883
|
+
* @example
|
|
43884
|
+
* ```typescript
|
|
43885
|
+
* await client.updateShippingSettings({
|
|
43886
|
+
* defaultHandlingFee: 2.50,
|
|
43887
|
+
* freeShippingEnabled: true,
|
|
43888
|
+
* freeShippingThreshold: 100
|
|
43889
|
+
* });
|
|
43890
|
+
* ```
|
|
43891
|
+
*/
|
|
43892
|
+
async updateShippingSettings(request) {
|
|
43893
|
+
return this.post("/api/marketplace/merchant/shipping/settings", request);
|
|
43894
|
+
}
|
|
43895
|
+
/**
|
|
43896
|
+
* List all shipping zones
|
|
43897
|
+
*
|
|
43898
|
+
* @returns List of shipping zones with rate counts
|
|
43899
|
+
*
|
|
43900
|
+
* @example
|
|
43901
|
+
* ```typescript
|
|
43902
|
+
* const { zones } = await client.listShippingZones();
|
|
43903
|
+
* zones.forEach(z => console.log(z.name, z.countries.length, "countries"));
|
|
43904
|
+
* ```
|
|
43905
|
+
*/
|
|
43906
|
+
async listShippingZones() {
|
|
43907
|
+
return this.get("/api/marketplace/merchant/shipping/zones");
|
|
43908
|
+
}
|
|
43909
|
+
/**
|
|
43910
|
+
* Get a shipping zone by ID
|
|
43911
|
+
*
|
|
43912
|
+
* @param zoneId - Zone ID
|
|
43913
|
+
* @returns Zone with rates
|
|
43914
|
+
*
|
|
43915
|
+
* @example
|
|
43916
|
+
* ```typescript
|
|
43917
|
+
* const { zone } = await client.getShippingZone("zone_123");
|
|
43918
|
+
* console.log(zone.name, zone.rates?.length, "rates");
|
|
43919
|
+
* ```
|
|
43920
|
+
*/
|
|
43921
|
+
async getShippingZone(zoneId) {
|
|
43922
|
+
return this.get(`/api/marketplace/merchant/shipping/zones/${zoneId}`);
|
|
43923
|
+
}
|
|
43924
|
+
/**
|
|
43925
|
+
* Create a shipping zone
|
|
43926
|
+
*
|
|
43927
|
+
* @param request - Zone data
|
|
43928
|
+
* @returns Created zone
|
|
43929
|
+
*
|
|
43930
|
+
* @example
|
|
43931
|
+
* ```typescript
|
|
43932
|
+
* const { zone } = await client.createShippingZone({
|
|
43933
|
+
* name: "Southeast Asia",
|
|
43934
|
+
* countries: ["SG", "MY", "TH", "ID", "PH", "VN"],
|
|
43935
|
+
* isDefault: false,
|
|
43936
|
+
* priority: 10
|
|
43937
|
+
* });
|
|
43938
|
+
* ```
|
|
43939
|
+
*/
|
|
43940
|
+
async createShippingZone(request) {
|
|
43941
|
+
return this.post("/api/marketplace/merchant/shipping/zones", request);
|
|
43942
|
+
}
|
|
43943
|
+
/**
|
|
43944
|
+
* Update a shipping zone
|
|
43945
|
+
*
|
|
43946
|
+
* @param zoneId - Zone ID
|
|
43947
|
+
* @param request - Updated zone data
|
|
43948
|
+
* @returns Updated zone
|
|
43949
|
+
*
|
|
43950
|
+
* @example
|
|
43951
|
+
* ```typescript
|
|
43952
|
+
* await client.updateShippingZone("zone_123", {
|
|
43953
|
+
* countries: ["SG", "MY", "TH", "ID", "PH", "VN", "BN"]
|
|
43954
|
+
* });
|
|
43955
|
+
* ```
|
|
43956
|
+
*/
|
|
43957
|
+
async updateShippingZone(zoneId, request) {
|
|
43958
|
+
return this.put(`/api/marketplace/merchant/shipping/zones/${zoneId}`, request);
|
|
43959
|
+
}
|
|
43960
|
+
/**
|
|
43961
|
+
* Delete a shipping zone
|
|
43962
|
+
*
|
|
43963
|
+
* @param zoneId - Zone ID
|
|
43964
|
+
* @returns Success response
|
|
43965
|
+
*
|
|
43966
|
+
* @example
|
|
43967
|
+
* ```typescript
|
|
43968
|
+
* await client.deleteShippingZone("zone_123");
|
|
43969
|
+
* ```
|
|
43970
|
+
*/
|
|
43971
|
+
async deleteShippingZone(zoneId) {
|
|
43972
|
+
return this.delete(`/api/marketplace/merchant/shipping/zones/${zoneId}`);
|
|
43973
|
+
}
|
|
43974
|
+
/**
|
|
43975
|
+
* List shipping rates
|
|
43976
|
+
*
|
|
43977
|
+
* @param zoneId - Optional zone ID to filter by
|
|
43978
|
+
* @returns List of shipping rates
|
|
43979
|
+
*
|
|
43980
|
+
* @example
|
|
43981
|
+
* ```typescript
|
|
43982
|
+
* // All rates
|
|
43983
|
+
* const { rates } = await client.listShippingRates();
|
|
43984
|
+
*
|
|
43985
|
+
* // Rates for a specific zone
|
|
43986
|
+
* const { rates: zoneRates } = await client.listShippingRates("zone_123");
|
|
43987
|
+
* ```
|
|
43988
|
+
*/
|
|
43989
|
+
async listShippingRates(zoneId) {
|
|
43990
|
+
const query = zoneId ? `?zoneId=${zoneId}` : "";
|
|
43991
|
+
return this.get(`/api/marketplace/merchant/shipping/rates${query}`);
|
|
43992
|
+
}
|
|
43993
|
+
/**
|
|
43994
|
+
* Create a shipping rate
|
|
43995
|
+
*
|
|
43996
|
+
* @param request - Rate data
|
|
43997
|
+
* @returns Created rate
|
|
43998
|
+
*
|
|
43999
|
+
* @example
|
|
44000
|
+
* ```typescript
|
|
44001
|
+
* const { rate } = await client.createShippingRate({
|
|
44002
|
+
* zoneId: "zone_123",
|
|
44003
|
+
* name: "Standard Shipping",
|
|
44004
|
+
* baseRate: 5.00,
|
|
44005
|
+
* perKgRate: 1.50,
|
|
44006
|
+
* minDeliveryDays: 7,
|
|
44007
|
+
* maxDeliveryDays: 14
|
|
44008
|
+
* });
|
|
44009
|
+
* ```
|
|
44010
|
+
*/
|
|
44011
|
+
async createShippingRate(request) {
|
|
44012
|
+
return this.post("/api/marketplace/merchant/shipping/rates", request);
|
|
44013
|
+
}
|
|
44014
|
+
/**
|
|
44015
|
+
* Update a shipping rate
|
|
44016
|
+
*
|
|
44017
|
+
* @param rateId - Rate ID
|
|
44018
|
+
* @param request - Updated rate data
|
|
44019
|
+
* @returns Updated rate
|
|
44020
|
+
*
|
|
44021
|
+
* @example
|
|
44022
|
+
* ```typescript
|
|
44023
|
+
* await client.updateShippingRate("rate_123", {
|
|
44024
|
+
* baseRate: 6.00,
|
|
44025
|
+
* freeAboveAmount: 75
|
|
44026
|
+
* });
|
|
44027
|
+
* ```
|
|
44028
|
+
*/
|
|
44029
|
+
async updateShippingRate(rateId, request) {
|
|
44030
|
+
return this.put(`/api/marketplace/merchant/shipping/rates/${rateId}`, request);
|
|
44031
|
+
}
|
|
44032
|
+
/**
|
|
44033
|
+
* Delete a shipping rate
|
|
44034
|
+
*
|
|
44035
|
+
* @param rateId - Rate ID
|
|
44036
|
+
* @returns Success response
|
|
44037
|
+
*
|
|
44038
|
+
* @example
|
|
44039
|
+
* ```typescript
|
|
44040
|
+
* await client.deleteShippingRate("rate_123");
|
|
44041
|
+
* ```
|
|
44042
|
+
*/
|
|
44043
|
+
async deleteShippingRate(rateId) {
|
|
44044
|
+
return this.delete(`/api/marketplace/merchant/shipping/rates/${rateId}`);
|
|
44045
|
+
}
|
|
44046
|
+
// ============================================================================
|
|
43802
44047
|
// Returns & Refunds
|
|
43803
44048
|
// ============================================================================
|
|
43804
44049
|
/**
|
|
@@ -44396,6 +44641,223 @@ var MerchantEcommerceClient = class extends BaseEcommerceClient {
|
|
|
44396
44641
|
async exportTaxReport(reportId) {
|
|
44397
44642
|
return this.get(`/api/marketplace/merchant/tax-reports/${reportId}/export`);
|
|
44398
44643
|
}
|
|
44644
|
+
// ============================================
|
|
44645
|
+
// DROPSHIPPING APIs
|
|
44646
|
+
// ============================================
|
|
44647
|
+
/**
|
|
44648
|
+
* List connected dropship suppliers
|
|
44649
|
+
*
|
|
44650
|
+
* @returns Connected and available suppliers
|
|
44651
|
+
*
|
|
44652
|
+
* @example
|
|
44653
|
+
* ```typescript
|
|
44654
|
+
* const { connected, available } = await client.listDropshipSuppliers();
|
|
44655
|
+
* ```
|
|
44656
|
+
*/
|
|
44657
|
+
async listDropshipSuppliers() {
|
|
44658
|
+
return this.get("/api/marketplace/merchant/dropship/suppliers");
|
|
44659
|
+
}
|
|
44660
|
+
/**
|
|
44661
|
+
* Connect a new dropship supplier
|
|
44662
|
+
*
|
|
44663
|
+
* @param request - Supplier credentials
|
|
44664
|
+
* @returns Connected supplier
|
|
44665
|
+
*
|
|
44666
|
+
* @example
|
|
44667
|
+
* ```typescript
|
|
44668
|
+
* const supplier = await client.connectDropshipSupplier({
|
|
44669
|
+
* code: "CJ_DROPSHIPPING",
|
|
44670
|
+
* apiKey: "your-api-key"
|
|
44671
|
+
* });
|
|
44672
|
+
* ```
|
|
44673
|
+
*/
|
|
44674
|
+
async connectDropshipSupplier(request) {
|
|
44675
|
+
return this.post("/api/marketplace/merchant/dropship/suppliers", request);
|
|
44676
|
+
}
|
|
44677
|
+
/**
|
|
44678
|
+
* Update dropship supplier settings
|
|
44679
|
+
*
|
|
44680
|
+
* @param supplierId - Supplier ID
|
|
44681
|
+
* @param request - Settings to update
|
|
44682
|
+
* @returns Updated supplier
|
|
44683
|
+
*/
|
|
44684
|
+
async updateDropshipSupplier(supplierId, request) {
|
|
44685
|
+
return this.put(`/api/marketplace/merchant/dropship/suppliers/${supplierId}`, request);
|
|
44686
|
+
}
|
|
44687
|
+
/**
|
|
44688
|
+
* Disconnect a dropship supplier
|
|
44689
|
+
*
|
|
44690
|
+
* @param supplierId - Supplier ID
|
|
44691
|
+
*/
|
|
44692
|
+
async disconnectDropshipSupplier(supplierId) {
|
|
44693
|
+
return this.delete(`/api/marketplace/merchant/dropship/suppliers/${supplierId}`);
|
|
44694
|
+
}
|
|
44695
|
+
/**
|
|
44696
|
+
* Search products from connected suppliers
|
|
44697
|
+
*
|
|
44698
|
+
* @param request - Search parameters
|
|
44699
|
+
* @returns Search results with pagination
|
|
44700
|
+
*
|
|
44701
|
+
* @example
|
|
44702
|
+
* ```typescript
|
|
44703
|
+
* const results = await client.searchDropshipProducts({
|
|
44704
|
+
* supplierId: "supplier_123",
|
|
44705
|
+
* query: "wireless headphones",
|
|
44706
|
+
* limit: 20
|
|
44707
|
+
* });
|
|
44708
|
+
* ```
|
|
44709
|
+
*/
|
|
44710
|
+
async searchDropshipProducts(request) {
|
|
44711
|
+
return this.post("/api/marketplace/merchant/dropship/search", request);
|
|
44712
|
+
}
|
|
44713
|
+
/**
|
|
44714
|
+
* Get dropship supplier categories
|
|
44715
|
+
*
|
|
44716
|
+
* @param supplierId - Supplier ID
|
|
44717
|
+
* @returns Category list
|
|
44718
|
+
*/
|
|
44719
|
+
async getDropshipCategories(supplierId) {
|
|
44720
|
+
return this.get(`/api/marketplace/merchant/dropship/categories?supplierId=${supplierId}`);
|
|
44721
|
+
}
|
|
44722
|
+
/**
|
|
44723
|
+
* Get detailed product info from supplier
|
|
44724
|
+
*
|
|
44725
|
+
* @param supplierId - Supplier ID
|
|
44726
|
+
* @param externalProductId - Supplier's product ID
|
|
44727
|
+
* @returns Product details with suggested pricing
|
|
44728
|
+
*/
|
|
44729
|
+
async getDropshipProductDetails(supplierId, externalProductId) {
|
|
44730
|
+
return this.get(
|
|
44731
|
+
`/api/marketplace/merchant/dropship/products/${encodeURIComponent(externalProductId)}?supplierId=${supplierId}`
|
|
44732
|
+
);
|
|
44733
|
+
}
|
|
44734
|
+
/**
|
|
44735
|
+
* Import a product from supplier to your store
|
|
44736
|
+
*
|
|
44737
|
+
* @param request - Import parameters
|
|
44738
|
+
* @returns Created product IDs
|
|
44739
|
+
*
|
|
44740
|
+
* @example
|
|
44741
|
+
* ```typescript
|
|
44742
|
+
* const result = await client.importDropshipProduct({
|
|
44743
|
+
* supplierId: "supplier_123",
|
|
44744
|
+
* externalProductId: "ext_product_456",
|
|
44745
|
+
* priceUSDC: 29.99,
|
|
44746
|
+
* title: "Custom Title"
|
|
44747
|
+
* });
|
|
44748
|
+
* ```
|
|
44749
|
+
*/
|
|
44750
|
+
async importDropshipProduct(request) {
|
|
44751
|
+
return this.post("/api/marketplace/merchant/dropship/import", request);
|
|
44752
|
+
}
|
|
44753
|
+
/**
|
|
44754
|
+
* Bulk import products from supplier
|
|
44755
|
+
*
|
|
44756
|
+
* @param request - Bulk import parameters
|
|
44757
|
+
* @returns Import results
|
|
44758
|
+
*/
|
|
44759
|
+
async bulkImportDropshipProducts(request) {
|
|
44760
|
+
return this.post("/api/marketplace/merchant/dropship/import", request);
|
|
44761
|
+
}
|
|
44762
|
+
/**
|
|
44763
|
+
* List imported dropship products
|
|
44764
|
+
*
|
|
44765
|
+
* @param params - Filter parameters
|
|
44766
|
+
* @returns Imported products list
|
|
44767
|
+
*/
|
|
44768
|
+
async listDropshipProducts(params) {
|
|
44769
|
+
const query = params ? `?${buildQueryString(params)}` : "";
|
|
44770
|
+
return this.get(`/api/marketplace/merchant/dropship/import${query}`);
|
|
44771
|
+
}
|
|
44772
|
+
/**
|
|
44773
|
+
* List dropship order links
|
|
44774
|
+
*
|
|
44775
|
+
* @param params - Filter parameters
|
|
44776
|
+
* @returns Order links with status summary
|
|
44777
|
+
*/
|
|
44778
|
+
async listDropshipOrders(params) {
|
|
44779
|
+
let query = "";
|
|
44780
|
+
if (params) {
|
|
44781
|
+
const queryParams = {};
|
|
44782
|
+
if (params.status) {
|
|
44783
|
+
queryParams.status = Array.isArray(params.status) ? params.status.join(",") : params.status;
|
|
44784
|
+
}
|
|
44785
|
+
if (params.limit) queryParams.limit = params.limit.toString();
|
|
44786
|
+
if (params.offset) queryParams.offset = params.offset.toString();
|
|
44787
|
+
query = `?${buildQueryString(queryParams)}`;
|
|
44788
|
+
}
|
|
44789
|
+
return this.get(`/api/marketplace/merchant/dropship/orders${query}`);
|
|
44790
|
+
}
|
|
44791
|
+
/**
|
|
44792
|
+
* Forward orders to supplier
|
|
44793
|
+
*
|
|
44794
|
+
* @param orderItemIds - Order item IDs to forward
|
|
44795
|
+
* @returns Forward results
|
|
44796
|
+
*/
|
|
44797
|
+
async forwardDropshipOrders(orderItemIds) {
|
|
44798
|
+
return this.post("/api/marketplace/merchant/dropship/orders", {
|
|
44799
|
+
action: "forward",
|
|
44800
|
+
orderItemIds
|
|
44801
|
+
});
|
|
44802
|
+
}
|
|
44803
|
+
/**
|
|
44804
|
+
* Sync tracking for all pending dropship orders
|
|
44805
|
+
*
|
|
44806
|
+
* @returns Sync results
|
|
44807
|
+
*/
|
|
44808
|
+
async syncDropshipTracking() {
|
|
44809
|
+
return this.post("/api/marketplace/merchant/dropship/orders", {
|
|
44810
|
+
action: "sync"
|
|
44811
|
+
});
|
|
44812
|
+
}
|
|
44813
|
+
/**
|
|
44814
|
+
* Get order forwarding details for manual forwarding
|
|
44815
|
+
*
|
|
44816
|
+
* @param orderItemId - Order item ID
|
|
44817
|
+
* @returns Forwarding details
|
|
44818
|
+
*/
|
|
44819
|
+
async getDropshipOrderDetails(orderItemId) {
|
|
44820
|
+
return this.get(`/api/marketplace/merchant/dropship/orders/${orderItemId}/forward`);
|
|
44821
|
+
}
|
|
44822
|
+
/**
|
|
44823
|
+
* Forward a single order item to supplier
|
|
44824
|
+
*
|
|
44825
|
+
* @param orderItemId - Order item ID
|
|
44826
|
+
* @returns Forward result
|
|
44827
|
+
*/
|
|
44828
|
+
async forwardDropshipOrder(orderItemId) {
|
|
44829
|
+
return this.post(`/api/marketplace/merchant/dropship/orders/${orderItemId}/forward`, {});
|
|
44830
|
+
}
|
|
44831
|
+
/**
|
|
44832
|
+
* Get dropship settings
|
|
44833
|
+
*
|
|
44834
|
+
* @returns Merchant dropship settings
|
|
44835
|
+
*/
|
|
44836
|
+
async getDropshipSettings() {
|
|
44837
|
+
return this.get("/api/marketplace/merchant/dropship/settings");
|
|
44838
|
+
}
|
|
44839
|
+
/**
|
|
44840
|
+
* Update dropship settings
|
|
44841
|
+
*
|
|
44842
|
+
* @param request - Settings to update
|
|
44843
|
+
* @returns Updated settings
|
|
44844
|
+
*/
|
|
44845
|
+
async updateDropshipSettings(request) {
|
|
44846
|
+
return this.put("/api/marketplace/merchant/dropship/settings", request);
|
|
44847
|
+
}
|
|
44848
|
+
/**
|
|
44849
|
+
* Sync dropship products and/or orders
|
|
44850
|
+
*
|
|
44851
|
+
* @param type - Sync type (products, orders, all, single)
|
|
44852
|
+
* @param dropshipProductId - For single product sync
|
|
44853
|
+
* @returns Sync results
|
|
44854
|
+
*/
|
|
44855
|
+
async syncDropship(type, dropshipProductId) {
|
|
44856
|
+
return this.post("/api/marketplace/merchant/dropship/sync", {
|
|
44857
|
+
type,
|
|
44858
|
+
dropshipProductId
|
|
44859
|
+
});
|
|
44860
|
+
}
|
|
44399
44861
|
};
|
|
44400
44862
|
|
|
44401
44863
|
// lib/ecommerce/types/enums.ts
|
|
@@ -44413,6 +44875,8 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
|
44413
44875
|
})(OrderStatus || {});
|
|
44414
44876
|
var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
|
|
44415
44877
|
PaymentMethod2["USDC_ESCROW"] = "USDC_ESCROW";
|
|
44878
|
+
PaymentMethod2["BASEDPAY"] = "BASEDPAY";
|
|
44879
|
+
PaymentMethod2["STRIPE"] = "STRIPE";
|
|
44416
44880
|
PaymentMethod2["POINTS"] = "POINTS";
|
|
44417
44881
|
return PaymentMethod2;
|
|
44418
44882
|
})(PaymentMethod || {});
|
|
@@ -44605,6 +45069,7 @@ exports.getNextTierInfo = getNextTierInfo;
|
|
|
44605
45069
|
exports.getPriceDecimals = getPriceDecimals;
|
|
44606
45070
|
exports.getStaticCollateralTokenByDex = getStaticCollateralTokenByDex;
|
|
44607
45071
|
exports.getStaticCollateralTokenSymbol = getStaticCollateralTokenSymbol;
|
|
45072
|
+
exports.getWeekInfoFromNumber = getWeekInfoFromNumber;
|
|
44608
45073
|
exports.getWidgetTypeById = getWidgetTypeById;
|
|
44609
45074
|
exports.isBasedCloid = isBasedCloid;
|
|
44610
45075
|
exports.isClientCode = isClientCode;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-SKX4VGEN.mjs';
|
|
2
2
|
export { AssetIdUtils, InstrumentClient } from './chunk-VBC6EQ7Q.mjs';
|
|
3
3
|
import { __glob } from './chunk-4UEJOM6W.mjs';
|
|
4
4
|
import Decimal, { Decimal as Decimal$1 } from 'decimal.js';
|
|
@@ -1297,6 +1297,12 @@ function getLatestCompletedWeek(currentTimestamp, offset = 0, weekStartsOn = 4 /
|
|
|
1297
1297
|
const weekNumber = Math.round(msSinceWeek1 / WEEK_IN_MS) + 1;
|
|
1298
1298
|
return { weekNumber, startDate, endDate };
|
|
1299
1299
|
}
|
|
1300
|
+
function getWeekInfoFromNumber(weekNumber, weekStartsOn = 4 /* Thursday */) {
|
|
1301
|
+
const week1StartDate = new Date(process.env.WEEK1_START_DATE || "2025-12-04T00:00:00Z");
|
|
1302
|
+
const startDate = new Date(week1StartDate.getTime() + (weekNumber - 1) * WEEK_IN_MS);
|
|
1303
|
+
const endDate = new Date(startDate.getTime() + WEEK_IN_MS);
|
|
1304
|
+
return { weekNumber, startDate, endDate };
|
|
1305
|
+
}
|
|
1300
1306
|
|
|
1301
1307
|
// lib/hip3/market-info.ts
|
|
1302
1308
|
async function getAllPerpsMeta(infoClient) {
|
|
@@ -1305,4 +1311,4 @@ async function getAllPerpsMeta(infoClient) {
|
|
|
1305
1311
|
});
|
|
1306
1312
|
}
|
|
1307
1313
|
|
|
1308
|
-
export { CloidClientCode, CloidClientCodeNameById, DayOfWeek, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, USDC_SPOT_TOKEN, UserDexAbstractionTypes, WidgetType, WidgetTypeById, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getAllPerpsMeta, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };
|
|
1314
|
+
export { CloidClientCode, CloidClientCodeNameById, DayOfWeek, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, USDC_SPOT_TOKEN, UserDexAbstractionTypes, WidgetType, WidgetTypeById, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getAllPerpsMeta, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWeekInfoFromNumber, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };
|
|
@@ -33,6 +33,9 @@ export interface EcommerceClientConfig {
|
|
|
33
33
|
|
|
34
34
|
/** Enable automatic retry on retryable errors */
|
|
35
35
|
enableRetry?: boolean;
|
|
36
|
+
|
|
37
|
+
/** Whether to send cookies with requests */
|
|
38
|
+
withCredentials?: boolean;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
@@ -55,9 +58,10 @@ export interface EcommerceClientConfig {
|
|
|
55
58
|
*/
|
|
56
59
|
export class BaseEcommerceClient {
|
|
57
60
|
private axiosInstance: AxiosInstance;
|
|
58
|
-
private config: Required<Omit<EcommerceClientConfig, "authToken" | "headers">> & {
|
|
61
|
+
private config: Required<Omit<EcommerceClientConfig, "authToken" | "headers" | "withCredentials">> & {
|
|
59
62
|
authToken?: string;
|
|
60
63
|
headers?: Record<string, string>;
|
|
64
|
+
withCredentials?: boolean;
|
|
61
65
|
};
|
|
62
66
|
|
|
63
67
|
constructor(config: EcommerceClientConfig) {
|
|
@@ -69,11 +73,13 @@ export class BaseEcommerceClient {
|
|
|
69
73
|
retryBaseDelay: config.retryBaseDelay || 1000,
|
|
70
74
|
headers: config.headers,
|
|
71
75
|
enableRetry: config.enableRetry !== false,
|
|
76
|
+
withCredentials: config.withCredentials || false,
|
|
72
77
|
};
|
|
73
78
|
|
|
74
79
|
this.axiosInstance = axios.create({
|
|
75
80
|
baseURL: this.config.baseURL,
|
|
76
81
|
timeout: this.config.timeout,
|
|
82
|
+
withCredentials: this.config.withCredentials,
|
|
77
83
|
headers: {
|
|
78
84
|
"Content-Type": "application/json",
|
|
79
85
|
...this.config.headers,
|
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
ListActiveFlashSalesParams,
|
|
25
25
|
ListMerchantProductsParams,
|
|
26
26
|
ListFollowingParams,
|
|
27
|
+
CalculateShippingRequest,
|
|
27
28
|
|
|
28
29
|
// Response types
|
|
29
30
|
ListProductsResponse,
|
|
@@ -47,11 +48,13 @@ import type {
|
|
|
47
48
|
MessageStatsResponse,
|
|
48
49
|
MessageResponse,
|
|
49
50
|
ActiveFlashSalesResponse,
|
|
51
|
+
GetPaymentMethodsResponse,
|
|
50
52
|
PublicMerchantProfileResponse,
|
|
51
53
|
MerchantProductsResponse,
|
|
52
54
|
FollowStatusResponse,
|
|
53
55
|
FollowActionResponse,
|
|
54
56
|
ListFollowingResponse,
|
|
57
|
+
CalculateShippingResponse,
|
|
55
58
|
} from "../types";
|
|
56
59
|
|
|
57
60
|
/**
|
|
@@ -488,6 +491,36 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
488
491
|
async calculateTax(request: CalculateTaxRequest): Promise<CalculateTaxResponse> {
|
|
489
492
|
return this.post("/api/marketplace/tax/calculate", request);
|
|
490
493
|
}
|
|
494
|
+
|
|
495
|
+
// ============================================================================
|
|
496
|
+
// Shipping Calculation API
|
|
497
|
+
// ============================================================================
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Calculate shipping options for cart items
|
|
501
|
+
*
|
|
502
|
+
* @param request - Cart items, merchant, and destination
|
|
503
|
+
* @returns Available shipping options with costs
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* ```typescript
|
|
507
|
+
* const result = await client.calculateShippingOptions({
|
|
508
|
+
* merchantId: "merchant_123",
|
|
509
|
+
* cartItems: [
|
|
510
|
+
* { productId: "prod_123", quantity: 2 }
|
|
511
|
+
* ],
|
|
512
|
+
* destinationCountry: "US",
|
|
513
|
+
* orderSubtotal: 99.99
|
|
514
|
+
* });
|
|
515
|
+
*
|
|
516
|
+
* result.shippingOptions.forEach(opt => {
|
|
517
|
+
* console.log(opt.name, opt.cost, opt.estimatedDelivery);
|
|
518
|
+
* });
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
async calculateShippingOptions(request: CalculateShippingRequest): Promise<CalculateShippingResponse> {
|
|
522
|
+
return this.post("/api/marketplace/shipping/calculate", request);
|
|
523
|
+
}
|
|
491
524
|
|
|
492
525
|
// ============================================================================
|
|
493
526
|
// Banners API
|
|
@@ -767,5 +800,30 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
767
800
|
const queryString = params ? buildQueryString(params) : "";
|
|
768
801
|
return this.get(`/api/marketplace/following${queryString}`);
|
|
769
802
|
}
|
|
803
|
+
|
|
804
|
+
// ============================================================================
|
|
805
|
+
// Payment Methods
|
|
806
|
+
// ============================================================================
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Get available payment methods
|
|
810
|
+
*
|
|
811
|
+
* Returns the list of enabled payment methods that can be used during checkout.
|
|
812
|
+
*
|
|
813
|
+
* @returns List of available payment methods with display info
|
|
814
|
+
*
|
|
815
|
+
* @example
|
|
816
|
+
* ```typescript
|
|
817
|
+
* const result = await client.getPaymentMethods();
|
|
818
|
+
* if (result.paymentsEnabled) {
|
|
819
|
+
* result.methods.forEach(method => {
|
|
820
|
+
* console.log(`${method.name}: ${method.description}`);
|
|
821
|
+
* });
|
|
822
|
+
* }
|
|
823
|
+
* ```
|
|
824
|
+
*/
|
|
825
|
+
async getPaymentMethods(): Promise<GetPaymentMethodsResponse> {
|
|
826
|
+
return this.get("/api/marketplace/payments/methods");
|
|
827
|
+
}
|
|
770
828
|
}
|
|
771
829
|
|