@cstar.help/js 0.16.1 → 0.17.2

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,452 +1,6 @@
1
- /** Every webhook event type cStar can dispatch. */
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
- }
13
- /** Payload for `article.created` events. */
14
- interface ArticleCreatedPayload {
15
- article: {
16
- id: string;
17
- title: string;
18
- slug: string;
19
- is_public: boolean;
20
- created_at: string;
21
- };
22
- }
23
- /** Payload for `article.deleted` events. */
24
- interface ArticleDeletedPayload {
25
- id: string;
26
- }
27
- /** Payload for `article.published` events. */
28
- interface ArticlePublishedPayload {
29
- article: {
30
- id: string;
31
- title: string;
32
- slug: string;
33
- is_public: boolean;
34
- published_at: string;
35
- };
36
- }
37
- /** Payload for `article.updated` events. */
38
- interface ArticleUpdatedPayload {
39
- article: {
40
- id: string;
41
- title: string;
42
- slug: string;
43
- is_public: boolean;
44
- };
45
- }
46
- /** Payload for `boss.damaged` events. */
47
- interface BossDamagedPayload {
48
- boss: {
49
- id: string;
50
- current_hp: number;
51
- };
52
- damage: number;
53
- by: {
54
- agent_id: string;
55
- name: string;
56
- };
57
- }
58
- /** Payload for `boss.defeated` events. */
59
- interface BossDefeatedPayload {
60
- boss: {
61
- id: string;
62
- name: string;
63
- };
64
- final_blow_by: {
65
- agent_id: string;
66
- name: string;
67
- };
68
- team_xp_awarded: number;
69
- }
70
- /** Payload for `boss.spawned` events. */
71
- interface BossSpawnedPayload {
72
- boss: {
73
- id: string;
74
- name: string;
75
- level: number;
76
- max_hp: number;
77
- };
78
- }
79
- /** Payload for `community_post.commented` events. */
80
- interface CommunityPostCommentedPayload {
81
- comment: {
82
- id: string;
83
- post_id: string;
84
- content: string;
85
- author_id: string;
86
- created_at: string;
87
- };
88
- }
89
- /** Payload for `community_post.created` events. */
90
- interface CommunityPostCreatedPayload {
91
- post: {
92
- id: string;
93
- prefixed_id: string;
94
- title: string;
95
- status: string;
96
- visibility: string;
97
- topic: string;
98
- created_at: string;
99
- };
100
- }
101
- /** Payload for `community_post.deleted` events. */
102
- interface CommunityPostDeletedPayload {
103
- post: {
104
- id: string;
105
- prefixed_id?: string;
106
- title?: string;
107
- };
108
- }
109
- /** Payload for `community_post.status_changed` events. */
110
- interface CommunityPostStatusChangedPayload {
111
- post: {
112
- id: string;
113
- title: string;
114
- status: string;
115
- visibility: string;
116
- };
117
- }
118
- /** Payload for `community_post.updated` events. */
119
- interface CommunityPostUpdatedPayload {
120
- post: {
121
- id: string;
122
- title: string;
123
- status: string;
124
- visibility: string;
125
- };
126
- }
127
- /** Payload for `community_post.voted` events. */
128
- interface CommunityPostVotedPayload {
129
- post: {
130
- id: string;
131
- vote_count: number;
132
- };
133
- voter: {
134
- id: string;
135
- };
136
- direction: string;
137
- }
138
- /** Payload for `customer.created` events. */
139
- interface CustomerCreatedPayload {
140
- customer: {
141
- id: string;
142
- name: string;
143
- email: string;
144
- status: string;
145
- tags: Array<string>;
146
- created_at: string;
147
- };
148
- }
149
- /** Payload for `customer.deleted` events. */
150
- interface CustomerDeletedPayload {
151
- id: string;
152
- }
153
- /** Payload for `customer.updated` events. */
154
- interface CustomerUpdatedPayload {
155
- customer: {
156
- id: string;
157
- name: string;
158
- email: string;
159
- status: string;
160
- tags: Array<string>;
161
- };
162
- changes: {
163
- tags: {
164
- from: Array<string>;
165
- to: Array<string>;
166
- };
167
- };
168
- }
169
- /** Payload for `customer_group.created` events. */
170
- interface CustomerGroupCreatedPayload {
171
- group: {
172
- id: string;
173
- name: string;
174
- color: string;
175
- member_count: number;
176
- };
177
- }
178
- /** Payload for `customer_group.deleted` events. */
179
- interface CustomerGroupDeletedPayload {
180
- customer_group: {
181
- id: string;
182
- };
183
- }
184
- /** Payload for `customer_group.updated` events. */
185
- interface CustomerGroupUpdatedPayload {
186
- group: {
187
- id: string;
188
- name: string;
189
- color: string;
190
- member_count: number;
191
- };
192
- }
193
- /** Payload for `player.achievement_unlocked` events. */
194
- interface PlayerAchievementUnlockedPayload {
195
- player: {
196
- agent_id: string;
197
- name: string;
198
- };
199
- achievement: {
200
- id: string;
201
- name: string;
202
- xp: number;
203
- };
204
- }
205
- /** Payload for `player.level_up` events. */
206
- interface PlayerLevelUpPayload {
207
- player: {
208
- agent_id: string;
209
- name: string;
210
- };
211
- level: {
212
- from: number;
213
- to: number;
214
- };
215
- title_unlocked: string;
216
- }
217
- /** Payload for `player.quest_completed` events. */
218
- interface PlayerQuestCompletedPayload {
219
- player: {
220
- agent_id: string;
221
- name: string;
222
- };
223
- quest: {
224
- id: string;
225
- name: string;
226
- xp: number;
227
- };
228
- }
229
- /** Payload for `player.streak_milestone` events. */
230
- interface PlayerStreakMilestonePayload {
231
- player: {
232
- agent_id: string;
233
- name: string;
234
- };
235
- streak_days: number;
236
- milestone: number;
237
- }
238
- /** Payload for `player.xp_gained` events. */
239
- interface PlayerXpGainedPayload {
240
- player: {
241
- agent_id: string;
242
- name: string;
243
- };
244
- amount: number;
245
- reason: string;
246
- ticket_id: string;
247
- }
248
- /** Payload for `social.high_five_sent` events. */
249
- interface SocialHighFiveSentPayload {
250
- from_team: {
251
- id: string;
252
- name: string;
253
- };
254
- to_team: {
255
- id: string;
256
- name: string;
257
- };
258
- message: string;
259
- }
260
- /** Payload for `social.one_up_sent` events. */
261
- interface SocialOneUpSentPayload {
262
- from: {
263
- agent_id: string;
264
- name: string;
265
- };
266
- to: {
267
- agent_id: string;
268
- name: string;
269
- };
270
- ticket_id: string;
271
- message: string;
272
- }
273
- /** Payload for `survey.submitted` events. */
274
- interface SurveySubmittedPayload {
275
- survey: {
276
- id: string;
277
- ticket_id: string;
278
- score: number;
279
- comment: string;
280
- submitted_at: string;
281
- };
282
- customer: {
283
- id: string;
284
- email: string;
285
- };
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
- }
295
- /** Payload for `ticket.assigned` events. */
296
- interface TicketAssignedPayload {
297
- ticket: {
298
- id: string;
299
- prefixed_id: string;
300
- };
301
- assignee: {
302
- id: string;
303
- name: string;
304
- email: string;
305
- };
306
- previous_assignee: null;
307
- }
308
- /** Payload for `ticket.closed` events. */
309
- interface TicketClosedPayload {
310
- ticket: {
311
- id: string;
312
- prefixed_id: string;
313
- title: string;
314
- status: string;
315
- priority: string;
316
- channel: string;
317
- resolved_at: string;
318
- };
319
- changes?: Record<string, {
320
- from: string;
321
- to: string;
322
- }>;
323
- }
324
- /** Payload for `ticket.created` events. */
325
- interface TicketCreatedPayload {
326
- ticket: {
327
- id: string;
328
- prefixed_id: string;
329
- title: string;
330
- status: string;
331
- priority: string;
332
- channel: string;
333
- customer_id: string;
334
- created_at: string;
335
- };
336
- customer: {
337
- id: string;
338
- name: string;
339
- email: string;
340
- };
341
- }
342
- /** Payload for `ticket.deleted` events. */
343
- interface TicketDeletedPayload {
344
- id: string;
345
- }
346
- /** Payload for `ticket.message_added` events. */
347
- interface TicketMessageAddedPayload {
348
- ticket: {
349
- id: string;
350
- dashboard_url: string | null;
351
- };
352
- message: {
353
- id: string;
354
- sender: string;
355
- sender_name: string | null;
356
- content: string;
357
- created_at: string;
358
- };
359
- customer?: {
360
- id: string;
361
- name: string | null;
362
- email: string | null;
363
- };
364
- }
365
- /** Payload for `ticket.updated` events. */
366
- interface TicketUpdatedPayload {
367
- ticket: {
368
- id: string;
369
- prefixed_id: string;
370
- title: string;
371
- status: string;
372
- priority: string;
373
- channel: string;
374
- };
375
- changes?: Record<string, {
376
- from: string;
377
- to: string;
378
- } | {
379
- from: Array<string>;
380
- to: Array<string>;
381
- }>;
382
- }
383
- /** Maps each event type to its payload interface — used internally for the discriminated union. */
384
- interface WebhookEventDataMap {
385
- 'agent.preferences_updated': AgentPreferencesUpdatedPayload;
386
- 'article.created': ArticleCreatedPayload;
387
- 'article.deleted': ArticleDeletedPayload;
388
- 'article.published': ArticlePublishedPayload;
389
- 'article.updated': ArticleUpdatedPayload;
390
- 'boss.damaged': BossDamagedPayload;
391
- 'boss.defeated': BossDefeatedPayload;
392
- 'boss.spawned': BossSpawnedPayload;
393
- 'community_post.commented': CommunityPostCommentedPayload;
394
- 'community_post.created': CommunityPostCreatedPayload;
395
- 'community_post.deleted': CommunityPostDeletedPayload;
396
- 'community_post.status_changed': CommunityPostStatusChangedPayload;
397
- 'community_post.updated': CommunityPostUpdatedPayload;
398
- 'community_post.voted': CommunityPostVotedPayload;
399
- 'customer.created': CustomerCreatedPayload;
400
- 'customer.deleted': CustomerDeletedPayload;
401
- 'customer.updated': CustomerUpdatedPayload;
402
- 'customer_group.created': CustomerGroupCreatedPayload;
403
- 'customer_group.deleted': CustomerGroupDeletedPayload;
404
- 'customer_group.updated': CustomerGroupUpdatedPayload;
405
- 'player.achievement_unlocked': PlayerAchievementUnlockedPayload;
406
- 'player.level_up': PlayerLevelUpPayload;
407
- 'player.quest_completed': PlayerQuestCompletedPayload;
408
- 'player.streak_milestone': PlayerStreakMilestonePayload;
409
- 'player.xp_gained': PlayerXpGainedPayload;
410
- 'social.high_five_sent': SocialHighFiveSentPayload;
411
- 'social.one_up_sent': SocialOneUpSentPayload;
412
- 'survey.submitted': SurveySubmittedPayload;
413
- 'team.preferences_updated': TeamPreferencesUpdatedPayload;
414
- 'ticket.assigned': TicketAssignedPayload;
415
- 'ticket.closed': TicketClosedPayload;
416
- 'ticket.created': TicketCreatedPayload;
417
- 'ticket.deleted': TicketDeletedPayload;
418
- 'ticket.message_added': TicketMessageAddedPayload;
419
- 'ticket.updated': TicketUpdatedPayload;
420
- }
421
- /** A webhook event delivered to your endpoint. */
422
- interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
423
- /** Unique event ID (idempotency key). */
424
- id: string;
425
- /** Event type. */
426
- type: T;
427
- /** When the event was created (ISO 8601). */
428
- created_at: string;
429
- /** Team that owns this event. */
430
- team_id: string;
431
- /** Event-specific payload. */
432
- data: WebhookEventDataMap[T];
433
- }
434
-
435
- /** Default replay window for Stripe-style signatures: 5 minutes (300s). */
436
- declare const DEFAULT_TOLERANCE_SECONDS = 300;
437
- /** Options for signature verification — accepted by both verify and construct calls. */
438
- interface VerifyOptions {
439
- /**
440
- * Maximum age (in seconds) of a Stripe-style timestamp before the signature
441
- * is rejected as expired. Defaults to {@link DEFAULT_TOLERANCE_SECONDS}.
442
- * Ignored for legacy `sha256=<hex>` signatures (which carry no timestamp).
443
- */
444
- tolerance?: number;
445
- }
446
- /** Thrown when webhook signature verification fails. */
447
- declare class WebhookSignatureVerificationError extends Error {
448
- constructor(message: string);
449
- }
1
+ import { d as WebhookEvent } from '../webhookEvents-1N2i2GcQ.js';
2
+ import { VerifyOptions } from './index.js';
3
+ export { DEFAULT_TOLERANCE_SECONDS, WebhookSignatureVerificationError } from './index.js';
450
4
 
451
5
  /**
452
6
  * Sign a payload in Stripe-style format `t=<unix>,v1=<hex>` (Node-only,
@@ -480,4 +34,4 @@ declare function constructEvent(rawBody: string, signature: string, secret: stri
480
34
  */
481
35
  declare function verifySignature(rawBody: string, signature: string, secret: string, options?: VerifyOptions): boolean;
482
36
 
483
- export { DEFAULT_TOLERANCE_SECONDS, type VerifyOptions, type WebhookEvent, WebhookSignatureVerificationError, constructEvent, signPayloadStripe, verifySignature };
37
+ export { VerifyOptions, WebhookEvent, constructEvent, signPayloadStripe, verifySignature };