@hipnation-truth/sdk 0.26.19 → 0.27.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 +140 -8
- package/dist/index.d.ts +140 -8
- package/dist/index.js +167 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +165 -7
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +162 -8
- package/dist/react.js +234 -62
- package/dist/react.js.map +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -86,6 +86,8 @@ __export(src_exports, {
|
|
|
86
86
|
PhysiciansResource: () => PhysiciansResource,
|
|
87
87
|
REMINDER_EVENTS: () => REMINDER_EVENTS,
|
|
88
88
|
RemindersResource: () => RemindersResource,
|
|
89
|
+
ReportsError: () => ReportsError,
|
|
90
|
+
ReportsResource: () => ReportsResource,
|
|
89
91
|
SECURITY_EVENTS: () => SECURITY_EVENTS,
|
|
90
92
|
TASK_EVENTS: () => TASK_EVENTS,
|
|
91
93
|
TRANSLATION_EVENTS: () => TRANSLATION_EVENTS,
|
|
@@ -272,7 +274,6 @@ var AttachmentsError = class extends Error {
|
|
|
272
274
|
var AttachmentsResource = class {
|
|
273
275
|
constructor(apiBaseUrl, apiKey, convexClient, getAuthToken) {
|
|
274
276
|
this.baseUrl = apiBaseUrl;
|
|
275
|
-
this.apiKey = apiKey;
|
|
276
277
|
this.auth = { apiKey, getAuthToken };
|
|
277
278
|
this.convex = convexClient;
|
|
278
279
|
}
|
|
@@ -703,7 +704,6 @@ var ConversationsResource = _ConversationsResource;
|
|
|
703
704
|
var DialpadResource = class {
|
|
704
705
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
705
706
|
this.baseUrl = apiBaseUrl;
|
|
706
|
-
this.apiKey = apiKey;
|
|
707
707
|
this.auth = { apiKey, getAuthToken };
|
|
708
708
|
}
|
|
709
709
|
/**
|
|
@@ -915,7 +915,6 @@ var MessagesResource = class {
|
|
|
915
915
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
916
916
|
this.dialpad = new DialpadResource(apiBaseUrl, apiKey, getAuthToken);
|
|
917
917
|
this.baseUrl = apiBaseUrl;
|
|
918
|
-
this.apiKey = apiKey;
|
|
919
918
|
this.auth = { apiKey, getAuthToken };
|
|
920
919
|
}
|
|
921
920
|
/**
|
|
@@ -1088,7 +1087,6 @@ var NotesError = class extends Error {
|
|
|
1088
1087
|
var _NotesResource = class _NotesResource {
|
|
1089
1088
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1090
1089
|
this.baseUrl = apiBaseUrl;
|
|
1091
|
-
this.apiKey = apiKey;
|
|
1092
1090
|
this.auth = { apiKey, getAuthToken };
|
|
1093
1091
|
}
|
|
1094
1092
|
post(path, body) {
|
|
@@ -1170,7 +1168,6 @@ var NotificationsError = class extends Error {
|
|
|
1170
1168
|
var NotificationsResource = class {
|
|
1171
1169
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1172
1170
|
this.baseUrl = apiBaseUrl;
|
|
1173
|
-
this.apiKey = apiKey;
|
|
1174
1171
|
this.auth = { apiKey, getAuthToken };
|
|
1175
1172
|
}
|
|
1176
1173
|
post(path, body) {
|
|
@@ -1343,7 +1340,6 @@ var PatientDetailsError = class extends Error {
|
|
|
1343
1340
|
var PatientDetailsResource = class {
|
|
1344
1341
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1345
1342
|
this.baseUrl = apiBaseUrl;
|
|
1346
|
-
this.apiKey = apiKey;
|
|
1347
1343
|
this.auth = { apiKey, getAuthToken };
|
|
1348
1344
|
}
|
|
1349
1345
|
post(path, body) {
|
|
@@ -1625,6 +1621,146 @@ var RemindersResource = class {
|
|
|
1625
1621
|
}
|
|
1626
1622
|
};
|
|
1627
1623
|
|
|
1624
|
+
// src/resources/reports.ts
|
|
1625
|
+
var import_zod = require("zod");
|
|
1626
|
+
var memberSchema = import_zod.z.object({
|
|
1627
|
+
elationId: import_zod.z.string(),
|
|
1628
|
+
name: import_zod.z.string(),
|
|
1629
|
+
doctor: import_zod.z.string().nullable(),
|
|
1630
|
+
status: import_zod.z.enum(["activated", "outreach", "scheduled", "review", "data"]),
|
|
1631
|
+
membershipStart: import_zod.z.string(),
|
|
1632
|
+
daysSinceMembershipStart: import_zod.z.number(),
|
|
1633
|
+
activationDate: import_zod.z.string().nullable(),
|
|
1634
|
+
futureApptDate: import_zod.z.string().nullable(),
|
|
1635
|
+
reason: import_zod.z.string().nullable(),
|
|
1636
|
+
hasLink: import_zod.z.boolean()
|
|
1637
|
+
});
|
|
1638
|
+
var reportSchema = import_zod.z.object({
|
|
1639
|
+
synthetic: import_zod.z.boolean(),
|
|
1640
|
+
generatedAt: import_zod.z.string(),
|
|
1641
|
+
employers: import_zod.z.array(
|
|
1642
|
+
import_zod.z.object({ id: import_zod.z.string(), name: import_zod.z.string(), activeMembers: import_zod.z.number() })
|
|
1643
|
+
),
|
|
1644
|
+
selected: import_zod.z.object({
|
|
1645
|
+
employerId: import_zod.z.string(),
|
|
1646
|
+
employerName: import_zod.z.string(),
|
|
1647
|
+
kpis: import_zod.z.object({
|
|
1648
|
+
active: import_zod.z.number(),
|
|
1649
|
+
linked: import_zod.z.number(),
|
|
1650
|
+
activated: import_zod.z.number(),
|
|
1651
|
+
needsOutreach: import_zod.z.number(),
|
|
1652
|
+
scheduled: import_zod.z.number(),
|
|
1653
|
+
needsReview: import_zod.z.number(),
|
|
1654
|
+
dataIssue: import_zod.z.number(),
|
|
1655
|
+
activationRate: import_zod.z.number()
|
|
1656
|
+
}),
|
|
1657
|
+
coverage: import_zod.z.object({
|
|
1658
|
+
active: import_zod.z.number(),
|
|
1659
|
+
linked: import_zod.z.number(),
|
|
1660
|
+
unlinked: import_zod.z.number(),
|
|
1661
|
+
pct: import_zod.z.number()
|
|
1662
|
+
}),
|
|
1663
|
+
breakdown: import_zod.z.array(
|
|
1664
|
+
import_zod.z.object({
|
|
1665
|
+
status: import_zod.z.enum([
|
|
1666
|
+
"activated",
|
|
1667
|
+
"outreach",
|
|
1668
|
+
"scheduled",
|
|
1669
|
+
"review",
|
|
1670
|
+
"data"
|
|
1671
|
+
]),
|
|
1672
|
+
label: import_zod.z.string(),
|
|
1673
|
+
count: import_zod.z.number(),
|
|
1674
|
+
pct: import_zod.z.number()
|
|
1675
|
+
})
|
|
1676
|
+
),
|
|
1677
|
+
aging: import_zod.z.array(
|
|
1678
|
+
import_zod.z.object({
|
|
1679
|
+
bucket: import_zod.z.string(),
|
|
1680
|
+
total: import_zod.z.number(),
|
|
1681
|
+
outreach: import_zod.z.number(),
|
|
1682
|
+
scheduled: import_zod.z.number(),
|
|
1683
|
+
review: import_zod.z.number()
|
|
1684
|
+
})
|
|
1685
|
+
),
|
|
1686
|
+
doctors: import_zod.z.array(
|
|
1687
|
+
import_zod.z.object({
|
|
1688
|
+
name: import_zod.z.string(),
|
|
1689
|
+
counts: import_zod.z.object({
|
|
1690
|
+
outreach: import_zod.z.number(),
|
|
1691
|
+
scheduled: import_zod.z.number(),
|
|
1692
|
+
review: import_zod.z.number(),
|
|
1693
|
+
data: import_zod.z.number()
|
|
1694
|
+
}),
|
|
1695
|
+
members: import_zod.z.array(memberSchema)
|
|
1696
|
+
})
|
|
1697
|
+
)
|
|
1698
|
+
}).nullable(),
|
|
1699
|
+
// True when the requested employer has no materialized report row yet
|
|
1700
|
+
// (ehr-sync's dailyHandler has not run for it). `selected` is null in that
|
|
1701
|
+
// case — the caller sees the employer roster but no report data to render.
|
|
1702
|
+
pending: import_zod.z.boolean()
|
|
1703
|
+
});
|
|
1704
|
+
var ReportsError = class extends Error {
|
|
1705
|
+
/**
|
|
1706
|
+
* Wraps a failed reports HTTP call with the operation name and status
|
|
1707
|
+
* code so callers can branch on `status` without re-parsing the message.
|
|
1708
|
+
* Falls back to a generated message when the server response body is
|
|
1709
|
+
* empty or unreadable.
|
|
1710
|
+
*/
|
|
1711
|
+
constructor(operation, status, message) {
|
|
1712
|
+
const trimmedMessage = message == null ? void 0 : message.trim();
|
|
1713
|
+
super(trimmedMessage || `Reports ${operation} failed (HTTP ${status})`);
|
|
1714
|
+
this.name = "ReportsError";
|
|
1715
|
+
this.status = status;
|
|
1716
|
+
}
|
|
1717
|
+
};
|
|
1718
|
+
var ReportsResource = class {
|
|
1719
|
+
/**
|
|
1720
|
+
* Captures the Truth API base URL and the auth inputs (API key + optional
|
|
1721
|
+
* user-token fetcher) needed to authenticate every request this resource
|
|
1722
|
+
* makes.
|
|
1723
|
+
*/
|
|
1724
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1725
|
+
this.baseUrl = apiBaseUrl;
|
|
1726
|
+
this.auth = { apiKey, getAuthToken };
|
|
1727
|
+
}
|
|
1728
|
+
/**
|
|
1729
|
+
* Fetches the member activation report from GET /reports/member-activation,
|
|
1730
|
+
* optionally scoped to a single employer. Requires the user JWT (not just
|
|
1731
|
+
* the API key) since the server hardens this route to
|
|
1732
|
+
* `verifiedUserProcedure` for PHI access — throws via `ReportsError` on a
|
|
1733
|
+
* non-OK response, including the response body (truncated) when present.
|
|
1734
|
+
*/
|
|
1735
|
+
memberActivation(params) {
|
|
1736
|
+
return __async(this, null, function* () {
|
|
1737
|
+
const url = new URL(`${this.baseUrl}/api/reports/member-activation`);
|
|
1738
|
+
if (params == null ? void 0 : params.employerId) {
|
|
1739
|
+
url.searchParams.set("employerId", params.employerId);
|
|
1740
|
+
}
|
|
1741
|
+
const res = yield fetch(url.toString(), {
|
|
1742
|
+
method: "GET",
|
|
1743
|
+
// PHI (member activation report) — REQUIRE the user JWT. The server
|
|
1744
|
+
// hardens this route to `verifiedUserProcedure`, so degrading to
|
|
1745
|
+
// key-only would 401. `requireUserToken` retries across the Clerk-
|
|
1746
|
+
// hydration gap and throws rather than silently sending key-only.
|
|
1747
|
+
headers: yield buildAuthHeaders(this.auth, {
|
|
1748
|
+
requireUserToken: true
|
|
1749
|
+
})
|
|
1750
|
+
});
|
|
1751
|
+
if (!res.ok) {
|
|
1752
|
+
const text = yield res.text().catch(() => "");
|
|
1753
|
+
throw new ReportsError(
|
|
1754
|
+
"member-activation",
|
|
1755
|
+
res.status,
|
|
1756
|
+
text.slice(0, 200)
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1759
|
+
return yield res.json();
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
|
|
1628
1764
|
// src/resources/tasks.ts
|
|
1629
1765
|
var TasksResource = class {
|
|
1630
1766
|
constructor(convexClient) {
|
|
@@ -1719,7 +1855,6 @@ var TranslationError = class extends Error {
|
|
|
1719
1855
|
var TranslationResource = class {
|
|
1720
1856
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1721
1857
|
this.baseUrl = apiBaseUrl;
|
|
1722
|
-
this.apiKey = apiKey;
|
|
1723
1858
|
this.auth = { apiKey, getAuthToken };
|
|
1724
1859
|
}
|
|
1725
1860
|
post(path, body) {
|
|
@@ -2039,6 +2174,14 @@ var CONVEX_URLS = {
|
|
|
2039
2174
|
production: "https://gallant-gecko-217.convex.cloud"
|
|
2040
2175
|
};
|
|
2041
2176
|
var TruthClient = class {
|
|
2177
|
+
/**
|
|
2178
|
+
* Builds the Convex client and event tracker from `config`, then wires up
|
|
2179
|
+
* every resource (patients, appointments, EHR proxy, reports, etc.) so
|
|
2180
|
+
* each shares the same Convex connection / API base URL / auth token
|
|
2181
|
+
* fetcher. When running in a browser that supports web push and the
|
|
2182
|
+
* caller hasn't opted out, kicks off best-effort service-worker
|
|
2183
|
+
* registration and push subscription in the background.
|
|
2184
|
+
*/
|
|
2042
2185
|
constructor(config) {
|
|
2043
2186
|
this._vapidPublicKey = null;
|
|
2044
2187
|
this._webPushReady = null;
|
|
@@ -2082,6 +2225,11 @@ var TruthClient = class {
|
|
|
2082
2225
|
this.convex,
|
|
2083
2226
|
config.getAuthToken
|
|
2084
2227
|
);
|
|
2228
|
+
this.reports = new ReportsResource(
|
|
2229
|
+
apiUrl,
|
|
2230
|
+
config.apiKey,
|
|
2231
|
+
config.getAuthToken
|
|
2232
|
+
);
|
|
2085
2233
|
this.notes = new NotesResource(apiUrl, config.apiKey, config.getAuthToken);
|
|
2086
2234
|
this.physicians = new PhysiciansResource(this.convex);
|
|
2087
2235
|
this.notifications = new NotificationsResource(
|
|
@@ -2102,9 +2250,11 @@ var TruthClient = class {
|
|
|
2102
2250
|
this._webPushReady = this.initWebPush();
|
|
2103
2251
|
}
|
|
2104
2252
|
}
|
|
2253
|
+
/** The VAPID public key fetched during web-push init, or `null` until `webPushReady` resolves (or if push is unsupported/disabled). */
|
|
2105
2254
|
get vapidPublicKey() {
|
|
2106
2255
|
return this._vapidPublicKey;
|
|
2107
2256
|
}
|
|
2257
|
+
/** Resolves once background web-push initialization (service worker registration + subscription) finishes; `null` if it was never started (SSR, unsupported browser, or opted out via config). */
|
|
2108
2258
|
get webPushReady() {
|
|
2109
2259
|
return this._webPushReady;
|
|
2110
2260
|
}
|
|
@@ -2131,6 +2281,14 @@ var TruthClient = class {
|
|
|
2131
2281
|
}
|
|
2132
2282
|
});
|
|
2133
2283
|
}
|
|
2284
|
+
/**
|
|
2285
|
+
* Best-effort web-push bootstrap: waits for auth (if configured), fetches
|
|
2286
|
+
* the VAPID key, registers the service worker, subscribes to push, and
|
|
2287
|
+
* registers the device with a placeholder `__pending__` userId (the
|
|
2288
|
+
* backend reconciles this once the real user is known). Any failure
|
|
2289
|
+
* along the way is swallowed — push notifications are opportunistic and
|
|
2290
|
+
* must never break client construction.
|
|
2291
|
+
*/
|
|
2134
2292
|
initWebPush() {
|
|
2135
2293
|
return __async(this, null, function* () {
|
|
2136
2294
|
try {
|
|
@@ -2322,6 +2480,8 @@ var ENVIRONMENTS = {
|
|
|
2322
2480
|
PhysiciansResource,
|
|
2323
2481
|
REMINDER_EVENTS,
|
|
2324
2482
|
RemindersResource,
|
|
2483
|
+
ReportsError,
|
|
2484
|
+
ReportsResource,
|
|
2325
2485
|
SECURITY_EVENTS,
|
|
2326
2486
|
TASK_EVENTS,
|
|
2327
2487
|
TRANSLATION_EVENTS,
|