@apextelemed/partner-core 0.2.0 → 0.3.1
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/api/index.d.ts +14 -1
- package/dist/api/index.js +2 -2
- package/dist/api/index.jsx +8 -2
- package/dist/chunk/{SNAV6DII.jsx → 2EVGOW2Z.jsx} +26 -4
- package/dist/chunk/{KFJXIKD4.js → 5RQ4ZIYB.js} +48 -9
- package/dist/chunk/5RQ4ZIYB.js.map +1 -0
- package/dist/chunk/{FJZHH5T4.jsx → AC7FFU4J.jsx} +312 -6
- package/dist/chunk/ACE7M2YA.jsx +1 -0
- package/dist/chunk/{EIXV4DCU.js → D6GCJFQD.js} +26 -6
- package/dist/chunk/D6GCJFQD.js.map +1 -0
- package/dist/chunk/{OEXSGX5F.js → J4G52ET6.js} +665 -337
- package/dist/chunk/J4G52ET6.js.map +1 -0
- package/dist/chunk/JSHO46VZ.js +3 -0
- package/dist/chunk/JSHO46VZ.js.map +1 -0
- package/dist/chunk/{MEWFN6IW.jsx → M6DZVPYZ.jsx} +49 -8
- package/dist/chunk/{6TFBQECC.jsx → NP4CMOLW.jsx} +41 -1
- package/dist/chunk/{J6KNY37T.js → XMYPS7PT.js} +40 -3
- package/dist/chunk/XMYPS7PT.js.map +1 -0
- package/dist/flows/index.js +3 -3
- package/dist/flows/index.jsx +3 -3
- package/dist/index/index.d.ts +1 -1
- package/dist/index/index.js +5 -5
- package/dist/index/index.jsx +11 -5
- package/dist/pages/index.js +2 -2
- package/dist/pages/index.jsx +2 -2
- package/dist/testing/storage.d.ts +1 -1
- package/dist/testing/storage.d.ts.map +1 -1
- package/dist/testing/storage.js +1 -0
- package/dist/testing/storage.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk/AN3WPMEP.js +0 -3
- package/dist/chunk/AN3WPMEP.js.map +0 -1
- package/dist/chunk/EIXV4DCU.js.map +0 -1
- package/dist/chunk/J6KNY37T.js.map +0 -1
- package/dist/chunk/KFJXIKD4.js.map +0 -1
- package/dist/chunk/O3QK7YZR.jsx +0 -1
- package/dist/chunk/OEXSGX5F.js.map +0 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -9,4 +9,17 @@ declare function readAffiliateRef(): string | null;
|
|
|
9
9
|
/** Drop the stored referral code. */
|
|
10
10
|
declare function clearAffiliateRef(): void;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/** Persist a promo code from a `?promo=` landing. No-op for empty input. */
|
|
13
|
+
declare function capturePromoCode(code: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Read the stored promo code, or null if absent or past the storage window.
|
|
16
|
+
*
|
|
17
|
+
* Being within the window says nothing about whether the CODE is still valid —
|
|
18
|
+
* a campaign can end while the stash is fresh. The caller re-validates against
|
|
19
|
+
* the server before showing it to anyone.
|
|
20
|
+
*/
|
|
21
|
+
declare function readPromoCode(): string | null;
|
|
22
|
+
/** Drop the stored promo code. */
|
|
23
|
+
declare function clearPromoCode(): void;
|
|
24
|
+
|
|
25
|
+
export { captureAffiliateRef, capturePromoCode, clearAffiliateRef, clearPromoCode, readAffiliateRef, readPromoCode };
|
package/dist/api/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import '../chunk/
|
|
2
|
-
export { adoptCartId, cartId, fetchCartConfig, fetchResumedCart, postCartSnapshot, readCartToken, resetCartConfigCache, resetCartId, stripCartToken } from '../chunk/
|
|
1
|
+
import '../chunk/JSHO46VZ.js';
|
|
2
|
+
export { adoptCartId, capturePromoCode, cartId, clearPromoCode, fetchCartConfig, fetchResumedCart, postCartSnapshot, readCartToken, readPromoCode, resetCartConfigCache, resetCartId, stripCartToken } from '../chunk/XMYPS7PT.js';
|
|
3
3
|
export { EmbedApiError2 as ApexV2ApiError, EmbedApiError, createEmbedApiClient, disqualificationReasonText, disqualifiedDrugIds, qualifiedDrugIds } from '../chunk/LZWA44KD.js';
|
|
4
4
|
export { adoptFunnelSessionId, fetchFunnelConfig, fetchResumedDraft, funnelSessionId, peekFunnelSessionId, postFunnelEvent, readResumeToken, resetFunnelConfigCache, saveFunnelDraft, stripResumeToken } from '../chunk/DS4E7FAI.js';
|
|
5
5
|
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 } from '../chunk/UNAI6NBV.js';
|
package/dist/api/index.jsx
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import "../chunk/
|
|
1
|
+
import "../chunk/ACE7M2YA.jsx";
|
|
2
2
|
import {
|
|
3
3
|
adoptCartId,
|
|
4
|
+
capturePromoCode,
|
|
4
5
|
cartId,
|
|
6
|
+
clearPromoCode,
|
|
5
7
|
fetchCartConfig,
|
|
6
8
|
fetchResumedCart,
|
|
7
9
|
postCartSnapshot,
|
|
8
10
|
readCartToken,
|
|
11
|
+
readPromoCode,
|
|
9
12
|
resetCartConfigCache,
|
|
10
13
|
resetCartId,
|
|
11
14
|
stripCartToken
|
|
12
|
-
} from "../chunk/
|
|
15
|
+
} from "../chunk/NP4CMOLW.jsx";
|
|
13
16
|
import {
|
|
14
17
|
EmbedApiError,
|
|
15
18
|
EmbedApiError2,
|
|
@@ -83,9 +86,11 @@ export {
|
|
|
83
86
|
authApi,
|
|
84
87
|
authStorageKey,
|
|
85
88
|
captureAffiliateRef,
|
|
89
|
+
capturePromoCode,
|
|
86
90
|
cartId,
|
|
87
91
|
clearAffiliateRef,
|
|
88
92
|
clearAffiliateTokens,
|
|
93
|
+
clearPromoCode,
|
|
89
94
|
clearTokens,
|
|
90
95
|
createEmbedApiClient,
|
|
91
96
|
disqualificationReasonText,
|
|
@@ -111,6 +116,7 @@ export {
|
|
|
111
116
|
qualifiedDrugIds,
|
|
112
117
|
readAffiliateRef,
|
|
113
118
|
readCartToken,
|
|
119
|
+
readPromoCode,
|
|
114
120
|
readResumeToken,
|
|
115
121
|
resetCartConfigCache,
|
|
116
122
|
resetCartId,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
adoptCartId,
|
|
3
|
+
clearPromoCode,
|
|
3
4
|
fetchCartConfig,
|
|
4
5
|
fetchResumedCart,
|
|
5
6
|
postCartSnapshot,
|
|
6
7
|
readCartToken,
|
|
8
|
+
readPromoCode,
|
|
7
9
|
resetCartId,
|
|
8
10
|
stripCartToken
|
|
9
|
-
} from "./
|
|
11
|
+
} from "./NP4CMOLW.jsx";
|
|
10
12
|
import {
|
|
11
13
|
firstAddressError,
|
|
12
14
|
formatCardNumber,
|
|
@@ -16,7 +18,7 @@ import {
|
|
|
16
18
|
useAddressPair,
|
|
17
19
|
useCardTokenizer,
|
|
18
20
|
validateAddress
|
|
19
|
-
} from "./
|
|
21
|
+
} from "./M6DZVPYZ.jsx";
|
|
20
22
|
import {
|
|
21
23
|
auth_default,
|
|
22
24
|
cart_default,
|
|
@@ -289,6 +291,20 @@ function useSubscriptionIntakeFlow(options) {
|
|
|
289
291
|
const [promoValidating, setPromoValidating] = createSignal2(false);
|
|
290
292
|
const [promoError, setPromoError] = createSignal2(null);
|
|
291
293
|
const [promoApplied, setPromoApplied] = createSignal2(null);
|
|
294
|
+
onMount(async () => {
|
|
295
|
+
if (promoCode().trim()) return;
|
|
296
|
+
const stashed = readPromoCode();
|
|
297
|
+
if (!stashed) return;
|
|
298
|
+
try {
|
|
299
|
+
const res = await promoCodesApi.validate(stashed, {
|
|
300
|
+
productIds: [options.pricing.productId],
|
|
301
|
+
subtotalCents: savingsBaseCents()
|
|
302
|
+
});
|
|
303
|
+
if (res.valid) setPromoCode(stashed);
|
|
304
|
+
else clearPromoCode();
|
|
305
|
+
} catch {
|
|
306
|
+
}
|
|
307
|
+
});
|
|
292
308
|
const [idemKey, setIdemKey] = createSignal2(restored.idempotencyKey ?? "");
|
|
293
309
|
onMount(() => {
|
|
294
310
|
createEffect(() => {
|
|
@@ -353,7 +369,13 @@ function useSubscriptionIntakeFlow(options) {
|
|
|
353
369
|
try {
|
|
354
370
|
const res = await promoCodesApi.validate(code, {
|
|
355
371
|
productIds: [options.pricing.productId],
|
|
356
|
-
|
|
372
|
+
// The base the promo will actually be applied to. For a savings member
|
|
373
|
+
// that is the savings price, not list: the server discounts the
|
|
374
|
+
// savings-substituted subtotal at checkout, so quoting off list would
|
|
375
|
+
// show a percentage promo as a bigger saving than it is (10% of $399
|
|
376
|
+
// displayed, 10% of $280 charged). Same rule as savingsBaseCents — keep
|
|
377
|
+
// the two in step.
|
|
378
|
+
subtotalCents: savingsBaseCents()
|
|
357
379
|
});
|
|
358
380
|
if (!res.valid) {
|
|
359
381
|
setPromoError(res.error ?? "Invalid promo code.");
|
|
@@ -730,4 +752,4 @@ export {
|
|
|
730
752
|
restoreCartFromLink,
|
|
731
753
|
startCartCapture
|
|
732
754
|
};
|
|
733
|
-
//# sourceMappingURL=
|
|
755
|
+
//# sourceMappingURL=2EVGOW2Z.jsx.map
|
|
@@ -2181,6 +2181,21 @@ function buildTrackingUrl(delivery) {
|
|
|
2181
2181
|
return builder ? builder(delivery.trackingNumber) : null;
|
|
2182
2182
|
}
|
|
2183
2183
|
|
|
2184
|
+
// src/utils/calendarDate.ts
|
|
2185
|
+
var DATE_ONLY = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2186
|
+
function parseCalendarDate(value) {
|
|
2187
|
+
if (!value) return null;
|
|
2188
|
+
const m = DATE_ONLY.exec(value.trim());
|
|
2189
|
+
const d = m ? new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])) : new Date(value);
|
|
2190
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
2191
|
+
}
|
|
2192
|
+
function formatCalendarDate(value, options = { year: "numeric", month: "long", day: "numeric" }) {
|
|
2193
|
+
if (!value) return "";
|
|
2194
|
+
const d = parseCalendarDate(value);
|
|
2195
|
+
if (!d) return value;
|
|
2196
|
+
return d.toLocaleDateString("en-US", options);
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2184
2199
|
// src/flows/tracker.ts
|
|
2185
2200
|
var PIPELINE = [
|
|
2186
2201
|
{ key: "submitted", label: "Submitted", heroWord: "Received", subCaption: "We\u2019ve received your request." },
|
|
@@ -2299,12 +2314,7 @@ function softRelative(date, now) {
|
|
|
2299
2314
|
const weeks = Math.round(diffDays / 7);
|
|
2300
2315
|
return `in ${weeks} weeks`;
|
|
2301
2316
|
}
|
|
2302
|
-
|
|
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
|
-
}
|
|
2317
|
+
var parseBackendDate = parseCalendarDate;
|
|
2308
2318
|
function buildRefillView(sub, now = Date.now()) {
|
|
2309
2319
|
if (!sub) return null;
|
|
2310
2320
|
if (sub.status === "cancelled" || sub.status === "expired" || sub.status === "suspended") {
|
|
@@ -3209,7 +3219,36 @@ function useSurveyV2Flow(opts) {
|
|
|
3209
3219
|
onError: opts.onError
|
|
3210
3220
|
});
|
|
3211
3221
|
}
|
|
3222
|
+
var PRESCRIPTION_PHOTO_MAX_BYTES = 10 * 1024 * 1024;
|
|
3223
|
+
async function uploadPrescriptionPhoto(file) {
|
|
3224
|
+
const cfg = getConfig();
|
|
3225
|
+
if (!cfg.apexEmbedApiBase) {
|
|
3226
|
+
throw new Error("apex-partner-core: apexEmbedApiBase is not configured.");
|
|
3227
|
+
}
|
|
3228
|
+
if (file.size > PRESCRIPTION_PHOTO_MAX_BYTES) {
|
|
3229
|
+
throw new Error("That photo is larger than 10MB. Please retake it at a lower resolution.");
|
|
3230
|
+
}
|
|
3231
|
+
const formData = new FormData();
|
|
3232
|
+
formData.append("photo", file);
|
|
3233
|
+
const res = await fetch(`${cfg.apexEmbedApiBase}/surveys/prescription-photos`, {
|
|
3234
|
+
method: "POST",
|
|
3235
|
+
headers: {
|
|
3236
|
+
...cfg.apexPublishableKey ? { "x-apex-publishable-key": cfg.apexPublishableKey } : {},
|
|
3237
|
+
...cfg.tenantKey ? { "X-Tenant-Key": cfg.tenantKey } : {}
|
|
3238
|
+
},
|
|
3239
|
+
body: formData
|
|
3240
|
+
});
|
|
3241
|
+
let parsed = null;
|
|
3242
|
+
try {
|
|
3243
|
+
parsed = await res.json();
|
|
3244
|
+
} catch {
|
|
3245
|
+
}
|
|
3246
|
+
if (!res.ok || !parsed?.photoId) {
|
|
3247
|
+
throw new Error(parsed?.error || `Photo upload failed (HTTP ${res.status})`);
|
|
3248
|
+
}
|
|
3249
|
+
return { photoId: parsed.photoId };
|
|
3250
|
+
}
|
|
3212
3251
|
|
|
3213
|
-
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 };
|
|
3214
|
-
//# sourceMappingURL=
|
|
3215
|
-
//# sourceMappingURL=
|
|
3252
|
+
export { LIVE_SUBSCRIPTION_STATUSES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, availableStateOptions, availableStates, buildRefillView, buildTrackerView, buildTrackingUrl, captureFunnelEmail, createFunnelTelemetry, emailGateAnswered, firstAddressError, formatCalendarDate, 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 };
|
|
3253
|
+
//# sourceMappingURL=5RQ4ZIYB.js.map
|
|
3254
|
+
//# sourceMappingURL=5RQ4ZIYB.js.map
|