@wix/himalaya-cli 0.1787.0 → 0.1789.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/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-v1/src/index.d.ts +36 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/online-programs/src/index.d.ts +18 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members.mjs +7 -0
- package/dist/cli.mjs +57 -13
- package/fixtures/wix-canned.json +8 -0
- package/guides/himi-json-output.md +7 -0
- package/guides/sdk-reference.json +25 -2
- package/package.json +2 -2
- package/templates/beauty-salon/config.ts +29 -1
- package/templates/beauty-salon/dev/index.ts +3702 -1505
- package/templates/beauty-salon/himalaya.content.json +13 -1
- package/templates/beauty-salon/l10n/ar.json +226 -264
- package/templates/beauty-salon/l10n/cs.json +226 -264
- package/templates/beauty-salon/l10n/da.json +226 -264
- package/templates/beauty-salon/l10n/de.json +226 -264
- package/templates/beauty-salon/l10n/el.json +226 -264
- package/templates/beauty-salon/l10n/en.json +158 -199
- package/templates/beauty-salon/l10n/es.json +226 -264
- package/templates/beauty-salon/l10n/fi.json +226 -264
- package/templates/beauty-salon/l10n/fr.json +227 -265
- package/templates/beauty-salon/l10n/he.json +186 -217
- package/templates/beauty-salon/l10n/hu.json +226 -264
- package/templates/beauty-salon/l10n/id.json +226 -264
- package/templates/beauty-salon/l10n/it.json +226 -264
- package/templates/beauty-salon/l10n/ja.json +226 -264
- package/templates/beauty-salon/l10n/ko.json +226 -264
- package/templates/beauty-salon/l10n/lt.json +226 -264
- package/templates/beauty-salon/l10n/nl.json +226 -264
- package/templates/beauty-salon/l10n/no.json +226 -264
- package/templates/beauty-salon/l10n/pl.json +226 -264
- package/templates/beauty-salon/l10n/pt.json +226 -264
- package/templates/beauty-salon/l10n/ru.json +226 -264
- package/templates/beauty-salon/l10n/sv.json +226 -264
- package/templates/beauty-salon/l10n/th.json +226 -264
- package/templates/beauty-salon/l10n/tr.json +226 -264
- package/templates/beauty-salon/l10n/uk.json +226 -264
- package/templates/beauty-salon/l10n/vi.json +226 -264
- package/templates/beauty-salon/l10n/zh.json +226 -264
- package/templates/beauty-salon/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/branded-lite/config.ts +29 -1
- package/templates/branded-lite/dev/index.ts +3915 -1513
- package/templates/branded-lite/himalaya.content.json +13 -1
- package/templates/branded-lite/l10n/ar.json +284 -267
- package/templates/branded-lite/l10n/cs.json +284 -267
- package/templates/branded-lite/l10n/da.json +284 -267
- package/templates/branded-lite/l10n/de.json +284 -267
- package/templates/branded-lite/l10n/el.json +284 -267
- package/templates/branded-lite/l10n/en.json +201 -207
- package/templates/branded-lite/l10n/es.json +284 -267
- package/templates/branded-lite/l10n/fi.json +284 -267
- package/templates/branded-lite/l10n/fr.json +288 -271
- package/templates/branded-lite/l10n/he.json +233 -219
- package/templates/branded-lite/l10n/hu.json +284 -267
- package/templates/branded-lite/l10n/id.json +284 -267
- package/templates/branded-lite/l10n/it.json +284 -267
- package/templates/branded-lite/l10n/ja.json +284 -267
- package/templates/branded-lite/l10n/ko.json +284 -267
- package/templates/branded-lite/l10n/lt.json +284 -267
- package/templates/branded-lite/l10n/nl.json +284 -267
- package/templates/branded-lite/l10n/no.json +284 -267
- package/templates/branded-lite/l10n/pl.json +284 -267
- package/templates/branded-lite/l10n/pt.json +284 -267
- package/templates/branded-lite/l10n/ru.json +284 -267
- package/templates/branded-lite/l10n/sv.json +284 -267
- package/templates/branded-lite/l10n/th.json +284 -267
- package/templates/branded-lite/l10n/tr.json +284 -267
- package/templates/branded-lite/l10n/uk.json +284 -267
- package/templates/branded-lite/l10n/vi.json +284 -267
- package/templates/branded-lite/l10n/zh.json +284 -267
- package/templates/branded-lite/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-program-participant/index.ts +169 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-program-participant/model.ts +32 -1
- package/templates/brandy/README.md +4 -2
- package/templates/brandy/config.ts +12 -1
- package/templates/brandy/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/community-club/config.ts +29 -1
- package/templates/community-club/dev/index.ts +3717 -1520
- package/templates/community-club/himalaya.content.json +13 -1
- package/templates/community-club/l10n/ar.json +218 -262
- package/templates/community-club/l10n/cs.json +218 -262
- package/templates/community-club/l10n/da.json +218 -262
- package/templates/community-club/l10n/de.json +218 -262
- package/templates/community-club/l10n/el.json +218 -262
- package/templates/community-club/l10n/en.json +140 -188
- package/templates/community-club/l10n/es.json +218 -262
- package/templates/community-club/l10n/fi.json +218 -262
- package/templates/community-club/l10n/fr.json +218 -262
- package/templates/community-club/l10n/he.json +180 -216
- package/templates/community-club/l10n/hu.json +218 -262
- package/templates/community-club/l10n/id.json +218 -262
- package/templates/community-club/l10n/it.json +218 -262
- package/templates/community-club/l10n/ja.json +218 -262
- package/templates/community-club/l10n/ko.json +218 -262
- package/templates/community-club/l10n/lt.json +218 -262
- package/templates/community-club/l10n/nl.json +218 -262
- package/templates/community-club/l10n/no.json +218 -262
- package/templates/community-club/l10n/pl.json +218 -262
- package/templates/community-club/l10n/pt.json +218 -262
- package/templates/community-club/l10n/ru.json +218 -262
- package/templates/community-club/l10n/sv.json +218 -262
- package/templates/community-club/l10n/th.json +218 -262
- package/templates/community-club/l10n/tr.json +218 -262
- package/templates/community-club/l10n/uk.json +218 -262
- package/templates/community-club/l10n/vi.json +218 -262
- package/templates/community-club/l10n/zh.json +218 -262
- package/templates/community-club/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/conference/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/events-meetups/config.ts +29 -1
- package/templates/events-meetups/dev/index.ts +3703 -1506
- package/templates/events-meetups/himalaya.content.json +13 -1
- package/templates/events-meetups/l10n/ar.json +218 -262
- package/templates/events-meetups/l10n/cs.json +218 -262
- package/templates/events-meetups/l10n/da.json +218 -262
- package/templates/events-meetups/l10n/de.json +218 -262
- package/templates/events-meetups/l10n/el.json +218 -262
- package/templates/events-meetups/l10n/en.json +140 -188
- package/templates/events-meetups/l10n/es.json +218 -262
- package/templates/events-meetups/l10n/fi.json +218 -262
- package/templates/events-meetups/l10n/fr.json +218 -262
- package/templates/events-meetups/l10n/he.json +180 -216
- package/templates/events-meetups/l10n/hu.json +218 -262
- package/templates/events-meetups/l10n/id.json +218 -262
- package/templates/events-meetups/l10n/it.json +218 -262
- package/templates/events-meetups/l10n/ja.json +218 -262
- package/templates/events-meetups/l10n/ko.json +218 -262
- package/templates/events-meetups/l10n/lt.json +218 -262
- package/templates/events-meetups/l10n/nl.json +218 -262
- package/templates/events-meetups/l10n/no.json +218 -262
- package/templates/events-meetups/l10n/pl.json +218 -262
- package/templates/events-meetups/l10n/pt.json +218 -262
- package/templates/events-meetups/l10n/ru.json +218 -262
- package/templates/events-meetups/l10n/sv.json +218 -262
- package/templates/events-meetups/l10n/th.json +218 -262
- package/templates/events-meetups/l10n/tr.json +218 -262
- package/templates/events-meetups/l10n/uk.json +218 -262
- package/templates/events-meetups/l10n/vi.json +218 -262
- package/templates/events-meetups/l10n/zh.json +218 -262
- package/templates/events-meetups/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/gym-fitness/config.ts +29 -1
- package/templates/gym-fitness/dev/index.ts +3711 -1514
- package/templates/gym-fitness/himalaya.content.json +13 -1
- package/templates/gym-fitness/l10n/ar.json +226 -264
- package/templates/gym-fitness/l10n/cs.json +226 -264
- package/templates/gym-fitness/l10n/da.json +226 -264
- package/templates/gym-fitness/l10n/de.json +226 -264
- package/templates/gym-fitness/l10n/el.json +226 -264
- package/templates/gym-fitness/l10n/en.json +161 -202
- package/templates/gym-fitness/l10n/es.json +226 -264
- package/templates/gym-fitness/l10n/fi.json +226 -264
- package/templates/gym-fitness/l10n/fr.json +227 -265
- package/templates/gym-fitness/l10n/he.json +186 -217
- package/templates/gym-fitness/l10n/hu.json +226 -264
- package/templates/gym-fitness/l10n/id.json +226 -264
- package/templates/gym-fitness/l10n/it.json +226 -264
- package/templates/gym-fitness/l10n/ja.json +226 -264
- package/templates/gym-fitness/l10n/ko.json +226 -264
- package/templates/gym-fitness/l10n/lt.json +226 -264
- package/templates/gym-fitness/l10n/nl.json +226 -264
- package/templates/gym-fitness/l10n/no.json +226 -264
- package/templates/gym-fitness/l10n/pl.json +226 -264
- package/templates/gym-fitness/l10n/pt.json +226 -264
- package/templates/gym-fitness/l10n/ru.json +226 -264
- package/templates/gym-fitness/l10n/sv.json +226 -264
- package/templates/gym-fitness/l10n/th.json +226 -264
- package/templates/gym-fitness/l10n/tr.json +226 -264
- package/templates/gym-fitness/l10n/uk.json +226 -264
- package/templates/gym-fitness/l10n/vi.json +226 -264
- package/templates/gym-fitness/l10n/zh.json +226 -264
- package/templates/gym-fitness/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/medical-services/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/nonprofit-cause/config.ts +29 -1
- package/templates/nonprofit-cause/dev/index.ts +3719 -1522
- package/templates/nonprofit-cause/himalaya.content.json +13 -1
- package/templates/nonprofit-cause/l10n/ar.json +218 -262
- package/templates/nonprofit-cause/l10n/cs.json +218 -262
- package/templates/nonprofit-cause/l10n/da.json +218 -262
- package/templates/nonprofit-cause/l10n/de.json +218 -262
- package/templates/nonprofit-cause/l10n/el.json +218 -262
- package/templates/nonprofit-cause/l10n/en.json +145 -193
- package/templates/nonprofit-cause/l10n/es.json +218 -262
- package/templates/nonprofit-cause/l10n/fi.json +218 -262
- package/templates/nonprofit-cause/l10n/fr.json +218 -262
- package/templates/nonprofit-cause/l10n/he.json +180 -216
- package/templates/nonprofit-cause/l10n/hu.json +218 -262
- package/templates/nonprofit-cause/l10n/id.json +218 -262
- package/templates/nonprofit-cause/l10n/it.json +218 -262
- package/templates/nonprofit-cause/l10n/ja.json +218 -262
- package/templates/nonprofit-cause/l10n/ko.json +218 -262
- package/templates/nonprofit-cause/l10n/lt.json +218 -262
- package/templates/nonprofit-cause/l10n/nl.json +218 -262
- package/templates/nonprofit-cause/l10n/no.json +218 -262
- package/templates/nonprofit-cause/l10n/pl.json +218 -262
- package/templates/nonprofit-cause/l10n/pt.json +218 -262
- package/templates/nonprofit-cause/l10n/ru.json +218 -262
- package/templates/nonprofit-cause/l10n/sv.json +218 -262
- package/templates/nonprofit-cause/l10n/th.json +218 -262
- package/templates/nonprofit-cause/l10n/tr.json +218 -262
- package/templates/nonprofit-cause/l10n/uk.json +218 -262
- package/templates/nonprofit-cause/l10n/vi.json +218 -262
- package/templates/nonprofit-cause/l10n/zh.json +218 -262
- package/templates/nonprofit-cause/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/personal-fitness-trainer/config.ts +30 -2
- package/templates/personal-fitness-trainer/dev/index.ts +3698 -1476
- package/templates/personal-fitness-trainer/himalaya.content.json +13 -1
- package/templates/personal-fitness-trainer/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/podcast-creator/config.ts +29 -1
- package/templates/podcast-creator/dev/index.ts +3718 -1521
- package/templates/podcast-creator/himalaya.content.json +13 -1
- package/templates/podcast-creator/l10n/ar.json +224 -262
- package/templates/podcast-creator/l10n/cs.json +224 -262
- package/templates/podcast-creator/l10n/da.json +224 -262
- package/templates/podcast-creator/l10n/de.json +224 -262
- package/templates/podcast-creator/l10n/el.json +224 -262
- package/templates/podcast-creator/l10n/en.json +152 -193
- package/templates/podcast-creator/l10n/es.json +224 -262
- package/templates/podcast-creator/l10n/fi.json +224 -262
- package/templates/podcast-creator/l10n/fr.json +227 -265
- package/templates/podcast-creator/l10n/he.json +185 -216
- package/templates/podcast-creator/l10n/hu.json +224 -262
- package/templates/podcast-creator/l10n/id.json +224 -262
- package/templates/podcast-creator/l10n/it.json +224 -262
- package/templates/podcast-creator/l10n/ja.json +224 -262
- package/templates/podcast-creator/l10n/ko.json +224 -262
- package/templates/podcast-creator/l10n/lt.json +224 -262
- package/templates/podcast-creator/l10n/nl.json +224 -262
- package/templates/podcast-creator/l10n/no.json +224 -262
- package/templates/podcast-creator/l10n/pl.json +224 -262
- package/templates/podcast-creator/l10n/pt.json +224 -262
- package/templates/podcast-creator/l10n/ru.json +224 -262
- package/templates/podcast-creator/l10n/sv.json +224 -262
- package/templates/podcast-creator/l10n/th.json +224 -262
- package/templates/podcast-creator/l10n/tr.json +224 -262
- package/templates/podcast-creator/l10n/uk.json +224 -262
- package/templates/podcast-creator/l10n/vi.json +224 -262
- package/templates/podcast-creator/l10n/zh.json +224 -262
- package/templates/podcast-creator/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/portfolio-creative/config.ts +29 -1
- package/templates/portfolio-creative/dev/index.ts +3708 -1511
- package/templates/portfolio-creative/himalaya.content.json +13 -1
- package/templates/portfolio-creative/l10n/ar.json +226 -264
- package/templates/portfolio-creative/l10n/cs.json +226 -264
- package/templates/portfolio-creative/l10n/da.json +226 -264
- package/templates/portfolio-creative/l10n/de.json +226 -264
- package/templates/portfolio-creative/l10n/el.json +226 -264
- package/templates/portfolio-creative/l10n/en.json +155 -196
- package/templates/portfolio-creative/l10n/es.json +226 -264
- package/templates/portfolio-creative/l10n/fi.json +226 -264
- package/templates/portfolio-creative/l10n/fr.json +226 -264
- package/templates/portfolio-creative/l10n/he.json +186 -217
- package/templates/portfolio-creative/l10n/hu.json +226 -264
- package/templates/portfolio-creative/l10n/id.json +226 -264
- package/templates/portfolio-creative/l10n/it.json +226 -264
- package/templates/portfolio-creative/l10n/ja.json +226 -264
- package/templates/portfolio-creative/l10n/ko.json +226 -264
- package/templates/portfolio-creative/l10n/lt.json +226 -264
- package/templates/portfolio-creative/l10n/nl.json +226 -264
- package/templates/portfolio-creative/l10n/no.json +226 -264
- package/templates/portfolio-creative/l10n/pl.json +226 -264
- package/templates/portfolio-creative/l10n/pt.json +226 -264
- package/templates/portfolio-creative/l10n/ru.json +226 -264
- package/templates/portfolio-creative/l10n/sv.json +226 -264
- package/templates/portfolio-creative/l10n/th.json +226 -264
- package/templates/portfolio-creative/l10n/tr.json +226 -264
- package/templates/portfolio-creative/l10n/uk.json +226 -264
- package/templates/portfolio-creative/l10n/vi.json +226 -264
- package/templates/portfolio-creative/l10n/zh.json +226 -264
- package/templates/portfolio-creative/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/restaurant/config.ts +29 -1
- package/templates/restaurant/dev/index.ts +3706 -1509
- package/templates/restaurant/himalaya.content.json +13 -1
- package/templates/restaurant/l10n/ar.json +226 -264
- package/templates/restaurant/l10n/cs.json +226 -264
- package/templates/restaurant/l10n/da.json +226 -264
- package/templates/restaurant/l10n/de.json +226 -264
- package/templates/restaurant/l10n/el.json +226 -264
- package/templates/restaurant/l10n/en.json +152 -193
- package/templates/restaurant/l10n/es.json +226 -264
- package/templates/restaurant/l10n/fi.json +226 -264
- package/templates/restaurant/l10n/fr.json +226 -264
- package/templates/restaurant/l10n/he.json +186 -217
- package/templates/restaurant/l10n/hu.json +226 -264
- package/templates/restaurant/l10n/id.json +226 -264
- package/templates/restaurant/l10n/it.json +226 -264
- package/templates/restaurant/l10n/ja.json +226 -264
- package/templates/restaurant/l10n/ko.json +226 -264
- package/templates/restaurant/l10n/lt.json +226 -264
- package/templates/restaurant/l10n/nl.json +226 -264
- package/templates/restaurant/l10n/no.json +226 -264
- package/templates/restaurant/l10n/pl.json +226 -264
- package/templates/restaurant/l10n/pt.json +226 -264
- package/templates/restaurant/l10n/ru.json +226 -264
- package/templates/restaurant/l10n/sv.json +226 -264
- package/templates/restaurant/l10n/th.json +226 -264
- package/templates/restaurant/l10n/tr.json +226 -264
- package/templates/restaurant/l10n/uk.json +226 -264
- package/templates/restaurant/l10n/vi.json +226 -264
- package/templates/restaurant/l10n/zh.json +226 -264
- package/templates/restaurant/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/retail-store/config.ts +29 -1
- package/templates/retail-store/dev/index.ts +3708 -1511
- package/templates/retail-store/himalaya.content.json +13 -1
- package/templates/retail-store/l10n/ar.json +226 -270
- package/templates/retail-store/l10n/cs.json +226 -270
- package/templates/retail-store/l10n/da.json +226 -270
- package/templates/retail-store/l10n/de.json +226 -270
- package/templates/retail-store/l10n/el.json +226 -270
- package/templates/retail-store/l10n/en.json +154 -202
- package/templates/retail-store/l10n/es.json +226 -270
- package/templates/retail-store/l10n/fi.json +226 -270
- package/templates/retail-store/l10n/fr.json +226 -270
- package/templates/retail-store/l10n/he.json +186 -222
- package/templates/retail-store/l10n/hu.json +226 -270
- package/templates/retail-store/l10n/id.json +226 -270
- package/templates/retail-store/l10n/it.json +226 -270
- package/templates/retail-store/l10n/ja.json +226 -270
- package/templates/retail-store/l10n/ko.json +226 -270
- package/templates/retail-store/l10n/lt.json +226 -270
- package/templates/retail-store/l10n/nl.json +226 -270
- package/templates/retail-store/l10n/no.json +226 -270
- package/templates/retail-store/l10n/pl.json +226 -270
- package/templates/retail-store/l10n/pt.json +226 -270
- package/templates/retail-store/l10n/ru.json +226 -270
- package/templates/retail-store/l10n/sv.json +226 -270
- package/templates/retail-store/l10n/th.json +226 -270
- package/templates/retail-store/l10n/tr.json +226 -270
- package/templates/retail-store/l10n/uk.json +226 -270
- package/templates/retail-store/l10n/vi.json +226 -270
- package/templates/retail-store/l10n/zh.json +226 -270
- package/templates/retail-store/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/salon-spa/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/wholesale-store/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/yoga-studio/config.ts +29 -1
- package/templates/yoga-studio/dev/index.ts +3905 -1506
- package/templates/yoga-studio/himalaya.content.json +13 -1
- package/templates/yoga-studio/l10n/ar.json +300 -262
- package/templates/yoga-studio/l10n/cs.json +300 -262
- package/templates/yoga-studio/l10n/da.json +300 -262
- package/templates/yoga-studio/l10n/de.json +300 -262
- package/templates/yoga-studio/l10n/el.json +300 -262
- package/templates/yoga-studio/l10n/en.json +198 -197
- package/templates/yoga-studio/l10n/es.json +300 -262
- package/templates/yoga-studio/l10n/fi.json +300 -262
- package/templates/yoga-studio/l10n/fr.json +301 -263
- package/templates/yoga-studio/l10n/he.json +247 -216
- package/templates/yoga-studio/l10n/hu.json +300 -262
- package/templates/yoga-studio/l10n/id.json +300 -262
- package/templates/yoga-studio/l10n/it.json +300 -262
- package/templates/yoga-studio/l10n/ja.json +300 -262
- package/templates/yoga-studio/l10n/ko.json +300 -262
- package/templates/yoga-studio/l10n/lt.json +300 -262
- package/templates/yoga-studio/l10n/nl.json +300 -262
- package/templates/yoga-studio/l10n/no.json +300 -262
- package/templates/yoga-studio/l10n/pl.json +300 -262
- package/templates/yoga-studio/l10n/pt.json +300 -262
- package/templates/yoga-studio/l10n/ru.json +300 -262
- package/templates/yoga-studio/l10n/sv.json +300 -262
- package/templates/yoga-studio/l10n/th.json +300 -262
- package/templates/yoga-studio/l10n/tr.json +300 -262
- package/templates/yoga-studio/l10n/uk.json +300 -262
- package/templates/yoga-studio/l10n/vi.json +300 -262
- package/templates/yoga-studio/l10n/zh.json +300 -262
- package/templates/yoga-studio/tier5-src/_shared/member-account-routes.ts +7 -3
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +69 -16
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/index.ts +46 -1082
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/login-info.ts +262 -0
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/personal-info.ts +824 -0
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
- package/templates/yoga-studio/tier5-src/himi-branded-lite-program-participant/index.ts +169 -4
- package/templates/yoga-studio/tier5-src/himi-branded-lite-program-participant/model.ts +32 -1
package/templates/community-club/tier5-src/himi-branded-lite-account-settings/personal-info.ts
ADDED
|
@@ -0,0 +1,824 @@
|
|
|
1
|
+
// Personal info — the photo, display name, title, name, phone and the site's own profile fields,
|
|
2
|
+
// with one Save in the top bar. Opened as a page sheet from the Account settings menu.
|
|
3
|
+
//
|
|
4
|
+
// The field list is the site's (`listCustomFields`): Phone shows only when the site lists it, and
|
|
5
|
+
// the owner's fields show under "More about you" in the site's order. Without the list (the call
|
|
6
|
+
// failed) the modal shows First name, Last name and Phone, as the form did before, and no site
|
|
7
|
+
// fields. Save sends only the fields the member changed, in one `updateMember` call; a validation
|
|
8
|
+
// failure is split by field so the error lands under the field Wix rejected. A full success closes
|
|
9
|
+
// the modal with a snackbar; a field error keeps it open; a server error shows a banner and keeps
|
|
10
|
+
// every change.
|
|
11
|
+
import { defineService } from "@himalaya/state";
|
|
12
|
+
import { snackbar } from "@himalaya/ui";
|
|
13
|
+
import { deleteMemberPhones, getMyMember, listCustomFields, updateMember } from "@himalaya/wix-members";
|
|
14
|
+
import { generateMemberPhotoUploadUrl } from "@himalaya/wix-site-media";
|
|
15
|
+
import { memberAccess } from "../_shared/member-access.js";
|
|
16
|
+
import { memberAccountRoutes } from "../_shared/member-account-routes.js";
|
|
17
|
+
import { copyParam, stashCopy } from "../_shared/himi-copy.js";
|
|
18
|
+
import {
|
|
19
|
+
clean, currentMemberRecordMatches, fetchMember, isSignedOut, loadErrorVariant, memberInitials, rawText,
|
|
20
|
+
signedOutError, type WixMemberRecord, type WixMemberResponse,
|
|
21
|
+
} from "./shared.js";
|
|
22
|
+
|
|
23
|
+
type SiteFieldType = "TEXT" | "NUMBER" | "DATE" | "URL";
|
|
24
|
+
/** Where a site field's member value lives: the contact's custom field map, or one of the
|
|
25
|
+
* default fields the Members Area keeps on the contact itself. */
|
|
26
|
+
type SiteFieldTarget = "custom" | "birthdate" | "company" | "jobTitle";
|
|
27
|
+
interface SiteField { id: string; key: string; label: string; type: SiteFieldType; target: SiteFieldTarget }
|
|
28
|
+
|
|
29
|
+
/** One row of "More about you", in the shape the descriptor's field row reads. */
|
|
30
|
+
interface CustomRow {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
value: string;
|
|
34
|
+
dateUnix: string;
|
|
35
|
+
notText: boolean;
|
|
36
|
+
notNumber: boolean;
|
|
37
|
+
notUrl: boolean;
|
|
38
|
+
notDate: boolean;
|
|
39
|
+
error: string;
|
|
40
|
+
noError: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface ProfileValues {
|
|
44
|
+
displayName: string;
|
|
45
|
+
title: string;
|
|
46
|
+
firstName: string;
|
|
47
|
+
lastName: string;
|
|
48
|
+
phone: string;
|
|
49
|
+
memberImage: string;
|
|
50
|
+
memberImageId: string;
|
|
51
|
+
memberInitials: string;
|
|
52
|
+
/** Site field values by SiteField.id, as text (a DATE is YYYY-MM-DD). */
|
|
53
|
+
custom: Record<string, string>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface S extends ProfileValues {
|
|
57
|
+
/** loading → ready, error (load failed; ErrorState with Try again) or signedOut (Sign in). */
|
|
58
|
+
phase: "loading" | "ready" | "error" | "signedOut";
|
|
59
|
+
errorVariant: "offline" | "server";
|
|
60
|
+
memberId: string;
|
|
61
|
+
memberEmail: string;
|
|
62
|
+
memberScope: string;
|
|
63
|
+
original: ProfileValues;
|
|
64
|
+
originalPhones: string[];
|
|
65
|
+
siteFields: SiteField[];
|
|
66
|
+
customRows: CustomRow[];
|
|
67
|
+
noCustomFields: boolean;
|
|
68
|
+
showPhone: boolean;
|
|
69
|
+
noPhone: boolean;
|
|
70
|
+
dirty: boolean;
|
|
71
|
+
saving: boolean;
|
|
72
|
+
cannotSave: boolean;
|
|
73
|
+
displayNameError: string;
|
|
74
|
+
titleError: string;
|
|
75
|
+
firstNameError: string;
|
|
76
|
+
lastNameError: string;
|
|
77
|
+
phoneError: string;
|
|
78
|
+
customErrors: Record<string, string>;
|
|
79
|
+
/** The banner at the top of the modal after a server error; the changes stay. */
|
|
80
|
+
saveError: string;
|
|
81
|
+
noSaveError: boolean;
|
|
82
|
+
hasMemberImage: boolean;
|
|
83
|
+
noMemberImage: boolean;
|
|
84
|
+
photoUploadAvailable: boolean;
|
|
85
|
+
noPhotoUploadAvailable: boolean;
|
|
86
|
+
photoUploadFunctionName: string;
|
|
87
|
+
photoDisplayUrl: string;
|
|
88
|
+
uploadUrl: string;
|
|
89
|
+
photoDraftUrl: string;
|
|
90
|
+
photoMediaId: string;
|
|
91
|
+
photoPendingMemberId: string;
|
|
92
|
+
photoPendingMemberEmail: string;
|
|
93
|
+
photoPendingMemberScope: string;
|
|
94
|
+
photoUploadError: string;
|
|
95
|
+
photoUploading: boolean;
|
|
96
|
+
notPhotoUploading: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const BLANK: ProfileValues = { displayName: "", title: "", firstName: "", lastName: "", phone: "", memberImage: "", memberImageId: "", memberInitials: "M", custom: {} };
|
|
100
|
+
const EMPTY: S = {
|
|
101
|
+
...BLANK,
|
|
102
|
+
phase: "loading",
|
|
103
|
+
errorVariant: "server",
|
|
104
|
+
memberId: "",
|
|
105
|
+
memberEmail: "",
|
|
106
|
+
memberScope: "",
|
|
107
|
+
original: { ...BLANK },
|
|
108
|
+
originalPhones: [],
|
|
109
|
+
siteFields: [],
|
|
110
|
+
customRows: [],
|
|
111
|
+
noCustomFields: true,
|
|
112
|
+
showPhone: false,
|
|
113
|
+
noPhone: true,
|
|
114
|
+
dirty: false,
|
|
115
|
+
saving: false,
|
|
116
|
+
cannotSave: true,
|
|
117
|
+
displayNameError: "",
|
|
118
|
+
titleError: "",
|
|
119
|
+
firstNameError: "",
|
|
120
|
+
lastNameError: "",
|
|
121
|
+
phoneError: "",
|
|
122
|
+
customErrors: {},
|
|
123
|
+
saveError: "",
|
|
124
|
+
noSaveError: true,
|
|
125
|
+
hasMemberImage: false,
|
|
126
|
+
noMemberImage: true,
|
|
127
|
+
photoUploadAvailable: false,
|
|
128
|
+
noPhotoUploadAvailable: true,
|
|
129
|
+
photoUploadFunctionName: "",
|
|
130
|
+
photoDisplayUrl: "",
|
|
131
|
+
uploadUrl: "",
|
|
132
|
+
photoDraftUrl: "",
|
|
133
|
+
photoMediaId: "",
|
|
134
|
+
photoPendingMemberId: "",
|
|
135
|
+
photoPendingMemberEmail: "",
|
|
136
|
+
photoPendingMemberScope: "",
|
|
137
|
+
photoUploadError: "",
|
|
138
|
+
photoUploading: false,
|
|
139
|
+
notPhotoUploading: true,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// ---- The site's field list ----
|
|
143
|
+
|
|
144
|
+
type ListedField = { key?: unknown; name?: unknown; fieldType?: unknown; fieldOrigin?: unknown };
|
|
145
|
+
|
|
146
|
+
/** Phone and the site fields this modal edits, from `listCustomFields`. SYSTEM fields other than
|
|
147
|
+
* Phone have their own places (name, title) or none here (email, address); a Members Area default
|
|
148
|
+
* field shows only where the member's value has a known contact field; an owner field shows with
|
|
149
|
+
* its own type, a social link as a link. */
|
|
150
|
+
export function siteFieldsFrom(listed: ListedField[]): { hasPhone: boolean; fields: SiteField[] } {
|
|
151
|
+
let hasPhone = false;
|
|
152
|
+
const fields: SiteField[] = [];
|
|
153
|
+
const seen = new Set<string>();
|
|
154
|
+
for (const field of listed) {
|
|
155
|
+
const key = clean(field.key);
|
|
156
|
+
const origin = clean(field.fieldOrigin).toUpperCase();
|
|
157
|
+
const type = clean(field.fieldType).toUpperCase();
|
|
158
|
+
const label = clean(field.name);
|
|
159
|
+
if (!key || seen.has(key)) continue;
|
|
160
|
+
seen.add(key);
|
|
161
|
+
const suffix = (key.split(".").pop() ?? "").toLowerCase();
|
|
162
|
+
if (origin === "SYSTEM") {
|
|
163
|
+
if (suffix === "phone") hasPhone = true;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (!label) continue;
|
|
167
|
+
// A list id for the row: the field key, restricted to the characters a test id takes.
|
|
168
|
+
const id = key.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 64);
|
|
169
|
+
if (origin === "CONTACT") {
|
|
170
|
+
const target: SiteFieldTarget | undefined = suffix === "birthdate" ? "birthdate" : suffix === "company" ? "company" : suffix === "position" || suffix === "jobtitle" ? "jobTitle" : undefined;
|
|
171
|
+
if (target) fields.push({ id, key, label, type: target === "birthdate" ? "DATE" : "TEXT", target });
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (origin === "CUSTOM") {
|
|
175
|
+
const t: SiteFieldType | undefined = type === "TEXT" || type === "NUMBER" || type === "DATE" || type === "URL" ? type : type === "SOCIAL" ? "URL" : undefined;
|
|
176
|
+
if (t) fields.push({ id, key, label, type: t, target: "custom" });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return { hasPhone, fields };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function readSiteFields(): Promise<{ hasPhone: boolean; fields: SiteField[] }> {
|
|
183
|
+
try {
|
|
184
|
+
const response = await listCustomFields({ paging: { limit: 100 } });
|
|
185
|
+
return siteFieldsFrom((response?.fields ?? []) as ListedField[]);
|
|
186
|
+
} catch {
|
|
187
|
+
// No field list: the name fields and Phone, as before, and no site fields.
|
|
188
|
+
return { hasPhone: true, fields: [] };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function customValueOf(member: WixMemberRecord, field: SiteField): string {
|
|
193
|
+
const contact = member.contact ?? {};
|
|
194
|
+
if (field.target === "birthdate") return clean(contact.birthdate);
|
|
195
|
+
if (field.target === "company") return clean(contact.company);
|
|
196
|
+
if (field.target === "jobTitle") return clean(contact.jobTitle);
|
|
197
|
+
const value = contact.customFields?.[field.key]?.value;
|
|
198
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
199
|
+
if (field.type === "DATE" && typeof value === "string") return /^\d{4}-\d{2}-\d{2}/.exec(value)?.[0] ?? "";
|
|
200
|
+
return clean(value);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** `YYYY-MM-DD` → unix seconds at local noon (a time zone shift cannot move the day), or "". */
|
|
204
|
+
function unixOfIsoDate(iso: string): string {
|
|
205
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
|
|
206
|
+
return m ? String(Math.floor(new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]), 12).getTime() / 1000)) : "";
|
|
207
|
+
}
|
|
208
|
+
function isoDateOfUnix(seconds: number): string {
|
|
209
|
+
const d = new Date(seconds * 1000);
|
|
210
|
+
const pad = (n: number) => String(n).padStart(2, "0");
|
|
211
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// ---- Values, change detection, the patch ----
|
|
215
|
+
|
|
216
|
+
type ProfileField = "displayName" | "title" | "firstName" | "lastName" | "phone" | "photo";
|
|
217
|
+
/** A field Save can send: a profile field, or `cf:<site field id>`. */
|
|
218
|
+
type SaveField = ProfileField | `cf:${string}`;
|
|
219
|
+
/** The profile fields whose readback is their own text. */
|
|
220
|
+
type TextField = "displayName" | "title" | "firstName" | "lastName";
|
|
221
|
+
|
|
222
|
+
function memberValues(member: WixMemberRecord, siteFields: SiteField[]): ProfileValues {
|
|
223
|
+
const firstName = clean(member.contact?.firstName);
|
|
224
|
+
const lastName = clean(member.contact?.lastName);
|
|
225
|
+
return {
|
|
226
|
+
displayName: clean(member.profile?.nickname) || [firstName, lastName].filter(Boolean).join(" ") || clean(member.loginEmail),
|
|
227
|
+
title: clean(member.profile?.title),
|
|
228
|
+
firstName,
|
|
229
|
+
lastName,
|
|
230
|
+
phone: clean(member.contact?.phones?.[0]),
|
|
231
|
+
memberImage: memberPhotoDisplayUrl(member.profile?.photo?.url),
|
|
232
|
+
memberImageId: clean(member.profile?.photo?.id),
|
|
233
|
+
memberInitials: memberInitials(firstName, lastName, clean(member.profile?.nickname)),
|
|
234
|
+
custom: Object.fromEntries(siteFields.map((field) => [field.id, customValueOf(member, field)])),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function changedFields(s: S): Set<SaveField> {
|
|
239
|
+
const fields = new Set<SaveField>();
|
|
240
|
+
if (s.displayName.trim() !== s.original.displayName.trim()) fields.add("displayName");
|
|
241
|
+
if (s.title.trim() !== s.original.title.trim()) fields.add("title");
|
|
242
|
+
if (s.firstName.trim() !== s.original.firstName.trim()) fields.add("firstName");
|
|
243
|
+
if (s.lastName.trim() !== s.original.lastName.trim()) fields.add("lastName");
|
|
244
|
+
if (s.showPhone && s.phone.trim() !== (s.originalPhones[0] ?? "").trim()) fields.add("phone");
|
|
245
|
+
if (s.photoMediaId && s.photoDraftUrl) fields.add("photo");
|
|
246
|
+
for (const field of s.siteFields) {
|
|
247
|
+
if ((s.custom[field.id] ?? "").trim() !== (s.original.custom[field.id] ?? "").trim()) fields.add(`cf:${field.id}`);
|
|
248
|
+
}
|
|
249
|
+
return fields;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function nextPhones(s: S): string[] {
|
|
253
|
+
return s.phone.trim() ? [s.phone.trim(), ...s.originalPhones.slice(1)] : s.originalPhones.slice(1);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function typedCustomValue(field: SiteField, text: string): unknown {
|
|
257
|
+
if (field.type === "NUMBER" && text) return Number(text);
|
|
258
|
+
return text;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function memberPatch(s: S, fields: Set<SaveField>): { profile?: Record<string, unknown>; contact?: Record<string, unknown> } {
|
|
262
|
+
const profile: Record<string, unknown> = {};
|
|
263
|
+
const contact: Record<string, unknown> = {};
|
|
264
|
+
const customFields: Record<string, unknown> = {};
|
|
265
|
+
if (fields.has("displayName")) profile.nickname = s.displayName.trim();
|
|
266
|
+
if (fields.has("title")) profile.title = s.title.trim();
|
|
267
|
+
if (fields.has("photo") && s.photoMediaId && s.photoDraftUrl) profile.photo = { id: s.photoMediaId, url: s.photoDraftUrl };
|
|
268
|
+
if (fields.has("firstName")) contact.firstName = s.firstName.trim();
|
|
269
|
+
if (fields.has("lastName")) contact.lastName = s.lastName.trim();
|
|
270
|
+
if (fields.has("phone")) {
|
|
271
|
+
const phones = nextPhones(s);
|
|
272
|
+
if (phones.length) contact.phones = phones;
|
|
273
|
+
}
|
|
274
|
+
for (const field of s.siteFields) {
|
|
275
|
+
if (!fields.has(`cf:${field.id}`)) continue;
|
|
276
|
+
const text = (s.custom[field.id] ?? "").trim();
|
|
277
|
+
if (field.target === "custom") customFields[field.key] = { name: field.label, value: typedCustomValue(field, text) };
|
|
278
|
+
else contact[field.target] = text;
|
|
279
|
+
}
|
|
280
|
+
if (Object.keys(customFields).length) contact.customFields = customFields;
|
|
281
|
+
return { ...(Object.keys(profile).length ? { profile } : {}), ...(Object.keys(contact).length ? { contact } : {}) };
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** The member's own check before a field is sent; "" when it can be sent. */
|
|
285
|
+
function localFieldError(s: S, field: SaveField): string {
|
|
286
|
+
if (field === "displayName" && !s.displayName.trim()) return copyParam("accountSettings.displayNameRequired", "Enter a display name.");
|
|
287
|
+
if (!field.startsWith("cf:")) return "";
|
|
288
|
+
const site = s.siteFields.find((f) => `cf:${f.id}` === field);
|
|
289
|
+
const text = (s.custom[site?.id ?? ""] ?? "").trim();
|
|
290
|
+
if (!site || !text) return "";
|
|
291
|
+
if (site.type === "NUMBER" && !Number.isFinite(Number(text))) return copyParam("accountSettings.numberInvalid", "Enter a number.");
|
|
292
|
+
if (site.type === "URL" && !/^https?:\/\/\S+\.\S+/i.test(text)) return copyParam("accountSettings.urlInvalid", "Enter a valid link.");
|
|
293
|
+
return "";
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function rejectedFieldError(field: SaveField): string {
|
|
297
|
+
if (field === "phone") return copyParam("accountSettings.phoneInvalid", "Enter a valid phone number.");
|
|
298
|
+
return copyParam("accountSettings.fieldSaveError", "This field could not be saved. Check it and try again.");
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// ---- Wix validation errors ----
|
|
302
|
+
|
|
303
|
+
function object(value: unknown): Record<string, unknown> | undefined {
|
|
304
|
+
return value && typeof value === "object" ? value as Record<string, unknown> : undefined;
|
|
305
|
+
}
|
|
306
|
+
function validationBody(error: unknown): Record<string, unknown> | undefined {
|
|
307
|
+
const message = typeof object(error)?.message === "string" ? object(error)!.message as string : "";
|
|
308
|
+
const rawBody = /^HTTP 400:\s*([\s\S]+)$/.exec(message)?.[1];
|
|
309
|
+
let body: Record<string, unknown> | undefined;
|
|
310
|
+
if (rawBody) {
|
|
311
|
+
try { body = object(JSON.parse(rawBody)); } catch { /* Non-JSON HTTP errors are not field validation. */ }
|
|
312
|
+
}
|
|
313
|
+
return body;
|
|
314
|
+
}
|
|
315
|
+
function isDefiniteValidationFailure(error: unknown): boolean {
|
|
316
|
+
const message = typeof object(error)?.message === "string" ? object(error)!.message as string : "";
|
|
317
|
+
if (/^HTTP 400 \[INVALID_ARGUMENT\]:/.test(message)) return true;
|
|
318
|
+
const body = validationBody(error);
|
|
319
|
+
if (!body) return false;
|
|
320
|
+
const details = object(body.details);
|
|
321
|
+
const validation = object(details?.validationError) ?? object(body.validationError);
|
|
322
|
+
return !!validation || Array.isArray(details?.fieldViolations) || Array.isArray(body.fieldViolations);
|
|
323
|
+
}
|
|
324
|
+
function fieldViolations(error: unknown, siteFields: SiteField[]): Set<SaveField> {
|
|
325
|
+
const result = new Set<SaveField>();
|
|
326
|
+
const body = validationBody(error);
|
|
327
|
+
if (!body) return result;
|
|
328
|
+
const details = object(body.details);
|
|
329
|
+
const validation = object(details?.validationError) ?? object(body.validationError);
|
|
330
|
+
const violations = validation?.fieldViolations ?? details?.fieldViolations ?? body.fieldViolations;
|
|
331
|
+
if (!Array.isArray(violations)) return result;
|
|
332
|
+
const paths: Record<string, ProfileField> = {
|
|
333
|
+
nickname: "displayName", "profile.nickname": "displayName", "member.profile.nickname": "displayName",
|
|
334
|
+
title: "title", "profile.title": "title", "member.profile.title": "title",
|
|
335
|
+
"contact.firstname": "firstName", firstname: "firstName", "member.contact.firstname": "firstName",
|
|
336
|
+
"contact.lastname": "lastName", lastname: "lastName", "member.contact.lastname": "lastName",
|
|
337
|
+
phone: "phone", phones: "phone", "contact.phone": "phone", "contact.phones": "phone", "member.contact.phones": "phone",
|
|
338
|
+
photo: "photo", "profile.photo": "photo", "member.profile.photo": "photo",
|
|
339
|
+
};
|
|
340
|
+
for (const violation of violations) {
|
|
341
|
+
const item = object(violation);
|
|
342
|
+
const path = [item?.field, item?.fieldName, item?.path, item?.property].find((value) => typeof value === "string");
|
|
343
|
+
if (typeof path !== "string") continue;
|
|
344
|
+
const normalized = path.toLowerCase().replace(/\[\d+\]/g, "").replace(/_/g, "");
|
|
345
|
+
const field = paths[normalized];
|
|
346
|
+
if (field) { result.add(field); continue; }
|
|
347
|
+
for (const site of siteFields) {
|
|
348
|
+
const name = site.target === "custom" ? site.key.toLowerCase() : site.target.toLowerCase();
|
|
349
|
+
if (normalized.includes(name.replace(/_/g, ""))) result.add(`cf:${site.id}`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// ---- Photo ----
|
|
356
|
+
|
|
357
|
+
function photoUploadFunctionName(value: unknown): string {
|
|
358
|
+
const name = clean(value);
|
|
359
|
+
return /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) ? name : "";
|
|
360
|
+
}
|
|
361
|
+
function validUploadUrl(value: unknown): string {
|
|
362
|
+
if (typeof value !== "string") return "";
|
|
363
|
+
// Hand-parsed: JSC (iOS) has no `URL` global. Host is plain letters/digits/dots, so userinfo and ports never match.
|
|
364
|
+
const m = /^https:\/\/([A-Za-z0-9.-]+)(?:[/?][^#\s\\]*)?$/.exec(value);
|
|
365
|
+
const host = m ? m[1].toLowerCase() : "";
|
|
366
|
+
return host === "wixmp.com" || host.endsWith(".wixmp.com") ? value : "";
|
|
367
|
+
}
|
|
368
|
+
function validPhotoUrl(value: unknown): string {
|
|
369
|
+
if (typeof value !== "string") return "";
|
|
370
|
+
// Members v1 documents profile photo URLs as protocol-relative even though
|
|
371
|
+
// upload responses use absolute HTTPS URLs.
|
|
372
|
+
const normalized = value.startsWith("//") ? `https:${value}` : value;
|
|
373
|
+
const m = /^https:\/\/([A-Za-z0-9.-]+)(\/media\/[^?#\s\\]*)(?:\?[^#\s\\]*)?$/.exec(normalized);
|
|
374
|
+
return m && m[1].toLowerCase() === "static.wixstatic.com" && !/\/\.\.?(\/|$)/.test(m[2]) ? normalized : "";
|
|
375
|
+
}
|
|
376
|
+
function memberPhotoDisplayUrl(value: unknown): string {
|
|
377
|
+
const photoUrl = clean(value);
|
|
378
|
+
return photoUrl.startsWith("//") ? `https:${photoUrl}` : photoUrl;
|
|
379
|
+
}
|
|
380
|
+
function canonicalPhotoMediaId(value: unknown): string {
|
|
381
|
+
const mediaId = clean(value);
|
|
382
|
+
try { return decodeURIComponent(mediaId); }
|
|
383
|
+
catch { return mediaId; }
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
let profileMutationInFlight = false;
|
|
387
|
+
let photoUploadMintInFlight = false;
|
|
388
|
+
let photoUploadVersion = 0;
|
|
389
|
+
let loadVersion = 0;
|
|
390
|
+
// The native picker uploads the file itself and never reports a failed PUT back to the worker, so a minted
|
|
391
|
+
// upload URL counts as "upload in progress" only for a bounded window. Save waits inside it, then recovers.
|
|
392
|
+
const PHOTO_UPLOAD_WAIT_MS = 60_000;
|
|
393
|
+
let photoMintedAt = 0;
|
|
394
|
+
function photoUploadPending(s: S): boolean {
|
|
395
|
+
return !!s.uploadUrl && !!s.photoPendingMemberId && Date.now() - photoMintedAt < PHOTO_UPLOAD_WAIT_MS;
|
|
396
|
+
}
|
|
397
|
+
/** The worker has no timers: the host fires `photoUploadTimeout` once the wait is over, so Save
|
|
398
|
+
* comes back by itself after a PUT that failed without telling the worker. */
|
|
399
|
+
const PHOTO_WAIT_POLL = "himiBrandedAccountPersonal.photoUploadWait";
|
|
400
|
+
const photoWaitPoll = { id: PHOTO_WAIT_POLL, intervalMs: PHOTO_UPLOAD_WAIT_MS + 1000, action: "himiBrandedAccountPersonal.photoUploadTimeout" };
|
|
401
|
+
const photoWaitStop = { id: PHOTO_WAIT_POLL, stop: true as const };
|
|
402
|
+
|
|
403
|
+
function clearPhotoUploadAttempt(s: S, message = ""): S {
|
|
404
|
+
photoUploadVersion += 1;
|
|
405
|
+
return {
|
|
406
|
+
...s,
|
|
407
|
+
uploadUrl: "",
|
|
408
|
+
photoPendingMemberId: "",
|
|
409
|
+
photoPendingMemberEmail: "",
|
|
410
|
+
photoPendingMemberScope: "",
|
|
411
|
+
photoUploadError: message,
|
|
412
|
+
photoUploading: false,
|
|
413
|
+
notPhotoUploading: true,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// ---- State ----
|
|
418
|
+
|
|
419
|
+
/** The flags the descriptor reads, from the values: Save, the site field rows, the banner. */
|
|
420
|
+
function derive(s: S): S {
|
|
421
|
+
const dirty = s.phase === "ready" && changedFields(s).size > 0;
|
|
422
|
+
const customRows: CustomRow[] = s.siteFields.map((field) => {
|
|
423
|
+
const value = s.custom[field.id] ?? "";
|
|
424
|
+
const error = s.customErrors[field.id] ?? "";
|
|
425
|
+
return {
|
|
426
|
+
id: field.id,
|
|
427
|
+
label: field.label,
|
|
428
|
+
value,
|
|
429
|
+
dateUnix: field.type === "DATE" ? unixOfIsoDate(value) : "",
|
|
430
|
+
notText: field.type !== "TEXT",
|
|
431
|
+
notNumber: field.type !== "NUMBER",
|
|
432
|
+
notUrl: field.type !== "URL",
|
|
433
|
+
notDate: field.type !== "DATE",
|
|
434
|
+
error,
|
|
435
|
+
noError: !error,
|
|
436
|
+
};
|
|
437
|
+
});
|
|
438
|
+
return {
|
|
439
|
+
...s,
|
|
440
|
+
dirty,
|
|
441
|
+
cannotSave: !dirty || s.saving || s.photoUploading || photoUploadPending(s),
|
|
442
|
+
customRows,
|
|
443
|
+
noCustomFields: customRows.length === 0,
|
|
444
|
+
noPhone: !s.showPhone,
|
|
445
|
+
hasMemberImage: !!s.memberImage,
|
|
446
|
+
noMemberImage: !s.memberImage,
|
|
447
|
+
noSaveError: !s.saveError,
|
|
448
|
+
noPhotoUploadAvailable: !s.photoUploadAvailable,
|
|
449
|
+
notPhotoUploading: !s.photoUploading,
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function clearFieldErrors(): Pick<S, "displayNameError" | "titleError" | "firstNameError" | "lastNameError" | "phoneError" | "customErrors"> {
|
|
454
|
+
return { displayNameError: "", titleError: "", firstNameError: "", lastNameError: "", phoneError: "", customErrors: {} };
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function loaded(member: WixMemberRecord, email: string, scope: string, siteFields: SiteField[], showPhone: boolean, prior?: S): S {
|
|
458
|
+
const values = memberValues(member, siteFields);
|
|
459
|
+
return derive({
|
|
460
|
+
...(prior ?? EMPTY),
|
|
461
|
+
...values,
|
|
462
|
+
phase: "ready",
|
|
463
|
+
errorVariant: "server",
|
|
464
|
+
memberId: clean(member.id),
|
|
465
|
+
memberEmail: email,
|
|
466
|
+
memberScope: scope,
|
|
467
|
+
original: { ...values, custom: { ...values.custom } },
|
|
468
|
+
originalPhones: [...(member.contact?.phones ?? [])],
|
|
469
|
+
siteFields,
|
|
470
|
+
showPhone,
|
|
471
|
+
saving: false,
|
|
472
|
+
...clearFieldErrors(),
|
|
473
|
+
saveError: "",
|
|
474
|
+
photoDisplayUrl: values.memberImage,
|
|
475
|
+
uploadUrl: "",
|
|
476
|
+
photoDraftUrl: "",
|
|
477
|
+
photoMediaId: "",
|
|
478
|
+
photoPendingMemberId: "",
|
|
479
|
+
photoPendingMemberEmail: "",
|
|
480
|
+
photoPendingMemberScope: "",
|
|
481
|
+
photoUploadError: "",
|
|
482
|
+
photoUploading: false,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function loadFailed(error: unknown): S {
|
|
487
|
+
return derive({ ...EMPTY, phase: isSignedOut(error) ? "signedOut" : "error", errorVariant: loadErrorVariant(error) });
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
type Result = S & { _nav?: { presentation: "dismiss" } };
|
|
491
|
+
type Polled = S & { _poll?: typeof photoWaitPoll | typeof photoWaitStop };
|
|
492
|
+
|
|
493
|
+
// A typed value always lands; Save and the dirty flag count it only once the modal is ready.
|
|
494
|
+
const setText = (key: "displayName" | "title" | "firstName" | "lastName" | "phone") => (s: S, arg?: unknown): S => derive({
|
|
495
|
+
...s, [key]: rawText((arg as { value?: unknown } | undefined)?.value), [`${key}Error`]: "", saveError: "",
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
const svc = defineService<S, {
|
|
499
|
+
load: (s: S, arg?: unknown) => Promise<S>;
|
|
500
|
+
setDisplayName: (s: S, arg?: unknown) => S;
|
|
501
|
+
setTitle: (s: S, arg?: unknown) => S;
|
|
502
|
+
setFirstName: (s: S, arg?: unknown) => S;
|
|
503
|
+
setLastName: (s: S, arg?: unknown) => S;
|
|
504
|
+
setPhone: (s: S, arg?: unknown) => S;
|
|
505
|
+
setCustom: (s: S, arg?: unknown) => S;
|
|
506
|
+
setCustomDate: (s: S, arg?: unknown) => S;
|
|
507
|
+
genUpload: (s: S, arg?: { fileName?: unknown; mimeType?: unknown }) => Promise<Polled>;
|
|
508
|
+
setMedia: (s: S, arg?: { mediaId?: unknown; imageUrl?: unknown }) => Promise<Polled>;
|
|
509
|
+
photoUploadTimeout: (s: S) => Polled;
|
|
510
|
+
save: (s: S) => Promise<Result | undefined>;
|
|
511
|
+
showLoading: (s: S) => S;
|
|
512
|
+
begin: (s: S, patch: Partial<S>) => S;
|
|
513
|
+
}>("himiBrandedAccountPersonal", {
|
|
514
|
+
state: { ...EMPTY },
|
|
515
|
+
// Every value is per visit: a reopened modal starts from the member's record, never a draft.
|
|
516
|
+
notHydrated: Object.keys(EMPTY) as (keyof S)[],
|
|
517
|
+
notPersisted: Object.keys(EMPTY) as (keyof S)[],
|
|
518
|
+
actions: {
|
|
519
|
+
// Internal: publish a state while an action awaits (the skeleton on reload, the Save spinner).
|
|
520
|
+
showLoading: () => derive({ ...EMPTY }),
|
|
521
|
+
begin: (s, patch) => derive({ ...s, ...patch }),
|
|
522
|
+
// Every appear starts over: the shell's Discard closes the modal without telling the worker,
|
|
523
|
+
// and a pooled worker comes back with the draft it had.
|
|
524
|
+
load: async (_s, arg): Promise<S> => {
|
|
525
|
+
const version = ++loadVersion;
|
|
526
|
+
photoUploadVersion += 1;
|
|
527
|
+
stashCopy(arg);
|
|
528
|
+
if (svc.getState().phase !== "loading") await svc.showLoading();
|
|
529
|
+
try {
|
|
530
|
+
const { email, scope, member } = await fetchMember();
|
|
531
|
+
const [routes, site] = await Promise.all([memberAccountRoutes(), readSiteFields()]);
|
|
532
|
+
if (version !== loadVersion) return svc.getState() as S;
|
|
533
|
+
if (!(await currentMemberRecordMatches(email, scope, clean(member.id)))) throw signedOutError();
|
|
534
|
+
if (version !== loadVersion) return svc.getState() as S;
|
|
535
|
+
const functionName = photoUploadFunctionName((arg as { photoUploadFunctionName?: unknown } | undefined)?.photoUploadFunctionName);
|
|
536
|
+
const available = !!functionName && routes.mediaField;
|
|
537
|
+
return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadAvailable: available });
|
|
538
|
+
} catch (error) {
|
|
539
|
+
if (version !== loadVersion) return svc.getState() as S;
|
|
540
|
+
return loadFailed(error);
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
setDisplayName: setText("displayName"),
|
|
544
|
+
setTitle: setText("title"),
|
|
545
|
+
setFirstName: setText("firstName"),
|
|
546
|
+
setLastName: setText("lastName"),
|
|
547
|
+
setPhone: setText("phone"),
|
|
548
|
+
setCustom: (s, arg) => {
|
|
549
|
+
const a = (arg ?? {}) as { id?: unknown; value?: unknown };
|
|
550
|
+
const id = clean(a.id);
|
|
551
|
+
if (s.phase !== "ready" || !s.siteFields.some((field) => field.id === id)) return s;
|
|
552
|
+
return derive({ ...s, custom: { ...s.custom, [id]: rawText(a.value) }, customErrors: { ...s.customErrors, [id]: "" }, saveError: "" });
|
|
553
|
+
},
|
|
554
|
+
// The platform date picker reports the picked day in unix seconds; a cleared web input, "".
|
|
555
|
+
setCustomDate: (s, arg) => {
|
|
556
|
+
const a = (arg ?? {}) as { id?: unknown; value?: unknown };
|
|
557
|
+
const id = clean(a.id);
|
|
558
|
+
if (s.phase !== "ready" || !s.siteFields.some((field) => field.id === id && field.type === "DATE")) return s;
|
|
559
|
+
const seconds = Number(a.value);
|
|
560
|
+
const value = a.value === "" || a.value === null ? "" : Number.isFinite(seconds) && seconds > 0 ? isoDateOfUnix(seconds) : undefined;
|
|
561
|
+
if (value === undefined) return s;
|
|
562
|
+
return derive({ ...s, custom: { ...s.custom, [id]: value }, customErrors: { ...s.customErrors, [id]: "" }, saveError: "" });
|
|
563
|
+
},
|
|
564
|
+
genUpload: async (s, arg): Promise<Polled> => {
|
|
565
|
+
if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || !s.photoUploadFunctionName) {
|
|
566
|
+
return derive({ ...s, uploadUrl: "", photoUploadError: copyParam("accountSettings.profilePhotoUnavailable", "Profile photo changes are not available in this session."), photoUploading: false });
|
|
567
|
+
}
|
|
568
|
+
photoUploadMintInFlight = true;
|
|
569
|
+
const version = ++photoUploadVersion;
|
|
570
|
+
const accountChanged = () => copyParam("accountSettings.profilePhotoAccountChanged", "Your account changed. Reload before choosing a profile photo.");
|
|
571
|
+
const sameMember = (latest: S) => latest.memberId === s.memberId && latest.memberEmail === s.memberEmail && latest.memberScope === s.memberScope;
|
|
572
|
+
try {
|
|
573
|
+
if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) {
|
|
574
|
+
const latest = svc.getState() as S;
|
|
575
|
+
if (version !== photoUploadVersion || !sameMember(latest)) return latest;
|
|
576
|
+
return derive(clearPhotoUploadAttempt(latest, accountChanged()));
|
|
577
|
+
}
|
|
578
|
+
const mimeType = clean(arg?.mimeType);
|
|
579
|
+
const fileName = clean(arg?.fileName);
|
|
580
|
+
if (!/^image\/(jpeg|png|webp)$/i.test(mimeType) || !/^[A-Za-z0-9._-]{1,128}$/.test(fileName)) {
|
|
581
|
+
const latest = svc.getState() as S;
|
|
582
|
+
if (version !== photoUploadVersion) return latest;
|
|
583
|
+
return derive(clearPhotoUploadAttempt(latest, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
|
|
584
|
+
}
|
|
585
|
+
const minted = await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
|
|
586
|
+
if (version !== photoUploadVersion) return svc.getState() as S;
|
|
587
|
+
if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) {
|
|
588
|
+
const latest = svc.getState() as S;
|
|
589
|
+
if (version !== photoUploadVersion || !sameMember(latest)) return latest;
|
|
590
|
+
return derive(clearPhotoUploadAttempt(latest, accountChanged()));
|
|
591
|
+
}
|
|
592
|
+
if (version !== photoUploadVersion) return svc.getState() as S;
|
|
593
|
+
const uploadUrl = validUploadUrl(minted.uploadUrl);
|
|
594
|
+
if (!uploadUrl) return derive(clearPhotoUploadAttempt(svc.getState() as S, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
|
|
595
|
+
const latest = svc.getState() as S;
|
|
596
|
+
if (!sameMember(latest)) return latest;
|
|
597
|
+
photoMintedAt = Date.now();
|
|
598
|
+
return { ...derive({
|
|
599
|
+
...latest,
|
|
600
|
+
uploadUrl,
|
|
601
|
+
photoPendingMemberId: latest.memberId,
|
|
602
|
+
photoPendingMemberEmail: latest.memberEmail,
|
|
603
|
+
photoPendingMemberScope: latest.memberScope,
|
|
604
|
+
photoUploadError: "",
|
|
605
|
+
photoUploading: false,
|
|
606
|
+
}), _poll: photoWaitPoll };
|
|
607
|
+
} catch {
|
|
608
|
+
const latest = svc.getState() as S;
|
|
609
|
+
if (version !== photoUploadVersion || !sameMember(latest)) return latest;
|
|
610
|
+
return derive(clearPhotoUploadAttempt(latest, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be uploaded. Try again.")));
|
|
611
|
+
} finally { photoUploadMintInFlight = false; }
|
|
612
|
+
},
|
|
613
|
+
setMedia: async (s, arg): Promise<Polled> => {
|
|
614
|
+
const mediaId = clean(arg?.mediaId);
|
|
615
|
+
const imageUrl = validPhotoUrl(arg?.imageUrl);
|
|
616
|
+
if (!s.uploadUrl || !s.photoPendingMemberId || s.photoPendingMemberId !== s.memberId || !/^[A-Za-z0-9._~:/+-]{1,512}$/.test(mediaId) || !imageUrl) {
|
|
617
|
+
return derive({ ...s, uploadUrl: "", photoPendingMemberId: "", photoPendingMemberEmail: "", photoPendingMemberScope: "", photoUploadError: copyParam("accountSettings.profilePhotoUploadError", "The photo could not be uploaded. Try again.") });
|
|
618
|
+
}
|
|
619
|
+
const version = photoUploadVersion;
|
|
620
|
+
const accountChanged = () => copyParam("accountSettings.profilePhotoAccountChanged", "Your account changed. Reload before choosing a profile photo.");
|
|
621
|
+
try {
|
|
622
|
+
const matches = await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId);
|
|
623
|
+
// The identity check awaits the network: merge onto the CURRENT state, never the entry snapshot,
|
|
624
|
+
// and drop the result if the upload attempt was superseded (new pick, reload, member change).
|
|
625
|
+
const latest = svc.getState() as S;
|
|
626
|
+
if (version !== photoUploadVersion || latest.memberId !== s.memberId || latest.memberEmail !== s.memberEmail || latest.memberScope !== s.memberScope) return latest;
|
|
627
|
+
if (!matches || s.photoPendingMemberEmail !== latest.memberEmail || s.photoPendingMemberScope !== latest.memberScope) {
|
|
628
|
+
return derive(clearPhotoUploadAttempt(latest, accountChanged()));
|
|
629
|
+
}
|
|
630
|
+
photoMintedAt = 0;
|
|
631
|
+
return { _poll: photoWaitStop, ...derive({
|
|
632
|
+
...latest,
|
|
633
|
+
uploadUrl: "",
|
|
634
|
+
photoDraftUrl: imageUrl,
|
|
635
|
+
photoDisplayUrl: imageUrl,
|
|
636
|
+
photoMediaId: mediaId,
|
|
637
|
+
photoPendingMemberId: "",
|
|
638
|
+
photoPendingMemberEmail: "",
|
|
639
|
+
photoPendingMemberScope: "",
|
|
640
|
+
photoUploadError: "",
|
|
641
|
+
saveError: "",
|
|
642
|
+
}) };
|
|
643
|
+
} catch {
|
|
644
|
+
const latest = svc.getState() as S;
|
|
645
|
+
if (version !== photoUploadVersion || latest.memberId !== s.memberId || latest.memberEmail !== s.memberEmail || latest.memberScope !== s.memberScope) return latest;
|
|
646
|
+
return derive(clearPhotoUploadAttempt(latest, accountChanged()));
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
// The upload wait is over and no photo arrived: the PUT failed without telling the worker.
|
|
650
|
+
// Drop the attempt, so Save counts only the member's other changes again.
|
|
651
|
+
photoUploadTimeout: (s) => {
|
|
652
|
+
if (photoUploadPending(s)) return s;
|
|
653
|
+
if (!s.uploadUrl) return { ...s, _poll: photoWaitStop };
|
|
654
|
+
return { ...derive(clearPhotoUploadAttempt(s, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be uploaded. Try again."))), _poll: photoWaitStop };
|
|
655
|
+
},
|
|
656
|
+
save: async (s): Promise<Result | undefined> => {
|
|
657
|
+
if (profileMutationInFlight || photoUploadMintInFlight || s.photoUploading || photoUploadPending(s) || !s.memberId || s.phase !== "ready") return undefined;
|
|
658
|
+
const attempted = changedFields(s);
|
|
659
|
+
if (!attempted.size) return undefined;
|
|
660
|
+
profileMutationInFlight = true;
|
|
661
|
+
await svc.begin({ saving: true });
|
|
662
|
+
const accepted = new Set<SaveField>();
|
|
663
|
+
try {
|
|
664
|
+
if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) throw signedOutError();
|
|
665
|
+
const rejected = new Map<SaveField, string>();
|
|
666
|
+
const fields = new Set<SaveField>();
|
|
667
|
+
for (const field of attempted) {
|
|
668
|
+
const local = localFieldError(s, field);
|
|
669
|
+
if (local) rejected.set(field, local);
|
|
670
|
+
else fields.add(field);
|
|
671
|
+
}
|
|
672
|
+
const savingPhotoId = s.photoMediaId;
|
|
673
|
+
const submit = async (submitted: Set<SaveField>): Promise<WixMemberResponse | undefined> => {
|
|
674
|
+
const patch = memberPatch(s, submitted);
|
|
675
|
+
if (!patch.profile && !patch.contact) return undefined;
|
|
676
|
+
if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) throw signedOutError();
|
|
677
|
+
const response = await updateMember(s.memberId, { member: patch }) as WixMemberResponse;
|
|
678
|
+
if (response.member?.id !== s.memberId) throw new Error("The profile update was not confirmed for this member.");
|
|
679
|
+
for (const field of submitted) accepted.add(field);
|
|
680
|
+
return response;
|
|
681
|
+
};
|
|
682
|
+
let pending = new Set(fields);
|
|
683
|
+
while (pending.size) {
|
|
684
|
+
try {
|
|
685
|
+
await submit(pending);
|
|
686
|
+
break;
|
|
687
|
+
} catch (error) {
|
|
688
|
+
if (!isDefiniteValidationFailure(error)) throw error;
|
|
689
|
+
const named = new Set([...fieldViolations(error, s.siteFields)].filter((field) => pending.has(field)));
|
|
690
|
+
if (named.size) {
|
|
691
|
+
for (const field of named) rejected.set(field, rejectedFieldError(field));
|
|
692
|
+
// A later validation response may name another field: keep filtering this subset.
|
|
693
|
+
pending = new Set([...pending].filter((field) => !named.has(field)));
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
// A typed INVALID_ARGUMENT names no field (the native bridge drops the details):
|
|
697
|
+
// send this batch's fields one at a time to find the one Wix rejects.
|
|
698
|
+
for (const field of pending) {
|
|
699
|
+
try { await submit(new Set([field])); }
|
|
700
|
+
catch (fieldError) {
|
|
701
|
+
if (!isDefiniteValidationFailure(fieldError)) throw fieldError;
|
|
702
|
+
const details = fieldViolations(fieldError, s.siteFields);
|
|
703
|
+
if (details.size && !details.has(field)) throw fieldError;
|
|
704
|
+
rejected.set(field, rejectedFieldError(field));
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
pending = new Set();
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
// Wix ignores an empty phones array, so clear the primary number only after the other
|
|
711
|
+
// accepted fields are patched. Secondary numbers stay. A validation failure here is the phone's.
|
|
712
|
+
if (fields.has("phone") && !rejected.has("phone") && !nextPhones(s).length && s.originalPhones.length) {
|
|
713
|
+
try {
|
|
714
|
+
if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) throw signedOutError();
|
|
715
|
+
await deleteMemberPhones(s.memberId);
|
|
716
|
+
accepted.add("phone");
|
|
717
|
+
} catch (error) {
|
|
718
|
+
if (!isDefiniteValidationFailure(error)) throw error;
|
|
719
|
+
rejected.set("phone", rejectedFieldError("phone"));
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
// The readback decides what was saved: a 200 that dropped a value is not a save.
|
|
723
|
+
const before = await memberAccess();
|
|
724
|
+
const refreshed = await getMyMember({ fieldsets: ["FULL"] }) as WixMemberResponse;
|
|
725
|
+
const after = await memberAccess();
|
|
726
|
+
if (refreshed.member?.id !== s.memberId || !after.email || after.email !== s.memberEmail || after.scope !== s.memberScope || before.email !== s.memberEmail) throw signedOutError();
|
|
727
|
+
const readback = memberValues(refreshed.member, s.siteFields);
|
|
728
|
+
const expectedPhones = nextPhones(s);
|
|
729
|
+
const actualPhones = refreshed.member.contact?.phones ?? [];
|
|
730
|
+
const digits = (phone: unknown) => clean(phone).replace(/[\s().-]/g, "");
|
|
731
|
+
const phonesMatch = expectedPhones.length === actualPhones.length && expectedPhones.every((phone, i) => digits(phone) === digits(actualPhones[i]));
|
|
732
|
+
const readbackMatches = (field: SaveField): boolean => {
|
|
733
|
+
if (field === "photo") return true;
|
|
734
|
+
if (field === "phone") return phonesMatch;
|
|
735
|
+
if (field.startsWith("cf:")) {
|
|
736
|
+
const id = field.slice(3);
|
|
737
|
+
const site = s.siteFields.find((f) => f.id === id);
|
|
738
|
+
const want = (s.custom[id] ?? "").trim();
|
|
739
|
+
const got = readback.custom[id] ?? "";
|
|
740
|
+
return site?.type === "NUMBER" && want ? Number(want) === Number(got) : want === got;
|
|
741
|
+
}
|
|
742
|
+
const text = field as TextField;
|
|
743
|
+
return readback[text] === s[text].trim();
|
|
744
|
+
};
|
|
745
|
+
const latest = svc.getState() as S;
|
|
746
|
+
const editedSince = (field: SaveField): boolean => field.startsWith("cf:")
|
|
747
|
+
? latest.custom[field.slice(3)] !== s.custom[field.slice(3)]
|
|
748
|
+
: field !== "photo" && latest[field as TextField | "phone"] !== s[field as TextField | "phone"];
|
|
749
|
+
for (const field of attempted) {
|
|
750
|
+
if (rejected.has(field) || editedSince(field)) continue;
|
|
751
|
+
if (!readbackMatches(field)) rejected.set(field, rejectedFieldError(field));
|
|
752
|
+
}
|
|
753
|
+
const photoChanged = latest.photoMediaId !== s.photoMediaId || latest.photoDraftUrl !== s.photoDraftUrl;
|
|
754
|
+
const refreshedPhotoId = clean(refreshed.member.profile?.photo?.id);
|
|
755
|
+
const refreshedPhotoUrl = memberPhotoDisplayUrl(refreshed.member.profile?.photo?.url);
|
|
756
|
+
const photoUnconfirmed = !!savingPhotoId && !photoChanged && (rejected.has("photo") || canonicalPhotoMediaId(refreshedPhotoId) !== canonicalPhotoMediaId(savingPhotoId) || !validPhotoUrl(refreshedPhotoUrl));
|
|
757
|
+
// Full success, and nothing typed while it saved: the modal closes on the menu's snackbar.
|
|
758
|
+
const typedSince = [...attempted].some(editedSince) || photoChanged;
|
|
759
|
+
if (!rejected.size && !photoUnconfirmed && !typedSince) {
|
|
760
|
+
void snackbar({ message: copyParam("accountSettings.savedToast", "Your changes are saved."), tone: "info" }).catch(() => undefined);
|
|
761
|
+
return { ...loaded(refreshed.member, s.memberEmail, s.memberScope, s.siteFields, s.showPhone, latest), photoUploadFunctionName: latest.photoUploadFunctionName, photoUploadAvailable: latest.photoUploadAvailable, noPhotoUploadAvailable: !latest.photoUploadAvailable, _nav: { presentation: "dismiss" } };
|
|
762
|
+
}
|
|
763
|
+
// Otherwise the readback is the new baseline, and every draft the member still needs stays.
|
|
764
|
+
const base = loaded(refreshed.member, s.memberEmail, s.memberScope, s.siteFields, s.showPhone, latest);
|
|
765
|
+
const keep: Partial<S> = { custom: { ...base.custom } };
|
|
766
|
+
for (const key of ["displayName", "title", "firstName", "lastName", "phone"] as const) {
|
|
767
|
+
if (latest[key] !== s[key]) keep[key] = latest[key];
|
|
768
|
+
else if (rejected.has(key)) keep[key] = s[key];
|
|
769
|
+
}
|
|
770
|
+
for (const site of s.siteFields) {
|
|
771
|
+
const field: SaveField = `cf:${site.id}`;
|
|
772
|
+
if (latest.custom[site.id] !== s.custom[site.id]) keep.custom![site.id] = latest.custom[site.id];
|
|
773
|
+
else if (rejected.has(field)) keep.custom![site.id] = s.custom[site.id];
|
|
774
|
+
}
|
|
775
|
+
const errors = clearFieldErrors();
|
|
776
|
+
for (const [field, message] of rejected) {
|
|
777
|
+
if (field === "photo" || editedSince(field)) continue;
|
|
778
|
+
if (field.startsWith("cf:")) errors.customErrors[field.slice(3)] = message;
|
|
779
|
+
else (errors as Record<string, unknown>)[`${field}Error`] = message;
|
|
780
|
+
}
|
|
781
|
+
return derive({
|
|
782
|
+
...base,
|
|
783
|
+
...keep,
|
|
784
|
+
...errors,
|
|
785
|
+
photoUploadFunctionName: latest.photoUploadFunctionName,
|
|
786
|
+
photoUploadAvailable: latest.photoUploadAvailable,
|
|
787
|
+
...(photoChanged || photoUnconfirmed ? {
|
|
788
|
+
photoDraftUrl: photoChanged ? latest.photoDraftUrl : s.photoDraftUrl,
|
|
789
|
+
photoMediaId: photoChanged ? latest.photoMediaId : s.photoMediaId,
|
|
790
|
+
photoDisplayUrl: (photoChanged ? latest.photoDraftUrl : s.photoDraftUrl) || refreshedPhotoUrl,
|
|
791
|
+
uploadUrl: latest.uploadUrl,
|
|
792
|
+
photoPendingMemberId: latest.photoPendingMemberId,
|
|
793
|
+
photoPendingMemberEmail: latest.photoPendingMemberEmail,
|
|
794
|
+
photoPendingMemberScope: latest.photoPendingMemberScope,
|
|
795
|
+
} : {}),
|
|
796
|
+
photoUploadError: photoUnconfirmed
|
|
797
|
+
? rejected.has("photo")
|
|
798
|
+
? rejectedFieldError("photo")
|
|
799
|
+
: copyParam("accountSettings.profilePhotoSaveError", "Your new profile photo was not confirmed as saved. Try saving it again.")
|
|
800
|
+
: latest.photoUploadError,
|
|
801
|
+
});
|
|
802
|
+
} catch (error) {
|
|
803
|
+
const latest = svc.getState() as S;
|
|
804
|
+
// Another member (or none) is signed in now: never leave the previous member's profile on
|
|
805
|
+
// screen. The modal shows the sign-in ErrorState.
|
|
806
|
+
if (isSignedOut(error) || latest.memberId !== s.memberId || latest.memberEmail !== s.memberEmail || latest.memberScope !== s.memberScope) {
|
|
807
|
+
return loadFailed(signedOutError());
|
|
808
|
+
}
|
|
809
|
+
// A server error: a banner at the top, and every change stays for Try again.
|
|
810
|
+
return derive({
|
|
811
|
+
...latest,
|
|
812
|
+
saving: false,
|
|
813
|
+
saveError: accepted.size
|
|
814
|
+
? copyParam("accountSettings.savePartialError", "Some changes were saved, but we couldn't confirm the rest. Try again.")
|
|
815
|
+
: copyParam("accountSettings.saveError", "Your changes weren't saved. Try again."),
|
|
816
|
+
});
|
|
817
|
+
} finally {
|
|
818
|
+
profileMutationInFlight = false;
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
},
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
export { svc as personalInfo };
|