@hipnation-truth/sdk 0.26.19 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +140 -8
- package/dist/index.d.ts +140 -8
- package/dist/index.js +167 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +165 -7
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +162 -8
- package/dist/react.js +234 -62
- package/dist/react.js.map +1 -1
- package/package.json +5 -2
package/dist/react.js
CHANGED
|
@@ -110,6 +110,7 @@ __export(react_exports, {
|
|
|
110
110
|
usePhysicianByElationId: () => usePhysicianByElationId,
|
|
111
111
|
usePhysiciansByElationIds: () => usePhysiciansByElationIds,
|
|
112
112
|
useRemindersForConversations: () => useRemindersForConversations,
|
|
113
|
+
useSaveCallSummary: () => useSaveCallSummary,
|
|
113
114
|
useTruth: () => useTruth,
|
|
114
115
|
useTruthClient: () => useTruthClient,
|
|
115
116
|
useTruthSdkContext: () => useTruthSdkContext,
|
|
@@ -122,7 +123,9 @@ __export(react_exports, {
|
|
|
122
123
|
module.exports = __toCommonJS(react_exports);
|
|
123
124
|
|
|
124
125
|
// src/react/calls.ts
|
|
126
|
+
var import_react4 = require("convex/react");
|
|
125
127
|
var import_server2 = require("convex/server");
|
|
128
|
+
var import_react5 = require("react");
|
|
126
129
|
|
|
127
130
|
// src/react/offline/use-persistent-query.ts
|
|
128
131
|
var import_react_query3 = require("@convex-dev/react-query");
|
|
@@ -306,7 +309,6 @@ var AttachmentsError = class extends Error {
|
|
|
306
309
|
var AttachmentsResource = class {
|
|
307
310
|
constructor(apiBaseUrl, apiKey, convexClient, getAuthToken) {
|
|
308
311
|
this.baseUrl = apiBaseUrl;
|
|
309
|
-
this.apiKey = apiKey;
|
|
310
312
|
this.auth = { apiKey, getAuthToken };
|
|
311
313
|
this.convex = convexClient;
|
|
312
314
|
}
|
|
@@ -737,7 +739,6 @@ var ConversationsResource = _ConversationsResource;
|
|
|
737
739
|
var DialpadResource = class {
|
|
738
740
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
739
741
|
this.baseUrl = apiBaseUrl;
|
|
740
|
-
this.apiKey = apiKey;
|
|
741
742
|
this.auth = { apiKey, getAuthToken };
|
|
742
743
|
}
|
|
743
744
|
/**
|
|
@@ -949,7 +950,6 @@ var MessagesResource = class {
|
|
|
949
950
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
950
951
|
this.dialpad = new DialpadResource(apiBaseUrl, apiKey, getAuthToken);
|
|
951
952
|
this.baseUrl = apiBaseUrl;
|
|
952
|
-
this.apiKey = apiKey;
|
|
953
953
|
this.auth = { apiKey, getAuthToken };
|
|
954
954
|
}
|
|
955
955
|
/**
|
|
@@ -1122,7 +1122,6 @@ var NotesError = class extends Error {
|
|
|
1122
1122
|
var _NotesResource = class _NotesResource {
|
|
1123
1123
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1124
1124
|
this.baseUrl = apiBaseUrl;
|
|
1125
|
-
this.apiKey = apiKey;
|
|
1126
1125
|
this.auth = { apiKey, getAuthToken };
|
|
1127
1126
|
}
|
|
1128
1127
|
post(path, body) {
|
|
@@ -1204,7 +1203,6 @@ var NotificationsError = class extends Error {
|
|
|
1204
1203
|
var NotificationsResource = class {
|
|
1205
1204
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1206
1205
|
this.baseUrl = apiBaseUrl;
|
|
1207
|
-
this.apiKey = apiKey;
|
|
1208
1206
|
this.auth = { apiKey, getAuthToken };
|
|
1209
1207
|
}
|
|
1210
1208
|
post(path, body) {
|
|
@@ -1377,7 +1375,6 @@ var PatientDetailsError = class extends Error {
|
|
|
1377
1375
|
var PatientDetailsResource = class {
|
|
1378
1376
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1379
1377
|
this.baseUrl = apiBaseUrl;
|
|
1380
|
-
this.apiKey = apiKey;
|
|
1381
1378
|
this.auth = { apiKey, getAuthToken };
|
|
1382
1379
|
}
|
|
1383
1380
|
post(path, body) {
|
|
@@ -1666,6 +1663,146 @@ var RemindersResource = class {
|
|
|
1666
1663
|
}
|
|
1667
1664
|
};
|
|
1668
1665
|
|
|
1666
|
+
// src/resources/reports.ts
|
|
1667
|
+
var import_zod = require("zod");
|
|
1668
|
+
var memberSchema = import_zod.z.object({
|
|
1669
|
+
elationId: import_zod.z.string(),
|
|
1670
|
+
name: import_zod.z.string(),
|
|
1671
|
+
doctor: import_zod.z.string().nullable(),
|
|
1672
|
+
status: import_zod.z.enum(["activated", "outreach", "scheduled", "review", "data"]),
|
|
1673
|
+
membershipStart: import_zod.z.string(),
|
|
1674
|
+
daysSinceMembershipStart: import_zod.z.number(),
|
|
1675
|
+
activationDate: import_zod.z.string().nullable(),
|
|
1676
|
+
futureApptDate: import_zod.z.string().nullable(),
|
|
1677
|
+
reason: import_zod.z.string().nullable(),
|
|
1678
|
+
hasLink: import_zod.z.boolean()
|
|
1679
|
+
});
|
|
1680
|
+
var reportSchema = import_zod.z.object({
|
|
1681
|
+
synthetic: import_zod.z.boolean(),
|
|
1682
|
+
generatedAt: import_zod.z.string(),
|
|
1683
|
+
employers: import_zod.z.array(
|
|
1684
|
+
import_zod.z.object({ id: import_zod.z.string(), name: import_zod.z.string(), activeMembers: import_zod.z.number() })
|
|
1685
|
+
),
|
|
1686
|
+
selected: import_zod.z.object({
|
|
1687
|
+
employerId: import_zod.z.string(),
|
|
1688
|
+
employerName: import_zod.z.string(),
|
|
1689
|
+
kpis: import_zod.z.object({
|
|
1690
|
+
active: import_zod.z.number(),
|
|
1691
|
+
linked: import_zod.z.number(),
|
|
1692
|
+
activated: import_zod.z.number(),
|
|
1693
|
+
needsOutreach: import_zod.z.number(),
|
|
1694
|
+
scheduled: import_zod.z.number(),
|
|
1695
|
+
needsReview: import_zod.z.number(),
|
|
1696
|
+
dataIssue: import_zod.z.number(),
|
|
1697
|
+
activationRate: import_zod.z.number()
|
|
1698
|
+
}),
|
|
1699
|
+
coverage: import_zod.z.object({
|
|
1700
|
+
active: import_zod.z.number(),
|
|
1701
|
+
linked: import_zod.z.number(),
|
|
1702
|
+
unlinked: import_zod.z.number(),
|
|
1703
|
+
pct: import_zod.z.number()
|
|
1704
|
+
}),
|
|
1705
|
+
breakdown: import_zod.z.array(
|
|
1706
|
+
import_zod.z.object({
|
|
1707
|
+
status: import_zod.z.enum([
|
|
1708
|
+
"activated",
|
|
1709
|
+
"outreach",
|
|
1710
|
+
"scheduled",
|
|
1711
|
+
"review",
|
|
1712
|
+
"data"
|
|
1713
|
+
]),
|
|
1714
|
+
label: import_zod.z.string(),
|
|
1715
|
+
count: import_zod.z.number(),
|
|
1716
|
+
pct: import_zod.z.number()
|
|
1717
|
+
})
|
|
1718
|
+
),
|
|
1719
|
+
aging: import_zod.z.array(
|
|
1720
|
+
import_zod.z.object({
|
|
1721
|
+
bucket: import_zod.z.string(),
|
|
1722
|
+
total: import_zod.z.number(),
|
|
1723
|
+
outreach: import_zod.z.number(),
|
|
1724
|
+
scheduled: import_zod.z.number(),
|
|
1725
|
+
review: import_zod.z.number()
|
|
1726
|
+
})
|
|
1727
|
+
),
|
|
1728
|
+
doctors: import_zod.z.array(
|
|
1729
|
+
import_zod.z.object({
|
|
1730
|
+
name: import_zod.z.string(),
|
|
1731
|
+
counts: import_zod.z.object({
|
|
1732
|
+
outreach: import_zod.z.number(),
|
|
1733
|
+
scheduled: import_zod.z.number(),
|
|
1734
|
+
review: import_zod.z.number(),
|
|
1735
|
+
data: import_zod.z.number()
|
|
1736
|
+
}),
|
|
1737
|
+
members: import_zod.z.array(memberSchema)
|
|
1738
|
+
})
|
|
1739
|
+
)
|
|
1740
|
+
}).nullable(),
|
|
1741
|
+
// True when the requested employer has no materialized report row yet
|
|
1742
|
+
// (ehr-sync's dailyHandler has not run for it). `selected` is null in that
|
|
1743
|
+
// case — the caller sees the employer roster but no report data to render.
|
|
1744
|
+
pending: import_zod.z.boolean()
|
|
1745
|
+
});
|
|
1746
|
+
var ReportsError = class extends Error {
|
|
1747
|
+
/**
|
|
1748
|
+
* Wraps a failed reports HTTP call with the operation name and status
|
|
1749
|
+
* code so callers can branch on `status` without re-parsing the message.
|
|
1750
|
+
* Falls back to a generated message when the server response body is
|
|
1751
|
+
* empty or unreadable.
|
|
1752
|
+
*/
|
|
1753
|
+
constructor(operation, status, message) {
|
|
1754
|
+
const trimmedMessage = message == null ? void 0 : message.trim();
|
|
1755
|
+
super(trimmedMessage || `Reports ${operation} failed (HTTP ${status})`);
|
|
1756
|
+
this.name = "ReportsError";
|
|
1757
|
+
this.status = status;
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
var ReportsResource = class {
|
|
1761
|
+
/**
|
|
1762
|
+
* Captures the Truth API base URL and the auth inputs (API key + optional
|
|
1763
|
+
* user-token fetcher) needed to authenticate every request this resource
|
|
1764
|
+
* makes.
|
|
1765
|
+
*/
|
|
1766
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1767
|
+
this.baseUrl = apiBaseUrl;
|
|
1768
|
+
this.auth = { apiKey, getAuthToken };
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Fetches the member activation report from GET /reports/member-activation,
|
|
1772
|
+
* optionally scoped to a single employer. Requires the user JWT (not just
|
|
1773
|
+
* the API key) since the server hardens this route to
|
|
1774
|
+
* `verifiedUserProcedure` for PHI access — throws via `ReportsError` on a
|
|
1775
|
+
* non-OK response, including the response body (truncated) when present.
|
|
1776
|
+
*/
|
|
1777
|
+
memberActivation(params) {
|
|
1778
|
+
return __async(this, null, function* () {
|
|
1779
|
+
const url = new URL(`${this.baseUrl}/api/reports/member-activation`);
|
|
1780
|
+
if (params == null ? void 0 : params.employerId) {
|
|
1781
|
+
url.searchParams.set("employerId", params.employerId);
|
|
1782
|
+
}
|
|
1783
|
+
const res = yield fetch(url.toString(), {
|
|
1784
|
+
method: "GET",
|
|
1785
|
+
// PHI (member activation report) — REQUIRE the user JWT. The server
|
|
1786
|
+
// hardens this route to `verifiedUserProcedure`, so degrading to
|
|
1787
|
+
// key-only would 401. `requireUserToken` retries across the Clerk-
|
|
1788
|
+
// hydration gap and throws rather than silently sending key-only.
|
|
1789
|
+
headers: yield buildAuthHeaders(this.auth, {
|
|
1790
|
+
requireUserToken: true
|
|
1791
|
+
})
|
|
1792
|
+
});
|
|
1793
|
+
if (!res.ok) {
|
|
1794
|
+
const text = yield res.text().catch(() => "");
|
|
1795
|
+
throw new ReportsError(
|
|
1796
|
+
"member-activation",
|
|
1797
|
+
res.status,
|
|
1798
|
+
text.slice(0, 200)
|
|
1799
|
+
);
|
|
1800
|
+
}
|
|
1801
|
+
return yield res.json();
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
|
|
1669
1806
|
// src/resources/tasks.ts
|
|
1670
1807
|
var TasksResource = class {
|
|
1671
1808
|
constructor(convexClient) {
|
|
@@ -1760,7 +1897,6 @@ var TranslationError = class extends Error {
|
|
|
1760
1897
|
var TranslationResource = class {
|
|
1761
1898
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1762
1899
|
this.baseUrl = apiBaseUrl;
|
|
1763
|
-
this.apiKey = apiKey;
|
|
1764
1900
|
this.auth = { apiKey, getAuthToken };
|
|
1765
1901
|
}
|
|
1766
1902
|
post(path, body) {
|
|
@@ -2066,6 +2202,14 @@ var CONVEX_URLS = {
|
|
|
2066
2202
|
production: "https://gallant-gecko-217.convex.cloud"
|
|
2067
2203
|
};
|
|
2068
2204
|
var TruthClient = class {
|
|
2205
|
+
/**
|
|
2206
|
+
* Builds the Convex client and event tracker from `config`, then wires up
|
|
2207
|
+
* every resource (patients, appointments, EHR proxy, reports, etc.) so
|
|
2208
|
+
* each shares the same Convex connection / API base URL / auth token
|
|
2209
|
+
* fetcher. When running in a browser that supports web push and the
|
|
2210
|
+
* caller hasn't opted out, kicks off best-effort service-worker
|
|
2211
|
+
* registration and push subscription in the background.
|
|
2212
|
+
*/
|
|
2069
2213
|
constructor(config) {
|
|
2070
2214
|
this._vapidPublicKey = null;
|
|
2071
2215
|
this._webPushReady = null;
|
|
@@ -2109,6 +2253,11 @@ var TruthClient = class {
|
|
|
2109
2253
|
this.convex,
|
|
2110
2254
|
config.getAuthToken
|
|
2111
2255
|
);
|
|
2256
|
+
this.reports = new ReportsResource(
|
|
2257
|
+
apiUrl,
|
|
2258
|
+
config.apiKey,
|
|
2259
|
+
config.getAuthToken
|
|
2260
|
+
);
|
|
2112
2261
|
this.notes = new NotesResource(apiUrl, config.apiKey, config.getAuthToken);
|
|
2113
2262
|
this.physicians = new PhysiciansResource(this.convex);
|
|
2114
2263
|
this.notifications = new NotificationsResource(
|
|
@@ -2129,9 +2278,11 @@ var TruthClient = class {
|
|
|
2129
2278
|
this._webPushReady = this.initWebPush();
|
|
2130
2279
|
}
|
|
2131
2280
|
}
|
|
2281
|
+
/** The VAPID public key fetched during web-push init, or `null` until `webPushReady` resolves (or if push is unsupported/disabled). */
|
|
2132
2282
|
get vapidPublicKey() {
|
|
2133
2283
|
return this._vapidPublicKey;
|
|
2134
2284
|
}
|
|
2285
|
+
/** Resolves once background web-push initialization (service worker registration + subscription) finishes; `null` if it was never started (SSR, unsupported browser, or opted out via config). */
|
|
2135
2286
|
get webPushReady() {
|
|
2136
2287
|
return this._webPushReady;
|
|
2137
2288
|
}
|
|
@@ -2158,6 +2309,14 @@ var TruthClient = class {
|
|
|
2158
2309
|
}
|
|
2159
2310
|
});
|
|
2160
2311
|
}
|
|
2312
|
+
/**
|
|
2313
|
+
* Best-effort web-push bootstrap: waits for auth (if configured), fetches
|
|
2314
|
+
* the VAPID key, registers the service worker, subscribes to push, and
|
|
2315
|
+
* registers the device with a placeholder `__pending__` userId (the
|
|
2316
|
+
* backend reconciles this once the real user is known). Any failure
|
|
2317
|
+
* along the way is swallowed — push notifications are opportunistic and
|
|
2318
|
+
* must never break client construction.
|
|
2319
|
+
*/
|
|
2161
2320
|
initWebPush() {
|
|
2162
2321
|
return __async(this, null, function* () {
|
|
2163
2322
|
try {
|
|
@@ -2486,7 +2645,9 @@ function TruthProvider({
|
|
|
2486
2645
|
for (let attempt = 0; attempt < 6; attempt++) {
|
|
2487
2646
|
try {
|
|
2488
2647
|
token = (_a2 = yield fetcher({ forceRefreshToken })) != null ? _a2 : null;
|
|
2489
|
-
if (token)
|
|
2648
|
+
if (token) {
|
|
2649
|
+
break;
|
|
2650
|
+
}
|
|
2490
2651
|
} catch (e) {
|
|
2491
2652
|
}
|
|
2492
2653
|
yield new Promise(
|
|
@@ -2674,6 +2835,7 @@ var listActiveRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents
|
|
|
2674
2835
|
var listForConversationRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:listForConversation");
|
|
2675
2836
|
var getByCallIdRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:getByCallId");
|
|
2676
2837
|
var listLogForCallIdRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:listLogForCallId");
|
|
2838
|
+
var setUserSummaryRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:setUserSummary");
|
|
2677
2839
|
var SKIP = "skip";
|
|
2678
2840
|
function toResult(value, skipped) {
|
|
2679
2841
|
if (skipped) {
|
|
@@ -2717,6 +2879,15 @@ function useDialpadCallLog(callId, options) {
|
|
|
2717
2879
|
);
|
|
2718
2880
|
return toResult(result, skipped);
|
|
2719
2881
|
}
|
|
2882
|
+
function useSaveCallSummary() {
|
|
2883
|
+
const mutate = (0, import_react4.useMutation)(
|
|
2884
|
+
setUserSummaryRef
|
|
2885
|
+
);
|
|
2886
|
+
return (0, import_react5.useCallback)(
|
|
2887
|
+
(callId, userSummary, updatedBy) => mutate({ callId, userSummary, updatedBy }),
|
|
2888
|
+
[mutate]
|
|
2889
|
+
);
|
|
2890
|
+
}
|
|
2720
2891
|
|
|
2721
2892
|
// src/react/conversation-by-id.ts
|
|
2722
2893
|
var import_server3 = require("convex/server");
|
|
@@ -2739,7 +2910,7 @@ function useConversationById(id) {
|
|
|
2739
2910
|
|
|
2740
2911
|
// src/react/conversations.ts
|
|
2741
2912
|
var import_server4 = require("convex/server");
|
|
2742
|
-
var
|
|
2913
|
+
var import_react6 = require("react");
|
|
2743
2914
|
var conversationsListForUserRef = (0, import_server4.makeFunctionReference)("conversations:listForUser");
|
|
2744
2915
|
var conversationsSearchForUserRef = (0, import_server4.makeFunctionReference)("conversations:searchForUser");
|
|
2745
2916
|
var conversationsGetUnreadTotalForUserRef = (0, import_server4.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
@@ -2826,7 +2997,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2826
2997
|
}
|
|
2827
2998
|
function useMemoizedPhones(phones) {
|
|
2828
2999
|
const key = phones ? [...phones].sort().join("|") : "";
|
|
2829
|
-
return (0,
|
|
3000
|
+
return (0, import_react6.useMemo)(
|
|
2830
3001
|
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
2831
3002
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2832
3003
|
[key]
|
|
@@ -2874,7 +3045,7 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
2874
3045
|
}
|
|
2875
3046
|
|
|
2876
3047
|
// src/react/hooks.ts
|
|
2877
|
-
var
|
|
3048
|
+
var import_react7 = require("react");
|
|
2878
3049
|
var import_server5 = require("convex/server");
|
|
2879
3050
|
var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
|
|
2880
3051
|
var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
|
|
@@ -2970,7 +3141,7 @@ function usePatientMedical(elationId, options) {
|
|
|
2970
3141
|
appointmentsByPatientRef,
|
|
2971
3142
|
id !== void 0 ? { elationPatientId: id } : "skip"
|
|
2972
3143
|
);
|
|
2973
|
-
(0,
|
|
3144
|
+
(0, import_react7.useEffect)(() => {
|
|
2974
3145
|
if (id === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2975
3146
|
return;
|
|
2976
3147
|
}
|
|
@@ -3010,7 +3181,7 @@ function usePatientBasic(input, options) {
|
|
|
3010
3181
|
hintPatientByIdRef,
|
|
3011
3182
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
3012
3183
|
);
|
|
3013
|
-
(0,
|
|
3184
|
+
(0, import_react7.useEffect)(() => {
|
|
3014
3185
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
3015
3186
|
return;
|
|
3016
3187
|
}
|
|
@@ -3067,7 +3238,7 @@ function usePatientPhoto(elationId, options) {
|
|
|
3067
3238
|
patientPhotoByIdRef,
|
|
3068
3239
|
id !== void 0 ? { elationPatientId: id } : "skip"
|
|
3069
3240
|
);
|
|
3070
|
-
(0,
|
|
3241
|
+
(0, import_react7.useEffect)(() => {
|
|
3071
3242
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
3072
3243
|
return;
|
|
3073
3244
|
}
|
|
@@ -3110,7 +3281,7 @@ function useConversationMessages(input, options) {
|
|
|
3110
3281
|
}
|
|
3111
3282
|
|
|
3112
3283
|
// src/react/notifications.ts
|
|
3113
|
-
var
|
|
3284
|
+
var import_react8 = require("react");
|
|
3114
3285
|
function loadExpo() {
|
|
3115
3286
|
return __async(this, null, function* () {
|
|
3116
3287
|
try {
|
|
@@ -3126,13 +3297,13 @@ function useNotifications(options) {
|
|
|
3126
3297
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3127
3298
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3128
3299
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
3129
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
3130
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
3131
|
-
const expoRef = (0,
|
|
3132
|
-
const isWebRef = (0,
|
|
3133
|
-
const vapidKeyRef = (0,
|
|
3134
|
-
const prevUserIdRef = (0,
|
|
3135
|
-
(0,
|
|
3300
|
+
const [permissionStatus, setPermissionStatus] = (0, import_react8.useState)("unknown");
|
|
3301
|
+
const [devicePushToken, setDevicePushToken] = (0, import_react8.useState)(null);
|
|
3302
|
+
const expoRef = (0, import_react8.useRef)(null);
|
|
3303
|
+
const isWebRef = (0, import_react8.useRef)(false);
|
|
3304
|
+
const vapidKeyRef = (0, import_react8.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
|
|
3305
|
+
const prevUserIdRef = (0, import_react8.useRef)(void 0);
|
|
3306
|
+
(0, import_react8.useEffect)(() => {
|
|
3136
3307
|
let mounted = true;
|
|
3137
3308
|
void (() => __async(null, null, function* () {
|
|
3138
3309
|
var _a2;
|
|
@@ -3188,7 +3359,7 @@ function useNotifications(options) {
|
|
|
3188
3359
|
mounted = false;
|
|
3189
3360
|
};
|
|
3190
3361
|
}, [apiBaseUrl, apiKey]);
|
|
3191
|
-
const register = (0,
|
|
3362
|
+
const register = (0, import_react8.useCallback)(() => __async(null, null, function* () {
|
|
3192
3363
|
var _a2, _b2;
|
|
3193
3364
|
if (!options.userId) {
|
|
3194
3365
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3311,7 +3482,7 @@ function useNotifications(options) {
|
|
|
3311
3482
|
options.appVersion,
|
|
3312
3483
|
options.serviceWorkerPath
|
|
3313
3484
|
]);
|
|
3314
|
-
const unregister = (0,
|
|
3485
|
+
const unregister = (0, import_react8.useCallback)(() => __async(null, null, function* () {
|
|
3315
3486
|
if (!devicePushToken) {
|
|
3316
3487
|
return;
|
|
3317
3488
|
}
|
|
@@ -3329,7 +3500,7 @@ function useNotifications(options) {
|
|
|
3329
3500
|
}
|
|
3330
3501
|
setDevicePushToken(null);
|
|
3331
3502
|
}), [apiBaseUrl, apiKey, getAuthToken, devicePushToken]);
|
|
3332
|
-
const addReceivedListener = (0,
|
|
3503
|
+
const addReceivedListener = (0, import_react8.useCallback)(
|
|
3333
3504
|
(listener) => {
|
|
3334
3505
|
if (isWebRef.current) {
|
|
3335
3506
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3358,7 +3529,7 @@ function useNotifications(options) {
|
|
|
3358
3529
|
},
|
|
3359
3530
|
[]
|
|
3360
3531
|
);
|
|
3361
|
-
const addResponseListener = (0,
|
|
3532
|
+
const addResponseListener = (0, import_react8.useCallback)(
|
|
3362
3533
|
(listener) => {
|
|
3363
3534
|
if (isWebRef.current) {
|
|
3364
3535
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3387,7 +3558,7 @@ function useNotifications(options) {
|
|
|
3387
3558
|
},
|
|
3388
3559
|
[]
|
|
3389
3560
|
);
|
|
3390
|
-
const getBadgeCount = (0,
|
|
3561
|
+
const getBadgeCount = (0, import_react8.useCallback)(() => __async(null, null, function* () {
|
|
3391
3562
|
var _a2;
|
|
3392
3563
|
const expo = expoRef.current;
|
|
3393
3564
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3395,7 +3566,7 @@ function useNotifications(options) {
|
|
|
3395
3566
|
}
|
|
3396
3567
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3397
3568
|
}), []);
|
|
3398
|
-
const setBadgeCount = (0,
|
|
3569
|
+
const setBadgeCount = (0, import_react8.useCallback)((count) => __async(null, null, function* () {
|
|
3399
3570
|
const expo = expoRef.current;
|
|
3400
3571
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3401
3572
|
return;
|
|
@@ -3403,7 +3574,7 @@ function useNotifications(options) {
|
|
|
3403
3574
|
yield expo.setBadgeCountAsync(count);
|
|
3404
3575
|
}), []);
|
|
3405
3576
|
const autoRegister = options.autoRegister !== false;
|
|
3406
|
-
(0,
|
|
3577
|
+
(0, import_react8.useEffect)(() => {
|
|
3407
3578
|
if (!autoRegister) {
|
|
3408
3579
|
return;
|
|
3409
3580
|
}
|
|
@@ -3442,7 +3613,7 @@ function useNotifications(options) {
|
|
|
3442
3613
|
remove == null ? void 0 : remove();
|
|
3443
3614
|
};
|
|
3444
3615
|
}, [autoRegister, options.userId, register]);
|
|
3445
|
-
(0,
|
|
3616
|
+
(0, import_react8.useEffect)(() => {
|
|
3446
3617
|
const prev = prevUserIdRef.current;
|
|
3447
3618
|
prevUserIdRef.current = options.userId;
|
|
3448
3619
|
if (!autoRegister) {
|
|
@@ -3453,7 +3624,7 @@ function useNotifications(options) {
|
|
|
3453
3624
|
}
|
|
3454
3625
|
void register();
|
|
3455
3626
|
}, [options.userId, autoRegister, register]);
|
|
3456
|
-
(0,
|
|
3627
|
+
(0, import_react8.useEffect)(() => {
|
|
3457
3628
|
if (!autoRegister) {
|
|
3458
3629
|
return;
|
|
3459
3630
|
}
|
|
@@ -3491,7 +3662,7 @@ function useNotificationsActions() {
|
|
|
3491
3662
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3492
3663
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3493
3664
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
3494
|
-
const post = (0,
|
|
3665
|
+
const post = (0, import_react8.useCallback)(
|
|
3495
3666
|
(path, body, opts) => __async(null, null, function* () {
|
|
3496
3667
|
if (!apiBaseUrl || !apiKey) {
|
|
3497
3668
|
throw new Error(
|
|
@@ -3521,7 +3692,7 @@ function useNotificationsActions() {
|
|
|
3521
3692
|
}),
|
|
3522
3693
|
[apiBaseUrl, apiKey, getAuthToken]
|
|
3523
3694
|
);
|
|
3524
|
-
const get = (0,
|
|
3695
|
+
const get = (0, import_react8.useCallback)(
|
|
3525
3696
|
(path, opts) => __async(null, null, function* () {
|
|
3526
3697
|
const headers = (opts == null ? void 0 : opts.requireUserToken) ? yield buildAuthHeaders(
|
|
3527
3698
|
{ apiKey, getAuthToken },
|
|
@@ -3541,22 +3712,22 @@ function useNotificationsActions() {
|
|
|
3541
3712
|
}),
|
|
3542
3713
|
[apiBaseUrl, apiKey, getAuthToken]
|
|
3543
3714
|
);
|
|
3544
|
-
const send = (0,
|
|
3715
|
+
const send = (0, import_react8.useCallback)(
|
|
3545
3716
|
(input) => post("/notifications/send", input),
|
|
3546
3717
|
[post]
|
|
3547
3718
|
);
|
|
3548
|
-
const schedule = (0,
|
|
3719
|
+
const schedule = (0, import_react8.useCallback)(
|
|
3549
3720
|
(input) => post("/notifications/schedule", input),
|
|
3550
3721
|
[post]
|
|
3551
3722
|
);
|
|
3552
|
-
const getPreferences = (0,
|
|
3723
|
+
const getPreferences = (0, import_react8.useCallback)(
|
|
3553
3724
|
(userId) => get(
|
|
3554
3725
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3555
3726
|
{ requireUserToken: true }
|
|
3556
3727
|
),
|
|
3557
3728
|
[get]
|
|
3558
3729
|
);
|
|
3559
|
-
const updatePreferences = (0,
|
|
3730
|
+
const updatePreferences = (0, import_react8.useCallback)(
|
|
3560
3731
|
(userId, prefs) => post(
|
|
3561
3732
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3562
3733
|
prefs,
|
|
@@ -3640,12 +3811,12 @@ function usePatientSearch(options) {
|
|
|
3640
3811
|
|
|
3641
3812
|
// src/react/patients-bulk.ts
|
|
3642
3813
|
var import_server8 = require("convex/server");
|
|
3643
|
-
var
|
|
3814
|
+
var import_react9 = require("react");
|
|
3644
3815
|
var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
|
|
3645
3816
|
var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
|
|
3646
3817
|
var SKIP5 = "skip";
|
|
3647
3818
|
function usePatientsByIds(ids) {
|
|
3648
|
-
const stableIds = (0,
|
|
3819
|
+
const stableIds = (0, import_react9.useMemo)(() => {
|
|
3649
3820
|
const arr = ids != null ? ids : [];
|
|
3650
3821
|
return [...new Set(arr)].sort();
|
|
3651
3822
|
}, [ids]);
|
|
@@ -3654,7 +3825,7 @@ function usePatientsByIds(ids) {
|
|
|
3654
3825
|
patientsGetByIdsRef,
|
|
3655
3826
|
skipped ? SKIP5 : { ids: stableIds }
|
|
3656
3827
|
);
|
|
3657
|
-
const mapped = (0,
|
|
3828
|
+
const mapped = (0, import_react9.useMemo)(() => {
|
|
3658
3829
|
if (result === void 0) {
|
|
3659
3830
|
return void 0;
|
|
3660
3831
|
}
|
|
@@ -3676,7 +3847,7 @@ function usePatientsByIds(ids) {
|
|
|
3676
3847
|
};
|
|
3677
3848
|
}
|
|
3678
3849
|
function usePatientsByPhones(phones) {
|
|
3679
|
-
const stableDigits = (0,
|
|
3850
|
+
const stableDigits = (0, import_react9.useMemo)(() => {
|
|
3680
3851
|
const arr = phones != null ? phones : [];
|
|
3681
3852
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3682
3853
|
return [...new Set(digits)].sort();
|
|
@@ -3686,7 +3857,7 @@ function usePatientsByPhones(phones) {
|
|
|
3686
3857
|
patientsGetByPhonesRef,
|
|
3687
3858
|
skipped ? SKIP5 : { phoneDigits: stableDigits }
|
|
3688
3859
|
);
|
|
3689
|
-
const mapped = (0,
|
|
3860
|
+
const mapped = (0, import_react9.useMemo)(() => {
|
|
3690
3861
|
if (result === void 0) {
|
|
3691
3862
|
return void 0;
|
|
3692
3863
|
}
|
|
@@ -3725,23 +3896,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3725
3896
|
}
|
|
3726
3897
|
|
|
3727
3898
|
// src/react/tasks.ts
|
|
3728
|
-
var
|
|
3899
|
+
var import_react10 = require("convex/react");
|
|
3729
3900
|
var import_server10 = require("convex/server");
|
|
3730
|
-
var
|
|
3901
|
+
var import_react11 = require("react");
|
|
3731
3902
|
var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
|
|
3732
3903
|
function useConversationTaskMarkSeen() {
|
|
3733
|
-
const mutate = (0,
|
|
3904
|
+
const mutate = (0, import_react10.useMutation)(
|
|
3734
3905
|
conversationTasksMarkSeenRef
|
|
3735
3906
|
);
|
|
3736
|
-
return (0,
|
|
3907
|
+
return (0, import_react11.useCallback)(
|
|
3737
3908
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3738
3909
|
[mutate]
|
|
3739
3910
|
);
|
|
3740
3911
|
}
|
|
3741
3912
|
|
|
3742
3913
|
// src/react/tracking.ts
|
|
3743
|
-
var
|
|
3744
|
-
var TruthTrackingContext = (0,
|
|
3914
|
+
var import_react12 = require("react");
|
|
3915
|
+
var TruthTrackingContext = (0, import_react12.createContext)(
|
|
3745
3916
|
null
|
|
3746
3917
|
);
|
|
3747
3918
|
function TruthTrackingProvider({
|
|
@@ -3754,7 +3925,7 @@ function TruthTrackingProvider({
|
|
|
3754
3925
|
}) {
|
|
3755
3926
|
var _a, _b;
|
|
3756
3927
|
const resolvedApiKey = (_b = apiKey != null ? apiKey : typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.EXPO_PUBLIC_TRUTH_API_KEY : void 0) != null ? _b : "";
|
|
3757
|
-
const value = (0,
|
|
3928
|
+
const value = (0, import_react12.useMemo)(() => {
|
|
3758
3929
|
const tracker = new Tracker({
|
|
3759
3930
|
apiKey: resolvedApiKey,
|
|
3760
3931
|
environment,
|
|
@@ -3773,10 +3944,10 @@ function TruthTrackingProvider({
|
|
|
3773
3944
|
}
|
|
3774
3945
|
};
|
|
3775
3946
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3776
|
-
return (0,
|
|
3947
|
+
return (0, import_react12.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3777
3948
|
}
|
|
3778
3949
|
function useTruth() {
|
|
3779
|
-
const ctx = (0,
|
|
3950
|
+
const ctx = (0, import_react12.useContext)(TruthTrackingContext);
|
|
3780
3951
|
if (!ctx) {
|
|
3781
3952
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3782
3953
|
}
|
|
@@ -3804,16 +3975,16 @@ function useUserSettings(userId) {
|
|
|
3804
3975
|
}
|
|
3805
3976
|
|
|
3806
3977
|
// src/react/users.ts
|
|
3807
|
-
var
|
|
3978
|
+
var import_react13 = require("react");
|
|
3808
3979
|
function useUserSync(input) {
|
|
3809
3980
|
var _a, _b, _c, _d;
|
|
3810
3981
|
const sdkContext = useTruthSdkContext();
|
|
3811
3982
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3812
3983
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3813
3984
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
3814
|
-
const [status, setStatus] = (0,
|
|
3815
|
-
const [error, setError] = (0,
|
|
3816
|
-
const lastKeyRef = (0,
|
|
3985
|
+
const [status, setStatus] = (0, import_react13.useState)("idle");
|
|
3986
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
3987
|
+
const lastKeyRef = (0, import_react13.useRef)(null);
|
|
3817
3988
|
const sync = () => __async(null, null, function* () {
|
|
3818
3989
|
if (!input.userId) {
|
|
3819
3990
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3857,7 +4028,7 @@ function useUserSync(input) {
|
|
|
3857
4028
|
return { ok: false, reason: message };
|
|
3858
4029
|
}
|
|
3859
4030
|
});
|
|
3860
|
-
(0,
|
|
4031
|
+
(0, import_react13.useEffect)(() => {
|
|
3861
4032
|
var _a2, _b2, _c2, _d2, _e;
|
|
3862
4033
|
if (!input.userId) {
|
|
3863
4034
|
return;
|
|
@@ -3896,13 +4067,13 @@ function useUserSync(input) {
|
|
|
3896
4067
|
}
|
|
3897
4068
|
|
|
3898
4069
|
// src/react/voicemail.ts
|
|
3899
|
-
var
|
|
4070
|
+
var import_react14 = require("react");
|
|
3900
4071
|
function useVoicemailUrl(client) {
|
|
3901
|
-
const [url, setUrl] = (0,
|
|
3902
|
-
const [isLoading, setIsLoading] = (0,
|
|
3903
|
-
const [error, setError] = (0,
|
|
3904
|
-
const inFlightRef = (0,
|
|
3905
|
-
const fetchUrl = (0,
|
|
4072
|
+
const [url, setUrl] = (0, import_react14.useState)(null);
|
|
4073
|
+
const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
|
|
4074
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
4075
|
+
const inFlightRef = (0, import_react14.useRef)(false);
|
|
4076
|
+
const fetchUrl = (0, import_react14.useCallback)(
|
|
3906
4077
|
(voicemailLink) => __async(null, null, function* () {
|
|
3907
4078
|
if (inFlightRef.current) {
|
|
3908
4079
|
return null;
|
|
@@ -3980,6 +4151,7 @@ function useVoicemailUrl(client) {
|
|
|
3980
4151
|
usePhysicianByElationId,
|
|
3981
4152
|
usePhysiciansByElationIds,
|
|
3982
4153
|
useRemindersForConversations,
|
|
4154
|
+
useSaveCallSummary,
|
|
3983
4155
|
useTruth,
|
|
3984
4156
|
useTruthClient,
|
|
3985
4157
|
useTruthSdkContext,
|