@wix/himalaya-cli 0.1887.0 → 0.1888.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/cli.mjs +58327 -58168
- package/guides/himi-json-output.md +23 -0
- package/package.json +2 -2
- package/templates/bare-fashion/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/beauty-salon/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/branded-lite/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/brandy/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/brandy/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/community-club/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/conference/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/conference/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/events-meetups/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/fitness-gym/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/gym-fitness/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/medical-services/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/nonprofit-cause/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/personal-fitness-trainer/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/podcast-creator/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/portfolio-creative/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/professional-services/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/professional-services/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/restaurant/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/retail-store/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/salon-spa/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/wholesale-store/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
- package/templates/yoga-studio/tier5-src/_shared/member-account-routes.ts +26 -3
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/personal-info.ts +21 -7
|
@@ -13,7 +13,7 @@ import { snackbar } from "@himalaya/ui";
|
|
|
13
13
|
import { deleteMemberPhones, getMyMember, listCustomFields, updateMember } from "@himalaya/wix-members";
|
|
14
14
|
import { generateMemberPhotoUploadUrl } from "@himalaya/wix-site-media";
|
|
15
15
|
import { memberAccess } from "../_shared/member-access.js";
|
|
16
|
-
import { memberAccountRoutes } from "../_shared/member-account-routes.js";
|
|
16
|
+
import { MEMBER_PHOTO_UPLOAD_TARGET, isMemberPhotoUploadTarget, memberAccountRoutes } from "../_shared/member-account-routes.js";
|
|
17
17
|
import { copyParam, stashCopy } from "../_shared/himi-copy.js";
|
|
18
18
|
import {
|
|
19
19
|
clean, currentMemberRecordMatches, fetchMember, isSignedOut, loadErrorVariant, memberInitials, rawText,
|
|
@@ -84,6 +84,8 @@ interface S extends ProfileValues {
|
|
|
84
84
|
photoUploadAvailable: boolean;
|
|
85
85
|
noPhotoUploadAvailable: boolean;
|
|
86
86
|
photoUploadFunctionName: string;
|
|
87
|
+
/** The photo goes to the app's member-photo route as the member (no site function): the host answers the placeholder target. */
|
|
88
|
+
photoUploadViaRoute: boolean;
|
|
87
89
|
photoDisplayUrl: string;
|
|
88
90
|
uploadUrl: string;
|
|
89
91
|
photoDraftUrl: string;
|
|
@@ -132,6 +134,7 @@ const EMPTY: S = {
|
|
|
132
134
|
photoUploadAvailable: false,
|
|
133
135
|
noPhotoUploadAvailable: true,
|
|
134
136
|
photoUploadFunctionName: "",
|
|
137
|
+
photoUploadViaRoute: false,
|
|
135
138
|
photoDisplayUrl: "",
|
|
136
139
|
uploadUrl: "",
|
|
137
140
|
photoDraftUrl: "",
|
|
@@ -373,9 +376,12 @@ function photoUploadFunctionName(value: unknown): string {
|
|
|
373
376
|
const name = clean(value);
|
|
374
377
|
return /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) ? name : "";
|
|
375
378
|
}
|
|
376
|
-
function validUploadUrl(value: unknown): string {
|
|
379
|
+
function validUploadUrl(value: unknown, viaRoute: boolean): string {
|
|
377
380
|
if (typeof value !== "string") return "";
|
|
378
381
|
// Hand-parsed: JSC (iOS) has no `URL` global. Host is plain letters/digits/dots, so userinfo and ports never match.
|
|
382
|
+
// The member-photo placeholder is the host's to answer with the member's credential; it names no host at all. Only the worker's own
|
|
383
|
+
// route path may publish it: a site function that returns it must not steer the host off the function's Wix Media upload.
|
|
384
|
+
if (isMemberPhotoUploadTarget(value)) return viaRoute && /^[A-Za-z0-9?=&.-]{0,64}$/.test(value.slice(MEMBER_PHOTO_UPLOAD_TARGET.length)) ? value : "";
|
|
379
385
|
const m = /^https:\/\/([A-Za-z0-9.-]+)(?:[/?][^#\s\\]*)?$/.exec(value);
|
|
380
386
|
const host = m ? m[1].toLowerCase() : "";
|
|
381
387
|
return host === "wixmp.com" || host.endsWith(".wixmp.com") ? value : "";
|
|
@@ -401,6 +407,8 @@ function canonicalPhotoMediaId(value: unknown): string {
|
|
|
401
407
|
let profileMutationInFlight = false;
|
|
402
408
|
let photoUploadMintInFlight = false;
|
|
403
409
|
let photoUploadVersion = 0;
|
|
410
|
+
/** Makes each pick's placeholder differ from the last (a retry must not look like the value left from a failed pick). */
|
|
411
|
+
let photoRouteNonce = 0;
|
|
404
412
|
let loadVersion = 0;
|
|
405
413
|
// The native picker uploads the file itself and never reports a failed PUT back to the worker, so a minted
|
|
406
414
|
// upload URL counts as "upload in progress" only for a bounded window. Save waits inside it, then recovers.
|
|
@@ -570,8 +578,11 @@ const svc = defineService<S, {
|
|
|
570
578
|
if (!(await currentMemberRecordMatches(email, scope, clean(member.id)))) throw signedOutError();
|
|
571
579
|
if (version !== loadVersion) return svc.getState() as S;
|
|
572
580
|
const functionName = photoUploadFunctionName((arg as { photoUploadFunctionName?: unknown } | undefined)?.photoUploadFunctionName);
|
|
573
|
-
|
|
574
|
-
|
|
581
|
+
// The site's own upload function wins (it works on every binary that has MediaField). Without one, a host that sends the photo
|
|
582
|
+
// to the app's member-photo route as the member does the upload, with no site code: migrated apps have none.
|
|
583
|
+
const viaRoute = !functionName && routes.memberPhotoRoute;
|
|
584
|
+
const available = (!!functionName && routes.mediaField) || viaRoute;
|
|
585
|
+
return derive({ ...loaded(member, email, scope, site.fields, site.hasPhone), photoUploadFunctionName: functionName, photoUploadViaRoute: viaRoute, photoUploadAvailable: available });
|
|
575
586
|
} catch (error) {
|
|
576
587
|
if (version !== loadVersion) return svc.getState() as S;
|
|
577
588
|
return loadFailed(error);
|
|
@@ -607,7 +618,7 @@ const svc = defineService<S, {
|
|
|
607
618
|
return derive({ ...s, custom: { ...s.custom, [id]: value }, customErrors: { ...s.customErrors, [id]: "" }, saveError: "" });
|
|
608
619
|
},
|
|
609
620
|
genUpload: async (s, arg): Promise<Polled> => {
|
|
610
|
-
if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || !s.photoUploadFunctionName) {
|
|
621
|
+
if (photoUploadMintInFlight || s.phase !== "ready" || !s.memberId || !s.photoUploadAvailable || (!s.photoUploadFunctionName && !s.photoUploadViaRoute)) {
|
|
611
622
|
return derive({ ...s, uploadUrl: "", photoUploadError: copyParam("accountSettings.profilePhotoUnavailable", "Profile photo changes are not available in this session."), photoUploading: false });
|
|
612
623
|
}
|
|
613
624
|
photoUploadMintInFlight = true;
|
|
@@ -628,7 +639,10 @@ const svc = defineService<S, {
|
|
|
628
639
|
if (version !== photoUploadVersion) return latest;
|
|
629
640
|
return derive(clearPhotoUploadAttempt(latest, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
|
|
630
641
|
}
|
|
631
|
-
|
|
642
|
+
// Through the member-photo route there is nothing to mint: the placeholder says "send it as the member", and the host does.
|
|
643
|
+
const minted = s.photoUploadViaRoute
|
|
644
|
+
? { uploadUrl: `${MEMBER_PHOTO_UPLOAD_TARGET}?n=${++photoRouteNonce}` }
|
|
645
|
+
: await generateMemberPhotoUploadUrl(s.photoUploadFunctionName, mimeType, fileName);
|
|
632
646
|
if (version !== photoUploadVersion) return svc.getState() as S;
|
|
633
647
|
if (!(await currentMemberRecordMatches(s.memberEmail, s.memberScope, s.memberId))) {
|
|
634
648
|
const latest = svc.getState() as S;
|
|
@@ -636,7 +650,7 @@ const svc = defineService<S, {
|
|
|
636
650
|
return derive(clearPhotoUploadAttempt(latest, accountChanged()));
|
|
637
651
|
}
|
|
638
652
|
if (version !== photoUploadVersion) return svc.getState() as S;
|
|
639
|
-
const uploadUrl = validUploadUrl(minted.uploadUrl);
|
|
653
|
+
const uploadUrl = validUploadUrl(minted.uploadUrl, s.photoUploadViaRoute);
|
|
640
654
|
if (!uploadUrl) return derive(clearPhotoUploadAttempt(svc.getState() as S, copyParam("accountSettings.profilePhotoUploadError", "The photo could not be prepared. Choose another image.")));
|
|
641
655
|
const latest = svc.getState() as S;
|
|
642
656
|
if (!sameMember(latest)) return latest;
|