@mrfylke/contact-form 0.1.3
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/lib/ContactFormRoot.d.ts +37 -0
- package/lib/ContactFormRoot.d.ts.map +1 -0
- package/lib/ContactFormRoot.js +53 -0
- package/lib/commoneEvents.d.ts +16 -0
- package/lib/commoneEvents.d.ts.map +1 -0
- package/lib/commoneEvents.js +4 -0
- package/lib/components/button/button.d.ts +17 -0
- package/lib/components/button/button.d.ts.map +1 -0
- package/lib/components/button/button.js +15 -0
- package/lib/components/button/button.module.css +399 -0
- package/lib/components/button/index.d.ts +5 -0
- package/lib/components/button/index.d.ts.map +1 -0
- package/lib/components/button/index.js +10 -0
- package/lib/components/button/link.d.ts +27 -0
- package/lib/components/button/link.d.ts.map +1 -0
- package/lib/components/button/link.js +19 -0
- package/lib/components/button/utils.d.ts +69 -0
- package/lib/components/button/utils.d.ts.map +1 -0
- package/lib/components/button/utils.js +33 -0
- package/lib/components/checkbox/checkbox.d.ts +13 -0
- package/lib/components/checkbox/checkbox.d.ts.map +1 -0
- package/lib/components/checkbox/checkbox.js +23 -0
- package/lib/components/checkbox/checkbox.module.css +96 -0
- package/lib/components/checkbox/index.d.ts +3 -0
- package/lib/components/checkbox/index.d.ts.map +1 -0
- package/lib/components/checkbox/index.js +8 -0
- package/lib/components/error-message/error-message.d.ts +6 -0
- package/lib/components/error-message/error-message.d.ts.map +1 -0
- package/lib/components/error-message/error-message.js +13 -0
- package/lib/components/error-message/error-message.module.css +6 -0
- package/lib/components/error-message/index.d.ts +3 -0
- package/lib/components/error-message/index.d.ts.map +1 -0
- package/lib/components/error-message/index.js +8 -0
- package/lib/components/external-link-page.d.ts +14 -0
- package/lib/components/external-link-page.d.ts.map +1 -0
- package/lib/components/external-link-page.js +27 -0
- package/lib/components/external-link-page.module.css +29 -0
- package/lib/components/form/date-selector.d.ts +11 -0
- package/lib/components/form/date-selector.d.ts.map +1 -0
- package/lib/components/form/date-selector.js +21 -0
- package/lib/components/form/description-modal.d.ts +13 -0
- package/lib/components/form/description-modal.d.ts.map +1 -0
- package/lib/components/form/description-modal.js +43 -0
- package/lib/components/form/field-wrapper-with-error/index.d.ts +8 -0
- package/lib/components/form/field-wrapper-with-error/index.d.ts.map +1 -0
- package/lib/components/form/field-wrapper-with-error/index.js +12 -0
- package/lib/components/form/fieldset/fieldset.module.css +26 -0
- package/lib/components/form/fieldset/index.d.ts +8 -0
- package/lib/components/form/fieldset/index.d.ts.map +1 -0
- package/lib/components/form/fieldset/index.js +17 -0
- package/lib/components/form/file-input.d.ts +10 -0
- package/lib/components/form/file-input.d.ts.map +1 -0
- package/lib/components/form/file-input.js +68 -0
- package/lib/components/form/form-component-label/form-component-label.module.css +10 -0
- package/lib/components/form/form-component-label/index.d.ts +9 -0
- package/lib/components/form/form-component-label/index.d.ts.map +1 -0
- package/lib/components/form/form-component-label/index.js +18 -0
- package/lib/components/form/form.module.css +573 -0
- package/lib/components/form/index.d.ts +11 -0
- package/lib/components/form/index.d.ts.map +1 -0
- package/lib/components/form/index.js +28 -0
- package/lib/components/form/input.d.ts +17 -0
- package/lib/components/form/input.d.ts.map +1 -0
- package/lib/components/form/input.js +42 -0
- package/lib/components/form/radio.d.ts +7 -0
- package/lib/components/form/radio.d.ts.map +1 -0
- package/lib/components/form/radio.js +14 -0
- package/lib/components/form/searchable-select/index.d.ts +3 -0
- package/lib/components/form/searchable-select/index.d.ts.map +1 -0
- package/lib/components/form/searchable-select/index.js +11 -0
- package/lib/components/form/searchable-select/searchable-select.d.ts +18 -0
- package/lib/components/form/searchable-select/searchable-select.d.ts.map +1 -0
- package/lib/components/form/searchable-select/searchable-select.js +55 -0
- package/lib/components/form/searchable-select/utils.d.ts +5 -0
- package/lib/components/form/searchable-select/utils.d.ts.map +1 -0
- package/lib/components/form/searchable-select/utils.js +19 -0
- package/lib/components/form/select.d.ts +15 -0
- package/lib/components/form/select.d.ts.map +1 -0
- package/lib/components/form/select.js +22 -0
- package/lib/components/form/textarea.d.ts +11 -0
- package/lib/components/form/textarea.d.ts.map +1 -0
- package/lib/components/form/textarea.js +17 -0
- package/lib/components/form/time-selector.d.ts +11 -0
- package/lib/components/form/time-selector.d.ts.map +1 -0
- package/lib/components/form/time-selector.js +22 -0
- package/lib/components/icon/checkbox-icon.d.ts +14 -0
- package/lib/components/icon/checkbox-icon.d.ts.map +1 -0
- package/lib/components/icon/checkbox-icon.js +18 -0
- package/lib/components/icon/color-icon.d.ts +17 -0
- package/lib/components/icon/color-icon.d.ts.map +1 -0
- package/lib/components/icon/color-icon.js +27 -0
- package/lib/components/icon/generated-icons.d.ts +1797 -0
- package/lib/components/icon/generated-icons.d.ts.map +1 -0
- package/lib/components/icon/generated-icons.js +1782 -0
- package/lib/components/icon/icon-wrapper.d.ts +30 -0
- package/lib/components/icon/icon-wrapper.d.ts.map +1 -0
- package/lib/components/icon/icon-wrapper.js +39 -0
- package/lib/components/icon/illustration.d.ts +7 -0
- package/lib/components/icon/illustration.d.ts.map +1 -0
- package/lib/components/icon/illustration.js +25 -0
- package/lib/components/icon/image.d.ts +7 -0
- package/lib/components/icon/image.d.ts.map +1 -0
- package/lib/components/icon/image.js +26 -0
- package/lib/components/icon/index.d.ts +6 -0
- package/lib/components/icon/index.d.ts.map +1 -0
- package/lib/components/icon/index.js +20 -0
- package/lib/components/icon/mono-icon-new.d.ts +32 -0
- package/lib/components/icon/mono-icon-new.d.ts.map +1 -0
- package/lib/components/icon/mono-icon-new.js +43 -0
- package/lib/components/icon/mono-icon.d.ts +29 -0
- package/lib/components/icon/mono-icon.d.ts.map +1 -0
- package/lib/components/icon/mono-icon.js +39 -0
- package/lib/components/icon/utils.d.ts +3 -0
- package/lib/components/icon/utils.d.ts.map +1 -0
- package/lib/components/icon/utils.js +12 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +18 -0
- package/lib/components/loading/index.d.ts +15 -0
- package/lib/components/loading/index.d.ts.map +1 -0
- package/lib/components/loading/index.js +19 -0
- package/lib/components/loading/loading.module.css +17 -0
- package/lib/components/section-card/index.d.ts +2 -0
- package/lib/components/section-card/index.d.ts.map +1 -0
- package/lib/components/section-card/index.js +8 -0
- package/lib/components/section-card/section-card.d.ts +7 -0
- package/lib/components/section-card/section-card.d.ts.map +1 -0
- package/lib/components/section-card/section-card.js +14 -0
- package/lib/components/section-card/section-card.module.css +15 -0
- package/lib/components/typography/index.d.ts +19 -0
- package/lib/components/typography/index.d.ts.map +1 -0
- package/lib/components/typography/index.js +27 -0
- package/lib/components/typography/utils.d.ts +2 -0
- package/lib/components/typography/utils.d.ts.map +1 -0
- package/lib/components/typography/utils.js +4 -0
- package/lib/contact.module.css +76 -0
- package/lib/error-content/error-content.d.ts +2 -0
- package/lib/error-content/error-content.d.ts.map +1 -0
- package/lib/error-content/error-content.js +19 -0
- package/lib/error-content/error-content.module.css +11 -0
- package/lib/group-travel/index.d.ts +2 -0
- package/lib/group-travel/index.d.ts.map +1 -0
- package/lib/group-travel/index.js +15 -0
- package/lib/index.d.ts +25 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +73 -0
- package/lib/journey-info/events.d.ts +14 -0
- package/lib/journey-info/events.d.ts.map +1 -0
- package/lib/journey-info/events.js +5 -0
- package/lib/journey-info/index.d.ts +2 -0
- package/lib/journey-info/index.d.ts.map +1 -0
- package/lib/journey-info/index.js +66 -0
- package/lib/journey-info/journeyInfoStateMachine.d.ts +179 -0
- package/lib/journey-info/journeyInfoStateMachine.d.ts.map +1 -0
- package/lib/journey-info/journeyInfoStateMachine.js +160 -0
- package/lib/layouts/contact-form-container.d.ts +10 -0
- package/lib/layouts/contact-form-container.d.ts.map +1 -0
- package/lib/layouts/contact-form-container.js +12 -0
- package/lib/layouts/contact-form-footer.d.ts +5 -0
- package/lib/layouts/contact-form-footer.d.ts.map +1 -0
- package/lib/layouts/contact-form-footer.js +59 -0
- package/lib/layouts/contact-form-header.d.ts +9 -0
- package/lib/layouts/contact-form-header.d.ts.map +1 -0
- package/lib/layouts/contact-form-header.js +45 -0
- package/lib/layouts/contact-page-layout.d.ts +24 -0
- package/lib/layouts/contact-page-layout.d.ts.map +1 -0
- package/lib/layouts/contact-page-layout.js +104 -0
- package/lib/layouts/container.module.css +15 -0
- package/lib/layouts/footer.module.css +109 -0
- package/lib/layouts/header.module.css +39 -0
- package/lib/layouts/index.d.ts +3 -0
- package/lib/layouts/index.d.ts.map +1 -0
- package/lib/layouts/index.js +11 -0
- package/lib/layouts/layout.module.css +80 -0
- package/lib/lines/use-lines.d.ts +25 -0
- package/lib/lines/use-lines.d.ts.map +1 -0
- package/lib/lines/use-lines.js +77 -0
- package/lib/lost-property/index.d.ts +2 -0
- package/lib/lost-property/index.d.ts.map +1 -0
- package/lib/lost-property/index.js +11 -0
- package/lib/means-of-transport/events.d.ts +17 -0
- package/lib/means-of-transport/events.d.ts.map +1 -0
- package/lib/means-of-transport/events.js +5 -0
- package/lib/means-of-transport/forms/delayForm.d.ts +11 -0
- package/lib/means-of-transport/forms/delayForm.d.ts.map +1 -0
- package/lib/means-of-transport/forms/delayForm.js +88 -0
- package/lib/means-of-transport/forms/driverForm.d.ts +11 -0
- package/lib/means-of-transport/forms/driverForm.d.ts.map +1 -0
- package/lib/means-of-transport/forms/driverForm.js +88 -0
- package/lib/means-of-transport/forms/index.d.ts +7 -0
- package/lib/means-of-transport/forms/index.d.ts.map +1 -0
- package/lib/means-of-transport/forms/index.js +18 -0
- package/lib/means-of-transport/forms/injuryForm.d.ts +11 -0
- package/lib/means-of-transport/forms/injuryForm.d.ts.map +1 -0
- package/lib/means-of-transport/forms/injuryForm.js +88 -0
- package/lib/means-of-transport/forms/serviceOfferingForm.d.ts +11 -0
- package/lib/means-of-transport/forms/serviceOfferingForm.d.ts.map +1 -0
- package/lib/means-of-transport/forms/serviceOfferingForm.js +64 -0
- package/lib/means-of-transport/forms/stopForm.d.ts +11 -0
- package/lib/means-of-transport/forms/stopForm.d.ts.map +1 -0
- package/lib/means-of-transport/forms/stopForm.js +76 -0
- package/lib/means-of-transport/forms/transportationForm.d.ts +11 -0
- package/lib/means-of-transport/forms/transportationForm.d.ts.map +1 -0
- package/lib/means-of-transport/forms/transportationForm.js +88 -0
- package/lib/means-of-transport/index.d.ts +3 -0
- package/lib/means-of-transport/index.d.ts.map +1 -0
- package/lib/means-of-transport/index.js +47 -0
- package/lib/means-of-transport/means-of-transport-form-machine.d.ts +291 -0
- package/lib/means-of-transport/means-of-transport-form-machine.d.ts.map +1 -0
- package/lib/means-of-transport/means-of-transport-form-machine.js +287 -0
- package/lib/modules/api-browser/index.d.ts +8 -0
- package/lib/modules/api-browser/index.d.ts.map +1 -0
- package/lib/modules/api-browser/index.js +54 -0
- package/lib/modules/api-server/external-client.d.ts +22 -0
- package/lib/modules/api-server/external-client.d.ts.map +1 -0
- package/lib/modules/api-server/external-client.js +86 -0
- package/lib/modules/api-server/index.d.ts +9 -0
- package/lib/modules/api-server/index.d.ts.map +1 -0
- package/lib/modules/api-server/index.js +24 -0
- package/lib/modules/api-server/requesters/graphql-requester.d.ts +6 -0
- package/lib/modules/api-server/requesters/graphql-requester.d.ts.map +1 -0
- package/lib/modules/api-server/requesters/graphql-requester.js +63 -0
- package/lib/modules/api-server/requesters/http-requester.d.ts +3 -0
- package/lib/modules/api-server/requesters/http-requester.d.ts.map +1 -0
- package/lib/modules/api-server/requesters/http-requester.js +110 -0
- package/lib/modules/api-server/requesters/types.d.ts +37 -0
- package/lib/modules/api-server/requesters/types.d.ts.map +1 -0
- package/lib/modules/api-server/requesters/types.js +34 -0
- package/lib/modules/api-server/requesters/utils.d.ts +17 -0
- package/lib/modules/api-server/requesters/utils.d.ts.map +1 -0
- package/lib/modules/api-server/requesters/utils.js +75 -0
- package/lib/modules/config/context.d.ts +54 -0
- package/lib/modules/config/context.d.ts.map +1 -0
- package/lib/modules/config/context.js +112 -0
- package/lib/modules/config/index.d.ts +4 -0
- package/lib/modules/config/index.d.ts.map +1 -0
- package/lib/modules/config/index.js +19 -0
- package/lib/modules/config/theme-adapter.d.ts +20 -0
- package/lib/modules/config/theme-adapter.d.ts.map +1 -0
- package/lib/modules/config/theme-adapter.js +56 -0
- package/lib/modules/config/types.d.ts +348 -0
- package/lib/modules/config/types.d.ts.map +1 -0
- package/lib/modules/config/types.js +6 -0
- package/lib/modules/cookies/constants.d.ts +4 -0
- package/lib/modules/cookies/constants.d.ts.map +1 -0
- package/lib/modules/cookies/constants.js +6 -0
- package/lib/modules/cookies/cookies-context.d.ts +17 -0
- package/lib/modules/cookies/cookies-context.d.ts.map +1 -0
- package/lib/modules/cookies/cookies-context.js +61 -0
- package/lib/modules/cookies/index.d.ts +15 -0
- package/lib/modules/cookies/index.d.ts.map +1 -0
- package/lib/modules/cookies/index.js +22 -0
- package/lib/modules/firebase/analytics.d.ts +3 -0
- package/lib/modules/firebase/analytics.d.ts.map +1 -0
- package/lib/modules/firebase/analytics.js +40 -0
- package/lib/modules/firebase/firebase.d.ts +4 -0
- package/lib/modules/firebase/firebase.d.ts.map +1 -0
- package/lib/modules/firebase/firebase.js +19 -0
- package/lib/modules/firebase/index.d.ts +5 -0
- package/lib/modules/firebase/index.d.ts.map +1 -0
- package/lib/modules/firebase/index.js +25 -0
- package/lib/modules/firebase/preassigned-fare-products.d.ts +8 -0
- package/lib/modules/firebase/preassigned-fare-products.d.ts.map +1 -0
- package/lib/modules/firebase/preassigned-fare-products.js +35 -0
- package/lib/modules/firebase/tariff-zones.d.ts +17 -0
- package/lib/modules/firebase/tariff-zones.d.ts.map +1 -0
- package/lib/modules/firebase/tariff-zones.js +32 -0
- package/lib/modules/firebase/transport-mode-filter.d.ts +27 -0
- package/lib/modules/firebase/transport-mode-filter.d.ts.map +1 -0
- package/lib/modules/firebase/transport-mode-filter.js +27 -0
- package/lib/modules/firebase/types.d.ts +19 -0
- package/lib/modules/firebase/types.d.ts.map +1 -0
- package/lib/modules/firebase/types.js +15 -0
- package/lib/modules/graphql-types/index.d.ts +1998 -0
- package/lib/modules/graphql-types/index.d.ts.map +1 -0
- package/lib/modules/graphql-types/index.js +442 -0
- package/lib/modules/graphql-types/journeyplanner-types_v3.generated.d.ts +2419 -0
- package/lib/modules/graphql-types/journeyplanner-types_v3.generated.d.ts.map +1 -0
- package/lib/modules/graphql-types/journeyplanner-types_v3.generated.js +524 -0
- package/lib/modules/logging/index.d.ts +6 -0
- package/lib/modules/logging/index.d.ts.map +1 -0
- package/lib/modules/logging/index.js +13 -0
- package/lib/modules/logging/log-api-response.d.ts +15 -0
- package/lib/modules/logging/log-api-response.d.ts.map +1 -0
- package/lib/modules/logging/log-api-response.js +52 -0
- package/lib/modules/logging/log-page-access.d.ts +20 -0
- package/lib/modules/logging/log-page-access.d.ts.map +1 -0
- package/lib/modules/logging/log-page-access.js +60 -0
- package/lib/modules/logging/logger.d.ts +3 -0
- package/lib/modules/logging/logger.d.ts.map +1 -0
- package/lib/modules/logging/logger.js +32 -0
- package/lib/modules/logging/timer.d.ts +6 -0
- package/lib/modules/logging/timer.d.ts.map +1 -0
- package/lib/modules/logging/timer.js +13 -0
- package/lib/modules/logging/with-access-logging.d.ts +5 -0
- package/lib/modules/logging/with-access-logging.d.ts.map +1 -0
- package/lib/modules/logging/with-access-logging.js +20 -0
- package/lib/modules/org-data/compat-layer.d.ts +8 -0
- package/lib/modules/org-data/compat-layer.d.ts.map +1 -0
- package/lib/modules/org-data/compat-layer.js +8 -0
- package/lib/modules/org-data/index.d.ts +12 -0
- package/lib/modules/org-data/index.d.ts.map +1 -0
- package/lib/modules/org-data/index.js +27 -0
- package/lib/modules/theme/index.d.ts +3 -0
- package/lib/modules/theme/index.d.ts.map +1 -0
- package/lib/modules/theme/index.js +9 -0
- package/lib/modules/theme/theme-context.d.ts +43 -0
- package/lib/modules/theme/theme-context.d.ts.map +1 -0
- package/lib/modules/theme/theme-context.js +73 -0
- package/lib/modules/transport-mode/filter/filter.d.ts +9 -0
- package/lib/modules/transport-mode/filter/filter.d.ts.map +1 -0
- package/lib/modules/transport-mode/filter/filter.js +64 -0
- package/lib/modules/transport-mode/filter/filter.module.css +98 -0
- package/lib/modules/transport-mode/filter/index.d.ts +3 -0
- package/lib/modules/transport-mode/filter/index.d.ts.map +1 -0
- package/lib/modules/transport-mode/filter/index.js +11 -0
- package/lib/modules/transport-mode/filter/types.d.ts +2 -0
- package/lib/modules/transport-mode/filter/types.d.ts.map +1 -0
- package/lib/modules/transport-mode/filter/types.js +2 -0
- package/lib/modules/transport-mode/filter/utils.d.ts +9 -0
- package/lib/modules/transport-mode/filter/utils.d.ts.map +1 -0
- package/lib/modules/transport-mode/filter/utils.js +21 -0
- package/lib/modules/transport-mode/icon/icon.module.css +33 -0
- package/lib/modules/transport-mode/icon/index.d.ts +29 -0
- package/lib/modules/transport-mode/icon/index.d.ts.map +1 -0
- package/lib/modules/transport-mode/icon/index.js +116 -0
- package/lib/modules/transport-mode/icon/transport-icon-new.d.ts +28 -0
- package/lib/modules/transport-mode/icon/transport-icon-new.d.ts.map +1 -0
- package/lib/modules/transport-mode/icon/transport-icon-new.js +114 -0
- package/lib/modules/transport-mode/index.d.ts +5 -0
- package/lib/modules/transport-mode/index.d.ts.map +1 -0
- package/lib/modules/transport-mode/index.js +29 -0
- package/lib/modules/transport-mode/types.d.ts +10 -0
- package/lib/modules/transport-mode/types.d.ts.map +1 -0
- package/lib/modules/transport-mode/types.js +141 -0
- package/lib/modules/transport-mode/utils.d.ts +9 -0
- package/lib/modules/transport-mode/utils.d.ts.map +1 -0
- package/lib/modules/transport-mode/utils.js +53 -0
- package/lib/refund/events.d.ts +32 -0
- package/lib/refund/events.d.ts.map +1 -0
- package/lib/refund/events.js +5 -0
- package/lib/refund/forms/refund-and-travel-guarantee/index.d.ts +10 -0
- package/lib/refund/forms/refund-and-travel-guarantee/index.d.ts.map +1 -0
- package/lib/refund/forms/refund-and-travel-guarantee/index.js +37 -0
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.d.ts +11 -0
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.d.ts.map +1 -0
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.js +133 -0
- package/lib/refund/forms/refund-and-travel-guarantee/refundTaxiForm.d.ts +11 -0
- package/lib/refund/forms/refund-and-travel-guarantee/refundTaxiForm.d.ts.map +1 -0
- package/lib/refund/forms/refund-and-travel-guarantee/refundTaxiForm.js +133 -0
- package/lib/refund/forms/refund-ticket/appTicketRefund.d.ts +12 -0
- package/lib/refund/forms/refund-ticket/appTicketRefund.d.ts.map +1 -0
- package/lib/refund/forms/refund-ticket/appTicketRefund.js +82 -0
- package/lib/refund/forms/refund-ticket/index.d.ts +10 -0
- package/lib/refund/forms/refund-ticket/index.d.ts.map +1 -0
- package/lib/refund/forms/refund-ticket/index.js +38 -0
- package/lib/refund/forms/refund-ticket/otherTicketRefund.d.ts +11 -0
- package/lib/refund/forms/refund-ticket/otherTicketRefund.d.ts.map +1 -0
- package/lib/refund/forms/refund-ticket/otherTicketRefund.js +109 -0
- package/lib/refund/forms/residualValueOnTravelCard/index.d.ts +2 -0
- package/lib/refund/forms/residualValueOnTravelCard/index.d.ts.map +1 -0
- package/lib/refund/forms/residualValueOnTravelCard/index.js +19 -0
- package/lib/refund/index.d.ts +3 -0
- package/lib/refund/index.d.ts.map +1 -0
- package/lib/refund/index.js +50 -0
- package/lib/refund/refundFormMachine.d.ts +406 -0
- package/lib/refund/refundFormMachine.d.ts.map +1 -0
- package/lib/refund/refundFormMachine.js +404 -0
- package/lib/server/contact/index.d.ts +11 -0
- package/lib/server/contact/index.d.ts.map +1 -0
- package/lib/server/contact/index.js +47 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/server/index.js +14 -0
- package/lib/server/journey-planner/authority.d.ts +26 -0
- package/lib/server/journey-planner/authority.d.ts.map +1 -0
- package/lib/server/journey-planner/authority.js +48 -0
- package/lib/server/journey-planner/entur-client.d.ts +7 -0
- package/lib/server/journey-planner/entur-client.d.ts.map +1 -0
- package/lib/server/journey-planner/entur-client.js +46 -0
- package/lib/server/journey-planner/index.d.ts +11 -0
- package/lib/server/journey-planner/index.d.ts.map +1 -0
- package/lib/server/journey-planner/index.js +63 -0
- package/lib/server/journey-planner/journey-gql/lines.generated.d.ts +25 -0
- package/lib/server/journey-planner/journey-gql/lines.generated.d.ts.map +1 -0
- package/lib/server/journey-planner/journey-gql/lines.generated.js +30 -0
- package/lib/server/journey-planner/validators.d.ts +25 -0
- package/lib/server/journey-planner/validators.d.ts.map +1 -0
- package/lib/server/journey-planner/validators.js +17 -0
- package/lib/server/types.d.ts +5 -0
- package/lib/server/types.d.ts.map +1 -0
- package/lib/server/types.js +2 -0
- package/lib/success-content/success-content.d.ts +2 -0
- package/lib/success-content/success-content.d.ts.map +1 -0
- package/lib/success-content/success-content.js +19 -0
- package/lib/success-content/success-content.module.css +11 -0
- package/lib/ticket-control/events.d.ts +16 -0
- package/lib/ticket-control/events.d.ts.map +1 -0
- package/lib/ticket-control/events.js +5 -0
- package/lib/ticket-control/forms/feeComplaintForm.d.ts +11 -0
- package/lib/ticket-control/forms/feeComplaintForm.d.ts.map +1 -0
- package/lib/ticket-control/forms/feeComplaintForm.js +130 -0
- package/lib/ticket-control/forms/feedbackForm.d.ts +11 -0
- package/lib/ticket-control/forms/feedbackForm.d.ts.map +1 -0
- package/lib/ticket-control/forms/feedbackForm.js +75 -0
- package/lib/ticket-control/forms/postponePayment.d.ts +11 -0
- package/lib/ticket-control/forms/postponePayment.d.ts.map +1 -0
- package/lib/ticket-control/forms/postponePayment.js +37 -0
- package/lib/ticket-control/index.d.ts +3 -0
- package/lib/ticket-control/index.d.ts.map +1 -0
- package/lib/ticket-control/index.js +53 -0
- package/lib/ticket-control/ticket-control-form-machine.d.ts +277 -0
- package/lib/ticket-control/ticket-control-form-machine.d.ts.map +1 -0
- package/lib/ticket-control/ticket-control-form-machine.js +262 -0
- package/lib/ticketing/events.d.ts +28 -0
- package/lib/ticketing/events.d.ts.map +1 -0
- package/lib/ticketing/events.js +5 -0
- package/lib/ticketing/forms/app/appAccountForm.d.ts +11 -0
- package/lib/ticketing/forms/app/appAccountForm.d.ts.map +1 -0
- package/lib/ticketing/forms/app/appAccountForm.js +51 -0
- package/lib/ticketing/forms/app/appTicketingForm.d.ts +11 -0
- package/lib/ticketing/forms/app/appTicketingForm.d.ts.map +1 -0
- package/lib/ticketing/forms/app/appTicketingForm.js +59 -0
- package/lib/ticketing/forms/app/appTravelSuggestionForm.d.ts +11 -0
- package/lib/ticketing/forms/app/appTravelSuggestionForm.d.ts.map +1 -0
- package/lib/ticketing/forms/app/appTravelSuggestionForm.js +41 -0
- package/lib/ticketing/forms/app/index.d.ts +10 -0
- package/lib/ticketing/forms/app/index.d.ts.map +1 -0
- package/lib/ticketing/forms/app/index.js +23 -0
- package/lib/ticketing/forms/priceAndTicketTypesForm.d.ts +11 -0
- package/lib/ticketing/forms/priceAndTicketTypesForm.d.ts.map +1 -0
- package/lib/ticketing/forms/priceAndTicketTypesForm.js +41 -0
- package/lib/ticketing/forms/travel-card/index.d.ts +10 -0
- package/lib/ticketing/forms/travel-card/index.d.ts.map +1 -0
- package/lib/ticketing/forms/travel-card/index.js +24 -0
- package/lib/ticketing/forms/travel-card/orderTravelCard.d.ts +3 -0
- package/lib/ticketing/forms/travel-card/orderTravelCard.d.ts.map +1 -0
- package/lib/ticketing/forms/travel-card/orderTravelCard.js +21 -0
- package/lib/ticketing/forms/travel-card/travelCardQuestionForm.d.ts +11 -0
- package/lib/ticketing/forms/travel-card/travelCardQuestionForm.d.ts.map +1 -0
- package/lib/ticketing/forms/travel-card/travelCardQuestionForm.js +52 -0
- package/lib/ticketing/forms/webshop/index.d.ts +10 -0
- package/lib/ticketing/forms/webshop/index.d.ts.map +1 -0
- package/lib/ticketing/forms/webshop/index.js +22 -0
- package/lib/ticketing/forms/webshop/webshopAccountForm.d.ts +11 -0
- package/lib/ticketing/forms/webshop/webshopAccountForm.d.ts.map +1 -0
- package/lib/ticketing/forms/webshop/webshopAccountForm.js +51 -0
- package/lib/ticketing/forms/webshop/webshopTicketingForm.d.ts +11 -0
- package/lib/ticketing/forms/webshop/webshopTicketingForm.d.ts.map +1 -0
- package/lib/ticketing/forms/webshop/webshopTicketingForm.js +58 -0
- package/lib/ticketing/index.d.ts +3 -0
- package/lib/ticketing/index.d.ts.map +1 -0
- package/lib/ticketing/index.js +52 -0
- package/lib/ticketing/ticketingStateMachine.d.ts +438 -0
- package/lib/ticketing/ticketingStateMachine.d.ts.map +1 -0
- package/lib/ticketing/ticketingStateMachine.js +435 -0
- package/lib/translations/__tests__/utils.test.d.ts +2 -0
- package/lib/translations/__tests__/utils.test.d.ts.map +1 -0
- package/lib/translations/__tests__/utils.test.js +35 -0
- package/lib/translations/common/index.d.ts +3 -0
- package/lib/translations/common/index.d.ts.map +1 -0
- package/lib/translations/common/index.js +7 -0
- package/lib/translations/common/layout.d.ts +8 -0
- package/lib/translations/common/layout.d.ts.map +1 -0
- package/lib/translations/common/layout.js +39 -0
- package/lib/translations/common/titles.d.ts +4 -0
- package/lib/translations/common/titles.d.ts.map +1 -0
- package/lib/translations/common/titles.js +25 -0
- package/lib/translations/commons.d.ts +21 -0
- package/lib/translations/commons.d.ts.map +1 -0
- package/lib/translations/commons.js +39 -0
- package/lib/translations/components/clear-button.d.ts +4 -0
- package/lib/translations/components/clear-button.d.ts.map +1 -0
- package/lib/translations/components/clear-button.js +7 -0
- package/lib/translations/components/departure-date-selector.d.ts +8 -0
- package/lib/translations/components/departure-date-selector.d.ts.map +1 -0
- package/lib/translations/components/departure-date-selector.js +11 -0
- package/lib/translations/components/departure-time.d.ts +8 -0
- package/lib/translations/components/departure-time.d.ts.map +1 -0
- package/lib/translations/components/departure-time.js +11 -0
- package/lib/translations/components/empty-search.d.ts +18 -0
- package/lib/translations/components/empty-search.d.ts.map +1 -0
- package/lib/translations/components/empty-search.js +21 -0
- package/lib/translations/components/geolocation-button.d.ts +10 -0
- package/lib/translations/components/geolocation-button.d.ts.map +1 -0
- package/lib/translations/components/geolocation-button.js +13 -0
- package/lib/translations/components/index.d.ts +14 -0
- package/lib/translations/components/index.d.ts.map +1 -0
- package/lib/translations/components/index.js +29 -0
- package/lib/translations/components/loading.d.ts +4 -0
- package/lib/translations/components/loading.d.ts.map +1 -0
- package/lib/translations/components/loading.js +7 -0
- package/lib/translations/components/map.d.ts +19 -0
- package/lib/translations/components/map.d.ts.map +1 -0
- package/lib/translations/components/map.js +22 -0
- package/lib/translations/components/search.d.ts +9 -0
- package/lib/translations/components/search.d.ts.map +1 -0
- package/lib/translations/components/search.js +12 -0
- package/lib/translations/components/swap-button.d.ts +4 -0
- package/lib/translations/components/swap-button.d.ts.map +1 -0
- package/lib/translations/components/swap-button.js +7 -0
- package/lib/translations/components/tab-link.d.ts +5 -0
- package/lib/translations/components/tab-link.d.ts.map +1 -0
- package/lib/translations/components/tab-link.js +8 -0
- package/lib/translations/components/transport-mode-filter.d.ts +6 -0
- package/lib/translations/components/transport-mode-filter.d.ts.map +1 -0
- package/lib/translations/components/transport-mode-filter.js +9 -0
- package/lib/translations/components/transport-mode.d.ts +3 -0
- package/lib/translations/components/transport-mode.d.ts.map +1 -0
- package/lib/translations/components/transport-mode.js +28 -0
- package/lib/translations/components/venue-icon.d.ts +9 -0
- package/lib/translations/components/venue-icon.d.ts.map +1 -0
- package/lib/translations/components/venue-icon.js +12 -0
- package/lib/translations/dictionary.d.ts +33 -0
- package/lib/translations/dictionary.d.ts.map +1 -0
- package/lib/translations/dictionary.js +59 -0
- package/lib/translations/index.d.ts +16 -0
- package/lib/translations/index.d.ts.map +1 -0
- package/lib/translations/index.js +65 -0
- package/lib/translations/json-to-override.d.ts +19 -0
- package/lib/translations/json-to-override.d.ts.map +1 -0
- package/lib/translations/json-to-override.js +61 -0
- package/lib/translations/language-context.d.ts +37 -0
- package/lib/translations/language-context.d.ts.map +1 -0
- package/lib/translations/language-context.js +98 -0
- package/lib/translations/load-org-translations.d.ts +19 -0
- package/lib/translations/load-org-translations.d.ts.map +1 -0
- package/lib/translations/load-org-translations.js +23 -0
- package/lib/translations/merge-overrides.d.ts +28 -0
- package/lib/translations/merge-overrides.d.ts.map +1 -0
- package/lib/translations/merge-overrides.js +126 -0
- package/lib/translations/modules/index.d.ts +4 -0
- package/lib/translations/modules/index.d.ts.map +1 -0
- package/lib/translations/modules/index.js +9 -0
- package/lib/translations/modules/layout.d.ts +73 -0
- package/lib/translations/modules/layout.d.ts.map +1 -0
- package/lib/translations/modules/layout.js +106 -0
- package/lib/translations/modules/search-time.d.ts +8 -0
- package/lib/translations/modules/search-time.d.ts.map +1 -0
- package/lib/translations/modules/search-time.js +11 -0
- package/lib/translations/modules/situation.d.ts +8 -0
- package/lib/translations/modules/situation.d.ts.map +1 -0
- package/lib/translations/modules/situation.js +11 -0
- package/lib/translations/pages/assistant.d.ts +2 -0
- package/lib/translations/pages/assistant.d.ts.map +1 -0
- package/lib/translations/pages/assistant.js +303 -0
- package/lib/translations/pages/contact.d.ts +589 -0
- package/lib/translations/pages/contact.d.ts.map +1 -0
- package/lib/translations/pages/contact.js +679 -0
- package/lib/translations/pages/departures.d.ts +64 -0
- package/lib/translations/pages/departures.d.ts.map +1 -0
- package/lib/translations/pages/departures.js +75 -0
- package/lib/translations/pages/error.d.ts +8 -0
- package/lib/translations/pages/error.d.ts.map +1 -0
- package/lib/translations/pages/error.js +11 -0
- package/lib/translations/pages/index.d.ts +4 -0
- package/lib/translations/pages/index.d.ts.map +1 -0
- package/lib/translations/pages/index.js +9 -0
- package/lib/translations/server/endpoints.d.ts +67 -0
- package/lib/translations/server/endpoints.d.ts.map +1 -0
- package/lib/translations/server/endpoints.js +146 -0
- package/lib/translations/server/index.d.ts +2 -0
- package/lib/translations/server/index.d.ts.map +1 -0
- package/lib/translations/server/index.js +5 -0
- package/lib/translations/translations-context.d.ts +10 -0
- package/lib/translations/translations-context.d.ts.map +1 -0
- package/lib/translations/translations-context.js +20 -0
- package/lib/translations/types.d.ts +41 -0
- package/lib/translations/types.d.ts.map +1 -0
- package/lib/translations/types.js +24 -0
- package/lib/translations/utils.d.ts +16 -0
- package/lib/translations/utils.d.ts.map +1 -0
- package/lib/translations/utils.js +56 -0
- package/lib/types/submit-payloads.d.ts +119 -0
- package/lib/types/submit-payloads.d.ts.map +1 -0
- package/lib/types/submit-payloads.js +7 -0
- package/lib/types.d.ts +20 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +12 -0
- package/lib/utils/color.d.ts +2 -0
- package/lib/utils/color.d.ts.map +1 -0
- package/lib/utils/color.js +50 -0
- package/lib/utils/css.d.ts +3 -0
- package/lib/utils/css.d.ts.map +1 -0
- package/lib/utils/css.js +15 -0
- package/lib/utils/date.d.ts +4 -0
- package/lib/utils/date.d.ts.map +1 -0
- package/lib/utils/date.js +21 -0
- package/lib/utils/enum-from-string.d.ts +4 -0
- package/lib/utils/enum-from-string.d.ts.map +1 -0
- package/lib/utils/enum-from-string.js +9 -0
- package/lib/utils/env.d.ts +10 -0
- package/lib/utils/env.d.ts.map +1 -0
- package/lib/utils/env.js +49 -0
- package/lib/utils/only-uniques.d.ts +3 -0
- package/lib/utils/only-uniques.d.ts.map +1 -0
- package/lib/utils/only-uniques.js +7 -0
- package/lib/utils/org-theme-definitions.d.ts +5 -0
- package/lib/utils/org-theme-definitions.d.ts.map +1 -0
- package/lib/utils/org-theme-definitions.js +13 -0
- package/lib/utils/presence.d.ts +2 -0
- package/lib/utils/presence.d.ts.map +1 -0
- package/lib/utils/presence.js +5 -0
- package/lib/utils/reference-data.d.ts +15 -0
- package/lib/utils/reference-data.d.ts.map +1 -0
- package/lib/utils/reference-data.js +15 -0
- package/lib/utils/use-client-width.d.ts +2 -0
- package/lib/utils/use-client-width.d.ts.map +1 -0
- package/lib/utils/use-client-width.js +18 -0
- package/lib/utils/use-debounce.d.ts +3 -0
- package/lib/utils/use-debounce.d.ts.map +1 -0
- package/lib/utils/use-debounce.js +14 -0
- package/lib/utils/use-interval.d.ts +2 -0
- package/lib/utils/use-interval.d.ts.map +1 -0
- package/lib/utils/use-interval.js +22 -0
- package/lib/utils/use-localstorage.d.ts +2 -0
- package/lib/utils/use-localstorage.d.ts.map +1 -0
- package/lib/utils/use-localstorage.js +40 -0
- package/lib/utils/use-now.d.ts +2 -0
- package/lib/utils/use-now.d.ts.map +1 -0
- package/lib/utils/use-now.js +13 -0
- package/lib/utils/user-media-query.d.ts +2 -0
- package/lib/utils/user-media-query.d.ts.map +1 -0
- package/lib/utils/user-media-query.js +36 -0
- package/lib/utils.d.ts +19 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +126 -0
- package/lib/validation/commonInputValidator.d.ts +7 -0
- package/lib/validation/commonInputValidator.d.ts.map +1 -0
- package/lib/validation/commonInputValidator.js +28 -0
- package/lib/validation/index.d.ts +2 -0
- package/lib/validation/index.d.ts.map +1 -0
- package/lib/validation/index.js +8 -0
- package/lib/validation/validationRules.d.ts +11 -0
- package/lib/validation/validationRules.d.ts.map +1 -0
- package/lib/validation/validationRules.js +372 -0
- package/package.json +99 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.meansOfTransportFormMachine = exports.FormType = void 0;
|
|
4
|
+
exports.createMeansOfTransportFormMachine = createMeansOfTransportFormMachine;
|
|
5
|
+
const xstate_1 = require("xstate");
|
|
6
|
+
const validation_1 = require("../validation");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const events_1 = require("./events");
|
|
9
|
+
var FormType;
|
|
10
|
+
(function (FormType) {
|
|
11
|
+
FormType["Driver"] = "driver";
|
|
12
|
+
FormType["Transportation"] = "transportation";
|
|
13
|
+
FormType["Delay"] = "delay";
|
|
14
|
+
FormType["Stop"] = "stop";
|
|
15
|
+
FormType["ServiceOffering"] = "serviceOffering";
|
|
16
|
+
FormType["Injury"] = "injury";
|
|
17
|
+
})(FormType || (exports.FormType = FormType = {}));
|
|
18
|
+
const setInputsToValidate = (context) => {
|
|
19
|
+
const { formType, transportMode, line, fromStop, toStop, stop, date, plannedDepartureTime, feedback, firstName, lastName, email, isResponseWanted, } = context;
|
|
20
|
+
switch (formType) {
|
|
21
|
+
case FormType.Driver:
|
|
22
|
+
return {
|
|
23
|
+
transportMode,
|
|
24
|
+
line,
|
|
25
|
+
fromStop,
|
|
26
|
+
toStop,
|
|
27
|
+
date,
|
|
28
|
+
plannedDepartureTime,
|
|
29
|
+
feedback,
|
|
30
|
+
isResponseWanted,
|
|
31
|
+
...(isResponseWanted && { firstName, lastName, email }),
|
|
32
|
+
};
|
|
33
|
+
case FormType.Transportation:
|
|
34
|
+
return {
|
|
35
|
+
transportMode,
|
|
36
|
+
line,
|
|
37
|
+
fromStop,
|
|
38
|
+
toStop,
|
|
39
|
+
date,
|
|
40
|
+
plannedDepartureTime,
|
|
41
|
+
feedback,
|
|
42
|
+
isResponseWanted,
|
|
43
|
+
...(isResponseWanted && { firstName, lastName, email }),
|
|
44
|
+
};
|
|
45
|
+
case FormType.Delay:
|
|
46
|
+
return {
|
|
47
|
+
transportMode,
|
|
48
|
+
line,
|
|
49
|
+
fromStop,
|
|
50
|
+
toStop,
|
|
51
|
+
date,
|
|
52
|
+
plannedDepartureTime,
|
|
53
|
+
feedback,
|
|
54
|
+
isResponseWanted,
|
|
55
|
+
...(isResponseWanted && { firstName, lastName, email }),
|
|
56
|
+
};
|
|
57
|
+
case FormType.Stop:
|
|
58
|
+
return {
|
|
59
|
+
transportMode,
|
|
60
|
+
line,
|
|
61
|
+
stop,
|
|
62
|
+
date,
|
|
63
|
+
feedback,
|
|
64
|
+
isResponseWanted,
|
|
65
|
+
...(isResponseWanted && { firstName, lastName, email }),
|
|
66
|
+
};
|
|
67
|
+
case FormType.ServiceOffering:
|
|
68
|
+
return {
|
|
69
|
+
transportMode,
|
|
70
|
+
line,
|
|
71
|
+
feedback,
|
|
72
|
+
isResponseWanted,
|
|
73
|
+
...(isResponseWanted && { firstName, lastName, email }),
|
|
74
|
+
};
|
|
75
|
+
case FormType.Injury:
|
|
76
|
+
return {
|
|
77
|
+
transportMode,
|
|
78
|
+
line,
|
|
79
|
+
fromStop,
|
|
80
|
+
toStop,
|
|
81
|
+
date,
|
|
82
|
+
plannedDepartureTime,
|
|
83
|
+
feedback,
|
|
84
|
+
isResponseWanted,
|
|
85
|
+
...(isResponseWanted && { firstName, lastName, email }),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
function createMeansOfTransportFormMachine(onSubmit, paths) {
|
|
90
|
+
const successPath = paths?.successPath ?? '/contact/success';
|
|
91
|
+
const errorPath = paths?.errorPath ?? '/contact/error';
|
|
92
|
+
return (0, xstate_1.setup)({
|
|
93
|
+
types: {
|
|
94
|
+
context: {},
|
|
95
|
+
events: events_1.meansOfTransportFormEvents,
|
|
96
|
+
},
|
|
97
|
+
guards: {
|
|
98
|
+
isFormValid: ({ context }) => {
|
|
99
|
+
const inputsToValidate = setInputsToValidate(context);
|
|
100
|
+
const errors = (0, validation_1.commonInputValidator)(inputsToValidate);
|
|
101
|
+
return Object.keys(errors).length === 0;
|
|
102
|
+
},
|
|
103
|
+
isDriverForm: ({ event }) => event.type === 'SELECT_FORM_TYPE' && event.formType === FormType.Driver,
|
|
104
|
+
isTransportationForm: ({ event }) => event.type === 'SELECT_FORM_TYPE' &&
|
|
105
|
+
event.formType === FormType.Transportation,
|
|
106
|
+
isDelayForm: ({ event }) => event.type === 'SELECT_FORM_TYPE' && event.formType === FormType.Delay,
|
|
107
|
+
isStopForm: ({ event }) => event.type === 'SELECT_FORM_TYPE' && event.formType === FormType.Stop,
|
|
108
|
+
isServiceOfferingForm: ({ event }) => event.type === 'SELECT_FORM_TYPE' &&
|
|
109
|
+
event.formType === FormType.ServiceOffering,
|
|
110
|
+
isInjuryForm: ({ event }) => event.type === 'SELECT_FORM_TYPE' && event.formType === FormType.Injury,
|
|
111
|
+
},
|
|
112
|
+
actions: {
|
|
113
|
+
clearValidationErrors: (0, xstate_1.assign)({ errorMessages: {} }),
|
|
114
|
+
setValidationErrors: (0, xstate_1.assign)(({ context, event }) => {
|
|
115
|
+
if (event.type === 'SUBMIT') {
|
|
116
|
+
const inputsToValidate = setInputsToValidate(context);
|
|
117
|
+
const errors = (0, validation_1.commonInputValidator)(inputsToValidate);
|
|
118
|
+
return {
|
|
119
|
+
firstErrorMessage: (0, utils_1.findFirstErrorMessage)(event.orderedFormFieldNames, errors),
|
|
120
|
+
errorMessages: { ...errors },
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return context;
|
|
124
|
+
}),
|
|
125
|
+
scrollToFirstErrorMessage: (0, xstate_1.assign)(({ context }) => {
|
|
126
|
+
(0, utils_1.scrollToFirstErrorMessage)(context.firstErrorMessage);
|
|
127
|
+
return context;
|
|
128
|
+
}),
|
|
129
|
+
setSubmissionError: (0, xstate_1.assign)({
|
|
130
|
+
hasSubmissionError: () => true,
|
|
131
|
+
}),
|
|
132
|
+
clearSubmissionError: (0, xstate_1.assign)({
|
|
133
|
+
hasSubmissionError: () => undefined,
|
|
134
|
+
}),
|
|
135
|
+
onInputChange: (0, xstate_1.assign)(({ context, event }) => {
|
|
136
|
+
if (event.type === 'ON_INPUT_CHANGE') {
|
|
137
|
+
const { inputName, value } = event;
|
|
138
|
+
context.errorMessages[inputName] = [];
|
|
139
|
+
return { ...context, [inputName]: value, hasSubmissionError: undefined };
|
|
140
|
+
}
|
|
141
|
+
return context;
|
|
142
|
+
}),
|
|
143
|
+
onTransportModeChange: (0, xstate_1.assign)(({ context, event }) => {
|
|
144
|
+
if (event.type === 'ON_TRANSPORTMODE_CHANGE')
|
|
145
|
+
return (0, utils_1.setTransportModeAndResetLineAndStops)(context, event.value);
|
|
146
|
+
return context;
|
|
147
|
+
}),
|
|
148
|
+
onLineChange: (0, xstate_1.assign)(({ context, event }) => {
|
|
149
|
+
if (event.type === 'ON_LINE_CHANGE')
|
|
150
|
+
return (0, utils_1.setLineAndResetStops)(context, event.value);
|
|
151
|
+
return context;
|
|
152
|
+
}),
|
|
153
|
+
navigateToErrorPage: () => {
|
|
154
|
+
window.location.href = errorPath;
|
|
155
|
+
},
|
|
156
|
+
navigateToSuccessPage: () => {
|
|
157
|
+
window.location.href = successPath;
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
actors: {
|
|
161
|
+
submit: (0, xstate_1.fromPromise)(async ({ input }) => {
|
|
162
|
+
const base64EncodedAttachments = await (0, utils_1.convertFilesToBase64)(input.attachments || []);
|
|
163
|
+
const state = {
|
|
164
|
+
...input,
|
|
165
|
+
attachments: base64EncodedAttachments,
|
|
166
|
+
};
|
|
167
|
+
const response = await onSubmit('meansOfTransport', state);
|
|
168
|
+
if (!response.ok)
|
|
169
|
+
throw new Error('Failed to call API');
|
|
170
|
+
return response.ok;
|
|
171
|
+
}),
|
|
172
|
+
},
|
|
173
|
+
}).createMachine({
|
|
174
|
+
/** @xstate-layout N4IgpgJg5mDOIC5QAoC2BDAxgCwJYDswBKAOlwgBswBiAZQFUAhAWQEkAVAbQAYBdRUAAcA9rFwAXXMPwCQAD0QBGAGzcSAZgCsATnXLlAJi2rN6gDQgAnkoDsmktxsAObstN7FN5eoC+Pi2hYeISk5FTU7ADyAOLRADIAojz8SCAiYpLSsgoIACyKJNpFxSUlFtYIRvZO6rUqBg3c3Fp+ARg4BMRklDTsAIIAGqzJsukSUjKpOSpqWrr6VSbmVojqueoaBk6K3AbOqjYGyq0ggR0hJJDj+FB0TGxcfKOi41lTiJqaBdyKmoaKTmcTkB2nKtnsjhcblqyk83hOZ2CXSukhudAS7AA+uwAEp9ABytAACpEcVjmJEACJJJ6pMaZSagHJ2NSKXKudnqGw7TSAsGVdTaEhOYpOTQ2ZqmZS5BHtJGkCjCdAQAi3CDSMBkfAAN2EAGtNYjOgqlSqbggCLrMOgGckRnSXgzsh8vg5fv9AcCQfztiRcsVnHpuO4bLKgsaSIrlarqGAAE5x4RxkiCCg2gBmSdQJCNFyjZqgFp1wmttr49qEjomzoQn2+7oMAKB3pWlQM9nF20cn20nj8-hA+GEEDgslzxGeGWr7wQAFplA4mkvl8ubPz52Hzl0wmBJ69GfIPkLcgZtMpudovmze6DW7UbH7FGzT9wnA12TKB+PSCjVXunTO2wPq47anmK3DaGKuT8msBS5M4EFit4Ng2OoBifm04Z5qaf4OlObxMqsmi5H6TjrGRhwoV4wb8r8BgOAh5FNCo56bvKJCwAArpgmBwPAeH7jWQEOIYmhgZoiHEbRzQkKY2jBl83C5GKnihv2QA */
|
|
175
|
+
initial: 'editing',
|
|
176
|
+
context: { isResponseWanted: undefined, errorMessages: {} },
|
|
177
|
+
on: {
|
|
178
|
+
ON_INPUT_CHANGE: { actions: 'onInputChange' },
|
|
179
|
+
SELECT_FORM_TYPE: { target: '#formTypeHandler' },
|
|
180
|
+
ON_TRANSPORTMODE_CHANGE: { actions: 'onTransportModeChange' },
|
|
181
|
+
ON_LINE_CHANGE: { actions: 'onLineChange' },
|
|
182
|
+
SUBMIT: { target: '#validating' },
|
|
183
|
+
},
|
|
184
|
+
states: {
|
|
185
|
+
formTypeHandler: {
|
|
186
|
+
id: 'formTypeHandler',
|
|
187
|
+
always: [
|
|
188
|
+
{ guard: 'isDriverForm', target: `#${FormType.Driver}` },
|
|
189
|
+
{
|
|
190
|
+
guard: 'isTransportationForm',
|
|
191
|
+
target: `#${FormType.Transportation}`,
|
|
192
|
+
},
|
|
193
|
+
{ guard: 'isDelayForm', target: `#${FormType.Delay}` },
|
|
194
|
+
{ guard: 'isStopForm', target: `#${FormType.Stop}` },
|
|
195
|
+
{
|
|
196
|
+
guard: 'isServiceOfferingForm',
|
|
197
|
+
target: `#${FormType.ServiceOffering}`,
|
|
198
|
+
},
|
|
199
|
+
{ guard: 'isInjuryForm', target: `#${FormType.Injury}` },
|
|
200
|
+
],
|
|
201
|
+
},
|
|
202
|
+
editing: {
|
|
203
|
+
initial: 'selectFormType',
|
|
204
|
+
states: {
|
|
205
|
+
selectFormType: {},
|
|
206
|
+
driver: {
|
|
207
|
+
id: 'driver',
|
|
208
|
+
entry: (0, xstate_1.assign)({ formType: () => FormType.Driver }),
|
|
209
|
+
exit: 'clearValidationErrors',
|
|
210
|
+
},
|
|
211
|
+
transportation: {
|
|
212
|
+
id: 'transportation',
|
|
213
|
+
entry: (0, xstate_1.assign)({ formType: () => FormType.Transportation }),
|
|
214
|
+
exit: 'clearValidationErrors',
|
|
215
|
+
},
|
|
216
|
+
delay: {
|
|
217
|
+
id: 'delay',
|
|
218
|
+
entry: (0, xstate_1.assign)({ formType: () => FormType.Delay }),
|
|
219
|
+
exit: 'clearValidationErrors',
|
|
220
|
+
},
|
|
221
|
+
stop: {
|
|
222
|
+
id: 'stop',
|
|
223
|
+
entry: (0, xstate_1.assign)({ formType: () => FormType.Stop }),
|
|
224
|
+
exit: 'clearValidationErrors',
|
|
225
|
+
},
|
|
226
|
+
serviceOffering: {
|
|
227
|
+
id: 'serviceOffering',
|
|
228
|
+
entry: (0, xstate_1.assign)({ formType: () => FormType.ServiceOffering }),
|
|
229
|
+
exit: 'clearValidationErrors',
|
|
230
|
+
},
|
|
231
|
+
injury: {
|
|
232
|
+
id: 'injury',
|
|
233
|
+
entry: (0, xstate_1.assign)({ formType: () => FormType.Injury }),
|
|
234
|
+
exit: 'clearValidationErrors',
|
|
235
|
+
},
|
|
236
|
+
history: { type: 'history', history: 'deep' },
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
validating: {
|
|
240
|
+
id: 'validating',
|
|
241
|
+
always: [
|
|
242
|
+
{ guard: 'isFormValid', target: '#submitting' },
|
|
243
|
+
{
|
|
244
|
+
actions: ['setValidationErrors', 'scrollToFirstErrorMessage'],
|
|
245
|
+
target: 'editing.history',
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
submitting: {
|
|
250
|
+
id: 'submitting',
|
|
251
|
+
invoke: {
|
|
252
|
+
src: 'submit',
|
|
253
|
+
input: ({ context }) => {
|
|
254
|
+
return {
|
|
255
|
+
formType: context.formType,
|
|
256
|
+
transportMode: context.transportMode,
|
|
257
|
+
line: (0, utils_1.getLineName)(context.line),
|
|
258
|
+
fromStop: context.fromStop?.name,
|
|
259
|
+
toStop: context.toStop?.name,
|
|
260
|
+
stop: context.stop?.name,
|
|
261
|
+
date: context.date,
|
|
262
|
+
departureTime: context.plannedDepartureTime,
|
|
263
|
+
feedback: context.feedback,
|
|
264
|
+
firstName: context.firstName,
|
|
265
|
+
lastName: context.lastName,
|
|
266
|
+
email: context.email,
|
|
267
|
+
isResponseWanted: context.isResponseWanted,
|
|
268
|
+
attachments: context.attachments,
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
onDone: { target: 'success' },
|
|
272
|
+
onError: {
|
|
273
|
+
target: 'editing.history',
|
|
274
|
+
actions: 'setSubmissionError',
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
success: { entry: 'navigateToSuccessPage', type: 'final' },
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
exports.meansOfTransportFormMachine = createMeansOfTransportFormMachine(async (data) => {
|
|
283
|
+
return fetch('/api/contact/means-of-transport', {
|
|
284
|
+
method: 'POST',
|
|
285
|
+
body: JSON.stringify(data),
|
|
286
|
+
});
|
|
287
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TranslatedString } from '../../translations';
|
|
2
|
+
export declare const swrFetcher: (url: string) => Promise<any>;
|
|
3
|
+
export declare class ClientTranslatedError extends Error {
|
|
4
|
+
translatedString: TranslatedString;
|
|
5
|
+
statusCode: number;
|
|
6
|
+
constructor(translatedString: TranslatedString, statusCode: number);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/api-browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEhE,eAAO,MAAM,UAAU,GAAU,KAAK,MAAM,iBAG3C,CAAC;AAmBF,qBAAa,qBAAsB,SAAQ,KAAK;IAC5C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;gBAEP,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM;CAMrE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientTranslatedError = exports.swrFetcher = void 0;
|
|
4
|
+
const translations_1 = require("../../translations");
|
|
5
|
+
const swrFetcher = async (url) => {
|
|
6
|
+
const res = await fetch(url);
|
|
7
|
+
return fetchErrorHandler(res);
|
|
8
|
+
};
|
|
9
|
+
exports.swrFetcher = swrFetcher;
|
|
10
|
+
async function fetchErrorHandler(res) {
|
|
11
|
+
if (!res.ok) {
|
|
12
|
+
const data = await responseToDataResponse(res);
|
|
13
|
+
const error = new ClientTranslatedError(data.translatedText, res.status);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
return (await res.json());
|
|
17
|
+
}
|
|
18
|
+
function isMessagedResponse(res) {
|
|
19
|
+
return 'message' in res;
|
|
20
|
+
}
|
|
21
|
+
class ClientTranslatedError extends Error {
|
|
22
|
+
constructor(translatedString, statusCode) {
|
|
23
|
+
super();
|
|
24
|
+
this.translatedString = translatedString;
|
|
25
|
+
this.message = translatedString['en-US'];
|
|
26
|
+
this.statusCode = statusCode;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.ClientTranslatedError = ClientTranslatedError;
|
|
30
|
+
async function responseToDataResponse(result) {
|
|
31
|
+
if (result.headers.get('Content-Type')?.includes('application/json')) {
|
|
32
|
+
const data = await result.json();
|
|
33
|
+
if (!isMessagedResponse(data)) {
|
|
34
|
+
return {
|
|
35
|
+
status: 500,
|
|
36
|
+
ok: false,
|
|
37
|
+
translatedText: translations_1.ServerText.Endpoints.serverError,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
status: result.status,
|
|
42
|
+
ok: result.ok,
|
|
43
|
+
translatedText: data.message,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const data = await result.text();
|
|
48
|
+
return {
|
|
49
|
+
status: result.status,
|
|
50
|
+
ok: false,
|
|
51
|
+
translatedText: translations_1.ServerText.Endpoints.serverErrorGeneric(data),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IncomingMessage } from 'http';
|
|
2
|
+
import type { GetServerSidePropsContext, GetServerSidePropsResult, NextApiRequest, NextApiResponse } from 'next';
|
|
3
|
+
import { type AllEndpoints, type ConditionalRequester } from './requesters/types';
|
|
4
|
+
import { ParsedUrlQuery } from 'node:querystring';
|
|
5
|
+
type HttpPropGetter<U extends AllEndpoints, T, P extends {} = {}, Params extends ParsedUrlQuery = ParsedUrlQuery> = (context: GetServerSidePropsContext<Params> & {
|
|
6
|
+
client: ExternalClient<U, T>;
|
|
7
|
+
}) => Promise<GetServerSidePropsResult<P>>;
|
|
8
|
+
export type ExternalClient<U extends AllEndpoints, T> = T & {
|
|
9
|
+
client: ConditionalRequester<U>;
|
|
10
|
+
};
|
|
11
|
+
export type ExternalClientFactory<U extends AllEndpoints, T> = (req?: IncomingMessage) => ExternalClient<U, T>;
|
|
12
|
+
export declare function createExternalClient<U extends AllEndpoints, T>(baseUrlType: U, apiFn: (request: ConditionalRequester<U>) => T): ExternalClientFactory<U, T>;
|
|
13
|
+
export declare function createWithExternalClientDecorator<U extends AllEndpoints, T>(clientCreate: ExternalClientFactory<U, T>): <P extends {} = {}, Params extends ParsedUrlQuery = ParsedUrlQuery>(propGetter: HttpPropGetter<U, T, P, Params>) => (ctx: GetServerSidePropsContext<Params>) => Promise<GetServerSidePropsResult<P>>;
|
|
14
|
+
export type NextApiClientHandler<U extends AllEndpoints, T, P = any> = (req: NextApiRequest, res: NextApiResponse<P>, extra: {
|
|
15
|
+
client: ExternalClient<U, T>;
|
|
16
|
+
ok: (a: P) => void;
|
|
17
|
+
}) => unknown | Promise<unknown>;
|
|
18
|
+
type EndpointMapping<U extends AllEndpoints, T, P = any> = Partial<Record<'GET' | 'POST' | 'DELETE' | 'PUT', NextApiClientHandler<U, T, P>>>;
|
|
19
|
+
type ApiHandler<U extends AllEndpoints, T, P = any> = NextApiClientHandler<U, T, P> | EndpointMapping<U, T, P>;
|
|
20
|
+
export declare function createWithExternalClientDecoratorForHttpHandlers<U extends AllEndpoints, T>(createClient: ExternalClientFactory<U, T>): <P>(handler: ApiHandler<U, T, P>, corsOrigin?: (string | RegExp)[]) => (req: NextApiRequest, res: NextApiResponse<P>) => Promise<unknown>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=external-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-client.d.ts","sourceRoot":"","sources":["../../../src/modules/api-server/external-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAC,yBAAyB,EAAE,wBAAwB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGhH,OAAO,EAAC,KAAK,YAAY,EAAE,KAAK,oBAAoB,EAAqB,MAAM,oBAAoB,CAAC;AAEpG,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAGhD,KAAK,cAAc,CACf,CAAC,SAAS,YAAY,EACtB,CAAC,EACD,CAAC,SAAS,EAAE,GAAG,EAAE,EACjB,MAAM,SAAS,cAAc,GAAG,cAAc,IAC9C,CACA,OAAO,EAAE,yBAAyB,CAAC,MAAM,CAAC,GAAG;IAAE,MAAM,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;CAAE,KAC5E,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1C,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,IAAI,CAAC,GAAG;IACxD,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,IAAI,CAC3D,GAAG,CAAC,EAAE,eAAe,KACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE1B,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EAC1D,WAAW,EAAE,CAAC,EACd,KAAK,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,GAC/C,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAkB7B;AAED,wBAAgB,iCAAiC,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EACvE,YAAY,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,IAGrC,CAAC,SAAS,EAAE,GAAG,EAAE,EACjB,MAAM,SAAS,cAAc,GAAG,cAAc,EAChD,YAAY,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAErC,KAAK,yBAAyB,CAAC,MAAM,CAAC,KACvC,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAO9C;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,CACnE,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC,EACvB,KAAK,EAAE;IACH,MAAM,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;CACtB,KACA,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC,KAAK,eAAe,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,OAAO,CAC9D,MAAM,CAAC,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAC3E,CAAC;AAEF,KAAK,UAAU,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EAAE,CAAC,GAAG,GAAG,IAC5C,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC7B,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE/B,wBAAgB,gDAAgD,CAC5D,CAAC,SAAS,YAAY,EACtB,CAAC,EACH,YAAY,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,IAChB,CAAC,EACpB,SAAS,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,MAElB,KAAK,cAAc,EAAE,KAAK,eAAe,CAAC,CAAC,CAAC,sBAiCjE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createExternalClient = createExternalClient;
|
|
7
|
+
exports.createWithExternalClientDecorator = createWithExternalClientDecorator;
|
|
8
|
+
exports.createWithExternalClientDecoratorForHttpHandlers = createWithExternalClientDecoratorForHttpHandlers;
|
|
9
|
+
const translations_1 = require("../..//translations");
|
|
10
|
+
const http2_1 = require("http2");
|
|
11
|
+
const graphql_requester_1 = require("./requesters/graphql-requester");
|
|
12
|
+
const http_requester_1 = require("./requesters/http-requester");
|
|
13
|
+
const types_1 = require("./requesters/types");
|
|
14
|
+
const utils_1 = require("./requesters/utils");
|
|
15
|
+
const cors_1 = __importDefault(require("cors"));
|
|
16
|
+
function createExternalClient(baseUrlType, apiFn) {
|
|
17
|
+
return function (req) {
|
|
18
|
+
if ((0, types_1.isGraphQlEndpoint)(baseUrlType)) {
|
|
19
|
+
let client = (0, graphql_requester_1.createGraphQlRequester)(baseUrlType, req);
|
|
20
|
+
return {
|
|
21
|
+
...apiFn(client),
|
|
22
|
+
client: client,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
let client = (0, http_requester_1.createRequester)(baseUrlType, req);
|
|
27
|
+
return {
|
|
28
|
+
...apiFn(client),
|
|
29
|
+
client: client,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function createWithExternalClientDecorator(clientCreate) {
|
|
35
|
+
return function handler(propGetter) {
|
|
36
|
+
return async function inside(ctx) {
|
|
37
|
+
return propGetter({
|
|
38
|
+
client: clientCreate(ctx.req),
|
|
39
|
+
...ctx,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function createWithExternalClientDecoratorForHttpHandlers(createClient) {
|
|
45
|
+
return function inside(handler, corsOrigin) {
|
|
46
|
+
return async (req, res) => {
|
|
47
|
+
function ok(val) {
|
|
48
|
+
res.status(200).json(val);
|
|
49
|
+
}
|
|
50
|
+
if (corsOrigin) {
|
|
51
|
+
const cors = (0, cors_1.default)({
|
|
52
|
+
methods: ['POST', 'GET', 'HEAD'],
|
|
53
|
+
origin: corsOrigin,
|
|
54
|
+
});
|
|
55
|
+
await runMiddleware(req, res, cors);
|
|
56
|
+
}
|
|
57
|
+
if (isRecordHandler(handler)) {
|
|
58
|
+
const potential = Object.entries(handler).find(([method]) => req.method === method);
|
|
59
|
+
if (potential) {
|
|
60
|
+
const [, properHandle] = potential;
|
|
61
|
+
return properHandle(req, res, { client: createClient(req), ok });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (isFunction(handler)) {
|
|
65
|
+
return handler(req, res, { client: createClient(req), ok });
|
|
66
|
+
}
|
|
67
|
+
return (0, utils_1.errorResultAsJson)(res, http2_1.constants.HTTP_STATUS_METHOD_NOT_ALLOWED, translations_1.ServerText.Endpoints.invalidMethod);
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function isRecordHandler(handlers) {
|
|
72
|
+
return Object.keys(handlers).some((m) => ['GET', 'POST', 'DELETE', 'PUT'].includes(m));
|
|
73
|
+
}
|
|
74
|
+
function runMiddleware(req, res, fn) {
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
fn(req, res, (result) => {
|
|
77
|
+
if (result instanceof Error) {
|
|
78
|
+
return reject(result);
|
|
79
|
+
}
|
|
80
|
+
return resolve(result);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function isFunction(fn) {
|
|
85
|
+
return fn && {}.toString.call(fn) === '[object Function]';
|
|
86
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HttpRequester, ApplicationError, AllEndpoints, GraphQlRequester } from './requesters/types';
|
|
2
|
+
export { genericError, tryResult, errorResultAsJson } from './requesters/utils';
|
|
3
|
+
import { ExternalClient, ExternalClientFactory } from './external-client';
|
|
4
|
+
export type { AllEndpoints, HttpRequester, ExternalClient, ExternalClientFactory, };
|
|
5
|
+
export { GraphQlRequester, ApplicationError };
|
|
6
|
+
export { createExternalClient, createWithExternalClientDecorator, createWithExternalClientDecoratorForHttpHandlers, } from './external-client';
|
|
7
|
+
export declare function composeClientFactories<U1 extends AllEndpoints, T1, U2 extends AllEndpoints, T2>(client1: ExternalClientFactory<U1, T1>, client2: ExternalClientFactory<U2, T2>): ExternalClientFactory<U1 | U2, T2 & T1>;
|
|
8
|
+
export declare function composeClientFactories<U1 extends AllEndpoints, T1, U2 extends AllEndpoints, T2, U3 extends AllEndpoints, T3>(client1: ExternalClientFactory<U1, T1>, client2: ExternalClientFactory<U2, T2>, client3: ExternalClientFactory<U3, T3>): ExternalClientFactory<U1 | U2 | U3, T3 & T2 & T1>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/api-server/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAE9E,OAAO,EAAC,cAAc,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAExE,YAAY,EACR,YAAY,EACZ,aAAa,EACb,cAAc,EACd,qBAAqB,GACxB,CAAC;AAEF,OAAO,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,CAAC;AAE5C,OAAO,EACH,oBAAoB,EACpB,iCAAiC,EACjC,gDAAgD,GACnD,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,sBAAsB,CAClC,EAAE,SAAS,YAAY,EACvB,EAAE,EACF,EAAE,SAAS,YAAY,EACvB,EAAE,EAEF,OAAO,EAAE,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,EACtC,OAAO,EAAE,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,GACvC,qBAAqB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AAE3C,wBAAgB,sBAAsB,CAClC,EAAE,SAAS,YAAY,EACvB,EAAE,EACF,EAAE,SAAS,YAAY,EACvB,EAAE,EACF,EAAE,SAAS,YAAY,EACvB,EAAE,EAEF,OAAO,EAAE,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,EACtC,OAAO,EAAE,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,EACtC,OAAO,EAAE,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,GACvC,qBAAqB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWithExternalClientDecoratorForHttpHandlers = exports.createWithExternalClientDecorator = exports.createExternalClient = exports.ApplicationError = exports.GraphQlRequester = exports.errorResultAsJson = exports.tryResult = exports.genericError = void 0;
|
|
4
|
+
exports.composeClientFactories = composeClientFactories;
|
|
5
|
+
const types_1 = require("./requesters/types");
|
|
6
|
+
Object.defineProperty(exports, "ApplicationError", { enumerable: true, get: function () { return types_1.ApplicationError; } });
|
|
7
|
+
Object.defineProperty(exports, "GraphQlRequester", { enumerable: true, get: function () { return types_1.GraphQlRequester; } });
|
|
8
|
+
var utils_1 = require("./requesters/utils");
|
|
9
|
+
Object.defineProperty(exports, "genericError", { enumerable: true, get: function () { return utils_1.genericError; } });
|
|
10
|
+
Object.defineProperty(exports, "tryResult", { enumerable: true, get: function () { return utils_1.tryResult; } });
|
|
11
|
+
Object.defineProperty(exports, "errorResultAsJson", { enumerable: true, get: function () { return utils_1.errorResultAsJson; } });
|
|
12
|
+
var external_client_1 = require("./external-client");
|
|
13
|
+
Object.defineProperty(exports, "createExternalClient", { enumerable: true, get: function () { return external_client_1.createExternalClient; } });
|
|
14
|
+
Object.defineProperty(exports, "createWithExternalClientDecorator", { enumerable: true, get: function () { return external_client_1.createWithExternalClientDecorator; } });
|
|
15
|
+
Object.defineProperty(exports, "createWithExternalClientDecoratorForHttpHandlers", { enumerable: true, get: function () { return external_client_1.createWithExternalClientDecoratorForHttpHandlers; } });
|
|
16
|
+
function composeClientFactories(client1, client2, client3) {
|
|
17
|
+
return function (req) {
|
|
18
|
+
return {
|
|
19
|
+
...client1(req),
|
|
20
|
+
...client2(req),
|
|
21
|
+
...(client3 ? client3(req) : {}),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GraphQlEndpoints, GraphQlRequester, ReqWithHeaders } from './types';
|
|
2
|
+
export declare const externalHttpUrls: {
|
|
3
|
+
readonly entur: "https://api.entur.io";
|
|
4
|
+
};
|
|
5
|
+
export declare function createGraphQlRequester<T extends GraphQlEndpoints>(baseUrlKey: T, req?: ReqWithHeaders): GraphQlRequester<T>;
|
|
6
|
+
//# sourceMappingURL=graphql-requester.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-requester.d.ts","sourceRoot":"","sources":["../../../../src/modules/api-server/requesters/graphql-requester.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AActG,eAAO,MAAM,gBAAgB;;CAEnB,CAAC;AAIX,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,gBAAgB,EAC7D,UAAU,EAAE,CAAC,EACb,GAAG,CAAC,EAAE,cAAc,GACrB,gBAAgB,CAAC,CAAC,CAAC,CA+CrB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.externalHttpUrls = void 0;
|
|
4
|
+
exports.createGraphQlRequester = createGraphQlRequester;
|
|
5
|
+
const cache_1 = require("@apollo/client/cache");
|
|
6
|
+
const core_1 = require("@apollo/client/core");
|
|
7
|
+
const error_1 = require("@apollo/client/link/error");
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
const logging_1 = require("../../logging");
|
|
10
|
+
const types_1 = require("./types");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
const defaultOptions = {
|
|
13
|
+
watchQuery: {
|
|
14
|
+
fetchPolicy: 'no-cache',
|
|
15
|
+
errorPolicy: 'ignore',
|
|
16
|
+
},
|
|
17
|
+
query: {
|
|
18
|
+
fetchPolicy: 'no-cache',
|
|
19
|
+
errorPolicy: 'all',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
exports.externalHttpUrls = {
|
|
23
|
+
entur: 'https://api.entur.io',
|
|
24
|
+
};
|
|
25
|
+
const cache = new cache_1.InMemoryCache();
|
|
26
|
+
function createGraphQlRequester(baseUrlKey, req) {
|
|
27
|
+
// Pass on from the potentially incoming request.
|
|
28
|
+
const headers = (0, utils_1.passOnHeadersFromRequest)(req, {
|
|
29
|
+
'X-Correlation-Id': (0, uuid_1.v4)(),
|
|
30
|
+
});
|
|
31
|
+
const uri = types_1.externalGraphQlEndpoints[baseUrlKey];
|
|
32
|
+
const httpLink = new core_1.HttpLink({
|
|
33
|
+
uri,
|
|
34
|
+
headers: {
|
|
35
|
+
...(0, utils_1.getEtNameHeaders)(),
|
|
36
|
+
...headers,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const errorLink = (0, error_1.onError)((error) => console.log('Apollo Error:', JSON.stringify(error)));
|
|
40
|
+
const loggingLink = new core_1.ApolloLink((operation, forward) => {
|
|
41
|
+
operation.setContext({ start: new Date() });
|
|
42
|
+
return forward(operation).map((response) => {
|
|
43
|
+
const context = operation.getContext();
|
|
44
|
+
const timer = new logging_1.Timer(operation.getContext().start);
|
|
45
|
+
(0, logging_1.logApiResponse)({
|
|
46
|
+
operationName: operation.operationName,
|
|
47
|
+
message: 'graphql call',
|
|
48
|
+
url: context.response.url,
|
|
49
|
+
statusCode: context.response.status,
|
|
50
|
+
requestHeaders: headers,
|
|
51
|
+
responseHeaders: context.response.headers,
|
|
52
|
+
duration: timer.getElapsedMs(),
|
|
53
|
+
});
|
|
54
|
+
return response;
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
const link = core_1.ApolloLink.from([loggingLink, errorLink, httpLink]);
|
|
58
|
+
return new types_1.GraphQlRequester(baseUrlKey, {
|
|
59
|
+
link,
|
|
60
|
+
cache,
|
|
61
|
+
defaultOptions,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-requester.d.ts","sourceRoot":"","sources":["../../../../src/modules/api-server/requesters/http-requester.ts"],"names":[],"mappings":"AACA,OAAO,EAGH,aAAa,EACb,aAAa,EACb,cAAc,EAEjB,MAAM,SAAS,CAAC;AAKjB,wBAAgB,eAAe,CAAC,CAAC,SAAS,aAAa,EACnD,UAAU,EAAE,CAAC,EACb,GAAG,CAAC,EAAE,cAAc,GACrB,aAAa,CAAC,CAAC,CAAC,CAuDlB"}
|