@ecodrix/erix-api 1.0.1 → 1.0.4
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 +38 -0
- package/dist/index.d.cts +1979 -0
- package/dist/index.d.ts +1173 -313
- package/dist/ts/browser/index.global.js +14 -14
- 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 +1173 -313
- package/dist/ts/esm/index.d.ts +1173 -313
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/index.js.map +1 -1
- package/package.json +18 -13
- package/src/cli.ts +305 -0
- package/src/core.ts +28 -12
- package/src/index.ts +22 -8
- package/src/resource.ts +21 -1
- package/src/resources/crm/activities.ts +89 -0
- package/src/resources/crm/analytics.ts +89 -0
- package/src/resources/crm/automationDashboard.ts +24 -0
- package/src/resources/crm/automations.ts +151 -0
- package/src/resources/crm/index.ts +25 -1
- package/src/resources/crm/leads.ts +178 -45
- package/src/resources/crm/payments.ts +16 -0
- package/src/resources/crm/pipelines.ts +119 -0
- package/src/resources/crm/scoring.ts +33 -0
- package/src/resources/crm/sequences.ts +28 -0
- package/src/resources/email.ts +2 -5
- package/src/resources/events.ts +52 -2
- package/src/resources/health.ts +63 -0
- package/src/resources/marketing.ts +111 -0
- package/src/resources/media.ts +1 -4
- package/src/resources/meet.ts +12 -2
- package/src/resources/notifications.ts +30 -0
- package/src/resources/queue.ts +39 -0
- package/src/resources/storage.ts +72 -0
- package/src/resources/webhooks.ts +3 -8
- package/src/resources/whatsapp/broadcasts.ts +31 -0
- package/src/resources/whatsapp/conversations.ts +39 -9
- package/src/resources/whatsapp/index.ts +20 -2
- package/src/resources/whatsapp/messages.ts +24 -0
- package/src/resources/whatsapp/templates.ts +109 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1979 @@
|
|
|
1
|
+
import type { AxiosInstance, AxiosRequestConfig, Method } from "axios";
|
|
2
|
+
|
|
3
|
+
interface RequestOptions extends AxiosRequestConfig {
|
|
4
|
+
/**
|
|
5
|
+
* If true, will not add the x-client-code header.
|
|
6
|
+
*/
|
|
7
|
+
ignoreClientCode?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Safe execution idempotency key.
|
|
10
|
+
* If provided, the backend will safely ignore duplicate requests retried with the same key.
|
|
11
|
+
*/
|
|
12
|
+
idempotencyKey?: string;
|
|
13
|
+
}
|
|
14
|
+
declare abstract class APIResource {
|
|
15
|
+
protected readonly client: AxiosInstance;
|
|
16
|
+
constructor(client: AxiosInstance);
|
|
17
|
+
protected post<T>(url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
18
|
+
protected get<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
19
|
+
protected patch<T>(url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
20
|
+
protected put<T>(url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
21
|
+
protected deleteRequest<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
22
|
+
private buildConfig;
|
|
23
|
+
private handleError;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Parameters for sending a free-form WhatsApp message.
|
|
28
|
+
*/
|
|
29
|
+
interface SendMessageParams {
|
|
30
|
+
/**
|
|
31
|
+
* Recipient's phone number in E.164 format.
|
|
32
|
+
* @example "+919876543210"
|
|
33
|
+
*/
|
|
34
|
+
to: string;
|
|
35
|
+
/** Plain text body of the message. */
|
|
36
|
+
text?: string;
|
|
37
|
+
/** Public URL of the media asset to send. */
|
|
38
|
+
mediaUrl?: string;
|
|
39
|
+
/** MIME category of the media. */
|
|
40
|
+
mediaType?: "image" | "video" | "audio" | "document";
|
|
41
|
+
/** The `messageId` of the message to reply to (quoted replies). */
|
|
42
|
+
replyToId?: string;
|
|
43
|
+
/** Filename shown to the recipient (required for `document` type). */
|
|
44
|
+
filename?: string;
|
|
45
|
+
/** Arbitrary metadata stored with the message record. */
|
|
46
|
+
metadata?: Record<string, any>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parameters for sending a pre-approved WhatsApp Business template.
|
|
50
|
+
*/
|
|
51
|
+
interface SendTemplateParams {
|
|
52
|
+
/**
|
|
53
|
+
* Recipient's phone number in E.164 format.
|
|
54
|
+
* @example "+919876543210"
|
|
55
|
+
*/
|
|
56
|
+
to: string;
|
|
57
|
+
/** The exact template name as approved in Meta Business Manager. */
|
|
58
|
+
templateName: string;
|
|
59
|
+
/**
|
|
60
|
+
* BCP-47 language code for the template.
|
|
61
|
+
* @default "en_US"
|
|
62
|
+
*/
|
|
63
|
+
language?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Ordered array of variable substitutions for template placeholders.
|
|
66
|
+
* @example ["Alice", "10 April 2026", "10:00 AM"]
|
|
67
|
+
*/
|
|
68
|
+
variables?: string[];
|
|
69
|
+
/** Optional header media URL (for templates with media headers). */
|
|
70
|
+
mediaUrl?: string;
|
|
71
|
+
/** Media type for the header (e.g. "image", "document"). */
|
|
72
|
+
mediaType?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* WhatsApp outbound messaging resource.
|
|
76
|
+
*
|
|
77
|
+
* Access via `ecod.whatsapp.messages`.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* await ecod.whatsapp.messages.send({
|
|
82
|
+
* to: "+919876543210",
|
|
83
|
+
* text: "Your appointment is confirmed!",
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare class Messages extends APIResource {
|
|
88
|
+
/**
|
|
89
|
+
* Send a free-text or media message to a WhatsApp number.
|
|
90
|
+
*
|
|
91
|
+
* For text-only messages, supply `text`. For media, supply `mediaUrl`
|
|
92
|
+
* and `mediaType`. Both can be combined.
|
|
93
|
+
*
|
|
94
|
+
* @param params - Message parameters.
|
|
95
|
+
* @returns The created message record.
|
|
96
|
+
*
|
|
97
|
+
* @example Text message
|
|
98
|
+
* ```typescript
|
|
99
|
+
* await ecod.whatsapp.messages.send({
|
|
100
|
+
* to: "+919876543210",
|
|
101
|
+
* text: "Hello!",
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @example Media message
|
|
106
|
+
* ```typescript
|
|
107
|
+
* await ecod.whatsapp.messages.send({
|
|
108
|
+
* to: "+919876543210",
|
|
109
|
+
* mediaUrl: "https://cdn.ecodrix.com/invoice.pdf",
|
|
110
|
+
* mediaType: "document",
|
|
111
|
+
* filename: "invoice.pdf",
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
send(params: SendMessageParams): Promise<unknown>;
|
|
116
|
+
/**
|
|
117
|
+
* Send a pre-approved WhatsApp Business template message.
|
|
118
|
+
*
|
|
119
|
+
* Templates must be approved in Meta Business Manager before use.
|
|
120
|
+
* Variable placeholders in the template body are filled left-to-right
|
|
121
|
+
* from the `variables` array.
|
|
122
|
+
*
|
|
123
|
+
* @param params - Template message parameters.
|
|
124
|
+
* @returns The created message record.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* await ecod.whatsapp.messages.sendTemplate({
|
|
129
|
+
* to: "+919876543210",
|
|
130
|
+
* templateName: "appointment_reminder",
|
|
131
|
+
* language: "en_US",
|
|
132
|
+
* variables: ["Alice", "10 April", "10:00 AM"],
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
sendTemplate(params: SendTemplateParams): Promise<unknown>;
|
|
137
|
+
/**
|
|
138
|
+
* Star or unstar a message.
|
|
139
|
+
*
|
|
140
|
+
* @param messageId - The ID of the message.
|
|
141
|
+
* @param isStarred - Boolean indicating whether to star or unstar.
|
|
142
|
+
*/
|
|
143
|
+
star<T = any>(messageId: string, isStarred: boolean): Promise<T>;
|
|
144
|
+
/**
|
|
145
|
+
* React to a message with an emoji.
|
|
146
|
+
*
|
|
147
|
+
* @param messageId - The ID of the message.
|
|
148
|
+
* @param reaction - The emoji (e.g. "👍") to react with, or empty string to remove.
|
|
149
|
+
*/
|
|
150
|
+
react<T = any>(messageId: string, reaction: string): Promise<T>;
|
|
151
|
+
/**
|
|
152
|
+
* Mark all messages in a conversation as read (double-tick).
|
|
153
|
+
*
|
|
154
|
+
* @param conversationId - The conversation to mark as read.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* await ecod.whatsapp.messages.markRead("conv_64abc...");
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
markRead(conversationId: string): Promise<unknown>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface ListParams {
|
|
165
|
+
limit?: number;
|
|
166
|
+
before?: string;
|
|
167
|
+
after?: string;
|
|
168
|
+
status?: string;
|
|
169
|
+
}
|
|
170
|
+
declare class Conversations extends APIResource {
|
|
171
|
+
/**
|
|
172
|
+
* List conversations for the tenant.
|
|
173
|
+
*/
|
|
174
|
+
list<T = any>(params?: ListParams): Promise<T>;
|
|
175
|
+
/**
|
|
176
|
+
* Create a new conversation explicitly.
|
|
177
|
+
*
|
|
178
|
+
* @param params - Conversation details.
|
|
179
|
+
*/
|
|
180
|
+
create<T = any>(params: {
|
|
181
|
+
phone: string;
|
|
182
|
+
name?: string;
|
|
183
|
+
}): Promise<T>;
|
|
184
|
+
/**
|
|
185
|
+
* Retrieve details of a specific conversation.
|
|
186
|
+
*/
|
|
187
|
+
retrieve<T = any>(conversationId: string): Promise<T>;
|
|
188
|
+
/**
|
|
189
|
+
* Get messages for a specific conversation.
|
|
190
|
+
*/
|
|
191
|
+
messages<T = any>(conversationId: string, params?: ListParams): Promise<T>;
|
|
192
|
+
/**
|
|
193
|
+
* Link a conversation to a lead.
|
|
194
|
+
*/
|
|
195
|
+
linkLead<T = any>(conversationId: string, leadId: string, leadData?: any): Promise<T>;
|
|
196
|
+
/**
|
|
197
|
+
* Delete a conversation.
|
|
198
|
+
*/
|
|
199
|
+
delete(conversationId: string): Promise<unknown>;
|
|
200
|
+
/**
|
|
201
|
+
* Bulk delete conversations.
|
|
202
|
+
*/
|
|
203
|
+
bulkDelete(ids: string[]): Promise<unknown>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
interface CreateBroadcastParams {
|
|
207
|
+
templateName: string;
|
|
208
|
+
recipients: string[];
|
|
209
|
+
}
|
|
210
|
+
declare class Broadcasts extends APIResource {
|
|
211
|
+
/**
|
|
212
|
+
* List past and active broadcasts.
|
|
213
|
+
*/
|
|
214
|
+
list<T = any>(params?: Record<string, any>): Promise<T>;
|
|
215
|
+
/**
|
|
216
|
+
* Create a new broadcast to send a template message to multiple recipients.
|
|
217
|
+
*/
|
|
218
|
+
create<T = any>(params: CreateBroadcastParams): Promise<T>;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
interface TemplateMapping {
|
|
222
|
+
mappings: any[];
|
|
223
|
+
onEmptyVariable: string;
|
|
224
|
+
}
|
|
225
|
+
declare class Templates extends APIResource {
|
|
226
|
+
/**
|
|
227
|
+
* List all templates from the tenant database.
|
|
228
|
+
*/
|
|
229
|
+
list<T = any>(params?: {
|
|
230
|
+
status?: string;
|
|
231
|
+
mappingStatus?: string;
|
|
232
|
+
channel?: string;
|
|
233
|
+
}): Promise<T>;
|
|
234
|
+
/**
|
|
235
|
+
* Synchronize templates from Meta API.
|
|
236
|
+
*/
|
|
237
|
+
sync<T = any>(): Promise<T>;
|
|
238
|
+
/**
|
|
239
|
+
* Get template details.
|
|
240
|
+
*/
|
|
241
|
+
retrieve<T = any>(templateIdentifier: string): Promise<T>;
|
|
242
|
+
/**
|
|
243
|
+
* Create a new template manually.
|
|
244
|
+
*/
|
|
245
|
+
create<T = any>(payload: any): Promise<T>;
|
|
246
|
+
/**
|
|
247
|
+
* Update an existing template.
|
|
248
|
+
*/
|
|
249
|
+
update<T = any>(templateId: string, payload: any): Promise<T>;
|
|
250
|
+
/**
|
|
251
|
+
* Delete a template.
|
|
252
|
+
*/
|
|
253
|
+
deleteTemplate<T = any>(templateName: string, force?: boolean): Promise<T>;
|
|
254
|
+
/**
|
|
255
|
+
* List curated mapping config options.
|
|
256
|
+
*/
|
|
257
|
+
mappingConfig<T = any>(): Promise<T>;
|
|
258
|
+
/**
|
|
259
|
+
* List CRM collections for variable mapping.
|
|
260
|
+
*/
|
|
261
|
+
collections<T = any>(): Promise<T>;
|
|
262
|
+
/**
|
|
263
|
+
* List CRM fields for a collection.
|
|
264
|
+
*/
|
|
265
|
+
collectionFields<T = any>(collectionName: string): Promise<T>;
|
|
266
|
+
/**
|
|
267
|
+
* Update variable mappings for a template.
|
|
268
|
+
*/
|
|
269
|
+
updateMapping<T = any>(templateName: string, payload: TemplateMapping): Promise<T>;
|
|
270
|
+
/**
|
|
271
|
+
* Validate mapping readiness.
|
|
272
|
+
*/
|
|
273
|
+
validate<T = any>(templateName: string): Promise<T>;
|
|
274
|
+
/**
|
|
275
|
+
* Preview a template resolution.
|
|
276
|
+
*/
|
|
277
|
+
preview<T = any>(
|
|
278
|
+
templateName: string,
|
|
279
|
+
context: {
|
|
280
|
+
lead?: any;
|
|
281
|
+
vars?: any;
|
|
282
|
+
},
|
|
283
|
+
): Promise<T>;
|
|
284
|
+
/**
|
|
285
|
+
* Check automation usage of a template.
|
|
286
|
+
*/
|
|
287
|
+
checkUsage<T = any>(templateName: string): Promise<T>;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
interface SendTemplatePayload {
|
|
291
|
+
/** Phone number in E.164 format. */
|
|
292
|
+
phone: string;
|
|
293
|
+
/** Name of the pre-approved WhatsApp template. */
|
|
294
|
+
templateName: string;
|
|
295
|
+
/** Language code (defaults to "en"). */
|
|
296
|
+
languageCode?: string;
|
|
297
|
+
/** Key-value pairs matching variables in your template (e.g., {{1}}, {{2}}). */
|
|
298
|
+
variables?: Record<string, string>;
|
|
299
|
+
/** Explicitly resolved variables if bypassing the internal resolution engine. */
|
|
300
|
+
resolvedVariables?: any[];
|
|
301
|
+
}
|
|
302
|
+
declare class WhatsApp extends APIResource {
|
|
303
|
+
messages: Messages;
|
|
304
|
+
conversations: Conversations;
|
|
305
|
+
broadcasts: Broadcasts;
|
|
306
|
+
templates: Templates;
|
|
307
|
+
constructor(client: AxiosInstance);
|
|
308
|
+
/**
|
|
309
|
+
* Upload an asset directly to chat storage.
|
|
310
|
+
*/
|
|
311
|
+
upload<T = any>(file: Blob | Buffer | File | any, filename: string): Promise<T>;
|
|
312
|
+
/**
|
|
313
|
+
* Dispatch a WhatsApp template message directly to a specific phone number.
|
|
314
|
+
* Bypasses the automation queue for immediate high-priority delivery.
|
|
315
|
+
*
|
|
316
|
+
* @param payload - The template dispatch payload.
|
|
317
|
+
* @returns Information about the dispatched message.
|
|
318
|
+
*/
|
|
319
|
+
sendTemplate(payload: SendTemplatePayload): Promise<{
|
|
320
|
+
success: boolean;
|
|
321
|
+
messageId?: string;
|
|
322
|
+
templateName?: string;
|
|
323
|
+
resolvedVariables?: any[];
|
|
324
|
+
}>;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Valid statuses for a CRM Lead.
|
|
329
|
+
*/
|
|
330
|
+
type LeadStatus = "new" | "contacted" | "qualified" | "won" | "lost" | "archived";
|
|
331
|
+
/**
|
|
332
|
+
* Common lead acquisition sources. Additional string values are allowed.
|
|
333
|
+
*/
|
|
334
|
+
type LeadSource = "website" | "whatsapp" | "direct" | "referral" | string;
|
|
335
|
+
/**
|
|
336
|
+
* Parameters for creating a new CRM Lead.
|
|
337
|
+
*/
|
|
338
|
+
interface CreateLeadParams {
|
|
339
|
+
/** Lead's first name. Required. */
|
|
340
|
+
firstName: string;
|
|
341
|
+
/** Lead's last name. */
|
|
342
|
+
lastName?: string;
|
|
343
|
+
/** Lead's email address. */
|
|
344
|
+
email?: string;
|
|
345
|
+
/** Lead's phone number in E.164 format (e.g. "+919876543210"). */
|
|
346
|
+
phone?: string;
|
|
347
|
+
/**
|
|
348
|
+
* Acquisition channel.
|
|
349
|
+
*/
|
|
350
|
+
source?: LeadSource;
|
|
351
|
+
/** Arbitrary key-value metadata (UTM params, order IDs, etc.). */
|
|
352
|
+
metadata?: Record<string, any>;
|
|
353
|
+
/** Pipeline ID to assign the lead */
|
|
354
|
+
pipelineId?: string;
|
|
355
|
+
/** Stage ID to assign the lead */
|
|
356
|
+
stageId?: string;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Options for listing leads.
|
|
360
|
+
*/
|
|
361
|
+
interface ListLeadsParams {
|
|
362
|
+
status?: LeadStatus;
|
|
363
|
+
pipelineId?: string;
|
|
364
|
+
stageId?: string;
|
|
365
|
+
source?: LeadSource;
|
|
366
|
+
assignedTo?: string;
|
|
367
|
+
tags?: string[] | string;
|
|
368
|
+
minScore?: number;
|
|
369
|
+
search?: string;
|
|
370
|
+
startDate?: string;
|
|
371
|
+
endDate?: string;
|
|
372
|
+
appointmentId?: string;
|
|
373
|
+
bookingId?: string;
|
|
374
|
+
orderId?: string;
|
|
375
|
+
meetingId?: string;
|
|
376
|
+
page?: number;
|
|
377
|
+
limit?: number;
|
|
378
|
+
sortBy?: string;
|
|
379
|
+
sortDir?: "asc" | "desc";
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Options for upserting a lead.
|
|
383
|
+
*/
|
|
384
|
+
interface UpsertLeadParams {
|
|
385
|
+
leadData: Partial<CreateLeadParams> & {
|
|
386
|
+
phone: string;
|
|
387
|
+
name?: string;
|
|
388
|
+
};
|
|
389
|
+
moduleInfo?: any;
|
|
390
|
+
trigger?: string;
|
|
391
|
+
pipelineId?: string;
|
|
392
|
+
stageId?: string;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* CRM Lead resource — full lifecycle management.
|
|
396
|
+
*
|
|
397
|
+
* Access via `ecod.crm.leads`.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```typescript
|
|
401
|
+
* const { data: lead } = await ecod.crm.leads.create({
|
|
402
|
+
* firstName: "Alice",
|
|
403
|
+
* phone: "+919876543210",
|
|
404
|
+
* source: "website",
|
|
405
|
+
* });
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
declare class Leads extends APIResource {
|
|
409
|
+
/**
|
|
410
|
+
* Create a new lead in the CRM pipeline.
|
|
411
|
+
*
|
|
412
|
+
* @param params - Lead creation parameters. `firstName` is required.
|
|
413
|
+
* @returns The newly created Lead document.
|
|
414
|
+
*/
|
|
415
|
+
create<T = any>(params: CreateLeadParams): Promise<T>;
|
|
416
|
+
/**
|
|
417
|
+
* Upsert a lead by phone number. Creates if not exists, updates if exists.
|
|
418
|
+
*
|
|
419
|
+
* @param params - Upsert parameters containing leadData with a phone number.
|
|
420
|
+
* @returns The newly created or updated Lead document.
|
|
421
|
+
*/
|
|
422
|
+
upsert<T = any>(params: UpsertLeadParams): Promise<T>;
|
|
423
|
+
/**
|
|
424
|
+
* Bulk ingest leads efficiently in parallel using automatic chunking.
|
|
425
|
+
* Prevents rate limit exhaustion by executing `chunkSize` requests at a time.
|
|
426
|
+
*
|
|
427
|
+
* @param leads - Array of leads to create.
|
|
428
|
+
* @param chunkSize - Number of leads to send concurrently (default: 50)
|
|
429
|
+
* @returns Array of created lead results.
|
|
430
|
+
*/
|
|
431
|
+
createMany(leads: CreateLeadParams[], chunkSize?: number): Promise<any[]>;
|
|
432
|
+
/**
|
|
433
|
+
* Bulk upsert (import) leads.
|
|
434
|
+
*
|
|
435
|
+
* @param leads - Array of leads to import.
|
|
436
|
+
*/
|
|
437
|
+
import<T = any>(leads: Partial<CreateLeadParams>[]): Promise<T>;
|
|
438
|
+
/**
|
|
439
|
+
* List leads with optional filtering and pagination.
|
|
440
|
+
*
|
|
441
|
+
* @param params - Filter options (status, source, pipelineId, page, limit, etc.)
|
|
442
|
+
* @returns Paginated list of Lead documents.
|
|
443
|
+
*/
|
|
444
|
+
list<T = any>(params?: ListLeadsParams): Promise<T>;
|
|
445
|
+
/**
|
|
446
|
+
* Auto-paginating iterator for leads.
|
|
447
|
+
* Seamlessly fetches leads page by page as you iterate.
|
|
448
|
+
*/
|
|
449
|
+
listAutoPaging(params?: ListLeadsParams): AsyncGenerator<any, void, unknown>;
|
|
450
|
+
/**
|
|
451
|
+
* Retrieve a single lead by its unique ID.
|
|
452
|
+
*
|
|
453
|
+
* @param leadId - The MongoDB ObjectId of the lead.
|
|
454
|
+
* @returns The Lead document, or a 404 error if not found.
|
|
455
|
+
*/
|
|
456
|
+
retrieve<T = any>(leadId: string): Promise<T>;
|
|
457
|
+
/**
|
|
458
|
+
* Retrieve a single lead by its phone number.
|
|
459
|
+
*
|
|
460
|
+
* @param phone - Lead's phone number.
|
|
461
|
+
*/
|
|
462
|
+
retrieveByPhone<T = any>(phone: string): Promise<T>;
|
|
463
|
+
/**
|
|
464
|
+
* Retrieve a single lead by a reference key and value.
|
|
465
|
+
*
|
|
466
|
+
* @param refKey - Reference key metadata.
|
|
467
|
+
* @param refValue - Reference value.
|
|
468
|
+
*/
|
|
469
|
+
retrieveByRef<T = any>(refKey: string, refValue: string): Promise<T>;
|
|
470
|
+
/**
|
|
471
|
+
* Update the fields of an existing lead.
|
|
472
|
+
*
|
|
473
|
+
* @param leadId - The ID of the lead to update.
|
|
474
|
+
* @param params - Partial lead fields to update.
|
|
475
|
+
* @returns The updated Lead document.
|
|
476
|
+
*/
|
|
477
|
+
update<T = any>(leadId: string, params: Partial<CreateLeadParams>): Promise<T>;
|
|
478
|
+
/**
|
|
479
|
+
* Move a lead to a new stage in a pipeline.
|
|
480
|
+
*
|
|
481
|
+
* @param leadId - ID of the lead.
|
|
482
|
+
* @param stageId - Target stage ID.
|
|
483
|
+
*/
|
|
484
|
+
move<T = any>(leadId: string, stageId: string): Promise<T>;
|
|
485
|
+
/**
|
|
486
|
+
* Convert a lead (mark as won or lost with reason).
|
|
487
|
+
*
|
|
488
|
+
* @param leadId - ID of the lead.
|
|
489
|
+
* @param outcome - "won" | "lost"
|
|
490
|
+
* @param reason - Reason for the outcome.
|
|
491
|
+
*/
|
|
492
|
+
convert<T = any>(leadId: string, outcome: "won" | "lost", reason?: string): Promise<T>;
|
|
493
|
+
/**
|
|
494
|
+
* Update the tags of a lead.
|
|
495
|
+
*
|
|
496
|
+
* @param leadId - ID of the lead.
|
|
497
|
+
* @param options - Tags to add or remove.
|
|
498
|
+
*/
|
|
499
|
+
tags<T = any>(
|
|
500
|
+
leadId: string,
|
|
501
|
+
options: {
|
|
502
|
+
add?: string[];
|
|
503
|
+
remove?: string[];
|
|
504
|
+
},
|
|
505
|
+
): Promise<T>;
|
|
506
|
+
/**
|
|
507
|
+
* Recalculate lead score based on activities and interactions.
|
|
508
|
+
*
|
|
509
|
+
* @param leadId - ID of the lead.
|
|
510
|
+
*/
|
|
511
|
+
recalculateScore<T = any>(leadId: string): Promise<T>;
|
|
512
|
+
/**
|
|
513
|
+
* Update embedded metadata/references of a lead without touching core fields.
|
|
514
|
+
*
|
|
515
|
+
* @param leadId - ID of the lead.
|
|
516
|
+
* @param metadata - Metadata object indicating { refs, extra }
|
|
517
|
+
*/
|
|
518
|
+
updateMetadata<T = any>(
|
|
519
|
+
leadId: string,
|
|
520
|
+
metadata: {
|
|
521
|
+
refs?: Record<string, any>;
|
|
522
|
+
extra?: Record<string, any>;
|
|
523
|
+
},
|
|
524
|
+
): Promise<T>;
|
|
525
|
+
/**
|
|
526
|
+
* Introspect available custom fields configured by the tenant limit.
|
|
527
|
+
*/
|
|
528
|
+
fields<T = any>(): Promise<T>;
|
|
529
|
+
/**
|
|
530
|
+
* Archive (soft-delete) a single lead.
|
|
531
|
+
*
|
|
532
|
+
* @param leadId - The ID of the lead to archive.
|
|
533
|
+
*/
|
|
534
|
+
delete(leadId: string): Promise<unknown>;
|
|
535
|
+
/**
|
|
536
|
+
* Bulk archive multiple leads.
|
|
537
|
+
*
|
|
538
|
+
* @param ids - Array of lead IDs to archive.
|
|
539
|
+
*/
|
|
540
|
+
bulkDelete(ids: string[]): Promise<unknown>;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
interface CreatePipelineParams {
|
|
544
|
+
name: string;
|
|
545
|
+
isDefault?: boolean;
|
|
546
|
+
stages?: any[];
|
|
547
|
+
}
|
|
548
|
+
interface PipelineStageParams {
|
|
549
|
+
name: string;
|
|
550
|
+
color?: string;
|
|
551
|
+
probability?: number;
|
|
552
|
+
}
|
|
553
|
+
declare class Pipelines extends APIResource {
|
|
554
|
+
/**
|
|
555
|
+
* List all pipelines matching the optional query parameters.
|
|
556
|
+
*/
|
|
557
|
+
list<T = any>(params?: Record<string, any>): Promise<T>;
|
|
558
|
+
/**
|
|
559
|
+
* Create a new pipeline.
|
|
560
|
+
*/
|
|
561
|
+
create<T = any>(params: CreatePipelineParams): Promise<T>;
|
|
562
|
+
/**
|
|
563
|
+
* Retrieve a single pipeline.
|
|
564
|
+
*/
|
|
565
|
+
retrieve<T = any>(pipelineId: string): Promise<T>;
|
|
566
|
+
/**
|
|
567
|
+
* Update a pipeline's details.
|
|
568
|
+
*/
|
|
569
|
+
update<T = any>(
|
|
570
|
+
pipelineId: string,
|
|
571
|
+
params: {
|
|
572
|
+
name?: string;
|
|
573
|
+
description?: string;
|
|
574
|
+
},
|
|
575
|
+
): Promise<T>;
|
|
576
|
+
/**
|
|
577
|
+
* Set pipeline as the tenant's default.
|
|
578
|
+
*/
|
|
579
|
+
setDefault<T = any>(pipelineId: string): Promise<T>;
|
|
580
|
+
/**
|
|
581
|
+
* Duplicate a pipeline with a new name.
|
|
582
|
+
*/
|
|
583
|
+
duplicate<T = any>(pipelineId: string, newName: string): Promise<T>;
|
|
584
|
+
/**
|
|
585
|
+
* Archive a pipeline.
|
|
586
|
+
*/
|
|
587
|
+
archive<T = any>(pipelineId: string): Promise<T>;
|
|
588
|
+
/**
|
|
589
|
+
* Delete a pipeline permanently.
|
|
590
|
+
*/
|
|
591
|
+
delete(pipelineId: string): Promise<unknown>;
|
|
592
|
+
/**
|
|
593
|
+
* Retrieve a Kanban-style board representation of the pipeline with leads nested.
|
|
594
|
+
*/
|
|
595
|
+
board<T = any>(pipelineId: string): Promise<T>;
|
|
596
|
+
/**
|
|
597
|
+
* Retrieve a revenue forecast based on stage probabilities for a pipeline.
|
|
598
|
+
*/
|
|
599
|
+
forecast<T = any>(pipelineId: string): Promise<T>;
|
|
600
|
+
/**
|
|
601
|
+
* Add a new stage to the pipeline.
|
|
602
|
+
*/
|
|
603
|
+
addStage<T = any>(pipelineId: string, params: PipelineStageParams): Promise<T>;
|
|
604
|
+
/**
|
|
605
|
+
* Change the order of stages inside the pipeline.
|
|
606
|
+
*/
|
|
607
|
+
reorderStages<T = any>(pipelineId: string, orderArray: string[]): Promise<T>;
|
|
608
|
+
/**
|
|
609
|
+
* Update a specific stage.
|
|
610
|
+
*/
|
|
611
|
+
updateStage<T = any>(stageId: string, params: Partial<PipelineStageParams>): Promise<T>;
|
|
612
|
+
/**
|
|
613
|
+
* Delete a stage. Optionally provide a fallback stageId to move active leads to.
|
|
614
|
+
*/
|
|
615
|
+
deleteStage(stageId: string, moveLeadsToStageId?: string): Promise<unknown>;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
interface LogActivityParams {
|
|
619
|
+
leadId: string;
|
|
620
|
+
type: "note" | "call" | "email" | "meeting" | "whatsapp" | "system";
|
|
621
|
+
title: string;
|
|
622
|
+
body?: string;
|
|
623
|
+
metadata?: Record<string, any>;
|
|
624
|
+
}
|
|
625
|
+
interface LogCallParams {
|
|
626
|
+
durationMinutes: number;
|
|
627
|
+
summary: string;
|
|
628
|
+
outcome: "answered" | "no_answer" | "busy" | "voicemail" | "wrong_number";
|
|
629
|
+
}
|
|
630
|
+
declare class Notes extends APIResource {
|
|
631
|
+
/**
|
|
632
|
+
* List all notes for a specific lead.
|
|
633
|
+
*/
|
|
634
|
+
list<T = any>(leadId: string): Promise<T>;
|
|
635
|
+
/**
|
|
636
|
+
* Add a note to a lead.
|
|
637
|
+
*/
|
|
638
|
+
create<T = any>(
|
|
639
|
+
leadId: string,
|
|
640
|
+
params: {
|
|
641
|
+
content: string;
|
|
642
|
+
},
|
|
643
|
+
): Promise<T>;
|
|
644
|
+
/**
|
|
645
|
+
* Update an existing note.
|
|
646
|
+
*/
|
|
647
|
+
update<T = any>(noteId: string, content: string): Promise<T>;
|
|
648
|
+
/**
|
|
649
|
+
* Pin or unpin a note to the top of the feed.
|
|
650
|
+
*/
|
|
651
|
+
pin<T = any>(noteId: string, isPinned?: boolean): Promise<T>;
|
|
652
|
+
/**
|
|
653
|
+
* Delete a note.
|
|
654
|
+
*/
|
|
655
|
+
delete(noteId: string): Promise<unknown>;
|
|
656
|
+
}
|
|
657
|
+
declare class Activities extends APIResource {
|
|
658
|
+
notes: Notes;
|
|
659
|
+
constructor(client: any);
|
|
660
|
+
/**
|
|
661
|
+
* Retrieve the complete chronological timeline for a lead.
|
|
662
|
+
*/
|
|
663
|
+
timeline<T = any>(
|
|
664
|
+
leadId: string,
|
|
665
|
+
params?: {
|
|
666
|
+
page?: number;
|
|
667
|
+
limit?: number;
|
|
668
|
+
},
|
|
669
|
+
): Promise<T>;
|
|
670
|
+
/**
|
|
671
|
+
* List specific activities (filtered by type).
|
|
672
|
+
*/
|
|
673
|
+
list<T = any>(
|
|
674
|
+
leadId: string,
|
|
675
|
+
params?: {
|
|
676
|
+
type?: string;
|
|
677
|
+
page?: number;
|
|
678
|
+
limit?: number;
|
|
679
|
+
},
|
|
680
|
+
): Promise<T>;
|
|
681
|
+
/**
|
|
682
|
+
* Generic method to log a business activity/event.
|
|
683
|
+
*/
|
|
684
|
+
log<T = any>(params: LogActivityParams): Promise<T>;
|
|
685
|
+
/**
|
|
686
|
+
* Specific method to log communication outcomes.
|
|
687
|
+
*/
|
|
688
|
+
logCall<T = any>(leadId: string, params: LogCallParams): Promise<T>;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
type AnalyticsRange = "24h" | "7d" | "30d" | "60d" | "90d" | "365d";
|
|
692
|
+
interface AnalyticsParams {
|
|
693
|
+
range?: AnalyticsRange;
|
|
694
|
+
from?: string;
|
|
695
|
+
to?: string;
|
|
696
|
+
pipelineId?: string;
|
|
697
|
+
}
|
|
698
|
+
declare class Analytics extends APIResource {
|
|
699
|
+
/**
|
|
700
|
+
* KPIs: total leads, pipeline value, won revenue, avg score, conversion rate.
|
|
701
|
+
*/
|
|
702
|
+
overview<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
703
|
+
/**
|
|
704
|
+
* Stage-by-stage lead counts and conversion percentages.
|
|
705
|
+
*/
|
|
706
|
+
funnel<T = any>(pipelineId: string): Promise<T>;
|
|
707
|
+
/**
|
|
708
|
+
* Revenue forecast: deal value × stage probability.
|
|
709
|
+
*/
|
|
710
|
+
forecast<T = any>(pipelineId?: string): Promise<T>;
|
|
711
|
+
/**
|
|
712
|
+
* Lead source breakdown: count, conversion rate, total value per source.
|
|
713
|
+
*/
|
|
714
|
+
sources<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
715
|
+
/**
|
|
716
|
+
* Team leaderboard: won deals, revenue, activity count, conversion rate per member.
|
|
717
|
+
*/
|
|
718
|
+
team<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
719
|
+
/**
|
|
720
|
+
* Daily activity counts by type. For activity calendar.
|
|
721
|
+
*/
|
|
722
|
+
heatmap<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
723
|
+
/**
|
|
724
|
+
* Score distribution: how many leads in each score bucket.
|
|
725
|
+
*/
|
|
726
|
+
scores<T = any>(): Promise<T>;
|
|
727
|
+
/**
|
|
728
|
+
* Avg time leads spend in each stage. Helps find bottlenecks.
|
|
729
|
+
*/
|
|
730
|
+
stageTime<T = any>(pipelineId: string): Promise<T>;
|
|
731
|
+
/**
|
|
732
|
+
* Tiered Growth Report matching business sophistication.
|
|
733
|
+
*/
|
|
734
|
+
tiered<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
735
|
+
/**
|
|
736
|
+
* Consolidated analytics including CRM overview and WhatsApp.
|
|
737
|
+
*/
|
|
738
|
+
summary<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
739
|
+
/**
|
|
740
|
+
* WhatsApp volume and delivery analytics.
|
|
741
|
+
*/
|
|
742
|
+
whatsapp<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
interface AutomationRulePayload {
|
|
746
|
+
name: string;
|
|
747
|
+
trigger: string;
|
|
748
|
+
isActive?: boolean;
|
|
749
|
+
nodes: any[];
|
|
750
|
+
edges: any[];
|
|
751
|
+
}
|
|
752
|
+
declare class Automations extends APIResource {
|
|
753
|
+
/**
|
|
754
|
+
* List all automation rules for the tenant.
|
|
755
|
+
*/
|
|
756
|
+
list<T = any>(): Promise<T>;
|
|
757
|
+
/**
|
|
758
|
+
* Create a new automation rule.
|
|
759
|
+
*/
|
|
760
|
+
create<T = any>(payload: AutomationRulePayload): Promise<T>;
|
|
761
|
+
/**
|
|
762
|
+
* Update an existing automation rule.
|
|
763
|
+
*/
|
|
764
|
+
update<T = any>(ruleId: string, payload: Partial<AutomationRulePayload>): Promise<T>;
|
|
765
|
+
/**
|
|
766
|
+
* Enable or disable an automation rule.
|
|
767
|
+
*/
|
|
768
|
+
toggle<T = any>(ruleId: string): Promise<T>;
|
|
769
|
+
/**
|
|
770
|
+
* Delete an automation rule.
|
|
771
|
+
*/
|
|
772
|
+
deleteRule<T = any>(ruleId: string): Promise<T>;
|
|
773
|
+
/**
|
|
774
|
+
* Bulk delete rules.
|
|
775
|
+
*/
|
|
776
|
+
bulkDelete<T = any>(ruleIds: string[]): Promise<T>;
|
|
777
|
+
/**
|
|
778
|
+
* Dry-run test an automation rule against a specific lead.
|
|
779
|
+
*/
|
|
780
|
+
test<T = any>(ruleId: string, leadId: string): Promise<T>;
|
|
781
|
+
/**
|
|
782
|
+
* List enrollments for a rule.
|
|
783
|
+
*/
|
|
784
|
+
enrollments<T = any>(ruleId: string): Promise<T>;
|
|
785
|
+
/**
|
|
786
|
+
* Get an enrollment detail.
|
|
787
|
+
*/
|
|
788
|
+
getEnrollment<T = any>(enrollmentId: string): Promise<T>;
|
|
789
|
+
/**
|
|
790
|
+
* Pause an enrollment.
|
|
791
|
+
*/
|
|
792
|
+
pauseEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
|
|
793
|
+
/**
|
|
794
|
+
* Resume an enrollment.
|
|
795
|
+
*/
|
|
796
|
+
resumeEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
|
|
797
|
+
/**
|
|
798
|
+
* List workflow runs.
|
|
799
|
+
*/
|
|
800
|
+
runs<T = any>(ruleId: string): Promise<T>;
|
|
801
|
+
/**
|
|
802
|
+
* Get run details.
|
|
803
|
+
*/
|
|
804
|
+
getRun<T = any>(runId: string): Promise<T>;
|
|
805
|
+
/**
|
|
806
|
+
* Resume a paused run.
|
|
807
|
+
*/
|
|
808
|
+
resumeRun<T = any>(runId: string): Promise<T>;
|
|
809
|
+
/**
|
|
810
|
+
* Abort a running workflow.
|
|
811
|
+
*/
|
|
812
|
+
abortRun<T = any>(runId: string): Promise<T>;
|
|
813
|
+
/**
|
|
814
|
+
* Emit an external webhook event to unlock a `wait_event` node inside a
|
|
815
|
+
* paused workflow run. Required when integrating third-party tools that
|
|
816
|
+
* need to resume a suspended automation.
|
|
817
|
+
*
|
|
818
|
+
* @param ruleId - The automation rule that contains the wait_event node.
|
|
819
|
+
* @param eventName - The event name that should match the node's condition.
|
|
820
|
+
* @param payload - Arbitrary data forwarded to the node context.
|
|
821
|
+
*/
|
|
822
|
+
webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any): Promise<T>;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
declare class Sequences extends APIResource {
|
|
826
|
+
/**
|
|
827
|
+
* Manually enroll a lead in a drip sequence (automation rule).
|
|
828
|
+
*/
|
|
829
|
+
enroll<T = any>(payload: {
|
|
830
|
+
leadId: string;
|
|
831
|
+
ruleId: string;
|
|
832
|
+
variables?: Record<string, any>;
|
|
833
|
+
}): Promise<T>;
|
|
834
|
+
/**
|
|
835
|
+
* Unenroll a lead from a running sequence.
|
|
836
|
+
*/
|
|
837
|
+
unenroll<T = any>(enrollmentId: string): Promise<T>;
|
|
838
|
+
/**
|
|
839
|
+
* List active sequence enrollments for a specific lead.
|
|
840
|
+
*/
|
|
841
|
+
listForLead<T = any>(leadId: string): Promise<T>;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
interface ScoringConfig {
|
|
845
|
+
decayDays: number;
|
|
846
|
+
thresholds: {
|
|
847
|
+
hot: number;
|
|
848
|
+
warm: number;
|
|
849
|
+
};
|
|
850
|
+
rules: any[];
|
|
851
|
+
}
|
|
852
|
+
declare class Scoring extends APIResource {
|
|
853
|
+
/**
|
|
854
|
+
* Retrieve the tenant's global lead scoring configuration.
|
|
855
|
+
*/
|
|
856
|
+
getConfig<T = any>(): Promise<T>;
|
|
857
|
+
/**
|
|
858
|
+
* Update scoring configuration.
|
|
859
|
+
*/
|
|
860
|
+
updateConfig<T = any>(payload: Partial<ScoringConfig>): Promise<T>;
|
|
861
|
+
/**
|
|
862
|
+
* Force recalculate the score for a specific lead.
|
|
863
|
+
*/
|
|
864
|
+
recalculate<T = any>(leadId: string): Promise<T>;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
declare class Payments extends APIResource {
|
|
868
|
+
/**
|
|
869
|
+
* Record an inbound payment against a lead or appointment.
|
|
870
|
+
*/
|
|
871
|
+
capture<T = any>(payload: {
|
|
872
|
+
leadId: string;
|
|
873
|
+
amount: number;
|
|
874
|
+
currency?: string;
|
|
875
|
+
description?: string;
|
|
876
|
+
appointmentId?: string;
|
|
877
|
+
}): Promise<T>;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
declare class AutomationDashboard extends APIResource {
|
|
881
|
+
/**
|
|
882
|
+
* Retrieve summary statistics for automation health.
|
|
883
|
+
*/
|
|
884
|
+
stats<T = any>(): Promise<T>;
|
|
885
|
+
/**
|
|
886
|
+
* List recent EventLog entries (automation logs).
|
|
887
|
+
*/
|
|
888
|
+
logs<T = any>(params?: {
|
|
889
|
+
limit?: number;
|
|
890
|
+
status?: string;
|
|
891
|
+
}): Promise<T>;
|
|
892
|
+
/**
|
|
893
|
+
* Re-emit a failed event log to process its automations again.
|
|
894
|
+
*/
|
|
895
|
+
retryFailedEvent<T = any>(logId: string): Promise<T>;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
declare class CRM {
|
|
899
|
+
leads: Leads;
|
|
900
|
+
pipelines: Pipelines;
|
|
901
|
+
activities: Activities;
|
|
902
|
+
analytics: Analytics;
|
|
903
|
+
automations: Automations;
|
|
904
|
+
sequences: Sequences;
|
|
905
|
+
scoring: Scoring;
|
|
906
|
+
payments: Payments;
|
|
907
|
+
automationDashboard: AutomationDashboard;
|
|
908
|
+
constructor(client: AxiosInstance);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Options for the `upload()` elite helper.
|
|
913
|
+
*/
|
|
914
|
+
interface UploadOptions {
|
|
915
|
+
/**
|
|
916
|
+
* The destination folder key in R2.
|
|
917
|
+
* @example "customer_documents" | "avatars" | "invoices"
|
|
918
|
+
*/
|
|
919
|
+
folder: string;
|
|
920
|
+
/**
|
|
921
|
+
* The desired filename, including extension.
|
|
922
|
+
* @example "contract.pdf" | "profile.jpg"
|
|
923
|
+
*/
|
|
924
|
+
filename: string;
|
|
925
|
+
/**
|
|
926
|
+
* The MIME type of the file.
|
|
927
|
+
* @example "application/pdf" | "image/jpeg" | "video/mp4"
|
|
928
|
+
*/
|
|
929
|
+
contentType: string;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Cloudflare R2-backed media resource.
|
|
933
|
+
*
|
|
934
|
+
* Access via `ecod.media`.
|
|
935
|
+
*
|
|
936
|
+
* The `upload()` method is the recommended approach. It acts as a client-side
|
|
937
|
+
* orchestrator: it fetches a presigned URL from the backend, uploads directly
|
|
938
|
+
* to R2 (bypassing the API server), then confirms the upload — all in one call.
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* ```typescript
|
|
942
|
+
* const { data } = await ecod.media.upload(fileBuffer, {
|
|
943
|
+
* folder: "invoices",
|
|
944
|
+
* filename: "invoice-001.pdf",
|
|
945
|
+
* contentType: "application/pdf",
|
|
946
|
+
* });
|
|
947
|
+
* console.log(data.url); // → https://cdn.ecodrix.com/invoices/invoice-001.pdf
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
declare class MediaResource extends APIResource {
|
|
951
|
+
/**
|
|
952
|
+
* Get current storage usage metrics for the tenant.
|
|
953
|
+
*
|
|
954
|
+
* @returns `{ usedMB, limitMB, fileCount }`
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```typescript
|
|
958
|
+
* const { data } = await ecod.media.getUsage();
|
|
959
|
+
* console.log(`${data.usedMB} / ${data.limitMB} MB used`);
|
|
960
|
+
* ```
|
|
961
|
+
*/
|
|
962
|
+
getUsage(): Promise<unknown>;
|
|
963
|
+
/**
|
|
964
|
+
* Create a new top-level folder in the tenant's R2 bucket.
|
|
965
|
+
*
|
|
966
|
+
* @param name - Folder name (alphanumeric, hyphens, underscores).
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```typescript
|
|
970
|
+
* await ecod.media.createFolder("patient_records");
|
|
971
|
+
* ```
|
|
972
|
+
*/
|
|
973
|
+
createFolder(name: string): Promise<unknown>;
|
|
974
|
+
/**
|
|
975
|
+
* List files within a specific folder, with optional date filtering.
|
|
976
|
+
*
|
|
977
|
+
* @param folder - The folder key to list.
|
|
978
|
+
* @param params - Optional `year` and `month` filters (e.g. `{ year: "2026", month: "04" }`).
|
|
979
|
+
* @returns Array of file metadata objects.
|
|
980
|
+
*
|
|
981
|
+
* @example
|
|
982
|
+
* ```typescript
|
|
983
|
+
* const { data: files } = await ecod.media.list("invoices", { year: "2026" });
|
|
984
|
+
* ```
|
|
985
|
+
*/
|
|
986
|
+
list(
|
|
987
|
+
folder: string,
|
|
988
|
+
params?: {
|
|
989
|
+
year?: string;
|
|
990
|
+
month?: string;
|
|
991
|
+
},
|
|
992
|
+
): Promise<unknown>;
|
|
993
|
+
/**
|
|
994
|
+
* Delete a file from R2 by its storage key.
|
|
995
|
+
*
|
|
996
|
+
* @param key - The full storage key of the file (e.g. `"invoices/contract.pdf"`).
|
|
997
|
+
*
|
|
998
|
+
* @example
|
|
999
|
+
* ```typescript
|
|
1000
|
+
* await ecod.media.delete("invoices/old-contract.pdf");
|
|
1001
|
+
* ```
|
|
1002
|
+
*/
|
|
1003
|
+
delete(key: string): Promise<unknown>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Request a temporary presigned download URL for a private file.
|
|
1006
|
+
*
|
|
1007
|
+
* @param key - The full storage key of the file.
|
|
1008
|
+
* @returns `{ url }` — a time-limited download URL.
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
* ```typescript
|
|
1012
|
+
* const { data } = await ecod.media.getDownloadUrl("invoices/contract.pdf");
|
|
1013
|
+
* // → { url: "https://cdn.ecodrix.com/...?token=..." }
|
|
1014
|
+
* ```
|
|
1015
|
+
*/
|
|
1016
|
+
getDownloadUrl(key: string): Promise<unknown>;
|
|
1017
|
+
/**
|
|
1018
|
+
* **Elite Upload Helper** — uploads a file to Cloudflare R2 in a single call.
|
|
1019
|
+
*
|
|
1020
|
+
* This orchestrates 3 steps transparently:
|
|
1021
|
+
* 1. Fetch a presigned `PUT` URL from the ECODrIx backend.
|
|
1022
|
+
* 2. Upload the file _directly_ to R2 (no API proxy, maximum throughput).
|
|
1023
|
+
* 3. Confirm the upload with the backend so it is indexed and tracked.
|
|
1024
|
+
*
|
|
1025
|
+
* Works with Node.js `Buffer`, browser `File`/`Blob`, or any stream-like
|
|
1026
|
+
* object that Axios can PUT.
|
|
1027
|
+
*
|
|
1028
|
+
* @param file - The file data to upload.
|
|
1029
|
+
* @param options - Folder, filename, and content type.
|
|
1030
|
+
* @returns Confirmed file metadata including `key` and `url`.
|
|
1031
|
+
*
|
|
1032
|
+
* @example Node.js
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* import { readFileSync } from "fs";
|
|
1035
|
+
* const buf = readFileSync("./invoice.pdf");
|
|
1036
|
+
* const { data } = await ecod.media.upload(buf, {
|
|
1037
|
+
* folder: "invoices",
|
|
1038
|
+
* filename: "invoice-001.pdf",
|
|
1039
|
+
* contentType: "application/pdf",
|
|
1040
|
+
* });
|
|
1041
|
+
* ```
|
|
1042
|
+
*
|
|
1043
|
+
* @example Browser
|
|
1044
|
+
* ```typescript
|
|
1045
|
+
* const file = inputElement.files[0];
|
|
1046
|
+
* const { data } = await ecod.media.upload(file, {
|
|
1047
|
+
* folder: "avatars",
|
|
1048
|
+
* filename: file.name,
|
|
1049
|
+
* contentType: file.type,
|
|
1050
|
+
* });
|
|
1051
|
+
* ```
|
|
1052
|
+
*/
|
|
1053
|
+
upload(file: any, options: UploadOptions): Promise<any>;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Parameters for scheduling a new Google Meet appointment.
|
|
1058
|
+
*/
|
|
1059
|
+
interface CreateMeetingParams {
|
|
1060
|
+
/** The CRM Lead ID this meeting belongs to. */
|
|
1061
|
+
leadId: string;
|
|
1062
|
+
/** Full name of the external participant. */
|
|
1063
|
+
participantName: string;
|
|
1064
|
+
/** Phone number of the participant in E.164 format. */
|
|
1065
|
+
participantPhone: string;
|
|
1066
|
+
/**
|
|
1067
|
+
* Meeting start time.
|
|
1068
|
+
* @example new Date("2026-04-10T10:00:00.000Z")
|
|
1069
|
+
*/
|
|
1070
|
+
startTime: Date | string;
|
|
1071
|
+
/**
|
|
1072
|
+
* Meeting end time.
|
|
1073
|
+
* @example new Date("2026-04-10T10:30:00.000Z")
|
|
1074
|
+
*/
|
|
1075
|
+
endTime: Date | string;
|
|
1076
|
+
/** Arbitrary metadata to attach to the meeting record. */
|
|
1077
|
+
metadata?: Record<string, any>;
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Parameters for updating an existing meeting.
|
|
1081
|
+
*/
|
|
1082
|
+
interface UpdateMeetingParams {
|
|
1083
|
+
/**
|
|
1084
|
+
* Update the meeting status.
|
|
1085
|
+
* @example "scheduled" | "completed" | "cancelled"
|
|
1086
|
+
*/
|
|
1087
|
+
status?: string;
|
|
1088
|
+
/** Update the payment status for paid consultations. */
|
|
1089
|
+
paymentStatus?: string;
|
|
1090
|
+
/** New start time for rescheduling. */
|
|
1091
|
+
startTime?: Date | string;
|
|
1092
|
+
/** New end time for rescheduling. */
|
|
1093
|
+
endTime?: Date | string;
|
|
1094
|
+
/** Duration in minutes. */
|
|
1095
|
+
duration?: number;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Google Meet appointment scheduling resource.
|
|
1099
|
+
*
|
|
1100
|
+
* Access via `ecod.meet`.
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```typescript
|
|
1104
|
+
* const { data } = await ecod.meet.create({
|
|
1105
|
+
* leadId: "64abc...",
|
|
1106
|
+
* participantName: "Alice",
|
|
1107
|
+
* participantPhone: "+919876543210",
|
|
1108
|
+
* startTime: "2026-04-10T10:00:00Z",
|
|
1109
|
+
* endTime: "2026-04-10T10:30:00Z",
|
|
1110
|
+
* });
|
|
1111
|
+
* console.log(data.meetLink); // → https://meet.google.com/abc-defg-hij
|
|
1112
|
+
* ```
|
|
1113
|
+
*/
|
|
1114
|
+
declare class Meetings extends APIResource {
|
|
1115
|
+
/**
|
|
1116
|
+
* Schedule a new Google Meet with a lead.
|
|
1117
|
+
*
|
|
1118
|
+
* The backend automatically creates a Google Calendar event and generates
|
|
1119
|
+
* a Meet link, then sends confirmation notifications via WhatsApp.
|
|
1120
|
+
*
|
|
1121
|
+
* @param data - Meeting details.
|
|
1122
|
+
* @returns The created Meeting document including `meetLink`.
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```typescript
|
|
1126
|
+
* const { data } = await ecod.meet.create({
|
|
1127
|
+
* leadId: "64abc...",
|
|
1128
|
+
* participantName: "Alice",
|
|
1129
|
+
* participantPhone: "+91...",
|
|
1130
|
+
* startTime: "2026-04-10T10:00:00Z",
|
|
1131
|
+
* endTime: "2026-04-10T10:30:00Z",
|
|
1132
|
+
* });
|
|
1133
|
+
* ```
|
|
1134
|
+
*/
|
|
1135
|
+
create(data: CreateMeetingParams): Promise<any>;
|
|
1136
|
+
/**
|
|
1137
|
+
* List all meetings for the tenant, with optional filters.
|
|
1138
|
+
*
|
|
1139
|
+
* @param params - `leadId` to filter by lead; `status` to filter by state.
|
|
1140
|
+
* @returns Array of Meeting documents.
|
|
1141
|
+
*
|
|
1142
|
+
* @example
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* const { data } = await ecod.meet.list({ status: "scheduled" });
|
|
1145
|
+
* ```
|
|
1146
|
+
*/
|
|
1147
|
+
list(params?: {
|
|
1148
|
+
leadId?: string;
|
|
1149
|
+
status?: string;
|
|
1150
|
+
}): Promise<any>;
|
|
1151
|
+
/**
|
|
1152
|
+
* Retrieve the full details for a specific meeting.
|
|
1153
|
+
*
|
|
1154
|
+
* @param meetingId - The unique meeting ID.
|
|
1155
|
+
* @returns The Meeting document.
|
|
1156
|
+
*
|
|
1157
|
+
* @example
|
|
1158
|
+
* ```typescript
|
|
1159
|
+
* const { data } = await ecod.meet.retrieve("meeting_id");
|
|
1160
|
+
* ```
|
|
1161
|
+
*/
|
|
1162
|
+
retrieve(meetingId: string): Promise<any>;
|
|
1163
|
+
/**
|
|
1164
|
+
* Update or reschedule an existing meeting.
|
|
1165
|
+
*
|
|
1166
|
+
* Partial updates are supported — only supply the fields you wish to change.
|
|
1167
|
+
*
|
|
1168
|
+
* @param meetingId - The meeting to update.
|
|
1169
|
+
* @param data - Fields to update.
|
|
1170
|
+
* @returns The updated Meeting document.
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```typescript
|
|
1174
|
+
* // Reschedule
|
|
1175
|
+
* await ecod.meet.update("meeting_id", {
|
|
1176
|
+
* startTime: "2026-04-11T11:00:00Z",
|
|
1177
|
+
* endTime: "2026-04-11T11:30:00Z",
|
|
1178
|
+
* });
|
|
1179
|
+
* ```
|
|
1180
|
+
*/
|
|
1181
|
+
update<T = any>(meetingId: string, data: UpdateMeetingParams): Promise<T>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Reschedule an existing meeting. Provides explicit method for time modifications.
|
|
1184
|
+
*/
|
|
1185
|
+
reschedule<T = any>(
|
|
1186
|
+
meetingId: string,
|
|
1187
|
+
params: {
|
|
1188
|
+
startTime: Date | string;
|
|
1189
|
+
endTime: Date | string;
|
|
1190
|
+
duration?: number;
|
|
1191
|
+
},
|
|
1192
|
+
): Promise<T>;
|
|
1193
|
+
/**
|
|
1194
|
+
* Cancel a meeting. This sets the meeting status to `"cancelled"`.
|
|
1195
|
+
*
|
|
1196
|
+
* @param meetingId - The meeting to cancel.
|
|
1197
|
+
*
|
|
1198
|
+
* @example
|
|
1199
|
+
* ```typescript
|
|
1200
|
+
* await ecod.meet.delete("meeting_id");
|
|
1201
|
+
* ```
|
|
1202
|
+
*/
|
|
1203
|
+
delete(meetingId: string): Promise<any>;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* Filters for querying event and automation execution logs.
|
|
1208
|
+
*/
|
|
1209
|
+
interface LogFilter {
|
|
1210
|
+
/** Page number for pagination (1-indexed). */
|
|
1211
|
+
page?: number;
|
|
1212
|
+
/** Maximum number of records to return per page. */
|
|
1213
|
+
limit?: number;
|
|
1214
|
+
/**
|
|
1215
|
+
* Filter by automation trigger name.
|
|
1216
|
+
* @example "lead_created" | "appointment_booked"
|
|
1217
|
+
*/
|
|
1218
|
+
trigger?: string;
|
|
1219
|
+
/**
|
|
1220
|
+
* Filter by execution status.
|
|
1221
|
+
* @example "success" | "failed" | "pending"
|
|
1222
|
+
*/
|
|
1223
|
+
status?: string;
|
|
1224
|
+
/** Filter logs associated with a specific phone number. */
|
|
1225
|
+
phone?: string;
|
|
1226
|
+
/** Start of the date range (inclusive). ISO 8601 or Date object. */
|
|
1227
|
+
startDate?: string | Date;
|
|
1228
|
+
/** End of the date range (inclusive). ISO 8601 or Date object. */
|
|
1229
|
+
endDate?: string | Date;
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* Automation event log and provider callback resource.
|
|
1233
|
+
*
|
|
1234
|
+
* Access via `ecod.notifications`.
|
|
1235
|
+
*
|
|
1236
|
+
* This resource is **read-only**. It exposes platform audit trails — useful
|
|
1237
|
+
* for debugging automation failures, monitoring webhook callbacks, and
|
|
1238
|
+
* building internal ops dashboards.
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```typescript
|
|
1242
|
+
* // Find failed automations in April
|
|
1243
|
+
* const { data } = await ecod.notifications.listLogs({
|
|
1244
|
+
* status: "failed",
|
|
1245
|
+
* startDate: "2026-04-01",
|
|
1246
|
+
* endDate: "2026-04-30",
|
|
1247
|
+
* });
|
|
1248
|
+
* ```
|
|
1249
|
+
*/
|
|
1250
|
+
declare class Notifications extends APIResource {
|
|
1251
|
+
/**
|
|
1252
|
+
* List automation execution logs with optional filtering.
|
|
1253
|
+
*
|
|
1254
|
+
* Each log entry represents one automation run triggered by a platform event.
|
|
1255
|
+
* Filter by `status: "failed"` to build a failure alerting pipeline.
|
|
1256
|
+
*
|
|
1257
|
+
* @param params - Optional filter criteria.
|
|
1258
|
+
* @returns Paginated list of event log objects.
|
|
1259
|
+
*
|
|
1260
|
+
* @example
|
|
1261
|
+
* ```typescript
|
|
1262
|
+
* const { data: failed } = await ecod.notifications.listLogs({
|
|
1263
|
+
* status: "failed",
|
|
1264
|
+
* trigger: "lead_created",
|
|
1265
|
+
* limit: 50,
|
|
1266
|
+
* });
|
|
1267
|
+
* ```
|
|
1268
|
+
*/
|
|
1269
|
+
listLogs(params?: LogFilter): Promise<unknown>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Retrieve the full details for a single automation event log entry.
|
|
1272
|
+
*
|
|
1273
|
+
* @param logId - The unique log ID.
|
|
1274
|
+
* @returns A single event log document including the payload and error trace.
|
|
1275
|
+
*
|
|
1276
|
+
* @example
|
|
1277
|
+
* ```typescript
|
|
1278
|
+
* const { data } = await ecod.notifications.retrieveLog("log_64abc...");
|
|
1279
|
+
* console.log(data.error); // → "Provider timeout after 30s"
|
|
1280
|
+
* ```
|
|
1281
|
+
*/
|
|
1282
|
+
retrieveLog(logId: string): Promise<unknown>;
|
|
1283
|
+
/**
|
|
1284
|
+
* Get a summary statistics object for automation event execution.
|
|
1285
|
+
*
|
|
1286
|
+
* @param params - Optional date range for the summary window.
|
|
1287
|
+
* @returns `{ total, success, failed, pending }` counts.
|
|
1288
|
+
*
|
|
1289
|
+
* @example
|
|
1290
|
+
* ```typescript
|
|
1291
|
+
* const { data: stats } = await ecod.notifications.getStats({
|
|
1292
|
+
* startDate: "2026-04-01",
|
|
1293
|
+
* endDate: "2026-04-30",
|
|
1294
|
+
* });
|
|
1295
|
+
* console.log(`Failed: ${stats.failed} / ${stats.total}`);
|
|
1296
|
+
* ```
|
|
1297
|
+
*/
|
|
1298
|
+
getStats(params?: {
|
|
1299
|
+
startDate?: string;
|
|
1300
|
+
endDate?: string;
|
|
1301
|
+
}): Promise<unknown>;
|
|
1302
|
+
/**
|
|
1303
|
+
* List external provider webhook callback logs.
|
|
1304
|
+
*
|
|
1305
|
+
* These are inbound HTTP callbacks from third-party providers
|
|
1306
|
+
* (payment gateways, email services, etc.) stored for audit purposes.
|
|
1307
|
+
*
|
|
1308
|
+
* @param params - Pagination and date filter options.
|
|
1309
|
+
* @returns Paginated list of callback log records.
|
|
1310
|
+
*
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```typescript
|
|
1313
|
+
* const { data } = await ecod.notifications.listCallbacks({ limit: 20 });
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
listCallbacks(params?: Omit<LogFilter, "trigger" | "phone">): Promise<unknown>;
|
|
1317
|
+
/**
|
|
1318
|
+
* List active CRM notifications/alerts for the current agent.
|
|
1319
|
+
*/
|
|
1320
|
+
listAlerts<T = any>(params?: {
|
|
1321
|
+
limit?: number;
|
|
1322
|
+
unreadOnly?: boolean;
|
|
1323
|
+
}): Promise<T>;
|
|
1324
|
+
/**
|
|
1325
|
+
* Dismiss a specific notification alert.
|
|
1326
|
+
*/
|
|
1327
|
+
dismissAlert<T = any>(notificationId: string): Promise<T>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Clear (dismiss) all notifications for the current agent.
|
|
1330
|
+
*/
|
|
1331
|
+
clearAllAlerts<T = any>(): Promise<T>;
|
|
1332
|
+
/**
|
|
1333
|
+
* Retry an action from a notification (e.g. failed send).
|
|
1334
|
+
*/
|
|
1335
|
+
retryAction<T = any>(notificationId: string): Promise<T>;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Payload to send a high-throughput email campaign.
|
|
1340
|
+
*/
|
|
1341
|
+
interface SendCampaignPayload {
|
|
1342
|
+
/** Array of recipient email addresses. */
|
|
1343
|
+
recipients: string[];
|
|
1344
|
+
/** Subject line of the email. */
|
|
1345
|
+
subject: string;
|
|
1346
|
+
/** HTML body of the email. */
|
|
1347
|
+
html: string;
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Interface representing the result of a campaign dispatch.
|
|
1351
|
+
*/
|
|
1352
|
+
interface CampaignResult {
|
|
1353
|
+
success: boolean;
|
|
1354
|
+
message?: string;
|
|
1355
|
+
[key: string]: any;
|
|
1356
|
+
}
|
|
1357
|
+
declare class EmailResource extends APIResource {
|
|
1358
|
+
/**
|
|
1359
|
+
* Send an HTML email campaign to a list of recipients.
|
|
1360
|
+
*
|
|
1361
|
+
* @param payload - The campaign details (recipients, subject, html).
|
|
1362
|
+
* @returns The dispatch result.
|
|
1363
|
+
*/
|
|
1364
|
+
sendEmailCampaign(payload: SendCampaignPayload): Promise<CampaignResult>;
|
|
1365
|
+
/**
|
|
1366
|
+
* Send a system verification/test email to validate SMTP configuration.
|
|
1367
|
+
*
|
|
1368
|
+
* @param to - The recipient's email address.
|
|
1369
|
+
* @returns The dispatch result.
|
|
1370
|
+
*/
|
|
1371
|
+
sendTestEmail(to: string): Promise<CampaignResult>;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* Event definition representing an entry point capable of triggering automations.
|
|
1376
|
+
*/
|
|
1377
|
+
interface EventDefinition {
|
|
1378
|
+
name: string;
|
|
1379
|
+
displayName: string;
|
|
1380
|
+
description?: string;
|
|
1381
|
+
pipelineId?: string;
|
|
1382
|
+
stageId?: string;
|
|
1383
|
+
defaultSource?: string;
|
|
1384
|
+
[key: string]: any;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Payload to register/assign a new custom event definition.
|
|
1388
|
+
*/
|
|
1389
|
+
interface AssignEventPayload {
|
|
1390
|
+
/** The internal machine-readable name of the event (e.g. "webinar_joined") */
|
|
1391
|
+
name: string;
|
|
1392
|
+
/** Human-readable display name */
|
|
1393
|
+
displayName: string;
|
|
1394
|
+
/** Event description */
|
|
1395
|
+
description?: string;
|
|
1396
|
+
/** ID of the pipeline to associate with matching leads */
|
|
1397
|
+
pipelineId?: string;
|
|
1398
|
+
/** ID of the stage within the pipeline */
|
|
1399
|
+
stageId?: string;
|
|
1400
|
+
/** Default source tag for leads created via this event */
|
|
1401
|
+
defaultSource?: string;
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Payload to programmatically trigger an event/workflow.
|
|
1405
|
+
*/
|
|
1406
|
+
interface TriggerPayload {
|
|
1407
|
+
/** The name of the event to fire (e.g., "webinar_joined") */
|
|
1408
|
+
trigger: string;
|
|
1409
|
+
/** Phone number of the lead (E.164 format) */
|
|
1410
|
+
phone: string;
|
|
1411
|
+
/** Email of the lead */
|
|
1412
|
+
email?: string;
|
|
1413
|
+
/** Key-value pairs for string templates */
|
|
1414
|
+
variables?: Record<string, string>;
|
|
1415
|
+
/** Deep payload data mapping to the event */
|
|
1416
|
+
data?: any;
|
|
1417
|
+
/** URL to receive an acknowledgment callback when processing completes */
|
|
1418
|
+
callbackUrl?: string;
|
|
1419
|
+
/** Secret metadata passed back to the callback URL */
|
|
1420
|
+
callbackMetadata?: any;
|
|
1421
|
+
/** Auto-create lead if phone does not exist in CRM */
|
|
1422
|
+
createLeadIfMissing?: boolean;
|
|
1423
|
+
/** Pre-fill data if creating a new lead */
|
|
1424
|
+
leadData?: {
|
|
1425
|
+
firstName?: string;
|
|
1426
|
+
lastName?: string;
|
|
1427
|
+
source?: string;
|
|
1428
|
+
};
|
|
1429
|
+
/** Delay execution of matched workflows (in seconds) */
|
|
1430
|
+
delaySeconds?: number;
|
|
1431
|
+
/** Delay execution of matched workflows (in minutes) */
|
|
1432
|
+
delayMinutes?: number;
|
|
1433
|
+
/** Explicit ISO timestamp to trigger the workflow run */
|
|
1434
|
+
runAt?: string;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Response returned when triggering an event.
|
|
1438
|
+
*/
|
|
1439
|
+
interface TriggerResponse {
|
|
1440
|
+
success: boolean;
|
|
1441
|
+
data?: {
|
|
1442
|
+
eventLogId: string;
|
|
1443
|
+
trigger: string;
|
|
1444
|
+
leadId: string;
|
|
1445
|
+
rulesMatched: number;
|
|
1446
|
+
};
|
|
1447
|
+
message?: string;
|
|
1448
|
+
code?: string;
|
|
1449
|
+
}
|
|
1450
|
+
declare class EventsResource extends APIResource {
|
|
1451
|
+
/**
|
|
1452
|
+
* Retrieve all valid events (system + custom) that can be used as Automation Rule triggers.
|
|
1453
|
+
*/
|
|
1454
|
+
list(): Promise<{
|
|
1455
|
+
success: boolean;
|
|
1456
|
+
data: EventDefinition[];
|
|
1457
|
+
}>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Register a new custom event entry point into the CRM automation engine.
|
|
1460
|
+
* Useful when introducing new granular triggers.
|
|
1461
|
+
*/
|
|
1462
|
+
assign(payload: AssignEventPayload): Promise<{
|
|
1463
|
+
success: boolean;
|
|
1464
|
+
data: EventDefinition;
|
|
1465
|
+
}>;
|
|
1466
|
+
/**
|
|
1467
|
+
* Deactivate a custom event assignment by name.
|
|
1468
|
+
*/
|
|
1469
|
+
unassign(name: string): Promise<{
|
|
1470
|
+
success: boolean;
|
|
1471
|
+
data: any;
|
|
1472
|
+
}>;
|
|
1473
|
+
/**
|
|
1474
|
+
* Deactivate multiple custom event assignments simultaneously.
|
|
1475
|
+
*/
|
|
1476
|
+
unassignBulk(names: string[]): Promise<{
|
|
1477
|
+
success: boolean;
|
|
1478
|
+
message: string;
|
|
1479
|
+
}>;
|
|
1480
|
+
/**
|
|
1481
|
+
* Programmatically fire an event into the CRM automation engine.
|
|
1482
|
+
* Emits to the internal EventBus to match with active Workflow Automation Rules.
|
|
1483
|
+
*/
|
|
1484
|
+
trigger(payload: TriggerPayload): Promise<TriggerResponse>;
|
|
1485
|
+
/**
|
|
1486
|
+
* List all custom event definitions.
|
|
1487
|
+
*/
|
|
1488
|
+
listCustomEvents<T = any>(): Promise<T>;
|
|
1489
|
+
/**
|
|
1490
|
+
* Create or upsert a custom event definition.
|
|
1491
|
+
*/
|
|
1492
|
+
createCustomEvent<T = any>(payload: {
|
|
1493
|
+
name: string;
|
|
1494
|
+
displayName: string;
|
|
1495
|
+
description?: string;
|
|
1496
|
+
}): Promise<T>;
|
|
1497
|
+
/**
|
|
1498
|
+
* Delete a custom event definition.
|
|
1499
|
+
*/
|
|
1500
|
+
deleteCustomEvent<T = any>(id: string): Promise<T>;
|
|
1501
|
+
/**
|
|
1502
|
+
* Manually emit a custom event to trigger workflows based on its definition.
|
|
1503
|
+
*/
|
|
1504
|
+
emit<T = any>(payload: {
|
|
1505
|
+
eventName: string;
|
|
1506
|
+
leadId: string;
|
|
1507
|
+
data?: any;
|
|
1508
|
+
}): Promise<T>;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* Typed error hierarchy for the @ecodrix/erix-api SDK.
|
|
1513
|
+
*
|
|
1514
|
+
* All errors thrown by the SDK extend `EcodrixError`, so a single
|
|
1515
|
+
* `catch` block can handle them all, while still allowing granular
|
|
1516
|
+
* differentiation between auth failures, rate limits, and generic API errors.
|
|
1517
|
+
*
|
|
1518
|
+
* @example
|
|
1519
|
+
* ```typescript
|
|
1520
|
+
* import { APIError, AuthenticationError, RateLimitError } from "@ecodrix/erix-api";
|
|
1521
|
+
*
|
|
1522
|
+
* try {
|
|
1523
|
+
* await ecod.crm.leads.retrieve("invalid_id");
|
|
1524
|
+
* } catch (err) {
|
|
1525
|
+
* if (err instanceof AuthenticationError) {
|
|
1526
|
+
* console.error("Invalid API key or client code.");
|
|
1527
|
+
* } else if (err instanceof RateLimitError) {
|
|
1528
|
+
* console.warn("Slow down — rate limit hit.");
|
|
1529
|
+
* } else if (err instanceof APIError) {
|
|
1530
|
+
* console.error(`API error ${err.status}: ${err.message}`);
|
|
1531
|
+
* }
|
|
1532
|
+
* }
|
|
1533
|
+
* ```
|
|
1534
|
+
*/
|
|
1535
|
+
/** Base class for all ECODrIx SDK errors. */
|
|
1536
|
+
declare class EcodrixError extends Error {
|
|
1537
|
+
constructor(message: string);
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Represents an error returned by the ECODrIx API.
|
|
1541
|
+
* Carries the HTTP `status` code and an optional `code` string.
|
|
1542
|
+
*/
|
|
1543
|
+
declare class APIError extends EcodrixError {
|
|
1544
|
+
/** HTTP status code returned by the API (e.g. 400, 404, 500). */
|
|
1545
|
+
status?: number;
|
|
1546
|
+
/** Machine-readable error code (e.g. `"NOT_FOUND"`, `"VALIDATION_ERROR"`). */
|
|
1547
|
+
code?: string;
|
|
1548
|
+
constructor(message: string, status?: number, code?: string);
|
|
1549
|
+
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Thrown when the API key or client code is missing, invalid, or expired.
|
|
1552
|
+
* HTTP 401.
|
|
1553
|
+
*/
|
|
1554
|
+
declare class AuthenticationError extends APIError {
|
|
1555
|
+
constructor(message?: string);
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* Thrown when the rate limit for the API key has been exceeded.
|
|
1559
|
+
* HTTP 429. Implement exponential backoff before retrying.
|
|
1560
|
+
*/
|
|
1561
|
+
declare class RateLimitError extends APIError {
|
|
1562
|
+
constructor(message?: string);
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
declare class WebhookSignatureError extends APIError {
|
|
1566
|
+
constructor(message: string);
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Validates and constructs webhook events sent by the ECODrIx platform.
|
|
1570
|
+
* Ensures the payload has not been tampered with.
|
|
1571
|
+
*
|
|
1572
|
+
* @example
|
|
1573
|
+
* ```typescript
|
|
1574
|
+
* import { ecod } from "./services/ecodrix";
|
|
1575
|
+
*
|
|
1576
|
+
* app.post("/api/webhooks", async (req, res) => {
|
|
1577
|
+
* try {
|
|
1578
|
+
* const event = await ecod.webhooks.constructEvent(
|
|
1579
|
+
* req.rawBody,
|
|
1580
|
+
* req.headers["x-ecodrix-signature"],
|
|
1581
|
+
* process.env.ECOD_WEBHOOK_SECRET
|
|
1582
|
+
* );
|
|
1583
|
+
* console.log("Verified event:", event.type);
|
|
1584
|
+
* res.send({ received: true });
|
|
1585
|
+
* } catch (err) {
|
|
1586
|
+
* res.status(400).send(`Webhook Error: ${err.message}`);
|
|
1587
|
+
* }
|
|
1588
|
+
* });
|
|
1589
|
+
* ```
|
|
1590
|
+
*/
|
|
1591
|
+
declare class Webhooks {
|
|
1592
|
+
/**
|
|
1593
|
+
* Cryptographically validates a webhook payload.
|
|
1594
|
+
* Note: This method dynamically imports Node's `crypto` module, meaning it will only execute gracefully in a Server environment.
|
|
1595
|
+
*
|
|
1596
|
+
* @param payload - The raw request body as a string or Buffer.
|
|
1597
|
+
* @param signature - The `x-ecodrix-signature` header value.
|
|
1598
|
+
* @param secret - The webhook signing secret for your tenant.
|
|
1599
|
+
* @returns The parsed JSON object of the event if the signature is valid.
|
|
1600
|
+
* @throws WebhookSignatureError if the validation fails.
|
|
1601
|
+
*/
|
|
1602
|
+
constructEvent(
|
|
1603
|
+
payload: string | Buffer,
|
|
1604
|
+
signature: string | string[] | undefined,
|
|
1605
|
+
secret: string,
|
|
1606
|
+
): Promise<any>;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
declare class Folders extends APIResource {
|
|
1610
|
+
/**
|
|
1611
|
+
* Create a new folder.
|
|
1612
|
+
*/
|
|
1613
|
+
create<T = any>(name: string): Promise<T>;
|
|
1614
|
+
/**
|
|
1615
|
+
* Delete a folder and its contents.
|
|
1616
|
+
*/
|
|
1617
|
+
delete<T = any>(folderPath: string): Promise<T>;
|
|
1618
|
+
}
|
|
1619
|
+
declare class Files extends APIResource {
|
|
1620
|
+
/**
|
|
1621
|
+
* List files in a folder.
|
|
1622
|
+
*/
|
|
1623
|
+
list<T = any>(
|
|
1624
|
+
folder: string,
|
|
1625
|
+
params?: {
|
|
1626
|
+
year?: string;
|
|
1627
|
+
month?: string;
|
|
1628
|
+
},
|
|
1629
|
+
): Promise<T>;
|
|
1630
|
+
/**
|
|
1631
|
+
* Get a presigned upload URL for direct-to-cloud browser uploads.
|
|
1632
|
+
*/
|
|
1633
|
+
getUploadUrl<T = any>(params: {
|
|
1634
|
+
folder: string;
|
|
1635
|
+
filename: string;
|
|
1636
|
+
contentType: string;
|
|
1637
|
+
}): Promise<T>;
|
|
1638
|
+
/**
|
|
1639
|
+
* Notify backend after a successful direct browser upload.
|
|
1640
|
+
*/
|
|
1641
|
+
confirmUpload<T = any>(params: {
|
|
1642
|
+
key: string;
|
|
1643
|
+
sizeBytes: number;
|
|
1644
|
+
}): Promise<T>;
|
|
1645
|
+
/**
|
|
1646
|
+
* Get a presigned download URL for an R2 key.
|
|
1647
|
+
*/
|
|
1648
|
+
getDownloadUrl<T = any>(key: string): Promise<T>;
|
|
1649
|
+
/**
|
|
1650
|
+
* Delete a file by key.
|
|
1651
|
+
*/
|
|
1652
|
+
delete(key: string): Promise<unknown>;
|
|
1653
|
+
}
|
|
1654
|
+
declare class Storage extends APIResource {
|
|
1655
|
+
folders: Folders;
|
|
1656
|
+
files: Files;
|
|
1657
|
+
constructor(client: any);
|
|
1658
|
+
/**
|
|
1659
|
+
* Get tenant storage usage and quota limitations.
|
|
1660
|
+
*/
|
|
1661
|
+
usage<T = any>(): Promise<T>;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
interface SendCampaignParams {
|
|
1665
|
+
recipients: string[];
|
|
1666
|
+
subject: string;
|
|
1667
|
+
html: string;
|
|
1668
|
+
}
|
|
1669
|
+
declare class Emails extends APIResource {
|
|
1670
|
+
/**
|
|
1671
|
+
* Dispatch a bulk email campaign.
|
|
1672
|
+
*/
|
|
1673
|
+
sendCampaign<T = any>(params: SendCampaignParams): Promise<T>;
|
|
1674
|
+
/**
|
|
1675
|
+
* Send a test verification email (used to verify SMTP functionality).
|
|
1676
|
+
*/
|
|
1677
|
+
sendTest<T = any>(to: string): Promise<T>;
|
|
1678
|
+
}
|
|
1679
|
+
declare class Campaigns extends APIResource {
|
|
1680
|
+
/**
|
|
1681
|
+
* List email and SMS marketing campaigns.
|
|
1682
|
+
*/
|
|
1683
|
+
list<T = any>(params?: {
|
|
1684
|
+
status?: string;
|
|
1685
|
+
limit?: number;
|
|
1686
|
+
}): Promise<T>;
|
|
1687
|
+
/**
|
|
1688
|
+
* Create a new campaign.
|
|
1689
|
+
*/
|
|
1690
|
+
create<T = any>(payload: {
|
|
1691
|
+
name: string;
|
|
1692
|
+
type: string;
|
|
1693
|
+
subject?: string;
|
|
1694
|
+
html?: string;
|
|
1695
|
+
templateId?: string;
|
|
1696
|
+
recipients?: string[];
|
|
1697
|
+
}): Promise<T>;
|
|
1698
|
+
/**
|
|
1699
|
+
* Retrieve campaign details.
|
|
1700
|
+
*/
|
|
1701
|
+
retrieve<T = any>(campaignId: string): Promise<T>;
|
|
1702
|
+
/**
|
|
1703
|
+
* Update a campaign.
|
|
1704
|
+
*/
|
|
1705
|
+
update<T = any>(campaignId: string, payload: any): Promise<T>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Delete a campaign.
|
|
1708
|
+
*/
|
|
1709
|
+
delete<T = any>(campaignId: string): Promise<T>;
|
|
1710
|
+
/**
|
|
1711
|
+
* Send or schedule a campaign.
|
|
1712
|
+
*/
|
|
1713
|
+
send<T = any>(
|
|
1714
|
+
campaignId: string,
|
|
1715
|
+
payload?: {
|
|
1716
|
+
scheduledAt?: string;
|
|
1717
|
+
},
|
|
1718
|
+
): Promise<T>;
|
|
1719
|
+
/**
|
|
1720
|
+
* Get campaign stats (opens, clicks, bounces).
|
|
1721
|
+
*/
|
|
1722
|
+
stats<T = any>(campaignId: string): Promise<T>;
|
|
1723
|
+
}
|
|
1724
|
+
declare class Marketing extends APIResource {
|
|
1725
|
+
emails: Emails;
|
|
1726
|
+
campaigns: Campaigns;
|
|
1727
|
+
constructor(client: any);
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
interface SystemHealth {
|
|
1731
|
+
status: string;
|
|
1732
|
+
version: string;
|
|
1733
|
+
env: string;
|
|
1734
|
+
uptime: number;
|
|
1735
|
+
db: string;
|
|
1736
|
+
queueDepth: number;
|
|
1737
|
+
timestamp: string;
|
|
1738
|
+
}
|
|
1739
|
+
interface ClientHealth {
|
|
1740
|
+
clientCode: string;
|
|
1741
|
+
services: {
|
|
1742
|
+
whatsapp: "connected" | "not_configured";
|
|
1743
|
+
email: "configured" | "not_configured";
|
|
1744
|
+
googleMeet: "configured" | "not_configured";
|
|
1745
|
+
};
|
|
1746
|
+
activeAutomations: number;
|
|
1747
|
+
queueDepth: number;
|
|
1748
|
+
timestamp: string;
|
|
1749
|
+
}
|
|
1750
|
+
interface JobStatus {
|
|
1751
|
+
jobId: string;
|
|
1752
|
+
status: string;
|
|
1753
|
+
attempts: number;
|
|
1754
|
+
maxAttempts: number;
|
|
1755
|
+
lastError: any;
|
|
1756
|
+
runAt: string;
|
|
1757
|
+
completedAt: string | null;
|
|
1758
|
+
failedAt: string | null;
|
|
1759
|
+
createdAt: string;
|
|
1760
|
+
}
|
|
1761
|
+
declare class Health extends APIResource {
|
|
1762
|
+
/**
|
|
1763
|
+
* Global platform health check.
|
|
1764
|
+
*/
|
|
1765
|
+
system(): Promise<SystemHealth>;
|
|
1766
|
+
/**
|
|
1767
|
+
* Tenant-specific health check. Identifies configured services.
|
|
1768
|
+
*/
|
|
1769
|
+
clientHealth(): Promise<ClientHealth>;
|
|
1770
|
+
/**
|
|
1771
|
+
* Job execution status lookup.
|
|
1772
|
+
*/
|
|
1773
|
+
jobStatus(jobId: string): Promise<JobStatus>;
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* Configuration options for the Ecodrix client.
|
|
1778
|
+
*/
|
|
1779
|
+
interface EcodrixOptions {
|
|
1780
|
+
/**
|
|
1781
|
+
* Your ECODrIx Platform API key.
|
|
1782
|
+
* Obtain this from the ECODrIx dashboard under Settings → API Keys.
|
|
1783
|
+
* @example "ecod_live_sk_..."
|
|
1784
|
+
*/
|
|
1785
|
+
apiKey: string;
|
|
1786
|
+
/**
|
|
1787
|
+
* Your tenant ID (Client Code).
|
|
1788
|
+
* This scopes all API requests to your specific organisation.
|
|
1789
|
+
* Required for most operations.
|
|
1790
|
+
* @example "ERIX_CLNT_JHBJHF"
|
|
1791
|
+
*/
|
|
1792
|
+
clientCode?: string;
|
|
1793
|
+
/**
|
|
1794
|
+
* Override the base URL of the ECODrIx API.
|
|
1795
|
+
* Useful for pointing to a local development or staging server.
|
|
1796
|
+
* @default "https://api.ecodrix.com"
|
|
1797
|
+
*/
|
|
1798
|
+
baseUrl?: string;
|
|
1799
|
+
/**
|
|
1800
|
+
* Override the Socket.io server URL for real-time events.
|
|
1801
|
+
* Defaults to the same value as `baseUrl`.
|
|
1802
|
+
* @default "https://api.ecodrix.com"
|
|
1803
|
+
*/
|
|
1804
|
+
socketUrl?: string;
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* The primary entry point for the ECODrIx SDK.
|
|
1808
|
+
*
|
|
1809
|
+
* Initialise once with your credentials and use the namespaced resources
|
|
1810
|
+
* to interact with every part of the platform.
|
|
1811
|
+
*
|
|
1812
|
+
* @example
|
|
1813
|
+
* ```typescript
|
|
1814
|
+
* import { Ecodrix } from "@ecodrix/erix-api";
|
|
1815
|
+
*
|
|
1816
|
+
* const ecod = new Ecodrix({
|
|
1817
|
+
* apiKey: process.env.ECOD_API_KEY!,
|
|
1818
|
+
* clientCode: "ERIX_CLNT_JHBJHF",
|
|
1819
|
+
* });
|
|
1820
|
+
*
|
|
1821
|
+
* await ecod.whatsapp.messages.send({ to: "+91...", text: "Hello!" });
|
|
1822
|
+
* const lead = await ecod.crm.leads.create({ firstName: "Alice", phone: "+91..." });
|
|
1823
|
+
* ```
|
|
1824
|
+
*/
|
|
1825
|
+
declare class Ecodrix {
|
|
1826
|
+
private readonly client;
|
|
1827
|
+
private readonly socket;
|
|
1828
|
+
/** WhatsApp messaging and conversation management. */
|
|
1829
|
+
readonly whatsapp: WhatsApp;
|
|
1830
|
+
/** CRM resources — Leads and related sub-resources. */
|
|
1831
|
+
readonly crm: CRM;
|
|
1832
|
+
/** Cloudflare R2-backed media storage. */
|
|
1833
|
+
readonly media: MediaResource;
|
|
1834
|
+
/** Google Meet appointment scheduling. */
|
|
1835
|
+
readonly meet: Meetings;
|
|
1836
|
+
/** Automation execution logs and provider webhook callbacks. */
|
|
1837
|
+
readonly notifications: Notifications;
|
|
1838
|
+
/** Outbound email marketing engine. */
|
|
1839
|
+
readonly email: EmailResource;
|
|
1840
|
+
/** Lead events and workflow automation triggers. */
|
|
1841
|
+
readonly events: EventsResource;
|
|
1842
|
+
/** Cryptographic webhook signature verification. */
|
|
1843
|
+
readonly webhooks: Webhooks;
|
|
1844
|
+
/** Tenant Cloud Storage mapping. */
|
|
1845
|
+
readonly storage: Storage;
|
|
1846
|
+
/** Email and SMS Marketing Campaigns. */
|
|
1847
|
+
readonly marketing: Marketing;
|
|
1848
|
+
/** Platform and tenant health diagnostics. */
|
|
1849
|
+
readonly health: Health;
|
|
1850
|
+
constructor(options: EcodrixOptions);
|
|
1851
|
+
private setupSocket;
|
|
1852
|
+
/**
|
|
1853
|
+
* Subscribe to a real-time event emitted by the ECODrIx platform.
|
|
1854
|
+
*
|
|
1855
|
+
* The SDK maintains a persistent Socket.io connection. Events are
|
|
1856
|
+
* scoped to your `clientCode` — you will only receive events for
|
|
1857
|
+
* your own tenant.
|
|
1858
|
+
*
|
|
1859
|
+
* **Standard events:**
|
|
1860
|
+
* - `whatsapp.message_received` — inbound WhatsApp message
|
|
1861
|
+
* - `whatsapp.message_sent` — outbound message delivered
|
|
1862
|
+
* - `crm.lead_created` — new CRM lead ingested
|
|
1863
|
+
* - `crm.lead_updated` — lead details or stage changed
|
|
1864
|
+
* - `meet.scheduled` — Google Meet appointment booked
|
|
1865
|
+
* - `storage.upload_confirmed` — file upload completed
|
|
1866
|
+
* - `automation.failed` — automation execution error
|
|
1867
|
+
*
|
|
1868
|
+
* @param event - The event name to subscribe to.
|
|
1869
|
+
* @param callback - The handler function invoked when the event fires.
|
|
1870
|
+
* @returns `this` for method chaining.
|
|
1871
|
+
*
|
|
1872
|
+
* @example
|
|
1873
|
+
* ```typescript
|
|
1874
|
+
* ecod
|
|
1875
|
+
* .on("whatsapp.message_received", (msg) => console.log(msg.body))
|
|
1876
|
+
* .on("automation.failed", (err) => alertTeam(err));
|
|
1877
|
+
* ```
|
|
1878
|
+
*/
|
|
1879
|
+
on(event: string, callback: (...args: any[]) => void): this;
|
|
1880
|
+
/**
|
|
1881
|
+
* Gracefully disconnect the real-time Socket.io connection.
|
|
1882
|
+
* Call this when shutting down your server or when the client is
|
|
1883
|
+
* no longer needed to free up resources.
|
|
1884
|
+
*
|
|
1885
|
+
* @example
|
|
1886
|
+
* ```typescript
|
|
1887
|
+
* process.on("SIGTERM", () => ecod.disconnect());
|
|
1888
|
+
* ```
|
|
1889
|
+
*/
|
|
1890
|
+
disconnect(): void;
|
|
1891
|
+
/**
|
|
1892
|
+
* Raw Execution Escape-Hatch.
|
|
1893
|
+
* Send an authenticated HTTP request directly to the ECODrIx backend from ANY external project.
|
|
1894
|
+
*
|
|
1895
|
+
* This is extremely powerful giving you full unrestricted access to make calls
|
|
1896
|
+
* against new, experimental, or completely custom backend APIs while still benefitting
|
|
1897
|
+
* from the SDK's built-in authentication and automatic `axios-retry` logic.
|
|
1898
|
+
*
|
|
1899
|
+
* @example
|
|
1900
|
+
* ```typescript
|
|
1901
|
+
* const { data } = await ecod.request("POST", "/api/saas/experimental-feature", { flag: true });
|
|
1902
|
+
* console.log(data);
|
|
1903
|
+
* ```
|
|
1904
|
+
*/
|
|
1905
|
+
request<T = any>(method: Method, path: string, data?: any, params?: any): Promise<T>;
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
export {
|
|
1909
|
+
APIError,
|
|
1910
|
+
Activities,
|
|
1911
|
+
Analytics,
|
|
1912
|
+
type AnalyticsParams,
|
|
1913
|
+
type AnalyticsRange,
|
|
1914
|
+
type AssignEventPayload,
|
|
1915
|
+
AuthenticationError,
|
|
1916
|
+
AutomationDashboard,
|
|
1917
|
+
type AutomationRulePayload,
|
|
1918
|
+
Automations,
|
|
1919
|
+
Broadcasts,
|
|
1920
|
+
CRM,
|
|
1921
|
+
type CampaignResult,
|
|
1922
|
+
Campaigns,
|
|
1923
|
+
type ClientHealth,
|
|
1924
|
+
Conversations,
|
|
1925
|
+
type CreateBroadcastParams,
|
|
1926
|
+
type CreateLeadParams,
|
|
1927
|
+
type CreateMeetingParams,
|
|
1928
|
+
type CreatePipelineParams,
|
|
1929
|
+
Ecodrix,
|
|
1930
|
+
EcodrixError,
|
|
1931
|
+
type EcodrixOptions,
|
|
1932
|
+
EmailResource,
|
|
1933
|
+
Emails,
|
|
1934
|
+
type EventDefinition,
|
|
1935
|
+
EventsResource,
|
|
1936
|
+
Files,
|
|
1937
|
+
Folders,
|
|
1938
|
+
Health,
|
|
1939
|
+
type JobStatus,
|
|
1940
|
+
type LeadSource,
|
|
1941
|
+
type LeadStatus,
|
|
1942
|
+
Leads,
|
|
1943
|
+
type ListLeadsParams,
|
|
1944
|
+
type ListParams,
|
|
1945
|
+
type LogActivityParams,
|
|
1946
|
+
type LogCallParams,
|
|
1947
|
+
type LogFilter,
|
|
1948
|
+
Marketing,
|
|
1949
|
+
MediaResource,
|
|
1950
|
+
Meetings,
|
|
1951
|
+
Messages,
|
|
1952
|
+
Notes,
|
|
1953
|
+
Notifications,
|
|
1954
|
+
Payments,
|
|
1955
|
+
type PipelineStageParams,
|
|
1956
|
+
Pipelines,
|
|
1957
|
+
RateLimitError,
|
|
1958
|
+
Scoring,
|
|
1959
|
+
type ScoringConfig,
|
|
1960
|
+
type SendCampaignParams,
|
|
1961
|
+
type SendCampaignPayload,
|
|
1962
|
+
type SendMessageParams,
|
|
1963
|
+
type SendTemplateParams,
|
|
1964
|
+
type SendTemplatePayload,
|
|
1965
|
+
Sequences,
|
|
1966
|
+
Storage,
|
|
1967
|
+
type SystemHealth,
|
|
1968
|
+
type TemplateMapping,
|
|
1969
|
+
Templates,
|
|
1970
|
+
type TriggerPayload,
|
|
1971
|
+
type TriggerResponse,
|
|
1972
|
+
type UpdateMeetingParams,
|
|
1973
|
+
type UploadOptions,
|
|
1974
|
+
type UpsertLeadParams,
|
|
1975
|
+
WebhookSignatureError,
|
|
1976
|
+
Webhooks,
|
|
1977
|
+
WhatsApp,
|
|
1978
|
+
Ecodrix as default,
|
|
1979
|
+
};
|