@wix/himalaya-cli 0.1947.0 → 0.1949.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 (188) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/files/src/index.d.ts +23 -2
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/admob-ids.d.ts +4 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/index.d.ts +1 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +3 -0
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/social-feed/src/index.d.ts +13 -4
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/video/src/display.d.ts +3 -0
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +8 -2
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/files.mjs +4 -1
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +3 -1
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-video.mjs +4 -0
  11. package/dist/browser-plane/assets.json +5 -5
  12. package/dist/browser-plane/preview-deferred/{da958a2a47eef7082c7892c1cc755a58bbeefcb4b617b47fde87f1ce567b3e64.bin → a8cfd0e17359578587e8937e88dedd40b46d533f08b4d2fdac4c47d5bae6f385.bin} +1 -1
  13. package/dist/browser-plane/sw.js +9 -9
  14. package/dist/cli.mjs +1906 -800
  15. package/dist/preview-assets.generated.bin +0 -0
  16. package/guides/app-icon.md +7 -3
  17. package/guides/getting-started.md +6 -1
  18. package/guides/himi-skill.md +6 -1
  19. package/guides/himi-test.md +30 -1
  20. package/guides/one-app-section-mappings.md +1 -1
  21. package/guides/one-app-to-himi-app.md +23 -16
  22. package/guides/sdk-reference.json +28 -7
  23. package/guides/skill.md +1 -1
  24. package/package.json +2 -2
  25. package/templates/beauty-salon-owner/config.ts +7 -0
  26. package/templates/beauty-salon-owner/dev/index.ts +567 -0
  27. package/templates/beauty-salon-owner/himalaya.content.json +3 -0
  28. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  29. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  30. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  31. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  32. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  33. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  34. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  35. package/templates/branded-lite/l10n/ar.json +21 -0
  36. package/templates/branded-lite/l10n/cs.json +21 -0
  37. package/templates/branded-lite/l10n/da.json +21 -0
  38. package/templates/branded-lite/l10n/de.json +21 -0
  39. package/templates/branded-lite/l10n/el.json +21 -0
  40. package/templates/branded-lite/l10n/en.json +5 -0
  41. package/templates/branded-lite/l10n/es.json +21 -0
  42. package/templates/branded-lite/l10n/fi.json +21 -0
  43. package/templates/branded-lite/l10n/fr.json +21 -0
  44. package/templates/branded-lite/l10n/he.json +21 -0
  45. package/templates/branded-lite/l10n/hu.json +21 -0
  46. package/templates/branded-lite/l10n/id.json +21 -0
  47. package/templates/branded-lite/l10n/it.json +21 -0
  48. package/templates/branded-lite/l10n/ja.json +21 -0
  49. package/templates/branded-lite/l10n/ko.json +21 -0
  50. package/templates/branded-lite/l10n/lt.json +21 -0
  51. package/templates/branded-lite/l10n/nl.json +21 -0
  52. package/templates/branded-lite/l10n/no.json +21 -0
  53. package/templates/branded-lite/l10n/pl.json +21 -0
  54. package/templates/branded-lite/l10n/pt.json +21 -0
  55. package/templates/branded-lite/l10n/ru.json +21 -0
  56. package/templates/branded-lite/l10n/sv.json +21 -0
  57. package/templates/branded-lite/l10n/th.json +21 -0
  58. package/templates/branded-lite/l10n/tr.json +21 -0
  59. package/templates/branded-lite/l10n/uk.json +21 -0
  60. package/templates/branded-lite/l10n/vi.json +21 -0
  61. package/templates/branded-lite/l10n/zh.json +21 -0
  62. package/templates/branded-lite/recipes/form-section.json +958 -0
  63. package/templates/branded-lite/recipes/group-feed.json +221 -3
  64. package/templates/branded-lite/recipes/groups-newsfeed.json +160 -2
  65. package/templates/branded-lite/recipes/video-library.json +475 -0
  66. package/templates/branded-lite/tier5-src/_shared/event-agenda.ts +15 -15
  67. package/templates/branded-lite/tier5-src/_shared/event-schedule-section.ts +8 -8
  68. package/templates/branded-lite/tier5-src/_shared/form-section.ts +640 -0
  69. package/templates/branded-lite/tier5-src/_shared/group-feed-section.ts +119 -7
  70. package/templates/branded-lite/tier5-src/_shared/groups-newsfeed-section.ts +17 -9
  71. package/templates/branded-lite/tier5-src/_shared/videos-section.ts +134 -2
  72. package/templates/branded-lite/tier5-src/himi-branded-lite-form/index.ts +4 -588
  73. package/templates/branded-lite/tier5-src/himi-branded-lite-video/index.ts +4 -2
  74. package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +7 -6
  75. package/templates/community-club/tier5-src/himi-events-detail/index.ts +7 -6
  76. package/templates/community-club-owner/config.ts +7 -0
  77. package/templates/community-club-owner/dev/index.ts +567 -0
  78. package/templates/community-club-owner/himalaya.content.json +3 -0
  79. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  80. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  81. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  82. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  83. package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  84. package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  85. package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  86. package/templates/conference/tier5-src/_shared/event-agenda.ts +15 -15
  87. package/templates/conference/tier5-src/himi-conference-agenda/index.ts +3 -5
  88. package/templates/conference/tier5-src/himi-conference-home/index.ts +5 -6
  89. package/templates/conference/tier5-src/himi-events-detail/index.ts +7 -6
  90. package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +7 -6
  91. package/templates/events-meetups-owner/config.ts +7 -0
  92. package/templates/events-meetups-owner/dev/index.ts +567 -0
  93. package/templates/events-meetups-owner/himalaya.content.json +3 -0
  94. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  95. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  96. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  97. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  98. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  99. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  100. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  101. package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +7 -6
  102. package/templates/gym-fitness-owner/config.ts +7 -0
  103. package/templates/gym-fitness-owner/dev/index.ts +567 -0
  104. package/templates/gym-fitness-owner/himalaya.content.json +3 -0
  105. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  106. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  107. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  108. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  109. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  110. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  111. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  112. package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +7 -6
  113. package/templates/nonprofit-cause-owner/config.ts +7 -0
  114. package/templates/nonprofit-cause-owner/dev/index.ts +567 -0
  115. package/templates/nonprofit-cause-owner/himalaya.content.json +3 -0
  116. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  117. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  118. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  119. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  120. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  121. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  122. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  123. package/templates/owner-lite/config.ts +7 -0
  124. package/templates/owner-lite/dev/index.ts +567 -0
  125. package/templates/owner-lite/himalaya.content.json +3 -0
  126. package/templates/owner-lite/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  127. package/templates/owner-lite/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  128. package/templates/owner-lite/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  129. package/templates/owner-lite/tier5-src/_shared/owner-maestro-when.ts +13 -0
  130. package/templates/owner-lite/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  131. package/templates/owner-lite/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  132. package/templates/owner-lite/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  133. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-video/index.ts +4 -2
  134. package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +7 -6
  135. package/templates/podcast-creator-owner/config.ts +7 -0
  136. package/templates/podcast-creator-owner/dev/index.ts +567 -0
  137. package/templates/podcast-creator-owner/himalaya.content.json +3 -0
  138. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  139. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  140. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  141. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  142. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  143. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  144. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  145. package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +7 -6
  146. package/templates/portfolio-creative-owner/config.ts +7 -0
  147. package/templates/portfolio-creative-owner/dev/index.ts +567 -0
  148. package/templates/portfolio-creative-owner/himalaya.content.json +3 -0
  149. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  150. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  151. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  152. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  153. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  154. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  155. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  156. package/templates/professional-services/tier5-src/himi-events-detail/index.ts +7 -6
  157. package/templates/restaurant/tier5-src/himi-events-detail/index.ts +7 -6
  158. package/templates/restaurant-owner/config.ts +7 -0
  159. package/templates/restaurant-owner/dev/index.ts +567 -0
  160. package/templates/restaurant-owner/himalaya.content.json +3 -0
  161. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  162. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  163. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  164. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  165. package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  166. package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  167. package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  168. package/templates/retail-store-owner/config.ts +7 -0
  169. package/templates/retail-store-owner/dev/index.ts +567 -0
  170. package/templates/retail-store-owner/himalaya.content.json +3 -0
  171. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  172. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  173. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  174. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  175. package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  176. package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  177. package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  178. package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +7 -6
  179. package/templates/yoga-studio-owner/config.ts +7 -0
  180. package/templates/yoga-studio-owner/dev/index.ts +567 -0
  181. package/templates/yoga-studio-owner/himalaya.content.json +3 -0
  182. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  183. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  184. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  185. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  186. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  187. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  188. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
@@ -0,0 +1,228 @@
1
+ // Tier-5 bundle: __HIMI_APP_NAME__ — what Maestro is doing for the business on screen.
2
+ //
3
+ // One list in three groups, read from Symphony: the tasks the owner gave Maestro, the routines it
4
+ // runs on a schedule, and the goals it works toward. A row opens the Maestro screen on the chat
5
+ // it belongs to; a routine can be paused and resumed here. Nothing is cached: storage is shared
6
+ // by everyone who signs in on the device, and a business id is not an account.
7
+
8
+ import { defineService } from "@himalaya/state";
9
+ import { copyParam, stashCopy } from "../_shared/himi-copy.js";
10
+ import { currentBusinessId } from "../_shared/owner-selected-site.js";
11
+ import { spaceIdsOf, symphonyAccount, type MaestroWixApi } from "../_shared/owner-maestro-availability.js";
12
+ import { whenLabel } from "../_shared/owner-maestro-when.js";
13
+ import {
14
+ goalsOf, routinesOf, setRoutinePaused, tasksOf,
15
+ type GoalStanding, type MaestroGoal, type MaestroRoutine, type MaestroTask, type TaskStanding,
16
+ } from "../_shared/owner-maestro-activity.js";
17
+
18
+ interface Host { wixApi?: MaestroWixApi }
19
+ const host = (): Host => (globalThis as { himalaya?: Host }).himalaya ?? {};
20
+
21
+ /** One row. `key` names it among all three groups; `id` is the task, routine or goal itself.
22
+ * `section` is the group's heading, on its first row only. `stamp` marks the list a row was
23
+ * shown in, so opening the same chat from a later list is a new request to the Maestro screen. */
24
+ export interface ActivityRow {
25
+ key: string; id: string; section: string; title: string; status: string; subtitle: string; conversationId: string; stamp: string;
26
+ /** Marks a row that waits on the owner. */
27
+ attentionHidden: string;
28
+ /** A row with a chat opens it; one without is not a button. Exactly one of the two is "false". */
29
+ openHidden: string; plainHidden: string;
30
+ /** Routines only: the button that pauses or resumes, and whether it is offered. */
31
+ toggleLabel: string; toggleHidden: string;
32
+ }
33
+
34
+ export interface MaestroActivityState {
35
+ items: ActivityRow[]; itemsHidden: string;
36
+ /** Shown until the first read ends. */
37
+ loadingHidden: string;
38
+ /** Says there is nothing to list ("" collapses the line). */
39
+ emptyText: string;
40
+ /** Says the task list was cut, and to how many ("" collapses the line). */
41
+ cutText: string;
42
+ /** Says what could not be read, which is not the same as having none. With rows on screen it
43
+ * is about the groups that are missing. */
44
+ error: string; errorHidden: string;
45
+ /** A change Symphony did not take ("" collapses the line). */
46
+ actionError: string;
47
+ _tasks: MaestroTask[]; _routines: MaestroRoutine[]; _goals: MaestroGoal[];
48
+ }
49
+
50
+ const initial: MaestroActivityState = {
51
+ items: [], itemsHidden: "true", loadingHidden: "false",
52
+ emptyText: "", cutText: "", error: "", errorHidden: "true", actionError: "",
53
+ _tasks: [], _routines: [], _goals: [],
54
+ };
55
+
56
+ const EVERY_FIELD = Object.keys(initial) as Array<keyof MaestroActivityState>;
57
+
58
+ /** Symphony's window is thirty days of tasks. Every one that waits on the owner is listed; of the
59
+ * rest, the newest up to this many, and the screen says when it left some out. */
60
+ const MAX_OTHER_TASKS = 50;
61
+
62
+ const TASK_STATUS: Record<TaskStanding, () => string> = {
63
+ needs_you: () => copyParam("ownerMaestroActivity.needsYou", "Needs you"),
64
+ working: () => copyParam("ownerMaestroActivity.working", "Working on it"),
65
+ paused: () => copyParam("ownerMaestroActivity.taskPaused", "Paused"),
66
+ done: () => copyParam("ownerMaestroActivity.done", "Done"),
67
+ stopped: () => copyParam("ownerMaestroActivity.stopped", "Stopped"),
68
+ failed: () => copyParam("ownerMaestroActivity.failed", "Didn't finish"),
69
+ };
70
+
71
+ const GOAL_STATUS: Record<GoalStanding, () => string> = {
72
+ suggested: () => copyParam("ownerMaestroActivity.goalSuggested", "Suggested"),
73
+ starting: () => copyParam("ownerMaestroActivity.goalStarting", "Getting started"),
74
+ active: () => copyParam("ownerMaestroActivity.goalActive", "In progress"),
75
+ achieved: () => copyParam("ownerMaestroActivity.goalAchieved", "Achieved"),
76
+ };
77
+
78
+ const untitled = (): string => copyParam("ownerMaestroActivity.untitled", "Untitled");
79
+ const joined = (...parts: string[]): string => parts.filter(Boolean).join(" · ");
80
+ const NO_TOGGLE = { toggleLabel: "", toggleHidden: "true" };
81
+ /** Whether the row is a button: only one that has a chat to open. */
82
+ const opening = (conversationId: string): { openHidden: string; plainHidden: string } =>
83
+ (conversationId ? { openHidden: "false", plainHidden: "true" } : { openHidden: "true", plainHidden: "false" });
84
+
85
+ /** A routine's state in words, in Symphony's own order: what Symphony holds it on comes before
86
+ * the owner's pause, since resuming does not lift it. */
87
+ function routineStatus(r: MaestroRoutine): string {
88
+ if (r.ended) return copyParam("ownerMaestroActivity.routineEnded", "Ended");
89
+ if (r.heldBy === "credits") return copyParam("ownerMaestroActivity.routineNoCredits", "Paused: out of credits");
90
+ if (r.heldBy === "error") return copyParam("ownerMaestroActivity.routineError", "Paused: something went wrong");
91
+ if (r.heldBy === "setup") return copyParam("ownerMaestroActivity.routineSetup", "Paused: needs setting up in Symphony");
92
+ return r.paused ? copyParam("ownerMaestroActivity.routinePaused", "Paused") : copyParam("ownerMaestroActivity.routineOn", "On");
93
+ }
94
+
95
+ /** The state as the screen shows it: tasks (the ones that wait on the owner first), then
96
+ * routines, then goals, each group headed on its first row. */
97
+ function shown(s: MaestroActivityState): MaestroActivityState {
98
+ const now = Date.now();
99
+ const stamp = String(now);
100
+ const others = s._tasks.filter((t) => t.standing !== "needs_you");
101
+ const tasks = [...s._tasks.filter((t) => t.standing === "needs_you"), ...others.slice(0, MAX_OTHER_TASKS)];
102
+ const left = others.length - Math.min(others.length, MAX_OTHER_TASKS);
103
+ const groups: Array<{ heading: string; rows: Array<Omit<ActivityRow, "section" | "stamp">> }> = [
104
+ { heading: copyParam("ownerMaestroActivity.tasks", "Tasks"), rows: tasks.map((t) => ({
105
+ key: `tasks_${t.id}`, id: t.id, title: t.title || untitled(), status: TASK_STATUS[t.standing](),
106
+ subtitle: joined(t.note, whenLabel(t.updated, now)), conversationId: t.conversationId,
107
+ attentionHidden: t.standing === "needs_you" ? "false" : "true", ...opening(t.conversationId), ...NO_TOGGLE,
108
+ })) },
109
+ { heading: copyParam("ownerMaestroActivity.routines", "Routines"), rows: s._routines.map((r) => ({
110
+ key: `routines_${r.id}`, id: r.id, title: r.name || untitled(), status: routineStatus(r), subtitle: r.schedule, conversationId: r.conversationId,
111
+ attentionHidden: "true", ...opening(r.conversationId),
112
+ toggleLabel: r.paused ? copyParam("ownerMaestroActivity.resume", "Resume") : copyParam("ownerMaestroActivity.pause", "Pause"),
113
+ // Not for one that is over, nor one Symphony holds: the owner's switch would change nothing they can see.
114
+ toggleHidden: r.ended || r.heldBy ? "true" : "false",
115
+ })) },
116
+ { heading: copyParam("ownerMaestroActivity.goals", "Goals"), rows: s._goals.map((g) => ({
117
+ key: `goals_${g.id}`, id: g.id, title: g.title || untitled(), status: GOAL_STATUS[g.standing](), subtitle: whenLabel(g.updated, now),
118
+ conversationId: g.conversationId, attentionHidden: "true", ...opening(g.conversationId), ...NO_TOGGLE,
119
+ })) },
120
+ ];
121
+ const items: ActivityRow[] = groups.flatMap((g) => g.rows.map((row, index) => ({ ...row, section: index === 0 ? g.heading : "", stamp })));
122
+ return {
123
+ ...s, items, itemsHidden: items.length ? "false" : "true", loadingHidden: "true",
124
+ cutText: left === 1 ? copyParam("ownerMaestroActivity.taskCut", "1 older task is not listed.")
125
+ : left > 1 ? copyParam("ownerMaestroActivity.tasksCut", "{count} older tasks are not listed.").replace("{count}", String(left)) : "",
126
+ emptyText: items.length || s.errorHidden === "false" ? ""
127
+ : copyParam("ownerMaestroActivity.empty", "Nothing yet. What you ask Maestro to do for this business shows up here."),
128
+ };
129
+ }
130
+
131
+ const loaded: MaestroActivityState = { ...initial, loadingHidden: "true" };
132
+ const none = (): MaestroActivityState => shown(loaded);
133
+ const failed = (): MaestroActivityState =>
134
+ ({ ...loaded, error: copyParam("ownerMaestroActivity.loadFailed", "Maestro's activity couldn't be loaded. Try again in a moment."), errorHidden: "false" });
135
+
136
+ const idOf = (arg: unknown): string => {
137
+ const id = (arg as { id?: unknown } | undefined)?.id;
138
+ return typeof id === "string" ? id : "";
139
+ };
140
+
141
+ // A read started for a business the owner has since left, or overtaken by a newer read, is dropped.
142
+ let reads = 0;
143
+ /** The state as it is now, which an action that waited on Symphony may no longer hold. */
144
+ const live = (fallback: MaestroActivityState): MaestroActivityState =>
145
+ (svc as unknown as { getState?: () => MaestroActivityState }).getState?.() ?? fallback;
146
+ // One change at a time: each result is built from the state it started with.
147
+ let changing = false;
148
+ // The owner's own switches: a read that started before one was made was answered with what was
149
+ // true before it, so the switch goes over that read's answer. `upTo` is the newest read started
150
+ // when the change was made.
151
+ const switched = new Map<string, { paused: boolean; upTo: number }>();
152
+
153
+ const svc = defineService<MaestroActivityState, {
154
+ load: (s: MaestroActivityState, arg?: unknown) => Promise<MaestroActivityState>;
155
+ toggleRoutine: (s: MaestroActivityState, arg?: unknown) => Promise<MaestroActivityState>;
156
+ }>("himiOwnerLiteMaestroActivity", {
157
+ state: initial,
158
+ // Read again on every appear and never shown from an earlier run.
159
+ notPersisted: EVERY_FIELD,
160
+ notHydrated: EVERY_FIELD,
161
+ actions: {
162
+ load: async (s, arg) => {
163
+ stashCopy(arg);
164
+ const site = currentBusinessId();
165
+ const api = host().wixApi;
166
+ // Counted even when nothing can be asked: a read still out for the last business is then stale.
167
+ const read = ++reads;
168
+ if (!site || !api) return failed();
169
+ // Whatever this read finds, it is for a screen that is gone once a newer read started or the
170
+ // owner picked another business.
171
+ const stale = (): boolean => read !== reads || currentBusinessId() !== site;
172
+ // A dropped read leaves the screen as it is. When it was the first, and no newer read is on
173
+ // its way, that would be "Loading…" for good: it says it failed, with Try again.
174
+ const dropped = (): MaestroActivityState => {
175
+ const now = live(s);
176
+ return now.loadingHidden === "false" && read === reads ? failed() : now;
177
+ };
178
+ try {
179
+ // No Symphony account, or a business that is not a Space: nothing to list.
180
+ const account = await symphonyAccount(api);
181
+ const spaces = account ? await spaceIdsOf(api, account, site) : [];
182
+ if (!spaces.length) return stale() ? dropped() : none();
183
+ // Each group on its own: one that could not be read does not take the others with it.
184
+ const [tasks, routines, goals] = await Promise.allSettled([tasksOf(api, spaces), routinesOf(api, spaces), goalsOf(api, spaces)]);
185
+ if (stale()) return dropped();
186
+ const read3 = [tasks, routines, goals];
187
+ if (read3.every((r) => r.status === "rejected")) return failed();
188
+ const partial = read3.some((r) => r.status === "rejected");
189
+ return shown({
190
+ ...loaded,
191
+ _tasks: tasks.status === "fulfilled" ? tasks.value : [],
192
+ _routines: routines.status === "fulfilled" ? routines.value.map((r) => {
193
+ const mine = switched.get(r.id);
194
+ return mine && read <= mine.upTo ? { ...r, paused: mine.paused } : r;
195
+ }) : [],
196
+ _goals: goals.status === "fulfilled" ? goals.value : [],
197
+ error: partial ? copyParam("ownerMaestroActivity.partFailed", "Some of Maestro's activity couldn't be loaded.") : "",
198
+ errorHidden: partial ? "false" : "true",
199
+ });
200
+ } catch {
201
+ return stale() ? dropped() : failed();
202
+ }
203
+ },
204
+ // Pause a routine that is on, or resume one the owner paused.
205
+ toggleRoutine: async (s, arg) => {
206
+ const routine = s._routines.find((r) => r.id === idOf(arg));
207
+ const api = host().wixApi;
208
+ if (!routine || routine.ended || routine.heldBy || changing || !api) return s;
209
+ changing = true;
210
+ try {
211
+ await setRoutinePaused(api, routine.id, !routine.paused);
212
+ // A read still out was answered before this change, and one may have finished while
213
+ // Symphony was being told: the change goes onto the list as it is now, and over the
214
+ // answer of any read that started before it.
215
+ switched.set(routine.id, { paused: !routine.paused, upTo: reads });
216
+ const now = live(s);
217
+ const routines = now._routines.map((r) => (r.id === routine.id ? { ...r, paused: !routine.paused } : r));
218
+ return shown({ ...now, _routines: routines, actionError: "" });
219
+ } catch {
220
+ return shown({ ...live(s), actionError: copyParam("ownerMaestroActivity.changeFailed", "That didn't go through. Try again in a moment.") });
221
+ } finally { changing = false; }
222
+ },
223
+ },
224
+ });
225
+
226
+ // No module-scope `svc.load()`: a bridge call made while the bundle is still being evaluated
227
+ // stalls on the Android WebView, and `onAppear` loads the list anyway.
228
+ export { svc };
@@ -5,11 +5,11 @@
5
5
  // messages itself. Nothing is cached here: storage is shared by everyone who signs in on the
6
6
  // device, and a business id is not an account.
7
7
 
8
- import { formatClock, formatMonthDayTime } from "../_shared/engine-intl.js";
9
8
  import { defineService } from "@himalaya/state";
10
9
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
11
10
  import { currentBusinessId } from "../_shared/owner-selected-site.js";
12
11
  import { noteDeletedChat } from "../_shared/owner-maestro-tab.js";
12
+ import { whenLabel } from "../_shared/owner-maestro-when.js";
13
13
  import { symphonyAccount, type MaestroWixApi } from "../_shared/owner-maestro-availability.js";
14
14
  import { deleteChat, pastChats, pinChat, renameChat, type PastChat } from "../_shared/owner-maestro-chat.js";
15
15
 
@@ -77,16 +77,6 @@ function bucketOf(updated: string, now: number): string {
77
77
  return copyParam("ownerMaestroHistory.older", "Older");
78
78
  }
79
79
 
80
- /** When a chat was last active: the time for one from today, whose rows would otherwise all
81
- * read the same date; the date and the time for an older one. */
82
- function whenLabel(updated: string, now: number): string {
83
- const at = Date.parse(updated);
84
- if (Number.isNaN(at)) return "";
85
- const midnight = new Date(now);
86
- midnight.setHours(0, 0, 0, 0);
87
- return at >= midnight.getTime() ? formatClock(new Date(at)) : formatMonthDayTime(new Date(at));
88
- }
89
-
90
80
  /** Rows: pinned chats first under their own heading, then by recency, each heading named on
91
81
  * its first row only. */
92
82
  function rowsOf(chats: PastChat[], now: number, s: Pick<MaestroHistoryState, "_open" | "_confirm">): HistoryRow[] {
@@ -187,6 +187,13 @@ export default defineApp({
187
187
  "parentScreenId": "himi_owner_lite_maestro",
188
188
  "tabId": "maestro"
189
189
  },
190
+ {
191
+ "screenId": "himi_owner_lite_maestro_activity",
192
+ "isPublic": false,
193
+ "paramKeys": [],
194
+ "parentScreenId": "himi_owner_lite_maestro",
195
+ "tabId": "maestro"
196
+ },
190
197
  {
191
198
  "screenId": "himi_owner_lite_brief",
192
199
  "isPublic": false,