@ecodrix/erix-api 1.1.9 → 1.2.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 +5 -5
- package/dist/index.d.ts +289 -43
- 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 +289 -43
- package/dist/ts/esm/index.d.ts +289 -43
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core.ts +18 -7
- package/src/index.ts +2 -0
- package/src/resources/crm/leads.ts +64 -0
- package/src/resources/crm/pipelines.ts +37 -1
- package/src/resources/email.ts +108 -26
- package/src/resources/health.ts +25 -22
- package/src/resources/logs.ts +97 -0
- package/src/resources/media.ts +7 -10
- package/src/resources/whatsapp/templates.ts +45 -0
- package/src/types/metadata.ts +71 -0
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import re from"repl";import{Command as ie}from"commander";import oe from"dotenv";import o from"picocolors";import se from"axios";import Q from"axios-retry";import{io as ae}from"socket.io-client";var V=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},u=class extends V{status;code;constructor(e,t,n){super(e),this.name="APIError",this.status=t,this.code=n}},T=class extends u{constructor(e="Invalid API Key or Client Code"){super(e,401,"AUTH_FAILED"),this.name="AuthenticationError"}};var r=class{constructor(e){this.client=e}async post(e,t,n){try{let s=this.buildConfig(n);return(await this.client.post(e,t,s)).data}catch(s){this.handleError(s)}}async get(e,t){try{let n=this.buildConfig(t);return(await this.client.get(e,n)).data}catch(n){this.handleError(n)}}async patch(e,t,n){try{let s=this.buildConfig(n);return(await this.client.patch(e,t,s)).data}catch(s){this.handleError(s)}}async put(e,t,n){try{let s=this.buildConfig(n);return(await this.client.put(e,t,s)).data}catch(s){this.handleError(s)}}async deleteRequest(e,t){try{let n=this.buildConfig(t);return(await this.client.delete(e,n)).data}catch(n){this.handleError(n)}}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 r{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 r{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 r{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 x=class extends r{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 v=class extends r{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,n){return this.post("/api/crm/webhook-event",{ruleId:e,eventName:t,payload:n})}};var w=class extends r{async create(e){return this.post("/api/crm/leads",e)}async upsert(e){return this.post("/api/crm/leads/upsert",e)}async createMany(e,t=50){let n=[];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")n.push(g.value);else throw g.reason}return n}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,n=!0;for(;n;){let s=await this.list({...e,page:t}),i=Array.isArray(s.data)?s.data:s||[];if(i.length===0){n=!1;break}for(let l of i)yield l;s.pagination&&t<s.pagination.pages||!s.pagination&&i.length>0?t++:n=!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,n){return this.post(`/api/crm/leads/${e}/convert`,{outcome:t,reason:n})}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,n){return this.patch(`/api/crm/notes/${t}`,n)}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 P=class extends r{async capture(e){return this.post("/api/crm/payments/capture",e)}};var $=class extends r{async list(){return this.get("/api/crm/pipelines")}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 r{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 I=class extends r{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 C=class{leads;pipelines;activities;analytics;automations;sequences;scoring;payments;automationDashboard;constructor(e){this.leads=new w(e),this.pipelines=new $(e),this.activities=new f(e),this.analytics=new b(e),this.automations=new v(e),this.sequences=new I(e),this.scoring=new R(e),this.payments=new P(e),this.automationDashboard=new x(e)}};var A=class extends r{async sendEmailCampaign(e){return this.post("/api/saas/emails/campaign",e)}async sendTestEmail(e){return this.post("/api/saas/emails/test",{to:e})}};var k=class extends r{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 r{async system(){return(await this.get("/api/saas/health",{headers:{accept:"application/json"}})).data}async clientHealth(){return(await this.get("/api/saas/health/client")).data}async jobStatus(e){return(await this.get(`/api/saas/jobs/status/${e}`)).data}};var H=class extends r{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})}},J=class extends r{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`)}},Y=class extends r{async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}},E=class extends r{emails;campaigns;whatsapp;constructor(e){super(e),this.emails=new H(e),this.campaigns=new J(e),this.whatsapp=new Y(e)}};import te from"axios";var D=class extends r{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{data:n}=await this.client.post("/api/saas/storage/upload-url",t),{uploadUrl:s,key:i}=n;await te.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 L=class extends r{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 q=class extends r{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 O=class extends r{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 r{async create(e){return this.post("/api/saas/storage/folders",{name:e})}async delete(e){return this.deleteRequest(`/api/saas/storage/folders/${encodeURIComponent(e)}`)}},z=class extends r{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 r{folders;files;constructor(e){super(e),this.folders=new G(e),this.files=new z(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"}},M=class{async constructEvent(e,t,n){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",n).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 U=class extends r{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 _=class extends r{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,n){return this.post(`/api/saas/chat/conversations/${e}/link-lead`,{leadId:t,leadData:n})}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 F=class extends r{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 r{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 checkUsage(e){return this.get(`/api/saas/chat/templates/${encodeURIComponent(e)}/usage`)}};var B=class extends r{messages;conversations;broadcasts;templates;constructor(e){super(e),this.messages=new F(e),this.conversations=new _(e),this.broadcasts=new U(e),this.templates=new K(e)}async upload(e,t){let n=new FormData;return n.append("file",e,t),this.post("/api/saas/chat/upload",n,{headers:typeof n.getHeaders=="function"?n.getHeaders():void 0})}async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}};var ne="https://api.ecodrix.com",W=class{client;socket;whatsapp;crm;media;meet;notifications;email;events;webhooks;storage;marketing;health;queue;constructor(e){if(!e.apiKey)throw new T("API Key is required");let t=e.baseUrl??ne,n=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";this.client=se.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:i,os:l})}}),Q(this.client,{retries:3,retryDelay:Q.exponentialDelay,retryCondition:m=>Q.isNetworkOrIdempotentRequestError(m)||m.response?.status===429,onRetry:(m,g,X)=>{typeof process<"u"&&process.env?.NODE_ENV==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${m}/3): ${X.method?.toUpperCase()} ${X.url}. Reason: ${g.message}`)}}),this.whatsapp=new B(this.client),this.crm=new C(this.client),this.media=new D(this.client),this.meet=new L(this.client),this.notifications=new q(this.client),this.email=new A(this.client),this.events=new k(this.client),this.webhooks=new M,this.storage=new N(this.client),this.marketing=new E(this.client),this.health=new S(this.client),this.queue=new O(this.client),this.socket=ae(n,{extraHeaders:{"x-api-key":e.apiKey,"x-client-code":e.clientCode?.toUpperCase()||""}}),this.setupSocket(e.clientCode)}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,n,s){try{return(await this.client.request({method:e,url:t,data:n,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")}}};oe.config();var Z="1.1.9";var ce="Official Isomorphic SDK for the ECODrIx platform. Native support for WhatsApp, CRM, Storage, and Meetings across TS, JS, Python, and Java.",d=new ie;d.name("erix").description(ce).version(Z);function y(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 W({apiKey:e,clientCode:t,baseUrl:a.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(a,e)=>{let t=e.parent.opts(),n=y(t);console.log(o.cyan("Checking connection to ECODrIx Platform..."));try{let s=await n.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 pe=d.command("whatsapp").description("WhatsApp Business API operations");pe.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,n)=>{let s=n.parent.parent.opts(),i=y(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 ee=d.command("crm").description("CRM and Lead management");ee.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(),n=y(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 n.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))}});ee.command("pipelines").description("List all CRM pipelines").action(async(a,e)=>{let t=e.parent.parent.opts(),n=y(t);try{console.log(o.cyan("Fetching pipelines..."));let s=await n.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 le=d.command("analytics").description("Business Intelligence Analytics");le.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(),n=y(t);try{console.log(o.cyan(`Fetching overview metrics for last ${a.range}...`));let s=await n.crm.analytics.overview({range:a.range}),i=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 ge=d.command("webhooks").description("Webhook utility tools");ge.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(
|
|
5
|
-
Welcome to the Erix Interactive Shell`))),console.log(o.dim(`SDK Version: ${
|
|
6
|
-
`));let s=
|
|
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`)}},G=class extends i{async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}},L=class extends i{emails;campaigns;whatsapp;constructor(e){super(e),this.emails=new J(e),this.campaigns=new Y(e),this.whatsapp=new G(e)}};import se from"axios";var D=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 Q=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)}`)}},z=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 Q(e),this.files=new z(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;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");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";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 D(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 L(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)}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.1";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(r.totalLeads||0)}`),console.log(`Open Value: ${o.yellow(`$${(r.openValue||0).toLocaleString()}`)}`),console.log(`Won Revenue: ${o.green(`$${(r.wonRevenue||0).toLocaleString()}`)}`),console.log(`Avg Score: ${o.blue(r.avgScore?.toFixed(1)||0)}`),console.log(`Conversion: ${o.magenta(`${(r.conversionRate||0).toFixed(2)}%`)}
|
|
4
|
+
`)}catch(s){console.error(o.red("\u2716 Failed to fetch analytics overview")),console.error(o.dim(s.message))}});var ge=d.command("webhooks").description("Webhook utility tools");ge.command("verify").description("Verify a cryptographic webhook signature").argument("<payload>","The raw request body string").argument("<signature>","The 'x-ecodrix-signature' header value").argument("<secret>","Your webhook signing secret").action(async(n,e,t,a,s)=>{let r=s.parent.parent.opts(),l=y(r);try{await l.webhooks.constructEvent(n,e,t),console.log(o.green("\u2714 Signature is VALID"))}catch(g){console.error(o.red("\u2716 Error during verification")),console.error(o.dim(g.message))}});d.command("shell").alias("repl").description("Start an interactive SDK shell").action(async(n,e)=>{let t=e.parent.opts(),a=y(t);console.log(o.magenta(o.bold(`
|
|
5
|
+
Welcome to the Erix Interactive Shell`))),console.log(o.dim(`SDK Version: ${ee}`)),console.log(o.dim(`The 'ecod' client is pre-initialized and ready.
|
|
6
|
+
`));let s=ie.start({prompt:o.cyan("erix > "),useColors:!0});s.context.ecod=a,s.context.whatsapp=a.whatsapp,s.context.crm=a.crm,s.context.meet=a.meet,s.context.media=a.media,s.on("exit",()=>{console.log(o.yellow(`
|
|
7
7
|
Goodbye!`)),process.exit(0)})});d.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
|
@@ -378,6 +378,67 @@ declare class Automations extends APIResource {
|
|
|
378
378
|
webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any): Promise<T>;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
/**
|
|
382
|
+
* The specific UI control type suggested for a field.
|
|
383
|
+
*/
|
|
384
|
+
type FieldType = "string" | "number" | "boolean" | "date" | "datetime" | "select" | "multi-select" | "phone" | "email" | "currency" | "json" | "textarea" | "richtext" | "file" | "image";
|
|
385
|
+
/**
|
|
386
|
+
* Metadata defining a single field within a resource.
|
|
387
|
+
* Used by UI kits to automatically generate forms and validation logic.
|
|
388
|
+
*/
|
|
389
|
+
interface FieldManifest {
|
|
390
|
+
/** The technical key name used in API requests. */
|
|
391
|
+
key: string;
|
|
392
|
+
/** Human-readable label (localized if possible). */
|
|
393
|
+
label: string;
|
|
394
|
+
/** Suggested UI type. */
|
|
395
|
+
type: FieldType;
|
|
396
|
+
/** Short hint/placeholder text. */
|
|
397
|
+
description?: string;
|
|
398
|
+
/** Whether the field is required for creation. */
|
|
399
|
+
required: boolean;
|
|
400
|
+
/** Whether the field should be hidden from standard create/edit forms. */
|
|
401
|
+
hidden?: boolean;
|
|
402
|
+
/** If type is 'select', the available options. */
|
|
403
|
+
options?: Array<{
|
|
404
|
+
label: string;
|
|
405
|
+
value: string | number;
|
|
406
|
+
}>;
|
|
407
|
+
/** Validation constraints. */
|
|
408
|
+
validation?: {
|
|
409
|
+
regex?: string;
|
|
410
|
+
min?: number;
|
|
411
|
+
max?: number;
|
|
412
|
+
message?: string;
|
|
413
|
+
};
|
|
414
|
+
/** Whether the field is read-only. */
|
|
415
|
+
readOnly?: boolean;
|
|
416
|
+
/** UI grouping/category name. */
|
|
417
|
+
group?: string;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* A logical grouping of fields and UI hints for a top-level resource.
|
|
421
|
+
* Provides a 'blueprint' for erix-react components.
|
|
422
|
+
*/
|
|
423
|
+
interface ResourceManifest {
|
|
424
|
+
/** The unique name of the resource (e.g., 'Lead', 'Template'). */
|
|
425
|
+
name: string;
|
|
426
|
+
/** All available fields for this resource. */
|
|
427
|
+
fields: FieldManifest[];
|
|
428
|
+
/** Suggested UI configurations. */
|
|
429
|
+
uiHints?: {
|
|
430
|
+
icon?: string;
|
|
431
|
+
primaryColor?: string;
|
|
432
|
+
/** Default sort order. */
|
|
433
|
+
defaultSort?: {
|
|
434
|
+
field: string;
|
|
435
|
+
direction: "asc" | "desc";
|
|
436
|
+
};
|
|
437
|
+
/** Fields to show in a compact table view. */
|
|
438
|
+
summaryFields?: string[];
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
|
|
381
442
|
/**
|
|
382
443
|
* Valid statuses for a CRM Lead.
|
|
383
444
|
*/
|
|
@@ -475,6 +536,14 @@ declare class Leads extends APIResource {
|
|
|
475
536
|
* ```
|
|
476
537
|
*/
|
|
477
538
|
create<T = any>(params: CreateLeadParams): Promise<T>;
|
|
539
|
+
/**
|
|
540
|
+
* Introspect the Leads resource and provide a "Blueprint" for UI generation.
|
|
541
|
+
*
|
|
542
|
+
* This method returns a list of all fields (standard + custom), their types,
|
|
543
|
+
* labels, and suggested UI controls. Erix React uses this to render SmartForms
|
|
544
|
+
* and tables dynamically.
|
|
545
|
+
*/
|
|
546
|
+
describe(): Promise<ResourceManifest>;
|
|
478
547
|
/**
|
|
479
548
|
* Upsert a lead by phone number. If a lead with the same phone exists,
|
|
480
549
|
* it will be updated; otherwise, a new lead is created.
|
|
@@ -701,6 +770,15 @@ declare class Pipelines extends APIResource {
|
|
|
701
770
|
* ```
|
|
702
771
|
*/
|
|
703
772
|
list<T = any>(): Promise<T>;
|
|
773
|
+
/**
|
|
774
|
+
* Introspect a pipeline and provide a manifest of its stages.
|
|
775
|
+
*
|
|
776
|
+
* Returns metadata about stage colors, probabilities, and order.
|
|
777
|
+
* Erix React uses this to build kanban boards and stage pickers.
|
|
778
|
+
*
|
|
779
|
+
* @param pipelineId - The unique ID of the pipeline.
|
|
780
|
+
*/
|
|
781
|
+
getStageManifest(pipelineId: string): Promise<ResourceManifest>;
|
|
704
782
|
/**
|
|
705
783
|
* Create a new CRM sales or support pipeline.
|
|
706
784
|
*
|
|
@@ -907,33 +985,98 @@ interface CampaignResult {
|
|
|
907
985
|
message?: string;
|
|
908
986
|
[key: string]: any;
|
|
909
987
|
}
|
|
910
|
-
|
|
988
|
+
interface EmailTemplate {
|
|
989
|
+
id: string;
|
|
990
|
+
name: string;
|
|
991
|
+
description?: string;
|
|
992
|
+
subject: string;
|
|
993
|
+
preheader?: string;
|
|
994
|
+
htmlBody: string;
|
|
995
|
+
textBody?: string;
|
|
996
|
+
category: "marketing" | "transactional" | "sequence";
|
|
997
|
+
status: "draft" | "published" | "archived";
|
|
998
|
+
type: "standard" | "layout";
|
|
999
|
+
layoutId?: string;
|
|
1000
|
+
thumbnail?: string;
|
|
1001
|
+
variableMapping?: any[];
|
|
1002
|
+
createdAt: string;
|
|
1003
|
+
updatedAt: string;
|
|
1004
|
+
}
|
|
1005
|
+
interface CreateTemplateDTO {
|
|
1006
|
+
name: string;
|
|
1007
|
+
subject: string;
|
|
1008
|
+
htmlBody: string;
|
|
1009
|
+
description?: string;
|
|
1010
|
+
category?: "marketing" | "transactional" | "sequence";
|
|
1011
|
+
status?: "draft" | "published" | "archived";
|
|
1012
|
+
variableMapping?: any[];
|
|
1013
|
+
}
|
|
1014
|
+
interface TemplatePreviewResponse {
|
|
1015
|
+
success: boolean;
|
|
1016
|
+
data: {
|
|
1017
|
+
subject: string;
|
|
1018
|
+
html: string;
|
|
1019
|
+
text?: string;
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Outbound email marketing engine and template management.
|
|
1024
|
+
*
|
|
1025
|
+
* Access via `ecod.email`.
|
|
1026
|
+
*/
|
|
1027
|
+
declare class Email extends APIResource {
|
|
911
1028
|
/**
|
|
912
1029
|
* Send an HTML email campaign to a list of recipients.
|
|
913
|
-
*
|
|
914
|
-
* @param payload - The campaign details (recipients, subject, html).
|
|
915
|
-
* @returns The dispatch result indicating success or failure.
|
|
916
|
-
* @example
|
|
917
|
-
* ```typescript
|
|
918
|
-
* await erixClient.email.sendEmailCampaign({
|
|
919
|
-
* recipients: ["user1@example.com", "user2@example.com"],
|
|
920
|
-
* subject: "Monthly Newsletter",
|
|
921
|
-
* html: "<h1>Hello!</h1><p>Check out our latest updates...</p>"
|
|
922
|
-
* });
|
|
923
|
-
* ```
|
|
924
1030
|
*/
|
|
925
|
-
|
|
1031
|
+
sendCampaign(payload: SendCampaignPayload): Promise<CampaignResult>;
|
|
926
1032
|
/**
|
|
927
1033
|
* Send a system test email to validate your current SMTP configuration.
|
|
928
|
-
*
|
|
929
|
-
* @param to - The recipient's email address.
|
|
930
|
-
* @returns The dispatch result.
|
|
931
|
-
* @example
|
|
932
|
-
* ```typescript
|
|
933
|
-
* await erixClient.email.sendTestEmail("admin@company.com");
|
|
934
|
-
* ```
|
|
935
1034
|
*/
|
|
936
|
-
|
|
1035
|
+
sendTest(to: string): Promise<CampaignResult>;
|
|
1036
|
+
/**
|
|
1037
|
+
* List all email templates.
|
|
1038
|
+
*/
|
|
1039
|
+
listTemplates(query?: any): Promise<{
|
|
1040
|
+
success: boolean;
|
|
1041
|
+
data: EmailTemplate[];
|
|
1042
|
+
}>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Get a single email template by ID.
|
|
1045
|
+
*/
|
|
1046
|
+
getTemplate(id: string): Promise<{
|
|
1047
|
+
success: boolean;
|
|
1048
|
+
data: EmailTemplate;
|
|
1049
|
+
}>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Create a new email template.
|
|
1052
|
+
*/
|
|
1053
|
+
createTemplate(data: CreateTemplateDTO): Promise<{
|
|
1054
|
+
success: boolean;
|
|
1055
|
+
data: EmailTemplate;
|
|
1056
|
+
}>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Update an existing email template.
|
|
1059
|
+
*/
|
|
1060
|
+
updateTemplate(id: string, data: Partial<CreateTemplateDTO>): Promise<{
|
|
1061
|
+
success: boolean;
|
|
1062
|
+
data: EmailTemplate;
|
|
1063
|
+
}>;
|
|
1064
|
+
/**
|
|
1065
|
+
* Delete an email template.
|
|
1066
|
+
*/
|
|
1067
|
+
deleteTemplate(id: string, force?: boolean): Promise<{
|
|
1068
|
+
success: boolean;
|
|
1069
|
+
}>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Preview a template with dynamic variable resolution.
|
|
1072
|
+
*/
|
|
1073
|
+
previewTemplate(id: string, params: {
|
|
1074
|
+
leadId?: string;
|
|
1075
|
+
variables?: Record<string, any>;
|
|
1076
|
+
}): Promise<TemplatePreviewResponse>;
|
|
1077
|
+
}
|
|
1078
|
+
/** @deprecated Use Email instead */
|
|
1079
|
+
declare class EmailResource extends Email {
|
|
937
1080
|
}
|
|
938
1081
|
|
|
939
1082
|
/**
|
|
@@ -1133,39 +1276,122 @@ interface JobStatus {
|
|
|
1133
1276
|
failedAt: string | null;
|
|
1134
1277
|
createdAt: string;
|
|
1135
1278
|
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Platform and tenant-specific health diagnostics.
|
|
1281
|
+
*
|
|
1282
|
+
* Access via `ecod.health`.
|
|
1283
|
+
*/
|
|
1136
1284
|
declare class Health extends APIResource {
|
|
1137
1285
|
/**
|
|
1138
1286
|
* Perform a global platform health check.
|
|
1139
|
-
* Verify that the API, database, and background workers are operational.
|
|
1140
|
-
*
|
|
1141
|
-
* @returns System health summary (status, version, uptime).
|
|
1142
|
-
* @example
|
|
1143
|
-
* ```typescript
|
|
1144
|
-
* const health = await erixClient.health.system();
|
|
1145
|
-
* console.log(`API Status: ${health.status}`);
|
|
1146
|
-
* ```
|
|
1287
|
+
* Verify that the core API, database, and background workers are operational.
|
|
1147
1288
|
*/
|
|
1148
1289
|
system(): Promise<SystemHealth>;
|
|
1149
1290
|
/**
|
|
1150
|
-
* Tenant-specific health check.
|
|
1291
|
+
* Tenant-specific health check.
|
|
1292
|
+
*
|
|
1293
|
+
* Identifies correctly configured third-party integrations (WhatsApp, SMTP, Google Meet)
|
|
1294
|
+
* and reports active automation counts.
|
|
1151
1295
|
*/
|
|
1152
1296
|
clientHealth(): Promise<ClientHealth>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Alias for clientHealth to match diagnostic terminology.
|
|
1299
|
+
*/
|
|
1300
|
+
getDiagnosticReport(): Promise<ClientHealth>;
|
|
1153
1301
|
/**
|
|
1154
1302
|
* Lookup the execution status of a background job.
|
|
1155
1303
|
*
|
|
1304
|
+
* Use this to poll for completion of long-running tasks like bulk exports
|
|
1305
|
+
* or campaign dispatches.
|
|
1306
|
+
*
|
|
1156
1307
|
* @param jobId - The unique ID of the background job.
|
|
1157
|
-
* @returns Job status report (attempts, error trace, completion time).
|
|
1158
|
-
* @example
|
|
1159
|
-
* ```typescript
|
|
1160
|
-
* const status = await erixClient.health.jobStatus("job_123");
|
|
1161
|
-
* if (status.status === "completed") {
|
|
1162
|
-
* console.log("Job finished successfully!");
|
|
1163
|
-
* }
|
|
1164
|
-
* ```
|
|
1165
1308
|
*/
|
|
1166
1309
|
jobStatus(jobId: string): Promise<JobStatus>;
|
|
1167
1310
|
}
|
|
1168
1311
|
|
|
1312
|
+
interface LogPaginationQuery {
|
|
1313
|
+
page?: number;
|
|
1314
|
+
limit?: number;
|
|
1315
|
+
trigger?: string;
|
|
1316
|
+
status?: "received" | "processing" | "completed" | "partial" | "failed";
|
|
1317
|
+
from?: string;
|
|
1318
|
+
to?: string;
|
|
1319
|
+
}
|
|
1320
|
+
interface EventLog {
|
|
1321
|
+
id: string;
|
|
1322
|
+
trigger: string;
|
|
1323
|
+
phone?: string;
|
|
1324
|
+
email?: string;
|
|
1325
|
+
status: "received" | "processing" | "completed" | "partial" | "failed";
|
|
1326
|
+
rulesMatched: number;
|
|
1327
|
+
jobsCreated: number;
|
|
1328
|
+
meetLink?: string;
|
|
1329
|
+
callbackUrl?: string;
|
|
1330
|
+
callbackStatus: "not_required" | "sent" | "failed";
|
|
1331
|
+
payload: any;
|
|
1332
|
+
error?: string;
|
|
1333
|
+
idempotencyKey?: string;
|
|
1334
|
+
processedAt?: string;
|
|
1335
|
+
createdAt: string;
|
|
1336
|
+
updatedAt: string;
|
|
1337
|
+
}
|
|
1338
|
+
interface CallbackLog {
|
|
1339
|
+
id: string;
|
|
1340
|
+
callbackUrl: string;
|
|
1341
|
+
method: string;
|
|
1342
|
+
payload: any;
|
|
1343
|
+
jobId?: string;
|
|
1344
|
+
enrollmentId?: string;
|
|
1345
|
+
responseStatus: number;
|
|
1346
|
+
responseBody: string;
|
|
1347
|
+
status: "sent" | "failed" | "pending_retry";
|
|
1348
|
+
attempts: number;
|
|
1349
|
+
lastAttemptAt?: string;
|
|
1350
|
+
signature?: string;
|
|
1351
|
+
createdAt: string;
|
|
1352
|
+
}
|
|
1353
|
+
interface LogResponse<T> {
|
|
1354
|
+
success: boolean;
|
|
1355
|
+
data: T[];
|
|
1356
|
+
pagination: {
|
|
1357
|
+
total: number;
|
|
1358
|
+
page: number;
|
|
1359
|
+
limit: number;
|
|
1360
|
+
pages: number;
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Audit and execution logs for platform events and webhooks.
|
|
1365
|
+
*
|
|
1366
|
+
* Access via `ecod.logs`.
|
|
1367
|
+
*/
|
|
1368
|
+
declare class Logs extends APIResource {
|
|
1369
|
+
/**
|
|
1370
|
+
* List event execution logs with optional filtering.
|
|
1371
|
+
*
|
|
1372
|
+
* Use this to audit automation triggers and debug workflow execution.
|
|
1373
|
+
*/
|
|
1374
|
+
listEventLogs(query?: LogPaginationQuery): Promise<LogResponse<EventLog>>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Get detailed information for a single event execution.
|
|
1377
|
+
*/
|
|
1378
|
+
getEventLog(id: string): Promise<{
|
|
1379
|
+
success: boolean;
|
|
1380
|
+
data: EventLog;
|
|
1381
|
+
}>;
|
|
1382
|
+
/**
|
|
1383
|
+
* List webhook callback logs (outbound responses from ECODrIx to your system).
|
|
1384
|
+
*/
|
|
1385
|
+
listCallbackLogs(query?: LogPaginationQuery): Promise<LogResponse<CallbackLog>>;
|
|
1386
|
+
/**
|
|
1387
|
+
* Get high-level execution statistics for the tenant.
|
|
1388
|
+
*/
|
|
1389
|
+
getStats(): Promise<{
|
|
1390
|
+
success: boolean;
|
|
1391
|
+
data: any;
|
|
1392
|
+
}>;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1169
1395
|
interface SendCampaignParams {
|
|
1170
1396
|
recipients: string[];
|
|
1171
1397
|
subject: string;
|
|
@@ -1352,7 +1578,7 @@ interface UploadOptions {
|
|
|
1352
1578
|
* console.log(data.url); // → https://cdn.ecodrix.com/invoices/invoice-001.pdf
|
|
1353
1579
|
* ```
|
|
1354
1580
|
*/
|
|
1355
|
-
declare class
|
|
1581
|
+
declare class Media extends APIResource {
|
|
1356
1582
|
/**
|
|
1357
1583
|
* Get current storage usage metrics for the tenant.
|
|
1358
1584
|
*
|
|
@@ -1455,6 +1681,9 @@ declare class MediaResource extends APIResource {
|
|
|
1455
1681
|
*/
|
|
1456
1682
|
upload(file: any, options: UploadOptions): Promise<any>;
|
|
1457
1683
|
}
|
|
1684
|
+
/** @deprecated Use Media instead */
|
|
1685
|
+
declare class MediaResource extends Media {
|
|
1686
|
+
}
|
|
1458
1687
|
|
|
1459
1688
|
/**
|
|
1460
1689
|
* Parameters for scheduling a new Google Meet appointment.
|
|
@@ -2491,6 +2720,15 @@ declare class Templates extends APIResource {
|
|
|
2491
2720
|
lead?: any;
|
|
2492
2721
|
vars?: any;
|
|
2493
2722
|
}): Promise<T>;
|
|
2723
|
+
/**
|
|
2724
|
+
* Introspect a template and provide a manifest of its required variables.
|
|
2725
|
+
*
|
|
2726
|
+
* This is used by Erix React to build dynamic "Mapping Forms" where users
|
|
2727
|
+
* can connect CRM fields to WhatsApp variables.
|
|
2728
|
+
*
|
|
2729
|
+
* @param templateIdentifier - The name or ID of the template.
|
|
2730
|
+
*/
|
|
2731
|
+
getVariableManifest(templateIdentifier: string): Promise<ResourceManifest>;
|
|
2494
2732
|
/**
|
|
2495
2733
|
* Check which automations or sequences are currently using this template.
|
|
2496
2734
|
*/
|
|
@@ -2584,20 +2822,28 @@ interface EcodrixOptions {
|
|
|
2584
2822
|
* ```
|
|
2585
2823
|
*/
|
|
2586
2824
|
declare class Ecodrix {
|
|
2825
|
+
/**
|
|
2826
|
+
* @internal Axios HTTP client for making API requests.
|
|
2827
|
+
*/
|
|
2587
2828
|
private readonly client;
|
|
2829
|
+
/**
|
|
2830
|
+
* @internal Socket.io client for real-time events.
|
|
2831
|
+
*/
|
|
2588
2832
|
private readonly socket;
|
|
2589
2833
|
/** WhatsApp messaging and conversation management. */
|
|
2590
2834
|
readonly whatsapp: WhatsApp;
|
|
2591
2835
|
/** CRM resources — Leads and related sub-resources. */
|
|
2592
2836
|
readonly crm: CRM;
|
|
2593
2837
|
/** Cloudflare R2-backed media storage. */
|
|
2594
|
-
readonly media:
|
|
2838
|
+
readonly media: Media;
|
|
2595
2839
|
/** Google Meet appointment scheduling. */
|
|
2596
2840
|
readonly meet: Meetings;
|
|
2597
2841
|
/** Automation execution logs and provider webhook callbacks. */
|
|
2598
2842
|
readonly notifications: Notifications;
|
|
2599
|
-
/** Outbound email marketing engine. */
|
|
2600
|
-
readonly email:
|
|
2843
|
+
/** Outbound email marketing engine and template management. */
|
|
2844
|
+
readonly email: Email;
|
|
2845
|
+
/** Platform-wide execution logs and audit trails. */
|
|
2846
|
+
readonly logs: Logs;
|
|
2601
2847
|
/** Lead events and workflow automation triggers. */
|
|
2602
2848
|
readonly events: EventsResource;
|
|
2603
2849
|
/** Cryptographic webhook signature verification. */
|
|
@@ -2691,4 +2937,4 @@ declare class Ecodrix {
|
|
|
2691
2937
|
request<T = any>(method: Method, path: string, data?: any, params?: any): Promise<T>;
|
|
2692
2938
|
}
|
|
2693
2939
|
|
|
2694
|
-
export { APIError, Activities, Analytics, type AnalyticsParams, type AnalyticsRange, type AssignEventPayload, AuthenticationError, AutomationDashboard, type AutomationRulePayload, Automations, Broadcasts, CRM, type CampaignResult, Campaigns, type ChatMediaMeta, type ClientHealth, Conversations, type CreateBroadcastParams, type CreateLeadParams, type CreateMeetingParams, type CreatePipelineParams, Ecodrix, EcodrixError, type EcodrixOptions, EmailResource, Emails, type EventDefinition, EventsResource, Files, Folders, Health, type JobStats, type JobStatus, type LeadSource, type LeadStatus, Leads, type ListLeadsParams, type ListParams, type LogActivityParams, type LogCallParams, type LogFilter, Marketing, MediaResource, Meetings, Messages, Notes, Notifications, Payments, type PipelineStageParams, Pipelines, Queue, RateLimitError, Scoring, type ScoringConfig, type SendCampaignParams, type SendCampaignPayload, type SendMessageParams, type SendTemplateParams, type SendTemplatePayload, Sequences, Storage, type SystemHealth, type TemplateMapping, Templates, type TriggerPayload, type TriggerResponse, type UpdateMeetingParams, type UploadOptions, type UpsertLeadParams, WebhookSignatureError, Webhooks, WhatsApp, WhatsAppMarketing, Ecodrix as default };
|
|
2940
|
+
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 };
|