@ecodrix/erix-api 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -378,6 +378,67 @@ declare class Automations extends APIResource {
378
378
  webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any): Promise<T>;
379
379
  }
380
380
 
381
+ /**
382
+ * The specific UI control type suggested for a field.
383
+ */
384
+ type FieldType = "string" | "number" | "boolean" | "date" | "datetime" | "select" | "multi-select" | "phone" | "email" | "currency" | "json" | "textarea" | "richtext" | "file" | "image";
385
+ /**
386
+ * Metadata defining a single field within a resource.
387
+ * Used by UI kits to automatically generate forms and validation logic.
388
+ */
389
+ interface FieldManifest {
390
+ /** The technical key name used in API requests. */
391
+ key: string;
392
+ /** Human-readable label (localized if possible). */
393
+ label: string;
394
+ /** Suggested UI type. */
395
+ type: FieldType;
396
+ /** Short hint/placeholder text. */
397
+ description?: string;
398
+ /** Whether the field is required for creation. */
399
+ required: boolean;
400
+ /** Whether the field should be hidden from standard create/edit forms. */
401
+ hidden?: boolean;
402
+ /** If type is 'select', the available options. */
403
+ options?: Array<{
404
+ label: string;
405
+ value: string | number;
406
+ }>;
407
+ /** Validation constraints. */
408
+ validation?: {
409
+ regex?: string;
410
+ min?: number;
411
+ max?: number;
412
+ message?: string;
413
+ };
414
+ /** Whether the field is read-only. */
415
+ readOnly?: boolean;
416
+ /** UI grouping/category name. */
417
+ group?: string;
418
+ }
419
+ /**
420
+ * A logical grouping of fields and UI hints for a top-level resource.
421
+ * Provides a 'blueprint' for erix-react components.
422
+ */
423
+ interface ResourceManifest {
424
+ /** The unique name of the resource (e.g., 'Lead', 'Template'). */
425
+ name: string;
426
+ /** All available fields for this resource. */
427
+ fields: FieldManifest[];
428
+ /** Suggested UI configurations. */
429
+ uiHints?: {
430
+ icon?: string;
431
+ primaryColor?: string;
432
+ /** Default sort order. */
433
+ defaultSort?: {
434
+ field: string;
435
+ direction: "asc" | "desc";
436
+ };
437
+ /** Fields to show in a compact table view. */
438
+ summaryFields?: string[];
439
+ };
440
+ }
441
+
381
442
  /**
382
443
  * Valid statuses for a CRM Lead.
383
444
  */
@@ -475,6 +536,14 @@ declare class Leads extends APIResource {
475
536
  * ```
476
537
  */
477
538
  create<T = any>(params: CreateLeadParams): Promise<T>;
539
+ /**
540
+ * Introspect the Leads resource and provide a "Blueprint" for UI generation.
541
+ *
542
+ * This method returns a list of all fields (standard + custom), their types,
543
+ * labels, and suggested UI controls. Erix React uses this to render SmartForms
544
+ * and tables dynamically.
545
+ */
546
+ describe(): Promise<ResourceManifest>;
478
547
  /**
479
548
  * Upsert a lead by phone number. If a lead with the same phone exists,
480
549
  * it will be updated; otherwise, a new lead is created.
@@ -701,6 +770,15 @@ declare class Pipelines extends APIResource {
701
770
  * ```
702
771
  */
703
772
  list<T = any>(): Promise<T>;
773
+ /**
774
+ * Introspect a pipeline and provide a manifest of its stages.
775
+ *
776
+ * Returns metadata about stage colors, probabilities, and order.
777
+ * Erix React uses this to build kanban boards and stage pickers.
778
+ *
779
+ * @param pipelineId - The unique ID of the pipeline.
780
+ */
781
+ getStageManifest(pipelineId: string): Promise<ResourceManifest>;
704
782
  /**
705
783
  * Create a new CRM sales or support pipeline.
706
784
  *
@@ -907,33 +985,98 @@ interface CampaignResult {
907
985
  message?: string;
908
986
  [key: string]: any;
909
987
  }
910
- declare class EmailResource extends APIResource {
988
+ interface EmailTemplate {
989
+ id: string;
990
+ name: string;
991
+ description?: string;
992
+ subject: string;
993
+ preheader?: string;
994
+ htmlBody: string;
995
+ textBody?: string;
996
+ category: "marketing" | "transactional" | "sequence";
997
+ status: "draft" | "published" | "archived";
998
+ type: "standard" | "layout";
999
+ layoutId?: string;
1000
+ thumbnail?: string;
1001
+ variableMapping?: any[];
1002
+ createdAt: string;
1003
+ updatedAt: string;
1004
+ }
1005
+ interface CreateTemplateDTO {
1006
+ name: string;
1007
+ subject: string;
1008
+ htmlBody: string;
1009
+ description?: string;
1010
+ category?: "marketing" | "transactional" | "sequence";
1011
+ status?: "draft" | "published" | "archived";
1012
+ variableMapping?: any[];
1013
+ }
1014
+ interface TemplatePreviewResponse {
1015
+ success: boolean;
1016
+ data: {
1017
+ subject: string;
1018
+ html: string;
1019
+ text?: string;
1020
+ };
1021
+ }
1022
+ /**
1023
+ * Outbound email marketing engine and template management.
1024
+ *
1025
+ * Access via `ecod.email`.
1026
+ */
1027
+ declare class Email extends APIResource {
911
1028
  /**
912
1029
  * Send an HTML email campaign to a list of recipients.
913
- *
914
- * @param payload - The campaign details (recipients, subject, html).
915
- * @returns The dispatch result indicating success or failure.
916
- * @example
917
- * ```typescript
918
- * await erixClient.email.sendEmailCampaign({
919
- * recipients: ["user1@example.com", "user2@example.com"],
920
- * subject: "Monthly Newsletter",
921
- * html: "<h1>Hello!</h1><p>Check out our latest updates...</p>"
922
- * });
923
- * ```
924
1030
  */
925
- sendEmailCampaign(payload: SendCampaignPayload): Promise<CampaignResult>;
1031
+ sendCampaign(payload: SendCampaignPayload): Promise<CampaignResult>;
926
1032
  /**
927
1033
  * Send a system test email to validate your current SMTP configuration.
928
- *
929
- * @param to - The recipient's email address.
930
- * @returns The dispatch result.
931
- * @example
932
- * ```typescript
933
- * await erixClient.email.sendTestEmail("admin@company.com");
934
- * ```
935
1034
  */
936
- sendTestEmail(to: string): Promise<CampaignResult>;
1035
+ sendTest(to: string): Promise<CampaignResult>;
1036
+ /**
1037
+ * List all email templates.
1038
+ */
1039
+ listTemplates(query?: any): Promise<{
1040
+ success: boolean;
1041
+ data: EmailTemplate[];
1042
+ }>;
1043
+ /**
1044
+ * Get a single email template by ID.
1045
+ */
1046
+ getTemplate(id: string): Promise<{
1047
+ success: boolean;
1048
+ data: EmailTemplate;
1049
+ }>;
1050
+ /**
1051
+ * Create a new email template.
1052
+ */
1053
+ createTemplate(data: CreateTemplateDTO): Promise<{
1054
+ success: boolean;
1055
+ data: EmailTemplate;
1056
+ }>;
1057
+ /**
1058
+ * Update an existing email template.
1059
+ */
1060
+ updateTemplate(id: string, data: Partial<CreateTemplateDTO>): Promise<{
1061
+ success: boolean;
1062
+ data: EmailTemplate;
1063
+ }>;
1064
+ /**
1065
+ * Delete an email template.
1066
+ */
1067
+ deleteTemplate(id: string, force?: boolean): Promise<{
1068
+ success: boolean;
1069
+ }>;
1070
+ /**
1071
+ * Preview a template with dynamic variable resolution.
1072
+ */
1073
+ previewTemplate(id: string, params: {
1074
+ leadId?: string;
1075
+ variables?: Record<string, any>;
1076
+ }): Promise<TemplatePreviewResponse>;
1077
+ }
1078
+ /** @deprecated Use Email instead */
1079
+ declare class EmailResource extends Email {
937
1080
  }
938
1081
 
939
1082
  /**
@@ -1133,39 +1276,122 @@ interface JobStatus {
1133
1276
  failedAt: string | null;
1134
1277
  createdAt: string;
1135
1278
  }
1279
+ /**
1280
+ * Platform and tenant-specific health diagnostics.
1281
+ *
1282
+ * Access via `ecod.health`.
1283
+ */
1136
1284
  declare class Health extends APIResource {
1137
1285
  /**
1138
1286
  * Perform a global platform health check.
1139
- * Verify that the API, database, and background workers are operational.
1140
- *
1141
- * @returns System health summary (status, version, uptime).
1142
- * @example
1143
- * ```typescript
1144
- * const health = await erixClient.health.system();
1145
- * console.log(`API Status: ${health.status}`);
1146
- * ```
1287
+ * Verify that the core API, database, and background workers are operational.
1147
1288
  */
1148
1289
  system(): Promise<SystemHealth>;
1149
1290
  /**
1150
- * Tenant-specific health check. Identifies configured services.
1291
+ * Tenant-specific health check.
1292
+ *
1293
+ * Identifies correctly configured third-party integrations (WhatsApp, SMTP, Google Meet)
1294
+ * and reports active automation counts.
1151
1295
  */
1152
1296
  clientHealth(): Promise<ClientHealth>;
1297
+ /**
1298
+ * Alias for clientHealth to match diagnostic terminology.
1299
+ */
1300
+ getDiagnosticReport(): Promise<ClientHealth>;
1153
1301
  /**
1154
1302
  * Lookup the execution status of a background job.
1155
1303
  *
1304
+ * Use this to poll for completion of long-running tasks like bulk exports
1305
+ * or campaign dispatches.
1306
+ *
1156
1307
  * @param jobId - The unique ID of the background job.
1157
- * @returns Job status report (attempts, error trace, completion time).
1158
- * @example
1159
- * ```typescript
1160
- * const status = await erixClient.health.jobStatus("job_123");
1161
- * if (status.status === "completed") {
1162
- * console.log("Job finished successfully!");
1163
- * }
1164
- * ```
1165
1308
  */
1166
1309
  jobStatus(jobId: string): Promise<JobStatus>;
1167
1310
  }
1168
1311
 
1312
+ interface LogPaginationQuery {
1313
+ page?: number;
1314
+ limit?: number;
1315
+ trigger?: string;
1316
+ status?: "received" | "processing" | "completed" | "partial" | "failed";
1317
+ from?: string;
1318
+ to?: string;
1319
+ }
1320
+ interface EventLog {
1321
+ id: string;
1322
+ trigger: string;
1323
+ phone?: string;
1324
+ email?: string;
1325
+ status: "received" | "processing" | "completed" | "partial" | "failed";
1326
+ rulesMatched: number;
1327
+ jobsCreated: number;
1328
+ meetLink?: string;
1329
+ callbackUrl?: string;
1330
+ callbackStatus: "not_required" | "sent" | "failed";
1331
+ payload: any;
1332
+ error?: string;
1333
+ idempotencyKey?: string;
1334
+ processedAt?: string;
1335
+ createdAt: string;
1336
+ updatedAt: string;
1337
+ }
1338
+ interface CallbackLog {
1339
+ id: string;
1340
+ callbackUrl: string;
1341
+ method: string;
1342
+ payload: any;
1343
+ jobId?: string;
1344
+ enrollmentId?: string;
1345
+ responseStatus: number;
1346
+ responseBody: string;
1347
+ status: "sent" | "failed" | "pending_retry";
1348
+ attempts: number;
1349
+ lastAttemptAt?: string;
1350
+ signature?: string;
1351
+ createdAt: string;
1352
+ }
1353
+ interface LogResponse<T> {
1354
+ success: boolean;
1355
+ data: T[];
1356
+ pagination: {
1357
+ total: number;
1358
+ page: number;
1359
+ limit: number;
1360
+ pages: number;
1361
+ };
1362
+ }
1363
+ /**
1364
+ * Audit and execution logs for platform events and webhooks.
1365
+ *
1366
+ * Access via `ecod.logs`.
1367
+ */
1368
+ declare class Logs extends APIResource {
1369
+ /**
1370
+ * List event execution logs with optional filtering.
1371
+ *
1372
+ * Use this to audit automation triggers and debug workflow execution.
1373
+ */
1374
+ listEventLogs(query?: LogPaginationQuery): Promise<LogResponse<EventLog>>;
1375
+ /**
1376
+ * Get detailed information for a single event execution.
1377
+ */
1378
+ getEventLog(id: string): Promise<{
1379
+ success: boolean;
1380
+ data: EventLog;
1381
+ }>;
1382
+ /**
1383
+ * List webhook callback logs (outbound responses from ECODrIx to your system).
1384
+ */
1385
+ listCallbackLogs(query?: LogPaginationQuery): Promise<LogResponse<CallbackLog>>;
1386
+ /**
1387
+ * Get high-level execution statistics for the tenant.
1388
+ */
1389
+ getStats(): Promise<{
1390
+ success: boolean;
1391
+ data: any;
1392
+ }>;
1393
+ }
1394
+
1169
1395
  interface SendCampaignParams {
1170
1396
  recipients: string[];
1171
1397
  subject: string;
@@ -1352,7 +1578,7 @@ interface UploadOptions {
1352
1578
  * console.log(data.url); // → https://cdn.ecodrix.com/invoices/invoice-001.pdf
1353
1579
  * ```
1354
1580
  */
1355
- declare class MediaResource extends APIResource {
1581
+ declare class Media extends APIResource {
1356
1582
  /**
1357
1583
  * Get current storage usage metrics for the tenant.
1358
1584
  *
@@ -1455,6 +1681,9 @@ declare class MediaResource extends APIResource {
1455
1681
  */
1456
1682
  upload(file: any, options: UploadOptions): Promise<any>;
1457
1683
  }
1684
+ /** @deprecated Use Media instead */
1685
+ declare class MediaResource extends Media {
1686
+ }
1458
1687
 
1459
1688
  /**
1460
1689
  * Parameters for scheduling a new Google Meet appointment.
@@ -2491,6 +2720,15 @@ declare class Templates extends APIResource {
2491
2720
  lead?: any;
2492
2721
  vars?: any;
2493
2722
  }): Promise<T>;
2723
+ /**
2724
+ * Introspect a template and provide a manifest of its required variables.
2725
+ *
2726
+ * This is used by Erix React to build dynamic "Mapping Forms" where users
2727
+ * can connect CRM fields to WhatsApp variables.
2728
+ *
2729
+ * @param templateIdentifier - The name or ID of the template.
2730
+ */
2731
+ getVariableManifest(templateIdentifier: string): Promise<ResourceManifest>;
2494
2732
  /**
2495
2733
  * Check which automations or sequences are currently using this template.
2496
2734
  */
@@ -2597,13 +2835,15 @@ declare class Ecodrix {
2597
2835
  /** CRM resources — Leads and related sub-resources. */
2598
2836
  readonly crm: CRM;
2599
2837
  /** Cloudflare R2-backed media storage. */
2600
- readonly media: MediaResource;
2838
+ readonly media: Media;
2601
2839
  /** Google Meet appointment scheduling. */
2602
2840
  readonly meet: Meetings;
2603
2841
  /** Automation execution logs and provider webhook callbacks. */
2604
2842
  readonly notifications: Notifications;
2605
- /** Outbound email marketing engine. */
2606
- readonly email: EmailResource;
2843
+ /** Outbound email marketing engine and template management. */
2844
+ readonly email: Email;
2845
+ /** Platform-wide execution logs and audit trails. */
2846
+ readonly logs: Logs;
2607
2847
  /** Lead events and workflow automation triggers. */
2608
2848
  readonly events: EventsResource;
2609
2849
  /** Cryptographic webhook signature verification. */
@@ -2697,4 +2937,4 @@ declare class Ecodrix {
2697
2937
  request<T = any>(method: Method, path: string, data?: any, params?: any): Promise<T>;
2698
2938
  }
2699
2939
 
2700
- export { APIError, Activities, Analytics, type AnalyticsParams, type AnalyticsRange, type AssignEventPayload, AuthenticationError, AutomationDashboard, type AutomationRulePayload, Automations, Broadcasts, CRM, type CampaignResult, Campaigns, type ChatMediaMeta, type ClientHealth, Conversations, type CreateBroadcastParams, type CreateLeadParams, type CreateMeetingParams, type CreatePipelineParams, Ecodrix, EcodrixError, type EcodrixOptions, EmailResource, Emails, type EventDefinition, EventsResource, Files, Folders, Health, type JobStats, type JobStatus, type LeadSource, type LeadStatus, Leads, type ListLeadsParams, type ListParams, type LogActivityParams, type LogCallParams, type LogFilter, Marketing, MediaResource, Meetings, Messages, Notes, Notifications, Payments, type PipelineStageParams, Pipelines, Queue, RateLimitError, Scoring, type ScoringConfig, type SendCampaignParams, type SendCampaignPayload, type SendMessageParams, type SendTemplateParams, type SendTemplatePayload, Sequences, Storage, type SystemHealth, type TemplateMapping, Templates, type TriggerPayload, type TriggerResponse, type UpdateMeetingParams, type UploadOptions, type UpsertLeadParams, WebhookSignatureError, Webhooks, WhatsApp, WhatsAppMarketing, Ecodrix as default };
2940
+ export { APIError, Activities, Analytics, type AnalyticsParams, type AnalyticsRange, type AssignEventPayload, AuthenticationError, AutomationDashboard, type AutomationRulePayload, Automations, Broadcasts, CRM, type CallbackLog, type CampaignResult, Campaigns, type ChatMediaMeta, type ClientHealth, Conversations, type CreateBroadcastParams, type CreateLeadParams, type CreateMeetingParams, type CreatePipelineParams, type CreateTemplateDTO, Ecodrix, EcodrixError, type EcodrixOptions, Email, EmailResource, type EmailTemplate, Emails, type EventDefinition, type EventLog, EventsResource, type FieldManifest, type FieldType, Files, Folders, Health, type JobStats, type JobStatus, type LeadSource, type LeadStatus, Leads, type ListLeadsParams, type ListParams, type LogActivityParams, type LogCallParams, type LogFilter, type LogPaginationQuery, type LogResponse, Logs, Marketing, Media, MediaResource, Meetings, Messages, Notes, Notifications, Payments, type PipelineStageParams, Pipelines, Queue, RateLimitError, type ResourceManifest, Scoring, type ScoringConfig, type SendCampaignParams, type SendCampaignPayload, type SendMessageParams, type SendTemplateParams, type SendTemplatePayload, Sequences, Storage, type SystemHealth, type TemplateMapping, type TemplatePreviewResponse, Templates, type TriggerPayload, type TriggerResponse, type UpdateMeetingParams, type UploadOptions, type UpsertLeadParams, WebhookSignatureError, Webhooks, WhatsApp, WhatsAppMarketing, Ecodrix as default };