@basedone/core 0.2.7 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/{chunk-L63E7FZC.mjs → chunk-35WGIB5F.mjs} +165 -1
  2. package/dist/{client-CgmiTuEX.d.mts → client-BQzYwHDY.d.mts} +5 -2
  3. package/dist/{client-CgmiTuEX.d.ts → client-BQzYwHDY.d.ts} +5 -2
  4. package/dist/ecommerce.d.mts +195 -2
  5. package/dist/ecommerce.d.ts +195 -2
  6. package/dist/ecommerce.js +176 -0
  7. package/dist/ecommerce.mjs +1 -2
  8. package/dist/index.d.mts +114 -160
  9. package/dist/index.d.ts +114 -160
  10. package/dist/index.js +462 -41454
  11. package/dist/index.mjs +246 -639
  12. package/dist/react.d.mts +1 -1
  13. package/dist/react.d.ts +1 -1
  14. package/dist/react.mjs +0 -1
  15. package/index.ts +3 -0
  16. package/lib/abstraction/api.ts +106 -0
  17. package/lib/abstraction/index.ts +3 -0
  18. package/lib/abstraction/ratio.ts +61 -0
  19. package/lib/abstraction/types.ts +73 -0
  20. package/lib/constants/admin.ts +30 -0
  21. package/lib/ecommerce/client/customer.ts +42 -0
  22. package/lib/ecommerce/index.ts +14 -0
  23. package/lib/ecommerce/types/entities.ts +70 -0
  24. package/lib/ecommerce/types/enums.ts +37 -1
  25. package/lib/ecommerce/types/requests.ts +2 -0
  26. package/lib/ecommerce/types/responses.ts +28 -0
  27. package/lib/ecommerce/utils/orderStateMachine.ts +197 -0
  28. package/lib/hip3/market-info.ts +5 -1
  29. package/lib/hip3/utils.ts +2 -0
  30. package/lib/meta/metadata.ts +0 -666
  31. package/lib/types.ts +29 -0
  32. package/package.json +1 -1
  33. package/dist/chunk-4UEJOM6W.mjs +0 -7
  34. package/dist/meta-JB5ITE27.mjs +0 -1390
  35. package/dist/meta-UOGUG3OW.mjs +0 -1504
  36. package/dist/perpDexs-3LRJ5ZHM.mjs +0 -288
  37. package/dist/perpDexs-4ISLD7NX.mjs +0 -2975
  38. package/dist/spotMeta-GHXX7C5M.mjs +0 -6968
  39. package/dist/spotMeta-IBBUP2SG.mjs +0 -27592
  40. package/dist/staticMeta-GM7T3OYL.mjs +0 -20
  41. package/dist/staticMeta-QV2KMX57.mjs +0 -22
@@ -192,6 +192,8 @@ declare enum OrderStatus {
192
192
  DELIVERED = "DELIVERED",
193
193
  /** Order has been cancelled */
194
194
  CANCELLED = "CANCELLED",
195
+ /** Payment settled / escrow released to merchant */
196
+ SETTLED = "SETTLED",
195
197
  /** Order is confirmed (legacy status) */
196
198
  CONFIRMED = "CONFIRMED",
197
199
  /** Order is completed (legacy status) */
@@ -236,6 +238,36 @@ declare enum MerchantStatus {
236
238
  /** Merchant is pending approval */
237
239
  PENDING = "PENDING"
238
240
  }
241
+ /**
242
+ * Merchant business type enum
243
+ */
244
+ declare enum MerchantBusinessType {
245
+ /** Individual seller */
246
+ INDIVIDUAL = "INDIVIDUAL",
247
+ /** Registered company */
248
+ COMPANY = "COMPANY",
249
+ /** Partnership */
250
+ PARTNERSHIP = "PARTNERSHIP",
251
+ /** Non-profit organization */
252
+ NON_PROFIT = "NON_PROFIT"
253
+ }
254
+ /**
255
+ * Merchant return policy type enum
256
+ */
257
+ declare enum MerchantReturnPolicyType {
258
+ /** No returns accepted */
259
+ NO_RETURNS = "NO_RETURNS",
260
+ /** Exchange for same/similar item only */
261
+ EXCHANGE_ONLY = "EXCHANGE_ONLY",
262
+ /** Refund as store credit only */
263
+ STORE_CREDIT = "STORE_CREDIT",
264
+ /** Full refund available */
265
+ FULL_REFUND = "FULL_REFUND",
266
+ /** Partial refund (restocking fee may apply) */
267
+ PARTIAL_REFUND = "PARTIAL_REFUND",
268
+ /** Handled on a case-by-case basis */
269
+ CASE_BY_CASE = "CASE_BY_CASE"
270
+ }
239
271
  /**
240
272
  * Shipment status enum
241
273
  */
@@ -407,8 +439,10 @@ declare enum ProductSortBy {
407
439
  PRICE_ASC = "price_asc",
408
440
  /** Sort by price (high to low) */
409
441
  PRICE_DESC = "price_desc",
410
- /** Sort by popularity */
442
+ /** Sort by popularity (views) */
411
443
  POPULAR = "popular",
444
+ /** Sort by best selling (sold quantity) */
445
+ BEST_SELLING = "best_selling",
412
446
  /** Sort by featured status */
413
447
  FEATURED = "featured",
414
448
  /** Sort by proximity to user location (requires lat/lng) */
@@ -532,6 +566,21 @@ interface ProductVariant extends BaseEntity {
532
566
  /** Sort order */
533
567
  sortOrder: number;
534
568
  }
569
+ /**
570
+ * Social links for merchant profile
571
+ */
572
+ interface MerchantSocialLinks {
573
+ /** Twitter/X profile URL */
574
+ twitter?: string | null;
575
+ /** Instagram profile URL */
576
+ instagram?: string | null;
577
+ /** Facebook page URL */
578
+ facebook?: string | null;
579
+ /** Discord server invite URL */
580
+ discord?: string | null;
581
+ /** Telegram channel/group URL */
582
+ telegram?: string | null;
583
+ }
535
584
  /**
536
585
  * Merchant entity
537
586
  */
@@ -546,6 +595,32 @@ interface Merchant extends BaseEntity {
546
595
  payoutAddress: string;
547
596
  /** Merchant status */
548
597
  status: MerchantStatus;
598
+ /** Contact email for notifications and customer inquiries */
599
+ email?: string | null;
600
+ /** Contact phone number */
601
+ phone?: string | null;
602
+ /** Store website URL */
603
+ website?: string | null;
604
+ /** Business type (individual, company, etc.) */
605
+ businessType?: MerchantBusinessType;
606
+ /** Store logo/avatar URL */
607
+ logoUrl?: string | null;
608
+ /** Store banner image URL */
609
+ bannerUrl?: string | null;
610
+ /** Social media links */
611
+ socialLinks?: MerchantSocialLinks | null;
612
+ /** Return policy type */
613
+ returnPolicyType?: MerchantReturnPolicyType;
614
+ /** Custom return policy details/text */
615
+ returnPolicyDetails?: string | null;
616
+ /** Return window in days (e.g., 30) */
617
+ returnWindowDays?: number | null;
618
+ /** ISO 2-letter country code (for tax/shipping) */
619
+ country?: string | null;
620
+ /** City name */
621
+ city?: string | null;
622
+ /** Street address */
623
+ addressLine1?: string | null;
549
624
  }
550
625
  /**
551
626
  * Shipping address
@@ -699,6 +774,20 @@ interface Order extends BaseEntity {
699
774
  };
700
775
  /** Order events */
701
776
  events?: OrderEvent[];
777
+ /** Expected ship date */
778
+ expectedShipDate?: string | null;
779
+ /** Estimated delivery date */
780
+ estimatedDeliveryDate?: string | null;
781
+ /** Estimated delivery days */
782
+ estimatedDeliveryDays?: number | null;
783
+ /** Auto-complete deadline */
784
+ autoCompleteDeadline?: string | null;
785
+ /** Customer confirmed receipt timestamp */
786
+ customerConfirmedAt?: string | null;
787
+ /** Auto-completed timestamp */
788
+ autoCompletedAt?: string | null;
789
+ /** Status transition timestamps */
790
+ statusTransitions?: Record<string, string> | null;
702
791
  }
703
792
  /**
704
793
  * Order event entity
@@ -1424,6 +1513,8 @@ interface CreateOrderRequest {
1424
1513
  interface ListOrdersParams extends PaginationParams {
1425
1514
  /** Filter by status */
1426
1515
  status?: OrderStatus;
1516
+ /** Filter by merchant ID (for godview access) */
1517
+ merchantId?: string;
1427
1518
  }
1428
1519
  /**
1429
1520
  * Update order status request
@@ -2215,6 +2306,10 @@ interface ValidateDiscountResponse {
2215
2306
  /** Discount amount */
2216
2307
  discountAmount: number;
2217
2308
  };
2309
+ /** Merchant ID the discount belongs to */
2310
+ merchantId?: string;
2311
+ /** Merchant name the discount belongs to */
2312
+ merchantName?: string | null;
2218
2313
  /** Subtotal */
2219
2314
  subtotal?: number;
2220
2315
  /** Total */
@@ -3134,6 +3229,30 @@ interface CashAccountBalanceResponse {
3134
3229
  /** Currency code (e.g., "USD") */
3135
3230
  currency: string;
3136
3231
  }
3232
+ interface CustomerNotification {
3233
+ id: string;
3234
+ type: string;
3235
+ title: string;
3236
+ message: string;
3237
+ metadata: Record<string, any> | null;
3238
+ isRead: boolean;
3239
+ createdAt: string;
3240
+ }
3241
+ interface CustomerNotificationsResponse {
3242
+ notifications: CustomerNotification[];
3243
+ stats: {
3244
+ unread: number;
3245
+ };
3246
+ pagination: {
3247
+ total: number;
3248
+ limit: number;
3249
+ offset: number;
3250
+ hasMore: boolean;
3251
+ };
3252
+ }
3253
+ interface MarkNotificationsReadResponse {
3254
+ updated: number;
3255
+ }
3137
3256
  interface DeliveryAddressResponse {
3138
3257
  name: string;
3139
3258
  phoneNumber: string;
@@ -3940,6 +4059,32 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
3940
4059
  * ```
3941
4060
  */
3942
4061
  getDeliveryAddress(): Promise<DeliveryAddressResponse>;
4062
+ /**
4063
+ * Get user's Hyperliquid USDC balance (perp withdrawable)
4064
+ *
4065
+ * Returns the USDC balance available for escrow deposits via usdSend.
4066
+ *
4067
+ * @returns Balance response with amount and currency
4068
+ */
4069
+ getUsdcBalance(): Promise<CashAccountBalanceResponse>;
4070
+ /**
4071
+ * List notifications for the authenticated customer
4072
+ *
4073
+ * @param params - Query parameters for filtering and pagination
4074
+ * @returns Paginated list of notifications with unread count
4075
+ */
4076
+ listNotifications(params?: {
4077
+ limit?: number;
4078
+ offset?: number;
4079
+ unreadOnly?: boolean;
4080
+ }): Promise<CustomerNotificationsResponse>;
4081
+ /**
4082
+ * Mark notifications as read
4083
+ *
4084
+ * @param ids - Specific notification IDs to mark as read. If omitted, marks all as read.
4085
+ * @returns Count of updated notifications
4086
+ */
4087
+ markNotificationsAsRead(ids?: string[]): Promise<MarkNotificationsReadResponse>;
3943
4088
  }
3944
4089
 
3945
4090
  /**
@@ -5654,4 +5799,52 @@ declare function calculateDiscountAmount(price: number, discountType: "PERCENTAG
5654
5799
  */
5655
5800
  declare function calculateFinalPrice(price: number, discountType: "PERCENTAGE" | "FIXED_AMOUNT", discountValue: number): number;
5656
5801
 
5657
- 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 CashAccountBalanceResponse, 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, type DeliveryAddressResponse, 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 };
5802
+ /** Detect pickup / on-site-collection shipping methods (normalised matching) */
5803
+ declare function isPickupOrder(shippingMethod?: string | null, shippingRateId?: string | null): boolean;
5804
+ /**
5805
+ * Canonical order status transitions.
5806
+ *
5807
+ * Buyer-protected escrow flow:
5808
+ * CREATED → PAYMENT_RESERVED → MERCHANT_ACCEPTED → SHIPPED → DELIVERED → SETTLED
5809
+ *
5810
+ * Cancellation is allowed from any non-terminal state except DELIVERED (already in settlement).
5811
+ */
5812
+ declare const ORDER_STATUS_TRANSITIONS: Partial<Record<OrderStatus, OrderStatus[]>>;
5813
+ /**
5814
+ * Validate whether transitioning from `currentStatus` to `newStatus` is allowed.
5815
+ *
5816
+ * For pickup / on-site-collection orders, MERCHANT_ACCEPTED → DELIVERED and
5817
+ * SETTLED → DELIVERED are permitted (skipping SHIPPED).
5818
+ */
5819
+ declare function validateStatusTransition(currentStatus: string, newStatus: string, options?: {
5820
+ shippingMethod?: string | null;
5821
+ shippingRateId?: string | null;
5822
+ }): {
5823
+ valid: boolean;
5824
+ error?: string;
5825
+ };
5826
+ /**
5827
+ * Return the list of statuses reachable from `currentStatus`.
5828
+ * For pickup orders, DELIVERED is added when on MERCHANT_ACCEPTED or SETTLED.
5829
+ */
5830
+ declare function getNextStatuses(currentStatus: string, options?: {
5831
+ shippingMethod?: string | null;
5832
+ shippingRateId?: string | null;
5833
+ }): string[];
5834
+ /** Human-readable label for a status. */
5835
+ declare function getStatusLabel(status: string): string;
5836
+ /** UI colour key for a status. */
5837
+ declare function getStatusColor(status: string): string;
5838
+ /** Whether the order can be cancelled from its current status. */
5839
+ declare function canCancelOrder(currentStatus: string): boolean;
5840
+ /** Whether tracking info is required for a status change. */
5841
+ declare function requiresTrackingInfo(newStatus: string, options?: {
5842
+ shippingMethod?: string | null;
5843
+ shippingRateId?: string | null;
5844
+ }): boolean;
5845
+ /** Whether a status change should trigger customer notification. */
5846
+ declare function shouldNotifyCustomer(newStatus: string): boolean;
5847
+ /** Status progression percentage (for progress bars). */
5848
+ declare function getStatusProgress(status: string): number;
5849
+
5850
+ 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 CashAccountBalanceResponse, 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 CustomerNotification, type CustomerNotificationsResponse, type CustomerSummary, type DeleteBrowsingLocationResponse, type DeliveryAddressResponse, 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 MarkNotificationsReadResponse, type MediaAsset, type MediaAssetResponse, type Merchant, MerchantBusinessType, MerchantEcommerceClient, type MerchantProductsResponse, type MerchantProfileRequest, type MerchantProfileResponse, MerchantReturnPolicyType, type MerchantShippingSettings, type MerchantSocialLinks, MerchantStatus, type Message, type MessageResponse, type MessageStatsResponse, ORDER_STATUS_TRANSITIONS, 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, canCancelOrder, formatPrice, getBackoffDelay, getNextStatuses, getStatusColor, getStatusLabel, getStatusProgress, isPickupOrder, isRetryableError, isValidAddress, isValidEmail, parseError, requiresTrackingInfo, retryWithBackoff, shouldNotifyCustomer, sleep, truncateAddress, validateStatusTransition };
package/dist/ecommerce.js CHANGED
@@ -1230,6 +1230,38 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
1230
1230
  async getDeliveryAddress() {
1231
1231
  return this.get("/api/basedpay/delivery-address");
1232
1232
  }
1233
+ /**
1234
+ * Get user's Hyperliquid USDC balance (perp withdrawable)
1235
+ *
1236
+ * Returns the USDC balance available for escrow deposits via usdSend.
1237
+ *
1238
+ * @returns Balance response with amount and currency
1239
+ */
1240
+ async getUsdcBalance() {
1241
+ return this.get("/api/marketplace/usdc-balance");
1242
+ }
1243
+ // ============================================================================
1244
+ // Notifications API
1245
+ // ============================================================================
1246
+ /**
1247
+ * List notifications for the authenticated customer
1248
+ *
1249
+ * @param params - Query parameters for filtering and pagination
1250
+ * @returns Paginated list of notifications with unread count
1251
+ */
1252
+ async listNotifications(params) {
1253
+ const queryString = params ? buildQueryString(params) : "";
1254
+ return this.get(`/api/marketplace/notifications${queryString}`);
1255
+ }
1256
+ /**
1257
+ * Mark notifications as read
1258
+ *
1259
+ * @param ids - Specific notification IDs to mark as read. If omitted, marks all as read.
1260
+ * @returns Count of updated notifications
1261
+ */
1262
+ async markNotificationsAsRead(ids) {
1263
+ return this.patch("/api/marketplace/notifications/read", { ids });
1264
+ }
1233
1265
  };
1234
1266
 
1235
1267
  // lib/ecommerce/client/merchant.ts
@@ -2775,6 +2807,7 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
2775
2807
  OrderStatus2["SHIPPED"] = "SHIPPED";
2776
2808
  OrderStatus2["DELIVERED"] = "DELIVERED";
2777
2809
  OrderStatus2["CANCELLED"] = "CANCELLED";
2810
+ OrderStatus2["SETTLED"] = "SETTLED";
2778
2811
  OrderStatus2["CONFIRMED"] = "CONFIRMED";
2779
2812
  OrderStatus2["COMPLETED"] = "COMPLETED";
2780
2813
  return OrderStatus2;
@@ -2800,6 +2833,22 @@ var MerchantStatus = /* @__PURE__ */ ((MerchantStatus2) => {
2800
2833
  MerchantStatus2["PENDING"] = "PENDING";
2801
2834
  return MerchantStatus2;
2802
2835
  })(MerchantStatus || {});
2836
+ var MerchantBusinessType = /* @__PURE__ */ ((MerchantBusinessType2) => {
2837
+ MerchantBusinessType2["INDIVIDUAL"] = "INDIVIDUAL";
2838
+ MerchantBusinessType2["COMPANY"] = "COMPANY";
2839
+ MerchantBusinessType2["PARTNERSHIP"] = "PARTNERSHIP";
2840
+ MerchantBusinessType2["NON_PROFIT"] = "NON_PROFIT";
2841
+ return MerchantBusinessType2;
2842
+ })(MerchantBusinessType || {});
2843
+ var MerchantReturnPolicyType = /* @__PURE__ */ ((MerchantReturnPolicyType2) => {
2844
+ MerchantReturnPolicyType2["NO_RETURNS"] = "NO_RETURNS";
2845
+ MerchantReturnPolicyType2["EXCHANGE_ONLY"] = "EXCHANGE_ONLY";
2846
+ MerchantReturnPolicyType2["STORE_CREDIT"] = "STORE_CREDIT";
2847
+ MerchantReturnPolicyType2["FULL_REFUND"] = "FULL_REFUND";
2848
+ MerchantReturnPolicyType2["PARTIAL_REFUND"] = "PARTIAL_REFUND";
2849
+ MerchantReturnPolicyType2["CASE_BY_CASE"] = "CASE_BY_CASE";
2850
+ return MerchantReturnPolicyType2;
2851
+ })(MerchantReturnPolicyType || {});
2803
2852
  var ShipmentStatus = /* @__PURE__ */ ((ShipmentStatus2) => {
2804
2853
  ShipmentStatus2["PENDING"] = "PENDING";
2805
2854
  ShipmentStatus2["SHIPPED"] = "SHIPPED";
@@ -2892,6 +2941,7 @@ var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
2892
2941
  ProductSortBy2["PRICE_ASC"] = "price_asc";
2893
2942
  ProductSortBy2["PRICE_DESC"] = "price_desc";
2894
2943
  ProductSortBy2["POPULAR"] = "popular";
2944
+ ProductSortBy2["BEST_SELLING"] = "best_selling";
2895
2945
  ProductSortBy2["FEATURED"] = "featured";
2896
2946
  ProductSortBy2["NEARBY"] = "nearby";
2897
2947
  return ProductSortBy2;
@@ -2903,6 +2953,120 @@ var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
2903
2953
  return ReviewSortBy2;
2904
2954
  })(ReviewSortBy || {});
2905
2955
 
2956
+ // lib/ecommerce/utils/orderStateMachine.ts
2957
+ function isPickupOrder(shippingMethod, shippingRateId) {
2958
+ if (shippingRateId && shippingRateId.trim().toUpperCase() === "PICKUP") {
2959
+ return true;
2960
+ }
2961
+ if (!shippingMethod) return false;
2962
+ const normalized = shippingMethod.trim().toLowerCase().replace(/[\s-]+/g, " ");
2963
+ return normalized === "pickup" || normalized === "on site collection" || normalized === "onsite collection";
2964
+ }
2965
+ var ORDER_STATUS_TRANSITIONS = {
2966
+ ["CREATED" /* CREATED */]: [
2967
+ "PAYMENT_RESERVED" /* PAYMENT_RESERVED */,
2968
+ "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */,
2969
+ "CANCELLED" /* CANCELLED */
2970
+ ],
2971
+ ["PAYMENT_RESERVED" /* PAYMENT_RESERVED */]: [
2972
+ "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */,
2973
+ "CANCELLED" /* CANCELLED */
2974
+ ],
2975
+ ["MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */]: [
2976
+ "SHIPPED" /* SHIPPED */,
2977
+ "CANCELLED" /* CANCELLED */
2978
+ ],
2979
+ // Backward compat for existing SETTLED orders created before escrow change
2980
+ // Note: CANCELLED removed — settled orders have funds paid out, no clawback mechanism
2981
+ ["SETTLED" /* SETTLED */]: ["SHIPPED" /* SHIPPED */],
2982
+ ["SHIPPED" /* SHIPPED */]: ["DELIVERED" /* DELIVERED */, "CANCELLED" /* CANCELLED */],
2983
+ // Settlement triggered on delivery (buyer-protected escrow)
2984
+ ["DELIVERED" /* DELIVERED */]: ["SETTLED" /* SETTLED */],
2985
+ // Terminal states
2986
+ ["CANCELLED" /* CANCELLED */]: []
2987
+ };
2988
+ function validateStatusTransition(currentStatus, newStatus, options) {
2989
+ if (isPickupOrder(options?.shippingMethod, options?.shippingRateId) && (currentStatus === "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */ || currentStatus === "SETTLED" /* SETTLED */) && newStatus === "DELIVERED" /* DELIVERED */) {
2990
+ return { valid: true };
2991
+ }
2992
+ const allowed = ORDER_STATUS_TRANSITIONS[currentStatus] ?? [];
2993
+ if (!allowed.includes(newStatus)) {
2994
+ if (allowed.length === 0) {
2995
+ return {
2996
+ valid: false,
2997
+ error: `Cannot change status from ${currentStatus} \u2014 this is a final state`
2998
+ };
2999
+ }
3000
+ return {
3001
+ valid: false,
3002
+ error: `Cannot transition from ${currentStatus} to ${newStatus}. Allowed: ${allowed.join(", ")}`
3003
+ };
3004
+ }
3005
+ return { valid: true };
3006
+ }
3007
+ function getNextStatuses(currentStatus, options) {
3008
+ const base = [
3009
+ ...ORDER_STATUS_TRANSITIONS[currentStatus] ?? []
3010
+ ];
3011
+ if (isPickupOrder(options?.shippingMethod, options?.shippingRateId) && (currentStatus === "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */ || currentStatus === "SETTLED" /* SETTLED */) && !base.includes("DELIVERED" /* DELIVERED */)) {
3012
+ base.push("DELIVERED" /* DELIVERED */);
3013
+ }
3014
+ return base;
3015
+ }
3016
+ function getStatusLabel(status) {
3017
+ const labels = {
3018
+ CREATED: "Created",
3019
+ PAYMENT_RESERVED: "Payment Reserved",
3020
+ MERCHANT_ACCEPTED: "Accepted",
3021
+ SETTLED: "Completed (Paid)",
3022
+ SHIPPED: "Shipped",
3023
+ DELIVERED: "Delivered",
3024
+ CANCELLED: "Cancelled"
3025
+ };
3026
+ return labels[status] || status;
3027
+ }
3028
+ function getStatusColor(status) {
3029
+ const colors = {
3030
+ CREATED: "gray",
3031
+ PAYMENT_RESERVED: "blue",
3032
+ MERCHANT_ACCEPTED: "purple",
3033
+ SETTLED: "indigo",
3034
+ SHIPPED: "yellow",
3035
+ DELIVERED: "green",
3036
+ CANCELLED: "red"
3037
+ };
3038
+ return colors[status] || "gray";
3039
+ }
3040
+ function canCancelOrder(currentStatus) {
3041
+ return ORDER_STATUS_TRANSITIONS[currentStatus]?.includes(
3042
+ "CANCELLED" /* CANCELLED */
3043
+ ) ?? false;
3044
+ }
3045
+ function requiresTrackingInfo(newStatus, options) {
3046
+ if (newStatus !== "SHIPPED" /* SHIPPED */) return false;
3047
+ return !isPickupOrder(options?.shippingMethod, options?.shippingRateId);
3048
+ }
3049
+ function shouldNotifyCustomer(newStatus) {
3050
+ return [
3051
+ "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */,
3052
+ "SHIPPED" /* SHIPPED */,
3053
+ "DELIVERED" /* DELIVERED */,
3054
+ "CANCELLED" /* CANCELLED */
3055
+ ].includes(newStatus);
3056
+ }
3057
+ function getStatusProgress(status) {
3058
+ const progressMap = {
3059
+ CREATED: 10,
3060
+ PAYMENT_RESERVED: 25,
3061
+ MERCHANT_ACCEPTED: 40,
3062
+ SETTLED: 50,
3063
+ SHIPPED: 75,
3064
+ DELIVERED: 100,
3065
+ CANCELLED: 0
3066
+ };
3067
+ return progressMap[status] || 0;
3068
+ }
3069
+
2906
3070
  exports.BannerType = BannerType;
2907
3071
  exports.BaseEcommerceClient = BaseEcommerceClient;
2908
3072
  exports.CustomerEcommerceClient = CustomerEcommerceClient;
@@ -2911,8 +3075,11 @@ exports.DiscountScope = DiscountScope;
2911
3075
  exports.DiscountType = DiscountType;
2912
3076
  exports.EcommerceApiError = EcommerceApiError;
2913
3077
  exports.InventoryAuditAction = InventoryAuditAction;
3078
+ exports.MerchantBusinessType = MerchantBusinessType;
2914
3079
  exports.MerchantEcommerceClient = MerchantEcommerceClient;
3080
+ exports.MerchantReturnPolicyType = MerchantReturnPolicyType;
2915
3081
  exports.MerchantStatus = MerchantStatus;
3082
+ exports.ORDER_STATUS_TRANSITIONS = ORDER_STATUS_TRANSITIONS;
2916
3083
  exports.OrderStatus = OrderStatus;
2917
3084
  exports.PaymentMethod = PaymentMethod;
2918
3085
  exports.PaymentStatus = PaymentStatus;
@@ -2929,12 +3096,21 @@ exports.TaxType = TaxType;
2929
3096
  exports.buildQueryString = buildQueryString;
2930
3097
  exports.calculateDiscountAmount = calculateDiscountAmount;
2931
3098
  exports.calculateFinalPrice = calculateFinalPrice;
3099
+ exports.canCancelOrder = canCancelOrder;
2932
3100
  exports.formatPrice = formatPrice;
2933
3101
  exports.getBackoffDelay = getBackoffDelay;
3102
+ exports.getNextStatuses = getNextStatuses;
3103
+ exports.getStatusColor = getStatusColor;
3104
+ exports.getStatusLabel = getStatusLabel;
3105
+ exports.getStatusProgress = getStatusProgress;
3106
+ exports.isPickupOrder = isPickupOrder;
2934
3107
  exports.isRetryableError = isRetryableError;
2935
3108
  exports.isValidAddress = isValidAddress;
2936
3109
  exports.isValidEmail = isValidEmail;
2937
3110
  exports.parseError = parseError;
3111
+ exports.requiresTrackingInfo = requiresTrackingInfo;
2938
3112
  exports.retryWithBackoff = retryWithBackoff;
3113
+ exports.shouldNotifyCustomer = shouldNotifyCustomer;
2939
3114
  exports.sleep = sleep;
2940
3115
  exports.truncateAddress = truncateAddress;
3116
+ exports.validateStatusTransition = validateStatusTransition;
@@ -1,2 +1 @@
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-L63E7FZC.mjs';
2
- import './chunk-4UEJOM6W.mjs';
1
+ export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantBusinessType, MerchantEcommerceClient, MerchantReturnPolicyType, MerchantStatus, ORDER_STATUS_TRANSITIONS, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, canCancelOrder, formatPrice, getBackoffDelay, getNextStatuses, getStatusColor, getStatusLabel, getStatusProgress, isPickupOrder, isRetryableError, isValidAddress, isValidEmail, parseError, requiresTrackingInfo, retryWithBackoff, shouldNotifyCustomer, sleep, truncateAddress, validateStatusTransition } from './chunk-35WGIB5F.mjs';