@apextelemed/partner-core 0.18.0-dev.59 → 0.18.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 (50) hide show
  1. package/dist/api/index.d.ts +23 -2
  2. package/dist/api/index.js +4 -4
  3. package/dist/api/index.jsx +8 -4
  4. package/dist/chunk/{AXCXMZKP.js → 22EFLJGO.js} +18 -8
  5. package/dist/chunk/22EFLJGO.js.map +1 -0
  6. package/dist/chunk/{P6RRDH3K.jsx → 2Q4GK4WD.jsx} +41 -3
  7. package/dist/chunk/{C4V7G2WO.js → BPF2SSKF.js} +3 -3
  8. package/dist/chunk/{C4V7G2WO.js.map → BPF2SSKF.js.map} +1 -1
  9. package/dist/chunk/{HWUNDWNY.js → CED3IYWX.js} +40 -4
  10. package/dist/chunk/CED3IYWX.js.map +1 -0
  11. package/dist/chunk/ESNAWOHG.jsx +1 -0
  12. package/dist/chunk/{23TRH45I.jsx → FL3DS5WN.jsx} +370 -131
  13. package/dist/chunk/{B3IHYFCS.js → GSYL4J57.js} +2712 -1452
  14. package/dist/chunk/GSYL4J57.js.map +1 -0
  15. package/dist/chunk/{HECRSRX5.jsx → GULO22W6.jsx} +2 -2
  16. package/dist/chunk/{IJR3CERD.js → GYAT2X65.js} +51 -3
  17. package/dist/chunk/GYAT2X65.js.map +1 -0
  18. package/dist/chunk/{QMMIJ5T5.jsx → I7L5WVA2.jsx} +20 -7
  19. package/dist/chunk/{WSP34CNN.jsx → PWEK34Q4.jsx} +50 -2
  20. package/dist/chunk/{OMHZD4JU.jsx → U5DE7VZP.jsx} +3156 -2314
  21. package/dist/chunk/{6D2HEGRD.js → UM5K75Y4.js} +3 -3
  22. package/dist/chunk/{6D2HEGRD.js.map → UM5K75Y4.js.map} +1 -1
  23. package/dist/chunk/{QN3GGUYU.jsx → W5QWCMTE.jsx} +2 -2
  24. package/dist/chunk/{PJVEDHQN.js → XPYBZU45.js} +240 -14
  25. package/dist/chunk/XPYBZU45.js.map +1 -0
  26. package/dist/chunk/XZVVZIRZ.js +3 -0
  27. package/dist/chunk/XZVVZIRZ.js.map +1 -0
  28. package/dist/{client-DUg3WI5F.d.ts → client-BQ8AEx5S.d.ts} +191 -2
  29. package/dist/flows/index.d.ts +113 -2
  30. package/dist/flows/index.js +6 -6
  31. package/dist/flows/index.jsx +14 -6
  32. package/dist/index/index.d.ts +26 -5
  33. package/dist/index/index.js +8 -8
  34. package/dist/index/index.jsx +22 -8
  35. package/dist/pages/index.d.ts +2 -2
  36. package/dist/pages/index.js +5 -5
  37. package/dist/pages/index.jsx +5 -5
  38. package/dist/stores/index.d.ts +1 -1
  39. package/dist/stores/index.js +2 -2
  40. package/dist/stores/index.jsx +2 -2
  41. package/dist/theme/member-portal.css +43 -0
  42. package/package.json +1 -1
  43. package/dist/chunk/ACE7M2YA.jsx +0 -1
  44. package/dist/chunk/AXCXMZKP.js.map +0 -1
  45. package/dist/chunk/B3IHYFCS.js.map +0 -1
  46. package/dist/chunk/HWUNDWNY.js.map +0 -1
  47. package/dist/chunk/IJR3CERD.js.map +0 -1
  48. package/dist/chunk/JSHO46VZ.js +0 -3
  49. package/dist/chunk/JSHO46VZ.js.map +0 -1
  50. package/dist/chunk/PJVEDHQN.js.map +0 -1
@@ -8,8 +8,9 @@ import {
8
8
  readPromoCode,
9
9
  resetCartId,
10
10
  stripCartToken
11
- } from "./HECRSRX5.jsx";
11
+ } from "./GULO22W6.jsx";
12
12
  import {
13
+ PHONE_ERROR,
13
14
  bestOfferDiscount,
14
15
  catalogUnavailableMessage,
15
16
  firstAddressError,
@@ -17,16 +18,18 @@ import {
17
18
  formatCvv,
18
19
  formatExpiry,
19
20
  isLive,
21
+ isValidUsPhone,
20
22
  offerBeatsPromo,
21
23
  useAddressPair,
22
24
  useCardTokenizer,
23
25
  useCatalogAvailability,
26
+ useSmsConsent,
24
27
  validateAddress
25
- } from "./23TRH45I.jsx";
28
+ } from "./FL3DS5WN.jsx";
26
29
  import {
27
30
  auth_default,
28
31
  cart_default
29
- } from "./QN3GGUYU.jsx";
32
+ } from "./W5QWCMTE.jsx";
30
33
  import {
31
34
  ApiError,
32
35
  newIdempotencyKey,
@@ -34,7 +37,7 @@ import {
34
37
  promoCodesApi,
35
38
  subscriptionsApi,
36
39
  usersApi
37
- } from "./WSP34CNN.jsx";
40
+ } from "./PWEK34Q4.jsx";
38
41
  import {
39
42
  getConfig
40
43
  } from "./QVZ7BRNO.jsx";
@@ -88,6 +91,7 @@ function useSubscriptionIntakeFlow(options) {
88
91
  const [password, setPassword] = createSignal("");
89
92
  const [dateOfBirth, setDateOfBirth] = createSignal(restored.dateOfBirth ?? "");
90
93
  const [phone, setPhone] = createSignal(restored.phone ?? "");
94
+ const smsConsent = useSmsConsent(phone, restored.smsConsentVersion);
91
95
  const addr = useAddressPair({
92
96
  initialShipping: {
93
97
  street: restored.street ?? "",
@@ -145,6 +149,7 @@ function useSubscriptionIntakeFlow(options) {
145
149
  city: city(),
146
150
  state: state(),
147
151
  zip: zip(),
152
+ smsConsentVersion: smsConsent.draftVersion(),
148
153
  idempotencyKey: idemKey() || void 0
149
154
  });
150
155
  });
@@ -278,6 +283,7 @@ function useSubscriptionIntakeFlow(options) {
278
283
  const age = (Date.now() - dob.getTime()) / (365.25 * 24 * 3600 * 1e3);
279
284
  if (age < 18) return "You must be at least 18 to register.";
280
285
  if (age > 120) return "Enter a valid date of birth.";
286
+ if (phone().trim() && !isValidUsPhone(phone())) return PHONE_ERROR;
281
287
  } else if (s === 1) {
282
288
  return firstAddressError(validateAddress(addr.shipping(), "", { enforceAvailability: true }));
283
289
  } else if (s === 2) {
@@ -358,6 +364,7 @@ function useSubscriptionIntakeFlow(options) {
358
364
  }
359
365
  try {
360
366
  const promo = promoApplied();
367
+ const smsGrant = smsConsent.grant();
361
368
  if (auth_default.isAuthenticated()) {
362
369
  await usersApi.updateProfile({
363
370
  firstName: firstName().trim(),
@@ -367,7 +374,11 @@ function useSubscriptionIntakeFlow(options) {
367
374
  address1: street().trim(),
368
375
  city: city().trim(),
369
376
  state: state(),
370
- zip: zip().trim()
377
+ zip: zip().trim(),
378
+ // Same PATCH as the phone, so the server applies the number first and
379
+ // the grant covers it. Alongside other fields a refused grant is a
380
+ // note in the reply, never a failed intake.
381
+ ...smsGrant ? { smsConsent: { ...smsGrant, source: "intake" } } : {}
371
382
  });
372
383
  const res = await subscriptionsApi.create({
373
384
  opaqueData: opaque,
@@ -422,7 +433,8 @@ function useSubscriptionIntakeFlow(options) {
422
433
  v2SurveyResponseId: options.surveyResult.v2SurveyResponseId,
423
434
  caseNotes: options.surveyResult.caseNotes,
424
435
  promoCode: promo?.valid ? promo.promoCode?.code : void 0,
425
- ...savingsMemberId ? { savingsMemberId } : {}
436
+ ...savingsMemberId ? { savingsMemberId } : {},
437
+ ...smsGrant ? { smsConsent: smsGrant } : {}
426
438
  }, { idempotencyKey });
427
439
  }
428
440
  clearDraft();
@@ -466,6 +478,7 @@ function useSubscriptionIntakeFlow(options) {
466
478
  setDateOfBirth,
467
479
  phone,
468
480
  setPhone,
481
+ smsConsent,
469
482
  address: addr,
470
483
  availability,
471
484
  cardNumber: cardNumberRaw,
@@ -648,4 +661,4 @@ export {
648
661
  restoreCartFromLink,
649
662
  startCartCapture
650
663
  };
651
- //# sourceMappingURL=QMMIJ5T5.jsx.map
664
+ //# sourceMappingURL=I7L5WVA2.jsx.map
@@ -292,6 +292,9 @@ var ApiError = class extends Error {
292
292
  /** The response body's `details`, untouched, for the few refusals whose
293
293
  * specifics a caller acts on (e.g. which prices are missing). Never shown as prose. */
294
294
  details;
295
+ /** The response body's `reason`, when the endpoint names why it refused (e.g.
296
+ * `stale_text` on a text-message consent). Branch on this, never on message. */
297
+ reason;
295
298
  constructor(message, opts = {}) {
296
299
  super(message);
297
300
  this.name = "ApiError";
@@ -299,6 +302,7 @@ var ApiError = class extends Error {
299
302
  this.ambiguous = opts.ambiguous ?? false;
300
303
  this.code = opts.code;
301
304
  this.details = opts.details;
305
+ this.reason = opts.reason;
302
306
  if (opts.cause !== void 0) this.cause = opts.cause;
303
307
  }
304
308
  };
@@ -376,11 +380,13 @@ async function coreFetch(endpoint, fetchOpts, track, call = {}) {
376
380
  let errorMsg = `Request failed: ${res.status}`;
377
381
  let errorCode;
378
382
  let errorDetails;
383
+ let errorReason;
379
384
  try {
380
385
  const body = await res.json();
381
386
  errorMsg = body.error || body.message || errorMsg;
382
387
  errorCode = typeof body.code === "string" ? body.code : void 0;
383
388
  errorDetails = body.details;
389
+ errorReason = typeof body.reason === "string" ? body.reason : void 0;
384
390
  if (track.enrichErrorDetails && Array.isArray(body.details) && body.details.length > 0) {
385
391
  const lines = body.details.map(
386
392
  (d) => typeof d === "string" ? d : d?.message
@@ -396,7 +402,8 @@ async function coreFetch(endpoint, fetchOpts, track, call = {}) {
396
402
  status: res.status,
397
403
  ambiguous: res.status >= 500,
398
404
  code: errorCode,
399
- ...errorDetails !== void 0 ? { details: errorDetails } : {}
405
+ ...errorDetails !== void 0 ? { details: errorDetails } : {},
406
+ ...errorReason !== void 0 ? { reason: errorReason } : {}
400
407
  });
401
408
  }
402
409
  if (res.status === 204) return void 0;
@@ -835,6 +842,13 @@ var usersApi = {
835
842
  },
836
843
  updateProfile(payload) {
837
844
  return patch("/users/me", payload);
845
+ },
846
+ getSmsState() {
847
+ return apiFetch("/users/me/sms");
848
+ },
849
+ /** Only the named events change; the reply is the full state again. */
850
+ setSmsEvents(events) {
851
+ return put("/users/me/sms/preferences", { events });
838
852
  }
839
853
  };
840
854
  var membersApi = {
@@ -998,6 +1012,14 @@ var adminApi = {
998
1012
  updateSubscription(id, body) {
999
1013
  return patch(`/admin/subscriptions/${id}`, body);
1000
1014
  },
1015
+ /**
1016
+ * Move a subscription's next refill and its check-in while unopened. Never
1017
+ * touches billing (use `updateSubscription` for that). 409 once the refill is
1018
+ * ordered or before the last order has gone out (`fillSchedule.retime.reason`).
1019
+ */
1020
+ retimeNextFill(subscriptionId, body) {
1021
+ return post(`/admin/subscriptions/${subscriptionId}/retime-fill`, body);
1022
+ },
1001
1023
  pauseSubscription(id) {
1002
1024
  return post(`/admin/subscriptions/${id}/pause`, {});
1003
1025
  },
@@ -1132,6 +1154,32 @@ var adminApi = {
1132
1154
  note ? { note } : {}
1133
1155
  );
1134
1156
  },
1157
+ // ── Text messages (settings.write / emailTemplates.write / patient.support) ──
1158
+ /** Is this site set up to text customers, and from what number. Needs `settings.write`. */
1159
+ getSmsSettings() {
1160
+ return apiFetch("/admin/sms/settings");
1161
+ },
1162
+ /** Every event's text, as saved. Needs `emailTemplates.write`. */
1163
+ getSmsTemplates() {
1164
+ return apiFetch("/admin/sms/templates");
1165
+ },
1166
+ /**
1167
+ * Change some events' texts. Send ONLY what changed: a missing event or field
1168
+ * is kept, `null` resets to the default. Rejects (400) with the server's
1169
+ * reason when a body doesn't start with `{{siteName}}`, runs past 300
1170
+ * characters, or uses a token the event doesn't have. Returns the full list.
1171
+ */
1172
+ saveSmsTemplates(templates) {
1173
+ return put("/admin/sms/templates", { templates });
1174
+ },
1175
+ /** Text the SAVED version of an event to the signed-in admin's own phone. */
1176
+ sendSmsTemplateTest(key) {
1177
+ return post(`/admin/sms/templates/${encodeURIComponent(key)}/test`);
1178
+ },
1179
+ /** The send log, newest first. Needs `patient.support`. Page with `nextBefore`. */
1180
+ listSmsMessages(params) {
1181
+ return apiFetch(`/admin/sms/messages${qs(params)}`);
1182
+ },
1135
1183
  getEmailNotifications() {
1136
1184
  return apiFetch("/admin/settings/email-notifications");
1137
1185
  },
@@ -1597,4 +1645,4 @@ export {
1597
1645
  clearAffiliateTokens,
1598
1646
  affiliatePortalApi
1599
1647
  };
1600
- //# sourceMappingURL=WSP34CNN.jsx.map
1648
+ //# sourceMappingURL=PWEK34Q4.jsx.map