@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,120 @@
|
|
|
1
|
+
import { buildMutationInput as e, fieldsOf as t } from "./internal/mutationInput.js";
|
|
2
|
+
import { CreatePolicyDocument as n, DeletePolicyDocument as r, GetPolicyDocument as i, ListPoliciesDocument as a, UpdatePolicyDocument as o } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { useWorkspaceId as s, useWorkspaceMutation as c, useWorkspaceQuery as l } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as u, useMemo as d } from "react";
|
|
5
|
+
//#region src/botlit/hooks/usePolicies.ts
|
|
6
|
+
var f = 100, p = t({
|
|
7
|
+
bucketId: !0,
|
|
8
|
+
config: !0,
|
|
9
|
+
description: !0,
|
|
10
|
+
metadata: !0,
|
|
11
|
+
name: !0,
|
|
12
|
+
status: !0,
|
|
13
|
+
tags: !0,
|
|
14
|
+
type: !0,
|
|
15
|
+
visibility: !0,
|
|
16
|
+
workspaceId: !0
|
|
17
|
+
}), m = t({
|
|
18
|
+
bucketId: !0,
|
|
19
|
+
config: !0,
|
|
20
|
+
description: !0,
|
|
21
|
+
metadata: !0,
|
|
22
|
+
name: !0,
|
|
23
|
+
status: !0,
|
|
24
|
+
tags: !0,
|
|
25
|
+
type: !0,
|
|
26
|
+
visibility: !0
|
|
27
|
+
}), h = [];
|
|
28
|
+
function g(e) {
|
|
29
|
+
return e?.listPolicies ?? h;
|
|
30
|
+
}
|
|
31
|
+
function _(e) {
|
|
32
|
+
let t = s(), { search: n, type: r, status: i, visibility: o, bucketId: c } = e ?? {};
|
|
33
|
+
return l({
|
|
34
|
+
document: a,
|
|
35
|
+
variables: d(() => ({
|
|
36
|
+
filters: {
|
|
37
|
+
workspaceId: t,
|
|
38
|
+
search: n || void 0,
|
|
39
|
+
type: r,
|
|
40
|
+
status: i,
|
|
41
|
+
visibility: o,
|
|
42
|
+
bucketId: c
|
|
43
|
+
},
|
|
44
|
+
pagination: {
|
|
45
|
+
limit: f,
|
|
46
|
+
offset: 0
|
|
47
|
+
}
|
|
48
|
+
}), [
|
|
49
|
+
t,
|
|
50
|
+
n,
|
|
51
|
+
r,
|
|
52
|
+
i,
|
|
53
|
+
o,
|
|
54
|
+
c
|
|
55
|
+
]),
|
|
56
|
+
select: g,
|
|
57
|
+
fallback: h,
|
|
58
|
+
enabled: !!t,
|
|
59
|
+
errorMessage: "Failed to load policies"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function v(e) {
|
|
63
|
+
return l({
|
|
64
|
+
document: i,
|
|
65
|
+
variables: d(() => ({ id: e ?? "" }), [e]),
|
|
66
|
+
select: (e) => e?.getPolicy ?? null,
|
|
67
|
+
fallback: null,
|
|
68
|
+
enabled: !!e,
|
|
69
|
+
errorMessage: "Failed to load policy"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function y() {
|
|
73
|
+
let t = s(), [r, i] = c({
|
|
74
|
+
document: n,
|
|
75
|
+
variables: u((n) => ({ input: e({
|
|
76
|
+
...n,
|
|
77
|
+
workspaceId: t
|
|
78
|
+
}, p) }), [t]),
|
|
79
|
+
select: (e) => e?.createPolicy,
|
|
80
|
+
errorMessage: "Failed to create policy"
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
create: r,
|
|
84
|
+
loading: i.loading,
|
|
85
|
+
error: i.error
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function b() {
|
|
89
|
+
let [t, n] = c({
|
|
90
|
+
document: o,
|
|
91
|
+
variables: ({ policyId: t, input: n }) => ({
|
|
92
|
+
id: t,
|
|
93
|
+
input: e(n, m)
|
|
94
|
+
}),
|
|
95
|
+
select: (e) => e?.updatePolicy,
|
|
96
|
+
errorMessage: "Failed to update policy"
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
update: t,
|
|
100
|
+
loading: n.loading,
|
|
101
|
+
error: n.error
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function x() {
|
|
105
|
+
let [e, t] = c({
|
|
106
|
+
document: r,
|
|
107
|
+
variables: (e) => ({ id: e }),
|
|
108
|
+
select: (e) => e?.deletePolicy,
|
|
109
|
+
errorMessage: "Failed to delete policy"
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
remove: e,
|
|
113
|
+
loading: t.loading,
|
|
114
|
+
error: t.error
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { y as useCreatePolicy, x as useDeletePolicy, _ as usePolicies, v as usePolicy, b as useUpdatePolicy };
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=usePolicies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePolicies.js","names":[],"sources":["../../../src/botlit/hooks/usePolicies.ts"],"sourcesContent":["/**\n * Policies Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listPolicies` / `getPolicy` operations and the\n * create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreatePolicyDocument,\n DeletePolicyDocument,\n GetPolicyDocument,\n ListPoliciesDocument,\n UpdatePolicyDocument,\n type CreatePolicyMutation,\n type DeletePolicyMutation,\n type GetPolicyQuery,\n type ListPoliciesQuery,\n type UpdatePolicyMutation,\n} from '../../generated/wspace-operations';\nimport type { CreatePolicyInput, UpdatePolicyInput } from '../../generated/wspace-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 PolicyRecord {\n id: string;\n name: string;\n type: string;\n status: string;\n visibility: string;\n description?: string | null;\n bucketId?: string | null;\n config?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface PolicyFilterVariables {\n search?: string;\n type?: string;\n status?: string;\n visibility?: string;\n bucketId?: string;\n}\n\n/** `CreatePolicyInput` minus the `workspaceId` the hook supplies. */\nexport type CreatePolicyVariables = Omit<GraphQLInput<CreatePolicyInput>, 'workspaceId'>;\n\nexport interface UpdatePolicyVariables {\n policyId: string;\n input: GraphQLInput<UpdatePolicyInput>;\n}\n\nconst CREATE_POLICY_FIELDS = fieldsOf<CreatePolicyInput>({\n bucketId: true,\n config: true,\n description: true,\n metadata: true,\n name: true,\n status: true,\n tags: true,\n type: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_POLICY_FIELDS = fieldsOf<UpdatePolicyInput>({\n bucketId: true,\n config: true,\n description: true,\n metadata: true,\n name: true,\n status: true,\n tags: true,\n type: true,\n visibility: true,\n});\n\nconst NO_POLICIES: PolicyRecord[] = [];\n\nfunction selectPolicies(data: ListPoliciesQuery | undefined): PolicyRecord[] {\n return data?.listPolicies ?? NO_POLICIES;\n}\n\nexport const policyKeys = {\n all: ['policies'] as const,\n lists: () => [...policyKeys.all, 'list'] as const,\n list: (filter?: PolicyFilterVariables) => [...policyKeys.lists(), filter] as const,\n details: () => [...policyKeys.all, 'detail'] as const,\n detail: (id: string) => [...policyKeys.details(), id] as const,\n byType: (type: string) => [...policyKeys.all, 'type', type] as const,\n};\n\nexport function usePolicies(filter?: PolicyFilterVariables): QueryResult<PolicyRecord[]> {\n const workspaceId = useWorkspaceId();\n const { search, type, status, visibility, bucketId } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n type,\n status,\n visibility,\n bucketId,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search, type, status, visibility, bucketId]\n );\n\n return useWorkspaceQuery<ListPoliciesQuery, PolicyRecord[]>({\n document: ListPoliciesDocument,\n variables,\n select: selectPolicies,\n fallback: NO_POLICIES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load policies',\n });\n}\n\nexport function usePoliciesByType(type: string): QueryResult<PolicyRecord[]> {\n return usePolicies({ type });\n}\n\nexport function usePolicy(policyId: string | undefined): QueryResult<PolicyRecord | null> {\n const variables = useMemo(() => ({ id: policyId ?? '' }), [policyId]);\n\n return useWorkspaceQuery<GetPolicyQuery, PolicyRecord | null>({\n document: GetPolicyDocument,\n variables,\n select: (data) => data?.getPolicy ?? null,\n fallback: null,\n enabled: Boolean(policyId),\n errorMessage: 'Failed to load policy',\n });\n}\n\nexport function useCreatePolicy() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreatePolicyVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_POLICY_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreatePolicyMutation,\n CreatePolicyVariables,\n PolicyRecord\n >({\n document: CreatePolicyDocument,\n variables,\n select: (data) => data?.createPolicy,\n errorMessage: 'Failed to create policy',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdatePolicy() {\n const [update, state] = useWorkspaceMutation<\n UpdatePolicyMutation,\n UpdatePolicyVariables,\n PolicyRecord\n >({\n document: UpdatePolicyDocument,\n variables: ({ policyId, input }) => ({\n id: policyId,\n input: buildMutationInput(input, UPDATE_POLICY_FIELDS),\n }),\n select: (data) => data?.updatePolicy,\n errorMessage: 'Failed to update policy',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeletePolicy() {\n const [remove, state] = useWorkspaceMutation<DeletePolicyMutation, string, boolean>({\n document: DeletePolicyDocument,\n variables: (policyId) => ({ id: policyId }),\n select: (data) => data?.deletePolicy,\n errorMessage: 'Failed to delete policy',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;AA8BA,IAAM,IAAa,KAqCb,IAAuB,EAA4B;CACvD,UAAU;CACV,QAAQ;CACR,aAAa;CACb,UAAU;CACV,MAAM;CACN,QAAQ;CACR,MAAM;CACN,MAAM;CACN,YAAY;CACZ,aAAa;CACd,CAAC,EAEI,IAAuB,EAA4B;CACvD,UAAU;CACV,QAAQ;CACR,aAAa;CACb,UAAU;CACV,MAAM;CACN,QAAQ;CACR,MAAM;CACN,MAAM;CACN,YAAY;CACb,CAAC,EAEI,IAA8B,EAAE;AAEtC,SAAS,EAAe,GAAqD;AAC3E,QAAO,GAAM,gBAAgB;;AAY/B,SAAgB,EAAY,GAA6D;CACvF,IAAM,IAAc,GAAgB,EAC9B,EAAE,WAAQ,SAAM,WAAQ,eAAY,gBAAa,KAAU,EAAE;AAiBnE,QAAO,EAAqD;EAC1D,UAAU;EACV,WAjBgB,SACT;GACL,SAAS;IACP;IACA,QAAQ,KAAU,KAAA;IAClB;IACA;IACA;IACA;IACD;GACD,YAAY;IAAE,OAAO;IAAY,QAAQ;IAAG;GAC7C,GACD;GAAC;GAAa;GAAQ;GAAM;GAAQ;GAAY;GAAS,CAC1D;EAKC,QAAQ;EACR,UAAU;EACV,SAAS,EAAQ;EACjB,cAAc;EACf,CAAC;;AAOJ,SAAgB,EAAU,GAAgE;AAGxF,QAAO,EAAuD;EAC5D,UAAU;EACV,WAJgB,SAAe,EAAE,IAAI,KAAY,IAAI,GAAG,CAAC,EAAS,CAAC;EAKnE,SAAS,MAAS,GAAM,aAAa;EACrC,UAAU;EACV,SAAS,EAAQ;EACjB,cAAc;EACf,CAAC;;AAGJ,SAAgB,IAAkB;CAChC,IAAM,IAAc,GAAgB,EAS9B,CAAC,GAAQ,KAAS,EAItB;EACA,UAAU;EACV,WAbgB,GACf,OAAkC,EACjC,OAAO,EAAmB;GAAE,GAAG;GAAO;GAAa,EAAE,EAAqB,EAC3E,GACD,CAAC,EAAY,CACd;EASC,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC;AAEF,QAAO;EAAE;EAAQ,SAAS,EAAM;EAAS,OAAO,EAAM;EAAO;;AAG/D,SAAgB,IAAkB;CAChC,IAAM,CAAC,GAAQ,KAAS,EAItB;EACA,UAAU;EACV,YAAY,EAAE,aAAU,gBAAa;GACnC,IAAI;GACJ,OAAO,EAAmB,GAAO,EAAqB;GACvD;EACD,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC;AAEF,QAAO;EAAE;EAAQ,SAAS,EAAM;EAAS,OAAO,EAAM;EAAO;;AAG/D,SAAgB,IAAkB;CAChC,IAAM,CAAC,GAAQ,KAAS,EAA4D;EAClF,UAAU;EACV,YAAY,OAAc,EAAE,IAAI,GAAU;EAC1C,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC;AAEF,QAAO;EAAE;EAAQ,SAAS,EAAM;EAAS,OAAO,EAAM;EAAO"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { buildMutationInput as e, fieldsOf as t } from "./internal/mutationInput.js";
|
|
2
|
+
import { CreatePromptTemplateDocument as n, DeletePromptTemplateDocument as r, GetPromptTemplateDocument as i, ListPromptTemplatesDocument as a, RenderPromptTemplateDocument as o, UpdatePromptTemplateDocument as s } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { useWorkspaceId as c, useWorkspaceMutation as l, useWorkspaceQuery as u } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { jsonRecords as d } from "../utils/unions.js";
|
|
5
|
+
import { useCallback as f, useMemo as p } from "react";
|
|
6
|
+
//#region src/botlit/hooks/usePromptTemplates.ts
|
|
7
|
+
var m = 100, h = t({
|
|
8
|
+
bucketId: !0,
|
|
9
|
+
description: !0,
|
|
10
|
+
exampleInputs: !0,
|
|
11
|
+
metadata: !0,
|
|
12
|
+
name: !0,
|
|
13
|
+
slug: !0,
|
|
14
|
+
status: !0,
|
|
15
|
+
tags: !0,
|
|
16
|
+
templateText: !0,
|
|
17
|
+
variables: !0,
|
|
18
|
+
version: !0,
|
|
19
|
+
visibility: !0,
|
|
20
|
+
workspaceId: !0
|
|
21
|
+
}), g = t({
|
|
22
|
+
bucketId: !0,
|
|
23
|
+
description: !0,
|
|
24
|
+
exampleInputs: !0,
|
|
25
|
+
metadata: !0,
|
|
26
|
+
name: !0,
|
|
27
|
+
slug: !0,
|
|
28
|
+
status: !0,
|
|
29
|
+
tags: !0,
|
|
30
|
+
templateText: !0,
|
|
31
|
+
variables: !0,
|
|
32
|
+
version: !0,
|
|
33
|
+
visibility: !0
|
|
34
|
+
}), _ = [], v = [
|
|
35
|
+
"string",
|
|
36
|
+
"number",
|
|
37
|
+
"boolean",
|
|
38
|
+
"array",
|
|
39
|
+
"object"
|
|
40
|
+
];
|
|
41
|
+
function y(e) {
|
|
42
|
+
return d(e.variables).map((e, t) => ({
|
|
43
|
+
name: typeof e.name == "string" ? e.name : `variable_${t + 1}`,
|
|
44
|
+
type: v.find((t) => typeof e.type == "string" && t === e.type) ?? "string",
|
|
45
|
+
required: e.required === !0,
|
|
46
|
+
description: typeof e.description == "string" ? e.description : void 0,
|
|
47
|
+
defaultValue: e.defaultValue
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
function b(e) {
|
|
51
|
+
return d(e.exampleInputs);
|
|
52
|
+
}
|
|
53
|
+
function x(e) {
|
|
54
|
+
return e?.listPromptTemplates ?? _;
|
|
55
|
+
}
|
|
56
|
+
function S(e) {
|
|
57
|
+
let t = c(), { search: n, status: r, visibility: i, bucketId: o } = e ?? {}, s = e?.tags?.join(",") ?? "";
|
|
58
|
+
return u({
|
|
59
|
+
document: a,
|
|
60
|
+
variables: p(() => ({
|
|
61
|
+
filters: {
|
|
62
|
+
workspaceId: t,
|
|
63
|
+
search: n || void 0,
|
|
64
|
+
status: r,
|
|
65
|
+
visibility: i,
|
|
66
|
+
bucketId: o,
|
|
67
|
+
tags: s ? s.split(",") : void 0
|
|
68
|
+
},
|
|
69
|
+
pagination: {
|
|
70
|
+
limit: m,
|
|
71
|
+
offset: 0
|
|
72
|
+
}
|
|
73
|
+
}), [
|
|
74
|
+
t,
|
|
75
|
+
n,
|
|
76
|
+
r,
|
|
77
|
+
i,
|
|
78
|
+
o,
|
|
79
|
+
s
|
|
80
|
+
]),
|
|
81
|
+
select: x,
|
|
82
|
+
fallback: _,
|
|
83
|
+
enabled: !!t,
|
|
84
|
+
errorMessage: "Failed to load prompt templates"
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function C(e) {
|
|
88
|
+
return u({
|
|
89
|
+
document: i,
|
|
90
|
+
variables: p(() => ({ id: e ?? "" }), [e]),
|
|
91
|
+
select: (e) => e?.getPromptTemplate ?? null,
|
|
92
|
+
fallback: null,
|
|
93
|
+
enabled: !!e,
|
|
94
|
+
errorMessage: "Failed to load prompt template"
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function w() {
|
|
98
|
+
let t = c(), [r, i] = l({
|
|
99
|
+
document: n,
|
|
100
|
+
variables: f((n) => ({ input: e({
|
|
101
|
+
...n,
|
|
102
|
+
workspaceId: t
|
|
103
|
+
}, h) }), [t]),
|
|
104
|
+
select: (e) => e?.createPromptTemplate,
|
|
105
|
+
errorMessage: "Failed to create prompt template"
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
create: r,
|
|
109
|
+
loading: i.loading,
|
|
110
|
+
error: i.error
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function T() {
|
|
114
|
+
let [t, n] = l({
|
|
115
|
+
document: s,
|
|
116
|
+
variables: ({ templateId: t, input: n }) => ({
|
|
117
|
+
id: t,
|
|
118
|
+
input: e(n, g)
|
|
119
|
+
}),
|
|
120
|
+
select: (e) => e?.updatePromptTemplate,
|
|
121
|
+
errorMessage: "Failed to update prompt template"
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
update: t,
|
|
125
|
+
loading: n.loading,
|
|
126
|
+
error: n.error
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function E() {
|
|
130
|
+
let [e, t] = l({
|
|
131
|
+
document: r,
|
|
132
|
+
variables: (e) => ({ id: e }),
|
|
133
|
+
select: (e) => e?.deletePromptTemplate,
|
|
134
|
+
errorMessage: "Failed to delete prompt template"
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
remove: e,
|
|
138
|
+
loading: t.loading,
|
|
139
|
+
error: t.error
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function D() {
|
|
143
|
+
let [e, t] = l({
|
|
144
|
+
document: o,
|
|
145
|
+
variables: ({ templateId: e, variables: t }) => ({
|
|
146
|
+
id: e,
|
|
147
|
+
variables: t
|
|
148
|
+
}),
|
|
149
|
+
select: (e) => e?.renderPromptTemplate,
|
|
150
|
+
errorMessage: "Failed to render prompt template"
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
render: e,
|
|
154
|
+
loading: t.loading,
|
|
155
|
+
error: t.error
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { b as promptTemplateExamples, y as promptTemplateVariables, w as useCreatePromptTemplate, E as useDeletePromptTemplate, C as usePromptTemplate, S as usePromptTemplates, D as useRenderPromptTemplate, T as useUpdatePromptTemplate };
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=usePromptTemplates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePromptTemplates.js","names":[],"sources":["../../../src/botlit/hooks/usePromptTemplates.ts"],"sourcesContent":["/**\n * Prompt Templates Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listPromptTemplates` / `getPromptTemplate` operations and\n * the create/update/delete/render mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreatePromptTemplateDocument,\n DeletePromptTemplateDocument,\n GetPromptTemplateDocument,\n ListPromptTemplatesDocument,\n RenderPromptTemplateDocument,\n UpdatePromptTemplateDocument,\n type CreatePromptTemplateMutation,\n type DeletePromptTemplateMutation,\n type GetPromptTemplateQuery,\n type ListPromptTemplatesQuery,\n type RenderPromptTemplateMutation,\n type UpdatePromptTemplateMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreatePromptTemplateInput,\n UpdatePromptTemplateInput,\n} from '../../generated/wspace-types';\nimport { jsonRecords } from '../utils/unions';\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 PromptTemplateRecord {\n id: string;\n name: string;\n slug: string;\n version: string;\n templateText: string;\n status: string;\n visibility: string;\n description?: string | null;\n bucketId?: string | null;\n /** Free-form JSON — the UI stores an array of `PromptVariable` here. */\n variables: Record<string, unknown> | unknown[];\n exampleInputs: Record<string, unknown> | unknown[];\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface PromptTemplateFilterVariables {\n search?: string;\n status?: string;\n visibility?: string;\n bucketId?: string;\n tags?: string[];\n}\n\n/** `CreatePromptTemplateInput` minus the `workspaceId` the hook supplies. */\nexport type CreatePromptTemplateVariables = Omit<\n GraphQLInput<CreatePromptTemplateInput>,\n 'workspaceId'\n>;\n\nexport interface UpdatePromptTemplateVariables {\n templateId: string;\n input: GraphQLInput<UpdatePromptTemplateInput>;\n}\n\nconst CREATE_TEMPLATE_FIELDS = fieldsOf<CreatePromptTemplateInput>({\n bucketId: true,\n description: true,\n exampleInputs: true,\n metadata: true,\n name: true,\n slug: true,\n status: true,\n tags: true,\n templateText: true,\n variables: true,\n version: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_TEMPLATE_FIELDS = fieldsOf<UpdatePromptTemplateInput>({\n bucketId: true,\n description: true,\n exampleInputs: true,\n metadata: true,\n name: true,\n slug: true,\n status: true,\n tags: true,\n templateText: true,\n variables: true,\n version: true,\n visibility: true,\n});\n\nexport interface RenderPromptTemplateVariables {\n templateId: string;\n variables?: Record<string, unknown>;\n}\n\nconst NO_TEMPLATES: PromptTemplateRecord[] = [];\n\n/** The variable types the editor offers; anything else falls back to `string`. */\nconst VARIABLE_TYPES: PromptVariableType[] = ['string', 'number', 'boolean', 'array', 'object'];\n\nexport type PromptVariableType = 'string' | 'number' | 'boolean' | 'array' | 'object';\n\n/**\n * One declared template variable. `variables` is a free-form `JSON` column, so\n * a template whose variables were written by another client (or stored as an\n * object rather than an array) must still render.\n */\nexport interface PromptTemplateVariable {\n name: string;\n type: PromptVariableType;\n required: boolean;\n description?: string;\n defaultValue?: unknown;\n}\n\n/** The template's declared variables, normalised for rendering. */\nexport function promptTemplateVariables(\n template: Pick<PromptTemplateRecord, 'variables'>\n): PromptTemplateVariable[] {\n return jsonRecords(template.variables).map((variable, index) => ({\n name: typeof variable.name === 'string' ? variable.name : `variable_${index + 1}`,\n type:\n VARIABLE_TYPES.find(\n (candidate) => typeof variable.type === 'string' && candidate === variable.type\n ) ?? 'string',\n required: variable.required === true,\n description: typeof variable.description === 'string' ? variable.description : undefined,\n defaultValue: variable.defaultValue,\n }));\n}\n\n/** The template's example input sets, normalised for rendering. */\nexport function promptTemplateExamples(\n template: Pick<PromptTemplateRecord, 'exampleInputs'>\n): Record<string, unknown>[] {\n return jsonRecords(template.exampleInputs);\n}\n\nfunction selectTemplates(data: ListPromptTemplatesQuery | undefined): PromptTemplateRecord[] {\n return data?.listPromptTemplates ?? NO_TEMPLATES;\n}\n\nexport const promptTemplateKeys = {\n all: ['promptTemplates'] as const,\n lists: () => [...promptTemplateKeys.all, 'list'] as const,\n list: (filter?: PromptTemplateFilterVariables) =>\n [...promptTemplateKeys.lists(), filter] as const,\n details: () => [...promptTemplateKeys.all, 'detail'] as const,\n detail: (id: string) => [...promptTemplateKeys.details(), id] as const,\n};\n\nexport function usePromptTemplates(\n filter?: PromptTemplateFilterVariables\n): QueryResult<PromptTemplateRecord[]> {\n const workspaceId = useWorkspaceId();\n const { search, status, visibility, bucketId } = filter ?? {};\n const tagsKey = filter?.tags?.join(',') ?? '';\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status,\n visibility,\n bucketId,\n tags: tagsKey ? tagsKey.split(',') : undefined,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search, status, visibility, bucketId, tagsKey]\n );\n\n return useWorkspaceQuery<ListPromptTemplatesQuery, PromptTemplateRecord[]>({\n document: ListPromptTemplatesDocument,\n variables,\n select: selectTemplates,\n fallback: NO_TEMPLATES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load prompt templates',\n });\n}\n\nexport function usePromptTemplate(\n templateId: string | undefined\n): QueryResult<PromptTemplateRecord | null> {\n const variables = useMemo(() => ({ id: templateId ?? '' }), [templateId]);\n\n return useWorkspaceQuery<GetPromptTemplateQuery, PromptTemplateRecord | null>({\n document: GetPromptTemplateDocument,\n variables,\n select: (data) => data?.getPromptTemplate ?? null,\n fallback: null,\n enabled: Boolean(templateId),\n errorMessage: 'Failed to load prompt template',\n });\n}\n\nexport function useCreatePromptTemplate() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreatePromptTemplateVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_TEMPLATE_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreatePromptTemplateMutation,\n CreatePromptTemplateVariables,\n PromptTemplateRecord\n >({\n document: CreatePromptTemplateDocument,\n variables,\n select: (data) => data?.createPromptTemplate,\n errorMessage: 'Failed to create prompt template',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdatePromptTemplate() {\n const [update, state] = useWorkspaceMutation<\n UpdatePromptTemplateMutation,\n UpdatePromptTemplateVariables,\n PromptTemplateRecord\n >({\n document: UpdatePromptTemplateDocument,\n variables: ({ templateId, input }) => ({\n id: templateId,\n input: buildMutationInput(input, UPDATE_TEMPLATE_FIELDS),\n }),\n select: (data) => data?.updatePromptTemplate,\n errorMessage: 'Failed to update prompt template',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeletePromptTemplate() {\n const [remove, state] = useWorkspaceMutation<DeletePromptTemplateMutation, string, boolean>({\n document: DeletePromptTemplateDocument,\n variables: (templateId) => ({ id: templateId }),\n select: (data) => data?.deletePromptTemplate,\n errorMessage: 'Failed to delete prompt template',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n\nexport function useRenderPromptTemplate() {\n const [render, state] = useWorkspaceMutation<\n RenderPromptTemplateMutation,\n RenderPromptTemplateVariables,\n string\n >({\n document: RenderPromptTemplateDocument,\n variables: ({ templateId, variables }) => ({ id: templateId, variables }),\n select: (data) => data?.renderPromptTemplate,\n errorMessage: 'Failed to render prompt template',\n });\n\n return { render, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;;AAoCA,IAAM,IAAa,KA4Cb,IAAyB,EAAoC;CACjE,UAAU;CACV,aAAa;CACb,eAAe;CACf,UAAU;CACV,MAAM;CACN,MAAM;CACN,QAAQ;CACR,MAAM;CACN,cAAc;CACd,WAAW;CACX,SAAS;CACT,YAAY;CACZ,aAAa;CACd,CAAC,EAEI,IAAyB,EAA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js";
|
|
2
|
+
import { CreateRetrievalProfileDocument as n, DeleteRetrievalProfileDocument as r, GetRetrievalProfileDocument as i, ListRetrievalProfilesDocument as a, UpdateRetrievalProfileDocument as o } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { useWorkspaceId as s, useWorkspaceMutation as c, useWorkspaceQuery as l } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as u, useMemo as d } from "react";
|
|
5
|
+
//#region src/botlit/hooks/useRetrievalProfiles.ts
|
|
6
|
+
var f = 100, p = t({
|
|
7
|
+
bucketId: !0,
|
|
8
|
+
citationFormat: !0,
|
|
9
|
+
citationsRequired: !0,
|
|
10
|
+
description: !0,
|
|
11
|
+
hybridWeights: !0,
|
|
12
|
+
metadata: !0,
|
|
13
|
+
minRelevanceScore: !0,
|
|
14
|
+
minSources: !0,
|
|
15
|
+
multiHop: !0,
|
|
16
|
+
multiHopDepth: !0,
|
|
17
|
+
name: !0,
|
|
18
|
+
noAnswerIfBelowThreshold: !0,
|
|
19
|
+
queryRewrite: !0,
|
|
20
|
+
reranker: !0,
|
|
21
|
+
rerankerModelPolicyId: !0,
|
|
22
|
+
showSources: !0,
|
|
23
|
+
snippetMaxChars: !0,
|
|
24
|
+
status: !0,
|
|
25
|
+
strategyMode: !0,
|
|
26
|
+
tags: !0,
|
|
27
|
+
testQueries: !0,
|
|
28
|
+
topK: !0,
|
|
29
|
+
visibility: !0,
|
|
30
|
+
workspaceId: !0
|
|
31
|
+
}), m = t({
|
|
32
|
+
bucketId: !0,
|
|
33
|
+
citationFormat: !0,
|
|
34
|
+
citationsRequired: !0,
|
|
35
|
+
description: !0,
|
|
36
|
+
hybridWeights: !0,
|
|
37
|
+
metadata: !0,
|
|
38
|
+
minRelevanceScore: !0,
|
|
39
|
+
minSources: !0,
|
|
40
|
+
multiHop: !0,
|
|
41
|
+
multiHopDepth: !0,
|
|
42
|
+
name: !0,
|
|
43
|
+
noAnswerIfBelowThreshold: !0,
|
|
44
|
+
queryRewrite: !0,
|
|
45
|
+
reranker: !0,
|
|
46
|
+
rerankerModelPolicyId: !0,
|
|
47
|
+
showSources: !0,
|
|
48
|
+
snippetMaxChars: !0,
|
|
49
|
+
status: !0,
|
|
50
|
+
strategyMode: !0,
|
|
51
|
+
tags: !0,
|
|
52
|
+
testQueries: !0,
|
|
53
|
+
topK: !0,
|
|
54
|
+
visibility: !0
|
|
55
|
+
}), h = [];
|
|
56
|
+
function g(e) {
|
|
57
|
+
return e?.listRetrievalProfiles ?? h;
|
|
58
|
+
}
|
|
59
|
+
function _(e) {
|
|
60
|
+
let t = s(), { search: n, status: r, strategyMode: i, bucketId: o } = e ?? {};
|
|
61
|
+
return l({
|
|
62
|
+
document: a,
|
|
63
|
+
variables: d(() => ({
|
|
64
|
+
filters: {
|
|
65
|
+
workspaceId: t,
|
|
66
|
+
search: n || void 0,
|
|
67
|
+
status: r,
|
|
68
|
+
strategyMode: i,
|
|
69
|
+
bucketId: o
|
|
70
|
+
},
|
|
71
|
+
pagination: {
|
|
72
|
+
limit: f,
|
|
73
|
+
offset: 0
|
|
74
|
+
}
|
|
75
|
+
}), [
|
|
76
|
+
t,
|
|
77
|
+
n,
|
|
78
|
+
r,
|
|
79
|
+
i,
|
|
80
|
+
o
|
|
81
|
+
]),
|
|
82
|
+
select: g,
|
|
83
|
+
fallback: h,
|
|
84
|
+
enabled: !!t,
|
|
85
|
+
errorMessage: "Failed to load retrieval profiles"
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function v(e) {
|
|
89
|
+
return l({
|
|
90
|
+
document: i,
|
|
91
|
+
variables: d(() => ({ id: e ?? "" }), [e]),
|
|
92
|
+
select: (e) => e?.getRetrievalProfile ?? null,
|
|
93
|
+
fallback: null,
|
|
94
|
+
enabled: !!e,
|
|
95
|
+
errorMessage: "Failed to load retrieval profile"
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function y() {
|
|
99
|
+
let t = s(), [r, i] = c({
|
|
100
|
+
document: n,
|
|
101
|
+
variables: u((n) => ({ input: e({
|
|
102
|
+
...n,
|
|
103
|
+
workspaceId: t
|
|
104
|
+
}, p) }), [t]),
|
|
105
|
+
select: (e) => e?.createRetrievalProfile,
|
|
106
|
+
errorMessage: "Failed to create retrieval profile"
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
create: r,
|
|
110
|
+
loading: i.loading,
|
|
111
|
+
error: i.error
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function b() {
|
|
115
|
+
let [t, n] = c({
|
|
116
|
+
document: o,
|
|
117
|
+
variables: ({ profileId: t, input: n }) => ({
|
|
118
|
+
id: t,
|
|
119
|
+
input: e(n, m)
|
|
120
|
+
}),
|
|
121
|
+
select: (e) => e?.updateRetrievalProfile,
|
|
122
|
+
errorMessage: "Failed to update retrieval profile"
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
update: t,
|
|
126
|
+
loading: n.loading,
|
|
127
|
+
error: n.error
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function x() {
|
|
131
|
+
let [e, t] = c({
|
|
132
|
+
document: r,
|
|
133
|
+
variables: (e) => ({ id: e }),
|
|
134
|
+
select: (e) => e?.deleteRetrievalProfile,
|
|
135
|
+
errorMessage: "Failed to delete retrieval profile"
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
remove: e,
|
|
139
|
+
loading: t.loading,
|
|
140
|
+
error: t.error
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { y as useCreateRetrievalProfile, x as useDeleteRetrievalProfile, v as useRetrievalProfile, _ as useRetrievalProfiles, b as useUpdateRetrievalProfile };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=useRetrievalProfiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRetrievalProfiles.js","names":[],"sources":["../../../src/botlit/hooks/useRetrievalProfiles.ts"],"sourcesContent":["/**\n * Retrieval Profiles Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listRetrievalProfiles` / `getRetrievalProfile` operations\n * and the create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateRetrievalProfileDocument,\n DeleteRetrievalProfileDocument,\n GetRetrievalProfileDocument,\n ListRetrievalProfilesDocument,\n UpdateRetrievalProfileDocument,\n type CreateRetrievalProfileMutation,\n type DeleteRetrievalProfileMutation,\n type GetRetrievalProfileQuery,\n type ListRetrievalProfilesQuery,\n type UpdateRetrievalProfileMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateRetrievalProfileInput,\n UpdateRetrievalProfileInput,\n} from '../../generated/wspace-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 RetrievalProfileRecord {\n id: string;\n name: string;\n status: string;\n visibility: string;\n strategyMode: string;\n topK: number;\n snippetMaxChars: number;\n minSources: number;\n citationsRequired: boolean;\n showSources: boolean;\n noAnswerIfBelowThreshold: boolean;\n multiHop: string;\n queryRewrite: string;\n reranker: string;\n description?: string | null;\n bucketId?: string | null;\n citationFormat?: string | null;\n hybridWeights?: Record<string, unknown> | null;\n minRelevanceScore?: number | null;\n multiHopDepth?: number | null;\n rerankerModelPolicyId?: string | null;\n testQueries?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface RetrievalProfileFilterVariables {\n search?: string;\n status?: string;\n strategyMode?: string;\n bucketId?: string;\n}\n\n/**\n * `CreateRetrievalProfileInput` minus the `workspaceId` the hook supplies.\n * The service's input is FLAT — there is no nested `strategy`/`grounding`/\n * `thresholds` object anywhere in the schema.\n */\nexport type CreateRetrievalProfileVariables = Omit<\n GraphQLInput<CreateRetrievalProfileInput>,\n 'workspaceId'\n>;\n\nexport interface UpdateRetrievalProfileVariables {\n profileId: string;\n input: GraphQLInput<UpdateRetrievalProfileInput>;\n}\n\nconst CREATE_PROFILE_FIELDS = fieldsOf<CreateRetrievalProfileInput>({\n bucketId: true,\n citationFormat: true,\n citationsRequired: true,\n description: true,\n hybridWeights: true,\n metadata: true,\n minRelevanceScore: true,\n minSources: true,\n multiHop: true,\n multiHopDepth: true,\n name: true,\n noAnswerIfBelowThreshold: true,\n queryRewrite: true,\n reranker: true,\n rerankerModelPolicyId: true,\n showSources: true,\n snippetMaxChars: true,\n status: true,\n strategyMode: true,\n tags: true,\n testQueries: true,\n topK: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_PROFILE_FIELDS = fieldsOf<UpdateRetrievalProfileInput>({\n bucketId: true,\n citationFormat: true,\n citationsRequired: true,\n description: true,\n hybridWeights: true,\n metadata: true,\n minRelevanceScore: true,\n minSources: true,\n multiHop: true,\n multiHopDepth: true,\n name: true,\n noAnswerIfBelowThreshold: true,\n queryRewrite: true,\n reranker: true,\n rerankerModelPolicyId: true,\n showSources: true,\n snippetMaxChars: true,\n status: true,\n strategyMode: true,\n tags: true,\n testQueries: true,\n topK: true,\n visibility: true,\n});\n\nconst NO_PROFILES: RetrievalProfileRecord[] = [];\n\nfunction selectProfiles(data: ListRetrievalProfilesQuery | undefined): RetrievalProfileRecord[] {\n return data?.listRetrievalProfiles ?? NO_PROFILES;\n}\n\nexport const retrievalProfileKeys = {\n all: ['retrieval-profiles'] as const,\n lists: () => [...retrievalProfileKeys.all, 'list'] as const,\n list: (filter?: RetrievalProfileFilterVariables) =>\n [...retrievalProfileKeys.lists(), filter] as const,\n details: () => [...retrievalProfileKeys.all, 'detail'] as const,\n detail: (id: string) => [...retrievalProfileKeys.details(), id] as const,\n};\n\nexport function useRetrievalProfiles(\n filter?: RetrievalProfileFilterVariables\n): QueryResult<RetrievalProfileRecord[]> {\n const workspaceId = useWorkspaceId();\n const { search, status, strategyMode, bucketId } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status,\n strategyMode,\n bucketId,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search, status, strategyMode, bucketId]\n );\n\n return useWorkspaceQuery<ListRetrievalProfilesQuery, RetrievalProfileRecord[]>({\n document: ListRetrievalProfilesDocument,\n variables,\n select: selectProfiles,\n fallback: NO_PROFILES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load retrieval profiles',\n });\n}\n\nexport function useRetrievalProfile(\n profileId: string | undefined\n): QueryResult<RetrievalProfileRecord | null> {\n const variables = useMemo(() => ({ id: profileId ?? '' }), [profileId]);\n\n return useWorkspaceQuery<GetRetrievalProfileQuery, RetrievalProfileRecord | null>({\n document: GetRetrievalProfileDocument,\n variables,\n select: (data) => data?.getRetrievalProfile ?? null,\n fallback: null,\n enabled: Boolean(profileId),\n errorMessage: 'Failed to load retrieval profile',\n });\n}\n\nexport function useCreateRetrievalProfile() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateRetrievalProfileVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_PROFILE_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreateRetrievalProfileMutation,\n CreateRetrievalProfileVariables,\n RetrievalProfileRecord\n >({\n document: CreateRetrievalProfileDocument,\n variables,\n select: (data) => data?.createRetrievalProfile,\n errorMessage: 'Failed to create retrieval profile',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdateRetrievalProfile() {\n const [update, state] = useWorkspaceMutation<\n UpdateRetrievalProfileMutation,\n UpdateRetrievalProfileVariables,\n RetrievalProfileRecord\n >({\n document: UpdateRetrievalProfileDocument,\n variables: ({ profileId, input }) => ({\n id: profileId,\n input: buildMutationInput(input, UPDATE_PROFILE_FIELDS),\n }),\n select: (data) => data?.updateRetrievalProfile,\n errorMessage: 'Failed to update retrieval profile',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeleteRetrievalProfile() {\n const [remove, state] = useWorkspaceMutation<DeleteRetrievalProfileMutation, string, boolean>({\n document: DeleteRetrievalProfileDocument,\n variables: (profileId) => ({ id: profileId }),\n select: (data) => data?.deleteRetrievalProfile,\n errorMessage: 'Failed to delete retrieval profile',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;AAiCA,IAAM,IAAa,KAyDb,IAAwB,EAAsC;CAClE,UAAU;CACV,gBAAgB;CAChB,mBAAmB;CACnB,aAAa;CACb,eAAe;CACf,UAAU;CACV,mBAAmB;CACnB,YAAY;CACZ,UAAU;CACV,eAAe;CACf,MAAM;CACN,0BAA0B;CAC1B,cAAc;CACd,UAAU;CACV,uBAAuB;CACvB,aAAa;CACb,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,MAAM;CACN,aAAa;CACb,MAAM;CACN,YAAY;CACZ,aAAa;CACd,CAAC,EAEI,IAAwB,EAAsC;CAClE,UAAU;CACV,gBAAgB;CAChB,mBAAmB;CACnB,aAAa;CACb,eAAe;CACf,UAAU;CACV,mBAAmB;CACnB,YAAY;CACZ,UAAU;CACV,eAAe;CACf,MAAM;CACN,0BAA0B;CAC1B,cAAc;CACd,UAAU;CACV,uBAAuB;CACvB,aAAa;CACb,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,MAAM;CACN,aAAa;CACb,MAAM;CACN,YAAY;CACb,CAAC,EAEI,IAAwC,EAAE;AAEhD,SAAS,EAAe,GAAwE;AAC9F,QAAO,GAAM,yBAAyB;;AAYxC,SAAgB,EACd,GACuC;CACvC,IAAM,IAAc,GAAgB,EAC9B,EAAE,WAAQ,WAAQ,iBAAc,gBAAa,KAAU,EAAE;AAgB/D,QAAO,EAAwE;EAC7E,UAAU;EACV,WAhBgB,SACT;GACL,SAAS;IACP;IACA,QAAQ,KAAU,KAAA;IAClB;IACA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e, fieldsOf as t } from "./internal/mutationInput.js";
|
|
2
|
+
import { CreateSkillDocument as n, DeleteSkillDocument as r, GetSkillDocument as i, ListSkillsDocument as a, UpdateSkillDocument as o } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { useWorkspaceId as s, useWorkspaceMutation as c, useWorkspaceQuery as l } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as u, useMemo as d } from "react";
|
|
5
|
+
//#region src/botlit/hooks/useSkills.ts
|
|
6
|
+
var f = 100, p = t({
|
|
7
|
+
bucketId: !0,
|
|
8
|
+
capabilityFlags: !0,
|
|
9
|
+
description: !0,
|
|
10
|
+
metadata: !0,
|
|
11
|
+
name: !0,
|
|
12
|
+
promptTemplateId: !0,
|
|
13
|
+
recommendedPolicies: !0,
|
|
14
|
+
retrievalProfileId: !0,
|
|
15
|
+
status: !0,
|
|
16
|
+
tags: !0,
|
|
17
|
+
toolPackDeps: !0,
|
|
18
|
+
toolPolicyId: !0,
|
|
19
|
+
visibility: !0,
|
|
20
|
+
workspaceId: !0
|
|
21
|
+
}), m = t({
|
|
22
|
+
bucketId: !0,
|
|
23
|
+
capabilityFlags: !0,
|
|
24
|
+
description: !0,
|
|
25
|
+
metadata: !0,
|
|
26
|
+
name: !0,
|
|
27
|
+
promptTemplateId: !0,
|
|
28
|
+
recommendedPolicies: !0,
|
|
29
|
+
retrievalProfileId: !0,
|
|
30
|
+
status: !0,
|
|
31
|
+
tags: !0,
|
|
32
|
+
toolPackDeps: !0,
|
|
33
|
+
toolPolicyId: !0,
|
|
34
|
+
visibility: !0
|
|
35
|
+
}), h = [];
|
|
36
|
+
function g(e) {
|
|
37
|
+
return e?.listSkills ?? h;
|
|
38
|
+
}
|
|
39
|
+
function _(e) {
|
|
40
|
+
let t = s(), { search: n, status: r, visibility: i, bucketId: o, promptTemplateId: c, retrievalProfileId: u, toolPolicyId: p } = e ?? {};
|
|
41
|
+
return l({
|
|
42
|
+
document: a,
|
|
43
|
+
variables: d(() => ({
|
|
44
|
+
filters: {
|
|
45
|
+
workspaceId: t,
|
|
46
|
+
search: n || void 0,
|
|
47
|
+
status: r,
|
|
48
|
+
visibility: i,
|
|
49
|
+
bucketId: o,
|
|
50
|
+
promptTemplateId: c,
|
|
51
|
+
retrievalProfileId: u,
|
|
52
|
+
toolPolicyId: p
|
|
53
|
+
},
|
|
54
|
+
pagination: {
|
|
55
|
+
limit: f,
|
|
56
|
+
offset: 0
|
|
57
|
+
}
|
|
58
|
+
}), [
|
|
59
|
+
t,
|
|
60
|
+
n,
|
|
61
|
+
r,
|
|
62
|
+
i,
|
|
63
|
+
o,
|
|
64
|
+
c,
|
|
65
|
+
u,
|
|
66
|
+
p
|
|
67
|
+
]),
|
|
68
|
+
select: g,
|
|
69
|
+
fallback: h,
|
|
70
|
+
enabled: !!t,
|
|
71
|
+
errorMessage: "Failed to load skills"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function v(e) {
|
|
75
|
+
return l({
|
|
76
|
+
document: i,
|
|
77
|
+
variables: d(() => ({ id: e ?? "" }), [e]),
|
|
78
|
+
select: (e) => e?.getSkill ?? null,
|
|
79
|
+
fallback: null,
|
|
80
|
+
enabled: !!e,
|
|
81
|
+
errorMessage: "Failed to load skill"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function y() {
|
|
85
|
+
let t = s(), [r, i] = c({
|
|
86
|
+
document: n,
|
|
87
|
+
variables: u((n) => ({ input: e({
|
|
88
|
+
...n,
|
|
89
|
+
workspaceId: t
|
|
90
|
+
}, p) }), [t]),
|
|
91
|
+
select: (e) => e?.createSkill,
|
|
92
|
+
errorMessage: "Failed to create skill"
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
create: r,
|
|
96
|
+
loading: i.loading,
|
|
97
|
+
error: i.error
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function b() {
|
|
101
|
+
let [t, n] = c({
|
|
102
|
+
document: o,
|
|
103
|
+
variables: ({ skillId: t, input: n }) => ({
|
|
104
|
+
id: t,
|
|
105
|
+
input: e(n, m)
|
|
106
|
+
}),
|
|
107
|
+
select: (e) => e?.updateSkill,
|
|
108
|
+
errorMessage: "Failed to update skill"
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
update: t,
|
|
112
|
+
loading: n.loading,
|
|
113
|
+
error: n.error
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function x() {
|
|
117
|
+
let [e, t] = c({
|
|
118
|
+
document: r,
|
|
119
|
+
variables: (e) => ({ id: e }),
|
|
120
|
+
select: (e) => e?.deleteSkill,
|
|
121
|
+
errorMessage: "Failed to delete skill"
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
remove: e,
|
|
125
|
+
loading: t.loading,
|
|
126
|
+
error: t.error
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { y as useCreateSkill, x as useDeleteSkill, v as useSkill, _ as useSkills, b as useUpdateSkill };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=useSkills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSkills.js","names":[],"sources":["../../../src/botlit/hooks/useSkills.ts"],"sourcesContent":["/**\n * Skills Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listSkills` / `getSkill` operations and the\n * create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateSkillDocument,\n DeleteSkillDocument,\n GetSkillDocument,\n ListSkillsDocument,\n UpdateSkillDocument,\n type CreateSkillMutation,\n type DeleteSkillMutation,\n type GetSkillQuery,\n type ListSkillsQuery,\n type UpdateSkillMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateSkillInput, UpdateSkillInput } from '../../generated/wspace-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 SkillRecord {\n id: string;\n name: string;\n status: string;\n visibility: string;\n description?: string | null;\n bucketId?: string | null;\n promptTemplateId?: string | null;\n retrievalProfileId?: string | null;\n toolPolicyId?: string | null;\n toolPackDeps: string[];\n recommendedPolicies: string[];\n capabilityFlags?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface SkillFilterVariables {\n search?: string;\n status?: string;\n visibility?: string;\n bucketId?: string;\n promptTemplateId?: string;\n retrievalProfileId?: string;\n toolPolicyId?: string;\n}\n\n/** `CreateSkillInput` minus the `workspaceId` the hook supplies. */\nexport type CreateSkillVariables = Omit<GraphQLInput<CreateSkillInput>, 'workspaceId'>;\n\nexport interface UpdateSkillVariables {\n skillId: string;\n input: GraphQLInput<UpdateSkillInput>;\n}\n\nconst CREATE_SKILL_FIELDS = fieldsOf<CreateSkillInput>({\n bucketId: true,\n capabilityFlags: true,\n description: true,\n metadata: true,\n name: true,\n promptTemplateId: true,\n recommendedPolicies: true,\n retrievalProfileId: true,\n status: true,\n tags: true,\n toolPackDeps: true,\n toolPolicyId: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_SKILL_FIELDS = fieldsOf<UpdateSkillInput>({\n bucketId: true,\n capabilityFlags: true,\n description: true,\n metadata: true,\n name: true,\n promptTemplateId: true,\n recommendedPolicies: true,\n retrievalProfileId: true,\n status: true,\n tags: true,\n toolPackDeps: true,\n toolPolicyId: true,\n visibility: true,\n});\n\nconst NO_SKILLS: SkillRecord[] = [];\n\nfunction selectSkills(data: ListSkillsQuery | undefined): SkillRecord[] {\n return data?.listSkills ?? NO_SKILLS;\n}\n\nexport const skillKeys = {\n all: ['skills'] as const,\n lists: () => [...skillKeys.all, 'list'] as const,\n list: (filter?: SkillFilterVariables) => [...skillKeys.lists(), filter] as const,\n details: () => [...skillKeys.all, 'detail'] as const,\n detail: (id: string) => [...skillKeys.details(), id] as const,\n};\n\nexport function useSkills(filter?: SkillFilterVariables): QueryResult<SkillRecord[]> {\n const workspaceId = useWorkspaceId();\n const {\n search,\n status,\n visibility,\n bucketId,\n promptTemplateId,\n retrievalProfileId,\n toolPolicyId,\n } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status,\n visibility,\n bucketId,\n promptTemplateId,\n retrievalProfileId,\n toolPolicyId,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [\n workspaceId,\n search,\n status,\n visibility,\n bucketId,\n promptTemplateId,\n retrievalProfileId,\n toolPolicyId,\n ]\n );\n\n return useWorkspaceQuery<ListSkillsQuery, SkillRecord[]>({\n document: ListSkillsDocument,\n variables,\n select: selectSkills,\n fallback: NO_SKILLS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load skills',\n });\n}\n\nexport function useSkill(skillId: string | undefined): QueryResult<SkillRecord | null> {\n const variables = useMemo(() => ({ id: skillId ?? '' }), [skillId]);\n\n return useWorkspaceQuery<GetSkillQuery, SkillRecord | null>({\n document: GetSkillDocument,\n variables,\n select: (data) => data?.getSkill ?? null,\n fallback: null,\n enabled: Boolean(skillId),\n errorMessage: 'Failed to load skill',\n });\n}\n\nexport function useCreateSkill() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateSkillVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_SKILL_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreateSkillMutation,\n CreateSkillVariables,\n SkillRecord\n >({\n document: CreateSkillDocument,\n variables,\n select: (data) => data?.createSkill,\n errorMessage: 'Failed to create skill',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdateSkill() {\n const [update, state] = useWorkspaceMutation<\n UpdateSkillMutation,\n UpdateSkillVariables,\n SkillRecord\n >({\n document: UpdateSkillDocument,\n variables: ({ skillId, input }) => ({\n id: skillId,\n input: buildMutationInput(input, UPDATE_SKILL_FIELDS),\n }),\n select: (data) => data?.updateSkill,\n errorMessage: 'Failed to update skill',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeleteSkill() {\n const [remove, state] = useWorkspaceMutation<DeleteSkillMutation, string, boolean>({\n document: DeleteSkillDocument,\n variables: (skillId) => ({ id: skillId }),\n select: (data) => data?.deleteSkill,\n errorMessage: 'Failed to delete skill',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;AA8BA,IAAM,IAAa,KA2Cb,IAAsB,EAA2B;CACrD,UAAU;CACV,iBAAiB;CACjB,aAAa;CACb,UAAU;CACV,MAAM;CACN,kBAAkB;CAClB,qBAAqB;CACrB,oBAAoB;CACpB,QAAQ;CACR,MAAM;CACN,cAAc;CACd,cAAc;CACd,YAAY;CACZ,aAAa;CACd,CAAC,EAEI,IAAsB,EAA2B;CACrD,UAAU;CACV,iBAAiB;CACjB,aAAa;CACb,UAAU;CACV,MAAM;CACN,kBAAkB;CAClB,qBAAqB;CACrB,oBAAoB;CACpB,QAAQ;CACR,MAAM;CACN,cAAc;CACd,cAAc;CACd,YAAY;CACb,CAAC,EAEI,IAA2B,EAAE;AAEnC,SAAS,EAAa,GAAkD;AACtE,QAAO,GAAM,cAAc;;AAW7B,SAAgB,EAAU,GAA2D;CACnF,IAAM,IAAc,GAAgB,EAC9B,EACJ,WACA,WACA,eACA,aACA,qBACA,uBACA,oBACE,KAAU,EAAE;AA4BhB,QAAO,EAAkD;EACvD,UAAU;EACV,WA5BgB,SACT;GACL,SAAS;IACP;IACA,QAAQ,KAAU,KAAA;IAClB;IACA;IACA;IACA;IACA;IACA;IACD;GACD,YAAY;IAAE,OAAO;IAAY,QAAQ;IAAG;GAC7C,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CACF;EAKC,QAAQ;EACR,UAAU;EACV,SAAS,EAA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