@ecodrix/erix-api 2.1.5 → 3.1.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/dist/cli.js +8 -8
- package/dist/ts/cjs/index.cjs +1 -1
- package/dist/ts/esm/index.d.ts +866 -3197
- package/dist/ts/esm/index.js +1 -1
- package/package.json +4 -3
package/dist/ts/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Kn=Object.create;var L=Object.defineProperty,zn=Object.defineProperties,Qn=Object.getOwnPropertyDescriptor,Gn=Object.getOwnPropertyDescriptors,Yn=Object.getOwnPropertyNames,Fn=Object.getOwnPropertySymbols,Jn=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty,Xn=Object.prototype.propertyIsEnumerable;var Zn=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t);var Tn=(t,e,n)=>e in t?L(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,T=(t,e)=>{for(var n in e||(e={}))Mn.call(e,n)&&Tn(t,n,e[n]);if(Fn)for(var n of Fn(e))Xn.call(e,n)&&Tn(t,n,e[n]);return t},P=(t,e)=>zn(t,Gn(e));var et=(t,e)=>{for(var n in e)L(t,n,{get:e[n],enumerable:!0})},Bn=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Yn(e))!Mn.call(t,o)&&o!==n&&L(t,o,{get:()=>e[o],enumerable:!(s=Qn(e,o))||s.enumerable});return t};var D=(t,e,n)=>(n=t!=null?Kn(Jn(t)):{},Bn(e||!t||!t.__esModule?L(n,"default",{value:t,enumerable:!0}):n,t)),nt=t=>Bn(L({},"__esModule",{value:!0}),t);var a=(t,e,n)=>Tn(t,typeof e!="symbol"?e+"":e,n);var bn=function(t,e){this[0]=t,this[1]=e},Un=(t,e,n)=>{var s=(d,l,f,y)=>{try{var b=n[d](l),x=(l=b.value)instanceof bn,R=b.done;Promise.resolve(x?l[0]:l).then(u=>x?s(d==="return"?d:"next",l[1]?{done:u.done,value:u.value}:u,f,y):f({value:u,done:R})).catch(u=>s("throw",u,f,y))}catch(u){y(u)}},o=(d,l,f,y)=>p[d]=b=>(l=new Promise((x,R,u)=>(u=()=>s(d,b,x,R),c?c.then(u):u())),y=()=>c===f&&(c=0),c=f=l.then(y,y),l),c,p={};return n=n.apply(t,e),p[Zn("asyncIterator")]=()=>p,o("next"),o("throw"),o("return"),p};var ct={};et(ct,{APIError:()=>g,AdminOnboarding:()=>A,AuthenticationError:()=>m,ConnectInfra:()=>B,ECODrIx:()=>w,ECODrIxAPI:()=>w,ERROR_RETRY_CONFIG:()=>Ln,EcodrixError:()=>H,EmailConnect:()=>F,ErixChat:()=>q,ErixProduct:()=>N,HTTP_STATUS_ERROR_MAP:()=>Hn,InfraDomain:()=>S,LEAD_STATUS_VALUES:()=>_n,Onboarding:()=>C,Persona:()=>I,PlatformAdmin:()=>j,PlatformDomain:()=>O,PlatformTenants:()=>V,PlatformUsers:()=>_,ProductDomain:()=>$,RateLimitError:()=>h,StorageInfra:()=>U,WhatsAppConnect:()=>M,default:()=>ot,getErrorDetails:()=>at,getRetryConfig:()=>it,handleAPIError:()=>rt,isAPIError:()=>st});module.exports=nt(ct);var Wn=D(require("axios"),1),hn=D(require("axios-retry"),1);var xn="https://api.ecodrix.com";function Vn(t="v1",e=xn){return`${e.replace(/\/+$/,"")}/${t}/api`}var H=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},g=class extends H{constructor(n,s,o){super(n);a(this,"status");a(this,"code");this.name="APIError",this.status=s,this.code=o}},m=class extends g{constructor(e="Invalid API Key or Client Code"){super(e,401,"AUTH_FAILED"),this.name="AuthenticationError"}},h=class extends g{constructor(e="Too many requests. Please slow down."){super(e,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};var r=class{constructor(e){a(this,"client",e)}async post(e,n,s){try{let o=this.buildConfig(s);return(await this.client.post(e,n,o)).data}catch(o){this.handleError(o)}}async get(e,n){try{let s=this.buildConfig(n);return(await this.client.get(e,s)).data}catch(s){this.handleError(s)}}async patch(e,n,s){try{let o=this.buildConfig(s);return(await this.client.patch(e,n,o)).data}catch(o){this.handleError(o)}}async put(e,n,s){try{let o=this.buildConfig(s);return(await this.client.put(e,n,o)).data}catch(o){this.handleError(o)}}async deleteRequest(e,n){try{let s=this.buildConfig(n);return(await this.client.delete(e,s)).data}catch(s){this.handleError(s)}}buildConfig(e){if(!e)return;let n=T({},e);return e.idempotencyKey&&(n.headers=P(T({},n.headers),{"Idempotency-Key":e.idempotencyKey})),n}handleError(e){var n,s,o;if(e.response){let c=e.response.status,p=((n=e.response.data)==null?void 0:n.message)||((s=e.response.data)==null?void 0:s.error)||"API Request Failed",d=(o=e.response.data)==null?void 0:o.code;switch(c){case 401:throw new m(p);case 403:throw new m(p);case 429:throw new h(p);default:throw new g(p,c,d)}}throw new g(e.message||"Network Error")}};var wn=class extends r{async list(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async create(e,n){return this.post(`/product/erix/crm/leads/${e}/notes`,n)}async update(e,n){return this.patch(`/product/erix/crm/notes/${e}`,{content:n})}async pin(e,n=!0){return this.patch(`/product/erix/crm/notes/${e}/pin`,{isPinned:n})}async delete(e){return this.deleteRequest(`/product/erix/crm/notes/${e}`)}},K=class extends r{constructor(n){super(n);a(this,"notes");this.notes=new wn(n)}async timeline(n,s){return this.get(`/product/erix/crm/leads/${n}/timeline`,{params:s})}async list(n,s){return this.get(`/product/erix/crm/leads/${n}/activities`,{params:T({},s)})}async log(n){return this.post(`/product/erix/crm/leads/${n.leadId}/activities`,n)}async logCall(n,s){return this.post(`/product/erix/crm/leads/${n}/calls`,s)}};var z=class extends r{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 Q=class extends r{async stats(){return this.get("/product/erix/crm/automation/stats")}async logs(e){return this.get("/product/erix/crm/automation/logs",{params:e})}async retryFailedEvent(e){return this.post(`/product/erix/crm/automation/logs/${e}/retry`,{})}};var G=class extends r{async list(){return this.get("/product/erix/crm/automations")}async create(e){return this.post("/product/erix/crm/automations",e)}async update(e,n){return this.patch(`/product/erix/crm/automations/${e}`,n)}async toggle(e){return this.patch(`/product/erix/crm/automations/${e}/toggle`)}async delete(e){return this.deleteRequest(`/product/erix/crm/automations/${e}`)}async bulkDelete(e){return this.post("/product/erix/crm/automations/bulk-delete",{ids:e})}async test(e,n){return this.post(`/product/erix/crm/automations/${e}/test`,{leadId:n})}async getAvailableEvents(){return this.post("/product/erix/crm/events",{})}async enrollments(e,n){return this.get(`/product/erix/crm/${e}/enrollments`,{params:n})}async getEnrollment(e){return this.get(`/product/erix/crm/enrollments/${e}`)}async pauseEnrollment(e,n){return this.post(`/product/erix/crm/${e}/enrollments/${n}/pause`,{})}async resumeEnrollment(e,n){return this.post(`/product/erix/crm/${e}/enrollments/${n}/resume`,{})}async runs(e){return this.get(`/product/erix/crm/${e}/runs`)}async getRun(e){return this.get(`/product/erix/crm/runs/${e}`)}async resumeRun(e){return this.post(`/product/erix/crm/runs/${e}/resume`,{})}async abortRun(e){return this.post(`/product/erix/crm/runs/${e}/abort`,{})}async webhookEvent(e,n,s){return this.post("/product/erix/crm/webhook-event",{ruleId:e,eventName:n,payload:s})}async trigger(e){return this.post("/product/erix/events/trigger",e)}};var Y=class extends r{async list(e){return this.get("/product/erix/crm/campaigns",{params:e})}async analytics(e){return this.get(`/product/erix/crm/campaigns/${e}/analytics`)}async create(e){return this.post("/product/erix/crm/campaigns",e)}async createAB(e){return this.post("/product/erix/crm/campaigns/ab",e)}};var J=class extends r{async getChecklist(e){return this.get(`/product/erix/crm/documents/checklist/${e}`)}async createChecklist(e,n){return this.post(`/product/erix/crm/documents/checklist/${e}`,{templateNiche:n})}async markReceived(e,n,s){return this.patch(`/product/erix/crm/documents/checklist/${e}/${n}`,s?{fileUrl:s}:{})}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 X=class extends r{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 _n=["open","won","lost","archived"],Z=class extends r{async create(e){return this.post("/product/erix/crm/leads",e)}async describe(){let e=await this.fields(),n=Array.isArray(e.data)?e.data:[],s=[{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:[{label:"New",value:"new"},{label:"Contacted",value:"contacted"},{label:"Qualified",value:"qualified"},{label:"Won",value:"won"},{label:"Lost",value:"lost"}]},{key:"value",label:"Lead Value",type:"currency",required:!1},{key:"source",label:"Source",type:"string",required:!1}],o=n.map(c=>({key:`metadata.extra.${c.name}`,label:c.label||c.name,type:c.type||"string",required:!!c.required,options:c.options,group:"Custom Fields"}));return{name:"Lead",fields:[...s,...o],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,n=50){let s=[];for(let o=0;o<e.length;o+=n){let p=e.slice(o,o+n).map(l=>this.create(l)),d=await Promise.allSettled(p);for(let l of d)if(l.status==="fulfilled")s.push(l.value);else throw l.reason}return s}async import(e){return this.post("/product/erix/crm/leads/import",{leads:e})}async bulkUpsert(e){return this.import(e)}async list(e){let n=T({},e);return Array.isArray(n.tags)&&(n.tags=n.tags.join(",")),this.get("/product/erix/crm/leads",{params:n})}listAutoPaging(e){return Un(this,null,function*(){let n=(e==null?void 0:e.page)||1,s=!0;for(;s;){let o=yield new bn(this.list(P(T({},e),{page:n}))),c=Array.isArray(o.data)?o.data:o||[];if(c.length===0){s=!1;break}for(let p of c)yield p;o.pagination&&n<o.pagination.pages||!o.pagination&&c.length>0?n++:s=!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,n,s={}){return this.get(`/product/erix/crm/pipelines/${e}/stages/${n}/leads`,{params:s})}async retrieveByRef(e,n){return this.get(`/product/erix/crm/leads/ref/${encodeURIComponent(e)}/${encodeURIComponent(n)}`)}async update(e,n){return this.patch(`/product/erix/crm/leads/${e}`,n)}async move(e,n){return this.patch(`/product/erix/crm/leads/${e}/move`,{stageId:n})}async convert(e,n,s){return this.post(`/product/erix/crm/leads/${e}/convert`,{outcome:n,reason:s})}async tags(e,n){return this.patch(`/product/erix/crm/leads/${e}/tags`,n)}async recalculateScore(e){return this.post(`/product/erix/crm/leads/${e}/score`,{})}async updateMetadata(e,n){return this.patch(`/product/erix/crm/leads/${e}/metadata`,n)}async fields(){return this.get("/product/erix/crm/fields")}async notes(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async activities(e,n){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:n})}async createNote(e,n){return this.post(`/product/erix/crm/leads/${e}/notes`,n)}async updateNote(e,n,s){return this.patch(`/product/erix/crm/notes/${n}`,s)}async deleteNote(e,n){return this.deleteRequest(`/product/erix/crm/notes/${n}`)}async delete(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}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 sequences(e){return this.get(`/product/erix/crm/leads/${e}/sequences`)}async merge(e,n){return this.post("/product/erix/crm/leads/merge",{primaryId:e,secondaryId:n})}};var ee=class extends r{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var ne=class extends r{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){var o,c;let n=await this.retrieve(e),s=Array.isArray((o=n.data)==null?void 0:o.stages)?n.data.stages:[];return{name:`Pipeline: ${((c=n.data)==null?void 0:c.name)||e}`,fields:s.map(p=>({key:p._id,label:p.name,type:"string",required:!0,options:[{label:p.name,value:p._id}],group:"Stages",uiHints:{color:p.color||"#cbd5e1",probability:p.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,n){return this.patch(`/product/erix/crm/pipelines/${e}`,n)}async setDefault(e){return this.patch(`/product/erix/crm/pipelines/${e}/default`,{})}async duplicate(e,n){return this.post(`/product/erix/crm/pipelines/${e}/duplicate`,{newName:n})}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,n){return this.post(`/product/erix/crm/pipelines/${e}/stages`,n)}async reorderStages(e,n){return this.patch(`/product/erix/crm/pipelines/${e}/stages/reorder`,{order:n})}async updateStage(e,n){return this.patch(`/product/erix/crm/stages/${e}`,n)}async deleteStage(e,n){return this.deleteRequest(`/product/erix/crm/stages/${e}`,{data:n?{moveLeadsToStageId:n}:void 0})}};var te=class extends r{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 re=class extends r{async enroll(e){return this.post("/product/erix/crm/sequences/enroll",e)}async unenroll(e){return this.deleteRequest(`/product/erix/crm/sequences/unenroll/${e}`)}async listForLead(e){return this.get(`/product/erix/crm/sequences/lead/${e}`)}};var se=class extends r{async list(e){return this.get("/product/erix/chat/broadcasts",{params:e})}async retrieve(e){return this.get(`/product/erix/chat/broadcasts/${e}`)}async create(e){return this.post("/product/erix/chat/broadcast",e)}async update(e,n){return this.patch(`/product/erix/chat/broadcasts/${e}`,n)}async delete(e){return this.deleteRequest(`/product/erix/chat/broadcasts/${e}`)}};var ae=class extends r{async list(e){return this.get("/product/erix/chat/conversations",{params:e})}async create(e){return this.post("/product/erix/chat/conversations",e)}async retrieve(e){return this.get(`/product/erix/chat/conversations/${e}`)}async messages(e,n){return this.get(`/product/erix/chat/conversations/${e}/messages`,{params:n})}async linkLead(e,n,s){return this.post(`/product/erix/chat/conversations/${e}/link-lead`,{leadId:n,leadData:s})}async markRead(e){return this.post(`/product/erix/chat/conversations/${e}/read`,{})}async delete(e){return this.deleteRequest(`/product/erix/chat/conversations/${e}`)}async bulkDelete(e){return this.post("/product/erix/chat/conversations/bulk-delete",{ids:e})}};var ie=class extends r{async send(e){return this.post("/product/erix/chat/send",e)}async sendTemplate(e){return this.post("/product/erix/chat/send",P(T({},e),{templateLanguage:e.language||e.templateLanguage||"en_US"}))}async star(e,n){return this.post(`/product/erix/chat/messages/${e}/star`,{isStarred:n})}async react(e,n){return this.post(`/product/erix/chat/messages/${e}/react`,{reaction:n})}async markRead(e){return this.post(`/product/erix/chat/conversations/${e}/read`)}async upload(e){let n=new FormData;return n.append("file",e),this.post("/product/erix/chat/upload",n,{headers:{"Content-Type":"multipart/form-data"}})}};var oe=class extends r{async list(e){return this.get("/product/erix/crm/campaigns",{params:e})}async create(e){return this.post("/product/erix/crm/campaigns",e)}async stats(e){return this.get(`/product/erix/crm/campaigns/${e}/analytics`)}};var ce=class extends r{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 pe=class extends r{async trigger(e){return this.post("/product/erix/events/trigger",e)}async listCustomEvents(){return this.get("/product/erix/crm/custom-events")}async createCustomEvent(e){return this.post("/product/erix/crm/custom-events",e)}async deleteCustomEvent(e){return this.deleteRequest(`/product/erix/crm/custom-events/${e}`)}};var le=class extends r{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,n){return this.patch(`/product/erix/commerce/invoices/${e}`,n)}async delete(e){return this.deleteRequest(`/product/erix/commerce/invoices/${e}`)}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)}};var de=class extends r{async listEventLogs(e){return this.get("/product/erix/event-log/events/logs",{params:e})}async getEventLog(e){return this.get(`/product/erix/event-log/events/logs/${e}`)}async listCallbackLogs(e){return this.get("/product/erix/event-log/callbacks/logs",{params:e})}async getStats(){return this.get("/product/erix/event-log/events/stats")}};var ge=class extends r{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 ue=class extends r{async conversations(){return this.get("/product/erix/portal-inbox/conversations")}async messages(e){return this.get(`/product/erix/portal-inbox/conversations/${e}/messages`)}async reply(e,n){return this.post(`/product/erix/portal-inbox/conversations/${e}/messages`,n)}};var me=class extends r{async list(e){return this.get(`/product/erix/commerce/projects/${e}/documents`)}async upload(e,n){return this.post(`/product/erix/commerce/projects/${e}/documents`,n)}async toggleSignature(e,n,s){return this.patch(`/product/erix/commerce/projects/${e}/documents/${n}/signature`,{required:s})}async addSigner(e,n,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${n}/signers`,s)}async sign(e,n,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${n}/sign`,s!=null?s:{})}async decline(e,n){return this.post(`/product/erix/commerce/projects/${e}/documents/${n}/decline`,{})}async stampSign(e,n,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${n}/stamp-sign`,s)}};var ye=class extends r{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,n){return this.post(`/infra/connect/connections/${e}/connect`,n)}async configure(e,n){return this.put(`/infra/connect/connections/${e}/configure`,n)}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,n){return this.put(`/infra/connect/connections/${e}/access`,n)}async createPaymentLink(e){return this.post("/infra/connect/connections/payments/payment-link",e)}};var fe=class extends r{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,n){return this.put(`/infra/connect/email/templates/${e}`,n)}async deleteTemplate(e,n=!1){return this.deleteRequest(`/infra/connect/email/templates/${e}`,{params:{force:n}})}async previewTemplate(e,n){return this.post(`/infra/connect/email/templates/${e}/preview`,n)}};var he=class extends r{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,n){return this.patch(`/infra/connect/meet/${e}`,n)}async reschedule(e,n){return this.patch(`/infra/connect/meet/${e}`,n)}async delete(e){return this.update(e,{status:"cancelled"})}};var Te=class extends r{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 be=class extends r{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,n){return this.put(`/infra/connect/whatsapp/templates/${e}`,n)}async deleteTemplate(e,n){return this.deleteRequest(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}${n?"?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,n){return this.put(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/mapping`,n)}async validate(e,n){let s=`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/validate`;return n?this.post(s,n):this.get(s)}async preview(e,n,s,o){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:n,mappings:s,onEmptyVariable:o})}async getVariableManifest(e){var c,p;let n=await this.retrieve(e),s=Array.isArray((c=n.data)==null?void 0:c.components)?n.data.components:[],o=[];for(let d of s)if(d.text){let l=d.text.match(/{{(\d+)}}/g);if(l)for(let f of l){let y=f.replace(/{{|}}/g,"");o.push({key:`var_${y}`,label:`${d.type} Var {{${y}}}`,type:"string",required:!0,group:d.type,description:`Variable placeholder in template ${d.type}`})}}return{name:`Template variables: ${((p=n.data)==null?void 0:p.name)||e}`,fields:o,uiHints:{icon:"Variables",primaryColor:"#059669"}}}async checkUsage(e){return this.get(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/usage`)}};var jn=D(require("axios"),1);var xe=class extends r{async getUsage(){return this.get("/infra/storage/files/usage")}async createFolder(e){return this.post("/infra/storage/files/folders",{name:e})}async list(e,n){return this.get(`/infra/storage/files/files/${e}`,{params:n})}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,n){let s=await this.post("/infra/storage/files/upload-url",n),{uploadUrl:o,key:c}=s.data;await jn.default.put(o,e,{headers:{"Content-Type":n.contentType}});let p=e.size||e.byteLength||0;return this.post("/infra/storage/files/confirm-upload",{key:c,sizeBytes:p})}};var we=class extends r{async create(e){return this.post("/infra/storage/files/folders",{name:e})}async delete(e){return this.deleteRequest(`/infra/storage/files/folders/${encodeURIComponent(e)}`)}},Re=class extends r{async list(e,n){return this.get(`/infra/storage/files/files/${e}`,{params:n})}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",{params:{key:e}})}};var A=class extends r{async listNichePacks(e={}){return this.get("/platform/admin/onboarding/niche-packs",{params:v(e)})}async getNichePack(e,n){let s=n?{version:n}:void 0;return this.get(`/platform/admin/onboarding/niche-packs/${encodeURIComponent(e)}`,{params:s})}async createNichePack(e){return this.post("/platform/admin/onboarding/niche-packs",e)}async updateNichePack(e,n,s){let o=s?{version:s}:void 0;return this.patch(`/platform/admin/onboarding/niche-packs/${encodeURIComponent(e)}`,n,{params:o})}async publishNichePack(e,n){let s=n?{version:n}:void 0;return this.post(`/platform/admin/onboarding/niche-packs/${encodeURIComponent(e)}/publish`,void 0,{params:s})}async unpublishNichePack(e,n){let s=n?{version:n}:void 0;return this.post(`/platform/admin/onboarding/niche-packs/${encodeURIComponent(e)}/unpublish`,void 0,{params:s})}async forkNichePack(e,n={}){return this.post(`/platform/admin/onboarding/niche-packs/${encodeURIComponent(e)}/fork`,n)}async smokeTestNichePack(e,n={},s){let o=s?{version:s}:void 0;return this.post(`/platform/admin/onboarding/niche-packs/${encodeURIComponent(e)}/smoke-test`,n,{params:o})}async listOnboardingConfigs(e={}){return this.get("/platform/admin/onboarding/configs",{params:v(e)})}async createOnboardingConfig(e){return this.post("/platform/admin/onboarding/configs",e)}async updateOnboardingConfig(e,n,s){return this.patch(`/platform/admin/onboarding/configs/${encodeURIComponent(e)}/${encodeURIComponent(n)}`,s)}async publishOnboardingConfig(e,n){return this.post(`/platform/admin/onboarding/configs/${encodeURIComponent(e)}/${encodeURIComponent(n)}/publish`)}async listOnboardingExperiments(e={}){return this.get("/platform/admin/onboarding/experiments",{params:v(e)})}async getOnboardingExperiment(e){return this.get(`/platform/admin/onboarding/experiments/${encodeURIComponent(e)}`)}async createOnboardingExperiment(e){return this.post("/platform/admin/onboarding/experiments",e)}async updateOnboardingExperiment(e,n){return this.patch(`/platform/admin/onboarding/experiments/${encodeURIComponent(e)}`,n)}async deleteOnboardingExperiment(e){return this.deleteRequest(`/platform/admin/onboarding/experiments/${encodeURIComponent(e)}`)}async getOnboardingFunnel(e={}){return this.get("/platform/admin/onboarding/analytics/funnel",{params:v(e)})}async getOnboardingTimeOnStep(e={}){return this.get("/platform/admin/onboarding/analytics/time-on-step",{params:v(e)})}async getOnboardingAbandonment(e={}){return this.get("/platform/admin/onboarding/analytics/abandonment",{params:v(e)})}};function v(t){let e={};for(let[n,s]of Object.entries(t))s!==void 0&&(e[n]=s);return e}var ke=class extends r{async list(){return this.get("/platform/admin/cors")}async create(e){return this.post("/platform/admin/cors",e)}async update(e,n){return this.patch(`/platform/admin/cors/${e}`,n)}async delete(e){return this.deleteRequest(`/platform/admin/cors/${e}`)}};var Pe=class extends r{async system(){return(await this.get("/health")).data}};var ve=class extends r{async listLogs(e){return this.get("/product/erix/event-log/events/logs",{params:e})}async retrieveLog(e){return this.get(`/product/erix/event-log/events/logs/${e}`)}async getStats(e){return this.get("/product/erix/event-log/events/stats",{params:e})}async listCallbacks(e){return this.get("/product/erix/event-log/callbacks/logs",{params:e})}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")}async retryAction(e){return this.post(`/platform/users/notifications/${e}/retry`,{})}};var C=class extends r{async global(e){return this.post("/platform/tenants/onboarding/global",e)}async start(e){return this.post(`/platform/tenants/onboarding/${e.productId}/start`,e)}async answer(e){return this.post("/api/onboarding/answer",e)}async state(e){return this.get(`/platform/tenants/onboarding/${e}/state`,{params:{productId:e}})}async complete(e){return this.post("/platform/tenants/onboarding/complete",e)}async edit(e){return this.post("/api/onboarding/edit",e)}async previewWorkspace(e){return this.get("/api/onboarding/preview-workspace",{params:{sessionId:e}})}};var I=class extends r{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,n){var o;let s=await super.get(`/platform/tenants/persona/${e}/timeline`,{params:n});return(o=s==null?void 0:s.data)!=null?o:{entries:[],hasMore:!1}}async followups(e){var s,o;let n=await super.get(`/platform/tenants/persona/${e}/followups`);return(o=(s=n==null?void 0:n.data)==null?void 0:s.entries)!=null?o:[]}};var Rn=class extends r{async list(){return this.get("/platform/admin/clients")}async getCountAndGenerateCode(){return this.get("/platform/admin/clients/count")}async retrieve(e){return this.get(`/platform/admin/clients/${e}`)}async getApiKey(e){return this.get(`/platform/admin/clients/${e}/api-key`)}async rotateApiKey(e){return this.post(`/platform/admin/clients/${e}/api-key`,{})}async create(e){return this.post("/platform/admin/clients",e)}async getConfig(e){return this.get(`/platform/admin/clients/${e}/config`)}async updateConfig(e,n){return this.patch(`/platform/admin/clients/${e}/config`,n)}async getConnections(e){return this.get(`/platform/admin/clients/${e}/connections`)}async getConnectProviders(e){return this.get(`/platform/admin/clients/${e}/connections/providers`)}async connectProvider(e,n,s){return this.post(`/platform/admin/clients/${e}/connections/${n}/connect`,s)}async configureProvider(e,n,s){return this.put(`/platform/admin/clients/${e}/connections/${n}/configure`,s)}async disconnectProvider(e,n){return this.post(`/platform/admin/clients/${e}/connections/${n}/disconnect`,{})}async revealConnection(e,n){return this.post(`/platform/admin/clients/${e}/connections/${n}/reveal`,{})}async setConnectionAccess(e,n,s){return this.put(`/platform/admin/clients/${e}/connections/${n}/access`,s)}async getDataSource(e){return this.get(`/api/clients/${e}/datasource`)}async manageDataSource(e,n){return this.post(`/api/clients/${e}/datasource`,n)}async updateIdentity(e,n){return this.patch(`/platform/admin/clients/${e}/identity`,n)}async googleReauth(e,n={}){return this.post(`/platform/admin/clients/${e}/google/reauth`,n)}async delete(e){return this.deleteRequest(`/platform/admin/clients/${e}`)}},kn=class extends r{async list(){return this.get("/platform/admin/blogs")}},Pn=class extends r{async add(e){return this.post("/platform/admin/leads/add-lead",e)}},Ae=class extends r{constructor(n){super(n);a(this,"clients");a(this,"blogs");a(this,"globalLeads");this.clients=new Rn(n),this.blogs=new kn(n),this.globalLeads=new Pn(n)}};var vn=class extends r{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"}},Ce=class{constructor(e){a(this,"copilot");this.copilot=new vn(e)}};var Ie=class extends r{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,n){return this.post(`/platform/auth/invitations/${e}/accept`,n)}};var An=class extends r{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},Cn=class extends r{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)}},In=class extends r{async listPublic(){return this.get("/platform/billing/plans/public")}},$n=class extends r{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)}},Sn=class extends r{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")}},On=class extends r{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)}},$e=class{constructor(e){a(this,"entitlements");a(this,"subscriptions");a(this,"plans");a(this,"checkout");a(this,"user");a(this,"credits");this.entitlements=new An(e),this.subscriptions=new Cn(e),this.plans=new In(e),this.checkout=new $n(e),this.user=new Sn(e),this.credits=new On(e)}};var Se=class extends r{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,n){return this.post(`/platform/support/tickets/${e}/reply`,n)}async close(e){return this.patch(`/platform/support/tickets/${e}/close`,{})}};var Oe=class extends r{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",{})}},Ee=class extends r{async list(){return this.get("/platform/users/members")}async invite(e){return this.post("/platform/users/members/invite",e)}async remove(e){return this.deleteRequest(`/platform/users/members/${e}`)}},Le=class extends r{async list(){return this.get("/platform/users/sessions")}async revoke(e){return this.deleteRequest(`/platform/users/sessions/${e}`)}async revokeAll(){return this.deleteRequest("/platform/users/sessions")}};var De=class extends r{async list(e){return this.get("/platform/admin/logs",{params:e})}async export(e){return this.get("/platform/admin/logs/export",{params:e})}};var qe=class extends r{async getSettings(){return this.get("/platform/admin/invoices/settings")}async updateSettings(e){return this.patch("/platform/admin/invoices/settings",e)}async list(e){return this.get("/platform/admin/invoices",{params:e})}async create(e){return this.post("/platform/admin/invoices",e)}async retrieve(e){return this.get(`/platform/admin/invoices/${e}`)}async update(e,n){return this.patch(`/platform/admin/invoices/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/invoices/${e}`)}};var Ne=class extends r{async stats(e){return this.get("/platform/admin/agents/stats",{params:e})}async list(e){return this.get("/platform/admin/agents",{params:e})}async retrieve(e){return this.get(`/platform/admin/agents/${e}`)}async update(e,n){return this.patch(`/platform/admin/agents/${e}`,n)}async runs(e){return this.get(`/platform/admin/agents/${e}/runs`)}};var Fe=class extends r{async overview(e){return this.get("/platform/admin/analytics/overview",{params:e})}async endpoints(e){return this.get("/platform/admin/analytics/endpoints",{params:e})}async errors(e){return this.get("/platform/admin/analytics/errors",{params:e})}async tenants(e){return this.get("/platform/admin/analytics/tenants",{params:e})}};var Me=class extends r{async list(e){return this.get("/platform/admin/comms",{params:e})}async create(e){return this.post("/platform/admin/comms",e)}async update(e,n){return this.patch(`/platform/admin/comms/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/comms/${e}`)}async publish(e,n){return this.post(`/platform/admin/comms/${e}/publish`,n)}async broadcast(e){return this.post("/platform/admin/comms/broadcast",e)}async setMaintenance(e){return this.post("/platform/admin/comms/maintenance",e)}async getMaintenance(e){return this.get("/platform/admin/comms/maintenance",{params:e})}async changelog(e){return this.post("/platform/admin/comms/changelog",e)}};var Be=class extends r{async stats(e){return this.get("/platform/admin/audit/stats",{params:e})}async list(e){return this.get("/platform/admin/audit",{params:e})}async export(e){return this.get("/platform/admin/audit/export",{params:e})}};var Ue=class extends r{async events(e){return this.get("/platform/admin/billing/events",{params:e})}async orgEvents(e){return this.get(`/platform/admin/billing/events/${e}`)}async failed(e){return this.get("/platform/admin/billing/failed",{params:e})}async recordEvent(e){return this.post("/platform/admin/billing/record-event",e)}async extendTrial(e){return this.post("/platform/admin/billing/extend-trial",e)}async grandfather(e){return this.post("/platform/admin/billing/grandfather",e)}async reconcile(e){return this.get("/platform/admin/billing/reconcile",{params:e})}};var Ve=class extends r{async list(e){return this.get("/platform/admin/blogs",{params:e})}async retrieve(e){return this.get(`/platform/admin/blogs/${e}`)}async create(e){return this.post("/platform/admin/blogs",e)}async update(e,n){return this.put(`/platform/admin/blogs/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/blogs/${e}`)}};var _e=class extends r{async requests(e){return this.get("/platform/admin/compliance/requests",{params:e})}async createRequest(e){return this.post("/platform/admin/compliance/requests",e)}async updateRequest(e,n){return this.patch(`/platform/admin/compliance/requests/${e}`,n)}async exportOrg(e,n){return this.post(`/platform/admin/compliance/export/${e}`,n)}};var je=class extends r{async rateCard(e){return this.get("/platform/admin/credits/rate-card",{params:e})}async packs(e){return this.get("/platform/admin/credits/packs",{params:e})}async createPack(e){return this.post("/platform/admin/credits/packs",e)}async updatePack(e,n){return this.patch(`/platform/admin/credits/packs/${e}`,n)}async deletePack(e){return this.deleteRequest(`/platform/admin/credits/packs/${e}`)}async wallet(e){return this.get(`/platform/admin/credits/wallet/${e}`)}async adjustWallet(e,n){return this.post(`/platform/admin/credits/wallet/${e}/adjust`,n)}};var We=class extends r{async stats(e){return this.get("/platform/admin/dashboard/stats",{params:e})}};var He=class extends r{async overview(e){return this.get("/platform/admin/email/overview",{params:e})}async campaigns(e){return this.get("/platform/admin/email/campaigns",{params:e})}async events(e){return this.get("/platform/admin/email/events",{params:e})}async sesHealth(e){return this.get("/platform/admin/email/ses-health",{params:e})}};var Ke=class extends r{async createTenant(e){return this.post("/platform/admin/erix/tenants",e)}async tenants(e){return this.get("/platform/admin/erix/tenants",{params:e})}async tenant(e){return this.get(`/platform/admin/erix/tenants/${e}`)}async updatePlan(e,n){return this.patch(`/platform/admin/erix/tenants/${e}/plan`,n)}async suspend(e,n){return this.post(`/platform/admin/erix/tenants/${e}/suspend`,n)}async reactivate(e,n){return this.post(`/platform/admin/erix/tenants/${e}/reactivate`,n)}async rotateKey(e,n){return this.post(`/platform/admin/erix/tenants/${e}/rotate-key`,n)}async usage(e){return this.get(`/platform/admin/erix/tenants/${e}/usage`)}};var ze=class extends r{async list(e){return this.get("/platform/admin/flags",{params:e})}async create(e){return this.post("/platform/admin/flags",e)}async update(e,n){return this.patch(`/platform/admin/flags/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/flags/${e}`)}async listOverrides(e){return this.get(`/platform/admin/flags/${e}/overrides`)}async addOverride(e,n){return this.post(`/platform/admin/flags/${e}/overrides`,n)}async removeOverride(e,n){return this.deleteRequest(`/platform/admin/flags/${e}/overrides/${n}`)}async forOrg(e){return this.get(`/platform/admin/flags/org/${e}`)}};var Qe=class extends r{async overview(e){return this.get("/platform/admin/flow/overview",{params:e})}async runs(e){return this.get("/platform/admin/flow/runs",{params:e})}async failures(e){return this.get("/platform/admin/flow/failures",{params:e})}async run(e){return this.get(`/platform/admin/flow/runs/${e}`)}async retryRun(e,n){return this.post(`/platform/admin/flow/runs/${e}/retry`,n)}};var Ge=class extends r{async list(e){return this.get(`/platform/admin/integrations/${e}/integrations`)}async connect(e,n,s){return this.post(`/platform/admin/integrations/${e}/integrations/${n}`,s)}async disconnect(e,n){return this.deleteRequest(`/platform/admin/integrations/${e}/integrations/${n}`)}async test(e,n,s){return this.post(`/platform/admin/integrations/${e}/integrations/${n}/test`,s)}async invite(e,n){return this.post(`/platform/admin/integrations/${e}/invite`,n)}};var Ye=class extends r{async overview(e){return this.get("/platform/admin/laie/overview",{params:e})}async queue(e){return this.get("/platform/admin/laie/queue",{params:e})}async proxies(e){return this.get("/platform/admin/laie/proxies",{params:e})}async vaultStats(e){return this.get("/platform/admin/laie/vault-stats",{params:e})}async credits(e){return this.get("/platform/admin/laie/credits",{params:e})}async actors(e){return this.get("/platform/admin/laie/actors",{params:e})}async actorRegistry(e){return this.get("/platform/admin/laie/actors/registry",{params:e})}async runActor(e,n){return this.post(`/platform/admin/laie/actors/${e}/run`,n)}async getEnrichmentConfig(){return this.get("/platform/admin/laie/enrichment/config")}async setEnrichmentConfig(e){return this.put("/platform/admin/laie/enrichment/config",e)}async audits(e){return this.get("/platform/admin/laie/audits",{params:e})}async audit(e){return this.get(`/platform/admin/laie/audits/${e}`)}};var Je=class extends r{async queueStats(e){return this.get("/platform/admin/laie-runtime/queue/stats",{params:e})}async proxyHealth(e){return this.get("/platform/admin/laie-runtime/proxy/health",{params:e})}async browserPoolStats(e){return this.get("/platform/admin/laie-runtime/browser-pool/stats",{params:e})}async replayDlq(e){return this.post("/platform/admin/laie-runtime/dlq/replay",e)}async runStats(e){return this.get("/platform/admin/laie-runtime/runs/stats",{params:e})}};var Xe=class extends r{async overview(e){return this.get("/platform/admin/laie-vault",{params:e})}};var Ze=class extends r{async addLead(e){return this.post("/platform/admin/leads/add-lead",e)}async list(e){return this.get("/platform/admin/leads",{params:e})}async retrieve(e){return this.get(`/platform/admin/leads/${e}`)}async update(e,n){return this.patch(`/platform/admin/leads/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/leads/${e}`)}async updateStatus(e,n){return this.patch(`/platform/admin/leads/${e}/status`,n)}async qualification(e,n){return this.post(`/platform/admin/leads/${e}/qualification`,n)}async firstContact(e,n){return this.post(`/platform/admin/leads/${e}/first-contact`,n)}async followup(e,n){return this.post(`/platform/admin/leads/${e}/followup`,n)}async notes(e){return this.get(`/platform/admin/leads/${e}/notes`)}async addNote(e,n){return this.post(`/platform/admin/leads/${e}/notes`,n)}async updateNote(e,n,s){return this.patch(`/platform/admin/leads/${e}/notes/${n}`,s)}async deleteNote(e,n){return this.deleteRequest(`/platform/admin/leads/${e}/notes/${n}`)}};var en=class extends r{async json(){return this.get("/platform/admin/openapi/spec.json")}async docs(){return this.get("/platform/admin/openapi")}async health(){return this.get("/platform/admin/openapi/health")}};var nn=class extends r{async stats(e){return this.get("/platform/admin/partners/stats",{params:e})}async list(e){return this.get("/platform/admin/partners",{params:e})}async create(e){return this.post("/platform/admin/partners",e)}async retrieve(e){return this.get(`/platform/admin/partners/${e}`)}async update(e,n){return this.patch(`/platform/admin/partners/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/partners/${e}`)}async referrals(e){return this.get(`/platform/admin/partners/${e}/referrals`)}async updateReferral(e,n,s){return this.patch(`/platform/admin/partners/${e}/referrals/${n}`,s)}};var tn=class extends r{async refund(e){return this.post("/platform/admin/payments/refund",e)}async validate(e){return this.get(`/platform/admin/payments/validate/${e}`)}async fetch(e){return this.get(`/platform/admin/payments/fetch/${e}`)}async subscription(e){return this.get(`/platform/admin/payments/subscription/${e}`)}async failed(e){return this.get("/platform/admin/payments/failed",{params:e})}async retry(e,n){return this.post(`/platform/admin/payments/retry/${e}`,n)}async timeline(e){return this.get(`/platform/admin/payments/timeline/${e}`)}async risk(e){return this.get(`/platform/admin/payments/risk/${e}`)}};var rn=class extends r{async stats(e){return this.get("/platform/admin/persona-history/stats",{params:e})}async list(e){return this.get("/platform/admin/persona-history",{params:e})}async retrieve(e){return this.get(`/platform/admin/persona-history/${e}`)}async version(e,n){return this.get(`/platform/admin/persona-history/${e}/${n}`)}};var sn=class extends r{async templates(e){return this.get("/platform/admin/pipelines/templates",{params:e})}async createTemplate(e){return this.post("/platform/admin/pipelines/templates",e)}async updateTemplate(e,n){return this.patch(`/platform/admin/pipelines/templates/${e}`,n)}async deleteTemplate(e){return this.deleteRequest(`/platform/admin/pipelines/templates/${e}`)}async provision(e){return this.post("/platform/admin/pipelines/provision",e)}async overview(e){return this.get("/platform/admin/pipelines/overview",{params:e})}};var an=class extends r{async list(e){return this.get("/platform/admin/plans",{params:e})}async create(e){return this.post("/platform/admin/plans",e)}async update(e,n){return this.patch(`/platform/admin/plans/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/plans/${e}`)}async tenants(e){return this.get(`/platform/admin/plans/${e}/tenants`)}};var on=class extends r{async summary(e){return this.get("/platform/admin/revenue/summary",{params:e})}async snapshots(e){return this.get("/platform/admin/revenue/snapshots",{params:e})}async generateSnapshot(e){return this.post("/platform/admin/revenue/snapshot/generate",e)}};var cn=class extends r{async verifyCredentials(e){return this.post("/platform/admin/auth/staff/verify-credentials",e)}async findOrCreate(e){return this.post("/platform/admin/auth/staff/find-or-create",e)}async list(e){return this.get("/platform/admin/auth/staff",{params:e})}async create(e){return this.post("/platform/admin/auth/staff",e)}async update(e,n){return this.patch(`/platform/admin/auth/staff/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/auth/staff/${e}`)}};var pn=class extends r{async stats(e){return this.get("/platform/admin/storage/stats",{params:e})}async events(e){return this.get("/platform/admin/storage/events",{params:e})}async usage(e){return this.get("/platform/admin/storage/usage",{params:e})}};var ln=class extends r{async overview(e){return this.get("/platform/admin/health",{params:e})}};var dn=class extends r{async list(e){return this.get("/platform/admin/templates",{params:e})}async create(e){return this.post("/platform/admin/templates",e)}async retrieve(e){return this.get(`/platform/admin/templates/${e}`)}async update(e,n){return this.patch(`/platform/admin/templates/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/templates/${e}`)}async clone(e,n){return this.post(`/platform/admin/templates/${e}/clone`,n)}async versions(e){return this.get(`/platform/admin/templates/${e}/versions`)}async assignPlans(e,n){return this.post(`/platform/admin/templates/${e}/plans`,n)}};var gn=class extends r{async deep(e){return this.get(`/platform/admin/tenants/${e}/deep`)}async usage(e){return this.get(`/platform/admin/tenants/${e}/usage`)}async team(e){return this.get(`/platform/admin/tenants/${e}/team`)}async billing(e){return this.get(`/platform/admin/tenants/${e}/billing`)}async whatsapp(e){return this.get(`/platform/admin/tenants/${e}/whatsapp`)}async flows(e){return this.get(`/platform/admin/tenants/${e}/flows`)}async crmStats(e){return this.get(`/platform/admin/tenants/${e}/crm-stats`)}async impersonate(e,n){return this.post(`/platform/admin/tenants/${e}/impersonate`,n)}async suspend(e,n){return this.post(`/platform/admin/tenants/${e}/suspend`,n)}async reactivate(e,n){return this.post(`/platform/admin/tenants/${e}/reactivate`,n)}async updatePlan(e,n){return this.patch(`/platform/admin/tenants/${e}/plan`,n)}async updateLimits(e,n){return this.patch(`/platform/admin/tenants/${e}/limits`,n)}async bulkAssignPlan(e){return this.post("/platform/admin/tenants/bulk-assign-plan",e)}async unassigned(){return this.get("/platform/admin/tenants/unassigned")}};var un=class extends r{async stats(e){return this.get("/platform/admin/tickets/stats",{params:e})}async list(e){return this.get("/platform/admin/tickets",{params:e})}async create(e){return this.post("/platform/admin/tickets",e)}async retrieve(e){return this.get(`/platform/admin/tickets/${e}`)}async update(e,n){return this.patch(`/platform/admin/tickets/${e}`,n)}async addMessage(e,n){return this.post(`/platform/admin/tickets/${e}/messages`,n)}async resolve(e,n){return this.post(`/platform/admin/tickets/${e}/resolve`,n)}async close(e,n){return this.post(`/platform/admin/tickets/${e}/close`,n)}};var mn=class extends r{async stats(e){return this.get("/platform/admin/waitlist/stats",{params:e})}async list(e){return this.get("/platform/admin/waitlist",{params:e})}async retrieve(e){return this.get(`/platform/admin/waitlist/${e}`)}async update(e,n){return this.patch(`/platform/admin/waitlist/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/waitlist/${e}`)}async bulk(e){return this.post("/platform/admin/waitlist/bulk",e)}};var yn=class extends r{async overview(e){return this.get("/platform/admin/whatsapp/overview",{params:e})}async wabas(e){return this.get("/platform/admin/whatsapp/wabas",{params:e})}async templates(e){return this.get("/platform/admin/whatsapp/templates",{params:e})}async delivery(e){return this.get("/platform/admin/whatsapp/delivery",{params:e})}async webhooks(e){return this.get("/platform/admin/whatsapp/webhooks",{params:e})}};var q=class{constructor(e){a(this,"messages");a(this,"conversations");a(this,"broadcasts");this.messages=new ie(e),this.conversations=new ae(e),this.broadcasts=new se(e)}},N=class{constructor(e){a(this,"leads");a(this,"pipelines");a(this,"automations");a(this,"activities");a(this,"analytics");a(this,"scoring");a(this,"payments");a(this,"sequences");a(this,"automationDashboard");a(this,"chat");a(this,"events");a(this,"eventLog");a(this,"invoices");a(this,"checkout");a(this,"projects");a(this,"campaigns");a(this,"portalInbox");a(this,"niche");a(this,"documents");a(this,"invoiceExport");a(this,"crmCampaigns");this.leads=new Z(e),this.pipelines=new ne(e),this.automations=new G(e),this.activities=new K(e),this.analytics=new z(e),this.scoring=new te(e),this.payments=new ee(e),this.sequences=new re(e),this.automationDashboard=new Q(e),this.chat=new q(e),this.events=new pe(e),this.eventLog=new de(e),this.invoices=new le(e),this.checkout=new ce(e),this.projects=new me(e),this.campaigns=new oe(e),this.portalInbox=new ue(e),this.niche=new ge(e),this.documents=new J(e),this.invoiceExport=new X(e),this.crmCampaigns=new Y(e)}},$=class{constructor(e){a(this,"erix");this.erix=new N(e)}},F=class{constructor(e){a(this,"config");a(this,"templates");this.config=new Te(e),this.templates=new fe(e)}},M=class{constructor(e){a(this,"templates");this.templates=new be(e)}},B=class{constructor(e){a(this,"email");a(this,"whatsapp");a(this,"meet");a(this,"connections");this.email=new F(e),this.whatsapp=new M(e),this.meet=new he(e),this.connections=new ye(e)}},U=class{constructor(e){a(this,"files");a(this,"folders");a(this,"media");this.files=new Re(e),this.folders=new we(e),this.media=new xe(e)}},S=class{constructor(e){a(this,"connect");a(this,"storage");this.connect=new B(e),this.storage=new U(e)}},V=class{constructor(e){a(this,"onboarding");a(this,"persona");this.onboarding=new C(e),this.persona=new I(e)}},_=class{constructor(e){a(this,"me");a(this,"members");a(this,"sessions");a(this,"notifications");this.me=new Oe(e),this.members=new Ee(e),this.sessions=new Le(e),this.notifications=new ve(e)}},j=class{constructor(e){a(this,"revenue");a(this,"billing");a(this,"payments");a(this,"credits");a(this,"plans");a(this,"agencyInvoices");a(this,"flags");a(this,"activityLogs");a(this,"auditLogs");a(this,"analytics");a(this,"health");a(this,"storage");a(this,"announcements");a(this,"compliance");a(this,"tickets");a(this,"templates");a(this,"agents");a(this,"personaHistory");a(this,"openapi");a(this,"staff");a(this,"tenants");a(this,"whatsapp");a(this,"laie");a(this,"laieRuntime");a(this,"laieVault");a(this,"flow");a(this,"email");a(this,"pipelines");a(this,"integrations");a(this,"erix");a(this,"dashboard");a(this,"partners");a(this,"waitlist");a(this,"blogs");a(this,"leads");a(this,"onboarding");a(this,"cors");a(this,"clients");this.revenue=new on(e),this.billing=new Ue(e),this.payments=new tn(e),this.credits=new je(e),this.plans=new an(e),this.agencyInvoices=new qe(e),this.flags=new ze(e),this.activityLogs=new De(e),this.auditLogs=new Be(e),this.analytics=new Fe(e),this.health=new ln(e),this.storage=new pn(e),this.announcements=new Me(e),this.compliance=new _e(e),this.tickets=new un(e),this.templates=new dn(e),this.agents=new Ne(e),this.personaHistory=new rn(e),this.openapi=new en(e),this.staff=new cn(e),this.tenants=new gn(e),this.whatsapp=new yn(e),this.laie=new Ye(e),this.laieRuntime=new Je(e),this.laieVault=new Xe(e),this.flow=new Qe(e),this.email=new He(e),this.pipelines=new sn(e),this.integrations=new Ge(e),this.erix=new Ke(e),this.dashboard=new We(e),this.partners=new nn(e),this.waitlist=new mn(e),this.blogs=new Ve(e),this.leads=new Ze(e),this.onboarding=new A(e),this.cors=new ke(e),this.clients=new Ae(e)}},O=class{constructor(e){a(this,"auth");a(this,"users");a(this,"tenants");a(this,"billing");a(this,"support");a(this,"ai");a(this,"admin");a(this,"health");this.auth=new Ie(e),this.users=new _(e),this.tenants=new V(e),this.billing=new $e(e),this.support=new Se(e),this.ai=new Ce(e),this.admin=new j(e),this.health=new Pe(e)}};var E=class extends g{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},fn=class{async constructEvent(e,n,s){if(!n)throw new E("No webhook signature provided");let o=Array.isArray(n)?n[0]:n;o.startsWith("sha256=")&&(o=o.slice(7));try{let c=await import("crypto"),d=c.createHmac("sha256",s).update(e).digest("hex");if(!c.timingSafeEqual(Buffer.from(d),Buffer.from(o)))throw new E("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(c){throw c instanceof E?c:new E(`Webhook payload parsing failed: ${c.message}`)}}};var En=typeof process!="undefined"&&"2.1.5"||"2.0.0";var w=class{constructor(e){a(this,"client");a(this,"socket",null);a(this,"socketPromise",null);a(this,"socketQueue",[]);a(this,"clientCode");a(this,"apiVersion");a(this,"platform");a(this,"product");a(this,"infra");a(this,"webhooks");var f,y,b,x,R,u;if(!e.apiKey)throw new m("API Key is required");this.clientCode=(f=e.clientCode)==null?void 0:f.toUpperCase(),this.apiVersion=(y=e.version)!=null?y:"v1";let n=(b=e.baseUrl)!=null?b:xn,s=Vn(this.apiVersion,n),o=e.socketUrl||n,c=typeof window!="undefined"&&typeof window.document!="undefined",p=c?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",d=c?((x=globalThis.navigator)==null?void 0:x.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown",l={"x-api-key":e.apiKey,"x-client-code":((R=e.clientCode)==null?void 0:R.toUpperCase())||"","Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:En,runtime:p,os:d})};if(e.coreApiKey&&(l["x-core-api-key"]=e.coreApiKey),this.client=Wn.default.create({baseURL:s,headers:l,timeout:(u=e.timeout)!=null?u:3e4}),(0,hn.default)(this.client,{retries:3,retryDelay:hn.default.exponentialDelay,retryCondition:k=>{var W;return hn.default.isNetworkOrIdempotentRequestError(k)||((W=k.response)==null?void 0:W.status)===429},onRetry:(k,W,Dn)=>{var qn,Nn;typeof process!="undefined"&&((qn=process.env)==null?void 0:qn.NODE_ENV)==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${k}/3): ${(Nn=Dn.method)==null?void 0:Nn.toUpperCase()} ${Dn.url}. Reason: ${W.message}`)}}),this.platform=new O(this.client),this.product=new $(this.client),this.infra=new S(this.client),this.webhooks=new fn,this.initSocket(o,e.apiKey,e.clientCode),c){let k={version:En,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=k,window.ecodrix||(window.ecodrix=this)}}initSocket(e,n,s){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:o})=>{this.socket=o(e,{extraHeaders:{"x-api-key":n,"x-client-code":(s==null?void 0:s.toUpperCase())||""}}),this.setupSocket(s);for(let{type:c,args:p}of this.socketQueue)c==="joinRoom"?this.socket.emit("join-room",p[0]):c==="leaveRoom"?this.socket.emit("leave-room",p[0]):c==="on"?this.socket.on(p[0],p[1]):c==="off"?this.socket.off(p[0],p[1]):c==="disconnect"&&this.socket.disconnect();this.socketQueue=[]}),this.socketPromise)}joinRoom(e){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(e){this.socket&&this.socket.on("connect",()=>{e&&this.socket.emit("join-room",e.toUpperCase())})}on(e,n){return this.socket?this.socket.on(e,n):this.socketQueue.push({type:"on",args:[e,n]}),this}disconnect(){this.socket?this.socket.disconnect():this.socketQueue.push({type:"disconnect",args:[]})}off(e,n){return this.socket?this.socket.off(e,n):this.socketQueue.push({type:"off",args:[e,n]}),this}async request(e,n,s,o){var c,p,d;try{return(await this.client.request({method:e,url:n,data:s,params:o})).data}catch(l){throw l.response?new g(((c=l.response.data)==null?void 0:c.message)||((p=l.response.data)==null?void 0:p.error)||"Raw Execution Failed",l.response.status,(d=l.response.data)==null?void 0:d.code):new g(l.message||"Network Error")}}};var Hn={401:m,403:m,429:h};function rt(t){var e,n,s;if(t.response){let o=t.response.status,c=((e=t.response.data)==null?void 0:e.message)||((n=t.response.data)==null?void 0:n.error)||"API Request Failed",p=(s=t.response.data)==null?void 0:s.code,d=Hn[o]||g;throw d===m?new m(c):d===h?new h(c):new g(c,o,p)}throw new g(t.message||"Network Error")}function st(t,e){return t instanceof e}function at(t){return t instanceof m?{message:t.message,status:t.status,code:t.code,type:"AuthenticationError"}:t instanceof h?{message:t.message,status:t.status,code:t.code,type:"RateLimitError"}:t instanceof g?{message:t.message,status:t.status,code:t.code,type:"APIError"}:{message:t.message||"Unknown error",type:"UnknownError"}}var Ln={[m.name]:{shouldRetry:!1,reason:"Authentication errors require fixing credentials, not retrying"},[h.name]:{shouldRetry:!0,maxRetries:3,baseDelay:1e3,backoffMultiplier:2,reason:"Rate limit errors can be retried with exponential backoff"},[g.name]:{shouldRetry:!0,maxRetries:2,baseDelay:500,backoffMultiplier:1.5,reason:"Generic API errors may be transient and worth retrying"}};function it(t){let e=t.constructor.name;return Ln[e]||Ln[g.name]}var ot=w;0&&(module.exports={APIError,AdminOnboarding,AuthenticationError,ConnectInfra,ECODrIx,ECODrIxAPI,ERROR_RETRY_CONFIG,EcodrixError,EmailConnect,ErixChat,ErixProduct,HTTP_STATUS_ERROR_MAP,InfraDomain,LEAD_STATUS_VALUES,Onboarding,Persona,PlatformAdmin,PlatformDomain,PlatformTenants,PlatformUsers,ProductDomain,RateLimitError,StorageInfra,WhatsAppConnect,getErrorDetails,getRetryConfig,handleAPIError,isAPIError});
|
|
1
|
+
"use strict";var nt=Object.create;var M=Object.defineProperty,rt=Object.defineProperties,st=Object.getOwnPropertyDescriptor,it=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertyNames,He=Object.getOwnPropertySymbols,ot=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var pt=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n);var Pe=(n,e,t)=>e in n?M(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,y=(n,e)=>{for(var t in e||(e={}))ze.call(e,t)&&Pe(n,t,e[t]);if(He)for(var t of He(e))ct.call(e,t)&&Pe(n,t,e[t]);return n},k=(n,e)=>rt(n,it(e));var lt=(n,e)=>{for(var t in e)M(n,t,{get:e[t],enumerable:!0})},Ge=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of at(e))!ze.call(n,s)&&s!==t&&M(n,s,{get:()=>e[s],enumerable:!(r=st(e,s))||r.enumerable});return n};var F=(n,e,t)=>(t=n!=null?nt(ot(n)):{},Ge(e||!n||!n.__esModule?M(t,"default",{value:n,enumerable:!0}):t,n)),gt=n=>Ge(M({},"__esModule",{value:!0}),n);var a=(n,e,t)=>Pe(n,typeof e!="symbol"?e+"":e,t);var Ae=function(n,e){this[0]=n,this[1]=e},Qe=(n,e,t)=>{var r=(g,l,h,d)=>{try{var x=t[g](l),w=(l=x.value)instanceof Ae,P=x.done;Promise.resolve(w?l[0]:l).then(m=>w?r(g==="return"?g:"next",l[1]?{done:m.done,value:m.value}:m,h,d):h({value:m,done:P})).catch(m=>r("throw",m,h,d))}catch(m){d(m)}},s=(g,l,h,d)=>p[g]=x=>(l=new Promise((w,P,m)=>(m=()=>r(g,x,w,P),o?o.then(m):m())),d=()=>o===h&&(o=0),o=h=l.then(d,d),l),o,p={};return t=t.apply(n,e),p[pt("asyncIterator")]=()=>p,s("next"),s("throw"),s("return"),p};var Tt={};lt(Tt,{APIError:()=>u,APIResource:()=>i,AiAgent:()=>S,AuthenticationError:()=>f,ConnectInfra:()=>N,ECODrIx:()=>R,ECODrIxAPI:()=>R,ERROR_RETRY_CONFIG:()=>_e,EcodrixError:()=>W,EmailConnect:()=>q,ErixChat:()=>B,ErixProduct:()=>L,HTTP_STATUS_ERROR_MAP:()=>tt,InfraDomain:()=>$,KNOWLEDGE_FILE_TYPES:()=>Xe,Knowledge:()=>I,LEAD_STATUS_VALUES:()=>Ie,Onboarding:()=>v,Persona:()=>C,PlatformDomain:()=>O,PlatformTenants:()=>U,PlatformUsers:()=>K,ProductDomain:()=>E,RateLimitError:()=>b,StorageInfra:()=>V,WhatsAppConnect:()=>_,default:()=>ht,getErrorDetails:()=>yt,getRetryConfig:()=>ft,handleAPIError:()=>dt,isAPIError:()=>mt});module.exports=gt(Tt);var et=F(require("axios"),1),qe=F(require("axios-retry"),1);var ve="https://api.ecodrix.com";function Ye(n="v1",e=ve){return`${e.replace(/\/+$/,"")}/${n}/api`}var W=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},u=class extends W{constructor(t,r,s){super(t);a(this,"status");a(this,"code");this.name="APIError",this.status=r,this.code=s}},f=class extends u{constructor(e="Invalid API Key or Client Code"){super(e,401,"AUTH_FAILED"),this.name="AuthenticationError"}},b=class extends u{constructor(e="Too many requests. Please slow down."){super(e,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};var i=class{constructor(e){a(this,"client",e)}async post(e,t,r){try{let s=this.buildConfig(r);return(await this.client.post(e,t,s)).data}catch(s){this.handleError(s)}}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 s=this.buildConfig(r);return(await this.client.patch(e,t,s)).data}catch(s){this.handleError(s)}}async put(e,t,r){try{let s=this.buildConfig(r);return(await this.client.put(e,t,s)).data}catch(s){this.handleError(s)}}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=y({},e);return e.idempotencyKey&&(t.headers=k(y({},t.headers),{"Idempotency-Key":e.idempotencyKey})),t}handleError(e){var t,r,s;if(e.response){let o=e.response.status,p=((t=e.response.data)==null?void 0:t.message)||((r=e.response.data)==null?void 0:r.error)||"API Request Failed",g=(s=e.response.data)==null?void 0:s.code;switch(o){case 401:throw new f(p);case 403:throw new f(p);case 429:throw new b(p);default:throw new u(p,o,g)}}throw new u(e.message||"Network Error")}};var Ce=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}`)}},H=class extends i{constructor(t){super(t);a(this,"notes");this.notes=new Ce(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:y({},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 z=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 G=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 Q=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 Ie=["open","won","lost","archived"],Y=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:Ie.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}],s=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,...s],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 s=0;s<e.length;s+=t){let p=e.slice(s,s+t).map(l=>this.create(l)),g=await Promise.allSettled(p);for(let l of g)if(l.status==="fulfilled")r.push(l.value);else throw l.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=y({},e);return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/product/erix/crm/leads",{params:t})}listAutoPaging(e){return Qe(this,null,function*(){let t=(e==null?void 0:e.page)||1,r=!0;for(;r;){let s=yield new Ae(this.list(k(y({},e),{page:t}))),o=Array.isArray(s.data)?s.data:s||[];if(o.length===0){r=!1;break}for(let p of o)yield p;s.pagination&&t<s.pagination.pages||!s.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 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 J=class extends i{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var X=class extends i{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){var s,o;let t=await this.retrieve(e),r=Array.isArray((s=t.data)==null?void 0:s.stages)?t.data.stages:[];return{name:`Pipeline: ${((o=t.data)==null?void 0:o.name)||e}`,fields:r.map(p=>({key:p._id,label:p.name,type:"string",required:!0,options:[{label:p.name,value:p._id}],group:"Stages",uiHints:{color:p.color||"#cbd5e1",probability:p.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`,{newName: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 Z=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 ee=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 A=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 h,d,x;let r=(d=(h=t.fileName)!=null?h:e.name)!=null?d:"file",s=e.type||"application/octet-stream",o=await this.post("/infra/storage/files/upload-url",{folder:(x=t.folder)!=null?x:"inbox",filename:r,contentType:s}),{uploadUrl:p,key:g}=o.data,l=await fetch(p,{method:"PUT",headers:{"Content-Type":s},body:e});if(!l.ok)throw new Error(`upload failed (${l.status})`);return await this.post("/infra/storage/files/confirm-upload",{key:g,sizeBytes:e.size}),{key:g,mimeType:s,fileName:r}}};var te=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 ne=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 re=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)}};var se=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 ie=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 sign(e,t,r){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/sign`,r!=null?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 ae=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 oe=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 ce=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 pe=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 le=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,s){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:t,mappings:r,onEmptyVariable:s})}async getVariableManifest(e){var o,p;let t=await this.retrieve(e),r=Array.isArray((o=t.data)==null?void 0:o.components)?t.data.components:[],s=[];for(let g of r)if(g.text){let l=g.text.match(/{{(\d+)}}/g);if(l)for(let h of l){let d=h.replace(/{{|}}/g,"");s.push({key:`var_${d}`,label:`${g.type} Var {{${d}}}`,type:"string",required:!0,group:g.type,description:`Variable placeholder in template ${g.type}`})}}return{name:`Template variables: ${((p=t.data)==null?void 0:p.name)||e}`,fields:s,uiHints:{icon:"Variables",primaryColor:"#059669"}}}};var Je=F(require("axios"),1);var ge=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:s,key:o}=r.data;await Je.default.put(s,e,{headers:{"Content-Type":t.contentType}});let p=e.size||e.byteLength||0;return this.post("/infra/storage/files/confirm-upload",{key:o,sizeBytes:p})}};var ue=class extends i{async create(e){return this.post("/infra/storage/files/folders",{name:e})}},de=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 me=class extends i{async system(){return(await this.get("/health")).data}};var ye=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 v=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 C=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 s;let r=await super.get(`/platform/tenants/persona/${e}/timeline`,{params:t});return(s=r==null?void 0:r.data)!=null?s:{entries:[],hasMore:!1}}async followups(e){var r,s;let t=await super.get(`/platform/tenants/persona/${e}/followups`);return(s=(r=t==null?void 0:t.data)==null?void 0:r.entries)!=null?s:[]}};var Se=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"}},fe=class{constructor(e){a(this,"copilot");this.copilot=new Se(e)}};var Xe=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain","text/markdown","text/csv","text/html","image/png","image/jpeg","image/webp"],I=class extends i{async list(){return this.get("/platform/knowledge/sources")}async addText(e){return this.post("/platform/knowledge/sources",y({kind:"text"},e))}async addUrl(e){return this.post("/platform/knowledge/sources",y({kind:"url"},e))}async addFile(e,t={}){var s,o;let r=await new A(this.client).upload(e,{folder:"knowledge"});return this.post("/platform/knowledge/sources",{kind:"file",key:r.key,mimeType:r.mimeType,title:(o=(s=t.title)!=null?s: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",y({query:e},t?{limit:t}:{}))}};var S=class extends i{async settings(){return this.get("/product/erix/ai/settings")}async updateSettings(e){return this.patch("/product/erix/ai/settings",e)}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){return this.post(`/product/flow/runs/${e}/approve`,{decision:t})}};var he=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 Ee=class extends i{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},$e=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)}},Oe=class extends i{async listPublic(){return this.get("/platform/billing/plans/public")}},De=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)}},Me=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")}},Fe=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)}},Te=class{constructor(e){a(this,"entitlements");a(this,"subscriptions");a(this,"plans");a(this,"checkout");a(this,"user");a(this,"credits");this.entitlements=new Ee(e),this.subscriptions=new $e(e),this.plans=new Oe(e),this.checkout=new De(e),this.user=new Me(e),this.credits=new Fe(e)}};var be=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 xe=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",{})}},we=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}`)}},ke=class extends i{async list(){return this.get("/platform/auth/sessions")}async revoke(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}};var B=class{constructor(e){a(this,"messages");a(this,"conversations");this.messages=new A(e),this.conversations=new ee(e)}},L=class{constructor(e){a(this,"leads");a(this,"pipelines");a(this,"activities");a(this,"analytics");a(this,"scoring");a(this,"payments");a(this,"chat");a(this,"events");a(this,"invoices");a(this,"checkout");a(this,"projects");a(this,"niche");a(this,"documents");a(this,"invoiceExport");a(this,"ai");this.leads=new Y(e),this.pipelines=new X(e),this.activities=new H(e),this.analytics=new z(e),this.scoring=new Z(e),this.payments=new J(e),this.chat=new B(e),this.events=new ne(e),this.invoices=new re(e),this.checkout=new te(e),this.projects=new ie(e),this.niche=new se(e),this.documents=new G(e),this.invoiceExport=new Q(e),this.ai=new S(e)}},E=class{constructor(e){a(this,"erix");this.erix=new L(e)}},q=class{constructor(e){a(this,"config");a(this,"templates");this.config=new pe(e),this.templates=new oe(e)}},_=class{constructor(e){a(this,"templates");this.templates=new le(e)}},N=class{constructor(e){a(this,"email");a(this,"whatsapp");a(this,"meet");a(this,"connections");this.email=new q(e),this.whatsapp=new _(e),this.meet=new ce(e),this.connections=new ae(e)}},V=class{constructor(e){a(this,"files");a(this,"folders");a(this,"media");this.files=new de(e),this.folders=new ue(e),this.media=new ge(e)}},$=class{constructor(e){a(this,"connect");a(this,"storage");this.connect=new N(e),this.storage=new V(e)}},U=class{constructor(e){a(this,"onboarding");a(this,"persona");this.onboarding=new v(e),this.persona=new C(e)}},K=class{constructor(e){a(this,"me");a(this,"members");a(this,"sessions");a(this,"notifications");this.me=new xe(e),this.members=new we(e),this.sessions=new ke(e),this.notifications=new ye(e)}},O=class{constructor(e){a(this,"auth");a(this,"users");a(this,"tenants");a(this,"billing");a(this,"support");a(this,"ai");a(this,"knowledge");a(this,"health");this.auth=new he(e),this.users=new K(e),this.tenants=new U(e),this.billing=new Te(e),this.support=new be(e),this.ai=new fe(e),this.knowledge=new I(e),this.health=new me(e)}};var D=class extends u{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},Re=class{async constructEvent(e,t,r){if(!t)throw new D("No webhook signature provided");let s=Array.isArray(t)?t[0]:t;s.startsWith("sha256=")&&(s=s.slice(7));try{let o=await import("crypto"),g=o.createHmac("sha256",r).update(e).digest("hex");if(!o.timingSafeEqual(Buffer.from(g),Buffer.from(s)))throw new D("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(o){throw o instanceof D?o:new D(`Webhook payload parsing failed: ${o.message}`)}}};var Be=typeof process!="undefined"&&"3.1.0"||"2.0.0";var Ze,Le=(Ze=qe.default.default)!=null?Ze:qe.default,R=class{constructor(e){a(this,"client");a(this,"socket",null);a(this,"socketPromise",null);a(this,"socketQueue",[]);a(this,"clientCode");a(this,"apiVersion");a(this,"platform");a(this,"product");a(this,"infra");a(this,"webhooks");a(this,"lastSeq");a(this,"closed",!1);var d,x,w,P,m,Ne,Ve,Ue;let t=e.proxy;if(!e.apiKey&&!t)throw new f("API Key is required");this.clientCode=(d=e.clientCode)==null?void 0:d.toUpperCase(),this.apiVersion=(x=e.version)!=null?x:"v1";let r=(w=e.baseUrl)!=null?w:ve,s=Ye(this.apiVersion,(P=t==null?void 0:t.url)!=null?P:r),o=e.socketUrl||r,p=typeof window!="undefined"&&typeof window.document!="undefined",g=p?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",l=p?((m=globalThis.navigator)==null?void 0:m.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown",h=k(y({},t?{}:{"x-api-key":e.apiKey,"x-client-code":((Ne=e.clientCode)==null?void 0:Ne.toUpperCase())||""}),{"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:Be,runtime:g,os:l})});if(this.client=et.default.create({baseURL:s,headers:h,timeout:(Ve=e.timeout)!=null?Ve:3e4}),Le(this.client,{retries:3,retryDelay:Le.exponentialDelay,retryCondition:T=>{var j;return Le.isNetworkOrIdempotentRequestError(T)||((j=T.response)==null?void 0:j.status)===429},onRetry:(T,j,Ke)=>{var je,We;typeof process!="undefined"&&((je=process.env)==null?void 0:je.NODE_ENV)==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${T}/3): ${(We=Ke.method)==null?void 0:We.toUpperCase()} ${Ke.url}. Reason: ${j.message}`)}}),this.platform=new O(this.client),this.product=new E(this.client),this.infra=new $(this.client),this.webhooks=new Re,t){if(t.ticket){let T=t.ticket;this.initSocket(o,async()=>({ticket:await T()}))}}else{let T={apiKey:e.apiKey,clientCode:((Ue=e.clientCode)==null?void 0:Ue.toUpperCase())||""};this.initSocket(o,async()=>T,{"x-api-key":T.apiKey,"x-client-code":T.clientCode})}if(p){let T={version:Be,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=T}}initSocket(e,t,r){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:s})=>{this.socket=s(e,{auth:o=>{t().then(p=>o(k(y({},p),{lastSeq:this.lastSeq})),()=>o({lastSeq:this.lastSeq}))},extraHeaders:r}),this.setupSocket();for(let{type:o,args:p}of this.socketQueue)o==="joinRoom"?this.socket.emit("join-room",p[0]):o==="leaveRoom"?this.socket.emit("leave-room",p[0]):o==="on"?this.socket.on(p[0],p[1]):o==="off"?this.socket.off(p[0],p[1]):o==="disconnect"&&this.socket.disconnect();this.socketQueue=[]}),this.socketPromise)}joinRoom(e){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,s;let t=(r=e.at(-1))==null?void 0:r.seq;typeof t=="number"&&t>((s=this.lastSeq)!=null?s:0)&&(this.lastSeq=t)}))}on(e,t){return 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.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,s){var o,p,g;try{return(await this.client.request({method:e,url:t,data:r,params:s})).data}catch(l){throw l.response?new u(((o=l.response.data)==null?void 0:o.message)||((p=l.response.data)==null?void 0:p.error)||"Raw Execution Failed",l.response.status,(g=l.response.data)==null?void 0:g.code):new u(l.message||"Network Error")}}};var tt={401:f,403:f,429:b};function dt(n){var e,t,r;if(n.response){let s=n.response.status,o=((e=n.response.data)==null?void 0:e.message)||((t=n.response.data)==null?void 0:t.error)||"API Request Failed",p=(r=n.response.data)==null?void 0:r.code,g=tt[s]||u;throw g===f?new f(o):g===b?new b(o):new u(o,s,p)}throw new u(n.message||"Network Error")}function mt(n,e){return n instanceof e}function yt(n){return n instanceof f?{message:n.message,status:n.status,code:n.code,type:"AuthenticationError"}:n instanceof b?{message:n.message,status:n.status,code:n.code,type:"RateLimitError"}:n instanceof u?{message:n.message,status:n.status,code:n.code,type:"APIError"}:{message:n.message||"Unknown error",type:"UnknownError"}}var _e={[f.name]:{shouldRetry:!1,reason:"Authentication errors require fixing credentials, not retrying"},[b.name]:{shouldRetry:!0,maxRetries:3,baseDelay:1e3,backoffMultiplier:2,reason:"Rate limit errors can be retried with exponential backoff"},[u.name]:{shouldRetry:!0,maxRetries:2,baseDelay:500,backoffMultiplier:1.5,reason:"Generic API errors may be transient and worth retrying"}};function ft(n){let e=n.constructor.name;return _e[e]||_e[u.name]}var ht=R;0&&(module.exports={APIError,APIResource,AiAgent,AuthenticationError,ConnectInfra,ECODrIx,ECODrIxAPI,ERROR_RETRY_CONFIG,EcodrixError,EmailConnect,ErixChat,ErixProduct,HTTP_STATUS_ERROR_MAP,InfraDomain,KNOWLEDGE_FILE_TYPES,Knowledge,LEAD_STATUS_VALUES,Onboarding,Persona,PlatformDomain,PlatformTenants,PlatformUsers,ProductDomain,RateLimitError,StorageInfra,WhatsAppConnect,getErrorDetails,getRetryConfig,handleAPIError,isAPIError});
|