@cstar.help/js 0.11.0 → 0.12.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.
- package/README.md +58 -6
- package/dist/chat/index.cjs +243 -10
- package/dist/chat/index.d.cts +188 -6
- package/dist/chat/index.d.ts +188 -6
- package/dist/chat/index.js +237 -9
- package/dist/index.d.cts +399 -15
- package/dist/index.d.ts +399 -15
- package/dist/quickhelp/index.cjs +102 -0
- package/dist/quickhelp/index.d.cts +97 -0
- package/dist/quickhelp/index.d.ts +97 -0
- package/dist/quickhelp/index.js +76 -0
- package/dist/webhook/index.d.cts +390 -102
- package/dist/webhook/index.d.ts +390 -102
- package/package.json +11 -1
package/dist/index.d.cts
CHANGED
|
@@ -499,8 +499,401 @@ declare class ArticlesResource extends BaseResource<Article, ArticleListParams,
|
|
|
499
499
|
constructor(client: HttpClient);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
/**
|
|
503
|
-
type WebhookEventType = '
|
|
502
|
+
/** Every webhook event type cStar can dispatch. */
|
|
503
|
+
type WebhookEventType = 'article.created' | 'article.deleted' | 'article.published' | 'article.updated' | 'boss.damaged' | 'boss.defeated' | 'boss.spawned' | 'community_post.commented' | 'community_post.created' | 'community_post.deleted' | 'community_post.status_changed' | 'community_post.updated' | 'community_post.voted' | 'customer.created' | 'customer.deleted' | 'customer.updated' | 'customer_group.created' | 'customer_group.deleted' | 'customer_group.updated' | 'player.achievement_unlocked' | 'player.level_up' | 'player.quest_completed' | 'player.streak_milestone' | 'player.xp_gained' | 'social.high_five_sent' | 'social.one_up_sent' | 'survey.submitted' | 'ticket.assigned' | 'ticket.closed' | 'ticket.created' | 'ticket.deleted' | 'ticket.message_added' | 'ticket.updated';
|
|
504
|
+
/** Payload for `article.created` events. */
|
|
505
|
+
interface ArticleCreatedPayload {
|
|
506
|
+
article: {
|
|
507
|
+
id: string;
|
|
508
|
+
title: string;
|
|
509
|
+
slug: string;
|
|
510
|
+
is_public: boolean;
|
|
511
|
+
created_at: string;
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
/** Payload for `article.deleted` events. */
|
|
515
|
+
interface ArticleDeletedPayload {
|
|
516
|
+
id: string;
|
|
517
|
+
}
|
|
518
|
+
/** Payload for `article.published` events. */
|
|
519
|
+
interface ArticlePublishedPayload {
|
|
520
|
+
article: {
|
|
521
|
+
id: string;
|
|
522
|
+
title: string;
|
|
523
|
+
slug: string;
|
|
524
|
+
is_public: boolean;
|
|
525
|
+
published_at: string;
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
/** Payload for `article.updated` events. */
|
|
529
|
+
interface ArticleUpdatedPayload {
|
|
530
|
+
article: {
|
|
531
|
+
id: string;
|
|
532
|
+
title: string;
|
|
533
|
+
slug: string;
|
|
534
|
+
is_public: boolean;
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
/** Payload for `boss.damaged` events. */
|
|
538
|
+
interface BossDamagedPayload {
|
|
539
|
+
boss: {
|
|
540
|
+
id: string;
|
|
541
|
+
current_hp: number;
|
|
542
|
+
};
|
|
543
|
+
damage: number;
|
|
544
|
+
by: {
|
|
545
|
+
agent_id: string;
|
|
546
|
+
name: string;
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
/** Payload for `boss.defeated` events. */
|
|
550
|
+
interface BossDefeatedPayload {
|
|
551
|
+
boss: {
|
|
552
|
+
id: string;
|
|
553
|
+
name: string;
|
|
554
|
+
};
|
|
555
|
+
final_blow_by: {
|
|
556
|
+
agent_id: string;
|
|
557
|
+
name: string;
|
|
558
|
+
};
|
|
559
|
+
team_xp_awarded: number;
|
|
560
|
+
}
|
|
561
|
+
/** Payload for `boss.spawned` events. */
|
|
562
|
+
interface BossSpawnedPayload {
|
|
563
|
+
boss: {
|
|
564
|
+
id: string;
|
|
565
|
+
name: string;
|
|
566
|
+
level: number;
|
|
567
|
+
max_hp: number;
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
/** Payload for `community_post.commented` events. */
|
|
571
|
+
interface CommunityPostCommentedPayload {
|
|
572
|
+
comment: {
|
|
573
|
+
id: string;
|
|
574
|
+
post_id: string;
|
|
575
|
+
content: string;
|
|
576
|
+
author_id: string;
|
|
577
|
+
created_at: string;
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
/** Payload for `community_post.created` events. */
|
|
581
|
+
interface CommunityPostCreatedPayload {
|
|
582
|
+
post: {
|
|
583
|
+
id: string;
|
|
584
|
+
prefixed_id: string;
|
|
585
|
+
title: string;
|
|
586
|
+
status: string;
|
|
587
|
+
visibility: string;
|
|
588
|
+
topic: string;
|
|
589
|
+
created_at: string;
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
/** Payload for `community_post.deleted` events. */
|
|
593
|
+
interface CommunityPostDeletedPayload {
|
|
594
|
+
post: {
|
|
595
|
+
id: string;
|
|
596
|
+
prefixed_id?: string;
|
|
597
|
+
title?: string;
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
/** Payload for `community_post.status_changed` events. */
|
|
601
|
+
interface CommunityPostStatusChangedPayload {
|
|
602
|
+
post: {
|
|
603
|
+
id: string;
|
|
604
|
+
title: string;
|
|
605
|
+
status: string;
|
|
606
|
+
visibility: string;
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
/** Payload for `community_post.updated` events. */
|
|
610
|
+
interface CommunityPostUpdatedPayload {
|
|
611
|
+
post: {
|
|
612
|
+
id: string;
|
|
613
|
+
title: string;
|
|
614
|
+
status: string;
|
|
615
|
+
visibility: string;
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
/** Payload for `community_post.voted` events. */
|
|
619
|
+
interface CommunityPostVotedPayload {
|
|
620
|
+
post: {
|
|
621
|
+
id: string;
|
|
622
|
+
vote_count: number;
|
|
623
|
+
};
|
|
624
|
+
voter: {
|
|
625
|
+
id: string;
|
|
626
|
+
};
|
|
627
|
+
direction: string;
|
|
628
|
+
}
|
|
629
|
+
/** Payload for `customer.created` events. */
|
|
630
|
+
interface CustomerCreatedPayload {
|
|
631
|
+
customer: {
|
|
632
|
+
id: string;
|
|
633
|
+
name: string;
|
|
634
|
+
email: string;
|
|
635
|
+
status: string;
|
|
636
|
+
tags: Array<string>;
|
|
637
|
+
created_at: string;
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
/** Payload for `customer.deleted` events. */
|
|
641
|
+
interface CustomerDeletedPayload {
|
|
642
|
+
id: string;
|
|
643
|
+
}
|
|
644
|
+
/** Payload for `customer.updated` events. */
|
|
645
|
+
interface CustomerUpdatedPayload {
|
|
646
|
+
customer: {
|
|
647
|
+
id: string;
|
|
648
|
+
name: string;
|
|
649
|
+
email: string;
|
|
650
|
+
status: string;
|
|
651
|
+
tags: Array<string>;
|
|
652
|
+
};
|
|
653
|
+
changes: {
|
|
654
|
+
tags: {
|
|
655
|
+
from: Array<string>;
|
|
656
|
+
to: Array<string>;
|
|
657
|
+
};
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
/** Payload for `customer_group.created` events. */
|
|
661
|
+
interface CustomerGroupCreatedPayload {
|
|
662
|
+
group: {
|
|
663
|
+
id: string;
|
|
664
|
+
name: string;
|
|
665
|
+
color: string;
|
|
666
|
+
member_count: number;
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
/** Payload for `customer_group.deleted` events. */
|
|
670
|
+
interface CustomerGroupDeletedPayload {
|
|
671
|
+
customer_group: {
|
|
672
|
+
id: string;
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
/** Payload for `customer_group.updated` events. */
|
|
676
|
+
interface CustomerGroupUpdatedPayload {
|
|
677
|
+
group: {
|
|
678
|
+
id: string;
|
|
679
|
+
name: string;
|
|
680
|
+
color: string;
|
|
681
|
+
member_count: number;
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
/** Payload for `player.achievement_unlocked` events. */
|
|
685
|
+
interface PlayerAchievementUnlockedPayload {
|
|
686
|
+
player: {
|
|
687
|
+
agent_id: string;
|
|
688
|
+
name: string;
|
|
689
|
+
};
|
|
690
|
+
achievement: {
|
|
691
|
+
id: string;
|
|
692
|
+
name: string;
|
|
693
|
+
xp: number;
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
/** Payload for `player.level_up` events. */
|
|
697
|
+
interface PlayerLevelUpPayload {
|
|
698
|
+
player: {
|
|
699
|
+
agent_id: string;
|
|
700
|
+
name: string;
|
|
701
|
+
};
|
|
702
|
+
level: {
|
|
703
|
+
from: number;
|
|
704
|
+
to: number;
|
|
705
|
+
};
|
|
706
|
+
title_unlocked: string;
|
|
707
|
+
}
|
|
708
|
+
/** Payload for `player.quest_completed` events. */
|
|
709
|
+
interface PlayerQuestCompletedPayload {
|
|
710
|
+
player: {
|
|
711
|
+
agent_id: string;
|
|
712
|
+
name: string;
|
|
713
|
+
};
|
|
714
|
+
quest: {
|
|
715
|
+
id: string;
|
|
716
|
+
name: string;
|
|
717
|
+
xp: number;
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
/** Payload for `player.streak_milestone` events. */
|
|
721
|
+
interface PlayerStreakMilestonePayload {
|
|
722
|
+
player: {
|
|
723
|
+
agent_id: string;
|
|
724
|
+
name: string;
|
|
725
|
+
};
|
|
726
|
+
streak_days: number;
|
|
727
|
+
milestone: number;
|
|
728
|
+
}
|
|
729
|
+
/** Payload for `player.xp_gained` events. */
|
|
730
|
+
interface PlayerXpGainedPayload {
|
|
731
|
+
player: {
|
|
732
|
+
agent_id: string;
|
|
733
|
+
name: string;
|
|
734
|
+
};
|
|
735
|
+
amount: number;
|
|
736
|
+
reason: string;
|
|
737
|
+
ticket_id: string;
|
|
738
|
+
}
|
|
739
|
+
/** Payload for `social.high_five_sent` events. */
|
|
740
|
+
interface SocialHighFiveSentPayload {
|
|
741
|
+
from_team: {
|
|
742
|
+
id: string;
|
|
743
|
+
name: string;
|
|
744
|
+
};
|
|
745
|
+
to_team: {
|
|
746
|
+
id: string;
|
|
747
|
+
name: string;
|
|
748
|
+
};
|
|
749
|
+
message: string;
|
|
750
|
+
}
|
|
751
|
+
/** Payload for `social.one_up_sent` events. */
|
|
752
|
+
interface SocialOneUpSentPayload {
|
|
753
|
+
from: {
|
|
754
|
+
agent_id: string;
|
|
755
|
+
name: string;
|
|
756
|
+
};
|
|
757
|
+
to: {
|
|
758
|
+
agent_id: string;
|
|
759
|
+
name: string;
|
|
760
|
+
};
|
|
761
|
+
ticket_id: string;
|
|
762
|
+
message: string;
|
|
763
|
+
}
|
|
764
|
+
/** Payload for `survey.submitted` events. */
|
|
765
|
+
interface SurveySubmittedPayload {
|
|
766
|
+
survey: {
|
|
767
|
+
id: string;
|
|
768
|
+
ticket_id: string;
|
|
769
|
+
score: number;
|
|
770
|
+
comment: string;
|
|
771
|
+
submitted_at: string;
|
|
772
|
+
};
|
|
773
|
+
customer: {
|
|
774
|
+
id: string;
|
|
775
|
+
email: string;
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
/** Payload for `ticket.assigned` events. */
|
|
779
|
+
interface TicketAssignedPayload {
|
|
780
|
+
ticket: {
|
|
781
|
+
id: string;
|
|
782
|
+
prefixed_id: string;
|
|
783
|
+
};
|
|
784
|
+
assignee: {
|
|
785
|
+
id: string;
|
|
786
|
+
name: string;
|
|
787
|
+
email: string;
|
|
788
|
+
};
|
|
789
|
+
previous_assignee: null;
|
|
790
|
+
}
|
|
791
|
+
/** Payload for `ticket.closed` events. */
|
|
792
|
+
interface TicketClosedPayload {
|
|
793
|
+
ticket: {
|
|
794
|
+
id: string;
|
|
795
|
+
prefixed_id: string;
|
|
796
|
+
title: string;
|
|
797
|
+
status: string;
|
|
798
|
+
priority: string;
|
|
799
|
+
channel: string;
|
|
800
|
+
resolved_at: string;
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
/** Payload for `ticket.created` events. */
|
|
804
|
+
interface TicketCreatedPayload {
|
|
805
|
+
ticket: {
|
|
806
|
+
id: string;
|
|
807
|
+
prefixed_id: string;
|
|
808
|
+
title: string;
|
|
809
|
+
status: string;
|
|
810
|
+
priority: string;
|
|
811
|
+
channel: string;
|
|
812
|
+
customer_id: string;
|
|
813
|
+
created_at: string;
|
|
814
|
+
};
|
|
815
|
+
customer: {
|
|
816
|
+
id: string;
|
|
817
|
+
name: string;
|
|
818
|
+
email: string;
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
/** Payload for `ticket.deleted` events. */
|
|
822
|
+
interface TicketDeletedPayload {
|
|
823
|
+
id: string;
|
|
824
|
+
}
|
|
825
|
+
/** Payload for `ticket.message_added` events. */
|
|
826
|
+
interface TicketMessageAddedPayload {
|
|
827
|
+
ticket: {
|
|
828
|
+
id: string;
|
|
829
|
+
dashboard_url: string | null;
|
|
830
|
+
};
|
|
831
|
+
message: {
|
|
832
|
+
id: string;
|
|
833
|
+
sender: string;
|
|
834
|
+
sender_name: string | null;
|
|
835
|
+
content: string;
|
|
836
|
+
created_at: string;
|
|
837
|
+
};
|
|
838
|
+
customer?: {
|
|
839
|
+
id: string;
|
|
840
|
+
name: string | null;
|
|
841
|
+
email: string | null;
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
/** Payload for `ticket.updated` events. */
|
|
845
|
+
interface TicketUpdatedPayload {
|
|
846
|
+
ticket: {
|
|
847
|
+
id: string;
|
|
848
|
+
prefixed_id: string;
|
|
849
|
+
title: string;
|
|
850
|
+
status: string;
|
|
851
|
+
priority: string;
|
|
852
|
+
channel: string;
|
|
853
|
+
};
|
|
854
|
+
changes: {
|
|
855
|
+
priority: {
|
|
856
|
+
from: string;
|
|
857
|
+
to: string;
|
|
858
|
+
};
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
/** Maps each event type to its payload interface — used internally for the discriminated union. */
|
|
862
|
+
interface WebhookEventDataMap {
|
|
863
|
+
'article.created': ArticleCreatedPayload;
|
|
864
|
+
'article.deleted': ArticleDeletedPayload;
|
|
865
|
+
'article.published': ArticlePublishedPayload;
|
|
866
|
+
'article.updated': ArticleUpdatedPayload;
|
|
867
|
+
'boss.damaged': BossDamagedPayload;
|
|
868
|
+
'boss.defeated': BossDefeatedPayload;
|
|
869
|
+
'boss.spawned': BossSpawnedPayload;
|
|
870
|
+
'community_post.commented': CommunityPostCommentedPayload;
|
|
871
|
+
'community_post.created': CommunityPostCreatedPayload;
|
|
872
|
+
'community_post.deleted': CommunityPostDeletedPayload;
|
|
873
|
+
'community_post.status_changed': CommunityPostStatusChangedPayload;
|
|
874
|
+
'community_post.updated': CommunityPostUpdatedPayload;
|
|
875
|
+
'community_post.voted': CommunityPostVotedPayload;
|
|
876
|
+
'customer.created': CustomerCreatedPayload;
|
|
877
|
+
'customer.deleted': CustomerDeletedPayload;
|
|
878
|
+
'customer.updated': CustomerUpdatedPayload;
|
|
879
|
+
'customer_group.created': CustomerGroupCreatedPayload;
|
|
880
|
+
'customer_group.deleted': CustomerGroupDeletedPayload;
|
|
881
|
+
'customer_group.updated': CustomerGroupUpdatedPayload;
|
|
882
|
+
'player.achievement_unlocked': PlayerAchievementUnlockedPayload;
|
|
883
|
+
'player.level_up': PlayerLevelUpPayload;
|
|
884
|
+
'player.quest_completed': PlayerQuestCompletedPayload;
|
|
885
|
+
'player.streak_milestone': PlayerStreakMilestonePayload;
|
|
886
|
+
'player.xp_gained': PlayerXpGainedPayload;
|
|
887
|
+
'social.high_five_sent': SocialHighFiveSentPayload;
|
|
888
|
+
'social.one_up_sent': SocialOneUpSentPayload;
|
|
889
|
+
'survey.submitted': SurveySubmittedPayload;
|
|
890
|
+
'ticket.assigned': TicketAssignedPayload;
|
|
891
|
+
'ticket.closed': TicketClosedPayload;
|
|
892
|
+
'ticket.created': TicketCreatedPayload;
|
|
893
|
+
'ticket.deleted': TicketDeletedPayload;
|
|
894
|
+
'ticket.message_added': TicketMessageAddedPayload;
|
|
895
|
+
'ticket.updated': TicketUpdatedPayload;
|
|
896
|
+
}
|
|
504
897
|
/** A webhook event delivered to your endpoint. */
|
|
505
898
|
interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
|
|
506
899
|
/** Unique event ID (idempotency key). */
|
|
@@ -512,19 +905,10 @@ interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
|
|
|
512
905
|
/** Team that owns this event. */
|
|
513
906
|
team_id: string;
|
|
514
907
|
/** Event-specific payload. */
|
|
515
|
-
data:
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
type WebhookEventData<T extends WebhookEventType> = T
|
|
519
|
-
ticket: Ticket;
|
|
520
|
-
} : T extends 'ticket.message_added' ? {
|
|
521
|
-
ticket: Ticket;
|
|
522
|
-
message: Message;
|
|
523
|
-
} : T extends 'customer.created' | 'customer.updated' ? {
|
|
524
|
-
customer: Customer;
|
|
525
|
-
} : T extends 'article.created' | 'article.published' | 'article.updated' ? {
|
|
526
|
-
article: Article;
|
|
527
|
-
} : Record<string, unknown>;
|
|
908
|
+
data: WebhookEventDataMap[T];
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
type WebhookEventData<T extends WebhookEventType> = WebhookEventDataMap[T];
|
|
528
912
|
|
|
529
913
|
/** A cStar webhook endpoint. */
|
|
530
914
|
interface Webhook {
|