@hipnation-truth/sdk 0.26.3 → 0.26.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react.d.ts +12 -17
- package/dist/react.js +128 -99
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -591,23 +591,6 @@ interface UsePatientMedicalOptions {
|
|
|
591
591
|
*/
|
|
592
592
|
skipRefresh?: boolean;
|
|
593
593
|
}
|
|
594
|
-
/**
|
|
595
|
-
* Composite hook that returns a patient's medical records — medications,
|
|
596
|
-
* problems, allergies, appointments — from the Convex cache.
|
|
597
|
-
*
|
|
598
|
-
* On mount (and when `elationId` changes) fires a background refresh
|
|
599
|
-
* against Truth's `/api/patients/medical/refresh` endpoint so stale data
|
|
600
|
-
* is pulled in without blocking render. Returns cached data immediately;
|
|
601
|
-
* Convex subscription updates the UI when refresh completes.
|
|
602
|
-
*
|
|
603
|
-
* OFFLINE-READS POLICY: these medical-record queries ARE mirrored offline
|
|
604
|
-
* via `usePersistentQuery`, so medications, problems, allergies and
|
|
605
|
-
* appointments render from the at-rest mirror when the device is offline.
|
|
606
|
-
* Full medical records are the most sensitive PHI we hold, so they are
|
|
607
|
-
* only ever written to the encrypted-at-rest store (256-bit MMKV key held
|
|
608
|
-
* in the device keychain), never to any plaintext storage. Keep them on
|
|
609
|
-
* the encrypted mirror only — do not relax the store's encryption.
|
|
610
|
-
*/
|
|
611
594
|
declare function usePatientMedical(elationId: number | undefined, options?: UsePatientMedicalOptions): {
|
|
612
595
|
medications: unknown[] | undefined;
|
|
613
596
|
problems: unknown[] | undefined;
|
|
@@ -2771,6 +2754,13 @@ interface TruthSdkContextValue {
|
|
|
2771
2754
|
apiKey: string;
|
|
2772
2755
|
environment: string;
|
|
2773
2756
|
client: TruthClient;
|
|
2757
|
+
/**
|
|
2758
|
+
* Clerk token fetcher (template "convex"), if wired. Hooks that make their
|
|
2759
|
+
* own HTTP calls (e.g. the patient `…/refresh` endpoints) use this to attach
|
|
2760
|
+
* `Authorization: Bearer <jwt>` so they work under a publishable `hn_pk_*`
|
|
2761
|
+
* key, which the API gate accepts only with a verified user JWT.
|
|
2762
|
+
*/
|
|
2763
|
+
getAuthToken?: AuthTokenFetcher;
|
|
2774
2764
|
/** Injected offline mirror (or the Noop default on web / flag off). */
|
|
2775
2765
|
offlineStore: OfflineStore;
|
|
2776
2766
|
/** Whether the offline-reads layer is active for this provider. */
|
|
@@ -2784,6 +2774,11 @@ interface TruthSdkContextValue {
|
|
|
2784
2774
|
* (legacy behavior).
|
|
2785
2775
|
*/
|
|
2786
2776
|
authGated: boolean;
|
|
2777
|
+
/**
|
|
2778
|
+
* Whether Convex currently considers the caller authenticated (driven
|
|
2779
|
+
* by `setAuth`'s onChange). Only meaningful when `authGated` is true.
|
|
2780
|
+
*/
|
|
2781
|
+
authReady: boolean;
|
|
2787
2782
|
}
|
|
2788
2783
|
/**
|
|
2789
2784
|
* Read the Truth REST API base URL + API key + shared client from
|
package/dist/react.js
CHANGED
|
@@ -122,16 +122,13 @@ __export(react_exports, {
|
|
|
122
122
|
module.exports = __toCommonJS(react_exports);
|
|
123
123
|
|
|
124
124
|
// src/react/calls.ts
|
|
125
|
-
var
|
|
125
|
+
var import_react3 = require("convex/react");
|
|
126
126
|
var import_server2 = require("convex/server");
|
|
127
127
|
|
|
128
128
|
// src/react/offline/use-persistent-query.ts
|
|
129
129
|
var import_react_query3 = require("@convex-dev/react-query");
|
|
130
130
|
var import_react_query4 = require("@tanstack/react-query");
|
|
131
131
|
|
|
132
|
-
// src/react/queries-ready.ts
|
|
133
|
-
var import_react3 = require("convex/react");
|
|
134
|
-
|
|
135
132
|
// src/react/provider.ts
|
|
136
133
|
var import_react_query = require("@convex-dev/react-query");
|
|
137
134
|
var import_react_query2 = require("@tanstack/react-query");
|
|
@@ -2305,14 +2302,19 @@ function TruthProvider({
|
|
|
2305
2302
|
}) : void 0,
|
|
2306
2303
|
[hasAuthFetcher]
|
|
2307
2304
|
);
|
|
2305
|
+
const [convexAuthed, setConvexAuthed] = (0, import_react2.useState)(false);
|
|
2308
2306
|
(0, import_react2.useEffect)(() => {
|
|
2309
2307
|
if (stableGetAuthToken) {
|
|
2310
|
-
convexClient.setAuth(
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2308
|
+
convexClient.setAuth(
|
|
2309
|
+
() => __async(null, null, function* () {
|
|
2310
|
+
var _a2;
|
|
2311
|
+
return (_a2 = yield stableGetAuthToken()) != null ? _a2 : null;
|
|
2312
|
+
}),
|
|
2313
|
+
(isAuthenticated) => setConvexAuthed(isAuthenticated)
|
|
2314
|
+
);
|
|
2314
2315
|
} else {
|
|
2315
2316
|
convexClient.clearAuth();
|
|
2317
|
+
setConvexAuthed(false);
|
|
2316
2318
|
}
|
|
2317
2319
|
}, [convexClient, stableGetAuthToken]);
|
|
2318
2320
|
const convexQueryClient = (0, import_react2.useMemo)(
|
|
@@ -2388,7 +2390,9 @@ function TruthProvider({
|
|
|
2388
2390
|
client: truthClient,
|
|
2389
2391
|
offlineStore,
|
|
2390
2392
|
offlineEnabled,
|
|
2391
|
-
|
|
2393
|
+
getAuthToken: stableGetAuthToken,
|
|
2394
|
+
authGated: hasAuthFetcher,
|
|
2395
|
+
authReady: convexAuthed
|
|
2392
2396
|
}),
|
|
2393
2397
|
[
|
|
2394
2398
|
resolvedApiBaseUrl,
|
|
@@ -2397,7 +2401,9 @@ function TruthProvider({
|
|
|
2397
2401
|
truthClient,
|
|
2398
2402
|
offlineStore,
|
|
2399
2403
|
offlineEnabled,
|
|
2400
|
-
|
|
2404
|
+
stableGetAuthToken,
|
|
2405
|
+
hasAuthFetcher,
|
|
2406
|
+
convexAuthed
|
|
2401
2407
|
]
|
|
2402
2408
|
);
|
|
2403
2409
|
const convexTree = (0, import_react2.createElement)(
|
|
@@ -2428,10 +2434,11 @@ function TruthProvider({
|
|
|
2428
2434
|
|
|
2429
2435
|
// src/react/queries-ready.ts
|
|
2430
2436
|
function useConvexQueriesReady() {
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2437
|
+
const ctx = useTruthSdkContext();
|
|
2438
|
+
if (!(ctx == null ? void 0 : ctx.authGated)) {
|
|
2439
|
+
return true;
|
|
2440
|
+
}
|
|
2441
|
+
return ctx.authReady;
|
|
2435
2442
|
}
|
|
2436
2443
|
|
|
2437
2444
|
// src/react/offline/use-persistent-query.ts
|
|
@@ -2490,7 +2497,7 @@ function toResult(value, skipped) {
|
|
|
2490
2497
|
}
|
|
2491
2498
|
function useActiveCalls(options) {
|
|
2492
2499
|
const ready = useConvexQueriesReady();
|
|
2493
|
-
const result = (0,
|
|
2500
|
+
const result = (0, import_react3.useQuery)(listActiveRef, ready ? options != null ? options : {} : "skip");
|
|
2494
2501
|
return toResult(result, false);
|
|
2495
2502
|
}
|
|
2496
2503
|
function useDialpadCallsForConversation(conversationId, options) {
|
|
@@ -2542,7 +2549,7 @@ function useConversationById(id) {
|
|
|
2542
2549
|
|
|
2543
2550
|
// src/react/conversations.ts
|
|
2544
2551
|
var import_server4 = require("convex/server");
|
|
2545
|
-
var
|
|
2552
|
+
var import_react4 = require("react");
|
|
2546
2553
|
var conversationsListForUserRef = (0, import_server4.makeFunctionReference)("conversations:listForUser");
|
|
2547
2554
|
var conversationsSearchForUserRef = (0, import_server4.makeFunctionReference)("conversations:searchForUser");
|
|
2548
2555
|
var conversationsGetUnreadTotalForUserRef = (0, import_server4.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
@@ -2629,7 +2636,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2629
2636
|
}
|
|
2630
2637
|
function useMemoizedPhones(phones) {
|
|
2631
2638
|
const key = phones ? [...phones].sort().join("|") : "";
|
|
2632
|
-
return (0,
|
|
2639
|
+
return (0, import_react4.useMemo)(
|
|
2633
2640
|
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
2634
2641
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2635
2642
|
[key]
|
|
@@ -2677,7 +2684,7 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
2677
2684
|
}
|
|
2678
2685
|
|
|
2679
2686
|
// src/react/hooks.ts
|
|
2680
|
-
var
|
|
2687
|
+
var import_react5 = require("react");
|
|
2681
2688
|
var import_server5 = require("convex/server");
|
|
2682
2689
|
var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
|
|
2683
2690
|
var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
|
|
@@ -2734,11 +2741,33 @@ var medicationsByPatientRef = (0, import_server5.makeFunctionReference)("medical
|
|
|
2734
2741
|
var problemsByPatientRef = (0, import_server5.makeFunctionReference)("medicalRecords:getProblemsByElationPatient");
|
|
2735
2742
|
var allergiesByPatientRef = (0, import_server5.makeFunctionReference)("medicalRecords:getAllergiesByElationPatient");
|
|
2736
2743
|
var appointmentsByPatientRef = (0, import_server5.makeFunctionReference)("medicalRecords:getAppointmentsByElationPatient");
|
|
2744
|
+
function postPatientRefresh(url, apiKey, getAuthToken, body, signal) {
|
|
2745
|
+
return __async(this, null, function* () {
|
|
2746
|
+
const headers = {
|
|
2747
|
+
"Content-Type": "application/json",
|
|
2748
|
+
"X-API-Key": apiKey
|
|
2749
|
+
};
|
|
2750
|
+
try {
|
|
2751
|
+
const token = yield getAuthToken == null ? void 0 : getAuthToken();
|
|
2752
|
+
if (token) {
|
|
2753
|
+
headers.Authorization = `Bearer ${token}`;
|
|
2754
|
+
}
|
|
2755
|
+
} catch (e) {
|
|
2756
|
+
}
|
|
2757
|
+
yield fetch(url, {
|
|
2758
|
+
method: "POST",
|
|
2759
|
+
headers,
|
|
2760
|
+
body: JSON.stringify(body),
|
|
2761
|
+
signal
|
|
2762
|
+
});
|
|
2763
|
+
});
|
|
2764
|
+
}
|
|
2737
2765
|
function usePatientMedical(elationId, options) {
|
|
2738
2766
|
var _a, _b;
|
|
2739
2767
|
const sdkContext = useTruthSdkContext();
|
|
2740
2768
|
const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
|
|
2741
2769
|
const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
|
|
2770
|
+
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
2742
2771
|
const medications = usePersistentQuery(
|
|
2743
2772
|
medicationsByPatientRef,
|
|
2744
2773
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
@@ -2755,7 +2784,7 @@ function usePatientMedical(elationId, options) {
|
|
|
2755
2784
|
appointmentsByPatientRef,
|
|
2756
2785
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2757
2786
|
);
|
|
2758
|
-
(0,
|
|
2787
|
+
(0, import_react5.useEffect)(() => {
|
|
2759
2788
|
if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2760
2789
|
return;
|
|
2761
2790
|
}
|
|
@@ -2763,18 +2792,16 @@ function usePatientMedical(elationId, options) {
|
|
|
2763
2792
|
return;
|
|
2764
2793
|
}
|
|
2765
2794
|
const controller = new AbortController();
|
|
2766
|
-
void
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
signal: controller.signal
|
|
2774
|
-
}).catch(() => {
|
|
2795
|
+
void postPatientRefresh(
|
|
2796
|
+
`${apiBaseUrl}/api/patients/medical/refresh`,
|
|
2797
|
+
apiKey,
|
|
2798
|
+
getAuthToken,
|
|
2799
|
+
{ elationId },
|
|
2800
|
+
controller.signal
|
|
2801
|
+
).catch(() => {
|
|
2775
2802
|
});
|
|
2776
2803
|
return () => controller.abort();
|
|
2777
|
-
}, [elationId, apiBaseUrl, apiKey, options == null ? void 0 : options.skipRefresh]);
|
|
2804
|
+
}, [elationId, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
|
|
2778
2805
|
return { medications, problems, allergies, appointments };
|
|
2779
2806
|
}
|
|
2780
2807
|
var elationPatientByIdRef = (0, import_server5.makeFunctionReference)("elationPatients:getByElationId");
|
|
@@ -2786,6 +2813,7 @@ function usePatientBasic(input, options) {
|
|
|
2786
2813
|
const sdkContext = useTruthSdkContext();
|
|
2787
2814
|
const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
|
|
2788
2815
|
const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
|
|
2816
|
+
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
2789
2817
|
const elationRow = usePersistentQuery(
|
|
2790
2818
|
elationPatientByIdRef,
|
|
2791
2819
|
input.elationId !== void 0 ? { elationId: input.elationId } : "skip"
|
|
@@ -2794,7 +2822,7 @@ function usePatientBasic(input, options) {
|
|
|
2794
2822
|
hintPatientByIdRef,
|
|
2795
2823
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
2796
2824
|
);
|
|
2797
|
-
(0,
|
|
2825
|
+
(0, import_react5.useEffect)(() => {
|
|
2798
2826
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2799
2827
|
return;
|
|
2800
2828
|
}
|
|
@@ -2805,21 +2833,23 @@ function usePatientBasic(input, options) {
|
|
|
2805
2833
|
return;
|
|
2806
2834
|
}
|
|
2807
2835
|
const controller = new AbortController();
|
|
2808
|
-
void
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
hintId: input.hintId,
|
|
2816
|
-
elationId: input.elationId
|
|
2817
|
-
}),
|
|
2818
|
-
signal: controller.signal
|
|
2819
|
-
}).catch(() => {
|
|
2836
|
+
void postPatientRefresh(
|
|
2837
|
+
`${apiBaseUrl}/api/patients/basic/refresh`,
|
|
2838
|
+
apiKey,
|
|
2839
|
+
getAuthToken,
|
|
2840
|
+
{ hintId: input.hintId, elationId: input.elationId },
|
|
2841
|
+
controller.signal
|
|
2842
|
+
).catch(() => {
|
|
2820
2843
|
});
|
|
2821
2844
|
return () => controller.abort();
|
|
2822
|
-
}, [
|
|
2845
|
+
}, [
|
|
2846
|
+
input.hintId,
|
|
2847
|
+
input.elationId,
|
|
2848
|
+
apiBaseUrl,
|
|
2849
|
+
apiKey,
|
|
2850
|
+
getAuthToken,
|
|
2851
|
+
options == null ? void 0 : options.skipRefresh
|
|
2852
|
+
]);
|
|
2823
2853
|
const elationPatient = elationRow === void 0 ? void 0 : elationRow === null ? null : (_c = elationRow.raw) != null ? _c : null;
|
|
2824
2854
|
const hintPatient = hintRow === void 0 ? void 0 : hintRow === null ? null : (_d = hintRow.raw) != null ? _d : null;
|
|
2825
2855
|
const elationLoading = input.elationId !== void 0 && elationRow === void 0;
|
|
@@ -2843,11 +2873,12 @@ function usePatientPhoto(elationId, options) {
|
|
|
2843
2873
|
const sdkContext = useTruthSdkContext();
|
|
2844
2874
|
const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
|
|
2845
2875
|
const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
|
|
2876
|
+
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
2846
2877
|
const photo = usePersistentQuery(
|
|
2847
2878
|
patientPhotoByIdRef,
|
|
2848
2879
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2849
2880
|
);
|
|
2850
|
-
(0,
|
|
2881
|
+
(0, import_react5.useEffect)(() => {
|
|
2851
2882
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2852
2883
|
return;
|
|
2853
2884
|
}
|
|
@@ -2858,18 +2889,16 @@ function usePatientPhoto(elationId, options) {
|
|
|
2858
2889
|
return;
|
|
2859
2890
|
}
|
|
2860
2891
|
const controller = new AbortController();
|
|
2861
|
-
void
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
signal: controller.signal
|
|
2869
|
-
}).catch(() => {
|
|
2892
|
+
void postPatientRefresh(
|
|
2893
|
+
`${apiBaseUrl}/api/patients/photo/refresh`,
|
|
2894
|
+
apiKey,
|
|
2895
|
+
getAuthToken,
|
|
2896
|
+
{ elationId },
|
|
2897
|
+
controller.signal
|
|
2898
|
+
).catch(() => {
|
|
2870
2899
|
});
|
|
2871
2900
|
return () => controller.abort();
|
|
2872
|
-
}, [elationId, apiBaseUrl, apiKey, options == null ? void 0 : options.skipRefresh]);
|
|
2901
|
+
}, [elationId, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
|
|
2873
2902
|
return photo;
|
|
2874
2903
|
}
|
|
2875
2904
|
var messagesByPhonesRef = (0, import_server5.makeFunctionReference)("conversationMessages:getByPhones");
|
|
@@ -2892,7 +2921,7 @@ function useConversationMessages(input, options) {
|
|
|
2892
2921
|
}
|
|
2893
2922
|
|
|
2894
2923
|
// src/react/notifications.ts
|
|
2895
|
-
var
|
|
2924
|
+
var import_react6 = require("react");
|
|
2896
2925
|
function loadExpo() {
|
|
2897
2926
|
return __async(this, null, function* () {
|
|
2898
2927
|
try {
|
|
@@ -2907,12 +2936,12 @@ function useNotifications(options) {
|
|
|
2907
2936
|
const sdkContext = useTruthSdkContext();
|
|
2908
2937
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
2909
2938
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
2910
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
2911
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
2912
|
-
const expoRef = (0,
|
|
2913
|
-
const isWebRef = (0,
|
|
2914
|
-
const vapidKeyRef = (0,
|
|
2915
|
-
(0,
|
|
2939
|
+
const [permissionStatus, setPermissionStatus] = (0, import_react6.useState)("unknown");
|
|
2940
|
+
const [devicePushToken, setDevicePushToken] = (0, import_react6.useState)(null);
|
|
2941
|
+
const expoRef = (0, import_react6.useRef)(null);
|
|
2942
|
+
const isWebRef = (0, import_react6.useRef)(false);
|
|
2943
|
+
const vapidKeyRef = (0, import_react6.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
|
|
2944
|
+
(0, import_react6.useEffect)(() => {
|
|
2916
2945
|
let mounted = true;
|
|
2917
2946
|
void (() => __async(null, null, function* () {
|
|
2918
2947
|
var _a2;
|
|
@@ -2968,7 +2997,7 @@ function useNotifications(options) {
|
|
|
2968
2997
|
mounted = false;
|
|
2969
2998
|
};
|
|
2970
2999
|
}, [apiBaseUrl, apiKey]);
|
|
2971
|
-
const register = (0,
|
|
3000
|
+
const register = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
2972
3001
|
var _a2, _b2;
|
|
2973
3002
|
if (!options.userId) {
|
|
2974
3003
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3081,7 +3110,7 @@ function useNotifications(options) {
|
|
|
3081
3110
|
options.appVersion,
|
|
3082
3111
|
options.serviceWorkerPath
|
|
3083
3112
|
]);
|
|
3084
|
-
const unregister = (0,
|
|
3113
|
+
const unregister = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3085
3114
|
if (!devicePushToken) {
|
|
3086
3115
|
return;
|
|
3087
3116
|
}
|
|
@@ -3096,7 +3125,7 @@ function useNotifications(options) {
|
|
|
3096
3125
|
});
|
|
3097
3126
|
setDevicePushToken(null);
|
|
3098
3127
|
}), [apiBaseUrl, apiKey, devicePushToken]);
|
|
3099
|
-
const addReceivedListener = (0,
|
|
3128
|
+
const addReceivedListener = (0, import_react6.useCallback)(
|
|
3100
3129
|
(listener) => {
|
|
3101
3130
|
if (isWebRef.current) {
|
|
3102
3131
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3125,7 +3154,7 @@ function useNotifications(options) {
|
|
|
3125
3154
|
},
|
|
3126
3155
|
[]
|
|
3127
3156
|
);
|
|
3128
|
-
const addResponseListener = (0,
|
|
3157
|
+
const addResponseListener = (0, import_react6.useCallback)(
|
|
3129
3158
|
(listener) => {
|
|
3130
3159
|
if (isWebRef.current) {
|
|
3131
3160
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3154,7 +3183,7 @@ function useNotifications(options) {
|
|
|
3154
3183
|
},
|
|
3155
3184
|
[]
|
|
3156
3185
|
);
|
|
3157
|
-
const getBadgeCount = (0,
|
|
3186
|
+
const getBadgeCount = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3158
3187
|
var _a2;
|
|
3159
3188
|
const expo = expoRef.current;
|
|
3160
3189
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3162,7 +3191,7 @@ function useNotifications(options) {
|
|
|
3162
3191
|
}
|
|
3163
3192
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3164
3193
|
}), []);
|
|
3165
|
-
const setBadgeCount = (0,
|
|
3194
|
+
const setBadgeCount = (0, import_react6.useCallback)((count) => __async(null, null, function* () {
|
|
3166
3195
|
const expo = expoRef.current;
|
|
3167
3196
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3168
3197
|
return;
|
|
@@ -3170,7 +3199,7 @@ function useNotifications(options) {
|
|
|
3170
3199
|
yield expo.setBadgeCountAsync(count);
|
|
3171
3200
|
}), []);
|
|
3172
3201
|
const autoRegister = options.autoRegister !== false;
|
|
3173
|
-
(0,
|
|
3202
|
+
(0, import_react6.useEffect)(() => {
|
|
3174
3203
|
if (!autoRegister) {
|
|
3175
3204
|
return;
|
|
3176
3205
|
}
|
|
@@ -3207,7 +3236,7 @@ function useNotificationsActions() {
|
|
|
3207
3236
|
const sdkContext = useTruthSdkContext();
|
|
3208
3237
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3209
3238
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3210
|
-
const post = (0,
|
|
3239
|
+
const post = (0, import_react6.useCallback)(
|
|
3211
3240
|
(path, body) => __async(null, null, function* () {
|
|
3212
3241
|
if (!apiBaseUrl || !apiKey) {
|
|
3213
3242
|
throw new Error(
|
|
@@ -3233,7 +3262,7 @@ function useNotificationsActions() {
|
|
|
3233
3262
|
}),
|
|
3234
3263
|
[apiBaseUrl, apiKey]
|
|
3235
3264
|
);
|
|
3236
|
-
const get = (0,
|
|
3265
|
+
const get = (0, import_react6.useCallback)(
|
|
3237
3266
|
(path) => __async(null, null, function* () {
|
|
3238
3267
|
const res = yield fetch(`${apiBaseUrl}/api${path}`, {
|
|
3239
3268
|
method: "GET",
|
|
@@ -3249,21 +3278,21 @@ function useNotificationsActions() {
|
|
|
3249
3278
|
}),
|
|
3250
3279
|
[apiBaseUrl, apiKey]
|
|
3251
3280
|
);
|
|
3252
|
-
const send = (0,
|
|
3281
|
+
const send = (0, import_react6.useCallback)(
|
|
3253
3282
|
(input) => post("/notifications/send", input),
|
|
3254
3283
|
[post]
|
|
3255
3284
|
);
|
|
3256
|
-
const schedule = (0,
|
|
3285
|
+
const schedule = (0, import_react6.useCallback)(
|
|
3257
3286
|
(input) => post("/notifications/schedule", input),
|
|
3258
3287
|
[post]
|
|
3259
3288
|
);
|
|
3260
|
-
const getPreferences = (0,
|
|
3289
|
+
const getPreferences = (0, import_react6.useCallback)(
|
|
3261
3290
|
(userId) => get(
|
|
3262
3291
|
`/notifications/preferences/${encodeURIComponent(userId)}`
|
|
3263
3292
|
),
|
|
3264
3293
|
[get]
|
|
3265
3294
|
);
|
|
3266
|
-
const updatePreferences = (0,
|
|
3295
|
+
const updatePreferences = (0, import_react6.useCallback)(
|
|
3267
3296
|
(userId, prefs) => post(
|
|
3268
3297
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3269
3298
|
prefs
|
|
@@ -3346,12 +3375,12 @@ function usePatientSearch(options) {
|
|
|
3346
3375
|
|
|
3347
3376
|
// src/react/patients-bulk.ts
|
|
3348
3377
|
var import_server8 = require("convex/server");
|
|
3349
|
-
var
|
|
3378
|
+
var import_react7 = require("react");
|
|
3350
3379
|
var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
|
|
3351
3380
|
var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
|
|
3352
3381
|
var SKIP5 = "skip";
|
|
3353
3382
|
function usePatientsByIds(ids) {
|
|
3354
|
-
const stableIds = (0,
|
|
3383
|
+
const stableIds = (0, import_react7.useMemo)(() => {
|
|
3355
3384
|
const arr = ids != null ? ids : [];
|
|
3356
3385
|
return [...new Set(arr)].sort();
|
|
3357
3386
|
}, [ids]);
|
|
@@ -3360,7 +3389,7 @@ function usePatientsByIds(ids) {
|
|
|
3360
3389
|
patientsGetByIdsRef,
|
|
3361
3390
|
skipped ? SKIP5 : { ids: stableIds }
|
|
3362
3391
|
);
|
|
3363
|
-
const mapped = (0,
|
|
3392
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3364
3393
|
if (result === void 0) {
|
|
3365
3394
|
return void 0;
|
|
3366
3395
|
}
|
|
@@ -3382,7 +3411,7 @@ function usePatientsByIds(ids) {
|
|
|
3382
3411
|
};
|
|
3383
3412
|
}
|
|
3384
3413
|
function usePatientsByPhones(phones) {
|
|
3385
|
-
const stableDigits = (0,
|
|
3414
|
+
const stableDigits = (0, import_react7.useMemo)(() => {
|
|
3386
3415
|
const arr = phones != null ? phones : [];
|
|
3387
3416
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3388
3417
|
return [...new Set(digits)].sort();
|
|
@@ -3392,7 +3421,7 @@ function usePatientsByPhones(phones) {
|
|
|
3392
3421
|
patientsGetByPhonesRef,
|
|
3393
3422
|
skipped ? SKIP5 : { phoneDigits: stableDigits }
|
|
3394
3423
|
);
|
|
3395
|
-
const mapped = (0,
|
|
3424
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3396
3425
|
if (result === void 0) {
|
|
3397
3426
|
return void 0;
|
|
3398
3427
|
}
|
|
@@ -3431,23 +3460,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3431
3460
|
}
|
|
3432
3461
|
|
|
3433
3462
|
// src/react/tasks.ts
|
|
3434
|
-
var
|
|
3463
|
+
var import_react8 = require("convex/react");
|
|
3435
3464
|
var import_server10 = require("convex/server");
|
|
3436
|
-
var
|
|
3465
|
+
var import_react9 = require("react");
|
|
3437
3466
|
var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
|
|
3438
3467
|
function useConversationTaskMarkSeen() {
|
|
3439
|
-
const mutate = (0,
|
|
3468
|
+
const mutate = (0, import_react8.useMutation)(
|
|
3440
3469
|
conversationTasksMarkSeenRef
|
|
3441
3470
|
);
|
|
3442
|
-
return (0,
|
|
3471
|
+
return (0, import_react9.useCallback)(
|
|
3443
3472
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3444
3473
|
[mutate]
|
|
3445
3474
|
);
|
|
3446
3475
|
}
|
|
3447
3476
|
|
|
3448
3477
|
// src/react/tracking.ts
|
|
3449
|
-
var
|
|
3450
|
-
var TruthTrackingContext = (0,
|
|
3478
|
+
var import_react10 = require("react");
|
|
3479
|
+
var TruthTrackingContext = (0, import_react10.createContext)(
|
|
3451
3480
|
null
|
|
3452
3481
|
);
|
|
3453
3482
|
function TruthTrackingProvider({
|
|
@@ -3460,7 +3489,7 @@ function TruthTrackingProvider({
|
|
|
3460
3489
|
}) {
|
|
3461
3490
|
var _a, _b;
|
|
3462
3491
|
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 : "";
|
|
3463
|
-
const value = (0,
|
|
3492
|
+
const value = (0, import_react10.useMemo)(() => {
|
|
3464
3493
|
const tracker = new Tracker({
|
|
3465
3494
|
apiKey: resolvedApiKey,
|
|
3466
3495
|
environment,
|
|
@@ -3479,10 +3508,10 @@ function TruthTrackingProvider({
|
|
|
3479
3508
|
}
|
|
3480
3509
|
};
|
|
3481
3510
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3482
|
-
return (0,
|
|
3511
|
+
return (0, import_react10.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3483
3512
|
}
|
|
3484
3513
|
function useTruth() {
|
|
3485
|
-
const ctx = (0,
|
|
3514
|
+
const ctx = (0, import_react10.useContext)(TruthTrackingContext);
|
|
3486
3515
|
if (!ctx) {
|
|
3487
3516
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3488
3517
|
}
|
|
@@ -3510,15 +3539,15 @@ function useUserSettings(userId) {
|
|
|
3510
3539
|
}
|
|
3511
3540
|
|
|
3512
3541
|
// src/react/users.ts
|
|
3513
|
-
var
|
|
3542
|
+
var import_react11 = require("react");
|
|
3514
3543
|
function useUserSync(input) {
|
|
3515
3544
|
var _a, _b, _c, _d;
|
|
3516
3545
|
const sdkContext = useTruthSdkContext();
|
|
3517
3546
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3518
3547
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3519
|
-
const [status, setStatus] = (0,
|
|
3520
|
-
const [error, setError] = (0,
|
|
3521
|
-
const lastKeyRef = (0,
|
|
3548
|
+
const [status, setStatus] = (0, import_react11.useState)("idle");
|
|
3549
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
3550
|
+
const lastKeyRef = (0, import_react11.useRef)(null);
|
|
3522
3551
|
const sync = () => __async(null, null, function* () {
|
|
3523
3552
|
if (!input.userId) {
|
|
3524
3553
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3561,7 +3590,7 @@ function useUserSync(input) {
|
|
|
3561
3590
|
return { ok: false, reason: message };
|
|
3562
3591
|
}
|
|
3563
3592
|
});
|
|
3564
|
-
(0,
|
|
3593
|
+
(0, import_react11.useEffect)(() => {
|
|
3565
3594
|
var _a2, _b2, _c2, _d2, _e;
|
|
3566
3595
|
if (!input.userId) {
|
|
3567
3596
|
return;
|
|
@@ -3600,13 +3629,13 @@ function useUserSync(input) {
|
|
|
3600
3629
|
}
|
|
3601
3630
|
|
|
3602
3631
|
// src/react/voicemail.ts
|
|
3603
|
-
var
|
|
3632
|
+
var import_react12 = require("react");
|
|
3604
3633
|
function useVoicemailUrl(client) {
|
|
3605
|
-
const [url, setUrl] = (0,
|
|
3606
|
-
const [isLoading, setIsLoading] = (0,
|
|
3607
|
-
const [error, setError] = (0,
|
|
3608
|
-
const inFlightRef = (0,
|
|
3609
|
-
const fetchUrl = (0,
|
|
3634
|
+
const [url, setUrl] = (0, import_react12.useState)(null);
|
|
3635
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
3636
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
3637
|
+
const inFlightRef = (0, import_react12.useRef)(false);
|
|
3638
|
+
const fetchUrl = (0, import_react12.useCallback)(
|
|
3610
3639
|
(voicemailLink) => __async(null, null, function* () {
|
|
3611
3640
|
if (inFlightRef.current) {
|
|
3612
3641
|
return null;
|