@ecodrix/erix-api 1.3.1 → 1.3.3
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/index.d.ts +105 -1
- package/dist/ts/browser/index.global.js +14 -14
- package/dist/ts/browser/index.global.js.map +1 -1
- package/dist/ts/cjs/index.cjs +1 -1
- package/dist/ts/cjs/index.cjs.map +1 -1
- package/dist/ts/cjs/index.d.cts +105 -1
- package/dist/ts/esm/index.d.ts +105 -1
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import de from"repl";import{Command as he}from"commander";import Te from"dotenv";import o from"picocolors";import me from"axios";import ie from"axios-retry";import{io as ue}from"socket.io-client";var G=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},u=class extends G{status;code;constructor(e,t,r){super(e),this.name="APIError",this.status=t,this.code=r}},T=class extends u{constructor(e="Invalid API Key or Client Code"){super(e,401,"AUTH_FAILED"),this.name="AuthenticationError"}};var n=class{constructor(e){this.client=e}async post(e,t,r){try{let s=this.buildConfig(r);return(await this.client.post(e,t,s)).data}catch(s){this.handleError(s)}}async get(e,t){try{let r=this.buildConfig(t);return(await this.client.get(e,r)).data}catch(r){this.handleError(r)}}async patch(e,t,r){try{let s=this.buildConfig(r);return(await this.client.patch(e,t,s)).data}catch(s){this.handleError(s)}}async put(e,t,r){try{let s=this.buildConfig(r);return(await this.client.put(e,t,s)).data}catch(s){this.handleError(s)}}async deleteRequest(e,t){try{let r=this.buildConfig(t);return(await this.client.delete(e,r)).data}catch(r){this.handleError(r)}}buildConfig(e){if(!e)return;let t={...e};return e.idempotencyKey&&(t.headers={...t.headers,"Idempotency-Key":e.idempotencyKey}),t}handleError(e){throw e.response?new u(e.response.data?.message||e.response.data?.error||"API Request Failed",e.response.status,e.response.data?.code):new u(e.message||"Network Error")}};var z=class extends n{async list(e){return this.get(`/api/crm/leads/${e}/notes`)}async create(e,t){return this.post(`/api/crm/leads/${e}/notes`,t)}async update(e,t){return this.patch(`/api/crm/notes/${e}`,{content:t})}async pin(e,t=!0){return this.patch(`/api/crm/notes/${e}/pin`,{isPinned:t})}async delete(e){return this.deleteRequest(`/api/crm/notes/${e}`)}},f=class extends n{notes;constructor(e){super(e),this.notes=new z(e)}async timeline(e,t){return this.get(`/api/crm/leads/${e}/timeline`,{params:t})}async list(e,t){return this.get(`/api/crm/leads/${e}/activities`,{params:{...t}})}async log(e){return this.post(`/api/crm/leads/${e.leadId}/activities`,e)}async logCall(e,t){return this.post(`/api/crm/leads/${e}/calls`,t)}};var b=class extends n{async overview(e){return this.get("/api/crm/analytics/overview",{params:e})}async funnel(e){return this.get("/api/crm/analytics/funnel",{params:{pipelineId:e}})}async forecast(e){return this.get("/api/crm/analytics/forecast",{params:{pipelineId:e}})}async sources(e){return this.get("/api/crm/analytics/sources",{params:e})}async team(e){return this.get("/api/crm/analytics/team",{params:e})}async heatmap(e){return this.get("/api/crm/analytics/heatmap",{params:e})}async scores(){return this.get("/api/crm/analytics/scores")}async stageTime(e){return this.get("/api/crm/analytics/stage-time",{params:{pipelineId:e}})}async tiered(e){return this.get("/api/crm/analytics/tiered",{params:e})}async summary(e){return this.get("/api/crm/analytics/summary",{params:e})}async whatsapp(e){return this.get("/api/crm/analytics/whatsapp",{params:e})}};var v=class extends n{async stats(){return this.get("/api/crm/automation/stats")}async logs(e){return this.get("/api/crm/automation/logs",{params:e})}async retryFailedEvent(e){return this.post(`/api/crm/automation/logs/${e}/retry`,{})}};var x=class extends n{async list(){return this.get("/api/crm/automations")}async create(e){return this.post("/api/crm/automations",e)}async update(e,t){return this.patch(`/api/crm/automations/${e}`,t)}async toggle(e){return this.patch(`/api/crm/automations/${e}/toggle`)}async delete(e){return this.deleteRequest(`/api/crm/automations/${e}`)}async bulkDelete(e){return this.post("/api/crm/automations/bulk-delete",{ids:e})}async test(e,t){return this.post(`/api/crm/automations/${e}/test`,{leadId:t})}async getAvailableEvents(){return this.post("/api/crm/automations/events",{})}async enrollments(e,t){return this.get(`/api/crm/automations/${e}/enrollments`,{params:t})}async getEnrollment(e){return this.get(`/api/crm/automations/enrollments/${e}`)}async pauseEnrollment(e,t){return this.post(`/api/crm/automations/${e}/enrollments/${t}/pause`,{})}async resumeEnrollment(e,t){return this.post(`/api/crm/automations/${e}/enrollments/${t}/resume`,{})}async runs(e){return this.get(`/api/crm/automations/${e}/runs`)}async getRun(e){return this.get(`/api/crm/automations/runs/${e}`)}async resumeRun(e){return this.post(`/api/crm/automations/runs/${e}/resume`,{})}async abortRun(e){return this.post(`/api/crm/automations/runs/${e}/abort`,{})}async webhookEvent(e,t,r){return this.post("/api/crm/webhook-event",{ruleId:e,eventName:t,payload:r})}};var P=class extends n{async create(e){return this.post("/api/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:[{label:"New",value:"new"},{label:"Contacted",value:"contacted"},{label:"Qualified",value:"qualified"},{label:"Won",value:"won"},{label:"Lost",value:"lost"}]},{key:"value",label:"Lead Value",type:"currency",required:!1},{key:"source",label:"Source",type:"string",required:!1}],s=t.map(i=>({key:`metadata.extra.${i.name}`,label:i.label||i.name,type:i.type||"string",required:!!i.required,options:i.options,group:"Custom Fields"}));return{name:"Lead",fields:[...r,...s],uiHints:{icon:"User",primaryColor:"#3b82f6",defaultSort:{field:"createdAt",direction:"desc"},summaryFields:["firstName","lastName","phone","status"]}}}async upsert(e){return this.post("/api/crm/leads/upsert",e)}async createMany(e,t=50){let r=[];for(let s=0;s<e.length;s+=t){let l=e.slice(s,s+t).map(g=>this.create(g)),m=await Promise.allSettled(l);for(let g of m)if(g.status==="fulfilled")r.push(g.value);else throw g.reason}return r}async import(e){return this.post("/api/crm/leads/import",{leads:e})}async list(e){let t={...e};return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/api/crm/leads",{params:t})}async*listAutoPaging(e){let t=e?.page||1,r=!0;for(;r;){let s=await this.list({...e,page:t}),i=Array.isArray(s.data)?s.data:s||[];if(i.length===0){r=!1;break}for(let l of i)yield l;s.pagination&&t<s.pagination.pages||!s.pagination&&i.length>0?t++:r=!1}}async retrieve(e){return this.get(`/api/crm/leads/${e}`)}async retrieveByPhone(e){return this.get(`/api/crm/leads/phone/${encodeURIComponent(e)}`)}async retrieveByRef(e,t){return this.get(`/api/crm/leads/ref/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}async update(e,t){return this.patch(`/api/crm/leads/${e}`,t)}async move(e,t){return this.patch(`/api/crm/leads/${e}/move`,{stageId:t})}async convert(e,t,r){return this.post(`/api/crm/leads/${e}/convert`,{outcome:t,reason:r})}async tags(e,t){return this.patch(`/api/crm/leads/${e}/tags`,t)}async recalculateScore(e){return this.post(`/api/crm/leads/${e}/score`,{})}async updateMetadata(e,t){return this.patch(`/api/crm/leads/${e}/metadata`,t)}async fields(){return this.get("/api/crm/leads/fields")}async notes(e){return this.get(`/api/crm/leads/${e}/notes`)}async activities(e,t){return this.get(`/api/crm/leads/${e}/timeline`,{params:t})}async createNote(e,t){return this.post(`/api/crm/leads/${e}/notes`,t)}async updateNote(e,t,r){return this.patch(`/api/crm/notes/${t}`,r)}async deleteNote(e,t){return this.deleteRequest(`/api/crm/notes/${t}`)}async delete(e){return this.deleteRequest(`/api/crm/leads/${e}`)}async bulkDelete(e){return this.deleteRequest("/api/crm/leads",{data:{ids:e}})}};var w=class extends n{async capture(e){return this.post("/api/crm/payments/capture",e)}};var $=class extends n{async list(){return this.get("/api/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(s=>({key:s._id,label:s.name,type:"string",required:!0,options:[{label:s.name,value:s._id}],group:"Stages",uiHints:{color:s.color||"#cbd5e1",probability:s.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/api/crm/pipelines",e)}async retrieve(e){return this.get(`/api/crm/pipelines/${e}`)}async update(e,t){return this.patch(`/api/crm/pipelines/${e}`,t)}async setDefault(e){return this.patch(`/api/crm/pipelines/${e}/default`,{})}async duplicate(e,t){return this.post(`/api/crm/pipelines/${e}/duplicate`,{newName:t})}async archive(e){return this.patch(`/api/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/api/crm/pipelines/${e}`)}async board(e){return this.get(`/api/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/api/crm/pipelines/${e}/forecast`)}async addStage(e,t){return this.post(`/api/crm/pipelines/${e}/stages`,t)}async reorderStages(e,t){return this.patch(`/api/crm/pipelines/${e}/stages/reorder`,{order:t})}async updateStage(e,t){return this.patch(`/api/crm/stages/${e}`,t)}async deleteStage(e,t){return this.deleteRequest(`/api/crm/stages/${e}`,{data:t?{moveLeadsToStageId:t}:void 0})}};var C=class extends n{async getConfig(){return this.get("/api/crm/scoring")}async updateConfig(e){return this.patch("/api/crm/scoring",e)}async recalculate(e){return this.post(`/api/crm/scoring/${e}/recalculate`,{})}};var R=class extends n{async enroll(e){return this.post("/api/crm/sequences/enroll",e)}async unenroll(e){return this.deleteRequest(`/api/crm/sequences/unenroll/${e}`)}async listForLead(e){return this.get(`/api/crm/sequences/lead/${e}`)}};var A=class{leads;pipelines;activities;analytics;automations;sequences;scoring;payments;automationDashboard;constructor(e){this.leads=new P(e),this.pipelines=new $(e),this.activities=new f(e),this.analytics=new b(e),this.automations=new x(e),this.sequences=new R(e),this.scoring=new C(e),this.payments=new w(e),this.automationDashboard=new v(e)}};var I=class extends n{async sendCampaign(e){return this.post("/api/saas/emails/campaign",e)}async sendTest(e){return this.post("/api/saas/emails/test",{to:e})}async listTemplates(e){return this.get("/api/saas/mail/templates",{params:e})}async getTemplate(e){return this.get(`/api/saas/mail/templates/${e}`)}async createTemplate(e){return this.post("/api/saas/mail/templates",e)}async updateTemplate(e,t){return this.put(`/api/saas/mail/templates/${e}`,t)}async deleteTemplate(e,t=!1){return this.deleteRequest(`/api/saas/mail/templates/${e}`,{params:{force:t}})}async previewTemplate(e,t){return this.post(`/api/saas/mail/templates/${e}/preview`,t)}};var k=class extends n{async list(){return this.get("/api/saas/events")}async assign(e){return this.post("/api/saas/events/assign",e)}async unassign(e){return this.post("/api/saas/events/unassign",{name:e})}async unassignBulk(e){return this.post("/api/saas/events/unassign/bulk",{names:e})}async trigger(e){return this.post("/api/saas/workflows/trigger",e)}async listCustomEvents(){return this.get("/api/saas/crm/custom-events")}async createCustomEvent(e){return this.post("/api/saas/crm/custom-events",e)}async deleteCustomEvent(e){return this.deleteRequest(`/api/saas/crm/custom-events/${e}`)}async emit(e){return this.post("/api/saas/crm/events/emit",e)}};var S=class extends n{async system(){return(await this.get("/api/saas/health")).data}async clientHealth(){return(await this.get("/api/saas/health/client")).data}async getDiagnosticReport(){return this.clientHealth()}async jobStatus(e){return(await this.get(`/api/saas/jobs/status/${e}`)).data}};var E=class extends n{async listEventLogs(e){return this.get("/api/saas/events/logs",{params:e})}async getEventLog(e){return this.get(`/api/saas/events/logs/${e}`)}async listCallbackLogs(e){return this.get("/api/saas/callbacks/logs",{params:e})}async getStats(){return this.get("/api/saas/events/stats")}};var Q=class extends n{async sendCampaign(e){return this.post("/api/saas/marketing/emails/campaign",e)}async sendTest(e){return this.post("/api/saas/marketing/emails/test",{to:e})}},X=class extends n{async list(e){return this.get("/api/saas/marketing/campaigns",{params:e})}async create(e){return this.post("/api/saas/marketing/campaigns",e)}async retrieve(e){return this.get(`/api/saas/marketing/campaigns/${e}`)}async update(e,t){return this.patch(`/api/saas/marketing/campaigns/${e}`,t)}async delete(e){return this.deleteRequest(`/api/saas/marketing/campaigns/${e}`)}async send(e,t){return this.post(`/api/saas/marketing/campaigns/${e}/send`,t||{})}async stats(e){return this.get(`/api/saas/marketing/campaigns/${e}/stats`)}},Z=class extends n{async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}},D=class extends n{emails;campaigns;whatsapp;constructor(e){super(e),this.emails=new Q(e),this.campaigns=new X(e),this.whatsapp=new Z(e)}};import ge from"axios";var L=class extends n{async getUsage(){return this.get("/api/saas/storage/usage")}async createFolder(e){return this.post("/api/saas/storage/folders",{name:e})}async list(e,t){return this.get(`/api/saas/storage/files/${e}`,{params:t})}async delete(e){return this.deleteRequest("/api/saas/storage/files",{params:{key:e}})}async getDownloadUrl(e){return this.post("/api/saas/storage/download-url",{key:e})}async upload(e,t){let r=await this.post("/api/saas/storage/upload-url",t),{uploadUrl:s,key:i}=r.data;await ge.put(s,e,{headers:{"Content-Type":t.contentType}});let l=e.size||e.byteLength||0;return this.post("/api/saas/storage/confirm-upload",{key:i,sizeBytes:l})}};var q=class extends n{async create(e){return this.post("/api/saas/meet",e)}async list(e){return this.get("/api/saas/meet",{params:e})}async retrieve(e){return this.get(`/api/saas/meet/${e}`)}async update(e,t){return this.patch(`/api/saas/meet/${e}`,t)}async reschedule(e,t){return this.patch(`/api/saas/meet/${e}`,t)}async delete(e){return this.update(e,{status:"cancelled"})}};var O=class extends n{async listLogs(e){return this.get("/api/saas/events/logs",{params:e})}async retrieveLog(e){return this.get(`/api/saas/events/logs/${e}`)}async getStats(e){return this.get("/api/saas/events/stats",{params:e})}async listCallbacks(e){return this.get("/api/saas/callbacks/logs",{params:e})}async listAlerts(e){return this.get("/api/crm/notifications",{params:e})}async dismissAlert(e){return this.patch(`/api/crm/notifications/${e}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/api/crm/notifications/clear-all")}async retryAction(e){return this.post(`/api/crm/notifications/${e}/retry`,{})}};var M=class extends n{async listFailed(){return this.get("/api/saas/admin/queue/failed")}async getStats(){return this.get("/api/saas/admin/queue/stats")}async retryJob(e){return this.post(`/api/saas/admin/queue/${e}/retry`,{})}async deleteJob(e){return this.deleteRequest(`/api/saas/admin/queue/${e}`)}};var ee=class extends n{async create(e){return this.post("/api/saas/storage/folders",{name:e})}async delete(e){return this.deleteRequest(`/api/saas/storage/folders/${encodeURIComponent(e)}`)}},te=class extends n{async list(e,t){return this.get(`/api/saas/storage/files/${e}`,{params:t})}async getUploadUrl(e){return this.post("/api/saas/storage/upload-url",e)}async confirmUpload(e){return this.post("/api/saas/storage/confirm-upload",e)}async getDownloadUrl(e){return this.post("/api/saas/storage/download-url",{key:e})}async delete(e){return this.deleteRequest("/api/saas/storage/files",{params:{key:e}})}},N=class extends n{folders;files;constructor(e){super(e),this.folders=new ee(e),this.files=new te(e)}async usage(){return this.get("/api/saas/storage/usage")}};var h=class extends u{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},U=class{async constructEvent(e,t,r){if(!t)throw new h("No webhook signature provided");let s=Array.isArray(t)?t[0]:t;s.startsWith("sha256=")&&(s=s.slice(7));try{let i=await import("crypto"),m=i.createHmac("sha256",r).update(e).digest("hex");if(!i.timingSafeEqual(Buffer.from(m),Buffer.from(s)))throw new h("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(i){throw i instanceof h?i:new h(`Webhook payload parsing failed: ${i.message}`)}}};var _=class extends n{async list(e){return this.get("/api/saas/chat/broadcasts",{params:e})}async retrieve(e){return this.get(`/api/saas/chat/broadcasts/${e}`)}async create(e){return this.post("/api/saas/chat/broadcast",e)}async update(e,t){return this.patch(`/api/saas/chat/broadcasts/${e}`,t)}async delete(e){return this.deleteRequest(`/api/saas/chat/broadcasts/${e}`)}};var F=class extends n{async list(e){return this.get("/api/saas/chat/conversations",{params:e})}async create(e){return this.post("/api/saas/chat/conversations",e)}async retrieve(e){return this.get(`/api/saas/chat/conversations/${e}`)}async messages(e,t){return this.get(`/api/saas/chat/conversations/${e}/messages`,{params:t})}async linkLead(e,t,r){return this.post(`/api/saas/chat/conversations/${e}/link-lead`,{leadId:t,leadData:r})}async markRead(e){return this.post(`/api/saas/chat/conversations/${e}/read`,{})}async delete(e){return this.deleteRequest(`/api/saas/chat/conversations/${e}`)}async bulkDelete(e){return this.post("/api/saas/chat/conversations/bulk-delete",{ids:e})}};var B=class extends n{async send(e){return this.post("/api/saas/chat/send",e)}async sendTemplate(e){return this.post("/api/saas/chat/send",{...e,templateLanguage:e.language||e.templateLanguage||"en_US"})}async star(e,t){return this.post(`/api/saas/chat/messages/${e}/star`,{isStarred:t})}async react(e,t){return this.post(`/api/saas/chat/messages/${e}/react`,{reaction:t})}async markRead(e){return this.post(`/api/saas/chat/conversations/${e}/read`)}async upload(e){let t=new FormData;return t.append("file",e),this.post("/api/saas/chat/upload",t,{headers:{"Content-Type":"multipart/form-data"}})}};var K=class extends n{async list(e){return this.get("/api/saas/chat/templates",{params:e})}async sync(){return this.post("/api/saas/chat/templates/sync",{})}async retrieve(e){return this.get(`/api/saas/chat/templates/${encodeURIComponent(e)}`)}async create(e){return this.post("/api/saas/chat/templates",e)}async update(e,t){return this.put(`/api/saas/chat/templates/${e}`,t)}async deleteTemplate(e,t){return this.deleteRequest(`/api/saas/chat/templates/${encodeURIComponent(e)}${t?"?force=true":""}`)}async mappingConfig(){return this.get("/api/saas/chat/templates/mapping/config")}async collections(){return this.get("/api/saas/chat/templates/collections")}async collectionFields(e){return this.get(`/api/saas/chat/templates/collections/${encodeURIComponent(e)}/fields`)}async updateMapping(e,t){return this.put(`/api/saas/chat/templates/${encodeURIComponent(e)}/mapping`,t)}async validate(e){return this.get(`/api/saas/chat/templates/${encodeURIComponent(e)}/validate`)}async preview(e,t){return this.post(`/api/saas/chat/templates/${encodeURIComponent(e)}/preview`,{context:t})}async getVariableManifest(e){let t=await this.retrieve(e),r=Array.isArray(t.data?.components)?t.data.components:[],s=[];for(let i of r)if(i.text){let l=i.text.match(/{{(\d+)}}/g);if(l)for(let m of l){let g=m.replace(/{{|}}/g,"");s.push({key:`var_${g}`,label:`${i.type} Var {{${g}}}`,type:"string",required:!0,group:i.type,description:`Variable placeholder in template ${i.type}`})}}return{name:`Template variables: ${t.data?.name||e}`,fields:s,uiHints:{icon:"Variables",primaryColor:"#059669"}}}async checkUsage(e){return this.get(`/api/saas/chat/templates/${encodeURIComponent(e)}/usage`)}};var V=class extends n{messages;conversations;broadcasts;templates;constructor(e){super(e),this.messages=new B(e),this.conversations=new F(e),this.broadcasts=new _(e),this.templates=new K(e)}async upload(e,t){let r=new FormData;return r.append("file",e,t),this.post("/api/saas/chat/upload",r,{headers:typeof r.getHeaders=="function"?r.getHeaders():void 0})}async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}};var H=class extends n{async listBlueprints(){return this.get("/api/agency/blueprints")}async createBlueprint(e){return this.post("/api/agency/blueprints",e)}async deployBlueprint(e){return this.post("/api/agency/blueprints/deploy",e)}async getPortfolioStats(e){return this.get(`/api/agency/portfolio/${e}/stats`)}async getPortfolioHealth(e){return this.get(`/api/agency/portfolio/${e}/health`)}async getUsage(e){return this.get(`/api/agency/usage/${e}`)}async listStaff(e){return this.get(`/api/agency/staff/${e}`)}async createStaff(e){return this.post("/api/agency/staff",e)}};var se=class extends n{async list(){return this.get("/api/services/clients")}async getCountAndGenerateCode(){return this.get("/api/services/clients/count")}async retrieve(e){return this.get(`/api/services/clients/${e}`)}async getApiKey(e){return this.get(`/api/services/clients/${e}/api-key`)}async rotateApiKey(e){return this.post(`/api/services/clients/${e}/api-key`,{})}async create(e){return this.post("/api/services/clients",e)}async getConfig(e){return this.get(`/api/services/clients/${e}/config`)}async updateConfig(e,t){return this.patch(`/api/services/clients/${e}/config`,t)}async getSecrets(e){return this.get(`/api/services/clients/${e}/secrets`)}async updateSecrets(e,t){return this.post(`/api/services/clients/${e}/secrets`,t)}async replaceSecrets(e,t){return this.put(`/api/services/clients/${e}/secrets`,t)}async patchSecrets(e,t){return this.patch(`/api/services/clients/${e}/secrets`,t)}async getDataSource(e){return this.get(`/api/services/clients/${e}/datasource`)}async manageDataSource(e,t){return this.post(`/api/services/clients/${e}/datasource`,t)}async updateIdentity(e,t){return this.patch(`/api/services/clients/${e}/identity`,t)}async googleReauth(e,t={}){return this.post(`/api/services/clients/${e}/google/reauth`,t)}async delete(e){return this.deleteRequest(`/api/services/clients/${e}`)}},ae=class extends n{async list(){return this.get("/api/services/blogs")}},ne=class extends n{async add(e){return this.post("/api/services/add-lead",e)}},W=class extends n{clients;blogs;globalLeads;constructor(e){super(e),this.clients=new se(e),this.blogs=new ae(e),this.globalLeads=new ne(e)}};var re=class extends n{async getConfig(){return this.get("/api/settings/email")}async switchProvider(e){return this.post("/api/settings/email/provider",{provider:e})}async saveSmtp(e){return this.post("/api/settings/email/smtp",e)}async initDomainVerification(e){return this.post("/api/settings/email/ses/domain",{domain:e})}async saveEmailConfig(e){return this.post("/api/settings/email/ses/config",e)}async checkSesVerification(){return this.get("/api/settings/email/ses/verify")}async removeSesIdentity(){return this.deleteRequest("/api/settings/email/ses/domain")}async sendTest(e){return this.post("/api/settings/email/test",{toEmail:e})}async saveAdvancedConfig(e){return this.post("/api/settings/email/advanced",e)}async getHealth(){return this.get("/api/settings/email/health")}async fixDmarc(){return this.post("/api/settings/email/ses/fix-dmarc",{})}async listProviders(){return this.get("/api/settings/email/providers")}},j=class extends n{email;constructor(e){super(e),this.email=new re(e)}};var J=class extends n{async list(){return this.get("/api/saas/cors")}async create(e){return this.post("/api/saas/cors",e)}async update(e,t){return this.patch(`/api/saas/cors/${e}`,t)}async delete(e){return this.deleteRequest(`/api/saas/cors/${e}`)}};var ye="https://api.ecodrix.com",Y=class{client;socket;clientCode;whatsapp;crm;media;meet;notifications;email;logs;events;webhooks;storage;marketing;health;queue;agency;services;settings;cors;constructor(e){if(!e.apiKey)throw new T("API Key is required");this.clientCode=e.clientCode?.toUpperCase();let t=e.baseUrl??ye,r=e.socketUrl||t,s=typeof window<"u"&&typeof window.document<"u",i=s?"browser":typeof process<"u"?`node ${process.version}`:"unknown",l=s?globalThis.navigator?.userAgent||"browser":typeof process<"u"?process.platform:"unknown",m={"x-api-key":e.apiKey,"x-client-code":e.clientCode?.toUpperCase()||"","Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:"1.0.0",runtime:i,os:l})};if(e.coreApiKey&&(m["x-core-api-key"]=e.coreApiKey),this.client=me.create({baseURL:t,headers:m}),ie(this.client,{retries:3,retryDelay:ie.exponentialDelay,retryCondition:g=>ie.isNetworkOrIdempotentRequestError(g)||g.response?.status===429,onRetry:(g,le,oe)=>{typeof process<"u"&&process.env?.NODE_ENV==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${g}/3): ${oe.method?.toUpperCase()} ${oe.url}. Reason: ${le.message}`)}}),this.whatsapp=new V(this.client),this.crm=new A(this.client),this.media=new L(this.client),this.meet=new q(this.client),this.notifications=new O(this.client),this.email=new I(this.client),this.logs=new E(this.client),this.events=new k(this.client),this.webhooks=new U,this.storage=new N(this.client),this.marketing=new D(this.client),this.health=new S(this.client),this.queue=new M(this.client),this.agency=new H(this.client),this.services=new W(this.client),this.settings=new j(this.client),this.cors=new J(this.client),this.socket=ue(r,{extraHeaders:{"x-api-key":e.apiKey,"x-client-code":e.clientCode?.toUpperCase()||""}}),this.setupSocket(e.clientCode),s){let g={version:"1.2.2",clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=g,window.ecodrix||(window.ecodrix=this)}}joinRoom(e){this.socket.emit("join-room",e)}leaveRoom(e){this.socket.emit("leave-room",e)}setupSocket(e){this.socket.on("connect",()=>{e&&this.socket.emit("join-room",e.toUpperCase())})}on(e,t){return this.socket.on(e,t),this}disconnect(){this.socket.disconnect()}off(e,t){return this.socket.off(e,t),this}async request(e,t,r,s){try{return(await this.client.request({method:e,url:t,data:r,params:s})).data}catch(i){throw i.response?new u(i.response.data?.message||i.response.data?.error||"Raw Execution Failed",i.response.status,i.response.data?.code):new u(i.message||"Network Error")}}};Te.config();var ce="1.3.1";var fe="Official Isomorphic SDK for the ECODrIx platform. Native support for WhatsApp, CRM, Storage, and Meetings across TS, JS, Python, and Java.",y=new he;y.name("erix").description(fe).version(ce);function d(a){let e=a.key||process.env.ECOD_API_KEY,t=a.client||process.env.ECOD_CLIENT_CODE;return e||(console.error(o.red("Error: API Key is missing.")),console.log(o.yellow("Set ECOD_API_KEY environment variable or use --key <key>")),process.exit(1)),new Y({apiKey:e,clientCode:t,baseUrl:a.baseUrl||process.env.ECOD_BASE_URL})}y.option("-k, --key <key>","ECODrIx API Key").option("-c, --client <code...","Tenant Client Code").option("--base-url <url>","API Base URL override");y.command("whoami").description("Verify current authentication and tenant status").action(async(a,e)=>{let t=e.parent.opts(),r=d(t);console.log(o.cyan("Checking connection to ECODrIx Platform..."));try{let s=await r.request("GET","/api/saas/me/profile");console.log(o.green("\u2714 Authenticated successfully!")),console.log(`${o.bold("User ID:")} ${s.id}`),console.log(`${o.bold("Organisation:")} ${s.organisation?.name||"N/A"}`),t.client&&console.log(`${o.bold("Tenant Code:")} ${o.magenta(t.client)}`)}catch(s){console.error(o.red("\u2716 Authentication failed")),console.error(o.dim(s.message)),process.exit(1)}});var be=y.command("whatsapp").description("WhatsApp Business API operations");be.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(a,e,t,r)=>{let s=r.parent.parent.opts(),i=d(s);try{let l=JSON.parse(t.vars);console.log(o.cyan(`Sending template '${e}' to ${a}...`));let m=await i.whatsapp.messages.sendTemplate({to:a,templateName:e,language:"en_US",variables:l});console.log(o.green("\u2714 Message sent successfully!")),console.log(o.dim(`ID: ${m?.id||"N/A"}`))}catch(l){console.error(o.red("\u2716 Failed to send message")),console.error(o.dim(l.message))}});var pe=y.command("crm").description("CRM and Lead management");pe.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(a,e)=>{let t=e.parent.parent.opts(),r=d(t);try{let s=Number.parseInt(a.limit);console.log(o.cyan(`Fetching last ${s} leads...`));let i={limit:s};a.status&&(i.status=a.status),a.pipeline&&(i.pipelineId=a.pipeline),a.search&&(i.search=a.search);let l=await r.crm.leads.list(i),m=Array.isArray(l.data)?l.data:Array.isArray(l)?l:[];if(m.length===0){console.log(o.yellow("No leads found."));return}console.table(m.map(g=>({ID:g.id||g._id,Name:`${g.firstName} ${g.lastName||""}`.trim(),Phone:g.phone,Status:g.status,Score:g.score||0,Created:new Date(g.createdAt).toLocaleDateString()})))}catch(s){console.error(o.red("\u2716 Failed to fetch leads")),console.error(o.dim(s.message))}});pe.command("pipelines").description("List all CRM pipelines").action(async(a,e)=>{let t=e.parent.parent.opts(),r=d(t);try{console.log(o.cyan("Fetching pipelines..."));let s=await r.crm.pipelines.list(),i=s.data||s||[];if(i.length===0){console.log(o.yellow("No pipelines found."));return}console.table(i.map(l=>({ID:l.id||l._id,Name:l.name,Default:l.isDefault?"Yes":"No",Stages:l.stages?.length||0})))}catch(s){console.error(o.red("\u2716 Failed to fetch pipelines")),console.error(o.dim(s.message))}});var ve=y.command("analytics").description("Business Intelligence Analytics");ve.command("overview").description("Get high-level CRM KPIs").option("-r, --range <range>","Date range (e.g., 24h, 7d, 30d, 365d)","30d").action(async(a,e)=>{let t=e.parent.parent.opts(),r=d(t);try{console.log(o.cyan(`Fetching overview metrics for last ${a.range}...`));let s=await r.crm.analytics.overview({range:a.range}),i=s.data||s;console.log(`
|
|
2
|
+
import he from"repl";import{Command as Te}from"commander";import fe from"dotenv";import o from"picocolors";import ue from"axios";import oe from"axios-retry";import{io as ye}from"socket.io-client";var z=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},u=class extends z{status;code;constructor(e,t,r){super(e),this.name="APIError",this.status=t,this.code=r}},T=class extends u{constructor(e="Invalid API Key or Client Code"){super(e,401,"AUTH_FAILED"),this.name="AuthenticationError"}};var n=class{constructor(e){this.client=e}async post(e,t,r){try{let s=this.buildConfig(r);return(await this.client.post(e,t,s)).data}catch(s){this.handleError(s)}}async get(e,t){try{let r=this.buildConfig(t);return(await this.client.get(e,r)).data}catch(r){this.handleError(r)}}async patch(e,t,r){try{let s=this.buildConfig(r);return(await this.client.patch(e,t,s)).data}catch(s){this.handleError(s)}}async put(e,t,r){try{let s=this.buildConfig(r);return(await this.client.put(e,t,s)).data}catch(s){this.handleError(s)}}async deleteRequest(e,t){try{let r=this.buildConfig(t);return(await this.client.delete(e,r)).data}catch(r){this.handleError(r)}}buildConfig(e){if(!e)return;let t={...e};return e.idempotencyKey&&(t.headers={...t.headers,"Idempotency-Key":e.idempotencyKey}),t}handleError(e){throw e.response?new u(e.response.data?.message||e.response.data?.error||"API Request Failed",e.response.status,e.response.data?.code):new u(e.message||"Network Error")}};var Q=class extends n{async list(e){return this.get(`/api/crm/leads/${e}/notes`)}async create(e,t){return this.post(`/api/crm/leads/${e}/notes`,t)}async update(e,t){return this.patch(`/api/crm/notes/${e}`,{content:t})}async pin(e,t=!0){return this.patch(`/api/crm/notes/${e}/pin`,{isPinned:t})}async delete(e){return this.deleteRequest(`/api/crm/notes/${e}`)}},f=class extends n{notes;constructor(e){super(e),this.notes=new Q(e)}async timeline(e,t){return this.get(`/api/crm/leads/${e}/timeline`,{params:t})}async list(e,t){return this.get(`/api/crm/leads/${e}/activities`,{params:{...t}})}async log(e){return this.post(`/api/crm/leads/${e.leadId}/activities`,e)}async logCall(e,t){return this.post(`/api/crm/leads/${e}/calls`,t)}};var b=class extends n{async overview(e){return this.get("/api/crm/analytics/overview",{params:e})}async funnel(e){return this.get("/api/crm/analytics/funnel",{params:{pipelineId:e}})}async forecast(e){return this.get("/api/crm/analytics/forecast",{params:{pipelineId:e}})}async sources(e){return this.get("/api/crm/analytics/sources",{params:e})}async team(e){return this.get("/api/crm/analytics/team",{params:e})}async heatmap(e){return this.get("/api/crm/analytics/heatmap",{params:e})}async scores(){return this.get("/api/crm/analytics/scores")}async stageTime(e){return this.get("/api/crm/analytics/stage-time",{params:{pipelineId:e}})}async tiered(e){return this.get("/api/crm/analytics/tiered",{params:e})}async summary(e){return this.get("/api/crm/analytics/summary",{params:e})}async whatsapp(e){return this.get("/api/crm/analytics/whatsapp",{params:e})}};var v=class extends n{async stats(){return this.get("/api/crm/automation/stats")}async logs(e){return this.get("/api/crm/automation/logs",{params:e})}async retryFailedEvent(e){return this.post(`/api/crm/automation/logs/${e}/retry`,{})}};var x=class extends n{async list(){return this.get("/api/crm/automations")}async create(e){return this.post("/api/crm/automations",e)}async update(e,t){return this.patch(`/api/crm/automations/${e}`,t)}async toggle(e){return this.patch(`/api/crm/automations/${e}/toggle`)}async delete(e){return this.deleteRequest(`/api/crm/automations/${e}`)}async bulkDelete(e){return this.post("/api/crm/automations/bulk-delete",{ids:e})}async test(e,t){return this.post(`/api/crm/automations/${e}/test`,{leadId:t})}async getAvailableEvents(){return this.post("/api/crm/automations/events",{})}async enrollments(e,t){return this.get(`/api/crm/automations/${e}/enrollments`,{params:t})}async getEnrollment(e){return this.get(`/api/crm/automations/enrollments/${e}`)}async pauseEnrollment(e,t){return this.post(`/api/crm/automations/${e}/enrollments/${t}/pause`,{})}async resumeEnrollment(e,t){return this.post(`/api/crm/automations/${e}/enrollments/${t}/resume`,{})}async runs(e){return this.get(`/api/crm/automations/${e}/runs`)}async getRun(e){return this.get(`/api/crm/automations/runs/${e}`)}async resumeRun(e){return this.post(`/api/crm/automations/runs/${e}/resume`,{})}async abortRun(e){return this.post(`/api/crm/automations/runs/${e}/abort`,{})}async webhookEvent(e,t,r){return this.post("/api/crm/webhook-event",{ruleId:e,eventName:t,payload:r})}};var P=class extends n{async create(e){return this.post("/api/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:[{label:"New",value:"new"},{label:"Contacted",value:"contacted"},{label:"Qualified",value:"qualified"},{label:"Won",value:"won"},{label:"Lost",value:"lost"}]},{key:"value",label:"Lead Value",type:"currency",required:!1},{key:"source",label:"Source",type:"string",required:!1}],s=t.map(i=>({key:`metadata.extra.${i.name}`,label:i.label||i.name,type:i.type||"string",required:!!i.required,options:i.options,group:"Custom Fields"}));return{name:"Lead",fields:[...r,...s],uiHints:{icon:"User",primaryColor:"#3b82f6",defaultSort:{field:"createdAt",direction:"desc"},summaryFields:["firstName","lastName","phone","status"]}}}async upsert(e){return this.post("/api/crm/leads/upsert",e)}async createMany(e,t=50){let r=[];for(let s=0;s<e.length;s+=t){let l=e.slice(s,s+t).map(g=>this.create(g)),m=await Promise.allSettled(l);for(let g of m)if(g.status==="fulfilled")r.push(g.value);else throw g.reason}return r}async import(e){return this.post("/api/crm/leads/import",{leads:e})}async list(e){let t={...e};return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/api/crm/leads",{params:t})}async*listAutoPaging(e){let t=e?.page||1,r=!0;for(;r;){let s=await this.list({...e,page:t}),i=Array.isArray(s.data)?s.data:s||[];if(i.length===0){r=!1;break}for(let l of i)yield l;s.pagination&&t<s.pagination.pages||!s.pagination&&i.length>0?t++:r=!1}}async retrieve(e){return this.get(`/api/crm/leads/${e}`)}async retrieveByPhone(e){return this.get(`/api/crm/leads/phone/${encodeURIComponent(e)}`)}async retrieveByRef(e,t){return this.get(`/api/crm/leads/ref/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}async update(e,t){return this.patch(`/api/crm/leads/${e}`,t)}async move(e,t){return this.patch(`/api/crm/leads/${e}/move`,{stageId:t})}async convert(e,t,r){return this.post(`/api/crm/leads/${e}/convert`,{outcome:t,reason:r})}async tags(e,t){return this.patch(`/api/crm/leads/${e}/tags`,t)}async recalculateScore(e){return this.post(`/api/crm/leads/${e}/score`,{})}async updateMetadata(e,t){return this.patch(`/api/crm/leads/${e}/metadata`,t)}async fields(){return this.get("/api/crm/leads/fields")}async notes(e){return this.get(`/api/crm/leads/${e}/notes`)}async activities(e,t){return this.get(`/api/crm/leads/${e}/timeline`,{params:t})}async createNote(e,t){return this.post(`/api/crm/leads/${e}/notes`,t)}async updateNote(e,t,r){return this.patch(`/api/crm/notes/${t}`,r)}async deleteNote(e,t){return this.deleteRequest(`/api/crm/notes/${t}`)}async delete(e){return this.deleteRequest(`/api/crm/leads/${e}`)}async bulkDelete(e){return this.deleteRequest("/api/crm/leads",{data:{ids:e}})}};var w=class extends n{async capture(e){return this.post("/api/crm/payments/capture",e)}};var C=class extends n{async list(){return this.get("/api/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(s=>({key:s._id,label:s.name,type:"string",required:!0,options:[{label:s.name,value:s._id}],group:"Stages",uiHints:{color:s.color||"#cbd5e1",probability:s.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/api/crm/pipelines",e)}async retrieve(e){return this.get(`/api/crm/pipelines/${e}`)}async update(e,t){return this.patch(`/api/crm/pipelines/${e}`,t)}async setDefault(e){return this.patch(`/api/crm/pipelines/${e}/default`,{})}async duplicate(e,t){return this.post(`/api/crm/pipelines/${e}/duplicate`,{newName:t})}async archive(e){return this.patch(`/api/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/api/crm/pipelines/${e}`)}async checkInUse(e){return this.get(`/api/crm/pipelines/${e}/in-use`)}async board(e){return this.get(`/api/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/api/crm/pipelines/${e}/forecast`)}async addStage(e,t){return this.post(`/api/crm/pipelines/${e}/stages`,t)}async reorderStages(e,t){return this.patch(`/api/crm/pipelines/${e}/stages/reorder`,{order:t})}async updateStage(e,t){return this.patch(`/api/crm/stages/${e}`,t)}async deleteStage(e,t){return this.deleteRequest(`/api/crm/stages/${e}`,{data:t?{moveLeadsToStageId:t}:void 0})}};var $=class extends n{async getConfig(){return this.get("/api/crm/scoring")}async updateConfig(e){return this.patch("/api/crm/scoring",e)}async recalculate(e){return this.post(`/api/crm/scoring/${e}/recalculate`,{})}};var R=class extends n{async enroll(e){return this.post("/api/crm/sequences/enroll",e)}async unenroll(e){return this.deleteRequest(`/api/crm/sequences/unenroll/${e}`)}async listForLead(e){return this.get(`/api/crm/sequences/lead/${e}`)}};var A=class{leads;pipelines;activities;analytics;automations;sequences;scoring;payments;automationDashboard;constructor(e){this.leads=new P(e),this.pipelines=new C(e),this.activities=new f(e),this.analytics=new b(e),this.automations=new x(e),this.sequences=new R(e),this.scoring=new $(e),this.payments=new w(e),this.automationDashboard=new v(e)}};var I=class extends n{async sendCampaign(e){return this.post("/api/saas/emails/campaign",e)}async sendTest(e){return this.post("/api/saas/emails/test",{to:e})}async listTemplates(e){return this.get("/api/saas/mail/templates",{params:e})}async getTemplate(e){return this.get(`/api/saas/mail/templates/${e}`)}async createTemplate(e){return this.post("/api/saas/mail/templates",e)}async updateTemplate(e,t){return this.put(`/api/saas/mail/templates/${e}`,t)}async deleteTemplate(e,t=!1){return this.deleteRequest(`/api/saas/mail/templates/${e}`,{params:{force:t}})}async previewTemplate(e,t){return this.post(`/api/saas/mail/templates/${e}/preview`,t)}};var k=class extends n{async list(){return this.get("/api/saas/events")}async assign(e){return this.post("/api/saas/events/assign",e)}async unassign(e){return this.post("/api/saas/events/unassign",{name:e})}async unassignBulk(e){return this.post("/api/saas/events/unassign/bulk",{names:e})}async trigger(e){return this.post("/api/saas/workflows/trigger",e)}async listCustomEvents(){return this.get("/api/saas/crm/custom-events")}async createCustomEvent(e){return this.post("/api/saas/crm/custom-events",e)}async deleteCustomEvent(e){return this.deleteRequest(`/api/saas/crm/custom-events/${e}`)}async emit(e){return this.post("/api/saas/crm/events/emit",e)}};var S=class extends n{async system(){return(await this.get("/api/saas/health")).data}async clientHealth(){return(await this.get("/api/saas/health/client")).data}async getDiagnosticReport(){return this.clientHealth()}async jobStatus(e){return(await this.get(`/api/saas/jobs/status/${e}`)).data}};var E=class extends n{async listEventLogs(e){return this.get("/api/saas/events/logs",{params:e})}async getEventLog(e){return this.get(`/api/saas/events/logs/${e}`)}async listCallbackLogs(e){return this.get("/api/saas/callbacks/logs",{params:e})}async getStats(){return this.get("/api/saas/events/stats")}};var X=class extends n{async sendCampaign(e){return this.post("/api/saas/marketing/emails/campaign",e)}async sendTest(e){return this.post("/api/saas/marketing/emails/test",{to:e})}},Z=class extends n{async list(e){return this.get("/api/saas/marketing/campaigns",{params:e})}async create(e){return this.post("/api/saas/marketing/campaigns",e)}async retrieve(e){return this.get(`/api/saas/marketing/campaigns/${e}`)}async update(e,t){return this.patch(`/api/saas/marketing/campaigns/${e}`,t)}async delete(e){return this.deleteRequest(`/api/saas/marketing/campaigns/${e}`)}async send(e,t){return this.post(`/api/saas/marketing/campaigns/${e}/send`,t||{})}async stats(e){return this.get(`/api/saas/marketing/campaigns/${e}/stats`)}},ee=class extends n{async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}},D=class extends n{emails;campaigns;whatsapp;constructor(e){super(e),this.emails=new X(e),this.campaigns=new Z(e),this.whatsapp=new ee(e)}};import me from"axios";var L=class extends n{async getUsage(){return this.get("/api/saas/storage/usage")}async createFolder(e){return this.post("/api/saas/storage/folders",{name:e})}async list(e,t){return this.get(`/api/saas/storage/files/${e}`,{params:t})}async delete(e){return this.deleteRequest("/api/saas/storage/files",{params:{key:e}})}async getDownloadUrl(e){return this.post("/api/saas/storage/download-url",{key:e})}async upload(e,t){let r=await this.post("/api/saas/storage/upload-url",t),{uploadUrl:s,key:i}=r.data;await me.put(s,e,{headers:{"Content-Type":t.contentType}});let l=e.size||e.byteLength||0;return this.post("/api/saas/storage/confirm-upload",{key:i,sizeBytes:l})}};var q=class extends n{async create(e){return this.post("/api/saas/meet",e)}async list(e){return this.get("/api/saas/meet",{params:e})}async retrieve(e){return this.get(`/api/saas/meet/${e}`)}async update(e,t){return this.patch(`/api/saas/meet/${e}`,t)}async reschedule(e,t){return this.patch(`/api/saas/meet/${e}`,t)}async delete(e){return this.update(e,{status:"cancelled"})}};var O=class extends n{async listLogs(e){return this.get("/api/saas/events/logs",{params:e})}async retrieveLog(e){return this.get(`/api/saas/events/logs/${e}`)}async getStats(e){return this.get("/api/saas/events/stats",{params:e})}async listCallbacks(e){return this.get("/api/saas/callbacks/logs",{params:e})}async listAlerts(e){return this.get("/api/crm/notifications",{params:e})}async dismissAlert(e){return this.patch(`/api/crm/notifications/${e}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/api/crm/notifications/clear-all")}async retryAction(e){return this.post(`/api/crm/notifications/${e}/retry`,{})}};var M=class extends n{async listFailed(){return this.get("/api/saas/admin/queue/failed")}async getStats(){return this.get("/api/saas/admin/queue/stats")}async retryJob(e){return this.post(`/api/saas/admin/queue/${e}/retry`,{})}async deleteJob(e){return this.deleteRequest(`/api/saas/admin/queue/${e}`)}};var te=class extends n{async create(e){return this.post("/api/saas/storage/folders",{name:e})}async delete(e){return this.deleteRequest(`/api/saas/storage/folders/${encodeURIComponent(e)}`)}},se=class extends n{async list(e,t){return this.get(`/api/saas/storage/files/${e}`,{params:t})}async getUploadUrl(e){return this.post("/api/saas/storage/upload-url",e)}async confirmUpload(e){return this.post("/api/saas/storage/confirm-upload",e)}async getDownloadUrl(e){return this.post("/api/saas/storage/download-url",{key:e})}async delete(e){return this.deleteRequest("/api/saas/storage/files",{params:{key:e}})}},N=class extends n{folders;files;constructor(e){super(e),this.folders=new te(e),this.files=new se(e)}async usage(){return this.get("/api/saas/storage/usage")}};var h=class extends u{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},U=class{async constructEvent(e,t,r){if(!t)throw new h("No webhook signature provided");let s=Array.isArray(t)?t[0]:t;s.startsWith("sha256=")&&(s=s.slice(7));try{let i=await import("crypto"),m=i.createHmac("sha256",r).update(e).digest("hex");if(!i.timingSafeEqual(Buffer.from(m),Buffer.from(s)))throw new h("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(i){throw i instanceof h?i:new h(`Webhook payload parsing failed: ${i.message}`)}}};var _=class extends n{async list(e){return this.get("/api/saas/chat/broadcasts",{params:e})}async retrieve(e){return this.get(`/api/saas/chat/broadcasts/${e}`)}async create(e){return this.post("/api/saas/chat/broadcast",e)}async update(e,t){return this.patch(`/api/saas/chat/broadcasts/${e}`,t)}async delete(e){return this.deleteRequest(`/api/saas/chat/broadcasts/${e}`)}};var F=class extends n{async list(e){return this.get("/api/saas/chat/conversations",{params:e})}async create(e){return this.post("/api/saas/chat/conversations",e)}async retrieve(e){return this.get(`/api/saas/chat/conversations/${e}`)}async messages(e,t){return this.get(`/api/saas/chat/conversations/${e}/messages`,{params:t})}async linkLead(e,t,r){return this.post(`/api/saas/chat/conversations/${e}/link-lead`,{leadId:t,leadData:r})}async markRead(e){return this.post(`/api/saas/chat/conversations/${e}/read`,{})}async delete(e){return this.deleteRequest(`/api/saas/chat/conversations/${e}`)}async bulkDelete(e){return this.post("/api/saas/chat/conversations/bulk-delete",{ids:e})}};var B=class extends n{async send(e){return this.post("/api/saas/chat/send",e)}async sendTemplate(e){return this.post("/api/saas/chat/send",{...e,templateLanguage:e.language||e.templateLanguage||"en_US"})}async star(e,t){return this.post(`/api/saas/chat/messages/${e}/star`,{isStarred:t})}async react(e,t){return this.post(`/api/saas/chat/messages/${e}/react`,{reaction:t})}async markRead(e){return this.post(`/api/saas/chat/conversations/${e}/read`)}async upload(e){let t=new FormData;return t.append("file",e),this.post("/api/saas/chat/upload",t,{headers:{"Content-Type":"multipart/form-data"}})}};var K=class extends n{async list(e){return this.get("/api/saas/chat/templates",{params:e})}async sync(){return this.post("/api/saas/chat/templates/sync",{})}async retrieve(e){return this.get(`/api/saas/chat/templates/${encodeURIComponent(e)}`)}async create(e){return this.post("/api/saas/chat/templates",e)}async update(e,t){return this.put(`/api/saas/chat/templates/${e}`,t)}async deleteTemplate(e,t){return this.deleteRequest(`/api/saas/chat/templates/${encodeURIComponent(e)}${t?"?force=true":""}`)}async mappingConfig(){return this.get("/api/saas/chat/templates/mapping/config")}async collections(){return this.get("/api/saas/chat/templates/collections")}async collectionFields(e){return this.get(`/api/saas/chat/templates/collections/${encodeURIComponent(e)}/fields`)}async updateMapping(e,t){return this.put(`/api/saas/chat/templates/${encodeURIComponent(e)}/mapping`,t)}async validate(e){return this.get(`/api/saas/chat/templates/${encodeURIComponent(e)}/validate`)}async preview(e,t){return this.post(`/api/saas/chat/templates/${encodeURIComponent(e)}/preview`,{context:t})}async getVariableManifest(e){let t=await this.retrieve(e),r=Array.isArray(t.data?.components)?t.data.components:[],s=[];for(let i of r)if(i.text){let l=i.text.match(/{{(\d+)}}/g);if(l)for(let m of l){let g=m.replace(/{{|}}/g,"");s.push({key:`var_${g}`,label:`${i.type} Var {{${g}}}`,type:"string",required:!0,group:i.type,description:`Variable placeholder in template ${i.type}`})}}return{name:`Template variables: ${t.data?.name||e}`,fields:s,uiHints:{icon:"Variables",primaryColor:"#059669"}}}async checkUsage(e){return this.get(`/api/saas/chat/templates/${encodeURIComponent(e)}/usage`)}};var V=class extends n{messages;conversations;broadcasts;templates;constructor(e){super(e),this.messages=new B(e),this.conversations=new F(e),this.broadcasts=new _(e),this.templates=new K(e)}async upload(e,t){let r=new FormData;return r.append("file",e,t),this.post("/api/saas/chat/upload",r,{headers:typeof r.getHeaders=="function"?r.getHeaders():void 0})}async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}};var H=class extends n{async listBlueprints(){return this.get("/api/agency/blueprints")}async createBlueprint(e){return this.post("/api/agency/blueprints",e)}async deployBlueprint(e){return this.post("/api/agency/blueprints/deploy",e)}async getPortfolioStats(e){return this.get(`/api/agency/portfolio/${e}/stats`)}async getPortfolioHealth(e){return this.get(`/api/agency/portfolio/${e}/health`)}async getUsage(e){return this.get(`/api/agency/usage/${e}`)}async listStaff(e){return this.get(`/api/agency/staff/${e}`)}async createStaff(e){return this.post("/api/agency/staff",e)}};var ae=class extends n{async list(){return this.get("/api/services/clients")}async getCountAndGenerateCode(){return this.get("/api/services/clients/count")}async retrieve(e){return this.get(`/api/services/clients/${e}`)}async getApiKey(e){return this.get(`/api/services/clients/${e}/api-key`)}async rotateApiKey(e){return this.post(`/api/services/clients/${e}/api-key`,{})}async create(e){return this.post("/api/services/clients",e)}async getConfig(e){return this.get(`/api/services/clients/${e}/config`)}async updateConfig(e,t){return this.patch(`/api/services/clients/${e}/config`,t)}async getSecrets(e){return this.get(`/api/services/clients/${e}/secrets`)}async updateSecrets(e,t){return this.post(`/api/services/clients/${e}/secrets`,t)}async replaceSecrets(e,t){return this.put(`/api/services/clients/${e}/secrets`,t)}async patchSecrets(e,t){return this.patch(`/api/services/clients/${e}/secrets`,t)}async getDataSource(e){return this.get(`/api/services/clients/${e}/datasource`)}async manageDataSource(e,t){return this.post(`/api/services/clients/${e}/datasource`,t)}async updateIdentity(e,t){return this.patch(`/api/services/clients/${e}/identity`,t)}async googleReauth(e,t={}){return this.post(`/api/services/clients/${e}/google/reauth`,t)}async delete(e){return this.deleteRequest(`/api/services/clients/${e}`)}},ne=class extends n{async list(){return this.get("/api/services/blogs")}},re=class extends n{async add(e){return this.post("/api/services/add-lead",e)}},W=class extends n{clients;blogs;globalLeads;constructor(e){super(e),this.clients=new ae(e),this.blogs=new ne(e),this.globalLeads=new re(e)}};var ie=class extends n{async getConfig(){return this.get("/api/settings/email")}async switchProvider(e){return this.post("/api/settings/email/provider",{provider:e})}async saveSmtp(e){return this.post("/api/settings/email/smtp",e)}async initDomainVerification(e){return this.post("/api/settings/email/ses/domain",{domain:e})}async saveEmailConfig(e){return this.post("/api/settings/email/ses/config",e)}async checkSesVerification(){return this.get("/api/settings/email/ses/verify")}async removeSesIdentity(){return this.deleteRequest("/api/settings/email/ses/domain")}async sendTest(e){return this.post("/api/settings/email/test",{toEmail:e})}async saveAdvancedConfig(e){return this.post("/api/settings/email/advanced",e)}async getHealth(){return this.get("/api/settings/email/health")}async fixDmarc(){return this.post("/api/settings/email/ses/fix-dmarc",{})}async listProviders(){return this.get("/api/settings/email/providers")}},j=class extends n{email;constructor(e){super(e),this.email=new ie(e)}};var J=class extends n{async list(){return this.get("/api/saas/cors")}async create(e){return this.post("/api/saas/cors",e)}async update(e,t){return this.patch(`/api/saas/cors/${e}`,t)}async delete(e){return this.deleteRequest(`/api/saas/cors/${e}`)}};var Y=class extends n{async getProduct(e){return this.get(`/api/v1/checkout/products/${e}`)}async createSession(e){return this.post("/api/v1/checkout/session",e)}async applyCoupon(e){return this.post("/api/v1/checkout/coupon",e)}async verify(e){return this.post("/api/v1/checkout/verify",e)}async createOrder(e){return this.post("/api/v1/checkout/order",e)}};var de="https://api.ecodrix.com",G=class{client;socket;clientCode;whatsapp;crm;media;meet;notifications;email;logs;events;webhooks;storage;marketing;health;queue;agency;services;settings;cors;checkout;constructor(e){if(!e.apiKey)throw new T("API Key is required");this.clientCode=e.clientCode?.toUpperCase();let t=e.baseUrl??de,r=e.socketUrl||t,s=typeof window<"u"&&typeof window.document<"u",i=s?"browser":typeof process<"u"?`node ${process.version}`:"unknown",l=s?globalThis.navigator?.userAgent||"browser":typeof process<"u"?process.platform:"unknown",m={"x-api-key":e.apiKey,"x-client-code":e.clientCode?.toUpperCase()||"","Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:"1.0.0",runtime:i,os:l})};if(e.coreApiKey&&(m["x-core-api-key"]=e.coreApiKey),this.client=ue.create({baseURL:t,headers:m}),oe(this.client,{retries:3,retryDelay:oe.exponentialDelay,retryCondition:g=>oe.isNetworkOrIdempotentRequestError(g)||g.response?.status===429,onRetry:(g,ge,ce)=>{typeof process<"u"&&process.env?.NODE_ENV==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${g}/3): ${ce.method?.toUpperCase()} ${ce.url}. Reason: ${ge.message}`)}}),this.whatsapp=new V(this.client),this.crm=new A(this.client),this.media=new L(this.client),this.meet=new q(this.client),this.notifications=new O(this.client),this.email=new I(this.client),this.logs=new E(this.client),this.events=new k(this.client),this.webhooks=new U,this.storage=new N(this.client),this.marketing=new D(this.client),this.health=new S(this.client),this.queue=new M(this.client),this.agency=new H(this.client),this.services=new W(this.client),this.settings=new j(this.client),this.cors=new J(this.client),this.checkout=new Y(this.client),this.socket=ye(r,{extraHeaders:{"x-api-key":e.apiKey,"x-client-code":e.clientCode?.toUpperCase()||""}}),this.setupSocket(e.clientCode),s){let g={version:"1.2.2",clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=g,window.ecodrix||(window.ecodrix=this)}}joinRoom(e){this.socket.emit("join-room",e)}leaveRoom(e){this.socket.emit("leave-room",e)}setupSocket(e){this.socket.on("connect",()=>{e&&this.socket.emit("join-room",e.toUpperCase())})}on(e,t){return this.socket.on(e,t),this}disconnect(){this.socket.disconnect()}off(e,t){return this.socket.off(e,t),this}async request(e,t,r,s){try{return(await this.client.request({method:e,url:t,data:r,params:s})).data}catch(i){throw i.response?new u(i.response.data?.message||i.response.data?.error||"Raw Execution Failed",i.response.status,i.response.data?.code):new u(i.message||"Network Error")}}};fe.config();var pe="1.3.3";var be="Official Isomorphic SDK for the ECODrIx platform. Native support for WhatsApp, CRM, Storage, and Meetings across TS, JS, Python, and Java.",y=new Te;y.name("erix").description(be).version(pe);function d(a){let e=a.key||process.env.ECOD_API_KEY,t=a.client||process.env.ECOD_CLIENT_CODE;return e||(console.error(o.red("Error: API Key is missing.")),console.log(o.yellow("Set ECOD_API_KEY environment variable or use --key <key>")),process.exit(1)),new G({apiKey:e,clientCode:t,baseUrl:a.baseUrl||process.env.ECOD_BASE_URL})}y.option("-k, --key <key>","ECODrIx API Key").option("-c, --client <code...","Tenant Client Code").option("--base-url <url>","API Base URL override");y.command("whoami").description("Verify current authentication and tenant status").action(async(a,e)=>{let t=e.parent.opts(),r=d(t);console.log(o.cyan("Checking connection to ECODrIx Platform..."));try{let s=await r.request("GET","/api/saas/me/profile");console.log(o.green("\u2714 Authenticated successfully!")),console.log(`${o.bold("User ID:")} ${s.id}`),console.log(`${o.bold("Organisation:")} ${s.organisation?.name||"N/A"}`),t.client&&console.log(`${o.bold("Tenant Code:")} ${o.magenta(t.client)}`)}catch(s){console.error(o.red("\u2716 Authentication failed")),console.error(o.dim(s.message)),process.exit(1)}});var ve=y.command("whatsapp").description("WhatsApp Business API operations");ve.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(a,e,t,r)=>{let s=r.parent.parent.opts(),i=d(s);try{let l=JSON.parse(t.vars);console.log(o.cyan(`Sending template '${e}' to ${a}...`));let m=await i.whatsapp.messages.sendTemplate({to:a,templateName:e,language:"en_US",variables:l});console.log(o.green("\u2714 Message sent successfully!")),console.log(o.dim(`ID: ${m?.id||"N/A"}`))}catch(l){console.error(o.red("\u2716 Failed to send message")),console.error(o.dim(l.message))}});var le=y.command("crm").description("CRM and Lead management");le.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(a,e)=>{let t=e.parent.parent.opts(),r=d(t);try{let s=Number.parseInt(a.limit);console.log(o.cyan(`Fetching last ${s} leads...`));let i={limit:s};a.status&&(i.status=a.status),a.pipeline&&(i.pipelineId=a.pipeline),a.search&&(i.search=a.search);let l=await r.crm.leads.list(i),m=Array.isArray(l.data)?l.data:Array.isArray(l)?l:[];if(m.length===0){console.log(o.yellow("No leads found."));return}console.table(m.map(g=>({ID:g.id||g._id,Name:`${g.firstName} ${g.lastName||""}`.trim(),Phone:g.phone,Status:g.status,Score:g.score||0,Created:new Date(g.createdAt).toLocaleDateString()})))}catch(s){console.error(o.red("\u2716 Failed to fetch leads")),console.error(o.dim(s.message))}});le.command("pipelines").description("List all CRM pipelines").action(async(a,e)=>{let t=e.parent.parent.opts(),r=d(t);try{console.log(o.cyan("Fetching pipelines..."));let s=await r.crm.pipelines.list(),i=s.data||s||[];if(i.length===0){console.log(o.yellow("No pipelines found."));return}console.table(i.map(l=>({ID:l.id||l._id,Name:l.name,Default:l.isDefault?"Yes":"No",Stages:l.stages?.length||0})))}catch(s){console.error(o.red("\u2716 Failed to fetch pipelines")),console.error(o.dim(s.message))}});var xe=y.command("analytics").description("Business Intelligence Analytics");xe.command("overview").description("Get high-level CRM KPIs").option("-r, --range <range>","Date range (e.g., 24h, 7d, 30d, 365d)","30d").action(async(a,e)=>{let t=e.parent.parent.opts(),r=d(t);try{console.log(o.cyan(`Fetching overview metrics for last ${a.range}...`));let s=await r.crm.analytics.overview({range:a.range}),i=s.data||s;console.log(`
|
|
3
3
|
${o.bold("OVERVIEW KPIs:")}`),console.log(`Total Leads: ${o.green(i.totalLeads||0)}`),console.log(`Open Value: ${o.yellow(`$${(i.openValue||0).toLocaleString()}`)}`),console.log(`Won Revenue: ${o.green(`$${(i.wonRevenue||0).toLocaleString()}`)}`),console.log(`Avg Score: ${o.blue(i.avgScore?.toFixed(1)||0)}`),console.log(`Conversion: ${o.magenta(`${(i.conversionRate||0).toFixed(2)}%`)}
|
|
4
|
-
`)}catch(s){console.error(o.red("\u2716 Failed to fetch analytics overview")),console.error(o.dim(s.message))}});var
|
|
5
|
-
Welcome to the Erix Interactive Shell`))),console.log(o.dim(`SDK Version: ${
|
|
6
|
-
`));let s=
|
|
4
|
+
`)}catch(s){console.error(o.red("\u2716 Failed to fetch analytics overview")),console.error(o.dim(s.message))}});var Pe=y.command("webhooks").description("Webhook utility tools");Pe.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(a,e,t,r,s)=>{let i=s.parent.parent.opts(),l=d(i);try{await l.webhooks.constructEvent(a,e,t),console.log(o.green("\u2714 Signature is VALID"))}catch(m){console.error(o.red("\u2716 Error during verification")),console.error(o.dim(m.message))}});y.command("shell").alias("repl").description("Start an interactive SDK shell").action(async(a,e)=>{let t=e.parent.opts(),r=d(t);console.log(o.magenta(o.bold(`
|
|
5
|
+
Welcome to the Erix Interactive Shell`))),console.log(o.dim(`SDK Version: ${pe}`)),console.log(o.dim(`The 'ecod' client is pre-initialized and ready.
|
|
6
|
+
`));let s=he.start({prompt:o.cyan("erix > "),useColors:!0});s.context.ecod=r,s.context.whatsapp=r.whatsapp,s.context.crm=r.crm,s.context.meet=r.meet,s.context.media=r.media,s.on("exit",()=>{console.log(o.yellow(`
|
|
7
7
|
Goodbye!`)),process.exit(0)})});y.command("completion").description("Generate Bash auto-completion script").action(()=>{console.log(`
|
|
8
8
|
# Erix Bash Completion
|
|
9
9
|
_erix_completions() {
|
package/dist/index.d.ts
CHANGED
|
@@ -829,6 +829,10 @@ declare class Pipelines extends APIResource {
|
|
|
829
829
|
* Delete a pipeline permanently.
|
|
830
830
|
*/
|
|
831
831
|
delete(pipelineId: string): Promise<unknown>;
|
|
832
|
+
/**
|
|
833
|
+
* Check if a pipeline is in use (e.g. has leads attached).
|
|
834
|
+
*/
|
|
835
|
+
checkInUse<T = any>(pipelineId: string): Promise<T>;
|
|
832
836
|
/**
|
|
833
837
|
* Retrieve a Kanban-style board representation of the pipeline with leads nested.
|
|
834
838
|
*
|
|
@@ -3007,6 +3011,104 @@ declare class Cors extends APIResource {
|
|
|
3007
3011
|
delete<T = any>(id: string): Promise<T>;
|
|
3008
3012
|
}
|
|
3009
3013
|
|
|
3014
|
+
interface CheckoutProduct {
|
|
3015
|
+
externalId: string;
|
|
3016
|
+
name: string;
|
|
3017
|
+
price: number;
|
|
3018
|
+
image?: string;
|
|
3019
|
+
}
|
|
3020
|
+
interface CheckoutAmountBreakdown {
|
|
3021
|
+
subtotal: number;
|
|
3022
|
+
discount: number;
|
|
3023
|
+
delivery: number;
|
|
3024
|
+
total: number;
|
|
3025
|
+
}
|
|
3026
|
+
interface CheckoutSession {
|
|
3027
|
+
sessionId: string;
|
|
3028
|
+
product: {
|
|
3029
|
+
name: string;
|
|
3030
|
+
price: number;
|
|
3031
|
+
image?: string;
|
|
3032
|
+
};
|
|
3033
|
+
amounts: CheckoutAmountBreakdown;
|
|
3034
|
+
items: Array<{
|
|
3035
|
+
productId: string;
|
|
3036
|
+
quantity: number;
|
|
3037
|
+
}>;
|
|
3038
|
+
}
|
|
3039
|
+
interface CreateSessionPayload {
|
|
3040
|
+
productId: string;
|
|
3041
|
+
quantity: number;
|
|
3042
|
+
couponCode?: string;
|
|
3043
|
+
}
|
|
3044
|
+
interface ApplyCouponPayload {
|
|
3045
|
+
sessionId: string;
|
|
3046
|
+
couponCode: string;
|
|
3047
|
+
}
|
|
3048
|
+
interface VerifyPayload {
|
|
3049
|
+
sessionId: string;
|
|
3050
|
+
method: "truecaller" | "otp";
|
|
3051
|
+
token?: string;
|
|
3052
|
+
phone?: string;
|
|
3053
|
+
otp?: string;
|
|
3054
|
+
}
|
|
3055
|
+
interface CreateOrderPayload {
|
|
3056
|
+
sessionId: string;
|
|
3057
|
+
customer: {
|
|
3058
|
+
name: string;
|
|
3059
|
+
phone: string;
|
|
3060
|
+
email?: string;
|
|
3061
|
+
address: {
|
|
3062
|
+
line1: string;
|
|
3063
|
+
city: string;
|
|
3064
|
+
state: string;
|
|
3065
|
+
pincode: string;
|
|
3066
|
+
};
|
|
3067
|
+
};
|
|
3068
|
+
paymentProvider: "razorpay" | "cod";
|
|
3069
|
+
}
|
|
3070
|
+
interface CheckoutOrderResponse {
|
|
3071
|
+
order_id: string;
|
|
3072
|
+
payment_order_id?: string;
|
|
3073
|
+
amount?: number;
|
|
3074
|
+
currency?: string;
|
|
3075
|
+
status?: string;
|
|
3076
|
+
message?: string;
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
/**
|
|
3080
|
+
* Resource for managing the ErixCheckout one-click flow.
|
|
3081
|
+
*
|
|
3082
|
+
* This resource handles session creation, coupon application,
|
|
3083
|
+
* identity verification, and final order placement.
|
|
3084
|
+
*/
|
|
3085
|
+
declare class Checkout extends APIResource {
|
|
3086
|
+
/**
|
|
3087
|
+
* Retrieves product information for the checkout modal.
|
|
3088
|
+
* @param productId - External SKU/ID of the product.
|
|
3089
|
+
*/
|
|
3090
|
+
getProduct(productId: string): Promise<CheckoutProduct>;
|
|
3091
|
+
/**
|
|
3092
|
+
* Initializes a new checkout session.
|
|
3093
|
+
*/
|
|
3094
|
+
createSession(payload: CreateSessionPayload): Promise<CheckoutSession>;
|
|
3095
|
+
/**
|
|
3096
|
+
* Applies a discount coupon to an active session.
|
|
3097
|
+
*/
|
|
3098
|
+
applyCoupon(payload: ApplyCouponPayload): Promise<CheckoutSession>;
|
|
3099
|
+
/**
|
|
3100
|
+
* Verifies user identity via Truecaller or OTP.
|
|
3101
|
+
*/
|
|
3102
|
+
verify(payload: VerifyPayload): Promise<{
|
|
3103
|
+
verified: boolean;
|
|
3104
|
+
data?: any;
|
|
3105
|
+
}>;
|
|
3106
|
+
/**
|
|
3107
|
+
* Finalizes the order and initiates payment.
|
|
3108
|
+
*/
|
|
3109
|
+
createOrder(payload: CreateOrderPayload): Promise<CheckoutOrderResponse>;
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3010
3112
|
/**
|
|
3011
3113
|
* Configuration options for the Ecodrix client.
|
|
3012
3114
|
*
|
|
@@ -3110,6 +3212,8 @@ declare class Ecodrix {
|
|
|
3110
3212
|
readonly settings: Settings;
|
|
3111
3213
|
/** Dynamic Cross-Origin Resource Sharing network policies. */
|
|
3112
3214
|
readonly cors: Cors;
|
|
3215
|
+
/** ErixCheckout one-click checkout flow management. */
|
|
3216
|
+
readonly checkout: Checkout;
|
|
3113
3217
|
constructor(options: EcodrixOptions);
|
|
3114
3218
|
/**
|
|
3115
3219
|
* Join a specific real-time room (e.g., a conversation or a lead).
|
|
@@ -3191,4 +3295,4 @@ declare class Ecodrix {
|
|
|
3191
3295
|
request<T = any>(method: Method, path: string, data?: any, params?: any): Promise<T>;
|
|
3192
3296
|
}
|
|
3193
3297
|
|
|
3194
|
-
export { APIError, Activities, Agency, Analytics, type AnalyticsParams, type AnalyticsRange, type AssignEventPayload, AuthenticationError, AutomationDashboard, type AutomationRulePayload, Automations, Blogs, Broadcasts, CRM, type CallbackLog, type CampaignResult, Campaigns, type ChatMediaMeta, type ClientHealth, Clients, Conversations, Cors, type CorsOriginCreatePayload, type CorsOriginUpdatePayload, type CreateBroadcastParams, type CreateLeadParams, type CreateMeetingParams, type CreatePipelineParams, type CreateTemplateDTO, Ecodrix, EcodrixError, type EcodrixOptions, Email, EmailConfig, EmailResource, type EmailTemplate, Emails, type EventDefinition, type EventLog, EventsResource, type FieldManifest, type FieldType, Files, Folders, GlobalLeads, Health, type JobStats, type JobStatus, type LeadSource, type LeadStatus, Leads, type ListLeadsParams, type ListParams, type LogActivityParams, type LogCallParams, type LogFilter, type LogPaginationQuery, type LogResponse, Logs, Marketing, Media, MediaResource, Meetings, Messages, Notes, Notifications, Payments, type PipelineStageParams, Pipelines, Queue, RateLimitError, type ResourceManifest, Scoring, type ScoringConfig, type SendCampaignParams, type SendCampaignPayload, type SendMessageParams, type SendTemplateParams, type SendTemplatePayload, Sequences, Services, Settings, Storage, type SystemHealth, type TemplateMapping, type TemplatePreviewResponse, Templates, type TriggerPayload, type TriggerResponse, type UpdateMeetingParams, type UploadOptions, type UpsertLeadParams, WebhookSignatureError, Webhooks, WhatsApp, WhatsAppMarketing, Ecodrix as default };
|
|
3298
|
+
export { APIError, Activities, Agency, Analytics, type AnalyticsParams, type AnalyticsRange, type ApplyCouponPayload, type AssignEventPayload, AuthenticationError, AutomationDashboard, type AutomationRulePayload, Automations, Blogs, Broadcasts, CRM, type CallbackLog, type CampaignResult, Campaigns, type ChatMediaMeta, Checkout, type CheckoutAmountBreakdown, type CheckoutOrderResponse, type CheckoutProduct, type CheckoutSession, type ClientHealth, Clients, Conversations, Cors, type CorsOriginCreatePayload, type CorsOriginUpdatePayload, type CreateBroadcastParams, type CreateLeadParams, type CreateMeetingParams, type CreateOrderPayload, type CreatePipelineParams, type CreateSessionPayload, type CreateTemplateDTO, Ecodrix, EcodrixError, type EcodrixOptions, Email, EmailConfig, EmailResource, type EmailTemplate, Emails, type EventDefinition, type EventLog, EventsResource, type FieldManifest, type FieldType, Files, Folders, GlobalLeads, Health, type JobStats, type JobStatus, type LeadSource, type LeadStatus, Leads, type ListLeadsParams, type ListParams, type LogActivityParams, type LogCallParams, type LogFilter, type LogPaginationQuery, type LogResponse, Logs, Marketing, Media, MediaResource, Meetings, Messages, Notes, Notifications, Payments, type PipelineStageParams, Pipelines, Queue, RateLimitError, type ResourceManifest, Scoring, type ScoringConfig, type SendCampaignParams, type SendCampaignPayload, type SendMessageParams, type SendTemplateParams, type SendTemplatePayload, Sequences, Services, Settings, Storage, type SystemHealth, type TemplateMapping, type TemplatePreviewResponse, Templates, type TriggerPayload, type TriggerResponse, type UpdateMeetingParams, type UploadOptions, type UpsertLeadParams, type VerifyPayload, WebhookSignatureError, Webhooks, WhatsApp, WhatsAppMarketing, Ecodrix as default };
|