@ecodrix/erix-api 1.0.9 → 1.1.1
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/dist/cli.js +2 -2
- package/dist/index.d.ts +36 -0
- package/dist/ts/browser/index.global.js +1 -1
- package/dist/ts/browser/index.global.js.map +1 -1
- package/dist/ts/cjs/index.cjs +1 -1
- package/dist/ts/cjs/index.cjs.map +1 -1
- package/dist/ts/cjs/index.d.cts +36 -0
- package/dist/ts/esm/index.d.ts +36 -0
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/index.js.map +1 -1
- package/package.json +3 -2
- package/src/core.ts +18 -0
- package/src/resources/whatsapp/messages.ts +28 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecodrix/erix-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
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.",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"format": "biome format --write .",
|
|
72
72
|
"check": "biome check --write .",
|
|
73
73
|
"publish:latest": "pnpm build:final && pnpm publish --access public --no-git-checks --tag latest",
|
|
74
|
-
"publish:beta": "pnpm build:final && pnpm publish --access public --no-git-checks --tag beta"
|
|
74
|
+
"publish:beta": "pnpm build:final && pnpm publish --access public --no-git-checks --tag beta",
|
|
75
|
+
"publish:patch": "pnpm build:final && pnpm publish --access public --no-git-checks --tag patch"
|
|
75
76
|
}
|
|
76
77
|
}
|
package/src/core.ts
CHANGED
|
@@ -181,6 +181,24 @@ export class Ecodrix {
|
|
|
181
181
|
this.setupSocket(options.clientCode);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Join a specific real-time room (e.g., a conversation or a lead).
|
|
186
|
+
*
|
|
187
|
+
* @param roomId - The unique identifier for the room.
|
|
188
|
+
*/
|
|
189
|
+
public joinRoom(roomId: string) {
|
|
190
|
+
this.socket.emit("join-room", roomId);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Leave a previously joined real-time room.
|
|
195
|
+
*
|
|
196
|
+
* @param roomId - The unique identifier for the room.
|
|
197
|
+
*/
|
|
198
|
+
public leaveRoom(roomId: string) {
|
|
199
|
+
this.socket.emit("leave-room", roomId);
|
|
200
|
+
}
|
|
201
|
+
|
|
184
202
|
private setupSocket(clientCode?: string) {
|
|
185
203
|
this.socket.on("connect", () => {
|
|
186
204
|
if (clientCode) {
|
|
@@ -171,4 +171,32 @@ export class Messages extends APIResource {
|
|
|
171
171
|
async markRead(conversationId: string) {
|
|
172
172
|
return this.post(`/api/saas/chat/conversations/${conversationId}/read`);
|
|
173
173
|
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Upload a media file for WhatsApp chat.
|
|
177
|
+
*
|
|
178
|
+
* This is the recommended way to upload media for WhatsApp chatting as it
|
|
179
|
+
* allows the backend to perform WhatsApp-specific optimizations (resizing,
|
|
180
|
+
* format conversion, and thumbnail generation).
|
|
181
|
+
*
|
|
182
|
+
* @param file - The file to upload (File, Blob, or Buffer).
|
|
183
|
+
* @returns The uploaded media details `{ url, type }`.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const file = input.files[0];
|
|
188
|
+
* const { data } = await ecod.whatsapp.messages.upload(file);
|
|
189
|
+
* console.log(data.url); // -> https://cdn.ecodrix.com/tenants/ABC/chat/chat_123.jpg
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
async upload<T = { url: string; type: string }>(file: any): Promise<{ success: boolean; data: T }> {
|
|
193
|
+
const formData = new FormData();
|
|
194
|
+
formData.append("file", file);
|
|
195
|
+
|
|
196
|
+
return this.post<{ success: boolean; data: T }>("/api/saas/chat/upload", formData, {
|
|
197
|
+
headers: {
|
|
198
|
+
"Content-Type": "multipart/form-data",
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
}
|
|
174
202
|
}
|