@ecodrix/erix-api 3.1.2 → 3.3.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.
@@ -0,0 +1 @@
1
+ "use strict";var v=Object.create;var E=Object.defineProperty,P=Object.defineProperties,D=Object.getOwnPropertyDescriptor,L=Object.getOwnPropertyDescriptors,W=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols,C=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable;var h=(s,t,e)=>t in s?E(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,m=(s,t)=>{for(var e in t||(t={}))T.call(t,e)&&h(s,e,t[e]);if(R)for(var e of R(t))y.call(t,e)&&h(s,e,t[e]);return s},V=(s,t)=>P(s,L(t));var S=(s,t)=>{var e={};for(var o in s)T.call(s,o)&&t.indexOf(o)<0&&(e[o]=s[o]);if(s!=null&&R)for(var o of R(s))t.indexOf(o)<0&&y.call(s,o)&&(e[o]=s[o]);return e};var U=(s,t)=>{for(var e in t)E(s,e,{get:t[e],enumerable:!0})},w=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of W(t))!T.call(s,r)&&r!==e&&E(s,r,{get:()=>t[r],enumerable:!(o=D(t,r))||o.enumerable});return s};var M=(s,t,e)=>(e=s!=null?v(C(s)):{},w(t||!s||!s.__esModule?E(e,"default",{value:s,enumerable:!0}):e,s)),k=s=>w(E({},"__esModule",{value:!0}),s);var p=(s,t,e)=>h(s,typeof t!="symbol"?t+"":t,e);var q={};U(q,{WebchatVisitor:()=>O,WebchatVisitorError:()=>l});module.exports=k(q);var f="https://api.ecodrix.com";function N(s="v1",t=f){return`${t.replace(/\/+$/,"")}/${s}/api`}var I=class extends Error{constructor(t){super(t),this.name="EcodrixError"}},d=class extends I{constructor(e,o,r){super(e);p(this,"status");p(this,"code");p(this,"issues");p(this,"field");this.name="APIError",this.status=o,this.code=r}};var l=class extends d{constructor(e,o,r,n){super(e,r,o);p(this,"field");this.name="WebchatVisitorError",this.field=n}},F=3e4,B=6e4,H=new Set(["RATE_LIMITED","INTERNAL_ERROR"]),K={400:"VALIDATION_ERROR",403:"ORIGIN_NOT_ALLOWED",404:"NOT_FOUND",429:"RATE_LIMITED"},O=class{constructor(t){p(this,"options",t);p(this,"host");p(this,"base");p(this,"socket",null);p(this,"opening",null);p(this,"retry");var e;this.host=((e=t.apiUrl)!=null?e:f).replace(/\/+$/,""),this.base=`${N("v1",this.host)}/infra/connect/webhooks/webchat/${encodeURIComponent(t.clientCode)}`}send(t,e={}){let{sessionId:o,parent:r}=this.options,i=e,{page:n}=i,u=S(i,["page"]);return this.call("/message",m(m({sessionId:o,text:t,parent:r},u),n&&{page:V(m({},n),{path:n.path.split(/[?#]/)[0]})}))}messages(){let{sessionId:t,parent:e}=this.options;return this.call(`/messages?${new URLSearchParams({sessionId:t,parent:e})}`)}receipts(t,e){let{sessionId:o,parent:r}=this.options;return this.call("/receipts",{sessionId:o,parent:r,ids:t,state:e})}contact(t){let{sessionId:e,parent:o}=this.options;return this.call("/contact",m({sessionId:e,parent:o},t))}connect(t){if(this.opening)return this.opening;let{clientCode:e,sessionId:o,parent:r}=this.options,n=import("socket.io-client").then(({io:u})=>{if(this.opening!==n)return;let i=u(`${this.host}/visitor`,{auth:{clientCode:e,sessionId:o,parent:r}});this.socket=i;let g=!1;i.on("connect",()=>{var a;g&&((a=t.onReconnect)==null||a.call(t)),g=!1}),i.on("disconnect",()=>{g=!0}),i.on("connect_error",a=>{var A,b,_;g=!0;let c=(b=(A=a.data)==null?void 0:A.code)!=null?b:"NETWORK_ERROR";(_=t.onError)==null||_.call(t,new l(a.message,c)),!i.active&&H.has(c)&&(clearTimeout(this.retry),this.retry=setTimeout(()=>{this.socket===i&&i.connect()},B))}),i.on("webchat.message",a=>{var c;return(c=t.onMessage)==null?void 0:c.call(t,a)}),i.on("webchat.typing",a=>{var c;return(c=t.onTyping)==null?void 0:c.call(t,a)}),i.on("webchat.status",a=>{var c;return(c=t.onStatus)==null?void 0:c.call(t,a)})},u=>{var i;this.opening===n&&(this.opening=null,(i=t.onError)==null||i.call(t,new l((u==null?void 0:u.message)||"Network error","NETWORK_ERROR")))});return this.opening=n,n}disconnect(){var t;clearTimeout(this.retry),(t=this.socket)==null||t.disconnect(),this.socket=null,this.opening=null}async call(t,e){var g,a;let o=new AbortController,r=setTimeout(()=>o.abort(),F),n,u;try{n=await fetch(`${this.base}${t}`,{method:e?"POST":"GET",headers:e?{"content-type":"application/json"}:void 0,body:e?JSON.stringify(e):void 0,signal:o.signal}),u=await n.text()}catch(c){throw new l((c==null?void 0:c.message)||"Network error","NETWORK_ERROR")}finally{clearTimeout(r)}let i=null;try{i=JSON.parse(u)}catch(c){}if(n.ok&&(i!=null&&i.success))return i;throw new l((i==null?void 0:i.message)||(i==null?void 0:i.error)||`Request failed (${n.status})`,(a=(g=i==null?void 0:i.code)!=null?g:K[n.status])!=null?a:"INTERNAL_ERROR",n.status,i==null?void 0:i.field)}};0&&(module.exports={WebchatVisitor,WebchatVisitorError});
@@ -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,171 @@
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
+ * Ticks, as on WhatsApp. The visitor's own message: `delivered` once stored,
22
+ * `read` once the team opened the chat. A reply: `sent` until `receipts()`
23
+ * reports it `delivered` / `read`. Absent from an older API.
24
+ */
25
+ status?: VisitorMessageStatus;
26
+ }
27
+ /** `sent` ✓ · `delivered` ✓✓ · `read` ✓✓ (seen). */
28
+ type VisitorMessageStatus = "sent" | "delivered" | "read";
29
+ /** The live `webchat.status` event: these messages of the visitor's moved on (e.g. the team read them). */
30
+ interface VisitorStatus {
31
+ ids: string[];
32
+ status: "delivered" | "read";
33
+ }
34
+ /**
35
+ * The live `webchat.typing` event. `waiting: true` (with `on: false`) means
36
+ * the AI left the reply to the team: show "The team will reply here".
37
+ */
38
+ interface VisitorTyping {
39
+ on: boolean;
40
+ waiting?: boolean;
41
+ }
42
+ /** The website chat widget's settings (`service_config.webchat`). */
43
+ interface WebchatSettings {
44
+ /**
45
+ * Sites the widget may run on. Read-only here: add one with `domain`,
46
+ * remove one with `connections.removeWebchatDomain`.
47
+ */
48
+ allowedDomains: string[];
49
+ /** Up to 60 characters. */
50
+ name?: string;
51
+ /** Up to 200 characters. */
52
+ greeting?: string;
53
+ /** `#rrggbb`. */
54
+ color?: string;
55
+ /** Default `right`. */
56
+ position?: "left" | "right";
57
+ /** `https://` only. */
58
+ logoUrl?: string;
59
+ /** When the widget asks for name and phone/email. Default `when_needed`. */
60
+ detailsMode?: "before" | "when_needed" | "off";
61
+ /** Up to 80 characters, e.g. "We reply 10 am to 7 pm". */
62
+ hoursText?: string;
63
+ /** Show a team member's first name on their replies. Default true. */
64
+ showStaffNames?: boolean;
65
+ }
66
+ /**
67
+ * The website chat as its owner edits it (`connections.webchatSettings()`):
68
+ * the sites it may run on in plain text, the plan's cap on them, and the
69
+ * saved settings (a setting left at its default is absent).
70
+ */
71
+ interface WebchatOwnerSettings {
72
+ allowedDomains: string[];
73
+ /** How many sites the plan allows. */
74
+ maxDomains: number;
75
+ settings: Omit<WebchatSettings, "allowedDomains">;
76
+ }
77
+ /**
78
+ * A settings save: send only what changes; `null` clears a setting back to
79
+ * its default. `domain` adds a site to the allowed domains (plan-capped).
80
+ */
81
+ type WebchatSettingsPatch = {
82
+ [K in Exclude<keyof WebchatSettings, "allowedDomains">]?: WebchatSettings[K] | null;
83
+ } & {
84
+ /** A site to add to the allowed domains, e.g. `example.com`. */
85
+ domain?: string;
86
+ };
87
+
88
+ /**
89
+ * Typed error hierarchy for the @ecodrix/erix-api SDK.
90
+ *
91
+ * All errors thrown by the SDK extend `EcodrixError`, so a single
92
+ * `catch` block can handle them all, while still allowing granular
93
+ * differentiation between auth failures, rate limits, and generic API errors.
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * import { APIError, AuthenticationError, RateLimitError } from "@ecodrix/erix-api";
98
+ *
99
+ * try {
100
+ * await ecod.product.erix.leads.retrieve("invalid_id");
101
+ * } catch (err) {
102
+ * if (err instanceof AuthenticationError) {
103
+ * console.error("Invalid API key or client code.");
104
+ * } else if (err instanceof RateLimitError) {
105
+ * console.warn("Slow down — rate limit hit.");
106
+ * } else if (err instanceof APIError) {
107
+ * console.error(`API error ${err.status}: ${err.message}`);
108
+ * }
109
+ * }
110
+ * ```
111
+ */
112
+ /** Base class for all ECODrIx SDK errors. */
113
+ declare class EcodrixError extends Error {
114
+ constructor(message: string);
115
+ }
116
+ /** One value the server refused, from a `VALIDATION_ERROR`'s `issues`. */
117
+ interface APIErrorIssue {
118
+ /** Where in the request body, e.g. `["color"]`. */
119
+ path: (string | number)[];
120
+ message: string;
121
+ /** The check that failed, e.g. `"too_big"`. */
122
+ code?: string;
123
+ }
124
+ /**
125
+ * Represents an error returned by the ECODrIx API.
126
+ * Carries the HTTP `status` code and an optional `code` string.
127
+ */
128
+ declare class APIError extends EcodrixError {
129
+ /** HTTP status code returned by the API (e.g. 400, 404, 500). */
130
+ status?: number;
131
+ /** Machine-readable error code (e.g. `"NOT_FOUND"`, `"VALIDATION_ERROR"`). */
132
+ code?: string;
133
+ /** Each refused value, when the server lists them (`VALIDATION_ERROR`). */
134
+ issues?: APIErrorIssue[];
135
+ /** The one field the server names, when it sends `field`. */
136
+ field?: string;
137
+ constructor(message: string, status?: number, code?: string);
138
+ }
139
+ /**
140
+ * Thrown when the API key or client code is missing, invalid, or expired.
141
+ * HTTP 401. `code` is the server's (e.g. `INVALID_KEY`) when it sends one.
142
+ */
143
+ declare class AuthenticationError extends APIError {
144
+ constructor(message?: string, code?: string, status?: number);
145
+ }
146
+ /**
147
+ * Thrown when the caller is signed in but not allowed: role, plan, or no
148
+ * longer a member (`code` `FORBIDDEN`, `NOT_A_MEMBER`, …). HTTP 403. Extends
149
+ * AuthenticationError so existing 401/403 handling keeps working; check
150
+ * `status` or `code` to tell a dead key from a missing permission.
151
+ */
152
+ declare class PermissionError extends AuthenticationError {
153
+ constructor(message?: string, code?: string);
154
+ }
155
+ /**
156
+ * Thrown when the rate limit for the API key has been exceeded.
157
+ * HTTP 429. Implement exponential backoff before retrying.
158
+ */
159
+ declare class RateLimitError extends APIError {
160
+ constructor(message?: string);
161
+ }
162
+ /**
163
+ * Turn an HTTP client error into the typed SDK error: 401 → AuthenticationError,
164
+ * 403 → PermissionError, 429 → RateLimitError, else APIError. Keeps the
165
+ * server's status and code (sent in `code`, or in `error` as UPPER_SNAKE),
166
+ * and an APIError keeps the body's `issues` and `field` so a form can show
167
+ * each refused value under its own field.
168
+ */
169
+ declare function toAPIError(error: any): APIError;
170
+
171
+ 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, type VisitorStatus as f, type VisitorMessageStatus as g, toAPIError as t };
@@ -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-Bl2AN2QP.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-Bl2AN2QP.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;
@@ -4349,6 +4425,19 @@ declare class BillingUser extends APIResource {
4349
4425
  * List the current user's billing transactions.
4350
4426
  */
4351
4427
  transactions<T = any>(): Promise<T>;
4428
+ /**
4429
+ * Invoice PDF for one successful payment (`id` from `transactions()`): a
4430
+ * short-lived signed `url` and the `invoiceNo` (`ERIX/YY-YY/NNNNN`). Issued
4431
+ * on the first call, the same document after that. Owner only; 400
4432
+ * `NOT_INVOICEABLE` for failed or refunded payments.
4433
+ */
4434
+ transactionInvoice(id: string): Promise<{
4435
+ success: boolean;
4436
+ data: {
4437
+ url: string;
4438
+ invoiceNo: string;
4439
+ };
4440
+ }>;
4352
4441
  /**
4353
4442
  * Retrieve the current user's subscription.
4354
4443
  */
@@ -4645,75 +4734,6 @@ declare class PlatformDomain {
4645
4734
  constructor(client: AxiosInstance);
4646
4735
  }
4647
4736
 
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
4737
  declare class WebhookSignatureError extends APIError {
4718
4738
  constructor(message: string);
4719
4739
  }
@@ -5348,4 +5368,4 @@ declare function getRetryConfig(error: any): {
5348
5368
  readonly reason: "Generic API errors may be transient and worth retrying";
5349
5369
  };
5350
5370
 
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, EcodrixError, 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, PermissionError, 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, WebhookSignatureError, Webhooks, WhatsAppConnect, type WorkspaceDashboardLayout, type WorkspaceDefaultAutomation, type WorkspaceDefaultField, type WorkspaceDefaultPipeline, type WorkspaceModuleConfig, type WorkspaceProfile, ECODrIxAPI as default, getErrorDetails, getRetryConfig, handleAPIError, isAPIError, toAPIError };
5371
+ 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 };