@classytic/commerce-sdk 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +164 -0
  3. package/dist/adjustment-MNH3AT6S.js +5 -0
  4. package/dist/adjustment-MNH3AT6S.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 +571 -0
  14. package/dist/catalog/index.js +9 -0
  15. package/dist/catalog/index.js.map +1 -0
  16. package/dist/chunk-24FDD6UR.js +75 -0
  17. package/dist/chunk-24FDD6UR.js.map +1 -0
  18. package/dist/chunk-2TF7QNYV.js +159 -0
  19. package/dist/chunk-2TF7QNYV.js.map +1 -0
  20. package/dist/chunk-2YAZ5WG6.js +479 -0
  21. package/dist/chunk-2YAZ5WG6.js.map +1 -0
  22. package/dist/chunk-36NLLAVH.js +177 -0
  23. package/dist/chunk-36NLLAVH.js.map +1 -0
  24. package/dist/chunk-3OYSJB3P.js +126 -0
  25. package/dist/chunk-3OYSJB3P.js.map +1 -0
  26. package/dist/chunk-5E57JODA.js +135 -0
  27. package/dist/chunk-5E57JODA.js.map +1 -0
  28. package/dist/chunk-7LZCW4VF.js +13 -0
  29. package/dist/chunk-7LZCW4VF.js.map +1 -0
  30. package/dist/chunk-ANYGZ6O5.js +830 -0
  31. package/dist/chunk-ANYGZ6O5.js.map +1 -0
  32. package/dist/chunk-AQAISI4F.js +183 -0
  33. package/dist/chunk-AQAISI4F.js.map +1 -0
  34. package/dist/chunk-B6MPVOV7.js +328 -0
  35. package/dist/chunk-B6MPVOV7.js.map +1 -0
  36. package/dist/chunk-CILP56G2.js +94 -0
  37. package/dist/chunk-CILP56G2.js.map +1 -0
  38. package/dist/chunk-ERQ52WHY.js +534 -0
  39. package/dist/chunk-ERQ52WHY.js.map +1 -0
  40. package/dist/chunk-FOTUJPM4.js +640 -0
  41. package/dist/chunk-FOTUJPM4.js.map +1 -0
  42. package/dist/chunk-IHCBBLLW.js +198 -0
  43. package/dist/chunk-IHCBBLLW.js.map +1 -0
  44. package/dist/chunk-J4JBQET2.js +76 -0
  45. package/dist/chunk-J4JBQET2.js.map +1 -0
  46. package/dist/chunk-L4OEI4VZ.js +123 -0
  47. package/dist/chunk-L4OEI4VZ.js.map +1 -0
  48. package/dist/chunk-LRV7MWWX.js +616 -0
  49. package/dist/chunk-LRV7MWWX.js.map +1 -0
  50. package/dist/chunk-N43VE355.js +126 -0
  51. package/dist/chunk-N43VE355.js.map +1 -0
  52. package/dist/chunk-PYYLHUV6.js +3 -0
  53. package/dist/chunk-PYYLHUV6.js.map +1 -0
  54. package/dist/chunk-QCTXAMLA.js +261 -0
  55. package/dist/chunk-QCTXAMLA.js.map +1 -0
  56. package/dist/chunk-RIKAPJNG.js +40 -0
  57. package/dist/chunk-RIKAPJNG.js.map +1 -0
  58. package/dist/chunk-U3XT35GZ.js +202 -0
  59. package/dist/chunk-U3XT35GZ.js.map +1 -0
  60. package/dist/chunk-W22WB3WZ.js +148 -0
  61. package/dist/chunk-W22WB3WZ.js.map +1 -0
  62. package/dist/chunk-WTIJMKML.js +27 -0
  63. package/dist/chunk-WTIJMKML.js.map +1 -0
  64. package/dist/chunk-X2CQFJPR.js +75 -0
  65. package/dist/chunk-X2CQFJPR.js.map +1 -0
  66. package/dist/chunk-YYFKLOKO.js +769 -0
  67. package/dist/chunk-YYFKLOKO.js.map +1 -0
  68. package/dist/client-Cs7E_usr.d.ts +113 -0
  69. package/dist/content/index.d.ts +309 -0
  70. package/dist/content/index.js +6 -0
  71. package/dist/content/index.js.map +1 -0
  72. package/dist/core/index.d.ts +166 -0
  73. package/dist/core/index.js +5 -0
  74. package/dist/core/index.js.map +1 -0
  75. package/dist/core/react.d.ts +107 -0
  76. package/dist/core/react.js +5 -0
  77. package/dist/core/react.js.map +1 -0
  78. package/dist/coupon-BZSZ0y3n.d.ts +129 -0
  79. package/dist/coupon-CDzL4bJG.d.ts +655 -0
  80. package/dist/crud.factory-DyKaPHcU.d.ts +181 -0
  81. package/dist/finance/index.d.ts +81 -0
  82. package/dist/finance/index.js +5 -0
  83. package/dist/finance/index.js.map +1 -0
  84. package/dist/finance-BJdfKRw0.d.ts +135 -0
  85. package/dist/index.d.ts +32 -0
  86. package/dist/index.js +29 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/inventory/index.d.ts +512 -0
  89. package/dist/inventory/index.js +16 -0
  90. package/dist/inventory/index.js.map +1 -0
  91. package/dist/inventory-B5pssqRx.d.ts +748 -0
  92. package/dist/logistics/index.d.ts +248 -0
  93. package/dist/logistics/index.js +7 -0
  94. package/dist/logistics/index.js.map +1 -0
  95. package/dist/logistics-CrpKadKE.d.ts +410 -0
  96. package/dist/media-CNLJK93J.d.ts +721 -0
  97. package/dist/movement-R3CERFAM.js +5 -0
  98. package/dist/movement-R3CERFAM.js.map +1 -0
  99. package/dist/order-B3dCvHgK.d.ts +360 -0
  100. package/dist/payment-BRboLqvU.d.ts +127 -0
  101. package/dist/payments/index.d.ts +55 -0
  102. package/dist/payments/index.js +6 -0
  103. package/dist/payments/index.js.map +1 -0
  104. package/dist/platform/index.d.ts +645 -0
  105. package/dist/platform/index.js +8 -0
  106. package/dist/platform/index.js.map +1 -0
  107. package/dist/pos-BCqkx2-K.d.ts +527 -0
  108. package/dist/product-p09zXkXB.d.ts +260 -0
  109. package/dist/purchase-54PER2PY.js +5 -0
  110. package/dist/purchase-54PER2PY.js.map +1 -0
  111. package/dist/request-MP6NV5ZE.js +5 -0
  112. package/dist/request-MP6NV5ZE.js.map +1 -0
  113. package/dist/sales/index.d.ts +587 -0
  114. package/dist/sales/index.js +9 -0
  115. package/dist/sales/index.js.map +1 -0
  116. package/dist/server.d.ts +23 -0
  117. package/dist/server.js +37 -0
  118. package/dist/server.js.map +1 -0
  119. package/dist/size-guide-DgjzjM5P.d.ts +554 -0
  120. package/dist/stock-2LP4HJSB.js +5 -0
  121. package/dist/stock-2LP4HJSB.js.map +1 -0
  122. package/dist/stock-CfrU5_Wr.d.ts +632 -0
  123. package/dist/supplier-BWJTRZ5Z.js +5 -0
  124. package/dist/supplier-BWJTRZ5Z.js.map +1 -0
  125. package/dist/transaction/index.d.ts +104 -0
  126. package/dist/transaction/index.js +8 -0
  127. package/dist/transaction/index.js.map +1 -0
  128. package/dist/transaction-Bf6WjYCh.d.ts +84 -0
  129. package/dist/transaction-dL3WW-er.d.ts +442 -0
  130. package/dist/transfer-4XSS6HWT.js +5 -0
  131. package/dist/transfer-4XSS6HWT.js.map +1 -0
  132. package/dist/user-data-DdLjAGwO.d.ts +132 -0
  133. package/package.json +147 -0
@@ -0,0 +1,587 @@
1
+ import { C as Cart, a as CartItem, A as AddCartItemPayload, U as UpdateCartItemPayload, f as Customer, j as CustomerPayload } from '../pos-BCqkx2-K.js';
2
+ export { c as AddToCartPayload, e as CartItemVariation, d as CartResponse, b as CartSummary, g as CustomerAddress, s as CustomerApi, n as CustomerGender, l as CustomerListResponse, i as CustomerMembership, k as CustomerQueryParams, m as CustomerResponse, h as CustomerStats, o as CustomerTier, P as PopulatedCartItem, R as RemoveCartItemPayload, p as cartApi, r as customerApi, q as orderApi, q as orderApiDefault, t as posApi, t as posApiDefault } from '../pos-BCqkx2-K.js';
3
+ import { b as Order, l as CreateOrderPayload, F as FulfillOrderPayload, o as RequestShippingPayload, h as OrderShipping, p as UpdateShippingPayload } from '../order-B3dCvHgK.js';
4
+ export { m as CancelOrderPayload, n as CancelRequestPayload, C as CancellationRequest, e as OrderAddress, d as OrderDelivery, c as OrderItem, j as OrderParcel, g as OrderPayment, i as OrderShippingHistory, O as OrderStatus, f as OrderVat, k as PaymentData, P as PaymentStatus, R as RefundOrderPayload, a as ShippingProvider, S as ShippingStatus, U as UpdateStatusPayload } from '../order-B3dCvHgK.js';
5
+ import { P as PosProduct, a as PosProductsResponse, g as PosLookupResponse, q as PosReceiptResponse, l as PosOrderPayload, ac as CreateAdjustmentPayload, ad as BulkAdjustmentPayload } from '../inventory-B5pssqRx.js';
6
+ export { B as BranchStock, t as PaymentOption, u as PaymentState, s as PosCartItem, k as PosCustomer, f as PosLookupData, e as PosLookupProduct, h as PosLookupResult, i as PosOrderItem, j as PosPayment, m as PosPaymentMethod, c as PosProductsBranch, d as PosProductsParams, b as PosProductsSummary, r as PosReceipt, p as PosReceiptData, n as PosReceiptItem, o as PosReceiptVat, S as SplitPaymentEntry, V as VariantStock } from '../inventory-B5pssqRx.js';
7
+ import { b as ProductVariant } from '../product-p09zXkXB.js';
8
+ import { k as QueryKeys, b as CrudHooksReturn, L as ListOptions, l as ListQueryResult, D as DetailOptions, m as DetailQueryResult, d as CrudActions, N as NavigateFn } from '../crud.factory-DyKaPHcU.js';
9
+ import * as _tanstack_react_query from '@tanstack/react-query';
10
+ import '../api-factory-B_h4RKBm.js';
11
+
12
+ declare const CART_KEYS: QueryKeys;
13
+ /**
14
+ * Calculate unit price for a cart item
15
+ * Handles both simple products and variant products
16
+ */
17
+ declare function calculateItemPrice(item: CartItem): number;
18
+ /**
19
+ * Calculate total for a cart item
20
+ */
21
+ declare function calculateItemTotal(item: CartItem): number;
22
+ /**
23
+ * Calculate cart subtotal
24
+ */
25
+ declare function calculateCartSubtotal(items: CartItem[]): number;
26
+ /**
27
+ * Get total item count in cart
28
+ */
29
+ declare function getCartItemCount(items: CartItem[]): number;
30
+ /**
31
+ * Get variant details from a cart item
32
+ */
33
+ declare function getCartItemVariant(item: CartItem): ProductVariant | null;
34
+ /**
35
+ * Format variant attributes for display
36
+ * @example "Size: M, Color: Red"
37
+ */
38
+ declare function formatVariantAttributes(attributes?: Record<string, string> | null): string;
39
+ interface UseCartReturn {
40
+ cart: Cart | null | undefined;
41
+ items: CartItem[];
42
+ itemCount: number;
43
+ subtotal: number;
44
+ isLoading: boolean;
45
+ isFetching: boolean;
46
+ isUpdating: boolean;
47
+ error: Error | null;
48
+ addToCart: (data: AddCartItemPayload) => void;
49
+ addToCartAsync: (data: AddCartItemPayload) => Promise<Cart>;
50
+ updateCartItem: (data: UpdateCartItemPayload) => void;
51
+ updateCartItemAsync: (data: UpdateCartItemPayload) => Promise<Cart>;
52
+ removeCartItem: (itemId: string) => void;
53
+ removeCartItemAsync: (itemId: string) => Promise<Cart>;
54
+ clearCart: () => void;
55
+ clearCartAsync: () => Promise<Cart>;
56
+ refetch: () => void;
57
+ getItemPrice: typeof calculateItemPrice;
58
+ }
59
+ interface UseCartCountReturn {
60
+ count: number;
61
+ isLoading: boolean;
62
+ }
63
+ interface CartOptions {
64
+ enabled?: boolean;
65
+ staleTime?: number;
66
+ gcTime?: number;
67
+ }
68
+ /**
69
+ * Full cart hook with optimistic updates
70
+ *
71
+ * @example
72
+ * ```tsx
73
+ * function CartPage() {
74
+ * const {
75
+ * items,
76
+ * itemCount,
77
+ * subtotal,
78
+ * addToCart,
79
+ * updateCartItem,
80
+ * removeCartItem,
81
+ * clearCart,
82
+ * isLoading,
83
+ * isUpdating,
84
+ * } = useCart(token);
85
+ *
86
+ * // Add item
87
+ * addToCart({ productId: "123", quantity: 2 });
88
+ *
89
+ * // Add variant item
90
+ * addToCart({ productId: "123", variantSku: "SIZE-M", quantity: 1 });
91
+ *
92
+ * // Update quantity
93
+ * updateCartItem({ itemId: "item_id", quantity: 3 });
94
+ *
95
+ * // Remove item
96
+ * removeCartItem("item_id");
97
+ *
98
+ * // Clear cart
99
+ * clearCart();
100
+ * }
101
+ * ```
102
+ */
103
+ declare function useCart(token: string | null | undefined, options?: CartOptions): UseCartReturn;
104
+ /**
105
+ * Lightweight hook for cart count (header badge)
106
+ *
107
+ * @example
108
+ * ```tsx
109
+ * function CartBadge() {
110
+ * const { count, isLoading } = useCartCount(token);
111
+ * return <Badge>{isLoading ? "..." : count}</Badge>;
112
+ * }
113
+ * ```
114
+ */
115
+ declare function useCartCount(token: string | null | undefined, options?: CartOptions): UseCartCountReturn;
116
+
117
+ /**
118
+ * Order hooks using createCrudHooks factory
119
+ *
120
+ * Provides:
121
+ * - useOrders: List orders with filtering/pagination
122
+ * - useOrderDetail: Get single order
123
+ * - useOrderActions: Create, update, delete mutations
124
+ * - useOrderNavigation: Navigation between orders
125
+ */
126
+ declare const orderHooks: CrudHooksReturn<Order, CreateOrderPayload, Partial<Order>>;
127
+ declare const ORDER_KEYS: {
128
+ all: readonly ["orders"];
129
+ lists: () => readonly ["orders", "list"];
130
+ list: (params?: Record<string, unknown>) => readonly ["orders", "list", Record<string, unknown> | undefined];
131
+ details: () => readonly ["orders", "detail"];
132
+ detail: (id: string) => readonly ["orders", "detail", string];
133
+ myOrders: (params?: Record<string, unknown>) => readonly ["orders", "my", Record<string, unknown> | undefined];
134
+ myDetail: (id: string) => readonly ["orders", "my", "detail", string];
135
+ };
136
+ declare const useOrders: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Order>;
137
+ declare const useOrderDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Order>;
138
+ declare const useOrderActions: () => CrudActions<CreateOrderPayload, Partial<Order>>;
139
+ declare const useOrderNavigation: () => NavigateFn<Order>;
140
+ interface QueryOptions$2 {
141
+ enabled?: boolean;
142
+ staleTime?: number;
143
+ }
144
+ interface UseMyOrdersReturn {
145
+ orders: Order[];
146
+ total: number;
147
+ page: number;
148
+ limit: number;
149
+ hasMore: boolean;
150
+ isLoading: boolean;
151
+ isFetching: boolean;
152
+ error: Error | null;
153
+ refetch: () => void;
154
+ }
155
+ interface UseCustomerOrderActionsReturn {
156
+ checkout: (data: CreateOrderPayload) => Promise<Order>;
157
+ isCheckingOut: boolean;
158
+ requestCancel: (params: {
159
+ orderId: string;
160
+ reason?: string;
161
+ }) => Promise<Order>;
162
+ isRequestingCancel: boolean;
163
+ isLoading: boolean;
164
+ }
165
+ interface UseAdminOrderActionsReturn {
166
+ updateStatus: (params: {
167
+ orderId: string;
168
+ status: string;
169
+ note?: string;
170
+ }) => Promise<Order>;
171
+ isUpdatingStatus: boolean;
172
+ fulfillOrder: (params: FulfillOrderPayload & {
173
+ orderId: string;
174
+ }) => Promise<Order>;
175
+ isFulfilling: boolean;
176
+ refundOrder: (params: {
177
+ orderId: string;
178
+ amount?: number;
179
+ reason?: string;
180
+ }) => Promise<Order>;
181
+ isRefunding: boolean;
182
+ cancelOrder: (params: {
183
+ orderId: string;
184
+ reason?: string;
185
+ refund?: boolean;
186
+ }) => Promise<Order>;
187
+ isCancelling: boolean;
188
+ requestShipping: (params: RequestShippingPayload & {
189
+ orderId: string;
190
+ }) => Promise<OrderShipping>;
191
+ isRequestingShipping: boolean;
192
+ updateShipping: (params: UpdateShippingPayload & {
193
+ orderId: string;
194
+ }) => Promise<OrderShipping>;
195
+ isUpdatingShipping: boolean;
196
+ isLoading: boolean;
197
+ }
198
+ /**
199
+ * Get customer's own orders
200
+ *
201
+ * @param token - Auth token
202
+ * @param params - Query params { page, limit, status, sort }
203
+ * @param options - Query options
204
+ *
205
+ * @example
206
+ * ```tsx
207
+ * function MyOrdersPage() {
208
+ * const { orders, isLoading, hasMore } = useMyOrders(token, { limit: 10 });
209
+ *
210
+ * return (
211
+ * <OrderList orders={orders} loading={isLoading} />
212
+ * );
213
+ * }
214
+ * ```
215
+ */
216
+ declare function useMyOrders(token: string, params?: Record<string, unknown>, options?: QueryOptions$2): UseMyOrdersReturn;
217
+ /**
218
+ * Get customer's own order detail
219
+ *
220
+ * @param token - Auth token
221
+ * @param orderId - Order ID
222
+ * @param options - Query options
223
+ *
224
+ * @example
225
+ * ```tsx
226
+ * function OrderDetailPage({ orderId }) {
227
+ * const { data: order, isLoading } = useMyOrderDetail(token, orderId);
228
+ *
229
+ * if (isLoading) return <Skeleton />;
230
+ * return <OrderDetail order={order} />;
231
+ * }
232
+ * ```
233
+ */
234
+ declare function useMyOrderDetail(token: string, orderId: string, options?: QueryOptions$2): _tanstack_react_query.UseQueryResult<Order, Error>;
235
+ /**
236
+ * Customer order actions (checkout, request cancellation)
237
+ *
238
+ * @param token - Customer auth token
239
+ *
240
+ * @example
241
+ * ```tsx
242
+ * function CheckoutButton({ cart }) {
243
+ * const { checkout, isCheckingOut } = useCustomerOrderActions(token);
244
+ *
245
+ * const handleCheckout = async () => {
246
+ * const order = await checkout({
247
+ * items: cart.items,
248
+ * shipping: shippingAddress,
249
+ * payment: { method: 'bkash' },
250
+ * });
251
+ * router.push(`/orders/${order._id}`);
252
+ * };
253
+ *
254
+ * return (
255
+ * <Button onClick={handleCheckout} disabled={isCheckingOut}>
256
+ * {isCheckingOut ? 'Processing...' : 'Place Order'}
257
+ * </Button>
258
+ * );
259
+ * }
260
+ * ```
261
+ */
262
+ declare function useCustomerOrderActions(token: string): UseCustomerOrderActionsReturn;
263
+ /**
264
+ * Admin order actions (status, fulfill, refund, cancel, shipping)
265
+ *
266
+ * @param token - Admin auth token
267
+ *
268
+ * @example
269
+ * ```tsx
270
+ * function OrderActions({ order }) {
271
+ * const {
272
+ * updateStatus,
273
+ * fulfillOrder,
274
+ * cancelOrder,
275
+ * isLoading,
276
+ * } = useAdminOrderActions(token);
277
+ *
278
+ * return (
279
+ * <>
280
+ * <Button onClick={() => updateStatus({ orderId: order._id, status: 'processing' })}>
281
+ * Mark Processing
282
+ * </Button>
283
+ * <Button onClick={() => fulfillOrder({ orderId: order._id, branchId: 'branch_123' })}>
284
+ * Fulfill Order
285
+ * </Button>
286
+ * </>
287
+ * );
288
+ * }
289
+ * ```
290
+ */
291
+ declare function useAdminOrderActions(token: string): UseAdminOrderActionsReturn;
292
+
293
+ interface QueryOptions$1 {
294
+ enabled?: boolean;
295
+ staleTime?: number;
296
+ }
297
+ type MembershipAction = "enroll" | "deactivate" | "reactivate" | "adjust";
298
+ type PointsType = "bonus" | "correction" | "manual_redemption" | "redemption" | "expiry";
299
+ interface MembershipActionParams {
300
+ id: string;
301
+ action: MembershipAction;
302
+ points?: number;
303
+ reason?: string;
304
+ type?: PointsType;
305
+ }
306
+ interface UseCustomerMembershipReturn {
307
+ membershipAction: (params: MembershipActionParams) => Promise<Customer>;
308
+ isPending: boolean;
309
+ }
310
+ /**
311
+ * Customer hooks using createCrudHooks factory
312
+ *
313
+ * Provides:
314
+ * - useCustomers: List customers with filtering/pagination
315
+ * - useCustomerDetail: Get single customer
316
+ * - useCustomerActions: Create, update, delete mutations
317
+ * - useCustomerNavigation: Navigation between customers
318
+ */
319
+ declare const customerHooks: CrudHooksReturn<Customer, CustomerPayload, CustomerPayload>;
320
+ declare const CUSTOMER_KEYS: QueryKeys;
321
+ declare const useCustomers: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Customer>;
322
+ declare const useCustomerDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Customer>;
323
+ declare const useCustomerActions: () => CrudActions<CustomerPayload, CustomerPayload>;
324
+ declare const useCustomerNavigation: () => NavigateFn<Customer>;
325
+ /**
326
+ * Get current user's customer profile
327
+ *
328
+ * @param token - Auth token
329
+ * @param options - Query options
330
+ *
331
+ * @example
332
+ * ```tsx
333
+ * function ProfilePage() {
334
+ * const { data: customer, isLoading } = useCurrentCustomer(token);
335
+ *
336
+ * if (isLoading) return <Skeleton />;
337
+ * return (
338
+ * <div>
339
+ * <h1>{customer?.name}</h1>
340
+ * <p>Points: {customer?.membership?.points || 0}</p>
341
+ * </div>
342
+ * );
343
+ * }
344
+ * ```
345
+ */
346
+ declare function useCurrentCustomer(token: string, options?: QueryOptions$1): _tanstack_react_query.UseQueryResult<Customer, Error>;
347
+ /**
348
+ * Customer membership actions (enroll, deactivate, reactivate, adjust points)
349
+ *
350
+ * @param token - Admin auth token
351
+ *
352
+ * @example
353
+ * ```tsx
354
+ * function MembershipManager({ customer }) {
355
+ * const { membershipAction, isPending } = useCustomerMembership(token);
356
+ *
357
+ * const handleEnroll = async () => {
358
+ * await membershipAction({
359
+ * id: customer._id,
360
+ * action: 'enroll',
361
+ * });
362
+ * };
363
+ *
364
+ * const handleAdjustPoints = async (points: number) => {
365
+ * await membershipAction({
366
+ * id: customer._id,
367
+ * action: 'adjust',
368
+ * points,
369
+ * type: 'bonus',
370
+ * reason: 'Birthday bonus',
371
+ * });
372
+ * };
373
+ *
374
+ * return (
375
+ * <Button onClick={handleEnroll} disabled={isPending}>
376
+ * Enroll in Membership
377
+ * </Button>
378
+ * );
379
+ * }
380
+ * ```
381
+ */
382
+ declare function useCustomerMembership(token: string): UseCustomerMembershipReturn;
383
+
384
+ declare const POS_KEYS: {
385
+ all: readonly ["pos"];
386
+ products: (branchId?: string) => readonly ["pos", "products", string | undefined];
387
+ productsList: (branchId?: string, params?: Record<string, unknown>) => readonly ["pos", "products", string | undefined, Record<string, unknown> | undefined];
388
+ lookup: (code: string, branchId?: string) => readonly ["pos", "lookup", string, string | undefined];
389
+ orders: () => readonly ["pos", "orders"];
390
+ receipt: (orderId: string) => readonly ["pos", "orders", string, "receipt"];
391
+ };
392
+ interface PosProductFilters {
393
+ category?: string;
394
+ search?: string;
395
+ inStockOnly?: boolean;
396
+ lowStockOnly?: boolean;
397
+ after?: string;
398
+ limit?: number;
399
+ sort?: string;
400
+ [key: string]: unknown;
401
+ }
402
+ interface UsePosProductsReturn {
403
+ products: PosProduct[];
404
+ summary: PosProductsResponse["summary"];
405
+ branch: PosProductsResponse["branch"];
406
+ hasMore: boolean;
407
+ nextCursor: string | null;
408
+ isLoading: boolean;
409
+ isFetching: boolean;
410
+ error: Error | null;
411
+ refetch: () => void;
412
+ }
413
+ interface QueryOptions {
414
+ enabled?: boolean;
415
+ }
416
+ /**
417
+ * Fetch POS products with branch-specific stock
418
+ *
419
+ * @param token - Auth token
420
+ * @param branchId - Branch to get stock for
421
+ * @param filters - Product filters
422
+ * @param options - Query options
423
+ *
424
+ * @example
425
+ * ```tsx
426
+ * function ProductGrid({ branchId }) {
427
+ * const { products, isLoading, summary } = usePosProducts(token, branchId, {
428
+ * category: 'electronics',
429
+ * inStockOnly: true,
430
+ * });
431
+ *
432
+ * return (
433
+ * <Grid>
434
+ * {products.map(product => (
435
+ * <ProductCard key={product._id} product={product} />
436
+ * ))}
437
+ * </Grid>
438
+ * );
439
+ * }
440
+ * ```
441
+ */
442
+ declare function usePosProducts(token: string, branchId: string | undefined, filters?: PosProductFilters, options?: QueryOptions): UsePosProductsReturn;
443
+ /**
444
+ * Lookup product by barcode/SKU (query-based)
445
+ *
446
+ * @param token - Auth token
447
+ * @param code - Barcode or SKU to lookup
448
+ * @param branchId - Branch for stock info
449
+ * @param options - Query options
450
+ */
451
+ declare function usePosLookup(token: string, code: string, branchId?: string, options?: QueryOptions): _tanstack_react_query.UseQueryResult<PosLookupResponse, Error>;
452
+ /**
453
+ * Lookup product by barcode/SKU (mutation-based)
454
+ * Preferred for "scan -> act" flows
455
+ *
456
+ * @param token - Auth token
457
+ *
458
+ * @example
459
+ * ```tsx
460
+ * function BarcodeScanner() {
461
+ * const { lookup, isLooking } = usePosLookupMutation(token);
462
+ *
463
+ * const handleScan = async (code: string) => {
464
+ * const result = await lookup({ code, branchId });
465
+ * if (result) addToCart(result.data);
466
+ * };
467
+ * }
468
+ * ```
469
+ */
470
+ declare function usePosLookupMutation(token: string): {
471
+ lookup: _tanstack_react_query.UseMutateAsyncFunction<PosLookupResponse, Error, {
472
+ code: string;
473
+ branchId?: string;
474
+ }, unknown>;
475
+ isLooking: boolean;
476
+ error: Error | null;
477
+ };
478
+ /**
479
+ * Get receipt for an order
480
+ *
481
+ * @param token - Auth token
482
+ * @param orderId - Order ID
483
+ * @param options - Query options
484
+ */
485
+ declare function usePosReceipt(token: string, orderId: string, options?: QueryOptions): _tanstack_react_query.UseQueryResult<PosReceiptResponse, Error>;
486
+ interface UsePosOrdersReturn {
487
+ createOrder: (data: PosOrderPayload) => Promise<unknown>;
488
+ isCreatingOrder: boolean;
489
+ }
490
+ /**
491
+ * POS order operations
492
+ *
493
+ * @param token - Auth token
494
+ *
495
+ * @example
496
+ * ```tsx
497
+ * function Checkout({ cart, branchId }) {
498
+ * const { createOrder, isCreatingOrder } = usePosOrders(token);
499
+ *
500
+ * const handleCheckout = async () => {
501
+ * const order = await createOrder({
502
+ * items: cart.items,
503
+ * branchId,
504
+ * payment: { method: 'cash' },
505
+ * });
506
+ * // Handle success (show receipt, clear cart, etc.)
507
+ * };
508
+ * }
509
+ * ```
510
+ */
511
+ declare function usePosOrders(token: string): UsePosOrdersReturn;
512
+ interface UsePosStockActionsReturn {
513
+ adjustStock: (data: CreateAdjustmentPayload) => Promise<unknown>;
514
+ isAdjusting: boolean;
515
+ setStock: (params: {
516
+ productId: string;
517
+ quantity: number;
518
+ branchId?: string;
519
+ variantSku?: string;
520
+ reason?: string;
521
+ }) => Promise<unknown>;
522
+ isSetting: boolean;
523
+ bulkAdjust: (data: BulkAdjustmentPayload) => Promise<unknown>;
524
+ isBulkAdjusting: boolean;
525
+ isLoading: boolean;
526
+ }
527
+ /**
528
+ * POS stock adjustment actions
529
+ *
530
+ * @param token - Auth token
531
+ * @param branchId - Branch for cache invalidation
532
+ *
533
+ * @example
534
+ * ```tsx
535
+ * function StockAdjuster({ product, branchId }) {
536
+ * const { setStock, isSetting } = usePosStockActions(token, branchId);
537
+ *
538
+ * const handleSetStock = async (newQuantity: number) => {
539
+ * await setStock({
540
+ * productId: product._id,
541
+ * quantity: newQuantity,
542
+ * reason: 'Inventory count',
543
+ * });
544
+ * };
545
+ * }
546
+ * ```
547
+ */
548
+ declare function usePosStockActions(token: string, branchId?: string): UsePosStockActionsReturn;
549
+ /**
550
+ * Generate idempotency key for POS orders
551
+ * Format: pos_{terminal}_{timestamp}_{counter}
552
+ */
553
+ declare function generateIdempotencyKey(terminalId?: string): string;
554
+ /**
555
+ * Calculate price for variant product
556
+ */
557
+ declare function calculateVariantPrice(basePrice: number, priceModifier?: number): number;
558
+ /**
559
+ * Format variant attributes for display
560
+ */
561
+ declare function formatVariantLabel(attributes?: Record<string, string>): string;
562
+ /**
563
+ * Check if product has variants
564
+ */
565
+ declare function isVariantProduct(product: PosProduct): boolean;
566
+ /**
567
+ * Get available (active) variants for a product
568
+ */
569
+ declare function getAvailableVariants(product: PosProduct): ProductVariant[];
570
+ /**
571
+ * Find variant by SKU
572
+ */
573
+ declare function findVariantBySku(product: PosProduct, sku: string): ProductVariant | null;
574
+ /**
575
+ * Get variant stock for branch
576
+ */
577
+ declare function getVariantStock(product: PosProduct, variantSku: string): number;
578
+ /**
579
+ * Check if product/variant is in stock
580
+ */
581
+ declare function isInStock(product: PosProduct, variantSku?: string): boolean;
582
+ /**
583
+ * Get product image URL (thumbnail preferred)
584
+ */
585
+ declare function getPosProductImage(product: PosProduct): string;
586
+
587
+ export { AddCartItemPayload, CART_KEYS, CUSTOMER_KEYS, Cart, CartItem, type CartOptions, CreateOrderPayload, Customer, CustomerPayload, FulfillOrderPayload, type MembershipActionParams, ORDER_KEYS, Order, OrderShipping, POS_KEYS, PosLookupResponse, PosOrderPayload, PosProduct, type PosProductFilters, PosProductsResponse, PosReceiptResponse, RequestShippingPayload, UpdateCartItemPayload, UpdateShippingPayload, type UseAdminOrderActionsReturn, type UseCartCountReturn, type UseCartReturn, type UseCustomerMembershipReturn, type UseCustomerOrderActionsReturn, type UseMyOrdersReturn, type UsePosOrdersReturn, type UsePosProductsReturn, type UsePosStockActionsReturn, calculateCartSubtotal, calculateItemPrice, calculateItemTotal, calculateVariantPrice, customerHooks, findVariantBySku, formatVariantAttributes, formatVariantLabel, generateIdempotencyKey, getAvailableVariants, getCartItemCount, getCartItemVariant, getPosProductImage, getVariantStock, isInStock, isVariantProduct, orderHooks, useAdminOrderActions, useCart, useCartCount, useCurrentCustomer, useCustomerActions, useCustomerDetail, useCustomerMembership, useCustomerNavigation, useCustomerOrderActions, useCustomers, useMyOrderDetail, useMyOrders, useOrderActions, useOrderDetail, useOrderNavigation, useOrders, usePosLookup, usePosLookupMutation, usePosOrders, usePosProducts, usePosReceipt, usePosStockActions };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ export { CART_KEYS, CUSTOMER_KEYS, CustomerApi, ORDER_KEYS, OrderStatus, POS_KEYS, PaymentStatus, calculateCartSubtotal, calculateItemPrice, calculateItemTotal, calculateVariantPrice, cartApi, customerApi, customerHooks, findVariantBySku, formatVariantAttributes, formatVariantLabel, generateIdempotencyKey, getAvailableVariants, getCartItemCount, getCartItemVariant, getPosProductImage, getVariantStock, isInStock, isVariantProduct, orderApi, order_default as orderApiDefault, orderHooks, useAdminOrderActions, useCart, useCartCount, useCurrentCustomer, useCustomerActions, useCustomerDetail, useCustomerMembership, useCustomerNavigation, useCustomerOrderActions, useCustomers, useMyOrderDetail, useMyOrders, useOrderActions, useOrderDetail, useOrderNavigation, useOrders, usePosLookup, usePosLookupMutation, usePosOrders, usePosProducts, usePosReceipt, usePosStockActions } from '../chunk-ANYGZ6O5.js';
3
+ export { posApi, pos_default as posApiDefault } from '../chunk-CILP56G2.js';
4
+ import '../chunk-QCTXAMLA.js';
5
+ import '../chunk-B6MPVOV7.js';
6
+ import '../chunk-U3XT35GZ.js';
7
+ import '../chunk-IHCBBLLW.js';
8
+ //# sourceMappingURL=index.js.map
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,23 @@
1
+ import { SDKConfig } from './core/index.js';
2
+ export { configureSDK, getBaseUrl, getSDKConfig, handleApiRequest } from './core/index.js';
3
+ export { a as CommerceSDKClient, C as CommerceSDKConfig, c as createCommerceSDK, i as initCommerceSDK } from './client-Cs7E_usr.js';
4
+ export { a as authApi, d as createUser, f as forgetPassApi, e as getProfile, g as getUser, c as getUserByPhone, l as loginApi, r as registerApi, b as resetPassApi, t as tokenRefreshApi, u as updateUser, v as verifyManagerAuth } from './user-data-DdLjAGwO.js';
5
+ export { c as categoryApi, p as productApi, s as sizeGuideApi } from './size-guide-DgjzjM5P.js';
6
+ export { p as cartApi, r as customerApi, q as orderApi, t as posApi } from './pos-BCqkx2-K.js';
7
+ export { t as transactionApi } from './transaction-Bf6WjYCh.js';
8
+ export { b as branchApi, c as couponApi, p as platformConfigApi, u as userApi } from './coupon-CDzL4bJG.js';
9
+ export { g as getCmsPage, m as mediaApi, u as updateCmsPage } from './media-CNLJK93J.js';
10
+ export { a as adjustmentApi, m as movementApi, p as purchaseApi, r as requestApi, s as stockApi, b as supplierApi, t as transferApi } from './stock-CfrU5_Wr.js';
11
+ export { l as logisticsApi } from './logistics-CrpKadKE.js';
12
+ export { f as financeApi } from './finance-BJdfKRw0.js';
13
+ export { p as paymentApi } from './payment-BRboLqvU.js';
14
+ export { a as analyticsApi } from './analytics-DMcD-o8w.js';
15
+ import './api-factory-B_h4RKBm.js';
16
+ import './product-p09zXkXB.js';
17
+ import './order-B3dCvHgK.js';
18
+ import './inventory-B5pssqRx.js';
19
+ import './transaction-dL3WW-er.js';
20
+
21
+ declare function runWithSDKConfig<T>(config: SDKConfig, fn: () => T): T;
22
+
23
+ export { runWithSDKConfig };
package/dist/server.js ADDED
@@ -0,0 +1,37 @@
1
+ export { createCommerceSDK, initCommerceSDK } from './chunk-J4JBQET2.js';
2
+ export { logisticsApi } from './chunk-2YAZ5WG6.js';
3
+ export { financeApi } from './chunk-N43VE355.js';
4
+ export { transactionApi } from './chunk-AQAISI4F.js';
5
+ export { getCmsPage, mediaApi, updateCmsPage } from './chunk-ERQ52WHY.js';
6
+ export { branchApi, couponApi, platformConfigApi, userApi } from './chunk-YYFKLOKO.js';
7
+ export { paymentApi } from './chunk-5E57JODA.js';
8
+ export { analyticsApi } from './chunk-RIKAPJNG.js';
9
+ export { authApi, createUser, forgetPassApi, getProfile, getUser, getUserByPhone, loginApi, registerApi, resetPassApi, tokenRefreshApi, updateUser, verifyManagerAuth } from './chunk-W22WB3WZ.js';
10
+ export { categoryApi, productApi, sizeGuideApi } from './chunk-FOTUJPM4.js';
11
+ import './chunk-PYYLHUV6.js';
12
+ export { cartApi, customerApi, orderApi } from './chunk-ANYGZ6O5.js';
13
+ import './chunk-LRV7MWWX.js';
14
+ export { purchaseApi } from './chunk-L4OEI4VZ.js';
15
+ export { transferApi } from './chunk-36NLLAVH.js';
16
+ export { requestApi } from './chunk-2TF7QNYV.js';
17
+ export { movementApi } from './chunk-24FDD6UR.js';
18
+ export { adjustmentApi } from './chunk-3OYSJB3P.js';
19
+ export { supplierApi } from './chunk-7LZCW4VF.js';
20
+ export { stockApi } from './chunk-X2CQFJPR.js';
21
+ export { posApi } from './chunk-CILP56G2.js';
22
+ import './chunk-QCTXAMLA.js';
23
+ import './chunk-B6MPVOV7.js';
24
+ import './chunk-U3XT35GZ.js';
25
+ import { setSDKConfigProvider } from './chunk-IHCBBLLW.js';
26
+ export { configureSDK, getBaseUrl, getSDKConfig, handleApiRequest } from './chunk-IHCBBLLW.js';
27
+ import { AsyncLocalStorage } from 'async_hooks';
28
+
29
+ var configStore = new AsyncLocalStorage();
30
+ setSDKConfigProvider(() => configStore.getStore() ?? null);
31
+ function runWithSDKConfig(config, fn) {
32
+ return configStore.run(config, fn);
33
+ }
34
+
35
+ export { runWithSDKConfig };
36
+ //# sourceMappingURL=server.js.map
37
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/server-context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAM,WAAA,GAAc,IAAI,iBAAA,EAA6B;AAErD,oBAAA,CAAqB,MAAM,WAAA,CAAY,QAAA,EAAS,IAAK,IAAI,CAAA;AAElD,SAAS,gBAAA,CAAoB,QAAmB,EAAA,EAAgB;AACrE,EAAA,OAAO,WAAA,CAAY,GAAA,CAAI,MAAA,EAAQ,EAAE,CAAA;AACnC","file":"server.js","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport { setSDKConfigProvider, type SDKConfig } from \"./api-handler\";\n\nconst configStore = new AsyncLocalStorage<SDKConfig>();\n\nsetSDKConfigProvider(() => configStore.getStore() ?? null);\n\nexport function runWithSDKConfig<T>(config: SDKConfig, fn: () => T): T {\n return configStore.run(config, fn);\n}\n"]}