@classytic/commerce-sdk 0.1.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.
- package/LICENSE +14 -0
- package/README.md +164 -0
- package/dist/adjustment-MNH3AT6S.js +5 -0
- package/dist/adjustment-MNH3AT6S.js.map +1 -0
- package/dist/analytics/index.d.ts +27 -0
- package/dist/analytics/index.js +6 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics-DMcD-o8w.d.ts +76 -0
- package/dist/api-factory-B_h4RKBm.d.ts +280 -0
- package/dist/auth/index.d.ts +39 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/catalog/index.d.ts +571 -0
- package/dist/catalog/index.js +9 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/chunk-24FDD6UR.js +75 -0
- package/dist/chunk-24FDD6UR.js.map +1 -0
- package/dist/chunk-2TF7QNYV.js +159 -0
- package/dist/chunk-2TF7QNYV.js.map +1 -0
- package/dist/chunk-2YAZ5WG6.js +479 -0
- package/dist/chunk-2YAZ5WG6.js.map +1 -0
- package/dist/chunk-36NLLAVH.js +177 -0
- package/dist/chunk-36NLLAVH.js.map +1 -0
- package/dist/chunk-3OYSJB3P.js +126 -0
- package/dist/chunk-3OYSJB3P.js.map +1 -0
- package/dist/chunk-5E57JODA.js +135 -0
- package/dist/chunk-5E57JODA.js.map +1 -0
- package/dist/chunk-7LZCW4VF.js +13 -0
- package/dist/chunk-7LZCW4VF.js.map +1 -0
- package/dist/chunk-ANYGZ6O5.js +830 -0
- package/dist/chunk-ANYGZ6O5.js.map +1 -0
- package/dist/chunk-AQAISI4F.js +183 -0
- package/dist/chunk-AQAISI4F.js.map +1 -0
- package/dist/chunk-B6MPVOV7.js +328 -0
- package/dist/chunk-B6MPVOV7.js.map +1 -0
- package/dist/chunk-CILP56G2.js +94 -0
- package/dist/chunk-CILP56G2.js.map +1 -0
- package/dist/chunk-ERQ52WHY.js +534 -0
- package/dist/chunk-ERQ52WHY.js.map +1 -0
- package/dist/chunk-FOTUJPM4.js +640 -0
- package/dist/chunk-FOTUJPM4.js.map +1 -0
- package/dist/chunk-IHCBBLLW.js +198 -0
- package/dist/chunk-IHCBBLLW.js.map +1 -0
- package/dist/chunk-J4JBQET2.js +76 -0
- package/dist/chunk-J4JBQET2.js.map +1 -0
- package/dist/chunk-L4OEI4VZ.js +123 -0
- package/dist/chunk-L4OEI4VZ.js.map +1 -0
- package/dist/chunk-LRV7MWWX.js +616 -0
- package/dist/chunk-LRV7MWWX.js.map +1 -0
- package/dist/chunk-N43VE355.js +126 -0
- package/dist/chunk-N43VE355.js.map +1 -0
- package/dist/chunk-PYYLHUV6.js +3 -0
- package/dist/chunk-PYYLHUV6.js.map +1 -0
- package/dist/chunk-QCTXAMLA.js +261 -0
- package/dist/chunk-QCTXAMLA.js.map +1 -0
- package/dist/chunk-RIKAPJNG.js +40 -0
- package/dist/chunk-RIKAPJNG.js.map +1 -0
- package/dist/chunk-U3XT35GZ.js +202 -0
- package/dist/chunk-U3XT35GZ.js.map +1 -0
- package/dist/chunk-W22WB3WZ.js +148 -0
- package/dist/chunk-W22WB3WZ.js.map +1 -0
- package/dist/chunk-WTIJMKML.js +27 -0
- package/dist/chunk-WTIJMKML.js.map +1 -0
- package/dist/chunk-X2CQFJPR.js +75 -0
- package/dist/chunk-X2CQFJPR.js.map +1 -0
- package/dist/chunk-YYFKLOKO.js +769 -0
- package/dist/chunk-YYFKLOKO.js.map +1 -0
- package/dist/client-Cs7E_usr.d.ts +113 -0
- package/dist/content/index.d.ts +309 -0
- package/dist/content/index.js +6 -0
- package/dist/content/index.js.map +1 -0
- package/dist/core/index.d.ts +166 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/react.d.ts +107 -0
- package/dist/core/react.js +5 -0
- package/dist/core/react.js.map +1 -0
- package/dist/coupon-BZSZ0y3n.d.ts +129 -0
- package/dist/coupon-CDzL4bJG.d.ts +655 -0
- package/dist/crud.factory-DyKaPHcU.d.ts +181 -0
- package/dist/finance/index.d.ts +81 -0
- package/dist/finance/index.js +5 -0
- package/dist/finance/index.js.map +1 -0
- package/dist/finance-BJdfKRw0.d.ts +135 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory/index.d.ts +512 -0
- package/dist/inventory/index.js +16 -0
- package/dist/inventory/index.js.map +1 -0
- package/dist/inventory-B5pssqRx.d.ts +748 -0
- package/dist/logistics/index.d.ts +248 -0
- package/dist/logistics/index.js +7 -0
- package/dist/logistics/index.js.map +1 -0
- package/dist/logistics-CrpKadKE.d.ts +410 -0
- package/dist/media-CNLJK93J.d.ts +721 -0
- package/dist/movement-R3CERFAM.js +5 -0
- package/dist/movement-R3CERFAM.js.map +1 -0
- package/dist/order-B3dCvHgK.d.ts +360 -0
- package/dist/payment-BRboLqvU.d.ts +127 -0
- package/dist/payments/index.d.ts +55 -0
- package/dist/payments/index.js +6 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/platform/index.d.ts +645 -0
- package/dist/platform/index.js +8 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/pos-BCqkx2-K.d.ts +527 -0
- package/dist/product-p09zXkXB.d.ts +260 -0
- package/dist/purchase-54PER2PY.js +5 -0
- package/dist/purchase-54PER2PY.js.map +1 -0
- package/dist/request-MP6NV5ZE.js +5 -0
- package/dist/request-MP6NV5ZE.js.map +1 -0
- package/dist/sales/index.d.ts +587 -0
- package/dist/sales/index.js +9 -0
- package/dist/sales/index.js.map +1 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.js +37 -0
- package/dist/server.js.map +1 -0
- package/dist/size-guide-DgjzjM5P.d.ts +554 -0
- package/dist/stock-2LP4HJSB.js +5 -0
- package/dist/stock-2LP4HJSB.js.map +1 -0
- package/dist/stock-CfrU5_Wr.d.ts +632 -0
- package/dist/supplier-BWJTRZ5Z.js +5 -0
- package/dist/supplier-BWJTRZ5Z.js.map +1 -0
- package/dist/transaction/index.d.ts +104 -0
- package/dist/transaction/index.js +8 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction-Bf6WjYCh.d.ts +84 -0
- package/dist/transaction-dL3WW-er.d.ts +442 -0
- package/dist/transfer-4XSS6HWT.js +5 -0
- package/dist/transfer-4XSS6HWT.js.map +1 -0
- package/dist/user-data-DdLjAGwO.d.ts +132 -0
- package/package.json +147 -0
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import { e as Product, b as ProductVariant } from './product-p09zXkXB.js';
|
|
2
|
+
import { P as PaginatedResponse, A as ApiResponse, B as BaseApi, R as RequestOptions } from './api-factory-B_h4RKBm.js';
|
|
3
|
+
import { b as Order, l as CreateOrderPayload, U as UpdateStatusPayload, F as FulfillOrderPayload, R as RefundOrderPayload, h as OrderShipping, o as RequestShippingPayload, p as UpdateShippingPayload } from './order-B3dCvHgK.js';
|
|
4
|
+
import { a as PosProductsResponse, g as PosLookupResponse, l as PosOrderPayload, ac as CreateAdjustmentPayload, ad as BulkAdjustmentPayload } from './inventory-B5pssqRx.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Cart Types
|
|
8
|
+
*
|
|
9
|
+
* Type definitions for shopping cart matching the backend cart schema.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Cart Item (Backend Response Format)
|
|
14
|
+
* Represents a single item in the shopping cart as returned by API
|
|
15
|
+
*/
|
|
16
|
+
interface CartItem {
|
|
17
|
+
/** Cart item ID (for update/remove operations via PATCH/DELETE /cart/items/:itemId) */
|
|
18
|
+
_id: string;
|
|
19
|
+
/** Product reference (fully populated Product object from backend) */
|
|
20
|
+
product: Product;
|
|
21
|
+
/**
|
|
22
|
+
* Variant SKU (optional)
|
|
23
|
+
* - null/undefined for simple products
|
|
24
|
+
* - Required for variant products (e.g., "TSHIRT-M-RED")
|
|
25
|
+
* - Must match a valid variant.sku from product.variants[]
|
|
26
|
+
*/
|
|
27
|
+
variantSku?: string | null;
|
|
28
|
+
/** Quantity of this item (minimum: 1) */
|
|
29
|
+
quantity: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Shopping Cart
|
|
33
|
+
* Represents a user's shopping cart
|
|
34
|
+
*/
|
|
35
|
+
interface Cart {
|
|
36
|
+
/** Cart ID */
|
|
37
|
+
_id: string;
|
|
38
|
+
/** User/Customer ID */
|
|
39
|
+
user: string;
|
|
40
|
+
/** Cart items */
|
|
41
|
+
items: CartItem[];
|
|
42
|
+
/** Creation timestamp */
|
|
43
|
+
createdAt: string;
|
|
44
|
+
/** Last update timestamp */
|
|
45
|
+
updatedAt: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Populated Cart Item
|
|
49
|
+
* Cart item with fully populated product for display
|
|
50
|
+
*/
|
|
51
|
+
interface PopulatedCartItem {
|
|
52
|
+
/** Fully populated product */
|
|
53
|
+
product: Product;
|
|
54
|
+
/** Variant SKU */
|
|
55
|
+
variantSku?: string | null;
|
|
56
|
+
/** Quantity */
|
|
57
|
+
quantity: number;
|
|
58
|
+
/** Resolved variant (if variantSku is provided) */
|
|
59
|
+
variant?: ProductVariant;
|
|
60
|
+
/** Final price (basePrice + variant.priceModifier) */
|
|
61
|
+
finalPrice: number;
|
|
62
|
+
/** Line total (finalPrice * quantity) */
|
|
63
|
+
lineTotal: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Cart Summary
|
|
67
|
+
* Complete cart with computed totals
|
|
68
|
+
*/
|
|
69
|
+
interface CartSummary {
|
|
70
|
+
/** Populated cart items with derived fields */
|
|
71
|
+
items: PopulatedCartItem[];
|
|
72
|
+
/** Total item count (sum of all quantities) */
|
|
73
|
+
itemCount: number;
|
|
74
|
+
/** Subtotal (sum of all line totals) */
|
|
75
|
+
subtotal: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Add Item Payload
|
|
79
|
+
* Data required to add an item to cart via POST /api/v1/cart/items
|
|
80
|
+
*/
|
|
81
|
+
interface AddCartItemPayload {
|
|
82
|
+
/** Product ID (required) */
|
|
83
|
+
productId: string;
|
|
84
|
+
/**
|
|
85
|
+
* Variant SKU (required for variant products, omit for simple products)
|
|
86
|
+
* - For simple products: omit this field
|
|
87
|
+
* - For variant products: must match a valid variant.sku from product.variants[]
|
|
88
|
+
*/
|
|
89
|
+
variantSku?: string | null;
|
|
90
|
+
/** Quantity to add (minimum: 1, required) */
|
|
91
|
+
quantity: number;
|
|
92
|
+
}
|
|
93
|
+
/** Alias for AddCartItemPayload (for consistency with hooks) */
|
|
94
|
+
type AddToCartPayload = AddCartItemPayload;
|
|
95
|
+
/**
|
|
96
|
+
* Update Item Payload
|
|
97
|
+
* Data required to update cart item quantity
|
|
98
|
+
*/
|
|
99
|
+
interface UpdateCartItemPayload {
|
|
100
|
+
/** Cart item ID */
|
|
101
|
+
itemId: string;
|
|
102
|
+
/** New quantity (minimum: 1) */
|
|
103
|
+
quantity: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Remove Item Payload
|
|
107
|
+
* Data required to remove an item from cart
|
|
108
|
+
*/
|
|
109
|
+
interface RemoveCartItemPayload {
|
|
110
|
+
/** Cart item ID */
|
|
111
|
+
itemId: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Cart API Response
|
|
115
|
+
*/
|
|
116
|
+
interface CartResponse {
|
|
117
|
+
success: boolean;
|
|
118
|
+
data: Cart;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated Use the new variant system instead
|
|
122
|
+
* Legacy type for old variation system - kept for backwards compatibility
|
|
123
|
+
*/
|
|
124
|
+
interface CartItemVariation {
|
|
125
|
+
name: string;
|
|
126
|
+
option: {
|
|
127
|
+
value: string;
|
|
128
|
+
priceModifier: number;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Customer Types
|
|
134
|
+
*
|
|
135
|
+
* Matches backend `modules/customer/customer.model.js`.
|
|
136
|
+
* Customer is the profile entity (addresses, phone, etc.) linked to auth `User` via `userId`.
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
type CustomerGender = 'male' | 'female' | 'other' | 'prefer-not-to-say';
|
|
140
|
+
type CustomerTier = 'bronze' | 'silver' | 'gold' | 'platinum';
|
|
141
|
+
/**
|
|
142
|
+
* Customer Address
|
|
143
|
+
*
|
|
144
|
+
* Stores user's saved addresses with area info for delivery.
|
|
145
|
+
*/
|
|
146
|
+
interface CustomerAddress {
|
|
147
|
+
_id?: string;
|
|
148
|
+
recipientName?: string;
|
|
149
|
+
/** Contact phone for delivery */
|
|
150
|
+
recipientPhone?: string;
|
|
151
|
+
label?: string;
|
|
152
|
+
addressLine1?: string;
|
|
153
|
+
addressLine2?: string;
|
|
154
|
+
city?: string;
|
|
155
|
+
division?: string;
|
|
156
|
+
postalCode?: string;
|
|
157
|
+
country?: string;
|
|
158
|
+
/** @deprecated Use recipientPhone instead */
|
|
159
|
+
phone?: string;
|
|
160
|
+
isDefault?: boolean;
|
|
161
|
+
/** Area internalId from @classytic/bd-areas */
|
|
162
|
+
areaId?: number;
|
|
163
|
+
/** Area name for display */
|
|
164
|
+
areaName?: string;
|
|
165
|
+
/** Delivery zone (1-6) for pricing tier */
|
|
166
|
+
zoneId?: number;
|
|
167
|
+
/** Provider-specific area IDs for logistics */
|
|
168
|
+
providerAreaIds?: {
|
|
169
|
+
redx?: number;
|
|
170
|
+
pathao?: number;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
interface CustomerStats {
|
|
174
|
+
orders?: {
|
|
175
|
+
total?: number;
|
|
176
|
+
completed?: number;
|
|
177
|
+
cancelled?: number;
|
|
178
|
+
refunded?: number;
|
|
179
|
+
};
|
|
180
|
+
revenue?: {
|
|
181
|
+
total?: number;
|
|
182
|
+
lifetime?: number;
|
|
183
|
+
};
|
|
184
|
+
firstOrderDate?: string;
|
|
185
|
+
lastOrderDate?: string;
|
|
186
|
+
/**
|
|
187
|
+
* Some deployments may include subscription stats; keep optional to avoid breaking.
|
|
188
|
+
*/
|
|
189
|
+
subscriptions?: {
|
|
190
|
+
active?: number;
|
|
191
|
+
cancelled?: number;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
interface CustomerMembership {
|
|
195
|
+
cardId: string;
|
|
196
|
+
isActive: boolean;
|
|
197
|
+
enrolledAt?: string;
|
|
198
|
+
points?: {
|
|
199
|
+
current?: number;
|
|
200
|
+
lifetime?: number;
|
|
201
|
+
redeemed?: number;
|
|
202
|
+
};
|
|
203
|
+
tier?: string;
|
|
204
|
+
tierOverride?: string;
|
|
205
|
+
tierOverrideReason?: string;
|
|
206
|
+
tierOverrideBy?: string;
|
|
207
|
+
}
|
|
208
|
+
interface Customer {
|
|
209
|
+
_id: string;
|
|
210
|
+
id?: string;
|
|
211
|
+
userId?: string;
|
|
212
|
+
name: string;
|
|
213
|
+
phone: string;
|
|
214
|
+
email?: string;
|
|
215
|
+
dateOfBirth?: string;
|
|
216
|
+
gender?: CustomerGender;
|
|
217
|
+
addresses?: CustomerAddress[];
|
|
218
|
+
stats?: CustomerStats;
|
|
219
|
+
tags?: string[];
|
|
220
|
+
notes?: string;
|
|
221
|
+
isActive?: boolean;
|
|
222
|
+
membership?: CustomerMembership | null;
|
|
223
|
+
defaultAddress?: CustomerAddress | null;
|
|
224
|
+
tier?: CustomerTier;
|
|
225
|
+
createdAt?: string;
|
|
226
|
+
updatedAt?: string;
|
|
227
|
+
}
|
|
228
|
+
interface CustomerPayload {
|
|
229
|
+
name?: string;
|
|
230
|
+
phone?: string;
|
|
231
|
+
email?: string;
|
|
232
|
+
dateOfBirth?: string;
|
|
233
|
+
gender?: CustomerGender;
|
|
234
|
+
addresses?: CustomerAddress[];
|
|
235
|
+
tags?: string[];
|
|
236
|
+
notes?: string;
|
|
237
|
+
isActive?: boolean;
|
|
238
|
+
}
|
|
239
|
+
interface CustomerQueryParams {
|
|
240
|
+
page?: number;
|
|
241
|
+
limit?: number;
|
|
242
|
+
after?: string;
|
|
243
|
+
sort?: string | Record<string, 1 | -1 | 'asc' | 'desc'>;
|
|
244
|
+
name?: string;
|
|
245
|
+
phone?: string;
|
|
246
|
+
email?: string;
|
|
247
|
+
userId?: string;
|
|
248
|
+
populate?: 'userId' | Array<'userId'> | string | string[];
|
|
249
|
+
[key: string]: unknown;
|
|
250
|
+
}
|
|
251
|
+
type CustomerListResponse = PaginatedResponse<Customer>;
|
|
252
|
+
type CustomerResponse = ApiResponse<Customer>;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Cart API Client
|
|
256
|
+
*
|
|
257
|
+
* **Authentication:** Required for all endpoints (use Bearer token)
|
|
258
|
+
*
|
|
259
|
+
* **Base URL:** `/api/v1/cart`
|
|
260
|
+
*
|
|
261
|
+
* **Endpoints:**
|
|
262
|
+
* - `GET /api/v1/cart` - Get current user's cart (auto-creates if doesn't exist)
|
|
263
|
+
* - `POST /api/v1/cart/items` - Add item to cart (productId + quantity + optional variantSku)
|
|
264
|
+
* - `PATCH /api/v1/cart/items/:itemId` - Update cart item quantity
|
|
265
|
+
* - `DELETE /api/v1/cart/items/:itemId` - Remove item from cart
|
|
266
|
+
* - `DELETE /api/v1/cart` - Clear all items from cart
|
|
267
|
+
*
|
|
268
|
+
* **Response Format:** All endpoints return `{ success: true, data: Cart }`
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
declare const cartApi: {
|
|
272
|
+
/**
|
|
273
|
+
* Get current user's cart
|
|
274
|
+
* GET /api/v1/cart
|
|
275
|
+
*
|
|
276
|
+
* Auto-creates cart if it doesn't exist for the user.
|
|
277
|
+
* Returns cart with fully populated product details.
|
|
278
|
+
*
|
|
279
|
+
* @param token - User authentication token
|
|
280
|
+
* @returns Cart with items array
|
|
281
|
+
*/
|
|
282
|
+
getCart: (token: string) => Promise<Cart>;
|
|
283
|
+
/**
|
|
284
|
+
* Add item to cart
|
|
285
|
+
* POST /api/v1/cart/items
|
|
286
|
+
*
|
|
287
|
+
* @param token - User authentication token
|
|
288
|
+
* @param data - Product ID, quantity, and optional variant SKU
|
|
289
|
+
* @returns Updated cart
|
|
290
|
+
*/
|
|
291
|
+
addToCart: (token: string, data: AddCartItemPayload) => Promise<Cart>;
|
|
292
|
+
/**
|
|
293
|
+
* Update cart item quantity
|
|
294
|
+
* PATCH /api/v1/cart/items/:itemId
|
|
295
|
+
*
|
|
296
|
+
* @param token - User authentication token
|
|
297
|
+
* @param itemId - Cart item ID (from cart.items[]._id)
|
|
298
|
+
* @param quantity - New quantity (minimum: 1)
|
|
299
|
+
* @returns Updated cart
|
|
300
|
+
*/
|
|
301
|
+
updateCartItem: (token: string, itemId: string, quantity: number) => Promise<Cart>;
|
|
302
|
+
/**
|
|
303
|
+
* Remove item from cart
|
|
304
|
+
* DELETE /api/v1/cart/items/:itemId
|
|
305
|
+
*
|
|
306
|
+
* @param token - User authentication token
|
|
307
|
+
* @param itemId - Cart item ID (from cart.items[]._id)
|
|
308
|
+
* @returns Updated cart
|
|
309
|
+
*/
|
|
310
|
+
removeCartItem: (token: string, itemId: string) => Promise<Cart>;
|
|
311
|
+
/**
|
|
312
|
+
* Clear all items from cart
|
|
313
|
+
* DELETE /api/v1/cart
|
|
314
|
+
*
|
|
315
|
+
* @param token - User authentication token
|
|
316
|
+
* @returns Empty cart
|
|
317
|
+
*/
|
|
318
|
+
clearCart: (token: string) => Promise<Cart>;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
declare class OrderApi extends BaseApi<Order, CreateOrderPayload, Partial<Order>> {
|
|
322
|
+
/**
|
|
323
|
+
* Checkout - create order from cart
|
|
324
|
+
* POST /api/v1/orders
|
|
325
|
+
*/
|
|
326
|
+
checkout: ({ token, organizationId, data }: {
|
|
327
|
+
token: string;
|
|
328
|
+
organizationId?: string | null;
|
|
329
|
+
data: CreateOrderPayload;
|
|
330
|
+
}) => Promise<ApiResponse<Order>>;
|
|
331
|
+
/** Get my orders */
|
|
332
|
+
getMyOrders: ({ token, params }: {
|
|
333
|
+
token: string;
|
|
334
|
+
params?: Record<string, unknown>;
|
|
335
|
+
}) => Promise<Order[]>;
|
|
336
|
+
/** Get my order detail */
|
|
337
|
+
getMyOrder: ({ token, id }: {
|
|
338
|
+
token: string;
|
|
339
|
+
id: string;
|
|
340
|
+
}) => Promise<Order>;
|
|
341
|
+
/** Cancel order */
|
|
342
|
+
cancel: ({ token, id, reason, refund }: {
|
|
343
|
+
token: string;
|
|
344
|
+
id: string;
|
|
345
|
+
reason?: string;
|
|
346
|
+
refund?: boolean;
|
|
347
|
+
}) => Promise<Order>;
|
|
348
|
+
/** Request cancellation (awaits admin review) */
|
|
349
|
+
requestCancellation: ({ token, id, reason }: {
|
|
350
|
+
token: string;
|
|
351
|
+
id: string;
|
|
352
|
+
reason?: string;
|
|
353
|
+
}) => Promise<Order>;
|
|
354
|
+
/** Update order status */
|
|
355
|
+
updateStatus: ({ token, organizationId, id, data }: {
|
|
356
|
+
token: string;
|
|
357
|
+
organizationId?: string | null;
|
|
358
|
+
id: string;
|
|
359
|
+
data: UpdateStatusPayload;
|
|
360
|
+
}) => Promise<Order>;
|
|
361
|
+
/**
|
|
362
|
+
* Fulfill order (ship)
|
|
363
|
+
* - Decrements inventory from branch
|
|
364
|
+
* - recordCogs: true -> also creates COGS expense transaction
|
|
365
|
+
*/
|
|
366
|
+
fulfill: ({ token, organizationId, id, data }: {
|
|
367
|
+
token: string;
|
|
368
|
+
organizationId?: string | null;
|
|
369
|
+
id: string;
|
|
370
|
+
data?: FulfillOrderPayload;
|
|
371
|
+
}) => Promise<Order>;
|
|
372
|
+
/** Refund order */
|
|
373
|
+
refund: ({ token, organizationId, id, data }: {
|
|
374
|
+
token: string;
|
|
375
|
+
organizationId?: string | null;
|
|
376
|
+
id: string;
|
|
377
|
+
data?: RefundOrderPayload;
|
|
378
|
+
}) => Promise<Order>;
|
|
379
|
+
/** Get shipping info */
|
|
380
|
+
getShipping: ({ token, id }: {
|
|
381
|
+
token: string;
|
|
382
|
+
id: string;
|
|
383
|
+
}) => Promise<OrderShipping>;
|
|
384
|
+
/** Request shipping pickup */
|
|
385
|
+
requestShipping: ({ token, organizationId, id, data }: {
|
|
386
|
+
token: string;
|
|
387
|
+
organizationId?: string | null;
|
|
388
|
+
id: string;
|
|
389
|
+
data: RequestShippingPayload;
|
|
390
|
+
}) => Promise<OrderShipping>;
|
|
391
|
+
/** Update shipping status */
|
|
392
|
+
updateShipping: ({ token, organizationId, id, data }: {
|
|
393
|
+
token: string;
|
|
394
|
+
organizationId?: string | null;
|
|
395
|
+
id: string;
|
|
396
|
+
data: UpdateShippingPayload;
|
|
397
|
+
}) => Promise<OrderShipping>;
|
|
398
|
+
}
|
|
399
|
+
declare const orderApi: OrderApi;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Customer API - CRUD + helper endpoint
|
|
403
|
+
*
|
|
404
|
+
* Standard CRUD (inherited from BaseApi):
|
|
405
|
+
* - getAll({ token, params }) - list with filtering/search/pagination
|
|
406
|
+
* - getById({ token, id }) - get by ID
|
|
407
|
+
* - update({ token, id, data }) - update (admin/staff rules apply)
|
|
408
|
+
* - delete({ token, id }) - delete (admin only)
|
|
409
|
+
*
|
|
410
|
+
* Notes:
|
|
411
|
+
* - Customers may be auto-created by backend workflows; some environments may not expose create.
|
|
412
|
+
*
|
|
413
|
+
* Extra endpoint:
|
|
414
|
+
* - getMe({ token }) - current user's customer profile
|
|
415
|
+
*/
|
|
416
|
+
|
|
417
|
+
type FetchOptions = Omit<RequestOptions, 'token' | 'organizationId'>;
|
|
418
|
+
declare class CustomerApi extends BaseApi<Customer, CustomerPayload, CustomerPayload> {
|
|
419
|
+
constructor(config?: {});
|
|
420
|
+
/**
|
|
421
|
+
* Get current user's customer profile
|
|
422
|
+
* GET /customers/me
|
|
423
|
+
*/
|
|
424
|
+
getMe({ token, options, }: {
|
|
425
|
+
token: string;
|
|
426
|
+
options?: FetchOptions;
|
|
427
|
+
}): Promise<ApiResponse<Customer>>;
|
|
428
|
+
/**
|
|
429
|
+
* Membership actions
|
|
430
|
+
* POST /customers/:id/membership
|
|
431
|
+
*/
|
|
432
|
+
membershipAction({ token, id, data, }: {
|
|
433
|
+
token: string;
|
|
434
|
+
id: string;
|
|
435
|
+
data: {
|
|
436
|
+
action: 'enroll' | 'deactivate' | 'reactivate' | 'adjust';
|
|
437
|
+
points?: number;
|
|
438
|
+
reason?: string;
|
|
439
|
+
type?: 'bonus' | 'correction' | 'manual_redemption' | 'redemption' | 'expiry';
|
|
440
|
+
};
|
|
441
|
+
}): Promise<ApiResponse<Customer>>;
|
|
442
|
+
}
|
|
443
|
+
declare const customerApi: CustomerApi;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* POS API Client
|
|
447
|
+
*
|
|
448
|
+
* Follows BaseApi pattern: all methods accept { token, ...params/data }
|
|
449
|
+
*/
|
|
450
|
+
|
|
451
|
+
declare class PosApi extends BaseApi {
|
|
452
|
+
/**
|
|
453
|
+
* Browse products with branch-specific stock
|
|
454
|
+
* GET /api/v1/pos/products
|
|
455
|
+
*/
|
|
456
|
+
getProducts(options: {
|
|
457
|
+
token: string;
|
|
458
|
+
branchId?: string;
|
|
459
|
+
/** Filter by category slug (matches both parent and child categories) */
|
|
460
|
+
category?: string;
|
|
461
|
+
search?: string;
|
|
462
|
+
inStockOnly?: boolean;
|
|
463
|
+
lowStockOnly?: boolean;
|
|
464
|
+
sort?: string;
|
|
465
|
+
after?: string;
|
|
466
|
+
limit?: number;
|
|
467
|
+
}): Promise<PosProductsResponse>;
|
|
468
|
+
/**
|
|
469
|
+
* Fast Lookup by Barcode/SKU
|
|
470
|
+
* GET /api/v1/pos/lookup
|
|
471
|
+
*/
|
|
472
|
+
lookup(options: {
|
|
473
|
+
token: string;
|
|
474
|
+
code: string;
|
|
475
|
+
branchId?: string;
|
|
476
|
+
}): Promise<PosLookupResponse>;
|
|
477
|
+
/**
|
|
478
|
+
* Create POS Order
|
|
479
|
+
* POST /api/v1/pos/orders
|
|
480
|
+
*/
|
|
481
|
+
createOrder(options: {
|
|
482
|
+
token: string;
|
|
483
|
+
data: PosOrderPayload;
|
|
484
|
+
}): Promise<unknown>;
|
|
485
|
+
/**
|
|
486
|
+
* Get Receipt Data
|
|
487
|
+
* GET /api/v1/pos/orders/:orderId/receipt
|
|
488
|
+
*/
|
|
489
|
+
getReceipt(options: {
|
|
490
|
+
token: string;
|
|
491
|
+
orderId: string;
|
|
492
|
+
}): Promise<unknown>;
|
|
493
|
+
/**
|
|
494
|
+
* Adjust Stock (Quick Adjustment from POS)
|
|
495
|
+
* POST /api/v1/pos/stock/adjust
|
|
496
|
+
*/
|
|
497
|
+
adjustStock(options: {
|
|
498
|
+
token: string;
|
|
499
|
+
data: CreateAdjustmentPayload;
|
|
500
|
+
}): Promise<unknown>;
|
|
501
|
+
/**
|
|
502
|
+
* Set stock level directly (POS adjustment alias)
|
|
503
|
+
* POST /api/v1/pos/stock/adjust
|
|
504
|
+
*/
|
|
505
|
+
setStock(options: {
|
|
506
|
+
token: string;
|
|
507
|
+
productId: string;
|
|
508
|
+
data: {
|
|
509
|
+
quantity: number;
|
|
510
|
+
branchId?: string;
|
|
511
|
+
variantSku?: string;
|
|
512
|
+
reason?: string;
|
|
513
|
+
notes?: string;
|
|
514
|
+
};
|
|
515
|
+
}): Promise<unknown>;
|
|
516
|
+
/**
|
|
517
|
+
* Bulk adjustments (POS adjustment alias)
|
|
518
|
+
* POST /api/v1/pos/stock/adjust
|
|
519
|
+
*/
|
|
520
|
+
bulkAdjust(options: {
|
|
521
|
+
token: string;
|
|
522
|
+
data: BulkAdjustmentPayload;
|
|
523
|
+
}): Promise<unknown>;
|
|
524
|
+
}
|
|
525
|
+
declare const posApi: PosApi;
|
|
526
|
+
|
|
527
|
+
export { type AddCartItemPayload as A, type Cart as C, type PopulatedCartItem as P, type RemoveCartItemPayload as R, type UpdateCartItemPayload as U, type CartItem as a, type CartSummary as b, type AddToCartPayload as c, type CartResponse as d, type CartItemVariation as e, type Customer as f, type CustomerAddress as g, type CustomerStats as h, type CustomerMembership as i, type CustomerPayload as j, type CustomerQueryParams as k, type CustomerListResponse as l, type CustomerResponse as m, type CustomerGender as n, type CustomerTier as o, cartApi as p, orderApi as q, customerApi as r, CustomerApi as s, posApi as t };
|