@basedone/core 0.2.4 → 0.2.6
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-NVL2HX2H.mjs → chunk-CAU4QLVH.mjs} +47 -0
- package/dist/ecommerce.d.mts +111 -13
- package/dist/ecommerce.d.ts +111 -13
- package/dist/ecommerce.js +47 -0
- package/dist/ecommerce.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +47 -0
- package/dist/index.mjs +1 -1
- package/lib/ecommerce/client/customer.ts +50 -0
- package/lib/ecommerce/types/entities.ts +20 -8
- package/lib/ecommerce/types/requests.ts +26 -4
- package/lib/ecommerce/types/responses.ts +30 -0
- package/package.json +1 -1
|
@@ -387,11 +387,28 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
387
387
|
*
|
|
388
388
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
389
389
|
*
|
|
390
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
391
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
392
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
393
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
394
|
+
*
|
|
390
395
|
* @param request - Order creation request
|
|
391
396
|
* @returns Created order(s) with payment instructions
|
|
392
397
|
*
|
|
393
398
|
* @example
|
|
394
399
|
* ```typescript
|
|
400
|
+
* // Step 1: Calculate available shipping options
|
|
401
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
402
|
+
* merchantId: "merchant_123",
|
|
403
|
+
* destinationCountry: "US",
|
|
404
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
405
|
+
* orderSubtotal: 59.98
|
|
406
|
+
* });
|
|
407
|
+
*
|
|
408
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
409
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
410
|
+
*
|
|
411
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
395
412
|
* const result = await client.createOrder({
|
|
396
413
|
* items: [
|
|
397
414
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -407,6 +424,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
407
424
|
* postalCode: "10001",
|
|
408
425
|
* country: "US"
|
|
409
426
|
* },
|
|
427
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
410
428
|
* couponCode: "SAVE10"
|
|
411
429
|
* });
|
|
412
430
|
*
|
|
@@ -851,6 +869,35 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
851
869
|
const queryString = params ? buildQueryString(params) : "";
|
|
852
870
|
return this.get(`/api/marketplace/flash-sales/active${queryString}`);
|
|
853
871
|
}
|
|
872
|
+
/**
|
|
873
|
+
* Get flash sale allowance
|
|
874
|
+
*
|
|
875
|
+
* Fetches user's remaining purchase allowance for flash sale items.
|
|
876
|
+
* Used to enforce per-customer purchase limits.
|
|
877
|
+
*
|
|
878
|
+
* @param params - Request params with product IDs
|
|
879
|
+
* @returns Allowance info for each product
|
|
880
|
+
*
|
|
881
|
+
* @example
|
|
882
|
+
* ```typescript
|
|
883
|
+
* const result = await client.getFlashSaleAllowance({
|
|
884
|
+
* productIds: ["prod_123", "prod_456"]
|
|
885
|
+
* });
|
|
886
|
+
*
|
|
887
|
+
* Object.entries(result.allowances).forEach(([productId, info]) => {
|
|
888
|
+
* if (info.limitPerCustomer !== null) {
|
|
889
|
+
* console.log(`Product ${productId}:`);
|
|
890
|
+
* console.log(` Limit: ${info.limitPerCustomer} per customer`);
|
|
891
|
+
* console.log(` You've purchased: ${info.purchased}`);
|
|
892
|
+
* console.log(` You can buy: ${info.remaining} more`);
|
|
893
|
+
* }
|
|
894
|
+
* });
|
|
895
|
+
* ```
|
|
896
|
+
*/
|
|
897
|
+
async getFlashSaleAllowance(params) {
|
|
898
|
+
const queryString = buildQueryString({ productIds: params.productIds.join(",") });
|
|
899
|
+
return this.get(`/api/marketplace/flash-sales/allowance${queryString}`);
|
|
900
|
+
}
|
|
854
901
|
// ============================================================================
|
|
855
902
|
// Merchant Storefront API
|
|
856
903
|
// ============================================================================
|
package/dist/ecommerce.d.mts
CHANGED
|
@@ -1241,18 +1241,30 @@ interface ShippingRate extends BaseEntity {
|
|
|
1241
1241
|
}
|
|
1242
1242
|
/**
|
|
1243
1243
|
* Shipping option (calculated for checkout)
|
|
1244
|
+
*
|
|
1245
|
+
* Use `rateId` when creating orders - the server will validate and calculate cost.
|
|
1244
1246
|
*/
|
|
1245
1247
|
interface ShippingOption {
|
|
1246
|
-
/** Rate ID */
|
|
1247
|
-
|
|
1248
|
-
/** Rate name */
|
|
1249
|
-
name: string;
|
|
1250
|
-
/** Calculated cost in USDC */
|
|
1251
|
-
cost: number;
|
|
1252
|
-
/** Estimated delivery string */
|
|
1253
|
-
estimatedDelivery: string;
|
|
1248
|
+
/** Rate ID - use this when creating orders */
|
|
1249
|
+
rateId: string;
|
|
1254
1250
|
/** Zone name */
|
|
1255
1251
|
zoneName: string;
|
|
1252
|
+
/** Rate name (e.g., "Standard", "Express") */
|
|
1253
|
+
rateName: string;
|
|
1254
|
+
/** Base rate in USDC */
|
|
1255
|
+
baseRate: number;
|
|
1256
|
+
/** Per-kg rate in USDC */
|
|
1257
|
+
perKgRate: number;
|
|
1258
|
+
/** Calculated total cost in USDC (for display only - server recalculates) */
|
|
1259
|
+
calculatedCost: number;
|
|
1260
|
+
/** Whether free shipping applies */
|
|
1261
|
+
isFree: boolean;
|
|
1262
|
+
/** Estimated delivery string (e.g., "5-7 business days") */
|
|
1263
|
+
estimatedDelivery: string | null;
|
|
1264
|
+
/** Minimum delivery days */
|
|
1265
|
+
minDeliveryDays: number | null;
|
|
1266
|
+
/** Maximum delivery days */
|
|
1267
|
+
maxDeliveryDays: number | null;
|
|
1256
1268
|
}
|
|
1257
1269
|
|
|
1258
1270
|
/**
|
|
@@ -1386,13 +1398,19 @@ interface CreateOrderRequest {
|
|
|
1386
1398
|
couponCode?: string;
|
|
1387
1399
|
/** Idempotency key */
|
|
1388
1400
|
idempotencyKey?: string;
|
|
1389
|
-
/**
|
|
1401
|
+
/**
|
|
1402
|
+
* Selected shipping rate ID (from shipping calculator)
|
|
1403
|
+
* The server will validate this rate and calculate the cost server-side.
|
|
1404
|
+
* SECURITY: The cost is never trusted from the frontend.
|
|
1405
|
+
*/
|
|
1406
|
+
shippingRateId?: string;
|
|
1407
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1390
1408
|
shippingMethod?: string;
|
|
1391
|
-
/**
|
|
1409
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1392
1410
|
shippingCost?: number;
|
|
1393
|
-
/**
|
|
1411
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1394
1412
|
shippingZone?: string;
|
|
1395
|
-
/**
|
|
1413
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1396
1414
|
estimatedDelivery?: string;
|
|
1397
1415
|
}
|
|
1398
1416
|
/**
|
|
@@ -1754,6 +1772,14 @@ interface ListActiveFlashSalesParams {
|
|
|
1754
1772
|
/** Filter by merchant ID */
|
|
1755
1773
|
merchantId?: string;
|
|
1756
1774
|
}
|
|
1775
|
+
/**
|
|
1776
|
+
* Get flash sale allowance request
|
|
1777
|
+
* Get user's remaining purchase allowance for flash sale items
|
|
1778
|
+
*/
|
|
1779
|
+
interface GetFlashSaleAllowanceParams {
|
|
1780
|
+
/** Comma-separated list of product IDs */
|
|
1781
|
+
productIds: string[];
|
|
1782
|
+
}
|
|
1757
1783
|
/**
|
|
1758
1784
|
* Flash sale item input
|
|
1759
1785
|
*/
|
|
@@ -2801,6 +2827,34 @@ interface ActiveFlashSalesResponse {
|
|
|
2801
2827
|
/** Server time (for client-side sync) */
|
|
2802
2828
|
serverTime: string;
|
|
2803
2829
|
}
|
|
2830
|
+
/**
|
|
2831
|
+
* Flash sale allowance info for a single product
|
|
2832
|
+
*/
|
|
2833
|
+
interface FlashSaleAllowanceInfo {
|
|
2834
|
+
/** Flash sale ID */
|
|
2835
|
+
flashSaleId: string;
|
|
2836
|
+
/** Limit per customer (null = no limit) */
|
|
2837
|
+
limitPerCustomer: number | null;
|
|
2838
|
+
/** Quantity already purchased by user */
|
|
2839
|
+
purchased: number;
|
|
2840
|
+
/** Remaining quantity user can purchase (null = no limit) */
|
|
2841
|
+
remaining: number | null;
|
|
2842
|
+
/** Current sale price */
|
|
2843
|
+
salePrice: string;
|
|
2844
|
+
/** Maximum quantity available in flash sale (null = unlimited) */
|
|
2845
|
+
maxQuantity: number | null;
|
|
2846
|
+
/** Remaining quantity in flash sale (null = unlimited) */
|
|
2847
|
+
remainingQuantity: number | null;
|
|
2848
|
+
}
|
|
2849
|
+
/**
|
|
2850
|
+
* Get flash sale allowance response
|
|
2851
|
+
*/
|
|
2852
|
+
interface GetFlashSaleAllowanceResponse {
|
|
2853
|
+
/** Allowances by product ID */
|
|
2854
|
+
allowances: Record<string, FlashSaleAllowanceInfo>;
|
|
2855
|
+
/** Whether user is authenticated */
|
|
2856
|
+
authenticated: boolean;
|
|
2857
|
+
}
|
|
2804
2858
|
|
|
2805
2859
|
/**
|
|
2806
2860
|
* Get shipping settings response
|
|
@@ -3162,11 +3216,28 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3162
3216
|
*
|
|
3163
3217
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
3164
3218
|
*
|
|
3219
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
3220
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
3221
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
3222
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
3223
|
+
*
|
|
3165
3224
|
* @param request - Order creation request
|
|
3166
3225
|
* @returns Created order(s) with payment instructions
|
|
3167
3226
|
*
|
|
3168
3227
|
* @example
|
|
3169
3228
|
* ```typescript
|
|
3229
|
+
* // Step 1: Calculate available shipping options
|
|
3230
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
3231
|
+
* merchantId: "merchant_123",
|
|
3232
|
+
* destinationCountry: "US",
|
|
3233
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
3234
|
+
* orderSubtotal: 59.98
|
|
3235
|
+
* });
|
|
3236
|
+
*
|
|
3237
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
3238
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
3239
|
+
*
|
|
3240
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
3170
3241
|
* const result = await client.createOrder({
|
|
3171
3242
|
* items: [
|
|
3172
3243
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -3182,6 +3253,7 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3182
3253
|
* postalCode: "10001",
|
|
3183
3254
|
* country: "US"
|
|
3184
3255
|
* },
|
|
3256
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
3185
3257
|
* couponCode: "SAVE10"
|
|
3186
3258
|
* });
|
|
3187
3259
|
*
|
|
@@ -3554,6 +3626,32 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3554
3626
|
* ```
|
|
3555
3627
|
*/
|
|
3556
3628
|
getActiveFlashSales(params?: ListActiveFlashSalesParams): Promise<ActiveFlashSalesResponse>;
|
|
3629
|
+
/**
|
|
3630
|
+
* Get flash sale allowance
|
|
3631
|
+
*
|
|
3632
|
+
* Fetches user's remaining purchase allowance for flash sale items.
|
|
3633
|
+
* Used to enforce per-customer purchase limits.
|
|
3634
|
+
*
|
|
3635
|
+
* @param params - Request params with product IDs
|
|
3636
|
+
* @returns Allowance info for each product
|
|
3637
|
+
*
|
|
3638
|
+
* @example
|
|
3639
|
+
* ```typescript
|
|
3640
|
+
* const result = await client.getFlashSaleAllowance({
|
|
3641
|
+
* productIds: ["prod_123", "prod_456"]
|
|
3642
|
+
* });
|
|
3643
|
+
*
|
|
3644
|
+
* Object.entries(result.allowances).forEach(([productId, info]) => {
|
|
3645
|
+
* if (info.limitPerCustomer !== null) {
|
|
3646
|
+
* console.log(`Product ${productId}:`);
|
|
3647
|
+
* console.log(` Limit: ${info.limitPerCustomer} per customer`);
|
|
3648
|
+
* console.log(` You've purchased: ${info.purchased}`);
|
|
3649
|
+
* console.log(` You can buy: ${info.remaining} more`);
|
|
3650
|
+
* }
|
|
3651
|
+
* });
|
|
3652
|
+
* ```
|
|
3653
|
+
*/
|
|
3654
|
+
getFlashSaleAllowance(params: GetFlashSaleAllowanceParams): Promise<GetFlashSaleAllowanceResponse>;
|
|
3557
3655
|
/**
|
|
3558
3656
|
* Get public merchant profile
|
|
3559
3657
|
*
|
|
@@ -5502,4 +5600,4 @@ declare function calculateDiscountAmount(price: number, discountType: "PERCENTAG
|
|
|
5502
5600
|
*/
|
|
5503
5601
|
declare function calculateFinalPrice(price: number, discountType: "PERCENTAGE" | "FIXED_AMOUNT", discountValue: number): number;
|
|
5504
5602
|
|
|
5505
|
-
export { type ActiveFlashSalesResponse, type AnalyticsOverview, type ApiResponse, type AppliedDiscount, type Banner, type BannerResponse, BannerType, BaseEcommerceClient, type BaseEntity, type BrowsingLocation, type CalculateCartDiscountsRequest, type CalculateCartDiscountsResponse, type CalculateShippingRequest, type CalculateShippingResponse, type CalculateTaxRequest, type CalculateTaxResponse, type CartItem, type ConfirmEscrowDepositResponse, type Coupon, type CouponResponse, type CouponUsage, type CreateBannerRequest, type CreateCouponRequest, type CreateFlashSaleRequest, type CreateOrderEventRequest, type CreateOrderEventResponse, type CreateOrderRequest, type CreateOrderResponse, type CreateProductRequest, type CreateProductVariantRequest, type CreateReviewRequest, type CreateShippingMethodRequest, type CreateShippingRateRequest, type CreateShippingZoneRequest, type CreateTaxNexusRequest, type CreateTaxRuleRequest, CustomerEcommerceClient, type CustomerMessagesResponse, type CustomerSummary, type DeleteBrowsingLocationResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, type EcommerceClientConfig, type ExpiringGemBatch, type FlashSale, type FlashSaleItem, type FlashSaleItemInput, type FollowActionResponse, type FollowStatusResponse, type FollowedMerchantSummary, type GemHistoryItem, type GemHistoryType, type GemHistoryTypeFilter, type GemSource, type GenerateTaxReportRequest, type GetAnalyticsParams, type GetAnalyticsResponse, type GetBrowsingLocationResponse, type GetCouponResponse, type GetExpiringGemsParams, type GetExpiringGemsResponse, type GetGemBalanceResponse, type GetGemHistoryParams, type GetGemHistoryResponse, type GetOrderResponse, type GetPaymentMethodsResponse, type GetProductMetricsResponse, type GetProductResponse, type GetTaxReportResponse, InventoryAuditAction, type InventoryAuditEntry, type ListActiveBannersParams, type ListActiveFlashSalesParams, type ListBannersResponse, type ListCouponsResponse, type ListCustomersParams, type ListCustomersResponse, type ListFollowingParams, type ListFollowingResponse, type ListInventoryAuditResponse, type ListMediaAssetsResponse, type ListMerchantProductsParams, type ListMessagesResponse, type ListOrdersParams, type ListOrdersResponse, type ListProductVariantsResponse, type ListProductsParams, type ListProductsResponse, type ListReturnsResponse, type ListReviewsParams, type ListReviewsResponse, type ListShipmentsResponse, type ListShippingAddressesResponse, type ListShippingMethodsResponse, type ListShippingRatesResponse, type ListShippingZonesResponse, type ListTaxNexusResponse, type ListTaxReportsParams, type ListTaxReportsResponse, type ListTaxRulesResponse, type MediaAsset, type MediaAssetResponse, type Merchant, MerchantEcommerceClient, type MerchantProductsResponse, type MerchantProfileRequest, type MerchantProfileResponse, type MerchantShippingSettings, MerchantStatus, type Message, type MessageResponse, type MessageStatsResponse, type Order, type OrderEvent, type OrderItem, type OrderReceiptResponse, OrderStatus, type OrdersByStatus, type PaginatedResponse, type PaginationParams, type Payment, PaymentMethod, type PaymentMethodInfo, PaymentStatus, type ProcessPaymentRequest, type ProcessPaymentResponse, type Product, type ProductDimensions, type ProductDiscountsResponse, type ProductMetrics, type ProductResponse, type ProductReview, ProductSortBy, type ProductVariant, type ProductVariantResponse, type PublicMerchantProfile, type PublicMerchantProfileResponse, type RecentOrderSummary, type RespondToReviewRequest, type Return, type ReturnItem, type ReturnResponse, ReturnStatus, type RevenueByDay, type ReviewResponse, ReviewSortBy, ReviewStatus, type SaveBrowsingLocationRequest, type SaveBrowsingLocationResponse, type SendMessageRequest, type Settlement, type Shipment, type ShipmentResponse, ShipmentStatus, type ShippingAddress$1 as ShippingAddress, type ShippingAddressRequest, type ShippingAddressResponse, type ShippingMethod, type ShippingMethodResponse, type ShippingOption, type ShippingRate, type ShippingRateResponse, type ShippingSettingsResponse, type ShippingZone, type ShippingZoneResponse, SortOrder, type SuccessResponse, TaxBehavior, type TaxBreakdownItem, type TaxNexus, type TaxNexusResponse, type TaxReport, type TaxReportDetails, TaxReportPeriodType, type TaxReportResponse, TaxReportStatus, type TaxRule, type TaxRuleResponse, type TaxSettings, type TaxSettingsResponse, TaxType, type TopProduct, type TrackBannerRequest, type UpdateBannerRequest, type UpdateCouponRequest, type UpdateFlashSaleRequest, type UpdateOrderResponse, type UpdateOrderStatusRequest, type UpdateProductRequest, type UpdateProductVariantRequest, type UpdateShipmentRequest, type UpdateShippingMethodRequest, type UpdateShippingRateRequest, type UpdateShippingSettingsRequest, type UpdateShippingZoneRequest, type UpdateTaxNexusRequest, type UpdateTaxReportStatusRequest, type UpdateTaxRuleRequest, type UpdateTaxSettingsRequest, type UserShippingAddress, type ValidateDiscountRequest, type ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress };
|
|
5603
|
+
export { type ActiveFlashSalesResponse, type AnalyticsOverview, type ApiResponse, type AppliedDiscount, type Banner, type BannerResponse, BannerType, BaseEcommerceClient, type BaseEntity, type BrowsingLocation, type CalculateCartDiscountsRequest, type CalculateCartDiscountsResponse, type CalculateShippingRequest, type CalculateShippingResponse, type CalculateTaxRequest, type CalculateTaxResponse, type CartItem, type ConfirmEscrowDepositResponse, type Coupon, type CouponResponse, type CouponUsage, type CreateBannerRequest, type CreateCouponRequest, type CreateFlashSaleRequest, type CreateOrderEventRequest, type CreateOrderEventResponse, type CreateOrderRequest, type CreateOrderResponse, type CreateProductRequest, type CreateProductVariantRequest, type CreateReviewRequest, type CreateShippingMethodRequest, type CreateShippingRateRequest, type CreateShippingZoneRequest, type CreateTaxNexusRequest, type CreateTaxRuleRequest, CustomerEcommerceClient, type CustomerMessagesResponse, type CustomerSummary, type DeleteBrowsingLocationResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, type EcommerceClientConfig, type ExpiringGemBatch, type FlashSale, type FlashSaleAllowanceInfo, type FlashSaleItem, type FlashSaleItemInput, type FollowActionResponse, type FollowStatusResponse, type FollowedMerchantSummary, type GemHistoryItem, type GemHistoryType, type GemHistoryTypeFilter, type GemSource, type GenerateTaxReportRequest, type GetAnalyticsParams, type GetAnalyticsResponse, type GetBrowsingLocationResponse, type GetCouponResponse, type GetExpiringGemsParams, type GetExpiringGemsResponse, type GetFlashSaleAllowanceParams, type GetFlashSaleAllowanceResponse, type GetGemBalanceResponse, type GetGemHistoryParams, type GetGemHistoryResponse, type GetOrderResponse, type GetPaymentMethodsResponse, type GetProductMetricsResponse, type GetProductResponse, type GetTaxReportResponse, InventoryAuditAction, type InventoryAuditEntry, type ListActiveBannersParams, type ListActiveFlashSalesParams, type ListBannersResponse, type ListCouponsResponse, type ListCustomersParams, type ListCustomersResponse, type ListFollowingParams, type ListFollowingResponse, type ListInventoryAuditResponse, type ListMediaAssetsResponse, type ListMerchantProductsParams, type ListMessagesResponse, type ListOrdersParams, type ListOrdersResponse, type ListProductVariantsResponse, type ListProductsParams, type ListProductsResponse, type ListReturnsResponse, type ListReviewsParams, type ListReviewsResponse, type ListShipmentsResponse, type ListShippingAddressesResponse, type ListShippingMethodsResponse, type ListShippingRatesResponse, type ListShippingZonesResponse, type ListTaxNexusResponse, type ListTaxReportsParams, type ListTaxReportsResponse, type ListTaxRulesResponse, type MediaAsset, type MediaAssetResponse, type Merchant, MerchantEcommerceClient, type MerchantProductsResponse, type MerchantProfileRequest, type MerchantProfileResponse, type MerchantShippingSettings, MerchantStatus, type Message, type MessageResponse, type MessageStatsResponse, type Order, type OrderEvent, type OrderItem, type OrderReceiptResponse, OrderStatus, type OrdersByStatus, type PaginatedResponse, type PaginationParams, type Payment, PaymentMethod, type PaymentMethodInfo, PaymentStatus, type ProcessPaymentRequest, type ProcessPaymentResponse, type Product, type ProductDimensions, type ProductDiscountsResponse, type ProductMetrics, type ProductResponse, type ProductReview, ProductSortBy, type ProductVariant, type ProductVariantResponse, type PublicMerchantProfile, type PublicMerchantProfileResponse, type RecentOrderSummary, type RespondToReviewRequest, type Return, type ReturnItem, type ReturnResponse, ReturnStatus, type RevenueByDay, type ReviewResponse, ReviewSortBy, ReviewStatus, type SaveBrowsingLocationRequest, type SaveBrowsingLocationResponse, type SendMessageRequest, type Settlement, type Shipment, type ShipmentResponse, ShipmentStatus, type ShippingAddress$1 as ShippingAddress, type ShippingAddressRequest, type ShippingAddressResponse, type ShippingMethod, type ShippingMethodResponse, type ShippingOption, type ShippingRate, type ShippingRateResponse, type ShippingSettingsResponse, type ShippingZone, type ShippingZoneResponse, SortOrder, type SuccessResponse, TaxBehavior, type TaxBreakdownItem, type TaxNexus, type TaxNexusResponse, type TaxReport, type TaxReportDetails, TaxReportPeriodType, type TaxReportResponse, TaxReportStatus, type TaxRule, type TaxRuleResponse, type TaxSettings, type TaxSettingsResponse, TaxType, type TopProduct, type TrackBannerRequest, type UpdateBannerRequest, type UpdateCouponRequest, type UpdateFlashSaleRequest, type UpdateOrderResponse, type UpdateOrderStatusRequest, type UpdateProductRequest, type UpdateProductVariantRequest, type UpdateShipmentRequest, type UpdateShippingMethodRequest, type UpdateShippingRateRequest, type UpdateShippingSettingsRequest, type UpdateShippingZoneRequest, type UpdateTaxNexusRequest, type UpdateTaxReportStatusRequest, type UpdateTaxRuleRequest, type UpdateTaxSettingsRequest, type UserShippingAddress, type ValidateDiscountRequest, type ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress };
|
package/dist/ecommerce.d.ts
CHANGED
|
@@ -1241,18 +1241,30 @@ interface ShippingRate extends BaseEntity {
|
|
|
1241
1241
|
}
|
|
1242
1242
|
/**
|
|
1243
1243
|
* Shipping option (calculated for checkout)
|
|
1244
|
+
*
|
|
1245
|
+
* Use `rateId` when creating orders - the server will validate and calculate cost.
|
|
1244
1246
|
*/
|
|
1245
1247
|
interface ShippingOption {
|
|
1246
|
-
/** Rate ID */
|
|
1247
|
-
|
|
1248
|
-
/** Rate name */
|
|
1249
|
-
name: string;
|
|
1250
|
-
/** Calculated cost in USDC */
|
|
1251
|
-
cost: number;
|
|
1252
|
-
/** Estimated delivery string */
|
|
1253
|
-
estimatedDelivery: string;
|
|
1248
|
+
/** Rate ID - use this when creating orders */
|
|
1249
|
+
rateId: string;
|
|
1254
1250
|
/** Zone name */
|
|
1255
1251
|
zoneName: string;
|
|
1252
|
+
/** Rate name (e.g., "Standard", "Express") */
|
|
1253
|
+
rateName: string;
|
|
1254
|
+
/** Base rate in USDC */
|
|
1255
|
+
baseRate: number;
|
|
1256
|
+
/** Per-kg rate in USDC */
|
|
1257
|
+
perKgRate: number;
|
|
1258
|
+
/** Calculated total cost in USDC (for display only - server recalculates) */
|
|
1259
|
+
calculatedCost: number;
|
|
1260
|
+
/** Whether free shipping applies */
|
|
1261
|
+
isFree: boolean;
|
|
1262
|
+
/** Estimated delivery string (e.g., "5-7 business days") */
|
|
1263
|
+
estimatedDelivery: string | null;
|
|
1264
|
+
/** Minimum delivery days */
|
|
1265
|
+
minDeliveryDays: number | null;
|
|
1266
|
+
/** Maximum delivery days */
|
|
1267
|
+
maxDeliveryDays: number | null;
|
|
1256
1268
|
}
|
|
1257
1269
|
|
|
1258
1270
|
/**
|
|
@@ -1386,13 +1398,19 @@ interface CreateOrderRequest {
|
|
|
1386
1398
|
couponCode?: string;
|
|
1387
1399
|
/** Idempotency key */
|
|
1388
1400
|
idempotencyKey?: string;
|
|
1389
|
-
/**
|
|
1401
|
+
/**
|
|
1402
|
+
* Selected shipping rate ID (from shipping calculator)
|
|
1403
|
+
* The server will validate this rate and calculate the cost server-side.
|
|
1404
|
+
* SECURITY: The cost is never trusted from the frontend.
|
|
1405
|
+
*/
|
|
1406
|
+
shippingRateId?: string;
|
|
1407
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1390
1408
|
shippingMethod?: string;
|
|
1391
|
-
/**
|
|
1409
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1392
1410
|
shippingCost?: number;
|
|
1393
|
-
/**
|
|
1411
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1394
1412
|
shippingZone?: string;
|
|
1395
|
-
/**
|
|
1413
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1396
1414
|
estimatedDelivery?: string;
|
|
1397
1415
|
}
|
|
1398
1416
|
/**
|
|
@@ -1754,6 +1772,14 @@ interface ListActiveFlashSalesParams {
|
|
|
1754
1772
|
/** Filter by merchant ID */
|
|
1755
1773
|
merchantId?: string;
|
|
1756
1774
|
}
|
|
1775
|
+
/**
|
|
1776
|
+
* Get flash sale allowance request
|
|
1777
|
+
* Get user's remaining purchase allowance for flash sale items
|
|
1778
|
+
*/
|
|
1779
|
+
interface GetFlashSaleAllowanceParams {
|
|
1780
|
+
/** Comma-separated list of product IDs */
|
|
1781
|
+
productIds: string[];
|
|
1782
|
+
}
|
|
1757
1783
|
/**
|
|
1758
1784
|
* Flash sale item input
|
|
1759
1785
|
*/
|
|
@@ -2801,6 +2827,34 @@ interface ActiveFlashSalesResponse {
|
|
|
2801
2827
|
/** Server time (for client-side sync) */
|
|
2802
2828
|
serverTime: string;
|
|
2803
2829
|
}
|
|
2830
|
+
/**
|
|
2831
|
+
* Flash sale allowance info for a single product
|
|
2832
|
+
*/
|
|
2833
|
+
interface FlashSaleAllowanceInfo {
|
|
2834
|
+
/** Flash sale ID */
|
|
2835
|
+
flashSaleId: string;
|
|
2836
|
+
/** Limit per customer (null = no limit) */
|
|
2837
|
+
limitPerCustomer: number | null;
|
|
2838
|
+
/** Quantity already purchased by user */
|
|
2839
|
+
purchased: number;
|
|
2840
|
+
/** Remaining quantity user can purchase (null = no limit) */
|
|
2841
|
+
remaining: number | null;
|
|
2842
|
+
/** Current sale price */
|
|
2843
|
+
salePrice: string;
|
|
2844
|
+
/** Maximum quantity available in flash sale (null = unlimited) */
|
|
2845
|
+
maxQuantity: number | null;
|
|
2846
|
+
/** Remaining quantity in flash sale (null = unlimited) */
|
|
2847
|
+
remainingQuantity: number | null;
|
|
2848
|
+
}
|
|
2849
|
+
/**
|
|
2850
|
+
* Get flash sale allowance response
|
|
2851
|
+
*/
|
|
2852
|
+
interface GetFlashSaleAllowanceResponse {
|
|
2853
|
+
/** Allowances by product ID */
|
|
2854
|
+
allowances: Record<string, FlashSaleAllowanceInfo>;
|
|
2855
|
+
/** Whether user is authenticated */
|
|
2856
|
+
authenticated: boolean;
|
|
2857
|
+
}
|
|
2804
2858
|
|
|
2805
2859
|
/**
|
|
2806
2860
|
* Get shipping settings response
|
|
@@ -3162,11 +3216,28 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3162
3216
|
*
|
|
3163
3217
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
3164
3218
|
*
|
|
3219
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
3220
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
3221
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
3222
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
3223
|
+
*
|
|
3165
3224
|
* @param request - Order creation request
|
|
3166
3225
|
* @returns Created order(s) with payment instructions
|
|
3167
3226
|
*
|
|
3168
3227
|
* @example
|
|
3169
3228
|
* ```typescript
|
|
3229
|
+
* // Step 1: Calculate available shipping options
|
|
3230
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
3231
|
+
* merchantId: "merchant_123",
|
|
3232
|
+
* destinationCountry: "US",
|
|
3233
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
3234
|
+
* orderSubtotal: 59.98
|
|
3235
|
+
* });
|
|
3236
|
+
*
|
|
3237
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
3238
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
3239
|
+
*
|
|
3240
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
3170
3241
|
* const result = await client.createOrder({
|
|
3171
3242
|
* items: [
|
|
3172
3243
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -3182,6 +3253,7 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3182
3253
|
* postalCode: "10001",
|
|
3183
3254
|
* country: "US"
|
|
3184
3255
|
* },
|
|
3256
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
3185
3257
|
* couponCode: "SAVE10"
|
|
3186
3258
|
* });
|
|
3187
3259
|
*
|
|
@@ -3554,6 +3626,32 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3554
3626
|
* ```
|
|
3555
3627
|
*/
|
|
3556
3628
|
getActiveFlashSales(params?: ListActiveFlashSalesParams): Promise<ActiveFlashSalesResponse>;
|
|
3629
|
+
/**
|
|
3630
|
+
* Get flash sale allowance
|
|
3631
|
+
*
|
|
3632
|
+
* Fetches user's remaining purchase allowance for flash sale items.
|
|
3633
|
+
* Used to enforce per-customer purchase limits.
|
|
3634
|
+
*
|
|
3635
|
+
* @param params - Request params with product IDs
|
|
3636
|
+
* @returns Allowance info for each product
|
|
3637
|
+
*
|
|
3638
|
+
* @example
|
|
3639
|
+
* ```typescript
|
|
3640
|
+
* const result = await client.getFlashSaleAllowance({
|
|
3641
|
+
* productIds: ["prod_123", "prod_456"]
|
|
3642
|
+
* });
|
|
3643
|
+
*
|
|
3644
|
+
* Object.entries(result.allowances).forEach(([productId, info]) => {
|
|
3645
|
+
* if (info.limitPerCustomer !== null) {
|
|
3646
|
+
* console.log(`Product ${productId}:`);
|
|
3647
|
+
* console.log(` Limit: ${info.limitPerCustomer} per customer`);
|
|
3648
|
+
* console.log(` You've purchased: ${info.purchased}`);
|
|
3649
|
+
* console.log(` You can buy: ${info.remaining} more`);
|
|
3650
|
+
* }
|
|
3651
|
+
* });
|
|
3652
|
+
* ```
|
|
3653
|
+
*/
|
|
3654
|
+
getFlashSaleAllowance(params: GetFlashSaleAllowanceParams): Promise<GetFlashSaleAllowanceResponse>;
|
|
3557
3655
|
/**
|
|
3558
3656
|
* Get public merchant profile
|
|
3559
3657
|
*
|
|
@@ -5502,4 +5600,4 @@ declare function calculateDiscountAmount(price: number, discountType: "PERCENTAG
|
|
|
5502
5600
|
*/
|
|
5503
5601
|
declare function calculateFinalPrice(price: number, discountType: "PERCENTAGE" | "FIXED_AMOUNT", discountValue: number): number;
|
|
5504
5602
|
|
|
5505
|
-
export { type ActiveFlashSalesResponse, type AnalyticsOverview, type ApiResponse, type AppliedDiscount, type Banner, type BannerResponse, BannerType, BaseEcommerceClient, type BaseEntity, type BrowsingLocation, type CalculateCartDiscountsRequest, type CalculateCartDiscountsResponse, type CalculateShippingRequest, type CalculateShippingResponse, type CalculateTaxRequest, type CalculateTaxResponse, type CartItem, type ConfirmEscrowDepositResponse, type Coupon, type CouponResponse, type CouponUsage, type CreateBannerRequest, type CreateCouponRequest, type CreateFlashSaleRequest, type CreateOrderEventRequest, type CreateOrderEventResponse, type CreateOrderRequest, type CreateOrderResponse, type CreateProductRequest, type CreateProductVariantRequest, type CreateReviewRequest, type CreateShippingMethodRequest, type CreateShippingRateRequest, type CreateShippingZoneRequest, type CreateTaxNexusRequest, type CreateTaxRuleRequest, CustomerEcommerceClient, type CustomerMessagesResponse, type CustomerSummary, type DeleteBrowsingLocationResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, type EcommerceClientConfig, type ExpiringGemBatch, type FlashSale, type FlashSaleItem, type FlashSaleItemInput, type FollowActionResponse, type FollowStatusResponse, type FollowedMerchantSummary, type GemHistoryItem, type GemHistoryType, type GemHistoryTypeFilter, type GemSource, type GenerateTaxReportRequest, type GetAnalyticsParams, type GetAnalyticsResponse, type GetBrowsingLocationResponse, type GetCouponResponse, type GetExpiringGemsParams, type GetExpiringGemsResponse, type GetGemBalanceResponse, type GetGemHistoryParams, type GetGemHistoryResponse, type GetOrderResponse, type GetPaymentMethodsResponse, type GetProductMetricsResponse, type GetProductResponse, type GetTaxReportResponse, InventoryAuditAction, type InventoryAuditEntry, type ListActiveBannersParams, type ListActiveFlashSalesParams, type ListBannersResponse, type ListCouponsResponse, type ListCustomersParams, type ListCustomersResponse, type ListFollowingParams, type ListFollowingResponse, type ListInventoryAuditResponse, type ListMediaAssetsResponse, type ListMerchantProductsParams, type ListMessagesResponse, type ListOrdersParams, type ListOrdersResponse, type ListProductVariantsResponse, type ListProductsParams, type ListProductsResponse, type ListReturnsResponse, type ListReviewsParams, type ListReviewsResponse, type ListShipmentsResponse, type ListShippingAddressesResponse, type ListShippingMethodsResponse, type ListShippingRatesResponse, type ListShippingZonesResponse, type ListTaxNexusResponse, type ListTaxReportsParams, type ListTaxReportsResponse, type ListTaxRulesResponse, type MediaAsset, type MediaAssetResponse, type Merchant, MerchantEcommerceClient, type MerchantProductsResponse, type MerchantProfileRequest, type MerchantProfileResponse, type MerchantShippingSettings, MerchantStatus, type Message, type MessageResponse, type MessageStatsResponse, type Order, type OrderEvent, type OrderItem, type OrderReceiptResponse, OrderStatus, type OrdersByStatus, type PaginatedResponse, type PaginationParams, type Payment, PaymentMethod, type PaymentMethodInfo, PaymentStatus, type ProcessPaymentRequest, type ProcessPaymentResponse, type Product, type ProductDimensions, type ProductDiscountsResponse, type ProductMetrics, type ProductResponse, type ProductReview, ProductSortBy, type ProductVariant, type ProductVariantResponse, type PublicMerchantProfile, type PublicMerchantProfileResponse, type RecentOrderSummary, type RespondToReviewRequest, type Return, type ReturnItem, type ReturnResponse, ReturnStatus, type RevenueByDay, type ReviewResponse, ReviewSortBy, ReviewStatus, type SaveBrowsingLocationRequest, type SaveBrowsingLocationResponse, type SendMessageRequest, type Settlement, type Shipment, type ShipmentResponse, ShipmentStatus, type ShippingAddress$1 as ShippingAddress, type ShippingAddressRequest, type ShippingAddressResponse, type ShippingMethod, type ShippingMethodResponse, type ShippingOption, type ShippingRate, type ShippingRateResponse, type ShippingSettingsResponse, type ShippingZone, type ShippingZoneResponse, SortOrder, type SuccessResponse, TaxBehavior, type TaxBreakdownItem, type TaxNexus, type TaxNexusResponse, type TaxReport, type TaxReportDetails, TaxReportPeriodType, type TaxReportResponse, TaxReportStatus, type TaxRule, type TaxRuleResponse, type TaxSettings, type TaxSettingsResponse, TaxType, type TopProduct, type TrackBannerRequest, type UpdateBannerRequest, type UpdateCouponRequest, type UpdateFlashSaleRequest, type UpdateOrderResponse, type UpdateOrderStatusRequest, type UpdateProductRequest, type UpdateProductVariantRequest, type UpdateShipmentRequest, type UpdateShippingMethodRequest, type UpdateShippingRateRequest, type UpdateShippingSettingsRequest, type UpdateShippingZoneRequest, type UpdateTaxNexusRequest, type UpdateTaxReportStatusRequest, type UpdateTaxRuleRequest, type UpdateTaxSettingsRequest, type UserShippingAddress, type ValidateDiscountRequest, type ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress };
|
|
5603
|
+
export { type ActiveFlashSalesResponse, type AnalyticsOverview, type ApiResponse, type AppliedDiscount, type Banner, type BannerResponse, BannerType, BaseEcommerceClient, type BaseEntity, type BrowsingLocation, type CalculateCartDiscountsRequest, type CalculateCartDiscountsResponse, type CalculateShippingRequest, type CalculateShippingResponse, type CalculateTaxRequest, type CalculateTaxResponse, type CartItem, type ConfirmEscrowDepositResponse, type Coupon, type CouponResponse, type CouponUsage, type CreateBannerRequest, type CreateCouponRequest, type CreateFlashSaleRequest, type CreateOrderEventRequest, type CreateOrderEventResponse, type CreateOrderRequest, type CreateOrderResponse, type CreateProductRequest, type CreateProductVariantRequest, type CreateReviewRequest, type CreateShippingMethodRequest, type CreateShippingRateRequest, type CreateShippingZoneRequest, type CreateTaxNexusRequest, type CreateTaxRuleRequest, CustomerEcommerceClient, type CustomerMessagesResponse, type CustomerSummary, type DeleteBrowsingLocationResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, type EcommerceClientConfig, type ExpiringGemBatch, type FlashSale, type FlashSaleAllowanceInfo, type FlashSaleItem, type FlashSaleItemInput, type FollowActionResponse, type FollowStatusResponse, type FollowedMerchantSummary, type GemHistoryItem, type GemHistoryType, type GemHistoryTypeFilter, type GemSource, type GenerateTaxReportRequest, type GetAnalyticsParams, type GetAnalyticsResponse, type GetBrowsingLocationResponse, type GetCouponResponse, type GetExpiringGemsParams, type GetExpiringGemsResponse, type GetFlashSaleAllowanceParams, type GetFlashSaleAllowanceResponse, type GetGemBalanceResponse, type GetGemHistoryParams, type GetGemHistoryResponse, type GetOrderResponse, type GetPaymentMethodsResponse, type GetProductMetricsResponse, type GetProductResponse, type GetTaxReportResponse, InventoryAuditAction, type InventoryAuditEntry, type ListActiveBannersParams, type ListActiveFlashSalesParams, type ListBannersResponse, type ListCouponsResponse, type ListCustomersParams, type ListCustomersResponse, type ListFollowingParams, type ListFollowingResponse, type ListInventoryAuditResponse, type ListMediaAssetsResponse, type ListMerchantProductsParams, type ListMessagesResponse, type ListOrdersParams, type ListOrdersResponse, type ListProductVariantsResponse, type ListProductsParams, type ListProductsResponse, type ListReturnsResponse, type ListReviewsParams, type ListReviewsResponse, type ListShipmentsResponse, type ListShippingAddressesResponse, type ListShippingMethodsResponse, type ListShippingRatesResponse, type ListShippingZonesResponse, type ListTaxNexusResponse, type ListTaxReportsParams, type ListTaxReportsResponse, type ListTaxRulesResponse, type MediaAsset, type MediaAssetResponse, type Merchant, MerchantEcommerceClient, type MerchantProductsResponse, type MerchantProfileRequest, type MerchantProfileResponse, type MerchantShippingSettings, MerchantStatus, type Message, type MessageResponse, type MessageStatsResponse, type Order, type OrderEvent, type OrderItem, type OrderReceiptResponse, OrderStatus, type OrdersByStatus, type PaginatedResponse, type PaginationParams, type Payment, PaymentMethod, type PaymentMethodInfo, PaymentStatus, type ProcessPaymentRequest, type ProcessPaymentResponse, type Product, type ProductDimensions, type ProductDiscountsResponse, type ProductMetrics, type ProductResponse, type ProductReview, ProductSortBy, type ProductVariant, type ProductVariantResponse, type PublicMerchantProfile, type PublicMerchantProfileResponse, type RecentOrderSummary, type RespondToReviewRequest, type Return, type ReturnItem, type ReturnResponse, ReturnStatus, type RevenueByDay, type ReviewResponse, ReviewSortBy, ReviewStatus, type SaveBrowsingLocationRequest, type SaveBrowsingLocationResponse, type SendMessageRequest, type Settlement, type Shipment, type ShipmentResponse, ShipmentStatus, type ShippingAddress$1 as ShippingAddress, type ShippingAddressRequest, type ShippingAddressResponse, type ShippingMethod, type ShippingMethodResponse, type ShippingOption, type ShippingRate, type ShippingRateResponse, type ShippingSettingsResponse, type ShippingZone, type ShippingZoneResponse, SortOrder, type SuccessResponse, TaxBehavior, type TaxBreakdownItem, type TaxNexus, type TaxNexusResponse, type TaxReport, type TaxReportDetails, TaxReportPeriodType, type TaxReportResponse, TaxReportStatus, type TaxRule, type TaxRuleResponse, type TaxSettings, type TaxSettingsResponse, TaxType, type TopProduct, type TrackBannerRequest, type UpdateBannerRequest, type UpdateCouponRequest, type UpdateFlashSaleRequest, type UpdateOrderResponse, type UpdateOrderStatusRequest, type UpdateProductRequest, type UpdateProductVariantRequest, type UpdateShipmentRequest, type UpdateShippingMethodRequest, type UpdateShippingRateRequest, type UpdateShippingSettingsRequest, type UpdateShippingZoneRequest, type UpdateTaxNexusRequest, type UpdateTaxReportStatusRequest, type UpdateTaxRuleRequest, type UpdateTaxSettingsRequest, type UserShippingAddress, type ValidateDiscountRequest, type ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress };
|
package/dist/ecommerce.js
CHANGED
|
@@ -397,11 +397,28 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
397
397
|
*
|
|
398
398
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
399
399
|
*
|
|
400
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
401
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
402
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
403
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
404
|
+
*
|
|
400
405
|
* @param request - Order creation request
|
|
401
406
|
* @returns Created order(s) with payment instructions
|
|
402
407
|
*
|
|
403
408
|
* @example
|
|
404
409
|
* ```typescript
|
|
410
|
+
* // Step 1: Calculate available shipping options
|
|
411
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
412
|
+
* merchantId: "merchant_123",
|
|
413
|
+
* destinationCountry: "US",
|
|
414
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
415
|
+
* orderSubtotal: 59.98
|
|
416
|
+
* });
|
|
417
|
+
*
|
|
418
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
419
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
420
|
+
*
|
|
421
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
405
422
|
* const result = await client.createOrder({
|
|
406
423
|
* items: [
|
|
407
424
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -417,6 +434,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
417
434
|
* postalCode: "10001",
|
|
418
435
|
* country: "US"
|
|
419
436
|
* },
|
|
437
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
420
438
|
* couponCode: "SAVE10"
|
|
421
439
|
* });
|
|
422
440
|
*
|
|
@@ -861,6 +879,35 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
861
879
|
const queryString = params ? buildQueryString(params) : "";
|
|
862
880
|
return this.get(`/api/marketplace/flash-sales/active${queryString}`);
|
|
863
881
|
}
|
|
882
|
+
/**
|
|
883
|
+
* Get flash sale allowance
|
|
884
|
+
*
|
|
885
|
+
* Fetches user's remaining purchase allowance for flash sale items.
|
|
886
|
+
* Used to enforce per-customer purchase limits.
|
|
887
|
+
*
|
|
888
|
+
* @param params - Request params with product IDs
|
|
889
|
+
* @returns Allowance info for each product
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* ```typescript
|
|
893
|
+
* const result = await client.getFlashSaleAllowance({
|
|
894
|
+
* productIds: ["prod_123", "prod_456"]
|
|
895
|
+
* });
|
|
896
|
+
*
|
|
897
|
+
* Object.entries(result.allowances).forEach(([productId, info]) => {
|
|
898
|
+
* if (info.limitPerCustomer !== null) {
|
|
899
|
+
* console.log(`Product ${productId}:`);
|
|
900
|
+
* console.log(` Limit: ${info.limitPerCustomer} per customer`);
|
|
901
|
+
* console.log(` You've purchased: ${info.purchased}`);
|
|
902
|
+
* console.log(` You can buy: ${info.remaining} more`);
|
|
903
|
+
* }
|
|
904
|
+
* });
|
|
905
|
+
* ```
|
|
906
|
+
*/
|
|
907
|
+
async getFlashSaleAllowance(params) {
|
|
908
|
+
const queryString = buildQueryString({ productIds: params.productIds.join(",") });
|
|
909
|
+
return this.get(`/api/marketplace/flash-sales/allowance${queryString}`);
|
|
910
|
+
}
|
|
864
911
|
// ============================================================================
|
|
865
912
|
// Merchant Storefront API
|
|
866
913
|
// ============================================================================
|
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-CAU4QLVH.mjs';
|
|
2
2
|
import './chunk-4UEJOM6W.mjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SpotToken, MarginTables, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
|
|
2
2
|
import { Hex } from '@nktkas/hyperliquid/types';
|
|
3
3
|
export { A as AllPerpsMeta, d as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, c as PerpsInstrument, P as PerpsMeta, a as PerpsMetaAndAssetCtxs, b as PerpsUniverse, S as SpotInstrument, g as getAllPerpsMeta } from './client-CgmiTuEX.mjs';
|
|
4
|
-
export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, BrowsingLocation, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateShippingRequest, CalculateShippingResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateShippingRateRequest, CreateShippingZoneRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerSummary, DeleteBrowsingLocationResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, ExpiringGemBatch, FlashSale, FlashSaleItem, FlashSaleItemInput, FollowActionResponse, FollowStatusResponse, FollowedMerchantSummary, GemHistoryItem, GemHistoryType, GemHistoryTypeFilter, GemSource, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetBrowsingLocationResponse, GetCouponResponse, GetExpiringGemsParams, GetExpiringGemsResponse, GetGemBalanceResponse, GetGemHistoryParams, GetGemHistoryResponse, GetOrderResponse, GetPaymentMethodsResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListFollowingParams, ListFollowingResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMerchantProductsParams, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListShippingRatesResponse, ListShippingZonesResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantEcommerceClient, MerchantProductsResponse, MerchantProfileRequest, MerchantProfileResponse, MerchantShippingSettings, MerchantStatus, Message, MessageResponse, MessageStatsResponse, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentMethodInfo, PaymentStatus, ProcessPaymentRequest, ProcessPaymentResponse, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, PublicMerchantProfile, PublicMerchantProfileResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SaveBrowsingLocationRequest, SaveBrowsingLocationResponse, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, ShippingOption, ShippingRate, ShippingRateResponse, ShippingSettingsResponse, ShippingZone, ShippingZoneResponse, SortOrder, SuccessResponse, TaxBehavior, TaxBreakdownItem, TaxNexus, TaxNexusResponse, TaxReport, TaxReportDetails, TaxReportPeriodType, TaxReportResponse, TaxReportStatus, TaxRule, TaxRuleResponse, TaxSettings, TaxSettingsResponse, TaxType, TopProduct, TrackBannerRequest, UpdateBannerRequest, UpdateCouponRequest, UpdateFlashSaleRequest, UpdateOrderResponse, UpdateOrderStatusRequest, UpdateProductRequest, UpdateProductVariantRequest, UpdateShipmentRequest, UpdateShippingMethodRequest, UpdateShippingRateRequest, UpdateShippingSettingsRequest, UpdateShippingZoneRequest, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './ecommerce.mjs';
|
|
4
|
+
export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, BrowsingLocation, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateShippingRequest, CalculateShippingResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateShippingRateRequest, CreateShippingZoneRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerSummary, DeleteBrowsingLocationResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, ExpiringGemBatch, FlashSale, FlashSaleAllowanceInfo, FlashSaleItem, FlashSaleItemInput, FollowActionResponse, FollowStatusResponse, FollowedMerchantSummary, GemHistoryItem, GemHistoryType, GemHistoryTypeFilter, GemSource, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetBrowsingLocationResponse, GetCouponResponse, GetExpiringGemsParams, GetExpiringGemsResponse, GetFlashSaleAllowanceParams, GetFlashSaleAllowanceResponse, GetGemBalanceResponse, GetGemHistoryParams, GetGemHistoryResponse, GetOrderResponse, GetPaymentMethodsResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListFollowingParams, ListFollowingResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMerchantProductsParams, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListShippingRatesResponse, ListShippingZonesResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantEcommerceClient, MerchantProductsResponse, MerchantProfileRequest, MerchantProfileResponse, MerchantShippingSettings, MerchantStatus, Message, MessageResponse, MessageStatsResponse, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentMethodInfo, PaymentStatus, ProcessPaymentRequest, ProcessPaymentResponse, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, PublicMerchantProfile, PublicMerchantProfileResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SaveBrowsingLocationRequest, SaveBrowsingLocationResponse, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, ShippingOption, ShippingRate, ShippingRateResponse, ShippingSettingsResponse, ShippingZone, ShippingZoneResponse, SortOrder, SuccessResponse, TaxBehavior, TaxBreakdownItem, TaxNexus, TaxNexusResponse, TaxReport, TaxReportDetails, TaxReportPeriodType, TaxReportResponse, TaxReportStatus, TaxRule, TaxRuleResponse, TaxSettings, TaxSettingsResponse, TaxType, TopProduct, TrackBannerRequest, UpdateBannerRequest, UpdateCouponRequest, UpdateFlashSaleRequest, UpdateOrderResponse, UpdateOrderStatusRequest, UpdateProductRequest, UpdateProductVariantRequest, UpdateShipmentRequest, UpdateShippingMethodRequest, UpdateShippingRateRequest, UpdateShippingSettingsRequest, UpdateShippingZoneRequest, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './ecommerce.mjs';
|
|
5
5
|
import 'axios';
|
|
6
6
|
|
|
7
7
|
declare function encodeSlug(slug: string): bigint;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SpotToken, MarginTables, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
|
|
2
2
|
import { Hex } from '@nktkas/hyperliquid/types';
|
|
3
3
|
export { A as AllPerpsMeta, d as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, c as PerpsInstrument, P as PerpsMeta, a as PerpsMetaAndAssetCtxs, b as PerpsUniverse, S as SpotInstrument, g as getAllPerpsMeta } from './client-CgmiTuEX.js';
|
|
4
|
-
export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, BrowsingLocation, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateShippingRequest, CalculateShippingResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateShippingRateRequest, CreateShippingZoneRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerSummary, DeleteBrowsingLocationResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, ExpiringGemBatch, FlashSale, FlashSaleItem, FlashSaleItemInput, FollowActionResponse, FollowStatusResponse, FollowedMerchantSummary, GemHistoryItem, GemHistoryType, GemHistoryTypeFilter, GemSource, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetBrowsingLocationResponse, GetCouponResponse, GetExpiringGemsParams, GetExpiringGemsResponse, GetGemBalanceResponse, GetGemHistoryParams, GetGemHistoryResponse, GetOrderResponse, GetPaymentMethodsResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListFollowingParams, ListFollowingResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMerchantProductsParams, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListShippingRatesResponse, ListShippingZonesResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantEcommerceClient, MerchantProductsResponse, MerchantProfileRequest, MerchantProfileResponse, MerchantShippingSettings, MerchantStatus, Message, MessageResponse, MessageStatsResponse, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentMethodInfo, PaymentStatus, ProcessPaymentRequest, ProcessPaymentResponse, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, PublicMerchantProfile, PublicMerchantProfileResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SaveBrowsingLocationRequest, SaveBrowsingLocationResponse, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, ShippingOption, ShippingRate, ShippingRateResponse, ShippingSettingsResponse, ShippingZone, ShippingZoneResponse, SortOrder, SuccessResponse, TaxBehavior, TaxBreakdownItem, TaxNexus, TaxNexusResponse, TaxReport, TaxReportDetails, TaxReportPeriodType, TaxReportResponse, TaxReportStatus, TaxRule, TaxRuleResponse, TaxSettings, TaxSettingsResponse, TaxType, TopProduct, TrackBannerRequest, UpdateBannerRequest, UpdateCouponRequest, UpdateFlashSaleRequest, UpdateOrderResponse, UpdateOrderStatusRequest, UpdateProductRequest, UpdateProductVariantRequest, UpdateShipmentRequest, UpdateShippingMethodRequest, UpdateShippingRateRequest, UpdateShippingSettingsRequest, UpdateShippingZoneRequest, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './ecommerce.js';
|
|
4
|
+
export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, BrowsingLocation, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateShippingRequest, CalculateShippingResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateShippingRateRequest, CreateShippingZoneRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerSummary, DeleteBrowsingLocationResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, ExpiringGemBatch, FlashSale, FlashSaleAllowanceInfo, FlashSaleItem, FlashSaleItemInput, FollowActionResponse, FollowStatusResponse, FollowedMerchantSummary, GemHistoryItem, GemHistoryType, GemHistoryTypeFilter, GemSource, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetBrowsingLocationResponse, GetCouponResponse, GetExpiringGemsParams, GetExpiringGemsResponse, GetFlashSaleAllowanceParams, GetFlashSaleAllowanceResponse, GetGemBalanceResponse, GetGemHistoryParams, GetGemHistoryResponse, GetOrderResponse, GetPaymentMethodsResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListFollowingParams, ListFollowingResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMerchantProductsParams, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListShippingRatesResponse, ListShippingZonesResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantEcommerceClient, MerchantProductsResponse, MerchantProfileRequest, MerchantProfileResponse, MerchantShippingSettings, MerchantStatus, Message, MessageResponse, MessageStatsResponse, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentMethodInfo, PaymentStatus, ProcessPaymentRequest, ProcessPaymentResponse, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, PublicMerchantProfile, PublicMerchantProfileResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SaveBrowsingLocationRequest, SaveBrowsingLocationResponse, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, ShippingOption, ShippingRate, ShippingRateResponse, ShippingSettingsResponse, ShippingZone, ShippingZoneResponse, SortOrder, SuccessResponse, TaxBehavior, TaxBreakdownItem, TaxNexus, TaxNexusResponse, TaxReport, TaxReportDetails, TaxReportPeriodType, TaxReportResponse, TaxReportStatus, TaxRule, TaxRuleResponse, TaxSettings, TaxSettingsResponse, TaxType, TopProduct, TrackBannerRequest, UpdateBannerRequest, UpdateCouponRequest, UpdateFlashSaleRequest, UpdateOrderResponse, UpdateOrderStatusRequest, UpdateProductRequest, UpdateProductVariantRequest, UpdateShipmentRequest, UpdateShippingMethodRequest, UpdateShippingRateRequest, UpdateShippingSettingsRequest, UpdateShippingZoneRequest, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './ecommerce.js';
|
|
5
5
|
import 'axios';
|
|
6
6
|
|
|
7
7
|
declare function encodeSlug(slug: string): bigint;
|
package/dist/index.js
CHANGED
|
@@ -42723,11 +42723,28 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42723
42723
|
*
|
|
42724
42724
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
42725
42725
|
*
|
|
42726
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
42727
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
42728
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
42729
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
42730
|
+
*
|
|
42726
42731
|
* @param request - Order creation request
|
|
42727
42732
|
* @returns Created order(s) with payment instructions
|
|
42728
42733
|
*
|
|
42729
42734
|
* @example
|
|
42730
42735
|
* ```typescript
|
|
42736
|
+
* // Step 1: Calculate available shipping options
|
|
42737
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
42738
|
+
* merchantId: "merchant_123",
|
|
42739
|
+
* destinationCountry: "US",
|
|
42740
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
42741
|
+
* orderSubtotal: 59.98
|
|
42742
|
+
* });
|
|
42743
|
+
*
|
|
42744
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
42745
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
42746
|
+
*
|
|
42747
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
42731
42748
|
* const result = await client.createOrder({
|
|
42732
42749
|
* items: [
|
|
42733
42750
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -42743,6 +42760,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42743
42760
|
* postalCode: "10001",
|
|
42744
42761
|
* country: "US"
|
|
42745
42762
|
* },
|
|
42763
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
42746
42764
|
* couponCode: "SAVE10"
|
|
42747
42765
|
* });
|
|
42748
42766
|
*
|
|
@@ -43187,6 +43205,35 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43187
43205
|
const queryString = params ? buildQueryString(params) : "";
|
|
43188
43206
|
return this.get(`/api/marketplace/flash-sales/active${queryString}`);
|
|
43189
43207
|
}
|
|
43208
|
+
/**
|
|
43209
|
+
* Get flash sale allowance
|
|
43210
|
+
*
|
|
43211
|
+
* Fetches user's remaining purchase allowance for flash sale items.
|
|
43212
|
+
* Used to enforce per-customer purchase limits.
|
|
43213
|
+
*
|
|
43214
|
+
* @param params - Request params with product IDs
|
|
43215
|
+
* @returns Allowance info for each product
|
|
43216
|
+
*
|
|
43217
|
+
* @example
|
|
43218
|
+
* ```typescript
|
|
43219
|
+
* const result = await client.getFlashSaleAllowance({
|
|
43220
|
+
* productIds: ["prod_123", "prod_456"]
|
|
43221
|
+
* });
|
|
43222
|
+
*
|
|
43223
|
+
* Object.entries(result.allowances).forEach(([productId, info]) => {
|
|
43224
|
+
* if (info.limitPerCustomer !== null) {
|
|
43225
|
+
* console.log(`Product ${productId}:`);
|
|
43226
|
+
* console.log(` Limit: ${info.limitPerCustomer} per customer`);
|
|
43227
|
+
* console.log(` You've purchased: ${info.purchased}`);
|
|
43228
|
+
* console.log(` You can buy: ${info.remaining} more`);
|
|
43229
|
+
* }
|
|
43230
|
+
* });
|
|
43231
|
+
* ```
|
|
43232
|
+
*/
|
|
43233
|
+
async getFlashSaleAllowance(params) {
|
|
43234
|
+
const queryString = buildQueryString({ productIds: params.productIds.join(",") });
|
|
43235
|
+
return this.get(`/api/marketplace/flash-sales/allowance${queryString}`);
|
|
43236
|
+
}
|
|
43190
43237
|
// ============================================================================
|
|
43191
43238
|
// Merchant Storefront API
|
|
43192
43239
|
// ============================================================================
|
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-CAU4QLVH.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';
|
|
@@ -22,6 +22,7 @@ import type {
|
|
|
22
22
|
TrackBannerRequest,
|
|
23
23
|
SendMessageRequest,
|
|
24
24
|
ListActiveFlashSalesParams,
|
|
25
|
+
GetFlashSaleAllowanceParams,
|
|
25
26
|
ListMerchantProductsParams,
|
|
26
27
|
ListFollowingParams,
|
|
27
28
|
CalculateShippingRequest,
|
|
@@ -51,6 +52,7 @@ import type {
|
|
|
51
52
|
MessageStatsResponse,
|
|
52
53
|
MessageResponse,
|
|
53
54
|
ActiveFlashSalesResponse,
|
|
55
|
+
GetFlashSaleAllowanceResponse,
|
|
54
56
|
GetPaymentMethodsResponse,
|
|
55
57
|
PublicMerchantProfileResponse,
|
|
56
58
|
MerchantProductsResponse,
|
|
@@ -176,11 +178,28 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
176
178
|
*
|
|
177
179
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
178
180
|
*
|
|
181
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
182
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
183
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
184
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
185
|
+
*
|
|
179
186
|
* @param request - Order creation request
|
|
180
187
|
* @returns Created order(s) with payment instructions
|
|
181
188
|
*
|
|
182
189
|
* @example
|
|
183
190
|
* ```typescript
|
|
191
|
+
* // Step 1: Calculate available shipping options
|
|
192
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
193
|
+
* merchantId: "merchant_123",
|
|
194
|
+
* destinationCountry: "US",
|
|
195
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
196
|
+
* orderSubtotal: 59.98
|
|
197
|
+
* });
|
|
198
|
+
*
|
|
199
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
200
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
201
|
+
*
|
|
202
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
184
203
|
* const result = await client.createOrder({
|
|
185
204
|
* items: [
|
|
186
205
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -196,6 +215,7 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
196
215
|
* postalCode: "10001",
|
|
197
216
|
* country: "US"
|
|
198
217
|
* },
|
|
218
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
199
219
|
* couponCode: "SAVE10"
|
|
200
220
|
* });
|
|
201
221
|
*
|
|
@@ -684,6 +704,36 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
684
704
|
const queryString = params ? buildQueryString(params) : "";
|
|
685
705
|
return this.get(`/api/marketplace/flash-sales/active${queryString}`);
|
|
686
706
|
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Get flash sale allowance
|
|
710
|
+
*
|
|
711
|
+
* Fetches user's remaining purchase allowance for flash sale items.
|
|
712
|
+
* Used to enforce per-customer purchase limits.
|
|
713
|
+
*
|
|
714
|
+
* @param params - Request params with product IDs
|
|
715
|
+
* @returns Allowance info for each product
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* ```typescript
|
|
719
|
+
* const result = await client.getFlashSaleAllowance({
|
|
720
|
+
* productIds: ["prod_123", "prod_456"]
|
|
721
|
+
* });
|
|
722
|
+
*
|
|
723
|
+
* Object.entries(result.allowances).forEach(([productId, info]) => {
|
|
724
|
+
* if (info.limitPerCustomer !== null) {
|
|
725
|
+
* console.log(`Product ${productId}:`);
|
|
726
|
+
* console.log(` Limit: ${info.limitPerCustomer} per customer`);
|
|
727
|
+
* console.log(` You've purchased: ${info.purchased}`);
|
|
728
|
+
* console.log(` You can buy: ${info.remaining} more`);
|
|
729
|
+
* }
|
|
730
|
+
* });
|
|
731
|
+
* ```
|
|
732
|
+
*/
|
|
733
|
+
async getFlashSaleAllowance(params: GetFlashSaleAllowanceParams): Promise<GetFlashSaleAllowanceResponse> {
|
|
734
|
+
const queryString = buildQueryString({ productIds: params.productIds.join(",") });
|
|
735
|
+
return this.get(`/api/marketplace/flash-sales/allowance${queryString}`);
|
|
736
|
+
}
|
|
687
737
|
|
|
688
738
|
// ============================================================================
|
|
689
739
|
// Merchant Storefront API
|
|
@@ -869,17 +869,29 @@ export interface ShippingRate extends BaseEntity {
|
|
|
869
869
|
|
|
870
870
|
/**
|
|
871
871
|
* Shipping option (calculated for checkout)
|
|
872
|
+
*
|
|
873
|
+
* Use `rateId` when creating orders - the server will validate and calculate cost.
|
|
872
874
|
*/
|
|
873
875
|
export interface ShippingOption {
|
|
874
|
-
/** Rate ID */
|
|
875
|
-
|
|
876
|
-
/** Rate name */
|
|
877
|
-
name: string;
|
|
878
|
-
/** Calculated cost in USDC */
|
|
879
|
-
cost: number;
|
|
880
|
-
/** Estimated delivery string */
|
|
881
|
-
estimatedDelivery: string;
|
|
876
|
+
/** Rate ID - use this when creating orders */
|
|
877
|
+
rateId: string;
|
|
882
878
|
/** Zone name */
|
|
883
879
|
zoneName: string;
|
|
880
|
+
/** Rate name (e.g., "Standard", "Express") */
|
|
881
|
+
rateName: string;
|
|
882
|
+
/** Base rate in USDC */
|
|
883
|
+
baseRate: number;
|
|
884
|
+
/** Per-kg rate in USDC */
|
|
885
|
+
perKgRate: number;
|
|
886
|
+
/** Calculated total cost in USDC (for display only - server recalculates) */
|
|
887
|
+
calculatedCost: number;
|
|
888
|
+
/** Whether free shipping applies */
|
|
889
|
+
isFree: boolean;
|
|
890
|
+
/** Estimated delivery string (e.g., "5-7 business days") */
|
|
891
|
+
estimatedDelivery: string | null;
|
|
892
|
+
/** Minimum delivery days */
|
|
893
|
+
minDeliveryDays: number | null;
|
|
894
|
+
/** Maximum delivery days */
|
|
895
|
+
maxDeliveryDays: number | null;
|
|
884
896
|
}
|
|
885
897
|
|
|
@@ -150,13 +150,26 @@ export interface CreateOrderRequest {
|
|
|
150
150
|
couponCode?: string;
|
|
151
151
|
/** Idempotency key */
|
|
152
152
|
idempotencyKey?: string;
|
|
153
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Selected shipping rate ID (from shipping calculator)
|
|
155
|
+
* The server will validate this rate and calculate the cost server-side.
|
|
156
|
+
* SECURITY: The cost is never trusted from the frontend.
|
|
157
|
+
*/
|
|
158
|
+
shippingRateId?: string;
|
|
159
|
+
|
|
160
|
+
// =====================================================
|
|
161
|
+
// DEPRECATED FIELDS - Do not use
|
|
162
|
+
// These fields are ignored by the server for security reasons.
|
|
163
|
+
// Shipping cost must be calculated server-side using shippingRateId.
|
|
164
|
+
// =====================================================
|
|
165
|
+
|
|
166
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
154
167
|
shippingMethod?: string;
|
|
155
|
-
/**
|
|
168
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
156
169
|
shippingCost?: number;
|
|
157
|
-
/**
|
|
170
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
158
171
|
shippingZone?: string;
|
|
159
|
-
/**
|
|
172
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
160
173
|
estimatedDelivery?: string;
|
|
161
174
|
}
|
|
162
175
|
|
|
@@ -547,6 +560,15 @@ export interface ListActiveFlashSalesParams {
|
|
|
547
560
|
merchantId?: string;
|
|
548
561
|
}
|
|
549
562
|
|
|
563
|
+
/**
|
|
564
|
+
* Get flash sale allowance request
|
|
565
|
+
* Get user's remaining purchase allowance for flash sale items
|
|
566
|
+
*/
|
|
567
|
+
export interface GetFlashSaleAllowanceParams {
|
|
568
|
+
/** Comma-separated list of product IDs */
|
|
569
|
+
productIds: string[];
|
|
570
|
+
}
|
|
571
|
+
|
|
550
572
|
/**
|
|
551
573
|
* Flash sale item input
|
|
552
574
|
*/
|
|
@@ -951,6 +951,36 @@ export interface ActiveFlashSalesResponse {
|
|
|
951
951
|
serverTime: string;
|
|
952
952
|
}
|
|
953
953
|
|
|
954
|
+
/**
|
|
955
|
+
* Flash sale allowance info for a single product
|
|
956
|
+
*/
|
|
957
|
+
export interface FlashSaleAllowanceInfo {
|
|
958
|
+
/** Flash sale ID */
|
|
959
|
+
flashSaleId: string;
|
|
960
|
+
/** Limit per customer (null = no limit) */
|
|
961
|
+
limitPerCustomer: number | null;
|
|
962
|
+
/** Quantity already purchased by user */
|
|
963
|
+
purchased: number;
|
|
964
|
+
/** Remaining quantity user can purchase (null = no limit) */
|
|
965
|
+
remaining: number | null;
|
|
966
|
+
/** Current sale price */
|
|
967
|
+
salePrice: string;
|
|
968
|
+
/** Maximum quantity available in flash sale (null = unlimited) */
|
|
969
|
+
maxQuantity: number | null;
|
|
970
|
+
/** Remaining quantity in flash sale (null = unlimited) */
|
|
971
|
+
remainingQuantity: number | null;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Get flash sale allowance response
|
|
976
|
+
*/
|
|
977
|
+
export interface GetFlashSaleAllowanceResponse {
|
|
978
|
+
/** Allowances by product ID */
|
|
979
|
+
allowances: Record<string, FlashSaleAllowanceInfo>;
|
|
980
|
+
/** Whether user is authenticated */
|
|
981
|
+
authenticated: boolean;
|
|
982
|
+
}
|
|
983
|
+
|
|
954
984
|
// ============================================
|
|
955
985
|
// SHIPPING RESPONSES
|
|
956
986
|
// ============================================
|