@apextelemed/partner-core 0.7.0 → 0.8.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 (42) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.js +3 -3
  3. package/dist/api/index.jsx +5 -3
  4. package/dist/chunk/{CBOGAYTL.jsx → 2OOCTPLG.jsx} +2 -2
  5. package/dist/chunk/{GODF2NJN.js → 4HOG2LES.js} +3 -3
  6. package/dist/chunk/{GODF2NJN.js.map → 4HOG2LES.js.map} +1 -1
  7. package/dist/chunk/{SHXH72AC.jsx → 6UXFHBE2.jsx} +24 -5
  8. package/dist/chunk/{PA66KUAU.jsx → AW6DQGQR.jsx} +242 -109
  9. package/dist/chunk/{KXO4U2C6.js → EHKYRS2R.js} +23 -6
  10. package/dist/chunk/EHKYRS2R.js.map +1 -0
  11. package/dist/chunk/{4S4MTN2K.jsx → GL3OY7W5.jsx} +2 -2
  12. package/dist/chunk/{7AMVRNYX.jsx → GNPMRN6O.jsx} +92 -35
  13. package/dist/chunk/{J3OK2PQA.js → HEQMD3X4.js} +3 -3
  14. package/dist/chunk/{J3OK2PQA.js.map → HEQMD3X4.js.map} +1 -1
  15. package/dist/chunk/{J3IRPONP.js → HKXDH266.js} +135 -9
  16. package/dist/chunk/HKXDH266.js.map +1 -0
  17. package/dist/chunk/{F34QLV7Z.js → HYLIHVIE.js} +251 -191
  18. package/dist/chunk/HYLIHVIE.js.map +1 -0
  19. package/dist/chunk/{7AFUT5S3.jsx → JF2KCOOX.jsx} +10 -1
  20. package/dist/chunk/{4SFB2SS2.jsx → QAFLR3EN.jsx} +2 -2
  21. package/dist/chunk/{UPZPR5TU.js → RUA3XYFO.js} +11 -3
  22. package/dist/chunk/RUA3XYFO.js.map +1 -0
  23. package/dist/chunk/{64RJJFEH.js → ZOZBYBNI.js} +3 -3
  24. package/dist/chunk/{64RJJFEH.js.map → ZOZBYBNI.js.map} +1 -1
  25. package/dist/{client-CiHb-dIf.d.ts → client-ZnA3JEbd.d.ts} +28 -1
  26. package/dist/flows/index.d.ts +91 -2
  27. package/dist/flows/index.js +6 -6
  28. package/dist/flows/index.jsx +12 -6
  29. package/dist/index/index.d.ts +2 -2
  30. package/dist/index/index.js +7 -7
  31. package/dist/index/index.jsx +15 -7
  32. package/dist/pages/index.d.ts +1 -1
  33. package/dist/pages/index.js +5 -5
  34. package/dist/pages/index.jsx +5 -5
  35. package/dist/stores/index.d.ts +1 -1
  36. package/dist/stores/index.js +2 -2
  37. package/dist/stores/index.jsx +2 -2
  38. package/package.json +1 -1
  39. package/dist/chunk/F34QLV7Z.js.map +0 -1
  40. package/dist/chunk/J3IRPONP.js.map +0 -1
  41. package/dist/chunk/KXO4U2C6.js.map +0 -1
  42. package/dist/chunk/UPZPR5TU.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './J3OK2PQA.js';
2
- import { cart_default, medication_default, auth_default, affiliateAuth_default } from './GODF2NJN.js';
3
- import { newIdempotencyKey, apexApi, usersApi, addressesApi, paymentsApi, subscriptionsApi, membersApi, supportApi, productsApi, affiliatePortalApi, ApiError, ordersApi, messagesApi, authApi } from './UPZPR5TU.js';
1
+ import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './HEQMD3X4.js';
2
+ import { cart_default, medication_default, auth_default, affiliateAuth_default } from './4HOG2LES.js';
3
+ import { newIdempotencyKey, apexApi, usersApi, addressesApi, catalogApi, paymentsApi, subscriptionsApi, membersApi, supportApi, productsApi, affiliatePortalApi, ApiError, ordersApi, messagesApi, authApi } from './RUA3XYFO.js';
4
4
  import { getConfig } from './5XGPFYIJ.js';
5
- import { createSignal, onMount, createEffect, onCleanup, on, createResource, createMemo } from 'solid-js';
5
+ import { createSignal, onMount, createEffect, on, onCleanup, createResource, createMemo } from 'solid-js';
6
6
  import { useSurveyV2Flow as useSurveyV2Flow$1 } from '@apextelemed/survey-solid';
7
7
  import { createLocalDraftStore, draftKey as draftKey$1 } from '@apextelemed/survey-core';
8
8
 
@@ -725,6 +725,85 @@ function useAddressPair(options = {}) {
725
725
  applyNormalized
726
726
  };
727
727
  }
728
+ var DEBOUNCE_MS = 300;
729
+ var STATE_RE = /^[A-Za-z]{2}$/;
730
+ var INERT_DECISION = {
731
+ unavailableIds: [],
732
+ blocking: false,
733
+ degraded: false
734
+ };
735
+ function deriveCatalogAvailabilityDecision(result) {
736
+ if (!result) return INERT_DECISION;
737
+ if (result.degraded === true) return { ...INERT_DECISION, degraded: true };
738
+ const unavailableIds = result.items.filter((item) => item.checked && item.available === false).map((item) => item.id);
739
+ return { unavailableIds, blocking: unavailableIds.length > 0, degraded: false };
740
+ }
741
+ function useCatalogAvailability(ids, state) {
742
+ const [loading, setLoading] = createSignal(false);
743
+ const [unavailableIds, setUnavailableIds] = createSignal([]);
744
+ const [degraded, setDegraded] = createSignal(false);
745
+ let generation = 0;
746
+ let timer;
747
+ let pending = null;
748
+ function markPending() {
749
+ if (pending) return;
750
+ let resolve;
751
+ const promise = new Promise((r) => resolve = r);
752
+ pending = { promise, resolve };
753
+ }
754
+ function markSettled() {
755
+ pending?.resolve();
756
+ pending = null;
757
+ }
758
+ function settleInert() {
759
+ setLoading(false);
760
+ setUnavailableIds([]);
761
+ setDegraded(false);
762
+ markSettled();
763
+ }
764
+ createEffect(
765
+ on([ids, state], ([currentIds, currentState]) => {
766
+ if (timer) clearTimeout(timer);
767
+ const requestedIds = [...new Set(currentIds.map((id) => id.trim()).filter(Boolean))];
768
+ const normalizedState = (currentState ?? "").trim().toUpperCase();
769
+ const gen = ++generation;
770
+ if (requestedIds.length === 0 || !STATE_RE.test(normalizedState)) {
771
+ settleInert();
772
+ return;
773
+ }
774
+ setLoading(true);
775
+ markPending();
776
+ timer = setTimeout(() => {
777
+ catalogApi.availability(requestedIds, normalizedState).then((result) => {
778
+ if (gen !== generation) return;
779
+ const decision = deriveCatalogAvailabilityDecision(result);
780
+ setUnavailableIds(decision.unavailableIds);
781
+ setDegraded(decision.degraded);
782
+ }).catch(() => {
783
+ if (gen !== generation) return;
784
+ setUnavailableIds([]);
785
+ setDegraded(false);
786
+ }).finally(() => {
787
+ if (gen !== generation) return;
788
+ setLoading(false);
789
+ markSettled();
790
+ });
791
+ }, DEBOUNCE_MS);
792
+ })
793
+ );
794
+ onCleanup(() => {
795
+ if (timer) clearTimeout(timer);
796
+ generation++;
797
+ markSettled();
798
+ });
799
+ const blocking = () => !degraded() && unavailableIds().length > 0;
800
+ const isUnavailable = (id) => unavailableIds().includes(id);
801
+ const settled = () => pending?.promise ?? Promise.resolve();
802
+ return { loading, blocking, degraded, unavailableIds, isUnavailable, settled };
803
+ }
804
+ function catalogUnavailableMessage(itemName, state) {
805
+ return `${itemName} isn\u2019t available for delivery to ${stateLabel(state)}.`;
806
+ }
728
807
  function useCardTokenizer() {
729
808
  const [config, setConfig] = createSignal(null);
730
809
  const [scriptLoaded, setScriptLoaded] = createSignal(false);
@@ -927,7 +1006,14 @@ function useCheckoutFlow(options = {}) {
927
1006
  promoCode: cart_default.appliedPromo()?.code
928
1007
  };
929
1008
  };
930
- const canSubmit = () => hasPaymentMethod() || accept.ready();
1009
+ const availability = useCatalogAvailability(
1010
+ () => {
1011
+ const drugId = prescription()?.drugId;
1012
+ return drugId ? [drugId] : [];
1013
+ },
1014
+ () => address.shipping().state
1015
+ );
1016
+ const canSubmit = () => (hasPaymentMethod() || accept.ready()) && !availability.blocking();
931
1017
  onMount(async () => {
932
1018
  try {
933
1019
  const [profileRes, subsRes] = await Promise.all([
@@ -1002,6 +1088,11 @@ function useCheckoutFlow(options = {}) {
1002
1088
  setPaymentError("Missing medication details.");
1003
1089
  return;
1004
1090
  }
1091
+ await availability.settled();
1092
+ if (availability.blocking()) {
1093
+ setPaymentError(catalogUnavailableMessage(rx.drugName || "This medication", address.shipping().state));
1094
+ return;
1095
+ }
1005
1096
  if (!address.validate()) {
1006
1097
  const badShipping = hasErrors(address.shippingErrors());
1007
1098
  const badBilling = hasErrors(address.billingErrors());
@@ -1081,6 +1172,7 @@ function useCheckoutFlow(options = {}) {
1081
1172
  outcome,
1082
1173
  profile,
1083
1174
  address,
1175
+ availability,
1084
1176
  pricing,
1085
1177
  hasPaymentMethod,
1086
1178
  tokenizerReady: accept.ready,
@@ -1142,6 +1234,10 @@ function useCartCheckoutFlow() {
1142
1234
  });
1143
1235
  const items = () => cart_default.items().filter((i) => i.isSubscription !== true);
1144
1236
  const skippedSubscriptionItems = () => cart_default.items().filter((i) => i.isSubscription === true);
1237
+ const availability = useCatalogAvailability(
1238
+ () => items().map((i) => i.productId),
1239
+ () => address.shipping().state
1240
+ );
1145
1241
  const pricing = () => {
1146
1242
  const subtotalCents = items().reduce((sum, i) => sum + i.priceCents * (i.quantity || 1), 0);
1147
1243
  const promo = cart_default.appliedPromo();
@@ -1159,7 +1255,7 @@ function useCartCheckoutFlow() {
1159
1255
  promoCode: promo?.code
1160
1256
  };
1161
1257
  };
1162
- const canSubmit = () => accept.ready();
1258
+ const canSubmit = () => accept.ready() && !availability.blocking();
1163
1259
  onMount(async () => {
1164
1260
  if (!auth_default.isAuthenticated()) {
1165
1261
  setOutcome({ kind: "needs_auth" });
@@ -1228,6 +1324,13 @@ function useCartCheckoutFlow() {
1228
1324
  setOutcome({ kind: "needs_cart" });
1229
1325
  return;
1230
1326
  }
1327
+ await availability.settled();
1328
+ if (availability.blocking()) {
1329
+ setPaymentError(
1330
+ "One or more items in your cart aren\u2019t available for delivery to your address. Please remove them or update your shipping state."
1331
+ );
1332
+ return;
1333
+ }
1231
1334
  if (!address.validate()) {
1232
1335
  const badShipping = hasErrors(address.shippingErrors());
1233
1336
  const badBilling = hasErrors(address.billingErrors());
@@ -1326,6 +1429,7 @@ function useCartCheckoutFlow() {
1326
1429
  address,
1327
1430
  items,
1328
1431
  skippedSubscriptionItems,
1432
+ availability,
1329
1433
  pricing,
1330
1434
  tokenizerReady: accept.ready,
1331
1435
  acceptJsLoaded: accept.ready,
@@ -1897,6 +2001,12 @@ function useSubscribeFlow(options) {
1897
2001
  const [city, setCity] = createSignal("");
1898
2002
  const [state, setState] = createSignal("");
1899
2003
  const [zip, setZip] = createSignal("");
2004
+ const [profileState, setProfileState] = createSignal("");
2005
+ const shipState = () => profileState() || state();
2006
+ const availability = useCatalogAvailability(
2007
+ () => cart_default.items().map((i) => i.productId),
2008
+ shipState
2009
+ );
1900
2010
  const [cardNumberRaw, setCardNumberRaw] = createSignal("", { equals: false });
1901
2011
  const [expiryRaw, setExpiryRaw] = createSignal("", { equals: false });
1902
2012
  const [cvvRaw, setCvvRaw] = createSignal("", { equals: false });
@@ -1924,6 +2034,7 @@ function useSubscribeFlow(options) {
1924
2034
  setStreet(p.address1 || p.street || "");
1925
2035
  setCity(p.city || "");
1926
2036
  setState(normalizeState(p.state || ""));
2037
+ setProfileState(normalizeState(p.state || ""));
1927
2038
  setZip(p.zip || "");
1928
2039
  }
1929
2040
  } catch {
@@ -2020,6 +2131,7 @@ function useSubscribeFlow(options) {
2020
2131
  if (!cvvRaw().trim()) return "CVV is required.";
2021
2132
  return null;
2022
2133
  }
2134
+ let awaitingAvailability = false;
2023
2135
  async function submit() {
2024
2136
  if (submitting()) return;
2025
2137
  if (!auth_default.isAuthenticated()) {
@@ -2034,6 +2146,18 @@ function useSubscribeFlow(options) {
2034
2146
  setError(quoteError());
2035
2147
  return;
2036
2148
  }
2149
+ if (awaitingAvailability) return;
2150
+ awaitingAvailability = true;
2151
+ try {
2152
+ await availability.settled();
2153
+ } finally {
2154
+ awaitingAvailability = false;
2155
+ }
2156
+ if (availability.blocking()) {
2157
+ const unavailableItem = cart_default.items().find((i) => availability.isUnavailable(i.productId));
2158
+ setError(catalogUnavailableMessage(unavailableItem?.productName ?? "One of your items", shipState()));
2159
+ return;
2160
+ }
2037
2161
  const err = validate();
2038
2162
  if (err) {
2039
2163
  setError(err);
@@ -2117,6 +2241,8 @@ function useSubscribeFlow(options) {
2117
2241
  setState,
2118
2242
  zip,
2119
2243
  setZip,
2244
+ availability,
2245
+ shipState,
2120
2246
  cardNumber: cardNumberRaw,
2121
2247
  setCardNumber: (v) => setCardNumberRaw(formatCardNumber(v)),
2122
2248
  expiry: expiryRaw,
@@ -4339,6 +4465,6 @@ async function uploadPrescriptionPhoto(file) {
4339
4465
  return { photoId: parsed.photoId };
4340
4466
  }
4341
4467
 
4342
- export { ACCOUNT_SOURCE_LABEL, DEFAULT_COLOR_PALETTE, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, availableStateOptions, availableStates, buildRefillView, buildTimeline, buildTrackerView, buildTrackingUrl, captureFunnelEmail, categoryColor, categoryLabel, createFunnelTelemetry, deriveAttention, deriveJourney, emailGateAnswered, firstAddressError, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, hasStateRestrictions, isCssColorValue, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, lowestPrice, lowestSalePrice, markEmailGateAnswered, normalizeState, primarySubscription, reconcileCartAgainstCatalog, reconcileCartLines, redeemResumeLink, resetResumeRedemption, resolveCategoryColor, resolveSurveyV2DrugIntent, salePriceForBase, stateAvailabilityNote, subscribeToSupportTopic, toTrackerRequest, uploadPrescriptionPhoto, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCartReconcile, useCatalog, useCheckoutFlow, useDashboardData, useMedicationSelect, useMemberPortalData, useMessagesThread, useProductDetail, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
4343
- //# sourceMappingURL=J3IRPONP.js.map
4344
- //# sourceMappingURL=J3IRPONP.js.map
4468
+ export { ACCOUNT_SOURCE_LABEL, DEFAULT_COLOR_PALETTE, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, availableStateOptions, availableStates, buildRefillView, buildTimeline, buildTrackerView, buildTrackingUrl, captureFunnelEmail, catalogUnavailableMessage, categoryColor, categoryLabel, createFunnelTelemetry, deriveAttention, deriveCatalogAvailabilityDecision, deriveJourney, emailGateAnswered, firstAddressError, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, hasStateRestrictions, isCssColorValue, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, lowestPrice, lowestSalePrice, markEmailGateAnswered, normalizeState, primarySubscription, reconcileCartAgainstCatalog, reconcileCartLines, redeemResumeLink, resetResumeRedemption, resolveCategoryColor, resolveSurveyV2DrugIntent, salePriceForBase, stateAvailabilityNote, subscribeToSupportTopic, toTrackerRequest, uploadPrescriptionPhoto, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCartReconcile, useCatalog, useCatalogAvailability, useCheckoutFlow, useDashboardData, useMedicationSelect, useMemberPortalData, useMessagesThread, useProductDetail, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
4469
+ //# sourceMappingURL=HKXDH266.js.map
4470
+ //# sourceMappingURL=HKXDH266.js.map