@hipnation-truth/sdk 0.23.2 → 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;
@@ -834,6 +842,77 @@ interface UseNotificationsActions {
834
842
  }
835
843
  declare function useNotificationsActions(): UseNotificationsActions;
836
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
+
837
916
  /**
838
917
  * React hook for patient family-member lookup — Truth SDK.
839
918
  *
@@ -1369,6 +1448,12 @@ interface SetConversationTaskStatusInput {
1369
1448
  taskId: string;
1370
1449
  status: ConversationTaskStatus;
1371
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;
1372
1457
  }
1373
1458
  interface UpdateConversationTaskInput {
1374
1459
  taskId: string;
@@ -1383,6 +1468,18 @@ interface UpdateConversationTaskInput {
1383
1468
  status?: ConversationTaskStatus;
1384
1469
  assignee?: string;
1385
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;
1386
1483
  }
1387
1484
  interface SendConversationMessageInput {
1388
1485
  fromNumber: string;
@@ -1415,6 +1512,11 @@ declare class ConversationTasksSubresource {
1415
1512
  setStatus(input: SetConversationTaskStatusInput): Promise<{
1416
1513
  ok: true;
1417
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
+ }>;
1418
1520
  /**
1419
1521
  * Update task fields (priority, assignee, description, type). Wraps
1420
1522
  * `PATCH /api/conversations/tasks/{id}` so CommHub doesn't have to
@@ -2651,6 +2753,10 @@ interface TruthSdkContextValue {
2651
2753
  apiKey: string;
2652
2754
  environment: string;
2653
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;
2654
2760
  }
2655
2761
  /**
2656
2762
  * Read the Truth REST API base URL + API key + shared client from
@@ -2659,6 +2765,17 @@ interface TruthSdkContextValue {
2659
2765
  * compatibility.
2660
2766
  */
2661
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;
2662
2779
  /**
2663
2780
  * Hook variant of `getTruthClient()` for code that lives inside the
2664
2781
  * React tree. Returns the shared `TruthClient` instance from
@@ -2696,9 +2813,24 @@ interface TruthProviderProps {
2696
2813
  source?: string;
2697
2814
  sourceVersion?: string;
2698
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;
2699
2831
  children: ReactNode;
2700
2832
  }
2701
- 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>>;
2702
2834
 
2703
2835
  /**
2704
2836
  * React hooks for conversation reminders — bulk lookup keyed by
@@ -2897,4 +3029,4 @@ interface UseVoicemailUrlResult {
2897
3029
  */
2898
3030
  declare function useVoicemailUrl(client: TruthClient): UseVoicemailUrlResult;
2899
3031
 
2900
- 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 };