@ecodrix/erix-api 1.2.7 → 1.2.9
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 +1 -1
- package/package.json +16 -19
- package/schema/openapi.yaml +0 -199
- package/src/cli.ts +0 -305
- package/src/core.ts +0 -359
- package/src/error.ts +0 -72
- package/src/index.ts +0 -34
- package/src/resource.ts +0 -93
- package/src/resources/crm/activities.ts +0 -122
- package/src/resources/crm/analytics.ts +0 -148
- package/src/resources/crm/automationDashboard.ts +0 -42
- package/src/resources/crm/automations.ts +0 -170
- package/src/resources/crm/index.ts +0 -34
- package/src/resources/crm/leads.ts +0 -458
- package/src/resources/crm/payments.ts +0 -27
- package/src/resources/crm/pipelines.ts +0 -197
- package/src/resources/crm/scoring.ts +0 -46
- package/src/resources/crm/sequences.ts +0 -51
- package/src/resources/email.ts +0 -142
- package/src/resources/events.ts +0 -189
- package/src/resources/health.ts +0 -84
- package/src/resources/logs.ts +0 -97
- package/src/resources/marketing.ts +0 -179
- package/src/resources/media.ts +0 -184
- package/src/resources/meet.ts +0 -163
- package/src/resources/notifications.ts +0 -178
- package/src/resources/queue.ts +0 -64
- package/src/resources/storage.ts +0 -101
- package/src/resources/webhooks.ts +0 -80
- package/src/resources/whatsapp/broadcasts.ts +0 -94
- package/src/resources/whatsapp/conversations.ts +0 -128
- package/src/resources/whatsapp/index.ts +0 -67
- package/src/resources/whatsapp/messages.ts +0 -239
- package/src/resources/whatsapp/templates.ts +0 -218
- package/src/types/metadata.ts +0 -71
package/src/error.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed error hierarchy for the @ecodrix/erix-api SDK.
|
|
3
|
-
*
|
|
4
|
-
* All errors thrown by the SDK extend `EcodrixError`, so a single
|
|
5
|
-
* `catch` block can handle them all, while still allowing granular
|
|
6
|
-
* differentiation between auth failures, rate limits, and generic API errors.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { APIError, AuthenticationError, RateLimitError } from "@ecodrix/erix-api";
|
|
11
|
-
*
|
|
12
|
-
* try {
|
|
13
|
-
* await ecod.crm.leads.retrieve("invalid_id");
|
|
14
|
-
* } catch (err) {
|
|
15
|
-
* if (err instanceof AuthenticationError) {
|
|
16
|
-
* console.error("Invalid API key or client code.");
|
|
17
|
-
* } else if (err instanceof RateLimitError) {
|
|
18
|
-
* console.warn("Slow down — rate limit hit.");
|
|
19
|
-
* } else if (err instanceof APIError) {
|
|
20
|
-
* console.error(`API error ${err.status}: ${err.message}`);
|
|
21
|
-
* }
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/** Base class for all ECODrIx SDK errors. */
|
|
27
|
-
export class EcodrixError extends Error {
|
|
28
|
-
constructor(message: string) {
|
|
29
|
-
super(message);
|
|
30
|
-
this.name = "EcodrixError";
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Represents an error returned by the ECODrIx API.
|
|
36
|
-
* Carries the HTTP `status` code and an optional `code` string.
|
|
37
|
-
*/
|
|
38
|
-
export class APIError extends EcodrixError {
|
|
39
|
-
/** HTTP status code returned by the API (e.g. 400, 404, 500). */
|
|
40
|
-
public status?: number;
|
|
41
|
-
/** Machine-readable error code (e.g. `"NOT_FOUND"`, `"VALIDATION_ERROR"`). */
|
|
42
|
-
public code?: string;
|
|
43
|
-
|
|
44
|
-
constructor(message: string, status?: number, code?: string) {
|
|
45
|
-
super(message);
|
|
46
|
-
this.name = "APIError";
|
|
47
|
-
this.status = status;
|
|
48
|
-
this.code = code;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Thrown when the API key or client code is missing, invalid, or expired.
|
|
54
|
-
* HTTP 401.
|
|
55
|
-
*/
|
|
56
|
-
export class AuthenticationError extends APIError {
|
|
57
|
-
constructor(message = "Invalid API Key or Client Code") {
|
|
58
|
-
super(message, 401, "AUTH_FAILED");
|
|
59
|
-
this.name = "AuthenticationError";
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Thrown when the rate limit for the API key has been exceeded.
|
|
65
|
-
* HTTP 429. Implement exponential backoff before retrying.
|
|
66
|
-
*/
|
|
67
|
-
export class RateLimitError extends APIError {
|
|
68
|
-
constructor(message = "Too many requests. Please slow down.") {
|
|
69
|
-
super(message, 429, "RATE_LIMIT_EXCEEDED");
|
|
70
|
-
this.name = "RateLimitError";
|
|
71
|
-
}
|
|
72
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export { Ecodrix, type EcodrixOptions } from "./core";
|
|
2
|
-
export * from "./types/metadata";
|
|
3
|
-
export * from "./error";
|
|
4
|
-
export * from "./resources/crm/activities";
|
|
5
|
-
export * from "./resources/crm/analytics";
|
|
6
|
-
export * from "./resources/crm/automationDashboard";
|
|
7
|
-
export * from "./resources/crm/automations";
|
|
8
|
-
export * from "./resources/crm/index";
|
|
9
|
-
export * from "./resources/crm/leads";
|
|
10
|
-
export * from "./resources/crm/payments";
|
|
11
|
-
export * from "./resources/crm/pipelines";
|
|
12
|
-
export * from "./resources/crm/scoring";
|
|
13
|
-
export * from "./resources/crm/sequences";
|
|
14
|
-
export * from "./resources/email";
|
|
15
|
-
export * from "./resources/events";
|
|
16
|
-
export * from "./resources/health";
|
|
17
|
-
export * from "./resources/logs";
|
|
18
|
-
export * from "./resources/marketing";
|
|
19
|
-
export * from "./resources/media";
|
|
20
|
-
export * from "./resources/meet";
|
|
21
|
-
export * from "./resources/notifications";
|
|
22
|
-
export * from "./resources/queue";
|
|
23
|
-
export * from "./resources/storage";
|
|
24
|
-
export * from "./resources/webhooks";
|
|
25
|
-
export * from "./resources/whatsapp/broadcasts";
|
|
26
|
-
export * from "./resources/whatsapp/conversations";
|
|
27
|
-
// Resource Type Exports
|
|
28
|
-
export * from "./resources/whatsapp/index";
|
|
29
|
-
export * from "./resources/whatsapp/messages";
|
|
30
|
-
export * from "./resources/whatsapp/templates";
|
|
31
|
-
|
|
32
|
-
// Export the main client also as default for better ergonomics
|
|
33
|
-
import { Ecodrix } from "./core";
|
|
34
|
-
export default Ecodrix;
|
package/src/resource.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
-
import { APIError } from "./error";
|
|
3
|
-
|
|
4
|
-
export interface RequestOptions extends AxiosRequestConfig {
|
|
5
|
-
/**
|
|
6
|
-
* If true, will not add the x-client-code header.
|
|
7
|
-
*/
|
|
8
|
-
ignoreClientCode?: boolean;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Safe execution idempotency key.
|
|
12
|
-
* If provided, the backend will safely ignore duplicate requests retried with the same key.
|
|
13
|
-
*/
|
|
14
|
-
idempotencyKey?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export abstract class APIResource {
|
|
18
|
-
public constructor(protected readonly client: AxiosInstance) {}
|
|
19
|
-
|
|
20
|
-
protected async post<T>(url: string, data?: any, options?: RequestOptions): Promise<T> {
|
|
21
|
-
try {
|
|
22
|
-
const config = this.buildConfig(options);
|
|
23
|
-
const response = await this.client.post(url, data, config);
|
|
24
|
-
return response.data;
|
|
25
|
-
} catch (error: any) {
|
|
26
|
-
this.handleError(error);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
protected async get<T>(url: string, options?: RequestOptions): Promise<T> {
|
|
31
|
-
try {
|
|
32
|
-
const config = this.buildConfig(options);
|
|
33
|
-
const response = await this.client.get(url, config);
|
|
34
|
-
return response.data;
|
|
35
|
-
} catch (error: any) {
|
|
36
|
-
this.handleError(error);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
protected async patch<T>(url: string, data?: any, options?: RequestOptions): Promise<T> {
|
|
41
|
-
try {
|
|
42
|
-
const config = this.buildConfig(options);
|
|
43
|
-
const response = await this.client.patch(url, data, config);
|
|
44
|
-
return response.data;
|
|
45
|
-
} catch (error: any) {
|
|
46
|
-
this.handleError(error);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
protected async put<T>(url: string, data?: any, options?: RequestOptions): Promise<T> {
|
|
51
|
-
try {
|
|
52
|
-
const config = this.buildConfig(options);
|
|
53
|
-
const response = await this.client.put(url, data, config);
|
|
54
|
-
return response.data;
|
|
55
|
-
} catch (error: any) {
|
|
56
|
-
this.handleError(error);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
protected async deleteRequest<T>(url: string, options?: RequestOptions): Promise<T> {
|
|
61
|
-
try {
|
|
62
|
-
const config = this.buildConfig(options);
|
|
63
|
-
const response = await this.client.delete(url, config);
|
|
64
|
-
return response.data;
|
|
65
|
-
} catch (error: any) {
|
|
66
|
-
this.handleError(error);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private buildConfig(options?: RequestOptions): AxiosRequestConfig | undefined {
|
|
71
|
-
if (!options) return undefined;
|
|
72
|
-
|
|
73
|
-
const config: AxiosRequestConfig = { ...options };
|
|
74
|
-
if (options.idempotencyKey) {
|
|
75
|
-
config.headers = {
|
|
76
|
-
...config.headers,
|
|
77
|
-
"Idempotency-Key": options.idempotencyKey,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return config;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private handleError(error: any): never {
|
|
84
|
-
if (error.response) {
|
|
85
|
-
throw new APIError(
|
|
86
|
-
error.response.data?.message || error.response.data?.error || "API Request Failed",
|
|
87
|
-
error.response.status,
|
|
88
|
-
error.response.data?.code,
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
throw new APIError(error.message || "Network Error");
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { APIResource } from "../../resource";
|
|
2
|
-
|
|
3
|
-
export interface LogActivityParams {
|
|
4
|
-
leadId: string;
|
|
5
|
-
type: "note" | "call" | "email" | "meeting" | "whatsapp" | "system";
|
|
6
|
-
title: string;
|
|
7
|
-
body?: string;
|
|
8
|
-
metadata?: Record<string, any>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface LogCallParams {
|
|
12
|
-
durationMinutes: number;
|
|
13
|
-
summary: string;
|
|
14
|
-
outcome: "answered" | "no_answer" | "busy" | "voicemail" | "wrong_number";
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class Notes extends APIResource {
|
|
18
|
-
/**
|
|
19
|
-
* List all notes for a specific lead.
|
|
20
|
-
*
|
|
21
|
-
* @param leadId - The unique ID of the lead.
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* const notes = await erixClient.crm.activities.notes.list("lead_123");
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
async list<T = any>(leadId: string) {
|
|
28
|
-
return this.get<T>(`/api/crm/leads/${leadId}/notes`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Add a new descriptive note to a lead's profile.
|
|
33
|
-
*
|
|
34
|
-
* @param leadId - The unique ID of the lead.
|
|
35
|
-
* @param params - The note content.
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* await erixClient.crm.activities.notes.create("lead_123", {
|
|
39
|
-
* content: "Customer is interested in the enterprise plan."
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
async create<T = any>(leadId: string, params: { content: string }) {
|
|
44
|
-
return this.post<T>(`/api/crm/leads/${leadId}/notes`, params);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Update an existing note.
|
|
49
|
-
*/
|
|
50
|
-
async update<T = any>(noteId: string, content: string) {
|
|
51
|
-
return this.patch<T>(`/api/crm/notes/${noteId}`, { content });
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Pin or unpin a note to the top of the feed.
|
|
56
|
-
*/
|
|
57
|
-
async pin<T = any>(noteId: string, isPinned = true) {
|
|
58
|
-
return this.patch<T>(`/api/crm/notes/${noteId}/pin`, { isPinned });
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Delete a note.
|
|
63
|
-
*/
|
|
64
|
-
async delete(noteId: string) {
|
|
65
|
-
return this.deleteRequest(`/api/crm/notes/${noteId}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export class Activities extends APIResource {
|
|
70
|
-
public notes: Notes;
|
|
71
|
-
|
|
72
|
-
constructor(client: any) {
|
|
73
|
-
super(client);
|
|
74
|
-
this.notes = new Notes(client);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Retrieve the complete chronological timeline of all activities for a lead.
|
|
79
|
-
*
|
|
80
|
-
* @param leadId - The unique ID of the lead.
|
|
81
|
-
* @param params - Optional pagination parameters.
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* const timeline = await erixClient.crm.activities.timeline("lead_123", { limit: 10 });
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
async timeline<T = any>(leadId: string, params?: { page?: number; limit?: number }) {
|
|
88
|
-
return this.get<T>(`/api/crm/leads/${leadId}/timeline`, { params } as any);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* List specific activities (filtered by type).
|
|
93
|
-
*/
|
|
94
|
-
async list<T = any>(leadId: string, params?: { type?: string; page?: number; limit?: number }) {
|
|
95
|
-
return this.get<T>(`/api/crm/leads/${leadId}/activities`, { params: { ...params } } as any);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Generic method to log a business activity/event (e.g., system events, manual tasks).
|
|
100
|
-
*
|
|
101
|
-
* @param params - Activity details (leadId, type, title, body).
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* await erixClient.crm.activities.log({
|
|
105
|
-
* leadId: "lead_123",
|
|
106
|
-
* type: "system",
|
|
107
|
-
* title: "Meeting Scheduled",
|
|
108
|
-
* body: "Initial consultation booked for Friday."
|
|
109
|
-
* });
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
async log<T = any>(params: LogActivityParams) {
|
|
113
|
-
return this.post<T>(`/api/crm/leads/${params.leadId}/activities`, params);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Specific method to log communication outcomes.
|
|
118
|
-
*/
|
|
119
|
-
async logCall<T = any>(leadId: string, params: LogCallParams) {
|
|
120
|
-
return this.post<T>(`/api/crm/leads/${leadId}/calls`, params);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { APIResource } from "../../resource";
|
|
2
|
-
|
|
3
|
-
export type AnalyticsRange = "24h" | "7d" | "30d" | "60d" | "90d" | "365d";
|
|
4
|
-
|
|
5
|
-
export interface AnalyticsParams {
|
|
6
|
-
range?: AnalyticsRange;
|
|
7
|
-
from?: string;
|
|
8
|
-
to?: string;
|
|
9
|
-
pipelineId?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class Analytics extends APIResource {
|
|
13
|
-
/**
|
|
14
|
-
* Retrieve high-level CRM performance KPIs.
|
|
15
|
-
* Includes total leads, pipeline value, won revenue, and conversion rates.
|
|
16
|
-
*
|
|
17
|
-
* @param params - Optional filters including time range (24h, 7d, 30d, etc.) and custom date bounds.
|
|
18
|
-
* @returns {Promise<any>} KPI summary object containing core business metrics.
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* const stats = await erixClient.crm.analytics.overview({ range: "30d" });
|
|
22
|
-
* console.log(stats.avgScore);
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
async overview<T = any>(params?: AnalyticsParams) {
|
|
26
|
-
return this.get<T>("/api/crm/analytics/overview", { params } as any);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Get stage-by-stage lead counts and conversion percentages for a pipeline.
|
|
31
|
-
* Useful for identifying funnel bottlenecks and drop-off points.
|
|
32
|
-
*
|
|
33
|
-
* @param pipelineId - The unique ID of the pipeline to analyze.
|
|
34
|
-
* @returns {Promise<any>} Array of funnel stages with count and conversion data.
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const funnel = await erixClient.crm.analytics.funnel("pipe_123");
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
async funnel<T = any>(pipelineId: string) {
|
|
41
|
-
return this.get<T>("/api/crm/analytics/funnel", {
|
|
42
|
-
params: { pipelineId },
|
|
43
|
-
} as any);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Revenue forecast: Calculates expected revenue based on deal value × stage probability.
|
|
48
|
-
* Helps in sales planning and goal setting.
|
|
49
|
-
*
|
|
50
|
-
* @param pipelineId - Optional pipeline ID to filter the forecast.
|
|
51
|
-
* @returns {Promise<any>} Forecast data including weighted expected revenue.
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const prognosis = await erixClient.crm.analytics.forecast("pipe_123");
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
async forecast<T = any>(pipelineId?: string) {
|
|
58
|
-
return this.get<T>("/api/crm/analytics/forecast", {
|
|
59
|
-
params: { pipelineId },
|
|
60
|
-
} as any);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Lead source breakdown: count, conversion rate, and total value per source.
|
|
65
|
-
*
|
|
66
|
-
* @param params - Time range filters.
|
|
67
|
-
* @returns {Promise<any>} Breakdown of how different marketing channels are performing.
|
|
68
|
-
*/
|
|
69
|
-
async sources<T = any>(params?: AnalyticsParams) {
|
|
70
|
-
return this.get<T>("/api/crm/analytics/sources", { params } as any);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Team leaderboard: Evaluates agent performance across won deals, revenue, and activity.
|
|
75
|
-
*
|
|
76
|
-
* @param params - Time range filters.
|
|
77
|
-
* @returns {Promise<any>} Ranked list of team members by performance.
|
|
78
|
-
*/
|
|
79
|
-
async team<T = any>(params?: AnalyticsParams) {
|
|
80
|
-
return this.get<T>("/api/crm/analytics/team", { params } as any);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Activity heatmap: Daily activity counts by type.
|
|
85
|
-
* Ideal for visualizing engagement patterns on a calendar view.
|
|
86
|
-
*
|
|
87
|
-
* @param params - Time range filters.
|
|
88
|
-
* @returns {Promise<any>} Time-series data of team activities.
|
|
89
|
-
*/
|
|
90
|
-
async heatmap<T = any>(params?: AnalyticsParams) {
|
|
91
|
-
return this.get<T>("/api/crm/analytics/heatmap", { params } as any);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Score distribution: Groups leads into buckets based on their calculated score (0-100).
|
|
96
|
-
*
|
|
97
|
-
* @returns {Promise<any>} Volume of leads in different readiness tiers.
|
|
98
|
-
*/
|
|
99
|
-
async scores<T = any>() {
|
|
100
|
-
return this.get<T>("/api/crm/analytics/scores");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Avg time in stage: Measures the velocity of leads through the sales pipeline.
|
|
105
|
-
*
|
|
106
|
-
* @param pipelineId - Target pipeline ID.
|
|
107
|
-
* @returns {Promise<any>} Velocity metrics per stage.
|
|
108
|
-
*/
|
|
109
|
-
async stageTime<T = any>(pipelineId: string) {
|
|
110
|
-
return this.get<T>("/api/crm/analytics/stage-time", {
|
|
111
|
-
params: { pipelineId },
|
|
112
|
-
} as any);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Tiered Growth Report matching business sophistication (Pulse, Growth, Weapon).
|
|
117
|
-
* Provides deep tactical and strategic insights.
|
|
118
|
-
*
|
|
119
|
-
* @param params - Filtering and range parameters.
|
|
120
|
-
*/
|
|
121
|
-
async tiered<T = any>(params?: AnalyticsParams) {
|
|
122
|
-
return this.get<T>("/api/crm/analytics/tiered", { params } as any);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Consolidated analytics including CRM overview and WhatsApp messaging metrics.
|
|
127
|
-
*
|
|
128
|
-
* @param params - Time range filters.
|
|
129
|
-
*/
|
|
130
|
-
async summary<T = any>(params?: AnalyticsParams) {
|
|
131
|
-
return this.get<T>("/api/crm/analytics/summary", { params } as any);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Retrieve WhatsApp messaging volume and delivery performance analytics.
|
|
136
|
-
* Includes total sent, delivered, read, and daily volume trends.
|
|
137
|
-
*
|
|
138
|
-
* @param params - Optional filters (time range).
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* const waStats = await erixClient.crm.analytics.whatsapp({ range: "7d" });
|
|
142
|
-
* console.log(waStats.totalSent);
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
async whatsapp<T = any>(params?: AnalyticsParams) {
|
|
146
|
-
return this.get<T>("/api/crm/analytics/whatsapp", { params } as any);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { APIResource } from "../../resource";
|
|
2
|
-
|
|
3
|
-
export class AutomationDashboard extends APIResource {
|
|
4
|
-
/**
|
|
5
|
-
* Retrieve summary statistics for automation health (total, success, failed).
|
|
6
|
-
*
|
|
7
|
-
* @returns Stats object.
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const stats = await erixClient.crm.automationDashboard.stats();
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
async stats<T = any>() {
|
|
14
|
-
return this.get<T>("/api/crm/automation/stats");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* List recent EventLog entries representing automation executions.
|
|
19
|
-
*
|
|
20
|
-
* @param params - Optional filters (limit, status).
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const logs = await erixClient.crm.automationDashboard.logs({ status: "failed" });
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
async logs<T = any>(params?: { limit?: number; status?: string }) {
|
|
27
|
-
return this.get<T>("/api/crm/automation/logs", { params } as any);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Re-emit a failed event log to re-trigger its associated automation rules.
|
|
32
|
-
*
|
|
33
|
-
* @param logId - The unique ID of the failed event log.
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* await erixClient.crm.automationDashboard.retryFailedEvent("log_123");
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
async retryFailedEvent<T = any>(logId: string) {
|
|
40
|
-
return this.post<T>(`/api/crm/automation/logs/${logId}/retry`, {});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { APIResource } from "../../resource";
|
|
2
|
-
|
|
3
|
-
export interface AutomationRulePayload {
|
|
4
|
-
name: string;
|
|
5
|
-
trigger: string;
|
|
6
|
-
isActive?: boolean;
|
|
7
|
-
nodes: any[];
|
|
8
|
-
edges: any[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class Automations extends APIResource {
|
|
12
|
-
/**
|
|
13
|
-
* List all automation rules (workflows) configured for the tenant.
|
|
14
|
-
*
|
|
15
|
-
* @returns Array of automation rule objects.
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const rules = await erixClient.crm.automations.list();
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
async list<T = any>() {
|
|
22
|
-
return this.get<T>("/api/crm/automations");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Create a new automation rule with triggers and workflow nodes.
|
|
27
|
-
*
|
|
28
|
-
* @param payload - The automation rule definition (trigger, nodes, edges).
|
|
29
|
-
* @returns The created automation rule.
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* await erixClient.crm.automations.create({
|
|
33
|
-
* name: "Welcome Email Workflow",
|
|
34
|
-
* trigger: "contact_created",
|
|
35
|
-
* nodes: [...],
|
|
36
|
-
* edges: [...]
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
async create<T = any>(payload: AutomationRulePayload) {
|
|
41
|
-
return this.post<T>("/api/crm/automations", payload);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Update an existing automation rule.
|
|
46
|
-
*/
|
|
47
|
-
async update<T = any>(ruleId: string, payload: Partial<AutomationRulePayload>) {
|
|
48
|
-
return this.patch<T>(`/api/crm/automations/${ruleId}`, payload as any);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Enable or disable an automation rule.
|
|
53
|
-
*/
|
|
54
|
-
async toggle<T = any>(ruleId: string) {
|
|
55
|
-
return this.patch<T>(`/api/crm/automations/${ruleId}/toggle`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Delete an automation rule.
|
|
60
|
-
*/
|
|
61
|
-
async delete<T = any>(ruleId: string) {
|
|
62
|
-
return this.deleteRequest(`/api/crm/automations/${ruleId}`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Bulk delete rules.
|
|
67
|
-
*/
|
|
68
|
-
async bulkDelete<T = any>(ruleIds: string[]) {
|
|
69
|
-
return this.post<T>("/api/crm/automations/bulk-delete", { ids: ruleIds });
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Dry-run test an automation rule against a specific lead to verify logic.
|
|
74
|
-
*
|
|
75
|
-
* @param ruleId - The ID of the rule to test.
|
|
76
|
-
* @param leadId - The ID of the lead to run the test against.
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* await erixClient.crm.automations.test("rule_123", "lead_456");
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
async test<T = any>(ruleId: string, leadId: string) {
|
|
83
|
-
return this.post<T>(`/api/crm/automations/${ruleId}/test`, { leadId });
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Get available event triggers for automations.
|
|
88
|
-
*/
|
|
89
|
-
async getAvailableEvents<T = any>() {
|
|
90
|
-
return this.post<T>("/api/crm/automations/events", {});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* List enrollments for a rule.
|
|
95
|
-
*/
|
|
96
|
-
async enrollments<T = any>(
|
|
97
|
-
ruleId: string,
|
|
98
|
-
params?: {
|
|
99
|
-
status?: string;
|
|
100
|
-
page?: number;
|
|
101
|
-
limit?: number;
|
|
102
|
-
startDate?: string;
|
|
103
|
-
endDate?: string;
|
|
104
|
-
},
|
|
105
|
-
) {
|
|
106
|
-
return this.get<T>(`/api/crm/automations/${ruleId}/enrollments`, { params });
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Get an enrollment detail.
|
|
111
|
-
*/
|
|
112
|
-
async getEnrollment<T = any>(enrollmentId: string) {
|
|
113
|
-
return this.get<T>(`/api/crm/automations/enrollments/${enrollmentId}`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Pause an enrollment.
|
|
118
|
-
*/
|
|
119
|
-
async pauseEnrollment<T = any>(ruleId: string, enrollmentId: string) {
|
|
120
|
-
return this.post<T>(`/api/crm/automations/${ruleId}/enrollments/${enrollmentId}/pause`, {});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Resume an enrollment.
|
|
125
|
-
*/
|
|
126
|
-
async resumeEnrollment<T = any>(ruleId: string, enrollmentId: string) {
|
|
127
|
-
return this.post<T>(`/api/crm/automations/${ruleId}/enrollments/${enrollmentId}/resume`, {});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* List workflow runs.
|
|
132
|
-
*/
|
|
133
|
-
async runs<T = any>(ruleId: string) {
|
|
134
|
-
return this.get<T>(`/api/crm/automations/${ruleId}/runs`);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Get run details.
|
|
139
|
-
*/
|
|
140
|
-
async getRun<T = any>(runId: string) {
|
|
141
|
-
return this.get<T>(`/api/crm/automations/runs/${runId}`);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Resume a paused run.
|
|
146
|
-
*/
|
|
147
|
-
async resumeRun<T = any>(runId: string) {
|
|
148
|
-
return this.post<T>(`/api/crm/automations/runs/${runId}/resume`, {});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Abort a running workflow.
|
|
153
|
-
*/
|
|
154
|
-
async abortRun<T = any>(runId: string) {
|
|
155
|
-
return this.post<T>(`/api/crm/automations/runs/${runId}/abort`, {});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Emit an external webhook event to unlock a `wait_event` node inside a
|
|
160
|
-
* paused workflow run. Required when integrating third-party tools that
|
|
161
|
-
* need to resume a suspended automation.
|
|
162
|
-
*
|
|
163
|
-
* @param ruleId - The automation rule that contains the wait_event node.
|
|
164
|
-
* @param eventName - The event name that should match the node's condition.
|
|
165
|
-
* @param payload - Arbitrary data forwarded to the node context.
|
|
166
|
-
*/
|
|
167
|
-
async webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any) {
|
|
168
|
-
return this.post<T>("/api/crm/webhook-event", { ruleId, eventName, payload });
|
|
169
|
-
}
|
|
170
|
-
}
|