@ecodrix/erix-api 1.5.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -76,52 +76,65 @@ npm install @ecodrix/erix-api
76
76
  ## Quick Start
77
77
 
78
78
  ```typescript
79
- import { Ecodrix } from "@ecodrix/erix-api";
79
+ import { ECODrIxAPI } from "@ecodrix/erix-api";
80
80
 
81
- const ecod = new Ecodrix({
81
+ const ecod = new ECODrIxAPI({
82
82
  apiKey: process.env.ECOD_API_KEY!,
83
- clientCode: process.env.ECOD_CLIENT_CODE,
83
+ clientCode: "ERIX_CLNT_JHBJHF",
84
+ // Optional — pick the API version. Defaults to "v1".
85
+ version: "v1",
84
86
  });
85
87
 
86
- // Send a WhatsApp message
87
- await ecod.whatsapp.messages.send({
88
+ // The SDK surface mirrors the server's domain ownership 1:1:
89
+ // ecod.platform.* control plane (auth-scoped tenant/admin)
90
+ // ecod.product.erix.* ERIX product (CRM, chat, commerce, events)
91
+ // ecod.infra.connect.* channel transport (email, whatsapp, meet)
92
+ // ecod.infra.storage.* file storage
93
+
94
+ // Send a WhatsApp/chat message
95
+ await ecod.product.erix.chat.messages.send({
88
96
  to: "+919876543210",
89
97
  text: "Hello from ECODrIx!",
90
98
  });
91
99
 
92
100
  // Create a CRM lead
93
- const lead = await ecod.crm.leads.create({
101
+ const lead = await ecod.product.erix.leads.create({
94
102
  firstName: "Priya",
95
103
  phone: "+919876543210",
96
104
  source: "website",
97
105
  });
98
106
 
99
107
  // Fire an automation trigger
100
- await ecod.events.trigger({
108
+ await ecod.product.erix.events.trigger({
101
109
  trigger: "trial_started",
102
110
  phone: "+919876543210",
103
111
  createLeadIfMissing: true,
104
112
  });
105
113
  ```
106
114
 
115
+ > **Note:** host projects never pass a URL. The domain is managed by the SDK;
116
+ > you only choose an API `version`. Moving the whole SDK to `v2` later is a
117
+ > single flag — `new ECODrIxAPI({ ..., version: "v2" })` — because every
118
+ > endpoint is issued relative to `<host>/<version>/api`.
119
+
107
120
  ---
108
121
 
109
122
  ## Configuration
110
123
 
111
124
  Pass an options object to `new Ecodrix(options)`:
112
125
 
113
- | Option | Type | Required | Default | Description |
114
- | ------------ | -------- | ----------- | ------------------------- | ---------------------------------------------- |
115
- | `apiKey` | `string` | ✅ Yes | — | Your ECOD Platform API key |
116
- | `clientCode` | `string` | Recommended | — | Your tenant ID — scopes all requests |
117
- | `baseUrl` | `string` | No | `https://api.ecodrix.com` | Override the API base URL (e.g. for local dev) |
118
- | `socketUrl` | `string` | No | Same as `baseUrl` | Override the Socket.io server URL |
126
+ | Option | Type | Required | Default | Description |
127
+ | ------------ | ---------------------- | ----------- | ------- | ------------------------------------------------------------------ |
128
+ | `apiKey` | `string` | ✅ Yes | — | Your ECOD Platform API key |
129
+ | `clientCode` | `string` | Recommended | — | Your tenant ID — scopes all requests |
130
+ | `version` | `"v1" \| "v2" \| "v3"` | No | `"v1"` | API route version. The single knob to target a new server version. |
131
+ | `coreApiKey` | `string` | No | — | Elevated key for platform-admin surfaces (`ecod.platform.admin.*`) |
119
132
 
120
133
  ```typescript
121
- const ecod = new Ecodrix({
134
+ const ecod = new ECODrIxAPI({
122
135
  apiKey: process.env.ECOD_API_KEY!,
123
- clientCode: process.env.ECOD_CLIENT_CODE,
124
- baseUrl: "http://localhost:4000", // For local development
136
+ clientCode: "ERIX_CLNT_JHBJHF",
137
+ version: "v1",
125
138
  });
126
139
  ```
127
140
 
@@ -190,12 +203,18 @@ const { data } = await ecod.whatsapp.conversations.list({
190
203
  const conv = await ecod.whatsapp.conversations.retrieve("conversation_id");
191
204
 
192
205
  // Get messages in a conversation
193
- const { data: msgs } = await ecod.whatsapp.conversations.messages("conversation_id", {
194
- limit: 50,
195
- });
206
+ const { data: msgs } = await ecod.whatsapp.conversations.messages(
207
+ "conversation_id",
208
+ {
209
+ limit: 50,
210
+ },
211
+ );
196
212
 
197
213
  // Create a conversation explicitly
198
- await ecod.whatsapp.conversations.create({ phone: "+919876543210", name: "Priya" });
214
+ await ecod.whatsapp.conversations.create({
215
+ phone: "+919876543210",
216
+ name: "Priya",
217
+ });
199
218
 
200
219
  // Link a conversation to a CRM lead
201
220
  await ecod.whatsapp.conversations.linkLead("conversation_id", "lead_id");
@@ -372,8 +391,15 @@ const { data: board } = await ecod.crm.pipelines.board("pipeline_id");
372
391
  const { data: forecast } = await ecod.crm.pipelines.forecast("pipeline_id");
373
392
 
374
393
  // Stage management
375
- await ecod.crm.pipelines.addStage("pipeline_id", { name: "Negotiation", color: "#f59e0b" });
376
- await ecod.crm.pipelines.reorderStages("pipeline_id", ["stage_1", "stage_3", "stage_2"]);
394
+ await ecod.crm.pipelines.addStage("pipeline_id", {
395
+ name: "Negotiation",
396
+ color: "#f59e0b",
397
+ });
398
+ await ecod.crm.pipelines.reorderStages("pipeline_id", [
399
+ "stage_1",
400
+ "stage_3",
401
+ "stage_2",
402
+ ]);
377
403
  await ecod.crm.pipelines.updateStage("stage_id", { probability: 80 });
378
404
  await ecod.crm.pipelines.deleteStage("stage_id", "fallback_stage_id");
379
405
  ```
@@ -385,7 +411,12 @@ await ecod.crm.pipelines.deleteStage("stage_id", "fallback_stage_id");
385
411
  ```typescript
386
412
  // CRUD
387
413
  const { data } = await ecod.crm.automations.list();
388
- await ecod.crm.automations.create({ name: "Follow-up", trigger: "lead_created", nodes: [], edges: [] });
414
+ await ecod.crm.automations.create({
415
+ name: "Follow-up",
416
+ trigger: "lead_created",
417
+ nodes: [],
418
+ edges: [],
419
+ });
389
420
  await ecod.crm.automations.update("rule_id", { isActive: false });
390
421
  await ecod.crm.automations.toggle("rule_id");
391
422
  await ecod.crm.automations.deleteRule("rule_id");
@@ -396,7 +427,10 @@ await ecod.crm.automations.test("rule_id", "lead_id");
396
427
  const { data: events } = await ecod.crm.automations.getAvailableEvents();
397
428
 
398
429
  // Enrollment management
399
- const { data } = await ecod.crm.automations.enrollments("rule_id", { status: "active", page: 1 });
430
+ const { data } = await ecod.crm.automations.enrollments("rule_id", {
431
+ status: "active",
432
+ page: 1,
433
+ });
400
434
  await ecod.crm.automations.getEnrollment("enrollment_id");
401
435
  await ecod.crm.automations.pauseEnrollment("rule_id", "enrollment_id");
402
436
  await ecod.crm.automations.resumeEnrollment("rule_id", "enrollment_id");
@@ -436,7 +470,10 @@ const { data } = await ecod.crm.sequences.listForLead("lead_id");
436
470
 
437
471
  ```typescript
438
472
  // Lead timeline (all CRM events in order)
439
- const { data } = await ecod.crm.activities.timeline("lead_id", { page: 1, limit: 50 });
473
+ const { data } = await ecod.crm.activities.timeline("lead_id", {
474
+ page: 1,
475
+ limit: 50,
476
+ });
440
477
 
441
478
  // Filtered activity list
442
479
  const { data } = await ecod.crm.activities.list("lead_id", { type: "call" });
@@ -457,7 +494,9 @@ await ecod.crm.activities.log({
457
494
 
458
495
  // --- Notes ---
459
496
  const { data: notes } = await ecod.crm.activities.notes.list("lead_id");
460
- await ecod.crm.activities.notes.create("lead_id", { content: "Call scheduled for Monday" });
497
+ await ecod.crm.activities.notes.create("lead_id", {
498
+ content: "Call scheduled for Monday",
499
+ });
461
500
  await ecod.crm.activities.notes.update("note_id", "Updated note text");
462
501
  await ecod.crm.activities.notes.pin("note_id"); // pin to top
463
502
  await ecod.crm.activities.notes.pin("note_id", false); // unpin
@@ -469,7 +508,8 @@ await ecod.crm.activities.notes.pin("note_id", false); // unpin
469
508
 
470
509
  ```typescript
471
510
  const { data: overview } = await ecod.crm.analytics.overview("pipeline_id");
472
- const { data: conversion } = await ecod.crm.analytics.conversionRate("pipeline_id");
511
+ const { data: conversion } =
512
+ await ecod.crm.analytics.conversionRate("pipeline_id");
473
513
  const { data: velocity } = await ecod.crm.analytics.dealVelocity("pipeline_id");
474
514
  const { data: stageTime } = await ecod.crm.analytics.stageTime("pipeline_id");
475
515
  ```
@@ -497,7 +537,10 @@ const { data } = await ecod.crm.payments.list("lead_id");
497
537
 
498
538
  ```typescript
499
539
  const { data: stats } = await ecod.crm.automationDashboard.stats();
500
- const { data: logs } = await ecod.crm.automationDashboard.logs({ limit: 10, status: "failed" });
540
+ const { data: logs } = await ecod.crm.automationDashboard.logs({
541
+ limit: 10,
542
+ status: "failed",
543
+ });
501
544
  await ecod.crm.automationDashboard.retryFailedEvent("log_id");
502
545
  ```
503
546
 
@@ -550,7 +593,10 @@ await ecod.events.trigger({
550
593
 
551
594
  ```typescript
552
595
  const { data } = await ecod.events.listCustomEvents();
553
- await ecod.events.createCustomEvent({ name: "webinar_attended", displayName: "Webinar Attended" });
596
+ await ecod.events.createCustomEvent({
597
+ name: "webinar_attended",
598
+ displayName: "Webinar Attended",
599
+ });
554
600
  await ecod.events.deleteCustomEvent("event_id");
555
601
  await ecod.events.emit({ eventName: "webinar_attended", leadId: "lead_id" });
556
602
  ```
@@ -578,8 +624,12 @@ await ecod.marketing.emails.sendTest("dev@example.com");
578
624
  await ecod.marketing.campaigns.create({ name: "Q2 Push", type: "email" });
579
625
  await ecod.marketing.campaigns.list({ status: "active" });
580
626
  await ecod.marketing.campaigns.retrieve("campaign_id");
581
- await ecod.marketing.campaigns.update("campaign_id", { subject: "New subject" });
582
- await ecod.marketing.campaigns.send("campaign_id", { scheduledAt: "2026-05-01T09:00:00Z" });
627
+ await ecod.marketing.campaigns.update("campaign_id", {
628
+ subject: "New subject",
629
+ });
630
+ await ecod.marketing.campaigns.send("campaign_id", {
631
+ scheduledAt: "2026-05-01T09:00:00Z",
632
+ });
583
633
  await ecod.marketing.campaigns.stats("campaign_id");
584
634
  await ecod.marketing.campaigns.delete("campaign_id");
585
635
  ```
@@ -774,7 +824,9 @@ Stream all records without manual page management:
774
824
 
775
825
  ```typescript
776
826
  // With optional type parameter for full type safety
777
- for await (const lead of ecod.crm.leads.listAutoPaging<Lead>({ status: "won" })) {
827
+ for await (const lead of ecod.crm.leads.listAutoPaging<Lead>({
828
+ status: "won",
829
+ })) {
778
830
  await syncToMyDatabase(lead);
779
831
  }
780
832
  ```
@@ -880,7 +932,12 @@ process.on("SIGTERM", () => ecod.disconnect());
880
932
  All methods throw typed errors you can catch and inspect:
881
933
 
882
934
  ```typescript
883
- import { APIError, AuthenticationError, RateLimitError, Ecodrix } from "@ecodrix/erix-api";
935
+ import {
936
+ APIError,
937
+ AuthenticationError,
938
+ RateLimitError,
939
+ Ecodrix,
940
+ } from "@ecodrix/erix-api";
884
941
 
885
942
  try {
886
943
  const { data } = await ecod.crm.leads.retrieve("non_existent_id");
@@ -901,12 +958,12 @@ try {
901
958
 
902
959
  ### Error Classes
903
960
 
904
- | Class | HTTP Status | Description |
905
- | --------------------- | ----------- | ------------------------------------------ |
906
- | `EcodrixError` | — | Base error class |
961
+ | Class | HTTP Status | Description |
962
+ | --------------------- | ----------- | -------------------------------------------- |
963
+ | `EcodrixError` | — | Base error class |
907
964
  | `APIError` | varies | Generic API error with `.status` and `.code` |
908
- | `AuthenticationError` | 401 | Invalid API key or client code |
909
- | `RateLimitError` | 429 | Too many requests |
965
+ | `AuthenticationError` | 401 | Invalid API key or client code |
966
+ | `RateLimitError` | 429 | Too many requests |
910
967
 
911
968
  ---
912
969
 
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import Ce from"repl";import{Command as Ae}from"commander";import Ie from"dotenv";import p from"picocolors";import Re from"axios";import be from"axios-retry";var oe=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},u=class extends oe{status;code;constructor(e,t,n){super(e),this.name="APIError",this.status=t,this.code=n}},y=class extends u{constructor(e="Invalid API Key or Client Code"){super(e,401,"AUTH_FAILED"),this.name="AuthenticationError"}},T=class extends u{constructor(e="Too many requests. Please slow down."){super(e,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};var a=class{constructor(e){this.client=e}client;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){if(e.response){let t=e.response.status,n=e.response.data?.message||e.response.data?.error||"API Request Failed",s=e.response.data?.code;switch(t){case 401:throw new y(n);case 403:throw new y(n);case 429:throw new T(n);default:throw new u(n,t,s)}}throw new u(e.message||"Network Error")}};var P=class extends a{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 v=class extends a{async listNichePacks(e={}){return this.get("/api/admin/onboarding/niche-packs",{params:f(e)})}async getNichePack(e,t){let n=t?{version:t}:void 0;return this.get(`/api/admin/onboarding/niche-packs/${encodeURIComponent(e)}`,{params:n})}async createNichePack(e){return this.post("/api/admin/onboarding/niche-packs",e)}async updateNichePack(e,t,n){let s=n?{version:n}:void 0;return this.patch(`/api/admin/onboarding/niche-packs/${encodeURIComponent(e)}`,t,{params:s})}async publishNichePack(e,t){let n=t?{version:t}:void 0;return this.post(`/api/admin/onboarding/niche-packs/${encodeURIComponent(e)}/publish`,void 0,{params:n})}async unpublishNichePack(e,t){let n=t?{version:t}:void 0;return this.post(`/api/admin/onboarding/niche-packs/${encodeURIComponent(e)}/unpublish`,void 0,{params:n})}async forkNichePack(e,t={}){return this.post(`/api/admin/onboarding/niche-packs/${encodeURIComponent(e)}/fork`,t)}async smokeTestNichePack(e,t={},n){let s=n?{version:n}:void 0;return this.post(`/api/admin/onboarding/niche-packs/${encodeURIComponent(e)}/smoke-test`,t,{params:s})}async listOnboardingConfigs(e={}){return this.get("/api/admin/onboarding/configs",{params:f(e)})}async createOnboardingConfig(e){return this.post("/api/admin/onboarding/configs",e)}async updateOnboardingConfig(e,t,n){return this.patch(`/api/admin/onboarding/configs/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n)}async publishOnboardingConfig(e,t){return this.post(`/api/admin/onboarding/configs/${encodeURIComponent(e)}/${encodeURIComponent(t)}/publish`)}async listOnboardingExperiments(e={}){return this.get("/api/admin/onboarding/experiments",{params:f(e)})}async getOnboardingExperiment(e){return this.get(`/api/admin/onboarding/experiments/${encodeURIComponent(e)}`)}async createOnboardingExperiment(e){return this.post("/api/admin/onboarding/experiments",e)}async updateOnboardingExperiment(e,t){return this.patch(`/api/admin/onboarding/experiments/${encodeURIComponent(e)}`,t)}async deleteOnboardingExperiment(e){return this.deleteRequest(`/api/admin/onboarding/experiments/${encodeURIComponent(e)}`)}async getOnboardingFunnel(e={}){return this.get("/api/admin/onboarding/analytics/funnel",{params:f(e)})}async getOnboardingTimeOnStep(e={}){return this.get("/api/admin/onboarding/analytics/time-on-step",{params:f(e)})}async getOnboardingAbandonment(e={}){return this.get("/api/admin/onboarding/analytics/abandonment",{params:f(e)})}};function f(r){let e={};for(let[t,n]of Object.entries(r))n!==void 0&&(e[t]=n);return e}var x=class extends a{async getProduct(e){return this.get(`/api/v1/checkout/products/${e}`)}async createSession(e){return this.post("/api/v1/checkout/session",e)}async applyCoupon(e){return this.post("/api/v1/checkout/coupon",e)}async verify(e){return this.post("/api/v1/checkout/verify",e)}async createOrder(e){return this.post("/api/v1/checkout/order",e)}};var w=class extends a{async providers(){return this.get("/api/connect/v1/providers")}async list(){return this.get("/api/connect/v1/connections")}async get_(e){return this.get(`/api/connect/v1/connections/${e}`)}async connect(e,t){return this.post(`/api/connect/v1/connections/${e}/connect`,t)}async configure(e,t){return this.put(`/api/connect/v1/connections/${e}/configure`,t)}async disconnect(e){return this.post(`/api/connect/v1/connections/${e}/disconnect`,{})}async reveal(e){return this.post(`/api/connect/v1/connections/${e}/reveal`,{})}async setAccess(e,t){return this.put(`/api/connect/v1/connections/${e}/access`,t)}};var R=class extends a{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 ce=class extends a{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}`)}},k=class extends a{notes;constructor(e){super(e),this.notes=new ce(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 C=class extends a{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 A=class extends a{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 I=class extends a{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/automations/webhook-event",{ruleId:e,eventName:t,payload:n})}async trigger(e){return this.post("/api/saas/workflows/trigger",e)}};var $=class extends a{async create(e){return this.post("/api/crm/leads",e)}async describe(){let e=await this.fields(),t=Array.isArray(e.data)?e.data:[],n=[{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:[...n,...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 n=[];for(let s=0;s<e.length;s+=t){let g=e.slice(s,s+t).map(l=>this.create(l)),d=await Promise.allSettled(g);for(let l of d)if(l.status==="fulfilled")n.push(l.value);else throw l.reason}return n}async import(e){return this.post("/api/crm/leads/import",{leads:e})}async bulkUpsert(e){return this.import(e)}async list(e){let t={...e};return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/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 g of i)yield g;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 byStage(e,t,n={}){return this.get(`/api/crm/pipelines/${e}/stages/${t}/leads`,{params:n})}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 bulkArchive(e){return this.patch("/api/crm/leads/bulk-archive",{ids:e})}async bulkDelete(e){return this.deleteRequest("/api/crm/leads",{data:{ids:e}})}async archive(e){return this.patch(`/api/crm/leads/${e}/archive`,{})}};var S=class extends a{async capture(e){return this.post("/api/crm/payments/capture",e)}};var O=class extends a{async list(){return this.get("/api/crm/pipelines")}async getStageManifest(e){let t=await this.retrieve(e),n=Array.isArray(t.data?.stages)?t.data.stages:[];return{name:`Pipeline: ${t.data?.name||e}`,fields:n.map(s=>({key:s._id,label:s.name,type:"string",required:!0,options:[{label:s.name,value:s._id}],group:"Stages",uiHints:{color:s.color||"#cbd5e1",probability:s.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/api/crm/pipelines",e)}async retrieve(e){return this.get(`/api/crm/pipelines/${e}`)}async update(e,t){return this.patch(`/api/crm/pipelines/${e}`,t)}async setDefault(e){return this.patch(`/api/crm/pipelines/${e}/default`,{})}async duplicate(e,t){return this.post(`/api/crm/pipelines/${e}/duplicate`,{newName:t})}async archive(e){return this.patch(`/api/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/api/crm/pipelines/${e}`)}async checkInUse(e){return this.get(`/api/crm/pipelines/${e}/in-use`)}async board(e){return this.get(`/api/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/api/crm/pipelines/${e}/forecast`)}async addStage(e,t){return this.post(`/api/crm/pipelines/${e}/stages`,t)}async reorderStages(e,t){return this.patch(`/api/crm/pipelines/${e}/stages/reorder`,{order:t})}async updateStage(e,t){return this.patch(`/api/crm/stages/${e}`,t)}async deleteStage(e,t){return this.deleteRequest(`/api/crm/stages/${e}`,{data:t?{moveLeadsToStageId:t}:void 0})}};var E=class extends a{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 L=class extends a{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 D=class{leads;pipelines;activities;analytics;automations;sequences;scoring;payments;automationDashboard;constructor(e){this.leads=new $(e),this.pipelines=new O(e),this.activities=new k(e),this.analytics=new C(e),this.automations=new I(e),this.sequences=new L(e),this.scoring=new E(e),this.payments=new S(e),this.automationDashboard=new A(e)}};var N=class extends a{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})}async listTemplates(e){return this.get("/api/saas/marketing/mail/templates",{params:e})}async getTemplate(e){return this.get(`/api/saas/marketing/mail/templates/${e}`)}async createTemplate(e){return this.post("/api/saas/marketing/mail/templates",e)}async updateTemplate(e,t){return this.put(`/api/saas/marketing/mail/templates/${e}`,t)}async deleteTemplate(e,t=!1){return this.deleteRequest(`/api/saas/marketing/mail/templates/${e}`,{params:{force:t}})}async previewTemplate(e,t){return this.post(`/api/saas/marketing/mail/templates/${e}/preview`,t)}};var M=class extends a{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/crm/events/emit",e)}};var q=class extends a{async list(e){return this.get("/api/flow/v1/workflows",{params:e})}async create(e){return this.post("/api/flow/v1/workflows",e)}async getWorkflow(e){return this.get(`/api/flow/v1/workflows/${e}`)}async update(e,t){return this.put(`/api/flow/v1/workflows/${e}`,t)}async run(e,t){return this.post(`/api/flow/v1/workflows/${e}/run`,t??{})}async getRun(e){return this.get(`/api/flow/v1/runs/${e}`)}async getRunRecords(e){return this.get(`/api/flow/v1/runs/${e}/records`)}async retry(e){return this.post(`/api/flow/v1/runs/${e}/retry`,{})}async approve(e,t){return this.post(`/api/flow/v1/runs/${e}/approve`,t)}async getRunLogs(e){return this.get(`/api/flow/v1/runs/${e}/logs`)}async templates(e){return this.get("/api/flow/v1/templates",{params:e})}async installTemplate(e,t){return this.post(`/api/flow/v1/templates/${e}/install`,t??{})}};var U=class extends a{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 _=class extends a{async list(e){return this.get("/api/saas/invoices",{params:e})}async getInvoice(e){return this.get(`/api/saas/invoices/${e}`)}async create(e){return this.post("/api/saas/invoices",e)}async update(e,t){return this.patch(`/api/saas/invoices/${e}`,t)}async delete(e){return this.deleteRequest(`/api/saas/invoices/${e}`)}async sendViaWhatsApp(e){return this.post(`/api/saas/invoices/${e}/send-whatsapp`,{})}async getSettings(){return this.get("/api/saas/invoice-settings")}async updateSettings(e){return this.patch("/api/saas/invoice-settings",e)}};var F=class extends a{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 pe=class extends a{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})}},ge=class extends a{async list(e){return this.get("/api/saas/marketing/emails/campaigns",{params:e})}async stats(e){return this.get(`/api/saas/marketing/emails/campaigns/${e}/analytics`)}},le=class extends a{async sendTemplate(e){return this.post("/api/saas/marketing/whatsapp/send-template",e)}},B=class extends a{emails;campaigns;whatsapp;constructor(e){super(e),this.emails=new pe(e),this.campaigns=new ge(e),this.whatsapp=new le(e)}};import we from"axios";var V=class extends a{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 aiDescribe(e){return this.post("/api/saas/storage/ai/describe",{key:e})}async upload(e,t){let n=await this.post("/api/saas/storage/upload-url",t),{uploadUrl:s,key:i}=n.data;await we.put(s,e,{headers:{"Content-Type":t.contentType}});let g=e.size||e.byteLength||0;return this.post("/api/saas/storage/confirm-upload",{key:i,sizeBytes:g})}};var j=class extends a{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 K=class extends a{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 W=class extends a{async global(e){return this.post("/api/onboarding/global",e)}async start(e){return this.post("/api/onboarding/start",e)}async answer(e){return this.post("/api/onboarding/answer",e)}async state(e){return this.get("/api/onboarding/state",{params:{productId:e}})}async complete(e){return this.post("/api/onboarding/complete",e)}async edit(e){return this.post("/api/onboarding/edit",e)}async previewWorkspace(e){return this.get("/api/onboarding/preview-workspace",{params:{sessionId:e}})}};var H=class extends a{async get(e){return super.get(`/api/persona/${e}`)}async reinforce(e){return this.post("/api/persona/reinforce",e)}async confidence(e){return super.get("/api/persona/confidence",{params:{productId:e}})}async timeline(e,t){return(await super.get(`/api/persona/${e}/timeline`,{params:t}))?.data??{entries:[],hasMore:!1}}async followups(e){return(await super.get(`/api/persona/${e}/followups`))?.data?.entries??[]}};var Q=class extends a{async conversations(){return this.get("/api/saas/portal-inbox/conversations")}async messages(e){return this.get(`/api/saas/portal-inbox/conversations/${e}/messages`)}async reply(e,t){return this.post(`/api/saas/portal-inbox/conversations/${e}/messages`,t)}};var z=class extends a{async list(e){return this.get(`/api/saas/projects/${e}/documents`)}async upload(e,t){return this.post(`/api/saas/projects/${e}/documents`,t)}async toggleSignature(e,t,n){return this.patch(`/api/saas/projects/${e}/documents/${t}/signature`,{required:n})}async addSigner(e,t,n){return this.post(`/api/saas/projects/${e}/documents/${t}/signers`,n)}async sign(e,t,n){return this.post(`/api/saas/projects/${e}/documents/${t}/sign`,n??{})}async decline(e,t){return this.post(`/api/saas/projects/${e}/documents/${t}/decline`,{})}async stampSign(e,t,n){return this.post(`/api/saas/projects/${e}/documents/${t}/stamp-sign`,n)}};var J=class extends a{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 Y=class extends a{async list(){return this.get("/api/laie/v1/relays")}async create(e){return this.post("/api/laie/v1/relays",e)}async update(e,t){return this.patch(`/api/laie/v1/relays/${e}`,t)}async delete(e){return this.deleteRequest(`/api/laie/v1/relays/${e}`)}async getConfig(){return this.get("/api/laie/v1/relays/config")}async updateConfig(e){return this.patch("/api/laie/v1/relays/config",e)}async ping(){return this.post("/api/laie/v1/relays/ping")}async provision(e={}){return this.post("/api/laie/v1/relays/provision",e)}async retire(e){return this.post(`/api/laie/v1/relays/${e}/retire`)}};var de=class extends a{async list(){return this.get("/api/clients")}async getCountAndGenerateCode(){return this.get("/api/clients/count")}async retrieve(e){return this.get(`/api/clients/${e}`)}async getApiKey(e){return this.get(`/api/clients/${e}/api-key`)}async rotateApiKey(e){return this.post(`/api/clients/${e}/api-key`,{})}async create(e){return this.post("/api/clients",e)}async getConfig(e){return this.get(`/api/clients/${e}/config`)}async updateConfig(e,t){return this.patch(`/api/clients/${e}/config`,t)}async getConnections(e){return this.get(`/api/clients/${e}/connections`)}async getConnectProviders(e){return this.get(`/api/clients/${e}/connections/providers`)}async connectProvider(e,t,n){return this.post(`/api/clients/${e}/connections/${t}/connect`,n)}async configureProvider(e,t,n){return this.put(`/api/clients/${e}/connections/${t}/configure`,n)}async disconnectProvider(e,t){return this.post(`/api/clients/${e}/connections/${t}/disconnect`,{})}async revealConnection(e,t){return this.post(`/api/clients/${e}/connections/${t}/reveal`,{})}async setConnectionAccess(e,t,n){return this.put(`/api/clients/${e}/connections/${t}/access`,n)}async getDataSource(e){return this.get(`/api/clients/${e}/datasource`)}async manageDataSource(e,t){return this.post(`/api/clients/${e}/datasource`,t)}async updateIdentity(e,t){return this.patch(`/api/clients/${e}/identity`,t)}async googleReauth(e,t={}){return this.post(`/api/clients/${e}/google/reauth`,t)}async delete(e){return this.deleteRequest(`/api/clients/${e}`)}},ue=class extends a{async list(){return this.get("/api/services/blogs")}},me=class extends a{async add(e){return this.post("/api/services/add-lead",e)}},G=class extends a{clients;blogs;globalLeads;constructor(e){super(e),this.clients=new de(e),this.blogs=new ue(e),this.globalLeads=new me(e)}};var ye=class extends a{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")}},X=class extends a{email;constructor(e){super(e),this.email=new ye(e)}};var he=class extends a{async create(e){return this.post("/api/saas/storage/folders",{name:e})}async delete(e){return this.deleteRequest(`/api/saas/storage/folders/${encodeURIComponent(e)}`)}},fe=class extends a{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}})}},Z=class extends a{folders;files;constructor(e){super(e),this.folders=new he(e),this.files=new fe(e)}async usage(){return this.get("/api/saas/storage/usage")}};var b=class extends u{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},ee=class{async constructEvent(e,t,n){if(!t)throw new b("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"),d=i.createHmac("sha256",n).update(e).digest("hex");if(!i.timingSafeEqual(Buffer.from(d),Buffer.from(s)))throw new b("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(i){throw i instanceof b?i:new b(`Webhook payload parsing failed: ${i.message}`)}}};var te=class extends a{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 ne=class extends a{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 se=class extends a{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 ae=class extends a{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),n=Array.isArray(t.data?.components)?t.data.components:[],s=[];for(let i of n)if(i.text){let g=i.text.match(/{{(\d+)}}/g);if(g)for(let d of g){let l=d.replace(/{{|}}/g,"");s.push({key:`var_${l}`,label:`${i.type} Var {{${l}}}`,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 re=class extends a{messages;conversations;broadcasts;templates;constructor(e){super(e),this.messages=new se(e),this.conversations=new ne(e),this.broadcasts=new te(e),this.templates=new ae(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 ke="https://api.ecodrix.com",ie=class{client;socket=null;socketPromise=null;socketQueue=[];clientCode;whatsapp;crm;media;meet;notifications;email;logs;events;webhooks;storage;marketing;health;queue;agency;services;settings;cors;relays;checkout;connect;onboarding;adminOnboarding;persona;flow;portalInbox;projectDocuments;invoices;constructor(e){if(!e.apiKey)throw new y("API Key is required");this.clientCode=e.clientCode?.toUpperCase();let t=e.baseUrl??ke,n=e.socketUrl||t,s=typeof window<"u"&&typeof window.document<"u",i=s?"browser":typeof process<"u"?`node ${process.version}`:"unknown",g=s?globalThis.navigator?.userAgent||"browser":typeof process<"u"?process.platform:"unknown",d={"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:g})};if(e.coreApiKey&&(d["x-core-api-key"]=e.coreApiKey),this.client=Re.create({baseURL:t,headers:d}),be(this.client,{retries:3,retryDelay:be.exponentialDelay,retryCondition:l=>be.isNetworkOrIdempotentRequestError(l)||l.response?.status===429,onRetry:(l,xe,Te)=>{typeof process<"u"&&process.env?.NODE_ENV==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${l}/3): ${Te.method?.toUpperCase()} ${Te.url}. Reason: ${xe.message}`)}}),this.whatsapp=new re(this.client),this.crm=new D(this.client),this.media=new V(this.client),this.meet=new j(this.client),this.notifications=new K(this.client),this.email=new N(this.client),this.logs=new F(this.client),this.events=new M(this.client),this.webhooks=new ee,this.storage=new Z(this.client),this.marketing=new B(this.client),this.health=new U(this.client),this.queue=new J(this.client),this.agency=new P(this.client),this.services=new G(this.client),this.settings=new X(this.client),this.cors=new R(this.client),this.relays=new Y(this.client),this.checkout=new x(this.client),this.connect=new w(this.client),this.onboarding=new W(this.client),this.adminOnboarding=new v(this.client),this.persona=new H(this.client),this.flow=new q(this.client),this.portalInbox=new Q(this.client),this.projectDocuments=new z(this.client),this.invoices=new _(this.client),this.initSocket(n,e.apiKey,e.clientCode),s){let l={version:"1.2.2",clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=l,window.ecodrix||(window.ecodrix=this)}}initSocket(e,t,n){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:s})=>{this.socket=s(e,{extraHeaders:{"x-api-key":t,"x-client-code":n?.toUpperCase()||""}}),this.setupSocket(n);for(let{type:i,args:g}of this.socketQueue)i==="joinRoom"?this.socket.emit("join-room",g[0]):i==="leaveRoom"?this.socket.emit("leave-room",g[0]):i==="on"?this.socket.on(g[0],g[1]):i==="off"?this.socket.off(g[0],g[1]):i==="disconnect"&&this.socket.disconnect();this.socketQueue=[]}),this.socketPromise)}joinRoom(e){this.socket?this.socket.emit("join-room",e):this.socketQueue.push({type:"joinRoom",args:[e]})}leaveRoom(e){this.socket?this.socket.emit("leave-room",e):this.socketQueue.push({type:"leaveRoom",args:[e]})}setupSocket(e){this.socket&&this.socket.on("connect",()=>{e&&this.socket.emit("join-room",e.toUpperCase())})}on(e,t){return this.socket?this.socket.on(e,t):this.socketQueue.push({type:"on",args:[e,t]}),this}disconnect(){this.socket?this.socket.disconnect():this.socketQueue.push({type:"disconnect",args:[]})}off(e,t){return this.socket?this.socket.off(e,t):this.socketQueue.push({type:"off",args:[e,t]}),this}async request(e,t,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")}}};Ie.config();var Pe="1.5.0";var $e="Official Isomorphic SDK for the ECODrIx platform. Native support for WhatsApp, CRM, Storage, and Meetings across TS, JS, Python, and Java.",m=new Ae;m.name("erix").description($e).version(Pe);function h(r){let e=r.key||process.env.ECOD_API_KEY,t=r.client||process.env.ECOD_CLIENT_CODE;return e||(console.error(p.red("Error: API Key is missing.")),console.log(p.yellow("Set ECOD_API_KEY environment variable or use --key <key>")),process.exit(1)),new ie({apiKey:e,clientCode:t,baseUrl:r.baseUrl||process.env.ECOD_BASE_URL})}m.option("-k, --key <key>","ECODrIx API Key").option("-c, --client <code...","Tenant Client Code").option("--base-url <url>","API Base URL override");m.command("whoami").description("Verify current authentication and tenant status").action(async(r,e)=>{let t=e.parent.opts(),n=h(t);console.log(p.cyan("Checking connection to ECODrIx Platform..."));try{let s=await n.request("GET","/api/saas/me/profile");console.log(p.green("\u2714 Authenticated successfully!")),console.log(`${p.bold("User ID:")} ${s.id}`),console.log(`${p.bold("Organisation:")} ${s.organisation?.name||"N/A"}`),t.client&&console.log(`${p.bold("Tenant Code:")} ${p.magenta(t.client)}`)}catch(s){console.error(p.red("\u2716 Authentication failed")),console.error(p.dim(s.message)),process.exit(1)}});var Se=m.command("whatsapp").description("WhatsApp Business API operations");Se.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(r,e,t,n)=>{let s=n.parent.parent.opts(),i=h(s);try{let g=JSON.parse(t.vars);console.log(p.cyan(`Sending template '${e}' to ${r}...`));let d=await i.whatsapp.messages.sendTemplate({to:r,templateName:e,language:"en_US",variables:g});console.log(p.green("\u2714 Message sent successfully!")),console.log(p.dim(`ID: ${d?.id||"N/A"}`))}catch(g){console.error(p.red("\u2716 Failed to send message")),console.error(p.dim(g.message))}});var ve=m.command("crm").description("CRM and Lead management");ve.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(r,e)=>{let t=e.parent.parent.opts(),n=h(t);try{let s=Number.parseInt(r.limit);console.log(p.cyan(`Fetching last ${s} leads...`));let i={limit:s};r.status&&(i.status=r.status),r.pipeline&&(i.pipelineId=r.pipeline),r.search&&(i.search=r.search);let g=await n.crm.leads.list(i),d=Array.isArray(g.data)?g.data:Array.isArray(g)?g:[];if(d.length===0){console.log(p.yellow("No leads found."));return}console.table(d.map(l=>({ID:l.id||l._id,Name:`${l.firstName} ${l.lastName||""}`.trim(),Phone:l.phone,Status:l.status,Score:l.score||0,Created:new Date(l.createdAt).toLocaleDateString()})))}catch(s){console.error(p.red("\u2716 Failed to fetch leads")),console.error(p.dim(s.message))}});ve.command("pipelines").description("List all CRM pipelines").action(async(r,e)=>{let t=e.parent.parent.opts(),n=h(t);try{console.log(p.cyan("Fetching pipelines..."));let s=await n.crm.pipelines.list(),i=s.data||s||[];if(i.length===0){console.log(p.yellow("No pipelines found."));return}console.table(i.map(g=>({ID:g.id||g._id,Name:g.name,Default:g.isDefault?"Yes":"No",Stages:g.stages?.length||0})))}catch(s){console.error(p.red("\u2716 Failed to fetch pipelines")),console.error(p.dim(s.message))}});var Oe=m.command("analytics").description("Business Intelligence Analytics");Oe.command("overview").description("Get high-level CRM KPIs").option("-r, --range <range>","Date range (e.g., 24h, 7d, 30d, 365d)","30d").action(async(r,e)=>{let t=e.parent.parent.opts(),n=h(t);try{console.log(p.cyan(`Fetching overview metrics for last ${r.range}...`));let s=await n.crm.analytics.overview({range:r.range}),i=s.data||s;console.log(`
3
- ${p.bold("OVERVIEW KPIs:")}`),console.log(`Total Leads: ${p.green(i.totalLeads||0)}`),console.log(`Open Value: ${p.yellow(`$${(i.openValue||0).toLocaleString()}`)}`),console.log(`Won Revenue: ${p.green(`$${(i.wonRevenue||0).toLocaleString()}`)}`),console.log(`Avg Score: ${p.blue(i.avgScore?.toFixed(1)||0)}`),console.log(`Conversion: ${p.magenta(`${(i.conversionRate||0).toFixed(2)}%`)}
4
- `)}catch(s){console.error(p.red("\u2716 Failed to fetch analytics overview")),console.error(p.dim(s.message))}});var Ee=m.command("webhooks").description("Webhook utility tools");Ee.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(r,e,t,n,s)=>{let i=s.parent.parent.opts(),g=h(i);try{await g.webhooks.constructEvent(r,e,t),console.log(p.green("\u2714 Signature is VALID"))}catch(d){console.error(p.red("\u2716 Error during verification")),console.error(p.dim(d.message))}});m.command("shell").alias("repl").description("Start an interactive SDK shell").action(async(r,e)=>{let t=e.parent.opts(),n=h(t);console.log(p.magenta(p.bold(`
5
- Welcome to the Erix Interactive Shell`))),console.log(p.dim(`SDK Version: ${Pe}`)),console.log(p.dim(`The 'ecod' client is pre-initialized and ready.
6
- `));let s=Ce.start({prompt:p.cyan("erix > "),useColors:!0});s.context.ecod=n,s.context.whatsapp=n.whatsapp,s.context.crm=n.crm,s.context.meet=n.meet,s.context.media=n.media,s.on("exit",()=>{console.log(p.yellow(`
7
- Goodbye!`)),process.exit(0)})});m.command("completion").description("Generate Bash auto-completion script").action(()=>{console.log(`
2
+ import $n from"repl";import{Command as In}from"commander";import Cn from"dotenv";import p from"picocolors";import An from"axios";import Tn from"axios-retry";var Qe="https://api.ecodrix.com";function xn(r="v1",e=Qe){return`${e.replace(/\/+$/,"")}/${r}/api`}var Ye=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},m=class extends Ye{status;code;constructor(e,n,s){super(e),this.name="APIError",this.status=n,this.code=s}},y=class extends m{constructor(e="Invalid API Key or Client Code"){super(e,401,"AUTH_FAILED"),this.name="AuthenticationError"}},x=class extends m{constructor(e="Too many requests. Please slow down."){super(e,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};var t=class{constructor(e){this.client=e}client;async post(e,n,s){try{let a=this.buildConfig(s);return(await this.client.post(e,n,a)).data}catch(a){this.handleError(a)}}async get(e,n){try{let s=this.buildConfig(n);return(await this.client.get(e,s)).data}catch(s){this.handleError(s)}}async patch(e,n,s){try{let a=this.buildConfig(s);return(await this.client.patch(e,n,a)).data}catch(a){this.handleError(a)}}async put(e,n,s){try{let a=this.buildConfig(s);return(await this.client.put(e,n,a)).data}catch(a){this.handleError(a)}}async deleteRequest(e,n){try{let s=this.buildConfig(n);return(await this.client.delete(e,s)).data}catch(s){this.handleError(s)}}buildConfig(e){if(!e)return;let n={...e};return e.idempotencyKey&&(n.headers={...n.headers,"Idempotency-Key":e.idempotencyKey}),n}handleError(e){if(e.response){let n=e.response.status,s=e.response.data?.message||e.response.data?.error||"API Request Failed",a=e.response.data?.code;switch(n){case 401:throw new y(s);case 403:throw new y(s);case 429:throw new x(s);default:throw new m(s,n,a)}}throw new m(e.message||"Network Error")}};var Ge=class extends t{async list(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async create(e,n){return this.post(`/product/erix/crm/leads/${e}/notes`,n)}async update(e,n){return this.patch(`/product/erix/crm/notes/${e}`,{content:n})}async pin(e,n=!0){return this.patch(`/product/erix/crm/notes/${e}/pin`,{isPinned:n})}async delete(e){return this.deleteRequest(`/product/erix/crm/notes/${e}`)}},w=class extends t{notes;constructor(e){super(e),this.notes=new Ge(e)}async timeline(e,n){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:n})}async list(e,n){return this.get(`/product/erix/crm/leads/${e}/activities`,{params:{...n}})}async log(e){return this.post(`/product/erix/crm/leads/${e.leadId}/activities`,e)}async logCall(e,n){return this.post(`/product/erix/crm/leads/${e}/calls`,n)}};var R=class extends t{async overview(e){return this.get("/product/erix/crm/analytics/overview",{params:e})}async funnel(e){return this.get("/product/erix/crm/analytics/funnel",{params:{pipelineId:e}})}async forecast(e){return this.get("/product/erix/crm/analytics/forecast",{params:{pipelineId:e}})}async sources(e){return this.get("/product/erix/crm/analytics/sources",{params:e})}async team(e){return this.get("/product/erix/crm/analytics/team",{params:e})}async heatmap(e){return this.get("/product/erix/crm/analytics/heatmap",{params:e})}async scores(){return this.get("/product/erix/crm/analytics/scores")}async stageTime(e){return this.get("/product/erix/crm/analytics/stage-time",{params:{pipelineId:e}})}async tiered(e){return this.get("/product/erix/crm/analytics/tiered",{params:e})}async summary(e){return this.get("/product/erix/crm/analytics/summary",{params:e})}async whatsapp(e){return this.get("/product/erix/crm/analytics/whatsapp",{params:e})}};var k=class extends t{async stats(){return this.get("/product/erix/crm/automation/stats")}async logs(e){return this.get("/product/erix/crm/automation/logs",{params:e})}async retryFailedEvent(e){return this.post(`/product/erix/crm/automation/logs/${e}/retry`,{})}};var v=class extends t{async list(){return this.get("/product/erix/crm/automations")}async create(e){return this.post("/product/erix/crm/automations",e)}async update(e,n){return this.patch(`/product/erix/crm/automations/${e}`,n)}async toggle(e){return this.patch(`/product/erix/crm/automations/${e}/toggle`)}async delete(e){return this.deleteRequest(`/product/erix/crm/automations/${e}`)}async bulkDelete(e){return this.post("/product/erix/crm/automations/bulk-delete",{ids:e})}async test(e,n){return this.post(`/product/erix/crm/automations/${e}/test`,{leadId:n})}async getAvailableEvents(){return this.post("/product/erix/crm/events",{})}async enrollments(e,n){return this.get(`/product/erix/crm/${e}/enrollments`,{params:n})}async getEnrollment(e){return this.get(`/product/erix/crm/enrollments/${e}`)}async pauseEnrollment(e,n){return this.post(`/product/erix/crm/${e}/enrollments/${n}/pause`,{})}async resumeEnrollment(e,n){return this.post(`/product/erix/crm/${e}/enrollments/${n}/resume`,{})}async runs(e){return this.get(`/product/erix/crm/${e}/runs`)}async getRun(e){return this.get(`/product/erix/crm/runs/${e}`)}async resumeRun(e){return this.post(`/product/erix/crm/runs/${e}/resume`,{})}async abortRun(e){return this.post(`/product/erix/crm/runs/${e}/abort`,{})}async webhookEvent(e,n,s){return this.post("/product/erix/crm/webhook-event",{ruleId:e,eventName:n,payload:s})}async trigger(e){return this.post("/product/erix/workflows/trigger",e)}};var P=class extends t{async create(e){return this.post("/product/erix/crm/leads",e)}async describe(){let e=await this.fields(),n=Array.isArray(e.data)?e.data:[],s=[{key:"firstName",label:"First Name",type:"string",required:!0,group:"Basic Info"},{key:"lastName",label:"Last Name",type:"string",required:!1,group:"Basic Info"},{key:"phone",label:"Phone Number",type:"phone",required:!0,group:"Contact"},{key:"email",label:"Email Address",type:"email",required:!1,group:"Contact"},{key:"status",label:"Status",type:"select",required:!0,options:[{label:"New",value:"new"},{label:"Contacted",value:"contacted"},{label:"Qualified",value:"qualified"},{label:"Won",value:"won"},{label:"Lost",value:"lost"}]},{key:"value",label:"Lead Value",type:"currency",required:!1},{key:"source",label:"Source",type:"string",required:!1}],a=n.map(c=>({key:`metadata.extra.${c.name}`,label:c.label||c.name,type:c.type||"string",required:!!c.required,options:c.options,group:"Custom Fields"}));return{name:"Lead",fields:[...s,...a],uiHints:{icon:"User",primaryColor:"#3b82f6",defaultSort:{field:"createdAt",direction:"desc"},summaryFields:["firstName","lastName","phone","status"]}}}async upsert(e){return this.post("/product/erix/crm/leads/upsert",e)}async createMany(e,n=50){let s=[];for(let a=0;a<e.length;a+=n){let l=e.slice(a,a+n).map(d=>this.create(d)),u=await Promise.allSettled(l);for(let d of u)if(d.status==="fulfilled")s.push(d.value);else throw d.reason}return s}async import(e){return this.post("/product/erix/crm/leads/import",{leads:e})}async bulkUpsert(e){return this.import(e)}async list(e){let n={...e};return Array.isArray(n.tags)&&(n.tags=n.tags.join(",")),this.get("/product/erix/crm/leads",{params:n})}async*listAutoPaging(e){let n=e?.page||1,s=!0;for(;s;){let a=await this.list({...e,page:n}),c=Array.isArray(a.data)?a.data:a||[];if(c.length===0){s=!1;break}for(let l of c)yield l;a.pagination&&n<a.pagination.pages||!a.pagination&&c.length>0?n++:s=!1}}async retrieve(e){return this.get(`/product/erix/crm/leads/${e}`)}async retrieveByPhone(e){return this.get(`/product/erix/crm/leads/phone/${encodeURIComponent(e)}`)}async byStage(e,n,s={}){return this.get(`/product/erix/crm/pipelines/${e}/stages/${n}/leads`,{params:s})}async retrieveByRef(e,n){return this.get(`/product/erix/crm/leads/ref/${encodeURIComponent(e)}/${encodeURIComponent(n)}`)}async update(e,n){return this.patch(`/product/erix/crm/leads/${e}`,n)}async move(e,n){return this.patch(`/product/erix/crm/leads/${e}/move`,{stageId:n})}async convert(e,n,s){return this.post(`/product/erix/crm/leads/${e}/convert`,{outcome:n,reason:s})}async tags(e,n){return this.patch(`/product/erix/crm/leads/${e}/tags`,n)}async recalculateScore(e){return this.post(`/product/erix/crm/leads/${e}/score`,{})}async updateMetadata(e,n){return this.patch(`/product/erix/crm/leads/${e}/metadata`,n)}async fields(){return this.get("/product/erix/crm/fields")}async notes(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async activities(e,n){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:n})}async createNote(e,n){return this.post(`/product/erix/crm/leads/${e}/notes`,n)}async updateNote(e,n,s){return this.patch(`/product/erix/crm/notes/${n}`,s)}async deleteNote(e,n){return this.deleteRequest(`/product/erix/crm/notes/${n}`)}async delete(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async bulkArchive(e){return this.patch("/product/erix/crm/leads/bulk-archive",{ids:e})}async bulkDelete(e){return this.deleteRequest("/product/erix/crm/leads",{data:{ids:e}})}async archive(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async profile(e){return this.get(`/product/erix/crm/leads/${e}/profile`)}async invoices(e){return this.get(`/product/erix/crm/leads/${e}/invoices`)}async projects(e){return this.get(`/product/erix/crm/leads/${e}/projects`)}async conversations(e){return this.get(`/product/erix/crm/leads/${e}/conversations`)}async meetings(e){return this.get(`/product/erix/crm/leads/${e}/meetings`)}async sequences(e){return this.get(`/product/erix/crm/leads/${e}/sequences`)}};var A=class extends t{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var $=class extends t{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){let n=await this.retrieve(e),s=Array.isArray(n.data?.stages)?n.data.stages:[];return{name:`Pipeline: ${n.data?.name||e}`,fields:s.map(a=>({key:a._id,label:a.name,type:"string",required:!0,options:[{label:a.name,value:a._id}],group:"Stages",uiHints:{color:a.color||"#cbd5e1",probability:a.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/product/erix/crm/pipelines",e)}async retrieve(e){return this.get(`/product/erix/crm/pipelines/${e}`)}async update(e,n){return this.patch(`/product/erix/crm/pipelines/${e}`,n)}async setDefault(e){return this.patch(`/product/erix/crm/pipelines/${e}/default`,{})}async duplicate(e,n){return this.post(`/product/erix/crm/pipelines/${e}/duplicate`,{newName:n})}async archive(e){return this.patch(`/product/erix/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/product/erix/crm/pipelines/${e}`)}async checkInUse(e){return this.get(`/product/erix/crm/pipelines/${e}/in-use`)}async board(e){return this.get(`/product/erix/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/product/erix/crm/pipelines/${e}/forecast`)}async addStage(e,n){return this.post(`/product/erix/crm/pipelines/${e}/stages`,n)}async reorderStages(e,n){return this.patch(`/product/erix/crm/pipelines/${e}/stages/reorder`,{order:n})}async updateStage(e,n){return this.patch(`/product/erix/crm/stages/${e}`,n)}async deleteStage(e,n){return this.deleteRequest(`/product/erix/crm/stages/${e}`,{data:n?{moveLeadsToStageId:n}:void 0})}};var I=class extends t{async getConfig(){return this.get("/product/erix/crm/scoring")}async updateConfig(e){return this.patch("/product/erix/crm/scoring",e)}async recalculate(e){return this.post(`/product/erix/crm/scoring/${e}/recalculate`,{})}};var C=class extends t{async enroll(e){return this.post("/product/erix/crm/sequences/enroll",e)}async unenroll(e){return this.deleteRequest(`/product/erix/crm/sequences/unenroll/${e}`)}async listForLead(e){return this.get(`/product/erix/crm/sequences/lead/${e}`)}};var S=class extends t{async list(e){return this.get("/product/erix/chat/broadcasts",{params:e})}async retrieve(e){return this.get(`/product/erix/chat/broadcasts/${e}`)}async create(e){return this.post("/product/erix/chat/broadcast",e)}async update(e,n){return this.patch(`/product/erix/chat/broadcasts/${e}`,n)}async delete(e){return this.deleteRequest(`/product/erix/chat/broadcasts/${e}`)}};var O=class extends t{async list(e){return this.get("/product/erix/chat/conversations",{params:e})}async create(e){return this.post("/product/erix/chat/conversations",e)}async retrieve(e){return this.get(`/product/erix/chat/conversations/${e}`)}async messages(e,n){return this.get(`/product/erix/chat/conversations/${e}/messages`,{params:n})}async linkLead(e,n,s){return this.post(`/product/erix/chat/conversations/${e}/link-lead`,{leadId:n,leadData:s})}async markRead(e){return this.post(`/product/erix/chat/conversations/${e}/read`,{})}async delete(e){return this.deleteRequest(`/product/erix/chat/conversations/${e}`)}async bulkDelete(e){return this.post("/product/erix/chat/conversations/bulk-delete",{ids:e})}};var E=class extends t{async send(e){return this.post("/product/erix/chat/send",e)}async sendTemplate(e){return this.post("/product/erix/chat/send",{...e,templateLanguage:e.language||e.templateLanguage||"en_US"})}async star(e,n){return this.post(`/product/erix/chat/messages/${e}/star`,{isStarred:n})}async react(e,n){return this.post(`/product/erix/chat/messages/${e}/react`,{reaction:n})}async markRead(e){return this.post(`/product/erix/chat/conversations/${e}/read`)}async upload(e){let n=new FormData;return n.append("file",e),this.post("/product/erix/chat/upload",n,{headers:{"Content-Type":"multipart/form-data"}})}};var L=class extends t{async list(e){return this.get("/product/erix/crm/campaigns",{params:e})}async create(e){return this.post("/product/erix/crm/campaigns",e)}async stats(e){return this.get(`/product/erix/crm/campaigns/${e}/analytics`)}};var D=class extends t{async getProduct(e){return this.get(`/product/erix/commerce/checkout/products/${e}`)}async createSession(e){return this.post("/product/erix/commerce/checkout/session",e)}async applyCoupon(e){return this.post("/product/erix/commerce/checkout/coupon",e)}async verify(e){return this.post("/product/erix/commerce/checkout/verify",e)}async createOrder(e){return this.post("/product/erix/commerce/checkout/order",e)}};var N=class extends t{async list(){return this.get("/product/erix/events")}async assign(e){return this.post("/product/erix/events/assign",e)}async unassign(e){return this.post("/product/erix/events/unassign",{name:e})}async unassignBulk(e){return this.post("/product/erix/events/unassign/bulk",{names:e})}async trigger(e){return this.post("/product/erix/workflows/trigger",e)}async listCustomEvents(){return this.get("/product/erix/crm/custom-events")}async createCustomEvent(e){return this.post("/product/erix/crm/custom-events",e)}async deleteCustomEvent(e){return this.deleteRequest(`/product/erix/crm/custom-events/${e}`)}async emit(e){return this.post("/product/erix/crm/events/emit",e)}};var q=class extends t{async list(e){return this.get("/product/erix/commerce/invoices",{params:e})}async getInvoice(e){return this.get(`/product/erix/commerce/invoices/${e}`)}async create(e){return this.post("/product/erix/commerce/invoices",e)}async update(e,n){return this.patch(`/product/erix/commerce/invoices/${e}`,n)}async delete(e){return this.deleteRequest(`/product/erix/commerce/invoices/${e}`)}async sendViaWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${e}/send-whatsapp`,{})}async getSettings(){return this.get("/product/erix/commerce/settings")}async updateSettings(e){return this.put("/product/erix/commerce/settings",e)}};var M=class extends t{async listEventLogs(e){return this.get("/product/erix/event-log/events/logs",{params:e})}async getEventLog(e){return this.get(`/product/erix/event-log/events/logs/${e}`)}async listCallbackLogs(e){return this.get("/product/erix/event-log/callbacks/logs",{params:e})}async getStats(){return this.get("/product/erix/event-log/events/stats")}};var U=class extends t{async conversations(){return this.get("/product/erix/portal-inbox/conversations")}async messages(e){return this.get(`/product/erix/portal-inbox/conversations/${e}/messages`)}async reply(e,n){return this.post(`/product/erix/portal-inbox/conversations/${e}/messages`,n)}};var _=class extends t{async list(e){return this.get(`/product/erix/commerce/projects/${e}/documents`)}async upload(e,n){return this.post(`/product/erix/commerce/projects/${e}/documents`,n)}async toggleSignature(e,n,s){return this.patch(`/product/erix/commerce/projects/${e}/documents/${n}/signature`,{required:s})}async addSigner(e,n,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${n}/signers`,s)}async sign(e,n,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${n}/sign`,s??{})}async decline(e,n){return this.post(`/product/erix/commerce/projects/${e}/documents/${n}/decline`,{})}async stampSign(e,n,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${n}/stamp-sign`,s)}};var V=class extends t{async providers(){return this.get("/infra/connect/providers")}async list(){return this.get("/infra/connect/connections")}async get_(e){return this.get(`/infra/connect/connections/${e}`)}async connect(e,n){return this.post(`/infra/connect/connections/${e}/connect`,n)}async configure(e,n){return this.put(`/infra/connect/connections/${e}/configure`,n)}async disconnect(e){return this.post(`/infra/connect/connections/${e}/disconnect`,{})}async reveal(e){return this.post(`/infra/connect/connections/${e}/reveal`,{})}async test(e){return this.post(`/infra/connect/connections/${e}/test`,{})}async setAccess(e,n){return this.put(`/infra/connect/connections/${e}/access`,n)}async createPaymentLink(e){return this.post("/infra/connect/connections/payments/payment-link",e)}};var F=class extends t{async sendTest(e){return this.post("/infra/connect/email/test",{to:e})}async listTemplates(e){return this.get("/infra/connect/email/templates",{params:e})}async getTemplate(e){return this.get(`/infra/connect/email/templates/${e}`)}async createTemplate(e){return this.post("/infra/connect/email/templates",e)}async updateTemplate(e,n){return this.put(`/infra/connect/email/templates/${e}`,n)}async deleteTemplate(e,n=!1){return this.deleteRequest(`/infra/connect/email/templates/${e}`,{params:{force:n}})}async previewTemplate(e,n){return this.post(`/infra/connect/email/templates/${e}/preview`,n)}};var B=class extends t{async create(e){return this.post("/infra/connect/meet",e)}async list(e){return this.get("/infra/connect/meet",{params:e})}async retrieve(e){return this.get(`/infra/connect/meet/${e}`)}async update(e,n){return this.patch(`/infra/connect/meet/${e}`,n)}async reschedule(e,n){return this.patch(`/infra/connect/meet/${e}`,n)}async delete(e){return this.update(e,{status:"cancelled"})}};var j=class extends t{async getConfig(){return this.get("/infra/connect/email/config")}async switchProvider(e){return this.post("/infra/connect/email/config/provider",{provider:e})}async saveSmtp(e){return this.post("/infra/connect/email/config/smtp",e)}async initDomainVerification(e){return this.post("/infra/connect/email/config/ses/domain",{domain:e})}async saveEmailConfig(e){return this.post("/infra/connect/email/config/ses/config",e)}async checkSesVerification(){return this.get("/infra/connect/email/config/ses/verify")}async removeSesIdentity(){return this.deleteRequest("/infra/connect/email/config/ses/domain")}async sendTest(e){return this.post("/infra/connect/email/config/test",{toEmail:e})}async saveAdvancedConfig(e){return this.post("/infra/connect/email/config/advanced",e)}async getHealth(){return this.get("/infra/connect/email/config/health")}async fixDmarc(){return this.post("/infra/connect/email/config/ses/fix-dmarc",{})}async listProviders(){return this.get("/infra/connect/email/config/providers")}};var K=class extends t{async list(e){return this.get("/infra/connect/whatsapp/templates",{params:e})}async sync(){return this.post("/infra/connect/whatsapp/templates/sync",{})}async retrieve(e){return this.get(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}`)}async create(e){return this.post("/infra/connect/whatsapp/templates",e)}async update(e,n){return this.put(`/infra/connect/whatsapp/templates/${e}`,n)}async deleteTemplate(e,n){return this.deleteRequest(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}${n?"?force=true":""}`)}async mappingConfig(){return this.get("/infra/connect/whatsapp/templates/mapping/config")}async collections(){return this.get("/infra/connect/whatsapp/templates/collections")}async collectionFields(e){return this.get(`/infra/connect/whatsapp/templates/collections/${encodeURIComponent(e)}/fields`)}async updateMapping(e,n){return this.put(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/mapping`,n)}async validate(e){return this.get(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/validate`)}async preview(e,n){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:n})}async getVariableManifest(e){let n=await this.retrieve(e),s=Array.isArray(n.data?.components)?n.data.components:[],a=[];for(let c of s)if(c.text){let l=c.text.match(/{{(\d+)}}/g);if(l)for(let u of l){let d=u.replace(/{{|}}/g,"");a.push({key:`var_${d}`,label:`${c.type} Var {{${d}}}`,type:"string",required:!0,group:c.type,description:`Variable placeholder in template ${c.type}`})}}return{name:`Template variables: ${n.data?.name||e}`,fields:a,uiHints:{icon:"Variables",primaryColor:"#059669"}}}async checkUsage(e){return this.get(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/usage`)}};import vn from"axios";var W=class extends t{async getUsage(){return this.get("/infra/storage/files/usage")}async createFolder(e){return this.post("/infra/storage/files/folders",{name:e})}async list(e,n){return this.get(`/infra/storage/files/files/${e}`,{params:n})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async aiDescribe(e){return this.post("/infra/storage/files/ai/describe",{key:e})}async upload(e,n){let s=await this.post("/infra/storage/files/upload-url",n),{uploadUrl:a,key:c}=s.data;await vn.put(a,e,{headers:{"Content-Type":n.contentType}});let l=e.size||e.byteLength||0;return this.post("/infra/storage/files/confirm-upload",{key:c,sizeBytes:l})}};var H=class extends t{async create(e){return this.post("/infra/storage/files/folders",{name:e})}async delete(e){return this.deleteRequest(`/infra/storage/files/folders/${encodeURIComponent(e)}`)}},z=class extends t{async list(e,n){return this.get(`/infra/storage/files/files/${e}`,{params:n})}async getUploadUrl(e){return this.post("/infra/storage/files/upload-url",e)}async confirmUpload(e){return this.post("/infra/storage/files/confirm-upload",e)}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async delete(e){return this.deleteRequest("/infra/storage/files",{params:{key:e}})}};var Q=class extends t{async listNichePacks(e={}){return this.get("/platform/admin/onboarding/admin/onboarding/niche-packs",{params:T(e)})}async getNichePack(e,n){let s=n?{version:n}:void 0;return this.get(`/platform/admin/onboarding/admin/onboarding/niche-packs/${encodeURIComponent(e)}`,{params:s})}async createNichePack(e){return this.post("/platform/admin/onboarding/admin/onboarding/niche-packs",e)}async updateNichePack(e,n,s){let a=s?{version:s}:void 0;return this.patch(`/platform/admin/onboarding/admin/onboarding/niche-packs/${encodeURIComponent(e)}`,n,{params:a})}async publishNichePack(e,n){let s=n?{version:n}:void 0;return this.post(`/platform/admin/onboarding/admin/onboarding/niche-packs/${encodeURIComponent(e)}/publish`,void 0,{params:s})}async unpublishNichePack(e,n){let s=n?{version:n}:void 0;return this.post(`/platform/admin/onboarding/admin/onboarding/niche-packs/${encodeURIComponent(e)}/unpublish`,void 0,{params:s})}async forkNichePack(e,n={}){return this.post(`/platform/admin/onboarding/admin/onboarding/niche-packs/${encodeURIComponent(e)}/fork`,n)}async smokeTestNichePack(e,n={},s){let a=s?{version:s}:void 0;return this.post(`/platform/admin/onboarding/admin/onboarding/niche-packs/${encodeURIComponent(e)}/smoke-test`,n,{params:a})}async listOnboardingConfigs(e={}){return this.get("/platform/admin/onboarding/admin/onboarding/configs",{params:T(e)})}async createOnboardingConfig(e){return this.post("/platform/admin/onboarding/admin/onboarding/configs",e)}async updateOnboardingConfig(e,n,s){return this.patch(`/platform/admin/onboarding/admin/onboarding/configs/${encodeURIComponent(e)}/${encodeURIComponent(n)}`,s)}async publishOnboardingConfig(e,n){return this.post(`/platform/admin/onboarding/admin/onboarding/configs/${encodeURIComponent(e)}/${encodeURIComponent(n)}/publish`)}async listOnboardingExperiments(e={}){return this.get("/platform/admin/onboarding/admin/onboarding/experiments",{params:T(e)})}async getOnboardingExperiment(e){return this.get(`/platform/admin/onboarding/admin/onboarding/experiments/${encodeURIComponent(e)}`)}async createOnboardingExperiment(e){return this.post("/platform/admin/onboarding/admin/onboarding/experiments",e)}async updateOnboardingExperiment(e,n){return this.patch(`/platform/admin/onboarding/admin/onboarding/experiments/${encodeURIComponent(e)}`,n)}async deleteOnboardingExperiment(e){return this.deleteRequest(`/platform/admin/onboarding/admin/onboarding/experiments/${encodeURIComponent(e)}`)}async getOnboardingFunnel(e={}){return this.get("/platform/admin/onboarding/admin/onboarding/analytics/funnel",{params:T(e)})}async getOnboardingTimeOnStep(e={}){return this.get("/platform/admin/onboarding/admin/onboarding/analytics/time-on-step",{params:T(e)})}async getOnboardingAbandonment(e={}){return this.get("/platform/admin/onboarding/admin/onboarding/analytics/abandonment",{params:T(e)})}};function T(r){let e={};for(let[n,s]of Object.entries(r))s!==void 0&&(e[n]=s);return e}var Y=class extends t{async list(){return this.get("/platform/admin/cors/cors")}async create(e){return this.post("/platform/admin/cors/cors",e)}async update(e,n){return this.patch(`/platform/admin/cors/cors/${e}`,n)}async delete(e){return this.deleteRequest(`/platform/admin/cors/cors/${e}`)}};var G=class extends t{async system(){return(await this.get("/health")).data}};var J=class extends t{async listLogs(e){return this.get("/product/erix/event-log/events/logs",{params:e})}async retrieveLog(e){return this.get(`/product/erix/event-log/events/logs/${e}`)}async getStats(e){return this.get("/product/erix/event-log/events/stats",{params:e})}async listCallbacks(e){return this.get("/product/erix/event-log/callbacks/logs",{params:e})}async listAlerts(e){return this.get("/platform/users/notifications",{params:e})}async dismissAlert(e){return this.patch(`/platform/users/notifications/${e}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/platform/users/notifications/dismiss-all")}async retryAction(e){return this.post(`/platform/users/notifications/${e}/retry`,{})}};var X=class extends t{async global(e){return this.post("/platform/tenants/onboarding/onboarding/global",e)}async start(e){return this.post(`/platform/tenants/onboarding/onboarding/${e.productId}/start`,e)}async answer(e){return this.post("/api/onboarding/answer",e)}async state(e){return this.get(`/platform/tenants/onboarding/onboarding/${e}/state`,{params:{productId:e}})}async complete(e){return this.post("/platform/tenants/onboarding/onboarding/complete",e)}async edit(e){return this.post("/api/onboarding/edit",e)}async previewWorkspace(e){return this.get("/api/onboarding/preview-workspace",{params:{sessionId:e}})}};var Z=class extends t{async get(e){return super.get(`/platform/tenants/persona/persona/${e}`)}async reinforce(e){return this.post(`/platform/tenants/persona/persona/${e.productId}/reinforce`,e)}async confidence(e){return super.get(`/platform/tenants/persona/persona/${e}/confidence`,{params:{productId:e}})}async timeline(e,n){return(await super.get(`/platform/tenants/persona/persona/${e}/timeline`,{params:n}))?.data??{entries:[],hasMore:!1}}async followups(e){return(await super.get(`/platform/tenants/persona/persona/${e}/followups`))?.data?.entries??[]}};var Je=class extends t{async list(){return this.get("/platform/admin/clients")}async getCountAndGenerateCode(){return this.get("/platform/admin/clients/count")}async retrieve(e){return this.get(`/platform/admin/clients/${e}`)}async getApiKey(e){return this.get(`/platform/admin/clients/${e}/api-key`)}async rotateApiKey(e){return this.post(`/platform/admin/clients/${e}/api-key`,{})}async create(e){return this.post("/platform/admin/clients",e)}async getConfig(e){return this.get(`/platform/admin/clients/${e}/config`)}async updateConfig(e,n){return this.patch(`/platform/admin/clients/${e}/config`,n)}async getConnections(e){return this.get(`/platform/admin/clients/${e}/connections`)}async getConnectProviders(e){return this.get(`/platform/admin/clients/${e}/connections/providers`)}async connectProvider(e,n,s){return this.post(`/platform/admin/clients/${e}/connections/${n}/connect`,s)}async configureProvider(e,n,s){return this.put(`/platform/admin/clients/${e}/connections/${n}/configure`,s)}async disconnectProvider(e,n){return this.post(`/platform/admin/clients/${e}/connections/${n}/disconnect`,{})}async revealConnection(e,n){return this.post(`/platform/admin/clients/${e}/connections/${n}/reveal`,{})}async setConnectionAccess(e,n,s){return this.put(`/platform/admin/clients/${e}/connections/${n}/access`,s)}async getDataSource(e){return this.get(`/api/clients/${e}/datasource`)}async manageDataSource(e,n){return this.post(`/api/clients/${e}/datasource`,n)}async updateIdentity(e,n){return this.patch(`/platform/admin/clients/${e}/identity`,n)}async googleReauth(e,n={}){return this.post(`/platform/admin/clients/${e}/google/reauth`,n)}async delete(e){return this.deleteRequest(`/platform/admin/clients/${e}`)}},Xe=class extends t{async list(){return this.get("/platform/admin/blogs/services/blogs")}},Ze=class extends t{async add(e){return this.post("/platform/admin/leads/add-lead",e)}},ee=class extends t{clients;blogs;globalLeads;constructor(e){super(e),this.clients=new Je(e),this.blogs=new Xe(e),this.globalLeads=new Ze(e)}};var en=class extends t{async chatSync(e){return this.post("/platform/ai/copilot/chat/sync",e)}async confirm(e){return this.post("/platform/ai/copilot/confirm",e)}async listSessions(){return this.get("/platform/ai/copilot/sessions")}async getSession(e){return this.get(`/platform/ai/copilot/sessions/${e}`)}async deleteSession(e){return this.deleteRequest(`/platform/ai/copilot/sessions/${e}`)}chatStreamUrl(){return"/platform/ai/copilot/chat"}},ne=class{copilot;constructor(e){this.copilot=new en(e)}};var te=class extends t{async register(e){return this.post("/platform/auth/register",e)}async login(e){return this.post("/platform/auth/login",e)}async logout(e){return this.post("/platform/auth/logout",e)}async logoutAll(e){return this.post("/platform/auth/logout-all",e)}async validateSession(e){return this.post("/platform/auth/session/validate",e)}async listSessions(){return this.get("/platform/auth/sessions")}async revokeSession(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}async requestPasswordOtp(e){return this.post("/platform/auth/password/request-otp",e)}async setPassword(e){return this.post("/platform/auth/password/set",e)}async changePassword(e){return this.post("/platform/auth/password/change",e)}async forgotPassword(e){return this.post("/platform/auth/forgot",e)}async resetPassword(e){return this.post("/platform/auth/reset",e)}async linkOAuth(e){return this.post("/platform/auth/oauth-link",e)}async getInvitation(e){return this.get(`/platform/auth/invitations/${e}`)}async acceptInvitation(e,n){return this.post(`/platform/auth/invitations/${e}/accept`,n)}};var nn=class extends t{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},tn=class extends t{async upgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/upgrade",e)}async downgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/downgrade",e)}async cancel(e){return this.post("/platform/billing/subscriptions/subscriptions/cancel",e)}async purchaseAddon(e){return this.post("/platform/billing/subscriptions/addons/purchase",e)}async cancelAddon(e){return this.post("/platform/billing/subscriptions/addons/cancel",e)}},rn=class extends t{async listPublic(){return this.get("/platform/billing/plans/public")}},sn=class extends t{async plans(){return this.get("/platform/billing/checkout/plans")}async subscribe(e){return this.post("/platform/billing/checkout/subscribe",e)}async verify(e){return this.post("/platform/billing/checkout/verify",e)}async cancel(e){return this.post("/platform/billing/checkout/cancel",e)}async status(){return this.get("/platform/billing/checkout/status")}async syncPlan(e){return this.post("/platform/billing/checkout/sync-plan",e)}},an=class extends t{async transactions(){return this.get("/platform/billing/user/transactions")}async subscription(){return this.get("/platform/billing/user/subscription")}async raiseDispute(e){return this.post("/platform/billing/user/dispute",e)}async disputes(){return this.get("/platform/billing/user/disputes")}},on=class extends t{async balance(){return this.get("/platform/billing/credits/balance")}async transactions(){return this.get("/platform/billing/credits/transactions")}async packs(){return this.get("/platform/billing/credits/packs")}async topupOrder(e){return this.post("/platform/billing/credits/topup/order",e)}async verifyTopup(e){return this.post("/platform/billing/credits/topup/verify",e)}async setAutoTopup(e){return this.patch("/platform/billing/credits/auto-topup",e)}},re=class{entitlements;subscriptions;plans;checkout;user;credits;constructor(e){this.entitlements=new nn(e),this.subscriptions=new tn(e),this.plans=new rn(e),this.checkout=new sn(e),this.user=new an(e),this.credits=new on(e)}};var se=class extends t{async categories(){return this.get("/platform/support/categories")}async listTickets(e){return this.get("/platform/support/tickets",{params:e})}async createTicket(e){return this.post("/platform/support/tickets",e)}async getTicket(e){return this.get(`/platform/support/tickets/${e}`)}async reply(e,n){return this.post(`/platform/support/tickets/${e}/reply`,n)}async close(e){return this.patch(`/platform/support/tickets/${e}/close`,{})}};var ae=class extends t{async get(){return super.get("/platform/users/me")}async update(e){return this.patch("/platform/users/me",e)}async updateOrganization(e){return this.patch("/platform/users/me/organization",e)}async toggleModules(e){return this.post("/platform/users/me/modules",e)}async workspaces(){return super.get("/platform/users/me/workspaces")}async setActiveOrg(e){return this.post("/platform/users/me/active-org",e)}async dismissWorkspaceSetup(){return this.post("/platform/users/me/workspace/dismiss-setup",{})}},ie=class extends t{async list(){return this.get("/platform/users/members/members")}async invite(e){return this.post("/platform/users/members/members/invite",e)}async remove(e){return this.deleteRequest(`/platform/users/members/members/${e}`)}},oe=class extends t{async list(){return this.get("/platform/users/sessions")}async revoke(e){return this.deleteRequest(`/platform/users/sessions/${e}`)}async revokeAll(){return this.deleteRequest("/platform/users/sessions")}};var ce=class extends t{async list(e){return this.get("/platform/admin/logs",{params:e})}async export(e){return this.get("/platform/admin/logs/export",{params:e})}};var pe=class extends t{async getSettings(){return this.get("/platform/admin/agency-invoices/admin/invoice-settings")}async updateSettings(e){return this.patch("/platform/admin/agency-invoices/admin/invoice-settings",e)}async list(e){return this.get("/platform/admin/agency-invoices/admin/invoices",{params:e})}async create(e){return this.post("/platform/admin/agency-invoices/admin/invoices",e)}async retrieve(e){return this.get(`/platform/admin/agency-invoices/admin/invoices/${e}`)}async update(e,n){return this.patch(`/platform/admin/agency-invoices/admin/invoices/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/agency-invoices/admin/invoices/${e}`)}};var le=class extends t{async stats(e){return this.get("/platform/admin/agents/stats",{params:e})}async list(e){return this.get("/platform/admin/agents",{params:e})}async retrieve(e){return this.get(`/platform/admin/agents/${e}`)}async update(e,n){return this.patch(`/platform/admin/agents/${e}`,n)}async runs(e){return this.get(`/platform/admin/agents/${e}/runs`)}};var de=class extends t{async overview(e){return this.get("/platform/admin/analytics/overview",{params:e})}async endpoints(e){return this.get("/platform/admin/analytics/endpoints",{params:e})}async errors(e){return this.get("/platform/admin/analytics/errors",{params:e})}async tenants(e){return this.get("/platform/admin/analytics/tenants",{params:e})}};var ue=class extends t{async list(e){return this.get("/platform/admin/comms",{params:e})}async create(e){return this.post("/platform/admin/comms",e)}async update(e,n){return this.patch(`/platform/admin/comms/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/comms/${e}`)}async publish(e,n){return this.post(`/platform/admin/comms/${e}/publish`,n)}async broadcast(e){return this.post("/platform/admin/comms/broadcast",e)}async setMaintenance(e){return this.post("/platform/admin/comms/maintenance",e)}async getMaintenance(e){return this.get("/platform/admin/comms/maintenance",{params:e})}async changelog(e){return this.post("/platform/admin/comms/changelog",e)}};var me=class extends t{async stats(e){return this.get("/platform/admin/audit/stats",{params:e})}async list(e){return this.get("/platform/admin/audit",{params:e})}async export(e){return this.get("/platform/admin/audit/export",{params:e})}};var ge=class extends t{async events(e){return this.get("/platform/admin/billing/events",{params:e})}async orgEvents(e){return this.get(`/platform/admin/billing/events/${e}`)}async failed(e){return this.get("/platform/admin/billing/failed",{params:e})}async recordEvent(e){return this.post("/platform/admin/billing/record-event",e)}async extendTrial(e){return this.post("/platform/admin/billing/extend-trial",e)}async grandfather(e){return this.post("/platform/admin/billing/grandfather",e)}async reconcile(e){return this.get("/platform/admin/billing/reconcile",{params:e})}};var ye=class extends t{async list(e){return this.get("/platform/admin/blogs/services/blogs",{params:e})}async retrieve(e){return this.get(`/platform/admin/blogs/services/blogs/${e}`)}async create(e){return this.post("/platform/admin/blogs/services/blogs",e)}async update(e,n){return this.put(`/platform/admin/blogs/services/blogs/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/blogs/services/blogs/${e}`)}};var he=class extends t{async requests(e){return this.get("/platform/admin/compliance/requests",{params:e})}async createRequest(e){return this.post("/platform/admin/compliance/requests",e)}async updateRequest(e,n){return this.patch(`/platform/admin/compliance/requests/${e}`,n)}async exportOrg(e,n){return this.post(`/platform/admin/compliance/export/${e}`,n)}};var fe=class extends t{async rateCard(e){return this.get("/platform/admin/credits/rate-card",{params:e})}async packs(e){return this.get("/platform/admin/credits/packs",{params:e})}async createPack(e){return this.post("/platform/admin/credits/packs",e)}async updatePack(e,n){return this.patch(`/platform/admin/credits/packs/${e}`,n)}async deletePack(e){return this.deleteRequest(`/platform/admin/credits/packs/${e}`)}async wallet(e){return this.get(`/platform/admin/credits/wallet/${e}`)}async adjustWallet(e,n){return this.post(`/platform/admin/credits/wallet/${e}/adjust`,n)}};var Te=class extends t{async stats(e){return this.get("/platform/admin/dashboard/admin/dashboard/stats",{params:e})}};var be=class extends t{async overview(e){return this.get("/platform/admin/email/overview",{params:e})}async campaigns(e){return this.get("/platform/admin/email/campaigns",{params:e})}async events(e){return this.get("/platform/admin/email/events",{params:e})}async sesHealth(e){return this.get("/platform/admin/email/ses-health",{params:e})}};var xe=class extends t{async createTenant(e){return this.post("/platform/admin/erix/tenants",e)}async tenants(e){return this.get("/platform/admin/erix/tenants",{params:e})}async tenant(e){return this.get(`/platform/admin/erix/tenants/${e}`)}async updatePlan(e,n){return this.patch(`/platform/admin/erix/tenants/${e}/plan`,n)}async suspend(e,n){return this.post(`/platform/admin/erix/tenants/${e}/suspend`,n)}async reactivate(e,n){return this.post(`/platform/admin/erix/tenants/${e}/reactivate`,n)}async rotateKey(e,n){return this.post(`/platform/admin/erix/tenants/${e}/rotate-key`,n)}async usage(e){return this.get(`/platform/admin/erix/tenants/${e}/usage`)}};var we=class extends t{async list(e){return this.get("/platform/admin/flags",{params:e})}async create(e){return this.post("/platform/admin/flags",e)}async update(e,n){return this.patch(`/platform/admin/flags/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/flags/${e}`)}async listOverrides(e){return this.get(`/platform/admin/flags/${e}/overrides`)}async addOverride(e,n){return this.post(`/platform/admin/flags/${e}/overrides`,n)}async removeOverride(e,n){return this.deleteRequest(`/platform/admin/flags/${e}/overrides/${n}`)}async forOrg(e){return this.get(`/platform/admin/flags/org/${e}`)}};var Re=class extends t{async overview(e){return this.get("/platform/admin/flow/overview",{params:e})}async runs(e){return this.get("/platform/admin/flow/runs",{params:e})}async failures(e){return this.get("/platform/admin/flow/failures",{params:e})}async run(e){return this.get(`/platform/admin/flow/runs/${e}`)}async retryRun(e,n){return this.post(`/platform/admin/flow/runs/${e}/retry`,n)}};var ke=class extends t{async list(e){return this.get(`/platform/admin/integrations/${e}/integrations`)}async connect(e,n,s){return this.post(`/platform/admin/integrations/${e}/integrations/${n}`,s)}async disconnect(e,n){return this.deleteRequest(`/platform/admin/integrations/${e}/integrations/${n}`)}async test(e,n,s){return this.post(`/platform/admin/integrations/${e}/integrations/${n}/test`,s)}async invite(e,n){return this.post(`/platform/admin/integrations/${e}/invite`,n)}};var ve=class extends t{async overview(e){return this.get("/platform/admin/laie/overview",{params:e})}async queue(e){return this.get("/platform/admin/laie/queue",{params:e})}async proxies(e){return this.get("/platform/admin/laie/proxies",{params:e})}async vaultStats(e){return this.get("/platform/admin/laie/vault-stats",{params:e})}async credits(e){return this.get("/platform/admin/laie/credits",{params:e})}async actors(e){return this.get("/platform/admin/laie/actors",{params:e})}async actorRegistry(e){return this.get("/platform/admin/laie/actors/registry",{params:e})}async runActor(e,n){return this.post(`/platform/admin/laie/actors/${e}/run`,n)}async getEnrichmentConfig(){return this.get("/platform/admin/laie/enrichment/config")}async setEnrichmentConfig(e){return this.put("/platform/admin/laie/enrichment/config",e)}async audits(e){return this.get("/platform/admin/laie/audits",{params:e})}async audit(e){return this.get(`/platform/admin/laie/audits/${e}`)}};var Pe=class extends t{async queueStats(e){return this.get("/platform/admin/laie-runtime/queue/stats",{params:e})}async proxyHealth(e){return this.get("/platform/admin/laie-runtime/proxy/health",{params:e})}async browserPoolStats(e){return this.get("/platform/admin/laie-runtime/browser-pool/stats",{params:e})}async replayDlq(e){return this.post("/platform/admin/laie-runtime/dlq/replay",e)}async runStats(e){return this.get("/platform/admin/laie-runtime/runs/stats",{params:e})}};var Ae=class extends t{async overview(e){return this.get("/platform/admin/laie-vault/admin/laie/vault",{params:e})}};var $e=class extends t{async addLead(e){return this.post("/platform/admin/leads/add-lead",e)}async list(e){return this.get("/platform/admin/leads/leads",{params:e})}async retrieve(e){return this.get(`/platform/admin/leads/leads/${e}`)}async update(e,n){return this.patch(`/platform/admin/leads/leads/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/leads/leads/${e}`)}async updateStatus(e,n){return this.patch(`/platform/admin/leads/leads/${e}/status`,n)}async qualification(e,n){return this.post(`/platform/admin/leads/leads/${e}/qualification`,n)}async firstContact(e,n){return this.post(`/platform/admin/leads/leads/${e}/first-contact`,n)}async followup(e,n){return this.post(`/platform/admin/leads/leads/${e}/followup`,n)}async notes(e){return this.get(`/platform/admin/leads/leads/${e}/notes`)}async addNote(e,n){return this.post(`/platform/admin/leads/leads/${e}/notes`,n)}async updateNote(e,n,s){return this.patch(`/platform/admin/leads/leads/${e}/notes/${n}`,s)}async deleteNote(e,n){return this.deleteRequest(`/platform/admin/leads/leads/${e}/notes/${n}`)}};var Ie=class extends t{async json(){return this.get("/platform/admin/openapi/openapi.json")}async spec(){return this.get("/platform/admin/openapi/openapi")}async health(){return this.get("/platform/admin/openapi/openapi/health")}};var Ce=class extends t{async stats(e){return this.get("/platform/admin/partners/stats",{params:e})}async list(e){return this.get("/platform/admin/partners",{params:e})}async create(e){return this.post("/platform/admin/partners",e)}async retrieve(e){return this.get(`/platform/admin/partners/${e}`)}async update(e,n){return this.patch(`/platform/admin/partners/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/partners/${e}`)}async referrals(e){return this.get(`/platform/admin/partners/${e}/referrals`)}async updateReferral(e,n,s){return this.patch(`/platform/admin/partners/${e}/referrals/${n}`,s)}};var Se=class extends t{async refund(e){return this.post("/platform/admin/payments/refund",e)}async validate(e){return this.get(`/platform/admin/payments/validate/${e}`)}async fetch(e){return this.get(`/platform/admin/payments/fetch/${e}`)}async subscription(e){return this.get(`/platform/admin/payments/subscription/${e}`)}async failed(e){return this.get("/platform/admin/payments/failed",{params:e})}async retry(e,n){return this.post(`/platform/admin/payments/retry/${e}`,n)}async timeline(e){return this.get(`/platform/admin/payments/timeline/${e}`)}async risk(e){return this.get(`/platform/admin/payments/risk/${e}`)}};var Oe=class extends t{async stats(e){return this.get("/platform/admin/persona-history/stats",{params:e})}async list(e){return this.get("/platform/admin/persona-history",{params:e})}async retrieve(e){return this.get(`/platform/admin/persona-history/${e}`)}async version(e,n){return this.get(`/platform/admin/persona-history/${e}/${n}`)}};var Ee=class extends t{async templates(e){return this.get("/platform/admin/pipelines/templates",{params:e})}async createTemplate(e){return this.post("/platform/admin/pipelines/templates",e)}async updateTemplate(e,n){return this.patch(`/platform/admin/pipelines/templates/${e}`,n)}async deleteTemplate(e){return this.deleteRequest(`/platform/admin/pipelines/templates/${e}`)}async provision(e){return this.post("/platform/admin/pipelines/provision",e)}async overview(e){return this.get("/platform/admin/pipelines/overview",{params:e})}};var Le=class extends t{async list(e){return this.get("/platform/admin/plans",{params:e})}async create(e){return this.post("/platform/admin/plans",e)}async update(e,n){return this.patch(`/platform/admin/plans/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/plans/${e}`)}async tenants(e){return this.get(`/platform/admin/plans/${e}/tenants`)}};var De=class extends t{async summary(e){return this.get("/platform/admin/revenue/summary",{params:e})}async snapshots(e){return this.get("/platform/admin/revenue/snapshots",{params:e})}async generateSnapshot(e){return this.post("/platform/admin/revenue/snapshot/generate",e)}};var Ne=class extends t{async verifyCredentials(e){return this.post("/platform/admin/auth/admin/staff/verify-credentials",e)}async findOrCreate(e){return this.post("/platform/admin/auth/admin/staff/find-or-create",e)}async list(e){return this.get("/platform/admin/auth/admin/staff",{params:e})}async create(e){return this.post("/platform/admin/auth/admin/staff",e)}async update(e,n){return this.patch(`/platform/admin/auth/admin/staff/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/auth/admin/staff/${e}`)}};var qe=class extends t{async stats(e){return this.get("/platform/admin/storage/stats",{params:e})}async events(e){return this.get("/platform/admin/storage/events",{params:e})}async usage(e){return this.get("/platform/admin/storage/usage",{params:e})}};var Me=class extends t{async overview(e){return this.get("/platform/admin/health",{params:e})}};var Ue=class extends t{async list(e){return this.get("/platform/admin/templates",{params:e})}async create(e){return this.post("/platform/admin/templates",e)}async retrieve(e){return this.get(`/platform/admin/templates/${e}`)}async update(e,n){return this.patch(`/platform/admin/templates/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/templates/${e}`)}async clone(e,n){return this.post(`/platform/admin/templates/${e}/clone`,n)}async versions(e){return this.get(`/platform/admin/templates/${e}/versions`)}async assignPlans(e,n){return this.post(`/platform/admin/templates/${e}/plans`,n)}};var _e=class extends t{async deep(e){return this.get(`/platform/admin/tenants/${e}/deep`)}async usage(e){return this.get(`/platform/admin/tenants/${e}/usage`)}async team(e){return this.get(`/platform/admin/tenants/${e}/team`)}async billing(e){return this.get(`/platform/admin/tenants/${e}/billing`)}async whatsapp(e){return this.get(`/platform/admin/tenants/${e}/whatsapp`)}async flows(e){return this.get(`/platform/admin/tenants/${e}/flows`)}async crmStats(e){return this.get(`/platform/admin/tenants/${e}/crm-stats`)}async impersonate(e,n){return this.post(`/platform/admin/tenants/${e}/impersonate`,n)}async suspend(e,n){return this.post(`/platform/admin/tenants/${e}/suspend`,n)}async reactivate(e,n){return this.post(`/platform/admin/tenants/${e}/reactivate`,n)}async updatePlan(e,n){return this.patch(`/platform/admin/tenants/${e}/plan`,n)}async updateLimits(e,n){return this.patch(`/platform/admin/tenants/${e}/limits`,n)}async bulkAssignPlan(e){return this.post("/platform/admin/tenants/bulk-assign-plan",e)}async unassigned(){return this.get("/platform/admin/tenants/unassigned")}};var Ve=class extends t{async stats(e){return this.get("/platform/admin/tickets/stats",{params:e})}async list(e){return this.get("/platform/admin/tickets",{params:e})}async create(e){return this.post("/platform/admin/tickets",e)}async retrieve(e){return this.get(`/platform/admin/tickets/${e}`)}async update(e,n){return this.patch(`/platform/admin/tickets/${e}`,n)}async addMessage(e,n){return this.post(`/platform/admin/tickets/${e}/messages`,n)}async resolve(e,n){return this.post(`/platform/admin/tickets/${e}/resolve`,n)}async close(e,n){return this.post(`/platform/admin/tickets/${e}/close`,n)}};var Fe=class extends t{async stats(e){return this.get("/platform/admin/waitlist/stats",{params:e})}async list(e){return this.get("/platform/admin/waitlist",{params:e})}async retrieve(e){return this.get(`/platform/admin/waitlist/${e}`)}async update(e,n){return this.patch(`/platform/admin/waitlist/${e}`,n)}async remove(e){return this.deleteRequest(`/platform/admin/waitlist/${e}`)}async bulk(e){return this.post("/platform/admin/waitlist/bulk",e)}};var Be=class extends t{async overview(e){return this.get("/platform/admin/whatsapp/overview",{params:e})}async wabas(e){return this.get("/platform/admin/whatsapp/wabas",{params:e})}async templates(e){return this.get("/platform/admin/whatsapp/templates",{params:e})}async delivery(e){return this.get("/platform/admin/whatsapp/delivery",{params:e})}async webhooks(e){return this.get("/platform/admin/whatsapp/webhooks",{params:e})}};var cn=class{messages;conversations;broadcasts;constructor(e){this.messages=new E(e),this.conversations=new O(e),this.broadcasts=new S(e)}},pn=class{leads;pipelines;automations;activities;analytics;scoring;payments;sequences;automationDashboard;chat;events;eventLog;invoices;checkout;projects;campaigns;portalInbox;constructor(e){this.leads=new P(e),this.pipelines=new $(e),this.automations=new v(e),this.activities=new w(e),this.analytics=new R(e),this.scoring=new I(e),this.payments=new A(e),this.sequences=new C(e),this.automationDashboard=new k(e),this.chat=new cn(e),this.events=new N(e),this.eventLog=new M(e),this.invoices=new q(e),this.checkout=new D(e),this.projects=new _(e),this.campaigns=new L(e),this.portalInbox=new U(e)}},je=class{erix;constructor(e){this.erix=new pn(e)}},ln=class{config;templates;constructor(e){this.config=new j(e),this.templates=new F(e)}},dn=class{templates;constructor(e){this.templates=new K(e)}},un=class{email;whatsapp;meet;connections;constructor(e){this.email=new ln(e),this.whatsapp=new dn(e),this.meet=new B(e),this.connections=new V(e)}},mn=class{files;folders;media;constructor(e){this.files=new z(e),this.folders=new H(e),this.media=new W(e)}},Ke=class{connect;storage;constructor(e){this.connect=new un(e),this.storage=new mn(e)}},gn=class{onboarding;persona;constructor(e){this.onboarding=new X(e),this.persona=new Z(e)}},yn=class{me;members;sessions;notifications;constructor(e){this.me=new ae(e),this.members=new ie(e),this.sessions=new oe(e),this.notifications=new J(e)}},hn=class{revenue;billing;payments;credits;plans;agencyInvoices;flags;activityLogs;auditLogs;analytics;health;storage;announcements;compliance;tickets;templates;agents;personaHistory;openapi;staff;tenants;whatsapp;laie;laieRuntime;laieVault;flow;email;pipelines;integrations;erix;dashboard;partners;waitlist;blogs;leads;onboarding;cors;clients;constructor(e){this.revenue=new De(e),this.billing=new ge(e),this.payments=new Se(e),this.credits=new fe(e),this.plans=new Le(e),this.agencyInvoices=new pe(e),this.flags=new we(e),this.activityLogs=new ce(e),this.auditLogs=new me(e),this.analytics=new de(e),this.health=new Me(e),this.storage=new qe(e),this.announcements=new ue(e),this.compliance=new he(e),this.tickets=new Ve(e),this.templates=new Ue(e),this.agents=new le(e),this.personaHistory=new Oe(e),this.openapi=new Ie(e),this.staff=new Ne(e),this.tenants=new _e(e),this.whatsapp=new Be(e),this.laie=new ve(e),this.laieRuntime=new Pe(e),this.laieVault=new Ae(e),this.flow=new Re(e),this.email=new be(e),this.pipelines=new Ee(e),this.integrations=new ke(e),this.erix=new xe(e),this.dashboard=new Te(e),this.partners=new Ce(e),this.waitlist=new Fe(e),this.blogs=new ye(e),this.leads=new $e(e),this.onboarding=new Q(e),this.cors=new Y(e),this.clients=new ee(e)}},We=class{auth;users;tenants;billing;support;ai;admin;health;constructor(e){this.auth=new te(e),this.users=new yn(e),this.tenants=new gn(e),this.billing=new re(e),this.support=new se(e),this.ai=new ne(e),this.admin=new hn(e),this.health=new G(e)}};var b=class extends m{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},He=class{async constructEvent(e,n,s){if(!n)throw new b("No webhook signature provided");let a=Array.isArray(n)?n[0]:n;a.startsWith("sha256=")&&(a=a.slice(7));try{let c=await import("crypto"),u=c.createHmac("sha256",s).update(e).digest("hex");if(!c.timingSafeEqual(Buffer.from(u),Buffer.from(a)))throw new b("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(c){throw c instanceof b?c:new b(`Webhook payload parsing failed: ${c.message}`)}}};var fn=typeof process<"u"&&"2.0.0"||"2.0.0";var ze=class{client;socket=null;socketPromise=null;socketQueue=[];clientCode;apiVersion;platform;product;infra;webhooks;constructor(e){if(!e.apiKey)throw new y("API Key is required");this.clientCode=e.clientCode?.toUpperCase(),this.apiVersion=e.version??"v1";let n=e.baseUrl??Qe,s=xn(this.apiVersion,n),a=e.socketUrl||n,c=typeof window<"u"&&typeof window.document<"u",l=c?"browser":typeof process<"u"?`node ${process.version}`:"unknown",u=c?globalThis.navigator?.userAgent||"browser":typeof process<"u"?process.platform:"unknown",d={"x-api-key":e.apiKey,"x-client-code":e.clientCode?.toUpperCase()||"","Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:fn,runtime:l,os:u})};if(e.coreApiKey&&(d["x-core-api-key"]=e.coreApiKey),this.client=An.create({baseURL:s,headers:d}),Tn(this.client,{retries:3,retryDelay:Tn.exponentialDelay,retryCondition:f=>Tn.isNetworkOrIdempotentRequestError(f)||f.response?.status===429,onRetry:(f,kn,bn)=>{typeof process<"u"&&process.env?.NODE_ENV==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${f}/3): ${bn.method?.toUpperCase()} ${bn.url}. Reason: ${kn.message}`)}}),this.platform=new We(this.client),this.product=new je(this.client),this.infra=new Ke(this.client),this.webhooks=new He,this.initSocket(a,e.apiKey,e.clientCode),c){let f={version:fn,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=f,window.ecodrix||(window.ecodrix=this)}}initSocket(e,n,s){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:a})=>{this.socket=a(e,{extraHeaders:{"x-api-key":n,"x-client-code":s?.toUpperCase()||""}}),this.setupSocket(s);for(let{type:c,args:l}of this.socketQueue)c==="joinRoom"?this.socket.emit("join-room",l[0]):c==="leaveRoom"?this.socket.emit("leave-room",l[0]):c==="on"?this.socket.on(l[0],l[1]):c==="off"?this.socket.off(l[0],l[1]):c==="disconnect"&&this.socket.disconnect();this.socketQueue=[]}),this.socketPromise)}joinRoom(e){this.socket?this.socket.emit("join-room",e):this.socketQueue.push({type:"joinRoom",args:[e]})}leaveRoom(e){this.socket?this.socket.emit("leave-room",e):this.socketQueue.push({type:"leaveRoom",args:[e]})}setupSocket(e){this.socket&&this.socket.on("connect",()=>{e&&this.socket.emit("join-room",e.toUpperCase())})}on(e,n){return this.socket?this.socket.on(e,n):this.socketQueue.push({type:"on",args:[e,n]}),this}disconnect(){this.socket?this.socket.disconnect():this.socketQueue.push({type:"disconnect",args:[]})}off(e,n){return this.socket?this.socket.off(e,n):this.socketQueue.push({type:"off",args:[e,n]}),this}async request(e,n,s,a){try{return(await this.client.request({method:e,url:n,data:s,params:a})).data}catch(c){throw c.response?new m(c.response.data?.message||c.response.data?.error||"Raw Execution Failed",c.response.status,c.response.data?.code):new m(c.message||"Network Error")}}};Cn.config();var wn="2.0.0";var Sn="Official Isomorphic SDK for the ECODrIx platform. Native support for WhatsApp, CRM, Storage, and Meetings across TS, JS, Python, and Java.",g=new In;g.name("erix").description(Sn).version(wn);function h(r){let e=r.key||process.env.ECOD_API_KEY,n=r.client||process.env.ECOD_CLIENT_CODE;return e||(console.error(p.red("Error: API Key is missing.")),console.log(p.yellow("Set ECOD_API_KEY environment variable or use --key <key>")),process.exit(1)),new ze({apiKey:e,clientCode:n,baseUrl:r.baseUrl||process.env.ECOD_BASE_URL})}g.option("-k, --key <key>","ECODrIx API Key").option("-c, --client <code...","Tenant Client Code").option("--base-url <url>","API Base URL override");g.command("whoami").description("Verify current authentication and tenant status").action(async(r,e)=>{let n=e.parent.opts(),s=h(n);console.log(p.cyan("Checking connection to ECODrIx Platform..."));try{let a=await s.request("GET","/api/saas/me/profile");console.log(p.green("\u2714 Authenticated successfully!")),console.log(`${p.bold("User ID:")} ${a.id}`),console.log(`${p.bold("Organisation:")} ${a.organisation?.name||"N/A"}`),n.client&&console.log(`${p.bold("Tenant Code:")} ${p.magenta(n.client)}`)}catch(a){console.error(p.red("\u2716 Authentication failed")),console.error(p.dim(a.message)),process.exit(1)}});var On=g.command("whatsapp").description("WhatsApp Business API operations");On.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(r,e,n,s)=>{let a=s.parent.parent.opts(),c=h(a);try{let l=JSON.parse(n.vars);console.log(p.cyan(`Sending template '${e}' to ${r}...`));let u=await c.product.erix.chat.messages.sendTemplate({to:r,templateName:e,language:"en_US",variables:l});console.log(p.green("\u2714 Message sent successfully!")),console.log(p.dim(`ID: ${u?.id||"N/A"}`))}catch(l){console.error(p.red("\u2716 Failed to send message")),console.error(p.dim(l.message))}});var Rn=g.command("crm").description("CRM and Lead management");Rn.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(r,e)=>{let n=e.parent.parent.opts(),s=h(n);try{let a=Number.parseInt(r.limit);console.log(p.cyan(`Fetching last ${a} leads...`));let c={limit:a};r.status&&(c.status=r.status),r.pipeline&&(c.pipelineId=r.pipeline),r.search&&(c.search=r.search);let l=await s.product.erix.leads.list(c),u=Array.isArray(l.data)?l.data:Array.isArray(l)?l:[];if(u.length===0){console.log(p.yellow("No leads found."));return}console.table(u.map(d=>({ID:d.id||d._id,Name:`${d.firstName} ${d.lastName||""}`.trim(),Phone:d.phone,Status:d.status,Score:d.score||0,Created:new Date(d.createdAt).toLocaleDateString()})))}catch(a){console.error(p.red("\u2716 Failed to fetch leads")),console.error(p.dim(a.message))}});Rn.command("pipelines").description("List all CRM pipelines").action(async(r,e)=>{let n=e.parent.parent.opts(),s=h(n);try{console.log(p.cyan("Fetching pipelines..."));let a=await s.product.erix.pipelines.list(),c=a.data||a||[];if(c.length===0){console.log(p.yellow("No pipelines found."));return}console.table(c.map(l=>({ID:l.id||l._id,Name:l.name,Default:l.isDefault?"Yes":"No",Stages:l.stages?.length||0})))}catch(a){console.error(p.red("\u2716 Failed to fetch pipelines")),console.error(p.dim(a.message))}});var En=g.command("analytics").description("Business Intelligence Analytics");En.command("overview").description("Get high-level CRM KPIs").option("-r, --range <range>","Date range (e.g., 24h, 7d, 30d, 365d)","30d").action(async(r,e)=>{let n=e.parent.parent.opts(),s=h(n);try{console.log(p.cyan(`Fetching overview metrics for last ${r.range}...`));let a=await s.product.erix.analytics.overview({range:r.range}),c=a.data||a;console.log(`
3
+ ${p.bold("OVERVIEW KPIs:")}`),console.log(`Total Leads: ${p.green(c.totalLeads||0)}`),console.log(`Open Value: ${p.yellow(`$${(c.openValue||0).toLocaleString()}`)}`),console.log(`Won Revenue: ${p.green(`$${(c.wonRevenue||0).toLocaleString()}`)}`),console.log(`Avg Score: ${p.blue(c.avgScore?.toFixed(1)||0)}`),console.log(`Conversion: ${p.magenta(`${(c.conversionRate||0).toFixed(2)}%`)}
4
+ `)}catch(a){console.error(p.red("\u2716 Failed to fetch analytics overview")),console.error(p.dim(a.message))}});var Ln=g.command("webhooks").description("Webhook utility tools");Ln.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(r,e,n,s,a)=>{let c=a.parent.parent.opts(),l=h(c);try{await l.webhooks.constructEvent(r,e,n),console.log(p.green("\u2714 Signature is VALID"))}catch(u){console.error(p.red("\u2716 Error during verification")),console.error(p.dim(u.message))}});g.command("shell").alias("repl").description("Start an interactive SDK shell").action(async(r,e)=>{let n=e.parent.opts(),s=h(n);console.log(p.magenta(p.bold(`
5
+ Welcome to the Erix Interactive Shell`))),console.log(p.dim(`SDK Version: ${wn}`)),console.log(p.dim(`The 'ecod' client is pre-initialized and ready.
6
+ `));let a=$n.start({prompt:p.cyan("erix > "),useColors:!0});a.context.ecod=s,a.context.platform=s.platform,a.context.product=s.product,a.context.infra=s.infra,a.on("exit",()=>{console.log(p.yellow(`
7
+ Goodbye!`)),process.exit(0)})});g.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(p.yellow(`
38
- # To enable, run: eval "$(erix completion)"`)),console.error(p.dim("# Or add it to your ~/.bashrc: erix completion >> ~/.bashrc"))});m.parse();
38
+ # To enable, run: eval "$(erix completion)"`)),console.error(p.dim("# Or add it to your ~/.bashrc: erix completion >> ~/.bashrc"))});g.parse();