@hipnation-truth/sdk 0.26.1 → 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/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +18 -0
- package/dist/react.js +364 -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;
|
|
@@ -2240,6 +2003,7 @@ var TruthClient = class {
|
|
|
2240
2003
|
config.getAuthToken
|
|
2241
2004
|
);
|
|
2242
2005
|
this.userSettings = new UserSettingsResource(this.convex);
|
|
2006
|
+
this._getAuthToken = config.getAuthToken;
|
|
2243
2007
|
this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
|
|
2244
2008
|
if (typeof window !== "undefined" && isWebPushSupported() && config.autoInitServiceWorker !== false) {
|
|
2245
2009
|
this._webPushReady = this.initWebPush();
|
|
@@ -2251,9 +2015,33 @@ var TruthClient = class {
|
|
|
2251
2015
|
get webPushReady() {
|
|
2252
2016
|
return this._webPushReady;
|
|
2253
2017
|
}
|
|
2018
|
+
/**
|
|
2019
|
+
* When a Clerk token fetcher is configured (publishable-key clients),
|
|
2020
|
+
* the VAPID endpoint is auth-gated — calling it before the session has
|
|
2021
|
+
* hydrated 401s and strands web-push in the "no key" path. Wait
|
|
2022
|
+
* (briefly, bounded) for a token to become available first. No fetcher
|
|
2023
|
+
* → resolve immediately (secret-key path is unaffected).
|
|
2024
|
+
*/
|
|
2025
|
+
waitForAuthToken() {
|
|
2026
|
+
return __async(this, null, function* () {
|
|
2027
|
+
if (!this._getAuthToken) {
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
2031
|
+
try {
|
|
2032
|
+
if (yield this._getAuthToken()) {
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
2035
|
+
} catch (e) {
|
|
2036
|
+
}
|
|
2037
|
+
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
2038
|
+
}
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2254
2041
|
initWebPush() {
|
|
2255
2042
|
return __async(this, null, function* () {
|
|
2256
2043
|
try {
|
|
2044
|
+
yield this.waitForAuthToken();
|
|
2257
2045
|
const key = yield this.notifications.getVapidKey();
|
|
2258
2046
|
if (!key) {
|
|
2259
2047
|
return;
|
|
@@ -2459,20 +2247,20 @@ function readEnv(name) {
|
|
|
2459
2247
|
const v = process.env[name];
|
|
2460
2248
|
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
2461
2249
|
}
|
|
2462
|
-
var TruthSdkContext = (0,
|
|
2250
|
+
var TruthSdkContext = (0, import_react2.createContext)(null);
|
|
2463
2251
|
function useTruthSdkContext() {
|
|
2464
|
-
return (0,
|
|
2252
|
+
return (0, import_react2.useContext)(TruthSdkContext);
|
|
2465
2253
|
}
|
|
2466
2254
|
function useOfflineStore() {
|
|
2467
2255
|
var _a, _b;
|
|
2468
|
-
return (_b = (_a = (0,
|
|
2256
|
+
return (_b = (_a = (0, import_react2.useContext)(TruthSdkContext)) == null ? void 0 : _a.offlineStore) != null ? _b : NOOP_STORE;
|
|
2469
2257
|
}
|
|
2470
2258
|
function useOfflineEnabled() {
|
|
2471
2259
|
var _a, _b;
|
|
2472
|
-
return (_b = (_a = (0,
|
|
2260
|
+
return (_b = (_a = (0, import_react2.useContext)(TruthSdkContext)) == null ? void 0 : _a.offlineEnabled) != null ? _b : false;
|
|
2473
2261
|
}
|
|
2474
2262
|
function useTruthClient() {
|
|
2475
|
-
const ctx = (0,
|
|
2263
|
+
const ctx = (0, import_react2.useContext)(TruthSdkContext);
|
|
2476
2264
|
if (!ctx) {
|
|
2477
2265
|
throw new Error(
|
|
2478
2266
|
"useTruthClient() called outside <TruthProvider>. Wrap your app in <TruthProvider> from @hipnation-truth/sdk/react."
|
|
@@ -2506,18 +2294,18 @@ function TruthProvider({
|
|
|
2506
2294
|
const url = resolveConvexUrl(environment, convexUrl);
|
|
2507
2295
|
const resolvedApiBaseUrl = (_a = apiBaseUrl != null ? apiBaseUrl : readEnv("EXPO_PUBLIC_TRUTH_API_BASE_URL")) != null ? _a : resolveApiBaseUrl(environment);
|
|
2508
2296
|
const resolvedApiKey = (_b = apiKey != null ? apiKey : readEnv("EXPO_PUBLIC_TRUTH_API_KEY")) != null ? _b : "";
|
|
2509
|
-
const convexClient = (0,
|
|
2510
|
-
const getAuthTokenRef = (0,
|
|
2297
|
+
const convexClient = (0, import_react2.useMemo)(() => new import_react.ConvexReactClient(url), [url]);
|
|
2298
|
+
const getAuthTokenRef = (0, import_react2.useRef)(getAuthToken);
|
|
2511
2299
|
getAuthTokenRef.current = getAuthToken;
|
|
2512
2300
|
const hasAuthFetcher = Boolean(getAuthToken);
|
|
2513
|
-
const stableGetAuthToken = (0,
|
|
2301
|
+
const stableGetAuthToken = (0, import_react2.useMemo)(
|
|
2514
2302
|
() => hasAuthFetcher ? () => __async(null, null, function* () {
|
|
2515
2303
|
var _a2, _b2;
|
|
2516
2304
|
return (_b2 = yield (_a2 = getAuthTokenRef.current) == null ? void 0 : _a2.call(getAuthTokenRef)) != null ? _b2 : null;
|
|
2517
2305
|
}) : void 0,
|
|
2518
2306
|
[hasAuthFetcher]
|
|
2519
2307
|
);
|
|
2520
|
-
(0,
|
|
2308
|
+
(0, import_react2.useEffect)(() => {
|
|
2521
2309
|
if (stableGetAuthToken) {
|
|
2522
2310
|
convexClient.setAuth(() => __async(null, null, function* () {
|
|
2523
2311
|
var _a2;
|
|
@@ -2527,12 +2315,12 @@ function TruthProvider({
|
|
|
2527
2315
|
convexClient.clearAuth();
|
|
2528
2316
|
}
|
|
2529
2317
|
}, [convexClient, stableGetAuthToken]);
|
|
2530
|
-
const convexQueryClient = (0,
|
|
2531
|
-
() => new
|
|
2318
|
+
const convexQueryClient = (0, import_react2.useMemo)(
|
|
2319
|
+
() => new import_react_query.ConvexQueryClient(convexClient),
|
|
2532
2320
|
[convexClient]
|
|
2533
2321
|
);
|
|
2534
|
-
const queryClient = (0,
|
|
2535
|
-
return new
|
|
2322
|
+
const queryClient = (0, import_react2.useMemo)(() => {
|
|
2323
|
+
return new import_react_query2.QueryClient({
|
|
2536
2324
|
defaultOptions: {
|
|
2537
2325
|
queries: {
|
|
2538
2326
|
queryKeyHashFn: convexQueryClient.hashFn(),
|
|
@@ -2545,18 +2333,18 @@ function TruthProvider({
|
|
|
2545
2333
|
}
|
|
2546
2334
|
});
|
|
2547
2335
|
}, [convexQueryClient]);
|
|
2548
|
-
const connectedClientRef = (0,
|
|
2549
|
-
(0,
|
|
2336
|
+
const connectedClientRef = (0, import_react2.useRef)(null);
|
|
2337
|
+
(0, import_react2.useEffect)(() => {
|
|
2550
2338
|
if (connectedClientRef.current !== convexQueryClient) {
|
|
2551
2339
|
convexQueryClient.connect(queryClient);
|
|
2552
2340
|
connectedClientRef.current = convexQueryClient;
|
|
2553
2341
|
}
|
|
2554
2342
|
}, [convexQueryClient, queryClient]);
|
|
2555
|
-
const persister = (0,
|
|
2343
|
+
const persister = (0, import_react2.useMemo)(
|
|
2556
2344
|
() => offlineEnabled && !isNoopStore(offlineStore) ? createOfflinePersister(offlineStore) : void 0,
|
|
2557
2345
|
[offlineEnabled, offlineStore]
|
|
2558
2346
|
);
|
|
2559
|
-
const truthClient = (0,
|
|
2347
|
+
const truthClient = (0, import_react2.useMemo)(
|
|
2560
2348
|
() => new TruthClient({
|
|
2561
2349
|
// Pin the resource client to the SAME deployment the React hooks
|
|
2562
2350
|
// use; without this it falls back to CONVEX_URLS[environment] and a
|
|
@@ -2582,7 +2370,7 @@ function TruthProvider({
|
|
|
2582
2370
|
stableGetAuthToken
|
|
2583
2371
|
]
|
|
2584
2372
|
);
|
|
2585
|
-
(0,
|
|
2373
|
+
(0, import_react2.useEffect)(() => {
|
|
2586
2374
|
_activeClient = truthClient;
|
|
2587
2375
|
return () => {
|
|
2588
2376
|
if (_activeClient === truthClient) {
|
|
@@ -2592,14 +2380,15 @@ function TruthProvider({
|
|
|
2592
2380
|
});
|
|
2593
2381
|
};
|
|
2594
2382
|
}, [truthClient]);
|
|
2595
|
-
const sdkContext = (0,
|
|
2383
|
+
const sdkContext = (0, import_react2.useMemo)(
|
|
2596
2384
|
() => ({
|
|
2597
2385
|
apiBaseUrl: resolvedApiBaseUrl,
|
|
2598
2386
|
apiKey: resolvedApiKey,
|
|
2599
2387
|
environment,
|
|
2600
2388
|
client: truthClient,
|
|
2601
2389
|
offlineStore,
|
|
2602
|
-
offlineEnabled
|
|
2390
|
+
offlineEnabled,
|
|
2391
|
+
authGated: hasAuthFetcher
|
|
2603
2392
|
}),
|
|
2604
2393
|
[
|
|
2605
2394
|
resolvedApiBaseUrl,
|
|
@@ -2607,15 +2396,16 @@ function TruthProvider({
|
|
|
2607
2396
|
environment,
|
|
2608
2397
|
truthClient,
|
|
2609
2398
|
offlineStore,
|
|
2610
|
-
offlineEnabled
|
|
2399
|
+
offlineEnabled,
|
|
2400
|
+
hasAuthFetcher
|
|
2611
2401
|
]
|
|
2612
2402
|
);
|
|
2613
|
-
const convexTree = (0,
|
|
2614
|
-
|
|
2403
|
+
const convexTree = (0, import_react2.createElement)(
|
|
2404
|
+
import_react.ConvexProvider,
|
|
2615
2405
|
{ client: convexClient },
|
|
2616
2406
|
children
|
|
2617
2407
|
);
|
|
2618
|
-
const queryTree = persister ? (0,
|
|
2408
|
+
const queryTree = persister ? (0, import_react2.createElement)(
|
|
2619
2409
|
import_react_query_persist_client.PersistQueryClientProvider,
|
|
2620
2410
|
{
|
|
2621
2411
|
client: queryClient,
|
|
@@ -2628,15 +2418,266 @@ function TruthProvider({
|
|
|
2628
2418
|
}
|
|
2629
2419
|
},
|
|
2630
2420
|
convexTree
|
|
2631
|
-
) : (0,
|
|
2632
|
-
return (0,
|
|
2421
|
+
) : (0, import_react2.createElement)(import_react_query2.QueryClientProvider, { client: queryClient }, convexTree);
|
|
2422
|
+
return (0, import_react2.createElement)(
|
|
2633
2423
|
TruthSdkContext.Provider,
|
|
2634
2424
|
{ value: sdkContext },
|
|
2635
2425
|
queryTree
|
|
2636
2426
|
);
|
|
2637
2427
|
}
|
|
2638
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
|
+
|
|
2639
2679
|
// src/react/hooks.ts
|
|
2680
|
+
var import_react6 = require("react");
|
|
2640
2681
|
var import_server5 = require("convex/server");
|
|
2641
2682
|
var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
|
|
2642
2683
|
var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
|
|
@@ -2714,7 +2755,7 @@ function usePatientMedical(elationId, options) {
|
|
|
2714
2755
|
appointmentsByPatientRef,
|
|
2715
2756
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2716
2757
|
);
|
|
2717
|
-
(0,
|
|
2758
|
+
(0, import_react6.useEffect)(() => {
|
|
2718
2759
|
if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2719
2760
|
return;
|
|
2720
2761
|
}
|
|
@@ -2753,7 +2794,7 @@ function usePatientBasic(input, options) {
|
|
|
2753
2794
|
hintPatientByIdRef,
|
|
2754
2795
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
2755
2796
|
);
|
|
2756
|
-
(0,
|
|
2797
|
+
(0, import_react6.useEffect)(() => {
|
|
2757
2798
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2758
2799
|
return;
|
|
2759
2800
|
}
|
|
@@ -2806,7 +2847,7 @@ function usePatientPhoto(elationId, options) {
|
|
|
2806
2847
|
patientPhotoByIdRef,
|
|
2807
2848
|
elationId !== void 0 ? { elationPatientId: elationId } : "skip"
|
|
2808
2849
|
);
|
|
2809
|
-
(0,
|
|
2850
|
+
(0, import_react6.useEffect)(() => {
|
|
2810
2851
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
2811
2852
|
return;
|
|
2812
2853
|
}
|
|
@@ -2851,7 +2892,7 @@ function useConversationMessages(input, options) {
|
|
|
2851
2892
|
}
|
|
2852
2893
|
|
|
2853
2894
|
// src/react/notifications.ts
|
|
2854
|
-
var
|
|
2895
|
+
var import_react7 = require("react");
|
|
2855
2896
|
function loadExpo() {
|
|
2856
2897
|
return __async(this, null, function* () {
|
|
2857
2898
|
try {
|
|
@@ -2866,12 +2907,12 @@ function useNotifications(options) {
|
|
|
2866
2907
|
const sdkContext = useTruthSdkContext();
|
|
2867
2908
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
2868
2909
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
2869
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
2870
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
2871
|
-
const expoRef = (0,
|
|
2872
|
-
const isWebRef = (0,
|
|
2873
|
-
const vapidKeyRef = (0,
|
|
2874
|
-
(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)(() => {
|
|
2875
2916
|
let mounted = true;
|
|
2876
2917
|
void (() => __async(null, null, function* () {
|
|
2877
2918
|
var _a2;
|
|
@@ -2927,7 +2968,7 @@ function useNotifications(options) {
|
|
|
2927
2968
|
mounted = false;
|
|
2928
2969
|
};
|
|
2929
2970
|
}, [apiBaseUrl, apiKey]);
|
|
2930
|
-
const register = (0,
|
|
2971
|
+
const register = (0, import_react7.useCallback)(() => __async(null, null, function* () {
|
|
2931
2972
|
var _a2, _b2;
|
|
2932
2973
|
if (!options.userId) {
|
|
2933
2974
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3040,7 +3081,7 @@ function useNotifications(options) {
|
|
|
3040
3081
|
options.appVersion,
|
|
3041
3082
|
options.serviceWorkerPath
|
|
3042
3083
|
]);
|
|
3043
|
-
const unregister = (0,
|
|
3084
|
+
const unregister = (0, import_react7.useCallback)(() => __async(null, null, function* () {
|
|
3044
3085
|
if (!devicePushToken) {
|
|
3045
3086
|
return;
|
|
3046
3087
|
}
|
|
@@ -3055,7 +3096,7 @@ function useNotifications(options) {
|
|
|
3055
3096
|
});
|
|
3056
3097
|
setDevicePushToken(null);
|
|
3057
3098
|
}), [apiBaseUrl, apiKey, devicePushToken]);
|
|
3058
|
-
const addReceivedListener = (0,
|
|
3099
|
+
const addReceivedListener = (0, import_react7.useCallback)(
|
|
3059
3100
|
(listener) => {
|
|
3060
3101
|
if (isWebRef.current) {
|
|
3061
3102
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3084,7 +3125,7 @@ function useNotifications(options) {
|
|
|
3084
3125
|
},
|
|
3085
3126
|
[]
|
|
3086
3127
|
);
|
|
3087
|
-
const addResponseListener = (0,
|
|
3128
|
+
const addResponseListener = (0, import_react7.useCallback)(
|
|
3088
3129
|
(listener) => {
|
|
3089
3130
|
if (isWebRef.current) {
|
|
3090
3131
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3113,7 +3154,7 @@ function useNotifications(options) {
|
|
|
3113
3154
|
},
|
|
3114
3155
|
[]
|
|
3115
3156
|
);
|
|
3116
|
-
const getBadgeCount = (0,
|
|
3157
|
+
const getBadgeCount = (0, import_react7.useCallback)(() => __async(null, null, function* () {
|
|
3117
3158
|
var _a2;
|
|
3118
3159
|
const expo = expoRef.current;
|
|
3119
3160
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3121,7 +3162,7 @@ function useNotifications(options) {
|
|
|
3121
3162
|
}
|
|
3122
3163
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3123
3164
|
}), []);
|
|
3124
|
-
const setBadgeCount = (0,
|
|
3165
|
+
const setBadgeCount = (0, import_react7.useCallback)((count) => __async(null, null, function* () {
|
|
3125
3166
|
const expo = expoRef.current;
|
|
3126
3167
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3127
3168
|
return;
|
|
@@ -3129,7 +3170,7 @@ function useNotifications(options) {
|
|
|
3129
3170
|
yield expo.setBadgeCountAsync(count);
|
|
3130
3171
|
}), []);
|
|
3131
3172
|
const autoRegister = options.autoRegister !== false;
|
|
3132
|
-
(0,
|
|
3173
|
+
(0, import_react7.useEffect)(() => {
|
|
3133
3174
|
if (!autoRegister) {
|
|
3134
3175
|
return;
|
|
3135
3176
|
}
|
|
@@ -3166,7 +3207,7 @@ function useNotificationsActions() {
|
|
|
3166
3207
|
const sdkContext = useTruthSdkContext();
|
|
3167
3208
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3168
3209
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3169
|
-
const post = (0,
|
|
3210
|
+
const post = (0, import_react7.useCallback)(
|
|
3170
3211
|
(path, body) => __async(null, null, function* () {
|
|
3171
3212
|
if (!apiBaseUrl || !apiKey) {
|
|
3172
3213
|
throw new Error(
|
|
@@ -3192,7 +3233,7 @@ function useNotificationsActions() {
|
|
|
3192
3233
|
}),
|
|
3193
3234
|
[apiBaseUrl, apiKey]
|
|
3194
3235
|
);
|
|
3195
|
-
const get = (0,
|
|
3236
|
+
const get = (0, import_react7.useCallback)(
|
|
3196
3237
|
(path) => __async(null, null, function* () {
|
|
3197
3238
|
const res = yield fetch(`${apiBaseUrl}/api${path}`, {
|
|
3198
3239
|
method: "GET",
|
|
@@ -3208,21 +3249,21 @@ function useNotificationsActions() {
|
|
|
3208
3249
|
}),
|
|
3209
3250
|
[apiBaseUrl, apiKey]
|
|
3210
3251
|
);
|
|
3211
|
-
const send = (0,
|
|
3252
|
+
const send = (0, import_react7.useCallback)(
|
|
3212
3253
|
(input) => post("/notifications/send", input),
|
|
3213
3254
|
[post]
|
|
3214
3255
|
);
|
|
3215
|
-
const schedule = (0,
|
|
3256
|
+
const schedule = (0, import_react7.useCallback)(
|
|
3216
3257
|
(input) => post("/notifications/schedule", input),
|
|
3217
3258
|
[post]
|
|
3218
3259
|
);
|
|
3219
|
-
const getPreferences = (0,
|
|
3260
|
+
const getPreferences = (0, import_react7.useCallback)(
|
|
3220
3261
|
(userId) => get(
|
|
3221
3262
|
`/notifications/preferences/${encodeURIComponent(userId)}`
|
|
3222
3263
|
),
|
|
3223
3264
|
[get]
|
|
3224
3265
|
);
|
|
3225
|
-
const updatePreferences = (0,
|
|
3266
|
+
const updatePreferences = (0, import_react7.useCallback)(
|
|
3226
3267
|
(userId, prefs) => post(
|
|
3227
3268
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3228
3269
|
prefs
|
|
@@ -3305,12 +3346,12 @@ function usePatientSearch(options) {
|
|
|
3305
3346
|
|
|
3306
3347
|
// src/react/patients-bulk.ts
|
|
3307
3348
|
var import_server8 = require("convex/server");
|
|
3308
|
-
var
|
|
3349
|
+
var import_react8 = require("react");
|
|
3309
3350
|
var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
|
|
3310
3351
|
var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
|
|
3311
3352
|
var SKIP5 = "skip";
|
|
3312
3353
|
function usePatientsByIds(ids) {
|
|
3313
|
-
const stableIds = (0,
|
|
3354
|
+
const stableIds = (0, import_react8.useMemo)(() => {
|
|
3314
3355
|
const arr = ids != null ? ids : [];
|
|
3315
3356
|
return [...new Set(arr)].sort();
|
|
3316
3357
|
}, [ids]);
|
|
@@ -3319,7 +3360,7 @@ function usePatientsByIds(ids) {
|
|
|
3319
3360
|
patientsGetByIdsRef,
|
|
3320
3361
|
skipped ? SKIP5 : { ids: stableIds }
|
|
3321
3362
|
);
|
|
3322
|
-
const mapped = (0,
|
|
3363
|
+
const mapped = (0, import_react8.useMemo)(() => {
|
|
3323
3364
|
if (result === void 0) {
|
|
3324
3365
|
return void 0;
|
|
3325
3366
|
}
|
|
@@ -3341,7 +3382,7 @@ function usePatientsByIds(ids) {
|
|
|
3341
3382
|
};
|
|
3342
3383
|
}
|
|
3343
3384
|
function usePatientsByPhones(phones) {
|
|
3344
|
-
const stableDigits = (0,
|
|
3385
|
+
const stableDigits = (0, import_react8.useMemo)(() => {
|
|
3345
3386
|
const arr = phones != null ? phones : [];
|
|
3346
3387
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3347
3388
|
return [...new Set(digits)].sort();
|
|
@@ -3351,7 +3392,7 @@ function usePatientsByPhones(phones) {
|
|
|
3351
3392
|
patientsGetByPhonesRef,
|
|
3352
3393
|
skipped ? SKIP5 : { phoneDigits: stableDigits }
|
|
3353
3394
|
);
|
|
3354
|
-
const mapped = (0,
|
|
3395
|
+
const mapped = (0, import_react8.useMemo)(() => {
|
|
3355
3396
|
if (result === void 0) {
|
|
3356
3397
|
return void 0;
|
|
3357
3398
|
}
|
|
@@ -3390,23 +3431,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3390
3431
|
}
|
|
3391
3432
|
|
|
3392
3433
|
// src/react/tasks.ts
|
|
3393
|
-
var
|
|
3434
|
+
var import_react9 = require("convex/react");
|
|
3394
3435
|
var import_server10 = require("convex/server");
|
|
3395
|
-
var
|
|
3436
|
+
var import_react10 = require("react");
|
|
3396
3437
|
var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
|
|
3397
3438
|
function useConversationTaskMarkSeen() {
|
|
3398
|
-
const mutate = (0,
|
|
3439
|
+
const mutate = (0, import_react9.useMutation)(
|
|
3399
3440
|
conversationTasksMarkSeenRef
|
|
3400
3441
|
);
|
|
3401
|
-
return (0,
|
|
3442
|
+
return (0, import_react10.useCallback)(
|
|
3402
3443
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3403
3444
|
[mutate]
|
|
3404
3445
|
);
|
|
3405
3446
|
}
|
|
3406
3447
|
|
|
3407
3448
|
// src/react/tracking.ts
|
|
3408
|
-
var
|
|
3409
|
-
var TruthTrackingContext = (0,
|
|
3449
|
+
var import_react11 = require("react");
|
|
3450
|
+
var TruthTrackingContext = (0, import_react11.createContext)(
|
|
3410
3451
|
null
|
|
3411
3452
|
);
|
|
3412
3453
|
function TruthTrackingProvider({
|
|
@@ -3419,7 +3460,7 @@ function TruthTrackingProvider({
|
|
|
3419
3460
|
}) {
|
|
3420
3461
|
var _a, _b;
|
|
3421
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 : "";
|
|
3422
|
-
const value = (0,
|
|
3463
|
+
const value = (0, import_react11.useMemo)(() => {
|
|
3423
3464
|
const tracker = new Tracker({
|
|
3424
3465
|
apiKey: resolvedApiKey,
|
|
3425
3466
|
environment,
|
|
@@ -3438,10 +3479,10 @@ function TruthTrackingProvider({
|
|
|
3438
3479
|
}
|
|
3439
3480
|
};
|
|
3440
3481
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3441
|
-
return (0,
|
|
3482
|
+
return (0, import_react11.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3442
3483
|
}
|
|
3443
3484
|
function useTruth() {
|
|
3444
|
-
const ctx = (0,
|
|
3485
|
+
const ctx = (0, import_react11.useContext)(TruthTrackingContext);
|
|
3445
3486
|
if (!ctx) {
|
|
3446
3487
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3447
3488
|
}
|
|
@@ -3469,15 +3510,15 @@ function useUserSettings(userId) {
|
|
|
3469
3510
|
}
|
|
3470
3511
|
|
|
3471
3512
|
// src/react/users.ts
|
|
3472
|
-
var
|
|
3513
|
+
var import_react12 = require("react");
|
|
3473
3514
|
function useUserSync(input) {
|
|
3474
3515
|
var _a, _b, _c, _d;
|
|
3475
3516
|
const sdkContext = useTruthSdkContext();
|
|
3476
3517
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3477
3518
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3478
|
-
const [status, setStatus] = (0,
|
|
3479
|
-
const [error, setError] = (0,
|
|
3480
|
-
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);
|
|
3481
3522
|
const sync = () => __async(null, null, function* () {
|
|
3482
3523
|
if (!input.userId) {
|
|
3483
3524
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3520,7 +3561,7 @@ function useUserSync(input) {
|
|
|
3520
3561
|
return { ok: false, reason: message };
|
|
3521
3562
|
}
|
|
3522
3563
|
});
|
|
3523
|
-
(0,
|
|
3564
|
+
(0, import_react12.useEffect)(() => {
|
|
3524
3565
|
var _a2, _b2, _c2, _d2, _e;
|
|
3525
3566
|
if (!input.userId) {
|
|
3526
3567
|
return;
|
|
@@ -3559,13 +3600,13 @@ function useUserSync(input) {
|
|
|
3559
3600
|
}
|
|
3560
3601
|
|
|
3561
3602
|
// src/react/voicemail.ts
|
|
3562
|
-
var
|
|
3603
|
+
var import_react13 = require("react");
|
|
3563
3604
|
function useVoicemailUrl(client) {
|
|
3564
|
-
const [url, setUrl] = (0,
|
|
3565
|
-
const [isLoading, setIsLoading] = (0,
|
|
3566
|
-
const [error, setError] = (0,
|
|
3567
|
-
const inFlightRef = (0,
|
|
3568
|
-
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)(
|
|
3569
3610
|
(voicemailLink) => __async(null, null, function* () {
|
|
3570
3611
|
if (inFlightRef.current) {
|
|
3571
3612
|
return null;
|