@hipnation-truth/sdk 0.27.0 → 0.28.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/index.d.mts +462 -3
- package/dist/index.d.ts +462 -3
- package/dist/index.js +464 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +448 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +753 -86
- package/dist/react.js +899 -124
- package/dist/react.js.map +1 -1
- package/package.json +3 -3
package/dist/react.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FunctionReference } from 'convex/server';
|
|
1
2
|
import * as react from 'react';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
4
|
import * as convex_browser from 'convex/browser';
|
|
@@ -107,6 +108,12 @@ interface ConversationListItem {
|
|
|
107
108
|
/** ISO timestamp of when the caller last marked the conversation read. */
|
|
108
109
|
lastReadAt: string | null;
|
|
109
110
|
}
|
|
111
|
+
/** Row from `conversations:listUrgentForUser` (Urgent tab). */
|
|
112
|
+
interface UrgentConversationListItem extends ConversationListItem {
|
|
113
|
+
isUrgent: true;
|
|
114
|
+
urgentSetAt: string | null;
|
|
115
|
+
urgentSetBy: string | null;
|
|
116
|
+
}
|
|
110
117
|
/**
|
|
111
118
|
* Raw `conversations` table row — what `getByPhonePair` returns. No
|
|
112
119
|
* unread / read joining; for that, prefer `useConversations`.
|
|
@@ -121,6 +128,10 @@ interface ConversationRow {
|
|
|
121
128
|
lastEventId: string | null;
|
|
122
129
|
lastMessageAt: string;
|
|
123
130
|
createdAt: string;
|
|
131
|
+
/** Manual Urgent flag; absent/false = not urgent. */
|
|
132
|
+
isUrgent?: boolean;
|
|
133
|
+
urgentSetAt?: string;
|
|
134
|
+
urgentSetBy?: string;
|
|
124
135
|
}
|
|
125
136
|
/**
|
|
126
137
|
* Message row returned by `conversationMessages:getByConversationId` —
|
|
@@ -147,6 +158,43 @@ interface ConversationNoteRow {
|
|
|
147
158
|
type: string | null;
|
|
148
159
|
createdAt: string;
|
|
149
160
|
updatedAt: string;
|
|
161
|
+
/**
|
|
162
|
+
* ISO timestamp of the FIRST successful send to Elation; null if never sent.
|
|
163
|
+
* Never overwritten by a resend.
|
|
164
|
+
*/
|
|
165
|
+
elationSentAt: string | null;
|
|
166
|
+
/** Actor (Clerk user id) of the first send; null if never sent. */
|
|
167
|
+
elationSentBy: string | null;
|
|
168
|
+
/** Convex id of the `elationSyncEvents` audit row for the first send. */
|
|
169
|
+
elationSyncEventId: string | null;
|
|
170
|
+
/** ISO timestamp of the most recent resend; null if never resent. */
|
|
171
|
+
elationLastResentAt: string | null;
|
|
172
|
+
/** Actor (Clerk user id) of the most recent resend; null if never resent. */
|
|
173
|
+
elationLastResentBy: string | null;
|
|
174
|
+
/** `elationSyncEvents` audit row id of the most recent resend. */
|
|
175
|
+
elationLastResentSyncEventId: string | null;
|
|
176
|
+
/** Number of resends after the first send; 0 if never resent. */
|
|
177
|
+
elationResendCount: number;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* One task history entry (comhub#374): a task was completed or reopened.
|
|
181
|
+
* Append-only; written server-side on a real status transition.
|
|
182
|
+
*/
|
|
183
|
+
interface TaskEventRow {
|
|
184
|
+
id: string;
|
|
185
|
+
/** Convex id of the task (`conversationTasks` or standalone `tasks` row). */
|
|
186
|
+
taskId: string;
|
|
187
|
+
taskSource: "conversation" | "standalone";
|
|
188
|
+
/** Set for conversation tasks; null for standalone tasks. */
|
|
189
|
+
conversationId: string | null;
|
|
190
|
+
action: "completed" | "reopened";
|
|
191
|
+
/** Email of the user who made the change ("unknown" if not supplied). */
|
|
192
|
+
actor: string;
|
|
193
|
+
/** Resolved display name for `actor`, or null (fall back to `actor`). */
|
|
194
|
+
actorName: string | null;
|
|
195
|
+
/** Task title/description snapshot, for the link text. */
|
|
196
|
+
taskTitle: string | null;
|
|
197
|
+
occurredAt: string;
|
|
150
198
|
}
|
|
151
199
|
/**
|
|
152
200
|
* Conversation task row — single entry shown in the right-panel tasks
|
|
@@ -290,6 +338,10 @@ interface UseMessagesOptions {
|
|
|
290
338
|
* resolves (`userId === undefined`); not an error, just a skip.
|
|
291
339
|
*/
|
|
292
340
|
declare function useConversations(filters: UseConversationsFilters): UseQueryResult<ConversationListItem[]>;
|
|
341
|
+
/**
|
|
342
|
+
* Subscribe to the user's Urgent conversations (Urgent tab), newest first.
|
|
343
|
+
*/
|
|
344
|
+
declare function useUrgentConversations(filters: Pick<UseConversationsFilters, "userId" | "limit">): UseQueryResult<UrgentConversationListItem[]>;
|
|
293
345
|
/**
|
|
294
346
|
* Look up a single conversation by its normalized phonePair (sorted
|
|
295
347
|
* digit-pair, e.g. `"5125550123|6505551234"`). Returns `null` if no
|
|
@@ -359,6 +411,20 @@ declare function useConversationTasksForUser(userId: string | null | undefined,
|
|
|
359
411
|
limit?: number;
|
|
360
412
|
}): UseQueryResult<ConversationTaskForUserRow[]>;
|
|
361
413
|
declare function useConversationTasksByPhonePair(phonePair: string | null | undefined): UseQueryResult<ConversationTaskRow[]>;
|
|
414
|
+
/**
|
|
415
|
+
* History (completed/reopened) of one task, oldest first. Returns the newest
|
|
416
|
+
* `limit` events (server default 200, max 500).
|
|
417
|
+
*/
|
|
418
|
+
declare function useTaskHistory(taskId: string | null | undefined, options?: {
|
|
419
|
+
limit?: number;
|
|
420
|
+
}): UseQueryResult<TaskEventRow[]>;
|
|
421
|
+
/**
|
|
422
|
+
* Task history entries for a conversation thread, oldest first. Returns the
|
|
423
|
+
* newest `limit` events (server default 200, max 500).
|
|
424
|
+
*/
|
|
425
|
+
declare function useConversationTaskHistory(conversationId: string | null | undefined, options?: {
|
|
426
|
+
limit?: number;
|
|
427
|
+
}): UseQueryResult<TaskEventRow[]>;
|
|
362
428
|
|
|
363
429
|
/**
|
|
364
430
|
* React hooks for Dialpad call events — replaces CommHub's Hasura
|
|
@@ -495,6 +561,643 @@ declare function useSaveCallSummary(): (callId: string, userSummary: string, upd
|
|
|
495
561
|
ok: true;
|
|
496
562
|
}>;
|
|
497
563
|
|
|
564
|
+
/**
|
|
565
|
+
* Configuration interfaces for the Truth SDK.
|
|
566
|
+
*/
|
|
567
|
+
/**
|
|
568
|
+
* Environment options for the Truth platform.
|
|
569
|
+
*/
|
|
570
|
+
declare const ENVIRONMENTS: {
|
|
571
|
+
readonly local: "local";
|
|
572
|
+
readonly staging: "staging";
|
|
573
|
+
readonly stg: "stg";
|
|
574
|
+
readonly sandbox: "sandbox";
|
|
575
|
+
readonly uat: "uat";
|
|
576
|
+
readonly production: "production";
|
|
577
|
+
};
|
|
578
|
+
type Environment = (typeof ENVIRONMENTS)[keyof typeof ENVIRONMENTS];
|
|
579
|
+
/**
|
|
580
|
+
* Fetches a user-identity JWT for Convex calls. Return the token from
|
|
581
|
+
* your identity provider's Clerk JWT template named "convex"
|
|
582
|
+
* (e.g. `getToken({ template: "convex" })` from `@clerk/expo`), or
|
|
583
|
+
* `null` when no user is signed in.
|
|
584
|
+
*
|
|
585
|
+
* Convex invokes this with `{ forceRefreshToken: true }` when the cached
|
|
586
|
+
* token has expired — forward it to your provider (e.g. Clerk's
|
|
587
|
+
* `getToken({ template: "convex", skipCache: opts?.forceRefreshToken })`)
|
|
588
|
+
* so the refresh returns a fresh token rather than a stale cached one.
|
|
589
|
+
*/
|
|
590
|
+
type AuthTokenFetcher = (opts?: {
|
|
591
|
+
forceRefreshToken?: boolean;
|
|
592
|
+
}) => Promise<string | null | undefined>;
|
|
593
|
+
/**
|
|
594
|
+
* Configuration for initializing a TruthClient.
|
|
595
|
+
*/
|
|
596
|
+
interface TruthClientConfig {
|
|
597
|
+
/** API key for authenticating with the Truth platform (e.g. "hn_live_...") */
|
|
598
|
+
apiKey: string;
|
|
599
|
+
/**
|
|
600
|
+
* Per-call Clerk JWT fetcher for Convex data access. When provided,
|
|
601
|
+
* every Convex query/mutation/action carries the caller's identity;
|
|
602
|
+
* Convex deployments with `CLERK_AUTH_REQUIRED` enabled reject calls
|
|
603
|
+
* without it. Omit for service contexts that don't act as a user.
|
|
604
|
+
*/
|
|
605
|
+
getAuthToken?: AuthTokenFetcher;
|
|
606
|
+
/** Target environment */
|
|
607
|
+
environment: Environment;
|
|
608
|
+
/** Override the default Convex URL for data access */
|
|
609
|
+
convexUrl?: string;
|
|
610
|
+
/** Event source identifier (e.g. "communication-hub.backend") */
|
|
611
|
+
source?: string;
|
|
612
|
+
/** Git SHA or version string for event source versioning */
|
|
613
|
+
sourceVersion?: string;
|
|
614
|
+
/** Default tenant (organization) ID for events */
|
|
615
|
+
tenantId?: string;
|
|
616
|
+
/** Number of events to buffer before flushing (default: 25) */
|
|
617
|
+
batchSize?: number;
|
|
618
|
+
/** Interval in milliseconds between automatic flushes (default: 5000) */
|
|
619
|
+
flushIntervalMs?: number;
|
|
620
|
+
/** Base URL for the Truth API (overrides environment-based default) */
|
|
621
|
+
apiBaseUrl?: string;
|
|
622
|
+
/**
|
|
623
|
+
* Auto-register the service worker and subscribe to web push on init.
|
|
624
|
+
* Only applies in browser environments with Push API support.
|
|
625
|
+
* Default: true.
|
|
626
|
+
*/
|
|
627
|
+
autoInitServiceWorker?: boolean;
|
|
628
|
+
/** Path to the service worker file. Default: "/truth-sw.js" */
|
|
629
|
+
serviceWorkerPath?: string;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Actor context attached to tracked events.
|
|
633
|
+
*/
|
|
634
|
+
interface ActorContext {
|
|
635
|
+
actorId: string;
|
|
636
|
+
actorType: "user" | "system" | "webhook";
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Paginated result wrapper for list operations.
|
|
640
|
+
*/
|
|
641
|
+
interface PaginatedResult<T> {
|
|
642
|
+
data: T[];
|
|
643
|
+
cursor: string | null;
|
|
644
|
+
hasMore: boolean;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* CareInboxResource — care-team shared-mailbox email (T12).
|
|
649
|
+
*
|
|
650
|
+
* Writes go through the Truth oRPC `careInbox` router (all
|
|
651
|
+
* `verifiedUserProcedure`, so every call REQUIRES the user JWT):
|
|
652
|
+
* - `linkMessage` POST /api/care-inbox/link
|
|
653
|
+
* - `unlinkMessage` POST /api/care-inbox/unlink
|
|
654
|
+
* - `replyToThread` POST /api/care-inbox/outbound/thread-reply
|
|
655
|
+
* - `composeEmail` POST /api/care-inbox/outbound/compose
|
|
656
|
+
* Reads are Convex queries; use the hooks in `@hipnation-truth/sdk/react`
|
|
657
|
+
* (`useEmailThreads`, …) or `createCareInboxSource`. Nothing here is
|
|
658
|
+
* persisted offline.
|
|
659
|
+
*
|
|
660
|
+
* Two type layers:
|
|
661
|
+
* - `*View` types are the raw Convex query payloads (nullable where the
|
|
662
|
+
* stored row can lack a value).
|
|
663
|
+
* - The contract types (`EmailMessage`, `EmailThreadSummary`, `ThreadPage`,
|
|
664
|
+
* …) mirror comhub's `lib/email/careInboxSource.ts` exactly. `to*`
|
|
665
|
+
* projections turn views into contract shapes: a missing string becomes
|
|
666
|
+
* "" and a missing participant `{ address: "", name: null }` because the
|
|
667
|
+
* contract declares those fields non-null.
|
|
668
|
+
*
|
|
669
|
+
* Errors: every rejection is a `CareInboxError` whose `code` is the comhub
|
|
670
|
+
* `CareInboxErrorCode`, so it satisfies comhub's `Error & { code }` contract
|
|
671
|
+
* as-is. `status` (0 = no HTTP response), `rpcCode` (oRPC / transport code),
|
|
672
|
+
* `reason` and `detail` carry the server detail. `toCareInboxError()` maps
|
|
673
|
+
* anything thrown — including a Convex `ConvexError` from a hook — onto it.
|
|
674
|
+
*/
|
|
675
|
+
|
|
676
|
+
type EmailDirection = "inbound" | "outbound";
|
|
677
|
+
/**
|
|
678
|
+
* Thread-list filter. "unlinked" is served only to triage callers (threads
|
|
679
|
+
* with at least one unlinked message); others get forbidden/not_triage.
|
|
680
|
+
*/
|
|
681
|
+
type ThreadListFilter = "all" | "unread" | "unlinked";
|
|
682
|
+
interface EmailMailbox {
|
|
683
|
+
id: string;
|
|
684
|
+
/** Shared mailbox address. "" for non-triage callers (server-redacted). */
|
|
685
|
+
address: string;
|
|
686
|
+
displayName: string;
|
|
687
|
+
}
|
|
688
|
+
interface MailboxAccess {
|
|
689
|
+
mailboxes: EmailMailbox[];
|
|
690
|
+
/** May see Unlinked and link/unlink (admin-only until G-TRIAGE). */
|
|
691
|
+
canTriage: boolean;
|
|
692
|
+
}
|
|
693
|
+
interface EmailParticipant {
|
|
694
|
+
address: string;
|
|
695
|
+
name: string | null;
|
|
696
|
+
}
|
|
697
|
+
interface EmailMessage {
|
|
698
|
+
id: string;
|
|
699
|
+
threadId: string;
|
|
700
|
+
mailboxId: string;
|
|
701
|
+
direction: EmailDirection;
|
|
702
|
+
from: EmailParticipant;
|
|
703
|
+
to: EmailParticipant[];
|
|
704
|
+
subject: string;
|
|
705
|
+
/** Epoch milliseconds. */
|
|
706
|
+
sentAt: number;
|
|
707
|
+
hasAttachments: boolean;
|
|
708
|
+
linkedPatientId: string | null;
|
|
709
|
+
linkedPatientName: string | null;
|
|
710
|
+
/** Always null in build 1 (metadata only). */
|
|
711
|
+
bodyText: string | null;
|
|
712
|
+
}
|
|
713
|
+
interface EmailThreadSummary {
|
|
714
|
+
id: string;
|
|
715
|
+
mailboxId: string;
|
|
716
|
+
subject: string;
|
|
717
|
+
/** Epoch milliseconds of the newest message. */
|
|
718
|
+
lastMessageAt: number;
|
|
719
|
+
lastDirection: EmailDirection;
|
|
720
|
+
counterpart: EmailParticipant;
|
|
721
|
+
messageCount: number;
|
|
722
|
+
unreadCount: number;
|
|
723
|
+
/** Triage callers only; always 0 for staff. */
|
|
724
|
+
unlinkedCount: number;
|
|
725
|
+
linkedPatientName: string | null;
|
|
726
|
+
hasAttachments: boolean;
|
|
727
|
+
}
|
|
728
|
+
interface LinkedPatientContact {
|
|
729
|
+
patientId: string;
|
|
730
|
+
name: string;
|
|
731
|
+
email: string | null;
|
|
732
|
+
phone: string | null;
|
|
733
|
+
office: string | null;
|
|
734
|
+
}
|
|
735
|
+
interface EmailThreadDetail {
|
|
736
|
+
summary: EmailThreadSummary;
|
|
737
|
+
mailbox: EmailMailbox;
|
|
738
|
+
/** Oldest first. */
|
|
739
|
+
messages: EmailMessage[];
|
|
740
|
+
/** Not provided in build 1 (always null). */
|
|
741
|
+
patientContact?: LinkedPatientContact | null;
|
|
742
|
+
}
|
|
743
|
+
interface ListThreadsArgs {
|
|
744
|
+
mailboxId?: string;
|
|
745
|
+
filter?: ThreadListFilter;
|
|
746
|
+
cursor?: string | null;
|
|
747
|
+
/** Server default 25, max 50. */
|
|
748
|
+
limit?: number;
|
|
749
|
+
}
|
|
750
|
+
interface ThreadPage {
|
|
751
|
+
threads: EmailThreadSummary[];
|
|
752
|
+
/** A mailbox-filtered page can be short; keep paging while non-null. */
|
|
753
|
+
nextCursor: string | null;
|
|
754
|
+
}
|
|
755
|
+
interface PatientLinkCandidate {
|
|
756
|
+
patientId: string;
|
|
757
|
+
displayName: string;
|
|
758
|
+
/** Office name when known; never an email address. */
|
|
759
|
+
detail: string | null;
|
|
760
|
+
}
|
|
761
|
+
interface LinkMessageArgs {
|
|
762
|
+
messageId: string;
|
|
763
|
+
patientId: string;
|
|
764
|
+
/**
|
|
765
|
+
* Client idempotency key (8-128 chars of `[A-Za-z0-9_:.-]`). A key the
|
|
766
|
+
* server already recorded for the message is a no-op that returns the
|
|
767
|
+
* current state, so a late retry can never undo a newer unlink.
|
|
768
|
+
*/
|
|
769
|
+
requestId: string;
|
|
770
|
+
}
|
|
771
|
+
interface UnlinkMessageArgs {
|
|
772
|
+
messageId: string;
|
|
773
|
+
/** Client idempotency key; see `LinkMessageArgs.requestId`. */
|
|
774
|
+
requestId: string;
|
|
775
|
+
}
|
|
776
|
+
interface LinkResult {
|
|
777
|
+
message: EmailMessage;
|
|
778
|
+
}
|
|
779
|
+
interface SendReplyArgs {
|
|
780
|
+
threadId: string;
|
|
781
|
+
body: string;
|
|
782
|
+
clientRequestId: string;
|
|
783
|
+
}
|
|
784
|
+
interface SendEmailArgs {
|
|
785
|
+
to: string;
|
|
786
|
+
subject: string;
|
|
787
|
+
body: string;
|
|
788
|
+
patientId?: string;
|
|
789
|
+
mailboxId: string;
|
|
790
|
+
clientRequestId: string;
|
|
791
|
+
}
|
|
792
|
+
/** Send is disabled in this build (always rejects forbidden/send_disabled). */
|
|
793
|
+
interface SendResult {
|
|
794
|
+
message: EmailMessage;
|
|
795
|
+
thread: EmailThreadSummary;
|
|
796
|
+
}
|
|
797
|
+
interface MarkReadArgs {
|
|
798
|
+
threadId: string;
|
|
799
|
+
}
|
|
800
|
+
interface MarkReadResult {
|
|
801
|
+
thread: EmailThreadSummary;
|
|
802
|
+
}
|
|
803
|
+
/** comhub `CareInboxErrorCode`. */
|
|
804
|
+
type CareInboxErrorCode = "forbidden" | "not_found" | "offline" | "unavailable" | "validation" | "unknown";
|
|
805
|
+
/** `EmailMailbox` plus the server-derived switches. */
|
|
806
|
+
interface CareInboxMailbox extends EmailMailbox {
|
|
807
|
+
mode: "mirror" | "live";
|
|
808
|
+
/** Live mailbox AND send enabled on the deployment. */
|
|
809
|
+
canSend: boolean;
|
|
810
|
+
/** bodyVisibility !== "none" (bodies still need openThreadBodies). */
|
|
811
|
+
bodyVisible: boolean;
|
|
812
|
+
}
|
|
813
|
+
interface CareInboxMailboxAccess extends MailboxAccess {
|
|
814
|
+
mailboxes: CareInboxMailbox[];
|
|
815
|
+
}
|
|
816
|
+
interface CareInboxThreadDetail extends EmailThreadDetail {
|
|
817
|
+
mailbox: CareInboxMailbox;
|
|
818
|
+
/** Whether `openThreadBodies` would serve bodies to this caller. */
|
|
819
|
+
bodyVisible: boolean;
|
|
820
|
+
patientContact: null;
|
|
821
|
+
}
|
|
822
|
+
/** Triage-only unlinked message page (`listUnlinked`). */
|
|
823
|
+
interface UnlinkedMessagePage {
|
|
824
|
+
messages: EmailMessage[];
|
|
825
|
+
nextCursor: string | null;
|
|
826
|
+
}
|
|
827
|
+
/** Back-compat aliases (T12 names). */
|
|
828
|
+
type CareInboxEmailMessage = EmailMessage;
|
|
829
|
+
type CareInboxEmailThreadSummary = EmailThreadSummary;
|
|
830
|
+
type CareInboxLinkResult = LinkResult;
|
|
831
|
+
type CareInboxSendResult = SendResult;
|
|
832
|
+
/**
|
|
833
|
+
* SDK call input: the contract args with `requestId` optional. Omit it and
|
|
834
|
+
* the SDK generates one for this call; pass your own to make retries across
|
|
835
|
+
* calls idempotent.
|
|
836
|
+
*/
|
|
837
|
+
type LinkEmailMessageInput = Omit<LinkMessageArgs, "requestId"> & Partial<Pick<LinkMessageArgs, "requestId">>;
|
|
838
|
+
type UnlinkEmailMessageInput = Omit<UnlinkMessageArgs, "requestId"> & Partial<Pick<UnlinkMessageArgs, "requestId">>;
|
|
839
|
+
type ReplyToEmailThreadInput = SendReplyArgs;
|
|
840
|
+
type ComposeEmailInput = SendEmailArgs;
|
|
841
|
+
type EmailParticipantView = EmailParticipant;
|
|
842
|
+
/** `careInboxQueries` message row. `bodyText` is always null from queries. */
|
|
843
|
+
interface EmailMessageView {
|
|
844
|
+
id: string;
|
|
845
|
+
threadId: string | null;
|
|
846
|
+
mailboxId: string;
|
|
847
|
+
direction: EmailDirection;
|
|
848
|
+
from: EmailParticipantView | null;
|
|
849
|
+
to: EmailParticipantView[];
|
|
850
|
+
subject: string | null;
|
|
851
|
+
sentAt: number;
|
|
852
|
+
hasAttachments: boolean;
|
|
853
|
+
linkedPatientId: string | null;
|
|
854
|
+
linkedPatientName: string | null;
|
|
855
|
+
bodyText: null;
|
|
856
|
+
}
|
|
857
|
+
interface EmailThreadSummaryView {
|
|
858
|
+
id: string;
|
|
859
|
+
mailboxId: string;
|
|
860
|
+
subject: string | null;
|
|
861
|
+
lastMessageAt: number;
|
|
862
|
+
lastDirection: EmailDirection | null;
|
|
863
|
+
counterpart: EmailParticipantView | null;
|
|
864
|
+
messageCount: number;
|
|
865
|
+
unreadCount: number;
|
|
866
|
+
unlinkedCount: number;
|
|
867
|
+
linkedPatientId: string | null;
|
|
868
|
+
linkedPatientName: string | null;
|
|
869
|
+
hasAttachments: boolean;
|
|
870
|
+
}
|
|
871
|
+
interface EmailMailboxView {
|
|
872
|
+
id: string;
|
|
873
|
+
displayName: string;
|
|
874
|
+
mode: "mirror" | "live";
|
|
875
|
+
canSend: boolean;
|
|
876
|
+
bodyVisible: boolean;
|
|
877
|
+
/** Present only when the caller can triage. */
|
|
878
|
+
address?: string;
|
|
879
|
+
}
|
|
880
|
+
interface EmailMailboxAccessView {
|
|
881
|
+
mailboxes: EmailMailboxView[];
|
|
882
|
+
canTriage: boolean;
|
|
883
|
+
}
|
|
884
|
+
/** Filters `listThreadsForUser` serves ("unlinked": triage only). */
|
|
885
|
+
type EmailThreadListFilter = ThreadListFilter;
|
|
886
|
+
interface EmailThreadPageView {
|
|
887
|
+
threads: EmailThreadSummaryView[];
|
|
888
|
+
nextCursor: string | null;
|
|
889
|
+
}
|
|
890
|
+
interface EmailThreadDetailView {
|
|
891
|
+
summary: EmailThreadSummaryView;
|
|
892
|
+
mailbox: EmailMailboxView;
|
|
893
|
+
/** Oldest first. Staff: linked only; triage: linked + unlinked. */
|
|
894
|
+
messages: EmailMessageView[];
|
|
895
|
+
bodyVisible: boolean;
|
|
896
|
+
patientContact: null;
|
|
897
|
+
}
|
|
898
|
+
interface UnlinkedEmailPageView {
|
|
899
|
+
messages: EmailMessageView[];
|
|
900
|
+
nextCursor: string | null;
|
|
901
|
+
}
|
|
902
|
+
type PatientLinkCandidateView = PatientLinkCandidate;
|
|
903
|
+
interface MarkEmailThreadReadResult {
|
|
904
|
+
thread: EmailThreadSummaryView;
|
|
905
|
+
}
|
|
906
|
+
interface EmailThreadBodiesView {
|
|
907
|
+
messages: {
|
|
908
|
+
id: string;
|
|
909
|
+
bodyText: string | null;
|
|
910
|
+
}[];
|
|
911
|
+
}
|
|
912
|
+
declare function toEmailMessage(m: EmailMessageView): EmailMessage;
|
|
913
|
+
/**
|
|
914
|
+
* `lastDirection` is null only for a thread with no visible message (it
|
|
915
|
+
* cannot happen for a summary the server lists; kept defensive). Projects to
|
|
916
|
+
* "inbound".
|
|
917
|
+
*/
|
|
918
|
+
declare function toEmailThreadSummary(t: EmailThreadSummaryView): EmailThreadSummary;
|
|
919
|
+
declare function toEmailMailbox(m: EmailMailboxView): CareInboxMailbox;
|
|
920
|
+
declare function toMailboxAccess(a: EmailMailboxAccessView): CareInboxMailboxAccess;
|
|
921
|
+
declare function toEmailThreadDetail(d: EmailThreadDetailView): CareInboxThreadDetail;
|
|
922
|
+
declare function toThreadPage(p: EmailThreadPageView): ThreadPage;
|
|
923
|
+
declare function toUnlinkedMessagePage(p: UnlinkedEmailPageView): UnlinkedMessagePage;
|
|
924
|
+
declare function toMarkReadResult(r: MarkEmailThreadReadResult): MarkReadResult;
|
|
925
|
+
/**
|
|
926
|
+
* Machine-readable sub-code. Server-sent: `send_disabled` | `not_triage` |
|
|
927
|
+
* `body_gated` | `unauthenticated` (Convex: no identity). SDK-derived:
|
|
928
|
+
* `unauthenticated` (no user JWT, or HTTP 401). The contract has no auth
|
|
929
|
+
* code, so `unauthenticated` surfaces as `forbidden` on every path.
|
|
930
|
+
*/
|
|
931
|
+
type CareInboxErrorReason = "send_disabled" | "not_triage" | "body_gated" | "unauthenticated";
|
|
932
|
+
interface CareInboxErrorFields {
|
|
933
|
+
/** HTTP status; 0 when there was no HTTP response (incl. Convex errors). */
|
|
934
|
+
status?: number;
|
|
935
|
+
/**
|
|
936
|
+
* oRPC code (`FORBIDDEN`, `NOT_FOUND`, …) or, for status 0, `TRANSPORT`
|
|
937
|
+
* (fetch threw), `TIMEOUT`, `NO_API_KEY`, `NO_USER_TOKEN`.
|
|
938
|
+
*/
|
|
939
|
+
rpcCode?: string | null;
|
|
940
|
+
reason?: CareInboxErrorReason | null;
|
|
941
|
+
/** Fixed server marker (e.g. `PATIENT_HAS_NO_OFFICE`), when present. */
|
|
942
|
+
detail?: string | null;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* The single care-inbox error. `code` is the comhub `CareInboxErrorCode`, so
|
|
946
|
+
* an instance satisfies comhub's `CareInboxError` (`Error & { code }`). The
|
|
947
|
+
* message never carries content, addresses or ids.
|
|
948
|
+
*/
|
|
949
|
+
declare class CareInboxError extends Error {
|
|
950
|
+
readonly code: CareInboxErrorCode;
|
|
951
|
+
readonly status: number;
|
|
952
|
+
readonly rpcCode: string | null;
|
|
953
|
+
readonly reason: CareInboxErrorReason | null;
|
|
954
|
+
readonly detail: string | null;
|
|
955
|
+
constructor(code: CareInboxErrorCode, fields?: CareInboxErrorFields);
|
|
956
|
+
}
|
|
957
|
+
/** True for any value carrying a contract `code` (comhub `isCareInboxError`). */
|
|
958
|
+
declare function isCareInboxError(value: unknown): value is Error & {
|
|
959
|
+
code: CareInboxErrorCode;
|
|
960
|
+
};
|
|
961
|
+
/**
|
|
962
|
+
* Coerce anything thrown by the resource, a care-inbox Convex function
|
|
963
|
+
* (`ConvexError({ code, reason? })`, payload on `.data`) or a comhub-style
|
|
964
|
+
* error into a `CareInboxError`. Never throws; unrecognised → `unknown`.
|
|
965
|
+
*/
|
|
966
|
+
declare function toCareInboxError(value: unknown): CareInboxError;
|
|
967
|
+
interface CareInboxErrorInfo {
|
|
968
|
+
code: CareInboxErrorCode;
|
|
969
|
+
reason: CareInboxErrorReason | null;
|
|
970
|
+
}
|
|
971
|
+
/** `{ code, reason }` of anything thrown (see `toCareInboxError`). */
|
|
972
|
+
declare function careInboxErrorInfo(err: unknown): CareInboxErrorInfo;
|
|
973
|
+
declare class CareInboxResource {
|
|
974
|
+
/** 30s upstream timeout — matches ConversationsResource. */
|
|
975
|
+
private static readonly REQUEST_TIMEOUT_MS;
|
|
976
|
+
private readonly baseUrl;
|
|
977
|
+
private readonly auth;
|
|
978
|
+
constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
|
|
979
|
+
/** Link one message to a patient (triage only). */
|
|
980
|
+
linkMessage(input: LinkEmailMessageInput): Promise<LinkResult>;
|
|
981
|
+
/** Undo a manual link (triage only). */
|
|
982
|
+
unlinkMessage(input: UnlinkEmailMessageInput): Promise<LinkResult>;
|
|
983
|
+
/** Reply into a thread. This build always rejects 403 `send_disabled`. */
|
|
984
|
+
replyToThread(input: SendReplyArgs): Promise<SendResult>;
|
|
985
|
+
/** Start a new email. This build always rejects 403 `send_disabled`. */
|
|
986
|
+
composeEmail(input: SendEmailArgs): Promise<SendResult>;
|
|
987
|
+
private post;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* `createCareInboxSource` — a promise-based object with exactly the method
|
|
992
|
+
* set of comhub's `CareInboxSource` (lib/email/careInboxSource.ts), so the
|
|
993
|
+
* comhub adapter is a pass-through. Reads are one-shot Convex queries
|
|
994
|
+
* (never persisted); link/unlink/send go through `CareInboxResource`.
|
|
995
|
+
*
|
|
996
|
+
* Every rejection is a `CareInboxError` (`Error & { code }` with the comhub
|
|
997
|
+
* code set). `getThread` rejects `unavailable` when the feature flag is off
|
|
998
|
+
* (the query returns null then). In React use `useCareInboxSource()` from
|
|
999
|
+
* `@hipnation-truth/sdk/react`, which rebuilds the source when Convex auth
|
|
1000
|
+
* flips so comhub's query hooks refetch.
|
|
1001
|
+
*/
|
|
1002
|
+
|
|
1003
|
+
declare const careInboxRefs: {
|
|
1004
|
+
listThreadsForUser: FunctionReference<"query", "public", {
|
|
1005
|
+
mailboxId?: string;
|
|
1006
|
+
filter?: ThreadListFilter;
|
|
1007
|
+
cursor?: string | null;
|
|
1008
|
+
limit?: number;
|
|
1009
|
+
}, EmailThreadPageView, string | undefined>;
|
|
1010
|
+
getThread: FunctionReference<"query", "public", {
|
|
1011
|
+
threadId: string;
|
|
1012
|
+
}, EmailThreadDetailView | null, string | undefined>;
|
|
1013
|
+
listUnlinked: FunctionReference<"query", "public", {
|
|
1014
|
+
mailboxId: string;
|
|
1015
|
+
cursor?: string | null;
|
|
1016
|
+
limit?: number;
|
|
1017
|
+
}, UnlinkedEmailPageView, string | undefined>;
|
|
1018
|
+
unreadEmailCount: FunctionReference<"query", "public", {
|
|
1019
|
+
mailboxId?: string;
|
|
1020
|
+
}, number, string | undefined>;
|
|
1021
|
+
listMailboxesForUser: FunctionReference<"query", "public", Record<string, never>, EmailMailboxAccessView, string | undefined>;
|
|
1022
|
+
searchPatientsForLink: FunctionReference<"query", "public", {
|
|
1023
|
+
q: string;
|
|
1024
|
+
}, PatientLinkCandidate[], string | undefined>;
|
|
1025
|
+
markRead: FunctionReference<"mutation", "public", {
|
|
1026
|
+
threadId: string;
|
|
1027
|
+
}, MarkEmailThreadReadResult, string | undefined>;
|
|
1028
|
+
openThreadBodies: FunctionReference<"mutation", "public", {
|
|
1029
|
+
threadId: string;
|
|
1030
|
+
}, EmailThreadBodiesView, string | undefined>;
|
|
1031
|
+
};
|
|
1032
|
+
/** The Convex surface the source needs (`ConvexReactClient` satisfies it). */
|
|
1033
|
+
interface CareInboxConvexClient {
|
|
1034
|
+
query(ref: FunctionReference<"query">, args: Record<string, unknown>): Promise<unknown>;
|
|
1035
|
+
mutation(ref: FunctionReference<"mutation">, args: Record<string, unknown>): Promise<unknown>;
|
|
1036
|
+
}
|
|
1037
|
+
interface CareInboxSourceDeps {
|
|
1038
|
+
convex: CareInboxConvexClient;
|
|
1039
|
+
careInbox: Pick<CareInboxResource, "linkMessage" | "unlinkMessage" | "replyToThread" | "composeEmail">;
|
|
1040
|
+
}
|
|
1041
|
+
/** Method set of comhub's `CareInboxSource` (minus optional `subscribe`). */
|
|
1042
|
+
interface CareInboxSdkSource {
|
|
1043
|
+
listThreads(args?: ListThreadsArgs): Promise<ThreadPage>;
|
|
1044
|
+
getUnreadCount(args?: {
|
|
1045
|
+
mailboxId?: string;
|
|
1046
|
+
}): Promise<number>;
|
|
1047
|
+
getThread(threadId: string): Promise<CareInboxThreadDetail>;
|
|
1048
|
+
listMailboxesForUser(): Promise<CareInboxMailboxAccess>;
|
|
1049
|
+
searchPatientsForLink(query: string): Promise<PatientLinkCandidate[]>;
|
|
1050
|
+
linkMessage(args: LinkMessageArgs): Promise<LinkResult>;
|
|
1051
|
+
unlinkMessage(args: UnlinkMessageArgs): Promise<LinkResult>;
|
|
1052
|
+
sendReply(args: SendReplyArgs): Promise<SendResult>;
|
|
1053
|
+
sendEmail(args: SendEmailArgs): Promise<SendResult>;
|
|
1054
|
+
markRead(args: MarkReadArgs): Promise<MarkReadResult>;
|
|
1055
|
+
}
|
|
1056
|
+
declare function createCareInboxSource({ convex, careInbox, }: CareInboxSourceDeps): CareInboxSdkSource;
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* React hooks for the care-team email inbox (T12).
|
|
1060
|
+
*
|
|
1061
|
+
* Reads are LIVE Convex subscriptions via `useQuery` from `convex/react` —
|
|
1062
|
+
* deliberately NOT the offline persisted mirror: email metadata is never
|
|
1063
|
+
* written to device storage. Do not route these through
|
|
1064
|
+
* `usePersistentQuery` or anything under `./offline/`.
|
|
1065
|
+
*
|
|
1066
|
+
* Every Convex function here derives the caller from the auth identity and
|
|
1067
|
+
* throws `forbidden` without one, so all queries skip until Convex reports
|
|
1068
|
+
* the websocket authenticated (`useConvexAuth`).
|
|
1069
|
+
*
|
|
1070
|
+
* Query hooks return `{ data, loading, error }` (see `UseQueryResult`) with
|
|
1071
|
+
* `data` projected onto comhub's contract types (`ThreadPage`,
|
|
1072
|
+
* `EmailThreadDetail`, …). `data` is `undefined` while loading or skipped;
|
|
1073
|
+
* `error` is SDK-side (a `CareInboxError`). Convex errors
|
|
1074
|
+
* (`ConvexError({code, reason?})`) throw into the nearest error boundary —
|
|
1075
|
+
* map them with `toCareInboxError`.
|
|
1076
|
+
*
|
|
1077
|
+
* Triage-only hooks (`useUnlinkedEmails`, `useSearchPatientsForLink`, and
|
|
1078
|
+
* the thread-list hooks with `filter: "unlinked"`) read `canTriage`
|
|
1079
|
+
* themselves and, for a non-triage caller, skip the query and report
|
|
1080
|
+
* `error: CareInboxError("forbidden", reason "not_triage")` — the contract's
|
|
1081
|
+
* "not available" state. No `enabled: canTriage` wiring needed.
|
|
1082
|
+
*
|
|
1083
|
+
* `useCareInboxSource()` returns a promise-based object with comhub's
|
|
1084
|
+
* `CareInboxSource` method set for the comhub adapter.
|
|
1085
|
+
*/
|
|
1086
|
+
|
|
1087
|
+
interface UseEmailThreadsOptions {
|
|
1088
|
+
mailboxId?: string;
|
|
1089
|
+
/**
|
|
1090
|
+
* "all" (default), "unread", or "unlinked" (triage only: threads holding
|
|
1091
|
+
* unlinked mail; non-triage callers skip with forbidden/not_triage).
|
|
1092
|
+
*/
|
|
1093
|
+
filter?: EmailThreadListFilter;
|
|
1094
|
+
/** Page cursor from a previous page's `nextCursor`. */
|
|
1095
|
+
cursor?: string | null;
|
|
1096
|
+
/** Page size (server default 25, max 50). */
|
|
1097
|
+
limit?: number;
|
|
1098
|
+
/** Pass false to skip. Default true. */
|
|
1099
|
+
enabled?: boolean;
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* One page of the caller's email threads, newest first. A filtered page can
|
|
1103
|
+
* be short; keep paging while `nextCursor` is non-null (or use
|
|
1104
|
+
* `usePaginatedEmailThreads`). `filter: "unlinked"` is triage-only: it waits
|
|
1105
|
+
* for `canTriage`, and a non-triage caller skips with forbidden/not_triage.
|
|
1106
|
+
*/
|
|
1107
|
+
declare function useEmailThreads(options?: UseEmailThreadsOptions): UseQueryResult<ThreadPage>;
|
|
1108
|
+
interface UsePaginatedEmailThreadsOptions {
|
|
1109
|
+
mailboxId?: string;
|
|
1110
|
+
/** As `UseEmailThreadsOptions.filter` ("unlinked" is triage-only). */
|
|
1111
|
+
filter?: EmailThreadListFilter;
|
|
1112
|
+
/** Page size per load (server default 25, max 50). */
|
|
1113
|
+
limit?: number;
|
|
1114
|
+
enabled?: boolean;
|
|
1115
|
+
}
|
|
1116
|
+
interface UsePaginatedEmailThreadsResult {
|
|
1117
|
+
/** Every loaded page, newest first, de-duplicated by id. */
|
|
1118
|
+
data: EmailThreadSummary[] | undefined;
|
|
1119
|
+
/** True while the first page loads. */
|
|
1120
|
+
loading: boolean;
|
|
1121
|
+
/** True while a page after the first loads. */
|
|
1122
|
+
loadingMore: boolean;
|
|
1123
|
+
/** A page's Convex error, as a `CareInboxError`. */
|
|
1124
|
+
error: CareInboxError | undefined;
|
|
1125
|
+
/** False once the last loaded page had `nextCursor: null`. */
|
|
1126
|
+
hasMore: boolean;
|
|
1127
|
+
/** Load the next page. No-op while loading or when `hasMore` is false. */
|
|
1128
|
+
loadMore: () => void;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Load-more over `listThreadsForUser`'s cursor pages: every loaded page stays
|
|
1132
|
+
* a live subscription and the results are concatenated. Changing
|
|
1133
|
+
* `mailboxId` / `filter` / `limit` resets to the first page.
|
|
1134
|
+
* `filter: "unlinked"` waits for `canTriage` (`loading`), and a non-triage
|
|
1135
|
+
* caller skips with `error` forbidden/not_triage.
|
|
1136
|
+
*/
|
|
1137
|
+
declare function usePaginatedEmailThreads(options?: UsePaginatedEmailThreadsOptions): UsePaginatedEmailThreadsResult;
|
|
1138
|
+
/**
|
|
1139
|
+
* One thread. Staff get linked messages only; triage callers also get the
|
|
1140
|
+
* unlinked ones (`linkedPatientId` null). Skips while `threadId` is empty.
|
|
1141
|
+
* `data` is null when the feature flag is off.
|
|
1142
|
+
*/
|
|
1143
|
+
declare function useEmailThread(threadId: string | null | undefined): UseQueryResult<CareInboxThreadDetail | null>;
|
|
1144
|
+
interface UseUnlinkedEmailsOptions {
|
|
1145
|
+
/** Required; the query skips without it. */
|
|
1146
|
+
mailboxId: string | null | undefined;
|
|
1147
|
+
cursor?: string | null;
|
|
1148
|
+
limit?: number;
|
|
1149
|
+
/** Pass false to skip. Default true. Non-triage callers skip on their own. */
|
|
1150
|
+
enabled?: boolean;
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Triage only: a mailbox's unlinked messages, newest first. For a
|
|
1154
|
+
* non-triage caller it skips and returns `error` forbidden/not_triage.
|
|
1155
|
+
*/
|
|
1156
|
+
declare function useUnlinkedEmails(options: UseUnlinkedEmailsOptions): UseQueryResult<UnlinkedMessagePage>;
|
|
1157
|
+
/** Number of the caller's threads with unread > 0 (tab badge). */
|
|
1158
|
+
declare function useEmailUnreadCount(options?: {
|
|
1159
|
+
mailboxId?: string;
|
|
1160
|
+
enabled?: boolean;
|
|
1161
|
+
}): UseQueryResult<number>;
|
|
1162
|
+
/** Mailboxes the caller can see, plus `canTriage`. */
|
|
1163
|
+
declare function useMailboxes(options?: {
|
|
1164
|
+
enabled?: boolean;
|
|
1165
|
+
}): UseQueryResult<CareInboxMailboxAccess>;
|
|
1166
|
+
interface UseSearchPatientsForLinkOptions {
|
|
1167
|
+
/** Pass false to skip. Default true. Non-triage callers skip on their own. */
|
|
1168
|
+
enabled?: boolean;
|
|
1169
|
+
/** Minimum trimmed length before searching. Default 2. */
|
|
1170
|
+
minLength?: number;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Triage only: patient candidates for linking (≤ 20). Not persisted. Skips
|
|
1174
|
+
* while the trimmed query is shorter than `minLength`; for a non-triage
|
|
1175
|
+
* caller it skips and returns `error` forbidden/not_triage.
|
|
1176
|
+
*/
|
|
1177
|
+
declare function useSearchPatientsForLink(q: string | null | undefined, options?: UseSearchPatientsForLinkOptions): UseQueryResult<PatientLinkCandidate[]>;
|
|
1178
|
+
/** `link(input)` → oRPC `POST /api/care-inbox/link`. Throws `CareInboxError`. */
|
|
1179
|
+
declare function useLinkEmailMessage(): (input: LinkMessageArgs) => Promise<LinkResult>;
|
|
1180
|
+
/** `unlink(input)` → oRPC `POST /api/care-inbox/unlink`. */
|
|
1181
|
+
declare function useUnlinkEmailMessage(): (input: UnlinkMessageArgs) => Promise<LinkResult>;
|
|
1182
|
+
/**
|
|
1183
|
+
* `markRead(threadId)` → Convex `careInboxReads:markRead`. Rejects with a
|
|
1184
|
+
* `CareInboxError` (`unavailable` when the feature flag is off).
|
|
1185
|
+
*/
|
|
1186
|
+
declare function useMarkEmailThreadRead(): (threadId: string) => Promise<MarkReadResult>;
|
|
1187
|
+
/**
|
|
1188
|
+
* `openBodies(threadId)` → Convex `careInboxReads:openThreadBodies`. Every
|
|
1189
|
+
* call writes a body-view audit row; rejects `CareInboxError` forbidden with
|
|
1190
|
+
* reason `body_gated` when the mailbox does not allow bodies for this caller.
|
|
1191
|
+
*/
|
|
1192
|
+
declare function useOpenEmailThreadBodies(): (threadId: string) => Promise<EmailThreadBodiesView>;
|
|
1193
|
+
/**
|
|
1194
|
+
* comhub's `CareInboxSource` over this SDK. Until Convex reports the socket
|
|
1195
|
+
* authenticated, Convex-backed methods reject forbidden/unauthenticated; the
|
|
1196
|
+
* returned object changes identity when auth flips, so consumers keyed on
|
|
1197
|
+
* the source refetch.
|
|
1198
|
+
*/
|
|
1199
|
+
declare function useCareInboxSource(): CareInboxSdkSource;
|
|
1200
|
+
|
|
498
1201
|
/**
|
|
499
1202
|
* React hook for a single conversation lookup by Convex id — Truth SDK.
|
|
500
1203
|
*
|
|
@@ -1288,89 +1991,6 @@ interface AppointmentListOptions {
|
|
|
1288
1991
|
cursor?: string;
|
|
1289
1992
|
}
|
|
1290
1993
|
|
|
1291
|
-
/**
|
|
1292
|
-
* Configuration interfaces for the Truth SDK.
|
|
1293
|
-
*/
|
|
1294
|
-
/**
|
|
1295
|
-
* Environment options for the Truth platform.
|
|
1296
|
-
*/
|
|
1297
|
-
declare const ENVIRONMENTS: {
|
|
1298
|
-
readonly local: "local";
|
|
1299
|
-
readonly staging: "staging";
|
|
1300
|
-
readonly stg: "stg";
|
|
1301
|
-
readonly sandbox: "sandbox";
|
|
1302
|
-
readonly uat: "uat";
|
|
1303
|
-
readonly production: "production";
|
|
1304
|
-
};
|
|
1305
|
-
type Environment = (typeof ENVIRONMENTS)[keyof typeof ENVIRONMENTS];
|
|
1306
|
-
/**
|
|
1307
|
-
* Fetches a user-identity JWT for Convex calls. Return the token from
|
|
1308
|
-
* your identity provider's Clerk JWT template named "convex"
|
|
1309
|
-
* (e.g. `getToken({ template: "convex" })` from `@clerk/expo`), or
|
|
1310
|
-
* `null` when no user is signed in.
|
|
1311
|
-
*
|
|
1312
|
-
* Convex invokes this with `{ forceRefreshToken: true }` when the cached
|
|
1313
|
-
* token has expired — forward it to your provider (e.g. Clerk's
|
|
1314
|
-
* `getToken({ template: "convex", skipCache: opts?.forceRefreshToken })`)
|
|
1315
|
-
* so the refresh returns a fresh token rather than a stale cached one.
|
|
1316
|
-
*/
|
|
1317
|
-
type AuthTokenFetcher = (opts?: {
|
|
1318
|
-
forceRefreshToken?: boolean;
|
|
1319
|
-
}) => Promise<string | null | undefined>;
|
|
1320
|
-
/**
|
|
1321
|
-
* Configuration for initializing a TruthClient.
|
|
1322
|
-
*/
|
|
1323
|
-
interface TruthClientConfig {
|
|
1324
|
-
/** API key for authenticating with the Truth platform (e.g. "hn_live_...") */
|
|
1325
|
-
apiKey: string;
|
|
1326
|
-
/**
|
|
1327
|
-
* Per-call Clerk JWT fetcher for Convex data access. When provided,
|
|
1328
|
-
* every Convex query/mutation/action carries the caller's identity;
|
|
1329
|
-
* Convex deployments with `CLERK_AUTH_REQUIRED` enabled reject calls
|
|
1330
|
-
* without it. Omit for service contexts that don't act as a user.
|
|
1331
|
-
*/
|
|
1332
|
-
getAuthToken?: AuthTokenFetcher;
|
|
1333
|
-
/** Target environment */
|
|
1334
|
-
environment: Environment;
|
|
1335
|
-
/** Override the default Convex URL for data access */
|
|
1336
|
-
convexUrl?: string;
|
|
1337
|
-
/** Event source identifier (e.g. "communication-hub.backend") */
|
|
1338
|
-
source?: string;
|
|
1339
|
-
/** Git SHA or version string for event source versioning */
|
|
1340
|
-
sourceVersion?: string;
|
|
1341
|
-
/** Default tenant (organization) ID for events */
|
|
1342
|
-
tenantId?: string;
|
|
1343
|
-
/** Number of events to buffer before flushing (default: 25) */
|
|
1344
|
-
batchSize?: number;
|
|
1345
|
-
/** Interval in milliseconds between automatic flushes (default: 5000) */
|
|
1346
|
-
flushIntervalMs?: number;
|
|
1347
|
-
/** Base URL for the Truth API (overrides environment-based default) */
|
|
1348
|
-
apiBaseUrl?: string;
|
|
1349
|
-
/**
|
|
1350
|
-
* Auto-register the service worker and subscribe to web push on init.
|
|
1351
|
-
* Only applies in browser environments with Push API support.
|
|
1352
|
-
* Default: true.
|
|
1353
|
-
*/
|
|
1354
|
-
autoInitServiceWorker?: boolean;
|
|
1355
|
-
/** Path to the service worker file. Default: "/truth-sw.js" */
|
|
1356
|
-
serviceWorkerPath?: string;
|
|
1357
|
-
}
|
|
1358
|
-
/**
|
|
1359
|
-
* Actor context attached to tracked events.
|
|
1360
|
-
*/
|
|
1361
|
-
interface ActorContext {
|
|
1362
|
-
actorId: string;
|
|
1363
|
-
actorType: "user" | "system" | "webhook";
|
|
1364
|
-
}
|
|
1365
|
-
/**
|
|
1366
|
-
* Paginated result wrapper for list operations.
|
|
1367
|
-
*/
|
|
1368
|
-
interface PaginatedResult<T> {
|
|
1369
|
-
data: T[];
|
|
1370
|
-
cursor: string | null;
|
|
1371
|
-
hasMore: boolean;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
1994
|
/**
|
|
1375
1995
|
* AppointmentResource provides data access to normalized appointment records
|
|
1376
1996
|
* backed by Convex.
|
|
@@ -1625,6 +2245,19 @@ declare class ConversationsResource {
|
|
|
1625
2245
|
}): Promise<{
|
|
1626
2246
|
updated: true;
|
|
1627
2247
|
}>;
|
|
2248
|
+
/**
|
|
2249
|
+
* Mark / unmark a conversation Urgent (conversation-level, shared by
|
|
2250
|
+
* participants). Refused if `userId` is not a participant.
|
|
2251
|
+
*/
|
|
2252
|
+
setUrgent(input: {
|
|
2253
|
+
conversationId: string;
|
|
2254
|
+
userId: string;
|
|
2255
|
+
isUrgent: boolean;
|
|
2256
|
+
}): Promise<{
|
|
2257
|
+
updated: true;
|
|
2258
|
+
isUrgent: boolean;
|
|
2259
|
+
changed: boolean;
|
|
2260
|
+
}>;
|
|
1628
2261
|
/**
|
|
1629
2262
|
* Zero unread on every conversation the user has reads for, except
|
|
1630
2263
|
* those whose `providerPhone` is in `excludedProviderPhones`.
|
|
@@ -1838,6 +2471,16 @@ declare class EhrResource {
|
|
|
1838
2471
|
* Caller assembles the note body (text + bullets). Truth owns the Elation
|
|
1839
2472
|
* OAuth token and the HTTP call so applications can drop Elation
|
|
1840
2473
|
* credentials from their own config.
|
|
2474
|
+
*
|
|
2475
|
+
* BREAKING — 0.26.20, `pushConversationToElation`:
|
|
2476
|
+
* - AUTH CLASS CHANGED. The server route moved from `applicationProcedure`
|
|
2477
|
+
* to `verifiedUserProcedure`, so an API key alone (including a secret
|
|
2478
|
+
* `hn_sk_*` or legacy `hn_live_*` key) now gets 401. Callers MUST supply
|
|
2479
|
+
* `getAuthToken` on the client so a verified Clerk JWT accompanies the
|
|
2480
|
+
* request; this resource already sends it with `requireUserToken: true`.
|
|
2481
|
+
* - `input.initiatedBy` is DEPRECATED and ignored server-side. The audit
|
|
2482
|
+
* row's actor is the JWT `sub`. Passing a differing value is logged as a
|
|
2483
|
+
* warning server-side and will be removed in a future major.
|
|
1841
2484
|
*/
|
|
1842
2485
|
|
|
1843
2486
|
interface NonVisitNoteBullet {
|
|
@@ -1864,14 +2507,27 @@ interface PushConversationToElationInput {
|
|
|
1864
2507
|
/** One-of: conversationId (Convex) or phonePair. */
|
|
1865
2508
|
conversationId?: string;
|
|
1866
2509
|
phonePair?: string;
|
|
1867
|
-
/**
|
|
1868
|
-
|
|
2510
|
+
/**
|
|
2511
|
+
* @deprecated Ignored by the server; the actor recorded on the audit row is
|
|
2512
|
+
* derived from the verified Clerk JWT (`sub`). Supplying a value has no
|
|
2513
|
+
* effect and will be removed in a future major.
|
|
2514
|
+
*/
|
|
2515
|
+
initiatedBy?: string;
|
|
1869
2516
|
/** Pre-assembled note body (transcript-style text). */
|
|
1870
2517
|
noteText: string;
|
|
1871
2518
|
bullets?: NonVisitNoteBullet[];
|
|
1872
2519
|
notesPushed?: number;
|
|
1873
2520
|
messagesPushed?: number;
|
|
1874
2521
|
tasksPushed?: number;
|
|
2522
|
+
/**
|
|
2523
|
+
* Convex ids of the `conversationNotes` rows included in this push. When
|
|
2524
|
+
* set, Truth rejects the call with 409 CONFLICT if any is already marked
|
|
2525
|
+
* sent (unless `resend`), rejects ids that are not in this conversation with
|
|
2526
|
+
* 404, and stamps each note sent on success (never on failure).
|
|
2527
|
+
*/
|
|
2528
|
+
noteIds?: string[];
|
|
2529
|
+
/** Explicitly allow re-sending notes already marked sent. Default false. */
|
|
2530
|
+
resend?: boolean;
|
|
1875
2531
|
}
|
|
1876
2532
|
interface PushConversationToElationResult {
|
|
1877
2533
|
success: true;
|
|
@@ -1880,6 +2536,8 @@ interface PushConversationToElationResult {
|
|
|
1880
2536
|
notesPushed: number;
|
|
1881
2537
|
messagesPushed: number;
|
|
1882
2538
|
tasksPushed: number;
|
|
2539
|
+
/** Notes stamped sent by this call (empty when no `noteIds` were supplied). */
|
|
2540
|
+
sentNoteIds: string[];
|
|
1883
2541
|
}
|
|
1884
2542
|
declare class NotesResource {
|
|
1885
2543
|
private readonly baseUrl;
|
|
@@ -1901,6 +2559,11 @@ declare class NotesResource {
|
|
|
1901
2559
|
* physician/practice in Elation, posts the note, and writes an audit
|
|
1902
2560
|
* row to `elationSyncEvents`. Replaces CommHub's `pushNotesToElation`
|
|
1903
2561
|
* Hasura action.
|
|
2562
|
+
*
|
|
2563
|
+
* Auth: requires a user token. The server runs this route under
|
|
2564
|
+
* `verifiedUserProcedure`, so the API key alone is rejected with 401 —
|
|
2565
|
+
* configure `getAuthToken` on the client. `input.initiatedBy` is ignored;
|
|
2566
|
+
* the audit row's actor is the verified JWT `sub`.
|
|
1904
2567
|
*/
|
|
1905
2568
|
pushConversationToElation(input: PushConversationToElationInput): Promise<PushConversationToElationResult>;
|
|
1906
2569
|
}
|
|
@@ -2325,6 +2988,8 @@ declare const reportSchema: z.ZodObject<{
|
|
|
2325
2988
|
members: z.ZodArray<z.ZodObject<{
|
|
2326
2989
|
elationId: z.ZodString;
|
|
2327
2990
|
name: z.ZodString;
|
|
2991
|
+
lastName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2992
|
+
firstName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2328
2993
|
doctor: z.ZodNullable<z.ZodString>;
|
|
2329
2994
|
status: z.ZodEnum<{
|
|
2330
2995
|
data: "data";
|
|
@@ -2855,6 +3520,8 @@ declare class TruthClient {
|
|
|
2855
3520
|
readonly notifications: NotificationsResource;
|
|
2856
3521
|
/** Conversation-tied writes — notes, tasks, outbound messages. */
|
|
2857
3522
|
readonly conversations: ConversationsResource;
|
|
3523
|
+
/** Care-team email inbox — link/unlink and (gated) send via oRPC. */
|
|
3524
|
+
readonly careInbox: CareInboxResource;
|
|
2858
3525
|
/** User settings — notification preferences (Convex-backed) */
|
|
2859
3526
|
readonly userSettings: UserSettingsResource;
|
|
2860
3527
|
private readonly convex;
|
|
@@ -3287,4 +3954,4 @@ interface UseVoicemailUrlResult {
|
|
|
3287
3954
|
*/
|
|
3288
3955
|
declare function useVoicemailUrl(client: TruthClient): UseVoicemailUrlResult;
|
|
3289
3956
|
|
|
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 };
|
|
3957
|
+
export { ACTIVE_CALL_STATES, API_BASE_URLS, type Appointment, type AppointmentListOptions, CONNECTED_CALL_STATES, CONVEX_URLS, type CareInboxConvexClient, type CareInboxEmailMessage, type CareInboxEmailThreadSummary, CareInboxError, type CareInboxErrorCode, type CareInboxErrorFields, type CareInboxErrorInfo, type CareInboxErrorReason, type CareInboxLinkResult, type CareInboxMailbox, type CareInboxMailboxAccess, type CareInboxSdkSource, type CareInboxSendResult, type CareInboxSourceDeps, type CareInboxThreadDetail, type ComposeEmailInput, type ConversationListItem, type ConversationMessage, type ConversationMessageRow, type ConversationNoteRow, type ConversationRow, type ConversationTaskForUserRow, type ConversationTaskRow, type DialpadCallLogRow, type DialpadCallRow, DialpadCallState, type EmailDirection, type EmailMailbox, type EmailMailboxAccessView, type EmailMailboxView, type EmailMessage, type EmailMessageView, type EmailParticipant, type EmailParticipantView, type EmailThreadBodiesView, type EmailThreadDetail, type EmailThreadDetailView, type EmailThreadListFilter, type EmailThreadPageView, type EmailThreadSummary, type EmailThreadSummaryView, type EventPayloadMap, type EventType, type FamilyMemberRow, type LinkEmailMessageInput, type LinkMessageArgs, type LinkResult, type LinkedPatientContact, type ListThreadsArgs, type MailboxAccess, type MarkEmailThreadReadResult, type MarkReadArgs, type MarkReadResult, NoopStore, type OfflineStore, type Patient, type PatientLinkCandidate, type PatientLinkCandidateView, type PatientListOptions, type PatientSearchResult, type PermissionStatus, type Physician$1 as Physician, RINGING_CALL_STATES, type ReplyToEmailThreadInput, type SendEmailArgs, type SendReplyArgs, type SendResult, TERMINAL_CALL_STATES, type TaskEventRow, type ThreadListFilter, type ThreadPage, type TrackOptions, TruthProvider, type TruthProviderProps, type TruthTrackingContextValue, TruthTrackingProvider, type TruthTrackingProviderProps, type UnlinkEmailMessageInput, type UnlinkMessageArgs, type UnlinkedEmailPageView, type UnlinkedMessagePage, type UrgentConversationListItem, type UseActiveCallsOptions, type UseAppointmentListOptions, type UseConversationMessagesOptions, type UseConversationsFilters, type UseEmailThreadsOptions, type UseMessagesOptions, type UseNotificationsActions, type UseNotificationsOptions, type UseNotificationsResult, type UsePaginatedEmailThreadsOptions, type UsePaginatedEmailThreadsResult, type UsePatientBasicOptions, type UsePatientBasicResult, type UsePatientFamilyMembersInput, type UsePatientListOptions, type UsePatientMedicalOptions, type UsePatientPhotoOptions, type UsePatientSearchOptions, type UseQueryResult, type UseSearchPatientsForLinkOptions, type UseUnlinkedEmailsOptions, type UseUserSyncInput, type UseUserSyncResult, careInboxErrorInfo, careInboxRefs, createCareInboxSource, getTruthClient, isCareInboxError, readPersistedSavedAt, resolveApiBaseUrl, resolveConvexUrl, toCareInboxError, toEmailMailbox, toEmailMessage, toEmailThreadDetail, toEmailThreadSummary, toMailboxAccess, toMarkReadResult, toThreadPage, toUnlinkedMessagePage, useActiveCalls, useAppointment, useAppointmentByElationId, useAppointments, useCareInboxSource, useConversationById, useConversationByPhonePair, useConversationMessages, useConversationNotes, useConversationNotesByPhonePair, useConversationTaskHistory, useConversationTaskMarkSeen, useConversationTasks, useConversationTasksByPhonePair, useConversationTasksForUser, useConversations, useDialpadCallByCallId, useDialpadCallLog, useDialpadCallsForConversation, useEmailThread, useEmailThreads, useEmailUnreadCount, useLinkEmailMessage, useMailboxes, useMarkEmailThreadRead, useMessages, useNotifications, useNotificationsActions, useOfflineEnabled, useOfflineStore, useOpenEmailThreadBodies, usePaginatedEmailThreads, usePatient, usePatientBasic, usePatientByElationId, usePatientByHintId, usePatientFamilyMembers, usePatientMedical, usePatientPhoto, usePatientSearch, usePatients, usePatientsByIds, usePatientsByPhones, usePharmacyByNcpdpId, usePhysicianByElationId, usePhysiciansByElationIds, useRemindersForConversations, useSaveCallSummary, useSearchPatientsForLink, useTaskHistory, useTruth, useTruthClient, useTruthSdkContext, useUnlinkEmailMessage, useUnlinkedEmails, useUnreadAggregate, useUnreadCount, useUrgentConversations, useUserSettings, useUserSync, useVoicemailUrl };
|