@wix/himalaya-cli 0.1557.0 → 0.1559.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 (55) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +6 -4
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/media/src/index.d.ts +1 -1
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/online-programs/src/index.d.ts +14 -5
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +2 -2
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-events.mjs +1 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-media.mjs +1 -0
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-online-programs.mjs +35 -7
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-rich-content.mjs +1 -0
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-stores-collections.mjs +1 -0
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-stores.mjs +1 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-video.mjs +1 -0
  12. package/dist/cli.mjs +164 -61
  13. package/dist/preview-assets.generated.bin +0 -0
  14. package/guides/getting-started.md +4 -1
  15. package/guides/himi-json-output.md +8 -0
  16. package/guides/himi-skill.md +4 -1
  17. package/guides/one-app-to-himi-app.md +18 -6
  18. package/guides/sdk-reference.json +8 -8
  19. package/guides/skill.md +4 -1
  20. package/guides/splash-screens.md +22 -1
  21. package/package.json +2 -2
  22. package/templates/beauty-salon/tier5-src/_shared/himi-media.ts +29 -0
  23. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +3 -4
  24. package/templates/branded-lite/tier5-src/_shared/himi-media.ts +29 -0
  25. package/templates/branded-lite/tier5-src/himi-branded-lite-group/index.ts +3 -6
  26. package/templates/branded-lite/tier5-src/himi-branded-lite-groups/index.ts +2 -15
  27. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +3 -4
  28. package/templates/branded-lite/tier5-src/himi-branded-lite-program/index.ts +21 -20
  29. package/templates/branded-lite/tier5-src/himi-branded-lite-programs/index.ts +1 -9
  30. package/templates/community-club/tier5-src/_shared/himi-media.ts +29 -0
  31. package/templates/community-club/tier5-src/himi-branded-lite-group/index.ts +3 -6
  32. package/templates/community-club/tier5-src/himi-branded-lite-groups/index.ts +2 -15
  33. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +3 -4
  34. package/templates/events-meetups/tier5-src/_shared/himi-media.ts +29 -0
  35. package/templates/events-meetups/tier5-src/himi-branded-lite-group/index.ts +3 -6
  36. package/templates/events-meetups/tier5-src/himi-branded-lite-groups/index.ts +2 -15
  37. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +3 -4
  38. package/templates/gym-fitness/tier5-src/_shared/himi-media.ts +29 -0
  39. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +3 -4
  40. package/templates/nonprofit-cause/tier5-src/_shared/himi-media.ts +29 -0
  41. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-group/index.ts +3 -6
  42. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-groups/index.ts +2 -15
  43. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +3 -4
  44. package/templates/podcast-creator/tier5-src/_shared/himi-media.ts +29 -0
  45. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +3 -4
  46. package/templates/portfolio-creative/tier5-src/_shared/himi-media.ts +29 -0
  47. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +3 -4
  48. package/templates/restaurant/tier5-src/_shared/himi-media.ts +29 -0
  49. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +3 -4
  50. package/templates/retail-store/tier5-src/_shared/himi-media.ts +29 -0
  51. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +3 -4
  52. package/templates/yoga-studio/tier5-src/_shared/himi-media.ts +29 -0
  53. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +3 -4
  54. package/templates/yoga-studio/tier5-src/himi-branded-lite-program/index.ts +21 -20
  55. package/templates/yoga-studio/tier5-src/himi-branded-lite-programs/index.ts +1 -9
@@ -9,7 +9,7 @@ import { withOnlineWrites } from "../_shared/online-actions.js";
9
9
  // error card.
10
10
  //
11
11
  // Phase 2d — enrolling is NATIVE. `joinProgram` covers all three program kinds in
12
- // one call and the outcome is read off `participant.state`, not assumed:
12
+ // the Join Applications API; its compatibility result exposes only confirmed outcomes:
13
13
  // a free/open program comes back JOINED with nothing to pay, a paid one comes back
14
14
  // PAYMENT_PENDING and settles on the shared in-app pay rail, and a private one comes
15
15
  // back APPROVAL_PENDING (the owner approves; there is nothing to charge). Any failure
@@ -21,6 +21,8 @@ import { withOnlineWrites } from "../_shared/online-actions.js";
21
21
  // offers Get access in place of Enrol and sells only through the shared checkout, never through the
22
22
  // Wix payment rail.
23
23
  import { defineService as registerService } from "@himalaya/state";
24
+ import { programImage } from "../_shared/himi-media.js";
25
+ import { WIX_DETAIL_IMAGE } from "@himalaya/wix-media";
24
26
  import {
25
27
  getProgram,
26
28
  joinProgram,
@@ -122,14 +124,6 @@ function detailsOf(p: WixProgram): string {
122
124
  .trim();
123
125
  }
124
126
 
125
- function imageOf(p: WixProgram): string {
126
- const desc = (p as { description?: unknown }).description;
127
- const nested = desc && typeof desc === "object" ? (desc as { image?: { url?: string } }).image?.url : undefined;
128
- const cover = (p as { coverImage?: unknown }).coverImage;
129
- const coverUrl = typeof cover === "string" ? cover : (cover as { url?: string } | undefined)?.url;
130
- return (coverUrl || p.image || nested || "").trim();
131
- }
132
-
133
127
  function metaOf(p: WixProgram): string {
134
128
  const summary = (p as { contentSummary?: { stepCount?: number; sectionCount?: number } }).contentSummary;
135
129
  const bits: string[] = [];
@@ -160,7 +154,7 @@ function ready(state: State, p: WixProgram | undefined): State {
160
154
  return derive({ ...state, status: "ready", name: "", description: "", meta: "", priceLine: "", image: "", initial: "", emptyText: copyParam("program.emptyText", "This program is no longer available.") });
161
155
  }
162
156
  const name = titleOf(p);
163
- const image = imageOf(p);
157
+ const image = programImage(p, WIX_DETAIL_IMAGE);
164
158
  return derive({
165
159
  ...state,
166
160
  status: "ready",
@@ -196,18 +190,26 @@ interface CommerceGuards {
196
190
  async function enrollmentMessage(name: string, guards: CommerceGuards): Promise<string> {
197
191
  const blocked = () => iapPriceCopy("program").purchaseUnavailable;
198
192
  if (!guards.mayStart()) return blocked();
193
+ let preparationWithdrawn = false;
199
194
  try {
200
- const joined = await joinProgram(inputId());
195
+ const joined = await joinProgram(inputId(), { mayPreparePayment: () => {
196
+ if (!guards.mayContinue()) preparationWithdrawn = true;
197
+ return !preparationWithdrawn;
198
+ } });
201
199
  const participant = joined.participant;
202
200
  const programState = (participant?.state ?? "").toUpperCase();
203
201
  if (programState === "APPROVAL_PENDING") {
204
202
  return copyParam("program.approvalPendingMessage", "Request sent — the host will approve your place.");
205
203
  }
204
+ if (programState === "ENROLLMENT_PENDING") {
205
+ return copyParam("program.enrollmentPendingMessage", "Your enrollment is processing — check back shortly.");
206
+ }
206
207
  const payable = payableIdOf(participant);
207
- if (!payable) {
208
- // Free / open program (or one already settled) ⇒ nothing to charge.
208
+ if (programState === "JOINED") {
209
+ // Only a confirmed participant is enrolled; absent payment data is not success.
209
210
  return copyTemplate("program.joinedMessage", "You're enrolled in {name}.", { name });
210
211
  }
212
+ if (programState !== "PAYMENT_PENDING" || !payable) throw new Error("Program enrollment is not ready");
211
213
  const msid = await wixPlatformSession.signedInstanceStatus().then((s) => s.msid ?? "").catch(() => "");
212
214
  // Re-read before each step that commits money: a route that settles meanwhile wins.
213
215
  let withdrawn = false;
@@ -227,12 +229,8 @@ async function enrollmentMessage(name: string, guards: CommerceGuards): Promise<
227
229
  // which is precisely the dead-end the two-rail design exists to prevent
228
230
  // (and which the cart/plans/events flows each guard with a test).
229
231
  //
230
- // There is no `programsCheckout` redirect intent. `ecomOrderPaymentRequest`
231
- // is the only payment-request-shaped one, and a program's `purchaseFlowId`
232
- // is a payment-request handle, so that is what we hand it. If that mapping
233
- // is ever wrong the call throws, we degrade to the same site-directing
234
- // message as before, and nothing regresses — but when it is right, a
235
- // wallet-less site can actually sell the program IN-APP.
232
+ // Join Applications returns a Wix Payments order id; the payment-request
233
+ // redirect uses that same order handle on the hosted rail.
236
234
  cashierUrl: async () => {
237
235
  if (!stillAllowed()) return undefined;
238
236
  const redirect = await createRedirectSession({
@@ -243,10 +241,13 @@ async function enrollmentMessage(name: string, guards: CommerceGuards): Promise<
243
241
  },
244
242
  });
245
243
  if (withdrawn) return blocked();
246
- if (pay.kind === "paid") return copyTemplate("program.joinedMessage", "You're enrolled in {name}.", { name });
244
+ if (pay.kind === "paid") return pay.pending
245
+ ? copyParam("program.paymentPendingMessage", "Payment is processing — enrollment will be confirmed after payment.")
246
+ : copyTemplate("program.joinedMessage", "You're enrolled in {name}.", { name });
247
247
  if (pay.kind === "handoff") return "";
248
248
  if (pay.kind === "cancelled") return copyParam("program.joinCancelledMessage", "Payment cancelled — you haven't enrolled.");
249
249
  } catch {
250
+ if (preparationWithdrawn) return blocked();
250
251
  // fall through to the site-directing message
251
252
  }
252
253
  return copyTemplate("program.joinOnSiteMessage", "Enrolment happens on the website — visit the site to join {name}.", { name });
@@ -14,7 +14,7 @@ import { decorateCollection } from "../_shared/collection-service.js";
14
14
  import { queryPrograms, type WixProgram } from "@himalaya/wix-online-programs";
15
15
  import { iapPriceFields, onlineProgramItem, type IapPollDirective } from "@himalaya/iap";
16
16
  import { createIapCommerce } from "@himalaya/iap-checkout";
17
- import { wixMediaUrl } from "@himalaya/wix-media";
17
+ import { programImage } from "../_shared/himi-media.js";
18
18
  import { cleanTitle, initials } from "../_shared/himi-text.js";
19
19
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
20
20
  import { iapPriceCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
@@ -86,14 +86,6 @@ function programDetails(p: WixProgram): string {
86
86
  return raw.length > 140 ? `${raw.slice(0, 139).trimEnd()}…` : raw;
87
87
  }
88
88
 
89
- function programImage(p: WixProgram): string {
90
- const desc = (p as { description?: unknown }).description;
91
- const nested = desc && typeof desc === "object" ? (desc as { image?: { url?: string } }).image?.url : undefined;
92
- const cover = (p as { coverImage?: unknown }).coverImage;
93
- const coverUrl = typeof cover === "string" ? cover : (cover as { url?: string } | undefined)?.url;
94
- return wixMediaUrl(coverUrl || p.image || nested);
95
- }
96
-
97
89
  function programMeta(p: WixProgram): string {
98
90
  const summary = (p as { contentSummary?: { stepCount?: number; sectionCount?: number } }).contentSummary;
99
91
  const bits: string[] = [];