@cemscale-voip/voip-sdk 1.25.0 → 1.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts DELETED
@@ -1,965 +0,0 @@
1
- export interface LoginParams {
2
- username: string;
3
- password: string;
4
- tenantId: string;
5
- }
6
- export interface AdminLoginParams {
7
- email: string;
8
- password: string;
9
- }
10
- export interface AuthResponse {
11
- token: string;
12
- user?: {
13
- id: string;
14
- extension: string;
15
- displayName: string | null;
16
- tenantId: string;
17
- };
18
- tenant?: {
19
- id: string;
20
- subdomain: string;
21
- companyName: string;
22
- };
23
- }
24
- export interface TurnCredentials {
25
- urls: string[];
26
- username: string;
27
- credential: string;
28
- ttl: number;
29
- }
30
- export interface CallRecord {
31
- id: string;
32
- tenant_id?: string;
33
- call_uuid: string;
34
- direction: 'inbound' | 'outbound' | 'internal';
35
- caller_id_name: string | null;
36
- caller_id_number: string | null;
37
- destination: string | null;
38
- status: string | null;
39
- hangup_cause: string | null;
40
- duration_seconds: number | null;
41
- billsec: number | null;
42
- recording_url: string | null;
43
- /** Direct URL to stream the recording audio. Append `?apiKey=...` for browser playback. Null if no recording. */
44
- audio_url: string | null;
45
- started_at: string | null;
46
- answered_at: string | null;
47
- ended_at: string | null;
48
- metadata?: Record<string, unknown> | null;
49
- /** Present when queried as global superadmin */
50
- tenants?: TenantInfo;
51
- /** Present when queried as global superadmin (convenience top-level fields) */
52
- company_name?: string;
53
- subdomain?: string;
54
- }
55
- export interface PaginationInfo {
56
- page: number;
57
- limit: number;
58
- total: number;
59
- pages: number;
60
- }
61
- export interface CallListResponse {
62
- calls: CallRecord[];
63
- pagination: PaginationInfo;
64
- }
65
- export interface CallListParams {
66
- page?: number;
67
- /** Max 500 per page */
68
- limit?: number;
69
- direction?: 'inbound' | 'outbound' | 'internal' | 'all';
70
- /** Filter by call status */
71
- status?: 'completed' | 'failed' | 'all';
72
- /** ISO date string — calls started on or after this date */
73
- dateFrom?: string;
74
- /** ISO date string — calls started on or before this date */
75
- dateTo?: string;
76
- /** Filter by extension number (matches caller or destination) */
77
- extension?: string;
78
- /** Search by phone number or name (matches caller_id_number, destination, caller_id_name) */
79
- number?: string;
80
- /** Filter by tenant ID (superadmin only — alternative to X-Tenant-ID header) */
81
- tenantId?: string;
82
- }
83
- export interface OriginateParams {
84
- fromExtension: string;
85
- toNumber: string;
86
- }
87
- export interface OriginateResponse {
88
- message: string;
89
- callUuid: string;
90
- }
91
- export interface TransferParams {
92
- targetExtension: string;
93
- type?: 'blind' | 'attended';
94
- }
95
- export interface ActiveCall {
96
- call_uuid: string;
97
- caller_id_name: string;
98
- caller_id_number: string;
99
- destination: string;
100
- direction: string;
101
- status: string;
102
- started_at: string;
103
- answered: boolean;
104
- on_hold: boolean;
105
- }
106
- export interface CallStats {
107
- stats: {
108
- total: number;
109
- inbound: number;
110
- outbound: number;
111
- internal: number;
112
- period: string;
113
- };
114
- }
115
- export interface Extension {
116
- id: string;
117
- tenant_id?: string;
118
- extension: string;
119
- display_name: string | null;
120
- voicemail_enabled: boolean;
121
- voicemail_pin?: string | null;
122
- voicemail_greeting_type?: VoicemailGreetingType | null;
123
- voicemail_greeting_text?: string | null;
124
- voicemail_greeting_audio_path?: string | null;
125
- do_not_disturb: boolean;
126
- outbound_caller_id?: string | null;
127
- status: string;
128
- created_at: string;
129
- call_forward_enabled?: boolean;
130
- call_forward_number?: string | null;
131
- call_forward_type?: string | null;
132
- crm_user_id?: string | null;
133
- crm_metadata?: Record<string, unknown> | null;
134
- /** Present when queried as global superadmin */
135
- tenants?: TenantInfo;
136
- }
137
- export interface CreateExtensionParams {
138
- extension: string;
139
- password: string;
140
- displayName: string;
141
- voicemailEnabled?: boolean;
142
- /** 4-6 digit PIN required to check voicemail via *97. If not set, voicemail has no PIN protection. */
143
- voicemailPin?: string;
144
- doNotDisturb?: boolean;
145
- /**
146
- * Outbound caller ID for this extension. Must be an active DID that belongs
147
- * to the same tenant (created via `createDid()`). The API validates this and
148
- * returns a 400 with `availableDids[]` if the number is not a valid tenant DID.
149
- * Set to `null` to clear (calls will fall back to the tenant's first active DID).
150
- *
151
- * @example "+17868392727"
152
- */
153
- outboundCallerId?: string | null;
154
- }
155
- export interface UpdateExtensionParams {
156
- displayName?: string;
157
- password?: string;
158
- voicemailEnabled?: boolean;
159
- /** 4-6 digit PIN for voicemail access. Set to null to remove PIN protection. */
160
- voicemailPin?: string | null;
161
- doNotDisturb?: boolean;
162
- status?: 'active' | 'disabled';
163
- /**
164
- * Outbound caller ID for this extension. Must be an active DID that belongs
165
- * to the same tenant. The API validates this and returns a 400 with
166
- * `availableDids[]` if the number is not a valid tenant DID.
167
- * Set to `null` to clear (calls will fall back to the tenant's first active DID).
168
- */
169
- outboundCallerId?: string | null;
170
- crmUserId?: string | null;
171
- crmMetadata?: Record<string, unknown> | null;
172
- }
173
- export interface Tenant {
174
- id: string;
175
- subdomain: string;
176
- company_name: string;
177
- sip_domain: string;
178
- admin_email?: string | null;
179
- timezone?: string | null;
180
- /** Whether call recording is enabled for this tenant. When enabled, all inbound, outbound, and internal calls are recorded. */
181
- recording_enabled?: boolean;
182
- status: string;
183
- created_at: string;
184
- /** Present on getTenant() — counts of related resources */
185
- _count?: {
186
- extensions: number;
187
- did_numbers: number;
188
- };
189
- }
190
- export interface CreateTenantParams {
191
- subdomain: string;
192
- companyName: string;
193
- /** Optional contact email for the tenant admin. Not used for authentication. */
194
- adminEmail?: string;
195
- /** IANA timezone (e.g. "America/New_York"). Defaults to "America/New_York" if not provided. */
196
- timezone?: string;
197
- /** Enable call recording for this tenant. When enabled, all inbound, outbound, and internal calls are recorded. Default: false. */
198
- recordingEnabled?: boolean;
199
- }
200
- export interface UpdateTenantParams {
201
- companyName?: string;
202
- status?: 'active' | 'suspended' | 'cancelled';
203
- /** IANA timezone (e.g. "America/New_York") */
204
- timezone?: string;
205
- /** Enable or disable call recording for this tenant */
206
- recordingEnabled?: boolean;
207
- }
208
- export interface DidNumber {
209
- id: string;
210
- tenant_id: string;
211
- number: string;
212
- carrier: string;
213
- inbound_route: string;
214
- route_target: string;
215
- status: string;
216
- created_at: string;
217
- /** Present when queried as global superadmin */
218
- tenants?: TenantInfo;
219
- }
220
- export interface CreateDidParams {
221
- number: string;
222
- carrier?: 'twilio' | 'telnyx' | 'other';
223
- inboundRoute?: 'extension' | 'ivr' | 'queue' | 'ringgroup' | 'external' | 'voicemail';
224
- /**
225
- * The target for inbound call routing. What this value represents depends on `inboundRoute`:
226
- * - `extension`: the extension number (e.g. `"1001"`)
227
- * - `ivr`: the IVR menu UUID or name (API resolves name to UUID automatically)
228
- * - `queue`: the queue UUID or name (API resolves name to UUID automatically)
229
- * - `ringgroup`: the ring group UUID or name (API resolves name to UUID automatically)
230
- * - `external`: an external phone number
231
- * - `voicemail`: the extension number whose voicemail to use (e.g. `"1001"`)
232
- *
233
- * The API validates that the target exists for the tenant.
234
- */
235
- routeTarget: string;
236
- }
237
- export interface UpdateDidParams {
238
- inboundRoute?: 'extension' | 'ivr' | 'queue' | 'ringgroup' | 'external' | 'voicemail';
239
- routeTarget?: string;
240
- status?: 'active' | 'inactive';
241
- }
242
- export type IvrGreetingType = 'audio' | 'tts' | 'text';
243
- export type IvrAction = 'transfer' | 'ivr' | 'voicemail' | 'hangup' | 'queue' | 'external' | 'ringgroup';
244
- export type IvrTimeoutAction = 'hangup' | 'transfer' | 'voicemail' | 'queue' | 'ivr' | 'external' | 'ringgroup' | 'repeat';
245
- export interface IvrOption {
246
- id: string;
247
- digit: string;
248
- action: string;
249
- target: string;
250
- description?: string | null;
251
- }
252
- export interface IvrMenu {
253
- id: string;
254
- tenant_id?: string;
255
- name: string;
256
- greeting_text: string | null;
257
- greeting_type: IvrGreetingType | null;
258
- greeting_audio_url: string | null;
259
- timeout: number;
260
- max_retries: number;
261
- timeout_action: string | null;
262
- timeout_target: string | null;
263
- invalid_input_audio_url: string | null;
264
- tts_voice: string | null;
265
- status: string | null;
266
- created_at: string;
267
- ivr_options: IvrOption[];
268
- /** Present when queried as global superadmin */
269
- tenants?: TenantInfo;
270
- }
271
- export interface CreateIvrParams {
272
- name: string;
273
- /** Text for the greeting. Used with greetingType 'text' or as source text for TTS. */
274
- greetingText?: string;
275
- /** How the greeting is played: 'audio' (uploaded file), 'tts' (ElevenLabs), 'text' (generic FS prompts). Default: 'text'. */
276
- greetingType?: IvrGreetingType;
277
- /** Seconds to wait for caller to press a digit (1-30, default 5) */
278
- timeout?: number;
279
- /** How many times to replay the greeting on invalid/no input (1-10, default 3) */
280
- maxRetries?: number;
281
- /** What to do when max retries are exhausted. Default: 'hangup'. */
282
- timeoutAction?: IvrTimeoutAction;
283
- /** Target for the timeout action (extension number, IVR ID, queue ID, etc.) */
284
- timeoutTarget?: string;
285
- /** ElevenLabs voice name for TTS (default: 'Rachel'). Use GET /api/ivr/voices for available voices. */
286
- ttsVoice?: string;
287
- /** Whether this IVR is active or disabled. Default: 'active'. */
288
- status?: 'active' | 'disabled';
289
- /** DTMF options — what happens when the caller presses each digit */
290
- options: Array<{
291
- /** Single digit: 0-9, *, # */
292
- digit: string;
293
- /** Action to execute */
294
- action: IvrAction;
295
- /** Target for the action (extension number, IVR UUID, queue UUID, phone number, etc.) */
296
- target: string;
297
- /** Human-readable description of what this option does */
298
- description?: string;
299
- }>;
300
- }
301
- export interface UpdateIvrParams {
302
- name?: string;
303
- greetingText?: string;
304
- greetingType?: IvrGreetingType;
305
- timeout?: number;
306
- maxRetries?: number;
307
- timeoutAction?: IvrTimeoutAction;
308
- timeoutTarget?: string | null;
309
- ttsVoice?: string;
310
- status?: 'active' | 'disabled';
311
- options?: Array<{
312
- digit: string;
313
- action: IvrAction;
314
- target: string;
315
- description?: string;
316
- }>;
317
- }
318
- export interface IvrTtsParams {
319
- /** Text to convert to speech */
320
- text: string;
321
- /** ElevenLabs voice name (default: 'Rachel') */
322
- voice?: string;
323
- }
324
- export interface IvrVoice {
325
- id: string;
326
- name: string;
327
- description: string;
328
- language: string;
329
- }
330
- export interface Recording {
331
- id: string;
332
- tenant_id?: string;
333
- call_uuid: string;
334
- caller_id_name: string;
335
- caller_id_number: string;
336
- destination: string;
337
- direction: string;
338
- duration_seconds: number;
339
- recording_url: string;
340
- /** Direct URL to stream the audio (MP3). Use with <audio src="..."> or fetch(). Requires auth via ?apiKey= query param or X-API-Key header. */
341
- audio_url: string;
342
- started_at: string;
343
- ended_at: string;
344
- /** Present when queried as global superadmin */
345
- tenants?: TenantInfo;
346
- }
347
- export interface RecordingUrlResponse {
348
- /** Direct URL to the audio file */
349
- url: string;
350
- /** Audio format: 'mp3' or 'wav' */
351
- format: string;
352
- /** No expiration for local files */
353
- expiresIn: number | null;
354
- }
355
- export interface RecordingListParams {
356
- page?: number;
357
- limit?: number;
358
- dateFrom?: string;
359
- dateTo?: string;
360
- /** Filter by direction */
361
- direction?: 'inbound' | 'outbound';
362
- }
363
- export interface RecordingListResponse {
364
- recordings: Recording[];
365
- pagination: PaginationInfo;
366
- }
367
- export type PresenceStatus = 'available' | 'registered' | 'on_call' | 'busy' | 'ringing' | 'dnd' | 'idle' | 'offline';
368
- export interface PresenceMap {
369
- [extension: string]: PresenceStatus | string;
370
- }
371
- export interface WsAuthMessage {
372
- type: 'auth';
373
- token: string;
374
- }
375
- export interface WsAuthSuccess {
376
- type: 'auth_success';
377
- tenantId: string;
378
- }
379
- export interface WsPresenceSnapshot {
380
- type: 'presence_snapshot';
381
- /** Detailed presence map: extension → { status, callUuid?, caller?, direction?, since? } */
382
- data: PresenceDetailMap;
383
- }
384
- export interface WsPresenceChange {
385
- type: 'presence_change';
386
- tenantId: string;
387
- extension: string;
388
- status: PresenceStatus;
389
- callUuid?: string;
390
- }
391
- export interface WsCallStart {
392
- type: 'call_start';
393
- tenantId: string;
394
- callUuid: string;
395
- caller: string;
396
- destination: string;
397
- direction: string;
398
- }
399
- export interface WsCallAnswer {
400
- type: 'call_answer';
401
- tenantId: string;
402
- callUuid: string;
403
- }
404
- export interface WsCallEnd {
405
- type: 'call_end';
406
- tenantId: string;
407
- callUuid: string;
408
- caller: string;
409
- destination: string;
410
- duration: number;
411
- hangupCause: string;
412
- }
413
- export type WsMessage = WsAuthSuccess | WsPresenceSnapshot | WsPresenceChange | WsCallStart | WsCallAnswer | WsCallEnd | {
414
- type: 'pong';
415
- } | {
416
- type: 'error';
417
- message: string;
418
- } | {
419
- type: 'auth_error';
420
- message: string;
421
- };
422
- export type WebRTCCallState = 'idle' | 'connecting' | 'ringing' | 'established' | 'held' | 'terminating' | 'terminated';
423
- export interface WebRTCConfig {
424
- sipDomain: string;
425
- wsUri: string;
426
- extension: string;
427
- password: string;
428
- displayName?: string;
429
- turnServers?: RTCIceServer[];
430
- audioElement?: HTMLAudioElement;
431
- /** Auto-answer incoming calls */
432
- autoAnswer?: boolean;
433
- }
434
- export interface WebRTCCallInfo {
435
- id: string;
436
- direction: 'inbound' | 'outbound';
437
- remoteIdentity: string;
438
- remoteDisplayName: string;
439
- state: WebRTCCallState;
440
- startTime: Date | null;
441
- answerTime: Date | null;
442
- held: boolean;
443
- muted: boolean;
444
- dtmfSent: string;
445
- }
446
- export interface WebRTCEventMap {
447
- registered: () => void;
448
- unregistered: () => void;
449
- registrationFailed: (error: Error) => void;
450
- incomingCall: (call: WebRTCCallInfo) => void;
451
- callStateChanged: (call: WebRTCCallInfo) => void;
452
- callEnded: (call: WebRTCCallInfo) => void;
453
- /** Hold re-INVITE was accepted by the server */
454
- holdSucceeded: (held: boolean) => void;
455
- /** Hold re-INVITE was rejected or failed */
456
- holdFailed: (error: Error) => void;
457
- /** REFER/transfer progress notification from server */
458
- transferProgress: (info: {
459
- state: 'trying' | 'accepted' | 'rejected';
460
- message: string;
461
- }) => void;
462
- error: (error: Error) => void;
463
- }
464
- export interface ConferenceMember {
465
- id: string;
466
- uuid: string;
467
- callerIdName: string;
468
- callerIdNumber: string;
469
- muted: boolean;
470
- deaf: boolean;
471
- joinTime: string;
472
- }
473
- export interface Conference {
474
- name: string;
475
- memberCount: number;
476
- locked: boolean;
477
- runTime: string;
478
- members: ConferenceMember[];
479
- }
480
- export interface RingGroupMember {
481
- id: string;
482
- extension: string;
483
- priority: number;
484
- delay_seconds: number;
485
- }
486
- export interface RingGroup {
487
- id: string;
488
- tenant_id?: string;
489
- name: string;
490
- strategy: string;
491
- ring_timeout: number;
492
- no_answer_action: string;
493
- no_answer_target: string | null;
494
- status: string;
495
- created_at: string;
496
- members: RingGroupMember[];
497
- /** Present when queried as global superadmin */
498
- tenant?: TenantInfo;
499
- }
500
- export interface CreateRingGroupParams {
501
- name: string;
502
- strategy?: 'simultaneous' | 'sequential' | 'random';
503
- ringTimeout?: number;
504
- noAnswerAction?: 'voicemail' | 'ivr' | 'extension' | 'hangup';
505
- noAnswerTarget?: string;
506
- members: Array<{
507
- extension: string;
508
- priority?: number;
509
- delaySeconds?: number;
510
- }>;
511
- }
512
- export interface QueueAgent {
513
- id: string;
514
- extension: string;
515
- priority: number;
516
- penalty: number;
517
- status: string;
518
- }
519
- export interface CallQueue {
520
- id: string;
521
- tenant_id?: string;
522
- name: string;
523
- strategy: string;
524
- moh_sound: string;
525
- announce_sound: string | null;
526
- announce_frequency: number;
527
- max_wait_time: number;
528
- max_callers: number;
529
- ring_timeout: number;
530
- wrap_up_time: number;
531
- no_agent_action: string;
532
- no_agent_target: string | null;
533
- timeout_action: string;
534
- timeout_target: string | null;
535
- status: string;
536
- created_at: string;
537
- agents: QueueAgent[];
538
- /** Present when queried as global superadmin */
539
- tenant?: TenantInfo;
540
- }
541
- export interface CreateQueueParams {
542
- name: string;
543
- strategy?: 'round-robin' | 'longest-idle' | 'ring-all' | 'least-calls' | 'random';
544
- mohSound?: string;
545
- announceSound?: string;
546
- announceFrequency?: number;
547
- maxWaitTime?: number;
548
- maxCallers?: number;
549
- ringTimeout?: number;
550
- wrapUpTime?: number;
551
- noAgentAction?: 'voicemail' | 'ivr' | 'extension' | 'hangup';
552
- noAgentTarget?: string;
553
- timeoutAction?: 'voicemail' | 'ivr' | 'extension' | 'hangup';
554
- timeoutTarget?: string;
555
- agents: Array<{
556
- extension: string;
557
- priority?: number;
558
- penalty?: number;
559
- }>;
560
- }
561
- export interface Webhook {
562
- id: string;
563
- name: string;
564
- url: string;
565
- events: string[];
566
- active: boolean;
567
- hasSecret: boolean;
568
- headers: Record<string, string> | null;
569
- maxRetries?: number;
570
- retryDelaySeconds?: number;
571
- createdAt: string;
572
- /** Present when queried as global superadmin */
573
- tenant?: TenantInfo;
574
- }
575
- export interface WebhookDelivery {
576
- id: string;
577
- eventType: string;
578
- payload?: Record<string, unknown>;
579
- responseStatus: number | null;
580
- responseBody?: string | null;
581
- attempt: number;
582
- success: boolean;
583
- error: string | null;
584
- deliveredAt: string;
585
- }
586
- export interface CreateWebhookParams {
587
- name: string;
588
- url: string;
589
- events: string[];
590
- secret?: string;
591
- headers?: Record<string, string>;
592
- maxRetries?: number;
593
- retryDelaySeconds?: number;
594
- }
595
- /** Greeting types for voicemail */
596
- export type VoicemailGreetingType = 'default' | 'name' | 'custom_audio' | 'custom_tts';
597
- export interface VoicemailMessage {
598
- id: string;
599
- tenant_id: string;
600
- extension: string;
601
- caller_id: string;
602
- caller_name: string | null;
603
- duration_seconds: number;
604
- is_read: boolean;
605
- is_urgent: boolean;
606
- created_at: string;
607
- read_at: string | null;
608
- /** Direct URL to stream this voicemail's audio. Append `?apiKey=...` for browser playback. */
609
- audio_url: string;
610
- /** Present when queried as global superadmin */
611
- company_name?: string;
612
- subdomain?: string;
613
- }
614
- export interface VoicemailListParams {
615
- page?: number;
616
- limit?: number;
617
- unreadOnly?: boolean;
618
- extension?: string;
619
- }
620
- export interface VoicemailListResponse {
621
- messages: VoicemailMessage[];
622
- unread: number;
623
- pagination: PaginationInfo;
624
- }
625
- export interface VoicemailCountResponse {
626
- total: number;
627
- unread: number;
628
- extension: string;
629
- }
630
- export interface VoicemailGreeting {
631
- extension: string;
632
- display_name: string | null;
633
- voicemail_enabled: boolean;
634
- voicemail_pin: string | null;
635
- greeting: {
636
- type: VoicemailGreetingType;
637
- text: string | null;
638
- has_custom_audio: boolean;
639
- /** URL to stream the custom greeting audio. Append `?apiKey=...` for browser playback. Null if no custom audio. */
640
- audio_url: string | null;
641
- };
642
- }
643
- export interface UpdateGreetingParams {
644
- extension?: string;
645
- /**
646
- * Greeting type:
647
- * - `default`: Standard "Extension 1001 is not available, leave a message"
648
- * - `name`: "[Display Name] is not available. Please leave a message after the tone."
649
- * - `custom_audio`: Plays an uploaded audio file (upload via `uploadVoicemailGreetingAudio()`)
650
- * - `custom_tts`: Speaks the `greetingText` using text-to-speech
651
- */
652
- greetingType: VoicemailGreetingType;
653
- /** Text to speak when greetingType is 'custom_tts'. Max 500 characters. */
654
- greetingText?: string;
655
- }
656
- export interface CallForwardParams {
657
- enabled: boolean;
658
- number?: string;
659
- type?: 'always' | 'busy' | 'no-answer';
660
- }
661
- export interface CallForwardResponse {
662
- extension: string;
663
- callForward: {
664
- enabled: boolean;
665
- number: string | null;
666
- type: string;
667
- };
668
- }
669
- export interface ParkedCall {
670
- slot: string;
671
- caller_id_number: string;
672
- destination: string;
673
- started_at: string;
674
- }
675
- export interface PresenceDetail {
676
- status: string;
677
- callUuid?: string;
678
- caller?: string;
679
- direction?: string;
680
- since?: string;
681
- /** Present when queried as global superadmin */
682
- tenant_id?: string;
683
- /** Present when queried as global superadmin */
684
- tenant_name?: string;
685
- /** Present when queried as global superadmin */
686
- subdomain?: string;
687
- /** Present when queried as global superadmin (the extension number, since the map key may be `tenant_uuid:ext`) */
688
- extension?: string;
689
- }
690
- export type PresenceDetailMap = Record<string, PresenceDetail>;
691
- export interface DashboardStats {
692
- dashboard: {
693
- extensions: number;
694
- dids: number;
695
- callsToday: number;
696
- callsThisMonth: number;
697
- };
698
- }
699
- export interface DayStats {
700
- total: number;
701
- inbound: number;
702
- outbound: number;
703
- internal: number;
704
- totalDuration: number;
705
- }
706
- export interface CallsByDayResponse {
707
- callsByDay: Record<string, DayStats>;
708
- }
709
- export interface TopExtension {
710
- extension: string;
711
- totalCalls: number;
712
- totalDuration: number;
713
- }
714
- export interface TopExtensionsResponse {
715
- topExtensions: TopExtension[];
716
- }
717
- export interface BlockedNumber {
718
- id: string;
719
- tenant_id: string;
720
- number: string;
721
- reason: string | null;
722
- direction: string | null;
723
- created_at: string | null;
724
- /** Present when queried as global superadmin */
725
- tenants?: TenantInfo;
726
- }
727
- export interface CreateBlockedNumberParams {
728
- number: string;
729
- reason?: string;
730
- direction?: 'inbound' | 'outbound' | 'both';
731
- }
732
- export interface BlocklistCheckResponse {
733
- blocked: boolean;
734
- entry: BlockedNumber | null;
735
- }
736
- export interface DaySchedule {
737
- day: 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
738
- enabled: boolean;
739
- startTime?: string;
740
- endTime?: string;
741
- }
742
- export interface Holiday {
743
- date: string;
744
- name?: string;
745
- }
746
- export interface BusinessSchedule {
747
- id: string;
748
- tenant_id: string;
749
- name: string;
750
- /** Present when queried as global superadmin */
751
- tenants?: TenantInfo;
752
- timezone: string | null;
753
- schedules: DaySchedule[] | null;
754
- holidays: Holiday[] | null;
755
- after_hours_action: string | null;
756
- after_hours_target: string | null;
757
- status: string | null;
758
- created_at: string | null;
759
- updated_at: string | null;
760
- }
761
- export interface CreateScheduleParams {
762
- name: string;
763
- timezone?: string;
764
- schedules?: DaySchedule[];
765
- holidays?: Holiday[];
766
- afterHoursAction?: 'voicemail' | 'ivr' | 'extension' | 'hangup' | 'external';
767
- afterHoursTarget?: string;
768
- }
769
- export interface ScheduleStatusResponse {
770
- isOpen: boolean;
771
- schedule: string;
772
- timezone: string;
773
- currentTime: string;
774
- }
775
- export interface GatewayStatus {
776
- state: string;
777
- status: string;
778
- callsIn: number;
779
- callsOut: number;
780
- failedIn?: number;
781
- failedOut?: number;
782
- uptime?: string;
783
- }
784
- export interface SipTrunk {
785
- id: string;
786
- /** NULL for global trunks (shared, not tied to any tenant) */
787
- tenant_id: string | null;
788
- /** Present when queried as global superadmin */
789
- tenants?: TenantInfo;
790
- name: string;
791
- provider: string | null;
792
- gateway: string;
793
- username: string | null;
794
- password: string | null;
795
- auth_type: string | null;
796
- outbound_enabled: boolean | null;
797
- inbound_enabled: boolean | null;
798
- priority: number | null;
799
- max_channels: number | null;
800
- status: string | null;
801
- realm: string | null;
802
- proxy: string | null;
803
- register: boolean | null;
804
- from_user: string | null;
805
- from_domain: string | null;
806
- transport: string | null;
807
- codec_prefs: string | null;
808
- caller_id_in_from: boolean | null;
809
- ping: number | null;
810
- retry_seconds: number | null;
811
- expire_seconds: number | null;
812
- register_proxy: string | null;
813
- contact_params: string | null;
814
- is_global: boolean | null;
815
- gateway_name: string | null;
816
- /** Live gateway status from FreeSWITCH (when available) */
817
- gatewayStatus?: GatewayStatus | null;
818
- created_at: string | null;
819
- updated_at: string | null;
820
- }
821
- export interface CreateTrunkParams {
822
- name: string;
823
- provider?: 'twilio' | 'telnyx' | 'vonage' | 'bandwidth' | 'flowroute' | 'signalwire' | 'custom';
824
- gateway: string;
825
- username?: string;
826
- password?: string;
827
- authType?: 'ip' | 'registration' | 'both';
828
- outboundEnabled?: boolean;
829
- inboundEnabled?: boolean;
830
- priority?: number;
831
- maxChannels?: number;
832
- status?: 'active' | 'inactive';
833
- realm?: string;
834
- proxy?: string;
835
- register?: boolean;
836
- fromUser?: string;
837
- fromDomain?: string;
838
- transport?: 'udp' | 'tcp' | 'tls';
839
- codecPrefs?: string;
840
- callerIdInFrom?: boolean;
841
- ping?: number;
842
- retrySeconds?: number;
843
- expireSeconds?: number;
844
- registerProxy?: string;
845
- contactParams?: string;
846
- isGlobal?: boolean;
847
- }
848
- export interface QueueStats {
849
- queueName: string;
850
- strategy: string;
851
- agents: {
852
- total: number;
853
- available: number;
854
- paused: number;
855
- busy: number;
856
- loggedOut: number;
857
- };
858
- today: {
859
- totalCalls: number;
860
- answered: number;
861
- abandoned: number;
862
- serviceLevel: number;
863
- avgDuration: number;
864
- };
865
- }
866
- export interface ExportCallsParams {
867
- dateFrom?: string;
868
- dateTo?: string;
869
- direction?: 'inbound' | 'outbound' | 'internal' | 'all';
870
- limit?: number;
871
- }
872
- export interface SipCredentials {
873
- extension: string;
874
- displayName: string;
875
- password: string;
876
- sipDomain: string;
877
- wsUri: string;
878
- registrar: string;
879
- }
880
- export interface ApiKey {
881
- id: string;
882
- name: string;
883
- /** Full raw key — only present on create and regenerate responses */
884
- key?: string;
885
- /** Masked preview: csk_live_••••••••abcd1234 */
886
- keyPreview: string;
887
- role: string;
888
- scopes: string[];
889
- lastUsedAt: string | null;
890
- expiresAt: string | null;
891
- status: string;
892
- createdBy: string | null;
893
- createdAt: string | null;
894
- revokedAt?: string | null;
895
- }
896
- export interface CreateApiKeyParams {
897
- name: string;
898
- role?: 'admin' | 'readonly' | 'user' | 'superadmin';
899
- scopes?: string[];
900
- expiresAt?: string;
901
- /** Superadmin only: create a global API key with no tenant (full PBX control) */
902
- global?: boolean;
903
- /** Superadmin only: specify which tenant this key belongs to */
904
- tenantId?: string;
905
- }
906
- export interface UpdateApiKeyParams {
907
- name?: string;
908
- role?: 'admin' | 'readonly' | 'user';
909
- scopes?: string[];
910
- expiresAt?: string | null;
911
- }
912
- /** Included in list responses when authenticated as global superadmin */
913
- export interface TenantInfo {
914
- id: string;
915
- company_name: string;
916
- subdomain: string;
917
- }
918
- /** Options that can be passed to individual SDK methods */
919
- export interface RequestOptions {
920
- /**
921
- * Override the tenant ID for this specific request.
922
- * Required when creating resources as a global superadmin.
923
- *
924
- * @example
925
- * // Create an extension for a specific tenant
926
- * await voip.createExtension(
927
- * { extension: '2001', password: 'secret', displayName: 'Bob' },
928
- * { tenantId: 'tenant-uuid-here' },
929
- * );
930
- */
931
- tenantId?: string;
932
- }
933
- /** SIP registration details returned when creating an extension */
934
- export interface SipProvisioningInfo {
935
- username: string;
936
- domain: string;
937
- server: string;
938
- }
939
- export interface VoIPClientConfig {
940
- /** API base URL, e.g. https://voip-api.cemscale.com */
941
- apiUrl: string;
942
- /**
943
- * API Key — the recommended way to authenticate.
944
- * Get your key from the dashboard (API Keys page) or via the API.
945
- * When set, all requests use this key automatically. No login needed.
946
- *
947
- * @example
948
- * const voip = new VoIPClient({
949
- * apiUrl: 'https://voip-api.cemscale.com',
950
- * apiKey: 'csk_live_...',
951
- * });
952
- */
953
- apiKey?: string;
954
- /**
955
- * JWT token — only needed for browser-based login flows (softphone, dashboard).
956
- * Most integrations should use `apiKey` instead.
957
- * This is set automatically when you call `login()` or `adminLogin()`.
958
- */
959
- token?: string;
960
- /** Tenant ID — only used by superadmin to target a specific tenant */
961
- tenantId?: string;
962
- /** Request timeout in ms (default 15000) */
963
- timeout?: number;
964
- }
965
- //# sourceMappingURL=types.d.ts.map