@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,1539 @@
1
+ declare const authStorageKey: () => string;
2
+ interface AuthTokens {
3
+ accessToken: string;
4
+ refreshToken: string;
5
+ userId: string;
6
+ }
7
+ interface User {
8
+ id: string;
9
+ email: string;
10
+ firstName: string;
11
+ lastName: string;
12
+ role: string;
13
+ [key: string]: unknown;
14
+ }
15
+ interface LoginPayload {
16
+ email: string;
17
+ password: string;
18
+ }
19
+ interface RegisterPayload {
20
+ email: string;
21
+ password: string;
22
+ member: {
23
+ firstName: string;
24
+ lastName: string;
25
+ dateOfBirth: string;
26
+ phone?: string;
27
+ address1: string;
28
+ city: string;
29
+ state: string;
30
+ zip: string;
31
+ };
32
+ }
33
+ interface RegisterAndSubscribePayload extends RegisterPayload {
34
+ opaqueData?: Record<string, unknown>;
35
+ amountCents: number;
36
+ intervalDays?: number;
37
+ medication?: string;
38
+ products?: Array<{
39
+ productId: string;
40
+ productName: string;
41
+ quantity?: number;
42
+ dosage?: string;
43
+ }>;
44
+ /** v1 survey response id (legacy, the-backend formats caseNotes locally). */
45
+ surveyResponseId?: string;
46
+ /** v2 survey response id (Apex formats caseNotes from the survey snapshot). */
47
+ v2SurveyResponseId?: string;
48
+ caseNotes?: string;
49
+ billingAddress?: {
50
+ street: string;
51
+ city: string;
52
+ state: string;
53
+ zip: string;
54
+ };
55
+ promoCode?: string;
56
+ }
57
+ /** Item in a cart-style order/checkout. Mirrors the live backend contract:
58
+ * POST /orders and POST /payments/checkout both read `item.productId`;
59
+ * quantity defaults to 1 server-side; dosage is required only for per-dose
60
+ * products carrying an Apex clinical dose. */
61
+ interface OrderItemInput {
62
+ productId: string;
63
+ quantity?: number;
64
+ dosage?: string;
65
+ }
66
+ /** A US postal address on the checkout wire (shipping or billing). Structurally
67
+ * matches the flows' `AddressValue`. */
68
+ interface CheckoutAddress {
69
+ street: string;
70
+ street2?: string;
71
+ city: string;
72
+ state: string;
73
+ zip: string;
74
+ }
75
+ interface CheckoutPayload {
76
+ items: OrderItemInput[];
77
+ /** Pinned to `CheckoutAddress` (`street`, not `street1`): the backend stores
78
+ * checkout shipping verbatim today, its only shipping-address parser
79
+ * (`sanitizeCheckoutAddress`, on the prescription-checkout route) reads
80
+ * `street`, and the AuthNet billTo mapping reads `billingAddress.street/
81
+ * city/state/zip` — so `street` is the wire canon for both addresses. */
82
+ shippingAddress: CheckoutAddress;
83
+ /** Provider-neutral tokenized card from useCardTokenizer().tokenize() — AuthNet
84
+ * ships `{ dataDescriptor, dataValue }`, QuickBooks `{ token }`. REQUIRED —
85
+ * POST /payments/checkout 400s when absent (it charges the raw token; there
86
+ * is no card-on-file path on this route). */
87
+ opaqueData: Record<string, unknown>;
88
+ billingAddress?: CheckoutAddress;
89
+ promoCode?: string;
90
+ }
91
+ /** Response envelope of POST /payments/checkout. 201 carries the succeeded
92
+ * charge; a declined card comes back as a 400 with `success: false` and the
93
+ * gateway's `error`/`errorCode` (surfaced to the caller as an ApiError). */
94
+ interface CheckoutResult {
95
+ success: boolean;
96
+ status?: 'succeeded' | 'failed';
97
+ orderId?: string;
98
+ paymentId?: string;
99
+ transactionId?: string;
100
+ amountCents?: number;
101
+ error?: string;
102
+ errorCode?: string;
103
+ }
104
+ /** A one-time order row as returned by GET /orders and GET /orders/:id.
105
+ * `items[].priceAtPurchase` is the per-unit price snapshot in cents; `delivery`
106
+ * is joined from the linked prescription request and is null for plain
107
+ * cart purchases. */
108
+ interface Order {
109
+ id: string;
110
+ status: string;
111
+ total_cents: number;
112
+ items: Array<{
113
+ productId: string;
114
+ name: string;
115
+ quantity: number;
116
+ priceAtPurchase: number;
117
+ dosage?: string;
118
+ }>;
119
+ created_at?: string;
120
+ delivery?: {
121
+ status: string;
122
+ trackingNumber?: string;
123
+ shipCarrier?: string;
124
+ trackingUrl?: string;
125
+ } | null;
126
+ }
127
+ interface PaymentInitiatePayload {
128
+ amount: number;
129
+ currency?: string;
130
+ paymentMethodToken?: string;
131
+ }
132
+ interface PaymentCallbackPayload {
133
+ transactionId: string;
134
+ status: string;
135
+ [key: string]: unknown;
136
+ }
137
+ interface SendMessagePayload {
138
+ text: string;
139
+ }
140
+ interface CreateOrderPayload {
141
+ items: OrderItemInput[];
142
+ shippingAddress: Record<string, string>;
143
+ }
144
+ interface UpdateProfilePayload {
145
+ firstName?: string;
146
+ lastName?: string;
147
+ phone?: string;
148
+ dateOfBirth?: string;
149
+ gender?: string;
150
+ address1?: string;
151
+ address2?: string;
152
+ city?: string;
153
+ state?: string;
154
+ zip?: string;
155
+ /** Last-entered survey vitals, persisted for cross-device carry-over. */
156
+ heightIn?: number;
157
+ weightLb?: number;
158
+ }
159
+ interface UpdatePaymentMethodPayload {
160
+ /** Provider-neutral tokenized card from useCardTokenizer().tokenize() (AuthNet
161
+ * {dataDescriptor,dataValue}, QuickBooks {token}). Sent to the backend as
162
+ * `opaqueData`; PUT /subscriptions/:id/payment-method 400s when absent. */
163
+ opaqueData: Record<string, unknown>;
164
+ /** The card's billTo. Omit to keep the backend's per-field fallback to the
165
+ * member's profile address. Sending it lets a member whose card bills
166
+ * somewhere other than where they ship actually save that card — the
167
+ * gateway validates live on update, so a wrong billTo fails AVS. */
168
+ billingAddress?: {
169
+ street?: string;
170
+ city?: string;
171
+ state?: string;
172
+ zip?: string;
173
+ };
174
+ }
175
+ interface TemplateText {
176
+ subject: string;
177
+ greeting: string;
178
+ bodyParagraphs: string[];
179
+ closingText: string;
180
+ }
181
+ interface EmailTemplatesMap {
182
+ [key: string]: TemplateText;
183
+ }
184
+ interface Placeholder {
185
+ token: string;
186
+ description: string;
187
+ }
188
+ /** Per-template placeholder tokens, keyed by template key. */
189
+ interface TemplatePlaceholdersMap {
190
+ [key: string]: Placeholder[];
191
+ }
192
+ interface ApiResponse<T = unknown> {
193
+ data?: T;
194
+ error?: string;
195
+ message?: string;
196
+ }
197
+ interface PaginationParams {
198
+ page?: number;
199
+ limit?: number;
200
+ [key: string]: unknown;
201
+ }
202
+ interface SurveySubmitPayload {
203
+ surveyId: string;
204
+ answers: Array<{
205
+ questionId: string;
206
+ value: unknown;
207
+ }>;
208
+ patientInfo: {
209
+ firstName: string;
210
+ lastName: string;
211
+ email: string;
212
+ dob: string;
213
+ state: string;
214
+ street1: string;
215
+ city: string;
216
+ zipCode: string;
217
+ phone?: string;
218
+ street2?: string;
219
+ };
220
+ }
221
+ interface SelectDrugPayload {
222
+ surveyId: string;
223
+ responseId: string;
224
+ drugId: string;
225
+ }
226
+ interface CreateRequestPayload {
227
+ drugId?: string;
228
+ dosage?: string;
229
+ /** Dose redesign (Phase 8): optional intake hints forwarded to Apex via the-backend
230
+ * for the single-drug (drugId) path. `requestedSku` is binding (patient-bought SKU);
231
+ * `requestedClinicalDose` is advisory. Both optional — absent => unchanged payload. */
232
+ requestedSku?: string;
233
+ /** SKU identity S4: the stable, opaque `skus[].id` form of `requestedSku` (from
234
+ * Apex's /v1/drugs catalog). Preferred over the free-text label — it survives a
235
+ * relabel. Additive alongside `requestedSku`; absent => unchanged payload. */
236
+ requestedSkuId?: string;
237
+ requestedClinicalDose?: {
238
+ value: number;
239
+ unit: string;
240
+ };
241
+ /** v1 survey response id (legacy, the-backend formats caseNotes locally). */
242
+ surveyResponseId?: string;
243
+ /** v2 survey response id (Apex formats caseNotes from the snapshot). */
244
+ v2SurveyResponseId?: string;
245
+ caseNotes?: string;
246
+ promoCode?: string;
247
+ medications?: Array<{
248
+ productId: string;
249
+ productName: string;
250
+ quantity?: number;
251
+ dosage?: string;
252
+ requestedSku?: string;
253
+ requestedSkuId?: string;
254
+ requestedClinicalDose?: {
255
+ value: number;
256
+ unit: string;
257
+ };
258
+ }>;
259
+ patientInfo?: {
260
+ firstName: string;
261
+ lastName: string;
262
+ email: string;
263
+ phone?: string;
264
+ dob: string;
265
+ street1: string;
266
+ street2?: string;
267
+ city: string;
268
+ state: string;
269
+ zipCode: string;
270
+ };
271
+ }
272
+ interface CreateSubscriptionPayload {
273
+ opaqueData?: Record<string, unknown>;
274
+ amountCents: number;
275
+ intervalDays?: number;
276
+ billingAddress?: {
277
+ street: string;
278
+ city: string;
279
+ state: string;
280
+ zip: string;
281
+ country?: string;
282
+ };
283
+ products?: Array<{
284
+ productId: string;
285
+ productName: string;
286
+ quantity?: number;
287
+ dosage?: string;
288
+ }>;
289
+ metadata?: Record<string, unknown>;
290
+ productId?: string;
291
+ promoCode?: string;
292
+ }
293
+ interface SendToPharmacyPayload {
294
+ requestId: string;
295
+ pharmacyId: string;
296
+ }
297
+ interface DeliveryInfo {
298
+ status: string | null;
299
+ trackingNumber: string;
300
+ shipCarrier: string;
301
+ trackingUrl: string | null;
302
+ }
303
+ type RenewalStatus = 'awaiting_fill' | 'scheduled' | 'survey_sent' | 'survey_completed' | 'request_created' | 'request_failed' | 'canceled';
304
+ interface MemberPrescriptionRequest {
305
+ requestId: string;
306
+ status: 'pending' | 'approved' | 'denied' | 'call_requested' | 'shipped';
307
+ drugId?: string;
308
+ drugName?: string;
309
+ productId?: string;
310
+ dosage?: string;
311
+ priceCents?: number;
312
+ /** The patient has already paid for this request (prescription_requests.payment_confirmed).
313
+ * In the pay-before-review flow a request can be paid while still pending, so consumers
314
+ * must not assume "unpaid until approved". */
315
+ paymentConfirmed?: boolean;
316
+ createdAt: string;
317
+ updatedAt?: string;
318
+ delivery: DeliveryInfo | null;
319
+ renewal?: {
320
+ renewalId: string;
321
+ cycleNumber: number;
322
+ status: RenewalStatus;
323
+ pharmacyFillDate: string | null;
324
+ triggerAt: string | null;
325
+ } | null;
326
+ }
327
+ interface PendingRenewalSurvey {
328
+ renewalId: string;
329
+ cycleNumber: number;
330
+ prescriptionRequestId: string;
331
+ drugId?: string;
332
+ drugName?: string;
333
+ dosage?: string;
334
+ pharmacyFillDate: string | null;
335
+ surveyId: string;
336
+ }
337
+ /**
338
+ * Body for `completeSurvey`. A renewal check-in ends one of two ways:
339
+ * - the member re-qualifies → `{ surveyResponseId }` (the Apex response id links
340
+ * the survey snapshot to the renewal so the next Rx carries case notes), or
341
+ * - the member no longer qualifies → `{ disqualified: true, reason? }` (the
342
+ * backend moves the renewal to terminal `declined`; no Rx is created).
343
+ */
344
+ type CompleteSurveyPayload = {
345
+ surveyResponseId: string;
346
+ } | {
347
+ disqualified: true;
348
+ reason?: string;
349
+ };
350
+ interface MembersMeResponse {
351
+ member: Record<string, unknown>;
352
+ orders?: Array<Record<string, unknown>>;
353
+ subscriptions?: Array<{
354
+ id: string;
355
+ productId: string;
356
+ /** Apex drug id (a code). */
357
+ medication: string;
358
+ /** Friendly product name resolved server-side; absent when unresolved. */
359
+ medicationName?: string;
360
+ dosage: string;
361
+ status: string;
362
+ amountCents: number;
363
+ intervalDays: number;
364
+ currentPeriodEnd: string;
365
+ createdAt: string;
366
+ }>;
367
+ /** The member's prescription requests. `/members/me` no longer emits a single
368
+ * "current" request — that field was dropped in the backend's single-drug
369
+ * migration; consumers use this list (or `membersApi.getRequests()` for the
370
+ * paginated list with renewal metadata). */
371
+ prescriptionRequests?: MemberPrescriptionRequest[];
372
+ }
373
+ type TokenTrackName = 'patient' | 'affiliate';
374
+ /** Subscribe to same-tab wipes of a track's tokens. Listeners must not write
375
+ * token storage (a re-clear would re-notify). Returns an unsubscribe. */
376
+ declare function onTokensCleared(track: TokenTrackName, cb: () => void): () => void;
377
+ declare function getTokens(): AuthTokens | null;
378
+ declare function setTokens(tokens: AuthTokens): void;
379
+ declare function clearTokens(): void;
380
+ /**
381
+ * Error thrown by {@link apiFetch}. `ambiguous` means the request's outcome is
382
+ * UNKNOWN to the client — the server may have committed the mutation even
383
+ * though we never saw a success response (connection dropped mid-flight, or a
384
+ * 5xx that could be post-commit). Callers of charge/create flows must treat an
385
+ * ambiguous failure as "maybe it worked": reconcile against server state before
386
+ * offering a retry, and reuse the same idempotency key if they do retry. A
387
+ * non-ambiguous error (4xx, declined card, validation) is a definitive "it did
388
+ * not happen" and is safe to retry with a fresh key.
389
+ */
390
+ declare class ApiError extends Error {
391
+ readonly status?: number;
392
+ readonly ambiguous: boolean;
393
+ /** Machine-readable error code from the response body, when the endpoint
394
+ * sends one (e.g. `SUBSCRIPTION_EXISTS`). Branch on this, never on message. */
395
+ readonly code?: string;
396
+ constructor(message: string, opts?: {
397
+ status?: number;
398
+ ambiguous?: boolean;
399
+ cause?: unknown;
400
+ code?: string;
401
+ });
402
+ }
403
+ /**
404
+ * Generate a client-side idempotency key (RFC 4122 v4). Persist it across
405
+ * retries of the SAME logical operation so the backend dedupes; mint a fresh
406
+ * one only for a genuinely new operation.
407
+ */
408
+ declare function newIdempotencyKey(): string;
409
+ declare function apiFetch<T = unknown>(endpoint: string, options?: RequestInit & {
410
+ skipAuth?: boolean;
411
+ authToken?: string;
412
+ idempotencyKey?: string;
413
+ }): Promise<T>;
414
+ declare const authApi: {
415
+ login(payload: LoginPayload): Promise<ApiResponse<{
416
+ user: User;
417
+ accessToken: string;
418
+ refreshToken: string;
419
+ userId: string;
420
+ subscriptionId?: string;
421
+ }>>;
422
+ register(payload: RegisterPayload): Promise<ApiResponse<{
423
+ user: User;
424
+ accessToken: string;
425
+ refreshToken: string;
426
+ userId: string;
427
+ subscriptionId?: string;
428
+ }>>;
429
+ refresh(refreshToken: string, userId: string): Promise<ApiResponse<{
430
+ user: User;
431
+ accessToken: string;
432
+ refreshToken: string;
433
+ userId: string;
434
+ subscriptionId?: string;
435
+ }>>;
436
+ registerAndSubscribe(payload: RegisterAndSubscribePayload, opts?: {
437
+ idempotencyKey?: string;
438
+ }): Promise<ApiResponse<{
439
+ user: User;
440
+ accessToken: string;
441
+ refreshToken: string;
442
+ userId: string;
443
+ subscriptionId?: string;
444
+ }>>;
445
+ checkEmail(email: string): Promise<{
446
+ exists: boolean;
447
+ }>;
448
+ requestPasswordReset(params: {
449
+ email: string;
450
+ redirectUrl: string;
451
+ }): Promise<{
452
+ message: string;
453
+ }>;
454
+ resetPassword(params: {
455
+ email: string;
456
+ token: string;
457
+ newPassword: string;
458
+ }): Promise<{
459
+ message: string;
460
+ }>;
461
+ };
462
+ declare const apexApi: {
463
+ getConfig(surveyType?: "glp1" | "generic"): Promise<ApiResponse<unknown>>;
464
+ getSurvey(surveyId: string): Promise<ApiResponse<unknown>>;
465
+ getSurveyForDrug(drugId: string): Promise<{
466
+ surveyId: string;
467
+ name: string;
468
+ description: string | null;
469
+ drugIds: string[];
470
+ }>;
471
+ getSurveyByType(type: "glp1" | "generic"): Promise<ApiResponse<unknown>>;
472
+ submitSurvey(payload: SurveySubmitPayload, opts?: {
473
+ idempotencyKey?: string;
474
+ }): Promise<unknown>;
475
+ checkQualification(surveyId: string, answers: Array<{
476
+ questionId: string;
477
+ value: unknown;
478
+ }>): Promise<ApiResponse<unknown>>;
479
+ selectDrug(payload: SelectDrugPayload): Promise<unknown>;
480
+ getPreviousAnswers(surveyId: string): Promise<ApiResponse<unknown>>;
481
+ getRequestStatus(requestId: string, drugId?: string, opts?: {
482
+ authToken?: string;
483
+ }): Promise<ApiResponse<unknown>>;
484
+ listRequests(): Promise<{
485
+ requests: Array<{
486
+ requestId: string;
487
+ status: "pending" | "approved" | "denied" | "new" | "processing" | "completed";
488
+ drugId?: string;
489
+ drugName?: string;
490
+ dosage?: string;
491
+ priceCents?: number;
492
+ paymentConfirmed?: boolean;
493
+ pharmacySent?: boolean;
494
+ createdAt: string;
495
+ items?: Array<{
496
+ drugId?: string;
497
+ productId?: string;
498
+ dosage?: string;
499
+ }>;
500
+ }>;
501
+ }>;
502
+ sendToPharmacy(payload: SendToPharmacyPayload): Promise<unknown>;
503
+ createRequest(payload: CreateRequestPayload, opts?: {
504
+ idempotencyKey?: string;
505
+ }): Promise<unknown>;
506
+ };
507
+ interface AddressVerifyResult {
508
+ status: 'verified' | 'corrected' | 'undeliverable' | 'unchecked';
509
+ /** Standardized address from the verifier (present on verified/corrected). */
510
+ normalized?: CheckoutAddress;
511
+ /** True when `normalized` differs from the input — the user should confirm it. */
512
+ corrected: boolean;
513
+ messages: string[];
514
+ }
515
+ declare const addressesApi: {
516
+ /** Server-side US address deliverability check (Shippo). Fails open: the
517
+ * backend returns `unchecked` when unconfigured/unreachable, never an error. */
518
+ verify(address: CheckoutAddress): Promise<AddressVerifyResult>;
519
+ };
520
+ declare const paymentsApi: {
521
+ getConfig(): Promise<ApiResponse<unknown>>;
522
+ /** One-time cart charge. The Idempotency-Key header is only sent when the
523
+ * tenant enables `idempotencyKeys` in PortalConfig, and the backend does NOT
524
+ * yet run its idempotency middleware on POST /payments/checkout (unlike
525
+ * prescription-checkout) — the key is best-effort future-proofing and never
526
+ * a license to auto-retry an ambiguous failure: a replay is a possible
527
+ * second real charge until the backend adds the middleware. */
528
+ checkout(payload: CheckoutPayload, opts?: {
529
+ idempotencyKey?: string;
530
+ }): Promise<CheckoutResult>;
531
+ prescriptionCheckout(payload: {
532
+ drugId: string;
533
+ prescriptionRequestId?: string;
534
+ opaqueData?: Record<string, unknown>;
535
+ promoCode?: string;
536
+ /** Per-order delivery address; backend falls back to the member profile when omitted. */
537
+ shippingAddress?: CheckoutAddress;
538
+ /** Charge billTo; backend falls back to the member profile when omitted. */
539
+ billingAddress?: CheckoutAddress;
540
+ }, opts?: {
541
+ idempotencyKey?: string;
542
+ }): Promise<unknown>;
543
+ initiate(payload: PaymentInitiatePayload): Promise<unknown>;
544
+ callback(payload: PaymentCallbackPayload): Promise<unknown>;
545
+ };
546
+ declare const subscriptionsApi: {
547
+ list(params?: PaginationParams, opts?: {
548
+ authToken?: string;
549
+ }): Promise<ApiResponse<unknown>>;
550
+ create(payload: CreateSubscriptionPayload, opts?: {
551
+ idempotencyKey?: string;
552
+ }): Promise<ApiResponse<unknown>>;
553
+ get(id: string): Promise<ApiResponse<unknown>>;
554
+ cancel(id: string): Promise<unknown>;
555
+ pause(id: string): Promise<unknown>;
556
+ resume(id: string): Promise<unknown>;
557
+ getPaymentMethod(id: string): Promise<ApiResponse<unknown>>;
558
+ updatePaymentMethod(id: string, payload: UpdatePaymentMethodPayload): Promise<unknown>;
559
+ };
560
+ declare const messagesApi: {
561
+ listConversations(params?: PaginationParams): Promise<ApiResponse<unknown>>;
562
+ getConversation(id: string): Promise<ApiResponse<unknown>>;
563
+ listMessages(conversationId: string, params?: PaginationParams): Promise<ApiResponse<unknown>>;
564
+ sendMessage(conversationId: string, payload: SendMessagePayload, opts?: {
565
+ idempotencyKey?: string;
566
+ }): Promise<unknown>;
567
+ markAsRead(conversationId: string): Promise<unknown>;
568
+ uploadAttachment(conversationId: string, file: File): Promise<ApiResponse<unknown>>;
569
+ getUnreadCount(): Promise<ApiResponse<{
570
+ unreadCount: number;
571
+ }>>;
572
+ };
573
+ type SupportThreadStatus = 'open' | 'pending' | 'closed';
574
+ /**
575
+ * Mirrors the backend's allowlist so a rejected file fails instantly instead of
576
+ * round-tripping to a 415. The server remains the authority — this is UX, not
577
+ * enforcement. Keep in step with services/supportAttachments.ts in the-backend.
578
+ */
579
+ declare const SUPPORT_ATTACHMENT_MIME_TYPES: string[];
580
+ /** 10MB, matching the server's multer cap and the bucket's own limit. */
581
+ declare const SUPPORT_ATTACHMENT_MAX_BYTES: number;
582
+ interface SupportThread {
583
+ id: string;
584
+ subject: string;
585
+ status: SupportThreadStatus;
586
+ lastMessageAt: string;
587
+ lastSender: 'customer' | 'support';
588
+ /** True when the customer has not read the latest support reply. */
589
+ customerUnread: boolean;
590
+ createdAt: string;
591
+ updatedAt: string;
592
+ }
593
+ interface SupportAttachment {
594
+ id: string;
595
+ messageId: string;
596
+ filename: string;
597
+ mimeType: string;
598
+ sizeBytes: number;
599
+ createdAt: string;
600
+ }
601
+ interface SupportMessage {
602
+ id: string;
603
+ threadId: string;
604
+ sender: 'customer' | 'support';
605
+ body: string;
606
+ createdAt: string;
607
+ attachments: SupportAttachment[];
608
+ }
609
+ /** Credentials for subscribing to live thread updates. 503 when unconfigured. */
610
+ interface SupportRealtimeToken {
611
+ token: string;
612
+ expiresAt: string;
613
+ url: string;
614
+ anonKey: string;
615
+ topics: {
616
+ tenant: string;
617
+ threadPrefix: string;
618
+ };
619
+ }
620
+ declare const supportApi: {
621
+ listThreads(): Promise<ApiResponse<{
622
+ threads: SupportThread[];
623
+ }> & {
624
+ threads?: SupportThread[];
625
+ }>;
626
+ getThread(id: string): Promise<ApiResponse<{
627
+ thread: SupportThread;
628
+ messages: SupportMessage[];
629
+ }> & {
630
+ thread?: SupportThread;
631
+ messages?: SupportMessage[];
632
+ }>;
633
+ /** Open a new thread. Unlike a clinical conversation this needs a subject. */
634
+ createThread(payload: {
635
+ subject: string;
636
+ body: string;
637
+ }, opts?: {
638
+ idempotencyKey?: string;
639
+ }): Promise<ApiResponse<{
640
+ thread: SupportThread;
641
+ message: SupportMessage;
642
+ }> & {
643
+ thread?: SupportThread;
644
+ message?: SupportMessage;
645
+ }>;
646
+ sendMessage(threadId: string, payload: {
647
+ body: string;
648
+ }, opts?: {
649
+ idempotencyKey?: string;
650
+ }): Promise<ApiResponse<{
651
+ message: SupportMessage;
652
+ }> & {
653
+ message?: SupportMessage;
654
+ }>;
655
+ markAsRead(threadId: string): Promise<unknown>;
656
+ uploadAttachment(threadId: string, file: File, body?: string): Promise<ApiResponse<unknown>>;
657
+ /** Short-lived signed URL for a stored attachment. */
658
+ getAttachmentUrl(attachmentId: string): Promise<ApiResponse<{
659
+ url: string;
660
+ }> & {
661
+ url?: string;
662
+ }>;
663
+ /** Threads (not messages) carrying an unread reply. */
664
+ getUnreadCount(): Promise<ApiResponse<{
665
+ unreadCount: number;
666
+ }> & {
667
+ unreadCount?: number;
668
+ }>;
669
+ /**
670
+ * Realtime credentials. Answers 503 when the deployment has no anon key
671
+ * configured, which callers should treat as "stay on polling", not an error.
672
+ */
673
+ getRealtimeToken(): Promise<SupportRealtimeToken>;
674
+ };
675
+ interface ProductSaleSummary {
676
+ saleIds: string[];
677
+ primaryLabel: string;
678
+ endDate?: string;
679
+ discountCents: number;
680
+ finalCents: number;
681
+ }
682
+ interface CatalogProduct {
683
+ id: string;
684
+ name: string;
685
+ description: string | null;
686
+ price: number | null;
687
+ categories: string[];
688
+ is_subscription: boolean;
689
+ /** Subscription billing cycle as stored on the product. The backend has
690
+ * always sent this on `GET /products` — it was just missing from the type.
691
+ * Sites needing a period in days derive it from here instead of assuming 30.
692
+ * Absent/null on non-subscription products. */
693
+ billing_interval?: {
694
+ unit: string;
695
+ length: number;
696
+ } | null;
697
+ benefits: string[];
698
+ metadata: Record<string, unknown> | null;
699
+ /** Available doses for this product, from the linked Apex drug (the source of
700
+ * truth for what's offered). The backend derives this; an empty/absent list
701
+ * means no Apex-backed doses (a plain, dose-less product). */
702
+ available_dosages?: string[];
703
+ /** Optional price overlay keyed by dosage: a dose listed here uses this price,
704
+ * any other available dose falls back to the product's base `price`. */
705
+ dosage_prices: Array<{
706
+ dosage: string;
707
+ price: number;
708
+ savingsPrice: number | null;
709
+ }>;
710
+ /** When 'flat_fee', the base `price` applies to any dose and the customer-facing
711
+ * UI is expected to hide the variant picker. `dosage_override` (or the first
712
+ * active dose) is the hidden dose used for prescriptions. Defaults to 'per_dose'. */
713
+ pricing_mode?: 'per_dose' | 'flat_fee';
714
+ dosage_override?: string | null;
715
+ /** The linked Apex drug id (the id the survey qualification verdict is keyed
716
+ * on). Carried onto the cart item so request creation can drop drugs the
717
+ * survey marked ineligible. Null for products with no Apex link. */
718
+ apex_drug_id?: string | null;
719
+ /** Merchandising flag set in the admin product editor — featured products are
720
+ * surfaced prominently (e.g. the storefront landing page / a "Featured"
721
+ * filter). Absent on older payloads; treat missing as not featured. */
722
+ featured?: boolean;
723
+ thumbnail_url: string | null;
724
+ salePriceCents?: number | null;
725
+ activeSale?: ProductSaleSummary | null;
726
+ }
727
+ interface PublicCategory {
728
+ id: string;
729
+ name: string;
730
+ order: number;
731
+ }
732
+ declare const productsApi: {
733
+ list(category?: string): Promise<{
734
+ products: CatalogProduct[];
735
+ }>;
736
+ categories(): Promise<{
737
+ categories: PublicCategory[];
738
+ }>;
739
+ };
740
+ interface PromoValidationResponse {
741
+ valid: boolean;
742
+ error?: string;
743
+ promoCode?: {
744
+ id: string;
745
+ code: string;
746
+ discountType: 'percent' | 'fixed';
747
+ discountValueCents: number;
748
+ productIds: string[];
749
+ isExclusive: boolean;
750
+ affiliateId?: string;
751
+ };
752
+ discountCents?: number;
753
+ finalCents?: number;
754
+ }
755
+ declare const promoCodesApi: {
756
+ validate(code: string, opts?: {
757
+ productIds?: string[];
758
+ subtotalCents?: number;
759
+ }): Promise<PromoValidationResponse>;
760
+ };
761
+ declare const ordersApi: {
762
+ create(payload: CreateOrderPayload): Promise<{
763
+ order: Order;
764
+ }>;
765
+ list(params?: PaginationParams): Promise<{
766
+ orders: Order[];
767
+ }>;
768
+ get(id: string): Promise<{
769
+ order: Order;
770
+ }>;
771
+ };
772
+ declare const usersApi: {
773
+ getProfile(opts?: {
774
+ authToken?: string;
775
+ }): Promise<ApiResponse<User>>;
776
+ updateProfile(payload: UpdateProfilePayload): Promise<unknown>;
777
+ };
778
+ type MemberSurveyMode = 'initial' | 'refill';
779
+ /** List entry for a member's own submitted surveys — served from the backend's
780
+ * local ownership records, no Apex round-trip. */
781
+ interface MemberSurveyResponseSummary {
782
+ id: string;
783
+ mode: MemberSurveyMode;
784
+ submittedAt: string;
785
+ }
786
+ interface MemberSurveyTranscriptItem {
787
+ questionId: string;
788
+ question: string;
789
+ answer: string;
790
+ }
791
+ interface MemberSurveyTranscriptSection {
792
+ sectionId: string;
793
+ title: string;
794
+ items: MemberSurveyTranscriptItem[];
795
+ }
796
+ /** Structured transcript of a submitted survey, exactly as asked at submit time
797
+ * (Apex renders from the stored composedSurvey — never recomposed against the
798
+ * current catalog). */
799
+ interface MemberSurveyTranscript {
800
+ id: string;
801
+ mode: MemberSurveyMode;
802
+ createdAt: string | null;
803
+ completedAt: string | null;
804
+ drugIds: string[];
805
+ selectedDrugId: string | null;
806
+ patientName: string | null;
807
+ sections: MemberSurveyTranscriptSection[];
808
+ }
809
+ declare const membersApi: {
810
+ getMe(): Promise<MembersMeResponse>;
811
+ /** The member's own submitted intake/refill surveys (newest first). */
812
+ getSurveyResponses(): Promise<{
813
+ responses: MemberSurveyResponseSummary[];
814
+ }>;
815
+ getSurveyResponse(responseId: string): Promise<MemberSurveyTranscript>;
816
+ getRequests(opts?: {
817
+ authToken?: string;
818
+ }): Promise<{
819
+ requests: MemberPrescriptionRequest[];
820
+ }>;
821
+ /** Cancel a still-under-review request (pending/new only). */
822
+ cancelRequest(requestId: string): Promise<unknown>;
823
+ getPendingSurveys(opts?: {
824
+ authToken?: string;
825
+ }): Promise<{
826
+ surveys: PendingRenewalSurvey[];
827
+ }>;
828
+ completeSurvey(renewalId: string, payload: CompleteSurveyPayload): Promise<{
829
+ success: boolean;
830
+ newRequestId?: string;
831
+ declined?: boolean;
832
+ }>;
833
+ };
834
+ interface AdminDashboardStats {
835
+ totalCustomers: number;
836
+ activeSubscriptions: number;
837
+ totalRevenueCents: number;
838
+ failedPayments30d: number;
839
+ }
840
+ interface AdminCustomer {
841
+ uid: string;
842
+ email: string;
843
+ firstName: string;
844
+ lastName: string;
845
+ createdAt: string;
846
+ subscriptionStatus: string;
847
+ status: string;
848
+ }
849
+ interface AdminPayment {
850
+ id: string;
851
+ date: string;
852
+ amountCents: number;
853
+ status: string;
854
+ customerEmail: string;
855
+ customerUid: string;
856
+ transactionId: string;
857
+ }
858
+ interface AdminSubscription {
859
+ id: string;
860
+ medication: string;
861
+ dosage: string;
862
+ status: string;
863
+ amountCents: number;
864
+ intervalDays: number;
865
+ currentPeriodEnd: string;
866
+ createdAt: string;
867
+ customerEmail: string;
868
+ customerUid: string;
869
+ authnetSubscriptionId: string;
870
+ }
871
+ interface AdminWebhookEvent {
872
+ id: string;
873
+ date: string;
874
+ event_type: string;
875
+ provider: string;
876
+ status: string;
877
+ payload: unknown;
878
+ [key: string]: unknown;
879
+ }
880
+ interface AdminProduct {
881
+ id: string;
882
+ name: string;
883
+ description: string | null;
884
+ price: number | null;
885
+ savingsPrice: number | null;
886
+ categories: string[];
887
+ isSubscription: boolean;
888
+ billingInterval: {
889
+ unit: string;
890
+ length: number;
891
+ } | null;
892
+ benefits: string[];
893
+ metadata: Record<string, unknown> | null;
894
+ apexDrugId: string | null;
895
+ dosageOverride: string | null;
896
+ /** A per-dose price overlay that now also carries the SKU identity binding.
897
+ * `price` is null for a dose that is SKU-bound but charges the product base
898
+ * price (binding is independent of pricing). `apexSkuId` is the drug's stable
899
+ * `skus[].id` this dose maps to. See sku-identity-backend-product-config.md. */
900
+ dosagePrices: Array<{
901
+ dosage: string;
902
+ price: number | null;
903
+ savingsPrice: number | null;
904
+ apexSkuId?: string | null;
905
+ }>;
906
+ /** 'per_dose' (default) lets each dose have its own price; 'flat_fee' uses the
907
+ * top-level `price` for any dose and hides the variant picker on storefronts. */
908
+ pricingMode: 'per_dose' | 'flat_fee';
909
+ /** SKU identity (id-native product config): product-level bound SKU id for a
910
+ * single-dose / flat-fee product (per-dose ids live on dosagePrices above). */
911
+ apexSkuId: string | null;
912
+ /** 'bound' = forward the bound apexSkuId; 'prescriber_picks' = forward drugId
913
+ * only (titration / no fixed SKU at order time); null = un-migrated (legacy
914
+ * fuzzy path). */
915
+ skuBindingMode: 'bound' | 'prescriber_picks' | null;
916
+ active: boolean;
917
+ /** Merchandising flag — marks the product for prominent placement (e.g. a
918
+ * "Featured" badge or row) on storefronts that choose to surface it. */
919
+ featured: boolean;
920
+ thumbnailUrl: string | null;
921
+ createdAt: string;
922
+ updatedAt: string;
923
+ }
924
+ interface AdminCategory {
925
+ id: string;
926
+ name: string;
927
+ order: number;
928
+ }
929
+ interface AdminCategoryInput {
930
+ id: string;
931
+ name: string;
932
+ order?: number;
933
+ }
934
+ interface AdminApexDrug {
935
+ id: string;
936
+ name: string;
937
+ dosages: string[];
938
+ /** SKU identity: the drug's stable, opaque SKUs (partner-safe — no pharmacy
939
+ * productId/internalName). Powers the dose→SKU picker in the product editor.
940
+ * Empty for an un-migrated Apex drug. */
941
+ skus: Array<{
942
+ id: string;
943
+ label: string;
944
+ active?: boolean;
945
+ }>;
946
+ defaultAdCopy: string | null;
947
+ imported: boolean;
948
+ productId: string | null;
949
+ }
950
+ interface AdminListParams {
951
+ limit?: number;
952
+ offset?: number;
953
+ search?: string;
954
+ [key: string]: unknown;
955
+ }
956
+ declare const adminApi: {
957
+ getDashboard(): Promise<AdminDashboardStats>;
958
+ getCustomers(params?: AdminListParams): Promise<{
959
+ customers: AdminCustomer[];
960
+ hasMore: boolean;
961
+ }>;
962
+ getCustomer(id: string): Promise<{
963
+ customer: AdminCustomer;
964
+ subscriptions: AdminSubscription[];
965
+ recentPayments: AdminPayment[];
966
+ }>;
967
+ /**
968
+ * Mint a short-lived (15-min) impersonation token to preview the patient
969
+ * dashboard as this customer, read-only. The returned token authenticates
970
+ * GET reads only; any write with it is rejected 403 by the backend.
971
+ */
972
+ impersonateCustomer(uid: string): Promise<{
973
+ token: string;
974
+ expiresAt: string;
975
+ customer: AdminCustomer;
976
+ }>;
977
+ updateCustomerEmail(uid: string, email: string): Promise<{
978
+ customer: AdminCustomer;
979
+ }>;
980
+ sendPasswordReset(uid: string, redirectUrl: string): Promise<{
981
+ ok: true;
982
+ }>;
983
+ getPayments(params?: AdminListParams): Promise<{
984
+ payments: AdminPayment[];
985
+ hasMore: boolean;
986
+ }>;
987
+ refundPayment(id: string, amountCents?: number): Promise<{
988
+ success: boolean;
989
+ refundId?: string;
990
+ error?: string;
991
+ }>;
992
+ quickbooksStatus(): Promise<{
993
+ provider: string | null;
994
+ connected: boolean;
995
+ realmId?: string;
996
+ environment: string;
997
+ }>;
998
+ connectQuickBooks(returnUrl: string): Promise<{
999
+ authUrl: string;
1000
+ }>;
1001
+ getSubscriptions(params?: AdminListParams): Promise<{
1002
+ subscriptions: AdminSubscription[];
1003
+ hasMore: boolean;
1004
+ }>;
1005
+ cancelSubscription(id: string): Promise<{
1006
+ success: boolean;
1007
+ requestsCancelled?: string[];
1008
+ requestsSkipped?: Array<{
1009
+ requestId: string;
1010
+ status: string;
1011
+ }>;
1012
+ requestsFailed?: Array<{
1013
+ requestId: string;
1014
+ error: string;
1015
+ }>;
1016
+ }>;
1017
+ /**
1018
+ * Cancel a customer's still-unapproved Apex requests without touching billing.
1019
+ * Backfill for members cancelled before the on-cancel cascade existed, whose
1020
+ * requests are still sitting in the prescriber queue. Idempotent; 409s while
1021
+ * the customer has a live subscription unless `force` is set.
1022
+ */
1023
+ cancelUnapprovedRequests(uid: string, opts?: {
1024
+ force?: boolean;
1025
+ }): Promise<{
1026
+ success: boolean;
1027
+ cancelled: string[];
1028
+ skipped: Array<{
1029
+ requestId: string;
1030
+ status: string;
1031
+ }>;
1032
+ failed: Array<{
1033
+ requestId: string;
1034
+ error: string;
1035
+ }>;
1036
+ }>;
1037
+ getWebhookEvents(params?: AdminListParams): Promise<{
1038
+ events: AdminWebhookEvent[];
1039
+ hasMore: boolean;
1040
+ }>;
1041
+ getEmailTemplates(): Promise<{
1042
+ templates: EmailTemplatesMap;
1043
+ placeholders?: TemplatePlaceholdersMap;
1044
+ }>;
1045
+ saveEmailTemplates(templates: EmailTemplatesMap): Promise<{
1046
+ success: boolean;
1047
+ }>;
1048
+ resetEmailTemplate(templateKey: string): Promise<{
1049
+ success: boolean;
1050
+ template: TemplateText;
1051
+ }>;
1052
+ sendTestEmail(templateKey: string): Promise<{
1053
+ success: boolean;
1054
+ sentTo?: string;
1055
+ error?: string;
1056
+ }>;
1057
+ getProducts(params?: AdminListParams & {
1058
+ category?: string;
1059
+ }): Promise<{
1060
+ products: AdminProduct[];
1061
+ total: number;
1062
+ hasMore: boolean;
1063
+ }>;
1064
+ getProduct(id: string): Promise<{
1065
+ product: AdminProduct;
1066
+ }>;
1067
+ updateProduct(id: string, payload: Partial<Omit<AdminProduct, "id" | "createdAt" | "updatedAt">>): Promise<{
1068
+ product: AdminProduct;
1069
+ }>;
1070
+ deleteProduct(id: string): Promise<unknown>;
1071
+ getApexDrugs(): Promise<{
1072
+ drugs: AdminApexDrug[];
1073
+ error?: string;
1074
+ }>;
1075
+ importFromApex(drugs: Array<{
1076
+ drugId: string;
1077
+ name: string;
1078
+ }>): Promise<{
1079
+ imported: Array<{
1080
+ productId: string;
1081
+ drugId: string;
1082
+ name: string;
1083
+ }>;
1084
+ skipped: Array<{
1085
+ drugId: string;
1086
+ reason: string;
1087
+ }>;
1088
+ }>;
1089
+ uploadThumbnail(productId: string, file: File): Promise<{
1090
+ thumbnailUrl: string;
1091
+ }>;
1092
+ deleteThumbnail(productId: string): Promise<unknown>;
1093
+ getSales(): Promise<{
1094
+ sales: AdminSale[];
1095
+ }>;
1096
+ createSale(payload: AdminSaleInput): Promise<{
1097
+ sale: AdminSale;
1098
+ }>;
1099
+ updateSale(id: string, payload: Partial<AdminSaleInput>): Promise<{
1100
+ sale: AdminSale;
1101
+ }>;
1102
+ deleteSale(id: string): Promise<unknown>;
1103
+ getPromoCodes(): Promise<{
1104
+ promoCodes: AdminPromoCode[];
1105
+ }>;
1106
+ createPromoCode(payload: AdminPromoCodeInput): Promise<{
1107
+ promoCode: AdminPromoCode;
1108
+ }>;
1109
+ updatePromoCode(id: string, payload: Partial<AdminPromoCodeInput>): Promise<{
1110
+ promoCode: AdminPromoCode;
1111
+ }>;
1112
+ deletePromoCode(id: string): Promise<unknown>;
1113
+ getCategories(): Promise<{
1114
+ categories: AdminCategory[];
1115
+ }>;
1116
+ createCategory(payload: AdminCategoryInput): Promise<{
1117
+ category: AdminCategory;
1118
+ }>;
1119
+ updateCategory(id: string, payload: {
1120
+ name?: string;
1121
+ order?: number;
1122
+ }): Promise<{
1123
+ category: AdminCategory;
1124
+ }>;
1125
+ deleteCategory(id: string): Promise<unknown>;
1126
+ getSupportStats(): Promise<AdminSupportStats>;
1127
+ getSupportThreads(params?: {
1128
+ status?: SupportThreadStatus;
1129
+ cursor?: string;
1130
+ }): Promise<{
1131
+ threads: AdminSupportThread[];
1132
+ nextCursor?: string;
1133
+ }>;
1134
+ /** Fetching a thread also clears its unread flag server-side. */
1135
+ getSupportThread(id: string): Promise<{
1136
+ thread: AdminSupportThread;
1137
+ messages: SupportMessage[];
1138
+ customer: AdminSupportCustomer | null;
1139
+ }>;
1140
+ replyToSupportThread(id: string, body: string): Promise<{
1141
+ message: SupportMessage;
1142
+ }>;
1143
+ setSupportThreadStatus(id: string, status: SupportThreadStatus): Promise<{
1144
+ thread: AdminSupportThread;
1145
+ }>;
1146
+ getSupportAttachmentUrl(attachmentId: string): Promise<{
1147
+ url: string;
1148
+ }>;
1149
+ /** Sends a file as a support reply, with optional accompanying text. */
1150
+ uploadSupportAttachment(threadId: string, file: File, body?: string): Promise<{
1151
+ message: SupportMessage;
1152
+ }>;
1153
+ };
1154
+ interface AdminSupportStats {
1155
+ total: number;
1156
+ /** Threads awaiting a support reply. */
1157
+ unread: number;
1158
+ open: number;
1159
+ }
1160
+ interface AdminSupportCustomer {
1161
+ id: string;
1162
+ firstName?: string;
1163
+ lastName?: string;
1164
+ email: string;
1165
+ }
1166
+ interface AdminSupportThread extends SupportThread {
1167
+ /** True when support has not read the latest customer message. */
1168
+ adminUnread: boolean;
1169
+ userId: string;
1170
+ /** Attached on list responses; null when the user row has gone. */
1171
+ customer?: AdminSupportCustomer | null;
1172
+ }
1173
+ type DiscountType = 'percent' | 'fixed';
1174
+ interface AdminSale {
1175
+ id: string;
1176
+ tenantId: string;
1177
+ name: string;
1178
+ discountType: DiscountType;
1179
+ discountValueCents: number;
1180
+ startDate?: string;
1181
+ endDate?: string;
1182
+ productIds: string[];
1183
+ isExclusive: boolean;
1184
+ isActive: boolean;
1185
+ recurringCharges: number;
1186
+ recurringIndefinite: boolean;
1187
+ createdAt: string;
1188
+ updatedAt: string;
1189
+ }
1190
+ interface AdminSaleInput {
1191
+ name: string;
1192
+ discountType: DiscountType;
1193
+ discountValueCents: number;
1194
+ startDate?: string | null;
1195
+ endDate?: string | null;
1196
+ productIds: string[];
1197
+ isExclusive?: boolean;
1198
+ isActive?: boolean;
1199
+ recurringCharges?: number;
1200
+ recurringIndefinite?: boolean;
1201
+ }
1202
+ interface AdminPromoCode {
1203
+ id: string;
1204
+ tenantId: string;
1205
+ code: string;
1206
+ discountType: DiscountType;
1207
+ discountValueCents: number;
1208
+ startDate?: string;
1209
+ endDate?: string;
1210
+ productIds: string[];
1211
+ isExclusive: boolean;
1212
+ isActive: boolean;
1213
+ recurringCharges: number;
1214
+ recurringIndefinite: boolean;
1215
+ affiliateId?: string;
1216
+ createdAt: string;
1217
+ updatedAt: string;
1218
+ }
1219
+ interface AdminPromoCodeInput {
1220
+ code: string;
1221
+ discountType: DiscountType;
1222
+ discountValueCents: number;
1223
+ startDate?: string | null;
1224
+ endDate?: string | null;
1225
+ productIds?: string[];
1226
+ isExclusive?: boolean;
1227
+ isActive?: boolean;
1228
+ recurringCharges?: number;
1229
+ recurringIndefinite?: boolean;
1230
+ affiliateId?: string | null;
1231
+ }
1232
+ type AffiliateStatus = 'pending' | 'active' | 'suspended' | 'rejected';
1233
+ type CommissionStatus = 'pending' | 'approved' | 'paid' | 'cancelled';
1234
+ type AttributionMethod = 'link' | 'promo_code' | 'both';
1235
+ type PaymentType = 'initial' | 'rebill' | 'onetime';
1236
+ type AffiliatePaymentMethod = 'paypal' | 'bank_transfer' | 'other';
1237
+ interface CommissionConfig {
1238
+ fixedAmountCents?: number;
1239
+ percentageRate?: number;
1240
+ }
1241
+ interface CustomerDiscountConfig {
1242
+ percentDiscount: number;
1243
+ includesShipping: boolean;
1244
+ canCombine: boolean;
1245
+ }
1246
+ interface AffiliateProgram {
1247
+ id: string;
1248
+ tenantId: string;
1249
+ name: string;
1250
+ description?: string;
1251
+ defaultCommission: CommissionConfig;
1252
+ /** Default override paid to a parent affiliate on each of their subs' sales. */
1253
+ secondTierCommission?: CommissionConfig;
1254
+ customerDiscount?: CustomerDiscountConfig;
1255
+ cookieDurationDays: number;
1256
+ paymentThresholdCents: number;
1257
+ commissionHoldDays: number;
1258
+ minPayoutCycles: number;
1259
+ recurringCommissions: boolean;
1260
+ oneTimeCommissions: boolean;
1261
+ isActive: boolean;
1262
+ createdAt: string;
1263
+ updatedAt: string;
1264
+ }
1265
+ interface Affiliate {
1266
+ id: string;
1267
+ tenantId: string;
1268
+ email: string;
1269
+ firstName?: string;
1270
+ lastName?: string;
1271
+ paymentEmail?: string;
1272
+ paymentMethod?: AffiliatePaymentMethod;
1273
+ programId: string;
1274
+ affiliateCode: string;
1275
+ status: AffiliateStatus;
1276
+ /** Upline affiliate this one is placed under (admin-assigned). */
1277
+ parentAffiliateId?: string;
1278
+ customCommission?: CommissionConfig;
1279
+ /** Per-affiliate override of the program's second-tier rate (this affiliate as a parent). */
1280
+ customSecondTierCommission?: CommissionConfig;
1281
+ customCustomerDiscountPercent?: number;
1282
+ customMinPayoutCycles?: number;
1283
+ notes?: string;
1284
+ totalEarningsCents: number;
1285
+ paidOutCents: number;
1286
+ pendingCents: number;
1287
+ lastLoginAt?: string;
1288
+ createdAt: string;
1289
+ updatedAt: string;
1290
+ }
1291
+ interface AffiliateConversion {
1292
+ id: string;
1293
+ tenantId: string;
1294
+ affiliateId: string;
1295
+ affiliateCode: string;
1296
+ /** 1 = direct commission; 2 = override earned by this affiliate's parent on a sub's sale. */
1297
+ tier: number;
1298
+ /** For tier-2 rows: the sub-affiliate whose conversion generated this override. */
1299
+ sourceAffiliateId?: string;
1300
+ /** For tier-2 rows: the originating tier-1 conversion. */
1301
+ parentConversionId?: string;
1302
+ orderId?: string;
1303
+ subscriptionId?: string;
1304
+ paymentId?: string;
1305
+ attributionMethod: AttributionMethod;
1306
+ promoCode?: string;
1307
+ paymentType: PaymentType;
1308
+ productSubtotalCents: number;
1309
+ shippingCents: number;
1310
+ orderTotalCents: number;
1311
+ commissionCents: number;
1312
+ commissionFixedAmountCents?: number;
1313
+ commissionPercentageRate?: number;
1314
+ commissionPercentageAmountCents?: number;
1315
+ minPayoutCycles: number;
1316
+ status: CommissionStatus;
1317
+ payableAt?: string;
1318
+ paidAt?: string;
1319
+ paymentBatchId?: string;
1320
+ createdAt: string;
1321
+ updatedAt: string;
1322
+ }
1323
+ interface AffiliateEarningsBreakdown {
1324
+ pending: number;
1325
+ approved: number;
1326
+ paid: number;
1327
+ cancelled: number;
1328
+ }
1329
+ interface CreateAffiliatePayload {
1330
+ email: string;
1331
+ password: string;
1332
+ firstName?: string;
1333
+ lastName?: string;
1334
+ paymentEmail?: string;
1335
+ paymentMethod?: AffiliatePaymentMethod;
1336
+ programId: string;
1337
+ affiliateCode: string;
1338
+ status?: AffiliateStatus;
1339
+ parentAffiliateId?: string;
1340
+ customCommission?: CommissionConfig;
1341
+ customSecondTierCommission?: CommissionConfig;
1342
+ customCustomerDiscountPercent?: number;
1343
+ customMinPayoutCycles?: number;
1344
+ notes?: string;
1345
+ }
1346
+ type UpdateAffiliatePayload = Partial<Omit<CreateAffiliatePayload, 'parentAffiliateId' | 'customCommission' | 'customSecondTierCommission' | 'customCustomerDiscountPercent' | 'customMinPayoutCycles'>> & {
1347
+ parentAffiliateId?: string | null;
1348
+ customCommission?: CommissionConfig | null;
1349
+ customSecondTierCommission?: CommissionConfig | null;
1350
+ customCustomerDiscountPercent?: number | null;
1351
+ customMinPayoutCycles?: number | null;
1352
+ };
1353
+ interface CreateAffiliateProgramPayload {
1354
+ name: string;
1355
+ description?: string;
1356
+ defaultCommission: CommissionConfig;
1357
+ secondTierCommission?: CommissionConfig;
1358
+ customerDiscount?: CustomerDiscountConfig;
1359
+ cookieDurationDays?: number;
1360
+ paymentThresholdCents?: number;
1361
+ commissionHoldDays?: number;
1362
+ minPayoutCycles?: number;
1363
+ recurringCommissions?: boolean;
1364
+ oneTimeCommissions?: boolean;
1365
+ isActive?: boolean;
1366
+ }
1367
+ type UpdateAffiliateProgramPayload = Partial<CreateAffiliateProgramPayload>;
1368
+ interface AffiliateStatsResponse {
1369
+ earnings: AffiliateEarningsBreakdown;
1370
+ recentConversions: AffiliateConversion[];
1371
+ }
1372
+ /** A single sub-affiliate in an affiliate's downline (one hop, no recursion). */
1373
+ interface AffiliateDownlineMember {
1374
+ id: string;
1375
+ affiliateCode: string;
1376
+ firstName?: string;
1377
+ lastName?: string;
1378
+ status: AffiliateStatus;
1379
+ createdAt: string;
1380
+ }
1381
+ declare const adminAffiliatesApi: {
1382
+ list(): Promise<{
1383
+ affiliates: Affiliate[];
1384
+ }>;
1385
+ get(id: string): Promise<{
1386
+ affiliate: Affiliate;
1387
+ }>;
1388
+ getStats(id: string): Promise<AffiliateStatsResponse>;
1389
+ getDownline(id: string): Promise<{
1390
+ downline: Affiliate[];
1391
+ }>;
1392
+ getPromoCodes(id: string): Promise<{
1393
+ promoCodes: AdminPromoCode[];
1394
+ }>;
1395
+ create(payload: CreateAffiliatePayload): Promise<{
1396
+ affiliate: Affiliate;
1397
+ }>;
1398
+ update(id: string, payload: UpdateAffiliatePayload): Promise<{
1399
+ affiliate: Affiliate;
1400
+ }>;
1401
+ remove(id: string): Promise<unknown>;
1402
+ listPrograms(): Promise<{
1403
+ programs: AffiliateProgram[];
1404
+ }>;
1405
+ getProgram(id: string): Promise<{
1406
+ program: AffiliateProgram;
1407
+ }>;
1408
+ createProgram(payload: CreateAffiliateProgramPayload): Promise<{
1409
+ program: AffiliateProgram;
1410
+ }>;
1411
+ updateProgram(id: string, payload: UpdateAffiliateProgramPayload): Promise<{
1412
+ program: AffiliateProgram;
1413
+ }>;
1414
+ removeProgram(id: string): Promise<unknown>;
1415
+ listConversions(params?: {
1416
+ status?: CommissionStatus;
1417
+ limit?: number;
1418
+ }): Promise<{
1419
+ conversions: AffiliateConversion[];
1420
+ }>;
1421
+ runTransitions(): Promise<{
1422
+ transitioned: number;
1423
+ }>;
1424
+ markPaid(id: string, paymentBatchId?: string): Promise<{
1425
+ success: boolean;
1426
+ }>;
1427
+ };
1428
+ declare const affiliateAuthStorageKey: () => string;
1429
+ interface AffiliateAuthTokens {
1430
+ accessToken: string;
1431
+ refreshToken: string;
1432
+ affiliateId: string;
1433
+ }
1434
+ interface AffiliateSession {
1435
+ affiliateId: string;
1436
+ idToken: string;
1437
+ refreshToken: string;
1438
+ expiresIn: number;
1439
+ status: AffiliateStatus;
1440
+ }
1441
+ interface AffiliateRegisterInput {
1442
+ email: string;
1443
+ password: string;
1444
+ firstName: string;
1445
+ lastName: string;
1446
+ affiliateCode: string;
1447
+ paymentEmail?: string;
1448
+ paymentMethod?: AffiliatePaymentMethod;
1449
+ }
1450
+ interface AffiliateRegisterResponse {
1451
+ affiliate: {
1452
+ id: string;
1453
+ email: string;
1454
+ status: AffiliateStatus;
1455
+ };
1456
+ }
1457
+ interface AffiliateDashboardProfile {
1458
+ affiliate: Affiliate;
1459
+ effectiveCommission?: CommissionConfig;
1460
+ customerDiscountPercent?: number;
1461
+ }
1462
+ interface AffiliateDashboardStats {
1463
+ totalClicks: number;
1464
+ totalConversions: number;
1465
+ conversionRate: number;
1466
+ totalEarningsCents: number;
1467
+ pendingCents: number;
1468
+ approvedCents: number;
1469
+ paidCents: number;
1470
+ recentConversions: AffiliateConversion[];
1471
+ }
1472
+ interface AffiliateClickRecord {
1473
+ id: string;
1474
+ affiliateId: string;
1475
+ affiliateCode: string;
1476
+ ipAddress?: string;
1477
+ userAgent?: string;
1478
+ referrer?: string;
1479
+ landingPage?: string;
1480
+ createdAt: string;
1481
+ }
1482
+ interface AffiliateDashboardLinks {
1483
+ affiliateCode: string;
1484
+ links: {
1485
+ homepage: string;
1486
+ signup: string;
1487
+ };
1488
+ }
1489
+ interface AffiliateTrackResponse {
1490
+ success: boolean;
1491
+ tracked: boolean;
1492
+ affiliateCode?: string;
1493
+ cookieDurationDays?: number;
1494
+ }
1495
+ declare function getAffiliateTokens(): AffiliateAuthTokens | null;
1496
+ declare function setAffiliateTokens(tokens: AffiliateAuthTokens): void;
1497
+ declare function clearAffiliateTokens(): void;
1498
+ declare const affiliatePortalApi: {
1499
+ register(input: AffiliateRegisterInput): Promise<AffiliateRegisterResponse>;
1500
+ requestPasswordReset(params: {
1501
+ email: string;
1502
+ redirectUrl: string;
1503
+ }): Promise<{
1504
+ message: string;
1505
+ }>;
1506
+ resetPassword(params: {
1507
+ email: string;
1508
+ token: string;
1509
+ newPassword: string;
1510
+ }): Promise<{
1511
+ message: string;
1512
+ }>;
1513
+ login(email: string, password: string): Promise<AffiliateSession>;
1514
+ logout(): Promise<void>;
1515
+ getProfile(): Promise<AffiliateDashboardProfile>;
1516
+ getStats(): Promise<{
1517
+ stats: AffiliateDashboardStats;
1518
+ }>;
1519
+ listConversions(params?: {
1520
+ limit?: number;
1521
+ }): Promise<{
1522
+ conversions: AffiliateConversion[];
1523
+ }>;
1524
+ listClicks(params?: {
1525
+ limit?: number;
1526
+ }): Promise<{
1527
+ clicks: AffiliateClickRecord[];
1528
+ }>;
1529
+ getLinks(): Promise<AffiliateDashboardLinks>;
1530
+ getPromoCodes(): Promise<{
1531
+ promoCodes: AdminPromoCode[];
1532
+ }>;
1533
+ getDownline(): Promise<{
1534
+ downline: AffiliateDownlineMember[];
1535
+ }>;
1536
+ track(refCode: string, landingPage?: string): Promise<AffiliateTrackResponse>;
1537
+ };
1538
+
1539
+ export { type DiscountType as $, type AddressVerifyResult as A, type AffiliatePaymentMethod as B, type AffiliateProgram as C, type AffiliateRegisterInput as D, type AffiliateRegisterResponse as E, type AffiliateSession as F, type AffiliateStatsResponse as G, type AffiliateStatus as H, type AffiliateTrackResponse as I, ApiError as J, type ApiResponse as K, type AttributionMethod as L, type AuthTokens as M, type CatalogProduct as N, type CheckoutAddress as O, type CheckoutPayload as P, type CheckoutResult as Q, type CommissionConfig as R, type CommissionStatus as S, type CompleteSurveyPayload as T, type CreateAffiliatePayload as U, type CreateAffiliateProgramPayload as V, type CreateOrderPayload as W, type CreateRequestPayload as X, type CreateSubscriptionPayload as Y, type CustomerDiscountConfig as Z, type DeliveryInfo as _, type AdminApexDrug as a, setAffiliateTokens as a$, type EmailTemplatesMap as a0, type LoginPayload as a1, type MemberPrescriptionRequest as a2, type MemberSurveyMode as a3, type MemberSurveyResponseSummary as a4, type MemberSurveyTranscript as a5, type MemberSurveyTranscriptItem as a6, type MemberSurveyTranscriptSection as a7, type MembersMeResponse as a8, type Order as a9, type TokenTrackName as aA, type UpdateAffiliatePayload as aB, type UpdateAffiliateProgramPayload as aC, type UpdatePaymentMethodPayload as aD, type UpdateProfilePayload as aE, type User as aF, addressesApi as aG, adminAffiliatesApi as aH, adminApi as aI, affiliateAuthStorageKey as aJ, affiliatePortalApi as aK, apexApi as aL, apiFetch as aM, authApi as aN, authStorageKey as aO, clearAffiliateTokens as aP, clearTokens as aQ, getAffiliateTokens as aR, getTokens as aS, membersApi as aT, messagesApi as aU, newIdempotencyKey as aV, onTokensCleared as aW, ordersApi as aX, paymentsApi as aY, productsApi as aZ, promoCodesApi as a_, type OrderItemInput as aa, type PaginationParams as ab, type PaymentCallbackPayload as ac, type PaymentInitiatePayload as ad, type PaymentType as ae, type PendingRenewalSurvey as af, type Placeholder as ag, type ProductSaleSummary as ah, type PromoValidationResponse as ai, type PublicCategory as aj, type RegisterAndSubscribePayload as ak, type RegisterPayload as al, type RenewalStatus as am, SUPPORT_ATTACHMENT_MAX_BYTES as an, SUPPORT_ATTACHMENT_MIME_TYPES as ao, type SelectDrugPayload as ap, type SendMessagePayload as aq, type SendToPharmacyPayload as ar, type SupportAttachment as as, type SupportMessage as at, type SupportRealtimeToken as au, type SupportThread as av, type SupportThreadStatus as aw, type SurveySubmitPayload as ax, type TemplatePlaceholdersMap as ay, type TemplateText as az, type AdminCategory as b, setTokens as b0, subscriptionsApi as b1, supportApi as b2, usersApi as b3, type AdminCategoryInput as c, type AdminCustomer as d, type AdminDashboardStats as e, type AdminListParams as f, type AdminPayment as g, type AdminProduct as h, type AdminPromoCode as i, type AdminPromoCodeInput as j, type AdminSale as k, type AdminSaleInput as l, type AdminSubscription as m, type AdminSupportCustomer as n, type AdminSupportStats as o, type AdminSupportThread as p, type AdminWebhookEvent as q, type Affiliate as r, type AffiliateAuthTokens as s, type AffiliateClickRecord as t, type AffiliateConversion as u, type AffiliateDashboardLinks as v, type AffiliateDashboardProfile as w, type AffiliateDashboardStats as x, type AffiliateDownlineMember as y, type AffiliateEarningsBreakdown as z };