@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.

Files changed (131) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +104 -0
  3. package/dist/adjustment-DTSLM7AN.js +5 -0
  4. package/dist/adjustment-DTSLM7AN.js.map +1 -0
  5. package/dist/analytics/index.d.ts +27 -0
  6. package/dist/analytics/index.js +6 -0
  7. package/dist/analytics/index.js.map +1 -0
  8. package/dist/analytics-DMcD-o8w.d.ts +76 -0
  9. package/dist/api-factory-B_h4RKBm.d.ts +280 -0
  10. package/dist/auth/index.d.ts +39 -0
  11. package/dist/auth/index.js +5 -0
  12. package/dist/auth/index.js.map +1 -0
  13. package/dist/catalog/index.d.ts +479 -0
  14. package/dist/catalog/index.js +9 -0
  15. package/dist/catalog/index.js.map +1 -0
  16. package/dist/chunk-4ZQK3FFN.js +40 -0
  17. package/dist/chunk-4ZQK3FFN.js.map +1 -0
  18. package/dist/chunk-5L6EXDGH.js +465 -0
  19. package/dist/chunk-5L6EXDGH.js.map +1 -0
  20. package/dist/chunk-5ZFW3FEI.js +183 -0
  21. package/dist/chunk-5ZFW3FEI.js.map +1 -0
  22. package/dist/chunk-66OQAZSL.js +94 -0
  23. package/dist/chunk-66OQAZSL.js.map +1 -0
  24. package/dist/chunk-6RYGA6MF.js +123 -0
  25. package/dist/chunk-6RYGA6MF.js.map +1 -0
  26. package/dist/chunk-B6MPVOV7.js +328 -0
  27. package/dist/chunk-B6MPVOV7.js.map +1 -0
  28. package/dist/chunk-BDA2WSJA.js +148 -0
  29. package/dist/chunk-BDA2WSJA.js.map +1 -0
  30. package/dist/chunk-EIVYT3HM.js +126 -0
  31. package/dist/chunk-EIVYT3HM.js.map +1 -0
  32. package/dist/chunk-EPQN7ZKZ.js +27 -0
  33. package/dist/chunk-EPQN7ZKZ.js.map +1 -0
  34. package/dist/chunk-FA7QFJ2G.js +177 -0
  35. package/dist/chunk-FA7QFJ2G.js.map +1 -0
  36. package/dist/chunk-I5TIKUIQ.js +261 -0
  37. package/dist/chunk-I5TIKUIQ.js.map +1 -0
  38. package/dist/chunk-ILQUH444.js +135 -0
  39. package/dist/chunk-ILQUH444.js.map +1 -0
  40. package/dist/chunk-IXMWZJLV.js +616 -0
  41. package/dist/chunk-IXMWZJLV.js.map +1 -0
  42. package/dist/chunk-KZIGRIQG.js +75 -0
  43. package/dist/chunk-KZIGRIQG.js.map +1 -0
  44. package/dist/chunk-OF5M6R2S.js +769 -0
  45. package/dist/chunk-OF5M6R2S.js.map +1 -0
  46. package/dist/chunk-PYYLHUV6.js +3 -0
  47. package/dist/chunk-PYYLHUV6.js.map +1 -0
  48. package/dist/chunk-QO5AGZFP.js +159 -0
  49. package/dist/chunk-QO5AGZFP.js.map +1 -0
  50. package/dist/chunk-QUMTBLNE.js +76 -0
  51. package/dist/chunk-QUMTBLNE.js.map +1 -0
  52. package/dist/chunk-R5Z7NYLH.js +126 -0
  53. package/dist/chunk-R5Z7NYLH.js.map +1 -0
  54. package/dist/chunk-SZYWG5IB.js +75 -0
  55. package/dist/chunk-SZYWG5IB.js.map +1 -0
  56. package/dist/chunk-U3XT35GZ.js +202 -0
  57. package/dist/chunk-U3XT35GZ.js.map +1 -0
  58. package/dist/chunk-UGELTUIZ.js +830 -0
  59. package/dist/chunk-UGELTUIZ.js.map +1 -0
  60. package/dist/chunk-VR36QVX2.js +122 -0
  61. package/dist/chunk-VR36QVX2.js.map +1 -0
  62. package/dist/chunk-WUOQK7BO.js +13 -0
  63. package/dist/chunk-WUOQK7BO.js.map +1 -0
  64. package/dist/chunk-X6PV5MHG.js +582 -0
  65. package/dist/chunk-X6PV5MHG.js.map +1 -0
  66. package/dist/chunk-ZWLMFLLH.js +534 -0
  67. package/dist/chunk-ZWLMFLLH.js.map +1 -0
  68. package/dist/content/index.d.ts +309 -0
  69. package/dist/content/index.js +6 -0
  70. package/dist/content/index.js.map +1 -0
  71. package/dist/core/index.d.ts +107 -0
  72. package/dist/core/index.js +5 -0
  73. package/dist/core/index.js.map +1 -0
  74. package/dist/core/react.d.ts +107 -0
  75. package/dist/core/react.js +5 -0
  76. package/dist/core/react.js.map +1 -0
  77. package/dist/coupon-CHFcw7cd.d.ts +632 -0
  78. package/dist/coupon-zGkvO-Xx.d.ts +129 -0
  79. package/dist/crud.factory-DyKaPHcU.d.ts +181 -0
  80. package/dist/finance/index.d.ts +81 -0
  81. package/dist/finance/index.js +5 -0
  82. package/dist/finance/index.js.map +1 -0
  83. package/dist/finance-BJdfKRw0.d.ts +135 -0
  84. package/dist/index.d.ts +31 -0
  85. package/dist/index.js +29 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/inventory/index.d.ts +512 -0
  88. package/dist/inventory/index.js +16 -0
  89. package/dist/inventory/index.js.map +1 -0
  90. package/dist/inventory-DCiIZh8P.d.ts +742 -0
  91. package/dist/logistics/index.d.ts +226 -0
  92. package/dist/logistics/index.js +7 -0
  93. package/dist/logistics/index.js.map +1 -0
  94. package/dist/logistics-V8a9lUN3.d.ts +428 -0
  95. package/dist/media-CNLJK93J.d.ts +721 -0
  96. package/dist/movement-7MV3ADY5.js +5 -0
  97. package/dist/movement-7MV3ADY5.js.map +1 -0
  98. package/dist/payment-BRboLqvU.d.ts +127 -0
  99. package/dist/payments/index.d.ts +55 -0
  100. package/dist/payments/index.js +6 -0
  101. package/dist/payments/index.js.map +1 -0
  102. package/dist/platform/index.d.ts +645 -0
  103. package/dist/platform/index.js +8 -0
  104. package/dist/platform/index.js.map +1 -0
  105. package/dist/pos-D1jkkFl0.d.ts +885 -0
  106. package/dist/product-p09zXkXB.d.ts +260 -0
  107. package/dist/purchase-24BGT2HA.js +5 -0
  108. package/dist/purchase-24BGT2HA.js.map +1 -0
  109. package/dist/request-652PS6VR.js +5 -0
  110. package/dist/request-652PS6VR.js.map +1 -0
  111. package/dist/sales/index.d.ts +585 -0
  112. package/dist/sales/index.js +9 -0
  113. package/dist/sales/index.js.map +1 -0
  114. package/dist/server.d.ts +120 -0
  115. package/dist/server.js +27 -0
  116. package/dist/server.js.map +1 -0
  117. package/dist/size-guide-DgjzjM5P.d.ts +554 -0
  118. package/dist/stock-DEApGC-w.d.ts +632 -0
  119. package/dist/stock-OOUW57VQ.js +5 -0
  120. package/dist/stock-OOUW57VQ.js.map +1 -0
  121. package/dist/supplier-OC6JAWV6.js +5 -0
  122. package/dist/supplier-OC6JAWV6.js.map +1 -0
  123. package/dist/transaction/index.d.ts +104 -0
  124. package/dist/transaction/index.js +8 -0
  125. package/dist/transaction/index.js.map +1 -0
  126. package/dist/transaction-BTmoHpWh.d.ts +428 -0
  127. package/dist/transaction-u5oaNuav.d.ts +84 -0
  128. package/dist/transfer-7SYSH3RG.js +5 -0
  129. package/dist/transfer-7SYSH3RG.js.map +1 -0
  130. package/dist/user-data-DdLjAGwO.d.ts +132 -0
  131. package/package.json +146 -0
@@ -0,0 +1,226 @@
1
+ import { m as PickupStore, P as ProviderName, d as ProviderCharges, j as Shipment, k as TrackingResult, C as CreateShipmentPayload } from '../logistics-V8a9lUN3.js';
2
+ export { A as Area, q as CalculateChargeParams, p as CancelShipmentPayload, t as CheckoutSettings, r as DeliveryFeeSource, u as DeliveryMethod, v as DeliveryOption, b as District, D as Division, L as LogisticsApi, o as LogisticsConfig, c as LogisticsProvider, s as PickupBranchInfo, a as ProviderAreaIds, n as ProviderConfig, h as ShipmentCashCollection, g as ShipmentDelivery, e as ShipmentParcel, f as ShipmentPickup, S as ShipmentStatus, i as ShipmentTimelineEvent, T as TrackingData, U as UpdateShipmentStatusPayload, l as logisticsApi } from '../logistics-V8a9lUN3.js';
3
+ import * as _tanstack_react_query from '@tanstack/react-query';
4
+ import '../api-factory-B_h4RKBm.js';
5
+
6
+ declare const LOGISTICS_KEYS: {
7
+ all: readonly ["logistics"];
8
+ pickupStores: (provider?: string) => readonly ["logistics", "pickup-stores", string | undefined];
9
+ shipment: (id: string) => readonly ["logistics", "shipment", string];
10
+ tracking: (id: string) => readonly ["logistics", "tracking", string];
11
+ charge: (params: {
12
+ deliveryAreaId: number;
13
+ amount: number;
14
+ weight?: number;
15
+ }) => readonly ["logistics", "charge", {
16
+ deliveryAreaId: number;
17
+ amount: number;
18
+ weight?: number;
19
+ }];
20
+ config: () => readonly ["logistics", "config"];
21
+ };
22
+ interface QueryOptions {
23
+ enabled?: boolean;
24
+ staleTime?: number;
25
+ refetchInterval?: number | false;
26
+ }
27
+ interface ChargeParams {
28
+ deliveryAreaId: number;
29
+ pickupAreaId?: number;
30
+ amount: number;
31
+ weight?: number;
32
+ provider?: ProviderName;
33
+ }
34
+ interface UseDeliveryChargeParams {
35
+ deliveryAreaId: number | null | undefined;
36
+ amount: number;
37
+ weight?: number;
38
+ enabled?: boolean;
39
+ }
40
+ interface UseDeliveryChargeReturn {
41
+ charges: ProviderCharges | null;
42
+ deliveryCharge: number;
43
+ codCharge: number;
44
+ totalCharge: number;
45
+ isLoading: boolean;
46
+ isFetching: boolean;
47
+ error: Error | null;
48
+ refetch: () => void;
49
+ }
50
+ interface UseLogisticsActionsReturn {
51
+ createShipment: (data: CreateShipmentPayload) => Promise<Shipment | undefined>;
52
+ isCreatingShipment: boolean;
53
+ cancelShipment: (params: {
54
+ shipmentId: string;
55
+ reason?: string;
56
+ }) => Promise<Shipment | undefined>;
57
+ isCancellingShipment: boolean;
58
+ updateShipmentStatus: (params: {
59
+ shipmentId: string;
60
+ status: string;
61
+ message?: string;
62
+ }) => Promise<Shipment | undefined>;
63
+ isUpdatingStatus: boolean;
64
+ isLoading: boolean;
65
+ }
66
+ /**
67
+ * Fetch pickup stores from logistics provider
68
+ *
69
+ * @param token - Auth token (admin required)
70
+ * @param provider - Optional provider filter
71
+ * @param options - Query options
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * function PickupStoreSelect() {
76
+ * const { data: stores, isLoading } = usePickupStores(token);
77
+ *
78
+ * return (
79
+ * <Select>
80
+ * {stores?.map(store => (
81
+ * <SelectItem key={store.id} value={store.id.toString()}>
82
+ * {store.name} - {store.areaName}
83
+ * </SelectItem>
84
+ * ))}
85
+ * </Select>
86
+ * );
87
+ * }
88
+ * ```
89
+ */
90
+ declare function usePickupStores(token: string, provider?: string, options?: QueryOptions): _tanstack_react_query.UseQueryResult<PickupStore[], Error>;
91
+ /**
92
+ * Calculate delivery charge via provider API
93
+ *
94
+ * @param token - Auth token (optional for public)
95
+ * @param params - Charge calculation parameters
96
+ * @param options - Query options
97
+ *
98
+ * @example
99
+ * ```tsx
100
+ * const { data: charges } = useDeliveryChargeCalculation(token, {
101
+ * deliveryAreaId: 1206,
102
+ * amount: isCOD ? cartTotal : 0,
103
+ * });
104
+ * ```
105
+ */
106
+ declare function useDeliveryChargeCalculation(token: string | null, params: ChargeParams | null, options?: QueryOptions): _tanstack_react_query.UseQueryResult<ProviderCharges, Error>;
107
+ /**
108
+ * Convenience hook for delivery charge with extracted values
109
+ *
110
+ * @param params - Delivery charge parameters
111
+ *
112
+ * @example
113
+ * ```tsx
114
+ * function CheckoutDelivery({ areaId, subtotal, isCOD }) {
115
+ * const { deliveryCharge, isLoading } = useDeliveryCharge({
116
+ * deliveryAreaId: areaId,
117
+ * amount: isCOD ? subtotal : 0,
118
+ * });
119
+ *
120
+ * return (
121
+ * <p>Delivery: {isLoading ? "..." : `৳${deliveryCharge}`}</p>
122
+ * );
123
+ * }
124
+ * ```
125
+ */
126
+ declare function useDeliveryCharge({ deliveryAreaId, amount, weight, enabled, }: UseDeliveryChargeParams): UseDeliveryChargeReturn;
127
+ /**
128
+ * Get shipment by ID
129
+ *
130
+ * @param token - Auth token
131
+ * @param shipmentId - Shipment ID
132
+ * @param options - Query options
133
+ */
134
+ declare function useShipment(token: string, shipmentId: string | null, options?: QueryOptions): _tanstack_react_query.UseQueryResult<Shipment, Error>;
135
+ /**
136
+ * Track shipment - fetches latest status from provider
137
+ *
138
+ * @param token - Auth token
139
+ * @param shipmentId - Shipment ID
140
+ * @param options - Query options (supports refetchInterval for auto-refresh)
141
+ *
142
+ * @example
143
+ * ```tsx
144
+ * function ShipmentTracker({ shipmentId }) {
145
+ * const { data, isLoading } = useTrackShipment(token, shipmentId, {
146
+ * refetchInterval: 5 * 60 * 1000, // Auto-refresh every 5 minutes
147
+ * });
148
+ *
149
+ * return (
150
+ * <Timeline events={data?.tracking?.timeline || []} />
151
+ * );
152
+ * }
153
+ * ```
154
+ */
155
+ declare function useTrackShipment(token: string, shipmentId: string | null, options?: QueryOptions): _tanstack_react_query.UseQueryResult<TrackingResult, Error>;
156
+ /**
157
+ * Create shipment mutation
158
+ *
159
+ * @param token - Auth token
160
+ *
161
+ * @example
162
+ * ```tsx
163
+ * function CreateShipmentButton({ order }) {
164
+ * const { mutate, isPending } = useCreateShipment(token);
165
+ *
166
+ * return (
167
+ * <Button
168
+ * onClick={() => mutate({ orderId: order._id })}
169
+ * disabled={isPending}
170
+ * >
171
+ * Create Shipment
172
+ * </Button>
173
+ * );
174
+ * }
175
+ * ```
176
+ */
177
+ declare function useCreateShipment(token: string): _tanstack_react_query.UseMutationResult<Shipment | undefined, Error, CreateShipmentPayload, unknown>;
178
+ /**
179
+ * Cancel shipment mutation
180
+ *
181
+ * @param token - Auth token
182
+ */
183
+ declare function useCancelShipment(token: string): _tanstack_react_query.UseMutationResult<Shipment | undefined, Error, {
184
+ shipmentId: string;
185
+ reason?: string;
186
+ }, unknown>;
187
+ /**
188
+ * Update shipment status mutation
189
+ *
190
+ * @param token - Auth token
191
+ */
192
+ declare function useUpdateShipmentStatus(token: string): _tanstack_react_query.UseMutationResult<Shipment | undefined, Error, {
193
+ shipmentId: string;
194
+ status: string;
195
+ message?: string;
196
+ }, unknown>;
197
+ /**
198
+ * Combined hook for all logistics mutations
199
+ *
200
+ * @param token - Auth token
201
+ *
202
+ * @example
203
+ * ```tsx
204
+ * function ShipmentActions({ order }) {
205
+ * const {
206
+ * createShipment,
207
+ * cancelShipment,
208
+ * isLoading,
209
+ * } = useLogisticsActions(token);
210
+ *
211
+ * return (
212
+ * <>
213
+ * <Button onClick={() => createShipment({ orderId: order._id })}>
214
+ * Create Shipment
215
+ * </Button>
216
+ * <Button onClick={() => cancelShipment({ shipmentId: order.shipment._id })}>
217
+ * Cancel
218
+ * </Button>
219
+ * </>
220
+ * );
221
+ * }
222
+ * ```
223
+ */
224
+ declare function useLogisticsActions(token: string): UseLogisticsActionsReturn;
225
+
226
+ export { CreateShipmentPayload, LOGISTICS_KEYS, PickupStore, ProviderCharges, ProviderName, Shipment, TrackingResult, type UseDeliveryChargeReturn, type UseLogisticsActionsReturn, useCancelShipment, useCreateShipment, useDeliveryCharge, useDeliveryChargeCalculation, useLogisticsActions, usePickupStores, useShipment, useTrackShipment, useUpdateShipmentStatus };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ export { LOGISTICS_KEYS, LogisticsApi, logisticsApi, useCancelShipment, useCreateShipment, useDeliveryCharge, useDeliveryChargeCalculation, useLogisticsActions, usePickupStores, useShipment, useTrackShipment, useUpdateShipmentStatus } from '../chunk-5L6EXDGH.js';
3
+ import '../chunk-I5TIKUIQ.js';
4
+ import '../chunk-U3XT35GZ.js';
5
+ import '../chunk-VR36QVX2.js';
6
+ //# sourceMappingURL=index.js.map
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,428 @@
1
+ import { B as BaseApi, R as RequestOptions, A as ApiResponse } from './api-factory-B_h4RKBm.js';
2
+
3
+ /**
4
+ * Logistics Types
5
+ *
6
+ * Types for logistics API responses (shipments, tracking, charges).
7
+ * For area data types, install @classytic/bd-areas:
8
+ *
9
+ * ```typescript
10
+ * import type { Area, Division, District, ProviderAreaIds } from '@classytic/bd-areas';
11
+ * import { searchAreas, getAreasByDistrict } from '@classytic/bd-areas';
12
+ * ```
13
+ */
14
+ type ProviderName = 'redx' | 'pathao' | 'steadfast' | 'paperfly';
15
+ interface ProviderAreaIds {
16
+ redx?: number;
17
+ pathao?: number;
18
+ steadfast?: number;
19
+ paperfly?: number;
20
+ }
21
+ interface Area {
22
+ internalId: number;
23
+ name: string;
24
+ districtId: number;
25
+ districtName: string;
26
+ divisionId: number;
27
+ divisionName: string;
28
+ postCode?: string;
29
+ providerAreaIds?: ProviderAreaIds;
30
+ }
31
+ interface Division {
32
+ id: number;
33
+ name: string;
34
+ nameBn?: string;
35
+ }
36
+ interface District {
37
+ id: number;
38
+ divisionId: number;
39
+ name: string;
40
+ nameBn?: string;
41
+ }
42
+ type ShipmentStatus = 'pending' | 'pickup-requested' | 'picked-up' | 'in-transit' | 'out-for-delivery' | 'delivered' | 'failed-attempt' | 'returning' | 'returned' | 'cancelled';
43
+ type LogisticsProvider = 'redx' | 'pathao' | 'steadfast' | 'paperfly' | 'sundarban' | 'manual';
44
+ /**
45
+ * Response from GET /logistics/charge
46
+ *
47
+ * Use deliveryCharge for customer-facing price.
48
+ * codCharge is the provider's fee for cash collection (not charged to customer).
49
+ */
50
+ interface ProviderCharges {
51
+ /** Base delivery charge from provider */
52
+ deliveryCharge: number;
53
+ /** COD charge (provider's fee, not customer-facing) */
54
+ codCharge: number;
55
+ /** Total charge (deliveryCharge + codCharge) */
56
+ totalCharge: number;
57
+ /** Currency code (default: BDT) */
58
+ currency?: string;
59
+ }
60
+ interface ShipmentParcel {
61
+ weight?: number;
62
+ value?: number;
63
+ itemCount?: number;
64
+ }
65
+ interface ShipmentPickup {
66
+ storeId?: number;
67
+ storeName?: string;
68
+ scheduledAt?: string;
69
+ pickedUpAt?: string;
70
+ }
71
+ interface ShipmentDelivery {
72
+ customerName: string;
73
+ customerPhone: string;
74
+ address: string;
75
+ areaId?: number;
76
+ areaName?: string;
77
+ }
78
+ interface ShipmentCashCollection {
79
+ amount: number;
80
+ collected?: boolean;
81
+ collectedAt?: string;
82
+ }
83
+ interface ShipmentTimelineEvent {
84
+ status: ShipmentStatus;
85
+ message?: string;
86
+ messageLocal?: string;
87
+ timestamp: string;
88
+ raw?: Record<string, unknown>;
89
+ }
90
+ interface Shipment {
91
+ _id: string;
92
+ order: string;
93
+ provider: LogisticsProvider;
94
+ trackingId: string;
95
+ providerOrderId?: string;
96
+ status: ShipmentStatus;
97
+ providerStatus?: string;
98
+ parcel: ShipmentParcel;
99
+ pickup: ShipmentPickup;
100
+ delivery: ShipmentDelivery;
101
+ cashCollection: ShipmentCashCollection;
102
+ charges: ProviderCharges;
103
+ merchantInvoiceId?: string;
104
+ timeline: ShipmentTimelineEvent[];
105
+ lastWebhookAt?: string;
106
+ webhookCount: number;
107
+ cancelledBy?: string;
108
+ cancelReason?: string;
109
+ createdBy?: string;
110
+ createdAt: string;
111
+ updatedAt: string;
112
+ }
113
+ interface TrackingData {
114
+ trackingId: string;
115
+ status: ShipmentStatus;
116
+ providerStatus?: string;
117
+ currentLocation?: string;
118
+ estimatedDelivery?: string;
119
+ timeline: ShipmentTimelineEvent[];
120
+ }
121
+ interface TrackingResult {
122
+ shipment: Shipment;
123
+ tracking: TrackingData;
124
+ }
125
+ /**
126
+ * Pickup store from RedX API
127
+ * Admin creates these via RedX dashboard
128
+ * Used for: selecting pickup location when creating shipments
129
+ */
130
+ interface PickupStore {
131
+ /** RedX store ID */
132
+ id: number;
133
+ /** Store name */
134
+ name: string;
135
+ /** Store address */
136
+ address?: string;
137
+ /** Contact phone */
138
+ phone?: string;
139
+ /** Area ID (RedX area) - used for charge calculation */
140
+ areaId?: number;
141
+ /** Area name */
142
+ areaName?: string;
143
+ /** Creation date */
144
+ createdAt?: string;
145
+ }
146
+ interface ProviderConfig {
147
+ provider: LogisticsProvider;
148
+ apiUrl?: string;
149
+ apiKey?: string;
150
+ isActive: boolean;
151
+ isDefault?: boolean;
152
+ settings?: Record<string, unknown>;
153
+ }
154
+ interface LogisticsConfig {
155
+ _id: string;
156
+ defaultProvider: LogisticsProvider;
157
+ providers: ProviderConfig[];
158
+ supportedProviders: LogisticsProvider[];
159
+ }
160
+ interface CreateShipmentPayload {
161
+ orderId: string;
162
+ provider?: LogisticsProvider;
163
+ deliveryAreaId?: number;
164
+ deliveryAreaName?: string;
165
+ providerAreaId?: number;
166
+ pickupStoreId?: number;
167
+ pickupAreaId?: number;
168
+ weight?: number;
169
+ /** COD amount to collect on delivery (0 for prepaid orders) */
170
+ codAmount?: number;
171
+ instructions?: string;
172
+ }
173
+ interface UpdateShipmentStatusPayload {
174
+ status: ShipmentStatus;
175
+ message?: string;
176
+ messageLocal?: string;
177
+ }
178
+ interface CancelShipmentPayload {
179
+ reason?: string;
180
+ }
181
+ interface CalculateChargeParams {
182
+ /** Delivery area internalId from bd-areas */
183
+ deliveryAreaId: number;
184
+ /** COD amount in BDT (use 0 for prepaid) */
185
+ amount: number;
186
+ /** Parcel weight in grams (default: 500g) */
187
+ weight?: number;
188
+ /** Pickup area internalId (optional - auto-fetched from merchant's RedX pickup store) */
189
+ pickupAreaId?: number;
190
+ /** Specific provider (optional - uses default provider if not specified) */
191
+ provider?: ProviderName;
192
+ }
193
+ type DeliveryFeeSource = 'static' | 'provider';
194
+ /**
195
+ * Branch info for store pickup
196
+ */
197
+ interface PickupBranchInfo {
198
+ branchId: string;
199
+ branchCode: string;
200
+ branchName: string;
201
+ }
202
+ /**
203
+ * Checkout settings from platform config
204
+ */
205
+ interface CheckoutSettings {
206
+ /** Enable store pickup option */
207
+ allowStorePickup: boolean;
208
+ /** Branches available for pickup (empty = all active) */
209
+ pickupBranches: PickupBranchInfo[];
210
+ /** Fee source: 'static' (from zones) or 'provider' (from RedX API) */
211
+ deliveryFeeSource: DeliveryFeeSource;
212
+ /** Minimum order for free delivery (0 = disabled) */
213
+ freeDeliveryThreshold: number;
214
+ }
215
+ type DeliveryMethod = 'standard' | 'express' | 'pickup';
216
+ /**
217
+ * Delivery option for checkout UI
218
+ */
219
+ interface DeliveryOption {
220
+ method: DeliveryMethod;
221
+ label: string;
222
+ price: number;
223
+ estimatedDays?: string;
224
+ /** For pickup: branch info */
225
+ pickupBranch?: PickupBranchInfo;
226
+ }
227
+
228
+ type FetchOptions = Omit<RequestOptions, 'token' | 'organizationId'>;
229
+ /**
230
+ * Logistics API
231
+ *
232
+ * Manages shipments and delivery charge calculation.
233
+ *
234
+ * NOTE: For area data (divisions, districts, areas), use @classytic/bd-areas directly:
235
+ * ```typescript
236
+ * import { searchAreas, getAreasByDistrict, getArea } from '@classytic/bd-areas';
237
+ * ```
238
+ *
239
+ * Public Endpoints:
240
+ * - GET /logistics/charge - Calculate delivery charge via provider (RedX)
241
+ *
242
+ * Shipment Endpoints (Admin/Store Manager):
243
+ * - POST /logistics/shipments - Create shipment
244
+ * - GET /logistics/shipments/:id - Get shipment
245
+ * - GET /logistics/shipments/:id/track - Track shipment
246
+ * - PATCH /logistics/shipments/:id/status - Update status manually
247
+ * - POST /logistics/shipments/:id/cancel - Cancel shipment
248
+ *
249
+ * Admin Endpoints:
250
+ * - GET /logistics/config - Get config (read-only)
251
+ * - GET /logistics/pickup-stores - List pickup stores
252
+ * - GET /logistics/health/circuit-status - Get circuit breaker status
253
+ * - POST /logistics/health/circuit-reset/:provider - Reset circuit breaker
254
+ */
255
+ declare class LogisticsApi extends BaseApi<Shipment, CreateShipmentPayload> {
256
+ constructor(config?: {});
257
+ /**
258
+ * Calculate delivery charge via provider API (e.g., RedX)
259
+ * GET /logistics/charge
260
+ *
261
+ * Use this to get real-time delivery charges from the logistics provider
262
+ * before creating an order.
263
+ *
264
+ * @param deliveryAreaId - Area internalId from @classytic/bd-areas
265
+ * @param amount - COD amount in BDT (use 0 for prepaid orders)
266
+ * @param weight - Parcel weight in grams (default: 500g)
267
+ *
268
+ * @example
269
+ * import { searchAreas } from '@classytic/bd-areas';
270
+ *
271
+ * // 1. User selects area
272
+ * const areas = searchAreas('mohamm');
273
+ * const selectedArea = areas[0]; // { internalId: 1206, name: 'Mohammadpur', ... }
274
+ *
275
+ * // 2. Calculate delivery charge
276
+ * const { data } = await logisticsApi.calculateCharge({
277
+ * deliveryAreaId: selectedArea.internalId,
278
+ * amount: isCOD ? cartTotal : 0,
279
+ * });
280
+ * // { deliveryCharge: 60, codCharge: 15, totalCharge: 75 }
281
+ */
282
+ calculateCharge({ deliveryAreaId, pickupAreaId, amount, weight, provider, options, }: {
283
+ deliveryAreaId: number;
284
+ pickupAreaId?: number;
285
+ amount: number;
286
+ weight?: number;
287
+ provider?: ProviderName;
288
+ options?: FetchOptions;
289
+ }): Promise<ApiResponse<ProviderCharges>>;
290
+ /**
291
+ * Get logistics configuration (read-only from .env)
292
+ * GET /logistics/config
293
+ *
294
+ * NOTE: Configuration is managed via environment variables.
295
+ * To change settings, update .env file and restart server.
296
+ */
297
+ getConfig({ token, options, }: {
298
+ token: string;
299
+ options?: FetchOptions;
300
+ }): Promise<ApiResponse<LogisticsConfig>>;
301
+ /**
302
+ * Get pickup stores from RedX API
303
+ * GET /logistics/pickup-stores
304
+ *
305
+ * Pickup stores are created by admin in RedX dashboard.
306
+ * Use this to list available pickup locations when creating shipments.
307
+ *
308
+ * @example
309
+ * // Admin: List pickup stores for shipment creation
310
+ * const { data: stores } = await logisticsApi.getPickupStores({ token });
311
+ *
312
+ * // Display in dropdown for admin to select
313
+ * stores.forEach(store => {
314
+ * console.log(`${store.name} - ${store.areaName} (ID: ${store.id})`);
315
+ * });
316
+ *
317
+ * // Use selected store when creating shipment
318
+ * await logisticsApi.createShipment({
319
+ * token,
320
+ * data: {
321
+ * orderId: order._id,
322
+ * pickupStoreId: selectedStore.id, // From dropdown
323
+ * },
324
+ * });
325
+ */
326
+ getPickupStores({ token, provider, options, }: {
327
+ token: string;
328
+ provider?: string;
329
+ options?: FetchOptions;
330
+ }): Promise<ApiResponse<PickupStore[]>>;
331
+ /**
332
+ * Create shipment for an order via RedX API
333
+ * POST /logistics/shipments
334
+ *
335
+ * This creates a parcel in RedX and updates the order with tracking info.
336
+ *
337
+ * @example
338
+ * // Basic: Create shipment with default pickup store
339
+ * const shipment = await logisticsApi.createShipment({
340
+ * token,
341
+ * data: { orderId: order._id },
342
+ * });
343
+ *
344
+ * @example
345
+ * // With specific pickup store (from getPickupStores)
346
+ * const { data: stores } = await logisticsApi.getPickupStores({ token });
347
+ * const shipment = await logisticsApi.createShipment({
348
+ * token,
349
+ * data: {
350
+ * orderId: order._id,
351
+ * pickupStoreId: stores[0].id, // Select pickup location
352
+ * weight: 500, // Parcel weight in grams
353
+ * instructions: 'Handle with care',
354
+ * },
355
+ * });
356
+ *
357
+ * // Response includes tracking ID
358
+ * console.log(`Tracking: ${shipment.data.trackingId}`);
359
+ */
360
+ createShipment({ token, data, options, }: {
361
+ token: string;
362
+ data: CreateShipmentPayload;
363
+ options?: FetchOptions;
364
+ }): Promise<ApiResponse<Shipment>>;
365
+ /**
366
+ * Get shipment by ID
367
+ * GET /logistics/shipments/:id
368
+ */
369
+ getShipment({ token, id, options, }: {
370
+ token: string;
371
+ id: string;
372
+ options?: FetchOptions;
373
+ }): Promise<ApiResponse<Shipment>>;
374
+ /**
375
+ * Track shipment (fetch latest from provider)
376
+ * GET /logistics/shipments/:id/track
377
+ */
378
+ trackShipment({ token, id, options, }: {
379
+ token: string;
380
+ id: string;
381
+ options?: FetchOptions;
382
+ }): Promise<ApiResponse<TrackingResult>>;
383
+ /**
384
+ * Update shipment status manually
385
+ * PATCH /logistics/shipments/:id/status
386
+ */
387
+ updateShipmentStatus({ token, id, data, options, }: {
388
+ token: string;
389
+ id: string;
390
+ data: UpdateShipmentStatusPayload;
391
+ options?: FetchOptions;
392
+ }): Promise<ApiResponse<Shipment>>;
393
+ /**
394
+ * Cancel shipment
395
+ * POST /logistics/shipments/:id/cancel
396
+ */
397
+ cancelShipment({ token, id, data, options, }: {
398
+ token: string;
399
+ id: string;
400
+ data?: CancelShipmentPayload;
401
+ options?: FetchOptions;
402
+ }): Promise<ApiResponse<Shipment>>;
403
+ /**
404
+ * Get circuit breaker status for all providers
405
+ * GET /logistics/health/circuit-status
406
+ */
407
+ getCircuitStatus({ token, options, }: {
408
+ token: string;
409
+ options?: FetchOptions;
410
+ }): Promise<ApiResponse<Record<string, {
411
+ state: string;
412
+ failureCount: number;
413
+ }>>>;
414
+ /**
415
+ * Reset circuit breaker for a provider
416
+ * POST /logistics/health/circuit-reset/:provider
417
+ */
418
+ resetProviderCircuit({ token, provider, options, }: {
419
+ token: string;
420
+ provider: string;
421
+ options?: FetchOptions;
422
+ }): Promise<ApiResponse<{
423
+ message: string;
424
+ }>>;
425
+ }
426
+ declare const logisticsApi: LogisticsApi;
427
+
428
+ export { type Area as A, type CreateShipmentPayload as C, type Division as D, LogisticsApi as L, type ProviderName as P, type ShipmentStatus as S, type TrackingData as T, type UpdateShipmentStatusPayload as U, type ProviderAreaIds as a, type District as b, type LogisticsProvider as c, type ProviderCharges as d, type ShipmentParcel as e, type ShipmentPickup as f, type ShipmentDelivery as g, type ShipmentCashCollection as h, type ShipmentTimelineEvent as i, type Shipment as j, type TrackingResult as k, logisticsApi as l, type PickupStore as m, type ProviderConfig as n, type LogisticsConfig as o, type CancelShipmentPayload as p, type CalculateChargeParams as q, type DeliveryFeeSource as r, type PickupBranchInfo as s, type CheckoutSettings as t, type DeliveryMethod as u, type DeliveryOption as v };