@hipnation-truth/sdk 0.15.3 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -84,15 +84,20 @@ __export(react_exports, {
84
84
  usePatientBasic: () => usePatientBasic,
85
85
  usePatientByElationId: () => usePatientByElationId,
86
86
  usePatientByHintId: () => usePatientByHintId,
87
+ usePatientFamilyMembers: () => usePatientFamilyMembers,
87
88
  usePatientMedical: () => usePatientMedical,
88
89
  usePatientPhoto: () => usePatientPhoto,
90
+ usePatientSearch: () => usePatientSearch,
89
91
  usePatients: () => usePatients,
92
+ usePatientsByIds: () => usePatientsByIds,
90
93
  usePharmacyByNcpdpId: () => usePharmacyByNcpdpId,
91
94
  usePhysicianByElationId: () => usePhysicianByElationId,
92
95
  usePhysiciansByElationIds: () => usePhysiciansByElationIds,
93
96
  useRemindersForConversations: () => useRemindersForConversations,
94
97
  useTruth: () => useTruth,
95
- useUnreadCount: () => useUnreadCount
98
+ useUnreadCount: () => useUnreadCount,
99
+ useUserSettings: () => useUserSettings,
100
+ useVoicemailUrl: () => useVoicemailUrl
96
101
  });
97
102
  module.exports = __toCommonJS(react_exports);
98
103
 
@@ -882,9 +887,94 @@ function detectPlatform(tokenType) {
882
887
  return "unknown";
883
888
  }
884
889
 
885
- // src/react/provider.ts
890
+ // src/react/patient-family.ts
886
891
  var import_react6 = require("convex/react");
887
- var import_react7 = require("react");
892
+ var import_server4 = require("convex/server");
893
+ var patientsFamilyMembersRef = (0, import_server4.makeFunctionReference)("patients:listFamilyMembers");
894
+ var SKIP3 = "skip";
895
+ function usePatientFamilyMembers(input) {
896
+ const hasFamilyId = !!(input == null ? void 0 : input.familyId);
897
+ const hasPhoneNumbers = !!((input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0);
898
+ const shouldQuery = hasFamilyId || hasPhoneNumbers;
899
+ const args = shouldQuery ? __spreadValues(__spreadValues(__spreadValues({}, (input == null ? void 0 : input.familyId) ? { familyId: input.familyId } : {}), (input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0 ? { phoneNumbers: input.phoneNumbers } : {}), (input == null ? void 0 : input.excludeHintId) ? { excludeHintId: input.excludeHintId } : {}) : SKIP3;
900
+ const result = (0, import_react6.useQuery)(
901
+ patientsFamilyMembersRef,
902
+ args
903
+ );
904
+ if (!shouldQuery) {
905
+ return { data: void 0, loading: false, error: void 0 };
906
+ }
907
+ return {
908
+ data: result,
909
+ loading: result === void 0,
910
+ error: void 0
911
+ };
912
+ }
913
+
914
+ // src/react/patient-search.ts
915
+ var import_react7 = require("convex/react");
916
+ var import_server5 = require("convex/server");
917
+ var patientsSearchRef = (0, import_server5.makeFunctionReference)("patients:search");
918
+ var SKIP4 = "skip";
919
+ function usePatientSearch(options) {
920
+ var _a;
921
+ const trimmedQuery = ((_a = options.query) != null ? _a : "").trim();
922
+ const skipped = trimmedQuery.length === 0;
923
+ const result = (0, import_react7.useQuery)(
924
+ patientsSearchRef,
925
+ skipped ? SKIP4 : __spreadValues(__spreadValues(__spreadValues({
926
+ query: trimmedQuery
927
+ }, options.officeId ? { officeId: options.officeId } : {}), options.mode ? { mode: options.mode } : {}), options.limit !== void 0 ? { limit: options.limit } : {})
928
+ );
929
+ if (skipped) {
930
+ return { data: void 0, loading: false, error: void 0 };
931
+ }
932
+ return {
933
+ data: result,
934
+ loading: result === void 0,
935
+ error: void 0
936
+ };
937
+ }
938
+
939
+ // src/react/patients-bulk.ts
940
+ var import_react8 = require("convex/react");
941
+ var import_server6 = require("convex/server");
942
+ var import_react9 = require("react");
943
+ var patientsGetByIdsRef = (0, import_server6.makeFunctionReference)("patients:getByIds");
944
+ var SKIP5 = "skip";
945
+ function usePatientsByIds(ids) {
946
+ const stableIds = (0, import_react9.useMemo)(() => {
947
+ const arr = ids != null ? ids : [];
948
+ return [...new Set(arr)].sort();
949
+ }, [ids]);
950
+ const skipped = stableIds.length === 0;
951
+ const result = (0, import_react8.useQuery)(
952
+ patientsGetByIdsRef,
953
+ skipped ? SKIP5 : { ids: stableIds }
954
+ );
955
+ const mapped = (0, import_react9.useMemo)(() => {
956
+ if (result === void 0) return void 0;
957
+ return Object.fromEntries(
958
+ result.map((p) => {
959
+ var _a, _b;
960
+ const id = (_b = (_a = p.id) != null ? _a : p._id) != null ? _b : "";
961
+ return [String(id), p];
962
+ })
963
+ );
964
+ }, [result]);
965
+ if (skipped) {
966
+ return { data: {}, loading: false, error: void 0 };
967
+ }
968
+ return {
969
+ data: mapped,
970
+ loading: mapped === void 0,
971
+ error: void 0
972
+ };
973
+ }
974
+
975
+ // src/react/provider.ts
976
+ var import_react10 = require("convex/react");
977
+ var import_react11 = require("react");
888
978
  var CONVEX_URLS = {
889
979
  local: "https://courteous-duck-623.convex.cloud",
890
980
  staging: "https://courteous-duck-623.convex.cloud",
@@ -907,21 +997,21 @@ function TruthProvider({
907
997
  children
908
998
  }) {
909
999
  const url = resolveConvexUrl(environment, convexUrl);
910
- const client = (0, import_react7.useMemo)(() => new import_react6.ConvexReactClient(url), [url]);
911
- return (0, import_react7.createElement)(import_react6.ConvexProvider, { client }, children);
1000
+ const client = (0, import_react11.useMemo)(() => new import_react10.ConvexReactClient(url), [url]);
1001
+ return (0, import_react11.createElement)(import_react10.ConvexProvider, { client }, children);
912
1002
  }
913
1003
 
914
1004
  // src/react/reminders.ts
915
- var import_react8 = require("convex/react");
916
- var import_server4 = require("convex/server");
917
- var remindersListPendingByConversationIdsRef = (0, import_server4.makeFunctionReference)("reminders:listPendingByConversationIds");
918
- var SKIP3 = "skip";
1005
+ var import_react12 = require("convex/react");
1006
+ var import_server7 = require("convex/server");
1007
+ var remindersListPendingByConversationIdsRef = (0, import_server7.makeFunctionReference)("reminders:listPendingByConversationIds");
1008
+ var SKIP6 = "skip";
919
1009
  function useRemindersForConversations(conversationIds) {
920
1010
  const ids = conversationIds != null ? conversationIds : [];
921
1011
  const skipped = ids.length === 0;
922
- const result = (0, import_react8.useQuery)(
1012
+ const result = (0, import_react12.useQuery)(
923
1013
  remindersListPendingByConversationIdsRef,
924
- skipped ? SKIP3 : { conversationIds: ids }
1014
+ skipped ? SKIP6 : { conversationIds: ids }
925
1015
  );
926
1016
  const mapped = result === void 0 ? void 0 : Object.fromEntries(result.map((r) => [r.conversationId, r]));
927
1017
  if (skipped) {
@@ -935,7 +1025,7 @@ function useRemindersForConversations(conversationIds) {
935
1025
  }
936
1026
 
937
1027
  // src/react/tracking.ts
938
- var import_react9 = require("react");
1028
+ var import_react13 = require("react");
939
1029
 
940
1030
  // src/tracking/tracker.ts
941
1031
  function generateUuidV7() {
@@ -1130,7 +1220,7 @@ function sleep(ms) {
1130
1220
  }
1131
1221
 
1132
1222
  // src/react/tracking.ts
1133
- var TruthTrackingContext = (0, import_react9.createContext)(
1223
+ var TruthTrackingContext = (0, import_react13.createContext)(
1134
1224
  null
1135
1225
  );
1136
1226
  function TruthTrackingProvider({
@@ -1141,7 +1231,7 @@ function TruthTrackingProvider({
1141
1231
  apiKey = "",
1142
1232
  children
1143
1233
  }) {
1144
- const value = (0, import_react9.useMemo)(() => {
1234
+ const value = (0, import_react13.useMemo)(() => {
1145
1235
  const tracker = new Tracker({
1146
1236
  apiKey,
1147
1237
  environment,
@@ -1160,15 +1250,67 @@ function TruthTrackingProvider({
1160
1250
  }
1161
1251
  };
1162
1252
  }, [apiKey, environment, source, sourceVersion, tenantId]);
1163
- return (0, import_react9.createElement)(TruthTrackingContext.Provider, { value }, children);
1253
+ return (0, import_react13.createElement)(TruthTrackingContext.Provider, { value }, children);
1164
1254
  }
1165
1255
  function useTruth() {
1166
- const ctx = (0, import_react9.useContext)(TruthTrackingContext);
1256
+ const ctx = (0, import_react13.useContext)(TruthTrackingContext);
1167
1257
  if (!ctx) {
1168
1258
  throw new Error("useTruth must be used within a TruthTrackingProvider");
1169
1259
  }
1170
1260
  return ctx;
1171
1261
  }
1262
+
1263
+ // src/react/user-settings.ts
1264
+ var import_react14 = require("convex/react");
1265
+ var import_server8 = require("convex/server");
1266
+ var userSettingsGetByUserIdRef = (0, import_server8.makeFunctionReference)("userSettings:getByUserId");
1267
+ var SKIP7 = "skip";
1268
+ function useUserSettings(userId) {
1269
+ const skip = !userId;
1270
+ const result = (0, import_react14.useQuery)(
1271
+ userSettingsGetByUserIdRef,
1272
+ skip ? SKIP7 : { userId }
1273
+ );
1274
+ if (skip) {
1275
+ return { data: null, loading: false, error: void 0 };
1276
+ }
1277
+ return {
1278
+ data: result != null ? result : null,
1279
+ loading: result === void 0,
1280
+ error: void 0
1281
+ };
1282
+ }
1283
+
1284
+ // src/react/voicemail.ts
1285
+ var import_react15 = require("react");
1286
+ function useVoicemailUrl(client) {
1287
+ const [url, setUrl] = (0, import_react15.useState)(null);
1288
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
1289
+ const [error, setError] = (0, import_react15.useState)(null);
1290
+ const inFlightRef = (0, import_react15.useRef)(false);
1291
+ const fetchUrl = (0, import_react15.useCallback)(
1292
+ (voicemailLink) => __async(null, null, function* () {
1293
+ if (inFlightRef.current) return null;
1294
+ inFlightRef.current = true;
1295
+ setIsLoading(true);
1296
+ setError(null);
1297
+ try {
1298
+ const result = yield client.messages.getVoicemailUrl(voicemailLink);
1299
+ setUrl(result.url);
1300
+ return result.url;
1301
+ } catch (err) {
1302
+ const msg = err instanceof Error ? err.message : "Unknown error";
1303
+ setError(msg);
1304
+ return null;
1305
+ } finally {
1306
+ setIsLoading(false);
1307
+ inFlightRef.current = false;
1308
+ }
1309
+ }),
1310
+ [client]
1311
+ );
1312
+ return { fetchUrl, url, isLoading, error };
1313
+ }
1172
1314
  // Annotate the CommonJS export names for ESM import in node:
1173
1315
  0 && (module.exports = {
1174
1316
  ACTIVE_CALL_STATES,
@@ -1199,14 +1341,19 @@ function useTruth() {
1199
1341
  usePatientBasic,
1200
1342
  usePatientByElationId,
1201
1343
  usePatientByHintId,
1344
+ usePatientFamilyMembers,
1202
1345
  usePatientMedical,
1203
1346
  usePatientPhoto,
1347
+ usePatientSearch,
1204
1348
  usePatients,
1349
+ usePatientsByIds,
1205
1350
  usePharmacyByNcpdpId,
1206
1351
  usePhysicianByElationId,
1207
1352
  usePhysiciansByElationIds,
1208
1353
  useRemindersForConversations,
1209
1354
  useTruth,
1210
- useUnreadCount
1355
+ useUnreadCount,
1356
+ useUserSettings,
1357
+ useVoicemailUrl
1211
1358
  });
1212
1359
  //# sourceMappingURL=react.js.map