@wix/himalaya-cli 0.1570.0 → 0.1572.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/core/ts/src/define-app.d.ts +8 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/auth-providers/wix/src/index.d.ts +7 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/blog-v3/src/extensions.d.ts +6 -3
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-feed-viewer/src/index.d.ts +6 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/auth.mjs +17 -7
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core/validation.mjs +17 -7
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +17 -7
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +17 -7
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/state.mjs +17 -7
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-auth.mjs +7 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-blog.mjs +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members-feed-viewer.mjs +18 -0
- package/dist/cli.mjs +2014 -1252
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/base44-app-to-himi-app.md +1 -1
- package/guides/capabilities.md +7 -0
- package/guides/himi-json-output.md +11 -0
- package/guides/index.json +7 -0
- package/guides/map-one-app-coverage.js +117 -0
- package/guides/one-app-to-himi-app.md +209 -11
- package/guides/recipe-one-app-coverage-mapping.md +74 -0
- package/guides/sdk-reference.json +8 -2
- package/guides/splash-screens.md +10 -1
- package/guides/trim-a-template.md +5 -0
- package/guides/wix-business-context.md +11 -2
- package/package.json +2 -2
- package/templates/beauty-salon/config.ts +1 -1
- package/templates/beauty-salon/dev/index.ts +31 -1
- package/templates/beauty-salon/tier5-src/_shared/member-read.ts +52 -0
- package/templates/beauty-salon/tier5-src/_shared/program-description.ts +11 -0
- package/templates/beauty-salon/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +6 -9
- package/templates/beauty-salon-owner/config.ts +1 -1
- package/templates/beauty-salon-owner/dev/index.ts +2 -3
- package/templates/branded-lite/config.ts +1 -1
- package/templates/branded-lite/dev/index.ts +163 -2
- package/templates/branded-lite/tier5-src/_shared/member-read.ts +52 -0
- package/templates/branded-lite/tier5-src/_shared/program-description.ts +11 -0
- package/templates/branded-lite/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/branded-lite/tier5-src/himi-branded-lite-program/index.ts +16 -14
- package/templates/branded-lite/tier5-src/himi-branded-lite-programs/index.ts +31 -18
- package/templates/branded-lite/tier5-src/himi-events-my-events/index.ts +76 -42
- package/templates/branded-lite/tier5-src/himi-store-product/index.ts +6 -9
- package/templates/branded-lite/tier5-src/wix-spaces-chat-thread/index.ts +101 -34
- package/templates/branded-lite/tier5-src/wix-spaces-forum-post/index.ts +23 -6
- package/templates/branded-lite/tier5-src/wix-spaces-member-detail/index.ts +26 -11
- package/templates/community-club/config.ts +1 -1
- package/templates/community-club/dev/index.ts +65 -2
- package/templates/community-club/tier5-src/_shared/branded-load-state.ts +106 -0
- package/templates/community-club/tier5-src/_shared/member-read.ts +52 -0
- package/templates/community-club/tier5-src/_shared/program-description.ts +11 -0
- package/templates/community-club/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/community-club/tier5-src/himi-events-my-events/index.ts +76 -42
- package/templates/community-club-owner/config.ts +1 -1
- package/templates/community-club-owner/dev/index.ts +2 -3
- package/templates/events-meetups/config.ts +1 -1
- package/templates/events-meetups/dev/index.ts +65 -2
- package/templates/events-meetups/tier5-src/_shared/branded-load-state.ts +106 -0
- package/templates/events-meetups/tier5-src/_shared/member-read.ts +52 -0
- package/templates/events-meetups/tier5-src/_shared/program-description.ts +11 -0
- package/templates/events-meetups/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/events-meetups/tier5-src/himi-events-my-events/index.ts +76 -42
- package/templates/events-meetups-owner/config.ts +1 -1
- package/templates/events-meetups-owner/dev/index.ts +2 -3
- package/templates/gym-fitness/config.ts +1 -1
- package/templates/gym-fitness/dev/index.ts +65 -2
- package/templates/gym-fitness/tier5-src/_shared/member-read.ts +52 -0
- package/templates/gym-fitness/tier5-src/_shared/program-description.ts +11 -0
- package/templates/gym-fitness/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/gym-fitness/tier5-src/himi-events-my-events/index.ts +76 -42
- package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +6 -9
- package/templates/gym-fitness-owner/config.ts +1 -1
- package/templates/gym-fitness-owner/dev/index.ts +2 -3
- package/templates/nonprofit-cause/config.ts +1 -1
- package/templates/nonprofit-cause/dev/index.ts +65 -2
- package/templates/nonprofit-cause/tier5-src/_shared/branded-load-state.ts +106 -0
- package/templates/nonprofit-cause/tier5-src/_shared/member-read.ts +52 -0
- package/templates/nonprofit-cause/tier5-src/_shared/program-description.ts +11 -0
- package/templates/nonprofit-cause/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/nonprofit-cause/tier5-src/himi-events-my-events/index.ts +76 -42
- package/templates/nonprofit-cause-owner/config.ts +1 -1
- package/templates/nonprofit-cause-owner/dev/index.ts +2 -3
- package/templates/owner-lite/config.ts +1 -1
- package/templates/owner-lite/dev/index.ts +2 -3
- package/templates/podcast-creator/config.ts +1 -1
- package/templates/podcast-creator/dev/index.ts +65 -2
- package/templates/podcast-creator/tier5-src/_shared/branded-load-state.ts +106 -0
- package/templates/podcast-creator/tier5-src/_shared/member-read.ts +52 -0
- package/templates/podcast-creator/tier5-src/_shared/program-description.ts +11 -0
- package/templates/podcast-creator/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/podcast-creator/tier5-src/himi-events-my-events/index.ts +76 -42
- package/templates/podcast-creator-owner/config.ts +1 -1
- package/templates/podcast-creator-owner/dev/index.ts +2 -3
- package/templates/portfolio-creative/config.ts +1 -1
- package/templates/portfolio-creative/dev/index.ts +65 -2
- package/templates/portfolio-creative/tier5-src/_shared/branded-load-state.ts +106 -0
- package/templates/portfolio-creative/tier5-src/_shared/member-read.ts +52 -0
- package/templates/portfolio-creative/tier5-src/_shared/program-description.ts +11 -0
- package/templates/portfolio-creative/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/portfolio-creative/tier5-src/himi-events-my-events/index.ts +76 -42
- package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +6 -9
- package/templates/portfolio-creative-owner/config.ts +1 -1
- package/templates/portfolio-creative-owner/dev/index.ts +2 -3
- package/templates/restaurant/config.ts +1 -1
- package/templates/restaurant/dev/index.ts +65 -2
- package/templates/restaurant/tier5-src/_shared/branded-load-state.ts +106 -0
- package/templates/restaurant/tier5-src/_shared/member-read.ts +52 -0
- package/templates/restaurant/tier5-src/_shared/program-description.ts +11 -0
- package/templates/restaurant/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/restaurant/tier5-src/himi-events-my-events/index.ts +76 -42
- package/templates/restaurant-owner/config.ts +1 -1
- package/templates/restaurant-owner/dev/index.ts +2 -3
- package/templates/retail-store/config.ts +1 -1
- package/templates/retail-store/dev/index.ts +31 -1
- package/templates/retail-store/tier5-src/_shared/branded-load-state.ts +106 -0
- package/templates/retail-store/tier5-src/_shared/member-read.ts +52 -0
- package/templates/retail-store/tier5-src/_shared/program-description.ts +11 -0
- package/templates/retail-store/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/retail-store/tier5-src/himi-store-product/index.ts +6 -9
- package/templates/retail-store-owner/config.ts +1 -1
- package/templates/retail-store-owner/dev/index.ts +2 -3
- package/templates/yoga-studio/config.ts +1 -1
- package/templates/yoga-studio/dev/index.ts +93 -2
- package/templates/yoga-studio/tier5-src/_shared/member-read.ts +52 -0
- package/templates/yoga-studio/tier5-src/_shared/program-description.ts +11 -0
- package/templates/yoga-studio/tier5-src/himi-blog-post/index.ts +35 -12
- package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +3 -3
- package/templates/yoga-studio/tier5-src/himi-branded-lite-program/index.ts +16 -14
- package/templates/yoga-studio/tier5-src/himi-branded-lite-programs/index.ts +31 -18
- package/templates/yoga-studio/tier5-src/himi-events-my-events/index.ts +76 -42
- package/templates/yoga-studio-owner/config.ts +1 -1
- package/templates/yoga-studio-owner/dev/index.ts +2 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { memberAccess, memberAccessChanged, memberAccessDenied, type MemberAccess } from "./member-access.js";
|
|
2
|
+
import { needsSignIn } from "./branded-load-state.js";
|
|
3
|
+
|
|
4
|
+
/** Public reads stay public. Capture their reader only to reject a result that
|
|
5
|
+
* belongs to the identity/site which was active before the request. */
|
|
6
|
+
export interface ReadAccess { member: MemberAccess; tenant: string; }
|
|
7
|
+
export async function readAccess(): Promise<ReadAccess> {
|
|
8
|
+
const member = await memberAccess();
|
|
9
|
+
const input = (globalThis as { himalaya?: { input?: Record<string, unknown> } }).himalaya?.input;
|
|
10
|
+
return { member, tenant: JSON.stringify([input?.__himiPreferenceAccount ?? "", input?.__himiPreferenceBusiness ?? ""]) };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function assertReadAccess(access: ReadAccess): Promise<void> {
|
|
14
|
+
const current = await readAccess();
|
|
15
|
+
if (current.member.email !== access.member.email || current.member.scope !== access.member.scope || current.tenant !== access.tenant) throw memberAccessChanged();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Bridge errors put the actual status first; codes quoted inside the body are data. */
|
|
19
|
+
function httpStatus(error: unknown): string | undefined {
|
|
20
|
+
return /^HTTP\s*(\d{3})\b/i.exec(String((error as { message?: unknown })?.message ?? error))?.[1];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const NO_READ_SIGN_IN = { signInRequired: false, noSignIn: true };
|
|
24
|
+
|
|
25
|
+
/** An authorization refusal must not fall back to a previously cached article. */
|
|
26
|
+
export function readAccessDenied(error: unknown): boolean {
|
|
27
|
+
let cause = error;
|
|
28
|
+
for (let depth = 0; cause && depth < 4; depth++) {
|
|
29
|
+
const status = httpStatus(cause);
|
|
30
|
+
if (status ? status === "401" || status === "403" : memberAccessDenied(cause) || needsSignIn(cause)) return true;
|
|
31
|
+
cause = (cause as { cause?: unknown }).cause;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A permission failure alone says nothing about whether signing in can help.
|
|
37
|
+
* In particular, a private member profile can be unavailable to members too.
|
|
38
|
+
* Only an authentication refusal for a current visitor offers Sign in. Follow
|
|
39
|
+
* SDK wrapper causes (blog getPost preserves its original read error there). */
|
|
40
|
+
export async function readSignInFlags(error: unknown): Promise<typeof NO_READ_SIGN_IN> {
|
|
41
|
+
let authenticationRequired = false;
|
|
42
|
+
let permissionRefused = false;
|
|
43
|
+
let cause = error;
|
|
44
|
+
for (let depth = 0; cause && depth < 4; depth++) {
|
|
45
|
+
const status = httpStatus(cause);
|
|
46
|
+
permissionRefused ||= status === "403";
|
|
47
|
+
authenticationRequired ||= status ? status === "401" : needsSignIn(cause);
|
|
48
|
+
cause = (cause as { cause?: unknown }).cause;
|
|
49
|
+
}
|
|
50
|
+
const signInRequired = !permissionRefused && authenticationRequired && !(await memberAccess()).email;
|
|
51
|
+
return { signInRequired, noSignIn: !signInRequired };
|
|
52
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WixProgram } from "@himalaya/wix-online-programs";
|
|
2
|
+
|
|
3
|
+
/** v3 nests the body in description.details; older responses use settings or a
|
|
4
|
+
* flat description. The body itself may be a Ricos document or serialized text. */
|
|
5
|
+
export function programDescription(program: WixProgram): unknown {
|
|
6
|
+
const raw = (program as { description?: unknown }).description;
|
|
7
|
+
const nested = raw && typeof raw === "object" ? raw as { details?: unknown; nodes?: unknown } : undefined;
|
|
8
|
+
return program.settings?.description ?? nested?.details
|
|
9
|
+
?? (typeof raw === "string" || Array.isArray(nested?.nodes) ? raw : undefined)
|
|
10
|
+
?? program.details?.description;
|
|
11
|
+
}
|
|
@@ -9,6 +9,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
|
|
|
9
9
|
import { formatDateMedium, formatMonthDay } from "../_shared/engine-intl.js";
|
|
10
10
|
import { openRichLink } from "../_shared/rich-content-link.js";
|
|
11
11
|
import { richBody, ROW_IMAGE_WIDTH } from "../_shared/rich-body.js";
|
|
12
|
+
import { readAccess, assertReadAccess, readAccessDenied, readSignInFlags, NO_READ_SIGN_IN } from "../_shared/member-read.js";
|
|
12
13
|
|
|
13
14
|
// Offline-first (data-offline): the post body is a public read-through — when the
|
|
14
15
|
// live fetch fails (offline) fall back to the last-synced row the feed cached under
|
|
@@ -34,6 +35,7 @@ interface CommentRow {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
interface S {
|
|
38
|
+
signInRequired: boolean; noSignIn: boolean; signInScreenId: string;
|
|
37
39
|
status: "loading" | "ready" | "error";
|
|
38
40
|
id: string;
|
|
39
41
|
title: string;
|
|
@@ -214,6 +216,7 @@ function derive(s: S): S {
|
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
const baseState: S = derive({
|
|
219
|
+
...NO_READ_SIGN_IN, signInScreenId: "himi_account",
|
|
217
220
|
status: "loading",
|
|
218
221
|
id: "",
|
|
219
222
|
title: "",
|
|
@@ -280,23 +283,28 @@ async function cachedPostState(s: S, id: string): Promise<S> {
|
|
|
280
283
|
});
|
|
281
284
|
}
|
|
282
285
|
|
|
283
|
-
|
|
286
|
+
let loadVersion = 0;
|
|
287
|
+
async function loadPostState(s: S): Promise<S | undefined> {
|
|
288
|
+
const version = ++loadVersion;
|
|
289
|
+
await svc.prepare();
|
|
290
|
+
const clean = { ...baseState, signInScreenId: s.signInScreenId };
|
|
284
291
|
const id = inputId();
|
|
285
292
|
if (!id) {
|
|
286
|
-
return derive({ ...
|
|
293
|
+
return derive({ ...clean, status: "ready", emptyText: copyParam("blogPost.notFoundText", "Post not found.") });
|
|
287
294
|
}
|
|
288
295
|
try {
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
296
|
+
const access = await readAccess();
|
|
297
|
+
const [postResult, commentsResult] = await Promise.allSettled([getPost(id, {}, { preserveAccessErrors: true }), listBlogComments(id)]);
|
|
298
|
+
if (postResult.status === "rejected") throw postResult.reason;
|
|
299
|
+
await assertReadAccess(access);
|
|
300
|
+
if (version !== loadVersion) return undefined;
|
|
293
301
|
const post = (((postResult.value as unknown as { post?: WixPost }).post) ?? postResult.value) as PostWithExtras;
|
|
294
302
|
const commentsUnavailable = commentsResult.status === "rejected";
|
|
295
303
|
const comments = commentsResult.status === "fulfilled" ? commentsResult.value.map(toCommentRow) : [];
|
|
296
304
|
const cover = imageUrl(post);
|
|
297
305
|
const title = post.title || "Untitled post";
|
|
298
306
|
return derive({
|
|
299
|
-
...
|
|
307
|
+
...clean,
|
|
300
308
|
status: "ready",
|
|
301
309
|
id,
|
|
302
310
|
title,
|
|
@@ -319,14 +327,23 @@ async function loadPostState(s: S): Promise<S> {
|
|
|
319
327
|
errorText: "",
|
|
320
328
|
emptyText: "",
|
|
321
329
|
});
|
|
322
|
-
} catch {
|
|
323
|
-
|
|
330
|
+
} catch (error) {
|
|
331
|
+
const flags = await readSignInFlags(error);
|
|
332
|
+
const failed = derive({ ...clean, ...flags, status: "error", id, errorText: copyParam("blogPost.errorText", "This post could not load.") });
|
|
333
|
+
if (version !== loadVersion) return undefined;
|
|
334
|
+
if (readAccessDenied(error)) return failed;
|
|
335
|
+
const access = await readAccess();
|
|
336
|
+
const cached = await cachedPostState(clean, id);
|
|
337
|
+
try { await assertReadAccess(access); }
|
|
338
|
+
catch { return version === loadVersion ? failed : undefined; }
|
|
339
|
+
return version === loadVersion ? cached : undefined;
|
|
324
340
|
}
|
|
325
341
|
}
|
|
326
342
|
|
|
327
343
|
const svc = defineService<S, {
|
|
328
|
-
|
|
329
|
-
|
|
344
|
+
prepare: (s: S) => S;
|
|
345
|
+
load: (s: S, arg?: unknown) => Promise<S | undefined>;
|
|
346
|
+
retry: (s: S) => Promise<S | undefined>;
|
|
330
347
|
like: (s: S) => Promise<S>;
|
|
331
348
|
unlike: (s: S) => Promise<S>;
|
|
332
349
|
toggleSave: (s: S) => S;
|
|
@@ -338,7 +355,12 @@ const svc = defineService<S, {
|
|
|
338
355
|
}>("himiBlogPost", {
|
|
339
356
|
state: baseState,
|
|
340
357
|
actions: {
|
|
341
|
-
|
|
358
|
+
prepare: (s) => ({ ...s, ...baseState }),
|
|
359
|
+
load: (s, arg) => {
|
|
360
|
+
stashCopy(arg);
|
|
361
|
+
const target = (arg as { signInScreenId?: unknown })?.signInScreenId;
|
|
362
|
+
return loadPostState({ ...s, signInScreenId: target === "himi_sign_in" ? target : s.signInScreenId });
|
|
363
|
+
},
|
|
342
364
|
retry: (s) => loadPostState({ ...s, status: "loading", errorText: "" }),
|
|
343
365
|
like: async (s) => {
|
|
344
366
|
if (!s.id) return derive({ ...s, actionMessage: copyParam("blogPost.noPostMessage", "No post selected.") });
|
|
@@ -409,5 +431,6 @@ const svc = defineService<S, {
|
|
|
409
431
|
},
|
|
410
432
|
});
|
|
411
433
|
|
|
434
|
+
svc.prepare();
|
|
412
435
|
svc.load();
|
|
413
436
|
export { svc };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { descriptionBody } from "../_shared/rich-body.js";
|
|
2
|
+
import { programDescription } from "../_shared/program-description.js";
|
|
1
3
|
import { fetchMemberBookings, type MemberBookingRow } from "../_shared/member-bookings.js";
|
|
2
4
|
import { hostSiteFromInput, hostedExploreCards, hostedHiddenFlags, type HostedExploreCard } from "../_shared/branded-lite-hosted.js";
|
|
3
5
|
import { memberAccess, assertMemberAccess } from "../_shared/member-access.js";
|
|
@@ -675,11 +677,9 @@ async function fetchHomePrograms(): Promise<ProgramCard[]> {
|
|
|
675
677
|
.map((p: WixProgram) => {
|
|
676
678
|
const desc = (p as { description?: unknown }).description;
|
|
677
679
|
const nestedTitle = desc && typeof desc === "object" ? (desc as { title?: string }).title : undefined;
|
|
678
|
-
const nestedDetails = desc && typeof desc === "object" ? (desc as { details?: string }).details : undefined;
|
|
679
680
|
const name = cleanTitle(p.settings?.title ?? nestedTitle ?? p.title) || copyParam("home.programFallbackName", "Program");
|
|
680
681
|
const image = programImage(p);
|
|
681
|
-
const details = (p.
|
|
682
|
-
.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
682
|
+
const details = descriptionBody(programDescription(p)).bodyText.replace(/\s+/g, " ").trim();
|
|
683
683
|
return {
|
|
684
684
|
id: p.id || name,
|
|
685
685
|
name,
|
|
@@ -5,6 +5,8 @@ import { queryEvents, type WixEvent } from "@himalaya/wix-events";
|
|
|
5
5
|
import { getAll, upsert, type DbEntity } from "@himalaya/local-db";
|
|
6
6
|
import { confirmedRsvpIds, eventStartMillis, normalizeEvent, type EventRow } from "../_shared/himi-events";
|
|
7
7
|
import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
|
|
8
|
+
import { memberAccess } from "../_shared/member-access.js";
|
|
9
|
+
import { readAccess, assertReadAccess, readAccessDenied, readSignInFlags, NO_READ_SIGN_IN } from "../_shared/member-read.js";
|
|
8
10
|
|
|
9
11
|
// Offline-first (data-offline): My Events is a read-through over the same `events`
|
|
10
12
|
// catalog the list caches — paint the last-synced rows (filtered to this device's
|
|
@@ -27,6 +29,7 @@ async function writeCached(rows: CachedEventRow[]): Promise<void> {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
interface S {
|
|
32
|
+
signInRequired: boolean; noSignIn: boolean; signInScreenId: string;
|
|
30
33
|
status: "loading" | "ready";
|
|
31
34
|
events: EventRow[];
|
|
32
35
|
emptyText: string;
|
|
@@ -98,11 +101,10 @@ function unverifiedEvent(event: CachedEventRow): CachedEventRow {
|
|
|
98
101
|
};
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
|
|
105
|
-
async function confirmRsvps(candidates: CachedEventRow[]): Promise<{ events: CachedEventRow[]; verificationUnavailable: boolean }> {
|
|
104
|
+
/** Verify device-local candidates against the current member. Member-only mode
|
|
105
|
+
* requires successful verification; standalone mode retains failed probes as
|
|
106
|
+
* explicitly unverified device-local history. */
|
|
107
|
+
async function confirmRsvps(candidates: CachedEventRow[], memberOnly = false): Promise<{ events: CachedEventRow[]; verificationUnavailable: boolean }> {
|
|
106
108
|
// Raw wixApi chokepoint rather than a generated client: the member RSVP read lives in
|
|
107
109
|
// events **v2**, and `@himalaya/wix-events` is the v1 domain module. Adding a
|
|
108
110
|
// `wix-events-v2` specifier is not an option — the umbrella package deliberately
|
|
@@ -122,7 +124,9 @@ async function confirmRsvps(candidates: CachedEventRow[]): Promise<{ events: Cac
|
|
|
122
124
|
event: held ? { ...event, status: [event.status, copyParam("myEvents.rsvpConfirmed", "RSVP confirmed")].filter(Boolean).join(" · ") } : null,
|
|
123
125
|
verificationUnavailable: false,
|
|
124
126
|
};
|
|
125
|
-
} catch {
|
|
127
|
+
} catch (error) {
|
|
128
|
+
// Device candidates carry no member ownership proof until this read succeeds.
|
|
129
|
+
if (memberOnly) throw error;
|
|
126
130
|
// Fail-open, but never claim backend confirmation while its member-readable
|
|
127
131
|
// probe is unavailable. The device id remains a candidate, explicitly labeled.
|
|
128
132
|
return { event: unverifiedEvent(event), verificationUnavailable: true };
|
|
@@ -134,8 +138,8 @@ async function confirmRsvps(candidates: CachedEventRow[]): Promise<{ events: Cac
|
|
|
134
138
|
};
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
const
|
|
138
|
-
|
|
141
|
+
const INITIAL: S = derive({
|
|
142
|
+
...NO_READ_SIGN_IN, signInScreenId: "himi_account",
|
|
139
143
|
status: "loading",
|
|
140
144
|
events: [],
|
|
141
145
|
emptyText: "",
|
|
@@ -147,45 +151,75 @@ const svc = defineService<S, { load: (s: S, arg?: unknown) => Promise<S> }>("him
|
|
|
147
151
|
isLoading: true,
|
|
148
152
|
notLoading: false,
|
|
149
153
|
noEmpty: true,
|
|
150
|
-
})
|
|
154
|
+
});
|
|
155
|
+
let memberOnlyRequested = false;
|
|
156
|
+
let loadVersion = 0;
|
|
157
|
+
const svc = defineService<S, { prepare: (s: S) => S; load: (s: S, arg?: unknown) => Promise<S | undefined> }>("himiMyEvents", {
|
|
158
|
+
state: INITIAL,
|
|
151
159
|
actions: {
|
|
152
|
-
|
|
160
|
+
prepare: (s) => ({ ...s, ...INITIAL }),
|
|
161
|
+
load: async (s, arg): Promise<S | undefined> => {
|
|
153
162
|
stashCopy(arg);
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
? derive({ ...s, status: "ready", errored: false, events: cachedEvents, identityLine: identity, verificationUnavailable: cachedEvents.length > 0 })
|
|
161
|
-
: s;
|
|
162
|
-
// 2) Revalidate from Wix and refresh the cache.
|
|
163
|
+
const version = ++loadVersion;
|
|
164
|
+
const options = arg as { memberOnly?: unknown; signInScreenId?: unknown } | undefined;
|
|
165
|
+
if (options?.memberOnly !== undefined) memberOnlyRequested = options.memberOnly === "1";
|
|
166
|
+
const memberOnly = memberOnlyRequested;
|
|
167
|
+
const clean = { ...INITIAL, signInScreenId: options?.signInScreenId === "himi_sign_in" ? "himi_sign_in" : s.signInScreenId };
|
|
168
|
+
await svc.prepare();
|
|
163
169
|
try {
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
170
|
+
const member = memberOnly ? await readAccess() : null;
|
|
171
|
+
if (memberOnly && !member?.member.email) throw new Error("Unauthenticated: sign in to see your events");
|
|
172
|
+
const confirmed = new Set(confirmedRsvpIds());
|
|
173
|
+
const identity = await identityLine();
|
|
174
|
+
// 1) Instant paint from the on-device cache (offline-safe; empty on first-ever run).
|
|
175
|
+
// Device-local candidates have no member ownership proof. Branded must
|
|
176
|
+
// verify them online rather than show a previous member's cached RSVP list.
|
|
177
|
+
const cached = memberOnly ? [] : await readCached();
|
|
178
|
+
const cachedEvents = cached.filter((event) => confirmed.has(event.id)).map(displayEventRow);
|
|
179
|
+
const base = cached.length
|
|
180
|
+
? derive({ ...clean, status: "ready", errored: false, events: cachedEvents, identityLine: identity, verificationUnavailable: cachedEvents.length > 0 })
|
|
181
|
+
: clean;
|
|
182
|
+
// 2) Revalidate from Wix and refresh the cache.
|
|
183
|
+
try {
|
|
184
|
+
const res = await queryEvents({ limit: 50 });
|
|
185
|
+
const all = ((res as unknown as { events?: WixEvent[] }).events ?? []).map(cachedEventRow);
|
|
186
|
+
if (member) await assertReadAccess(member);
|
|
187
|
+
if (version !== loadVersion) return undefined;
|
|
188
|
+
await writeCached(all);
|
|
189
|
+
// Phase 3c — make each row AUTHORITATIVE. The device list is only a candidate
|
|
190
|
+
// set: it never forgets, so an RSVP cancelled elsewhere (web, or by the
|
|
191
|
+
// business) would otherwise show here forever. Confirm each candidate against
|
|
192
|
+
// Wix and drop the ones the member no longer holds.
|
|
193
|
+
//
|
|
194
|
+
// Per-event by necessity, not by choice: a member CANNOT enumerate their own
|
|
195
|
+
// RSVPs. Verified live against a real member token — `queryRsvps` (cross-event)
|
|
196
|
+
// 403s "WIX_EVENTS.READ_RSVP permission required", `listOrders` 403s
|
|
197
|
+
// READ_ORDERS, and `/rsvps/current` 400s without an eventId. Only the
|
|
198
|
+
// single-event read is member-readable, so the fan-out below IS the ceiling
|
|
199
|
+
// until those member scopes exist server-side.
|
|
200
|
+
const candidates = all.filter((event) => confirmed.has(event.id)).map(displayEventRow);
|
|
201
|
+
const confirmation = await confirmRsvps(candidates, memberOnly);
|
|
202
|
+
if (member) await assertReadAccess(member);
|
|
203
|
+
if (version !== loadVersion) return undefined;
|
|
204
|
+
return derive({ ...base, status: "ready", errored: false, events: confirmation.events, identityLine: identity, verificationUnavailable: confirmation.verificationUnavailable });
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (memberOnly && readAccessDenied(error)) throw error;
|
|
207
|
+
if (member) await assertReadAccess(member);
|
|
208
|
+
if (version !== loadVersion) return undefined;
|
|
209
|
+
// Offline / fetch failure: keep the cached rows instead of a blank error state.
|
|
210
|
+
return cached.length
|
|
211
|
+
? base
|
|
212
|
+
: derive({ ...clean, status: "ready", errored: true, events: [], identityLine: identity });
|
|
213
|
+
}
|
|
214
|
+
} catch (error) {
|
|
215
|
+
const failure = memberOnly && !(await memberAccess()).email ? new Error("Unauthenticated: sign in to see your events") : error;
|
|
216
|
+
const flags = await readSignInFlags(failure);
|
|
217
|
+
return version === loadVersion ? derive({ ...clean, ...flags, status: "ready", errored: true, events: [] }) : undefined;
|
|
186
218
|
}
|
|
187
219
|
},
|
|
188
220
|
},
|
|
189
221
|
});
|
|
190
|
-
|
|
222
|
+
// Wait for the descriptor's load action to select member-only or device-local scope.
|
|
223
|
+
// An eager unconfigured read could briefly expose guest KV before Branded opts in.
|
|
224
|
+
svc.prepare();
|
|
191
225
|
export { svc };
|
|
@@ -15,7 +15,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
|
|
|
15
15
|
import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
|
|
16
16
|
import { isProductSaved, toggleSavedProduct } from "../_shared/himi-store-saved.js";
|
|
17
17
|
import { openRichLink } from "../_shared/rich-content-link.js";
|
|
18
|
-
import {
|
|
18
|
+
import { descriptionBody } from "../_shared/rich-body.js";
|
|
19
19
|
|
|
20
20
|
// Offline-first (data-offline): the detail is a public READ-THROUGH — when the live
|
|
21
21
|
// product fetch fails (offline) fall back to the last-synced row the catalog cached
|
|
@@ -85,9 +85,7 @@ function productPolicyBody(product: StoreProduct, kind: "returns" | "shipping"):
|
|
|
85
85
|
});
|
|
86
86
|
if (!section) return "";
|
|
87
87
|
const html = "plainDescription" in section ? section.plainDescription : undefined;
|
|
88
|
-
|
|
89
|
-
if (typeof section.description === "string") return plainText(section.description.replace(/ /gi, " "));
|
|
90
|
-
return richBody(section.description).bodyText;
|
|
88
|
+
return descriptionBody(html || section.description).bodyText;
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
/** The product id `lastProduct` was read for. A pooled screen re-appearing calls
|
|
@@ -170,13 +168,12 @@ function optionsHint(groups: StoreOption[], selection: StoreOptionSelection): st
|
|
|
170
168
|
return copyTemplate("product.optionsChoose", "Choose {options}", { options: missing.join(", ") });
|
|
171
169
|
}
|
|
172
170
|
|
|
173
|
-
/**
|
|
174
|
-
*
|
|
175
|
-
* `description` is an HTML string: stripped text, no document. */
|
|
171
|
+
/** Catalog V3 returns Ricos objects or serialized documents; V1 returns HTML.
|
|
172
|
+
* Keep plainDescription as the independent fallback, never raw document JSON. */
|
|
176
173
|
function productBody(p: StoreProduct): { description: string; descriptionJson: string } {
|
|
177
174
|
const raw = (p as { description?: unknown }).description;
|
|
178
|
-
const html =
|
|
179
|
-
const { bodyJson, bodyText } =
|
|
175
|
+
const html = descriptionBody(p.plainDescription).bodyText;
|
|
176
|
+
const { bodyJson, bodyText } = descriptionBody(raw, html);
|
|
180
177
|
return { description: html || bodyText, descriptionJson: bodyJson };
|
|
181
178
|
}
|
|
182
179
|
|
|
@@ -37,7 +37,7 @@ export default defineApp({
|
|
|
37
37
|
actions: "http://localhost:8190/v1/actions",
|
|
38
38
|
sync: "http://localhost:8190/v1/sync",
|
|
39
39
|
},
|
|
40
|
-
capabilities: ["live_activity","push","share","secure_storage","open_url","local_database","clipboard","ui","speech","camera","photos","file_picker","files","presigned_upload","app_info","biometrics","wix_platform","
|
|
40
|
+
capabilities: ["live_activity","push","share","secure_storage","open_url","local_database","clipboard","ui","speech","camera","photos","file_picker","files","presigned_upload","app_info","biometrics","wix_platform","stream","wix_api"],
|
|
41
41
|
designTokensPath: "./tokens.json",
|
|
42
42
|
// Native fallback; the T5 splash descriptor owns the editable launch appearance.
|
|
43
43
|
splash: {
|
|
@@ -52829,8 +52829,7 @@ const SCREENS = runtimeSetting({
|
|
|
52829
52829
|
"params": {
|
|
52830
52830
|
"screenId": "himi_owner_lite_search",
|
|
52831
52831
|
"title": "Search records",
|
|
52832
|
-
"subtitle": "Across your business areas"
|
|
52833
|
-
"search": "drawer"
|
|
52832
|
+
"subtitle": "Across your business areas"
|
|
52834
52833
|
}
|
|
52835
52834
|
},
|
|
52836
52835
|
"pressFeedback": "scale",
|
|
@@ -54349,7 +54348,7 @@ const SCREENS = runtimeSetting({
|
|
|
54349
54348
|
"actionId": "tier5.himiOwnerLiteSearch.search"
|
|
54350
54349
|
},
|
|
54351
54350
|
"debounceMs": 200,
|
|
54352
|
-
"
|
|
54351
|
+
"loadingPath": "$service:himiOwnerLiteSearch.anyLoading"
|
|
54353
54352
|
}
|
|
54354
54353
|
}
|
|
54355
54354
|
},
|
|
@@ -37,7 +37,7 @@ export default defineApp({
|
|
|
37
37
|
actions: "http://localhost:8190/v1/actions",
|
|
38
38
|
sync: "http://localhost:8190/v1/sync",
|
|
39
39
|
},
|
|
40
|
-
capabilities: ["
|
|
40
|
+
capabilities: ["push","share","secure_storage","open_url","calendar","local_database","wix_api","wix_platform","app_info","iap","release_control","clipboard","theme","wix_cashier"],
|
|
41
41
|
cache: {
|
|
42
42
|
"rules": [
|
|
43
43
|
{
|
|
@@ -16323,6 +16323,9 @@ const SCREENS = runtimeSetting({
|
|
|
16323
16323
|
"style": "body",
|
|
16324
16324
|
"color": "textSecondary"
|
|
16325
16325
|
}
|
|
16326
|
+
},
|
|
16327
|
+
"modifiers": {
|
|
16328
|
+
"hiddenPath": "$service:himiMyEvents.signInRequired"
|
|
16326
16329
|
}
|
|
16327
16330
|
},
|
|
16328
16331
|
{
|
|
@@ -16337,6 +16340,32 @@ const SCREENS = runtimeSetting({
|
|
|
16337
16340
|
"actionId": "tier5.himiMyEvents.load"
|
|
16338
16341
|
}
|
|
16339
16342
|
}
|
|
16343
|
+
},
|
|
16344
|
+
"modifiers": {
|
|
16345
|
+
"hiddenPath": "$service:himiMyEvents.signInRequired"
|
|
16346
|
+
}
|
|
16347
|
+
},
|
|
16348
|
+
{
|
|
16349
|
+
"id": "himi_my_events.retry.sign_in",
|
|
16350
|
+
"body": {
|
|
16351
|
+
"package": "himalaya",
|
|
16352
|
+
"type": "Button",
|
|
16353
|
+
"props": {
|
|
16354
|
+
"title": "Sign in",
|
|
16355
|
+
"style": "primary",
|
|
16356
|
+
"action": {
|
|
16357
|
+
"actionId": "himi.open",
|
|
16358
|
+
"params": {
|
|
16359
|
+
"screenId": "himi_sign_in",
|
|
16360
|
+
"mode": "signin",
|
|
16361
|
+
"modal": "1"
|
|
16362
|
+
},
|
|
16363
|
+
"presentation": "sheet"
|
|
16364
|
+
}
|
|
16365
|
+
}
|
|
16366
|
+
},
|
|
16367
|
+
"modifiers": {
|
|
16368
|
+
"hiddenPath": "$service:himiMyEvents.noSignIn"
|
|
16340
16369
|
}
|
|
16341
16370
|
}
|
|
16342
16371
|
]
|
|
@@ -16767,7 +16796,11 @@ const SCREENS = runtimeSetting({
|
|
|
16767
16796
|
"bottom": 24
|
|
16768
16797
|
},
|
|
16769
16798
|
"onAppear": {
|
|
16770
|
-
"actionId": "tier5.himiMyEvents.load"
|
|
16799
|
+
"actionId": "tier5.himiMyEvents.load",
|
|
16800
|
+
"params": {
|
|
16801
|
+
"signInScreenId": "himi_sign_in",
|
|
16802
|
+
"memberOnly": "1"
|
|
16803
|
+
}
|
|
16771
16804
|
}
|
|
16772
16805
|
}
|
|
16773
16806
|
},
|
|
@@ -25966,6 +25999,9 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
|
|
|
25966
25999
|
"style": "body",
|
|
25967
26000
|
"color": "textSecondary"
|
|
25968
26001
|
}
|
|
26002
|
+
},
|
|
26003
|
+
"modifiers": {
|
|
26004
|
+
"hiddenPath": "$service:himiBlogPost.signInRequired"
|
|
25969
26005
|
}
|
|
25970
26006
|
},
|
|
25971
26007
|
{
|
|
@@ -25980,6 +26016,32 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
|
|
|
25980
26016
|
"actionId": "tier5.himiBlogPost.retry"
|
|
25981
26017
|
}
|
|
25982
26018
|
}
|
|
26019
|
+
},
|
|
26020
|
+
"modifiers": {
|
|
26021
|
+
"hiddenPath": "$service:himiBlogPost.signInRequired"
|
|
26022
|
+
}
|
|
26023
|
+
},
|
|
26024
|
+
{
|
|
26025
|
+
"id": "himi_blog_post.retry.sign_in",
|
|
26026
|
+
"body": {
|
|
26027
|
+
"package": "himalaya",
|
|
26028
|
+
"type": "Button",
|
|
26029
|
+
"props": {
|
|
26030
|
+
"title": "Sign in",
|
|
26031
|
+
"style": "primary",
|
|
26032
|
+
"action": {
|
|
26033
|
+
"actionId": "himi.open",
|
|
26034
|
+
"params": {
|
|
26035
|
+
"screenId": "himi_sign_in",
|
|
26036
|
+
"mode": "signin",
|
|
26037
|
+
"modal": "1"
|
|
26038
|
+
},
|
|
26039
|
+
"presentation": "sheet"
|
|
26040
|
+
}
|
|
26041
|
+
}
|
|
26042
|
+
},
|
|
26043
|
+
"modifiers": {
|
|
26044
|
+
"hiddenPath": "$service:himiBlogPost.noSignIn"
|
|
25983
26045
|
}
|
|
25984
26046
|
}
|
|
25985
26047
|
]
|
|
@@ -26684,7 +26746,8 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
|
|
|
26684
26746
|
"onAppear": {
|
|
26685
26747
|
"actionId": "tier5.himiBlogPost.load",
|
|
26686
26748
|
"params": {
|
|
26687
|
-
"id": "__HIMI_ID__"
|
|
26749
|
+
"id": "__HIMI_ID__",
|
|
26750
|
+
"signInScreenId": "himi_sign_in"
|
|
26688
26751
|
}
|
|
26689
26752
|
}
|
|
26690
26753
|
}
|