@unidy.io/sdk 1.2.0-alpha9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_commonjsHelpers-CFO10eej.js +10 -0
- package/dist/cjs/_commonjsHelpers-CFO10eej.js.map +1 -0
- package/dist/cjs/app-globals-C-Wl5lPS.js +10 -0
- package/dist/cjs/app-globals-C-Wl5lPS.js.map +1 -0
- package/dist/cjs/{auth-store-DPmGKHZ2.js → auth-store-0vv3uOib.js} +4 -4
- package/dist/cjs/{auth-store-DPmGKHZ2.js.map → auth-store-0vv3uOib.js.map} +1 -1
- package/dist/cjs/component-DLxnZCW6.js +34 -0
- package/dist/cjs/component-DLxnZCW6.js.map +1 -0
- package/dist/cjs/component-utils-XXctnOM9.js +38 -0
- package/dist/cjs/component-utils-XXctnOM9.js.map +1 -0
- package/dist/cjs/de-BWF6Glzg.js +704 -0
- package/dist/cjs/de-BWF6Glzg.js.map +1 -0
- package/dist/cjs/en-GB-DhD5mdQw.js +119 -0
- package/dist/cjs/en-GB-DhD5mdQw.js.map +1 -0
- package/dist/cjs/{flash-store-gbSYhPAV.js → flash-store-CR6Umh1O.js} +3 -3
- package/dist/cjs/{flash-store-gbSYhPAV.js.map → flash-store-CR6Umh1O.js.map} +1 -1
- package/dist/cjs/fr-j2wwoj-A.js +577 -0
- package/dist/cjs/fr-j2wwoj-A.js.map +1 -0
- package/dist/cjs/has-slot-content-CfJbU4t-.js +37 -0
- package/dist/cjs/has-slot-content-CfJbU4t-.js.map +1 -0
- package/dist/cjs/{i18n-D5j_Zl-4.js → i18n-ClWrNmGh.js} +100 -4
- package/dist/cjs/{i18n-D5j_Zl-4.js.map → i18n-ClWrNmGh.js.map} +1 -1
- package/dist/cjs/{index-B325yXfO.js → index-2Fz3r5o0.js} +5 -41
- package/dist/cjs/index-2Fz3r5o0.js.map +1 -0
- package/dist/cjs/{index-yaeiYlfa.js → index-C6ZBKFYr.js} +3 -3
- package/dist/cjs/{index-yaeiYlfa.js.map → index-C6ZBKFYr.js.map} +1 -1
- package/dist/cjs/{index-BzPYBLYC.js → index-CpPKy1CZ.js} +1170 -1087
- package/dist/cjs/index-CpPKy1CZ.js.map +1 -0
- package/dist/cjs/index.cjs.js +24 -11
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{newsletter-helpers-hdDC5X-V.js → newsletter-helpers-BHvOI8M4.js} +46 -9
- package/dist/cjs/newsletter-helpers-BHvOI8M4.js.map +1 -0
- package/dist/cjs/{newsletter-store-CupsLgO9.js → newsletter-store-22Jswiqe.js} +5 -3
- package/dist/cjs/newsletter-store-22Jswiqe.js.map +1 -0
- package/dist/cjs/nl-BE-yKvOp1-G.js +542 -0
- package/dist/cjs/nl-BE-yKvOp1-G.js.map +1 -0
- package/dist/cjs/{profile-helpers-Bprrm-Xl.js → profile-helpers-BBpAqHjK.js} +4 -4
- package/dist/cjs/{profile-helpers-Bprrm-Xl.js.map → profile-helpers-BBpAqHjK.js.map} +1 -1
- package/dist/cjs/{profile-store-C_q-TuA_.js → profile-store-CQEQhPQD.js} +4 -4
- package/dist/cjs/{profile-store-C_q-TuA_.js.map → profile-store-CQEQhPQD.js.map} +1 -1
- package/dist/cjs/redirect-with-token-wupYX97S.js +37 -0
- package/dist/cjs/redirect-with-token-wupYX97S.js.map +1 -0
- package/dist/cjs/ro-CXq9d1lv.js +578 -0
- package/dist/cjs/ro-CXq9d1lv.js.map +1 -0
- package/dist/cjs/sdk.cjs.js +3 -3
- package/dist/cjs/sv-CMln4V33.js +597 -0
- package/dist/cjs/sv-CMln4V33.js.map +1 -0
- package/dist/cjs/u-conditional-render.cjs.entry.js +14 -14
- package/dist/cjs/u-conditional-render.entry.cjs.js.map +1 -1
- package/dist/cjs/u-config.cjs.entry.js +24 -11
- package/dist/cjs/u-config.entry.cjs.js.map +1 -1
- package/dist/cjs/u-email-field.cjs.entry.js +7 -7
- package/dist/cjs/u-error-message.cjs.entry.js +49 -22
- package/dist/cjs/u-error-message.entry.cjs.js.map +1 -1
- package/dist/cjs/u-field.u-raw-field.entry.cjs.js.map +1 -1
- package/dist/cjs/u-field_2.cjs.entry.js +124 -12
- package/dist/cjs/u-flash-message.cjs.entry.js +3 -3
- package/dist/cjs/u-full-profile.cjs.entry.js +6 -6
- package/dist/cjs/u-jump-to-service.cjs.entry.js +23 -44
- package/dist/cjs/u-jump-to-service.entry.cjs.js.map +1 -1
- package/dist/cjs/u-jump-to-unidy.cjs.entry.js +22 -43
- package/dist/cjs/u-jump-to-unidy.entry.cjs.js.map +1 -1
- package/dist/cjs/u-logout-button.u-signed-in.entry.cjs.js.map +1 -1
- package/dist/cjs/u-logout-button_2.cjs.entry.js +15 -22
- package/dist/cjs/u-magic-code-field.cjs.entry.js +8 -9
- package/dist/cjs/u-magic-code-field.entry.cjs.js.map +1 -1
- package/dist/cjs/u-missing-field.cjs.entry.js +6 -5
- package/dist/cjs/u-missing-field.entry.cjs.js.map +1 -1
- package/dist/cjs/u-missing-fields-submit-button.cjs.entry.js +16 -14
- package/dist/cjs/u-missing-fields-submit-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-checkbox.cjs.entry.js +11 -12
- package/dist/cjs/u-newsletter-checkbox.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-consent-checkbox.cjs.entry.js +4 -4
- package/dist/cjs/u-newsletter-logout-button.cjs.entry.js +15 -20
- package/dist/cjs/u-newsletter-logout-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-preference-checkbox.cjs.entry.js +11 -12
- package/dist/cjs/u-newsletter-preference-checkbox.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-resend-doi-button.cjs.entry.js +10 -11
- package/dist/cjs/u-newsletter-resend-doi-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-root.cjs.entry.js +45 -22
- package/dist/cjs/u-newsletter-root.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-toggle-subscription-button.cjs.entry.js +11 -12
- package/dist/cjs/u-newsletter-toggle-subscription-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-pagination-button.cjs.entry.js +4 -4
- package/dist/cjs/u-pagination-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-pagination-page.cjs.entry.js +4 -4
- package/dist/cjs/u-pagination-page.entry.cjs.js.map +1 -1
- package/dist/cjs/u-passkey.cjs.entry.js +8 -9
- package/dist/cjs/u-passkey.entry.cjs.js.map +1 -1
- package/dist/cjs/u-password-field.cjs.entry.js +5 -5
- package/dist/cjs/u-profile.u-submit-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-profile_2.cjs.entry.js +31 -33
- package/dist/cjs/u-registration-button.cjs.entry.js +5 -5
- package/dist/cjs/u-reset-password-button.cjs.entry.js +12 -15
- package/dist/cjs/u-reset-password-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-send-magic-code-button.cjs.entry.js +8 -9
- package/dist/cjs/u-send-magic-code-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-signin-root.cjs.entry.js +6 -8
- package/dist/cjs/u-signin-root.entry.cjs.js.map +1 -1
- package/dist/cjs/u-signin-step.cjs.entry.js +17 -21
- package/dist/cjs/u-signin-step.entry.cjs.js.map +1 -1
- package/dist/cjs/u-social-login-button.cjs.entry.js +16 -15
- package/dist/cjs/u-social-login-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-spinner.cjs.entry.js +3 -3
- package/dist/cjs/u-spinner.entry.cjs.js.map +1 -1
- package/dist/cjs/u-ticketable-export.cjs.entry.js +76 -0
- package/dist/cjs/u-ticketable-export.entry.cjs.js.map +1 -0
- package/dist/cjs/u-ticketable-list-D3M8iA-g.js +3991 -0
- package/dist/cjs/u-ticketable-list-D3M8iA-g.js.map +1 -0
- package/dist/cjs/u-ticketable-list.cjs.entry.js +11 -6118
- package/dist/cjs/u-ticketable-list.entry.cjs.js.map +1 -1
- package/dist/cjs/{unidy-store-BGnWn9pc.js → unidy-store-Bvnl24i9.js} +3 -3
- package/dist/cjs/{unidy-store-BGnWn9pc.js.map → unidy-store-Bvnl24i9.js.map} +1 -1
- package/dist/collection/api/base-service.js.map +1 -1
- package/dist/collection/api/client.js.map +1 -1
- package/dist/collection/api/index.js +6 -6
- package/dist/collection/api/index.js.map +1 -1
- package/dist/collection/api/standalone.js +88 -39
- package/dist/collection/api/standalone.js.map +1 -1
- package/dist/collection/auth/api/auth.js.map +1 -1
- package/dist/collection/auth/api/schemas.js +5 -5
- package/dist/collection/auth/api/schemas.js.map +1 -1
- package/dist/collection/auth/auth-helpers.js +7 -8
- package/dist/collection/auth/auth-helpers.js.map +1 -1
- package/dist/collection/auth/auth.js +1 -0
- package/dist/collection/auth/auth.js.map +1 -1
- package/dist/collection/auth/components/jump-to-service/jump-to-service.js +20 -40
- package/dist/collection/auth/components/jump-to-service/jump-to-service.js.map +1 -1
- package/dist/collection/auth/components/jump-to-unidy/jump-to-unidy.js +20 -39
- package/dist/collection/auth/components/jump-to-unidy/jump-to-unidy.js.map +1 -1
- package/dist/collection/auth/components/logout-button/logout-button.js +7 -11
- package/dist/collection/auth/components/logout-button/logout-button.js.map +1 -1
- package/dist/collection/auth/components/missing-field/missing-field.js +25 -1
- package/dist/collection/auth/components/missing-field/missing-field.js.map +1 -1
- package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js +33 -7
- package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js.map +1 -1
- package/dist/collection/auth/components/password-field/password-field.js +1 -1
- package/dist/collection/auth/components/reset-pass-button/reset-pass-button.js +6 -8
- package/dist/collection/auth/components/reset-pass-button/reset-pass-button.js.map +1 -1
- package/dist/collection/auth/components/signed-in/signed-in.js +2 -5
- package/dist/collection/auth/components/signed-in/signed-in.js.map +1 -1
- package/dist/collection/auth/components/signin-root/signin-root.js +2 -5
- package/dist/collection/auth/components/signin-root/signin-root.js.map +1 -1
- package/dist/collection/auth/components/signin-step/signin-step.js +9 -13
- package/dist/collection/auth/components/signin-step/signin-step.js.map +1 -1
- package/dist/collection/auth/components/social-logins/social-login-button.css +1 -1
- package/dist/collection/auth/components/social-logins/social-login-button.js +11 -12
- package/dist/collection/auth/components/social-logins/social-login-button.js.map +1 -1
- package/dist/collection/auth/components/submit-button/auth-submit-button.js +10 -0
- package/dist/collection/auth/components/submit-button/auth-submit-button.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/locales/de.json +16 -0
- package/dist/collection/locales/en.json +16 -0
- package/dist/collection/locales/fr.json +16 -0
- package/dist/collection/locales/it.json +16 -0
- package/dist/collection/locales/nl_be.json +16 -0
- package/dist/collection/locales/ro.json +16 -0
- package/dist/collection/logger.js +0 -37
- package/dist/collection/logger.js.map +1 -1
- package/dist/collection/newsletter/api/newsletters.js +19 -18
- package/dist/collection/newsletter/api/newsletters.js.map +1 -1
- package/dist/collection/newsletter/components/consent-checkbox/consent-checkbox.js +1 -1
- package/dist/collection/newsletter/components/logout-button/logout-button.js +6 -10
- package/dist/collection/newsletter/components/logout-button/logout-button.js.map +1 -1
- package/dist/collection/newsletter/components/newsletter-checkbox/newsletter-checkbox.js +1 -1
- package/dist/collection/newsletter/components/newsletter-root/newsletter-root.js +65 -10
- package/dist/collection/newsletter/components/newsletter-root/newsletter-root.js.map +1 -1
- package/dist/collection/newsletter/components/preference-checkbox/preference-checkbox.js +1 -1
- package/dist/collection/newsletter/components/toggle-subscription-button/toggle-subscription-button.js +1 -1
- package/dist/collection/newsletter/newsletter-helpers.js +39 -2
- package/dist/collection/newsletter/newsletter-helpers.js.map +1 -1
- package/dist/collection/newsletter/store/newsletter-store.js +2 -0
- package/dist/collection/newsletter/store/newsletter-store.js.map +1 -1
- package/dist/collection/profile/api/profile.js.map +1 -1
- package/dist/collection/profile/api/schemas.js +1 -1
- package/dist/collection/profile/api/schemas.js.map +1 -1
- package/dist/collection/profile/components/field/field.js +3 -1
- package/dist/collection/profile/components/field/field.js.map +1 -1
- package/dist/collection/profile/components/full-profile/full-profile.js +1 -1
- package/dist/collection/profile/components/raw-field/raw-field.js +40 -7
- package/dist/collection/profile/components/raw-field/raw-field.js.map +1 -1
- package/dist/collection/profile/store/profile-store.js +1 -1
- package/dist/collection/profile/store/profile-store.js.map +1 -1
- package/dist/collection/shared/base/component.js +28 -0
- package/dist/collection/shared/base/component.js.map +1 -0
- package/dist/collection/shared/base/has-slot-content.js +31 -0
- package/dist/collection/shared/base/has-slot-content.js.map +1 -0
- package/dist/collection/shared/component-utils.js +23 -27
- package/dist/collection/shared/component-utils.js.map +1 -1
- package/dist/collection/shared/components/conditional-render/conditional-render.js +4 -5
- package/dist/collection/shared/components/conditional-render/conditional-render.js.map +1 -1
- package/dist/collection/shared/components/config/config.js +18 -5
- package/dist/collection/shared/components/config/config.js.map +1 -1
- package/dist/collection/shared/components/email-field/email-field.js +1 -1
- package/dist/collection/shared/components/error-message/error-message.css +1 -1
- package/dist/collection/shared/components/error-message/error-message.js +44 -17
- package/dist/collection/shared/components/error-message/error-message.js.map +1 -1
- package/dist/collection/shared/components/spinner/spinner.css +1 -1
- package/dist/collection/shared/components/spinner/spinner.js +1 -1
- package/dist/collection/shared/components/submit-button/submit-button.css +1 -1
- package/dist/collection/shared/components/submit-button/submit-button.js +12 -23
- package/dist/collection/shared/components/submit-button/submit-button.js.map +1 -1
- package/dist/collection/shared/context-utils.js +96 -0
- package/dist/collection/shared/context-utils.js.map +1 -0
- package/dist/collection/shared/utils/redirect-with-token.js +30 -0
- package/dist/collection/shared/utils/redirect-with-token.js.map +1 -0
- package/dist/collection/shared/utils/url-utils.js +25 -0
- package/dist/collection/shared/utils/url-utils.js.map +1 -0
- package/dist/collection/ticketable/api/schemas.js +10 -2
- package/dist/collection/ticketable/api/schemas.js.map +1 -1
- package/dist/collection/ticketable/api/subscriptions.js +22 -1
- package/dist/collection/ticketable/api/subscriptions.js.map +1 -1
- package/dist/collection/ticketable/api/tickets.js +22 -1
- package/dist/collection/ticketable/api/tickets.js.map +1 -1
- package/dist/collection/ticketable/components/pagination/pagination-button.js +3 -5
- package/dist/collection/ticketable/components/pagination/pagination-button.js.map +1 -1
- package/dist/collection/ticketable/components/pagination/pagination-page.js +3 -5
- package/dist/collection/ticketable/components/pagination/pagination-page.js.map +1 -1
- package/dist/collection/ticketable/components/ticketable-export/ticketable-export.js +175 -0
- package/dist/collection/ticketable/components/ticketable-export/ticketable-export.js.map +1 -0
- package/dist/collection/ticketable/components/ticketable-list/ticketable-list.js +163 -25
- package/dist/collection/ticketable/components/ticketable-list/ticketable-list.js.map +1 -1
- package/dist/collection/ticketable/index.js +1 -0
- package/dist/collection/ticketable/index.js.map +1 -1
- package/dist/components/_commonjsHelpers.js +8 -0
- package/dist/components/_commonjsHelpers.js.map +1 -0
- package/dist/components/component-utils.js +25 -28
- package/dist/components/component-utils.js.map +1 -1
- package/dist/components/component.js +33 -0
- package/dist/components/component.js.map +1 -0
- package/dist/components/de.js +702 -0
- package/dist/components/de.js.map +1 -0
- package/dist/components/en-GB.js +117 -0
- package/dist/components/en-GB.js.map +1 -0
- package/dist/components/field.js +3 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/fr.js +575 -0
- package/dist/components/fr.js.map +1 -0
- package/dist/components/has-slot-content.js +35 -0
- package/dist/components/has-slot-content.js.map +1 -0
- package/dist/components/i18n.js +96 -0
- package/dist/components/i18n.js.map +1 -1
- package/dist/components/index.js +11 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/index2.js +1158 -1083
- package/dist/components/index2.js.map +1 -1
- package/dist/components/logger.js +1 -39
- package/dist/components/logger.js.map +1 -1
- package/dist/components/newsletter-helpers.js +39 -2
- package/dist/components/newsletter-helpers.js.map +1 -1
- package/dist/components/newsletter-store.js +2 -0
- package/dist/components/newsletter-store.js.map +1 -1
- package/dist/components/nl-BE.js +540 -0
- package/dist/components/nl-BE.js.map +1 -0
- package/dist/components/profile-store.js +1 -1
- package/dist/components/profile-store.js.map +1 -1
- package/dist/components/raw-field.js +116 -7
- package/dist/components/raw-field.js.map +1 -1
- package/dist/components/redirect-with-token.js +35 -0
- package/dist/components/redirect-with-token.js.map +1 -0
- package/dist/components/ro.js +576 -0
- package/dist/components/ro.js.map +1 -0
- package/dist/components/spinner.js +2 -2
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/submit-button.js +21 -24
- package/dist/components/submit-button.js.map +1 -1
- package/dist/components/sv.js +595 -0
- package/dist/components/sv.js.map +1 -0
- package/dist/components/u-conditional-render.js +5 -6
- package/dist/components/u-conditional-render.js.map +1 -1
- package/dist/components/u-config.js +16 -3
- package/dist/components/u-config.js.map +1 -1
- package/dist/components/u-email-field.js +1 -1
- package/dist/components/u-error-message.js +44 -19
- package/dist/components/u-error-message.js.map +1 -1
- package/dist/components/u-full-profile.js +1 -1
- package/dist/components/u-jump-to-service.js +16 -38
- package/dist/components/u-jump-to-service.js.map +1 -1
- package/dist/components/u-jump-to-unidy.js +16 -37
- package/dist/components/u-jump-to-unidy.js.map +1 -1
- package/dist/components/u-logout-button.js +5 -11
- package/dist/components/u-logout-button.js.map +1 -1
- package/dist/components/u-missing-field.js +5 -2
- package/dist/components/u-missing-field.js.map +1 -1
- package/dist/components/u-missing-fields-submit-button.js +10 -8
- package/dist/components/u-missing-fields-submit-button.js.map +1 -1
- package/dist/components/u-newsletter-checkbox.js +1 -1
- package/dist/components/u-newsletter-consent-checkbox.js +1 -1
- package/dist/components/u-newsletter-logout-button.js +6 -12
- package/dist/components/u-newsletter-logout-button.js.map +1 -1
- package/dist/components/u-newsletter-preference-checkbox.js +1 -1
- package/dist/components/u-newsletter-root.js +35 -12
- package/dist/components/u-newsletter-root.js.map +1 -1
- package/dist/components/u-newsletter-toggle-subscription-button.js +1 -1
- package/dist/components/u-pagination-button.js +3 -4
- package/dist/components/u-pagination-button.js.map +1 -1
- package/dist/components/u-pagination-page.js +3 -4
- package/dist/components/u-pagination-page.js.map +1 -1
- package/dist/components/u-reset-password-button.js +4 -8
- package/dist/components/u-reset-password-button.js.map +1 -1
- package/dist/components/u-signed-in.js +3 -6
- package/dist/components/u-signed-in.js.map +1 -1
- package/dist/components/u-signin-root.js +3 -6
- package/dist/components/u-signin-root.js.map +1 -1
- package/dist/components/u-signin-step.js +10 -14
- package/dist/components/u-signin-step.js.map +1 -1
- package/dist/components/u-social-login-button.js +13 -14
- package/dist/components/u-social-login-button.js.map +1 -1
- package/dist/components/u-ticketable-export.d.ts +11 -0
- package/dist/components/u-ticketable-export.js +93 -0
- package/dist/components/u-ticketable-export.js.map +1 -0
- package/dist/components/u-ticketable-list.js +256 -2396
- package/dist/components/u-ticketable-list.js.map +1 -1
- package/dist/esm/_commonjsHelpers-B85MJLTf.js +8 -0
- package/dist/esm/_commonjsHelpers-B85MJLTf.js.map +1 -0
- package/dist/esm/app-globals-J743qnJf.js +8 -0
- package/dist/esm/app-globals-J743qnJf.js.map +1 -0
- package/dist/esm/{auth-store-DBlGNGhq.js → auth-store-CSpEdi46.js} +4 -4
- package/dist/esm/{auth-store-DBlGNGhq.js.map → auth-store-CSpEdi46.js.map} +1 -1
- package/dist/esm/component-qfegGRWr.js +32 -0
- package/dist/esm/component-qfegGRWr.js.map +1 -0
- package/dist/esm/component-utils-WEof9bTg.js +36 -0
- package/dist/esm/component-utils-WEof9bTg.js.map +1 -0
- package/dist/esm/de-C6AnCqsA.js +702 -0
- package/dist/esm/de-C6AnCqsA.js.map +1 -0
- package/dist/esm/en-GB-DO63WPxt.js +117 -0
- package/dist/esm/en-GB-DO63WPxt.js.map +1 -0
- package/dist/esm/{flash-store-Df2YkLTB.js → flash-store-Dn1Bava8.js} +3 -3
- package/dist/esm/{flash-store-Df2YkLTB.js.map → flash-store-Dn1Bava8.js.map} +1 -1
- package/dist/esm/fr-C0oU6-EJ.js +575 -0
- package/dist/esm/fr-C0oU6-EJ.js.map +1 -0
- package/dist/esm/has-slot-content-DSMkJu9G.js +35 -0
- package/dist/esm/has-slot-content-DSMkJu9G.js.map +1 -0
- package/dist/esm/{i18n-Da7S9Oqf.js → i18n-ioyZxWsT.js} +100 -4
- package/dist/esm/{i18n-Da7S9Oqf.js.map → i18n-ioyZxWsT.js.map} +1 -1
- package/dist/esm/{index-FTKB5a1d.js → index-BsJDptgj.js} +4 -40
- package/dist/esm/index-BsJDptgj.js.map +1 -0
- package/dist/esm/{index-BnAYOYR5.js → index-C8kmD3tu.js} +3 -3
- package/dist/esm/{index-BnAYOYR5.js.map → index-C8kmD3tu.js.map} +1 -1
- package/dist/esm/{index-BVlbCQEX.js → index-kgGjfc-n.js} +1163 -1088
- package/dist/esm/index-kgGjfc-n.js.map +1 -0
- package/dist/esm/index.js +18 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +4 -4
- package/dist/esm/{newsletter-helpers-fCpxzovf.js → newsletter-helpers-DoKGN_Kq.js} +46 -9
- package/dist/esm/newsletter-helpers-DoKGN_Kq.js.map +1 -0
- package/dist/esm/{newsletter-store-BB618FgS.js → newsletter-store-DpR85vaC.js} +5 -3
- package/dist/esm/newsletter-store-DpR85vaC.js.map +1 -0
- package/dist/esm/nl-BE-C8uPYb_H.js +540 -0
- package/dist/esm/nl-BE-C8uPYb_H.js.map +1 -0
- package/dist/esm/{profile-helpers-CXK2X6Ts.js → profile-helpers-BMJy0ei_.js} +4 -4
- package/dist/esm/{profile-helpers-CXK2X6Ts.js.map → profile-helpers-BMJy0ei_.js.map} +1 -1
- package/dist/esm/{profile-store-CHlSKuTY.js → profile-store-7wBS3gBH.js} +4 -4
- package/dist/esm/{profile-store-CHlSKuTY.js.map → profile-store-7wBS3gBH.js.map} +1 -1
- package/dist/esm/redirect-with-token-StCLJlSp.js +35 -0
- package/dist/esm/redirect-with-token-StCLJlSp.js.map +1 -0
- package/dist/esm/ro-BlDHz7d-.js +576 -0
- package/dist/esm/ro-BlDHz7d-.js.map +1 -0
- package/dist/esm/sdk.js +4 -4
- package/dist/esm/sv-B_Gq29K0.js +595 -0
- package/dist/esm/sv-B_Gq29K0.js.map +1 -0
- package/dist/esm/u-conditional-render.entry.js +14 -14
- package/dist/esm/u-conditional-render.entry.js.map +1 -1
- package/dist/esm/u-config.entry.js +24 -11
- package/dist/esm/u-config.entry.js.map +1 -1
- package/dist/esm/u-email-field.entry.js +7 -7
- package/dist/esm/u-error-message.entry.js +49 -22
- package/dist/esm/u-error-message.entry.js.map +1 -1
- package/dist/esm/u-field.u-raw-field.entry.js.map +1 -1
- package/dist/esm/u-field_2.entry.js +124 -12
- package/dist/esm/u-flash-message.entry.js +3 -3
- package/dist/esm/u-full-profile.entry.js +6 -6
- package/dist/esm/u-jump-to-service.entry.js +23 -44
- package/dist/esm/u-jump-to-service.entry.js.map +1 -1
- package/dist/esm/u-jump-to-unidy.entry.js +22 -43
- package/dist/esm/u-jump-to-unidy.entry.js.map +1 -1
- package/dist/esm/u-logout-button.u-signed-in.entry.js.map +1 -1
- package/dist/esm/u-logout-button_2.entry.js +15 -22
- package/dist/esm/u-magic-code-field.entry.js +8 -9
- package/dist/esm/u-magic-code-field.entry.js.map +1 -1
- package/dist/esm/u-missing-field.entry.js +6 -5
- package/dist/esm/u-missing-field.entry.js.map +1 -1
- package/dist/esm/u-missing-fields-submit-button.entry.js +16 -14
- package/dist/esm/u-missing-fields-submit-button.entry.js.map +1 -1
- package/dist/esm/u-newsletter-checkbox.entry.js +11 -12
- package/dist/esm/u-newsletter-checkbox.entry.js.map +1 -1
- package/dist/esm/u-newsletter-consent-checkbox.entry.js +4 -4
- package/dist/esm/u-newsletter-logout-button.entry.js +15 -20
- package/dist/esm/u-newsletter-logout-button.entry.js.map +1 -1
- package/dist/esm/u-newsletter-preference-checkbox.entry.js +11 -12
- package/dist/esm/u-newsletter-preference-checkbox.entry.js.map +1 -1
- package/dist/esm/u-newsletter-resend-doi-button.entry.js +10 -11
- package/dist/esm/u-newsletter-resend-doi-button.entry.js.map +1 -1
- package/dist/esm/u-newsletter-root.entry.js +42 -19
- package/dist/esm/u-newsletter-root.entry.js.map +1 -1
- package/dist/esm/u-newsletter-toggle-subscription-button.entry.js +11 -12
- package/dist/esm/u-newsletter-toggle-subscription-button.entry.js.map +1 -1
- package/dist/esm/u-pagination-button.entry.js +4 -4
- package/dist/esm/u-pagination-button.entry.js.map +1 -1
- package/dist/esm/u-pagination-page.entry.js +4 -4
- package/dist/esm/u-pagination-page.entry.js.map +1 -1
- package/dist/esm/u-passkey.entry.js +8 -9
- package/dist/esm/u-passkey.entry.js.map +1 -1
- package/dist/esm/u-password-field.entry.js +5 -5
- package/dist/esm/u-profile.u-submit-button.entry.js.map +1 -1
- package/dist/esm/u-profile_2.entry.js +31 -33
- package/dist/esm/u-registration-button.entry.js +5 -5
- package/dist/esm/u-reset-password-button.entry.js +12 -15
- package/dist/esm/u-reset-password-button.entry.js.map +1 -1
- package/dist/esm/u-send-magic-code-button.entry.js +8 -9
- package/dist/esm/u-send-magic-code-button.entry.js.map +1 -1
- package/dist/esm/u-signin-root.entry.js +6 -8
- package/dist/esm/u-signin-root.entry.js.map +1 -1
- package/dist/esm/u-signin-step.entry.js +17 -21
- package/dist/esm/u-signin-step.entry.js.map +1 -1
- package/dist/esm/u-social-login-button.entry.js +16 -15
- package/dist/esm/u-social-login-button.entry.js.map +1 -1
- package/dist/esm/u-spinner.entry.js +3 -3
- package/dist/esm/u-spinner.entry.js.map +1 -1
- package/dist/esm/u-ticketable-export.entry.js +74 -0
- package/dist/esm/u-ticketable-export.entry.js.map +1 -0
- package/dist/esm/u-ticketable-list-D2p21JjR.js +3981 -0
- package/dist/esm/u-ticketable-list-D2p21JjR.js.map +1 -0
- package/dist/esm/u-ticketable-list.entry.js +10 -6121
- package/dist/esm/u-ticketable-list.entry.js.map +1 -1
- package/dist/esm/{unidy-store-Bg7IaIMd.js → unidy-store-B5Bf4Vit.js} +3 -3
- package/dist/esm/{unidy-store-Bg7IaIMd.js.map → unidy-store-B5Bf4Vit.js.map} +1 -1
- package/dist/sdk/index.esm.js +1 -1
- package/dist/sdk/index.esm.js.map +1 -1
- package/dist/sdk/locales/de.json +16 -0
- package/dist/sdk/locales/en.json +16 -0
- package/dist/sdk/locales/fr.json +16 -0
- package/dist/sdk/locales/it.json +16 -0
- package/dist/sdk/locales/nl_be.json +16 -0
- package/dist/sdk/locales/ro.json +16 -0
- package/dist/sdk/p-02dce5da.entry.js +2 -0
- package/dist/sdk/p-02dce5da.entry.js.map +1 -0
- package/dist/sdk/p-043c7643.entry.js +2 -0
- package/dist/sdk/p-043c7643.entry.js.map +1 -0
- package/dist/sdk/p-18c17747.entry.js +2 -0
- package/dist/sdk/p-18c17747.entry.js.map +1 -0
- package/dist/sdk/p-1a1c1af0.entry.js +2 -0
- package/dist/sdk/p-1a1c1af0.entry.js.map +1 -0
- package/dist/sdk/p-271781c7.entry.js +2 -0
- package/dist/sdk/{p-1a8973a6.entry.js.map → p-271781c7.entry.js.map} +1 -1
- package/dist/sdk/p-29473a55.entry.js +2 -0
- package/dist/sdk/p-29473a55.entry.js.map +1 -0
- package/dist/sdk/p-2a25d62e.entry.js +2 -0
- package/dist/sdk/p-2a25d62e.entry.js.map +1 -0
- package/dist/sdk/{p-C8lRzJEX.js → p-2bKltz_F.js} +2 -2
- package/dist/sdk/{p-C8lRzJEX.js.map → p-2bKltz_F.js.map} +1 -1
- package/dist/sdk/p-2cc3a00d.entry.js +2 -0
- package/dist/sdk/p-2cc3a00d.entry.js.map +1 -0
- package/dist/sdk/p-2f49e0cb.entry.js +2 -0
- package/dist/sdk/p-2f49e0cb.entry.js.map +1 -0
- package/dist/sdk/p-34f5d201.entry.js +2 -0
- package/dist/sdk/p-34f5d201.entry.js.map +1 -0
- package/dist/sdk/p-52c4bdd9.entry.js +2 -0
- package/dist/sdk/p-52c4bdd9.entry.js.map +1 -0
- package/dist/sdk/p-585a0efa.entry.js +2 -0
- package/dist/sdk/p-585a0efa.entry.js.map +1 -0
- package/dist/sdk/p-60675019.entry.js +2 -0
- package/dist/sdk/p-60675019.entry.js.map +1 -0
- package/dist/sdk/p-79ef9a70.entry.js +2 -0
- package/dist/sdk/p-79ef9a70.entry.js.map +1 -0
- package/dist/sdk/p-7d88e21c.entry.js +2 -0
- package/dist/sdk/p-7d88e21c.entry.js.map +1 -0
- package/dist/sdk/p-7eaf3468.entry.js +2 -0
- package/dist/sdk/p-7eaf3468.entry.js.map +1 -0
- package/dist/sdk/{p-88beb872.entry.js → p-8412762c.entry.js} +2 -2
- package/dist/sdk/p-8ea70c08.entry.js +2 -0
- package/dist/sdk/p-8ea70c08.entry.js.map +1 -0
- package/dist/sdk/p-946cdb0a.entry.js +2 -0
- package/dist/sdk/p-946cdb0a.entry.js.map +1 -0
- package/dist/sdk/p-94bb0217.entry.js +2 -0
- package/dist/sdk/p-94bb0217.entry.js.map +1 -0
- package/dist/sdk/{p-bcca06f1.entry.js → p-96860b09.entry.js} +2 -2
- package/dist/sdk/p-B1A6Nu24.js +2 -0
- package/dist/sdk/p-B1A6Nu24.js.map +1 -0
- package/dist/sdk/p-B85MJLTf.js +2 -0
- package/dist/sdk/p-B85MJLTf.js.map +1 -0
- package/dist/sdk/p-B8N6Bwsa.js +2 -0
- package/dist/sdk/{p-DCG3L43i.js.map → p-B8N6Bwsa.js.map} +1 -1
- package/dist/sdk/p-Ba5szISo.js +2 -0
- package/dist/sdk/p-Ba5szISo.js.map +1 -0
- package/dist/sdk/p-BsJDptgj.js +14 -0
- package/dist/sdk/p-BsJDptgj.js.map +1 -0
- package/dist/sdk/{p-bpXpOZY_.js → p-C0Mo15qt.js} +2 -2
- package/dist/sdk/{p-bpXpOZY_.js.map → p-C0Mo15qt.js.map} +1 -1
- package/dist/sdk/p-C10MAuCE.js +2 -0
- package/dist/sdk/p-C10MAuCE.js.map +1 -0
- package/dist/sdk/p-CTy6pQSg.js +2 -0
- package/dist/sdk/p-CTy6pQSg.js.map +1 -0
- package/dist/sdk/p-CW6kGAuQ.js +2 -0
- package/dist/sdk/p-CW6kGAuQ.js.map +1 -0
- package/dist/sdk/{p-DdMKVWx8.js → p-CbSP8My1.js} +2 -2
- package/dist/sdk/{p-DdMKVWx8.js.map → p-CbSP8My1.js.map} +1 -1
- package/dist/sdk/p-CbzzI4uW.js +2 -0
- package/dist/sdk/p-CbzzI4uW.js.map +1 -0
- package/dist/sdk/p-CgT6fZjb.js +2 -0
- package/dist/sdk/p-CgT6fZjb.js.map +1 -0
- package/dist/sdk/p-CuHZ3IkE.js +2 -0
- package/dist/sdk/p-CuHZ3IkE.js.map +1 -0
- package/dist/sdk/p-Cysk_vik.js +2 -0
- package/dist/sdk/p-Cysk_vik.js.map +1 -0
- package/dist/sdk/p-D0ut3waq.js +2 -0
- package/dist/sdk/p-D0ut3waq.js.map +1 -0
- package/dist/sdk/{p-BigbTrKk.js → p-D2Rf-QGm.js} +2 -2
- package/dist/sdk/{p-BigbTrKk.js.map → p-D2Rf-QGm.js.map} +1 -1
- package/dist/sdk/{p-6rqGeAfT.js → p-D9yFO_ID.js} +2 -2
- package/dist/sdk/{p-6rqGeAfT.js.map → p-D9yFO_ID.js.map} +1 -1
- package/dist/sdk/p-DD_5soRi.js +2 -0
- package/dist/sdk/p-DD_5soRi.js.map +1 -0
- package/dist/sdk/p-DHuvvagO.js +2 -0
- package/dist/sdk/p-DHuvvagO.js.map +1 -0
- package/dist/sdk/p-DSMkJu9G.js +2 -0
- package/dist/sdk/p-DSMkJu9G.js.map +1 -0
- package/dist/sdk/p-DcirMfca.js +2 -0
- package/dist/sdk/p-DcirMfca.js.map +1 -0
- package/dist/sdk/p-J0cv5IOA.js +2 -0
- package/dist/sdk/p-J0cv5IOA.js.map +1 -0
- package/dist/sdk/p-_5evboqW.js +2 -0
- package/dist/sdk/{p-DSktNM_k.js.map → p-_5evboqW.js.map} +1 -1
- package/dist/sdk/{p-7ee2f2ab.entry.js → p-ac3a6bbf.entry.js} +2 -2
- package/dist/sdk/p-b498bcdd.entry.js +2 -0
- package/dist/sdk/p-b498bcdd.entry.js.map +1 -0
- package/dist/sdk/p-b5dd5b4c.entry.js +2 -0
- package/dist/sdk/p-b5dd5b4c.entry.js.map +1 -0
- package/dist/sdk/{p-6b061b18.entry.js → p-b99588a8.entry.js} +2 -2
- package/dist/sdk/p-bf9c27a8.entry.js +2 -0
- package/dist/sdk/p-bf9c27a8.entry.js.map +1 -0
- package/dist/sdk/p-c10d9b8e.entry.js +2 -0
- package/dist/sdk/p-c10d9b8e.entry.js.map +1 -0
- package/dist/sdk/{p-10e20afd.entry.js → p-c2634439.entry.js} +2 -2
- package/dist/sdk/p-d6777395.entry.js +2 -0
- package/dist/sdk/p-d6777395.entry.js.map +1 -0
- package/dist/sdk/p-dbfe7b29.entry.js +2 -0
- package/dist/sdk/p-dbfe7b29.entry.js.map +1 -0
- package/dist/sdk/p-def4e874.entry.js +2 -0
- package/dist/sdk/p-def4e874.entry.js.map +1 -0
- package/dist/sdk/p-e872a012.entry.js +2 -0
- package/dist/sdk/p-e872a012.entry.js.map +1 -0
- package/dist/sdk/p-eaaf3989.entry.js +2 -0
- package/dist/sdk/p-eaaf3989.entry.js.map +1 -0
- package/dist/sdk/p-fd46b459.entry.js +2 -0
- package/dist/sdk/{p-830778eb.entry.js.map → p-fd46b459.entry.js.map} +1 -1
- package/dist/sdk/sdk.esm.js +1 -1
- package/dist/sdk/u-conditional-render.entry.esm.js.map +1 -1
- package/dist/sdk/u-config.entry.esm.js.map +1 -1
- package/dist/sdk/u-error-message.entry.esm.js.map +1 -1
- package/dist/sdk/u-field.u-raw-field.entry.esm.js.map +1 -1
- package/dist/sdk/u-jump-to-service.entry.esm.js.map +1 -1
- package/dist/sdk/u-jump-to-unidy.entry.esm.js.map +1 -1
- package/dist/sdk/u-logout-button.u-signed-in.entry.esm.js.map +1 -1
- package/dist/sdk/u-magic-code-field.entry.esm.js.map +1 -1
- package/dist/sdk/u-missing-field.entry.esm.js.map +1 -1
- package/dist/sdk/u-missing-fields-submit-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-checkbox.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-logout-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-preference-checkbox.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-resend-doi-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-root.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-toggle-subscription-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-pagination-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-pagination-page.entry.esm.js.map +1 -1
- package/dist/sdk/u-passkey.entry.esm.js.map +1 -1
- package/dist/sdk/u-profile.u-submit-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-reset-password-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-send-magic-code-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-signin-root.entry.esm.js.map +1 -1
- package/dist/sdk/u-signin-step.entry.esm.js.map +1 -1
- package/dist/sdk/u-social-login-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-spinner.entry.esm.js.map +1 -1
- package/dist/sdk/u-ticketable-export.entry.esm.js.map +1 -0
- package/dist/sdk/u-ticketable-list.entry.esm.js.map +1 -1
- package/dist/types/api/client.d.ts +1 -1
- package/dist/types/api/index.d.ts +4 -4
- package/dist/types/api/standalone.d.ts +9 -9
- package/dist/types/auth/api/auth.d.ts +2 -3
- package/dist/types/auth/api/schemas.d.ts +19 -19
- package/dist/types/auth/auth-helpers.d.ts +1 -0
- package/dist/types/auth/components/jump-to-service/jump-to-service.d.ts +13 -5
- package/dist/types/auth/components/jump-to-unidy/jump-to-unidy.d.ts +13 -9
- package/dist/types/auth/components/logout-button/logout-button.d.ts +13 -4
- package/dist/types/auth/components/missing-field/missing-field.d.ts +1 -0
- package/dist/types/auth/components/missing-fields-submit-button/missing-fields-submit-button.d.ts +14 -2
- package/dist/types/auth/components/reset-pass-button/reset-pass-button.d.ts +13 -4
- package/dist/types/auth/components/social-logins/social-login-button.d.ts +11 -7
- package/dist/types/components.d.ts +73 -0
- package/dist/types/logger.d.ts +0 -34
- package/dist/types/newsletter/components/logout-button/logout-button.d.ts +13 -4
- package/dist/types/newsletter/components/newsletter-root/newsletter-root.d.ts +16 -2
- package/dist/types/newsletter/newsletter-helpers.d.ts +8 -2
- package/dist/types/newsletter/store/newsletter-store.d.ts +8 -1
- package/dist/types/profile/api/profile.d.ts +2 -2
- package/dist/types/profile/api/schemas.d.ts +21 -21
- package/dist/types/profile/components/raw-field/raw-field.d.ts +14 -2
- package/dist/types/shared/base/component.d.ts +46 -0
- package/dist/types/shared/base/has-slot-content.d.ts +10 -0
- package/dist/types/shared/component-utils.d.ts +20 -12
- package/dist/types/shared/components/conditional-render/conditional-render.d.ts +7 -2
- package/dist/types/shared/components/config/config.d.ts +7 -2
- package/dist/types/shared/components/error-message/error-message.d.ts +14 -2
- package/dist/types/shared/components/submit-button/submit-button.d.ts +13 -4
- package/dist/types/shared/context-utils.d.ts +73 -0
- package/dist/types/shared/utils/redirect-with-token.d.ts +21 -0
- package/dist/types/shared/utils/url-utils.d.ts +16 -0
- package/dist/types/ticketable/api/schemas.d.ts +16 -2
- package/dist/types/ticketable/api/subscriptions.d.ts +8 -3
- package/dist/types/ticketable/api/tickets.d.ts +8 -3
- package/dist/types/ticketable/components/pagination/pagination-button.d.ts +8 -4
- package/dist/types/ticketable/components/pagination/pagination-page.d.ts +8 -4
- package/dist/types/ticketable/components/ticketable-export/ticketable-export.d.ts +24 -0
- package/dist/types/ticketable/components/ticketable-list/ticketable-list.d.ts +10 -4
- package/dist/types/ticketable/index.d.ts +1 -0
- package/package.json +6 -2
- package/readme.md +248 -27
- package/dist/cjs/app-globals-hdkLqF51.js +0 -10
- package/dist/cjs/app-globals-hdkLqF51.js.map +0 -1
- package/dist/cjs/component-utils-bu3SY4dE.js +0 -42
- package/dist/cjs/component-utils-bu3SY4dE.js.map +0 -1
- package/dist/cjs/index-B325yXfO.js.map +0 -1
- package/dist/cjs/index-BzPYBLYC.js.map +0 -1
- package/dist/cjs/newsletter-helpers-hdDC5X-V.js.map +0 -1
- package/dist/cjs/newsletter-store-CupsLgO9.js.map +0 -1
- package/dist/cjs/pagination-store-zo48QpTm.js +0 -16
- package/dist/cjs/pagination-store-zo48QpTm.js.map +0 -1
- package/dist/components/pagination-store.js +0 -14
- package/dist/components/pagination-store.js.map +0 -1
- package/dist/esm/app-globals-iHhGdwBB.js +0 -8
- package/dist/esm/app-globals-iHhGdwBB.js.map +0 -1
- package/dist/esm/component-utils-BGq0leDV.js +0 -39
- package/dist/esm/component-utils-BGq0leDV.js.map +0 -1
- package/dist/esm/index-BVlbCQEX.js.map +0 -1
- package/dist/esm/index-FTKB5a1d.js.map +0 -1
- package/dist/esm/newsletter-helpers-fCpxzovf.js.map +0 -1
- package/dist/esm/newsletter-store-BB618FgS.js.map +0 -1
- package/dist/esm/pagination-store-DxmcQH8R.js +0 -14
- package/dist/esm/pagination-store-DxmcQH8R.js.map +0 -1
- package/dist/sdk/p-1a8973a6.entry.js +0 -2
- package/dist/sdk/p-35ad60ab.entry.js +0 -2
- package/dist/sdk/p-35ad60ab.entry.js.map +0 -1
- package/dist/sdk/p-3f352f38.entry.js +0 -2
- package/dist/sdk/p-3f352f38.entry.js.map +0 -1
- package/dist/sdk/p-468aaf62.entry.js +0 -2
- package/dist/sdk/p-468aaf62.entry.js.map +0 -1
- package/dist/sdk/p-4e2e6a13.entry.js +0 -2
- package/dist/sdk/p-4e2e6a13.entry.js.map +0 -1
- package/dist/sdk/p-57c8dc68.entry.js +0 -2
- package/dist/sdk/p-57c8dc68.entry.js.map +0 -1
- package/dist/sdk/p-594aec0c.entry.js +0 -2
- package/dist/sdk/p-594aec0c.entry.js.map +0 -1
- package/dist/sdk/p-60c8be64.entry.js +0 -2
- package/dist/sdk/p-60c8be64.entry.js.map +0 -1
- package/dist/sdk/p-760718d3.entry.js +0 -2
- package/dist/sdk/p-760718d3.entry.js.map +0 -1
- package/dist/sdk/p-77f541f3.entry.js +0 -2
- package/dist/sdk/p-77f541f3.entry.js.map +0 -1
- package/dist/sdk/p-830778eb.entry.js +0 -2
- package/dist/sdk/p-8839648e.entry.js +0 -2
- package/dist/sdk/p-8839648e.entry.js.map +0 -1
- package/dist/sdk/p-B6MYe-dh.js +0 -2
- package/dist/sdk/p-B6MYe-dh.js.map +0 -1
- package/dist/sdk/p-BGq0leDV.js +0 -2
- package/dist/sdk/p-BGq0leDV.js.map +0 -1
- package/dist/sdk/p-C_UZBwdm.js +0 -2
- package/dist/sdk/p-C_UZBwdm.js.map +0 -1
- package/dist/sdk/p-CbazSxaZ.js +0 -2
- package/dist/sdk/p-CbazSxaZ.js.map +0 -1
- package/dist/sdk/p-DCG3L43i.js +0 -2
- package/dist/sdk/p-DEUPZOH-.js +0 -2
- package/dist/sdk/p-DEUPZOH-.js.map +0 -1
- package/dist/sdk/p-DSktNM_k.js +0 -2
- package/dist/sdk/p-FTKB5a1d.js +0 -14
- package/dist/sdk/p-FTKB5a1d.js.map +0 -1
- package/dist/sdk/p-a7ffcff9.entry.js +0 -2
- package/dist/sdk/p-a7ffcff9.entry.js.map +0 -1
- package/dist/sdk/p-acaba1d5.entry.js +0 -2
- package/dist/sdk/p-acaba1d5.entry.js.map +0 -1
- package/dist/sdk/p-ae47a7a3.entry.js +0 -2
- package/dist/sdk/p-ae47a7a3.entry.js.map +0 -1
- package/dist/sdk/p-aec580e4.entry.js +0 -2
- package/dist/sdk/p-aec580e4.entry.js.map +0 -1
- package/dist/sdk/p-b63438ff.entry.js +0 -2
- package/dist/sdk/p-b63438ff.entry.js.map +0 -1
- package/dist/sdk/p-baaaa7f5.entry.js +0 -2
- package/dist/sdk/p-baaaa7f5.entry.js.map +0 -1
- package/dist/sdk/p-bba2da84.entry.js +0 -2
- package/dist/sdk/p-bba2da84.entry.js.map +0 -1
- package/dist/sdk/p-bc47f42b.entry.js +0 -2
- package/dist/sdk/p-bc47f42b.entry.js.map +0 -1
- package/dist/sdk/p-bd51e26f.entry.js +0 -2
- package/dist/sdk/p-bd51e26f.entry.js.map +0 -1
- package/dist/sdk/p-c3552f75.entry.js +0 -2
- package/dist/sdk/p-c3552f75.entry.js.map +0 -1
- package/dist/sdk/p-d9900482.entry.js +0 -2
- package/dist/sdk/p-d9900482.entry.js.map +0 -1
- package/dist/sdk/p-e6796c38.entry.js +0 -2
- package/dist/sdk/p-e6796c38.entry.js.map +0 -1
- package/dist/sdk/p-f272eb38.entry.js +0 -2
- package/dist/sdk/p-f272eb38.entry.js.map +0 -1
- package/dist/sdk/p-f4a47ef8.entry.js +0 -2
- package/dist/sdk/p-f4a47ef8.entry.js.map +0 -1
- package/dist/sdk/p-f608e64a.entry.js +0 -2
- package/dist/sdk/p-f608e64a.entry.js.map +0 -1
- package/dist/sdk/p-f762ac70.entry.js +0 -2
- package/dist/sdk/p-f762ac70.entry.js.map +0 -1
- package/dist/sdk/p-l6NinBiD.js +0 -2
- package/dist/sdk/p-l6NinBiD.js.map +0 -1
- /package/dist/sdk/{p-88beb872.entry.js.map → p-8412762c.entry.js.map} +0 -0
- /package/dist/sdk/{p-bcca06f1.entry.js.map → p-96860b09.entry.js.map} +0 -0
- /package/dist/sdk/{p-7ee2f2ab.entry.js.map → p-ac3a6bbf.entry.js.map} +0 -0
- /package/dist/sdk/{p-6b061b18.entry.js.map → p-b99588a8.entry.js.map} +0 -0
- /package/dist/sdk/{p-10e20afd.entry.js.map → p-c2634439.entry.js.map} +0 -0
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Mixin } from '@stencil/core/internal/client';
|
|
2
|
-
|
|
3
1
|
const DEFAULT_LOG_LEVEL = "info";
|
|
4
2
|
const LOG_LEVELS = {
|
|
5
3
|
trace: 4,
|
|
@@ -41,42 +39,6 @@ const createLogger = (prefix) => {
|
|
|
41
39
|
return logger;
|
|
42
40
|
}, {});
|
|
43
41
|
};
|
|
44
|
-
/**
|
|
45
|
-
* Stencil mixin factory that adds a logger property to the component.
|
|
46
|
-
* The logger automatically uses the component's class name as the prefix.
|
|
47
|
-
*/
|
|
48
|
-
// biome-ignore lint/suspicious/noExplicitAny: if we have no Base we have to invent one
|
|
49
|
-
const loggerFactory = (Base = Object) => {
|
|
50
|
-
class LoggerMixin extends Base {
|
|
51
|
-
/** @internal */
|
|
52
|
-
__logger = null;
|
|
53
|
-
get logger() {
|
|
54
|
-
if (!this.__logger) {
|
|
55
|
-
this.__logger = createLogger(this.constructor.name);
|
|
56
|
-
}
|
|
57
|
-
return this.__logger;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return LoggerMixin;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Base class for Unidy Stencil components that provides logging functionality.
|
|
64
|
-
* Components extending this class get a `this.logger` property that automatically
|
|
65
|
-
* prefixes log messages with the component's class name.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```tsx
|
|
69
|
-
* import { UnidyComponent } from '../logger';
|
|
70
|
-
*
|
|
71
|
-
* @Component({ tag: 'my-component' })
|
|
72
|
-
* export class MyComponent extends UnidyComponent {
|
|
73
|
-
* componentDidLoad() {
|
|
74
|
-
* this.logger.debug('Component loaded');
|
|
75
|
-
* }
|
|
76
|
-
* }
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
const UnidyComponent = Mixin(loggerFactory);
|
|
80
42
|
// Global logger for non-class contexts (backwards compatibility)
|
|
81
43
|
const logger = createLogger("");
|
|
82
44
|
// biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case
|
|
@@ -105,7 +67,7 @@ const i18nLogger = {
|
|
|
105
67
|
},
|
|
106
68
|
};
|
|
107
69
|
|
|
108
|
-
export {
|
|
70
|
+
export { createLogger as c, i18nLogger as i, logger as l };
|
|
109
71
|
//# sourceMappingURL=logger.js.map
|
|
110
72
|
|
|
111
73
|
//# sourceMappingURL=logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"logger.js","mappings":"
|
|
1
|
+
{"file":"logger.js","mappings":"AAUA,MAAM,iBAAiB,GAAa,MAAM;AAE1C,MAAM,UAAU,GAA6B;AAC3C,IAAA,KAAK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,MAAM,EAAE,OAAO,CAAC;KAC7B;;;;;","names":[],"sources":["src/logger.ts"],"sourcesContent":["import type { LoggerModule } from \"i18next\";\n\ndeclare global {\n interface Window {\n setLogLevel: (level: LogLevel) => void;\n }\n}\n\ntype LogLevel = \"error\" | \"warn\" | \"info\" | \"debug\" | \"trace\";\n\nconst DEFAULT_LOG_LEVEL: LogLevel = \"info\";\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n trace: 4,\n debug: 3,\n info: 2,\n warn: 1,\n error: 0,\n};\n\nconst getLogLevel = (): LogLevel => {\n if (typeof window === \"undefined\") {\n return DEFAULT_LOG_LEVEL;\n }\n return (localStorage.getItem(\"unidy_log_level\") as LogLevel) || DEFAULT_LOG_LEVEL;\n};\n\nconst setLogLevel = (level: LogLevel) => {\n if (typeof window !== \"undefined\") {\n localStorage.setItem(\"unidy_log_level\", level);\n }\n};\n\nif (typeof window !== \"undefined\") {\n window.setLogLevel = setLogLevel;\n}\n\nconst canLog = (level: LogLevel) => LOG_LEVELS[getLogLevel()] >= LOG_LEVELS[level];\n\n// biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\nconst log = (level: LogLevel, prefix: string, ...args: any[]) => {\n if (canLog(level)) {\n const prefixedArgs = prefix ? [`[${prefix}]`, ...args] : args;\n console[level](...prefixedArgs);\n }\n};\n\nexport interface Logger {\n // biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\n error: (...args: any[]) => void;\n // biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\n warn: (...args: any[]) => void;\n // biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\n info: (...args: any[]) => void;\n // biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\n debug: (...args: any[]) => void;\n // biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\n trace: (...args: any[]) => void;\n}\n\nconst LOG_METHODS: LogLevel[] = [\"error\", \"warn\", \"info\", \"debug\", \"trace\"];\n\n/**\n * Creates a logger instance with a specific prefix (typically class/component name)\n */\nexport const createLogger = (prefix: string): Logger => {\n return LOG_METHODS.reduce((logger, level) => {\n // biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\n logger[level] = (...args: any[]) => log(level, prefix, ...args);\n return logger;\n }, {} as Logger);\n};\n\n// Global logger for non-class contexts (backwards compatibility)\nexport const logger = createLogger(\"\");\n\n// biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\nconst formatI18nMessage = (args: any[]): { prefix: string; message: string } => {\n const [caller_action, ...messages] = args;\n const [caller, action] = caller_action.split(\": \");\n const message = typeof messages[0] === \"object\" ? action : `${action}: ${messages.join(\" \")}`;\n return { prefix: caller || \"i18next\", message };\n};\n\nexport const i18nLogger: LoggerModule = {\n type: \"logger\",\n // biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\n error: (args: any[]) => {\n const { prefix, message } = formatI18nMessage(args);\n log(\"error\", prefix, message);\n },\n // biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\n warn: (args: any[]) => {\n const { prefix, message } = formatI18nMessage(args);\n log(\"warn\", prefix, message);\n },\n // biome-ignore lint/suspicious/noExplicitAny: External interfaces require the use of any in this case\n log: (args: any[]) => {\n const { prefix, message } = formatI18nMessage(args);\n log(\"info\", prefix, message);\n },\n};\n"],"version":3}
|
|
@@ -5,6 +5,24 @@ import { F as Flash } from './flash-store.js';
|
|
|
5
5
|
import { n as newsletterStore, p as persist } from './newsletter-store.js';
|
|
6
6
|
|
|
7
7
|
const logger = createLogger("NewsletterHelpers");
|
|
8
|
+
function buildAdditionalFieldsPayload(additionalFields) {
|
|
9
|
+
const payload = {};
|
|
10
|
+
for (const [key, node] of Object.entries(additionalFields)) {
|
|
11
|
+
if (node.value === undefined || node.value === null || (typeof node.value === "string" && node.value.trim() === ""))
|
|
12
|
+
continue;
|
|
13
|
+
if (key.startsWith("custom_attributes.")) {
|
|
14
|
+
// custom attributes
|
|
15
|
+
const attrKey = key.replace("custom_attributes.", "");
|
|
16
|
+
payload.custom_attributes = payload.custom_attributes || {};
|
|
17
|
+
payload.custom_attributes[attrKey] = node.value;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
// standard user attributes
|
|
21
|
+
payload[key] = node.value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return payload;
|
|
25
|
+
}
|
|
8
26
|
const PERSIST_KEY_PREFIX = "unidy_newsletter_";
|
|
9
27
|
function newsletterLogout() {
|
|
10
28
|
newsletterStore.state.preferenceToken = "";
|
|
@@ -38,15 +56,19 @@ async function sendLoginEmail(email) {
|
|
|
38
56
|
});
|
|
39
57
|
if (error === null) {
|
|
40
58
|
Flash.info.addMessage(t("newsletter.success.login_email_sent"));
|
|
59
|
+
return { success: true };
|
|
41
60
|
}
|
|
42
61
|
else if (error === "rate_limit_exceeded") {
|
|
43
62
|
Flash.error.addMessage(t("newsletter.errors.rate_limit_exceeded", { defaultValue: "Too many requests. Please try again later." }));
|
|
63
|
+
return { success: false, error: "rate_limit_exceeded" };
|
|
44
64
|
}
|
|
45
65
|
else if (error === "not_found") {
|
|
46
66
|
Flash.error.addMessage(t("newsletter.errors.login_email_not_found", { defaultValue: "Email address not found" }));
|
|
67
|
+
return { success: false, error: "not_found" };
|
|
47
68
|
}
|
|
48
69
|
else {
|
|
49
70
|
Flash.error.addMessage(t("errors.unknown", { defaultValue: "An unknown error occurred" }));
|
|
71
|
+
return { success: false, error: "unknown" };
|
|
50
72
|
}
|
|
51
73
|
}
|
|
52
74
|
async function fetchSubscriptions() {
|
|
@@ -99,7 +121,8 @@ async function handleAlreadySubscribedError(email, errors) {
|
|
|
99
121
|
}
|
|
100
122
|
}
|
|
101
123
|
async function handleCreateSubscriptionRequest(email, internalNames, showSuccessMessage = true) {
|
|
102
|
-
const { checkedNewsletters } = newsletterStore.state;
|
|
124
|
+
const { checkedNewsletters, additionalFields } = newsletterStore.state;
|
|
125
|
+
const additionalFieldsPayload = buildAdditionalFieldsPayload(additionalFields);
|
|
103
126
|
const [error, response] = await getUnidyClient().newsletters.create({
|
|
104
127
|
payload: {
|
|
105
128
|
email,
|
|
@@ -108,6 +131,7 @@ async function handleCreateSubscriptionRequest(email, internalNames, showSuccess
|
|
|
108
131
|
preference_identifiers: checkedNewsletters[newsletter] || [],
|
|
109
132
|
})),
|
|
110
133
|
redirect_to_after_confirmation: redirectToAfterConfirmationUrl(),
|
|
134
|
+
...(Object.keys(additionalFieldsPayload).length > 0 && { additional_fields: additionalFieldsPayload }),
|
|
111
135
|
},
|
|
112
136
|
});
|
|
113
137
|
if (error === null && response && "results" in response) {
|
|
@@ -132,6 +156,7 @@ async function handleCreateSubscriptionRequest(email, internalNames, showSuccess
|
|
|
132
156
|
if (error === "newsletter_error" && response) {
|
|
133
157
|
const errors = response.errors || [];
|
|
134
158
|
const errorMap = {};
|
|
159
|
+
const additionalFieldErrors = {};
|
|
135
160
|
// special error case which is handled differently: if user is not authenticated, we send a login email, otherwise we add the
|
|
136
161
|
// already_subscribed subscriptions to the existing subscriptions
|
|
137
162
|
const hasAlreadySubscribedError = errors.some((err) => err.error_identifier === "already_subscribed");
|
|
@@ -143,15 +168,27 @@ async function handleCreateSubscriptionRequest(email, internalNames, showSuccess
|
|
|
143
168
|
errorMap.general = "newsletter_not_found";
|
|
144
169
|
}
|
|
145
170
|
const hasInvalidEmailError = errors.some((err) => err.error_identifier === "validation_error" && err.error_details && "email" in err.error_details);
|
|
171
|
+
const userValidationErrors = errors.filter((err) => err.error_identifier === "user_validation_error" && err.error_details);
|
|
172
|
+
for (const err of userValidationErrors) {
|
|
173
|
+
for (const [field, messages] of Object.entries(err.error_details || {})) {
|
|
174
|
+
if (Array.isArray(messages) && messages.length > 0) {
|
|
175
|
+
additionalFieldErrors[field] = messages[0];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
146
179
|
if (hasInvalidEmailError) {
|
|
147
180
|
errorMap.email = "invalid_email";
|
|
148
181
|
}
|
|
149
182
|
else {
|
|
150
183
|
for (const err of errors) {
|
|
184
|
+
// Skip user_validation_error - handled via additionalFieldErrors
|
|
185
|
+
if (err.error_identifier === "user_validation_error")
|
|
186
|
+
continue;
|
|
151
187
|
errorMap[err.meta.newsletter_internal_name] = err.error_identifier;
|
|
152
188
|
}
|
|
153
189
|
}
|
|
154
190
|
newsletterStore.state.errors = errorMap;
|
|
191
|
+
newsletterStore.state.additionalFieldErrors = additionalFieldErrors;
|
|
155
192
|
}
|
|
156
193
|
else {
|
|
157
194
|
Flash.error.addMessage(t("errors.unknown", { defaultValue: "An unknown error occurred" }));
|
|
@@ -163,7 +200,7 @@ async function subscribeToNewsletter(internalName, email) {
|
|
|
163
200
|
}
|
|
164
201
|
async function createSubscriptions({ email }) {
|
|
165
202
|
const internalNames = Object.keys(newsletterStore.state.checkedNewsletters);
|
|
166
|
-
|
|
203
|
+
return handleCreateSubscriptionRequest(email, internalNames, true);
|
|
167
204
|
}
|
|
168
205
|
async function deleteSubscription(internalName) {
|
|
169
206
|
const { preferenceToken } = newsletterStore.state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"newsletter-helpers.js","mappings":";;;;;;AAYA,MAAM,MAAM,GAAG,YAAY,CAAC,mBAAmB,CAAC;AAEhD,MAAM,kBAAkB,GAAG,mBAAmB;SAE9B,gBAAgB,GAAA;AAC9B,IAAA,eAAe,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE;AAC1C,IAAA,eAAe,CAAC,KAAK,CAAC,qBAAqB,GAAG,EAAE;AAChD,IAAA,cAAc,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAA,eAAA,CAAiB,CAAC;AACjE,IAAA,cAAc,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAA,KAAA,CAAO,CAAC;AACzD;AAEO,eAAe,SAAS,CAAC,YAAoB,EAAA;AAClD,IAAA,MAAM,EAAE,eAAe,EAAE,GAAG,eAAe,CAAC,KAAK;IAEjD,MAAM,CAAC,KA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AAA,OAAO,KAAK;;IAGd,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,IAAI,wBAAwB,IAAI,IAAI,EAAE;;QAE9D,MAAM,iBAAiB,GAAG,eAAe,CAAC,KAAK,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,wBAAwB,KAAK,YAAY,CAAC;AAEvI,QAAA,IAAI,iBAAiB,KAAK,EAAE,EAAE;YAC5B,MAAM,oBAAoB,GAAG,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,qBAAqB,CAAC;YAC7E,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;gBACxC,GAAG,oBAAoB,CAAC,iBAAiB,CAAC;AAC1C,gBAAA,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,IAAI,EAAE;aAC1D;AACD,YAAA,eAAe,CAAC,KAAK,CAAC,qBAAqB,GAAG,oBAAoB;;QAGpE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC;AACrE,QAAA,OAAO,IAAI;;AAGb,IAAA,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,EAAE,EAAE,YAAY,EAAE,2BAA2B,EAAE,CAAC,CAAC;AAC1F,IAAA,OAAO,KAAK;AACd;;;;","names":[],"sources":["src/newsletter/newsletter-helpers.ts"],"sourcesContent":["import { getUnidyClient } from \"../api\";\nimport { t } from \"../i18n\";\nimport { createLogger } from \"../logger\";\nimport { Flash } from \"../shared/store/flash-store\";\nimport {\n type CheckedNewsletters,\n type ExistingSubscription,\n type NewsletterErrorIdentifier,\n newsletterStore,\n persist,\n} from \"./store/newsletter-store\";\n\nconst logger = createLogger(\"NewsletterHelpers\");\n\nconst PERSIST_KEY_PREFIX = \"unidy_newsletter_\";\n\nexport function newsletterLogout(): void {\n newsletterStore.state.preferenceToken = \"\";\n newsletterStore.state.existingSubscriptions = [];\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}preferenceToken`);\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}email`);\n}\n\nexport async function resendDoi(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n const [error] = await getUnidyClient().newsletters.resendDoi({\n internalName,\n payload: { redirect_to_after_confirmation: redirectToAfterConfirmationUrl() },\n options: preferenceToken ? { preferenceToken } : undefined,\n });\n\n if (error === null) {\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n return false;\n}\n\nexport async function sendLoginEmail(email: string): Promise<void> {\n const [error] = await getUnidyClient().newsletters.sendLoginEmail({\n payload: {\n email,\n redirect_uri: redirectToAfterConfirmationUrl(),\n },\n });\n\n if (error === null) {\n Flash.info.addMessage(t(\"newsletter.success.login_email_sent\"));\n } else if (error === \"rate_limit_exceeded\") {\n Flash.error.addMessage(t(\"newsletter.errors.rate_limit_exceeded\", { defaultValue: \"Too many requests. Please try again later.\" }));\n } else if (error === \"not_found\") {\n Flash.error.addMessage(t(\"newsletter.errors.login_email_not_found\", { defaultValue: \"Email address not found\" }));\n } else {\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n }\n}\n\nexport async function fetchSubscriptions(): Promise<void> {\n const { preferenceToken } = newsletterStore.state;\n\n // either preference token is needed or the user must be authenticated\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to fetch subscriptions\");\n return;\n }\n\n newsletterStore.state.fetchingSubscriptions = true;\n\n const [error, data] = await getUnidyClient().newsletters.list({\n options: preferenceToken ? { preferenceToken } : undefined,\n });\n\n newsletterStore.state.fetchingSubscriptions = false;\n\n if (error === \"unauthorized\") {\n newsletterLogout();\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n return;\n }\n\n if (error === null && data && Array.isArray(data)) {\n newsletterStore.state.existingSubscriptions = data.map(\n (sub): ExistingSubscription => ({\n newsletter_internal_name: sub.newsletter_internal_name,\n confirmed: sub.confirmed_at !== null,\n preference_identifiers: sub.preference_identifiers || [],\n }),\n );\n\n // init checked newsletters and preferences\n const checkedNewsletters: CheckedNewsletters = { ...newsletterStore.state.checkedNewsletters };\n for (const sub of data) {\n checkedNewsletters[sub.newsletter_internal_name] = [...(sub.preference_identifiers || [])];\n }\n newsletterStore.state.checkedNewsletters = checkedNewsletters;\n }\n}\n\nasync function handleAlreadySubscribedError(\n email: string,\n errors: Array<{ error_identifier: string; meta: { newsletter_internal_name: string } }>,\n): Promise<void> {\n if (newsletterStore.state.isAuthenticated || newsletterStore.state.preferenceToken) {\n const existingNames = new Set(newsletterStore.state.existingSubscriptions.map((s) => s.newsletter_internal_name));\n\n const newSubscriptions: ExistingSubscription[] = errors\n .filter((err) => err.error_identifier === \"already_subscribed\" && !existingNames.has(err.meta.newsletter_internal_name))\n .map((err) => ({\n newsletter_internal_name: err.meta.newsletter_internal_name,\n confirmed: false, // We don't know the confirmation status for already_subscribed errors\n preference_identifiers: [],\n }));\n\n if (newSubscriptions.length > 0) {\n newsletterStore.state.existingSubscriptions = [...newsletterStore.state.existingSubscriptions, ...newSubscriptions];\n }\n } else {\n await sendLoginEmail(email);\n }\n}\n\nasync function handleCreateSubscriptionRequest(email: string, internalNames: string[], showSuccessMessage = true): Promise<boolean> {\n const { checkedNewsletters } = newsletterStore.state;\n\n const [error, response] = await getUnidyClient().newsletters.create({\n payload: {\n email,\n newsletter_subscriptions: internalNames.map((newsletter) => ({\n newsletter_internal_name: newsletter,\n preference_identifiers: checkedNewsletters[newsletter] || [],\n })),\n redirect_to_after_confirmation: redirectToAfterConfirmationUrl(),\n },\n });\n\n if (error === null && response && \"results\" in response) {\n if (response.results.length > 0) {\n const newSubscriptions: ExistingSubscription[] = response.results.map((result) => ({\n newsletter_internal_name: result.newsletter_internal_name,\n confirmed: result.confirmed_at !== null,\n preference_identifiers: result.preference_identifiers || [],\n }));\n\n newsletterStore.state.existingSubscriptions = [...newsletterStore.state.existingSubscriptions, ...newSubscriptions];\n }\n\n if (showSuccessMessage) {\n Flash.success.addMessage(t(\"newsletter.success.subscribe\"));\n }\n\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === \"newsletter_error\" && response) {\n const errors = response.errors || [];\n const errorMap: Record<string, NewsletterErrorIdentifier> = {};\n\n // special error case which is handled differently: if user is not authenticated, we send a login email, otherwise we add the\n // already_subscribed subscriptions to the existing subscriptions\n const hasAlreadySubscribedError = errors.some((err) => err.error_identifier === \"already_subscribed\");\n if (hasAlreadySubscribedError) {\n await handleAlreadySubscribedError(email, errors);\n }\n\n const newsletterNotFoundError = errors.some((err) => err.error_identifier === \"newsletter_not_found\");\n if (newsletterNotFoundError) {\n errorMap.general = \"newsletter_not_found\";\n }\n\n const hasInvalidEmailError = errors.some(\n (err) => err.error_identifier === \"validation_error\" && err.error_details && \"email\" in err.error_details,\n );\n\n if (hasInvalidEmailError) {\n errorMap.email = \"invalid_email\";\n } else {\n for (const err of errors) {\n errorMap[err.meta.newsletter_internal_name] = err.error_identifier as NewsletterErrorIdentifier;\n }\n }\n\n newsletterStore.state.errors = errorMap;\n } else {\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n }\n\n return false;\n}\n\nexport async function subscribeToNewsletter(internalName: string, email: string): Promise<boolean> {\n return handleCreateSubscriptionRequest(email, [internalName], false);\n}\n\nexport async function createSubscriptions({ email }: { email: string }): Promise<void> {\n const internalNames = Object.keys(newsletterStore.state.checkedNewsletters);\n await handleCreateSubscriptionRequest(email, internalNames, true);\n}\n\nexport async function deleteSubscription(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n // either preference token is needed or the user must be authenticated to delete a subscription\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to delete a subscription\");\n return false;\n }\n\n const [error, data] = await getUnidyClient().newsletters.delete({\n internalName,\n options: preferenceToken ? { preferenceToken } : undefined,\n });\n\n if (error === null) {\n if (data && \"new_preference_token\" in data) {\n // if user is not authenticated, we need to store the new preference token which is used for the next request\n if (!newsletterStore.state.isAuthenticated) {\n newsletterStore.state.preferenceToken = data.new_preference_token;\n persist(\"preferenceToken\");\n }\n }\n\n newsletterStore.state.existingSubscriptions = newsletterStore.state.existingSubscriptions.filter(\n (sub) => sub.newsletter_internal_name !== internalName,\n );\n\n // Reset checked preferences to defaults (preferences marked with checked='true')\n const defaultPrefs = newsletterStore.state.defaultPreferences[internalName];\n newsletterStore.state.checkedNewsletters = {\n ...newsletterStore.state.checkedNewsletters,\n [internalName]: defaultPrefs ? [...defaultPrefs] : [],\n };\n\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === \"not_found\") {\n return false;\n }\n\n // 422 Unprocessable Entity - silently fail (e.g., trying to delete something that can't be deleted)\n if (error === \"unprocessable_entity\") {\n return false;\n }\n\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n return false;\n}\n\nexport function getSubscription(internalName: string): ExistingSubscription | undefined {\n return newsletterStore.state.existingSubscriptions.find((sub) => sub.newsletter_internal_name === internalName);\n}\n\nexport function isSubscribed(internalName: string): boolean {\n return newsletterStore.state.existingSubscriptions.some((sub) => sub.newsletter_internal_name === internalName);\n}\n\nexport function isConfirmed(internalName: string): boolean {\n const sub = getSubscription(internalName);\n return sub?.confirmed ?? false;\n}\n\nfunction redirectToAfterConfirmationUrl(): string {\n const baseUrl = `${location.origin}${location.pathname}`;\n const params = new URLSearchParams(location.search);\n for (const key of [\"email\", \"newsletter_error\"]) {\n params.delete(key);\n }\n const queryString = params.toString();\n return queryString ? `${baseUrl}?${queryString}` : baseUrl;\n}\n\nexport function getSubscriptionPreferences(internalName: string): string[] {\n const subscription = getSubscription(internalName);\n return subscription?.preference_identifiers || [];\n}\n\nexport async function updateSubscriptionPreferences(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n // Either preference token is needed or the user must be authenticated\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to update subscription preferences\");\n return false;\n }\n\n // Check if the subscription exists\n if (!isSubscribed(internalName)) {\n logger.error(`Cannot update preferences: not subscribed to newsletter '${internalName}'`);\n return false;\n }\n\n const preferenceIdentifiers = newsletterStore.state.checkedNewsletters[internalName] || [];\n\n const [error, data] = await getUnidyClient().newsletters.update({\n internalName,\n payload: { preference_identifiers: preferenceIdentifiers },\n options: preferenceToken ? { preferenceToken } : undefined,\n });\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === null && data && \"preference_identifiers\" in data) {\n // Update the local subscription with the new preferences\n const subscriptionIndex = newsletterStore.state.existingSubscriptions.findIndex((sub) => sub.newsletter_internal_name === internalName);\n\n if (subscriptionIndex !== -1) {\n const updatedSubscriptions = [...newsletterStore.state.existingSubscriptions];\n updatedSubscriptions[subscriptionIndex] = {\n ...updatedSubscriptions[subscriptionIndex],\n preference_identifiers: data.preference_identifiers || [],\n };\n newsletterStore.state.existingSubscriptions = updatedSubscriptions;\n }\n\n Flash.success.addMessage(t(\"newsletter.success.preferences_updated\"));\n return true;\n }\n\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n return false;\n}\n"],"version":3}
|
|
1
|
+
{"file":"newsletter-helpers.js","mappings":";;;;;;AAaA,MAAM,MAAM,GAAG,YAAY,CAAC,mBAAmB,CAAC;AAEhD,SAAS,4BAA4B,CAAC,gBAAsC,EAAA;IAC1E,MAAM,OAAO,GAA4B,EAAE;AAE3C,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC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AAqB,CAAC;YAC7E,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;gBACxC,GAAG,oBAAoB,CAAC,iBAAiB,CAAC;AAC1C,gBAAA,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,IAAI,EAAE;aAC1D;AACD,YAAA,eAAe,CAAC,KAAK,CAAC,qBAAqB,GAAG,oBAAoB;;QAGpE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC;AACrE,QAAA,OAAO,IAAI;;AAGb,IAAA,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,EAAE,EAAE,YAAY,EAAE,2BAA2B,EAAE,CAAC,CAAC;AAC1F,IAAA,OAAO,KAAK;AACd;;;;","names":[],"sources":["src/newsletter/newsletter-helpers.ts"],"sourcesContent":["import { getUnidyClient } from \"../api\";\nimport { t } from \"../i18n\";\nimport { createLogger } from \"../logger\";\nimport { Flash } from \"../shared/store/flash-store\";\nimport {\n type AdditionalFieldsData,\n type CheckedNewsletters,\n type ExistingSubscription,\n type NewsletterErrorIdentifier,\n newsletterStore,\n persist,\n} from \"./store/newsletter-store\";\n\nconst logger = createLogger(\"NewsletterHelpers\");\n\nfunction buildAdditionalFieldsPayload(additionalFields: AdditionalFieldsData): Record<string, unknown> {\n const payload: Record<string, unknown> = {};\n\n for (const [key, node] of Object.entries(additionalFields)) {\n if (node.value === undefined || node.value === null || (typeof node.value === \"string\" && node.value.trim() === \"\")) continue;\n\n if (key.startsWith(\"custom_attributes.\")) {\n // custom attributes\n const attrKey = key.replace(\"custom_attributes.\", \"\");\n payload.custom_attributes = payload.custom_attributes || {};\n (payload.custom_attributes as Record<string, unknown>)[attrKey] = node.value;\n } else {\n // standard user attributes\n payload[key] = node.value;\n }\n }\n\n return payload;\n}\n\nconst PERSIST_KEY_PREFIX = \"unidy_newsletter_\";\n\nexport function newsletterLogout(): void {\n newsletterStore.state.preferenceToken = \"\";\n newsletterStore.state.existingSubscriptions = [];\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}preferenceToken`);\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}email`);\n}\n\nexport async function resendDoi(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n const [error] = await getUnidyClient().newsletters.resendDoi({\n internalName,\n payload: { redirect_to_after_confirmation: redirectToAfterConfirmationUrl() },\n options: preferenceToken ? { preferenceToken } : undefined,\n });\n\n if (error === null) {\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n return false;\n}\n\nexport type LoginEmailResult = { success: true } | { success: false; error: \"rate_limit_exceeded\" | \"not_found\" | \"unknown\" };\n\nexport async function sendLoginEmail(email: string): Promise<LoginEmailResult> {\n const [error] = await getUnidyClient().newsletters.sendLoginEmail({\n payload: {\n email,\n redirect_uri: redirectToAfterConfirmationUrl(),\n },\n });\n\n if (error === null) {\n Flash.info.addMessage(t(\"newsletter.success.login_email_sent\"));\n return { success: true };\n } else if (error === \"rate_limit_exceeded\") {\n Flash.error.addMessage(t(\"newsletter.errors.rate_limit_exceeded\", { defaultValue: \"Too many requests. Please try again later.\" }));\n return { success: false, error: \"rate_limit_exceeded\" };\n } else if (error === \"not_found\") {\n Flash.error.addMessage(t(\"newsletter.errors.login_email_not_found\", { defaultValue: \"Email address not found\" }));\n return { success: false, error: \"not_found\" };\n } else {\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n return { success: false, error: \"unknown\" };\n }\n}\n\nexport async function fetchSubscriptions(): Promise<void> {\n const { preferenceToken } = newsletterStore.state;\n\n // either preference token is needed or the user must be authenticated\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to fetch subscriptions\");\n return;\n }\n\n newsletterStore.state.fetchingSubscriptions = true;\n\n const [error, data] = await getUnidyClient().newsletters.list({\n options: preferenceToken ? { preferenceToken } : undefined,\n });\n\n newsletterStore.state.fetchingSubscriptions = false;\n\n if (error === \"unauthorized\") {\n newsletterLogout();\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n return;\n }\n\n if (error === null && data && Array.isArray(data)) {\n newsletterStore.state.existingSubscriptions = data.map(\n (sub): ExistingSubscription => ({\n newsletter_internal_name: sub.newsletter_internal_name,\n confirmed: sub.confirmed_at !== null,\n preference_identifiers: sub.preference_identifiers || [],\n }),\n );\n\n // init checked newsletters and preferences\n const checkedNewsletters: CheckedNewsletters = { ...newsletterStore.state.checkedNewsletters };\n for (const sub of data) {\n checkedNewsletters[sub.newsletter_internal_name] = [...(sub.preference_identifiers || [])];\n }\n newsletterStore.state.checkedNewsletters = checkedNewsletters;\n }\n}\n\nasync function handleAlreadySubscribedError(\n email: string,\n errors: Array<{ error_identifier: string; meta: { newsletter_internal_name: string } }>,\n): Promise<void> {\n if (newsletterStore.state.isAuthenticated || newsletterStore.state.preferenceToken) {\n const existingNames = new Set(newsletterStore.state.existingSubscriptions.map((s) => s.newsletter_internal_name));\n\n const newSubscriptions: ExistingSubscription[] = errors\n .filter((err) => err.error_identifier === \"already_subscribed\" && !existingNames.has(err.meta.newsletter_internal_name))\n .map((err) => ({\n newsletter_internal_name: err.meta.newsletter_internal_name,\n confirmed: false, // We don't know the confirmation status for already_subscribed errors\n preference_identifiers: [],\n }));\n\n if (newSubscriptions.length > 0) {\n newsletterStore.state.existingSubscriptions = [...newsletterStore.state.existingSubscriptions, ...newSubscriptions];\n }\n } else {\n await sendLoginEmail(email);\n }\n}\n\nasync function handleCreateSubscriptionRequest(email: string, internalNames: string[], showSuccessMessage = true): Promise<boolean> {\n const { checkedNewsletters, additionalFields } = newsletterStore.state;\n\n const additionalFieldsPayload = buildAdditionalFieldsPayload(additionalFields);\n\n const [error, response] = await getUnidyClient().newsletters.create({\n payload: {\n email,\n newsletter_subscriptions: internalNames.map((newsletter) => ({\n newsletter_internal_name: newsletter,\n preference_identifiers: checkedNewsletters[newsletter] || [],\n })),\n redirect_to_after_confirmation: redirectToAfterConfirmationUrl(),\n ...(Object.keys(additionalFieldsPayload).length > 0 && { additional_fields: additionalFieldsPayload }),\n },\n });\n\n if (error === null && response && \"results\" in response) {\n if (response.results.length > 0) {\n const newSubscriptions: ExistingSubscription[] = response.results.map((result) => ({\n newsletter_internal_name: result.newsletter_internal_name,\n confirmed: result.confirmed_at !== null,\n preference_identifiers: result.preference_identifiers || [],\n }));\n\n newsletterStore.state.existingSubscriptions = [...newsletterStore.state.existingSubscriptions, ...newSubscriptions];\n }\n\n if (showSuccessMessage) {\n Flash.success.addMessage(t(\"newsletter.success.subscribe\"));\n }\n\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === \"newsletter_error\" && response) {\n const errors = response.errors || [];\n const errorMap: Record<string, NewsletterErrorIdentifier> = {};\n const additionalFieldErrors: Record<string, string> = {};\n\n // special error case which is handled differently: if user is not authenticated, we send a login email, otherwise we add the\n // already_subscribed subscriptions to the existing subscriptions\n const hasAlreadySubscribedError = errors.some((err) => err.error_identifier === \"already_subscribed\");\n if (hasAlreadySubscribedError) {\n await handleAlreadySubscribedError(email, errors);\n }\n\n const newsletterNotFoundError = errors.some((err) => err.error_identifier === \"newsletter_not_found\");\n if (newsletterNotFoundError) {\n errorMap.general = \"newsletter_not_found\";\n }\n\n const hasInvalidEmailError = errors.some(\n (err) => err.error_identifier === \"validation_error\" && err.error_details && \"email\" in err.error_details,\n );\n\n const userValidationErrors = errors.filter((err) => err.error_identifier === \"user_validation_error\" && err.error_details);\n for (const err of userValidationErrors) {\n for (const [field, messages] of Object.entries(err.error_details || {})) {\n if (Array.isArray(messages) && messages.length > 0) {\n additionalFieldErrors[field] = messages[0];\n }\n }\n }\n\n if (hasInvalidEmailError) {\n errorMap.email = \"invalid_email\";\n } else {\n for (const err of errors) {\n // Skip user_validation_error - handled via additionalFieldErrors\n if (err.error_identifier === \"user_validation_error\") continue;\n errorMap[err.meta.newsletter_internal_name] = err.error_identifier as NewsletterErrorIdentifier;\n }\n }\n\n newsletterStore.state.errors = errorMap;\n newsletterStore.state.additionalFieldErrors = additionalFieldErrors;\n } else {\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n }\n\n return false;\n}\n\nexport async function subscribeToNewsletter(internalName: string, email: string): Promise<boolean> {\n return handleCreateSubscriptionRequest(email, [internalName], false);\n}\n\nexport async function createSubscriptions({ email }: { email: string }): Promise<boolean> {\n const internalNames = Object.keys(newsletterStore.state.checkedNewsletters);\n return handleCreateSubscriptionRequest(email, internalNames, true);\n}\n\nexport async function deleteSubscription(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n // either preference token is needed or the user must be authenticated to delete a subscription\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to delete a subscription\");\n return false;\n }\n\n const [error, data] = await getUnidyClient().newsletters.delete({\n internalName,\n options: preferenceToken ? { preferenceToken } : undefined,\n });\n\n if (error === null) {\n if (data && \"new_preference_token\" in data) {\n // if user is not authenticated, we need to store the new preference token which is used for the next request\n if (!newsletterStore.state.isAuthenticated) {\n newsletterStore.state.preferenceToken = data.new_preference_token;\n persist(\"preferenceToken\");\n }\n }\n\n newsletterStore.state.existingSubscriptions = newsletterStore.state.existingSubscriptions.filter(\n (sub) => sub.newsletter_internal_name !== internalName,\n );\n\n // Reset checked preferences to defaults (preferences marked with checked='true')\n const defaultPrefs = newsletterStore.state.defaultPreferences[internalName];\n newsletterStore.state.checkedNewsletters = {\n ...newsletterStore.state.checkedNewsletters,\n [internalName]: defaultPrefs ? [...defaultPrefs] : [],\n };\n\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === \"not_found\") {\n return false;\n }\n\n // 422 Unprocessable Entity - silently fail (e.g., trying to delete something that can't be deleted)\n if (error === \"unprocessable_entity\") {\n return false;\n }\n\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n return false;\n}\n\nexport function getSubscription(internalName: string): ExistingSubscription | undefined {\n return newsletterStore.state.existingSubscriptions.find((sub) => sub.newsletter_internal_name === internalName);\n}\n\nexport function isSubscribed(internalName: string): boolean {\n return newsletterStore.state.existingSubscriptions.some((sub) => sub.newsletter_internal_name === internalName);\n}\n\nexport function isConfirmed(internalName: string): boolean {\n const sub = getSubscription(internalName);\n return sub?.confirmed ?? false;\n}\n\nfunction redirectToAfterConfirmationUrl(): string {\n const baseUrl = `${location.origin}${location.pathname}`;\n const params = new URLSearchParams(location.search);\n for (const key of [\"email\", \"newsletter_error\"]) {\n params.delete(key);\n }\n const queryString = params.toString();\n return queryString ? `${baseUrl}?${queryString}` : baseUrl;\n}\n\nexport function getSubscriptionPreferences(internalName: string): string[] {\n const subscription = getSubscription(internalName);\n return subscription?.preference_identifiers || [];\n}\n\nexport async function updateSubscriptionPreferences(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n // Either preference token is needed or the user must be authenticated\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to update subscription preferences\");\n return false;\n }\n\n // Check if the subscription exists\n if (!isSubscribed(internalName)) {\n logger.error(`Cannot update preferences: not subscribed to newsletter '${internalName}'`);\n return false;\n }\n\n const preferenceIdentifiers = newsletterStore.state.checkedNewsletters[internalName] || [];\n\n const [error, data] = await getUnidyClient().newsletters.update({\n internalName,\n payload: { preference_identifiers: preferenceIdentifiers },\n options: preferenceToken ? { preferenceToken } : undefined,\n });\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === null && data && \"preference_identifiers\" in data) {\n // Update the local subscription with the new preferences\n const subscriptionIndex = newsletterStore.state.existingSubscriptions.findIndex((sub) => sub.newsletter_internal_name === internalName);\n\n if (subscriptionIndex !== -1) {\n const updatedSubscriptions = [...newsletterStore.state.existingSubscriptions];\n updatedSubscriptions[subscriptionIndex] = {\n ...updatedSubscriptions[subscriptionIndex],\n preference_identifiers: data.preference_identifiers || [],\n };\n newsletterStore.state.existingSubscriptions = updatedSubscriptions;\n }\n\n Flash.success.addMessage(t(\"newsletter.success.preferences_updated\"));\n return true;\n }\n\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n return false;\n}\n"],"version":3}
|
|
@@ -12,6 +12,8 @@ const initialState = {
|
|
|
12
12
|
preferenceToken: getPersistedValue("preferenceToken") ?? "",
|
|
13
13
|
checkedNewsletters: {},
|
|
14
14
|
defaultPreferences: {},
|
|
15
|
+
additionalFields: {},
|
|
16
|
+
additionalFieldErrors: {},
|
|
15
17
|
fetchingSubscriptions: false,
|
|
16
18
|
existingSubscriptions: [],
|
|
17
19
|
errors: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"newsletter-store.js","mappings":";;
|
|
1
|
+
{"file":"newsletter-store.js","mappings":";;AAmDA,MAAM,kBAAkB,GAAG,mBAAmB;AAEjC,MAAA,OAAO,GAAG,CAAC,GAAgC,KAAI;AAC1D,IAAA,cAAc,CAAC,OAAO,CAAC,CAAG,EAAA,kBAAkB,GAAG,GAAG,CAAA,CAAE,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACnF;AAEA,MAAM,iBAAiB,GAAG,CAAC,GAAgC,KAAI;IAC7D,OAAO,cAAc,CAAC,OAAO,CAAC,CAAA,EAAG,kBAAkB,CAAG,EAAA,GAAG,CAAE,CAAA,CAAC;AAC9D,CAAC;AAED,MAAM,YAAY,GAAoB;AACpC,IAAA,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE;AACvC,IAAA,eAAe,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,EAAE;AAC3D,IAAA,kBAAkB,EAAE,EAAE;AACtB,IAAA,kBAAkB,EAAE,EAAE;AACtB,IAAA,gBAAgB,EAAE,EAAE;AACpB,IAAA,qBAAqB,EAAE,EAAE;AAEzB,IAAA,qBAAqB,EAAE,KAAK;AAC5B,IAAA,qBAAqB,EAAE,EAAE;AAEzB,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,YAAY,EAAE,KAAK;AACnB,IAAA,eAAe,EAAE,KAAK;AAEtB,IAAA,eAAe,EAAE,KAAK;CACvB;MAEY,eAAe,GAAG,WAAW,CAAkB,YAAY;MAE3D,sBAAsB,GAAG,CAAC,YAAoC,EAAE,oBAA0C,KAAI;AACzH,IAAA,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC,YAAY,CAAC,IAAI,IAAI,GAAG,EAAE;AACnF,IAAA,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC;AAChC,IAAA,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACjC,IAAA,eAAe,CAAC,KAAK,CAAC,kBAAkB,GAAG;AACzC,QAAA,GAAG,eAAe,CAAC,KAAK,CAAC,kBAAkB;QAC3C,CAAC,YAAY,GAAG,OAAO;KACxB;AACH;;;;","names":[],"sources":["src/newsletter/store/newsletter-store.ts"],"sourcesContent":["import { createStore } from \"@stencil/store\";\n\nexport type NewsletterErrorIdentifier =\n | \"unconfirmed\"\n | \"already_subscribed\"\n | \"consent_required\"\n | \"invalid_email\"\n | \"newsletter_not_found\"\n | \"preferences_not_found\"\n | \"invalid_preference_token\"\n | \"internal_server_error\"\n | \"user_validation_error\"\n | \"unknown\";\n\nexport type NewsletterInternalName = string;\nexport type PreferenceIdentifier = string;\n\nexport interface ExistingSubscription {\n newsletter_internal_name: NewsletterInternalName;\n confirmed: boolean;\n preference_identifiers: PreferenceIdentifier[];\n}\n\nexport type CheckedNewsletters = Record<NewsletterInternalName, PreferenceIdentifier[]>;\n\nexport type DefaultPreferences = Record<NewsletterInternalName, Set<PreferenceIdentifier>>;\n\nexport interface AdditionalFieldNode {\n value?: string | string[];\n type?: string;\n}\nexport type AdditionalFieldsData = Record<string, AdditionalFieldNode>;\n\ninterface NewsletterState {\n email: string;\n preferenceToken: string;\n checkedNewsletters: CheckedNewsletters;\n defaultPreferences: DefaultPreferences;\n additionalFields: AdditionalFieldsData;\n additionalFieldErrors: Record<string, string>;\n\n fetchingSubscriptions: boolean;\n existingSubscriptions: ExistingSubscription[];\n\n errors: Record<string, NewsletterErrorIdentifier>;\n consentGiven: boolean;\n consentRequired: boolean;\n\n isAuthenticated: boolean;\n}\n\nconst PERSIST_KEY_PREFIX = \"unidy_newsletter_\";\n\nexport const persist = (key: \"email\" | \"preferenceToken\") => {\n sessionStorage.setItem(`${PERSIST_KEY_PREFIX}${key}`, newsletterStore.state[key]);\n};\n\nconst getPersistedValue = (key: \"email\" | \"preferenceToken\") => {\n return sessionStorage.getItem(`${PERSIST_KEY_PREFIX}${key}`);\n};\n\nconst initialState: NewsletterState = {\n email: getPersistedValue(\"email\") ?? \"\",\n preferenceToken: getPersistedValue(\"preferenceToken\") ?? \"\",\n checkedNewsletters: {},\n defaultPreferences: {},\n additionalFields: {},\n additionalFieldErrors: {},\n\n fetchingSubscriptions: false,\n existingSubscriptions: [],\n\n errors: {},\n consentGiven: false,\n consentRequired: false,\n\n isAuthenticated: false,\n};\n\nexport const newsletterStore = createStore<NewsletterState>(initialState);\n\nexport const storeDefaultPreference = (internalName: NewsletterInternalName, preferenceIdentifier: PreferenceIdentifier) => {\n const current = newsletterStore.state.defaultPreferences[internalName] ?? new Set();\n const updated = new Set(current);\n updated.add(preferenceIdentifier);\n newsletterStore.state.defaultPreferences = {\n ...newsletterStore.state.defaultPreferences,\n [internalName]: updated,\n };\n};\n\nexport const reset = () => {\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}preferenceToken`);\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}email`);\n const consentRequired = newsletterStore.state.consentRequired;\n newsletterStore.state = initialState;\n newsletterStore.state.consentRequired = consentRequired;\n};\n"],"version":3}
|