@elqnt/admin 2.0.5 → 2.2.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.
@@ -1,22 +1,2335 @@
1
- import { ResponseMetadata, CreditBalance, Plan, OrganizationBilling, UsageSummary } from '@elqnt/types';
2
- export { CreateCheckoutSessionRequest, CreateCheckoutSessionResponse, CreatePortalSessionRequest, CreatePortalSessionResponse, CreditBalance, CreditPackage, GetCreditsRequest, GetCreditsResponse, GetPlansRequest, GetPlansResponse, GetSubscriptionRequest, GetSubscriptionResponse, OrganizationBilling, Plan, PurchaseCreditsRequest, PurchaseCreditsResponse, UsagePeriod, UsageSummary } from '@elqnt/types';
1
+ import { ResponseMetadata } from '@elqnt/types';
3
2
  export { OrgSettings, OrgSettingsRequest, OrgSettingsResponse } from '@elqnt/agents/models';
4
3
 
4
+ interface Address {
5
+ line1: string;
6
+ line2: string;
7
+ city: string;
8
+ state: string;
9
+ country: string;
10
+ zip: string;
11
+ }
12
+ interface Org {
13
+ id?: string;
14
+ title: string;
15
+ logoUrl: string;
16
+ mainDomain: string;
17
+ address: Address;
18
+ apps: SystemAppTS[];
19
+ /**
20
+ * Status & Control
21
+ */
22
+ status: OrgStatusTS;
23
+ enabled: boolean;
24
+ /**
25
+ * Classification
26
+ */
27
+ product?: OrgProductTS;
28
+ type: OrgTypeTS;
29
+ size?: OrgSizeTS;
30
+ industry?: string;
31
+ tags?: string[];
32
+ /**
33
+ * Subscription (Stripe)
34
+ */
35
+ subscription?: OrgSubscription;
36
+ userCount: number;
37
+ /**
38
+ * Onboarding & Provisioning
39
+ */
40
+ onboarding?: OrgOnboarding;
41
+ provisioning?: OrgProvisioning;
42
+ /**
43
+ * Template & Roles
44
+ */
45
+ template?: OrgTemplate;
46
+ roles: string[];
47
+ /**
48
+ * Flexible metadata
49
+ */
50
+ metadata?: {
51
+ [key: string]: any;
52
+ };
53
+ /**
54
+ * Audit fields
55
+ */
56
+ createdAt?: number;
57
+ updatedAt?: number;
58
+ createdBy?: string;
59
+ updatedBy?: string;
60
+ }
61
+ type OrgStatus = string;
62
+ declare const OrgStatusActive: OrgStatus;
63
+ declare const OrgStatusSuspended: OrgStatus;
64
+ declare const OrgStatuses: {
65
+ readonly active: {
66
+ readonly value: "active";
67
+ readonly label: "Active";
68
+ };
69
+ readonly suspended: {
70
+ readonly value: "suspended";
71
+ readonly label: "Suspended";
72
+ };
73
+ };
74
+ type OrgStatusTS = keyof typeof OrgStatuses;
75
+ type OrgStatusOptionTS = typeof OrgStatuses[OrgStatusTS];
76
+ /**
77
+ * OrgType represents whether the org is self-serve or enterprise
78
+ */
79
+ type OrgType = string;
80
+ declare const OrgTypeSelfServe: OrgType;
81
+ declare const OrgTypeEnterprise: OrgType;
82
+ declare const OrgTypes: {
83
+ readonly "self-serve": {
84
+ readonly value: "self-serve";
85
+ readonly label: "Self-Serve";
86
+ };
87
+ readonly enterprise: {
88
+ readonly value: "enterprise";
89
+ readonly label: "Enterprise";
90
+ };
91
+ };
92
+ type OrgTypeTS = keyof typeof OrgTypes;
93
+ type OrgTypeOptionTS = typeof OrgTypes[OrgTypeTS];
94
+ /**
95
+ * OrgSize represents the size of the organization
96
+ */
97
+ type OrgSize = string;
98
+ declare const OrgSizeSolo: OrgSize;
99
+ declare const OrgSizeSmall: OrgSize;
100
+ declare const OrgSizeMedium: OrgSize;
101
+ declare const OrgSizeLarge: OrgSize;
102
+ declare const OrgSizeEnterprise: OrgSize;
103
+ declare const OrgSizes: {
104
+ readonly solo: {
105
+ readonly value: "solo";
106
+ readonly label: "Just me";
107
+ };
108
+ readonly small: {
109
+ readonly value: "small";
110
+ readonly label: "2-10";
111
+ };
112
+ readonly medium: {
113
+ readonly value: "medium";
114
+ readonly label: "11-50";
115
+ };
116
+ readonly large: {
117
+ readonly value: "large";
118
+ readonly label: "51-200";
119
+ };
120
+ readonly enterprise: {
121
+ readonly value: "enterprise";
122
+ readonly label: "200+";
123
+ };
124
+ };
125
+ type OrgSizeTS = keyof typeof OrgSizes;
126
+ type OrgSizeOptionTS = typeof OrgSizes[OrgSizeTS];
127
+ /**
128
+ * OrgProduct represents the product type for an organization
129
+ */
130
+ type OrgProduct = string;
131
+ declare const OrgProductEloquent: OrgProduct;
132
+ declare const OrgProductShopAssist: OrgProduct;
133
+ declare const OrgProductConsumer: OrgProduct;
134
+ declare const OrgProductCustom: OrgProduct;
135
+ declare const OrgProductAafya: OrgProduct;
136
+ declare const OrgProductFahim: OrgProduct;
137
+ declare const OrgProducts: {
138
+ readonly eloquent: {
139
+ readonly value: "eloquent";
140
+ readonly label: "Eloquent";
141
+ readonly description: "Full-featured enterprise AI platform with all capabilities";
142
+ };
143
+ readonly "shop-assist": {
144
+ readonly value: "shop-assist";
145
+ readonly label: "Shop Assist";
146
+ readonly description: "E-commerce focused AI assistant for online stores";
147
+ };
148
+ readonly consumer: {
149
+ readonly value: "consumer";
150
+ readonly label: "Consumer";
151
+ readonly description: "Consumer-facing AI applications";
152
+ };
153
+ readonly custom: {
154
+ readonly value: "custom";
155
+ readonly label: "Custom";
156
+ readonly description: "Custom configuration for specific requirements";
157
+ };
158
+ readonly aafya: {
159
+ readonly value: "aafya";
160
+ readonly label: "Aafya";
161
+ readonly description: "AI-powered healthcare triage and medical assistance platform";
162
+ };
163
+ readonly fahim: {
164
+ readonly value: "fahim";
165
+ readonly label: "Fahim فاهم";
166
+ readonly description: "AI-powered tutor for personalized learning across subjects";
167
+ };
168
+ };
169
+ type OrgProductTS = keyof typeof OrgProducts;
170
+ type OrgProductOptionTS = typeof OrgProducts[OrgProductTS];
171
+ /**
172
+ * OrgArtifactType represents the type of artifact to provision
173
+ */
174
+ type OrgArtifactType = string;
175
+ /**
176
+ * PostgreSQL schemas (3 databases)
177
+ */
178
+ declare const OrgArtifactPostgresEntities: OrgArtifactType;
179
+ declare const OrgArtifactPostgresAgents: OrgArtifactType;
180
+ declare const OrgArtifactPostgresOrgConfig: OrgArtifactType;
181
+ /**
182
+ * ClickHouse
183
+ */
184
+ declare const OrgArtifactClickHouseOrg: OrgArtifactType;
185
+ /**
186
+ * NATS
187
+ */
188
+ declare const OrgArtifactNATSChatBuckets: OrgArtifactType;
189
+ /**
190
+ * Entity definitions
191
+ */
192
+ declare const OrgArtifactEntityDefsEloquent: OrgArtifactType;
193
+ declare const OrgArtifactEntityDefsDocs: OrgArtifactType;
194
+ declare const OrgArtifactEntityDefsBoards: OrgArtifactType;
195
+ /**
196
+ * Settings
197
+ */
198
+ declare const OrgArtifactOrgSettings: OrgArtifactType;
199
+ /**
200
+ * Knowledge Graph
201
+ */
202
+ declare const OrgArtifactKnowledgeGraph: OrgArtifactType;
203
+ declare const OrgArtifactKGSchema: OrgArtifactType;
204
+ /**
205
+ * Agents
206
+ */
207
+ declare const OrgArtifactDefaultSkills: OrgArtifactType;
208
+ declare const OrgArtifactDefaultAgent: OrgArtifactType;
209
+ declare const OrgArtifactChatWidget: OrgArtifactType;
210
+ /**
211
+ * Default Resources
212
+ */
213
+ declare const OrgArtifactDefaultOrgLibrary: OrgArtifactType;
214
+ declare const OrgArtifactTypes: {
215
+ readonly postgres_entities: {
216
+ readonly value: "postgres_entities";
217
+ readonly label: "PostgreSQL Entities";
218
+ };
219
+ readonly postgres_agents: {
220
+ readonly value: "postgres_agents";
221
+ readonly label: "PostgreSQL Agents";
222
+ };
223
+ readonly postgres_org_config: {
224
+ readonly value: "postgres_org_config";
225
+ readonly label: "PostgreSQL Org Config";
226
+ };
227
+ readonly clickhouse_org: {
228
+ readonly value: "clickhouse_org";
229
+ readonly label: "ClickHouse Analytics";
230
+ };
231
+ readonly nats_chat_buckets: {
232
+ readonly value: "nats_chat_buckets";
233
+ readonly label: "NATS Chat Buckets";
234
+ };
235
+ readonly entity_defs_eloquent: {
236
+ readonly value: "entity_defs_eloquent";
237
+ readonly label: "Eloquent Entities";
238
+ };
239
+ readonly entity_defs_docs: {
240
+ readonly value: "entity_defs_docs";
241
+ readonly label: "Documents Entities";
242
+ };
243
+ readonly entity_defs_boards: {
244
+ readonly value: "entity_defs_boards";
245
+ readonly label: "Boards Entities";
246
+ };
247
+ readonly org_settings: {
248
+ readonly value: "org_settings";
249
+ readonly label: "Organization Settings";
250
+ };
251
+ readonly knowledge_graph: {
252
+ readonly value: "knowledge_graph";
253
+ readonly label: "Knowledge Graph";
254
+ };
255
+ readonly kg_schema: {
256
+ readonly value: "kg_schema";
257
+ readonly label: "KG Default Schema";
258
+ };
259
+ readonly default_skills: {
260
+ readonly value: "default_skills";
261
+ readonly label: "Default Skills";
262
+ };
263
+ readonly default_agent: {
264
+ readonly value: "default_agent";
265
+ readonly label: "Default Agent";
266
+ };
267
+ readonly chat_widget: {
268
+ readonly value: "chat_widget";
269
+ readonly label: "Chat Widget";
270
+ };
271
+ readonly default_org_library: {
272
+ readonly value: "default_org_library";
273
+ readonly label: "Org Documents Library";
274
+ };
275
+ };
276
+ type OrgArtifactTypeTS = keyof typeof OrgArtifactTypes;
277
+ type OrgArtifactTypeOptionTS = typeof OrgArtifactTypes[OrgArtifactTypeTS];
278
+ /**
279
+ * OrgArtifactStatus represents the status of an artifact
280
+ */
281
+ type OrgArtifactStatus = string;
282
+ declare const OrgArtifactStatusPending: OrgArtifactStatus;
283
+ declare const OrgArtifactStatusInProgress: OrgArtifactStatus;
284
+ declare const OrgArtifactStatusCompleted: OrgArtifactStatus;
285
+ declare const OrgArtifactStatusFailed: OrgArtifactStatus;
286
+ declare const OrgArtifactStatusSkipped: OrgArtifactStatus;
287
+ declare const OrgArtifactStatuses: {
288
+ readonly pending: {
289
+ readonly value: "pending";
290
+ readonly label: "Pending";
291
+ };
292
+ readonly in_progress: {
293
+ readonly value: "in_progress";
294
+ readonly label: "In Progress";
295
+ };
296
+ readonly completed: {
297
+ readonly value: "completed";
298
+ readonly label: "Completed";
299
+ };
300
+ readonly failed: {
301
+ readonly value: "failed";
302
+ readonly label: "Failed";
303
+ };
304
+ readonly skipped: {
305
+ readonly value: "skipped";
306
+ readonly label: "Skipped";
307
+ };
308
+ };
309
+ type OrgArtifactStatusTS = keyof typeof OrgArtifactStatuses;
310
+ type OrgArtifactStatusOptionTS = typeof OrgArtifactStatuses[OrgArtifactStatusTS];
311
+ /**
312
+ * OnboardingStatus represents the status of an onboarding flow
313
+ */
314
+ type OnboardingStatus = string;
315
+ declare const OnboardingStatusPending: OnboardingStatus;
316
+ declare const OnboardingStatusInProgress: OnboardingStatus;
317
+ declare const OnboardingStatusCompleted: OnboardingStatus;
318
+ declare const OnboardingStatusSkipped: OnboardingStatus;
319
+ declare const OnboardingStatusLegacy: OnboardingStatus;
320
+ declare const OnboardingStatuses: {
321
+ readonly pending: {
322
+ readonly value: "pending";
323
+ readonly label: "Pending";
324
+ };
325
+ readonly in_progress: {
326
+ readonly value: "in_progress";
327
+ readonly label: "In Progress";
328
+ };
329
+ readonly completed: {
330
+ readonly value: "completed";
331
+ readonly label: "Completed";
332
+ };
333
+ readonly skipped: {
334
+ readonly value: "skipped";
335
+ readonly label: "Skipped";
336
+ };
337
+ readonly legacy: {
338
+ readonly value: "legacy";
339
+ readonly label: "Legacy";
340
+ };
341
+ };
342
+ type OnboardingStatusTS = keyof typeof OnboardingStatuses;
343
+ type OnboardingStatusOptionTS = typeof OnboardingStatuses[OnboardingStatusTS];
344
+ /**
345
+ * ProvisioningStatus represents the status of resource provisioning
346
+ */
347
+ type ProvisioningStatus = string;
348
+ declare const ProvisioningStatusPending: ProvisioningStatus;
349
+ declare const ProvisioningStatusInProgress: ProvisioningStatus;
350
+ declare const ProvisioningStatusCompleted: ProvisioningStatus;
351
+ declare const ProvisioningStatusPartial: ProvisioningStatus;
352
+ declare const ProvisioningStatusFailed: ProvisioningStatus;
353
+ declare const ProvisioningStatuses: {
354
+ readonly pending: {
355
+ readonly value: "pending";
356
+ readonly label: "Pending";
357
+ };
358
+ readonly in_progress: {
359
+ readonly value: "in_progress";
360
+ readonly label: "In Progress";
361
+ };
362
+ readonly completed: {
363
+ readonly value: "completed";
364
+ readonly label: "Completed";
365
+ };
366
+ readonly partial: {
367
+ readonly value: "partial";
368
+ readonly label: "Partial";
369
+ };
370
+ readonly failed: {
371
+ readonly value: "failed";
372
+ readonly label: "Failed";
373
+ };
374
+ };
375
+ type ProvisioningStatusTS = keyof typeof ProvisioningStatuses;
376
+ type ProvisioningStatusOptionTS = typeof ProvisioningStatuses[ProvisioningStatusTS];
377
+ /**
378
+ * OrgOnboarding tracks the onboarding progress for an organization
379
+ */
380
+ interface OrgOnboarding {
381
+ status: OnboardingStatus;
382
+ currentStep: number;
383
+ completedAt?: number;
384
+ skippedSteps?: number[];
385
+ }
386
+ /**
387
+ * OrgArtifact represents a single provisioned artifact
388
+ */
389
+ interface OrgArtifact {
390
+ type: OrgArtifactTypeTS;
391
+ status: OrgArtifactStatusTS;
392
+ critical: boolean;
393
+ error?: string;
394
+ duration?: number;
395
+ estimatedDuration?: number;
396
+ startedAt?: number;
397
+ completedAt?: number;
398
+ metadata?: {
399
+ [key: string]: any;
400
+ };
401
+ }
402
+ /**
403
+ * OrgProvisioning tracks the provisioning status of org resources
404
+ */
405
+ interface OrgProvisioning {
406
+ status: ProvisioningStatusTS;
407
+ totalArtifacts: number;
408
+ completedArtifacts: number;
409
+ failedArtifacts: number;
410
+ artifacts?: OrgArtifact[];
411
+ startedAt?: number;
412
+ completedAt?: number;
413
+ /**
414
+ * Legacy fields for backwards compatibility
415
+ */
416
+ defaultAgentId?: string;
417
+ defaultKnowledgeGraphId?: string;
418
+ error?: string;
419
+ /**
420
+ * Metadata for passing data between provisioners (e.g., skill IDs)
421
+ */
422
+ metadata?: {
423
+ [key: string]: any;
424
+ };
425
+ }
426
+ /**
427
+ * OrgProvisioningProgress represents real-time progress for SSE
428
+ */
429
+ interface OrgProvisioningProgress {
430
+ orgId: string;
431
+ artifact?: OrgArtifactTypeTS;
432
+ status: OrgArtifactStatusTS;
433
+ error?: string;
434
+ progress: number;
435
+ totalArtifacts: number;
436
+ completedCount: number;
437
+ failedCount: number;
438
+ currentStep?: string;
439
+ elapsedMs: number;
440
+ estimatedMs?: number;
441
+ }
442
+ /**
443
+ * OrgProvisioningOptions allows customizing provisioning behavior
444
+ */
445
+ interface OrgProvisioningOptions {
446
+ skipArtifacts?: OrgArtifactTypeTS[];
447
+ onlyArtifacts?: OrgArtifactTypeTS[];
448
+ customArtifacts?: OrgArtifactTypeTS[];
449
+ skipKnowledgeGraph?: boolean;
450
+ skipDefaultAgent?: boolean;
451
+ }
452
+ interface OrgSubscription {
453
+ plan: string;
454
+ platform: SubscriptionPlatform;
455
+ status: OrgSubscriptionStatus;
456
+ trialEndsAt?: number;
457
+ currentPeriodEnd?: number;
458
+ seats?: number;
459
+ stripeCustomerId?: string;
460
+ stripeSubscriptionId?: string;
461
+ cancelledAt?: number;
462
+ cancelReason?: string;
463
+ gracePeriodEndsAt?: number;
464
+ }
465
+ type OrgSubscriptionStatus = string;
466
+ declare const OrgSubscriptionStatusTrialing: OrgSubscriptionStatus;
467
+ declare const OrgSubscriptionStatusActive: OrgSubscriptionStatus;
468
+ declare const OrgSubscriptionStatusPastDue: OrgSubscriptionStatus;
469
+ declare const OrgSubscriptionStatusCancelled: OrgSubscriptionStatus;
470
+ declare const OrgSubscriptionStatusUnpaid: OrgSubscriptionStatus;
471
+ declare const OrgSubscriptionStatuses: {
472
+ readonly trialing: {
473
+ readonly value: "trialing";
474
+ readonly label: "Trialing";
475
+ };
476
+ readonly active: {
477
+ readonly value: "active";
478
+ readonly label: "Active";
479
+ };
480
+ readonly past_due: {
481
+ readonly value: "past_due";
482
+ readonly label: "Past Due";
483
+ };
484
+ readonly cancelled: {
485
+ readonly value: "cancelled";
486
+ readonly label: "Cancelled";
487
+ };
488
+ readonly unpaid: {
489
+ readonly value: "unpaid";
490
+ readonly label: "Unpaid";
491
+ };
492
+ };
493
+ type OrgSubscriptionStatusTS = keyof typeof OrgSubscriptionStatuses;
494
+ type OrgSubscriptionStatusOptionTS = typeof OrgSubscriptionStatuses[OrgSubscriptionStatusTS];
495
+ interface OrgResponse {
496
+ org: Org;
497
+ metadata: ResponseMetadata;
498
+ }
499
+ interface OrgInfoResponse {
500
+ orgInfo: OrgInfo;
501
+ metadata: ResponseMetadata;
502
+ }
503
+ interface OrgRoleResponse {
504
+ role: OrgRole;
505
+ metadata: ResponseMetadata;
506
+ }
507
+ interface ListOrgsResponse {
508
+ orgs: Org[];
509
+ metadata: ResponseMetadata;
510
+ }
511
+ interface ListOrgRolesResponse {
512
+ roles: OrgRole[];
513
+ metadata: ResponseMetadata;
514
+ }
515
+ interface OrgInfo {
516
+ id?: string;
517
+ title: string;
518
+ logoUrl: string;
519
+ mainDomain?: string;
520
+ apps: SystemAppTS[];
521
+ }
522
+ interface AzureSettings {
523
+ appClientId?: string;
524
+ appClientSecret?: string;
525
+ azureTenantId?: string;
526
+ }
527
+ interface OrgTemplate {
528
+ id: string;
529
+ slug: string;
530
+ title: string;
531
+ }
532
+ interface UserOrgAccess {
533
+ orgId?: string;
534
+ orgTitle?: string;
535
+ roles: string[];
536
+ isSingleAccount: boolean;
537
+ entityRecordFilter?: {
538
+ entityName: string;
539
+ recordId: string;
540
+ displayValue?: string;
541
+ };
542
+ }
543
+ /**
544
+ * UserSettings represents user preferences (elastic JSON structure)
545
+ */
546
+ interface UserSettings {
547
+ theme?: string;
548
+ language?: string;
549
+ timezone?: string;
550
+ occupation?: string;
551
+ company?: string;
552
+ }
553
+ declare const ThemeOptions: {
554
+ readonly system: {
555
+ readonly value: "system";
556
+ readonly label: "System";
557
+ };
558
+ readonly light: {
559
+ readonly value: "light";
560
+ readonly label: "Light";
561
+ };
562
+ readonly dark: {
563
+ readonly value: "dark";
564
+ readonly label: "Dark";
565
+ };
566
+ };
567
+ type ThemeOptionTS = keyof typeof ThemeOptions;
568
+ /**
569
+ * NotificationPreferences represents user notification settings
570
+ */
571
+ interface NotificationPreferences {
572
+ pushEnabled: boolean;
573
+ newChatAssignment: boolean;
574
+ newMessages: boolean;
575
+ escalations: boolean;
576
+ urgentOnly: boolean;
577
+ soundEnabled: boolean;
578
+ doNotDisturb: boolean;
579
+ dndStart?: string;
580
+ dndEnd?: string;
581
+ }
582
+ /**
583
+ * UserSource represents how a user was created
584
+ */
585
+ type UserSource = string;
586
+ declare const UserSourceSignup: UserSource;
587
+ declare const UserSourceInvite: UserSource;
588
+ declare const UserSourceSSO: UserSource;
589
+ declare const UserSourceAPI: UserSource;
590
+ declare const UserSources: {
591
+ readonly signup: {
592
+ readonly value: "signup";
593
+ readonly label: "Signup";
594
+ };
595
+ readonly invite: {
596
+ readonly value: "invite";
597
+ readonly label: "Invite";
598
+ };
599
+ readonly sso: {
600
+ readonly value: "sso";
601
+ readonly label: "SSO";
602
+ };
603
+ readonly api: {
604
+ readonly value: "api";
605
+ readonly label: "API";
606
+ };
607
+ };
608
+ type UserSourceTS = keyof typeof UserSources;
609
+ type UserSourceOptionTS = typeof UserSources[UserSourceTS];
610
+ /**
611
+ * InviteStatus represents the status of an invitation
612
+ */
613
+ type InviteStatus = string;
614
+ declare const InviteStatusPending: InviteStatus;
615
+ declare const InviteStatusAccepted: InviteStatus;
616
+ declare const InviteStatusExpired: InviteStatus;
617
+ declare const InviteStatusRevoked: InviteStatus;
618
+ declare const InviteStatuses: {
619
+ readonly pending: {
620
+ readonly value: "pending";
621
+ readonly label: "Pending";
622
+ };
623
+ readonly accepted: {
624
+ readonly value: "accepted";
625
+ readonly label: "Accepted";
626
+ };
627
+ readonly expired: {
628
+ readonly value: "expired";
629
+ readonly label: "Expired";
630
+ };
631
+ readonly revoked: {
632
+ readonly value: "revoked";
633
+ readonly label: "Revoked";
634
+ };
635
+ };
636
+ type InviteStatusTS = keyof typeof InviteStatuses;
637
+ type InviteStatusOptionTS = typeof InviteStatuses[InviteStatusTS];
638
+ /**
639
+ * Invite represents a team/org invitation
640
+ */
641
+ interface Invite {
642
+ id?: string;
643
+ orgId: string;
644
+ email: string;
645
+ role: string;
646
+ invitedBy: string;
647
+ status: InviteStatusTS;
648
+ acceptedBy?: string;
649
+ acceptedAt?: number;
650
+ expiresAt?: number;
651
+ createdAt?: number;
652
+ updatedAt?: number;
653
+ }
654
+ interface InviteResponse {
655
+ invite: Invite;
656
+ metadata: ResponseMetadata;
657
+ }
658
+ interface ListInvitesResponse {
659
+ invites: Invite[];
660
+ metadata: ResponseMetadata;
661
+ }
662
+ /**
663
+ * UserOnboarding tracks the onboarding progress for a user
664
+ */
665
+ interface UserOnboarding {
666
+ status: OnboardingStatus;
667
+ completedAt?: number;
668
+ }
669
+ /**
670
+ * User represents a user in the system
671
+ */
672
+ interface User {
673
+ id?: string;
674
+ email: string;
675
+ firstName: string;
676
+ lastName: string;
677
+ authProviderName: string;
678
+ orgAccess?: UserOrgAccess[];
679
+ /**
680
+ * Status & Control
681
+ */
682
+ enabled?: boolean;
683
+ /**
684
+ * Source tracking
685
+ */
686
+ source?: UserSourceTS;
687
+ invitedBy?: string;
688
+ inviteStatus?: InviteStatusTS;
689
+ /**
690
+ * Team membership - LEGACY, DO NOT USE
691
+ * These fields are deprecated and will be removed.
692
+ * Use Org and OrgAccess patterns instead.
693
+ */
694
+ isTeamAdmin?: boolean;
695
+ teamId?: string;
696
+ teamName?: string;
697
+ /**
698
+ * System admin flag
699
+ */
700
+ isSysAdmin?: boolean;
701
+ /**
702
+ * Preferences
703
+ */
704
+ settings?: UserSettings;
705
+ notificationPreferences?: NotificationPreferences;
706
+ /**
707
+ * Onboarding tracking
708
+ */
709
+ onboarding?: UserOnboarding;
710
+ /**
711
+ * Flexible metadata
712
+ */
713
+ metadata?: {
714
+ [key: string]: any;
715
+ };
716
+ /**
717
+ * Audit fields
718
+ */
719
+ createdAt?: number;
720
+ updatedAt?: number;
721
+ createdBy?: string;
722
+ updatedBy?: string;
723
+ }
724
+ interface UserResponse {
725
+ user: User;
726
+ metadata: ResponseMetadata;
727
+ }
728
+ interface ListUsersResponse {
729
+ users: User[];
730
+ metadata: ResponseMetadata;
731
+ }
732
+ interface Team {
733
+ id?: string;
734
+ name: string;
735
+ isSubscribed: boolean;
736
+ subscribedAt?: number;
737
+ plan: string;
738
+ ownerName?: string;
739
+ ownerEmail?: string;
740
+ subscriptionPlatform?: SubscriptionPlatform;
741
+ subscriptionId?: string;
742
+ onboardingDone?: boolean;
743
+ onboardingData?: string;
744
+ }
745
+ type SubscriptionPlatform = string;
746
+ declare const SubscriptionPlatformStripe: SubscriptionPlatform;
747
+ declare const SubscriptionPlatformCustom: SubscriptionPlatform;
748
+ interface OrgRole {
749
+ id?: string;
750
+ orgId?: string;
751
+ title: string;
752
+ permissions: Permission[];
753
+ isSystem: boolean;
754
+ createdAt?: number;
755
+ updatedAt?: number;
756
+ createdBy?: string;
757
+ updatedBy?: string;
758
+ }
759
+ /**
760
+ * org db - copied from sys db
761
+ */
762
+ interface Permission {
763
+ /**
764
+ * ID *primitive.ObjectID `bson:"_id,omitempty" json:"id"`
765
+ */
766
+ name: string;
767
+ title: string;
768
+ isSystem: boolean;
769
+ }
770
+ type SystemApp = string;
771
+ declare const SystemAppAdmin: SystemApp;
772
+ declare const SystemAppCRM: SystemApp;
773
+ declare const SystemAppHelpdesk: SystemApp;
774
+ declare const SystemAppMarketing: SystemApp;
775
+ declare const SystemAppWorkflow: SystemApp;
776
+ declare const SystemAppAnalytics: SystemApp;
777
+ declare const SystemAppKnowledgeGraph: SystemApp;
778
+ declare const SystemAppDocumentProcessor: SystemApp;
779
+ declare const SystemApps: {
780
+ readonly admin: {
781
+ readonly value: "admin";
782
+ readonly label: "Admin";
783
+ };
784
+ readonly crm: {
785
+ readonly value: "crm";
786
+ readonly label: "CRM";
787
+ };
788
+ readonly helpdesk: {
789
+ readonly value: "helpdesk";
790
+ readonly label: "Helpdesk";
791
+ };
792
+ readonly marketing: {
793
+ readonly value: "marketing";
794
+ readonly label: "Marketing";
795
+ };
796
+ readonly workflow: {
797
+ readonly value: "workflow";
798
+ readonly label: "Workflow";
799
+ };
800
+ readonly analytics: {
801
+ readonly value: "analytics";
802
+ readonly label: "Analytics";
803
+ };
804
+ readonly "knowledge-graph": {
805
+ readonly value: "knowledge-graph";
806
+ readonly label: "Knowledge Graph";
807
+ };
808
+ readonly "document-processor": {
809
+ readonly value: "document-processor";
810
+ readonly label: "Document Processor";
811
+ };
812
+ };
813
+ type SystemAppTS = keyof typeof SystemApps;
814
+ type SystemAppOptionTS = typeof SystemApps[SystemAppTS];
815
+ /**
816
+ * UpdateUserSettingsRequest is the request payload for updating user settings
817
+ */
818
+ interface UpdateUserSettingsRequest {
819
+ id: string;
820
+ settings?: UserSettings;
821
+ notificationPreferences?: NotificationPreferences;
822
+ }
823
+ /**
824
+ * UserSettingsResponse is the response for settings operations
825
+ */
826
+ interface UserSettingsResponse {
827
+ settings?: UserSettings;
828
+ notificationPreferences?: NotificationPreferences;
829
+ metadata: ResponseMetadata;
830
+ }
831
+ /**
832
+ * OnboardingStep represents a step in the onboarding flow
833
+ */
834
+ interface OnboardingStep {
835
+ step: number;
836
+ name: string;
837
+ status: string;
838
+ required: boolean;
839
+ }
840
+ /**
841
+ * OnboardingState represents the current state of a user's onboarding
842
+ */
843
+ interface OnboardingState {
844
+ status: string;
845
+ currentStep: number;
846
+ steps: OnboardingStep[];
847
+ user?: User;
848
+ org?: Org;
849
+ }
850
+ /**
851
+ * OnboardingStateResponse is the response for onboarding status
852
+ */
853
+ interface OnboardingStateResponse {
854
+ state: OnboardingState;
855
+ metadata: ResponseMetadata;
856
+ }
857
+ /**
858
+ * OrgInput contains the input for creating an organization
859
+ */
860
+ interface OrgInput {
861
+ name: string;
862
+ industry?: string;
863
+ size: string;
864
+ stripeSessionId?: string;
865
+ }
866
+ /**
867
+ * OrgResult contains the result of organization creation
868
+ */
869
+ interface OrgResult {
870
+ org?: Org;
871
+ nextStep: string;
872
+ metadata: ResponseMetadata;
873
+ }
874
+ /**
875
+ * WorkspaceInput is an alias for OrgInput (deprecated)
876
+ */
877
+ type WorkspaceInput = OrgInput;
878
+ /**
879
+ * WorkspaceResult is an alias for OrgResult (deprecated)
880
+ */
881
+ type WorkspaceResult = OrgResult;
882
+ /**
883
+ * InviteInput contains the input for sending invites
884
+ */
885
+ interface InviteInput {
886
+ email: string;
887
+ role: string;
888
+ }
889
+ /**
890
+ * InvitesResult contains the result of sending invites
891
+ */
892
+ interface InvitesResult {
893
+ sent: InviteSentStatus[];
894
+ failed: string[];
895
+ nextStep: string;
896
+ metadata: ResponseMetadata;
897
+ }
898
+ /**
899
+ * InviteSentStatus represents status of a sent invite
900
+ */
901
+ interface InviteSentStatus {
902
+ email: string;
903
+ status: string;
904
+ }
905
+ /**
906
+ * KnowledgeInput contains the input for creating knowledge graph
907
+ */
908
+ interface KnowledgeInput {
909
+ name?: string;
910
+ skipUpload: boolean;
911
+ }
912
+ /**
913
+ * KnowledgeGraphInfo contains info about a knowledge graph
914
+ */
915
+ interface KnowledgeGraphInfo {
916
+ id: string;
917
+ name: string;
918
+ status: string;
919
+ documentCount: number;
920
+ }
921
+ /**
922
+ * KnowledgeResult contains the result of knowledge graph creation
923
+ */
924
+ interface KnowledgeResult {
925
+ knowledgeGraph: KnowledgeGraphInfo;
926
+ nextStep: string;
927
+ metadata: ResponseMetadata;
928
+ }
929
+ /**
930
+ * AgentInput contains the input for creating an agent
931
+ */
932
+ interface AgentInput {
933
+ name: string;
934
+ goal: string;
935
+ personality: string;
936
+ skills?: string[];
937
+ }
938
+ /**
939
+ * AgentInfo contains info about an agent
940
+ */
941
+ interface AgentInfo {
942
+ id: string;
943
+ name: string;
944
+ goal: string;
945
+ personality: string;
946
+ status: string;
947
+ knowledgeGraphId?: string;
948
+ }
949
+ /**
950
+ * AgentResult contains the result of agent creation
951
+ */
952
+ interface AgentResult {
953
+ agent: AgentInfo;
954
+ nextStep: string;
955
+ metadata: ResponseMetadata;
956
+ }
957
+ /**
958
+ * OnboardingCompleteResult contains the result of completing onboarding
959
+ */
960
+ interface OnboardingCompleteResult {
961
+ status: string;
962
+ completedAt: number;
963
+ org?: Org;
964
+ redirectUrl: string;
965
+ metadata: ResponseMetadata;
966
+ }
967
+ /**
968
+ * PaymentSessionInput contains input for creating a payment session
969
+ */
970
+ interface PaymentSessionInput {
971
+ plan: string;
972
+ billingCycle: string;
973
+ seats: number;
974
+ successUrl: string;
975
+ cancelUrl: string;
976
+ affiliateCode?: string;
977
+ }
978
+ /**
979
+ * PaymentSessionResult contains the result of creating a payment session
980
+ */
981
+ interface PaymentSessionResult {
982
+ url: string;
983
+ sessionId: string;
984
+ customerId: string;
985
+ metadata: ResponseMetadata;
986
+ }
987
+ /**
988
+ * OnboardingPlanInput contains subscription plan selection for provisioning
989
+ */
990
+ interface OnboardingPlanInput {
991
+ plan: string;
992
+ billingCycle: string;
993
+ seats: number;
994
+ stripeSessionId?: string;
995
+ }
996
+ /**
997
+ * OnboardingOrgInput contains organization data for provisioning
998
+ * Aligned with SeedOrgRequest structure
999
+ */
1000
+ interface OnboardingOrgInput {
1001
+ title: string;
1002
+ mainDomain: string;
1003
+ product?: OrgProduct;
1004
+ industry?: string;
1005
+ size?: string;
1006
+ }
1007
+ /**
1008
+ * OnboardingDocumentInput contains a document to be ingested during onboarding
1009
+ */
1010
+ interface OnboardingDocumentInput {
1011
+ title: string;
1012
+ fileUrl: string;
1013
+ }
1014
+ /**
1015
+ * OnboardingKnowledgeInput contains knowledge base configuration with optional documents
1016
+ */
1017
+ interface OnboardingKnowledgeInput {
1018
+ name: string;
1019
+ documents?: OnboardingDocumentInput[];
1020
+ }
1021
+ /**
1022
+ * OnboardingProvisionRequest contains all data collected during onboarding
1023
+ * to create org and provision all resources in one request
1024
+ */
1025
+ interface OnboardingProvisionRequest {
1026
+ plan: OnboardingPlanInput;
1027
+ org: OnboardingOrgInput;
1028
+ invites?: InviteInput[];
1029
+ knowledge: OnboardingKnowledgeInput;
1030
+ agent: AgentInput;
1031
+ }
1032
+ /**
1033
+ * OnboardingProvisionResponse is returned after starting provisioning
1034
+ */
1035
+ interface OnboardingProvisionResponse {
1036
+ orgId: string;
1037
+ userId: string;
1038
+ status: string;
1039
+ metadata: ResponseMetadata;
1040
+ }
1041
+ /**
1042
+ * CreateOrgRequest is the request payload for creating an organization with provisioning
1043
+ */
1044
+ interface CreateOrgRequest {
1045
+ title: string;
1046
+ mainDomain: string;
1047
+ product: OrgProductTS;
1048
+ type?: OrgTypeTS;
1049
+ size?: OrgSizeTS;
1050
+ industry?: string;
1051
+ logoUrl?: string;
1052
+ address?: Address;
1053
+ subscription?: OrgSubscription;
1054
+ provisioningOptions?: OrgProvisioningOptions;
1055
+ metadata?: {
1056
+ [key: string]: any;
1057
+ };
1058
+ }
1059
+ /**
1060
+ * RetryProvisioningRequest is the request for retrying failed artifacts
1061
+ */
1062
+ interface RetryProvisioningRequest {
1063
+ artifacts?: OrgArtifactTypeTS[];
1064
+ }
1065
+ /**
1066
+ * RetryProvisioningResponse is the response for retry operation
1067
+ */
1068
+ interface RetryProvisioningResponse {
1069
+ metadata: ResponseMetadata;
1070
+ }
1071
+ /**
1072
+ * OrgSchemaType represents a database schema type for bare schema provisioning.
1073
+ * Unlike OrgArtifactType, this only creates empty org_<uuid> schemas.
1074
+ */
1075
+ type OrgSchemaType = string;
1076
+ declare const SchemaTypeEntities: OrgSchemaType;
1077
+ declare const SchemaTypeAgents: OrgSchemaType;
1078
+ declare const SchemaTypeOrgConfig: OrgSchemaType;
1079
+ declare const OrgSchemaTypes: {
1080
+ readonly entities: {
1081
+ readonly value: "entities";
1082
+ readonly label: "Entities Database";
1083
+ };
1084
+ readonly agents: {
1085
+ readonly value: "agents";
1086
+ readonly label: "Agents Database";
1087
+ };
1088
+ readonly "org-config": {
1089
+ readonly value: "org-config";
1090
+ readonly label: "Org Config Database";
1091
+ };
1092
+ };
1093
+ type OrgSchemaTypeTS = keyof typeof OrgSchemaTypes;
1094
+ /**
1095
+ * CreateOrgWithSchemasRequest creates an org with bare database schemas
1096
+ */
1097
+ interface CreateOrgWithSchemasRequest {
1098
+ org: Org;
1099
+ schemas: OrgSchemaTypeTS[];
1100
+ }
1101
+ /**
1102
+ * CreateOrgWithSchemasResponse contains the result of creating an org with schemas
1103
+ */
1104
+ interface CreateOrgWithSchemasResponse {
1105
+ success: boolean;
1106
+ org: Org;
1107
+ createdSchemas: OrgSchemaTypeTS[];
1108
+ failedSchemas?: OrgSchemaTypeTS[];
1109
+ errors?: {
1110
+ [key: string]: string;
1111
+ };
1112
+ }
1113
+ declare const AdminOrgCreate = "admin.orgs.create";
1114
+ declare const AdminOrgList = "admin.orgs.list";
1115
+ declare const AdminOrgListByMetadata = "admin.orgs.listByMetadata";
1116
+ declare const AdminOrgGet = "admin.orgs.get";
1117
+ declare const AdminOrgGetInfo = "admin.orgs.getInfo";
1118
+ declare const AdminOrgGetByDomain = "admin.orgs.getByDomain";
1119
+ declare const AdminOrgUpdate = "admin.orgs.update";
1120
+ declare const AdminOrgDelete = "admin.orgs.delete";
1121
+ declare const AdminOrgCreated = "system.admin.org.created";
1122
+ declare const AdminOrgRolesGet = "admin.orgRoles.get";
1123
+ declare const AdminOrgRolesCreate = "admin.orgRoles.create";
1124
+ declare const AdminOrgRolesUpdate = "admin.orgRoles.update";
1125
+ declare const AdminOrgRolesDelete = "admin.orgRoles.delete";
1126
+ declare const AdminUsersGet = "admin.users.get";
1127
+ declare const AdminUsersGetForOrg = "admin.users.getUsersForOrg";
1128
+ declare const AdminUsersGetOne = "admin.users.getOne";
1129
+ declare const AdminUsersGetOneByEmail = "admin.users.getOneByEmail";
1130
+ declare const AdminUsersGetOneByPhone = "admin.users.getOneByPhone";
1131
+ declare const AdminUsersCreate = "admin.users.create";
1132
+ declare const AdminUsersUpdate = "admin.users.update";
1133
+ declare const AdminUsersDelete = "admin.users.delete";
1134
+ declare const AdminUsersUpdateSettings = "admin.users.updateSettings";
1135
+ declare const AdminUsersGetSettings = "admin.users.getSettings";
1136
+ declare const AdminTeamsCreate = "admin.teams.create";
1137
+ declare const AdminTeamsGetOne = "admin.teams.getOne";
1138
+ declare const AdminTeamsGetForOrg = "admin.teams.getTeamsForOrg";
1139
+ declare const AdminTeamsUpdateOnboarding = "admin.teams.updateOnboardingData";
1140
+
1141
+ /**
1142
+ * Billing event handlers
1143
+ */
1144
+ declare const BillingRecordEvent = "billing.events.record";
1145
+ /**
1146
+ * NATS Subject constants
1147
+ */
1148
+ declare const BillingGetUsageReport = "billing.usage.report";
1149
+ /**
1150
+ * NATS Subject constants
1151
+ */
1152
+ declare const BillingGetInvoice = "billing.invoice.get";
1153
+ /**
1154
+ * NATS Subject constants
1155
+ */
1156
+ declare const BillingProcessBillingPeriod = "billing.period.process";
1157
+ /**
1158
+ * Usage handlers
1159
+ */
1160
+ declare const UsageGetCurrentUsage = "billing.usage.current";
1161
+ /**
1162
+ * NATS Subject constants
1163
+ */
1164
+ declare const UsageGetUsageHistory = "billing.usage.history";
1165
+ /**
1166
+ * NATS Subject constants
1167
+ */
1168
+ declare const UsageGetCostBreakdown = "billing.usage.breakdown";
1169
+ /**
1170
+ * NATS Subject constants
1171
+ */
1172
+ declare const UsageGetTopCostCenters = "billing.usage.top_centers";
1173
+ /**
1174
+ * Rules handlers
1175
+ */
1176
+ declare const RulesGetBillingRules = "billing.rules.get";
1177
+ /**
1178
+ * NATS Subject constants
1179
+ */
1180
+ declare const RulesCreateBillingRule = "billing.rules.create";
1181
+ /**
1182
+ * NATS Subject constants
1183
+ */
1184
+ declare const RulesUpdateBillingRule = "billing.rules.update";
1185
+ /**
1186
+ * NATS Subject constants
1187
+ */
1188
+ declare const RulesDeleteBillingRule = "billing.rules.delete";
1189
+ interface BillingEvent {
1190
+ /**
1191
+ * Core identifiers
1192
+ */
1193
+ org_id: string;
1194
+ event_id: string;
1195
+ user_id: string;
1196
+ customer_id: string;
1197
+ /**
1198
+ * Event details
1199
+ */
1200
+ event_type: string;
1201
+ event_subtype: string;
1202
+ timestamp: string;
1203
+ /**
1204
+ * Billing metrics
1205
+ */
1206
+ billable_units: number;
1207
+ unit_type: string;
1208
+ cost_per_unit: number;
1209
+ total_cost: number;
1210
+ /**
1211
+ * Context
1212
+ */
1213
+ service_name: string;
1214
+ session_id: string;
1215
+ parent_event_id: string;
1216
+ /**
1217
+ * Resource consumption
1218
+ */
1219
+ input_tokens: number;
1220
+ output_tokens: number;
1221
+ processing_time_ms: number;
1222
+ /**
1223
+ * Product context
1224
+ */
1225
+ product_tier: string;
1226
+ feature_name: string;
1227
+ plan_id: string;
1228
+ /**
1229
+ * Metadata
1230
+ */
1231
+ metadata: {
1232
+ [key: string]: any;
1233
+ };
1234
+ created_by: string;
1235
+ }
1236
+ interface UsageReport {
1237
+ org_id: string;
1238
+ period_start: string;
1239
+ period_end: string;
1240
+ total_cost: number;
1241
+ currency: string;
1242
+ service_breakdowns: ServiceUsage[];
1243
+ generated_at: string;
1244
+ }
1245
+ interface ServiceUsage {
1246
+ service_name: string;
1247
+ event_type: string;
1248
+ unit_type: string;
1249
+ total_units: number;
1250
+ total_cost: number;
1251
+ total_events: number;
1252
+ unique_users: number;
1253
+ unique_sessions: number;
1254
+ total_input_tokens: number;
1255
+ total_output_tokens: number;
1256
+ total_processing_time: number;
1257
+ }
1258
+ interface BillingRule {
1259
+ rule_id: string;
1260
+ org_id: string;
1261
+ service_name: string;
1262
+ event_type: string;
1263
+ unit_type: string;
1264
+ /**
1265
+ * Tiered pricing
1266
+ */
1267
+ base_cost: number;
1268
+ tier_1_threshold: number;
1269
+ tier_1_cost: number;
1270
+ tier_2_threshold: number;
1271
+ tier_2_cost: number;
1272
+ tier_3_threshold: number;
1273
+ tier_3_cost: number;
1274
+ /**
1275
+ * Validity
1276
+ */
1277
+ effective_from: string;
1278
+ effective_to: string;
1279
+ is_active: boolean;
1280
+ created_at: string;
1281
+ updated_at: string;
1282
+ }
1283
+ interface BillingPeriod {
1284
+ period_id: string;
1285
+ org_id: string;
1286
+ period_start: string;
1287
+ period_end: string;
1288
+ status: string;
1289
+ billing_cycle: string;
1290
+ created_at: string;
1291
+ }
1292
+ interface Invoice {
1293
+ invoice_id: string;
1294
+ org_id: string;
1295
+ period_id: string;
1296
+ period_start: string;
1297
+ period_end: string;
1298
+ line_items: InvoiceLineItem[];
1299
+ subtotal_amount: number;
1300
+ tax_amount: number;
1301
+ total_amount: number;
1302
+ currency: string;
1303
+ status: string;
1304
+ generated_at: string;
1305
+ due_date: string;
1306
+ payment_method_id: string;
1307
+ }
1308
+ interface InvoiceLineItem {
1309
+ line_item_id: string;
1310
+ service_name: string;
1311
+ event_type: string;
1312
+ unit_type: string;
1313
+ description: string;
1314
+ quantity: number;
1315
+ unit_price: number;
1316
+ total_price: number;
1317
+ }
1318
+ interface BillingEventRequest {
1319
+ BillingEvent: BillingEvent;
1320
+ }
1321
+ interface BillingEventResponse {
1322
+ success: boolean;
1323
+ error?: string;
1324
+ }
1325
+ interface UsageReportRequest {
1326
+ org_id: string;
1327
+ period_start: string;
1328
+ period_end: string;
1329
+ }
1330
+ interface UsageReportResponse {
1331
+ success: boolean;
1332
+ data?: UsageReport;
1333
+ error?: string;
1334
+ }
1335
+ interface CurrentUsageRequest {
1336
+ org_id: string;
1337
+ service_name: string;
1338
+ event_type: string;
1339
+ }
1340
+ interface CurrentUsageResponse {
1341
+ success: boolean;
1342
+ data?: {
1343
+ [key: string]: any;
1344
+ };
1345
+ error?: string;
1346
+ }
1347
+ interface CostBreakdownRequest {
1348
+ org_id: string;
1349
+ period_start: string;
1350
+ period_end: string;
1351
+ group_by: string;
1352
+ }
1353
+ interface CostBreakdownResponse {
1354
+ success: boolean;
1355
+ data?: CostBreakdown[];
1356
+ error?: string;
1357
+ }
1358
+ interface CostBreakdown {
1359
+ group_value: string;
1360
+ total_cost: number;
1361
+ total_units: number;
1362
+ event_count: number;
1363
+ }
1364
+ interface BillingRuleRequest {
1365
+ BillingRule: BillingRule;
1366
+ }
1367
+ interface BillingRuleResponse {
1368
+ success: boolean;
1369
+ data?: BillingRule;
1370
+ error?: string;
1371
+ }
1372
+ interface BillingRulesRequest {
1373
+ org_id: string;
1374
+ service_name: string;
1375
+ event_type: string;
1376
+ }
1377
+ interface BillingRulesResponse {
1378
+ success: boolean;
1379
+ data?: (BillingRule | undefined)[];
1380
+ error?: string;
1381
+ }
1382
+ interface InvoiceRequest {
1383
+ org_id: string;
1384
+ period_id: string;
1385
+ invoice_id: string;
1386
+ }
1387
+ interface InvoiceResponse {
1388
+ success: boolean;
1389
+ data?: Invoice;
1390
+ error?: string;
1391
+ }
1392
+ interface BillingPeriodProcessRequest {
1393
+ org_id: string;
1394
+ period_id: string;
1395
+ }
1396
+ interface BillingPeriodProcessResponse {
1397
+ success: boolean;
1398
+ invoice_id?: string;
1399
+ error?: string;
1400
+ }
1401
+ interface UsageAggregation {
1402
+ org_id: string;
1403
+ period_id: string;
1404
+ date: string;
1405
+ hour: number;
1406
+ service_name: string;
1407
+ event_type: string;
1408
+ unit_type: string;
1409
+ total_units: number;
1410
+ total_events: number;
1411
+ total_cost: number;
1412
+ unique_users: number;
1413
+ unique_sessions: number;
1414
+ total_input_tokens: number;
1415
+ total_output_tokens: number;
1416
+ total_processing_time: number;
1417
+ created_at: string;
1418
+ }
1419
+ interface TopCostCenter {
1420
+ service_name: string;
1421
+ event_type: string;
1422
+ total_cost: number;
1423
+ total_units: number;
1424
+ event_count: number;
1425
+ percentage: number;
1426
+ }
1427
+ interface UsageHistory {
1428
+ date: string;
1429
+ total_cost: number;
1430
+ total_units: number;
1431
+ event_count: number;
1432
+ unique_users: number;
1433
+ }
1434
+ interface UserUsage {
1435
+ user_id: string;
1436
+ total_cost: number;
1437
+ total_units: number;
1438
+ event_count: number;
1439
+ last_activity: string;
1440
+ }
1441
+ /**
1442
+ * Usage trends and analytics models
1443
+ */
1444
+ interface UsageTrends {
1445
+ org_id: string;
1446
+ days: number;
1447
+ trend: string;
1448
+ direction: string;
1449
+ change_percent: number;
1450
+ recent_week_cost: number;
1451
+ previous_week_cost: number;
1452
+ }
1453
+ interface UsageAlert {
1454
+ type: string;
1455
+ severity: string;
1456
+ message: string;
1457
+ current_value: number;
1458
+ threshold_value: number;
1459
+ created_at: string;
1460
+ }
1461
+ /**
1462
+ * Cost preview models
1463
+ */
1464
+ interface CostPreview {
1465
+ units: number;
1466
+ total_cost: number;
1467
+ cost_per_unit: number;
1468
+ tier_breakdown: TierCost[];
1469
+ rule?: BillingRule;
1470
+ }
1471
+ interface TierCost {
1472
+ tier: string;
1473
+ units: number;
1474
+ rate: number;
1475
+ cost: number;
1476
+ }
1477
+ /**
1478
+ * Rule coverage models
1479
+ */
1480
+ interface RuleCoverage {
1481
+ org_id: string;
1482
+ total_services: number;
1483
+ covered_services: {
1484
+ [key: string]: boolean;
1485
+ };
1486
+ missing_rules: string[];
1487
+ rule_count: number;
1488
+ coverage_percentage: number;
1489
+ }
1490
+ /**
1491
+ * Generic Response
1492
+ */
1493
+ interface BillingResponse {
1494
+ success: boolean;
1495
+ data?: any;
1496
+ error?: string;
1497
+ }
1498
+ /**
1499
+ * Subscription management
1500
+ */
1501
+ declare const SubscriptionCreate = "billing.subscription.create";
1502
+ /**
1503
+ * NATS Subjects for Stripe/Subscription operations
1504
+ */
1505
+ declare const SubscriptionGet = "billing.subscription.get";
1506
+ /**
1507
+ * NATS Subjects for Stripe/Subscription operations
1508
+ */
1509
+ declare const SubscriptionUpdate = "billing.subscription.update";
1510
+ /**
1511
+ * NATS Subjects for Stripe/Subscription operations
1512
+ */
1513
+ declare const SubscriptionCancel = "billing.subscription.cancel";
1514
+ /**
1515
+ * NATS Subjects for Stripe/Subscription operations
1516
+ */
1517
+ declare const SubscriptionList = "billing.subscription.list";
1518
+ /**
1519
+ * NATS Subjects for Stripe/Subscription operations
1520
+ */
1521
+ declare const SubscriptionCheckout = "billing.subscription.checkout";
1522
+ /**
1523
+ * Payment links
1524
+ */
1525
+ declare const PaymentLinkCreate = "billing.payment-link.create";
1526
+ /**
1527
+ * NATS Subjects for Stripe/Subscription operations
1528
+ */
1529
+ declare const PaymentLinkList = "billing.payment-link.list";
1530
+ /**
1531
+ * Customer portal
1532
+ */
1533
+ declare const PortalSessionCreate = "billing.portal.create";
1534
+ /**
1535
+ * Customer management
1536
+ */
1537
+ declare const CustomerCreate = "billing.customer.create";
1538
+ /**
1539
+ * NATS Subjects for Stripe/Subscription operations
1540
+ */
1541
+ declare const CustomerGet = "billing.customer.get";
1542
+ /**
1543
+ * NATS Subjects for Stripe/Subscription operations
1544
+ */
1545
+ declare const CustomerUpdate = "billing.customer.update";
1546
+ /**
1547
+ * Credits
1548
+ */
1549
+ declare const CreditsBalance = "billing.credits.balance";
1550
+ /**
1551
+ * NATS Subjects for Stripe/Subscription operations
1552
+ */
1553
+ declare const CreditsPurchase = "billing.credits.purchase";
1554
+ /**
1555
+ * NATS Subjects for Stripe/Subscription operations
1556
+ */
1557
+ declare const CreditsConsume = "billing.credits.consume";
1558
+ /**
1559
+ * Plans
1560
+ */
1561
+ declare const PlansGet = "billing.plans.get";
1562
+ /**
1563
+ * NATS Subjects for Stripe/Subscription operations
1564
+ */
1565
+ declare const PlansGetAll = "billing.plans.list";
1566
+ /**
1567
+ * Usage alerts
1568
+ */
1569
+ declare const UsageAlertThreshold = "billing.usage.alert";
1570
+ /**
1571
+ * Webhooks (internal events)
1572
+ */
1573
+ declare const WebhookSubscriptionCreated = "billing.webhook.subscription.created";
1574
+ /**
1575
+ * NATS Subjects for Stripe/Subscription operations
1576
+ */
1577
+ declare const WebhookSubscriptionUpdated = "billing.webhook.subscription.updated";
1578
+ /**
1579
+ * NATS Subjects for Stripe/Subscription operations
1580
+ */
1581
+ declare const WebhookSubscriptionCanceled = "billing.webhook.subscription.canceled";
1582
+ /**
1583
+ * NATS Subjects for Stripe/Subscription operations
1584
+ */
1585
+ declare const WebhookInvoicePaid = "billing.webhook.invoice.paid";
1586
+ /**
1587
+ * NATS Subjects for Stripe/Subscription operations
1588
+ */
1589
+ declare const WebhookInvoiceFailed = "billing.webhook.invoice.failed";
1590
+ /**
1591
+ * NATS Subjects for Stripe/Subscription operations
1592
+ */
1593
+ declare const WebhookPaymentSucceeded = "billing.webhook.payment.succeeded";
1594
+ /**
1595
+ * Affiliates
1596
+ */
1597
+ declare const AffiliateCreate = "billing.affiliate.create";
1598
+ /**
1599
+ * NATS Subjects for Stripe/Subscription operations
1600
+ */
1601
+ declare const AffiliateGet = "billing.affiliate.get";
1602
+ /**
1603
+ * NATS Subjects for Stripe/Subscription operations
1604
+ */
1605
+ declare const AffiliateList = "billing.affiliate.list";
5
1606
  /**
6
- * Admin Models
1607
+ * NATS Subjects for Stripe/Subscription operations
1608
+ */
1609
+ declare const AffiliateUpdate = "billing.affiliate.update";
1610
+ /**
1611
+ * NATS Subjects for Stripe/Subscription operations
1612
+ */
1613
+ declare const AffiliateOnboard = "billing.affiliate.onboard";
1614
+ /**
1615
+ * NATS Subjects for Stripe/Subscription operations
1616
+ */
1617
+ declare const AffiliateCommissions = "billing.affiliate.commissions";
1618
+ /**
1619
+ * Analytics
1620
+ */
1621
+ declare const AnalyticsRevenue = "billing.analytics.revenue";
1622
+ /**
1623
+ * NATS Subjects for Stripe/Subscription operations
1624
+ */
1625
+ declare const AnalyticsUsage = "billing.analytics.usage";
1626
+ /**
1627
+ * NATS Subjects for Stripe/Subscription operations
1628
+ */
1629
+ declare const AnalyticsChurn = "billing.analytics.churn";
1630
+ /**
1631
+ * Plan represents a subscription plan
1632
+ */
1633
+ interface Plan {
1634
+ id: string;
1635
+ stripeProductId?: string;
1636
+ stripePriceId?: string;
1637
+ name: string;
1638
+ tier: string;
1639
+ priceCents: number;
1640
+ currency: string;
1641
+ billingInterval: string;
1642
+ chatSessionsLimit: number;
1643
+ tokenAllowance: number;
1644
+ agentsLimit: number;
1645
+ usersLimit: number;
1646
+ knowledgeGraphMb: number;
1647
+ tokenOverageRateCents: number;
1648
+ sessionOverageRateCents: number;
1649
+ features: {
1650
+ [key: string]: any;
1651
+ };
1652
+ isActive: boolean;
1653
+ createdAt: string;
1654
+ updatedAt: string;
1655
+ }
1656
+ /**
1657
+ * OrganizationBilling represents an organization's billing info
1658
+ */
1659
+ interface OrganizationBilling {
1660
+ orgId: string;
1661
+ stripeCustomerId?: string;
1662
+ stripeSubscriptionId?: string;
1663
+ planId?: string;
1664
+ plan?: Plan;
1665
+ status: string;
1666
+ currentPeriodStart?: string;
1667
+ currentPeriodEnd?: string;
1668
+ trialStart?: string;
1669
+ trialEnd?: string;
1670
+ billingEmail?: string;
1671
+ billingName?: string;
1672
+ affiliateCode?: string;
1673
+ createdAt: string;
1674
+ updatedAt: string;
1675
+ }
1676
+ /**
1677
+ * CreditBalance represents a credit balance entry
1678
+ */
1679
+ interface CreditBalance {
1680
+ id: string;
1681
+ orgId: string;
1682
+ creditType: string;
1683
+ amount: number;
1684
+ remaining: number;
1685
+ description?: string;
1686
+ expiresAt?: string;
1687
+ stripePaymentId?: string;
1688
+ createdAt: string;
1689
+ }
1690
+ /**
1691
+ * CreditPackage represents a purchasable credit package
1692
+ */
1693
+ interface CreditPackage {
1694
+ id: string;
1695
+ stripeProductId?: string;
1696
+ stripePriceId?: string;
1697
+ name: string;
1698
+ tokens: number;
1699
+ priceCents: number;
1700
+ currency: string;
1701
+ bonusTokens: number;
1702
+ isActive: boolean;
1703
+ createdAt: string;
1704
+ }
1705
+ /**
1706
+ * UsagePeriod represents usage within a billing period
1707
+ */
1708
+ interface UsagePeriod {
1709
+ id: string;
1710
+ orgId: string;
1711
+ periodStart: string;
1712
+ periodEnd: string;
1713
+ tokensUsed: number;
1714
+ sessionsUsed: number;
1715
+ tokensAllowance: number;
1716
+ sessionsAllowance: number;
1717
+ tokensOverage: number;
1718
+ sessionsOverage: number;
1719
+ overageChargedCents: number;
1720
+ status: string;
1721
+ stripeUsageRecordId?: string;
1722
+ createdAt: string;
1723
+ updatedAt: string;
1724
+ }
1725
+ /**
1726
+ * UsageSummary provides a summary of current usage
1727
+ */
1728
+ interface UsageSummary {
1729
+ orgId: string;
1730
+ planTier: string;
1731
+ billingPeriodStart: string;
1732
+ billingPeriodEnd: string;
1733
+ daysRemaining: number;
1734
+ /**
1735
+ * Token usage
1736
+ */
1737
+ tokensUsed: number;
1738
+ tokensAllowance: number;
1739
+ tokensPercentage: number;
1740
+ tokensRemaining: number;
1741
+ /**
1742
+ * Session usage
1743
+ */
1744
+ sessionsUsed: number;
1745
+ sessionsAllowance: number;
1746
+ sessionsPercentage: number;
1747
+ sessionsRemaining: number;
1748
+ /**
1749
+ * Credits
1750
+ */
1751
+ creditsRemaining: number;
1752
+ /**
1753
+ * Projected overage
1754
+ */
1755
+ projectedTokenOverage: number;
1756
+ projectedSessionOverage: number;
1757
+ projectedOverageCents: number;
1758
+ }
1759
+ /**
1760
+ * Affiliate represents an affiliate partner
1761
+ */
1762
+ interface Affiliate {
1763
+ id: string;
1764
+ name: string;
1765
+ email: string;
1766
+ stripeAccountId?: string;
1767
+ status: string;
1768
+ commissionRate: number;
1769
+ commissionType: string;
1770
+ referralCode: string;
1771
+ referralLink: string;
1772
+ totalEarningsCents: number;
1773
+ pendingPayoutCents: number;
1774
+ onboardingCompleted: boolean;
1775
+ onboardingCompletedAt?: string;
1776
+ country?: string;
1777
+ phone?: string;
1778
+ createdAt: string;
1779
+ updatedAt: string;
1780
+ }
1781
+ /**
1782
+ * AffiliateReferral represents a customer referred by an affiliate
1783
+ */
1784
+ interface AffiliateReferral {
1785
+ id: string;
1786
+ affiliateId: string;
1787
+ customerOrgId: string;
1788
+ stripeCustomerId?: string;
1789
+ status: string;
1790
+ firstPurchaseAt?: string;
1791
+ totalRevenueCents: number;
1792
+ totalCommissionCents: number;
1793
+ createdAt: string;
1794
+ updatedAt: string;
1795
+ }
1796
+ /**
1797
+ * AffiliateCommission represents a commission payment to an affiliate
1798
+ */
1799
+ interface AffiliateCommission {
1800
+ id: string;
1801
+ affiliateId: string;
1802
+ referralId: string;
1803
+ stripePaymentId?: string;
1804
+ stripeTransferId?: string;
1805
+ stripeInvoiceId?: string;
1806
+ grossAmountCents: number;
1807
+ commissionAmountCents: number;
1808
+ commissionRate: number;
1809
+ currency: string;
1810
+ status: string;
1811
+ createdAt: string;
1812
+ paidAt?: string;
1813
+ }
1814
+ /**
1815
+ * Payment represents a payment record
1816
+ */
1817
+ interface Payment {
1818
+ id: string;
1819
+ orgId: string;
1820
+ stripePaymentIntentId?: string;
1821
+ stripeInvoiceId?: string;
1822
+ stripeSubscriptionId?: string;
1823
+ amountCents: number;
1824
+ currency: string;
1825
+ status: string;
1826
+ paymentType: string;
1827
+ customerEmail?: string;
1828
+ paymentMethod?: string;
1829
+ description?: string;
1830
+ metadata?: {
1831
+ [key: string]: any;
1832
+ };
1833
+ createdAt: string;
1834
+ updatedAt: string;
1835
+ }
1836
+ /**
1837
+ * CreatePaymentLinkRequest is the request to create a payment link
1838
+ */
1839
+ interface CreatePaymentLinkRequest {
1840
+ orgId: string;
1841
+ priceId: string;
1842
+ successUrl: string;
1843
+ cancelUrl: string;
1844
+ customerEmail?: string;
1845
+ affiliateCode?: string;
1846
+ quantity?: number;
1847
+ metadata?: {
1848
+ [key: string]: string;
1849
+ };
1850
+ }
1851
+ /**
1852
+ * CreatePaymentLinkResponse is the response from creating a payment link
1853
+ */
1854
+ interface CreatePaymentLinkResponse {
1855
+ success: boolean;
1856
+ url?: string;
1857
+ paymentLinkId?: string;
1858
+ error?: string;
1859
+ }
1860
+ /**
1861
+ * CreatePortalSessionRequest is the request to create a billing portal session
1862
+ */
1863
+ interface CreatePortalSessionRequest {
1864
+ orgId: string;
1865
+ returnUrl: string;
1866
+ }
1867
+ /**
1868
+ * CreatePortalSessionResponse is the response from creating a portal session
1869
+ */
1870
+ interface CreatePortalSessionResponse {
1871
+ success: boolean;
1872
+ url?: string;
1873
+ error?: string;
1874
+ }
1875
+ /**
1876
+ * CreateCheckoutSessionRequest is the request to create a checkout session
1877
+ */
1878
+ interface CreateCheckoutSessionRequest {
1879
+ orgId: string;
1880
+ priceId: string;
1881
+ successUrl: string;
1882
+ cancelUrl: string;
1883
+ customerEmail?: string;
1884
+ affiliateCode?: string;
1885
+ trialDays?: number;
1886
+ metadata?: {
1887
+ [key: string]: string;
1888
+ };
1889
+ }
1890
+ /**
1891
+ * CreateCheckoutSessionResponse is the response from creating a checkout session
1892
+ */
1893
+ interface CreateCheckoutSessionResponse {
1894
+ success: boolean;
1895
+ sessionId?: string;
1896
+ url?: string;
1897
+ error?: string;
1898
+ }
1899
+ /**
1900
+ * GetSubscriptionRequest is the request to get subscription info
1901
+ */
1902
+ interface GetSubscriptionRequest {
1903
+ orgId: string;
1904
+ }
1905
+ /**
1906
+ * GetSubscriptionResponse is the response with subscription info
1907
+ */
1908
+ interface GetSubscriptionResponse {
1909
+ success: boolean;
1910
+ subscription?: OrganizationBilling;
1911
+ usage?: UsageSummary;
1912
+ error?: string;
1913
+ }
1914
+ /**
1915
+ * CancelSubscriptionRequest is the request to cancel a subscription
1916
+ */
1917
+ interface CancelSubscriptionRequest {
1918
+ orgId: string;
1919
+ cancelAtEnd: boolean;
1920
+ reason?: string;
1921
+ }
1922
+ /**
1923
+ * CancelSubscriptionResponse is the response from canceling a subscription
1924
+ */
1925
+ interface CancelSubscriptionResponse {
1926
+ success: boolean;
1927
+ cancelAt?: string;
1928
+ error?: string;
1929
+ }
1930
+ /**
1931
+ * GetCreditsRequest is the request to get credit balance
1932
+ */
1933
+ interface GetCreditsRequest {
1934
+ orgId: string;
1935
+ }
1936
+ /**
1937
+ * GetCreditsResponse is the response with credit balance
1938
+ */
1939
+ interface GetCreditsResponse {
1940
+ success: boolean;
1941
+ totalRemaining: number;
1942
+ balances?: (CreditBalance | undefined)[];
1943
+ error?: string;
1944
+ }
1945
+ /**
1946
+ * PurchaseCreditsRequest is the request to purchase credits
1947
+ */
1948
+ interface PurchaseCreditsRequest {
1949
+ orgId: string;
1950
+ packageId: string;
1951
+ successUrl: string;
1952
+ cancelUrl: string;
1953
+ }
1954
+ /**
1955
+ * PurchaseCreditsResponse is the response from purchasing credits
1956
+ */
1957
+ interface PurchaseCreditsResponse {
1958
+ success: boolean;
1959
+ sessionId?: string;
1960
+ url?: string;
1961
+ error?: string;
1962
+ }
1963
+ /**
1964
+ * ConsumeCreditsRequest is the request to consume credits
1965
+ */
1966
+ interface ConsumeCreditsRequest {
1967
+ orgId: string;
1968
+ amount: number;
1969
+ reason?: string;
1970
+ }
1971
+ /**
1972
+ * ConsumeCreditsResponse is the response from consuming credits
1973
+ */
1974
+ interface ConsumeCreditsResponse {
1975
+ success: boolean;
1976
+ consumed: number;
1977
+ remaining: number;
1978
+ error?: string;
1979
+ }
1980
+ /**
1981
+ * GetPlansRequest is the request to get available plans
1982
+ */
1983
+ interface GetPlansRequest {
1984
+ activeOnly: boolean;
1985
+ }
1986
+ /**
1987
+ * GetPlansResponse is the response with available plans
1988
+ */
1989
+ interface GetPlansResponse {
1990
+ success: boolean;
1991
+ plans?: (Plan | undefined)[];
1992
+ error?: string;
1993
+ }
1994
+ /**
1995
+ * CreateAffiliateRequest is the request to create an affiliate
1996
+ */
1997
+ interface CreateAffiliateRequest {
1998
+ name: string;
1999
+ email: string;
2000
+ country: string;
2001
+ commissionRate?: number;
2002
+ phone?: string;
2003
+ }
2004
+ /**
2005
+ * CreateAffiliateResponse is the response from creating an affiliate
2006
+ */
2007
+ interface CreateAffiliateResponse {
2008
+ success: boolean;
2009
+ affiliate?: Affiliate;
2010
+ error?: string;
2011
+ }
2012
+ /**
2013
+ * GetAffiliateRequest is the request to get an affiliate
2014
+ */
2015
+ interface GetAffiliateRequest {
2016
+ affiliateId?: string;
2017
+ referralCode?: string;
2018
+ }
2019
+ /**
2020
+ * GetAffiliateResponse is the response with affiliate info
2021
+ */
2022
+ interface GetAffiliateResponse {
2023
+ success: boolean;
2024
+ affiliate?: Affiliate;
2025
+ error?: string;
2026
+ }
2027
+ /**
2028
+ * ListAffiliatesRequest is the request to list affiliates
2029
+ */
2030
+ interface ListAffiliatesRequest {
2031
+ status?: string;
2032
+ page?: number;
2033
+ pageSize?: number;
2034
+ }
2035
+ /**
2036
+ * ListAffiliatesResponse is the response with affiliate list
2037
+ */
2038
+ interface ListAffiliatesResponse {
2039
+ success: boolean;
2040
+ affiliates?: (Affiliate | undefined)[];
2041
+ total: number;
2042
+ page: number;
2043
+ pageSize: number;
2044
+ error?: string;
2045
+ }
2046
+ /**
2047
+ * CreateAffiliateOnboardingLinkRequest is the request to create an onboarding link
2048
+ */
2049
+ interface CreateAffiliateOnboardingLinkRequest {
2050
+ affiliateId: string;
2051
+ refreshUrl: string;
2052
+ returnUrl: string;
2053
+ }
2054
+ /**
2055
+ * CreateAffiliateOnboardingLinkResponse is the response with onboarding link
2056
+ */
2057
+ interface CreateAffiliateOnboardingLinkResponse {
2058
+ success: boolean;
2059
+ url?: string;
2060
+ error?: string;
2061
+ }
2062
+ /**
2063
+ * GetAffiliateCommissionsRequest is the request to get affiliate commissions
2064
+ */
2065
+ interface GetAffiliateCommissionsRequest {
2066
+ affiliateId: string;
2067
+ startDate?: string;
2068
+ endDate?: string;
2069
+ status?: string;
2070
+ page?: number;
2071
+ pageSize?: number;
2072
+ }
2073
+ /**
2074
+ * GetAffiliateCommissionsResponse is the response with affiliate commissions
2075
+ */
2076
+ interface GetAffiliateCommissionsResponse {
2077
+ success: boolean;
2078
+ commissions?: (AffiliateCommission | undefined)[];
2079
+ total: number;
2080
+ totalAmount: number;
2081
+ page: number;
2082
+ pageSize: number;
2083
+ error?: string;
2084
+ }
2085
+ /**
2086
+ * GetAffiliateAnalyticsRequest is the request to get affiliate analytics
2087
+ */
2088
+ interface GetAffiliateAnalyticsRequest {
2089
+ affiliateId: string;
2090
+ period?: string;
2091
+ startDate?: string;
2092
+ endDate?: string;
2093
+ }
2094
+ /**
2095
+ * NATS Subjects for Stripe/Subscription operations
2096
+ */
2097
+ declare const AffiliateAnalytics = "billing.affiliate.analytics";
2098
+ /**
2099
+ * AffiliateAnalytics represents affiliate analytics data
2100
+ */
2101
+ interface AffiliateAnalytics {
2102
+ affiliateId: string;
2103
+ period: string;
2104
+ totalReferrals: number;
2105
+ activeReferrals: number;
2106
+ churnedReferrals: number;
2107
+ totalRevenueCents: number;
2108
+ totalCommissionsCents: number;
2109
+ conversionRate: number;
2110
+ avgCustomerLtvCents: number;
2111
+ }
2112
+ /**
2113
+ * GetAffiliateAnalyticsResponse is the response with affiliate analytics
2114
+ */
2115
+ interface GetAffiliateAnalyticsResponse {
2116
+ success: boolean;
2117
+ analytics?: AffiliateAnalytics;
2118
+ error?: string;
2119
+ }
2120
+ /**
2121
+ * RevenueAnalyticsRequest is the request to get revenue analytics
2122
+ */
2123
+ interface RevenueAnalyticsRequest {
2124
+ period?: string;
2125
+ startDate?: string;
2126
+ endDate?: string;
2127
+ }
2128
+ /**
2129
+ * RevenueAnalytics represents revenue analytics data
2130
+ */
2131
+ interface RevenueAnalytics {
2132
+ period: string;
2133
+ mrrCents: number;
2134
+ arrCents: number;
2135
+ newMrrCents: number;
2136
+ churnedMrrCents: number;
2137
+ expansionMrrCents: number;
2138
+ contractionMrrCents: number;
2139
+ netMrrCents: number;
2140
+ totalCustomers: number;
2141
+ newCustomers: number;
2142
+ churnedCustomers: number;
2143
+ churnRate: number;
2144
+ }
2145
+ /**
2146
+ * RevenueAnalyticsResponse is the response with revenue analytics
2147
+ */
2148
+ interface RevenueAnalyticsResponse {
2149
+ success: boolean;
2150
+ analytics?: RevenueAnalytics;
2151
+ error?: string;
2152
+ }
2153
+ /**
2154
+ * Webhook event types
2155
+ */
2156
+ interface StripeWebhookEvent {
2157
+ type: string;
2158
+ data: {
2159
+ [key: string]: any;
2160
+ };
2161
+ eventId: string;
2162
+ createdAt: string;
2163
+ }
2164
+ /**
2165
+ * Base subject prefix
2166
+ */
2167
+ declare const BillingSubjectPrefix = "billing";
2168
+ /**
2169
+ * Event recording subjects
2170
+ */
2171
+ declare const BillingEventsRecord = "billing.events.record";
2172
+ /**
2173
+ * Usage reporting subjects
2174
+ */
2175
+ declare const BillingUsageReport = "billing.usage.report";
2176
+ declare const BillingUsageCurrent = "billing.usage.current";
2177
+ declare const BillingUsageHistory = "billing.usage.history";
2178
+ declare const BillingUsageCostBreakdown = "billing.usage.breakdown";
2179
+ declare const BillingUsageTopCenters = "billing.usage.top_centers";
2180
+ /**
2181
+ * Invoice subjects
2182
+ */
2183
+ declare const BillingInvoiceGet = "billing.invoice.get";
2184
+ declare const BillingInvoiceCreate = "billing.invoice.create";
2185
+ declare const BillingInvoiceProcess = "billing.invoice.process";
2186
+ /**
2187
+ * Billing period subjects
2188
+ */
2189
+ declare const BillingPeriodCreate = "billing.period.create";
2190
+ declare const BillingPeriodClose = "billing.period.close";
2191
+ declare const BillingPeriodProcess = "billing.period.process";
2192
+ /**
2193
+ * Billing rules subjects
2194
+ */
2195
+ declare const BillingRulesGet = "billing.rules.get";
2196
+ declare const BillingRulesCreate = "billing.rules.create";
2197
+ declare const BillingRulesUpdate = "billing.rules.update";
2198
+ declare const BillingRulesDelete = "billing.rules.delete";
2199
+ /**
2200
+ * Organization provisioning
2201
+ */
2202
+ declare const BillingOrgProvision = "billing.org.provision";
2203
+ /**
2204
+ * Health check
2205
+ */
2206
+ declare const BillingHealthCheck = "billing.health.check";
2207
+
2208
+ /**
2209
+ * Product Analytics Models
7
2210
  *
8
- * Types for admin-related operations (onboarding, org-settings, billing)
9
- * Re-exports types from @elqnt/types for consistency.
2211
+ * Types for product analytics (chats, agents, usage, events).
10
2212
  */
11
2213
 
12
- interface OnboardingState {
13
- currentStep: string;
14
- completedSteps: string[];
15
- skippedSteps: string[];
2214
+ interface DateFilter {
2215
+ from?: string;
2216
+ to?: string;
2217
+ }
2218
+ interface AnalyticsSummary {
2219
+ total_chats: number;
2220
+ total_messages: number;
2221
+ total_tokens: number;
2222
+ total_cost: number;
2223
+ unique_users: number;
2224
+ avg_session_duration: number;
2225
+ }
2226
+ interface SummaryResponse {
2227
+ success: boolean;
2228
+ data: AnalyticsSummary;
2229
+ metadata?: ResponseMetadata;
2230
+ }
2231
+ interface ChatAnalytics {
2232
+ chat_id: string;
2233
+ agent_id: string;
2234
+ user_id: string;
2235
+ message_count: number;
2236
+ total_tokens: number;
2237
+ duration_secs: number;
2238
+ csat_score?: number;
2239
+ created_at: string;
2240
+ }
2241
+ interface ChatsResponse {
2242
+ success: boolean;
2243
+ data: ChatAnalytics[];
2244
+ total: number;
2245
+ metadata?: ResponseMetadata;
2246
+ }
2247
+ interface AgentAnalytics {
2248
+ agent_id: string;
2249
+ agent_name?: string;
2250
+ total_chats: number;
2251
+ total_messages: number;
2252
+ total_tokens: number;
2253
+ avg_duration_secs: number;
2254
+ unique_users: number;
2255
+ avg_csat?: number;
2256
+ }
2257
+ interface AgentsAnalyticsResponse {
2258
+ success: boolean;
2259
+ data: AgentAnalytics[];
2260
+ metadata?: ResponseMetadata;
2261
+ }
2262
+ interface UsageAnalytics {
2263
+ service: string;
2264
+ model: string;
2265
+ input_tokens: number;
2266
+ output_tokens: number;
2267
+ total_tokens: number;
2268
+ cost: number;
2269
+ request_count: number;
2270
+ }
2271
+ interface UsageResponse {
2272
+ success: boolean;
2273
+ data: UsageAnalytics[];
2274
+ metadata?: ResponseMetadata;
2275
+ }
2276
+ interface DailyAnalytics {
2277
+ date: string;
2278
+ total_chats: number;
2279
+ total_messages: number;
2280
+ total_tokens: number;
2281
+ unique_users: number;
2282
+ }
2283
+ interface DailyResponse {
2284
+ success: boolean;
2285
+ data: DailyAnalytics[];
2286
+ metadata?: ResponseMetadata;
2287
+ }
2288
+ interface AnalyticsEvent {
2289
+ eventId?: string;
16
2290
  orgId?: string;
17
- userId?: string;
18
- [key: string]: unknown;
2291
+ sessionId: string;
2292
+ userId: string;
2293
+ eventType: string;
2294
+ eventCategory: string;
2295
+ pagePath?: string;
2296
+ properties?: Record<string, unknown>;
2297
+ timestamp?: string;
2298
+ }
2299
+ interface EventsResponse {
2300
+ success: boolean;
2301
+ data: AnalyticsEvent[];
2302
+ metadata?: ResponseMetadata;
2303
+ }
2304
+ interface GlobalAnalyticsSummary {
2305
+ total_orgs: number;
2306
+ total_chats: number;
2307
+ total_messages: number;
2308
+ total_tokens: number;
2309
+ total_cost: number;
2310
+ total_users: number;
2311
+ }
2312
+ interface GlobalSummaryResponse {
2313
+ success: boolean;
2314
+ data: GlobalAnalyticsSummary;
2315
+ metadata?: ResponseMetadata;
2316
+ }
2317
+ interface OrgAnalytics {
2318
+ org_id: string;
2319
+ org_name: string;
2320
+ total_chats: number;
2321
+ total_messages: number;
2322
+ total_tokens: number;
2323
+ total_cost: number;
2324
+ unique_users: number;
19
2325
  }
2326
+ interface OrgAnalyticsResponse {
2327
+ success: boolean;
2328
+ data: OrgAnalytics[];
2329
+ total: number;
2330
+ metadata?: ResponseMetadata;
2331
+ }
2332
+
20
2333
  interface OnboardingResponse {
21
2334
  state: OnboardingState;
22
2335
  metadata: ResponseMetadata;
@@ -52,29 +2365,6 @@ interface PaymentSessionResponse {
52
2365
  url: string;
53
2366
  metadata: ResponseMetadata;
54
2367
  }
55
-
56
- interface ProvisionAgentsResponse {
57
- agentsCreated: number;
58
- subAgentsCreated: number;
59
- toolsCreated: number;
60
- skillsCreated: number;
61
- success: boolean;
62
- metadata: ResponseMetadata;
63
- }
64
- interface ProvisionEntitiesResponse {
65
- successCount: number;
66
- errorCount: number;
67
- errors: string[];
68
- success: boolean;
69
- metadata: ResponseMetadata;
70
- }
71
- interface ProvisionWorkflowsResponse {
72
- successCount: number;
73
- errorCount: number;
74
- errors: string[];
75
- success: boolean;
76
- metadata: ResponseMetadata;
77
- }
78
2368
  interface PlansResponse {
79
2369
  plans: Plan[];
80
2370
  metadata: ResponseMetadata;
@@ -98,5 +2388,27 @@ interface PortalSessionResponse {
98
2388
  url: string;
99
2389
  metadata: ResponseMetadata;
100
2390
  }
2391
+ interface ProvisionAgentsResponse {
2392
+ agentsCreated: number;
2393
+ subAgentsCreated: number;
2394
+ toolsCreated: number;
2395
+ skillsCreated: number;
2396
+ success: boolean;
2397
+ metadata: ResponseMetadata;
2398
+ }
2399
+ interface ProvisionEntitiesResponse {
2400
+ successCount: number;
2401
+ errorCount: number;
2402
+ errors: string[];
2403
+ success: boolean;
2404
+ metadata: ResponseMetadata;
2405
+ }
2406
+ interface ProvisionWorkflowsResponse {
2407
+ successCount: number;
2408
+ errorCount: number;
2409
+ errors: string[];
2410
+ success: boolean;
2411
+ metadata: ResponseMetadata;
2412
+ }
101
2413
 
102
- export type { CompleteOnboardingResponse, CreateAgentResponse, CreateCheckoutResponse, CreateKnowledgeResponse, CreateOrgResponse, CreditsResponse, OnboardingResponse, OnboardingState, PaymentSessionResponse, PlansResponse, PortalSessionResponse, ProvisionAgentsResponse, ProvisionEntitiesResponse, ProvisionWorkflowsResponse, SendInvitesResponse, SubscriptionResponse };
2414
+ export { type Address, AdminOrgCreate, AdminOrgCreated, AdminOrgDelete, AdminOrgGet, AdminOrgGetByDomain, AdminOrgGetInfo, AdminOrgList, AdminOrgListByMetadata, AdminOrgRolesCreate, AdminOrgRolesDelete, AdminOrgRolesGet, AdminOrgRolesUpdate, AdminOrgUpdate, AdminTeamsCreate, AdminTeamsGetForOrg, AdminTeamsGetOne, AdminTeamsUpdateOnboarding, AdminUsersCreate, AdminUsersDelete, AdminUsersGet, AdminUsersGetForOrg, AdminUsersGetOne, AdminUsersGetOneByEmail, AdminUsersGetOneByPhone, AdminUsersGetSettings, AdminUsersUpdate, AdminUsersUpdateSettings, type Affiliate, AffiliateAnalytics, type AffiliateCommission, AffiliateCommissions, AffiliateCreate, AffiliateGet, AffiliateList, AffiliateOnboard, type AffiliateReferral, AffiliateUpdate, type AgentAnalytics, type AgentInfo, type AgentInput, type AgentResult, type AgentsAnalyticsResponse, AnalyticsChurn, type AnalyticsEvent, AnalyticsRevenue, type AnalyticsSummary, AnalyticsUsage, type AzureSettings, type BillingEvent, type BillingEventRequest, type BillingEventResponse, BillingEventsRecord, BillingGetInvoice, BillingGetUsageReport, BillingHealthCheck, BillingInvoiceCreate, BillingInvoiceGet, BillingInvoiceProcess, BillingOrgProvision, type BillingPeriod, BillingPeriodClose, BillingPeriodCreate, BillingPeriodProcess, type BillingPeriodProcessRequest, type BillingPeriodProcessResponse, BillingProcessBillingPeriod, BillingRecordEvent, type BillingResponse, type BillingRule, type BillingRuleRequest, type BillingRuleResponse, BillingRulesCreate, BillingRulesDelete, BillingRulesGet, type BillingRulesRequest, type BillingRulesResponse, BillingRulesUpdate, BillingSubjectPrefix, BillingUsageCostBreakdown, BillingUsageCurrent, BillingUsageHistory, BillingUsageReport, BillingUsageTopCenters, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type ChatAnalytics, type ChatsResponse, type CompleteOnboardingResponse, type ConsumeCreditsRequest, type ConsumeCreditsResponse, type CostBreakdown, type CostBreakdownRequest, type CostBreakdownResponse, type CostPreview, type CreateAffiliateOnboardingLinkRequest, type CreateAffiliateOnboardingLinkResponse, type CreateAffiliateRequest, type CreateAffiliateResponse, type CreateAgentResponse, type CreateCheckoutResponse, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateKnowledgeResponse, type CreateOrgRequest, type CreateOrgResponse, type CreateOrgWithSchemasRequest, type CreateOrgWithSchemasResponse, type CreatePaymentLinkRequest, type CreatePaymentLinkResponse, type CreatePortalSessionRequest, type CreatePortalSessionResponse, type CreditBalance, type CreditPackage, CreditsBalance, CreditsConsume, CreditsPurchase, type CreditsResponse, type CurrentUsageRequest, type CurrentUsageResponse, CustomerCreate, CustomerGet, CustomerUpdate, type DailyAnalytics, type DailyResponse, type DateFilter, type EventsResponse, type GetAffiliateAnalyticsRequest, type GetAffiliateAnalyticsResponse, type GetAffiliateCommissionsRequest, type GetAffiliateCommissionsResponse, type GetAffiliateRequest, type GetAffiliateResponse, type GetCreditsRequest, type GetCreditsResponse, type GetPlansRequest, type GetPlansResponse, type GetSubscriptionRequest, type GetSubscriptionResponse, type GlobalAnalyticsSummary, type GlobalSummaryResponse, type Invite, type InviteInput, type InviteResponse, type InviteSentStatus, type InviteStatus, InviteStatusAccepted, InviteStatusExpired, type InviteStatusOptionTS, InviteStatusPending, InviteStatusRevoked, type InviteStatusTS, InviteStatuses, type InvitesResult, type Invoice, type InvoiceLineItem, type InvoiceRequest, type InvoiceResponse, type KnowledgeGraphInfo, type KnowledgeInput, type KnowledgeResult, type ListAffiliatesRequest, type ListAffiliatesResponse, type ListInvitesResponse, type ListOrgRolesResponse, type ListOrgsResponse, type ListUsersResponse, type NotificationPreferences, type OnboardingCompleteResult, type OnboardingDocumentInput, type OnboardingKnowledgeInput, type OnboardingOrgInput, type OnboardingPlanInput, type OnboardingProvisionRequest, type OnboardingProvisionResponse, type OnboardingResponse, type OnboardingState, type OnboardingStateResponse, type OnboardingStatus, OnboardingStatusCompleted, OnboardingStatusInProgress, OnboardingStatusLegacy, type OnboardingStatusOptionTS, OnboardingStatusPending, OnboardingStatusSkipped, type OnboardingStatusTS, OnboardingStatuses, type OnboardingStep, type Org, type OrgAnalytics, type OrgAnalyticsResponse, type OrgArtifact, OrgArtifactChatWidget, OrgArtifactClickHouseOrg, OrgArtifactDefaultAgent, OrgArtifactDefaultOrgLibrary, OrgArtifactDefaultSkills, OrgArtifactEntityDefsBoards, OrgArtifactEntityDefsDocs, OrgArtifactEntityDefsEloquent, OrgArtifactKGSchema, OrgArtifactKnowledgeGraph, OrgArtifactNATSChatBuckets, OrgArtifactOrgSettings, OrgArtifactPostgresAgents, OrgArtifactPostgresEntities, OrgArtifactPostgresOrgConfig, type OrgArtifactStatus, OrgArtifactStatusCompleted, OrgArtifactStatusFailed, OrgArtifactStatusInProgress, type OrgArtifactStatusOptionTS, OrgArtifactStatusPending, OrgArtifactStatusSkipped, type OrgArtifactStatusTS, OrgArtifactStatuses, type OrgArtifactType, type OrgArtifactTypeOptionTS, type OrgArtifactTypeTS, OrgArtifactTypes, type OrgInfo, type OrgInfoResponse, type OrgInput, type OrgOnboarding, type OrgProduct, OrgProductAafya, OrgProductConsumer, OrgProductCustom, OrgProductEloquent, OrgProductFahim, type OrgProductOptionTS, OrgProductShopAssist, type OrgProductTS, OrgProducts, type OrgProvisioning, type OrgProvisioningOptions, type OrgProvisioningProgress, type OrgResponse, type OrgResult, type OrgRole, type OrgRoleResponse, type OrgSchemaType, type OrgSchemaTypeTS, OrgSchemaTypes, type OrgSize, OrgSizeEnterprise, OrgSizeLarge, OrgSizeMedium, type OrgSizeOptionTS, OrgSizeSmall, OrgSizeSolo, type OrgSizeTS, OrgSizes, type OrgStatus, OrgStatusActive, type OrgStatusOptionTS, OrgStatusSuspended, type OrgStatusTS, OrgStatuses, type OrgSubscription, type OrgSubscriptionStatus, OrgSubscriptionStatusActive, OrgSubscriptionStatusCancelled, type OrgSubscriptionStatusOptionTS, OrgSubscriptionStatusPastDue, type OrgSubscriptionStatusTS, OrgSubscriptionStatusTrialing, OrgSubscriptionStatusUnpaid, OrgSubscriptionStatuses, type OrgTemplate, type OrgType, OrgTypeEnterprise, type OrgTypeOptionTS, OrgTypeSelfServe, type OrgTypeTS, OrgTypes, type OrganizationBilling, type Payment, PaymentLinkCreate, PaymentLinkList, type PaymentSessionInput, type PaymentSessionResponse, type PaymentSessionResult, type Permission, type Plan, PlansGet, PlansGetAll, type PlansResponse, PortalSessionCreate, type PortalSessionResponse, type ProvisionAgentsResponse, type ProvisionEntitiesResponse, type ProvisionWorkflowsResponse, type ProvisioningStatus, ProvisioningStatusCompleted, ProvisioningStatusFailed, ProvisioningStatusInProgress, type ProvisioningStatusOptionTS, ProvisioningStatusPartial, ProvisioningStatusPending, type ProvisioningStatusTS, ProvisioningStatuses, type PurchaseCreditsRequest, type PurchaseCreditsResponse, type RetryProvisioningRequest, type RetryProvisioningResponse, type RevenueAnalytics, type RevenueAnalyticsRequest, type RevenueAnalyticsResponse, type RuleCoverage, RulesCreateBillingRule, RulesDeleteBillingRule, RulesGetBillingRules, RulesUpdateBillingRule, SchemaTypeAgents, SchemaTypeEntities, SchemaTypeOrgConfig, type SendInvitesResponse, type ServiceUsage, type StripeWebhookEvent, SubscriptionCancel, SubscriptionCheckout, SubscriptionCreate, SubscriptionGet, SubscriptionList, type SubscriptionPlatform, SubscriptionPlatformCustom, SubscriptionPlatformStripe, type SubscriptionResponse, SubscriptionUpdate, type SummaryResponse, type SystemApp, SystemAppAdmin, SystemAppAnalytics, SystemAppCRM, SystemAppDocumentProcessor, SystemAppHelpdesk, SystemAppKnowledgeGraph, SystemAppMarketing, type SystemAppOptionTS, type SystemAppTS, SystemAppWorkflow, SystemApps, type Team, type ThemeOptionTS, ThemeOptions, type TierCost, type TopCostCenter, type UpdateUserSettingsRequest, type UsageAggregation, type UsageAlert, UsageAlertThreshold, type UsageAnalytics, UsageGetCostBreakdown, UsageGetCurrentUsage, UsageGetTopCostCenters, UsageGetUsageHistory, type UsageHistory, type UsagePeriod, type UsageReport, type UsageReportRequest, type UsageReportResponse, type UsageResponse, type UsageSummary, type UsageTrends, type User, type UserOnboarding, type UserOrgAccess, type UserResponse, type UserSettings, type UserSettingsResponse, type UserSource, UserSourceAPI, UserSourceInvite, type UserSourceOptionTS, UserSourceSSO, UserSourceSignup, type UserSourceTS, UserSources, type UserUsage, WebhookInvoiceFailed, WebhookInvoicePaid, WebhookPaymentSucceeded, WebhookSubscriptionCanceled, WebhookSubscriptionCreated, WebhookSubscriptionUpdated, type WorkspaceInput, type WorkspaceResult };