@fayz-ai/plugin-automations 0.15.29 → 0.15.31
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/AutomationDetailPage-UHY7KHQK.js +4 -0
- package/dist/AutomationDetailPage-UHY7KHQK.js.map +1 -0
- package/dist/AutomationsList-3UTTQSIX.js +478 -0
- package/dist/AutomationsList-3UTTQSIX.js.map +1 -0
- package/dist/FlowsPage-6SUXT2LP.js +509 -0
- package/dist/FlowsPage-6SUXT2LP.js.map +1 -0
- package/dist/chunk-63YAGMWV.js +258 -0
- package/dist/chunk-63YAGMWV.js.map +1 -0
- package/dist/chunk-TCSHZ3VF.js +764 -0
- package/dist/chunk-TCSHZ3VF.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2974
- package/dist/index.js.map +1 -1
- package/dist/migrations/main.browser.js +9 -0
- package/dist/migrations/main.browser.js.map +1 -0
- package/dist/migrations/main.js +998 -0
- package/dist/migrations/main.js.map +1 -0
- package/dist/views/AutomationsList.d.ts.map +1 -1
- package/package.json +10 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"AutomationDetailPage-UHY7KHQK.js"}
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import { useOrganizationStoreLike, resolveMessages, AutomationDetailPage } from './chunk-TCSHZ3VF.js';
|
|
2
|
+
import { useProviderTemplates, ProviderTemplateBadge, providerApprovalFor } from './chunk-63YAGMWV.js';
|
|
3
|
+
import { usePluginRuntimeOptional, onAppPathChange, errorMessage, currentAppPath } from '@fayz-ai/core';
|
|
4
|
+
import React2 from 'react';
|
|
5
|
+
import { WandSparkles, Zap, Receipt, Megaphone, MessageSquare, Smartphone, Mail, ChevronRight } from 'lucide-react';
|
|
6
|
+
import { PageHeaderActions, PageTabs, Card, WhatsAppIcon, Switch, toast, getLucideIcon, Button } from '@fayz-ai/ui';
|
|
7
|
+
import { useConnectors, useAgentSurface, PageActions, askAI, SettingsTabs, adminNavigateTo, RightRailPage, connectorRoute, ConnectorMark, ConnectorDeliveries } from '@fayz-ai/admin';
|
|
8
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
// src/lib/connector-automations.ts
|
|
11
|
+
function connectorAutomationRows(connectors) {
|
|
12
|
+
const out = [];
|
|
13
|
+
for (const connector of connectors) {
|
|
14
|
+
if (connector.state !== "connected") continue;
|
|
15
|
+
for (const auto of connector.definition?.managedAutomations ?? []) {
|
|
16
|
+
out.push({
|
|
17
|
+
connectorId: connector.id,
|
|
18
|
+
connectorName: connector.name,
|
|
19
|
+
hostPluginId: connector.hostPluginId,
|
|
20
|
+
icon: connector.icon,
|
|
21
|
+
logoUrl: connector.logoUrl,
|
|
22
|
+
eventKey: auto.eventKey,
|
|
23
|
+
label: auto.label,
|
|
24
|
+
optional: auto.optional ?? false,
|
|
25
|
+
...connector.definition?.listDeliveries ? { listDeliveries: connector.definition.listDeliveries.bind(connector.definition) } : {}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
function groupConnectorAutomations(rows) {
|
|
32
|
+
const groups = [];
|
|
33
|
+
for (const row of rows) {
|
|
34
|
+
let group = groups.find((g) => g.connectorId === row.connectorId);
|
|
35
|
+
if (!group) {
|
|
36
|
+
group = {
|
|
37
|
+
connectorId: row.connectorId,
|
|
38
|
+
connectorName: row.connectorName,
|
|
39
|
+
hostPluginId: row.hostPluginId,
|
|
40
|
+
icon: row.icon,
|
|
41
|
+
logoUrl: row.logoUrl,
|
|
42
|
+
items: []
|
|
43
|
+
};
|
|
44
|
+
groups.push(group);
|
|
45
|
+
}
|
|
46
|
+
group.items.push(row);
|
|
47
|
+
}
|
|
48
|
+
return groups;
|
|
49
|
+
}
|
|
50
|
+
function ConnectorAutomations({ rows }) {
|
|
51
|
+
if (rows.length === 0) return null;
|
|
52
|
+
return /* @__PURE__ */ jsx(Fragment, { children: groupConnectorAutomations(rows).map((group) => {
|
|
53
|
+
const href = connectorRoute({ hostPluginId: group.hostPluginId });
|
|
54
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
55
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: group.connectorName }),
|
|
56
|
+
group.items.map((row) => /* @__PURE__ */ jsx(
|
|
57
|
+
AutomationCard,
|
|
58
|
+
{
|
|
59
|
+
row,
|
|
60
|
+
group,
|
|
61
|
+
href
|
|
62
|
+
},
|
|
63
|
+
`${group.connectorId}:${row.eventKey}`
|
|
64
|
+
))
|
|
65
|
+
] }, group.connectorId);
|
|
66
|
+
}) });
|
|
67
|
+
}
|
|
68
|
+
function AutomationCard({
|
|
69
|
+
row,
|
|
70
|
+
group,
|
|
71
|
+
href
|
|
72
|
+
}) {
|
|
73
|
+
const [open, setOpen] = React2.useState(false);
|
|
74
|
+
return /* @__PURE__ */ jsxs(Card, { className: "overflow-hidden", children: [
|
|
75
|
+
/* @__PURE__ */ jsxs(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
role: "button",
|
|
79
|
+
tabIndex: 0,
|
|
80
|
+
onClick: () => adminNavigateTo(href),
|
|
81
|
+
onKeyDown: (e) => {
|
|
82
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
adminNavigateTo(href);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
className: "flex cursor-pointer items-start gap-4 p-4 transition-colors hover:bg-muted/30 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
ConnectorMark,
|
|
91
|
+
{
|
|
92
|
+
connector: {
|
|
93
|
+
id: group.connectorId,
|
|
94
|
+
name: group.connectorName,
|
|
95
|
+
icon: group.icon,
|
|
96
|
+
logoUrl: group.logoUrl
|
|
97
|
+
},
|
|
98
|
+
size: "sm"
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
102
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: row.label }),
|
|
103
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
104
|
+
"Quando ",
|
|
105
|
+
/* @__PURE__ */ jsx("code", { className: "font-mono text-xs", children: row.eventKey }),
|
|
106
|
+
" acontece aqui."
|
|
107
|
+
] })
|
|
108
|
+
] }),
|
|
109
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 pt-0.5 text-right text-xs text-muted-foreground", children: row.optional ? `Opcional \u2014 desligue em ${group.connectorName}` : `Ligada pela integra\xE7\xE3o \xB7 sai ao desconectar ${group.connectorName}` })
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
row.listDeliveries && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
114
|
+
/* @__PURE__ */ jsxs(
|
|
115
|
+
Button,
|
|
116
|
+
{
|
|
117
|
+
variant: "bare",
|
|
118
|
+
size: "bare",
|
|
119
|
+
type: "button",
|
|
120
|
+
onClick: () => setOpen(!open),
|
|
121
|
+
"aria-expanded": open,
|
|
122
|
+
className: "flex w-full items-center justify-start gap-2 rounded-none border-t border-border px-4 py-2 text-left font-normal transition-colors hover:bg-muted/40",
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: `h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${open ? "rotate-90" : ""}` }),
|
|
125
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs font-medium", children: [
|
|
126
|
+
"O que j\xE1 foi para o ",
|
|
127
|
+
group.connectorName
|
|
128
|
+
] })
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
open && /* @__PURE__ */ jsx("div", { className: "border-t border-border p-4", children: /* @__PURE__ */ jsx(
|
|
133
|
+
ConnectorDeliveries,
|
|
134
|
+
{
|
|
135
|
+
load: (options) => row.listDeliveries({ ...options, eventKey: row.eventKey }),
|
|
136
|
+
providerName: group.connectorName
|
|
137
|
+
}
|
|
138
|
+
) })
|
|
139
|
+
] })
|
|
140
|
+
] });
|
|
141
|
+
}
|
|
142
|
+
var CONFIGURE_TOOL = {
|
|
143
|
+
id: "automations.configure",
|
|
144
|
+
name: "configureAutomation",
|
|
145
|
+
description: "Turns an automation on or off, and/or rewrites its message. Use the `event` and `channel` values exactly as they appear in the surface state. Placeholders must come from that automation's own list \u2014 an invented one renders as literal text in a message a customer reads. To review several, call once per automation.",
|
|
146
|
+
icon: "Zap",
|
|
147
|
+
mode: "persist",
|
|
148
|
+
execution: { plane: "client" },
|
|
149
|
+
category: "Automations",
|
|
150
|
+
parameters: {
|
|
151
|
+
type: "object",
|
|
152
|
+
properties: {
|
|
153
|
+
event: { type: "string", description: "Event key from the surface state." },
|
|
154
|
+
channel: { type: "string", description: "Channel of that automation (email | whatsapp | sms | in_app)." },
|
|
155
|
+
enabled: { type: "boolean", description: "Turn it on or off. Omit to leave as is." },
|
|
156
|
+
subject: { type: "string", description: "New subject. Email only." },
|
|
157
|
+
body: { type: "string", description: "New message body." }
|
|
158
|
+
},
|
|
159
|
+
required: ["event", "channel"]
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
var ASK_AI_ACTION = {
|
|
163
|
+
label: "Criar com IA",
|
|
164
|
+
hint: "O que revisar nas automa\xE7\xF5es\u2026",
|
|
165
|
+
intro: {
|
|
166
|
+
role: "setup",
|
|
167
|
+
persona: "Redator das automa\xE7\xF5es",
|
|
168
|
+
pitch: "Diga o que revisar nas automa\xE7\xF5es.",
|
|
169
|
+
description: "Vejo todas as automa\xE7\xF5es deste app, quais est\xE3o ligadas e o texto de cada uma. Posso ligar, desligar e reescrever \u2014 em uma ou em v\xE1rias de uma vez. Voc\xEA confirma cada mudan\xE7a.",
|
|
170
|
+
suggestions: [
|
|
171
|
+
{ label: "Revise as mensagens de pedido no tom da minha marca" },
|
|
172
|
+
{ label: "Ligue as automa\xE7\xF5es de entrega" },
|
|
173
|
+
{ label: "Deixe as mensagens de WhatsApp mais curtas" }
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
var CHANNEL_ICON = {
|
|
178
|
+
email: Mail,
|
|
179
|
+
// The brand glyph, not a generic bubble: in a list of channels, WhatsApp
|
|
180
|
+
// is recognized by its mark before its label.
|
|
181
|
+
whatsapp: WhatsAppIcon,
|
|
182
|
+
sms: Smartphone,
|
|
183
|
+
push: MessageSquare,
|
|
184
|
+
webchat: MessageSquare
|
|
185
|
+
};
|
|
186
|
+
var CHANNEL_LABEL = {
|
|
187
|
+
email: "E-mail",
|
|
188
|
+
whatsapp: "WhatsApp",
|
|
189
|
+
sms: "SMS",
|
|
190
|
+
push: "Push",
|
|
191
|
+
webchat: "Chat"
|
|
192
|
+
};
|
|
193
|
+
var KIND_TABS = [
|
|
194
|
+
{ value: "all", label: "Todos", icon: Zap },
|
|
195
|
+
{ value: "transactional", label: "Transacionais", icon: Receipt },
|
|
196
|
+
{ value: "marketing", label: "Marketing", icon: Megaphone }
|
|
197
|
+
];
|
|
198
|
+
var KIND_HINT = {
|
|
199
|
+
all: "Tudo que o produto sabe enviar, por qualquer canal.",
|
|
200
|
+
transactional: "Disparados por uma a\xE7\xE3o da pessoa. N\xE3o precisam de opt-in.",
|
|
201
|
+
marketing: "Iniciativa da empresa. S\xF3 para quem aceitou receber."
|
|
202
|
+
};
|
|
203
|
+
function iconFor(name) {
|
|
204
|
+
if (!name) return Zap;
|
|
205
|
+
return getLucideIcon(name) ?? Zap;
|
|
206
|
+
}
|
|
207
|
+
function readSelection(basePath) {
|
|
208
|
+
const hash = currentAppPath();
|
|
209
|
+
if (!hash.startsWith(basePath + "/")) return null;
|
|
210
|
+
const [eventKey, channel] = hash.slice(basePath.length + 1).split("/");
|
|
211
|
+
if (!eventKey || !channel) return null;
|
|
212
|
+
return { eventKey, channel };
|
|
213
|
+
}
|
|
214
|
+
function AutomationsList({ store, variant = "page", basePath = "/automations" }) {
|
|
215
|
+
const tenantId = useOrganizationStoreLike();
|
|
216
|
+
const runtime = usePluginRuntimeOptional();
|
|
217
|
+
const [messages, setMessages] = React2.useState(null);
|
|
218
|
+
const [kind, setKind] = React2.useState("all");
|
|
219
|
+
const { connectors } = useConnectors({ includeGrants: false, includeCatalog: false });
|
|
220
|
+
const owned = React2.useMemo(() => connectorAutomationRows(connectors ?? []), [connectors]);
|
|
221
|
+
const providerTemplates = useProviderTemplates();
|
|
222
|
+
const [selected, setSelected] = React2.useState(() => readSelection(basePath));
|
|
223
|
+
React2.useEffect(() => {
|
|
224
|
+
const sync = () => setSelected(readSelection(basePath));
|
|
225
|
+
sync();
|
|
226
|
+
return onAppPathChange(sync);
|
|
227
|
+
}, [basePath]);
|
|
228
|
+
const reload = React2.useCallback(async () => {
|
|
229
|
+
let overrides = [];
|
|
230
|
+
try {
|
|
231
|
+
overrides = await store.list(tenantId);
|
|
232
|
+
} catch (err) {
|
|
233
|
+
console.warn("[automations] could not load template overrides; showing defaults", err);
|
|
234
|
+
}
|
|
235
|
+
setMessages(resolveMessages(overrides, runtime?.events ?? []));
|
|
236
|
+
}, [store, tenantId, runtime]);
|
|
237
|
+
React2.useEffect(() => {
|
|
238
|
+
void reload();
|
|
239
|
+
}, [reload]);
|
|
240
|
+
const surfaceRef = React2.useRef({ messages, store, tenantId, reload, basePath });
|
|
241
|
+
surfaceRef.current = { messages, store, tenantId, reload, basePath };
|
|
242
|
+
const agentSurface = React2.useMemo(() => ({
|
|
243
|
+
id: "automations.list",
|
|
244
|
+
pluginId: "automations",
|
|
245
|
+
instructions: "The user is on the automations list. `automations` in the surface state is the complete set \u2014 use each entry's `event` and `channel` verbatim, and each entry's own `placeholders` when rewriting its text. Call configureAutomation once per automation you change; say afterwards which ones you touched.",
|
|
246
|
+
describe: () => {
|
|
247
|
+
const o = surfaceRef.current;
|
|
248
|
+
return {
|
|
249
|
+
title: "Automa\xE7\xF5es",
|
|
250
|
+
state: {
|
|
251
|
+
automations: (o.messages ?? []).map((m) => ({
|
|
252
|
+
event: m.event.name,
|
|
253
|
+
title: m.event.title,
|
|
254
|
+
channel: m.channel,
|
|
255
|
+
enabled: m.enabled,
|
|
256
|
+
customized: Boolean(m.customized),
|
|
257
|
+
subject: m.subject,
|
|
258
|
+
body: m.body,
|
|
259
|
+
// `fields` é o contrato do evento — os mesmos descritores que viram
|
|
260
|
+
// as merge fields do editor. É de lá que saem os placeholders.
|
|
261
|
+
placeholders: (m.event.fields ?? []).map((f) => `{{${f.name}}}`)
|
|
262
|
+
}))
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
},
|
|
266
|
+
tools: [{
|
|
267
|
+
tool: CONFIGURE_TOOL,
|
|
268
|
+
execute: async (args) => {
|
|
269
|
+
const o = surfaceRef.current;
|
|
270
|
+
const found = (o.messages ?? []).find(
|
|
271
|
+
(m) => m.event.name === args.event && m.channel === args.channel
|
|
272
|
+
);
|
|
273
|
+
if (!found) {
|
|
274
|
+
return {
|
|
275
|
+
ok: false,
|
|
276
|
+
error: "unknown_automation",
|
|
277
|
+
available: (o.messages ?? []).map((m) => `${m.event.name}/${m.channel}`)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
await o.store.upsert({
|
|
282
|
+
eventKey: found.event.name,
|
|
283
|
+
channel: found.channel,
|
|
284
|
+
...args.enabled === void 0 ? {} : { enabled: Boolean(args.enabled) },
|
|
285
|
+
...args.subject === void 0 ? {} : { subject: String(args.subject) },
|
|
286
|
+
...args.body === void 0 ? {} : { body: String(args.body) }
|
|
287
|
+
}, o.tenantId);
|
|
288
|
+
await o.reload();
|
|
289
|
+
return {
|
|
290
|
+
ok: true,
|
|
291
|
+
event: found.event.name,
|
|
292
|
+
channel: found.channel,
|
|
293
|
+
ref: {
|
|
294
|
+
id: `${found.event.name}/${found.channel}`,
|
|
295
|
+
label: `${found.event.title ?? found.event.name} \u2014 ${CHANNEL_LABEL[found.channel] ?? found.channel}`,
|
|
296
|
+
path: `${o.basePath}/${encodeURIComponent(found.event.name)}/${found.channel}`
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
} catch (e) {
|
|
300
|
+
return { ok: false, error: errorMessage(e) };
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}]
|
|
304
|
+
}), []);
|
|
305
|
+
useAgentSurface(agentSurface);
|
|
306
|
+
const toggle = async (m, enabled) => {
|
|
307
|
+
setMessages((prev) => prev?.map((x) => x.event.name === m.event.name && x.channel === m.channel ? { ...x, enabled } : x) ?? null);
|
|
308
|
+
try {
|
|
309
|
+
await store.upsert({ eventKey: m.event.name, channel: m.channel, enabled }, tenantId);
|
|
310
|
+
await reload();
|
|
311
|
+
} catch (err) {
|
|
312
|
+
console.warn("[automations] toggle failed", err);
|
|
313
|
+
toast.error("N\xE3o foi poss\xEDvel salvar");
|
|
314
|
+
await reload();
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const visible = (messages ?? []).filter((m) => kind === "all" || m.kind === kind);
|
|
318
|
+
const ownedVisible = kind === "all" ? owned : [];
|
|
319
|
+
const activeCount = (messages ?? []).filter((m) => m.enabled).length + owned.length;
|
|
320
|
+
const totalCount = (messages?.length ?? 0) + owned.length;
|
|
321
|
+
const groups = [];
|
|
322
|
+
for (const m of visible) {
|
|
323
|
+
let g = groups.find((x) => x.module === m.event.pluginId);
|
|
324
|
+
if (!g) {
|
|
325
|
+
g = { module: m.event.pluginId, label: m.event.pluginName, items: [] };
|
|
326
|
+
groups.push(g);
|
|
327
|
+
}
|
|
328
|
+
g.items.push(m);
|
|
329
|
+
}
|
|
330
|
+
const counter = messages !== null && /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
|
|
331
|
+
activeCount,
|
|
332
|
+
" de ",
|
|
333
|
+
totalCount,
|
|
334
|
+
" automa\xE7\xF5es ativas"
|
|
335
|
+
] });
|
|
336
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
337
|
+
variant !== "panel" ? /* @__PURE__ */ jsx(PageHeaderActions, { children: /* @__PURE__ */ jsx(
|
|
338
|
+
PageActions,
|
|
339
|
+
{
|
|
340
|
+
actions: [{
|
|
341
|
+
id: "automations-ai",
|
|
342
|
+
label: ASK_AI_ACTION.label,
|
|
343
|
+
icon: WandSparkles,
|
|
344
|
+
ai: true,
|
|
345
|
+
intent: "primary",
|
|
346
|
+
creates: true,
|
|
347
|
+
onSelect: () => askAI({ hint: ASK_AI_ACTION.hint, intro: ASK_AI_ACTION.intro })
|
|
348
|
+
}]
|
|
349
|
+
}
|
|
350
|
+
) }) : null,
|
|
351
|
+
variant === "panel" ? /* @__PURE__ */ jsx(
|
|
352
|
+
SettingsTabs,
|
|
353
|
+
{
|
|
354
|
+
tabs: KIND_TABS.map((t) => ({ id: t.value, label: t.label, IconComp: t.icon })),
|
|
355
|
+
value: kind,
|
|
356
|
+
onChange: (id) => setKind(id),
|
|
357
|
+
"aria-label": "Automa\xE7\xF5es",
|
|
358
|
+
actions: counter
|
|
359
|
+
}
|
|
360
|
+
) : (
|
|
361
|
+
/* Mesma faixa das listas e da sub-nav de módulo. */
|
|
362
|
+
/* @__PURE__ */ jsx(
|
|
363
|
+
PageTabs,
|
|
364
|
+
{
|
|
365
|
+
className: "mb-0",
|
|
366
|
+
tabs: KIND_TABS.map((t) => ({ value: t.value, label: t.label, icon: t.icon })),
|
|
367
|
+
value: kind,
|
|
368
|
+
onChange: setKind,
|
|
369
|
+
"aria-label": "Automa\xE7\xF5es",
|
|
370
|
+
actions: counter
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
),
|
|
374
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: KIND_HINT[kind] }),
|
|
375
|
+
messages === null ? /* @__PURE__ */ jsx("div", { className: "space-y-3", children: Array.from({ length: 4 }).map((_, i) => /* @__PURE__ */ jsxs(Card, { className: "p-4", children: [
|
|
376
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-40 animate-pulse rounded bg-muted" }),
|
|
377
|
+
/* @__PURE__ */ jsx("div", { className: "mt-2 h-3 w-64 animate-pulse rounded bg-muted" })
|
|
378
|
+
] }, i)) }) : groups.length === 0 && ownedVisible.length === 0 ? /* @__PURE__ */ jsxs(Card, { className: "flex flex-col items-center gap-1 p-12 text-center", children: [
|
|
379
|
+
/* @__PURE__ */ jsx(Zap, { className: "mb-2 h-9 w-9 text-muted-foreground/40", strokeWidth: 1.5 }),
|
|
380
|
+
/* @__PURE__ */ jsx("p", { className: "text-base font-semibold", children: "Nenhuma automa\xE7\xE3o nesta aba" }),
|
|
381
|
+
/* @__PURE__ */ jsx("p", { className: "max-w-sm text-sm text-muted-foreground", children: "Os eventos v\xEAm dos m\xF3dulos instalados \u2014 a loja traz os do pedido, o CRM os do funil." })
|
|
382
|
+
] }) : groups.map((group) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
383
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: group.label }),
|
|
384
|
+
group.items.map((m) => {
|
|
385
|
+
const Icon = iconFor(m.event.icon ?? m.event.pluginIcon);
|
|
386
|
+
const ChannelIcon = CHANNEL_ICON[m.channel];
|
|
387
|
+
const href = `${basePath}/${encodeURIComponent(m.event.name)}/${m.channel}`;
|
|
388
|
+
const isOpen = selected != null && decodeURIComponent(selected.eventKey) === m.event.name && selected.channel === m.channel;
|
|
389
|
+
return /* @__PURE__ */ jsx(
|
|
390
|
+
Card,
|
|
391
|
+
{
|
|
392
|
+
role: "button",
|
|
393
|
+
tabIndex: 0,
|
|
394
|
+
"aria-current": isOpen || void 0,
|
|
395
|
+
onClick: () => adminNavigateTo(href),
|
|
396
|
+
onKeyDown: (e) => {
|
|
397
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
398
|
+
e.preventDefault();
|
|
399
|
+
adminNavigateTo(href);
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
style: isOpen ? { outline: "2px solid hsl(var(--primary) / 0.65)", outlineOffset: "-2px" } : void 0,
|
|
403
|
+
className: `cursor-pointer overflow-hidden transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ${isOpen ? "" : "hover:border-primary/40"}`,
|
|
404
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-4 p-4", children: [
|
|
405
|
+
/* @__PURE__ */ jsx("span", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border text-muted-foreground", children: /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4" }) }),
|
|
406
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
407
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
408
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: m.override?.name ?? m.event.title ?? m.event.name }),
|
|
409
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground", children: [
|
|
410
|
+
/* @__PURE__ */ jsx(ChannelIcon, { className: "h-3 w-3" }),
|
|
411
|
+
CHANNEL_LABEL[m.channel]
|
|
412
|
+
] }),
|
|
413
|
+
m.customized && /* @__PURE__ */ jsx("span", { className: "rounded-full bg-primary/10 px-2 py-0.5 text-[11px] text-primary", children: "personalizado" }),
|
|
414
|
+
/* @__PURE__ */ jsx(
|
|
415
|
+
ProviderTemplateBadge,
|
|
416
|
+
{
|
|
417
|
+
approval: providerApprovalFor(providerTemplates, m.event.name, m.channel)
|
|
418
|
+
}
|
|
419
|
+
)
|
|
420
|
+
] }),
|
|
421
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: m.event.description }),
|
|
422
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: [
|
|
423
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
424
|
+
/* @__PURE__ */ jsx(Zap, { className: "h-3 w-3" }),
|
|
425
|
+
m.event.trigger
|
|
426
|
+
] }),
|
|
427
|
+
m.subject && /* @__PURE__ */ jsxs("span", { className: "truncate", children: [
|
|
428
|
+
"Assunto: ",
|
|
429
|
+
m.subject
|
|
430
|
+
] })
|
|
431
|
+
] })
|
|
432
|
+
] }),
|
|
433
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-3", children: [
|
|
434
|
+
/* @__PURE__ */ jsx(
|
|
435
|
+
Switch,
|
|
436
|
+
{
|
|
437
|
+
checked: m.enabled,
|
|
438
|
+
onCheckedChange: (next) => void toggle(m, next),
|
|
439
|
+
label: m.enabled ? "Ativo" : "Inativo",
|
|
440
|
+
"aria-label": `${m.event.title} \u2014 ${CHANNEL_LABEL[m.channel]}`
|
|
441
|
+
}
|
|
442
|
+
),
|
|
443
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 text-muted-foreground" })
|
|
444
|
+
] })
|
|
445
|
+
] })
|
|
446
|
+
},
|
|
447
|
+
`${m.event.name}:${m.channel}`
|
|
448
|
+
);
|
|
449
|
+
})
|
|
450
|
+
] }, group.module)),
|
|
451
|
+
messages !== null && /* @__PURE__ */ jsx(ConnectorAutomations, { rows: ownedVisible }),
|
|
452
|
+
selected && /* @__PURE__ */ jsx(
|
|
453
|
+
RightRailPage,
|
|
454
|
+
{
|
|
455
|
+
title: (messages ?? []).find(
|
|
456
|
+
(m) => m.event.name === decodeURIComponent(selected.eventKey) && m.channel === selected.channel
|
|
457
|
+
)?.event.title ?? "Automa\xE7\xE3o",
|
|
458
|
+
open: true,
|
|
459
|
+
onClose: () => adminNavigateTo(basePath),
|
|
460
|
+
width: "max-w-2xl",
|
|
461
|
+
children: /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(
|
|
462
|
+
AutomationDetailPage,
|
|
463
|
+
{
|
|
464
|
+
eventKey: selected.eventKey,
|
|
465
|
+
channel: selected.channel,
|
|
466
|
+
store,
|
|
467
|
+
backTo: basePath,
|
|
468
|
+
embedded: true
|
|
469
|
+
}
|
|
470
|
+
) })
|
|
471
|
+
}
|
|
472
|
+
)
|
|
473
|
+
] });
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export { AutomationsList };
|
|
477
|
+
//# sourceMappingURL=AutomationsList-3UTTQSIX.js.map
|
|
478
|
+
//# sourceMappingURL=AutomationsList-3UTTQSIX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/connector-automations.ts","../src/views/ConnectorAutomations.tsx","../src/views/AutomationsList.tsx"],"names":["React","jsxs","jsx","Card","adminNavigateTo","ChevronRight"],"mappings":";;;;;;;;;;AAmCO,SAAS,wBAAwB,UAAA,EAA0D;AAChG,EAAA,MAAM,MAAgC,EAAC;AACvC,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,IAAI,SAAA,CAAU,UAAU,WAAA,EAAa;AACrC,IAAA,KAAA,MAAW,IAAA,IAAQ,SAAA,CAAU,UAAA,EAAY,kBAAA,IAAsB,EAAC,EAAG;AACjE,MAAA,GAAA,CAAI,IAAA,CAAK;AAAA,QACP,aAAa,SAAA,CAAU,EAAA;AAAA,QACvB,eAAe,SAAA,CAAU,IAAA;AAAA,QACzB,cAAc,SAAA,CAAU,YAAA;AAAA,QACxB,MAAM,SAAA,CAAU,IAAA;AAAA,QAChB,SAAS,SAAA,CAAU,OAAA;AAAA,QACnB,UAAU,IAAA,CAAK,QAAA;AAAA,QACf,OAAO,IAAA,CAAK,KAAA;AAAA,QACZ,QAAA,EAAU,KAAK,QAAA,IAAY,KAAA;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AAAA,IAEA,aAAa,IAAA,oBAAQH,GAAAA,CAAC,oBAAA,EAAA,EAAqB,MAAM,YAAA,EAAc,CAAA;AAAA,IAM/D,4BACCA,GAAAA;AAAA,MAAC,aAAA;AAAA,MAAA;AAAA,QACC,KAAA,EAAA,CACG,QAAA,IAAY,EAAC,EAAG,IAAA;AAAA,UACf,CAAC,CAAA,KAAM,CAAA,CAAE,KAAA,CAAM,IAAA,KAAS,kBAAA,CAAmB,QAAA,CAAS,QAAQ,CAAA,IAAK,CAAA,CAAE,OAAA,KAAY,QAAA,CAAS;AAAA,SAC1F,EAAG,MAAM,KAAA,IAAS,iBAAA;AAAA,QAEpB,IAAA,EAAI,IAAA;AAAA,QACJ,OAAA,EAAS,MAAME,eAAAA,CAAgB,QAAQ,CAAA;AAAA,QACvC,KAAA,EAAM,WAAA;AAAA,QAEN,QAAA,kBAAAF,GAAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,sCACb,QAAA,kBAAAA,GAAAA;AAAA,UAAC,oBAAA;AAAA,UAAA;AAAA,YACC,UAAU,QAAA,CAAS,QAAA;AAAA,YACnB,SAAS,QAAA,CAAS,OAAA;AAAA,YAClB,KAAA;AAAA,YACA,MAAA,EAAQ,QAAA;AAAA,YACR,QAAA,EAAQ;AAAA;AAAA,SACV,EACF;AAAA;AAAA;AACF,GAAA,EAEJ,CAAA;AAEJ","file":"AutomationsList-3UTTQSIX.js","sourcesContent":["import type { UnifiedConnector } from '@fayz-ai/admin'\nimport type { ConnectorDelivery } from '@fayz-ai/core'\n\n// ---------------------------------------------------------------------------\n// As automações que a INTEGRAÇÃO é dona.\n//\n// A tela de automações lia uma fonte só: mensagens. \"Quando um horário é\n// agendado → manda um e-mail\" é uma preferência que alguém escolheu, mora numa\n// linha de `plg_automations_templates` e pode ser apagada. \"Quando um horário é\n// agendado → cria o evento no Google Calendar\" não é preferência nenhuma: é o\n// que a integração É. Por isso é uma SEGUNDA fonte de linhas, e não um texto\n// padrão fingido — um texto padrão viraria uma linha que o usuário pode apagar,\n// deixando a integração conectada e meio ligada em silêncio.\n//\n// Elas existem só enquanto a conexão está viva. Desconectar é a saída, e é a\n// única — o contrato está em ConnectorManagedAutomation (@fayz-ai/core).\n// ---------------------------------------------------------------------------\n\nexport interface ConnectorAutomationRow {\n connectorId: string\n connectorName: string\n /** Onde a integração é configurada — para onde a linha leva. */\n hostPluginId?: string\n /** A cara da integração, resolvida como em qualquer outra tela (ConnectorMark). */\n icon?: string\n logoUrl?: string\n eventKey: string\n label: string\n /** O locatário pode desligar esta e seguir conectado. */\n optional: boolean\n /** Registro a registro: o que chegou no provedor. Ausente = a integração não conta. */\n listDeliveries?: (options?: { eventKey?: string; limit?: number }) => Promise<ConnectorDelivery[]>\n}\n\n/** As linhas de automação dos conectores CONECTADOS. Nada dos demais. */\nexport function connectorAutomationRows(connectors: UnifiedConnector[]): ConnectorAutomationRow[] {\n const out: ConnectorAutomationRow[] = []\n for (const connector of connectors) {\n if (connector.state !== 'connected') continue\n for (const auto of connector.definition?.managedAutomations ?? []) {\n out.push({\n connectorId: connector.id,\n connectorName: connector.name,\n hostPluginId: connector.hostPluginId,\n icon: connector.icon,\n logoUrl: connector.logoUrl,\n eventKey: auto.eventKey,\n label: auto.label,\n optional: auto.optional ?? false,\n ...(connector.definition?.listDeliveries\n ? { listDeliveries: connector.definition.listDeliveries.bind(connector.definition) }\n : {}),\n })\n }\n }\n return out\n}\n\n/** Agrupadas por conector: o dono precisa estar escrito em cima das linhas. */\nexport function groupConnectorAutomations(\n rows: ConnectorAutomationRow[],\n): {\n connectorId: string\n connectorName: string\n hostPluginId?: string\n icon?: string\n logoUrl?: string\n items: ConnectorAutomationRow[]\n}[] {\n const groups: ReturnType<typeof groupConnectorAutomations> = []\n for (const row of rows) {\n let group = groups.find((g) => g.connectorId === row.connectorId)\n if (!group) {\n group = {\n connectorId: row.connectorId,\n connectorName: row.connectorName,\n hostPluginId: row.hostPluginId,\n icon: row.icon,\n logoUrl: row.logoUrl,\n items: [],\n }\n groups.push(group)\n }\n group.items.push(row)\n }\n return groups\n}\n","import React from 'react'\nimport { ChevronRight } from 'lucide-react'\nimport { Button, Card } from '@fayz-ai/ui'\nimport { adminNavigateTo, connectorRoute, ConnectorDeliveries, ConnectorMark } from '@fayz-ai/admin'\nimport {\n groupConnectorAutomations,\n type ConnectorAutomationRow,\n} from '../lib/connector-automations'\n\n// ---------------------------------------------------------------------------\n// As linhas que a integração é dona.\n//\n// Sem interruptor e sem lixeira, de propósito: uma linha apagada deixaria a\n// integração conectada e meio ligada, e semanas depois isso chega como \"o\n// Google Calendar parou de funcionar\". A saída é desconectar, e a linha diz\n// isso em texto — não em botão cinza, que se lê como algo que o usuário poderia\n// consertar (mesmo padrão de ConnectorDetail → \"faz parte do app\").\n// ---------------------------------------------------------------------------\n\nexport function ConnectorAutomations({ rows }: { rows: ConnectorAutomationRow[] }) {\n if (rows.length === 0) return null\n\n return (\n <>\n {groupConnectorAutomations(rows).map((group) => {\n const href = connectorRoute({ hostPluginId: group.hostPluginId })\n return (\n <div key={group.connectorId} className=\"space-y-3\">\n <p className=\"text-xs font-semibold uppercase tracking-wide text-muted-foreground\">\n {group.connectorName}\n </p>\n {group.items.map((row) => (\n <AutomationCard\n key={`${group.connectorId}:${row.eventKey}`}\n row={row}\n group={group}\n href={href}\n />\n ))}\n </div>\n )\n })}\n </>\n )\n}\n\n/**\n * Uma linha da integração, e — quando a integração sabe responder — o que de\n * fato chegou lá.\n *\n * A tela dizia que o gatilho existe. Não dizia se o pedido subiu, que é a\n * pergunta que alguém tem depois de cadastrar. As duas metades eram contadas por\n * sistemas diferentes e nenhum conhecia o outro.\n */\nfunction AutomationCard({\n row,\n group,\n href,\n}: {\n row: ConnectorAutomationRow\n group: { connectorId: string; connectorName: string; icon?: string; logoUrl?: string }\n href: string\n}) {\n const [open, setOpen] = React.useState(false)\n\n return (\n <Card className=\"overflow-hidden\">\n <div\n role=\"button\"\n tabIndex={0}\n onClick={() => adminNavigateTo(href)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); adminNavigateTo(href) }\n }}\n className=\"flex cursor-pointer items-start gap-4 p-4 transition-colors hover:bg-muted/30 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {/* A mesma cara que a integração tem em qualquer outra tela: um plugue\n cinza aqui e o logo do Bling na tela de conectores é a mesma coisa\n parecendo duas. */}\n <ConnectorMark\n connector={{\n id: group.connectorId,\n name: group.connectorName,\n icon: group.icon,\n logoUrl: group.logoUrl,\n }}\n size=\"sm\"\n />\n <div className=\"min-w-0 flex-1\">\n <p className=\"font-medium\">{row.label}</p>\n <p className=\"text-sm text-muted-foreground\">\n Quando <code className=\"font-mono text-xs\">{row.eventKey}</code> acontece aqui.\n </p>\n </div>\n <span className=\"shrink-0 pt-0.5 text-right text-xs text-muted-foreground\">\n {row.optional\n ? `Opcional — desligue em ${group.connectorName}`\n : `Ligada pela integração · sai ao desconectar ${group.connectorName}`}\n </span>\n </div>\n\n {row.listDeliveries && (\n <>\n <Button variant=\"bare\" size=\"bare\"\n type=\"button\"\n onClick={() => setOpen(!open)}\n aria-expanded={open}\n className=\"flex w-full items-center justify-start gap-2 rounded-none border-t border-border px-4 py-2 text-left font-normal transition-colors hover:bg-muted/40\"\n >\n <ChevronRight className={`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${open ? 'rotate-90' : ''}`} />\n <span className=\"text-xs font-medium\">O que já foi para o {group.connectorName}</span>\n </Button>\n {open && (\n <div className=\"border-t border-border p-4\">\n <ConnectorDeliveries\n load={(options) => row.listDeliveries!({ ...options, eventKey: row.eventKey })}\n providerName={group.connectorName}\n />\n </div>\n )}\n </>\n )}\n </Card>\n )\n}\n","import { errorMessage, currentAppPath, onAppPathChange } from '@fayz-ai/core'\nimport React from 'react'\nimport { ChevronRight, Mail, Megaphone, MessageSquare, Receipt, Smartphone, WandSparkles, Zap } from 'lucide-react'\nimport { Card, PageHeaderActions, PageTabs, Switch, toast, WhatsAppIcon, getLucideIcon } from '@fayz-ai/ui'\nimport {\n adminNavigateTo, useConnectors, askAI, PageActions, RightRailPage, SettingsTabs, useAgentSurface,\n type AgentSurfaceContribution,\n} from '@fayz-ai/admin'\nimport type { PluginAITool } from '@fayz-ai/core'\n\n// ---------------------------------------------------------------------------\n// A lista inteira, entregue ao assistente.\n//\n// Da lista dá para fazer as duas coisas que se faz aqui — ligar/desligar e\n// escrever o texto — sem abrir uma por uma, que é a diferença entre \"revise as\n// mensagens de pedido\" e catorze cliques. Passa pelo MESMO `store.upsert` do\n// interruptor e do botão Salvar.\n//\n// `persist` de propósito, ao contrário da ferramenta da tela de detalhe: aqui o\n// texto vai direto para o registro, sem passar por um editor onde alguém leia\n// antes. A confirmação obrigatória é o que põe uma pessoa entre o modelo e uma\n// mensagem que um cliente vai receber.\n// ---------------------------------------------------------------------------\nconst CONFIGURE_TOOL: PluginAITool = {\n id: 'automations.configure',\n name: 'configureAutomation',\n description:\n 'Turns an automation on or off, and/or rewrites its message. Use the `event` and `channel` values exactly as they appear in the surface state. '\n + 'Placeholders must come from that automation\\'s own list — an invented one renders as literal text in a message a customer reads. '\n + 'To review several, call once per automation.',\n icon: 'Zap',\n mode: 'persist',\n execution: { plane: 'client' },\n category: 'Automations',\n parameters: {\n type: 'object',\n properties: {\n event: { type: 'string', description: 'Event key from the surface state.' },\n channel: { type: 'string', description: 'Channel of that automation (email | whatsapp | sms | in_app).' },\n enabled: { type: 'boolean', description: 'Turn it on or off. Omit to leave as is.' },\n subject: { type: 'string', description: 'New subject. Email only.' },\n body: { type: 'string', description: 'New message body.' },\n },\n required: ['event', 'channel'],\n },\n}\nimport { AutomationDetailPage } from './AutomationDetailPage'\nimport { resolveMessages, useOrganizationStoreLike } from '../lib/runtime'\nimport { usePluginRuntimeOptional } from '@fayz-ai/core'\nimport type { MessageChannel, MessageKind, ResolvedMessage } from '@fayz-ai/core'\nimport type { MessageTemplateStore } from '../data/templates'\nimport { connectorAutomationRows } from '../lib/connector-automations'\nimport { ConnectorAutomations } from './ConnectorAutomations'\nimport {\n ProviderTemplateBadge, providerApprovalFor, useProviderTemplates,\n} from './ProviderTemplateStatus'\n\n// ---------------------------------------------------------------------------\n// Automações — quando ISTO acontece, mande AQUILO.\n//\n// Cada linha é uma automação inteira: o gatilho à esquerda, o canal na\n// pastilha, o interruptor à direita. Não existe \"modelo\" separado do \"fluxo\" —\n// um texto sem gatilho nunca sai, e um fluxo de um passo é o texto com o\n// gatilho escrito na frente.\n//\n// Agrupado por MÓDULO (Loja, CRM, Agenda) e não por canal, porque é assim que a\n// pergunta chega: \"o que a gente manda quando um pedido é enviado?\" — e a\n// resposta pode ser um e-mail, um WhatsApp, ou os dois. Separar por canal, como\n// fazia a tela de e-mails, obriga a visitar dois menus para responder isso.\n//\n// Cada linha é um par evento×canal. O evento aparece uma vez, com uma pastilha\n// por canal ofertado: é o desenho que o RD Station e o Kommo usam para não\n// esconder que \"confirmação de pedido\" e \"confirmação por WhatsApp\" são o mesmo\n// gatilho com duas saídas.\n//\n// Duas fontes de linha, e não uma: além das mensagens, as automações que uma\n// integração conectada é dona — ../lib/connector-automations.ts diz por quê.\n// ---------------------------------------------------------------------------\n\n// A porta de IA desta tela, fora do JSX para a ação poder ser declarada.\nconst ASK_AI_ACTION = {\n label: 'Criar com IA',\n hint: 'O que revisar nas automações…',\n intro: {\n role: 'setup' as const,\n persona: 'Redator das automações',\n pitch: 'Diga o que revisar nas automações.',\n description:\n 'Vejo todas as automações deste app, quais estão ligadas e o texto de cada uma. Posso ligar, desligar e reescrever — em uma ou em várias de uma vez. Você confirma cada mudança.',\n suggestions: [\n { label: 'Revise as mensagens de pedido no tom da minha marca' },\n { label: 'Ligue as automações de entrega' },\n { label: 'Deixe as mensagens de WhatsApp mais curtas' },\n ],\n },\n}\n\nconst CHANNEL_ICON: Record<MessageChannel, React.ComponentType<{ className?: string }>> = {\n email: Mail,\n // The brand glyph, not a generic bubble: in a list of channels, WhatsApp\n // is recognized by its mark before its label.\n whatsapp: WhatsAppIcon,\n sms: Smartphone,\n push: MessageSquare,\n webchat: MessageSquare,\n}\n\nconst CHANNEL_LABEL: Record<MessageChannel, string> = {\n email: 'E-mail', whatsapp: 'WhatsApp', sms: 'SMS', push: 'Push', webchat: 'Chat',\n}\n\nconst KIND_TABS: { value: MessageKind | 'all'; label: string; icon: React.ComponentType<{ className?: string }> }[] = [\n { value: 'all', label: 'Todos', icon: Zap },\n { value: 'transactional', label: 'Transacionais', icon: Receipt },\n { value: 'marketing', label: 'Marketing', icon: Megaphone },\n]\n\nconst KIND_HINT: Record<string, string> = {\n all: 'Tudo que o produto sabe enviar, por qualquer canal.',\n transactional: 'Disparados por uma ação da pessoa. Não precisam de opt-in.',\n marketing: 'Iniciativa da empresa. Só para quem aceitou receber.',\n}\n\nfunction iconFor(name?: string): React.ComponentType<{ className?: string }> {\n if (!name) return Zap\n // The SDK's icon registry, not a namespace import of all of lucide.\n return getLucideIcon(name) ?? Zap\n}\n\n/**\n * Qual automação a URL está pedindo. `null` = nenhuma, e a coluna fica com o\n * assistente.\n *\n * A URL continua sendo a verdade mesmo com o detalhe na coluna: é o que faz o\n * link direto funcionar e o botão voltar do navegador FECHAR o painel em vez de\n * sair da lista.\n */\nfunction readSelection(basePath: string): { eventKey: string; channel: string } | null {\n const hash = currentAppPath()\n if (!hash.startsWith(basePath + '/')) return null\n const [eventKey, channel] = hash.slice(basePath.length + 1).split('/')\n if (!eventKey || !channel) return null\n return { eventKey, channel }\n}\n\nexport function AutomationsList({ store, variant = 'page', basePath = '/automations' }: {\n store: MessageTemplateStore\n /**\n * Onde esta lista mora, e portanto sob que caminho o detalhe abre.\n *\n * A lista pode estar no menu (`/automations`) ou dentro de Configurações\n * (`/settings/automations`) — e o detalhe tem que abrir SOB ela, senão clicar\n * numa linha dentro de Configurações jogava a pessoa para fora da tela em que\n * ela estava.\n */\n basePath?: string\n /**\n * Onde a lista está montada, e portanto que faixa de abas ela desenha.\n *\n * 'page' a tela é dela: a faixa é a sub-cabeça do módulo, sangra até as\n * bordas e sua régua encontra a barra da shell.\n * 'panel' ela é o conteúdo de uma aba de Configurações, onde a shell já\n * escreveu \"← Configurações / Automações\". Aí vale a MESMA faixa dos\n * outros painéis de configuração (Agenda, CRM, Formulários), que\n * começa e termina onde o conteúdo começa e termina.\n */\n variant?: 'page' | 'panel'\n}) {\n const tenantId = useOrganizationStoreLike()\n // Os eventos vêm do runtime: só os plugins ATIVOS anunciam fatos.\n const runtime = usePluginRuntimeOptional()\n const [messages, setMessages] = React.useState<ResolvedMessage[] | null>(null)\n const [kind, setKind] = React.useState<MessageKind | 'all'>('all')\n // A segunda fonte de linhas: as automações que a integração é dona. Mesmo\n // loader dos conectores — duas leituras seriam duas respostas para \"o Google\n // Calendar está ligado?\". Sem grants e sem catálogo: nada disso vira linha\n // aqui, e assim a tela não faz rede nenhuma.\n const { connectors } = useConnectors({ includeGrants: false, includeCatalog: false })\n const owned = React.useMemo(() => connectorAutomationRows(connectors ?? []), [connectors])\n // O que a Meta respondeu sobre cada modelo de WhatsApp. Uma leitura por tela,\n // e sem ela a lista continua inteira — só sem a pastilha.\n const providerTemplates = useProviderTemplates()\n\n // A automação aberta na coluna da direita, lida da URL.\n const [selected, setSelected] = React.useState(() => readSelection(basePath))\n React.useEffect(() => {\n const sync = () => setSelected(readSelection(basePath))\n sync()\n return onAppPathChange(sync)\n }, [basePath])\n\n const reload = React.useCallback(async () => {\n // Uma leitura que falha ainda mostra o catálogo inteiro nos padrões: os\n // eventos são código, então \"sem personalização\" é um estado válido e\n // completo, não uma tela vazia.\n let overrides: Awaited<ReturnType<MessageTemplateStore['list']>> = []\n try {\n overrides = await store.list(tenantId)\n } catch (err) {\n console.warn('[automations] could not load template overrides; showing defaults', err)\n }\n setMessages(resolveMessages(overrides, runtime?.events ?? []))\n }, [store, tenantId, runtime])\n\n React.useEffect(() => { void reload() }, [reload])\n\n // --- assistant surface ---------------------------------------------------\n const surfaceRef = React.useRef({ messages, store, tenantId, reload, basePath })\n surfaceRef.current = { messages, store, tenantId, reload, basePath }\n\n const agentSurface = React.useMemo<AgentSurfaceContribution>(() => ({\n id: 'automations.list',\n pluginId: 'automations',\n instructions:\n 'The user is on the automations list. `automations` in the surface state is the complete set — use each entry\\'s `event` and `channel` verbatim, and each entry\\'s own `placeholders` when rewriting its text. '\n + 'Call configureAutomation once per automation you change; say afterwards which ones you touched.',\n describe: () => {\n const o = surfaceRef.current\n return {\n title: 'Automações',\n state: {\n automations: (o.messages ?? []).map((m) => ({\n event: m.event.name,\n title: m.event.title,\n channel: m.channel,\n enabled: m.enabled,\n customized: Boolean(m.customized),\n subject: m.subject,\n body: m.body,\n // `fields` é o contrato do evento — os mesmos descritores que viram\n // as merge fields do editor. É de lá que saem os placeholders.\n placeholders: (m.event.fields ?? []).map((f) => `{{${f.name}}}`),\n })),\n },\n }\n },\n tools: [{\n tool: CONFIGURE_TOOL,\n execute: async (args: Record<string, unknown>) => {\n const o = surfaceRef.current\n const found = (o.messages ?? []).find(\n (m) => m.event.name === args.event && m.channel === args.channel,\n )\n if (!found) {\n return {\n ok: false,\n error: 'unknown_automation',\n available: (o.messages ?? []).map((m) => `${m.event.name}/${m.channel}`),\n }\n }\n try {\n await o.store.upsert({\n eventKey: found.event.name,\n channel: found.channel,\n ...(args.enabled === undefined ? {} : { enabled: Boolean(args.enabled) }),\n ...(args.subject === undefined ? {} : { subject: String(args.subject) }),\n ...(args.body === undefined ? {} : { body: String(args.body) }),\n }, o.tenantId)\n await o.reload()\n // `ref.path` decorates the reply with a goto chip (RecordChip) — the\n // user lands on what the agent just changed. `path`, not archetype:\n // an automation is a settings destination, not a record.\n return {\n ok: true,\n event: found.event.name,\n channel: found.channel,\n ref: {\n id: `${found.event.name}/${found.channel}`,\n label: `${found.event.title ?? found.event.name} — ${CHANNEL_LABEL[found.channel] ?? found.channel}`,\n path: `${o.basePath}/${encodeURIComponent(found.event.name)}/${found.channel}`,\n },\n }\n } catch (e) {\n return { ok: false, error: errorMessage(e) }\n }\n },\n }],\n }), [])\n useAgentSurface(agentSurface)\n\n const toggle = async (m: ResolvedMessage, enabled: boolean) => {\n setMessages((prev) => prev?.map((x) =>\n x.event.name === m.event.name && x.channel === m.channel ? { ...x, enabled } : x) ?? null)\n try {\n await store.upsert({ eventKey: m.event.name, channel: m.channel, enabled }, tenantId)\n await reload()\n } catch (err) {\n console.warn('[automations] toggle failed', err)\n toast.error('Não foi possível salvar')\n await reload()\n }\n }\n\n const visible = (messages ?? []).filter((m) => kind === 'all' || m.kind === kind)\n // As linhas do conector não são mensagens, então não têm \"kind\" — aparecem na\n // aba Todos. Contam no total porque estão rodando: omiti-las faria o contador\n // dizer menos automações ativas do que o negócio tem.\n const ownedVisible = kind === 'all' ? owned : []\n const activeCount = (messages ?? []).filter((m) => m.enabled).length + owned.length\n const totalCount = (messages?.length ?? 0) + owned.length\n\n // Agrupa por módulo preservando a ordem de registro dos plugins.\n const groups: { module: string; label: string; items: ResolvedMessage[] }[] = []\n for (const m of visible) {\n let g = groups.find((x) => x.module === m.event.pluginId)\n if (!g) { g = { module: m.event.pluginId, label: m.event.pluginName, items: [] }; groups.push(g) }\n g.items.push(m)\n }\n\n const counter = messages !== null && (\n <span className=\"text-sm text-muted-foreground\">\n {activeCount} de {totalCount} automações ativas\n </span>\n )\n\n return (\n <div className=\"space-y-6\">\n {/* Declarado, não desenhado: o <AskAIButton> cru ficava no cabeçalho no\n celular, onde toda outra tela já entrega a ação ao polegar. */}\n {variant !== 'panel' ? (\n <PageHeaderActions>\n <PageActions\n actions={[{\n id: 'automations-ai',\n label: ASK_AI_ACTION.label,\n icon: WandSparkles,\n ai: true,\n intent: 'primary',\n creates: true,\n onSelect: () => askAI({ hint: ASK_AI_ACTION.hint, intro: ASK_AI_ACTION.intro }),\n }]}\n />\n </PageHeaderActions>\n ) : null}\n\n {variant === 'panel' ? (\n <SettingsTabs\n tabs={KIND_TABS.map((t) => ({ id: t.value, label: t.label, IconComp: t.icon }))}\n value={kind}\n onChange={(id) => setKind(id as MessageKind | 'all')}\n aria-label=\"Automações\"\n actions={counter}\n />\n ) : (\n /* Mesma faixa das listas e da sub-nav de módulo. */\n <PageTabs\n className=\"mb-0\"\n tabs={KIND_TABS.map((t) => ({ value: t.value, label: t.label, icon: t.icon }))}\n value={kind}\n onChange={setKind}\n aria-label=\"Automações\"\n actions={counter}\n />\n )}\n\n <p className=\"text-sm text-muted-foreground\">{KIND_HINT[kind]}</p>\n\n {messages === null ? (\n <div className=\"space-y-3\">\n {Array.from({ length: 4 }).map((_, i) => (\n <Card key={i} className=\"p-4\">\n <div className=\"h-4 w-40 animate-pulse rounded bg-muted\" />\n <div className=\"mt-2 h-3 w-64 animate-pulse rounded bg-muted\" />\n </Card>\n ))}\n </div>\n ) : groups.length === 0 && ownedVisible.length === 0 ? (\n <Card className=\"flex flex-col items-center gap-1 p-12 text-center\">\n <Zap className=\"mb-2 h-9 w-9 text-muted-foreground/40\" strokeWidth={1.5} />\n <p className=\"text-base font-semibold\">Nenhuma automação nesta aba</p>\n <p className=\"max-w-sm text-sm text-muted-foreground\">\n Os eventos vêm dos módulos instalados — a loja traz os do pedido, o CRM os do funil.\n </p>\n </Card>\n ) : groups.map((group) => (\n <div key={group.module} className=\"space-y-3\">\n <p className=\"text-xs font-semibold uppercase tracking-wide text-muted-foreground\">\n {group.label}\n </p>\n {group.items.map((m) => {\n const Icon = iconFor(m.event.icon ?? m.event.pluginIcon)\n const ChannelIcon = CHANNEL_ICON[m.channel]\n const href = `${basePath}/${encodeURIComponent(m.event.name)}/${m.channel}`\n // A linha cujo detalhe está aberto na coluna ao lado. Sem a marca,\n // com o rail aberto a lista não diz de QUEM ele fala.\n const isOpen = selected != null\n && decodeURIComponent(selected.eventKey) === m.event.name\n && selected.channel === m.channel\n return (\n <Card\n key={`${m.event.name}:${m.channel}`}\n role=\"button\"\n tabIndex={0}\n aria-current={isOpen || undefined}\n onClick={() => adminNavigateTo(href)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); adminNavigateTo(href) }\n }}\n // Outline, not border/ring: the glass surface forces the card's\n // border-color to transparent and owns its box-shadow, so both\n // utilities are silently defeated there. Outline is the one\n // edge the glass system does not touch, and inline style keeps\n // it out of Tailwind's content-scan lottery.\n style={isOpen ? { outline: '2px solid hsl(var(--primary) / 0.65)', outlineOffset: '-2px' } : undefined}\n className={`cursor-pointer overflow-hidden transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ${\n isOpen ? '' : 'hover:border-primary/40'\n }`}\n >\n <div className=\"flex items-start gap-4 p-4\">\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border text-muted-foreground\">\n <Icon className=\"h-4 w-4\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <p className=\"font-medium\">{m.override?.name ?? m.event.title ?? m.event.name}</p>\n <span className=\"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground\">\n <ChannelIcon className=\"h-3 w-3\" />\n {CHANNEL_LABEL[m.channel]}\n </span>\n {m.customized && (\n <span className=\"rounded-full bg-primary/10 px-2 py-0.5 text-[11px] text-primary\">\n personalizado\n </span>\n )}\n {/* Ligado não quer dizer que vai sair: no WhatsApp a Meta\n ainda precisa aprovar o modelo. */}\n <ProviderTemplateBadge\n approval={providerApprovalFor(providerTemplates, m.event.name, m.channel)}\n />\n </div>\n <p className=\"text-sm text-muted-foreground\">{m.event.description}</p>\n <div className=\"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground\">\n <span className=\"inline-flex items-center gap-1\">\n <Zap className=\"h-3 w-3\" />\n {m.event.trigger}\n </span>\n {m.subject && <span className=\"truncate\">Assunto: {m.subject}</span>}\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-3\">\n {/* Switch e não checkbox: isto vale na hora, não quando\n algum Salvar for clicado. */}\n <Switch\n checked={m.enabled}\n onCheckedChange={(next) => void toggle(m, next)}\n label={m.enabled ? 'Ativo' : 'Inativo'}\n aria-label={`${m.event.title} — ${CHANNEL_LABEL[m.channel]}`}\n />\n <ChevronRight className=\"h-4 w-4 text-muted-foreground\" />\n </div>\n </div>\n </Card>\n )\n })}\n </div>\n ))}\n\n {messages !== null && <ConnectorAutomations rows={ownedVisible} />}\n\n {/* O detalhe abre AO LADO da lista, não no lugar dela: escolher o que uma\n automação diz é olhar as outras que já existem, e a tela cheia tirava\n exatamente isso de vista. O nome sai da linha que já está carregada —\n a coluna se nomeia antes de o detalhe terminar de carregar. */}\n {selected && (\n <RightRailPage\n title={\n (messages ?? []).find(\n (m) => m.event.name === decodeURIComponent(selected.eventKey) && m.channel === selected.channel,\n )?.event.title ?? 'Automação'\n }\n open\n onClose={() => adminNavigateTo(basePath)}\n width=\"max-w-2xl\"\n >\n <div className=\"min-h-0 flex-1 overflow-y-auto p-4\">\n <AutomationDetailPage\n eventKey={selected.eventKey}\n channel={selected.channel}\n store={store}\n backTo={basePath}\n embedded\n />\n </div>\n </RightRailPage>\n )}\n </div>\n )\n}\n"]}
|