@apextelemed/partner-core 0.6.4 → 0.7.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 (54) hide show
  1. package/README.md +2 -2
  2. package/dist/api/index.d.ts +1 -1
  3. package/dist/api/index.js +3 -3
  4. package/dist/api/index.jsx +3 -3
  5. package/dist/{cart-D4mVX_zx.d.ts → cart-o6DpAu5y.d.ts} +1 -0
  6. package/dist/chunk/{WLEIDQ5M.jsx → 4S4MTN2K.jsx} +6 -2
  7. package/dist/chunk/{NBB2VTQK.jsx → 4SFB2SS2.jsx} +2 -2
  8. package/dist/chunk/{BVLA7ATM.js → 64RJJFEH.js} +3 -3
  9. package/dist/chunk/{BVLA7ATM.js.map → 64RJJFEH.js.map} +1 -1
  10. package/dist/chunk/{EVCGDF5D.jsx → 7AFUT5S3.jsx} +9 -1
  11. package/dist/chunk/{ZDBW3JDO.jsx → 7AMVRNYX.jsx} +3286 -1423
  12. package/dist/chunk/{4ZSZHZQV.jsx → CBOGAYTL.jsx} +2 -2
  13. package/dist/chunk/{YJEHCCLY.js → EXXI5Y7I.js} +4 -3
  14. package/dist/chunk/EXXI5Y7I.js.map +1 -0
  15. package/dist/chunk/{MTCQREMZ.js → F34QLV7Z.js} +4063 -2058
  16. package/dist/chunk/F34QLV7Z.js.map +1 -0
  17. package/dist/chunk/{MLXPHJLR.js → GODF2NJN.js} +7 -3
  18. package/dist/chunk/GODF2NJN.js.map +1 -0
  19. package/dist/chunk/{WUE4VQBA.js → J3IRPONP.js} +392 -21
  20. package/dist/chunk/J3IRPONP.js.map +1 -0
  21. package/dist/chunk/{QTGJY3YQ.js → J3OK2PQA.js} +3 -3
  22. package/dist/chunk/{QTGJY3YQ.js.map → J3OK2PQA.js.map} +1 -1
  23. package/dist/chunk/{NSRQXBHK.js → KXO4U2C6.js} +8 -189
  24. package/dist/chunk/KXO4U2C6.js.map +1 -0
  25. package/dist/chunk/{HXMLRDIJ.jsx → PA66KUAU.jsx} +418 -26
  26. package/dist/chunk/{2OXI5TKO.jsx → RSMUKR4J.jsx} +3 -2
  27. package/dist/chunk/{5HNZ7SEM.jsx → SHXH72AC.jsx} +26 -219
  28. package/dist/chunk/{BEDW4XUM.js → UPZPR5TU.js} +10 -2
  29. package/dist/chunk/UPZPR5TU.js.map +1 -0
  30. package/dist/{client-B6Kt7LWo.d.ts → client-CiHb-dIf.d.ts} +64 -8
  31. package/dist/flows/index.d.ts +157 -13
  32. package/dist/flows/index.js +6 -6
  33. package/dist/flows/index.jsx +25 -13
  34. package/dist/index/index.d.ts +4 -4
  35. package/dist/index/index.js +8 -8
  36. package/dist/index/index.jsx +40 -16
  37. package/dist/pages/index.d.ts +41 -6
  38. package/dist/pages/index.js +5 -5
  39. package/dist/pages/index.jsx +19 -7
  40. package/dist/primitives/default/index.js +1 -1
  41. package/dist/primitives/default/index.jsx +1 -1
  42. package/dist/stores/index.d.ts +2 -2
  43. package/dist/stores/index.js +2 -2
  44. package/dist/stores/index.jsx +2 -2
  45. package/dist/testing/seam-suite.js +1 -1
  46. package/dist/theme/admin.css +406 -1
  47. package/dist/theme/member-portal.css +5 -5
  48. package/package.json +1 -1
  49. package/dist/chunk/BEDW4XUM.js.map +0 -1
  50. package/dist/chunk/MLXPHJLR.js.map +0 -1
  51. package/dist/chunk/MTCQREMZ.js.map +0 -1
  52. package/dist/chunk/NSRQXBHK.js.map +0 -1
  53. package/dist/chunk/WUE4VQBA.js.map +0 -1
  54. package/dist/chunk/YJEHCCLY.js.map +0 -1
@@ -8,7 +8,7 @@ import {
8
8
  readPromoCode,
9
9
  resetCartId,
10
10
  stripCartToken
11
- } from "./4ZSZHZQV.jsx";
11
+ } from "./CBOGAYTL.jsx";
12
12
  import {
13
13
  firstAddressError,
14
14
  formatCardNumber,
@@ -18,210 +18,24 @@ import {
18
18
  useAddressPair,
19
19
  useCardTokenizer,
20
20
  validateAddress
21
- } from "./HXMLRDIJ.jsx";
21
+ } from "./PA66KUAU.jsx";
22
22
  import {
23
23
  auth_default,
24
- cart_default,
25
- medication_default
26
- } from "./WLEIDQ5M.jsx";
24
+ cart_default
25
+ } from "./4S4MTN2K.jsx";
27
26
  import {
28
27
  ApiError,
29
28
  newIdempotencyKey,
30
- productsApi,
31
29
  promoCodesApi,
32
30
  subscriptionsApi,
33
31
  usersApi
34
- } from "./EVCGDF5D.jsx";
32
+ } from "./7AFUT5S3.jsx";
35
33
  import {
36
34
  getConfig
37
35
  } from "./LDZIUFDM.jsx";
38
36
 
39
- // src/flows/products.ts
40
- import { createMemo, createResource, createSignal } from "solid-js";
41
- function priceForDosage(product, dosage) {
42
- const overlay = (product.dosage_prices ?? []).find((d) => d.dosage === dosage);
43
- if (overlay && overlay.price != null) return overlay.price;
44
- return product.price;
45
- }
46
- function lowestPrice(product) {
47
- const available = product.available_dosages ?? [];
48
- if (available.length === 0) return product.price;
49
- let min = null;
50
- for (const dose of available) {
51
- const p = priceForDosage(product, dose);
52
- if (p != null && (min == null || p < min)) min = p;
53
- }
54
- return min ?? product.price;
55
- }
56
- function lowestSalePrice(product, basePrice) {
57
- if (basePrice == null || !product.activeSale) return null;
58
- const sale = product.activeSale;
59
- const baseCents = Math.round(basePrice * 100);
60
- if (sale.discountCents <= 0) return null;
61
- if (product.salePriceCents != null && product.price != null && Math.abs(product.price - basePrice) < 1e-3) {
62
- return product.salePriceCents / 100;
63
- }
64
- if (product.price != null && product.salePriceCents != null && product.price > 0) {
65
- const ratio = product.salePriceCents / Math.round(product.price * 100);
66
- return Math.max(0, basePrice * ratio);
67
- }
68
- return Math.max(0, (baseCents - sale.discountCents) / 100);
69
- }
70
- function useCatalog() {
71
- const [products] = createResource(async () => {
72
- try {
73
- const res = await productsApi.list();
74
- return res.products;
75
- } catch {
76
- return [];
77
- }
78
- });
79
- const weightLoss = () => (products() ?? []).filter((p) => (p.categories ?? []).includes("weight-loss"));
80
- const peptides = () => (products() ?? []).filter((p) => !(p.categories ?? []).includes("weight-loss"));
81
- const filterByCategory = (slug) => (products() ?? []).filter((p) => (p.categories ?? []).includes(slug));
82
- return { products, weightLoss, peptides, filterByCategory };
83
- }
84
- function useProductDetail(productId) {
85
- const [product] = createResource(productId, async (id) => {
86
- if (!id) return null;
87
- try {
88
- const res = await productsApi.list();
89
- return res.products.find((p) => p.id === id) ?? null;
90
- } catch {
91
- return null;
92
- }
93
- });
94
- const pricingMode = createMemo(
95
- () => product()?.pricing_mode ?? "per_dose"
96
- );
97
- const dosageOptions = createMemo(() => {
98
- const p = product();
99
- if (!p) return [];
100
- const all = (p.available_dosages ?? []).map((dosage) => {
101
- const overlay = (p.dosage_prices ?? []).find((d) => d.dosage === dosage);
102
- const price = overlay && overlay.price != null ? overlay.price : p.price;
103
- return { dosage, price, savingsPrice: overlay?.savingsPrice ?? null };
104
- }).filter((o) => o.price != null);
105
- if (pricingMode() !== "flat_fee" || all.length === 0) return all;
106
- const override = p.dosage_override;
107
- const chosen = override && all.find((d) => d.dosage === override) || all[0];
108
- return [chosen];
109
- });
110
- const [selectedDosage, setSelectedDosage] = createSignal("");
111
- createMemo(() => {
112
- const opts = dosageOptions();
113
- if (opts.length > 0 && !selectedDosage()) setSelectedDosage(opts[0].dosage);
114
- });
115
- const selectedPrice = createMemo(() => {
116
- const opts = dosageOptions();
117
- const chosen = opts.find((d) => d.dosage === selectedDosage());
118
- if (chosen) return chosen.price;
119
- return product()?.price ?? null;
120
- });
121
- const selectedSalePrice = createMemo(() => {
122
- const p = product();
123
- const base = selectedPrice();
124
- if (!p || base == null || !p.activeSale) return null;
125
- if (p.salePriceCents != null && p.price != null && p.price > 0) {
126
- const ratio = p.salePriceCents / Math.round(p.price * 100);
127
- return Math.max(0, base * ratio);
128
- }
129
- return Math.max(0, base - p.activeSale.discountCents / 100);
130
- });
131
- const inCart = createMemo(() => {
132
- const p = product();
133
- if (!p) return false;
134
- const dosage = selectedDosage() || (dosageOptions()[0]?.dosage ?? "");
135
- const key = cart_default.itemKey(p.id, dosage);
136
- return cart_default.items().some((i) => cart_default.itemKey(i.productId, i.dosage) === key);
137
- });
138
- function addToCart() {
139
- const p = product();
140
- if (!p) return;
141
- const dosage = selectedDosage() || (dosageOptions()[0]?.dosage ?? "");
142
- const effective = selectedSalePrice() ?? selectedPrice() ?? 0;
143
- const priceCents = Math.round(effective * 100);
144
- cart_default.add({
145
- productId: p.id,
146
- productName: p.name,
147
- dosage,
148
- quantity: 1,
149
- priceCents,
150
- drugId: p.id,
151
- apexDrugId: p.apex_drug_id ?? null,
152
- categories: p.categories ?? [],
153
- thumbnailUrl: p.thumbnail_url ?? void 0,
154
- hideDoseLabel: pricingMode() === "flat_fee" ? true : void 0,
155
- isSubscription: p.is_subscription ? true : void 0
156
- });
157
- cart_default.open();
158
- }
159
- return {
160
- product,
161
- dosageOptions,
162
- selectedDosage,
163
- setSelectedDosage,
164
- selectedPrice,
165
- selectedSalePrice,
166
- pricingMode,
167
- inCart,
168
- addToCart
169
- };
170
- }
171
- function useMedicationSelect(options = {}) {
172
- const catalog = useCatalog();
173
- function selectMedication(product) {
174
- medication_default.select({ drugId: product.id, drugName: product.name });
175
- options.onSelected?.();
176
- }
177
- function selectGeneralConsultation() {
178
- medication_default.select({
179
- drugId: null,
180
- drugName: options.generalConsultationLabel ?? "General Consultation"
181
- });
182
- options.onSelected?.();
183
- }
184
- return {
185
- products: catalog.products,
186
- weightLoss: catalog.weightLoss,
187
- peptides: catalog.peptides,
188
- selectMedication,
189
- selectGeneralConsultation
190
- };
191
- }
192
-
193
- // src/flows/categoryVisual.ts
194
- function hashId(id) {
195
- let h = 5381;
196
- for (let i = 0; i < id.length; i++) h = (h << 5) + h + id.charCodeAt(i) | 0;
197
- return Math.abs(h);
198
- }
199
- var DEFAULT_COLOR_PALETTE = [
200
- "#4f46e5",
201
- // indigo
202
- "#0891b2",
203
- // cyan
204
- "#0d9488",
205
- // teal
206
- "#f59e0b",
207
- // amber
208
- "#e11d48",
209
- // rose
210
- "#10b981",
211
- // emerald
212
- "#8b5cf6",
213
- // violet
214
- "#f97316"
215
- // orange
216
- ];
217
- function categoryColor(id, opts = {}) {
218
- const palette = opts.palette ?? DEFAULT_COLOR_PALETTE;
219
- if (palette.length === 0) return "currentColor";
220
- return palette[hashId(id) % palette.length];
221
- }
222
-
223
37
  // src/flows/subscriptionIntake.ts
224
- import { createEffect, createSignal as createSignal2, onMount } from "solid-js";
38
+ import { createEffect, createSignal, onMount } from "solid-js";
225
39
  var DRAFT_TTL_MS = 7 * 24 * 3600 * 1e3;
226
40
  var MAX_RESTORABLE_STEP = 1;
227
41
  function draftKey() {
@@ -257,17 +71,17 @@ function useSubscriptionIntakeFlow(options) {
257
71
  const accept = useCardTokenizer();
258
72
  let restored = {};
259
73
  if (typeof window !== "undefined") restored = loadDraft();
260
- const [step, setStep] = createSignal2(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP));
261
- const [error, setError] = createSignal2(null);
262
- const [tokenizing, setTokenizing] = createSignal2(false);
263
- const [submitting, setSubmitting] = createSignal2(false);
264
- const [outcome, setOutcome] = createSignal2({ kind: "in_progress" });
265
- const [firstName, setFirstName] = createSignal2(restored.firstName ?? "");
266
- const [lastName, setLastName] = createSignal2(restored.lastName ?? "");
267
- const [email, setEmail] = createSignal2(restored.email ?? "");
268
- const [password, setPassword] = createSignal2("");
269
- const [dateOfBirth, setDateOfBirth] = createSignal2(restored.dateOfBirth ?? "");
270
- const [phone, setPhone] = createSignal2(restored.phone ?? "");
74
+ const [step, setStep] = createSignal(Math.min(restored.step ?? 0, MAX_RESTORABLE_STEP));
75
+ const [error, setError] = createSignal(null);
76
+ const [tokenizing, setTokenizing] = createSignal(false);
77
+ const [submitting, setSubmitting] = createSignal(false);
78
+ const [outcome, setOutcome] = createSignal({ kind: "in_progress" });
79
+ const [firstName, setFirstName] = createSignal(restored.firstName ?? "");
80
+ const [lastName, setLastName] = createSignal(restored.lastName ?? "");
81
+ const [email, setEmail] = createSignal(restored.email ?? "");
82
+ const [password, setPassword] = createSignal("");
83
+ const [dateOfBirth, setDateOfBirth] = createSignal(restored.dateOfBirth ?? "");
84
+ const [phone, setPhone] = createSignal(restored.phone ?? "");
271
85
  const addr = useAddressPair({
272
86
  initialShipping: {
273
87
  street: restored.street ?? "",
@@ -284,13 +98,13 @@ function useSubscriptionIntakeFlow(options) {
284
98
  const b = addr.effectiveBilling();
285
99
  return { street: b.street.trim(), city: b.city.trim(), state: b.state, zip: b.zip.trim() };
286
100
  };
287
- const [cardNumberRaw, setCardNumberRaw] = createSignal2("", { equals: false });
288
- const [expiryRaw, setExpiryRaw] = createSignal2("", { equals: false });
289
- const [cvvRaw, setCvvRaw] = createSignal2("", { equals: false });
290
- const [promoCode, setPromoCode] = createSignal2("");
291
- const [promoValidating, setPromoValidating] = createSignal2(false);
292
- const [promoError, setPromoError] = createSignal2(null);
293
- const [promoApplied, setPromoApplied] = createSignal2(null);
101
+ const [cardNumberRaw, setCardNumberRaw] = createSignal("", { equals: false });
102
+ const [expiryRaw, setExpiryRaw] = createSignal("", { equals: false });
103
+ const [cvvRaw, setCvvRaw] = createSignal("", { equals: false });
104
+ const [promoCode, setPromoCode] = createSignal("");
105
+ const [promoValidating, setPromoValidating] = createSignal(false);
106
+ const [promoError, setPromoError] = createSignal(null);
107
+ const [promoApplied, setPromoApplied] = createSignal(null);
294
108
  onMount(async () => {
295
109
  if (promoCode().trim()) return;
296
110
  const stashed = readPromoCode();
@@ -307,7 +121,7 @@ function useSubscriptionIntakeFlow(options) {
307
121
  } catch {
308
122
  }
309
123
  });
310
- const [idemKey, setIdemKey] = createSignal2(restored.idempotencyKey ?? "");
124
+ const [idemKey, setIdemKey] = createSignal(restored.idempotencyKey ?? "");
311
125
  onMount(() => {
312
126
  createEffect(() => {
313
127
  saveDraft({
@@ -762,16 +576,9 @@ function startCartCapture(opts = {}) {
762
576
  }
763
577
 
764
578
  export {
765
- lowestPrice,
766
- lowestSalePrice,
767
- useCatalog,
768
- useProductDetail,
769
- useMedicationSelect,
770
- DEFAULT_COLOR_PALETTE,
771
- categoryColor,
772
579
  useSubscriptionIntakeFlow,
773
580
  validateResumedPromo,
774
581
  restoreCartFromLink,
775
582
  startCartCapture
776
583
  };
777
- //# sourceMappingURL=5HNZ7SEM.jsx.map
584
+ //# sourceMappingURL=SHXH72AC.jsx.map
@@ -593,6 +593,14 @@ var subscriptionsApi = {
593
593
  { idempotencyKey: opts?.idempotencyKey }
594
594
  );
595
595
  },
596
+ /** Server-priced quote for `create(payload)` — same model, guards and pricing
597
+ * as the charge, nothing charged. 404 on a backend that predates it. */
598
+ preview(payload) {
599
+ return post("/subscriptions/preview", {
600
+ ...payload,
601
+ affiliateRef: readAffiliateRef() ?? void 0
602
+ });
603
+ },
596
604
  get(id) {
597
605
  return apiFetch(`/subscriptions/${id}`);
598
606
  },
@@ -1290,5 +1298,5 @@ var affiliatePortalApi = {
1290
1298
  };
1291
1299
 
1292
1300
  export { ApiError, SUPPORT_ATTACHMENT_MAX_BYTES, SUPPORT_ATTACHMENT_MIME_TYPES, addressesApi, adminAffiliatesApi, adminApi, affiliateAuthStorageKey, affiliatePortalApi, apexApi, apiFetch, authApi, authStorageKey, captureAffiliateRef, clearAffiliateRef, clearAffiliateTokens, clearTokens, getAffiliateTokens, getTokens, membersApi, messagesApi, newIdempotencyKey, onTokensCleared, ordersApi, paymentsApi, productsApi, promoCodesApi, readAffiliateRef, setAffiliateTokens, setTokens, subscriptionsApi, supportApi, usersApi };
1293
- //# sourceMappingURL=BEDW4XUM.js.map
1294
- //# sourceMappingURL=BEDW4XUM.js.map
1301
+ //# sourceMappingURL=UPZPR5TU.js.map
1302
+ //# sourceMappingURL=UPZPR5TU.js.map