@ecodrix/erix-api 1.0.8 → 1.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.
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +38 -2
- 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 +38 -2
- package/dist/ts/esm/index.d.ts +38 -2
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/index.js.map +1 -1
- package/package.json +5 -2
- package/src/resources/crm/pipelines.ts +9 -9
- package/src/resources/queue.ts +4 -4
- package/src/resources/whatsapp/index.ts +2 -2
- package/src/resources/whatsapp/messages.ts +42 -2
- package/src/resources/whatsapp/templates.ts +13 -13
- package/dist/index.d.cts +0 -1979
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecodrix/erix-api",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.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.",
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
"clear": "rm -rf dist",
|
|
70
70
|
"lint": "biome lint .",
|
|
71
71
|
"format": "biome format --write .",
|
|
72
|
-
"check": "biome check --write ."
|
|
72
|
+
"check": "biome check --write .",
|
|
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",
|
|
75
|
+
"publish:patch": "pnpm build:final && pnpm publish --access public --no-git-checks --tag patch"
|
|
73
76
|
}
|
|
74
77
|
}
|
|
@@ -45,7 +45,7 @@ export class Pipelines extends APIResource {
|
|
|
45
45
|
* Set pipeline as the tenant's default.
|
|
46
46
|
*/
|
|
47
47
|
async setDefault<T = any>(pipelineId: string) {
|
|
48
|
-
return this.
|
|
48
|
+
return this.patch<T>(`/api/crm/pipelines/${pipelineId}/default`, {});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -59,28 +59,28 @@ export class Pipelines extends APIResource {
|
|
|
59
59
|
* Archive a pipeline.
|
|
60
60
|
*/
|
|
61
61
|
async archive<T = any>(pipelineId: string) {
|
|
62
|
-
return this.
|
|
62
|
+
return this.patch<T>(`/api/crm/pipelines/${pipelineId}/archive`, {});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Delete a pipeline permanently.
|
|
67
67
|
*/
|
|
68
68
|
async delete(pipelineId: string) {
|
|
69
|
-
return this.deleteRequest(`/api/
|
|
69
|
+
return this.deleteRequest(`/api/crm/pipelines/${pipelineId}`);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Retrieve a Kanban-style board representation of the pipeline with leads nested.
|
|
74
74
|
*/
|
|
75
75
|
async board<T = any>(pipelineId: string) {
|
|
76
|
-
return this.get<T>(`/api/
|
|
76
|
+
return this.get<T>(`/api/crm/pipelines/${pipelineId}/board`);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* Retrieve a revenue forecast based on stage probabilities for a pipeline.
|
|
81
81
|
*/
|
|
82
82
|
async forecast<T = any>(pipelineId: string) {
|
|
83
|
-
return this.get<T>(`/api/
|
|
83
|
+
return this.get<T>(`/api/crm/pipelines/${pipelineId}/forecast`);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// --- Stage Management ---
|
|
@@ -89,14 +89,14 @@ export class Pipelines extends APIResource {
|
|
|
89
89
|
* Add a new stage to the pipeline.
|
|
90
90
|
*/
|
|
91
91
|
async addStage<T = any>(pipelineId: string, params: PipelineStageParams) {
|
|
92
|
-
return this.post<T>(`/api/
|
|
92
|
+
return this.post<T>(`/api/crm/pipelines/${pipelineId}/stages`, params);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Change the order of stages inside the pipeline.
|
|
97
97
|
*/
|
|
98
98
|
async reorderStages<T = any>(pipelineId: string, orderArray: string[]) {
|
|
99
|
-
return this.
|
|
99
|
+
return this.patch<T>(`/api/crm/pipelines/${pipelineId}/stages/reorder`, {
|
|
100
100
|
order: orderArray,
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -105,14 +105,14 @@ export class Pipelines extends APIResource {
|
|
|
105
105
|
* Update a specific stage.
|
|
106
106
|
*/
|
|
107
107
|
async updateStage<T = any>(stageId: string, params: Partial<PipelineStageParams>) {
|
|
108
|
-
return this.patch<T>(`/api/
|
|
108
|
+
return this.patch<T>(`/api/crm/stages/${stageId}`, params);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Delete a stage. Optionally provide a fallback stageId to move active leads to.
|
|
113
113
|
*/
|
|
114
114
|
async deleteStage(stageId: string, moveLeadsToStageId?: string) {
|
|
115
|
-
return this.deleteRequest(`/api/
|
|
115
|
+
return this.deleteRequest(`/api/crm/stages/${stageId}`, {
|
|
116
116
|
data: moveLeadsToStageId ? { moveLeadsToStageId } : undefined,
|
|
117
117
|
});
|
|
118
118
|
}
|
package/src/resources/queue.ts
CHANGED
|
@@ -13,27 +13,27 @@ export class Queue extends APIResource {
|
|
|
13
13
|
* List all failed jobs.
|
|
14
14
|
*/
|
|
15
15
|
async listFailed<T = any>() {
|
|
16
|
-
return this.get<T>("/api/saas/queue/failed");
|
|
16
|
+
return this.get<T>("/api/saas/admin/queue/failed");
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Get queue health statistics.
|
|
21
21
|
*/
|
|
22
22
|
async getStats<T = JobStats>() {
|
|
23
|
-
return this.get<T>("/api/saas/queue/stats");
|
|
23
|
+
return this.get<T>("/api/saas/admin/queue/stats");
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Retry a failed job.
|
|
28
28
|
*/
|
|
29
29
|
async retryJob<T = any>(jobId: string) {
|
|
30
|
-
return this.post<T>(`/api/saas/queue/${jobId}/retry`, {});
|
|
30
|
+
return this.post<T>(`/api/saas/admin/queue/${jobId}/retry`, {});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Remove a job from the queue.
|
|
35
35
|
*/
|
|
36
36
|
async deleteJob<T = any>(jobId: string) {
|
|
37
|
-
return this.deleteRequest<T>(`/api/saas/queue/${jobId}`);
|
|
37
|
+
return this.deleteRequest<T>(`/api/saas/admin/queue/${jobId}`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -38,7 +38,7 @@ export class WhatsApp extends APIResource {
|
|
|
38
38
|
async upload<T = any>(file: Blob | Buffer | File | any, filename: string) {
|
|
39
39
|
const form = new FormData();
|
|
40
40
|
form.append("file", file, filename);
|
|
41
|
-
return this.post<T>("/api/saas/
|
|
41
|
+
return this.post<T>("/api/saas/chat/upload", form, {
|
|
42
42
|
headers:
|
|
43
43
|
typeof (form as any).getHeaders === "function" ? (form as any).getHeaders() : undefined,
|
|
44
44
|
});
|
|
@@ -62,6 +62,6 @@ export class WhatsApp extends APIResource {
|
|
|
62
62
|
messageId?: string;
|
|
63
63
|
templateName?: string;
|
|
64
64
|
resolvedVariables?: any[];
|
|
65
|
-
}>("/api/saas/whatsapp/send-template", payload);
|
|
65
|
+
}>("/api/saas/marketing/whatsapp/send-template", payload);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -8,7 +8,11 @@ export interface SendMessageParams {
|
|
|
8
8
|
* Recipient's phone number in E.164 format.
|
|
9
9
|
* @example "+919876543210"
|
|
10
10
|
*/
|
|
11
|
-
to
|
|
11
|
+
to?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The unique ID of the conversation. If supplied, `to` is resolved automatically.
|
|
14
|
+
*/
|
|
15
|
+
conversationId?: string;
|
|
12
16
|
/** Plain text body of the message. */
|
|
13
17
|
text?: string;
|
|
14
18
|
/** Public URL of the media asset to send. */
|
|
@@ -31,7 +35,11 @@ export interface SendTemplateParams {
|
|
|
31
35
|
* Recipient's phone number in E.164 format.
|
|
32
36
|
* @example "+919876543210"
|
|
33
37
|
*/
|
|
34
|
-
to
|
|
38
|
+
to?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The unique ID of the conversation.
|
|
41
|
+
*/
|
|
42
|
+
conversationId?: string;
|
|
35
43
|
/** The exact template name as approved in Meta Business Manager. */
|
|
36
44
|
templateName: string;
|
|
37
45
|
/**
|
|
@@ -48,6 +56,10 @@ export interface SendTemplateParams {
|
|
|
48
56
|
mediaUrl?: string;
|
|
49
57
|
/** Media type for the header (e.g. "image", "document"). */
|
|
50
58
|
mediaType?: string;
|
|
59
|
+
/** User ID of the agent sending the message. */
|
|
60
|
+
userId?: string;
|
|
61
|
+
/** Optional filename for media headers. */
|
|
62
|
+
filename?: string;
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
/**
|
|
@@ -159,4 +171,32 @@ export class Messages extends APIResource {
|
|
|
159
171
|
async markRead(conversationId: string) {
|
|
160
172
|
return this.post(`/api/saas/chat/conversations/${conversationId}/read`);
|
|
161
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
|
+
}
|
|
162
202
|
}
|
|
@@ -10,35 +10,35 @@ export class Templates extends APIResource {
|
|
|
10
10
|
* List all templates from the tenant database.
|
|
11
11
|
*/
|
|
12
12
|
async list<T = any>(params?: { status?: string; mappingStatus?: string; channel?: string }) {
|
|
13
|
-
return this.get<T>("/api/saas/
|
|
13
|
+
return this.get<T>("/api/saas/chat/templates", { params } as any);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Synchronize templates from Meta API.
|
|
18
18
|
*/
|
|
19
19
|
async sync<T = any>() {
|
|
20
|
-
return this.post<T>("/api/saas/
|
|
20
|
+
return this.post<T>("/api/saas/chat/templates/sync", {});
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Get template details.
|
|
25
25
|
*/
|
|
26
26
|
async retrieve<T = any>(templateIdentifier: string) {
|
|
27
|
-
return this.get<T>(`/api/saas/
|
|
27
|
+
return this.get<T>(`/api/saas/chat/templates/${encodeURIComponent(templateIdentifier)}`);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Create a new template manually.
|
|
32
32
|
*/
|
|
33
33
|
async create<T = any>(payload: any) {
|
|
34
|
-
return this.post<T>("/api/saas/
|
|
34
|
+
return this.post<T>("/api/saas/chat/templates", payload);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Update an existing template.
|
|
39
39
|
*/
|
|
40
40
|
async update<T = any>(templateId: string, payload: any) {
|
|
41
|
-
return this.put<T>(`/api/saas/
|
|
41
|
+
return this.put<T>(`/api/saas/chat/templates/${templateId}`, payload);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -46,7 +46,7 @@ export class Templates extends APIResource {
|
|
|
46
46
|
*/
|
|
47
47
|
async deleteTemplate<T = any>(templateName: string, force?: boolean) {
|
|
48
48
|
return this.deleteRequest<T>(
|
|
49
|
-
`/api/saas/
|
|
49
|
+
`/api/saas/chat/templates/${encodeURIComponent(templateName)}${force ? "?force=true" : ""}`,
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -54,14 +54,14 @@ export class Templates extends APIResource {
|
|
|
54
54
|
* List curated mapping config options.
|
|
55
55
|
*/
|
|
56
56
|
async mappingConfig<T = any>() {
|
|
57
|
-
return this.get<T>("/api/saas/
|
|
57
|
+
return this.get<T>("/api/saas/chat/templates/mapping/config");
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* List CRM collections for variable mapping.
|
|
62
62
|
*/
|
|
63
63
|
async collections<T = any>() {
|
|
64
|
-
return this.get<T>("/api/saas/
|
|
64
|
+
return this.get<T>("/api/saas/chat/templates/collections");
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
@@ -69,7 +69,7 @@ export class Templates extends APIResource {
|
|
|
69
69
|
*/
|
|
70
70
|
async collectionFields<T = any>(collectionName: string) {
|
|
71
71
|
return this.get<T>(
|
|
72
|
-
`/api/saas/
|
|
72
|
+
`/api/saas/chat/templates/collections/${encodeURIComponent(collectionName)}/fields`,
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -78,7 +78,7 @@ export class Templates extends APIResource {
|
|
|
78
78
|
*/
|
|
79
79
|
async updateMapping<T = any>(templateName: string, payload: TemplateMapping) {
|
|
80
80
|
return this.put<T>(
|
|
81
|
-
`/api/saas/
|
|
81
|
+
`/api/saas/chat/templates/${encodeURIComponent(templateName)}/mapping`,
|
|
82
82
|
payload,
|
|
83
83
|
);
|
|
84
84
|
}
|
|
@@ -87,7 +87,7 @@ export class Templates extends APIResource {
|
|
|
87
87
|
* Validate mapping readiness.
|
|
88
88
|
*/
|
|
89
89
|
async validate<T = any>(templateName: string) {
|
|
90
|
-
return this.get<T>(`/api/saas/
|
|
90
|
+
return this.get<T>(`/api/saas/chat/templates/${encodeURIComponent(templateName)}/validate`);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
@@ -95,7 +95,7 @@ export class Templates extends APIResource {
|
|
|
95
95
|
*/
|
|
96
96
|
async preview<T = any>(templateName: string, context: { lead?: any; vars?: any }) {
|
|
97
97
|
return this.post<T>(
|
|
98
|
-
`/api/saas/
|
|
98
|
+
`/api/saas/chat/templates/${encodeURIComponent(templateName)}/preview`,
|
|
99
99
|
{ context },
|
|
100
100
|
);
|
|
101
101
|
}
|
|
@@ -104,6 +104,6 @@ export class Templates extends APIResource {
|
|
|
104
104
|
* Check automation usage of a template.
|
|
105
105
|
*/
|
|
106
106
|
async checkUsage<T = any>(templateName: string) {
|
|
107
|
-
return this.get<T>(`/api/saas/
|
|
107
|
+
return this.get<T>(`/api/saas/chat/templates/${encodeURIComponent(templateName)}/usage`);
|
|
108
108
|
}
|
|
109
109
|
}
|