@exyconn/common 2.1.0 → 2.3.3

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 (142) hide show
  1. package/README.md +969 -261
  2. package/dist/client/hooks/index.d.mts +1042 -0
  3. package/dist/client/hooks/index.d.ts +1042 -0
  4. package/dist/client/hooks/index.js +2276 -0
  5. package/dist/client/hooks/index.js.map +1 -0
  6. package/dist/client/hooks/index.mjs +2217 -0
  7. package/dist/client/hooks/index.mjs.map +1 -0
  8. package/dist/client/http/index.d.mts +217 -49
  9. package/dist/client/http/index.d.ts +217 -49
  10. package/dist/client/http/index.js +473 -94
  11. package/dist/client/http/index.js.map +1 -1
  12. package/dist/client/http/index.mjs +441 -84
  13. package/dist/client/http/index.mjs.map +1 -1
  14. package/dist/client/index.d.mts +6 -4
  15. package/dist/client/index.d.ts +6 -4
  16. package/dist/client/index.js +481 -319
  17. package/dist/client/index.js.map +1 -1
  18. package/dist/client/index.mjs +449 -290
  19. package/dist/client/index.mjs.map +1 -1
  20. package/dist/client/utils/index.d.mts +3 -279
  21. package/dist/client/utils/index.d.ts +3 -279
  22. package/dist/client/web/index.d.mts +1461 -0
  23. package/dist/client/web/index.d.ts +1461 -0
  24. package/dist/client/web/index.js +2681 -0
  25. package/dist/client/web/index.js.map +1 -0
  26. package/dist/client/web/index.mjs +2618 -0
  27. package/dist/client/web/index.mjs.map +1 -0
  28. package/dist/data/brand-identity.d.mts +149 -0
  29. package/dist/data/brand-identity.d.ts +149 -0
  30. package/dist/data/brand-identity.js +235 -0
  31. package/dist/data/brand-identity.js.map +1 -0
  32. package/dist/data/brand-identity.mjs +220 -0
  33. package/dist/data/brand-identity.mjs.map +1 -0
  34. package/dist/data/countries.d.mts +61 -0
  35. package/dist/data/countries.d.ts +61 -0
  36. package/dist/data/countries.js +987 -0
  37. package/dist/data/countries.js.map +1 -0
  38. package/dist/data/countries.mjs +971 -0
  39. package/dist/data/countries.mjs.map +1 -0
  40. package/dist/data/currencies.d.mts +19 -0
  41. package/dist/data/currencies.d.ts +19 -0
  42. package/dist/data/currencies.js +162 -0
  43. package/dist/data/currencies.js.map +1 -0
  44. package/dist/data/currencies.mjs +153 -0
  45. package/dist/data/currencies.mjs.map +1 -0
  46. package/dist/data/index.d.mts +7 -0
  47. package/dist/data/index.d.ts +7 -0
  48. package/dist/data/index.js +2087 -0
  49. package/dist/data/index.js.map +1 -0
  50. package/dist/data/index.mjs +1948 -0
  51. package/dist/data/index.mjs.map +1 -0
  52. package/dist/data/phone-codes.d.mts +15 -0
  53. package/dist/data/phone-codes.d.ts +15 -0
  54. package/dist/data/phone-codes.js +219 -0
  55. package/dist/data/phone-codes.js.map +1 -0
  56. package/dist/data/phone-codes.mjs +211 -0
  57. package/dist/data/phone-codes.mjs.map +1 -0
  58. package/dist/data/regex.d.mts +287 -0
  59. package/dist/data/regex.d.ts +287 -0
  60. package/dist/data/regex.js +306 -0
  61. package/dist/data/regex.js.map +1 -0
  62. package/dist/data/regex.mjs +208 -0
  63. package/dist/data/regex.mjs.map +1 -0
  64. package/dist/data/timezones.d.mts +16 -0
  65. package/dist/data/timezones.d.ts +16 -0
  66. package/dist/data/timezones.js +98 -0
  67. package/dist/data/timezones.js.map +1 -0
  68. package/dist/data/timezones.mjs +89 -0
  69. package/dist/data/timezones.mjs.map +1 -0
  70. package/dist/index-BZf42T3R.d.mts +305 -0
  71. package/dist/index-CF0D8PGE.d.ts +305 -0
  72. package/dist/index-Ckhm_HaX.d.mts +138 -0
  73. package/dist/index-DKn4raO7.d.ts +222 -0
  74. package/dist/index-NS8dS0p9.d.mts +222 -0
  75. package/dist/index-Nqm5_lwT.d.ts +188 -0
  76. package/dist/index-br6POSyA.d.ts +138 -0
  77. package/dist/index-jBi3V6e5.d.mts +188 -0
  78. package/dist/index.d.mts +21 -580
  79. package/dist/index.d.ts +21 -580
  80. package/dist/index.js +1839 -347
  81. package/dist/index.js.map +1 -1
  82. package/dist/index.mjs +1850 -359
  83. package/dist/index.mjs.map +1 -1
  84. package/dist/packageCheck-B_qfsD6R.d.ts +280 -0
  85. package/dist/packageCheck-C2_FT_Rl.d.mts +280 -0
  86. package/dist/server/configs/index.d.mts +602 -0
  87. package/dist/server/configs/index.d.ts +602 -0
  88. package/dist/server/configs/index.js +707 -0
  89. package/dist/server/configs/index.js.map +1 -0
  90. package/dist/server/configs/index.mjs +665 -0
  91. package/dist/server/configs/index.mjs.map +1 -0
  92. package/dist/server/index.d.mts +4 -1
  93. package/dist/server/index.d.ts +4 -1
  94. package/dist/server/index.js +1330 -0
  95. package/dist/server/index.js.map +1 -1
  96. package/dist/server/index.mjs +1286 -2
  97. package/dist/server/index.mjs.map +1 -1
  98. package/dist/server/middleware/index.d.mts +283 -2
  99. package/dist/server/middleware/index.d.ts +283 -2
  100. package/dist/server/middleware/index.js +761 -0
  101. package/dist/server/middleware/index.js.map +1 -1
  102. package/dist/server/middleware/index.mjs +751 -1
  103. package/dist/server/middleware/index.mjs.map +1 -1
  104. package/dist/shared/config/index.d.mts +40 -0
  105. package/dist/shared/config/index.d.ts +40 -0
  106. package/dist/shared/config/index.js +58 -0
  107. package/dist/shared/config/index.js.map +1 -0
  108. package/dist/shared/config/index.mjs +51 -0
  109. package/dist/shared/config/index.mjs.map +1 -0
  110. package/dist/shared/constants/index.d.mts +593 -0
  111. package/dist/shared/constants/index.d.ts +593 -0
  112. package/dist/shared/constants/index.js +391 -0
  113. package/dist/shared/constants/index.js.map +1 -0
  114. package/dist/shared/constants/index.mjs +360 -0
  115. package/dist/shared/constants/index.mjs.map +1 -0
  116. package/dist/shared/index.d.mts +5 -1
  117. package/dist/shared/index.d.ts +5 -1
  118. package/dist/shared/types/index.d.mts +140 -0
  119. package/dist/shared/types/index.d.ts +140 -0
  120. package/dist/shared/types/index.js +4 -0
  121. package/dist/shared/types/index.js.map +1 -0
  122. package/dist/shared/types/index.mjs +3 -0
  123. package/dist/shared/types/index.mjs.map +1 -0
  124. package/dist/shared/utils/index.d.mts +255 -0
  125. package/dist/shared/utils/index.d.ts +255 -0
  126. package/dist/shared/utils/index.js +623 -0
  127. package/dist/shared/utils/index.js.map +1 -0
  128. package/dist/shared/utils/index.mjs +324 -0
  129. package/dist/shared/utils/index.mjs.map +1 -0
  130. package/dist/shared/validation/index.d.mts +258 -0
  131. package/dist/shared/validation/index.d.ts +258 -0
  132. package/dist/shared/validation/index.js +185 -0
  133. package/dist/shared/validation/index.js.map +1 -0
  134. package/dist/shared/validation/index.mjs +172 -0
  135. package/dist/shared/validation/index.mjs.map +1 -0
  136. package/package.json +127 -62
  137. package/dist/index-BcxL4_V4.d.ts +0 -2946
  138. package/dist/index-DEzgM15j.d.ts +0 -67
  139. package/dist/index-DNFVgQx8.d.ts +0 -1375
  140. package/dist/index-DbV04Dx8.d.mts +0 -67
  141. package/dist/index-DfqEP6Oe.d.mts +0 -1375
  142. package/dist/index-bvvCev9Q.d.mts +0 -2946
@@ -1,109 +1,466 @@
1
1
  import axios from 'axios';
2
2
 
3
- // src/client/http/axios-instance.ts
4
- var createHttpClient = (options) => {
5
- const {
6
- baseURL,
7
- timeout = 3e4,
8
- withCredentials = true,
9
- getAuthToken,
10
- onUnauthorized,
11
- onServerError
12
- } = options;
13
- const instance = axios.create({
14
- baseURL,
15
- timeout,
16
- withCredentials,
17
- headers: {
18
- "Content-Type": "application/json"
19
- }
20
- });
21
- instance.interceptors.request.use(
22
- (config) => {
23
- if (getAuthToken) {
24
- const token = getAuthToken();
25
- if (token && config.headers) {
26
- config.headers.Authorization = `Bearer ${token}`;
27
- }
3
+ // src/client/http/http.ts
4
+
5
+ // src/client/http/logger.ts
6
+ var Logger = class {
7
+ constructor() {
8
+ this.isDevelopment = typeof window !== "undefined" && window.location.hostname === "localhost";
9
+ }
10
+ /**
11
+ * Log informational messages
12
+ */
13
+ info(message, data, options) {
14
+ if (this.isDevelopment) {
15
+ const prefix = options?.context ? `[${options.context}]` : "";
16
+ console.log(`${prefix} ${message}`, data ?? "");
17
+ }
18
+ }
19
+ /**
20
+ * Log warning messages
21
+ */
22
+ warn(message, data, options) {
23
+ if (this.isDevelopment) {
24
+ const prefix = options?.context ? `[${options.context}]` : "";
25
+ console.warn(`${prefix} ${message}`, data ?? "");
26
+ }
27
+ }
28
+ /**
29
+ * Log error messages
30
+ */
31
+ error(message, error, options) {
32
+ const prefix = options?.context ? `[${options.context}]` : "";
33
+ if (this.isDevelopment) {
34
+ console.error(`${prefix} ${message}`, error, options?.metadata || "");
35
+ }
36
+ }
37
+ /**
38
+ * Log debug messages (only in development)
39
+ */
40
+ debug(message, data, options) {
41
+ if (this.isDevelopment) {
42
+ const prefix = options?.context ? `[${options.context}]` : "";
43
+ console.debug(`${prefix} ${message}`, data || "");
44
+ }
45
+ }
46
+ /**
47
+ * Log API errors with structured information
48
+ */
49
+ apiError(endpoint, error, metadata) {
50
+ this.error(`API Error: ${endpoint}`, error, {
51
+ context: "API",
52
+ metadata: {
53
+ endpoint,
54
+ ...metadata
28
55
  }
29
- return config;
30
- },
31
- (error) => Promise.reject(error)
32
- );
33
- instance.interceptors.response.use(
34
- (response) => response,
35
- (error) => {
36
- if (error.response) {
37
- const status = error.response.status;
38
- if (status === 401 && onUnauthorized) {
39
- onUnauthorized();
40
- }
41
- if (status >= 500 && onServerError) {
42
- onServerError(error);
43
- }
56
+ });
57
+ }
58
+ };
59
+ var logger = new Logger();
60
+
61
+ // src/client/http/response-parser.ts
62
+ var STATUS_CODES = {
63
+ SUCCESS: 200,
64
+ CREATED: 201,
65
+ NO_CONTENT: 204,
66
+ BAD_REQUEST: 400,
67
+ UNAUTHORIZED: 401,
68
+ FORBIDDEN: 403,
69
+ NOT_FOUND: 404,
70
+ CONFLICT: 409,
71
+ ERROR: 500
72
+ };
73
+ var STATUS_MESSAGES = {
74
+ SUCCESS: "success",
75
+ CREATED: "created",
76
+ NO_CONTENT: "no_content",
77
+ BAD_REQUEST: "bad_request",
78
+ UNAUTHORIZED: "unauthorized",
79
+ FORBIDDEN: "forbidden",
80
+ NOT_FOUND: "not_found",
81
+ CONFLICT: "conflict",
82
+ ERROR: "error"
83
+ };
84
+ var SUCCESS_CODES = [200, 201, 204];
85
+ var ERROR_CODES = [400, 401, 403, 404, 409, 500];
86
+ var parseResponseData = (response, fallback = null) => {
87
+ try {
88
+ if (!response || typeof response !== "object") {
89
+ return fallback;
90
+ }
91
+ const resp = response;
92
+ if ("data" in resp) {
93
+ return resp["data"] ?? fallback;
94
+ }
95
+ return response;
96
+ } catch (error) {
97
+ logger.error("Error parsing response data", error);
98
+ return fallback;
99
+ }
100
+ };
101
+ var parseResponseMessage = (response, fallback = "") => {
102
+ try {
103
+ if (!response || typeof response !== "object") {
104
+ return fallback;
105
+ }
106
+ const resp = response;
107
+ if ("message" in resp && typeof resp["message"] === "string") {
108
+ return resp["message"];
109
+ }
110
+ return fallback;
111
+ } catch (error) {
112
+ logger.error("Error parsing response message", error);
113
+ return fallback;
114
+ }
115
+ };
116
+ var parseResponseStatus = (response) => {
117
+ try {
118
+ if (!response || typeof response !== "object") {
119
+ return null;
120
+ }
121
+ const resp = response;
122
+ if ("statusCode" in resp && typeof resp["statusCode"] === "number") {
123
+ return resp["statusCode"];
124
+ }
125
+ if ("status" in resp && typeof resp["status"] === "number") {
126
+ return resp["status"];
127
+ }
128
+ return null;
129
+ } catch (error) {
130
+ logger.error("Error parsing response status", error);
131
+ return null;
132
+ }
133
+ };
134
+ var parseResponseStatusMessage = (response, fallback = "") => {
135
+ try {
136
+ if (!response || typeof response !== "object") {
137
+ return fallback;
138
+ }
139
+ const resp = response;
140
+ if ("status" in resp && typeof resp["status"] === "string") {
141
+ return resp["status"];
142
+ }
143
+ return fallback;
144
+ } catch (error) {
145
+ logger.error("Error parsing response status message", error);
146
+ return fallback;
147
+ }
148
+ };
149
+ var isSuccessResponse = (response) => {
150
+ try {
151
+ const statusCode = parseResponseStatus(response);
152
+ if (statusCode !== null) {
153
+ return SUCCESS_CODES.includes(statusCode);
154
+ }
155
+ const status = parseResponseStatusMessage(response);
156
+ return [STATUS_MESSAGES.SUCCESS, STATUS_MESSAGES.CREATED, STATUS_MESSAGES.NO_CONTENT].includes(
157
+ status
158
+ );
159
+ } catch (error) {
160
+ logger.error("Error checking response success", error);
161
+ return false;
162
+ }
163
+ };
164
+ var isErrorResponse = (response) => {
165
+ try {
166
+ const statusCode = parseResponseStatus(response);
167
+ if (statusCode !== null) {
168
+ return ERROR_CODES.includes(statusCode);
169
+ }
170
+ return false;
171
+ } catch (error) {
172
+ logger.error("Error checking response error", error);
173
+ return false;
174
+ }
175
+ };
176
+ var parsePaginatedResponse = (response) => {
177
+ try {
178
+ if (!response || typeof response !== "object") {
179
+ return { items: [], total: 0, page: 1, limit: 10 };
180
+ }
181
+ const resp = response;
182
+ let items = [];
183
+ if ("data" in resp && Array.isArray(resp["data"])) {
184
+ items = resp["data"];
185
+ }
186
+ let total = items.length;
187
+ let page = 1;
188
+ let limit = 10;
189
+ let totalPages;
190
+ if ("paginationData" in resp && resp["paginationData"] && typeof resp["paginationData"] === "object") {
191
+ const paginationData = resp["paginationData"];
192
+ if ("total" in paginationData && typeof paginationData["total"] === "number") {
193
+ total = paginationData["total"];
194
+ }
195
+ if ("page" in paginationData && typeof paginationData["page"] === "number") {
196
+ page = paginationData["page"];
197
+ }
198
+ if ("limit" in paginationData && typeof paginationData["limit"] === "number") {
199
+ limit = paginationData["limit"];
200
+ }
201
+ if ("totalPages" in paginationData && typeof paginationData["totalPages"] === "number") {
202
+ totalPages = paginationData["totalPages"];
44
203
  }
45
- return Promise.reject(error);
46
204
  }
47
- );
48
- return instance;
205
+ let columns;
206
+ if ("columns" in resp && Array.isArray(resp["columns"])) {
207
+ columns = resp["columns"];
208
+ }
209
+ return {
210
+ items,
211
+ total,
212
+ page,
213
+ limit,
214
+ ...totalPages !== void 0 && { totalPages },
215
+ ...columns !== void 0 && { columns }
216
+ };
217
+ } catch (error) {
218
+ logger.error("Error parsing paginated response", error);
219
+ return { items: [], total: 0, page: 1, limit: 10 };
220
+ }
49
221
  };
50
- var withFormData = () => ({
51
- headers: {
52
- "Content-Type": "multipart/form-data"
222
+ var extractNestedData = (response, path, fallback = null) => {
223
+ try {
224
+ const keys = path.split(".");
225
+ let current = response;
226
+ for (const key of keys) {
227
+ if (current && typeof current === "object" && key in current) {
228
+ current = current[key];
229
+ } else {
230
+ return fallback;
231
+ }
232
+ }
233
+ return current;
234
+ } catch (error) {
235
+ logger.error("Error extracting nested data", error);
236
+ return fallback;
53
237
  }
54
- });
55
- var withTimeout = (ms) => ({
56
- timeout: ms
57
- });
58
- var withAbortSignal = (signal) => ({
59
- signal
60
- });
61
-
62
- // src/client/http/response-parser.ts
63
- var parseResponse = (response) => {
64
- if (response.data?.success && response.data?.data !== void 0) {
65
- return response.data.data;
238
+ };
239
+ var safeJsonParse = (json, fallback = null) => {
240
+ try {
241
+ return JSON.parse(json);
242
+ } catch (error) {
243
+ logger.error("Error parsing JSON", error);
244
+ return fallback;
66
245
  }
67
- return null;
68
246
  };
69
- var parseFullResponse = (response) => {
70
- return response.data;
247
+ var parseAxiosErrorMessage = (error) => {
248
+ try {
249
+ if (!error || typeof error !== "object") {
250
+ return "An unexpected error occurred";
251
+ }
252
+ const err = error;
253
+ if ("response" in err && err["response"] && typeof err["response"] === "object") {
254
+ const response = err["response"];
255
+ if ("data" in response && response["data"] && typeof response["data"] === "object") {
256
+ const data = response["data"];
257
+ if ("data" in data && data["data"] && typeof data["data"] === "object") {
258
+ const nestedData = data["data"];
259
+ if ("message" in nestedData && typeof nestedData["message"] === "string") {
260
+ return nestedData["message"];
261
+ }
262
+ }
263
+ if ("message" in data && typeof data["message"] === "string") {
264
+ return data["message"];
265
+ }
266
+ if ("error" in data && typeof data["error"] === "string") {
267
+ return data["error"];
268
+ }
269
+ }
270
+ }
271
+ if ("message" in err && typeof err["message"] === "string") {
272
+ return err["message"];
273
+ }
274
+ if (typeof error === "string") {
275
+ return error;
276
+ }
277
+ return "An unexpected error occurred";
278
+ } catch (parseError2) {
279
+ logger.error("Error parsing axios error message", parseError2);
280
+ return "An unexpected error occurred";
281
+ }
71
282
  };
72
283
  var parseError = (error) => {
73
- if (error.response?.data?.message) {
74
- return error.response.data.message;
284
+ try {
285
+ if (!error || typeof error !== "object") {
286
+ return {
287
+ message: "An unexpected error occurred",
288
+ statusCode: null,
289
+ data: null
290
+ };
291
+ }
292
+ const err = error;
293
+ let statusCode = null;
294
+ let data = null;
295
+ let status;
296
+ if ("response" in err && err["response"] && typeof err["response"] === "object") {
297
+ const response = err["response"];
298
+ if ("status" in response && typeof response["status"] === "number") {
299
+ statusCode = response["status"];
300
+ }
301
+ if ("data" in response && response["data"] !== void 0) {
302
+ data = response["data"];
303
+ if (data && typeof data === "object" && "status" in data) {
304
+ const dataObj = data;
305
+ if (typeof dataObj["status"] === "string") {
306
+ status = dataObj["status"];
307
+ }
308
+ }
309
+ }
310
+ }
311
+ if (statusCode === null && "statusCode" in err && typeof err["statusCode"] === "number") {
312
+ statusCode = err["statusCode"];
313
+ }
314
+ if (data === null && "data" in err && err["data"] !== void 0) {
315
+ data = err["data"];
316
+ }
317
+ if (!status && "status" in err && typeof err["status"] === "string") {
318
+ status = err["status"];
319
+ }
320
+ return {
321
+ message: parseAxiosErrorMessage(error),
322
+ statusCode,
323
+ data,
324
+ ...status !== void 0 && { status }
325
+ };
326
+ } catch (err) {
327
+ logger.error("Error parsing error object", err);
328
+ return {
329
+ message: "An unexpected error occurred",
330
+ statusCode: null,
331
+ data: null
332
+ };
75
333
  }
76
- if (error.response?.data?.error) {
77
- return error.response.data.error;
334
+ };
335
+ var simpleParseResponse = (response) => {
336
+ return response?.data?.data?.data;
337
+ };
338
+ var simpleMetaParseResponse = (response) => {
339
+ return response?.data?.data?.meta;
340
+ };
341
+ var simpleParseDualDataResponse = (response) => {
342
+ return response?.data?.data;
343
+ };
344
+
345
+ // src/client/http/http.ts
346
+ var isDevelopment = typeof window !== "undefined" && window.location.hostname === "localhost";
347
+ var API_BASE_URL = isDevelopment ? "http://localhost:4002" : "https://service-api.exyconn.com";
348
+ var API_PREFIX = "/v1/api";
349
+ var axiosInstance = axios.create({
350
+ baseURL: API_BASE_URL,
351
+ timeout: 3e4,
352
+ // 30 seconds
353
+ headers: {
354
+ "Content-Type": "application/json"
78
355
  }
79
- if (error.code === "ERR_NETWORK") {
80
- return "Network error. Please check your connection.";
356
+ });
357
+ axiosInstance.interceptors.request.use(
358
+ (config) => {
359
+ try {
360
+ if (typeof window !== "undefined" && window.localStorage) {
361
+ const selectedOrg = localStorage.getItem("selectedOrganization");
362
+ if (selectedOrg) {
363
+ const org = JSON.parse(selectedOrg);
364
+ if (org && org._id) {
365
+ config.headers["x-organization-id"] = org._id;
366
+ }
367
+ }
368
+ }
369
+ } catch (error) {
370
+ logger.warn("Failed to read organization from localStorage", error);
371
+ }
372
+ return config;
373
+ },
374
+ (error) => {
375
+ return Promise.reject(error);
81
376
  }
82
- if (error.code === "ECONNABORTED") {
83
- return "Request timed out. Please try again.";
377
+ );
378
+ axiosInstance.interceptors.response.use(
379
+ (response) => response,
380
+ (error) => {
381
+ const parsedError = parseError(error);
382
+ logger.error("API Error", parsedError);
383
+ return Promise.reject(parsedError);
84
384
  }
85
- return error.message || "An unexpected error occurred.";
385
+ );
386
+ var buildHeaders = (customHeaders) => {
387
+ const headers = {
388
+ "Content-Type": "application/json",
389
+ ...customHeaders
390
+ };
391
+ return headers;
86
392
  };
87
- var isSuccess = (response) => {
88
- return response.data?.success === true;
393
+ var buildConfig = (params, customHeaders) => {
394
+ const config = {
395
+ headers: buildHeaders(customHeaders)
396
+ };
397
+ if (params) {
398
+ config.params = params;
399
+ }
400
+ return config;
401
+ };
402
+ var getRequest = async (url, params, customHeaders) => {
403
+ const config = buildConfig(params, customHeaders);
404
+ return axiosInstance.get(url, config);
89
405
  };
90
- var isStatusError = (error, statusCode) => {
91
- return error.response?.status === statusCode;
406
+ var postRequest = async (url, data, customHeaders) => {
407
+ const config = buildConfig(void 0, customHeaders);
408
+ return axiosInstance.post(url, data, config);
92
409
  };
93
- var isUnauthorized = (error) => {
94
- return isStatusError(error, 401);
410
+ var putRequest = async (url, data, customHeaders) => {
411
+ const config = buildConfig(void 0, customHeaders);
412
+ return axiosInstance.put(url, data, config);
95
413
  };
96
- var isForbidden = (error) => {
97
- return isStatusError(error, 403);
414
+ var patchRequest = async (url, data, customHeaders) => {
415
+ const config = buildConfig(void 0, customHeaders);
416
+ return axiosInstance.patch(url, data, config);
417
+ };
418
+ var deleteRequest = async (url, params, customHeaders) => {
419
+ const config = buildConfig(params, customHeaders);
420
+ return axiosInstance.delete(url, config);
421
+ };
422
+ var uploadFile = async (url, file, additionalData) => {
423
+ const formData = new FormData();
424
+ formData.append("file", file);
425
+ if (additionalData) {
426
+ Object.entries(additionalData).forEach(([key, value]) => {
427
+ formData.append(key, String(value));
428
+ });
429
+ }
430
+ const config = {
431
+ headers: {
432
+ "Content-Type": "multipart/form-data"
433
+ }
434
+ };
435
+ return axiosInstance.post(url, formData, config);
436
+ };
437
+ var extractData = (response) => {
438
+ return parseResponseData(response.data);
439
+ };
440
+ var extractMessage = (response) => {
441
+ return parseResponseMessage(response, "");
442
+ };
443
+ var isSuccess = (response) => {
444
+ return response.status >= 200 && response.status < 300;
445
+ };
446
+ var extractPaginatedData = (response) => {
447
+ return parsePaginatedResponse(response.data);
448
+ };
449
+
450
+ // src/client/http/slug.ts
451
+ var generateSlug = (text) => {
452
+ if (!text) return "";
453
+ return text.trim().replace(/[^\w\s]/g, "").replace(/\s+(.)/g, (_, char) => char.toUpperCase()).replace(/\s+/g, "").replace(/^(.)/, (_, char) => char.toLowerCase());
98
454
  };
99
- var isNotFound = (error) => {
100
- return isStatusError(error, 404);
455
+ var generateUrlSlug = (text) => {
456
+ if (!text) return "";
457
+ return text.trim().toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
101
458
  };
102
- var isServerError = (error) => {
103
- const status = error.response?.status;
104
- return status !== void 0 && status >= 500;
459
+ var generateSnakeSlug = (text) => {
460
+ if (!text) return "";
461
+ return text.trim().toLowerCase().replace(/[^\w\s]/g, "").replace(/\s+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
105
462
  };
106
463
 
107
- export { createHttpClient, isForbidden, isNotFound, isServerError, isStatusError, isSuccess, isUnauthorized, parseError, parseFullResponse, parseResponse, withAbortSignal, withFormData, withTimeout };
464
+ export { API_BASE_URL, API_PREFIX, ERROR_CODES, STATUS_CODES, STATUS_MESSAGES, SUCCESS_CODES, axiosInstance as axios, deleteRequest, extractData, extractMessage, extractNestedData, extractPaginatedData, generateSlug, generateSnakeSlug, generateUrlSlug, getRequest, isErrorResponse, isSuccess, isSuccessResponse, logger, parseAxiosErrorMessage, parseError, parsePaginatedResponse, parseResponseData, parseResponseMessage, parseResponseStatus, parseResponseStatusMessage, patchRequest, postRequest, putRequest, safeJsonParse, simpleMetaParseResponse, simpleParseDualDataResponse, simpleParseResponse, uploadFile };
108
465
  //# sourceMappingURL=index.mjs.map
109
466
  //# sourceMappingURL=index.mjs.map