@burdenoff/microfe-botmanor 2026.1124.1 → 2026.1127.2
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/botlit/BotmanorRootInner.js +45 -44
- package/dist/botlit/BotmanorRootInner.js.map +1 -1
- package/dist/botlit/components/AgentA2APanel.js +63 -62
- package/dist/botlit/components/AgentA2APanel.js.map +1 -1
- package/dist/botlit/components/AgentBindingsPanel.js +125 -124
- package/dist/botlit/components/AgentBindingsPanel.js.map +1 -1
- package/dist/botlit/components/AgentFallbackModelsPicker.js +56 -55
- package/dist/botlit/components/AgentFallbackModelsPicker.js.map +1 -1
- package/dist/botlit/components/AiOperationsPanel.js.map +1 -1
- package/dist/botlit/components/AssistantChannelPanel.js +40 -39
- package/dist/botlit/components/AssistantChannelPanel.js.map +1 -1
- package/dist/botlit/components/AssistantRuntimeSetupPanel.js +36 -35
- package/dist/botlit/components/AssistantRuntimeSetupPanel.js.map +1 -1
- package/dist/botlit/components/BotAgentsPanel.js +104 -103
- package/dist/botlit/components/BotAgentsPanel.js.map +1 -1
- package/dist/botlit/components/BotFormFields.js +118 -117
- package/dist/botlit/components/BotFormFields.js.map +1 -1
- package/dist/botlit/components/BucketDialogs.js +110 -110
- package/dist/botlit/components/BucketDialogs.js.map +1 -1
- package/dist/botlit/components/ChannelRoutesPanel.js +29 -28
- package/dist/botlit/components/ChannelRoutesPanel.js.map +1 -1
- package/dist/botlit/components/CreateChannelRouteDialog.js +105 -105
- package/dist/botlit/components/CreateChannelRouteDialog.js.map +1 -1
- package/dist/botlit/components/DescribeBotDialog.js +86 -86
- package/dist/botlit/components/DescribeBotDialog.js.map +1 -1
- package/dist/botlit/components/EmptyState.d.ts +8 -0
- package/dist/botlit/components/EmptyState.js +43 -30
- package/dist/botlit/components/EmptyState.js.map +1 -1
- package/dist/botlit/components/HandoffConfigPanel.js +125 -124
- package/dist/botlit/components/HandoffConfigPanel.js.map +1 -1
- package/dist/botlit/components/HandoffTargetPickers.js +42 -41
- package/dist/botlit/components/HandoffTargetPickers.js.map +1 -1
- package/dist/botlit/components/KnowledgeBackendMigrationPanel.js +106 -105
- package/dist/botlit/components/KnowledgeBackendMigrationPanel.js.map +1 -1
- package/dist/botlit/components/KnowledgeRetrievalTestPanel.js +76 -75
- package/dist/botlit/components/KnowledgeRetrievalTestPanel.js.map +1 -1
- package/dist/botlit/components/KnowledgeSourceImportPanel.js +76 -75
- package/dist/botlit/components/KnowledgeSourceImportPanel.js.map +1 -1
- package/dist/botlit/components/ModelRegistrationPanel.js +70 -69
- package/dist/botlit/components/ModelRegistrationPanel.js.map +1 -1
- package/dist/botlit/components/StorePackageDraftCard.js +87 -86
- package/dist/botlit/components/StorePackageDraftCard.js.map +1 -1
- package/dist/botlit/components/SuggestionsPanel.js.map +1 -1
- package/dist/botlit/hooks/internal/workspaceGateway.d.ts +12 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +1 -1
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
- package/dist/botlit/hooks/useA2A.js +2 -1
- package/dist/botlit/hooks/useA2A.js.map +1 -1
- package/dist/botlit/hooks/useA2AConnections.js +30 -38
- package/dist/botlit/hooks/useA2AConnections.js.map +1 -1
- package/dist/botlit/hooks/useKnowledgeBases.js +91 -48
- package/dist/botlit/hooks/useKnowledgeBases.js.map +1 -1
- package/dist/botlit/pages/A2AAgentDetailPage.js +263 -262
- package/dist/botlit/pages/A2AAgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/A2ARegistryPage.js +47 -46
- package/dist/botlit/pages/A2ARegistryPage.js.map +1 -1
- package/dist/botlit/pages/AgentBuilderPage.js +426 -425
- package/dist/botlit/pages/AgentBuilderPage.js.map +1 -1
- package/dist/botlit/pages/AgentDetailPage.js +1 -0
- package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/AgentsListPage.js +248 -247
- package/dist/botlit/pages/AgentsListPage.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.js +324 -310
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/BotDetailPage.js +1 -0
- package/dist/botlit/pages/BotDetailPage.js.map +1 -1
- package/dist/botlit/pages/BotWorkflowTab.js +126 -121
- package/dist/botlit/pages/BotWorkflowTab.js.map +1 -1
- package/dist/botlit/pages/BotsListPage.js +1 -0
- package/dist/botlit/pages/BotsListPage.js.map +1 -1
- package/dist/botlit/pages/BucketDetailPage.js +1 -0
- package/dist/botlit/pages/BucketDetailPage.js.map +1 -1
- package/dist/botlit/pages/BucketsPage.js +1 -0
- package/dist/botlit/pages/BucketsPage.js.map +1 -1
- package/dist/botlit/pages/ChannelDetailPage.js +267 -266
- package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
- package/dist/botlit/pages/ChannelsPage.js +187 -186
- package/dist/botlit/pages/ChannelsPage.js.map +1 -1
- package/dist/botlit/pages/ChatPage.js +69 -68
- package/dist/botlit/pages/ChatPage.js.map +1 -1
- package/dist/botlit/pages/ExecutionDetailPage.js +1 -0
- package/dist/botlit/pages/ExecutionDetailPage.js.map +1 -1
- package/dist/botlit/pages/ExecutionsPage.js +191 -191
- package/dist/botlit/pages/ExecutionsPage.js.map +1 -1
- package/dist/botlit/pages/HandoffsPage.js +65 -64
- package/dist/botlit/pages/HandoffsPage.js.map +1 -1
- package/dist/botlit/pages/InstalledPackagesPage.js +146 -145
- package/dist/botlit/pages/InstalledPackagesPage.js.map +1 -1
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js +235 -234
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js.map +1 -1
- package/dist/botlit/pages/KnowledgeBasesPage.js +152 -151
- package/dist/botlit/pages/KnowledgeBasesPage.js.map +1 -1
- package/dist/botlit/pages/MCPServerDetailPage.js +180 -179
- package/dist/botlit/pages/MCPServerDetailPage.js.map +1 -1
- package/dist/botlit/pages/MCPServersPage.js +145 -145
- package/dist/botlit/pages/MCPServersPage.js.map +1 -1
- package/dist/botlit/pages/PoliciesPage.js.map +1 -1
- package/dist/botlit/pages/PolicyDetailPage.js +293 -292
- package/dist/botlit/pages/PolicyDetailPage.js.map +1 -1
- package/dist/botlit/pages/PromptStudioPage.js +229 -229
- package/dist/botlit/pages/PromptStudioPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplateDetailPage.js +280 -279
- package/dist/botlit/pages/PromptTemplateDetailPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplatesPage.js +31 -30
- package/dist/botlit/pages/PromptTemplatesPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfileDetailPage.js +204 -203
- package/dist/botlit/pages/RetrievalProfileDetailPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfilesPage.js.map +1 -1
- package/dist/botlit/pages/SettingsPage.js +153 -153
- package/dist/botlit/pages/SettingsPage.js.map +1 -1
- package/dist/botlit/pages/SkillDetailPage.js +305 -304
- package/dist/botlit/pages/SkillDetailPage.js.map +1 -1
- package/dist/botlit/pages/SkillsPage.js.map +1 -1
- package/dist/botlit/pages/StorePackageDetailPage.js +1 -0
- package/dist/botlit/pages/StorePackageDetailPage.js.map +1 -1
- package/dist/botlit/pages/StorePage.js +173 -173
- package/dist/botlit/pages/StorePage.js.map +1 -1
- package/dist/botlit/utils/confirmAction.d.ts +13 -11
- package/dist/botlit/utils/confirmAction.js +26 -4
- package/dist/botlit/utils/confirmAction.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +106 -42
- package/dist/generated/wspace-operations.js +198 -172
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +9859 -49
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CreateKnowledgeBaseDocument as e, DeleteKnowledgeBaseDocument as t, GetKnowledgeBaseDocument as n, GetKnowledgeBaseUsageDocument as r, ListBotmanorKnowledgeBasesPageDocument as i, ListKnowledgeDocumentsDocument as a, RebuildKnowledgeBaseIndexDocument as o, RemoveKnowledgeDocumentDocument as s, UpdateKnowledgeBaseDocument as c } from "../../generated/wspace-operations.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { useBotlit as l } from "../providers/BotlitProvider.js";
|
|
3
|
+
import { useAllPagesQuery as u } from "./internal/allPages.js";
|
|
4
|
+
import { buildMutationInput as d, fieldsOf as f } from "./internal/mutationInput.js";
|
|
5
|
+
import { toError as p, useWorkspaceClient as m, useWorkspaceId as h, useWorkspaceMutation as g, useWorkspaceQuery as _ } from "./internal/workspaceGateway.js";
|
|
6
|
+
import { useCallback as v, useMemo as y } from "react";
|
|
7
|
+
import { useQuery as b } from "@tanstack/react-query";
|
|
6
8
|
// src/botlit/hooks/useKnowledgeBases.ts
|
|
7
|
-
var
|
|
9
|
+
var x = 100, S = 50, C = "Failed to load knowledge documents", w = f({
|
|
8
10
|
chunkOverlap: !0,
|
|
9
11
|
chunkSize: !0,
|
|
10
12
|
chunkingStrategy: !0,
|
|
@@ -15,62 +17,103 @@ var v = 100, y = d({
|
|
|
15
17
|
name: !0,
|
|
16
18
|
vectorStoreDriver: !0,
|
|
17
19
|
workspaceId: !0
|
|
18
|
-
}),
|
|
20
|
+
}), T = f({
|
|
19
21
|
chunkOverlap: !0,
|
|
20
22
|
chunkSize: !0,
|
|
21
23
|
chunkingStrategy: !0,
|
|
22
24
|
description: !0,
|
|
23
25
|
metadata: !0,
|
|
24
26
|
name: !0
|
|
25
|
-
}),
|
|
26
|
-
function
|
|
27
|
+
}), E = [], D = [];
|
|
28
|
+
function O(e) {
|
|
27
29
|
return e?.getKnowledgeBase ?? null;
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
var k = {
|
|
32
|
+
all: ["knowledgeBases"],
|
|
33
|
+
lists: () => [...k.all, "list"],
|
|
34
|
+
list: (e) => [...k.lists(), e],
|
|
35
|
+
details: () => [...k.all, "detail"],
|
|
36
|
+
detail: (e) => [...k.details(), e],
|
|
37
|
+
documents: (e) => [...k.detail(e), "documents"]
|
|
38
|
+
};
|
|
39
|
+
function A(e) {
|
|
40
|
+
let t = h(), n = e?.search, r = y(() => ({ filters: {
|
|
34
41
|
workspaceId: t,
|
|
35
42
|
search: n || void 0
|
|
36
43
|
} }), [t, n]);
|
|
37
|
-
return
|
|
44
|
+
return u({
|
|
38
45
|
document: i,
|
|
39
46
|
variables: r,
|
|
40
|
-
pageSize:
|
|
41
|
-
extractRows: (e) => e?.listBotmanorKnowledgeBasesPage.items ??
|
|
47
|
+
pageSize: x,
|
|
48
|
+
extractRows: (e) => e?.listBotmanorKnowledgeBasesPage.items ?? E,
|
|
42
49
|
extractNextOffset: (e) => e?.listBotmanorKnowledgeBasesPage.nextOffset ?? null,
|
|
43
|
-
fallback:
|
|
50
|
+
fallback: E,
|
|
44
51
|
enabled: !!t,
|
|
45
52
|
errorMessage: "Failed to load knowledge bases"
|
|
46
53
|
});
|
|
47
54
|
}
|
|
48
|
-
function
|
|
49
|
-
let t =
|
|
50
|
-
return
|
|
55
|
+
function j(e) {
|
|
56
|
+
let t = y(() => ({ id: e ?? "" }), [e]);
|
|
57
|
+
return _({
|
|
51
58
|
document: n,
|
|
52
59
|
variables: t,
|
|
53
|
-
select:
|
|
60
|
+
select: O,
|
|
54
61
|
fallback: null,
|
|
55
62
|
enabled: !!e,
|
|
56
63
|
errorMessage: "Failed to load knowledge base"
|
|
57
64
|
});
|
|
58
65
|
}
|
|
59
|
-
function
|
|
60
|
-
let t =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
function M(e) {
|
|
67
|
+
let { workspaceId: t, currentUser: n } = l(), r = m(), i = !!(t && e), o = b({
|
|
68
|
+
queryKey: [
|
|
69
|
+
...k.documents(e ?? ""),
|
|
70
|
+
t,
|
|
71
|
+
n?.id
|
|
72
|
+
],
|
|
73
|
+
enabled: i,
|
|
74
|
+
refetchOnMount: "always",
|
|
75
|
+
retry: !1,
|
|
76
|
+
queryFn: async ({ signal: n }) => {
|
|
77
|
+
if (!e || !t) throw Error(C);
|
|
78
|
+
let i = [], o = /* @__PURE__ */ new Set(), s = null;
|
|
79
|
+
try {
|
|
80
|
+
for (;;) {
|
|
81
|
+
n.throwIfAborted();
|
|
82
|
+
let t = {
|
|
83
|
+
knowledgeBaseId: e,
|
|
84
|
+
first: S,
|
|
85
|
+
after: s
|
|
86
|
+
}, c = await r.query({
|
|
87
|
+
query: a,
|
|
88
|
+
variables: t,
|
|
89
|
+
fetchPolicy: "no-cache",
|
|
90
|
+
context: { queryDeduplication: !1 }
|
|
91
|
+
});
|
|
92
|
+
if (n.throwIfAborted(), c.error) throw c.error;
|
|
93
|
+
let l = c.data?.listBotmanorKnowledgeDocumentsConnection;
|
|
94
|
+
if (!l) throw Error(C);
|
|
95
|
+
if (i.push(...l.edges.map(({ node: e }) => e)), !l.pageInfo.hasNextPage) return i;
|
|
96
|
+
let u = l.edges.at(-1)?.cursor;
|
|
97
|
+
if (!u || o.has(u)) throw Error(C);
|
|
98
|
+
o.add(u), s = u;
|
|
99
|
+
}
|
|
100
|
+
} catch (e) {
|
|
101
|
+
throw p(e, C);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
69
104
|
});
|
|
105
|
+
return {
|
|
106
|
+
data: o.error ? D : o.data ?? D,
|
|
107
|
+
loading: o.isFetching,
|
|
108
|
+
error: o.error ?? void 0,
|
|
109
|
+
refetch: async () => {
|
|
110
|
+
i && await o.refetch();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
70
113
|
}
|
|
71
|
-
function
|
|
72
|
-
let e =
|
|
73
|
-
return
|
|
114
|
+
function N() {
|
|
115
|
+
let e = m();
|
|
116
|
+
return v(async (t) => {
|
|
74
117
|
let n = await e.query({
|
|
75
118
|
query: r,
|
|
76
119
|
variables: { id: t },
|
|
@@ -80,53 +123,53 @@ function O() {
|
|
|
80
123
|
return n.data?.getKnowledgeBaseUsage ?? { agents: [] };
|
|
81
124
|
}, [e]);
|
|
82
125
|
}
|
|
83
|
-
function
|
|
84
|
-
return
|
|
126
|
+
function P() {
|
|
127
|
+
return g({
|
|
85
128
|
document: s,
|
|
86
129
|
variables: (e) => ({ id: e }),
|
|
87
130
|
select: (e) => e?.removeKnowledgeDocument,
|
|
88
131
|
errorMessage: "Failed to remove the document"
|
|
89
132
|
});
|
|
90
133
|
}
|
|
91
|
-
function
|
|
92
|
-
let t =
|
|
134
|
+
function F() {
|
|
135
|
+
let t = h(), n = v((e) => ({ input: d({
|
|
93
136
|
...e,
|
|
94
137
|
workspaceId: t
|
|
95
|
-
},
|
|
96
|
-
return
|
|
138
|
+
}, w) }), [t]);
|
|
139
|
+
return g({
|
|
97
140
|
document: e,
|
|
98
141
|
variables: n,
|
|
99
142
|
select: (e) => e?.createKnowledgeBase,
|
|
100
143
|
errorMessage: "Failed to create knowledge base"
|
|
101
144
|
});
|
|
102
145
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
146
|
+
function I() {
|
|
147
|
+
return g({
|
|
105
148
|
document: c,
|
|
106
149
|
variables: ({ kbId: e, input: t }) => ({
|
|
107
150
|
id: e,
|
|
108
|
-
input:
|
|
151
|
+
input: d(t, T)
|
|
109
152
|
}),
|
|
110
153
|
select: (e) => e?.updateKnowledgeBase,
|
|
111
154
|
errorMessage: "Failed to update knowledge base"
|
|
112
155
|
});
|
|
113
156
|
}
|
|
114
|
-
function
|
|
115
|
-
return
|
|
157
|
+
function L() {
|
|
158
|
+
return g({
|
|
116
159
|
document: o,
|
|
117
160
|
variables: (e) => ({ knowledgeBaseId: e }),
|
|
118
161
|
select: (e) => e?.rebuildKnowledgeBaseIndex,
|
|
119
162
|
errorMessage: "Failed to rebuild the knowledge base index"
|
|
120
163
|
});
|
|
121
164
|
}
|
|
122
|
-
function
|
|
123
|
-
return
|
|
165
|
+
function R() {
|
|
166
|
+
return g({
|
|
124
167
|
document: t,
|
|
125
168
|
variables: (e) => ({ id: e }),
|
|
126
169
|
select: (e) => e?.deleteKnowledgeBase,
|
|
127
170
|
errorMessage: "Failed to delete knowledge base"
|
|
128
171
|
});
|
|
129
172
|
}
|
|
130
|
-
export {
|
|
173
|
+
export { k as knowledgeBaseKeys, F as useCreateKnowledgeBase, R as useDeleteKnowledgeBase, j as useKnowledgeBase, A as useKnowledgeBases, M as useKnowledgeDocuments, N as useLoadKnowledgeBaseUsage, L as useRebuildKnowledgeBaseIndex, P as useRemoveKnowledgeDocument, I as useUpdateKnowledgeBase };
|
|
131
174
|
|
|
132
175
|
//# sourceMappingURL=useKnowledgeBases.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKnowledgeBases.js","names":["LIST_LIMIT","CREATE_KB_FIELDS","fieldsOf","UPDATE_KB_FIELDS","NO_KNOWLEDGE_BASES","NO_DOCUMENTS","selectKnowledgeBase","data","selectDocuments","useKnowledgeBases","workspaceId","useWorkspaceId","search","filter","variables","useMemo","useAllPagesQuery","ListBotmanorKnowledgeBasesPageDocument","useKnowledgeBase","kbId","useWorkspaceQuery","GetKnowledgeBaseDocument","useKnowledgeDocuments","ListKnowledgeDocumentsDocument","useLoadKnowledgeBaseUsage","client","useWorkspaceClient","useCallback","result","GetKnowledgeBaseUsageDocument","operationError","useRemoveKnowledgeDocument","useWorkspaceMutation","RemoveKnowledgeDocumentDocument","documentId","useCreateKnowledgeBase","buildMutationInput","input","CreateKnowledgeBaseDocument","useUpdateKnowledgeBase","UpdateKnowledgeBaseDocument","useRebuildKnowledgeBaseIndex","RebuildKnowledgeBaseIndexDocument","useDeleteKnowledgeBase","DeleteKnowledgeBaseDocument"],"sources":["../../../src/botlit/hooks/useKnowledgeBases.ts"],"sourcesContent":["/**\n * Knowledge Bases Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBotmanorKnowledgeBasesPage` / `getKnowledgeBase` /\n * `listKnowledgeDocuments` operations and the create/update/delete mutations on\n * wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateKnowledgeBaseDocument,\n DeleteKnowledgeBaseDocument,\n GetKnowledgeBaseDocument,\n GetKnowledgeBaseUsageDocument,\n ListBotmanorKnowledgeBasesPageDocument,\n ListKnowledgeDocumentsDocument,\n RebuildKnowledgeBaseIndexDocument,\n RemoveKnowledgeDocumentDocument,\n UpdateKnowledgeBaseDocument,\n type CreateKnowledgeBaseMutation,\n type DeleteKnowledgeBaseMutation,\n type GetKnowledgeBaseQuery,\n type ListBotmanorKnowledgeBasesPageQuery,\n type ListKnowledgeDocumentsQuery,\n type GetKnowledgeBaseUsageQuery,\n type RebuildKnowledgeBaseIndexMutation,\n type RemoveKnowledgeDocumentMutation,\n type UpdateKnowledgeBaseMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateKnowledgeBaseInput,\n UpdateKnowledgeBaseInput,\n} from '../../generated/wspace-types';\nimport type { BaseFilter } from '../types';\nimport { useAllPagesQuery } from './internal/allPages';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceClient,\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface KnowledgeBaseRecord {\n id: string;\n name: string;\n description?: string | null;\n indexStatus: string;\n embeddingModel: string;\n embeddingDimensions: number;\n chunkingStrategy: string;\n chunkSize: number;\n chunkOverlap: number;\n totalDocuments: number;\n totalChunks: number;\n vectorCount: number;\n lastIndexedAt?: string | null;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface KnowledgeDocumentRecord {\n id: string;\n knowledgeBaseId: string;\n title: string;\n fileId: string;\n status: string;\n chunkCount: number;\n processingError?: string | null;\n processedAt?: string | null;\n addedAt: string;\n addedById: string;\n updatedAt: string;\n}\n\n/**\n * `CreateKnowledgeBaseInput` minus the `workspaceId` the hook supplies.\n * `embeddingModel`/`embeddingDimensions` are required by the service.\n */\nexport type CreateKnowledgeBaseVariables = Omit<\n GraphQLInput<CreateKnowledgeBaseInput>,\n 'workspaceId'\n>;\n\nexport interface UpdateKnowledgeBaseVariables {\n kbId: string;\n input: GraphQLInput<UpdateKnowledgeBaseInput>;\n}\n\nconst CREATE_KB_FIELDS = fieldsOf<CreateKnowledgeBaseInput>({\n chunkOverlap: true,\n chunkSize: true,\n chunkingStrategy: true,\n description: true,\n embeddingDimensions: true,\n embeddingModel: true,\n metadata: true,\n name: true,\n // Optional: the service picks the environment default when omitted.\n vectorStoreDriver: true,\n workspaceId: true,\n});\n\nconst UPDATE_KB_FIELDS = fieldsOf<UpdateKnowledgeBaseInput>({\n chunkOverlap: true,\n chunkSize: true,\n chunkingStrategy: true,\n description: true,\n metadata: true,\n name: true,\n});\n\nconst NO_KNOWLEDGE_BASES: KnowledgeBaseRecord[] = [];\nconst NO_DOCUMENTS: KnowledgeDocumentRecord[] = [];\n\nfunction selectKnowledgeBase(data: GetKnowledgeBaseQuery | undefined): KnowledgeBaseRecord | null {\n return data?.getKnowledgeBase ?? null;\n}\n\nfunction selectDocuments(data: ListKnowledgeDocumentsQuery | undefined): KnowledgeDocumentRecord[] {\n return data?.listKnowledgeDocuments ?? NO_DOCUMENTS;\n}\n\nexport const knowledgeBaseKeys = {\n all: ['knowledgeBases'] as const,\n lists: () => [...knowledgeBaseKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...knowledgeBaseKeys.lists(), filter] as const,\n details: () => [...knowledgeBaseKeys.all, 'detail'] as const,\n detail: (id: string) => [...knowledgeBaseKeys.details(), id] as const,\n documents: (kbId: string) => [...knowledgeBaseKeys.detail(kbId), 'documents'] as const,\n};\n\nexport function useKnowledgeBases(filter?: BaseFilter): QueryResult<KnowledgeBaseRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search;\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, search: search || undefined },\n }),\n [workspaceId, search]\n );\n\n // Every page: pickers and lookups need the whole list, not the first 100.\n return useAllPagesQuery<ListBotmanorKnowledgeBasesPageQuery, KnowledgeBaseRecord>({\n document: ListBotmanorKnowledgeBasesPageDocument,\n variables,\n pageSize: LIST_LIMIT,\n extractRows: (data) => data?.listBotmanorKnowledgeBasesPage.items ?? NO_KNOWLEDGE_BASES,\n extractNextOffset: (data) => data?.listBotmanorKnowledgeBasesPage.nextOffset ?? null,\n fallback: NO_KNOWLEDGE_BASES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load knowledge bases',\n });\n}\n\nexport function useKnowledgeBase(\n kbId: string | undefined\n): QueryResult<KnowledgeBaseRecord | null> {\n const variables = useMemo(() => ({ id: kbId ?? '' }), [kbId]);\n\n return useWorkspaceQuery<GetKnowledgeBaseQuery, KnowledgeBaseRecord | null>({\n document: GetKnowledgeBaseDocument,\n variables,\n select: selectKnowledgeBase,\n fallback: null,\n enabled: Boolean(kbId),\n errorMessage: 'Failed to load knowledge base',\n });\n}\n\n/** Every document of a knowledge base: all pages, `loading` until the last one is in. */\nexport function useKnowledgeDocuments(\n kbId: string | undefined\n): QueryResult<KnowledgeDocumentRecord[]> {\n const variables = useMemo(() => ({ knowledgeBaseId: kbId ?? '' }), [kbId]);\n\n return useAllPagesQuery<ListKnowledgeDocumentsQuery, KnowledgeDocumentRecord>({\n document: ListKnowledgeDocumentsDocument,\n variables,\n pageSize: LIST_LIMIT,\n extractRows: selectDocuments,\n fallback: NO_DOCUMENTS,\n enabled: Boolean(kbId),\n errorMessage: 'Failed to load knowledge documents',\n });\n}\n\n/** What still uses a knowledge base: the live agents that have it attached (BOFF-12472). */\nexport interface KnowledgeBaseUsage {\n agents: Array<{ id: string; name: string; status: string }>;\n}\n\n/** Returns a function that reads what uses a knowledge base, fresh each time: a delete is about to rely on it. */\nexport function useLoadKnowledgeBaseUsage() {\n const client = useWorkspaceClient();\n\n return useCallback(\n async (kbId: string): Promise<KnowledgeBaseUsage> => {\n const result = await client.query<GetKnowledgeBaseUsageQuery>({\n query: GetKnowledgeBaseUsageDocument,\n variables: { id: kbId },\n fetchPolicy: 'network-only',\n });\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error\n ? operationError\n : new Error('Failed to load what uses this knowledge base');\n }\n return result.data?.getKnowledgeBaseUsage ?? { agents: [] };\n },\n [client]\n );\n}\n\n/** Removes one document and its vectors (`removeKnowledgeDocument`). */\nexport function useRemoveKnowledgeDocument() {\n return useWorkspaceMutation<RemoveKnowledgeDocumentMutation, string, boolean>({\n document: RemoveKnowledgeDocumentDocument,\n variables: (documentId) => ({ id: documentId }),\n select: (data) => data?.removeKnowledgeDocument,\n errorMessage: 'Failed to remove the document',\n });\n}\n\nexport function useCreateKnowledgeBase() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateKnowledgeBaseVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_KB_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<\n CreateKnowledgeBaseMutation,\n CreateKnowledgeBaseVariables,\n { id: string; name: string; workspaceId: string }\n >({\n document: CreateKnowledgeBaseDocument,\n variables,\n select: (data) => data?.createKnowledgeBase,\n errorMessage: 'Failed to create knowledge base',\n });\n}\n\nexport function useUpdateKnowledgeBase() {\n return useWorkspaceMutation<\n UpdateKnowledgeBaseMutation,\n UpdateKnowledgeBaseVariables,\n { id: string; name: string; indexStatus: string }\n >({\n document: UpdateKnowledgeBaseDocument,\n variables: ({ kbId, input }) => ({\n id: kbId,\n input: buildMutationInput(input, UPDATE_KB_FIELDS),\n }),\n select: (data) => data?.updateKnowledgeBase,\n errorMessage: 'Failed to update knowledge base',\n });\n}\n\n/** Re-indexes every document in the knowledge base (`rebuildKnowledgeBaseIndex`). */\nexport function useRebuildKnowledgeBaseIndex() {\n return useWorkspaceMutation<RebuildKnowledgeBaseIndexMutation, string, boolean>({\n document: RebuildKnowledgeBaseIndexDocument,\n variables: (kbId) => ({ knowledgeBaseId: kbId }),\n select: (data) => data?.rebuildKnowledgeBaseIndex,\n errorMessage: 'Failed to rebuild the knowledge base index',\n });\n}\n\nexport function useDeleteKnowledgeBase() {\n return useWorkspaceMutation<DeleteKnowledgeBaseMutation, string, boolean>({\n document: DeleteKnowledgeBaseDocument,\n variables: (kbId) => ({ id: kbId }),\n select: (data) => data?.deleteKnowledgeBase,\n errorMessage: 'Failed to delete knowledge base',\n });\n}\n"],"mappings":";;;;;;AA6CA,IAAMA,IAAa,KAoDbC,IAAmBC,EAAmC;CAC1D,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,qBAAqB;CACrB,gBAAgB;CAChB,UAAU;CACV,MAAM;CAEN,mBAAmB;CACnB,aAAa;AACf,CAAC,GAEKC,IAAmBD,EAAmC;CAC1D,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,UAAU;CACV,MAAM;AACR,CAAC,GAEKE,IAA4C,CAAC,GAC7CC,IAA0C,CAAC;AAEjD,SAASC,EAAoB,GAAqE;CAChG,OAAOC,GAAM,oBAAoB;AACnC;AAEA,SAASC,EAAgB,GAA0E;CACjG,OAAOD,GAAM,0BAA0BF;AACzC;AAWA,SAAgBI,EAAkB,GAAyD;CACzF,IAAMC,IAAcC,EAAe,GAC7BC,IAASC,GAAQ,QAEjBC,IAAYC,SACT,EACL,SAAS;EAAE;EAAa,QAAQH,KAAU,KAAA;CAAU,EACtD,IACA,CAACF,GAAaE,CAAM,CACtB;CAGA,OAAOI,EAA2E;EAChF,UAAUC;EACV;EACA,UAAUjB;EACV,cAAc,MAASO,GAAM,+BAA+B,SAASH;EACrE,oBAAoB,MAASG,GAAM,+BAA+B,cAAc;EAChF,UAAUH;EACV,SAAS,EAAQM;EACjB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBQ,EACd,GACyC;CACzC,IAAMJ,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IL;EACA,UAAUQ;EACV,YAAY,EAAE,SAAM,gBAAa;GAC/B,IAAIrB;GACJ,OAAOiB,EAAmBC,GAAOlC,CAAgB;EACnD;EACA,SAAS,MAASI,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAGA,SAAgBkC,IAA+B;CAC7C,OAAOT,EAAyE;EAC9E,UAAUU;EACV,YAAY,OAAU,EAAE,iBAAiBvB,EAAK;EAC9C,SAAS,MAASZ,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBoC,IAAyB;CACvC,OAAOX,EAAmE;EACxE,UAAUY;EACV,YAAY,OAAU,EAAE,IAAIzB,EAAK;EACjC,SAAS,MAASZ,GAAM;EACxB,cAAc;CAChB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"useKnowledgeBases.js","names":["LIST_LIMIT","DOCUMENT_PAGE_SIZE","DOCUMENT_LOAD_ERROR","CREATE_KB_FIELDS","fieldsOf","UPDATE_KB_FIELDS","NO_KNOWLEDGE_BASES","NO_DOCUMENTS","selectKnowledgeBase","data","knowledgeBaseKeys","filter","id","kbId","useKnowledgeBases","workspaceId","useWorkspaceId","search","variables","useMemo","useAllPagesQuery","ListBotmanorKnowledgeBasesPageDocument","useKnowledgeBase","useWorkspaceQuery","GetKnowledgeBaseDocument","useKnowledgeDocuments","useBotlit","client","useWorkspaceClient","enabled","query","useQuery","currentUser","documents","continuations","after","result","ListKnowledgeDocumentsDocument","signal","page","node","next","cause","toError","useLoadKnowledgeBaseUsage","useCallback","GetKnowledgeBaseUsageDocument","operationError","useRemoveKnowledgeDocument","useWorkspaceMutation","RemoveKnowledgeDocumentDocument","documentId","useCreateKnowledgeBase","buildMutationInput","input","CreateKnowledgeBaseDocument","useUpdateKnowledgeBase","UpdateKnowledgeBaseDocument","useRebuildKnowledgeBaseIndex","RebuildKnowledgeBaseIndexDocument","useDeleteKnowledgeBase","DeleteKnowledgeBaseDocument"],"sources":["../../../src/botlit/hooks/useKnowledgeBases.ts"],"sourcesContent":["/**\n * Knowledge Bases Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBotmanorKnowledgeBasesPage` / `getKnowledgeBase` /\n * `listKnowledgeDocuments` operations and the create/update/delete mutations on\n * wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport type { ApolloClient } from '@apollo/client';\nimport { useQuery } from '@tanstack/react-query';\nimport {\n CreateKnowledgeBaseDocument,\n DeleteKnowledgeBaseDocument,\n GetKnowledgeBaseDocument,\n GetKnowledgeBaseUsageDocument,\n ListBotmanorKnowledgeBasesPageDocument,\n ListKnowledgeDocumentsDocument,\n RebuildKnowledgeBaseIndexDocument,\n RemoveKnowledgeDocumentDocument,\n UpdateKnowledgeBaseDocument,\n type CreateKnowledgeBaseMutation,\n type DeleteKnowledgeBaseMutation,\n type GetKnowledgeBaseQuery,\n type ListBotmanorKnowledgeBasesPageQuery,\n type ListKnowledgeDocumentsQuery,\n type ListKnowledgeDocumentsQueryVariables,\n type GetKnowledgeBaseUsageQuery,\n type RebuildKnowledgeBaseIndexMutation,\n type RemoveKnowledgeDocumentMutation,\n type UpdateKnowledgeBaseMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateKnowledgeBaseInput,\n UpdateKnowledgeBaseInput,\n} from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { BaseFilter } from '../types';\nimport { useAllPagesQuery } from './internal/allPages';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n toError,\n useWorkspaceClient,\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\nconst DOCUMENT_PAGE_SIZE = 50;\nconst DOCUMENT_LOAD_ERROR = 'Failed to load knowledge documents';\n\nexport interface KnowledgeBaseRecord {\n id: string;\n name: string;\n description?: string | null;\n indexStatus: string;\n embeddingModel: string;\n embeddingDimensions: number;\n chunkingStrategy: string;\n chunkSize: number;\n chunkOverlap: number;\n totalDocuments: number;\n totalChunks: number;\n vectorCount: number;\n lastIndexedAt?: string | null;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface KnowledgeDocumentRecord {\n id: string;\n knowledgeBaseId: string;\n title: string;\n fileId: string;\n status: string;\n chunkCount: number;\n processingError?: string | null;\n processedAt?: string | null;\n addedAt: string;\n addedById: string;\n updatedAt: string;\n}\n\n/**\n * `CreateKnowledgeBaseInput` minus the `workspaceId` the hook supplies.\n * `embeddingModel`/`embeddingDimensions` are required by the service.\n */\nexport type CreateKnowledgeBaseVariables = Omit<\n GraphQLInput<CreateKnowledgeBaseInput>,\n 'workspaceId'\n>;\n\nexport interface UpdateKnowledgeBaseVariables {\n kbId: string;\n input: GraphQLInput<UpdateKnowledgeBaseInput>;\n}\n\nconst CREATE_KB_FIELDS = fieldsOf<CreateKnowledgeBaseInput>({\n chunkOverlap: true,\n chunkSize: true,\n chunkingStrategy: true,\n description: true,\n embeddingDimensions: true,\n embeddingModel: true,\n metadata: true,\n name: true,\n // Optional: the service picks the environment default when omitted.\n vectorStoreDriver: true,\n workspaceId: true,\n});\n\nconst UPDATE_KB_FIELDS = fieldsOf<UpdateKnowledgeBaseInput>({\n chunkOverlap: true,\n chunkSize: true,\n chunkingStrategy: true,\n description: true,\n metadata: true,\n name: true,\n});\n\nconst NO_KNOWLEDGE_BASES: KnowledgeBaseRecord[] = [];\nconst NO_DOCUMENTS: KnowledgeDocumentRecord[] = [];\n\nfunction selectKnowledgeBase(data: GetKnowledgeBaseQuery | undefined): KnowledgeBaseRecord | null {\n return data?.getKnowledgeBase ?? null;\n}\n\nexport const knowledgeBaseKeys = {\n all: ['knowledgeBases'] as const,\n lists: () => [...knowledgeBaseKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...knowledgeBaseKeys.lists(), filter] as const,\n details: () => [...knowledgeBaseKeys.all, 'detail'] as const,\n detail: (id: string) => [...knowledgeBaseKeys.details(), id] as const,\n documents: (kbId: string) => [...knowledgeBaseKeys.detail(kbId), 'documents'] as const,\n};\n\nexport function useKnowledgeBases(filter?: BaseFilter): QueryResult<KnowledgeBaseRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search;\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, search: search || undefined },\n }),\n [workspaceId, search]\n );\n\n // Every page: pickers and lookups need the whole list, not the first 100.\n return useAllPagesQuery<ListBotmanorKnowledgeBasesPageQuery, KnowledgeBaseRecord>({\n document: ListBotmanorKnowledgeBasesPageDocument,\n variables,\n pageSize: LIST_LIMIT,\n extractRows: (data) => data?.listBotmanorKnowledgeBasesPage.items ?? NO_KNOWLEDGE_BASES,\n extractNextOffset: (data) => data?.listBotmanorKnowledgeBasesPage.nextOffset ?? null,\n fallback: NO_KNOWLEDGE_BASES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load knowledge bases',\n });\n}\n\nexport function useKnowledgeBase(\n kbId: string | undefined\n): QueryResult<KnowledgeBaseRecord | null> {\n const variables = useMemo(() => ({ id: kbId ?? '' }), [kbId]);\n\n return useWorkspaceQuery<GetKnowledgeBaseQuery, KnowledgeBaseRecord | null>({\n document: GetKnowledgeBaseDocument,\n variables,\n select: selectKnowledgeBase,\n fallback: null,\n enabled: Boolean(kbId),\n errorMessage: 'Failed to load knowledge base',\n });\n}\n\n/** Every document of a knowledge base: all pages, `loading` until the last one is in. */\nexport function useKnowledgeDocuments(\n kbId: string | undefined\n): QueryResult<KnowledgeDocumentRecord[]> {\n const { workspaceId, currentUser } = useBotlit();\n const client = useWorkspaceClient();\n const enabled = Boolean(workspaceId && kbId);\n const query = useQuery({\n queryKey: [...knowledgeBaseKeys.documents(kbId ?? ''), workspaceId, currentUser?.id],\n enabled,\n // A reopened knowledge base may have changed after indexing finished elsewhere.\n refetchOnMount: 'always',\n retry: false,\n queryFn: async ({ signal }) => {\n if (!kbId || !workspaceId) throw new Error(DOCUMENT_LOAD_ERROR);\n const documents: KnowledgeDocumentRecord[] = [];\n const continuations = new Set<string>();\n let after: string | null = null;\n\n try {\n while (true) {\n signal.throwIfAborted();\n const variables: ListKnowledgeDocumentsQueryVariables = {\n knowledgeBaseId: kbId,\n first: DOCUMENT_PAGE_SIZE,\n after,\n };\n const result: ApolloClient.QueryResult<ListKnowledgeDocumentsQuery> = await client.query<\n ListKnowledgeDocumentsQuery,\n ListKnowledgeDocumentsQueryVariables\n >({\n query: ListKnowledgeDocumentsDocument,\n variables,\n fetchPolicy: 'no-cache',\n context: { queryDeduplication: false },\n });\n signal.throwIfAborted();\n if (result.error) throw result.error;\n const page = result.data?.listBotmanorKnowledgeDocumentsConnection;\n if (!page) throw new Error(DOCUMENT_LOAD_ERROR);\n documents.push(...page.edges.map(({ node }) => node));\n if (!page.pageInfo.hasNextPage) return documents;\n\n const next = page.edges.at(-1)?.cursor;\n if (!next || continuations.has(next)) throw new Error(DOCUMENT_LOAD_ERROR);\n continuations.add(next);\n after = next;\n }\n } catch (cause) {\n throw toError(cause, DOCUMENT_LOAD_ERROR);\n }\n },\n });\n\n return {\n data: query.error ? NO_DOCUMENTS : (query.data ?? NO_DOCUMENTS),\n loading: query.isFetching,\n error: query.error ?? undefined,\n refetch: async () => {\n if (enabled) await query.refetch();\n },\n };\n}\n\n/** What still uses a knowledge base: the live agents that have it attached (BOFF-12472). */\nexport interface KnowledgeBaseUsage {\n agents: Array<{ id: string; name: string; status: string }>;\n}\n\n/** Returns a function that reads what uses a knowledge base, fresh each time: a delete is about to rely on it. */\nexport function useLoadKnowledgeBaseUsage() {\n const client = useWorkspaceClient();\n\n return useCallback(\n async (kbId: string): Promise<KnowledgeBaseUsage> => {\n const result = await client.query<GetKnowledgeBaseUsageQuery>({\n query: GetKnowledgeBaseUsageDocument,\n variables: { id: kbId },\n fetchPolicy: 'network-only',\n });\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error\n ? operationError\n : new Error('Failed to load what uses this knowledge base');\n }\n return result.data?.getKnowledgeBaseUsage ?? { agents: [] };\n },\n [client]\n );\n}\n\n/** Removes one document and its vectors (`removeKnowledgeDocument`). */\nexport function useRemoveKnowledgeDocument() {\n return useWorkspaceMutation<RemoveKnowledgeDocumentMutation, string, boolean>({\n document: RemoveKnowledgeDocumentDocument,\n variables: (documentId) => ({ id: documentId }),\n select: (data) => data?.removeKnowledgeDocument,\n errorMessage: 'Failed to remove the document',\n });\n}\n\nexport function useCreateKnowledgeBase() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateKnowledgeBaseVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_KB_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<\n CreateKnowledgeBaseMutation,\n CreateKnowledgeBaseVariables,\n { id: string; name: string; workspaceId: string }\n >({\n document: CreateKnowledgeBaseDocument,\n variables,\n select: (data) => data?.createKnowledgeBase,\n errorMessage: 'Failed to create knowledge base',\n });\n}\n\nexport function useUpdateKnowledgeBase() {\n return useWorkspaceMutation<\n UpdateKnowledgeBaseMutation,\n UpdateKnowledgeBaseVariables,\n { id: string; name: string; indexStatus: string }\n >({\n document: UpdateKnowledgeBaseDocument,\n variables: ({ kbId, input }) => ({\n id: kbId,\n input: buildMutationInput(input, UPDATE_KB_FIELDS),\n }),\n select: (data) => data?.updateKnowledgeBase,\n errorMessage: 'Failed to update knowledge base',\n });\n}\n\n/** Re-indexes every document in the knowledge base (`rebuildKnowledgeBaseIndex`). */\nexport function useRebuildKnowledgeBaseIndex() {\n return useWorkspaceMutation<RebuildKnowledgeBaseIndexMutation, string, boolean>({\n document: RebuildKnowledgeBaseIndexDocument,\n variables: (kbId) => ({ knowledgeBaseId: kbId }),\n select: (data) => data?.rebuildKnowledgeBaseIndex,\n errorMessage: 'Failed to rebuild the knowledge base index',\n });\n}\n\nexport function useDeleteKnowledgeBase() {\n return useWorkspaceMutation<DeleteKnowledgeBaseMutation, string, boolean>({\n document: DeleteKnowledgeBaseDocument,\n variables: (kbId) => ({ id: kbId }),\n select: (data) => data?.deleteKnowledgeBase,\n errorMessage: 'Failed to delete knowledge base',\n });\n}\n"],"mappings":";;;;;;;;AAkDA,IAAMA,IAAa,KACbC,IAAqB,IACrBC,IAAsB,sCAoDtBC,IAAmBC,EAAmC;CAC1D,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,qBAAqB;CACrB,gBAAgB;CAChB,UAAU;CACV,MAAM;CAEN,mBAAmB;CACnB,aAAa;AACf,CAAC,GAEKC,IAAmBD,EAAmC;CAC1D,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,aAAa;CACb,UAAU;CACV,MAAM;AACR,CAAC,GAEKE,IAA4C,CAAC,GAC7CC,IAA0C,CAAC;AAEjD,SAASC,EAAoB,GAAqE;CAChG,OAAOC,GAAM,oBAAoB;AACnC;AAEA,IAAaC,IAAoB;CAC/B,KAAK,CAAC,gBAAgB;CACtB,aAAa,CAAC,GAAGA,EAAkB,KAAK,MAAM;CAC9C,OAAO,MAAwB,CAAC,GAAGA,EAAkB,MAAM,GAAGC,CAAM;CACpE,eAAe,CAAC,GAAGD,EAAkB,KAAK,QAAQ;CAClD,SAAS,MAAe,CAAC,GAAGA,EAAkB,QAAQ,GAAGE,CAAE;CAC3D,YAAY,MAAiB,CAAC,GAAGF,EAAkB,OAAOG,CAAI,GAAG,WAAW;AAC9E;AAEA,SAAgBC,EAAkB,GAAyD;CACzF,IAAMC,IAAcC,EAAe,GAC7BC,IAASN,GAAQ,QAEjBO,IAAYC,SACT,EACL,SAAS;EAAE;EAAa,QAAQF,KAAU,KAAA;CAAU,EACtD,IACA,CAACF,GAAaE,CAAM,CACtB;CAGA,OAAOG,EAA2E;EAChF,UAAUC;EACV;EACA,UAAUrB;EACV,cAAc,MAASS,GAAM,+BAA+B,SAASH;EACrE,oBAAoB,MAASG,GAAM,+BAA+B,cAAc;EAChF,UAAUH;EACV,SAAS,EAA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