@coras-io/embed 0.5.1 → 0.6.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 (373) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +15 -2
  3. package/dist/components/accordion/accordion-item/accordion-item.component.js +9 -3
  4. package/dist/components/accordion/accordion-item/accordion-item.styles.js +4 -0
  5. package/dist/components/accordion/accordion.component.js +8 -0
  6. package/dist/components/alert/alert.component.d.ts +1 -1
  7. package/dist/components/alert/alert.component.js +4 -3
  8. package/dist/components/attraction-card/base/attraction-card.mixin.d.ts +0 -2
  9. package/dist/components/attraction-card/base/attraction-card.mixin.js +0 -6
  10. package/dist/components/attraction-card/base/attraction-card.types.d.ts +0 -1
  11. package/dist/components/basket-mobile/basket-mobile.component.d.ts +14 -3
  12. package/dist/components/basket-mobile/basket-mobile.component.js +71 -15
  13. package/dist/components/better-carousel/better-carousel.component.d.ts +3 -5
  14. package/dist/components/better-carousel/better-carousel.component.js +13 -34
  15. package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.component.js +5 -12
  16. package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.styles.js +13 -5
  17. package/dist/components/breadcrumbs/breadcrumbs.component.d.ts +0 -1
  18. package/dist/components/breadcrumbs/breadcrumbs.component.js +5 -8
  19. package/dist/components/breadcrumbs/breadcrumbs.styles.js +8 -2
  20. package/dist/components/button/button.constants.d.ts +1 -2
  21. package/dist/components/button/button.constants.js +0 -1
  22. package/dist/components/calendar/base/calendar.mixin.js +5 -1
  23. package/dist/components/calendar/multi/multi.component.d.ts +2 -2
  24. package/dist/components/calendar/multi/multi.component.js +12 -19
  25. package/dist/components/carousel/carousel.component.js +9 -2
  26. package/dist/components/categories-tree/categories-tree.component.d.ts +5 -3
  27. package/dist/components/categories-tree/categories-tree.component.js +22 -21
  28. package/dist/components/checkbox/checkbox.component.js +5 -1
  29. package/dist/components/checkbox-group/checkbox-group.component.js +1 -1
  30. package/dist/components/checkbox-group/checkbox-group.styles.js +1 -1
  31. package/dist/components/chip/chip.component.js +8 -3
  32. package/dist/components/crypto-auth-modal/crypto-auth-modal.component.d.ts +6 -0
  33. package/dist/components/crypto-auth-modal/crypto-auth-modal.component.js +15 -1
  34. package/dist/components/currencies-list/currencies-list.component.js +0 -1
  35. package/dist/components/dialog/dialog.component.js +52 -21
  36. package/dist/components/drawer/drawer.component.d.ts +3 -2
  37. package/dist/components/drawer/drawer.component.js +13 -18
  38. package/dist/components/drawer/drawer.styles.js +5 -2
  39. package/dist/components/dropdown/dropdown.component.js +6 -9
  40. package/dist/components/expiration-timer/expiration-timer.component.d.ts +2 -3
  41. package/dist/components/expiration-timer/expiration-timer.component.js +10 -8
  42. package/dist/components/explore-card/explore-card.component.js +3 -1
  43. package/dist/components/explore-card/explore-card.styles.js +31 -0
  44. package/dist/components/filters-drawer/filters-drawer.component.js +1 -1
  45. package/dist/components/flag-icon/flag-icon.component.d.ts +4 -2
  46. package/dist/components/flag-icon/flag-icon.component.js +16 -4
  47. package/dist/components/icon/icon.component.js +15 -2
  48. package/dist/components/image/image.component.js +4 -3
  49. package/dist/components/image-viewer/image-viewer.component.js +6 -4
  50. package/dist/components/input-field/input-field.component.js +10 -6
  51. package/dist/components/layout/layout.styles.js +1 -1
  52. package/dist/components/locales-list/locales-list.component.js +0 -1
  53. package/dist/components/location-image/location-image.component.js +0 -1
  54. package/dist/components/locations-results/locations-results.component.d.ts +10 -0
  55. package/dist/components/locations-results/locations-results.component.js +22 -15
  56. package/dist/components/locations-results/locations-results.styles.js +4 -1
  57. package/dist/components/message-card/message-card.component.d.ts +1 -1
  58. package/dist/components/message-card/message-card.component.js +4 -3
  59. package/dist/components/mobile-menu-item/mobile-menu-item.component.d.ts +0 -1
  60. package/dist/components/mobile-menu-item/mobile-menu-item.component.js +14 -16
  61. package/dist/components/mobile-menu-item/mobile-menu-item.styles.js +9 -5
  62. package/dist/components/option-group/option-chip/option-chip.component.d.ts +4 -1
  63. package/dist/components/option-group/option-chip/option-chip.component.js +23 -10
  64. package/dist/components/option-group/option-group.component.d.ts +3 -1
  65. package/dist/components/option-group/option-group.component.js +10 -3
  66. package/dist/components/overlay/overlay.component.d.ts +0 -5
  67. package/dist/components/overlay/overlay.component.js +3 -15
  68. package/dist/components/phone-country-code/phone-country-code.component.d.ts +4 -0
  69. package/dist/components/phone-country-code/phone-country-code.component.js +37 -0
  70. package/dist/components/phone-country-codes/phone-country-codes.component.js +1 -1
  71. package/dist/components/phone-field/phone-field.component.js +2 -2
  72. package/dist/components/search-button/search-button.component.d.ts +1 -1
  73. package/dist/components/search-button/search-button.component.js +13 -7
  74. package/dist/components/seated-selector/seated-selector.component.js +3 -3
  75. package/dist/components/seats-io/seats-io.component.d.ts +3 -2
  76. package/dist/components/seats-io/seats-io.component.js +31 -13
  77. package/dist/components/seats-io/seats-io.constants.d.ts +0 -2
  78. package/dist/components/seats-io/seats-io.constants.js +0 -3
  79. package/dist/components/seats-io/seats-io.transform.d.ts +1 -6
  80. package/dist/components/seats-io/seats-io.transform.js +1 -20
  81. package/dist/components/select-list/select-list.component.js +7 -2
  82. package/dist/components/select-list/select-option/select-option.component.d.ts +3 -1
  83. package/dist/components/select-list/select-option/select-option.component.js +10 -3
  84. package/dist/components/tabs/tabs.component.d.ts +2 -0
  85. package/dist/components/tabs/tabs.component.js +59 -5
  86. package/dist/components/time-tag/time-tag.component.js +1 -1
  87. package/dist/containers/basket/basket.component.d.ts +1 -1
  88. package/dist/containers/basket/basket.component.js +21 -20
  89. package/dist/containers/navbar/navbar.component.d.ts +12 -8
  90. package/dist/containers/navbar/navbar.component.js +108 -62
  91. package/dist/containers/navbar/navbar.styles.js +23 -5
  92. package/dist/containers/navbar/navbar.utils.js +4 -4
  93. package/dist/contexts/basket/basket.provider.d.ts +3 -4
  94. package/dist/contexts/basket/basket.provider.js +46 -61
  95. package/dist/contexts/basket/basket.types.d.ts +0 -2
  96. package/dist/controllers/time-expiration.d.ts +15 -2
  97. package/dist/controllers/time-expiration.js +47 -17
  98. package/dist/core/api/client.d.ts +9 -0
  99. package/dist/core/api/client.js +26 -0
  100. package/dist/core/api/middlewares/booking-session/booking-session.constants.d.ts +0 -2
  101. package/dist/core/api/middlewares/booking-session/booking-session.constants.js +0 -2
  102. package/dist/core/api/middlewares/booking-session/booking-session.js +3 -12
  103. package/dist/core/api/middlewares/booking-session/booking-session.utils.d.ts +0 -1
  104. package/dist/core/api/middlewares/booking-session/booking-session.utils.js +6 -28
  105. package/dist/core/api/middlewares/error-handler/error-handler.js +5 -1
  106. package/dist/core/api/middlewares/retry/retry.constants.d.ts +3 -0
  107. package/dist/core/api/middlewares/retry/retry.constants.js +7 -0
  108. package/dist/core/api/middlewares/retry/retry.d.ts +2 -0
  109. package/dist/core/api/middlewares/retry/retry.js +48 -0
  110. package/dist/core/api/queries.d.ts +13 -38
  111. package/dist/core/api/queries.js +16 -99
  112. package/dist/core/events.d.ts +2 -4
  113. package/dist/core/i18n/date.d.ts +14 -5
  114. package/dist/core/i18n/date.js +47 -20
  115. package/dist/core/i18n/localization.js +10 -3
  116. package/dist/core/images/helpers.js +6 -5
  117. package/dist/core/logger.d.ts +17 -0
  118. package/dist/core/logger.js +13 -0
  119. package/dist/core/types/api-schema.d.ts +7872 -0
  120. package/dist/core/types/seats-config.d.ts +5 -4
  121. package/dist/core/types/seats-config.js +10 -3
  122. package/dist/core/utils/crypto-address.d.ts +12 -0
  123. package/dist/core/utils/crypto-address.js +17 -0
  124. package/dist/core/utils/datetime.d.ts +13 -11
  125. package/dist/core/utils/datetime.js +41 -51
  126. package/dist/core/utils/loyalty.d.ts +8 -0
  127. package/dist/core/utils/loyalty.js +10 -0
  128. package/dist/core/utils/redaction.d.ts +9 -0
  129. package/dist/core/utils/redaction.js +58 -0
  130. package/dist/core/utils/time.js +2 -3
  131. package/dist/helpers/helpers.d.ts +6 -0
  132. package/dist/helpers/helpers.js +33 -16
  133. package/dist/locales/ar-SA.d.ts +38 -21
  134. package/dist/locales/ar-SA.js +38 -21
  135. package/dist/locales/da-DK.d.ts +38 -21
  136. package/dist/locales/da-DK.js +38 -21
  137. package/dist/locales/de-DE.d.ts +38 -21
  138. package/dist/locales/de-DE.js +38 -21
  139. package/dist/locales/en-IE.d.ts +38 -21
  140. package/dist/locales/en-IE.js +38 -21
  141. package/dist/locales/en-US.d.ts +38 -21
  142. package/dist/locales/en-US.js +38 -21
  143. package/dist/locales/es-ES.d.ts +38 -21
  144. package/dist/locales/es-ES.js +38 -21
  145. package/dist/locales/fr-FR.d.ts +38 -21
  146. package/dist/locales/fr-FR.js +38 -21
  147. package/dist/locales/fr-MA.d.ts +38 -21
  148. package/dist/locales/fr-MA.js +38 -21
  149. package/dist/locales/is-IS.d.ts +38 -21
  150. package/dist/locales/is-IS.js +38 -21
  151. package/dist/locales/it-IT.d.ts +38 -21
  152. package/dist/locales/it-IT.js +38 -21
  153. package/dist/locales/ms-MY.d.ts +38 -21
  154. package/dist/locales/ms-MY.js +38 -21
  155. package/dist/locales/nb-NO.d.ts +38 -21
  156. package/dist/locales/nb-NO.js +38 -21
  157. package/dist/locales/pl-PL.d.ts +38 -21
  158. package/dist/locales/pl-PL.js +38 -21
  159. package/dist/locales/pt-PT.d.ts +38 -21
  160. package/dist/locales/pt-PT.js +38 -21
  161. package/dist/locales/sv-SE.d.ts +38 -21
  162. package/dist/locales/sv-SE.js +38 -21
  163. package/dist/locales/th-TH.d.ts +38 -21
  164. package/dist/locales/th-TH.js +38 -21
  165. package/dist/locales/tr-TR.d.ts +38 -21
  166. package/dist/locales/tr-TR.js +38 -21
  167. package/dist/locales/zh-CN.d.ts +38 -21
  168. package/dist/locales/zh-CN.js +38 -21
  169. package/dist/locales/zh-HK.d.ts +38 -21
  170. package/dist/locales/zh-HK.js +38 -21
  171. package/dist/mixins/base.mixin.d.ts +3 -1
  172. package/dist/mixins/base.mixin.js +10 -7
  173. package/dist/mixins/coinbase.mixin.d.ts +13 -17
  174. package/dist/mixins/coinbase.mixin.js +251 -288
  175. package/dist/mixins/error-modal.mixin.js +8 -4
  176. package/dist/mixins/location-search/location-search.d.ts +13 -1
  177. package/dist/mixins/location-search/location-search.js +35 -27
  178. package/dist/mixins/overlay/overlay-mixin.js +39 -3
  179. package/dist/mixins/overlay/types.d.ts +1 -0
  180. package/dist/mixins/search-mixin/search-mixin.js +8 -5
  181. package/dist/sdk/diagnostics.js +2 -0
  182. package/dist/sdk/mount.d.ts +10 -0
  183. package/dist/sdk/mount.js +20 -1
  184. package/dist/sdk/page-registry.js +5 -0
  185. package/dist/sdk/params.d.ts +53 -0
  186. package/dist/sdk/params.js +180 -0
  187. package/dist/sdk/redaction.d.ts +1 -4
  188. package/dist/sdk/redaction.js +2 -41
  189. package/dist/sdk/types.d.ts +21 -7
  190. package/dist/sdk/url.d.ts +1 -1
  191. package/dist/sdk/url.js +12 -5
  192. package/dist/sdk/validation.d.ts +1 -26
  193. package/dist/sdk/validation.js +8 -145
  194. package/dist/styles/tokens.d.ts +1 -1
  195. package/dist/styles/tokens.generated.d.ts +1 -1
  196. package/dist/styles/tokens.generated.js +1 -1
  197. package/dist/views/chrome-only-page/chrome-only-page.component.d.ts +30 -0
  198. package/dist/views/chrome-only-page/chrome-only-page.component.js +24 -0
  199. package/dist/views/chrome-only-page/chrome-only-page.d.ts +8 -0
  200. package/dist/views/chrome-only-page/chrome-only-page.js +6 -0
  201. package/dist/views/chrome-only-page/chrome-only-page.styles.js +13 -0
  202. package/dist/views/details-page/details-page.component.d.ts +11 -4
  203. package/dist/views/details-page/details-page.component.js +263 -237
  204. package/dist/views/details-page/details-page.utilts.d.ts +63 -3
  205. package/dist/views/details-page/details-page.utilts.js +53 -5
  206. package/dist/views/details-page/partials/location-categories/location-categories.component.d.ts +29 -0
  207. package/dist/views/details-page/partials/location-categories/location-categories.component.js +149 -0
  208. package/dist/views/details-page/partials/location-categories/location-categories.d.ts +8 -0
  209. package/dist/views/details-page/partials/location-categories/location-categories.js +6 -0
  210. package/dist/views/details-page/partials/location-categories/location-categories.styles.js +35 -0
  211. package/dist/views/details-page/partials/location-highlights/location-highlights.component.d.ts +26 -0
  212. package/dist/views/details-page/partials/location-highlights/location-highlights.component.js +158 -0
  213. package/dist/views/details-page/partials/location-highlights/location-highlights.d.ts +8 -0
  214. package/dist/views/details-page/partials/location-highlights/location-highlights.js +6 -0
  215. package/dist/views/details-page/partials/location-highlights/location-highlights.styles.js +42 -0
  216. package/dist/views/details-page/partials/tour-description/tour-description.component.js +1 -4
  217. package/dist/views/help-page/help-page.component.d.ts +2 -0
  218. package/dist/views/help-page/help-page.component.js +37 -18
  219. package/dist/views/help-page/help-page.utils.js +6 -5
  220. package/dist/views/landing-page/landing-page.component.d.ts +5 -8
  221. package/dist/views/landing-page/landing-page.component.js +82 -97
  222. package/dist/views/payment-page/controllers/crypto-auth.controller.d.ts +10 -4
  223. package/dist/views/payment-page/controllers/crypto-auth.controller.js +53 -31
  224. package/dist/views/payment-page/controllers/crypto-transfer.controller.d.ts +9 -5
  225. package/dist/views/payment-page/controllers/crypto-transfer.controller.js +26 -39
  226. package/dist/views/payment-page/controllers/payment-flow.controller.d.ts +6 -1
  227. package/dist/views/payment-page/controllers/payment-flow.controller.js +1 -0
  228. package/dist/views/payment-page/controllers/stripe-payment.controller.d.ts +20 -2
  229. package/dist/views/payment-page/controllers/stripe-payment.controller.js +42 -19
  230. package/dist/views/payment-page/partials/activity-details/activity-details.component.d.ts +2 -0
  231. package/dist/views/payment-page/partials/activity-details/activity-details.component.js +6 -3
  232. package/dist/views/payment-page/partials/billing-address/billing-address.component.d.ts +2 -0
  233. package/dist/views/payment-page/partials/billing-address/billing-address.component.js +5 -1
  234. package/dist/views/payment-page/partials/confirmation/confirmation.component.js +2 -3
  235. package/dist/views/payment-page/partials/country-field/country-field.component.js +1 -1
  236. package/dist/views/payment-page/partials/payment-type-selector/payment-type-selector.component.js +3 -3
  237. package/dist/views/payment-page/partials/stripe/stripe.component.d.ts +2 -0
  238. package/dist/views/payment-page/partials/stripe/stripe.component.js +36 -7
  239. package/dist/views/payment-page/partials/stripe/stripe.utils.js +0 -3
  240. package/dist/views/payment-page/payment-page.component.d.ts +39 -6
  241. package/dist/views/payment-page/payment-page.component.js +302 -178
  242. package/dist/views/payment-page/payment-page.constants.d.ts +1 -27
  243. package/dist/views/payment-page/payment-page.constants.js +3 -30
  244. package/dist/views/payment-page/payment-page.types.d.ts +1 -19
  245. package/dist/views/payment-page/payment-page.utils.d.ts +22 -13
  246. package/dist/views/payment-page/payment-page.utils.js +57 -75
  247. package/dist/views/payment-page/services/payment-api.service.d.ts +16 -34
  248. package/dist/views/payment-page/services/payment-api.service.js +19 -27
  249. package/dist/views/search-page/search-page.component.d.ts +2 -0
  250. package/dist/views/search-page/search-page.component.js +39 -20
  251. package/dist/views/suggestion-widget/suggestion-widget.component.d.ts +1 -0
  252. package/dist/views/suggestion-widget/suggestion-widget.component.js +6 -5
  253. package/package.json +24 -20
  254. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.component.d.ts +0 -10
  255. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.component.js +0 -43
  256. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.d.ts +0 -8
  257. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.js +0 -6
  258. package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.styles.js +0 -23
  259. package/dist/components/attraction-discovery/attraction-discovery.component.d.ts +0 -10
  260. package/dist/components/attraction-discovery/attraction-discovery.component.js +0 -52
  261. package/dist/components/attraction-discovery/attraction-discovery.constants.d.ts +0 -4
  262. package/dist/components/attraction-discovery/attraction-discovery.constants.js +0 -5
  263. package/dist/components/attraction-discovery/attraction-discovery.d.ts +0 -8
  264. package/dist/components/attraction-discovery/attraction-discovery.js +0 -6
  265. package/dist/components/attraction-discovery/attraction-discovery.styles.js +0 -193
  266. package/dist/components/basket-rewards/basket-rewards.component.d.ts +0 -10
  267. package/dist/components/basket-rewards/basket-rewards.component.js +0 -52
  268. package/dist/components/basket-rewards/basket-rewards.d.ts +0 -8
  269. package/dist/components/basket-rewards/basket-rewards.js +0 -6
  270. package/dist/components/basket-rewards/basket-rewards.styles.js +0 -18
  271. package/dist/components/filter-chip/filter-chip.component.d.ts +0 -12
  272. package/dist/components/filter-chip/filter-chip.component.js +0 -68
  273. package/dist/components/filter-chip/filter-chip.constants.d.ts +0 -2
  274. package/dist/components/filter-chip/filter-chip.constants.js +0 -2
  275. package/dist/components/filter-chip/filter-chip.d.ts +0 -8
  276. package/dist/components/filter-chip/filter-chip.js +0 -6
  277. package/dist/components/filter-chip/filter-chip.styles.d.ts +0 -2
  278. package/dist/components/filter-chip/filter-chip.styles.js +0 -162
  279. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.component.d.ts +0 -10
  280. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.component.js +0 -43
  281. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.d.ts +0 -8
  282. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.js +0 -6
  283. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.styles.d.ts +0 -2
  284. package/dist/components/image-carousel/image-carousel-item/image-carousel-item.styles.js +0 -28
  285. package/dist/components/image-carousel/image-carousel.component.d.ts +0 -8
  286. package/dist/components/image-carousel/image-carousel.component.js +0 -36
  287. package/dist/components/image-carousel/image-carousel.d.ts +0 -8
  288. package/dist/components/image-carousel/image-carousel.js +0 -6
  289. package/dist/components/image-carousel/image-carousel.styles.d.ts +0 -2
  290. package/dist/components/image-carousel/image-carousel.styles.js +0 -72
  291. package/dist/components/itinerary/itinerary-item/itinerary-item.component.d.ts +0 -9
  292. package/dist/components/itinerary/itinerary-item/itinerary-item.component.js +0 -45
  293. package/dist/components/itinerary/itinerary-item/itinerary-item.d.ts +0 -8
  294. package/dist/components/itinerary/itinerary-item/itinerary-item.js +0 -6
  295. package/dist/components/itinerary/itinerary-item/itinerary-item.styles.d.ts +0 -2
  296. package/dist/components/itinerary/itinerary-item/itinerary-item.styles.js +0 -70
  297. package/dist/components/itinerary/itinerary.component.d.ts +0 -7
  298. package/dist/components/itinerary/itinerary.component.js +0 -23
  299. package/dist/components/itinerary/itinerary.d.ts +0 -8
  300. package/dist/components/itinerary/itinerary.js +0 -6
  301. package/dist/components/itinerary/itinerary.styles.d.ts +0 -2
  302. package/dist/components/itinerary/itinerary.styles.js +0 -15
  303. package/dist/components/marketing-tag/marketing-tag.component.d.ts +0 -5
  304. package/dist/components/marketing-tag/marketing-tag.component.js +0 -8
  305. package/dist/components/marketing-tag/marketing-tag.d.ts +0 -8
  306. package/dist/components/marketing-tag/marketing-tag.js +0 -6
  307. package/dist/components/marketing-tag/marketing-tag.styles.d.ts +0 -2
  308. package/dist/components/marketing-tag/marketing-tag.styles.js +0 -36
  309. package/dist/components/price/price.component.d.ts +0 -12
  310. package/dist/components/price/price.component.js +0 -38
  311. package/dist/components/price/price.d.ts +0 -8
  312. package/dist/components/price/price.js +0 -6
  313. package/dist/components/reviews/review/review.component.d.ts +0 -9
  314. package/dist/components/reviews/review/review.component.js +0 -41
  315. package/dist/components/reviews/review/review.d.ts +0 -8
  316. package/dist/components/reviews/review/review.js +0 -6
  317. package/dist/components/reviews/review/review.styles.d.ts +0 -2
  318. package/dist/components/reviews/review/review.styles.js +0 -45
  319. package/dist/components/reviews/reviews.component.d.ts +0 -9
  320. package/dist/components/reviews/reviews.component.js +0 -56
  321. package/dist/components/reviews/reviews.d.ts +0 -8
  322. package/dist/components/reviews/reviews.js +0 -6
  323. package/dist/components/reviews/reviews.styles.d.ts +0 -2
  324. package/dist/components/reviews/reviews.styles.js +0 -73
  325. package/dist/components/selected-tickets-preview/selected-tickets-preview.component.d.ts +0 -10
  326. package/dist/components/selected-tickets-preview/selected-tickets-preview.component.js +0 -51
  327. package/dist/components/selected-tickets-preview/selected-tickets-preview.d.ts +0 -8
  328. package/dist/components/selected-tickets-preview/selected-tickets-preview.js +0 -6
  329. package/dist/components/selected-tickets-preview/selected-tickets-preview.styles.d.ts +0 -2
  330. package/dist/components/selected-tickets-preview/selected-tickets-preview.styles.js +0 -89
  331. package/dist/components/tag/tag.component.d.ts +0 -8
  332. package/dist/components/tag/tag.component.js +0 -33
  333. package/dist/components/tag/tag.constants.d.ts +0 -1
  334. package/dist/components/tag/tag.constants.js +0 -1
  335. package/dist/components/tag/tag.d.ts +0 -8
  336. package/dist/components/tag/tag.js +0 -6
  337. package/dist/components/tag/tag.styles.d.ts +0 -2
  338. package/dist/components/tag/tag.styles.js +0 -56
  339. package/dist/components/tooltip/tooltip.component.d.ts +0 -19
  340. package/dist/components/tooltip/tooltip.component.js +0 -124
  341. package/dist/components/tooltip/tooltip.d.ts +0 -8
  342. package/dist/components/tooltip/tooltip.js +0 -6
  343. package/dist/components/tooltip/tooltip.styles.d.ts +0 -2
  344. package/dist/components/tooltip/tooltip.styles.js +0 -79
  345. package/dist/core/signals.d.ts +0 -2
  346. package/dist/core/signals.js +0 -3
  347. package/dist/core/storybook/argTypes.d.ts +0 -1
  348. package/dist/core/storybook/argTypes.js +0 -46
  349. package/dist/core/storybook/cssprops.d.ts +0 -30
  350. package/dist/core/storybook/cssprops.js +0 -46
  351. package/dist/core/storybook/demo.d.ts +0 -4
  352. package/dist/core/storybook/demo.js +0 -17
  353. package/dist/core/types/api-errors.d.ts +0 -8
  354. package/dist/core/types/api-errors.js +0 -1
  355. package/dist/styles/contrast-fixtures.d.ts +0 -5
  356. package/dist/styles/contrast-fixtures.js +0 -131
  357. package/dist/views/payment-page/domain/payment-mappers.d.ts +0 -7
  358. package/dist/views/payment-page/domain/payment-mappers.js +0 -7
  359. package/dist/views/payment-page/domain/payment-validators.d.ts +0 -6
  360. package/dist/views/payment-page/domain/payment-validators.js +0 -6
  361. package/dist/views/payment-page/domain/recovery-payload.d.ts +0 -8
  362. package/dist/views/payment-page/domain/recovery-payload.js +0 -7
  363. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.component.d.ts +0 -22
  364. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.component.js +0 -65
  365. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.d.ts +0 -8
  366. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.js +0 -6
  367. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.styles.d.ts +0 -2
  368. package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.styles.js +0 -12
  369. package/dist/views/payment-page/payment-page.validation-schema.d.ts +0 -28
  370. package/dist/views/payment-page/payment-page.validation-schema.js +0 -42
  371. /package/dist/{components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.styles.d.ts → views/chrome-only-page/chrome-only-page.styles.d.ts} +0 -0
  372. /package/dist/{components/attraction-discovery/attraction-discovery.styles.d.ts → views/details-page/partials/location-categories/location-categories.styles.d.ts} +0 -0
  373. /package/dist/{components/basket-rewards/basket-rewards.styles.d.ts → views/details-page/partials/location-highlights/location-highlights.styles.d.ts} +0 -0
@@ -128,7 +128,9 @@ export default css `
128
128
  }
129
129
  }
130
130
 
131
- > coras-search-button {
131
+ /* The search-only header swaps the search field's dropdown for a button
132
+ that opens the drawer once the container is too narrow for it. */
133
+ .search-only-controls > coras-search-button {
132
134
  display: none;
133
135
 
134
136
  @container navbar (max-width: 800px) {
@@ -184,11 +186,28 @@ export default css `
184
186
  }
185
187
  }
186
188
 
189
+ /* Menu triggers are native buttons, for keyboard access, drawn as the plain
190
+ text and icons the chrome is made of rather than as form buttons. */
191
+ button.trigger {
192
+ padding: 0;
193
+ border: 0;
194
+ background: none;
195
+ color: inherit;
196
+ font: inherit;
197
+ cursor: pointer;
198
+ }
199
+
187
200
  .navigation-container {
188
201
  display: flex;
189
202
  align-items: center;
190
203
  column-gap: var(--navbar-gap);
191
204
 
205
+ slot[name="nav"]::slotted(*),
206
+ slot[name="actions-start"]::slotted(*),
207
+ slot[name="actions-end"]::slotted(*) {
208
+ flex-shrink: 0;
209
+ }
210
+
192
211
  coras-dropdown {
193
212
  [slot="trigger"] {
194
213
  display: flex;
@@ -211,16 +230,15 @@ export default css `
211
230
  }
212
231
  }
213
232
 
214
- > coras-icon {
215
- cursor: pointer;
233
+ > .mobile-menu-trigger {
216
234
  display: none;
217
235
 
218
236
  @container navbar (max-width: 800px) {
219
- display: block;
237
+ display: flex;
220
238
  }
221
239
 
222
240
  @media (max-width: 800px) {
223
- display: block;
241
+ display: flex;
224
242
  }
225
243
  }
226
244
 
@@ -5,8 +5,8 @@ export const getRecentlySelectedSearches = () => {
5
5
  const storedData = localStorage.getItem(RECENTLY_SELECTED_SEARCHES_KEY);
6
6
  return storedData ? JSON.parse(storedData) : [];
7
7
  }
8
- catch (error) {
9
- console.error("Error while parsing recently selected searches:", error);
8
+ catch {
9
+ // Storage can be unavailable (private browsing) or hold stale data.
10
10
  return [];
11
11
  }
12
12
  };
@@ -19,8 +19,8 @@ export const addRecentlySelectedSearches = (item) => {
19
19
  ].slice(0, RECENTLY_SELECTED_SEARCHES_LIMIT);
20
20
  localStorage.setItem(RECENTLY_SELECTED_SEARCHES_KEY, JSON.stringify(updatedResults));
21
21
  }
22
- catch (error) {
23
- console.error("Error while updating recently selected searches:", error);
22
+ catch {
23
+ // Storage can be unavailable or full; recent searches are a convenience.
24
24
  }
25
25
  };
26
26
  export const getLocaleLabel = (locale) => {
@@ -1,5 +1,5 @@
1
1
  import { LitElement, type PropertyValues, type CSSResultGroup } from "lit";
2
- import type { BasketContext, RemoveItem, ReservationSummary } from "./basket.types.js";
2
+ import type { BasketContext, RemoveItem } from "./basket.types.js";
3
3
  import type { paths } from "../../core/types/api-schema.js";
4
4
  import type { Client } from "openapi-fetch";
5
5
  import type { SupportedLocales } from "../../core/types/index.js";
@@ -9,13 +9,14 @@ export declare class CorasBasketProvider extends LitElement {
9
9
  locale: SupportedLocales;
10
10
  client: Client<paths>;
11
11
  private expirationTimer;
12
- private lowestExpiresInReservationId;
12
+ private expiresAt;
13
13
  private mountRoot;
14
14
  basketState: BasketContext;
15
15
  constructor();
16
16
  connectedCallback(): void;
17
17
  disconnectedCallback(): void;
18
18
  private clearExpirationTimer;
19
+ private recordExpiries;
19
20
  private setupExpirationTimers;
20
21
  private handleReservationCreated;
21
22
  willUpdate(changedProperties: PropertyValues<this>): void;
@@ -23,9 +24,7 @@ export declare class CorasBasketProvider extends LitElement {
23
24
  private deleteReservationTask;
24
25
  private updateBasketState;
25
26
  getReservations: () => void;
26
- addItem: (reservation: ReservationSummary) => void;
27
27
  removeItem: ({ reservationId, apiRequest }: RemoveItem) => void;
28
- clearBasket: () => void;
29
28
  private aggregateLoyalty;
30
29
  render(): import("lit").TemplateResult<1>;
31
30
  }
@@ -12,7 +12,7 @@ import { basketContext } from "./basket.context.js";
12
12
  import { getBookingSession } from "../../core/api/middlewares/booking-session/booking-session.utils.js";
13
13
  import { distributorIdContext, localeContext } from "../properties.context.js";
14
14
  import { clientContext } from "../client.context.js";
15
- import { apiGet, apiDelete, withErrorHandling, } from "../../core/api/queries.js";
15
+ import { apiGet, apiDelete } from "../../core/api/queries.js";
16
16
  import styles from "./basket.styles.js";
17
17
  // Walk up (crossing shadow boundaries) to the mount root the SDK marks with
18
18
  // `data-coras-root`. Null when rendered outside a mount (e.g. Storybook).
@@ -35,6 +35,10 @@ export class CorasBasketProvider extends LitElement {
35
35
  static { this.styles = styles; }
36
36
  constructor() {
37
37
  super();
38
+ // Absolute expiry per reservation id, fixed when the reservations were
39
+ // fetched. `expires_in` is relative to that fetch, so re-reading it when a
40
+ // timer re-arms would push every later deadline into the future.
41
+ this.expiresAt = new Map();
38
42
  // The mount this provider belongs to, used to ignore reservation events from
39
43
  // other Coras mounts on the same page (the listener is on `window`).
40
44
  this.mountRoot = null;
@@ -45,9 +49,7 @@ export class CorasBasketProvider extends LitElement {
45
49
  quantity: 0,
46
50
  loyalty: undefined,
47
51
  getReservations: () => { },
48
- addItem: () => { },
49
52
  removeItem: () => { },
50
- clearBasket: () => { },
51
53
  };
52
54
  this.handleReservationCreated = (event) => {
53
55
  // A composed event's path runs through this mount's root only when the
@@ -63,16 +65,17 @@ export class CorasBasketProvider extends LitElement {
63
65
  if (!bookingSession) {
64
66
  return null;
65
67
  }
66
- const { data } = await withErrorHandling(apiGet({
68
+ const { data } = await apiGet({
67
69
  client: this.client,
68
70
  distributorID: this.distributorID,
69
71
  locale,
70
72
  endpoint: "/{api_version}/reservations",
71
73
  bookingSession,
72
- }));
74
+ });
73
75
  if (!data) {
74
76
  return null;
75
77
  }
78
+ this.recordExpiries(data.reservations);
76
79
  this.updateBasketState({
77
80
  items: data.reservations,
78
81
  price: data.total_price,
@@ -91,34 +94,28 @@ export class CorasBasketProvider extends LitElement {
91
94
  if (!bookingSession) {
92
95
  return null;
93
96
  }
94
- const { data } = await withErrorHandling(apiDelete({
95
- client: this.client,
96
- distributorID: this.distributorID,
97
- locale: this.locale,
98
- endpoint: "/{api_version}/reservations/{reservation_id}",
99
- path: { reservation_id: reservationId },
100
- bookingSession,
101
- }));
102
- if (!data) {
103
- return null;
97
+ try {
98
+ await apiDelete({
99
+ client: this.client,
100
+ distributorID: this.distributorID,
101
+ locale: this.locale,
102
+ endpoint: "/{api_version}/reservations/{reservation_id}",
103
+ path: { reservation_id: reservationId },
104
+ bookingSession,
105
+ });
104
106
  }
105
- this.getReservations();
106
- return data;
107
+ finally {
108
+ // A successful delete answers 204 with no body, and a failed one
109
+ // leaves the optimistic local removal wrong: resync from the API in
110
+ // both cases rather than trusting the local totals.
111
+ this.getReservations();
112
+ }
113
+ return null;
107
114
  },
108
115
  args: (reservationId = "") => [reservationId],
109
116
  });
110
117
  this.getReservations = () => {
111
- this.reservationsTask.run();
112
- };
113
- this.addItem = (reservation) => {
114
- const items = [...(this.basketState.items || []), reservation];
115
- this.updateBasketState({
116
- items,
117
- quantity: this.basketState.quantity + 1,
118
- price: this.basketState.price + reservation.total_price,
119
- loyalty: this.aggregateLoyalty(items),
120
- });
121
- this.setupExpirationTimers();
118
+ void this.reservationsTask.run();
122
119
  };
123
120
  this.removeItem = ({ reservationId, apiRequest = false }) => {
124
121
  if (!this.basketState.items) {
@@ -135,23 +132,12 @@ export class CorasBasketProvider extends LitElement {
135
132
  });
136
133
  this.setupExpirationTimers();
137
134
  if (apiRequest) {
138
- this.deleteReservationTask.run([item.reservation_id]);
135
+ void this.deleteReservationTask.run([item.reservation_id]);
139
136
  }
140
137
  }
141
138
  };
142
- this.clearBasket = () => {
143
- this.updateBasketState({
144
- items: [],
145
- price: 0,
146
- quantity: 0,
147
- loyalty: undefined,
148
- });
149
- this.clearExpirationTimer();
150
- };
151
139
  this.basketState.getReservations = this.getReservations;
152
- this.basketState.addItem = this.addItem;
153
140
  this.basketState.removeItem = this.removeItem;
154
- this.basketState.clearBasket = this.clearBasket;
155
141
  }
156
142
  connectedCallback() {
157
143
  super.connectedCallback();
@@ -171,34 +157,33 @@ export class CorasBasketProvider extends LitElement {
171
157
  if (this.expirationTimer !== undefined) {
172
158
  window.clearTimeout(this.expirationTimer);
173
159
  this.expirationTimer = undefined;
174
- this.lowestExpiresInReservationId = undefined;
175
160
  }
176
161
  }
162
+ recordExpiries(items) {
163
+ const now = Date.now();
164
+ this.expiresAt = new Map(items
165
+ .filter((item) => item.expires_in > 0)
166
+ .map((item) => [item.reservation_id, now + item.expires_in * 1000]));
167
+ }
168
+ // Arm one timer for the earliest deadline among the current items. When it
169
+ // fires the API is the source of truth: refetching drops what the server
170
+ // released and picks up fresh deadlines for the rest.
177
171
  setupExpirationTimers() {
178
172
  this.clearExpirationTimer();
179
- if (!this.basketState.items || this.basketState.items.length === 0) {
180
- return;
181
- }
182
- let lowestExpiresIn = Number.MAX_SAFE_INTEGER;
183
- let lowestExpiresInItem = null;
184
- for (const item of this.basketState.items) {
185
- if (item.expires_in > 0 && item.expires_in < lowestExpiresIn) {
186
- lowestExpiresIn = item.expires_in;
187
- lowestExpiresInItem = item;
173
+ let earliest = Number.POSITIVE_INFINITY;
174
+ for (const item of this.basketState.items ?? []) {
175
+ const deadline = this.expiresAt.get(item.reservation_id);
176
+ if (deadline !== undefined && deadline < earliest) {
177
+ earliest = deadline;
188
178
  }
189
179
  }
190
- if (lowestExpiresInItem) {
191
- const expiresInMs = lowestExpiresIn * 1000;
192
- this.lowestExpiresInReservationId = lowestExpiresInItem.reservation_id;
193
- this.expirationTimer = window.setTimeout(() => {
194
- if (this.lowestExpiresInReservationId) {
195
- this.removeItem({
196
- reservationId: this.lowestExpiresInReservationId,
197
- apiRequest: false,
198
- });
199
- }
200
- }, expiresInMs);
180
+ if (earliest === Number.POSITIVE_INFINITY) {
181
+ return;
201
182
  }
183
+ this.expirationTimer = window.setTimeout(() => {
184
+ this.expirationTimer = undefined;
185
+ this.getReservations();
186
+ }, Math.max(0, earliest - Date.now()));
202
187
  }
203
188
  willUpdate(changedProperties) {
204
189
  super.willUpdate(changedProperties);
@@ -12,7 +12,5 @@ export type BasketContext = {
12
12
  status: TaskStatus;
13
13
  loyalty: components["schemas"]["LoyaltySchema"] | undefined;
14
14
  getReservations: () => void;
15
- addItem: (item: ReservationSummary) => void;
16
15
  removeItem: ({ reservationId, apiRequest }: RemoveItem) => void;
17
- clearBasket: () => void;
18
16
  };
@@ -1,11 +1,24 @@
1
1
  import type { ReactiveController, ReactiveControllerHost } from "lit";
2
+ /**
3
+ * Counts down to a deadline. The remaining time is derived from the deadline
4
+ * on every read rather than decremented per tick, so a background tab whose
5
+ * timers are throttled still shows the right value when it comes back.
6
+ */
2
7
  export declare class TimeExpirationController implements ReactiveController {
3
8
  host: ReactiveControllerHost;
4
- value: number;
9
+ private deadline;
10
+ private connected;
5
11
  private timerID?;
6
12
  private onExpire?;
7
13
  constructor(host: ReactiveControllerHost, expirationTime?: number, onExpire?: () => void);
8
- private destroy;
14
+ /** Whole seconds left, never negative. */
15
+ get value(): number;
16
+ /** Restart the countdown from `seconds` (0 stops it). */
17
+ reset(seconds: number): void;
18
+ private start;
19
+ private stop;
20
+ private tick;
21
+ private handleVisibilityChange;
9
22
  hostConnected(): void;
10
23
  hostDisconnected(): void;
11
24
  }
@@ -1,31 +1,61 @@
1
+ /**
2
+ * Counts down to a deadline. The remaining time is derived from the deadline
3
+ * on every read rather than decremented per tick, so a background tab whose
4
+ * timers are throttled still shows the right value when it comes back.
5
+ */
1
6
  export class TimeExpirationController {
2
7
  constructor(host, expirationTime = 0, onExpire) {
3
- this.value = expirationTime;
8
+ this.deadline = 0;
9
+ this.connected = false;
10
+ this.tick = () => {
11
+ if (this.value <= 0) {
12
+ this.stop();
13
+ this.onExpire?.();
14
+ }
15
+ this.host.requestUpdate();
16
+ };
17
+ // Throttled or suspended timers catch up here, so the label is correct the
18
+ // moment the tab is visible again instead of one tick later.
19
+ this.handleVisibilityChange = () => {
20
+ if (document.visibilityState === "visible" && this.timerID !== undefined) {
21
+ this.tick();
22
+ }
23
+ };
4
24
  this.host = host;
5
25
  this.onExpire = onExpire;
26
+ this.reset(expirationTime);
6
27
  host.addController(this);
7
28
  }
8
- destroy() {
9
- clearInterval(this.timerID);
10
- this.timerID = undefined;
29
+ /** Whole seconds left, never negative. */
30
+ get value() {
31
+ return Math.max(0, Math.ceil((this.deadline - Date.now()) / 1000));
11
32
  }
12
- hostConnected() {
33
+ /** Restart the countdown from `seconds` (0 stops it). */
34
+ reset(seconds) {
35
+ this.deadline = Date.now() + seconds * 1000;
36
+ if (this.connected) {
37
+ this.start();
38
+ }
39
+ }
40
+ start() {
41
+ this.stop();
13
42
  if (this.value <= 0) {
14
43
  return;
15
44
  }
16
- this.timerID = setInterval(() => {
17
- this.value--;
18
- if (this.value <= 0) {
19
- this.value = 0;
20
- this.destroy();
21
- if (this.onExpire) {
22
- this.onExpire();
23
- }
24
- }
25
- this.host.requestUpdate();
26
- }, 1000);
45
+ this.timerID = setInterval(this.tick, 1000);
46
+ }
47
+ stop() {
48
+ clearInterval(this.timerID);
49
+ this.timerID = undefined;
50
+ }
51
+ hostConnected() {
52
+ this.connected = true;
53
+ document.addEventListener("visibilitychange", this.handleVisibilityChange);
54
+ this.start();
27
55
  }
28
56
  hostDisconnected() {
29
- this.destroy();
57
+ this.connected = false;
58
+ document.removeEventListener("visibilitychange", this.handleVisibilityChange);
59
+ this.stop();
30
60
  }
31
61
  }
@@ -0,0 +1,9 @@
1
+ import { type Client } from "openapi-fetch";
2
+ import type { paths } from "../types/api-schema.js";
3
+ export declare const API_REQUEST_TIMEOUT_MS = 60000;
4
+ export type ApiClientOptions = {
5
+ baseUrl: string;
6
+ distributorId: string;
7
+ requestTimeoutMs?: number;
8
+ };
9
+ export declare const createApiClient: ({ baseUrl, distributorId, requestTimeoutMs, }: ApiClientOptions) => Client<paths>;
@@ -0,0 +1,26 @@
1
+ import createClient, {} from "openapi-fetch";
2
+ import { DISTRIBUTOR_HEADER } from "./middlewares/booking-session/booking-session.constants.js";
3
+ import { bookingSessionMiddleware } from "./middlewares/booking-session/booking-session.js";
4
+ import { errorHandlerMiddleware } from "./middlewares/error-handler/error-handler.js";
5
+ import { retryMiddleware } from "./middlewares/retry/retry.js";
6
+ // Generous on purpose: PUT /reservations confirms and charges a booking, and
7
+ // aborting it early would report a failure for a payment that may still
8
+ // complete server-side. The point is to stop a dead connection hanging a page
9
+ // forever, not to police slow responses.
10
+ export const API_REQUEST_TIMEOUT_MS = 60_000;
11
+ export const createApiClient = ({ baseUrl, distributorId, requestTimeoutMs = API_REQUEST_TIMEOUT_MS, }) => {
12
+ const client = createClient({
13
+ baseUrl,
14
+ headers: { [DISTRIBUTOR_HEADER]: distributorId },
15
+ // Every attempt, including a middleware retry, gets its own deadline. No
16
+ // caller passes its own signal today; one passed here would be replaced.
17
+ fetch: (request) => fetch(request, { signal: AbortSignal.timeout(requestTimeoutMs) }),
18
+ });
19
+ // openapi-fetch runs onResponse hooks in reverse registration order, so the
20
+ // response pipeline is: retry transient failures, then let the booking
21
+ // session react to a 401, then turn any remaining non-ok response into an
22
+ // APIError. Registering the error handler first is what lets the booking
23
+ // session hook see a 401 at all.
24
+ client.use(errorHandlerMiddleware, bookingSessionMiddleware, retryMiddleware);
25
+ return client;
26
+ };
@@ -2,5 +2,3 @@ export declare const BOOKING_SESSION_STORAGE_KEY = "coras-booking-session";
2
2
  export declare const BOOKING_SESSION_HEADER = "Booking-Session";
3
3
  export declare const BOOKING_SESSION_EXPIRES_HEADER = "booking-session-expires";
4
4
  export declare const DISTRIBUTOR_HEADER = "Coras-Distributor";
5
- export declare const RETRY_ATTEMPTS = 3;
6
- export declare const RETRY_DELAY = 1000;
@@ -2,5 +2,3 @@ export const BOOKING_SESSION_STORAGE_KEY = "coras-booking-session";
2
2
  export const BOOKING_SESSION_HEADER = "Booking-Session";
3
3
  export const BOOKING_SESSION_EXPIRES_HEADER = "booking-session-expires";
4
4
  export const DISTRIBUTOR_HEADER = "Coras-Distributor";
5
- export const RETRY_ATTEMPTS = 3;
6
- export const RETRY_DELAY = 1000;
@@ -1,16 +1,7 @@
1
1
  import { BOOKING_SESSION_EXPIRES_HEADER, BOOKING_SESSION_HEADER, DISTRIBUTOR_HEADER, } from "./booking-session.constants.js";
2
- import { getBookingSession, removeBookingSession, retryWithExponentialBackoff, updateBookingSessionExpiration, } from "./booking-session.utils.js";
2
+ import { getBookingSession, removeBookingSession, updateBookingSessionExpiration, } from "./booking-session.utils.js";
3
3
  export const bookingSessionMiddleware = {
4
- async onError({ request }) {
5
- return await retryWithExponentialBackoff(async () => {
6
- const response = await fetch(request.clone());
7
- if (!response.ok) {
8
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
9
- }
10
- return response;
11
- });
12
- },
13
- async onResponse({ response, request }) {
4
+ async onResponse({ response, request, options }) {
14
5
  // The booking session is per-distributor; scope every read/write to the
15
6
  // distributor this request was made for (set on the client's headers).
16
7
  const distributorId = request.headers.get(DISTRIBUTOR_HEADER);
@@ -24,7 +15,7 @@ export const bookingSessionMiddleware = {
24
15
  headers: newHeaders,
25
16
  });
26
17
  try {
27
- return await fetch(newRequest);
18
+ return await options.fetch(newRequest);
28
19
  }
29
20
  catch {
30
21
  return response;
@@ -2,4 +2,3 @@ export declare const getBookingSession: (distributorId: string) => string | unde
2
2
  export declare const storeBookingSession: (distributorId: string, bookingSession: string, expirationDate: Date) => void;
3
3
  export declare const updateBookingSessionExpiration: (distributorId: string, expirationDate: Date) => void;
4
4
  export declare const removeBookingSession: (distributorId: string) => void;
5
- export declare const retryWithExponentialBackoff: <T>(operation: () => Promise<T>, maxRetries?: number, baseDelayMs?: number, maxDelayMs?: number) => Promise<T>;
@@ -1,4 +1,4 @@
1
- import { BOOKING_SESSION_STORAGE_KEY, RETRY_ATTEMPTS, RETRY_DELAY, } from "./booking-session.constants.js";
1
+ import { BOOKING_SESSION_STORAGE_KEY } from "./booking-session.constants.js";
2
2
  // The token is scoped per distributor: two embeds on the same origin pointing at
3
3
  // different distributors must not share a booking session (basket/checkout).
4
4
  const storageKey = (distributorId) => `${BOOKING_SESSION_STORAGE_KEY}:${distributorId}`;
@@ -8,7 +8,11 @@ export const getBookingSession = (distributorId) => {
8
8
  if (!raw)
9
9
  return undefined;
10
10
  const { token, expiresAt } = JSON.parse(raw);
11
- if (!token || expiresAt <= Date.now()) {
11
+ // An entry with no usable expiry has to fail closed. Comparing it directly
12
+ // would not: `undefined <= Date.now()` is false, so a stored record missing
13
+ // `expiresAt` - or holding a non-numeric one - would hand back its token
14
+ // forever. Anything we cannot prove is still live counts as expired.
15
+ if (!token || !Number.isFinite(expiresAt) || expiresAt <= Date.now()) {
12
16
  removeBookingSession(distributorId);
13
17
  return undefined;
14
18
  }
@@ -45,29 +49,3 @@ export const removeBookingSession = (distributorId) => {
45
49
  // localStorage may be blocked (private browsing).
46
50
  }
47
51
  };
48
- const delay = (ms) => {
49
- return new Promise((resolve) => setTimeout(resolve, ms));
50
- };
51
- export const retryWithExponentialBackoff = async (operation, maxRetries = RETRY_ATTEMPTS, baseDelayMs = RETRY_DELAY, maxDelayMs) => {
52
- let lastError;
53
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
54
- try {
55
- return await operation();
56
- }
57
- catch (error) {
58
- lastError = error;
59
- if (attempt < maxRetries) {
60
- let currentDelay = baseDelayMs * Math.pow(2, attempt - 1);
61
- if (maxDelayMs !== undefined) {
62
- currentDelay = Math.min(currentDelay, maxDelayMs);
63
- }
64
- const jitter = Math.random() * (baseDelayMs / 2);
65
- const finalDelay = Math.round(currentDelay + jitter);
66
- await delay(finalDelay);
67
- }
68
- }
69
- }
70
- throw lastError instanceof Error
71
- ? lastError
72
- : new Error(`Operation failed after ${maxRetries} retries. Last error: ${lastError instanceof Error ? lastError.message : String(lastError)}`);
73
- };
@@ -1,4 +1,5 @@
1
1
  import { APIError } from "../../api-error.js";
2
+ import { redactValue } from "../../../utils/redaction.js";
2
3
  let apiErrorReporter;
3
4
  export const setApiErrorReporter = (reporter) => {
4
5
  apiErrorReporter = reporter;
@@ -13,10 +14,13 @@ export const errorHandlerMiddleware = {
13
14
  catch {
14
15
  errorBody = await response.clone().text();
15
16
  }
17
+ // Validation errors echo submitted fields, so the body is scrubbed once
18
+ // here and every consumer, including the host's error reporter, sees the
19
+ // redacted copy.
16
20
  const error = new APIError({
17
21
  endpoint: new URL(request.url).pathname,
18
22
  method: request.method,
19
- response: errorBody,
23
+ response: redactValue(errorBody),
20
24
  statusCode: response.status,
21
25
  });
22
26
  apiErrorReporter?.(error);
@@ -0,0 +1,3 @@
1
+ export declare const MAX_RETRIES = 2;
2
+ export declare const RETRY_BASE_DELAY_MS = 500;
3
+ export declare const RETRYABLE_STATUSES: ReadonlySet<number>;
@@ -0,0 +1,7 @@
1
+ // Retries after the initial attempt. Delays grow as base * 2^(attempt - 1)
2
+ // plus jitter, so two retries wait roughly 0.5 s and 1 s.
3
+ export const MAX_RETRIES = 2;
4
+ export const RETRY_BASE_DELAY_MS = 500;
5
+ // Transient upstream failures worth a second look. 4xx responses are final and
6
+ // 500 usually means the request itself is the problem.
7
+ export const RETRYABLE_STATUSES = new Set([502, 503, 504]);
@@ -0,0 +1,2 @@
1
+ import type { Middleware } from "openapi-fetch";
2
+ export declare const retryMiddleware: Middleware;
@@ -0,0 +1,48 @@
1
+ import { MAX_RETRIES, RETRY_BASE_DELAY_MS, RETRYABLE_STATUSES, } from "./retry.constants.js";
2
+ // Only safe methods (RFC 9110) are replayed: repeating them cannot create a
3
+ // second reservation, charge, or support request. PUT and DELETE are formally
4
+ // idempotent, but this API's PUT /reservations confirms and charges a booking,
5
+ // so anything that is not read-only is left to the caller to retry.
6
+ const SAFE_METHODS = new Set(["GET", "HEAD", "OPTIONS"]);
7
+ const isSafeRequest = (request) => SAFE_METHODS.has(request.method);
8
+ // A caller cancelling the request is final. A timeout (`TimeoutError`) is a
9
+ // transport failure and is retried like any other network error.
10
+ const isCallerAbort = (error) => error instanceof DOMException && error.name === "AbortError";
11
+ const backoffDelayMs = (attempt) => RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) +
12
+ Math.random() * (RETRY_BASE_DELAY_MS / 2);
13
+ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
14
+ // Resolves with the last response received, even when it still carries a
15
+ // retryable status, so the error middleware can report the real outcome.
16
+ // Rejects with the last network error when no attempt produced a response.
17
+ const replay = async (request, fetch) => {
18
+ let lastError;
19
+ for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
20
+ await delay(backoffDelayMs(attempt));
21
+ try {
22
+ const response = await fetch(request.clone());
23
+ if (attempt === MAX_RETRIES || !RETRYABLE_STATUSES.has(response.status)) {
24
+ return response;
25
+ }
26
+ }
27
+ catch (error) {
28
+ if (isCallerAbort(error))
29
+ throw error;
30
+ lastError = error;
31
+ }
32
+ }
33
+ throw lastError;
34
+ };
35
+ export const retryMiddleware = {
36
+ async onResponse({ request, response, options }) {
37
+ if (!isSafeRequest(request) || !RETRYABLE_STATUSES.has(response.status)) {
38
+ return;
39
+ }
40
+ return await replay(request, options.fetch);
41
+ },
42
+ async onError({ request, error, options }) {
43
+ if (!isSafeRequest(request) || isCallerAbort(error)) {
44
+ return;
45
+ }
46
+ return await replay(request, options.fetch);
47
+ },
48
+ };