@sippulse/niva-sdk 0.1.0-rc.9 → 0.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.
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { NivaJsonValue } from "../types.js";
6
6
  /** Registry literals mirrored from WEBHOOK_EVENT_TYPES; runtime const for the registry gate. */
7
- export declare const NIVA_WEBHOOK_EVENT_TYPES: readonly ["alert.fired", "alert.resolved", "call.amd_completed", "call.analysis_completed", "call.answered", "call.hangup", "call.intent_matched", "call.node_entered", "call.node_error", "call.node_warning", "call.recording_available", "call.rejected", "call.signal_triggered", "call.started", "call.transcribed", "call.transferred", "dialer.attempt.finished", "message.sent", "plan.published", "service.down", "service.up"];
7
+ export declare const NIVA_WEBHOOK_EVENT_TYPES: readonly ["alert.fired", "alert.resolved", "attendant.status_changed", "call.amd_completed", "call.analysis_completed", "call.answered", "call.hangup", "call.intent_matched", "call.node_entered", "call.node_error", "call.node_warning", "call.recording_available", "call.rejected", "call.signal_triggered", "call.started", "call.transcribed", "call.transcription_failed", "call.transferred", "conversation.abandoned", "conversation.answered", "conversation.offered", "conversation.queued", "conversation.wrapped", "dialer.attempt.finished", "message.sent", "plan.published", "service.down", "service.up", "webhook.test"];
8
8
  /** Union of the registry event literals. */
9
9
  export type NivaWebhookEventType = (typeof NIVA_WEBHOOK_EVENT_TYPES)[number];
10
10
  /** Per-event data payloads of the external delivery envelope (no org_id). */
@@ -22,6 +22,27 @@ export interface NivaWebhookEventMap {
22
22
  title: string;
23
23
  body: string;
24
24
  };
25
+ "attendant.status_changed": {
26
+ /**
27
+ * minLength: 1
28
+ */
29
+ attendant_id: `att_${string}`;
30
+ /**
31
+ * minLength: 1
32
+ */
33
+ user_id: `usr_${string}`;
34
+ from: "offline" | "available" | "paused" | "not_responding" | "ringing" | "busy" | "wrap_up";
35
+ to: "offline" | "available" | "paused" | "not_responding" | "ringing" | "busy" | "wrap_up";
36
+ reason: {
37
+ /**
38
+ * minLength: 1
39
+ */
40
+ id: `pause_${string}`;
41
+ name: string;
42
+ } | null;
43
+ source: "attendant" | "system" | "supervisor";
44
+ changed_at: string;
45
+ };
25
46
  "call.amd_completed": {
26
47
  /**
27
48
  * minLength: 1
@@ -394,6 +415,19 @@ export interface NivaWebhookEventMap {
394
415
  is_anonymized: boolean;
395
416
  metadata: Record<string, string>;
396
417
  };
418
+ "call.transcription_failed": {
419
+ /**
420
+ * minLength: 1
421
+ */
422
+ call_record_id: `call_${string}`;
423
+ /**
424
+ * minLength: 1
425
+ */
426
+ transcription_id: `ctr_${string}`;
427
+ metadata: Record<string, string>;
428
+ error_code: "ASR_REJECTED" | "RETRIES_EXHAUSTED" | "RANGE_TRANSCRIPTION_FAILED" | "PROCESSING_TIMEOUT";
429
+ error_message: string;
430
+ };
397
431
  "call.transferred": {
398
432
  /**
399
433
  * minLength: 1
@@ -409,9 +443,194 @@ export interface NivaWebhookEventMap {
409
443
  * minimum: 0
410
444
  */
411
445
  duration_ms: number | null;
446
+ note: string | null;
412
447
  transferred_at: string;
413
448
  metadata: Record<string, string>;
414
449
  };
450
+ "conversation.abandoned": {
451
+ /**
452
+ * minLength: 1
453
+ */
454
+ conversation_id: `conv_${string}`;
455
+ call_record_id: `call_${string}`;
456
+ attendant_id: `att_${string}`;
457
+ user_id: `usr_${string}`;
458
+ channel: "voice" | "chat";
459
+ status: "queued" | "offered" | "active" | "waiting_customer" | "wrap_up" | "closed";
460
+ outcome: "completed" | "abandoned" | "timeout" | "full" | "no_attendant" | "transferred" | "attendant_offline" | "refused" | "no_answer" | "busy" | "failed" | null;
461
+ joined_at: string;
462
+ offered_at: string | null;
463
+ answered_at: string | null;
464
+ ended_at: string | null;
465
+ wrapped_at: string | null;
466
+ /**
467
+ * minimum: 0
468
+ * maximum: 9007199254740991
469
+ */
470
+ wait_ms: number | null;
471
+ /**
472
+ * minimum: 0
473
+ * maximum: 9007199254740991
474
+ */
475
+ talk_ms: number | null;
476
+ /**
477
+ * minimum: 0
478
+ * maximum: 9007199254740991
479
+ */
480
+ wrap_ms: number | null;
481
+ /**
482
+ * minLength: 1
483
+ */
484
+ queue_id: `que_${string}`;
485
+ /**
486
+ * minimum: 0
487
+ * maximum: 9007199254740991
488
+ */
489
+ wait_s: number;
490
+ short: boolean;
491
+ };
492
+ "conversation.answered": {
493
+ /**
494
+ * minLength: 1
495
+ */
496
+ conversation_id: `conv_${string}`;
497
+ call_record_id: `call_${string}`;
498
+ attendant_id: `att_${string}`;
499
+ user_id: `usr_${string}`;
500
+ channel: "voice" | "chat";
501
+ status: "queued" | "offered" | "active" | "waiting_customer" | "wrap_up" | "closed";
502
+ outcome: "completed" | "abandoned" | "timeout" | "full" | "no_attendant" | "transferred" | "attendant_offline" | "refused" | "no_answer" | "busy" | "failed" | null;
503
+ joined_at: string;
504
+ offered_at: string | null;
505
+ answered_at: string | null;
506
+ ended_at: string | null;
507
+ wrapped_at: string | null;
508
+ /**
509
+ * minimum: 0
510
+ * maximum: 9007199254740991
511
+ */
512
+ wait_ms: number | null;
513
+ /**
514
+ * minimum: 0
515
+ * maximum: 9007199254740991
516
+ */
517
+ talk_ms: number | null;
518
+ /**
519
+ * minimum: 0
520
+ * maximum: 9007199254740991
521
+ */
522
+ wrap_ms: number | null;
523
+ };
524
+ "conversation.offered": {
525
+ /**
526
+ * minLength: 1
527
+ */
528
+ conversation_id: `conv_${string}`;
529
+ call_record_id: `call_${string}`;
530
+ attendant_id: `att_${string}`;
531
+ user_id: `usr_${string}`;
532
+ channel: "voice" | "chat";
533
+ status: "queued" | "offered" | "active" | "waiting_customer" | "wrap_up" | "closed";
534
+ outcome: "completed" | "abandoned" | "timeout" | "full" | "no_attendant" | "transferred" | "attendant_offline" | "refused" | "no_answer" | "busy" | "failed" | null;
535
+ joined_at: string;
536
+ offered_at: string | null;
537
+ answered_at: string | null;
538
+ ended_at: string | null;
539
+ wrapped_at: string | null;
540
+ /**
541
+ * minimum: 0
542
+ * maximum: 9007199254740991
543
+ */
544
+ wait_ms: number | null;
545
+ /**
546
+ * minimum: 0
547
+ * maximum: 9007199254740991
548
+ */
549
+ talk_ms: number | null;
550
+ /**
551
+ * minimum: 0
552
+ * maximum: 9007199254740991
553
+ */
554
+ wrap_ms: number | null;
555
+ };
556
+ "conversation.queued": {
557
+ /**
558
+ * minLength: 1
559
+ */
560
+ conversation_id: `conv_${string}`;
561
+ call_record_id: `call_${string}`;
562
+ attendant_id: `att_${string}`;
563
+ user_id: `usr_${string}`;
564
+ channel: "voice" | "chat";
565
+ status: "queued" | "offered" | "active" | "waiting_customer" | "wrap_up" | "closed";
566
+ outcome: "completed" | "abandoned" | "timeout" | "full" | "no_attendant" | "transferred" | "attendant_offline" | "refused" | "no_answer" | "busy" | "failed" | null;
567
+ joined_at: string;
568
+ offered_at: string | null;
569
+ answered_at: string | null;
570
+ ended_at: string | null;
571
+ wrapped_at: string | null;
572
+ /**
573
+ * minimum: 0
574
+ * maximum: 9007199254740991
575
+ */
576
+ wait_ms: number | null;
577
+ /**
578
+ * minimum: 0
579
+ * maximum: 9007199254740991
580
+ */
581
+ talk_ms: number | null;
582
+ /**
583
+ * minimum: 0
584
+ * maximum: 9007199254740991
585
+ */
586
+ wrap_ms: number | null;
587
+ /**
588
+ * minLength: 1
589
+ */
590
+ queue_id: `que_${string}`;
591
+ };
592
+ "conversation.wrapped": {
593
+ /**
594
+ * minLength: 1
595
+ */
596
+ conversation_id: `conv_${string}`;
597
+ call_record_id: `call_${string}`;
598
+ attendant_id: `att_${string}`;
599
+ user_id: `usr_${string}`;
600
+ channel: "voice" | "chat";
601
+ status: "queued" | "offered" | "active" | "waiting_customer" | "wrap_up" | "closed";
602
+ outcome: "completed" | "abandoned" | "timeout" | "full" | "no_attendant" | "transferred" | "attendant_offline" | "refused" | "no_answer" | "busy" | "failed" | null;
603
+ joined_at: string;
604
+ offered_at: string | null;
605
+ answered_at: string | null;
606
+ ended_at: string | null;
607
+ wrapped_at: string | null;
608
+ /**
609
+ * minimum: 0
610
+ * maximum: 9007199254740991
611
+ */
612
+ wait_ms: number | null;
613
+ /**
614
+ * minimum: 0
615
+ * maximum: 9007199254740991
616
+ */
617
+ talk_ms: number | null;
618
+ /**
619
+ * minimum: 0
620
+ * maximum: 9007199254740991
621
+ */
622
+ wrap_ms: number | null;
623
+ disposition: {
624
+ /**
625
+ * minLength: 1
626
+ */
627
+ id: `disp_${string}`;
628
+ code: string;
629
+ name: string;
630
+ color: "tomato" | "red" | "ruby" | "crimson" | "pink" | "plum" | "purple" | "violet" | "iris" | "indigo" | "blue" | "cyan" | "teal" | "jade" | "green" | "grass" | "bronze" | "gold" | "sky" | "mint" | "lime" | "amber" | "orange" | null;
631
+ } | null;
632
+ note: string | null;
633
+ };
415
634
  "dialer.attempt.finished": {
416
635
  /**
417
636
  * minLength: 1
@@ -439,6 +658,7 @@ export interface NivaWebhookEventMap {
439
658
  * minimum: 0
440
659
  */
441
660
  duration_s: number | null;
661
+ screening_outcome: "accepted" | "declined" | "voicemail" | "timeout" | null;
442
662
  custom_fields: Record<string, string>;
443
663
  };
444
664
  "message.sent": {
@@ -488,6 +708,16 @@ export interface NivaWebhookEventMap {
488
708
  downtime_seconds: number | null;
489
709
  recovered_at: string;
490
710
  };
711
+ "webhook.test": {
712
+ /**
713
+ * minLength: 1
714
+ */
715
+ webhook_endpoint_id: string;
716
+ /**
717
+ * minLength: 1
718
+ */
719
+ message: string;
720
+ };
491
721
  }
492
722
  /** One delivery: event, event_id, timestamp plus data narrowed by K. */
493
723
  export type NivaWebhookEvent<K extends NivaWebhookEventType = NivaWebhookEventType> = {