@ecodrix/erix-api 4.0.1 → 4.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 +4 -4
- package/dist/ts/cjs/index.cjs +1 -1
- package/dist/ts/esm/index.d.ts +9082 -8696
- package/dist/ts/esm/index.js +1 -1
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import Ft from"repl";import{Command as qt}from"commander";import Bt from"dotenv";import u from"picocolors";import Mt from"axios";import Lt from"axios-retry";var Je="https://api.ecodrix.com";function Pt(n="v1",e=Je){return`${e.replace(/\/+$/,"")}/${n}/api`}var Xe=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},x=class extends Xe{status;code;issues;field;constructor(e,t,r){super(e),this.name="APIError",this.status=t,this.code=r}},T=class extends x{constructor(e="Invalid API Key or Client Code",t="AUTH_FAILED",r=401){super(e,r,t),this.name="AuthenticationError"}},Ze=class extends T{constructor(e="You don't have permission to do this.",t="FORBIDDEN"){super(e,t,403),this.name="PermissionError"}},et=class extends x{constructor(e="Too many requests. Please slow down."){super(e,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};function P(n){if(!n?.response)return new x(n?.message||"Network Error");let{status:e,data:t}=n.response,r=t?.message||t?.error||"API Request Failed",i=t?.code??(typeof t?.error=="string"&&/^[A-Z][A-Z0-9_]*$/.test(t.error)?t.error:void 0);switch(e){case 401:return new T(r,i);case 403:return new Ze(r,i);case 429:return new et(r);default:{let o=new x(r,e,i);return Array.isArray(t?.issues)&&(o.issues=t.issues),typeof t?.field=="string"&&(o.field=t.field),o}}}var s=class{constructor(e){this.client=e}client;async post(e,t,r){try{let i=this.buildConfig(r);return(await this.client.post(e,t,i)).data}catch(i){this.handleError(i)}}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 i=this.buildConfig(r);return(await this.client.patch(e,t,i)).data}catch(i){this.handleError(i)}}async put(e,t,r){try{let i=this.buildConfig(r);return(await this.client.put(e,t,i)).data}catch(i){this.handleError(i)}}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={...e};return e.idempotencyKey&&(t.headers={...t.headers,"Idempotency-Key":e.idempotencyKey}),t}handleError(e){throw P(e)}};var L=class extends s{path(e,t=""){return`/product/flow/workflows/${encodeURIComponent(e)}${t}`}async versions(e){return this.get(this.path(e,"/versions"))}async version(e,t){return this.get(this.path(e,`/versions/${encodeURIComponent(t)}`))}async restoreVersion(e,t){return this.post(this.path(e,`/versions/${encodeURIComponent(t)}/restore`))}async testData(e){return this.get(this.path(e,"/test-data"))}async pinTestData(e,t){return this.put(this.path(e,"/test-data"),{runId:t})}async unpinTestData(e){return this.deleteRequest(this.path(e,"/test-data"))}async testRun(e,t={}){return this.post(this.path(e,"/test-run"),t)}async testRunProgress(e,t){return this.get(this.path(e,"/test-run"),{params:{runIds:t.join(",")}})}async copilot(e,t){return this.post(this.path(e,"/copilot"),t)}async live(e){return this.get(this.path(e,"/live"))}async week(e){return this.get(this.path(e,"/week"))}async deleteImpact(e){return this.get(this.path(e,"/delete-impact"))}async remove(e,t={}){return this.deleteRequest(this.path(e,t.stop?"?stop=true":""))}async duplicate(e){return this.post(this.path(e,"/duplicate"))}async retryFailed(e,t={}){return this.post(this.path(e,"/retry-failed"),t)}};var S=class extends s{async list(e={}){return this.get("/product/flow/campaigns",{params:e})}async create(e){return this.post("/product/flow/campaigns",e)}async launch(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/launch`,t)}async retrieve(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}`)}async update(e,t){return this.patch(`/product/flow/campaigns/${encodeURIComponent(e)}`,t)}async test(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/test`,{})}async start(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/start`,t)}async pause(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/pause`,{})}async resume(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/resume`,{})}async stop(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/stop`,{})}async remove(e){return this.deleteRequest(`/product/flow/campaigns/${encodeURIComponent(e)}`)}async duplicate(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/duplicate`,{})}async followUp(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/follow-up`,t)}async checks(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/checks`)}async results(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/results`)}async people(e,t={}){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/people`,{params:t})}};var C="/product/flow/conversations",y=(n,e="")=>`${C}/${encodeURIComponent(n)}${e}`,$=class extends s{async list(e={}){return this.get(C,{params:e})}async create(e){return this.post(C,e)}async retrieve(e){return this.get(y(e))}async update(e,t){return this.patch(y(e),t)}async duplicate(e){return this.post(y(e,"/duplicate"),{})}async archive(e){return this.deleteRequest(y(e))}async publish(e,t={}){return this.post(y(e,"/publish"),t)}async versions(e){return this.get(y(e,"/versions"))}async version(e,t){return this.get(y(e,`/versions/${t}`))}async rollback(e,t){return this.post(y(e,"/rollback"),{version:t})}async try(e,t){return this.post(y(e,"/try"),t)}async tests(e){return this.get(y(e,"/tests"))}async addTest(e,t){return this.post(y(e,"/tests"),t)}async deleteTest(e,t){return this.deleteRequest(y(e,`/tests/${encodeURIComponent(t)}`))}async runTests(e,t={}){return this.post(y(e,"/tests/run"),t)}async deployments(e){return this.get(y(e,"/deployments"))}async allDeployments(){return this.get(`${C}/deployments`)}async deploy(e,t){return this.post(y(e,"/deployments"),t)}async updateDeployment(e,t){return this.patch(`${C}/deployments/${encodeURIComponent(e)}`,t)}async removeDeployment(e){return this.deleteRequest(`${C}/deployments/${encodeURIComponent(e)}`)}async checks(e){return this.get(y(e,"/checks"))}};var E=class extends s{async get(){return super.get("/product/flow/home")}async nav(){return super.get("/product/flow/home/nav")}},O=class extends s{async create(e){return this.post("/product/flow/drafts",e)}},V=class extends s{async status(){return this.get("/product/flow/first-run")}async installPack(e){return this.post(`/product/flow/first-run/packs/${e}`)}},D=class extends s{async list(){return this.get("/product/flow/audiences")}async byId(e){return this.get(`/product/flow/audiences/${encodeURIComponent(e)}`)}async create(e){return this.post("/product/flow/audiences",e)}async update(e,t){return this.patch(`/product/flow/audiences/${encodeURIComponent(e)}`,t)}async remove(e){return this.deleteRequest(`/product/flow/audiences/${encodeURIComponent(e)}`)}async preview(e,t){return this.get(`/product/flow/audiences/${encodeURIComponent(e)}/preview${t?`?channel=${t}`:""}`)}async previewRules(e){return this.post("/product/flow/audiences/preview",e)}};var h="/product/erix/commerce/checkout",k="/product/erix/public/checkout",b=encodeURIComponent,tt=class extends s{async getProduct(e,t){return this.get(`${k}/products/${b(t)}`,{params:{c:e}})}async viewSession(e,t){return this.get(`${k}/sessions/view`,{params:{c:e,t}})}async updateItems(e){let{sessionId:t,...r}=e;return this.post(`${k}/sessions/${b(t)}/items`,r)}async startSession(e){return this.post(`${k}/sessions`,e)}async applyCoupon(e){let{sessionId:t,...r}=e;return this.post(`${k}/sessions/${b(t)}/coupon`,r)}async verify(e){let{sessionId:t,...r}=e;return this.post(`${k}/sessions/${b(t)}/verify`,r)}async placeOrder(e){let{sessionId:t,...r}=e;return this.post(`${k}/sessions/${b(t)}/order`,r)}async verifyRazorpay(e){let{sessionId:t,orderId:r,...i}=e;return this.post(`${k}/sessions/${b(t)}/order/${b(r)}/razorpay`,i)}async orderStatus(e,t){return this.get(`${k}/orders/status`,{params:{c:e,t}})}async confirmCod(e,t){return this.post(`${k}/cod/confirm`,{clientCode:e,token:t})}},nt=class extends s{async create(e){return this.post(`${h}/sessions`,e)}},_=class extends s{buyer;sessions;constructor(e){super(e),this.buyer=new tt(e),this.sessions=new nt(e)}async listProducts(){return this.get(`${h}/products`)}async createProduct(e){return this.post(`${h}/products`,e)}async updateProduct(e,t){return this.patch(`${h}/products/${b(e)}`,t)}async deleteProduct(e){return this.deleteRequest(`${h}/products/${b(e)}`)}async listCoupons(){return this.get(`${h}/coupons`)}async createCoupon(e){return this.post(`${h}/coupons`,e)}async updateCoupon(e,t){return this.patch(`${h}/coupons/${b(e)}`,t)}async deleteCoupon(e){return this.deleteRequest(`${h}/coupons/${b(e)}`)}async listOrders(e){return this.get(`${h}/orders`,{params:e})}async getOrder(e){return this.get(`${h}/orders/${b(e)}`)}async updateOrderStatus(e,t){return this.patch(`${h}/orders/${b(e)}/status`,t)}async getSettings(){return this.get(`${h}/settings`)}async updateSettings(e){return this.put(`${h}/settings`,e)}async createProductLink(e){return this.post(`${h}/links`,e)}};var rt=class extends s{async list(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async create(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async update(e,t){return this.patch(`/product/erix/crm/notes/${e}`,{content:t})}async pin(e,t=!0){return this.patch(`/product/erix/crm/notes/${e}/pin`,{isPinned:t})}async delete(e){return this.deleteRequest(`/product/erix/crm/notes/${e}`)}},N=class extends s{notes;constructor(e){super(e),this.notes=new rt(e)}async timeline(e,t){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:t})}async list(e,t){return this.get(`/product/erix/crm/leads/${e}/activities`,{params:{...t}})}async log(e){return this.post(`/product/erix/crm/leads/${e.leadId}/activities`,e)}async logCall(e,t){return this.post(`/product/erix/crm/leads/${e}/calls`,t)}};var U=class extends s{async overview(e){return this.get("/product/erix/crm/analytics/overview",{params:e})}async funnel(e){return this.get("/product/erix/crm/analytics/funnel",{params:{pipelineId:e}})}async forecast(e){return this.get("/product/erix/crm/analytics/forecast",{params:{pipelineId:e}})}async sources(e){return this.get("/product/erix/crm/analytics/sources",{params:e})}async team(e){return this.get("/product/erix/crm/analytics/team",{params:e})}async heatmap(e){return this.get("/product/erix/crm/analytics/heatmap",{params:e})}async scores(){return this.get("/product/erix/crm/analytics/scores")}async stageTime(e){return this.get("/product/erix/crm/analytics/stage-time",{params:{pipelineId:e}})}async tiered(e){return this.get("/product/erix/crm/analytics/tiered",{params:e})}async summary(e){return this.get("/product/erix/crm/analytics/summary",{params:e})}async whatsapp(e){return this.get("/product/erix/crm/analytics/whatsapp",{params:e})}async revenue(){return this.get("/product/erix/crm/analytics/revenue")}async health(){return this.get("/product/erix/crm/analytics/health")}async payments(){return this.get("/product/erix/crm/analytics/payments")}async reviews(){return this.get("/product/erix/crm/analytics/reviews")}async retention(){return this.get("/product/erix/crm/analytics/retention")}};var M=class extends s{async getChecklist(e){return this.get(`/product/erix/crm/documents/checklist/${e}`)}async createChecklist(e,t){return this.post(`/product/erix/crm/documents/checklist/${e}`,{templateNiche:t})}async markReceived(e,t,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 F=class extends s{async csv(e){return this.get("/product/erix/commerce/invoices/export/csv",{params:e})}async tally(e){return this.get("/product/erix/commerce/invoices/export/tally",{params:e})}async zoho(e){return this.get("/product/erix/commerce/invoices/export/zoho",{params:e})}};var Dt=["open","won","lost","archived"],q=class extends s{async create(e){return this.post("/product/erix/crm/leads",e)}async describe(){let e=await this.fields(),t=Array.isArray(e.data)?e.data:[],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:Dt.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}],i=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,...i],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 i=0;i<e.length;i+=t){let p=e.slice(i,i+t).map(d=>this.create(d)),m=await Promise.allSettled(p);for(let d of m)if(d.status==="fulfilled")r.push(d.value);else throw d.reason}return r}async import(e,t={}){return this.post("/product/erix/crm/leads/import",{leads:e,...t})}async bulkUpsert(e){return this.import(e)}async list(e){let t={...e};return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/product/erix/crm/leads",{params:t})}async*listAutoPaging(e){let t=e?.page||1,r=!0;for(;r;){let i=await this.list({...e,page:t}),o=Array.isArray(i.data)?i.data:i||[];if(o.length===0){r=!1;break}for(let p of o)yield p;i.pagination&&t<i.pagination.pages||!i.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:null})}async move(e,t){return this.patch(`/product/erix/crm/leads/${e}/move`,{stageId:t})}async convert(e,t,r){return this.post(`/product/erix/crm/leads/${e}/convert`,{outcome:t,reason:r})}async tags(e,t){return this.patch(`/product/erix/crm/leads/${e}/tags`,t)}async recalculateScore(e){return this.post(`/product/erix/crm/leads/${e}/score`,{})}async updateMetadata(e,t){return this.patch(`/product/erix/crm/leads/${e}/metadata`,t)}async fields(){return this.get("/product/erix/crm/fields")}async notes(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async activities(e,t){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:t})}async createNote(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async updateNote(e,t,r){return this.patch(`/product/erix/crm/notes/${t}`,r)}async deleteNote(e,t){return this.deleteRequest(`/product/erix/crm/notes/${t}`)}async delete(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async export(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/export`)}async erase(e){return this.post(`/product/erix/crm/leads/${encodeURIComponent(e)}/erase`,{confirm:"ERASE"})}async bulkArchive(e){return this.patch("/product/erix/crm/leads/bulk-archive",{ids:e})}async bulkDelete(e){return this.deleteRequest("/product/erix/crm/leads",{data:{ids:e}})}async archive(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async profile(e){return this.get(`/product/erix/crm/leads/${e}/profile`)}async invoices(e){return this.get(`/product/erix/crm/leads/${e}/invoices`)}async projects(e){return this.get(`/product/erix/crm/leads/${e}/projects`)}async conversations(e){return this.get(`/product/erix/crm/leads/${e}/conversations`)}async meetings(e){return this.get(`/product/erix/crm/leads/${e}/meetings`)}async flowRuns(e){return this.get(`/product/erix/crm/leads/${e}/flow-runs`)}async merge(e,t){return this.post("/product/erix/crm/leads/merge",{primaryId:e,secondaryId:t})}async duplicates(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/duplicates`)}};var B=class extends s{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var K=class extends s{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){let t=await this.retrieve(e),r=Array.isArray(t.data?.stages)?t.data.stages:[];return{name:`Pipeline: ${t.data?.name||e}`,fields:r.map(i=>({key:i._id,label:i.name,type:"string",required:!0,options:[{label:i.name,value:i._id}],group:"Stages",uiHints:{color:i.color||"#cbd5e1",probability:i.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/product/erix/crm/pipelines",e)}async retrieve(e){return this.get(`/product/erix/crm/pipelines/${e}`)}async update(e,t){return this.patch(`/product/erix/crm/pipelines/${e}`,t)}async setDefault(e){return this.patch(`/product/erix/crm/pipelines/${e}/default`,{})}async duplicate(e,t){return this.post(`/product/erix/crm/pipelines/${e}/duplicate`,{name:t})}async archive(e){return this.patch(`/product/erix/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/product/erix/crm/pipelines/${e}`)}async checkInUse(e){return this.get(`/product/erix/crm/pipelines/${e}/in-use`)}async board(e){return this.get(`/product/erix/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/product/erix/crm/pipelines/${e}/forecast`)}async addStage(e,t){return this.post(`/product/erix/crm/pipelines/${e}/stages`,t)}async reorderStages(e,t){return this.patch(`/product/erix/crm/pipelines/${e}/stages/reorder`,{order:t})}async updateStage(e,t){return this.patch(`/product/erix/crm/stages/${e}`,t)}async deleteStage(e,t){return this.deleteRequest(`/product/erix/crm/stages/${e}`,{data:t?{moveLeadsToStageId:t}:void 0})}};var j=class extends s{async getConfig(){return this.get("/product/erix/crm/scoring")}async updateConfig(e){return this.patch("/product/erix/crm/scoring",e)}async recalculate(e){return this.post(`/product/erix/crm/scoring/${e}/recalculate`,{})}async preview(e){return this.get(`/product/erix/crm/scoring/preview/${e}`)}};var H=class extends s{async trigger(e){return this.post("/product/erix/events/trigger",e)}async listCustomEvents(){return this.get("/product/flow/config/triggers")}async createCustomEvent(e){return this.post("/product/flow/config/triggers",e)}async deleteCustomEvent(e){return this.deleteRequest(`/product/flow/config/triggers/${e}`)}};var W=class extends s{async list(e){return this.get("/product/erix/commerce/invoices",{params:e})}async getInvoice(e){return this.get(`/product/erix/commerce/invoices/${e}`)}async create(e){return this.post("/product/erix/commerce/invoices",e)}async update(e,t){return this.patch(`/product/erix/commerce/invoices/${e}`,t)}async void(e){return this.post(`/product/erix/commerce/invoices/${e}/void`,{})}async sendViaWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${e}/send-whatsapp`,{})}async getSettings(){return this.get("/product/erix/commerce/settings")}async updateSettings(e){return this.put("/product/erix/commerce/settings",e)}async paymentLink(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payment-link`,{})}async recordPayment(e,t){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payments`,t)}async sendWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-whatsapp`,{})}async sendEmail(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-email`,{})}};var G=class extends s{async workflowPacks(){return this.get("/product/erix/crm/niche/workflow-packs")}async workflowPackDetail(e){return this.get(`/product/erix/crm/niche/workflow-packs/${e}`)}async installWorkflowPack(e){return this.post(`/product/erix/crm/niche/workflow-packs/${e}/install`)}async templateSuggestions(){return this.get("/product/erix/crm/niche/template-suggestions")}};var Q=class extends s{async list(e){return this.get(`/product/erix/commerce/projects/${e}/documents`)}async upload(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents`,t)}async toggleSignature(e,t,r){return this.patch(`/product/erix/commerce/projects/${e}/documents/${t}/signature`,{required:r})}async addSigner(e,t,r){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/signers`,r)}async decline(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/decline`,{})}async stampSign(e,t,r){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/stamp-sign`,r)}};var z=class extends s{async list(e){return this.get("/platform/inbox/conversations",{params:e})}async create(e){return this.post("/platform/inbox/conversations",{address:e.phone,channel:e.channel??"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 R=class extends s{async send(e){if(e.conversationId)return this.post(`/platform/inbox/conversations/${e.conversationId}/messages`,{text:e.text,media:e.media});if(!e.to)throw new Error("send: conversationId or to is required");if(e.media)throw new Error("send: media goes to an inbox thread (conversationId)");return this.post("/infra/connect/send/whatsapp",{phone:e.to,text:e.text})}async sendTemplate(e){return this.post("/infra/connect/send/whatsapp",{phone:e.to,templateName:e.templateName,language:e.language,variables:e.variables})}async star(e,t){return this.post(`/platform/inbox/messages/${e}/star`,{starred:t})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async upload(e,t={}){let r=t.fileName??e.name??"file",i=e.type||"application/octet-stream",o=await this.post("/infra/storage/files/upload-url",{folder:t.folder??"inbox",filename:r,contentType:i}),{uploadUrl:p,key:m}=o.data,d=await fetch(p,{method:"PUT",headers:{"Content-Type":i},body:e});if(!d.ok)throw new Error(`upload failed (${d.status})`);return await this.post("/infra/storage/files/confirm-upload",{key:m,sizeBytes:e.size}),{key:m,mimeType:i,fileName:r}}};var Y=class extends s{async providers(){return this.get("/infra/connect/providers")}async list(){return this.get("/infra/connect/connections")}async get_(e){return this.get(`/infra/connect/connections/${e}`)}async connect(e,t){return this.post(`/infra/connect/connections/${e}/connect`,t)}async configure(e,t){return this.put(`/infra/connect/connections/${e}/configure`,t)}async configureWebchat(e){return this.configure("webchat",{method:"domain",config:e})}async webchatSettings(){return this.get("/infra/connect/connections/webchat/settings")}async removeWebchatDomain(e){return this.deleteRequest(`/infra/connect/connections/webchat/domains/${encodeURIComponent(e)}`)}async disconnect(e){return this.post(`/infra/connect/connections/${e}/disconnect`,{})}async reveal(e){return this.post(`/infra/connect/connections/${e}/reveal`,{})}async test(e){return this.post(`/infra/connect/connections/${e}/test`,{})}async checkNow(e){return this.post(`/infra/connect/connections/${e}/health/check`,{})}async googleConnectUrl(){return this.post("/infra/connect/google/connect-url",{})}async moveChannel(e,t){return this.post(`/infra/connect/${e}/move`,{ticket:t})}async requestChannelRelease(e,t){return this.post(`/infra/connect/${e}/release-request`,{ticket:t})}async channelReleaseRequest(e){return this.get(`/infra/connect/${e}/release-request`)}async cancelChannelRelease(e){return this.deleteRequest(`/infra/connect/${e}/release-request`)}async createPaymentLink(e){return this.post("/infra/connect/connections/payments/payment-link",e)}};var J=class extends s{async sendTest(e){return this.post("/infra/connect/email/test",{to:e})}async listTemplates(e){return this.get("/infra/connect/email/templates",{params:e})}async getTemplate(e){return this.get(`/infra/connect/email/templates/${e}`)}async createTemplate(e){return this.post("/infra/connect/email/templates",e)}async updateTemplate(e,t){return this.put(`/infra/connect/email/templates/${e}`,t)}async deleteTemplate(e,t=!1){return this.deleteRequest(`/infra/connect/email/templates/${e}`,{params:{force:t}})}async previewTemplate(e,t){return this.post(`/infra/connect/email/templates/${e}/preview`,t)}};var X=class extends s{async create(e){return this.post("/infra/connect/meet",e)}async list(e){return this.get("/infra/connect/meet",{params:e})}async retrieve(e){return this.get(`/infra/connect/meet/${e}`)}async update(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async reschedule(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async delete(e){return this.update(e,{status:"cancelled"})}};var Z=class extends s{async getConfig(){return this.get("/infra/connect/email/config")}async initDomainVerification(e){return this.post("/infra/connect/email/config/ses/domain",{domain:e})}async saveEmailConfig(e){return this.post("/infra/connect/email/config/ses/config",e)}async checkSesVerification(){return this.get("/infra/connect/email/config/ses/verify")}async removeSesIdentity(){return this.deleteRequest("/infra/connect/email/config/ses/domain")}async sendTest(e){return this.post("/infra/connect/email/config/test",{toEmail:e})}async saveAdvancedConfig(e){return this.post("/infra/connect/email/config/advanced",e)}async getHealth(){return this.get("/infra/connect/email/config/health")}async fixDmarc(){return this.post("/infra/connect/email/config/ses/fix-dmarc",{})}async listProviders(){return this.get("/infra/connect/email/config/providers")}};var ee=class extends s{async list(e){return this.get("/infra/connect/whatsapp/templates",{params:e})}async sync(){return this.post("/infra/connect/whatsapp/templates/sync",{})}async retrieve(e){return this.get(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}`)}async create(e){return this.post("/infra/connect/whatsapp/templates",e)}async update(e,t){return this.put(`/infra/connect/whatsapp/templates/${e}`,t)}async fix(e){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/fix`,{})}async resubmit(e,t){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/resubmit`,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,i){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:t,mappings:r,onEmptyVariable:i})}async getVariableManifest(e){let t=await this.retrieve(e),r=Array.isArray(t.data?.components)?t.data.components:[],i=[];for(let o of r)if(o.text){let p=o.text.match(/{{(\d+)}}/g);if(p)for(let m of p){let d=m.replace(/{{|}}/g,"");i.push({key:`var_${d}`,label:`${o.type} Var {{${d}}}`,type:"string",required:!0,group:o.type,description:`Variable placeholder in template ${o.type}`})}}return{name:`Template variables: ${t.data?.name||e}`,fields:i,uiHints:{icon:"Variables",primaryColor:"#059669"}}}};var g=encodeURIComponent,a="/product/laie",te=class extends s{async list(){return this.get(`${a}/packs`)}async byId(e){return this.get(`${a}/packs/${g(e)}`)}},ne=class extends s{async catalog(e={}){return this.get(`${a}/signals/catalog`,{params:e})}async list(e={}){return this.get(`${a}/signals`,{params:e})}},re=class extends s{async find(e){return this.post(`${a}/tools/find`,e)}async collect(e){return this.post(`${a}/tools/collect`,e)}async enrich(e){return this.post(`${a}/tools/enrich`,e)}async verify(e){return this.post(`${a}/tools/verify`,e)}async qualify(e){return this.post(`${a}/tools/qualify`,e)}async store(e){return this.post(`${a}/tools/store`,e)}async use(e){return this.post(`${a}/tools/use`,e)}async verifyEmail(e){return this.post(`${a}/tools/verify-email`,{emails:e})}async websiteLookup(e){return this.post(`${a}/tools/website-lookup`,{url:e})}},se=class extends s{async list(){return this.get(`${a}/campaigns`)}async create(e){return this.post(`${a}/campaigns`,e)}async byId(e){return this.get(`${a}/flows/${g(e)}`)}async settings(e){return this.get(`${a}/campaigns/${g(e)}/settings`)}async updateSettings(e,t){return this.patch(`${a}/campaigns/${g(e)}/settings`,t)}async signals(e){return this.get(`${a}/campaigns/${g(e)}/signals`)}async setSignals(e,t){return this.put(`${a}/campaigns/${g(e)}/signals`,t)}},ie=class extends s{async start(e){return this.post(`${a}/campaigns/${g(e)}/runs`)}async list(e,t={}){return this.get(`${a}/campaigns/${g(e)}/runs`,{params:t})}async byId(e,t){return this.get(`${a}/campaigns/${g(e)}/runs/${g(t)}`)}async changes(e,t,r={}){return this.get(`${a}/campaigns/${g(e)}/runs/${g(t)}/changes`,{params:r})}async cancel(e,t){return this.post(`${a}/campaigns/${g(e)}/runs/${g(t)}/cancel`)}async quality(e){return this.get(`${a}/jobs/${g(e)}/quality`)}},oe=class extends s{async list(e={}){let{importedToCrm:t,...r}=e;return this.get(`${a}/leads`,{params:{...r,...t!==void 0&&{importedToCrm:String(t)}}})}async byId(e){return this.get(`${a}/leads/${g(e)}`)}async update(e,t){return this.patch(`${a}/leads/${g(e)}`,t)}async notes(e){return this.get(`${a}/leads/${g(e)}/notes`)}async addNote(e,t){return this.post(`${a}/leads/${g(e)}/notes`,t)}async generateKit(e){return this.post(`${a}/leads/${g(e)}/generate-kit`)}async pipelineSummary(){return this.get(`${a}/leads/pipeline-summary`)}async bulkContacted(e,t){return this.post(`${a}/leads/bulk/contacted`,{leadIds:e,channel:t})}async bulkTag(e,t){return this.post(`${a}/leads/bulk/tag`,{leadIds:e,tags:t})}async bulkDelete(e){return this.post(`${a}/leads/bulk/delete`,{leadIds:e})}async bulkExport(e,t="json"){return t==="csv"?this.post(`${a}/leads/bulk/export`,{leadIds:e,format:t},{responseType:"text"}):this.post(`${a}/leads/bulk/export`,{leadIds:e,format:t})}},ae=class extends s{async pipelines(){return this.get(`${a}/import/pipelines`)}async crm(e){return this.post(`${a}/import/crm`,e)}},ce=class extends s{async enrich(e){return this.post(`${a}/lists/enrich`,e)}},le=class extends s{async dsr(e){return this.post(`${a}/compliance/dsr`,e)}async report(e={}){return this.get(`${a}/compliance/report`,{params:e})}},ue=class extends s{async map(e={}){return this.get(`${a}/market-map`,{params:e})}async forCampaign(e){return this.get(`${a}/campaigns/${g(e)}/market-map`)}async refresh(e={}){return this.post(`${a}/market-map/refresh`,e)}},pe=class extends s{async weights(e={}){return this.get(`${a}/learning/weights`,{params:e})}async outcomes(e={}){return this.get(`${a}/learning/outcomes`,{params:e})}},ge=class extends s{async preview(e){return this.post(`${a}/lookalikes/preview`,e)}async create(e){return this.post(`${a}/lookalikes`,e)}async list(e={}){return this.get(`${a}/lookalikes`,{params:e})}async byId(e){return this.get(`${a}/lookalikes/${g(e)}`)}async rank(e,t={}){return this.get(`${a}/lookalikes/${g(e)}/rank`,{params:t})}},de=class extends s{async status(){return this.get(`${a}/freshness`)}},me=class extends s{async start(e){return this.post(`${a}/audit`,e)}async byId(e){return this.get(`${a}/audit/${g(e)}`)}};import _t from"axios";var ye=class extends s{async getUsage(){return this.get("/infra/storage/files/usage")}async createFolder(e){return this.post("/infra/storage/files/folders",{name:e})}async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async aiDescribe(e){return this.post("/infra/storage/files/ai/describe",{key:e})}async upload(e,t){let r=await this.post("/infra/storage/files/upload-url",t),{uploadUrl:i,key:o}=r.data;await _t.put(i,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 he=class extends s{async list(){return this.get("/infra/connect/facebook/lead-forms")}async subscribe(){return this.post("/infra/connect/facebook/lead-forms/subscribe",{})}async setEnabled(e,t){return this.put(`/infra/connect/facebook/lead-forms/${encodeURIComponent(e)}`,{enabled:t})}async importLast24Hours(e){return this.post(`/infra/connect/facebook/lead-forms/${encodeURIComponent(e)}/import-last-24h`,{})}};var I=encodeURIComponent,st=class extends s{get flow(){return new S(this.client)}list(e={}){return this.flow.list(e)}retrieve(e){return this.flow.retrieve(e)}create(e){return this.flow.create(e)}launch(e,t={}){return this.flow.launch(e,t)}start(e,t={}){return this.flow.start(e,t)}pause(e){return this.flow.pause(e)}resume(e){return this.flow.resume(e)}stop(e){return this.flow.stop(e)}costPreview(e){return this.get(`/product/flow/campaigns/${I(e)}/voice-preview`)}counters(e){return this.get(`/infra/connect/voice/campaigns/${I(e)}/counters`)}approval(e){return this.get(`/infra/connect/voice/campaigns/${I(e)}/approval`)}requestApproval(e){return this.post(`/infra/connect/voice/campaigns/${I(e)}/approval/request`,{})}},be=class extends s{campaigns;constructor(e){super(e),this.campaigns=new st(e)}status(){return this.get("/infra/connect/voice/status")}setup(){return this.get("/infra/connect/voice/setup")}setupNumbers(){return this.get("/infra/connect/voice/setup/numbers")}kycUploadUrl(e){return this.post("/infra/connect/voice/setup/kyc/upload-url",e)}submitKyc(e){return this.post("/infra/connect/voice/setup/kyc",e)}pickNumber(e){return this.post("/infra/connect/voice/setup/number",{number:e})}askForNumber(){return this.post("/infra/connect/voice/setup/number/request",{})}goLive(){return this.post("/infra/connect/voice/setup/go-live",{})}agent(){return this.get("/infra/connect/voice/agent")}skills(){return this.get("/infra/connect/voice/skills")}voices(e){return this.get(`/infra/connect/voice/voices?language=${encodeURIComponent(e)}`)}saveAgent(e){return this.put("/infra/connect/voice/agent",e)}async preview(e={}){try{return(await this.client.post("/infra/connect/voice/preview",e,{responseType:"arraybuffer"})).data}catch(t){let r=t?.response?.data;if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))try{t.response.data=JSON.parse(new TextDecoder().decode(r))}catch{t.response.data=void 0}throw P(t)}}lines(){return this.get("/infra/connect/voice/lines")}activity(){return this.get("/infra/connect/voice/activity")}calls(e={}){return this.get("/infra/connect/voice/calls",{params:e})}call(e){return this.get(`/infra/connect/voice/calls/${I(e)}`)}callWithAI(e){return this.post("/infra/connect/voice/calls",e)}checkCallWithAI(e){return this.post("/infra/connect/voice/calls/check",e)}callMyPhone(e={}){return this.post("/infra/connect/voice/calls/my-phone",e)}testCall(e={}){return this.post("/infra/connect/voice/test-call",e)}};var fe=class extends s{async list(){return this.get("/product/seo/projects")}async create(e){return this.post("/product/seo/projects",e)}async byId(e){return this.get(`/product/seo/projects/${e}`)}async update(e,t){return this.patch(`/product/seo/projects/${e}`,t)}async remove(e){return this.deleteRequest(`/product/seo/projects/${e}`)}async crawl(e){return this.post(`/product/seo/projects/${e}/crawl`)}async crawlCompetitor(e,t){return this.post(`/product/seo/projects/${e}/competitors/crawl`,{domain:t})}},xe=class extends s{async start(e){return this.post("/product/seo/audits",e)}async list(e={}){return this.get("/product/seo/audits",{params:e})}async compare(e){return this.post("/product/seo/audits/compare",e)}async byId(e){return this.get(`/product/seo/audits/${e}`)}async resume(e){return this.post(`/product/seo/audits/${e}/resume`)}async pages(e,t={}){return this.get(`/product/seo/audits/${e}/pages`,{params:t})}async issues(e){return this.get(`/product/seo/audits/${e}/issues`)}async links(e){return this.get(`/product/seo/audits/${e}/links`)}async export(e,t="json"){return this.get(`/product/seo/audits/${e}/export`,{params:{format:t},responseType:"text"})}},ke=class extends s{async keywords(e,t={}){return this.get(`/product/seo/audits/${e}/keywords`,{params:t})}async contentGap(e){return this.post("/product/seo/audits/content-gap",e)}async search(e){return this.post("/product/seo/audits/search",e)}async backlinks(e){return this.get("/product/seo/audits/backlinks",{params:e})}async domain(e){return this.get(`/product/seo/audits/domains/${encodeURIComponent(e)}`)}},we=class extends s{async check(e){return this.post(`/product/seo/search-console/${e}/check`)}async importNow(e){return this.post(`/product/seo/search-console/${e}/import`)}async status(e){return this.get(`/product/seo/search-console/${e}/status`)}async queries(e,t={}){return this.get(`/product/seo/search-console/${e}/queries`,{params:t})}async pages(e,t={}){return this.get(`/product/seo/search-console/${e}/pages`,{params:t})}async trend(e,t={}){return this.get(`/product/seo/search-console/${e}/trend`,{params:t})}},ve=class extends s{async keywords(e){return this.get(`/product/seo/ranks/${e}/keywords`)}async add(e,t,r={}){return this.post(`/product/seo/ranks/${e}/keywords`,{queries:t,...r})}async visibility(e,t={}){return this.get(`/product/seo/ranks/${e}/visibility`,{params:t})}async competitors(e){return this.get(`/product/seo/ranks/${e}/competitors`)}async gap(e,t={}){return this.get(`/product/seo/ranks/${e}/gap`,{params:t})}async remove(e,t){return this.deleteRequest(`/product/seo/ranks/${e}/keywords/${t}`)}async checkNow(e,t){return this.post(`/product/seo/ranks/${e}/keywords/${t}/check`)}async history(e,t,r={}){return this.get(`/product/seo/ranks/${e}/keywords/${t}/history`,{params:r})}async changes(e){return this.get(`/product/seo/ranks/${e}/changes`)}},Te=class extends s{async checkNow(e){return this.post(`/product/seo/local/${e}/check`)}async latest(e){return this.get(`/product/seo/local/${e}`)}async history(e,t={}){return this.get(`/product/seo/local/${e}/history`,{params:t})}async startGrid(e,t={}){return this.post(`/product/seo/local/${e}/grid`,t)}async grid(e){return this.get(`/product/seo/local/${e}/grid`)}async grids(e,t={}){return this.get(`/product/seo/local/${e}/grids`,{params:t})}},Se=class extends s{async byProject(e){return this.get(`/product/seo/reports/${e}`)}async export(e,t="csv"){return this.get(`/product/seo/reports/${e}/export`,{params:{format:t},responseType:"text"})}async pdf(e,t={}){return this.get(`/product/seo/reports/${e}/pdf`,{params:t,responseType:"arraybuffer"})}async generate(e,t={}){return this.post(`/product/seo/reports/${e}/generate`,t)}async history(e,t={}){return this.get(`/product/seo/reports/${e}/history`,{params:t})}async changes(e){return this.get(`/product/seo/reports/${e}/changes`)}},Ce=class extends s{async seed(e,t,r="en"){return this.post(`/product/seo/research/${e}/seed`,{seed:t,lang:r})}async fromSearchConsole(e){return this.post(`/product/seo/research/${e}/from-search-console`)}async ideas(e,t={}){return this.get(`/product/seo/research/${e}/ideas`,{params:t})}async analyze(e,t){return this.post(`/product/seo/research/${e}/ideas/${t}/analyze`)}};var Re=class extends s{async releases(){return this.get("/product/seo/backlinks/releases")}async strength(e){return this.get("/product/seo/backlinks/strength",{params:{domains:e.join(",")}})}async overview(e){return this.get(`/product/seo/backlinks/${e}`)}async referring(e,t){return this.get(`/product/seo/backlinks/${e}/referring`,{params:t})}async changes(e,t){return this.get(`/product/seo/backlinks/${e}/changes`,{params:t})}},Ae=class extends s{async checkNow(e){return this.post(`/product/seo/performance/${e}/check`)}async latest(e){return this.get(`/product/seo/performance/${e}`)}async history(e,t={}){return this.get(`/product/seo/performance/${e}/history`,{params:t})}},Ie=class extends s{async create(e){return this.post("/product/seo/briefs",e)}async byId(e){return this.get(`/product/seo/briefs/${e}`)}async list(e,t={}){return this.get("/product/seo/briefs",{params:{projectId:e,...t}})}};var Nt=35e3,Pe=class extends s{async claim(e,t){let r=await this.post("/infra/serp/collector/claim",{collectorId:e,kinds:t},{timeout:Nt});return(r&&typeof r=="object"?r.data:null)??null}async result(e){return this.post("/infra/serp/collector/result",e)}async heartbeat(e,t){return this.post("/infra/serp/collector/heartbeat",{collectorId:e,...t})}};var Le=class extends s{async create(e){return this.post("/infra/storage/files/folders",{name:e})}},$e=class extends s{async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async getUploadUrl(e){return this.post("/infra/storage/files/upload-url",e)}async confirmUpload(e){return this.post("/infra/storage/files/confirm-upload",e)}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}};var Ee=class extends s{async settings(){return this.get("/product/erix/ai/settings")}async updateSettings(e){return this.patch("/product/erix/ai/settings",e)}async outcomes(e={}){return this.get("/product/erix/ai/outcomes",{params:e})}async reviews(e){return this.get(`/product/erix/ai/reviews${e?`?status=${e}`:""}`)}async review(e,t,r){return this.post(`/product/erix/ai/reviews/${encodeURIComponent(e)}`,{verdict:t,...r?{note:r}:{}})}async suggestion(e){return this.get(`/product/erix/ai/suggestion/${e}`)}async approveAction(e){return this.post(`/product/erix/ai/suggestion/${e}/approve-action`,{})}async markSent(e,t,r){return this.post(`/product/erix/ai/suggestion/${e}/send`,{text:t,confidence:r})}async dismiss(e){return this.post(`/product/erix/ai/suggestion/${e}/dismiss`,{})}async approvals(){return this.get("/product/flow/approvals")}async agents(){return this.get("/product/flow/agents")}async agent(e){return this.get(`/product/flow/agents/${encodeURIComponent(e)}`)}async tryAgent(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/try`,t)}async agentTemplates(){return this.get("/product/flow/agents/templates")}async createAgent(e){return this.post("/product/flow/agents",e)}async updateAgent(e,t){return this.patch(`/product/flow/agents/${encodeURIComponent(e)}`,t)}async deleteAgent(e){return this.deleteRequest(`/product/flow/agents/${encodeURIComponent(e)}`)}async agentAutomation(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/automation`,{trigger:t})}async decideRun(e,t,r){return this.post(`/product/flow/runs/${encodeURIComponent(e)}/approve`,{decision:t,...r&&{nodeId:r}})}};var Oe=class extends s{async system(){return(await this.get("/health")).data}};var Ve=class extends s{async listAlerts(e){return this.get("/platform/users/notifications",{params:e})}async dismissAlert(e){return this.patch(`/platform/users/notifications/${e}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/platform/users/notifications/dismiss-all")}};var De=class extends s{async global(e){return this.post("/platform/tenants/onboarding/global",e)}async complete(e){return this.post("/platform/tenants/onboarding/complete",e)}};var _e=class extends s{async get(e){return super.get(`/platform/tenants/persona/${e}`)}async reinforce(e){return this.post(`/platform/tenants/persona/${e.productId}/reinforce`,e)}async confidence(e){return super.get(`/platform/tenants/persona/${e}/confidence`,{params:{productId:e}})}async timeline(e,t){return(await super.get(`/platform/tenants/persona/${e}/timeline`,{params:t}))?.data??{entries:[],hasMore:!1}}async followups(e){return(await super.get(`/platform/tenants/persona/${e}/followups`))?.data?.entries??[]}};var it=class extends s{async chatSync(e){return this.post("/platform/ai/copilot/chat/sync",e)}async confirm(e){return this.post("/platform/ai/copilot/confirm",e)}async listSessions(){return this.get("/platform/ai/copilot/sessions")}async getSession(e){return this.get(`/platform/ai/copilot/sessions/${e}`)}async deleteSession(e){return this.deleteRequest(`/platform/ai/copilot/sessions/${e}`)}chatStreamUrl(){return"/platform/ai/copilot/chat"}},Ne=class{copilot;constructor(e){this.copilot=new it(e)}};var Ue=class extends s{async register(e){return this.post("/platform/auth/register",e)}async login(e){return this.post("/platform/auth/login",e)}async logout(e){return this.post("/platform/auth/logout",e)}async logoutAll(e){return this.post("/platform/auth/logout-all",e)}async validateSession(e){return this.post("/platform/auth/session/validate",e)}async listSessions(){return this.get("/platform/auth/sessions")}async revokeSession(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}async requestPasswordOtp(e){return this.post("/platform/auth/password/request-otp",e)}async setPassword(e){return this.post("/platform/auth/password/set",e)}async changePassword(e){return this.post("/platform/auth/password/change",e)}async forgotPassword(e){return this.post("/platform/auth/forgot",e)}async resetPassword(e){return this.post("/platform/auth/reset",e)}async linkOAuth(e){return this.post("/platform/auth/oauth-link",e)}async getInvitation(e){return this.get(`/platform/auth/invitations/${e}`)}async acceptInvitation(e,t){return this.post(`/platform/auth/invitations/${e}/accept`,t)}};var ot=class extends s{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},at=class extends s{async upgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/upgrade",e)}async downgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/downgrade",e)}async cancel(e){return this.post("/platform/billing/subscriptions/subscriptions/cancel",e)}},ct=class extends s{list(){return this.get("/platform/billing/addons")}add(e,t){return this.post(`/platform/billing/addons/${encodeURIComponent(e)}/add`,t===void 0?{}:{quantity:t})}remove(e){return this.post(`/platform/billing/addons/${encodeURIComponent(e)}/remove`)}overage(){return this.get("/platform/billing/overage")}setOverage(e){return this.put("/platform/billing/overage",e)}},lt=class extends s{async listPublic(){return this.get("/platform/billing/plans/public")}},ut=class extends s{async plans(){return this.get("/platform/billing/checkout/plans")}async proration(e,t){return this.get("/platform/billing/checkout/proration",{params:{planId:e,billingCycle:t}})}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)}},pt=class extends s{async transactions(){return this.get("/platform/billing/user/transactions")}async transactionInvoice(e){return this.get(`/platform/billing/user/transactions/${encodeURIComponent(e)}/invoice`)}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")}},gt=class extends s{async balance(){return this.get("/platform/billing/credits/balance")}async transactions(){return this.get("/platform/billing/credits/transactions")}async packs(){return this.get("/platform/billing/credits/packs")}async topupOrder(e){return this.post("/platform/billing/credits/topup/order",e)}async verifyTopup(e){return this.post("/platform/billing/credits/topup/verify",e)}async setAutoTopup(e){return this.patch("/platform/billing/credits/auto-topup",e)}async setSpendCap(e){return this.patch("/platform/billing/credits/spend-cap",e)}},Me=class{entitlements;subscriptions;plans;checkout;user;credits;addOns;constructor(e){this.entitlements=new ot(e),this.subscriptions=new at(e),this.plans=new lt(e),this.checkout=new ut(e),this.user=new pt(e),this.credits=new gt(e),this.addOns=new ct(e)}};var Fe=class extends s{async list(){return this.get("/platform/public/catalog",{ignoreClientCode:!0})}};var qe=class extends s{async list(){return this.get("/platform/knowledge/sources")}async addText(e){return this.post("/platform/knowledge/sources",{kind:"text",...e})}async addUrl(e){return this.post("/platform/knowledge/sources",{kind:"url",...e})}async addWebsite(e){return this.post("/platform/knowledge/sources",{type:"website",url:e.url})}async addFile(e,t={}){let r=await new R(this.client).upload(e,{folder:"knowledge"});return this.post("/platform/knowledge/sources",{kind:"file",key:r.key,mimeType:r.mimeType,title:t.title??r.fileName??"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",{query:e,...t?{limit:t}:{}})}};var Be=class extends s{async categories(){return this.get("/platform/support/categories")}async listTickets(e){return this.get("/platform/support/tickets",{params:e})}async createTicket(e){return this.post("/platform/support/tickets",e)}async getTicket(e){return this.get(`/platform/support/tickets/${e}`)}async reply(e,t){return this.post(`/platform/support/tickets/${e}/reply`,t)}async close(e){return this.patch(`/platform/support/tickets/${e}/close`,{})}async channelSetup(e){return this.get(`/platform/support/channel-requests/${encodeURIComponent(e)}/setup`)}};var Ke=class extends s{async get(){return super.get("/platform/users/me")}async update(e){return this.patch("/platform/users/me",e)}async updateOrganization(e){return this.patch("/platform/users/me/organization",e)}async toggleModules(e){return this.post("/platform/users/me/modules",e)}async workspaces(){return super.get("/platform/users/me/workspaces")}async setActiveOrg(e){return this.post("/platform/users/me/active-org",e)}async dismissWorkspaceSetup(){return this.post("/platform/users/me/workspace/dismiss-setup",{})}},je=class extends s{async list(){return this.get("/platform/users/members")}async access(){return this.get("/platform/users/members/access")}async invite(e){return this.post("/platform/users/members/invite",e)}async updateAccess(e,t){return this.patch(`/platform/users/members/${encodeURIComponent(e)}`,t)}async updateRole(e,t){return this.updateAccess(e,{role:t})}async remove(e){return this.deleteRequest(`/platform/users/members/${encodeURIComponent(e)}`)}async invitations(){return this.get("/platform/users/members/invitations")}async resendInvitation(e){return this.post(`/platform/users/members/invitations/${encodeURIComponent(e)}/resend`,{})}async revokeInvitation(e){return this.deleteRequest(`/platform/users/members/invitations/${encodeURIComponent(e)}`)}},He=class extends s{async list(){return this.get("/platform/auth/sessions")}async revoke(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}};var dt=class{messages;conversations;constructor(e){this.messages=new R(e),this.conversations=new z(e)}},mt=class{leads;pipelines;activities;analytics;scoring;payments;chat;events;invoices;checkout;projects;niche;documents;invoiceExport;ai;constructor(e){this.leads=new q(e),this.pipelines=new K(e),this.activities=new N(e),this.analytics=new U(e),this.scoring=new j(e),this.payments=new B(e),this.chat=new dt(e),this.events=new H(e),this.invoices=new W(e),this.checkout=new _(e),this.projects=new Q(e),this.niche=new G(e),this.documents=new M(e),this.invoiceExport=new F(e),this.ai=new Ee(e)}},yt=class{automations;campaigns;conversations;home;drafts;firstRun;audiences;constructor(e){this.automations=new L(e),this.campaigns=new S(e),this.conversations=new $(e),this.home=new E(e),this.drafts=new O(e),this.firstRun=new V(e),this.audiences=new D(e)}},ht=class{projects;audits;insights;searchConsole;ranks;local;reports;backlinks;performance;briefs;research;constructor(e){this.projects=new fe(e),this.audits=new xe(e),this.insights=new ke(e),this.searchConsole=new we(e),this.ranks=new ve(e),this.local=new Te(e),this.reports=new Se(e),this.backlinks=new Re(e),this.performance=new Ae(e),this.briefs=new Ie(e),this.research=new Ce(e)}},bt=class{packs;signals;tools;campaigns;runs;leads;import;lists;compliance;market;learning;lookalikes;freshness;audit;constructor(e){this.packs=new te(e),this.signals=new ne(e),this.tools=new re(e),this.campaigns=new se(e),this.runs=new ie(e),this.leads=new oe(e),this.import=new ae(e),this.lists=new ce(e),this.compliance=new le(e),this.market=new ue(e),this.learning=new pe(e),this.lookalikes=new ge(e),this.freshness=new de(e),this.audit=new me(e)}},We=class{erix;flow;seo;laie;constructor(e){this.erix=new mt(e),this.flow=new yt(e),this.seo=new ht(e),this.laie=new bt(e)}},ft=class{config;templates;constructor(e){this.config=new Z(e),this.templates=new J(e)}},xt=class{templates;constructor(e){this.templates=new ee(e)}},kt=class{leadForms;constructor(e){this.leadForms=new he(e)}},wt=class{email;whatsapp;facebook;meet;connections;voice;constructor(e){this.email=new ft(e),this.whatsapp=new xt(e),this.facebook=new kt(e),this.meet=new X(e),this.connections=new Y(e),this.voice=new be(e)}},vt=class{files;folders;media;constructor(e){this.files=new $e(e),this.folders=new Le(e),this.media=new ye(e)}},Tt=class{collector;constructor(e){this.collector=new Pe(e)}},Ge=class{connect;storage;serp;constructor(e){this.connect=new wt(e),this.storage=new vt(e),this.serp=new Tt(e)}},St=class{onboarding;persona;constructor(e){this.onboarding=new De(e),this.persona=new _e(e)}},Ct=class{me;members;sessions;notifications;constructor(e){this.me=new Ke(e),this.members=new je(e),this.sessions=new He(e),this.notifications=new Ve(e)}},Qe=class{auth;users;tenants;billing;support;ai;knowledge;health;catalog;constructor(e){this.auth=new Ue(e),this.users=new Ct(e),this.tenants=new St(e),this.billing=new Me(e),this.support=new Be(e),this.ai=new Ne(e),this.knowledge=new qe(e),this.health=new Oe(e),this.catalog=new Fe(e)}};var A=class extends x{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},ze=class{async constructEvent(e,t,r){if(!t)throw new A("No webhook signature provided");let i=Array.isArray(t)?t[0]:t;i.startsWith("sha256=")&&(i=i.slice(7));try{let o=await import("crypto"),m=o.createHmac("sha256",r).update(e).digest("hex");if(!o.timingSafeEqual(Buffer.from(m),Buffer.from(i)))throw new A("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(o){throw o instanceof A?o:new A(`Webhook payload parsing failed: ${o.message}`)}}};var Rt=typeof process<"u"&&"4.0.1"||"3.1.1";var At=Lt.default??Lt,Ye=class{client;socket=null;startSocket=null;socketPromise=null;socketQueue=[];clientCode;apiVersion;platform;product;infra;webhooks;constructor(e){let t=e.proxy;if(!e.apiKey&&!t)throw new T("API Key is required");this.clientCode=e.clientCode?.toUpperCase(),this.apiVersion=e.version??"v1";let r=e.baseUrl??Je,i=Pt(this.apiVersion,t?.url??r),o=e.socketUrl||r,p=typeof window<"u"&&typeof window.document<"u",m=p?"browser":typeof process<"u"?`node ${process.version}`:"unknown",d=p?globalThis.navigator?.userAgent||"browser":typeof process<"u"?process.platform:"unknown",Ot={...t?{}:{"x-api-key":e.apiKey,"x-client-code":e.clientCode?.toUpperCase()||""},"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:Rt,runtime:m,os:d})};if(this.client=Mt.create({baseURL:i,headers:Ot,timeout:e.timeout??3e4}),At(this.client,{retries:3,retryDelay:At.exponentialDelay,retryCondition:f=>At.isNetworkOrIdempotentRequestError(f)||f.response?.status===429,onRetry:(f,Vt,It)=>{typeof process<"u"&&process.env?.NODE_ENV==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${f}/3): ${It.method?.toUpperCase()} ${It.url}. Reason: ${Vt.message}`)}}),this.platform=new Qe(this.client),this.product=new We(this.client),this.infra=new Ge(this.client),this.webhooks=new ze,t){if(t.ticket){let f=t.ticket;this.startSocket=()=>this.initSocket(o,async()=>({ticket:await f()}))}}else{let f={apiKey:e.apiKey,clientCode:e.clientCode?.toUpperCase()||""};this.startSocket=()=>this.initSocket(o,async()=>f,{"x-api-key":f.apiKey,"x-client-code":f.clientCode})}if(p){let f={version:Rt,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=f}}initSocket(e,t,r){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:i})=>{this.socket=i(e,{auth:o=>{t().then(p=>o({...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.closed||this.startSocket?.(),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]})}lastSeq;setupSocket(){this.socket&&(this.socket.on("connect_error",()=>{this.socket?.active||setTimeout(()=>{this.closed||this.socket?.connect()},5e3)}),this.socket.onAny((...e)=>{let t=e.at(-1)?.seq;typeof t=="number"&&t>(this.lastSeq??0)&&(this.lastSeq=t)}))}on(e,t){return this.closed||this.startSocket?.(),this.socket?this.socket.on(e,t):this.socketQueue.push({type:"on",args:[e,t]}),this}closed=!1;disconnect(){this.closed=!0,this.socket?this.socket.disconnect():this.socketPromise&&this.socketQueue.push({type:"disconnect",args:[]})}off(e,t){return this.socket?this.socket.off(e,t):this.socketQueue.push({type:"off",args:[e,t]}),this}async request(e,t,r,i){try{return(await this.client.request({method:e,url:t,data:r,params:i})).data}catch(o){throw o.response?new x(o.response.data?.message||o.response.data?.error||"Raw Execution Failed",o.response.status,o.response.data?.code):new x(o.message||"Network Error")}}};Bt.config();var $t="4.0.1";var Kt="Official TypeScript SDK for the ERIX API by ECODrIx: CRM, Flow automations, one inbox across WhatsApp, Instagram and email, GST invoices and payments. Node and browser (proxy mode).",w=new qt;w.name("erix").description(Kt).version($t);function v(n){let e=n.key||process.env.ECOD_API_KEY,t=n.client||process.env.ECOD_CLIENT_CODE;return e||(console.error(u.red("Error: API Key is missing.")),console.log(u.yellow("Set ECOD_API_KEY environment variable or use --key <key>")),process.exit(1)),new Ye({apiKey:e,clientCode:t,baseUrl:n.baseUrl||process.env.ECOD_BASE_URL})}w.option("-k, --key <key>","ECODrIx API Key").option("-c, --client <code...","Tenant Client Code").option("--base-url <url>","API Base URL override");w.command("whoami").description("Verify current authentication and tenant status").action(async(n,e)=>{let t=e.parent.opts(),r=v(t);console.log(u.cyan("Checking connection to ECODrIx Platform..."));try{let i=await r.request("GET","/api/saas/me/profile");console.log(u.green("\u2714 Authenticated successfully!")),console.log(`${u.bold("User ID:")} ${i.id}`),console.log(`${u.bold("Organisation:")} ${i.organisation?.name||"N/A"}`),t.client&&console.log(`${u.bold("Tenant Code:")} ${u.magenta(t.client)}`)}catch(i){console.error(u.red("\u2716 Authentication failed")),console.error(u.dim(i.message)),process.exit(1)}});var jt=w.command("whatsapp").description("WhatsApp Business API operations");jt.command("send-template").description("Send a WhatsApp template message").argument("<phone>","Recipient phone number").argument("<template>","Template name").option("-v, --vars <json>","Template variables as JSON string","[]").action(async(n,e,t,r)=>{let i=r.parent.parent.opts(),o=v(i);try{let p=JSON.parse(t.vars);console.log(u.cyan(`Sending template '${e}' to ${n}...`));let m=await o.product.erix.chat.messages.sendTemplate({to:n,templateName:e,language:"en_US",variables:p});console.log(u.green("\u2714 Message sent successfully!")),console.log(u.dim(`ID: ${m?.id||"N/A"}`))}catch(p){console.error(u.red("\u2716 Failed to send message")),console.error(u.dim(p.message))}});var Et=w.command("crm").description("CRM and Lead management");Et.command("leads").description("List recent leads").option("-l, --limit <number>","Number of leads to fetch","10").option("-s, --status <status>","Filter by lead status").option("-p, --pipeline <id>","Filter by pipeline ID").option("-q, --search <query>","Search by name or email").action(async(n,e)=>{let t=e.parent.parent.opts(),r=v(t);try{let i=Number.parseInt(n.limit);console.log(u.cyan(`Fetching last ${i} leads...`));let o={limit:i};n.status&&(o.status=n.status),n.pipeline&&(o.pipelineId=n.pipeline),n.search&&(o.search=n.search);let p=await r.product.erix.leads.list(o),m=Array.isArray(p.data)?p.data:Array.isArray(p)?p:[];if(m.length===0){console.log(u.yellow("No leads found."));return}console.table(m.map(d=>({ID:d.id||d._id,Name:`${d.firstName} ${d.lastName||""}`.trim(),Phone:d.phone,Status:d.status,Score:d.score||0,Created:new Date(d.createdAt).toLocaleDateString()})))}catch(i){console.error(u.red("\u2716 Failed to fetch leads")),console.error(u.dim(i.message))}});Et.command("pipelines").description("List all CRM pipelines").action(async(n,e)=>{let t=e.parent.parent.opts(),r=v(t);try{console.log(u.cyan("Fetching pipelines..."));let i=await r.product.erix.pipelines.list(),o=i.data||i||[];if(o.length===0){console.log(u.yellow("No pipelines found."));return}console.table(o.map(p=>({ID:p.id||p._id,Name:p.name,Default:p.isDefault?"Yes":"No",Stages:p.stages?.length||0})))}catch(i){console.error(u.red("\u2716 Failed to fetch pipelines")),console.error(u.dim(i.message))}});var Ht=w.command("analytics").description("Business Intelligence Analytics");Ht.command("overview").description("Get high-level CRM KPIs").option("-r, --range <range>","Date range (e.g., 24h, 7d, 30d, 365d)","30d").action(async(n,e)=>{let t=e.parent.parent.opts(),r=v(t);try{console.log(u.cyan(`Fetching overview metrics for last ${n.range}...`));let i=await r.product.erix.analytics.overview({range:n.range}),o=i.data||i;console.log(`
|
|
2
|
+
import Bt from"repl";import{Command as Kt}from"commander";import jt from"dotenv";import u from"picocolors";import qt from"axios";import Et from"axios-retry";var Ze="https://api.ecodrix.com";function $t(n="v1",e=Ze){return`${e.replace(/\/+$/,"")}/${n}/api`}var et=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},x=class extends et{status;code;issues;field;constructor(e,t,s){super(e),this.name="APIError",this.status=t,this.code=s}},T=class extends x{constructor(e="Invalid API Key or Client Code",t="AUTH_FAILED",s=401){super(e,s,t),this.name="AuthenticationError"}},tt=class extends T{constructor(e="You don't have permission to do this.",t="FORBIDDEN"){super(e,t,403),this.name="PermissionError"}},nt=class extends x{constructor(e="Too many requests. Please slow down."){super(e,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};function P(n){if(!n?.response)return new x(n?.message||"Network Error");let{status:e,data:t}=n.response,s=t?.message||t?.error||"API Request Failed",i=t?.code??(typeof t?.error=="string"&&/^[A-Z][A-Z0-9_]*$/.test(t.error)?t.error:void 0);switch(e){case 401:return new T(s,i);case 403:return new tt(s,i);case 429:return new nt(s);default:{let o=new x(s,e,i);return Array.isArray(t?.issues)&&(o.issues=t.issues),typeof t?.field=="string"&&(o.field=t.field),o}}}var r=class{constructor(e){this.client=e}client;async post(e,t,s){try{let i=this.buildConfig(s);return(await this.client.post(e,t,i)).data}catch(i){this.handleError(i)}}async get(e,t){try{let s=this.buildConfig(t);return(await this.client.get(e,s)).data}catch(s){this.handleError(s)}}async patch(e,t,s){try{let i=this.buildConfig(s);return(await this.client.patch(e,t,i)).data}catch(i){this.handleError(i)}}async put(e,t,s){try{let i=this.buildConfig(s);return(await this.client.put(e,t,i)).data}catch(i){this.handleError(i)}}async deleteRequest(e,t){try{let s=this.buildConfig(t);return(await this.client.delete(e,s)).data}catch(s){this.handleError(s)}}buildConfig(e){if(!e)return;let t={...e};return e.idempotencyKey&&(t.headers={...t.headers,"Idempotency-Key":e.idempotencyKey}),t}handleError(e){throw P(e)}};var L=class extends r{async settings(){return this.get("/product/erix/ai/settings")}async updateSettings(e){return this.patch("/product/erix/ai/settings",e)}async outcomes(e={}){return this.get("/product/erix/ai/outcomes",{params:e})}async reviews(e){return this.get(`/product/erix/ai/reviews${e?`?status=${e}`:""}`)}async review(e,t,s){return this.post(`/product/erix/ai/reviews/${encodeURIComponent(e)}`,{verdict:t,...s?{note:s}:{}})}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,s){return this.post(`/product/erix/ai/suggestion/${e}/send`,{text:t,confidence:s})}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 agent(e){return this.get(`/product/flow/agents/${encodeURIComponent(e)}`)}async tryAgent(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/try`,t)}async proposeAgentChange(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/propose`,t)}async buildAgent(e){return this.post("/product/flow/agents/build",e)}async unansweredQuestions(){return this.get("/product/flow/agents/unanswered")}async markQuestionHandled(e){return this.post("/product/flow/agents/unanswered/handled",{question:e})}async agentTemplates(){return this.get("/product/flow/agents/templates")}async createAgent(e){return this.post("/product/flow/agents",e)}async updateAgent(e,t){return this.patch(`/product/flow/agents/${encodeURIComponent(e)}`,t)}async deleteAgent(e){return this.deleteRequest(`/product/flow/agents/${encodeURIComponent(e)}`)}async agentAutomation(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/automation`,{trigger:t})}async decideRun(e,t,s){return this.post(`/product/flow/runs/${encodeURIComponent(e)}/approve`,{decision:t,...s&&{nodeId:s}})}};var h="/product/erix/commerce/checkout",k="/product/erix/public/checkout",b=encodeURIComponent,rt=class extends r{async getProduct(e,t){return this.get(`${k}/products/${b(t)}`,{params:{c:e}})}async viewSession(e,t){return this.get(`${k}/sessions/view`,{params:{c:e,t}})}async updateItems(e){let{sessionId:t,...s}=e;return this.post(`${k}/sessions/${b(t)}/items`,s)}async startSession(e){return this.post(`${k}/sessions`,e)}async applyCoupon(e){let{sessionId:t,...s}=e;return this.post(`${k}/sessions/${b(t)}/coupon`,s)}async verify(e){let{sessionId:t,...s}=e;return this.post(`${k}/sessions/${b(t)}/verify`,s)}async placeOrder(e){let{sessionId:t,...s}=e;return this.post(`${k}/sessions/${b(t)}/order`,s)}async verifyRazorpay(e){let{sessionId:t,orderId:s,...i}=e;return this.post(`${k}/sessions/${b(t)}/order/${b(s)}/razorpay`,i)}async orderStatus(e,t){return this.get(`${k}/orders/status`,{params:{c:e,t}})}async confirmCod(e,t){return this.post(`${k}/cod/confirm`,{clientCode:e,token:t})}},st=class extends r{async create(e){return this.post(`${h}/sessions`,e)}},$=class extends r{buyer;sessions;constructor(e){super(e),this.buyer=new rt(e),this.sessions=new st(e)}async listProducts(){return this.get(`${h}/products`)}async createProduct(e){return this.post(`${h}/products`,e)}async updateProduct(e,t){return this.patch(`${h}/products/${b(e)}`,t)}async deleteProduct(e){return this.deleteRequest(`${h}/products/${b(e)}`)}async listCoupons(){return this.get(`${h}/coupons`)}async createCoupon(e){return this.post(`${h}/coupons`,e)}async updateCoupon(e,t){return this.patch(`${h}/coupons/${b(e)}`,t)}async deleteCoupon(e){return this.deleteRequest(`${h}/coupons/${b(e)}`)}async listOrders(e){return this.get(`${h}/orders`,{params:e})}async getOrder(e){return this.get(`${h}/orders/${b(e)}`)}async updateOrderStatus(e,t){return this.patch(`${h}/orders/${b(e)}/status`,t)}async getSettings(){return this.get(`${h}/settings`)}async updateSettings(e){return this.put(`${h}/settings`,e)}async createProductLink(e){return this.post(`${h}/links`,e)}};var E=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,t){return this.post(`/infra/connect/connections/${e}/connect`,t)}async configure(e,t){return this.put(`/infra/connect/connections/${e}/configure`,t)}async configureWebchat(e){return this.configure("webchat",{method:"domain",config:e})}async webchatSettings(){return this.get("/infra/connect/connections/webchat/settings")}async removeWebchatDomain(e){return this.deleteRequest(`/infra/connect/connections/webchat/domains/${encodeURIComponent(e)}`)}async disconnect(e){return this.post(`/infra/connect/connections/${e}/disconnect`,{})}async reveal(e){return this.post(`/infra/connect/connections/${e}/reveal`,{})}async test(e){return this.post(`/infra/connect/connections/${e}/test`,{})}async checkNow(e){return this.post(`/infra/connect/connections/${e}/health/check`,{})}async googleConnectUrl(){return this.post("/infra/connect/google/connect-url",{})}async moveChannel(e,t){return this.post(`/infra/connect/${e}/move`,{ticket:t})}async requestChannelRelease(e,t){return this.post(`/infra/connect/${e}/release-request`,{ticket:t})}async channelReleaseRequest(e){return this.get(`/infra/connect/${e}/release-request`)}async cancelChannelRelease(e){return this.deleteRequest(`/infra/connect/${e}/release-request`)}async createPaymentLink(e){return this.post("/infra/connect/connections/payments/payment-link",e)}};var O=class extends r{async list(e){return this.get("/infra/connect/accounts",e?{params:{providerId:e}}:void 0)}async retrieve(e){return this.get(`/infra/connect/accounts/${encodeURIComponent(e)}`)}async update(e,t){return this.patch(`/infra/connect/accounts/${encodeURIComponent(e)}`,t)}async remove(e,t={}){return this.deleteRequest(`/infra/connect/accounts/${encodeURIComponent(e)}`,t.newDefaultId?{params:{newDefaultId:t.newDefaultId}}:void 0)}};var it=class extends r{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}`)}},V=class extends r{notes;constructor(e){super(e),this.notes=new it(e)}async timeline(e,t){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:t})}async list(e,t){return this.get(`/product/erix/crm/leads/${e}/activities`,{params:{...t}})}async log(e){return this.post(`/product/erix/crm/leads/${e.leadId}/activities`,e)}async logCall(e,t){return this.post(`/product/erix/crm/leads/${e}/calls`,t)}};var D=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 _=class extends r{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,s){return this.patch(`/product/erix/crm/documents/checklist/${e}/${t}`,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 U=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 Ut=["open","won","lost","archived"],N=class extends r{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:[],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:Ut.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}],i=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:[...s,...i],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 s=[];for(let i=0;i<e.length;i+=t){let p=e.slice(i,i+t).map(d=>this.create(d)),m=await Promise.allSettled(p);for(let d of m)if(d.status==="fulfilled")s.push(d.value);else throw d.reason}return s}async import(e,t={}){return this.post("/product/erix/crm/leads/import",{leads:e,...t})}async bulkUpsert(e){return this.import(e)}async list(e){let t={...e};return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/product/erix/crm/leads",{params:t})}async*listAutoPaging(e){let t=e?.page||1,s=!0;for(;s;){let i=await this.list({...e,page:t}),o=Array.isArray(i.data)?i.data:i||[];if(o.length===0){s=!1;break}for(let p of o)yield p;i.pagination&&t<i.pagination.pages||!i.pagination&&o.length>0?t++: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,t,s={}){return this.get(`/product/erix/crm/pipelines/${e}/stages/${t}/leads`,{params:s})}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,s){return this.patch(`/product/erix/crm/leads/${e}`,{nextFollowUpAt:t,nextFollowUpNote:t?s??null:null})}async move(e,t){return this.patch(`/product/erix/crm/leads/${e}/move`,{stageId:t})}async convert(e,t,s){return this.post(`/product/erix/crm/leads/${e}/convert`,{outcome:t,reason:s})}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,s){return this.patch(`/product/erix/crm/notes/${t}`,s)}async deleteNote(e,t){return this.deleteRequest(`/product/erix/crm/notes/${t}`)}async delete(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async export(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/export`)}async erase(e){return this.post(`/product/erix/crm/leads/${encodeURIComponent(e)}/erase`,{confirm:"ERASE"})}async bulkArchive(e){return this.patch("/product/erix/crm/leads/bulk-archive",{ids:e})}async bulkDelete(e){return this.deleteRequest("/product/erix/crm/leads",{data:{ids:e}})}async archive(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async profile(e){return this.get(`/product/erix/crm/leads/${e}/profile`)}async invoices(e){return this.get(`/product/erix/crm/leads/${e}/invoices`)}async projects(e){return this.get(`/product/erix/crm/leads/${e}/projects`)}async conversations(e){return this.get(`/product/erix/crm/leads/${e}/conversations`)}async meetings(e){return this.get(`/product/erix/crm/leads/${e}/meetings`)}async flowRuns(e){return this.get(`/product/erix/crm/leads/${e}/flow-runs`)}async merge(e,t){return this.post("/product/erix/crm/leads/merge",{primaryId:e,secondaryId:t})}async duplicates(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/duplicates`)}};var M=class extends r{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var F=class extends r{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){let t=await this.retrieve(e),s=Array.isArray(t.data?.stages)?t.data.stages:[];return{name:`Pipeline: ${t.data?.name||e}`,fields:s.map(i=>({key:i._id,label:i.name,type:"string",required:!0,options:[{label:i.name,value:i._id}],group:"Stages",uiHints:{color:i.color||"#cbd5e1",probability:i.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/product/erix/crm/pipelines",e)}async retrieve(e){return this.get(`/product/erix/crm/pipelines/${e}`)}async update(e,t){return this.patch(`/product/erix/crm/pipelines/${e}`,t)}async setDefault(e){return this.patch(`/product/erix/crm/pipelines/${e}/default`,{})}async duplicate(e,t){return this.post(`/product/erix/crm/pipelines/${e}/duplicate`,{name:t})}async archive(e){return this.patch(`/product/erix/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/product/erix/crm/pipelines/${e}`)}async checkInUse(e){return this.get(`/product/erix/crm/pipelines/${e}/in-use`)}async board(e){return this.get(`/product/erix/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/product/erix/crm/pipelines/${e}/forecast`)}async addStage(e,t){return this.post(`/product/erix/crm/pipelines/${e}/stages`,t)}async reorderStages(e,t){return this.patch(`/product/erix/crm/pipelines/${e}/stages/reorder`,{order:t})}async updateStage(e,t){return this.patch(`/product/erix/crm/stages/${e}`,t)}async deleteStage(e,t){return this.deleteRequest(`/product/erix/crm/stages/${e}`,{data:t?{moveLeadsToStageId:t}:void 0})}};var q=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 B=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,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 K=class extends r{async trigger(e){return this.post("/product/erix/events/trigger",e)}async listCustomEvents(){return this.get("/product/flow/config/triggers")}async createCustomEvent(e){return this.post("/product/flow/config/triggers",e)}async deleteCustomEvent(e){return this.deleteRequest(`/product/flow/config/triggers/${e}`)}};var j=class extends r{async list(){return this.get("/infra/connect/facebook/lead-forms")}async subscribe(){return this.post("/infra/connect/facebook/lead-forms/subscribe",{})}async setEnabled(e,t){return this.put(`/infra/connect/facebook/lead-forms/${encodeURIComponent(e)}`,{enabled:t})}async importLast24Hours(e){return this.post(`/infra/connect/facebook/lead-forms/${encodeURIComponent(e)}/import-last-24h`,{})}};var W=class extends r{path(e,t=""){return`/product/flow/workflows/${encodeURIComponent(e)}${t}`}async versions(e){return this.get(this.path(e,"/versions"))}async version(e,t){return this.get(this.path(e,`/versions/${encodeURIComponent(t)}`))}async restoreVersion(e,t){return this.post(this.path(e,`/versions/${encodeURIComponent(t)}/restore`))}async testData(e){return this.get(this.path(e,"/test-data"))}async pinTestData(e,t){return this.put(this.path(e,"/test-data"),{runId:t})}async unpinTestData(e){return this.deleteRequest(this.path(e,"/test-data"))}async testRun(e,t={}){return this.post(this.path(e,"/test-run"),t)}async testRunProgress(e,t){return this.get(this.path(e,"/test-run"),{params:{runIds:t.join(",")}})}async copilot(e,t){return this.post(this.path(e,"/copilot"),t)}async live(e){return this.get(this.path(e,"/live"))}async week(e){return this.get(this.path(e,"/week"))}async deleteImpact(e){return this.get(this.path(e,"/delete-impact"))}async remove(e,t={}){return this.deleteRequest(this.path(e,t.stop?"?stop=true":""))}async duplicate(e){return this.post(this.path(e,"/duplicate"))}async retryFailed(e,t={}){return this.post(this.path(e,"/retry-failed"),t)}};var C=class extends r{async list(e={}){return this.get("/product/flow/campaigns",{params:e})}async create(e){return this.post("/product/flow/campaigns",e)}async launch(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/launch`,t)}async retrieve(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}`)}async update(e,t){return this.patch(`/product/flow/campaigns/${encodeURIComponent(e)}`,t)}async test(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/test`,{})}async start(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/start`,t)}async pause(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/pause`,{})}async resume(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/resume`,{})}async stop(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/stop`,{})}async remove(e){return this.deleteRequest(`/product/flow/campaigns/${encodeURIComponent(e)}`)}async duplicate(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/duplicate`,{})}async followUp(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/follow-up`,t)}async checks(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/checks`)}async results(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/results`)}async people(e,t={}){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/people`,{params:t})}};var A="/product/flow/conversations",y=(n,e="")=>`${A}/${encodeURIComponent(n)}${e}`,H=class extends r{async list(e={}){return this.get(A,{params:e})}async create(e){return this.post(A,e)}async retrieve(e){return this.get(y(e))}async update(e,t){return this.patch(y(e),t)}async duplicate(e){return this.post(y(e,"/duplicate"),{})}async archive(e){return this.deleteRequest(y(e))}async publish(e,t={}){return this.post(y(e,"/publish"),t)}async versions(e){return this.get(y(e,"/versions"))}async version(e,t){return this.get(y(e,`/versions/${t}`))}async rollback(e,t){return this.post(y(e,"/rollback"),{version:t})}async try(e,t){return this.post(y(e,"/try"),t)}async tests(e){return this.get(y(e,"/tests"))}async addTest(e,t){return this.post(y(e,"/tests"),t)}async deleteTest(e,t){return this.deleteRequest(y(e,`/tests/${encodeURIComponent(t)}`))}async runTests(e,t={}){return this.post(y(e,"/tests/run"),t)}async deployments(e){return this.get(y(e,"/deployments"))}async allDeployments(){return this.get(`${A}/deployments`)}async deploy(e,t){return this.post(y(e,"/deployments"),t)}async updateDeployment(e,t){return this.patch(`${A}/deployments/${encodeURIComponent(e)}`,t)}async removeDeployment(e){return this.deleteRequest(`${A}/deployments/${encodeURIComponent(e)}`)}async checks(e){return this.get(y(e,"/checks"))}};var G=class extends r{async get(){return super.get("/product/flow/home")}async nav(){return super.get("/product/flow/home/nav")}},Q=class extends r{async create(e){return this.post("/product/flow/drafts",e)}async plan(e){return this.post("/product/flow/drafts/plan",e)}},z=class extends r{async status(){return this.get("/product/flow/first-run")}async installPack(e){return this.post(`/product/flow/first-run/packs/${e}`)}},Y=class extends r{async list(){return this.get("/product/flow/audiences")}async byId(e){return this.get(`/product/flow/audiences/${encodeURIComponent(e)}`)}async create(e){return this.post("/product/flow/audiences",e)}async update(e,t){return this.patch(`/product/flow/audiences/${encodeURIComponent(e)}`,t)}async remove(e){return this.deleteRequest(`/product/flow/audiences/${encodeURIComponent(e)}`)}async preview(e,t){return this.get(`/product/flow/audiences/${encodeURIComponent(e)}/preview${t?`?channel=${t}`:""}`)}async previewRules(e){return this.post("/product/flow/audiences/preview",e)}};var J=class extends r{async system(){return(await this.get("/health")).data}};var X=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,t){return this.patch(`/product/erix/commerce/invoices/${e}`,t)}async void(e){return this.post(`/product/erix/commerce/invoices/${e}/void`,{})}async sendViaWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${e}/send-whatsapp`,{})}async getSettings(){return this.get("/product/erix/commerce/settings")}async updateSettings(e){return this.put("/product/erix/commerce/settings",e)}async paymentLink(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payment-link`,{})}async recordPayment(e,t){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payments`,t)}async sendWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-whatsapp`,{})}async sendEmail(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-email`,{})}};var g=encodeURIComponent,a="/product/laie",Z=class extends r{async list(){return this.get(`${a}/packs`)}async byId(e){return this.get(`${a}/packs/${g(e)}`)}},ee=class extends r{async catalog(e={}){return this.get(`${a}/signals/catalog`,{params:e})}async list(e={}){return this.get(`${a}/signals`,{params:e})}},te=class extends r{async find(e){return this.post(`${a}/tools/find`,e)}async collect(e){return this.post(`${a}/tools/collect`,e)}async enrich(e){return this.post(`${a}/tools/enrich`,e)}async verify(e){return this.post(`${a}/tools/verify`,e)}async qualify(e){return this.post(`${a}/tools/qualify`,e)}async store(e){return this.post(`${a}/tools/store`,e)}async use(e){return this.post(`${a}/tools/use`,e)}async verifyEmail(e){return this.post(`${a}/tools/verify-email`,{emails:e})}async websiteLookup(e){return this.post(`${a}/tools/website-lookup`,{url:e})}},ne=class extends r{async list(){return this.get(`${a}/campaigns`)}async create(e){return this.post(`${a}/campaigns`,e)}async byId(e){return this.get(`${a}/flows/${g(e)}`)}async settings(e){return this.get(`${a}/campaigns/${g(e)}/settings`)}async updateSettings(e,t){return this.patch(`${a}/campaigns/${g(e)}/settings`,t)}async signals(e){return this.get(`${a}/campaigns/${g(e)}/signals`)}async setSignals(e,t){return this.put(`${a}/campaigns/${g(e)}/signals`,t)}},re=class extends r{async start(e){return this.post(`${a}/campaigns/${g(e)}/runs`)}async list(e,t={}){return this.get(`${a}/campaigns/${g(e)}/runs`,{params:t})}async byId(e,t){return this.get(`${a}/campaigns/${g(e)}/runs/${g(t)}`)}async changes(e,t,s={}){return this.get(`${a}/campaigns/${g(e)}/runs/${g(t)}/changes`,{params:s})}async cancel(e,t){return this.post(`${a}/campaigns/${g(e)}/runs/${g(t)}/cancel`)}async quality(e){return this.get(`${a}/jobs/${g(e)}/quality`)}},se=class extends r{async list(e={}){let{importedToCrm:t,...s}=e;return this.get(`${a}/leads`,{params:{...s,...t!==void 0&&{importedToCrm:String(t)}}})}async byId(e){return this.get(`${a}/leads/${g(e)}`)}async update(e,t){return this.patch(`${a}/leads/${g(e)}`,t)}async notes(e){return this.get(`${a}/leads/${g(e)}/notes`)}async addNote(e,t){return this.post(`${a}/leads/${g(e)}/notes`,t)}async generateKit(e){return this.post(`${a}/leads/${g(e)}/generate-kit`)}async pipelineSummary(){return this.get(`${a}/leads/pipeline-summary`)}async bulkContacted(e,t){return this.post(`${a}/leads/bulk/contacted`,{leadIds:e,channel:t})}async bulkTag(e,t){return this.post(`${a}/leads/bulk/tag`,{leadIds:e,tags:t})}async bulkDelete(e){return this.post(`${a}/leads/bulk/delete`,{leadIds:e})}async bulkExport(e,t="json"){return t==="csv"?this.post(`${a}/leads/bulk/export`,{leadIds:e,format:t},{responseType:"text"}):this.post(`${a}/leads/bulk/export`,{leadIds:e,format:t})}},ie=class extends r{async pipelines(){return this.get(`${a}/import/pipelines`)}async crm(e){return this.post(`${a}/import/crm`,e)}},oe=class extends r{async enrich(e){return this.post(`${a}/lists/enrich`,e)}},ae=class extends r{async dsr(e){return this.post(`${a}/compliance/dsr`,e)}async report(e={}){return this.get(`${a}/compliance/report`,{params:e})}},ce=class extends r{async map(e={}){return this.get(`${a}/market-map`,{params:e})}async forCampaign(e){return this.get(`${a}/campaigns/${g(e)}/market-map`)}async refresh(e={}){return this.post(`${a}/market-map/refresh`,e)}},le=class extends r{async weights(e={}){return this.get(`${a}/learning/weights`,{params:e})}async outcomes(e={}){return this.get(`${a}/learning/outcomes`,{params:e})}},ue=class extends r{async preview(e){return this.post(`${a}/lookalikes/preview`,e)}async create(e){return this.post(`${a}/lookalikes`,e)}async list(e={}){return this.get(`${a}/lookalikes`,{params:e})}async byId(e){return this.get(`${a}/lookalikes/${g(e)}`)}async rank(e,t={}){return this.get(`${a}/lookalikes/${g(e)}/rank`,{params:t})}},pe=class extends r{async status(){return this.get(`${a}/freshness`)}},ge=class extends r{async start(e){return this.post(`${a}/audit`,e)}async byId(e){return this.get(`${a}/audit/${g(e)}`)}};import Nt from"axios";var de=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,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 s=await this.post("/infra/storage/files/upload-url",t),{uploadUrl:i,key:o}=s.data;await Nt.put(i,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 me=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,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 ye=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 he=class extends r{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 be=class extends r{async global(e){return this.post("/platform/tenants/onboarding/global",e)}async complete(e){return this.post("/platform/tenants/onboarding/complete",e)}};var fe=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,t){return(await super.get(`/platform/tenants/persona/${e}/timeline`,{params:t}))?.data??{entries:[],hasMore:!1}}async followups(e){return(await super.get(`/platform/tenants/persona/${e}/followups`))?.data?.entries??[]}};var ot=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"}},xe=class{copilot;constructor(e){this.copilot=new ot(e)}};var ke=class extends r{async list(e){return this.get("/platform/tenants/audit",{params:e})}};var we=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,t){return this.post(`/platform/auth/invitations/${e}/accept`,t)}};var at=class extends r{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},ct=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)}},lt=class extends r{list(){return this.get("/platform/billing/addons")}add(e,t){return this.post(`/platform/billing/addons/${encodeURIComponent(e)}/add`,t===void 0?{}:{quantity:t})}remove(e){return this.post(`/platform/billing/addons/${encodeURIComponent(e)}/remove`)}overage(){return this.get("/platform/billing/overage")}setOverage(e){return this.put("/platform/billing/overage",e)}},ut=class extends r{async listPublic(){return this.get("/platform/billing/plans/public")}},pt=class extends r{async plans(){return this.get("/platform/billing/checkout/plans")}async proration(e,t){return this.get("/platform/billing/checkout/proration",{params:{planId:e,billingCycle:t}})}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)}},gt=class extends r{async transactions(){return this.get("/platform/billing/user/transactions")}async transactionInvoice(e){return this.get(`/platform/billing/user/transactions/${encodeURIComponent(e)}/invoice`)}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")}},dt=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)}},ve=class{entitlements;subscriptions;plans;checkout;user;credits;addOns;constructor(e){this.entitlements=new at(e),this.subscriptions=new ct(e),this.plans=new ut(e),this.checkout=new pt(e),this.user=new gt(e),this.credits=new dt(e),this.addOns=new lt(e)}};var Te=class extends r{async list(){return this.get("/platform/public/catalog",{ignoreClientCode:!0})}};var S=class extends r{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,...e.accountId?{accountId:e.accountId}:{}})}async sendTemplate(e){return this.post("/infra/connect/send/whatsapp",{phone:e.to,templateName:e.templateName,language:e.language,variables:e.variables,...e.accountId?{accountId:e.accountId}:{}})}async star(e,t){return this.post(`/platform/inbox/messages/${e}/star`,{starred:t})}async translate(e){return this.post(`/platform/inbox/messages/${encodeURIComponent(e)}/translate`,{})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async upload(e,t={}){let s=t.fileName??e.name??"file",i=e.type||"application/octet-stream",o=await this.post("/infra/storage/files/upload-url",{folder:t.folder??"inbox",filename:s,contentType:i}),{uploadUrl:p,key:m}=o.data,d=await fetch(p,{method:"PUT",headers:{"Content-Type":i},body:e});if(!d.ok)throw new Error(`upload failed (${d.status})`);return await this.post("/infra/storage/files/confirm-upload",{key:m,sizeBytes:e.size}),{key:m,mimeType:i,fileName:s}}};var Ce=class extends r{async list(){return this.get("/platform/knowledge/sources")}async addText(e){return this.post("/platform/knowledge/sources",{kind:"text",...e})}async addUrl(e){return this.post("/platform/knowledge/sources",{kind:"url",...e})}async addWebsite(e){return this.post("/platform/knowledge/sources",{type:"website",url:e.url})}async addFile(e,t={}){let s=await new S(this.client).upload(e,{folder:"knowledge"});return this.post("/platform/knowledge/sources",{kind:"file",key:s.key,mimeType:s.mimeType,title:t.title??s.fileName??"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",{query:e,...t?{limit:t}:{}})}};var Ae=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,t){return this.post(`/platform/support/tickets/${e}/reply`,t)}async close(e){return this.patch(`/platform/support/tickets/${e}/close`,{})}async channelSetup(e){return this.get(`/platform/support/channel-requests/${encodeURIComponent(e)}/setup`)}};var Se=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",{})}},Re=class extends r{async list(){return this.get("/platform/users/members")}async access(){return this.get("/platform/users/members/access")}async invite(e){return this.post("/platform/users/members/invite",e)}async updateAccess(e,t){return this.patch(`/platform/users/members/${encodeURIComponent(e)}`,t)}async updateRole(e,t){return this.updateAccess(e,{role:t})}async remove(e){return this.deleteRequest(`/platform/users/members/${encodeURIComponent(e)}`)}async invitations(){return this.get("/platform/users/members/invitations")}async resendInvitation(e){return this.post(`/platform/users/members/invitations/${encodeURIComponent(e)}/resend`,{})}async revokeInvitation(e){return this.deleteRequest(`/platform/users/members/invitations/${encodeURIComponent(e)}`)}},Ie=class extends r{async list(){return this.get("/platform/auth/sessions")}async revoke(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}};var Pe=class extends r{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,s){return this.patch(`/product/erix/commerce/projects/${e}/documents/${t}/signature`,{required:s})}async addSigner(e,t,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/signers`,s)}async decline(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/decline`,{})}async stampSign(e,t,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/stamp-sign`,s)}};var Le=class extends r{async list(){return this.get("/product/seo/projects")}async create(e){return this.post("/product/seo/projects",e)}async byId(e){return this.get(`/product/seo/projects/${e}`)}async update(e,t){return this.patch(`/product/seo/projects/${e}`,t)}async remove(e){return this.deleteRequest(`/product/seo/projects/${e}`)}async crawl(e){return this.post(`/product/seo/projects/${e}/crawl`)}async crawlCompetitor(e,t){return this.post(`/product/seo/projects/${e}/competitors/crawl`,{domain:t})}},$e=class extends r{async start(e){return this.post("/product/seo/audits",e)}async list(e={}){return this.get("/product/seo/audits",{params:e})}async compare(e){return this.post("/product/seo/audits/compare",e)}async byId(e){return this.get(`/product/seo/audits/${e}`)}async resume(e){return this.post(`/product/seo/audits/${e}/resume`)}async pages(e,t={}){return this.get(`/product/seo/audits/${e}/pages`,{params:t})}async issues(e){return this.get(`/product/seo/audits/${e}/issues`)}async links(e){return this.get(`/product/seo/audits/${e}/links`)}async export(e,t="json"){return this.get(`/product/seo/audits/${e}/export`,{params:{format:t},responseType:"text"})}},Ee=class extends r{async keywords(e,t={}){return this.get(`/product/seo/audits/${e}/keywords`,{params:t})}async contentGap(e){return this.post("/product/seo/audits/content-gap",e)}async search(e){return this.post("/product/seo/audits/search",e)}async backlinks(e){return this.get("/product/seo/audits/backlinks",{params:e})}async domain(e){return this.get(`/product/seo/audits/domains/${encodeURIComponent(e)}`)}},Oe=class extends r{async check(e){return this.post(`/product/seo/search-console/${e}/check`)}async importNow(e){return this.post(`/product/seo/search-console/${e}/import`)}async status(e){return this.get(`/product/seo/search-console/${e}/status`)}async queries(e,t={}){return this.get(`/product/seo/search-console/${e}/queries`,{params:t})}async pages(e,t={}){return this.get(`/product/seo/search-console/${e}/pages`,{params:t})}async trend(e,t={}){return this.get(`/product/seo/search-console/${e}/trend`,{params:t})}},Ve=class extends r{async keywords(e){return this.get(`/product/seo/ranks/${e}/keywords`)}async add(e,t,s={}){return this.post(`/product/seo/ranks/${e}/keywords`,{queries:t,...s})}async visibility(e,t={}){return this.get(`/product/seo/ranks/${e}/visibility`,{params:t})}async competitors(e){return this.get(`/product/seo/ranks/${e}/competitors`)}async gap(e,t={}){return this.get(`/product/seo/ranks/${e}/gap`,{params:t})}async remove(e,t){return this.deleteRequest(`/product/seo/ranks/${e}/keywords/${t}`)}async checkNow(e,t){return this.post(`/product/seo/ranks/${e}/keywords/${t}/check`)}async history(e,t,s={}){return this.get(`/product/seo/ranks/${e}/keywords/${t}/history`,{params:s})}async changes(e){return this.get(`/product/seo/ranks/${e}/changes`)}},De=class extends r{async checkNow(e){return this.post(`/product/seo/local/${e}/check`)}async latest(e){return this.get(`/product/seo/local/${e}`)}async history(e,t={}){return this.get(`/product/seo/local/${e}/history`,{params:t})}async startGrid(e,t={}){return this.post(`/product/seo/local/${e}/grid`,t)}async grid(e){return this.get(`/product/seo/local/${e}/grid`)}async grids(e,t={}){return this.get(`/product/seo/local/${e}/grids`,{params:t})}},_e=class extends r{async byProject(e){return this.get(`/product/seo/reports/${e}`)}async export(e,t="csv"){return this.get(`/product/seo/reports/${e}/export`,{params:{format:t},responseType:"text"})}async pdf(e,t={}){return this.get(`/product/seo/reports/${e}/pdf`,{params:t,responseType:"arraybuffer"})}async generate(e,t={}){return this.post(`/product/seo/reports/${e}/generate`,t)}async history(e,t={}){return this.get(`/product/seo/reports/${e}/history`,{params:t})}async changes(e){return this.get(`/product/seo/reports/${e}/changes`)}},Ue=class extends r{async seed(e,t,s="en"){return this.post(`/product/seo/research/${e}/seed`,{seed:t,lang:s})}async fromSearchConsole(e){return this.post(`/product/seo/research/${e}/from-search-console`)}async ideas(e,t={}){return this.get(`/product/seo/research/${e}/ideas`,{params:t})}async analyze(e,t){return this.post(`/product/seo/research/${e}/ideas/${t}/analyze`)}};var Ne=class extends r{async releases(){return this.get("/product/seo/backlinks/releases")}async strength(e){return this.get("/product/seo/backlinks/strength",{params:{domains:e.join(",")}})}async overview(e){return this.get(`/product/seo/backlinks/${e}`)}async referring(e,t){return this.get(`/product/seo/backlinks/${e}/referring`,{params:t})}async changes(e,t){return this.get(`/product/seo/backlinks/${e}/changes`,{params:t})}},Me=class extends r{async checkNow(e){return this.post(`/product/seo/performance/${e}/check`)}async latest(e){return this.get(`/product/seo/performance/${e}`)}async history(e,t={}){return this.get(`/product/seo/performance/${e}/history`,{params:t})}},Fe=class extends r{async create(e){return this.post("/product/seo/briefs",e)}async byId(e){return this.get(`/product/seo/briefs/${e}`)}async list(e,t={}){return this.get("/product/seo/briefs",{params:{projectId:e,...t}})}};var Mt=35e3,qe=class extends r{async claim(e,t){let s=await this.post("/infra/serp/collector/claim",{collectorId:e,kinds:t},{timeout:Mt});return(s&&typeof s=="object"?s.data:null)??null}async result(e){return this.post("/infra/serp/collector/result",e)}async heartbeat(e,t){return this.post("/infra/serp/collector/heartbeat",{collectorId:e,...t})}};var Be=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 Ke=class extends r{async create(e){return this.post("/infra/storage/files/folders",{name:e})}},je=class extends r{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 I=encodeURIComponent,mt=class extends r{get flow(){return new C(this.client)}list(e={}){return this.flow.list(e)}retrieve(e){return this.flow.retrieve(e)}create(e){return this.flow.create(e)}launch(e,t={}){return this.flow.launch(e,t)}start(e,t={}){return this.flow.start(e,t)}pause(e){return this.flow.pause(e)}resume(e){return this.flow.resume(e)}stop(e){return this.flow.stop(e)}costPreview(e){return this.get(`/product/flow/campaigns/${I(e)}/voice-preview`)}counters(e){return this.get(`/infra/connect/voice/campaigns/${I(e)}/counters`)}approval(e){return this.get(`/infra/connect/voice/campaigns/${I(e)}/approval`)}requestApproval(e){return this.post(`/infra/connect/voice/campaigns/${I(e)}/approval/request`,{})}},We=class extends r{campaigns;constructor(e){super(e),this.campaigns=new mt(e)}status(){return this.get("/infra/connect/voice/status")}setup(){return this.get("/infra/connect/voice/setup")}setupNumbers(){return this.get("/infra/connect/voice/setup/numbers")}kycUploadUrl(e){return this.post("/infra/connect/voice/setup/kyc/upload-url",e)}submitKyc(e){return this.post("/infra/connect/voice/setup/kyc",e)}pickNumber(e){return this.post("/infra/connect/voice/setup/number",{number:e})}askForNumber(){return this.post("/infra/connect/voice/setup/number/request",{})}goLive(){return this.post("/infra/connect/voice/setup/go-live",{})}agent(){return this.get("/infra/connect/voice/agent")}skills(){return this.get("/infra/connect/voice/skills")}voices(e){return this.get(`/infra/connect/voice/voices?language=${encodeURIComponent(e)}`)}saveAgent(e){return this.put("/infra/connect/voice/agent",e)}agents(){return this.get("/infra/connect/voice/agents")}createAgent(e){return this.post("/infra/connect/voice/agents",e)}getAgent(e){return this.get(`/infra/connect/voice/agents/${encodeURIComponent(e)}`)}updateAgent(e,t){return this.put(`/infra/connect/voice/agents/${encodeURIComponent(e)}`,t)}setAgentLead(e,t){return this.put(`/infra/connect/voice/agents/${encodeURIComponent(e)}/lead`,{customAgentId:t})}deleteAgent(e){return this.deleteRequest(`/infra/connect/voice/agents/${encodeURIComponent(e)}`)}numbers(){return this.get("/infra/connect/voice/numbers")}updateNumber(e,t){return this.patch(`/infra/connect/voice/numbers/${encodeURIComponent(e)}`,t)}async preview(e={}){try{return(await this.client.post("/infra/connect/voice/preview",e,{responseType:"arraybuffer"})).data}catch(t){let s=t?.response?.data;if(s instanceof ArrayBuffer||ArrayBuffer.isView(s))try{t.response.data=JSON.parse(new TextDecoder().decode(s))}catch{t.response.data=void 0}throw P(t)}}lines(){return this.get("/infra/connect/voice/lines")}activity(){return this.get("/infra/connect/voice/activity")}calls(e={}){return this.get("/infra/connect/voice/calls",{params:e})}call(e){return this.get(`/infra/connect/voice/calls/${I(e)}`)}callWithAI(e){return this.post("/infra/connect/voice/calls",e)}checkCallWithAI(e){return this.post("/infra/connect/voice/calls/check",e)}callMyPhone(e={}){return this.post("/infra/connect/voice/calls/my-phone",e)}testCall(e={}){return this.post("/infra/connect/voice/test-call",e)}};var He=class extends r{async list(e){return this.get("/platform/inbox/conversations",{params:e})}async create(e){return this.post("/platform/inbox/conversations",{address:e.phone,channel:e.channel??"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 Ge=class extends r{async list(e){return this.get("/infra/connect/whatsapp/templates",{params:e})}async sync(e={}){return this.post("/infra/connect/whatsapp/templates/sync",e.accountId?{accountId:e.accountId}:{})}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 fix(e){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/fix`,{})}async resubmit(e,t){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/resubmit`,t)}async deleteTemplate(e,t,s){let i=new URLSearchParams;t&&i.set("force","true"),s&&i.set("accountId",s);let o=i.toString();return this.deleteRequest(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}${o?`?${o}`:""}`)}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 s=`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/validate`;return t?this.post(s,t):this.get(s)}async preview(e,t,s,i){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:t,mappings:s,onEmptyVariable:i})}async getVariableManifest(e){let t=await this.retrieve(e),s=Array.isArray(t.data?.components)?t.data.components:[],i=[];for(let o of s)if(o.text){let p=o.text.match(/{{(\d+)}}/g);if(p)for(let m of p){let d=m.replace(/{{|}}/g,"");i.push({key:`var_${d}`,label:`${o.type} Var {{${d}}}`,type:"string",required:!0,group:o.type,description:`Variable placeholder in template ${o.type}`})}}return{name:`Template variables: ${t.data?.name||e}`,fields:i,uiHints:{icon:"Variables",primaryColor:"#059669"}}}};var yt=class{messages;conversations;constructor(e){this.messages=new S(e),this.conversations=new He(e)}},ht=class{leads;pipelines;activities;analytics;scoring;payments;chat;events;invoices;checkout;projects;niche;documents;invoiceExport;ai;constructor(e){this.leads=new N(e),this.pipelines=new F(e),this.activities=new V(e),this.analytics=new D(e),this.scoring=new q(e),this.payments=new M(e),this.chat=new yt(e),this.events=new K(e),this.invoices=new X(e),this.checkout=new $(e),this.projects=new Pe(e),this.niche=new ye(e),this.documents=new _(e),this.invoiceExport=new U(e),this.ai=new L(e)}},bt=class{automations;campaigns;conversations;home;drafts;firstRun;audiences;constructor(e){this.automations=new W(e),this.campaigns=new C(e),this.conversations=new H(e),this.home=new G(e),this.drafts=new Q(e),this.firstRun=new z(e),this.audiences=new Y(e)}},ft=class{projects;audits;insights;searchConsole;ranks;local;reports;backlinks;performance;briefs;research;constructor(e){this.projects=new Le(e),this.audits=new $e(e),this.insights=new Ee(e),this.searchConsole=new Oe(e),this.ranks=new Ve(e),this.local=new De(e),this.reports=new _e(e),this.backlinks=new Ne(e),this.performance=new Me(e),this.briefs=new Fe(e),this.research=new Ue(e)}},xt=class{packs;signals;tools;campaigns;runs;leads;import;lists;compliance;market;learning;lookalikes;freshness;audit;constructor(e){this.packs=new Z(e),this.signals=new ee(e),this.tools=new te(e),this.campaigns=new ne(e),this.runs=new re(e),this.leads=new se(e),this.import=new ie(e),this.lists=new oe(e),this.compliance=new ae(e),this.market=new ce(e),this.learning=new le(e),this.lookalikes=new ue(e),this.freshness=new pe(e),this.audit=new ge(e)}},Qe=class{erix;flow;seo;laie;constructor(e){this.erix=new ht(e),this.flow=new bt(e),this.seo=new ft(e),this.laie=new xt(e)}},kt=class{config;templates;constructor(e){this.config=new Be(e),this.templates=new B(e)}},wt=class{templates;constructor(e){this.templates=new Ge(e)}},vt=class{leadForms;constructor(e){this.leadForms=new j(e)}},Tt=class{email;whatsapp;facebook;meet;connections;accounts;voice;constructor(e){this.email=new kt(e),this.whatsapp=new wt(e),this.facebook=new vt(e),this.meet=new me(e),this.connections=new E(e),this.accounts=new O(e),this.voice=new We(e)}},Ct=class{files;folders;media;constructor(e){this.files=new je(e),this.folders=new Ke(e),this.media=new de(e)}},At=class{collector;constructor(e){this.collector=new qe(e)}},ze=class{connect;storage;serp;constructor(e){this.connect=new Tt(e),this.storage=new Ct(e),this.serp=new At(e)}},St=class{onboarding;persona;audit;constructor(e){this.onboarding=new be(e),this.persona=new fe(e),this.audit=new ke(e)}},Rt=class{me;members;sessions;notifications;constructor(e){this.me=new Se(e),this.members=new Re(e),this.sessions=new Ie(e),this.notifications=new he(e)}},Ye=class{auth;users;tenants;billing;support;ai;knowledge;health;catalog;constructor(e){this.auth=new we(e),this.users=new Rt(e),this.tenants=new St(e),this.billing=new ve(e),this.support=new Ae(e),this.ai=new xe(e),this.knowledge=new Ce(e),this.health=new J(e),this.catalog=new Te(e)}};var R=class extends x{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},Je=class{async constructEvent(e,t,s){if(!t)throw new R("No webhook signature provided");let i=Array.isArray(t)?t[0]:t;i.startsWith("sha256=")&&(i=i.slice(7));try{let o=await import("crypto"),m=o.createHmac("sha256",s).update(e).digest("hex");if(!o.timingSafeEqual(Buffer.from(m),Buffer.from(i)))throw new R("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(o){throw o instanceof R?o:new R(`Webhook payload parsing failed: ${o.message}`)}}};var It=typeof process<"u"&&"4.1.0"||"3.1.1";var Pt=Et.default??Et,Xe=class{client;socket=null;startSocket=null;socketPromise=null;socketQueue=[];clientCode;apiVersion;platform;product;infra;webhooks;constructor(e){let t=e.proxy;if(!e.apiKey&&!t)throw new T("API Key is required");this.clientCode=e.clientCode?.toUpperCase(),this.apiVersion=e.version??"v1";let s=e.baseUrl??Ze,i=$t(this.apiVersion,t?.url??s),o=e.socketUrl||s,p=typeof window<"u"&&typeof window.document<"u",m=p?"browser":typeof process<"u"?`node ${process.version}`:"unknown",d=p?globalThis.navigator?.userAgent||"browser":typeof process<"u"?process.platform:"unknown",Dt={...t?{}:{"x-api-key":e.apiKey,"x-client-code":e.clientCode?.toUpperCase()||""},"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:It,runtime:m,os:d})};if(this.client=qt.create({baseURL:i,headers:Dt,timeout:e.timeout??3e4}),Pt(this.client,{retries:3,retryDelay:Pt.exponentialDelay,retryCondition:f=>Pt.isNetworkOrIdempotentRequestError(f)||f.response?.status===429,onRetry:(f,_t,Lt)=>{typeof process<"u"&&process.env?.NODE_ENV==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${f}/3): ${Lt.method?.toUpperCase()} ${Lt.url}. Reason: ${_t.message}`)}}),this.platform=new Ye(this.client),this.product=new Qe(this.client),this.infra=new ze(this.client),this.webhooks=new Je,t){if(t.ticket){let f=t.ticket;this.startSocket=()=>this.initSocket(o,async()=>({ticket:await f()}))}}else{let f={apiKey:e.apiKey,clientCode:e.clientCode?.toUpperCase()||""};this.startSocket=()=>this.initSocket(o,async()=>f,{"x-api-key":f.apiKey,"x-client-code":f.clientCode})}if(p){let f={version:It,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=f}}initSocket(e,t,s){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:i})=>{this.socket=i(e,{auth:o=>{t().then(p=>o({...p,lastSeq:this.lastSeq}),()=>o({lastSeq:this.lastSeq}))},extraHeaders:s,transports:["websocket","polling"],tryAllTransports:!0}),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.closed||this.startSocket?.(),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]})}lastSeq;setupSocket(){this.socket&&(this.socket.on("connect_error",()=>{this.socket?.active||setTimeout(()=>{this.closed||this.socket?.connect()},5e3)}),this.socket.onAny((...e)=>{let t=e.at(-1)?.seq;typeof t=="number"&&t>(this.lastSeq??0)&&(this.lastSeq=t)}))}on(e,t){return this.closed||this.startSocket?.(),this.socket?this.socket.on(e,t):this.socketQueue.push({type:"on",args:[e,t]}),this}closed=!1;disconnect(){this.closed=!0,this.socket?this.socket.disconnect():this.socketPromise&&this.socketQueue.push({type:"disconnect",args:[]})}off(e,t){return this.socket?this.socket.off(e,t):this.socketQueue.push({type:"off",args:[e,t]}),this}async request(e,t,s,i){try{return(await this.client.request({method:e,url:t,data:s,params:i})).data}catch(o){throw o.response?new x(o.response.data?.message||o.response.data?.error||"Raw Execution Failed",o.response.status,o.response.data?.code):new x(o.message||"Network Error")}}};jt.config();var Ot="4.1.0";var Wt="Official TypeScript SDK for the ERIX API by ECODrIx: CRM, Flow automations, one inbox across WhatsApp, Instagram and email, GST invoices and payments. Node and browser (proxy mode).",w=new Kt;w.name("erix").description(Wt).version(Ot);function v(n){let e=n.key||process.env.ECOD_API_KEY,t=n.client||process.env.ECOD_CLIENT_CODE;return e||(console.error(u.red("Error: API Key is missing.")),console.log(u.yellow("Set ECOD_API_KEY environment variable or use --key <key>")),process.exit(1)),new Xe({apiKey:e,clientCode:t,baseUrl:n.baseUrl||process.env.ECOD_BASE_URL})}w.option("-k, --key <key>","ECODrIx API Key").option("-c, --client <code...","Tenant Client Code").option("--base-url <url>","API Base URL override");w.command("whoami").description("Verify current authentication and tenant status").action(async(n,e)=>{let t=e.parent.opts(),s=v(t);console.log(u.cyan("Checking connection to ECODrIx Platform..."));try{let i=await s.request("GET","/api/saas/me/profile");console.log(u.green("\u2714 Authenticated successfully!")),console.log(`${u.bold("User ID:")} ${i.id}`),console.log(`${u.bold("Organisation:")} ${i.organisation?.name||"N/A"}`),t.client&&console.log(`${u.bold("Tenant Code:")} ${u.magenta(t.client)}`)}catch(i){console.error(u.red("\u2716 Authentication failed")),console.error(u.dim(i.message)),process.exit(1)}});var Ht=w.command("whatsapp").description("WhatsApp Business API operations");Ht.command("send-template").description("Send a WhatsApp template message").argument("<phone>","Recipient phone number").argument("<template>","Template name").option("-v, --vars <json>","Template variables as JSON string","[]").action(async(n,e,t,s)=>{let i=s.parent.parent.opts(),o=v(i);try{let p=JSON.parse(t.vars);console.log(u.cyan(`Sending template '${e}' to ${n}...`));let m=await o.product.erix.chat.messages.sendTemplate({to:n,templateName:e,language:"en_US",variables:p});console.log(u.green("\u2714 Message sent successfully!")),console.log(u.dim(`ID: ${m?.id||"N/A"}`))}catch(p){console.error(u.red("\u2716 Failed to send message")),console.error(u.dim(p.message))}});var Vt=w.command("crm").description("CRM and Lead management");Vt.command("leads").description("List recent leads").option("-l, --limit <number>","Number of leads to fetch","10").option("-s, --status <status>","Filter by lead status").option("-p, --pipeline <id>","Filter by pipeline ID").option("-q, --search <query>","Search by name or email").action(async(n,e)=>{let t=e.parent.parent.opts(),s=v(t);try{let i=Number.parseInt(n.limit);console.log(u.cyan(`Fetching last ${i} leads...`));let o={limit:i};n.status&&(o.status=n.status),n.pipeline&&(o.pipelineId=n.pipeline),n.search&&(o.search=n.search);let p=await s.product.erix.leads.list(o),m=Array.isArray(p.data)?p.data:Array.isArray(p)?p:[];if(m.length===0){console.log(u.yellow("No leads found."));return}console.table(m.map(d=>({ID:d.id||d._id,Name:`${d.firstName} ${d.lastName||""}`.trim(),Phone:d.phone,Status:d.status,Score:d.score||0,Created:new Date(d.createdAt).toLocaleDateString()})))}catch(i){console.error(u.red("\u2716 Failed to fetch leads")),console.error(u.dim(i.message))}});Vt.command("pipelines").description("List all CRM pipelines").action(async(n,e)=>{let t=e.parent.parent.opts(),s=v(t);try{console.log(u.cyan("Fetching pipelines..."));let i=await s.product.erix.pipelines.list(),o=i.data||i||[];if(o.length===0){console.log(u.yellow("No pipelines found."));return}console.table(o.map(p=>({ID:p.id||p._id,Name:p.name,Default:p.isDefault?"Yes":"No",Stages:p.stages?.length||0})))}catch(i){console.error(u.red("\u2716 Failed to fetch pipelines")),console.error(u.dim(i.message))}});var Gt=w.command("analytics").description("Business Intelligence Analytics");Gt.command("overview").description("Get high-level CRM KPIs").option("-r, --range <range>","Date range (e.g., 24h, 7d, 30d, 365d)","30d").action(async(n,e)=>{let t=e.parent.parent.opts(),s=v(t);try{console.log(u.cyan(`Fetching overview metrics for last ${n.range}...`));let i=await s.product.erix.analytics.overview({range:n.range}),o=i.data||i;console.log(`
|
|
3
3
|
${u.bold("OVERVIEW KPIs:")}`),console.log(`Total Leads: ${u.green(o.totalLeads||0)}`),console.log(`Open Value: ${u.yellow(`$${(o.openValue||0).toLocaleString()}`)}`),console.log(`Won Revenue: ${u.green(`$${(o.wonRevenue||0).toLocaleString()}`)}`),console.log(`Avg Score: ${u.blue(o.avgScore?.toFixed(1)||0)}`),console.log(`Conversion: ${u.magenta(`${(o.conversionRate||0).toFixed(2)}%`)}
|
|
4
|
-
`)}catch(i){console.error(u.red("\u2716 Failed to fetch analytics overview")),console.error(u.dim(i.message))}});var
|
|
5
|
-
Welcome to the Erix Interactive Shell`))),console.log(u.dim(`SDK Version: ${
|
|
6
|
-
`));let i=
|
|
4
|
+
`)}catch(i){console.error(u.red("\u2716 Failed to fetch analytics overview")),console.error(u.dim(i.message))}});var Qt=w.command("webhooks").description("Webhook utility tools");Qt.command("verify").description("Verify a cryptographic webhook signature").argument("<payload>","The raw request body string").argument("<signature>","The 'x-ecodrix-signature' header value").argument("<secret>","Your webhook signing secret").action(async(n,e,t,s,i)=>{let o=i.parent.parent.opts(),p=v(o);try{await p.webhooks.constructEvent(n,e,t),console.log(u.green("\u2714 Signature is VALID"))}catch(m){console.error(u.red("\u2716 Error during verification")),console.error(u.dim(m.message))}});w.command("shell").alias("repl").description("Start an interactive SDK shell").action(async(n,e)=>{let t=e.parent.opts(),s=v(t);console.log(u.magenta(u.bold(`
|
|
5
|
+
Welcome to the Erix Interactive Shell`))),console.log(u.dim(`SDK Version: ${Ot}`)),console.log(u.dim(`The 'ecod' client is pre-initialized and ready.
|
|
6
|
+
`));let i=Bt.start({prompt:u.cyan("erix > "),useColors:!0});i.context.ecod=s,i.context.platform=s.platform,i.context.product=s.product,i.context.infra=s.infra,i.on("exit",()=>{console.log(u.yellow(`
|
|
7
7
|
Goodbye!`)),process.exit(0)})});w.command("completion").description("Generate Bash auto-completion script").action(()=>{console.log(`
|
|
8
8
|
# Erix Bash Completion
|
|
9
9
|
_erix_completions() {
|