3a-ecommerce-utils 1.0.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.
Files changed (45) hide show
  1. package/README.md +163 -0
  2. package/dist/chunk-PEAZVBSD.mjs +597 -0
  3. package/dist/client-DYGi_pyp.d.mts +87 -0
  4. package/dist/client-DYGi_pyp.d.ts +87 -0
  5. package/dist/index.d.mts +496 -0
  6. package/dist/index.d.ts +496 -0
  7. package/dist/index.js +17707 -0
  8. package/dist/index.mjs +17043 -0
  9. package/dist/validation/server.d.mts +50 -0
  10. package/dist/validation/server.d.ts +50 -0
  11. package/dist/validation/server.js +518 -0
  12. package/dist/validation/server.mjs +168 -0
  13. package/package.json +69 -0
  14. package/src/api/address.queries.ts +96 -0
  15. package/src/api/category.queries.ts +85 -0
  16. package/src/api/coupon.queries.ts +120 -0
  17. package/src/api/dashboard.queries.ts +35 -0
  18. package/src/api/errorHandler.ts +164 -0
  19. package/src/api/graphqlClient.ts +113 -0
  20. package/src/api/index.ts +10 -0
  21. package/src/api/logger.client.ts +89 -0
  22. package/src/api/logger.ts +135 -0
  23. package/src/api/order.queries.ts +211 -0
  24. package/src/api/product.queries.ts +144 -0
  25. package/src/api/review.queries.ts +56 -0
  26. package/src/api/user.queries.ts +232 -0
  27. package/src/assets/3A.png +0 -0
  28. package/src/assets/index.ts +1 -0
  29. package/src/assets.d.ts +29 -0
  30. package/src/auth.ts +176 -0
  31. package/src/config/jest.backend.config.js +42 -0
  32. package/src/config/jest.frontend.config.js +50 -0
  33. package/src/config/postcss.config.js +6 -0
  34. package/src/config/tailwind.config.ts +70 -0
  35. package/src/config/tsconfig.base.json +36 -0
  36. package/src/config/vite.config.ts +86 -0
  37. package/src/config/vitest.base.config.ts +74 -0
  38. package/src/config/webpack.base.config.ts +126 -0
  39. package/src/constants/index.ts +312 -0
  40. package/src/cookies.ts +104 -0
  41. package/src/helpers.ts +400 -0
  42. package/src/index.ts +32 -0
  43. package/src/validation/client.ts +287 -0
  44. package/src/validation/index.ts +3 -0
  45. package/src/validation/server.ts +32 -0
@@ -0,0 +1,496 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { LogLevel } from '@e-commerce/types';
3
+ export { y as batchValidate, h as isValidCouponCode, i as isValidEmail, p as isValidObjectId, a as isValidPassword, d as isValidPhone, f as isValidPostalCode, t as isValidSku, r as isValidUrl, j as validateCouponCode, w as validateDate, x as validateDateRange, n as validateDiscountPercentage, v as validateEmail, c as validateName, q as validateObjectId, o as validatePagination, b as validatePassword, e as validatePhone, g as validatePostalCode, k as validatePrice, l as validateQuantity, m as validateRating, u as validateSku, s as validateUrl } from './client-DYGi_pyp.js';
4
+
5
+ interface AuthTokens {
6
+ accessToken: string;
7
+ refreshToken?: string;
8
+ expiresIn?: number;
9
+ }
10
+ interface StoredAuth {
11
+ user: any;
12
+ token: string;
13
+ expiresIn: number;
14
+ }
15
+ declare const storeAuth: (data: {
16
+ user: any;
17
+ accessToken: string;
18
+ refreshToken?: string;
19
+ expiresIn?: number;
20
+ }) => void;
21
+ declare const getStoredAuth: () => StoredAuth | null;
22
+ declare const isTokenExpired: () => boolean;
23
+ declare const willTokenExpireSoon: () => boolean;
24
+ declare const clearAuth: () => void;
25
+ declare const validateUserRole: (requiredRole: string) => boolean;
26
+ declare const getCurrentUser: () => any;
27
+ declare const getAccessToken: () => string | null;
28
+ declare const getRefreshToken: () => string | null;
29
+ declare const updateAccessToken: (newToken: string, expiresIn?: number) => void;
30
+ declare const setupAutoRefresh: (refreshFn: () => Promise<void>) => () => void;
31
+
32
+ /**
33
+ * Cookie utility functions for secure authentication storage
34
+ */
35
+ interface CookieOptions {
36
+ expires?: number;
37
+ path?: string;
38
+ domain?: string;
39
+ secure?: boolean;
40
+ sameSite?: 'Strict' | 'Lax' | 'None';
41
+ }
42
+ /**
43
+ * Set a cookie with the given name, value, and options
44
+ */
45
+ declare const setCookie: (name: string, value: string, options?: CookieOptions) => void;
46
+ /**
47
+ * Get a cookie value by name
48
+ */
49
+ declare const getCookie: (name: string) => string | null;
50
+ /**
51
+ * Remove a cookie by name
52
+ */
53
+ declare const removeCookie: (name: string, options?: CookieOptions) => void;
54
+ /**
55
+ * Check if cookies are enabled in the browser
56
+ */
57
+ declare const areCookiesEnabled: () => boolean;
58
+ declare const AUTH_COOKIE_NAMES: {
59
+ readonly ACCESS_TOKEN: "accessToken";
60
+ readonly REFRESH_TOKEN: "refreshToken";
61
+ readonly TOKEN_EXPIRY: "tokenExpiry";
62
+ readonly USER: "user";
63
+ };
64
+
65
+ declare const GET_USERS_QUERY = "\n query GetUsers($page: Int, $limit: Int, $search: String, $role: String) {\n users(page: $page, limit: $limit, search: $search, role: $role) {\n users {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n lastLogin\n }\n pagination {\n page\n limit\n total\n pages\n sellerCount\n adminCount\n customerCount\n }\n }\n }\n";
66
+ declare const GET_USER_QUERY = "\n query GetUser($id: ID!) {\n user(id: $id) {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n lastLogin\n }\n }\n";
67
+ declare const GET_USER_BY_ID_QUERY = "\n query GetUserById($id: ID!) {\n getUserById(id: $id) {\n user {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n lastLogin\n }\n accessToken\n refreshToken\n tokenExpiry\n }\n }\n";
68
+ declare const GET_ME_QUERY = "\n query GetMe {\n me {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n lastLogin\n }\n }\n";
69
+ declare const LOGIN_MUTATION = "\n mutation Login($input: LoginInput!) {\n login(input: $input) {\n user {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n }\n accessToken\n refreshToken\n }\n }\n";
70
+ declare const REGISTER_MUTATION = "\n mutation Register($input: RegisterInput!) {\n register(input: $input) {\n user {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n }\n accessToken\n refreshToken\n }\n }\n";
71
+ declare const GOOGLE_AUTH_MUTATION = "\n mutation GoogleAuth($input: GoogleAuthInput!) {\n googleAuth(input: $input) {\n user {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n profilePicture\n }\n accessToken\n refreshToken\n }\n }\n";
72
+ declare const LOGOUT_MUTATION = "\n mutation Logout {\n logout\n }\n";
73
+ declare const UPDATE_USER_ROLE_MUTATION = "\n mutation UpdateUserRole($id: ID!, $role: String!) {\n updateUserRole(id: $id, role: $role) {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n lastLogin\n }\n }\n";
74
+ declare const DELETE_USER_MUTATION = "\n mutation DeleteUser($id: ID!) {\n deleteUser(id: $id)\n }\n";
75
+ declare const SEND_VERIFICATION_EMAIL_MUTATION = "\n mutation SendVerificationEmail($source: String) {\n sendVerificationEmail(source: $source) {\n success\n message\n }\n }\n";
76
+ declare const VERIFY_EMAIL_MUTATION = "\n mutation VerifyEmail {\n verifyEmail {\n success\n message\n user {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n }\n }\n }\n";
77
+ declare const FORGOT_PASSWORD_MUTATION = "\n mutation ForgotPassword($email: String!, $role: String!) {\n forgotPassword(email: $email, role: $role) {\n success\n message\n resetToken\n resetUrl\n }\n }\n";
78
+ declare const RESET_PASSWORD_MUTATION = "\n mutation ResetPassword($token: String!, $password: String!, $confirmPassword: String!) {\n resetPassword(token: $token, password: $password, confirmPassword: $confirmPassword) {\n success\n message\n }\n }\n";
79
+ declare const VALIDATE_RESET_TOKEN_QUERY = "\n query ValidateResetToken($token: String!) {\n validateResetToken(token: $token) {\n success\n message\n email\n }\n }\n";
80
+ declare const UPDATE_PROFILE_MUTATION = "\n mutation UpdateProfile($input: UpdateProfileInput!) {\n updateProfile(input: $input) {\n success\n message\n user {\n id\n name\n email\n role\n isActive\n emailVerified\n createdAt\n }\n }\n }\n";
81
+
82
+ declare const GET_PRODUCTS_QUERY = "\n query GetProducts($page: Int, $limit: Int, $search: String, $category: String, $minPrice: Float, $maxPrice: Float, $sortBy: String, $sortOrder: String, $featured: Boolean, $includeInactive: Boolean) {\n products(page: $page, limit: $limit, search: $search, category: $category, minPrice: $minPrice, maxPrice: $maxPrice, sortBy: $sortBy, sortOrder: $sortOrder, featured: $featured, includeInactive: $includeInactive) {\n products {\n id\n name\n description\n price\n stock\n category\n sellerId\n isActive\n imageUrl\n tags\n rating\n reviewCount\n createdAt\n updatedAt\n }\n pagination {\n page\n limit\n total\n pages\n }\n }\n }\n";
83
+ declare const GET_PRODUCT_QUERY = "\n query GetProduct($id: ID!) {\n product(id: $id) {\n id\n name\n description\n price\n stock\n category\n sellerId\n seller {\n id\n name\n email\n }\n isActive\n imageUrl\n tags\n rating\n reviewCount\n createdAt\n updatedAt\n }\n }\n";
84
+ declare const GET_PRODUCTS_BY_SELLER_QUERY = "\n query GetProductsBySeller($sellerId: String!) {\n productsBySeller(sellerId: $sellerId) {\n id\n name\n description\n price\n stock\n category\n sellerId\n isActive\n imageUrl\n tags\n rating\n reviewCount\n createdAt\n updatedAt\n }\n }\n";
85
+ declare const CREATE_PRODUCT_MUTATION = "\n mutation CreateProduct($input: CreateProductInput!) {\n createProduct(input: $input) {\n id\n name\n description\n price\n stock\n category\n sellerId\n isActive\n imageUrl\n tags\n rating\n reviewCount\n createdAt\n updatedAt\n }\n }\n";
86
+ declare const UPDATE_PRODUCT_MUTATION = "\n mutation UpdateProduct($id: ID!, $input: UpdateProductInput!) {\n updateProduct(id: $id, input: $input) {\n id\n name\n description\n price\n stock\n category\n sellerId\n isActive\n imageUrl\n tags\n rating\n reviewCount\n createdAt\n updatedAt\n }\n }\n";
87
+ declare const DELETE_PRODUCT_MUTATION = "\n mutation DeleteProduct($id: ID!) {\n deleteProduct(id: $id)\n }\n";
88
+ declare const SEARCH_PRODUCTS_QUERY = "\n query SearchProducts($search: String!, $limit: Int) {\n searchProducts(search: $search, limit: $limit) {\n id\n name\n description\n price\n stock\n category\n sellerId\n isActive\n imageUrl\n tags\n rating\n reviewCount\n createdAt\n updatedAt\n }\n }\n";
89
+
90
+ declare const GET_ORDERS_QUERY = "\n query GetOrders($page: Int, $limit: Int, $customerId: String) {\n orders(page: $page, limit: $limit, customerId: $customerId) {\n orders {\n id\n orderNumber\n customerId\n customerEmail\n items {\n productId\n productName\n quantity\n price\n subtotal\n }\n subtotal\n tax\n shipping\n discount\n total\n orderStatus\n paymentStatus\n paymentMethod\n shippingAddress {\n street\n city\n state\n zip\n country\n }\n notes\n createdAt\n updatedAt\n }\n pagination {\n page\n limit\n total\n pages\n }\n }\n }\n";
91
+ declare const GET_ORDER_QUERY = "\n query GetOrder($id: ID!) {\n order(id: $id) {\n id\n orderNumber\n customerId\n customerEmail\n items {\n productId\n productName\n quantity\n price\n subtotal\n }\n subtotal\n tax\n shipping\n total\n orderStatus\n paymentStatus\n paymentMethod\n shippingAddress {\n street\n city\n state\n zip\n country\n }\n notes\n createdAt\n updatedAt\n }\n }\n";
92
+ declare const GET_ORDERS_BY_CUSTOMER_QUERY = "\n query GetOrdersByCustomer($customerId: String!) {\n ordersByCustomer(customerId: $customerId) {\n id\n orderNumber\n customerId\n customerEmail\n items {\n productId\n productName\n quantity\n price\n subtotal\n }\n subtotal\n tax\n shipping\n total\n orderStatus\n paymentStatus\n paymentMethod\n shippingAddress {\n street\n city\n state\n zip\n country\n }\n notes\n createdAt\n updatedAt\n }\n }\n";
93
+ declare const CREATE_ORDER_MUTATION = "\n mutation CreateOrder($input: CreateOrderInput!) {\n createOrder(input: $input) {\n order {\n id\n orderNumber\n customerId\n customerEmail\n sellerId\n items {\n productId\n productName\n quantity\n price\n sellerId\n subtotal\n }\n subtotal\n tax\n shipping\n discount\n couponCode\n total\n orderStatus\n paymentStatus\n paymentMethod\n shippingAddress {\n street\n city\n state\n zip\n country\n }\n notes\n createdAt\n updatedAt\n }\n orders {\n id\n orderNumber\n customerId\n customerEmail\n sellerId\n items {\n productId\n productName\n quantity\n price\n sellerId\n subtotal\n }\n subtotal\n tax\n shipping\n discount\n total\n orderStatus\n paymentStatus\n createdAt\n }\n orderCount\n }\n }\n";
94
+ declare const UPDATE_ORDER_STATUS_MUTATION = "\n mutation UpdateOrderStatus($id: ID!, $status: OrderStatus!) {\n updateOrderStatus(id: $id, status: $status) {\n id\n orderNumber\n orderStatus\n updatedAt\n }\n }\n";
95
+ declare const UPDATE_PAYMENT_STATUS_MUTATION = "\n mutation UpdatePaymentStatus($id: ID!, $status: PaymentStatus!) {\n updatePaymentStatus(id: $id, status: $status) {\n id\n orderNumber\n paymentStatus\n updatedAt\n }\n }\n";
96
+ declare const CANCEL_ORDER_MUTATION = "\n mutation CancelOrder($id: ID!) {\n cancelOrder(id: $id) {\n id\n orderNumber\n orderStatus\n updatedAt\n }\n }\n";
97
+
98
+ declare const GET_COUPONS_QUERY = "\n query GetCoupons($page: Int, $limit: Int, $isActive: Boolean, $search: String) {\n coupons(page: $page, limit: $limit, isActive: $isActive, search: $search) {\n coupons {\n id\n code\n description\n discountType\n discount\n minPurchase\n maxDiscount\n validFrom\n validTo\n usageLimit\n usageCount\n isActive\n createdAt\n updatedAt\n }\n pagination {\n page\n limit\n total\n pages\n }\n }\n }\n";
99
+ declare const GET_COUPON_QUERY = "\n query GetCoupon($id: ID!) {\n coupon(id: $id) {\n id\n code\n description\n discountType\n discount\n minPurchase\n maxDiscount\n validFrom\n validTo\n usageLimit\n usageCount\n isActive\n createdAt\n updatedAt\n }\n }\n";
100
+ declare const VALIDATE_COUPON_QUERY = "\n query ValidateCoupon($code: String!, $orderTotal: Float!) {\n validateCoupon(code: $code, orderTotal: $orderTotal) {\n valid\n discount\n discountValue\n finalTotal\n discountType\n message\n code\n }\n }\n";
101
+ declare const CREATE_COUPON_MUTATION = "\n mutation CreateCoupon($input: CreateCouponInput!) {\n createCoupon(input: $input) {\n id\n code\n description\n discountType\n discount\n minPurchase\n maxDiscount\n validFrom\n validTo\n usageLimit\n usageCount\n isActive\n createdAt\n updatedAt\n }\n }\n";
102
+ declare const UPDATE_COUPON_MUTATION = "\n mutation UpdateCoupon($id: ID!, $input: UpdateCouponInput!) {\n updateCoupon(id: $id, input: $input) {\n id\n code\n description\n discountType\n discount\n minPurchase\n maxDiscount\n validFrom\n validTo\n usageLimit\n usageCount\n isActive\n createdAt\n updatedAt\n }\n }\n";
103
+ declare const DELETE_COUPON_MUTATION = "\n mutation DeleteCoupon($id: ID!) {\n deleteCoupon(id: $id)\n }\n";
104
+ declare const TOGGLE_COUPON_STATUS_MUTATION = "\n mutation ToggleCouponStatus($id: ID!) {\n toggleCouponStatus(id: $id) {\n id\n isActive\n }\n }\n";
105
+
106
+ declare const GET_CATEGORIES_QUERY = "\n query GetCategories($filter: CategoryFilterInput) {\n categories(filter: $filter) {\n success\n message\n data {\n id\n name\n description\n icon\n slug\n isActive\n productCount\n createdAt\n updatedAt\n }\n count\n }\n }\n";
107
+ declare const GET_CATEGORY_QUERY = "\n query GetCategory($id: String!) {\n category(id: $id) {\n id\n name\n description\n icon\n slug\n isActive\n productCount\n createdAt\n updatedAt\n }\n }\n";
108
+ declare const CREATE_CATEGORY_MUTATION = "\n mutation CreateCategory($input: CategoryInput!) {\n createCategory(input: $input) {\n success\n message\n data {\n id\n name\n description\n icon\n slug\n isActive\n productCount\n createdAt\n updatedAt\n }\n }\n }\n";
109
+ declare const UPDATE_CATEGORY_MUTATION = "\n mutation UpdateCategory($id: ID!, $input: CategoryInput!) {\n updateCategory(id: $id, input: $input) {\n success\n message\n data {\n id\n name\n description\n icon\n slug\n isActive\n productCount\n createdAt\n updatedAt\n }\n }\n }\n";
110
+ declare const DELETE_CATEGORY_MUTATION = "\n mutation DeleteCategory($id: ID!) {\n deleteCategory(id: $id) {\n success\n message\n }\n }\n";
111
+
112
+ declare const DASHBOARD_STATS_QUERY = "\n query GetDashboardStats {\n dashboardStats {\n totalUsers\n totalOrders\n totalRevenue\n pendingOrders\n }\n }\n";
113
+ declare const SALES_ANALYTICS_QUERY = "\n query GetSalesAnalytics($period: String!) {\n salesAnalytics(period: $period) {\n daily {\n date\n sales\n orders\n revenue\n }\n weekly {\n date\n sales\n orders\n revenue\n }\n monthly {\n date\n sales\n orders\n revenue\n }\n }\n }\n";
114
+
115
+ declare const GET_PRODUCT_REVIEWS_QUERY = "\n query GetProductReviews($productId: ID!, $page: Int, $limit: Int) {\n productReviews(productId: $productId, page: $page, limit: $limit) {\n reviews {\n id\n productId\n userId\n userName\n rating\n comment\n helpful\n createdAt\n }\n pagination {\n page\n limit\n total\n pages\n }\n }\n }\n";
116
+ declare const CREATE_REVIEW_MUTATION = "\n mutation CreateReview($productId: ID!, $input: CreateReviewInput!) {\n createReview(productId: $productId, input: $input) {\n success\n message\n review {\n id\n productId\n userId\n userName\n rating\n comment\n helpful\n createdAt\n }\n }\n }\n";
117
+ declare const MARK_REVIEW_HELPFUL_MUTATION = "\n mutation MarkReviewHelpful($reviewId: ID!) {\n markReviewHelpful(reviewId: $reviewId) {\n id\n helpful\n }\n }\n";
118
+ declare const DELETE_REVIEW_MUTATION = "\n mutation DeleteReview($reviewId: ID!) {\n deleteReview(reviewId: $reviewId)\n }\n";
119
+
120
+ declare const GET_MY_ADDRESSES_QUERY = "\n query GetMyAddresses {\n myAddresses {\n addresses {\n id\n userId\n street\n city\n state\n zip\n country\n isDefault\n label\n createdAt\n updatedAt\n }\n }\n }\n";
121
+ declare const ADD_ADDRESS_MUTATION = "\n mutation AddAddress($input: AddAddressInput!) {\n addAddress(input: $input) {\n success\n message\n address {\n id\n userId\n street\n city\n state\n zip\n country\n isDefault\n label\n createdAt\n updatedAt\n }\n }\n }\n";
122
+ declare const UPDATE_ADDRESS_MUTATION = "\n mutation UpdateAddress($id: ID!, $input: UpdateAddressInput!) {\n updateAddress(id: $id, input: $input) {\n success\n message\n address {\n id\n userId\n street\n city\n state\n zip\n country\n isDefault\n label\n createdAt\n updatedAt\n }\n }\n }\n";
123
+ declare const DELETE_ADDRESS_MUTATION = "\n mutation DeleteAddress($id: ID!) {\n deleteAddress(id: $id) {\n success\n message\n }\n }\n";
124
+ declare const SET_DEFAULT_ADDRESS_MUTATION = "\n mutation SetDefaultAddress($id: ID!) {\n setDefaultAddress(id: $id) {\n success\n message\n address {\n id\n userId\n street\n city\n state\n zip\n country\n isDefault\n label\n createdAt\n updatedAt\n }\n }\n }\n";
125
+
126
+ interface GraphQLResponse<T = any> {
127
+ data?: T;
128
+ errors?: Array<{
129
+ message: string;
130
+ locations?: Array<{
131
+ line: number;
132
+ column: number;
133
+ }>;
134
+ path?: string[];
135
+ extensions?: any;
136
+ }>;
137
+ }
138
+ interface GraphQLClientConfig {
139
+ url: string;
140
+ headers?: Record<string, string>;
141
+ tokenStorageKey?: string;
142
+ onError?: (error: Error) => void;
143
+ }
144
+ declare class GraphQLClient {
145
+ private client;
146
+ private tokenStorageKey;
147
+ private onError?;
148
+ constructor(config: GraphQLClientConfig);
149
+ private setupInterceptors;
150
+ request<T = any>(query: string, variables?: Record<string, any>, config?: AxiosRequestConfig): Promise<T>;
151
+ setToken(token: string): void;
152
+ clearToken(): void;
153
+ getToken(): string | null;
154
+ }
155
+ declare function createGraphQLClient(config: GraphQLClientConfig): GraphQLClient;
156
+
157
+ interface LogEntry {
158
+ level: LogLevel;
159
+ message: string;
160
+ timestamp: string;
161
+ data?: any;
162
+ context?: string;
163
+ }
164
+ /**
165
+ * Client-safe Logger for frontend applications
166
+ * Uses console only, no file system access
167
+ */
168
+ declare class Logger {
169
+ private static logs;
170
+ private static maxLogs;
171
+ private static enableConsole;
172
+ static configure(options: {
173
+ maxLogs?: number;
174
+ enableConsole?: boolean;
175
+ }): void;
176
+ private static addLog;
177
+ private static format;
178
+ static debug(message: string, data?: any, context?: string): void;
179
+ static info(message: string, data?: any, context?: string): void;
180
+ static warn(message: string, data?: any, context?: string): void;
181
+ static error(message: string, error?: any, context?: string): void;
182
+ private static log;
183
+ static getLogs(level?: LogLevel): LogEntry[];
184
+ static clearLogs(): void;
185
+ }
186
+
187
+ /**
188
+ * Helper Utilities
189
+ * Commonly used utility functions across services and frontend apps
190
+ */
191
+ declare const capitalize: (str: string) => string;
192
+ declare const capitalizeWords: (str: string) => string;
193
+ declare const toTitleCase: (str: string) => string;
194
+ declare const slugify: (str: string) => string;
195
+ declare const generateRandomCode: (length?: number) => string;
196
+ declare const truncate: (str: string, length: number, suffix?: string) => string;
197
+ declare const formatCurrency: (amount: number, currency?: string) => string;
198
+ declare const formatNumber: (num: number, decimals?: number) => number;
199
+ declare const roundUp: (num: number, decimals?: number) => number;
200
+ declare const roundDown: (num: number, decimals?: number) => number;
201
+ declare const calculatePercentage: (value: number, percentage: number) => number;
202
+ declare const calculateDiscount: (price: number, discountPercent: number) => number;
203
+ declare const calculateTax: (amount: number, taxRate: number) => number;
204
+ declare const chunk: <T>(arr: T[], size: number) => T[][];
205
+ declare const unique: <T>(arr: T[]) => T[];
206
+ declare const removeDuplicates: <T extends Record<string, any>>(arr: T[], key: keyof T) => T[];
207
+ declare const groupBy: <T extends Record<string, any>>(arr: T[], key: keyof T) => Record<string, T[]>;
208
+ declare const sortBy: <T extends Record<string, any>>(arr: T[], key: keyof T, order?: "ASC" | "DESC") => T[];
209
+ declare const flatten: <T>(arr: T[][]) => T[];
210
+ declare const difference: <T>(arr1: T[], arr2: T[]) => T[];
211
+ declare const intersection: <T>(arr1: T[], arr2: T[]) => T[];
212
+ declare const omit: <T extends Record<string, any>>(obj: T, keys: (keyof T)[]) => Partial<T>;
213
+ declare const pick: <T extends Record<string, any>>(obj: T, keys: (keyof T)[]) => Partial<T>;
214
+ declare const deepMerge: <T extends Record<string, any>>(target: T, source: Partial<T>) => T;
215
+ declare const isEmpty: (obj: Record<string, any>) => boolean;
216
+ declare const getNestedValue: <T = any>(obj: Record<string, any>, path: string) => T | undefined;
217
+ declare const setNestedValue: (obj: Record<string, any>, path: string, value: any) => void;
218
+ declare const formatDate: (date: Date | string, format?: string) => string;
219
+ declare const addDays: (date: Date, days: number) => Date;
220
+ declare const addHours: (date: Date, hours: number) => Date;
221
+ declare const getDaysDifference: (date1: Date, date2: Date) => number;
222
+ declare const isDateInRange: (date: Date, startDate: Date, endDate: Date) => boolean;
223
+ declare const isFutureDate: (date: Date) => boolean;
224
+ declare const isPastDate: (date: Date) => boolean;
225
+ declare const delay: (ms: number) => Promise<void>;
226
+ declare const debounce: <T extends (...args: any[]) => any>(fn: T, wait: number) => ((...args: Parameters<T>) => void);
227
+ declare const throttle: <T extends (...args: any[]) => any>(fn: T, limit: number) => ((...args: Parameters<T>) => void);
228
+ declare const tryParse: <T = any>(json: string, fallback: T) => T;
229
+ declare const withErrorHandling: <T>(fn: () => Promise<T>) => Promise<{
230
+ success: boolean;
231
+ data?: T;
232
+ error?: string;
233
+ }>;
234
+ declare const createApiResponse: <T>(success: boolean, data?: T, message?: string, statusCode?: number) => {
235
+ success: boolean;
236
+ statusCode: number;
237
+ message: string;
238
+ data: {} | null;
239
+ };
240
+ declare const retry: <T>(fn: () => Promise<T>, maxAttempts?: number, delayMs?: number) => Promise<T>;
241
+ declare const isString: (val: unknown) => val is string;
242
+ declare const isNumber: (val: unknown) => val is number;
243
+ declare const isBoolean: (val: unknown) => val is boolean;
244
+ declare const isArray: (val: unknown) => val is unknown[];
245
+ declare const isObject: (val: unknown) => val is Record<string, unknown>;
246
+ declare const isFunction: (val: unknown) => val is Function;
247
+ declare const isNull: (val: unknown) => val is null;
248
+ declare const isUndefined: (val: unknown) => val is undefined;
249
+ declare const isNullOrUndefined: (val: unknown) => val is null | undefined;
250
+ declare const formatIndianCompact: (num?: number) => string;
251
+ declare function formatPrice(price: number): string;
252
+ declare function formatPriceShort(price: number): string;
253
+
254
+ declare const SHELL_APP_URL = "http://localhost:3000";
255
+ declare const ADMIN_APP_URL = "http://localhost:3001";
256
+ declare const SELLER_APP_URL = "http://localhost:3002";
257
+ declare const STOREFRONT_APP_URL = "http://localhost:3003";
258
+ declare const PORT_CONFIG: {
259
+ AUTH_SERVICE: number;
260
+ CATEGORY_SERVICE: number;
261
+ COUPON_SERVICE: number;
262
+ PRODUCT_SERVICE: number;
263
+ ORDER_SERVICE: number;
264
+ GRAPHQL_GATEWAY: number;
265
+ STOREFRONT_APP: number;
266
+ ADMIN_APP: number;
267
+ SELLER_APP: number;
268
+ SHELL_APP: number;
269
+ };
270
+ declare const SERVICE_URLS: {
271
+ AUTH_SERVICE: string;
272
+ CATEGORY_SERVICE: string;
273
+ COUPON_SERVICE: string;
274
+ PRODUCT_SERVICE: string;
275
+ ORDER_SERVICE: string;
276
+ GRAPHQL_GATEWAY: string;
277
+ AUTH_API: string;
278
+ CATEGORY_API: string;
279
+ COUPON_API: string;
280
+ PRODUCT_API: string;
281
+ ORDER_API: string;
282
+ };
283
+ declare const DATABASE_CONFIG: {
284
+ MONGODB_URI: string;
285
+ REDIS_URL: string;
286
+ };
287
+ declare const DEFAULT_CORS_ORIGINS: string[];
288
+ declare const JWT_CONFIG: {
289
+ ACCESS_TOKEN_EXPIRY: string;
290
+ REFRESH_TOKEN_EXPIRY: string;
291
+ PASSWORD_MIN_LENGTH: number;
292
+ PASSWORD_PATTERN: RegExp;
293
+ };
294
+ declare const PAGINATION: {
295
+ DEFAULT_PAGE: number;
296
+ DEFAULT_LIMIT: number;
297
+ DEFAULT_PAGE_SIZE: number;
298
+ MAX_PAGE_SIZE: number;
299
+ MIN_PAGE_SIZE: number;
300
+ DEFAULT_SORT_BY: string;
301
+ DEFAULT_SORT_ORDER: "DESC";
302
+ };
303
+ declare const PRODUCT_CONFIG: {
304
+ MIN_PRICE: number;
305
+ MAX_PRICE: number;
306
+ MIN_STOCK: number;
307
+ MAX_RATING: number;
308
+ MIN_RATING: number;
309
+ DEFAULT_RATING: number;
310
+ MAX_IMAGE_SIZE: number;
311
+ ALLOWED_IMAGE_TYPES: string[];
312
+ };
313
+ declare const ORDER_CONFIG: {
314
+ TAX_RATE: number;
315
+ SHIPPING_COST_STANDARD: number;
316
+ SHIPPING_COST_EXPRESS: number;
317
+ SHIPPING_COST_OVERNIGHT: number;
318
+ MIN_ORDER_AMOUNT: number;
319
+ MAX_ORDER_ITEMS: number;
320
+ };
321
+ declare const COUPON_CONFIG: {
322
+ CODE_LENGTH: number;
323
+ CODE_UPPERCASE: boolean;
324
+ MAX_DISCOUNT_PERCENTAGE: number;
325
+ MAX_DISCOUNT_FIXED: number;
326
+ MIN_PURCHASE_REQUIRED: number;
327
+ };
328
+ declare const API_ENDPOINTS: {
329
+ AUTH: {
330
+ LOGIN: string;
331
+ REGISTER: string;
332
+ LOGOUT: string;
333
+ PROFILE: string;
334
+ REFRESH: string;
335
+ VERIFY: string;
336
+ };
337
+ PRODUCTS: {
338
+ LIST: string;
339
+ CREATE: string;
340
+ GET: string;
341
+ UPDATE: string;
342
+ DELETE: string;
343
+ SEARCH: string;
344
+ };
345
+ ORDERS: {
346
+ LIST: string;
347
+ CREATE: string;
348
+ GET: string;
349
+ UPDATE: string;
350
+ CANCEL: string;
351
+ TRACK: string;
352
+ };
353
+ CATEGORIES: {
354
+ LIST: string;
355
+ CREATE: string;
356
+ GET: string;
357
+ UPDATE: string;
358
+ DELETE: string;
359
+ };
360
+ COUPONS: {
361
+ LIST: string;
362
+ CREATE: string;
363
+ GET: string;
364
+ UPDATE: string;
365
+ DELETE: string;
366
+ VALIDATE: string;
367
+ };
368
+ };
369
+ declare const HTTP_STATUS: {
370
+ OK: number;
371
+ CREATED: number;
372
+ NO_CONTENT: number;
373
+ BAD_REQUEST: number;
374
+ UNAUTHORIZED: number;
375
+ FORBIDDEN: number;
376
+ NOT_FOUND: number;
377
+ CONFLICT: number;
378
+ UNPROCESSABLE_ENTITY: number;
379
+ INTERNAL_SERVER_ERROR: number;
380
+ SERVICE_UNAVAILABLE: number;
381
+ };
382
+ declare const ERROR_MESSAGES: {
383
+ UNAUTHORIZED: string;
384
+ FORBIDDEN: string;
385
+ NO_TOKEN: string;
386
+ INVALID_TOKEN: string;
387
+ INVALID_CREDENTIALS: string;
388
+ USER_EXISTS: string;
389
+ USER_NOT_FOUND: string;
390
+ ACCOUNT_DEACTIVATED: string;
391
+ EMAIL_PASSWORD_MISMATCH: string;
392
+ NOT_FOUND: string;
393
+ VALIDATION_FAILED: string;
394
+ INTERNAL_ERROR: string;
395
+ SERVICE_UNAVAILABLE: string;
396
+ FAILED_TO_FETCH: string;
397
+ PRODUCT_NOT_FOUND: string;
398
+ INSUFFICIENT_STOCK: string;
399
+ FAILED_TO_GET_PRODUCTS: string;
400
+ FAILED_TO_CREATE_PRODUCT: string;
401
+ FAILED_TO_UPDATE_PRODUCT: string;
402
+ FAILED_TO_DELETE_PRODUCT: string;
403
+ CATEGORY_NOT_FOUND: string;
404
+ FAILED_TO_GET_CATEGORIES: string;
405
+ FAILED_TO_CREATE_CATEGORY: string;
406
+ FAILED_TO_UPDATE_CATEGORY: string;
407
+ FAILED_TO_DELETE_CATEGORY: string;
408
+ ORDER_NOT_FOUND: string;
409
+ INVALID_ORDER_STATUS: string;
410
+ FAILED_TO_GET_ORDERS: string;
411
+ FAILED_TO_CREATE_ORDER: string;
412
+ FAILED_TO_UPDATE_ORDER: string;
413
+ INVALID_COUPON: string;
414
+ COUPON_NOT_FOUND: string;
415
+ COUPON_EXPIRED: string;
416
+ COUPON_LIMIT_REACHED: string;
417
+ FAILED_TO_GET_COUPONS: string;
418
+ FAILED_TO_CREATE_COUPON: string;
419
+ FAILED_TO_UPDATE_COUPON: string;
420
+ FAILED_TO_DELETE_COUPON: string;
421
+ REVIEW_NOT_FOUND: string;
422
+ DUPLICATE_REVIEW: string;
423
+ OWN_REVIEW_ONLY: string;
424
+ FAILED_TO_GET_REVIEWS: string;
425
+ FAILED_TO_CREATE_REVIEW: string;
426
+ FAILED_TO_DELETE_REVIEW: string;
427
+ ADDRESS_NOT_FOUND: string;
428
+ FAILED_TO_GET_ADDRESSES: string;
429
+ };
430
+ declare const SUCCESS_MESSAGES: {
431
+ CREATED: string;
432
+ UPDATED: string;
433
+ DELETED: string;
434
+ FETCHED: string;
435
+ USER_REGISTERED: string;
436
+ LOGIN_SUCCESS: string;
437
+ LOGOUT_SUCCESS: string;
438
+ PROFILE_UPDATED: string;
439
+ PASSWORD_CHANGED: string;
440
+ PRODUCT_CREATED: string;
441
+ PRODUCT_UPDATED: string;
442
+ PRODUCT_DELETED: string;
443
+ CATEGORY_CREATED: string;
444
+ CATEGORY_UPDATED: string;
445
+ CATEGORY_DELETED: string;
446
+ ORDER_PLACED: string;
447
+ ORDER_UPDATED: string;
448
+ ORDER_CANCELLED: string;
449
+ COUPON_CREATED: string;
450
+ COUPON_UPDATED: string;
451
+ COUPON_DELETED: string;
452
+ COUPON_APPLIED: string;
453
+ REVIEW_SUBMITTED: string;
454
+ REVIEW_DELETED: string;
455
+ PAYMENT_SUCCESSFUL: string;
456
+ };
457
+ declare const CACHE_CONFIG: {
458
+ DASHBOARD_STATS_TTL: number;
459
+ DASHBOARD_STATS_REFETCH: number;
460
+ PRODUCTS_TTL: number;
461
+ CATEGORIES_TTL: number;
462
+ USER_PROFILE_TTL: number;
463
+ ORDERS_TTL: number;
464
+ };
465
+ declare const TIMEOUT_CONFIG: {
466
+ API_REQUEST: number;
467
+ DATABASE: number;
468
+ GRAPHQL: number;
469
+ };
470
+ declare const REGEX_PATTERNS: {
471
+ EMAIL: RegExp;
472
+ PHONE: RegExp;
473
+ POSTAL_CODE: RegExp;
474
+ COUPON_CODE: RegExp;
475
+ PRODUCT_SKU: RegExp;
476
+ URL: RegExp;
477
+ };
478
+ declare const ENV_PRESETS: {
479
+ DEVELOPMENT: {
480
+ corsOrigins: string[];
481
+ logLevel: string;
482
+ apiTimeout: number;
483
+ };
484
+ PRODUCTION: {
485
+ corsOrigins: string[];
486
+ logLevel: string;
487
+ apiTimeout: number;
488
+ };
489
+ TESTING: {
490
+ corsOrigins: string[];
491
+ logLevel: string;
492
+ apiTimeout: number;
493
+ };
494
+ };
495
+
496
+ export { ADD_ADDRESS_MUTATION, ADMIN_APP_URL, API_ENDPOINTS, AUTH_COOKIE_NAMES, type AuthTokens, CACHE_CONFIG, CANCEL_ORDER_MUTATION, COUPON_CONFIG, CREATE_CATEGORY_MUTATION, CREATE_COUPON_MUTATION, CREATE_ORDER_MUTATION, CREATE_PRODUCT_MUTATION, CREATE_REVIEW_MUTATION, DASHBOARD_STATS_QUERY, DATABASE_CONFIG, DEFAULT_CORS_ORIGINS, DELETE_ADDRESS_MUTATION, DELETE_CATEGORY_MUTATION, DELETE_COUPON_MUTATION, DELETE_PRODUCT_MUTATION, DELETE_REVIEW_MUTATION, DELETE_USER_MUTATION, ENV_PRESETS, ERROR_MESSAGES, FORGOT_PASSWORD_MUTATION, GET_CATEGORIES_QUERY, GET_CATEGORY_QUERY, GET_COUPONS_QUERY, GET_COUPON_QUERY, GET_ME_QUERY, GET_MY_ADDRESSES_QUERY, GET_ORDERS_BY_CUSTOMER_QUERY, GET_ORDERS_QUERY, GET_ORDER_QUERY, GET_PRODUCTS_BY_SELLER_QUERY, GET_PRODUCTS_QUERY, GET_PRODUCT_QUERY, GET_PRODUCT_REVIEWS_QUERY, GET_USERS_QUERY, GET_USER_BY_ID_QUERY, GET_USER_QUERY, GOOGLE_AUTH_MUTATION, GraphQLClient, type GraphQLClientConfig, type GraphQLResponse, HTTP_STATUS, JWT_CONFIG, LOGIN_MUTATION, LOGOUT_MUTATION, type LogEntry, Logger, MARK_REVIEW_HELPFUL_MUTATION, ORDER_CONFIG, PAGINATION, PORT_CONFIG, PRODUCT_CONFIG, REGEX_PATTERNS, REGISTER_MUTATION, RESET_PASSWORD_MUTATION, SALES_ANALYTICS_QUERY, SEARCH_PRODUCTS_QUERY, SELLER_APP_URL, SEND_VERIFICATION_EMAIL_MUTATION, SERVICE_URLS, SET_DEFAULT_ADDRESS_MUTATION, SHELL_APP_URL, STOREFRONT_APP_URL, SUCCESS_MESSAGES, type StoredAuth, TIMEOUT_CONFIG, TOGGLE_COUPON_STATUS_MUTATION, UPDATE_ADDRESS_MUTATION, UPDATE_CATEGORY_MUTATION, UPDATE_COUPON_MUTATION, UPDATE_ORDER_STATUS_MUTATION, UPDATE_PAYMENT_STATUS_MUTATION, UPDATE_PRODUCT_MUTATION, UPDATE_PROFILE_MUTATION, UPDATE_USER_ROLE_MUTATION, VALIDATE_COUPON_QUERY, VALIDATE_RESET_TOKEN_QUERY, VERIFY_EMAIL_MUTATION, addDays, addHours, areCookiesEnabled, calculateDiscount, calculatePercentage, calculateTax, capitalize, capitalizeWords, chunk, clearAuth, createApiResponse, createGraphQLClient, debounce, deepMerge, delay, difference, flatten, formatCurrency, formatDate, formatIndianCompact, formatNumber, formatPrice, formatPriceShort, generateRandomCode, getAccessToken, getCookie, getCurrentUser, getDaysDifference, getNestedValue, getRefreshToken, getStoredAuth, groupBy, intersection, isArray, isBoolean, isDateInRange, isEmpty, isFunction, isFutureDate, isNull, isNullOrUndefined, isNumber, isObject, isPastDate, isString, isTokenExpired, isUndefined, omit, pick, removeCookie, removeDuplicates, retry, roundDown, roundUp, setCookie, setNestedValue, setupAutoRefresh, slugify, sortBy, storeAuth, throttle, toTitleCase, truncate, tryParse, unique, updateAccessToken, validateUserRole, willTokenExpireSoon, withErrorHandling };