@apextelemed/partner-core 0.1.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.
Files changed (114) hide show
  1. package/LICENSE +64 -0
  2. package/README.md +363 -0
  3. package/dist/api/index.d.ts +12 -0
  4. package/dist/api/index.js +8 -0
  5. package/dist/api/index.js.map +1 -0
  6. package/dist/api/index.jsx +127 -0
  7. package/dist/cart-CBH8Em8f.d.ts +189 -0
  8. package/dist/cart-D4mVX_zx.d.ts +66 -0
  9. package/dist/chunk/2OXI5TKO.jsx +249 -0
  10. package/dist/chunk/3A3MF7R2.jsx +1 -0
  11. package/dist/chunk/3VEOP7TZ.jsx +16679 -0
  12. package/dist/chunk/5XGPFYIJ.js +26 -0
  13. package/dist/chunk/5XGPFYIJ.js.map +1 -0
  14. package/dist/chunk/67KHO66G.js +26 -0
  15. package/dist/chunk/67KHO66G.js.map +1 -0
  16. package/dist/chunk/6TFBQECC.jsx +135 -0
  17. package/dist/chunk/AN3WPMEP.js +3 -0
  18. package/dist/chunk/AN3WPMEP.js.map +1 -0
  19. package/dist/chunk/DHII7L5Y.js +686 -0
  20. package/dist/chunk/DHII7L5Y.js.map +1 -0
  21. package/dist/chunk/DS4E7FAI.js +132 -0
  22. package/dist/chunk/DS4E7FAI.js.map +1 -0
  23. package/dist/chunk/DY5BJ6UG.js +1195 -0
  24. package/dist/chunk/DY5BJ6UG.js.map +1 -0
  25. package/dist/chunk/E7722UPF.js +378 -0
  26. package/dist/chunk/E7722UPF.js.map +1 -0
  27. package/dist/chunk/HLXKWRRW.js +16774 -0
  28. package/dist/chunk/HLXKWRRW.js.map +1 -0
  29. package/dist/chunk/I46Y2J5W.jsx +144 -0
  30. package/dist/chunk/J63XPQP4.jsx +21 -0
  31. package/dist/chunk/J6KNY37T.js +122 -0
  32. package/dist/chunk/J6KNY37T.js.map +1 -0
  33. package/dist/chunk/KNTZTYXE.jsx +3315 -0
  34. package/dist/chunk/KZZSQ7LP.jsx +409 -0
  35. package/dist/chunk/L46OKCKG.jsx +733 -0
  36. package/dist/chunk/LDZIUFDM.jsx +31 -0
  37. package/dist/chunk/LZWA44KD.js +3 -0
  38. package/dist/chunk/LZWA44KD.js.map +1 -0
  39. package/dist/chunk/NVRAOAVV.js +3 -0
  40. package/dist/chunk/NVRAOAVV.js.map +1 -0
  41. package/dist/chunk/O3QK7YZR.jsx +1 -0
  42. package/dist/chunk/UZCST66N.jsx +21 -0
  43. package/dist/chunk/V42CGY2S.jsx +1229 -0
  44. package/dist/chunk/YJEHCCLY.js +467 -0
  45. package/dist/chunk/YJEHCCLY.js.map +1 -0
  46. package/dist/chunk/ZMOG2IIC.js +3194 -0
  47. package/dist/chunk/ZMOG2IIC.js.map +1 -0
  48. package/dist/client-BzSg2DEK.d.ts +1539 -0
  49. package/dist/config/index.d.ts +55 -0
  50. package/dist/config/index.js +3 -0
  51. package/dist/config/index.js.map +1 -0
  52. package/dist/config/index.jsx +11 -0
  53. package/dist/flows/index.d.ts +1322 -0
  54. package/dist/flows/index.js +9 -0
  55. package/dist/flows/index.js.map +1 -0
  56. package/dist/flows/index.jsx +124 -0
  57. package/dist/index/index.d.ts +71 -0
  58. package/dist/index/index.js +15 -0
  59. package/dist/index/index.js.map +1 -0
  60. package/dist/index/index.jsx +311 -0
  61. package/dist/pages/index.d.ts +617 -0
  62. package/dist/pages/index.js +10 -0
  63. package/dist/pages/index.js.map +1 -0
  64. package/dist/pages/index.jsx +50 -0
  65. package/dist/primitives/default/index.d.ts +6 -0
  66. package/dist/primitives/default/index.js +3 -0
  67. package/dist/primitives/default/index.js.map +1 -0
  68. package/dist/primitives/default/index.jsx +7 -0
  69. package/dist/primitives/index.d.ts +122 -0
  70. package/dist/primitives/index.js +3 -0
  71. package/dist/primitives/index.js.map +1 -0
  72. package/dist/primitives/index.jsx +9 -0
  73. package/dist/stores/index.d.ts +48 -0
  74. package/dist/stores/index.js +6 -0
  75. package/dist/stores/index.js.map +1 -0
  76. package/dist/stores/index.jsx +16 -0
  77. package/dist/surveyV2-BgQHK0GE.d.ts +48 -0
  78. package/dist/testing/adapter.d.ts +104 -0
  79. package/dist/testing/adapter.d.ts.map +1 -0
  80. package/dist/testing/adapter.js +14 -0
  81. package/dist/testing/adapter.js.map +1 -0
  82. package/dist/testing/env.d.ts +29 -0
  83. package/dist/testing/env.d.ts.map +1 -0
  84. package/dist/testing/env.js +42 -0
  85. package/dist/testing/env.js.map +1 -0
  86. package/dist/testing/fixtures.d.ts +70 -0
  87. package/dist/testing/fixtures.d.ts.map +1 -0
  88. package/dist/testing/fixtures.js +74 -0
  89. package/dist/testing/fixtures.js.map +1 -0
  90. package/dist/testing/index.d.ts +15 -0
  91. package/dist/testing/index.d.ts.map +1 -0
  92. package/dist/testing/index.js +14 -0
  93. package/dist/testing/index.js.map +1 -0
  94. package/dist/testing/mocks.d.ts +53 -0
  95. package/dist/testing/mocks.d.ts.map +1 -0
  96. package/dist/testing/mocks.js +90 -0
  97. package/dist/testing/mocks.js.map +1 -0
  98. package/dist/testing/seam-suite.d.ts +39 -0
  99. package/dist/testing/seam-suite.d.ts.map +1 -0
  100. package/dist/testing/seam-suite.js +196 -0
  101. package/dist/testing/seam-suite.js.map +1 -0
  102. package/dist/testing/storage.d.ts +40 -0
  103. package/dist/testing/storage.d.ts.map +1 -0
  104. package/dist/testing/storage.js +71 -0
  105. package/dist/testing/storage.js.map +1 -0
  106. package/dist/theme/admin.css +579 -0
  107. package/dist/theme/affiliate.css +191 -0
  108. package/dist/theme/flow.css +497 -0
  109. package/dist/theme/index.d.ts +84 -0
  110. package/dist/theme/index.js +94 -0
  111. package/dist/theme/index.js.map +1 -0
  112. package/dist/theme/index.jsx +97 -0
  113. package/dist/theme/member-portal.css +1762 -0
  114. package/package.json +199 -0
@@ -0,0 +1,409 @@
1
+ import {
2
+ ApiError,
3
+ affiliateAuthStorageKey,
4
+ affiliatePortalApi,
5
+ authApi,
6
+ authStorageKey,
7
+ clearAffiliateTokens,
8
+ clearTokens,
9
+ getAffiliateTokens,
10
+ getTokens,
11
+ onTokensCleared,
12
+ setAffiliateTokens,
13
+ setTokens,
14
+ usersApi
15
+ } from "./V42CGY2S.jsx";
16
+ import {
17
+ getConfig,
18
+ onConfigured
19
+ } from "./LDZIUFDM.jsx";
20
+
21
+ // src/stores/cart.ts
22
+ import { createSignal, createRoot } from "solid-js";
23
+ var cartStorageKey = () => `${getConfig().storagePrefix}-cart`;
24
+ var promoStorageKey = () => `${getConfig().storagePrefix}-cart-promo`;
25
+ function itemKey(productId, dosage) {
26
+ return `${productId}::${dosage}`;
27
+ }
28
+ function loadInitial() {
29
+ try {
30
+ const raw = localStorage.getItem(cartStorageKey());
31
+ if (!raw) return [];
32
+ const parsed = JSON.parse(raw);
33
+ if (!Array.isArray(parsed)) return [];
34
+ return parsed.map((i) => ({
35
+ ...i,
36
+ quantity: Number.isInteger(i.quantity) && i.quantity > 0 ? i.quantity : 1
37
+ }));
38
+ } catch {
39
+ return [];
40
+ }
41
+ }
42
+ function loadInitialPromo() {
43
+ try {
44
+ const raw = localStorage.getItem(promoStorageKey());
45
+ if (!raw) return null;
46
+ return JSON.parse(raw);
47
+ } catch {
48
+ return null;
49
+ }
50
+ }
51
+ function persist(items) {
52
+ try {
53
+ localStorage.setItem(cartStorageKey(), JSON.stringify(items));
54
+ } catch {
55
+ }
56
+ }
57
+ function persistPromo(promo) {
58
+ try {
59
+ if (promo) localStorage.setItem(promoStorageKey(), JSON.stringify(promo));
60
+ else localStorage.removeItem(promoStorageKey());
61
+ } catch {
62
+ }
63
+ }
64
+ function createCartStore() {
65
+ const [items, setItems] = createSignal(loadInitial());
66
+ const [isOpen, setIsOpen] = createSignal(false);
67
+ const [appliedPromo, setAppliedPromo] = createSignal(loadInitialPromo());
68
+ function write(next) {
69
+ setItems(next);
70
+ persist(next);
71
+ }
72
+ function count() {
73
+ return items().length;
74
+ }
75
+ function subtotalCents() {
76
+ return items().reduce((sum, i) => sum + i.priceCents * (i.quantity || 1), 0);
77
+ }
78
+ function add(item) {
79
+ const key = itemKey(item.productId, item.dosage);
80
+ const current = items();
81
+ if (current.some((i) => itemKey(i.productId, i.dosage) === key)) return;
82
+ write([...current, { ...item, quantity: 1 }]);
83
+ }
84
+ function remove(key) {
85
+ write(items().filter((i) => itemKey(i.productId, i.dosage) !== key));
86
+ }
87
+ function setQuantity(key, quantity) {
88
+ if (!Number.isFinite(quantity)) return;
89
+ const clamped = Math.max(1, Math.floor(quantity));
90
+ const current = items();
91
+ if (!current.some((i) => itemKey(i.productId, i.dosage) === key)) return;
92
+ write(current.map((i) => itemKey(i.productId, i.dosage) === key ? { ...i, quantity: clamped } : i));
93
+ }
94
+ function clear() {
95
+ write([]);
96
+ }
97
+ function hasGlp1() {
98
+ return items().some(
99
+ (i) => i.categories.some((c) => c.toLowerCase().includes("weight") || c.toLowerCase().includes("glp"))
100
+ );
101
+ }
102
+ function isMultiItem() {
103
+ return items().length > 1;
104
+ }
105
+ function setPromo(promo) {
106
+ setAppliedPromo(promo);
107
+ persistPromo(promo);
108
+ }
109
+ return {
110
+ items,
111
+ count,
112
+ subtotalCents,
113
+ add,
114
+ remove,
115
+ setQuantity,
116
+ clear,
117
+ hasGlp1,
118
+ isMultiItem,
119
+ itemKey,
120
+ isOpen,
121
+ open: () => setIsOpen(true),
122
+ close: () => setIsOpen(false),
123
+ toggle: () => setIsOpen((v) => !v),
124
+ appliedPromo,
125
+ setPromo
126
+ };
127
+ }
128
+ var cartStore = createRoot(createCartStore);
129
+ var cart_default = cartStore;
130
+
131
+ // src/stores/auth.ts
132
+ import { createSignal as createSignal2, createRoot as createRoot2 } from "solid-js";
133
+ function createAuthStore() {
134
+ const [tokens, _setTokens] = createSignal2(null);
135
+ const [user, setUser] = createSignal2(null);
136
+ const [isAuthenticated, setIsAuthenticated] = createSignal2(false);
137
+ const [isAdmin, setIsAdmin] = createSignal2(false);
138
+ const [loading, setLoading] = createSignal2(false);
139
+ function dropSession() {
140
+ _setTokens(null);
141
+ setIsAuthenticated(false);
142
+ setIsAdmin(false);
143
+ setUser(null);
144
+ }
145
+ function syncTokens(t) {
146
+ _setTokens(t);
147
+ if (t) {
148
+ setTokens(t);
149
+ setIsAuthenticated(true);
150
+ } else {
151
+ clearTokens();
152
+ dropSession();
153
+ cart_default.clear();
154
+ cart_default.setPromo(null);
155
+ }
156
+ }
157
+ onTokensCleared("patient", dropSession);
158
+ if (typeof window !== "undefined") {
159
+ window.addEventListener("storage", (e) => {
160
+ let key;
161
+ try {
162
+ key = authStorageKey();
163
+ } catch {
164
+ return;
165
+ }
166
+ if (e.key !== null && e.key !== key) return;
167
+ const stored = getTokens();
168
+ if (stored?.accessToken) {
169
+ const wasAuthenticated = isAuthenticated();
170
+ _setTokens(stored);
171
+ setIsAuthenticated(true);
172
+ if (!wasAuthenticated) void fetchProfile();
173
+ } else {
174
+ dropSession();
175
+ }
176
+ });
177
+ }
178
+ async function fetchProfile() {
179
+ try {
180
+ const res = await usersApi.getProfile();
181
+ if (res.data) {
182
+ setUser(res.data);
183
+ setIsAdmin(res.data.role === "admin");
184
+ }
185
+ } catch (err) {
186
+ if (err instanceof ApiError && (err.status === 401 || err.status === 403)) {
187
+ syncTokens(null);
188
+ }
189
+ }
190
+ }
191
+ let hydrated = false;
192
+ function hydrate() {
193
+ if (hydrated) return;
194
+ hydrated = true;
195
+ const stored = getTokens();
196
+ if (stored?.accessToken) {
197
+ _setTokens(stored);
198
+ setIsAuthenticated(true);
199
+ fetchProfile();
200
+ }
201
+ }
202
+ onConfigured(hydrate);
203
+ async function login(email, password) {
204
+ setLoading(true);
205
+ try {
206
+ const res = await authApi.login({ email, password });
207
+ if (res.data) {
208
+ syncTokens({
209
+ accessToken: res.data.accessToken,
210
+ refreshToken: res.data.refreshToken,
211
+ userId: res.data.userId
212
+ });
213
+ await fetchProfile();
214
+ }
215
+ } finally {
216
+ setLoading(false);
217
+ }
218
+ }
219
+ async function signup(payload) {
220
+ setLoading(true);
221
+ try {
222
+ const res = await authApi.register(payload);
223
+ if (res.data) {
224
+ syncTokens({
225
+ accessToken: res.data.accessToken,
226
+ refreshToken: res.data.refreshToken,
227
+ userId: res.data.userId
228
+ });
229
+ await fetchProfile();
230
+ }
231
+ } finally {
232
+ setLoading(false);
233
+ }
234
+ }
235
+ async function signupAndSubscribe(payload, opts) {
236
+ setLoading(true);
237
+ try {
238
+ const res = await authApi.registerAndSubscribe(payload, opts);
239
+ if (res.data) {
240
+ syncTokens({
241
+ accessToken: res.data.accessToken,
242
+ refreshToken: res.data.refreshToken,
243
+ userId: res.data.userId
244
+ });
245
+ await fetchProfile();
246
+ return res.data;
247
+ }
248
+ } finally {
249
+ setLoading(false);
250
+ }
251
+ }
252
+ function logout() {
253
+ syncTokens(null);
254
+ }
255
+ return {
256
+ // Reactive getters
257
+ tokens,
258
+ user,
259
+ isAuthenticated,
260
+ isAdmin,
261
+ loading,
262
+ // Actions
263
+ login,
264
+ signup,
265
+ signupAndSubscribe,
266
+ logout,
267
+ fetchProfile
268
+ };
269
+ }
270
+ var authStore = createRoot2(createAuthStore);
271
+ var auth_default = authStore;
272
+
273
+ // src/stores/affiliateAuth.ts
274
+ import { createSignal as createSignal3, createRoot as createRoot3 } from "solid-js";
275
+ function createAffiliateAuthStore() {
276
+ const [tokens, _setTokens] = createSignal3(null);
277
+ const [affiliate, setAffiliate] = createSignal3(null);
278
+ const [isAuthenticated, setIsAuthenticated] = createSignal3(false);
279
+ const [isHydrated, setIsHydrated] = createSignal3(false);
280
+ const [loading, setLoading] = createSignal3(false);
281
+ function dropSession() {
282
+ _setTokens(null);
283
+ setIsAuthenticated(false);
284
+ setAffiliate(null);
285
+ }
286
+ function syncTokens(t) {
287
+ _setTokens(t);
288
+ if (t) {
289
+ setAffiliateTokens(t);
290
+ setIsAuthenticated(true);
291
+ } else {
292
+ clearAffiliateTokens();
293
+ dropSession();
294
+ }
295
+ }
296
+ onTokensCleared("affiliate", dropSession);
297
+ if (typeof window !== "undefined") {
298
+ window.addEventListener("storage", (e) => {
299
+ let key;
300
+ try {
301
+ key = affiliateAuthStorageKey();
302
+ } catch {
303
+ return;
304
+ }
305
+ if (e.key !== null && e.key !== key) return;
306
+ const stored = getAffiliateTokens();
307
+ if (stored?.accessToken) {
308
+ const wasAuthenticated = isAuthenticated();
309
+ _setTokens(stored);
310
+ setIsAuthenticated(true);
311
+ if (!wasAuthenticated) void fetchProfile();
312
+ } else {
313
+ dropSession();
314
+ }
315
+ });
316
+ }
317
+ async function fetchProfile() {
318
+ try {
319
+ const res = await affiliatePortalApi.getProfile();
320
+ setAffiliate(res.affiliate);
321
+ } catch (err) {
322
+ if (err instanceof ApiError && (err.status === 401 || err.status === 403)) {
323
+ syncTokens(null);
324
+ }
325
+ } finally {
326
+ setIsHydrated(true);
327
+ }
328
+ }
329
+ let hydrated = false;
330
+ function hydrate() {
331
+ if (hydrated) return;
332
+ hydrated = true;
333
+ const stored = getAffiliateTokens();
334
+ if (stored?.accessToken) {
335
+ _setTokens(stored);
336
+ setIsAuthenticated(true);
337
+ fetchProfile();
338
+ } else {
339
+ setIsHydrated(true);
340
+ }
341
+ }
342
+ onConfigured(hydrate);
343
+ async function login(email, password) {
344
+ setLoading(true);
345
+ try {
346
+ const session = await affiliatePortalApi.login(email, password);
347
+ syncTokens({
348
+ accessToken: session.idToken,
349
+ refreshToken: session.refreshToken,
350
+ affiliateId: session.affiliateId
351
+ });
352
+ setIsHydrated(false);
353
+ await fetchProfile();
354
+ } finally {
355
+ setLoading(false);
356
+ }
357
+ }
358
+ async function register(input) {
359
+ setLoading(true);
360
+ try {
361
+ await affiliatePortalApi.register(input);
362
+ } finally {
363
+ setLoading(false);
364
+ }
365
+ }
366
+ async function logout() {
367
+ try {
368
+ await affiliatePortalApi.logout();
369
+ } finally {
370
+ syncTokens(null);
371
+ }
372
+ }
373
+ return {
374
+ tokens,
375
+ affiliate,
376
+ isAuthenticated,
377
+ isHydrated,
378
+ loading,
379
+ login,
380
+ register,
381
+ logout,
382
+ fetchProfile
383
+ };
384
+ }
385
+ var affiliateAuthStore = createRoot3(createAffiliateAuthStore);
386
+ var affiliateAuth_default = affiliateAuthStore;
387
+
388
+ // src/stores/medication.ts
389
+ import { createSignal as createSignal4, createRoot as createRoot4 } from "solid-js";
390
+ function createMedicationStore() {
391
+ const [selected, setSelected] = createSignal4(null);
392
+ function select(medication) {
393
+ setSelected(medication);
394
+ }
395
+ function clear() {
396
+ setSelected(null);
397
+ }
398
+ return { selected, select, clear };
399
+ }
400
+ var medicationStore = createRoot4(createMedicationStore);
401
+ var medication_default = medicationStore;
402
+
403
+ export {
404
+ cart_default,
405
+ auth_default,
406
+ affiliateAuth_default,
407
+ medication_default
408
+ };
409
+ //# sourceMappingURL=KZZSQ7LP.jsx.map