@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,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRequester = createRequester;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const translations_1 = require("../../../translations");
|
|
8
|
+
const logging_1 = require("../../logging");
|
|
9
|
+
function createRequester(baseUrlKey, req) {
|
|
10
|
+
return async function request(url, init) {
|
|
11
|
+
const baseUrl = types_1.externalHttpUrls[baseUrlKey];
|
|
12
|
+
const actualUrl = `${baseUrl}${url}`;
|
|
13
|
+
// Pass on from the potentially incoming request.
|
|
14
|
+
const headers = (0, utils_1.passOnHeadersFromRequest)(req, {
|
|
15
|
+
'X-Correlation-Id': (0, uuid_1.v4)(),
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
const timer = new logging_1.Timer();
|
|
19
|
+
const data = await fetch(actualUrl, {
|
|
20
|
+
...init,
|
|
21
|
+
headers: {
|
|
22
|
+
...init?.headers,
|
|
23
|
+
...(0, utils_1.getEtNameHeaders)(),
|
|
24
|
+
...headers,
|
|
25
|
+
Accept: 'application/json',
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
(0, logging_1.logApiResponse)({
|
|
30
|
+
message: 'http call',
|
|
31
|
+
method: init?.method,
|
|
32
|
+
url: data.url,
|
|
33
|
+
statusCode: data.status,
|
|
34
|
+
responseHeaders: data.headers,
|
|
35
|
+
requestHeaders: headers,
|
|
36
|
+
duration: timer.getElapsedMs(),
|
|
37
|
+
});
|
|
38
|
+
if (!data.ok) {
|
|
39
|
+
throw await errorFromResponse(data);
|
|
40
|
+
}
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.error(e);
|
|
45
|
+
if (e instanceof types_1.ApplicationError) {
|
|
46
|
+
throw e;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new types_1.ApplicationError(mapServerToMessage(e), 500, headers['X-Correlation-Id']);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function errorFromResponse(result) {
|
|
55
|
+
if (result.headers.get('content-type')?.includes('application/json')) {
|
|
56
|
+
const data = await result.json();
|
|
57
|
+
return new types_1.ApplicationError(mapServerToMessage(data), result.status, undefined, result);
|
|
58
|
+
}
|
|
59
|
+
else if (result.headers.get('content-type')?.includes('text/html')) {
|
|
60
|
+
return new types_1.ApplicationError(mapServerToMessage(result.statusText), result.status, undefined, result);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const data = await result.text();
|
|
64
|
+
if (result.status === 401) {
|
|
65
|
+
return new types_1.ApplicationError({
|
|
66
|
+
message: translations_1.ServerText.Endpoints.accessError,
|
|
67
|
+
}, result.status, undefined, result);
|
|
68
|
+
}
|
|
69
|
+
return new types_1.ApplicationError(mapServerToMessage(data), result.status, undefined, result);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function mapServerToMessage(e) {
|
|
73
|
+
if (typeof e === 'string') {
|
|
74
|
+
return { message: (0, translations_1.translation)(e, e, e) };
|
|
75
|
+
}
|
|
76
|
+
if (!isInternalServerError(e)) {
|
|
77
|
+
return { message: translations_1.ServerText.Endpoints.serverError };
|
|
78
|
+
}
|
|
79
|
+
if (isMessagedError(e)) {
|
|
80
|
+
return { message: (0, translations_1.translation)(e.message, e.message, e.message) };
|
|
81
|
+
}
|
|
82
|
+
const defaultError = { message: (0, translations_1.translation)(e.error, e.error, e.error) };
|
|
83
|
+
if (!isInternalServerErrorWithUpstream(e)) {
|
|
84
|
+
return defaultError;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const upstreamError = JSON.parse(e.upstreamError);
|
|
88
|
+
if (!isInternalUpstreamServerError(upstreamError)) {
|
|
89
|
+
return defaultError;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
message: (0, translations_1.translation)(upstreamError.shortNorwegian, upstreamError.shortEnglish, upstreamError.shortNorwegian),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (_err) {
|
|
96
|
+
return defaultError;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function isMessagedError(e) {
|
|
100
|
+
return 'message' in e;
|
|
101
|
+
}
|
|
102
|
+
function isInternalServerError(e) {
|
|
103
|
+
return 'error' in e;
|
|
104
|
+
}
|
|
105
|
+
function isInternalServerErrorWithUpstream(e) {
|
|
106
|
+
return 'upstreamError' in e;
|
|
107
|
+
}
|
|
108
|
+
function isInternalUpstreamServerError(e) {
|
|
109
|
+
return 'errorCode' in e && 'shortNorwegian' in e;
|
|
110
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IncomingHttpHeaders } from 'http';
|
|
2
|
+
import { NextApiResponse } from 'next';
|
|
3
|
+
import type { NormalizedCacheObject } from '@apollo/client/cache';
|
|
4
|
+
import { ApolloClient, type ApolloClientOptions } from '@apollo/client/core';
|
|
5
|
+
import { TranslatedString } from "../../../translations";
|
|
6
|
+
export declare const externalHttpUrls: {
|
|
7
|
+
readonly 'http-bff': string;
|
|
8
|
+
readonly 'http-sales': string;
|
|
9
|
+
readonly 'http-contact-api': string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export type HttpEndpoints = keyof typeof externalHttpUrls;
|
|
12
|
+
export declare const externalGraphQlEndpoints: {
|
|
13
|
+
readonly 'graphql-journeyPlanner3': `${string}/journey-planner/v3/graphql`;
|
|
14
|
+
};
|
|
15
|
+
export type GraphQlEndpoints = keyof typeof externalGraphQlEndpoints;
|
|
16
|
+
export type AllEndpoints = HttpEndpoints | GraphQlEndpoints;
|
|
17
|
+
export type ReqWithHeaders = {
|
|
18
|
+
headers: IncomingHttpHeaders;
|
|
19
|
+
};
|
|
20
|
+
export declare class GraphQlRequester<T extends GraphQlEndpoints> extends ApolloClient<NormalizedCacheObject> {
|
|
21
|
+
endpoint: T;
|
|
22
|
+
constructor(endpoint: T, options: ApolloClientOptions<NormalizedCacheObject>);
|
|
23
|
+
}
|
|
24
|
+
export type HttpRequester<T extends HttpEndpoints> = (url: `/${string}`, init?: RequestInit | undefined) => Promise<Response>;
|
|
25
|
+
export type ConditionalRequester<U extends AllEndpoints> = U extends HttpEndpoints ? HttpRequester<U> : U extends GraphQlEndpoints ? GraphQlRequester<U> : never;
|
|
26
|
+
export declare function isGraphQlEndpoint(a: any): a is GraphQlEndpoints;
|
|
27
|
+
export type ServerErrorMessage = {
|
|
28
|
+
message: TranslatedString;
|
|
29
|
+
};
|
|
30
|
+
export declare class ApplicationError extends Error {
|
|
31
|
+
data: ServerErrorMessage;
|
|
32
|
+
status: number;
|
|
33
|
+
correlationId?: string;
|
|
34
|
+
upstreamResponse?: Response | NextApiResponse<any>;
|
|
35
|
+
constructor(error: ServerErrorMessage, status?: number, correlationId?: string, upstreamResponse?: Response | NextApiResponse<any>);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/modules/api-server/requesters/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,MAAM,CAAC;AACzC,OAAO,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AAErC,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAC,YAAY,EAAE,KAAK,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEvD,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAE1D,eAAO,MAAM,wBAAwB;;CAE3B,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,wBAAwB,CAAC;AAErE,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,gBAAgB,CAAC;AAE5D,MAAM,MAAM,cAAc,GAAG;IACzB,OAAO,EAAE,mBAAmB,CAAC;CAChC,CAAC;AAEF,qBAAa,gBAAgB,CACzB,CAAC,SAAS,gBAAgB,CAC5B,SAAQ,YAAY,CAAC,qBAAqB,CAAC;IAClC,QAAQ,EAAE,CAAC,CAAC;gBAGf,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,mBAAmB,CAAC,qBAAqB,CAAC;CAK1D;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,aAAa,IAAI,CACjD,GAAG,EAAE,IAAI,MAAM,EAAE,EACjB,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,KAC7B,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,YAAY,IACnD,CAAC,SAAS,aAAa,GACjB,aAAa,CAAC,CAAC,CAAC,GAChB,CAAC,SAAS,gBAAgB,GACtB,gBAAgB,CAAC,CAAC,CAAC,GACnB,KAAK,CAAC;AAEpB,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,gBAAgB,CAE/D;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,OAAO,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,KAAK;IACvC,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;gBAG/C,KAAK,EAAE,kBAAkB,EACzB,MAAM,GAAE,MAAY,EACpB,aAAa,CAAC,EAAE,MAAM,EACtB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC;CAQzD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApplicationError = exports.GraphQlRequester = exports.externalGraphQlEndpoints = exports.externalHttpUrls = void 0;
|
|
4
|
+
exports.isGraphQlEndpoint = isGraphQlEndpoint;
|
|
5
|
+
const core_1 = require("@apollo/client/core");
|
|
6
|
+
const env_1 = require("../../../utils/env");
|
|
7
|
+
exports.externalHttpUrls = {
|
|
8
|
+
'http-bff': env_1.BFFURL,
|
|
9
|
+
'http-sales': env_1.SALESURL,
|
|
10
|
+
'http-contact-api': process.env.NEXT_PUBLIC_CONTACT_API_URL,
|
|
11
|
+
};
|
|
12
|
+
exports.externalGraphQlEndpoints = {
|
|
13
|
+
'graphql-journeyPlanner3': `${process.env.ENTUR_BASE_URL ?? 'https://api.entur.io'}/journey-planner/v3/graphql`,
|
|
14
|
+
};
|
|
15
|
+
class GraphQlRequester extends core_1.ApolloClient {
|
|
16
|
+
constructor(endpoint, options) {
|
|
17
|
+
super(options);
|
|
18
|
+
this.endpoint = endpoint;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.GraphQlRequester = GraphQlRequester;
|
|
22
|
+
function isGraphQlEndpoint(a) {
|
|
23
|
+
return a in exports.externalGraphQlEndpoints;
|
|
24
|
+
}
|
|
25
|
+
class ApplicationError extends Error {
|
|
26
|
+
constructor(error, status = 500, correlationId, upstreamResponse) {
|
|
27
|
+
super();
|
|
28
|
+
this.data = error;
|
|
29
|
+
this.status = status;
|
|
30
|
+
this.correlationId = correlationId;
|
|
31
|
+
this.upstreamResponse = upstreamResponse;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ApplicationError = ApplicationError;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { ApplicationError, ReqWithHeaders, ServerErrorMessage } from './types';
|
|
3
|
+
import { TranslatedString } from "../../../translations";
|
|
4
|
+
export declare function tryResult(req: NextApiRequest, res: NextApiResponse<any>, fn: () => Promise<void>, errorMapper?: (e: ApplicationError) => ApplicationError): Promise<void>;
|
|
5
|
+
export declare function genericError(): ApplicationError;
|
|
6
|
+
export declare function errorResultAsJson(res: NextApiResponse, code: number, text: TranslatedString | ServerErrorMessage): void;
|
|
7
|
+
export declare function getEtNameHeaders(orgName?: string): {
|
|
8
|
+
'ET-Client-Name': string;
|
|
9
|
+
};
|
|
10
|
+
declare const repassableHeaders: {
|
|
11
|
+
readonly installId: "Atb-Install-Id";
|
|
12
|
+
readonly correlationId: "X-Correlation-Id";
|
|
13
|
+
};
|
|
14
|
+
type RepassableHeaders = (typeof repassableHeaders)[keyof typeof repassableHeaders];
|
|
15
|
+
export declare function passOnHeadersFromRequest(req: ReqWithHeaders | undefined, defaults: Partial<Record<RepassableHeaders, string>>): Record<string, string> | Partial<Record<RepassableHeaders, string>>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/modules/api-server/requesters/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,eAAe,EAAC,MAAM,MAAM,CAAC;AACrD,OAAO,EAAC,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAE7E,OAAO,EAAa,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEnE,wBAAsB,SAAS,CAC3B,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,EACzB,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EACvB,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,gBAAgB,iBAc1D;AAED,wBAAgB,YAAY,qBAE3B;AAED,wBAAgB,iBAAiB,CAC7B,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,QAQ9C;AA2BD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,MAAuB;;EAIhE;AAED,QAAA,MAAM,iBAAiB;;;CAGb,CAAC;AAEX,KAAK,iBAAiB,GAClB,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE/D,wBAAgB,wBAAwB,CACpC,GAAG,EAAE,cAAc,GAAG,SAAS,EAC/B,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,uEAevD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tryResult = tryResult;
|
|
4
|
+
exports.genericError = genericError;
|
|
5
|
+
exports.errorResultAsJson = errorResultAsJson;
|
|
6
|
+
exports.getEtNameHeaders = getEtNameHeaders;
|
|
7
|
+
exports.passOnHeadersFromRequest = passOnHeadersFromRequest;
|
|
8
|
+
const types_1 = require("./types");
|
|
9
|
+
const logging_1 = require("../../logging");
|
|
10
|
+
const translations_1 = require("../../../translations");
|
|
11
|
+
async function tryResult(req, res, fn, errorMapper) {
|
|
12
|
+
try {
|
|
13
|
+
return await fn();
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
if (e instanceof types_1.ApplicationError) {
|
|
17
|
+
const properError = errorMapper?.(e) ?? e;
|
|
18
|
+
logApplicationError(properError, req, res);
|
|
19
|
+
return errorResultAsJson(res, properError.status, properError.data);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
logging_1.logger.error(e);
|
|
23
|
+
return errorResultAsJson(res, 500, translations_1.ServerText.Endpoints.serverError);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function genericError() {
|
|
28
|
+
return new types_1.ApplicationError({ message: translations_1.ServerText.Endpoints.serverError });
|
|
29
|
+
}
|
|
30
|
+
function errorResultAsJson(res, code, text) {
|
|
31
|
+
const ret = isServerErrorMessage(text)
|
|
32
|
+
? text
|
|
33
|
+
: {
|
|
34
|
+
message: text,
|
|
35
|
+
};
|
|
36
|
+
return res.status(code).json(ret);
|
|
37
|
+
}
|
|
38
|
+
function isServerErrorMessage(e) {
|
|
39
|
+
return 'message' in e;
|
|
40
|
+
}
|
|
41
|
+
function logApplicationError(e, req, res) {
|
|
42
|
+
if (process.env.NODE_ENV === 'development') {
|
|
43
|
+
console.error(e);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
logging_1.logger.error({
|
|
47
|
+
upstream: e.upstreamResponse,
|
|
48
|
+
correlationId: e.correlationId,
|
|
49
|
+
res,
|
|
50
|
+
req,
|
|
51
|
+
err: e,
|
|
52
|
+
}, e.message);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function getEtNameHeaders(orgName = 'contact-form') {
|
|
56
|
+
return {
|
|
57
|
+
'ET-Client-Name': `${orgName}-web`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const repassableHeaders = {
|
|
61
|
+
installId: 'Atb-Install-Id',
|
|
62
|
+
correlationId: 'X-Correlation-Id',
|
|
63
|
+
};
|
|
64
|
+
function passOnHeadersFromRequest(req, defaults) {
|
|
65
|
+
let headers = {};
|
|
66
|
+
if (!req) {
|
|
67
|
+
return defaults;
|
|
68
|
+
}
|
|
69
|
+
for (let headerName of Object.values(repassableHeaders)) {
|
|
70
|
+
const headerNameTyped = headerName;
|
|
71
|
+
headers[headerName] =
|
|
72
|
+
req.headers[headerName]?.toString() ?? defaults[headerNameTyped] ?? '';
|
|
73
|
+
}
|
|
74
|
+
return headers;
|
|
75
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import type { ContactFormConfig, Theme } from './types';
|
|
3
|
+
export type ContactFormConfigProviderProps = PropsWithChildren<{
|
|
4
|
+
config: ContactFormConfig;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Provider component that supplies configuration to the entire contact form.
|
|
8
|
+
* This should wrap your entire application or the part that uses the contact form.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { ContactFormConfigProvider } from '@mrfylke/contact-form';
|
|
13
|
+
* import { myTheme, myIcons } from './my-config';
|
|
14
|
+
*
|
|
15
|
+
* function App() {
|
|
16
|
+
* return (
|
|
17
|
+
* <ContactFormConfigProvider
|
|
18
|
+
* config={{
|
|
19
|
+
* theme: myTheme,
|
|
20
|
+
* icons: myIcons,
|
|
21
|
+
* api: { baseUrl: '/api', endpoints: { submitForm: '/contact' } },
|
|
22
|
+
* org: { name: 'My Company', supportEmail: 'support@example.com' }
|
|
23
|
+
* }}
|
|
24
|
+
* >
|
|
25
|
+
* <ContactForm />
|
|
26
|
+
* </ContactFormConfigProvider>
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function ContactFormConfigProvider({ config, children, }: ContactFormConfigProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* Hook to access the contact form configuration.
|
|
34
|
+
* @throws Error if used outside of ContactFormConfigProvider
|
|
35
|
+
*/
|
|
36
|
+
export declare function useContactFormConfig(): ContactFormConfig;
|
|
37
|
+
/**
|
|
38
|
+
* Hook to access the theme from configuration.
|
|
39
|
+
* Returns both light and dark theme variants.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useThemeConfig(): Theme;
|
|
42
|
+
/**
|
|
43
|
+
* Hook to access the icon set from configuration.
|
|
44
|
+
*/
|
|
45
|
+
export declare function useIconConfig(): import("./types").IconSet;
|
|
46
|
+
/**
|
|
47
|
+
* Hook to access the org configuration.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useOrgConfig(): import("./types").OrgConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Hook to access the API configuration.
|
|
52
|
+
*/
|
|
53
|
+
export declare function useApiConfig(): import("./types").ApiConfig;
|
|
54
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/modules/config/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,iBAAiB,EAAC,MAAM,OAAO,CAAC;AACnE,OAAO,KAAK,EAAC,iBAAiB,EAAE,KAAK,EAAC,MAAM,SAAS,CAAC;AAQtD,MAAM,MAAM,8BAA8B,GAAG,iBAAiB,CAAC;IAC3D,MAAM,EAAE,iBAAiB,CAAC;CAC7B,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,yBAAyB,CAAC,EACI,MAAM,EACN,QAAQ,GACX,EAAE,8BAA8B,2CAW1E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CASxD;AAED;;;GAGG;AACH,wBAAgB,cAAc,UAG7B;AA4BD;;GAEG;AACH,wBAAgB,aAAa,8BAG5B;AAED;;GAEG;AACH,wBAAgB,YAAY,gCAG3B;AAED;;GAEG;AACH,wBAAgB,YAAY,gCAG3B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContactFormConfigProvider = ContactFormConfigProvider;
|
|
4
|
+
exports.useContactFormConfig = useContactFormConfig;
|
|
5
|
+
exports.useThemeConfig = useThemeConfig;
|
|
6
|
+
exports.useIconConfig = useIconConfig;
|
|
7
|
+
exports.useOrgConfig = useOrgConfig;
|
|
8
|
+
exports.useApiConfig = useApiConfig;
|
|
9
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
/**
|
|
12
|
+
* Context for contact form configuration.
|
|
13
|
+
* This allows the entire form to access theme, icons, and other settings.
|
|
14
|
+
*/
|
|
15
|
+
const ContactFormConfigContext = (0, react_1.createContext)(null);
|
|
16
|
+
/**
|
|
17
|
+
* Provider component that supplies configuration to the entire contact form.
|
|
18
|
+
* This should wrap your entire application or the part that uses the contact form.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { ContactFormConfigProvider } from '@mrfylke/contact-form';
|
|
23
|
+
* import { myTheme, myIcons } from './my-config';
|
|
24
|
+
*
|
|
25
|
+
* function App() {
|
|
26
|
+
* return (
|
|
27
|
+
* <ContactFormConfigProvider
|
|
28
|
+
* config={{
|
|
29
|
+
* theme: myTheme,
|
|
30
|
+
* icons: myIcons,
|
|
31
|
+
* api: { baseUrl: '/api', endpoints: { submitForm: '/contact' } },
|
|
32
|
+
* org: { name: 'My Company', supportEmail: 'support@example.com' }
|
|
33
|
+
* }}
|
|
34
|
+
* >
|
|
35
|
+
* <ContactForm />
|
|
36
|
+
* </ContactFormConfigProvider>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
function ContactFormConfigProvider({ config, children, }) {
|
|
42
|
+
const mergedConfig = {
|
|
43
|
+
...config,
|
|
44
|
+
theme: mergeThemeWithOverrides(config.theme, config.themeOverrides),
|
|
45
|
+
};
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(ContactFormConfigContext.Provider, { value: mergedConfig, children: children }));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Hook to access the contact form configuration.
|
|
50
|
+
* @throws Error if used outside of ContactFormConfigProvider
|
|
51
|
+
*/
|
|
52
|
+
function useContactFormConfig() {
|
|
53
|
+
const context = (0, react_1.useContext)(ContactFormConfigContext);
|
|
54
|
+
if (!context) {
|
|
55
|
+
throw new Error('useContactFormConfig must be used within ContactFormConfigProvider. ' +
|
|
56
|
+
'Make sure to wrap your app with <ContactFormConfigProvider config={...}>');
|
|
57
|
+
}
|
|
58
|
+
return context;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Hook to access the theme from configuration.
|
|
62
|
+
* Returns both light and dark theme variants.
|
|
63
|
+
*/
|
|
64
|
+
function useThemeConfig() {
|
|
65
|
+
const { theme } = useContactFormConfig();
|
|
66
|
+
return theme;
|
|
67
|
+
}
|
|
68
|
+
function mergeThemeWithOverrides(base, overrides) {
|
|
69
|
+
if (!overrides) {
|
|
70
|
+
return base;
|
|
71
|
+
}
|
|
72
|
+
// Shallow clone so we don't mutate the incoming theme object.
|
|
73
|
+
const result = { ...base };
|
|
74
|
+
function apply(target, source) {
|
|
75
|
+
if (!source)
|
|
76
|
+
return;
|
|
77
|
+
Object.keys(source).forEach((key) => {
|
|
78
|
+
const srcVal = source[key];
|
|
79
|
+
if (srcVal && typeof srcVal === 'object' && !Array.isArray(srcVal)) {
|
|
80
|
+
const current = target[key] ?? {};
|
|
81
|
+
target[key] = { ...current };
|
|
82
|
+
apply(target[key], srcVal);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
target[key] = srcVal;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
apply(result, overrides);
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Hook to access the icon set from configuration.
|
|
94
|
+
*/
|
|
95
|
+
function useIconConfig() {
|
|
96
|
+
const { icons } = useContactFormConfig();
|
|
97
|
+
return icons;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Hook to access the org configuration.
|
|
101
|
+
*/
|
|
102
|
+
function useOrgConfig() {
|
|
103
|
+
const { org } = useContactFormConfig();
|
|
104
|
+
return org;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Hook to access the API configuration.
|
|
108
|
+
*/
|
|
109
|
+
function useApiConfig() {
|
|
110
|
+
const { api } = useContactFormConfig();
|
|
111
|
+
return api;
|
|
112
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./context"), exports);
|
|
19
|
+
__exportStar(require("./theme-adapter"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter to convert @atb-as/theme format to ContactFormConfig theme format.
|
|
3
|
+
* This helps migrate existing code to the new configuration system.
|
|
4
|
+
*/
|
|
5
|
+
import type { Theme as ContactFormTheme } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to adapt @atb-as/theme to ContactFormConfig format.
|
|
8
|
+
* Use this if you're using the @atb-as/theme package.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { createThemesFor, ThemeVariant } from '@atb-as/theme';
|
|
13
|
+
* import { adaptAtbTheme } from '@mrfylke/contact-form/lib/modules/config';
|
|
14
|
+
*
|
|
15
|
+
* const atbThemes = createThemesFor(ThemeVariant.FRAM);
|
|
16
|
+
* const contactFormTheme = adaptAtbTheme(atbThemes);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function adaptAtbTheme(atbTheme: any): ContactFormTheme;
|
|
20
|
+
//# sourceMappingURL=theme-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-adapter.d.ts","sourceRoot":"","sources":["../../../src/modules/config/theme-adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAC,KAAK,IAAI,gBAAgB,EAAc,MAAM,SAAS,CAAC;AAYpE;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,GAAG,GAAG,gBAAgB,CAK7D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Adapter to convert @atb-as/theme format to ContactFormConfig theme format.
|
|
4
|
+
* This helps migrate existing code to the new configuration system.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.adaptAtbTheme = adaptAtbTheme;
|
|
8
|
+
function adaptSpacer(spacing) {
|
|
9
|
+
if (!spacing)
|
|
10
|
+
return { small: '8px', medium: '12px', large: '20px', xLarge: '24px' };
|
|
11
|
+
return {
|
|
12
|
+
small: `${spacing.small ?? 8}px`,
|
|
13
|
+
medium: `${spacing.medium ?? 12}px`,
|
|
14
|
+
large: `${spacing.large ?? 20}px`,
|
|
15
|
+
xLarge: `${spacing.xLarge ?? 24}px`,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Helper function to adapt @atb-as/theme to ContactFormConfig format.
|
|
20
|
+
* Use this if you're using the @atb-as/theme package.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { createThemesFor, ThemeVariant } from '@atb-as/theme';
|
|
25
|
+
* import { adaptAtbTheme } from '@mrfylke/contact-form/lib/modules/config';
|
|
26
|
+
*
|
|
27
|
+
* const atbThemes = createThemesFor(ThemeVariant.FRAM);
|
|
28
|
+
* const contactFormTheme = adaptAtbTheme(atbThemes);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function adaptAtbTheme(atbTheme) {
|
|
32
|
+
return {
|
|
33
|
+
light: adaptThemeColors(atbTheme.light),
|
|
34
|
+
dark: adaptThemeColors(atbTheme.dark),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function adaptThemeColors(themeVariant) {
|
|
38
|
+
const ds = themeVariant.color.interactive;
|
|
39
|
+
// Map design-system interactive (0, 1, 2, destructive) to contact-form shape (primary, secondary, destructive).
|
|
40
|
+
// Design-system: 0 = primary, 1 = secondary, 2 = tertiary, destructive = destructive
|
|
41
|
+
return {
|
|
42
|
+
color: {
|
|
43
|
+
transport: themeVariant.color.transport,
|
|
44
|
+
status: themeVariant.color.status,
|
|
45
|
+
background: themeVariant.color.background,
|
|
46
|
+
interactive: {
|
|
47
|
+
...ds,
|
|
48
|
+
primary: ds[0] ?? ds.primary,
|
|
49
|
+
secondary: ds[1] ?? ds.secondary,
|
|
50
|
+
destructive: ds.destructive ?? ds,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
spacer: themeVariant.spacer ?? adaptSpacer(themeVariant.spacing),
|
|
54
|
+
border: themeVariant.border,
|
|
55
|
+
};
|
|
56
|
+
}
|