@hipnation-truth/sdk 0.23.1 → 0.24.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
@@ -599,6 +599,14 @@ interface UsePatientMedicalOptions {
599
599
  * against Truth's `/api/patients/medical/refresh` endpoint so stale data
600
600
  * is pulled in without blocking render. Returns cached data immediately;
601
601
  * Convex subscription updates the UI when refresh completes.
602
+ *
603
+ * OFFLINE-READS POLICY: these medical-record queries ARE mirrored offline
604
+ * via `usePersistentQuery`, so medications, problems, allergies and
605
+ * appointments render from the at-rest mirror when the device is offline.
606
+ * Full medical records are the most sensitive PHI we hold, so they are
607
+ * only ever written to the encrypted-at-rest store (256-bit MMKV key held
608
+ * in the device keychain), never to any plaintext storage. Keep them on
609
+ * the encrypted mirror only — do not relax the store's encryption.
602
610
  */
603
611
  declare function usePatientMedical(elationId: number | undefined, options?: UsePatientMedicalOptions): {
604
612
  medications: unknown[] | undefined;
@@ -690,6 +698,14 @@ interface ConversationMessage {
690
698
  mms: boolean;
691
699
  mmsUrl: string | null;
692
700
  messageStatus: string | null;
701
+ /**
702
+ * True while an outbound SMS is the optimistic local row inserted by the
703
+ * Truth `sendMessage` path and not yet reconciled by the Dialpad webhook
704
+ * (Truth #100). Clients gate a "sending" affordance on THIS flag — not on
705
+ * `messageStatus === "optimistic"`, a value minted nowhere. Always `false`
706
+ * for calls and reconciled rows.
707
+ */
708
+ optimistic: boolean;
693
709
  occurredAt: string;
694
710
  conversationId: string | null;
695
711
  patientId: string | null;
@@ -826,6 +842,77 @@ interface UseNotificationsActions {
826
842
  }
827
843
  declare function useNotificationsActions(): UseNotificationsActions;
828
844
 
845
+ /**
846
+ * Offline mirror storage seam.
847
+ *
848
+ * The Truth SDK is consumed by two apps with very different storage
849
+ * stories:
850
+ * - `ch/` (Expo / React Native) — has access to native, encrypted,
851
+ * synchronous KV (MMKV) and wants durable offline reads.
852
+ * - `truth/apps/web` (Next.js) — has no such store and must behave
853
+ * exactly as it does today.
854
+ *
855
+ * So the SDK never imports a native module. Instead the consuming app
856
+ * *injects* an `OfflineStore` implementation through `<TruthProvider>`.
857
+ * When none is injected the SDK falls back to {@link NoopStore} and the
858
+ * entire offline layer becomes a transparent pass-through.
859
+ *
860
+ * The interface is deliberately **synchronous**: cold-start hydration
861
+ * has to read the last-known value during the first render, before any
862
+ * effect or promise resolves, so async storage (AsyncStorage) is not
863
+ * sufficient here. MMKV's `getString`/`set` are synchronous and map
864
+ * onto this directly.
865
+ */
866
+ /** Synchronous KV mirror. Sync getters enable instant cold-start hydration. */
867
+ interface OfflineStore {
868
+ /** Return the stored string for `key`, or `null` when absent. */
869
+ get(key: string): string | null;
870
+ /** Write `value` under `key`, overwriting any prior value. */
871
+ set(key: string, value: string): void;
872
+ /** Remove a single `key`. No-op when absent. */
873
+ delete(key: string): void;
874
+ /**
875
+ * Wipe every key this store owns. Called on logout / user switch so a
876
+ * second user on the same device never sees the first user's cached
877
+ * PHI. MUST clear durably (survive the next cold start).
878
+ */
879
+ clearAll(): void;
880
+ }
881
+ /**
882
+ * Used when no store is injected (e.g. `truth/apps/web`) → the offline
883
+ * layer is a no-op and behavior is identical to a build without it.
884
+ */
885
+ declare class NoopStore implements OfflineStore {
886
+ get(): string | null;
887
+ set(): void;
888
+ delete(): void;
889
+ clearAll(): void;
890
+ }
891
+
892
+ /**
893
+ * TanStack Query persister backed by the injected {@link OfflineStore}.
894
+ *
895
+ * Under Path A the whole dehydrated query cache is serialized as a
896
+ * single blob and written through the synchronous `OfflineStore` (MMKV
897
+ * on `ch/`). On cold start `PersistQueryClientProvider` calls
898
+ * `restoreClient()` to rehydrate that blob before the Convex websocket
899
+ * reconnects, which is what makes last-known data render with no
900
+ * network.
901
+ *
902
+ * The store is synchronous, so all three methods resolve immediately —
903
+ * but the `Persister` contract allows returning a value or a promise, so
904
+ * returning the raw values is fine.
905
+ */
906
+
907
+ /**
908
+ * Read the epoch-millis timestamp the persisted cache was last written
909
+ * (TanStack stamps `timestamp` on every persist → it tracks the most
910
+ * recent successful sync). Returns `null` when nothing is persisted or
911
+ * the blob is unreadable. Powers the "Offline · updated {relative}"
912
+ * indicator without the app having to know the dehydrated cache format.
913
+ */
914
+ declare function readPersistedSavedAt(store: OfflineStore, cacheKey?: string): number | null;
915
+
829
916
  /**
830
917
  * React hook for patient family-member lookup — Truth SDK.
831
918
  *
@@ -1361,6 +1448,12 @@ interface SetConversationTaskStatusInput {
1361
1448
  taskId: string;
1362
1449
  status: ConversationTaskStatus;
1363
1450
  resolvedBy?: string;
1451
+ /**
1452
+ * Email of the user performing the action. Truth excludes the actor
1453
+ * from the task-action push fan-out (legacy parity) — omit it and the
1454
+ * actor notifies themselves.
1455
+ */
1456
+ actor?: string;
1364
1457
  }
1365
1458
  interface UpdateConversationTaskInput {
1366
1459
  taskId: string;
@@ -1375,6 +1468,18 @@ interface UpdateConversationTaskInput {
1375
1468
  status?: ConversationTaskStatus;
1376
1469
  assignee?: string;
1377
1470
  type?: string;
1471
+ /**
1472
+ * Email of the user performing the action. Truth excludes the actor
1473
+ * from the task-action push fan-out (legacy parity) — omit it and the
1474
+ * actor notifies themselves.
1475
+ */
1476
+ actor?: string;
1477
+ }
1478
+ interface SetConversationTaskArchivedInput {
1479
+ taskId: string;
1480
+ archived: boolean;
1481
+ /** Email of the acting user — excluded from the archive push fan-out. */
1482
+ actor?: string;
1378
1483
  }
1379
1484
  interface SendConversationMessageInput {
1380
1485
  fromNumber: string;
@@ -1407,6 +1512,11 @@ declare class ConversationTasksSubresource {
1407
1512
  setStatus(input: SetConversationTaskStatusInput): Promise<{
1408
1513
  ok: true;
1409
1514
  }>;
1515
+ /** Archive or un-archive a task (hides it from My Tasks without deleting). */
1516
+ setArchived(input: SetConversationTaskArchivedInput): Promise<{
1517
+ ok: true;
1518
+ changed: boolean;
1519
+ }>;
1410
1520
  /**
1411
1521
  * Update task fields (priority, assignee, description, type). Wraps
1412
1522
  * `PATCH /api/conversations/tasks/{id}` so CommHub doesn't have to
@@ -2643,6 +2753,10 @@ interface TruthSdkContextValue {
2643
2753
  apiKey: string;
2644
2754
  environment: string;
2645
2755
  client: TruthClient;
2756
+ /** Injected offline mirror (or the Noop default on web / flag off). */
2757
+ offlineStore: OfflineStore;
2758
+ /** Whether the offline-reads layer is active for this provider. */
2759
+ offlineEnabled: boolean;
2646
2760
  }
2647
2761
  /**
2648
2762
  * Read the Truth REST API base URL + API key + shared client from
@@ -2651,6 +2765,17 @@ interface TruthSdkContextValue {
2651
2765
  * compatibility.
2652
2766
  */
2653
2767
  declare function useTruthSdkContext(): TruthSdkContextValue | null;
2768
+ /**
2769
+ * Read the injected offline mirror. Returns the shared `NoopStore`
2770
+ * (transparent pass-through) when no provider is mounted or no store was
2771
+ * injected — so callers never have to null-check.
2772
+ */
2773
+ declare function useOfflineStore(): OfflineStore;
2774
+ /**
2775
+ * Whether the offline-reads layer is active. `false` when no provider is
2776
+ * mounted or the feature flag is off.
2777
+ */
2778
+ declare function useOfflineEnabled(): boolean;
2654
2779
  /**
2655
2780
  * Hook variant of `getTruthClient()` for code that lives inside the
2656
2781
  * React tree. Returns the shared `TruthClient` instance from
@@ -2688,9 +2813,24 @@ interface TruthProviderProps {
2688
2813
  source?: string;
2689
2814
  sourceVersion?: string;
2690
2815
  tenantId?: string;
2816
+ /**
2817
+ * Synchronous encrypted KV mirror for durable offline reads, injected
2818
+ * by the consuming app (e.g. MMKV on `ch/`). Omit on web — the SDK
2819
+ * falls back to a `NoopStore` and the offline layer is a transparent
2820
+ * pass-through. Never import a native module into the SDK; inject it
2821
+ * here instead.
2822
+ */
2823
+ offlineStore?: OfflineStore;
2824
+ /**
2825
+ * Feature flag for the offline-reads layer. Default `false`. Has no
2826
+ * effect unless a real (non-Noop) `offlineStore` is also injected.
2827
+ * When both are set, the TanStack query cache is persisted to the
2828
+ * store so last-known reads survive a cold start with no network.
2829
+ */
2830
+ offlineEnabled?: boolean;
2691
2831
  children: ReactNode;
2692
2832
  }
2693
- declare function TruthProvider({ environment, convexUrl, apiBaseUrl, apiKey, source, sourceVersion, tenantId, children, }: TruthProviderProps): react.FunctionComponentElement<react.ProviderProps<TruthSdkContextValue | null>>;
2833
+ declare function TruthProvider({ environment, convexUrl, apiBaseUrl, apiKey, source, sourceVersion, tenantId, offlineStore, offlineEnabled, children, }: TruthProviderProps): react.FunctionComponentElement<react.ProviderProps<TruthSdkContextValue | null>>;
2694
2834
 
2695
2835
  /**
2696
2836
  * React hooks for conversation reminders — bulk lookup keyed by
@@ -2889,4 +3029,4 @@ interface UseVoicemailUrlResult {
2889
3029
  */
2890
3030
  declare function useVoicemailUrl(client: TruthClient): UseVoicemailUrlResult;
2891
3031
 
2892
- 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, 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, resolveApiBaseUrl, resolveConvexUrl, useActiveCalls, useAppointment, useAppointmentByElationId, useAppointments, useConversationById, useConversationByPhonePair, useConversationMessages, useConversationNotes, useConversationNotesByPhonePair, useConversationTaskMarkSeen, useConversationTasks, useConversationTasksByPhonePair, useConversationTasksForUser, useConversations, useDialpadCallByCallId, useDialpadCallLog, useDialpadCallsForConversation, useMessages, useNotifications, useNotificationsActions, usePatient, usePatientBasic, usePatientByElationId, usePatientByHintId, usePatientFamilyMembers, usePatientMedical, usePatientPhoto, usePatientSearch, usePatients, usePatientsByIds, usePatientsByPhones, usePharmacyByNcpdpId, usePhysicianByElationId, usePhysiciansByElationIds, useRemindersForConversations, useTruth, useTruthClient, useTruthSdkContext, useUnreadAggregate, useUnreadCount, useUserSettings, useUserSync, useVoicemailUrl };
3032
+ 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 };