@curless/hotel-storefront 0.78.1 → 0.79.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.
Files changed (50) hide show
  1. package/dist/account/fake-ota.d.ts +12 -0
  2. package/dist/account/fake-ota.d.ts.map +1 -1
  3. package/dist/account/fake-ota.js +15 -0
  4. package/dist/account/fake-ota.js.map +1 -1
  5. package/dist/account/index.d.ts.map +1 -1
  6. package/dist/account/index.js +60 -20
  7. package/dist/account/index.js.map +1 -1
  8. package/dist/account/pages.d.ts +6 -2
  9. package/dist/account/pages.d.ts.map +1 -1
  10. package/dist/account/pages.js +16 -4
  11. package/dist/account/pages.js.map +1 -1
  12. package/dist/card.generated.d.ts +1 -1
  13. package/dist/card.generated.js +2 -2
  14. package/dist/card.generated.js.map +1 -1
  15. package/dist/config.d.ts +10 -0
  16. package/dist/config.d.ts.map +1 -1
  17. package/dist/config.js.map +1 -1
  18. package/dist/huazhu/ari-sync.d.ts +175 -0
  19. package/dist/huazhu/ari-sync.d.ts.map +1 -0
  20. package/dist/huazhu/ari-sync.js +712 -0
  21. package/dist/huazhu/ari-sync.js.map +1 -0
  22. package/dist/huazhu/backend.d.ts +12 -0
  23. package/dist/huazhu/backend.d.ts.map +1 -1
  24. package/dist/huazhu/backend.js +102 -78
  25. package/dist/huazhu/backend.js.map +1 -1
  26. package/dist/huazhu/client.d.ts +15 -4
  27. package/dist/huazhu/client.d.ts.map +1 -1
  28. package/dist/huazhu/client.js +12 -7
  29. package/dist/huazhu/client.js.map +1 -1
  30. package/dist/huazhu/make.d.ts.map +1 -1
  31. package/dist/huazhu/make.js +15 -0
  32. package/dist/huazhu/make.js.map +1 -1
  33. package/dist/huazhu/sellable.d.ts +25 -0
  34. package/dist/huazhu/sellable.d.ts.map +1 -1
  35. package/dist/huazhu/sellable.js +73 -0
  36. package/dist/huazhu/sellable.js.map +1 -1
  37. package/dist/otaless/booking.d.ts +11 -0
  38. package/dist/otaless/booking.d.ts.map +1 -1
  39. package/dist/otaless/booking.js +35 -1
  40. package/dist/otaless/booking.js.map +1 -1
  41. package/dist/server.d.ts +2 -2
  42. package/dist/server.d.ts.map +1 -1
  43. package/dist/server.js +12 -5
  44. package/dist/server.js.map +1 -1
  45. package/dist/tools.d.ts.map +1 -1
  46. package/dist/tools.js +30 -11
  47. package/dist/tools.js.map +1 -1
  48. package/dist/types.d.ts +14 -0
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +1 -1
@@ -714,6 +714,17 @@ export const refundOutcome = (out) => {
714
714
  * codes for it are questions #94; ⚠️ NOT ITS 4012 (`CHANNEL_SESSION_EXPIRED`, answered with a
715
715
  * new handshake first) NOR 401 (the account's own sign-in). Words we cannot read are not it.
716
716
  */
717
+ /**
718
+ * The backend's 409 "This record already exists. Please reset and try again." (0.79.1,
719
+ * questions #99): its old record of a group's link stands in the way of a new handshake (16).
720
+ */
721
+ export const recordExistsSaid = (err) => {
722
+ if (!(err instanceof OtalessError) || err instanceof OtalessBusy)
723
+ return false;
724
+ return (err.status === 409 ||
725
+ err.backendCode === 409 ||
726
+ /already exists/i.test(String(err.answer?.msg ?? '')));
727
+ };
717
728
  export const unlinkedSaid = (err) => {
718
729
  if (!(err instanceof OtalessError) || err instanceof OtalessBusy)
719
730
  return false;
@@ -824,6 +835,21 @@ export const createOtalessBookings = (deps) => {
824
835
  log(`[otaless] a booking at ${acct.group} needs its membership linked: ${why} - nothing was ordered`);
825
836
  return signInRefusal('sign-in', `${name} needs the guest's ${name} membership linked to their ${deps.brand} account before this booking can be made, so nothing was booked or charged. Once it is linked, the guest presses Book again.`, [acct.group]);
826
837
  };
838
+ /**
839
+ * ⚠️ THE GROUP'S OLD RECORD OF THE LINK STANDS IN THE WAY (0.79.1, robin 11-19; questions #99):
840
+ * `/initialize` answered 409 "This record already exists. Please reset and try again." - a
841
+ * link older than the group's 24-hour session. Said as the link to be done again - never as
842
+ * the group not taking the booking - with the way on: link again, and if it keeps failing,
843
+ * the platform's support. Nothing was ordered (the handshake comes first). The account marks
844
+ * the link to be linked again, as `linkFirst`.
845
+ */
846
+ const linkRedo = (acct, why) => {
847
+ sessions.delete(sessionKey(acct));
848
+ deps.auth?.expired?.(acct.key, acct.group);
849
+ const name = deps.groupOf(acct.group).name;
850
+ log(`[otaless] a booking at ${acct.group} needs its link done again: ${why} (POST /api/v1/ota/initialize) - nothing was ordered`);
851
+ return Object.assign(signInRefusal('sign-in', `${name} still holds an old record of the guest's ${name} membership link, so its session could not be opened and nothing was booked or charged. The guest links ${name} again (one press, no unlinking first), then presses Book again; if it keeps failing, they contact ${deps.brand} support to have the old record reset.`, [acct.group]), { redo: true });
852
+ };
827
853
  /**
828
854
  * One of this guest's orders, by its id or the code the guest quotes, with
829
855
  * their sign-in at its group - never an order of anyone else, and never one
@@ -893,6 +919,8 @@ export const createOtalessBookings = (deps) => {
893
919
  return signedOut(acct);
894
920
  if (unlinkedSaid(err))
895
921
  return linkFirst(acct, 'initialize said so in its own words');
922
+ if (recordExistsSaid(err))
923
+ return linkRedo(acct, 'initialize answered 409, the record already exists');
896
924
  return err;
897
925
  };
898
926
  let sent;
@@ -2555,7 +2583,13 @@ export const createOtalessBookings = (deps) => {
2555
2583
  stayRefusals.push(err);
2556
2584
  // ⚠️ WITH ITS CODE (0.74.5): the card says it in its own words, with the way to link or
2557
2585
  // sign in - the message is the model's ("…the guest presses Book again").
2558
- const code = e.code === 'sign-in' ? (e.groups.length ? 'link-first' : 'sign-in') : 'signed-out';
2586
+ const code = e.code === 'sign-in'
2587
+ ? e.groups.length
2588
+ ? e.redo
2589
+ ? 'link-redo'
2590
+ : 'link-first'
2591
+ : 'sign-in'
2592
+ : 'signed-out';
2559
2593
  return {
2560
2594
  failed: {
2561
2595
  ...failedStay(label, err.message, code),