@swiss-ai-hub/web 0.290.11
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/LICENSE +661 -0
- package/README.md +479 -0
- package/app.config.ts +1 -0
- package/app.vue +52 -0
- package/assets/css/main.css +4 -0
- package/assets/images/logo.png +0 -0
- package/components/Agent/Avatar.vue +40 -0
- package/components/Agent/Card.vue +139 -0
- package/components/Agent/Configuration.vue +20 -0
- package/components/Agent/CreateModal.vue +287 -0
- package/components/Agent/EmptyCard.vue +35 -0
- package/components/Agent/List.vue +85 -0
- package/components/Agent/TemplateCard.vue +58 -0
- package/components/AppLoader.vue +55 -0
- package/components/Chat/Message.vue +90 -0
- package/components/Chat/SourceNodes.vue +120 -0
- package/components/Chat/Thread.vue +134 -0
- package/components/Costs/Table.vue +56 -0
- package/components/Dashboard/Component/BarChart.vue +46 -0
- package/components/Dashboard/Component/LineChart.vue +138 -0
- package/components/Dashboard/Component/Number.vue +31 -0
- package/components/Dashboard/Grid.vue +214 -0
- package/components/Dashboard/Item.vue +75 -0
- package/components/Dashboard/Trend.vue +34 -0
- package/components/Display/List/DisplayList.vue +93 -0
- package/components/Evaluation/Dataset/Card.vue +70 -0
- package/components/Evaluation/Dataset/Create.vue +81 -0
- package/components/Evaluation/Dataset/Edit.vue +132 -0
- package/components/Event/Display/AddMemoryToChatHistoryEvent.vue +60 -0
- package/components/Event/Display/AgentInTheLoopRequestEvent.vue +56 -0
- package/components/Event/Display/AgentInTheLoopResponseEvent.vue +17 -0
- package/components/Event/Display/Base.vue +125 -0
- package/components/Event/Display/BaseRetrieveMemoryEvent.vue +101 -0
- package/components/Event/Display/BaseStoreMemoryEvent.vue +182 -0
- package/components/Event/Display/ChunkEvent.vue +40 -0
- package/components/Event/Display/EmbeddingEvent.vue +25 -0
- package/components/Event/Display/ExceptionEvent.vue +21 -0
- package/components/Event/Display/GuardAcceptEvent.vue +25 -0
- package/components/Event/Display/GuardEvent.vue +17 -0
- package/components/Event/Display/GuardRejectionEvent.vue +25 -0
- package/components/Event/Display/HumanInTheLoopRequestEvent.vue +53 -0
- package/components/Event/Display/HumanInTheLoopResponseEvent.vue +40 -0
- package/components/Event/Display/LLMCostEvent.vue +25 -0
- package/components/Event/Display/LLMEvent.vue +92 -0
- package/components/Event/Display/LimitChatHistoryEvent.vue +60 -0
- package/components/Event/Display/RAGFailureStopEvent.vue +28 -0
- package/components/Event/Display/RAGStartEvent.vue +77 -0
- package/components/Event/Display/RAGSuccessStopEvent.vue +16 -0
- package/components/Event/Display/RawDataContent.vue +69 -0
- package/components/Event/Display/RerankerEvent.vue +39 -0
- package/components/Event/Display/RetrieverEvent.vue +22 -0
- package/components/Event/Display/RouterEvent.vue +54 -0
- package/components/Event/Display/StandaloneQuestionCondenserEvent.vue +38 -0
- package/components/Event/Display/StopEvent.vue +16 -0
- package/components/Event/Display/ThoughtEvent.vue +20 -0
- package/components/Event/Display/ToolEvent.vue +38 -0
- package/components/Event/Display/UnknownEvent.vue +17 -0
- package/components/Event/Display/UserMessageEvent.vue +35 -0
- package/components/Event/List/EventList.vue +249 -0
- package/components/Event/Statistics.vue +49 -0
- package/components/Event/Timeseries.vue +224 -0
- package/components/FormKit/AgentSelector.vue +307 -0
- package/components/FormKit/ChipsInput.vue +62 -0
- package/components/FormKit/DynamicConfiguration.vue +155 -0
- package/components/FormKit/IconSelector.vue +72 -0
- package/components/FormKit/KnowledgeDatabaseSelector.vue +92 -0
- package/components/FormKit/LocaleInput.vue +150 -0
- package/components/FormKit/ModelSelect.vue +110 -0
- package/components/FormKit/Repeater.vue +93 -0
- package/components/FormKit/VectorStoreInput.vue +247 -0
- package/components/Knowledge/Document/List.vue +140 -0
- package/components/Knowledge/Document/Overview.vue +28 -0
- package/components/Knowledge/Document/UploadModal.vue +298 -0
- package/components/Knowledge/Document/WithNodes.vue +105 -0
- package/components/Knowledge/Namespace/Card.vue +108 -0
- package/components/Knowledge/Namespace/CreateModal.vue +203 -0
- package/components/Knowledge/Namespace/EditModal.vue +134 -0
- package/components/Knowledge/Namespace/EmptyCard.vue +35 -0
- package/components/Knowledge/Node/Content.vue +71 -0
- package/components/Markdown/Renderer.vue +87 -0
- package/components/Memory/DetailPage.vue +48 -0
- package/components/Memory/Edit.vue +241 -0
- package/components/Memory/Graph.vue +318 -0
- package/components/Memory/List.vue +155 -0
- package/components/Memory/MemoryManagementPage.vue +178 -0
- package/components/Memory/OpenWebUIContent.vue +96 -0
- package/components/Memory/PageLayout.vue +72 -0
- package/components/Models/ModelDetailsPanel.vue +250 -0
- package/components/Models/NamespaceCard.vue +79 -0
- package/components/Navigation/Left.vue +85 -0
- package/components/Navigation/Top.vue +31 -0
- package/components/Notification/Item.vue +88 -0
- package/components/Notification/NotificationsOverlay.vue +164 -0
- package/components/Process/Card.vue +119 -0
- package/components/Process/Configuration.vue +20 -0
- package/components/Process/CreateModal.vue +276 -0
- package/components/Process/EmptyCard.vue +35 -0
- package/components/Process/Form.vue +153 -0
- package/components/Process/Starts.vue +44 -0
- package/components/Process/Walkthrough/List.vue +162 -0
- package/components/Role/AccessRulesEditor.vue +132 -0
- package/components/Role/Card.vue +68 -0
- package/components/Role/Create.vue +55 -0
- package/components/Role/Edit.vue +82 -0
- package/components/Role/UsageLimitsEditor.vue +225 -0
- package/components/Service/Selection.vue +148 -0
- package/components/Structural/Column.vue +74 -0
- package/components/Structural/Screen.vue +10 -0
- package/components/Structural/Substructure.vue +5 -0
- package/components/Tenant/Switcher.vue +102 -0
- package/components/Thread/Details.vue +135 -0
- package/components/Thread/Hierarchy.vue +136 -0
- package/components/Thread/Info.vue +41 -0
- package/components/Thread/List.vue +136 -0
- package/components/User/Bar.vue +74 -0
- package/components/User/List.vue +86 -0
- package/components/User/RoleChips.vue +83 -0
- package/components/User/Settings.vue +79 -0
- package/components/Workflow/Modal.vue +39 -0
- package/components/Workflow/NodeCard.vue +41 -0
- package/components/Workflow/StartNode.vue +24 -0
- package/components/Workflow/StepNode.vue +27 -0
- package/components/Workflow/StopNode.vue +24 -0
- package/components/Workflow/Visualization.vue +265 -0
- package/components/mdc/MarkdownFigure.vue +9 -0
- package/components/mdc/MarkdownTable.vue +9 -0
- package/components/mdc/ResolveImageComponent.vue +58 -0
- package/composables/agent/useAgentClass.ts +27 -0
- package/composables/agent/useAgentClassInstances.ts +27 -0
- package/composables/agent/useAgentClasses.ts +27 -0
- package/composables/agent/useAgentIconFromThread.ts +8 -0
- package/composables/agent/useAgentInstance.ts +28 -0
- package/composables/agent/useAgentInstanceThreads.ts +76 -0
- package/composables/agent/useAgentInstances.ts +25 -0
- package/composables/agent/useAgentNavigation.ts +35 -0
- package/composables/agent/useCreateAgentInstance.ts +33 -0
- package/composables/agent/useDeleteAgentInstance.ts +31 -0
- package/composables/agent/useUpdateAgentInstance.ts +40 -0
- package/composables/auth/useAuth.ts +54 -0
- package/composables/auth/useAuthProviders.ts +14 -0
- package/composables/chat/useChatCompletions.ts +30 -0
- package/composables/dashboard/useAgentNameFromDashboardWidget.ts +27 -0
- package/composables/dashboard/useDashboardComponent.ts +27 -0
- package/composables/dashboard/useSaveDashboard.ts +21 -0
- package/composables/document/useCreateNamespace.ts +26 -0
- package/composables/document/useDatabases.ts +23 -0
- package/composables/document/useDocument.ts +29 -0
- package/composables/document/useDocumentUrl.ts +20 -0
- package/composables/document/useDocuments.ts +107 -0
- package/composables/document/useNodes.ts +29 -0
- package/composables/document/useSummaryNodes.ts +32 -0
- package/composables/document/useUpdateNamespace.ts +22 -0
- package/composables/evaluation/useCreateDataset.ts +19 -0
- package/composables/evaluation/useDataset.ts +26 -0
- package/composables/evaluation/useDatasets.ts +25 -0
- package/composables/evaluation/useUpdateDataset.ts +23 -0
- package/composables/event/useBasicEventStatistics.ts +83 -0
- package/composables/event/useEventColor.ts +25 -0
- package/composables/event/useEventComponent.ts +87 -0
- package/composables/event/useEventTimeseries.ts +39 -0
- package/composables/event/useEventTimeseriesStats.ts +26 -0
- package/composables/file/useFileUpload.ts +91 -0
- package/composables/file/useSupportedFileTypes.ts +22 -0
- package/composables/form/useCreateInstanceForm.ts +251 -0
- package/composables/form/useFormKitTransform.ts +753 -0
- package/composables/memory/useMemoryCRUD.ts +88 -0
- package/composables/memory/useMemoryFactory.ts +319 -0
- package/composables/memory/useMemorySearchFilter.ts +74 -0
- package/composables/models/useModelsList.ts +24 -0
- package/composables/models/useSingleModel.ts +30 -0
- package/composables/notification/useNotificationPoller.ts +58 -0
- package/composables/notification/useNotifications.ts +57 -0
- package/composables/notification/useUpdateMultipleNotifications.ts +17 -0
- package/composables/notification/useUpdateNotification.ts +17 -0
- package/composables/process/useCreateProcessInstance.ts +32 -0
- package/composables/process/useDeleteProcessInstance.ts +31 -0
- package/composables/process/useProcessClasses.ts +27 -0
- package/composables/process/useProcessInstance.ts +28 -0
- package/composables/process/useProcessInstances.ts +27 -0
- package/composables/process/useProcessWalkthroughs.ts +73 -0
- package/composables/process/useSendProcessStartForm.ts +43 -0
- package/composables/process/useUpdateProcessInstance.ts +40 -0
- package/composables/role/useCreateRole.ts +19 -0
- package/composables/role/useDeleteRole.ts +21 -0
- package/composables/role/useRole.ts +30 -0
- package/composables/role/useRoles.ts +25 -0
- package/composables/role/useUpdateRole.ts +22 -0
- package/composables/suite/useApps.ts +31 -0
- package/composables/suite/useSuite.ts +26 -0
- package/composables/tenant/useActiveTenant.ts +27 -0
- package/composables/tenant/useSysadminNavigation.ts +19 -0
- package/composables/tenant/useTenant.ts +38 -0
- package/composables/tenant/useTenantMemberships.ts +15 -0
- package/composables/tenant/useTenantPath.ts +20 -0
- package/composables/tenant/useTenantPolling.ts +30 -0
- package/composables/tenant/useTenantReady.ts +12 -0
- package/composables/theme/useDarkMode.ts +5 -0
- package/composables/thread/useThread.ts +27 -0
- package/composables/thread/useThreadEvents.ts +91 -0
- package/composables/thread/useThreadUtils.ts +49 -0
- package/composables/thread/useThreads.ts +64 -0
- package/composables/thread/useThreadsInfinite.ts +56 -0
- package/composables/translation/useTranslate.ts +20 -0
- package/composables/useRouteReady.ts +21 -0
- package/composables/useTimeAgo.ts +40 -0
- package/composables/user/useAssignRoleToUser.ts +22 -0
- package/composables/user/useMyUser.ts +25 -0
- package/composables/user/useRevokeRoleFromUser.ts +21 -0
- package/composables/user/useUser.ts +30 -0
- package/composables/user/useUsers.ts +63 -0
- package/composables/utils/useJsonTree.ts +138 -0
- package/formkit.config.ts +44 -0
- package/i18n/locales/de.yaml +815 -0
- package/i18n/locales/en.yaml +804 -0
- package/i18n/locales/fr.yaml +812 -0
- package/i18n/locales/it.yaml +808 -0
- package/layouts/anonymous.vue +8 -0
- package/layouts/default.vue +116 -0
- package/middleware/auth.global.ts +62 -0
- package/nuxt.config.ts +145 -0
- package/package.json +114 -0
- package/pages/[tenant]/index.vue +31 -0
- package/pages/[tenant]/notifications/index.vue +235 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/chat.vue +67 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/configuration.vue +122 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/memories/[memory_id].vue +3 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/memories.vue +20 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/overview.vue +72 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/threads.vue +52 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/workflow.vue +19 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id].vue +63 -0
- package/pages/[tenant]/service/agents/templates.vue +102 -0
- package/pages/[tenant]/service/agents.vue +185 -0
- package/pages/[tenant]/service/datasets/[dataset_id].vue +81 -0
- package/pages/[tenant]/service/datasets.vue +53 -0
- package/pages/[tenant]/service/health/index.vue +3 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace]/[document_id]/nodes.vue +20 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace]/[document_id]/overview.vue +40 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace]/[document_id]/summary.vue +88 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace]/[document_id].vue +48 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace].vue +144 -0
- package/pages/[tenant]/service/knowledge.vue +126 -0
- package/pages/[tenant]/service/models/[model_name].vue +84 -0
- package/pages/[tenant]/service/models.vue +61 -0
- package/pages/[tenant]/service/my-account.vue +117 -0
- package/pages/[tenant]/service/openai/[thread_id]/[display_id]/memories.vue +66 -0
- package/pages/[tenant]/service/openai/[thread_id]/[display_id]/sources.vue +100 -0
- package/pages/[tenant]/service/openai/[thread_id]/[display_id]/tracing.vue +49 -0
- package/pages/[tenant]/service/openai.vue +101 -0
- package/pages/[tenant]/service/organization-memories/graph.vue +97 -0
- package/pages/[tenant]/service/organization-memories/list/[memory_id].vue +3 -0
- package/pages/[tenant]/service/organization-memories/list.vue +150 -0
- package/pages/[tenant]/service/organization-memories.vue +3 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/[process_walkthrough_id].vue +7 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/configuration.vue +106 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/overview.vue +67 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/start.vue +26 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/walkthroughs/[process_walkthrough_id]/overview.vue +14 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/walkthroughs.vue +54 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id].vue +60 -0
- package/pages/[tenant]/service/processes.vue +129 -0
- package/pages/[tenant]/service/roles/[role_id].vue +54 -0
- package/pages/[tenant]/service/roles.vue +84 -0
- package/pages/[tenant]/service/threads/[thread_id]/chat.vue +51 -0
- package/pages/[tenant]/service/threads/[thread_id]/display/[display_id].vue +21 -0
- package/pages/[tenant]/service/threads/[thread_id]/display.vue +29 -0
- package/pages/[tenant]/service/threads/[thread_id]/hierarchy.vue +14 -0
- package/pages/[tenant]/service/threads/[thread_id]/memories/[memory_id].vue +3 -0
- package/pages/[tenant]/service/threads/[thread_id]/memories.vue +19 -0
- package/pages/[tenant]/service/threads/[thread_id]/overview.vue +100 -0
- package/pages/[tenant]/service/threads/[thread_id].vue +54 -0
- package/pages/[tenant]/service/threads.vue +52 -0
- package/pages/[tenant]/service/user-memories/graph.vue +97 -0
- package/pages/[tenant]/service/user-memories/list/[memory_id].vue +3 -0
- package/pages/[tenant]/service/user-memories/list.vue +150 -0
- package/pages/[tenant]/service/user-memories.vue +3 -0
- package/pages/[tenant]/service/users/[user_id].vue +117 -0
- package/pages/[tenant]/service/users.vue +88 -0
- package/pages/auth/callback.vue +52 -0
- package/pages/auth/login.vue +80 -0
- package/pages/auth/renew.vue +24 -0
- package/pages/index.vue +59 -0
- package/pages/select-tenant.vue +76 -0
- package/plugins/0.runtime-config.client.ts +55 -0
- package/plugins/apexcharts.client.ts +5 -0
- package/plugins/api-client.client.ts +38 -0
- package/plugins/dark-mode.client.ts +12 -0
- package/plugins/keycloak-client.ts +41 -0
- package/plugins/oidc-client.ts +78 -0
- package/sdk/client/client/client.gen.ts +237 -0
- package/sdk/client/client/index.ts +24 -0
- package/sdk/client/client/types.gen.ts +213 -0
- package/sdk/client/client/utils.gen.ts +407 -0
- package/sdk/client/client.gen.ts +25 -0
- package/sdk/client/core/auth.gen.ts +42 -0
- package/sdk/client/core/bodySerializer.gen.ts +96 -0
- package/sdk/client/core/params.gen.ts +181 -0
- package/sdk/client/core/pathSerializer.gen.ts +180 -0
- package/sdk/client/core/queryKeySerializer.gen.ts +136 -0
- package/sdk/client/core/serverSentEvents.gen.ts +265 -0
- package/sdk/client/core/types.gen.ts +118 -0
- package/sdk/client/core/utils.gen.ts +143 -0
- package/sdk/client/index.ts +1013 -0
- package/sdk/client/schemas.gen.ts +35395 -0
- package/sdk/client/sdk.gen.ts +3438 -0
- package/sdk/client/transformers.gen.ts +143 -0
- package/sdk/client/types.gen.ts +27567 -0
- package/tailwind.config.mjs +27 -0
- package/themes/aihub-theme.ts +125 -0
- package/types/DashboardWidget.ts +13 -0
- package/types/EventChartInput.ts +7 -0
- package/types/NavItem.ts +6 -0
- package/types/TimeseriesInput.ts +7 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { updateAgentInstance } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useUpdateAgentInstance = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
|
|
6
|
+
const { mutateAsync: updateAgentInstanceMutation, isPending: isUpdating } = useMutation({
|
|
7
|
+
mutation: async ({
|
|
8
|
+
agentClass,
|
|
9
|
+
agentId,
|
|
10
|
+
tenantId,
|
|
11
|
+
configuration,
|
|
12
|
+
}: {
|
|
13
|
+
agentClass: string
|
|
14
|
+
agentId: string
|
|
15
|
+
tenantId: string
|
|
16
|
+
configuration: Record<string, unknown>
|
|
17
|
+
}) => {
|
|
18
|
+
const result = await updateAgentInstance({
|
|
19
|
+
composable: '$fetch',
|
|
20
|
+
path: {
|
|
21
|
+
tenant_id: tenantId,
|
|
22
|
+
agent_class: agentClass,
|
|
23
|
+
agent_id: agentId,
|
|
24
|
+
},
|
|
25
|
+
body: {
|
|
26
|
+
configuration,
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'agent-instances', agentClass, agentId] })
|
|
30
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'agent-instances'] })
|
|
31
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'agent-class-instances', agentClass] })
|
|
32
|
+
return result
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
updateAgentInstance: updateAgentInstanceMutation,
|
|
38
|
+
isUpdating,
|
|
39
|
+
}
|
|
40
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const useAuth = () => {
|
|
2
|
+
const login = (idpHint?: string) => {
|
|
3
|
+
const { $auth } = useNuxtApp()
|
|
4
|
+
const extraQueryParams = idpHint ? { kc_idp_hint: idpHint } : {}
|
|
5
|
+
$auth.signinRedirect({ prompt: 'login', extraQueryParams })
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const logout = async () => {
|
|
9
|
+
const { $auth, $keycloakClient } = useNuxtApp()
|
|
10
|
+
const user = await $auth.getUser()
|
|
11
|
+
|
|
12
|
+
if (user?.refresh_token) {
|
|
13
|
+
await $keycloakClient.logout(user.refresh_token)
|
|
14
|
+
.catch((error: unknown) => console.error('Keycloak session revocation failed:', error))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
await $auth.removeUser()
|
|
18
|
+
navigateTo('/auth/login')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const getUser = async () => {
|
|
22
|
+
const { $auth } = useNuxtApp()
|
|
23
|
+
return await $auth.getUser()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const getToken = async () => {
|
|
27
|
+
const user = await getUser()
|
|
28
|
+
if (!user) {
|
|
29
|
+
throw new Error('User not logged in')
|
|
30
|
+
}
|
|
31
|
+
return user.access_token
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const getBearer = async () => {
|
|
35
|
+
const token = await getToken()
|
|
36
|
+
return `Bearer ${token}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const getHeaders = async (): Promise<Record<string, string>> => {
|
|
40
|
+
const bearer = await getBearer()
|
|
41
|
+
return {
|
|
42
|
+
Authorization: bearer,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
login,
|
|
48
|
+
logout,
|
|
49
|
+
getUser,
|
|
50
|
+
getToken,
|
|
51
|
+
getBearer,
|
|
52
|
+
getHeaders,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getAuthProviders } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
|
|
4
|
+
import type { AuthProviderResponse } from '@core/sdk/client'
|
|
5
|
+
|
|
6
|
+
export const useAuthProviders = defineQuery(() => {
|
|
7
|
+
const { data: authProviders, isPending: isLoading } = useQuery<AuthProviderResponse[]>({
|
|
8
|
+
key: () => ['auth-providers'],
|
|
9
|
+
staleTime: minutesToMilliseconds(5),
|
|
10
|
+
query: async () => await getAuthProviders({ composable: '$fetch' }),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
return { authProviders, isLoading }
|
|
14
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ChatCompletionAssistantMessageParam,
|
|
3
|
+
type ChatCompletionDeveloperMessageParam, type ChatCompletionFunctionMessageParam,
|
|
4
|
+
type ChatCompletionSystemMessageParam, type ChatCompletionToolMessageParam, type ChatCompletionUserMessageParam,
|
|
5
|
+
chatCompletionWithAssistants,
|
|
6
|
+
} from '@core/sdk/client'
|
|
7
|
+
|
|
8
|
+
type MessageType = Array<ChatCompletionDeveloperMessageParam | ChatCompletionSystemMessageParam | ChatCompletionUserMessageParam | ChatCompletionAssistantMessageParam | ChatCompletionToolMessageParam | ChatCompletionFunctionMessageParam>
|
|
9
|
+
|
|
10
|
+
export const useChatCompletions = defineMutation(() => {
|
|
11
|
+
const { mutate: sendMessages } = useMutation({
|
|
12
|
+
mutation: ({ model, messages, threadId, tenantId }: { model: string, messages: MessageType, threadId: string, tenantId: string }) =>
|
|
13
|
+
chatCompletionWithAssistants({
|
|
14
|
+
composable: '$fetch',
|
|
15
|
+
path: { tenant_id: tenantId },
|
|
16
|
+
body: {
|
|
17
|
+
model,
|
|
18
|
+
messages,
|
|
19
|
+
stream: false,
|
|
20
|
+
metadata: {
|
|
21
|
+
thread_id: threadId,
|
|
22
|
+
reconstruct_history: true,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
})
|
|
27
|
+
return {
|
|
28
|
+
sendMessages,
|
|
29
|
+
}
|
|
30
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FullAgentInstanceDto } from '@core/sdk/client'
|
|
2
|
+
import type { DashboardWidget } from '@core/types/DashboardWidget'
|
|
3
|
+
|
|
4
|
+
export const useAgentNameFromDashboardWidget = (widgetData: DashboardWidget) => {
|
|
5
|
+
const { agentInstances } = useAgentInstances()
|
|
6
|
+
const { t } = useI18n()
|
|
7
|
+
const agentName = computed<string>(() => {
|
|
8
|
+
const agentId = widgetData.agent?.agentId
|
|
9
|
+
const agentClass = widgetData.agent?.agentClass
|
|
10
|
+
if (!(agentId && agentClass)) {
|
|
11
|
+
return t('dashboard.all_agents')
|
|
12
|
+
}
|
|
13
|
+
if (agentClass === 'UserAgent') {
|
|
14
|
+
return t('dashboard.users')
|
|
15
|
+
}
|
|
16
|
+
const agent = agentInstances.value?.find((instance: FullAgentInstanceDto) => {
|
|
17
|
+
return instance.agent_id === agentId && instance.agent_class === agentClass
|
|
18
|
+
})
|
|
19
|
+
if (!agent) {
|
|
20
|
+
return t('dashboard.unknown_agent')
|
|
21
|
+
}
|
|
22
|
+
return agent.agent_config.name
|
|
23
|
+
})
|
|
24
|
+
return {
|
|
25
|
+
agentName,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DashboardComponentNumber,
|
|
3
|
+
DashboardComponentLineChart,
|
|
4
|
+
DashboardComponentBarChart,
|
|
5
|
+
} from '#components'
|
|
6
|
+
|
|
7
|
+
export const useDashboardComponent = () => {
|
|
8
|
+
const mapping = {
|
|
9
|
+
DashboardComponentNumber,
|
|
10
|
+
DashboardComponentLineChart,
|
|
11
|
+
DashboardComponentBarChart,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const resolveComponent = (name: string) => {
|
|
15
|
+
if (name in mapping) {
|
|
16
|
+
return mapping[name]
|
|
17
|
+
}
|
|
18
|
+
throw Error(`Unable to resolve component for ${name}`)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const componentNames = Object.keys(mapping)
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
resolveComponent,
|
|
25
|
+
componentNames,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { updateMyDashboard } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
import type { GridStackOptions } from 'gridstack/dist/types'
|
|
4
|
+
|
|
5
|
+
export const useSaveDashboard = () => {
|
|
6
|
+
const queryCache = useQueryCache()
|
|
7
|
+
|
|
8
|
+
const { mutate: saveDashboard } = useMutation({
|
|
9
|
+
mutation: async ({ grid, tenantId }: { grid: GridStackOptions, tenantId: string }) => {
|
|
10
|
+
await updateMyDashboard({
|
|
11
|
+
composable: '$fetch',
|
|
12
|
+
path: { tenant_id: tenantId },
|
|
13
|
+
body: grid,
|
|
14
|
+
})
|
|
15
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'my_user'] })
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
return {
|
|
19
|
+
saveDashboard,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createNamespace, type CreateNamespaceRequest } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useCreateNamespace = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
const { tenantId } = useTenant()
|
|
6
|
+
|
|
7
|
+
return useMutation({
|
|
8
|
+
mutation: (request: CreateNamespaceRequest & { database: string, namespace: string, tenantId: string }) =>
|
|
9
|
+
createNamespace({
|
|
10
|
+
composable: '$fetch',
|
|
11
|
+
body: {
|
|
12
|
+
folder_name: request.folder_name,
|
|
13
|
+
display_name: request.display_name,
|
|
14
|
+
description: request.description,
|
|
15
|
+
},
|
|
16
|
+
path: {
|
|
17
|
+
tenant_id: request.tenantId,
|
|
18
|
+
database: request.database,
|
|
19
|
+
namespace: request.namespace,
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
onSuccess: () => {
|
|
23
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId.value, 'knowledge'] })
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type DatabaseDto, getDatabases } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
|
|
4
|
+
export const useDatabases = defineQuery(() => {
|
|
5
|
+
const { tenantId } = useTenant()
|
|
6
|
+
|
|
7
|
+
const { data: databases, isPending: databasesAreLoading } = useQuery<DatabaseDto[]>({
|
|
8
|
+
key: () => ['tenant', tenantId.value, 'knowledge'],
|
|
9
|
+
staleTime: minutesToMilliseconds(5),
|
|
10
|
+
enabled: useTenantReady(),
|
|
11
|
+
query: async () => {
|
|
12
|
+
return await getDatabases({
|
|
13
|
+
composable: '$fetch',
|
|
14
|
+
path: { tenant_id: tenantId.value! },
|
|
15
|
+
})
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
databases,
|
|
21
|
+
databasesAreLoading,
|
|
22
|
+
}
|
|
23
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type DocumentDto, getDocumentById } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
import { useRoute } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
export const useDocument = defineQuery(() => {
|
|
6
|
+
const route = useRoute()
|
|
7
|
+
const { tenantId } = useTenant()
|
|
8
|
+
|
|
9
|
+
const { data: document, isPending: documentIsLoading } = useQuery<DocumentDto>({
|
|
10
|
+
key: () => ['tenant', tenantId.value, 'knowledge', 'databases', route.params.db as string, 'namespaces', route.params.namespace as string, 'documents', route.params.document_id as string],
|
|
11
|
+
staleTime: minutesToMilliseconds(5),
|
|
12
|
+
enabled: useTenantReady('db', 'namespace', 'document_id'),
|
|
13
|
+
query: async () => {
|
|
14
|
+
return await getDocumentById({
|
|
15
|
+
composable: '$fetch',
|
|
16
|
+
path: {
|
|
17
|
+
tenant_id: tenantId.value!,
|
|
18
|
+
database: route.params.db as string,
|
|
19
|
+
namespace: route.params.namespace as string,
|
|
20
|
+
document_id: route.params.document_id as string,
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
return {
|
|
26
|
+
document,
|
|
27
|
+
documentIsLoading,
|
|
28
|
+
}
|
|
29
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getDocumentUrl } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useDocumentUrl = () => {
|
|
4
|
+
const getDocumentSourceUrl = async (tenantId: string, database: string, namespace: string, documentId: string): Promise<string> => {
|
|
5
|
+
const { url } = await getDocumentUrl({
|
|
6
|
+
composable: '$fetch',
|
|
7
|
+
path: {
|
|
8
|
+
tenant_id: tenantId,
|
|
9
|
+
database,
|
|
10
|
+
namespace,
|
|
11
|
+
document_id: documentId,
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
return url
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
getDocumentSourceUrl,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type DocumentDto, getDocumentsForNamespace } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export interface SortState {
|
|
4
|
+
field: string | null
|
|
5
|
+
order: 1 | -1
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const useDocuments = defineQuery(() => {
|
|
9
|
+
const route = useRoute()
|
|
10
|
+
const { tenantId } = useTenant()
|
|
11
|
+
|
|
12
|
+
const currentPage = ref(1)
|
|
13
|
+
const pageSize = ref(10)
|
|
14
|
+
const searchQuery = ref<string | null>(null)
|
|
15
|
+
const sortState = ref<SortState>({ field: null, order: 1 })
|
|
16
|
+
|
|
17
|
+
const database = computed(() => route.params.db as string)
|
|
18
|
+
const namespace = computed(() => route.params.namespace as string)
|
|
19
|
+
|
|
20
|
+
const documentsQuery = useQuery({
|
|
21
|
+
key: () => ['tenant', tenantId.value, 'knowledge', 'databases', database.value, 'namespaces', namespace.value, 'documents', { page: currentPage.value, size: pageSize.value, search: searchQuery.value, sortField: sortState.value.field, sortOrder: sortState.value.order }],
|
|
22
|
+
enabled: useTenantReady('db', 'namespace'),
|
|
23
|
+
query: async () => {
|
|
24
|
+
const db = database.value
|
|
25
|
+
const ns = namespace.value
|
|
26
|
+
|
|
27
|
+
if (!db || !ns) {
|
|
28
|
+
throw new Error('Database and namespace are required')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const pageToFetch = Math.max(1, currentPage.value)
|
|
32
|
+
|
|
33
|
+
return await getDocumentsForNamespace({
|
|
34
|
+
composable: '$fetch',
|
|
35
|
+
query: {
|
|
36
|
+
page: pageToFetch,
|
|
37
|
+
page_size: pageSize.value,
|
|
38
|
+
search: searchQuery.value ?? undefined,
|
|
39
|
+
sort_field: sortState.value.field ?? undefined,
|
|
40
|
+
sort_order: sortState.value.order,
|
|
41
|
+
},
|
|
42
|
+
path: {
|
|
43
|
+
tenant_id: tenantId.value!,
|
|
44
|
+
database: db,
|
|
45
|
+
namespace: ns,
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
},
|
|
49
|
+
placeholderData: previousData => previousData,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const setPageSize = (newSize: number) => {
|
|
53
|
+
if (newSize > 0) {
|
|
54
|
+
pageSize.value = newSize
|
|
55
|
+
currentPage.value = 1
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const setPage = (newPage: number) => {
|
|
60
|
+
if (newPage > 0) {
|
|
61
|
+
currentPage.value = newPage
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const setSearch = (query: string | null) => {
|
|
66
|
+
searchQuery.value = query?.trim() || null
|
|
67
|
+
currentPage.value = 1
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const setSort = (field: string | null, order: 1 | -1 = 1) => {
|
|
71
|
+
sortState.value = { field, order }
|
|
72
|
+
currentPage.value = 1
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const paginationMeta = computed(() => {
|
|
76
|
+
const data = documentsQuery.state.value?.data
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
total: data?.total ?? 0,
|
|
80
|
+
currentPage: data?.page ?? currentPage.value,
|
|
81
|
+
pageSize: data?.page_size ?? pageSize.value,
|
|
82
|
+
totalPages: data?.total_pages ?? 0,
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const documents = computed(() => documentsQuery.state.value?.data?.documents ?? [] as DocumentDto[])
|
|
87
|
+
|
|
88
|
+
// Only show loading on initial load, not during refetch/search when we have data
|
|
89
|
+
const isLoading = computed(() => documentsQuery.asyncStatus.value === 'loading' && !documentsQuery.state.value?.data)
|
|
90
|
+
const isFetching = computed(() => documentsQuery.asyncStatus.value === 'loading')
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
documents,
|
|
94
|
+
isLoading,
|
|
95
|
+
isFetching,
|
|
96
|
+
pagination: paginationMeta,
|
|
97
|
+
currentPage,
|
|
98
|
+
pageSize,
|
|
99
|
+
searchQuery,
|
|
100
|
+
sortState,
|
|
101
|
+
setPage,
|
|
102
|
+
setPageSize,
|
|
103
|
+
setSearch,
|
|
104
|
+
setSort,
|
|
105
|
+
refetch: documentsQuery.refetch,
|
|
106
|
+
}
|
|
107
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getNodesForDocument, type IngestedNode } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
import { useRoute } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
export const useNodes = defineQuery(() => {
|
|
6
|
+
const route = useRoute()
|
|
7
|
+
const { tenantId } = useTenant()
|
|
8
|
+
|
|
9
|
+
const { data: nodes, isPending: nodesAreLoading } = useQuery<IngestedNode[]>({
|
|
10
|
+
key: () => ['tenant', tenantId.value, 'knowledge', 'databases', route.params.db as string, 'namespaces', route.params.namespace as string, 'documents', route.params.document_id as string, 'nodes'],
|
|
11
|
+
staleTime: minutesToMilliseconds(5),
|
|
12
|
+
enabled: useTenantReady('db', 'namespace', 'document_id'),
|
|
13
|
+
query: async () => {
|
|
14
|
+
return await getNodesForDocument({
|
|
15
|
+
composable: '$fetch',
|
|
16
|
+
path: {
|
|
17
|
+
tenant_id: tenantId.value!,
|
|
18
|
+
database: route.params.db as string,
|
|
19
|
+
namespace: route.params.namespace as string,
|
|
20
|
+
document_id: route.params.document_id as string,
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
return {
|
|
26
|
+
nodes,
|
|
27
|
+
nodesAreLoading,
|
|
28
|
+
}
|
|
29
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSummaryNodesForDocument,
|
|
3
|
+
type NodeSummaryDto,
|
|
4
|
+
} from '@core/sdk/client'
|
|
5
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
6
|
+
import { useRoute } from 'vue-router'
|
|
7
|
+
|
|
8
|
+
export const useSummaryNodes = defineQuery(() => {
|
|
9
|
+
const route = useRoute()
|
|
10
|
+
const { tenantId } = useTenant()
|
|
11
|
+
|
|
12
|
+
const { data: summaryNodes, isPending: summaryNodesAreLoading } = useQuery<NodeSummaryDto[]>({
|
|
13
|
+
key: () => ['tenant', tenantId.value, 'knowledge', 'databases', route.params.db as string, 'namespaces', route.params.namespace as string, 'documents', route.params.document_id as string, 'summaries'],
|
|
14
|
+
staleTime: minutesToMilliseconds(5),
|
|
15
|
+
enabled: useTenantReady('db', 'namespace', 'document_id'),
|
|
16
|
+
query: async () => {
|
|
17
|
+
return await getSummaryNodesForDocument({
|
|
18
|
+
composable: '$fetch',
|
|
19
|
+
path: {
|
|
20
|
+
tenant_id: tenantId.value!,
|
|
21
|
+
database: route.params.db as string,
|
|
22
|
+
namespace: route.params.namespace as string,
|
|
23
|
+
document_id: route.params.document_id as string,
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
return {
|
|
29
|
+
summaryNodes,
|
|
30
|
+
summaryNodesAreLoading,
|
|
31
|
+
}
|
|
32
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { updateNamespace, type UpdateNamespaceRequest } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useUpdateNamespace = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
const { tenantId } = useTenant()
|
|
6
|
+
|
|
7
|
+
return useMutation({
|
|
8
|
+
mutation: ({ database, namespace, payload, tenantId }: { database: string, namespace: string, payload: Ref<UpdateNamespaceRequest>, tenantId: string }) =>
|
|
9
|
+
updateNamespace({
|
|
10
|
+
composable: '$fetch',
|
|
11
|
+
path: {
|
|
12
|
+
tenant_id: tenantId,
|
|
13
|
+
database,
|
|
14
|
+
namespace,
|
|
15
|
+
},
|
|
16
|
+
body: payload,
|
|
17
|
+
}),
|
|
18
|
+
onSuccess: () => {
|
|
19
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId.value, 'knowledge'] })
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createDataset as createDatasetCall, type DatasetCreate } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useCreateDataset = () => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
|
|
6
|
+
const { mutateAsync: createDataset } = useMutation({
|
|
7
|
+
mutation: async ({ dataset, tenantId }: { dataset: DatasetCreate, tenantId: string }) => {
|
|
8
|
+
await createDatasetCall({
|
|
9
|
+
composable: '$fetch',
|
|
10
|
+
path: { tenant_id: tenantId },
|
|
11
|
+
body: dataset,
|
|
12
|
+
})
|
|
13
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'datasets'] })
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
return {
|
|
17
|
+
createDataset,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Dataset, getDataset } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
|
|
4
|
+
export const useDataset = defineQuery(() => {
|
|
5
|
+
const route = useRoute()
|
|
6
|
+
const { tenantId } = useTenant()
|
|
7
|
+
|
|
8
|
+
const { data: dataset, isPending: datasetIsLoading } = useQuery<Dataset>({
|
|
9
|
+
key: () => ['tenant', tenantId.value, 'datasets', route.params.dataset_id as string],
|
|
10
|
+
staleTime: minutesToMilliseconds(5),
|
|
11
|
+
enabled: useTenantReady('dataset_id'),
|
|
12
|
+
query: async () => {
|
|
13
|
+
return await getDataset({
|
|
14
|
+
composable: '$fetch',
|
|
15
|
+
path: {
|
|
16
|
+
tenant_id: tenantId.value!,
|
|
17
|
+
dataset_id: route.params.dataset_id as string,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
return {
|
|
23
|
+
dataset,
|
|
24
|
+
datasetIsLoading,
|
|
25
|
+
}
|
|
26
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDatasets,
|
|
3
|
+
type MinimalDataset,
|
|
4
|
+
} from '@core/sdk/client'
|
|
5
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
6
|
+
|
|
7
|
+
export const useDatasets = defineQuery(() => {
|
|
8
|
+
const { tenantId } = useTenant()
|
|
9
|
+
|
|
10
|
+
const { data: datasets, isPending: datasetsAreLoading } = useQuery<MinimalDataset[]>({
|
|
11
|
+
key: () => ['tenant', tenantId.value, 'datasets'],
|
|
12
|
+
staleTime: minutesToMilliseconds(5),
|
|
13
|
+
enabled: useTenantReady(),
|
|
14
|
+
query: async () => {
|
|
15
|
+
return await getDatasets({
|
|
16
|
+
composable: '$fetch',
|
|
17
|
+
path: { tenant_id: tenantId.value! },
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
return {
|
|
22
|
+
datasets,
|
|
23
|
+
datasetsAreLoading,
|
|
24
|
+
}
|
|
25
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type DatasetUpdate, updateDataset as updateDatasetCall } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useUpdateDataset = () => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
const route = useRoute()
|
|
6
|
+
|
|
7
|
+
const { mutateAsync: updateDataset } = useMutation({
|
|
8
|
+
mutation: async ({ dataset, tenantId }: { dataset: DatasetUpdate, tenantId: string }) => {
|
|
9
|
+
await updateDatasetCall({
|
|
10
|
+
composable: '$fetch',
|
|
11
|
+
body: dataset,
|
|
12
|
+
path: {
|
|
13
|
+
tenant_id: tenantId,
|
|
14
|
+
dataset_id: route.params.dataset_id as string,
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'datasets'] })
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
return {
|
|
21
|
+
updateDataset,
|
|
22
|
+
}
|
|
23
|
+
}
|