@wix/himalaya-cli 0.1672.0 → 0.1674.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.
Files changed (44) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/legacy-import/src/index.d.ts +16 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/legacy-import.d.ts +21 -3
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/online-programs/src/index.d.ts +4 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +14 -2
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/legacy-import.mjs +32 -1
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-online-programs.mjs +25 -1
  7. package/dist/browser-plane/assets.json +5 -5
  8. package/dist/browser-plane/preview-deferred/{cf2ac6865a1e6be5cccec4f2538bf18bbbf121a5f5971ad46212bf3a848ec35c.bin → 0f5533bf4197dc43489701db18378cecdb02db230a0fc2603e764999544513da.bin} +1 -1
  9. package/dist/browser-plane/sw.js +6 -6
  10. package/dist/cli.mjs +366 -110
  11. package/dist/preview-assets.generated.bin +0 -0
  12. package/guides/himi-json-output.md +5 -0
  13. package/guides/releasing-with-himi-serve.md +10 -2
  14. package/guides/sdk-reference.json +17 -3
  15. package/guides/skill.md +1 -0
  16. package/guides/web-page-sdk-reference.md +1 -1
  17. package/package.json +2 -2
  18. package/templates/beauty-salon/l10n/en.json +1 -1
  19. package/templates/branded-lite/dev/index.ts +6607 -2231
  20. package/templates/branded-lite/l10n/en.json +25 -15
  21. package/templates/branded-lite/l10n/he.json +34 -34
  22. package/templates/branded-lite/tier5-src/_shared/himi-cms.ts +10 -3
  23. package/templates/branded-lite/tier5-src/_shared/program-standing.ts +6 -0
  24. package/templates/branded-lite/tier5-src/himi-branded-lite-cms/index.ts +7 -0
  25. package/templates/branded-lite/tier5-src/himi-branded-lite-cms-collection/index.ts +527 -138
  26. package/templates/branded-lite/tier5-src/himi-branded-lite-member-programs/index.ts +36 -7
  27. package/templates/branded-lite/tier5-src/himi-branded-lite-program/index.ts +30 -17
  28. package/templates/community-club/dev/index.ts +2459 -271
  29. package/templates/community-club/l10n/en.json +16 -11
  30. package/templates/community-club/l10n/he.json +38 -34
  31. package/templates/community-club/tier5-src/_shared/himi-cms.ts +10 -3
  32. package/templates/community-club/tier5-src/himi-branded-lite-cms/index.ts +7 -0
  33. package/templates/community-club/tier5-src/himi-branded-lite-cms-collection/index.ts +527 -138
  34. package/templates/events-meetups/l10n/en.json +1 -1
  35. package/templates/gym-fitness/l10n/en.json +1 -1
  36. package/templates/nonprofit-cause/l10n/en.json +1 -1
  37. package/templates/podcast-creator/l10n/en.json +1 -1
  38. package/templates/portfolio-creative/l10n/en.json +1 -1
  39. package/templates/restaurant/l10n/en.json +1 -1
  40. package/templates/retail-store/l10n/en.json +1 -1
  41. package/templates/yoga-studio/l10n/en.json +1 -1
  42. package/templates/yoga-studio/tier5-src/_shared/program-standing.ts +6 -0
  43. package/templates/yoga-studio/tier5-src/himi-branded-lite-member-programs/index.ts +36 -7
  44. package/templates/yoga-studio/tier5-src/himi-branded-lite-program/index.ts +30 -17
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-11T22:30:17.102Z",
3
+ "$generated": "2026-11-11T23:43:24.040Z",
4
4
  "messages": {
5
5
  "h_01e1787a9e5b": {
6
6
  "source": "App language",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-11T22:30:17.102Z",
3
+ "$generated": "2026-11-11T23:43:24.040Z",
4
4
  "messages": {
5
5
  "h_0028d743eb44": {
6
6
  "source": "Sale",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-11T22:30:17.102Z",
3
+ "$generated": "2026-11-11T23:43:24.040Z",
4
4
  "messages": {
5
5
  "h_01e1787a9e5b": {
6
6
  "source": "App language",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-11T22:30:17.102Z",
3
+ "$generated": "2026-11-11T23:43:24.040Z",
4
4
  "messages": {
5
5
  "h_01e1787a9e5b": {
6
6
  "source": "App language",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-11T22:30:17.102Z",
3
+ "$generated": "2026-11-11T23:43:24.040Z",
4
4
  "messages": {
5
5
  "h_0028d743eb44": {
6
6
  "source": "Sale",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-11T22:30:17.102Z",
3
+ "$generated": "2026-11-11T23:43:24.040Z",
4
4
  "messages": {
5
5
  "h_01e1787a9e5b": {
6
6
  "source": "App language",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-11T22:30:17.102Z",
3
+ "$generated": "2026-11-11T23:43:24.040Z",
4
4
  "messages": {
5
5
  "h_0028d743eb44": {
6
6
  "source": "Sale",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-11T22:30:17.102Z",
3
+ "$generated": "2026-11-11T23:43:24.040Z",
4
4
  "messages": {
5
5
  "h_01e1787a9e5b": {
6
6
  "source": "App language",
@@ -5,6 +5,12 @@ import type { WixJoinApplication, WixParticipant } from "@himalaya/wix-online-pr
5
5
  export type Standing = "none" | "joined" | "completed" | "finished" | "suspended" | "pending" | "approved" | "invited";
6
6
 
7
7
  export function standingOf(ended: boolean, participant: WixParticipant | undefined, application: WixJoinApplication | undefined): Standing {
8
+ // A withdrawn participant is history even if its old progress says completed.
9
+ // Only its matching admitted application is history too; newer requests remain visible.
10
+ if (["LEFT", "REMOVED", "AUTO_REMOVED"].includes((participant?.enrollmentStatus ?? "").toUpperCase())) {
11
+ if (participant?.id && application?.participantId === participant.id && application.status?.toUpperCase() === "APPROVED") application = undefined;
12
+ participant = undefined;
13
+ }
8
14
  if (participant) {
9
15
  const progress = (participant.progressStatus ?? "").toUpperCase();
10
16
  const enrollment = (participant.enrollmentStatus ?? "").toUpperCase();
@@ -14,7 +14,7 @@
14
14
  // ProgressBar and two filters. The shared query controller is reused as it is.
15
15
  import { defineService as register, navigate } from "@himalaya/state";
16
16
  import {
17
- queryPrograms, getParticipationStats, queryMemberParticipants, getCurrentJoinApplication, listProgramCategories,
17
+ queryPrograms, getParticipationStats, queryMemberParticipants, getCurrentJoinApplication, listProgramCategories, searchMemberParticipation, participationsByProgram,
18
18
  type WixProgram, type WixProgramFull, type WixParticipant, type WixJoinApplication, type WixProgramCategory,
19
19
  } from "@himalaya/wix-online-programs";
20
20
  import { getMyMember } from "@himalaya/wix-members";
@@ -356,19 +356,47 @@ async function participationsFor(scope: Scope, firstPage: boolean, required: boo
356
356
  }
357
357
 
358
358
  /** Only where an application can exist: an unjoined PRIVATE, SECRET (invite-only) or priced program, for a member. */
359
- async function applicationsFor(programs: WixProgram[], participations: Participations, scope: Scope): Promise<{ map: Map<string, WixJoinApplication>; unknown: Set<string> }> {
359
+ async function applicationsFor(programs: WixProgram[], participations: Participations, scope: Scope): Promise<{ map: Map<string, WixJoinApplication>; reconciled: Participations; unknown: Set<string> }> {
360
360
  const result = new Map<string, WixJoinApplication>();
361
+ const reconciled: Participations = new Map();
361
362
  // A failed read is not "no application": those programs make no join claim (see programContent).
362
363
  const unknown = new Set<string>();
363
- if (!scope.memberId) return { map: result, unknown };
364
+ if (!scope.memberId) return { map: result, reconciled, unknown };
364
365
  const candidates = programs.filter((p) => !participations.has(p.id) && (accessType(p) === "PRIVATE" || accessType(p) === "SECRET" || !!commercePriceOf(p)));
365
- const settled = await Promise.allSettled(candidates.map((p) => getCurrentJoinApplication(p.id)));
366
+ const settled = await Promise.allSettled(candidates.map(async (p) => {
367
+ const response = await getCurrentJoinApplication(p.id);
368
+ const application = response?.joinApplication;
369
+ // A successful empty envelope is the API's documented "never applied" answer.
370
+ // An application object that is present still needs its full identity below.
371
+ if (response && typeof response === "object" && !Array.isArray(response) && application === undefined) return;
372
+ if (typeof application?.id !== "string" || !application.id || application.programId !== p.id
373
+ || typeof application.status !== "string" || !application.status
374
+ || (application.memberId && application.memberId !== scope.memberId)) {
375
+ throw new Error("Current application identity is unknown");
376
+ }
377
+ result.set(p.id, application);
378
+ if (application.status.toUpperCase() !== "APPROVED" || !application.participantId) return;
379
+ // The batch roster omits withdrawals. Only admitted applications absent from it
380
+ // need this scoped read (at most one per candidate on this page), so the shared
381
+ // standing fold can distinguish current access from a matching historical join.
382
+ try {
383
+ const response = await searchMemberParticipation(p.id, scope.memberId);
384
+ const participant = Array.isArray(response.participants) ? response.participants[0] : undefined;
385
+ if (!participant?.id || participant.memberId !== scope.memberId || participant.programId !== p.id
386
+ || (!participationsByProgram([participant]).has(p.id) && participant.id !== application.participantId)) {
387
+ throw new Error("Current participation is unknown");
388
+ }
389
+ reconciled.set(p.id, participant);
390
+ } catch {
391
+ result.delete(p.id);
392
+ unknown.add(p.id);
393
+ }
394
+ }));
366
395
  settled.forEach((outcome, i) => {
367
396
  // 404 / NOT_FOUND is the endpoint's "this member never applied"; any other rejection is unknown.
368
397
  if (outcome.status === "rejected") { if (!isNotFoundError(outcome.reason)) unknown.add(candidates[i].id); }
369
- else if (outcome.value.joinApplication?.status) result.set(candidates[i].id, outcome.value.joinApplication);
370
398
  });
371
- return { map: result, unknown };
399
+ return { map: result, reconciled, unknown };
372
400
  }
373
401
 
374
402
  async function statsFor(programs: WixProgram[]): Promise<Map<string, number>> {
@@ -453,7 +481,8 @@ async function fetchPage(filter: string, cursor: string): Promise<CollectionPage
453
481
  return { items: [], nextCursor: "", metadata };
454
482
  }
455
483
  const [counts, applications] = await Promise.all([statsFor(programs), applicationsFor(programs, participations, scope)]);
456
- const items = programs.map((p) => programContent({ program: p, participant: participations.get(p.id), application: applications.map.get(p.id), applicationUnknown: applications.unknown.has(p.id), participationsUnknown: !participationsKnown, participants: counts.get(p.id), member: !!scope.memberId, now }));
484
+ if (!sameScope(scope, await resolveScope())) throw memberAccessChanged();
485
+ const items = programs.map((p) => programContent({ program: p, participant: participations.get(p.id) ?? applications.reconciled.get(p.id), application: applications.map.get(p.id), applicationUnknown: applications.unknown.has(p.id), participationsUnknown: !participationsKnown, participants: counts.get(p.id), member: !!scope.memberId, now }));
457
486
  // A revalidating load publishes nothing until it settles, so page 1 records the scope its later pages
458
487
  // are read under here, not only from the published snapshot.
459
488
  if (!cursor) pageScope = scope;
@@ -212,6 +212,7 @@ async function fetchProgram(id: string): Promise<WixProgram | undefined> {
212
212
  /** Whether the existing commerce flow may start (before the join) and continue (before the Wix
213
213
  * payment): a price refresh can move the program onto a route this flow must not charge. */
214
214
  interface CommerceGuards {
215
+ withdrawnParticipantId?: string;
215
216
  assertMember(): Promise<void>;
216
217
  mayStart(): boolean;
217
218
  mayContinue(): boolean;
@@ -222,7 +223,7 @@ async function enrollmentMessage(id: string, name: string, guards: CommerceGuard
222
223
  if (!guards.mayStart()) return blocked();
223
224
  let preparationWithdrawn = false;
224
225
  try {
225
- const joined = await joinProgram(id, { beforeWrite: guards.assertMember, mayPreparePayment: () => {
226
+ const joined = await joinProgram(id, { withdrawnParticipantId: guards.withdrawnParticipantId, resumeExistingParticipant: false, beforeWrite: guards.assertMember, mayPreparePayment: () => {
226
227
  if (!guards.mayContinue()) preparationWithdrawn = true;
227
228
  return !preparationWithdrawn;
228
229
  } });
@@ -396,7 +397,7 @@ async function load(state: State, arg?: unknown): Promise<undefined> {
396
397
  // Authority stays in the host until the last asynchronous prerequisite completes:
397
398
  // expiry, cancellation or an intervening account switch can still revoke it.
398
399
  const permit = await continuation("consume", id);
399
- if (permit?.confirmed && permit.account) await enroll(permit.account);
400
+ if (inputId() === id && permit?.confirmed && permit.account) await enroll(permit.account, id);
400
401
  }
401
402
  }
402
403
  void resumeCommerce();
@@ -479,7 +480,7 @@ async function readStanding(id: string, seq: number): Promise<StandingRead | und
479
480
  }
480
481
  sameCancelledStanding = cancelledRow && !participant;
481
482
  feedbackKnown ||= applicationKnown || !!participant;
482
- next = standingOf(programEnded, participant, application);
483
+ next = standingOf(programEnded, participant ?? scoped[0], application);
483
484
  if (next !== "none") owner = member;
484
485
  if (failedFeedback && (applicationKnown || participant)) {
485
486
  failedFeedbackInvalidated ||= !!participant || applicationRead?.id !== failedFeedback.id
@@ -618,8 +619,9 @@ async function priceProgram(): Promise<void> {
618
619
  void svc.pricingPublish();
619
620
  }
620
621
 
621
- async function enroll(afterAuthAccount = ""): Promise<undefined> {
622
- const id = inputId();
622
+ async function enroll(afterAuthAccount = "", targetId = inputId()): Promise<undefined> {
623
+ const id = targetId;
624
+ if (id !== inputId()) return undefined;
623
625
  const reference = programReference();
624
626
  const context = standingContext;
625
627
  if (!reference || enrollmentInFlight || !standingForInput()) return undefined;
@@ -641,6 +643,10 @@ async function enroll(afterAuthAccount = ""): Promise<undefined> {
641
643
  if (afterAuthAccount && member.email !== afterAuthAccount) return undefined;
642
644
  if (!member.email) {
643
645
  const request = await continuation("begin", id);
646
+ if (!ownsStanding(context, await memberAccess(), id)) {
647
+ if (request?.token) await continuation("cancel", id, request.token);
648
+ return undefined;
649
+ }
644
650
  if (request?.supported !== true || !request.token) {
645
651
  actionMessage = copyParam("program.signInUpdateRequired", "Update the app to sign in and continue enrollment.");
646
652
  return undefined;
@@ -658,9 +664,10 @@ async function enroll(afterAuthAccount = ""): Promise<undefined> {
658
664
  return undefined;
659
665
  }
660
666
  await assertMemberAccess(member);
661
- if (afterAuthAccount) {
662
- // Branded's initPhase refetches participation after NOW_LOGGED_IN, before
663
- // joining. A settled participant need not have a current Join Application.
667
+ let rejoinParticipantId = "";
668
+ {
669
+ // Every join verifies current participation, including after a route change. A
670
+ // display snapshot never authorizes resuming an old admitted application.
664
671
  const memberId = (await getMyMember()).member?.id;
665
672
  if (!memberId) throw new Error("Current member unavailable");
666
673
  const response = await searchMemberParticipation(id, memberId);
@@ -670,15 +677,19 @@ async function enroll(afterAuthAccount = ""): Promise<undefined> {
670
677
  const participant = response.participants[0];
671
678
  if (participant) {
672
679
  if (participant.memberId !== memberId || participant.programId !== id) throw new Error("Participation identity changed");
673
- const status = (participant.enrollmentStatus ?? "").toUpperCase();
674
- const progress = (participant.progressStatus ?? "").toUpperCase();
675
- if (status === "JOINED" || ["COMPLETED", "FAILED"].includes(progress)) {
676
- actionMessage = ["COMPLETED", "FAILED"].includes(progress)
677
- ? copyTemplate("program.participationRecordedMessage", "Your participation in {name} is already recorded.", { name: content.name })
678
- : copyTemplate("program.joinedMessage", "You're enrolled in {name}.", { name: content.name });
679
- return undefined;
680
- }
681
- if (!["LEFT", "REMOVED"].includes(status)) {
680
+ // Withdrawal wins over old completion/failure progress, including AUTO_REMOVED.
681
+ if (!participationsByProgram([participant]).has(id)) {
682
+ if (!participant.id) throw new Error("Withdrawn participant identity unavailable");
683
+ rejoinParticipantId = participant.id;
684
+ } else {
685
+ const status = (participant.enrollmentStatus ?? "").toUpperCase();
686
+ const progress = (participant.progressStatus ?? "").toUpperCase();
687
+ if (status === "JOINED" || ["COMPLETED", "FAILED"].includes(progress)) {
688
+ actionMessage = ["COMPLETED", "FAILED"].includes(progress)
689
+ ? copyTemplate("program.participationRecordedMessage", "Your participation in {name} is already recorded.", { name: content.name })
690
+ : copyTemplate("program.joinedMessage", "You're enrolled in {name}.", { name: content.name });
691
+ return undefined;
692
+ }
682
693
  actionMessage = copyParam("program.participationUnavailable", "Your current participation cannot be enrolled again.");
683
694
  return undefined;
684
695
  }
@@ -687,8 +698,10 @@ async function enroll(afterAuthAccount = ""): Promise<undefined> {
687
698
  // joinProgram refreshes the current Join Application before creating anything. Its
688
699
  // existing-participant/private/paid and pending-payment guards remain authoritative.
689
700
  const message = await enrollmentMessage(id, content.name, {
701
+ withdrawnParticipantId: rejoinParticipantId || undefined,
690
702
  assertMember: async () => {
691
703
  await assertMemberAccess(member);
704
+ if (id !== inputId()) throw new Error("Program changed");
692
705
  if (!connectivity().online) throw new Error(offlineWriteMessage);
693
706
  },
694
707
  mayStart: () => id === inputId() && pricing.checkoutGuard(reference).allowed,