@hipnation-truth/sdk 0.25.3 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +6 -18
- package/dist/index.d.ts +6 -18
- package/dist/index.js +43 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -29
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +6 -18
- package/dist/react.js +43 -29
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -1420,19 +1420,6 @@ declare class AttachmentsResource {
|
|
|
1420
1420
|
}>;
|
|
1421
1421
|
}
|
|
1422
1422
|
|
|
1423
|
-
/**
|
|
1424
|
-
* ConversationsResource — write methods that hang off a specific
|
|
1425
|
-
* conversation: notes, tasks, outbound messages.
|
|
1426
|
-
*
|
|
1427
|
-
* Replaces CommHub's `truthConversationApi.ts` raw-fetch wrappers so
|
|
1428
|
-
* the frontend goes through a typed SDK surface instead of building
|
|
1429
|
-
* URLs by hand.
|
|
1430
|
-
*
|
|
1431
|
-
* All methods proxy the matching oRPC procedures (`/conversations/*`)
|
|
1432
|
-
* via Truth's application-key auth. Errors surface as
|
|
1433
|
-
* `ConversationsError` with a status code so callers can distinguish
|
|
1434
|
-
* transport failures (status=0) from API rejections (status>=400).
|
|
1435
|
-
*/
|
|
1436
1423
|
/** Address a conversation by either Convex `_id` or the phonePair. */
|
|
1437
1424
|
interface ConversationAddress {
|
|
1438
1425
|
conversationId?: string;
|
|
@@ -1560,8 +1547,9 @@ declare class ConversationsResource {
|
|
|
1560
1547
|
private static readonly REQUEST_TIMEOUT_MS;
|
|
1561
1548
|
private readonly baseUrl;
|
|
1562
1549
|
private readonly apiKey;
|
|
1550
|
+
private readonly auth;
|
|
1563
1551
|
private readonly convex;
|
|
1564
|
-
constructor(apiBaseUrl: string, apiKey: string, convex?: convex_browser.ConvexHttpClient);
|
|
1552
|
+
constructor(apiBaseUrl: string, apiKey: string, convex?: convex_browser.ConvexHttpClient, getAuthToken?: AuthTokenFetcher);
|
|
1565
1553
|
/**
|
|
1566
1554
|
* Mark a conversation read for the calling user (zeroes unreadCount,
|
|
1567
1555
|
* stamps `lastReadAt`). Calls the public Convex `markRead` mutation
|
|
@@ -1758,12 +1746,12 @@ declare class MessagesResource {
|
|
|
1758
1746
|
* const hintPatient = await truth.ehr.hint.get('/provider/patients/456');
|
|
1759
1747
|
* ```
|
|
1760
1748
|
*/
|
|
1749
|
+
|
|
1761
1750
|
declare class EhrProviderProxy {
|
|
1762
1751
|
private readonly baseUrl;
|
|
1763
1752
|
private readonly provider;
|
|
1764
|
-
private readonly
|
|
1765
|
-
constructor(apiBaseUrl: string, provider: string, apiKey: string);
|
|
1766
|
-
private headers;
|
|
1753
|
+
private readonly auth;
|
|
1754
|
+
constructor(apiBaseUrl: string, provider: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
|
|
1767
1755
|
private request;
|
|
1768
1756
|
/**
|
|
1769
1757
|
* GET request to the EHR proxy.
|
|
@@ -1785,7 +1773,7 @@ declare class EhrResource {
|
|
|
1785
1773
|
readonly elation: EhrProviderProxy;
|
|
1786
1774
|
/** Hint Health proxy */
|
|
1787
1775
|
readonly hint: EhrProviderProxy;
|
|
1788
|
-
constructor(apiBaseUrl: string, apiKey: string);
|
|
1776
|
+
constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
|
|
1789
1777
|
}
|
|
1790
1778
|
|
|
1791
1779
|
/**
|
package/dist/react.js
CHANGED
|
@@ -624,6 +624,31 @@ var AttachmentsResource = class {
|
|
|
624
624
|
}
|
|
625
625
|
};
|
|
626
626
|
|
|
627
|
+
// src/resources/rest-auth.ts
|
|
628
|
+
function buildAuthHeaders(auth, options) {
|
|
629
|
+
return __async(this, null, function* () {
|
|
630
|
+
const headers = {
|
|
631
|
+
"X-API-Key": auth.apiKey
|
|
632
|
+
};
|
|
633
|
+
if ((options == null ? void 0 : options.accept) !== false) {
|
|
634
|
+
headers.Accept = "application/json";
|
|
635
|
+
}
|
|
636
|
+
if (options == null ? void 0 : options.json) {
|
|
637
|
+
headers["Content-Type"] = "application/json";
|
|
638
|
+
}
|
|
639
|
+
if (auth.getAuthToken) {
|
|
640
|
+
try {
|
|
641
|
+
const token = yield auth.getAuthToken();
|
|
642
|
+
if (token) {
|
|
643
|
+
headers.Authorization = `Bearer ${token}`;
|
|
644
|
+
}
|
|
645
|
+
} catch (e) {
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return headers;
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
|
|
627
652
|
// src/resources/conversations.ts
|
|
628
653
|
var ConversationsError = class extends Error {
|
|
629
654
|
constructor(operation, status, message) {
|
|
@@ -736,9 +761,10 @@ var ConversationMessagesSubresource = class {
|
|
|
736
761
|
}
|
|
737
762
|
};
|
|
738
763
|
var _ConversationsResource = class _ConversationsResource {
|
|
739
|
-
constructor(apiBaseUrl, apiKey, convex) {
|
|
764
|
+
constructor(apiBaseUrl, apiKey, convex, getAuthToken) {
|
|
740
765
|
this.baseUrl = apiBaseUrl;
|
|
741
766
|
this.apiKey = apiKey;
|
|
767
|
+
this.auth = { apiKey, getAuthToken };
|
|
742
768
|
this.convex = convex != null ? convex : null;
|
|
743
769
|
const post = (path, body) => this.postRequest(path, body);
|
|
744
770
|
const patch = (path, body) => this.patchRequest(path, body);
|
|
@@ -821,11 +847,7 @@ var _ConversationsResource = class _ConversationsResource {
|
|
|
821
847
|
try {
|
|
822
848
|
res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
823
849
|
method: "POST",
|
|
824
|
-
headers: {
|
|
825
|
-
"Content-Type": "application/json",
|
|
826
|
-
Accept: "application/json",
|
|
827
|
-
"X-API-Key": this.apiKey
|
|
828
|
-
},
|
|
850
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
829
851
|
body: JSON.stringify(body),
|
|
830
852
|
signal: controller.signal
|
|
831
853
|
});
|
|
@@ -867,11 +889,7 @@ var _ConversationsResource = class _ConversationsResource {
|
|
|
867
889
|
try {
|
|
868
890
|
res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
869
891
|
method: "PATCH",
|
|
870
|
-
headers: {
|
|
871
|
-
"Content-Type": "application/json",
|
|
872
|
-
Accept: "application/json",
|
|
873
|
-
"X-API-Key": this.apiKey
|
|
874
|
-
},
|
|
892
|
+
headers: yield buildAuthHeaders(this.auth, { json: true }),
|
|
875
893
|
body: JSON.stringify(body),
|
|
876
894
|
signal: controller.signal
|
|
877
895
|
});
|
|
@@ -1205,20 +1223,10 @@ var DialpadProxyError = class extends Error {
|
|
|
1205
1223
|
|
|
1206
1224
|
// src/resources/ehr.ts
|
|
1207
1225
|
var EhrProviderProxy = class {
|
|
1208
|
-
constructor(apiBaseUrl, provider, apiKey) {
|
|
1226
|
+
constructor(apiBaseUrl, provider, apiKey, getAuthToken) {
|
|
1209
1227
|
this.baseUrl = apiBaseUrl;
|
|
1210
1228
|
this.provider = provider;
|
|
1211
|
-
this.
|
|
1212
|
-
}
|
|
1213
|
-
headers(withBody) {
|
|
1214
|
-
const headers = {
|
|
1215
|
-
Accept: "application/json",
|
|
1216
|
-
"X-API-Key": this.apiKey
|
|
1217
|
-
};
|
|
1218
|
-
if (withBody) {
|
|
1219
|
-
headers["Content-Type"] = "application/json";
|
|
1220
|
-
}
|
|
1221
|
-
return headers;
|
|
1229
|
+
this.auth = { apiKey, getAuthToken };
|
|
1222
1230
|
}
|
|
1223
1231
|
request(method, path, body, params) {
|
|
1224
1232
|
return __async(this, null, function* () {
|
|
@@ -1232,7 +1240,7 @@ var EhrProviderProxy = class {
|
|
|
1232
1240
|
}
|
|
1233
1241
|
const response = yield fetch(url.toString(), {
|
|
1234
1242
|
method,
|
|
1235
|
-
headers: this.
|
|
1243
|
+
headers: yield buildAuthHeaders(this.auth, { json: body !== void 0 }),
|
|
1236
1244
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
1237
1245
|
});
|
|
1238
1246
|
if (!response.ok) {
|
|
@@ -1277,9 +1285,14 @@ var EhrProviderProxy = class {
|
|
|
1277
1285
|
}
|
|
1278
1286
|
};
|
|
1279
1287
|
var EhrResource = class {
|
|
1280
|
-
constructor(apiBaseUrl, apiKey) {
|
|
1281
|
-
this.elation = new EhrProviderProxy(
|
|
1282
|
-
|
|
1288
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1289
|
+
this.elation = new EhrProviderProxy(
|
|
1290
|
+
apiBaseUrl,
|
|
1291
|
+
"elation",
|
|
1292
|
+
apiKey,
|
|
1293
|
+
getAuthToken
|
|
1294
|
+
);
|
|
1295
|
+
this.hint = new EhrProviderProxy(apiBaseUrl, "hint", apiKey, getAuthToken);
|
|
1283
1296
|
}
|
|
1284
1297
|
};
|
|
1285
1298
|
var EhrProxyError = class extends Error {
|
|
@@ -2230,7 +2243,7 @@ var TruthClient = class {
|
|
|
2230
2243
|
const apiUrl = this.tracker.apiUrl;
|
|
2231
2244
|
this.patients = new PatientResource(this.convex);
|
|
2232
2245
|
this.appointments = new AppointmentResource(this.convex);
|
|
2233
|
-
this.ehr = new EhrResource(apiUrl, config.apiKey);
|
|
2246
|
+
this.ehr = new EhrResource(apiUrl, config.apiKey, config.getAuthToken);
|
|
2234
2247
|
this.messages = new MessagesResource(apiUrl, config.apiKey);
|
|
2235
2248
|
this.reminders = new RemindersResource(this.convex);
|
|
2236
2249
|
this.translation = new TranslationResource(apiUrl, config.apiKey);
|
|
@@ -2247,7 +2260,8 @@ var TruthClient = class {
|
|
|
2247
2260
|
this.conversations = new ConversationsResource(
|
|
2248
2261
|
apiUrl,
|
|
2249
2262
|
config.apiKey,
|
|
2250
|
-
this.convex
|
|
2263
|
+
this.convex,
|
|
2264
|
+
config.getAuthToken
|
|
2251
2265
|
);
|
|
2252
2266
|
this.userSettings = new UserSettingsResource(this.convex);
|
|
2253
2267
|
this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
|