@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,571 @@
1
+ import { d as Category, f as CreateCategoryPayload, U as UpdateCategoryPayload, h as CategoryTreeResponse, e as CategoryTreeNode, m as SizeGuide, n as CreateSizeGuidePayload, o as UpdateSizeGuidePayload } from '../size-guide-DgjzjM5P.js';
2
+ export { C as CategoryApi, j as CategoryDeleteResponse, a as CategoryImage, g as CategoryListResponse, i as CategoryResponse, b as CategorySeo, k as CategorySyncResponse, P as ProductApi, l as SizeDefinition, S as SizeGuideApi, t as SizeGuideDeleteResponse, q as SizeGuideListResponse, r as SizeGuideResponse, c as categoryApi, p as productApi, s as sizeGuideApi } from '../size-guide-DgjzjM5P.js';
3
+ import { A as ApiResponse, P as PaginatedResponse, B as BaseApi } from '../api-factory-B_h4RKBm.js';
4
+ import { e as Product, C as CreateProductPayload, U as UpdateProductPayload, i as ProductSyncStockResponse } from '../product-p09zXkXB.js';
5
+ export { D as Dimensions, h as ProductDeleteResponse, c as ProductDiscount, P as ProductImage, f as ProductListResponse, g as ProductResponse, a as ProductShipping, d as ProductStats, b as ProductVariant, S as StockProjection, V as VariationAttribute } from '../product-p09zXkXB.js';
6
+ import * as _tanstack_react_query from '@tanstack/react-query';
7
+ import { UseQueryOptions } from '@tanstack/react-query';
8
+ import { b as CrudHooksReturn, k as QueryKeys, L as ListOptions, l as ListQueryResult, D as DetailOptions, m as DetailQueryResult, d as CrudActions, N as NavigateFn } from '../crud.factory-DyKaPHcU.js';
9
+
10
+ /**
11
+ * Review Types
12
+ *
13
+ * Product reviews with verified purchase support.
14
+ */
15
+
16
+ type ReviewStatus = "pending" | "approved" | "rejected";
17
+ interface ReviewReply {
18
+ content?: string;
19
+ repliedBy?: string | {
20
+ _id: string;
21
+ name?: string;
22
+ email?: string;
23
+ };
24
+ repliedAt?: string;
25
+ }
26
+ interface Review {
27
+ _id: string;
28
+ user: string | {
29
+ _id: string;
30
+ name?: string;
31
+ email?: string;
32
+ };
33
+ product: string | Product;
34
+ order?: string;
35
+ title?: string;
36
+ rating: number;
37
+ comment?: string;
38
+ helpfulCount: number;
39
+ isVerifiedPurchase: boolean;
40
+ status: ReviewStatus;
41
+ reply?: ReviewReply;
42
+ createdAt: string;
43
+ updatedAt: string;
44
+ }
45
+ interface CreateReviewPayload {
46
+ product: string;
47
+ rating: number;
48
+ title?: string;
49
+ comment?: string;
50
+ }
51
+ interface UpdateReviewPayload {
52
+ rating?: number;
53
+ title?: string;
54
+ comment?: string;
55
+ }
56
+ type ReviewResponse = ApiResponse<Review | null>;
57
+ type ReviewListResponse = PaginatedResponse<Review>;
58
+
59
+ /**
60
+ * Review API Client
61
+ *
62
+ * **Authentication:**
63
+ * - Public: List, Get
64
+ * - User/Admin: Create, Update, Get My Review
65
+ * - Admin: Delete
66
+ *
67
+ * **Base URL:** `/api/v1/reviews`
68
+ */
69
+
70
+ type FetchOptions = {
71
+ cache?: RequestCache;
72
+ revalidate?: number;
73
+ tags?: string[];
74
+ };
75
+ declare class ReviewApi extends BaseApi<Review, CreateReviewPayload, UpdateReviewPayload> {
76
+ constructor(config?: {});
77
+ /**
78
+ * Get current user's review for a product
79
+ * GET /reviews/my/:productId
80
+ *
81
+ * @param token - Auth token (required)
82
+ * @param productId - Product ID
83
+ * @param options - Additional fetch options
84
+ * @returns Review or null
85
+ */
86
+ getMyReview({ token, productId, options, }: {
87
+ token: string;
88
+ productId: string;
89
+ options?: FetchOptions;
90
+ }): Promise<ApiResponse<Review | null>>;
91
+ }
92
+ declare const reviewApi: ReviewApi;
93
+
94
+ /**
95
+ * Product CRUD hooks with optimistic updates
96
+ */
97
+ declare const productHooks: CrudHooksReturn<Product, CreateProductPayload, UpdateProductPayload>;
98
+ declare const PRODUCT_KEYS: QueryKeys;
99
+ declare const useProducts: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Product>;
100
+ declare const useProductDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Product>;
101
+ declare const useProductActions: () => CrudActions<CreateProductPayload, UpdateProductPayload>;
102
+ declare const useProductNavigation: () => NavigateFn<Product>;
103
+ /**
104
+ * Hook to get product by slug
105
+ *
106
+ * @param token - Auth token (optional for public access)
107
+ * @param slug - Product slug
108
+ * @param options - React Query options
109
+ * @returns Query result with product data
110
+ *
111
+ * @example
112
+ * ```tsx
113
+ * function ProductPage({ slug }) {
114
+ * const { data, isLoading } = useProductBySlug(null, slug);
115
+ *
116
+ * if (isLoading) return <Spinner />;
117
+ *
118
+ * return <h1>{data?.data?.name}</h1>;
119
+ * }
120
+ * ```
121
+ */
122
+ declare function useProductBySlug(token: string | null | undefined, slug: string, options?: Omit<UseQueryOptions<ApiResponse<Product>>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<ApiResponse<Product>, Error>;
123
+ interface UseProductRecommendationsReturn {
124
+ recommendations: Product[];
125
+ isLoading: boolean;
126
+ error: Error | null;
127
+ }
128
+ /**
129
+ * Hook to get product recommendations
130
+ *
131
+ * @param productId - Product ID to get recommendations for
132
+ * @param options - React Query options
133
+ * @returns Object with recommendations array, isLoading, and error
134
+ *
135
+ * @example
136
+ * ```tsx
137
+ * function ProductRecommendations({ productId }) {
138
+ * const { recommendations, isLoading } = useProductRecommendations(productId);
139
+ *
140
+ * if (isLoading) return <Spinner />;
141
+ *
142
+ * return (
143
+ * <div>
144
+ * {recommendations.map(product => (
145
+ * <ProductCard key={product._id} product={product} />
146
+ * ))}
147
+ * </div>
148
+ * );
149
+ * }
150
+ * ```
151
+ */
152
+ declare function useProductRecommendations(productId: string, options?: Omit<UseQueryOptions<ApiResponse<Product[]>>, "queryKey" | "queryFn">): UseProductRecommendationsReturn;
153
+ /**
154
+ * Hook to get soft-deleted products (Recycle Bin)
155
+ *
156
+ * @param token - Auth token (required, admin only)
157
+ * @param params - Query parameters for pagination/filtering
158
+ * @param options - React Query options
159
+ * @returns Query result with deleted products
160
+ *
161
+ * @example
162
+ * ```tsx
163
+ * function RecycleBin() {
164
+ * const { data, isLoading } = useDeletedProducts(token, { page: 1, limit: 20 });
165
+ *
166
+ * if (isLoading) return <Spinner />;
167
+ *
168
+ * return (
169
+ * <div>
170
+ * {data?.docs?.map(product => (
171
+ * <DeletedProductRow key={product._id} product={product} />
172
+ * ))}
173
+ * </div>
174
+ * );
175
+ * }
176
+ * ```
177
+ */
178
+ declare function useDeletedProducts(token: string, params?: Record<string, unknown>, options?: Omit<UseQueryOptions<PaginatedResponse<Product>>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PaginatedResponse<Product>, Error>;
179
+ /**
180
+ * Hook to restore a soft-deleted product
181
+ *
182
+ * @param token - Auth token (required, admin only)
183
+ * @returns Mutation result with restore function
184
+ *
185
+ * @example
186
+ * ```tsx
187
+ * function RestoreButton({ productId }) {
188
+ * const { mutate: restore, isPending } = useRestoreProduct(token);
189
+ *
190
+ * return (
191
+ * <Button onClick={() => restore(productId)} disabled={isPending}>
192
+ * Restore Product
193
+ * </Button>
194
+ * );
195
+ * }
196
+ * ```
197
+ */
198
+ declare function useRestoreProduct(token: string): _tanstack_react_query.UseMutationResult<ApiResponse<Product>, Error, string, unknown>;
199
+ /**
200
+ * Hook to permanently delete a product (Hard delete)
201
+ *
202
+ * @param token - Auth token (required, admin only)
203
+ * @returns Mutation result with hard delete function
204
+ *
205
+ * @example
206
+ * ```tsx
207
+ * function PermanentDeleteButton({ productId }) {
208
+ * const { mutate: hardDelete, isPending } = useHardDeleteProduct(token);
209
+ *
210
+ * return (
211
+ * <Button
212
+ * variant="destructive"
213
+ * onClick={() => hardDelete(productId)}
214
+ * disabled={isPending}
215
+ * >
216
+ * Permanently Delete
217
+ * </Button>
218
+ * );
219
+ * }
220
+ * ```
221
+ */
222
+ declare function useHardDeleteProduct(token: string): _tanstack_react_query.UseMutationResult<ApiResponse<{
223
+ deleted: boolean;
224
+ }>, Error, string, unknown>;
225
+ /**
226
+ * Hook to sync product stock quantity
227
+ *
228
+ * Recomputes product.quantity by summing all StockEntry quantities across branches.
229
+ *
230
+ * @param token - Auth token (requires: admin, warehouse-admin, warehouse-staff, or store-manager role)
231
+ * @returns Mutation result with sync function
232
+ *
233
+ * @example
234
+ * ```tsx
235
+ * function SyncStockButton({ productId }) {
236
+ * const { mutate: syncStock, isPending } = useSyncProductStock(token);
237
+ *
238
+ * return (
239
+ * <Button onClick={() => syncStock(productId)} disabled={isPending}>
240
+ * Sync Stock
241
+ * </Button>
242
+ * );
243
+ * }
244
+ * ```
245
+ */
246
+ declare function useSyncProductStock(token: string): _tanstack_react_query.UseMutationResult<ProductSyncStockResponse, Error, string, unknown>;
247
+
248
+ interface FlattenedNode extends CategoryTreeNode {
249
+ depth: number;
250
+ displayName: string;
251
+ }
252
+ interface SelectOption {
253
+ value: string;
254
+ label: string;
255
+ }
256
+ /**
257
+ * Category CRUD hooks
258
+ */
259
+ declare const categoryHooks: CrudHooksReturn<Category, CreateCategoryPayload, UpdateCategoryPayload>;
260
+ declare const CATEGORY_KEYS: QueryKeys;
261
+ declare const useCategories: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Category>;
262
+ declare const useCategoryDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Category>;
263
+ declare const useCategoryActions: () => CrudActions<CreateCategoryPayload, UpdateCategoryPayload>;
264
+ declare const useCategoryNavigation: () => NavigateFn<Category>;
265
+ /**
266
+ * Hook to get category tree (nested structure)
267
+ * FE should cache this and derive everything else from it
268
+ *
269
+ * @param token - Auth token (optional for public access)
270
+ * @param options - React Query options
271
+ * @returns Query result with tree data
272
+ *
273
+ * @example
274
+ * ```tsx
275
+ * function CategoryNav() {
276
+ * const { data, isLoading } = useCategoryTree(token);
277
+ *
278
+ * if (isLoading) return <Spinner />;
279
+ *
280
+ * return (
281
+ * <nav>
282
+ * {data?.data?.map(category => (
283
+ * <CategoryItem key={category.slug} category={category} />
284
+ * ))}
285
+ * </nav>
286
+ * );
287
+ * }
288
+ * ```
289
+ */
290
+ declare function useCategoryTree(token?: string | null, options?: Omit<UseQueryOptions<CategoryTreeResponse>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<CategoryTreeResponse, Error>;
291
+ /**
292
+ * Hook to get category by slug
293
+ *
294
+ * @param token - Auth token (optional for public access)
295
+ * @param slug - Category slug
296
+ * @param options - React Query options
297
+ * @returns Query result with category data
298
+ *
299
+ * @example
300
+ * ```tsx
301
+ * function CategoryPage({ slug }) {
302
+ * const { data, isLoading } = useCategoryBySlug(token, slug);
303
+ *
304
+ * if (isLoading) return <Spinner />;
305
+ *
306
+ * return <h1>{data?.data?.name}</h1>;
307
+ * }
308
+ * ```
309
+ */
310
+ declare function useCategoryBySlug(token: string | null | undefined, slug: string, options?: Omit<UseQueryOptions<ApiResponse<Category>>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<ApiResponse<Category>, Error>;
311
+ /**
312
+ * Hook to sync product counts for all categories
313
+ * POST /categories/sync-product-count
314
+ *
315
+ * Use when manual data fixes or migrations may have desynced counts.
316
+ *
317
+ * @param token - Auth token (admin or inventory staff required)
318
+ * @returns Mutation result with sync function
319
+ *
320
+ * @example
321
+ * ```tsx
322
+ * function AdminPanel() {
323
+ * const { mutate: sync, isPending } = useCategorySyncProductCount(token);
324
+ *
325
+ * return (
326
+ * <Button onClick={() => sync()} disabled={isPending}>
327
+ * Sync Product Counts
328
+ * </Button>
329
+ * );
330
+ * }
331
+ * ```
332
+ */
333
+ declare function useCategorySyncProductCount(token: string): _tanstack_react_query.UseMutationResult<ApiResponse<{
334
+ updated: number;
335
+ }>, Error, void, unknown>;
336
+ /**
337
+ * Flatten category tree with depth indicator
338
+ * Useful for building hierarchical selects
339
+ *
340
+ * @param nodes - Category tree nodes
341
+ * @param depth - Current depth (used recursively)
342
+ * @param result - Accumulator array (used recursively)
343
+ * @returns Flattened array with depth and displayName
344
+ *
345
+ * @example
346
+ * ```typescript
347
+ * const { data } = useCategoryTree(token);
348
+ * const flat = flattenCategoryTree(data?.data);
349
+ * // flat = [
350
+ * // { slug: 'clothing', displayName: 'Clothing', depth: 0, ... },
351
+ * // { slug: 't-shirts', displayName: ' T-Shirts', depth: 1, ... },
352
+ * // ]
353
+ * ```
354
+ */
355
+ declare function flattenCategoryTree(nodes: CategoryTreeNode[] | undefined, depth?: number, result?: FlattenedNode[]): FlattenedNode[];
356
+ /**
357
+ * Build parent category options for select (root categories only)
358
+ *
359
+ * @param tree - Category tree from useCategoryTree
360
+ * @returns Options array with value/label for select inputs
361
+ *
362
+ * @example
363
+ * ```tsx
364
+ * function ParentSelect() {
365
+ * const { data } = useCategoryTree(token);
366
+ * const options = getParentCategoryOptions(data?.data);
367
+ *
368
+ * return (
369
+ * <Select>
370
+ * {options.map(opt => (
371
+ * <SelectItem key={opt.value} value={opt.value}>
372
+ * {opt.label}
373
+ * </SelectItem>
374
+ * ))}
375
+ * </Select>
376
+ * );
377
+ * }
378
+ * ```
379
+ */
380
+ declare function getParentCategoryOptions(tree: CategoryTreeNode[] | undefined): SelectOption[];
381
+ /**
382
+ * Build all category options for select (flattened with hierarchy)
383
+ *
384
+ * @param tree - Category tree from useCategoryTree
385
+ * @returns Options array with value/label showing hierarchy
386
+ *
387
+ * @example
388
+ * ```tsx
389
+ * function CategorySelect() {
390
+ * const { data } = useCategoryTree(token);
391
+ * const options = getAllCategoryOptions(data?.data);
392
+ *
393
+ * return (
394
+ * <Select>
395
+ * {options.map(opt => (
396
+ * <SelectItem key={opt.value} value={opt.value}>
397
+ * {opt.label}
398
+ * </SelectItem>
399
+ * ))}
400
+ * </Select>
401
+ * );
402
+ * }
403
+ * ```
404
+ */
405
+ declare function getAllCategoryOptions(tree: CategoryTreeNode[] | undefined): SelectOption[];
406
+ /**
407
+ * Find a category in the tree by slug
408
+ *
409
+ * @param tree - Category tree nodes
410
+ * @param slug - Category slug to find
411
+ * @returns Category node or undefined
412
+ */
413
+ declare function findCategoryBySlug(tree: CategoryTreeNode[] | undefined, slug: string): CategoryTreeNode | undefined;
414
+ /**
415
+ * Get breadcrumb path for a category
416
+ *
417
+ * @param tree - Category tree nodes
418
+ * @param slug - Category slug
419
+ * @returns Array of categories from root to target
420
+ */
421
+ declare function getCategoryBreadcrumb(tree: CategoryTreeNode[] | undefined, slug: string): CategoryTreeNode[];
422
+ /**
423
+ * Get all children slugs for a category (recursive)
424
+ *
425
+ * @param tree - Category tree nodes
426
+ * @param parentSlug - Parent category slug
427
+ * @returns Array of child category slugs
428
+ */
429
+ declare function getChildCategorySlugs(tree: CategoryTreeNode[] | undefined, parentSlug: string): string[];
430
+ /**
431
+ * Get root categories only
432
+ *
433
+ * @param tree - Category tree nodes
434
+ * @returns Array of root category nodes
435
+ */
436
+ declare function getRootCategories(tree: CategoryTreeNode[] | undefined): CategoryTreeNode[];
437
+
438
+ /**
439
+ * Size Guide CRUD hooks
440
+ */
441
+ declare const sizeGuideHooks: CrudHooksReturn<SizeGuide, CreateSizeGuidePayload, UpdateSizeGuidePayload>;
442
+ declare const SIZE_GUIDE_KEYS: QueryKeys;
443
+ declare const useSizeGuides: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<SizeGuide>;
444
+ declare const useSizeGuideDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<SizeGuide>;
445
+ declare const useSizeGuideActions: () => CrudActions<CreateSizeGuidePayload, UpdateSizeGuidePayload>;
446
+ declare const useSizeGuideNavigation: () => NavigateFn<SizeGuide>;
447
+ /**
448
+ * Hook to get size guide by slug
449
+ *
450
+ * @param token - Auth token (optional for public access)
451
+ * @param slug - Size guide slug
452
+ * @param options - React Query options
453
+ * @returns Query result with size guide data
454
+ *
455
+ * @example
456
+ * ```tsx
457
+ * function SizeGuideDisplay({ slug }) {
458
+ * const { data, isLoading } = useSizeGuideBySlug(null, slug);
459
+ *
460
+ * if (isLoading) return <Spinner />;
461
+ *
462
+ * return (
463
+ * <div>
464
+ * <h2>{data?.data?.name}</h2>
465
+ * <SizeTable guide={data?.data} />
466
+ * </div>
467
+ * );
468
+ * }
469
+ * ```
470
+ */
471
+ declare function useSizeGuideBySlug(token: string | null | undefined, slug: string, options?: Omit<UseQueryOptions<ApiResponse<SizeGuide>>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<ApiResponse<SizeGuide>, Error>;
472
+ /**
473
+ * Format size guide as select options
474
+ *
475
+ * @param sizeGuides - Array of size guides
476
+ * @returns Options array with value/label for select inputs
477
+ *
478
+ * @example
479
+ * ```tsx
480
+ * function SizeGuideSelect() {
481
+ * const { data } = useSizeGuides(token);
482
+ * const options = getSizeGuideOptions(data?.docs);
483
+ *
484
+ * return (
485
+ * <Select>
486
+ * {options.map(opt => (
487
+ * <SelectItem key={opt.value} value={opt.value}>
488
+ * {opt.label}
489
+ * </SelectItem>
490
+ * ))}
491
+ * </Select>
492
+ * );
493
+ * }
494
+ * ```
495
+ */
496
+ declare function getSizeGuideOptions(sizeGuides: SizeGuide[] | undefined): {
497
+ value: string;
498
+ label: string;
499
+ }[];
500
+ /**
501
+ * Get size guide by ID from a list
502
+ *
503
+ * @param sizeGuides - Array of size guides
504
+ * @param id - Size guide ID
505
+ * @returns Size guide or undefined
506
+ */
507
+ declare function findSizeGuideById(sizeGuides: SizeGuide[] | undefined, id: string): SizeGuide | undefined;
508
+ /**
509
+ * Get size guide by slug from a list
510
+ *
511
+ * @param sizeGuides - Array of size guides
512
+ * @param slug - Size guide slug
513
+ * @returns Size guide or undefined
514
+ */
515
+ declare function findSizeGuideBySlug(sizeGuides: SizeGuide[] | undefined, slug: string): SizeGuide | undefined;
516
+ /**
517
+ * Format measurement value with unit
518
+ *
519
+ * @param value - Measurement value
520
+ * @param unit - Measurement unit ('inches' or 'cm')
521
+ * @returns Formatted measurement string
522
+ *
523
+ * @example
524
+ * ```typescript
525
+ * formatMeasurement("34-36", "inches") // "34-36 in"
526
+ * formatMeasurement("88", "cm") // "88 cm"
527
+ * ```
528
+ */
529
+ declare function formatMeasurement(value: string, unit: 'inches' | 'cm'): string;
530
+ /**
531
+ * Get measurement labels as table headers
532
+ *
533
+ * @param guide - Size guide object
534
+ * @returns Array of header labels including "Size" as first column
535
+ *
536
+ * @example
537
+ * ```typescript
538
+ * const headers = getSizeTableHeaders(sizeGuide);
539
+ * // ["Size", "Chest", "Length", "Shoulder"]
540
+ * ```
541
+ */
542
+ declare function getSizeTableHeaders(guide: SizeGuide | undefined): string[];
543
+ /**
544
+ * Get size table rows
545
+ *
546
+ * @param guide - Size guide object
547
+ * @returns Array of row data with size name and measurements
548
+ *
549
+ * @example
550
+ * ```typescript
551
+ * const rows = getSizeTableRows(sizeGuide);
552
+ * // [
553
+ * // { name: "S", measurements: { chest: "34-36", length: "28" } },
554
+ * // { name: "M", measurements: { chest: "38-40", length: "29" } },
555
+ * // ]
556
+ * ```
557
+ */
558
+ declare function getSizeTableRows(guide: SizeGuide | undefined): Array<{
559
+ name: string;
560
+ measurements: Record<string, string>;
561
+ }>;
562
+
563
+ declare const reviewHooks: CrudHooksReturn<Review, CreateReviewPayload, UpdateReviewPayload>;
564
+ declare const REVIEW_KEYS: QueryKeys;
565
+ declare const useReviews: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Review>;
566
+ declare const useReviewDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Review>;
567
+ declare const useReviewActions: () => CrudActions<CreateReviewPayload, UpdateReviewPayload>;
568
+ declare const useReviewNavigation: () => NavigateFn<Review>;
569
+ declare function useMyReview(token: string | null | undefined, productId: string | null | undefined, options?: Omit<UseQueryOptions<ReviewResponse>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<ReviewResponse, Error>;
570
+
571
+ export { CATEGORY_KEYS, Category, CategoryTreeNode, CategoryTreeResponse, CreateCategoryPayload, CreateProductPayload, type CreateReviewPayload, CreateSizeGuidePayload, PRODUCT_KEYS, Product, ProductSyncStockResponse, REVIEW_KEYS, type Review, ReviewApi, type ReviewListResponse, type ReviewReply, type ReviewResponse, type ReviewStatus, SIZE_GUIDE_KEYS, SizeGuide, UpdateCategoryPayload, UpdateProductPayload, type UpdateReviewPayload, UpdateSizeGuidePayload, categoryHooks, findCategoryBySlug, findSizeGuideById, findSizeGuideBySlug, flattenCategoryTree, formatMeasurement, getAllCategoryOptions, getCategoryBreadcrumb, getChildCategorySlugs, getParentCategoryOptions, getRootCategories, getSizeGuideOptions, getSizeTableHeaders, getSizeTableRows, productHooks, reviewApi, reviewHooks, sizeGuideHooks, useCategories, useCategoryActions, useCategoryBySlug, useCategoryDetail, useCategoryNavigation, useCategorySyncProductCount, useCategoryTree, useDeletedProducts, useHardDeleteProduct, useMyReview, useProductActions, useProductBySlug, useProductDetail, useProductNavigation, useProductRecommendations, useProducts, useRestoreProduct, useReviewActions, useReviewDetail, useReviewNavigation, useReviews, useSizeGuideActions, useSizeGuideBySlug, useSizeGuideDetail, useSizeGuideNavigation, useSizeGuides, useSyncProductStock };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ export { CATEGORY_KEYS, CategoryApi, PRODUCT_KEYS, ProductApi, REVIEW_KEYS, ReviewApi, SIZE_GUIDE_KEYS, SizeGuideApi, categoryApi, categoryHooks, findCategoryBySlug, findSizeGuideById, findSizeGuideBySlug, flattenCategoryTree, formatMeasurement, getAllCategoryOptions, getCategoryBreadcrumb, getChildCategorySlugs, getParentCategoryOptions, getRootCategories, getSizeGuideOptions, getSizeTableHeaders, getSizeTableRows, productApi, productHooks, reviewApi, reviewHooks, sizeGuideApi, sizeGuideHooks, useCategories, useCategoryActions, useCategoryBySlug, useCategoryDetail, useCategoryNavigation, useCategorySyncProductCount, useCategoryTree, useDeletedProducts, useHardDeleteProduct, useMyReview, useProductActions, useProductBySlug, useProductDetail, useProductNavigation, useProductRecommendations, useProducts, useRestoreProduct, useReviewActions, useReviewDetail, useReviewNavigation, useReviews, useSizeGuideActions, useSizeGuideBySlug, useSizeGuideDetail, useSizeGuideNavigation, useSizeGuides, useSyncProductStock } from '../chunk-FOTUJPM4.js';
3
+ import '../chunk-PYYLHUV6.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,75 @@
1
+ import { BaseApi } from './chunk-QCTXAMLA.js';
2
+ import { handleApiRequest } from './chunk-IHCBBLLW.js';
3
+
4
+ // src/inventory/api/movement.ts
5
+ var MovementApi = class extends BaseApi {
6
+ constructor(config = {}) {
7
+ super("inventory/movements", config);
8
+ }
9
+ /**
10
+ * Get stock movements (audit trail)
11
+ * GET /inventory/movements
12
+ *
13
+ * @param params - Filters (productId, branchId, type, startDate, endDate, page, limit, sort, after/cursor)
14
+ */
15
+ async list({
16
+ token,
17
+ params = {},
18
+ options = {}
19
+ }) {
20
+ const processedParams = this.prepareParams(params);
21
+ const queryString = this.createQueryString(processedParams);
22
+ return handleApiRequest("GET", `${this.baseUrl}?${queryString}`, {
23
+ token,
24
+ cache: this.config.cache,
25
+ ...options
26
+ });
27
+ }
28
+ /**
29
+ * Get movements by type
30
+ * GET /inventory/movements?type=<type>
31
+ */
32
+ async listByType({
33
+ token,
34
+ type,
35
+ params = {},
36
+ options = {}
37
+ }) {
38
+ return this.list({ token, params: { ...params, type }, options });
39
+ }
40
+ /**
41
+ * Get movements for a specific product
42
+ * GET /inventory/movements?productId=<id>
43
+ */
44
+ async listByProduct({
45
+ token,
46
+ productId,
47
+ params = {},
48
+ options = {}
49
+ }) {
50
+ return this.list({ token, params: { ...params, productId }, options });
51
+ }
52
+ /**
53
+ * Get low stock items
54
+ * GET /inventory/low-stock
55
+ */
56
+ async lowStock({
57
+ token,
58
+ params = {},
59
+ options = {}
60
+ }) {
61
+ const processedParams = this.prepareParams(params);
62
+ const queryString = this.createQueryString(processedParams);
63
+ const baseUrl = this.baseUrl.replace("/movements", "/low-stock");
64
+ return handleApiRequest("GET", `${baseUrl}?${queryString}`, {
65
+ token,
66
+ cache: this.config.cache,
67
+ ...options
68
+ });
69
+ }
70
+ };
71
+ var movementApi = new MovementApi();
72
+
73
+ export { MovementApi, movementApi };
74
+ //# sourceMappingURL=chunk-24FDD6UR.js.map
75
+ //# sourceMappingURL=chunk-24FDD6UR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/inventory/api/movement.ts"],"names":[],"mappings":";;;;AAiBA,IAAM,WAAA,GAAN,cAA0B,OAAA,CAAuB;AAAA,EAC/C,WAAA,CAAY,MAAA,GAAS,EAAC,EAAG;AACvB,IAAA,KAAA,CAAM,uBAAuB,MAAM,CAAA;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAA,CAAK;AAAA,IACT,KAAA;AAAA,IACA,SAAS,EAAC;AAAA,IACV,UAAU;AAAC,GACb,EAI8C;AAC5C,IAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,aAAA,CAAc,MAAiC,CAAA;AAC5E,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,iBAAA,CAAkB,eAAe,CAAA;AAE1D,IAAA,OAAO,iBAAiB,KAAA,EAAO,CAAA,EAAG,KAAK,OAAO,CAAA,CAAA,EAAI,WAAW,CAAA,CAAA,EAAI;AAAA,MAC/D,KAAA;AAAA,MACA,KAAA,EAAO,KAAK,MAAA,CAAO,KAAA;AAAA,MACnB,GAAG;AAAA,KACJ,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAA,CAAW;AAAA,IACf,KAAA;AAAA,IACA,IAAA;AAAA,IACA,SAAS,EAAC;AAAA,IACV,UAAU;AAAC,GACb,EAK8C;AAC5C,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,EAAE,KAAA,EAAO,MAAA,EAAQ,EAAE,GAAG,MAAA,EAAQ,IAAA,EAAK,EAAG,OAAA,EAAS,CAAA;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,aAAA,CAAc;AAAA,IAClB,KAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAS,EAAC;AAAA,IACV,UAAU;AAAC,GACb,EAK8C;AAC5C,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,EAAE,KAAA,EAAO,MAAA,EAAQ,EAAE,GAAG,MAAA,EAAQ,SAAA,EAAU,EAAG,OAAA,EAAS,CAAA;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,QAAA,CAAS;AAAA,IACb,KAAA;AAAA,IACA,SAAS,EAAC;AAAA,IACV,UAAU;AAAC,GACb,EAIyC;AACvC,IAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,aAAA,CAAc,MAAM,CAAA;AACjD,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,iBAAA,CAAkB,eAAe,CAAA;AAC1D,IAAA,MAAM,OAAA,GAAU,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,cAAc,YAAY,CAAA;AAE/D,IAAA,OAAO,iBAAiB,KAAA,EAAO,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,WAAW,CAAA,CAAA,EAAI;AAAA,MAC1D,KAAA;AAAA,MACA,KAAA,EAAO,KAAK,MAAA,CAAO,KAAA;AAAA,MACnB,GAAG;AAAA,KACJ,CAAA;AAAA,EACH;AACF;AAEO,IAAM,WAAA,GAAc,IAAI,WAAA","file":"chunk-24FDD6UR.js","sourcesContent":["/**\r\n * Movement API - Stock Audit Trail\r\n *\r\n * Every stock change creates an immutable StockMovement record.\r\n * Types: purchase, sale, return, adjustment, transfer_in, transfer_out, initial, recount\r\n */\r\n\r\nimport { BaseApi, type ApiResponse, type PaginatedResponse, type RequestOptions } from \"../../core/api-factory\";\r\nimport { handleApiRequest } from \"../../core/api-handler\";\r\nimport type {\r\n StockMovement,\r\n MovementQueryParams,\r\n LowStockItem,\r\n} from \"../types\";\r\n\r\ntype FetchOptions = Omit<RequestOptions, \"token\" | \"organizationId\">;\r\n\r\nclass MovementApi extends BaseApi<StockMovement> {\r\n constructor(config = {}) {\r\n super(\"inventory/movements\", config);\r\n }\r\n\r\n /**\r\n * Get stock movements (audit trail)\r\n * GET /inventory/movements\r\n *\r\n * @param params - Filters (productId, branchId, type, startDate, endDate, page, limit, sort, after/cursor)\r\n */\r\n async list({\r\n token,\r\n params = {},\r\n options = {},\r\n }: {\r\n token: string;\r\n params?: MovementQueryParams;\r\n options?: FetchOptions;\r\n }): Promise<PaginatedResponse<StockMovement>> {\r\n const processedParams = this.prepareParams(params as Record<string, unknown>);\r\n const queryString = this.createQueryString(processedParams);\r\n\r\n return handleApiRequest(\"GET\", `${this.baseUrl}?${queryString}`, {\r\n token,\r\n cache: this.config.cache,\r\n ...options,\r\n });\r\n }\r\n\r\n /**\r\n * Get movements by type\r\n * GET /inventory/movements?type=<type>\r\n */\r\n async listByType({\r\n token,\r\n type,\r\n params = {},\r\n options = {},\r\n }: {\r\n token: string;\r\n type: StockMovement[\"type\"];\r\n params?: Omit<MovementQueryParams, \"type\">;\r\n options?: FetchOptions;\r\n }): Promise<PaginatedResponse<StockMovement>> {\r\n return this.list({ token, params: { ...params, type }, options });\r\n }\r\n\r\n /**\r\n * Get movements for a specific product\r\n * GET /inventory/movements?productId=<id>\r\n */\r\n async listByProduct({\r\n token,\r\n productId,\r\n params = {},\r\n options = {},\r\n }: {\r\n token: string;\r\n productId: string;\r\n params?: Omit<MovementQueryParams, \"productId\">;\r\n options?: FetchOptions;\r\n }): Promise<PaginatedResponse<StockMovement>> {\r\n return this.list({ token, params: { ...params, productId }, options });\r\n }\r\n\r\n /**\r\n * Get low stock items\r\n * GET /inventory/low-stock\r\n */\r\n async lowStock({\r\n token,\r\n params = {},\r\n options = {},\r\n }: {\r\n token: string;\r\n params?: { branchId?: string; threshold?: number };\r\n options?: FetchOptions;\r\n }): Promise<ApiResponse<LowStockItem[]>> {\r\n const processedParams = this.prepareParams(params);\r\n const queryString = this.createQueryString(processedParams);\r\n const baseUrl = this.baseUrl.replace(\"/movements\", \"/low-stock\");\r\n\r\n return handleApiRequest(\"GET\", `${baseUrl}?${queryString}`, {\r\n token,\r\n cache: this.config.cache,\r\n ...options,\r\n });\r\n }\r\n}\r\n\r\nexport const movementApi = new MovementApi();\r\nexport { MovementApi };\r\n"]}