@apotech-os/support-kit 7.0.0 → 8.0.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/README.md +66 -0
- package/dist/{chunk-CQJJZA4F.js → chunk-2UHFKGMI.js} +55 -6
- package/dist/chunk-2UHFKGMI.js.map +1 -0
- package/dist/index.cjs +686 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -5
- package/dist/index.d.ts +51 -5
- package/dist/index.js +651 -38
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +284 -8
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +249 -6
- package/dist/ui/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/chunk-CQJJZA4F.js.map +0 -1
package/dist/ui/index.cjs
CHANGED
|
@@ -54,6 +54,16 @@ function requiresFollowup(verdict) {
|
|
|
54
54
|
return verdict === "send_and_escalate";
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// src/domain/origin.ts
|
|
58
|
+
var DECISION_ORIGINS = ["triage", "followup"];
|
|
59
|
+
var DEFAULT_DECISION_ORIGIN = "triage";
|
|
60
|
+
function isDecisionOrigin(value) {
|
|
61
|
+
return typeof value === "string" && DECISION_ORIGINS.includes(value);
|
|
62
|
+
}
|
|
63
|
+
function toDecisionOrigin(value) {
|
|
64
|
+
return isDecisionOrigin(value) ? value : DEFAULT_DECISION_ORIGIN;
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
// src/functions/records.ts
|
|
58
68
|
function toAgent(record) {
|
|
59
69
|
const data = record.data;
|
|
@@ -82,7 +92,9 @@ function toCategory(record) {
|
|
|
82
92
|
description: data.description ?? null,
|
|
83
93
|
examples: data.examples ?? null,
|
|
84
94
|
autoReplyEnabled: data.autoReplyEnabled ?? false,
|
|
85
|
-
fastResponseEnabled: data.fastResponseEnabled ?? false
|
|
95
|
+
fastResponseEnabled: data.fastResponseEnabled ?? false,
|
|
96
|
+
followupFastResponseEnabled: data.followupFastResponseEnabled ?? false,
|
|
97
|
+
followupAutoReplyEnabled: data.followupAutoReplyEnabled ?? false
|
|
86
98
|
};
|
|
87
99
|
}
|
|
88
100
|
function toCategoryGroup(record) {
|
|
@@ -111,7 +123,8 @@ function toTriageDecision(record) {
|
|
|
111
123
|
status: data.status ?? null,
|
|
112
124
|
error: data.error ?? null,
|
|
113
125
|
runId: data.runId ?? null,
|
|
114
|
-
subjectRenamed: data.subjectRenamed ?? false
|
|
126
|
+
subjectRenamed: data.subjectRenamed ?? false,
|
|
127
|
+
origin: toDecisionOrigin(data.origin)
|
|
115
128
|
};
|
|
116
129
|
}
|
|
117
130
|
function toVerdict(raw) {
|
|
@@ -152,7 +165,8 @@ function toGeneratedResponse(record) {
|
|
|
152
165
|
autoSendDecision: data.autoSendDecision ?? null,
|
|
153
166
|
sentAt: data.sentAt ?? null,
|
|
154
167
|
sentMessageId: data.sentMessageId ?? null,
|
|
155
|
-
error: data.error ?? null
|
|
168
|
+
error: data.error ?? null,
|
|
169
|
+
origin: toDecisionOrigin(data.origin)
|
|
156
170
|
};
|
|
157
171
|
}
|
|
158
172
|
function toResponseComparison(record) {
|
|
@@ -1840,7 +1854,6 @@ function ticketActions(input) {
|
|
|
1840
1854
|
} else if (job) {
|
|
1841
1855
|
skipped.push(`R\xE9ponse non envoy\xE9e \u2014 ${notSentReason2 ?? "raison inconnue."}`);
|
|
1842
1856
|
}
|
|
1843
|
-
if (job?.outcome === "needs_human") taken.push("Alerte lev\xE9e dans la bo\xEEte de r\xE9ception.");
|
|
1844
1857
|
if (job?.outcome === "awaiting_approval" && !simulated) taken.push("Demande d'approbation cr\xE9\xE9e.");
|
|
1845
1858
|
return { tags, taken, skipped, simulated, unrecorded: job !== void 0 && job.outcome === null };
|
|
1846
1859
|
}
|
|
@@ -3794,6 +3807,25 @@ function CategoriesPage() {
|
|
|
3794
3807
|
toast({ title: "\xC9chec de la mise \xE0 jour", description: describeApiError(err), variant: "error" });
|
|
3795
3808
|
}
|
|
3796
3809
|
}
|
|
3810
|
+
async function toggleFollowupFastResponse(category) {
|
|
3811
|
+
const next = !category.followupFastResponseEnabled;
|
|
3812
|
+
const data = { followupFastResponseEnabled: next };
|
|
3813
|
+
if (!next && category.followupAutoReplyEnabled) data.followupAutoReplyEnabled = false;
|
|
3814
|
+
try {
|
|
3815
|
+
await api.patch(categoryPath(category.id), { data });
|
|
3816
|
+
await refreshCategories();
|
|
3817
|
+
} catch (err) {
|
|
3818
|
+
toast({ title: "\xC9chec de la mise \xE0 jour", description: describeApiError(err), variant: "error" });
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
async function toggleFollowupAutoReply(category) {
|
|
3822
|
+
try {
|
|
3823
|
+
await api.patch(categoryPath(category.id), { data: { followupAutoReplyEnabled: !category.followupAutoReplyEnabled } });
|
|
3824
|
+
await refreshCategories();
|
|
3825
|
+
} catch (err) {
|
|
3826
|
+
toast({ title: "\xC9chec de la mise \xE0 jour", description: describeApiError(err), variant: "error" });
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3797
3829
|
async function move(category, direction) {
|
|
3798
3830
|
const siblings = byGroup.get(category.groupId ?? UNGROUPED_KEY) ?? [];
|
|
3799
3831
|
const index = siblings.findIndex((c) => c.id === category.id);
|
|
@@ -3864,6 +3896,30 @@ function CategoriesPage() {
|
|
|
3864
3896
|
}
|
|
3865
3897
|
)
|
|
3866
3898
|
] }),
|
|
3899
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3900
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Fast response (suite)" }),
|
|
3901
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3902
|
+
uiSdk.Switch,
|
|
3903
|
+
{
|
|
3904
|
+
"aria-label": `Fast response (suite) \u2014 ${category.name}`,
|
|
3905
|
+
checked: category.followupFastResponseEnabled,
|
|
3906
|
+
onCheckedChange: () => void toggleFollowupFastResponse(category),
|
|
3907
|
+
disabled: !canWrite || !category.agentId
|
|
3908
|
+
}
|
|
3909
|
+
)
|
|
3910
|
+
] }),
|
|
3911
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3912
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "R\xE9ponse auto (suite)" }),
|
|
3913
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3914
|
+
uiSdk.Switch,
|
|
3915
|
+
{
|
|
3916
|
+
"aria-label": `R\xE9ponse auto (suite) \u2014 ${category.name}`,
|
|
3917
|
+
checked: category.followupAutoReplyEnabled,
|
|
3918
|
+
onCheckedChange: () => void toggleFollowupAutoReply(category),
|
|
3919
|
+
disabled: !canWrite || !category.followupFastResponseEnabled || !category.agentId
|
|
3920
|
+
}
|
|
3921
|
+
)
|
|
3922
|
+
] }),
|
|
3867
3923
|
category.extraTags.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-1", children: category.extraTags.map((tag) => /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "outline", children: tag }, tag)) }),
|
|
3868
3924
|
canWrite && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
3869
3925
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4492,6 +4548,106 @@ function SourceViewField({ views, value, onChange, disabled }) {
|
|
|
4492
4548
|
}
|
|
4493
4549
|
);
|
|
4494
4550
|
}
|
|
4551
|
+
|
|
4552
|
+
// src/functions/followup-webhook-install.ts
|
|
4553
|
+
var FOLLOWUP_WEBHOOK_ROUTE_PATH = "/gorgias/webhook";
|
|
4554
|
+
var FOLLOWUP_WEBHOOK_FORM = {
|
|
4555
|
+
ticket_id: "{{ticket.id}}",
|
|
4556
|
+
channel: "{{ticket.channel}}",
|
|
4557
|
+
last_message_datetime: "{{ticket.last_message_datetime}}",
|
|
4558
|
+
status: "{{ticket.status}}",
|
|
4559
|
+
tags: "{{ticket.tags}}",
|
|
4560
|
+
last_message_from_agent: "{{ticket.messages[-1].from_agent}}",
|
|
4561
|
+
last_message_public: "{{ticket.messages[-1].public}}"
|
|
4562
|
+
};
|
|
4563
|
+
var FOLLOWUP_WEBHOOK_TRIGGER = "ticket-message-created";
|
|
4564
|
+
function followupIntegrationName(slug) {
|
|
4565
|
+
return `Wopilo \u2014 R\xE9ponses aux messages suivants (${slug})`;
|
|
4566
|
+
}
|
|
4567
|
+
function followupWebhookPath(slug) {
|
|
4568
|
+
return `/api/s/${slug}${FOLLOWUP_WEBHOOK_ROUTE_PATH}`;
|
|
4569
|
+
}
|
|
4570
|
+
function FollowupWebhookCard({ scopeTag, onScopeTagChange, canWrite }) {
|
|
4571
|
+
const { appSlug } = uiSdk.useAppContext();
|
|
4572
|
+
const scopeId = react.useId();
|
|
4573
|
+
return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { id: "webhook-suite", children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-4 p-4", children: [
|
|
4574
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4575
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-medium", children: "R\xE9ponses aux messages suivants" }),
|
|
4576
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Quand un client r\xE9pond sur un ticket d\xE9j\xE0 trait\xE9, l'agent peut g\xE9n\xE9rer une nouvelle r\xE9ponse. Chaque cat\xE9gorie d\xE9cide si elle suit le fil (page Cat\xE9gories)." })
|
|
4577
|
+
] }),
|
|
4578
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4579
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: scopeId, className: "mb-1 block text-sm font-medium", children: "Tag de p\xE9rim\xE8tre webhook" }),
|
|
4580
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4581
|
+
uiSdk.Input,
|
|
4582
|
+
{
|
|
4583
|
+
id: scopeId,
|
|
4584
|
+
value: scopeTag,
|
|
4585
|
+
onChange: (e) => onScopeTagChange(e.target.value),
|
|
4586
|
+
placeholder: "wai/triaged",
|
|
4587
|
+
disabled: !canWrite
|
|
4588
|
+
}
|
|
4589
|
+
),
|
|
4590
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
4591
|
+
"Le ticket doit d\xE9j\xE0 porter ce tag pour qu'un message suivant soit trait\xE9 \u2014 typiquement le tag \xAB trait\xE9 \xBB pos\xE9 par le premier passage. ",
|
|
4592
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Vide = aucun message suivant trait\xE9" }),
|
|
4593
|
+
" (c'est aussi le kill-switch). Deux apps sur le m\xEAme compte Gorgias doivent y mettre des valeurs ",
|
|
4594
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "distinctes" }),
|
|
4595
|
+
", sinon chacune r\xE9pondrait sur les tickets de l'autre."
|
|
4596
|
+
] })
|
|
4597
|
+
] }),
|
|
4598
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 border-t pt-4", children: [
|
|
4599
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: "Int\xE9gration Gorgias (installation manuelle)" }),
|
|
4600
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4601
|
+
"\xC0 cr\xE9er une fois dans Gorgias, sous ",
|
|
4602
|
+
/* @__PURE__ */ jsxRuntime.jsx("em", { children: "Settings \u203A Integrations \u203A HTTP" }),
|
|
4603
|
+
". Rien n'est install\xE9 depuis cette page : l'app n'\xE9crit rien sur le compte Gorgias."
|
|
4604
|
+
] }),
|
|
4605
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "space-y-1 text-xs", children: [
|
|
4606
|
+
/* @__PURE__ */ jsxRuntime.jsx(RecipeRow, { label: "Nom", children: followupIntegrationName(appSlug) }),
|
|
4607
|
+
/* @__PURE__ */ jsxRuntime.jsx(RecipeRow, { label: "D\xE9clencheur", children: FOLLOWUP_WEBHOOK_TRIGGER }),
|
|
4608
|
+
/* @__PURE__ */ jsxRuntime.jsx(RecipeRow, { label: "M\xE9thode", children: "POST" }),
|
|
4609
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RecipeRow, { label: "URL", children: [
|
|
4610
|
+
"<PUBLIC_BASE_URL>",
|
|
4611
|
+
followupWebhookPath(appSlug)
|
|
4612
|
+
] }),
|
|
4613
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RecipeRow, { label: "En-t\xEAte", children: [
|
|
4614
|
+
"Authorization: Bearer <cl\xE9 d'application ",
|
|
4615
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { children: "wopilo_app_\u2026" }),
|
|
4616
|
+
">"
|
|
4617
|
+
] })
|
|
4618
|
+
] }),
|
|
4619
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4620
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { children: "PUBLIC_BASE_URL" }),
|
|
4621
|
+
" est l'origine publique de l'",
|
|
4622
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "API" }),
|
|
4623
|
+
" \u2014 pas forc\xE9ment celle de cette interface, que l'instance peut servir depuis un autre domaine (",
|
|
4624
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { children: "WEB_APP_URL" }),
|
|
4625
|
+
"). En cas de doute, c'est la valeur r\xE9gl\xE9e c\xF4t\xE9 instance qui fait foi : une URL construite sur la mauvaise origine renvoie 404 \xE0 chaque appel Gorgias, sans message d'erreur nulle part."
|
|
4626
|
+
] }),
|
|
4627
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4628
|
+
"La cl\xE9 est une cl\xE9 d'application de cette app, cr\xE9\xE9e dans la plateforme puis coll\xE9e telle quelle dans l'en-t\xEAte. Elle porte le r\xF4le manifeste complet de l'app (voir",
|
|
4629
|
+
" ",
|
|
4630
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { children: "docs/app-platform/gorgias-callback-authentication.md" }),
|
|
4631
|
+
" \xA75)."
|
|
4632
|
+
] }),
|
|
4633
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4634
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-xs font-medium", children: "Champs du corps (onglet \xAB Body \xBB, un par ligne)" }),
|
|
4635
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-0.5 font-mono text-xs text-muted-foreground", children: Object.entries(FOLLOWUP_WEBHOOK_FORM).map(([key, value]) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
4636
|
+
key,
|
|
4637
|
+
" = ",
|
|
4638
|
+
value
|
|
4639
|
+
] }, key)) }),
|
|
4640
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Les quatre derniers champs ne sont pas document\xE9s par Gorgias : s'ils ne se r\xE9solvent pas, le traitement relit simplement le ticket et continue. Rien ne casse s'ils manquent." })
|
|
4641
|
+
] })
|
|
4642
|
+
] })
|
|
4643
|
+
] }) });
|
|
4644
|
+
}
|
|
4645
|
+
function RecipeRow({ label, children }) {
|
|
4646
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
4647
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "w-24 shrink-0 text-muted-foreground", children: label }),
|
|
4648
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "break-all font-mono", children })
|
|
4649
|
+
] });
|
|
4650
|
+
}
|
|
4495
4651
|
var WHATSAPP_MODE_LABELS = {
|
|
4496
4652
|
escalate_only: "Escalade uniquement",
|
|
4497
4653
|
draft_only: "Brouillon uniquement",
|
|
@@ -4511,7 +4667,7 @@ function list(value) {
|
|
|
4511
4667
|
return Array.isArray(value) ? value.join(", ") : "";
|
|
4512
4668
|
}
|
|
4513
4669
|
function parseList(value) {
|
|
4514
|
-
return value.split(
|
|
4670
|
+
return value.split(/[\n,]/).map((v) => v.trim()).filter(Boolean);
|
|
4515
4671
|
}
|
|
4516
4672
|
function describeConnection(connections) {
|
|
4517
4673
|
if (connections === void 0) return { text: "Chargement\u2026", tone: "muted" };
|
|
@@ -4787,6 +4943,14 @@ function SettingsPage() {
|
|
|
4787
4943
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: key, value: field(form[key]), onChange: (e) => set(key, e.target.value), disabled: !canWrite })
|
|
4788
4944
|
] }, key))
|
|
4789
4945
|
] }) }),
|
|
4946
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4947
|
+
FollowupWebhookCard,
|
|
4948
|
+
{
|
|
4949
|
+
scopeTag: field(form.webhookScopeTag),
|
|
4950
|
+
onScopeTagChange: (value) => set("webhookScopeTag", value),
|
|
4951
|
+
canWrite
|
|
4952
|
+
}
|
|
4953
|
+
),
|
|
4790
4954
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { id: "guardrails", children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-3 p-4", children: [
|
|
4791
4955
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-medium", children: "Garde-fous" }),
|
|
4792
4956
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
@@ -4803,7 +4967,7 @@ function SettingsPage() {
|
|
|
4803
4967
|
)) })
|
|
4804
4968
|
] }),
|
|
4805
4969
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4806
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "blocklist", className: "mb-1 block text-sm font-medium", children: "Liste de blocage" }),
|
|
4970
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "blocklist", className: "mb-1 block text-sm font-medium", children: "Liste de blocage (un par ligne ou s\xE9par\xE9s par des virgules)" }),
|
|
4807
4971
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4808
4972
|
uiSdk.Textarea,
|
|
4809
4973
|
{
|
|
@@ -4815,7 +4979,7 @@ function SettingsPage() {
|
|
|
4815
4979
|
)
|
|
4816
4980
|
] }),
|
|
4817
4981
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4818
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "noreplySenders", className: "mb-1 block text-sm font-medium", children: "Exp\xE9diteurs no-reply (s\xE9par\xE9s par des virgules)" }),
|
|
4982
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "noreplySenders", className: "mb-1 block text-sm font-medium", children: "Exp\xE9diteurs no-reply (un par ligne ou s\xE9par\xE9s par des virgules)" }),
|
|
4819
4983
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4820
4984
|
uiSdk.Textarea,
|
|
4821
4985
|
{
|
|
@@ -6539,6 +6703,116 @@ function DryRunResultView({ result, langfuseConfig, knownTags, tagSettings }) {
|
|
|
6539
6703
|
] })
|
|
6540
6704
|
] });
|
|
6541
6705
|
}
|
|
6706
|
+
var STATUS_BADGE = {
|
|
6707
|
+
passed: { label: "OK", variant: "success" },
|
|
6708
|
+
stopped: { label: "Arr\xEAt", variant: "danger" },
|
|
6709
|
+
// A pre-gate that could not read its field. Never shown by the diagnostic
|
|
6710
|
+
// (it evaluates no payload) but rendered honestly if it ever appears, rather
|
|
6711
|
+
// than falling through to a blank badge.
|
|
6712
|
+
muted: { label: "Muet", variant: "warning" },
|
|
6713
|
+
skipped: { label: "Non \xE9valu\xE9", variant: "neutral" }
|
|
6714
|
+
};
|
|
6715
|
+
function FollowupWebhookCard2() {
|
|
6716
|
+
const api = uiSdk.useAppApi();
|
|
6717
|
+
const toast = uiSdk.useToast();
|
|
6718
|
+
const ticketId = react.useId();
|
|
6719
|
+
const [ticket, setTicket] = react.useState("");
|
|
6720
|
+
const [test, setTest] = react.useState(null);
|
|
6721
|
+
const [isTesting, setIsTesting] = react.useState(false);
|
|
6722
|
+
const [confirmingRealRun, setConfirmingRealRun] = react.useState(false);
|
|
6723
|
+
async function runTest(mode) {
|
|
6724
|
+
setIsTesting(true);
|
|
6725
|
+
setTest(null);
|
|
6726
|
+
try {
|
|
6727
|
+
setTest(await api.invoke("test-gorgias-webhook", { ticketId: ticket.trim(), mode }));
|
|
6728
|
+
} catch (err) {
|
|
6729
|
+
toast({ title: "\xC9chec du test", description: describeInvokeError(err), variant: "error" });
|
|
6730
|
+
} finally {
|
|
6731
|
+
setIsTesting(false);
|
|
6732
|
+
setConfirmingRealRun(false);
|
|
6733
|
+
}
|
|
6734
|
+
}
|
|
6735
|
+
const disabled = !ticket.trim() || isTesting;
|
|
6736
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { id: "webhook-suite", children: [
|
|
6737
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-3 p-4", children: [
|
|
6738
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
6739
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-medium", children: "R\xE9ponses aux messages suivants" }),
|
|
6740
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Rejoue sur un ticket r\xE9el ce que ferait le webhook Gorgias quand un client r\xE9pond sur un ticket d\xE9j\xE0 trait\xE9. Le tag de p\xE9rim\xE8tre et les cat\xE9gories se r\xE8glent dans Param\xE8tres." })
|
|
6741
|
+
] }),
|
|
6742
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 border-t pt-3", children: [
|
|
6743
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ticketId, className: "block text-sm font-medium", children: "Ticket \xE0 tester" }),
|
|
6744
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
6745
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6746
|
+
uiSdk.Input,
|
|
6747
|
+
{
|
|
6748
|
+
id: ticketId,
|
|
6749
|
+
value: ticket,
|
|
6750
|
+
onChange: (e) => setTicket(e.target.value),
|
|
6751
|
+
placeholder: "1534712154",
|
|
6752
|
+
className: "max-w-48"
|
|
6753
|
+
}
|
|
6754
|
+
),
|
|
6755
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "button", variant: "outline", onClick: () => void runTest("diagnostic"), disabled, children: "Diagnostic" }),
|
|
6756
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "button", variant: "outline", onClick: () => void runTest("generate"), disabled, children: "G\xE9n\xE9rer sans envoyer" }),
|
|
6757
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "button", variant: "outline", onClick: () => setConfirmingRealRun(true), disabled, children: "Ex\xE9cution r\xE9elle" })
|
|
6758
|
+
] }),
|
|
6759
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
6760
|
+
"Le diagnostic \xE9value les m\xEAmes conditions que le webhook, sans aucun effet de bord.",
|
|
6761
|
+
" ",
|
|
6762
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "G\xE9n\xE9rer sans envoyer" }),
|
|
6763
|
+
" produit la r\xE9ponse compl\xE8te \u2014 m\xEAme si la cat\xE9gorie n'a pas activ\xE9 les r\xE9ponses aux messages suivants \u2014 et ne l'envoie jamais ; elle se lit dans la fiche du ticket. L'ex\xE9cution r\xE9elle d\xE9clenche le vrai traitement."
|
|
6764
|
+
] }),
|
|
6765
|
+
isTesting && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
6766
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Spinner, {}),
|
|
6767
|
+
" Test en cours\u2026"
|
|
6768
|
+
] }),
|
|
6769
|
+
test?.mode === "generate" && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm", children: [
|
|
6770
|
+
"G\xE9n\xE9ration d\xE9clench\xE9e, sans envoi. Run \xE0 suivre : ",
|
|
6771
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { children: test.runId }),
|
|
6772
|
+
"."
|
|
6773
|
+
] }),
|
|
6774
|
+
test?.mode === "run" && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm", children: [
|
|
6775
|
+
"Traitement d\xE9clench\xE9. Run \xE0 suivre : ",
|
|
6776
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { children: test.runId }),
|
|
6777
|
+
"."
|
|
6778
|
+
] }),
|
|
6779
|
+
test?.mode === "diagnostic" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
6780
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: test.stoppedAt === null ? `Ticket ${test.ticketId} : il aurait re\xE7u une r\xE9ponse de suite.` : `Ticket ${test.ticketId} : arr\xEAt en ${test.stoppedAt}.` }),
|
|
6781
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-1", children: test.gates.map((gate) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-start gap-2 text-xs", children: [
|
|
6782
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: STATUS_BADGE[gate.status].variant, children: STATUS_BADGE[gate.status].label }),
|
|
6783
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
6784
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
|
|
6785
|
+
gate.gate,
|
|
6786
|
+
" \u2014 ",
|
|
6787
|
+
gate.label
|
|
6788
|
+
] }),
|
|
6789
|
+
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
6790
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: gate.detail })
|
|
6791
|
+
] })
|
|
6792
|
+
] }, gate.gate)) })
|
|
6793
|
+
] })
|
|
6794
|
+
] })
|
|
6795
|
+
] }),
|
|
6796
|
+
confirmingRealRun && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6797
|
+
ConfirmModal,
|
|
6798
|
+
{
|
|
6799
|
+
title: "Lancer le traitement r\xE9el ?",
|
|
6800
|
+
description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6801
|
+
"Le ticket ",
|
|
6802
|
+
ticket.trim(),
|
|
6803
|
+
" va \xEAtre trait\xE9 comme un vrai message suivant : g\xE9n\xE9ration, garde-fous, et",
|
|
6804
|
+
" ",
|
|
6805
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "envoi r\xE9el au client" }),
|
|
6806
|
+
" si sa cat\xE9gorie est en r\xE9ponse automatique. Pour tout voir sans rien envoyer, utilisez \xAB G\xE9n\xE9rer sans envoyer \xBB."
|
|
6807
|
+
] }),
|
|
6808
|
+
confirmLabel: "Lancer",
|
|
6809
|
+
busyLabel: "D\xE9clenchement\u2026",
|
|
6810
|
+
onConfirm: () => runTest("run"),
|
|
6811
|
+
onCancel: () => setConfirmingRealRun(false)
|
|
6812
|
+
}
|
|
6813
|
+
)
|
|
6814
|
+
] });
|
|
6815
|
+
}
|
|
6542
6816
|
var TRI_STATE_OPTIONS = [
|
|
6543
6817
|
{ value: "", label: "R\xE9glages actuels" },
|
|
6544
6818
|
{ value: "on", label: "Forcer actif" },
|
|
@@ -6726,9 +7000,11 @@ function TestControls() {
|
|
|
6726
7000
|
function TestPage() {
|
|
6727
7001
|
const { role } = uiSdk.useAppContext();
|
|
6728
7002
|
const canRun = canWriteForRole(role);
|
|
7003
|
+
const canTestFollowup = role === "ADMIN";
|
|
6729
7004
|
return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
|
|
6730
7005
|
/* @__PURE__ */ jsxRuntime.jsx(PageHeader, { title: "Banc de test", description: "Rejoue le graphe sans jamais agir sur un vrai ticket (\xA70)." }),
|
|
6731
|
-
!canRun ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Acc\xE8s en lecture seule \u2014 lancer un test n\xE9cessite le r\xF4le EDITOR (chaque ex\xE9cution consomme du budget LLM)." }) : /* @__PURE__ */ jsxRuntime.jsx(TestControls, {})
|
|
7006
|
+
!canRun ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Acc\xE8s en lecture seule \u2014 lancer un test n\xE9cessite le r\xF4le EDITOR (chaque ex\xE9cution consomme du budget LLM)." }) : /* @__PURE__ */ jsxRuntime.jsx(TestControls, {}),
|
|
7007
|
+
canTestFollowup && /* @__PURE__ */ jsxRuntime.jsx(FollowupWebhookCard2, {})
|
|
6732
7008
|
] });
|
|
6733
7009
|
}
|
|
6734
7010
|
function ExperimentStatusBadge({ experiment }) {
|