@ecodrix/erix-api 1.1.8 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecodrix/erix-api",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "author": "ECODrIx Team <contact@ecodrix.com>",
5
5
  "license": "MIT",
6
6
  "description": "Official Isomorphic SDK for the ECODrIx platform. Native support for WhatsApp, CRM, Storage, and Meetings across TS, JS, Python, and Java.",
@@ -46,12 +46,12 @@
46
46
  "schema"
47
47
  ],
48
48
  "dependencies": {
49
- "axios": "^1.7.0",
49
+ "axios": "^1.7.9",
50
50
  "axios-retry": "^4.5.0",
51
51
  "commander": "^14.0.3",
52
52
  "dotenv": "^17.4.0",
53
53
  "picocolors": "^1.1.1",
54
- "socket.io-client": "^4.7.5"
54
+ "socket.io-client": "^4.8.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@biomejs/biome": "^1.9.4",
package/src/core.ts CHANGED
@@ -74,7 +74,13 @@ export interface EcodrixOptions {
74
74
  * ```
75
75
  */
76
76
  export class Ecodrix {
77
+ /**
78
+ * @internal Axios HTTP client for making API requests.
79
+ */
77
80
  private readonly client: AxiosInstance;
81
+ /**
82
+ * @internal Socket.io client for real-time events.
83
+ */
78
84
  private readonly socket: Socket;
79
85
 
80
86
  /** WhatsApp messaging and conversation management. */
@@ -123,7 +129,8 @@ export class Ecodrix {
123
129
  const baseUrl = options.baseUrl ?? ECOD_API_BASE;
124
130
  const socketUrl = options.socketUrl || baseUrl;
125
131
 
126
- const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
132
+ const isBrowser =
133
+ typeof window !== "undefined" && typeof window.document !== "undefined";
127
134
  const runtime = isBrowser
128
135
  ? "browser"
129
136
  : typeof process !== "undefined"
@@ -156,9 +163,20 @@ export class Ecodrix {
156
163
  retryDelay: axiosRetry.exponentialDelay,
157
164
  retryCondition: (error) => {
158
165
  return (
159
- axiosRetry.isNetworkOrIdempotentRequestError(error) || error.response?.status === 429
166
+ axiosRetry.isNetworkOrIdempotentRequestError(error) ||
167
+ error.response?.status === 429
160
168
  );
161
169
  },
170
+ onRetry: (retryCount, error, requestConfig) => {
171
+ const isDev =
172
+ typeof process !== "undefined" &&
173
+ process.env?.NODE_ENV === "development";
174
+ if (isDev) {
175
+ console.warn(
176
+ `[ECODrIx SDK] Retrying request (${retryCount}/3): ${requestConfig.method?.toUpperCase()} ${requestConfig.url}. Reason: ${error.message}`,
177
+ );
178
+ }
179
+ },
162
180
  });
163
181
 
164
182
  // Initialise resources
@@ -305,7 +323,9 @@ export class Ecodrix {
305
323
  } catch (error: any) {
306
324
  if (error.response) {
307
325
  throw new APIError(
308
- error.response.data?.message || error.response.data?.error || "Raw Execution Failed",
326
+ error.response.data?.message ||
327
+ error.response.data?.error ||
328
+ "Raw Execution Failed",
309
329
  error.response.status,
310
330
  error.response.data?.code,
311
331
  );
@@ -158,11 +158,11 @@ export class MediaResource extends APIResource {
158
158
  */
159
159
  async upload(file: any, options: UploadOptions): Promise<any> {
160
160
  // Step 1: Get presigned URL
161
- const { data: presignedData } = await this.client.post(
161
+ const response = await this.post<any>(
162
162
  "/api/saas/storage/upload-url",
163
163
  options,
164
164
  );
165
- const { uploadUrl, key } = presignedData;
165
+ const { uploadUrl, key } = response.data;
166
166
 
167
167
  // Step 2: Upload directly to R2 (bypasses the API server for performance)
168
168
  await axios.put(uploadUrl, file, {