@classytic/commerce-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @classytic/commerce-sdk might be problematic. Click here for more details.

Files changed (131) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +104 -0
  3. package/dist/adjustment-DTSLM7AN.js +5 -0
  4. package/dist/adjustment-DTSLM7AN.js.map +1 -0
  5. package/dist/analytics/index.d.ts +27 -0
  6. package/dist/analytics/index.js +6 -0
  7. package/dist/analytics/index.js.map +1 -0
  8. package/dist/analytics-DMcD-o8w.d.ts +76 -0
  9. package/dist/api-factory-B_h4RKBm.d.ts +280 -0
  10. package/dist/auth/index.d.ts +39 -0
  11. package/dist/auth/index.js +5 -0
  12. package/dist/auth/index.js.map +1 -0
  13. package/dist/catalog/index.d.ts +479 -0
  14. package/dist/catalog/index.js +9 -0
  15. package/dist/catalog/index.js.map +1 -0
  16. package/dist/chunk-4ZQK3FFN.js +40 -0
  17. package/dist/chunk-4ZQK3FFN.js.map +1 -0
  18. package/dist/chunk-5L6EXDGH.js +465 -0
  19. package/dist/chunk-5L6EXDGH.js.map +1 -0
  20. package/dist/chunk-5ZFW3FEI.js +183 -0
  21. package/dist/chunk-5ZFW3FEI.js.map +1 -0
  22. package/dist/chunk-66OQAZSL.js +94 -0
  23. package/dist/chunk-66OQAZSL.js.map +1 -0
  24. package/dist/chunk-6RYGA6MF.js +123 -0
  25. package/dist/chunk-6RYGA6MF.js.map +1 -0
  26. package/dist/chunk-B6MPVOV7.js +328 -0
  27. package/dist/chunk-B6MPVOV7.js.map +1 -0
  28. package/dist/chunk-BDA2WSJA.js +148 -0
  29. package/dist/chunk-BDA2WSJA.js.map +1 -0
  30. package/dist/chunk-EIVYT3HM.js +126 -0
  31. package/dist/chunk-EIVYT3HM.js.map +1 -0
  32. package/dist/chunk-EPQN7ZKZ.js +27 -0
  33. package/dist/chunk-EPQN7ZKZ.js.map +1 -0
  34. package/dist/chunk-FA7QFJ2G.js +177 -0
  35. package/dist/chunk-FA7QFJ2G.js.map +1 -0
  36. package/dist/chunk-I5TIKUIQ.js +261 -0
  37. package/dist/chunk-I5TIKUIQ.js.map +1 -0
  38. package/dist/chunk-ILQUH444.js +135 -0
  39. package/dist/chunk-ILQUH444.js.map +1 -0
  40. package/dist/chunk-IXMWZJLV.js +616 -0
  41. package/dist/chunk-IXMWZJLV.js.map +1 -0
  42. package/dist/chunk-KZIGRIQG.js +75 -0
  43. package/dist/chunk-KZIGRIQG.js.map +1 -0
  44. package/dist/chunk-OF5M6R2S.js +769 -0
  45. package/dist/chunk-OF5M6R2S.js.map +1 -0
  46. package/dist/chunk-PYYLHUV6.js +3 -0
  47. package/dist/chunk-PYYLHUV6.js.map +1 -0
  48. package/dist/chunk-QO5AGZFP.js +159 -0
  49. package/dist/chunk-QO5AGZFP.js.map +1 -0
  50. package/dist/chunk-QUMTBLNE.js +76 -0
  51. package/dist/chunk-QUMTBLNE.js.map +1 -0
  52. package/dist/chunk-R5Z7NYLH.js +126 -0
  53. package/dist/chunk-R5Z7NYLH.js.map +1 -0
  54. package/dist/chunk-SZYWG5IB.js +75 -0
  55. package/dist/chunk-SZYWG5IB.js.map +1 -0
  56. package/dist/chunk-U3XT35GZ.js +202 -0
  57. package/dist/chunk-U3XT35GZ.js.map +1 -0
  58. package/dist/chunk-UGELTUIZ.js +830 -0
  59. package/dist/chunk-UGELTUIZ.js.map +1 -0
  60. package/dist/chunk-VR36QVX2.js +122 -0
  61. package/dist/chunk-VR36QVX2.js.map +1 -0
  62. package/dist/chunk-WUOQK7BO.js +13 -0
  63. package/dist/chunk-WUOQK7BO.js.map +1 -0
  64. package/dist/chunk-X6PV5MHG.js +582 -0
  65. package/dist/chunk-X6PV5MHG.js.map +1 -0
  66. package/dist/chunk-ZWLMFLLH.js +534 -0
  67. package/dist/chunk-ZWLMFLLH.js.map +1 -0
  68. package/dist/content/index.d.ts +309 -0
  69. package/dist/content/index.js +6 -0
  70. package/dist/content/index.js.map +1 -0
  71. package/dist/core/index.d.ts +107 -0
  72. package/dist/core/index.js +5 -0
  73. package/dist/core/index.js.map +1 -0
  74. package/dist/core/react.d.ts +107 -0
  75. package/dist/core/react.js +5 -0
  76. package/dist/core/react.js.map +1 -0
  77. package/dist/coupon-CHFcw7cd.d.ts +632 -0
  78. package/dist/coupon-zGkvO-Xx.d.ts +129 -0
  79. package/dist/crud.factory-DyKaPHcU.d.ts +181 -0
  80. package/dist/finance/index.d.ts +81 -0
  81. package/dist/finance/index.js +5 -0
  82. package/dist/finance/index.js.map +1 -0
  83. package/dist/finance-BJdfKRw0.d.ts +135 -0
  84. package/dist/index.d.ts +31 -0
  85. package/dist/index.js +29 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/inventory/index.d.ts +512 -0
  88. package/dist/inventory/index.js +16 -0
  89. package/dist/inventory/index.js.map +1 -0
  90. package/dist/inventory-DCiIZh8P.d.ts +742 -0
  91. package/dist/logistics/index.d.ts +226 -0
  92. package/dist/logistics/index.js +7 -0
  93. package/dist/logistics/index.js.map +1 -0
  94. package/dist/logistics-V8a9lUN3.d.ts +428 -0
  95. package/dist/media-CNLJK93J.d.ts +721 -0
  96. package/dist/movement-7MV3ADY5.js +5 -0
  97. package/dist/movement-7MV3ADY5.js.map +1 -0
  98. package/dist/payment-BRboLqvU.d.ts +127 -0
  99. package/dist/payments/index.d.ts +55 -0
  100. package/dist/payments/index.js +6 -0
  101. package/dist/payments/index.js.map +1 -0
  102. package/dist/platform/index.d.ts +645 -0
  103. package/dist/platform/index.js +8 -0
  104. package/dist/platform/index.js.map +1 -0
  105. package/dist/pos-D1jkkFl0.d.ts +885 -0
  106. package/dist/product-p09zXkXB.d.ts +260 -0
  107. package/dist/purchase-24BGT2HA.js +5 -0
  108. package/dist/purchase-24BGT2HA.js.map +1 -0
  109. package/dist/request-652PS6VR.js +5 -0
  110. package/dist/request-652PS6VR.js.map +1 -0
  111. package/dist/sales/index.d.ts +585 -0
  112. package/dist/sales/index.js +9 -0
  113. package/dist/sales/index.js.map +1 -0
  114. package/dist/server.d.ts +120 -0
  115. package/dist/server.js +27 -0
  116. package/dist/server.js.map +1 -0
  117. package/dist/size-guide-DgjzjM5P.d.ts +554 -0
  118. package/dist/stock-DEApGC-w.d.ts +632 -0
  119. package/dist/stock-OOUW57VQ.js +5 -0
  120. package/dist/stock-OOUW57VQ.js.map +1 -0
  121. package/dist/supplier-OC6JAWV6.js +5 -0
  122. package/dist/supplier-OC6JAWV6.js.map +1 -0
  123. package/dist/transaction/index.d.ts +104 -0
  124. package/dist/transaction/index.js +8 -0
  125. package/dist/transaction/index.js.map +1 -0
  126. package/dist/transaction-BTmoHpWh.d.ts +428 -0
  127. package/dist/transaction-u5oaNuav.d.ts +84 -0
  128. package/dist/transfer-7SYSH3RG.js +5 -0
  129. package/dist/transfer-7SYSH3RG.js.map +1 -0
  130. package/dist/user-data-DdLjAGwO.d.ts +132 -0
  131. package/package.json +146 -0
@@ -0,0 +1,120 @@
1
+ export { configureSDK, getBaseUrl, getSDKConfig, handleApiRequest } from './core/index.js';
2
+ import { a as authApi } from './user-data-DdLjAGwO.js';
3
+ export { 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';
4
+ import { p as productApi, c as categoryApi, s as sizeGuideApi } from './size-guide-DgjzjM5P.js';
5
+ import { M as cartApi, N as orderApi, Q as customerApi, V as posApi } from './pos-D1jkkFl0.js';
6
+ import { t as transactionApi } from './transaction-u5oaNuav.js';
7
+ import { c as couponApi, u as userApi, b as branchApi, p as platformConfigApi } from './coupon-CHFcw7cd.js';
8
+ import { m as mediaApi, g as getCmsPage, u as updateCmsPage } from './media-CNLJK93J.js';
9
+ import { p as paymentApi } from './payment-BRboLqvU.js';
10
+ import { f as financeApi } from './finance-BJdfKRw0.js';
11
+ import { l as logisticsApi } from './logistics-V8a9lUN3.js';
12
+ import { s as stockApi, p as purchaseApi, t as transferApi, a as adjustmentApi, m as movementApi, r as requestApi, b as supplierApi } from './stock-DEApGC-w.js';
13
+ export { a as analyticsApi } from './analytics-DMcD-o8w.js';
14
+ import './api-factory-B_h4RKBm.js';
15
+ import './product-p09zXkXB.js';
16
+ import './inventory-DCiIZh8P.js';
17
+ import './transaction-BTmoHpWh.js';
18
+
19
+ /**
20
+ * @classytic/commerce-sdk - SDK Client Factory
21
+ *
22
+ * Create a configured SDK client instance for use in Next.js applications.
23
+ */
24
+
25
+ declare const cmsApi: {
26
+ getPage: typeof getCmsPage;
27
+ updatePage: typeof updateCmsPage;
28
+ };
29
+
30
+ /**
31
+ * SDK Client Configuration Options
32
+ */
33
+ interface CommerceSDKConfig {
34
+ /** Base URL for API requests (e.g., "https://api.example.com") */
35
+ baseUrl: string;
36
+ /** Default organization ID for multi-tenant support */
37
+ organizationId?: string;
38
+ /** Function to get current auth token */
39
+ getToken?: () => string | null | Promise<string | null>;
40
+ /** Default request cache mode */
41
+ cache?: RequestCache;
42
+ /** Default headers to include in all requests */
43
+ headers?: Record<string, string>;
44
+ }
45
+ /**
46
+ * Commerce SDK Client
47
+ *
48
+ * Provides typed access to all commerce APIs.
49
+ */
50
+ interface CommerceSDKClient {
51
+ auth: typeof authApi;
52
+ product: typeof productApi;
53
+ category: typeof categoryApi;
54
+ sizeGuide: typeof sizeGuideApi;
55
+ cart: typeof cartApi;
56
+ order: typeof orderApi;
57
+ coupon: typeof couponApi;
58
+ customer: typeof customerApi;
59
+ user: typeof userApi;
60
+ branch: typeof branchApi;
61
+ media: typeof mediaApi;
62
+ payment: typeof paymentApi;
63
+ transaction: typeof transactionApi;
64
+ finance: typeof financeApi;
65
+ logistics: typeof logisticsApi;
66
+ platform: typeof platformConfigApi;
67
+ cms: typeof cmsApi;
68
+ pos: typeof posApi;
69
+ inventory: {
70
+ stock: typeof stockApi;
71
+ purchase: typeof purchaseApi;
72
+ transfer: typeof transferApi;
73
+ adjustment: typeof adjustmentApi;
74
+ movement: typeof movementApi;
75
+ request: typeof requestApi;
76
+ supplier: typeof supplierApi;
77
+ };
78
+ }
79
+ /**
80
+ * Create a configured Commerce SDK client
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // In your app initialization
85
+ * import { createCommerceSDK } from '@classytic/commerce-sdk';
86
+ *
87
+ * const sdk = createCommerceSDK({
88
+ * baseUrl: process.env.NEXT_PUBLIC_API_URL!,
89
+ * getToken: () => getCookie('token'),
90
+ * organizationId: 'org_123',
91
+ * });
92
+ *
93
+ * // Use the SDK
94
+ * const products = await sdk.product.getAll({ params: { page: 1 } });
95
+ * const order = await sdk.order.create({ token, data: orderData });
96
+ * ```
97
+ */
98
+ declare function createCommerceSDK(config: CommerceSDKConfig): CommerceSDKClient;
99
+ /**
100
+ * Initialize SDK configuration without creating a client
101
+ *
102
+ * Useful when you want to configure the SDK globally and use
103
+ * individual API instances directly.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * import { initCommerceSDK, productApi } from '@classytic/commerce-sdk';
108
+ *
109
+ * // Initialize once at app startup
110
+ * initCommerceSDK({
111
+ * baseUrl: process.env.NEXT_PUBLIC_API_URL!,
112
+ * });
113
+ *
114
+ * // Use APIs directly
115
+ * const products = await productApi.getAll({ params: { page: 1 } });
116
+ * ```
117
+ */
118
+ declare function initCommerceSDK(config: CommerceSDKConfig): void;
119
+
120
+ export { type CommerceSDKClient, type CommerceSDKConfig, adjustmentApi, authApi, branchApi, cartApi, categoryApi, couponApi, createCommerceSDK, customerApi, financeApi, getCmsPage, initCommerceSDK, logisticsApi, mediaApi, movementApi, orderApi, paymentApi, platformConfigApi, posApi, productApi, purchaseApi, requestApi, sizeGuideApi, stockApi, supplierApi, transactionApi, transferApi, updateCmsPage, userApi };
package/dist/server.js ADDED
@@ -0,0 +1,27 @@
1
+ export { createCommerceSDK, initCommerceSDK } from './chunk-QUMTBLNE.js';
2
+ export { logisticsApi } from './chunk-5L6EXDGH.js';
3
+ export { financeApi } from './chunk-EIVYT3HM.js';
4
+ export { transactionApi } from './chunk-5ZFW3FEI.js';
5
+ export { getCmsPage, mediaApi, updateCmsPage } from './chunk-ZWLMFLLH.js';
6
+ export { branchApi, couponApi, platformConfigApi, userApi } from './chunk-OF5M6R2S.js';
7
+ export { paymentApi } from './chunk-ILQUH444.js';
8
+ export { analyticsApi } from './chunk-4ZQK3FFN.js';
9
+ export { authApi, createUser, forgetPassApi, getProfile, getUser, getUserByPhone, loginApi, registerApi, resetPassApi, tokenRefreshApi, updateUser, verifyManagerAuth } from './chunk-BDA2WSJA.js';
10
+ export { categoryApi, productApi, sizeGuideApi } from './chunk-X6PV5MHG.js';
11
+ import './chunk-PYYLHUV6.js';
12
+ export { cartApi, customerApi, orderApi } from './chunk-UGELTUIZ.js';
13
+ import './chunk-IXMWZJLV.js';
14
+ export { purchaseApi } from './chunk-6RYGA6MF.js';
15
+ export { transferApi } from './chunk-FA7QFJ2G.js';
16
+ export { requestApi } from './chunk-QO5AGZFP.js';
17
+ export { movementApi } from './chunk-SZYWG5IB.js';
18
+ export { adjustmentApi } from './chunk-R5Z7NYLH.js';
19
+ export { supplierApi } from './chunk-WUOQK7BO.js';
20
+ export { stockApi } from './chunk-KZIGRIQG.js';
21
+ export { posApi } from './chunk-66OQAZSL.js';
22
+ import './chunk-I5TIKUIQ.js';
23
+ import './chunk-B6MPVOV7.js';
24
+ import './chunk-U3XT35GZ.js';
25
+ export { configureSDK, getBaseUrl, getSDKConfig, handleApiRequest } from './chunk-VR36QVX2.js';
26
+ //# sourceMappingURL=server.js.map
27
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"server.js"}
@@ -0,0 +1,554 @@
1
+ import { B as BaseApi, A as ApiResponse, P as PaginatedResponse } from './api-factory-B_h4RKBm.js';
2
+ import { e as Product, C as CreateProductPayload, U as UpdateProductPayload, i as ProductSyncStockResponse } from './product-p09zXkXB.js';
3
+
4
+ /**
5
+ * Category Types
6
+ *
7
+ * Source of truth: modules/commerce/category/category.model.js
8
+ *
9
+ * **Slug-Based Design:**
10
+ * - Products store `category` as slug string (not ObjectId)
11
+ * - Enables fast queries without $lookup/aggregation
12
+ * - Example: `db.products.find({ category: "electronics" })`
13
+ *
14
+ * **Product Count:**
15
+ * - Automatically maintained via product repository events
16
+ * - Increments on product create
17
+ * - Decrements on product delete
18
+ * - Updates when product changes category
19
+ */
20
+ interface CategoryImage {
21
+ url?: string;
22
+ alt?: string;
23
+ }
24
+ interface CategorySeo {
25
+ title?: string;
26
+ description?: string;
27
+ keywords?: string[];
28
+ }
29
+ interface Category {
30
+ _id: string;
31
+ /** Display name (can be changed without breaking product references) */
32
+ name: string;
33
+ /**
34
+ * URL-safe identifier (auto-generated from name, globally unique).
35
+ * Products store this value in their `category` field.
36
+ * IMMUTABLE after creation.
37
+ */
38
+ slug: string;
39
+ /**
40
+ * Parent category slug (not ObjectId).
41
+ * null for root categories.
42
+ */
43
+ parent: string | null;
44
+ /** Short description for category listing */
45
+ description?: string;
46
+ /** Category image for display */
47
+ image?: CategoryImage;
48
+ /** Display order for sorting (lower = first) */
49
+ displayOrder: number;
50
+ /**
51
+ * Category-specific VAT rate override.
52
+ * null = use platform default rate.
53
+ */
54
+ vatRate?: number | null;
55
+ /** Whether category is visible to customers */
56
+ isActive: boolean;
57
+ /**
58
+ * Cached product count (maintained by product repository events).
59
+ * Updated automatically on product create/delete/category-change.
60
+ */
61
+ productCount: number;
62
+ /** SEO metadata */
63
+ seo?: CategorySeo;
64
+ createdAt: string;
65
+ updatedAt: string;
66
+ /** Full path e.g. "clothing/t-shirts" */
67
+ fullPath?: string;
68
+ /** Whether this is a root category (no parent) */
69
+ isRoot?: boolean;
70
+ }
71
+ /**
72
+ * Category with nested children for tree display
73
+ * Used for navigation menus and admin selects
74
+ *
75
+ * **To flatten for dropdowns:**
76
+ * ```typescript
77
+ * function flattenTree(nodes, depth = 0, result = []) {
78
+ * for (const n of nodes) {
79
+ * result.push({ ...n, depth, displayName: ' '.repeat(depth) + n.name });
80
+ * if (n.children) flattenTree(n.children, depth + 1, result);
81
+ * }
82
+ * return result;
83
+ * }
84
+ * ```
85
+ */
86
+ interface CategoryTreeNode extends Category {
87
+ /** Child categories (empty array for leaf nodes) */
88
+ children?: CategoryTreeNode[];
89
+ }
90
+ interface CreateCategoryPayload {
91
+ /** Required: Display name (slug auto-generated from this) */
92
+ name: string;
93
+ /** Parent category slug (not ObjectId) */
94
+ parent?: string;
95
+ /** Short description */
96
+ description?: string;
97
+ /** Category image */
98
+ image?: CategoryImage;
99
+ /** Display order (lower = first, default: 0) */
100
+ displayOrder?: number;
101
+ /** VAT rate override (null = use platform default) */
102
+ vatRate?: number | null;
103
+ /** Whether visible to customers (default: true) */
104
+ isActive?: boolean;
105
+ /** SEO metadata */
106
+ seo?: CategorySeo;
107
+ }
108
+ interface UpdateCategoryPayload {
109
+ /** Display name (slug is immutable, cannot be changed) */
110
+ name?: string;
111
+ /** Short description */
112
+ description?: string;
113
+ /** Category image */
114
+ image?: CategoryImage;
115
+ /** Display order */
116
+ displayOrder?: number;
117
+ /** VAT rate override */
118
+ vatRate?: number | null;
119
+ /** Visibility */
120
+ isActive?: boolean;
121
+ /** SEO metadata */
122
+ seo?: CategorySeo;
123
+ }
124
+ /**
125
+ * Response from GET /categories (paginated list)
126
+ */
127
+ interface CategoryListResponse {
128
+ success: boolean;
129
+ method: "offset";
130
+ docs: Category[];
131
+ page: number;
132
+ limit: number;
133
+ total: number;
134
+ pages: number;
135
+ hasNext: boolean;
136
+ hasPrev: boolean;
137
+ }
138
+ /**
139
+ * Response from GET /categories/tree
140
+ */
141
+ interface CategoryTreeResponse {
142
+ success: boolean;
143
+ data: CategoryTreeNode[];
144
+ }
145
+ /**
146
+ * Response from GET /categories/:id or /categories/slug/:slug
147
+ */
148
+ interface CategoryResponse {
149
+ success: boolean;
150
+ data: Category;
151
+ }
152
+ /**
153
+ * Response from DELETE /categories/:id
154
+ */
155
+ interface CategoryDeleteResponse {
156
+ success: boolean;
157
+ deleted: boolean;
158
+ message?: string;
159
+ }
160
+ /**
161
+ * Response from POST /categories/sync-product-count
162
+ */
163
+ interface CategorySyncResponse {
164
+ success: boolean;
165
+ data: {
166
+ updated: number;
167
+ };
168
+ }
169
+
170
+ /**
171
+ * Size Guide Types
172
+ *
173
+ * Size guides are templates that can be referenced by products to display size information.
174
+ * Products store `sizeGuideSlug` to reference a size guide.
175
+ *
176
+ * **Dynamic Measurements:**
177
+ * - `measurementLabels` define the columns (e.g., ["Chest", "Length", "Shoulder"])
178
+ * - Each size has a `measurements` object with key-value pairs
179
+ * - Keys are lowercase/underscored versions of labels (e.g., "chest", "length")
180
+ */
181
+ interface SizeDefinition {
182
+ /** Size name (e.g., "XS", "S", "M", "L", "XL") */
183
+ name: string;
184
+ /**
185
+ * Key-value pairs of measurements.
186
+ * Keys should match measurementLabels (lowercase, underscored).
187
+ * Values are strings to support ranges (e.g., "34-36").
188
+ */
189
+ measurements: Record<string, string>;
190
+ }
191
+ interface SizeGuide {
192
+ _id: string;
193
+ /** Size guide name (e.g., "T-Shirts & Tops") */
194
+ name: string;
195
+ /**
196
+ * URL-safe identifier (auto-generated from name, globally unique).
197
+ * Products store this value in their `sizeGuideSlug` field.
198
+ */
199
+ slug: string;
200
+ /** Size guide description (max 500 chars) */
201
+ description?: string;
202
+ /** Measurement unit: 'inches' or 'cm' */
203
+ measurementUnit: 'inches' | 'cm';
204
+ /**
205
+ * Array of measurement labels (e.g., ["Chest", "Length", "Shoulder", "Sleeve"]).
206
+ * Used as table column headers. Max 10 labels.
207
+ */
208
+ measurementLabels: string[];
209
+ /** Array of size definitions with measurements */
210
+ sizes: SizeDefinition[];
211
+ /** Additional notes for customers (max 1000 chars) */
212
+ note?: string;
213
+ /** Whether size guide is visible to customers */
214
+ isActive: boolean;
215
+ /** Display order for sorting (lower = first) */
216
+ displayOrder: number;
217
+ createdAt: string;
218
+ updatedAt: string;
219
+ }
220
+ interface CreateSizeGuidePayload {
221
+ /** Required: Size guide name (slug auto-generated from this) */
222
+ name: string;
223
+ /** Custom slug (optional, auto-generated if not provided) */
224
+ slug?: string;
225
+ /** Size guide description */
226
+ description?: string;
227
+ /** Measurement unit (default: 'inches') */
228
+ measurementUnit?: 'inches' | 'cm';
229
+ /** Measurement labels (max 10) */
230
+ measurementLabels?: string[];
231
+ /** Size definitions */
232
+ sizes?: SizeDefinition[];
233
+ /** Additional notes */
234
+ note?: string;
235
+ /** Whether visible to customers (default: true) */
236
+ isActive?: boolean;
237
+ /** Display order (default: 0) */
238
+ displayOrder?: number;
239
+ }
240
+ interface UpdateSizeGuidePayload {
241
+ /** Size guide name */
242
+ name?: string;
243
+ /** Size guide description */
244
+ description?: string;
245
+ /** Measurement unit */
246
+ measurementUnit?: 'inches' | 'cm';
247
+ /** Measurement labels (replaces existing) */
248
+ measurementLabels?: string[];
249
+ /** Size definitions (replaces existing) */
250
+ sizes?: SizeDefinition[];
251
+ /** Additional notes */
252
+ note?: string;
253
+ /** Visibility */
254
+ isActive?: boolean;
255
+ /** Display order */
256
+ displayOrder?: number;
257
+ }
258
+ /**
259
+ * Response from GET /size-guides (paginated list)
260
+ */
261
+ interface SizeGuideListResponse {
262
+ success: boolean;
263
+ docs: SizeGuide[];
264
+ page: number;
265
+ limit: number;
266
+ total: number;
267
+ pages: number;
268
+ hasNext: boolean;
269
+ hasPrev: boolean;
270
+ }
271
+ /**
272
+ * Response from GET /size-guides/:id or /size-guides/slug/:slug
273
+ */
274
+ interface SizeGuideResponse {
275
+ success: boolean;
276
+ data: SizeGuide;
277
+ }
278
+ /**
279
+ * Response from DELETE /size-guides/:id
280
+ */
281
+ interface SizeGuideDeleteResponse {
282
+ success: boolean;
283
+ message?: string;
284
+ }
285
+
286
+ /**
287
+ * Product API Client
288
+ *
289
+ * **Authentication:**
290
+ * - Public: List, Get, GetBySlug, GetRecommendations
291
+ * - Admin: Create, Update, Delete, GetDeleted, Restore, HardDelete, SyncStock
292
+ *
293
+ * **Base URL:** `/api/v1/products`
294
+ */
295
+
296
+ type FetchOptions$2 = {
297
+ cache?: RequestCache;
298
+ revalidate?: number;
299
+ tags?: string[];
300
+ };
301
+ /**
302
+ * Product API Client
303
+ * Extends BaseApi with product-specific endpoints
304
+ */
305
+ declare class ProductApi extends BaseApi<Product, CreateProductPayload, UpdateProductPayload> {
306
+ constructor(config?: {});
307
+ /**
308
+ * Get product by slug
309
+ * GET /products/slug/:slug
310
+ * (Public endpoint)
311
+ *
312
+ * @param token - Auth token (optional, public endpoint)
313
+ * @param slug - Product slug
314
+ * @param options - Additional fetch options
315
+ * @returns Product object
316
+ */
317
+ getBySlug({ token, slug, options, }: {
318
+ token?: string | null;
319
+ slug: string;
320
+ options?: FetchOptions$2;
321
+ }): Promise<ApiResponse<Product>>;
322
+ /**
323
+ * Get product recommendations
324
+ * GET /products/:id/recommendations
325
+ * (Public endpoint)
326
+ *
327
+ * @param token - Auth token (optional)
328
+ * @param productId - Product ID to get recommendations for
329
+ * @param options - Additional fetch options
330
+ * @returns List of recommended products
331
+ */
332
+ getRecommendations({ token, productId, options, }: {
333
+ token?: string | null;
334
+ productId: string;
335
+ options?: FetchOptions$2;
336
+ }): Promise<ApiResponse<Product[]>>;
337
+ /**
338
+ * Get soft-deleted products (Recycle Bin)
339
+ * GET /products/deleted
340
+ * (Admin only)
341
+ *
342
+ * @param token - Auth token (required)
343
+ * @param params - Query parameters for pagination/filtering
344
+ * @param options - Additional fetch options
345
+ * @returns Paginated list of deleted products
346
+ */
347
+ getDeleted({ token, params, options, }: {
348
+ token: string;
349
+ params?: Record<string, unknown>;
350
+ options?: FetchOptions$2;
351
+ }): Promise<PaginatedResponse<Product>>;
352
+ /**
353
+ * Restore a soft-deleted product
354
+ * POST /products/:id/restore
355
+ * (Admin only)
356
+ *
357
+ * @param token - Auth token (required)
358
+ * @param id - Product ID to restore
359
+ * @param options - Additional fetch options
360
+ * @returns Restored product
361
+ */
362
+ restore({ token, id, options, }: {
363
+ token: string;
364
+ id: string;
365
+ options?: FetchOptions$2;
366
+ }): Promise<ApiResponse<Product>>;
367
+ /**
368
+ * Permanently delete a product (Hard delete)
369
+ * DELETE /products/:id?hard=true
370
+ * (Admin only - use with caution)
371
+ *
372
+ * @param token - Auth token (required)
373
+ * @param id - Product ID to permanently delete
374
+ * @param options - Additional fetch options
375
+ * @returns Delete confirmation
376
+ */
377
+ hardDelete({ token, id, options, }: {
378
+ token: string;
379
+ id: string;
380
+ options?: FetchOptions$2;
381
+ }): Promise<ApiResponse<{
382
+ deleted: boolean;
383
+ }>>;
384
+ /**
385
+ * Sync product stock quantity
386
+ * POST /products/:id/sync-stock
387
+ *
388
+ * Recomputes product.quantity by summing all StockEntry quantities across branches.
389
+ * (Requires: admin, warehouse-admin, warehouse-staff, or store-manager role)
390
+ *
391
+ * @param token - Auth token (required)
392
+ * @param id - Product ID to sync stock for
393
+ * @param options - Additional fetch options
394
+ * @returns Sync result with new quantity
395
+ */
396
+ syncStock({ token, id, options, }: {
397
+ token: string;
398
+ id: string;
399
+ options?: FetchOptions$2;
400
+ }): Promise<ProductSyncStockResponse>;
401
+ }
402
+ declare const productApi: ProductApi;
403
+
404
+ /**
405
+ * Category API Client
406
+ *
407
+ * **Authentication:**
408
+ * - Public: List, Get, Tree, GetBySlug
409
+ * - Admin: Create, Update, Delete
410
+ *
411
+ * **Base URL:** `/api/v1/categories`
412
+ *
413
+ * **Slug-Based Design:**
414
+ * - Categories use slugs as identifiers (not ObjectIds)
415
+ * - Products store category as slug string for fast queries
416
+ * - Example: `db.products.find({ category: "electronics" })`
417
+ */
418
+
419
+ type FetchOptions$1 = {
420
+ cache?: RequestCache;
421
+ revalidate?: number;
422
+ tags?: string[];
423
+ };
424
+ /**
425
+ * Category API Client
426
+ * Extends BaseApi with category-specific endpoints
427
+ */
428
+ declare class CategoryApi extends BaseApi<Category, CreateCategoryPayload, UpdateCategoryPayload> {
429
+ constructor(config?: {});
430
+ /**
431
+ * Get category tree (nested structure)
432
+ * GET /categories/tree
433
+ *
434
+ * **This is the main endpoint - FE should cache this and derive everything else from it.**
435
+ *
436
+ * Returns nested tree structure with children. Use helper functions to flatten, search, or extract children.
437
+ *
438
+ * @param token - Auth token (optional, public endpoint)
439
+ * @param options - Additional fetch options
440
+ * @returns Nested category tree
441
+ *
442
+ * @example
443
+ * ```typescript
444
+ * const { data } = await categoryApi.getTree({ token: null });
445
+ * // data = [{ slug: "clothing", name: "Clothing", children: [...] }]
446
+ * ```
447
+ */
448
+ getTree({ token, options, }?: {
449
+ token?: string | null;
450
+ options?: FetchOptions$1;
451
+ }): Promise<CategoryTreeResponse>;
452
+ /**
453
+ * Get category by slug
454
+ * GET /categories/slug/:slug
455
+ *
456
+ * For URL resolution when you need full category details.
457
+ *
458
+ * @param token - Auth token (optional, public endpoint)
459
+ * @param slug - Category slug (e.g., "electronics", "t-shirts")
460
+ * @param options - Additional fetch options
461
+ * @returns Category object
462
+ *
463
+ * @example
464
+ * ```typescript
465
+ * const { data } = await categoryApi.getBySlug({
466
+ * token: null,
467
+ * slug: 'electronics'
468
+ * });
469
+ * ```
470
+ */
471
+ getBySlug({ token, slug, options, }: {
472
+ token?: string | null;
473
+ slug: string;
474
+ options?: FetchOptions$1;
475
+ }): Promise<ApiResponse<Category>>;
476
+ /**
477
+ * Sync product counts for all categories
478
+ * POST /categories/sync-product-count
479
+ *
480
+ * Recalculates `productCount` for all categories based on current products.
481
+ * Use when manual data fixes or migrations may have desynced counts.
482
+ *
483
+ * @param token - Auth token (admin or inventory staff required)
484
+ * @param options - Additional fetch options
485
+ * @returns Number of categories updated
486
+ *
487
+ * @example
488
+ * ```typescript
489
+ * const { data } = await categoryApi.syncProductCount({ token });
490
+ * // data = { updated: 42 }
491
+ * ```
492
+ */
493
+ syncProductCount({ token, options, }: {
494
+ token: string;
495
+ options?: FetchOptions$1;
496
+ }): Promise<ApiResponse<{
497
+ updated: number;
498
+ }>>;
499
+ }
500
+ declare const categoryApi: CategoryApi;
501
+
502
+ /**
503
+ * Size Guide API Client
504
+ *
505
+ * **Authentication:**
506
+ * - Public: List, Get, GetBySlug
507
+ * - Admin: Create, Update, Delete
508
+ *
509
+ * **Base URL:** `/api/v1/size-guides`
510
+ *
511
+ * **Slug-Based Design:**
512
+ * - Size guides use slugs as identifiers
513
+ * - Products store `sizeGuideSlug` to reference a size guide
514
+ */
515
+
516
+ type FetchOptions = {
517
+ cache?: RequestCache;
518
+ revalidate?: number;
519
+ tags?: string[];
520
+ };
521
+ /**
522
+ * Size Guide API Client
523
+ * Extends BaseApi with size-guide-specific endpoints
524
+ */
525
+ declare class SizeGuideApi extends BaseApi<SizeGuide, CreateSizeGuidePayload, UpdateSizeGuidePayload> {
526
+ constructor(config?: {});
527
+ /**
528
+ * Get size guide by slug
529
+ * GET /size-guides/slug/:slug
530
+ *
531
+ * For product detail pages to fetch the appropriate size guide.
532
+ *
533
+ * @param token - Auth token (optional, public endpoint)
534
+ * @param slug - Size guide slug (e.g., "t-shirts-tops")
535
+ * @param options - Additional fetch options
536
+ * @returns Size guide object
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * const { data } = await sizeGuideApi.getBySlug({
541
+ * token: null,
542
+ * slug: 't-shirts-tops'
543
+ * });
544
+ * ```
545
+ */
546
+ getBySlug({ token, slug, options, }: {
547
+ token?: string | null;
548
+ slug: string;
549
+ options?: FetchOptions;
550
+ }): Promise<ApiResponse<SizeGuide>>;
551
+ }
552
+ declare const sizeGuideApi: SizeGuideApi;
553
+
554
+ export { CategoryApi as C, ProductApi as P, SizeGuideApi as S, type UpdateCategoryPayload as U, type CategoryImage as a, type CategorySeo as b, categoryApi as c, type Category as d, type CategoryTreeNode as e, type CreateCategoryPayload as f, type CategoryListResponse as g, type CategoryTreeResponse as h, type CategoryResponse as i, type CategoryDeleteResponse as j, type CategorySyncResponse as k, type SizeDefinition as l, type SizeGuide as m, type CreateSizeGuidePayload as n, type UpdateSizeGuidePayload as o, productApi as p, type SizeGuideListResponse as q, type SizeGuideResponse as r, sizeGuideApi as s, type SizeGuideDeleteResponse as t };