@hipnation-truth/sdk 0.27.0 → 0.29.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/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -20,6 +22,7 @@ var __spreadValues = (a, b) => {
|
|
|
20
22
|
}
|
|
21
23
|
return a;
|
|
22
24
|
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
26
|
var __export = (target, all) => {
|
|
24
27
|
for (var name in all)
|
|
25
28
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -64,6 +67,8 @@ __export(src_exports, {
|
|
|
64
67
|
AttachmentsResource: () => AttachmentsResource,
|
|
65
68
|
CALL_EVENTS: () => CALL_EVENTS,
|
|
66
69
|
CONVERSATION_EVENTS: () => CONVERSATION_EVENTS,
|
|
70
|
+
CareInboxError: () => CareInboxError,
|
|
71
|
+
CareInboxResource: () => CareInboxResource,
|
|
67
72
|
ConversationsError: () => ConversationsError,
|
|
68
73
|
ConversationsResource: () => ConversationsResource,
|
|
69
74
|
DialpadProxyError: () => DialpadProxyError,
|
|
@@ -97,12 +102,25 @@ __export(src_exports, {
|
|
|
97
102
|
TranslationResource: () => TranslationResource,
|
|
98
103
|
TruthClient: () => TruthClient,
|
|
99
104
|
UserSettingsResource: () => UserSettingsResource,
|
|
105
|
+
careInboxErrorInfo: () => careInboxErrorInfo,
|
|
106
|
+
careInboxRefs: () => careInboxRefs,
|
|
107
|
+
createCareInboxSource: () => createCareInboxSource,
|
|
100
108
|
generateUuidV7: () => generateUuidV7,
|
|
109
|
+
isCareInboxError: () => isCareInboxError,
|
|
101
110
|
isWebPushSupported: () => isWebPushSupported,
|
|
102
111
|
onServiceWorkerMessage: () => onServiceWorkerMessage,
|
|
103
112
|
registerServiceWorker: () => registerServiceWorker,
|
|
104
113
|
subscribeToPush: () => subscribeToPush,
|
|
105
|
-
subscriptionToJSON: () => subscriptionToJSON
|
|
114
|
+
subscriptionToJSON: () => subscriptionToJSON,
|
|
115
|
+
toCareInboxError: () => toCareInboxError,
|
|
116
|
+
toEmailMailbox: () => toEmailMailbox,
|
|
117
|
+
toEmailMessage: () => toEmailMessage,
|
|
118
|
+
toEmailThreadDetail: () => toEmailThreadDetail,
|
|
119
|
+
toEmailThreadSummary: () => toEmailThreadSummary,
|
|
120
|
+
toMailboxAccess: () => toMailboxAccess,
|
|
121
|
+
toMarkReadResult: () => toMarkReadResult,
|
|
122
|
+
toThreadPage: () => toThreadPage,
|
|
123
|
+
toUnlinkedMessagePage: () => toUnlinkedMessagePage
|
|
106
124
|
});
|
|
107
125
|
module.exports = __toCommonJS(src_exports);
|
|
108
126
|
|
|
@@ -419,6 +437,304 @@ var AttachmentsResource = class {
|
|
|
419
437
|
}
|
|
420
438
|
};
|
|
421
439
|
|
|
440
|
+
// src/resources/care-inbox.ts
|
|
441
|
+
var NO_PARTICIPANT = { address: "", name: null };
|
|
442
|
+
function participant(p) {
|
|
443
|
+
return p ? { address: p.address, name: p.name } : __spreadValues({}, NO_PARTICIPANT);
|
|
444
|
+
}
|
|
445
|
+
function toEmailMessage(m) {
|
|
446
|
+
var _a, _b;
|
|
447
|
+
return {
|
|
448
|
+
id: m.id,
|
|
449
|
+
threadId: (_a = m.threadId) != null ? _a : "",
|
|
450
|
+
mailboxId: m.mailboxId,
|
|
451
|
+
direction: m.direction,
|
|
452
|
+
from: participant(m.from),
|
|
453
|
+
to: m.to.map(participant),
|
|
454
|
+
subject: (_b = m.subject) != null ? _b : "",
|
|
455
|
+
sentAt: m.sentAt,
|
|
456
|
+
hasAttachments: m.hasAttachments,
|
|
457
|
+
linkedPatientId: m.linkedPatientId,
|
|
458
|
+
linkedPatientName: m.linkedPatientName,
|
|
459
|
+
bodyText: m.bodyText
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function toEmailThreadSummary(t) {
|
|
463
|
+
var _a, _b;
|
|
464
|
+
return {
|
|
465
|
+
id: t.id,
|
|
466
|
+
mailboxId: t.mailboxId,
|
|
467
|
+
subject: (_a = t.subject) != null ? _a : "",
|
|
468
|
+
lastMessageAt: t.lastMessageAt,
|
|
469
|
+
lastDirection: (_b = t.lastDirection) != null ? _b : "inbound",
|
|
470
|
+
counterpart: participant(t.counterpart),
|
|
471
|
+
messageCount: t.messageCount,
|
|
472
|
+
unreadCount: t.unreadCount,
|
|
473
|
+
unlinkedCount: t.unlinkedCount,
|
|
474
|
+
linkedPatientName: t.linkedPatientName,
|
|
475
|
+
hasAttachments: t.hasAttachments
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
function toEmailMailbox(m) {
|
|
479
|
+
var _a;
|
|
480
|
+
return {
|
|
481
|
+
id: m.id,
|
|
482
|
+
address: (_a = m.address) != null ? _a : "",
|
|
483
|
+
displayName: m.displayName,
|
|
484
|
+
mode: m.mode,
|
|
485
|
+
canSend: m.canSend,
|
|
486
|
+
bodyVisible: m.bodyVisible
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
function toMailboxAccess(a) {
|
|
490
|
+
return { mailboxes: a.mailboxes.map(toEmailMailbox), canTriage: a.canTriage };
|
|
491
|
+
}
|
|
492
|
+
function toEmailThreadDetail(d) {
|
|
493
|
+
return {
|
|
494
|
+
summary: toEmailThreadSummary(d.summary),
|
|
495
|
+
mailbox: toEmailMailbox(d.mailbox),
|
|
496
|
+
messages: d.messages.map(toEmailMessage),
|
|
497
|
+
bodyVisible: d.bodyVisible,
|
|
498
|
+
patientContact: null
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function toThreadPage(p) {
|
|
502
|
+
return {
|
|
503
|
+
threads: p.threads.map(toEmailThreadSummary),
|
|
504
|
+
nextCursor: p.nextCursor
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function toUnlinkedMessagePage(p) {
|
|
508
|
+
return {
|
|
509
|
+
messages: p.messages.map(toEmailMessage),
|
|
510
|
+
nextCursor: p.nextCursor
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function toMarkReadResult(r) {
|
|
514
|
+
return { thread: toEmailThreadSummary(r.thread) };
|
|
515
|
+
}
|
|
516
|
+
var REASONS = [
|
|
517
|
+
"send_disabled",
|
|
518
|
+
"not_triage",
|
|
519
|
+
"body_gated",
|
|
520
|
+
"unauthenticated"
|
|
521
|
+
];
|
|
522
|
+
var CODES = [
|
|
523
|
+
"forbidden",
|
|
524
|
+
"not_found",
|
|
525
|
+
"offline",
|
|
526
|
+
"unavailable",
|
|
527
|
+
"validation",
|
|
528
|
+
"unknown"
|
|
529
|
+
];
|
|
530
|
+
function asReason(value) {
|
|
531
|
+
return REASONS.includes(value) ? value : null;
|
|
532
|
+
}
|
|
533
|
+
function asCode(value) {
|
|
534
|
+
return CODES.includes(value) ? value : null;
|
|
535
|
+
}
|
|
536
|
+
var CareInboxError = class extends Error {
|
|
537
|
+
constructor(code, fields = {}) {
|
|
538
|
+
var _a, _b, _c, _d;
|
|
539
|
+
const reason = (_a = fields.reason) != null ? _a : null;
|
|
540
|
+
const status = (_b = fields.status) != null ? _b : 0;
|
|
541
|
+
super(
|
|
542
|
+
`Care inbox request failed: ${code}${reason ? ` (${reason})` : ""}${status ? ` HTTP ${status}` : ""}`
|
|
543
|
+
);
|
|
544
|
+
this.name = "CareInboxError";
|
|
545
|
+
this.code = code;
|
|
546
|
+
this.status = status;
|
|
547
|
+
this.rpcCode = (_c = fields.rpcCode) != null ? _c : null;
|
|
548
|
+
this.reason = reason;
|
|
549
|
+
this.detail = (_d = fields.detail) != null ? _d : null;
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
function codeForStatus(status, rpcCode) {
|
|
553
|
+
if (status === 0) {
|
|
554
|
+
if (rpcCode === "TRANSPORT" || rpcCode === "TIMEOUT") {
|
|
555
|
+
return "offline";
|
|
556
|
+
}
|
|
557
|
+
if (rpcCode === "NO_USER_TOKEN") {
|
|
558
|
+
return "forbidden";
|
|
559
|
+
}
|
|
560
|
+
return "unknown";
|
|
561
|
+
}
|
|
562
|
+
if (status === 400) {
|
|
563
|
+
return "validation";
|
|
564
|
+
}
|
|
565
|
+
if (status === 401 || status === 403) {
|
|
566
|
+
return "forbidden";
|
|
567
|
+
}
|
|
568
|
+
if (status === 404) {
|
|
569
|
+
return "not_found";
|
|
570
|
+
}
|
|
571
|
+
if (status === 503) {
|
|
572
|
+
return "unavailable";
|
|
573
|
+
}
|
|
574
|
+
return "unknown";
|
|
575
|
+
}
|
|
576
|
+
function httpError(fields) {
|
|
577
|
+
var _a;
|
|
578
|
+
const unauthenticated = fields.status === 401 || fields.rpcCode === "NO_USER_TOKEN";
|
|
579
|
+
return new CareInboxError(codeForStatus(fields.status, fields.rpcCode), __spreadProps(__spreadValues({}, fields), {
|
|
580
|
+
reason: (_a = fields.reason) != null ? _a : unauthenticated ? "unauthenticated" : null
|
|
581
|
+
}));
|
|
582
|
+
}
|
|
583
|
+
function isCareInboxError(value) {
|
|
584
|
+
return value instanceof Error && asCode(value.code) !== null;
|
|
585
|
+
}
|
|
586
|
+
function toCareInboxError(value) {
|
|
587
|
+
if (value instanceof CareInboxError) {
|
|
588
|
+
return value;
|
|
589
|
+
}
|
|
590
|
+
const data = value && typeof value === "object" ? value.data : void 0;
|
|
591
|
+
if (data && typeof data === "object") {
|
|
592
|
+
const { code, reason } = data;
|
|
593
|
+
const known = asCode(code);
|
|
594
|
+
if (known) {
|
|
595
|
+
return new CareInboxError(known, { reason: asReason(reason) });
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
if (isCareInboxError(value)) {
|
|
599
|
+
const v = value;
|
|
600
|
+
return new CareInboxError(value.code, {
|
|
601
|
+
status: typeof v.status === "number" && Number.isInteger(v.status) && v.status >= 0 ? v.status : 0,
|
|
602
|
+
rpcCode: typeof v.rpcCode === "string" ? v.rpcCode : null,
|
|
603
|
+
reason: asReason(v.reason),
|
|
604
|
+
detail: typeof v.detail === "string" ? v.detail : null
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
return new CareInboxError("unknown");
|
|
608
|
+
}
|
|
609
|
+
function careInboxErrorInfo(err) {
|
|
610
|
+
const e = toCareInboxError(err);
|
|
611
|
+
return { code: e.code, reason: e.reason };
|
|
612
|
+
}
|
|
613
|
+
function newRequestId() {
|
|
614
|
+
const c = globalThis.crypto;
|
|
615
|
+
if (c && typeof c.randomUUID === "function") {
|
|
616
|
+
return c.randomUUID();
|
|
617
|
+
}
|
|
618
|
+
const bytes = new Uint8Array(16);
|
|
619
|
+
if (c && typeof c.getRandomValues === "function") {
|
|
620
|
+
c.getRandomValues(bytes);
|
|
621
|
+
} else {
|
|
622
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
623
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
627
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
628
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join(
|
|
629
|
+
""
|
|
630
|
+
);
|
|
631
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
632
|
+
}
|
|
633
|
+
var _CareInboxResource = class _CareInboxResource {
|
|
634
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
635
|
+
this.baseUrl = apiBaseUrl;
|
|
636
|
+
this.auth = { apiKey, getAuthToken };
|
|
637
|
+
}
|
|
638
|
+
/** Link one message to a patient (triage only). */
|
|
639
|
+
linkMessage(input) {
|
|
640
|
+
return __async(this, null, function* () {
|
|
641
|
+
var _a;
|
|
642
|
+
return this.post("/care-inbox/link", {
|
|
643
|
+
messageId: input.messageId,
|
|
644
|
+
patientId: input.patientId,
|
|
645
|
+
requestId: (_a = input.requestId) != null ? _a : newRequestId()
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
/** Undo a manual link (triage only). */
|
|
650
|
+
unlinkMessage(input) {
|
|
651
|
+
return __async(this, null, function* () {
|
|
652
|
+
var _a;
|
|
653
|
+
return this.post("/care-inbox/unlink", {
|
|
654
|
+
messageId: input.messageId,
|
|
655
|
+
requestId: (_a = input.requestId) != null ? _a : newRequestId()
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
/** Reply into a thread. This build always rejects 403 `send_disabled`. */
|
|
660
|
+
replyToThread(input) {
|
|
661
|
+
return __async(this, null, function* () {
|
|
662
|
+
return this.post("/care-inbox/outbound/thread-reply", {
|
|
663
|
+
threadId: input.threadId,
|
|
664
|
+
body: input.body,
|
|
665
|
+
clientRequestId: input.clientRequestId
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
/** Start a new email. This build always rejects 403 `send_disabled`. */
|
|
670
|
+
composeEmail(input) {
|
|
671
|
+
return __async(this, null, function* () {
|
|
672
|
+
return this.post("/care-inbox/outbound/compose", __spreadProps(__spreadValues({
|
|
673
|
+
to: input.to,
|
|
674
|
+
subject: input.subject,
|
|
675
|
+
body: input.body
|
|
676
|
+
}, input.patientId !== void 0 ? { patientId: input.patientId } : {}), {
|
|
677
|
+
mailboxId: input.mailboxId,
|
|
678
|
+
clientRequestId: input.clientRequestId
|
|
679
|
+
}));
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
post(path, body) {
|
|
683
|
+
return __async(this, null, function* () {
|
|
684
|
+
const fail = (rpcCode) => httpError({ status: 0, rpcCode, reason: null, detail: null });
|
|
685
|
+
if (!this.auth.apiKey) {
|
|
686
|
+
throw fail("NO_API_KEY");
|
|
687
|
+
}
|
|
688
|
+
let headers;
|
|
689
|
+
try {
|
|
690
|
+
headers = yield buildAuthHeaders(this.auth, {
|
|
691
|
+
json: true,
|
|
692
|
+
requireUserToken: true
|
|
693
|
+
});
|
|
694
|
+
} catch (e) {
|
|
695
|
+
throw fail("NO_USER_TOKEN");
|
|
696
|
+
}
|
|
697
|
+
const controller = new AbortController();
|
|
698
|
+
const timeout = setTimeout(
|
|
699
|
+
() => controller.abort(),
|
|
700
|
+
_CareInboxResource.REQUEST_TIMEOUT_MS
|
|
701
|
+
);
|
|
702
|
+
let res;
|
|
703
|
+
try {
|
|
704
|
+
res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
705
|
+
method: "POST",
|
|
706
|
+
headers,
|
|
707
|
+
body: JSON.stringify(body),
|
|
708
|
+
signal: controller.signal
|
|
709
|
+
});
|
|
710
|
+
} catch (err) {
|
|
711
|
+
const isAbort = err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
|
|
712
|
+
throw fail(isAbort ? "TIMEOUT" : "TRANSPORT");
|
|
713
|
+
} finally {
|
|
714
|
+
clearTimeout(timeout);
|
|
715
|
+
}
|
|
716
|
+
if (!res.ok) {
|
|
717
|
+
let parsed = {};
|
|
718
|
+
try {
|
|
719
|
+
parsed = yield res.json();
|
|
720
|
+
} catch (e) {
|
|
721
|
+
}
|
|
722
|
+
const data = parsed.data && typeof parsed.data === "object" ? parsed.data : {};
|
|
723
|
+
throw httpError({
|
|
724
|
+
status: res.status,
|
|
725
|
+
rpcCode: typeof parsed.code === "string" ? parsed.code : null,
|
|
726
|
+
reason: asReason(data.reason),
|
|
727
|
+
detail: typeof parsed.message === "string" ? parsed.message.slice(0, 200) : null
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
return yield res.json();
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
/** 30s upstream timeout — matches ConversationsResource. */
|
|
735
|
+
_CareInboxResource.REQUEST_TIMEOUT_MS = 3e4;
|
|
736
|
+
var CareInboxResource = _CareInboxResource;
|
|
737
|
+
|
|
422
738
|
// src/resources/conversations.ts
|
|
423
739
|
var ConversationsError = class extends Error {
|
|
424
740
|
constructor(operation, status, message) {
|
|
@@ -581,6 +897,25 @@ var _ConversationsResource = class _ConversationsResource {
|
|
|
581
897
|
);
|
|
582
898
|
});
|
|
583
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* Mark / unmark a conversation Urgent (conversation-level, shared by
|
|
902
|
+
* participants). Refused if `userId` is not a participant.
|
|
903
|
+
*/
|
|
904
|
+
setUrgent(input) {
|
|
905
|
+
return __async(this, null, function* () {
|
|
906
|
+
if (!this.convex) {
|
|
907
|
+
throw new ConversationsError(
|
|
908
|
+
"/setUrgent",
|
|
909
|
+
0,
|
|
910
|
+
"ConversationsResource missing Convex client"
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
return yield this.convex.mutation(
|
|
914
|
+
"conversations:setUrgent",
|
|
915
|
+
input
|
|
916
|
+
);
|
|
917
|
+
});
|
|
918
|
+
}
|
|
584
919
|
/**
|
|
585
920
|
* Zero unread on every conversation the user has reads for, except
|
|
586
921
|
* those whose `providerPhone` is in `excludedProviderPhones`.
|
|
@@ -1142,6 +1477,11 @@ var _NotesResource = class _NotesResource {
|
|
|
1142
1477
|
* physician/practice in Elation, posts the note, and writes an audit
|
|
1143
1478
|
* row to `elationSyncEvents`. Replaces CommHub's `pushNotesToElation`
|
|
1144
1479
|
* Hasura action.
|
|
1480
|
+
*
|
|
1481
|
+
* Auth: requires a user token. The server runs this route under
|
|
1482
|
+
* `verifiedUserProcedure`, so the API key alone is rejected with 401 —
|
|
1483
|
+
* configure `getAuthToken` on the client. `input.initiatedBy` is ignored;
|
|
1484
|
+
* the audit row's actor is the verified JWT `sub`.
|
|
1145
1485
|
*/
|
|
1146
1486
|
pushConversationToElation(input) {
|
|
1147
1487
|
return __async(this, null, function* () {
|
|
@@ -1626,6 +1966,11 @@ var import_zod = require("zod");
|
|
|
1626
1966
|
var memberSchema = import_zod.z.object({
|
|
1627
1967
|
elationId: import_zod.z.string(),
|
|
1628
1968
|
name: import_zod.z.string(),
|
|
1969
|
+
// T6: mirrors truth's member-activation-report.ts memberSchema (T5).
|
|
1970
|
+
// Optional/nullable so a comhub build against an older/newer server
|
|
1971
|
+
// payload still parses either way.
|
|
1972
|
+
lastName: import_zod.z.string().nullable().optional(),
|
|
1973
|
+
firstName: import_zod.z.string().nullable().optional(),
|
|
1629
1974
|
doctor: import_zod.z.string().nullable(),
|
|
1630
1975
|
status: import_zod.z.enum(["activated", "outreach", "scheduled", "review", "data"]),
|
|
1631
1976
|
membershipStart: import_zod.z.string(),
|
|
@@ -2243,6 +2588,11 @@ var TruthClient = class {
|
|
|
2243
2588
|
this.convex,
|
|
2244
2589
|
config.getAuthToken
|
|
2245
2590
|
);
|
|
2591
|
+
this.careInbox = new CareInboxResource(
|
|
2592
|
+
apiUrl,
|
|
2593
|
+
config.apiKey,
|
|
2594
|
+
config.getAuthToken
|
|
2595
|
+
);
|
|
2246
2596
|
this.userSettings = new UserSettingsResource(this.convex);
|
|
2247
2597
|
this._getAuthToken = config.getAuthToken;
|
|
2248
2598
|
this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
|
|
@@ -2384,6 +2734,103 @@ var TruthClient = class {
|
|
|
2384
2734
|
}
|
|
2385
2735
|
};
|
|
2386
2736
|
|
|
2737
|
+
// src/resources/care-inbox-source.ts
|
|
2738
|
+
var import_server2 = require("convex/server");
|
|
2739
|
+
var careInboxRefs = {
|
|
2740
|
+
listThreadsForUser: (0, import_server2.makeFunctionReference)("careInboxQueries:listThreadsForUser"),
|
|
2741
|
+
getThread: (0, import_server2.makeFunctionReference)("careInboxQueries:getThread"),
|
|
2742
|
+
listUnlinked: (0, import_server2.makeFunctionReference)("careInboxQueries:listUnlinked"),
|
|
2743
|
+
unreadEmailCount: (0, import_server2.makeFunctionReference)("careInboxQueries:unreadEmailCount"),
|
|
2744
|
+
listMailboxesForUser: (0, import_server2.makeFunctionReference)("careInboxQueries:listMailboxesForUser"),
|
|
2745
|
+
searchPatientsForLink: (0, import_server2.makeFunctionReference)("careInboxQueries:searchPatientsForLink"),
|
|
2746
|
+
markRead: (0, import_server2.makeFunctionReference)("careInboxReads:markRead"),
|
|
2747
|
+
openThreadBodies: (0, import_server2.makeFunctionReference)("careInboxReads:openThreadBodies")
|
|
2748
|
+
};
|
|
2749
|
+
function compactArgs(args) {
|
|
2750
|
+
const out = {};
|
|
2751
|
+
for (const [k, v] of Object.entries(args)) {
|
|
2752
|
+
if (v !== void 0) {
|
|
2753
|
+
out[k] = v;
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
return out;
|
|
2757
|
+
}
|
|
2758
|
+
function guarded(run) {
|
|
2759
|
+
return __async(this, null, function* () {
|
|
2760
|
+
try {
|
|
2761
|
+
return yield run();
|
|
2762
|
+
} catch (err) {
|
|
2763
|
+
throw toCareInboxError(err);
|
|
2764
|
+
}
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
function createCareInboxSource({
|
|
2768
|
+
convex,
|
|
2769
|
+
careInbox
|
|
2770
|
+
}) {
|
|
2771
|
+
const q = (ref, args) => convex.query(
|
|
2772
|
+
ref,
|
|
2773
|
+
compactArgs(args)
|
|
2774
|
+
);
|
|
2775
|
+
return {
|
|
2776
|
+
listThreads: (args = {}) => guarded(
|
|
2777
|
+
() => __async(null, null, function* () {
|
|
2778
|
+
return toThreadPage(
|
|
2779
|
+
yield q(careInboxRefs.listThreadsForUser, {
|
|
2780
|
+
mailboxId: args.mailboxId,
|
|
2781
|
+
filter: args.filter,
|
|
2782
|
+
cursor: args.cursor,
|
|
2783
|
+
limit: args.limit
|
|
2784
|
+
})
|
|
2785
|
+
);
|
|
2786
|
+
})
|
|
2787
|
+
),
|
|
2788
|
+
getUnreadCount: (args = {}) => guarded(
|
|
2789
|
+
() => q(careInboxRefs.unreadEmailCount, {
|
|
2790
|
+
mailboxId: args.mailboxId
|
|
2791
|
+
})
|
|
2792
|
+
),
|
|
2793
|
+
getThread: (threadId) => guarded(() => __async(null, null, function* () {
|
|
2794
|
+
const detail = yield q(
|
|
2795
|
+
careInboxRefs.getThread,
|
|
2796
|
+
{ threadId }
|
|
2797
|
+
);
|
|
2798
|
+
if (!detail) {
|
|
2799
|
+
throw new CareInboxError("unavailable");
|
|
2800
|
+
}
|
|
2801
|
+
return toEmailThreadDetail(detail);
|
|
2802
|
+
})),
|
|
2803
|
+
listMailboxesForUser: () => guarded(
|
|
2804
|
+
() => __async(null, null, function* () {
|
|
2805
|
+
return toMailboxAccess(
|
|
2806
|
+
yield q(
|
|
2807
|
+
careInboxRefs.listMailboxesForUser,
|
|
2808
|
+
{}
|
|
2809
|
+
)
|
|
2810
|
+
);
|
|
2811
|
+
})
|
|
2812
|
+
),
|
|
2813
|
+
searchPatientsForLink: (query) => guarded(
|
|
2814
|
+
() => q(careInboxRefs.searchPatientsForLink, {
|
|
2815
|
+
q: query
|
|
2816
|
+
})
|
|
2817
|
+
),
|
|
2818
|
+
linkMessage: (args) => guarded(() => careInbox.linkMessage(args)),
|
|
2819
|
+
unlinkMessage: (args) => guarded(() => careInbox.unlinkMessage(args)),
|
|
2820
|
+
sendReply: (args) => guarded(() => careInbox.replyToThread(args)),
|
|
2821
|
+
sendEmail: (args) => guarded(() => careInbox.composeEmail(args)),
|
|
2822
|
+
markRead: ({ threadId }) => guarded(
|
|
2823
|
+
() => __async(null, null, function* () {
|
|
2824
|
+
return toMarkReadResult(
|
|
2825
|
+
yield convex.mutation(careInboxRefs.markRead, {
|
|
2826
|
+
threadId
|
|
2827
|
+
})
|
|
2828
|
+
);
|
|
2829
|
+
})
|
|
2830
|
+
)
|
|
2831
|
+
};
|
|
2832
|
+
}
|
|
2833
|
+
|
|
2387
2834
|
// src/tracking/events.ts
|
|
2388
2835
|
var CONVERSATION_EVENTS = {
|
|
2389
2836
|
created: "conversation.created.v1",
|
|
@@ -2458,6 +2905,8 @@ var ENVIRONMENTS = {
|
|
|
2458
2905
|
AttachmentsResource,
|
|
2459
2906
|
CALL_EVENTS,
|
|
2460
2907
|
CONVERSATION_EVENTS,
|
|
2908
|
+
CareInboxError,
|
|
2909
|
+
CareInboxResource,
|
|
2461
2910
|
ConversationsError,
|
|
2462
2911
|
ConversationsResource,
|
|
2463
2912
|
DialpadProxyError,
|
|
@@ -2491,11 +2940,24 @@ var ENVIRONMENTS = {
|
|
|
2491
2940
|
TranslationResource,
|
|
2492
2941
|
TruthClient,
|
|
2493
2942
|
UserSettingsResource,
|
|
2943
|
+
careInboxErrorInfo,
|
|
2944
|
+
careInboxRefs,
|
|
2945
|
+
createCareInboxSource,
|
|
2494
2946
|
generateUuidV7,
|
|
2947
|
+
isCareInboxError,
|
|
2495
2948
|
isWebPushSupported,
|
|
2496
2949
|
onServiceWorkerMessage,
|
|
2497
2950
|
registerServiceWorker,
|
|
2498
2951
|
subscribeToPush,
|
|
2499
|
-
subscriptionToJSON
|
|
2952
|
+
subscriptionToJSON,
|
|
2953
|
+
toCareInboxError,
|
|
2954
|
+
toEmailMailbox,
|
|
2955
|
+
toEmailMessage,
|
|
2956
|
+
toEmailThreadDetail,
|
|
2957
|
+
toEmailThreadSummary,
|
|
2958
|
+
toMailboxAccess,
|
|
2959
|
+
toMarkReadResult,
|
|
2960
|
+
toThreadPage,
|
|
2961
|
+
toUnlinkedMessagePage
|
|
2500
2962
|
});
|
|
2501
2963
|
//# sourceMappingURL=index.js.map
|