@ecodrix/erix-api 3.1.2 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -1
- package/dist/cli.js +3 -3
- package/dist/ts/cjs/index.cjs +1 -1
- package/dist/ts/cjs/visitor.cjs +1 -0
- package/dist/ts/esm/chunk-XPXDFZWU.js +1 -0
- package/dist/ts/esm/error-DuNpKP1d.d.ts +158 -0
- package/dist/ts/esm/index.d.ts +77 -70
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/visitor.d.ts +147 -0
- package/dist/ts/esm/visitor.js +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var y=Object.defineProperty,D=Object.defineProperties;var v=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var T=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var a=(e,t,s)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,V=(e,t)=>{for(var s in t||(t={}))w.call(t,s)&&a(e,s,t[s]);if(g)for(var s of g(t))b.call(t,s)&&a(e,s,t[s]);return e},C=(e,t)=>D(e,v(t));var L=(e,t)=>{var s={};for(var r in e)w.call(e,r)&&t.indexOf(r)<0&&(s[r]=e[r]);if(e!=null&&g)for(var r of g(e))t.indexOf(r)<0&&b.call(e,r)&&(s[r]=e[r]);return s};var E=(e,t,s)=>a(e,typeof t!="symbol"?t+"":t,s);var F=function(e,t){this[0]=e,this[1]=t},N=(e,t,s)=>{var r=(l,o,A,p)=>{try{var d=s[l](o),I=(o=d.value)instanceof F,f=d.done;Promise.resolve(I?o[0]:o).then(n=>I?r(l==="return"?l:"next",o[1]?{done:n.done,value:n.value}:n,A,p):A({value:n,done:f})).catch(n=>r("throw",n,A,p))}catch(n){p(n)}},i=(l,o,A,p)=>u[l]=d=>(o=new Promise((I,f,n)=>(n=()=>r(l,d,I,f),c?c.then(n):n())),p=()=>c===A&&(c=0),c=A=o.then(p,p),o),c,u={};return s=s.apply(e,t),u[T("asyncIterator")]=()=>u,i("next"),i("throw"),i("return"),u};var R="https://api.ecodrix.com";function U(e="v1",t=R){return`${t.replace(/\/+$/,"")}/${e}/api`}var h=class extends Error{constructor(t){super(t),this.name="EcodrixError"}},m=class extends h{constructor(s,r,i){super(s);E(this,"status");E(this,"code");E(this,"issues");E(this,"field");this.name="APIError",this.status=r,this.code=i}},x=class extends m{constructor(t="Invalid API Key or Client Code",s="AUTH_FAILED",r=401){super(t,r,s),this.name="AuthenticationError"}},P=class extends x{constructor(t="You don't have permission to do this.",s="FORBIDDEN"){super(t,s,403),this.name="PermissionError"}},_=class extends m{constructor(t="Too many requests. Please slow down."){super(t,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};function B(e){var c;if(!(e!=null&&e.response))return new m((e==null?void 0:e.message)||"Network Error");let{status:t,data:s}=e.response,r=(s==null?void 0:s.message)||(s==null?void 0:s.error)||"API Request Failed",i=(c=s==null?void 0:s.code)!=null?c:typeof(s==null?void 0:s.error)=="string"&&/^[A-Z][A-Z0-9_]*$/.test(s.error)?s.error:void 0;switch(t){case 401:return new x(r,i);case 403:return new P(r,i);case 429:return new _(r);default:{let u=new m(r,t,i);return Array.isArray(s==null?void 0:s.issues)&&(u.issues=s.issues),typeof(s==null?void 0:s.field)=="string"&&(u.field=s.field),u}}}export{V as a,C as b,L as c,E as d,F as e,N as f,R as g,U as h,h as i,m as j,x as k,P as l,_ as m,B as n};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Website chat (webchat) shapes shared by the visitor client
|
|
3
|
+
* (`@ecodrix/erix-api/visitor`) and the workspace client. Types only: this
|
|
4
|
+
* file must never import runtime code, so the visitor bundle stays small.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A message as a website visitor sees it (`messages()`, the live
|
|
8
|
+
* `webchat.message` event). Nothing else from the stored row is exposed.
|
|
9
|
+
*/
|
|
10
|
+
interface VisitorMessage {
|
|
11
|
+
id: string;
|
|
12
|
+
direction: "inbound" | "outbound";
|
|
13
|
+
text: string;
|
|
14
|
+
/** ISO timestamp. */
|
|
15
|
+
createdAt: string;
|
|
16
|
+
/** Who wrote it: the visitor, the AI assistant, a team member, or a system notice. */
|
|
17
|
+
from: "visitor" | "ai" | "team" | "system";
|
|
18
|
+
/** Team replies only, and only when the workspace shows staff names. */
|
|
19
|
+
senderFirstName?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The live `webchat.typing` event. `waiting: true` (with `on: false`) means
|
|
23
|
+
* the AI left the reply to the team: show "The team will reply here".
|
|
24
|
+
*/
|
|
25
|
+
interface VisitorTyping {
|
|
26
|
+
on: boolean;
|
|
27
|
+
waiting?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** The website chat widget's settings (`service_config.webchat`). */
|
|
30
|
+
interface WebchatSettings {
|
|
31
|
+
/**
|
|
32
|
+
* Sites the widget may run on. Read-only here: add one with `domain`,
|
|
33
|
+
* remove one with `connections.removeWebchatDomain`.
|
|
34
|
+
*/
|
|
35
|
+
allowedDomains: string[];
|
|
36
|
+
/** Up to 60 characters. */
|
|
37
|
+
name?: string;
|
|
38
|
+
/** Up to 200 characters. */
|
|
39
|
+
greeting?: string;
|
|
40
|
+
/** `#rrggbb`. */
|
|
41
|
+
color?: string;
|
|
42
|
+
/** Default `right`. */
|
|
43
|
+
position?: "left" | "right";
|
|
44
|
+
/** `https://` only. */
|
|
45
|
+
logoUrl?: string;
|
|
46
|
+
/** When the widget asks for name and phone/email. Default `when_needed`. */
|
|
47
|
+
detailsMode?: "before" | "when_needed" | "off";
|
|
48
|
+
/** Up to 80 characters, e.g. "We reply 10 am to 7 pm". */
|
|
49
|
+
hoursText?: string;
|
|
50
|
+
/** Show a team member's first name on their replies. Default true. */
|
|
51
|
+
showStaffNames?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The website chat as its owner edits it (`connections.webchatSettings()`):
|
|
55
|
+
* the sites it may run on in plain text, the plan's cap on them, and the
|
|
56
|
+
* saved settings (a setting left at its default is absent).
|
|
57
|
+
*/
|
|
58
|
+
interface WebchatOwnerSettings {
|
|
59
|
+
allowedDomains: string[];
|
|
60
|
+
/** How many sites the plan allows. */
|
|
61
|
+
maxDomains: number;
|
|
62
|
+
settings: Omit<WebchatSettings, "allowedDomains">;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A settings save: send only what changes; `null` clears a setting back to
|
|
66
|
+
* its default. `domain` adds a site to the allowed domains (plan-capped).
|
|
67
|
+
*/
|
|
68
|
+
type WebchatSettingsPatch = {
|
|
69
|
+
[K in Exclude<keyof WebchatSettings, "allowedDomains">]?: WebchatSettings[K] | null;
|
|
70
|
+
} & {
|
|
71
|
+
/** A site to add to the allowed domains, e.g. `example.com`. */
|
|
72
|
+
domain?: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Typed error hierarchy for the @ecodrix/erix-api SDK.
|
|
77
|
+
*
|
|
78
|
+
* All errors thrown by the SDK extend `EcodrixError`, so a single
|
|
79
|
+
* `catch` block can handle them all, while still allowing granular
|
|
80
|
+
* differentiation between auth failures, rate limits, and generic API errors.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import { APIError, AuthenticationError, RateLimitError } from "@ecodrix/erix-api";
|
|
85
|
+
*
|
|
86
|
+
* try {
|
|
87
|
+
* await ecod.product.erix.leads.retrieve("invalid_id");
|
|
88
|
+
* } catch (err) {
|
|
89
|
+
* if (err instanceof AuthenticationError) {
|
|
90
|
+
* console.error("Invalid API key or client code.");
|
|
91
|
+
* } else if (err instanceof RateLimitError) {
|
|
92
|
+
* console.warn("Slow down — rate limit hit.");
|
|
93
|
+
* } else if (err instanceof APIError) {
|
|
94
|
+
* console.error(`API error ${err.status}: ${err.message}`);
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
/** Base class for all ECODrIx SDK errors. */
|
|
100
|
+
declare class EcodrixError extends Error {
|
|
101
|
+
constructor(message: string);
|
|
102
|
+
}
|
|
103
|
+
/** One value the server refused, from a `VALIDATION_ERROR`'s `issues`. */
|
|
104
|
+
interface APIErrorIssue {
|
|
105
|
+
/** Where in the request body, e.g. `["color"]`. */
|
|
106
|
+
path: (string | number)[];
|
|
107
|
+
message: string;
|
|
108
|
+
/** The check that failed, e.g. `"too_big"`. */
|
|
109
|
+
code?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Represents an error returned by the ECODrIx API.
|
|
113
|
+
* Carries the HTTP `status` code and an optional `code` string.
|
|
114
|
+
*/
|
|
115
|
+
declare class APIError extends EcodrixError {
|
|
116
|
+
/** HTTP status code returned by the API (e.g. 400, 404, 500). */
|
|
117
|
+
status?: number;
|
|
118
|
+
/** Machine-readable error code (e.g. `"NOT_FOUND"`, `"VALIDATION_ERROR"`). */
|
|
119
|
+
code?: string;
|
|
120
|
+
/** Each refused value, when the server lists them (`VALIDATION_ERROR`). */
|
|
121
|
+
issues?: APIErrorIssue[];
|
|
122
|
+
/** The one field the server names, when it sends `field`. */
|
|
123
|
+
field?: string;
|
|
124
|
+
constructor(message: string, status?: number, code?: string);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Thrown when the API key or client code is missing, invalid, or expired.
|
|
128
|
+
* HTTP 401. `code` is the server's (e.g. `INVALID_KEY`) when it sends one.
|
|
129
|
+
*/
|
|
130
|
+
declare class AuthenticationError extends APIError {
|
|
131
|
+
constructor(message?: string, code?: string, status?: number);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Thrown when the caller is signed in but not allowed: role, plan, or no
|
|
135
|
+
* longer a member (`code` `FORBIDDEN`, `NOT_A_MEMBER`, …). HTTP 403. Extends
|
|
136
|
+
* AuthenticationError so existing 401/403 handling keeps working; check
|
|
137
|
+
* `status` or `code` to tell a dead key from a missing permission.
|
|
138
|
+
*/
|
|
139
|
+
declare class PermissionError extends AuthenticationError {
|
|
140
|
+
constructor(message?: string, code?: string);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Thrown when the rate limit for the API key has been exceeded.
|
|
144
|
+
* HTTP 429. Implement exponential backoff before retrying.
|
|
145
|
+
*/
|
|
146
|
+
declare class RateLimitError extends APIError {
|
|
147
|
+
constructor(message?: string);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Turn an HTTP client error into the typed SDK error: 401 → AuthenticationError,
|
|
151
|
+
* 403 → PermissionError, 429 → RateLimitError, else APIError. Keeps the
|
|
152
|
+
* server's status and code (sent in `code`, or in `error` as UPPER_SNAKE),
|
|
153
|
+
* and an APIError keeps the body's `issues` and `field` so a form can show
|
|
154
|
+
* each refused value under its own field.
|
|
155
|
+
*/
|
|
156
|
+
declare function toAPIError(error: any): APIError;
|
|
157
|
+
|
|
158
|
+
export { APIError as A, EcodrixError as E, PermissionError as P, RateLimitError as R, type VisitorMessage as V, type WebchatSettingsPatch as W, type WebchatOwnerSettings as a, AuthenticationError as b, type APIErrorIssue as c, type VisitorTyping as d, type WebchatSettings as e, toAPIError as t };
|
package/dist/ts/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, Method } from 'axios';
|
|
2
|
+
import { W as WebchatSettingsPatch, a as WebchatOwnerSettings, A as APIError, b as AuthenticationError, R as RateLimitError } from './error-DuNpKP1d.js';
|
|
3
|
+
export { c as APIErrorIssue, E as EcodrixError, P as PermissionError, V as VisitorMessage, d as VisitorTyping, e as WebchatSettings, t as toAPIError } from './error-DuNpKP1d.js';
|
|
2
4
|
|
|
3
5
|
/** Supported API route versions. Add `"v2"` here the day the server ships it. */
|
|
4
6
|
type ApiVersion = "v1" | "v2" | "v3";
|
|
@@ -1667,6 +1669,36 @@ declare class Connect extends APIResource {
|
|
|
1667
1669
|
method: string;
|
|
1668
1670
|
config?: Record<string, unknown>;
|
|
1669
1671
|
}): Promise<T>;
|
|
1672
|
+
/**
|
|
1673
|
+
* Save the website chat widget's settings, add a site to its allowed
|
|
1674
|
+
* domains, or both (owners and admins). Send only what changes; `null`
|
|
1675
|
+
* resets a setting to its default. A bad value fails with `APIError` code
|
|
1676
|
+
* `VALIDATION_ERROR` (each field in `issues`); a site over the plan's cap
|
|
1677
|
+
* fails with status 402, code `WEBCHAT_DOMAIN_LIMIT`, and saves nothing.
|
|
1678
|
+
* Returns the webchat connection, like `configure`.
|
|
1679
|
+
*/
|
|
1680
|
+
configureWebchat<T = any>(settings: WebchatSettingsPatch): Promise<T>;
|
|
1681
|
+
/**
|
|
1682
|
+
* The website chat as its owner edits it (owners and admins): the saved
|
|
1683
|
+
* widget settings, the allowed sites in plain text (the connection view
|
|
1684
|
+
* masks them) and the plan's cap on them.
|
|
1685
|
+
*/
|
|
1686
|
+
webchatSettings(): Promise<{
|
|
1687
|
+
success: boolean;
|
|
1688
|
+
data: WebchatOwnerSettings;
|
|
1689
|
+
}>;
|
|
1690
|
+
/**
|
|
1691
|
+
* Remove a site from the website chat's allowed domains (owners and
|
|
1692
|
+
* admins), written any way: `https://www.example.com/` removes
|
|
1693
|
+
* `example.com`. Removing the last one turns the chat off on every
|
|
1694
|
+
* website. Returns the sites left.
|
|
1695
|
+
*/
|
|
1696
|
+
removeWebchatDomain(domain: string): Promise<{
|
|
1697
|
+
success: boolean;
|
|
1698
|
+
data: {
|
|
1699
|
+
allowedDomains: string[];
|
|
1700
|
+
};
|
|
1701
|
+
}>;
|
|
1670
1702
|
/**
|
|
1671
1703
|
* Disconnect a provider.
|
|
1672
1704
|
*/
|
|
@@ -3913,6 +3945,20 @@ declare class Knowledge extends APIResource {
|
|
|
3913
3945
|
url: string;
|
|
3914
3946
|
title?: string;
|
|
3915
3947
|
}): Promise<Res<KnowledgeSource>>;
|
|
3948
|
+
/**
|
|
3949
|
+
* A whole website: the pages in its sitemap, each added as its own source
|
|
3950
|
+
* (admins). The site must be on your website chat domains or be your
|
|
3951
|
+
* workspace website; pages count against your plan's cap. `pagesFound` =
|
|
3952
|
+
* pages listed on the site, `queued` = sources added now. Fails with
|
|
3953
|
+
* `code` `INVALID_WEBSITE`, `WEBSITE_NOT_ALLOWED`, `KNOWLEDGE_LIMIT` or
|
|
3954
|
+
* `WEBSITE_UNREACHABLE`.
|
|
3955
|
+
*/
|
|
3956
|
+
addWebsite(params: {
|
|
3957
|
+
url: string;
|
|
3958
|
+
}): Promise<Res<{
|
|
3959
|
+
pagesFound: number;
|
|
3960
|
+
queued: number;
|
|
3961
|
+
}>>;
|
|
3916
3962
|
/** Upload a file (PDF, Word, text, image) to your storage and add it. */
|
|
3917
3963
|
addFile(file: Blob, opts?: {
|
|
3918
3964
|
title?: string;
|
|
@@ -4099,6 +4145,25 @@ interface PausedRun {
|
|
|
4099
4145
|
/** Who the run is about: the contact's name, else their masked phone/email. */
|
|
4100
4146
|
contact?: string;
|
|
4101
4147
|
}
|
|
4148
|
+
/** Channels with AI outcome counts. */
|
|
4149
|
+
type AiOutcomeChannel = "webchat";
|
|
4150
|
+
/** What the AI achieved on a channel in a window. */
|
|
4151
|
+
interface AiOutcomeCounts {
|
|
4152
|
+
/** Threads with at least one visitor message. */
|
|
4153
|
+
chats: number;
|
|
4154
|
+
/** Threads the AI answered with no team reply. */
|
|
4155
|
+
answeredByAi: number;
|
|
4156
|
+
/** Threads the AI handed to a person. */
|
|
4157
|
+
handedOff: number;
|
|
4158
|
+
/** Threads linked to a contact. */
|
|
4159
|
+
contactsSaved: number;
|
|
4160
|
+
/** Appointments the AI booked. */
|
|
4161
|
+
bookings: number;
|
|
4162
|
+
}
|
|
4163
|
+
/** The counts for the window, and for the same length of time before it. */
|
|
4164
|
+
interface AiOutcomes extends AiOutcomeCounts {
|
|
4165
|
+
previous: AiOutcomeCounts;
|
|
4166
|
+
}
|
|
4102
4167
|
/**
|
|
4103
4168
|
* The AI agent: its settings and the drafts it leaves in the inbox. Drafts
|
|
4104
4169
|
* also arrive live on `ai_suggestion` and leave on `ai_suggestion.resolved`;
|
|
@@ -4115,6 +4180,17 @@ declare class AiAgent extends APIResource {
|
|
|
4115
4180
|
success: boolean;
|
|
4116
4181
|
data: AiAgentSettings;
|
|
4117
4182
|
}>;
|
|
4183
|
+
/**
|
|
4184
|
+
* What the AI achieved on a channel in the last `days` days (1–90, default
|
|
4185
|
+
* 30), with `previous` for the `days` before. Default channel `webchat`.
|
|
4186
|
+
*/
|
|
4187
|
+
outcomes(params?: {
|
|
4188
|
+
channel?: AiOutcomeChannel;
|
|
4189
|
+
days?: number;
|
|
4190
|
+
}): Promise<{
|
|
4191
|
+
success: boolean;
|
|
4192
|
+
data: AiOutcomes;
|
|
4193
|
+
}>;
|
|
4118
4194
|
/** Answer review: sampled AI replies (last 30 days), waiting first. */
|
|
4119
4195
|
reviews(status?: "waiting" | "reviewed"): Promise<{
|
|
4120
4196
|
success: boolean;
|
|
@@ -4645,75 +4721,6 @@ declare class PlatformDomain {
|
|
|
4645
4721
|
constructor(client: AxiosInstance);
|
|
4646
4722
|
}
|
|
4647
4723
|
|
|
4648
|
-
/**
|
|
4649
|
-
* Typed error hierarchy for the @ecodrix/erix-api SDK.
|
|
4650
|
-
*
|
|
4651
|
-
* All errors thrown by the SDK extend `EcodrixError`, so a single
|
|
4652
|
-
* `catch` block can handle them all, while still allowing granular
|
|
4653
|
-
* differentiation between auth failures, rate limits, and generic API errors.
|
|
4654
|
-
*
|
|
4655
|
-
* @example
|
|
4656
|
-
* ```typescript
|
|
4657
|
-
* import { APIError, AuthenticationError, RateLimitError } from "@ecodrix/erix-api";
|
|
4658
|
-
*
|
|
4659
|
-
* try {
|
|
4660
|
-
* await ecod.product.erix.leads.retrieve("invalid_id");
|
|
4661
|
-
* } catch (err) {
|
|
4662
|
-
* if (err instanceof AuthenticationError) {
|
|
4663
|
-
* console.error("Invalid API key or client code.");
|
|
4664
|
-
* } else if (err instanceof RateLimitError) {
|
|
4665
|
-
* console.warn("Slow down — rate limit hit.");
|
|
4666
|
-
* } else if (err instanceof APIError) {
|
|
4667
|
-
* console.error(`API error ${err.status}: ${err.message}`);
|
|
4668
|
-
* }
|
|
4669
|
-
* }
|
|
4670
|
-
* ```
|
|
4671
|
-
*/
|
|
4672
|
-
/** Base class for all ECODrIx SDK errors. */
|
|
4673
|
-
declare class EcodrixError extends Error {
|
|
4674
|
-
constructor(message: string);
|
|
4675
|
-
}
|
|
4676
|
-
/**
|
|
4677
|
-
* Represents an error returned by the ECODrIx API.
|
|
4678
|
-
* Carries the HTTP `status` code and an optional `code` string.
|
|
4679
|
-
*/
|
|
4680
|
-
declare class APIError extends EcodrixError {
|
|
4681
|
-
/** HTTP status code returned by the API (e.g. 400, 404, 500). */
|
|
4682
|
-
status?: number;
|
|
4683
|
-
/** Machine-readable error code (e.g. `"NOT_FOUND"`, `"VALIDATION_ERROR"`). */
|
|
4684
|
-
code?: string;
|
|
4685
|
-
constructor(message: string, status?: number, code?: string);
|
|
4686
|
-
}
|
|
4687
|
-
/**
|
|
4688
|
-
* Thrown when the API key or client code is missing, invalid, or expired.
|
|
4689
|
-
* HTTP 401. `code` is the server's (e.g. `INVALID_KEY`) when it sends one.
|
|
4690
|
-
*/
|
|
4691
|
-
declare class AuthenticationError extends APIError {
|
|
4692
|
-
constructor(message?: string, code?: string, status?: number);
|
|
4693
|
-
}
|
|
4694
|
-
/**
|
|
4695
|
-
* Thrown when the caller is signed in but not allowed: role, plan, or no
|
|
4696
|
-
* longer a member (`code` `FORBIDDEN`, `NOT_A_MEMBER`, …). HTTP 403. Extends
|
|
4697
|
-
* AuthenticationError so existing 401/403 handling keeps working; check
|
|
4698
|
-
* `status` or `code` to tell a dead key from a missing permission.
|
|
4699
|
-
*/
|
|
4700
|
-
declare class PermissionError extends AuthenticationError {
|
|
4701
|
-
constructor(message?: string, code?: string);
|
|
4702
|
-
}
|
|
4703
|
-
/**
|
|
4704
|
-
* Thrown when the rate limit for the API key has been exceeded.
|
|
4705
|
-
* HTTP 429. Implement exponential backoff before retrying.
|
|
4706
|
-
*/
|
|
4707
|
-
declare class RateLimitError extends APIError {
|
|
4708
|
-
constructor(message?: string);
|
|
4709
|
-
}
|
|
4710
|
-
/**
|
|
4711
|
-
* Turn an HTTP client error into the typed SDK error: 401 → AuthenticationError,
|
|
4712
|
-
* 403 → PermissionError, 429 → RateLimitError, else APIError. Keeps the
|
|
4713
|
-
* server's status and code (sent in `code`, or in `error` as UPPER_SNAKE).
|
|
4714
|
-
*/
|
|
4715
|
-
declare function toAPIError(error: any): APIError;
|
|
4716
|
-
|
|
4717
4724
|
declare class WebhookSignatureError extends APIError {
|
|
4718
4725
|
constructor(message: string);
|
|
4719
4726
|
}
|
|
@@ -5348,4 +5355,4 @@ declare function getRetryConfig(error: any): {
|
|
|
5348
5355
|
readonly reason: "Generic API errors may be transient and worth retrying";
|
|
5349
5356
|
};
|
|
5350
5357
|
|
|
5351
|
-
export { type AIPersona, APIError, APIResource, type AgentAutonomy, type AgentBudget, AiAgent, type AiAgentSettings, type AiAgentTool, type AiHumanTopics, type AiReviewItem, type AiReviewStats, type AiReviewVerdict, type AiSuggestion, type AnswerFollowupBody, type AnswerOnboardingPayload, type AnswerOnboardingResponse, type ApplyCouponPayload, type AssignEventPayload, AuthenticationError, type BehaviorRules, type CheckboxConfig, type CheckoutAmountBreakdown, type CheckoutOrderResponse, type CheckoutProduct, type CheckoutSession, type ColorRule, type ColumnConfig, type CompleteOnboardingPayload, type CompleteOnboardingResponse, type ConfidenceResponse, ConnectInfra, type Conversation, type ListParams as ConversationListParams, type Correction, type CreateLeadParams, type CreateOrderPayload, type CreatePipelineParams, type CreateSessionPayload, type CrmView, type CurrencyConfig, type CurrencyValue, type CustomFieldFilter, type DateConfig, type DateTimeConfig, type DropdownConfig, ECODrIxAPI as ECODrIx, ECODrIxAPI, type ECODrIxAPIOptions, ERROR_RETRY_CONFIG,
|
|
5358
|
+
export { type AIPersona, APIError, APIResource, type AgentAutonomy, type AgentBudget, AiAgent, type AiAgentSettings, type AiAgentTool, type AiHumanTopics, type AiOutcomeChannel, type AiOutcomeCounts, type AiOutcomes, type AiReviewItem, type AiReviewStats, type AiReviewVerdict, type AiSuggestion, type AnswerFollowupBody, type AnswerOnboardingPayload, type AnswerOnboardingResponse, type ApplyCouponPayload, type AssignEventPayload, AuthenticationError, type BehaviorRules, type CheckboxConfig, type CheckoutAmountBreakdown, type CheckoutOrderResponse, type CheckoutProduct, type CheckoutSession, type ColorRule, type ColumnConfig, type CompleteOnboardingPayload, type CompleteOnboardingResponse, type ConfidenceResponse, ConnectInfra, type Conversation, type ListParams as ConversationListParams, type Correction, type CreateLeadParams, type CreateOrderPayload, type CreatePipelineParams, type CreateSessionPayload, type CrmView, type CurrencyConfig, type CurrencyValue, type CustomFieldFilter, type DateConfig, type DateTimeConfig, type DropdownConfig, ECODrIxAPI as ECODrIx, ECODrIxAPI, type ECODrIxAPIOptions, ERROR_RETRY_CONFIG, type EditOnboardingPayload, type EditOnboardingResponse, type EmailConfig, EmailConnect, ErixChat, ErixProduct, type EventDefinition, type FieldConfig, type FieldDefinition, type FieldManifest, type FieldType, type FileConfig, type FilterOperator, type FilterRule, type FormulaConfig, type GlobalOnboardingPayload, HTTP_STATUS_ERROR_MAP, type ICP, type InboxChannel, InfraDomain, KNOWLEDGE_FILE_TYPES, Knowledge, type KnowledgePassage, type KnowledgeSource, LEAD_STATUS_VALUES, type LayoutType, type Lead, type LeadPattern, type LeadSource, type LeadStatus, type LearningMemory, type ListLeadsParams, type ManifestFieldType, type MappingField, type MappingPreviewResult, type MappingSources, type MappingValidationResult, type Message, type ModuleAgent, type ModuleAgentPatch, type ModuleAgentSettings, type ModuleAgentTool, type NichePack, type NichePackResearchConfig, type NichePackStatus, type NormalizedFieldValue, type NumberConfig, Onboarding, type OnboardingCohortRange, type OnboardingConfig, type OnboardingExperiment, type OnboardingExperimentStatus, type OnboardingExperimentVariant, type OnboardingMemoryMapping, type OnboardingOption, type OnboardingSession, type OnboardingSessionStatus, type OnboardingStateResponse, type OnboardingStep, type OnboardingStepType, type OutboundMedia, type OutreachEdit, type PaginatedResponse, type PausedRun, Persona, type PersonaFollowupQuestion, type PersonaFollowupsResponse, type PersonaIdentity, type PersonaTimelineEntry, type PersonaTimelineOptions, type PersonaTimelineResponse, type PhoneConfig, type Pipeline, type PipelineStage, type PipelineStageParams, PlatformDomain, PlatformTenants, PlatformUsers, ProductDomain, type ProgressConfig, RateLimitError, type RatingConfig, type ReinforceResponse, type ReinforcementEvent, type RelationConfig, type RelationValue, type RequestOptions, type ResourceManifest, type SendMessageParams, type SendTemplateParams, type ServiceConfig, type ServiceConfigGlobal, type ServiceConfigPerProduct, type SortRule, type StartOnboardingPayload, type StartOnboardingResponse, StorageInfra, type StoredFieldValue, type SuggestionEvent, type TagsConfig, type Template, type TemplateApiResponse, type TemplateBinding, type TemplateBindingSource, type TemplateComponent, type TemplateEmptyPolicy, type TemplateMapping, type TextConfig, type TriggerPayload, type TriggerResponse, type UpsertLeadParams, type UrlConfig, type VerifyPayload, type ViewConfig, type Vocabulary, WebchatOwnerSettings, WebchatSettingsPatch, WebhookSignatureError, Webhooks, WhatsAppConnect, type WorkspaceDashboardLayout, type WorkspaceDefaultAutomation, type WorkspaceDefaultField, type WorkspaceDefaultPipeline, type WorkspaceModuleConfig, type WorkspaceProfile, ECODrIxAPI as default, getErrorDetails, getRetryConfig, handleAPIError, isAPIError };
|
package/dist/ts/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Qe=Object.defineProperty,Ye=Object.defineProperties;var Je=Object.getOwnPropertyDescriptors;var Fe=Object.getOwnPropertySymbols;var Xe=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var et=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n);var Re=(n,e,t)=>e in n?Qe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,u=(n,e)=>{for(var t in e||(e={}))Xe.call(e,t)&&Re(n,t,e[t]);if(Fe)for(var t of Fe(e))Ze.call(e,t)&&Re(n,t,e[t]);return n},b=(n,e)=>Ye(n,Je(e));var s=(n,e,t)=>Re(n,typeof e!="symbol"?e+"":e,t);var ke=function(n,e){this[0]=n,this[1]=e},Ke=(n,e,t)=>{var r=(l,p,y,g)=>{try{var h=t[l](p),x=(p=h.value)instanceof ke,k=h.done;Promise.resolve(x?p[0]:p).then(d=>x?r(l==="return"?l:"next",p[1]?{done:d.done,value:d.value}:d,y,g):y({value:d,done:k})).catch(d=>r("throw",d,y,g))}catch(d){g(d)}},a=(l,p,y,g)=>c[l]=h=>(p=new Promise((x,k,d)=>(d=()=>r(l,h,x,k),o?o.then(d):d())),g=()=>o===y&&(o=0),o=y=p.then(g,g),p),o,c={};return t=t.apply(n,e),c[et("asyncIterator")]=()=>c,a("next"),a("throw"),a("return"),c};import st from"axios";import We from"axios-retry";var Pe="https://api.ecodrix.com";function je(n="v1",e=Pe){return`${e.replace(/\/+$/,"")}/${n}/api`}var Ae=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},m=class extends Ae{constructor(t,r,a){super(t);s(this,"status");s(this,"code");this.name="APIError",this.status=r,this.code=a}},T=class extends m{constructor(e="Invalid API Key or Client Code",t="AUTH_FAILED",r=401){super(e,r,t),this.name="AuthenticationError"}},v=class extends T{constructor(e="You don't have permission to do this.",t="FORBIDDEN"){super(e,t,403),this.name="PermissionError"}},w=class extends m{constructor(e="Too many requests. Please slow down."){super(e,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};function q(n){var o;if(!(n!=null&&n.response))return new m((n==null?void 0:n.message)||"Network Error");let{status:e,data:t}=n.response,r=(t==null?void 0:t.message)||(t==null?void 0:t.error)||"API Request Failed",a=(o=t==null?void 0:t.code)!=null?o:typeof(t==null?void 0:t.error)=="string"&&/^[A-Z][A-Z0-9_]*$/.test(t.error)?t.error:void 0;switch(e){case 401:return new T(r,a);case 403:return new v(r,a);case 429:return new w(r);default:return new m(r,e,a)}}var i=class{constructor(e){s(this,"client",e)}async post(e,t,r){try{let a=this.buildConfig(r);return(await this.client.post(e,t,a)).data}catch(a){this.handleError(a)}}async get(e,t){try{let r=this.buildConfig(t);return(await this.client.get(e,r)).data}catch(r){this.handleError(r)}}async patch(e,t,r){try{let a=this.buildConfig(r);return(await this.client.patch(e,t,a)).data}catch(a){this.handleError(a)}}async put(e,t,r){try{let a=this.buildConfig(r);return(await this.client.put(e,t,a)).data}catch(a){this.handleError(a)}}async deleteRequest(e,t){try{let r=this.buildConfig(t);return(await this.client.delete(e,r)).data}catch(r){this.handleError(r)}}buildConfig(e){if(!e)return;let t=u({},e);return e.idempotencyKey&&(t.headers=b(u({},t.headers),{"Idempotency-Key":e.idempotencyKey})),t}handleError(e){throw q(e)}};var ve=class extends i{async list(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async create(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async update(e,t){return this.patch(`/product/erix/crm/notes/${e}`,{content:t})}async pin(e,t=!0){return this.patch(`/product/erix/crm/notes/${e}/pin`,{isPinned:t})}async delete(e){return this.deleteRequest(`/product/erix/crm/notes/${e}`)}},U=class extends i{constructor(t){super(t);s(this,"notes");this.notes=new ve(t)}async timeline(t,r){return this.get(`/product/erix/crm/leads/${t}/timeline`,{params:r})}async list(t,r){return this.get(`/product/erix/crm/leads/${t}/activities`,{params:u({},r)})}async log(t){return this.post(`/product/erix/crm/leads/${t.leadId}/activities`,t)}async logCall(t,r){return this.post(`/product/erix/crm/leads/${t}/calls`,r)}};var _=class extends i{async overview(e){return this.get("/product/erix/crm/analytics/overview",{params:e})}async funnel(e){return this.get("/product/erix/crm/analytics/funnel",{params:{pipelineId:e}})}async forecast(e){return this.get("/product/erix/crm/analytics/forecast",{params:{pipelineId:e}})}async sources(e){return this.get("/product/erix/crm/analytics/sources",{params:e})}async team(e){return this.get("/product/erix/crm/analytics/team",{params:e})}async heatmap(e){return this.get("/product/erix/crm/analytics/heatmap",{params:e})}async scores(){return this.get("/product/erix/crm/analytics/scores")}async stageTime(e){return this.get("/product/erix/crm/analytics/stage-time",{params:{pipelineId:e}})}async tiered(e){return this.get("/product/erix/crm/analytics/tiered",{params:e})}async summary(e){return this.get("/product/erix/crm/analytics/summary",{params:e})}async whatsapp(e){return this.get("/product/erix/crm/analytics/whatsapp",{params:e})}async revenue(){return this.get("/product/erix/crm/analytics/revenue")}async health(){return this.get("/product/erix/crm/analytics/health")}async payments(){return this.get("/product/erix/crm/analytics/payments")}async reviews(){return this.get("/product/erix/crm/analytics/reviews")}async retention(){return this.get("/product/erix/crm/analytics/retention")}};var N=class extends i{async getChecklist(e){return this.get(`/product/erix/crm/documents/checklist/${e}`)}async createChecklist(e,t){return this.post(`/product/erix/crm/documents/checklist/${e}`,{templateNiche:t})}async markReceived(e,t,r){return this.patch(`/product/erix/crm/documents/checklist/${e}/${t}`,r?{fileUrl:r}:{})}async sendReminder(e){return this.post(`/product/erix/crm/documents/checklist/${e}/remind`)}async listIncomplete(){return this.get("/product/erix/crm/documents/checklist/incomplete")}async listTemplates(){return this.get("/product/erix/crm/documents/templates")}};var B=class extends i{async csv(e){return this.get("/product/erix/commerce/invoices/export/csv",{params:e})}async tally(e){return this.get("/product/erix/commerce/invoices/export/tally",{params:e})}async zoho(e){return this.get("/product/erix/commerce/invoices/export/zoho",{params:e})}};var He=["open","won","lost","archived"],V=class extends i{async create(e){return this.post("/product/erix/crm/leads",e)}async describe(){let e=await this.fields(),t=Array.isArray(e.data)?e.data:[],r=[{key:"firstName",label:"First Name",type:"string",required:!0,group:"Basic Info"},{key:"lastName",label:"Last Name",type:"string",required:!1,group:"Basic Info"},{key:"phone",label:"Phone Number",type:"phone",required:!0,group:"Contact"},{key:"email",label:"Email Address",type:"email",required:!1,group:"Contact"},{key:"status",label:"Status",type:"select",required:!0,options:He.map(o=>({label:`${o.charAt(0).toUpperCase()}${o.slice(1)}`,value:o}))},{key:"value",label:"Lead Value",type:"currency",required:!1},{key:"source",label:"Source",type:"string",required:!1}],a=t.map(o=>({key:`metadata.extra.${o.name}`,label:o.label||o.name,type:o.type||"string",required:!!o.required,options:o.options,group:"Custom Fields"}));return{name:"Lead",fields:[...r,...a],uiHints:{icon:"User",primaryColor:"#3b82f6",defaultSort:{field:"createdAt",direction:"desc"},summaryFields:["firstName","lastName","phone","status"]}}}async upsert(e){return this.post("/product/erix/crm/leads/upsert",e)}async createMany(e,t=50){let r=[];for(let a=0;a<e.length;a+=t){let c=e.slice(a,a+t).map(p=>this.create(p)),l=await Promise.allSettled(c);for(let p of l)if(p.status==="fulfilled")r.push(p.value);else throw p.reason}return r}async import(e){return this.post("/product/erix/crm/leads/import",{leads:e})}async bulkUpsert(e){return this.import(e)}async list(e){let t=u({},e);return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/product/erix/crm/leads",{params:t})}listAutoPaging(e){return Ke(this,null,function*(){let t=(e==null?void 0:e.page)||1,r=!0;for(;r;){let a=yield new ke(this.list(b(u({},e),{page:t}))),o=Array.isArray(a.data)?a.data:a||[];if(o.length===0){r=!1;break}for(let c of o)yield c;a.pagination&&t<a.pagination.pages||!a.pagination&&o.length>0?t++:r=!1}})}async retrieve(e){return this.get(`/product/erix/crm/leads/${e}`)}async retrieveByPhone(e){return this.get(`/product/erix/crm/leads/phone/${encodeURIComponent(e)}`)}async byStage(e,t,r={}){return this.get(`/product/erix/crm/pipelines/${e}/stages/${t}/leads`,{params:r})}async retrieveByRef(e,t){return this.get(`/product/erix/crm/leads/ref/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}async update(e,t){return this.patch(`/product/erix/crm/leads/${e}`,t)}async setFollowUp(e,t,r){return this.patch(`/product/erix/crm/leads/${e}`,{nextFollowUpAt:t,nextFollowUpNote:t&&r!=null?r:null})}async move(e,t){return this.patch(`/product/erix/crm/leads/${e}/move`,{stageId:t})}async convert(e,t,r){return this.post(`/product/erix/crm/leads/${e}/convert`,{outcome:t,reason:r})}async tags(e,t){return this.patch(`/product/erix/crm/leads/${e}/tags`,t)}async recalculateScore(e){return this.post(`/product/erix/crm/leads/${e}/score`,{})}async updateMetadata(e,t){return this.patch(`/product/erix/crm/leads/${e}/metadata`,t)}async fields(){return this.get("/product/erix/crm/fields")}async notes(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async activities(e,t){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:t})}async createNote(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async updateNote(e,t,r){return this.patch(`/product/erix/crm/notes/${t}`,r)}async deleteNote(e,t){return this.deleteRequest(`/product/erix/crm/notes/${t}`)}async delete(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async export(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/export`)}async erase(e){return this.post(`/product/erix/crm/leads/${encodeURIComponent(e)}/erase`,{confirm:"ERASE"})}async bulkArchive(e){return this.patch("/product/erix/crm/leads/bulk-archive",{ids:e})}async bulkDelete(e){return this.deleteRequest("/product/erix/crm/leads",{data:{ids:e}})}async archive(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async profile(e){return this.get(`/product/erix/crm/leads/${e}/profile`)}async invoices(e){return this.get(`/product/erix/crm/leads/${e}/invoices`)}async projects(e){return this.get(`/product/erix/crm/leads/${e}/projects`)}async conversations(e){return this.get(`/product/erix/crm/leads/${e}/conversations`)}async meetings(e){return this.get(`/product/erix/crm/leads/${e}/meetings`)}async flowRuns(e){return this.get(`/product/erix/crm/leads/${e}/flow-runs`)}async merge(e,t){return this.post("/product/erix/crm/leads/merge",{primaryId:e,secondaryId:t})}};var F=class extends i{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var K=class extends i{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){var a,o;let t=await this.retrieve(e),r=Array.isArray((a=t.data)==null?void 0:a.stages)?t.data.stages:[];return{name:`Pipeline: ${((o=t.data)==null?void 0:o.name)||e}`,fields:r.map(c=>({key:c._id,label:c.name,type:"string",required:!0,options:[{label:c.name,value:c._id}],group:"Stages",uiHints:{color:c.color||"#cbd5e1",probability:c.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/product/erix/crm/pipelines",e)}async retrieve(e){return this.get(`/product/erix/crm/pipelines/${e}`)}async update(e,t){return this.patch(`/product/erix/crm/pipelines/${e}`,t)}async setDefault(e){return this.patch(`/product/erix/crm/pipelines/${e}/default`,{})}async duplicate(e,t){return this.post(`/product/erix/crm/pipelines/${e}/duplicate`,{name:t})}async archive(e){return this.patch(`/product/erix/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/product/erix/crm/pipelines/${e}`)}async checkInUse(e){return this.get(`/product/erix/crm/pipelines/${e}/in-use`)}async board(e){return this.get(`/product/erix/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/product/erix/crm/pipelines/${e}/forecast`)}async addStage(e,t){return this.post(`/product/erix/crm/pipelines/${e}/stages`,t)}async reorderStages(e,t){return this.patch(`/product/erix/crm/pipelines/${e}/stages/reorder`,{order:t})}async updateStage(e,t){return this.patch(`/product/erix/crm/stages/${e}`,t)}async deleteStage(e,t){return this.deleteRequest(`/product/erix/crm/stages/${e}`,{data:t?{moveLeadsToStageId:t}:void 0})}};var j=class extends i{async getConfig(){return this.get("/product/erix/crm/scoring")}async updateConfig(e){return this.patch("/product/erix/crm/scoring",e)}async recalculate(e){return this.post(`/product/erix/crm/scoring/${e}/recalculate`,{})}async preview(e){return this.get(`/product/erix/crm/scoring/preview/${e}`)}};var H=class extends i{async list(e){return this.get("/platform/inbox/conversations",{params:e})}async create(e){var t;return this.post("/platform/inbox/conversations",{address:e.phone,channel:(t=e.channel)!=null?t:"whatsapp",userName:e.name})}async linkLead(e,t){return this.patch(`/platform/inbox/conversations/${e}/lead`,{leadId:t})}async retrieve(e){return this.get(`/platform/inbox/conversations/${e}`)}async messages(e,t){return this.get(`/platform/inbox/conversations/${e}/messages`,{params:t})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async delete(e){return this.deleteRequest(`/platform/inbox/conversations/${e}`)}async bulkDelete(e){return this.post("/platform/inbox/conversations/bulk-delete",{ids:e})}};var P=class extends i{async send(e){if(e.conversationId)return this.post(`/platform/inbox/conversations/${e.conversationId}/messages`,{text:e.text,media:e.media});if(!e.to)throw new Error("send: conversationId or to is required");if(e.media)throw new Error("send: media goes to an inbox thread (conversationId)");return this.post("/infra/connect/send/whatsapp",{phone:e.to,text:e.text})}async sendTemplate(e){return this.post("/infra/connect/send/whatsapp",{phone:e.to,templateName:e.templateName,language:e.language,variables:e.variables})}async star(e,t){return this.post(`/platform/inbox/messages/${e}/star`,{starred:t})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async upload(e,t={}){var y,g,h;let r=(g=(y=t.fileName)!=null?y:e.name)!=null?g:"file",a=e.type||"application/octet-stream",o=await this.post("/infra/storage/files/upload-url",{folder:(h=t.folder)!=null?h:"inbox",filename:r,contentType:a}),{uploadUrl:c,key:l}=o.data,p=await fetch(c,{method:"PUT",headers:{"Content-Type":a},body:e});if(!p.ok)throw new Error(`upload failed (${p.status})`);return await this.post("/infra/storage/files/confirm-upload",{key:l,sizeBytes:e.size}),{key:l,mimeType:a,fileName:r}}};var W=class extends i{async getProduct(e){return this.get(`/product/erix/commerce/checkout/products/${e}`)}async createSession(e){return this.post("/product/erix/commerce/checkout/session",e)}async applyCoupon(e){return this.post("/product/erix/commerce/checkout/coupon",e)}async verify(e){return this.post("/product/erix/commerce/checkout/verify",e)}async createOrder(e){return this.post("/product/erix/commerce/checkout/order",e)}};var z=class extends i{async trigger(e){return this.post("/product/erix/events/trigger",e)}async listCustomEvents(){return this.get("/product/flow/config/triggers")}async createCustomEvent(e){return this.post("/product/flow/config/triggers",e)}async deleteCustomEvent(e){return this.deleteRequest(`/product/flow/config/triggers/${e}`)}};var G=class extends i{async list(e){return this.get("/product/erix/commerce/invoices",{params:e})}async getInvoice(e){return this.get(`/product/erix/commerce/invoices/${e}`)}async create(e){return this.post("/product/erix/commerce/invoices",e)}async update(e,t){return this.patch(`/product/erix/commerce/invoices/${e}`,t)}async void(e){return this.post(`/product/erix/commerce/invoices/${e}/void`,{})}async sendViaWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${e}/send-whatsapp`,{})}async getSettings(){return this.get("/product/erix/commerce/settings")}async updateSettings(e){return this.put("/product/erix/commerce/settings",e)}async paymentLink(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payment-link`,{})}async recordPayment(e,t){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payments`,t)}async sendWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-whatsapp`,{})}async sendEmail(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-email`,{})}};var Q=class extends i{async workflowPacks(){return this.get("/product/erix/crm/niche/workflow-packs")}async workflowPackDetail(e){return this.get(`/product/erix/crm/niche/workflow-packs/${e}`)}async installWorkflowPack(e){return this.post(`/product/erix/crm/niche/workflow-packs/${e}/install`)}async templateSuggestions(){return this.get("/product/erix/crm/niche/template-suggestions")}};var Y=class extends i{async list(e){return this.get(`/product/erix/commerce/projects/${e}/documents`)}async upload(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents`,t)}async toggleSignature(e,t,r){return this.patch(`/product/erix/commerce/projects/${e}/documents/${t}/signature`,{required:r})}async addSigner(e,t,r){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/signers`,r)}async decline(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/decline`,{})}async stampSign(e,t,r){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/stamp-sign`,r)}};var J=class extends i{async providers(){return this.get("/infra/connect/providers")}async list(){return this.get("/infra/connect/connections")}async get_(e){return this.get(`/infra/connect/connections/${e}`)}async connect(e,t){return this.post(`/infra/connect/connections/${e}/connect`,t)}async configure(e,t){return this.put(`/infra/connect/connections/${e}/configure`,t)}async disconnect(e){return this.post(`/infra/connect/connections/${e}/disconnect`,{})}async reveal(e){return this.post(`/infra/connect/connections/${e}/reveal`,{})}async test(e){return this.post(`/infra/connect/connections/${e}/test`,{})}async setAccess(e,t){return this.put(`/infra/connect/connections/${e}/access`,t)}async googleConnectUrl(){return this.post("/infra/connect/google/connect-url",{})}async createPaymentLink(e){return this.post("/infra/connect/connections/payments/payment-link",e)}};var X=class extends i{async sendTest(e){return this.post("/infra/connect/email/test",{to:e})}async listTemplates(e){return this.get("/infra/connect/email/templates",{params:e})}async getTemplate(e){return this.get(`/infra/connect/email/templates/${e}`)}async createTemplate(e){return this.post("/infra/connect/email/templates",e)}async updateTemplate(e,t){return this.put(`/infra/connect/email/templates/${e}`,t)}async deleteTemplate(e,t=!1){return this.deleteRequest(`/infra/connect/email/templates/${e}`,{params:{force:t}})}async previewTemplate(e,t){return this.post(`/infra/connect/email/templates/${e}/preview`,t)}};var Z=class extends i{async create(e){return this.post("/infra/connect/meet",e)}async list(e){return this.get("/infra/connect/meet",{params:e})}async retrieve(e){return this.get(`/infra/connect/meet/${e}`)}async update(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async reschedule(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async delete(e){return this.update(e,{status:"cancelled"})}};var ee=class extends i{async getConfig(){return this.get("/infra/connect/email/config")}async initDomainVerification(e){return this.post("/infra/connect/email/config/ses/domain",{domain:e})}async saveEmailConfig(e){return this.post("/infra/connect/email/config/ses/config",e)}async checkSesVerification(){return this.get("/infra/connect/email/config/ses/verify")}async removeSesIdentity(){return this.deleteRequest("/infra/connect/email/config/ses/domain")}async sendTest(e){return this.post("/infra/connect/email/config/test",{toEmail:e})}async saveAdvancedConfig(e){return this.post("/infra/connect/email/config/advanced",e)}async getHealth(){return this.get("/infra/connect/email/config/health")}async fixDmarc(){return this.post("/infra/connect/email/config/ses/fix-dmarc",{})}async listProviders(){return this.get("/infra/connect/email/config/providers")}};var te=class extends i{async list(e){return this.get("/infra/connect/whatsapp/templates",{params:e})}async sync(){return this.post("/infra/connect/whatsapp/templates/sync",{})}async retrieve(e){return this.get(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}`)}async create(e){return this.post("/infra/connect/whatsapp/templates",e)}async update(e,t){return this.put(`/infra/connect/whatsapp/templates/${e}`,t)}async deleteTemplate(e,t){return this.deleteRequest(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}${t?"?force=true":""}`)}async mappingConfig(){return this.get("/infra/connect/whatsapp/templates/mapping/config")}async mappingSources(){return this.get("/infra/connect/whatsapp/templates/mapping/sources")}async collections(){return this.get("/infra/connect/whatsapp/templates/collections")}async collectionFields(e){return this.get(`/infra/connect/whatsapp/templates/collections/${encodeURIComponent(e)}/fields`)}async updateMapping(e,t){return this.put(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/mapping`,t)}async validate(e,t){let r=`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/validate`;return t?this.post(r,t):this.get(r)}async preview(e,t,r,a){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:t,mappings:r,onEmptyVariable:a})}async getVariableManifest(e){var o,c;let t=await this.retrieve(e),r=Array.isArray((o=t.data)==null?void 0:o.components)?t.data.components:[],a=[];for(let l of r)if(l.text){let p=l.text.match(/{{(\d+)}}/g);if(p)for(let y of p){let g=y.replace(/{{|}}/g,"");a.push({key:`var_${g}`,label:`${l.type} Var {{${g}}}`,type:"string",required:!0,group:l.type,description:`Variable placeholder in template ${l.type}`})}}return{name:`Template variables: ${((c=t.data)==null?void 0:c.name)||e}`,fields:a,uiHints:{icon:"Variables",primaryColor:"#059669"}}}};import tt from"axios";var ne=class extends i{async getUsage(){return this.get("/infra/storage/files/usage")}async createFolder(e){return this.post("/infra/storage/files/folders",{name:e})}async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async aiDescribe(e){return this.post("/infra/storage/files/ai/describe",{key:e})}async upload(e,t){let r=await this.post("/infra/storage/files/upload-url",t),{uploadUrl:a,key:o}=r.data;await tt.put(a,e,{headers:{"Content-Type":t.contentType}});let c=e.size||e.byteLength||0;return this.post("/infra/storage/files/confirm-upload",{key:o,sizeBytes:c})}};var re=class extends i{async create(e){return this.post("/infra/storage/files/folders",{name:e})}},se=class extends i{async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async getUploadUrl(e){return this.post("/infra/storage/files/upload-url",e)}async confirmUpload(e){return this.post("/infra/storage/files/confirm-upload",e)}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}};var ie=class extends i{async system(){return(await this.get("/health")).data}};var ae=class extends i{async listAlerts(e){return this.get("/platform/users/notifications",{params:e})}async dismissAlert(e){return this.patch(`/platform/users/notifications/${e}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/platform/users/notifications/dismiss-all")}};var I=class extends i{async global(e){return this.post("/platform/tenants/onboarding/global",e)}async complete(e){return this.post("/platform/tenants/onboarding/complete",e)}};var S=class extends i{async get(e){return super.get(`/platform/tenants/persona/${e}`)}async reinforce(e){return this.post(`/platform/tenants/persona/${e.productId}/reinforce`,e)}async confidence(e){return super.get(`/platform/tenants/persona/${e}/confidence`,{params:{productId:e}})}async timeline(e,t){var a;let r=await super.get(`/platform/tenants/persona/${e}/timeline`,{params:t});return(a=r==null?void 0:r.data)!=null?a:{entries:[],hasMore:!1}}async followups(e){var r,a;let t=await super.get(`/platform/tenants/persona/${e}/followups`);return(a=(r=t==null?void 0:t.data)==null?void 0:r.entries)!=null?a:[]}};var Ie=class extends i{async chatSync(e){return this.post("/platform/ai/copilot/chat/sync",e)}async confirm(e){return this.post("/platform/ai/copilot/confirm",e)}async listSessions(){return this.get("/platform/ai/copilot/sessions")}async getSession(e){return this.get(`/platform/ai/copilot/sessions/${e}`)}async deleteSession(e){return this.deleteRequest(`/platform/ai/copilot/sessions/${e}`)}chatStreamUrl(){return"/platform/ai/copilot/chat"}},oe=class{constructor(e){s(this,"copilot");this.copilot=new Ie(e)}};var nt=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain","text/markdown","text/csv","text/html","image/png","image/jpeg","image/webp"],C=class extends i{async list(){return this.get("/platform/knowledge/sources")}async addText(e){return this.post("/platform/knowledge/sources",u({kind:"text"},e))}async addUrl(e){return this.post("/platform/knowledge/sources",u({kind:"url"},e))}async addFile(e,t={}){var a,o;let r=await new P(this.client).upload(e,{folder:"knowledge"});return this.post("/platform/knowledge/sources",{kind:"file",key:r.key,mimeType:r.mimeType,title:(o=(a=t.title)!=null?a:r.fileName)!=null?o:"Document"})}async remove(e){return this.deleteRequest(`/platform/knowledge/sources/${e}`)}async reindex(e){return this.post(`/platform/knowledge/sources/${e}/reindex`,{})}async search(e,t){return this.post("/platform/knowledge/search",u({query:e},t?{limit:t}:{}))}};var E=class extends i{async settings(){return this.get("/product/erix/ai/settings")}async updateSettings(e){return this.patch("/product/erix/ai/settings",e)}async reviews(e){return this.get(`/product/erix/ai/reviews${e?`?status=${e}`:""}`)}async review(e,t,r){return this.post(`/product/erix/ai/reviews/${encodeURIComponent(e)}`,u({verdict:t},r?{note:r}:{}))}async suggestion(e){return this.get(`/product/erix/ai/suggestion/${e}`)}async approveAction(e){return this.post(`/product/erix/ai/suggestion/${e}/approve-action`,{})}async markSent(e,t,r){return this.post(`/product/erix/ai/suggestion/${e}/send`,{text:t,confidence:r})}async dismiss(e){return this.post(`/product/erix/ai/suggestion/${e}/dismiss`,{})}async approvals(){return this.get("/product/flow/approvals")}async agents(){return this.get("/product/flow/agents")}async updateAgent(e,t){return this.patch(`/product/flow/agents/${encodeURIComponent(e)}`,t)}async decideRun(e,t,r){return this.post(`/product/flow/runs/${encodeURIComponent(e)}/approve`,u({decision:t},r&&{nodeId:r}))}};var ce=class extends i{async register(e){return this.post("/platform/auth/register",e)}async login(e){return this.post("/platform/auth/login",e)}async logout(e){return this.post("/platform/auth/logout",e)}async logoutAll(e){return this.post("/platform/auth/logout-all",e)}async validateSession(e){return this.post("/platform/auth/session/validate",e)}async listSessions(){return this.get("/platform/auth/sessions")}async revokeSession(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}async requestPasswordOtp(e){return this.post("/platform/auth/password/request-otp",e)}async setPassword(e){return this.post("/platform/auth/password/set",e)}async changePassword(e){return this.post("/platform/auth/password/change",e)}async forgotPassword(e){return this.post("/platform/auth/forgot",e)}async resetPassword(e){return this.post("/platform/auth/reset",e)}async linkOAuth(e){return this.post("/platform/auth/oauth-link",e)}async getInvitation(e){return this.get(`/platform/auth/invitations/${e}`)}async acceptInvitation(e,t){return this.post(`/platform/auth/invitations/${e}/accept`,t)}};var Se=class extends i{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},Ce=class extends i{async upgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/upgrade",e)}async downgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/downgrade",e)}async cancel(e){return this.post("/platform/billing/subscriptions/subscriptions/cancel",e)}async purchaseAddon(e){return this.post("/platform/billing/subscriptions/addons/purchase",e)}async cancelAddon(e){return this.post("/platform/billing/subscriptions/addons/cancel",e)}},Ee=class extends i{async listPublic(){return this.get("/platform/billing/plans/public")}},$e=class extends i{async plans(){return this.get("/platform/billing/checkout/plans")}async subscribe(e){return this.post("/platform/billing/checkout/subscribe",e)}async verify(e){return this.post("/platform/billing/checkout/verify",e)}async cancel(e){return this.post("/platform/billing/checkout/cancel",e)}async status(){return this.get("/platform/billing/checkout/status")}async syncPlan(e){return this.post("/platform/billing/checkout/sync-plan",e)}},Oe=class extends i{async transactions(){return this.get("/platform/billing/user/transactions")}async subscription(){return this.get("/platform/billing/user/subscription")}async raiseDispute(e){return this.post("/platform/billing/user/dispute",e)}async disputes(){return this.get("/platform/billing/user/disputes")}},Me=class extends i{async balance(){return this.get("/platform/billing/credits/balance")}async transactions(){return this.get("/platform/billing/credits/transactions")}async packs(){return this.get("/platform/billing/credits/packs")}async topupOrder(e){return this.post("/platform/billing/credits/topup/order",e)}async verifyTopup(e){return this.post("/platform/billing/credits/topup/verify",e)}async setAutoTopup(e){return this.patch("/platform/billing/credits/auto-topup",e)}async setSpendCap(e){return this.patch("/platform/billing/credits/spend-cap",e)}},pe=class{constructor(e){s(this,"entitlements");s(this,"subscriptions");s(this,"plans");s(this,"checkout");s(this,"user");s(this,"credits");this.entitlements=new Se(e),this.subscriptions=new Ce(e),this.plans=new Ee(e),this.checkout=new $e(e),this.user=new Oe(e),this.credits=new Me(e)}};var le=class extends i{async categories(){return this.get("/platform/support/categories")}async listTickets(e){return this.get("/platform/support/tickets",{params:e})}async createTicket(e){return this.post("/platform/support/tickets",e)}async getTicket(e){return this.get(`/platform/support/tickets/${e}`)}async reply(e,t){return this.post(`/platform/support/tickets/${e}/reply`,t)}async close(e){return this.patch(`/platform/support/tickets/${e}/close`,{})}};var ue=class extends i{async get(){return super.get("/platform/users/me")}async update(e){return this.patch("/platform/users/me",e)}async updateOrganization(e){return this.patch("/platform/users/me/organization",e)}async toggleModules(e){return this.post("/platform/users/me/modules",e)}async workspaces(){return super.get("/platform/users/me/workspaces")}async setActiveOrg(e){return this.post("/platform/users/me/active-org",e)}async dismissWorkspaceSetup(){return this.post("/platform/users/me/workspace/dismiss-setup",{})}},ge=class extends i{async list(){return this.get("/platform/users/members")}async invite(e){return this.post("/platform/users/members/invite",e)}async updateRole(e,t){return this.patch(`/platform/users/members/${e}`,{role:t})}async remove(e){return this.deleteRequest(`/platform/users/members/${e}`)}},de=class extends i{async list(){return this.get("/platform/auth/sessions")}async revoke(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}};var me=class{constructor(e){s(this,"messages");s(this,"conversations");this.messages=new P(e),this.conversations=new H(e)}},ye=class{constructor(e){s(this,"leads");s(this,"pipelines");s(this,"activities");s(this,"analytics");s(this,"scoring");s(this,"payments");s(this,"chat");s(this,"events");s(this,"invoices");s(this,"checkout");s(this,"projects");s(this,"niche");s(this,"documents");s(this,"invoiceExport");s(this,"ai");this.leads=new V(e),this.pipelines=new K(e),this.activities=new U(e),this.analytics=new _(e),this.scoring=new j(e),this.payments=new F(e),this.chat=new me(e),this.events=new z(e),this.invoices=new G(e),this.checkout=new W(e),this.projects=new Y(e),this.niche=new Q(e),this.documents=new N(e),this.invoiceExport=new B(e),this.ai=new E(e)}},$=class{constructor(e){s(this,"erix");this.erix=new ye(e)}},fe=class{constructor(e){s(this,"config");s(this,"templates");this.config=new ee(e),this.templates=new X(e)}},he=class{constructor(e){s(this,"templates");this.templates=new te(e)}},Te=class{constructor(e){s(this,"email");s(this,"whatsapp");s(this,"meet");s(this,"connections");this.email=new fe(e),this.whatsapp=new he(e),this.meet=new Z(e),this.connections=new J(e)}},xe=class{constructor(e){s(this,"files");s(this,"folders");s(this,"media");this.files=new se(e),this.folders=new re(e),this.media=new ne(e)}},O=class{constructor(e){s(this,"connect");s(this,"storage");this.connect=new Te(e),this.storage=new xe(e)}},be=class{constructor(e){s(this,"onboarding");s(this,"persona");this.onboarding=new I(e),this.persona=new S(e)}},we=class{constructor(e){s(this,"me");s(this,"members");s(this,"sessions");s(this,"notifications");this.me=new ue(e),this.members=new ge(e),this.sessions=new de(e),this.notifications=new ae(e)}},M=class{constructor(e){s(this,"auth");s(this,"users");s(this,"tenants");s(this,"billing");s(this,"support");s(this,"ai");s(this,"knowledge");s(this,"health");this.auth=new ce(e),this.users=new we(e),this.tenants=new be(e),this.billing=new pe(e),this.support=new le(e),this.ai=new oe(e),this.knowledge=new C(e),this.health=new ie(e)}};var R=class extends m{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},D=class{async constructEvent(e,t,r){if(!t)throw new R("No webhook signature provided");let a=Array.isArray(t)?t[0]:t;a.startsWith("sha256=")&&(a=a.slice(7));try{let o=await import("crypto"),l=o.createHmac("sha256",r).update(e).digest("hex");if(!o.timingSafeEqual(Buffer.from(l),Buffer.from(a)))throw new R("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(o){throw o instanceof R?o:new R(`Webhook payload parsing failed: ${o.message}`)}}};var De=typeof process!="undefined"&&"3.1.2"||"3.1.1";var ze,Le=(ze=We.default)!=null?ze:We,A=class{constructor(e){s(this,"client");s(this,"socket",null);s(this,"startSocket",null);s(this,"socketPromise",null);s(this,"socketQueue",[]);s(this,"clientCode");s(this,"apiVersion");s(this,"platform");s(this,"product");s(this,"infra");s(this,"webhooks");s(this,"lastSeq");s(this,"closed",!1);var g,h,x,k,d,qe,Ue,_e;let t=e.proxy;if(!e.apiKey&&!t)throw new T("API Key is required");this.clientCode=(g=e.clientCode)==null?void 0:g.toUpperCase(),this.apiVersion=(h=e.version)!=null?h:"v1";let r=(x=e.baseUrl)!=null?x:Pe,a=je(this.apiVersion,(k=t==null?void 0:t.url)!=null?k:r),o=e.socketUrl||r,c=typeof window!="undefined"&&typeof window.document!="undefined",l=c?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",p=c?((d=globalThis.navigator)==null?void 0:d.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown",y=b(u({},t?{}:{"x-api-key":e.apiKey,"x-client-code":((qe=e.clientCode)==null?void 0:qe.toUpperCase())||""}),{"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:De,runtime:l,os:p})});if(this.client=st.create({baseURL:a,headers:y,timeout:(Ue=e.timeout)!=null?Ue:3e4}),Le(this.client,{retries:3,retryDelay:Le.exponentialDelay,retryCondition:f=>{var L;return Le.isNetworkOrIdempotentRequestError(f)||((L=f.response)==null?void 0:L.status)===429},onRetry:(f,L,Ne)=>{var Be,Ve;typeof process!="undefined"&&((Be=process.env)==null?void 0:Be.NODE_ENV)==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${f}/3): ${(Ve=Ne.method)==null?void 0:Ve.toUpperCase()} ${Ne.url}. Reason: ${L.message}`)}}),this.platform=new M(this.client),this.product=new $(this.client),this.infra=new O(this.client),this.webhooks=new D,t){if(t.ticket){let f=t.ticket;this.startSocket=()=>this.initSocket(o,async()=>({ticket:await f()}))}}else{let f={apiKey:e.apiKey,clientCode:((_e=e.clientCode)==null?void 0:_e.toUpperCase())||""};this.startSocket=()=>this.initSocket(o,async()=>f,{"x-api-key":f.apiKey,"x-client-code":f.clientCode})}if(c){let f={version:De,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=f}}initSocket(e,t,r){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:a})=>{this.socket=a(e,{auth:o=>{t().then(c=>o(b(u({},c),{lastSeq:this.lastSeq})),()=>o({lastSeq:this.lastSeq}))},extraHeaders:r}),this.setupSocket();for(let{type:o,args:c}of this.socketQueue)o==="joinRoom"?this.socket.emit("join-room",c[0]):o==="leaveRoom"?this.socket.emit("leave-room",c[0]):o==="on"?this.socket.on(c[0],c[1]):o==="off"?this.socket.off(c[0],c[1]):o==="disconnect"&&this.socket.disconnect();this.socketQueue=[]}),this.socketPromise)}joinRoom(e){var t;this.closed||(t=this.startSocket)==null||t.call(this),this.socket?this.socket.emit("join-room",e):this.socketQueue.push({type:"joinRoom",args:[e]})}leaveRoom(e){this.socket?this.socket.emit("leave-room",e):this.socketQueue.push({type:"leaveRoom",args:[e]})}setupSocket(){this.socket&&(this.socket.on("connect_error",()=>{var e;(e=this.socket)!=null&&e.active||setTimeout(()=>{var t;this.closed||(t=this.socket)==null||t.connect()},5e3)}),this.socket.onAny((...e)=>{var r,a;let t=(r=e.at(-1))==null?void 0:r.seq;typeof t=="number"&&t>((a=this.lastSeq)!=null?a:0)&&(this.lastSeq=t)}))}on(e,t){var r;return this.closed||(r=this.startSocket)==null||r.call(this),this.socket?this.socket.on(e,t):this.socketQueue.push({type:"on",args:[e,t]}),this}disconnect(){this.closed=!0,this.socket?this.socket.disconnect():this.socketPromise&&this.socketQueue.push({type:"disconnect",args:[]})}off(e,t){return this.socket?this.socket.off(e,t):this.socketQueue.push({type:"off",args:[e,t]}),this}async request(e,t,r,a){var o,c,l;try{return(await this.client.request({method:e,url:t,data:r,params:a})).data}catch(p){throw p.response?new m(((o=p.response.data)==null?void 0:o.message)||((c=p.response.data)==null?void 0:c.error)||"Raw Execution Failed",p.response.status,(l=p.response.data)==null?void 0:l.code):new m(p.message||"Network Error")}}};var $r={401:T,403:v,429:w};function Or(n){throw q(n)}function Mr(n,e){return n instanceof e}function Dr(n){return n instanceof T?{message:n.message,status:n.status,code:n.code,type:"AuthenticationError"}:n instanceof w?{message:n.message,status:n.status,code:n.code,type:"RateLimitError"}:n instanceof m?{message:n.message,status:n.status,code:n.code,type:"APIError"}:{message:n.message||"Unknown error",type:"UnknownError"}}var Ge={[T.name]:{shouldRetry:!1,reason:"Authentication errors require fixing credentials, not retrying"},[w.name]:{shouldRetry:!0,maxRetries:3,baseDelay:1e3,backoffMultiplier:2,reason:"Rate limit errors can be retried with exponential backoff"},[m.name]:{shouldRetry:!0,maxRetries:2,baseDelay:500,backoffMultiplier:1.5,reason:"Generic API errors may be transient and worth retrying"}};function Lr(n){let e=n.constructor.name;return Ge[e]||Ge[m.name]}var _r=A;export{m as APIError,i as APIResource,E as AiAgent,T as AuthenticationError,Te as ConnectInfra,A as ECODrIx,A as ECODrIxAPI,Ge as ERROR_RETRY_CONFIG,Ae as EcodrixError,fe as EmailConnect,me as ErixChat,ye as ErixProduct,$r as HTTP_STATUS_ERROR_MAP,O as InfraDomain,nt as KNOWLEDGE_FILE_TYPES,C as Knowledge,He as LEAD_STATUS_VALUES,I as Onboarding,v as PermissionError,S as Persona,M as PlatformDomain,be as PlatformTenants,we as PlatformUsers,$ as ProductDomain,w as RateLimitError,xe as StorageInfra,R as WebhookSignatureError,D as Webhooks,he as WhatsAppConnect,_r as default,Dr as getErrorDetails,Lr as getRetryConfig,Or as handleAPIError,Mr as isAPIError,q as toAPIError};
|
|
1
|
+
import{a as l,b as y,d as i,e as Ue,f as Ne,g as _e,h as Be,i as Je,j as d,k as T,l as Ve,m as E,n as O}from"./chunk-XPXDFZWU.js";import Qe from"axios";import Ke from"axios-retry";var s=class{constructor(e){i(this,"client",e)}async post(e,t,n){try{let a=this.buildConfig(n);return(await this.client.post(e,t,a)).data}catch(a){this.handleError(a)}}async get(e,t){try{let n=this.buildConfig(t);return(await this.client.get(e,n)).data}catch(n){this.handleError(n)}}async patch(e,t,n){try{let a=this.buildConfig(n);return(await this.client.patch(e,t,a)).data}catch(a){this.handleError(a)}}async put(e,t,n){try{let a=this.buildConfig(n);return(await this.client.put(e,t,a)).data}catch(a){this.handleError(a)}}async deleteRequest(e,t){try{let n=this.buildConfig(t);return(await this.client.delete(e,n)).data}catch(n){this.handleError(n)}}buildConfig(e){if(!e)return;let t=l({},e);return e.idempotencyKey&&(t.headers=y(l({},t.headers),{"Idempotency-Key":e.idempotencyKey})),t}handleError(e){throw O(e)}};var Te=class extends s{async list(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async create(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async update(e,t){return this.patch(`/product/erix/crm/notes/${e}`,{content:t})}async pin(e,t=!0){return this.patch(`/product/erix/crm/notes/${e}/pin`,{isPinned:t})}async delete(e){return this.deleteRequest(`/product/erix/crm/notes/${e}`)}},M=class extends s{constructor(t){super(t);i(this,"notes");this.notes=new Te(t)}async timeline(t,n){return this.get(`/product/erix/crm/leads/${t}/timeline`,{params:n})}async list(t,n){return this.get(`/product/erix/crm/leads/${t}/activities`,{params:l({},n)})}async log(t){return this.post(`/product/erix/crm/leads/${t.leadId}/activities`,t)}async logCall(t,n){return this.post(`/product/erix/crm/leads/${t}/calls`,n)}};var D=class extends s{async overview(e){return this.get("/product/erix/crm/analytics/overview",{params:e})}async funnel(e){return this.get("/product/erix/crm/analytics/funnel",{params:{pipelineId:e}})}async forecast(e){return this.get("/product/erix/crm/analytics/forecast",{params:{pipelineId:e}})}async sources(e){return this.get("/product/erix/crm/analytics/sources",{params:e})}async team(e){return this.get("/product/erix/crm/analytics/team",{params:e})}async heatmap(e){return this.get("/product/erix/crm/analytics/heatmap",{params:e})}async scores(){return this.get("/product/erix/crm/analytics/scores")}async stageTime(e){return this.get("/product/erix/crm/analytics/stage-time",{params:{pipelineId:e}})}async tiered(e){return this.get("/product/erix/crm/analytics/tiered",{params:e})}async summary(e){return this.get("/product/erix/crm/analytics/summary",{params:e})}async whatsapp(e){return this.get("/product/erix/crm/analytics/whatsapp",{params:e})}async revenue(){return this.get("/product/erix/crm/analytics/revenue")}async health(){return this.get("/product/erix/crm/analytics/health")}async payments(){return this.get("/product/erix/crm/analytics/payments")}async reviews(){return this.get("/product/erix/crm/analytics/reviews")}async retention(){return this.get("/product/erix/crm/analytics/retention")}};var L=class extends s{async getChecklist(e){return this.get(`/product/erix/crm/documents/checklist/${e}`)}async createChecklist(e,t){return this.post(`/product/erix/crm/documents/checklist/${e}`,{templateNiche:t})}async markReceived(e,t,n){return this.patch(`/product/erix/crm/documents/checklist/${e}/${t}`,n?{fileUrl:n}:{})}async sendReminder(e){return this.post(`/product/erix/crm/documents/checklist/${e}/remind`)}async listIncomplete(){return this.get("/product/erix/crm/documents/checklist/incomplete")}async listTemplates(){return this.get("/product/erix/crm/documents/templates")}};var q=class extends s{async csv(e){return this.get("/product/erix/commerce/invoices/export/csv",{params:e})}async tally(e){return this.get("/product/erix/commerce/invoices/export/tally",{params:e})}async zoho(e){return this.get("/product/erix/commerce/invoices/export/zoho",{params:e})}};var Fe=["open","won","lost","archived"],U=class extends s{async create(e){return this.post("/product/erix/crm/leads",e)}async describe(){let e=await this.fields(),t=Array.isArray(e.data)?e.data:[],n=[{key:"firstName",label:"First Name",type:"string",required:!0,group:"Basic Info"},{key:"lastName",label:"Last Name",type:"string",required:!1,group:"Basic Info"},{key:"phone",label:"Phone Number",type:"phone",required:!0,group:"Contact"},{key:"email",label:"Email Address",type:"email",required:!1,group:"Contact"},{key:"status",label:"Status",type:"select",required:!0,options:Fe.map(o=>({label:`${o.charAt(0).toUpperCase()}${o.slice(1)}`,value:o}))},{key:"value",label:"Lead Value",type:"currency",required:!1},{key:"source",label:"Source",type:"string",required:!1}],a=t.map(o=>({key:`metadata.extra.${o.name}`,label:o.label||o.name,type:o.type||"string",required:!!o.required,options:o.options,group:"Custom Fields"}));return{name:"Lead",fields:[...n,...a],uiHints:{icon:"User",primaryColor:"#3b82f6",defaultSort:{field:"createdAt",direction:"desc"},summaryFields:["firstName","lastName","phone","status"]}}}async upsert(e){return this.post("/product/erix/crm/leads/upsert",e)}async createMany(e,t=50){let n=[];for(let a=0;a<e.length;a+=t){let c=e.slice(a,a+t).map(p=>this.create(p)),u=await Promise.allSettled(c);for(let p of u)if(p.status==="fulfilled")n.push(p.value);else throw p.reason}return n}async import(e){return this.post("/product/erix/crm/leads/import",{leads:e})}async bulkUpsert(e){return this.import(e)}async list(e){let t=l({},e);return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/product/erix/crm/leads",{params:t})}listAutoPaging(e){return Ne(this,null,function*(){let t=(e==null?void 0:e.page)||1,n=!0;for(;n;){let a=yield new Ue(this.list(y(l({},e),{page:t}))),o=Array.isArray(a.data)?a.data:a||[];if(o.length===0){n=!1;break}for(let c of o)yield c;a.pagination&&t<a.pagination.pages||!a.pagination&&o.length>0?t++:n=!1}})}async retrieve(e){return this.get(`/product/erix/crm/leads/${e}`)}async retrieveByPhone(e){return this.get(`/product/erix/crm/leads/phone/${encodeURIComponent(e)}`)}async byStage(e,t,n={}){return this.get(`/product/erix/crm/pipelines/${e}/stages/${t}/leads`,{params:n})}async retrieveByRef(e,t){return this.get(`/product/erix/crm/leads/ref/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}async update(e,t){return this.patch(`/product/erix/crm/leads/${e}`,t)}async setFollowUp(e,t,n){return this.patch(`/product/erix/crm/leads/${e}`,{nextFollowUpAt:t,nextFollowUpNote:t&&n!=null?n:null})}async move(e,t){return this.patch(`/product/erix/crm/leads/${e}/move`,{stageId:t})}async convert(e,t,n){return this.post(`/product/erix/crm/leads/${e}/convert`,{outcome:t,reason:n})}async tags(e,t){return this.patch(`/product/erix/crm/leads/${e}/tags`,t)}async recalculateScore(e){return this.post(`/product/erix/crm/leads/${e}/score`,{})}async updateMetadata(e,t){return this.patch(`/product/erix/crm/leads/${e}/metadata`,t)}async fields(){return this.get("/product/erix/crm/fields")}async notes(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async activities(e,t){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:t})}async createNote(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async updateNote(e,t,n){return this.patch(`/product/erix/crm/notes/${t}`,n)}async deleteNote(e,t){return this.deleteRequest(`/product/erix/crm/notes/${t}`)}async delete(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async export(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/export`)}async erase(e){return this.post(`/product/erix/crm/leads/${encodeURIComponent(e)}/erase`,{confirm:"ERASE"})}async bulkArchive(e){return this.patch("/product/erix/crm/leads/bulk-archive",{ids:e})}async bulkDelete(e){return this.deleteRequest("/product/erix/crm/leads",{data:{ids:e}})}async archive(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async profile(e){return this.get(`/product/erix/crm/leads/${e}/profile`)}async invoices(e){return this.get(`/product/erix/crm/leads/${e}/invoices`)}async projects(e){return this.get(`/product/erix/crm/leads/${e}/projects`)}async conversations(e){return this.get(`/product/erix/crm/leads/${e}/conversations`)}async meetings(e){return this.get(`/product/erix/crm/leads/${e}/meetings`)}async flowRuns(e){return this.get(`/product/erix/crm/leads/${e}/flow-runs`)}async merge(e,t){return this.post("/product/erix/crm/leads/merge",{primaryId:e,secondaryId:t})}};var N=class extends s{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var _=class extends s{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){var a,o;let t=await this.retrieve(e),n=Array.isArray((a=t.data)==null?void 0:a.stages)?t.data.stages:[];return{name:`Pipeline: ${((o=t.data)==null?void 0:o.name)||e}`,fields:n.map(c=>({key:c._id,label:c.name,type:"string",required:!0,options:[{label:c.name,value:c._id}],group:"Stages",uiHints:{color:c.color||"#cbd5e1",probability:c.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/product/erix/crm/pipelines",e)}async retrieve(e){return this.get(`/product/erix/crm/pipelines/${e}`)}async update(e,t){return this.patch(`/product/erix/crm/pipelines/${e}`,t)}async setDefault(e){return this.patch(`/product/erix/crm/pipelines/${e}/default`,{})}async duplicate(e,t){return this.post(`/product/erix/crm/pipelines/${e}/duplicate`,{name:t})}async archive(e){return this.patch(`/product/erix/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/product/erix/crm/pipelines/${e}`)}async checkInUse(e){return this.get(`/product/erix/crm/pipelines/${e}/in-use`)}async board(e){return this.get(`/product/erix/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/product/erix/crm/pipelines/${e}/forecast`)}async addStage(e,t){return this.post(`/product/erix/crm/pipelines/${e}/stages`,t)}async reorderStages(e,t){return this.patch(`/product/erix/crm/pipelines/${e}/stages/reorder`,{order:t})}async updateStage(e,t){return this.patch(`/product/erix/crm/stages/${e}`,t)}async deleteStage(e,t){return this.deleteRequest(`/product/erix/crm/stages/${e}`,{data:t?{moveLeadsToStageId:t}:void 0})}};var B=class extends s{async getConfig(){return this.get("/product/erix/crm/scoring")}async updateConfig(e){return this.patch("/product/erix/crm/scoring",e)}async recalculate(e){return this.post(`/product/erix/crm/scoring/${e}/recalculate`,{})}async preview(e){return this.get(`/product/erix/crm/scoring/preview/${e}`)}};var V=class extends s{async list(e){return this.get("/platform/inbox/conversations",{params:e})}async create(e){var t;return this.post("/platform/inbox/conversations",{address:e.phone,channel:(t=e.channel)!=null?t:"whatsapp",userName:e.name})}async linkLead(e,t){return this.patch(`/platform/inbox/conversations/${e}/lead`,{leadId:t})}async retrieve(e){return this.get(`/platform/inbox/conversations/${e}`)}async messages(e,t){return this.get(`/platform/inbox/conversations/${e}/messages`,{params:t})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async delete(e){return this.deleteRequest(`/platform/inbox/conversations/${e}`)}async bulkDelete(e){return this.post("/platform/inbox/conversations/bulk-delete",{ids:e})}};var b=class extends s{async send(e){if(e.conversationId)return this.post(`/platform/inbox/conversations/${e.conversationId}/messages`,{text:e.text,media:e.media});if(!e.to)throw new Error("send: conversationId or to is required");if(e.media)throw new Error("send: media goes to an inbox thread (conversationId)");return this.post("/infra/connect/send/whatsapp",{phone:e.to,text:e.text})}async sendTemplate(e){return this.post("/infra/connect/send/whatsapp",{phone:e.to,templateName:e.templateName,language:e.language,variables:e.variables})}async star(e,t){return this.post(`/platform/inbox/messages/${e}/star`,{starred:t})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async upload(e,t={}){var f,m,w;let n=(m=(f=t.fileName)!=null?f:e.name)!=null?m:"file",a=e.type||"application/octet-stream",o=await this.post("/infra/storage/files/upload-url",{folder:(w=t.folder)!=null?w:"inbox",filename:n,contentType:a}),{uploadUrl:c,key:u}=o.data,p=await fetch(c,{method:"PUT",headers:{"Content-Type":a},body:e});if(!p.ok)throw new Error(`upload failed (${p.status})`);return await this.post("/infra/storage/files/confirm-upload",{key:u,sizeBytes:e.size}),{key:u,mimeType:a,fileName:n}}};var F=class extends s{async getProduct(e){return this.get(`/product/erix/commerce/checkout/products/${e}`)}async createSession(e){return this.post("/product/erix/commerce/checkout/session",e)}async applyCoupon(e){return this.post("/product/erix/commerce/checkout/coupon",e)}async verify(e){return this.post("/product/erix/commerce/checkout/verify",e)}async createOrder(e){return this.post("/product/erix/commerce/checkout/order",e)}};var K=class extends s{async trigger(e){return this.post("/product/erix/events/trigger",e)}async listCustomEvents(){return this.get("/product/flow/config/triggers")}async createCustomEvent(e){return this.post("/product/flow/config/triggers",e)}async deleteCustomEvent(e){return this.deleteRequest(`/product/flow/config/triggers/${e}`)}};var j=class extends s{async list(e){return this.get("/product/erix/commerce/invoices",{params:e})}async getInvoice(e){return this.get(`/product/erix/commerce/invoices/${e}`)}async create(e){return this.post("/product/erix/commerce/invoices",e)}async update(e,t){return this.patch(`/product/erix/commerce/invoices/${e}`,t)}async void(e){return this.post(`/product/erix/commerce/invoices/${e}/void`,{})}async sendViaWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${e}/send-whatsapp`,{})}async getSettings(){return this.get("/product/erix/commerce/settings")}async updateSettings(e){return this.put("/product/erix/commerce/settings",e)}async paymentLink(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payment-link`,{})}async recordPayment(e,t){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payments`,t)}async sendWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-whatsapp`,{})}async sendEmail(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-email`,{})}};var W=class extends s{async workflowPacks(){return this.get("/product/erix/crm/niche/workflow-packs")}async workflowPackDetail(e){return this.get(`/product/erix/crm/niche/workflow-packs/${e}`)}async installWorkflowPack(e){return this.post(`/product/erix/crm/niche/workflow-packs/${e}/install`)}async templateSuggestions(){return this.get("/product/erix/crm/niche/template-suggestions")}};var H=class extends s{async list(e){return this.get(`/product/erix/commerce/projects/${e}/documents`)}async upload(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents`,t)}async toggleSignature(e,t,n){return this.patch(`/product/erix/commerce/projects/${e}/documents/${t}/signature`,{required:n})}async addSigner(e,t,n){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/signers`,n)}async decline(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/decline`,{})}async stampSign(e,t,n){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/stamp-sign`,n)}};var z=class extends s{async providers(){return this.get("/infra/connect/providers")}async list(){return this.get("/infra/connect/connections")}async get_(e){return this.get(`/infra/connect/connections/${e}`)}async connect(e,t){return this.post(`/infra/connect/connections/${e}/connect`,t)}async configure(e,t){return this.put(`/infra/connect/connections/${e}/configure`,t)}async configureWebchat(e){return this.configure("webchat",{method:"domain",config:e})}async webchatSettings(){return this.get("/infra/connect/connections/webchat/settings")}async removeWebchatDomain(e){return this.deleteRequest(`/infra/connect/connections/webchat/domains/${encodeURIComponent(e)}`)}async disconnect(e){return this.post(`/infra/connect/connections/${e}/disconnect`,{})}async reveal(e){return this.post(`/infra/connect/connections/${e}/reveal`,{})}async test(e){return this.post(`/infra/connect/connections/${e}/test`,{})}async setAccess(e,t){return this.put(`/infra/connect/connections/${e}/access`,t)}async googleConnectUrl(){return this.post("/infra/connect/google/connect-url",{})}async createPaymentLink(e){return this.post("/infra/connect/connections/payments/payment-link",e)}};var G=class extends s{async sendTest(e){return this.post("/infra/connect/email/test",{to:e})}async listTemplates(e){return this.get("/infra/connect/email/templates",{params:e})}async getTemplate(e){return this.get(`/infra/connect/email/templates/${e}`)}async createTemplate(e){return this.post("/infra/connect/email/templates",e)}async updateTemplate(e,t){return this.put(`/infra/connect/email/templates/${e}`,t)}async deleteTemplate(e,t=!1){return this.deleteRequest(`/infra/connect/email/templates/${e}`,{params:{force:t}})}async previewTemplate(e,t){return this.post(`/infra/connect/email/templates/${e}/preview`,t)}};var Q=class extends s{async create(e){return this.post("/infra/connect/meet",e)}async list(e){return this.get("/infra/connect/meet",{params:e})}async retrieve(e){return this.get(`/infra/connect/meet/${e}`)}async update(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async reschedule(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async delete(e){return this.update(e,{status:"cancelled"})}};var Y=class extends s{async getConfig(){return this.get("/infra/connect/email/config")}async initDomainVerification(e){return this.post("/infra/connect/email/config/ses/domain",{domain:e})}async saveEmailConfig(e){return this.post("/infra/connect/email/config/ses/config",e)}async checkSesVerification(){return this.get("/infra/connect/email/config/ses/verify")}async removeSesIdentity(){return this.deleteRequest("/infra/connect/email/config/ses/domain")}async sendTest(e){return this.post("/infra/connect/email/config/test",{toEmail:e})}async saveAdvancedConfig(e){return this.post("/infra/connect/email/config/advanced",e)}async getHealth(){return this.get("/infra/connect/email/config/health")}async fixDmarc(){return this.post("/infra/connect/email/config/ses/fix-dmarc",{})}async listProviders(){return this.get("/infra/connect/email/config/providers")}};var J=class extends s{async list(e){return this.get("/infra/connect/whatsapp/templates",{params:e})}async sync(){return this.post("/infra/connect/whatsapp/templates/sync",{})}async retrieve(e){return this.get(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}`)}async create(e){return this.post("/infra/connect/whatsapp/templates",e)}async update(e,t){return this.put(`/infra/connect/whatsapp/templates/${e}`,t)}async deleteTemplate(e,t){return this.deleteRequest(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}${t?"?force=true":""}`)}async mappingConfig(){return this.get("/infra/connect/whatsapp/templates/mapping/config")}async mappingSources(){return this.get("/infra/connect/whatsapp/templates/mapping/sources")}async collections(){return this.get("/infra/connect/whatsapp/templates/collections")}async collectionFields(e){return this.get(`/infra/connect/whatsapp/templates/collections/${encodeURIComponent(e)}/fields`)}async updateMapping(e,t){return this.put(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/mapping`,t)}async validate(e,t){let n=`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/validate`;return t?this.post(n,t):this.get(n)}async preview(e,t,n,a){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:t,mappings:n,onEmptyVariable:a})}async getVariableManifest(e){var o,c;let t=await this.retrieve(e),n=Array.isArray((o=t.data)==null?void 0:o.components)?t.data.components:[],a=[];for(let u of n)if(u.text){let p=u.text.match(/{{(\d+)}}/g);if(p)for(let f of p){let m=f.replace(/{{|}}/g,"");a.push({key:`var_${m}`,label:`${u.type} Var {{${m}}}`,type:"string",required:!0,group:u.type,description:`Variable placeholder in template ${u.type}`})}}return{name:`Template variables: ${((c=t.data)==null?void 0:c.name)||e}`,fields:a,uiHints:{icon:"Variables",primaryColor:"#059669"}}}};import He from"axios";var X=class extends s{async getUsage(){return this.get("/infra/storage/files/usage")}async createFolder(e){return this.post("/infra/storage/files/folders",{name:e})}async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async aiDescribe(e){return this.post("/infra/storage/files/ai/describe",{key:e})}async upload(e,t){let n=await this.post("/infra/storage/files/upload-url",t),{uploadUrl:a,key:o}=n.data;await He.put(a,e,{headers:{"Content-Type":t.contentType}});let c=e.size||e.byteLength||0;return this.post("/infra/storage/files/confirm-upload",{key:o,sizeBytes:c})}};var Z=class extends s{async create(e){return this.post("/infra/storage/files/folders",{name:e})}},ee=class extends s{async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async getUploadUrl(e){return this.post("/infra/storage/files/upload-url",e)}async confirmUpload(e){return this.post("/infra/storage/files/confirm-upload",e)}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}};var te=class extends s{async system(){return(await this.get("/health")).data}};var ne=class extends s{async listAlerts(e){return this.get("/platform/users/notifications",{params:e})}async dismissAlert(e){return this.patch(`/platform/users/notifications/${e}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/platform/users/notifications/dismiss-all")}};var R=class extends s{async global(e){return this.post("/platform/tenants/onboarding/global",e)}async complete(e){return this.post("/platform/tenants/onboarding/complete",e)}};var k=class extends s{async get(e){return super.get(`/platform/tenants/persona/${e}`)}async reinforce(e){return this.post(`/platform/tenants/persona/${e.productId}/reinforce`,e)}async confidence(e){return super.get(`/platform/tenants/persona/${e}/confidence`,{params:{productId:e}})}async timeline(e,t){var a;let n=await super.get(`/platform/tenants/persona/${e}/timeline`,{params:t});return(a=n==null?void 0:n.data)!=null?a:{entries:[],hasMore:!1}}async followups(e){var n,a;let t=await super.get(`/platform/tenants/persona/${e}/followups`);return(a=(n=t==null?void 0:t.data)==null?void 0:n.entries)!=null?a:[]}};var be=class extends s{async chatSync(e){return this.post("/platform/ai/copilot/chat/sync",e)}async confirm(e){return this.post("/platform/ai/copilot/confirm",e)}async listSessions(){return this.get("/platform/ai/copilot/sessions")}async getSession(e){return this.get(`/platform/ai/copilot/sessions/${e}`)}async deleteSession(e){return this.deleteRequest(`/platform/ai/copilot/sessions/${e}`)}chatStreamUrl(){return"/platform/ai/copilot/chat"}},re=class{constructor(e){i(this,"copilot");this.copilot=new be(e)}};var ze=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain","text/markdown","text/csv","text/html","image/png","image/jpeg","image/webp"],P=class extends s{async list(){return this.get("/platform/knowledge/sources")}async addText(e){return this.post("/platform/knowledge/sources",l({kind:"text"},e))}async addUrl(e){return this.post("/platform/knowledge/sources",l({kind:"url"},e))}async addWebsite(e){return this.post("/platform/knowledge/sources",{type:"website",url:e.url})}async addFile(e,t={}){var a,o;let n=await new b(this.client).upload(e,{folder:"knowledge"});return this.post("/platform/knowledge/sources",{kind:"file",key:n.key,mimeType:n.mimeType,title:(o=(a=t.title)!=null?a:n.fileName)!=null?o:"Document"})}async remove(e){return this.deleteRequest(`/platform/knowledge/sources/${e}`)}async reindex(e){return this.post(`/platform/knowledge/sources/${e}/reindex`,{})}async search(e,t){return this.post("/platform/knowledge/search",l({query:e},t?{limit:t}:{}))}};var A=class extends s{async settings(){return this.get("/product/erix/ai/settings")}async updateSettings(e){return this.patch("/product/erix/ai/settings",e)}async outcomes(e={}){return this.get("/product/erix/ai/outcomes",{params:e})}async reviews(e){return this.get(`/product/erix/ai/reviews${e?`?status=${e}`:""}`)}async review(e,t,n){return this.post(`/product/erix/ai/reviews/${encodeURIComponent(e)}`,l({verdict:t},n?{note:n}:{}))}async suggestion(e){return this.get(`/product/erix/ai/suggestion/${e}`)}async approveAction(e){return this.post(`/product/erix/ai/suggestion/${e}/approve-action`,{})}async markSent(e,t,n){return this.post(`/product/erix/ai/suggestion/${e}/send`,{text:t,confidence:n})}async dismiss(e){return this.post(`/product/erix/ai/suggestion/${e}/dismiss`,{})}async approvals(){return this.get("/product/flow/approvals")}async agents(){return this.get("/product/flow/agents")}async updateAgent(e,t){return this.patch(`/product/flow/agents/${encodeURIComponent(e)}`,t)}async decideRun(e,t,n){return this.post(`/product/flow/runs/${encodeURIComponent(e)}/approve`,l({decision:t},n&&{nodeId:n}))}};var se=class extends s{async register(e){return this.post("/platform/auth/register",e)}async login(e){return this.post("/platform/auth/login",e)}async logout(e){return this.post("/platform/auth/logout",e)}async logoutAll(e){return this.post("/platform/auth/logout-all",e)}async validateSession(e){return this.post("/platform/auth/session/validate",e)}async listSessions(){return this.get("/platform/auth/sessions")}async revokeSession(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}async requestPasswordOtp(e){return this.post("/platform/auth/password/request-otp",e)}async setPassword(e){return this.post("/platform/auth/password/set",e)}async changePassword(e){return this.post("/platform/auth/password/change",e)}async forgotPassword(e){return this.post("/platform/auth/forgot",e)}async resetPassword(e){return this.post("/platform/auth/reset",e)}async linkOAuth(e){return this.post("/platform/auth/oauth-link",e)}async getInvitation(e){return this.get(`/platform/auth/invitations/${e}`)}async acceptInvitation(e,t){return this.post(`/platform/auth/invitations/${e}/accept`,t)}};var xe=class extends s{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},we=class extends s{async upgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/upgrade",e)}async downgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/downgrade",e)}async cancel(e){return this.post("/platform/billing/subscriptions/subscriptions/cancel",e)}async purchaseAddon(e){return this.post("/platform/billing/subscriptions/addons/purchase",e)}async cancelAddon(e){return this.post("/platform/billing/subscriptions/addons/cancel",e)}},Re=class extends s{async listPublic(){return this.get("/platform/billing/plans/public")}},ke=class extends s{async plans(){return this.get("/platform/billing/checkout/plans")}async subscribe(e){return this.post("/platform/billing/checkout/subscribe",e)}async verify(e){return this.post("/platform/billing/checkout/verify",e)}async cancel(e){return this.post("/platform/billing/checkout/cancel",e)}async status(){return this.get("/platform/billing/checkout/status")}async syncPlan(e){return this.post("/platform/billing/checkout/sync-plan",e)}},Pe=class extends s{async transactions(){return this.get("/platform/billing/user/transactions")}async subscription(){return this.get("/platform/billing/user/subscription")}async raiseDispute(e){return this.post("/platform/billing/user/dispute",e)}async disputes(){return this.get("/platform/billing/user/disputes")}},Ae=class extends s{async balance(){return this.get("/platform/billing/credits/balance")}async transactions(){return this.get("/platform/billing/credits/transactions")}async packs(){return this.get("/platform/billing/credits/packs")}async topupOrder(e){return this.post("/platform/billing/credits/topup/order",e)}async verifyTopup(e){return this.post("/platform/billing/credits/topup/verify",e)}async setAutoTopup(e){return this.patch("/platform/billing/credits/auto-topup",e)}async setSpendCap(e){return this.patch("/platform/billing/credits/spend-cap",e)}},ie=class{constructor(e){i(this,"entitlements");i(this,"subscriptions");i(this,"plans");i(this,"checkout");i(this,"user");i(this,"credits");this.entitlements=new xe(e),this.subscriptions=new we(e),this.plans=new Re(e),this.checkout=new ke(e),this.user=new Pe(e),this.credits=new Ae(e)}};var ae=class extends s{async categories(){return this.get("/platform/support/categories")}async listTickets(e){return this.get("/platform/support/tickets",{params:e})}async createTicket(e){return this.post("/platform/support/tickets",e)}async getTicket(e){return this.get(`/platform/support/tickets/${e}`)}async reply(e,t){return this.post(`/platform/support/tickets/${e}/reply`,t)}async close(e){return this.patch(`/platform/support/tickets/${e}/close`,{})}};var oe=class extends s{async get(){return super.get("/platform/users/me")}async update(e){return this.patch("/platform/users/me",e)}async updateOrganization(e){return this.patch("/platform/users/me/organization",e)}async toggleModules(e){return this.post("/platform/users/me/modules",e)}async workspaces(){return super.get("/platform/users/me/workspaces")}async setActiveOrg(e){return this.post("/platform/users/me/active-org",e)}async dismissWorkspaceSetup(){return this.post("/platform/users/me/workspace/dismiss-setup",{})}},ce=class extends s{async list(){return this.get("/platform/users/members")}async invite(e){return this.post("/platform/users/members/invite",e)}async updateRole(e,t){return this.patch(`/platform/users/members/${e}`,{role:t})}async remove(e){return this.deleteRequest(`/platform/users/members/${e}`)}},pe=class extends s{async list(){return this.get("/platform/auth/sessions")}async revoke(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}};var le=class{constructor(e){i(this,"messages");i(this,"conversations");this.messages=new b(e),this.conversations=new V(e)}},ue=class{constructor(e){i(this,"leads");i(this,"pipelines");i(this,"activities");i(this,"analytics");i(this,"scoring");i(this,"payments");i(this,"chat");i(this,"events");i(this,"invoices");i(this,"checkout");i(this,"projects");i(this,"niche");i(this,"documents");i(this,"invoiceExport");i(this,"ai");this.leads=new U(e),this.pipelines=new _(e),this.activities=new M(e),this.analytics=new D(e),this.scoring=new B(e),this.payments=new N(e),this.chat=new le(e),this.events=new K(e),this.invoices=new j(e),this.checkout=new F(e),this.projects=new H(e),this.niche=new W(e),this.documents=new L(e),this.invoiceExport=new q(e),this.ai=new A(e)}},v=class{constructor(e){i(this,"erix");this.erix=new ue(e)}},ge=class{constructor(e){i(this,"config");i(this,"templates");this.config=new Y(e),this.templates=new G(e)}},de=class{constructor(e){i(this,"templates");this.templates=new J(e)}},me=class{constructor(e){i(this,"email");i(this,"whatsapp");i(this,"meet");i(this,"connections");this.email=new ge(e),this.whatsapp=new de(e),this.meet=new Q(e),this.connections=new z(e)}},ye=class{constructor(e){i(this,"files");i(this,"folders");i(this,"media");this.files=new ee(e),this.folders=new Z(e),this.media=new X(e)}},I=class{constructor(e){i(this,"connect");i(this,"storage");this.connect=new me(e),this.storage=new ye(e)}},he=class{constructor(e){i(this,"onboarding");i(this,"persona");this.onboarding=new R(e),this.persona=new k(e)}},fe=class{constructor(e){i(this,"me");i(this,"members");i(this,"sessions");i(this,"notifications");this.me=new oe(e),this.members=new ce(e),this.sessions=new pe(e),this.notifications=new ne(e)}},S=class{constructor(e){i(this,"auth");i(this,"users");i(this,"tenants");i(this,"billing");i(this,"support");i(this,"ai");i(this,"knowledge");i(this,"health");this.auth=new se(e),this.users=new fe(e),this.tenants=new he(e),this.billing=new ie(e),this.support=new ae(e),this.ai=new re(e),this.knowledge=new P(e),this.health=new te(e)}};var h=class extends d{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},C=class{async constructEvent(e,t,n){if(!t)throw new h("No webhook signature provided");let a=Array.isArray(t)?t[0]:t;a.startsWith("sha256=")&&(a=a.slice(7));try{let o=await import("crypto"),u=o.createHmac("sha256",n).update(e).digest("hex");if(!o.timingSafeEqual(Buffer.from(u),Buffer.from(a)))throw new h("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(o){throw o instanceof h?o:new h(`Webhook payload parsing failed: ${o.message}`)}}};var ve=typeof process!="undefined"&&"3.2.0"||"3.1.1";var je,Ie=(je=Ke.default)!=null?je:Ke,x=class{constructor(e){i(this,"client");i(this,"socket",null);i(this,"startSocket",null);i(this,"socketPromise",null);i(this,"socketQueue",[]);i(this,"clientCode");i(this,"apiVersion");i(this,"platform");i(this,"product");i(this,"infra");i(this,"webhooks");i(this,"lastSeq");i(this,"closed",!1);var m,w,Se,Ce,$e,Ee,Oe,Me;let t=e.proxy;if(!e.apiKey&&!t)throw new T("API Key is required");this.clientCode=(m=e.clientCode)==null?void 0:m.toUpperCase(),this.apiVersion=(w=e.version)!=null?w:"v1";let n=(Se=e.baseUrl)!=null?Se:_e,a=Be(this.apiVersion,(Ce=t==null?void 0:t.url)!=null?Ce:n),o=e.socketUrl||n,c=typeof window!="undefined"&&typeof window.document!="undefined",u=c?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",p=c?(($e=globalThis.navigator)==null?void 0:$e.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown",f=y(l({},t?{}:{"x-api-key":e.apiKey,"x-client-code":((Ee=e.clientCode)==null?void 0:Ee.toUpperCase())||""}),{"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:ve,runtime:u,os:p})});if(this.client=Qe.create({baseURL:a,headers:f,timeout:(Oe=e.timeout)!=null?Oe:3e4}),Ie(this.client,{retries:3,retryDelay:Ie.exponentialDelay,retryCondition:g=>{var $;return Ie.isNetworkOrIdempotentRequestError(g)||(($=g.response)==null?void 0:$.status)===429},onRetry:(g,$,De)=>{var Le,qe;typeof process!="undefined"&&((Le=process.env)==null?void 0:Le.NODE_ENV)==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${g}/3): ${(qe=De.method)==null?void 0:qe.toUpperCase()} ${De.url}. Reason: ${$.message}`)}}),this.platform=new S(this.client),this.product=new v(this.client),this.infra=new I(this.client),this.webhooks=new C,t){if(t.ticket){let g=t.ticket;this.startSocket=()=>this.initSocket(o,async()=>({ticket:await g()}))}}else{let g={apiKey:e.apiKey,clientCode:((Me=e.clientCode)==null?void 0:Me.toUpperCase())||""};this.startSocket=()=>this.initSocket(o,async()=>g,{"x-api-key":g.apiKey,"x-client-code":g.clientCode})}if(c){let g={version:ve,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=g}}initSocket(e,t,n){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:a})=>{this.socket=a(e,{auth:o=>{t().then(c=>o(y(l({},c),{lastSeq:this.lastSeq})),()=>o({lastSeq:this.lastSeq}))},extraHeaders:n}),this.setupSocket();for(let{type:o,args:c}of this.socketQueue)o==="joinRoom"?this.socket.emit("join-room",c[0]):o==="leaveRoom"?this.socket.emit("leave-room",c[0]):o==="on"?this.socket.on(c[0],c[1]):o==="off"?this.socket.off(c[0],c[1]):o==="disconnect"&&this.socket.disconnect();this.socketQueue=[]}),this.socketPromise)}joinRoom(e){var t;this.closed||(t=this.startSocket)==null||t.call(this),this.socket?this.socket.emit("join-room",e):this.socketQueue.push({type:"joinRoom",args:[e]})}leaveRoom(e){this.socket?this.socket.emit("leave-room",e):this.socketQueue.push({type:"leaveRoom",args:[e]})}setupSocket(){this.socket&&(this.socket.on("connect_error",()=>{var e;(e=this.socket)!=null&&e.active||setTimeout(()=>{var t;this.closed||(t=this.socket)==null||t.connect()},5e3)}),this.socket.onAny((...e)=>{var n,a;let t=(n=e.at(-1))==null?void 0:n.seq;typeof t=="number"&&t>((a=this.lastSeq)!=null?a:0)&&(this.lastSeq=t)}))}on(e,t){var n;return this.closed||(n=this.startSocket)==null||n.call(this),this.socket?this.socket.on(e,t):this.socketQueue.push({type:"on",args:[e,t]}),this}disconnect(){this.closed=!0,this.socket?this.socket.disconnect():this.socketPromise&&this.socketQueue.push({type:"disconnect",args:[]})}off(e,t){return this.socket?this.socket.off(e,t):this.socketQueue.push({type:"off",args:[e,t]}),this}async request(e,t,n,a){var o,c,u;try{return(await this.client.request({method:e,url:t,data:n,params:a})).data}catch(p){throw p.response?new d(((o=p.response.data)==null?void 0:o.message)||((c=p.response.data)==null?void 0:c.error)||"Raw Execution Failed",p.response.status,(u=p.response.data)==null?void 0:u.code):new d(p.message||"Network Error")}}};var br={401:T,403:Ve,429:E};function xr(r){throw O(r)}function wr(r,e){return r instanceof e}function Rr(r){return r instanceof T?{message:r.message,status:r.status,code:r.code,type:"AuthenticationError"}:r instanceof E?{message:r.message,status:r.status,code:r.code,type:"RateLimitError"}:r instanceof d?{message:r.message,status:r.status,code:r.code,type:"APIError"}:{message:r.message||"Unknown error",type:"UnknownError"}}var We={[T.name]:{shouldRetry:!1,reason:"Authentication errors require fixing credentials, not retrying"},[E.name]:{shouldRetry:!0,maxRetries:3,baseDelay:1e3,backoffMultiplier:2,reason:"Rate limit errors can be retried with exponential backoff"},[d.name]:{shouldRetry:!0,maxRetries:2,baseDelay:500,backoffMultiplier:1.5,reason:"Generic API errors may be transient and worth retrying"}};function kr(r){let e=r.constructor.name;return We[e]||We[d.name]}var vr=x;export{d as APIError,s as APIResource,A as AiAgent,T as AuthenticationError,me as ConnectInfra,x as ECODrIx,x as ECODrIxAPI,We as ERROR_RETRY_CONFIG,Je as EcodrixError,ge as EmailConnect,le as ErixChat,ue as ErixProduct,br as HTTP_STATUS_ERROR_MAP,I as InfraDomain,ze as KNOWLEDGE_FILE_TYPES,P as Knowledge,Fe as LEAD_STATUS_VALUES,R as Onboarding,Ve as PermissionError,k as Persona,S as PlatformDomain,he as PlatformTenants,fe as PlatformUsers,v as ProductDomain,E as RateLimitError,ye as StorageInfra,h as WebhookSignatureError,C as Webhooks,de as WhatsAppConnect,vr as default,Rr as getErrorDetails,kr as getRetryConfig,xr as handleAPIError,wr as isAPIError,O as toAPIError};
|