@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.
@@ -1,99 +1,398 @@
1
- /** Metadata: string key-value pairs. Max 50 keys, 40-char keys, 500-char values. */
2
- type Metadata = Record<string, string>;
3
-
4
- /** A message on a ticket. */
5
- interface Message {
6
- id: string;
7
- object: 'message';
8
- sender: 'customer' | 'agent' | 'system';
9
- content: string;
10
- senderId: string | null;
11
- senderName: string | null;
12
- senderAvatarUrl: string | null;
13
- createdAt: string;
14
- mergedFromShortId: string | null;
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';
3
+ /** Payload for `article.created` events. */
4
+ interface ArticleCreatedPayload {
5
+ article: {
6
+ id: string;
7
+ title: string;
8
+ slug: string;
9
+ is_public: boolean;
10
+ created_at: string;
11
+ };
15
12
  }
16
-
17
- /** A cStar support ticket. */
18
- interface Ticket {
13
+ /** Payload for `article.deleted` events. */
14
+ interface ArticleDeletedPayload {
19
15
  id: string;
20
- object: 'ticket';
21
- title: string;
22
- priority: 'low' | 'normal' | 'high' | 'urgent';
23
- status: string;
24
- customerId: string | null;
25
- customerName: string | null;
26
- assignedTo: string | null;
27
- tags: string[];
28
- notes: string | null;
29
- messageCount: number;
30
- responseDeadline: string | null;
31
- resolutionDeadline: string | null;
32
- firstResponseAt: string | null;
33
- responseTier: string | null;
34
- resolutionTier: string | null;
35
- slaPaused: boolean;
36
- metadata: Metadata;
37
- createdAt: string;
38
- closedAt: string | null;
39
- updatedAt: string;
40
- /** Present when expand includes 'messages' or on single-ticket GET. */
41
- messages?: Message[];
42
- /** Present when expand includes 'customer'. */
43
- customer?: TicketCustomerSummary | null;
44
- }
45
- /** Inline customer summary when expanding on a ticket. */
46
- interface TicketCustomerSummary {
47
- id: string;
48
- object: 'customer';
49
- name: string;
50
- email: string;
51
- sentiment: string;
52
- status: string;
53
16
  }
54
-
55
- /** A cStar customer. */
56
- interface Customer {
17
+ /** Payload for `article.published` events. */
18
+ interface ArticlePublishedPayload {
19
+ article: {
20
+ id: string;
21
+ title: string;
22
+ slug: string;
23
+ is_public: boolean;
24
+ published_at: string;
25
+ };
26
+ }
27
+ /** Payload for `article.updated` events. */
28
+ interface ArticleUpdatedPayload {
29
+ article: {
30
+ id: string;
31
+ title: string;
32
+ slug: string;
33
+ is_public: boolean;
34
+ };
35
+ }
36
+ /** Payload for `boss.damaged` events. */
37
+ interface BossDamagedPayload {
38
+ boss: {
39
+ id: string;
40
+ current_hp: number;
41
+ };
42
+ damage: number;
43
+ by: {
44
+ agent_id: string;
45
+ name: string;
46
+ };
47
+ }
48
+ /** Payload for `boss.defeated` events. */
49
+ interface BossDefeatedPayload {
50
+ boss: {
51
+ id: string;
52
+ name: string;
53
+ };
54
+ final_blow_by: {
55
+ agent_id: string;
56
+ name: string;
57
+ };
58
+ team_xp_awarded: number;
59
+ }
60
+ /** Payload for `boss.spawned` events. */
61
+ interface BossSpawnedPayload {
62
+ boss: {
63
+ id: string;
64
+ name: string;
65
+ level: number;
66
+ max_hp: number;
67
+ };
68
+ }
69
+ /** Payload for `community_post.commented` events. */
70
+ interface CommunityPostCommentedPayload {
71
+ comment: {
72
+ id: string;
73
+ post_id: string;
74
+ content: string;
75
+ author_id: string;
76
+ created_at: string;
77
+ };
78
+ }
79
+ /** Payload for `community_post.created` events. */
80
+ interface CommunityPostCreatedPayload {
81
+ post: {
82
+ id: string;
83
+ prefixed_id: string;
84
+ title: string;
85
+ status: string;
86
+ visibility: string;
87
+ topic: string;
88
+ created_at: string;
89
+ };
90
+ }
91
+ /** Payload for `community_post.deleted` events. */
92
+ interface CommunityPostDeletedPayload {
93
+ post: {
94
+ id: string;
95
+ prefixed_id?: string;
96
+ title?: string;
97
+ };
98
+ }
99
+ /** Payload for `community_post.status_changed` events. */
100
+ interface CommunityPostStatusChangedPayload {
101
+ post: {
102
+ id: string;
103
+ title: string;
104
+ status: string;
105
+ visibility: string;
106
+ };
107
+ }
108
+ /** Payload for `community_post.updated` events. */
109
+ interface CommunityPostUpdatedPayload {
110
+ post: {
111
+ id: string;
112
+ title: string;
113
+ status: string;
114
+ visibility: string;
115
+ };
116
+ }
117
+ /** Payload for `community_post.voted` events. */
118
+ interface CommunityPostVotedPayload {
119
+ post: {
120
+ id: string;
121
+ vote_count: number;
122
+ };
123
+ voter: {
124
+ id: string;
125
+ };
126
+ direction: string;
127
+ }
128
+ /** Payload for `customer.created` events. */
129
+ interface CustomerCreatedPayload {
130
+ customer: {
131
+ id: string;
132
+ name: string;
133
+ email: string;
134
+ status: string;
135
+ tags: Array<string>;
136
+ created_at: string;
137
+ };
138
+ }
139
+ /** Payload for `customer.deleted` events. */
140
+ interface CustomerDeletedPayload {
57
141
  id: string;
58
- object: 'customer';
59
- name: string;
60
- email: string;
61
- sentiment: string;
62
- status: string;
63
- tags: string[];
64
- notes: string | null;
65
- customFields: Record<string, unknown>;
66
- ticketCount: number;
67
- metadata: Metadata;
68
- createdAt: string;
69
- updatedAt: string;
70
142
  }
71
-
72
- /** A cStar knowledge base article. */
73
- interface Article {
143
+ /** Payload for `customer.updated` events. */
144
+ interface CustomerUpdatedPayload {
145
+ customer: {
146
+ id: string;
147
+ name: string;
148
+ email: string;
149
+ status: string;
150
+ tags: Array<string>;
151
+ };
152
+ changes: {
153
+ tags: {
154
+ from: Array<string>;
155
+ to: Array<string>;
156
+ };
157
+ };
158
+ }
159
+ /** Payload for `customer_group.created` events. */
160
+ interface CustomerGroupCreatedPayload {
161
+ group: {
162
+ id: string;
163
+ name: string;
164
+ color: string;
165
+ member_count: number;
166
+ };
167
+ }
168
+ /** Payload for `customer_group.deleted` events. */
169
+ interface CustomerGroupDeletedPayload {
170
+ customer_group: {
171
+ id: string;
172
+ };
173
+ }
174
+ /** Payload for `customer_group.updated` events. */
175
+ interface CustomerGroupUpdatedPayload {
176
+ group: {
177
+ id: string;
178
+ name: string;
179
+ color: string;
180
+ member_count: number;
181
+ };
182
+ }
183
+ /** Payload for `player.achievement_unlocked` events. */
184
+ interface PlayerAchievementUnlockedPayload {
185
+ player: {
186
+ agent_id: string;
187
+ name: string;
188
+ };
189
+ achievement: {
190
+ id: string;
191
+ name: string;
192
+ xp: number;
193
+ };
194
+ }
195
+ /** Payload for `player.level_up` events. */
196
+ interface PlayerLevelUpPayload {
197
+ player: {
198
+ agent_id: string;
199
+ name: string;
200
+ };
201
+ level: {
202
+ from: number;
203
+ to: number;
204
+ };
205
+ title_unlocked: string;
206
+ }
207
+ /** Payload for `player.quest_completed` events. */
208
+ interface PlayerQuestCompletedPayload {
209
+ player: {
210
+ agent_id: string;
211
+ name: string;
212
+ };
213
+ quest: {
214
+ id: string;
215
+ name: string;
216
+ xp: number;
217
+ };
218
+ }
219
+ /** Payload for `player.streak_milestone` events. */
220
+ interface PlayerStreakMilestonePayload {
221
+ player: {
222
+ agent_id: string;
223
+ name: string;
224
+ };
225
+ streak_days: number;
226
+ milestone: number;
227
+ }
228
+ /** Payload for `player.xp_gained` events. */
229
+ interface PlayerXpGainedPayload {
230
+ player: {
231
+ agent_id: string;
232
+ name: string;
233
+ };
234
+ amount: number;
235
+ reason: string;
236
+ ticket_id: string;
237
+ }
238
+ /** Payload for `social.high_five_sent` events. */
239
+ interface SocialHighFiveSentPayload {
240
+ from_team: {
241
+ id: string;
242
+ name: string;
243
+ };
244
+ to_team: {
245
+ id: string;
246
+ name: string;
247
+ };
248
+ message: string;
249
+ }
250
+ /** Payload for `social.one_up_sent` events. */
251
+ interface SocialOneUpSentPayload {
252
+ from: {
253
+ agent_id: string;
254
+ name: string;
255
+ };
256
+ to: {
257
+ agent_id: string;
258
+ name: string;
259
+ };
260
+ ticket_id: string;
261
+ message: string;
262
+ }
263
+ /** Payload for `survey.submitted` events. */
264
+ interface SurveySubmittedPayload {
265
+ survey: {
266
+ id: string;
267
+ ticket_id: string;
268
+ score: number;
269
+ comment: string;
270
+ submitted_at: string;
271
+ };
272
+ customer: {
273
+ id: string;
274
+ email: string;
275
+ };
276
+ }
277
+ /** Payload for `ticket.assigned` events. */
278
+ interface TicketAssignedPayload {
279
+ ticket: {
280
+ id: string;
281
+ prefixed_id: string;
282
+ };
283
+ assignee: {
284
+ id: string;
285
+ name: string;
286
+ email: string;
287
+ };
288
+ previous_assignee: null;
289
+ }
290
+ /** Payload for `ticket.closed` events. */
291
+ interface TicketClosedPayload {
292
+ ticket: {
293
+ id: string;
294
+ prefixed_id: string;
295
+ title: string;
296
+ status: string;
297
+ priority: string;
298
+ channel: string;
299
+ resolved_at: string;
300
+ };
301
+ }
302
+ /** Payload for `ticket.created` events. */
303
+ interface TicketCreatedPayload {
304
+ ticket: {
305
+ id: string;
306
+ prefixed_id: string;
307
+ title: string;
308
+ status: string;
309
+ priority: string;
310
+ channel: string;
311
+ customer_id: string;
312
+ created_at: string;
313
+ };
314
+ customer: {
315
+ id: string;
316
+ name: string;
317
+ email: string;
318
+ };
319
+ }
320
+ /** Payload for `ticket.deleted` events. */
321
+ interface TicketDeletedPayload {
74
322
  id: string;
75
- object: 'article';
76
- title: string;
77
- slug: string | null;
78
- excerpt: string | null;
79
- content: string | null;
80
- categoryId: string | null;
81
- status: 'draft' | 'published';
82
- tags: string[];
83
- notes: string | null;
84
- viewCount: number;
85
- useCount: number;
86
- readTime: string;
87
- isPublic: boolean;
88
- publishedAt: string | null;
89
- metaDescription: string | null;
90
- metadata: Metadata;
91
- createdAt: string;
92
- updatedAt: string;
93
323
  }
94
-
95
- /** All webhook event types supported by cStar. */
96
- type WebhookEventType = 'ticket.created' | 'ticket.updated' | 'ticket.closed' | 'ticket.message_added' | 'customer.created' | 'customer.updated' | 'article.created' | 'article.published' | 'article.updated' | 'boss.spawned' | 'boss.defeated' | 'player.level_up' | 'achievement.unlocked' | 'survey.submitted';
324
+ /** Payload for `ticket.message_added` events. */
325
+ interface TicketMessageAddedPayload {
326
+ ticket: {
327
+ id: string;
328
+ dashboard_url: string | null;
329
+ };
330
+ message: {
331
+ id: string;
332
+ sender: string;
333
+ sender_name: string | null;
334
+ content: string;
335
+ created_at: string;
336
+ };
337
+ customer?: {
338
+ id: string;
339
+ name: string | null;
340
+ email: string | null;
341
+ };
342
+ }
343
+ /** Payload for `ticket.updated` events. */
344
+ interface TicketUpdatedPayload {
345
+ ticket: {
346
+ id: string;
347
+ prefixed_id: string;
348
+ title: string;
349
+ status: string;
350
+ priority: string;
351
+ channel: string;
352
+ };
353
+ changes: {
354
+ priority: {
355
+ from: string;
356
+ to: string;
357
+ };
358
+ };
359
+ }
360
+ /** Maps each event type to its payload interface — used internally for the discriminated union. */
361
+ interface WebhookEventDataMap {
362
+ 'article.created': ArticleCreatedPayload;
363
+ 'article.deleted': ArticleDeletedPayload;
364
+ 'article.published': ArticlePublishedPayload;
365
+ 'article.updated': ArticleUpdatedPayload;
366
+ 'boss.damaged': BossDamagedPayload;
367
+ 'boss.defeated': BossDefeatedPayload;
368
+ 'boss.spawned': BossSpawnedPayload;
369
+ 'community_post.commented': CommunityPostCommentedPayload;
370
+ 'community_post.created': CommunityPostCreatedPayload;
371
+ 'community_post.deleted': CommunityPostDeletedPayload;
372
+ 'community_post.status_changed': CommunityPostStatusChangedPayload;
373
+ 'community_post.updated': CommunityPostUpdatedPayload;
374
+ 'community_post.voted': CommunityPostVotedPayload;
375
+ 'customer.created': CustomerCreatedPayload;
376
+ 'customer.deleted': CustomerDeletedPayload;
377
+ 'customer.updated': CustomerUpdatedPayload;
378
+ 'customer_group.created': CustomerGroupCreatedPayload;
379
+ 'customer_group.deleted': CustomerGroupDeletedPayload;
380
+ 'customer_group.updated': CustomerGroupUpdatedPayload;
381
+ 'player.achievement_unlocked': PlayerAchievementUnlockedPayload;
382
+ 'player.level_up': PlayerLevelUpPayload;
383
+ 'player.quest_completed': PlayerQuestCompletedPayload;
384
+ 'player.streak_milestone': PlayerStreakMilestonePayload;
385
+ 'player.xp_gained': PlayerXpGainedPayload;
386
+ 'social.high_five_sent': SocialHighFiveSentPayload;
387
+ 'social.one_up_sent': SocialOneUpSentPayload;
388
+ 'survey.submitted': SurveySubmittedPayload;
389
+ 'ticket.assigned': TicketAssignedPayload;
390
+ 'ticket.closed': TicketClosedPayload;
391
+ 'ticket.created': TicketCreatedPayload;
392
+ 'ticket.deleted': TicketDeletedPayload;
393
+ 'ticket.message_added': TicketMessageAddedPayload;
394
+ 'ticket.updated': TicketUpdatedPayload;
395
+ }
97
396
  /** A webhook event delivered to your endpoint. */
98
397
  interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
99
398
  /** Unique event ID (idempotency key). */
@@ -105,19 +404,8 @@ interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
105
404
  /** Team that owns this event. */
106
405
  team_id: string;
107
406
  /** Event-specific payload. */
108
- data: WebhookEventData<T>;
109
- }
110
- /** Discriminated union mapping event types to their data payloads. */
111
- type WebhookEventData<T extends WebhookEventType> = T extends 'ticket.created' | 'ticket.updated' | 'ticket.closed' ? {
112
- ticket: Ticket;
113
- } : T extends 'ticket.message_added' ? {
114
- ticket: Ticket;
115
- message: Message;
116
- } : T extends 'customer.created' | 'customer.updated' ? {
117
- customer: Customer;
118
- } : T extends 'article.created' | 'article.published' | 'article.updated' ? {
119
- article: Article;
120
- } : Record<string, unknown>;
407
+ data: WebhookEventDataMap[T];
408
+ }
121
409
 
122
410
  /** Thrown when webhook signature verification fails. */
123
411
  declare class WebhookSignatureVerificationError extends Error {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cstar.help/js",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Official TypeScript SDK for the cStar customer support platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -76,6 +76,16 @@
76
76
  "types": "./dist/proactive/index.d.cts",
77
77
  "default": "./dist/proactive/index.cjs"
78
78
  }
79
+ },
80
+ "./quickhelp": {
81
+ "import": {
82
+ "types": "./dist/quickhelp/index.d.ts",
83
+ "default": "./dist/quickhelp/index.js"
84
+ },
85
+ "require": {
86
+ "types": "./dist/quickhelp/index.d.cts",
87
+ "default": "./dist/quickhelp/index.cjs"
88
+ }
79
89
  }
80
90
  },
81
91
  "files": [