@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,645 @@
|
|
|
1
|
+
export { g as Branch, f as BranchAddress, B as BranchApi, e as BranchRole, l as BranchRoleType, k as BranchSummary, d as BranchType, A as CheckoutPickupBranch, Q as CheckoutSettings, r as Coupon, C as CouponApi, w as CouponListResponse, x as CouponResponse, z as CouponUsage, y as CouponValidationResponse, s as CouponValidationResult, h as CreateBranchPayload, t as CreateCouponPayload, n as CreateUserPayload, O as DeliveryFeeSource, D as DeliveryZone, L as LogisticsSettings, H as MembershipConfig, G as MembershipRedemptionConfig, M as MembershipRoundingMode, F as MembershipTierConfig, R as PaymentMethodConfig, I as PlatformConfig, P as PlatformConfigApi, E as PlatformPolicies, j as UpdateBranchPayload, v as UpdateCouponPayload, J as UpdatePlatformConfigPayload, o as UpdateUserPayload, T as User, U as UserApi, m as UserBranchAssignment, q as UserListParams, S as UserRoleType, V as ValidateCouponPayload, b as branchApi, N as businessApi, c as couponApi, i as isHeadOffice, a as isSubBranch, K as platformApi, p as platformConfigApi, u as userApi } from '../coupon-CHFcw7cd.js';
|
|
2
|
+
import { A as ApiResponse, R as RequestOptions } from '../api-factory-B_h4RKBm.js';
|
|
3
|
+
import { c as TransactionStatus, e as TransactionCategory } from '../transaction-BTmoHpWh.js';
|
|
4
|
+
export { B as BRANCH_KEYS, C as COUPON_KEYS, P as PLATFORM_KEYS, U as USER_KEYS, w as UseDeliveryZonesReturn, x as UseMembershipConfigReturn, v as UsePaymentMethodsReturn, t as UsePlatformConfigReturn, y as UseUpdatePlatformConfigReturn, e as branchHooks, o as couponHooks, h as useBranchActions, g as useBranchDetail, i as useBranchNavigation, f as useBranches, r as useCouponActions, q as useCouponDetail, s as useCouponNavigation, p as useCoupons, c as useDeliveryZones, d as useMembershipConfig, b as usePaymentMethods, u as usePlatformConfig, a as useUpdatePlatformConfig, m as useUserActions, l as useUserDetail, n as useUserNavigation, k as useUsers, j as userHooks } from '../coupon-zGkvO-Xx.js';
|
|
5
|
+
import '../crud.factory-DyKaPHcU.js';
|
|
6
|
+
import '@tanstack/react-query';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Webhook Types
|
|
10
|
+
*
|
|
11
|
+
* Type definitions for payment webhook API endpoints.
|
|
12
|
+
* Matches backend routes/webhooks/payment-webhook.plugin.js
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Supported payment gateway providers
|
|
17
|
+
* - manual: Built-in manual verification (cash, bank transfer, mobile money)
|
|
18
|
+
* - stripe: Stripe payment gateway
|
|
19
|
+
* - sslcommerz: SSLCommerz (Bangladesh)
|
|
20
|
+
* - bkash: bKash API integration
|
|
21
|
+
* - nagad: Nagad API integration
|
|
22
|
+
*/
|
|
23
|
+
type PaymentGatewayProvider = 'manual' | 'stripe' | 'sslcommerz' | 'bkash' | 'nagad';
|
|
24
|
+
/**
|
|
25
|
+
* Request payload for manual payment verification
|
|
26
|
+
* POST /webhooks/payments/manual/verify
|
|
27
|
+
*
|
|
28
|
+
* Used by superadmin to verify manual payments (cash, bank transfer, bKash, Nagad)
|
|
29
|
+
*/
|
|
30
|
+
interface ManualVerifyPayload {
|
|
31
|
+
/** Transaction ID to verify (MongoDB ObjectId as string) */
|
|
32
|
+
transactionId: string;
|
|
33
|
+
/** Optional verification notes */
|
|
34
|
+
notes?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Request payload for manual payment rejection
|
|
38
|
+
* POST /webhooks/payments/manual/reject
|
|
39
|
+
*
|
|
40
|
+
* Used by superadmin to reject invalid payments (fraud, invalid reference, etc.)
|
|
41
|
+
*/
|
|
42
|
+
interface ManualRejectPayload {
|
|
43
|
+
/** Transaction ID to reject (MongoDB ObjectId as string) */
|
|
44
|
+
transactionId: string;
|
|
45
|
+
/** Reason for rejection (required) */
|
|
46
|
+
reason: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Entity reference information from transaction
|
|
50
|
+
*/
|
|
51
|
+
interface TransactionEntityRef {
|
|
52
|
+
/** Reference model type (Order, Commission, etc.) */
|
|
53
|
+
referenceModel: string;
|
|
54
|
+
/** Reference document ID */
|
|
55
|
+
referenceId: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Successful verification response data
|
|
59
|
+
*/
|
|
60
|
+
interface ManualVerifyResponseData {
|
|
61
|
+
/** Transaction ID */
|
|
62
|
+
transactionId: string;
|
|
63
|
+
/** New transaction status */
|
|
64
|
+
status: TransactionStatus;
|
|
65
|
+
/** Transaction amount (in smallest currency unit) */
|
|
66
|
+
amount: number;
|
|
67
|
+
/** Transaction category */
|
|
68
|
+
category: TransactionCategory | string;
|
|
69
|
+
/** Verification timestamp (ISO 8601) */
|
|
70
|
+
verifiedAt: string;
|
|
71
|
+
/** User ID who verified */
|
|
72
|
+
verifiedBy: string;
|
|
73
|
+
/** Linked entity (Order, etc.) if exists */
|
|
74
|
+
entity: TransactionEntityRef | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Successful rejection response data
|
|
78
|
+
*/
|
|
79
|
+
interface ManualRejectResponseData {
|
|
80
|
+
/** Transaction ID */
|
|
81
|
+
transactionId: string;
|
|
82
|
+
/** Transaction status (always 'failed') */
|
|
83
|
+
status: 'failed';
|
|
84
|
+
/** Failure timestamp (ISO 8601) */
|
|
85
|
+
failedAt: string;
|
|
86
|
+
/** Rejection reason */
|
|
87
|
+
failureReason: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Provider webhook response data
|
|
91
|
+
*/
|
|
92
|
+
interface ProviderWebhookResponseData {
|
|
93
|
+
/** Webhook event type from provider */
|
|
94
|
+
event: string;
|
|
95
|
+
/** Provider's event ID */
|
|
96
|
+
eventId: string;
|
|
97
|
+
/** Transaction ID (if found) */
|
|
98
|
+
transactionId?: string;
|
|
99
|
+
/** Processing status */
|
|
100
|
+
status: 'processed' | 'already_processed';
|
|
101
|
+
/** Provider name */
|
|
102
|
+
provider: PaymentGatewayProvider;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Webhook error names for error handling
|
|
106
|
+
*/
|
|
107
|
+
type WebhookErrorName = 'TransactionNotFoundError' | 'AlreadyVerifiedError' | 'AlreadyRejectedError' | 'PaymentVerificationError' | 'PaymentRejectionError' | 'ProviderNotFoundError' | 'ValidationError' | 'ProviderError';
|
|
108
|
+
/**
|
|
109
|
+
* Webhook error response
|
|
110
|
+
*/
|
|
111
|
+
interface WebhookErrorResponse {
|
|
112
|
+
success: false;
|
|
113
|
+
message: string;
|
|
114
|
+
error: WebhookErrorName | string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Manual verification API response
|
|
118
|
+
*/
|
|
119
|
+
interface ManualVerifyResponse {
|
|
120
|
+
success: true;
|
|
121
|
+
message: string;
|
|
122
|
+
data: ManualVerifyResponseData;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Manual rejection API response
|
|
126
|
+
*/
|
|
127
|
+
interface ManualRejectResponse {
|
|
128
|
+
success: true;
|
|
129
|
+
message: string;
|
|
130
|
+
data: ManualRejectResponseData;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Provider webhook API response
|
|
134
|
+
*/
|
|
135
|
+
interface ProviderWebhookResponse {
|
|
136
|
+
success: true;
|
|
137
|
+
message: string;
|
|
138
|
+
data: ProviderWebhookResponseData;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Stripe webhook event types (common ones)
|
|
142
|
+
*/
|
|
143
|
+
type StripeWebhookEventType = 'payment_intent.succeeded' | 'payment_intent.payment_failed' | 'checkout.session.completed' | 'checkout.session.expired' | 'charge.refunded' | 'charge.dispute.created';
|
|
144
|
+
/**
|
|
145
|
+
* SSLCommerz IPN status values
|
|
146
|
+
*/
|
|
147
|
+
type SSLCommerzStatus = 'VALID' | 'FAILED' | 'CANCELLED' | 'UNATTEMPTED' | 'EXPIRED';
|
|
148
|
+
/**
|
|
149
|
+
* Generic provider webhook payload
|
|
150
|
+
* Each provider has different formats - this is the common interface
|
|
151
|
+
*/
|
|
152
|
+
interface ProviderWebhookPayload {
|
|
153
|
+
/** Provider-specific event/transaction ID */
|
|
154
|
+
id?: string;
|
|
155
|
+
/** Event type (provider-specific naming) */
|
|
156
|
+
type?: string;
|
|
157
|
+
/** Status (provider-specific) */
|
|
158
|
+
status?: string;
|
|
159
|
+
/** Nested data object (common in Stripe) */
|
|
160
|
+
data?: {
|
|
161
|
+
object?: {
|
|
162
|
+
id?: string;
|
|
163
|
+
payment_intent?: string;
|
|
164
|
+
metadata?: Record<string, string>;
|
|
165
|
+
[key: string]: unknown;
|
|
166
|
+
};
|
|
167
|
+
[key: string]: unknown;
|
|
168
|
+
};
|
|
169
|
+
/** SSLCommerz specific fields */
|
|
170
|
+
tran_id?: string;
|
|
171
|
+
val_id?: string;
|
|
172
|
+
/** Allow additional provider-specific fields */
|
|
173
|
+
[key: string]: unknown;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Export & Archive Types
|
|
178
|
+
*
|
|
179
|
+
* Type definitions for data export (CSV/XLSX) and archival operations.
|
|
180
|
+
*/
|
|
181
|
+
/**
|
|
182
|
+
* Supported collection names for export
|
|
183
|
+
*/
|
|
184
|
+
type ExportCollection = 'product' | 'order' | 'customer' | 'transaction' | 'stockEntry' | 'stockMovement';
|
|
185
|
+
/**
|
|
186
|
+
* Export format
|
|
187
|
+
*/
|
|
188
|
+
type ExportFormat = 'csv' | 'xlsx';
|
|
189
|
+
/**
|
|
190
|
+
* Export request parameters
|
|
191
|
+
*/
|
|
192
|
+
interface ExportParams {
|
|
193
|
+
/** Collection to export */
|
|
194
|
+
collection: ExportCollection;
|
|
195
|
+
/** Comma-separated field names to include */
|
|
196
|
+
select?: string;
|
|
197
|
+
/** JSON filter criteria (stringified) */
|
|
198
|
+
filter?: string | Record<string, unknown>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Export response (blob data)
|
|
202
|
+
*/
|
|
203
|
+
interface ExportResponse {
|
|
204
|
+
data: Blob;
|
|
205
|
+
response: Response;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Supported archive types
|
|
209
|
+
*/
|
|
210
|
+
type ArchiveType = 'transaction' | 'stock_movement';
|
|
211
|
+
/**
|
|
212
|
+
* Archive creation payload
|
|
213
|
+
*/
|
|
214
|
+
interface CreateArchivePayload {
|
|
215
|
+
type: ArchiveType;
|
|
216
|
+
organizationId?: string;
|
|
217
|
+
rangeFrom?: Date | string;
|
|
218
|
+
rangeTo?: Date | string;
|
|
219
|
+
ttlDays?: number;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Archive record
|
|
223
|
+
*/
|
|
224
|
+
interface Archive {
|
|
225
|
+
_id: string;
|
|
226
|
+
type: ArchiveType;
|
|
227
|
+
organizationId?: string;
|
|
228
|
+
rangeFrom: string;
|
|
229
|
+
rangeTo: string;
|
|
230
|
+
filePath: string;
|
|
231
|
+
format: 'json';
|
|
232
|
+
recordCount: number;
|
|
233
|
+
sizeBytes: number;
|
|
234
|
+
expiresAt?: string;
|
|
235
|
+
archivedAt: string;
|
|
236
|
+
createdAt: string;
|
|
237
|
+
updatedAt: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Archive result (after creation)
|
|
241
|
+
*/
|
|
242
|
+
interface ArchiveResult {
|
|
243
|
+
archived: number;
|
|
244
|
+
filePath: string;
|
|
245
|
+
cutoffDate: string;
|
|
246
|
+
olderThanDays: number;
|
|
247
|
+
message?: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Stock movement statistics
|
|
251
|
+
*/
|
|
252
|
+
interface StockMovementStats {
|
|
253
|
+
total: number;
|
|
254
|
+
last30Days: number;
|
|
255
|
+
last90Days: number;
|
|
256
|
+
lastYear: number;
|
|
257
|
+
olderThanYear: number;
|
|
258
|
+
recommendation: string;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Transaction statistics
|
|
262
|
+
*/
|
|
263
|
+
interface TransactionStats {
|
|
264
|
+
total: number;
|
|
265
|
+
last30Days: number;
|
|
266
|
+
last90Days: number;
|
|
267
|
+
lastYear: number;
|
|
268
|
+
olderThanYear: number;
|
|
269
|
+
pending: number;
|
|
270
|
+
archivable: number;
|
|
271
|
+
recommendation: string;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Options for archiving old data
|
|
275
|
+
*/
|
|
276
|
+
interface ArchiveOptions {
|
|
277
|
+
/** Archive records older than X days (default: 365) */
|
|
278
|
+
olderThanDays?: number;
|
|
279
|
+
/** Branch ID filter (optional) */
|
|
280
|
+
branchId?: string;
|
|
281
|
+
/** How long to keep archives before deletion (default: 730 days for movements, 2555 for transactions) */
|
|
282
|
+
ttlDays?: number;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Cleanup expired archives result
|
|
286
|
+
*/
|
|
287
|
+
interface CleanupResult {
|
|
288
|
+
deletedArchives: number;
|
|
289
|
+
deletedFiles: number;
|
|
290
|
+
orphanedFilesRemoved: number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Payment Webhook API
|
|
295
|
+
*
|
|
296
|
+
* Handles manual payment verification/rejection for superadmins.
|
|
297
|
+
*
|
|
298
|
+
* Routes:
|
|
299
|
+
* - POST /webhooks/payments/manual/verify - Verify manual payment (superadmin)
|
|
300
|
+
* - POST /webhooks/payments/manual/reject - Reject manual payment (superadmin)
|
|
301
|
+
*
|
|
302
|
+
* Note: Provider webhooks (POST /webhooks/payments/:provider) are called
|
|
303
|
+
* directly by payment providers (Stripe, SSLCommerz, etc.) and don't need
|
|
304
|
+
* a frontend client method.
|
|
305
|
+
*/
|
|
306
|
+
|
|
307
|
+
type FetchOptions$1 = Omit<RequestInit, 'body' | 'method'>;
|
|
308
|
+
declare class WebhookApi {
|
|
309
|
+
private baseUrl;
|
|
310
|
+
constructor();
|
|
311
|
+
/**
|
|
312
|
+
* Verify a manual payment (superadmin only)
|
|
313
|
+
* POST /webhooks/payments/manual/verify
|
|
314
|
+
*
|
|
315
|
+
* Flow:
|
|
316
|
+
* 1. Customer places order with manual payment (cash, bKash, Nagad, bank)
|
|
317
|
+
* 2. Customer pays and provides transaction reference
|
|
318
|
+
* 3. Admin verifies payment via this endpoint
|
|
319
|
+
* 4. Transaction status -> 'verified'
|
|
320
|
+
* 5. Order payment status -> 'verified', order status -> 'confirmed'
|
|
321
|
+
*
|
|
322
|
+
* @param params.transactionId - Transaction ID to verify
|
|
323
|
+
* @param params.notes - Optional verification notes
|
|
324
|
+
* @param params.token - Auth token (superadmin required)
|
|
325
|
+
* @param params.options - Additional fetch options
|
|
326
|
+
* @returns Verification result with transaction details
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```typescript
|
|
330
|
+
* const result = await webhookApi.verifyPayment({
|
|
331
|
+
* token: adminToken,
|
|
332
|
+
* transactionId: '507f1f77bcf86cd799439011',
|
|
333
|
+
* notes: 'Verified bKash TrxID via app',
|
|
334
|
+
* });
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
verifyPayment({ token, transactionId, notes, options, }: {
|
|
338
|
+
token: string;
|
|
339
|
+
transactionId: string;
|
|
340
|
+
notes?: string;
|
|
341
|
+
options?: FetchOptions$1;
|
|
342
|
+
}): Promise<ApiResponse<ManualVerifyResponseData>>;
|
|
343
|
+
/**
|
|
344
|
+
* Reject a manual payment (superadmin only)
|
|
345
|
+
* POST /webhooks/payments/manual/reject
|
|
346
|
+
*
|
|
347
|
+
* Flow:
|
|
348
|
+
* 1. Customer claims to have paid but admin finds issue
|
|
349
|
+
* 2. Admin rejects payment with reason via this endpoint
|
|
350
|
+
* 3. Transaction status -> 'failed', failureReason recorded
|
|
351
|
+
* 4. Order payment status -> 'failed'
|
|
352
|
+
*
|
|
353
|
+
* Common rejection reasons:
|
|
354
|
+
* - Invalid transaction reference
|
|
355
|
+
* - Amount mismatch
|
|
356
|
+
* - Duplicate claim
|
|
357
|
+
* - Suspected fraud
|
|
358
|
+
* - Payment not received
|
|
359
|
+
*
|
|
360
|
+
* @param params.transactionId - Transaction ID to reject
|
|
361
|
+
* @param params.reason - Rejection reason (required)
|
|
362
|
+
* @param params.token - Auth token (superadmin required)
|
|
363
|
+
* @param params.options - Additional fetch options
|
|
364
|
+
* @returns Rejection result with failure details
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* const result = await webhookApi.rejectPayment({
|
|
369
|
+
* token: adminToken,
|
|
370
|
+
* transactionId: '507f1f77bcf86cd799439011',
|
|
371
|
+
* reason: 'Invalid bKash TrxID - no matching transaction found',
|
|
372
|
+
* });
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
rejectPayment({ token, transactionId, reason, options, }: {
|
|
376
|
+
token: string;
|
|
377
|
+
transactionId: string;
|
|
378
|
+
reason: string;
|
|
379
|
+
options?: FetchOptions$1;
|
|
380
|
+
}): Promise<ApiResponse<ManualRejectResponseData>>;
|
|
381
|
+
/**
|
|
382
|
+
* Alias for verifyPayment - more explicit naming
|
|
383
|
+
* @deprecated Use verifyPayment instead
|
|
384
|
+
*/
|
|
385
|
+
verifyManualPayment(params: Parameters<typeof this.verifyPayment>[0]): Promise<ApiResponse<ManualVerifyResponseData>>;
|
|
386
|
+
/**
|
|
387
|
+
* Alias for rejectPayment - more explicit naming
|
|
388
|
+
* @deprecated Use rejectPayment instead
|
|
389
|
+
*/
|
|
390
|
+
rejectManualPayment(params: Parameters<typeof this.rejectPayment>[0]): Promise<ApiResponse<ManualRejectResponseData>>;
|
|
391
|
+
}
|
|
392
|
+
declare const webhookApi: WebhookApi;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Export API - Data Export Operations
|
|
396
|
+
*
|
|
397
|
+
* Consolidated API for exporting data to CSV/XLSX formats.
|
|
398
|
+
*
|
|
399
|
+
* Routes:
|
|
400
|
+
* - GET /export/csv?collection=xxx&select=yyy&filter=zzz
|
|
401
|
+
* - GET /export/xlsx?collection=xxx&select=yyy&filter=zzz
|
|
402
|
+
*
|
|
403
|
+
* Features:
|
|
404
|
+
* - MongoKit repository-based exports (secure, role-filtered)
|
|
405
|
+
* - Role-based field filtering (hides sensitive data like costPrice)
|
|
406
|
+
* - CSV and XLSX formats
|
|
407
|
+
* - Direct download or programmatic handling
|
|
408
|
+
* - Filter support with MongoDB query syntax
|
|
409
|
+
*
|
|
410
|
+
* Supported Collections:
|
|
411
|
+
* - product: Product catalog with pricing
|
|
412
|
+
* - order: Order history
|
|
413
|
+
* - customer: Customer list
|
|
414
|
+
* - transaction: Financial transactions
|
|
415
|
+
* - stockEntry: Current inventory levels
|
|
416
|
+
* - stockMovement: Inventory movement history
|
|
417
|
+
*
|
|
418
|
+
* Usage Examples:
|
|
419
|
+
* ```ts
|
|
420
|
+
* // Export all products to CSV
|
|
421
|
+
* const blob = await exportApi.toCSV({ token, collection: 'product' });
|
|
422
|
+
*
|
|
423
|
+
* // Export orders with filters
|
|
424
|
+
* const blob = await exportApi.toXLSX({
|
|
425
|
+
* token,
|
|
426
|
+
* collection: 'order',
|
|
427
|
+
* filter: { status: 'delivered' },
|
|
428
|
+
* select: 'orderNumber,customer,totalAmount,createdAt'
|
|
429
|
+
* });
|
|
430
|
+
*
|
|
431
|
+
* // Trigger browser download
|
|
432
|
+
* exportApi.downloadFile(blob, 'orders.xlsx');
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
|
|
436
|
+
type FetchOptions = Omit<RequestOptions, 'token' | 'organizationId'>;
|
|
437
|
+
declare class ExportApi {
|
|
438
|
+
private readonly basePath;
|
|
439
|
+
constructor();
|
|
440
|
+
/**
|
|
441
|
+
* Build query string from export parameters
|
|
442
|
+
*/
|
|
443
|
+
private buildQueryString;
|
|
444
|
+
/**
|
|
445
|
+
* Export data to CSV format
|
|
446
|
+
* GET /export/csv
|
|
447
|
+
*
|
|
448
|
+
* Returns CSV file as blob for download or processing.
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* // Export all products
|
|
452
|
+
* const blob = await exportApi.toCSV({ token, collection: 'product' });
|
|
453
|
+
*
|
|
454
|
+
* // Export filtered transactions
|
|
455
|
+
* const blob = await exportApi.toCSV({
|
|
456
|
+
* token,
|
|
457
|
+
* collection: 'transaction',
|
|
458
|
+
* filter: { status: 'verified' },
|
|
459
|
+
* select: 'amount,method,status,createdAt'
|
|
460
|
+
* });
|
|
461
|
+
*/
|
|
462
|
+
toCSV({ token, collection, filter, select, options, }: {
|
|
463
|
+
token: string;
|
|
464
|
+
collection: ExportCollection;
|
|
465
|
+
filter?: Record<string, unknown> | string;
|
|
466
|
+
select?: string;
|
|
467
|
+
options?: FetchOptions;
|
|
468
|
+
}): Promise<Blob>;
|
|
469
|
+
/**
|
|
470
|
+
* Export data to XLSX (Excel) format
|
|
471
|
+
* GET /export/xlsx
|
|
472
|
+
*
|
|
473
|
+
* Returns Excel file as blob for download or processing.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* // Export stock movements
|
|
477
|
+
* const blob = await exportApi.toXLSX({
|
|
478
|
+
* token,
|
|
479
|
+
* collection: 'stockMovement',
|
|
480
|
+
* filter: { type: 'sale', createdAt: { $gte: '2024-01-01' } }
|
|
481
|
+
* });
|
|
482
|
+
*/
|
|
483
|
+
toXLSX({ token, collection, filter, select, options, }: {
|
|
484
|
+
token: string;
|
|
485
|
+
collection: ExportCollection;
|
|
486
|
+
filter?: Record<string, unknown> | string;
|
|
487
|
+
select?: string;
|
|
488
|
+
options?: FetchOptions;
|
|
489
|
+
}): Promise<Blob>;
|
|
490
|
+
/**
|
|
491
|
+
* Export data with specified format
|
|
492
|
+
* Convenience method for format-agnostic exports
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* const format = userPreference.exportFormat; // 'csv' | 'xlsx'
|
|
496
|
+
* const blob = await exportApi.export({
|
|
497
|
+
* token,
|
|
498
|
+
* format,
|
|
499
|
+
* collection: 'customer',
|
|
500
|
+
* select: 'name,phone,email'
|
|
501
|
+
* });
|
|
502
|
+
*/
|
|
503
|
+
export({ token, format, collection, filter, select, options, }: {
|
|
504
|
+
token: string;
|
|
505
|
+
format: ExportFormat;
|
|
506
|
+
collection: ExportCollection;
|
|
507
|
+
filter?: Record<string, unknown> | string;
|
|
508
|
+
select?: string;
|
|
509
|
+
options?: FetchOptions;
|
|
510
|
+
}): Promise<Blob>;
|
|
511
|
+
/**
|
|
512
|
+
* Trigger browser download of blob
|
|
513
|
+
* Creates temporary link and clicks it to download file
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* const blob = await exportApi.toCSV({ token, collection: 'product' });
|
|
517
|
+
* exportApi.downloadFile(blob, 'products.csv');
|
|
518
|
+
*/
|
|
519
|
+
downloadFile(blob: Blob, filename: string): void;
|
|
520
|
+
/**
|
|
521
|
+
* Get suggested filename based on collection and format
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* const filename = exportApi.getSuggestedFilename('product', 'csv');
|
|
525
|
+
* // Returns: 'products-2024-12-11.csv'
|
|
526
|
+
*/
|
|
527
|
+
getSuggestedFilename(collection: ExportCollection, format: ExportFormat): string;
|
|
528
|
+
}
|
|
529
|
+
declare const exportApi: ExportApi;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Export and download in one call
|
|
533
|
+
* Convenience wrapper for common use case
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* await exportAndDownload({
|
|
537
|
+
* token,
|
|
538
|
+
* format: 'xlsx',
|
|
539
|
+
* collection: 'order',
|
|
540
|
+
* filter: { status: 'delivered' }
|
|
541
|
+
* });
|
|
542
|
+
*/
|
|
543
|
+
declare function exportAndDownload({ token, format, collection, filter, select, filename, }: {
|
|
544
|
+
token: string;
|
|
545
|
+
format: ExportFormat;
|
|
546
|
+
collection: ExportCollection;
|
|
547
|
+
filter?: Record<string, unknown> | string;
|
|
548
|
+
select?: string;
|
|
549
|
+
filename?: string;
|
|
550
|
+
}): Promise<void>;
|
|
551
|
+
/**
|
|
552
|
+
* Read CSV blob as text
|
|
553
|
+
* Useful for preview or parsing
|
|
554
|
+
*
|
|
555
|
+
* @example
|
|
556
|
+
* const blob = await exportApi.toCSV({ token, collection: 'customer' });
|
|
557
|
+
* const csvText = await readCSVBlob(blob);
|
|
558
|
+
* console.log('First 100 chars:', csvText.slice(0, 100));
|
|
559
|
+
*/
|
|
560
|
+
declare function readCSVBlob(blob: Blob): Promise<string>;
|
|
561
|
+
/**
|
|
562
|
+
* Parse CSV text to array of objects
|
|
563
|
+
* Simple CSV parser for client-side processing
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* const csvText = await readCSVBlob(blob);
|
|
567
|
+
* const data = parseCSV(csvText);
|
|
568
|
+
* console.log('First row:', data[0]);
|
|
569
|
+
*/
|
|
570
|
+
declare function parseCSV(csvText: string): Array<Record<string, string>>;
|
|
571
|
+
/**
|
|
572
|
+
* Common filter builders for exports
|
|
573
|
+
*/
|
|
574
|
+
declare const ExportFilters: {
|
|
575
|
+
/** Orders by date range */
|
|
576
|
+
ordersByDateRange: (startDate: string, endDate: string) => {
|
|
577
|
+
createdAt: {
|
|
578
|
+
$gte: string;
|
|
579
|
+
$lte: string;
|
|
580
|
+
};
|
|
581
|
+
};
|
|
582
|
+
/** Orders by status */
|
|
583
|
+
ordersByStatus: (status: string | string[]) => {
|
|
584
|
+
status: {
|
|
585
|
+
$in: string[];
|
|
586
|
+
};
|
|
587
|
+
} | {
|
|
588
|
+
status: string;
|
|
589
|
+
};
|
|
590
|
+
/** Transactions by date and status */
|
|
591
|
+
transactionsByDate: (startDate: string, endDate: string, status?: string) => {
|
|
592
|
+
status?: string | undefined;
|
|
593
|
+
transactionDate: {
|
|
594
|
+
$gte: string;
|
|
595
|
+
$lte: string;
|
|
596
|
+
};
|
|
597
|
+
};
|
|
598
|
+
/** Stock movements by type and date */
|
|
599
|
+
movementsByType: (type: string, startDate?: string, endDate?: string) => {
|
|
600
|
+
createdAt?: {
|
|
601
|
+
$gte: string;
|
|
602
|
+
$lte: string;
|
|
603
|
+
} | undefined;
|
|
604
|
+
type: string;
|
|
605
|
+
};
|
|
606
|
+
/** Products by category */
|
|
607
|
+
productsByCategory: (category: string | string[]) => {
|
|
608
|
+
category: {
|
|
609
|
+
$in: string[];
|
|
610
|
+
};
|
|
611
|
+
} | {
|
|
612
|
+
category: string;
|
|
613
|
+
};
|
|
614
|
+
/** Customers with orders */
|
|
615
|
+
customersWithOrders: () => {
|
|
616
|
+
'stats.totalOrders': {
|
|
617
|
+
$gt: number;
|
|
618
|
+
};
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* Common field selections for exports
|
|
623
|
+
*/
|
|
624
|
+
declare const ExportFields: {
|
|
625
|
+
/** Product essentials */
|
|
626
|
+
productBasic: string;
|
|
627
|
+
productFull: string;
|
|
628
|
+
/** Order essentials */
|
|
629
|
+
orderBasic: string;
|
|
630
|
+
orderFull: string;
|
|
631
|
+
/** Customer essentials */
|
|
632
|
+
customerBasic: string;
|
|
633
|
+
customerFull: string;
|
|
634
|
+
/** Transaction essentials */
|
|
635
|
+
transactionBasic: string;
|
|
636
|
+
transactionFull: string;
|
|
637
|
+
/** Stock essentials */
|
|
638
|
+
stockBasic: string;
|
|
639
|
+
stockFull: string;
|
|
640
|
+
/** Movement essentials */
|
|
641
|
+
movementBasic: string;
|
|
642
|
+
movementFull: string;
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
export { type Archive, type ArchiveOptions, type ArchiveResult, type ArchiveType, type CleanupResult, type CreateArchivePayload, ExportApi, type ExportCollection, ExportFields, ExportFilters, type ExportFormat, type ExportParams, type ExportResponse, type ManualRejectPayload, type ManualRejectResponse, type ManualRejectResponseData, type ManualVerifyPayload, type ManualVerifyResponse, type ManualVerifyResponseData, type PaymentGatewayProvider, type ProviderWebhookPayload, type ProviderWebhookResponse, type ProviderWebhookResponseData, type SSLCommerzStatus, type StockMovementStats, type StripeWebhookEventType, type TransactionEntityRef, type TransactionStats, WebhookApi, type WebhookErrorName, type WebhookErrorResponse, exportAndDownload, exportApi, parseCSV, readCSVBlob, webhookApi };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export { BRANCH_KEYS, BranchApi, COUPON_KEYS, CouponApi, ExportApi, ExportFields, ExportFilters, PLATFORM_KEYS, PlatformConfigApi, USER_KEYS, UserApi, WebhookApi, branchApi, branchHooks, businessApi, couponApi, couponHooks, exportAndDownload, exportApi, isHeadOffice, isSubBranch, parseCSV, platformApi, platformConfigApi, readCSVBlob, useBranchActions, useBranchDetail, useBranchNavigation, useBranches, useCouponActions, useCouponDetail, useCouponNavigation, useCoupons, useDeliveryZones, useMembershipConfig, usePaymentMethods, usePlatformConfig, useUpdatePlatformConfig, useUserActions, useUserDetail, useUserNavigation, useUsers, userApi, userHooks, webhookApi } from '../chunk-OF5M6R2S.js';
|
|
3
|
+
import '../chunk-I5TIKUIQ.js';
|
|
4
|
+
import '../chunk-B6MPVOV7.js';
|
|
5
|
+
import '../chunk-U3XT35GZ.js';
|
|
6
|
+
import '../chunk-VR36QVX2.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|