@ecodrix/erix-api 2.1.3 → 2.1.5

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.
@@ -234,6 +234,26 @@ declare class Analytics extends APIResource {
234
234
  * ```
235
235
  */
236
236
  whatsapp<T = any>(params?: AnalyticsParams): Promise<T>;
237
+ /**
238
+ * Revenue Intelligence — source attribution, deal velocity, cohorts, pulse.
239
+ */
240
+ revenue<T = any>(): Promise<T>;
241
+ /**
242
+ * Business Health Score — 0-100 composite with sub-scores and top actions.
243
+ */
244
+ health<T = any>(): Promise<T>;
245
+ /**
246
+ * Payment Intelligence — client scores, reminders, cash flow forecast.
247
+ */
248
+ payments<T = any>(): Promise<T>;
249
+ /**
250
+ * Review Engine Stats — requests sent, ratings, Google redirects.
251
+ */
252
+ reviews<T = any>(): Promise<T>;
253
+ /**
254
+ * Customer Retention — churn risk, at-risk leads, re-engagement stats.
255
+ */
256
+ retention<T = any>(): Promise<T>;
237
257
  }
238
258
 
239
259
  declare class AutomationDashboard extends APIResource {
@@ -402,6 +422,144 @@ declare class Automations extends APIResource {
402
422
  }): Promise<T>;
403
423
  }
404
424
 
425
+ /**
426
+ * CRM Campaigns — broadcast campaigns with A/B testing.
427
+ *
428
+ * @example
429
+ * ```typescript
430
+ * const campaigns = await ecod.crm.campaigns.list();
431
+ * const analytics = await ecod.crm.campaigns.analytics("campaign-id");
432
+ * const ab = await ecod.crm.campaigns.createAB({ channel: "email", ... });
433
+ * ```
434
+ */
435
+ declare class CRMCampaigns extends APIResource {
436
+ /**
437
+ * List campaigns with metrics.
438
+ */
439
+ list<T = any>(params?: {
440
+ status?: string;
441
+ startDate?: string;
442
+ endDate?: string;
443
+ page?: number;
444
+ limit?: number;
445
+ }): Promise<T>;
446
+ /**
447
+ * Get analytics for a specific campaign.
448
+ */
449
+ analytics<T = any>(campaignId: string): Promise<T>;
450
+ /**
451
+ * Create and send a campaign.
452
+ */
453
+ create<T = any>(payload: {
454
+ channel: "email" | "whatsapp";
455
+ recipients: Array<string | {
456
+ email?: string;
457
+ phone?: string;
458
+ name?: string;
459
+ }>;
460
+ subject?: string;
461
+ html?: string;
462
+ templateName?: string;
463
+ languageCode?: string;
464
+ variables?: Record<string, unknown>;
465
+ }): Promise<T>;
466
+ /**
467
+ * Create an A/B split test campaign.
468
+ */
469
+ createAB<T = any>(payload: {
470
+ channel: "email" | "whatsapp";
471
+ recipients: Array<string | {
472
+ email?: string;
473
+ phone?: string;
474
+ name?: string;
475
+ }>;
476
+ variants: Array<{
477
+ name: string;
478
+ subject?: string;
479
+ html?: string;
480
+ templateName?: string;
481
+ }>;
482
+ testPercent?: number;
483
+ waitHours?: number;
484
+ winnerMetric?: "open" | "click" | "reply" | "delivered";
485
+ }): Promise<T>;
486
+ }
487
+
488
+ /**
489
+ * CRM Documents — document checklist management per lead.
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * const checklist = await ecod.crm.documents.getChecklist("lead-id");
494
+ * await ecod.crm.documents.createChecklist("lead-id", "consultant__business");
495
+ * await ecod.crm.documents.markReceived("lead-id", "pan_card", fileUrl);
496
+ * await ecod.crm.documents.sendReminder("lead-id");
497
+ * ```
498
+ */
499
+ declare class CRMDocuments extends APIResource {
500
+ /**
501
+ * Get document checklist for a lead.
502
+ */
503
+ getChecklist<T = any>(leadId: string): Promise<T>;
504
+ /**
505
+ * Create a checklist from a niche template.
506
+ */
507
+ createChecklist<T = any>(leadId: string, templateNiche: string): Promise<T>;
508
+ /**
509
+ * Mark a checklist item as received.
510
+ */
511
+ markReceived<T = any>(leadId: string, itemKey: string, fileUrl?: string): Promise<T>;
512
+ /**
513
+ * Send missing documents reminder via WhatsApp.
514
+ */
515
+ sendReminder<T = any>(leadId: string): Promise<T>;
516
+ /**
517
+ * List all leads with incomplete document checklists.
518
+ */
519
+ listIncomplete<T = any>(): Promise<T>;
520
+ /**
521
+ * List available checklist templates.
522
+ */
523
+ listTemplates<T = any>(): Promise<T>;
524
+ }
525
+
526
+ /**
527
+ * CRM Invoice Export — download invoices in accounting formats.
528
+ *
529
+ * @example
530
+ * ```typescript
531
+ * const csv = await ecod.crm.invoiceExport.csv({ from: "2026-01-01", status: "paid" });
532
+ * const tally = await ecod.crm.invoiceExport.tally();
533
+ * const zoho = await ecod.crm.invoiceExport.zoho({ from: "2026-06-01", to: "2026-08-31" });
534
+ * ```
535
+ */
536
+ declare class CRMInvoiceExport extends APIResource {
537
+ /**
538
+ * Export invoices as CSV (universal spreadsheet format).
539
+ */
540
+ csv<T = any>(params?: {
541
+ from?: string;
542
+ to?: string;
543
+ status?: string;
544
+ }): Promise<T>;
545
+ /**
546
+ * Export invoices in Tally Prime-compatible JSON format.
547
+ */
548
+ tally<T = any>(params?: {
549
+ from?: string;
550
+ to?: string;
551
+ status?: string;
552
+ }): Promise<T>;
553
+ /**
554
+ * Export invoices in Zoho Books CSV format.
555
+ */
556
+ zoho<T = any>(params?: {
557
+ from?: string;
558
+ to?: string;
559
+ status?: string;
560
+ }): Promise<T>;
561
+ }
562
+
405
563
  /**
406
564
  * The specific UI control type suggested for a field on a `ResourceManifest`.
407
565
  *
@@ -894,6 +1052,14 @@ declare class Leads extends APIResource {
894
1052
  * List sequence enrollments for this lead.
895
1053
  */
896
1054
  sequences<T = any>(leadId: string): Promise<T>;
1055
+ /**
1056
+ * Merge two duplicate leads. Primary survives, secondary's data is merged in
1057
+ * (conversations, activities, tags) and the secondary is deleted.
1058
+ *
1059
+ * @param primaryId - The lead to keep.
1060
+ * @param secondaryId - The lead to merge into primary and delete.
1061
+ */
1062
+ merge<T = any>(primaryId: string, secondaryId: string): Promise<T>;
897
1063
  }
898
1064
 
899
1065
  declare class Payments extends APIResource {
@@ -1974,6 +2140,36 @@ declare class Logs extends APIResource {
1974
2140
  }>;
1975
2141
  }
1976
2142
 
2143
+ /**
2144
+ * Niche Resources — Workflow packs + WhatsApp template suggestions.
2145
+ *
2146
+ * @example
2147
+ * ```typescript
2148
+ * const packs = await ecod.niche.workflowPacks();
2149
+ * const detail = await ecod.niche.workflowPackDetail("pack_healthcare");
2150
+ * const result = await ecod.niche.installWorkflowPack("pack_healthcare");
2151
+ * const templates = await ecod.niche.templateSuggestions();
2152
+ * ```
2153
+ */
2154
+ declare class NicheResources extends APIResource {
2155
+ /**
2156
+ * List workflow packs available for the org's niche.
2157
+ */
2158
+ workflowPacks<T = any>(): Promise<T>;
2159
+ /**
2160
+ * Get a specific workflow pack with full flow details.
2161
+ */
2162
+ workflowPackDetail<T = any>(packId: string): Promise<T>;
2163
+ /**
2164
+ * Install a workflow pack — clone all flows into the org's workspace.
2165
+ */
2166
+ installWorkflowPack<T = any>(packId: string): Promise<T>;
2167
+ /**
2168
+ * WhatsApp template suggestions for the org's niche.
2169
+ */
2170
+ templateSuggestions<T = any>(): Promise<T>;
2171
+ }
2172
+
1977
2173
  /**
1978
2174
  * Portal Inbox — team-side unified inbox for portal conversations.
1979
2175
  *
@@ -2593,9 +2789,65 @@ interface Template {
2593
2789
  status: "APPROVED" | "PENDING" | "REJECTED";
2594
2790
  components: TemplateComponent[];
2595
2791
  }
2792
+ type TemplateBindingSource = "crm" | "trigger" | "system" | "manual" | "static" | "computed";
2793
+ type TemplateEmptyPolicy = "use_fallback" | "error" | "empty_string";
2794
+ interface TemplateBinding {
2795
+ token?: string;
2796
+ position: number;
2797
+ source: TemplateBindingSource;
2798
+ collection?: string;
2799
+ field?: string;
2800
+ staticValue?: string;
2801
+ formula?: string;
2802
+ transform?: string;
2803
+ fallback?: string;
2804
+ required?: boolean;
2805
+ label?: string;
2806
+ componentType?: string;
2807
+ componentIndex?: number;
2808
+ originalIndex?: string | number;
2809
+ }
2596
2810
  interface TemplateMapping {
2597
- mappings: any[];
2598
- onEmptyVariable: string;
2811
+ mappings: TemplateBinding[];
2812
+ onEmptyVariable: TemplateEmptyPolicy;
2813
+ }
2814
+ interface MappingField {
2815
+ key: string;
2816
+ label: string;
2817
+ type?: string;
2818
+ dataType?: string;
2819
+ }
2820
+ interface MappingSources {
2821
+ collections: Array<{
2822
+ name: string;
2823
+ label: string;
2824
+ fields: MappingField[];
2825
+ }>;
2826
+ triggers: Array<{
2827
+ name: string;
2828
+ label: string;
2829
+ fields: MappingField[];
2830
+ }>;
2831
+ system: MappingField[];
2832
+ static: {
2833
+ hint: string;
2834
+ };
2835
+ }
2836
+ interface TemplateApiResponse<T> {
2837
+ success: boolean;
2838
+ data: T;
2839
+ message?: string;
2840
+ error?: string;
2841
+ }
2842
+ interface MappingValidationResult {
2843
+ isReady: boolean;
2844
+ mappingCount: number;
2845
+ }
2846
+ interface MappingPreviewResult {
2847
+ isReady: boolean;
2848
+ resolvedVariables: string[];
2849
+ previewText: string;
2850
+ contextSnapshot?: Record<string, unknown>;
2599
2851
  }
2600
2852
  declare class Templates extends APIResource {
2601
2853
  /**
@@ -2677,8 +2929,10 @@ declare class Templates extends APIResource {
2677
2929
  * ```
2678
2930
  */
2679
2931
  mappingConfig<T = any>(): Promise<T>;
2932
+ /** Tenant-scoped CRM, custom-field, automation, and system mapping sources. */
2933
+ mappingSources<T = MappingSources>(): Promise<TemplateApiResponse<T>>;
2680
2934
  /**
2681
- * List CRM collections available for variable mapping (Leads, Deals, etc.).
2935
+ * List CRM collections available for variable mapping (legacy).
2682
2936
  */
2683
2937
  collections<T = any>(): Promise<T>;
2684
2938
  /**
@@ -2693,27 +2947,17 @@ declare class Templates extends APIResource {
2693
2947
  * @param templateName - Name of the template.
2694
2948
  * @param payload - Mapping definitions.
2695
2949
  */
2696
- updateMapping<T = any>(templateName: string, payload: TemplateMapping): Promise<T>;
2950
+ updateMapping<T = unknown>(templateName: string, payload: TemplateMapping): Promise<TemplateApiResponse<T>>;
2951
+ /** Validate a persisted mapping, or a draft mapping before saving. */
2952
+ validate<T = MappingValidationResult>(templateName: string, draft?: TemplateMapping): Promise<TemplateApiResponse<T>>;
2697
2953
  /**
2698
- * Validate if a template is ready for automated sending based on its mappings.
2954
+ * Preview a template resolution with caller-provided sample data.
2955
+ * Draft mappings are validated server-side and are never persisted.
2699
2956
  */
2700
- validate<T = any>(templateName: string): Promise<T>;
2701
- /**
2702
- * Preview a template resolution with sample data.
2703
- *
2704
- * @param templateName - Name of the template.
2705
- * @param context - Lead data or variable overrides for preview.
2706
- * @example
2707
- * ```typescript
2708
- * const preview = await erixClient.whatsapp.templates.preview("welcome", {
2709
- * lead: { firstName: "Alice" }
2710
- * });
2711
- * ```
2712
- */
2713
- preview<T = any>(templateName: string, context: {
2714
- lead?: any;
2715
- vars?: any;
2716
- }): Promise<T>;
2957
+ preview<T = MappingPreviewResult>(templateName: string, context: {
2958
+ lead?: Record<string, unknown>;
2959
+ vars?: Record<string, unknown>;
2960
+ }, mappings?: TemplateBinding[], onEmptyVariable?: TemplateEmptyPolicy): Promise<TemplateApiResponse<T>>;
2717
2961
  /**
2718
2962
  * Introspect a template and provide a manifest of its required variables.
2719
2963
  *
@@ -6505,6 +6749,10 @@ declare class ErixProduct {
6505
6749
  readonly projects: ProjectDocuments;
6506
6750
  readonly campaigns: Campaigns;
6507
6751
  readonly portalInbox: PortalInbox;
6752
+ readonly niche: NicheResources;
6753
+ readonly documents: CRMDocuments;
6754
+ readonly invoiceExport: CRMInvoiceExport;
6755
+ readonly crmCampaigns: CRMCampaigns;
6508
6756
  constructor(client: AxiosInstance);
6509
6757
  }
6510
6758
  /** Product domain root (`/v1/api/product/*`). */
@@ -7265,4 +7513,4 @@ declare function getRetryConfig(error: any): {
7265
7513
  readonly reason: "Generic API errors may be transient and worth retrying";
7266
7514
  };
7267
7515
 
7268
- export { type AIPersona, APIError, AdminOnboarding, type AnswerFollowupBody, type AnswerOnboardingPayload, type AnswerOnboardingResponse, type ApplyCouponPayload, AuthenticationError, type BehaviorRules, type Broadcast, type CheckboxConfig, type CheckoutAmountBreakdown, type CheckoutOrderResponse, type CheckoutProduct, type CheckoutSession, type ColorRule, type ColumnConfig, type CompleteOnboardingPayload, type CompleteOnboardingResponse, type ConfidenceResponse, ConnectInfra, type Conversation, type ListParams as ConversationListParams, type Correction, type CreateBroadcastParams, type CreateLeadParams, type CreateNichePackPayload, type CreateOnboardingConfigPayload, type CreateOnboardingExperimentPayload, type CreateOrderPayload, type CreatePipelineParams, type CreateSessionPayload, type CrmView, type CurrencyConfig, type CurrencyValue, type CustomFieldFilter, type DateConfig, type DateTimeConfig, type DropdownConfig, ECODrIxAPI as ECODrIx, ECODrIxAPI, type ECODrIxAPIOptions, ERROR_RETRY_CONFIG, EcodrixError, type EditOnboardingPayload, type EditOnboardingResponse, type EmailConfig, EmailConnect, ErixChat, ErixProduct, type FieldConfig, type FieldDefinition, type FieldManifest, type FieldType, type FileConfig, type FilterOperator, type FilterRule, type ForkNichePackPayload, type FormulaConfig, type GlobalOnboardingPayload, HTTP_STATUS_ERROR_MAP, type ICP, InfraDomain, LEAD_STATUS_VALUES, type LayoutType, type Lead, type LeadPattern, type LeadSource, type LeadStatus, type LearningMemory, type ListLeadsParams, type ListNichePacksParams, type ListNichePacksResponse, type ListOnboardingConfigsParams, type ListOnboardingExperimentsParams, type ListOnboardingExperimentsResponse, type ManifestFieldType, type Message, type NichePack, type NichePackResearchConfig, type NichePackResponse, type NichePackStatus, type NichePackSummary, type NormalizedFieldValue, type NumberConfig, Onboarding, type OnboardingAbandonmentResponse, type OnboardingAbandonmentResult, type OnboardingAbandonmentRow, type OnboardingAnalyticsFiltersParams, type OnboardingCohortRange, type OnboardingConfig, type OnboardingExperiment, type OnboardingExperimentResponse, type OnboardingExperimentStatus, type OnboardingExperimentVariant, type OnboardingFunnelResponse, type OnboardingFunnelResult, type OnboardingFunnelStep, type OnboardingMemoryMapping, type OnboardingOption, type OnboardingSession, type OnboardingSessionStatus, type OnboardingStateResponse, type OnboardingStep, type OnboardingStepType, type OnboardingTimeOnStepResponse, type OnboardingTimeOnStepResult, type OnboardingTimeOnStepRow, type OutreachEdit, type PaginatedResponse, Persona, type PersonaFollowupQuestion, type PersonaFollowupsResponse, type PersonaIdentity, type PersonaTimelineEntry, type PersonaTimelineOptions, type PersonaTimelineResponse, type PhoneConfig, type Pipeline, type PipelineStage, type PipelineStageParams, PlatformAdmin, PlatformDomain, PlatformTenants, PlatformUsers, ProductDomain, type ProgressConfig, RateLimitError, type RatingConfig, type ReinforceResponse, type ReinforcementEvent, type RelationConfig, type RelationValue, type ResourceManifest, type SendMessageParams, type ServiceConfig, type ServiceConfigGlobal, type ServiceConfigPerProduct, type SmokeTestMaterializerAction, type SmokeTestNichePackPayload, type SmokeTestResult, type SortRule, type StartOnboardingPayload, type StartOnboardingResponse, StorageInfra, type StoredFieldValue, type SuggestionEvent, type TagsConfig, type Template, type TemplateComponent, type TemplateMapping, type TextConfig, type UpdateNichePackPayload, type UpdateOnboardingConfigPayload, type UpdateOnboardingExperimentPayload, type UpsertLeadParams, type UrlConfig, type VerifyPayload, type ViewConfig, type Vocabulary, WhatsAppConnect, type WorkspaceDashboardLayout, type WorkspaceDefaultAutomation, type WorkspaceDefaultField, type WorkspaceDefaultPipeline, type WorkspaceModuleConfig, type WorkspaceProfile, ECODrIxAPI as default, getErrorDetails, getRetryConfig, handleAPIError, isAPIError };
7516
+ export { type AIPersona, APIError, AdminOnboarding, type AnswerFollowupBody, type AnswerOnboardingPayload, type AnswerOnboardingResponse, type ApplyCouponPayload, AuthenticationError, type BehaviorRules, type Broadcast, type CheckboxConfig, type CheckoutAmountBreakdown, type CheckoutOrderResponse, type CheckoutProduct, type CheckoutSession, type ColorRule, type ColumnConfig, type CompleteOnboardingPayload, type CompleteOnboardingResponse, type ConfidenceResponse, ConnectInfra, type Conversation, type ListParams as ConversationListParams, type Correction, type CreateBroadcastParams, type CreateLeadParams, type CreateNichePackPayload, type CreateOnboardingConfigPayload, type CreateOnboardingExperimentPayload, type CreateOrderPayload, type CreatePipelineParams, type CreateSessionPayload, type CrmView, type CurrencyConfig, type CurrencyValue, type CustomFieldFilter, type DateConfig, type DateTimeConfig, type DropdownConfig, ECODrIxAPI as ECODrIx, ECODrIxAPI, type ECODrIxAPIOptions, ERROR_RETRY_CONFIG, EcodrixError, type EditOnboardingPayload, type EditOnboardingResponse, type EmailConfig, EmailConnect, ErixChat, ErixProduct, type FieldConfig, type FieldDefinition, type FieldManifest, type FieldType, type FileConfig, type FilterOperator, type FilterRule, type ForkNichePackPayload, type FormulaConfig, type GlobalOnboardingPayload, HTTP_STATUS_ERROR_MAP, type ICP, InfraDomain, LEAD_STATUS_VALUES, type LayoutType, type Lead, type LeadPattern, type LeadSource, type LeadStatus, type LearningMemory, type ListLeadsParams, type ListNichePacksParams, type ListNichePacksResponse, type ListOnboardingConfigsParams, type ListOnboardingExperimentsParams, type ListOnboardingExperimentsResponse, type ManifestFieldType, type MappingField, type MappingPreviewResult, type MappingSources, type MappingValidationResult, type Message, type NichePack, type NichePackResearchConfig, type NichePackResponse, type NichePackStatus, type NichePackSummary, type NormalizedFieldValue, type NumberConfig, Onboarding, type OnboardingAbandonmentResponse, type OnboardingAbandonmentResult, type OnboardingAbandonmentRow, type OnboardingAnalyticsFiltersParams, type OnboardingCohortRange, type OnboardingConfig, type OnboardingExperiment, type OnboardingExperimentResponse, type OnboardingExperimentStatus, type OnboardingExperimentVariant, type OnboardingFunnelResponse, type OnboardingFunnelResult, type OnboardingFunnelStep, type OnboardingMemoryMapping, type OnboardingOption, type OnboardingSession, type OnboardingSessionStatus, type OnboardingStateResponse, type OnboardingStep, type OnboardingStepType, type OnboardingTimeOnStepResponse, type OnboardingTimeOnStepResult, type OnboardingTimeOnStepRow, type OutreachEdit, type PaginatedResponse, Persona, type PersonaFollowupQuestion, type PersonaFollowupsResponse, type PersonaIdentity, type PersonaTimelineEntry, type PersonaTimelineOptions, type PersonaTimelineResponse, type PhoneConfig, type Pipeline, type PipelineStage, type PipelineStageParams, PlatformAdmin, PlatformDomain, PlatformTenants, PlatformUsers, ProductDomain, type ProgressConfig, RateLimitError, type RatingConfig, type ReinforceResponse, type ReinforcementEvent, type RelationConfig, type RelationValue, type ResourceManifest, type SendMessageParams, type ServiceConfig, type ServiceConfigGlobal, type ServiceConfigPerProduct, type SmokeTestMaterializerAction, type SmokeTestNichePackPayload, type SmokeTestResult, type SortRule, type StartOnboardingPayload, type StartOnboardingResponse, StorageInfra, type StoredFieldValue, type SuggestionEvent, type TagsConfig, type Template, type TemplateApiResponse, type TemplateBinding, type TemplateBindingSource, type TemplateComponent, type TemplateEmptyPolicy, type TemplateMapping, type TextConfig, type UpdateNichePackPayload, type UpdateOnboardingConfigPayload, type UpdateOnboardingExperimentPayload, type UpsertLeadParams, type UrlConfig, type VerifyPayload, type ViewConfig, type Vocabulary, WhatsAppConnect, type WorkspaceDashboardLayout, type WorkspaceDefaultAutomation, type WorkspaceDefaultField, type WorkspaceDefaultPipeline, type WorkspaceModuleConfig, type WorkspaceProfile, ECODrIxAPI as default, getErrorDetails, getRetryConfig, handleAPIError, isAPIError };