@hipnation-truth/sdk 0.23.2 → 0.24.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 +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +134 -2
- package/dist/react.js +287 -116
- package/dist/react.js.map +1 -1
- package/package.json +16 -1
package/dist/react.js
CHANGED
|
@@ -61,11 +61,13 @@ __export(react_exports, {
|
|
|
61
61
|
CONNECTED_CALL_STATES: () => CONNECTED_CALL_STATES,
|
|
62
62
|
CONVEX_URLS: () => CONVEX_URLS2,
|
|
63
63
|
DialpadCallState: () => DialpadCallState,
|
|
64
|
+
NoopStore: () => NoopStore,
|
|
64
65
|
RINGING_CALL_STATES: () => RINGING_CALL_STATES,
|
|
65
66
|
TERMINAL_CALL_STATES: () => TERMINAL_CALL_STATES,
|
|
66
67
|
TruthProvider: () => TruthProvider,
|
|
67
68
|
TruthTrackingProvider: () => TruthTrackingProvider,
|
|
68
69
|
getTruthClient: () => getTruthClient,
|
|
70
|
+
readPersistedSavedAt: () => readPersistedSavedAt,
|
|
69
71
|
resolveApiBaseUrl: () => resolveApiBaseUrl,
|
|
70
72
|
resolveConvexUrl: () => resolveConvexUrl,
|
|
71
73
|
useActiveCalls: () => useActiveCalls,
|
|
@@ -88,6 +90,8 @@ __export(react_exports, {
|
|
|
88
90
|
useMessages: () => useMessages,
|
|
89
91
|
useNotifications: () => useNotifications,
|
|
90
92
|
useNotificationsActions: () => useNotificationsActions,
|
|
93
|
+
useOfflineEnabled: () => useOfflineEnabled,
|
|
94
|
+
useOfflineStore: () => useOfflineStore,
|
|
91
95
|
usePatient: () => usePatient,
|
|
92
96
|
usePatientBasic: () => usePatientBasic,
|
|
93
97
|
usePatientByElationId: () => usePatientByElationId,
|
|
@@ -117,6 +121,21 @@ module.exports = __toCommonJS(react_exports);
|
|
|
117
121
|
// src/react/calls.ts
|
|
118
122
|
var import_react = require("convex/react");
|
|
119
123
|
var import_server = require("convex/server");
|
|
124
|
+
|
|
125
|
+
// src/react/offline/use-persistent-query.ts
|
|
126
|
+
var import_react_query = require("@convex-dev/react-query");
|
|
127
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
128
|
+
function usePersistentQuery(ref, args) {
|
|
129
|
+
const { data } = (0, import_react_query2.useQuery)(
|
|
130
|
+
(0, import_react_query.convexQuery)(
|
|
131
|
+
ref,
|
|
132
|
+
args
|
|
133
|
+
)
|
|
134
|
+
);
|
|
135
|
+
return data;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/react/calls.ts
|
|
120
139
|
var DialpadCallState = {
|
|
121
140
|
Calling: "calling",
|
|
122
141
|
Ringing: "ringing",
|
|
@@ -163,7 +182,7 @@ function useActiveCalls(options) {
|
|
|
163
182
|
}
|
|
164
183
|
function useDialpadCallsForConversation(conversationId, options) {
|
|
165
184
|
const skipped = !conversationId;
|
|
166
|
-
const result = (
|
|
185
|
+
const result = usePersistentQuery(
|
|
167
186
|
listForConversationRef,
|
|
168
187
|
skipped ? SKIP : {
|
|
169
188
|
conversationId,
|
|
@@ -174,7 +193,7 @@ function useDialpadCallsForConversation(conversationId, options) {
|
|
|
174
193
|
}
|
|
175
194
|
function useDialpadCallByCallId(callId) {
|
|
176
195
|
const skipped = !callId;
|
|
177
|
-
const result = (
|
|
196
|
+
const result = usePersistentQuery(
|
|
178
197
|
getByCallIdRef,
|
|
179
198
|
skipped ? SKIP : { callId }
|
|
180
199
|
);
|
|
@@ -182,7 +201,7 @@ function useDialpadCallByCallId(callId) {
|
|
|
182
201
|
}
|
|
183
202
|
function useDialpadCallLog(callId, options) {
|
|
184
203
|
const skipped = !callId;
|
|
185
|
-
const result = (
|
|
204
|
+
const result = usePersistentQuery(
|
|
186
205
|
listLogForCallIdRef,
|
|
187
206
|
skipped ? SKIP : { callId, limit: options == null ? void 0 : options.limit }
|
|
188
207
|
);
|
|
@@ -190,12 +209,11 @@ function useDialpadCallLog(callId, options) {
|
|
|
190
209
|
}
|
|
191
210
|
|
|
192
211
|
// src/react/conversation-by-id.ts
|
|
193
|
-
var import_react2 = require("convex/react");
|
|
194
212
|
var import_server2 = require("convex/server");
|
|
195
213
|
var conversationsGetByIdRef = (0, import_server2.makeFunctionReference)("conversations:getById");
|
|
196
214
|
function useConversationById(id) {
|
|
197
215
|
const skipped = !id;
|
|
198
|
-
const result = (
|
|
216
|
+
const result = usePersistentQuery(
|
|
199
217
|
conversationsGetByIdRef,
|
|
200
218
|
skipped ? "skip" : { id }
|
|
201
219
|
);
|
|
@@ -210,9 +228,8 @@ function useConversationById(id) {
|
|
|
210
228
|
}
|
|
211
229
|
|
|
212
230
|
// src/react/conversations.ts
|
|
213
|
-
var import_react3 = require("convex/react");
|
|
214
231
|
var import_server3 = require("convex/server");
|
|
215
|
-
var
|
|
232
|
+
var import_react2 = require("react");
|
|
216
233
|
var conversationsListForUserRef = (0, import_server3.makeFunctionReference)("conversations:listForUser");
|
|
217
234
|
var conversationsSearchForUserRef = (0, import_server3.makeFunctionReference)("conversations:searchForUser");
|
|
218
235
|
var conversationsGetUnreadTotalForUserRef = (0, import_server3.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
@@ -240,14 +257,14 @@ function useConversations(filters) {
|
|
|
240
257
|
const trimmedSearch = (_b = (_a = filters.search) == null ? void 0 : _a.trim()) != null ? _b : "";
|
|
241
258
|
const isSearchMode = trimmedSearch.length > 0;
|
|
242
259
|
const skipped = !filters.userId;
|
|
243
|
-
const listResult = (
|
|
260
|
+
const listResult = usePersistentQuery(
|
|
244
261
|
conversationsListForUserRef,
|
|
245
262
|
skipped || isSearchMode ? SKIP2 : {
|
|
246
263
|
userId: filters.userId,
|
|
247
264
|
limit: filters.limit
|
|
248
265
|
}
|
|
249
266
|
);
|
|
250
|
-
const searchResult = (
|
|
267
|
+
const searchResult = usePersistentQuery(
|
|
251
268
|
conversationsSearchForUserRef,
|
|
252
269
|
skipped || !isSearchMode ? SKIP2 : {
|
|
253
270
|
userId: filters.userId,
|
|
@@ -259,7 +276,7 @@ function useConversations(filters) {
|
|
|
259
276
|
}
|
|
260
277
|
function useConversationByPhonePair(phonePair) {
|
|
261
278
|
const skipped = !phonePair;
|
|
262
|
-
const result = (
|
|
279
|
+
const result = usePersistentQuery(
|
|
263
280
|
conversationsGetByPhonePairRef,
|
|
264
281
|
skipped ? SKIP2 : { phonePair }
|
|
265
282
|
);
|
|
@@ -267,7 +284,7 @@ function useConversationByPhonePair(phonePair) {
|
|
|
267
284
|
}
|
|
268
285
|
function useMessages(conversationId, options) {
|
|
269
286
|
const skipped = !conversationId;
|
|
270
|
-
const result = (
|
|
287
|
+
const result = usePersistentQuery(
|
|
271
288
|
conversationMessagesGetByConversationIdRef,
|
|
272
289
|
skipped ? SKIP2 : {
|
|
273
290
|
conversationId,
|
|
@@ -278,7 +295,7 @@ function useMessages(conversationId, options) {
|
|
|
278
295
|
}
|
|
279
296
|
function useUnreadCount(userId) {
|
|
280
297
|
const skipped = !userId;
|
|
281
|
-
const result = (
|
|
298
|
+
const result = usePersistentQuery(
|
|
282
299
|
conversationsGetUnreadTotalForUserRef,
|
|
283
300
|
skipped ? SKIP2 : { userId }
|
|
284
301
|
);
|
|
@@ -288,7 +305,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
288
305
|
const skipped = !userId;
|
|
289
306
|
const phones = options == null ? void 0 : options.providerPhones;
|
|
290
307
|
const stablePhones = useMemoizedPhones(phones);
|
|
291
|
-
const result = (
|
|
308
|
+
const result = usePersistentQuery(
|
|
292
309
|
conversationsGetUnreadAggregateForUserRef,
|
|
293
310
|
skipped ? SKIP2 : {
|
|
294
311
|
userId,
|
|
@@ -299,7 +316,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
299
316
|
}
|
|
300
317
|
function useMemoizedPhones(phones) {
|
|
301
318
|
const key = phones ? [...phones].sort().join("|") : "";
|
|
302
|
-
return (0,
|
|
319
|
+
return (0, import_react2.useMemo)(
|
|
303
320
|
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
304
321
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
305
322
|
[key]
|
|
@@ -307,7 +324,7 @@ function useMemoizedPhones(phones) {
|
|
|
307
324
|
}
|
|
308
325
|
function useConversationNotes(conversationId) {
|
|
309
326
|
const skipped = !conversationId;
|
|
310
|
-
const result = (
|
|
327
|
+
const result = usePersistentQuery(
|
|
311
328
|
conversationNotesListForConversationRef,
|
|
312
329
|
skipped ? SKIP2 : { conversationId }
|
|
313
330
|
);
|
|
@@ -315,7 +332,7 @@ function useConversationNotes(conversationId) {
|
|
|
315
332
|
}
|
|
316
333
|
function useConversationTasks(conversationId) {
|
|
317
334
|
const skipped = !conversationId;
|
|
318
|
-
const result = (
|
|
335
|
+
const result = usePersistentQuery(
|
|
319
336
|
conversationTasksListForConversationRef,
|
|
320
337
|
skipped ? SKIP2 : { conversationId }
|
|
321
338
|
);
|
|
@@ -323,7 +340,7 @@ function useConversationTasks(conversationId) {
|
|
|
323
340
|
}
|
|
324
341
|
function useConversationNotesByPhonePair(phonePair) {
|
|
325
342
|
const skipped = !phonePair;
|
|
326
|
-
const result = (
|
|
343
|
+
const result = usePersistentQuery(
|
|
327
344
|
conversationNotesListByPhonePairRef,
|
|
328
345
|
skipped ? SKIP2 : { phonePair }
|
|
329
346
|
);
|
|
@@ -331,7 +348,7 @@ function useConversationNotesByPhonePair(phonePair) {
|
|
|
331
348
|
}
|
|
332
349
|
function useConversationTasksForUser(userId, options) {
|
|
333
350
|
const skipped = !userId;
|
|
334
|
-
const result = (
|
|
351
|
+
const result = usePersistentQuery(
|
|
335
352
|
conversationTasksListForUserRef,
|
|
336
353
|
skipped ? SKIP2 : { userId, limit: options == null ? void 0 : options.limit }
|
|
337
354
|
);
|
|
@@ -339,7 +356,7 @@ function useConversationTasksForUser(userId, options) {
|
|
|
339
356
|
}
|
|
340
357
|
function useConversationTasksByPhonePair(phonePair) {
|
|
341
358
|
const skipped = !phonePair;
|
|
342
|
-
const result = (
|
|
359
|
+
const result = usePersistentQuery(
|
|
343
360
|
conversationTasksListByPhonePairRef,
|
|
344
361
|
skipped ? SKIP2 : { phonePair }
|
|
345
362
|
);
|
|
@@ -347,12 +364,14 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
347
364
|
}
|
|
348
365
|
|
|
349
366
|
// src/react/hooks.ts
|
|
350
|
-
var
|
|
351
|
-
var import_react8 = require("react");
|
|
367
|
+
var import_react5 = require("react");
|
|
352
368
|
|
|
353
369
|
// src/react/provider.ts
|
|
354
|
-
var
|
|
355
|
-
var
|
|
370
|
+
var import_react_query3 = require("@convex-dev/react-query");
|
|
371
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
372
|
+
var import_react_query_persist_client = require("@tanstack/react-query-persist-client");
|
|
373
|
+
var import_react3 = require("convex/react");
|
|
374
|
+
var import_react4 = require("react");
|
|
356
375
|
|
|
357
376
|
// src/client.ts
|
|
358
377
|
var import_browser = require("convex/browser");
|
|
@@ -603,10 +622,22 @@ var ConversationTasksSubresource = class {
|
|
|
603
622
|
return __async(this, null, function* () {
|
|
604
623
|
return this.post(
|
|
605
624
|
`/conversations/tasks/${encodeURIComponent(input.taskId)}/status`,
|
|
606
|
-
__spreadValues({
|
|
625
|
+
__spreadValues(__spreadValues({
|
|
607
626
|
id: input.taskId,
|
|
608
627
|
status: input.status
|
|
609
|
-
}, input.resolvedBy ? { resolvedBy: input.resolvedBy } : {})
|
|
628
|
+
}, input.resolvedBy ? { resolvedBy: input.resolvedBy } : {}), input.actor ? { actor: input.actor } : {})
|
|
629
|
+
);
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
/** Archive or un-archive a task (hides it from My Tasks without deleting). */
|
|
633
|
+
setArchived(input) {
|
|
634
|
+
return __async(this, null, function* () {
|
|
635
|
+
return this.post(
|
|
636
|
+
`/conversations/tasks/${encodeURIComponent(input.taskId)}/archive`,
|
|
637
|
+
__spreadValues({
|
|
638
|
+
id: input.taskId,
|
|
639
|
+
archived: input.archived
|
|
640
|
+
}, input.actor ? { actor: input.actor } : {})
|
|
610
641
|
);
|
|
611
642
|
});
|
|
612
643
|
}
|
|
@@ -619,12 +650,12 @@ var ConversationTasksSubresource = class {
|
|
|
619
650
|
return __async(this, null, function* () {
|
|
620
651
|
return this.patch(
|
|
621
652
|
`/conversations/tasks/${encodeURIComponent(input.taskId)}`,
|
|
622
|
-
__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
653
|
+
__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
623
654
|
id: input.taskId,
|
|
624
655
|
conversationId: input.conversationId,
|
|
625
656
|
author: input.author,
|
|
626
657
|
description: input.description
|
|
627
|
-
}, input.title !== void 0 ? { title: input.title } : {}), input.priority ? { priority: input.priority } : {}), input.status ? { status: input.status } : {}), input.assignee !== void 0 ? { assignee: input.assignee } : {}), input.type !== void 0 ? { type: input.type } : {})
|
|
658
|
+
}, input.title !== void 0 ? { title: input.title } : {}), input.priority ? { priority: input.priority } : {}), input.status ? { status: input.status } : {}), input.assignee !== void 0 ? { assignee: input.assignee } : {}), input.type !== void 0 ? { type: input.type } : {}), input.actor ? { actor: input.actor } : {})
|
|
628
659
|
);
|
|
629
660
|
});
|
|
630
661
|
}
|
|
@@ -2311,7 +2342,81 @@ var TruthClient = class {
|
|
|
2311
2342
|
}
|
|
2312
2343
|
};
|
|
2313
2344
|
|
|
2345
|
+
// src/react/offline/envelope.ts
|
|
2346
|
+
var SCHEMA_VERSION = 1;
|
|
2347
|
+
|
|
2348
|
+
// src/react/offline/persister.ts
|
|
2349
|
+
var PERSIST_CACHE_KEY = "truth-offline:tanstack-cache";
|
|
2350
|
+
function isPersistedClient(value) {
|
|
2351
|
+
if (typeof value !== "object" || value === null) {
|
|
2352
|
+
return false;
|
|
2353
|
+
}
|
|
2354
|
+
const candidate = value;
|
|
2355
|
+
return typeof candidate.timestamp === "number" && Number.isFinite(candidate.timestamp) && typeof candidate.clientState === "object" && candidate.clientState !== null;
|
|
2356
|
+
}
|
|
2357
|
+
function createOfflinePersister(store, cacheKey = PERSIST_CACHE_KEY) {
|
|
2358
|
+
return {
|
|
2359
|
+
persistClient(client) {
|
|
2360
|
+
try {
|
|
2361
|
+
store.set(cacheKey, JSON.stringify(client));
|
|
2362
|
+
} catch (e) {
|
|
2363
|
+
}
|
|
2364
|
+
},
|
|
2365
|
+
restoreClient() {
|
|
2366
|
+
try {
|
|
2367
|
+
const raw = store.get(cacheKey);
|
|
2368
|
+
if (raw == null) {
|
|
2369
|
+
return void 0;
|
|
2370
|
+
}
|
|
2371
|
+
const parsed = JSON.parse(raw);
|
|
2372
|
+
if (!isPersistedClient(parsed)) {
|
|
2373
|
+
return void 0;
|
|
2374
|
+
}
|
|
2375
|
+
return parsed;
|
|
2376
|
+
} catch (e) {
|
|
2377
|
+
return void 0;
|
|
2378
|
+
}
|
|
2379
|
+
},
|
|
2380
|
+
removeClient() {
|
|
2381
|
+
try {
|
|
2382
|
+
store.delete(cacheKey);
|
|
2383
|
+
} catch (e) {
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2387
|
+
}
|
|
2388
|
+
function readPersistedSavedAt(store, cacheKey = PERSIST_CACHE_KEY) {
|
|
2389
|
+
try {
|
|
2390
|
+
const raw = store.get(cacheKey);
|
|
2391
|
+
if (raw == null) {
|
|
2392
|
+
return null;
|
|
2393
|
+
}
|
|
2394
|
+
const parsed = JSON.parse(raw);
|
|
2395
|
+
return typeof parsed.timestamp === "number" ? parsed.timestamp : null;
|
|
2396
|
+
} catch (e) {
|
|
2397
|
+
return null;
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
// src/react/offline/store.ts
|
|
2402
|
+
var NoopStore = class {
|
|
2403
|
+
get() {
|
|
2404
|
+
return null;
|
|
2405
|
+
}
|
|
2406
|
+
set() {
|
|
2407
|
+
}
|
|
2408
|
+
delete() {
|
|
2409
|
+
}
|
|
2410
|
+
clearAll() {
|
|
2411
|
+
}
|
|
2412
|
+
};
|
|
2413
|
+
var NOOP_STORE = new NoopStore();
|
|
2414
|
+
function isNoopStore(store) {
|
|
2415
|
+
return store == null || store instanceof NoopStore;
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2314
2418
|
// src/react/provider.ts
|
|
2419
|
+
var OFFLINE_MAX_AGE_MS = 1e3 * 60 * 60 * 24 * 7;
|
|
2315
2420
|
var CONVEX_URLS2 = {
|
|
2316
2421
|
local: "https://courteous-duck-623.convex.cloud",
|
|
2317
2422
|
staging: "https://courteous-duck-623.convex.cloud",
|
|
@@ -2351,12 +2456,20 @@ function readEnv(name) {
|
|
|
2351
2456
|
const v = process.env[name];
|
|
2352
2457
|
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
2353
2458
|
}
|
|
2354
|
-
var TruthSdkContext = (0,
|
|
2459
|
+
var TruthSdkContext = (0, import_react4.createContext)(null);
|
|
2355
2460
|
function useTruthSdkContext() {
|
|
2356
|
-
return (0,
|
|
2461
|
+
return (0, import_react4.useContext)(TruthSdkContext);
|
|
2462
|
+
}
|
|
2463
|
+
function useOfflineStore() {
|
|
2464
|
+
var _a, _b;
|
|
2465
|
+
return (_b = (_a = (0, import_react4.useContext)(TruthSdkContext)) == null ? void 0 : _a.offlineStore) != null ? _b : NOOP_STORE;
|
|
2466
|
+
}
|
|
2467
|
+
function useOfflineEnabled() {
|
|
2468
|
+
var _a, _b;
|
|
2469
|
+
return (_b = (_a = (0, import_react4.useContext)(TruthSdkContext)) == null ? void 0 : _a.offlineEnabled) != null ? _b : false;
|
|
2357
2470
|
}
|
|
2358
2471
|
function useTruthClient() {
|
|
2359
|
-
const ctx = (0,
|
|
2472
|
+
const ctx = (0, import_react4.useContext)(TruthSdkContext);
|
|
2360
2473
|
if (!ctx) {
|
|
2361
2474
|
throw new Error(
|
|
2362
2475
|
"useTruthClient() called outside <TruthProvider>. Wrap your app in <TruthProvider> from @hipnation-truth/sdk/react."
|
|
@@ -2381,14 +2494,45 @@ function TruthProvider({
|
|
|
2381
2494
|
source,
|
|
2382
2495
|
sourceVersion,
|
|
2383
2496
|
tenantId,
|
|
2497
|
+
offlineStore = NOOP_STORE,
|
|
2498
|
+
offlineEnabled = false,
|
|
2384
2499
|
children
|
|
2385
2500
|
}) {
|
|
2386
2501
|
var _a, _b;
|
|
2387
2502
|
const url = resolveConvexUrl(environment, convexUrl);
|
|
2388
2503
|
const resolvedApiBaseUrl = (_a = apiBaseUrl != null ? apiBaseUrl : readEnv("EXPO_PUBLIC_TRUTH_API_BASE_URL")) != null ? _a : resolveApiBaseUrl(environment);
|
|
2389
2504
|
const resolvedApiKey = (_b = apiKey != null ? apiKey : readEnv("EXPO_PUBLIC_TRUTH_API_KEY")) != null ? _b : "";
|
|
2390
|
-
const convexClient = (0,
|
|
2391
|
-
const
|
|
2505
|
+
const convexClient = (0, import_react4.useMemo)(() => new import_react3.ConvexReactClient(url), [url]);
|
|
2506
|
+
const convexQueryClient = (0, import_react4.useMemo)(
|
|
2507
|
+
() => new import_react_query3.ConvexQueryClient(convexClient),
|
|
2508
|
+
[convexClient]
|
|
2509
|
+
);
|
|
2510
|
+
const queryClient = (0, import_react4.useMemo)(() => {
|
|
2511
|
+
return new import_react_query4.QueryClient({
|
|
2512
|
+
defaultOptions: {
|
|
2513
|
+
queries: {
|
|
2514
|
+
queryKeyHashFn: convexQueryClient.hashFn(),
|
|
2515
|
+
queryFn: convexQueryClient.queryFn(),
|
|
2516
|
+
gcTime: OFFLINE_MAX_AGE_MS,
|
|
2517
|
+
// Convex throws on subscribe rather than returning errors;
|
|
2518
|
+
// retrying a permanently-failing query buys nothing.
|
|
2519
|
+
retry: false
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
});
|
|
2523
|
+
}, [convexQueryClient]);
|
|
2524
|
+
const connectedClientRef = (0, import_react4.useRef)(null);
|
|
2525
|
+
(0, import_react4.useEffect)(() => {
|
|
2526
|
+
if (connectedClientRef.current !== convexQueryClient) {
|
|
2527
|
+
convexQueryClient.connect(queryClient);
|
|
2528
|
+
connectedClientRef.current = convexQueryClient;
|
|
2529
|
+
}
|
|
2530
|
+
}, [convexQueryClient, queryClient]);
|
|
2531
|
+
const persister = (0, import_react4.useMemo)(
|
|
2532
|
+
() => offlineEnabled && !isNoopStore(offlineStore) ? createOfflinePersister(offlineStore) : void 0,
|
|
2533
|
+
[offlineEnabled, offlineStore]
|
|
2534
|
+
);
|
|
2535
|
+
const truthClient = (0, import_react4.useMemo)(
|
|
2392
2536
|
() => new TruthClient({
|
|
2393
2537
|
// Pin the resource client to the SAME deployment the React hooks
|
|
2394
2538
|
// use; without this it falls back to CONVEX_URLS[environment] and a
|
|
@@ -2412,7 +2556,7 @@ function TruthProvider({
|
|
|
2412
2556
|
tenantId
|
|
2413
2557
|
]
|
|
2414
2558
|
);
|
|
2415
|
-
(0,
|
|
2559
|
+
(0, import_react4.useEffect)(() => {
|
|
2416
2560
|
_activeClient = truthClient;
|
|
2417
2561
|
return () => {
|
|
2418
2562
|
if (_activeClient === truthClient) {
|
|
@@ -2422,19 +2566,47 @@ function TruthProvider({
|
|
|
2422
2566
|
});
|
|
2423
2567
|
};
|
|
2424
2568
|
}, [truthClient]);
|
|
2425
|
-
const sdkContext = (0,
|
|
2569
|
+
const sdkContext = (0, import_react4.useMemo)(
|
|
2426
2570
|
() => ({
|
|
2427
2571
|
apiBaseUrl: resolvedApiBaseUrl,
|
|
2428
2572
|
apiKey: resolvedApiKey,
|
|
2429
2573
|
environment,
|
|
2430
|
-
client: truthClient
|
|
2574
|
+
client: truthClient,
|
|
2575
|
+
offlineStore,
|
|
2576
|
+
offlineEnabled
|
|
2431
2577
|
}),
|
|
2432
|
-
[
|
|
2578
|
+
[
|
|
2579
|
+
resolvedApiBaseUrl,
|
|
2580
|
+
resolvedApiKey,
|
|
2581
|
+
environment,
|
|
2582
|
+
truthClient,
|
|
2583
|
+
offlineStore,
|
|
2584
|
+
offlineEnabled
|
|
2585
|
+
]
|
|
2586
|
+
);
|
|
2587
|
+
const convexTree = (0, import_react4.createElement)(
|
|
2588
|
+
import_react3.ConvexProvider,
|
|
2589
|
+
{ client: convexClient },
|
|
2590
|
+
children
|
|
2433
2591
|
);
|
|
2434
|
-
|
|
2592
|
+
const queryTree = persister ? (0, import_react4.createElement)(
|
|
2593
|
+
import_react_query_persist_client.PersistQueryClientProvider,
|
|
2594
|
+
{
|
|
2595
|
+
client: queryClient,
|
|
2596
|
+
persistOptions: {
|
|
2597
|
+
persister,
|
|
2598
|
+
maxAge: OFFLINE_MAX_AGE_MS,
|
|
2599
|
+
// A SCHEMA_VERSION bump busts the entire dehydrated cache, so
|
|
2600
|
+
// an older build's shapes can never rehydrate the new UI.
|
|
2601
|
+
buster: String(SCHEMA_VERSION)
|
|
2602
|
+
}
|
|
2603
|
+
},
|
|
2604
|
+
convexTree
|
|
2605
|
+
) : (0, import_react4.createElement)(import_react_query4.QueryClientProvider, { client: queryClient }, convexTree);
|
|
2606
|
+
return (0, import_react4.createElement)(
|
|
2435
2607
|
TruthSdkContext.Provider,
|
|
2436
2608
|
{ value: sdkContext },
|
|
2437
|
-
|
|
2609
|
+
queryTree
|
|
2438
2610
|
);
|
|
2439
2611
|
}
|
|
2440
2612
|
|
|
@@ -2448,45 +2620,45 @@ var appointmentsListRef = (0, import_server5.makeFunctionReference)("appointment
|
|
|
2448
2620
|
var appointmentsGetRef = (0, import_server5.makeFunctionReference)("appointments:get");
|
|
2449
2621
|
var appointmentsByElationIdRef = (0, import_server5.makeFunctionReference)("appointments:getByElationId");
|
|
2450
2622
|
function usePatients(options) {
|
|
2451
|
-
return (
|
|
2623
|
+
return usePersistentQuery(patientsListRef, options != null ? options : {});
|
|
2452
2624
|
}
|
|
2453
2625
|
function usePatient(id) {
|
|
2454
|
-
return (
|
|
2626
|
+
return usePersistentQuery(patientsGetRef, { id });
|
|
2455
2627
|
}
|
|
2456
2628
|
function usePatientByElationId(elationId) {
|
|
2457
|
-
return (
|
|
2629
|
+
return usePersistentQuery(patientsByElationIdRef, {
|
|
2458
2630
|
elationId
|
|
2459
2631
|
});
|
|
2460
2632
|
}
|
|
2461
2633
|
function usePatientByHintId(hintId) {
|
|
2462
|
-
return (
|
|
2634
|
+
return usePersistentQuery(patientsByHintIdRef, {
|
|
2463
2635
|
hintId
|
|
2464
2636
|
});
|
|
2465
2637
|
}
|
|
2466
2638
|
function useAppointments(options) {
|
|
2467
|
-
return (
|
|
2639
|
+
return usePersistentQuery(
|
|
2468
2640
|
appointmentsListRef,
|
|
2469
2641
|
options != null ? options : {}
|
|
2470
2642
|
);
|
|
2471
2643
|
}
|
|
2472
2644
|
function useAppointment(id) {
|
|
2473
|
-
return (
|
|
2645
|
+
return usePersistentQuery(appointmentsGetRef, { id });
|
|
2474
2646
|
}
|
|
2475
2647
|
function useAppointmentByElationId(elationId) {
|
|
2476
|
-
return (
|
|
2648
|
+
return usePersistentQuery(appointmentsByElationIdRef, {
|
|
2477
2649
|
elationId
|
|
2478
2650
|
});
|
|
2479
2651
|
}
|
|
2480
2652
|
var physiciansGetByElationIdsRef = (0, import_server5.makeFunctionReference)("physicians:getByElationIds");
|
|
2481
2653
|
var physiciansGetByElationIdRef = (0, import_server5.makeFunctionReference)("physicians:getByElationId");
|
|
2482
2654
|
function usePhysiciansByElationIds(ids) {
|
|
2483
|
-
return (
|
|
2655
|
+
return usePersistentQuery(
|
|
2484
2656
|
physiciansGetByElationIdsRef,
|
|
2485
2657
|
ids && ids.length > 0 ? { ids } : "skip"
|
|
2486
2658
|
);
|
|
2487
2659
|
}
|
|
2488
2660
|
function usePhysicianByElationId(id) {
|
|
2489
|
-
return (
|
|
2661
|
+
return usePersistentQuery(
|
|
2490
2662
|
physiciansGetByElationIdRef,
|
|
2491
2663
|
id !== void 0 ? { id } : "skip"
|
|
2492
2664
|
);
|
|
@@ -2500,23 +2672,23 @@ function usePatientMedical(elationId, options) {
|
|
|
2500
2672
|
const sdkContext = useTruthSdkContext();
|
|
2501
2673
|
const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
|
|
2502
2674
|
const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
|
|
2503
|
-
const medications = (
|
|
2675
|
+
const medications = usePersistentQuery(
|
|
2504
2676
|
medicationsByPatientRef,
|
|
2505
2677
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2506
2678
|
);
|
|
2507
|
-
const problems = (
|
|
2679
|
+
const problems = usePersistentQuery(
|
|
2508
2680
|
problemsByPatientRef,
|
|
2509
2681
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2510
2682
|
);
|
|
2511
|
-
const allergies = (
|
|
2683
|
+
const allergies = usePersistentQuery(
|
|
2512
2684
|
allergiesByPatientRef,
|
|
2513
2685
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2514
2686
|
);
|
|
2515
|
-
const appointments = (
|
|
2687
|
+
const appointments = usePersistentQuery(
|
|
2516
2688
|
appointmentsByPatientRef,
|
|
2517
2689
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2518
2690
|
);
|
|
2519
|
-
(0,
|
|
2691
|
+
(0, import_react5.useEffect)(() => {
|
|
2520
2692
|
if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2521
2693
|
return;
|
|
2522
2694
|
}
|
|
@@ -2547,15 +2719,15 @@ function usePatientBasic(input, options) {
|
|
|
2547
2719
|
const sdkContext = useTruthSdkContext();
|
|
2548
2720
|
const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
|
|
2549
2721
|
const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
|
|
2550
|
-
const elationRow = (
|
|
2722
|
+
const elationRow = usePersistentQuery(
|
|
2551
2723
|
elationPatientByIdRef,
|
|
2552
2724
|
input.elationId !== void 0 ? { elationId: input.elationId } : "skip"
|
|
2553
2725
|
);
|
|
2554
|
-
const hintRow = (
|
|
2726
|
+
const hintRow = usePersistentQuery(
|
|
2555
2727
|
hintPatientByIdRef,
|
|
2556
2728
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
2557
2729
|
);
|
|
2558
|
-
(0,
|
|
2730
|
+
(0, import_react5.useEffect)(() => {
|
|
2559
2731
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2560
2732
|
return;
|
|
2561
2733
|
}
|
|
@@ -2594,7 +2766,7 @@ function usePatientBasic(input, options) {
|
|
|
2594
2766
|
};
|
|
2595
2767
|
}
|
|
2596
2768
|
function usePharmacyByNcpdpId(ncpdpId) {
|
|
2597
|
-
return (
|
|
2769
|
+
return usePersistentQuery(
|
|
2598
2770
|
pharmacyByNcpdpRef,
|
|
2599
2771
|
ncpdpId ? { ncpdpId } : "skip"
|
|
2600
2772
|
);
|
|
@@ -2604,11 +2776,11 @@ function usePatientPhoto(elationId, options) {
|
|
|
2604
2776
|
const sdkContext = useTruthSdkContext();
|
|
2605
2777
|
const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
|
|
2606
2778
|
const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
|
|
2607
|
-
const photo = (
|
|
2779
|
+
const photo = usePersistentQuery(
|
|
2608
2780
|
patientPhotoByIdRef,
|
|
2609
2781
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2610
2782
|
);
|
|
2611
|
-
(0,
|
|
2783
|
+
(0, import_react5.useEffect)(() => {
|
|
2612
2784
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2613
2785
|
return;
|
|
2614
2786
|
}
|
|
@@ -2637,7 +2809,7 @@ var messagesByPhonesRef = (0, import_server5.makeFunctionReference)("conversatio
|
|
|
2637
2809
|
var messagesByConversationIdRef = (0, import_server5.makeFunctionReference)("conversationMessages:getByConversationId");
|
|
2638
2810
|
function useConversationMessages(input, options) {
|
|
2639
2811
|
const hasPair = !!input.phoneA && !!input.phoneB;
|
|
2640
|
-
const byPair = (
|
|
2812
|
+
const byPair = usePersistentQuery(
|
|
2641
2813
|
messagesByPhonesRef,
|
|
2642
2814
|
hasPair ? {
|
|
2643
2815
|
phoneA: input.phoneA,
|
|
@@ -2645,7 +2817,7 @@ function useConversationMessages(input, options) {
|
|
|
2645
2817
|
limit: options == null ? void 0 : options.limit
|
|
2646
2818
|
} : "skip"
|
|
2647
2819
|
);
|
|
2648
|
-
const byConvo = (
|
|
2820
|
+
const byConvo = usePersistentQuery(
|
|
2649
2821
|
messagesByConversationIdRef,
|
|
2650
2822
|
!hasPair && input.conversationId ? { conversationId: input.conversationId, limit: options == null ? void 0 : options.limit } : "skip"
|
|
2651
2823
|
);
|
|
@@ -2653,7 +2825,7 @@ function useConversationMessages(input, options) {
|
|
|
2653
2825
|
}
|
|
2654
2826
|
|
|
2655
2827
|
// src/react/notifications.ts
|
|
2656
|
-
var
|
|
2828
|
+
var import_react6 = require("react");
|
|
2657
2829
|
function loadExpo() {
|
|
2658
2830
|
return __async(this, null, function* () {
|
|
2659
2831
|
try {
|
|
@@ -2668,12 +2840,12 @@ function useNotifications(options) {
|
|
|
2668
2840
|
const sdkContext = useTruthSdkContext();
|
|
2669
2841
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
2670
2842
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
2671
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
2672
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
2673
|
-
const expoRef = (0,
|
|
2674
|
-
const isWebRef = (0,
|
|
2675
|
-
const vapidKeyRef = (0,
|
|
2676
|
-
(0,
|
|
2843
|
+
const [permissionStatus, setPermissionStatus] = (0, import_react6.useState)("unknown");
|
|
2844
|
+
const [devicePushToken, setDevicePushToken] = (0, import_react6.useState)(null);
|
|
2845
|
+
const expoRef = (0, import_react6.useRef)(null);
|
|
2846
|
+
const isWebRef = (0, import_react6.useRef)(false);
|
|
2847
|
+
const vapidKeyRef = (0, import_react6.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
|
|
2848
|
+
(0, import_react6.useEffect)(() => {
|
|
2677
2849
|
let mounted = true;
|
|
2678
2850
|
void (() => __async(null, null, function* () {
|
|
2679
2851
|
var _a2;
|
|
@@ -2729,7 +2901,7 @@ function useNotifications(options) {
|
|
|
2729
2901
|
mounted = false;
|
|
2730
2902
|
};
|
|
2731
2903
|
}, [apiBaseUrl, apiKey]);
|
|
2732
|
-
const register = (0,
|
|
2904
|
+
const register = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
2733
2905
|
var _a2, _b2;
|
|
2734
2906
|
if (!options.userId) {
|
|
2735
2907
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -2842,7 +3014,7 @@ function useNotifications(options) {
|
|
|
2842
3014
|
options.appVersion,
|
|
2843
3015
|
options.serviceWorkerPath
|
|
2844
3016
|
]);
|
|
2845
|
-
const unregister = (0,
|
|
3017
|
+
const unregister = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
2846
3018
|
if (!devicePushToken) {
|
|
2847
3019
|
return;
|
|
2848
3020
|
}
|
|
@@ -2857,7 +3029,7 @@ function useNotifications(options) {
|
|
|
2857
3029
|
});
|
|
2858
3030
|
setDevicePushToken(null);
|
|
2859
3031
|
}), [apiBaseUrl, apiKey, devicePushToken]);
|
|
2860
|
-
const addReceivedListener = (0,
|
|
3032
|
+
const addReceivedListener = (0, import_react6.useCallback)(
|
|
2861
3033
|
(listener) => {
|
|
2862
3034
|
if (isWebRef.current) {
|
|
2863
3035
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -2886,7 +3058,7 @@ function useNotifications(options) {
|
|
|
2886
3058
|
},
|
|
2887
3059
|
[]
|
|
2888
3060
|
);
|
|
2889
|
-
const addResponseListener = (0,
|
|
3061
|
+
const addResponseListener = (0, import_react6.useCallback)(
|
|
2890
3062
|
(listener) => {
|
|
2891
3063
|
if (isWebRef.current) {
|
|
2892
3064
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -2915,7 +3087,7 @@ function useNotifications(options) {
|
|
|
2915
3087
|
},
|
|
2916
3088
|
[]
|
|
2917
3089
|
);
|
|
2918
|
-
const getBadgeCount = (0,
|
|
3090
|
+
const getBadgeCount = (0, import_react6.useCallback)(() => __async(null, null, function* () {
|
|
2919
3091
|
var _a2;
|
|
2920
3092
|
const expo = expoRef.current;
|
|
2921
3093
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -2923,7 +3095,7 @@ function useNotifications(options) {
|
|
|
2923
3095
|
}
|
|
2924
3096
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
2925
3097
|
}), []);
|
|
2926
|
-
const setBadgeCount = (0,
|
|
3098
|
+
const setBadgeCount = (0, import_react6.useCallback)((count) => __async(null, null, function* () {
|
|
2927
3099
|
const expo = expoRef.current;
|
|
2928
3100
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
2929
3101
|
return;
|
|
@@ -2931,7 +3103,7 @@ function useNotifications(options) {
|
|
|
2931
3103
|
yield expo.setBadgeCountAsync(count);
|
|
2932
3104
|
}), []);
|
|
2933
3105
|
const autoRegister = options.autoRegister !== false;
|
|
2934
|
-
(0,
|
|
3106
|
+
(0, import_react6.useEffect)(() => {
|
|
2935
3107
|
if (!autoRegister) {
|
|
2936
3108
|
return;
|
|
2937
3109
|
}
|
|
@@ -2968,7 +3140,7 @@ function useNotificationsActions() {
|
|
|
2968
3140
|
const sdkContext = useTruthSdkContext();
|
|
2969
3141
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
2970
3142
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
2971
|
-
const post = (0,
|
|
3143
|
+
const post = (0, import_react6.useCallback)(
|
|
2972
3144
|
(path, body) => __async(null, null, function* () {
|
|
2973
3145
|
if (!apiBaseUrl || !apiKey) {
|
|
2974
3146
|
throw new Error(
|
|
@@ -2994,7 +3166,7 @@ function useNotificationsActions() {
|
|
|
2994
3166
|
}),
|
|
2995
3167
|
[apiBaseUrl, apiKey]
|
|
2996
3168
|
);
|
|
2997
|
-
const get = (0,
|
|
3169
|
+
const get = (0, import_react6.useCallback)(
|
|
2998
3170
|
(path) => __async(null, null, function* () {
|
|
2999
3171
|
const res = yield fetch(`${apiBaseUrl}/api${path}`, {
|
|
3000
3172
|
method: "GET",
|
|
@@ -3010,21 +3182,21 @@ function useNotificationsActions() {
|
|
|
3010
3182
|
}),
|
|
3011
3183
|
[apiBaseUrl, apiKey]
|
|
3012
3184
|
);
|
|
3013
|
-
const send = (0,
|
|
3185
|
+
const send = (0, import_react6.useCallback)(
|
|
3014
3186
|
(input) => post("/notifications/send", input),
|
|
3015
3187
|
[post]
|
|
3016
3188
|
);
|
|
3017
|
-
const schedule = (0,
|
|
3189
|
+
const schedule = (0, import_react6.useCallback)(
|
|
3018
3190
|
(input) => post("/notifications/schedule", input),
|
|
3019
3191
|
[post]
|
|
3020
3192
|
);
|
|
3021
|
-
const getPreferences = (0,
|
|
3193
|
+
const getPreferences = (0, import_react6.useCallback)(
|
|
3022
3194
|
(userId) => get(
|
|
3023
3195
|
`/notifications/preferences/${encodeURIComponent(userId)}`
|
|
3024
3196
|
),
|
|
3025
3197
|
[get]
|
|
3026
3198
|
);
|
|
3027
|
-
const updatePreferences = (0,
|
|
3199
|
+
const updatePreferences = (0, import_react6.useCallback)(
|
|
3028
3200
|
(userId, prefs) => post(
|
|
3029
3201
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3030
3202
|
prefs
|
|
@@ -3059,7 +3231,6 @@ function detectPlatform(tokenType) {
|
|
|
3059
3231
|
}
|
|
3060
3232
|
|
|
3061
3233
|
// src/react/patient-family.ts
|
|
3062
|
-
var import_react10 = require("convex/react");
|
|
3063
3234
|
var import_server6 = require("convex/server");
|
|
3064
3235
|
var patientsFamilyMembersRef = (0, import_server6.makeFunctionReference)("patients:listFamilyMembers");
|
|
3065
3236
|
var SKIP3 = "skip";
|
|
@@ -3068,7 +3239,7 @@ function usePatientFamilyMembers(input) {
|
|
|
3068
3239
|
const hasPhoneNumbers = !!((input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0);
|
|
3069
3240
|
const shouldQuery = hasFamilyId || hasPhoneNumbers;
|
|
3070
3241
|
const args = shouldQuery ? __spreadValues(__spreadValues(__spreadValues({}, (input == null ? void 0 : input.familyId) ? { familyId: input.familyId } : {}), (input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0 ? { phoneNumbers: input.phoneNumbers } : {}), (input == null ? void 0 : input.excludeHintId) ? { excludeHintId: input.excludeHintId } : {}) : SKIP3;
|
|
3071
|
-
const result = (
|
|
3242
|
+
const result = usePersistentQuery(
|
|
3072
3243
|
patientsFamilyMembersRef,
|
|
3073
3244
|
args
|
|
3074
3245
|
);
|
|
@@ -3083,7 +3254,6 @@ function usePatientFamilyMembers(input) {
|
|
|
3083
3254
|
}
|
|
3084
3255
|
|
|
3085
3256
|
// src/react/patient-search.ts
|
|
3086
|
-
var import_react11 = require("convex/react");
|
|
3087
3257
|
var import_server7 = require("convex/server");
|
|
3088
3258
|
var patientsSearchRef = (0, import_server7.makeFunctionReference)("patients:search");
|
|
3089
3259
|
var SKIP4 = "skip";
|
|
@@ -3091,7 +3261,7 @@ function usePatientSearch(options) {
|
|
|
3091
3261
|
var _a;
|
|
3092
3262
|
const trimmedQuery = ((_a = options.query) != null ? _a : "").trim();
|
|
3093
3263
|
const skipped = trimmedQuery.length === 0;
|
|
3094
|
-
const result = (
|
|
3264
|
+
const result = usePersistentQuery(
|
|
3095
3265
|
patientsSearchRef,
|
|
3096
3266
|
skipped ? SKIP4 : __spreadValues(__spreadValues(__spreadValues({
|
|
3097
3267
|
query: trimmedQuery
|
|
@@ -3108,23 +3278,22 @@ function usePatientSearch(options) {
|
|
|
3108
3278
|
}
|
|
3109
3279
|
|
|
3110
3280
|
// src/react/patients-bulk.ts
|
|
3111
|
-
var import_react12 = require("convex/react");
|
|
3112
3281
|
var import_server8 = require("convex/server");
|
|
3113
|
-
var
|
|
3282
|
+
var import_react7 = require("react");
|
|
3114
3283
|
var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
|
|
3115
3284
|
var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
|
|
3116
3285
|
var SKIP5 = "skip";
|
|
3117
3286
|
function usePatientsByIds(ids) {
|
|
3118
|
-
const stableIds = (0,
|
|
3287
|
+
const stableIds = (0, import_react7.useMemo)(() => {
|
|
3119
3288
|
const arr = ids != null ? ids : [];
|
|
3120
3289
|
return [...new Set(arr)].sort();
|
|
3121
3290
|
}, [ids]);
|
|
3122
3291
|
const skipped = stableIds.length === 0;
|
|
3123
|
-
const result = (
|
|
3292
|
+
const result = usePersistentQuery(
|
|
3124
3293
|
patientsGetByIdsRef,
|
|
3125
3294
|
skipped ? SKIP5 : { ids: stableIds }
|
|
3126
3295
|
);
|
|
3127
|
-
const mapped = (0,
|
|
3296
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3128
3297
|
if (result === void 0) {
|
|
3129
3298
|
return void 0;
|
|
3130
3299
|
}
|
|
@@ -3146,17 +3315,17 @@ function usePatientsByIds(ids) {
|
|
|
3146
3315
|
};
|
|
3147
3316
|
}
|
|
3148
3317
|
function usePatientsByPhones(phones) {
|
|
3149
|
-
const stableDigits = (0,
|
|
3318
|
+
const stableDigits = (0, import_react7.useMemo)(() => {
|
|
3150
3319
|
const arr = phones != null ? phones : [];
|
|
3151
3320
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3152
3321
|
return [...new Set(digits)].sort();
|
|
3153
3322
|
}, [phones]);
|
|
3154
3323
|
const skipped = stableDigits.length === 0;
|
|
3155
|
-
const result = (
|
|
3324
|
+
const result = usePersistentQuery(
|
|
3156
3325
|
patientsGetByPhonesRef,
|
|
3157
3326
|
skipped ? SKIP5 : { phoneDigits: stableDigits }
|
|
3158
3327
|
);
|
|
3159
|
-
const mapped = (0,
|
|
3328
|
+
const mapped = (0, import_react7.useMemo)(() => {
|
|
3160
3329
|
if (result === void 0) {
|
|
3161
3330
|
return void 0;
|
|
3162
3331
|
}
|
|
@@ -3173,14 +3342,13 @@ function usePatientsByPhones(phones) {
|
|
|
3173
3342
|
}
|
|
3174
3343
|
|
|
3175
3344
|
// src/react/reminders.ts
|
|
3176
|
-
var import_react14 = require("convex/react");
|
|
3177
3345
|
var import_server9 = require("convex/server");
|
|
3178
3346
|
var remindersListPendingByConversationIdsRef = (0, import_server9.makeFunctionReference)("reminders:listPendingByConversationIds");
|
|
3179
3347
|
var SKIP6 = "skip";
|
|
3180
3348
|
function useRemindersForConversations(conversationIds) {
|
|
3181
3349
|
const ids = conversationIds != null ? conversationIds : [];
|
|
3182
3350
|
const skipped = ids.length === 0;
|
|
3183
|
-
const result = (
|
|
3351
|
+
const result = usePersistentQuery(
|
|
3184
3352
|
remindersListPendingByConversationIdsRef,
|
|
3185
3353
|
skipped ? SKIP6 : { conversationIds: ids }
|
|
3186
3354
|
);
|
|
@@ -3196,23 +3364,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3196
3364
|
}
|
|
3197
3365
|
|
|
3198
3366
|
// src/react/tasks.ts
|
|
3199
|
-
var
|
|
3367
|
+
var import_react8 = require("convex/react");
|
|
3200
3368
|
var import_server10 = require("convex/server");
|
|
3201
|
-
var
|
|
3369
|
+
var import_react9 = require("react");
|
|
3202
3370
|
var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
|
|
3203
3371
|
function useConversationTaskMarkSeen() {
|
|
3204
|
-
const mutate = (0,
|
|
3372
|
+
const mutate = (0, import_react8.useMutation)(
|
|
3205
3373
|
conversationTasksMarkSeenRef
|
|
3206
3374
|
);
|
|
3207
|
-
return (0,
|
|
3375
|
+
return (0, import_react9.useCallback)(
|
|
3208
3376
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3209
3377
|
[mutate]
|
|
3210
3378
|
);
|
|
3211
3379
|
}
|
|
3212
3380
|
|
|
3213
3381
|
// src/react/tracking.ts
|
|
3214
|
-
var
|
|
3215
|
-
var TruthTrackingContext = (0,
|
|
3382
|
+
var import_react10 = require("react");
|
|
3383
|
+
var TruthTrackingContext = (0, import_react10.createContext)(
|
|
3216
3384
|
null
|
|
3217
3385
|
);
|
|
3218
3386
|
function TruthTrackingProvider({
|
|
@@ -3225,7 +3393,7 @@ function TruthTrackingProvider({
|
|
|
3225
3393
|
}) {
|
|
3226
3394
|
var _a, _b;
|
|
3227
3395
|
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 : "";
|
|
3228
|
-
const value = (0,
|
|
3396
|
+
const value = (0, import_react10.useMemo)(() => {
|
|
3229
3397
|
const tracker = new Tracker({
|
|
3230
3398
|
apiKey: resolvedApiKey,
|
|
3231
3399
|
environment,
|
|
@@ -3244,10 +3412,10 @@ function TruthTrackingProvider({
|
|
|
3244
3412
|
}
|
|
3245
3413
|
};
|
|
3246
3414
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3247
|
-
return (0,
|
|
3415
|
+
return (0, import_react10.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3248
3416
|
}
|
|
3249
3417
|
function useTruth() {
|
|
3250
|
-
const ctx = (0,
|
|
3418
|
+
const ctx = (0, import_react10.useContext)(TruthTrackingContext);
|
|
3251
3419
|
if (!ctx) {
|
|
3252
3420
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3253
3421
|
}
|
|
@@ -3255,13 +3423,12 @@ function useTruth() {
|
|
|
3255
3423
|
}
|
|
3256
3424
|
|
|
3257
3425
|
// src/react/user-settings.ts
|
|
3258
|
-
var import_react18 = require("convex/react");
|
|
3259
3426
|
var import_server11 = require("convex/server");
|
|
3260
3427
|
var userSettingsGetByUserIdRef = (0, import_server11.makeFunctionReference)("userSettings:getByUserId");
|
|
3261
3428
|
var SKIP7 = "skip";
|
|
3262
3429
|
function useUserSettings(userId) {
|
|
3263
3430
|
const skip = !userId;
|
|
3264
|
-
const result = (
|
|
3431
|
+
const result = usePersistentQuery(
|
|
3265
3432
|
userSettingsGetByUserIdRef,
|
|
3266
3433
|
skip ? SKIP7 : { userId }
|
|
3267
3434
|
);
|
|
@@ -3276,15 +3443,15 @@ function useUserSettings(userId) {
|
|
|
3276
3443
|
}
|
|
3277
3444
|
|
|
3278
3445
|
// src/react/users.ts
|
|
3279
|
-
var
|
|
3446
|
+
var import_react11 = require("react");
|
|
3280
3447
|
function useUserSync(input) {
|
|
3281
3448
|
var _a, _b, _c, _d;
|
|
3282
3449
|
const sdkContext = useTruthSdkContext();
|
|
3283
3450
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3284
3451
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3285
|
-
const [status, setStatus] = (0,
|
|
3286
|
-
const [error, setError] = (0,
|
|
3287
|
-
const lastKeyRef = (0,
|
|
3452
|
+
const [status, setStatus] = (0, import_react11.useState)("idle");
|
|
3453
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
3454
|
+
const lastKeyRef = (0, import_react11.useRef)(null);
|
|
3288
3455
|
const sync = () => __async(null, null, function* () {
|
|
3289
3456
|
if (!input.userId) {
|
|
3290
3457
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3327,7 +3494,7 @@ function useUserSync(input) {
|
|
|
3327
3494
|
return { ok: false, reason: message };
|
|
3328
3495
|
}
|
|
3329
3496
|
});
|
|
3330
|
-
(0,
|
|
3497
|
+
(0, import_react11.useEffect)(() => {
|
|
3331
3498
|
var _a2, _b2, _c2, _d2, _e;
|
|
3332
3499
|
if (!input.userId) {
|
|
3333
3500
|
return;
|
|
@@ -3366,13 +3533,13 @@ function useUserSync(input) {
|
|
|
3366
3533
|
}
|
|
3367
3534
|
|
|
3368
3535
|
// src/react/voicemail.ts
|
|
3369
|
-
var
|
|
3536
|
+
var import_react12 = require("react");
|
|
3370
3537
|
function useVoicemailUrl(client) {
|
|
3371
|
-
const [url, setUrl] = (0,
|
|
3372
|
-
const [isLoading, setIsLoading] = (0,
|
|
3373
|
-
const [error, setError] = (0,
|
|
3374
|
-
const inFlightRef = (0,
|
|
3375
|
-
const fetchUrl = (0,
|
|
3538
|
+
const [url, setUrl] = (0, import_react12.useState)(null);
|
|
3539
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
3540
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
3541
|
+
const inFlightRef = (0, import_react12.useRef)(false);
|
|
3542
|
+
const fetchUrl = (0, import_react12.useCallback)(
|
|
3376
3543
|
(voicemailLink) => __async(null, null, function* () {
|
|
3377
3544
|
if (inFlightRef.current) {
|
|
3378
3545
|
return null;
|
|
@@ -3404,11 +3571,13 @@ function useVoicemailUrl(client) {
|
|
|
3404
3571
|
CONNECTED_CALL_STATES,
|
|
3405
3572
|
CONVEX_URLS,
|
|
3406
3573
|
DialpadCallState,
|
|
3574
|
+
NoopStore,
|
|
3407
3575
|
RINGING_CALL_STATES,
|
|
3408
3576
|
TERMINAL_CALL_STATES,
|
|
3409
3577
|
TruthProvider,
|
|
3410
3578
|
TruthTrackingProvider,
|
|
3411
3579
|
getTruthClient,
|
|
3580
|
+
readPersistedSavedAt,
|
|
3412
3581
|
resolveApiBaseUrl,
|
|
3413
3582
|
resolveConvexUrl,
|
|
3414
3583
|
useActiveCalls,
|
|
@@ -3431,6 +3600,8 @@ function useVoicemailUrl(client) {
|
|
|
3431
3600
|
useMessages,
|
|
3432
3601
|
useNotifications,
|
|
3433
3602
|
useNotificationsActions,
|
|
3603
|
+
useOfflineEnabled,
|
|
3604
|
+
useOfflineStore,
|
|
3434
3605
|
usePatient,
|
|
3435
3606
|
usePatientBasic,
|
|
3436
3607
|
usePatientByElationId,
|