@mrfylke/contact-form 0.1.4 → 0.1.5
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.map +1 -1
- package/lib/ContactFormRoot.js +3 -1
- package/lib/commoneEvents.d.ts.map +1 -1
- package/lib/components/button/button.d.ts.map +1 -1
- package/lib/components/button/index.d.ts.map +1 -1
- package/lib/components/button/link.d.ts.map +1 -1
- package/lib/components/button/utils.d.ts.map +1 -1
- package/lib/components/checkbox/checkbox.d.ts.map +1 -1
- package/lib/components/checkbox/index.d.ts.map +1 -1
- package/lib/components/error-message/error-message.d.ts.map +1 -1
- package/lib/components/error-message/index.d.ts.map +1 -1
- package/lib/components/external-link-page.d.ts +1 -1
- package/lib/components/external-link-page.d.ts.map +1 -1
- package/lib/components/external-link-page.js +7 -6
- package/lib/components/form/date-selector.d.ts +1 -1
- package/lib/components/form/date-selector.d.ts.map +1 -1
- package/lib/components/form/description-modal.d.ts.map +1 -1
- package/lib/components/form/field-wrapper-with-error/index.d.ts +1 -1
- package/lib/components/form/field-wrapper-with-error/index.d.ts.map +1 -1
- package/lib/components/form/fieldset/index.d.ts.map +1 -1
- package/lib/components/form/file-input.d.ts.map +1 -1
- package/lib/components/form/file-input.js +1 -1
- package/lib/components/form/form-component-label/index.d.ts.map +1 -1
- package/lib/components/form/index.d.ts.map +1 -1
- package/lib/components/form/input.d.ts +1 -1
- package/lib/components/form/input.d.ts.map +1 -1
- package/lib/components/form/input.js +1 -1
- package/lib/components/form/radio.d.ts.map +1 -1
- package/lib/components/form/searchable-select/index.d.ts.map +1 -1
- package/lib/components/form/searchable-select/searchable-select.d.ts.map +1 -1
- package/lib/components/form/searchable-select/searchable-select.js +1 -1
- package/lib/components/form/searchable-select/utils.d.ts +1 -1
- package/lib/components/form/searchable-select/utils.d.ts.map +1 -1
- package/lib/components/form/select.d.ts.map +1 -1
- package/lib/components/form/textarea.d.ts.map +1 -1
- package/lib/components/form/time-selector.d.ts +1 -1
- package/lib/components/form/time-selector.d.ts.map +1 -1
- package/lib/components/icon/checkbox-icon.d.ts +1 -1
- package/lib/components/icon/checkbox-icon.d.ts.map +1 -1
- package/lib/components/icon/checkbox-icon.js +1 -1
- package/lib/components/icon/color-icon.d.ts.map +1 -1
- package/lib/components/icon/color-icon.js +0 -2
- package/lib/components/icon/generated-icons.d.ts +233 -233
- package/lib/components/icon/generated-icons.d.ts.map +1 -1
- package/lib/components/icon/generated-icons.js +1771 -1771
- package/lib/components/icon/icon-wrapper.d.ts +1 -1
- package/lib/components/icon/icon-wrapper.d.ts.map +1 -1
- package/lib/components/icon/illustration.d.ts.map +1 -1
- package/lib/components/icon/illustration.js +0 -2
- package/lib/components/icon/image.d.ts.map +1 -1
- package/lib/components/icon/image.js +0 -2
- package/lib/components/icon/mono-icon-new.d.ts +2 -2
- package/lib/components/icon/mono-icon-new.d.ts.map +1 -1
- package/lib/components/icon/mono-icon.d.ts +1 -1
- package/lib/components/icon/mono-icon.d.ts.map +1 -1
- package/lib/components/icon/mono-icon.js +1 -3
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/loading/index.d.ts +1 -1
- package/lib/components/loading/index.d.ts.map +1 -1
- package/lib/components/section-card/index.d.ts.map +1 -1
- package/lib/components/section-card/section-card.d.ts.map +1 -1
- package/lib/components/typography/index.d.ts +6 -5
- package/lib/components/typography/index.d.ts.map +1 -1
- package/lib/components/typography/index.js +0 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/journey-info/events.d.ts +6 -6
- package/lib/journey-info/events.d.ts.map +1 -1
- package/lib/journey-info/events.js +0 -1
- package/lib/journey-info/index.d.ts.map +1 -1
- package/lib/journey-info/index.js +4 -2
- package/lib/journey-info/journeyInfoStateMachine.d.ts.map +1 -1
- package/lib/layouts/contact-form-container.d.ts.map +1 -1
- package/lib/layouts/contact-form-footer.d.ts +1 -1
- package/lib/layouts/contact-form-footer.d.ts.map +1 -1
- package/lib/layouts/contact-form-footer.js +39 -23
- package/lib/layouts/contact-form-header.d.ts.map +1 -1
- package/lib/layouts/contact-form-header.js +12 -7
- package/lib/layouts/contact-page-layout.d.ts +2 -2
- package/lib/layouts/contact-page-layout.d.ts.map +1 -1
- package/lib/layouts/contact-page-layout.js +1 -5
- package/lib/layouts/index.d.ts.map +1 -1
- package/lib/lines/use-lines.d.ts.map +1 -1
- package/lib/means-of-transport/events.d.ts +7 -7
- package/lib/means-of-transport/events.d.ts.map +1 -1
- package/lib/means-of-transport/events.js +0 -1
- package/lib/means-of-transport/forms/delayForm.d.ts.map +1 -1
- package/lib/means-of-transport/forms/driverForm.d.ts.map +1 -1
- package/lib/means-of-transport/forms/index.d.ts.map +1 -1
- package/lib/means-of-transport/forms/injuryForm.d.ts.map +1 -1
- package/lib/means-of-transport/forms/serviceOfferingForm.d.ts.map +1 -1
- package/lib/means-of-transport/forms/stopForm.d.ts.map +1 -1
- package/lib/means-of-transport/forms/transportationForm.d.ts.map +1 -1
- package/lib/means-of-transport/index.d.ts.map +1 -1
- package/lib/means-of-transport/index.js +4 -2
- package/lib/means-of-transport/means-of-transport-form-machine.d.ts.map +1 -1
- package/lib/means-of-transport/means-of-transport-form-machine.js +5 -1
- package/lib/modules/api-browser/index.d.ts.map +1 -1
- package/lib/modules/config/context.d.ts.map +1 -1
- package/lib/modules/config/theme-adapter.d.ts.map +1 -1
- package/lib/modules/config/types.d.ts +2 -2
- package/lib/modules/config/types.d.ts.map +1 -1
- package/lib/modules/graphql-types/index.d.ts.map +1 -1
- package/lib/modules/graphql-types/journeyplanner-types_v3.generated.d.ts.map +1 -1
- package/lib/modules/theme/index.d.ts.map +1 -1
- package/lib/modules/theme/theme-context.d.ts +1 -1
- package/lib/modules/theme/theme-context.d.ts.map +1 -1
- package/lib/modules/theme/theme-context.js +9 -6
- package/lib/modules/transport-mode/filter/filter.d.ts.map +1 -1
- package/lib/modules/transport-mode/filter/index.d.ts.map +1 -1
- package/lib/modules/transport-mode/filter/types.d.ts.map +1 -1
- package/lib/modules/transport-mode/filter/utils.d.ts.map +1 -1
- package/lib/modules/transport-mode/icon/index.d.ts.map +1 -1
- package/lib/modules/transport-mode/icon/index.js +1 -1
- package/lib/modules/transport-mode/index.d.ts.map +1 -1
- package/lib/modules/transport-mode/types.d.ts.map +1 -1
- package/lib/modules/transport-mode/utils.d.ts.map +1 -1
- package/lib/refund/events.d.ts +12 -12
- package/lib/refund/events.d.ts.map +1 -1
- package/lib/refund/events.js +0 -1
- package/lib/refund/forms/refund-and-travel-guarantee/index.d.ts.map +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.d.ts.map +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/refundTaxiForm.d.ts.map +1 -1
- package/lib/refund/forms/refund-ticket/appTicketRefund.d.ts.map +1 -1
- package/lib/refund/forms/refund-ticket/index.d.ts.map +1 -1
- package/lib/refund/forms/refund-ticket/otherTicketRefund.d.ts.map +1 -1
- package/lib/refund/index.d.ts.map +1 -1
- package/lib/refund/index.js +4 -2
- package/lib/refund/refundFormMachine.d.ts.map +1 -1
- package/lib/refund/refundFormMachine.js +9 -3
- package/lib/server/index.d.ts +1 -1
- package/lib/server/index.d.ts.map +1 -1
- package/lib/server/journey-planner/authority.d.ts.map +1 -1
- package/lib/server/journey-planner/entur-client.d.ts.map +1 -1
- package/lib/server/journey-planner/index.d.ts.map +1 -1
- package/lib/server/journey-planner/journey-gql/lines.generated.d.ts +1 -1
- package/lib/server/journey-planner/journey-gql/lines.generated.d.ts.map +1 -1
- package/lib/server/journey-planner/journey-gql/lines.generated.js +11 -11
- package/lib/server/journey-planner/validators.d.ts.map +1 -1
- package/lib/server/types.d.ts.map +1 -1
- package/lib/ticket-control/events.d.ts +6 -6
- package/lib/ticket-control/events.d.ts.map +1 -1
- package/lib/ticket-control/events.js +0 -1
- package/lib/ticket-control/forms/feeComplaintForm.d.ts.map +1 -1
- package/lib/ticket-control/forms/feedbackForm.d.ts.map +1 -1
- package/lib/ticket-control/forms/postponePayment.d.ts.map +1 -1
- package/lib/ticket-control/index.d.ts.map +1 -1
- package/lib/ticket-control/index.js +4 -2
- package/lib/ticket-control/ticket-control-form-machine.d.ts.map +1 -1
- package/lib/ticket-control/ticket-control-form-machine.js +7 -2
- package/lib/ticketing/events.d.ts +10 -10
- package/lib/ticketing/events.d.ts.map +1 -1
- package/lib/ticketing/events.js +0 -1
- package/lib/ticketing/forms/app/appAccountForm.d.ts.map +1 -1
- package/lib/ticketing/forms/app/appTicketingForm.d.ts.map +1 -1
- package/lib/ticketing/forms/app/appTravelSuggestionForm.d.ts.map +1 -1
- package/lib/ticketing/forms/app/index.d.ts.map +1 -1
- package/lib/ticketing/forms/app/index.js +1 -1
- package/lib/ticketing/forms/priceAndTicketTypesForm.d.ts.map +1 -1
- package/lib/ticketing/forms/travel-card/index.d.ts.map +1 -1
- package/lib/ticketing/forms/travel-card/index.js +1 -1
- package/lib/ticketing/forms/travel-card/orderTravelCard.d.ts.map +1 -1
- package/lib/ticketing/forms/travel-card/travelCardQuestionForm.d.ts.map +1 -1
- package/lib/ticketing/forms/webshop/index.d.ts.map +1 -1
- package/lib/ticketing/forms/webshop/index.js +1 -1
- package/lib/ticketing/forms/webshop/webshopAccountForm.d.ts.map +1 -1
- package/lib/ticketing/forms/webshop/webshopTicketingForm.d.ts.map +1 -1
- package/lib/ticketing/index.d.ts.map +1 -1
- package/lib/ticketing/index.js +4 -2
- package/lib/ticketing/ticketingStateMachine.d.ts.map +1 -1
- package/lib/ticketing/ticketingStateMachine.js +2 -1
- package/lib/translations/common/index.d.ts.map +1 -1
- package/lib/translations/common/layout.d.ts.map +1 -1
- package/lib/translations/commons.d.ts.map +1 -1
- package/lib/translations/components/index.d.ts.map +1 -1
- package/lib/translations/components/map.d.ts.map +1 -1
- package/lib/translations/components/search.d.ts.map +1 -1
- package/lib/translations/components/transport-mode.d.ts.map +1 -1
- package/lib/translations/dictionary.d.ts.map +1 -1
- package/lib/translations/index.d.ts +2 -2
- package/lib/translations/index.d.ts.map +1 -1
- package/lib/translations/json-to-override.d.ts.map +1 -1
- package/lib/translations/json-to-override.js +15 -5
- package/lib/translations/language-context.d.ts.map +1 -1
- package/lib/translations/language-context.js +5 -9
- package/lib/translations/load-org-translations.d.ts.map +1 -1
- package/lib/translations/merge-overrides.d.ts.map +1 -1
- package/lib/translations/merge-overrides.js +3 -1
- package/lib/translations/modules/index.d.ts.map +1 -1
- package/lib/translations/modules/situation.d.ts.map +1 -1
- package/lib/translations/pages/contact.d.ts +1 -1
- package/lib/translations/pages/contact.d.ts.map +1 -1
- package/lib/translations/pages/departures.d.ts.map +1 -1
- package/lib/translations/pages/index.d.ts.map +1 -1
- package/lib/translations/server/endpoints.d.ts.map +1 -1
- package/lib/translations/server/index.d.ts.map +1 -1
- package/lib/translations/translations-context.d.ts.map +1 -1
- package/lib/translations/types.d.ts.map +1 -1
- package/lib/translations/utils.d.ts.map +1 -1
- package/lib/translations/utils.js +3 -1
- package/lib/types/submit-payloads.d.ts.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/utils/color.js +1 -1
- package/lib/utils/date.d.ts.map +1 -1
- package/lib/utils/date.js +1 -1
- package/lib/utils/env.d.ts.map +1 -1
- package/lib/utils/presence.d.ts.map +1 -1
- package/lib/utils/use-localstorage.d.ts.map +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/validation/commonInputValidator.d.ts.map +1 -1
- package/lib/validation/index.d.ts.map +1 -1
- package/lib/validation/validationRules.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/modules/api-server/external-client.d.ts +0 -22
- package/lib/modules/api-server/external-client.d.ts.map +0 -1
- package/lib/modules/api-server/external-client.js +0 -86
- package/lib/modules/api-server/index.d.ts +0 -9
- package/lib/modules/api-server/index.d.ts.map +0 -1
- package/lib/modules/api-server/index.js +0 -24
- package/lib/modules/api-server/requesters/graphql-requester.d.ts +0 -6
- package/lib/modules/api-server/requesters/graphql-requester.d.ts.map +0 -1
- package/lib/modules/api-server/requesters/graphql-requester.js +0 -63
- package/lib/modules/api-server/requesters/http-requester.d.ts +0 -3
- package/lib/modules/api-server/requesters/http-requester.d.ts.map +0 -1
- package/lib/modules/api-server/requesters/http-requester.js +0 -110
- package/lib/modules/api-server/requesters/types.d.ts +0 -37
- package/lib/modules/api-server/requesters/types.d.ts.map +0 -1
- package/lib/modules/api-server/requesters/types.js +0 -34
- package/lib/modules/api-server/requesters/utils.d.ts +0 -17
- package/lib/modules/api-server/requesters/utils.d.ts.map +0 -1
- package/lib/modules/api-server/requesters/utils.js +0 -75
- package/lib/modules/cookies/constants.d.ts +0 -4
- package/lib/modules/cookies/constants.d.ts.map +0 -1
- package/lib/modules/cookies/constants.js +0 -6
- package/lib/modules/cookies/cookies-context.d.ts +0 -17
- package/lib/modules/cookies/cookies-context.d.ts.map +0 -1
- package/lib/modules/cookies/cookies-context.js +0 -61
- package/lib/modules/cookies/index.d.ts +0 -15
- package/lib/modules/cookies/index.d.ts.map +0 -1
- package/lib/modules/cookies/index.js +0 -22
- package/lib/modules/firebase/analytics.d.ts +0 -3
- package/lib/modules/firebase/analytics.d.ts.map +0 -1
- package/lib/modules/firebase/analytics.js +0 -40
- package/lib/modules/firebase/firebase.d.ts +0 -4
- package/lib/modules/firebase/firebase.d.ts.map +0 -1
- package/lib/modules/firebase/firebase.js +0 -19
- package/lib/modules/firebase/index.d.ts +0 -5
- package/lib/modules/firebase/index.d.ts.map +0 -1
- package/lib/modules/firebase/index.js +0 -25
- package/lib/modules/firebase/preassigned-fare-products.d.ts +0 -8
- package/lib/modules/firebase/preassigned-fare-products.d.ts.map +0 -1
- package/lib/modules/firebase/preassigned-fare-products.js +0 -35
- package/lib/modules/firebase/tariff-zones.d.ts +0 -17
- package/lib/modules/firebase/tariff-zones.d.ts.map +0 -1
- package/lib/modules/firebase/tariff-zones.js +0 -32
- package/lib/modules/firebase/transport-mode-filter.d.ts +0 -27
- package/lib/modules/firebase/transport-mode-filter.d.ts.map +0 -1
- package/lib/modules/firebase/transport-mode-filter.js +0 -27
- package/lib/modules/firebase/types.d.ts +0 -19
- package/lib/modules/firebase/types.d.ts.map +0 -1
- package/lib/modules/firebase/types.js +0 -15
- package/lib/modules/logging/index.d.ts +0 -6
- package/lib/modules/logging/index.d.ts.map +0 -1
- package/lib/modules/logging/index.js +0 -13
- package/lib/modules/logging/log-api-response.d.ts +0 -15
- package/lib/modules/logging/log-api-response.d.ts.map +0 -1
- package/lib/modules/logging/log-api-response.js +0 -52
- package/lib/modules/logging/log-page-access.d.ts +0 -20
- package/lib/modules/logging/log-page-access.d.ts.map +0 -1
- package/lib/modules/logging/log-page-access.js +0 -60
- package/lib/modules/logging/logger.d.ts +0 -3
- package/lib/modules/logging/logger.d.ts.map +0 -1
- package/lib/modules/logging/logger.js +0 -32
- package/lib/modules/logging/timer.d.ts +0 -6
- package/lib/modules/logging/timer.d.ts.map +0 -1
- package/lib/modules/logging/timer.js +0 -13
- package/lib/modules/logging/with-access-logging.d.ts +0 -5
- package/lib/modules/logging/with-access-logging.d.ts.map +0 -1
- package/lib/modules/logging/with-access-logging.js +0 -20
- package/lib/modules/transport-mode/icon/transport-icon-new.d.ts +0 -28
- package/lib/modules/transport-mode/icon/transport-icon-new.d.ts.map +0 -1
- package/lib/modules/transport-mode/icon/transport-icon-new.js +0 -114
- package/lib/server/contact/index.d.ts +0 -11
- package/lib/server/contact/index.d.ts.map +0 -1
- package/lib/server/contact/index.js +0 -47
- package/lib/translations/__tests__/utils.test.d.ts +0 -2
- package/lib/translations/__tests__/utils.test.d.ts.map +0 -1
- package/lib/translations/__tests__/utils.test.js +0 -35
- package/lib/translations/pages/assistant.d.ts +0 -2
- package/lib/translations/pages/assistant.d.ts.map +0 -1
- package/lib/translations/pages/assistant.js +0 -303
- package/lib/utils/enum-from-string.d.ts +0 -4
- package/lib/utils/enum-from-string.d.ts.map +0 -1
- package/lib/utils/enum-from-string.js +0 -9
- package/lib/utils/only-uniques.d.ts +0 -3
- package/lib/utils/only-uniques.d.ts.map +0 -1
- package/lib/utils/only-uniques.js +0 -7
- package/lib/utils/org-theme-definitions.d.ts +0 -5
- package/lib/utils/org-theme-definitions.d.ts.map +0 -1
- package/lib/utils/org-theme-definitions.js +0 -13
- package/lib/utils/reference-data.d.ts +0 -15
- package/lib/utils/reference-data.d.ts.map +0 -1
- package/lib/utils/reference-data.js +0 -15
- package/lib/utils/use-client-width.d.ts +0 -2
- package/lib/utils/use-client-width.d.ts.map +0 -1
- package/lib/utils/use-client-width.js +0 -18
- package/lib/utils/use-interval.d.ts +0 -2
- package/lib/utils/use-interval.d.ts.map +0 -1
- package/lib/utils/use-interval.js +0 -22
- package/lib/utils/use-now.d.ts +0 -2
- package/lib/utils/use-now.d.ts.map +0 -1
- package/lib/utils/use-now.js +0 -13
|
@@ -1,110 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,34 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/modules/cookies/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,oBAAoB,sBAAsB,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DARKMODE_COOKIE_NAME = exports.LANGUAGE_COOKIE_NAME = exports.SETTINGS_STORETIME_DAYS = void 0;
|
|
4
|
-
exports.SETTINGS_STORETIME_DAYS = 60;
|
|
5
|
-
exports.LANGUAGE_COOKIE_NAME = 'selectedLanguage';
|
|
6
|
-
exports.DARKMODE_COOKIE_NAME = 'dark-mode-enabled';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type PropsWithChildren } from 'react';
|
|
2
|
-
export type AppCookiesContextState = {
|
|
3
|
-
darkmode: [boolean | undefined, (val: boolean) => void];
|
|
4
|
-
language: [string | undefined, (val: string) => void];
|
|
5
|
-
};
|
|
6
|
-
export type InitialCookieData = {
|
|
7
|
-
darkmode: boolean | null;
|
|
8
|
-
language: string | null;
|
|
9
|
-
};
|
|
10
|
-
export type AppCookiesProviderProps = PropsWithChildren<{
|
|
11
|
-
initialCookies: InitialCookieData;
|
|
12
|
-
}>;
|
|
13
|
-
export declare function AppCookiesProvider({ children, initialCookies, }: AppCookiesProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare function useCookieSettings(): AppCookiesContextState | undefined;
|
|
15
|
-
export declare function useDarkmodeCookie(): [boolean | undefined, (val: boolean) => void];
|
|
16
|
-
export declare function useLanguageCookie(): [string | undefined, (val: string) => void];
|
|
17
|
-
//# sourceMappingURL=cookies-context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookies-context.d.ts","sourceRoot":"","sources":["../../../src/modules/cookies/cookies-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,iBAAiB,EAMvB,MAAM,OAAO,CAAC;AAQf,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,CAAC,OAAO,GAAG,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC,CAAC;IACxD,QAAQ,EAAE,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;CACvD,CAAC;AAMF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;IACtD,cAAc,EAAE,iBAAiB,CAAC;CACnC,CAAC,CAAC;AAEH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,cAAc,GACf,EAAE,uBAAuB,2CAiBzB;AAED,wBAAgB,iBAAiB,uCAGhC;AACD,wBAAgB,iBAAiB,gCA3CO,OAAO,KAAK,IAAI,EA8CvD;AACD,wBAAgB,iBAAiB,+BA9CM,MAAM,KAAK,IAAI,EAiDrD"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppCookiesProvider = AppCookiesProvider;
|
|
4
|
-
exports.useCookieSettings = useCookieSettings;
|
|
5
|
-
exports.useDarkmodeCookie = useDarkmodeCookie;
|
|
6
|
-
exports.useLanguageCookie = useLanguageCookie;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const cookies_next_1 = require("cookies-next");
|
|
9
|
-
const date_fns_1 = require("date-fns");
|
|
10
|
-
const react_1 = require("react");
|
|
11
|
-
const constants_1 = require("./constants");
|
|
12
|
-
const CookiesContext = (0, react_1.createContext)(undefined);
|
|
13
|
-
function AppCookiesProvider({ children, initialCookies, }) {
|
|
14
|
-
const language = useCookie(constants_1.LANGUAGE_COOKIE_NAME, initialCookies.language ?? undefined, (i) => String(i ?? ''));
|
|
15
|
-
const darkmode = useCookie(constants_1.DARKMODE_COOKIE_NAME, initialCookies.darkmode ?? undefined, (i) => (typeof i === 'string' ? i === 'true' : i === true));
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(CookiesContext.Provider, { value: { language, darkmode }, children: children }));
|
|
17
|
-
}
|
|
18
|
-
function useCookieSettings() {
|
|
19
|
-
const context = (0, react_1.useContext)(CookiesContext);
|
|
20
|
-
return context;
|
|
21
|
-
}
|
|
22
|
-
function useDarkmodeCookie() {
|
|
23
|
-
const ctx = useCookieSettings();
|
|
24
|
-
return ctx?.darkmode ?? [undefined, () => { }];
|
|
25
|
-
}
|
|
26
|
-
function useLanguageCookie() {
|
|
27
|
-
const ctx = useCookieSettings();
|
|
28
|
-
return ctx?.language ?? [undefined, () => { }];
|
|
29
|
-
}
|
|
30
|
-
function useCookie(key, initialValue, mapper) {
|
|
31
|
-
const [storedValue, setStoredValue] = (0, react_1.useState)(initialValue);
|
|
32
|
-
(0, react_1.useEffect)(() => {
|
|
33
|
-
async function getData() {
|
|
34
|
-
try {
|
|
35
|
-
const data = await (0, cookies_next_1.getCookie)(key);
|
|
36
|
-
if (typeof data !== 'undefined') {
|
|
37
|
-
setStoredValue(mapper(data));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
console.warn('Failed to load cookie:', key, e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
getData();
|
|
45
|
-
}, [key, mapper]);
|
|
46
|
-
const setValue = (0, react_1.useCallback)((value) => {
|
|
47
|
-
try {
|
|
48
|
-
setStoredValue(value);
|
|
49
|
-
if (typeof window !== 'undefined') {
|
|
50
|
-
(0, cookies_next_1.setCookie)(key, value, {
|
|
51
|
-
expires: (0, date_fns_1.addDays)(new Date(), constants_1.SETTINGS_STORETIME_DAYS),
|
|
52
|
-
path: '/',
|
|
53
|
-
sameSite: 'lax',
|
|
54
|
-
secure: process.env.NEXT_PUBLIC_COOKIE_SECURE === 'true',
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (error) { }
|
|
59
|
-
}, [key]);
|
|
60
|
-
return [storedValue, setValue];
|
|
61
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { IncomingHttpHeaders } from 'http';
|
|
2
|
-
import { NextApiRequestCookies } from 'next/dist/server/api-utils';
|
|
3
|
-
import { InitialCookieData } from './cookies-context';
|
|
4
|
-
export { AppCookiesProvider, useCookieSettings, useDarkmodeCookie, useLanguageCookie, } from './cookies-context';
|
|
5
|
-
export type { InitialCookieData };
|
|
6
|
-
export type GlobalCookiesData = {
|
|
7
|
-
initialCookies: InitialCookieData;
|
|
8
|
-
headersAcceptLanguage: string;
|
|
9
|
-
referer: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function getGlobalCookies(req?: {
|
|
12
|
-
cookies: NextApiRequestCookies;
|
|
13
|
-
headers: IncomingHttpHeaders;
|
|
14
|
-
}): GlobalCookiesData;
|
|
15
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/cookies/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,iBAAiB,CAAC;IAClC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,wBAAgB,gBAAgB,CAAC,GAAG,CAAC,EAAE;IACrC,OAAO,EAAE,qBAAqB,CAAC;IAC/B,OAAO,EAAE,mBAAmB,CAAC;CAC9B,GAAG,iBAAiB,CAYpB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useLanguageCookie = exports.useDarkmodeCookie = exports.useCookieSettings = exports.AppCookiesProvider = void 0;
|
|
4
|
-
exports.getGlobalCookies = getGlobalCookies;
|
|
5
|
-
const constants_1 = require("./constants");
|
|
6
|
-
var cookies_context_1 = require("./cookies-context");
|
|
7
|
-
Object.defineProperty(exports, "AppCookiesProvider", { enumerable: true, get: function () { return cookies_context_1.AppCookiesProvider; } });
|
|
8
|
-
Object.defineProperty(exports, "useCookieSettings", { enumerable: true, get: function () { return cookies_context_1.useCookieSettings; } });
|
|
9
|
-
Object.defineProperty(exports, "useDarkmodeCookie", { enumerable: true, get: function () { return cookies_context_1.useDarkmodeCookie; } });
|
|
10
|
-
Object.defineProperty(exports, "useLanguageCookie", { enumerable: true, get: function () { return cookies_context_1.useLanguageCookie; } });
|
|
11
|
-
function getGlobalCookies(req) {
|
|
12
|
-
return {
|
|
13
|
-
initialCookies: {
|
|
14
|
-
darkmode: typeof req?.cookies[constants_1.DARKMODE_COOKIE_NAME] === 'undefined'
|
|
15
|
-
? null
|
|
16
|
-
: req.cookies[constants_1.DARKMODE_COOKIE_NAME] == 'true',
|
|
17
|
-
language: req?.cookies[constants_1.LANGUAGE_COOKIE_NAME] ?? null,
|
|
18
|
-
},
|
|
19
|
-
headersAcceptLanguage: req?.headers['accept-language'] ?? '',
|
|
20
|
-
referer: req?.headers.referer ?? '',
|
|
21
|
-
};
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../src/modules/firebase/analytics.ts"],"names":[],"mappings":"AAQA,wBAAsB,IAAI,kBAqBzB;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EACD,kBAAkB,GAClB,kBAAkB,GAClB,eAAe,GACf,gBAAgB,QAYrB"}
|
|
@@ -1,40 +0,0 @@
|
|
|
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.init = init;
|
|
7
|
-
exports.logSpecificEvent = logSpecificEvent;
|
|
8
|
-
const analytics_1 = require("firebase/analytics");
|
|
9
|
-
const firebase_1 = __importDefault(require("./firebase"));
|
|
10
|
-
async function init() {
|
|
11
|
-
if (!(await (0, analytics_1.isSupported)())) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
// Default all consents to denied.
|
|
15
|
-
(0, analytics_1.setConsent)({
|
|
16
|
-
ad_storage: 'denied',
|
|
17
|
-
ad_personalization: 'denied',
|
|
18
|
-
ad_user_data: 'denied',
|
|
19
|
-
functionality_storage: 'denied',
|
|
20
|
-
security_storage: 'denied',
|
|
21
|
-
personalization_storage: 'denied',
|
|
22
|
-
analytics_storage: 'denied',
|
|
23
|
-
});
|
|
24
|
-
// Initialize Firebase
|
|
25
|
-
const analytics = (0, analytics_1.getAnalytics)(firebase_1.default);
|
|
26
|
-
// Disable automatic data collection.
|
|
27
|
-
analytics.app.automaticDataCollectionEnabled = false;
|
|
28
|
-
}
|
|
29
|
-
function logSpecificEvent(event) {
|
|
30
|
-
if (!(0, analytics_1.isSupported)()) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
const analytics = (0, analytics_1.getAnalytics)(firebase_1.default);
|
|
35
|
-
(0, analytics_1.logEvent)(analytics, event, {});
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
// ignore, fire and forget
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.d.ts","sourceRoot":"","sources":["../../../src/modules/firebase/firebase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAoB3C,QAAA,MAAM,GAAG,EAAE,WAAmE,CAAC;AAE/E,eAAe,GAAG,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const app_1 = require("firebase/app");
|
|
4
|
-
if (!process.env.NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY ||
|
|
5
|
-
!process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN ||
|
|
6
|
-
!process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID ||
|
|
7
|
-
!process.env.NEXT_PUBLIC_FIREBASE_APP_ID) {
|
|
8
|
-
throw new Error('Missing required Firebase environment variables');
|
|
9
|
-
}
|
|
10
|
-
const firebaseConfig = {
|
|
11
|
-
apiKey: process.env.NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY,
|
|
12
|
-
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
13
|
-
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
|
14
|
-
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
|
15
|
-
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID, // optional
|
|
16
|
-
};
|
|
17
|
-
const apps = (0, app_1.getApps)();
|
|
18
|
-
const app = apps.length ? apps[0] : (0, app_1.initializeApp)(firebaseConfig);
|
|
19
|
-
exports.default = app;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/firebase/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,cAAc,SAAS,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
exports.getPreassignedFareProducts = exports.getTariffZones = exports.logSpecificEvent = exports.init = void 0;
|
|
18
|
-
var analytics_1 = require("./analytics");
|
|
19
|
-
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return analytics_1.init; } });
|
|
20
|
-
Object.defineProperty(exports, "logSpecificEvent", { enumerable: true, get: function () { return analytics_1.logSpecificEvent; } });
|
|
21
|
-
var tariff_zones_1 = require("./tariff-zones");
|
|
22
|
-
Object.defineProperty(exports, "getTariffZones", { enumerable: true, get: function () { return tariff_zones_1.getTariffZones; } });
|
|
23
|
-
var preassigned_fare_products_1 = require("./preassigned-fare-products");
|
|
24
|
-
Object.defineProperty(exports, "getPreassignedFareProducts", { enumerable: true, get: function () { return preassigned_fare_products_1.getPreassignedFareProducts; } });
|
|
25
|
-
__exportStar(require("./types"), exports);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type PreassignedFareProduct as PreassignedFareProductType } from '@atb-as/config-specs';
|
|
2
|
-
/**
|
|
3
|
-
* NB! This retrieves preassignedFareProducts_v2 directly from firestore instead of via sales svc.
|
|
4
|
-
* Be aware - future use cases may require going through sales svc.
|
|
5
|
-
* Any personalised tickets such as HjemJobbHjem need to go throug sales svc.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getPreassignedFareProducts(): Promise<PreassignedFareProductType[]>;
|
|
8
|
-
//# sourceMappingURL=preassigned-fare-products.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preassigned-fare-products.d.ts","sourceRoot":"","sources":["../../../src/modules/firebase/preassigned-fare-products.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,sBAAsB,IAAI,0BAA0B,EAE1D,MAAM,sBAAsB,CAAC;AAG9B;;;;GAIG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CACzD,0BAA0B,EAAE,CAC7B,CAuBA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
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.getPreassignedFareProducts = getPreassignedFareProducts;
|
|
7
|
-
const firestore_1 = require("firebase/firestore");
|
|
8
|
-
const firebase_1 = __importDefault(require("./firebase"));
|
|
9
|
-
const config_specs_1 = require("@atb-as/config-specs");
|
|
10
|
-
const presence_1 = require("../../utils/presence");
|
|
11
|
-
/**
|
|
12
|
-
* NB! This retrieves preassignedFareProducts_v2 directly from firestore instead of via sales svc.
|
|
13
|
-
* Be aware - future use cases may require going through sales svc.
|
|
14
|
-
* Any personalised tickets such as HjemJobbHjem need to go throug sales svc.
|
|
15
|
-
*/
|
|
16
|
-
async function getPreassignedFareProducts() {
|
|
17
|
-
const firestore = (0, firestore_1.getFirestore)(firebase_1.default);
|
|
18
|
-
const docRef = (0, firestore_1.doc)(firestore, 'configuration', 'referenceData');
|
|
19
|
-
const snapshot = await (0, firestore_1.getDoc)(docRef);
|
|
20
|
-
if (snapshot.exists()) {
|
|
21
|
-
const data = snapshot.data();
|
|
22
|
-
try {
|
|
23
|
-
return JSON.parse(data?.preassignedFareProducts_v2)
|
|
24
|
-
.map((p) => {
|
|
25
|
-
const parsed = config_specs_1.PreassignedFareProduct.safeParse(p);
|
|
26
|
-
return parsed.success ? parsed.data : undefined;
|
|
27
|
-
})
|
|
28
|
-
.filter(presence_1.isDefined);
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
throw new Error('Could not parse preassigned fare products from Firebase');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare function getTariffZones(): Promise<{
|
|
2
|
-
geometry: {
|
|
3
|
-
coordinates: number[][][];
|
|
4
|
-
type: "Polygon";
|
|
5
|
-
};
|
|
6
|
-
id: string;
|
|
7
|
-
name: {
|
|
8
|
-
lang: string;
|
|
9
|
-
value: string;
|
|
10
|
-
} | {
|
|
11
|
-
language?: string | undefined;
|
|
12
|
-
value?: string | undefined;
|
|
13
|
-
};
|
|
14
|
-
version: string;
|
|
15
|
-
isDefault?: boolean | undefined;
|
|
16
|
-
}[]>;
|
|
17
|
-
//# sourceMappingURL=tariff-zones.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tariff-zones.d.ts","sourceRoot":"","sources":["../../../src/modules/firebase/tariff-zones.ts"],"names":[],"mappings":"AAIA,wBAAsB,cAAc;;;;;;;;;;;;;;;KAwBnC"}
|