@cstar.help/js 0.15.1 → 0.16.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/dist/index.cjs CHANGED
@@ -33,7 +33,9 @@ __export(src_exports, {
33
33
  CStarValidationError: () => CStarValidationError,
34
34
  ErrorType: () => ErrorType,
35
35
  OfflineQueue: () => OfflineQueue,
36
- Subscription: () => Subscription
36
+ Subscription: () => Subscription,
37
+ WEBHOOK_EVENT_CATALOG: () => WEBHOOK_EVENT_CATALOG,
38
+ WEBHOOK_EVENT_SAMPLES: () => WEBHOOK_EVENT_SAMPLES
37
39
  });
38
40
  module.exports = __toCommonJS(src_exports);
39
41
 
@@ -355,7 +357,8 @@ var HttpClient = class {
355
357
  let lastError = null;
356
358
  for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
357
359
  if (attempt > 0 && lastError) {
358
- const delay = lastError instanceof CStarRateLimitError ? lastError.retryAfter * 1e3 : this.getBackoffDelay(attempt);
360
+ const RATE_LIMIT_RETRY_CAP_MS = 6e4;
361
+ const delay = lastError instanceof CStarRateLimitError ? Math.min(lastError.retryAfter * 1e3, RATE_LIMIT_RETRY_CAP_MS) : this.getBackoffDelay(attempt);
359
362
  await this.sleep(delay);
360
363
  }
361
364
  let response;
@@ -1339,10 +1342,31 @@ var InvitesResource = class {
1339
1342
  return this.client.request("DELETE", `/invites/${inviteId}`);
1340
1343
  }
1341
1344
  };
1345
+ var MemberPreferencesResource = class {
1346
+ constructor(client) {
1347
+ this.client = client;
1348
+ }
1349
+ /** Get an agent's UX preferences (boring mode, etc.). */
1350
+ async get(memberId) {
1351
+ return this.client.request(
1352
+ "GET",
1353
+ `/members/${memberId}/preferences`
1354
+ );
1355
+ }
1356
+ /** Update an agent's UX preferences. Only provided fields are written. */
1357
+ async update(memberId, params) {
1358
+ return this.client.request(
1359
+ "PATCH",
1360
+ `/members/${memberId}/preferences`,
1361
+ { body: params }
1362
+ );
1363
+ }
1364
+ };
1342
1365
  var MembersResource = class {
1343
1366
  constructor(client) {
1344
1367
  this.client = client;
1345
1368
  this.invites = new InvitesResource(client);
1369
+ this.preferences = new MemberPreferencesResource(client);
1346
1370
  }
1347
1371
  /** List all team members. */
1348
1372
  async list(params) {
@@ -2305,6 +2329,23 @@ var BillingResource = class {
2305
2329
  }
2306
2330
  };
2307
2331
 
2332
+ // src/resources/preferences.ts
2333
+ var PreferencesResource = class {
2334
+ constructor(client) {
2335
+ this.client = client;
2336
+ }
2337
+ /** Get team preferences. */
2338
+ async get() {
2339
+ return this.client.request("GET", "/preferences");
2340
+ }
2341
+ /** Update team preferences. Only provided fields are written. */
2342
+ async update(params) {
2343
+ return this.client.request("PATCH", "/preferences", {
2344
+ body: params
2345
+ });
2346
+ }
2347
+ };
2348
+
2308
2349
  // src/offline.ts
2309
2350
  var STORAGE_KEY = "cstar_offline_queue";
2310
2351
  var OfflineQueue = class {
@@ -2422,6 +2463,416 @@ var OfflineQueue = class {
2422
2463
  }
2423
2464
  };
2424
2465
 
2466
+ // src/types/generated/webhookEvents.ts
2467
+ var WEBHOOK_EVENT_SAMPLES = {
2468
+ "agent.preferences_updated": {
2469
+ "team_id": "team_01H8X9YZ7E0J3K4M5N6U",
2470
+ "member_id": "mem_01H8X9YZ7E0J3K4M5N6U",
2471
+ "agent_id": "agt_01H8X9YZ7E0J3K4M5N6U",
2472
+ "changed": [
2473
+ "boringMode"
2474
+ ],
2475
+ "preferences": {
2476
+ "boringMode": true
2477
+ }
2478
+ },
2479
+ "article.created": {
2480
+ "article": {
2481
+ "id": "art_01H8X9YZ7E0J3K4M5N6U",
2482
+ "title": "How to reset your password",
2483
+ "slug": "how-to-reset-your-password",
2484
+ "is_public": false,
2485
+ "created_at": "2026-04-27T18:42:11.000Z"
2486
+ }
2487
+ },
2488
+ "article.deleted": {
2489
+ "id": "art_01H8X9YZ7E0J3K4M5N6U"
2490
+ },
2491
+ "article.published": {
2492
+ "article": {
2493
+ "id": "art_01H8X9YZ7E0J3K4M5N6U",
2494
+ "title": "How to reset your password",
2495
+ "slug": "how-to-reset-your-password",
2496
+ "is_public": true,
2497
+ "published_at": "2026-04-27T19:00:00.000Z"
2498
+ }
2499
+ },
2500
+ "article.updated": {
2501
+ "article": {
2502
+ "id": "art_01H8X9YZ7E0J3K4M5N6U",
2503
+ "title": "How to reset your password (updated)",
2504
+ "slug": "how-to-reset-your-password",
2505
+ "is_public": true
2506
+ }
2507
+ },
2508
+ "boss.damaged": {
2509
+ "boss": {
2510
+ "id": "boss_thunder_drake",
2511
+ "current_hp": 740
2512
+ },
2513
+ "damage": 120,
2514
+ "by": {
2515
+ "agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
2516
+ "name": "Riley"
2517
+ }
2518
+ },
2519
+ "boss.defeated": {
2520
+ "boss": {
2521
+ "id": "boss_thunder_drake",
2522
+ "name": "The Thunder Drake"
2523
+ },
2524
+ "final_blow_by": {
2525
+ "agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
2526
+ "name": "Riley"
2527
+ },
2528
+ "team_xp_awarded": 1500
2529
+ },
2530
+ "boss.spawned": {
2531
+ "boss": {
2532
+ "id": "boss_thunder_drake",
2533
+ "name": "The Thunder Drake",
2534
+ "level": 4,
2535
+ "max_hp": 1200
2536
+ }
2537
+ },
2538
+ "community_post.commented": {
2539
+ "comment": {
2540
+ "id": "cmt_01H8X9YZ7E0J3K4M5N6X",
2541
+ "post_id": "post_01H8X9YZ7E0J3K4M5N6W",
2542
+ "content": "I would love this \u2014 bumping for visibility.",
2543
+ "author_id": "cus_01H8X9YZ7E0J3K4M5N6Q",
2544
+ "created_at": "2026-04-27T18:55:02.000Z"
2545
+ }
2546
+ },
2547
+ "community_post.created": {
2548
+ "post": {
2549
+ "id": "post_01H8X9YZ7E0J3K4M5N6W",
2550
+ "prefixed_id": "IDEA-42",
2551
+ "title": "Add Slack-style threading to tickets",
2552
+ "status": "open",
2553
+ "visibility": "public",
2554
+ "topic": "feature-requests",
2555
+ "created_at": "2026-04-27T18:42:11.000Z"
2556
+ }
2557
+ },
2558
+ "community_post.deleted": {
2559
+ "post": {
2560
+ "id": "post_01H8X9YZ7E0J3K4M5N6W",
2561
+ "prefixed_id": "IDEA-42",
2562
+ "title": "Add Slack-style threading to tickets"
2563
+ }
2564
+ },
2565
+ "community_post.status_changed": {
2566
+ "post": {
2567
+ "id": "post_01H8X9YZ7E0J3K4M5N6W",
2568
+ "title": "Add Slack-style threading to tickets",
2569
+ "status": "planned",
2570
+ "visibility": "public"
2571
+ }
2572
+ },
2573
+ "community_post.updated": {
2574
+ "post": {
2575
+ "id": "post_01H8X9YZ7E0J3K4M5N6W",
2576
+ "title": "Add Slack-style threading to tickets (revised)",
2577
+ "status": "open",
2578
+ "visibility": "public"
2579
+ }
2580
+ },
2581
+ "community_post.voted": {
2582
+ "post": {
2583
+ "id": "post_01H8X9YZ7E0J3K4M5N6W",
2584
+ "vote_count": 13
2585
+ },
2586
+ "voter": {
2587
+ "id": "cus_01H8X9YZ7E0J3K4M5N6Q"
2588
+ },
2589
+ "direction": "up"
2590
+ },
2591
+ "customer.created": {
2592
+ "customer": {
2593
+ "id": "cus_01H8X9YZ7E0J3K4M5N6Q",
2594
+ "name": "Casey Patel",
2595
+ "email": "casey@example.com",
2596
+ "status": "active",
2597
+ "tags": [
2598
+ "trial"
2599
+ ],
2600
+ "created_at": "2026-04-27T18:42:11.000Z"
2601
+ }
2602
+ },
2603
+ "customer.deleted": {
2604
+ "id": "cus_01H8X9YZ7E0J3K4M5N6Q"
2605
+ },
2606
+ "customer.updated": {
2607
+ "customer": {
2608
+ "id": "cus_01H8X9YZ7E0J3K4M5N6Q",
2609
+ "name": "Casey Patel",
2610
+ "email": "casey@example.com",
2611
+ "status": "active",
2612
+ "tags": [
2613
+ "trial",
2614
+ "paying"
2615
+ ]
2616
+ },
2617
+ "changes": {
2618
+ "tags": {
2619
+ "from": [
2620
+ "trial"
2621
+ ],
2622
+ "to": [
2623
+ "trial",
2624
+ "paying"
2625
+ ]
2626
+ }
2627
+ }
2628
+ },
2629
+ "customer_group.created": {
2630
+ "group": {
2631
+ "id": "grp_01H8X9YZ7E0J3K4M5N6T",
2632
+ "name": "Pro Plan",
2633
+ "color": "indigo",
2634
+ "member_count": 0
2635
+ }
2636
+ },
2637
+ "customer_group.deleted": {
2638
+ "customer_group": {
2639
+ "id": "grp_01H8X9YZ7E0J3K4M5N6T"
2640
+ }
2641
+ },
2642
+ "customer_group.updated": {
2643
+ "group": {
2644
+ "id": "grp_01H8X9YZ7E0J3K4M5N6T",
2645
+ "name": "Pro Plan (Annual)",
2646
+ "color": "indigo",
2647
+ "member_count": 38
2648
+ }
2649
+ },
2650
+ "player.achievement_unlocked": {
2651
+ "player": {
2652
+ "agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
2653
+ "name": "Riley"
2654
+ },
2655
+ "achievement": {
2656
+ "id": "first_resolve",
2657
+ "name": "First Resolve",
2658
+ "xp": 50
2659
+ }
2660
+ },
2661
+ "player.level_up": {
2662
+ "player": {
2663
+ "agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
2664
+ "name": "Riley"
2665
+ },
2666
+ "level": {
2667
+ "from": 7,
2668
+ "to": 8
2669
+ },
2670
+ "title_unlocked": "Apprentice Healer"
2671
+ },
2672
+ "player.quest_completed": {
2673
+ "player": {
2674
+ "agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
2675
+ "name": "Riley"
2676
+ },
2677
+ "quest": {
2678
+ "id": "resolve_5_tickets",
2679
+ "name": "Resolve 5 tickets today",
2680
+ "xp": 100
2681
+ }
2682
+ },
2683
+ "player.streak_milestone": {
2684
+ "player": {
2685
+ "agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
2686
+ "name": "Riley"
2687
+ },
2688
+ "streak_days": 5,
2689
+ "milestone": 5
2690
+ },
2691
+ "player.xp_gained": {
2692
+ "player": {
2693
+ "agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
2694
+ "name": "Riley"
2695
+ },
2696
+ "amount": 75,
2697
+ "reason": "ticket.resolved",
2698
+ "ticket_id": "tkt_01H8X9YZ7E0J3K4M5N6P"
2699
+ },
2700
+ "social.high_five_sent": {
2701
+ "from_team": {
2702
+ "id": "team_acme",
2703
+ "name": "Acme Support"
2704
+ },
2705
+ "to_team": {
2706
+ "id": "team_globex",
2707
+ "name": "Globex Support"
2708
+ },
2709
+ "message": "Thanks for the assist!"
2710
+ },
2711
+ "social.one_up_sent": {
2712
+ "from": {
2713
+ "agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
2714
+ "name": "Riley"
2715
+ },
2716
+ "to": {
2717
+ "agent_id": "usr_01H8X9YZ7E0J3K4M5N6V",
2718
+ "name": "Sam"
2719
+ },
2720
+ "ticket_id": "tkt_01H8X9YZ7E0J3K4M5N6P",
2721
+ "message": "Great empathy on this one"
2722
+ },
2723
+ "survey.submitted": {
2724
+ "survey": {
2725
+ "id": "svy_01H8X9YZ7E0J3K4M5N6Y",
2726
+ "ticket_id": "tkt_01H8X9YZ7E0J3K4M5N6P",
2727
+ "score": 5,
2728
+ "comment": "Resolved fast, thank you!",
2729
+ "submitted_at": "2026-04-27T19:30:00.000Z"
2730
+ },
2731
+ "customer": {
2732
+ "id": "cus_01H8X9YZ7E0J3K4M5N6Q",
2733
+ "email": "casey@example.com"
2734
+ }
2735
+ },
2736
+ "team.preferences_updated": {
2737
+ "team_id": "team_01H8X9YZ7E0J3K4M5N6U",
2738
+ "changed": [
2739
+ "bossBattlesEnabled"
2740
+ ],
2741
+ "preferences": {
2742
+ "bossBattlesEnabled": false
2743
+ }
2744
+ },
2745
+ "ticket.assigned": {
2746
+ "ticket": {
2747
+ "id": "tkt_01H8X9YZ7E0J3K4M5N6P",
2748
+ "prefixed_id": "CST-1024"
2749
+ },
2750
+ "assignee": {
2751
+ "id": "usr_01H8X9YZ7E0J3K4M5N6S",
2752
+ "name": "Riley",
2753
+ "email": "riley@acme.test"
2754
+ },
2755
+ "previous_assignee": null
2756
+ },
2757
+ "ticket.closed": {
2758
+ "ticket": {
2759
+ "id": "tkt_01H8X9YZ7E0J3K4M5N6P",
2760
+ "prefixed_id": "CST-1024",
2761
+ "title": "Cannot reset password",
2762
+ "status": "resolved",
2763
+ "priority": "normal",
2764
+ "channel": "widget",
2765
+ "resolved_at": "2026-04-27T19:08:43.000Z"
2766
+ },
2767
+ "changes": {
2768
+ "status": {
2769
+ "from": "open",
2770
+ "to": "resolved"
2771
+ }
2772
+ }
2773
+ },
2774
+ "ticket.created": {
2775
+ "ticket": {
2776
+ "id": "tkt_01H8X9YZ7E0J3K4M5N6P",
2777
+ "prefixed_id": "CST-1024",
2778
+ "title": "Cannot reset password",
2779
+ "status": "new",
2780
+ "priority": "normal",
2781
+ "channel": "widget",
2782
+ "customer_id": "cus_01H8X9YZ7E0J3K4M5N6Q",
2783
+ "created_at": "2026-04-27T18:42:11.000Z"
2784
+ },
2785
+ "customer": {
2786
+ "id": "cus_01H8X9YZ7E0J3K4M5N6Q",
2787
+ "name": "Casey Patel",
2788
+ "email": "casey@example.com"
2789
+ }
2790
+ },
2791
+ "ticket.deleted": {
2792
+ "id": "CST-1024"
2793
+ },
2794
+ "ticket.message_added": {
2795
+ "ticket": {
2796
+ "id": "tkt_01H8X9YZ7E0J3K4M5N6P",
2797
+ "dashboard_url": "https://www.cstar.help/team/acme/tickets?selected=tkt_01H8X9YZ7E0J3K4M5N6P"
2798
+ },
2799
+ "message": {
2800
+ "id": "msg_01H8X9YZ7E0J3K4M5N6R",
2801
+ "sender": "agent",
2802
+ "sender_name": "Riley",
2803
+ "content": "I just sent a reset link to your inbox \u2014 let me know if it lands.",
2804
+ "created_at": "2026-04-27T18:55:02.000Z"
2805
+ },
2806
+ "customer": {
2807
+ "id": "cus_01H8X9YZ7E0J3K4M5N6Q",
2808
+ "name": "Casey Patel",
2809
+ "email": "casey@example.com"
2810
+ }
2811
+ },
2812
+ "ticket.updated": {
2813
+ "ticket": {
2814
+ "id": "tkt_01H8X9YZ7E0J3K4M5N6P",
2815
+ "prefixed_id": "CST-1024",
2816
+ "title": "Cannot reset password",
2817
+ "status": "open",
2818
+ "priority": "high",
2819
+ "channel": "widget"
2820
+ },
2821
+ "changes": {
2822
+ "priority": {
2823
+ "from": "normal",
2824
+ "to": "high"
2825
+ },
2826
+ "tags": {
2827
+ "from": [
2828
+ "bug"
2829
+ ],
2830
+ "to": [
2831
+ "bug",
2832
+ "feature-request"
2833
+ ]
2834
+ }
2835
+ }
2836
+ }
2837
+ };
2838
+ var WEBHOOK_EVENT_CATALOG = {
2839
+ "agent.preferences_updated": { label: "Agent Preferences Updated", description: "Fired when an agent's per-user UX preferences change (e.g., boringMode toggled)", category: "team" },
2840
+ "article.created": { label: "New Article Created", description: "Fired when a new Library article is created", category: "articles" },
2841
+ "article.deleted": { label: "Article Deleted", description: "Fired when an article is deleted via app or API", category: "articles" },
2842
+ "article.published": { label: "Article Published", description: "Fired when an article is published to the Public Library", category: "articles" },
2843
+ "article.updated": { label: "Article Updated", description: "Fired when an article content or metadata is modified", category: "articles" },
2844
+ "boss.damaged": { label: "Boss Damaged", description: "Fired when a boss takes damage from a ticket close", category: "gamification" },
2845
+ "boss.defeated": { label: "Boss Defeated", description: "Fired when a boss is defeated by the team", category: "gamification" },
2846
+ "boss.spawned": { label: "Boss Battle Started", description: "Fired when a boss appears for the team", category: "gamification" },
2847
+ "community_post.commented": { label: "New Comment on Post", description: "Fired when a new comment is added to a community post", category: "community" },
2848
+ "community_post.created": { label: "New Community Post", description: "Fired when a new community post is created", category: "community" },
2849
+ "community_post.deleted": { label: "Community Post Deleted", description: "Fired when a community post is deleted", category: "community" },
2850
+ "community_post.status_changed": { label: "Post Status Changed", description: "Fired when a community post status is changed (e.g., Planned, Completed)", category: "community" },
2851
+ "community_post.updated": { label: "Community Post Updated", description: "Fired when a community post is updated", category: "community" },
2852
+ "community_post.voted": { label: "Post Voted On", description: "Fired when a community post receives a vote", category: "community" },
2853
+ "customer.created": { label: "New Customer Added", description: "Fired when a new customer is created", category: "customers" },
2854
+ "customer.deleted": { label: "Customer Deleted", description: "Fired when a customer is deleted via app or API", category: "customers" },
2855
+ "customer.updated": { label: "Customer Updated", description: "Fired when customer details are modified", category: "customers" },
2856
+ "customer_group.created": { label: "New Customer Group", description: "Fired when a customer group is created", category: "customers" },
2857
+ "customer_group.deleted": { label: "Customer Group Deleted", description: "Fired when a customer group is deleted", category: "customers" },
2858
+ "customer_group.updated": { label: "Customer Group Updated", description: "Fired when a customer group is modified", category: "customers" },
2859
+ "player.achievement_unlocked": { label: "Achievement Unlocked", description: "Fired when a player unlocks an achievement", category: "gamification" },
2860
+ "player.level_up": { label: "Player Leveled Up", description: "Fired when a player reaches a new level", category: "gamification" },
2861
+ "player.quest_completed": { label: "Quest Completed", description: "Fired when a player completes a daily quest", category: "gamification" },
2862
+ "player.streak_milestone": { label: "Streak Milestone", description: "Fired when a player hits a streak milestone (3, 5, 10, or 25 days)", category: "gamification" },
2863
+ "player.xp_gained": { label: "XP Gained", description: "Fired when a player earns XP from closing a ticket or quest", category: "gamification" },
2864
+ "social.high_five_sent": { label: "High Five Sent", description: "Fired when a team sends a high five to another team", category: "gamification" },
2865
+ "social.one_up_sent": { label: "One-Up Sent", description: "Fired when a teammate sends a one-up recognition", category: "gamification" },
2866
+ "survey.submitted": { label: "Customer Feedback Received", description: "Fired when a customer submits a CSAT survey response", category: "csat" },
2867
+ "team.preferences_updated": { label: "Team Preferences Updated", description: "Fired when team-wide UX preferences change (e.g., bossBattlesEnabled toggled)", category: "team" },
2868
+ "ticket.assigned": { label: "Ticket Assigned", description: "Fired when a ticket is assigned to an agent", category: "tickets" },
2869
+ "ticket.closed": { label: "Ticket Closed/Resolved", description: "Fired when a ticket is resolved or closed", category: "tickets" },
2870
+ "ticket.created": { label: "New Ticket Created", description: "Fired when a new ticket is created via app, widget, API, or email", category: "tickets" },
2871
+ "ticket.deleted": { label: "Ticket Deleted", description: "Fired when a ticket is deleted via app or API", category: "tickets" },
2872
+ "ticket.message_added": { label: "New Message on Ticket", description: "Fired when a new message is added to a ticket", category: "tickets" },
2873
+ "ticket.updated": { label: "Ticket Updated", description: "Fired when a ticket status, priority, or assignment changes", category: "tickets" }
2874
+ };
2875
+
2425
2876
  // src/index.ts
2426
2877
  var CStarClient = class {
2427
2878
  constructor(config) {
@@ -2438,6 +2889,7 @@ var CStarClient = class {
2438
2889
  };
2439
2890
  this.members = new MembersResource(this._httpClient);
2440
2891
  this.settings = new SettingsResource(this._httpClient);
2892
+ this.preferences = new PreferencesResource(this._httpClient);
2441
2893
  this.notifications = new NotificationsResource(this._httpClient);
2442
2894
  this.mentions = new MentionsResource(this._httpClient);
2443
2895
  this.attachments = new AttachmentsResource(this._httpClient);
@@ -2521,5 +2973,7 @@ var CStarClient = class {
2521
2973
  CStarValidationError,
2522
2974
  ErrorType,
2523
2975
  OfflineQueue,
2524
- Subscription
2976
+ Subscription,
2977
+ WEBHOOK_EVENT_CATALOG,
2978
+ WEBHOOK_EVENT_SAMPLES
2525
2979
  });