@basedone/core 0.1.10 → 0.2.1

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 (54) hide show
  1. package/dist/chunk-4UEJOM6W.mjs +1 -3
  2. package/dist/chunk-MVFO4WRF.mjs +2091 -0
  3. package/dist/chunk-VBC6EQ7Q.mjs +235 -0
  4. package/dist/client-CgmiTuEX.d.mts +179 -0
  5. package/dist/client-CgmiTuEX.d.ts +179 -0
  6. package/dist/ecommerce.d.mts +3986 -0
  7. package/dist/ecommerce.d.ts +3986 -0
  8. package/dist/ecommerce.js +2135 -0
  9. package/dist/ecommerce.mjs +2 -0
  10. package/dist/index.d.mts +51 -43
  11. package/dist/index.d.ts +51 -43
  12. package/dist/index.js +2795 -205
  13. package/dist/index.mjs +68 -90
  14. package/dist/{meta-FVJIMALT.mjs → meta-JB5ITE27.mjs} +4 -10
  15. package/dist/meta-UOGUG3OW.mjs +3 -7
  16. package/dist/{perpDexs-GGL32HT4.mjs → perpDexs-3LRJ5ZHM.mjs} +37 -8
  17. package/dist/{perpDexs-G7V2QIM6.mjs → perpDexs-4ISLD7NX.mjs} +177 -32
  18. package/dist/react.d.mts +39 -0
  19. package/dist/react.d.ts +39 -0
  20. package/dist/react.js +268 -0
  21. package/dist/react.mjs +31 -0
  22. package/dist/{spotMeta-OD7S6HGW.mjs → spotMeta-GHXX7C5M.mjs} +24 -9
  23. package/dist/{spotMeta-PCN4Z4R3.mjs → spotMeta-IBBUP2SG.mjs} +54 -6
  24. package/dist/staticMeta-GM7T3OYL.mjs +3 -6
  25. package/dist/staticMeta-QV2KMX57.mjs +3 -6
  26. package/ecommerce.ts +15 -0
  27. package/index.ts +6 -0
  28. package/lib/ecommerce/FLASH_SALES.md +340 -0
  29. package/lib/ecommerce/QUICK_REFERENCE.md +211 -0
  30. package/lib/ecommerce/README.md +391 -0
  31. package/lib/ecommerce/USAGE_EXAMPLES.md +704 -0
  32. package/lib/ecommerce/client/base.ts +272 -0
  33. package/lib/ecommerce/client/customer.ts +639 -0
  34. package/lib/ecommerce/client/merchant.ts +1341 -0
  35. package/lib/ecommerce/index.ts +51 -0
  36. package/lib/ecommerce/types/entities.ts +791 -0
  37. package/lib/ecommerce/types/enums.ts +270 -0
  38. package/lib/ecommerce/types/index.ts +18 -0
  39. package/lib/ecommerce/types/requests.ts +580 -0
  40. package/lib/ecommerce/types/responses.ts +857 -0
  41. package/lib/ecommerce/utils/errors.ts +113 -0
  42. package/lib/ecommerce/utils/helpers.ts +131 -0
  43. package/lib/hip3/market-info.ts +1 -1
  44. package/lib/instrument/client.ts +351 -0
  45. package/lib/meta/data/mainnet/perpDexs.json +34 -4
  46. package/lib/meta/data/mainnet/spotMeta.json +21 -3
  47. package/lib/meta/data/testnet/meta.json +1 -3
  48. package/lib/meta/data/testnet/perpDexs.json +174 -28
  49. package/lib/meta/data/testnet/spotMeta.json +51 -0
  50. package/lib/react/InstrumentProvider.tsx +69 -0
  51. package/lib/utils/flooredDateTime.ts +55 -0
  52. package/lib/utils/time.ts +51 -0
  53. package/package.json +37 -11
  54. package/react.ts +1 -0
@@ -0,0 +1,2091 @@
1
+ import axios from 'axios';
2
+
3
+ // lib/ecommerce/utils/errors.ts
4
+ var EcommerceApiError = class _EcommerceApiError extends Error {
5
+ constructor(message, statusCode, data, isNetworkError = false, isTimeoutError = false) {
6
+ super(message);
7
+ this.name = "EcommerceApiError";
8
+ this.statusCode = statusCode;
9
+ this.data = data;
10
+ this.isNetworkError = isNetworkError;
11
+ this.isTimeoutError = isTimeoutError;
12
+ this.isAuthError = statusCode === 401 || statusCode === 403;
13
+ if (Error.captureStackTrace) {
14
+ Error.captureStackTrace(this, _EcommerceApiError);
15
+ }
16
+ }
17
+ };
18
+ function parseError(error) {
19
+ if (error.code === "ECONNABORTED" || error.code === "ETIMEDOUT") {
20
+ return new EcommerceApiError(
21
+ "Request timeout",
22
+ void 0,
23
+ void 0,
24
+ false,
25
+ true
26
+ );
27
+ }
28
+ if (error.code === "ERR_NETWORK" || !error.response) {
29
+ return new EcommerceApiError(
30
+ error.message || "Network error",
31
+ void 0,
32
+ void 0,
33
+ true,
34
+ false
35
+ );
36
+ }
37
+ const response = error.response;
38
+ const statusCode = response?.status;
39
+ const data = response?.data;
40
+ const message = data?.error || data?.message || error.message || `API error (${statusCode})`;
41
+ return new EcommerceApiError(message, statusCode, data);
42
+ }
43
+ function isRetryableError(error) {
44
+ if (error.isNetworkError) {
45
+ return true;
46
+ }
47
+ if (error.isTimeoutError) {
48
+ return true;
49
+ }
50
+ if (error.statusCode && error.statusCode >= 500) {
51
+ return true;
52
+ }
53
+ if (error.statusCode === 429) {
54
+ return true;
55
+ }
56
+ return false;
57
+ }
58
+
59
+ // lib/ecommerce/utils/helpers.ts
60
+ function buildQueryString(params) {
61
+ const searchParams = new URLSearchParams();
62
+ Object.entries(params).forEach(([key, value]) => {
63
+ if (value !== void 0 && value !== null) {
64
+ if (Array.isArray(value)) {
65
+ searchParams.append(key, value.join(","));
66
+ } else {
67
+ searchParams.append(key, String(value));
68
+ }
69
+ }
70
+ });
71
+ const queryString = searchParams.toString();
72
+ return queryString ? `?${queryString}` : "";
73
+ }
74
+ function sleep(ms) {
75
+ return new Promise((resolve) => setTimeout(resolve, ms));
76
+ }
77
+ function getBackoffDelay(attempt, baseDelay = 1e3) {
78
+ return Math.min(baseDelay * Math.pow(2, attempt), 3e4);
79
+ }
80
+ async function retryWithBackoff(fn, maxRetries = 3, baseDelay = 1e3, shouldRetry) {
81
+ let lastError;
82
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
83
+ try {
84
+ return await fn();
85
+ } catch (error) {
86
+ lastError = error;
87
+ if (attempt < maxRetries && (!shouldRetry || shouldRetry(error))) {
88
+ const delay = getBackoffDelay(attempt, baseDelay);
89
+ await sleep(delay);
90
+ continue;
91
+ }
92
+ throw error;
93
+ }
94
+ }
95
+ throw lastError;
96
+ }
97
+ function formatPrice(price, decimals = 2) {
98
+ const num = typeof price === "string" ? parseFloat(price) : price;
99
+ return num.toFixed(decimals);
100
+ }
101
+ function isValidEmail(email) {
102
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
103
+ return emailRegex.test(email);
104
+ }
105
+ function isValidAddress(address) {
106
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
107
+ }
108
+ function truncateAddress(address, start = 6, end = 4) {
109
+ if (!address || address.length < start + end) {
110
+ return address;
111
+ }
112
+ return `${address.slice(0, start)}...${address.slice(-end)}`;
113
+ }
114
+ function calculateDiscountAmount(price, discountType, discountValue) {
115
+ if (discountType === "PERCENTAGE") {
116
+ return price * discountValue / 100;
117
+ }
118
+ return Math.min(discountValue, price);
119
+ }
120
+ function calculateFinalPrice(price, discountType, discountValue) {
121
+ const discountAmount = calculateDiscountAmount(price, discountType, discountValue);
122
+ return Math.max(0, price - discountAmount);
123
+ }
124
+ var BaseEcommerceClient = class {
125
+ constructor(config) {
126
+ this.config = {
127
+ baseURL: config.baseURL,
128
+ authToken: config.authToken,
129
+ timeout: config.timeout || 3e4,
130
+ maxRetries: config.maxRetries || 3,
131
+ retryBaseDelay: config.retryBaseDelay || 1e3,
132
+ headers: config.headers,
133
+ enableRetry: config.enableRetry !== false
134
+ };
135
+ this.axiosInstance = axios.create({
136
+ baseURL: this.config.baseURL,
137
+ timeout: this.config.timeout,
138
+ headers: {
139
+ "Content-Type": "application/json",
140
+ ...this.config.headers
141
+ }
142
+ });
143
+ this.axiosInstance.interceptors.request.use(
144
+ (config2) => {
145
+ if (this.config.authToken) {
146
+ config2.headers.Authorization = `Bearer ${this.config.authToken}`;
147
+ }
148
+ return config2;
149
+ },
150
+ (error) => Promise.reject(error)
151
+ );
152
+ this.axiosInstance.interceptors.response.use(
153
+ (response) => response,
154
+ (error) => Promise.reject(parseError(error))
155
+ );
156
+ }
157
+ /**
158
+ * Update authentication token
159
+ *
160
+ * @param token - New authentication token
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * client.setAuthToken("new-auth-token");
165
+ * ```
166
+ */
167
+ setAuthToken(token) {
168
+ this.config.authToken = token;
169
+ }
170
+ /**
171
+ * Clear authentication token
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * client.clearAuthToken();
176
+ * ```
177
+ */
178
+ clearAuthToken() {
179
+ this.config.authToken = void 0;
180
+ }
181
+ /**
182
+ * Make a GET request
183
+ *
184
+ * @param url - Request URL
185
+ * @param config - Axios request config
186
+ * @returns Response data
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const products = await client.get("/api/marketplace/products", {
191
+ * params: { limit: 20, offset: 0 }
192
+ * });
193
+ * ```
194
+ */
195
+ async get(url, config) {
196
+ return this.request({ ...config, method: "GET", url });
197
+ }
198
+ /**
199
+ * Make a POST request
200
+ *
201
+ * @param url - Request URL
202
+ * @param data - Request body data
203
+ * @param config - Axios request config
204
+ * @returns Response data
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const order = await client.post("/api/marketplace/orders", {
209
+ * items: [{ productId: "123", quantity: 1 }],
210
+ * paymentMethod: "USDC_ESCROW"
211
+ * });
212
+ * ```
213
+ */
214
+ async post(url, data, config) {
215
+ return this.request({ ...config, method: "POST", url, data });
216
+ }
217
+ /**
218
+ * Make a PUT request
219
+ *
220
+ * @param url - Request URL
221
+ * @param data - Request body data
222
+ * @param config - Axios request config
223
+ * @returns Response data
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * const product = await client.put("/api/marketplace/products/123", {
228
+ * title: "Updated Product"
229
+ * });
230
+ * ```
231
+ */
232
+ async put(url, data, config) {
233
+ return this.request({ ...config, method: "PUT", url, data });
234
+ }
235
+ /**
236
+ * Make a PATCH request
237
+ *
238
+ * @param url - Request URL
239
+ * @param data - Request body data
240
+ * @param config - Axios request config
241
+ * @returns Response data
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * const order = await client.patch("/api/marketplace/merchant/orders/123", {
246
+ * status: "SHIPPED",
247
+ * tracking: { trackingNumber: "123456", carrier: "UPS" }
248
+ * });
249
+ * ```
250
+ */
251
+ async patch(url, data, config) {
252
+ return this.request({ ...config, method: "PATCH", url, data });
253
+ }
254
+ /**
255
+ * Make a DELETE request
256
+ *
257
+ * @param url - Request URL
258
+ * @param config - Axios request config
259
+ * @returns Response data
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * await client.delete("/api/marketplace/products/123");
264
+ * ```
265
+ */
266
+ async delete(url, config) {
267
+ return this.request({ ...config, method: "DELETE", url });
268
+ }
269
+ /**
270
+ * Make a request with retry logic
271
+ *
272
+ * @param config - Axios request config
273
+ * @returns Response data
274
+ */
275
+ async request(config) {
276
+ const makeRequest = async () => {
277
+ return this.axiosInstance.request(config);
278
+ };
279
+ if (this.config.enableRetry) {
280
+ const response = await retryWithBackoff(
281
+ makeRequest,
282
+ this.config.maxRetries,
283
+ this.config.retryBaseDelay,
284
+ (error) => isRetryableError(error)
285
+ );
286
+ return response.data;
287
+ } else {
288
+ const response = await makeRequest();
289
+ return response.data;
290
+ }
291
+ }
292
+ /**
293
+ * Get the underlying axios instance
294
+ *
295
+ * @returns Axios instance
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * const axios = client.getAxiosInstance();
300
+ * // Use axios directly for advanced use cases
301
+ * ```
302
+ */
303
+ getAxiosInstance() {
304
+ return this.axiosInstance;
305
+ }
306
+ };
307
+
308
+ // lib/ecommerce/client/customer.ts
309
+ var CustomerEcommerceClient = class extends BaseEcommerceClient {
310
+ // ============================================================================
311
+ // Products API
312
+ // ============================================================================
313
+ /**
314
+ * List products with filtering and pagination
315
+ *
316
+ * @param params - Query parameters for filtering
317
+ * @returns Paginated list of products
318
+ *
319
+ * @example
320
+ * ```typescript
321
+ * const products = await client.listProducts({
322
+ * limit: 20,
323
+ * offset: 0,
324
+ * category: "electronics",
325
+ * search: "laptop",
326
+ * minPrice: 500,
327
+ * maxPrice: 2000,
328
+ * sortBy: "price_asc"
329
+ * });
330
+ * ```
331
+ */
332
+ async listProducts(params) {
333
+ const queryString = params ? buildQueryString(params) : "";
334
+ return this.get(`/api/marketplace/products${queryString}`);
335
+ }
336
+ /**
337
+ * Get product details by ID
338
+ *
339
+ * @param productId - Product ID
340
+ * @returns Product details with merchant info, variants, and reviews
341
+ *
342
+ * @example
343
+ * ```typescript
344
+ * const product = await client.getProduct("prod_123");
345
+ * console.log(product.title, product.priceUSDC);
346
+ * ```
347
+ */
348
+ async getProduct(productId) {
349
+ return this.get(`/api/marketplace/products/${productId}`);
350
+ }
351
+ /**
352
+ * Track product view (increment view count)
353
+ *
354
+ * @param productId - Product ID
355
+ * @returns Success response
356
+ *
357
+ * @example
358
+ * ```typescript
359
+ * await client.trackProductView("prod_123");
360
+ * ```
361
+ */
362
+ async trackProductView(productId) {
363
+ return this.post(`/api/marketplace/products/${productId}/view`);
364
+ }
365
+ /**
366
+ * Get active automatic discounts for a product
367
+ *
368
+ * @param productId - Product ID
369
+ * @returns List of applicable discounts
370
+ *
371
+ * @example
372
+ * ```typescript
373
+ * const discounts = await client.getProductDiscounts("prod_123");
374
+ * discounts.discounts.forEach(d => console.log(d.description));
375
+ * ```
376
+ */
377
+ async getProductDiscounts(productId) {
378
+ return this.get(`/api/marketplace/products/${productId}/discounts`);
379
+ }
380
+ // ============================================================================
381
+ // Orders API
382
+ // ============================================================================
383
+ /**
384
+ * Create order from cart checkout
385
+ *
386
+ * Supports multi-merchant checkout - automatically splits orders by merchant.
387
+ *
388
+ * @param request - Order creation request
389
+ * @returns Created order(s) with payment instructions
390
+ *
391
+ * @example
392
+ * ```typescript
393
+ * const result = await client.createOrder({
394
+ * items: [
395
+ * { productId: "prod_123", quantity: 2 },
396
+ * { productId: "prod_456", quantity: 1, variantId: "var_789" }
397
+ * ],
398
+ * paymentMethod: "USDC_ESCROW",
399
+ * shippingAddress: {
400
+ * fullName: "John Doe",
401
+ * phone: "+1234567890",
402
+ * addressLine1: "123 Main St",
403
+ * city: "New York",
404
+ * stateProvince: "NY",
405
+ * postalCode: "10001",
406
+ * country: "US"
407
+ * },
408
+ * couponCode: "SAVE10"
409
+ * });
410
+ *
411
+ * // For USDC escrow, deposit to the escrow address
412
+ * if (result.escrow) {
413
+ * console.log("Deposit", result.escrow.amountUSDC, "USDC to", result.escrow.address);
414
+ * }
415
+ * ```
416
+ */
417
+ async createOrder(request) {
418
+ return this.post("/api/marketplace/orders", request);
419
+ }
420
+ /**
421
+ * List user's orders
422
+ *
423
+ * @param params - Query parameters for filtering
424
+ * @returns Paginated list of orders
425
+ *
426
+ * @example
427
+ * ```typescript
428
+ * const orders = await client.listOrders({
429
+ * limit: 10,
430
+ * offset: 0,
431
+ * status: "SHIPPED"
432
+ * });
433
+ * ```
434
+ */
435
+ async listOrders(params) {
436
+ const queryString = params ? buildQueryString(params) : "";
437
+ return this.get(`/api/marketplace/orders${queryString}`);
438
+ }
439
+ /**
440
+ * Get order details by ID
441
+ *
442
+ * @param orderId - Order ID
443
+ * @returns Order details with items, payment, and shipment info
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * const order = await client.getOrder("ord_123");
448
+ * console.log(order.order.status, order.order.totalUSDC);
449
+ * ```
450
+ */
451
+ async getOrder(orderId) {
452
+ return this.get(`/api/marketplace/orders/${orderId}`);
453
+ }
454
+ /**
455
+ * Confirm USDC escrow deposit for order payment
456
+ *
457
+ * Verifies the Hyperliquid transaction and updates order status.
458
+ *
459
+ * @param orderId - Order ID
460
+ * @returns Confirmation response with transaction hash
461
+ *
462
+ * @example
463
+ * ```typescript
464
+ * // After depositing USDC to escrow address
465
+ * const result = await client.confirmEscrowDeposit("ord_123");
466
+ * console.log("Payment confirmed:", result.depositTxHash);
467
+ * ```
468
+ */
469
+ async confirmEscrowDeposit(orderId) {
470
+ return this.post(`/api/marketplace/orders/${orderId}/confirm-escrow-deposit`);
471
+ }
472
+ /**
473
+ * Get order receipt
474
+ *
475
+ * @param orderId - Order ID
476
+ * @returns Order receipt for download/display
477
+ *
478
+ * @example
479
+ * ```typescript
480
+ * const receipt = await client.getOrderReceipt("ord_123");
481
+ * console.log("Order #", receipt.receipt.orderNumber);
482
+ * ```
483
+ */
484
+ async getOrderReceipt(orderId) {
485
+ return this.get(`/api/marketplace/orders/${orderId}/receipt`);
486
+ }
487
+ // ============================================================================
488
+ // Reviews API
489
+ // ============================================================================
490
+ /**
491
+ * List reviews for a product
492
+ *
493
+ * @param productId - Product ID
494
+ * @param params - Query parameters
495
+ * @returns Paginated list of reviews
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * const reviews = await client.listProductReviews("prod_123", {
500
+ * limit: 10,
501
+ * sortBy: "highest"
502
+ * });
503
+ * ```
504
+ */
505
+ async listProductReviews(productId, params) {
506
+ const queryString = params ? buildQueryString(params) : "";
507
+ return this.get(`/api/marketplace/products/${productId}/reviews${queryString}`);
508
+ }
509
+ /**
510
+ * Create a product review
511
+ *
512
+ * Requires authenticated user who has purchased the product.
513
+ *
514
+ * @param productId - Product ID
515
+ * @param request - Review creation request
516
+ * @returns Created review
517
+ *
518
+ * @example
519
+ * ```typescript
520
+ * const review = await client.createReview("prod_123", {
521
+ * rating: 5,
522
+ * title: "Great product!",
523
+ * comment: "Exactly what I needed. Fast shipping too!"
524
+ * });
525
+ * ```
526
+ */
527
+ async createReview(productId, request) {
528
+ return this.post(`/api/marketplace/products/${productId}/reviews`, request);
529
+ }
530
+ // ============================================================================
531
+ // Shipping Addresses API
532
+ // ============================================================================
533
+ /**
534
+ * List saved shipping addresses
535
+ *
536
+ * @returns List of user's saved shipping addresses
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * const addresses = await client.listShippingAddresses();
541
+ * const defaultAddress = addresses.addresses.find(a => a.isDefault);
542
+ * ```
543
+ */
544
+ async listShippingAddresses() {
545
+ return this.get("/api/user/shipping-addresses");
546
+ }
547
+ /**
548
+ * Create a new shipping address
549
+ *
550
+ * @param request - Shipping address data
551
+ * @returns Created address
552
+ *
553
+ * @example
554
+ * ```typescript
555
+ * const address = await client.createShippingAddress({
556
+ * fullName: "John Doe",
557
+ * phone: "+1234567890",
558
+ * addressLine1: "123 Main St",
559
+ * city: "New York",
560
+ * stateProvince: "NY",
561
+ * postalCode: "10001",
562
+ * country: "US",
563
+ * isDefault: true,
564
+ * label: "Home"
565
+ * });
566
+ * ```
567
+ */
568
+ async createShippingAddress(request) {
569
+ return this.post("/api/user/shipping-addresses", request);
570
+ }
571
+ /**
572
+ * Update a shipping address
573
+ *
574
+ * @param addressId - Address ID
575
+ * @param request - Updated address data
576
+ * @returns Updated address
577
+ *
578
+ * @example
579
+ * ```typescript
580
+ * const address = await client.updateShippingAddress("addr_123", {
581
+ * phone: "+0987654321"
582
+ * });
583
+ * ```
584
+ */
585
+ async updateShippingAddress(addressId, request) {
586
+ return this.patch(`/api/user/shipping-addresses/${addressId}`, request);
587
+ }
588
+ /**
589
+ * Delete a shipping address
590
+ *
591
+ * @param addressId - Address ID
592
+ * @returns Success response
593
+ *
594
+ * @example
595
+ * ```typescript
596
+ * await client.deleteShippingAddress("addr_123");
597
+ * ```
598
+ */
599
+ async deleteShippingAddress(addressId) {
600
+ return this.delete(`/api/user/shipping-addresses/${addressId}`);
601
+ }
602
+ // ============================================================================
603
+ // Cart & Discounts API
604
+ // ============================================================================
605
+ /**
606
+ * Calculate automatic discounts for cart items
607
+ *
608
+ * @param request - Cart items
609
+ * @returns Calculated discounts and totals
610
+ *
611
+ * @example
612
+ * ```typescript
613
+ * const result = await client.calculateCartDiscounts({
614
+ * items: [
615
+ * { productId: "prod_123", quantity: 2 },
616
+ * { productId: "prod_456", quantity: 1 }
617
+ * ]
618
+ * });
619
+ * console.log("Subtotal:", result.subtotal);
620
+ * console.log("Discount:", result.discountAmount);
621
+ * console.log("Total:", result.total);
622
+ * ```
623
+ */
624
+ async calculateCartDiscounts(request) {
625
+ return this.post("/api/marketplace/cart/discounts", request);
626
+ }
627
+ /**
628
+ * Validate a discount code for cart items
629
+ *
630
+ * @param request - Discount code and cart items
631
+ * @returns Validation result with discount details
632
+ *
633
+ * @example
634
+ * ```typescript
635
+ * const result = await client.validateDiscountCode({
636
+ * code: "SAVE10",
637
+ * items: [
638
+ * { productId: "prod_123", quantity: 2 }
639
+ * ]
640
+ * });
641
+ *
642
+ * if (result.valid) {
643
+ * console.log("Discount:", result.discount?.discountAmount);
644
+ * } else {
645
+ * console.log("Error:", result.error);
646
+ * }
647
+ * ```
648
+ */
649
+ async validateDiscountCode(request) {
650
+ return this.post("/api/marketplace/discounts/validate", request);
651
+ }
652
+ // ============================================================================
653
+ // Tax Calculation API
654
+ // ============================================================================
655
+ /**
656
+ * Calculate tax for cart items based on shipping address
657
+ *
658
+ * @param request - Cart items and shipping address
659
+ * @returns Tax calculation with breakdown
660
+ *
661
+ * @example
662
+ * ```typescript
663
+ * const result = await client.calculateTax({
664
+ * items: [
665
+ * { productId: "prod_123", quantity: 2 }
666
+ * ],
667
+ * shippingAddress: {
668
+ * country: "US",
669
+ * region: "NY",
670
+ * postalCode: "10001"
671
+ * }
672
+ * });
673
+ * console.log("Tax:", result.taxAmount);
674
+ * console.log("Total:", result.total);
675
+ * ```
676
+ */
677
+ async calculateTax(request) {
678
+ return this.post("/api/marketplace/tax/calculate", request);
679
+ }
680
+ // ============================================================================
681
+ // Banners API
682
+ // ============================================================================
683
+ /**
684
+ * Get active promotional banners
685
+ *
686
+ * @param params - Query parameters
687
+ * @returns List of active banners
688
+ *
689
+ * @example
690
+ * ```typescript
691
+ * const banners = await client.getActiveBanners({
692
+ * type: "HERO",
693
+ * merchantId: "merchant_123"
694
+ * });
695
+ * ```
696
+ */
697
+ async getActiveBanners(params) {
698
+ const queryString = params ? buildQueryString(params) : "";
699
+ return this.get(`/api/marketplace/banners/active${queryString}`);
700
+ }
701
+ /**
702
+ * Track banner impression or click
703
+ *
704
+ * @param bannerId - Banner ID
705
+ * @param request - Track action (impression or click)
706
+ * @returns Success response
707
+ *
708
+ * @example
709
+ * ```typescript
710
+ * // Track impression
711
+ * await client.trackBanner("banner_123", { action: "impression" });
712
+ *
713
+ * // Track click
714
+ * await client.trackBanner("banner_123", { action: "click" });
715
+ * ```
716
+ */
717
+ async trackBanner(bannerId, request) {
718
+ return this.post(`/api/marketplace/banners/${bannerId}/track`, request);
719
+ }
720
+ // ============================================================================
721
+ // Messages API
722
+ // ============================================================================
723
+ /**
724
+ * List messages for customer
725
+ *
726
+ * Returns all conversations grouped by order, where each order represents
727
+ * a conversation with a merchant.
728
+ *
729
+ * @returns List of conversations with messages and stats
730
+ *
731
+ * @example
732
+ * ```typescript
733
+ * const result = await client.listMessages();
734
+ * console.log("Unread:", result.stats.unread);
735
+ * result.conversations.forEach(conv => {
736
+ * console.log(`Order ${conv.orderNumber}: ${conv.unreadCount} unread`);
737
+ * });
738
+ * ```
739
+ */
740
+ async listMessages() {
741
+ return this.get("/api/marketplace/messages");
742
+ }
743
+ /**
744
+ * Get message stats (unread count)
745
+ *
746
+ * Lightweight endpoint for notification badges.
747
+ *
748
+ * @returns Unread message count
749
+ *
750
+ * @example
751
+ * ```typescript
752
+ * const stats = await client.getMessageStats();
753
+ * console.log("Unread messages:", stats.unread);
754
+ * ```
755
+ */
756
+ async getMessageStats() {
757
+ return this.get("/api/marketplace/messages/stats");
758
+ }
759
+ /**
760
+ * Send a message to a merchant about an order
761
+ *
762
+ * @param request - Message data including orderId, recipientId (merchant user ID), and message
763
+ * @returns Sent message
764
+ *
765
+ * @example
766
+ * ```typescript
767
+ * await client.sendMessage({
768
+ * orderId: "ord_123",
769
+ * recipientId: "user_merchant_456",
770
+ * message: "When will my order ship?"
771
+ * });
772
+ * ```
773
+ */
774
+ async sendMessage(request) {
775
+ return this.post("/api/marketplace/messages/send", request);
776
+ }
777
+ /**
778
+ * Mark a message as read
779
+ *
780
+ * @param messageId - Message ID
781
+ * @returns Updated message
782
+ *
783
+ * @example
784
+ * ```typescript
785
+ * await client.markMessageAsRead("msg_123");
786
+ * ```
787
+ */
788
+ async markMessageAsRead(messageId) {
789
+ return this.patch(`/api/marketplace/messages/${messageId}/read`, {});
790
+ }
791
+ // ============================================================================
792
+ // Flash Sales API
793
+ // ============================================================================
794
+ /**
795
+ * Get active flash sales
796
+ *
797
+ * Returns currently running flash sales with their discounted products.
798
+ * Includes countdown timer information for UI display.
799
+ *
800
+ * @param params - Query parameters
801
+ * @returns List of active flash sales with time remaining
802
+ *
803
+ * @example
804
+ * ```typescript
805
+ * const result = await client.getActiveFlashSales({ limit: 5 });
806
+ *
807
+ * result.flashSales.forEach(sale => {
808
+ * console.log(`${sale.name} - ends at ${sale.endsAt}`);
809
+ * sale.items.forEach(item => {
810
+ * console.log(` ${item.product.title}: $${item.salePrice} (${item.discountPercent}% off)`);
811
+ * });
812
+ * });
813
+ *
814
+ * // Use timeRemaining for countdown UI
815
+ * if (result.timeRemaining) {
816
+ * console.log(`Featured sale ends in ${result.timeRemaining.remainingSeconds} seconds`);
817
+ * }
818
+ * ```
819
+ */
820
+ async getActiveFlashSales(params) {
821
+ const queryString = params ? buildQueryString(params) : "";
822
+ return this.get(`/api/marketplace/flash-sales/active${queryString}`);
823
+ }
824
+ };
825
+
826
+ // lib/ecommerce/client/merchant.ts
827
+ var MerchantEcommerceClient = class extends BaseEcommerceClient {
828
+ // ============================================================================
829
+ // Profile Management
830
+ // ============================================================================
831
+ /**
832
+ * Get merchant profile
833
+ *
834
+ * @returns Merchant profile
835
+ *
836
+ * @example
837
+ * ```typescript
838
+ * const profile = await client.getMerchantProfile();
839
+ * console.log(profile.merchant.name);
840
+ * ```
841
+ */
842
+ async getMerchantProfile() {
843
+ return this.get("/api/marketplace/merchant/profile");
844
+ }
845
+ /**
846
+ * Get merchant profile (alias for getMerchantProfile)
847
+ *
848
+ * @returns Merchant profile
849
+ *
850
+ * @example
851
+ * ```typescript
852
+ * const profile = await client.getProfile();
853
+ * console.log(profile.merchant.name);
854
+ * ```
855
+ */
856
+ async getProfile() {
857
+ return this.getMerchantProfile();
858
+ }
859
+ /**
860
+ * Create or update merchant profile
861
+ *
862
+ * @param request - Profile data
863
+ * @returns Updated merchant profile
864
+ *
865
+ * @example
866
+ * ```typescript
867
+ * const profile = await client.upsertMerchantProfile({
868
+ * name: "My Store",
869
+ * description: "We sell great products",
870
+ * payoutAddress: "0x1234..."
871
+ * });
872
+ * ```
873
+ */
874
+ async upsertMerchantProfile(request) {
875
+ return this.post("/api/marketplace/merchant/profile", request);
876
+ }
877
+ // ============================================================================
878
+ // Products Management
879
+ // ============================================================================
880
+ /**
881
+ * List merchant's products
882
+ *
883
+ * @param params - Query parameters
884
+ * @returns Paginated list of products
885
+ *
886
+ * @example
887
+ * ```typescript
888
+ * const products = await client.listMerchantProducts({ limit: 20, offset: 0 });
889
+ * ```
890
+ */
891
+ async listMerchantProducts(params) {
892
+ const queryString = params ? buildQueryString(params) : "";
893
+ return this.get(`/api/marketplace/merchant/products${queryString}`);
894
+ }
895
+ /**
896
+ * Get a single product by ID
897
+ *
898
+ * @param productId - Product ID
899
+ * @returns Product details
900
+ *
901
+ * @example
902
+ * ```typescript
903
+ * const product = await client.getProduct("prod_123");
904
+ * console.log(product.product?.title, product.product?.priceUSDC);
905
+ * ```
906
+ */
907
+ async getProduct(productId) {
908
+ return this.get(`/api/marketplace/products/${productId}`);
909
+ }
910
+ /**
911
+ * Create a new product
912
+ *
913
+ * @param request - Product data
914
+ * @returns Created product
915
+ *
916
+ * @example
917
+ * ```typescript
918
+ * const product = await client.createProduct({
919
+ * title: "Awesome Product",
920
+ * images: ["https://..."],
921
+ * priceUSDC: 49.99,
922
+ * inventory: 50,
923
+ * category: "electronics",
924
+ * moq: 1
925
+ * });
926
+ * ```
927
+ */
928
+ async createProduct(request) {
929
+ return this.post("/api/marketplace/merchant/products", request);
930
+ }
931
+ /**
932
+ * Update a product
933
+ *
934
+ * @param productId - Product ID
935
+ * @param request - Updated product data
936
+ * @returns Updated product
937
+ *
938
+ * @example
939
+ * ```typescript
940
+ * const product = await client.updateProduct("prod_123", {
941
+ * priceUSDC: 39.99,
942
+ * inventory: 75
943
+ * });
944
+ * ```
945
+ */
946
+ async updateProduct(productId, request) {
947
+ return this.put(`/api/marketplace/products/${productId}`, request);
948
+ }
949
+ /**
950
+ * Delete a product
951
+ *
952
+ * @param productId - Product ID
953
+ * @returns Success response
954
+ *
955
+ * @example
956
+ * ```typescript
957
+ * await client.deleteProduct("prod_123");
958
+ * ```
959
+ */
960
+ async deleteProduct(productId) {
961
+ return this.delete(`/api/marketplace/products/${productId}`);
962
+ }
963
+ /**
964
+ * Toggle product featured status
965
+ *
966
+ * @param productId - Product ID
967
+ * @param featured - Featured status
968
+ * @returns Updated product
969
+ *
970
+ * @example
971
+ * ```typescript
972
+ * await client.setProductFeatured("prod_123", true);
973
+ * ```
974
+ */
975
+ async setProductFeatured(productId, featured) {
976
+ return this.patch(`/api/marketplace/merchant/products/${productId}/featured`, { featured });
977
+ }
978
+ /**
979
+ * List product variants
980
+ *
981
+ * @param productId - Product ID
982
+ * @returns List of variants
983
+ *
984
+ * @example
985
+ * ```typescript
986
+ * const variants = await client.listProductVariants("prod_123");
987
+ * ```
988
+ */
989
+ async listProductVariants(productId) {
990
+ return this.get(`/api/marketplace/merchant/products/${productId}/variants`);
991
+ }
992
+ /**
993
+ * Create a product variant
994
+ *
995
+ * @param productId - Product ID
996
+ * @param request - Variant data
997
+ * @returns Created variant
998
+ *
999
+ * @example
1000
+ * ```typescript
1001
+ * const variant = await client.createProductVariant("prod_123", {
1002
+ * name: "Large / Red",
1003
+ * attributes: { size: "L", color: "Red" },
1004
+ * priceUSDC: 54.99,
1005
+ * inventory: 20
1006
+ * });
1007
+ * ```
1008
+ */
1009
+ async createProductVariant(productId, request) {
1010
+ return this.post(`/api/marketplace/merchant/products/${productId}/variants`, request);
1011
+ }
1012
+ /**
1013
+ * Get a product variant
1014
+ *
1015
+ * @param productId - Product ID
1016
+ * @param variantId - Variant ID
1017
+ * @returns Variant details
1018
+ *
1019
+ * @example
1020
+ * ```typescript
1021
+ * const variant = await client.getProductVariant("prod_123", "var_456");
1022
+ * ```
1023
+ */
1024
+ async getProductVariant(productId, variantId) {
1025
+ return this.get(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`);
1026
+ }
1027
+ /**
1028
+ * Update a product variant
1029
+ *
1030
+ * @param productId - Product ID
1031
+ * @param variantId - Variant ID
1032
+ * @param request - Updated variant data
1033
+ * @returns Updated variant
1034
+ *
1035
+ * @example
1036
+ * ```typescript
1037
+ * const variant = await client.updateProductVariant("prod_123", "var_456", {
1038
+ * inventory: 30
1039
+ * });
1040
+ * ```
1041
+ */
1042
+ async updateProductVariant(productId, variantId, request) {
1043
+ return this.put(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`, request);
1044
+ }
1045
+ /**
1046
+ * Delete a product variant
1047
+ *
1048
+ * @param productId - Product ID
1049
+ * @param variantId - Variant ID
1050
+ * @returns Success response
1051
+ *
1052
+ * @example
1053
+ * ```typescript
1054
+ * await client.deleteProductVariant("prod_123", "var_456");
1055
+ * ```
1056
+ */
1057
+ async deleteProductVariant(productId, variantId) {
1058
+ return this.delete(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`);
1059
+ }
1060
+ /**
1061
+ * Get product metrics
1062
+ *
1063
+ * @returns Product performance metrics
1064
+ *
1065
+ * @example
1066
+ * ```typescript
1067
+ * const metrics = await client.getProductMetrics();
1068
+ * console.log("Total revenue:", metrics.summary.totalRevenue);
1069
+ * ```
1070
+ */
1071
+ async getProductMetrics() {
1072
+ return this.get("/api/marketplace/merchant/products/metrics");
1073
+ }
1074
+ // ============================================================================
1075
+ // Orders Management
1076
+ // ============================================================================
1077
+ /**
1078
+ * List merchant's orders
1079
+ *
1080
+ * @param params - Query parameters
1081
+ * @returns Paginated list of orders
1082
+ *
1083
+ * @example
1084
+ * ```typescript
1085
+ * const orders = await client.listMerchantOrders({ limit: 20, offset: 0 });
1086
+ * ```
1087
+ */
1088
+ async listMerchantOrders(params) {
1089
+ const queryString = params ? buildQueryString(params) : "";
1090
+ return this.get(`/api/marketplace/merchant/orders${queryString}`);
1091
+ }
1092
+ /**
1093
+ * Get order details
1094
+ *
1095
+ * @param orderId - Order ID
1096
+ * @returns Order details with full information
1097
+ *
1098
+ * @example
1099
+ * ```typescript
1100
+ * const order = await client.getMerchantOrder("ord_123");
1101
+ * console.log(order.order.status, order.order.items);
1102
+ * ```
1103
+ */
1104
+ async getMerchantOrder(orderId) {
1105
+ return this.get(`/api/marketplace/merchant/orders/${orderId}`);
1106
+ }
1107
+ /**
1108
+ * Update order status
1109
+ *
1110
+ * @param orderId - Order ID
1111
+ * @param request - Status update request
1112
+ * @returns Updated order
1113
+ *
1114
+ * @example
1115
+ * ```typescript
1116
+ * // Accept order
1117
+ * await client.updateOrderStatus("ord_123", {
1118
+ * status: "MERCHANT_ACCEPTED"
1119
+ * });
1120
+ *
1121
+ * // Mark as shipped
1122
+ * await client.updateOrderStatus("ord_123", {
1123
+ * status: "SHIPPED",
1124
+ * tracking: {
1125
+ * trackingNumber: "1Z999AA10123456784",
1126
+ * carrier: "UPS"
1127
+ * }
1128
+ * });
1129
+ * ```
1130
+ */
1131
+ async updateOrderStatus(orderId, request) {
1132
+ return this.patch(`/api/marketplace/merchant/orders/${orderId}`, request);
1133
+ }
1134
+ /**
1135
+ * Create a custom order event
1136
+ *
1137
+ * @param orderId - Order ID
1138
+ * @param request - Event data
1139
+ * @returns Created event
1140
+ *
1141
+ * @example
1142
+ * ```typescript
1143
+ * await client.createOrderEvent("ord_123", {
1144
+ * eventType: "CUSTOM",
1145
+ * title: "Package delayed",
1146
+ * description: "Shipment delayed due to weather"
1147
+ * });
1148
+ * ```
1149
+ */
1150
+ async createOrderEvent(orderId, request) {
1151
+ return this.post(`/api/marketplace/merchant/orders/${orderId}/events`, request);
1152
+ }
1153
+ // ============================================================================
1154
+ // Customers Management
1155
+ // ============================================================================
1156
+ /**
1157
+ * List customers with order history and stats
1158
+ *
1159
+ * @param params - Query parameters
1160
+ * @returns Paginated list of customers
1161
+ *
1162
+ * @example
1163
+ * ```typescript
1164
+ * const customers = await client.listCustomers({ limit: 50, offset: 0 });
1165
+ * customers.items.forEach(c => {
1166
+ * console.log(c.username, "Total spent:", c.totalSpent);
1167
+ * });
1168
+ * ```
1169
+ */
1170
+ async listCustomers(params) {
1171
+ const queryString = params ? buildQueryString(params) : "";
1172
+ return this.get(`/api/marketplace/merchant/customers${queryString}`);
1173
+ }
1174
+ // ============================================================================
1175
+ // Coupons & Discounts Management
1176
+ // ============================================================================
1177
+ /**
1178
+ * List merchant's coupons
1179
+ *
1180
+ * @returns List of coupons with stats
1181
+ *
1182
+ * @example
1183
+ * ```typescript
1184
+ * const result = await client.listCoupons();
1185
+ * console.log("Total coupons:", result.stats.total);
1186
+ * console.log("Active:", result.stats.active);
1187
+ * ```
1188
+ */
1189
+ async listCoupons() {
1190
+ return this.get("/api/marketplace/merchant/coupons");
1191
+ }
1192
+ /**
1193
+ * Create a coupon
1194
+ *
1195
+ * @param request - Coupon data
1196
+ * @returns Created coupon
1197
+ *
1198
+ * @example
1199
+ * ```typescript
1200
+ * const coupon = await client.createCoupon({
1201
+ * code: "SAVE20",
1202
+ * discountType: "PERCENTAGE",
1203
+ * discountValue: 20,
1204
+ * startsAt: "2025-01-01T00:00:00Z",
1205
+ * expiresAt: "2025-12-31T23:59:59Z",
1206
+ * maxUses: 100
1207
+ * });
1208
+ * ```
1209
+ */
1210
+ async createCoupon(request) {
1211
+ return this.post("/api/marketplace/merchant/coupons", request);
1212
+ }
1213
+ /**
1214
+ * Get coupon details with usage history
1215
+ *
1216
+ * @param couponId - Coupon ID
1217
+ * @returns Coupon with usages
1218
+ *
1219
+ * @example
1220
+ * ```typescript
1221
+ * const coupon = await client.getCoupon("coupon_123");
1222
+ * console.log("Used", coupon.coupon.usedCount, "times");
1223
+ * ```
1224
+ */
1225
+ async getCoupon(couponId) {
1226
+ return this.get(`/api/marketplace/merchant/coupons/${couponId}`);
1227
+ }
1228
+ /**
1229
+ * Update a coupon
1230
+ *
1231
+ * @param couponId - Coupon ID
1232
+ * @param request - Updated coupon data
1233
+ * @returns Updated coupon
1234
+ *
1235
+ * @example
1236
+ * ```typescript
1237
+ * await client.updateCoupon("coupon_123", {
1238
+ * isActive: false
1239
+ * });
1240
+ * ```
1241
+ */
1242
+ async updateCoupon(couponId, request) {
1243
+ return this.put(`/api/marketplace/merchant/coupons/${couponId}`, request);
1244
+ }
1245
+ /**
1246
+ * Delete a coupon
1247
+ *
1248
+ * @param couponId - Coupon ID
1249
+ * @returns Success response
1250
+ *
1251
+ * @example
1252
+ * ```typescript
1253
+ * await client.deleteCoupon("coupon_123");
1254
+ * ```
1255
+ */
1256
+ async deleteCoupon(couponId) {
1257
+ return this.delete(`/api/marketplace/merchant/coupons/${couponId}`);
1258
+ }
1259
+ // ============================================================================
1260
+ // Shipping & Fulfillment
1261
+ // ============================================================================
1262
+ /**
1263
+ * List shipping methods
1264
+ *
1265
+ * @returns List of shipping methods
1266
+ *
1267
+ * @example
1268
+ * ```typescript
1269
+ * const methods = await client.listShippingMethods();
1270
+ * ```
1271
+ */
1272
+ async listShippingMethods() {
1273
+ return this.get("/api/marketplace/merchant/shipping/methods");
1274
+ }
1275
+ /**
1276
+ * Create a shipping method
1277
+ *
1278
+ * @param request - Shipping method data
1279
+ * @returns Created method
1280
+ *
1281
+ * @example
1282
+ * ```typescript
1283
+ * const method = await client.createShippingMethod({
1284
+ * name: "Standard Shipping",
1285
+ * carrier: "USPS",
1286
+ * estimatedDays: "3-5 business days",
1287
+ * flatRate: 5.99
1288
+ * });
1289
+ * ```
1290
+ */
1291
+ async createShippingMethod(request) {
1292
+ return this.post("/api/marketplace/merchant/shipping/methods", request);
1293
+ }
1294
+ /**
1295
+ * Update a shipping method
1296
+ *
1297
+ * @param methodId - Method ID
1298
+ * @param request - Updated method data
1299
+ * @returns Updated method
1300
+ *
1301
+ * @example
1302
+ * ```typescript
1303
+ * await client.updateShippingMethod("method_123", {
1304
+ * flatRate: 6.99
1305
+ * });
1306
+ * ```
1307
+ */
1308
+ async updateShippingMethod(methodId, request) {
1309
+ return this.put(`/api/marketplace/merchant/shipping/methods/${methodId}`, request);
1310
+ }
1311
+ /**
1312
+ * Delete a shipping method
1313
+ *
1314
+ * @param methodId - Method ID
1315
+ * @returns Success response
1316
+ *
1317
+ * @example
1318
+ * ```typescript
1319
+ * await client.deleteShippingMethod("method_123");
1320
+ * ```
1321
+ */
1322
+ async deleteShippingMethod(methodId) {
1323
+ return this.delete(`/api/marketplace/merchant/shipping/methods/${methodId}`);
1324
+ }
1325
+ /**
1326
+ * List shipments
1327
+ *
1328
+ * @returns List of shipments for merchant's orders
1329
+ *
1330
+ * @example
1331
+ * ```typescript
1332
+ * const shipments = await client.listShipments();
1333
+ * ```
1334
+ */
1335
+ async listShipments() {
1336
+ return this.get("/api/marketplace/merchant/shipping/shipments");
1337
+ }
1338
+ /**
1339
+ * Update shipment status and tracking
1340
+ *
1341
+ * @param shipmentId - Shipment ID
1342
+ * @param request - Updated shipment data
1343
+ * @returns Updated shipment
1344
+ *
1345
+ * @example
1346
+ * ```typescript
1347
+ * await client.updateShipment("ship_123", {
1348
+ * status: "SHIPPED",
1349
+ * trackingNumber: "1Z999AA10123456784",
1350
+ * carrier: "UPS"
1351
+ * });
1352
+ * ```
1353
+ */
1354
+ async updateShipment(shipmentId, request) {
1355
+ return this.patch(`/api/marketplace/merchant/shipping/shipments/${shipmentId}`, request);
1356
+ }
1357
+ // ============================================================================
1358
+ // Returns & Refunds
1359
+ // ============================================================================
1360
+ /**
1361
+ * List returns
1362
+ *
1363
+ * @returns List of returns for merchant's orders
1364
+ *
1365
+ * @example
1366
+ * ```typescript
1367
+ * const returns = await client.listReturns();
1368
+ * ```
1369
+ */
1370
+ async listReturns() {
1371
+ return this.get("/api/marketplace/merchant/returns");
1372
+ }
1373
+ /**
1374
+ * Approve a return request
1375
+ *
1376
+ * @param returnId - Return ID
1377
+ * @returns Updated return
1378
+ *
1379
+ * @example
1380
+ * ```typescript
1381
+ * await client.approveReturn("return_123");
1382
+ * ```
1383
+ */
1384
+ async approveReturn(returnId) {
1385
+ return this.post(`/api/marketplace/merchant/returns/${returnId}/approve`);
1386
+ }
1387
+ /**
1388
+ * Reject a return request
1389
+ *
1390
+ * @param returnId - Return ID
1391
+ * @returns Updated return
1392
+ *
1393
+ * @example
1394
+ * ```typescript
1395
+ * await client.rejectReturn("return_123");
1396
+ * ```
1397
+ */
1398
+ async rejectReturn(returnId) {
1399
+ return this.post(`/api/marketplace/merchant/returns/${returnId}/reject`);
1400
+ }
1401
+ /**
1402
+ * Mark return as received
1403
+ *
1404
+ * @param returnId - Return ID
1405
+ * @returns Updated return
1406
+ *
1407
+ * @example
1408
+ * ```typescript
1409
+ * await client.markReturnReceived("return_123");
1410
+ * ```
1411
+ */
1412
+ async markReturnReceived(returnId) {
1413
+ return this.post(`/api/marketplace/merchant/returns/${returnId}/received`);
1414
+ }
1415
+ /**
1416
+ * Process refund for return
1417
+ *
1418
+ * @param returnId - Return ID
1419
+ * @returns Updated return
1420
+ *
1421
+ * @example
1422
+ * ```typescript
1423
+ * await client.processRefund("return_123");
1424
+ * ```
1425
+ */
1426
+ async processRefund(returnId) {
1427
+ return this.post(`/api/marketplace/merchant/returns/${returnId}/refunded`);
1428
+ }
1429
+ // ============================================================================
1430
+ // Reviews Management
1431
+ // ============================================================================
1432
+ /**
1433
+ * List reviews for merchant's products
1434
+ *
1435
+ * @returns List of reviews
1436
+ *
1437
+ * @example
1438
+ * ```typescript
1439
+ * const reviews = await client.listMerchantReviews();
1440
+ * ```
1441
+ */
1442
+ async listMerchantReviews() {
1443
+ return this.get("/api/marketplace/merchant/reviews");
1444
+ }
1445
+ /**
1446
+ * Respond to a review
1447
+ *
1448
+ * @param reviewId - Review ID
1449
+ * @param request - Response data
1450
+ * @returns Updated review
1451
+ *
1452
+ * @example
1453
+ * ```typescript
1454
+ * await client.respondToReview("review_123", {
1455
+ * merchantResponse: "Thank you for your feedback!"
1456
+ * });
1457
+ * ```
1458
+ */
1459
+ async respondToReview(reviewId, request) {
1460
+ return this.post(`/api/marketplace/merchant/reviews/${reviewId}/respond`, request);
1461
+ }
1462
+ /**
1463
+ * Flag a review as inappropriate
1464
+ *
1465
+ * @param reviewId - Review ID
1466
+ * @returns Updated review
1467
+ *
1468
+ * @example
1469
+ * ```typescript
1470
+ * await client.flagReview("review_123");
1471
+ * ```
1472
+ */
1473
+ async flagReview(reviewId) {
1474
+ return this.post(`/api/marketplace/merchant/reviews/${reviewId}/flag`);
1475
+ }
1476
+ // ============================================================================
1477
+ // Messages
1478
+ // ============================================================================
1479
+ /**
1480
+ * List messages/conversations
1481
+ *
1482
+ * @returns List of conversations grouped by order
1483
+ *
1484
+ * @example
1485
+ * ```typescript
1486
+ * const messages = await client.listMessages();
1487
+ * console.log("Unread:", messages.stats.unread);
1488
+ * ```
1489
+ */
1490
+ async listMessages() {
1491
+ return this.get("/api/marketplace/merchant/messages");
1492
+ }
1493
+ /**
1494
+ * Send a message to customer
1495
+ *
1496
+ * @param request - Message data
1497
+ * @returns Sent message
1498
+ *
1499
+ * @example
1500
+ * ```typescript
1501
+ * await client.sendMessage({
1502
+ * orderId: "ord_123",
1503
+ * recipientId: "user_456",
1504
+ * message: "Your order has been shipped!"
1505
+ * });
1506
+ * ```
1507
+ */
1508
+ async sendMessage(request) {
1509
+ return this.post("/api/marketplace/merchant/messages/send", request);
1510
+ }
1511
+ /**
1512
+ * Mark message as read
1513
+ *
1514
+ * @param messageId - Message ID
1515
+ * @returns Updated message
1516
+ *
1517
+ * @example
1518
+ * ```typescript
1519
+ * await client.markMessageRead("msg_123");
1520
+ * ```
1521
+ */
1522
+ async markMessageRead(messageId) {
1523
+ return this.patch(`/api/marketplace/merchant/messages/${messageId}/read`);
1524
+ }
1525
+ // ============================================================================
1526
+ // Media Library
1527
+ // ============================================================================
1528
+ /**
1529
+ * List media assets
1530
+ *
1531
+ * @param params - Query parameters
1532
+ * @returns Paginated list of media assets
1533
+ *
1534
+ * @example
1535
+ * ```typescript
1536
+ * const media = await client.listMediaAssets({ limit: 50, offset: 0 });
1537
+ * ```
1538
+ */
1539
+ async listMediaAssets(params) {
1540
+ const queryString = params ? buildQueryString(params) : "";
1541
+ return this.get(`/api/marketplace/merchant/media${queryString}`);
1542
+ }
1543
+ /**
1544
+ * Upload a media asset
1545
+ *
1546
+ * @param file - File to upload (max 10MB, images only)
1547
+ * @returns Uploaded asset
1548
+ *
1549
+ * @example
1550
+ * ```typescript
1551
+ * const formData = new FormData();
1552
+ * formData.append("file", imageFile);
1553
+ *
1554
+ * const asset = await client.uploadMediaAsset(formData);
1555
+ * console.log("Uploaded:", asset.asset.blobUrl);
1556
+ * ```
1557
+ */
1558
+ async uploadMediaAsset(formData) {
1559
+ return this.post("/api/marketplace/merchant/media/upload", formData, {
1560
+ headers: { "Content-Type": "multipart/form-data" }
1561
+ });
1562
+ }
1563
+ /**
1564
+ * Delete a media asset
1565
+ *
1566
+ * @param assetId - Asset ID
1567
+ * @returns Success response
1568
+ *
1569
+ * @example
1570
+ * ```typescript
1571
+ * await client.deleteMediaAsset("asset_123");
1572
+ * ```
1573
+ */
1574
+ async deleteMediaAsset(assetId) {
1575
+ return this.delete(`/api/marketplace/merchant/media?id=${assetId}`);
1576
+ }
1577
+ // ============================================================================
1578
+ // Banners
1579
+ // ============================================================================
1580
+ /**
1581
+ * List merchant's banners
1582
+ *
1583
+ * @returns List of banners
1584
+ *
1585
+ * @example
1586
+ * ```typescript
1587
+ * const banners = await client.listMerchantBanners();
1588
+ * ```
1589
+ */
1590
+ async listMerchantBanners() {
1591
+ return this.get("/api/marketplace/merchant/banners");
1592
+ }
1593
+ /**
1594
+ * Create a promotional banner
1595
+ *
1596
+ * @param request - Banner data
1597
+ * @returns Created banner
1598
+ *
1599
+ * @example
1600
+ * ```typescript
1601
+ * const banner = await client.createBanner({
1602
+ * title: "Summer Sale",
1603
+ * imageUrl: "https://...",
1604
+ * linkUrl: "/products?category=summer",
1605
+ * ctaText: "Shop Now",
1606
+ * priority: 10
1607
+ * });
1608
+ * ```
1609
+ */
1610
+ async createBanner(request) {
1611
+ return this.post("/api/marketplace/merchant/banners", request);
1612
+ }
1613
+ /**
1614
+ * Get banner details
1615
+ *
1616
+ * @param bannerId - Banner ID
1617
+ * @returns Banner details
1618
+ *
1619
+ * @example
1620
+ * ```typescript
1621
+ * const banner = await client.getBanner("banner_123");
1622
+ * ```
1623
+ */
1624
+ async getBanner(bannerId) {
1625
+ return this.get(`/api/marketplace/merchant/banners/${bannerId}`);
1626
+ }
1627
+ /**
1628
+ * Update a banner
1629
+ *
1630
+ * @param bannerId - Banner ID
1631
+ * @param request - Updated banner data
1632
+ * @returns Updated banner
1633
+ *
1634
+ * @example
1635
+ * ```typescript
1636
+ * await client.updateBanner("banner_123", {
1637
+ * isActive: false
1638
+ * });
1639
+ * ```
1640
+ */
1641
+ async updateBanner(bannerId, request) {
1642
+ return this.put(`/api/marketplace/merchant/banners/${bannerId}`, request);
1643
+ }
1644
+ /**
1645
+ * Delete a banner
1646
+ *
1647
+ * @param bannerId - Banner ID
1648
+ * @returns Success response
1649
+ *
1650
+ * @example
1651
+ * ```typescript
1652
+ * await client.deleteBanner("banner_123");
1653
+ * ```
1654
+ */
1655
+ async deleteBanner(bannerId) {
1656
+ return this.delete(`/api/marketplace/merchant/banners/${bannerId}`);
1657
+ }
1658
+ // ============================================================================
1659
+ // Analytics
1660
+ // ============================================================================
1661
+ /**
1662
+ * Get merchant analytics
1663
+ *
1664
+ * @param params - Query parameters
1665
+ * @returns Analytics data with overview, charts, and insights
1666
+ *
1667
+ * @example
1668
+ * ```typescript
1669
+ * const analytics = await client.getAnalytics({ range: "30days" });
1670
+ * console.log("Revenue:", analytics.overview.totalRevenue);
1671
+ * console.log("Orders:", analytics.overview.totalOrders);
1672
+ * ```
1673
+ */
1674
+ async getAnalytics(params) {
1675
+ const queryString = params ? buildQueryString(params) : "";
1676
+ return this.get(`/api/marketplace/merchant/analytics${queryString}`);
1677
+ }
1678
+ // ============================================================================
1679
+ // Inventory
1680
+ // ============================================================================
1681
+ /**
1682
+ * Get inventory audit log
1683
+ *
1684
+ * @returns Recent inventory audit entries (last 500)
1685
+ *
1686
+ * @example
1687
+ * ```typescript
1688
+ * const audit = await client.getInventoryAudit();
1689
+ * audit.entries.forEach(e => {
1690
+ * console.log(e.action, e.product.title, e.changeAmount);
1691
+ * });
1692
+ * ```
1693
+ */
1694
+ async getInventoryAudit() {
1695
+ return this.get("/api/marketplace/merchant/inventory/audit");
1696
+ }
1697
+ // ============================================================================
1698
+ // Tax Management
1699
+ // ============================================================================
1700
+ /**
1701
+ * Get tax settings
1702
+ *
1703
+ * @returns Tax settings
1704
+ *
1705
+ * @example
1706
+ * ```typescript
1707
+ * const settings = await client.getTaxSettings();
1708
+ * console.log("Tax enabled:", settings.settings.taxEnabled);
1709
+ * ```
1710
+ */
1711
+ async getTaxSettings() {
1712
+ return this.get("/api/marketplace/merchant/tax-settings");
1713
+ }
1714
+ /**
1715
+ * Update tax settings
1716
+ *
1717
+ * @param request - Updated settings
1718
+ * @returns Updated tax settings
1719
+ *
1720
+ * @example
1721
+ * ```typescript
1722
+ * await client.updateTaxSettings({
1723
+ * taxEnabled: true,
1724
+ * pricesIncludeTax: false,
1725
+ * defaultTaxBehavior: "CHARGE"
1726
+ * });
1727
+ * ```
1728
+ */
1729
+ async updateTaxSettings(request) {
1730
+ return this.put("/api/marketplace/merchant/tax-settings", request);
1731
+ }
1732
+ /**
1733
+ * List tax rules
1734
+ *
1735
+ * @returns List of tax rules
1736
+ *
1737
+ * @example
1738
+ * ```typescript
1739
+ * const rules = await client.listTaxRules();
1740
+ * ```
1741
+ */
1742
+ async listTaxRules() {
1743
+ return this.get("/api/marketplace/merchant/tax-rules");
1744
+ }
1745
+ /**
1746
+ * Create a tax rule
1747
+ *
1748
+ * @param request - Tax rule data
1749
+ * @returns Created tax rule
1750
+ *
1751
+ * @example
1752
+ * ```typescript
1753
+ * const rule = await client.createTaxRule({
1754
+ * country: "US",
1755
+ * region: "NY",
1756
+ * taxType: "SALES_TAX",
1757
+ * taxName: "NY Sales Tax",
1758
+ * taxRate: 8.875
1759
+ * });
1760
+ * ```
1761
+ */
1762
+ async createTaxRule(request) {
1763
+ return this.post("/api/marketplace/merchant/tax-rules", request);
1764
+ }
1765
+ /**
1766
+ * Get tax rule details
1767
+ *
1768
+ * @param ruleId - Rule ID
1769
+ * @returns Tax rule details
1770
+ *
1771
+ * @example
1772
+ * ```typescript
1773
+ * const rule = await client.getTaxRule("rule_123");
1774
+ * ```
1775
+ */
1776
+ async getTaxRule(ruleId) {
1777
+ return this.get(`/api/marketplace/merchant/tax-rules/${ruleId}`);
1778
+ }
1779
+ /**
1780
+ * Update a tax rule
1781
+ *
1782
+ * @param ruleId - Rule ID
1783
+ * @param request - Updated rule data
1784
+ * @returns Updated tax rule
1785
+ *
1786
+ * @example
1787
+ * ```typescript
1788
+ * await client.updateTaxRule("rule_123", {
1789
+ * taxRate: 9.0
1790
+ * });
1791
+ * ```
1792
+ */
1793
+ async updateTaxRule(ruleId, request) {
1794
+ return this.put(`/api/marketplace/merchant/tax-rules/${ruleId}`, request);
1795
+ }
1796
+ /**
1797
+ * Delete a tax rule
1798
+ *
1799
+ * @param ruleId - Rule ID
1800
+ * @returns Success response
1801
+ *
1802
+ * @example
1803
+ * ```typescript
1804
+ * await client.deleteTaxRule("rule_123");
1805
+ * ```
1806
+ */
1807
+ async deleteTaxRule(ruleId) {
1808
+ return this.delete(`/api/marketplace/merchant/tax-rules/${ruleId}`);
1809
+ }
1810
+ /**
1811
+ * List tax nexus locations
1812
+ *
1813
+ * @returns List of nexus locations
1814
+ *
1815
+ * @example
1816
+ * ```typescript
1817
+ * const nexus = await client.listTaxNexus();
1818
+ * ```
1819
+ */
1820
+ async listTaxNexus() {
1821
+ return this.get("/api/marketplace/merchant/tax-nexus");
1822
+ }
1823
+ /**
1824
+ * Add a tax nexus location
1825
+ *
1826
+ * @param request - Nexus data
1827
+ * @returns Created nexus
1828
+ *
1829
+ * @example
1830
+ * ```typescript
1831
+ * const nexus = await client.createTaxNexus({
1832
+ * country: "US",
1833
+ * region: "CA",
1834
+ * registrationId: "123456789"
1835
+ * });
1836
+ * ```
1837
+ */
1838
+ async createTaxNexus(request) {
1839
+ return this.post("/api/marketplace/merchant/tax-nexus", request);
1840
+ }
1841
+ /**
1842
+ * Update a tax nexus location
1843
+ *
1844
+ * @param nexusId - Nexus ID
1845
+ * @param request - Updated nexus data
1846
+ * @returns Updated nexus
1847
+ *
1848
+ * @example
1849
+ * ```typescript
1850
+ * await client.updateTaxNexus("nexus_123", {
1851
+ * registrationId: "987654321"
1852
+ * });
1853
+ * ```
1854
+ */
1855
+ async updateTaxNexus(nexusId, request) {
1856
+ return this.put(`/api/marketplace/merchant/tax-nexus/${nexusId}`, request);
1857
+ }
1858
+ /**
1859
+ * Delete a tax nexus location
1860
+ *
1861
+ * @param nexusId - Nexus ID
1862
+ * @returns Success response
1863
+ *
1864
+ * @example
1865
+ * ```typescript
1866
+ * await client.deleteTaxNexus("nexus_123");
1867
+ * ```
1868
+ */
1869
+ async deleteTaxNexus(nexusId) {
1870
+ return this.delete(`/api/marketplace/merchant/tax-nexus/${nexusId}`);
1871
+ }
1872
+ /**
1873
+ * List tax reports
1874
+ *
1875
+ * @param params - Query parameters
1876
+ * @returns Paginated list of tax reports
1877
+ *
1878
+ * @example
1879
+ * ```typescript
1880
+ * const reports = await client.listTaxReports({ limit: 20, offset: 0 });
1881
+ *
1882
+ * // Get summary for a specific year
1883
+ * const summary = await client.listTaxReports({ year: 2025 });
1884
+ * ```
1885
+ */
1886
+ async listTaxReports(params) {
1887
+ const queryString = params ? buildQueryString(params) : "";
1888
+ return this.get(`/api/marketplace/merchant/tax-reports${queryString}`);
1889
+ }
1890
+ /**
1891
+ * Generate a tax report
1892
+ *
1893
+ * @param request - Report generation request
1894
+ * @returns Generated report
1895
+ *
1896
+ * @example
1897
+ * ```typescript
1898
+ * const report = await client.generateTaxReport({
1899
+ * periodType: "MONTHLY",
1900
+ * year: 2025,
1901
+ * period: 1 // January
1902
+ * });
1903
+ * ```
1904
+ */
1905
+ async generateTaxReport(request) {
1906
+ return this.post("/api/marketplace/merchant/tax-reports/generate", request);
1907
+ }
1908
+ /**
1909
+ * Get tax report details
1910
+ *
1911
+ * @param reportId - Report ID
1912
+ * @returns Report with detailed records
1913
+ *
1914
+ * @example
1915
+ * ```typescript
1916
+ * const report = await client.getTaxReport("report_123");
1917
+ * console.log("Total tax:", report.report.totalTax);
1918
+ * ```
1919
+ */
1920
+ async getTaxReport(reportId) {
1921
+ return this.get(`/api/marketplace/merchant/tax-reports/${reportId}`);
1922
+ }
1923
+ /**
1924
+ * Update tax report status
1925
+ *
1926
+ * @param reportId - Report ID
1927
+ * @param request - Status update
1928
+ * @returns Updated report
1929
+ *
1930
+ * @example
1931
+ * ```typescript
1932
+ * await client.updateTaxReportStatus("report_123", {
1933
+ * status: "FINALIZED"
1934
+ * });
1935
+ * ```
1936
+ */
1937
+ async updateTaxReportStatus(reportId, request) {
1938
+ return this.put(`/api/marketplace/merchant/tax-reports/${reportId}`, request);
1939
+ }
1940
+ /**
1941
+ * Export tax report as CSV
1942
+ *
1943
+ * @param reportId - Report ID
1944
+ * @returns CSV file data
1945
+ *
1946
+ * @example
1947
+ * ```typescript
1948
+ * const csv = await client.exportTaxReport("report_123");
1949
+ * // Save or download the CSV
1950
+ * ```
1951
+ */
1952
+ async exportTaxReport(reportId) {
1953
+ return this.get(`/api/marketplace/merchant/tax-reports/${reportId}/export`);
1954
+ }
1955
+ };
1956
+
1957
+ // lib/ecommerce/types/enums.ts
1958
+ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
1959
+ OrderStatus2["CREATED"] = "CREATED";
1960
+ OrderStatus2["AWAITING_DEPOSIT"] = "AWAITING_DEPOSIT";
1961
+ OrderStatus2["PAYMENT_RESERVED"] = "PAYMENT_RESERVED";
1962
+ OrderStatus2["MERCHANT_ACCEPTED"] = "MERCHANT_ACCEPTED";
1963
+ OrderStatus2["SHIPPED"] = "SHIPPED";
1964
+ OrderStatus2["DELIVERED"] = "DELIVERED";
1965
+ OrderStatus2["CANCELLED"] = "CANCELLED";
1966
+ OrderStatus2["CONFIRMED"] = "CONFIRMED";
1967
+ OrderStatus2["COMPLETED"] = "COMPLETED";
1968
+ return OrderStatus2;
1969
+ })(OrderStatus || {});
1970
+ var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
1971
+ PaymentMethod2["USDC_ESCROW"] = "USDC_ESCROW";
1972
+ PaymentMethod2["POINTS"] = "POINTS";
1973
+ return PaymentMethod2;
1974
+ })(PaymentMethod || {});
1975
+ var PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
1976
+ PaymentStatus2["PENDING"] = "PENDING";
1977
+ PaymentStatus2["RESERVED"] = "RESERVED";
1978
+ PaymentStatus2["COMPLETED"] = "COMPLETED";
1979
+ PaymentStatus2["FAILED"] = "FAILED";
1980
+ PaymentStatus2["REFUNDED"] = "REFUNDED";
1981
+ return PaymentStatus2;
1982
+ })(PaymentStatus || {});
1983
+ var MerchantStatus = /* @__PURE__ */ ((MerchantStatus2) => {
1984
+ MerchantStatus2["ACTIVE"] = "ACTIVE";
1985
+ MerchantStatus2["SUSPENDED"] = "SUSPENDED";
1986
+ MerchantStatus2["PENDING"] = "PENDING";
1987
+ return MerchantStatus2;
1988
+ })(MerchantStatus || {});
1989
+ var ShipmentStatus = /* @__PURE__ */ ((ShipmentStatus2) => {
1990
+ ShipmentStatus2["PENDING"] = "PENDING";
1991
+ ShipmentStatus2["SHIPPED"] = "SHIPPED";
1992
+ ShipmentStatus2["DELIVERED"] = "DELIVERED";
1993
+ ShipmentStatus2["FAILED"] = "FAILED";
1994
+ return ShipmentStatus2;
1995
+ })(ShipmentStatus || {});
1996
+ var ReturnStatus = /* @__PURE__ */ ((ReturnStatus2) => {
1997
+ ReturnStatus2["REQUESTED"] = "REQUESTED";
1998
+ ReturnStatus2["APPROVED"] = "APPROVED";
1999
+ ReturnStatus2["REJECTED"] = "REJECTED";
2000
+ ReturnStatus2["SHIPPED_BACK"] = "SHIPPED_BACK";
2001
+ ReturnStatus2["RECEIVED"] = "RECEIVED";
2002
+ ReturnStatus2["REFUNDED"] = "REFUNDED";
2003
+ return ReturnStatus2;
2004
+ })(ReturnStatus || {});
2005
+ var ReviewStatus = /* @__PURE__ */ ((ReviewStatus2) => {
2006
+ ReviewStatus2["PENDING"] = "PENDING";
2007
+ ReviewStatus2["RESPONDED"] = "RESPONDED";
2008
+ ReviewStatus2["FLAGGED"] = "FLAGGED";
2009
+ return ReviewStatus2;
2010
+ })(ReviewStatus || {});
2011
+ var DiscountType = /* @__PURE__ */ ((DiscountType2) => {
2012
+ DiscountType2["PERCENTAGE"] = "PERCENTAGE";
2013
+ DiscountType2["FIXED_AMOUNT"] = "FIXED_AMOUNT";
2014
+ DiscountType2["BUY_X_GET_Y"] = "BUY_X_GET_Y";
2015
+ DiscountType2["FREE_SHIPPING"] = "FREE_SHIPPING";
2016
+ return DiscountType2;
2017
+ })(DiscountType || {});
2018
+ var DiscountMethod = /* @__PURE__ */ ((DiscountMethod2) => {
2019
+ DiscountMethod2["CODE"] = "CODE";
2020
+ DiscountMethod2["AUTOMATIC"] = "AUTOMATIC";
2021
+ return DiscountMethod2;
2022
+ })(DiscountMethod || {});
2023
+ var DiscountScope = /* @__PURE__ */ ((DiscountScope2) => {
2024
+ DiscountScope2["ORDER"] = "ORDER";
2025
+ DiscountScope2["PRODUCT"] = "PRODUCT";
2026
+ DiscountScope2["CATEGORY"] = "CATEGORY";
2027
+ DiscountScope2["SHIPPING"] = "SHIPPING";
2028
+ return DiscountScope2;
2029
+ })(DiscountScope || {});
2030
+ var BannerType = /* @__PURE__ */ ((BannerType2) => {
2031
+ BannerType2["HERO"] = "HERO";
2032
+ BannerType2["PROMO"] = "PROMO";
2033
+ BannerType2["FEATURED"] = "FEATURED";
2034
+ return BannerType2;
2035
+ })(BannerType || {});
2036
+ var TaxType = /* @__PURE__ */ ((TaxType2) => {
2037
+ TaxType2["SALES_TAX"] = "SALES_TAX";
2038
+ TaxType2["VAT"] = "VAT";
2039
+ TaxType2["GST"] = "GST";
2040
+ TaxType2["PST"] = "PST";
2041
+ TaxType2["HST"] = "HST";
2042
+ return TaxType2;
2043
+ })(TaxType || {});
2044
+ var TaxBehavior = /* @__PURE__ */ ((TaxBehavior2) => {
2045
+ TaxBehavior2["CHARGE"] = "CHARGE";
2046
+ TaxBehavior2["INCLUSIVE"] = "INCLUSIVE";
2047
+ TaxBehavior2["EXEMPT"] = "EXEMPT";
2048
+ return TaxBehavior2;
2049
+ })(TaxBehavior || {});
2050
+ var TaxReportPeriodType = /* @__PURE__ */ ((TaxReportPeriodType2) => {
2051
+ TaxReportPeriodType2["MONTHLY"] = "MONTHLY";
2052
+ TaxReportPeriodType2["QUARTERLY"] = "QUARTERLY";
2053
+ TaxReportPeriodType2["YEARLY"] = "YEARLY";
2054
+ return TaxReportPeriodType2;
2055
+ })(TaxReportPeriodType || {});
2056
+ var TaxReportStatus = /* @__PURE__ */ ((TaxReportStatus2) => {
2057
+ TaxReportStatus2["DRAFT"] = "DRAFT";
2058
+ TaxReportStatus2["FINALIZED"] = "FINALIZED";
2059
+ TaxReportStatus2["FILED"] = "FILED";
2060
+ return TaxReportStatus2;
2061
+ })(TaxReportStatus || {});
2062
+ var InventoryAuditAction = /* @__PURE__ */ ((InventoryAuditAction2) => {
2063
+ InventoryAuditAction2["CREATED"] = "CREATED";
2064
+ InventoryAuditAction2["UPDATED"] = "UPDATED";
2065
+ InventoryAuditAction2["RESERVED"] = "RESERVED";
2066
+ InventoryAuditAction2["DEDUCTED"] = "DEDUCTED";
2067
+ InventoryAuditAction2["RESTORED"] = "RESTORED";
2068
+ return InventoryAuditAction2;
2069
+ })(InventoryAuditAction || {});
2070
+ var SortOrder = /* @__PURE__ */ ((SortOrder2) => {
2071
+ SortOrder2["ASC"] = "asc";
2072
+ SortOrder2["DESC"] = "desc";
2073
+ return SortOrder2;
2074
+ })(SortOrder || {});
2075
+ var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
2076
+ ProductSortBy2["DATE_DESC"] = "date_desc";
2077
+ ProductSortBy2["DATE_ASC"] = "date_asc";
2078
+ ProductSortBy2["PRICE_ASC"] = "price_asc";
2079
+ ProductSortBy2["PRICE_DESC"] = "price_desc";
2080
+ ProductSortBy2["POPULAR"] = "popular";
2081
+ ProductSortBy2["FEATURED"] = "featured";
2082
+ return ProductSortBy2;
2083
+ })(ProductSortBy || {});
2084
+ var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
2085
+ ReviewSortBy2["NEWEST"] = "newest";
2086
+ ReviewSortBy2["HIGHEST"] = "highest";
2087
+ ReviewSortBy2["LOWEST"] = "lowest";
2088
+ return ReviewSortBy2;
2089
+ })(ReviewSortBy || {});
2090
+
2091
+ 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 };