@basedone/core 0.2.3 → 0.2.5

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/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, 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, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, FlashSale, FlashSaleItem, FlashSaleItemInput, FollowActionResponse, FollowStatusResponse, FollowedMerchantSummary, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetCouponResponse, 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, 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
@@ -43187,6 +43187,35 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
43187
43187
  const queryString = params ? buildQueryString(params) : "";
43188
43188
  return this.get(`/api/marketplace/flash-sales/active${queryString}`);
43189
43189
  }
43190
+ /**
43191
+ * Get flash sale allowance
43192
+ *
43193
+ * Fetches user's remaining purchase allowance for flash sale items.
43194
+ * Used to enforce per-customer purchase limits.
43195
+ *
43196
+ * @param params - Request params with product IDs
43197
+ * @returns Allowance info for each product
43198
+ *
43199
+ * @example
43200
+ * ```typescript
43201
+ * const result = await client.getFlashSaleAllowance({
43202
+ * productIds: ["prod_123", "prod_456"]
43203
+ * });
43204
+ *
43205
+ * Object.entries(result.allowances).forEach(([productId, info]) => {
43206
+ * if (info.limitPerCustomer !== null) {
43207
+ * console.log(`Product ${productId}:`);
43208
+ * console.log(` Limit: ${info.limitPerCustomer} per customer`);
43209
+ * console.log(` You've purchased: ${info.purchased}`);
43210
+ * console.log(` You can buy: ${info.remaining} more`);
43211
+ * }
43212
+ * });
43213
+ * ```
43214
+ */
43215
+ async getFlashSaleAllowance(params) {
43216
+ const queryString = buildQueryString({ productIds: params.productIds.join(",") });
43217
+ return this.get(`/api/marketplace/flash-sales/allowance${queryString}`);
43218
+ }
43190
43219
  // ============================================================================
43191
43220
  // Merchant Storefront API
43192
43221
  // ============================================================================
@@ -43324,6 +43353,148 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
43324
43353
  async getPaymentMethods() {
43325
43354
  return this.get("/api/marketplace/payments/methods");
43326
43355
  }
43356
+ // ============================================================================
43357
+ // GEM System API
43358
+ // ============================================================================
43359
+ /**
43360
+ * Get user's gem balance
43361
+ *
43362
+ * Returns the current gem balance including total gems, available gems,
43363
+ * and gems expiring soon. Gems are earned at 100 per $1 of revenue.
43364
+ *
43365
+ * @returns Current gem balance with USD equivalent
43366
+ *
43367
+ * @example
43368
+ * ```typescript
43369
+ * const balance = await client.getGemBalance();
43370
+ * console.log(`You have ${balance.totalGems} gems (${balance.usdEquivalent} USD)`);
43371
+ * console.log(`${balance.expiringSoon} gems expiring soon`);
43372
+ * ```
43373
+ */
43374
+ async getGemBalance() {
43375
+ return this.get("/api/gems/balance");
43376
+ }
43377
+ /**
43378
+ * Get gem transaction history
43379
+ *
43380
+ * Returns paginated history of gem transactions including earning,
43381
+ * spending, and expiration events.
43382
+ *
43383
+ * @param params - Query parameters for filtering and pagination
43384
+ * @returns Paginated gem history
43385
+ *
43386
+ * @example
43387
+ * ```typescript
43388
+ * // Get all history
43389
+ * const history = await client.getGemHistory({ limit: 20, offset: 0 });
43390
+ *
43391
+ * // Get only earned gems
43392
+ * const earned = await client.getGemHistory({ type: "earn", limit: 10 });
43393
+ *
43394
+ * // Get only spent gems
43395
+ * const spent = await client.getGemHistory({ type: "spend", limit: 10 });
43396
+ *
43397
+ * history.items.forEach(item => {
43398
+ * console.log(`${item.type}: ${item.amount} gems - ${item.createdAt}`);
43399
+ * });
43400
+ * ```
43401
+ */
43402
+ async getGemHistory(params) {
43403
+ const queryString = params ? buildQueryString(params) : "";
43404
+ return this.get(`/api/gems/history${queryString}`);
43405
+ }
43406
+ /**
43407
+ * Get gems that are expiring soon
43408
+ *
43409
+ * Returns gem batches that will expire within the specified number of days.
43410
+ * Useful for prompting users to spend gems before they expire.
43411
+ *
43412
+ * @param params - Query parameters (days: default 30, max 180)
43413
+ * @returns Expiring gem batches with countdown info
43414
+ *
43415
+ * @example
43416
+ * ```typescript
43417
+ * // Get gems expiring in next 30 days (default)
43418
+ * const expiring = await client.getExpiringGems();
43419
+ *
43420
+ * // Get gems expiring in next 7 days
43421
+ * const urgent = await client.getExpiringGems({ days: 7 });
43422
+ *
43423
+ * if (expiring.totalExpiring > 0) {
43424
+ * console.log(`${expiring.totalExpiring} gems expiring soon!`);
43425
+ * expiring.batches.forEach(batch => {
43426
+ * console.log(`${batch.amount} gems expire in ${batch.daysUntilExpiry} days`);
43427
+ * });
43428
+ * }
43429
+ * ```
43430
+ */
43431
+ async getExpiringGems(params) {
43432
+ const queryString = params ? buildQueryString(params) : "";
43433
+ return this.get(`/api/gems/expiring${queryString}`);
43434
+ }
43435
+ // ============================================================================
43436
+ // Browsing Location API
43437
+ // ============================================================================
43438
+ /**
43439
+ * Get user's browsing location
43440
+ *
43441
+ * Returns the user's saved delivery location for geo-based product filtering.
43442
+ * This location is used to show products from merchants that ship to the area.
43443
+ *
43444
+ * @returns Current browsing location or null if not set
43445
+ *
43446
+ * @example
43447
+ * ```typescript
43448
+ * const result = await client.getBrowsingLocation();
43449
+ * if (result.location) {
43450
+ * console.log(`Delivery to: ${result.location.city}, ${result.location.country}`);
43451
+ * }
43452
+ * ```
43453
+ */
43454
+ async getBrowsingLocation() {
43455
+ return this.get("/api/user/browsing-location");
43456
+ }
43457
+ /**
43458
+ * Save user's browsing location
43459
+ *
43460
+ * Sets the user's delivery location for geo-based product filtering.
43461
+ * Products will be filtered to show only items from merchants that ship to this location.
43462
+ *
43463
+ * @param request - Location data from Google Places or manual input
43464
+ * @returns The saved location
43465
+ *
43466
+ * @example
43467
+ * ```typescript
43468
+ * const result = await client.saveBrowsingLocation({
43469
+ * formattedAddress: "Singapore, Singapore",
43470
+ * city: "Singapore",
43471
+ * country: "SG",
43472
+ * latitude: 1.3521,
43473
+ * longitude: 103.8198
43474
+ * });
43475
+ * console.log(`Location saved: ${result.location.formattedAddress}`);
43476
+ * ```
43477
+ */
43478
+ async saveBrowsingLocation(request) {
43479
+ return this.post("/api/user/browsing-location", request);
43480
+ }
43481
+ /**
43482
+ * Clear user's browsing location
43483
+ *
43484
+ * Removes the user's saved delivery location. Products will no longer
43485
+ * be filtered by shipping destination.
43486
+ *
43487
+ * @returns Success response
43488
+ *
43489
+ * @example
43490
+ * ```typescript
43491
+ * await client.clearBrowsingLocation();
43492
+ * console.log("Location cleared - showing all products");
43493
+ * ```
43494
+ */
43495
+ async clearBrowsingLocation() {
43496
+ return this.delete("/api/user/browsing-location");
43497
+ }
43327
43498
  };
43328
43499
 
43329
43500
  // lib/ecommerce/client/merchant.ts
@@ -44987,6 +45158,7 @@ var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
44987
45158
  ProductSortBy2["PRICE_DESC"] = "price_desc";
44988
45159
  ProductSortBy2["POPULAR"] = "popular";
44989
45160
  ProductSortBy2["FEATURED"] = "featured";
45161
+ ProductSortBy2["NEARBY"] = "nearby";
44990
45162
  return ProductSortBy2;
44991
45163
  })(ProductSortBy || {});
44992
45164
  var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
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-SKX4VGEN.mjs';
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-P5C65GIG.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,9 +22,13 @@ import type {
22
22
  TrackBannerRequest,
23
23
  SendMessageRequest,
24
24
  ListActiveFlashSalesParams,
25
+ GetFlashSaleAllowanceParams,
25
26
  ListMerchantProductsParams,
26
27
  ListFollowingParams,
27
28
  CalculateShippingRequest,
29
+ GetGemHistoryParams,
30
+ GetExpiringGemsParams,
31
+ SaveBrowsingLocationRequest,
28
32
 
29
33
  // Response types
30
34
  ListProductsResponse,
@@ -48,6 +52,7 @@ import type {
48
52
  MessageStatsResponse,
49
53
  MessageResponse,
50
54
  ActiveFlashSalesResponse,
55
+ GetFlashSaleAllowanceResponse,
51
56
  GetPaymentMethodsResponse,
52
57
  PublicMerchantProfileResponse,
53
58
  MerchantProductsResponse,
@@ -55,6 +60,12 @@ import type {
55
60
  FollowActionResponse,
56
61
  ListFollowingResponse,
57
62
  CalculateShippingResponse,
63
+ GetGemBalanceResponse,
64
+ GetBrowsingLocationResponse,
65
+ SaveBrowsingLocationResponse,
66
+ DeleteBrowsingLocationResponse,
67
+ GetGemHistoryResponse,
68
+ GetExpiringGemsResponse,
58
69
  } from "../types";
59
70
 
60
71
  /**
@@ -675,6 +686,36 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
675
686
  const queryString = params ? buildQueryString(params) : "";
676
687
  return this.get(`/api/marketplace/flash-sales/active${queryString}`);
677
688
  }
689
+
690
+ /**
691
+ * Get flash sale allowance
692
+ *
693
+ * Fetches user's remaining purchase allowance for flash sale items.
694
+ * Used to enforce per-customer purchase limits.
695
+ *
696
+ * @param params - Request params with product IDs
697
+ * @returns Allowance info for each product
698
+ *
699
+ * @example
700
+ * ```typescript
701
+ * const result = await client.getFlashSaleAllowance({
702
+ * productIds: ["prod_123", "prod_456"]
703
+ * });
704
+ *
705
+ * Object.entries(result.allowances).forEach(([productId, info]) => {
706
+ * if (info.limitPerCustomer !== null) {
707
+ * console.log(`Product ${productId}:`);
708
+ * console.log(` Limit: ${info.limitPerCustomer} per customer`);
709
+ * console.log(` You've purchased: ${info.purchased}`);
710
+ * console.log(` You can buy: ${info.remaining} more`);
711
+ * }
712
+ * });
713
+ * ```
714
+ */
715
+ async getFlashSaleAllowance(params: GetFlashSaleAllowanceParams): Promise<GetFlashSaleAllowanceResponse> {
716
+ const queryString = buildQueryString({ productIds: params.productIds.join(",") });
717
+ return this.get(`/api/marketplace/flash-sales/allowance${queryString}`);
718
+ }
678
719
 
679
720
  // ============================================================================
680
721
  // Merchant Storefront API
@@ -825,5 +866,155 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
825
866
  async getPaymentMethods(): Promise<GetPaymentMethodsResponse> {
826
867
  return this.get("/api/marketplace/payments/methods");
827
868
  }
869
+
870
+ // ============================================================================
871
+ // GEM System API
872
+ // ============================================================================
873
+
874
+ /**
875
+ * Get user's gem balance
876
+ *
877
+ * Returns the current gem balance including total gems, available gems,
878
+ * and gems expiring soon. Gems are earned at 100 per $1 of revenue.
879
+ *
880
+ * @returns Current gem balance with USD equivalent
881
+ *
882
+ * @example
883
+ * ```typescript
884
+ * const balance = await client.getGemBalance();
885
+ * console.log(`You have ${balance.totalGems} gems (${balance.usdEquivalent} USD)`);
886
+ * console.log(`${balance.expiringSoon} gems expiring soon`);
887
+ * ```
888
+ */
889
+ async getGemBalance(): Promise<GetGemBalanceResponse> {
890
+ return this.get("/api/gems/balance");
891
+ }
892
+
893
+ /**
894
+ * Get gem transaction history
895
+ *
896
+ * Returns paginated history of gem transactions including earning,
897
+ * spending, and expiration events.
898
+ *
899
+ * @param params - Query parameters for filtering and pagination
900
+ * @returns Paginated gem history
901
+ *
902
+ * @example
903
+ * ```typescript
904
+ * // Get all history
905
+ * const history = await client.getGemHistory({ limit: 20, offset: 0 });
906
+ *
907
+ * // Get only earned gems
908
+ * const earned = await client.getGemHistory({ type: "earn", limit: 10 });
909
+ *
910
+ * // Get only spent gems
911
+ * const spent = await client.getGemHistory({ type: "spend", limit: 10 });
912
+ *
913
+ * history.items.forEach(item => {
914
+ * console.log(`${item.type}: ${item.amount} gems - ${item.createdAt}`);
915
+ * });
916
+ * ```
917
+ */
918
+ async getGemHistory(params?: GetGemHistoryParams): Promise<GetGemHistoryResponse> {
919
+ const queryString = params ? buildQueryString(params) : "";
920
+ return this.get(`/api/gems/history${queryString}`);
921
+ }
922
+
923
+ /**
924
+ * Get gems that are expiring soon
925
+ *
926
+ * Returns gem batches that will expire within the specified number of days.
927
+ * Useful for prompting users to spend gems before they expire.
928
+ *
929
+ * @param params - Query parameters (days: default 30, max 180)
930
+ * @returns Expiring gem batches with countdown info
931
+ *
932
+ * @example
933
+ * ```typescript
934
+ * // Get gems expiring in next 30 days (default)
935
+ * const expiring = await client.getExpiringGems();
936
+ *
937
+ * // Get gems expiring in next 7 days
938
+ * const urgent = await client.getExpiringGems({ days: 7 });
939
+ *
940
+ * if (expiring.totalExpiring > 0) {
941
+ * console.log(`${expiring.totalExpiring} gems expiring soon!`);
942
+ * expiring.batches.forEach(batch => {
943
+ * console.log(`${batch.amount} gems expire in ${batch.daysUntilExpiry} days`);
944
+ * });
945
+ * }
946
+ * ```
947
+ */
948
+ async getExpiringGems(params?: GetExpiringGemsParams): Promise<GetExpiringGemsResponse> {
949
+ const queryString = params ? buildQueryString(params) : "";
950
+ return this.get(`/api/gems/expiring${queryString}`);
951
+ }
952
+
953
+ // ============================================================================
954
+ // Browsing Location API
955
+ // ============================================================================
956
+
957
+ /**
958
+ * Get user's browsing location
959
+ *
960
+ * Returns the user's saved delivery location for geo-based product filtering.
961
+ * This location is used to show products from merchants that ship to the area.
962
+ *
963
+ * @returns Current browsing location or null if not set
964
+ *
965
+ * @example
966
+ * ```typescript
967
+ * const result = await client.getBrowsingLocation();
968
+ * if (result.location) {
969
+ * console.log(`Delivery to: ${result.location.city}, ${result.location.country}`);
970
+ * }
971
+ * ```
972
+ */
973
+ async getBrowsingLocation(): Promise<GetBrowsingLocationResponse> {
974
+ return this.get("/api/user/browsing-location");
975
+ }
976
+
977
+ /**
978
+ * Save user's browsing location
979
+ *
980
+ * Sets the user's delivery location for geo-based product filtering.
981
+ * Products will be filtered to show only items from merchants that ship to this location.
982
+ *
983
+ * @param request - Location data from Google Places or manual input
984
+ * @returns The saved location
985
+ *
986
+ * @example
987
+ * ```typescript
988
+ * const result = await client.saveBrowsingLocation({
989
+ * formattedAddress: "Singapore, Singapore",
990
+ * city: "Singapore",
991
+ * country: "SG",
992
+ * latitude: 1.3521,
993
+ * longitude: 103.8198
994
+ * });
995
+ * console.log(`Location saved: ${result.location.formattedAddress}`);
996
+ * ```
997
+ */
998
+ async saveBrowsingLocation(request: SaveBrowsingLocationRequest): Promise<SaveBrowsingLocationResponse> {
999
+ return this.post("/api/user/browsing-location", request);
1000
+ }
1001
+
1002
+ /**
1003
+ * Clear user's browsing location
1004
+ *
1005
+ * Removes the user's saved delivery location. Products will no longer
1006
+ * be filtered by shipping destination.
1007
+ *
1008
+ * @returns Success response
1009
+ *
1010
+ * @example
1011
+ * ```typescript
1012
+ * await client.clearBrowsingLocation();
1013
+ * console.log("Location cleared - showing all products");
1014
+ * ```
1015
+ */
1016
+ async clearBrowsingLocation(): Promise<DeleteBrowsingLocationResponse> {
1017
+ return this.delete("/api/user/browsing-location");
1018
+ }
828
1019
  }
829
1020
 
@@ -258,6 +258,8 @@ export enum ProductSortBy {
258
258
  POPULAR = "popular",
259
259
  /** Sort by featured status */
260
260
  FEATURED = "featured",
261
+ /** Sort by proximity to user location (requires lat/lng) */
262
+ NEARBY = "nearby",
261
263
  }
262
264
 
263
265
  /**
@@ -54,6 +54,12 @@ export interface ListProductsParams extends PaginationParams {
54
54
  sortBy?: ProductSortBy;
55
55
  /** Filter by active status */
56
56
  isActive?: boolean;
57
+ /** Filter by destination country (ISO 2-letter code) - only show products from merchants that ship here */
58
+ country?: string;
59
+ /** User latitude for proximity sorting (used with sortBy=nearby) */
60
+ lat?: number;
61
+ /** User longitude for proximity sorting (used with sortBy=nearby) */
62
+ lng?: number;
57
63
  }
58
64
 
59
65
  /**
@@ -541,6 +547,15 @@ export interface ListActiveFlashSalesParams {
541
547
  merchantId?: string;
542
548
  }
543
549
 
550
+ /**
551
+ * Get flash sale allowance request
552
+ * Get user's remaining purchase allowance for flash sale items
553
+ */
554
+ export interface GetFlashSaleAllowanceParams {
555
+ /** Comma-separated list of product IDs */
556
+ productIds: string[];
557
+ }
558
+
544
559
  /**
545
560
  * Flash sale item input
546
561
  */
@@ -700,3 +715,50 @@ export interface CalculateShippingRequest {
700
715
  orderSubtotal: number;
701
716
  }
702
717
 
718
+ // ============================================================================
719
+ // GEM System Requests
720
+ // ============================================================================
721
+
722
+ /**
723
+ * Gem history type filter
724
+ */
725
+ export type GemHistoryTypeFilter = "earn" | "spend" | "all";
726
+
727
+ /**
728
+ * Get gem history parameters
729
+ */
730
+ export interface GetGemHistoryParams extends PaginationParams {
731
+ /** Filter by transaction type */
732
+ type?: GemHistoryTypeFilter;
733
+ }
734
+
735
+ /**
736
+ * Get expiring gems parameters
737
+ */
738
+ export interface GetExpiringGemsParams {
739
+ /** Number of days ahead to check (default: 30, max: 180) */
740
+ days?: number;
741
+ }
742
+
743
+ // ============================================================================
744
+ // Browsing Location Requests
745
+ // ============================================================================
746
+
747
+ /**
748
+ * Save browsing location request
749
+ */
750
+ export interface SaveBrowsingLocationRequest {
751
+ /** Full display address from Google Places */
752
+ formattedAddress: string;
753
+ /** City name */
754
+ city: string;
755
+ /** State/Province (optional) */
756
+ stateProvince?: string;
757
+ /** ISO 2-letter country code (e.g., "SG", "US") */
758
+ country: string;
759
+ /** Latitude coordinate */
760
+ latitude: number;
761
+ /** Longitude coordinate */
762
+ longitude: number;
763
+ }
764
+