@hipnation-truth/sdk 0.26.8 → 0.26.10
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 +6 -5
- package/dist/react.js +103 -82
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -2779,13 +2779,14 @@ interface TruthSdkContextValue {
|
|
|
2779
2779
|
* signed-out render throws UNAUTHENTICATED and blanks the app. When no
|
|
2780
2780
|
* fetcher is configured this stays false and queries run unconditionally
|
|
2781
2781
|
* (legacy behavior).
|
|
2782
|
+
*
|
|
2783
|
+
* The "is the caller authenticated yet" half of the gate is no longer
|
|
2784
|
+
* tracked here: `<TruthProvider>` now mounts `ConvexProviderWithAuth`,
|
|
2785
|
+
* so `useConvexQueriesReady()` reads Convex's own server-acknowledged
|
|
2786
|
+
* `useConvexAuth().isAuthenticated`. `authGated` only answers "should we
|
|
2787
|
+
* gate at all", which still depends on whether a fetcher was supplied.
|
|
2782
2788
|
*/
|
|
2783
2789
|
authGated: boolean;
|
|
2784
|
-
/**
|
|
2785
|
-
* Whether Convex currently considers the caller authenticated (driven
|
|
2786
|
-
* by `setAuth`'s onChange). Only meaningful when `authGated` is true.
|
|
2787
|
-
*/
|
|
2788
|
-
authReady: boolean;
|
|
2789
2790
|
}
|
|
2790
2791
|
/**
|
|
2791
2792
|
* Read the Truth REST API base URL + API key + shared client from
|
package/dist/react.js
CHANGED
|
@@ -128,6 +128,9 @@ var import_server2 = require("convex/server");
|
|
|
128
128
|
var import_react_query3 = require("@convex-dev/react-query");
|
|
129
129
|
var import_react_query4 = require("@tanstack/react-query");
|
|
130
130
|
|
|
131
|
+
// src/react/queries-ready.ts
|
|
132
|
+
var import_react3 = require("convex/react");
|
|
133
|
+
|
|
131
134
|
// src/react/provider.ts
|
|
132
135
|
var import_react_query = require("@convex-dev/react-query");
|
|
133
136
|
var import_react_query2 = require("@tanstack/react-query");
|
|
@@ -2290,10 +2293,16 @@ function TruthProvider({
|
|
|
2290
2293
|
const url = resolveConvexUrl(environment, convexUrl);
|
|
2291
2294
|
const resolvedApiBaseUrl = (_a = apiBaseUrl != null ? apiBaseUrl : readEnv("EXPO_PUBLIC_TRUTH_API_BASE_URL")) != null ? _a : resolveApiBaseUrl(environment);
|
|
2292
2295
|
const resolvedApiKey = (_b = apiKey != null ? apiKey : readEnv("EXPO_PUBLIC_TRUTH_API_KEY")) != null ? _b : "";
|
|
2293
|
-
const
|
|
2296
|
+
const hasAuthFetcher = Boolean(getAuthToken);
|
|
2297
|
+
const convexClient = (0, import_react2.useMemo)(
|
|
2298
|
+
() => new import_react.ConvexReactClient(
|
|
2299
|
+
url,
|
|
2300
|
+
hasAuthFetcher ? { expectAuth: true } : void 0
|
|
2301
|
+
),
|
|
2302
|
+
[url, hasAuthFetcher]
|
|
2303
|
+
);
|
|
2294
2304
|
const getAuthTokenRef = (0, import_react2.useRef)(getAuthToken);
|
|
2295
2305
|
getAuthTokenRef.current = getAuthToken;
|
|
2296
|
-
const hasAuthFetcher = Boolean(getAuthToken);
|
|
2297
2306
|
const stableGetAuthToken = (0, import_react2.useMemo)(
|
|
2298
2307
|
() => hasAuthFetcher ? (opts) => __async(null, null, function* () {
|
|
2299
2308
|
var _a2, _b2;
|
|
@@ -2301,29 +2310,42 @@ function TruthProvider({
|
|
|
2301
2310
|
}) : void 0,
|
|
2302
2311
|
[hasAuthFetcher]
|
|
2303
2312
|
);
|
|
2304
|
-
const [
|
|
2313
|
+
const [tokenAttempted, setTokenAttempted] = (0, import_react2.useState)(false);
|
|
2305
2314
|
(0, import_react2.useEffect)(() => {
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2315
|
+
setTokenAttempted(false);
|
|
2316
|
+
}, [stableGetAuthToken]);
|
|
2317
|
+
const fetchAccessToken = (0, import_react2.useCallback)(
|
|
2318
|
+
(_0) => __async(null, [_0], function* ({
|
|
2319
|
+
forceRefreshToken
|
|
2320
|
+
}) {
|
|
2321
|
+
var _a2;
|
|
2322
|
+
const fetcher = stableGetAuthToken;
|
|
2323
|
+
if (!fetcher) {
|
|
2324
|
+
setTokenAttempted(true);
|
|
2325
|
+
return null;
|
|
2326
|
+
}
|
|
2327
|
+
let token = null;
|
|
2312
2328
|
for (let attempt = 0; attempt < 6; attempt++) {
|
|
2313
2329
|
try {
|
|
2314
|
-
|
|
2315
|
-
if (token)
|
|
2330
|
+
token = (_a2 = yield fetcher({ forceRefreshToken })) != null ? _a2 : null;
|
|
2331
|
+
if (token) break;
|
|
2316
2332
|
} catch (e) {
|
|
2317
2333
|
}
|
|
2318
2334
|
yield new Promise((resolve) => setTimeout(resolve, 200 + attempt * 150));
|
|
2319
2335
|
}
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2336
|
+
setTokenAttempted(true);
|
|
2337
|
+
return token;
|
|
2338
|
+
}),
|
|
2339
|
+
[stableGetAuthToken]
|
|
2340
|
+
);
|
|
2341
|
+
const useConvexAuthAdapter = (0, import_react2.useCallback)(
|
|
2342
|
+
() => ({
|
|
2343
|
+
isLoading: hasAuthFetcher && !tokenAttempted,
|
|
2344
|
+
isAuthenticated: hasAuthFetcher,
|
|
2345
|
+
fetchAccessToken
|
|
2346
|
+
}),
|
|
2347
|
+
[hasAuthFetcher, tokenAttempted, fetchAccessToken]
|
|
2348
|
+
);
|
|
2327
2349
|
const convexQueryClient = (0, import_react2.useMemo)(
|
|
2328
2350
|
() => new import_react_query.ConvexQueryClient(convexClient),
|
|
2329
2351
|
[convexClient]
|
|
@@ -2398,8 +2420,7 @@ function TruthProvider({
|
|
|
2398
2420
|
offlineStore,
|
|
2399
2421
|
offlineEnabled,
|
|
2400
2422
|
getAuthToken: stableGetAuthToken,
|
|
2401
|
-
authGated: hasAuthFetcher
|
|
2402
|
-
authReady: convexAuthed
|
|
2423
|
+
authGated: hasAuthFetcher
|
|
2403
2424
|
}),
|
|
2404
2425
|
[
|
|
2405
2426
|
resolvedApiBaseUrl,
|
|
@@ -2409,15 +2430,9 @@ function TruthProvider({
|
|
|
2409
2430
|
offlineStore,
|
|
2410
2431
|
offlineEnabled,
|
|
2411
2432
|
stableGetAuthToken,
|
|
2412
|
-
hasAuthFetcher
|
|
2413
|
-
convexAuthed
|
|
2433
|
+
hasAuthFetcher
|
|
2414
2434
|
]
|
|
2415
2435
|
);
|
|
2416
|
-
const convexTree = (0, import_react2.createElement)(
|
|
2417
|
-
import_react.ConvexProvider,
|
|
2418
|
-
{ client: convexClient },
|
|
2419
|
-
children
|
|
2420
|
-
);
|
|
2421
2436
|
const queryTree = persister ? (0, import_react2.createElement)(
|
|
2422
2437
|
import_react_query_persist_client.PersistQueryClientProvider,
|
|
2423
2438
|
{
|
|
@@ -2430,22 +2445,28 @@ function TruthProvider({
|
|
|
2430
2445
|
buster: String(SCHEMA_VERSION)
|
|
2431
2446
|
}
|
|
2432
2447
|
},
|
|
2433
|
-
|
|
2434
|
-
) : (0, import_react2.createElement)(import_react_query2.QueryClientProvider, { client: queryClient },
|
|
2448
|
+
children
|
|
2449
|
+
) : (0, import_react2.createElement)(import_react_query2.QueryClientProvider, { client: queryClient }, children);
|
|
2450
|
+
const authedTree = (0, import_react2.createElement)(
|
|
2451
|
+
import_react.ConvexProviderWithAuth,
|
|
2452
|
+
{ client: convexClient, useAuth: useConvexAuthAdapter },
|
|
2453
|
+
queryTree
|
|
2454
|
+
);
|
|
2435
2455
|
return (0, import_react2.createElement)(
|
|
2436
2456
|
TruthSdkContext.Provider,
|
|
2437
2457
|
{ value: sdkContext },
|
|
2438
|
-
|
|
2458
|
+
authedTree
|
|
2439
2459
|
);
|
|
2440
2460
|
}
|
|
2441
2461
|
|
|
2442
2462
|
// src/react/queries-ready.ts
|
|
2443
2463
|
function useConvexQueriesReady() {
|
|
2444
2464
|
const ctx = useTruthSdkContext();
|
|
2465
|
+
const { isAuthenticated } = (0, import_react3.useConvexAuth)();
|
|
2445
2466
|
if (!(ctx == null ? void 0 : ctx.authGated)) {
|
|
2446
2467
|
return true;
|
|
2447
2468
|
}
|
|
2448
|
-
return
|
|
2469
|
+
return isAuthenticated;
|
|
2449
2470
|
}
|
|
2450
2471
|
|
|
2451
2472
|
// src/react/offline/use-persistent-query.ts
|
|
@@ -2556,7 +2577,7 @@ function useConversationById(id) {
|
|
|
2556
2577
|
|
|
2557
2578
|
// src/react/conversations.ts
|
|
2558
2579
|
var import_server4 = require("convex/server");
|
|
2559
|
-
var
|
|
2580
|
+
var import_react4 = require("react");
|
|
2560
2581
|
var conversationsListForUserRef = (0, import_server4.makeFunctionReference)("conversations:listForUser");
|
|
2561
2582
|
var conversationsSearchForUserRef = (0, import_server4.makeFunctionReference)("conversations:searchForUser");
|
|
2562
2583
|
var conversationsGetUnreadTotalForUserRef = (0, import_server4.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
@@ -2643,7 +2664,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2643
2664
|
}
|
|
2644
2665
|
function useMemoizedPhones(phones) {
|
|
2645
2666
|
const key = phones ? [...phones].sort().join("|") : "";
|
|
2646
|
-
return (0,
|
|
2667
|
+
return (0, import_react4.useMemo)(
|
|
2647
2668
|
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
2648
2669
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2649
2670
|
[key]
|
|
@@ -2691,7 +2712,7 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
2691
2712
|
}
|
|
2692
2713
|
|
|
2693
2714
|
// src/react/hooks.ts
|
|
2694
|
-
var
|
|
2715
|
+
var import_react5 = require("react");
|
|
2695
2716
|
var import_server5 = require("convex/server");
|
|
2696
2717
|
var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
|
|
2697
2718
|
var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
|
|
@@ -2791,7 +2812,7 @@ function usePatientMedical(elationId, options) {
|
|
|
2791
2812
|
appointmentsByPatientRef,
|
|
2792
2813
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2793
2814
|
);
|
|
2794
|
-
(0,
|
|
2815
|
+
(0, import_react5.useEffect)(() => {
|
|
2795
2816
|
if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2796
2817
|
return;
|
|
2797
2818
|
}
|
|
@@ -2829,7 +2850,7 @@ function usePatientBasic(input, options) {
|
|
|
2829
2850
|
hintPatientByIdRef,
|
|
2830
2851
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
2831
2852
|
);
|
|
2832
|
-
(0,
|
|
2853
|
+
(0, import_react5.useEffect)(() => {
|
|
2833
2854
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2834
2855
|
return;
|
|
2835
2856
|
}
|
|
@@ -2885,7 +2906,7 @@ function usePatientPhoto(elationId, options) {
|
|
|
2885
2906
|
patientPhotoByIdRef,
|
|
2886
2907
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2887
2908
|
);
|
|
2888
|
-
(0,
|
|
2909
|
+
(0, import_react5.useEffect)(() => {
|
|
2889
2910
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2890
2911
|
return;
|
|
2891
2912
|
}
|
|
@@ -2928,7 +2949,7 @@ function useConversationMessages(input, options) {
|
|
|
2928
2949
|
}
|
|
2929
2950
|
|
|
2930
2951
|
// src/react/notifications.ts
|
|
2931
|
-
var
|
|
2952
|
+
var import_react6 = require("react");
|
|
2932
2953
|
function loadExpo() {
|
|
2933
2954
|
return __async(this, null, function* () {
|
|
2934
2955
|
try {
|
|
@@ -2943,12 +2964,12 @@ function useNotifications(options) {
|
|
|
2943
2964
|
const sdkContext = useTruthSdkContext();
|
|
2944
2965
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
2945
2966
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
2946
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
2947
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
2948
|
-
const expoRef = (0,
|
|
2949
|
-
const isWebRef = (0,
|
|
2950
|
-
const vapidKeyRef = (0,
|
|
2951
|
-
(0,
|
|
2967
|
+
const [permissionStatus, setPermissionStatus] = (0, import_react6.useState)("unknown");
|
|
2968
|
+
const [devicePushToken, setDevicePushToken] = (0, import_react6.useState)(null);
|
|
2969
|
+
const expoRef = (0, import_react6.useRef)(null);
|
|
2970
|
+
const isWebRef = (0, import_react6.useRef)(false);
|
|
2971
|
+
const vapidKeyRef = (0, import_react6.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
|
|
2972
|
+
(0, import_react6.useEffect)(() => {
|
|
2952
2973
|
let mounted = true;
|
|
2953
2974
|
void (() => __async(null, null, function* () {
|
|
2954
2975
|
var _a2;
|
|
@@ -3004,7 +3025,7 @@ function useNotifications(options) {
|
|
|
3004
3025
|
mounted = false;
|
|
3005
3026
|
};
|
|
3006
3027
|
}, [apiBaseUrl, apiKey]);
|
|
3007
|
-
const register = (0,
|
|
3028
|
+
const register = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3008
3029
|
var _a2, _b2;
|
|
3009
3030
|
if (!options.userId) {
|
|
3010
3031
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3117,7 +3138,7 @@ function useNotifications(options) {
|
|
|
3117
3138
|
options.appVersion,
|
|
3118
3139
|
options.serviceWorkerPath
|
|
3119
3140
|
]);
|
|
3120
|
-
const unregister = (0,
|
|
3141
|
+
const unregister = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3121
3142
|
if (!devicePushToken) {
|
|
3122
3143
|
return;
|
|
3123
3144
|
}
|
|
@@ -3132,7 +3153,7 @@ function useNotifications(options) {
|
|
|
3132
3153
|
});
|
|
3133
3154
|
setDevicePushToken(null);
|
|
3134
3155
|
}), [apiBaseUrl, apiKey, devicePushToken]);
|
|
3135
|
-
const addReceivedListener = (0,
|
|
3156
|
+
const addReceivedListener = (0, import_react6.useCallback)(
|
|
3136
3157
|
(listener) => {
|
|
3137
3158
|
if (isWebRef.current) {
|
|
3138
3159
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3161,7 +3182,7 @@ function useNotifications(options) {
|
|
|
3161
3182
|
},
|
|
3162
3183
|
[]
|
|
3163
3184
|
);
|
|
3164
|
-
const addResponseListener = (0,
|
|
3185
|
+
const addResponseListener = (0, import_react6.useCallback)(
|
|
3165
3186
|
(listener) => {
|
|
3166
3187
|
if (isWebRef.current) {
|
|
3167
3188
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3190,7 +3211,7 @@ function useNotifications(options) {
|
|
|
3190
3211
|
},
|
|
3191
3212
|
[]
|
|
3192
3213
|
);
|
|
3193
|
-
const getBadgeCount = (0,
|
|
3214
|
+
const getBadgeCount = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
3194
3215
|
var _a2;
|
|
3195
3216
|
const expo = expoRef.current;
|
|
3196
3217
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3198,7 +3219,7 @@ function useNotifications(options) {
|
|
|
3198
3219
|
}
|
|
3199
3220
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3200
3221
|
}), []);
|
|
3201
|
-
const setBadgeCount = (0,
|
|
3222
|
+
const setBadgeCount = (0, import_react6.useCallback)((count) => __async(null, null, function* () {
|
|
3202
3223
|
const expo = expoRef.current;
|
|
3203
3224
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3204
3225
|
return;
|
|
@@ -3206,7 +3227,7 @@ function useNotifications(options) {
|
|
|
3206
3227
|
yield expo.setBadgeCountAsync(count);
|
|
3207
3228
|
}), []);
|
|
3208
3229
|
const autoRegister = options.autoRegister !== false;
|
|
3209
|
-
(0,
|
|
3230
|
+
(0, import_react6.useEffect)(() => {
|
|
3210
3231
|
if (!autoRegister) {
|
|
3211
3232
|
return;
|
|
3212
3233
|
}
|
|
@@ -3243,7 +3264,7 @@ function useNotificationsActions() {
|
|
|
3243
3264
|
const sdkContext = useTruthSdkContext();
|
|
3244
3265
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3245
3266
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3246
|
-
const post = (0,
|
|
3267
|
+
const post = (0, import_react6.useCallback)(
|
|
3247
3268
|
(path, body) => __async(null, null, function* () {
|
|
3248
3269
|
if (!apiBaseUrl || !apiKey) {
|
|
3249
3270
|
throw new Error(
|
|
@@ -3269,7 +3290,7 @@ function useNotificationsActions() {
|
|
|
3269
3290
|
}),
|
|
3270
3291
|
[apiBaseUrl, apiKey]
|
|
3271
3292
|
);
|
|
3272
|
-
const get = (0,
|
|
3293
|
+
const get = (0, import_react6.useCallback)(
|
|
3273
3294
|
(path) => __async(null, null, function* () {
|
|
3274
3295
|
const res = yield fetch(`${apiBaseUrl}/api${path}`, {
|
|
3275
3296
|
method: "GET",
|
|
@@ -3285,21 +3306,21 @@ function useNotificationsActions() {
|
|
|
3285
3306
|
}),
|
|
3286
3307
|
[apiBaseUrl, apiKey]
|
|
3287
3308
|
);
|
|
3288
|
-
const send = (0,
|
|
3309
|
+
const send = (0, import_react6.useCallback)(
|
|
3289
3310
|
(input) => post("/notifications/send", input),
|
|
3290
3311
|
[post]
|
|
3291
3312
|
);
|
|
3292
|
-
const schedule = (0,
|
|
3313
|
+
const schedule = (0, import_react6.useCallback)(
|
|
3293
3314
|
(input) => post("/notifications/schedule", input),
|
|
3294
3315
|
[post]
|
|
3295
3316
|
);
|
|
3296
|
-
const getPreferences = (0,
|
|
3317
|
+
const getPreferences = (0, import_react6.useCallback)(
|
|
3297
3318
|
(userId) => get(
|
|
3298
3319
|
`/notifications/preferences/${encodeURIComponent(userId)}`
|
|
3299
3320
|
),
|
|
3300
3321
|
[get]
|
|
3301
3322
|
);
|
|
3302
|
-
const updatePreferences = (0,
|
|
3323
|
+
const updatePreferences = (0, import_react6.useCallback)(
|
|
3303
3324
|
(userId, prefs) => post(
|
|
3304
3325
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3305
3326
|
prefs
|
|
@@ -3382,12 +3403,12 @@ function usePatientSearch(options) {
|
|
|
3382
3403
|
|
|
3383
3404
|
// src/react/patients-bulk.ts
|
|
3384
3405
|
var import_server8 = require("convex/server");
|
|
3385
|
-
var
|
|
3406
|
+
var import_react7 = require("react");
|
|
3386
3407
|
var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
|
|
3387
3408
|
var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
|
|
3388
3409
|
var SKIP5 = "skip";
|
|
3389
3410
|
function usePatientsByIds(ids) {
|
|
3390
|
-
const stableIds = (0,
|
|
3411
|
+
const stableIds = (0, import_react7.useMemo)(() => {
|
|
3391
3412
|
const arr = ids != null ? ids : [];
|
|
3392
3413
|
return [...new Set(arr)].sort();
|
|
3393
3414
|
}, [ids]);
|
|
@@ -3396,7 +3417,7 @@ function usePatientsByIds(ids) {
|
|
|
3396
3417
|
patientsGetByIdsRef,
|
|
3397
3418
|
skipped ? SKIP5 : { ids: stableIds }
|
|
3398
3419
|
);
|
|
3399
|
-
const mapped = (0,
|
|
3420
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3400
3421
|
if (result === void 0) {
|
|
3401
3422
|
return void 0;
|
|
3402
3423
|
}
|
|
@@ -3418,7 +3439,7 @@ function usePatientsByIds(ids) {
|
|
|
3418
3439
|
};
|
|
3419
3440
|
}
|
|
3420
3441
|
function usePatientsByPhones(phones) {
|
|
3421
|
-
const stableDigits = (0,
|
|
3442
|
+
const stableDigits = (0, import_react7.useMemo)(() => {
|
|
3422
3443
|
const arr = phones != null ? phones : [];
|
|
3423
3444
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3424
3445
|
return [...new Set(digits)].sort();
|
|
@@ -3428,7 +3449,7 @@ function usePatientsByPhones(phones) {
|
|
|
3428
3449
|
patientsGetByPhonesRef,
|
|
3429
3450
|
skipped ? SKIP5 : { phoneDigits: stableDigits }
|
|
3430
3451
|
);
|
|
3431
|
-
const mapped = (0,
|
|
3452
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3432
3453
|
if (result === void 0) {
|
|
3433
3454
|
return void 0;
|
|
3434
3455
|
}
|
|
@@ -3467,23 +3488,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3467
3488
|
}
|
|
3468
3489
|
|
|
3469
3490
|
// src/react/tasks.ts
|
|
3470
|
-
var
|
|
3491
|
+
var import_react8 = require("convex/react");
|
|
3471
3492
|
var import_server10 = require("convex/server");
|
|
3472
|
-
var
|
|
3493
|
+
var import_react9 = require("react");
|
|
3473
3494
|
var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
|
|
3474
3495
|
function useConversationTaskMarkSeen() {
|
|
3475
|
-
const mutate = (0,
|
|
3496
|
+
const mutate = (0, import_react8.useMutation)(
|
|
3476
3497
|
conversationTasksMarkSeenRef
|
|
3477
3498
|
);
|
|
3478
|
-
return (0,
|
|
3499
|
+
return (0, import_react9.useCallback)(
|
|
3479
3500
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3480
3501
|
[mutate]
|
|
3481
3502
|
);
|
|
3482
3503
|
}
|
|
3483
3504
|
|
|
3484
3505
|
// src/react/tracking.ts
|
|
3485
|
-
var
|
|
3486
|
-
var TruthTrackingContext = (0,
|
|
3506
|
+
var import_react10 = require("react");
|
|
3507
|
+
var TruthTrackingContext = (0, import_react10.createContext)(
|
|
3487
3508
|
null
|
|
3488
3509
|
);
|
|
3489
3510
|
function TruthTrackingProvider({
|
|
@@ -3496,7 +3517,7 @@ function TruthTrackingProvider({
|
|
|
3496
3517
|
}) {
|
|
3497
3518
|
var _a, _b;
|
|
3498
3519
|
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 : "";
|
|
3499
|
-
const value = (0,
|
|
3520
|
+
const value = (0, import_react10.useMemo)(() => {
|
|
3500
3521
|
const tracker = new Tracker({
|
|
3501
3522
|
apiKey: resolvedApiKey,
|
|
3502
3523
|
environment,
|
|
@@ -3515,10 +3536,10 @@ function TruthTrackingProvider({
|
|
|
3515
3536
|
}
|
|
3516
3537
|
};
|
|
3517
3538
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3518
|
-
return (0,
|
|
3539
|
+
return (0, import_react10.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3519
3540
|
}
|
|
3520
3541
|
function useTruth() {
|
|
3521
|
-
const ctx = (0,
|
|
3542
|
+
const ctx = (0, import_react10.useContext)(TruthTrackingContext);
|
|
3522
3543
|
if (!ctx) {
|
|
3523
3544
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3524
3545
|
}
|
|
@@ -3546,15 +3567,15 @@ function useUserSettings(userId) {
|
|
|
3546
3567
|
}
|
|
3547
3568
|
|
|
3548
3569
|
// src/react/users.ts
|
|
3549
|
-
var
|
|
3570
|
+
var import_react11 = require("react");
|
|
3550
3571
|
function useUserSync(input) {
|
|
3551
3572
|
var _a, _b, _c, _d;
|
|
3552
3573
|
const sdkContext = useTruthSdkContext();
|
|
3553
3574
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3554
3575
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3555
|
-
const [status, setStatus] = (0,
|
|
3556
|
-
const [error, setError] = (0,
|
|
3557
|
-
const lastKeyRef = (0,
|
|
3576
|
+
const [status, setStatus] = (0, import_react11.useState)("idle");
|
|
3577
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
3578
|
+
const lastKeyRef = (0, import_react11.useRef)(null);
|
|
3558
3579
|
const sync = () => __async(null, null, function* () {
|
|
3559
3580
|
if (!input.userId) {
|
|
3560
3581
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3597,7 +3618,7 @@ function useUserSync(input) {
|
|
|
3597
3618
|
return { ok: false, reason: message };
|
|
3598
3619
|
}
|
|
3599
3620
|
});
|
|
3600
|
-
(0,
|
|
3621
|
+
(0, import_react11.useEffect)(() => {
|
|
3601
3622
|
var _a2, _b2, _c2, _d2, _e;
|
|
3602
3623
|
if (!input.userId) {
|
|
3603
3624
|
return;
|
|
@@ -3636,13 +3657,13 @@ function useUserSync(input) {
|
|
|
3636
3657
|
}
|
|
3637
3658
|
|
|
3638
3659
|
// src/react/voicemail.ts
|
|
3639
|
-
var
|
|
3660
|
+
var import_react12 = require("react");
|
|
3640
3661
|
function useVoicemailUrl(client) {
|
|
3641
|
-
const [url, setUrl] = (0,
|
|
3642
|
-
const [isLoading, setIsLoading] = (0,
|
|
3643
|
-
const [error, setError] = (0,
|
|
3644
|
-
const inFlightRef = (0,
|
|
3645
|
-
const fetchUrl = (0,
|
|
3662
|
+
const [url, setUrl] = (0, import_react12.useState)(null);
|
|
3663
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
3664
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
3665
|
+
const inFlightRef = (0, import_react12.useRef)(false);
|
|
3666
|
+
const fetchUrl = (0, import_react12.useCallback)(
|
|
3646
3667
|
(voicemailLink) => __async(null, null, function* () {
|
|
3647
3668
|
if (inFlightRef.current) {
|
|
3648
3669
|
return null;
|