@basedone/core 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-P5C65GIG.mjs → chunk-L63E7FZC.mjs} +174 -113
- package/dist/ecommerce.d.mts +103 -13
- package/dist/ecommerce.d.ts +103 -13
- package/dist/ecommerce.js +174 -113
- package/dist/ecommerce.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +174 -113
- package/dist/index.mjs +1 -1
- package/lib/ecommerce/client/customer.ts +276 -183
- package/lib/ecommerce/types/entities.ts +20 -8
- package/lib/ecommerce/types/requests.ts +22 -4
- package/lib/ecommerce/types/responses.ts +90 -48
- package/package.json +10 -8
|
@@ -869,17 +869,29 @@ export interface ShippingRate extends BaseEntity {
|
|
|
869
869
|
|
|
870
870
|
/**
|
|
871
871
|
* Shipping option (calculated for checkout)
|
|
872
|
+
*
|
|
873
|
+
* Use `rateId` when creating orders - the server will validate and calculate cost.
|
|
872
874
|
*/
|
|
873
875
|
export interface ShippingOption {
|
|
874
|
-
/** Rate ID */
|
|
875
|
-
|
|
876
|
-
/** Rate name */
|
|
877
|
-
name: string;
|
|
878
|
-
/** Calculated cost in USDC */
|
|
879
|
-
cost: number;
|
|
880
|
-
/** Estimated delivery string */
|
|
881
|
-
estimatedDelivery: string;
|
|
876
|
+
/** Rate ID - use this when creating orders */
|
|
877
|
+
rateId: string;
|
|
882
878
|
/** Zone name */
|
|
883
879
|
zoneName: string;
|
|
880
|
+
/** Rate name (e.g., "Standard", "Express") */
|
|
881
|
+
rateName: string;
|
|
882
|
+
/** Base rate in USDC */
|
|
883
|
+
baseRate: number;
|
|
884
|
+
/** Per-kg rate in USDC */
|
|
885
|
+
perKgRate: number;
|
|
886
|
+
/** Calculated total cost in USDC (for display only - server recalculates) */
|
|
887
|
+
calculatedCost: number;
|
|
888
|
+
/** Whether free shipping applies */
|
|
889
|
+
isFree: boolean;
|
|
890
|
+
/** Estimated delivery string (e.g., "5-7 business days") */
|
|
891
|
+
estimatedDelivery: string | null;
|
|
892
|
+
/** Minimum delivery days */
|
|
893
|
+
minDeliveryDays: number | null;
|
|
894
|
+
/** Maximum delivery days */
|
|
895
|
+
maxDeliveryDays: number | null;
|
|
884
896
|
}
|
|
885
897
|
|
|
@@ -150,13 +150,31 @@ export interface CreateOrderRequest {
|
|
|
150
150
|
couponCode?: string;
|
|
151
151
|
/** Idempotency key */
|
|
152
152
|
idempotencyKey?: string;
|
|
153
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Selected shipping rate ID (from shipping calculator)
|
|
155
|
+
* The server will validate this rate and calculate the cost server-side.
|
|
156
|
+
* SECURITY: The cost is never trusted from the frontend.
|
|
157
|
+
*/
|
|
158
|
+
shippingRateId?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Shipping method name (e.g., "On-site Collection")
|
|
161
|
+
* Sent as fallback when validation is disabled, so the method name can still be stored.
|
|
162
|
+
*/
|
|
163
|
+
shippingMethodName?: string;
|
|
164
|
+
|
|
165
|
+
// =====================================================
|
|
166
|
+
// DEPRECATED FIELDS - Do not use
|
|
167
|
+
// These fields are ignored by the server for security reasons.
|
|
168
|
+
// Shipping cost must be calculated server-side using shippingRateId.
|
|
169
|
+
// =====================================================
|
|
170
|
+
|
|
171
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
154
172
|
shippingMethod?: string;
|
|
155
|
-
/**
|
|
173
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
156
174
|
shippingCost?: number;
|
|
157
|
-
/**
|
|
175
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
158
176
|
shippingZone?: string;
|
|
159
|
-
/**
|
|
177
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
160
178
|
estimatedDelivery?: string;
|
|
161
179
|
}
|
|
162
180
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Ecommerce API Response Types
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This module contains all response types for the ecommerce API.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -61,7 +61,7 @@ export interface ListProductsResponse extends PaginatedResponse<Product> {}
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Get product response
|
|
64
|
-
*
|
|
64
|
+
*
|
|
65
65
|
* Note: The API returns the product object directly, not wrapped in a `product` field.
|
|
66
66
|
* This type extends Product to be compatible with the actual API response.
|
|
67
67
|
*/
|
|
@@ -465,11 +465,13 @@ export interface CouponResponse {
|
|
|
465
465
|
export interface GetCouponResponse {
|
|
466
466
|
/** Coupon with usages */
|
|
467
467
|
coupon: Coupon & {
|
|
468
|
-
usages: Array<
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
468
|
+
usages: Array<
|
|
469
|
+
CouponUsage & {
|
|
470
|
+
user: {
|
|
471
|
+
username?: string;
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
>;
|
|
473
475
|
};
|
|
474
476
|
}
|
|
475
477
|
|
|
@@ -494,17 +496,19 @@ export interface ShippingMethodResponse {
|
|
|
494
496
|
*/
|
|
495
497
|
export interface ListShipmentsResponse {
|
|
496
498
|
/** Shipments */
|
|
497
|
-
shipments: Array<
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
totalUSDC: string;
|
|
501
|
-
shippingAddress: any;
|
|
502
|
-
user: {
|
|
499
|
+
shipments: Array<
|
|
500
|
+
Shipment & {
|
|
501
|
+
order: {
|
|
503
502
|
id: string;
|
|
504
|
-
|
|
503
|
+
totalUSDC: string;
|
|
504
|
+
shippingAddress: any;
|
|
505
|
+
user: {
|
|
506
|
+
id: string;
|
|
507
|
+
username?: string;
|
|
508
|
+
};
|
|
505
509
|
};
|
|
506
|
-
}
|
|
507
|
-
|
|
510
|
+
}
|
|
511
|
+
>;
|
|
508
512
|
}
|
|
509
513
|
|
|
510
514
|
/**
|
|
@@ -520,16 +524,18 @@ export interface ShipmentResponse {
|
|
|
520
524
|
*/
|
|
521
525
|
export interface ListReturnsResponse {
|
|
522
526
|
/** Returns */
|
|
523
|
-
returns: Array<
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
527
|
+
returns: Array<
|
|
528
|
+
Return & {
|
|
529
|
+
user: {
|
|
530
|
+
id: string;
|
|
531
|
+
username?: string;
|
|
532
|
+
};
|
|
533
|
+
order: {
|
|
534
|
+
id: string;
|
|
535
|
+
totalUSDC: string;
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
>;
|
|
533
539
|
}
|
|
534
540
|
|
|
535
541
|
/**
|
|
@@ -603,7 +609,7 @@ export interface MessageResponse {
|
|
|
603
609
|
|
|
604
610
|
/**
|
|
605
611
|
* Customer messages response (for retail users)
|
|
606
|
-
*
|
|
612
|
+
*
|
|
607
613
|
* Groups messages by order, where each order represents a conversation with a merchant.
|
|
608
614
|
*/
|
|
609
615
|
export interface CustomerMessagesResponse {
|
|
@@ -790,17 +796,19 @@ export interface GetProductMetricsResponse {
|
|
|
790
796
|
*/
|
|
791
797
|
export interface ListInventoryAuditResponse {
|
|
792
798
|
/** Entries */
|
|
793
|
-
entries: Array<
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
799
|
+
entries: Array<
|
|
800
|
+
InventoryAuditEntry & {
|
|
801
|
+
product: {
|
|
802
|
+
id: string;
|
|
803
|
+
title: string;
|
|
804
|
+
images: string[];
|
|
805
|
+
};
|
|
806
|
+
variant?: {
|
|
807
|
+
id: string;
|
|
808
|
+
name: string;
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
>;
|
|
804
812
|
}
|
|
805
813
|
|
|
806
814
|
/**
|
|
@@ -997,14 +1005,16 @@ import type {
|
|
|
997
1005
|
*/
|
|
998
1006
|
export interface ShippingSettingsResponse {
|
|
999
1007
|
/** Shipping settings */
|
|
1000
|
-
settings:
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
+
settings:
|
|
1009
|
+
| MerchantShippingSettings
|
|
1010
|
+
| {
|
|
1011
|
+
defaultHandlingFee: number;
|
|
1012
|
+
defaultProcessingDays: number;
|
|
1013
|
+
freeShippingEnabled: boolean;
|
|
1014
|
+
freeShippingThreshold: number | null;
|
|
1015
|
+
defaultWeightKg: number;
|
|
1016
|
+
showEstimatedDelivery: boolean;
|
|
1017
|
+
};
|
|
1008
1018
|
}
|
|
1009
1019
|
|
|
1010
1020
|
/**
|
|
@@ -1118,7 +1128,13 @@ export interface ProcessPaymentResponse {
|
|
|
1118
1128
|
/** Blockchain transaction hash (for crypto payments) */
|
|
1119
1129
|
transactionHash?: string;
|
|
1120
1130
|
/** Payment status */
|
|
1121
|
-
status:
|
|
1131
|
+
status:
|
|
1132
|
+
| "PENDING"
|
|
1133
|
+
| "PROCESSING"
|
|
1134
|
+
| "COMPLETED"
|
|
1135
|
+
| "FAILED"
|
|
1136
|
+
| "CANCELLED"
|
|
1137
|
+
| "REFUNDED";
|
|
1122
1138
|
/** Amount charged */
|
|
1123
1139
|
amount: number;
|
|
1124
1140
|
/** Currency */
|
|
@@ -1136,7 +1152,7 @@ export interface ProcessPaymentResponse {
|
|
|
1136
1152
|
/**
|
|
1137
1153
|
* Gem source type - how gems were earned
|
|
1138
1154
|
*/
|
|
1139
|
-
export type GemSource =
|
|
1155
|
+
export type GemSource =
|
|
1140
1156
|
| "BUILDER_CODE"
|
|
1141
1157
|
| "PREDICTION"
|
|
1142
1158
|
| "CARD_SPEND"
|
|
@@ -1295,3 +1311,29 @@ export interface DeleteBrowsingLocationResponse {
|
|
|
1295
1311
|
message: string;
|
|
1296
1312
|
}
|
|
1297
1313
|
|
|
1314
|
+
// ============================================================================
|
|
1315
|
+
// BasedPay Cash Account Responses
|
|
1316
|
+
// ============================================================================
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Cash account balance response
|
|
1320
|
+
*/
|
|
1321
|
+
export interface CashAccountBalanceResponse {
|
|
1322
|
+
/** Balance amount */
|
|
1323
|
+
balance: string;
|
|
1324
|
+
/** Currency code (e.g., "USD") */
|
|
1325
|
+
currency: string;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
export interface DeliveryAddressResponse {
|
|
1329
|
+
name: string;
|
|
1330
|
+
phoneNumber: string;
|
|
1331
|
+
deliveryAddress: {
|
|
1332
|
+
addressLine1: string;
|
|
1333
|
+
addressLine2?: string | null;
|
|
1334
|
+
postalCode: string;
|
|
1335
|
+
city: string | null;
|
|
1336
|
+
region: string | null;
|
|
1337
|
+
country: string;
|
|
1338
|
+
};
|
|
1339
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basedone/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Core utilities for Based One",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -30,9 +30,17 @@
|
|
|
30
30
|
"ecommerce.ts",
|
|
31
31
|
"lib"
|
|
32
32
|
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "rm -rf dist && tsup index.ts react.ts ecommerce.ts --format cjs,esm --dts",
|
|
35
|
+
"dev": "tsup index.ts react.ts ecommerce.ts --format cjs,esm --dts --watch",
|
|
36
|
+
"test": "vitest",
|
|
37
|
+
"update-meta": "tsx scripts/update-static-meta.ts",
|
|
38
|
+
"prepublishOnly": "pnpm build"
|
|
39
|
+
},
|
|
33
40
|
"keywords": [],
|
|
34
41
|
"author": "",
|
|
35
42
|
"license": "ISC",
|
|
43
|
+
"packageManager": "pnpm@10.10.0",
|
|
36
44
|
"devDependencies": {
|
|
37
45
|
"@types/node": "^20.0.0",
|
|
38
46
|
"@types/react": "^18.0.0",
|
|
@@ -54,11 +62,5 @@
|
|
|
54
62
|
"react": {
|
|
55
63
|
"optional": true
|
|
56
64
|
}
|
|
57
|
-
},
|
|
58
|
-
"scripts": {
|
|
59
|
-
"build": "rm -rf dist && tsup index.ts react.ts ecommerce.ts --format cjs,esm --dts",
|
|
60
|
-
"dev": "tsup index.ts react.ts ecommerce.ts --format cjs,esm --dts --watch",
|
|
61
|
-
"test": "vitest",
|
|
62
|
-
"update-meta": "tsx scripts/update-static-meta.ts"
|
|
63
65
|
}
|
|
64
|
-
}
|
|
66
|
+
}
|