@metaboliccode-dev/widget 0.2.20 → 0.2.22
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/MetabolicDashboard/api/index.d.ts +4 -4
- package/dist/MetabolicDashboard/api/metabolicBackendApi.d.ts +49 -1
- package/dist/MetabolicDashboard/api/metabolicStealthHealth.d.ts +6 -0
- package/dist/MetabolicDashboard/index.d.ts +2 -2
- package/dist/api.js +31 -24
- package/dist/components/MetabolicCodePatientProgress/index.d.ts +6 -0
- package/dist/components/MetabolicCodePatientProgress/index.test.d.ts +1 -0
- package/dist/components/MetabolicCodeShortReport/index.d.ts +8 -0
- package/dist/components/MetabolicCodeShortReport/index.test.d.ts +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/entry-api--UTRftOZ.js +688 -0
- package/dist/entry-api.d.ts +6 -4
- package/dist/index.css +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1292 -1263
- package/package.json +1 -1
- package/dist/entry-api--y5Fjh-O.js +0 -536
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
var J = Object.defineProperty;
|
|
2
|
+
var V = (t, e, r) => e in t ? J(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var S = (t, e, r) => V(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
const g = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_AG_CHARTS_LICENSE_KEY: "Using_this_{AG_Charts}_Enterprise_key_{AG-125036}_in_excess_of_the_licence_granted_is_not_permitted___Please_report_misuse_to_legal@ag-grid.com___For_help_with_changing_this_key_please_contact_info@ag-grid.com___{Metabolic_Code}_is_granted_a_{Single_Application}_Developer_License_for_the_application_{Metabolic_Code}_only_for_{1}_Front-End_JavaScript_developer___All_Front-End_JavaScript_developers_working_on_{Metabolic_Code}_need_to_be_licensed___{Metabolic_Code}_has_been_granted_a_Deployment_License_Add-on_for_{1}_Production_Environment___This_key_works_with_{AG_Charts}_Enterprise_versions_released_before_{31_March_2027}____[v3]_[02]_MTgwNjQ0NzYwMDAwMA==4e5dbf88087527cd3b1cf09b0557ec38", VITE_METABOLIC_LMS_API_BASE_URL: "https://mc-api-us.metaboliccode.com", VITE_METABOLIC_LMS_FRONTEND_BASE_URL: "https://mc-lms.metaboliccode.com", VITE_METABOLIC_REPORT_PAGES_API_BASE_URL: "https://mc-api-us.metaboliccode.com", VITE_METABOLIC_REPORT_PAGES_API_BASE_URL_CA: "https://mc-api-ca.metaboliccode.com", VITE_METABOLIC_REPORT_PAGES_API_BASE_URL_US: "https://mc-api-us.metaboliccode.com" }, G = "https://mc-api-us.metaboliccode.com", W = "https://mc-api-us.metaboliccode.com", K = "https://mc-lms.metaboliccode.com";
|
|
5
|
+
function A(t) {
|
|
6
|
+
const e = t == null ? void 0 : t.trim();
|
|
7
|
+
return e || void 0;
|
|
8
|
+
}
|
|
9
|
+
function Q() {
|
|
10
|
+
try {
|
|
11
|
+
return A(
|
|
12
|
+
"https://mc-api-us.metaboliccode.com"
|
|
13
|
+
);
|
|
14
|
+
} catch {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function z() {
|
|
19
|
+
try {
|
|
20
|
+
return A(
|
|
21
|
+
"https://mc-api-us.metaboliccode.com"
|
|
22
|
+
);
|
|
23
|
+
} catch {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function Y() {
|
|
28
|
+
try {
|
|
29
|
+
return A("https://mc-api-us.metaboliccode.com");
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function Z() {
|
|
35
|
+
try {
|
|
36
|
+
return A(
|
|
37
|
+
"https://mc-lms.metaboliccode.com"
|
|
38
|
+
);
|
|
39
|
+
} catch {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const tt = Q(), y = z() ?? G, Rt = y, et = tt ?? y, rt = Y() ?? W, nt = Z() ?? K, ot = (() => {
|
|
44
|
+
try {
|
|
45
|
+
return g == null ? void 0 : g.VITE_METABOLIC_DASHBOARD_STUB_API_KEY;
|
|
46
|
+
} catch {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
50
|
+
function Lt(t) {
|
|
51
|
+
return t === ot;
|
|
52
|
+
}
|
|
53
|
+
function U(t) {
|
|
54
|
+
return t.replace(/\/+$/, "");
|
|
55
|
+
}
|
|
56
|
+
function st(t) {
|
|
57
|
+
const e = t == null ? void 0 : t.trim().toUpperCase();
|
|
58
|
+
return e != null && e.startsWith("CA-") ? "ca" : "us";
|
|
59
|
+
}
|
|
60
|
+
function it(t, e) {
|
|
61
|
+
return st(t) === "ca", U(e.us || e.fallback || "");
|
|
62
|
+
}
|
|
63
|
+
function O(t) {
|
|
64
|
+
return it(t, {
|
|
65
|
+
fallback: et,
|
|
66
|
+
us: y
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function at({
|
|
70
|
+
apiKey: t,
|
|
71
|
+
userId: e,
|
|
72
|
+
questionnaireResponseId: r,
|
|
73
|
+
headers: n
|
|
74
|
+
}) {
|
|
75
|
+
if (!t && !e && !r && n == null) return;
|
|
76
|
+
const o = new Headers(n ?? void 0);
|
|
77
|
+
return t && o.set("X-Api-Key", t), e && o.set("X-User-Id", e), r && (o.set("X-Questionnaire-Response-Id", r), o.set("X-Appointment-Id", r)), o;
|
|
78
|
+
}
|
|
79
|
+
function ct(t, e) {
|
|
80
|
+
const r = t.replace(/\/$/, ""), n = e.startsWith("/") ? e : `/${e}`;
|
|
81
|
+
return `${r}${n}`;
|
|
82
|
+
}
|
|
83
|
+
function lt(t, e) {
|
|
84
|
+
const r = ct(t || "", "/api/v1/report/exists");
|
|
85
|
+
return e ? `${r}?report_id=${encodeURIComponent(e)}` : r;
|
|
86
|
+
}
|
|
87
|
+
function ut(t) {
|
|
88
|
+
return t instanceof DOMException && t.name === "AbortError";
|
|
89
|
+
}
|
|
90
|
+
async function Mt(t) {
|
|
91
|
+
const {
|
|
92
|
+
reportId: e,
|
|
93
|
+
headers: r,
|
|
94
|
+
apiKey: n,
|
|
95
|
+
userId: o,
|
|
96
|
+
questionnaireResponseId: s,
|
|
97
|
+
fetchImpl: i = globalThis.fetch.bind(globalThis),
|
|
98
|
+
signal: a
|
|
99
|
+
} = t, _ = O(n), d = lt(_, e), c = at({
|
|
100
|
+
apiKey: n,
|
|
101
|
+
userId: o,
|
|
102
|
+
questionnaireResponseId: s,
|
|
103
|
+
headers: r
|
|
104
|
+
});
|
|
105
|
+
let p;
|
|
106
|
+
try {
|
|
107
|
+
p = await i(d, { method: "GET", headers: c, signal: a });
|
|
108
|
+
} catch (f) {
|
|
109
|
+
throw ut(f) ? f : new Error(
|
|
110
|
+
`Network error checking report availability: ${f instanceof Error ? f.message : String(f)}`,
|
|
111
|
+
{ cause: f }
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
if (p.status === 404) return !1;
|
|
115
|
+
const m = await p.text();
|
|
116
|
+
let h;
|
|
117
|
+
try {
|
|
118
|
+
h = m ? JSON.parse(m) : null;
|
|
119
|
+
} catch {
|
|
120
|
+
h = m;
|
|
121
|
+
}
|
|
122
|
+
if (!p.ok) {
|
|
123
|
+
const f = typeof h == "object" && h !== null && "error" in h && typeof h.error == "string" ? h.error : null;
|
|
124
|
+
throw new Error(f ?? `Failed to check report availability (HTTP ${p.status})`);
|
|
125
|
+
}
|
|
126
|
+
if (h === null || typeof h != "object" || Array.isArray(h) || !("exists" in h) || typeof h.exists != "boolean")
|
|
127
|
+
throw new Error("Unexpected response shape for /report/exists: missing boolean 'exists'");
|
|
128
|
+
return h.exists;
|
|
129
|
+
}
|
|
130
|
+
const ht = {
|
|
131
|
+
stealth_health: "/api/v1/webhooks/stealth_health",
|
|
132
|
+
stealth_health_short_report: "/api/v1/webhooks/stealth_health/short_report",
|
|
133
|
+
stealth_health_junction: "/api/v1/webhooks/stealth_health/junction"
|
|
134
|
+
};
|
|
135
|
+
function I(t) {
|
|
136
|
+
return t.replace(/\/+$/, "");
|
|
137
|
+
}
|
|
138
|
+
function P(t) {
|
|
139
|
+
const e = t.trim();
|
|
140
|
+
if (!e)
|
|
141
|
+
throw new Error("Metabolic Code API key is required.");
|
|
142
|
+
return e;
|
|
143
|
+
}
|
|
144
|
+
function R(t) {
|
|
145
|
+
return O(t);
|
|
146
|
+
}
|
|
147
|
+
function _t({
|
|
148
|
+
apiKey: t,
|
|
149
|
+
kind: e
|
|
150
|
+
}) {
|
|
151
|
+
return `${I(R(t))}${ht[e]}`;
|
|
152
|
+
}
|
|
153
|
+
async function L({
|
|
154
|
+
apiKey: t,
|
|
155
|
+
kind: e,
|
|
156
|
+
body: r,
|
|
157
|
+
headers: n,
|
|
158
|
+
fetchImpl: o = fetch,
|
|
159
|
+
signal: s
|
|
160
|
+
}) {
|
|
161
|
+
const i = P(t), a = new Headers(n);
|
|
162
|
+
return a.set("Content-Type", "application/json"), a.set("X-Api-Key", i), o(_t({ apiKey: i, kind: e }), {
|
|
163
|
+
method: "POST",
|
|
164
|
+
headers: a,
|
|
165
|
+
body: JSON.stringify(r),
|
|
166
|
+
cache: "no-store",
|
|
167
|
+
redirect: "manual",
|
|
168
|
+
signal: s
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function k(t, e) {
|
|
172
|
+
var n;
|
|
173
|
+
const r = new Headers();
|
|
174
|
+
return r.set("X-Api-Key", P(t)), r.set("X-User-Id", e.userId), (n = e.userEmail) != null && n.trim() && r.set("X-User-Email", e.userEmail.trim()), r;
|
|
175
|
+
}
|
|
176
|
+
async function w(t) {
|
|
177
|
+
const e = await t.text();
|
|
178
|
+
let r;
|
|
179
|
+
try {
|
|
180
|
+
r = e.trim() ? JSON.parse(e) : {};
|
|
181
|
+
} catch {
|
|
182
|
+
r = { raw: e.slice(0, 500) };
|
|
183
|
+
}
|
|
184
|
+
if (!t.ok) {
|
|
185
|
+
const n = r && typeof r == "object" && "error" in r ? String(r.error) : `Metabolic Code request failed with HTTP ${t.status}.`;
|
|
186
|
+
throw Object.assign(new Error(n), { status: t.status, body: r });
|
|
187
|
+
}
|
|
188
|
+
return r;
|
|
189
|
+
}
|
|
190
|
+
async function Ut({
|
|
191
|
+
apiKey: t,
|
|
192
|
+
patient: e,
|
|
193
|
+
fetchImpl: r = fetch,
|
|
194
|
+
signal: n
|
|
195
|
+
}) {
|
|
196
|
+
const o = I(R(t)), s = await r(`${o}/api/v1/patient/progress`, {
|
|
197
|
+
method: "GET",
|
|
198
|
+
headers: k(t, e),
|
|
199
|
+
cache: "no-store",
|
|
200
|
+
signal: n
|
|
201
|
+
});
|
|
202
|
+
return w(s);
|
|
203
|
+
}
|
|
204
|
+
async function Ht({
|
|
205
|
+
apiKey: t,
|
|
206
|
+
patient: e,
|
|
207
|
+
questionnaireResponseId: r,
|
|
208
|
+
fetchImpl: n = fetch,
|
|
209
|
+
signal: o
|
|
210
|
+
}) {
|
|
211
|
+
const s = I(R(t)), i = new URL(`${s}/api/v1/patient/short_report_summary`);
|
|
212
|
+
r != null && r.trim() && i.searchParams.set("questionnaire_response_id", r.trim());
|
|
213
|
+
const a = await n(i.toString(), {
|
|
214
|
+
method: "GET",
|
|
215
|
+
headers: k(t, e),
|
|
216
|
+
cache: "no-store",
|
|
217
|
+
signal: o
|
|
218
|
+
});
|
|
219
|
+
return w(a);
|
|
220
|
+
}
|
|
221
|
+
function B(t) {
|
|
222
|
+
return t.replace(/\/+$/, "");
|
|
223
|
+
}
|
|
224
|
+
function l(t) {
|
|
225
|
+
if (typeof t != "string") return null;
|
|
226
|
+
const e = t.trim();
|
|
227
|
+
return e.length ? e : null;
|
|
228
|
+
}
|
|
229
|
+
function C(t) {
|
|
230
|
+
const e = t.trim();
|
|
231
|
+
if (!e)
|
|
232
|
+
throw new Error("Metabolic Code API key is required.");
|
|
233
|
+
return e;
|
|
234
|
+
}
|
|
235
|
+
function dt(t) {
|
|
236
|
+
return t === "video" || t === "article" || t === "guide" || t === "webinar" ? t : "guide";
|
|
237
|
+
}
|
|
238
|
+
async function j(t) {
|
|
239
|
+
const e = await t.json().catch(() => null);
|
|
240
|
+
return e && typeof e == "object" ? e : null;
|
|
241
|
+
}
|
|
242
|
+
function x() {
|
|
243
|
+
return B(rt);
|
|
244
|
+
}
|
|
245
|
+
function pt() {
|
|
246
|
+
return B(nt);
|
|
247
|
+
}
|
|
248
|
+
function ft(t) {
|
|
249
|
+
const e = l(t);
|
|
250
|
+
if (!e)
|
|
251
|
+
throw new Error("LMS launch token is required.");
|
|
252
|
+
const r = new URL("/launch", pt());
|
|
253
|
+
return r.searchParams.set("token", e), r.toString();
|
|
254
|
+
}
|
|
255
|
+
function mt(t) {
|
|
256
|
+
const e = l(t.id), r = l(t.title), n = l(t.course_slug) ?? l(t.courseSlug), o = l(t.resource_key) ?? l(t.resourceKey) ?? e;
|
|
257
|
+
return !e || !r || !n || !o ? null : {
|
|
258
|
+
id: e,
|
|
259
|
+
type: dt(t.type),
|
|
260
|
+
title: r,
|
|
261
|
+
category: l(t.category) ?? "Courses",
|
|
262
|
+
categoryId: l(t.category_id) ?? l(t.categoryId) ?? "courses",
|
|
263
|
+
excerpt: l(t.excerpt),
|
|
264
|
+
thumbnailUrl: l(t.thumbnail_url) ?? l(t.thumbnailUrl),
|
|
265
|
+
imageUrl: l(t.image_url) ?? l(t.imageUrl),
|
|
266
|
+
url: null,
|
|
267
|
+
isFeatured: !!(t.is_featured ?? t.isFeatured),
|
|
268
|
+
launchType: "lms_course",
|
|
269
|
+
courseSlug: n,
|
|
270
|
+
resourceKey: o
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function Ot(t, e) {
|
|
274
|
+
const r = /* @__PURE__ */ new Set(), n = [];
|
|
275
|
+
for (const o of e)
|
|
276
|
+
r.has(o.id) || (r.add(o.id), n.push(o));
|
|
277
|
+
for (const o of t)
|
|
278
|
+
r.has(o.id) || (r.add(o.id), n.push(o));
|
|
279
|
+
return n;
|
|
280
|
+
}
|
|
281
|
+
async function Pt({
|
|
282
|
+
apiKey: t,
|
|
283
|
+
fetchImpl: e = fetch,
|
|
284
|
+
signal: r
|
|
285
|
+
}) {
|
|
286
|
+
const n = C(t), o = await e(`${x()}/api/v1/lms/partner_resources`, {
|
|
287
|
+
method: "GET",
|
|
288
|
+
headers: {
|
|
289
|
+
Accept: "application/json",
|
|
290
|
+
"X-Api-Key": n
|
|
291
|
+
},
|
|
292
|
+
cache: "no-store",
|
|
293
|
+
signal: r
|
|
294
|
+
});
|
|
295
|
+
if (!o.ok) return [];
|
|
296
|
+
const s = await j(o), i = s == null ? void 0 : s.resources;
|
|
297
|
+
return Array.isArray(i) ? i.map(
|
|
298
|
+
(a) => mt(a)
|
|
299
|
+
).filter((a) => a !== null) : [];
|
|
300
|
+
}
|
|
301
|
+
async function kt({
|
|
302
|
+
apiKey: t,
|
|
303
|
+
externalUserId: e,
|
|
304
|
+
email: r,
|
|
305
|
+
displayName: n,
|
|
306
|
+
courseSlug: o,
|
|
307
|
+
resourceKey: s,
|
|
308
|
+
fetchImpl: i = fetch,
|
|
309
|
+
signal: a
|
|
310
|
+
}) {
|
|
311
|
+
var m;
|
|
312
|
+
const _ = C(t), d = await i(`${x()}/api/v1/lms/partner_launches`, {
|
|
313
|
+
method: "POST",
|
|
314
|
+
headers: {
|
|
315
|
+
Accept: "application/json",
|
|
316
|
+
"Content-Type": "application/json",
|
|
317
|
+
"X-Api-Key": _
|
|
318
|
+
},
|
|
319
|
+
cache: "no-store",
|
|
320
|
+
signal: a,
|
|
321
|
+
body: JSON.stringify({
|
|
322
|
+
launch: {
|
|
323
|
+
external_user_id: e,
|
|
324
|
+
email: r,
|
|
325
|
+
display_name: n,
|
|
326
|
+
course_slug: o,
|
|
327
|
+
resource_key: s
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
}), c = await j(d);
|
|
331
|
+
if (!d.ok) {
|
|
332
|
+
const h = typeof (c == null ? void 0 : c.error) == "string" ? c.error : "lms_launch_failed";
|
|
333
|
+
throw new Error(h);
|
|
334
|
+
}
|
|
335
|
+
const p = l(c == null ? void 0 : c.launch_token);
|
|
336
|
+
if (!p) throw new Error("lms_launch_failed");
|
|
337
|
+
return {
|
|
338
|
+
launchUrl: ft(p),
|
|
339
|
+
expiresAt: l(c == null ? void 0 : c.expires_at),
|
|
340
|
+
courseTitle: l((m = c == null ? void 0 : c.course) == null ? void 0 : m.title)
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
const N = "enroll.questionnaire.completed", $ = "metabolic_code.short_report.completed", X = "enroll.junction_order.created";
|
|
344
|
+
class H extends Error {
|
|
345
|
+
constructor(r, n, o, s) {
|
|
346
|
+
super(r);
|
|
347
|
+
S(this, "status");
|
|
348
|
+
S(this, "statusText");
|
|
349
|
+
S(this, "body");
|
|
350
|
+
this.name = "MetabolicStealthHealthRequestError", this.status = n, this.statusText = o, this.body = s;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function Et(t) {
|
|
354
|
+
return t.replace(/\/+$/, "");
|
|
355
|
+
}
|
|
356
|
+
function u(t) {
|
|
357
|
+
return typeof t == "string" ? t.trim() : "";
|
|
358
|
+
}
|
|
359
|
+
function St(t) {
|
|
360
|
+
return Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0));
|
|
361
|
+
}
|
|
362
|
+
function v(t, e) {
|
|
363
|
+
const r = u(t);
|
|
364
|
+
if (!r)
|
|
365
|
+
throw new Error("Stealth Health Functions base URL is required.");
|
|
366
|
+
return `${Et(r)}/${e}`;
|
|
367
|
+
}
|
|
368
|
+
function At(t) {
|
|
369
|
+
if (!t.trim()) return null;
|
|
370
|
+
try {
|
|
371
|
+
const e = JSON.parse(t);
|
|
372
|
+
return e && typeof e == "object" && !Array.isArray(e) ? e : { raw: e };
|
|
373
|
+
} catch {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
async function D(t) {
|
|
378
|
+
const e = await t.text(), r = At(e);
|
|
379
|
+
if (!r)
|
|
380
|
+
throw new H(
|
|
381
|
+
`Firebase Function error: ${t.status} ${t.statusText}`,
|
|
382
|
+
t.status || 500,
|
|
383
|
+
t.statusText,
|
|
384
|
+
e.slice(0, 200)
|
|
385
|
+
);
|
|
386
|
+
if (!t.ok) {
|
|
387
|
+
const n = typeof r.error == "string" ? r.error : `Request failed (HTTP ${t.status}).`;
|
|
388
|
+
throw new H(
|
|
389
|
+
n,
|
|
390
|
+
t.status,
|
|
391
|
+
t.statusText,
|
|
392
|
+
r
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
return r;
|
|
396
|
+
}
|
|
397
|
+
async function wt({
|
|
398
|
+
functionsBaseUrl: t,
|
|
399
|
+
questionnaireResponseId: e,
|
|
400
|
+
questionnaireId: r,
|
|
401
|
+
enrollSlug: n,
|
|
402
|
+
profileData: o,
|
|
403
|
+
selectedMedication: s,
|
|
404
|
+
partnerRef: i,
|
|
405
|
+
whiteLabelDomain: a,
|
|
406
|
+
fetchImpl: _ = fetch,
|
|
407
|
+
signal: d
|
|
408
|
+
}) {
|
|
409
|
+
const c = await _(
|
|
410
|
+
v(t, "processQuestionnaireSubmission"),
|
|
411
|
+
{
|
|
412
|
+
method: "POST",
|
|
413
|
+
headers: { "Content-Type": "application/json" },
|
|
414
|
+
body: JSON.stringify(
|
|
415
|
+
St({
|
|
416
|
+
questionnaireResponseId: e,
|
|
417
|
+
questionnaireId: r,
|
|
418
|
+
enrollSlug: u(n) || void 0,
|
|
419
|
+
profileData: o,
|
|
420
|
+
selectedMedication: s,
|
|
421
|
+
partnerRef: i,
|
|
422
|
+
whiteLabelDomain: a
|
|
423
|
+
})
|
|
424
|
+
),
|
|
425
|
+
signal: d
|
|
426
|
+
}
|
|
427
|
+
);
|
|
428
|
+
return D(c);
|
|
429
|
+
}
|
|
430
|
+
async function Bt({
|
|
431
|
+
functionsBaseUrl: t,
|
|
432
|
+
body: e,
|
|
433
|
+
fetchImpl: r = fetch,
|
|
434
|
+
signal: n
|
|
435
|
+
}) {
|
|
436
|
+
const o = await r(v(t, "createPatientLabOrder"), {
|
|
437
|
+
method: "POST",
|
|
438
|
+
headers: { "Content-Type": "application/json" },
|
|
439
|
+
cache: "no-store",
|
|
440
|
+
body: e || "{}",
|
|
441
|
+
signal: n
|
|
442
|
+
});
|
|
443
|
+
return D(o);
|
|
444
|
+
}
|
|
445
|
+
function T(t) {
|
|
446
|
+
if (t == null || typeof t != "object") return t;
|
|
447
|
+
if (typeof t.toDate == "function") {
|
|
448
|
+
const e = t.toDate();
|
|
449
|
+
return Number.isNaN(e.getTime()) ? null : e.toISOString();
|
|
450
|
+
}
|
|
451
|
+
return Array.isArray(t) ? t.map(T) : Object.fromEntries(
|
|
452
|
+
Object.entries(t).map(([e, r]) => [
|
|
453
|
+
e,
|
|
454
|
+
T(r)
|
|
455
|
+
])
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
function M(t) {
|
|
459
|
+
var r;
|
|
460
|
+
if (Array.isArray(t.slugs))
|
|
461
|
+
return t.slugs.filter(
|
|
462
|
+
(n) => typeof n == "string" && !!n.trim()
|
|
463
|
+
);
|
|
464
|
+
const e = (r = t.data) == null ? void 0 : r.slugs;
|
|
465
|
+
return Array.isArray(e) ? e.filter((n) => typeof n == "string" && !!n.trim()) : [];
|
|
466
|
+
}
|
|
467
|
+
function E(t, e) {
|
|
468
|
+
return u(t.slug) || u(e) || M(t)[0] || "";
|
|
469
|
+
}
|
|
470
|
+
function F({
|
|
471
|
+
appointmentId: t,
|
|
472
|
+
enrollPage: e,
|
|
473
|
+
enrollSlug: r,
|
|
474
|
+
questionnaireId: n,
|
|
475
|
+
questionnaireResponseId: o,
|
|
476
|
+
responseData: s,
|
|
477
|
+
user: i,
|
|
478
|
+
occurredAt: a = (/* @__PURE__ */ new Date()).toISOString()
|
|
479
|
+
}) {
|
|
480
|
+
const _ = T(s), d = _.questionnaireSnapshot && typeof _.questionnaireSnapshot == "object" && !Array.isArray(_.questionnaireSnapshot) ? _.questionnaireSnapshot : {}, c = E(e, r);
|
|
481
|
+
return {
|
|
482
|
+
event: N,
|
|
483
|
+
occurredAt: a,
|
|
484
|
+
enrollPage: {
|
|
485
|
+
id: e.id,
|
|
486
|
+
slug: c,
|
|
487
|
+
slugs: M(e)
|
|
488
|
+
},
|
|
489
|
+
appointment: { id: t },
|
|
490
|
+
appointmentId: t,
|
|
491
|
+
user: {
|
|
492
|
+
id: i.uid,
|
|
493
|
+
uid: i.uid,
|
|
494
|
+
email: i.email,
|
|
495
|
+
firstname: i.firstname,
|
|
496
|
+
lastname: i.lastname,
|
|
497
|
+
birthday: i.birthday,
|
|
498
|
+
telephone: i.telephone
|
|
499
|
+
},
|
|
500
|
+
questionnaire: {
|
|
501
|
+
id: n,
|
|
502
|
+
title: typeof d.title == "string" ? d.title : "",
|
|
503
|
+
version: typeof d.version == "number" ? d.version : null
|
|
504
|
+
},
|
|
505
|
+
response: {
|
|
506
|
+
..._,
|
|
507
|
+
id: o,
|
|
508
|
+
questionnaireId: n
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
async function Ct({
|
|
513
|
+
apiKey: t,
|
|
514
|
+
fetchImpl: e,
|
|
515
|
+
signal: r,
|
|
516
|
+
...n
|
|
517
|
+
}) {
|
|
518
|
+
const o = F(n);
|
|
519
|
+
return L({
|
|
520
|
+
apiKey: t,
|
|
521
|
+
kind: "stealth_health",
|
|
522
|
+
body: o,
|
|
523
|
+
headers: {
|
|
524
|
+
"User-Agent": "StealthHealth-EnrollWebhook/1.0",
|
|
525
|
+
"X-StealthHealth-Event": N,
|
|
526
|
+
"X-StealthHealth-Enroll-Slug": E(
|
|
527
|
+
n.enrollPage,
|
|
528
|
+
n.enrollSlug
|
|
529
|
+
),
|
|
530
|
+
"X-StealthHealth-Appointment-Id": n.appointmentId,
|
|
531
|
+
"X-StealthHealth-Questionnaire-Id": n.questionnaireId,
|
|
532
|
+
"X-StealthHealth-Questionnaire-Response-Id": n.questionnaireResponseId
|
|
533
|
+
},
|
|
534
|
+
fetchImpl: e,
|
|
535
|
+
signal: r
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
function bt({
|
|
539
|
+
submissionId: t,
|
|
540
|
+
...e
|
|
541
|
+
}) {
|
|
542
|
+
const r = u(t) || e.questionnaireResponseId;
|
|
543
|
+
return {
|
|
544
|
+
...F({
|
|
545
|
+
...e,
|
|
546
|
+
appointmentId: r
|
|
547
|
+
}),
|
|
548
|
+
event: $,
|
|
549
|
+
appointment: { id: r },
|
|
550
|
+
appointmentId: r
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
async function jt({
|
|
554
|
+
apiKey: t,
|
|
555
|
+
fetchImpl: e,
|
|
556
|
+
signal: r,
|
|
557
|
+
...n
|
|
558
|
+
}) {
|
|
559
|
+
const o = bt(n), s = typeof o.appointmentId == "string" ? o.appointmentId : n.questionnaireResponseId;
|
|
560
|
+
return L({
|
|
561
|
+
apiKey: t,
|
|
562
|
+
kind: "stealth_health_short_report",
|
|
563
|
+
body: o,
|
|
564
|
+
headers: {
|
|
565
|
+
"User-Agent": "StealthHealth-EnrollWebhook/1.0",
|
|
566
|
+
"X-StealthHealth-Event": $,
|
|
567
|
+
"X-StealthHealth-Enroll-Slug": E(
|
|
568
|
+
n.enrollPage,
|
|
569
|
+
n.enrollSlug
|
|
570
|
+
),
|
|
571
|
+
"X-StealthHealth-Appointment-Id": s,
|
|
572
|
+
"X-StealthHealth-Questionnaire-Id": n.questionnaireId,
|
|
573
|
+
"X-StealthHealth-Questionnaire-Response-Id": n.questionnaireResponseId
|
|
574
|
+
},
|
|
575
|
+
fetchImpl: e,
|
|
576
|
+
signal: r
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
function b(t) {
|
|
580
|
+
return t && typeof t == "object" && !Array.isArray(t) ? t : null;
|
|
581
|
+
}
|
|
582
|
+
function q(t, e) {
|
|
583
|
+
return b(t == null ? void 0 : t[e]);
|
|
584
|
+
}
|
|
585
|
+
function gt(t) {
|
|
586
|
+
const e = b(t), r = q(e, "order");
|
|
587
|
+
return u(e == null ? void 0 : e.junctionOrderId) || u(e == null ? void 0 : e.junction_order_id) || u(e == null ? void 0 : e.orderId) || u(r == null ? void 0 : r.id);
|
|
588
|
+
}
|
|
589
|
+
function Tt(t) {
|
|
590
|
+
const e = b(t), r = q(e, "order");
|
|
591
|
+
return u(e == null ? void 0 : e.status) || u(e == null ? void 0 : e.junctionStatus) || u(e == null ? void 0 : e.labOrderStatus) || u(r == null ? void 0 : r.status);
|
|
592
|
+
}
|
|
593
|
+
function yt({
|
|
594
|
+
enrollPage: t,
|
|
595
|
+
requestBody: e,
|
|
596
|
+
responseData: r,
|
|
597
|
+
appointmentData: n,
|
|
598
|
+
occurredAt: o = (/* @__PURE__ */ new Date()).toISOString()
|
|
599
|
+
}) {
|
|
600
|
+
const s = b(r), i = u(s == null ? void 0 : s.appointmentId) || u(e == null ? void 0 : e.appointmentId), a = gt(r);
|
|
601
|
+
if (!i || !a) return null;
|
|
602
|
+
const _ = u(e == null ? void 0 : e.questionnaireResponseId) || u(n == null ? void 0 : n.questionnaireResponseId), d = Tt(r), c = E(t);
|
|
603
|
+
return {
|
|
604
|
+
event: X,
|
|
605
|
+
occurredAt: o,
|
|
606
|
+
enrollPage: {
|
|
607
|
+
id: t.id,
|
|
608
|
+
slug: c,
|
|
609
|
+
slugs: M(t)
|
|
610
|
+
},
|
|
611
|
+
appointment: { id: i },
|
|
612
|
+
appointmentId: i,
|
|
613
|
+
..._ ? { questionnaireResponseId: _ } : {},
|
|
614
|
+
junctionOrder: {
|
|
615
|
+
id: a,
|
|
616
|
+
status: d || null
|
|
617
|
+
},
|
|
618
|
+
junctionOrderId: a,
|
|
619
|
+
junctionStatus: d || null
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
async function xt({
|
|
623
|
+
apiKey: t,
|
|
624
|
+
fetchImpl: e,
|
|
625
|
+
signal: r,
|
|
626
|
+
...n
|
|
627
|
+
}) {
|
|
628
|
+
const o = yt(n);
|
|
629
|
+
if (!o) return null;
|
|
630
|
+
const s = typeof o.questionnaireResponseId == "string" ? o.questionnaireResponseId : "", i = typeof o.appointmentId == "string" ? o.appointmentId : "", a = typeof o.junctionOrderId == "string" ? o.junctionOrderId : "";
|
|
631
|
+
return L({
|
|
632
|
+
apiKey: t,
|
|
633
|
+
kind: "stealth_health_junction",
|
|
634
|
+
body: o,
|
|
635
|
+
headers: {
|
|
636
|
+
"User-Agent": "StealthHealth-EnrollWebhook/1.0",
|
|
637
|
+
"X-StealthHealth-Event": X,
|
|
638
|
+
...E(n.enrollPage) ? { "X-StealthHealth-Enroll-Slug": E(n.enrollPage) } : {},
|
|
639
|
+
"X-StealthHealth-Appointment-Id": i,
|
|
640
|
+
"X-StealthHealth-Junction-Order-Id": a,
|
|
641
|
+
...s ? { "X-StealthHealth-Questionnaire-Response-Id": s } : {}
|
|
642
|
+
},
|
|
643
|
+
fetchImpl: e,
|
|
644
|
+
signal: r
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
export {
|
|
648
|
+
R as A,
|
|
649
|
+
x as B,
|
|
650
|
+
pt as C,
|
|
651
|
+
Ot as D,
|
|
652
|
+
st as E,
|
|
653
|
+
mt as F,
|
|
654
|
+
w as G,
|
|
655
|
+
it as H,
|
|
656
|
+
gt as I,
|
|
657
|
+
Tt as J,
|
|
658
|
+
Bt as K,
|
|
659
|
+
wt as L,
|
|
660
|
+
ot as M,
|
|
661
|
+
N as S,
|
|
662
|
+
rt as a,
|
|
663
|
+
at as b,
|
|
664
|
+
nt as c,
|
|
665
|
+
et as d,
|
|
666
|
+
Rt as e,
|
|
667
|
+
y as f,
|
|
668
|
+
O as g,
|
|
669
|
+
H as h,
|
|
670
|
+
Lt as i,
|
|
671
|
+
$ as j,
|
|
672
|
+
X as k,
|
|
673
|
+
_t as l,
|
|
674
|
+
ft as m,
|
|
675
|
+
F as n,
|
|
676
|
+
yt as o,
|
|
677
|
+
bt as p,
|
|
678
|
+
lt as q,
|
|
679
|
+
Mt as r,
|
|
680
|
+
kt as s,
|
|
681
|
+
L as t,
|
|
682
|
+
Ct as u,
|
|
683
|
+
xt as v,
|
|
684
|
+
jt as w,
|
|
685
|
+
Pt as x,
|
|
686
|
+
Ut as y,
|
|
687
|
+
Ht as z
|
|
688
|
+
};
|
package/dist/entry-api.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export type { BuiltInReportPagesApiBaseUrls, MetabolicDashboardApiKeyRegion, } from "./MetabolicDashboard/api/builtInReportPagesApi";
|
|
2
2
|
export { getBuiltInReportPagesApiBaseUrl, normalizeMetabolicDashboardApiKeyRegion, resolveBuiltInReportPagesApiBaseUrl, } from "./MetabolicDashboard/api/builtInReportPagesApi";
|
|
3
|
-
export type {
|
|
4
|
-
export {
|
|
3
|
+
export type { CheckMetabolicReportExistsOptions } from "./MetabolicDashboard/api/fetchReportExists";
|
|
4
|
+
export { checkMetabolicReportExists } from "./MetabolicDashboard/api/fetchReportExists";
|
|
5
|
+
export type { DispatchMetabolicBackendWebhookOptions, MetabolicBackendPatientHeaders, MetabolicBackendWebhookKind, MetabolicPatientProgress, MetabolicPatientProgressMilestone, MetabolicShortReportMetricSummary, MetabolicShortReportSummary, } from "./MetabolicDashboard/api/metabolicBackendApi";
|
|
6
|
+
export { buildMetabolicBackendWebhookUrl, dispatchMetabolicBackendWebhook, fetchMetabolicPatientProgress, fetchMetabolicShortReportSummary, getMetabolicBackendApiBaseUrl, parseMetabolicBackendJsonResponse, } from "./MetabolicDashboard/api/metabolicBackendApi";
|
|
5
7
|
export { METABOLIC_LMS_API_BASE_URL, METABOLIC_LMS_FRONTEND_BASE_URL, METABOLIC_REPORT_PAGES_API_BASE_URL, METABOLIC_REPORT_PAGES_API_BASE_URL_CA, METABOLIC_REPORT_PAGES_API_BASE_URL_US, } from "./MetabolicDashboard/api/metabolicDashboardApiKey";
|
|
6
8
|
export type { CreateMetabolicLmsLaunchOptions, FetchMetabolicLmsEducationResourcesOptions, MetabolicLmsBackendResource, MetabolicLmsEducationResource, MetabolicLmsLaunchResult, } from "./MetabolicDashboard/api/metabolicLms";
|
|
7
9
|
export { buildMetabolicLmsLaunchUrl, createMetabolicLmsLaunch, fetchMetabolicLmsEducationResources, getMetabolicLmsApiBaseUrl, getMetabolicLmsFrontendBaseUrl, mergeMetabolicLmsEducationResources, normalizeMetabolicLmsEducationResource, } from "./MetabolicDashboard/api/metabolicLms";
|
|
8
|
-
export type { DispatchMetabolicStealthHealthAppointmentCompletedWebhookOptions, DispatchMetabolicStealthHealthJunctionOrderWebhookOptions, MetabolicStealthHealthEnrollPage, MetabolicStealthHealthWebhookUser, SubmitStealthHealthPatientLabOrderOptions, SubmitStealthHealthQuestionnaireSubmissionOptions, } from "./MetabolicDashboard/api/metabolicStealthHealth";
|
|
9
|
-
export { buildMetabolicStealthHealthAppointmentCompletedWebhookPayload, buildMetabolicStealthHealthJunctionOrderWebhookPayload, dispatchMetabolicStealthHealthAppointmentCompletedWebhook, dispatchMetabolicStealthHealthJunctionOrderWebhook, MetabolicStealthHealthRequestError, resolveMetabolicStealthHealthJunctionOrderId, resolveMetabolicStealthHealthJunctionStatus, STEALTH_HEALTH_ENROLL_QUESTIONNAIRE_COMPLETED_EVENT, STEALTH_HEALTH_TENANT_JUNCTION_ORDER_EVENT, submitStealthHealthPatientLabOrder, submitStealthHealthQuestionnaireSubmission, } from "./MetabolicDashboard/api/metabolicStealthHealth";
|
|
10
|
+
export type { DispatchMetabolicStealthHealthAppointmentCompletedWebhookOptions, DispatchMetabolicStealthHealthJunctionOrderWebhookOptions, DispatchMetabolicStealthHealthShortReportWebhookOptions, MetabolicStealthHealthEnrollPage, MetabolicStealthHealthWebhookUser, SubmitStealthHealthPatientLabOrderOptions, SubmitStealthHealthQuestionnaireSubmissionOptions, } from "./MetabolicDashboard/api/metabolicStealthHealth";
|
|
11
|
+
export { buildMetabolicStealthHealthAppointmentCompletedWebhookPayload, buildMetabolicStealthHealthJunctionOrderWebhookPayload, buildMetabolicStealthHealthShortReportWebhookPayload, dispatchMetabolicStealthHealthAppointmentCompletedWebhook, dispatchMetabolicStealthHealthJunctionOrderWebhook, dispatchMetabolicStealthHealthShortReportWebhook, MetabolicStealthHealthRequestError, resolveMetabolicStealthHealthJunctionOrderId, resolveMetabolicStealthHealthJunctionStatus, STEALTH_HEALTH_ENROLL_QUESTIONNAIRE_COMPLETED_EVENT, STEALTH_HEALTH_SHORT_REPORT_COMPLETED_EVENT, STEALTH_HEALTH_TENANT_JUNCTION_ORDER_EVENT, submitStealthHealthPatientLabOrder, submitStealthHealthQuestionnaireSubmission, } from "./MetabolicDashboard/api/metabolicStealthHealth";
|