@hipnation-truth/sdk 0.26.19 → 0.27.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.
package/dist/react.d.ts CHANGED
@@ -2,6 +2,7 @@ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as convex_browser from 'convex/browser';
4
4
  import { ConvexHttpClient } from 'convex/browser';
5
+ import { z } from 'zod';
5
6
 
6
7
  /**
7
8
  * React hooks for Truth SDK — reactive conversation + message data.
@@ -417,6 +418,17 @@ interface DialpadCallRow {
417
418
  voicemailLink: string | null;
418
419
  voicemailDurationSec: number | null;
419
420
  transcript: unknown | null;
421
+ /** Dialpad AI Recap — arrives via a separate `recap_summary` event after hangup. */
422
+ recapSummary: string | null;
423
+ /**
424
+ * User-authored call summary (#454) — distinct from `recapSummary`
425
+ * above; the user creates/edits this via `useSaveCallSummary`. Never
426
+ * written by the Dialpad webhook.
427
+ */
428
+ userSummary: string | null;
429
+ /** Email/Clerk id of whoever last saved `userSummary`. */
430
+ userSummaryBy: string | null;
431
+ userSummaryUpdatedAt: string | null;
420
432
  duration: number | null;
421
433
  occurredAt: string;
422
434
  updatedAt: string;
@@ -461,6 +473,27 @@ declare function useDialpadCallByCallId(callId: string | null | undefined): UseQ
461
473
  declare function useDialpadCallLog(callId: string | null | undefined, options?: {
462
474
  limit?: number;
463
475
  }): UseQueryResult<DialpadCallLogRow[]>;
476
+ /**
477
+ * Returns a stable `saveCallSummary(callId, userSummary, updatedBy)`
478
+ * callback backed by the `dialpadCallEvents:setUserSummary` Convex
479
+ * mutation. Writes the USER-authored call summary (#454) — separate from
480
+ * the Dialpad AI `recapSummary` surfaced read-only above; this never
481
+ * touches that field. Mirrors `useConversationTaskMarkSeen` in
482
+ * `./tasks.ts`: plain `useMutation` + `useCallback`, not a live
483
+ * subscription.
484
+ *
485
+ * @example
486
+ * ```tsx
487
+ * const saveCallSummary = useSaveCallSummary();
488
+ *
489
+ * async function onSave() {
490
+ * await saveCallSummary(call.callId, notes, currentUser.email);
491
+ * }
492
+ * ```
493
+ */
494
+ declare function useSaveCallSummary(): (callId: string, userSummary: string, updatedBy: string) => Promise<{
495
+ ok: true;
496
+ }>;
464
497
 
465
498
  /**
466
499
  * React hook for a single conversation lookup by Convex id — Truth SDK.
@@ -1402,7 +1435,6 @@ interface Attachment {
1402
1435
  }
1403
1436
  declare class AttachmentsResource {
1404
1437
  private readonly baseUrl;
1405
- private readonly apiKey;
1406
1438
  private readonly auth;
1407
1439
  private readonly convex;
1408
1440
  constructor(apiBaseUrl: string, apiKey: string, convexClient: ConvexHttpClient, getAuthToken?: AuthTokenFetcher);
@@ -1658,7 +1690,6 @@ interface DialpadNumberInfo {
1658
1690
  }
1659
1691
  declare class DialpadResource {
1660
1692
  private readonly baseUrl;
1661
- private readonly apiKey;
1662
1693
  private readonly auth;
1663
1694
  constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
1664
1695
  /**
@@ -1724,7 +1755,6 @@ declare class DialpadResource {
1724
1755
  declare class MessagesResource {
1725
1756
  readonly dialpad: DialpadResource;
1726
1757
  private readonly baseUrl;
1727
- private readonly apiKey;
1728
1758
  private readonly auth;
1729
1759
  constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
1730
1760
  /**
@@ -1853,7 +1883,6 @@ interface PushConversationToElationResult {
1853
1883
  }
1854
1884
  declare class NotesResource {
1855
1885
  private readonly baseUrl;
1856
- private readonly apiKey;
1857
1886
  private readonly auth;
1858
1887
  constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
1859
1888
  /** 30s upstream timeout — Elation API has occasional slow hops; we
@@ -1995,7 +2024,6 @@ interface PushEventPayload {
1995
2024
  }
1996
2025
  declare class NotificationsResource {
1997
2026
  private readonly baseUrl;
1998
- private readonly apiKey;
1999
2027
  private readonly auth;
2000
2028
  constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
2001
2029
  private post;
@@ -2077,7 +2105,6 @@ interface PatientMedicalDetailsResult {
2077
2105
  }
2078
2106
  declare class PatientDetailsResource {
2079
2107
  private readonly baseUrl;
2080
- private readonly apiKey;
2081
2108
  private readonly auth;
2082
2109
  constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
2083
2110
  private post;
@@ -2231,6 +2258,114 @@ declare class RemindersResource {
2231
2258
  listByConversation(conversationId: string): Promise<Reminder[]>;
2232
2259
  }
2233
2260
 
2261
+ /**
2262
+ * ReportsResource — member activation report from truth.
2263
+ *
2264
+ * Accesses the Truth API at GET /reports/member-activation,
2265
+ * authenticated with X-API-Key + user JWT (verifiedUserProcedure).
2266
+ *
2267
+ * Replaces the broker pattern: frontend calls truth directly via SDK,
2268
+ * no comhub hop.
2269
+ */
2270
+
2271
+ declare const reportSchema: z.ZodObject<{
2272
+ synthetic: z.ZodBoolean;
2273
+ generatedAt: z.ZodString;
2274
+ employers: z.ZodArray<z.ZodObject<{
2275
+ id: z.ZodString;
2276
+ name: z.ZodString;
2277
+ activeMembers: z.ZodNumber;
2278
+ }, z.core.$strip>>;
2279
+ selected: z.ZodNullable<z.ZodObject<{
2280
+ employerId: z.ZodString;
2281
+ employerName: z.ZodString;
2282
+ kpis: z.ZodObject<{
2283
+ active: z.ZodNumber;
2284
+ linked: z.ZodNumber;
2285
+ activated: z.ZodNumber;
2286
+ needsOutreach: z.ZodNumber;
2287
+ scheduled: z.ZodNumber;
2288
+ needsReview: z.ZodNumber;
2289
+ dataIssue: z.ZodNumber;
2290
+ activationRate: z.ZodNumber;
2291
+ }, z.core.$strip>;
2292
+ coverage: z.ZodObject<{
2293
+ active: z.ZodNumber;
2294
+ linked: z.ZodNumber;
2295
+ unlinked: z.ZodNumber;
2296
+ pct: z.ZodNumber;
2297
+ }, z.core.$strip>;
2298
+ breakdown: z.ZodArray<z.ZodObject<{
2299
+ status: z.ZodEnum<{
2300
+ data: "data";
2301
+ activated: "activated";
2302
+ outreach: "outreach";
2303
+ scheduled: "scheduled";
2304
+ review: "review";
2305
+ }>;
2306
+ label: z.ZodString;
2307
+ count: z.ZodNumber;
2308
+ pct: z.ZodNumber;
2309
+ }, z.core.$strip>>;
2310
+ aging: z.ZodArray<z.ZodObject<{
2311
+ bucket: z.ZodString;
2312
+ total: z.ZodNumber;
2313
+ outreach: z.ZodNumber;
2314
+ scheduled: z.ZodNumber;
2315
+ review: z.ZodNumber;
2316
+ }, z.core.$strip>>;
2317
+ doctors: z.ZodArray<z.ZodObject<{
2318
+ name: z.ZodString;
2319
+ counts: z.ZodObject<{
2320
+ outreach: z.ZodNumber;
2321
+ scheduled: z.ZodNumber;
2322
+ review: z.ZodNumber;
2323
+ data: z.ZodNumber;
2324
+ }, z.core.$strip>;
2325
+ members: z.ZodArray<z.ZodObject<{
2326
+ elationId: z.ZodString;
2327
+ name: z.ZodString;
2328
+ doctor: z.ZodNullable<z.ZodString>;
2329
+ status: z.ZodEnum<{
2330
+ data: "data";
2331
+ activated: "activated";
2332
+ outreach: "outreach";
2333
+ scheduled: "scheduled";
2334
+ review: "review";
2335
+ }>;
2336
+ membershipStart: z.ZodString;
2337
+ daysSinceMembershipStart: z.ZodNumber;
2338
+ activationDate: z.ZodNullable<z.ZodString>;
2339
+ futureApptDate: z.ZodNullable<z.ZodString>;
2340
+ reason: z.ZodNullable<z.ZodString>;
2341
+ hasLink: z.ZodBoolean;
2342
+ }, z.core.$strip>>;
2343
+ }, z.core.$strip>>;
2344
+ }, z.core.$strip>>;
2345
+ pending: z.ZodBoolean;
2346
+ }, z.core.$strip>;
2347
+ type MemberActivationReport = z.infer<typeof reportSchema>;
2348
+ declare class ReportsResource {
2349
+ private readonly baseUrl;
2350
+ private readonly auth;
2351
+ /**
2352
+ * Captures the Truth API base URL and the auth inputs (API key + optional
2353
+ * user-token fetcher) needed to authenticate every request this resource
2354
+ * makes.
2355
+ */
2356
+ constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
2357
+ /**
2358
+ * Fetches the member activation report from GET /reports/member-activation,
2359
+ * optionally scoped to a single employer. Requires the user JWT (not just
2360
+ * the API key) since the server hardens this route to
2361
+ * `verifiedUserProcedure` for PHI access — throws via `ReportsError` on a
2362
+ * non-OK response, including the response body (truncated) when present.
2363
+ */
2364
+ memberActivation(params?: {
2365
+ employerId?: string;
2366
+ }): Promise<MemberActivationReport>;
2367
+ }
2368
+
2234
2369
  type TaskStatus = "open" | "in_progress" | "resolved" | "cancelled";
2235
2370
  interface Task {
2236
2371
  _id: string;
@@ -2349,7 +2484,6 @@ interface TranslateBatchInput {
2349
2484
 
2350
2485
  declare class TranslationResource {
2351
2486
  private readonly baseUrl;
2352
- private readonly apiKey;
2353
2487
  private readonly auth;
2354
2488
  constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
2355
2489
  private post;
@@ -2711,6 +2845,8 @@ declare class TruthClient {
2711
2845
  readonly patientDetails: PatientDetailsResource;
2712
2846
  /** Attachments — presigned S3 upload/download + Convex metadata */
2713
2847
  readonly attachments: AttachmentsResource;
2848
+ /** Reports — member activation report (Truth API) */
2849
+ readonly reports: ReportsResource;
2714
2850
  /** Notes — push formatted notes to Elation */
2715
2851
  readonly notes: NotesResource;
2716
2852
  /** Physicians (Convex-backed cache from Elation) */
@@ -2727,8 +2863,18 @@ declare class TruthClient {
2727
2863
  private _vapidPublicKey;
2728
2864
  private _webPushReady;
2729
2865
  private readonly _serviceWorkerPath;
2866
+ /**
2867
+ * Builds the Convex client and event tracker from `config`, then wires up
2868
+ * every resource (patients, appointments, EHR proxy, reports, etc.) so
2869
+ * each shares the same Convex connection / API base URL / auth token
2870
+ * fetcher. When running in a browser that supports web push and the
2871
+ * caller hasn't opted out, kicks off best-effort service-worker
2872
+ * registration and push subscription in the background.
2873
+ */
2730
2874
  constructor(config: TruthClientConfig);
2875
+ /** The VAPID public key fetched during web-push init, or `null` until `webPushReady` resolves (or if push is unsupported/disabled). */
2731
2876
  get vapidPublicKey(): string | null;
2877
+ /** Resolves once background web-push initialization (service worker registration + subscription) finishes; `null` if it was never started (SSR, unsupported browser, or opted out via config). */
2732
2878
  get webPushReady(): Promise<void> | null;
2733
2879
  /**
2734
2880
  * When a Clerk token fetcher is configured (publishable-key clients),
@@ -2738,6 +2884,14 @@ declare class TruthClient {
2738
2884
  * → resolve immediately (secret-key path is unaffected).
2739
2885
  */
2740
2886
  private waitForAuthToken;
2887
+ /**
2888
+ * Best-effort web-push bootstrap: waits for auth (if configured), fetches
2889
+ * the VAPID key, registers the service worker, subscribes to push, and
2890
+ * registers the device with a placeholder `__pending__` userId (the
2891
+ * backend reconciles this once the real user is known). Any failure
2892
+ * along the way is swallowed — push notifications are opportunistic and
2893
+ * must never break client construction.
2894
+ */
2741
2895
  private initWebPush;
2742
2896
  /**
2743
2897
  * The resolved Truth API base URL for this environment.
@@ -3133,4 +3287,4 @@ interface UseVoicemailUrlResult {
3133
3287
  */
3134
3288
  declare function useVoicemailUrl(client: TruthClient): UseVoicemailUrlResult;
3135
3289
 
3136
- export { ACTIVE_CALL_STATES, API_BASE_URLS, type Appointment, type AppointmentListOptions, CONNECTED_CALL_STATES, CONVEX_URLS, type ConversationListItem, type ConversationMessage, type ConversationMessageRow, type ConversationNoteRow, type ConversationRow, type ConversationTaskForUserRow, type ConversationTaskRow, type DialpadCallLogRow, type DialpadCallRow, DialpadCallState, type EventPayloadMap, type EventType, type FamilyMemberRow, NoopStore, type OfflineStore, type Patient, type PatientListOptions, type PatientSearchResult, type PermissionStatus, type Physician$1 as Physician, RINGING_CALL_STATES, TERMINAL_CALL_STATES, type TrackOptions, TruthProvider, type TruthProviderProps, type TruthTrackingContextValue, TruthTrackingProvider, type TruthTrackingProviderProps, type UseActiveCallsOptions, type UseAppointmentListOptions, type UseConversationMessagesOptions, type UseConversationsFilters, type UseMessagesOptions, type UseNotificationsActions, type UseNotificationsOptions, type UseNotificationsResult, type UsePatientBasicOptions, type UsePatientBasicResult, type UsePatientFamilyMembersInput, type UsePatientListOptions, type UsePatientMedicalOptions, type UsePatientPhotoOptions, type UsePatientSearchOptions, type UseQueryResult, type UseUserSyncInput, type UseUserSyncResult, getTruthClient, readPersistedSavedAt, resolveApiBaseUrl, resolveConvexUrl, useActiveCalls, useAppointment, useAppointmentByElationId, useAppointments, useConversationById, useConversationByPhonePair, useConversationMessages, useConversationNotes, useConversationNotesByPhonePair, useConversationTaskMarkSeen, useConversationTasks, useConversationTasksByPhonePair, useConversationTasksForUser, useConversations, useDialpadCallByCallId, useDialpadCallLog, useDialpadCallsForConversation, useMessages, useNotifications, useNotificationsActions, useOfflineEnabled, useOfflineStore, usePatient, usePatientBasic, usePatientByElationId, usePatientByHintId, usePatientFamilyMembers, usePatientMedical, usePatientPhoto, usePatientSearch, usePatients, usePatientsByIds, usePatientsByPhones, usePharmacyByNcpdpId, usePhysicianByElationId, usePhysiciansByElationIds, useRemindersForConversations, useTruth, useTruthClient, useTruthSdkContext, useUnreadAggregate, useUnreadCount, useUserSettings, useUserSync, useVoicemailUrl };
3290
+ export { ACTIVE_CALL_STATES, API_BASE_URLS, type Appointment, type AppointmentListOptions, CONNECTED_CALL_STATES, CONVEX_URLS, type ConversationListItem, type ConversationMessage, type ConversationMessageRow, type ConversationNoteRow, type ConversationRow, type ConversationTaskForUserRow, type ConversationTaskRow, type DialpadCallLogRow, type DialpadCallRow, DialpadCallState, type EventPayloadMap, type EventType, type FamilyMemberRow, NoopStore, type OfflineStore, type Patient, type PatientListOptions, type PatientSearchResult, type PermissionStatus, type Physician$1 as Physician, RINGING_CALL_STATES, TERMINAL_CALL_STATES, type TrackOptions, TruthProvider, type TruthProviderProps, type TruthTrackingContextValue, TruthTrackingProvider, type TruthTrackingProviderProps, type UseActiveCallsOptions, type UseAppointmentListOptions, type UseConversationMessagesOptions, type UseConversationsFilters, type UseMessagesOptions, type UseNotificationsActions, type UseNotificationsOptions, type UseNotificationsResult, type UsePatientBasicOptions, type UsePatientBasicResult, type UsePatientFamilyMembersInput, type UsePatientListOptions, type UsePatientMedicalOptions, type UsePatientPhotoOptions, type UsePatientSearchOptions, type UseQueryResult, type UseUserSyncInput, type UseUserSyncResult, getTruthClient, readPersistedSavedAt, resolveApiBaseUrl, resolveConvexUrl, useActiveCalls, useAppointment, useAppointmentByElationId, useAppointments, useConversationById, useConversationByPhonePair, useConversationMessages, useConversationNotes, useConversationNotesByPhonePair, useConversationTaskMarkSeen, useConversationTasks, useConversationTasksByPhonePair, useConversationTasksForUser, useConversations, useDialpadCallByCallId, useDialpadCallLog, useDialpadCallsForConversation, useMessages, useNotifications, useNotificationsActions, useOfflineEnabled, useOfflineStore, usePatient, usePatientBasic, usePatientByElationId, usePatientByHintId, usePatientFamilyMembers, usePatientMedical, usePatientPhoto, usePatientSearch, usePatients, usePatientsByIds, usePatientsByPhones, usePharmacyByNcpdpId, usePhysicianByElationId, usePhysiciansByElationIds, useRemindersForConversations, useSaveCallSummary, useTruth, useTruthClient, useTruthSdkContext, useUnreadAggregate, useUnreadCount, useUserSettings, useUserSync, useVoicemailUrl };