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