@hipnation-truth/sdk 0.26.2 → 0.26.3
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 +9 -0
- package/dist/react.js +339 -323
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -122,259 +122,22 @@ __export(react_exports, {
|
|
|
122
122
|
module.exports = __toCommonJS(react_exports);
|
|
123
123
|
|
|
124
124
|
// src/react/calls.ts
|
|
125
|
-
var
|
|
126
|
-
var import_server = require("convex/server");
|
|
127
|
-
|
|
128
|
-
// src/react/offline/use-persistent-query.ts
|
|
129
|
-
var import_react_query = require("@convex-dev/react-query");
|
|
130
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
131
|
-
function usePersistentQuery(ref, args) {
|
|
132
|
-
const { data } = (0, import_react_query2.useQuery)(
|
|
133
|
-
(0, import_react_query.convexQuery)(
|
|
134
|
-
ref,
|
|
135
|
-
args
|
|
136
|
-
)
|
|
137
|
-
);
|
|
138
|
-
return data;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// src/react/calls.ts
|
|
142
|
-
var DialpadCallState = {
|
|
143
|
-
Calling: "calling",
|
|
144
|
-
Ringing: "ringing",
|
|
145
|
-
Connected: "connected",
|
|
146
|
-
Hold: "hold",
|
|
147
|
-
Hangup: "hangup",
|
|
148
|
-
Missed: "missed",
|
|
149
|
-
VoicemailUploaded: "voicemail_uploaded"
|
|
150
|
-
};
|
|
151
|
-
var RINGING_CALL_STATES = /* @__PURE__ */ new Set([
|
|
152
|
-
DialpadCallState.Calling,
|
|
153
|
-
DialpadCallState.Ringing
|
|
154
|
-
]);
|
|
155
|
-
var CONNECTED_CALL_STATES = /* @__PURE__ */ new Set([
|
|
156
|
-
DialpadCallState.Connected
|
|
157
|
-
]);
|
|
158
|
-
var ACTIVE_CALL_STATES = /* @__PURE__ */ new Set([
|
|
159
|
-
...RINGING_CALL_STATES,
|
|
160
|
-
...CONNECTED_CALL_STATES
|
|
161
|
-
]);
|
|
162
|
-
var TERMINAL_CALL_STATES = /* @__PURE__ */ new Set([
|
|
163
|
-
DialpadCallState.Hangup,
|
|
164
|
-
DialpadCallState.Missed,
|
|
165
|
-
DialpadCallState.VoicemailUploaded
|
|
166
|
-
]);
|
|
167
|
-
var listActiveRef = (0, import_server.makeFunctionReference)("dialpadCallEvents:listActive");
|
|
168
|
-
var listForConversationRef = (0, import_server.makeFunctionReference)("dialpadCallEvents:listForConversation");
|
|
169
|
-
var getByCallIdRef = (0, import_server.makeFunctionReference)("dialpadCallEvents:getByCallId");
|
|
170
|
-
var listLogForCallIdRef = (0, import_server.makeFunctionReference)("dialpadCallEvents:listLogForCallId");
|
|
171
|
-
var SKIP = "skip";
|
|
172
|
-
function toResult(value, skipped) {
|
|
173
|
-
if (skipped) {
|
|
174
|
-
return { data: void 0, loading: false, error: void 0 };
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
data: value,
|
|
178
|
-
loading: value === void 0,
|
|
179
|
-
error: void 0
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
function useActiveCalls(options) {
|
|
183
|
-
const result = (0, import_react.useQuery)(listActiveRef, options != null ? options : {});
|
|
184
|
-
return toResult(result, false);
|
|
185
|
-
}
|
|
186
|
-
function useDialpadCallsForConversation(conversationId, options) {
|
|
187
|
-
const skipped = !conversationId;
|
|
188
|
-
const result = usePersistentQuery(
|
|
189
|
-
listForConversationRef,
|
|
190
|
-
skipped ? SKIP : {
|
|
191
|
-
conversationId,
|
|
192
|
-
limit: options == null ? void 0 : options.limit
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
return toResult(result, skipped);
|
|
196
|
-
}
|
|
197
|
-
function useDialpadCallByCallId(callId) {
|
|
198
|
-
const skipped = !callId;
|
|
199
|
-
const result = usePersistentQuery(
|
|
200
|
-
getByCallIdRef,
|
|
201
|
-
skipped ? SKIP : { callId }
|
|
202
|
-
);
|
|
203
|
-
return toResult(result, skipped);
|
|
204
|
-
}
|
|
205
|
-
function useDialpadCallLog(callId, options) {
|
|
206
|
-
const skipped = !callId;
|
|
207
|
-
const result = usePersistentQuery(
|
|
208
|
-
listLogForCallIdRef,
|
|
209
|
-
skipped ? SKIP : { callId, limit: options == null ? void 0 : options.limit }
|
|
210
|
-
);
|
|
211
|
-
return toResult(result, skipped);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// src/react/conversation-by-id.ts
|
|
125
|
+
var import_react4 = require("convex/react");
|
|
215
126
|
var import_server2 = require("convex/server");
|
|
216
|
-
var conversationsGetByIdRef = (0, import_server2.makeFunctionReference)("conversations:getById");
|
|
217
|
-
function useConversationById(id) {
|
|
218
|
-
const skipped = !id;
|
|
219
|
-
const result = usePersistentQuery(
|
|
220
|
-
conversationsGetByIdRef,
|
|
221
|
-
skipped ? "skip" : { id }
|
|
222
|
-
);
|
|
223
|
-
if (skipped) {
|
|
224
|
-
return { data: void 0, loading: false, error: void 0 };
|
|
225
|
-
}
|
|
226
|
-
return {
|
|
227
|
-
data: result,
|
|
228
|
-
loading: result === void 0,
|
|
229
|
-
error: void 0
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
127
|
|
|
233
|
-
// src/react/
|
|
234
|
-
var
|
|
235
|
-
var
|
|
236
|
-
var conversationsListForUserRef = (0, import_server3.makeFunctionReference)("conversations:listForUser");
|
|
237
|
-
var conversationsSearchForUserRef = (0, import_server3.makeFunctionReference)("conversations:searchForUser");
|
|
238
|
-
var conversationsGetUnreadTotalForUserRef = (0, import_server3.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
239
|
-
var conversationsGetUnreadAggregateForUserRef = (0, import_server3.makeFunctionReference)("conversations:getUnreadAggregateForUser");
|
|
240
|
-
var conversationsGetByPhonePairRef = (0, import_server3.makeFunctionReference)("conversations:getByPhonePair");
|
|
241
|
-
var conversationMessagesGetByConversationIdRef = (0, import_server3.makeFunctionReference)("conversationMessages:getByConversationId");
|
|
242
|
-
var conversationNotesListForConversationRef = (0, import_server3.makeFunctionReference)("conversationNotes:listForConversation");
|
|
243
|
-
var conversationTasksListForConversationRef = (0, import_server3.makeFunctionReference)("conversationTasks:listForConversation");
|
|
244
|
-
var conversationNotesListByPhonePairRef = (0, import_server3.makeFunctionReference)("conversationNotes:listByPhonePair");
|
|
245
|
-
var conversationTasksListByPhonePairRef = (0, import_server3.makeFunctionReference)("conversationTasks:listByPhonePair");
|
|
246
|
-
var conversationTasksListForUserRef = (0, import_server3.makeFunctionReference)("conversationTasks:listForUser");
|
|
247
|
-
var SKIP2 = "skip";
|
|
248
|
-
function toResult2(value, skipped) {
|
|
249
|
-
if (skipped) {
|
|
250
|
-
return { data: void 0, loading: false, error: void 0 };
|
|
251
|
-
}
|
|
252
|
-
return {
|
|
253
|
-
data: value,
|
|
254
|
-
loading: value === void 0,
|
|
255
|
-
error: void 0
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
function useConversations(filters) {
|
|
259
|
-
var _a, _b;
|
|
260
|
-
const trimmedSearch = (_b = (_a = filters.search) == null ? void 0 : _a.trim()) != null ? _b : "";
|
|
261
|
-
const isSearchMode = trimmedSearch.length > 0;
|
|
262
|
-
const skipped = !filters.userId;
|
|
263
|
-
const listResult = usePersistentQuery(
|
|
264
|
-
conversationsListForUserRef,
|
|
265
|
-
skipped || isSearchMode ? SKIP2 : {
|
|
266
|
-
userId: filters.userId,
|
|
267
|
-
limit: filters.limit
|
|
268
|
-
}
|
|
269
|
-
);
|
|
270
|
-
const searchResult = usePersistentQuery(
|
|
271
|
-
conversationsSearchForUserRef,
|
|
272
|
-
skipped || !isSearchMode ? SKIP2 : {
|
|
273
|
-
userId: filters.userId,
|
|
274
|
-
search: trimmedSearch,
|
|
275
|
-
limit: filters.limit
|
|
276
|
-
}
|
|
277
|
-
);
|
|
278
|
-
return toResult2(isSearchMode ? searchResult : listResult, skipped);
|
|
279
|
-
}
|
|
280
|
-
function useConversationByPhonePair(phonePair) {
|
|
281
|
-
const skipped = !phonePair;
|
|
282
|
-
const result = usePersistentQuery(
|
|
283
|
-
conversationsGetByPhonePairRef,
|
|
284
|
-
skipped ? SKIP2 : { phonePair }
|
|
285
|
-
);
|
|
286
|
-
return toResult2(result, skipped);
|
|
287
|
-
}
|
|
288
|
-
function useMessages(conversationId, options) {
|
|
289
|
-
const skipped = !conversationId;
|
|
290
|
-
const result = usePersistentQuery(
|
|
291
|
-
conversationMessagesGetByConversationIdRef,
|
|
292
|
-
skipped ? SKIP2 : {
|
|
293
|
-
conversationId,
|
|
294
|
-
limit: options == null ? void 0 : options.limit
|
|
295
|
-
}
|
|
296
|
-
);
|
|
297
|
-
return toResult2(result, skipped);
|
|
298
|
-
}
|
|
299
|
-
function useUnreadCount(userId) {
|
|
300
|
-
const skipped = !userId;
|
|
301
|
-
const result = usePersistentQuery(
|
|
302
|
-
conversationsGetUnreadTotalForUserRef,
|
|
303
|
-
skipped ? SKIP2 : { userId }
|
|
304
|
-
);
|
|
305
|
-
return toResult2(result, skipped);
|
|
306
|
-
}
|
|
307
|
-
function useUnreadAggregate(userId, options) {
|
|
308
|
-
const skipped = !userId;
|
|
309
|
-
const phones = options == null ? void 0 : options.providerPhones;
|
|
310
|
-
const stablePhones = useMemoizedPhones(phones);
|
|
311
|
-
const result = usePersistentQuery(
|
|
312
|
-
conversationsGetUnreadAggregateForUserRef,
|
|
313
|
-
skipped ? SKIP2 : {
|
|
314
|
-
userId,
|
|
315
|
-
providerPhones: stablePhones
|
|
316
|
-
}
|
|
317
|
-
);
|
|
318
|
-
return toResult2(result, skipped);
|
|
319
|
-
}
|
|
320
|
-
function useMemoizedPhones(phones) {
|
|
321
|
-
const key = phones ? [...phones].sort().join("|") : "";
|
|
322
|
-
return (0, import_react2.useMemo)(
|
|
323
|
-
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
324
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
325
|
-
[key]
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
function useConversationNotes(conversationId) {
|
|
329
|
-
const skipped = !conversationId;
|
|
330
|
-
const result = usePersistentQuery(
|
|
331
|
-
conversationNotesListForConversationRef,
|
|
332
|
-
skipped ? SKIP2 : { conversationId }
|
|
333
|
-
);
|
|
334
|
-
return toResult2(result, skipped);
|
|
335
|
-
}
|
|
336
|
-
function useConversationTasks(conversationId) {
|
|
337
|
-
const skipped = !conversationId;
|
|
338
|
-
const result = usePersistentQuery(
|
|
339
|
-
conversationTasksListForConversationRef,
|
|
340
|
-
skipped ? SKIP2 : { conversationId }
|
|
341
|
-
);
|
|
342
|
-
return toResult2(result, skipped);
|
|
343
|
-
}
|
|
344
|
-
function useConversationNotesByPhonePair(phonePair) {
|
|
345
|
-
const skipped = !phonePair;
|
|
346
|
-
const result = usePersistentQuery(
|
|
347
|
-
conversationNotesListByPhonePairRef,
|
|
348
|
-
skipped ? SKIP2 : { phonePair }
|
|
349
|
-
);
|
|
350
|
-
return toResult2(result, skipped);
|
|
351
|
-
}
|
|
352
|
-
function useConversationTasksForUser(userId, options) {
|
|
353
|
-
const skipped = !userId;
|
|
354
|
-
const result = usePersistentQuery(
|
|
355
|
-
conversationTasksListForUserRef,
|
|
356
|
-
skipped ? SKIP2 : { userId, limit: options == null ? void 0 : options.limit }
|
|
357
|
-
);
|
|
358
|
-
return toResult2(result, skipped);
|
|
359
|
-
}
|
|
360
|
-
function useConversationTasksByPhonePair(phonePair) {
|
|
361
|
-
const skipped = !phonePair;
|
|
362
|
-
const result = usePersistentQuery(
|
|
363
|
-
conversationTasksListByPhonePairRef,
|
|
364
|
-
skipped ? SKIP2 : { phonePair }
|
|
365
|
-
);
|
|
366
|
-
return toResult2(result, skipped);
|
|
367
|
-
}
|
|
128
|
+
// src/react/offline/use-persistent-query.ts
|
|
129
|
+
var import_react_query3 = require("@convex-dev/react-query");
|
|
130
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
368
131
|
|
|
369
|
-
// src/react/
|
|
370
|
-
var
|
|
132
|
+
// src/react/queries-ready.ts
|
|
133
|
+
var import_react3 = require("convex/react");
|
|
371
134
|
|
|
372
135
|
// src/react/provider.ts
|
|
373
|
-
var
|
|
374
|
-
var
|
|
136
|
+
var import_react_query = require("@convex-dev/react-query");
|
|
137
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
375
138
|
var import_react_query_persist_client = require("@tanstack/react-query-persist-client");
|
|
376
|
-
var
|
|
377
|
-
var
|
|
139
|
+
var import_react = require("convex/react");
|
|
140
|
+
var import_react2 = require("react");
|
|
378
141
|
|
|
379
142
|
// src/auth-convex-client.ts
|
|
380
143
|
var import_browser = require("convex/browser");
|
|
@@ -1917,8 +1680,8 @@ var TranslationResource = class {
|
|
|
1917
1680
|
};
|
|
1918
1681
|
|
|
1919
1682
|
// src/resources/user-settings.ts
|
|
1920
|
-
var
|
|
1921
|
-
var upsertNotificationsRef = (0,
|
|
1683
|
+
var import_server = require("convex/server");
|
|
1684
|
+
var upsertNotificationsRef = (0, import_server.makeFunctionReference)("userSettings:upsertNotifications");
|
|
1922
1685
|
var UserSettingsResource = class {
|
|
1923
1686
|
constructor(convex) {
|
|
1924
1687
|
this.convex = convex;
|
|
@@ -2484,20 +2247,20 @@ function readEnv(name) {
|
|
|
2484
2247
|
const v = process.env[name];
|
|
2485
2248
|
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
2486
2249
|
}
|
|
2487
|
-
var TruthSdkContext = (0,
|
|
2250
|
+
var TruthSdkContext = (0, import_react2.createContext)(null);
|
|
2488
2251
|
function useTruthSdkContext() {
|
|
2489
|
-
return (0,
|
|
2252
|
+
return (0, import_react2.useContext)(TruthSdkContext);
|
|
2490
2253
|
}
|
|
2491
2254
|
function useOfflineStore() {
|
|
2492
2255
|
var _a, _b;
|
|
2493
|
-
return (_b = (_a = (0,
|
|
2256
|
+
return (_b = (_a = (0, import_react2.useContext)(TruthSdkContext)) == null ? void 0 : _a.offlineStore) != null ? _b : NOOP_STORE;
|
|
2494
2257
|
}
|
|
2495
2258
|
function useOfflineEnabled() {
|
|
2496
2259
|
var _a, _b;
|
|
2497
|
-
return (_b = (_a = (0,
|
|
2260
|
+
return (_b = (_a = (0, import_react2.useContext)(TruthSdkContext)) == null ? void 0 : _a.offlineEnabled) != null ? _b : false;
|
|
2498
2261
|
}
|
|
2499
2262
|
function useTruthClient() {
|
|
2500
|
-
const ctx = (0,
|
|
2263
|
+
const ctx = (0, import_react2.useContext)(TruthSdkContext);
|
|
2501
2264
|
if (!ctx) {
|
|
2502
2265
|
throw new Error(
|
|
2503
2266
|
"useTruthClient() called outside <TruthProvider>. Wrap your app in <TruthProvider> from @hipnation-truth/sdk/react."
|
|
@@ -2531,18 +2294,18 @@ function TruthProvider({
|
|
|
2531
2294
|
const url = resolveConvexUrl(environment, convexUrl);
|
|
2532
2295
|
const resolvedApiBaseUrl = (_a = apiBaseUrl != null ? apiBaseUrl : readEnv("EXPO_PUBLIC_TRUTH_API_BASE_URL")) != null ? _a : resolveApiBaseUrl(environment);
|
|
2533
2296
|
const resolvedApiKey = (_b = apiKey != null ? apiKey : readEnv("EXPO_PUBLIC_TRUTH_API_KEY")) != null ? _b : "";
|
|
2534
|
-
const convexClient = (0,
|
|
2535
|
-
const getAuthTokenRef = (0,
|
|
2297
|
+
const convexClient = (0, import_react2.useMemo)(() => new import_react.ConvexReactClient(url), [url]);
|
|
2298
|
+
const getAuthTokenRef = (0, import_react2.useRef)(getAuthToken);
|
|
2536
2299
|
getAuthTokenRef.current = getAuthToken;
|
|
2537
2300
|
const hasAuthFetcher = Boolean(getAuthToken);
|
|
2538
|
-
const stableGetAuthToken = (0,
|
|
2301
|
+
const stableGetAuthToken = (0, import_react2.useMemo)(
|
|
2539
2302
|
() => hasAuthFetcher ? () => __async(null, null, function* () {
|
|
2540
2303
|
var _a2, _b2;
|
|
2541
2304
|
return (_b2 = yield (_a2 = getAuthTokenRef.current) == null ? void 0 : _a2.call(getAuthTokenRef)) != null ? _b2 : null;
|
|
2542
2305
|
}) : void 0,
|
|
2543
2306
|
[hasAuthFetcher]
|
|
2544
2307
|
);
|
|
2545
|
-
(0,
|
|
2308
|
+
(0, import_react2.useEffect)(() => {
|
|
2546
2309
|
if (stableGetAuthToken) {
|
|
2547
2310
|
convexClient.setAuth(() => __async(null, null, function* () {
|
|
2548
2311
|
var _a2;
|
|
@@ -2552,12 +2315,12 @@ function TruthProvider({
|
|
|
2552
2315
|
convexClient.clearAuth();
|
|
2553
2316
|
}
|
|
2554
2317
|
}, [convexClient, stableGetAuthToken]);
|
|
2555
|
-
const convexQueryClient = (0,
|
|
2556
|
-
() => new
|
|
2318
|
+
const convexQueryClient = (0, import_react2.useMemo)(
|
|
2319
|
+
() => new import_react_query.ConvexQueryClient(convexClient),
|
|
2557
2320
|
[convexClient]
|
|
2558
2321
|
);
|
|
2559
|
-
const queryClient = (0,
|
|
2560
|
-
return new
|
|
2322
|
+
const queryClient = (0, import_react2.useMemo)(() => {
|
|
2323
|
+
return new import_react_query2.QueryClient({
|
|
2561
2324
|
defaultOptions: {
|
|
2562
2325
|
queries: {
|
|
2563
2326
|
queryKeyHashFn: convexQueryClient.hashFn(),
|
|
@@ -2570,18 +2333,18 @@ function TruthProvider({
|
|
|
2570
2333
|
}
|
|
2571
2334
|
});
|
|
2572
2335
|
}, [convexQueryClient]);
|
|
2573
|
-
const connectedClientRef = (0,
|
|
2574
|
-
(0,
|
|
2336
|
+
const connectedClientRef = (0, import_react2.useRef)(null);
|
|
2337
|
+
(0, import_react2.useEffect)(() => {
|
|
2575
2338
|
if (connectedClientRef.current !== convexQueryClient) {
|
|
2576
2339
|
convexQueryClient.connect(queryClient);
|
|
2577
2340
|
connectedClientRef.current = convexQueryClient;
|
|
2578
2341
|
}
|
|
2579
2342
|
}, [convexQueryClient, queryClient]);
|
|
2580
|
-
const persister = (0,
|
|
2343
|
+
const persister = (0, import_react2.useMemo)(
|
|
2581
2344
|
() => offlineEnabled && !isNoopStore(offlineStore) ? createOfflinePersister(offlineStore) : void 0,
|
|
2582
2345
|
[offlineEnabled, offlineStore]
|
|
2583
2346
|
);
|
|
2584
|
-
const truthClient = (0,
|
|
2347
|
+
const truthClient = (0, import_react2.useMemo)(
|
|
2585
2348
|
() => new TruthClient({
|
|
2586
2349
|
// Pin the resource client to the SAME deployment the React hooks
|
|
2587
2350
|
// use; without this it falls back to CONVEX_URLS[environment] and a
|
|
@@ -2607,7 +2370,7 @@ function TruthProvider({
|
|
|
2607
2370
|
stableGetAuthToken
|
|
2608
2371
|
]
|
|
2609
2372
|
);
|
|
2610
|
-
(0,
|
|
2373
|
+
(0, import_react2.useEffect)(() => {
|
|
2611
2374
|
_activeClient = truthClient;
|
|
2612
2375
|
return () => {
|
|
2613
2376
|
if (_activeClient === truthClient) {
|
|
@@ -2617,14 +2380,15 @@ function TruthProvider({
|
|
|
2617
2380
|
});
|
|
2618
2381
|
};
|
|
2619
2382
|
}, [truthClient]);
|
|
2620
|
-
const sdkContext = (0,
|
|
2383
|
+
const sdkContext = (0, import_react2.useMemo)(
|
|
2621
2384
|
() => ({
|
|
2622
2385
|
apiBaseUrl: resolvedApiBaseUrl,
|
|
2623
2386
|
apiKey: resolvedApiKey,
|
|
2624
2387
|
environment,
|
|
2625
2388
|
client: truthClient,
|
|
2626
2389
|
offlineStore,
|
|
2627
|
-
offlineEnabled
|
|
2390
|
+
offlineEnabled,
|
|
2391
|
+
authGated: hasAuthFetcher
|
|
2628
2392
|
}),
|
|
2629
2393
|
[
|
|
2630
2394
|
resolvedApiBaseUrl,
|
|
@@ -2632,15 +2396,16 @@ function TruthProvider({
|
|
|
2632
2396
|
environment,
|
|
2633
2397
|
truthClient,
|
|
2634
2398
|
offlineStore,
|
|
2635
|
-
offlineEnabled
|
|
2399
|
+
offlineEnabled,
|
|
2400
|
+
hasAuthFetcher
|
|
2636
2401
|
]
|
|
2637
2402
|
);
|
|
2638
|
-
const convexTree = (0,
|
|
2639
|
-
|
|
2403
|
+
const convexTree = (0, import_react2.createElement)(
|
|
2404
|
+
import_react.ConvexProvider,
|
|
2640
2405
|
{ client: convexClient },
|
|
2641
2406
|
children
|
|
2642
2407
|
);
|
|
2643
|
-
const queryTree = persister ? (0,
|
|
2408
|
+
const queryTree = persister ? (0, import_react2.createElement)(
|
|
2644
2409
|
import_react_query_persist_client.PersistQueryClientProvider,
|
|
2645
2410
|
{
|
|
2646
2411
|
client: queryClient,
|
|
@@ -2653,15 +2418,266 @@ function TruthProvider({
|
|
|
2653
2418
|
}
|
|
2654
2419
|
},
|
|
2655
2420
|
convexTree
|
|
2656
|
-
) : (0,
|
|
2657
|
-
return (0,
|
|
2421
|
+
) : (0, import_react2.createElement)(import_react_query2.QueryClientProvider, { client: queryClient }, convexTree);
|
|
2422
|
+
return (0, import_react2.createElement)(
|
|
2658
2423
|
TruthSdkContext.Provider,
|
|
2659
2424
|
{ value: sdkContext },
|
|
2660
2425
|
queryTree
|
|
2661
2426
|
);
|
|
2662
2427
|
}
|
|
2663
2428
|
|
|
2429
|
+
// src/react/queries-ready.ts
|
|
2430
|
+
function useConvexQueriesReady() {
|
|
2431
|
+
var _a, _b;
|
|
2432
|
+
const authGated = (_b = (_a = useTruthSdkContext()) == null ? void 0 : _a.authGated) != null ? _b : false;
|
|
2433
|
+
const { isAuthenticated } = (0, import_react3.useConvexAuth)();
|
|
2434
|
+
return !authGated || isAuthenticated;
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
// src/react/offline/use-persistent-query.ts
|
|
2438
|
+
function usePersistentQuery(ref, args) {
|
|
2439
|
+
const ready = useConvexQueriesReady();
|
|
2440
|
+
const effectiveArgs = ready ? args : "skip";
|
|
2441
|
+
const { data } = (0, import_react_query4.useQuery)(
|
|
2442
|
+
(0, import_react_query3.convexQuery)(
|
|
2443
|
+
ref,
|
|
2444
|
+
effectiveArgs
|
|
2445
|
+
)
|
|
2446
|
+
);
|
|
2447
|
+
return data;
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
// src/react/calls.ts
|
|
2451
|
+
var DialpadCallState = {
|
|
2452
|
+
Calling: "calling",
|
|
2453
|
+
Ringing: "ringing",
|
|
2454
|
+
Connected: "connected",
|
|
2455
|
+
Hold: "hold",
|
|
2456
|
+
Hangup: "hangup",
|
|
2457
|
+
Missed: "missed",
|
|
2458
|
+
VoicemailUploaded: "voicemail_uploaded"
|
|
2459
|
+
};
|
|
2460
|
+
var RINGING_CALL_STATES = /* @__PURE__ */ new Set([
|
|
2461
|
+
DialpadCallState.Calling,
|
|
2462
|
+
DialpadCallState.Ringing
|
|
2463
|
+
]);
|
|
2464
|
+
var CONNECTED_CALL_STATES = /* @__PURE__ */ new Set([
|
|
2465
|
+
DialpadCallState.Connected
|
|
2466
|
+
]);
|
|
2467
|
+
var ACTIVE_CALL_STATES = /* @__PURE__ */ new Set([
|
|
2468
|
+
...RINGING_CALL_STATES,
|
|
2469
|
+
...CONNECTED_CALL_STATES
|
|
2470
|
+
]);
|
|
2471
|
+
var TERMINAL_CALL_STATES = /* @__PURE__ */ new Set([
|
|
2472
|
+
DialpadCallState.Hangup,
|
|
2473
|
+
DialpadCallState.Missed,
|
|
2474
|
+
DialpadCallState.VoicemailUploaded
|
|
2475
|
+
]);
|
|
2476
|
+
var listActiveRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:listActive");
|
|
2477
|
+
var listForConversationRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:listForConversation");
|
|
2478
|
+
var getByCallIdRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:getByCallId");
|
|
2479
|
+
var listLogForCallIdRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:listLogForCallId");
|
|
2480
|
+
var SKIP = "skip";
|
|
2481
|
+
function toResult(value, skipped) {
|
|
2482
|
+
if (skipped) {
|
|
2483
|
+
return { data: void 0, loading: false, error: void 0 };
|
|
2484
|
+
}
|
|
2485
|
+
return {
|
|
2486
|
+
data: value,
|
|
2487
|
+
loading: value === void 0,
|
|
2488
|
+
error: void 0
|
|
2489
|
+
};
|
|
2490
|
+
}
|
|
2491
|
+
function useActiveCalls(options) {
|
|
2492
|
+
const ready = useConvexQueriesReady();
|
|
2493
|
+
const result = (0, import_react4.useQuery)(listActiveRef, ready ? options != null ? options : {} : "skip");
|
|
2494
|
+
return toResult(result, false);
|
|
2495
|
+
}
|
|
2496
|
+
function useDialpadCallsForConversation(conversationId, options) {
|
|
2497
|
+
const skipped = !conversationId;
|
|
2498
|
+
const result = usePersistentQuery(
|
|
2499
|
+
listForConversationRef,
|
|
2500
|
+
skipped ? SKIP : {
|
|
2501
|
+
conversationId,
|
|
2502
|
+
limit: options == null ? void 0 : options.limit
|
|
2503
|
+
}
|
|
2504
|
+
);
|
|
2505
|
+
return toResult(result, skipped);
|
|
2506
|
+
}
|
|
2507
|
+
function useDialpadCallByCallId(callId) {
|
|
2508
|
+
const skipped = !callId;
|
|
2509
|
+
const result = usePersistentQuery(
|
|
2510
|
+
getByCallIdRef,
|
|
2511
|
+
skipped ? SKIP : { callId }
|
|
2512
|
+
);
|
|
2513
|
+
return toResult(result, skipped);
|
|
2514
|
+
}
|
|
2515
|
+
function useDialpadCallLog(callId, options) {
|
|
2516
|
+
const skipped = !callId;
|
|
2517
|
+
const result = usePersistentQuery(
|
|
2518
|
+
listLogForCallIdRef,
|
|
2519
|
+
skipped ? SKIP : { callId, limit: options == null ? void 0 : options.limit }
|
|
2520
|
+
);
|
|
2521
|
+
return toResult(result, skipped);
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
// src/react/conversation-by-id.ts
|
|
2525
|
+
var import_server3 = require("convex/server");
|
|
2526
|
+
var conversationsGetByIdRef = (0, import_server3.makeFunctionReference)("conversations:getById");
|
|
2527
|
+
function useConversationById(id) {
|
|
2528
|
+
const skipped = !id;
|
|
2529
|
+
const result = usePersistentQuery(
|
|
2530
|
+
conversationsGetByIdRef,
|
|
2531
|
+
skipped ? "skip" : { id }
|
|
2532
|
+
);
|
|
2533
|
+
if (skipped) {
|
|
2534
|
+
return { data: void 0, loading: false, error: void 0 };
|
|
2535
|
+
}
|
|
2536
|
+
return {
|
|
2537
|
+
data: result,
|
|
2538
|
+
loading: result === void 0,
|
|
2539
|
+
error: void 0
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
// src/react/conversations.ts
|
|
2544
|
+
var import_server4 = require("convex/server");
|
|
2545
|
+
var import_react5 = require("react");
|
|
2546
|
+
var conversationsListForUserRef = (0, import_server4.makeFunctionReference)("conversations:listForUser");
|
|
2547
|
+
var conversationsSearchForUserRef = (0, import_server4.makeFunctionReference)("conversations:searchForUser");
|
|
2548
|
+
var conversationsGetUnreadTotalForUserRef = (0, import_server4.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
2549
|
+
var conversationsGetUnreadAggregateForUserRef = (0, import_server4.makeFunctionReference)("conversations:getUnreadAggregateForUser");
|
|
2550
|
+
var conversationsGetByPhonePairRef = (0, import_server4.makeFunctionReference)("conversations:getByPhonePair");
|
|
2551
|
+
var conversationMessagesGetByConversationIdRef = (0, import_server4.makeFunctionReference)("conversationMessages:getByConversationId");
|
|
2552
|
+
var conversationNotesListForConversationRef = (0, import_server4.makeFunctionReference)("conversationNotes:listForConversation");
|
|
2553
|
+
var conversationTasksListForConversationRef = (0, import_server4.makeFunctionReference)("conversationTasks:listForConversation");
|
|
2554
|
+
var conversationNotesListByPhonePairRef = (0, import_server4.makeFunctionReference)("conversationNotes:listByPhonePair");
|
|
2555
|
+
var conversationTasksListByPhonePairRef = (0, import_server4.makeFunctionReference)("conversationTasks:listByPhonePair");
|
|
2556
|
+
var conversationTasksListForUserRef = (0, import_server4.makeFunctionReference)("conversationTasks:listForUser");
|
|
2557
|
+
var SKIP2 = "skip";
|
|
2558
|
+
function toResult2(value, skipped) {
|
|
2559
|
+
if (skipped) {
|
|
2560
|
+
return { data: void 0, loading: false, error: void 0 };
|
|
2561
|
+
}
|
|
2562
|
+
return {
|
|
2563
|
+
data: value,
|
|
2564
|
+
loading: value === void 0,
|
|
2565
|
+
error: void 0
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2568
|
+
function useConversations(filters) {
|
|
2569
|
+
var _a, _b;
|
|
2570
|
+
const trimmedSearch = (_b = (_a = filters.search) == null ? void 0 : _a.trim()) != null ? _b : "";
|
|
2571
|
+
const isSearchMode = trimmedSearch.length > 0;
|
|
2572
|
+
const skipped = !filters.userId;
|
|
2573
|
+
const listResult = usePersistentQuery(
|
|
2574
|
+
conversationsListForUserRef,
|
|
2575
|
+
skipped || isSearchMode ? SKIP2 : {
|
|
2576
|
+
userId: filters.userId,
|
|
2577
|
+
limit: filters.limit
|
|
2578
|
+
}
|
|
2579
|
+
);
|
|
2580
|
+
const searchResult = usePersistentQuery(
|
|
2581
|
+
conversationsSearchForUserRef,
|
|
2582
|
+
skipped || !isSearchMode ? SKIP2 : {
|
|
2583
|
+
userId: filters.userId,
|
|
2584
|
+
search: trimmedSearch,
|
|
2585
|
+
limit: filters.limit
|
|
2586
|
+
}
|
|
2587
|
+
);
|
|
2588
|
+
return toResult2(isSearchMode ? searchResult : listResult, skipped);
|
|
2589
|
+
}
|
|
2590
|
+
function useConversationByPhonePair(phonePair) {
|
|
2591
|
+
const skipped = !phonePair;
|
|
2592
|
+
const result = usePersistentQuery(
|
|
2593
|
+
conversationsGetByPhonePairRef,
|
|
2594
|
+
skipped ? SKIP2 : { phonePair }
|
|
2595
|
+
);
|
|
2596
|
+
return toResult2(result, skipped);
|
|
2597
|
+
}
|
|
2598
|
+
function useMessages(conversationId, options) {
|
|
2599
|
+
const skipped = !conversationId;
|
|
2600
|
+
const result = usePersistentQuery(
|
|
2601
|
+
conversationMessagesGetByConversationIdRef,
|
|
2602
|
+
skipped ? SKIP2 : {
|
|
2603
|
+
conversationId,
|
|
2604
|
+
limit: options == null ? void 0 : options.limit
|
|
2605
|
+
}
|
|
2606
|
+
);
|
|
2607
|
+
return toResult2(result, skipped);
|
|
2608
|
+
}
|
|
2609
|
+
function useUnreadCount(userId) {
|
|
2610
|
+
const skipped = !userId;
|
|
2611
|
+
const result = usePersistentQuery(
|
|
2612
|
+
conversationsGetUnreadTotalForUserRef,
|
|
2613
|
+
skipped ? SKIP2 : { userId }
|
|
2614
|
+
);
|
|
2615
|
+
return toResult2(result, skipped);
|
|
2616
|
+
}
|
|
2617
|
+
function useUnreadAggregate(userId, options) {
|
|
2618
|
+
const skipped = !userId;
|
|
2619
|
+
const phones = options == null ? void 0 : options.providerPhones;
|
|
2620
|
+
const stablePhones = useMemoizedPhones(phones);
|
|
2621
|
+
const result = usePersistentQuery(
|
|
2622
|
+
conversationsGetUnreadAggregateForUserRef,
|
|
2623
|
+
skipped ? SKIP2 : {
|
|
2624
|
+
userId,
|
|
2625
|
+
providerPhones: stablePhones
|
|
2626
|
+
}
|
|
2627
|
+
);
|
|
2628
|
+
return toResult2(result, skipped);
|
|
2629
|
+
}
|
|
2630
|
+
function useMemoizedPhones(phones) {
|
|
2631
|
+
const key = phones ? [...phones].sort().join("|") : "";
|
|
2632
|
+
return (0, import_react5.useMemo)(
|
|
2633
|
+
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
2634
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2635
|
+
[key]
|
|
2636
|
+
);
|
|
2637
|
+
}
|
|
2638
|
+
function useConversationNotes(conversationId) {
|
|
2639
|
+
const skipped = !conversationId;
|
|
2640
|
+
const result = usePersistentQuery(
|
|
2641
|
+
conversationNotesListForConversationRef,
|
|
2642
|
+
skipped ? SKIP2 : { conversationId }
|
|
2643
|
+
);
|
|
2644
|
+
return toResult2(result, skipped);
|
|
2645
|
+
}
|
|
2646
|
+
function useConversationTasks(conversationId) {
|
|
2647
|
+
const skipped = !conversationId;
|
|
2648
|
+
const result = usePersistentQuery(
|
|
2649
|
+
conversationTasksListForConversationRef,
|
|
2650
|
+
skipped ? SKIP2 : { conversationId }
|
|
2651
|
+
);
|
|
2652
|
+
return toResult2(result, skipped);
|
|
2653
|
+
}
|
|
2654
|
+
function useConversationNotesByPhonePair(phonePair) {
|
|
2655
|
+
const skipped = !phonePair;
|
|
2656
|
+
const result = usePersistentQuery(
|
|
2657
|
+
conversationNotesListByPhonePairRef,
|
|
2658
|
+
skipped ? SKIP2 : { phonePair }
|
|
2659
|
+
);
|
|
2660
|
+
return toResult2(result, skipped);
|
|
2661
|
+
}
|
|
2662
|
+
function useConversationTasksForUser(userId, options) {
|
|
2663
|
+
const skipped = !userId;
|
|
2664
|
+
const result = usePersistentQuery(
|
|
2665
|
+
conversationTasksListForUserRef,
|
|
2666
|
+
skipped ? SKIP2 : { userId, limit: options == null ? void 0 : options.limit }
|
|
2667
|
+
);
|
|
2668
|
+
return toResult2(result, skipped);
|
|
2669
|
+
}
|
|
2670
|
+
function useConversationTasksByPhonePair(phonePair) {
|
|
2671
|
+
const skipped = !phonePair;
|
|
2672
|
+
const result = usePersistentQuery(
|
|
2673
|
+
conversationTasksListByPhonePairRef,
|
|
2674
|
+
skipped ? SKIP2 : { phonePair }
|
|
2675
|
+
);
|
|
2676
|
+
return toResult2(result, skipped);
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2664
2679
|
// src/react/hooks.ts
|
|
2680
|
+
var import_react6 = require("react");
|
|
2665
2681
|
var import_server5 = require("convex/server");
|
|
2666
2682
|
var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
|
|
2667
2683
|
var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
|
|
@@ -2739,7 +2755,7 @@ function usePatientMedical(elationId, options) {
|
|
|
2739
2755
|
appointmentsByPatientRef,
|
|
2740
2756
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2741
2757
|
);
|
|
2742
|
-
(0,
|
|
2758
|
+
(0, import_react6.useEffect)(() => {
|
|
2743
2759
|
if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2744
2760
|
return;
|
|
2745
2761
|
}
|
|
@@ -2778,7 +2794,7 @@ function usePatientBasic(input, options) {
|
|
|
2778
2794
|
hintPatientByIdRef,
|
|
2779
2795
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
2780
2796
|
);
|
|
2781
|
-
(0,
|
|
2797
|
+
(0, import_react6.useEffect)(() => {
|
|
2782
2798
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2783
2799
|
return;
|
|
2784
2800
|
}
|
|
@@ -2831,7 +2847,7 @@ function usePatientPhoto(elationId, options) {
|
|
|
2831
2847
|
patientPhotoByIdRef,
|
|
2832
2848
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2833
2849
|
);
|
|
2834
|
-
(0,
|
|
2850
|
+
(0, import_react6.useEffect)(() => {
|
|
2835
2851
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2836
2852
|
return;
|
|
2837
2853
|
}
|
|
@@ -2876,7 +2892,7 @@ function useConversationMessages(input, options) {
|
|
|
2876
2892
|
}
|
|
2877
2893
|
|
|
2878
2894
|
// src/react/notifications.ts
|
|
2879
|
-
var
|
|
2895
|
+
var import_react7 = require("react");
|
|
2880
2896
|
function loadExpo() {
|
|
2881
2897
|
return __async(this, null, function* () {
|
|
2882
2898
|
try {
|
|
@@ -2891,12 +2907,12 @@ function useNotifications(options) {
|
|
|
2891
2907
|
const sdkContext = useTruthSdkContext();
|
|
2892
2908
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
2893
2909
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
2894
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
2895
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
2896
|
-
const expoRef = (0,
|
|
2897
|
-
const isWebRef = (0,
|
|
2898
|
-
const vapidKeyRef = (0,
|
|
2899
|
-
(0,
|
|
2910
|
+
const [permissionStatus, setPermissionStatus] = (0, import_react7.useState)("unknown");
|
|
2911
|
+
const [devicePushToken, setDevicePushToken] = (0, import_react7.useState)(null);
|
|
2912
|
+
const expoRef = (0, import_react7.useRef)(null);
|
|
2913
|
+
const isWebRef = (0, import_react7.useRef)(false);
|
|
2914
|
+
const vapidKeyRef = (0, import_react7.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
|
|
2915
|
+
(0, import_react7.useEffect)(() => {
|
|
2900
2916
|
let mounted = true;
|
|
2901
2917
|
void (() => __async(null, null, function* () {
|
|
2902
2918
|
var _a2;
|
|
@@ -2952,7 +2968,7 @@ function useNotifications(options) {
|
|
|
2952
2968
|
mounted = false;
|
|
2953
2969
|
};
|
|
2954
2970
|
}, [apiBaseUrl, apiKey]);
|
|
2955
|
-
const register = (0,
|
|
2971
|
+
const register = (0, import_react7.useCallback)(() => __async(null, null, function* () {
|
|
2956
2972
|
var _a2, _b2;
|
|
2957
2973
|
if (!options.userId) {
|
|
2958
2974
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3065,7 +3081,7 @@ function useNotifications(options) {
|
|
|
3065
3081
|
options.appVersion,
|
|
3066
3082
|
options.serviceWorkerPath
|
|
3067
3083
|
]);
|
|
3068
|
-
const unregister = (0,
|
|
3084
|
+
const unregister = (0, import_react7.useCallback)(() => __async(null, null, function* () {
|
|
3069
3085
|
if (!devicePushToken) {
|
|
3070
3086
|
return;
|
|
3071
3087
|
}
|
|
@@ -3080,7 +3096,7 @@ function useNotifications(options) {
|
|
|
3080
3096
|
});
|
|
3081
3097
|
setDevicePushToken(null);
|
|
3082
3098
|
}), [apiBaseUrl, apiKey, devicePushToken]);
|
|
3083
|
-
const addReceivedListener = (0,
|
|
3099
|
+
const addReceivedListener = (0, import_react7.useCallback)(
|
|
3084
3100
|
(listener) => {
|
|
3085
3101
|
if (isWebRef.current) {
|
|
3086
3102
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3109,7 +3125,7 @@ function useNotifications(options) {
|
|
|
3109
3125
|
},
|
|
3110
3126
|
[]
|
|
3111
3127
|
);
|
|
3112
|
-
const addResponseListener = (0,
|
|
3128
|
+
const addResponseListener = (0, import_react7.useCallback)(
|
|
3113
3129
|
(listener) => {
|
|
3114
3130
|
if (isWebRef.current) {
|
|
3115
3131
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3138,7 +3154,7 @@ function useNotifications(options) {
|
|
|
3138
3154
|
},
|
|
3139
3155
|
[]
|
|
3140
3156
|
);
|
|
3141
|
-
const getBadgeCount = (0,
|
|
3157
|
+
const getBadgeCount = (0, import_react7.useCallback)(() => __async(null, null, function* () {
|
|
3142
3158
|
var _a2;
|
|
3143
3159
|
const expo = expoRef.current;
|
|
3144
3160
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3146,7 +3162,7 @@ function useNotifications(options) {
|
|
|
3146
3162
|
}
|
|
3147
3163
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3148
3164
|
}), []);
|
|
3149
|
-
const setBadgeCount = (0,
|
|
3165
|
+
const setBadgeCount = (0, import_react7.useCallback)((count) => __async(null, null, function* () {
|
|
3150
3166
|
const expo = expoRef.current;
|
|
3151
3167
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3152
3168
|
return;
|
|
@@ -3154,7 +3170,7 @@ function useNotifications(options) {
|
|
|
3154
3170
|
yield expo.setBadgeCountAsync(count);
|
|
3155
3171
|
}), []);
|
|
3156
3172
|
const autoRegister = options.autoRegister !== false;
|
|
3157
|
-
(0,
|
|
3173
|
+
(0, import_react7.useEffect)(() => {
|
|
3158
3174
|
if (!autoRegister) {
|
|
3159
3175
|
return;
|
|
3160
3176
|
}
|
|
@@ -3191,7 +3207,7 @@ function useNotificationsActions() {
|
|
|
3191
3207
|
const sdkContext = useTruthSdkContext();
|
|
3192
3208
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3193
3209
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3194
|
-
const post = (0,
|
|
3210
|
+
const post = (0, import_react7.useCallback)(
|
|
3195
3211
|
(path, body) => __async(null, null, function* () {
|
|
3196
3212
|
if (!apiBaseUrl || !apiKey) {
|
|
3197
3213
|
throw new Error(
|
|
@@ -3217,7 +3233,7 @@ function useNotificationsActions() {
|
|
|
3217
3233
|
}),
|
|
3218
3234
|
[apiBaseUrl, apiKey]
|
|
3219
3235
|
);
|
|
3220
|
-
const get = (0,
|
|
3236
|
+
const get = (0, import_react7.useCallback)(
|
|
3221
3237
|
(path) => __async(null, null, function* () {
|
|
3222
3238
|
const res = yield fetch(`${apiBaseUrl}/api${path}`, {
|
|
3223
3239
|
method: "GET",
|
|
@@ -3233,21 +3249,21 @@ function useNotificationsActions() {
|
|
|
3233
3249
|
}),
|
|
3234
3250
|
[apiBaseUrl, apiKey]
|
|
3235
3251
|
);
|
|
3236
|
-
const send = (0,
|
|
3252
|
+
const send = (0, import_react7.useCallback)(
|
|
3237
3253
|
(input) => post("/notifications/send", input),
|
|
3238
3254
|
[post]
|
|
3239
3255
|
);
|
|
3240
|
-
const schedule = (0,
|
|
3256
|
+
const schedule = (0, import_react7.useCallback)(
|
|
3241
3257
|
(input) => post("/notifications/schedule", input),
|
|
3242
3258
|
[post]
|
|
3243
3259
|
);
|
|
3244
|
-
const getPreferences = (0,
|
|
3260
|
+
const getPreferences = (0, import_react7.useCallback)(
|
|
3245
3261
|
(userId) => get(
|
|
3246
3262
|
`/notifications/preferences/${encodeURIComponent(userId)}`
|
|
3247
3263
|
),
|
|
3248
3264
|
[get]
|
|
3249
3265
|
);
|
|
3250
|
-
const updatePreferences = (0,
|
|
3266
|
+
const updatePreferences = (0, import_react7.useCallback)(
|
|
3251
3267
|
(userId, prefs) => post(
|
|
3252
3268
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3253
3269
|
prefs
|
|
@@ -3330,12 +3346,12 @@ function usePatientSearch(options) {
|
|
|
3330
3346
|
|
|
3331
3347
|
// src/react/patients-bulk.ts
|
|
3332
3348
|
var import_server8 = require("convex/server");
|
|
3333
|
-
var
|
|
3349
|
+
var import_react8 = require("react");
|
|
3334
3350
|
var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
|
|
3335
3351
|
var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
|
|
3336
3352
|
var SKIP5 = "skip";
|
|
3337
3353
|
function usePatientsByIds(ids) {
|
|
3338
|
-
const stableIds = (0,
|
|
3354
|
+
const stableIds = (0, import_react8.useMemo)(() => {
|
|
3339
3355
|
const arr = ids != null ? ids : [];
|
|
3340
3356
|
return [...new Set(arr)].sort();
|
|
3341
3357
|
}, [ids]);
|
|
@@ -3344,7 +3360,7 @@ function usePatientsByIds(ids) {
|
|
|
3344
3360
|
patientsGetByIdsRef,
|
|
3345
3361
|
skipped ? SKIP5 : { ids: stableIds }
|
|
3346
3362
|
);
|
|
3347
|
-
const mapped = (0,
|
|
3363
|
+
const mapped = (0, import_react8.useMemo)(() => {
|
|
3348
3364
|
if (result === void 0) {
|
|
3349
3365
|
return void 0;
|
|
3350
3366
|
}
|
|
@@ -3366,7 +3382,7 @@ function usePatientsByIds(ids) {
|
|
|
3366
3382
|
};
|
|
3367
3383
|
}
|
|
3368
3384
|
function usePatientsByPhones(phones) {
|
|
3369
|
-
const stableDigits = (0,
|
|
3385
|
+
const stableDigits = (0, import_react8.useMemo)(() => {
|
|
3370
3386
|
const arr = phones != null ? phones : [];
|
|
3371
3387
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3372
3388
|
return [...new Set(digits)].sort();
|
|
@@ -3376,7 +3392,7 @@ function usePatientsByPhones(phones) {
|
|
|
3376
3392
|
patientsGetByPhonesRef,
|
|
3377
3393
|
skipped ? SKIP5 : { phoneDigits: stableDigits }
|
|
3378
3394
|
);
|
|
3379
|
-
const mapped = (0,
|
|
3395
|
+
const mapped = (0, import_react8.useMemo)(() => {
|
|
3380
3396
|
if (result === void 0) {
|
|
3381
3397
|
return void 0;
|
|
3382
3398
|
}
|
|
@@ -3415,23 +3431,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3415
3431
|
}
|
|
3416
3432
|
|
|
3417
3433
|
// src/react/tasks.ts
|
|
3418
|
-
var
|
|
3434
|
+
var import_react9 = require("convex/react");
|
|
3419
3435
|
var import_server10 = require("convex/server");
|
|
3420
|
-
var
|
|
3436
|
+
var import_react10 = require("react");
|
|
3421
3437
|
var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
|
|
3422
3438
|
function useConversationTaskMarkSeen() {
|
|
3423
|
-
const mutate = (0,
|
|
3439
|
+
const mutate = (0, import_react9.useMutation)(
|
|
3424
3440
|
conversationTasksMarkSeenRef
|
|
3425
3441
|
);
|
|
3426
|
-
return (0,
|
|
3442
|
+
return (0, import_react10.useCallback)(
|
|
3427
3443
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3428
3444
|
[mutate]
|
|
3429
3445
|
);
|
|
3430
3446
|
}
|
|
3431
3447
|
|
|
3432
3448
|
// src/react/tracking.ts
|
|
3433
|
-
var
|
|
3434
|
-
var TruthTrackingContext = (0,
|
|
3449
|
+
var import_react11 = require("react");
|
|
3450
|
+
var TruthTrackingContext = (0, import_react11.createContext)(
|
|
3435
3451
|
null
|
|
3436
3452
|
);
|
|
3437
3453
|
function TruthTrackingProvider({
|
|
@@ -3444,7 +3460,7 @@ function TruthTrackingProvider({
|
|
|
3444
3460
|
}) {
|
|
3445
3461
|
var _a, _b;
|
|
3446
3462
|
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 : "";
|
|
3447
|
-
const value = (0,
|
|
3463
|
+
const value = (0, import_react11.useMemo)(() => {
|
|
3448
3464
|
const tracker = new Tracker({
|
|
3449
3465
|
apiKey: resolvedApiKey,
|
|
3450
3466
|
environment,
|
|
@@ -3463,10 +3479,10 @@ function TruthTrackingProvider({
|
|
|
3463
3479
|
}
|
|
3464
3480
|
};
|
|
3465
3481
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3466
|
-
return (0,
|
|
3482
|
+
return (0, import_react11.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3467
3483
|
}
|
|
3468
3484
|
function useTruth() {
|
|
3469
|
-
const ctx = (0,
|
|
3485
|
+
const ctx = (0, import_react11.useContext)(TruthTrackingContext);
|
|
3470
3486
|
if (!ctx) {
|
|
3471
3487
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3472
3488
|
}
|
|
@@ -3494,15 +3510,15 @@ function useUserSettings(userId) {
|
|
|
3494
3510
|
}
|
|
3495
3511
|
|
|
3496
3512
|
// src/react/users.ts
|
|
3497
|
-
var
|
|
3513
|
+
var import_react12 = require("react");
|
|
3498
3514
|
function useUserSync(input) {
|
|
3499
3515
|
var _a, _b, _c, _d;
|
|
3500
3516
|
const sdkContext = useTruthSdkContext();
|
|
3501
3517
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3502
3518
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3503
|
-
const [status, setStatus] = (0,
|
|
3504
|
-
const [error, setError] = (0,
|
|
3505
|
-
const lastKeyRef = (0,
|
|
3519
|
+
const [status, setStatus] = (0, import_react12.useState)("idle");
|
|
3520
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
3521
|
+
const lastKeyRef = (0, import_react12.useRef)(null);
|
|
3506
3522
|
const sync = () => __async(null, null, function* () {
|
|
3507
3523
|
if (!input.userId) {
|
|
3508
3524
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3545,7 +3561,7 @@ function useUserSync(input) {
|
|
|
3545
3561
|
return { ok: false, reason: message };
|
|
3546
3562
|
}
|
|
3547
3563
|
});
|
|
3548
|
-
(0,
|
|
3564
|
+
(0, import_react12.useEffect)(() => {
|
|
3549
3565
|
var _a2, _b2, _c2, _d2, _e;
|
|
3550
3566
|
if (!input.userId) {
|
|
3551
3567
|
return;
|
|
@@ -3584,13 +3600,13 @@ function useUserSync(input) {
|
|
|
3584
3600
|
}
|
|
3585
3601
|
|
|
3586
3602
|
// src/react/voicemail.ts
|
|
3587
|
-
var
|
|
3603
|
+
var import_react13 = require("react");
|
|
3588
3604
|
function useVoicemailUrl(client) {
|
|
3589
|
-
const [url, setUrl] = (0,
|
|
3590
|
-
const [isLoading, setIsLoading] = (0,
|
|
3591
|
-
const [error, setError] = (0,
|
|
3592
|
-
const inFlightRef = (0,
|
|
3593
|
-
const fetchUrl = (0,
|
|
3605
|
+
const [url, setUrl] = (0, import_react13.useState)(null);
|
|
3606
|
+
const [isLoading, setIsLoading] = (0, import_react13.useState)(false);
|
|
3607
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
3608
|
+
const inFlightRef = (0, import_react13.useRef)(false);
|
|
3609
|
+
const fetchUrl = (0, import_react13.useCallback)(
|
|
3594
3610
|
(voicemailLink) => __async(null, null, function* () {
|
|
3595
3611
|
if (inFlightRef.current) {
|
|
3596
3612
|
return null;
|