@paceful/sdk 1.0.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.
@@ -0,0 +1,1052 @@
1
+ import React from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ /**
5
+ * Paceful SDK Types
6
+ */
7
+ interface PacefulConfig {
8
+ apiKey: string;
9
+ baseUrl?: string;
10
+ timeout?: number;
11
+ retries?: number;
12
+ }
13
+ interface RegisterUserParams {
14
+ externalId: string;
15
+ email?: string;
16
+ metadata?: Record<string, unknown>;
17
+ }
18
+ interface PartnerUser {
19
+ id: string;
20
+ externalId: string;
21
+ email?: string;
22
+ metadata?: Record<string, unknown>;
23
+ createdAt: string;
24
+ }
25
+ type MoodLevel = 1 | 2 | 3 | 4 | 5;
26
+ interface LogMoodParams {
27
+ externalId: string;
28
+ mood: MoodLevel;
29
+ note?: string;
30
+ factors?: string[];
31
+ timestamp?: string;
32
+ }
33
+ interface MoodEntry {
34
+ id: string;
35
+ mood: MoodLevel;
36
+ note?: string;
37
+ factors?: string[];
38
+ loggedAt: string;
39
+ }
40
+ interface MoodHistoryParams {
41
+ externalId: string;
42
+ startDate?: string;
43
+ endDate?: string;
44
+ limit?: number;
45
+ }
46
+ interface CreateJournalParams {
47
+ externalId: string;
48
+ content: string;
49
+ promptId?: string;
50
+ mood?: MoodLevel;
51
+ }
52
+ interface JournalEntry {
53
+ id: string;
54
+ content: string;
55
+ promptId?: string;
56
+ mood?: MoodLevel;
57
+ sentimentScore?: number;
58
+ themes?: string[];
59
+ createdAt: string;
60
+ }
61
+ interface JournalHistoryParams {
62
+ externalId: string;
63
+ startDate?: string;
64
+ endDate?: string;
65
+ limit?: number;
66
+ }
67
+ type ERSStage = 'healing' | 'rebuilding' | 'ready';
68
+ interface ERSDimensions {
69
+ emotionalStability: number;
70
+ selfAwareness: number;
71
+ socialConnection: number;
72
+ purposeClarity: number;
73
+ resilienceGrowth: number;
74
+ }
75
+ interface ERSScore {
76
+ userId: string;
77
+ ersScore: number;
78
+ stage: ERSStage;
79
+ dimensions: ERSDimensions;
80
+ calculatedAt: string;
81
+ trend?: {
82
+ direction: 'up' | 'down' | 'stable';
83
+ weeklyChange: number;
84
+ daysTracked: number;
85
+ };
86
+ }
87
+ interface ERSCalculateResult {
88
+ ersScore: number;
89
+ stage: ERSStage;
90
+ dimensions: ERSDimensions;
91
+ previousScore: number | null;
92
+ change: number | null;
93
+ dataPointsUsed: number;
94
+ }
95
+ interface ERSBatchResult {
96
+ results: Array<{
97
+ externalId: string;
98
+ ersScore: number | null;
99
+ stage: ERSStage | null;
100
+ calculatedAt: string | null;
101
+ }>;
102
+ totalRequested: number;
103
+ totalReturned: number;
104
+ }
105
+ type AnalyticsPeriod = '7d' | '30d' | '90d' | 'all';
106
+ interface AnalyticsSummary {
107
+ totalUsers: number;
108
+ averageErs: number | null;
109
+ stageDistribution: {
110
+ healing: number;
111
+ rebuilding: number;
112
+ ready: number;
113
+ };
114
+ engagementMetrics: {
115
+ avgMoodLogsPerWeek: number;
116
+ avgJournalEntriesPerWeek: number;
117
+ };
118
+ period: AnalyticsPeriod;
119
+ }
120
+ type WebhookEvent = 'ers.stage_changed' | 'ers.score_threshold' | 'mood.critical' | 'mood.logged' | 'journal.created';
121
+ interface RegisterWebhookParams {
122
+ url: string;
123
+ events: WebhookEvent[];
124
+ }
125
+ interface WebhookRegistration {
126
+ webhookId: string;
127
+ secret: string;
128
+ events: WebhookEvent[];
129
+ status: 'created' | 'updated';
130
+ }
131
+ interface Webhook {
132
+ id: string;
133
+ url: string;
134
+ events: WebhookEvent[];
135
+ isActive: boolean;
136
+ createdAt: string;
137
+ }
138
+ interface ApiResponse<T> {
139
+ success: boolean;
140
+ data?: T;
141
+ error?: {
142
+ message: string;
143
+ code: string;
144
+ };
145
+ }
146
+ interface PaginatedResponse<T> {
147
+ items: T[];
148
+ total: number;
149
+ hasMore: boolean;
150
+ cursor?: string;
151
+ }
152
+
153
+ /**
154
+ * HTTP Client for Paceful API
155
+ */
156
+
157
+ interface RequestOptions {
158
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
159
+ path: string;
160
+ body?: Record<string, unknown>;
161
+ query?: Record<string, string | number | boolean | undefined>;
162
+ }
163
+ declare class HttpClient {
164
+ private readonly apiKey;
165
+ private readonly baseUrl;
166
+ private readonly timeout;
167
+ private readonly maxRetries;
168
+ constructor(config: PacefulConfig);
169
+ request<T>(options: RequestOptions): Promise<T>;
170
+ private sleep;
171
+ get<T>(path: string, query?: RequestOptions['query']): Promise<T>;
172
+ post<T>(path: string, body?: Record<string, unknown>): Promise<T>;
173
+ put<T>(path: string, body?: Record<string, unknown>): Promise<T>;
174
+ patch<T>(path: string, body?: Record<string, unknown>): Promise<T>;
175
+ delete<T>(path: string): Promise<T>;
176
+ }
177
+
178
+ /**
179
+ * Users Module
180
+ * Manage partner users in the Paceful system
181
+ */
182
+
183
+ declare class Users {
184
+ private readonly http;
185
+ constructor(http: HttpClient);
186
+ /**
187
+ * Register a new user or update existing user metadata
188
+ *
189
+ * @param params - User registration parameters
190
+ * @returns The registered or updated user
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * const user = await paceful.users.register({
195
+ * externalId: 'user_123',
196
+ * email: 'user@example.com',
197
+ * metadata: { plan: 'premium' }
198
+ * });
199
+ * ```
200
+ */
201
+ register(params: RegisterUserParams): Promise<PartnerUser>;
202
+ /**
203
+ * Get a user by their external ID
204
+ *
205
+ * @param externalId - Your system's user identifier
206
+ * @returns The user if found
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * const user = await paceful.users.get('user_123');
211
+ * ```
212
+ */
213
+ get(externalId: string): Promise<PartnerUser>;
214
+ /**
215
+ * Update a user's metadata
216
+ *
217
+ * @param externalId - Your system's user identifier
218
+ * @param metadata - New metadata to merge with existing
219
+ * @returns The updated user
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * const user = await paceful.users.update('user_123', {
224
+ * metadata: { plan: 'enterprise' }
225
+ * });
226
+ * ```
227
+ */
228
+ update(externalId: string, params: {
229
+ email?: string;
230
+ metadata?: Record<string, unknown>;
231
+ }): Promise<PartnerUser>;
232
+ /**
233
+ * List all users for this partner
234
+ *
235
+ * @param params - Pagination parameters
236
+ * @returns Paginated list of users
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const { items, total, hasMore } = await paceful.users.list({ limit: 50 });
241
+ * ```
242
+ */
243
+ list(params?: {
244
+ limit?: number;
245
+ cursor?: string;
246
+ }): Promise<{
247
+ items: PartnerUser[];
248
+ total: number;
249
+ hasMore: boolean;
250
+ cursor?: string;
251
+ }>;
252
+ /**
253
+ * Delete a user and all their data
254
+ *
255
+ * @param externalId - Your system's user identifier
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * await paceful.users.delete('user_123');
260
+ * ```
261
+ */
262
+ delete(externalId: string): Promise<void>;
263
+ }
264
+
265
+ /**
266
+ * Mood Module
267
+ * Track and retrieve mood data for users
268
+ */
269
+
270
+ declare class Mood {
271
+ private readonly http;
272
+ constructor(http: HttpClient);
273
+ /**
274
+ * Log a mood entry for a user
275
+ *
276
+ * @param params - Mood log parameters
277
+ * @returns The created mood entry
278
+ *
279
+ * @example
280
+ * ```typescript
281
+ * const entry = await paceful.mood.log({
282
+ * externalId: 'user_123',
283
+ * mood: 4,
284
+ * note: 'Feeling productive today',
285
+ * factors: ['work', 'exercise']
286
+ * });
287
+ * ```
288
+ */
289
+ log(params: LogMoodParams): Promise<MoodEntry>;
290
+ /**
291
+ * Get mood history for a user
292
+ *
293
+ * @param params - History query parameters
294
+ * @returns List of mood entries
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * const history = await paceful.mood.history({
299
+ * externalId: 'user_123',
300
+ * startDate: '2024-01-01',
301
+ * limit: 30
302
+ * });
303
+ * ```
304
+ */
305
+ history(params: MoodHistoryParams): Promise<MoodEntry[]>;
306
+ /**
307
+ * Get the latest mood entry for a user
308
+ *
309
+ * @param externalId - Your system's user identifier
310
+ * @returns The most recent mood entry or null
311
+ *
312
+ * @example
313
+ * ```typescript
314
+ * const latest = await paceful.mood.latest('user_123');
315
+ * if (latest) {
316
+ * console.log(`Last mood: ${latest.mood}`);
317
+ * }
318
+ * ```
319
+ */
320
+ latest(externalId: string): Promise<MoodEntry | null>;
321
+ /**
322
+ * Get mood statistics for a user over a time period
323
+ *
324
+ * @param externalId - Your system's user identifier
325
+ * @param period - Time period ('7d', '30d', '90d', 'all')
326
+ * @returns Mood statistics
327
+ *
328
+ * @example
329
+ * ```typescript
330
+ * const stats = await paceful.mood.stats('user_123', '30d');
331
+ * console.log(`Average mood: ${stats.average}`);
332
+ * ```
333
+ */
334
+ stats(externalId: string, period?: '7d' | '30d' | '90d' | 'all'): Promise<{
335
+ average: number;
336
+ count: number;
337
+ highest: number;
338
+ lowest: number;
339
+ trend: 'up' | 'down' | 'stable';
340
+ }>;
341
+ }
342
+
343
+ /**
344
+ * Journal Module
345
+ * Create and retrieve journal entries for users
346
+ */
347
+
348
+ declare class Journal {
349
+ private readonly http;
350
+ constructor(http: HttpClient);
351
+ /**
352
+ * Create a journal entry for a user
353
+ *
354
+ * @param params - Journal entry parameters
355
+ * @returns The created journal entry with AI analysis
356
+ *
357
+ * @example
358
+ * ```typescript
359
+ * const entry = await paceful.journal.create({
360
+ * externalId: 'user_123',
361
+ * content: 'Today I reflected on my progress...',
362
+ * mood: 4
363
+ * });
364
+ *
365
+ * console.log('Themes:', entry.themes);
366
+ * console.log('Sentiment:', entry.sentimentScore);
367
+ * ```
368
+ */
369
+ create(params: CreateJournalParams): Promise<JournalEntry>;
370
+ /**
371
+ * Get journal history for a user
372
+ *
373
+ * @param params - History query parameters
374
+ * @returns List of journal entries
375
+ *
376
+ * @example
377
+ * ```typescript
378
+ * const entries = await paceful.journal.history({
379
+ * externalId: 'user_123',
380
+ * limit: 10
381
+ * });
382
+ * ```
383
+ */
384
+ history(params: JournalHistoryParams): Promise<JournalEntry[]>;
385
+ /**
386
+ * Get a specific journal entry
387
+ *
388
+ * @param externalId - Your system's user identifier
389
+ * @param entryId - The journal entry ID
390
+ * @returns The journal entry
391
+ *
392
+ * @example
393
+ * ```typescript
394
+ * const entry = await paceful.journal.get('user_123', 'entry_abc');
395
+ * ```
396
+ */
397
+ get(externalId: string, entryId: string): Promise<JournalEntry>;
398
+ /**
399
+ * Get available journal prompts
400
+ *
401
+ * @returns List of prompts categorized by theme
402
+ *
403
+ * @example
404
+ * ```typescript
405
+ * const prompts = await paceful.journal.prompts();
406
+ * const gratitudePrompts = prompts.gratitude;
407
+ * ```
408
+ */
409
+ prompts(): Promise<Record<string, Array<{
410
+ id: string;
411
+ text: string;
412
+ }>>>;
413
+ /**
414
+ * Get journal statistics for a user
415
+ *
416
+ * @param externalId - Your system's user identifier
417
+ * @param period - Time period ('7d', '30d', '90d', 'all')
418
+ * @returns Journal statistics
419
+ *
420
+ * @example
421
+ * ```typescript
422
+ * const stats = await paceful.journal.stats('user_123', '30d');
423
+ * console.log(`Entries this month: ${stats.count}`);
424
+ * ```
425
+ */
426
+ stats(externalId: string, period?: '7d' | '30d' | '90d' | 'all'): Promise<{
427
+ count: number;
428
+ avgSentiment: number;
429
+ topThemes: string[];
430
+ streakDays: number;
431
+ }>;
432
+ }
433
+
434
+ /**
435
+ * ERS (Emotional Readiness Score) Module
436
+ * Calculate and retrieve ERS scores for users
437
+ */
438
+
439
+ declare class ERS {
440
+ private readonly http;
441
+ constructor(http: HttpClient);
442
+ /**
443
+ * Get the current ERS score for a user
444
+ * Returns cached score if recent (< 24 hours), otherwise calculates fresh
445
+ *
446
+ * @param externalId - Your system's user identifier
447
+ * @returns The user's ERS score with trend data
448
+ *
449
+ * @example
450
+ * ```typescript
451
+ * const ers = await paceful.ers.get('user_123');
452
+ *
453
+ * console.log(`ERS Score: ${ers.ersScore}`);
454
+ * console.log(`Stage: ${ers.stage}`);
455
+ * console.log(`Trend: ${ers.trend?.direction}`);
456
+ * ```
457
+ */
458
+ get(externalId: string): Promise<ERSScore>;
459
+ /**
460
+ * Force a fresh ERS calculation for a user
461
+ * Useful after significant user activity
462
+ *
463
+ * @param externalId - Your system's user identifier
464
+ * @returns Fresh calculation results with change data
465
+ *
466
+ * @example
467
+ * ```typescript
468
+ * const result = await paceful.ers.calculate('user_123');
469
+ *
470
+ * if (result.change !== null) {
471
+ * console.log(`Score changed by ${result.change} points`);
472
+ * }
473
+ * ```
474
+ */
475
+ calculate(externalId: string): Promise<ERSCalculateResult>;
476
+ /**
477
+ * Get ERS scores for multiple users in a single request
478
+ * Maximum 50 users per request
479
+ *
480
+ * @param externalIds - Array of your system's user identifiers
481
+ * @returns Batch results with scores for each user
482
+ *
483
+ * @example
484
+ * ```typescript
485
+ * const batch = await paceful.ers.batch(['user_1', 'user_2', 'user_3']);
486
+ *
487
+ * for (const result of batch.results) {
488
+ * console.log(`${result.externalId}: ${result.ersScore}`);
489
+ * }
490
+ * ```
491
+ */
492
+ batch(externalIds: string[]): Promise<ERSBatchResult>;
493
+ /**
494
+ * Get ERS score history for a user
495
+ *
496
+ * @param externalId - Your system's user identifier
497
+ * @param params - Query parameters
498
+ * @returns Historical ERS scores
499
+ *
500
+ * @example
501
+ * ```typescript
502
+ * const history = await paceful.ers.history('user_123', {
503
+ * period: '30d',
504
+ * granularity: 'daily'
505
+ * });
506
+ * ```
507
+ */
508
+ history(externalId: string, params?: {
509
+ period?: '7d' | '30d' | '90d' | 'all';
510
+ granularity?: 'daily' | 'weekly';
511
+ }): Promise<Array<{
512
+ score: number;
513
+ stage: string;
514
+ date: string;
515
+ }>>;
516
+ /**
517
+ * Set up alerts for ERS threshold crossings
518
+ *
519
+ * @param params - Alert configuration
520
+ * @returns The created alert configuration
521
+ *
522
+ * @example
523
+ * ```typescript
524
+ * await paceful.ers.setThresholdAlert({
525
+ * externalId: 'user_123',
526
+ * threshold: 40,
527
+ * direction: 'below',
528
+ * webhookUrl: 'https://yourapp.com/alerts'
529
+ * });
530
+ * ```
531
+ */
532
+ setThresholdAlert(params: {
533
+ externalId: string;
534
+ threshold: number;
535
+ direction: 'above' | 'below';
536
+ webhookUrl?: string;
537
+ }): Promise<{
538
+ alertId: string;
539
+ }>;
540
+ }
541
+
542
+ /**
543
+ * Analytics Module
544
+ * Get aggregate analytics for your partner account
545
+ */
546
+
547
+ declare class Analytics {
548
+ private readonly http;
549
+ constructor(http: HttpClient);
550
+ /**
551
+ * Get aggregate analytics summary for all your users
552
+ *
553
+ * @param period - Time period for analytics ('7d', '30d', '90d', 'all')
554
+ * @returns Aggregate analytics summary
555
+ *
556
+ * @example
557
+ * ```typescript
558
+ * const summary = await paceful.analytics.summary('30d');
559
+ *
560
+ * console.log(`Total users: ${summary.totalUsers}`);
561
+ * console.log(`Average ERS: ${summary.averageErs}`);
562
+ * console.log(`Healing stage: ${summary.stageDistribution.healing * 100}%`);
563
+ * ```
564
+ */
565
+ summary(period?: AnalyticsPeriod): Promise<AnalyticsSummary>;
566
+ /**
567
+ * Get engagement metrics over time
568
+ *
569
+ * @param params - Query parameters
570
+ * @returns Time series engagement data
571
+ *
572
+ * @example
573
+ * ```typescript
574
+ * const engagement = await paceful.analytics.engagement({
575
+ * period: '30d',
576
+ * granularity: 'daily'
577
+ * });
578
+ *
579
+ * for (const point of engagement.dataPoints) {
580
+ * console.log(`${point.date}: ${point.activeUsers} active users`);
581
+ * }
582
+ * ```
583
+ */
584
+ engagement(params?: {
585
+ period?: AnalyticsPeriod;
586
+ granularity?: 'daily' | 'weekly';
587
+ }): Promise<{
588
+ dataPoints: Array<{
589
+ date: string;
590
+ activeUsers: number;
591
+ moodLogs: number;
592
+ journalEntries: number;
593
+ }>;
594
+ totals: {
595
+ activeUsers: number;
596
+ moodLogs: number;
597
+ journalEntries: number;
598
+ };
599
+ }>;
600
+ /**
601
+ * Get ERS distribution across all users
602
+ *
603
+ * @param period - Time period for analytics
604
+ * @returns ERS distribution data
605
+ *
606
+ * @example
607
+ * ```typescript
608
+ * const distribution = await paceful.analytics.ersDistribution('30d');
609
+ *
610
+ * console.log('Score ranges:');
611
+ * for (const bucket of distribution.buckets) {
612
+ * console.log(`${bucket.range}: ${bucket.count} users`);
613
+ * }
614
+ * ```
615
+ */
616
+ ersDistribution(period?: AnalyticsPeriod): Promise<{
617
+ buckets: Array<{
618
+ range: string;
619
+ min: number;
620
+ max: number;
621
+ count: number;
622
+ percentage: number;
623
+ }>;
624
+ stageDistribution: {
625
+ healing: number;
626
+ rebuilding: number;
627
+ ready: number;
628
+ };
629
+ }>;
630
+ /**
631
+ * Get retention metrics
632
+ *
633
+ * @param period - Time period for analytics
634
+ * @returns Retention and churn data
635
+ *
636
+ * @example
637
+ * ```typescript
638
+ * const retention = await paceful.analytics.retention('30d');
639
+ *
640
+ * console.log(`Day 7 retention: ${retention.day7}%`);
641
+ * console.log(`Day 30 retention: ${retention.day30}%`);
642
+ * ```
643
+ */
644
+ retention(period?: AnalyticsPeriod): Promise<{
645
+ day1: number;
646
+ day7: number;
647
+ day14: number;
648
+ day30: number;
649
+ weeklyActive: number;
650
+ monthlyActive: number;
651
+ }>;
652
+ /**
653
+ * Export analytics data as CSV
654
+ *
655
+ * @param params - Export parameters
656
+ * @returns Download URL for the CSV
657
+ *
658
+ * @example
659
+ * ```typescript
660
+ * const { downloadUrl } = await paceful.analytics.export({
661
+ * type: 'user_summary',
662
+ * period: '30d'
663
+ * });
664
+ * ```
665
+ */
666
+ export(params: {
667
+ type: 'user_summary' | 'ers_scores' | 'engagement';
668
+ period?: AnalyticsPeriod;
669
+ format?: 'csv' | 'json';
670
+ }): Promise<{
671
+ downloadUrl: string;
672
+ expiresAt: string;
673
+ }>;
674
+ }
675
+
676
+ /**
677
+ * Webhooks Module
678
+ * Manage webhook endpoints for real-time event notifications
679
+ */
680
+
681
+ declare class Webhooks {
682
+ private readonly http;
683
+ constructor(http: HttpClient);
684
+ /**
685
+ * Register a webhook endpoint for receiving events
686
+ * Updates existing webhook if same URL already registered
687
+ *
688
+ * @param params - Webhook configuration
689
+ * @returns Webhook registration details including secret
690
+ *
691
+ * @example
692
+ * ```typescript
693
+ * const webhook = await paceful.webhooks.register({
694
+ * url: 'https://yourapp.com/webhooks/paceful',
695
+ * events: ['ers.stage_changed', 'mood.critical']
696
+ * });
697
+ *
698
+ * // Store the secret securely for signature verification
699
+ * console.log('Webhook secret:', webhook.secret);
700
+ * ```
701
+ */
702
+ register(params: RegisterWebhookParams): Promise<WebhookRegistration>;
703
+ /**
704
+ * List all registered webhooks
705
+ *
706
+ * @returns Array of webhook configurations
707
+ *
708
+ * @example
709
+ * ```typescript
710
+ * const webhooks = await paceful.webhooks.list();
711
+ *
712
+ * for (const webhook of webhooks) {
713
+ * console.log(`${webhook.url}: ${webhook.events.join(', ')}`);
714
+ * }
715
+ * ```
716
+ */
717
+ list(): Promise<Webhook[]>;
718
+ /**
719
+ * Get a specific webhook by ID
720
+ *
721
+ * @param webhookId - The webhook ID
722
+ * @returns Webhook configuration
723
+ *
724
+ * @example
725
+ * ```typescript
726
+ * const webhook = await paceful.webhooks.get('webhook_abc123');
727
+ * ```
728
+ */
729
+ get(webhookId: string): Promise<Webhook>;
730
+ /**
731
+ * Update a webhook's configuration
732
+ *
733
+ * @param webhookId - The webhook ID
734
+ * @param params - Updated configuration
735
+ * @returns Updated webhook
736
+ *
737
+ * @example
738
+ * ```typescript
739
+ * await paceful.webhooks.update('webhook_abc123', {
740
+ * events: ['ers.stage_changed', 'mood.critical', 'journal.created']
741
+ * });
742
+ * ```
743
+ */
744
+ update(webhookId: string, params: {
745
+ url?: string;
746
+ events?: WebhookEvent[];
747
+ isActive?: boolean;
748
+ }): Promise<Webhook>;
749
+ /**
750
+ * Delete a webhook
751
+ *
752
+ * @param webhookId - The webhook ID
753
+ *
754
+ * @example
755
+ * ```typescript
756
+ * await paceful.webhooks.delete('webhook_abc123');
757
+ * ```
758
+ */
759
+ delete(webhookId: string): Promise<void>;
760
+ /**
761
+ * Test a webhook by sending a test event
762
+ *
763
+ * @param webhookId - The webhook ID
764
+ * @returns Test result
765
+ *
766
+ * @example
767
+ * ```typescript
768
+ * const result = await paceful.webhooks.test('webhook_abc123');
769
+ *
770
+ * if (result.success) {
771
+ * console.log('Webhook is working!');
772
+ * } else {
773
+ * console.error('Test failed:', result.error);
774
+ * }
775
+ * ```
776
+ */
777
+ test(webhookId: string): Promise<{
778
+ success: boolean;
779
+ statusCode?: number;
780
+ responseTime?: number;
781
+ error?: string;
782
+ }>;
783
+ /**
784
+ * Get delivery history for a webhook
785
+ *
786
+ * @param webhookId - The webhook ID
787
+ * @param params - Query parameters
788
+ * @returns Delivery history
789
+ *
790
+ * @example
791
+ * ```typescript
792
+ * const history = await paceful.webhooks.deliveryHistory('webhook_abc123', {
793
+ * limit: 20
794
+ * });
795
+ *
796
+ * for (const delivery of history) {
797
+ * console.log(`${delivery.event}: ${delivery.status}`);
798
+ * }
799
+ * ```
800
+ */
801
+ deliveryHistory(webhookId: string, params?: {
802
+ limit?: number;
803
+ status?: 'success' | 'failed';
804
+ }): Promise<Array<{
805
+ id: string;
806
+ event: WebhookEvent;
807
+ status: 'success' | 'failed';
808
+ statusCode?: number;
809
+ attempts: number;
810
+ deliveredAt: string;
811
+ payload: Record<string, unknown>;
812
+ }>>;
813
+ /**
814
+ * Rotate the webhook secret
815
+ *
816
+ * @param webhookId - The webhook ID
817
+ * @returns New webhook secret
818
+ *
819
+ * @example
820
+ * ```typescript
821
+ * const { secret } = await paceful.webhooks.rotateSecret('webhook_abc123');
822
+ *
823
+ * // Update your server with the new secret
824
+ * console.log('New secret:', secret);
825
+ * ```
826
+ */
827
+ rotateSecret(webhookId: string): Promise<{
828
+ secret: string;
829
+ }>;
830
+ /**
831
+ * Verify a webhook signature
832
+ * Call this method to validate incoming webhook requests
833
+ *
834
+ * @param payload - Raw request body as string
835
+ * @param signature - Value of X-Paceful-Signature header
836
+ * @param secret - Your webhook secret
837
+ * @returns Whether the signature is valid
838
+ *
839
+ * @example
840
+ * ```typescript
841
+ * // In your webhook handler:
842
+ * const isValid = Webhooks.verifySignature(
843
+ * rawBody,
844
+ * request.headers['x-paceful-signature'],
845
+ * process.env.PACEFUL_WEBHOOK_SECRET
846
+ * );
847
+ *
848
+ * if (!isValid) {
849
+ * return res.status(401).send('Invalid signature');
850
+ * }
851
+ * ```
852
+ */
853
+ static verifySignature(payload: string, signature: string, secret: string): boolean;
854
+ }
855
+
856
+ /**
857
+ * Paceful SDK Client
858
+ * Main entry point for the Paceful Partner API
859
+ */
860
+
861
+ declare class PacefulClient {
862
+ private readonly http;
863
+ /**
864
+ * Users module for managing partner users
865
+ */
866
+ readonly users: Users;
867
+ /**
868
+ * Mood module for tracking mood entries
869
+ */
870
+ readonly mood: Mood;
871
+ /**
872
+ * Journal module for managing journal entries
873
+ */
874
+ readonly journal: Journal;
875
+ /**
876
+ * ERS module for emotional readiness scores
877
+ */
878
+ readonly ers: ERS;
879
+ /**
880
+ * Analytics module for aggregate insights
881
+ */
882
+ readonly analytics: Analytics;
883
+ /**
884
+ * Webhooks module for event notifications
885
+ */
886
+ readonly webhooks: Webhooks;
887
+ /**
888
+ * Create a new Paceful client
889
+ *
890
+ * @param config - Configuration options
891
+ *
892
+ * @example
893
+ * ```typescript
894
+ * import { PacefulClient } from '@paceful/sdk';
895
+ *
896
+ * const paceful = new PacefulClient({
897
+ * apiKey: process.env.PACEFUL_API_KEY,
898
+ * });
899
+ *
900
+ * // Register a user
901
+ * const user = await paceful.users.register({
902
+ * externalId: 'user_123',
903
+ * email: 'user@example.com'
904
+ * });
905
+ *
906
+ * // Log a mood entry
907
+ * await paceful.mood.log({
908
+ * externalId: 'user_123',
909
+ * mood: 4,
910
+ * note: 'Feeling good today'
911
+ * });
912
+ *
913
+ * // Get ERS score
914
+ * const ers = await paceful.ers.get('user_123');
915
+ * console.log(`ERS: ${ers.ersScore}, Stage: ${ers.stage}`);
916
+ * ```
917
+ */
918
+ constructor(config: PacefulConfig);
919
+ /**
920
+ * Check API connectivity and authentication
921
+ *
922
+ * @returns Health check result
923
+ *
924
+ * @example
925
+ * ```typescript
926
+ * const health = await paceful.healthCheck();
927
+ * if (health.ok) {
928
+ * console.log('API is reachable');
929
+ * }
930
+ * ```
931
+ */
932
+ healthCheck(): Promise<{
933
+ ok: boolean;
934
+ partnerId: string;
935
+ rateLimit: {
936
+ remaining: number;
937
+ limit: number;
938
+ resetAt: string;
939
+ };
940
+ }>;
941
+ }
942
+
943
+ /**
944
+ * Paceful SDK Error Classes
945
+ */
946
+ declare class PacefulError extends Error {
947
+ readonly code: string;
948
+ readonly statusCode?: number;
949
+ readonly details?: Record<string, unknown>;
950
+ constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>);
951
+ }
952
+ declare class PacefulAuthError extends PacefulError {
953
+ constructor(message?: string);
954
+ }
955
+ declare class PacefulRateLimitError extends PacefulError {
956
+ readonly retryAfter: number;
957
+ constructor(retryAfter?: number);
958
+ }
959
+ declare class PacefulNotFoundError extends PacefulError {
960
+ constructor(resource?: string);
961
+ }
962
+ declare class PacefulValidationError extends PacefulError {
963
+ constructor(message: string, details?: Record<string, unknown>);
964
+ }
965
+ declare class PacefulNetworkError extends PacefulError {
966
+ constructor(message?: string);
967
+ }
968
+
969
+ interface PacefulContextValue {
970
+ apiKey: string;
971
+ userId: string;
972
+ baseUrl: string;
973
+ }
974
+ declare function usePaceful(): PacefulContextValue;
975
+ interface PacefulProviderProps {
976
+ apiKey: string;
977
+ userId: string;
978
+ baseUrl?: string;
979
+ children: React.ReactNode;
980
+ }
981
+ declare function PacefulProvider({ apiKey, userId, baseUrl, children }: PacefulProviderProps): React.FunctionComponentElement<React.ProviderProps<PacefulContextValue | null>>;
982
+
983
+ interface MoodWidgetProps {
984
+ apiKey?: string;
985
+ userId?: string;
986
+ baseUrl?: string;
987
+ theme?: 'light' | 'dark';
988
+ brandColor?: string;
989
+ compact?: boolean;
990
+ showStreak?: boolean;
991
+ onComplete?: (mood: {
992
+ logged: boolean;
993
+ moodId: string;
994
+ timestamp: string;
995
+ }) => void;
996
+ onError?: (error: Error) => void;
997
+ className?: string;
998
+ }
999
+ declare function MoodWidget({ apiKey: propApiKey, userId: propUserId, baseUrl: propBaseUrl, theme, brandColor, compact, showStreak, onComplete, onError, className, }: MoodWidgetProps): react_jsx_runtime.JSX.Element;
1000
+
1001
+ interface JournalWidgetProps {
1002
+ apiKey?: string;
1003
+ userId?: string;
1004
+ baseUrl?: string;
1005
+ theme?: 'light' | 'dark';
1006
+ brandColor?: string;
1007
+ showPrompt?: boolean;
1008
+ showAIReflection?: boolean;
1009
+ maxLength?: number;
1010
+ placeholder?: string;
1011
+ onComplete?: (entry: {
1012
+ entryId: string;
1013
+ sentiment: string;
1014
+ aiReflection: string;
1015
+ }) => void;
1016
+ onError?: (error: Error) => void;
1017
+ className?: string;
1018
+ }
1019
+ declare function JournalWidget({ apiKey: propApiKey, userId: propUserId, baseUrl: propBaseUrl, theme, brandColor, showPrompt, showAIReflection, maxLength, placeholder, onComplete, onError, className, }: JournalWidgetProps): react_jsx_runtime.JSX.Element;
1020
+
1021
+ interface ERSDisplayProps {
1022
+ apiKey?: string;
1023
+ userId?: string;
1024
+ baseUrl?: string;
1025
+ theme?: 'light' | 'dark';
1026
+ brandColor?: string;
1027
+ showDimensions?: boolean;
1028
+ showTrend?: boolean;
1029
+ compact?: boolean;
1030
+ onLoad?: (ers: ERSData) => void;
1031
+ onError?: (error: Error) => void;
1032
+ className?: string;
1033
+ }
1034
+ interface ERSData {
1035
+ ersScore: number;
1036
+ stage: 'healing' | 'rebuilding' | 'ready';
1037
+ dimensions: {
1038
+ emotionalStability: number;
1039
+ selfAwareness: number;
1040
+ socialConnection: number;
1041
+ purposeClarity: number;
1042
+ resilienceGrowth: number;
1043
+ };
1044
+ trend?: {
1045
+ direction: 'up' | 'down' | 'stable';
1046
+ weeklyChange: number;
1047
+ daysTracked: number;
1048
+ };
1049
+ }
1050
+ declare function ERSDisplay({ apiKey: propApiKey, userId: propUserId, baseUrl: propBaseUrl, theme, brandColor, showDimensions, showTrend, compact, onLoad, onError, className, }: ERSDisplayProps): react_jsx_runtime.JSX.Element | null;
1051
+
1052
+ export { Analytics, type AnalyticsPeriod, type AnalyticsSummary, type ApiResponse, type CreateJournalParams, ERS, type ERSBatchResult, type ERSCalculateResult, type ERSDimensions, ERSDisplay, type ERSScore, type ERSStage, Journal, type JournalEntry, type JournalHistoryParams, JournalWidget, type LogMoodParams, Mood, type MoodEntry, type MoodHistoryParams, type MoodLevel, MoodWidget, PacefulAuthError, PacefulClient, type PacefulConfig, PacefulError, PacefulNetworkError, PacefulNotFoundError, PacefulProvider, PacefulRateLimitError, PacefulValidationError, type PaginatedResponse, type PartnerUser, type RegisterUserParams, type RegisterWebhookParams, Users, type Webhook, type WebhookEvent, type WebhookRegistration, Webhooks, PacefulClient as default, usePaceful };