@hipnation-truth/sdk 0.7.2 → 0.7.4

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/react.d.mts DELETED
@@ -1,898 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import { ConvexReactClient } from 'convex/react';
4
-
5
- /**
6
- * React hooks for Truth SDK — reactive conversation + message data.
7
- *
8
- * Wraps Convex queries owned by the Truth backend so consumers (CommHub
9
- * Expo frontend) get live-updating conversation lists, message threads,
10
- * and unread totals without managing subscriptions themselves.
11
- *
12
- * **Hook contract:** every hook in this file returns
13
- * `{ data, loading, error }`. `data` is `undefined` while loading and
14
- * also when the underlying query is `"skip"`'d (caller didn't pass the
15
- * required arg yet). `loading` is `true` only while a real subscription
16
- * is in-flight; once `data` resolves (even to `null`) `loading` flips
17
- * to `false`. `error` is reserved for SDK-side validation — Convex
18
- * itself throws on subscribe rather than returning an error value, so
19
- * unhandled query errors propagate as React errors and should be caught
20
- * with an error boundary.
21
- *
22
- * **Backed by PR #110 schema (commit `41dbb59` on
23
- * `feat/migrate-dialpad-webhook-and-messages-to-truth`):**
24
- * - `conversations:listForUser` → `useConversations`
25
- * - `conversations:getUnreadTotalForUser` → `useUnreadCount`
26
- * - `conversations:getByPhonePair` → `useConversationByPhonePair`
27
- * - `conversationMessages:getByConversationId` → `useMessages`
28
- *
29
- * **Deliberately NOT shipped here (no backend query yet — flagged in
30
- * PR #111 body for follow-up):**
31
- * - Single-conversation-by-id lookup. Convex `conversations` has no
32
- * `get(id)` query — only `getByPhonePair`. CommHub uses phonePair as
33
- * the primary handle, so the byPair flavor is what consumers need;
34
- * if id-based lookup is needed later we can add a `conversations:get`
35
- * in Truth.
36
- * - Participants / "seen by" hook. The migrated schema has no
37
- * `conversationParticipants` table — read state is per-user via
38
- * `conversationReads` and there's no public list query for it yet.
39
- * - `markRead` mutation. PR #110 declares `markRead` as
40
- * `internalMutation`, so the frontend can't invoke it directly — it
41
- * has to go through a Truth HTTP endpoint, or webhook-migrator needs
42
- * to flip it to a public `mutation`. Flagged for a follow-up.
43
- *
44
- * Must be used within `<TruthProvider />` (see `./provider`).
45
- *
46
- * @example
47
- * ```tsx
48
- * import {
49
- * useConversations,
50
- * useConversationByPhonePair,
51
- * useMessages,
52
- * useUnreadCount,
53
- * } from '@hipnation-truth/sdk/react';
54
- *
55
- * function Inbox({ userId }: { userId: string }) {
56
- * const { data: convos, loading } = useConversations({ userId });
57
- * const { data: unread } = useUnreadCount(userId);
58
- * if (loading) return <Spinner />;
59
- * return (
60
- * <div>
61
- * <Badge count={unread ?? 0} />
62
- * {convos?.map((c) => <ConvoRow key={c.id} convo={c} />)}
63
- * </div>
64
- * );
65
- * }
66
- * ```
67
- */
68
- /**
69
- * Row shape returned by `conversations:listForUser` — joins the base
70
- * `conversations` row with the caller's per-user `conversationReads`
71
- * entry so unread state lives on each item.
72
- */
73
- interface ConversationListItem {
74
- /** Convex id of the conversation row. */
75
- id: string;
76
- patientPhone: string;
77
- providerPhone: string;
78
- /** Sorted-digit-pair key (commutative — same regardless of direction). */
79
- phonePair: string;
80
- /** Truth-side patient id, when the kinesis pipeline could resolve it. */
81
- patientId: string | null;
82
- /** ISO timestamp of the most recent message in the conversation. */
83
- lastMessageAt: string;
84
- /** Caller's unread count for this conversation. */
85
- unreadCount: number;
86
- /** ISO timestamp of when the caller last marked the conversation read. */
87
- lastReadAt: string | null;
88
- }
89
- /**
90
- * Raw `conversations` table row — what `getByPhonePair` returns. No
91
- * unread / read joining; for that, prefer `useConversations`.
92
- */
93
- interface ConversationRow {
94
- _id: string;
95
- _creationTime: number;
96
- patientPhone: string;
97
- providerPhone: string;
98
- phonePair: string;
99
- patientId: string | null;
100
- lastEventId: string | null;
101
- lastMessageAt: string;
102
- createdAt: string;
103
- }
104
- /**
105
- * Message row returned by `conversationMessages:getByConversationId` —
106
- * calls + SMS merged chronologically. Mirrors `ConversationMessage`
107
- * already exported from the SDK; re-exported here under a clearer name
108
- * for the new hook surface.
109
- */
110
- interface ConversationMessageRow {
111
- kind: "call" | "sms";
112
- id: string;
113
- providerId: string;
114
- state: string | null;
115
- direction: string | null;
116
- fromNumber: string | null;
117
- toNumber: string | null;
118
- voicemailLink: string | null;
119
- duration: number | null;
120
- text: string | null;
121
- mms: boolean;
122
- mmsUrl: string | null;
123
- messageStatus: string | null;
124
- occurredAt: string;
125
- conversationId: string | null;
126
- patientId: string | null;
127
- }
128
- interface UseQueryResult<T> {
129
- /**
130
- * Query data. `undefined` while loading or while the query is
131
- * intentionally skipped (e.g. caller hasn't supplied `userId` yet).
132
- */
133
- data: T | undefined;
134
- /** True only while a real subscription is in-flight. */
135
- loading: boolean;
136
- /**
137
- * Reserved for client-side validation errors surfaced by the SDK
138
- * itself. Convex query errors propagate as React errors and should
139
- * be caught with an error boundary.
140
- */
141
- error: Error | undefined;
142
- }
143
- interface UseConversationsFilters {
144
- /**
145
- * Truth user id (the Better Auth subject). Pass `undefined` to skip
146
- * the query — useful when the auth session is still loading.
147
- */
148
- userId: string | null | undefined;
149
- /** Page size. Server caps at 100 by default. */
150
- limit?: number;
151
- }
152
- interface UseMessagesOptions {
153
- /** Page size. Server caps at 200 by default. */
154
- limit?: number;
155
- }
156
- /**
157
- * Subscribe to a user's conversations — joined with their per-conversation
158
- * unread count, sorted by most recent message. Updates live as new
159
- * SMS / calls land in Convex and the webhook bumps `unreadCount`.
160
- *
161
- * Returns `{ data: undefined, loading: false }` while the auth session
162
- * resolves (`userId === undefined`); not an error, just a skip.
163
- */
164
- declare function useConversations(filters: UseConversationsFilters): UseQueryResult<ConversationListItem[]>;
165
- /**
166
- * Look up a single conversation by its normalized phonePair (sorted
167
- * digit-pair, e.g. `"5125550123|6505551234"`). Returns `null` if no
168
- * conversation exists yet for that pair.
169
- *
170
- * Use the `phonePairKey(patientPhone, providerPhone)` helper exposed by
171
- * the Truth Convex module to derive the key from raw phone strings.
172
- */
173
- declare function useConversationByPhonePair(phonePair: string | null | undefined): UseQueryResult<ConversationRow | null>;
174
- /**
175
- * Subscribe to a paginated message stream for a single conversation.
176
- * Calls + SMS merged chronologically, newest-first. Live as the
177
- * kinesis consumer writes to `messageCalls` / `messageSms`.
178
- *
179
- * Pass the Convex `_id` of the conversation row (from
180
- * `useConversations` / `useConversationByPhonePair`) as
181
- * `conversationId`.
182
- */
183
- declare function useMessages(conversationId: string | null | undefined, options?: UseMessagesOptions): UseQueryResult<ConversationMessageRow[]>;
184
- /**
185
- * Subscribe to the user's total unread message count across all
186
- * conversations. Backs the inbox tab badge in CommHub.
187
- *
188
- * Returns `0` when the underlying query resolves with no unread
189
- * messages, `undefined` while loading or when `userId` is missing.
190
- */
191
- declare function useUnreadCount(userId: string | null | undefined): UseQueryResult<number>;
192
-
193
- /**
194
- * React hooks for Truth SDK — real-time Convex-backed data access.
195
- *
196
- * These hooks use Convex React subscriptions for live-updating data.
197
- * Must be used within a ConvexProvider (see TruthProvider).
198
- *
199
- * @example
200
- * ```tsx
201
- * import { usePatients, useAppointments } from '@hipnation-truth/sdk/react';
202
- *
203
- * function PatientList() {
204
- * const patients = usePatients({ limit: 20 });
205
- * return patients?.map(p => <div key={p._id}>{p.firstName} {p.lastName}</div>);
206
- * }
207
- * ```
208
- */
209
- interface UsePatientListOptions {
210
- search?: string;
211
- lastName?: string;
212
- limit?: number;
213
- }
214
- /**
215
- * Subscribe to a list of patients with optional search and filtering.
216
- * Returns undefined while loading, then an array of patients.
217
- */
218
- declare function usePatients(options?: UsePatientListOptions): any;
219
- /**
220
- * Subscribe to a single patient by Convex document ID.
221
- */
222
- declare function usePatient(id: string): any;
223
- /**
224
- * Subscribe to a patient by their Elation ID.
225
- */
226
- declare function usePatientByElationId(elationId: string): any;
227
- /**
228
- * Subscribe to a patient by their Hint ID.
229
- */
230
- declare function usePatientByHintId(hintId: string): any;
231
- interface UseAppointmentListOptions {
232
- patientId?: string;
233
- status?: string;
234
- startDate?: string;
235
- endDate?: string;
236
- limit?: number;
237
- }
238
- /**
239
- * Subscribe to a list of appointments with optional filtering.
240
- */
241
- declare function useAppointments(options?: UseAppointmentListOptions): any;
242
- /**
243
- * Subscribe to a single appointment by Convex document ID.
244
- */
245
- declare function useAppointment(id: string): any;
246
- /**
247
- * Subscribe to an appointment by its Elation ID.
248
- */
249
- declare function useAppointmentByElationId(elationId: string): any;
250
- interface Physician {
251
- _id: string;
252
- elationId: number;
253
- firstName?: string;
254
- lastName?: string;
255
- npi?: string;
256
- credentials?: string;
257
- specialties?: string[];
258
- practice?: number;
259
- email?: string;
260
- phone?: string;
261
- lastSyncedAt: string;
262
- }
263
- /**
264
- * Resolve a batch of physicians by their Elation IDs. Returns an array
265
- * of physicians that exist in Convex; missing ids are silently dropped.
266
- *
267
- * Use this to resolve medication `prescribing_physician` / appointment
268
- * physician ids to display names, avoiding the per-physician HTTP
269
- * round-trip through Truth's Elation proxy.
270
- *
271
- * Pass `undefined` (or an empty array) to skip the query — the hook
272
- * returns `undefined` until you pass a populated list.
273
- */
274
- declare function usePhysiciansByElationIds(ids: number[] | undefined): any;
275
- /**
276
- * Subscribe to a single physician by their Elation ID.
277
- */
278
- declare function usePhysicianByElationId(id: number | undefined): any;
279
- interface UsePatientMedicalOptions {
280
- /**
281
- * Base URL of the Truth API. Required to trigger the background refresh
282
- * (e.g. `https://app.truth.communication-hub.com`). If omitted, the hook
283
- * only reads from Convex and does not refresh.
284
- */
285
- apiBaseUrl?: string;
286
- /** API key used for the refresh call. */
287
- apiKey?: string;
288
- /**
289
- * If true, suppress the background refresh. Useful when you know the
290
- * data was just refreshed by another component on the page.
291
- */
292
- skipRefresh?: boolean;
293
- }
294
- /**
295
- * Composite hook that returns a patient's medical records — medications,
296
- * problems, allergies, appointments — from the Convex cache.
297
- *
298
- * On mount (and when `elationId` changes) fires a background refresh
299
- * against Truth's `/api/patients/medical/refresh` endpoint so stale data
300
- * is pulled in without blocking render. Returns cached data immediately;
301
- * Convex subscription updates the UI when refresh completes.
302
- */
303
- declare function usePatientMedical(elationId: number | undefined, options?: UsePatientMedicalOptions): {
304
- medications: unknown[] | undefined;
305
- problems: unknown[] | undefined;
306
- allergies: unknown[] | undefined;
307
- appointments: unknown[] | undefined;
308
- };
309
- interface UsePatientBasicOptions {
310
- /** Truth API base URL used for the background refresh. */
311
- apiBaseUrl?: string;
312
- /** API key for the refresh call. */
313
- apiKey?: string;
314
- /** Suppress the background refresh. */
315
- skipRefresh?: boolean;
316
- }
317
- interface UsePatientBasicResult {
318
- /**
319
- * Raw Elation patient payload (matches the shape Elation's
320
- * `/patients/{id}` returns — `first_name`, `last_name`, `phones`, etc).
321
- * Returns `undefined` while the cache miss is loading, `null` if the
322
- * patient isn't in Convex yet (first-open-after-backfill).
323
- */
324
- elationPatient: Record<string, unknown> | null | undefined;
325
- /**
326
- * Raw Hint patient payload (matches the shape Hint's
327
- * `/provider/patients/{id}` returns — `memberships`, `account`,
328
- * `phones`, etc).
329
- */
330
- hintPatient: Record<string, unknown> | null | undefined;
331
- /**
332
- * The full Convex row for Elation (includes `elationId`, `lastSyncedAt`,
333
- * `photoS3Key`, `preferredPharmacyNcpdpId`, etc). Use this when you
334
- * need the structured/typed fields rather than the raw Elation payload.
335
- */
336
- elationRow: Record<string, unknown> | null | undefined;
337
- /**
338
- * The full Convex row for Hint. Similar relationship to `hintPatient`.
339
- */
340
- hintRow: Record<string, unknown> | null | undefined;
341
- /** True while either cache miss is still pending. */
342
- loading: boolean;
343
- }
344
- /**
345
- * Composite hook returning a patient's basic details — Hint demographics
346
- * + memberships + account, Elation demographics + clinical metadata —
347
- * from the Convex cache.
348
- *
349
- * On mount (and when inputs change) fires a background refresh against
350
- * `/api/patients/basic/refresh` so stale rows get pulled fresh without
351
- * blocking render. Returns cached data immediately; Convex subscription
352
- * updates the UI when refresh completes.
353
- */
354
- declare function usePatientBasic(input: {
355
- hintId?: string;
356
- elationId?: number;
357
- }, options?: UsePatientBasicOptions): UsePatientBasicResult;
358
- /**
359
- * Read a shared pharmacy row by NCPDP id. Backs the pharmacy card in
360
- * the patient panel (from Elation's preferred_pharmacy reference).
361
- */
362
- declare function usePharmacyByNcpdpId(ncpdpId: string | undefined): any;
363
- interface UsePatientPhotoOptions {
364
- apiBaseUrl?: string;
365
- apiKey?: string;
366
- skipRefresh?: boolean;
367
- }
368
- /**
369
- * Subscribe to a patient's profile photo (s3Key + metadata). The
370
- * consumer constructs a download URL via the Truth attachments resource
371
- * (signed S3 URL). Fires a background refresh to pull the latest photo
372
- * binary from Elation + upload to S3.
373
- */
374
- declare function usePatientPhoto(elationId: number | undefined, options?: UsePatientPhotoOptions): any;
375
- interface ConversationMessage {
376
- kind: "call" | "sms";
377
- id: string;
378
- providerId: string;
379
- state: string | null;
380
- direction: string | null;
381
- fromNumber: string | null;
382
- toNumber: string | null;
383
- voicemailLink: string | null;
384
- duration: number | null;
385
- text: string | null;
386
- mms: boolean;
387
- mmsUrl: string | null;
388
- messageStatus: string | null;
389
- occurredAt: string;
390
- conversationId: string | null;
391
- patientId: string | null;
392
- }
393
- interface UseConversationMessagesOptions {
394
- /** Max items to return (default 200). */
395
- limit?: number;
396
- }
397
- /**
398
- * Subscribe to a conversation's calls + SMS merged chronologically.
399
- * Pass the patient phone + the provider phone — Truth computes a
400
- * normalized pair key server-side so formatting differences don't
401
- * matter.
402
- *
403
- * Returns `undefined` while loading, then `ConversationMessage[]`
404
- * sorted newest-first. Updates live as new webhook events land in
405
- * Convex via the kinesis consumer.
406
- */
407
- declare function useConversationMessages(input: {
408
- phoneA?: string;
409
- phoneB?: string;
410
- conversationId?: string;
411
- }, options?: UseConversationMessagesOptions): ConversationMessage[] | undefined;
412
-
413
- /**
414
- * useNotifications — Truth SDK React hook for push notifications.
415
- *
416
- * Shape-compatible with `expo-notifications` where practical so
417
- * consumers port with minimal change. The hook dynamically imports
418
- * `expo-notifications` so the SDK doesn't hard-depend on Expo —
419
- * consumers running on a non-Expo runtime (e.g. a server test harness)
420
- * can still import the SDK without Metro blowing up.
421
- *
422
- * Exposes:
423
- * - permissionStatus — "granted" / "denied" / "undetermined"
424
- * - devicePushToken — native APNs/FCM token (undefined until register)
425
- * - register() — request permission, fetch token, register with Truth
426
- * - unregister() — revoke the device
427
- * - addReceivedListener / addResponseListener — re-exports of expo's
428
- * - getBadgeCount / setBadgeCount — re-exports of expo's
429
- *
430
- * Web push (VAPID subscription) lands in Phase 3.
431
- */
432
- type PermissionStatus = "granted" | "denied" | "undetermined" | "unknown";
433
- interface UseNotificationsOptions {
434
- /** Truth API base URL, e.g. https://app.truth.communication-hub.com */
435
- apiBaseUrl: string;
436
- /** `hn_live_*` API key for the caller's application. */
437
- apiKey: string;
438
- /** Current user id — used when registering the device. */
439
- userId: string | null | undefined;
440
- /** Optional app version string stored on the device row. */
441
- appVersion?: string;
442
- /**
443
- * Auto-register on mount when permission is already granted.
444
- * Default: true. Set false if you want to control the registration
445
- * lifecycle yourself.
446
- */
447
- autoRegister?: boolean;
448
- /** VAPID public key for web push. Fetched automatically if omitted. */
449
- vapidPublicKey?: string;
450
- /** Path to the service worker file. Default: "/truth-sw.js" */
451
- serviceWorkerPath?: string;
452
- }
453
- interface UseNotificationsResult {
454
- permissionStatus: PermissionStatus;
455
- devicePushToken: string | null;
456
- register: () => Promise<{
457
- ok: boolean;
458
- reason?: string;
459
- }>;
460
- unregister: () => Promise<void>;
461
- addReceivedListener: (listener: (n: unknown) => void) => () => void;
462
- addResponseListener: (listener: (r: unknown) => void) => () => void;
463
- getBadgeCount: () => Promise<number>;
464
- setBadgeCount: (count: number) => Promise<void>;
465
- }
466
- declare function useNotifications(options: UseNotificationsOptions): UseNotificationsResult;
467
-
468
- interface TruthProviderProps {
469
- /** Truth environment — determines which Convex deployment to connect to */
470
- environment?: string;
471
- /** Override the Convex URL directly */
472
- convexUrl?: string;
473
- children: ReactNode;
474
- }
475
- declare function TruthProvider({ environment, convexUrl, children, }: TruthProviderProps): react.FunctionComponentElement<{
476
- client: ConvexReactClient;
477
- children?: React.ReactNode;
478
- }>;
479
-
480
- /**
481
- * Typed event definitions for the Truth Platform event store.
482
- *
483
- * All 26 event types from the Communication Hub -> Truth Event Store Contract.
484
- * Events are grouped by domain and include typed payload interfaces.
485
- */
486
- declare const CONVERSATION_EVENTS: {
487
- readonly created: "conversation.created.v1";
488
- readonly messageSent: "conversation.message_sent.v1";
489
- readonly messageReceived: "conversation.message_received.v1";
490
- readonly markedRead: "conversation.marked_read.v1";
491
- readonly attachmentUploaded: "conversation.attachment_uploaded.v1";
492
- readonly attachmentDownloaded: "conversation.attachment_downloaded.v1";
493
- };
494
- declare const CALL_EVENTS: {
495
- readonly initiated: "call.initiated.v1";
496
- readonly connected: "call.connected.v1";
497
- readonly ended: "call.ended.v1";
498
- readonly missed: "call.missed.v1";
499
- };
500
- declare const TASK_EVENTS: {
501
- readonly created: "task.created.v1";
502
- readonly assigned: "task.assigned.v1";
503
- readonly statusChanged: "task.status_changed.v1";
504
- };
505
- declare const REMINDER_EVENTS: {
506
- readonly scheduled: "reminder.scheduled.v1";
507
- readonly triggered: "reminder.triggered.v1";
508
- };
509
- declare const TRANSLATION_EVENTS: {
510
- readonly requested: "translation.requested.v1";
511
- readonly completed: "translation.completed.v1";
512
- };
513
- declare const NOTIFICATION_EVENTS: {
514
- readonly sent: "notification.sent.v1";
515
- readonly delivered: "notification.delivered.v1";
516
- readonly opened: "notification.opened.v1";
517
- };
518
- declare const PROVIDER_EVENTS: {
519
- readonly syncStarted: "provider.sync_started.v1";
520
- readonly syncSucceeded: "provider.sync_succeeded.v1";
521
- readonly syncFailed: "provider.sync_failed.v1";
522
- };
523
- declare const AUTH_EVENTS: {
524
- readonly loginSucceeded: "auth.login_succeeded.v1";
525
- readonly loginFailed: "auth.login_failed.v1";
526
- };
527
- declare const SECURITY_EVENTS: {
528
- readonly accessDenied: "security.access_denied.v1";
529
- };
530
- type ConversationEventType = (typeof CONVERSATION_EVENTS)[keyof typeof CONVERSATION_EVENTS];
531
- type CallEventType = (typeof CALL_EVENTS)[keyof typeof CALL_EVENTS];
532
- type TaskEventType = (typeof TASK_EVENTS)[keyof typeof TASK_EVENTS];
533
- type ReminderEventType = (typeof REMINDER_EVENTS)[keyof typeof REMINDER_EVENTS];
534
- type TranslationEventType = (typeof TRANSLATION_EVENTS)[keyof typeof TRANSLATION_EVENTS];
535
- type NotificationEventType = (typeof NOTIFICATION_EVENTS)[keyof typeof NOTIFICATION_EVENTS];
536
- type ProviderEventType = (typeof PROVIDER_EVENTS)[keyof typeof PROVIDER_EVENTS];
537
- type AuthEventType = (typeof AUTH_EVENTS)[keyof typeof AUTH_EVENTS];
538
- type SecurityEventType = (typeof SECURITY_EVENTS)[keyof typeof SECURITY_EVENTS];
539
- /**
540
- * Union of all 26 registered event type strings.
541
- */
542
- type EventType = ConversationEventType | CallEventType | TaskEventType | ReminderEventType | TranslationEventType | NotificationEventType | ProviderEventType | AuthEventType | SecurityEventType;
543
- interface ConversationCreatedPayload {
544
- channel: string;
545
- origin_system: string;
546
- participant_count: number;
547
- }
548
- interface ConversationMessageSentPayload {
549
- channel: string;
550
- direction: string;
551
- message_chars: number;
552
- has_attachment: boolean;
553
- provider_system: string;
554
- }
555
- interface ConversationMessageReceivedPayload {
556
- channel: string;
557
- direction: string;
558
- message_chars: number;
559
- provider_system: string;
560
- }
561
- interface ConversationMarkedReadPayload {
562
- read_by_actor_id: string;
563
- unread_count_before: number;
564
- unread_count_after: number;
565
- }
566
- interface ConversationAttachmentUploadedPayload {
567
- attachment_id: string;
568
- mime_type: string;
569
- size_bytes: number;
570
- storage_class: string;
571
- }
572
- interface ConversationAttachmentDownloadedPayload {
573
- attachment_id: string;
574
- download_actor_type: string;
575
- access_path: string;
576
- }
577
- interface CallInitiatedPayload {
578
- direction: string;
579
- provider_system: string;
580
- from_number_ref: string;
581
- to_number_ref: string;
582
- }
583
- interface CallConnectedPayload {
584
- provider_system: string;
585
- ring_duration_ms: number;
586
- }
587
- interface CallEndedPayload {
588
- provider_system: string;
589
- duration_ms: number;
590
- end_reason: string;
591
- disposition: string;
592
- }
593
- interface CallMissedPayload {
594
- provider_system: string;
595
- miss_reason: string;
596
- }
597
- interface TaskCreatedPayload {
598
- task_id: string;
599
- created_by: string;
600
- assigned_to: string;
601
- priority: string;
602
- due_at: string;
603
- }
604
- interface TaskAssignedPayload {
605
- task_id: string;
606
- assigned_to: string;
607
- assigned_by: string;
608
- }
609
- interface TaskStatusChangedPayload {
610
- task_id: string;
611
- status_from: string;
612
- status_to: string;
613
- changed_by: string;
614
- }
615
- interface ReminderScheduledPayload {
616
- reminder_id: string;
617
- conversation_id: string;
618
- scheduled_for: string;
619
- scheduled_by: string;
620
- }
621
- interface ReminderTriggeredPayload {
622
- reminder_id: string;
623
- trigger_result: string;
624
- notification_attempted: boolean;
625
- }
626
- interface TranslationRequestedPayload {
627
- target_language: string;
628
- source_language: string;
629
- char_count: number;
630
- mode: string;
631
- }
632
- interface TranslationCompletedPayload {
633
- target_language: string;
634
- provider: string;
635
- latency_ms: number;
636
- success: boolean;
637
- error_code?: string;
638
- }
639
- interface NotificationSentPayload {
640
- notification_id: string;
641
- channel: string;
642
- platform: string;
643
- recipient_ref: string;
644
- success: boolean;
645
- }
646
- interface NotificationDeliveredPayload {
647
- notification_id: string;
648
- platform: string;
649
- delivered_at: string;
650
- }
651
- interface NotificationOpenedPayload {
652
- notification_id: string;
653
- platform: string;
654
- opened_at: string;
655
- }
656
- interface ProviderSyncStartedPayload {
657
- provider_system: string;
658
- operation: string;
659
- scope: string;
660
- batch_id: string;
661
- }
662
- interface ProviderSyncSucceededPayload {
663
- provider_system: string;
664
- operation: string;
665
- batch_id: string;
666
- records_processed: number;
667
- duration_ms: number;
668
- }
669
- interface ProviderSyncFailedPayload {
670
- provider_system: string;
671
- operation: string;
672
- batch_id: string;
673
- error_code: string;
674
- retryable: boolean;
675
- }
676
- interface AuthLoginSucceededPayload {
677
- auth_provider: string;
678
- platform: string;
679
- session_ref: string;
680
- }
681
- interface AuthLoginFailedPayload {
682
- auth_provider: string;
683
- platform: string;
684
- failure_code: string;
685
- }
686
- interface SecurityAccessDeniedPayload {
687
- resource: string;
688
- policy: string;
689
- reason_code: string;
690
- actor_id: string;
691
- }
692
- /**
693
- * Maps each event type string to its required payload interface.
694
- */
695
- interface EventPayloadMap {
696
- "conversation.created.v1": ConversationCreatedPayload;
697
- "conversation.message_sent.v1": ConversationMessageSentPayload;
698
- "conversation.message_received.v1": ConversationMessageReceivedPayload;
699
- "conversation.marked_read.v1": ConversationMarkedReadPayload;
700
- "conversation.attachment_uploaded.v1": ConversationAttachmentUploadedPayload;
701
- "conversation.attachment_downloaded.v1": ConversationAttachmentDownloadedPayload;
702
- "call.initiated.v1": CallInitiatedPayload;
703
- "call.connected.v1": CallConnectedPayload;
704
- "call.ended.v1": CallEndedPayload;
705
- "call.missed.v1": CallMissedPayload;
706
- "task.created.v1": TaskCreatedPayload;
707
- "task.assigned.v1": TaskAssignedPayload;
708
- "task.status_changed.v1": TaskStatusChangedPayload;
709
- "reminder.scheduled.v1": ReminderScheduledPayload;
710
- "reminder.triggered.v1": ReminderTriggeredPayload;
711
- "translation.requested.v1": TranslationRequestedPayload;
712
- "translation.completed.v1": TranslationCompletedPayload;
713
- "notification.sent.v1": NotificationSentPayload;
714
- "notification.delivered.v1": NotificationDeliveredPayload;
715
- "notification.opened.v1": NotificationOpenedPayload;
716
- "provider.sync_started.v1": ProviderSyncStartedPayload;
717
- "provider.sync_succeeded.v1": ProviderSyncSucceededPayload;
718
- "provider.sync_failed.v1": ProviderSyncFailedPayload;
719
- "auth.login_succeeded.v1": AuthLoginSucceededPayload;
720
- "auth.login_failed.v1": AuthLoginFailedPayload;
721
- "security.access_denied.v1": SecurityAccessDeniedPayload;
722
- }
723
- /**
724
- * Subject references for the event. Uses tokenized references only -- no PHI.
725
- */
726
- interface EventSubject {
727
- patient_ref?: string;
728
- conversation_id?: string;
729
- task_id?: string;
730
- call_id?: string;
731
- }
732
- /**
733
- * Actor who triggered the event.
734
- */
735
- interface EventActor {
736
- actor_id: string;
737
- actor_type: "user" | "system" | "webhook";
738
- }
739
- /**
740
- * Compliance metadata for the event.
741
- */
742
- interface EventCompliance {
743
- pii_level: "none" | "limited" | "full";
744
- contains_phi: boolean;
745
- consent_context: string;
746
- retention_class: string;
747
- }
748
- /**
749
- * Optional overrides when calling truth.track().
750
- */
751
- interface TrackOptions {
752
- /** Override the default actor for this event */
753
- actor?: EventActor;
754
- /** Subject references for this event */
755
- subject?: EventSubject;
756
- /** Compliance metadata for this event */
757
- compliance?: EventCompliance;
758
- /** Override the default tenant ID for this event */
759
- tenantId?: string;
760
- /** Override the occurred_at timestamp (ISO 8601) */
761
- occurredAt?: string;
762
- }
763
-
764
- /**
765
- * Actor context attached to tracked events.
766
- */
767
- interface ActorContext {
768
- actorId: string;
769
- actorType: "user" | "system" | "webhook";
770
- }
771
-
772
- interface TruthTrackingContextValue {
773
- track: <T extends EventType>(eventType: T, payload: EventPayloadMap[T], options?: TrackOptions) => void;
774
- identify: (actorId: string, actorType: ActorContext["actorType"]) => void;
775
- }
776
- interface TruthTrackingProviderProps {
777
- /** Truth environment — determines API URL for event delivery */
778
- environment?: string;
779
- /** Event source identifier */
780
- source?: string;
781
- /** Source version (git SHA) */
782
- sourceVersion?: string;
783
- /** Default tenant ID */
784
- tenantId?: string;
785
- /** API key for authentication */
786
- apiKey?: string;
787
- children: ReactNode;
788
- }
789
- declare function TruthTrackingProvider({ environment, source, sourceVersion, tenantId, apiKey, children, }: TruthTrackingProviderProps): react.FunctionComponentElement<react.ProviderProps<TruthTrackingContextValue | null>>;
790
- /**
791
- * Access the Truth tracking context. Must be within a TruthTrackingProvider.
792
- * Returns `{ track, identify }` for emitting events to Kinesis.
793
- */
794
- declare function useTruth(): TruthTrackingContextValue;
795
-
796
- /**
797
- * Appointment interfaces for the Truth SDK.
798
- */
799
- /**
800
- * Normalized appointment record from the Truth platform.
801
- */
802
- interface Appointment {
803
- /** Truth platform appointment ID */
804
- id: string;
805
- /** Associated patient ID */
806
- patientId: string;
807
- /** Provider/practitioner ID */
808
- providerId?: string;
809
- /** Provider/practitioner name */
810
- providerName?: string;
811
- /** Appointment start time (ISO 8601) */
812
- startTime: string;
813
- /** Appointment end time (ISO 8601) */
814
- endTime: string;
815
- /** Appointment status */
816
- status: string;
817
- /** Appointment type or reason */
818
- appointmentType?: string;
819
- /** Visit reason or chief complaint */
820
- reason?: string;
821
- /** Location or facility name */
822
- location?: string;
823
- /** Source EHR system (e.g. "elation", "hint") */
824
- sourceSystem?: string;
825
- /** ID in the source EHR system */
826
- sourceId?: string;
827
- /** Associated organization/tenant ID */
828
- tenantId: string;
829
- /** ISO 8601 timestamp of record creation */
830
- createdAt: string;
831
- /** ISO 8601 timestamp of last update */
832
- updatedAt: string;
833
- }
834
- /**
835
- * Options for listing appointments.
836
- */
837
- interface AppointmentListOptions {
838
- /** Filter by patient ID */
839
- patientId?: string;
840
- /** Filter by start date (ISO 8601 date string) */
841
- startDate?: string;
842
- /** Filter by end date (ISO 8601 date string) */
843
- endDate?: string;
844
- /** Filter by appointment status */
845
- status?: string;
846
- /** Maximum number of results to return */
847
- limit?: number;
848
- /** Cursor for pagination */
849
- cursor?: string;
850
- }
851
-
852
- /**
853
- * Patient interfaces for the Truth SDK.
854
- */
855
- /**
856
- * Normalized patient record from the Truth platform.
857
- */
858
- interface Patient {
859
- /** Truth platform patient ID */
860
- id: string;
861
- /** Elation EHR patient ID (if linked) */
862
- elationId?: string;
863
- /** Hint EHR patient ID (if linked) */
864
- hintId?: string;
865
- /** Patient first name */
866
- firstName: string;
867
- /** Patient last name */
868
- lastName: string;
869
- /** Date of birth (ISO 8601 date string, e.g. "1990-01-15") */
870
- dateOfBirth?: string;
871
- /** Patient sex */
872
- sex?: string;
873
- /** Primary email address */
874
- email?: string;
875
- /** Primary phone number */
876
- phone?: string;
877
- /** Patient status in the system */
878
- status: string;
879
- /** Associated organization/tenant ID */
880
- tenantId: string;
881
- /** ISO 8601 timestamp of record creation */
882
- createdAt: string;
883
- /** ISO 8601 timestamp of last update */
884
- updatedAt: string;
885
- }
886
- /**
887
- * Options for listing patients.
888
- */
889
- interface PatientListOptions {
890
- /** Search patients by name, email, or phone */
891
- search?: string;
892
- /** Maximum number of results to return */
893
- limit?: number;
894
- /** Cursor for pagination */
895
- cursor?: string;
896
- }
897
-
898
- export { type Appointment, type AppointmentListOptions, type ConversationListItem, type ConversationMessage, type ConversationMessageRow, type ConversationRow, type EventPayloadMap, type EventType, type Patient, type PatientListOptions, type PermissionStatus, type Physician, type TrackOptions, TruthProvider, type TruthProviderProps, type TruthTrackingContextValue, TruthTrackingProvider, type TruthTrackingProviderProps, type UseAppointmentListOptions, type UseConversationMessagesOptions, type UseConversationsFilters, type UseMessagesOptions, type UseNotificationsOptions, type UseNotificationsResult, type UsePatientBasicOptions, type UsePatientBasicResult, type UsePatientListOptions, type UsePatientMedicalOptions, type UsePatientPhotoOptions, type UseQueryResult, useAppointment, useAppointmentByElationId, useAppointments, useConversationByPhonePair, useConversationMessages, useConversations, useMessages, useNotifications, usePatient, usePatientBasic, usePatientByElationId, usePatientByHintId, usePatientMedical, usePatientPhoto, usePatients, usePharmacyByNcpdpId, usePhysicianByElationId, usePhysiciansByElationIds, useTruth, useUnreadCount };