@classytic/commerce-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @classytic/commerce-sdk might be problematic. Click here for more details.
- package/LICENSE +14 -0
- package/README.md +104 -0
- package/dist/adjustment-DTSLM7AN.js +5 -0
- package/dist/adjustment-DTSLM7AN.js.map +1 -0
- package/dist/analytics/index.d.ts +27 -0
- package/dist/analytics/index.js +6 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics-DMcD-o8w.d.ts +76 -0
- package/dist/api-factory-B_h4RKBm.d.ts +280 -0
- package/dist/auth/index.d.ts +39 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/catalog/index.d.ts +479 -0
- package/dist/catalog/index.js +9 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/chunk-4ZQK3FFN.js +40 -0
- package/dist/chunk-4ZQK3FFN.js.map +1 -0
- package/dist/chunk-5L6EXDGH.js +465 -0
- package/dist/chunk-5L6EXDGH.js.map +1 -0
- package/dist/chunk-5ZFW3FEI.js +183 -0
- package/dist/chunk-5ZFW3FEI.js.map +1 -0
- package/dist/chunk-66OQAZSL.js +94 -0
- package/dist/chunk-66OQAZSL.js.map +1 -0
- package/dist/chunk-6RYGA6MF.js +123 -0
- package/dist/chunk-6RYGA6MF.js.map +1 -0
- package/dist/chunk-B6MPVOV7.js +328 -0
- package/dist/chunk-B6MPVOV7.js.map +1 -0
- package/dist/chunk-BDA2WSJA.js +148 -0
- package/dist/chunk-BDA2WSJA.js.map +1 -0
- package/dist/chunk-EIVYT3HM.js +126 -0
- package/dist/chunk-EIVYT3HM.js.map +1 -0
- package/dist/chunk-EPQN7ZKZ.js +27 -0
- package/dist/chunk-EPQN7ZKZ.js.map +1 -0
- package/dist/chunk-FA7QFJ2G.js +177 -0
- package/dist/chunk-FA7QFJ2G.js.map +1 -0
- package/dist/chunk-I5TIKUIQ.js +261 -0
- package/dist/chunk-I5TIKUIQ.js.map +1 -0
- package/dist/chunk-ILQUH444.js +135 -0
- package/dist/chunk-ILQUH444.js.map +1 -0
- package/dist/chunk-IXMWZJLV.js +616 -0
- package/dist/chunk-IXMWZJLV.js.map +1 -0
- package/dist/chunk-KZIGRIQG.js +75 -0
- package/dist/chunk-KZIGRIQG.js.map +1 -0
- package/dist/chunk-OF5M6R2S.js +769 -0
- package/dist/chunk-OF5M6R2S.js.map +1 -0
- package/dist/chunk-PYYLHUV6.js +3 -0
- package/dist/chunk-PYYLHUV6.js.map +1 -0
- package/dist/chunk-QO5AGZFP.js +159 -0
- package/dist/chunk-QO5AGZFP.js.map +1 -0
- package/dist/chunk-QUMTBLNE.js +76 -0
- package/dist/chunk-QUMTBLNE.js.map +1 -0
- package/dist/chunk-R5Z7NYLH.js +126 -0
- package/dist/chunk-R5Z7NYLH.js.map +1 -0
- package/dist/chunk-SZYWG5IB.js +75 -0
- package/dist/chunk-SZYWG5IB.js.map +1 -0
- package/dist/chunk-U3XT35GZ.js +202 -0
- package/dist/chunk-U3XT35GZ.js.map +1 -0
- package/dist/chunk-UGELTUIZ.js +830 -0
- package/dist/chunk-UGELTUIZ.js.map +1 -0
- package/dist/chunk-VR36QVX2.js +122 -0
- package/dist/chunk-VR36QVX2.js.map +1 -0
- package/dist/chunk-WUOQK7BO.js +13 -0
- package/dist/chunk-WUOQK7BO.js.map +1 -0
- package/dist/chunk-X6PV5MHG.js +582 -0
- package/dist/chunk-X6PV5MHG.js.map +1 -0
- package/dist/chunk-ZWLMFLLH.js +534 -0
- package/dist/chunk-ZWLMFLLH.js.map +1 -0
- package/dist/content/index.d.ts +309 -0
- package/dist/content/index.js +6 -0
- package/dist/content/index.js.map +1 -0
- package/dist/core/index.d.ts +107 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/react.d.ts +107 -0
- package/dist/core/react.js +5 -0
- package/dist/core/react.js.map +1 -0
- package/dist/coupon-CHFcw7cd.d.ts +632 -0
- package/dist/coupon-zGkvO-Xx.d.ts +129 -0
- package/dist/crud.factory-DyKaPHcU.d.ts +181 -0
- package/dist/finance/index.d.ts +81 -0
- package/dist/finance/index.js +5 -0
- package/dist/finance/index.js.map +1 -0
- package/dist/finance-BJdfKRw0.d.ts +135 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory/index.d.ts +512 -0
- package/dist/inventory/index.js +16 -0
- package/dist/inventory/index.js.map +1 -0
- package/dist/inventory-DCiIZh8P.d.ts +742 -0
- package/dist/logistics/index.d.ts +226 -0
- package/dist/logistics/index.js +7 -0
- package/dist/logistics/index.js.map +1 -0
- package/dist/logistics-V8a9lUN3.d.ts +428 -0
- package/dist/media-CNLJK93J.d.ts +721 -0
- package/dist/movement-7MV3ADY5.js +5 -0
- package/dist/movement-7MV3ADY5.js.map +1 -0
- package/dist/payment-BRboLqvU.d.ts +127 -0
- package/dist/payments/index.d.ts +55 -0
- package/dist/payments/index.js +6 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/platform/index.d.ts +645 -0
- package/dist/platform/index.js +8 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/pos-D1jkkFl0.d.ts +885 -0
- package/dist/product-p09zXkXB.d.ts +260 -0
- package/dist/purchase-24BGT2HA.js +5 -0
- package/dist/purchase-24BGT2HA.js.map +1 -0
- package/dist/request-652PS6VR.js +5 -0
- package/dist/request-652PS6VR.js.map +1 -0
- package/dist/sales/index.d.ts +585 -0
- package/dist/sales/index.js +9 -0
- package/dist/sales/index.js.map +1 -0
- package/dist/server.d.ts +120 -0
- package/dist/server.js +27 -0
- package/dist/server.js.map +1 -0
- package/dist/size-guide-DgjzjM5P.d.ts +554 -0
- package/dist/stock-DEApGC-w.d.ts +632 -0
- package/dist/stock-OOUW57VQ.js +5 -0
- package/dist/stock-OOUW57VQ.js.map +1 -0
- package/dist/supplier-OC6JAWV6.js +5 -0
- package/dist/supplier-OC6JAWV6.js.map +1 -0
- package/dist/transaction/index.d.ts +104 -0
- package/dist/transaction/index.js +8 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction-BTmoHpWh.d.ts +428 -0
- package/dist/transaction-u5oaNuav.d.ts +84 -0
- package/dist/transfer-7SYSH3RG.js +5 -0
- package/dist/transfer-7SYSH3RG.js.map +1 -0
- package/dist/user-data-DdLjAGwO.d.ts +132 -0
- package/package.json +146 -0
|
@@ -0,0 +1,479 @@
|
|
|
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 { e as Product, C as CreateProductPayload, U as UpdateProductPayload, i as ProductSyncStockResponse } from '../product-p09zXkXB.js';
|
|
4
|
+
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';
|
|
5
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
7
|
+
import { A as ApiResponse, P as PaginatedResponse } from '../api-factory-B_h4RKBm.js';
|
|
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
|
+
* Product CRUD hooks with optimistic updates
|
|
12
|
+
*/
|
|
13
|
+
declare const productHooks: CrudHooksReturn<Product, CreateProductPayload, UpdateProductPayload>;
|
|
14
|
+
declare const PRODUCT_KEYS: QueryKeys;
|
|
15
|
+
declare const useProducts: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Product>;
|
|
16
|
+
declare const useProductDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Product>;
|
|
17
|
+
declare const useProductActions: () => CrudActions<CreateProductPayload, UpdateProductPayload>;
|
|
18
|
+
declare const useProductNavigation: () => NavigateFn<Product>;
|
|
19
|
+
/**
|
|
20
|
+
* Hook to get product by slug
|
|
21
|
+
*
|
|
22
|
+
* @param token - Auth token (optional for public access)
|
|
23
|
+
* @param slug - Product slug
|
|
24
|
+
* @param options - React Query options
|
|
25
|
+
* @returns Query result with product data
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* function ProductPage({ slug }) {
|
|
30
|
+
* const { data, isLoading } = useProductBySlug(null, slug);
|
|
31
|
+
*
|
|
32
|
+
* if (isLoading) return <Spinner />;
|
|
33
|
+
*
|
|
34
|
+
* return <h1>{data?.data?.name}</h1>;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function useProductBySlug(token: string | null | undefined, slug: string, options?: Omit<UseQueryOptions<ApiResponse<Product>>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<ApiResponse<Product>, Error>;
|
|
39
|
+
interface UseProductRecommendationsReturn {
|
|
40
|
+
recommendations: Product[];
|
|
41
|
+
isLoading: boolean;
|
|
42
|
+
error: Error | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Hook to get product recommendations
|
|
46
|
+
*
|
|
47
|
+
* @param productId - Product ID to get recommendations for
|
|
48
|
+
* @param options - React Query options
|
|
49
|
+
* @returns Object with recommendations array, isLoading, and error
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* function ProductRecommendations({ productId }) {
|
|
54
|
+
* const { recommendations, isLoading } = useProductRecommendations(productId);
|
|
55
|
+
*
|
|
56
|
+
* if (isLoading) return <Spinner />;
|
|
57
|
+
*
|
|
58
|
+
* return (
|
|
59
|
+
* <div>
|
|
60
|
+
* {recommendations.map(product => (
|
|
61
|
+
* <ProductCard key={product._id} product={product} />
|
|
62
|
+
* ))}
|
|
63
|
+
* </div>
|
|
64
|
+
* );
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare function useProductRecommendations(productId: string, options?: Omit<UseQueryOptions<ApiResponse<Product[]>>, "queryKey" | "queryFn">): UseProductRecommendationsReturn;
|
|
69
|
+
/**
|
|
70
|
+
* Hook to get soft-deleted products (Recycle Bin)
|
|
71
|
+
*
|
|
72
|
+
* @param token - Auth token (required, admin only)
|
|
73
|
+
* @param params - Query parameters for pagination/filtering
|
|
74
|
+
* @param options - React Query options
|
|
75
|
+
* @returns Query result with deleted products
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* function RecycleBin() {
|
|
80
|
+
* const { data, isLoading } = useDeletedProducts(token, { page: 1, limit: 20 });
|
|
81
|
+
*
|
|
82
|
+
* if (isLoading) return <Spinner />;
|
|
83
|
+
*
|
|
84
|
+
* return (
|
|
85
|
+
* <div>
|
|
86
|
+
* {data?.docs?.map(product => (
|
|
87
|
+
* <DeletedProductRow key={product._id} product={product} />
|
|
88
|
+
* ))}
|
|
89
|
+
* </div>
|
|
90
|
+
* );
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
declare function useDeletedProducts(token: string, params?: Record<string, unknown>, options?: Omit<UseQueryOptions<PaginatedResponse<Product>>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PaginatedResponse<Product>, Error>;
|
|
95
|
+
/**
|
|
96
|
+
* Hook to restore a soft-deleted product
|
|
97
|
+
*
|
|
98
|
+
* @param token - Auth token (required, admin only)
|
|
99
|
+
* @returns Mutation result with restore function
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* function RestoreButton({ productId }) {
|
|
104
|
+
* const { mutate: restore, isPending } = useRestoreProduct(token);
|
|
105
|
+
*
|
|
106
|
+
* return (
|
|
107
|
+
* <Button onClick={() => restore(productId)} disabled={isPending}>
|
|
108
|
+
* Restore Product
|
|
109
|
+
* </Button>
|
|
110
|
+
* );
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
declare function useRestoreProduct(token: string): _tanstack_react_query.UseMutationResult<ApiResponse<Product>, Error, string, unknown>;
|
|
115
|
+
/**
|
|
116
|
+
* Hook to permanently delete a product (Hard delete)
|
|
117
|
+
*
|
|
118
|
+
* @param token - Auth token (required, admin only)
|
|
119
|
+
* @returns Mutation result with hard delete function
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```tsx
|
|
123
|
+
* function PermanentDeleteButton({ productId }) {
|
|
124
|
+
* const { mutate: hardDelete, isPending } = useHardDeleteProduct(token);
|
|
125
|
+
*
|
|
126
|
+
* return (
|
|
127
|
+
* <Button
|
|
128
|
+
* variant="destructive"
|
|
129
|
+
* onClick={() => hardDelete(productId)}
|
|
130
|
+
* disabled={isPending}
|
|
131
|
+
* >
|
|
132
|
+
* Permanently Delete
|
|
133
|
+
* </Button>
|
|
134
|
+
* );
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
declare function useHardDeleteProduct(token: string): _tanstack_react_query.UseMutationResult<ApiResponse<{
|
|
139
|
+
deleted: boolean;
|
|
140
|
+
}>, Error, string, unknown>;
|
|
141
|
+
/**
|
|
142
|
+
* Hook to sync product stock quantity
|
|
143
|
+
*
|
|
144
|
+
* Recomputes product.quantity by summing all StockEntry quantities across branches.
|
|
145
|
+
*
|
|
146
|
+
* @param token - Auth token (requires: admin, warehouse-admin, warehouse-staff, or store-manager role)
|
|
147
|
+
* @returns Mutation result with sync function
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```tsx
|
|
151
|
+
* function SyncStockButton({ productId }) {
|
|
152
|
+
* const { mutate: syncStock, isPending } = useSyncProductStock(token);
|
|
153
|
+
*
|
|
154
|
+
* return (
|
|
155
|
+
* <Button onClick={() => syncStock(productId)} disabled={isPending}>
|
|
156
|
+
* Sync Stock
|
|
157
|
+
* </Button>
|
|
158
|
+
* );
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare function useSyncProductStock(token: string): _tanstack_react_query.UseMutationResult<ProductSyncStockResponse, Error, string, unknown>;
|
|
163
|
+
|
|
164
|
+
interface FlattenedNode extends CategoryTreeNode {
|
|
165
|
+
depth: number;
|
|
166
|
+
displayName: string;
|
|
167
|
+
}
|
|
168
|
+
interface SelectOption {
|
|
169
|
+
value: string;
|
|
170
|
+
label: string;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Category CRUD hooks
|
|
174
|
+
*/
|
|
175
|
+
declare const categoryHooks: CrudHooksReturn<Category, CreateCategoryPayload, UpdateCategoryPayload>;
|
|
176
|
+
declare const CATEGORY_KEYS: QueryKeys;
|
|
177
|
+
declare const useCategories: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Category>;
|
|
178
|
+
declare const useCategoryDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Category>;
|
|
179
|
+
declare const useCategoryActions: () => CrudActions<CreateCategoryPayload, UpdateCategoryPayload>;
|
|
180
|
+
declare const useCategoryNavigation: () => NavigateFn<Category>;
|
|
181
|
+
/**
|
|
182
|
+
* Hook to get category tree (nested structure)
|
|
183
|
+
* FE should cache this and derive everything else from it
|
|
184
|
+
*
|
|
185
|
+
* @param token - Auth token (optional for public access)
|
|
186
|
+
* @param options - React Query options
|
|
187
|
+
* @returns Query result with tree data
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```tsx
|
|
191
|
+
* function CategoryNav() {
|
|
192
|
+
* const { data, isLoading } = useCategoryTree(token);
|
|
193
|
+
*
|
|
194
|
+
* if (isLoading) return <Spinner />;
|
|
195
|
+
*
|
|
196
|
+
* return (
|
|
197
|
+
* <nav>
|
|
198
|
+
* {data?.data?.map(category => (
|
|
199
|
+
* <CategoryItem key={category.slug} category={category} />
|
|
200
|
+
* ))}
|
|
201
|
+
* </nav>
|
|
202
|
+
* );
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
declare function useCategoryTree(token?: string | null, options?: Omit<UseQueryOptions<CategoryTreeResponse>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<CategoryTreeResponse, Error>;
|
|
207
|
+
/**
|
|
208
|
+
* Hook to get category by slug
|
|
209
|
+
*
|
|
210
|
+
* @param token - Auth token (optional for public access)
|
|
211
|
+
* @param slug - Category slug
|
|
212
|
+
* @param options - React Query options
|
|
213
|
+
* @returns Query result with category data
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```tsx
|
|
217
|
+
* function CategoryPage({ slug }) {
|
|
218
|
+
* const { data, isLoading } = useCategoryBySlug(token, slug);
|
|
219
|
+
*
|
|
220
|
+
* if (isLoading) return <Spinner />;
|
|
221
|
+
*
|
|
222
|
+
* return <h1>{data?.data?.name}</h1>;
|
|
223
|
+
* }
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
declare function useCategoryBySlug(token: string | null | undefined, slug: string, options?: Omit<UseQueryOptions<ApiResponse<Category>>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<ApiResponse<Category>, Error>;
|
|
227
|
+
/**
|
|
228
|
+
* Hook to sync product counts for all categories
|
|
229
|
+
* POST /categories/sync-product-count
|
|
230
|
+
*
|
|
231
|
+
* Use when manual data fixes or migrations may have desynced counts.
|
|
232
|
+
*
|
|
233
|
+
* @param token - Auth token (admin or inventory staff required)
|
|
234
|
+
* @returns Mutation result with sync function
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```tsx
|
|
238
|
+
* function AdminPanel() {
|
|
239
|
+
* const { mutate: sync, isPending } = useCategorySyncProductCount(token);
|
|
240
|
+
*
|
|
241
|
+
* return (
|
|
242
|
+
* <Button onClick={() => sync()} disabled={isPending}>
|
|
243
|
+
* Sync Product Counts
|
|
244
|
+
* </Button>
|
|
245
|
+
* );
|
|
246
|
+
* }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
declare function useCategorySyncProductCount(token: string): _tanstack_react_query.UseMutationResult<ApiResponse<{
|
|
250
|
+
updated: number;
|
|
251
|
+
}>, Error, void, unknown>;
|
|
252
|
+
/**
|
|
253
|
+
* Flatten category tree with depth indicator
|
|
254
|
+
* Useful for building hierarchical selects
|
|
255
|
+
*
|
|
256
|
+
* @param nodes - Category tree nodes
|
|
257
|
+
* @param depth - Current depth (used recursively)
|
|
258
|
+
* @param result - Accumulator array (used recursively)
|
|
259
|
+
* @returns Flattened array with depth and displayName
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const { data } = useCategoryTree(token);
|
|
264
|
+
* const flat = flattenCategoryTree(data?.data);
|
|
265
|
+
* // flat = [
|
|
266
|
+
* // { slug: 'clothing', displayName: 'Clothing', depth: 0, ... },
|
|
267
|
+
* // { slug: 't-shirts', displayName: ' T-Shirts', depth: 1, ... },
|
|
268
|
+
* // ]
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
declare function flattenCategoryTree(nodes: CategoryTreeNode[] | undefined, depth?: number, result?: FlattenedNode[]): FlattenedNode[];
|
|
272
|
+
/**
|
|
273
|
+
* Build parent category options for select (root categories only)
|
|
274
|
+
*
|
|
275
|
+
* @param tree - Category tree from useCategoryTree
|
|
276
|
+
* @returns Options array with value/label for select inputs
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```tsx
|
|
280
|
+
* function ParentSelect() {
|
|
281
|
+
* const { data } = useCategoryTree(token);
|
|
282
|
+
* const options = getParentCategoryOptions(data?.data);
|
|
283
|
+
*
|
|
284
|
+
* return (
|
|
285
|
+
* <Select>
|
|
286
|
+
* {options.map(opt => (
|
|
287
|
+
* <SelectItem key={opt.value} value={opt.value}>
|
|
288
|
+
* {opt.label}
|
|
289
|
+
* </SelectItem>
|
|
290
|
+
* ))}
|
|
291
|
+
* </Select>
|
|
292
|
+
* );
|
|
293
|
+
* }
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
declare function getParentCategoryOptions(tree: CategoryTreeNode[] | undefined): SelectOption[];
|
|
297
|
+
/**
|
|
298
|
+
* Build all category options for select (flattened with hierarchy)
|
|
299
|
+
*
|
|
300
|
+
* @param tree - Category tree from useCategoryTree
|
|
301
|
+
* @returns Options array with value/label showing hierarchy
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```tsx
|
|
305
|
+
* function CategorySelect() {
|
|
306
|
+
* const { data } = useCategoryTree(token);
|
|
307
|
+
* const options = getAllCategoryOptions(data?.data);
|
|
308
|
+
*
|
|
309
|
+
* return (
|
|
310
|
+
* <Select>
|
|
311
|
+
* {options.map(opt => (
|
|
312
|
+
* <SelectItem key={opt.value} value={opt.value}>
|
|
313
|
+
* {opt.label}
|
|
314
|
+
* </SelectItem>
|
|
315
|
+
* ))}
|
|
316
|
+
* </Select>
|
|
317
|
+
* );
|
|
318
|
+
* }
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
declare function getAllCategoryOptions(tree: CategoryTreeNode[] | undefined): SelectOption[];
|
|
322
|
+
/**
|
|
323
|
+
* Find a category in the tree by slug
|
|
324
|
+
*
|
|
325
|
+
* @param tree - Category tree nodes
|
|
326
|
+
* @param slug - Category slug to find
|
|
327
|
+
* @returns Category node or undefined
|
|
328
|
+
*/
|
|
329
|
+
declare function findCategoryBySlug(tree: CategoryTreeNode[] | undefined, slug: string): CategoryTreeNode | undefined;
|
|
330
|
+
/**
|
|
331
|
+
* Get breadcrumb path for a category
|
|
332
|
+
*
|
|
333
|
+
* @param tree - Category tree nodes
|
|
334
|
+
* @param slug - Category slug
|
|
335
|
+
* @returns Array of categories from root to target
|
|
336
|
+
*/
|
|
337
|
+
declare function getCategoryBreadcrumb(tree: CategoryTreeNode[] | undefined, slug: string): CategoryTreeNode[];
|
|
338
|
+
/**
|
|
339
|
+
* Get all children slugs for a category (recursive)
|
|
340
|
+
*
|
|
341
|
+
* @param tree - Category tree nodes
|
|
342
|
+
* @param parentSlug - Parent category slug
|
|
343
|
+
* @returns Array of child category slugs
|
|
344
|
+
*/
|
|
345
|
+
declare function getChildCategorySlugs(tree: CategoryTreeNode[] | undefined, parentSlug: string): string[];
|
|
346
|
+
/**
|
|
347
|
+
* Get root categories only
|
|
348
|
+
*
|
|
349
|
+
* @param tree - Category tree nodes
|
|
350
|
+
* @returns Array of root category nodes
|
|
351
|
+
*/
|
|
352
|
+
declare function getRootCategories(tree: CategoryTreeNode[] | undefined): CategoryTreeNode[];
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Size Guide CRUD hooks
|
|
356
|
+
*/
|
|
357
|
+
declare const sizeGuideHooks: CrudHooksReturn<SizeGuide, CreateSizeGuidePayload, UpdateSizeGuidePayload>;
|
|
358
|
+
declare const SIZE_GUIDE_KEYS: QueryKeys;
|
|
359
|
+
declare const useSizeGuides: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<SizeGuide>;
|
|
360
|
+
declare const useSizeGuideDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<SizeGuide>;
|
|
361
|
+
declare const useSizeGuideActions: () => CrudActions<CreateSizeGuidePayload, UpdateSizeGuidePayload>;
|
|
362
|
+
declare const useSizeGuideNavigation: () => NavigateFn<SizeGuide>;
|
|
363
|
+
/**
|
|
364
|
+
* Hook to get size guide by slug
|
|
365
|
+
*
|
|
366
|
+
* @param token - Auth token (optional for public access)
|
|
367
|
+
* @param slug - Size guide slug
|
|
368
|
+
* @param options - React Query options
|
|
369
|
+
* @returns Query result with size guide data
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```tsx
|
|
373
|
+
* function SizeGuideDisplay({ slug }) {
|
|
374
|
+
* const { data, isLoading } = useSizeGuideBySlug(null, slug);
|
|
375
|
+
*
|
|
376
|
+
* if (isLoading) return <Spinner />;
|
|
377
|
+
*
|
|
378
|
+
* return (
|
|
379
|
+
* <div>
|
|
380
|
+
* <h2>{data?.data?.name}</h2>
|
|
381
|
+
* <SizeTable guide={data?.data} />
|
|
382
|
+
* </div>
|
|
383
|
+
* );
|
|
384
|
+
* }
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
declare function useSizeGuideBySlug(token: string | null | undefined, slug: string, options?: Omit<UseQueryOptions<ApiResponse<SizeGuide>>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<ApiResponse<SizeGuide>, Error>;
|
|
388
|
+
/**
|
|
389
|
+
* Format size guide as select options
|
|
390
|
+
*
|
|
391
|
+
* @param sizeGuides - Array of size guides
|
|
392
|
+
* @returns Options array with value/label for select inputs
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```tsx
|
|
396
|
+
* function SizeGuideSelect() {
|
|
397
|
+
* const { data } = useSizeGuides(token);
|
|
398
|
+
* const options = getSizeGuideOptions(data?.docs);
|
|
399
|
+
*
|
|
400
|
+
* return (
|
|
401
|
+
* <Select>
|
|
402
|
+
* {options.map(opt => (
|
|
403
|
+
* <SelectItem key={opt.value} value={opt.value}>
|
|
404
|
+
* {opt.label}
|
|
405
|
+
* </SelectItem>
|
|
406
|
+
* ))}
|
|
407
|
+
* </Select>
|
|
408
|
+
* );
|
|
409
|
+
* }
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
declare function getSizeGuideOptions(sizeGuides: SizeGuide[] | undefined): {
|
|
413
|
+
value: string;
|
|
414
|
+
label: string;
|
|
415
|
+
}[];
|
|
416
|
+
/**
|
|
417
|
+
* Get size guide by ID from a list
|
|
418
|
+
*
|
|
419
|
+
* @param sizeGuides - Array of size guides
|
|
420
|
+
* @param id - Size guide ID
|
|
421
|
+
* @returns Size guide or undefined
|
|
422
|
+
*/
|
|
423
|
+
declare function findSizeGuideById(sizeGuides: SizeGuide[] | undefined, id: string): SizeGuide | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* Get size guide by slug from a list
|
|
426
|
+
*
|
|
427
|
+
* @param sizeGuides - Array of size guides
|
|
428
|
+
* @param slug - Size guide slug
|
|
429
|
+
* @returns Size guide or undefined
|
|
430
|
+
*/
|
|
431
|
+
declare function findSizeGuideBySlug(sizeGuides: SizeGuide[] | undefined, slug: string): SizeGuide | undefined;
|
|
432
|
+
/**
|
|
433
|
+
* Format measurement value with unit
|
|
434
|
+
*
|
|
435
|
+
* @param value - Measurement value
|
|
436
|
+
* @param unit - Measurement unit ('inches' or 'cm')
|
|
437
|
+
* @returns Formatted measurement string
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```typescript
|
|
441
|
+
* formatMeasurement("34-36", "inches") // "34-36 in"
|
|
442
|
+
* formatMeasurement("88", "cm") // "88 cm"
|
|
443
|
+
* ```
|
|
444
|
+
*/
|
|
445
|
+
declare function formatMeasurement(value: string, unit: 'inches' | 'cm'): string;
|
|
446
|
+
/**
|
|
447
|
+
* Get measurement labels as table headers
|
|
448
|
+
*
|
|
449
|
+
* @param guide - Size guide object
|
|
450
|
+
* @returns Array of header labels including "Size" as first column
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* ```typescript
|
|
454
|
+
* const headers = getSizeTableHeaders(sizeGuide);
|
|
455
|
+
* // ["Size", "Chest", "Length", "Shoulder"]
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
declare function getSizeTableHeaders(guide: SizeGuide | undefined): string[];
|
|
459
|
+
/**
|
|
460
|
+
* Get size table rows
|
|
461
|
+
*
|
|
462
|
+
* @param guide - Size guide object
|
|
463
|
+
* @returns Array of row data with size name and measurements
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* const rows = getSizeTableRows(sizeGuide);
|
|
468
|
+
* // [
|
|
469
|
+
* // { name: "S", measurements: { chest: "34-36", length: "28" } },
|
|
470
|
+
* // { name: "M", measurements: { chest: "38-40", length: "29" } },
|
|
471
|
+
* // ]
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
declare function getSizeTableRows(guide: SizeGuide | undefined): Array<{
|
|
475
|
+
name: string;
|
|
476
|
+
measurements: Record<string, string>;
|
|
477
|
+
}>;
|
|
478
|
+
|
|
479
|
+
export { CATEGORY_KEYS, Category, CategoryTreeNode, CategoryTreeResponse, CreateCategoryPayload, CreateProductPayload, CreateSizeGuidePayload, PRODUCT_KEYS, Product, ProductSyncStockResponse, SIZE_GUIDE_KEYS, SizeGuide, UpdateCategoryPayload, UpdateProductPayload, UpdateSizeGuidePayload, categoryHooks, findCategoryBySlug, findSizeGuideById, findSizeGuideBySlug, flattenCategoryTree, formatMeasurement, getAllCategoryOptions, getCategoryBreadcrumb, getChildCategorySlugs, getParentCategoryOptions, getRootCategories, getSizeGuideOptions, getSizeTableHeaders, getSizeTableRows, productHooks, sizeGuideHooks, useCategories, useCategoryActions, useCategoryBySlug, useCategoryDetail, useCategoryNavigation, useCategorySyncProductCount, useCategoryTree, useDeletedProducts, useHardDeleteProduct, useProductActions, useProductBySlug, useProductDetail, useProductNavigation, useProductRecommendations, useProducts, useRestoreProduct, useSizeGuideActions, useSizeGuideBySlug, useSizeGuideDetail, useSizeGuideNavigation, useSizeGuides, useSyncProductStock };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export { CATEGORY_KEYS, CategoryApi, PRODUCT_KEYS, ProductApi, SIZE_GUIDE_KEYS, SizeGuideApi, categoryApi, categoryHooks, findCategoryBySlug, findSizeGuideById, findSizeGuideBySlug, flattenCategoryTree, formatMeasurement, getAllCategoryOptions, getCategoryBreadcrumb, getChildCategorySlugs, getParentCategoryOptions, getRootCategories, getSizeGuideOptions, getSizeTableHeaders, getSizeTableRows, productApi, productHooks, sizeGuideApi, sizeGuideHooks, useCategories, useCategoryActions, useCategoryBySlug, useCategoryDetail, useCategoryNavigation, useCategorySyncProductCount, useCategoryTree, useDeletedProducts, useHardDeleteProduct, useProductActions, useProductBySlug, useProductDetail, useProductNavigation, useProductRecommendations, useProducts, useRestoreProduct, useSizeGuideActions, useSizeGuideBySlug, useSizeGuideDetail, useSizeGuideNavigation, useSizeGuides, useSyncProductStock } from '../chunk-X6PV5MHG.js';
|
|
3
|
+
import '../chunk-PYYLHUV6.js';
|
|
4
|
+
import '../chunk-I5TIKUIQ.js';
|
|
5
|
+
import '../chunk-B6MPVOV7.js';
|
|
6
|
+
import '../chunk-U3XT35GZ.js';
|
|
7
|
+
import '../chunk-VR36QVX2.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,40 @@
|
|
|
1
|
+
import { handleApiRequest } from './chunk-VR36QVX2.js';
|
|
2
|
+
|
|
3
|
+
// src/analytics/api/analytics.ts
|
|
4
|
+
var AnalyticsApi = class {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.baseUrl = "/api/v1/analytics";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get dashboard analytics
|
|
10
|
+
* GET /analytics/dashboard
|
|
11
|
+
*
|
|
12
|
+
* @param token - Auth token (required)
|
|
13
|
+
* @param params.period - Time period: '7d', '30d', '90d', '1y' (default: '30d')
|
|
14
|
+
* @param params.branchId - Optional branch filter
|
|
15
|
+
*/
|
|
16
|
+
async getDashboard({
|
|
17
|
+
token,
|
|
18
|
+
params = {},
|
|
19
|
+
options = {}
|
|
20
|
+
}) {
|
|
21
|
+
if (!token) {
|
|
22
|
+
throw new Error("Authentication required");
|
|
23
|
+
}
|
|
24
|
+
const queryParams = new URLSearchParams();
|
|
25
|
+
if (params.period) queryParams.append("period", params.period);
|
|
26
|
+
if (params.branchId) queryParams.append("branchId", params.branchId);
|
|
27
|
+
const url = `${this.baseUrl}/dashboard${queryParams.toString() ? `?${queryParams}` : ""}`;
|
|
28
|
+
return handleApiRequest("GET", url, {
|
|
29
|
+
token,
|
|
30
|
+
cache: "no-store",
|
|
31
|
+
// Always fetch fresh analytics data
|
|
32
|
+
...options
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var analyticsApi = new AnalyticsApi();
|
|
37
|
+
|
|
38
|
+
export { AnalyticsApi, analyticsApi };
|
|
39
|
+
//# sourceMappingURL=chunk-4ZQK3FFN.js.map
|
|
40
|
+
//# sourceMappingURL=chunk-4ZQK3FFN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/analytics/api/analytics.ts"],"names":[],"mappings":";;;AAgBA,IAAM,eAAN,MAAmB;AAAA,EAGjB,WAAA,GAAc;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,mBAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,YAAA,CAAa;AAAA,IACjB,KAAA;AAAA,IACA,SAAS,EAAC;AAAA,IACV,UAAU;AAAC,GACb,EAI6C;AAC3C,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAI,MAAM,yBAAyB,CAAA;AAAA,IAC3C;AAEA,IAAA,MAAM,WAAA,GAAc,IAAI,eAAA,EAAgB;AACxC,IAAA,IAAI,OAAO,MAAA,EAAQ,WAAA,CAAY,MAAA,CAAO,QAAA,EAAU,OAAO,MAAM,CAAA;AAC7D,IAAA,IAAI,OAAO,QAAA,EAAU,WAAA,CAAY,MAAA,CAAO,UAAA,EAAY,OAAO,QAAQ,CAAA;AAEnE,IAAA,MAAM,GAAA,GAAM,CAAA,EAAG,IAAA,CAAK,OAAO,CAAA,UAAA,EAAa,WAAA,CAAY,QAAA,EAAS,GAAI,CAAA,CAAA,EAAI,WAAW,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA;AAEvF,IAAA,OAAO,gBAAA,CAAiB,OAAO,GAAA,EAAK;AAAA,MAClC,KAAA;AAAA,MACA,KAAA,EAAO,UAAA;AAAA;AAAA,MACP,GAAG;AAAA,KACJ,CAAA;AAAA,EACH;AACF;AAEO,IAAM,YAAA,GAAe,IAAI,YAAA","file":"chunk-4ZQK3FFN.js","sourcesContent":["/**\r\n * Analytics API - Dashboard and reporting\r\n *\r\n * Endpoints:\r\n * - getDashboard({ token, params }) - Get dashboard analytics\r\n *\r\n * Roles:\r\n * - admin, superadmin, finance-admin, finance-manager\r\n */\r\n\r\nimport { handleApiRequest } from \"../../core/api-handler\";\r\nimport type { ApiResponse, RequestOptions } from \"../../core/api-factory\";\r\nimport type { AnalyticsDashboard, AnalyticsDashboardParams } from \"../types\";\r\n\r\ntype FetchOptions = Omit<RequestOptions, \"token\" | \"organizationId\">;\r\n\r\nclass AnalyticsApi {\r\n private baseUrl: string;\r\n\r\n constructor() {\r\n this.baseUrl = \"/api/v1/analytics\";\r\n }\r\n\r\n /**\r\n * Get dashboard analytics\r\n * GET /analytics/dashboard\r\n *\r\n * @param token - Auth token (required)\r\n * @param params.period - Time period: '7d', '30d', '90d', '1y' (default: '30d')\r\n * @param params.branchId - Optional branch filter\r\n */\r\n async getDashboard({\r\n token,\r\n params = {},\r\n options = {},\r\n }: {\r\n token: string;\r\n params?: AnalyticsDashboardParams;\r\n options?: FetchOptions;\r\n }): Promise<ApiResponse<AnalyticsDashboard>> {\r\n if (!token) {\r\n throw new Error(\"Authentication required\");\r\n }\r\n\r\n const queryParams = new URLSearchParams();\r\n if (params.period) queryParams.append(\"period\", params.period);\r\n if (params.branchId) queryParams.append(\"branchId\", params.branchId);\r\n\r\n const url = `${this.baseUrl}/dashboard${queryParams.toString() ? `?${queryParams}` : \"\"}`;\r\n\r\n return handleApiRequest(\"GET\", url, {\r\n token,\r\n cache: \"no-store\", // Always fetch fresh analytics data\r\n ...options,\r\n });\r\n }\r\n}\r\n\r\nexport const analyticsApi = new AnalyticsApi();\r\nexport { AnalyticsApi };\r\n"]}
|