@apextelemed/partner-core 0.1.0 → 0.3.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 (51) hide show
  1. package/README.md +10 -6
  2. package/dist/api/index.d.ts +15 -2
  3. package/dist/api/index.js +3 -3
  4. package/dist/api/index.jsx +9 -3
  5. package/dist/chunk/{L46OKCKG.jsx → 6HLXYY4F.jsx} +28 -6
  6. package/dist/chunk/{3VEOP7TZ.jsx → AAWNUGML.jsx} +330 -6
  7. package/dist/chunk/ACE7M2YA.jsx +1 -0
  8. package/dist/chunk/{KNTZTYXE.jsx → B63K5R7M.jsx} +61 -10
  9. package/dist/chunk/{V42CGY2S.jsx → DUVW24DM.jsx} +1 -1
  10. package/dist/chunk/{DHII7L5Y.js → FBVNUFJM.js} +27 -7
  11. package/dist/chunk/FBVNUFJM.js.map +1 -0
  12. package/dist/chunk/{E7722UPF.js → FWUBNK42.js} +3 -3
  13. package/dist/chunk/{E7722UPF.js.map → FWUBNK42.js.map} +1 -1
  14. package/dist/chunk/JSHO46VZ.js +3 -0
  15. package/dist/chunk/JSHO46VZ.js.map +1 -0
  16. package/dist/chunk/{KZZSQ7LP.jsx → KMHMT6YP.jsx} +2 -2
  17. package/dist/chunk/{6TFBQECC.jsx → NP4CMOLW.jsx} +41 -1
  18. package/dist/chunk/{HLXKWRRW.js → QSSVQ5PR.js} +756 -404
  19. package/dist/chunk/QSSVQ5PR.js.map +1 -0
  20. package/dist/chunk/{ZMOG2IIC.js → SE6JHCPZ.js} +61 -11
  21. package/dist/chunk/SE6JHCPZ.js.map +1 -0
  22. package/dist/chunk/{DY5BJ6UG.js → UNAI6NBV.js} +2 -2
  23. package/dist/chunk/UNAI6NBV.js.map +1 -0
  24. package/dist/chunk/{J6KNY37T.js → XMYPS7PT.js} +40 -3
  25. package/dist/chunk/XMYPS7PT.js.map +1 -0
  26. package/dist/{client-BzSg2DEK.d.ts → client-CWYoMmla.d.ts} +11 -0
  27. package/dist/flows/index.d.ts +55 -7
  28. package/dist/flows/index.js +5 -5
  29. package/dist/flows/index.jsx +5 -5
  30. package/dist/index/index.d.ts +2 -2
  31. package/dist/index/index.js +7 -7
  32. package/dist/index/index.jsx +13 -7
  33. package/dist/pages/index.d.ts +1 -1
  34. package/dist/pages/index.js +4 -4
  35. package/dist/pages/index.jsx +4 -4
  36. package/dist/stores/index.d.ts +1 -1
  37. package/dist/stores/index.js +2 -2
  38. package/dist/stores/index.jsx +2 -2
  39. package/dist/testing/storage.d.ts +1 -1
  40. package/dist/testing/storage.d.ts.map +1 -1
  41. package/dist/testing/storage.js +1 -0
  42. package/dist/testing/storage.js.map +1 -1
  43. package/package.json +1 -1
  44. package/dist/chunk/AN3WPMEP.js +0 -3
  45. package/dist/chunk/AN3WPMEP.js.map +0 -1
  46. package/dist/chunk/DHII7L5Y.js.map +0 -1
  47. package/dist/chunk/DY5BJ6UG.js.map +0 -1
  48. package/dist/chunk/HLXKWRRW.js.map +0 -1
  49. package/dist/chunk/J6KNY37T.js.map +0 -1
  50. package/dist/chunk/O3QK7YZR.jsx +0 -1
  51. package/dist/chunk/ZMOG2IIC.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './DS4E7FAI.js';
2
- import { cart_default, medication_default, auth_default, affiliateAuth_default } from './E7722UPF.js';
3
- import { newIdempotencyKey, apexApi, usersApi, addressesApi, paymentsApi, subscriptionsApi, membersApi, affiliatePortalApi, ApiError, ordersApi, supportApi, messagesApi, authApi } from './DY5BJ6UG.js';
2
+ import { cart_default, medication_default, auth_default, affiliateAuth_default } from './FWUBNK42.js';
3
+ import { newIdempotencyKey, apexApi, usersApi, addressesApi, paymentsApi, subscriptionsApi, membersApi, affiliatePortalApi, ApiError, ordersApi, supportApi, messagesApi, authApi } from './UNAI6NBV.js';
4
4
  import { getConfig } from './5XGPFYIJ.js';
5
5
  import { createSignal, onMount, createEffect, onCleanup, createResource } from 'solid-js';
6
6
  import { useSurveyV2Flow as useSurveyV2Flow$1 } from '@apextelemed/survey-solid';
@@ -2299,19 +2299,35 @@ function softRelative(date, now) {
2299
2299
  const weeks = Math.round(diffDays / 7);
2300
2300
  return `in ${weeks} weeks`;
2301
2301
  }
2302
+ function parseBackendDate(value) {
2303
+ if (!value) return null;
2304
+ const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
2305
+ const d = dateOnly ? new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3])) : new Date(value);
2306
+ return Number.isNaN(d.getTime()) ? null : d;
2307
+ }
2302
2308
  function buildRefillView(sub, now = Date.now()) {
2303
- if (!sub || !sub.currentPeriodEnd) return null;
2309
+ if (!sub) return null;
2304
2310
  if (sub.status === "cancelled" || sub.status === "expired" || sub.status === "suspended") {
2305
2311
  return null;
2306
2312
  }
2307
- const periodEnd = new Date(sub.currentPeriodEnd);
2308
- if (Number.isNaN(periodEnd.getTime())) return null;
2309
2313
  const cycleLength = sub.intervalDays && sub.intervalDays > 0 ? sub.intervalDays : 30;
2314
+ const fillDate = parseBackendDate(sub.nextFillDate);
2315
+ if (!fillDate && sub.checkInStatus) {
2316
+ const events2 = [
2317
+ { key: "survey", label: "Check-in due", date: null, relative: "after your next fill", nearest: false },
2318
+ { key: "fill", label: "Next refill", date: null, relative: "once your order ships", nearest: true },
2319
+ { key: "shipment", label: "Next shipment", date: null, relative: "once your order ships", nearest: false }
2320
+ ];
2321
+ return { events: events2, cycleDay: 0, cycleLength, progress: 0, precise: true, pendingFill: true };
2322
+ }
2323
+ const periodEnd = fillDate ?? parseBackendDate(sub.currentPeriodEnd);
2324
+ if (!periodEnd) return null;
2325
+ const precise = fillDate !== null;
2310
2326
  const periodStart = new Date(periodEnd.getTime() - cycleLength * DAY_MS);
2311
2327
  const elapsed = (now - periodStart.getTime()) / DAY_MS;
2312
2328
  const cycleDay = Math.min(cycleLength, Math.max(1, Math.round(elapsed)));
2313
2329
  const progress = Math.min(1, Math.max(0, (now - periodStart.getTime()) / (cycleLength * DAY_MS)));
2314
- const surveyDate = new Date(periodEnd.getTime() - 7 * DAY_MS);
2330
+ const surveyDate = parseBackendDate(sub.checkInDueAt) ?? new Date(periodEnd.getTime() - 7 * DAY_MS);
2315
2331
  const events = [
2316
2332
  { key: "survey", label: "Check-in due", date: surveyDate, relative: "", nearest: false },
2317
2333
  { key: "fill", label: "Next refill", date: periodEnd, relative: "", nearest: false },
@@ -2321,7 +2337,7 @@ function buildRefillView(sub, now = Date.now()) {
2321
2337
  const upcoming = events.filter((e) => e.date && e.date.getTime() >= now);
2322
2338
  const nearest = upcoming.sort((a, b) => a.date.getTime() - b.date.getTime())[0] || events[0];
2323
2339
  nearest.nearest = true;
2324
- return { events, cycleDay, cycleLength, progress };
2340
+ return { events, cycleDay, cycleLength, progress, precise, pendingFill: false };
2325
2341
  }
2326
2342
  function formatStageDate(value) {
2327
2343
  if (!value) return "";
@@ -2406,7 +2422,12 @@ function useMemberPortalData() {
2406
2422
  return {
2407
2423
  status: s.status,
2408
2424
  currentPeriodEnd: s.currentPeriodEnd ?? null,
2409
- intervalDays: s.intervalDays
2425
+ intervalDays: s.intervalDays,
2426
+ // The real schedule. Must be forwarded, or buildRefillView silently falls
2427
+ // back to estimating off the billing mirror.
2428
+ nextFillDate: s.nextFillDate ?? null,
2429
+ checkInDueAt: s.checkInDueAt ?? null,
2430
+ checkInStatus: s.checkInStatus ?? null
2410
2431
  };
2411
2432
  };
2412
2433
  return {
@@ -3188,7 +3209,36 @@ function useSurveyV2Flow(opts) {
3188
3209
  onError: opts.onError
3189
3210
  });
3190
3211
  }
3212
+ var PRESCRIPTION_PHOTO_MAX_BYTES = 10 * 1024 * 1024;
3213
+ async function uploadPrescriptionPhoto(file) {
3214
+ const cfg = getConfig();
3215
+ if (!cfg.apexEmbedApiBase) {
3216
+ throw new Error("apex-partner-core: apexEmbedApiBase is not configured.");
3217
+ }
3218
+ if (file.size > PRESCRIPTION_PHOTO_MAX_BYTES) {
3219
+ throw new Error("That photo is larger than 10MB. Please retake it at a lower resolution.");
3220
+ }
3221
+ const formData = new FormData();
3222
+ formData.append("photo", file);
3223
+ const res = await fetch(`${cfg.apexEmbedApiBase}/surveys/prescription-photos`, {
3224
+ method: "POST",
3225
+ headers: {
3226
+ ...cfg.apexPublishableKey ? { "x-apex-publishable-key": cfg.apexPublishableKey } : {},
3227
+ ...cfg.tenantKey ? { "X-Tenant-Key": cfg.tenantKey } : {}
3228
+ },
3229
+ body: formData
3230
+ });
3231
+ let parsed = null;
3232
+ try {
3233
+ parsed = await res.json();
3234
+ } catch {
3235
+ }
3236
+ if (!res.ok || !parsed?.photoId) {
3237
+ throw new Error(parsed?.error || `Photo upload failed (HTTP ${res.status})`);
3238
+ }
3239
+ return { photoId: parsed.photoId };
3240
+ }
3191
3241
 
3192
- export { LIVE_SUBSCRIPTION_STATUSES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, availableStateOptions, availableStates, buildRefillView, buildTrackerView, buildTrackingUrl, captureFunnelEmail, createFunnelTelemetry, emailGateAnswered, firstAddressError, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, hasStateRestrictions, isImageAttachment, isLive, isQuestionVisible, isReconcilable, markEmailGateAnswered, normalizeState, redeemResumeLink, resetResumeRedemption, resolveSurveyV2DrugIntent, stateAvailabilityNote, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCheckoutFlow, useDashboardData, useMemberPortalData, useMessagesThread, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
3193
- //# sourceMappingURL=ZMOG2IIC.js.map
3194
- //# sourceMappingURL=ZMOG2IIC.js.map
3242
+ export { LIVE_SUBSCRIPTION_STATUSES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, availableStateOptions, availableStates, buildRefillView, buildTrackerView, buildTrackingUrl, captureFunnelEmail, createFunnelTelemetry, emailGateAnswered, firstAddressError, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, hasStateRestrictions, isImageAttachment, isLive, isQuestionVisible, isReconcilable, markEmailGateAnswered, normalizeState, redeemResumeLink, resetResumeRedemption, resolveSurveyV2DrugIntent, stateAvailabilityNote, uploadPrescriptionPhoto, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCheckoutFlow, useDashboardData, useMemberPortalData, useMessagesThread, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
3243
+ //# sourceMappingURL=SE6JHCPZ.js.map
3244
+ //# sourceMappingURL=SE6JHCPZ.js.map