@burdenoff/microfe-botmanor 2026.813.1
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 +12 -0
- package/dist/botlit/BotlitRoutes.js +357 -0
- package/dist/botlit/BotlitRoutes.js.map +1 -0
- package/dist/botlit/BotmanorRoot.js +12 -0
- package/dist/botlit/BotmanorRoot.js.map +1 -0
- package/dist/botlit/BotmanorRootInner.js +101 -0
- package/dist/botlit/BotmanorRootInner.js.map +1 -0
- package/dist/botlit/components/Badge.js +39 -0
- package/dist/botlit/components/Badge.js.map +1 -0
- package/dist/botlit/components/Button.js +46 -0
- package/dist/botlit/components/Button.js.map +1 -0
- package/dist/botlit/components/Card.js +31 -0
- package/dist/botlit/components/Card.js.map +1 -0
- package/dist/botlit/components/ChannelSelectorSheet.js +130 -0
- package/dist/botlit/components/ChannelSelectorSheet.js.map +1 -0
- package/dist/botlit/components/EmptyState.js +35 -0
- package/dist/botlit/components/EmptyState.js.map +1 -0
- package/dist/botlit/components/ErrorState.js +33 -0
- package/dist/botlit/components/ErrorState.js.map +1 -0
- package/dist/botlit/components/Input.js +59 -0
- package/dist/botlit/components/Input.js.map +1 -0
- package/dist/botlit/components/PageLayout.js +34 -0
- package/dist/botlit/components/PageLayout.js.map +1 -0
- package/dist/botlit/components/QuotaExhaustedDialog.js +20 -0
- package/dist/botlit/components/QuotaExhaustedDialog.js.map +1 -0
- package/dist/botlit/components/RouteLoader.js +52 -0
- package/dist/botlit/components/RouteLoader.js.map +1 -0
- package/dist/botlit/components/VersionHistoryPanel.js +144 -0
- package/dist/botlit/components/VersionHistoryPanel.js.map +1 -0
- package/dist/botlit/components/WorkspaceRequired.js +70 -0
- package/dist/botlit/components/WorkspaceRequired.js.map +1 -0
- package/dist/botlit/hooks/index.js +16 -0
- package/dist/botlit/hooks/internal/mutationInput.js +16 -0
- package/dist/botlit/hooks/internal/mutationInput.js.map +1 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +99 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -0
- package/dist/botlit/hooks/useA2A.js +184 -0
- package/dist/botlit/hooks/useA2A.js.map +1 -0
- package/dist/botlit/hooks/useAgents.js +469 -0
- package/dist/botlit/hooks/useAgents.js.map +1 -0
- package/dist/botlit/hooks/useBots.js +306 -0
- package/dist/botlit/hooks/useBots.js.map +1 -0
- package/dist/botlit/hooks/useBuckets.js +119 -0
- package/dist/botlit/hooks/useBuckets.js.map +1 -0
- package/dist/botlit/hooks/useChannels.js +213 -0
- package/dist/botlit/hooks/useChannels.js.map +1 -0
- package/dist/botlit/hooks/useConversations.js +64 -0
- package/dist/botlit/hooks/useConversations.js.map +1 -0
- package/dist/botlit/hooks/useExecutions.js +86 -0
- package/dist/botlit/hooks/useExecutions.js.map +1 -0
- package/dist/botlit/hooks/useKnowledgeBases.js +113 -0
- package/dist/botlit/hooks/useKnowledgeBases.js.map +1 -0
- package/dist/botlit/hooks/useLLMProviders.js +83 -0
- package/dist/botlit/hooks/useLLMProviders.js.map +1 -0
- package/dist/botlit/hooks/useMCPServers.js +134 -0
- package/dist/botlit/hooks/useMCPServers.js.map +1 -0
- package/dist/botlit/hooks/usePolicies.js +120 -0
- package/dist/botlit/hooks/usePolicies.js.map +1 -0
- package/dist/botlit/hooks/usePromptTemplates.js +161 -0
- package/dist/botlit/hooks/usePromptTemplates.js.map +1 -0
- package/dist/botlit/hooks/useRetrievalProfiles.js +146 -0
- package/dist/botlit/hooks/useRetrievalProfiles.js.map +1 -0
- package/dist/botlit/hooks/useSkills.js +132 -0
- package/dist/botlit/hooks/useSkills.js.map +1 -0
- package/dist/botlit/hooks/useStore.js +167 -0
- package/dist/botlit/hooks/useStore.js.map +1 -0
- package/dist/botlit/hooks/useUserPlatformConnection.js +172 -0
- package/dist/botlit/hooks/useUserPlatformConnection.js.map +1 -0
- package/dist/botlit/index.js +11 -0
- package/dist/botlit/pages/A2AAgentDetailPage.js +589 -0
- package/dist/botlit/pages/A2AAgentDetailPage.js.map +1 -0
- package/dist/botlit/pages/A2ARegistryPage.js +240 -0
- package/dist/botlit/pages/A2ARegistryPage.js.map +1 -0
- package/dist/botlit/pages/AgentBuilderPage.js +486 -0
- package/dist/botlit/pages/AgentBuilderPage.js.map +1 -0
- package/dist/botlit/pages/AgentDetailPage.js +517 -0
- package/dist/botlit/pages/AgentDetailPage.js.map +1 -0
- package/dist/botlit/pages/AgentsListPage.js +294 -0
- package/dist/botlit/pages/AgentsListPage.js.map +1 -0
- package/dist/botlit/pages/BotChannelsTab.js +530 -0
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -0
- package/dist/botlit/pages/BotDetailPage.js +872 -0
- package/dist/botlit/pages/BotDetailPage.js.map +1 -0
- package/dist/botlit/pages/BotWorkflowTab.js +229 -0
- package/dist/botlit/pages/BotWorkflowTab.js.map +1 -0
- package/dist/botlit/pages/BotsListPage.js +313 -0
- package/dist/botlit/pages/BotsListPage.js.map +1 -0
- package/dist/botlit/pages/BucketsPage.js +604 -0
- package/dist/botlit/pages/BucketsPage.js.map +1 -0
- package/dist/botlit/pages/ChannelDetailPage.js +955 -0
- package/dist/botlit/pages/ChannelDetailPage.js.map +1 -0
- package/dist/botlit/pages/ChannelRoutesPage.js +218 -0
- package/dist/botlit/pages/ChannelRoutesPage.js.map +1 -0
- package/dist/botlit/pages/ChannelsPage.js +304 -0
- package/dist/botlit/pages/ChannelsPage.js.map +1 -0
- package/dist/botlit/pages/ChatPage.js +247 -0
- package/dist/botlit/pages/ChatPage.js.map +1 -0
- package/dist/botlit/pages/DashboardPage.js +318 -0
- package/dist/botlit/pages/DashboardPage.js.map +1 -0
- package/dist/botlit/pages/ExecutionDetailPage.js +313 -0
- package/dist/botlit/pages/ExecutionDetailPage.js.map +1 -0
- package/dist/botlit/pages/ExecutionsPage.js +294 -0
- package/dist/botlit/pages/ExecutionsPage.js.map +1 -0
- package/dist/botlit/pages/InstalledPackagesPage.js +619 -0
- package/dist/botlit/pages/InstalledPackagesPage.js.map +1 -0
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js +473 -0
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js.map +1 -0
- package/dist/botlit/pages/KnowledgeBasesPage.js +150 -0
- package/dist/botlit/pages/KnowledgeBasesPage.js.map +1 -0
- package/dist/botlit/pages/MCPServerDetailPage.js +550 -0
- package/dist/botlit/pages/MCPServerDetailPage.js.map +1 -0
- package/dist/botlit/pages/MCPServersPage.js +321 -0
- package/dist/botlit/pages/MCPServersPage.js.map +1 -0
- package/dist/botlit/pages/PoliciesPage.js +224 -0
- package/dist/botlit/pages/PoliciesPage.js.map +1 -0
- package/dist/botlit/pages/PolicyDetailPage.js +861 -0
- package/dist/botlit/pages/PolicyDetailPage.js.map +1 -0
- package/dist/botlit/pages/PromptStudioPage.js +236 -0
- package/dist/botlit/pages/PromptStudioPage.js.map +1 -0
- package/dist/botlit/pages/PromptTemplateDetailPage.js +812 -0
- package/dist/botlit/pages/PromptTemplateDetailPage.js.map +1 -0
- package/dist/botlit/pages/PromptTemplatesPage.js +269 -0
- package/dist/botlit/pages/PromptTemplatesPage.js.map +1 -0
- package/dist/botlit/pages/RetrievalProfileDetailPage.js +559 -0
- package/dist/botlit/pages/RetrievalProfileDetailPage.js.map +1 -0
- package/dist/botlit/pages/RetrievalProfilesPage.js +219 -0
- package/dist/botlit/pages/RetrievalProfilesPage.js.map +1 -0
- package/dist/botlit/pages/SettingsPage.js +655 -0
- package/dist/botlit/pages/SettingsPage.js.map +1 -0
- package/dist/botlit/pages/SkillDetailPage.js +778 -0
- package/dist/botlit/pages/SkillDetailPage.js.map +1 -0
- package/dist/botlit/pages/SkillsPage.js +206 -0
- package/dist/botlit/pages/SkillsPage.js.map +1 -0
- package/dist/botlit/pages/StorePackageDetailPage.js +462 -0
- package/dist/botlit/pages/StorePackageDetailPage.js.map +1 -0
- package/dist/botlit/pages/StorePage.js +315 -0
- package/dist/botlit/pages/StorePage.js.map +1 -0
- package/dist/botlit/providers/BotlitProvider.js +93 -0
- package/dist/botlit/providers/BotlitProvider.js.map +1 -0
- package/dist/botlit/store/botlitStore.js +101 -0
- package/dist/botlit/store/botlitStore.js.map +1 -0
- package/dist/botlit/utils/cn.js +10 -0
- package/dist/botlit/utils/cn.js.map +1 -0
- package/dist/botlit/utils/formatters.js +37 -0
- package/dist/botlit/utils/formatters.js.map +1 -0
- package/dist/botlit/utils/navigation.js +9 -0
- package/dist/botlit/utils/navigation.js.map +1 -0
- package/dist/botlit/utils/unions.js +14 -0
- package/dist/botlit/utils/unions.js.map +1 -0
- package/dist/generated/global-operations.js +66 -0
- package/dist/generated/global-operations.js.map +1 -0
- package/dist/generated/global-types.js +8 -0
- package/dist/generated/global-types.js.map +1 -0
- package/dist/generated/wspace-operations.js +1591 -0
- package/dist/generated/wspace-operations.js.map +1 -0
- package/dist/generated/wspace-types.js +12 -0
- package/dist/generated/wspace-types.js.map +1 -0
- package/dist/index.js +13 -0
- package/dist/utils/nativeBridge.js +2 -0
- package/package.json +133 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { useBotlit as e } from "../providers/BotlitProvider.js";
|
|
2
|
+
import { buildMutationInput as t, fieldsOf as n } from "./internal/mutationInput.js";
|
|
3
|
+
import { useCallback as r, useEffect as i, useMemo as a, useState as o } from "react";
|
|
4
|
+
import { gql as s } from "@apollo/client";
|
|
5
|
+
import { useGatewayClient as c } from "@burdenoff/fe-libs/shared/graphql";
|
|
6
|
+
//#region src/botlit/hooks/useBots.ts
|
|
7
|
+
var l = s`
|
|
8
|
+
query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {
|
|
9
|
+
listBotApps(filters: $filters, pagination: $pagination) {
|
|
10
|
+
id
|
|
11
|
+
name
|
|
12
|
+
slug
|
|
13
|
+
description
|
|
14
|
+
icon
|
|
15
|
+
type
|
|
16
|
+
status
|
|
17
|
+
visibility
|
|
18
|
+
routingStrategy
|
|
19
|
+
defaultAgentId
|
|
20
|
+
welcomeMessage
|
|
21
|
+
fallbackMessage
|
|
22
|
+
workflowId
|
|
23
|
+
executionCount
|
|
24
|
+
lastExecutedAt
|
|
25
|
+
tagIds
|
|
26
|
+
createdAt
|
|
27
|
+
updatedAt
|
|
28
|
+
createdById
|
|
29
|
+
updatedById
|
|
30
|
+
workspaceId
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`, u = s`
|
|
34
|
+
query GetBotApp($id: ID!) {
|
|
35
|
+
getBotApp(id: $id) {
|
|
36
|
+
id
|
|
37
|
+
name
|
|
38
|
+
slug
|
|
39
|
+
description
|
|
40
|
+
icon
|
|
41
|
+
type
|
|
42
|
+
status
|
|
43
|
+
visibility
|
|
44
|
+
routingStrategy
|
|
45
|
+
defaultAgentId
|
|
46
|
+
welcomeMessage
|
|
47
|
+
fallbackMessage
|
|
48
|
+
workflowId
|
|
49
|
+
executionCount
|
|
50
|
+
lastExecutedAt
|
|
51
|
+
tagIds
|
|
52
|
+
createdAt
|
|
53
|
+
updatedAt
|
|
54
|
+
createdById
|
|
55
|
+
updatedById
|
|
56
|
+
workspaceId
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`, d = s`
|
|
60
|
+
mutation CreateBotApp($input: CreateBotAppInput!) {
|
|
61
|
+
createBotApp(input: $input) {
|
|
62
|
+
id
|
|
63
|
+
name
|
|
64
|
+
slug
|
|
65
|
+
description
|
|
66
|
+
icon
|
|
67
|
+
type
|
|
68
|
+
status
|
|
69
|
+
visibility
|
|
70
|
+
routingStrategy
|
|
71
|
+
defaultAgentId
|
|
72
|
+
workflowId
|
|
73
|
+
tagIds
|
|
74
|
+
createdAt
|
|
75
|
+
updatedAt
|
|
76
|
+
workspaceId
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`, f = s`
|
|
80
|
+
mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {
|
|
81
|
+
updateBotApp(id: $id, input: $input) {
|
|
82
|
+
id
|
|
83
|
+
name
|
|
84
|
+
slug
|
|
85
|
+
description
|
|
86
|
+
icon
|
|
87
|
+
type
|
|
88
|
+
status
|
|
89
|
+
visibility
|
|
90
|
+
routingStrategy
|
|
91
|
+
defaultAgentId
|
|
92
|
+
welcomeMessage
|
|
93
|
+
fallbackMessage
|
|
94
|
+
workflowId
|
|
95
|
+
tagIds
|
|
96
|
+
updatedAt
|
|
97
|
+
updatedById
|
|
98
|
+
workspaceId
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
`, p = s`
|
|
102
|
+
mutation DeleteBotApp($id: ID!) {
|
|
103
|
+
deleteBotApp(id: $id)
|
|
104
|
+
}
|
|
105
|
+
`, m = n({
|
|
106
|
+
bucketId: !0,
|
|
107
|
+
context: !0,
|
|
108
|
+
defaultAgentId: !0,
|
|
109
|
+
description: !0,
|
|
110
|
+
fallbackMessage: !0,
|
|
111
|
+
icon: !0,
|
|
112
|
+
metadata: !0,
|
|
113
|
+
name: !0,
|
|
114
|
+
routingStrategy: !0,
|
|
115
|
+
slug: !0,
|
|
116
|
+
status: !0,
|
|
117
|
+
tagIds: !0,
|
|
118
|
+
tags: !0,
|
|
119
|
+
type: !0,
|
|
120
|
+
visibility: !0,
|
|
121
|
+
welcomeMessage: !0,
|
|
122
|
+
workflowId: !0
|
|
123
|
+
});
|
|
124
|
+
function h(e) {
|
|
125
|
+
return e;
|
|
126
|
+
}
|
|
127
|
+
function g(e, t) {
|
|
128
|
+
if (!(!e && !t)) return {
|
|
129
|
+
workspaceId: e,
|
|
130
|
+
search: t?.search,
|
|
131
|
+
status: t?.status?.[0],
|
|
132
|
+
visibility: t?.visibility?.[0],
|
|
133
|
+
bucketId: t?.bucketId
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function _(t) {
|
|
137
|
+
let n = h(c("workspace")), { workspaceId: s } = e(), [u, d] = o([]), [f, p] = o(!1), [m, _] = o(), v = a(() => ({
|
|
138
|
+
filters: g(s, t),
|
|
139
|
+
pagination: {
|
|
140
|
+
limit: 100,
|
|
141
|
+
offset: 0
|
|
142
|
+
}
|
|
143
|
+
}), [t, s]), y = r(async () => {
|
|
144
|
+
if (!s) {
|
|
145
|
+
d([]);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
p(!0), _(void 0);
|
|
149
|
+
try {
|
|
150
|
+
d((await n.query({
|
|
151
|
+
query: l,
|
|
152
|
+
variables: v,
|
|
153
|
+
fetchPolicy: "network-only"
|
|
154
|
+
})).data?.listBotApps ?? []);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
_(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load bots"));
|
|
157
|
+
} finally {
|
|
158
|
+
p(!1);
|
|
159
|
+
}
|
|
160
|
+
}, [
|
|
161
|
+
n,
|
|
162
|
+
v,
|
|
163
|
+
s
|
|
164
|
+
]);
|
|
165
|
+
return i(() => {
|
|
166
|
+
y();
|
|
167
|
+
}, [y]), {
|
|
168
|
+
data: u,
|
|
169
|
+
loading: f,
|
|
170
|
+
error: m,
|
|
171
|
+
refetch: y
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function v(e) {
|
|
175
|
+
let t = h(c("workspace")), [n, a] = o(null), [s, l] = o(!1), [d, f] = o(), p = r(async () => {
|
|
176
|
+
if (!e) {
|
|
177
|
+
a(null);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
l(!0), f(void 0);
|
|
181
|
+
try {
|
|
182
|
+
a((await t.query({
|
|
183
|
+
query: u,
|
|
184
|
+
variables: { id: e },
|
|
185
|
+
fetchPolicy: "network-only"
|
|
186
|
+
})).data?.getBotApp ?? null);
|
|
187
|
+
} catch (e) {
|
|
188
|
+
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load bot"));
|
|
189
|
+
} finally {
|
|
190
|
+
l(!1);
|
|
191
|
+
}
|
|
192
|
+
}, [e, t]);
|
|
193
|
+
return i(() => {
|
|
194
|
+
p();
|
|
195
|
+
}, [p]), {
|
|
196
|
+
data: n,
|
|
197
|
+
loading: s,
|
|
198
|
+
error: d,
|
|
199
|
+
refetch: p
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function y() {
|
|
203
|
+
let e = h(c("workspace")), [t, n] = o({
|
|
204
|
+
data: void 0,
|
|
205
|
+
loading: !1,
|
|
206
|
+
error: void 0
|
|
207
|
+
});
|
|
208
|
+
return [r(async (t) => {
|
|
209
|
+
n({
|
|
210
|
+
data: void 0,
|
|
211
|
+
loading: !0,
|
|
212
|
+
error: void 0
|
|
213
|
+
});
|
|
214
|
+
try {
|
|
215
|
+
let r = (await e.mutate({
|
|
216
|
+
mutation: d,
|
|
217
|
+
variables: { input: t }
|
|
218
|
+
})).data?.createBotApp;
|
|
219
|
+
if (!r) throw Error("Failed to create bot");
|
|
220
|
+
return n({
|
|
221
|
+
data: r,
|
|
222
|
+
loading: !1,
|
|
223
|
+
error: void 0
|
|
224
|
+
}), r;
|
|
225
|
+
} catch (e) {
|
|
226
|
+
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Failed to create bot");
|
|
227
|
+
throw n({
|
|
228
|
+
data: void 0,
|
|
229
|
+
loading: !1,
|
|
230
|
+
error: t
|
|
231
|
+
}), t;
|
|
232
|
+
}
|
|
233
|
+
}, [e]), t];
|
|
234
|
+
}
|
|
235
|
+
function b() {
|
|
236
|
+
let e = h(c("workspace")), [n, i] = o({
|
|
237
|
+
data: void 0,
|
|
238
|
+
loading: !1,
|
|
239
|
+
error: void 0
|
|
240
|
+
});
|
|
241
|
+
return [r(async ({ botId: n, input: r }) => {
|
|
242
|
+
i({
|
|
243
|
+
data: void 0,
|
|
244
|
+
loading: !0,
|
|
245
|
+
error: void 0
|
|
246
|
+
});
|
|
247
|
+
try {
|
|
248
|
+
let a = (await e.mutate({
|
|
249
|
+
mutation: f,
|
|
250
|
+
variables: {
|
|
251
|
+
id: n,
|
|
252
|
+
input: t(r, m)
|
|
253
|
+
}
|
|
254
|
+
})).data?.updateBotApp;
|
|
255
|
+
if (!a) throw Error("Failed to update bot");
|
|
256
|
+
return i({
|
|
257
|
+
data: a,
|
|
258
|
+
loading: !1,
|
|
259
|
+
error: void 0
|
|
260
|
+
}), a;
|
|
261
|
+
} catch (e) {
|
|
262
|
+
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Failed to update bot");
|
|
263
|
+
throw i({
|
|
264
|
+
data: void 0,
|
|
265
|
+
loading: !1,
|
|
266
|
+
error: t
|
|
267
|
+
}), t;
|
|
268
|
+
}
|
|
269
|
+
}, [e]), n];
|
|
270
|
+
}
|
|
271
|
+
function x() {
|
|
272
|
+
let e = h(c("workspace")), [t, n] = o({
|
|
273
|
+
data: void 0,
|
|
274
|
+
loading: !1,
|
|
275
|
+
error: void 0
|
|
276
|
+
});
|
|
277
|
+
return [r(async (t) => {
|
|
278
|
+
n({
|
|
279
|
+
data: void 0,
|
|
280
|
+
loading: !0,
|
|
281
|
+
error: void 0
|
|
282
|
+
});
|
|
283
|
+
try {
|
|
284
|
+
let r = (await e.mutate({
|
|
285
|
+
mutation: p,
|
|
286
|
+
variables: { id: t }
|
|
287
|
+
})).data?.deleteBotApp ?? !1;
|
|
288
|
+
return n({
|
|
289
|
+
data: r,
|
|
290
|
+
loading: !1,
|
|
291
|
+
error: void 0
|
|
292
|
+
}), r;
|
|
293
|
+
} catch (e) {
|
|
294
|
+
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Failed to delete bot");
|
|
295
|
+
throw n({
|
|
296
|
+
data: void 0,
|
|
297
|
+
loading: !1,
|
|
298
|
+
error: t
|
|
299
|
+
}), t;
|
|
300
|
+
}
|
|
301
|
+
}, [e]), t];
|
|
302
|
+
}
|
|
303
|
+
//#endregion
|
|
304
|
+
export { v as useBot, _ as useBots, y as useCreateBot, x as useDeleteBot, b as useUpdateBot };
|
|
305
|
+
|
|
306
|
+
//# sourceMappingURL=useBots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBots.js","names":[],"sources":["../../../src/botlit/hooks/useBots.ts"],"sourcesContent":["import { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport type { UpdateBotAppInput } from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\n\nconst LIST_BOT_APPS_DOCUMENT = gql`\n query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {\n listBotApps(filters: $filters, pagination: $pagination) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst GET_BOT_APP_DOCUMENT = gql`\n query GetBotApp($id: ID!) {\n getBotApp(id: $id) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst CREATE_BOT_APP_DOCUMENT = gql`\n mutation CreateBotApp($input: CreateBotAppInput!) {\n createBotApp(input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n workflowId\n tagIds\n createdAt\n updatedAt\n workspaceId\n }\n }\n`;\n\nconst UPDATE_BOT_APP_DOCUMENT = gql`\n mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {\n updateBotApp(id: $id, input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n tagIds\n updatedAt\n updatedById\n workspaceId\n }\n }\n`;\n\nconst DELETE_BOT_APP_DOCUMENT = gql`\n mutation DeleteBotApp($id: ID!) {\n deleteBotApp(id: $id)\n }\n`;\n\ntype WorkspaceClient = ApolloClient;\n\nexport interface BotAppRecord {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n icon?: string | null;\n type: string;\n status: string;\n visibility?: string | null;\n routingStrategy?: string | null;\n defaultAgentId?: string | null;\n welcomeMessage?: string | null;\n fallbackMessage?: string | null;\n /** Bound FluidGrids workflow definition id — the bot's designed behaviour. */\n workflowId?: string | null;\n executionCount?: number | null;\n lastExecutedAt?: string | null;\n tagIds?: string[] | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n createdById?: string | null;\n updatedById?: string | null;\n workspaceId?: string | null;\n}\n\ninterface ListBotAppsData {\n listBotApps: BotAppRecord[];\n}\n\ninterface GetBotAppData {\n getBotApp: BotAppRecord | null;\n}\n\ninterface CreateBotAppData {\n createBotApp: BotAppRecord;\n}\n\ninterface UpdateBotAppData {\n updateBotApp: BotAppRecord;\n}\n\ninterface DeleteBotAppData {\n deleteBotApp: boolean;\n}\n\ninterface BotMutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\ninterface CreateBotInput {\n workspaceId: string;\n name: string;\n slug?: string;\n type: string;\n routingStrategy?: string;\n description?: string;\n icon?: string;\n}\n\ninterface UpdateBotInput {\n botId: string;\n input: GraphQLInput<UpdateBotAppInput>;\n}\n\nconst UPDATE_BOT_APP_FIELDS = fieldsOf<UpdateBotAppInput>({\n bucketId: true,\n context: true,\n defaultAgentId: true,\n description: true,\n fallbackMessage: true,\n icon: true,\n metadata: true,\n name: true,\n routingStrategy: true,\n slug: true,\n status: true,\n tagIds: true,\n tags: true,\n type: true,\n visibility: true,\n welcomeMessage: true,\n workflowId: true,\n});\n\nfunction getWorkspaceClient(client: unknown): WorkspaceClient {\n return client as WorkspaceClient;\n}\n\nfunction buildBotFilter(\n workspaceId: string | undefined,\n filter?: BaseFilter\n): Record<string, unknown> | undefined {\n if (!workspaceId && !filter) return undefined;\n\n return {\n workspaceId,\n search: filter?.search,\n status: filter?.status?.[0],\n visibility: filter?.visibility?.[0],\n bucketId: filter?.bucketId,\n };\n}\n\nexport const botKeys = {\n all: ['bots'] as const,\n lists: () => [...botKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...botKeys.lists(), filter] as const,\n details: () => [...botKeys.all, 'detail'] as const,\n detail: (id: string) => [...botKeys.details(), id] as const,\n};\n\nexport function useBots(filter?: BaseFilter) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const { workspaceId } = useBotlit();\n const [data, setData] = useState<BotAppRecord[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const variables = useMemo(\n () => ({ filters: buildBotFilter(workspaceId, filter), pagination: { limit: 100, offset: 0 } }),\n [filter, workspaceId]\n );\n\n const refetch = useCallback(async () => {\n if (!workspaceId) {\n setData([]);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<ListBotAppsData>({\n query: LIST_BOT_APPS_DOCUMENT,\n variables,\n fetchPolicy: 'network-only',\n });\n setData(result.data?.listBotApps ?? []);\n } catch (queryError) {\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bots'));\n } finally {\n setLoading(false);\n }\n }, [client, variables, workspaceId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useBot(botId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<BotAppRecord | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!botId) {\n setData(null);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<GetBotAppData>({\n query: GET_BOT_APP_DOCUMENT,\n variables: { id: botId },\n fetchPolicy: 'network-only',\n });\n setData(result.data?.getBotApp ?? null);\n } catch (queryError) {\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bot'));\n } finally {\n setLoading(false);\n }\n }, [botId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useCreateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const createBot = useCallback(\n async (input: CreateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<CreateBotAppData>({\n mutation: CREATE_BOT_APP_DOCUMENT,\n variables: { input },\n });\n\n const createdBot = result.data?.createBotApp;\n if (!createdBot) {\n throw new Error('Failed to create bot');\n }\n\n setState({ data: createdBot, loading: false, error: undefined });\n return createdBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to create bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [createBot, state] as const;\n}\n\nexport function useUpdateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const updateBot = useCallback(\n async ({ botId, input }: UpdateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<UpdateBotAppData>({\n mutation: UPDATE_BOT_APP_DOCUMENT,\n variables: { id: botId, input: buildMutationInput(input, UPDATE_BOT_APP_FIELDS) },\n });\n\n const updatedBot = result.data?.updateBotApp;\n if (!updatedBot) {\n throw new Error('Failed to update bot');\n }\n\n setState({ data: updatedBot, loading: false, error: undefined });\n return updatedBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to update bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [updateBot, state] as const;\n}\n\nexport function useDeleteBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<boolean>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const deleteBot = useCallback(\n async (botId: string) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<DeleteBotAppData>({\n mutation: DELETE_BOT_APP_DOCUMENT,\n variables: { id: botId },\n });\n\n const deleted = result.data?.deleteBotApp ?? false;\n setState({ data: deleted, loading: false, error: undefined });\n return deleted;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to delete bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [deleteBot, state] as const;\n}\n"],"mappings":";;;;;;AASA,IAAM,IAAyB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GA4B5B,IAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GA4B1B,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;GAsB7B,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;;GAwB7B,IAA0B,CAAG;;;;GA0E7B,IAAwB,EAA4B;CACxD,UAAU;CACV,SAAS;CACT,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,MAAM;CACN,UAAU;CACV,MAAM;CACN,iBAAiB;CACjB,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,MAAM;CACN,YAAY;CACZ,gBAAgB;CAChB,YAAY;CACb,CAAC;AAEF,SAAS,EAAmB,GAAkC;AAC5D,QAAO;;AAGT,SAAS,EACP,GACA,GACqC;AACjC,QAAC,KAAe,CAAC,GAErB,QAAO;EACL;EACA,QAAQ,GAAQ;EAChB,QAAQ,GAAQ,SAAS;EACzB,YAAY,GAAQ,aAAa;EACjC,UAAU,GAAQ;EACnB;;AAWH,SAAgB,EAAQ,GAAqB;CAC3C,IAAM,IAAS,EAAmB,EAAiB,YAAY,CAAC,EAC1D,EAAE,mBAAgB,GAAW,EAC7B,CAAC,GAAM,KAAW,EAAyB,EAAE,CAAC,EAC9C,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,CAAC,GAAO,KAAY,GAA6B,EAEjD,IAAY,SACT;EAAE,SAAS,EAAe,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J,aAAyB,QAAQ,IAAgB,gBAAI,MAAM,uBAAuB;AAEpF,SADA,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;IAAO,CAAC,EAC9C;;IAGV,CAAC,EAAO,CACT,EAEkB,EAAM;;AAG3B,SAAgB,IAAe;CAC7B,IAAM,IAAS,EAAmB,EAAiB,YAAY,CAAC,EAC1D,CAAC,GAAO,KAAY,EAAoC;EAC5D,MAAM,KAAA;EACN,SAAS;EACT,OAAO,KAAA;EACR,CAAC;AAwBF,QAAO,CAtBW,EAChB,OAAO,MAAkB;AACvB,IAAS;GAAE,MAAM,KAAA;GAAW,SAAS;GAAM,OAAO,KAAA;GAAW,CAAC;AAC9D,MAAI;GAMF,IAAM,KALS,MAAM,EAAO,OAAyB;IACnD,UAAU;IACV,WAAW,EAAE,IAAI,GAAO;IACzB,CAAC,EAEqB,MAAM,gBAAgB;AAE7C,UADA,EAAS;IAAE,MAAM;IAAS,SAAS;IAAO,OAAO,KAAA;IAAW,CAAC,EACtD;WACA,GAAe;GACtB,IAAM,IACJ,aAAyB,QAAQ,IAAgB,gBAAI,MAAM,uBAAuB;AAEpF,SADA,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;IAAO,CAAC,EAC9C;;IAGV,CAAC,EAAO,CACT,EAEkB,EAAM"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { buildMutationInput as e, fieldsOf as t } from "./internal/mutationInput.js";
|
|
2
|
+
import { CreateBucketDocument as n, DeleteBucketDocument as r, ListBucketsDocument as i, UpdateBucketDocument as a } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { useWorkspaceId as o, useWorkspaceMutation as s, useWorkspaceQuery as c } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as l, useMemo as u } from "react";
|
|
5
|
+
//#region src/botlit/hooks/useBuckets.ts
|
|
6
|
+
var d = 100, f = t({
|
|
7
|
+
color: !0,
|
|
8
|
+
context: !0,
|
|
9
|
+
description: !0,
|
|
10
|
+
icon: !0,
|
|
11
|
+
metadata: !0,
|
|
12
|
+
name: !0,
|
|
13
|
+
parentBucketId: !0,
|
|
14
|
+
slug: !0,
|
|
15
|
+
workspaceId: !0
|
|
16
|
+
}), p = t({
|
|
17
|
+
color: !0,
|
|
18
|
+
context: !0,
|
|
19
|
+
description: !0,
|
|
20
|
+
icon: !0,
|
|
21
|
+
metadata: !0,
|
|
22
|
+
name: !0,
|
|
23
|
+
parentBucketId: !0,
|
|
24
|
+
slug: !0
|
|
25
|
+
}), m = [], h = [];
|
|
26
|
+
function g(e) {
|
|
27
|
+
return e?.listBuckets ?? m;
|
|
28
|
+
}
|
|
29
|
+
function _(e) {
|
|
30
|
+
let t = /* @__PURE__ */ new Map();
|
|
31
|
+
for (let n of e) t.set(n.id, {
|
|
32
|
+
...n,
|
|
33
|
+
children: []
|
|
34
|
+
});
|
|
35
|
+
let n = [];
|
|
36
|
+
for (let r of e) {
|
|
37
|
+
let e = t.get(r.id);
|
|
38
|
+
if (!e) continue;
|
|
39
|
+
let i = r.parentBucketId ? t.get(r.parentBucketId) : void 0;
|
|
40
|
+
i && i !== e ? i.children.push(e) : n.push(e);
|
|
41
|
+
}
|
|
42
|
+
let r = (e, t) => e.name.localeCompare(t.name), i = (e) => {
|
|
43
|
+
e.sort(r);
|
|
44
|
+
for (let t of e) i(t.children);
|
|
45
|
+
};
|
|
46
|
+
return i(n), n;
|
|
47
|
+
}
|
|
48
|
+
function v(e) {
|
|
49
|
+
let t = o(), n = e?.search;
|
|
50
|
+
return c({
|
|
51
|
+
document: i,
|
|
52
|
+
variables: u(() => ({
|
|
53
|
+
filters: {
|
|
54
|
+
workspaceId: t,
|
|
55
|
+
search: n || void 0
|
|
56
|
+
},
|
|
57
|
+
pagination: {
|
|
58
|
+
limit: d,
|
|
59
|
+
offset: 0
|
|
60
|
+
}
|
|
61
|
+
}), [t, n]),
|
|
62
|
+
select: g,
|
|
63
|
+
fallback: m,
|
|
64
|
+
enabled: !!t,
|
|
65
|
+
errorMessage: "Failed to load buckets"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function y() {
|
|
69
|
+
let e = o();
|
|
70
|
+
return c({
|
|
71
|
+
document: i,
|
|
72
|
+
variables: u(() => ({
|
|
73
|
+
filters: { workspaceId: e },
|
|
74
|
+
pagination: {
|
|
75
|
+
limit: d,
|
|
76
|
+
offset: 0
|
|
77
|
+
}
|
|
78
|
+
}), [e]),
|
|
79
|
+
select: l((e) => _(e?.listBuckets ?? m), []),
|
|
80
|
+
fallback: h,
|
|
81
|
+
enabled: !!e,
|
|
82
|
+
errorMessage: "Failed to load the bucket tree"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function b() {
|
|
86
|
+
let t = o();
|
|
87
|
+
return s({
|
|
88
|
+
document: n,
|
|
89
|
+
variables: l((n) => ({ input: e({
|
|
90
|
+
...n,
|
|
91
|
+
workspaceId: t
|
|
92
|
+
}, f) }), [t]),
|
|
93
|
+
select: (e) => e?.createBucket,
|
|
94
|
+
errorMessage: "Failed to create bucket"
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function x() {
|
|
98
|
+
return s({
|
|
99
|
+
document: a,
|
|
100
|
+
variables: ({ bucketId: t, input: n }) => ({
|
|
101
|
+
id: t,
|
|
102
|
+
input: e(n, p)
|
|
103
|
+
}),
|
|
104
|
+
select: (e) => e?.updateBucket,
|
|
105
|
+
errorMessage: "Failed to update bucket"
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function S() {
|
|
109
|
+
return s({
|
|
110
|
+
document: r,
|
|
111
|
+
variables: (e) => ({ id: e }),
|
|
112
|
+
select: (e) => e?.deleteBucket,
|
|
113
|
+
errorMessage: "Failed to delete bucket"
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { _ as buildBucketTree, y as useBucketTree, v as useBuckets, b as useCreateBucket, S as useDeleteBucket, x as useUpdateBucket };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=useBuckets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBuckets.js","names":[],"sources":["../../../src/botlit/hooks/useBuckets.ts"],"sourcesContent":["/**\n * Buckets Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBuckets` / `getBucket` / `createBucket` / `updateBucket`\n * / `deleteBucket` operations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateBucketDocument,\n DeleteBucketDocument,\n GetBucketDocument,\n ListBucketsDocument,\n UpdateBucketDocument,\n type CreateBucketMutation,\n type DeleteBucketMutation,\n type GetBucketQuery,\n type ListBucketsQuery,\n type UpdateBucketMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateBucketInput, UpdateBucketInput } from '../../generated/wspace-types';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface BucketRecord {\n id: string;\n name: string;\n slug: string;\n path: string;\n description?: string | null;\n color?: string | null;\n icon?: string | null;\n parentBucketId?: string | null;\n metadata?: Record<string, unknown> | null;\n deletedAt?: string | null;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\n/** A bucket plus its resolved children — the shape the tree view renders. */\nexport interface BucketTreeNode extends BucketRecord {\n children: BucketTreeNode[];\n}\n\n/**\n * `CreateBucketInput` minus the `workspaceId`/`context` the hook supplies.\n */\nexport type CreateBucketVariables = Omit<\n GraphQLInput<CreateBucketInput>,\n 'workspaceId' | 'context'\n>;\n\nexport interface UpdateBucketVariables {\n bucketId: string;\n input: GraphQLInput<UpdateBucketInput>;\n}\n\nconst CREATE_BUCKET_FIELDS = fieldsOf<CreateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n workspaceId: true,\n});\n\nconst UPDATE_BUCKET_FIELDS = fieldsOf<UpdateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n});\n\nconst NO_BUCKETS: BucketRecord[] = [];\nconst NO_BUCKET_TREE: BucketTreeNode[] = [];\n\nfunction selectBuckets(data: ListBucketsQuery | undefined): BucketRecord[] {\n return data?.listBuckets ?? NO_BUCKETS;\n}\n\nfunction selectBucket(data: GetBucketQuery | undefined): BucketRecord | null {\n return data?.getBucket ?? null;\n}\n\n/**\n * Builds the parent → children tree. Buckets whose parent is not in the result\n * set (filtered out, or not readable) are surfaced at the root rather than\n * silently dropped.\n */\nexport function buildBucketTree(buckets: readonly BucketRecord[]): BucketTreeNode[] {\n const nodes = new Map<string, BucketTreeNode>();\n for (const bucket of buckets) {\n nodes.set(bucket.id, { ...bucket, children: [] });\n }\n\n const roots: BucketTreeNode[] = [];\n for (const bucket of buckets) {\n const node = nodes.get(bucket.id);\n if (!node) continue;\n const parent = bucket.parentBucketId ? nodes.get(bucket.parentBucketId) : undefined;\n if (parent && parent !== node) {\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n }\n\n const byName = (a: BucketTreeNode, b: BucketTreeNode) => a.name.localeCompare(b.name);\n const sortRecursively = (list: BucketTreeNode[]) => {\n list.sort(byName);\n for (const child of list) sortRecursively(child.children);\n };\n sortRecursively(roots);\n\n return roots;\n}\n\nexport const bucketKeys = {\n all: ['buckets'] as const,\n lists: () => [...bucketKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...bucketKeys.lists(), filter] as const,\n tree: () => [...bucketKeys.all, 'tree'] as const,\n details: () => [...bucketKeys.all, 'detail'] as const,\n detail: (id: string) => [...bucketKeys.details(), id] as const,\n};\n\nexport function useBuckets(filter?: BaseFilter): QueryResult<BucketRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search;\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, search: search || undefined },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search]\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketRecord[]>({\n document: ListBucketsDocument,\n variables,\n select: selectBuckets,\n fallback: NO_BUCKETS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load buckets',\n });\n}\n\n/**\n * The bucket hierarchy. Derived from `listBuckets` — the service exposes the\n * parent link on every bucket, so no separate tree operation is needed.\n */\nexport function useBucketTree(): QueryResult<BucketTreeNode[]> {\n const workspaceId = useWorkspaceId();\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId]\n );\n\n const select = useCallback(\n (data: ListBucketsQuery | undefined) => buildBucketTree(data?.listBuckets ?? NO_BUCKETS),\n []\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketTreeNode[]>({\n document: ListBucketsDocument,\n variables,\n select,\n fallback: NO_BUCKET_TREE,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load the bucket tree',\n });\n}\n\nexport function useBucket(bucketId: string | undefined): QueryResult<BucketRecord | null> {\n const variables = useMemo(() => ({ id: bucketId ?? '' }), [bucketId]);\n\n return useWorkspaceQuery<GetBucketQuery, BucketRecord | null>({\n document: GetBucketDocument,\n variables,\n select: selectBucket,\n fallback: null,\n enabled: Boolean(bucketId),\n errorMessage: 'Failed to load bucket',\n });\n}\n\nexport function useCreateBucket() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateBucketVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_BUCKET_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<CreateBucketMutation, CreateBucketVariables, BucketRecord>({\n document: CreateBucketDocument,\n variables,\n select: (data) => data?.createBucket,\n errorMessage: 'Failed to create bucket',\n });\n}\n\nexport function useUpdateBucket() {\n return useWorkspaceMutation<UpdateBucketMutation, UpdateBucketVariables, BucketRecord>({\n document: UpdateBucketDocument,\n variables: ({ bucketId, input }) => ({\n id: bucketId,\n input: buildMutationInput(input, UPDATE_BUCKET_FIELDS),\n }),\n select: (data) => data?.updateBucket,\n errorMessage: 'Failed to update bucket',\n });\n}\n\nexport function useDeleteBucket() {\n return useWorkspaceMutation<DeleteBucketMutation, string, boolean>({\n document: DeleteBucketDocument,\n variables: (bucketId) => ({ id: bucketId }),\n select: (data) => data?.deleteBucket,\n errorMessage: 'Failed to delete bucket',\n });\n}\n"],"mappings":";;;;;AA+BA,IAAM,IAAa,KAsCb,IAAuB,EAA4B;CACvD,OAAO;CACP,SAAS;CACT,aAAa;CACb,MAAM;CACN,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,MAAM;CACN,aAAa;CACd,CAAC,EAEI,IAAuB,EAA4B;CACvD,OAAO;CACP,SAAS;CACT,aAAa;CACb,MAAM;CACN,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,MAAM;CACP,CAAC,EAEI,IAA6B,EAAE,EAC/B,IAAmC,EAAE;AAE3C,SAAS,EAAc,GAAoD;AACzE,QAAO,GAAM,eAAe;;AAY9B,SAAgB,EAAgB,GAAoD;CAClF,IAAM,oBAAQ,IAAI,KAA6B;AAC/C,MAAK,IAAM,KAAU,EACnB,GAAM,IAAI,EAAO,IAAI;EAAE,GAAG;EAAQ,UAAU,EAAE;EAAE,CAAC;CAGnD,IAAM,IAA0B,EAAE;AAClC,MAAK,IAAM,KAAU,GAAS;EAC5B,IAAM,IAAO,EAAM,IAAI,EAAO,GAAG;AACjC,MAAI,CAAC,EAAM;EACX,IAAM,IAAS,EAAO,iBAAiB,EAAM,IAAI,EAAO,eAAe,GAAG,KAAA;AAC1E,EAAI,KAAU,MAAW,IACvB,EAAO,SAAS,KAAK,EAAK,GAE1B,EAAM,KAAK,EAAK;;CAIpB,IAAM,KAAU,GAAmB,MAAsB,EAAE,KAAK,cAAc,EAAE,KAAK,EAC/E,KAAmB,MAA2B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IAAI,GAAU;EAC1C,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { buildMutationInput as e, fieldsOf as t } from "./internal/mutationInput.js";
|
|
2
|
+
import { CreateChannelConnectorDocument as n, CreateChannelRouteDocument as r, DeleteChannelConnectorDocument as i, DeleteChannelRouteDocument as a, GetChannelConnectorDocument as o, ListChannelConnectorsDocument as s, ListChannelRoutesDocument as c, UpdateChannelConnectorDocument as l } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { useWorkspaceId as u, useWorkspaceMutation as d, useWorkspaceQuery as f } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as p, useMemo as m } from "react";
|
|
5
|
+
//#region src/botlit/hooks/useChannels.ts
|
|
6
|
+
var h = 100, g = t({
|
|
7
|
+
bucketId: !0,
|
|
8
|
+
credentialsRefId: !0,
|
|
9
|
+
defaultPolicyBindings: !0,
|
|
10
|
+
description: !0,
|
|
11
|
+
metadata: !0,
|
|
12
|
+
name: !0,
|
|
13
|
+
status: !0,
|
|
14
|
+
tags: !0,
|
|
15
|
+
type: !0,
|
|
16
|
+
visibility: !0,
|
|
17
|
+
workspaceId: !0
|
|
18
|
+
}), _ = t({
|
|
19
|
+
bucketId: !0,
|
|
20
|
+
credentialsRefId: !0,
|
|
21
|
+
defaultPolicyBindings: !0,
|
|
22
|
+
description: !0,
|
|
23
|
+
metadata: !0,
|
|
24
|
+
name: !0,
|
|
25
|
+
status: !0,
|
|
26
|
+
tags: !0,
|
|
27
|
+
visibility: !0
|
|
28
|
+
}), v = t({
|
|
29
|
+
appId: !0,
|
|
30
|
+
connectorId: !0,
|
|
31
|
+
formatPolicyId: !0,
|
|
32
|
+
locationId: !0,
|
|
33
|
+
metadata: !0,
|
|
34
|
+
policyBindings: !0,
|
|
35
|
+
routingOverrides: !0,
|
|
36
|
+
workspaceId: !0
|
|
37
|
+
});
|
|
38
|
+
t({
|
|
39
|
+
appId: !0,
|
|
40
|
+
formatPolicyId: !0,
|
|
41
|
+
locationId: !0,
|
|
42
|
+
metadata: !0,
|
|
43
|
+
policyBindings: !0,
|
|
44
|
+
routingOverrides: !0
|
|
45
|
+
});
|
|
46
|
+
var y = [], b = [];
|
|
47
|
+
function x(e) {
|
|
48
|
+
return e?.listChannelConnectors ?? y;
|
|
49
|
+
}
|
|
50
|
+
function S(e) {
|
|
51
|
+
return e?.getChannelConnector ?? null;
|
|
52
|
+
}
|
|
53
|
+
function C(e) {
|
|
54
|
+
return e?.listChannelRoutes ?? b;
|
|
55
|
+
}
|
|
56
|
+
var w = "webWidget", T = {
|
|
57
|
+
allowedOrigins: [],
|
|
58
|
+
primaryColor: "#3b82f6",
|
|
59
|
+
fontFamily: "Inter, sans-serif",
|
|
60
|
+
starterPrompts: []
|
|
61
|
+
};
|
|
62
|
+
function E(e) {
|
|
63
|
+
let t = e.metadata?.[w];
|
|
64
|
+
if (typeof t != "object" || !t || Array.isArray(t)) return;
|
|
65
|
+
let n = t;
|
|
66
|
+
return {
|
|
67
|
+
allowedOrigins: D(n.allowedOrigins),
|
|
68
|
+
primaryColor: typeof n.primaryColor == "string" ? n.primaryColor : T.primaryColor,
|
|
69
|
+
fontFamily: typeof n.fontFamily == "string" ? n.fontFamily : T.fontFamily,
|
|
70
|
+
starterPrompts: D(n.starterPrompts)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function D(e) {
|
|
74
|
+
return Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
|
|
75
|
+
}
|
|
76
|
+
function O(e, t) {
|
|
77
|
+
let n = e.metadata?.[t];
|
|
78
|
+
return typeof n == "string" ? n : void 0;
|
|
79
|
+
}
|
|
80
|
+
function k(e) {
|
|
81
|
+
let t = u(), n = e?.search, r = e?.type?.[0], i = e?.status?.[0], a = e?.bucketId;
|
|
82
|
+
return f({
|
|
83
|
+
document: s,
|
|
84
|
+
variables: m(() => ({
|
|
85
|
+
filters: {
|
|
86
|
+
workspaceId: t,
|
|
87
|
+
search: n || void 0,
|
|
88
|
+
type: r,
|
|
89
|
+
status: i,
|
|
90
|
+
bucketId: a
|
|
91
|
+
},
|
|
92
|
+
pagination: {
|
|
93
|
+
limit: h,
|
|
94
|
+
offset: 0
|
|
95
|
+
}
|
|
96
|
+
}), [
|
|
97
|
+
t,
|
|
98
|
+
n,
|
|
99
|
+
r,
|
|
100
|
+
i,
|
|
101
|
+
a
|
|
102
|
+
]),
|
|
103
|
+
select: x,
|
|
104
|
+
fallback: y,
|
|
105
|
+
enabled: !!t,
|
|
106
|
+
errorMessage: "Failed to load channel connectors"
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function A(e) {
|
|
110
|
+
return f({
|
|
111
|
+
document: o,
|
|
112
|
+
variables: m(() => ({ id: e ?? "" }), [e]),
|
|
113
|
+
select: S,
|
|
114
|
+
fallback: null,
|
|
115
|
+
enabled: !!e,
|
|
116
|
+
errorMessage: "Failed to load channel connector"
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function j() {
|
|
120
|
+
let t = u();
|
|
121
|
+
return d({
|
|
122
|
+
document: n,
|
|
123
|
+
variables: p((n) => ({ input: e({
|
|
124
|
+
...n,
|
|
125
|
+
workspaceId: t
|
|
126
|
+
}, g) }), [t]),
|
|
127
|
+
select: (e) => e?.createChannelConnector,
|
|
128
|
+
errorMessage: "Failed to create channel connector"
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function M() {
|
|
132
|
+
return d({
|
|
133
|
+
document: l,
|
|
134
|
+
variables: ({ connectorId: t, input: n }) => ({
|
|
135
|
+
id: t,
|
|
136
|
+
input: e(n, _)
|
|
137
|
+
}),
|
|
138
|
+
select: (e) => e?.updateChannelConnector,
|
|
139
|
+
errorMessage: "Failed to update channel connector"
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function N() {
|
|
143
|
+
return d({
|
|
144
|
+
document: i,
|
|
145
|
+
variables: (e) => ({ id: e }),
|
|
146
|
+
select: (e) => e?.deleteChannelConnector,
|
|
147
|
+
errorMessage: "Failed to delete channel connector"
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function P(e) {
|
|
151
|
+
let t = u();
|
|
152
|
+
return f({
|
|
153
|
+
document: c,
|
|
154
|
+
variables: m(() => ({
|
|
155
|
+
filters: {
|
|
156
|
+
workspaceId: t,
|
|
157
|
+
connectorId: e || void 0
|
|
158
|
+
},
|
|
159
|
+
pagination: {
|
|
160
|
+
limit: h,
|
|
161
|
+
offset: 0
|
|
162
|
+
}
|
|
163
|
+
}), [t, e]),
|
|
164
|
+
select: C,
|
|
165
|
+
fallback: b,
|
|
166
|
+
enabled: !!t,
|
|
167
|
+
errorMessage: "Failed to load channel routes"
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function F(e) {
|
|
171
|
+
let t = u();
|
|
172
|
+
return f({
|
|
173
|
+
document: c,
|
|
174
|
+
variables: m(() => ({
|
|
175
|
+
filters: {
|
|
176
|
+
workspaceId: t,
|
|
177
|
+
appId: e
|
|
178
|
+
},
|
|
179
|
+
pagination: {
|
|
180
|
+
limit: h,
|
|
181
|
+
offset: 0
|
|
182
|
+
}
|
|
183
|
+
}), [t, e]),
|
|
184
|
+
select: C,
|
|
185
|
+
fallback: b,
|
|
186
|
+
enabled: !!t && !!e,
|
|
187
|
+
errorMessage: "Failed to load channel routes for this bot"
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function I() {
|
|
191
|
+
let t = u();
|
|
192
|
+
return d({
|
|
193
|
+
document: r,
|
|
194
|
+
variables: p((n) => ({ input: e({
|
|
195
|
+
...n,
|
|
196
|
+
workspaceId: t
|
|
197
|
+
}, v) }), [t]),
|
|
198
|
+
select: (e) => e?.createChannelRoute,
|
|
199
|
+
errorMessage: "Failed to create channel route"
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function L() {
|
|
203
|
+
return d({
|
|
204
|
+
document: a,
|
|
205
|
+
variables: (e) => ({ id: e }),
|
|
206
|
+
select: (e) => e?.deleteChannelRoute,
|
|
207
|
+
errorMessage: "Failed to delete channel route"
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
export { w as WIDGET_METADATA_KEY, E as readWidgetConfig, O as routeMetadataString, F as useBotChannelRoutes, A as useChannelConnector, k as useChannelConnectors, P as useChannelRoutes, j as useCreateChannelConnector, I as useCreateChannelRoute, N as useDeleteChannelConnector, L as useDeleteChannelRoute, M as useUpdateChannelConnector };
|
|
212
|
+
|
|
213
|
+
//# sourceMappingURL=useChannels.js.map
|