@wix/himalaya-cli 0.1937.0 → 0.1939.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/dev-server/src/builder.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +6 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{e5837d5c411f8725fbfe259349eee3e04e53eb313ff505c35d46a14d80cfb484.bin → 5b3d097922a41f4f7e9ad5d9701a5025ae5d293b3ee4927ad9eb21730bf6bf5c.bin} +1 -1
- package/dist/browser-plane/sw.js +9 -9
- package/dist/cli.mjs +49 -44
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-index.md +1 -1
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +6 -0
- package/package.json +2 -2
- package/templates/beauty-salon-owner/config.ts +12 -2
- package/templates/beauty-salon-owner/dev/index.ts +1200 -69
- package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-product/index.ts +12 -1
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-service/index.ts +12 -1
- package/templates/community-club-owner/config.ts +12 -2
- package/templates/community-club-owner/dev/index.ts +1200 -69
- package/templates/community-club-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/community-club-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/community-club-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/community-club-owner/tier5-src/himi-owner-lite-event/index.ts +12 -1
- package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/community-club-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/community-club-owner/tier5-src/himi-owner-lite-product/index.ts +12 -1
- package/templates/community-club-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/events-meetups-owner/config.ts +12 -2
- package/templates/events-meetups-owner/dev/index.ts +1178 -69
- package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-event/index.ts +12 -1
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/gym-fitness-owner/config.ts +12 -2
- package/templates/gym-fitness-owner/dev/index.ts +1222 -69
- package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-event/index.ts +12 -1
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-product/index.ts +12 -1
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-service/index.ts +12 -1
- package/templates/nonprofit-cause-owner/config.ts +12 -2
- package/templates/nonprofit-cause-owner/dev/index.ts +1200 -69
- package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-event/index.ts +12 -1
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-service/index.ts +12 -1
- package/templates/owner-lite/config.ts +12 -2
- package/templates/owner-lite/dev/index.ts +1222 -69
- package/templates/owner-lite/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/owner-lite/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/owner-lite/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/owner-lite/tier5-src/himi-owner-lite-event/index.ts +12 -1
- package/templates/owner-lite/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/owner-lite/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/owner-lite/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/owner-lite/tier5-src/himi-owner-lite-product/index.ts +12 -1
- package/templates/owner-lite/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/owner-lite/tier5-src/himi-owner-lite-service/index.ts +12 -1
- package/templates/podcast-creator-owner/config.ts +12 -2
- package/templates/podcast-creator-owner/dev/index.ts +1200 -69
- package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-event/index.ts +12 -1
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-product/index.ts +12 -1
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/portfolio-creative-owner/config.ts +12 -2
- package/templates/portfolio-creative-owner/dev/index.ts +1200 -69
- package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-product/index.ts +12 -1
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-service/index.ts +12 -1
- package/templates/restaurant-owner/config.ts +12 -2
- package/templates/restaurant-owner/dev/index.ts +1222 -69
- package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-event/index.ts +12 -1
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-product/index.ts +12 -1
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-service/index.ts +12 -1
- package/templates/retail-store-owner/config.ts +12 -2
- package/templates/retail-store-owner/dev/index.ts +1178 -69
- package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-product/index.ts +12 -1
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/yoga-studio-owner/config.ts +12 -2
- package/templates/yoga-studio-owner/dev/index.ts +1200 -69
- package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-chat.ts +168 -16
- package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-kinds.ts +28 -0
- package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-tab.ts +47 -4
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-event/index.ts +12 -1
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro/index.ts +529 -70
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +147 -17
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-post/index.ts +12 -1
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-record/index.ts +3 -3
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-service/index.ts +12 -1
|
@@ -9,8 +9,9 @@ import { formatClock, formatMonthDayTime } from "../_shared/engine-intl.js";
|
|
|
9
9
|
import { defineService } from "@himalaya/state";
|
|
10
10
|
import { copyParam, stashCopy } from "../_shared/himi-copy.js";
|
|
11
11
|
import { currentBusinessId } from "../_shared/owner-selected-site.js";
|
|
12
|
+
import { noteDeletedChat } from "../_shared/owner-maestro-tab.js";
|
|
12
13
|
import { symphonyAccount, type MaestroWixApi } from "../_shared/owner-maestro-availability.js";
|
|
13
|
-
import { pastChats, type PastChat } from "../_shared/owner-maestro-chat.js";
|
|
14
|
+
import { deleteChat, pastChats, pinChat, renameChat, type PastChat } from "../_shared/owner-maestro-chat.js";
|
|
14
15
|
|
|
15
16
|
interface Host { wixApi?: MaestroWixApi; input?: Record<string, unknown> }
|
|
16
17
|
const host = (): Host => (globalThis as { himalaya?: Host }).himalaya ?? {};
|
|
@@ -20,20 +21,45 @@ function activeSiteId(): string {
|
|
|
20
21
|
return currentBusinessId();
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
/** `stamp` marks the list a row was shown in, so opening the same chat from a later
|
|
24
|
-
|
|
24
|
+
/** One chat. `stamp` marks the list a row was shown in, so opening the same chat from a later
|
|
25
|
+
* list is a new request. The `*Hidden` flags pick which strip shows under the row: its
|
|
26
|
+
* actions, the delete question, or nothing. */
|
|
27
|
+
export interface HistoryRow {
|
|
28
|
+
id: string; title: string; subtitle: string; section: string; stamp: string;
|
|
29
|
+
pinnedHidden: string; pinLabel: string; menuHidden: string; confirmHidden: string;
|
|
30
|
+
}
|
|
25
31
|
|
|
26
32
|
export interface MaestroHistoryState {
|
|
27
33
|
items: HistoryRow[];
|
|
28
34
|
itemsHidden: string;
|
|
29
|
-
/** Says the owner has no past chats ("" collapses the line). */
|
|
35
|
+
/** Says the owner has no past chats, or that none match the search ("" collapses the line). */
|
|
30
36
|
emptyText: string;
|
|
31
37
|
/** Says the list could not be read, which is not the same as having none. */
|
|
32
38
|
error: string;
|
|
33
39
|
errorHidden: string;
|
|
40
|
+
/** Search over the chats' names, and whether the field shows (only with chats to search). */
|
|
41
|
+
query: string;
|
|
42
|
+
searchHidden: string;
|
|
43
|
+
/** A change Symphony did not take ("" collapses the line). */
|
|
44
|
+
actionError: string;
|
|
45
|
+
/** Renaming one chat: whether the form shows, and the name being typed. */
|
|
46
|
+
renameHidden: string;
|
|
47
|
+
renameText: string;
|
|
48
|
+
/** Every chat of this business as read, before the search narrows it. */
|
|
49
|
+
_chats: PastChat[];
|
|
50
|
+
/** The row whose actions show, the one being asked "delete?", and the one being renamed. */
|
|
51
|
+
_open: string;
|
|
52
|
+
_confirm: string;
|
|
53
|
+
_rename: string;
|
|
34
54
|
}
|
|
35
55
|
|
|
36
|
-
const initial: MaestroHistoryState = {
|
|
56
|
+
const initial: MaestroHistoryState = {
|
|
57
|
+
items: [], itemsHidden: "true", emptyText: "", error: "", errorHidden: "true",
|
|
58
|
+
query: "", searchHidden: "true", actionError: "", renameHidden: "true", renameText: "",
|
|
59
|
+
_chats: [], _open: "", _confirm: "", _rename: "",
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const EVERY_FIELD = Object.keys(initial) as Array<keyof MaestroHistoryState>;
|
|
37
63
|
|
|
38
64
|
const DAY = 24 * 60 * 60 * 1000;
|
|
39
65
|
|
|
@@ -61,31 +87,93 @@ function whenLabel(updated: string, now: number): string {
|
|
|
61
87
|
return at >= midnight.getTime() ? formatClock(new Date(at)) : formatMonthDayTime(new Date(at));
|
|
62
88
|
}
|
|
63
89
|
|
|
64
|
-
/** Rows
|
|
65
|
-
|
|
90
|
+
/** Rows: pinned chats first under their own heading, then by recency, each heading named on
|
|
91
|
+
* its first row only. */
|
|
92
|
+
function rowsOf(chats: PastChat[], now: number, s: Pick<MaestroHistoryState, "_open" | "_confirm">): HistoryRow[] {
|
|
93
|
+
const ordered = [...chats.filter((c) => c.pinned), ...chats.filter((c) => !c.pinned)];
|
|
66
94
|
let last = "";
|
|
67
|
-
return
|
|
68
|
-
const bucket = bucketOf(c.updated, now);
|
|
95
|
+
return ordered.map((c) => {
|
|
96
|
+
const bucket = c.pinned ? copyParam("ownerMaestroHistory.pinned", "Pinned") : bucketOf(c.updated, now);
|
|
69
97
|
const section = bucket === last ? "" : bucket;
|
|
70
98
|
last = bucket;
|
|
71
|
-
return {
|
|
99
|
+
return {
|
|
100
|
+
id: c.id, title: c.title || copyParam("ownerMaestroHistory.untitled", "Untitled conversation"), subtitle: whenLabel(c.updated, now), section, stamp: String(now),
|
|
101
|
+
pinnedHidden: c.pinned ? "false" : "true",
|
|
102
|
+
pinLabel: c.pinned ? copyParam("ownerMaestroHistory.unpin", "Unpin") : copyParam("ownerMaestroHistory.pin", "Pin"),
|
|
103
|
+
menuHidden: s._open === c.id && s._confirm !== c.id ? "false" : "true",
|
|
104
|
+
confirmHidden: s._confirm === c.id ? "false" : "true",
|
|
105
|
+
};
|
|
72
106
|
});
|
|
73
107
|
}
|
|
74
108
|
|
|
75
|
-
|
|
76
|
-
|
|
109
|
+
/** The state as the screen shows it: the chats the search keeps, and the lines that follow. */
|
|
110
|
+
function shown(s: MaestroHistoryState): MaestroHistoryState {
|
|
111
|
+
const q = s.query.trim().toLowerCase();
|
|
112
|
+
const kept = q ? s._chats.filter((c) => c.title.toLowerCase().includes(q)) : s._chats;
|
|
113
|
+
const items = rowsOf(kept, Date.now(), s);
|
|
114
|
+
return {
|
|
115
|
+
...s, items, itemsHidden: items.length ? "false" : "true",
|
|
116
|
+
searchHidden: s._chats.length ? "false" : "true",
|
|
117
|
+
emptyText: items.length ? ""
|
|
118
|
+
: s._chats.length ? copyParam("ownerMaestroHistory.noMatch", "No conversations match that search.")
|
|
119
|
+
: copyParam("ownerMaestroHistory.empty", "No past conversations yet."),
|
|
120
|
+
renameHidden: s._rename ? "false" : "true",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const none = (): MaestroHistoryState => shown(initial);
|
|
77
125
|
const failed = (): MaestroHistoryState =>
|
|
78
126
|
({ ...initial, error: copyParam("ownerMaestroHistory.failed", "Your conversations couldn't be loaded. Try again in a moment."), errorHidden: "false" });
|
|
127
|
+
const changeFailed = (): string => copyParam("ownerMaestroHistory.changeFailed", "That didn't go through. Try again in a moment.");
|
|
128
|
+
|
|
129
|
+
const idOf = (arg: unknown): string => {
|
|
130
|
+
const id = (arg as { id?: unknown } | undefined)?.id;
|
|
131
|
+
return typeof id === "string" ? id : "";
|
|
132
|
+
};
|
|
133
|
+
const textOf = (arg: unknown): string => {
|
|
134
|
+
if (typeof arg === "string") return arg;
|
|
135
|
+
for (const key of ["value", "text"] as const) {
|
|
136
|
+
const v = (arg as Record<string, unknown> | undefined)?.[key];
|
|
137
|
+
if (typeof v === "string") return v;
|
|
138
|
+
}
|
|
139
|
+
return "";
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// One change at a time: each result is built from the state it started with.
|
|
143
|
+
let changing = false;
|
|
144
|
+
|
|
145
|
+
/** Make one change in Symphony, then apply it to the list read earlier. A change Symphony did
|
|
146
|
+
* not take leaves the list as it was and says so. */
|
|
147
|
+
async function change(s: MaestroHistoryState, call: (api: MaestroWixApi) => Promise<PastChat[]>): Promise<MaestroHistoryState> {
|
|
148
|
+
const api = host().wixApi;
|
|
149
|
+
if (changing || !api) return s;
|
|
150
|
+
changing = true;
|
|
151
|
+
try {
|
|
152
|
+
const chats = await call(api);
|
|
153
|
+
return shown({ ...s, _chats: chats, _open: "", _confirm: "", _rename: "", renameText: "", actionError: "" });
|
|
154
|
+
} catch {
|
|
155
|
+
return shown({ ...s, _confirm: "", actionError: changeFailed() });
|
|
156
|
+
} finally { changing = false; }
|
|
157
|
+
}
|
|
79
158
|
|
|
80
159
|
const svc = defineService<MaestroHistoryState, {
|
|
81
160
|
load: (s: MaestroHistoryState, arg?: unknown) => Promise<MaestroHistoryState>;
|
|
161
|
+
search: (s: MaestroHistoryState, arg?: unknown) => MaestroHistoryState;
|
|
162
|
+
more: (s: MaestroHistoryState, arg?: unknown) => MaestroHistoryState;
|
|
163
|
+
pin: (s: MaestroHistoryState, arg?: unknown) => Promise<MaestroHistoryState>;
|
|
164
|
+
askDelete: (s: MaestroHistoryState, arg?: unknown) => MaestroHistoryState;
|
|
165
|
+
cancel: (s: MaestroHistoryState) => MaestroHistoryState;
|
|
166
|
+
confirmDelete: (s: MaestroHistoryState, arg?: unknown) => Promise<MaestroHistoryState>;
|
|
167
|
+
rename: (s: MaestroHistoryState, arg?: unknown) => MaestroHistoryState;
|
|
168
|
+
setName: (s: MaestroHistoryState, arg?: unknown) => MaestroHistoryState;
|
|
169
|
+
saveName: (s: MaestroHistoryState) => Promise<MaestroHistoryState>;
|
|
82
170
|
}>("himiOwnerLiteMaestroHistory", {
|
|
83
171
|
state: initial,
|
|
84
172
|
// The list is read again on every appear and is never shown from an earlier run.
|
|
85
|
-
notPersisted:
|
|
86
|
-
notHydrated:
|
|
173
|
+
notPersisted: EVERY_FIELD,
|
|
174
|
+
notHydrated: EVERY_FIELD,
|
|
87
175
|
actions: {
|
|
88
|
-
load: async (
|
|
176
|
+
load: async (s, arg) => {
|
|
89
177
|
stashCopy(arg);
|
|
90
178
|
const site = activeSiteId();
|
|
91
179
|
const api = host().wixApi;
|
|
@@ -94,12 +182,54 @@ const svc = defineService<MaestroHistoryState, {
|
|
|
94
182
|
// No Symphony account means no chats: the list call would only be refused.
|
|
95
183
|
if (!(await symphonyAccount(api))) return none();
|
|
96
184
|
const chats = await pastChats(api, site);
|
|
97
|
-
|
|
98
|
-
return { ...initial,
|
|
185
|
+
// The search the owner typed is kept across a re-read; what was open on a row is not.
|
|
186
|
+
return shown({ ...initial, _chats: chats, query: s.query ?? "" });
|
|
99
187
|
} catch {
|
|
100
188
|
return failed();
|
|
101
189
|
}
|
|
102
190
|
},
|
|
191
|
+
// Over the names of the chats read: Symphony's own search cannot be asked for one business.
|
|
192
|
+
search: (s, arg) => shown({ ...s, query: textOf(arg), _open: "", _confirm: "" }),
|
|
193
|
+
// A row's actions: Pin, Rename, Delete. Tapping the same row again puts them away.
|
|
194
|
+
more: (s, arg) => {
|
|
195
|
+
const id = idOf(arg);
|
|
196
|
+
return shown({ ...s, _open: s._open === id ? "" : id, _confirm: "", actionError: "" });
|
|
197
|
+
},
|
|
198
|
+
pin: async (s, arg) => {
|
|
199
|
+
const chat = s._chats.find((c) => c.id === idOf(arg));
|
|
200
|
+
if (!chat) return s;
|
|
201
|
+
return change(s, async (api) => {
|
|
202
|
+
await pinChat(api, chat.id, !chat.pinned);
|
|
203
|
+
return s._chats.map((c) => (c.id === chat.id ? { ...c, pinned: !chat.pinned } : c));
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
askDelete: (s, arg) => (s._chats.some((c) => c.id === idOf(arg)) ? shown({ ...s, _confirm: idOf(arg), actionError: "" }) : s),
|
|
207
|
+
cancel: (s) => shown({ ...s, _open: "", _confirm: "", _rename: "", renameText: "", actionError: "" }),
|
|
208
|
+
confirmDelete: async (s, arg) => {
|
|
209
|
+
const id = idOf(arg);
|
|
210
|
+
// Only the chat the owner was just asked about.
|
|
211
|
+
if (!id || s._confirm !== id) return s;
|
|
212
|
+
return change(s, async (api) => {
|
|
213
|
+
await deleteChat(api, id);
|
|
214
|
+
// The Maestro screen may have this chat open: it must not go on writing into it.
|
|
215
|
+
noteDeletedChat(id);
|
|
216
|
+
return s._chats.filter((c) => c.id !== id);
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
rename: (s, arg) => {
|
|
220
|
+
const chat = s._chats.find((c) => c.id === idOf(arg));
|
|
221
|
+
return chat ? shown({ ...s, _rename: chat.id, renameText: chat.title, _open: "", _confirm: "", actionError: "" }) : s;
|
|
222
|
+
},
|
|
223
|
+
setName: (s, arg) => ({ ...s, renameText: textOf(arg) }),
|
|
224
|
+
saveName: async (s) => {
|
|
225
|
+
const id = s._rename;
|
|
226
|
+
const name = s.renameText.replace(/\s+/g, " ").trim().slice(0, 120);
|
|
227
|
+
if (!id || !name) return s;
|
|
228
|
+
return change(s, async (api) => {
|
|
229
|
+
const kept = await renameChat(api, id, name);
|
|
230
|
+
return s._chats.map((c) => (c.id === id ? { ...c, title: kept } : c));
|
|
231
|
+
});
|
|
232
|
+
},
|
|
103
233
|
},
|
|
104
234
|
});
|
|
105
235
|
|
|
@@ -6,6 +6,7 @@ import { postCoverUrl } from "../_shared/owner-post-content.js";
|
|
|
6
6
|
// Modeled on himi-blog-owner-post; write verbs use the wix-blog draft lifecycle.
|
|
7
7
|
|
|
8
8
|
import { defineService } from "@himalaya/state";
|
|
9
|
+
import { askMaestroHidden, askMaestroNav } from "../_shared/owner-maestro-tab.js";
|
|
9
10
|
import { getPost, getDraftPost, publishDraftPost, revertDraftPost, deleteDraftPost } from "@himalaya/wix-blog";
|
|
10
11
|
import { parseRicosJson } from "@himalaya/wix-rich-content";
|
|
11
12
|
import { openRichLink } from "../_shared/rich-content-link.js";
|
|
@@ -38,6 +39,8 @@ async function cacheBodyText(s: PostState): Promise<void> {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
interface PostState {
|
|
42
|
+
/** "false" while the assistant tab is Maestro for this business: shows "Ask Maestro". */
|
|
43
|
+
askMaestroHidden: string;
|
|
41
44
|
id: string;
|
|
42
45
|
/** Edit-form target for the loaded entity (canonical detail descriptors bind
|
|
43
46
|
* this — the id is only known at runtime under WS-C nav params). */
|
|
@@ -128,7 +131,11 @@ const FACT_KEYS = ["postStatus", "category", "published", "updated"] as const;
|
|
|
128
131
|
|
|
129
132
|
function shape(s: Partial<PostState>): PostState {
|
|
130
133
|
const out = shapeFields(s);
|
|
131
|
-
return {
|
|
134
|
+
return {
|
|
135
|
+
...out, ...blankFlags(out as unknown as Record<string, unknown>, FACT_KEYS),
|
|
136
|
+
// "Ask Maestro" shows only for a loaded record, while the assistant tab is Maestro.
|
|
137
|
+
askMaestroHidden: out.status === "ready" && out.id ? askMaestroHidden() : "true",
|
|
138
|
+
};
|
|
132
139
|
}
|
|
133
140
|
|
|
134
141
|
function shapeFields(s: Partial<PostState>): PostState {
|
|
@@ -139,6 +146,7 @@ function shapeFields(s: Partial<PostState>): PostState {
|
|
|
139
146
|
const isLoading = status === "loading";
|
|
140
147
|
const published = raw === "PUBLISHED" || raw === "SCHEDULED";
|
|
141
148
|
return {
|
|
149
|
+
askMaestroHidden: "true", // `shape` decides it
|
|
142
150
|
id: s.id ?? "",
|
|
143
151
|
// WS-C — CANONICAL form target (the entity `id` rides as a separate nav
|
|
144
152
|
// param the descriptor binds; suffixed `_form_<id>` was #570 and 404s on
|
|
@@ -340,6 +348,7 @@ const DELETE_RUN_KEYS = ["deletePending", "noDeleteConfirmation"] as const;
|
|
|
340
348
|
const disarm = <T extends { deletePending: boolean }>(s: T): T => ({ ...s, deletePending: false });
|
|
341
349
|
|
|
342
350
|
const svc = defineService<PostState, {
|
|
351
|
+
askMaestro: (s: PostState) => PostState;
|
|
343
352
|
load: (s: PostState, arg?: unknown) => Promise<PostState>;
|
|
344
353
|
retry: (s: PostState) => Promise<PostState>;
|
|
345
354
|
publish: (s: PostState) => Promise<PostState>;
|
|
@@ -355,6 +364,8 @@ const svc = defineService<PostState, {
|
|
|
355
364
|
// perVisit: a cached embed's warm return starts this run fresh, as a cold boot does (`__resetRunState`).
|
|
356
365
|
perVisit: [...DELETE_RUN_KEYS],
|
|
357
366
|
actions: {
|
|
367
|
+
// "Ask Maestro": the chat opens on the Maestro tab, about this post.
|
|
368
|
+
askMaestro: (s) => askMaestroNav(s, { kind: "post", id: s.id, subject: s.title }),
|
|
358
369
|
load: async (s0, arg) => {
|
|
359
370
|
const s = disarm(s0);
|
|
360
371
|
stashCopy(arg); // absorb the descriptor's onAppear copy-pack param
|
|
@@ -7,6 +7,7 @@ import { openRichLink } from "../_shared/rich-content-link.js";
|
|
|
7
7
|
// generic buildDetail descriptor ($service:himiOwnerLiteProduct.*).
|
|
8
8
|
|
|
9
9
|
import { defineService } from "@himalaya/state";
|
|
10
|
+
import { askMaestroHidden, askMaestroNav } from "../_shared/owner-maestro-tab.js";
|
|
10
11
|
import { getProduct, updateProduct, deleteProduct, type WixProduct } from "@himalaya/wix-stores";
|
|
11
12
|
import { productImage, wixMediaUrl, WIX_DETAIL_IMAGE, type StoreProduct } from "../_shared/himi-store.js";
|
|
12
13
|
import { ownerLoadError, isOwnerPreviewDemo, ownerDemoFallback, ownerWriteError, isNotFound } from "../_shared/owner-load-error.js";
|
|
@@ -27,6 +28,8 @@ async function cacheDrop(id: string): Promise<void> { try { await dbRemove(ENTIT
|
|
|
27
28
|
async function cacheGet(id: string): Promise<DbEntity | null> { try { return await dbGet(ENTITY, id); } catch { return null; } }
|
|
28
29
|
|
|
29
30
|
interface ProductState {
|
|
31
|
+
/** "false" while the assistant tab is Maestro for this business: shows "Ask Maestro". */
|
|
32
|
+
askMaestroHidden: string;
|
|
30
33
|
id: string;
|
|
31
34
|
/** Edit-form target for the loaded entity (canonical detail descriptors bind
|
|
32
35
|
* this — the id is only known at runtime under WS-C nav params). */
|
|
@@ -120,7 +123,11 @@ const FACT_KEYS = ["price", "statusLabel", "sku", "inventory"] as const;
|
|
|
120
123
|
|
|
121
124
|
function shape(s: Partial<ProductState>): ProductState {
|
|
122
125
|
const out = shapeFields(s);
|
|
123
|
-
return {
|
|
126
|
+
return {
|
|
127
|
+
...out, ...blankFlags(out as unknown as Record<string, unknown>, FACT_KEYS),
|
|
128
|
+
// "Ask Maestro" shows only for a loaded record, while the assistant tab is Maestro.
|
|
129
|
+
askMaestroHidden: out.status === "ready" && out.id ? askMaestroHidden() : "true",
|
|
130
|
+
};
|
|
124
131
|
}
|
|
125
132
|
|
|
126
133
|
function shapeFields(s: Partial<ProductState>): ProductState {
|
|
@@ -130,6 +137,7 @@ function shapeFields(s: Partial<ProductState>): ProductState {
|
|
|
130
137
|
const hasEntity = !!s.title && status === "ready";
|
|
131
138
|
const isLoading = status === "loading";
|
|
132
139
|
return {
|
|
140
|
+
askMaestroHidden: "true", // `shape` decides it
|
|
133
141
|
id: s.id ?? "",
|
|
134
142
|
// WS-C — CANONICAL form target (the entity `id` rides as a separate nav
|
|
135
143
|
// param the descriptor binds; suffixed `_form_<id>` was #570 and 404s on
|
|
@@ -316,6 +324,7 @@ const DELETE_RUN_KEYS = ["deletePending", "noDeleteConfirmation"] as const;
|
|
|
316
324
|
const disarm = <T extends { deletePending: boolean }>(s: T): T => ({ ...s, deletePending: false });
|
|
317
325
|
|
|
318
326
|
const svc = defineService<ProductState, {
|
|
327
|
+
askMaestro: (s: ProductState) => ProductState;
|
|
319
328
|
load: (s: ProductState, arg?: unknown) => Promise<ProductState>;
|
|
320
329
|
retry: (s: ProductState) => Promise<ProductState>;
|
|
321
330
|
show: (s: ProductState) => Promise<ProductState>;
|
|
@@ -330,6 +339,8 @@ const svc = defineService<ProductState, {
|
|
|
330
339
|
// perVisit: a cached embed's warm return starts this run fresh, as a cold boot does (`__resetRunState`).
|
|
331
340
|
perVisit: [...DELETE_RUN_KEYS],
|
|
332
341
|
actions: {
|
|
342
|
+
// "Ask Maestro": the chat opens on the Maestro tab, about this product.
|
|
343
|
+
askMaestro: (s) => askMaestroNav(s, { kind: "product", id: s.id, subject: s.title }),
|
|
333
344
|
openLink: async (_state, arg): Promise<ProductState> => {
|
|
334
345
|
const opened = await openRichLink(arg);
|
|
335
346
|
const failed = copyParam("ownerProduct.linkOpenFailed", "This link could not be opened.");
|
|
@@ -19,10 +19,10 @@ const svc = defineService('himiOwnerRecord', {
|
|
|
19
19
|
notLoading: false, notErrored: true, hideContent: true, handoffError: '' } as State,
|
|
20
20
|
actions: {
|
|
21
21
|
// "Ask Maestro": the chat opens on the Maestro tab, about this record.
|
|
22
|
-
// The screen says what kind of record this is
|
|
23
|
-
//
|
|
22
|
+
// The screen says what kind of record this is. The record's title names it, except where
|
|
23
|
+
// the title is a person's name (`askMaestroNav` leaves those out).
|
|
24
24
|
askMaestro(state: State, arg?: unknown): State {
|
|
25
|
-
return askMaestroNav(state, { kind: (arg as { kind?: unknown } | undefined)?.kind, id: state.id });
|
|
25
|
+
return askMaestroNav(state, { kind: (arg as { kind?: unknown } | undefined)?.kind, id: state.id, subject: state.title });
|
|
26
26
|
},
|
|
27
27
|
async load(state: State, arg?: unknown): Promise<State | undefined> {
|
|
28
28
|
stashCopy(arg);
|
|
@@ -606,7 +606,12 @@ export default defineApp({
|
|
|
606
606
|
"label": "Maestro",
|
|
607
607
|
"icon": "ai",
|
|
608
608
|
"hiddenPath": "$service:ownerLiteNav.maestroTabHidden",
|
|
609
|
-
"hiddenUntilResolved": true
|
|
609
|
+
"hiddenUntilResolved": true,
|
|
610
|
+
"badge": {
|
|
611
|
+
"kind": "count",
|
|
612
|
+
"valuePath": "$service:ownerLiteNav.maestroWaiting",
|
|
613
|
+
"countLabel": "waiting on you"
|
|
614
|
+
}
|
|
610
615
|
},
|
|
611
616
|
{
|
|
612
617
|
"id": "manage",
|
|
@@ -645,7 +650,12 @@ export default defineApp({
|
|
|
645
650
|
"label": "Maestro",
|
|
646
651
|
"icon": "ai",
|
|
647
652
|
"hiddenPath": "$service:ownerLiteNav.maestroTabHidden",
|
|
648
|
-
"hiddenUntilResolved": true
|
|
653
|
+
"hiddenUntilResolved": true,
|
|
654
|
+
"badge": {
|
|
655
|
+
"kind": "count",
|
|
656
|
+
"valuePath": "$service:ownerLiteNav.maestroWaiting",
|
|
657
|
+
"countLabel": "waiting on you"
|
|
658
|
+
}
|
|
649
659
|
},
|
|
650
660
|
{
|
|
651
661
|
"id": "manage",
|