@ecodrix/erix-api 1.2.9 → 1.3.1
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 +7 -7
- package/dist/index.d.ts +239 -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 +239 -1
- package/dist/ts/esm/index.d.ts +239 -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,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import ie from"repl";import{Command as oe}from"commander";import ce from"dotenv";import o from"picocolors";import ae from"axios";import X from"axios-retry";import{io as ne}from"socket.io-client";var H=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},u=class extends H{status;code;constructor(e,t,a){super(e),this.name="APIError",this.status=t,this.code=a}},T=class extends u{constructor(e="Invalid API Key or Client Code"){super(e,401,"AUTH_FAILED"),this.name="AuthenticationError"}};var i=class{constructor(e){this.client=e}async post(e,t,a){try{let s=this.buildConfig(a);return(await this.client.post(e,t,s)).data}catch(s){this.handleError(s)}}async get(e,t){try{let a=this.buildConfig(t);return(await this.client.get(e,a)).data}catch(a){this.handleError(a)}}async patch(e,t,a){try{let s=this.buildConfig(a);return(await this.client.patch(e,t,s)).data}catch(s){this.handleError(s)}}async put(e,t,a){try{let s=this.buildConfig(a);return(await this.client.put(e,t,s)).data}catch(s){this.handleError(s)}}async deleteRequest(e,t){try{let a=this.buildConfig(t);return(await this.client.delete(e,a)).data}catch(a){this.handleError(a)}}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 j=class extends i{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 i{notes;constructor(e){super(e),this.notes=new j(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 i{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 i{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 i{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,a){return this.post("/api/crm/webhook-event",{ruleId:e,eventName:t,payload:a})}};var P=class extends i{async create(e){return this.post("/api/crm/leads",e)}async describe(){let e=await this.fields(),t=Array.isArray(e.data)?e.data:[],a=[{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(r=>({key:`metadata.extra.${r.name}`,label:r.label||r.name,type:r.type||"string",required:!!r.required,options:r.options,group:"Custom Fields"}));return{name:"Lead",fields:[...a,...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 a=[];for(let s=0;s<e.length;s+=t){let l=e.slice(s,s+t).map(m=>this.create(m)),g=await Promise.allSettled(l);for(let m of g)if(m.status==="fulfilled")a.push(m.value);else throw m.reason}return a}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,a=!0;for(;a;){let s=await this.list({...e,page:t}),r=Array.isArray(s.data)?s.data:s||[];if(r.length===0){a=!1;break}for(let l of r)yield l;s.pagination&&t<s.pagination.pages||!s.pagination&&r.length>0?t++:a=!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,a){return this.post(`/api/crm/leads/${e}/convert`,{outcome:t,reason:a})}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,a){return this.patch(`/api/crm/notes/${t}`,a)}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 i{async capture(e){return this.post("/api/crm/payments/capture",e)}};var $=class extends i{async list(){return this.get("/api/crm/pipelines")}async getStageManifest(e){let t=await this.retrieve(e),a=Array.isArray(t.data?.stages)?t.data.stages:[];return{name:`Pipeline: ${t.data?.name||e}`,fields:a.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 R=class extends i{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 C=class extends i{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 C(e),this.scoring=new R(e),this.payments=new w(e),this.automationDashboard=new v(e)}};var I=class extends i{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 i{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 E=class extends i{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 S=class extends i{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 J=class extends i{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})}},Y=class extends i{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 i{async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}},D=class extends i{emails;campaigns;whatsapp;constructor(e){super(e),this.emails=new J(e),this.campaigns=new Y(e),this.whatsapp=new z(e)}};import se from"axios";var L=class extends i{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 a=await this.post("/api/saas/storage/upload-url",t),{uploadUrl:s,key:r}=a.data;await se.put(s,e,{headers:{"Content-Type":t.contentType}});let l=e.size||e.byteLength||0;return this.post("/api/saas/storage/confirm-upload",{key:r,sizeBytes:l})}};var q=class extends i{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 i{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 i{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 G=class extends i{async create(e){return this.post("/api/saas/storage/folders",{name:e})}async delete(e){return this.deleteRequest(`/api/saas/storage/folders/${encodeURIComponent(e)}`)}},Q=class extends i{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 i{folders;files;constructor(e){super(e),this.folders=new G(e),this.files=new Q(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,a){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 r=await import("crypto"),g=r.createHmac("sha256",a).update(e).digest("hex");if(!r.timingSafeEqual(Buffer.from(g),Buffer.from(s)))throw new h("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(r){throw r instanceof h?r:new h(`Webhook payload parsing failed: ${r.message}`)}}};var _=class extends i{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 i{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,a){return this.post(`/api/saas/chat/conversations/${e}/link-lead`,{leadId:t,leadData:a})}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 i{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 i{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),a=Array.isArray(t.data?.components)?t.data.components:[],s=[];for(let r of a)if(r.text){let l=r.text.match(/{{(\d+)}}/g);if(l)for(let g of l){let m=g.replace(/{{|}}/g,"");s.push({key:`var_${m}`,label:`${r.type} Var {{${m}}}`,type:"string",required:!0,group:r.type,description:`Variable placeholder in template ${r.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 i{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 a=new FormData;return a.append("file",e,t),this.post("/api/saas/chat/upload",a,{headers:typeof a.getHeaders=="function"?a.getHeaders():void 0})}async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}};var re="https://api.ecodrix.com",W=class{client;socket;clientCode;whatsapp;crm;media;meet;notifications;email;logs;events;webhooks;storage;marketing;health;queue;constructor(e){if(!e.apiKey)throw new T("API Key is required");this.clientCode=e.clientCode?.toUpperCase();let t=e.baseUrl??re,a=e.socketUrl||t,s=typeof window<"u"&&typeof window.document<"u",r=s?"browser":typeof process<"u"?`node ${process.version}`:"unknown",l=s?globalThis.navigator?.userAgent||"browser":typeof process<"u"?process.platform:"unknown";if(this.client=ae.create({baseURL:t,headers:{"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:r,os:l})}}),X(this.client,{retries:3,retryDelay:X.exponentialDelay,retryCondition:g=>X.isNetworkOrIdempotentRequestError(g)||g.response?.status===429,onRetry:(g,m,Z)=>{typeof process<"u"&&process.env?.NODE_ENV==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${g}/3): ${Z.method?.toUpperCase()} ${Z.url}. Reason: ${m.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 S(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 E(this.client),this.queue=new M(this.client),this.socket=ne(a,{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,a,s){try{return(await this.client.request({method:e,url:t,data:a,params:s})).data}catch(r){throw r.response?new u(r.response.data?.message||r.response.data?.error||"Raw Execution Failed",r.response.status,r.response.data?.code):new u(r.message||"Network Error")}}};ce.config();var ee="1.2.9";var pe="Official Isomorphic SDK for the ECODrIx platform. Native support for WhatsApp, CRM, Storage, and Meetings across TS, JS, Python, and Java.",d=new oe;d.name("erix").description(pe).version(ee);function y(n){let e=n.key||process.env.ECOD_API_KEY,t=n.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 W({apiKey:e,clientCode:t,baseUrl:n.baseUrl||process.env.ECOD_BASE_URL})}d.option("-k, --key <key>","ECODrIx API Key").option("-c, --client <code...","Tenant Client Code").option("--base-url <url>","API Base URL override");d.command("whoami").description("Verify current authentication and tenant status").action(async(n,e)=>{let t=e.parent.opts(),a=y(t);console.log(o.cyan("Checking connection to ECODrIx Platform..."));try{let s=await a.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 le=d.command("whatsapp").description("WhatsApp Business API operations");le.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,a)=>{let s=a.parent.parent.opts(),r=y(s);try{let l=JSON.parse(t.vars);console.log(o.cyan(`Sending template '${e}' to ${n}...`));let g=await r.whatsapp.messages.sendTemplate({to:n,templateName:e,language:"en_US",variables:l});console.log(o.green("\u2714 Message sent successfully!")),console.log(o.dim(`ID: ${g?.id||"N/A"}`))}catch(l){console.error(o.red("\u2716 Failed to send message")),console.error(o.dim(l.message))}});var te=d.command("crm").description("CRM and Lead management");te.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(),a=y(t);try{let s=Number.parseInt(n.limit);console.log(o.cyan(`Fetching last ${s} leads...`));let r={limit:s};n.status&&(r.status=n.status),n.pipeline&&(r.pipelineId=n.pipeline),n.search&&(r.search=n.search);let l=await a.crm.leads.list(r),g=Array.isArray(l.data)?l.data:Array.isArray(l)?l:[];if(g.length===0){console.log(o.yellow("No leads found."));return}console.table(g.map(m=>({ID:m.id||m._id,Name:`${m.firstName} ${m.lastName||""}`.trim(),Phone:m.phone,Status:m.status,Score:m.score||0,Created:new Date(m.createdAt).toLocaleDateString()})))}catch(s){console.error(o.red("\u2716 Failed to fetch leads")),console.error(o.dim(s.message))}});te.command("pipelines").description("List all CRM pipelines").action(async(n,e)=>{let t=e.parent.parent.opts(),a=y(t);try{console.log(o.cyan("Fetching pipelines..."));let s=await a.crm.pipelines.list(),r=s.data||s||[];if(r.length===0){console.log(o.yellow("No pipelines found."));return}console.table(r.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 me=d.command("analytics").description("Business Intelligence Analytics");me.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(),a=y(t);try{console.log(o.cyan(`Fetching overview metrics for last ${n.range}...`));let s=await a.crm.analytics.overview({range:n.range}),r=s.data||s;console.log(`
|
|
3
|
-
${o.bold("OVERVIEW KPIs:")}`),console.log(`Total Leads: ${o.green(
|
|
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=
|
|
7
|
-
Goodbye!`)),process.exit(0)})});
|
|
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(`
|
|
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 xe=y.command("webhooks").description("Webhook utility tools");xe.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: ${ce}`)),console.log(o.dim(`The 'ecod' client is pre-initialized and ready.
|
|
6
|
+
`));let s=de.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
|
+
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() {
|
|
10
10
|
local cur opts
|
|
@@ -35,4 +35,4 @@ _erix_completions() {
|
|
|
35
35
|
}
|
|
36
36
|
complete -F _erix_completions erix
|
|
37
37
|
`.trim()),console.error(o.yellow(`
|
|
38
|
-
# To enable, run: eval "$(erix completion)"`)),console.error(o.dim("# Or add it to your ~/.bashrc: erix completion >> ~/.bashrc"))});
|
|
38
|
+
# To enable, run: eval "$(erix completion)"`)),console.error(o.dim("# Or add it to your ~/.bashrc: erix completion >> ~/.bashrc"))});y.parse();
|
package/dist/index.d.ts
CHANGED
|
@@ -2782,6 +2782,231 @@ declare class WhatsApp extends APIResource {
|
|
|
2782
2782
|
}>;
|
|
2783
2783
|
}
|
|
2784
2784
|
|
|
2785
|
+
declare class Agency extends APIResource {
|
|
2786
|
+
/**
|
|
2787
|
+
* List all available blueprints.
|
|
2788
|
+
*/
|
|
2789
|
+
listBlueprints<T = any>(): Promise<T>;
|
|
2790
|
+
/**
|
|
2791
|
+
* Create a new blueprint configuration ("Gold Standard").
|
|
2792
|
+
*/
|
|
2793
|
+
createBlueprint<T = any>(payload: any): Promise<T>;
|
|
2794
|
+
/**
|
|
2795
|
+
* Deploy a blueprint to a specific tenant client code.
|
|
2796
|
+
*/
|
|
2797
|
+
deployBlueprint<T = any>(payload: {
|
|
2798
|
+
clientCode: string;
|
|
2799
|
+
blueprintId: string;
|
|
2800
|
+
}): Promise<T>;
|
|
2801
|
+
/**
|
|
2802
|
+
* Get aggregate portfolio statistics for an agency.
|
|
2803
|
+
*/
|
|
2804
|
+
getPortfolioStats<T = any>(agencyCode: string): Promise<T>;
|
|
2805
|
+
/**
|
|
2806
|
+
* Get proactive health report for an agency portfolio.
|
|
2807
|
+
*/
|
|
2808
|
+
getPortfolioHealth<T = any>(agencyCode: string): Promise<T>;
|
|
2809
|
+
/**
|
|
2810
|
+
* View consumption usage for a specific client code.
|
|
2811
|
+
*/
|
|
2812
|
+
getUsage<T = any>(clientCode: string): Promise<T>;
|
|
2813
|
+
/**
|
|
2814
|
+
* List staff members under a specific agency code.
|
|
2815
|
+
*/
|
|
2816
|
+
listStaff<T = any>(agencyCode: string): Promise<T>;
|
|
2817
|
+
/**
|
|
2818
|
+
* Create a new staff member for an agency.
|
|
2819
|
+
*/
|
|
2820
|
+
createStaff<T = any>(payload: any): Promise<T>;
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
declare class Clients extends APIResource {
|
|
2824
|
+
/**
|
|
2825
|
+
* List all clients in the ecosystem.
|
|
2826
|
+
*/
|
|
2827
|
+
list<T = any>(): Promise<T>;
|
|
2828
|
+
/**
|
|
2829
|
+
* Get client count and auto-generate a unique code.
|
|
2830
|
+
*/
|
|
2831
|
+
getCountAndGenerateCode<T = any>(): Promise<T>;
|
|
2832
|
+
/**
|
|
2833
|
+
* Retrieve a single client by client code.
|
|
2834
|
+
*/
|
|
2835
|
+
retrieve<T = any>(clientCode: string): Promise<T>;
|
|
2836
|
+
/**
|
|
2837
|
+
* Get API Key for a specific client (Admin Only).
|
|
2838
|
+
*/
|
|
2839
|
+
getApiKey<T = any>(clientCode: string): Promise<T>;
|
|
2840
|
+
/**
|
|
2841
|
+
* Generate or rotate API Key for a specific client (Admin Only).
|
|
2842
|
+
*/
|
|
2843
|
+
rotateApiKey<T = any>(clientCode: string): Promise<T>;
|
|
2844
|
+
/**
|
|
2845
|
+
* Create a new client identity and provision initial resources.
|
|
2846
|
+
*/
|
|
2847
|
+
create<T = any>(payload: {
|
|
2848
|
+
name: string;
|
|
2849
|
+
clientCode: string;
|
|
2850
|
+
business?: any;
|
|
2851
|
+
plan?: any;
|
|
2852
|
+
}): Promise<T>;
|
|
2853
|
+
/**
|
|
2854
|
+
* Get active service configuration for a specific client.
|
|
2855
|
+
*/
|
|
2856
|
+
getConfig<T = any>(clientCode: string): Promise<T>;
|
|
2857
|
+
/**
|
|
2858
|
+
* Update active service configuration for a specific client.
|
|
2859
|
+
*/
|
|
2860
|
+
updateConfig<T = any>(clientCode: string, payload: any): Promise<T>;
|
|
2861
|
+
/**
|
|
2862
|
+
* Get decrypted secrets for a specific client.
|
|
2863
|
+
*/
|
|
2864
|
+
getSecrets<T = any>(clientCode: string): Promise<T>;
|
|
2865
|
+
/**
|
|
2866
|
+
* Set secrets for a specific client.
|
|
2867
|
+
*/
|
|
2868
|
+
updateSecrets<T = any>(clientCode: string, payload: any): Promise<T>;
|
|
2869
|
+
/**
|
|
2870
|
+
* Completely replace secrets for a specific client.
|
|
2871
|
+
*/
|
|
2872
|
+
replaceSecrets<T = any>(clientCode: string, payload: any): Promise<T>;
|
|
2873
|
+
/**
|
|
2874
|
+
* Partially update secrets for a specific client.
|
|
2875
|
+
*/
|
|
2876
|
+
patchSecrets<T = any>(clientCode: string, payload: any): Promise<T>;
|
|
2877
|
+
/**
|
|
2878
|
+
* Retrieve Data Source connection metadata.
|
|
2879
|
+
*/
|
|
2880
|
+
getDataSource<T = any>(clientCode: string): Promise<T>;
|
|
2881
|
+
/**
|
|
2882
|
+
* Configure Data Source metadata.
|
|
2883
|
+
*/
|
|
2884
|
+
manageDataSource<T = any>(clientCode: string, payload: any): Promise<T>;
|
|
2885
|
+
/**
|
|
2886
|
+
* Update Client Identity and perform cascading updates if required.
|
|
2887
|
+
*/
|
|
2888
|
+
updateIdentity<T = any>(id: string, payload: any): Promise<T>;
|
|
2889
|
+
/**
|
|
2890
|
+
* Initiate Google Re-authentication for OAuth tokens.
|
|
2891
|
+
*/
|
|
2892
|
+
googleReauth<T = any>(clientCode: string, payload?: {
|
|
2893
|
+
authCode?: string;
|
|
2894
|
+
}): Promise<T>;
|
|
2895
|
+
/**
|
|
2896
|
+
* Delete a client and perform cascading cleanup.
|
|
2897
|
+
*/
|
|
2898
|
+
delete<T = any>(id: string): Promise<T>;
|
|
2899
|
+
}
|
|
2900
|
+
declare class Blogs extends APIResource {
|
|
2901
|
+
/**
|
|
2902
|
+
* Retrieve public corporate blogs/news.
|
|
2903
|
+
*/
|
|
2904
|
+
list<T = any>(): Promise<T>;
|
|
2905
|
+
}
|
|
2906
|
+
declare class GlobalLeads extends APIResource {
|
|
2907
|
+
/**
|
|
2908
|
+
* Add a corporate lead capture entry.
|
|
2909
|
+
*/
|
|
2910
|
+
add<T = any>(payload: any): Promise<T>;
|
|
2911
|
+
}
|
|
2912
|
+
declare class Services extends APIResource {
|
|
2913
|
+
clients: Clients;
|
|
2914
|
+
blogs: Blogs;
|
|
2915
|
+
globalLeads: GlobalLeads;
|
|
2916
|
+
constructor(client: any);
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
declare class EmailConfig extends APIResource {
|
|
2920
|
+
/**
|
|
2921
|
+
* Retrieve current email provider configuration and domain verification statuses.
|
|
2922
|
+
*/
|
|
2923
|
+
getConfig<T = any>(): Promise<T>;
|
|
2924
|
+
/**
|
|
2925
|
+
* Switch the active email provider.
|
|
2926
|
+
*/
|
|
2927
|
+
switchProvider<T = any>(provider: string): Promise<T>;
|
|
2928
|
+
/**
|
|
2929
|
+
* Provide explicit SMTP credentials and connection preferences.
|
|
2930
|
+
*/
|
|
2931
|
+
saveSmtp<T = any>(payload: any): Promise<T>;
|
|
2932
|
+
/**
|
|
2933
|
+
* Initialize a new domain for SES identity verification.
|
|
2934
|
+
*/
|
|
2935
|
+
initDomainVerification<T = any>(domain: string): Promise<T>;
|
|
2936
|
+
/**
|
|
2937
|
+
* Confirm "From" details and finalize configuration payload.
|
|
2938
|
+
*/
|
|
2939
|
+
saveEmailConfig<T = any>(payload: {
|
|
2940
|
+
fromName: string;
|
|
2941
|
+
fromEmail: string;
|
|
2942
|
+
replyTo?: string;
|
|
2943
|
+
}): Promise<T>;
|
|
2944
|
+
/**
|
|
2945
|
+
* Check status of AWS SES domain validation DNS records.
|
|
2946
|
+
*/
|
|
2947
|
+
checkSesVerification<T = any>(): Promise<T>;
|
|
2948
|
+
/**
|
|
2949
|
+
* Remove a verified SES domain identity and clean up local secrets.
|
|
2950
|
+
*/
|
|
2951
|
+
removeSesIdentity<T = any>(): Promise<T>;
|
|
2952
|
+
/**
|
|
2953
|
+
* Send a test email to verify infrastructure is correctly bound.
|
|
2954
|
+
*/
|
|
2955
|
+
sendTest<T = any>(toEmail: string): Promise<T>;
|
|
2956
|
+
/**
|
|
2957
|
+
* Define customized global email footers, limits, and specific campaign policies.
|
|
2958
|
+
*/
|
|
2959
|
+
saveAdvancedConfig<T = any>(payload: any): Promise<T>;
|
|
2960
|
+
/**
|
|
2961
|
+
* Retrieve email configuration health properties including bounce limits metrics.
|
|
2962
|
+
*/
|
|
2963
|
+
getHealth<T = any>(): Promise<T>;
|
|
2964
|
+
/**
|
|
2965
|
+
* Upgrade configurations dynamically to add DMARC enforcement records.
|
|
2966
|
+
*/
|
|
2967
|
+
fixDmarc<T = any>(): Promise<T>;
|
|
2968
|
+
/**
|
|
2969
|
+
* Discover internally available providers constants metadata.
|
|
2970
|
+
*/
|
|
2971
|
+
listProviders<T = any>(): Promise<T>;
|
|
2972
|
+
}
|
|
2973
|
+
declare class Settings extends APIResource {
|
|
2974
|
+
email: EmailConfig;
|
|
2975
|
+
constructor(client: any);
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
interface CorsOriginCreatePayload {
|
|
2979
|
+
url: string;
|
|
2980
|
+
name?: string;
|
|
2981
|
+
allowedHeaders?: string[];
|
|
2982
|
+
allowedMethods?: string[];
|
|
2983
|
+
}
|
|
2984
|
+
interface CorsOriginUpdatePayload {
|
|
2985
|
+
url?: string;
|
|
2986
|
+
name?: string;
|
|
2987
|
+
allowedHeaders?: string[];
|
|
2988
|
+
allowedMethods?: string[];
|
|
2989
|
+
isActive?: boolean;
|
|
2990
|
+
}
|
|
2991
|
+
declare class Cors extends APIResource {
|
|
2992
|
+
/**
|
|
2993
|
+
* List all dynamic cross-origin policies.
|
|
2994
|
+
*/
|
|
2995
|
+
list<T = any>(): Promise<T>;
|
|
2996
|
+
/**
|
|
2997
|
+
* Register a new cross-origin client for the SaaS API network dynamically.
|
|
2998
|
+
*/
|
|
2999
|
+
create<T = any>(payload: CorsOriginCreatePayload): Promise<T>;
|
|
3000
|
+
/**
|
|
3001
|
+
* Adjust active states or configurations for an existing origin policy.
|
|
3002
|
+
*/
|
|
3003
|
+
update<T = any>(id: string, payload: CorsOriginUpdatePayload): Promise<T>;
|
|
3004
|
+
/**
|
|
3005
|
+
* Irreversibly drop support for a cross-origin client URL policy permanently.
|
|
3006
|
+
*/
|
|
3007
|
+
delete<T = any>(id: string): Promise<T>;
|
|
3008
|
+
}
|
|
3009
|
+
|
|
2785
3010
|
/**
|
|
2786
3011
|
* Configuration options for the Ecodrix client.
|
|
2787
3012
|
*
|
|
@@ -2801,6 +3026,11 @@ interface EcodrixOptions {
|
|
|
2801
3026
|
* @example "ERIX_CLNT_JHBJHF"
|
|
2802
3027
|
*/
|
|
2803
3028
|
clientCode?: string;
|
|
3029
|
+
/**
|
|
3030
|
+
* Optional Core API Key for deep system-level bypasses.
|
|
3031
|
+
* Only used by elevated internal SaaS modules like Nirvisham.
|
|
3032
|
+
*/
|
|
3033
|
+
coreApiKey?: string;
|
|
2804
3034
|
/**
|
|
2805
3035
|
* @internal Override Socket.io URL for testing/staging.
|
|
2806
3036
|
* Not documented — internal use only.
|
|
@@ -2872,6 +3102,14 @@ declare class Ecodrix {
|
|
|
2872
3102
|
readonly health: Health;
|
|
2873
3103
|
/** Background job queue management. */
|
|
2874
3104
|
readonly queue: Queue;
|
|
3105
|
+
/** White-Label Agency administration. */
|
|
3106
|
+
readonly agency: Agency;
|
|
3107
|
+
/** Multi-tenant Identity & Lifecycle services. */
|
|
3108
|
+
readonly services: Services;
|
|
3109
|
+
/** Tenant environment and provider settings. */
|
|
3110
|
+
readonly settings: Settings;
|
|
3111
|
+
/** Dynamic Cross-Origin Resource Sharing network policies. */
|
|
3112
|
+
readonly cors: Cors;
|
|
2875
3113
|
constructor(options: EcodrixOptions);
|
|
2876
3114
|
/**
|
|
2877
3115
|
* Join a specific real-time room (e.g., a conversation or a lead).
|
|
@@ -2953,4 +3191,4 @@ declare class Ecodrix {
|
|
|
2953
3191
|
request<T = any>(method: Method, path: string, data?: any, params?: any): Promise<T>;
|
|
2954
3192
|
}
|
|
2955
3193
|
|
|
2956
|
-
export { APIError, Activities, Analytics, type AnalyticsParams, type AnalyticsRange, type AssignEventPayload, AuthenticationError, AutomationDashboard, type AutomationRulePayload, Automations, Broadcasts, CRM, type CallbackLog, type CampaignResult, Campaigns, type ChatMediaMeta, type ClientHealth, Conversations, type CreateBroadcastParams, type CreateLeadParams, type CreateMeetingParams, type CreatePipelineParams, type CreateTemplateDTO, Ecodrix, EcodrixError, type EcodrixOptions, Email, EmailResource, type EmailTemplate, Emails, type EventDefinition, type EventLog, EventsResource, type FieldManifest, type FieldType, Files, Folders, 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, 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 };
|
|
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 };
|