@wix/himalaya-cli 0.1582.0 → 0.1583.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 (50) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +8 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +26 -2
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +18 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +5 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +5 -1
  6. package/dist/cli.mjs +888 -553
  7. package/dist/preview-assets.generated.bin +0 -0
  8. package/guides/component-reference.json +4 -3
  9. package/guides/component-reference.md +24 -2
  10. package/package.json +2 -2
  11. package/templates/beauty-salon/config.ts +20 -1
  12. package/templates/beauty-salon/dev/index.ts +1751 -629
  13. package/templates/beauty-salon/tier5-src/_shared/booking-location.ts +147 -0
  14. package/templates/beauty-salon/tier5-src/_shared/booking-session.ts +222 -0
  15. package/templates/beauty-salon/tier5-src/himi-booking-service/index.ts +277 -14
  16. package/templates/beauty-salon/tier5-src/himi-booking-services/index.ts +351 -92
  17. package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +25 -5
  18. package/templates/beauty-salon/tier5-src/himi-branded-lite-agenda/index.ts +219 -220
  19. package/templates/branded-lite/config.ts +20 -1
  20. package/templates/branded-lite/dev/index.ts +1688 -566
  21. package/templates/branded-lite/l10n/en.json +2 -2
  22. package/templates/branded-lite/tier5-src/_shared/booking-location.ts +147 -0
  23. package/templates/branded-lite/tier5-src/_shared/booking-session.ts +222 -0
  24. package/templates/branded-lite/tier5-src/himi-booking-service/index.ts +277 -14
  25. package/templates/branded-lite/tier5-src/himi-booking-services/index.ts +351 -92
  26. package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +25 -5
  27. package/templates/branded-lite/tier5-src/himi-branded-lite-agenda/index.ts +219 -220
  28. package/templates/community-club/config.ts +20 -1
  29. package/templates/events-meetups/config.ts +20 -1
  30. package/templates/gym-fitness/config.ts +20 -1
  31. package/templates/gym-fitness/dev/index.ts +1751 -629
  32. package/templates/gym-fitness/tier5-src/_shared/booking-location.ts +147 -0
  33. package/templates/gym-fitness/tier5-src/_shared/booking-session.ts +222 -0
  34. package/templates/gym-fitness/tier5-src/himi-booking-service/index.ts +277 -14
  35. package/templates/gym-fitness/tier5-src/himi-booking-services/index.ts +351 -92
  36. package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +25 -5
  37. package/templates/gym-fitness/tier5-src/himi-branded-lite-agenda/index.ts +219 -220
  38. package/templates/nonprofit-cause/config.ts +20 -1
  39. package/templates/podcast-creator/config.ts +20 -1
  40. package/templates/portfolio-creative/config.ts +20 -1
  41. package/templates/restaurant/config.ts +20 -1
  42. package/templates/retail-store/config.ts +20 -1
  43. package/templates/yoga-studio/config.ts +20 -1
  44. package/templates/yoga-studio/dev/index.ts +1533 -411
  45. package/templates/yoga-studio/tier5-src/_shared/booking-location.ts +147 -0
  46. package/templates/yoga-studio/tier5-src/_shared/booking-session.ts +222 -0
  47. package/templates/yoga-studio/tier5-src/himi-booking-service/index.ts +277 -14
  48. package/templates/yoga-studio/tier5-src/himi-booking-services/index.ts +351 -92
  49. package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +25 -5
  50. package/templates/yoga-studio/tier5-src/himi-branded-lite-agenda/index.ts +219 -220
@@ -17,6 +17,7 @@ import { displayName, getMyData, type WixMyData } from "@himalaya/wix-users";
17
17
  import { formatServicePrice, serviceIsChargeable } from "../_shared/wix-service-price.js";
18
18
  import { stashCopy, copyParam, copyPlural, copyTemplate } from "../_shared/himi-copy.js";
19
19
  import { upsert as dbUpsert, remove as dbRemove, enqueue as dbEnqueue, type DbEntity } from "@himalaya/local-db";
20
+ import { locationChoice, readSharedLocationResult, writeSharedLocation } from "../_shared/booking-location.js";
20
21
  import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
21
22
  import { emitHostEvent, hostEventInstant } from "../_shared/host-events.js";
22
23
  import { availabilityBeyond, courseReadWindows, courseSessionsAvailability, courseWindowOpen, slotIdAt } from "../_shared/himi-bookings.js";
@@ -71,6 +72,9 @@ interface SlotRow {
71
72
  locKey: string;
72
73
  locLabel: string;
73
74
  locSub: string;
75
+ /** The location as every bookings screen keys it (`booking-location.ts`): what the shared
76
+ * choice of Services and the Agenda names. "" when it has none. */
77
+ locPlace: string;
74
78
  }
75
79
 
76
80
  /** One time in a staff group: a pill with three looks. */
@@ -523,6 +527,7 @@ function slotRows(entries: ReadonlyArray<{ slot?: WixBookingSlotFull; bookable?:
523
527
  locKey: loc.key,
524
528
  locLabel: loc.label,
525
529
  locSub: loc.sub,
530
+ locPlace: locationChoice(slot.location as Parameters<typeof locationChoice>[0]).key,
526
531
  });
527
532
  }
528
533
  return { rows, slots, waitlist };
@@ -552,9 +557,9 @@ function locationMatches(row: SlotRow, locationId: string): boolean {
552
557
 
553
558
  /** Every distinct location of the window's times (the greyed ones read so far included), in the
554
559
  * order they first appear. */
555
- function windowLocations(): Array<{ key: string; label: string; sub: string }> {
556
- const seen = new Map<string, { key: string; label: string; sub: string }>();
557
- for (const row of [...allRows, ...[...greyByDay.values()].flat()]) if (row.locKey && !seen.has(row.locKey)) seen.set(row.locKey, { key: row.locKey, label: row.locLabel, sub: row.locSub });
560
+ function windowLocations(): Array<{ key: string; label: string; sub: string; place: string }> {
561
+ const seen = new Map<string, { key: string; label: string; sub: string; place: string }>();
562
+ for (const row of [...allRows, ...[...greyByDay.values()].flat()]) if (row.locKey && !seen.has(row.locKey)) seen.set(row.locKey, { key: row.locKey, label: row.locLabel, sub: row.locSub, place: row.locPlace });
558
563
  return [...seen.values()];
559
564
  }
560
565
 
@@ -1236,8 +1241,17 @@ const svc = defineService<S, {
1236
1241
  // A location with no times left (greyed ones included) goes back to "All locations", and so
1237
1242
  // does a filter that would hide the time this load restores (a host's start, a guest's pick).
1238
1243
  const restored = startRow ?? picked;
1239
- const locationId = windowLocations().some((l) => l.key === chosen.locationId) && (!restored || locationMatches(restored, chosen.locationId))
1240
- ? chosen.locationId : "";
1244
+ // The location chosen on any bookings screen (this one writes its choices there too), matched
1245
+ // by the key they all share; this screen's own choice only when the store cannot answer. A
1246
+ // pooled worker re-shown later otherwise kept an older choice than Services' newer one.
1247
+ // A place the other screens cannot name (the client's own place) is never written there, so
1248
+ // this screen keeps it rather than lose it to the shared value.
1249
+ const shared = await readSharedLocationResult();
1250
+ const own = windowLocations().find((l) => l.key === chosen.locationId);
1251
+ const preferred = own && !own.place ? own.key
1252
+ : shared ? (shared.id ? windowLocations().find((l) => l.place === shared.id)?.key ?? "" : "") : chosen.locationId;
1253
+ const locationId = windowLocations().some((l) => l.key === preferred) && (!restored || locationMatches(restored, preferred))
1254
+ ? preferred : "";
1241
1255
  return derive(withDay({
1242
1256
  ...next,
1243
1257
  days,
@@ -1322,6 +1336,12 @@ const svc = defineService<S, {
1322
1336
  const keep = allRows.some((row) => row.dayKey === s.selectedDay && row.selectable && locationMatches(row, locationId));
1323
1337
  const first = allRows.filter((row) => row.selectable && locationMatches(row, locationId)).sort(byDay)[0];
1324
1338
  const revision = ++dayRevision;
1339
+ // Kept for Services and the Agenda, which filter by the same location. Not awaited (it never
1340
+ // throws): the choice shows at once, and a search still running settles as it always has.
1341
+ // A place with no shared key (the client's place) is this screen's alone: Services and the
1342
+ // Agenda keep their own choice instead of falling back to "All locations".
1343
+ const picked = windowLocations().find((l) => l.key === locationId);
1344
+ if (!locationId || picked?.place) void writeSharedLocation({ id: picked?.place ?? "", label: picked?.label ?? "" });
1325
1345
  if (keep || !first) return derive(next);
1326
1346
  if (lastService?.type !== "CLASS") await loadGreyDay(s.id, first.dayKey);
1327
1347
  // A newer day or location choice made during the read wins.