@hipnation-truth/sdk 0.25.3 → 0.26.1
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 +24 -25
- package/dist/index.d.ts +24 -25
- package/dist/index.js +94 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -104
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +24 -25
- package/dist/react.js +94 -104
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -199,6 +199,31 @@ var AppointmentResource = class {
|
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
|
|
202
|
+
// src/resources/rest-auth.ts
|
|
203
|
+
function buildAuthHeaders(auth, options) {
|
|
204
|
+
return __async(this, null, function* () {
|
|
205
|
+
const headers = {
|
|
206
|
+
"X-API-Key": auth.apiKey
|
|
207
|
+
};
|
|
208
|
+
if ((options == null ? void 0 : options.accept) !== false) {
|
|
209
|
+
headers.Accept = "application/json";
|
|
210
|
+
}
|
|
211
|
+
if (options == null ? void 0 : options.json) {
|
|
212
|
+
headers["Content-Type"] = "application/json";
|
|
213
|
+
}
|
|
214
|
+
if (auth.getAuthToken) {
|
|
215
|
+
try {
|
|
216
|
+
const token = yield auth.getAuthToken();
|
|
217
|
+
if (token) {
|
|
218
|
+
headers.Authorization = `Bearer ${token}`;
|
|
219
|
+
}
|
|
220
|
+
} catch (e) {
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return headers;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
202
227
|
// src/resources/attachments.ts
|
|
203
228
|
var AttachmentsError = class extends Error {
|
|
204
229
|
constructor(operation, status, message) {
|
|
@@ -208,20 +233,17 @@ var AttachmentsError = class extends Error {
|
|
|
208
233
|
}
|
|
209
234
|
};
|
|
210
235
|
var AttachmentsResource = class {
|
|
211
|
-
constructor(apiBaseUrl, apiKey, convexClient) {
|
|
236
|
+
constructor(apiBaseUrl, apiKey, convexClient, getAuthToken) {
|
|
212
237
|
this.baseUrl = apiBaseUrl;
|
|
213
238
|
this.apiKey = apiKey;
|
|
239
|
+
this.auth = { apiKey, getAuthToken };
|
|
214
240
|
this.convex = convexClient;
|
|
215
241
|
}
|
|
216
242
|
post(path, body) {
|
|
217
243
|
return __async(this, null, function* () {
|
|
218
244
|
const res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
219
245
|
method: "POST",
|
|
220
|
-
headers: {
|
|
221
|
-
"Content-Type": "application/json",
|
|
222
|
-
Accept: "application/json",
|
|
223
|
-
"X-API-Key": this.apiKey
|
|
224
|
-
},
|
|
246
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
225
247
|
body: JSON.stringify(body)
|
|
226
248
|
});
|
|
227
249
|
if (!res.ok) {
|
|
@@ -464,9 +486,10 @@ var ConversationMessagesSubresource = class {
|
|
|
464
486
|
}
|
|
465
487
|
};
|
|
466
488
|
var _ConversationsResource = class _ConversationsResource {
|
|
467
|
-
constructor(apiBaseUrl, apiKey, convex) {
|
|
489
|
+
constructor(apiBaseUrl, apiKey, convex, getAuthToken) {
|
|
468
490
|
this.baseUrl = apiBaseUrl;
|
|
469
491
|
this.apiKey = apiKey;
|
|
492
|
+
this.auth = { apiKey, getAuthToken };
|
|
470
493
|
this.convex = convex != null ? convex : null;
|
|
471
494
|
const post = (path, body) => this.postRequest(path, body);
|
|
472
495
|
const patch = (path, body) => this.patchRequest(path, body);
|
|
@@ -549,11 +572,7 @@ var _ConversationsResource = class _ConversationsResource {
|
|
|
549
572
|
try {
|
|
550
573
|
res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
551
574
|
method: "POST",
|
|
552
|
-
headers: {
|
|
553
|
-
"Content-Type": "application/json",
|
|
554
|
-
Accept: "application/json",
|
|
555
|
-
"X-API-Key": this.apiKey
|
|
556
|
-
},
|
|
575
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
557
576
|
body: JSON.stringify(body),
|
|
558
577
|
signal: controller.signal
|
|
559
578
|
});
|
|
@@ -595,11 +614,7 @@ var _ConversationsResource = class _ConversationsResource {
|
|
|
595
614
|
try {
|
|
596
615
|
res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
597
616
|
method: "PATCH",
|
|
598
|
-
headers: {
|
|
599
|
-
"Content-Type": "application/json",
|
|
600
|
-
Accept: "application/json",
|
|
601
|
-
"X-API-Key": this.apiKey
|
|
602
|
-
},
|
|
617
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
603
618
|
body: JSON.stringify(body),
|
|
604
619
|
signal: controller.signal
|
|
605
620
|
});
|
|
@@ -628,9 +643,10 @@ var ConversationsResource = _ConversationsResource;
|
|
|
628
643
|
|
|
629
644
|
// src/resources/dialpad.ts
|
|
630
645
|
var DialpadResource = class {
|
|
631
|
-
constructor(apiBaseUrl, apiKey) {
|
|
646
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
632
647
|
this.baseUrl = apiBaseUrl;
|
|
633
648
|
this.apiKey = apiKey;
|
|
649
|
+
this.auth = { apiKey, getAuthToken };
|
|
634
650
|
}
|
|
635
651
|
/**
|
|
636
652
|
* Send an SMS or MMS message via Dialpad.
|
|
@@ -771,10 +787,7 @@ var DialpadResource = class {
|
|
|
771
787
|
const url = `${this.baseUrl}/api/messages/dialpad/voicemail/authenticate`;
|
|
772
788
|
const response = yield fetch(url, {
|
|
773
789
|
method: "POST",
|
|
774
|
-
headers: {
|
|
775
|
-
"Content-Type": "application/json",
|
|
776
|
-
"X-API-Key": this.apiKey
|
|
777
|
-
},
|
|
790
|
+
headers: yield buildAuthHeaders(this.auth, { json: true, accept: false }),
|
|
778
791
|
body: JSON.stringify({ voicemail_link: voicemailLink })
|
|
779
792
|
});
|
|
780
793
|
const result = yield response.json();
|
|
@@ -799,10 +812,7 @@ var DialpadResource = class {
|
|
|
799
812
|
}
|
|
800
813
|
const response = yield fetch(url.toString(), {
|
|
801
814
|
method: "GET",
|
|
802
|
-
headers:
|
|
803
|
-
Accept: "application/json",
|
|
804
|
-
"X-API-Key": this.apiKey
|
|
805
|
-
}
|
|
815
|
+
headers: yield buildAuthHeaders(this.auth)
|
|
806
816
|
});
|
|
807
817
|
if (!response.ok) {
|
|
808
818
|
throw new DialpadProxyError("GET", path, response.status);
|
|
@@ -815,11 +825,7 @@ var DialpadResource = class {
|
|
|
815
825
|
const url = `${this.baseUrl}/api/messages/dialpad${path}`;
|
|
816
826
|
const response = yield fetch(url, {
|
|
817
827
|
method: "POST",
|
|
818
|
-
headers: {
|
|
819
|
-
"Content-Type": "application/json",
|
|
820
|
-
Accept: "application/json",
|
|
821
|
-
"X-API-Key": this.apiKey
|
|
822
|
-
},
|
|
828
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
823
829
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
824
830
|
});
|
|
825
831
|
if (!response.ok) {
|
|
@@ -834,11 +840,7 @@ var DialpadResource = class {
|
|
|
834
840
|
const url = `${this.baseUrl}/api/messages/dialpad${path}`;
|
|
835
841
|
const response = yield fetch(url, {
|
|
836
842
|
method: "PUT",
|
|
837
|
-
headers: {
|
|
838
|
-
"Content-Type": "application/json",
|
|
839
|
-
Accept: "application/json",
|
|
840
|
-
"X-API-Key": this.apiKey
|
|
841
|
-
},
|
|
843
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
842
844
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
843
845
|
});
|
|
844
846
|
if (!response.ok) {
|
|
@@ -852,10 +854,11 @@ var DialpadResource = class {
|
|
|
852
854
|
}
|
|
853
855
|
};
|
|
854
856
|
var MessagesResource = class {
|
|
855
|
-
constructor(apiBaseUrl, apiKey) {
|
|
856
|
-
this.dialpad = new DialpadResource(apiBaseUrl, apiKey);
|
|
857
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
858
|
+
this.dialpad = new DialpadResource(apiBaseUrl, apiKey, getAuthToken);
|
|
857
859
|
this.baseUrl = apiBaseUrl;
|
|
858
860
|
this.apiKey = apiKey;
|
|
861
|
+
this.auth = { apiKey, getAuthToken };
|
|
859
862
|
}
|
|
860
863
|
/**
|
|
861
864
|
* Get an authenticated URL for a Dialpad voicemail recording.
|
|
@@ -874,11 +877,7 @@ var MessagesResource = class {
|
|
|
874
877
|
return __async(this, null, function* () {
|
|
875
878
|
const res = yield fetch(`${this.baseUrl}/api/conversations/voicemail/url`, {
|
|
876
879
|
method: "POST",
|
|
877
|
-
headers: {
|
|
878
|
-
"Content-Type": "application/json",
|
|
879
|
-
Accept: "application/json",
|
|
880
|
-
"X-API-Key": this.apiKey
|
|
881
|
-
},
|
|
880
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
882
881
|
body: JSON.stringify({ voicemailLink })
|
|
883
882
|
});
|
|
884
883
|
if (!res.ok) {
|
|
@@ -902,11 +901,7 @@ var MessagesResource = class {
|
|
|
902
901
|
return __async(this, null, function* () {
|
|
903
902
|
const res = yield fetch(`${this.baseUrl}/api/conversations/calls/end`, {
|
|
904
903
|
method: "POST",
|
|
905
|
-
headers: {
|
|
906
|
-
"Content-Type": "application/json",
|
|
907
|
-
Accept: "application/json",
|
|
908
|
-
"X-API-Key": this.apiKey
|
|
909
|
-
},
|
|
904
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
910
905
|
body: JSON.stringify({ callId })
|
|
911
906
|
});
|
|
912
907
|
if (!res.ok) {
|
|
@@ -933,20 +928,10 @@ var DialpadProxyError = class extends Error {
|
|
|
933
928
|
|
|
934
929
|
// src/resources/ehr.ts
|
|
935
930
|
var EhrProviderProxy = class {
|
|
936
|
-
constructor(apiBaseUrl, provider, apiKey) {
|
|
931
|
+
constructor(apiBaseUrl, provider, apiKey, getAuthToken) {
|
|
937
932
|
this.baseUrl = apiBaseUrl;
|
|
938
933
|
this.provider = provider;
|
|
939
|
-
this.
|
|
940
|
-
}
|
|
941
|
-
headers(withBody) {
|
|
942
|
-
const headers = {
|
|
943
|
-
Accept: "application/json",
|
|
944
|
-
"X-API-Key": this.apiKey
|
|
945
|
-
};
|
|
946
|
-
if (withBody) {
|
|
947
|
-
headers["Content-Type"] = "application/json";
|
|
948
|
-
}
|
|
949
|
-
return headers;
|
|
934
|
+
this.auth = { apiKey, getAuthToken };
|
|
950
935
|
}
|
|
951
936
|
request(method, path, body, params) {
|
|
952
937
|
return __async(this, null, function* () {
|
|
@@ -960,7 +945,7 @@ var EhrProviderProxy = class {
|
|
|
960
945
|
}
|
|
961
946
|
const response = yield fetch(url.toString(), {
|
|
962
947
|
method,
|
|
963
|
-
headers: this.
|
|
948
|
+
headers: yield buildAuthHeaders(this.auth, { json: body !== void 0 }),
|
|
964
949
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
965
950
|
});
|
|
966
951
|
if (!response.ok) {
|
|
@@ -1005,9 +990,14 @@ var EhrProviderProxy = class {
|
|
|
1005
990
|
}
|
|
1006
991
|
};
|
|
1007
992
|
var EhrResource = class {
|
|
1008
|
-
constructor(apiBaseUrl, apiKey) {
|
|
1009
|
-
this.elation = new EhrProviderProxy(
|
|
1010
|
-
|
|
993
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
994
|
+
this.elation = new EhrProviderProxy(
|
|
995
|
+
apiBaseUrl,
|
|
996
|
+
"elation",
|
|
997
|
+
apiKey,
|
|
998
|
+
getAuthToken
|
|
999
|
+
);
|
|
1000
|
+
this.hint = new EhrProviderProxy(apiBaseUrl, "hint", apiKey, getAuthToken);
|
|
1011
1001
|
}
|
|
1012
1002
|
};
|
|
1013
1003
|
var EhrProxyError = class extends Error {
|
|
@@ -1032,9 +1022,10 @@ var NotesError = class extends Error {
|
|
|
1032
1022
|
}
|
|
1033
1023
|
};
|
|
1034
1024
|
var _NotesResource = class _NotesResource {
|
|
1035
|
-
constructor(apiBaseUrl, apiKey) {
|
|
1025
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1036
1026
|
this.baseUrl = apiBaseUrl;
|
|
1037
1027
|
this.apiKey = apiKey;
|
|
1028
|
+
this.auth = { apiKey, getAuthToken };
|
|
1038
1029
|
}
|
|
1039
1030
|
post(path, body) {
|
|
1040
1031
|
return __async(this, null, function* () {
|
|
@@ -1047,11 +1038,7 @@ var _NotesResource = class _NotesResource {
|
|
|
1047
1038
|
try {
|
|
1048
1039
|
res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
1049
1040
|
method: "POST",
|
|
1050
|
-
headers: {
|
|
1051
|
-
"Content-Type": "application/json",
|
|
1052
|
-
Accept: "application/json",
|
|
1053
|
-
"X-API-Key": this.apiKey
|
|
1054
|
-
},
|
|
1041
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
1055
1042
|
body: JSON.stringify(body),
|
|
1056
1043
|
signal: controller.signal
|
|
1057
1044
|
});
|
|
@@ -1112,19 +1099,16 @@ var NotificationsError = class extends Error {
|
|
|
1112
1099
|
}
|
|
1113
1100
|
};
|
|
1114
1101
|
var NotificationsResource = class {
|
|
1115
|
-
constructor(apiBaseUrl, apiKey) {
|
|
1102
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1116
1103
|
this.baseUrl = apiBaseUrl;
|
|
1117
1104
|
this.apiKey = apiKey;
|
|
1105
|
+
this.auth = { apiKey, getAuthToken };
|
|
1118
1106
|
}
|
|
1119
1107
|
post(path, body) {
|
|
1120
1108
|
return __async(this, null, function* () {
|
|
1121
1109
|
const res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
1122
1110
|
method: "POST",
|
|
1123
|
-
headers: {
|
|
1124
|
-
"Content-Type": "application/json",
|
|
1125
|
-
Accept: "application/json",
|
|
1126
|
-
"X-API-Key": this.apiKey
|
|
1127
|
-
},
|
|
1111
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
1128
1112
|
body: JSON.stringify(body)
|
|
1129
1113
|
});
|
|
1130
1114
|
if (!res.ok) {
|
|
@@ -1142,10 +1126,7 @@ var NotificationsResource = class {
|
|
|
1142
1126
|
}
|
|
1143
1127
|
const res = yield fetch(url.toString(), {
|
|
1144
1128
|
method: "GET",
|
|
1145
|
-
headers:
|
|
1146
|
-
Accept: "application/json",
|
|
1147
|
-
"X-API-Key": this.apiKey
|
|
1148
|
-
}
|
|
1129
|
+
headers: yield buildAuthHeaders(this.auth)
|
|
1149
1130
|
});
|
|
1150
1131
|
if (!res.ok) {
|
|
1151
1132
|
const text = yield res.text().catch(() => "");
|
|
@@ -1158,10 +1139,7 @@ var NotificationsResource = class {
|
|
|
1158
1139
|
return __async(this, null, function* () {
|
|
1159
1140
|
const res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
1160
1141
|
method: "DELETE",
|
|
1161
|
-
headers:
|
|
1162
|
-
Accept: "application/json",
|
|
1163
|
-
"X-API-Key": this.apiKey
|
|
1164
|
-
}
|
|
1142
|
+
headers: yield buildAuthHeaders(this.auth)
|
|
1165
1143
|
});
|
|
1166
1144
|
if (!res.ok) {
|
|
1167
1145
|
const text = yield res.text().catch(() => "");
|
|
@@ -1294,19 +1272,16 @@ var PatientDetailsError = class extends Error {
|
|
|
1294
1272
|
}
|
|
1295
1273
|
};
|
|
1296
1274
|
var PatientDetailsResource = class {
|
|
1297
|
-
constructor(apiBaseUrl, apiKey) {
|
|
1275
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1298
1276
|
this.baseUrl = apiBaseUrl;
|
|
1299
1277
|
this.apiKey = apiKey;
|
|
1278
|
+
this.auth = { apiKey, getAuthToken };
|
|
1300
1279
|
}
|
|
1301
1280
|
post(path, body) {
|
|
1302
1281
|
return __async(this, null, function* () {
|
|
1303
1282
|
const res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
1304
1283
|
method: "POST",
|
|
1305
|
-
headers: {
|
|
1306
|
-
"Content-Type": "application/json",
|
|
1307
|
-
Accept: "application/json",
|
|
1308
|
-
"X-API-Key": this.apiKey
|
|
1309
|
-
},
|
|
1284
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
1310
1285
|
body: JSON.stringify(body)
|
|
1311
1286
|
});
|
|
1312
1287
|
if (!res.ok) {
|
|
@@ -1628,20 +1603,17 @@ var TranslationError = class extends Error {
|
|
|
1628
1603
|
}
|
|
1629
1604
|
};
|
|
1630
1605
|
var TranslationResource = class {
|
|
1631
|
-
constructor(apiBaseUrl, apiKey) {
|
|
1606
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1632
1607
|
this.baseUrl = apiBaseUrl;
|
|
1633
1608
|
this.apiKey = apiKey;
|
|
1609
|
+
this.auth = { apiKey, getAuthToken };
|
|
1634
1610
|
}
|
|
1635
1611
|
post(path, body) {
|
|
1636
1612
|
return __async(this, null, function* () {
|
|
1637
1613
|
const url = `${this.baseUrl}/api${path}`;
|
|
1638
1614
|
const res = yield fetch(url, {
|
|
1639
1615
|
method: "POST",
|
|
1640
|
-
headers: {
|
|
1641
|
-
"Content-Type": "application/json",
|
|
1642
|
-
Accept: "application/json",
|
|
1643
|
-
"X-API-Key": this.apiKey
|
|
1644
|
-
},
|
|
1616
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
1645
1617
|
body: JSON.stringify(body)
|
|
1646
1618
|
});
|
|
1647
1619
|
if (!res.ok) {
|
|
@@ -1972,24 +1944,42 @@ var TruthClient = class {
|
|
|
1972
1944
|
const apiUrl = this.tracker.apiUrl;
|
|
1973
1945
|
this.patients = new PatientResource(this.convex);
|
|
1974
1946
|
this.appointments = new AppointmentResource(this.convex);
|
|
1975
|
-
this.ehr = new EhrResource(apiUrl, config.apiKey);
|
|
1976
|
-
this.messages = new MessagesResource(
|
|
1947
|
+
this.ehr = new EhrResource(apiUrl, config.apiKey, config.getAuthToken);
|
|
1948
|
+
this.messages = new MessagesResource(
|
|
1949
|
+
apiUrl,
|
|
1950
|
+
config.apiKey,
|
|
1951
|
+
config.getAuthToken
|
|
1952
|
+
);
|
|
1977
1953
|
this.reminders = new RemindersResource(this.convex);
|
|
1978
|
-
this.translation = new TranslationResource(
|
|
1954
|
+
this.translation = new TranslationResource(
|
|
1955
|
+
apiUrl,
|
|
1956
|
+
config.apiKey,
|
|
1957
|
+
config.getAuthToken
|
|
1958
|
+
);
|
|
1979
1959
|
this.tasks = new TasksResource(this.convex);
|
|
1980
|
-
this.patientDetails = new PatientDetailsResource(
|
|
1960
|
+
this.patientDetails = new PatientDetailsResource(
|
|
1961
|
+
apiUrl,
|
|
1962
|
+
config.apiKey,
|
|
1963
|
+
config.getAuthToken
|
|
1964
|
+
);
|
|
1981
1965
|
this.attachments = new AttachmentsResource(
|
|
1982
1966
|
apiUrl,
|
|
1983
1967
|
config.apiKey,
|
|
1984
|
-
this.convex
|
|
1968
|
+
this.convex,
|
|
1969
|
+
config.getAuthToken
|
|
1985
1970
|
);
|
|
1986
|
-
this.notes = new NotesResource(apiUrl, config.apiKey);
|
|
1971
|
+
this.notes = new NotesResource(apiUrl, config.apiKey, config.getAuthToken);
|
|
1987
1972
|
this.physicians = new PhysiciansResource(this.convex);
|
|
1988
|
-
this.notifications = new NotificationsResource(
|
|
1973
|
+
this.notifications = new NotificationsResource(
|
|
1974
|
+
apiUrl,
|
|
1975
|
+
config.apiKey,
|
|
1976
|
+
config.getAuthToken
|
|
1977
|
+
);
|
|
1989
1978
|
this.conversations = new ConversationsResource(
|
|
1990
1979
|
apiUrl,
|
|
1991
1980
|
config.apiKey,
|
|
1992
|
-
this.convex
|
|
1981
|
+
this.convex,
|
|
1982
|
+
config.getAuthToken
|
|
1993
1983
|
);
|
|
1994
1984
|
this.userSettings = new UserSettingsResource(this.convex);
|
|
1995
1985
|
this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
|