@coras-io/embed 0.5.0 → 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.
- package/CHANGELOG.md +36 -0
- package/README.md +15 -2
- package/dist/components/accordion/accordion-item/accordion-item.component.js +9 -3
- package/dist/components/accordion/accordion-item/accordion-item.styles.js +4 -0
- package/dist/components/accordion/accordion.component.js +8 -0
- package/dist/components/alert/alert.component.d.ts +1 -1
- package/dist/components/alert/alert.component.js +4 -3
- package/dist/components/attraction-card/base/attraction-card.mixin.d.ts +0 -2
- package/dist/components/attraction-card/base/attraction-card.mixin.js +0 -6
- package/dist/components/attraction-card/base/attraction-card.types.d.ts +0 -1
- package/dist/components/basket-mobile/basket-mobile.component.d.ts +14 -3
- package/dist/components/basket-mobile/basket-mobile.component.js +71 -15
- package/dist/components/better-carousel/better-carousel.component.d.ts +3 -5
- package/dist/components/better-carousel/better-carousel.component.js +13 -34
- package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.component.js +5 -12
- package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.styles.js +13 -5
- package/dist/components/breadcrumbs/breadcrumbs.component.d.ts +0 -1
- package/dist/components/breadcrumbs/breadcrumbs.component.js +5 -8
- package/dist/components/breadcrumbs/breadcrumbs.styles.js +8 -2
- package/dist/components/button/button.constants.d.ts +1 -2
- package/dist/components/button/button.constants.js +0 -1
- package/dist/components/calendar/base/calendar.mixin.js +5 -1
- package/dist/components/calendar/multi/multi.component.d.ts +2 -2
- package/dist/components/calendar/multi/multi.component.js +12 -19
- package/dist/components/carousel/carousel.component.js +9 -2
- package/dist/components/categories-tree/categories-tree.component.d.ts +5 -3
- package/dist/components/categories-tree/categories-tree.component.js +22 -21
- package/dist/components/checkbox/checkbox.component.js +5 -1
- package/dist/components/checkbox-group/checkbox-group.component.js +1 -1
- package/dist/components/checkbox-group/checkbox-group.styles.js +1 -1
- package/dist/components/chip/chip.component.js +8 -3
- package/dist/components/crypto-auth-modal/crypto-auth-modal.component.d.ts +6 -0
- package/dist/components/crypto-auth-modal/crypto-auth-modal.component.js +15 -1
- package/dist/components/currencies-list/currencies-list.component.js +0 -1
- package/dist/components/dialog/dialog.component.js +52 -21
- package/dist/components/drawer/drawer.component.d.ts +3 -2
- package/dist/components/drawer/drawer.component.js +13 -18
- package/dist/components/drawer/drawer.styles.js +5 -2
- package/dist/components/dropdown/dropdown.component.js +6 -9
- package/dist/components/expiration-timer/expiration-timer.component.d.ts +2 -3
- package/dist/components/expiration-timer/expiration-timer.component.js +10 -8
- package/dist/components/explore-card/explore-card.component.js +3 -1
- package/dist/components/explore-card/explore-card.styles.js +31 -0
- package/dist/components/filters-drawer/filters-drawer.component.js +1 -1
- package/dist/components/flag-icon/flag-icon.component.d.ts +4 -2
- package/dist/components/flag-icon/flag-icon.component.js +16 -4
- package/dist/components/icon/icon.component.js +15 -2
- package/dist/components/image/image.component.js +4 -3
- package/dist/components/image-viewer/image-viewer.component.js +6 -4
- package/dist/components/input-field/input-field.component.js +10 -6
- package/dist/components/layout/layout.styles.js +1 -1
- package/dist/components/locales-list/locales-list.component.js +0 -1
- package/dist/components/location-image/location-image.component.js +0 -1
- package/dist/components/locations-results/locations-results.component.d.ts +10 -0
- package/dist/components/locations-results/locations-results.component.js +22 -15
- package/dist/components/locations-results/locations-results.styles.js +4 -1
- package/dist/components/message-card/message-card.component.d.ts +1 -1
- package/dist/components/message-card/message-card.component.js +4 -3
- package/dist/components/mobile-menu-item/mobile-menu-item.component.d.ts +0 -1
- package/dist/components/mobile-menu-item/mobile-menu-item.component.js +14 -16
- package/dist/components/mobile-menu-item/mobile-menu-item.styles.js +9 -5
- package/dist/components/option-group/option-chip/option-chip.component.d.ts +4 -1
- package/dist/components/option-group/option-chip/option-chip.component.js +23 -10
- package/dist/components/option-group/option-group.component.d.ts +3 -1
- package/dist/components/option-group/option-group.component.js +10 -3
- package/dist/components/overlay/overlay.component.d.ts +0 -5
- package/dist/components/overlay/overlay.component.js +3 -15
- package/dist/components/phone-country-code/phone-country-code.component.d.ts +4 -0
- package/dist/components/phone-country-code/phone-country-code.component.js +37 -0
- package/dist/components/phone-country-codes/phone-country-codes.component.js +1 -1
- package/dist/components/phone-field/phone-field.component.js +2 -2
- package/dist/components/search-button/search-button.component.d.ts +1 -1
- package/dist/components/search-button/search-button.component.js +13 -7
- package/dist/components/seated-selector/seated-selector.component.js +3 -3
- package/dist/components/seats-io/seats-io.component.d.ts +3 -2
- package/dist/components/seats-io/seats-io.component.js +31 -13
- package/dist/components/seats-io/seats-io.constants.d.ts +0 -2
- package/dist/components/seats-io/seats-io.constants.js +0 -3
- package/dist/components/seats-io/seats-io.transform.d.ts +1 -6
- package/dist/components/seats-io/seats-io.transform.js +1 -20
- package/dist/components/select-list/select-list.component.js +7 -2
- package/dist/components/select-list/select-option/select-option.component.d.ts +3 -1
- package/dist/components/select-list/select-option/select-option.component.js +10 -3
- package/dist/components/tabs/tabs.component.d.ts +2 -0
- package/dist/components/tabs/tabs.component.js +59 -5
- package/dist/components/time-tag/time-tag.component.js +1 -1
- package/dist/containers/basket/basket.component.d.ts +1 -1
- package/dist/containers/basket/basket.component.js +21 -20
- package/dist/containers/navbar/navbar.component.d.ts +12 -8
- package/dist/containers/navbar/navbar.component.js +108 -62
- package/dist/containers/navbar/navbar.styles.js +23 -5
- package/dist/containers/navbar/navbar.utils.js +4 -4
- package/dist/contexts/basket/basket.provider.d.ts +3 -4
- package/dist/contexts/basket/basket.provider.js +46 -61
- package/dist/contexts/basket/basket.types.d.ts +0 -2
- package/dist/controllers/time-expiration.d.ts +15 -2
- package/dist/controllers/time-expiration.js +47 -17
- package/dist/core/api/client.d.ts +9 -0
- package/dist/core/api/client.js +26 -0
- package/dist/core/api/middlewares/booking-session/booking-session.constants.d.ts +0 -2
- package/dist/core/api/middlewares/booking-session/booking-session.constants.js +0 -2
- package/dist/core/api/middlewares/booking-session/booking-session.js +3 -12
- package/dist/core/api/middlewares/booking-session/booking-session.utils.d.ts +0 -1
- package/dist/core/api/middlewares/booking-session/booking-session.utils.js +6 -28
- package/dist/core/api/middlewares/error-handler/error-handler.js +5 -1
- package/dist/core/api/middlewares/retry/retry.constants.d.ts +3 -0
- package/dist/core/api/middlewares/retry/retry.constants.js +7 -0
- package/dist/core/api/middlewares/retry/retry.d.ts +2 -0
- package/dist/core/api/middlewares/retry/retry.js +48 -0
- package/dist/core/api/queries.d.ts +13 -38
- package/dist/core/api/queries.js +16 -99
- package/dist/core/events.d.ts +2 -4
- package/dist/core/i18n/date.d.ts +14 -5
- package/dist/core/i18n/date.js +47 -20
- package/dist/core/i18n/localization.js +10 -3
- package/dist/core/images/helpers.js +6 -5
- package/dist/core/logger.d.ts +17 -0
- package/dist/core/logger.js +13 -0
- package/dist/core/types/api-schema.d.ts +7872 -0
- package/dist/core/types/seats-config.d.ts +5 -4
- package/dist/core/types/seats-config.js +10 -3
- package/dist/core/utils/crypto-address.d.ts +12 -0
- package/dist/core/utils/crypto-address.js +17 -0
- package/dist/core/utils/datetime.d.ts +13 -11
- package/dist/core/utils/datetime.js +41 -51
- package/dist/core/utils/loyalty.d.ts +8 -0
- package/dist/core/utils/loyalty.js +10 -0
- package/dist/core/utils/redaction.d.ts +9 -0
- package/dist/core/utils/redaction.js +58 -0
- package/dist/core/utils/time.js +2 -3
- package/dist/helpers/helpers.d.ts +6 -0
- package/dist/helpers/helpers.js +33 -16
- package/dist/locales/ar-SA.d.ts +38 -21
- package/dist/locales/ar-SA.js +38 -21
- package/dist/locales/da-DK.d.ts +38 -21
- package/dist/locales/da-DK.js +38 -21
- package/dist/locales/de-DE.d.ts +38 -21
- package/dist/locales/de-DE.js +38 -21
- package/dist/locales/en-IE.d.ts +38 -21
- package/dist/locales/en-IE.js +38 -21
- package/dist/locales/en-US.d.ts +38 -21
- package/dist/locales/en-US.js +38 -21
- package/dist/locales/es-ES.d.ts +38 -21
- package/dist/locales/es-ES.js +38 -21
- package/dist/locales/fr-FR.d.ts +38 -21
- package/dist/locales/fr-FR.js +38 -21
- package/dist/locales/fr-MA.d.ts +38 -21
- package/dist/locales/fr-MA.js +38 -21
- package/dist/locales/is-IS.d.ts +38 -21
- package/dist/locales/is-IS.js +38 -21
- package/dist/locales/it-IT.d.ts +38 -21
- package/dist/locales/it-IT.js +38 -21
- package/dist/locales/ms-MY.d.ts +38 -21
- package/dist/locales/ms-MY.js +38 -21
- package/dist/locales/nb-NO.d.ts +38 -21
- package/dist/locales/nb-NO.js +38 -21
- package/dist/locales/pl-PL.d.ts +38 -21
- package/dist/locales/pl-PL.js +38 -21
- package/dist/locales/pt-PT.d.ts +38 -21
- package/dist/locales/pt-PT.js +38 -21
- package/dist/locales/sv-SE.d.ts +38 -21
- package/dist/locales/sv-SE.js +38 -21
- package/dist/locales/th-TH.d.ts +38 -21
- package/dist/locales/th-TH.js +38 -21
- package/dist/locales/tr-TR.d.ts +38 -21
- package/dist/locales/tr-TR.js +38 -21
- package/dist/locales/zh-CN.d.ts +38 -21
- package/dist/locales/zh-CN.js +38 -21
- package/dist/locales/zh-HK.d.ts +38 -21
- package/dist/locales/zh-HK.js +38 -21
- package/dist/mixins/base.mixin.d.ts +3 -1
- package/dist/mixins/base.mixin.js +10 -7
- package/dist/mixins/coinbase.mixin.d.ts +13 -17
- package/dist/mixins/coinbase.mixin.js +251 -288
- package/dist/mixins/error-modal.mixin.js +8 -4
- package/dist/mixins/location-search/location-search.d.ts +13 -1
- package/dist/mixins/location-search/location-search.js +35 -27
- package/dist/mixins/overlay/overlay-mixin.js +39 -3
- package/dist/mixins/overlay/types.d.ts +1 -0
- package/dist/mixins/search-mixin/search-mixin.js +8 -5
- package/dist/sdk/diagnostics.js +2 -0
- package/dist/sdk/mount.d.ts +10 -0
- package/dist/sdk/mount.js +20 -1
- package/dist/sdk/page-registry.js +5 -0
- package/dist/sdk/params.d.ts +53 -0
- package/dist/sdk/params.js +180 -0
- package/dist/sdk/redaction.d.ts +1 -4
- package/dist/sdk/redaction.js +2 -41
- package/dist/sdk/types.d.ts +21 -7
- package/dist/sdk/url.d.ts +1 -1
- package/dist/sdk/url.js +12 -5
- package/dist/sdk/validation.d.ts +1 -26
- package/dist/sdk/validation.js +14 -152
- package/dist/styles/tokens.d.ts +1 -1
- package/dist/styles/tokens.generated.d.ts +1 -1
- package/dist/styles/tokens.generated.js +1 -1
- package/dist/views/chrome-only-page/chrome-only-page.component.d.ts +30 -0
- package/dist/views/chrome-only-page/chrome-only-page.component.js +24 -0
- package/dist/views/chrome-only-page/chrome-only-page.d.ts +8 -0
- package/dist/views/chrome-only-page/chrome-only-page.js +6 -0
- package/dist/views/chrome-only-page/chrome-only-page.styles.js +13 -0
- package/dist/views/details-page/details-page.component.d.ts +11 -4
- package/dist/views/details-page/details-page.component.js +263 -237
- package/dist/views/details-page/details-page.utilts.d.ts +63 -3
- package/dist/views/details-page/details-page.utilts.js +53 -5
- package/dist/views/details-page/partials/location-categories/location-categories.component.d.ts +29 -0
- package/dist/views/details-page/partials/location-categories/location-categories.component.js +149 -0
- package/dist/views/details-page/partials/location-categories/location-categories.d.ts +8 -0
- package/dist/views/details-page/partials/location-categories/location-categories.js +6 -0
- package/dist/views/details-page/partials/location-categories/location-categories.styles.js +35 -0
- package/dist/views/details-page/partials/location-highlights/location-highlights.component.d.ts +26 -0
- package/dist/views/details-page/partials/location-highlights/location-highlights.component.js +158 -0
- package/dist/views/details-page/partials/location-highlights/location-highlights.d.ts +8 -0
- package/dist/views/details-page/partials/location-highlights/location-highlights.js +6 -0
- package/dist/views/details-page/partials/location-highlights/location-highlights.styles.js +42 -0
- package/dist/views/details-page/partials/tour-description/tour-description.component.js +1 -4
- package/dist/views/help-page/help-page.component.d.ts +2 -0
- package/dist/views/help-page/help-page.component.js +37 -18
- package/dist/views/help-page/help-page.utils.js +6 -5
- package/dist/views/landing-page/landing-page.component.d.ts +5 -8
- package/dist/views/landing-page/landing-page.component.js +82 -97
- package/dist/views/payment-page/controllers/crypto-auth.controller.d.ts +10 -4
- package/dist/views/payment-page/controllers/crypto-auth.controller.js +53 -31
- package/dist/views/payment-page/controllers/crypto-transfer.controller.d.ts +9 -5
- package/dist/views/payment-page/controllers/crypto-transfer.controller.js +26 -39
- package/dist/views/payment-page/controllers/payment-flow.controller.d.ts +6 -1
- package/dist/views/payment-page/controllers/payment-flow.controller.js +1 -0
- package/dist/views/payment-page/controllers/stripe-payment.controller.d.ts +20 -2
- package/dist/views/payment-page/controllers/stripe-payment.controller.js +42 -19
- package/dist/views/payment-page/partials/activity-details/activity-details.component.d.ts +2 -0
- package/dist/views/payment-page/partials/activity-details/activity-details.component.js +6 -3
- package/dist/views/payment-page/partials/billing-address/billing-address.component.d.ts +2 -0
- package/dist/views/payment-page/partials/billing-address/billing-address.component.js +5 -1
- package/dist/views/payment-page/partials/confirmation/confirmation.component.js +2 -3
- package/dist/views/payment-page/partials/country-field/country-field.component.js +1 -1
- package/dist/views/payment-page/partials/payment-type-selector/payment-type-selector.component.js +3 -3
- package/dist/views/payment-page/partials/stripe/stripe.component.d.ts +2 -0
- package/dist/views/payment-page/partials/stripe/stripe.component.js +36 -7
- package/dist/views/payment-page/partials/stripe/stripe.utils.js +0 -3
- package/dist/views/payment-page/payment-page.component.d.ts +39 -6
- package/dist/views/payment-page/payment-page.component.js +302 -178
- package/dist/views/payment-page/payment-page.constants.d.ts +1 -27
- package/dist/views/payment-page/payment-page.constants.js +3 -30
- package/dist/views/payment-page/payment-page.types.d.ts +1 -19
- package/dist/views/payment-page/payment-page.utils.d.ts +22 -13
- package/dist/views/payment-page/payment-page.utils.js +57 -75
- package/dist/views/payment-page/services/payment-api.service.d.ts +16 -34
- package/dist/views/payment-page/services/payment-api.service.js +19 -27
- package/dist/views/search-page/search-page.component.d.ts +2 -0
- package/dist/views/search-page/search-page.component.js +39 -20
- package/dist/views/suggestion-widget/suggestion-widget.component.d.ts +1 -0
- package/dist/views/suggestion-widget/suggestion-widget.component.js +6 -5
- package/package.json +24 -20
- package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.component.d.ts +0 -10
- package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.component.js +0 -43
- package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.d.ts +0 -8
- package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.js +0 -6
- package/dist/components/attraction-discovery/attraction-discovery-image/attraction-discovery-image.styles.js +0 -23
- package/dist/components/attraction-discovery/attraction-discovery.component.d.ts +0 -10
- package/dist/components/attraction-discovery/attraction-discovery.component.js +0 -52
- package/dist/components/attraction-discovery/attraction-discovery.constants.d.ts +0 -4
- package/dist/components/attraction-discovery/attraction-discovery.constants.js +0 -5
- package/dist/components/attraction-discovery/attraction-discovery.d.ts +0 -8
- package/dist/components/attraction-discovery/attraction-discovery.js +0 -6
- package/dist/components/attraction-discovery/attraction-discovery.styles.js +0 -193
- package/dist/components/basket-rewards/basket-rewards.component.d.ts +0 -10
- package/dist/components/basket-rewards/basket-rewards.component.js +0 -52
- package/dist/components/basket-rewards/basket-rewards.d.ts +0 -8
- package/dist/components/basket-rewards/basket-rewards.js +0 -6
- package/dist/components/basket-rewards/basket-rewards.styles.js +0 -18
- package/dist/components/filter-chip/filter-chip.component.d.ts +0 -12
- package/dist/components/filter-chip/filter-chip.component.js +0 -68
- package/dist/components/filter-chip/filter-chip.constants.d.ts +0 -2
- package/dist/components/filter-chip/filter-chip.constants.js +0 -2
- package/dist/components/filter-chip/filter-chip.d.ts +0 -8
- package/dist/components/filter-chip/filter-chip.js +0 -6
- package/dist/components/filter-chip/filter-chip.styles.d.ts +0 -2
- package/dist/components/filter-chip/filter-chip.styles.js +0 -162
- package/dist/components/image-carousel/image-carousel-item/image-carousel-item.component.d.ts +0 -10
- package/dist/components/image-carousel/image-carousel-item/image-carousel-item.component.js +0 -43
- package/dist/components/image-carousel/image-carousel-item/image-carousel-item.d.ts +0 -8
- package/dist/components/image-carousel/image-carousel-item/image-carousel-item.js +0 -6
- package/dist/components/image-carousel/image-carousel-item/image-carousel-item.styles.d.ts +0 -2
- package/dist/components/image-carousel/image-carousel-item/image-carousel-item.styles.js +0 -28
- package/dist/components/image-carousel/image-carousel.component.d.ts +0 -8
- package/dist/components/image-carousel/image-carousel.component.js +0 -36
- package/dist/components/image-carousel/image-carousel.d.ts +0 -8
- package/dist/components/image-carousel/image-carousel.js +0 -6
- package/dist/components/image-carousel/image-carousel.styles.d.ts +0 -2
- package/dist/components/image-carousel/image-carousel.styles.js +0 -72
- package/dist/components/itinerary/itinerary-item/itinerary-item.component.d.ts +0 -9
- package/dist/components/itinerary/itinerary-item/itinerary-item.component.js +0 -45
- package/dist/components/itinerary/itinerary-item/itinerary-item.d.ts +0 -8
- package/dist/components/itinerary/itinerary-item/itinerary-item.js +0 -6
- package/dist/components/itinerary/itinerary-item/itinerary-item.styles.d.ts +0 -2
- package/dist/components/itinerary/itinerary-item/itinerary-item.styles.js +0 -70
- package/dist/components/itinerary/itinerary.component.d.ts +0 -7
- package/dist/components/itinerary/itinerary.component.js +0 -23
- package/dist/components/itinerary/itinerary.d.ts +0 -8
- package/dist/components/itinerary/itinerary.js +0 -6
- package/dist/components/itinerary/itinerary.styles.d.ts +0 -2
- package/dist/components/itinerary/itinerary.styles.js +0 -15
- package/dist/components/marketing-tag/marketing-tag.component.d.ts +0 -5
- package/dist/components/marketing-tag/marketing-tag.component.js +0 -8
- package/dist/components/marketing-tag/marketing-tag.d.ts +0 -8
- package/dist/components/marketing-tag/marketing-tag.js +0 -6
- package/dist/components/marketing-tag/marketing-tag.styles.d.ts +0 -2
- package/dist/components/marketing-tag/marketing-tag.styles.js +0 -36
- package/dist/components/price/price.component.d.ts +0 -12
- package/dist/components/price/price.component.js +0 -38
- package/dist/components/price/price.d.ts +0 -8
- package/dist/components/price/price.js +0 -6
- package/dist/components/reviews/review/review.component.d.ts +0 -9
- package/dist/components/reviews/review/review.component.js +0 -41
- package/dist/components/reviews/review/review.d.ts +0 -8
- package/dist/components/reviews/review/review.js +0 -6
- package/dist/components/reviews/review/review.styles.d.ts +0 -2
- package/dist/components/reviews/review/review.styles.js +0 -45
- package/dist/components/reviews/reviews.component.d.ts +0 -9
- package/dist/components/reviews/reviews.component.js +0 -56
- package/dist/components/reviews/reviews.d.ts +0 -8
- package/dist/components/reviews/reviews.js +0 -6
- package/dist/components/reviews/reviews.styles.d.ts +0 -2
- package/dist/components/reviews/reviews.styles.js +0 -73
- package/dist/components/selected-tickets-preview/selected-tickets-preview.component.d.ts +0 -10
- package/dist/components/selected-tickets-preview/selected-tickets-preview.component.js +0 -51
- package/dist/components/selected-tickets-preview/selected-tickets-preview.d.ts +0 -8
- package/dist/components/selected-tickets-preview/selected-tickets-preview.js +0 -6
- package/dist/components/selected-tickets-preview/selected-tickets-preview.styles.d.ts +0 -2
- package/dist/components/selected-tickets-preview/selected-tickets-preview.styles.js +0 -89
- package/dist/components/tag/tag.component.d.ts +0 -8
- package/dist/components/tag/tag.component.js +0 -33
- package/dist/components/tag/tag.constants.d.ts +0 -1
- package/dist/components/tag/tag.constants.js +0 -1
- package/dist/components/tag/tag.d.ts +0 -8
- package/dist/components/tag/tag.js +0 -6
- package/dist/components/tag/tag.styles.d.ts +0 -2
- package/dist/components/tag/tag.styles.js +0 -56
- package/dist/components/tooltip/tooltip.component.d.ts +0 -19
- package/dist/components/tooltip/tooltip.component.js +0 -124
- package/dist/components/tooltip/tooltip.d.ts +0 -8
- package/dist/components/tooltip/tooltip.js +0 -6
- package/dist/components/tooltip/tooltip.styles.d.ts +0 -2
- package/dist/components/tooltip/tooltip.styles.js +0 -79
- package/dist/core/signals.d.ts +0 -2
- package/dist/core/signals.js +0 -3
- package/dist/core/storybook/argTypes.d.ts +0 -1
- package/dist/core/storybook/argTypes.js +0 -46
- package/dist/core/storybook/cssprops.d.ts +0 -30
- package/dist/core/storybook/cssprops.js +0 -46
- package/dist/core/storybook/demo.d.ts +0 -4
- package/dist/core/storybook/demo.js +0 -17
- package/dist/core/types/api-errors.d.ts +0 -8
- package/dist/core/types/api-errors.js +0 -1
- package/dist/styles/contrast-fixtures.d.ts +0 -5
- package/dist/styles/contrast-fixtures.js +0 -131
- package/dist/views/payment-page/domain/payment-mappers.d.ts +0 -7
- package/dist/views/payment-page/domain/payment-mappers.js +0 -7
- package/dist/views/payment-page/domain/payment-validators.d.ts +0 -6
- package/dist/views/payment-page/domain/payment-validators.js +0 -6
- package/dist/views/payment-page/domain/recovery-payload.d.ts +0 -8
- package/dist/views/payment-page/domain/recovery-payload.js +0 -7
- package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.component.d.ts +0 -22
- package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.component.js +0 -65
- package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.d.ts +0 -8
- package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.js +0 -6
- package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.styles.d.ts +0 -2
- package/dist/views/payment-page/partials/terms-checkbox/terms-checkbox.styles.js +0 -12
- package/dist/views/payment-page/payment-page.validation-schema.d.ts +0 -28
- package/dist/views/payment-page/payment-page.validation-schema.js +0 -42
- /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
- /package/dist/{components/attraction-discovery/attraction-discovery.styles.d.ts → views/details-page/partials/location-categories/location-categories.styles.d.ts} +0 -0
- /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
|
-
|
|
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
|
-
>
|
|
215
|
-
cursor: pointer;
|
|
233
|
+
> .mobile-menu-trigger {
|
|
216
234
|
display: none;
|
|
217
235
|
|
|
218
236
|
@container navbar (max-width: 800px) {
|
|
219
|
-
display:
|
|
237
|
+
display: flex;
|
|
220
238
|
}
|
|
221
239
|
|
|
222
240
|
@media (max-width: 800px) {
|
|
223
|
-
display:
|
|
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
|
|
9
|
-
|
|
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
|
|
23
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
106
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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 (
|
|
191
|
-
|
|
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
|
-
|
|
9
|
+
private deadline;
|
|
10
|
+
private connected;
|
|
5
11
|
private timerID?;
|
|
6
12
|
private onExpire?;
|
|
7
13
|
constructor(host: ReactiveControllerHost, expirationTime?: number, onExpire?: () => void);
|
|
8
|
-
|
|
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.
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
this.
|
|
29
|
+
/** Whole seconds left, never negative. */
|
|
30
|
+
get value() {
|
|
31
|
+
return Math.max(0, Math.ceil((this.deadline - Date.now()) / 1000));
|
|
11
32
|
}
|
|
12
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
|
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,
|
|
2
|
+
import { getBookingSession, removeBookingSession, updateBookingSessionExpiration, } from "./booking-session.utils.js";
|
|
3
3
|
export const bookingSessionMiddleware = {
|
|
4
|
-
async
|
|
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
|
|
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
|
-
|
|
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,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,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
|
+
};
|