@ecodrix/erix-api 1.0.7 → 1.0.8

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.
@@ -186,7 +186,7 @@ declare class Automations extends APIResource {
186
186
  /**
187
187
  * Delete an automation rule.
188
188
  */
189
- deleteRule<T = any>(ruleId: string): Promise<T>;
189
+ delete<T = any>(ruleId: string): Promise<unknown>;
190
190
  /**
191
191
  * Bulk delete rules.
192
192
  */
@@ -452,6 +452,33 @@ declare class Leads extends APIResource {
452
452
  * Introspect available custom fields configured by the tenant limit.
453
453
  */
454
454
  fields<T = any>(): Promise<T>;
455
+ /**
456
+ * List all notes for a specific lead.
457
+ */
458
+ notes<T = any>(leadId: string): Promise<T>;
459
+ /**
460
+ * Retrieve the complete chronological timeline for a lead.
461
+ */
462
+ activities<T = any>(leadId: string, params?: {
463
+ page?: number;
464
+ limit?: number;
465
+ }): Promise<T>;
466
+ /**
467
+ * Add a note to a lead.
468
+ */
469
+ createNote<T = any>(leadId: string, params: {
470
+ content: string;
471
+ }): Promise<T>;
472
+ /**
473
+ * Update an existing note.
474
+ */
475
+ updateNote<T = any>(leadId: string, noteId: string, params: {
476
+ content: string;
477
+ }): Promise<T>;
478
+ /**
479
+ * Delete a note.
480
+ */
481
+ deleteNote<T = any>(leadId: string, noteId: string): Promise<unknown>;
455
482
  /**
456
483
  * Archive (soft-delete) a single lead.
457
484
  *
@@ -491,24 +518,27 @@ interface PipelineStageParams {
491
518
  }
492
519
  declare class Pipelines extends APIResource {
493
520
  /**
494
- * List all pipelines matching the optional query parameters.
521
+ * List all pipelines and their stages.
495
522
  */
496
- list<T = any>(params?: Record<string, any>): Promise<T>;
523
+ list<T = any>(): Promise<T>;
497
524
  /**
498
525
  * Create a new pipeline.
499
526
  */
500
- create<T = any>(params: CreatePipelineParams): Promise<T>;
527
+ create<T = any>(payload: {
528
+ name: string;
529
+ stages: string[];
530
+ }): Promise<T>;
501
531
  /**
502
- * Retrieve a single pipeline.
532
+ * Retrieve a single pipeline by ID.
503
533
  */
504
534
  retrieve<T = any>(pipelineId: string): Promise<T>;
505
535
  /**
506
- * Update a pipeline's details.
536
+ * Update an existing pipeline.
507
537
  */
508
- update<T = any>(pipelineId: string, params: {
509
- name?: string;
510
- description?: string;
511
- }): Promise<T>;
538
+ update<T = any>(pipelineId: string, payload: Partial<{
539
+ name: string;
540
+ stages: string[];
541
+ }>): Promise<T>;
512
542
  /**
513
543
  * Set pipeline as the tenant's default.
514
544
  */
@@ -586,7 +616,7 @@ declare class Sequences extends APIResource {
586
616
  /**
587
617
  * Unenroll a lead from a running sequence.
588
618
  */
589
- unenroll<T = any>(enrollmentId: string): Promise<T>;
619
+ unenroll<T = any>(enrollmentId: string): Promise<unknown>;
590
620
  /**
591
621
  * List active sequence enrollments for a specific lead.
592
622
  */
@@ -186,7 +186,7 @@ declare class Automations extends APIResource {
186
186
  /**
187
187
  * Delete an automation rule.
188
188
  */
189
- deleteRule<T = any>(ruleId: string): Promise<T>;
189
+ delete<T = any>(ruleId: string): Promise<unknown>;
190
190
  /**
191
191
  * Bulk delete rules.
192
192
  */
@@ -452,6 +452,33 @@ declare class Leads extends APIResource {
452
452
  * Introspect available custom fields configured by the tenant limit.
453
453
  */
454
454
  fields<T = any>(): Promise<T>;
455
+ /**
456
+ * List all notes for a specific lead.
457
+ */
458
+ notes<T = any>(leadId: string): Promise<T>;
459
+ /**
460
+ * Retrieve the complete chronological timeline for a lead.
461
+ */
462
+ activities<T = any>(leadId: string, params?: {
463
+ page?: number;
464
+ limit?: number;
465
+ }): Promise<T>;
466
+ /**
467
+ * Add a note to a lead.
468
+ */
469
+ createNote<T = any>(leadId: string, params: {
470
+ content: string;
471
+ }): Promise<T>;
472
+ /**
473
+ * Update an existing note.
474
+ */
475
+ updateNote<T = any>(leadId: string, noteId: string, params: {
476
+ content: string;
477
+ }): Promise<T>;
478
+ /**
479
+ * Delete a note.
480
+ */
481
+ deleteNote<T = any>(leadId: string, noteId: string): Promise<unknown>;
455
482
  /**
456
483
  * Archive (soft-delete) a single lead.
457
484
  *
@@ -491,24 +518,27 @@ interface PipelineStageParams {
491
518
  }
492
519
  declare class Pipelines extends APIResource {
493
520
  /**
494
- * List all pipelines matching the optional query parameters.
521
+ * List all pipelines and their stages.
495
522
  */
496
- list<T = any>(params?: Record<string, any>): Promise<T>;
523
+ list<T = any>(): Promise<T>;
497
524
  /**
498
525
  * Create a new pipeline.
499
526
  */
500
- create<T = any>(params: CreatePipelineParams): Promise<T>;
527
+ create<T = any>(payload: {
528
+ name: string;
529
+ stages: string[];
530
+ }): Promise<T>;
501
531
  /**
502
- * Retrieve a single pipeline.
532
+ * Retrieve a single pipeline by ID.
503
533
  */
504
534
  retrieve<T = any>(pipelineId: string): Promise<T>;
505
535
  /**
506
- * Update a pipeline's details.
536
+ * Update an existing pipeline.
507
537
  */
508
- update<T = any>(pipelineId: string, params: {
509
- name?: string;
510
- description?: string;
511
- }): Promise<T>;
538
+ update<T = any>(pipelineId: string, payload: Partial<{
539
+ name: string;
540
+ stages: string[];
541
+ }>): Promise<T>;
512
542
  /**
513
543
  * Set pipeline as the tenant's default.
514
544
  */
@@ -586,7 +616,7 @@ declare class Sequences extends APIResource {
586
616
  /**
587
617
  * Unenroll a lead from a running sequence.
588
618
  */
589
- unenroll<T = any>(enrollmentId: string): Promise<T>;
619
+ unenroll<T = any>(enrollmentId: string): Promise<unknown>;
590
620
  /**
591
621
  * List active sequence enrollments for a specific lead.
592
622
  */
@@ -1,2 +1,2 @@
1
- var is=Object.defineProperty,os=Object.defineProperties;var cs=Object.getOwnPropertyDescriptors;var ts=Object.getOwnPropertySymbols;var ps=Object.prototype.hasOwnProperty,gs=Object.prototype.propertyIsEnumerable;var ms=(t,s)=>(s=Symbol[t])?s:Symbol.for("Symbol."+t);var V=(t,s,e)=>s in t?is(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e,l=(t,s)=>{for(var e in s||(s={}))ps.call(s,e)&&V(t,e,s[e]);if(ts)for(var e of ts(s))gs.call(s,e)&&V(t,e,s[e]);return t},d=(t,s)=>os(t,cs(s));var i=(t,s,e)=>V(t,typeof s!="symbol"?s+"":s,e);var W=function(t,s){this[0]=t,this[1]=s},as=(t,s,e)=>{var r=(p,g,c,u)=>{try{var T=e[p](g),f=(g=T.value)instanceof W,ns=T.done;Promise.resolve(f?g[0]:g).then(y=>f?r(p==="return"?p:"next",g[1]?{done:y.done,value:y.value}:y,c,u):c({value:y,done:ns})).catch(y=>r("throw",y,c,u))}catch(y){u(y)}},n=p=>o[p]=g=>new Promise((c,u)=>r(p,g,c,u)),o={};return e=e.apply(t,s),o[ms("asyncIterator")]=()=>o,n("next"),n("throw"),n("return"),o};import us from"axios";import es from"axios-retry";import{io as ys}from"socket.io-client";var z=class extends Error{constructor(s){super(s),this.name="EcodrixError"}},m=class extends z{constructor(e,r,n){super(e);i(this,"status");i(this,"code");this.name="APIError",this.status=r,this.code=n}},x=class extends m{constructor(s="Invalid API Key or Client Code"){super(s,401,"AUTH_FAILED"),this.name="AuthenticationError"}},rs=class extends m{constructor(s="Too many requests. Please slow down."){super(s,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};var a=class{constructor(s){this.client=s}async post(s,e,r){try{let n=this.buildConfig(r);return(await this.client.post(s,e,n)).data}catch(n){this.handleError(n)}}async get(s,e){try{let r=this.buildConfig(e);return(await this.client.get(s,r)).data}catch(r){this.handleError(r)}}async patch(s,e,r){try{let n=this.buildConfig(r);return(await this.client.patch(s,e,n)).data}catch(n){this.handleError(n)}}async put(s,e,r){try{let n=this.buildConfig(r);return(await this.client.put(s,e,n)).data}catch(n){this.handleError(n)}}async deleteRequest(s,e){try{let r=this.buildConfig(e);return(await this.client.delete(s,r)).data}catch(r){this.handleError(r)}}buildConfig(s){if(!s)return;let e=l({},s);return s.idempotencyKey&&(e.headers=d(l({},e.headers),{"Idempotency-Key":s.idempotencyKey})),e}handleError(s){var e,r,n;throw s.response?new m(((e=s.response.data)==null?void 0:e.message)||((r=s.response.data)==null?void 0:r.error)||"API Request Failed",s.response.status,(n=s.response.data)==null?void 0:n.code):new m(s.message||"Network Error")}};var G=class extends a{async list(s){return this.get(`/api/saas/crm/leads/${s}/notes`)}async create(s,e){return this.post(`/api/saas/crm/leads/${s}/notes`,e)}async update(s,e){return this.patch(`/api/saas/crm/notes/${s}`,{content:e})}async pin(s,e=!0){return this.patch(`/api/saas/crm/notes/${s}/pin`,{isPinned:e})}async delete(s){return this.deleteRequest(`/api/saas/crm/notes/${s}`)}},w=class extends a{constructor(e){super(e);i(this,"notes");this.notes=new G(e)}async timeline(e,r){return this.get(`/api/saas/crm/leads/${e}/timeline`,{params:r})}async list(e,r){return this.get("/api/saas/crm/activities",{params:l({leadId:e},r)})}async log(e){return this.post("/api/saas/crm/activities",e)}async logCall(e,r){return this.post(`/api/saas/crm/leads/${e}/calls`,r)}};var v=class extends a{async overview(s){return this.get("/api/saas/crm/analytics/overview",{params:s})}async funnel(s){return this.get("/api/saas/crm/analytics/funnel",{params:{pipelineId:s}})}async forecast(s){return this.get("/api/saas/crm/analytics/forecast",{params:{pipelineId:s}})}async sources(s){return this.get("/api/saas/crm/analytics/sources",{params:s})}async team(s){return this.get("/api/saas/crm/analytics/team",{params:s})}async heatmap(s){return this.get("/api/saas/crm/analytics/heatmap",{params:s})}async scores(){return this.get("/api/saas/crm/analytics/scores")}async stageTime(s){return this.get("/api/saas/crm/analytics/stage-time",{params:{pipelineId:s}})}async tiered(s){return this.get("/api/saas/crm/analytics/tiered",{params:s})}async summary(s){return this.get("/api/saas/crm/analytics/summary",{params:s})}async whatsapp(s){return this.get("/api/saas/crm/analytics/whatsapp",{params:s})}};var P=class extends a{async stats(){return this.get("/api/saas/crm/automation/stats")}async logs(s){return this.get("/api/saas/crm/automation/logs",{params:s})}async retryFailedEvent(s){return this.post(`/api/saas/crm/automation/logs/${s}/retry`,{})}};var R=class extends a{async list(){return this.get("/api/saas/crm/automations")}async create(s){return this.post("/api/saas/crm/automations",s)}async update(s,e){return this.patch(`/api/saas/crm/automations/${s}`,e)}async toggle(s){return this.patch(`/api/saas/crm/automations/${s}/toggle`)}async deleteRule(s){return this.deleteRequest(`/api/saas/crm/automations/${s}`)}async bulkDelete(s){return this.post("/api/saas/crm/automations/bulk-delete",{ids:s})}async test(s,e){return this.post(`/api/saas/crm/automations/${s}/test`,{leadId:e})}async getAvailableEvents(){return this.post("/api/saas/crm/automations/events",{})}async enrollments(s,e){return this.get(`/api/saas/crm/automations/${s}/enrollments`,{params:e})}async getEnrollment(s){return this.get(`/api/saas/crm/automations/enrollments/${s}`)}async pauseEnrollment(s,e){return this.post(`/api/saas/crm/automations/${s}/enrollments/${e}/pause`,{})}async resumeEnrollment(s,e){return this.post(`/api/saas/crm/automations/${s}/enrollments/${e}/resume`,{})}async runs(s){return this.get(`/api/saas/crm/automations/${s}/runs`)}async getRun(s){return this.get(`/api/saas/crm/automations/runs/${s}`)}async resumeRun(s){return this.post(`/api/saas/crm/automations/runs/${s}/resume`,{})}async abortRun(s){return this.post(`/api/saas/crm/automations/runs/${s}/abort`,{})}async webhookEvent(s,e,r){return this.post("/api/saas/crm/webhook-event",{ruleId:s,eventName:e,payload:r})}};var A=class extends a{async create(s){return this.post("/api/services/leads",s)}async upsert(s){return this.post("/api/services/leads/upsert",s)}async createMany(s,e=50){let r=[];for(let n=0;n<s.length;n+=e){let p=s.slice(n,n+e).map(c=>this.create(c)),g=await Promise.allSettled(p);for(let c of g)if(c.status==="fulfilled")r.push(c.value);else throw c.reason}return r}async import(s){return this.post("/api/services/leads/import",{leads:s})}async list(s){let e=l({},s);return Array.isArray(e.tags)&&(e.tags=e.tags.join(",")),this.get("/api/services/leads",{params:e})}listAutoPaging(s){return as(this,null,function*(){let e=(s==null?void 0:s.page)||1,r=!0;for(;r;){let n=yield new W(this.list(d(l({},s),{page:e}))),o=Array.isArray(n.data)?n.data:n||[];if(o.length===0){r=!1;break}for(let p of o)yield p;n.pagination&&e<n.pagination.pages||!n.pagination&&o.length>0?e++:r=!1}})}async retrieve(s){return this.get(`/api/services/leads/${s}`)}async retrieveByPhone(s){return this.get(`/api/services/leads/phone/${encodeURIComponent(s)}`)}async retrieveByRef(s,e){return this.get(`/api/services/leads/ref/${encodeURIComponent(s)}/${encodeURIComponent(e)}`)}async update(s,e){return this.post(`/api/services/leads/${s}`,e)}async move(s,e){return this.patch(`/api/services/leads/${s}/move`,{stageId:e})}async convert(s,e,r){return this.post(`/api/services/leads/${s}/convert`,{outcome:e,reason:r})}async tags(s,e){return this.patch(`/api/services/leads/${s}/tags`,e)}async recalculateScore(s){return this.post(`/api/services/leads/${s}/score`,{})}async updateMetadata(s,e){return this.patch(`/api/services/leads/${s}/metadata`,e)}async fields(){return this.get("/api/services/leads/fields")}async delete(s){return this.deleteRequest(`/api/services/leads/${s}`)}async bulkDelete(s){return this.deleteRequest("/api/services/leads",{data:{ids:s}})}};var I=class extends a{async capture(s){return this.post("/api/saas/crm/payments/capture",s)}};var $=class extends a{async list(s){return this.get("/api/saas/crm/pipelines",{params:s})}async create(s){return this.post("/api/saas/crm/pipelines",s)}async retrieve(s){return this.get(`/api/saas/crm/pipelines/${s}`)}async update(s,e){return this.patch(`/api/saas/crm/pipelines/${s}`,e)}async setDefault(s){return this.post(`/api/saas/crm/pipelines/${s}/default`,{})}async duplicate(s,e){return this.post(`/api/saas/crm/pipelines/${s}/duplicate`,{newName:e})}async archive(s){return this.post(`/api/saas/crm/pipelines/${s}/archive`,{})}async delete(s){return this.deleteRequest(`/api/saas/crm/pipelines/${s}`)}async board(s){return this.get(`/api/saas/crm/pipelines/${s}/board`)}async forecast(s){return this.get(`/api/saas/crm/pipelines/${s}/forecast`)}async addStage(s,e){return this.post(`/api/saas/crm/pipelines/${s}/stages`,e)}async reorderStages(s,e){return this.put(`/api/saas/crm/pipelines/${s}/stages/reorder`,{order:e})}async updateStage(s,e){return this.patch(`/api/saas/crm/stages/${s}`,e)}async deleteStage(s,e){return this.deleteRequest(`/api/saas/crm/stages/${s}`,{data:e?{moveLeadsToStageId:e}:void 0})}};var C=class extends a{async getConfig(){return this.get("/api/saas/crm/scoring")}async updateConfig(s){return this.patch("/api/saas/crm/scoring",s)}async recalculate(s){return this.post(`/api/saas/crm/scoring/${s}/recalculate`,{})}};var k=class extends a{async enroll(s){return this.post("/api/saas/crm/sequences/enroll",s)}async unenroll(s){return this.deleteRequest(`/api/saas/crm/sequences/unenroll/${s}`)}async listForLead(s){return this.get(`/api/saas/crm/sequences/lead/${s}`)}};var S=class{constructor(s){i(this,"leads");i(this,"pipelines");i(this,"activities");i(this,"analytics");i(this,"automations");i(this,"sequences");i(this,"scoring");i(this,"payments");i(this,"automationDashboard");this.leads=new A(s),this.pipelines=new $(s),this.activities=new w(s),this.analytics=new v(s),this.automations=new R(s),this.sequences=new k(s),this.scoring=new C(s),this.payments=new I(s),this.automationDashboard=new P(s)}};var q=class extends a{async sendEmailCampaign(s){return this.post("/api/saas/emails/campaign",s)}async sendTestEmail(s){return this.post("/api/saas/emails/test",{to:s})}};var E=class extends a{async list(){return this.get("/api/saas/events")}async assign(s){return this.post("/api/saas/events/assign",s)}async unassign(s){return this.post("/api/saas/events/unassign",{name:s})}async unassignBulk(s){return this.post("/api/saas/events/unassign/bulk",{names:s})}async trigger(s){return this.post("/api/saas/workflows/trigger",s)}async listCustomEvents(){return this.get("/api/saas/crm/custom-events")}async createCustomEvent(s){return this.post("/api/saas/crm/custom-events",s)}async deleteCustomEvent(s){return this.deleteRequest(`/api/saas/crm/custom-events/${s}`)}async emit(s){return this.post("/api/saas/crm/events/emit",s)}};var D=class extends a{async system(){return(await this.get("/api/saas/health",{headers:{accept:"application/json"}})).data}async clientHealth(){return(await this.get("/api/saas/health/client")).data}async jobStatus(s){return(await this.get(`/api/saas/jobs/status/${s}`)).data}};var Q=class extends a{async sendCampaign(s){return this.post("/api/saas/marketing/emails/campaign",s)}async sendTest(s){return this.post("/api/saas/marketing/emails/test",{to:s})}},X=class extends a{async list(s){return this.get("/api/saas/marketing/campaigns",{params:s})}async create(s){return this.post("/api/saas/marketing/campaigns",s)}async retrieve(s){return this.get(`/api/saas/marketing/campaigns/${s}`)}async update(s,e){return this.patch(`/api/saas/marketing/campaigns/${s}`,e)}async delete(s){return this.deleteRequest(`/api/saas/marketing/campaigns/${s}`)}async send(s,e){return this.post(`/api/saas/marketing/campaigns/${s}/send`,e||{})}async stats(s){return this.get(`/api/saas/marketing/campaigns/${s}/stats`)}},Y=class extends a{async sendTemplate(s){return this.post("/api/saas/marketing/whatsapp/send-template",s)}},L=class extends a{constructor(e){super(e);i(this,"emails");i(this,"campaigns");i(this,"whatsapp");this.emails=new Q(e),this.campaigns=new X(e),this.whatsapp=new Y(e)}};import ls from"axios";var U=class extends a{async getUsage(){return this.get("/api/saas/storage/usage")}async createFolder(s){return this.post("/api/saas/storage/folders",{name:s})}async list(s,e){return this.get(`/api/saas/storage/files/${s}`,{params:e})}async delete(s){return this.deleteRequest("/api/saas/storage/files",{params:{key:s}})}async getDownloadUrl(s){return this.post("/api/saas/storage/download-url",{key:s})}async upload(s,e){let{data:r}=await this.client.post("/api/saas/storage/upload-url",e),{uploadUrl:n,key:o}=r;await ls.put(n,s,{headers:{"Content-Type":e.contentType}});let p=s.size||s.byteLength||0;return this.post("/api/saas/storage/confirm-upload",{key:o,sizeBytes:p})}};var M=class extends a{async create(s){return this.post("/api/saas/meet",s)}async list(s){return this.get("/api/saas/meet",{params:s})}async retrieve(s){return this.get(`/api/saas/meet/${s}`)}async update(s,e){return this.patch(`/api/saas/meet/${s}`,e)}async reschedule(s,e){return this.patch(`/api/saas/meet/${s}`,e)}async delete(s){return this.update(s,{status:"cancelled"})}};var N=class extends a{async listLogs(s){return this.get("/api/saas/events/logs",{params:s})}async retrieveLog(s){return this.get(`/api/saas/events/logs/${s}`)}async getStats(s){return this.get("/api/saas/events/stats",{params:s})}async listCallbacks(s){return this.get("/api/saas/callbacks/logs",{params:s})}async listAlerts(s){return this.get("/api/crm/notifications",{params:s})}async dismissAlert(s){return this.patch(`/api/crm/notifications/${s}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/api/crm/notifications/clear-all")}async retryAction(s){return this.post(`/api/crm/notifications/${s}/retry`,{})}};var O=class extends a{async listFailed(){return this.get("/api/saas/queue/failed")}async getStats(){return this.get("/api/saas/queue/stats")}async retryJob(s){return this.post(`/api/saas/queue/${s}/retry`,{})}async deleteJob(s){return this.deleteRequest(`/api/saas/queue/${s}`)}};var Z=class extends a{async create(s){return this.post("/api/saas/storage/folders",{name:s})}async delete(s){return this.deleteRequest(`/api/saas/storage/folders/${encodeURIComponent(s)}`)}},ss=class extends a{async list(s,e){return this.get(`/api/saas/storage/files/${s}`,{params:e})}async getUploadUrl(s){return this.post("/api/saas/storage/upload-url",s)}async confirmUpload(s){return this.post("/api/saas/storage/confirm-upload",s)}async getDownloadUrl(s){return this.post("/api/saas/storage/download-url",{key:s})}async delete(s){return this.deleteRequest("/api/saas/storage/files",{params:{key:s}})}},B=class extends a{constructor(e){super(e);i(this,"folders");i(this,"files");this.folders=new Z(e),this.files=new ss(e)}async usage(){return this.get("/api/saas/storage/usage")}};var h=class extends m{constructor(s){super(s,400,"invalid_signature"),this.name="WebhookSignatureError"}},F=class{async constructEvent(s,e,r){if(!e)throw new h("No webhook signature provided");let n=Array.isArray(e)?e[0]:e;n.startsWith("sha256=")&&(n=n.slice(7));try{let o=await import("crypto"),g=o.createHmac("sha256",r).update(s).digest("hex");if(!o.timingSafeEqual(Buffer.from(g),Buffer.from(n)))throw new h("Invalid webhook signature provided");return JSON.parse(s.toString("utf8"))}catch(o){throw o instanceof h?o:new h(`Webhook payload parsing failed: ${o.message}`)}}};var H=class extends a{async list(s){return this.get("/api/saas/chat/broadcasts",{params:s})}async create(s){return this.post("/api/saas/chat/broadcast",s)}};var _=class extends a{async list(s){return this.get("/api/saas/chat/conversations",{params:s})}async create(s){return this.post("/api/saas/chat/conversations",s)}async retrieve(s){return this.get(`/api/saas/chat/conversations/${s}`)}async messages(s,e){return this.get(`/api/saas/chat/conversations/${s}/messages`,{params:e})}async linkLead(s,e,r){return this.post(`/api/saas/chat/conversations/${s}/link-lead`,{leadId:e,leadData:r})}async markRead(s){return this.post(`/api/saas/chat/conversations/${s}/read`,{})}async delete(s){return this.deleteRequest(`/api/saas/chat/conversations/${s}`)}async bulkDelete(s){return this.post("/api/saas/chat/conversations/bulk-delete",{ids:s})}};var j=class extends a{async send(s){return this.post("/api/saas/chat/send",s)}async sendTemplate(s){return this.post("/api/saas/chat/send",d(l({},s),{templateLanguage:s.language||"en_US"}))}async star(s,e){return this.post(`/api/saas/chat/messages/${s}/star`,{isStarred:e})}async react(s,e){return this.post(`/api/saas/chat/messages/${s}/react`,{reaction:e})}async markRead(s){return this.post(`/api/saas/chat/conversations/${s}/read`)}};var K=class extends a{async list(s){return this.get("/api/saas/whatsapp/templates",{params:s})}async sync(){return this.post("/api/saas/whatsapp/templates/sync",{})}async retrieve(s){return this.get(`/api/saas/whatsapp/templates/${encodeURIComponent(s)}`)}async create(s){return this.post("/api/saas/whatsapp/templates",s)}async update(s,e){return this.put(`/api/saas/whatsapp/templates/${s}`,e)}async deleteTemplate(s,e){return this.deleteRequest(`/api/saas/whatsapp/templates/${encodeURIComponent(s)}${e?"?force=true":""}`)}async mappingConfig(){return this.get("/api/saas/whatsapp/templates/mapping/config")}async collections(){return this.get("/api/saas/whatsapp/templates/collections")}async collectionFields(s){return this.get(`/api/saas/whatsapp/templates/collections/${encodeURIComponent(s)}/fields`)}async updateMapping(s,e){return this.put(`/api/saas/whatsapp/templates/${encodeURIComponent(s)}/mapping`,e)}async validate(s){return this.get(`/api/saas/whatsapp/templates/${encodeURIComponent(s)}/validate`)}async preview(s,e){return this.post(`/api/saas/whatsapp/templates/${encodeURIComponent(s)}/preview`,{context:e})}async checkUsage(s){return this.get(`/api/saas/whatsapp/templates/${encodeURIComponent(s)}/usage`)}};var J=class extends a{constructor(e){super(e);i(this,"messages");i(this,"conversations");i(this,"broadcasts");i(this,"templates");this.messages=new j(e),this.conversations=new _(e),this.broadcasts=new H(e),this.templates=new K(e)}async upload(e,r){let n=new FormData;return n.append("file",e,r),this.post("/api/saas/whatsapp/upload",n,{headers:typeof n.getHeaders=="function"?n.getHeaders():void 0})}async sendTemplate(e){return this.post("/api/saas/whatsapp/send-template",e)}};var b=class{constructor(s){i(this,"client");i(this,"socket");i(this,"whatsapp");i(this,"crm");i(this,"media");i(this,"meet");i(this,"notifications");i(this,"email");i(this,"events");i(this,"webhooks");i(this,"storage");i(this,"marketing");i(this,"health");i(this,"queue");var g,c,u;if(!s.apiKey)throw new x("API Key is required");let e=s.baseUrl||"https://api.ecodrix.com",r=s.socketUrl||e,n=typeof window!="undefined"&&typeof window.document!="undefined",o=n?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",p=n?((g=globalThis.navigator)==null?void 0:g.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown";this.client=us.create({baseURL:e,headers:{"x-api-key":s.apiKey,"x-client-code":(c=s.clientCode)==null?void 0:c.toUpperCase(),"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:"1.0.0",runtime:o,os:p})}}),es(this.client,{retries:3,retryDelay:es.exponentialDelay,retryCondition:T=>{var f;return es.isNetworkOrIdempotentRequestError(T)||((f=T.response)==null?void 0:f.status)===429}}),this.whatsapp=new J(this.client),this.crm=new S(this.client),this.media=new U(this.client),this.meet=new M(this.client),this.notifications=new N(this.client),this.email=new q(this.client),this.events=new E(this.client),this.webhooks=new F,this.storage=new B(this.client),this.marketing=new L(this.client),this.health=new D(this.client),this.queue=new O(this.client),this.socket=ys(r,{extraHeaders:{"x-api-key":s.apiKey,"x-client-code":((u=s.clientCode)==null?void 0:u.toUpperCase())||""}}),this.setupSocket(s.clientCode)}setupSocket(s){this.socket.on("connect",()=>{s&&this.socket.emit("join-room",s.toUpperCase())})}on(s,e){return this.socket.on(s,e),this}disconnect(){this.socket.disconnect()}off(s,e){return this.socket.off(s,e),this}async request(s,e,r,n){var o,p,g;try{return(await this.client.request({method:s,url:e,data:r,params:n})).data}catch(c){throw c.response?new m(((o=c.response.data)==null?void 0:o.message)||((p=c.response.data)==null?void 0:p.error)||"Raw Execution Failed",c.response.status,(g=c.response.data)==null?void 0:g.code):new m(c.message||"Network Error")}}};var tt=b;export{m as APIError,w as Activities,v as Analytics,x as AuthenticationError,P as AutomationDashboard,R as Automations,H as Broadcasts,S as CRM,X as Campaigns,_ as Conversations,b as Ecodrix,z as EcodrixError,q as EmailResource,Q as Emails,E as EventsResource,ss as Files,Z as Folders,D as Health,A as Leads,L as Marketing,U as MediaResource,M as Meetings,j as Messages,G as Notes,N as Notifications,I as Payments,$ as Pipelines,O as Queue,rs as RateLimitError,C as Scoring,k as Sequences,B as Storage,K as Templates,h as WebhookSignatureError,F as Webhooks,J as WhatsApp,Y as WhatsAppMarketing,tt as default};
1
+ var it=Object.defineProperty,ot=Object.defineProperties;var ct=Object.getOwnPropertyDescriptors;var st=Object.getOwnPropertySymbols;var pt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var mt=(s,t)=>(t=Symbol[s])?t:Symbol.for("Symbol."+s);var V=(s,t,e)=>t in s?it(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,l=(s,t)=>{for(var e in t||(t={}))pt.call(t,e)&&V(s,e,t[e]);if(st)for(var e of st(t))gt.call(t,e)&&V(s,e,t[e]);return s},d=(s,t)=>ot(s,ct(t));var i=(s,t,e)=>V(s,typeof t!="symbol"?t+"":t,e);var W=function(s,t){this[0]=s,this[1]=t},at=(s,t,e)=>{var r=(p,g,c,u)=>{try{var T=e[p](g),f=(g=T.value)instanceof W,nt=T.done;Promise.resolve(f?g[0]:g).then(y=>f?r(p==="return"?p:"next",g[1]?{done:y.done,value:y.value}:y,c,u):c({value:y,done:nt})).catch(y=>r("throw",y,c,u))}catch(y){u(y)}},n=p=>o[p]=g=>new Promise((c,u)=>r(p,g,c,u)),o={};return e=e.apply(s,t),o[mt("asyncIterator")]=()=>o,n("next"),n("throw"),n("return"),o};import ut from"axios";import et from"axios-retry";import{io as yt}from"socket.io-client";var z=class extends Error{constructor(t){super(t),this.name="EcodrixError"}},m=class extends z{constructor(e,r,n){super(e);i(this,"status");i(this,"code");this.name="APIError",this.status=r,this.code=n}},x=class extends m{constructor(t="Invalid API Key or Client Code"){super(t,401,"AUTH_FAILED"),this.name="AuthenticationError"}},rt=class extends m{constructor(t="Too many requests. Please slow down."){super(t,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};var a=class{constructor(t){this.client=t}async post(t,e,r){try{let n=this.buildConfig(r);return(await this.client.post(t,e,n)).data}catch(n){this.handleError(n)}}async get(t,e){try{let r=this.buildConfig(e);return(await this.client.get(t,r)).data}catch(r){this.handleError(r)}}async patch(t,e,r){try{let n=this.buildConfig(r);return(await this.client.patch(t,e,n)).data}catch(n){this.handleError(n)}}async put(t,e,r){try{let n=this.buildConfig(r);return(await this.client.put(t,e,n)).data}catch(n){this.handleError(n)}}async deleteRequest(t,e){try{let r=this.buildConfig(e);return(await this.client.delete(t,r)).data}catch(r){this.handleError(r)}}buildConfig(t){if(!t)return;let e=l({},t);return t.idempotencyKey&&(e.headers=d(l({},e.headers),{"Idempotency-Key":t.idempotencyKey})),e}handleError(t){var e,r,n;throw t.response?new m(((e=t.response.data)==null?void 0:e.message)||((r=t.response.data)==null?void 0:r.error)||"API Request Failed",t.response.status,(n=t.response.data)==null?void 0:n.code):new m(t.message||"Network Error")}};var G=class extends a{async list(t){return this.get(`/api/crm/leads/${t}/notes`)}async create(t,e){return this.post(`/api/crm/leads/${t}/notes`,e)}async update(t,e){return this.patch(`/api/crm/notes/${t}`,{content:e})}async pin(t,e=!0){return this.patch(`/api/crm/notes/${t}/pin`,{isPinned:e})}async delete(t){return this.deleteRequest(`/api/crm/notes/${t}`)}},w=class extends a{constructor(e){super(e);i(this,"notes");this.notes=new G(e)}async timeline(e,r){return this.get(`/api/crm/leads/${e}/timeline`,{params:r})}async list(e,r){return this.get(`/api/crm/leads/${e}/activities`,{params:l({},r)})}async log(e){return this.post(`/api/crm/leads/${e.leadId}/activities`,e)}async logCall(e,r){return this.post(`/api/crm/leads/${e}/calls`,r)}};var P=class extends a{async overview(t){return this.get("/api/crm/analytics/overview",{params:t})}async funnel(t){return this.get("/api/crm/analytics/funnel",{params:{pipelineId:t}})}async forecast(t){return this.get("/api/crm/analytics/forecast",{params:{pipelineId:t}})}async sources(t){return this.get("/api/crm/analytics/sources",{params:t})}async team(t){return this.get("/api/crm/analytics/team",{params:t})}async heatmap(t){return this.get("/api/crm/analytics/heatmap",{params:t})}async scores(){return this.get("/api/crm/analytics/scores")}async stageTime(t){return this.get("/api/crm/analytics/stage-time",{params:{pipelineId:t}})}async tiered(t){return this.get("/api/crm/analytics/tiered",{params:t})}async summary(t){return this.get("/api/crm/analytics/summary",{params:t})}async whatsapp(t){return this.get("/api/crm/analytics/whatsapp",{params:t})}};var v=class extends a{async stats(){return this.get("/api/crm/automation/stats")}async logs(t){return this.get("/api/crm/automation/logs",{params:t})}async retryFailedEvent(t){return this.post(`/api/crm/automation/logs/${t}/retry`,{})}};var R=class extends a{async list(){return this.get("/api/crm/automations")}async create(t){return this.post("/api/crm/automations",t)}async update(t,e){return this.patch(`/api/crm/automations/${t}`,e)}async toggle(t){return this.patch(`/api/crm/automations/${t}/toggle`)}async delete(t){return this.deleteRequest(`/api/crm/automations/${t}`)}async bulkDelete(t){return this.post("/api/crm/automations/bulk-delete",{ids:t})}async test(t,e){return this.post(`/api/crm/automations/${t}/test`,{leadId:e})}async getAvailableEvents(){return this.post("/api/crm/automations/events",{})}async enrollments(t,e){return this.get(`/api/crm/automations/${t}/enrollments`,{params:e})}async getEnrollment(t){return this.get(`/api/crm/automations/enrollments/${t}`)}async pauseEnrollment(t,e){return this.post(`/api/crm/automations/${t}/enrollments/${e}/pause`,{})}async resumeEnrollment(t,e){return this.post(`/api/crm/automations/${t}/enrollments/${e}/resume`,{})}async runs(t){return this.get(`/api/crm/automations/${t}/runs`)}async getRun(t){return this.get(`/api/crm/automations/runs/${t}`)}async resumeRun(t){return this.post(`/api/crm/automations/runs/${t}/resume`,{})}async abortRun(t){return this.post(`/api/crm/automations/runs/${t}/abort`,{})}async webhookEvent(t,e,r){return this.post("/api/crm/webhook-event",{ruleId:t,eventName:e,payload:r})}};var A=class extends a{async create(t){return this.post("/api/crm/leads",t)}async upsert(t){return this.post("/api/crm/leads/upsert",t)}async createMany(t,e=50){let r=[];for(let n=0;n<t.length;n+=e){let p=t.slice(n,n+e).map(c=>this.create(c)),g=await Promise.allSettled(p);for(let c of g)if(c.status==="fulfilled")r.push(c.value);else throw c.reason}return r}async import(t){return this.post("/api/crm/leads/import",{leads:t})}async list(t){let e=l({},t);return Array.isArray(e.tags)&&(e.tags=e.tags.join(",")),this.get("/api/crm/leads",{params:e})}listAutoPaging(t){return at(this,null,function*(){let e=(t==null?void 0:t.page)||1,r=!0;for(;r;){let n=yield new W(this.list(d(l({},t),{page:e}))),o=Array.isArray(n.data)?n.data:n||[];if(o.length===0){r=!1;break}for(let p of o)yield p;n.pagination&&e<n.pagination.pages||!n.pagination&&o.length>0?e++:r=!1}})}async retrieve(t){return this.get(`/api/crm/leads/${t}`)}async retrieveByPhone(t){return this.get(`/api/crm/leads/phone/${encodeURIComponent(t)}`)}async retrieveByRef(t,e){return this.get(`/api/crm/leads/ref/${encodeURIComponent(t)}/${encodeURIComponent(e)}`)}async update(t,e){return this.patch(`/api/crm/leads/${t}`,e)}async move(t,e){return this.patch(`/api/crm/leads/${t}/move`,{stageId:e})}async convert(t,e,r){return this.post(`/api/crm/leads/${t}/convert`,{outcome:e,reason:r})}async tags(t,e){return this.patch(`/api/crm/leads/${t}/tags`,e)}async recalculateScore(t){return this.post(`/api/crm/leads/${t}/score`,{})}async updateMetadata(t,e){return this.patch(`/api/crm/leads/${t}/metadata`,e)}async fields(){return this.get("/api/crm/leads/fields")}async notes(t){return this.get(`/api/crm/leads/${t}/notes`)}async activities(t,e){return this.get(`/api/crm/leads/${t}/timeline`,{params:e})}async createNote(t,e){return this.post(`/api/crm/leads/${t}/notes`,e)}async updateNote(t,e,r){return this.patch(`/api/crm/notes/${e}`,r)}async deleteNote(t,e){return this.deleteRequest(`/api/crm/notes/${e}`)}async delete(t){return this.deleteRequest(`/api/crm/leads/${t}`)}async bulkDelete(t){return this.deleteRequest("/api/crm/leads",{data:{ids:t}})}};var $=class extends a{async capture(t){return this.post("/api/crm/payments/capture",t)}};var I=class extends a{async list(){return this.get("/api/crm/pipelines")}async create(t){return this.post("/api/crm/pipelines",t)}async retrieve(t){return this.get(`/api/crm/pipelines/${t}`)}async update(t,e){return this.patch(`/api/crm/pipelines/${t}`,e)}async setDefault(t){return this.post(`/api/crm/pipelines/${t}/default`,{})}async duplicate(t,e){return this.post(`/api/crm/pipelines/${t}/duplicate`,{newName:e})}async archive(t){return this.post(`/api/saas/crm/pipelines/${t}/archive`,{})}async delete(t){return this.deleteRequest(`/api/saas/crm/pipelines/${t}`)}async board(t){return this.get(`/api/saas/crm/pipelines/${t}/board`)}async forecast(t){return this.get(`/api/saas/crm/pipelines/${t}/forecast`)}async addStage(t,e){return this.post(`/api/saas/crm/pipelines/${t}/stages`,e)}async reorderStages(t,e){return this.put(`/api/saas/crm/pipelines/${t}/stages/reorder`,{order:e})}async updateStage(t,e){return this.patch(`/api/saas/crm/stages/${t}`,e)}async deleteStage(t,e){return this.deleteRequest(`/api/saas/crm/stages/${t}`,{data:e?{moveLeadsToStageId:e}:void 0})}};var C=class extends a{async getConfig(){return this.get("/api/crm/scoring")}async updateConfig(t){return this.patch("/api/crm/scoring",t)}async recalculate(t){return this.post(`/api/crm/scoring/${t}/recalculate`,{})}};var k=class extends a{async enroll(t){return this.post("/api/crm/sequences/enroll",t)}async unenroll(t){return this.deleteRequest(`/api/crm/sequences/unenroll/${t}`)}async listForLead(t){return this.get(`/api/crm/sequences/lead/${t}`)}};var q=class{constructor(t){i(this,"leads");i(this,"pipelines");i(this,"activities");i(this,"analytics");i(this,"automations");i(this,"sequences");i(this,"scoring");i(this,"payments");i(this,"automationDashboard");this.leads=new A(t),this.pipelines=new I(t),this.activities=new w(t),this.analytics=new P(t),this.automations=new R(t),this.sequences=new k(t),this.scoring=new C(t),this.payments=new $(t),this.automationDashboard=new v(t)}};var S=class extends a{async sendEmailCampaign(t){return this.post("/api/saas/emails/campaign",t)}async sendTestEmail(t){return this.post("/api/saas/emails/test",{to:t})}};var E=class extends a{async list(){return this.get("/api/saas/events")}async assign(t){return this.post("/api/saas/events/assign",t)}async unassign(t){return this.post("/api/saas/events/unassign",{name:t})}async unassignBulk(t){return this.post("/api/saas/events/unassign/bulk",{names:t})}async trigger(t){return this.post("/api/saas/workflows/trigger",t)}async listCustomEvents(){return this.get("/api/saas/crm/custom-events")}async createCustomEvent(t){return this.post("/api/saas/crm/custom-events",t)}async deleteCustomEvent(t){return this.deleteRequest(`/api/saas/crm/custom-events/${t}`)}async emit(t){return this.post("/api/saas/crm/events/emit",t)}};var D=class extends a{async system(){return(await this.get("/api/saas/health",{headers:{accept:"application/json"}})).data}async clientHealth(){return(await this.get("/api/saas/health/client")).data}async jobStatus(t){return(await this.get(`/api/saas/jobs/status/${t}`)).data}};var Q=class extends a{async sendCampaign(t){return this.post("/api/saas/marketing/emails/campaign",t)}async sendTest(t){return this.post("/api/saas/marketing/emails/test",{to:t})}},X=class extends a{async list(t){return this.get("/api/saas/marketing/campaigns",{params:t})}async create(t){return this.post("/api/saas/marketing/campaigns",t)}async retrieve(t){return this.get(`/api/saas/marketing/campaigns/${t}`)}async update(t,e){return this.patch(`/api/saas/marketing/campaigns/${t}`,e)}async delete(t){return this.deleteRequest(`/api/saas/marketing/campaigns/${t}`)}async send(t,e){return this.post(`/api/saas/marketing/campaigns/${t}/send`,e||{})}async stats(t){return this.get(`/api/saas/marketing/campaigns/${t}/stats`)}},Y=class extends a{async sendTemplate(t){return this.post("/api/saas/marketing/whatsapp/send-template",t)}},L=class extends a{constructor(e){super(e);i(this,"emails");i(this,"campaigns");i(this,"whatsapp");this.emails=new Q(e),this.campaigns=new X(e),this.whatsapp=new Y(e)}};import lt from"axios";var U=class extends a{async getUsage(){return this.get("/api/saas/storage/usage")}async createFolder(t){return this.post("/api/saas/storage/folders",{name:t})}async list(t,e){return this.get(`/api/saas/storage/files/${t}`,{params:e})}async delete(t){return this.deleteRequest("/api/saas/storage/files",{params:{key:t}})}async getDownloadUrl(t){return this.post("/api/saas/storage/download-url",{key:t})}async upload(t,e){let{data:r}=await this.client.post("/api/saas/storage/upload-url",e),{uploadUrl:n,key:o}=r;await lt.put(n,t,{headers:{"Content-Type":e.contentType}});let p=t.size||t.byteLength||0;return this.post("/api/saas/storage/confirm-upload",{key:o,sizeBytes:p})}};var M=class extends a{async create(t){return this.post("/api/saas/meet",t)}async list(t){return this.get("/api/saas/meet",{params:t})}async retrieve(t){return this.get(`/api/saas/meet/${t}`)}async update(t,e){return this.patch(`/api/saas/meet/${t}`,e)}async reschedule(t,e){return this.patch(`/api/saas/meet/${t}`,e)}async delete(t){return this.update(t,{status:"cancelled"})}};var N=class extends a{async listLogs(t){return this.get("/api/saas/events/logs",{params:t})}async retrieveLog(t){return this.get(`/api/saas/events/logs/${t}`)}async getStats(t){return this.get("/api/saas/events/stats",{params:t})}async listCallbacks(t){return this.get("/api/saas/callbacks/logs",{params:t})}async listAlerts(t){return this.get("/api/crm/notifications",{params:t})}async dismissAlert(t){return this.patch(`/api/crm/notifications/${t}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/api/crm/notifications/clear-all")}async retryAction(t){return this.post(`/api/crm/notifications/${t}/retry`,{})}};var O=class extends a{async listFailed(){return this.get("/api/saas/queue/failed")}async getStats(){return this.get("/api/saas/queue/stats")}async retryJob(t){return this.post(`/api/saas/queue/${t}/retry`,{})}async deleteJob(t){return this.deleteRequest(`/api/saas/queue/${t}`)}};var Z=class extends a{async create(t){return this.post("/api/saas/storage/folders",{name:t})}async delete(t){return this.deleteRequest(`/api/saas/storage/folders/${encodeURIComponent(t)}`)}},tt=class extends a{async list(t,e){return this.get(`/api/saas/storage/files/${t}`,{params:e})}async getUploadUrl(t){return this.post("/api/saas/storage/upload-url",t)}async confirmUpload(t){return this.post("/api/saas/storage/confirm-upload",t)}async getDownloadUrl(t){return this.post("/api/saas/storage/download-url",{key:t})}async delete(t){return this.deleteRequest("/api/saas/storage/files",{params:{key:t}})}},B=class extends a{constructor(e){super(e);i(this,"folders");i(this,"files");this.folders=new Z(e),this.files=new tt(e)}async usage(){return this.get("/api/saas/storage/usage")}};var h=class extends m{constructor(t){super(t,400,"invalid_signature"),this.name="WebhookSignatureError"}},F=class{async constructEvent(t,e,r){if(!e)throw new h("No webhook signature provided");let n=Array.isArray(e)?e[0]:e;n.startsWith("sha256=")&&(n=n.slice(7));try{let o=await import("crypto"),g=o.createHmac("sha256",r).update(t).digest("hex");if(!o.timingSafeEqual(Buffer.from(g),Buffer.from(n)))throw new h("Invalid webhook signature provided");return JSON.parse(t.toString("utf8"))}catch(o){throw o instanceof h?o:new h(`Webhook payload parsing failed: ${o.message}`)}}};var H=class extends a{async list(t){return this.get("/api/saas/chat/broadcasts",{params:t})}async create(t){return this.post("/api/saas/chat/broadcast",t)}};var _=class extends a{async list(t){return this.get("/api/saas/chat/conversations",{params:t})}async create(t){return this.post("/api/saas/chat/conversations",t)}async retrieve(t){return this.get(`/api/saas/chat/conversations/${t}`)}async messages(t,e){return this.get(`/api/saas/chat/conversations/${t}/messages`,{params:e})}async linkLead(t,e,r){return this.post(`/api/saas/chat/conversations/${t}/link-lead`,{leadId:e,leadData:r})}async markRead(t){return this.post(`/api/saas/chat/conversations/${t}/read`,{})}async delete(t){return this.deleteRequest(`/api/saas/chat/conversations/${t}`)}async bulkDelete(t){return this.post("/api/saas/chat/conversations/bulk-delete",{ids:t})}};var j=class extends a{async send(t){return this.post("/api/saas/chat/send",t)}async sendTemplate(t){return this.post("/api/saas/chat/send",d(l({},t),{templateLanguage:t.language||"en_US"}))}async star(t,e){return this.post(`/api/saas/chat/messages/${t}/star`,{isStarred:e})}async react(t,e){return this.post(`/api/saas/chat/messages/${t}/react`,{reaction:e})}async markRead(t){return this.post(`/api/saas/chat/conversations/${t}/read`)}};var K=class extends a{async list(t){return this.get("/api/saas/whatsapp/templates",{params:t})}async sync(){return this.post("/api/saas/whatsapp/templates/sync",{})}async retrieve(t){return this.get(`/api/saas/whatsapp/templates/${encodeURIComponent(t)}`)}async create(t){return this.post("/api/saas/whatsapp/templates",t)}async update(t,e){return this.put(`/api/saas/whatsapp/templates/${t}`,e)}async deleteTemplate(t,e){return this.deleteRequest(`/api/saas/whatsapp/templates/${encodeURIComponent(t)}${e?"?force=true":""}`)}async mappingConfig(){return this.get("/api/saas/whatsapp/templates/mapping/config")}async collections(){return this.get("/api/saas/whatsapp/templates/collections")}async collectionFields(t){return this.get(`/api/saas/whatsapp/templates/collections/${encodeURIComponent(t)}/fields`)}async updateMapping(t,e){return this.put(`/api/saas/whatsapp/templates/${encodeURIComponent(t)}/mapping`,e)}async validate(t){return this.get(`/api/saas/whatsapp/templates/${encodeURIComponent(t)}/validate`)}async preview(t,e){return this.post(`/api/saas/whatsapp/templates/${encodeURIComponent(t)}/preview`,{context:e})}async checkUsage(t){return this.get(`/api/saas/whatsapp/templates/${encodeURIComponent(t)}/usage`)}};var J=class extends a{constructor(e){super(e);i(this,"messages");i(this,"conversations");i(this,"broadcasts");i(this,"templates");this.messages=new j(e),this.conversations=new _(e),this.broadcasts=new H(e),this.templates=new K(e)}async upload(e,r){let n=new FormData;return n.append("file",e,r),this.post("/api/saas/whatsapp/upload",n,{headers:typeof n.getHeaders=="function"?n.getHeaders():void 0})}async sendTemplate(e){return this.post("/api/saas/whatsapp/send-template",e)}};var b=class{constructor(t){i(this,"client");i(this,"socket");i(this,"whatsapp");i(this,"crm");i(this,"media");i(this,"meet");i(this,"notifications");i(this,"email");i(this,"events");i(this,"webhooks");i(this,"storage");i(this,"marketing");i(this,"health");i(this,"queue");var g,c,u;if(!t.apiKey)throw new x("API Key is required");let e=t.baseUrl||"https://api.ecodrix.com",r=t.socketUrl||e,n=typeof window!="undefined"&&typeof window.document!="undefined",o=n?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",p=n?((g=globalThis.navigator)==null?void 0:g.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown";this.client=ut.create({baseURL:e,headers:{"x-api-key":t.apiKey,"x-client-code":(c=t.clientCode)==null?void 0:c.toUpperCase(),"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:"1.0.0",runtime:o,os:p})}}),et(this.client,{retries:3,retryDelay:et.exponentialDelay,retryCondition:T=>{var f;return et.isNetworkOrIdempotentRequestError(T)||((f=T.response)==null?void 0:f.status)===429}}),this.whatsapp=new J(this.client),this.crm=new q(this.client),this.media=new U(this.client),this.meet=new M(this.client),this.notifications=new N(this.client),this.email=new S(this.client),this.events=new E(this.client),this.webhooks=new F,this.storage=new B(this.client),this.marketing=new L(this.client),this.health=new D(this.client),this.queue=new O(this.client),this.socket=yt(r,{extraHeaders:{"x-api-key":t.apiKey,"x-client-code":((u=t.clientCode)==null?void 0:u.toUpperCase())||""}}),this.setupSocket(t.clientCode)}setupSocket(t){this.socket.on("connect",()=>{t&&this.socket.emit("join-room",t.toUpperCase())})}on(t,e){return this.socket.on(t,e),this}disconnect(){this.socket.disconnect()}off(t,e){return this.socket.off(t,e),this}async request(t,e,r,n){var o,p,g;try{return(await this.client.request({method:t,url:e,data:r,params:n})).data}catch(c){throw c.response?new m(((o=c.response.data)==null?void 0:o.message)||((p=c.response.data)==null?void 0:p.error)||"Raw Execution Failed",c.response.status,(g=c.response.data)==null?void 0:g.code):new m(c.message||"Network Error")}}};var ss=b;export{m as APIError,w as Activities,P as Analytics,x as AuthenticationError,v as AutomationDashboard,R as Automations,H as Broadcasts,q as CRM,X as Campaigns,_ as Conversations,b as Ecodrix,z as EcodrixError,S as EmailResource,Q as Emails,E as EventsResource,tt as Files,Z as Folders,D as Health,A as Leads,L as Marketing,U as MediaResource,M as Meetings,j as Messages,G as Notes,N as Notifications,$ as Payments,I as Pipelines,O as Queue,rt as RateLimitError,C as Scoring,k as Sequences,B as Storage,K as Templates,h as WebhookSignatureError,F as Webhooks,J as WhatsApp,Y as WhatsAppMarketing,ss as default};
2
2
  //# sourceMappingURL=index.js.map