@classytic/commerce-sdk 0.1.0
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.
Potentially problematic release.
This version of @classytic/commerce-sdk might be problematic. Click here for more details.
- package/LICENSE +14 -0
- package/README.md +104 -0
- package/dist/adjustment-DTSLM7AN.js +5 -0
- package/dist/adjustment-DTSLM7AN.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 +479 -0
- package/dist/catalog/index.js +9 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/chunk-4ZQK3FFN.js +40 -0
- package/dist/chunk-4ZQK3FFN.js.map +1 -0
- package/dist/chunk-5L6EXDGH.js +465 -0
- package/dist/chunk-5L6EXDGH.js.map +1 -0
- package/dist/chunk-5ZFW3FEI.js +183 -0
- package/dist/chunk-5ZFW3FEI.js.map +1 -0
- package/dist/chunk-66OQAZSL.js +94 -0
- package/dist/chunk-66OQAZSL.js.map +1 -0
- package/dist/chunk-6RYGA6MF.js +123 -0
- package/dist/chunk-6RYGA6MF.js.map +1 -0
- package/dist/chunk-B6MPVOV7.js +328 -0
- package/dist/chunk-B6MPVOV7.js.map +1 -0
- package/dist/chunk-BDA2WSJA.js +148 -0
- package/dist/chunk-BDA2WSJA.js.map +1 -0
- package/dist/chunk-EIVYT3HM.js +126 -0
- package/dist/chunk-EIVYT3HM.js.map +1 -0
- package/dist/chunk-EPQN7ZKZ.js +27 -0
- package/dist/chunk-EPQN7ZKZ.js.map +1 -0
- package/dist/chunk-FA7QFJ2G.js +177 -0
- package/dist/chunk-FA7QFJ2G.js.map +1 -0
- package/dist/chunk-I5TIKUIQ.js +261 -0
- package/dist/chunk-I5TIKUIQ.js.map +1 -0
- package/dist/chunk-ILQUH444.js +135 -0
- package/dist/chunk-ILQUH444.js.map +1 -0
- package/dist/chunk-IXMWZJLV.js +616 -0
- package/dist/chunk-IXMWZJLV.js.map +1 -0
- package/dist/chunk-KZIGRIQG.js +75 -0
- package/dist/chunk-KZIGRIQG.js.map +1 -0
- package/dist/chunk-OF5M6R2S.js +769 -0
- package/dist/chunk-OF5M6R2S.js.map +1 -0
- package/dist/chunk-PYYLHUV6.js +3 -0
- package/dist/chunk-PYYLHUV6.js.map +1 -0
- package/dist/chunk-QO5AGZFP.js +159 -0
- package/dist/chunk-QO5AGZFP.js.map +1 -0
- package/dist/chunk-QUMTBLNE.js +76 -0
- package/dist/chunk-QUMTBLNE.js.map +1 -0
- package/dist/chunk-R5Z7NYLH.js +126 -0
- package/dist/chunk-R5Z7NYLH.js.map +1 -0
- package/dist/chunk-SZYWG5IB.js +75 -0
- package/dist/chunk-SZYWG5IB.js.map +1 -0
- package/dist/chunk-U3XT35GZ.js +202 -0
- package/dist/chunk-U3XT35GZ.js.map +1 -0
- package/dist/chunk-UGELTUIZ.js +830 -0
- package/dist/chunk-UGELTUIZ.js.map +1 -0
- package/dist/chunk-VR36QVX2.js +122 -0
- package/dist/chunk-VR36QVX2.js.map +1 -0
- package/dist/chunk-WUOQK7BO.js +13 -0
- package/dist/chunk-WUOQK7BO.js.map +1 -0
- package/dist/chunk-X6PV5MHG.js +582 -0
- package/dist/chunk-X6PV5MHG.js.map +1 -0
- package/dist/chunk-ZWLMFLLH.js +534 -0
- package/dist/chunk-ZWLMFLLH.js.map +1 -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 +107 -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-CHFcw7cd.d.ts +632 -0
- package/dist/coupon-zGkvO-Xx.d.ts +129 -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 +31 -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-DCiIZh8P.d.ts +742 -0
- package/dist/logistics/index.d.ts +226 -0
- package/dist/logistics/index.js +7 -0
- package/dist/logistics/index.js.map +1 -0
- package/dist/logistics-V8a9lUN3.d.ts +428 -0
- package/dist/media-CNLJK93J.d.ts +721 -0
- package/dist/movement-7MV3ADY5.js +5 -0
- package/dist/movement-7MV3ADY5.js.map +1 -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-D1jkkFl0.d.ts +885 -0
- package/dist/product-p09zXkXB.d.ts +260 -0
- package/dist/purchase-24BGT2HA.js +5 -0
- package/dist/purchase-24BGT2HA.js.map +1 -0
- package/dist/request-652PS6VR.js +5 -0
- package/dist/request-652PS6VR.js.map +1 -0
- package/dist/sales/index.d.ts +585 -0
- package/dist/sales/index.js +9 -0
- package/dist/sales/index.js.map +1 -0
- package/dist/server.d.ts +120 -0
- package/dist/server.js +27 -0
- package/dist/server.js.map +1 -0
- package/dist/size-guide-DgjzjM5P.d.ts +554 -0
- package/dist/stock-DEApGC-w.d.ts +632 -0
- package/dist/stock-OOUW57VQ.js +5 -0
- package/dist/stock-OOUW57VQ.js.map +1 -0
- package/dist/supplier-OC6JAWV6.js +5 -0
- package/dist/supplier-OC6JAWV6.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-BTmoHpWh.d.ts +428 -0
- package/dist/transaction-u5oaNuav.d.ts +84 -0
- package/dist/transfer-7SYSH3RG.js +5 -0
- package/dist/transfer-7SYSH3RG.js.map +1 -0
- package/dist/user-data-DdLjAGwO.d.ts +132 -0
- package/package.json +146 -0
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import { P as PaginatedResponse, A as ApiResponse, B as BaseApi, R as RequestOptions } from './api-factory-B_h4RKBm.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Platform Config Types
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `modules/platform/platform.model.js` (PlatformConfig singleton).
|
|
7
|
+
* Includes payment methods, checkout, logistics, VAT, and policies.
|
|
8
|
+
*/
|
|
9
|
+
type PaymentMethodType = "cash" | "mfs" | "card" | "online" | "bank" | "bank_transfer";
|
|
10
|
+
interface PaymentMethodConfig {
|
|
11
|
+
_id?: string;
|
|
12
|
+
key: string;
|
|
13
|
+
label: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
type?: PaymentMethodType;
|
|
16
|
+
provider?: string;
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
isActive?: boolean;
|
|
19
|
+
gateway?: string;
|
|
20
|
+
walletNumber?: string;
|
|
21
|
+
note?: string;
|
|
22
|
+
settings?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
interface PlatformVatConfig {
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
rate: number;
|
|
27
|
+
sellerBin?: string;
|
|
28
|
+
pricesIncludeVat: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface DeliveryZone {
|
|
31
|
+
_id?: string;
|
|
32
|
+
name: string;
|
|
33
|
+
region: string;
|
|
34
|
+
price: number;
|
|
35
|
+
estimatedDays?: number;
|
|
36
|
+
isActive?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface CheckoutPickupBranch {
|
|
39
|
+
branchId?: string;
|
|
40
|
+
branchCode?: string;
|
|
41
|
+
branchName?: string;
|
|
42
|
+
}
|
|
43
|
+
type DeliveryFeeSource = "static" | "provider";
|
|
44
|
+
interface CheckoutSettings {
|
|
45
|
+
allowStorePickup: boolean;
|
|
46
|
+
pickupBranches: CheckoutPickupBranch[];
|
|
47
|
+
deliveryFeeSource: DeliveryFeeSource;
|
|
48
|
+
freeDeliveryThreshold: number;
|
|
49
|
+
deliveryZones: DeliveryZone[];
|
|
50
|
+
}
|
|
51
|
+
interface LogisticsSettings {
|
|
52
|
+
defaultPickupStoreId?: number;
|
|
53
|
+
defaultPickupStoreName?: string;
|
|
54
|
+
defaultPickupAreaId?: number;
|
|
55
|
+
defaultPickupAreaName?: string;
|
|
56
|
+
webhookSecret?: string;
|
|
57
|
+
autoCreateShipment: boolean;
|
|
58
|
+
autoCreateOnStatus: string;
|
|
59
|
+
}
|
|
60
|
+
interface PlatformPolicies {
|
|
61
|
+
termsAndConditions?: string;
|
|
62
|
+
privacyPolicy?: string;
|
|
63
|
+
refundPolicy?: string;
|
|
64
|
+
shippingPolicy?: string;
|
|
65
|
+
}
|
|
66
|
+
type MembershipRoundingMode = "floor" | "round" | "ceil";
|
|
67
|
+
interface MembershipTierConfig {
|
|
68
|
+
name: string;
|
|
69
|
+
minPoints: number;
|
|
70
|
+
pointsMultiplier: number;
|
|
71
|
+
discountPercent: number;
|
|
72
|
+
color?: string;
|
|
73
|
+
}
|
|
74
|
+
interface MembershipRedemptionConfig {
|
|
75
|
+
enabled: boolean;
|
|
76
|
+
minRedeemPoints: number;
|
|
77
|
+
minOrderAmount: number;
|
|
78
|
+
maxRedeemPercent: number;
|
|
79
|
+
pointsPerBdt: number;
|
|
80
|
+
}
|
|
81
|
+
interface MembershipConfig {
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
pointsPerAmount: number;
|
|
84
|
+
amountPerPoint: number;
|
|
85
|
+
roundingMode: MembershipRoundingMode;
|
|
86
|
+
tiers: MembershipTierConfig[];
|
|
87
|
+
cardPrefix: string;
|
|
88
|
+
cardDigits: number;
|
|
89
|
+
redemption?: MembershipRedemptionConfig;
|
|
90
|
+
}
|
|
91
|
+
interface PlatformConfig {
|
|
92
|
+
_id: string;
|
|
93
|
+
platformName: string;
|
|
94
|
+
/** Flexible payment methods array */
|
|
95
|
+
paymentMethods: PaymentMethodConfig[];
|
|
96
|
+
checkout: CheckoutSettings;
|
|
97
|
+
logistics: LogisticsSettings;
|
|
98
|
+
vat: PlatformVatConfig;
|
|
99
|
+
membership?: MembershipConfig;
|
|
100
|
+
policies?: PlatformPolicies;
|
|
101
|
+
isSingleton: boolean;
|
|
102
|
+
createdAt: string;
|
|
103
|
+
updatedAt: string;
|
|
104
|
+
}
|
|
105
|
+
interface UpdatePlatformConfigPayload {
|
|
106
|
+
platformName?: string;
|
|
107
|
+
paymentMethods?: PaymentMethodConfig[];
|
|
108
|
+
checkout?: Partial<CheckoutSettings>;
|
|
109
|
+
logistics?: Partial<LogisticsSettings>;
|
|
110
|
+
vat?: Partial<PlatformVatConfig>;
|
|
111
|
+
membership?: Partial<MembershipConfig>;
|
|
112
|
+
policies?: Partial<PlatformPolicies>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Branch Types
|
|
117
|
+
*
|
|
118
|
+
* Type definitions for store/warehouse locations.
|
|
119
|
+
* Separated from inventory types for better organization and single responsibility.
|
|
120
|
+
*/
|
|
121
|
+
type BranchType = 'store' | 'warehouse' | 'outlet' | 'franchise';
|
|
122
|
+
/**
|
|
123
|
+
* Branch Hierarchy Role
|
|
124
|
+
* Determines the branch's position in the inventory flow hierarchy.
|
|
125
|
+
*
|
|
126
|
+
* - head_office: Central warehouse/HQ that receives purchases and distributes to sub-branches
|
|
127
|
+
* - sub_branch: Store/outlet that receives stock from head office
|
|
128
|
+
*/
|
|
129
|
+
type BranchRole = 'head_office' | 'sub_branch';
|
|
130
|
+
interface BranchAddress {
|
|
131
|
+
line1?: string;
|
|
132
|
+
line2?: string;
|
|
133
|
+
city?: string;
|
|
134
|
+
state?: string;
|
|
135
|
+
postalCode?: string;
|
|
136
|
+
country?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Branch (Store/Warehouse Location)
|
|
140
|
+
*
|
|
141
|
+
* Represents a physical location for inventory tracking and POS operations.
|
|
142
|
+
* Every deployment must have at least one branch (default branch).
|
|
143
|
+
*
|
|
144
|
+
* Branch Hierarchy:
|
|
145
|
+
* - One branch must be designated as head_office (typically the default branch)
|
|
146
|
+
* - All other branches are sub_branch by default
|
|
147
|
+
* - Stock flows: Suppliers -> Head Office -> Sub-branches
|
|
148
|
+
*/
|
|
149
|
+
interface Branch {
|
|
150
|
+
_id: string;
|
|
151
|
+
/** URL-friendly slug (auto-generated from name) */
|
|
152
|
+
slug: string;
|
|
153
|
+
/** Unique branch code (e.g., "DHK-1", "CTG-MAIN") - uppercase, stable */
|
|
154
|
+
code: string;
|
|
155
|
+
/** Display name */
|
|
156
|
+
name: string;
|
|
157
|
+
/** Branch type (store, warehouse, outlet, franchise) */
|
|
158
|
+
type: BranchType;
|
|
159
|
+
/**
|
|
160
|
+
* Branch role in inventory hierarchy
|
|
161
|
+
* - head_office: Receives purchases, distributes to sub-branches
|
|
162
|
+
* - sub_branch: Receives stock from head office only
|
|
163
|
+
*/
|
|
164
|
+
role: BranchRole;
|
|
165
|
+
/** Physical address */
|
|
166
|
+
address?: BranchAddress;
|
|
167
|
+
/** Contact phone */
|
|
168
|
+
phone?: string;
|
|
169
|
+
/** Contact email */
|
|
170
|
+
email?: string;
|
|
171
|
+
/** Operating hours (simple format, e.g., "10:00 AM - 10:00 PM") */
|
|
172
|
+
operatingHours?: string;
|
|
173
|
+
/** Whether this is the default branch (only one can be default) */
|
|
174
|
+
isDefault: boolean;
|
|
175
|
+
/** Whether this branch is active */
|
|
176
|
+
isActive: boolean;
|
|
177
|
+
/** Manager user ID reference */
|
|
178
|
+
manager?: string;
|
|
179
|
+
/** Admin notes (admin-only field) */
|
|
180
|
+
notes?: string;
|
|
181
|
+
createdAt: string;
|
|
182
|
+
updatedAt: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create Branch Payload
|
|
186
|
+
*/
|
|
187
|
+
interface CreateBranchPayload {
|
|
188
|
+
code: string;
|
|
189
|
+
name: string;
|
|
190
|
+
type?: BranchType;
|
|
191
|
+
/** Branch hierarchy role (defaults to 'sub_branch') */
|
|
192
|
+
role?: BranchRole;
|
|
193
|
+
address?: BranchAddress;
|
|
194
|
+
phone?: string;
|
|
195
|
+
email?: string;
|
|
196
|
+
operatingHours?: string;
|
|
197
|
+
isDefault?: boolean;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Update Branch Payload
|
|
201
|
+
*/
|
|
202
|
+
interface UpdateBranchPayload extends Partial<CreateBranchPayload> {
|
|
203
|
+
isActive?: boolean;
|
|
204
|
+
notes?: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Branch Summary (for dropdowns, lists)
|
|
208
|
+
*/
|
|
209
|
+
interface BranchSummary {
|
|
210
|
+
_id: string;
|
|
211
|
+
code: string;
|
|
212
|
+
name: string;
|
|
213
|
+
role: BranchRole;
|
|
214
|
+
isDefault: boolean;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Check if branch is head office
|
|
218
|
+
*/
|
|
219
|
+
declare function isHeadOffice(branch: Branch | BranchSummary): boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Check if branch is sub-branch
|
|
222
|
+
*/
|
|
223
|
+
declare function isSubBranch(branch: Branch | BranchSummary): boolean;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* User Types for Admin Management
|
|
227
|
+
*
|
|
228
|
+
* Simple types for CRUD operations on users.
|
|
229
|
+
* Frontend uses standard BaseApi methods with these types.
|
|
230
|
+
*/
|
|
231
|
+
/** System-level roles (global permissions) */
|
|
232
|
+
type UserRoleType = 'user' | 'admin' | 'superadmin' | 'finance-admin' | 'finance-manager' | 'store-manager' | 'store-staff' | 'warehouse-admin' | 'warehouse-staff';
|
|
233
|
+
/** Branch-specific roles */
|
|
234
|
+
type BranchRoleType = 'branch_manager' | 'inventory_staff' | 'cashier' | 'stock_receiver' | 'stock_requester' | 'viewer';
|
|
235
|
+
/** User's branch assignment */
|
|
236
|
+
interface UserBranchAssignment {
|
|
237
|
+
branchId: string;
|
|
238
|
+
branchCode?: string;
|
|
239
|
+
branchName?: string;
|
|
240
|
+
branchRole?: 'head_office' | 'sub_branch';
|
|
241
|
+
roles: BranchRoleType[];
|
|
242
|
+
isPrimary: boolean;
|
|
243
|
+
}
|
|
244
|
+
/** User document */
|
|
245
|
+
interface User {
|
|
246
|
+
_id: string;
|
|
247
|
+
name: string;
|
|
248
|
+
email: string;
|
|
249
|
+
roles: UserRoleType[];
|
|
250
|
+
branches: UserBranchAssignment[];
|
|
251
|
+
isActive: boolean;
|
|
252
|
+
lastLoginAt?: string;
|
|
253
|
+
createdAt: string;
|
|
254
|
+
updatedAt: string;
|
|
255
|
+
}
|
|
256
|
+
/** Create user payload */
|
|
257
|
+
interface CreateUserPayload {
|
|
258
|
+
name: string;
|
|
259
|
+
email: string;
|
|
260
|
+
password: string;
|
|
261
|
+
roles?: UserRoleType[];
|
|
262
|
+
branches?: Array<{
|
|
263
|
+
branchId: string;
|
|
264
|
+
roles?: BranchRoleType[];
|
|
265
|
+
isPrimary?: boolean;
|
|
266
|
+
}>;
|
|
267
|
+
}
|
|
268
|
+
/** Update user payload - just patch what you need */
|
|
269
|
+
interface UpdateUserPayload {
|
|
270
|
+
name?: string;
|
|
271
|
+
email?: string;
|
|
272
|
+
roles?: UserRoleType[];
|
|
273
|
+
branches?: Array<{
|
|
274
|
+
branchId: string;
|
|
275
|
+
roles?: BranchRoleType[];
|
|
276
|
+
isPrimary?: boolean;
|
|
277
|
+
}>;
|
|
278
|
+
isActive?: boolean;
|
|
279
|
+
}
|
|
280
|
+
/** Query params for listing users */
|
|
281
|
+
interface UserListParams {
|
|
282
|
+
page?: number;
|
|
283
|
+
limit?: number;
|
|
284
|
+
sort?: string;
|
|
285
|
+
name?: string;
|
|
286
|
+
'name[contains]'?: string;
|
|
287
|
+
email?: string;
|
|
288
|
+
roles?: UserRoleType;
|
|
289
|
+
'roles[in]'?: string;
|
|
290
|
+
'branches.branchId'?: string;
|
|
291
|
+
'branches.roles'?: BranchRoleType;
|
|
292
|
+
isActive?: boolean;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Coupon Types
|
|
297
|
+
*
|
|
298
|
+
* Type definitions for discount coupons and promotional codes.
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
type DiscountType = 'percentage' | 'fixed';
|
|
302
|
+
/**
|
|
303
|
+
* Discount coupon/promo code
|
|
304
|
+
*/
|
|
305
|
+
interface Coupon {
|
|
306
|
+
_id: string;
|
|
307
|
+
code: string;
|
|
308
|
+
discountType: DiscountType;
|
|
309
|
+
discountAmount: number;
|
|
310
|
+
minOrderAmount: number;
|
|
311
|
+
maxDiscountAmount?: number;
|
|
312
|
+
expiresAt: string;
|
|
313
|
+
usageLimit: number;
|
|
314
|
+
usedCount: number;
|
|
315
|
+
isActive: boolean;
|
|
316
|
+
createdAt: string;
|
|
317
|
+
updatedAt: string;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Coupon validation result
|
|
321
|
+
*/
|
|
322
|
+
interface CouponValidationResult {
|
|
323
|
+
valid: boolean;
|
|
324
|
+
coupon?: Coupon;
|
|
325
|
+
discountAmount?: number;
|
|
326
|
+
error?: string;
|
|
327
|
+
details?: {
|
|
328
|
+
codeExists?: boolean;
|
|
329
|
+
isActive?: boolean;
|
|
330
|
+
notExpired?: boolean;
|
|
331
|
+
meetsMinPurchase?: boolean;
|
|
332
|
+
withinUsageLimit?: boolean;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Apply coupon request
|
|
337
|
+
*/
|
|
338
|
+
interface ValidateCouponPayload {
|
|
339
|
+
orderAmount: number;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Create coupon request (admin)
|
|
343
|
+
*/
|
|
344
|
+
interface CreateCouponPayload {
|
|
345
|
+
code: string;
|
|
346
|
+
discountType: DiscountType;
|
|
347
|
+
discountAmount: number;
|
|
348
|
+
minOrderAmount?: number;
|
|
349
|
+
maxDiscountAmount?: number;
|
|
350
|
+
expiresAt: string;
|
|
351
|
+
usageLimit?: number;
|
|
352
|
+
isActive?: boolean;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Update coupon request (admin)
|
|
356
|
+
*/
|
|
357
|
+
type UpdateCouponPayload = Partial<CreateCouponPayload>;
|
|
358
|
+
type CouponListResponse = PaginatedResponse<Coupon>;
|
|
359
|
+
type CouponResponse = ApiResponse<Coupon>;
|
|
360
|
+
type CouponValidationResponse = ApiResponse<CouponValidationResult>;
|
|
361
|
+
/**
|
|
362
|
+
* Coupon usage record
|
|
363
|
+
*/
|
|
364
|
+
interface CouponUsage {
|
|
365
|
+
/** Usage record ID */
|
|
366
|
+
_id: string;
|
|
367
|
+
/** Coupon ID */
|
|
368
|
+
couponId: string;
|
|
369
|
+
/** Coupon code */
|
|
370
|
+
couponCode: string;
|
|
371
|
+
/** User who used it */
|
|
372
|
+
userId: string;
|
|
373
|
+
/** Order ID */
|
|
374
|
+
orderId: string;
|
|
375
|
+
/** Discount amount applied */
|
|
376
|
+
discountAmount: number;
|
|
377
|
+
/** Used timestamp */
|
|
378
|
+
usedAt: string;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Platform Configuration API
|
|
383
|
+
*
|
|
384
|
+
* Singleton platform configuration - stores all platform-wide settings.
|
|
385
|
+
*
|
|
386
|
+
* Endpoints:
|
|
387
|
+
* - GET /api/v1/platform/config - Get platform config (supports field selection)
|
|
388
|
+
* - PATCH /api/v1/platform/config - Update platform config (admin only)
|
|
389
|
+
*
|
|
390
|
+
* Field Selection:
|
|
391
|
+
* - ?select=paymentMethods
|
|
392
|
+
* - ?select=checkout,vat
|
|
393
|
+
* - ?select=policies
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
declare class PlatformConfigApi {
|
|
397
|
+
readonly baseUrl = "/api/v1/platform";
|
|
398
|
+
/**
|
|
399
|
+
* Get platform configuration
|
|
400
|
+
*
|
|
401
|
+
* @param options.token - Optional access token (public without, authenticated with)
|
|
402
|
+
* @param options.select - Optional field selection (e.g., "paymentMethods", "checkout,vat")
|
|
403
|
+
* @returns Platform configuration (full or selected fields)
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* // Full config (public)
|
|
407
|
+
* const config = await platformConfigApi.getConfig({});
|
|
408
|
+
*
|
|
409
|
+
* // Selected fields (public)
|
|
410
|
+
* const config = await platformConfigApi.getConfig({ select: "paymentMethods" });
|
|
411
|
+
*
|
|
412
|
+
* // Authenticated (admin sees more fields)
|
|
413
|
+
* const config = await platformConfigApi.getConfig({ token, select: "checkout,vat" });
|
|
414
|
+
*/
|
|
415
|
+
getConfig({ token, select, }?: {
|
|
416
|
+
token?: string | null;
|
|
417
|
+
select?: string | null;
|
|
418
|
+
}): Promise<ApiResponse<PlatformConfig>>;
|
|
419
|
+
/**
|
|
420
|
+
* Update platform configuration
|
|
421
|
+
*
|
|
422
|
+
* @param options.token - Admin access token (required)
|
|
423
|
+
* @param options.data - Configuration data to update (partial update)
|
|
424
|
+
* @returns Updated platform configuration
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* // Update payment methods
|
|
428
|
+
* await platformConfigApi.updateConfig({
|
|
429
|
+
* token,
|
|
430
|
+
* data: {
|
|
431
|
+
* paymentMethods: [
|
|
432
|
+
* { type: 'cash', name: 'Cash on Delivery', isActive: true },
|
|
433
|
+
* { type: 'mfs', provider: 'bkash', name: 'bKash', walletNumber: '01712345678' },
|
|
434
|
+
* ]
|
|
435
|
+
* }
|
|
436
|
+
* });
|
|
437
|
+
*
|
|
438
|
+
* // Update checkout settings
|
|
439
|
+
* await platformConfigApi.updateConfig({
|
|
440
|
+
* token,
|
|
441
|
+
* data: {
|
|
442
|
+
* checkout: {
|
|
443
|
+
* freeDeliveryThreshold: 2000,
|
|
444
|
+
* deliveryZones: [
|
|
445
|
+
* { name: 'Dhaka', region: 'dhaka', price: 60, estimatedDays: 2, isActive: true }
|
|
446
|
+
* ]
|
|
447
|
+
* }
|
|
448
|
+
* }
|
|
449
|
+
* });
|
|
450
|
+
*/
|
|
451
|
+
updateConfig({ token, data, }: {
|
|
452
|
+
token: string;
|
|
453
|
+
data: UpdatePlatformConfigPayload;
|
|
454
|
+
}): Promise<ApiResponse<PlatformConfig>>;
|
|
455
|
+
/**
|
|
456
|
+
* Get payment methods only
|
|
457
|
+
* Convenience method for checkout/POS
|
|
458
|
+
*
|
|
459
|
+
* @param options.token - Optional access token
|
|
460
|
+
* @returns Platform config with only paymentMethods field
|
|
461
|
+
*/
|
|
462
|
+
getPaymentMethods({ token, }?: {
|
|
463
|
+
token?: string | null;
|
|
464
|
+
}): Promise<ApiResponse<Pick<PlatformConfig, "paymentMethods">>>;
|
|
465
|
+
/**
|
|
466
|
+
* Get checkout settings only
|
|
467
|
+
* Convenience method for checkout flow
|
|
468
|
+
*
|
|
469
|
+
* @param options.token - Optional access token
|
|
470
|
+
* @returns Platform config with only checkout field
|
|
471
|
+
*/
|
|
472
|
+
getCheckoutSettings({ token, }?: {
|
|
473
|
+
token?: string | null;
|
|
474
|
+
}): Promise<ApiResponse<Pick<PlatformConfig, "checkout">>>;
|
|
475
|
+
/**
|
|
476
|
+
* Get delivery zones
|
|
477
|
+
* Convenience method for delivery selection
|
|
478
|
+
*
|
|
479
|
+
* @param options.token - Optional access token
|
|
480
|
+
* @returns Platform config with checkout.deliveryZones
|
|
481
|
+
*/
|
|
482
|
+
getDeliveryZones({ token, }?: {
|
|
483
|
+
token?: string | null;
|
|
484
|
+
}): Promise<ApiResponse<Pick<PlatformConfig, "checkout">>>;
|
|
485
|
+
/**
|
|
486
|
+
* Get VAT configuration
|
|
487
|
+
* Convenience method for invoice/tax calculations
|
|
488
|
+
*
|
|
489
|
+
* @param options.token - Optional access token
|
|
490
|
+
* @returns Platform config with only vat field
|
|
491
|
+
*/
|
|
492
|
+
getVatConfig({ token, }?: {
|
|
493
|
+
token?: string | null;
|
|
494
|
+
}): Promise<ApiResponse<Pick<PlatformConfig, "vat">>>;
|
|
495
|
+
/**
|
|
496
|
+
* Get membership configuration
|
|
497
|
+
* Convenience method for loyalty programs
|
|
498
|
+
*
|
|
499
|
+
* @param options.token - Optional access token
|
|
500
|
+
* @returns Platform config with only membership field
|
|
501
|
+
*/
|
|
502
|
+
getMembershipConfig({ token, }?: {
|
|
503
|
+
token?: string | null;
|
|
504
|
+
}): Promise<ApiResponse<Pick<PlatformConfig, "membership">>>;
|
|
505
|
+
}
|
|
506
|
+
declare const platformConfigApi: PlatformConfigApi;
|
|
507
|
+
|
|
508
|
+
declare const platformApi: PlatformConfigApi;
|
|
509
|
+
declare const businessApi: PlatformConfigApi;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Branch API - CRUD + Custom Endpoints
|
|
513
|
+
*
|
|
514
|
+
* Standard CRUD (inherited from BaseApi):
|
|
515
|
+
* - getAll({ token, params }) - list with filtering/pagination
|
|
516
|
+
* - getById({ token, id }) - get by ID
|
|
517
|
+
* - create({ token, data }) - create (admin only)
|
|
518
|
+
* - update({ token, id, data }) - update (admin only)
|
|
519
|
+
* - delete({ token, id }) - delete (admin only)
|
|
520
|
+
*
|
|
521
|
+
* Custom endpoints:
|
|
522
|
+
* - getByCode({ token, code }) - GET /branches/code/:code
|
|
523
|
+
* - getDefault({ token }) - GET /branches/default (auto-creates if none)
|
|
524
|
+
* - setDefault({ token, id }) - POST /branches/:id/set-default
|
|
525
|
+
*
|
|
526
|
+
* For active branches: getAll({ token, params: { isActive: true } })
|
|
527
|
+
*/
|
|
528
|
+
|
|
529
|
+
type FetchOptions$1 = Omit<RequestOptions, 'token' | 'organizationId'>;
|
|
530
|
+
declare class BranchApi extends BaseApi<Branch, CreateBranchPayload, UpdateBranchPayload> {
|
|
531
|
+
constructor(config?: {});
|
|
532
|
+
/**
|
|
533
|
+
* Get branch by code
|
|
534
|
+
* GET /branches/code/:code
|
|
535
|
+
*
|
|
536
|
+
* @example
|
|
537
|
+
* branchApi.getByCode({ token, code: 'DHK-1' })
|
|
538
|
+
*/
|
|
539
|
+
getByCode({ token, code, options, }: {
|
|
540
|
+
token: string;
|
|
541
|
+
code: string;
|
|
542
|
+
options?: FetchOptions$1;
|
|
543
|
+
}): Promise<ApiResponse<Branch>>;
|
|
544
|
+
/**
|
|
545
|
+
* Get default branch (auto-creates if none exists)
|
|
546
|
+
* GET /branches/default
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
* branchApi.getDefault({ token })
|
|
550
|
+
*/
|
|
551
|
+
getDefault({ token, options, }: {
|
|
552
|
+
token: string;
|
|
553
|
+
options?: FetchOptions$1;
|
|
554
|
+
}): Promise<ApiResponse<Branch>>;
|
|
555
|
+
/**
|
|
556
|
+
* Set a branch as the default
|
|
557
|
+
* POST /branches/:id/set-default
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* branchApi.setDefault({ token, id: '507f1f77bcf86cd799439011' })
|
|
561
|
+
*/
|
|
562
|
+
setDefault({ token, id, options, }: {
|
|
563
|
+
token: string;
|
|
564
|
+
id: string;
|
|
565
|
+
options?: FetchOptions$1;
|
|
566
|
+
}): Promise<ApiResponse<Branch>>;
|
|
567
|
+
}
|
|
568
|
+
declare const branchApi: BranchApi;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* User API - Admin User Management (CRUD)
|
|
572
|
+
*
|
|
573
|
+
* Standard CRUD (inherited from BaseApi):
|
|
574
|
+
* - getAll({ token, params }) - list users with filtering/pagination
|
|
575
|
+
* - getById({ token, id }) - get user by ID
|
|
576
|
+
* - create({ token, data }) - create user (admin only)
|
|
577
|
+
* - update({ token, id, data }) - update user (admin only)
|
|
578
|
+
* - delete({ token, id }) - delete user (admin only)
|
|
579
|
+
*
|
|
580
|
+
* Query examples:
|
|
581
|
+
* - List all users: getAll({ token, params: { page: 1, limit: 10 } })
|
|
582
|
+
* - Filter by role: getAll({ token, params: { roles: 'admin' } })
|
|
583
|
+
* - Search by name: getAll({ token, params: { 'name[contains]': 'john' } })
|
|
584
|
+
* - Filter by branch: getAll({ token, params: { 'branches.branchId': 'branch_123' } })
|
|
585
|
+
* - Active users only: getAll({ token, params: { isActive: true } })
|
|
586
|
+
*/
|
|
587
|
+
|
|
588
|
+
declare class UserApi extends BaseApi<User, CreateUserPayload, UpdateUserPayload> {
|
|
589
|
+
constructor(config?: {});
|
|
590
|
+
}
|
|
591
|
+
declare const userApi: UserApi;
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Coupon API - CRUD + validate
|
|
595
|
+
*
|
|
596
|
+
* Standard CRUD (inherited from BaseApi):
|
|
597
|
+
* - getAll({ token, params }) - list coupons with filtering/pagination
|
|
598
|
+
* - getById({ token, id }) - get coupon by ID
|
|
599
|
+
* - create({ token, data }) - create coupon (admin only)
|
|
600
|
+
* - update({ token, id, data }) - update coupon (admin only)
|
|
601
|
+
* - delete({ token, id }) - delete coupon (admin only)
|
|
602
|
+
*
|
|
603
|
+
* Custom endpoints:
|
|
604
|
+
* - validateCoupon({ code, data }) - POST /coupons/validate/:code
|
|
605
|
+
*/
|
|
606
|
+
|
|
607
|
+
type FetchOptions = Omit<RequestOptions, "token" | "organizationId">;
|
|
608
|
+
declare class CouponApi extends BaseApi<Coupon, CreateCouponPayload, UpdateCouponPayload> {
|
|
609
|
+
constructor(config?: {});
|
|
610
|
+
/**
|
|
611
|
+
* Validate coupon by code with order amount
|
|
612
|
+
* POST /coupons/validate/:code
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* const result = await couponApi.validateCoupon({
|
|
616
|
+
* code: 'SUMMER20',
|
|
617
|
+
* data: { orderAmount: 1500 }
|
|
618
|
+
* });
|
|
619
|
+
*
|
|
620
|
+
* if (result.data?.valid) {
|
|
621
|
+
* console.log('Discount:', result.data.discountAmount);
|
|
622
|
+
* }
|
|
623
|
+
*/
|
|
624
|
+
validateCoupon({ code, data, options, }: {
|
|
625
|
+
code: string;
|
|
626
|
+
data: ValidateCouponPayload;
|
|
627
|
+
options?: FetchOptions;
|
|
628
|
+
}): Promise<ApiResponse<CouponValidationResult>>;
|
|
629
|
+
}
|
|
630
|
+
declare const couponApi: CouponApi;
|
|
631
|
+
|
|
632
|
+
export { type CheckoutPickupBranch as A, BranchApi as B, CouponApi as C, type DeliveryZone as D, type PlatformPolicies as E, type MembershipTierConfig as F, type MembershipRedemptionConfig as G, type MembershipConfig as H, type PlatformConfig as I, type UpdatePlatformConfigPayload as J, platformApi as K, type LogisticsSettings as L, type MembershipRoundingMode as M, businessApi as N, type DeliveryFeeSource as O, PlatformConfigApi as P, type CheckoutSettings as Q, type PaymentMethodConfig as R, type UserRoleType as S, type User as T, UserApi as U, type ValidateCouponPayload as V, isSubBranch as a, branchApi as b, couponApi as c, type BranchType as d, type BranchRole as e, type BranchAddress as f, type Branch as g, type CreateBranchPayload as h, isHeadOffice as i, type UpdateBranchPayload as j, type BranchSummary as k, type BranchRoleType as l, type UserBranchAssignment as m, type CreateUserPayload as n, type UpdateUserPayload as o, platformConfigApi as p, type UserListParams as q, type Coupon as r, type CouponValidationResult as s, type CreateCouponPayload as t, userApi as u, type UpdateCouponPayload as v, type CouponListResponse as w, type CouponResponse as x, type CouponValidationResponse as y, type CouponUsage as z };
|