@cstar.help/js 0.15.1 → 0.16.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/index.cjs +478 -7
- package/dist/index.d.cts +129 -6
- package/dist/index.d.ts +129 -6
- package/dist/index.js +475 -6
- package/dist/webhook/index.d.cts +21 -1
- package/dist/webhook/index.d.ts +21 -1
- package/dist/webhook/node.d.cts +21 -1
- package/dist/webhook/node.d.ts +21 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -262,7 +262,7 @@ var HttpClient = class {
|
|
|
262
262
|
}
|
|
263
263
|
if (typeof config.teamId !== "string" || config.teamId.length === 0) {
|
|
264
264
|
throw new Error(
|
|
265
|
-
"[cStar] CStarClient: teamId is required. Find your team ID in Settings \u2192
|
|
265
|
+
"[cStar] CStarClient: teamId is required. Find your team ID in Settings \u2192 API Keys (Team Identifiers) or via `cstar status`."
|
|
266
266
|
);
|
|
267
267
|
}
|
|
268
268
|
this.config = {
|
|
@@ -316,7 +316,8 @@ var HttpClient = class {
|
|
|
316
316
|
let lastError = null;
|
|
317
317
|
for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
|
|
318
318
|
if (attempt > 0 && lastError) {
|
|
319
|
-
const
|
|
319
|
+
const RATE_LIMIT_RETRY_CAP_MS = 6e4;
|
|
320
|
+
const delay = lastError instanceof CStarRateLimitError ? Math.min(lastError.retryAfter * 1e3, RATE_LIMIT_RETRY_CAP_MS) : this.getBackoffDelay(attempt);
|
|
320
321
|
await this.sleep(delay);
|
|
321
322
|
}
|
|
322
323
|
let response;
|
|
@@ -468,6 +469,15 @@ var CStarRealtime = class {
|
|
|
468
469
|
this.errorHandlers = /* @__PURE__ */ new Set();
|
|
469
470
|
this.connectionHandlers = /* @__PURE__ */ new Set();
|
|
470
471
|
this.lastEventId = null;
|
|
472
|
+
/**
|
|
473
|
+
* Timestamp of the most recently received event, kept as an ISO-8601 string.
|
|
474
|
+
* Sent as `?since=<iso>` on reconnect so the server can replay events missed
|
|
475
|
+
* during the gap. The `id:` field on each SSE message is a prefixed entity
|
|
476
|
+
* ID (`evt_*`), which `new Date(...)` can't parse — passing it as `since`
|
|
477
|
+
* silently skips the replay branch on the server. Track the timestamp
|
|
478
|
+
* separately so reconnects actually catch up. R62.
|
|
479
|
+
*/
|
|
480
|
+
this.lastEventTimestamp = null;
|
|
471
481
|
this.retryCount = 0;
|
|
472
482
|
this.retryTimer = null;
|
|
473
483
|
this._connected = false;
|
|
@@ -577,8 +587,8 @@ var CStarRealtime = class {
|
|
|
577
587
|
if (this.types && this.types.length > 0) {
|
|
578
588
|
params.set("types", this.types.join(","));
|
|
579
589
|
}
|
|
580
|
-
if (this.
|
|
581
|
-
params.set("since", this.
|
|
590
|
+
if (this.lastEventTimestamp) {
|
|
591
|
+
params.set("since", this.lastEventTimestamp);
|
|
582
592
|
}
|
|
583
593
|
const qs = params.toString();
|
|
584
594
|
const url = `${baseUrl}/events/stream${qs ? `?${qs}` : ""}`;
|
|
@@ -641,6 +651,9 @@ var CStarRealtime = class {
|
|
|
641
651
|
}
|
|
642
652
|
try {
|
|
643
653
|
const parsed = JSON.parse(msgEvent.data);
|
|
654
|
+
if (typeof parsed.timestamp === "string" && parsed.timestamp) {
|
|
655
|
+
this.lastEventTimestamp = parsed.timestamp;
|
|
656
|
+
}
|
|
644
657
|
const realtimeEvent = {
|
|
645
658
|
type: parsed.type || type,
|
|
646
659
|
id: msgEvent.lastEventId || "",
|
|
@@ -671,6 +684,8 @@ var CStarRealtime = class {
|
|
|
671
684
|
}
|
|
672
685
|
this.sseToken = null;
|
|
673
686
|
this.sseTokenExpiresAt = 0;
|
|
687
|
+
this.lastEventId = null;
|
|
688
|
+
this.lastEventTimestamp = null;
|
|
674
689
|
this.setConnected(false);
|
|
675
690
|
this.handlers.clear();
|
|
676
691
|
this.anyHandlers.clear();
|
|
@@ -694,6 +709,9 @@ var CStarRealtime = class {
|
|
|
694
709
|
try {
|
|
695
710
|
const parsed = JSON.parse(event.data);
|
|
696
711
|
if (parsed.type === "connected") return;
|
|
712
|
+
if (typeof parsed.timestamp === "string" && parsed.timestamp) {
|
|
713
|
+
this.lastEventTimestamp = parsed.timestamp;
|
|
714
|
+
}
|
|
697
715
|
const realtimeEvent = {
|
|
698
716
|
type: parsed.type,
|
|
699
717
|
id: event.lastEventId || "",
|
|
@@ -1300,10 +1318,31 @@ var InvitesResource = class {
|
|
|
1300
1318
|
return this.client.request("DELETE", `/invites/${inviteId}`);
|
|
1301
1319
|
}
|
|
1302
1320
|
};
|
|
1321
|
+
var MemberPreferencesResource = class {
|
|
1322
|
+
constructor(client) {
|
|
1323
|
+
this.client = client;
|
|
1324
|
+
}
|
|
1325
|
+
/** Get an agent's UX preferences (boring mode, etc.). */
|
|
1326
|
+
async get(memberId) {
|
|
1327
|
+
return this.client.request(
|
|
1328
|
+
"GET",
|
|
1329
|
+
`/members/${memberId}/preferences`
|
|
1330
|
+
);
|
|
1331
|
+
}
|
|
1332
|
+
/** Update an agent's UX preferences. Only provided fields are written. */
|
|
1333
|
+
async update(memberId, params) {
|
|
1334
|
+
return this.client.request(
|
|
1335
|
+
"PATCH",
|
|
1336
|
+
`/members/${memberId}/preferences`,
|
|
1337
|
+
{ body: params }
|
|
1338
|
+
);
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1303
1341
|
var MembersResource = class {
|
|
1304
1342
|
constructor(client) {
|
|
1305
1343
|
this.client = client;
|
|
1306
1344
|
this.invites = new InvitesResource(client);
|
|
1345
|
+
this.preferences = new MemberPreferencesResource(client);
|
|
1307
1346
|
}
|
|
1308
1347
|
/** List all team members. */
|
|
1309
1348
|
async list(params) {
|
|
@@ -1893,7 +1932,7 @@ var AchievementsResource = class {
|
|
|
1893
1932
|
constructor(client) {
|
|
1894
1933
|
this.client = client;
|
|
1895
1934
|
}
|
|
1896
|
-
/** List all achievements with progress. */
|
|
1935
|
+
/** List all achievements with progress. `params.userId` is required. */
|
|
1897
1936
|
async list(params) {
|
|
1898
1937
|
return this.client.request("GET", "/game/achievements", {
|
|
1899
1938
|
query: params
|
|
@@ -2266,6 +2305,23 @@ var BillingResource = class {
|
|
|
2266
2305
|
}
|
|
2267
2306
|
};
|
|
2268
2307
|
|
|
2308
|
+
// src/resources/preferences.ts
|
|
2309
|
+
var PreferencesResource = class {
|
|
2310
|
+
constructor(client) {
|
|
2311
|
+
this.client = client;
|
|
2312
|
+
}
|
|
2313
|
+
/** Get team preferences. */
|
|
2314
|
+
async get() {
|
|
2315
|
+
return this.client.request("GET", "/preferences");
|
|
2316
|
+
}
|
|
2317
|
+
/** Update team preferences. Only provided fields are written. */
|
|
2318
|
+
async update(params) {
|
|
2319
|
+
return this.client.request("PATCH", "/preferences", {
|
|
2320
|
+
body: params
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
};
|
|
2324
|
+
|
|
2269
2325
|
// src/offline.ts
|
|
2270
2326
|
var STORAGE_KEY = "cstar_offline_queue";
|
|
2271
2327
|
var OfflineQueue = class {
|
|
@@ -2383,6 +2439,416 @@ var OfflineQueue = class {
|
|
|
2383
2439
|
}
|
|
2384
2440
|
};
|
|
2385
2441
|
|
|
2442
|
+
// src/types/generated/webhookEvents.ts
|
|
2443
|
+
var WEBHOOK_EVENT_SAMPLES = {
|
|
2444
|
+
"agent.preferences_updated": {
|
|
2445
|
+
"team_id": "team_01H8X9YZ7E0J3K4M5N6U",
|
|
2446
|
+
"member_id": "mem_01H8X9YZ7E0J3K4M5N6U",
|
|
2447
|
+
"agent_id": "agt_01H8X9YZ7E0J3K4M5N6U",
|
|
2448
|
+
"changed": [
|
|
2449
|
+
"boringMode"
|
|
2450
|
+
],
|
|
2451
|
+
"preferences": {
|
|
2452
|
+
"boringMode": true
|
|
2453
|
+
}
|
|
2454
|
+
},
|
|
2455
|
+
"article.created": {
|
|
2456
|
+
"article": {
|
|
2457
|
+
"id": "art_01H8X9YZ7E0J3K4M5N6U",
|
|
2458
|
+
"title": "How to reset your password",
|
|
2459
|
+
"slug": "how-to-reset-your-password",
|
|
2460
|
+
"is_public": false,
|
|
2461
|
+
"created_at": "2026-04-27T18:42:11.000Z"
|
|
2462
|
+
}
|
|
2463
|
+
},
|
|
2464
|
+
"article.deleted": {
|
|
2465
|
+
"id": "art_01H8X9YZ7E0J3K4M5N6U"
|
|
2466
|
+
},
|
|
2467
|
+
"article.published": {
|
|
2468
|
+
"article": {
|
|
2469
|
+
"id": "art_01H8X9YZ7E0J3K4M5N6U",
|
|
2470
|
+
"title": "How to reset your password",
|
|
2471
|
+
"slug": "how-to-reset-your-password",
|
|
2472
|
+
"is_public": true,
|
|
2473
|
+
"published_at": "2026-04-27T19:00:00.000Z"
|
|
2474
|
+
}
|
|
2475
|
+
},
|
|
2476
|
+
"article.updated": {
|
|
2477
|
+
"article": {
|
|
2478
|
+
"id": "art_01H8X9YZ7E0J3K4M5N6U",
|
|
2479
|
+
"title": "How to reset your password (updated)",
|
|
2480
|
+
"slug": "how-to-reset-your-password",
|
|
2481
|
+
"is_public": true
|
|
2482
|
+
}
|
|
2483
|
+
},
|
|
2484
|
+
"boss.damaged": {
|
|
2485
|
+
"boss": {
|
|
2486
|
+
"id": "boss_thunder_drake",
|
|
2487
|
+
"current_hp": 740
|
|
2488
|
+
},
|
|
2489
|
+
"damage": 120,
|
|
2490
|
+
"by": {
|
|
2491
|
+
"agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
|
|
2492
|
+
"name": "Riley"
|
|
2493
|
+
}
|
|
2494
|
+
},
|
|
2495
|
+
"boss.defeated": {
|
|
2496
|
+
"boss": {
|
|
2497
|
+
"id": "boss_thunder_drake",
|
|
2498
|
+
"name": "The Thunder Drake"
|
|
2499
|
+
},
|
|
2500
|
+
"final_blow_by": {
|
|
2501
|
+
"agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
|
|
2502
|
+
"name": "Riley"
|
|
2503
|
+
},
|
|
2504
|
+
"team_xp_awarded": 1500
|
|
2505
|
+
},
|
|
2506
|
+
"boss.spawned": {
|
|
2507
|
+
"boss": {
|
|
2508
|
+
"id": "boss_thunder_drake",
|
|
2509
|
+
"name": "The Thunder Drake",
|
|
2510
|
+
"level": 4,
|
|
2511
|
+
"max_hp": 1200
|
|
2512
|
+
}
|
|
2513
|
+
},
|
|
2514
|
+
"community_post.commented": {
|
|
2515
|
+
"comment": {
|
|
2516
|
+
"id": "cmt_01H8X9YZ7E0J3K4M5N6X",
|
|
2517
|
+
"post_id": "post_01H8X9YZ7E0J3K4M5N6W",
|
|
2518
|
+
"content": "I would love this \u2014 bumping for visibility.",
|
|
2519
|
+
"author_id": "cus_01H8X9YZ7E0J3K4M5N6Q",
|
|
2520
|
+
"created_at": "2026-04-27T18:55:02.000Z"
|
|
2521
|
+
}
|
|
2522
|
+
},
|
|
2523
|
+
"community_post.created": {
|
|
2524
|
+
"post": {
|
|
2525
|
+
"id": "post_01H8X9YZ7E0J3K4M5N6W",
|
|
2526
|
+
"prefixed_id": "IDEA-42",
|
|
2527
|
+
"title": "Add Slack-style threading to tickets",
|
|
2528
|
+
"status": "open",
|
|
2529
|
+
"visibility": "public",
|
|
2530
|
+
"topic": "feature-requests",
|
|
2531
|
+
"created_at": "2026-04-27T18:42:11.000Z"
|
|
2532
|
+
}
|
|
2533
|
+
},
|
|
2534
|
+
"community_post.deleted": {
|
|
2535
|
+
"post": {
|
|
2536
|
+
"id": "post_01H8X9YZ7E0J3K4M5N6W",
|
|
2537
|
+
"prefixed_id": "IDEA-42",
|
|
2538
|
+
"title": "Add Slack-style threading to tickets"
|
|
2539
|
+
}
|
|
2540
|
+
},
|
|
2541
|
+
"community_post.status_changed": {
|
|
2542
|
+
"post": {
|
|
2543
|
+
"id": "post_01H8X9YZ7E0J3K4M5N6W",
|
|
2544
|
+
"title": "Add Slack-style threading to tickets",
|
|
2545
|
+
"status": "planned",
|
|
2546
|
+
"visibility": "public"
|
|
2547
|
+
}
|
|
2548
|
+
},
|
|
2549
|
+
"community_post.updated": {
|
|
2550
|
+
"post": {
|
|
2551
|
+
"id": "post_01H8X9YZ7E0J3K4M5N6W",
|
|
2552
|
+
"title": "Add Slack-style threading to tickets (revised)",
|
|
2553
|
+
"status": "open",
|
|
2554
|
+
"visibility": "public"
|
|
2555
|
+
}
|
|
2556
|
+
},
|
|
2557
|
+
"community_post.voted": {
|
|
2558
|
+
"post": {
|
|
2559
|
+
"id": "post_01H8X9YZ7E0J3K4M5N6W",
|
|
2560
|
+
"vote_count": 13
|
|
2561
|
+
},
|
|
2562
|
+
"voter": {
|
|
2563
|
+
"id": "cus_01H8X9YZ7E0J3K4M5N6Q"
|
|
2564
|
+
},
|
|
2565
|
+
"direction": "up"
|
|
2566
|
+
},
|
|
2567
|
+
"customer.created": {
|
|
2568
|
+
"customer": {
|
|
2569
|
+
"id": "cus_01H8X9YZ7E0J3K4M5N6Q",
|
|
2570
|
+
"name": "Casey Patel",
|
|
2571
|
+
"email": "casey@example.com",
|
|
2572
|
+
"status": "active",
|
|
2573
|
+
"tags": [
|
|
2574
|
+
"trial"
|
|
2575
|
+
],
|
|
2576
|
+
"created_at": "2026-04-27T18:42:11.000Z"
|
|
2577
|
+
}
|
|
2578
|
+
},
|
|
2579
|
+
"customer.deleted": {
|
|
2580
|
+
"id": "cus_01H8X9YZ7E0J3K4M5N6Q"
|
|
2581
|
+
},
|
|
2582
|
+
"customer.updated": {
|
|
2583
|
+
"customer": {
|
|
2584
|
+
"id": "cus_01H8X9YZ7E0J3K4M5N6Q",
|
|
2585
|
+
"name": "Casey Patel",
|
|
2586
|
+
"email": "casey@example.com",
|
|
2587
|
+
"status": "active",
|
|
2588
|
+
"tags": [
|
|
2589
|
+
"trial",
|
|
2590
|
+
"paying"
|
|
2591
|
+
]
|
|
2592
|
+
},
|
|
2593
|
+
"changes": {
|
|
2594
|
+
"tags": {
|
|
2595
|
+
"from": [
|
|
2596
|
+
"trial"
|
|
2597
|
+
],
|
|
2598
|
+
"to": [
|
|
2599
|
+
"trial",
|
|
2600
|
+
"paying"
|
|
2601
|
+
]
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
},
|
|
2605
|
+
"customer_group.created": {
|
|
2606
|
+
"group": {
|
|
2607
|
+
"id": "grp_01H8X9YZ7E0J3K4M5N6T",
|
|
2608
|
+
"name": "Pro Plan",
|
|
2609
|
+
"color": "indigo",
|
|
2610
|
+
"member_count": 0
|
|
2611
|
+
}
|
|
2612
|
+
},
|
|
2613
|
+
"customer_group.deleted": {
|
|
2614
|
+
"customer_group": {
|
|
2615
|
+
"id": "grp_01H8X9YZ7E0J3K4M5N6T"
|
|
2616
|
+
}
|
|
2617
|
+
},
|
|
2618
|
+
"customer_group.updated": {
|
|
2619
|
+
"group": {
|
|
2620
|
+
"id": "grp_01H8X9YZ7E0J3K4M5N6T",
|
|
2621
|
+
"name": "Pro Plan (Annual)",
|
|
2622
|
+
"color": "indigo",
|
|
2623
|
+
"member_count": 38
|
|
2624
|
+
}
|
|
2625
|
+
},
|
|
2626
|
+
"player.achievement_unlocked": {
|
|
2627
|
+
"player": {
|
|
2628
|
+
"agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
|
|
2629
|
+
"name": "Riley"
|
|
2630
|
+
},
|
|
2631
|
+
"achievement": {
|
|
2632
|
+
"id": "first_resolve",
|
|
2633
|
+
"name": "First Resolve",
|
|
2634
|
+
"xp": 50
|
|
2635
|
+
}
|
|
2636
|
+
},
|
|
2637
|
+
"player.level_up": {
|
|
2638
|
+
"player": {
|
|
2639
|
+
"agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
|
|
2640
|
+
"name": "Riley"
|
|
2641
|
+
},
|
|
2642
|
+
"level": {
|
|
2643
|
+
"from": 7,
|
|
2644
|
+
"to": 8
|
|
2645
|
+
},
|
|
2646
|
+
"title_unlocked": "Apprentice Healer"
|
|
2647
|
+
},
|
|
2648
|
+
"player.quest_completed": {
|
|
2649
|
+
"player": {
|
|
2650
|
+
"agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
|
|
2651
|
+
"name": "Riley"
|
|
2652
|
+
},
|
|
2653
|
+
"quest": {
|
|
2654
|
+
"id": "resolve_5_tickets",
|
|
2655
|
+
"name": "Resolve 5 tickets today",
|
|
2656
|
+
"xp": 100
|
|
2657
|
+
}
|
|
2658
|
+
},
|
|
2659
|
+
"player.streak_milestone": {
|
|
2660
|
+
"player": {
|
|
2661
|
+
"agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
|
|
2662
|
+
"name": "Riley"
|
|
2663
|
+
},
|
|
2664
|
+
"streak_days": 5,
|
|
2665
|
+
"milestone": 5
|
|
2666
|
+
},
|
|
2667
|
+
"player.xp_gained": {
|
|
2668
|
+
"player": {
|
|
2669
|
+
"agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
|
|
2670
|
+
"name": "Riley"
|
|
2671
|
+
},
|
|
2672
|
+
"amount": 75,
|
|
2673
|
+
"reason": "ticket.resolved",
|
|
2674
|
+
"ticket_id": "tkt_01H8X9YZ7E0J3K4M5N6P"
|
|
2675
|
+
},
|
|
2676
|
+
"social.high_five_sent": {
|
|
2677
|
+
"from_team": {
|
|
2678
|
+
"id": "team_acme",
|
|
2679
|
+
"name": "Acme Support"
|
|
2680
|
+
},
|
|
2681
|
+
"to_team": {
|
|
2682
|
+
"id": "team_globex",
|
|
2683
|
+
"name": "Globex Support"
|
|
2684
|
+
},
|
|
2685
|
+
"message": "Thanks for the assist!"
|
|
2686
|
+
},
|
|
2687
|
+
"social.one_up_sent": {
|
|
2688
|
+
"from": {
|
|
2689
|
+
"agent_id": "usr_01H8X9YZ7E0J3K4M5N6S",
|
|
2690
|
+
"name": "Riley"
|
|
2691
|
+
},
|
|
2692
|
+
"to": {
|
|
2693
|
+
"agent_id": "usr_01H8X9YZ7E0J3K4M5N6V",
|
|
2694
|
+
"name": "Sam"
|
|
2695
|
+
},
|
|
2696
|
+
"ticket_id": "tkt_01H8X9YZ7E0J3K4M5N6P",
|
|
2697
|
+
"message": "Great empathy on this one"
|
|
2698
|
+
},
|
|
2699
|
+
"survey.submitted": {
|
|
2700
|
+
"survey": {
|
|
2701
|
+
"id": "svy_01H8X9YZ7E0J3K4M5N6Y",
|
|
2702
|
+
"ticket_id": "tkt_01H8X9YZ7E0J3K4M5N6P",
|
|
2703
|
+
"score": 5,
|
|
2704
|
+
"comment": "Resolved fast, thank you!",
|
|
2705
|
+
"submitted_at": "2026-04-27T19:30:00.000Z"
|
|
2706
|
+
},
|
|
2707
|
+
"customer": {
|
|
2708
|
+
"id": "cus_01H8X9YZ7E0J3K4M5N6Q",
|
|
2709
|
+
"email": "casey@example.com"
|
|
2710
|
+
}
|
|
2711
|
+
},
|
|
2712
|
+
"team.preferences_updated": {
|
|
2713
|
+
"team_id": "team_01H8X9YZ7E0J3K4M5N6U",
|
|
2714
|
+
"changed": [
|
|
2715
|
+
"bossBattlesEnabled"
|
|
2716
|
+
],
|
|
2717
|
+
"preferences": {
|
|
2718
|
+
"bossBattlesEnabled": false
|
|
2719
|
+
}
|
|
2720
|
+
},
|
|
2721
|
+
"ticket.assigned": {
|
|
2722
|
+
"ticket": {
|
|
2723
|
+
"id": "tkt_01H8X9YZ7E0J3K4M5N6P",
|
|
2724
|
+
"prefixed_id": "CST-1024"
|
|
2725
|
+
},
|
|
2726
|
+
"assignee": {
|
|
2727
|
+
"id": "usr_01H8X9YZ7E0J3K4M5N6S",
|
|
2728
|
+
"name": "Riley",
|
|
2729
|
+
"email": "riley@acme.test"
|
|
2730
|
+
},
|
|
2731
|
+
"previous_assignee": null
|
|
2732
|
+
},
|
|
2733
|
+
"ticket.closed": {
|
|
2734
|
+
"ticket": {
|
|
2735
|
+
"id": "tkt_01H8X9YZ7E0J3K4M5N6P",
|
|
2736
|
+
"prefixed_id": "CST-1024",
|
|
2737
|
+
"title": "Cannot reset password",
|
|
2738
|
+
"status": "resolved",
|
|
2739
|
+
"priority": "normal",
|
|
2740
|
+
"channel": "widget",
|
|
2741
|
+
"resolved_at": "2026-04-27T19:08:43.000Z"
|
|
2742
|
+
},
|
|
2743
|
+
"changes": {
|
|
2744
|
+
"status": {
|
|
2745
|
+
"from": "open",
|
|
2746
|
+
"to": "resolved"
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
},
|
|
2750
|
+
"ticket.created": {
|
|
2751
|
+
"ticket": {
|
|
2752
|
+
"id": "tkt_01H8X9YZ7E0J3K4M5N6P",
|
|
2753
|
+
"prefixed_id": "CST-1024",
|
|
2754
|
+
"title": "Cannot reset password",
|
|
2755
|
+
"status": "new",
|
|
2756
|
+
"priority": "normal",
|
|
2757
|
+
"channel": "widget",
|
|
2758
|
+
"customer_id": "cus_01H8X9YZ7E0J3K4M5N6Q",
|
|
2759
|
+
"created_at": "2026-04-27T18:42:11.000Z"
|
|
2760
|
+
},
|
|
2761
|
+
"customer": {
|
|
2762
|
+
"id": "cus_01H8X9YZ7E0J3K4M5N6Q",
|
|
2763
|
+
"name": "Casey Patel",
|
|
2764
|
+
"email": "casey@example.com"
|
|
2765
|
+
}
|
|
2766
|
+
},
|
|
2767
|
+
"ticket.deleted": {
|
|
2768
|
+
"id": "CST-1024"
|
|
2769
|
+
},
|
|
2770
|
+
"ticket.message_added": {
|
|
2771
|
+
"ticket": {
|
|
2772
|
+
"id": "tkt_01H8X9YZ7E0J3K4M5N6P",
|
|
2773
|
+
"dashboard_url": "https://www.cstar.help/team/acme/tickets?selected=tkt_01H8X9YZ7E0J3K4M5N6P"
|
|
2774
|
+
},
|
|
2775
|
+
"message": {
|
|
2776
|
+
"id": "msg_01H8X9YZ7E0J3K4M5N6R",
|
|
2777
|
+
"sender": "agent",
|
|
2778
|
+
"sender_name": "Riley",
|
|
2779
|
+
"content": "I just sent a reset link to your inbox \u2014 let me know if it lands.",
|
|
2780
|
+
"created_at": "2026-04-27T18:55:02.000Z"
|
|
2781
|
+
},
|
|
2782
|
+
"customer": {
|
|
2783
|
+
"id": "cus_01H8X9YZ7E0J3K4M5N6Q",
|
|
2784
|
+
"name": "Casey Patel",
|
|
2785
|
+
"email": "casey@example.com"
|
|
2786
|
+
}
|
|
2787
|
+
},
|
|
2788
|
+
"ticket.updated": {
|
|
2789
|
+
"ticket": {
|
|
2790
|
+
"id": "tkt_01H8X9YZ7E0J3K4M5N6P",
|
|
2791
|
+
"prefixed_id": "CST-1024",
|
|
2792
|
+
"title": "Cannot reset password",
|
|
2793
|
+
"status": "open",
|
|
2794
|
+
"priority": "high",
|
|
2795
|
+
"channel": "widget"
|
|
2796
|
+
},
|
|
2797
|
+
"changes": {
|
|
2798
|
+
"priority": {
|
|
2799
|
+
"from": "normal",
|
|
2800
|
+
"to": "high"
|
|
2801
|
+
},
|
|
2802
|
+
"tags": {
|
|
2803
|
+
"from": [
|
|
2804
|
+
"bug"
|
|
2805
|
+
],
|
|
2806
|
+
"to": [
|
|
2807
|
+
"bug",
|
|
2808
|
+
"feature-request"
|
|
2809
|
+
]
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
};
|
|
2814
|
+
var WEBHOOK_EVENT_CATALOG = {
|
|
2815
|
+
"agent.preferences_updated": { label: "Agent Preferences Updated", description: "Fired when an agent's per-user UX preferences change (e.g., boringMode toggled)", category: "team" },
|
|
2816
|
+
"article.created": { label: "New Article Created", description: "Fired when a new Library article is created", category: "articles" },
|
|
2817
|
+
"article.deleted": { label: "Article Deleted", description: "Fired when an article is deleted via app or API", category: "articles" },
|
|
2818
|
+
"article.published": { label: "Article Published", description: "Fired when an article is published to the Public Library", category: "articles" },
|
|
2819
|
+
"article.updated": { label: "Article Updated", description: "Fired when an article content or metadata is modified", category: "articles" },
|
|
2820
|
+
"boss.damaged": { label: "Boss Damaged", description: "Fired when a boss takes damage from a ticket close", category: "gamification" },
|
|
2821
|
+
"boss.defeated": { label: "Boss Defeated", description: "Fired when a boss is defeated by the team", category: "gamification" },
|
|
2822
|
+
"boss.spawned": { label: "Boss Battle Started", description: "Fired when a boss appears for the team", category: "gamification" },
|
|
2823
|
+
"community_post.commented": { label: "New Comment on Post", description: "Fired when a new comment is added to a community post", category: "community" },
|
|
2824
|
+
"community_post.created": { label: "New Community Post", description: "Fired when a new community post is created", category: "community" },
|
|
2825
|
+
"community_post.deleted": { label: "Community Post Deleted", description: "Fired when a community post is deleted", category: "community" },
|
|
2826
|
+
"community_post.status_changed": { label: "Post Status Changed", description: "Fired when a community post status is changed (e.g., Planned, Completed)", category: "community" },
|
|
2827
|
+
"community_post.updated": { label: "Community Post Updated", description: "Fired when a community post is updated", category: "community" },
|
|
2828
|
+
"community_post.voted": { label: "Post Voted On", description: "Fired when a community post receives a vote", category: "community" },
|
|
2829
|
+
"customer.created": { label: "New Customer Added", description: "Fired when a new customer is created", category: "customers" },
|
|
2830
|
+
"customer.deleted": { label: "Customer Deleted", description: "Fired when a customer is deleted via app or API", category: "customers" },
|
|
2831
|
+
"customer.updated": { label: "Customer Updated", description: "Fired when customer details are modified", category: "customers" },
|
|
2832
|
+
"customer_group.created": { label: "New Customer Group", description: "Fired when a customer group is created", category: "customers" },
|
|
2833
|
+
"customer_group.deleted": { label: "Customer Group Deleted", description: "Fired when a customer group is deleted", category: "customers" },
|
|
2834
|
+
"customer_group.updated": { label: "Customer Group Updated", description: "Fired when a customer group is modified", category: "customers" },
|
|
2835
|
+
"player.achievement_unlocked": { label: "Achievement Unlocked", description: "Fired when a player unlocks an achievement", category: "gamification" },
|
|
2836
|
+
"player.level_up": { label: "Player Leveled Up", description: "Fired when a player reaches a new level", category: "gamification" },
|
|
2837
|
+
"player.quest_completed": { label: "Quest Completed", description: "Fired when a player completes a daily quest", category: "gamification" },
|
|
2838
|
+
"player.streak_milestone": { label: "Streak Milestone", description: "Fired when a player hits a streak milestone (3, 5, 10, or 25 days)", category: "gamification" },
|
|
2839
|
+
"player.xp_gained": { label: "XP Gained", description: "Fired when a player earns XP from closing a ticket or quest", category: "gamification" },
|
|
2840
|
+
"social.high_five_sent": { label: "High Five Sent", description: "Fired when a team sends a high five to another team", category: "gamification" },
|
|
2841
|
+
"social.one_up_sent": { label: "One-Up Sent", description: "Fired when a teammate sends a one-up recognition", category: "gamification" },
|
|
2842
|
+
"survey.submitted": { label: "Customer Feedback Received", description: "Fired when a customer submits a CSAT survey response", category: "csat" },
|
|
2843
|
+
"team.preferences_updated": { label: "Team Preferences Updated", description: "Fired when team-wide UX preferences change (e.g., bossBattlesEnabled toggled)", category: "team" },
|
|
2844
|
+
"ticket.assigned": { label: "Ticket Assigned", description: "Fired when a ticket is assigned to an agent", category: "tickets" },
|
|
2845
|
+
"ticket.closed": { label: "Ticket Closed/Resolved", description: "Fired when a ticket is resolved or closed", category: "tickets" },
|
|
2846
|
+
"ticket.created": { label: "New Ticket Created", description: "Fired when a new ticket is created via app, widget, API, or email", category: "tickets" },
|
|
2847
|
+
"ticket.deleted": { label: "Ticket Deleted", description: "Fired when a ticket is deleted via app or API", category: "tickets" },
|
|
2848
|
+
"ticket.message_added": { label: "New Message on Ticket", description: "Fired when a new message is added to a ticket", category: "tickets" },
|
|
2849
|
+
"ticket.updated": { label: "Ticket Updated", description: "Fired when a ticket status, priority, or assignment changes", category: "tickets" }
|
|
2850
|
+
};
|
|
2851
|
+
|
|
2386
2852
|
// src/index.ts
|
|
2387
2853
|
var CStarClient = class {
|
|
2388
2854
|
constructor(config) {
|
|
@@ -2399,6 +2865,7 @@ var CStarClient = class {
|
|
|
2399
2865
|
};
|
|
2400
2866
|
this.members = new MembersResource(this._httpClient);
|
|
2401
2867
|
this.settings = new SettingsResource(this._httpClient);
|
|
2868
|
+
this.preferences = new PreferencesResource(this._httpClient);
|
|
2402
2869
|
this.notifications = new NotificationsResource(this._httpClient);
|
|
2403
2870
|
this.mentions = new MentionsResource(this._httpClient);
|
|
2404
2871
|
this.attachments = new AttachmentsResource(this._httpClient);
|
|
@@ -2481,5 +2948,7 @@ export {
|
|
|
2481
2948
|
CStarValidationError,
|
|
2482
2949
|
ErrorType,
|
|
2483
2950
|
OfflineQueue,
|
|
2484
|
-
Subscription
|
|
2951
|
+
Subscription,
|
|
2952
|
+
WEBHOOK_EVENT_CATALOG,
|
|
2953
|
+
WEBHOOK_EVENT_SAMPLES
|
|
2485
2954
|
};
|
package/dist/webhook/index.d.cts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
/** Every webhook event type cStar can dispatch. */
|
|
2
|
-
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';
|
|
2
|
+
type WebhookEventType = 'agent.preferences_updated' | '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' | 'team.preferences_updated' | 'ticket.assigned' | 'ticket.closed' | 'ticket.created' | 'ticket.deleted' | 'ticket.message_added' | 'ticket.updated';
|
|
3
|
+
/** Payload for `agent.preferences_updated` events. */
|
|
4
|
+
interface AgentPreferencesUpdatedPayload {
|
|
5
|
+
team_id: string;
|
|
6
|
+
member_id: string;
|
|
7
|
+
agent_id: string;
|
|
8
|
+
changed: Array<string>;
|
|
9
|
+
preferences: {
|
|
10
|
+
boringMode: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
3
13
|
/** Payload for `article.created` events. */
|
|
4
14
|
interface ArticleCreatedPayload {
|
|
5
15
|
article: {
|
|
@@ -274,6 +284,14 @@ interface SurveySubmittedPayload {
|
|
|
274
284
|
email: string;
|
|
275
285
|
};
|
|
276
286
|
}
|
|
287
|
+
/** Payload for `team.preferences_updated` events. */
|
|
288
|
+
interface TeamPreferencesUpdatedPayload {
|
|
289
|
+
team_id: string;
|
|
290
|
+
changed: Array<string>;
|
|
291
|
+
preferences: {
|
|
292
|
+
bossBattlesEnabled: boolean;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
277
295
|
/** Payload for `ticket.assigned` events. */
|
|
278
296
|
interface TicketAssignedPayload {
|
|
279
297
|
ticket: {
|
|
@@ -364,6 +382,7 @@ interface TicketUpdatedPayload {
|
|
|
364
382
|
}
|
|
365
383
|
/** Maps each event type to its payload interface — used internally for the discriminated union. */
|
|
366
384
|
interface WebhookEventDataMap {
|
|
385
|
+
'agent.preferences_updated': AgentPreferencesUpdatedPayload;
|
|
367
386
|
'article.created': ArticleCreatedPayload;
|
|
368
387
|
'article.deleted': ArticleDeletedPayload;
|
|
369
388
|
'article.published': ArticlePublishedPayload;
|
|
@@ -391,6 +410,7 @@ interface WebhookEventDataMap {
|
|
|
391
410
|
'social.high_five_sent': SocialHighFiveSentPayload;
|
|
392
411
|
'social.one_up_sent': SocialOneUpSentPayload;
|
|
393
412
|
'survey.submitted': SurveySubmittedPayload;
|
|
413
|
+
'team.preferences_updated': TeamPreferencesUpdatedPayload;
|
|
394
414
|
'ticket.assigned': TicketAssignedPayload;
|
|
395
415
|
'ticket.closed': TicketClosedPayload;
|
|
396
416
|
'ticket.created': TicketCreatedPayload;
|
package/dist/webhook/index.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
/** Every webhook event type cStar can dispatch. */
|
|
2
|
-
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';
|
|
2
|
+
type WebhookEventType = 'agent.preferences_updated' | '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' | 'team.preferences_updated' | 'ticket.assigned' | 'ticket.closed' | 'ticket.created' | 'ticket.deleted' | 'ticket.message_added' | 'ticket.updated';
|
|
3
|
+
/** Payload for `agent.preferences_updated` events. */
|
|
4
|
+
interface AgentPreferencesUpdatedPayload {
|
|
5
|
+
team_id: string;
|
|
6
|
+
member_id: string;
|
|
7
|
+
agent_id: string;
|
|
8
|
+
changed: Array<string>;
|
|
9
|
+
preferences: {
|
|
10
|
+
boringMode: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
3
13
|
/** Payload for `article.created` events. */
|
|
4
14
|
interface ArticleCreatedPayload {
|
|
5
15
|
article: {
|
|
@@ -274,6 +284,14 @@ interface SurveySubmittedPayload {
|
|
|
274
284
|
email: string;
|
|
275
285
|
};
|
|
276
286
|
}
|
|
287
|
+
/** Payload for `team.preferences_updated` events. */
|
|
288
|
+
interface TeamPreferencesUpdatedPayload {
|
|
289
|
+
team_id: string;
|
|
290
|
+
changed: Array<string>;
|
|
291
|
+
preferences: {
|
|
292
|
+
bossBattlesEnabled: boolean;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
277
295
|
/** Payload for `ticket.assigned` events. */
|
|
278
296
|
interface TicketAssignedPayload {
|
|
279
297
|
ticket: {
|
|
@@ -364,6 +382,7 @@ interface TicketUpdatedPayload {
|
|
|
364
382
|
}
|
|
365
383
|
/** Maps each event type to its payload interface — used internally for the discriminated union. */
|
|
366
384
|
interface WebhookEventDataMap {
|
|
385
|
+
'agent.preferences_updated': AgentPreferencesUpdatedPayload;
|
|
367
386
|
'article.created': ArticleCreatedPayload;
|
|
368
387
|
'article.deleted': ArticleDeletedPayload;
|
|
369
388
|
'article.published': ArticlePublishedPayload;
|
|
@@ -391,6 +410,7 @@ interface WebhookEventDataMap {
|
|
|
391
410
|
'social.high_five_sent': SocialHighFiveSentPayload;
|
|
392
411
|
'social.one_up_sent': SocialOneUpSentPayload;
|
|
393
412
|
'survey.submitted': SurveySubmittedPayload;
|
|
413
|
+
'team.preferences_updated': TeamPreferencesUpdatedPayload;
|
|
394
414
|
'ticket.assigned': TicketAssignedPayload;
|
|
395
415
|
'ticket.closed': TicketClosedPayload;
|
|
396
416
|
'ticket.created': TicketCreatedPayload;
|