@burdenoff/microfe-botmanor 2026.1108.1 → 2026.1109.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botlit/BotlitRoutes.d.ts +2 -0
- package/dist/botlit/BotlitRoutes.js +40 -52
- package/dist/botlit/BotlitRoutes.js.map +1 -1
- package/dist/botlit/BotmanorRoot.d.ts +3 -0
- package/dist/botlit/BotmanorRoot.js +1 -2
- package/dist/botlit/BotmanorRoot.js.map +1 -1
- package/dist/botlit/BotmanorRootInner.d.ts +3 -0
- package/dist/botlit/BotmanorRootInner.js +9 -10
- package/dist/botlit/BotmanorRootInner.js.map +1 -1
- package/dist/botlit/components/AgentApprovalPanel.d.ts +20 -0
- package/dist/botlit/components/AgentApprovalPanel.js +49 -50
- package/dist/botlit/components/AgentApprovalPanel.js.map +1 -1
- package/dist/botlit/components/AiOperationsPanel.d.ts +14 -0
- package/dist/botlit/components/AiOperationsPanel.js +54 -55
- package/dist/botlit/components/AiOperationsPanel.js.map +1 -1
- package/dist/botlit/components/AssistantChannelPanel.d.ts +3 -0
- package/dist/botlit/components/AssistantChannelPanel.js +12 -13
- package/dist/botlit/components/AssistantChannelPanel.js.map +1 -1
- package/dist/botlit/components/AssistantRuntimeSetupPanel.d.ts +4 -0
- package/dist/botlit/components/AssistantRuntimeSetupPanel.js +14 -14
- package/dist/botlit/components/AssistantRuntimeSetupPanel.js.map +1 -1
- package/dist/botlit/components/AssistantWebsitePanel.d.ts +5 -0
- package/dist/botlit/components/AssistantWebsitePanel.js +15 -16
- package/dist/botlit/components/AssistantWebsitePanel.js.map +1 -1
- package/dist/botlit/components/Badge.d.ts +9 -0
- package/dist/botlit/components/Badge.js +1 -2
- package/dist/botlit/components/Badge.js.map +1 -1
- package/dist/botlit/components/Button.d.ts +10 -0
- package/dist/botlit/components/Button.js +1 -2
- package/dist/botlit/components/Button.js.map +1 -1
- package/dist/botlit/components/Card.d.ts +16 -0
- package/dist/botlit/components/Card.js +1 -2
- package/dist/botlit/components/Card.js.map +1 -1
- package/dist/botlit/components/ChannelSelectorSheet.d.ts +23 -0
- package/dist/botlit/components/ChannelSelectorSheet.js +1 -2
- package/dist/botlit/components/ChannelSelectorSheet.js.map +1 -1
- package/dist/botlit/components/EmptyState.d.ts +12 -0
- package/dist/botlit/components/EmptyState.js +1 -2
- package/dist/botlit/components/EmptyState.js.map +1 -1
- package/dist/botlit/components/ErrorState.d.ts +10 -0
- package/dist/botlit/components/ErrorState.js +5 -6
- package/dist/botlit/components/ErrorState.js.map +1 -1
- package/dist/botlit/components/Input.d.ts +27 -0
- package/dist/botlit/components/Input.js +1 -2
- package/dist/botlit/components/Input.js.map +1 -1
- package/dist/botlit/components/KnowledgeSourceImportPanel.d.ts +3 -0
- package/dist/botlit/components/KnowledgeSourceImportPanel.js +12 -13
- package/dist/botlit/components/KnowledgeSourceImportPanel.js.map +1 -1
- package/dist/botlit/components/ModelRegistrationPanel.d.ts +5 -0
- package/dist/botlit/components/ModelRegistrationPanel.js +1 -2
- package/dist/botlit/components/ModelRegistrationPanel.js.map +1 -1
- package/dist/botlit/components/PageLayout.d.ts +12 -0
- package/dist/botlit/components/PageLayout.js +1 -2
- package/dist/botlit/components/PageLayout.js.map +1 -1
- package/dist/botlit/components/QuotaExhaustedDialog.d.ts +9 -0
- package/dist/botlit/components/QuotaExhaustedDialog.js +1 -2
- package/dist/botlit/components/QuotaExhaustedDialog.js.map +1 -1
- package/dist/botlit/components/RetentionStatusPanel.d.ts +2 -0
- package/dist/botlit/components/RetentionStatusPanel.js +18 -19
- package/dist/botlit/components/RetentionStatusPanel.js.map +1 -1
- package/dist/botlit/components/RouteLoader.d.ts +23 -0
- package/dist/botlit/components/RouteLoader.js +1 -2
- package/dist/botlit/components/RouteLoader.js.map +1 -1
- package/dist/botlit/components/VersionHistoryPanel.d.ts +12 -0
- package/dist/botlit/components/VersionHistoryPanel.js +23 -24
- package/dist/botlit/components/VersionHistoryPanel.js.map +1 -1
- package/dist/botlit/components/WorkspaceRequired.d.ts +18 -0
- package/dist/botlit/components/WorkspaceRequired.js +1 -2
- package/dist/botlit/components/WorkspaceRequired.js.map +1 -1
- package/dist/botlit/components/index.d.ts +14 -0
- package/dist/botlit/hooks/index.d.ts +35 -0
- package/dist/botlit/hooks/index.js +16 -16
- package/dist/botlit/hooks/internal/mutationInput.d.ts +56 -0
- package/dist/botlit/hooks/internal/mutationInput.js +1 -2
- package/dist/botlit/hooks/internal/mutationInput.js.map +1 -1
- package/dist/botlit/hooks/internal/workspaceGateway.d.ts +54 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +17 -19
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
- package/dist/botlit/hooks/useA2A.d.ts +104 -0
- package/dist/botlit/hooks/useA2A.js +45 -45
- package/dist/botlit/hooks/useA2A.js.map +1 -1
- package/dist/botlit/hooks/useAgentApprovals.d.ts +62 -0
- package/dist/botlit/hooks/useAgentApprovals.js +38 -39
- package/dist/botlit/hooks/useAgentApprovals.js.map +1 -1
- package/dist/botlit/hooks/useAgents.d.ts +105 -0
- package/dist/botlit/hooks/useAgents.js +53 -54
- package/dist/botlit/hooks/useAgents.js.map +1 -1
- package/dist/botlit/hooks/useAiOperations.d.ts +95 -0
- package/dist/botlit/hooks/useAiOperations.js +20 -19
- package/dist/botlit/hooks/useAiOperations.js.map +1 -1
- package/dist/botlit/hooks/useAssistantChannels.d.ts +16 -0
- package/dist/botlit/hooks/useAssistantChannels.js +1 -2
- package/dist/botlit/hooks/useAssistantChannels.js.map +1 -1
- package/dist/botlit/hooks/useAssistantRuntimeSetup.d.ts +17 -0
- package/dist/botlit/hooks/useAssistantRuntimeSetup.js +1 -2
- package/dist/botlit/hooks/useAssistantRuntimeSetup.js.map +1 -1
- package/dist/botlit/hooks/useAssistantWebsites.d.ts +18 -0
- package/dist/botlit/hooks/useAssistantWebsites.js +1 -2
- package/dist/botlit/hooks/useAssistantWebsites.js.map +1 -1
- package/dist/botlit/hooks/useBotWorkflow.d.ts +22 -0
- package/dist/botlit/hooks/useBotWorkflow.js +1 -2
- package/dist/botlit/hooks/useBotWorkflow.js.map +1 -1
- package/dist/botlit/hooks/useBots.d.ts +68 -0
- package/dist/botlit/hooks/useBots.js +32 -33
- package/dist/botlit/hooks/useBots.js.map +1 -1
- package/dist/botlit/hooks/useBuckets.d.ts +62 -0
- package/dist/botlit/hooks/useBuckets.js +91 -58
- package/dist/botlit/hooks/useBuckets.js.map +1 -1
- package/dist/botlit/hooks/useChannels.d.ts +87 -0
- package/dist/botlit/hooks/useChannels.js +73 -73
- package/dist/botlit/hooks/useChannels.js.map +1 -1
- package/dist/botlit/hooks/useExecutions.d.ts +87 -0
- package/dist/botlit/hooks/useExecutions.js +37 -37
- package/dist/botlit/hooks/useExecutions.js.map +1 -1
- package/dist/botlit/hooks/useKnowledgeBases.d.ts +79 -0
- package/dist/botlit/hooks/useKnowledgeBases.js +40 -39
- package/dist/botlit/hooks/useKnowledgeBases.js.map +1 -1
- package/dist/botlit/hooks/useKnowledgeSourceImports.d.ts +21 -0
- package/dist/botlit/hooks/useKnowledgeSourceImports.js +1 -2
- package/dist/botlit/hooks/useKnowledgeSourceImports.js.map +1 -1
- package/dist/botlit/hooks/useLLMProviders.d.ts +66 -0
- package/dist/botlit/hooks/useLLMProviders.js +25 -26
- package/dist/botlit/hooks/useLLMProviders.js.map +1 -1
- package/dist/botlit/hooks/useMCPServers.d.ts +71 -0
- package/dist/botlit/hooks/useMCPServers.js +40 -38
- package/dist/botlit/hooks/useMCPServers.js.map +1 -1
- package/dist/botlit/hooks/usePolicies.d.ts +60 -0
- package/dist/botlit/hooks/usePolicies.js +49 -49
- package/dist/botlit/hooks/usePolicies.js.map +1 -1
- package/dist/botlit/hooks/usePromptTemplates.d.ts +88 -0
- package/dist/botlit/hooks/usePromptTemplates.js +57 -57
- package/dist/botlit/hooks/usePromptTemplates.js.map +1 -1
- package/dist/botlit/hooks/useRetention.d.ts +26 -0
- package/dist/botlit/hooks/useRetention.js +3 -3
- package/dist/botlit/hooks/useRetention.js.map +1 -1
- package/dist/botlit/hooks/useRetrievalProfiles.d.ts +75 -0
- package/dist/botlit/hooks/useRetrievalProfiles.js +47 -47
- package/dist/botlit/hooks/useRetrievalProfiles.js.map +1 -1
- package/dist/botlit/hooks/useSkills.d.ts +64 -0
- package/dist/botlit/hooks/useSkills.js +53 -53
- package/dist/botlit/hooks/useSkills.js.map +1 -1
- package/dist/botlit/hooks/useStore.d.ts +112 -0
- package/dist/botlit/hooks/useStore.js +55 -55
- package/dist/botlit/hooks/useStore.js.map +1 -1
- package/dist/botlit/hooks/useUserPlatformConnection.d.ts +80 -0
- package/dist/botlit/hooks/useUserPlatformConnection.js +19 -19
- package/dist/botlit/hooks/useUserPlatformConnection.js.map +1 -1
- package/dist/botlit/index.d.ts +15 -0
- package/dist/botlit/index.js +11 -11
- package/dist/botlit/pages/A2AAgentDetailPage.d.ts +6 -0
- package/dist/botlit/pages/A2AAgentDetailPage.js +171 -178
- package/dist/botlit/pages/A2AAgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/A2ARegistryPage.d.ts +2 -0
- package/dist/botlit/pages/A2ARegistryPage.js +25 -26
- package/dist/botlit/pages/A2ARegistryPage.js.map +1 -1
- package/dist/botlit/pages/AgentApprovalsPage.d.ts +2 -0
- package/dist/botlit/pages/AgentApprovalsPage.js +32 -33
- package/dist/botlit/pages/AgentApprovalsPage.js.map +1 -1
- package/dist/botlit/pages/AgentBuilderPage.d.ts +2 -0
- package/dist/botlit/pages/AgentBuilderPage.js +59 -60
- package/dist/botlit/pages/AgentBuilderPage.js.map +1 -1
- package/dist/botlit/pages/AgentDetailPage.d.ts +2 -0
- package/dist/botlit/pages/AgentDetailPage.js +83 -84
- package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/AgentsListPage.d.ts +2 -0
- package/dist/botlit/pages/AgentsListPage.js +71 -72
- package/dist/botlit/pages/AgentsListPage.js.map +1 -1
- package/dist/botlit/pages/AiOperationsPage.d.ts +2 -0
- package/dist/botlit/pages/AiOperationsPage.js +52 -53
- package/dist/botlit/pages/AiOperationsPage.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.d.ts +7 -0
- package/dist/botlit/pages/BotChannelsTab.js +120 -122
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/BotDetailPage.d.ts +7 -0
- package/dist/botlit/pages/BotDetailPage.js +353 -358
- package/dist/botlit/pages/BotDetailPage.js.map +1 -1
- package/dist/botlit/pages/BotWorkflowTab.d.ts +11 -0
- package/dist/botlit/pages/BotWorkflowTab.js +20 -21
- package/dist/botlit/pages/BotWorkflowTab.js.map +1 -1
- package/dist/botlit/pages/BotsListPage.d.ts +2 -0
- package/dist/botlit/pages/BotsListPage.js +52 -53
- package/dist/botlit/pages/BotsListPage.js.map +1 -1
- package/dist/botlit/pages/BucketDetailPage.d.ts +2 -0
- package/dist/botlit/pages/BucketDetailPage.js +251 -0
- package/dist/botlit/pages/BucketDetailPage.js.map +1 -0
- package/dist/botlit/pages/BucketsPage.d.ts +2 -0
- package/dist/botlit/pages/BucketsPage.js +260 -261
- package/dist/botlit/pages/BucketsPage.js.map +1 -1
- package/dist/botlit/pages/ChannelDetailPage.d.ts +6 -0
- package/dist/botlit/pages/ChannelDetailPage.js +97 -96
- package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
- package/dist/botlit/pages/ChannelRoutesPage.d.ts +2 -0
- package/dist/botlit/pages/ChannelRoutesPage.js +23 -24
- package/dist/botlit/pages/ChannelRoutesPage.js.map +1 -1
- package/dist/botlit/pages/ChannelsPage.d.ts +2 -0
- package/dist/botlit/pages/ChannelsPage.js +44 -45
- package/dist/botlit/pages/ChannelsPage.js.map +1 -1
- package/dist/botlit/pages/ChatPage.d.ts +1 -0
- package/dist/botlit/pages/ChatPage.js +10 -11
- package/dist/botlit/pages/ChatPage.js.map +1 -1
- package/dist/botlit/pages/DashboardPage.d.ts +2 -0
- package/dist/botlit/pages/DashboardPage.js +37 -38
- package/dist/botlit/pages/DashboardPage.js.map +1 -1
- package/dist/botlit/pages/ExecutionDetailPage.d.ts +2 -0
- package/dist/botlit/pages/ExecutionDetailPage.js +47 -48
- package/dist/botlit/pages/ExecutionDetailPage.js.map +1 -1
- package/dist/botlit/pages/ExecutionsPage.d.ts +2 -0
- package/dist/botlit/pages/ExecutionsPage.js +72 -70
- package/dist/botlit/pages/ExecutionsPage.js.map +1 -1
- package/dist/botlit/pages/InstalledPackagesPage.d.ts +2 -0
- package/dist/botlit/pages/InstalledPackagesPage.js +77 -78
- package/dist/botlit/pages/InstalledPackagesPage.js.map +1 -1
- package/dist/botlit/pages/KnowledgeBaseDetailPage.d.ts +6 -0
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js +171 -181
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js.map +1 -1
- package/dist/botlit/pages/KnowledgeBasesPage.d.ts +2 -0
- package/dist/botlit/pages/KnowledgeBasesPage.js +30 -31
- package/dist/botlit/pages/KnowledgeBasesPage.js.map +1 -1
- package/dist/botlit/pages/MCPServerDetailPage.d.ts +6 -0
- package/dist/botlit/pages/MCPServerDetailPage.js +82 -83
- package/dist/botlit/pages/MCPServerDetailPage.js.map +1 -1
- package/dist/botlit/pages/MCPServersPage.d.ts +2 -0
- package/dist/botlit/pages/MCPServersPage.js +54 -55
- package/dist/botlit/pages/MCPServersPage.js.map +1 -1
- package/dist/botlit/pages/PoliciesPage.d.ts +2 -0
- package/dist/botlit/pages/PoliciesPage.js +25 -26
- package/dist/botlit/pages/PoliciesPage.js.map +1 -1
- package/dist/botlit/pages/PolicyDetailPage.d.ts +6 -0
- package/dist/botlit/pages/PolicyDetailPage.js +257 -259
- package/dist/botlit/pages/PolicyDetailPage.js.map +1 -1
- package/dist/botlit/pages/PromptStudioPage.d.ts +2 -0
- package/dist/botlit/pages/PromptStudioPage.js +35 -35
- package/dist/botlit/pages/PromptStudioPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplateDetailPage.d.ts +6 -0
- package/dist/botlit/pages/PromptTemplateDetailPage.js +363 -362
- package/dist/botlit/pages/PromptTemplateDetailPage.js.map +1 -1
- package/dist/botlit/pages/PromptTemplatesPage.d.ts +2 -0
- package/dist/botlit/pages/PromptTemplatesPage.js +26 -27
- package/dist/botlit/pages/PromptTemplatesPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfileDetailPage.d.ts +6 -0
- package/dist/botlit/pages/RetrievalProfileDetailPage.js +150 -158
- package/dist/botlit/pages/RetrievalProfileDetailPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfilesPage.d.ts +2 -0
- package/dist/botlit/pages/RetrievalProfilesPage.js +24 -25
- package/dist/botlit/pages/RetrievalProfilesPage.js.map +1 -1
- package/dist/botlit/pages/SettingsPage.d.ts +2 -0
- package/dist/botlit/pages/SettingsPage.js +124 -125
- package/dist/botlit/pages/SettingsPage.js.map +1 -1
- package/dist/botlit/pages/SkillDetailPage.d.ts +6 -0
- package/dist/botlit/pages/SkillDetailPage.js +216 -217
- package/dist/botlit/pages/SkillDetailPage.js.map +1 -1
- package/dist/botlit/pages/SkillsPage.d.ts +2 -0
- package/dist/botlit/pages/SkillsPage.js +24 -25
- package/dist/botlit/pages/SkillsPage.js.map +1 -1
- package/dist/botlit/pages/StorePackageDetailPage.d.ts +2 -0
- package/dist/botlit/pages/StorePackageDetailPage.js +38 -39
- package/dist/botlit/pages/StorePackageDetailPage.js.map +1 -1
- package/dist/botlit/pages/StorePage.d.ts +2 -0
- package/dist/botlit/pages/StorePage.js +135 -136
- package/dist/botlit/pages/StorePage.js.map +1 -1
- package/dist/botlit/pages/index.d.ts +38 -0
- package/dist/botlit/permissions/PermissionRequired.d.ts +20 -0
- package/dist/botlit/permissions/PermissionRequired.js +10 -11
- package/dist/botlit/permissions/PermissionRequired.js.map +1 -1
- package/dist/botlit/permissions/botmanorPermissions.d.ts +82 -0
- package/dist/botlit/permissions/botmanorPermissions.js +1 -2
- package/dist/botlit/permissions/botmanorPermissions.js.map +1 -1
- package/dist/botlit/permissions/index.d.ts +7 -0
- package/dist/botlit/permissions/index.js +4 -3
- package/dist/botlit/permissions/useBotmanorPermissions.d.ts +41 -0
- package/dist/botlit/permissions/useBotmanorPermissions.js +1 -2
- package/dist/botlit/permissions/useBotmanorPermissions.js.map +1 -1
- package/dist/botlit/providers/BotlitProvider.d.ts +14 -0
- package/dist/botlit/providers/BotlitProvider.js +3 -3
- package/dist/botlit/providers/BotlitProvider.js.map +1 -1
- package/dist/botlit/store/botlitStore.d.ts +85 -0
- package/dist/botlit/store/botlitStore.js +1 -2
- package/dist/botlit/store/botlitStore.js.map +1 -1
- package/dist/botlit/store/renamedKeyStorage.d.ts +13 -0
- package/dist/botlit/store/renamedKeyStorage.js +1 -2
- package/dist/botlit/store/renamedKeyStorage.js.map +1 -1
- package/dist/botlit/types/index.d.ts +1008 -0
- package/dist/botlit/utils/cn.d.ts +2 -0
- package/dist/botlit/utils/cn.js +1 -2
- package/dist/botlit/utils/cn.js.map +1 -1
- package/dist/botlit/utils/embedding-models.d.ts +9 -0
- package/dist/botlit/utils/embedding-models.js +1 -2
- package/dist/botlit/utils/embedding-models.js.map +1 -1
- package/dist/botlit/utils/errors.d.ts +19 -0
- package/dist/botlit/utils/errors.js +1 -2
- package/dist/botlit/utils/errors.js.map +1 -1
- package/dist/botlit/utils/formatters.d.ts +38 -0
- package/dist/botlit/utils/formatters.js +0 -1
- package/dist/botlit/utils/formatters.js.map +1 -1
- package/dist/botlit/utils/navigation.d.ts +19 -0
- package/dist/botlit/utils/navigation.js +1 -2
- package/dist/botlit/utils/navigation.js.map +1 -1
- package/dist/botlit/utils/policyConfig.d.ts +68 -0
- package/dist/botlit/utils/policyConfig.js +2 -3
- package/dist/botlit/utils/policyConfig.js.map +1 -1
- package/dist/botlit/utils/unions.d.ts +25 -0
- package/dist/botlit/utils/unions.js +1 -2
- package/dist/botlit/utils/unions.js.map +1 -1
- package/dist/dev/App.d.ts +2 -0
- package/dist/dev/main.d.ts +0 -0
- package/dist/generated/global-operations.d.ts +197 -0
- package/dist/generated/global-operations.js +1 -2
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.d.ts +27678 -0
- package/dist/generated/global-types.js +1 -2
- package/dist/generated/global-types.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +5489 -0
- package/dist/generated/wspace-operations.js +88 -84
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +152017 -0
- package/dist/generated/wspace-types.js +1 -2
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -6
- package/dist/shared/hooks/useTr.d.ts +16 -0
- package/dist/shared/hooks/useTr.js +1 -2
- package/dist/shared/hooks/useTr.js.map +1 -1
- package/dist/stories/Badge.stories.d.ts +11 -0
- package/dist/stories/Button.stories.d.ts +13 -0
- package/dist/stories/EmptyState.stories.d.ts +8 -0
- package/dist/stories/StatusBadge.stories.d.ts +9 -0
- package/dist/test/fixtures.d.ts +39 -0
- package/dist/test/happydom.d.ts +1 -0
- package/dist/test/renderPage.d.ts +18 -0
- package/dist/test/setup.d.ts +9 -0
- package/dist/utils/nativeBridge.d.ts +2 -0
- package/dist/utils/nativeBridge.js +1 -2
- package/package.json +87 -60
- package/dist/botlit/hooks/useConversations.js +0 -64
- package/dist/botlit/hooks/useConversations.js.map +0 -1
|
@@ -3,7 +3,7 @@ import { buildMutationInput as t, fieldsOf as n } from "./internal/mutationInput
|
|
|
3
3
|
import { useCallback as r, useEffect as i, useMemo as a, useState as o } from "react";
|
|
4
4
|
import { gql as s } from "@apollo/client";
|
|
5
5
|
import { useGatewayClient as c } from "@burdenoff/fe-libs/shared/graphql";
|
|
6
|
-
|
|
6
|
+
// src/botlit/hooks/useBots.ts
|
|
7
7
|
var l = s`
|
|
8
8
|
query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {
|
|
9
9
|
listBotApps(filters: $filters, pagination: $pagination) {
|
|
@@ -125,7 +125,7 @@ function h(e) {
|
|
|
125
125
|
return e;
|
|
126
126
|
}
|
|
127
127
|
function g(e, t) {
|
|
128
|
-
if (
|
|
128
|
+
if (e || t) return {
|
|
129
129
|
workspaceId: e,
|
|
130
130
|
search: t?.search,
|
|
131
131
|
status: t?.status?.[0],
|
|
@@ -141,21 +141,21 @@ function _(t) {
|
|
|
141
141
|
offset: 0
|
|
142
142
|
}
|
|
143
143
|
}), [t, s]), y = r(async () => {
|
|
144
|
-
if (!s)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
144
|
+
if (!s) d([]);
|
|
145
|
+
else {
|
|
146
|
+
p(!0), _(void 0);
|
|
147
|
+
try {
|
|
148
|
+
let e = await n.query({
|
|
149
|
+
query: l,
|
|
150
|
+
variables: v,
|
|
151
|
+
fetchPolicy: "network-only"
|
|
152
|
+
});
|
|
153
|
+
d(e.data?.listBotApps ?? []);
|
|
154
|
+
} catch (e) {
|
|
155
|
+
_(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load bots"));
|
|
156
|
+
} finally {
|
|
157
|
+
p(!1);
|
|
158
|
+
}
|
|
159
159
|
}
|
|
160
160
|
}, [
|
|
161
161
|
n,
|
|
@@ -173,21 +173,21 @@ function _(t) {
|
|
|
173
173
|
}
|
|
174
174
|
function v(e) {
|
|
175
175
|
let t = h(c("workspace")), [n, a] = o(null), [s, l] = o(!1), [d, f] = o(), p = r(async () => {
|
|
176
|
-
if (!e)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
176
|
+
if (!e) a(null);
|
|
177
|
+
else {
|
|
178
|
+
l(!0), f(void 0);
|
|
179
|
+
try {
|
|
180
|
+
let n = await t.query({
|
|
181
|
+
query: u,
|
|
182
|
+
variables: { id: e },
|
|
183
|
+
fetchPolicy: "network-only"
|
|
184
|
+
});
|
|
185
|
+
a(n.data?.getBotApp ?? null);
|
|
186
|
+
} catch (e) {
|
|
187
|
+
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load bot"));
|
|
188
|
+
} finally {
|
|
189
|
+
l(!1);
|
|
190
|
+
}
|
|
191
191
|
}
|
|
192
192
|
}, [e, t]);
|
|
193
193
|
return i(() => {
|
|
@@ -300,7 +300,6 @@ function x() {
|
|
|
300
300
|
}
|
|
301
301
|
}, [e]), t];
|
|
302
302
|
}
|
|
303
|
-
//#endregion
|
|
304
303
|
export { v as useBot, _ as useBots, y as useCreateBot, x as useDeleteBot, b as useUpdateBot };
|
|
305
304
|
|
|
306
305
|
//# sourceMappingURL=useBots.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBots.js","names":[],"sources":["../../../src/botlit/hooks/useBots.ts"],"sourcesContent":["import { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport type { UpdateBotAppInput } from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\n\nconst LIST_BOT_APPS_DOCUMENT = gql`\n query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {\n listBotApps(filters: $filters, pagination: $pagination) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst GET_BOT_APP_DOCUMENT = gql`\n query GetBotApp($id: ID!) {\n getBotApp(id: $id) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst CREATE_BOT_APP_DOCUMENT = gql`\n mutation CreateBotApp($input: CreateBotAppInput!) {\n createBotApp(input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n workflowId\n tagIds\n createdAt\n updatedAt\n workspaceId\n }\n }\n`;\n\nconst UPDATE_BOT_APP_DOCUMENT = gql`\n mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {\n updateBotApp(id: $id, input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n tagIds\n updatedAt\n updatedById\n workspaceId\n }\n }\n`;\n\nconst DELETE_BOT_APP_DOCUMENT = gql`\n mutation DeleteBotApp($id: ID!) {\n deleteBotApp(id: $id)\n }\n`;\n\ntype WorkspaceClient = ApolloClient;\n\nexport interface BotAppRecord {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n icon?: string | null;\n type: string;\n status: string;\n visibility?: string | null;\n routingStrategy?: string | null;\n defaultAgentId?: string | null;\n welcomeMessage?: string | null;\n fallbackMessage?: string | null;\n /** Bound FluidGrids workflow definition id — the bot's designed behaviour. */\n workflowId?: string | null;\n executionCount?: number | null;\n lastExecutedAt?: string | null;\n tagIds?: string[] | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n createdById?: string | null;\n updatedById?: string | null;\n workspaceId?: string | null;\n}\n\ninterface ListBotAppsData {\n listBotApps: BotAppRecord[];\n}\n\ninterface GetBotAppData {\n getBotApp: BotAppRecord | null;\n}\n\ninterface CreateBotAppData {\n createBotApp: BotAppRecord;\n}\n\ninterface UpdateBotAppData {\n updateBotApp: BotAppRecord;\n}\n\ninterface DeleteBotAppData {\n deleteBotApp: boolean;\n}\n\ninterface BotMutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\ninterface CreateBotInput {\n workspaceId: string;\n name: string;\n slug?: string;\n type: string;\n routingStrategy?: string;\n description?: string;\n icon?: string;\n}\n\ninterface UpdateBotInput {\n botId: string;\n input: GraphQLInput<UpdateBotAppInput>;\n}\n\nconst UPDATE_BOT_APP_FIELDS = fieldsOf<UpdateBotAppInput>({\n bucketId: true,\n context: true,\n defaultAgentId: true,\n description: true,\n fallbackMessage: true,\n icon: true,\n metadata: true,\n name: true,\n routingStrategy: true,\n slug: true,\n status: true,\n tagIds: true,\n tags: true,\n type: true,\n visibility: true,\n welcomeMessage: true,\n workflowId: true,\n});\n\nfunction getWorkspaceClient(client: unknown): WorkspaceClient {\n return client as WorkspaceClient;\n}\n\nfunction buildBotFilter(\n workspaceId: string | undefined,\n filter?: BaseFilter\n): Record<string, unknown> | undefined {\n if (!workspaceId && !filter) return undefined;\n\n return {\n workspaceId,\n search: filter?.search,\n status: filter?.status?.[0],\n visibility: filter?.visibility?.[0],\n bucketId: filter?.bucketId,\n };\n}\n\nexport const botKeys = {\n all: ['bots'] as const,\n lists: () => [...botKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...botKeys.lists(), filter] as const,\n details: () => [...botKeys.all, 'detail'] as const,\n detail: (id: string) => [...botKeys.details(), id] as const,\n};\n\nexport function useBots(filter?: BaseFilter) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const { workspaceId } = useBotlit();\n const [data, setData] = useState<BotAppRecord[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const variables = useMemo(\n () => ({ filters: buildBotFilter(workspaceId, filter), pagination: { limit: 100, offset: 0 } }),\n [filter, workspaceId]\n );\n\n const refetch = useCallback(async () => {\n if (!workspaceId) {\n setData([]);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<ListBotAppsData>({\n query: LIST_BOT_APPS_DOCUMENT,\n variables,\n fetchPolicy: 'network-only',\n });\n setData(result.data?.listBotApps ?? []);\n } catch (queryError) {\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bots'));\n } finally {\n setLoading(false);\n }\n }, [client, variables, workspaceId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useBot(botId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<BotAppRecord | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!botId) {\n setData(null);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<GetBotAppData>({\n query: GET_BOT_APP_DOCUMENT,\n variables: { id: botId },\n fetchPolicy: 'network-only',\n });\n setData(result.data?.getBotApp ?? null);\n } catch (queryError) {\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bot'));\n } finally {\n setLoading(false);\n }\n }, [botId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useCreateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const createBot = useCallback(\n async (input: CreateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<CreateBotAppData>({\n mutation: CREATE_BOT_APP_DOCUMENT,\n variables: { input },\n });\n\n const createdBot = result.data?.createBotApp;\n if (!createdBot) {\n throw new Error('Failed to create bot');\n }\n\n setState({ data: createdBot, loading: false, error: undefined });\n return createdBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to create bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [createBot, state] as const;\n}\n\nexport function useUpdateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const updateBot = useCallback(\n async ({ botId, input }: UpdateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<UpdateBotAppData>({\n mutation: UPDATE_BOT_APP_DOCUMENT,\n variables: { id: botId, input: buildMutationInput(input, UPDATE_BOT_APP_FIELDS) },\n });\n\n const updatedBot = result.data?.updateBotApp;\n if (!updatedBot) {\n throw new Error('Failed to update bot');\n }\n\n setState({ data: updatedBot, loading: false, error: undefined });\n return updatedBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to update bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [updateBot, state] as const;\n}\n\nexport function useDeleteBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<boolean>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const deleteBot = useCallback(\n async (botId: string) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<DeleteBotAppData>({\n mutation: DELETE_BOT_APP_DOCUMENT,\n variables: { id: botId },\n });\n\n const deleted = result.data?.deleteBotApp ?? false;\n setState({ data: deleted, loading: false, error: undefined });\n return deleted;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to delete bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [deleteBot, state] as const;\n}\n"],"mappings":";;;;;;AASA,IAAM,IAAyB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GA4B5B,IAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GA4B1B,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;GAsB7B,IAA0B,CAAG;;;;;;;;;;;;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AAE,IAAI,GAAO;IACzB,CAAC,EAEqB,MAAM,gBAAgB;AAE7C,UADA,EAAS;IAAE,MAAM;IAAS,SAAS;IAAO,OAAO,KAAA;IAAW,CAAC,EACtD;WACA,GAAe;GACtB,IAAM,IACJ,aAAyB,QAAQ,IAAgB,gBAAI,MAAM,uBAAuB;AAEpF,SADA,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;IAAO,CAAC,EAC9C;;IAGV,CAAC,EAAO,CACT,EAEkB,EAAM"}
|
|
1
|
+
{"version":3,"file":"useBots.js","names":["LIST_BOT_APPS_DOCUMENT","GET_BOT_APP_DOCUMENT","CREATE_BOT_APP_DOCUMENT","UPDATE_BOT_APP_DOCUMENT","DELETE_BOT_APP_DOCUMENT","UPDATE_BOT_APP_FIELDS","fieldsOf","getWorkspaceClient","client","buildBotFilter","workspaceId","filter","useBots","useGatewayClient","useBotlit","data","setData","useState","loading","setLoading","error","setError","variables","useMemo","refetch","useCallback","result","queryError","useEffect","useBot","botId","useCreateBot","state","setState","createdBot","mutationError","useUpdateBot","updatedBot","buildMutationInput","input","useDeleteBot","deleted"],"sources":["../../../src/botlit/hooks/useBots.ts"],"sourcesContent":["import { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport type { UpdateBotAppInput } from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\n\nconst LIST_BOT_APPS_DOCUMENT = gql`\n query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {\n listBotApps(filters: $filters, pagination: $pagination) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst GET_BOT_APP_DOCUMENT = gql`\n query GetBotApp($id: ID!) {\n getBotApp(id: $id) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst CREATE_BOT_APP_DOCUMENT = gql`\n mutation CreateBotApp($input: CreateBotAppInput!) {\n createBotApp(input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n workflowId\n tagIds\n createdAt\n updatedAt\n workspaceId\n }\n }\n`;\n\nconst UPDATE_BOT_APP_DOCUMENT = gql`\n mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {\n updateBotApp(id: $id, input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n tagIds\n updatedAt\n updatedById\n workspaceId\n }\n }\n`;\n\nconst DELETE_BOT_APP_DOCUMENT = gql`\n mutation DeleteBotApp($id: ID!) {\n deleteBotApp(id: $id)\n }\n`;\n\ntype WorkspaceClient = ApolloClient;\n\nexport interface BotAppRecord {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n icon?: string | null;\n type: string;\n status: string;\n visibility?: string | null;\n routingStrategy?: string | null;\n defaultAgentId?: string | null;\n welcomeMessage?: string | null;\n fallbackMessage?: string | null;\n /** Bound FluidGrids workflow definition id — the bot's designed behaviour. */\n workflowId?: string | null;\n executionCount?: number | null;\n lastExecutedAt?: string | null;\n tagIds?: string[] | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n createdById?: string | null;\n updatedById?: string | null;\n workspaceId?: string | null;\n}\n\ninterface ListBotAppsData {\n listBotApps: BotAppRecord[];\n}\n\ninterface GetBotAppData {\n getBotApp: BotAppRecord | null;\n}\n\ninterface CreateBotAppData {\n createBotApp: BotAppRecord;\n}\n\ninterface UpdateBotAppData {\n updateBotApp: BotAppRecord;\n}\n\ninterface DeleteBotAppData {\n deleteBotApp: boolean;\n}\n\ninterface BotMutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\ninterface CreateBotInput {\n workspaceId: string;\n name: string;\n slug?: string;\n type: string;\n routingStrategy?: string;\n description?: string;\n icon?: string;\n}\n\ninterface UpdateBotInput {\n botId: string;\n input: GraphQLInput<UpdateBotAppInput>;\n}\n\nconst UPDATE_BOT_APP_FIELDS = fieldsOf<UpdateBotAppInput>({\n bucketId: true,\n context: true,\n defaultAgentId: true,\n description: true,\n fallbackMessage: true,\n icon: true,\n metadata: true,\n name: true,\n routingStrategy: true,\n slug: true,\n status: true,\n tagIds: true,\n tags: true,\n type: true,\n visibility: true,\n welcomeMessage: true,\n workflowId: true,\n});\n\nfunction getWorkspaceClient(client: unknown): WorkspaceClient {\n return client as WorkspaceClient;\n}\n\nfunction buildBotFilter(\n workspaceId: string | undefined,\n filter?: BaseFilter\n): Record<string, unknown> | undefined {\n if (!workspaceId && !filter) return undefined;\n\n return {\n workspaceId,\n search: filter?.search,\n status: filter?.status?.[0],\n visibility: filter?.visibility?.[0],\n bucketId: filter?.bucketId,\n };\n}\n\nexport const botKeys = {\n all: ['bots'] as const,\n lists: () => [...botKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...botKeys.lists(), filter] as const,\n details: () => [...botKeys.all, 'detail'] as const,\n detail: (id: string) => [...botKeys.details(), id] as const,\n};\n\nexport function useBots(filter?: BaseFilter) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const { workspaceId } = useBotlit();\n const [data, setData] = useState<BotAppRecord[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const variables = useMemo(\n () => ({ filters: buildBotFilter(workspaceId, filter), pagination: { limit: 100, offset: 0 } }),\n [filter, workspaceId]\n );\n\n const refetch = useCallback(async () => {\n if (!workspaceId) {\n setData([]);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<ListBotAppsData>({\n query: LIST_BOT_APPS_DOCUMENT,\n variables,\n fetchPolicy: 'network-only',\n });\n setData(result.data?.listBotApps ?? []);\n } catch (queryError) {\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bots'));\n } finally {\n setLoading(false);\n }\n }, [client, variables, workspaceId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useBot(botId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<BotAppRecord | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!botId) {\n setData(null);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<GetBotAppData>({\n query: GET_BOT_APP_DOCUMENT,\n variables: { id: botId },\n fetchPolicy: 'network-only',\n });\n setData(result.data?.getBotApp ?? null);\n } catch (queryError) {\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bot'));\n } finally {\n setLoading(false);\n }\n }, [botId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useCreateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const createBot = useCallback(\n async (input: CreateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<CreateBotAppData>({\n mutation: CREATE_BOT_APP_DOCUMENT,\n variables: { input },\n });\n\n const createdBot = result.data?.createBotApp;\n if (!createdBot) {\n throw new Error('Failed to create bot');\n }\n\n setState({ data: createdBot, loading: false, error: undefined });\n return createdBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to create bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [createBot, state] as const;\n}\n\nexport function useUpdateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const updateBot = useCallback(\n async ({ botId, input }: UpdateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<UpdateBotAppData>({\n mutation: UPDATE_BOT_APP_DOCUMENT,\n variables: { id: botId, input: buildMutationInput(input, UPDATE_BOT_APP_FIELDS) },\n });\n\n const updatedBot = result.data?.updateBotApp;\n if (!updatedBot) {\n throw new Error('Failed to update bot');\n }\n\n setState({ data: updatedBot, loading: false, error: undefined });\n return updatedBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to update bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [updateBot, state] as const;\n}\n\nexport function useDeleteBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<boolean>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const deleteBot = useCallback(\n async (botId: string) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<DeleteBotAppData>({\n mutation: DELETE_BOT_APP_DOCUMENT,\n variables: { id: botId },\n });\n\n const deleted = result.data?.deleteBotApp ?? false;\n setState({ data: deleted, loading: false, error: undefined });\n return deleted;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to delete bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [deleteBot, state] as const;\n}\n"],"mappings":";;;;;;AASA,IAAMA,IAAyB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GA4B5BC,IAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GA4B1BC,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;GAsB7BC,IAA0B,CAAG;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IAASD,EAAmBM,EAAiB,WAAW,CAAC,GACzD,CAACmB,GAAOC,KAAYhB,EAAoC;EAC5D,MAAM,KAAA;EACN,SAAS;EACT,OAAO,KAAA;CACT,CAAC;CAwBD,OAAO,CAtBWQ,EAChB,OAAO,MAAkB;EACvB,EAAS;GAAE,MAAM,KAAA;GAAW,SAAS;GAAM,OAAO,KAAA;EAAU,CAAC;EAC7D,IAAI;GAMF,IAAMgB,KAAU,MALKjC,EAAO,OAAyB;IACnD,UAAUJ;IACV,WAAW,EAAE,IAAI0B,EAAM;GACzB,CAAC,EAAA,CAEsB,MAAM,gBAAgB;GAE7C,OADAG,EAAS;IAAE,MAAMQ;IAAS,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACrDA;EACT,SAASN,GAAe;GACtB,IAAMf,IACJe,aAAyB,QAAQA,IAAgB,gBAAI,MAAM,sBAAsB;GAEnF,MADAF,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;GAAM,CAAC,GAC7Cb;EACR;CACF,GACA,CAACZ,CAAM,CAGD,GAAWwB,CAAK;AAC1B"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CreateBucketInput, UpdateBucketInput } from '../../generated/wspace-types';
|
|
2
|
+
import { BaseFilter } from '../types';
|
|
3
|
+
import { GraphQLInput } from './internal/mutationInput';
|
|
4
|
+
import { QueryResult } from './internal/workspaceGateway';
|
|
5
|
+
export interface BucketRecord {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
slug: string;
|
|
9
|
+
path: string;
|
|
10
|
+
description?: string | null;
|
|
11
|
+
color?: string | null;
|
|
12
|
+
icon?: string | null;
|
|
13
|
+
parentBucketId?: string | null;
|
|
14
|
+
metadata?: Record<string, unknown> | null;
|
|
15
|
+
deletedAt?: string | null;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
createdById: string;
|
|
19
|
+
updatedById: string;
|
|
20
|
+
workspaceId: string;
|
|
21
|
+
}
|
|
22
|
+
/** A bucket plus its resolved children — the shape the tree view renders. */
|
|
23
|
+
export interface BucketTreeNode extends BucketRecord {
|
|
24
|
+
children: BucketTreeNode[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `CreateBucketInput` minus the `workspaceId`/`context` the hook supplies.
|
|
28
|
+
*/
|
|
29
|
+
export type CreateBucketVariables = Omit<GraphQLInput<CreateBucketInput>, 'workspaceId' | 'context'>;
|
|
30
|
+
export interface UpdateBucketVariables {
|
|
31
|
+
bucketId: string;
|
|
32
|
+
input: GraphQLInput<UpdateBucketInput>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Builds the parent → children tree. Buckets whose parent is not in the result
|
|
36
|
+
* set (filtered out, or not readable) are surfaced at the root rather than
|
|
37
|
+
* silently dropped.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildBucketTree(buckets: readonly BucketRecord[]): BucketTreeNode[];
|
|
40
|
+
export declare const bucketKeys: {
|
|
41
|
+
all: readonly ["buckets"];
|
|
42
|
+
lists: () => readonly ["buckets", "list"];
|
|
43
|
+
list: (filter?: BaseFilter) => readonly ["buckets", "list", BaseFilter | undefined];
|
|
44
|
+
tree: () => readonly ["buckets", "tree"];
|
|
45
|
+
details: () => readonly ["buckets", "detail"];
|
|
46
|
+
detail: (id: string) => readonly ["buckets", "detail", string];
|
|
47
|
+
};
|
|
48
|
+
export declare function useBuckets(filter?: BaseFilter): QueryResult<BucketRecord[]>;
|
|
49
|
+
/**
|
|
50
|
+
* The bucket hierarchy. Derived from `listBuckets` — the service exposes the
|
|
51
|
+
* parent link on every bucket, so no separate tree operation is needed.
|
|
52
|
+
*/
|
|
53
|
+
export declare function useBucketTree(): QueryResult<BucketTreeNode[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Direct children of one bucket, resolved via the `parentBucketId` filter on
|
|
56
|
+
* `listBuckets`. Powers the sub-bucket section of the bucket detail page.
|
|
57
|
+
*/
|
|
58
|
+
export declare function useChildBuckets(parentBucketId: string | undefined): QueryResult<BucketRecord[]>;
|
|
59
|
+
export declare function useBucket(bucketId: string | undefined): QueryResult<BucketRecord | null>;
|
|
60
|
+
export declare function useCreateBucket(): readonly [(input: CreateBucketVariables) => Promise<BucketRecord>, import('./internal/workspaceGateway').MutationState<BucketRecord>];
|
|
61
|
+
export declare function useUpdateBucket(): readonly [(input: UpdateBucketVariables) => Promise<BucketRecord>, import('./internal/workspaceGateway').MutationState<BucketRecord>];
|
|
62
|
+
export declare function useDeleteBucket(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useWorkspaceId as
|
|
4
|
-
import { useCallback as
|
|
5
|
-
|
|
6
|
-
var
|
|
1
|
+
import { CreateBucketDocument as e, DeleteBucketDocument as t, GetBucketDocument as n, ListBucketsDocument as r, UpdateBucketDocument as i } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { buildMutationInput as a, fieldsOf as o } from "./internal/mutationInput.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
|
+
// src/botlit/hooks/useBuckets.ts
|
|
6
|
+
var f = 100, p = o({
|
|
7
7
|
color: !0,
|
|
8
8
|
context: !0,
|
|
9
9
|
description: !0,
|
|
@@ -13,7 +13,7 @@ var d = 100, f = t({
|
|
|
13
13
|
parentBucketId: !0,
|
|
14
14
|
slug: !0,
|
|
15
15
|
workspaceId: !0
|
|
16
|
-
}),
|
|
16
|
+
}), m = o({
|
|
17
17
|
color: !0,
|
|
18
18
|
context: !0,
|
|
19
19
|
description: !0,
|
|
@@ -22,11 +22,14 @@ var d = 100, f = t({
|
|
|
22
22
|
name: !0,
|
|
23
23
|
parentBucketId: !0,
|
|
24
24
|
slug: !0
|
|
25
|
-
}),
|
|
26
|
-
function g(e) {
|
|
27
|
-
return e?.listBuckets ?? m;
|
|
28
|
-
}
|
|
25
|
+
}), h = [], g = [];
|
|
29
26
|
function _(e) {
|
|
27
|
+
return e?.listBuckets ?? h;
|
|
28
|
+
}
|
|
29
|
+
function v(e) {
|
|
30
|
+
return e?.getBucket ?? null;
|
|
31
|
+
}
|
|
32
|
+
function y(e) {
|
|
30
33
|
let t = /* @__PURE__ */ new Map();
|
|
31
34
|
for (let n of e) t.set(n.id, {
|
|
32
35
|
...n,
|
|
@@ -45,75 +48,105 @@ function _(e) {
|
|
|
45
48
|
};
|
|
46
49
|
return i(n), n;
|
|
47
50
|
}
|
|
48
|
-
function
|
|
49
|
-
let t =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
select:
|
|
63
|
-
fallback:
|
|
51
|
+
function b(e) {
|
|
52
|
+
let t = s(), n = e?.search, i = d(() => ({
|
|
53
|
+
filters: {
|
|
54
|
+
workspaceId: t,
|
|
55
|
+
search: n || void 0
|
|
56
|
+
},
|
|
57
|
+
pagination: {
|
|
58
|
+
limit: f,
|
|
59
|
+
offset: 0
|
|
60
|
+
}
|
|
61
|
+
}), [t, n]);
|
|
62
|
+
return l({
|
|
63
|
+
document: r,
|
|
64
|
+
variables: i,
|
|
65
|
+
select: _,
|
|
66
|
+
fallback: h,
|
|
64
67
|
enabled: !!t,
|
|
65
68
|
errorMessage: "Failed to load buckets"
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
|
-
function
|
|
69
|
-
let e =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
select:
|
|
80
|
-
fallback:
|
|
71
|
+
function x() {
|
|
72
|
+
let e = s(), t = d(() => ({
|
|
73
|
+
filters: { workspaceId: e },
|
|
74
|
+
pagination: {
|
|
75
|
+
limit: f,
|
|
76
|
+
offset: 0
|
|
77
|
+
}
|
|
78
|
+
}), [e]), n = u((e) => y(e?.listBuckets ?? h), []);
|
|
79
|
+
return l({
|
|
80
|
+
document: r,
|
|
81
|
+
variables: t,
|
|
82
|
+
select: n,
|
|
83
|
+
fallback: g,
|
|
81
84
|
enabled: !!e,
|
|
82
85
|
errorMessage: "Failed to load the bucket tree"
|
|
83
86
|
});
|
|
84
87
|
}
|
|
85
|
-
function
|
|
86
|
-
let t =
|
|
87
|
-
|
|
88
|
+
function S(e) {
|
|
89
|
+
let t = s(), n = d(() => ({
|
|
90
|
+
filters: {
|
|
91
|
+
workspaceId: t,
|
|
92
|
+
parentBucketId: e ?? ""
|
|
93
|
+
},
|
|
94
|
+
pagination: {
|
|
95
|
+
limit: f,
|
|
96
|
+
offset: 0
|
|
97
|
+
}
|
|
98
|
+
}), [t, e]);
|
|
99
|
+
return l({
|
|
100
|
+
document: r,
|
|
101
|
+
variables: n,
|
|
102
|
+
select: _,
|
|
103
|
+
fallback: h,
|
|
104
|
+
enabled: !!(t && e),
|
|
105
|
+
errorMessage: "Failed to load sub-buckets"
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function C(e) {
|
|
109
|
+
let t = d(() => ({ id: e ?? "" }), [e]);
|
|
110
|
+
return l({
|
|
88
111
|
document: n,
|
|
89
|
-
variables:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
112
|
+
variables: t,
|
|
113
|
+
select: v,
|
|
114
|
+
fallback: null,
|
|
115
|
+
enabled: !!e,
|
|
116
|
+
errorMessage: "Failed to load bucket"
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function w() {
|
|
120
|
+
let t = s(), n = u((e) => ({ input: a({
|
|
121
|
+
...e,
|
|
122
|
+
workspaceId: t
|
|
123
|
+
}, p) }), [t]);
|
|
124
|
+
return c({
|
|
125
|
+
document: e,
|
|
126
|
+
variables: n,
|
|
93
127
|
select: (e) => e?.createBucket,
|
|
94
128
|
errorMessage: "Failed to create bucket"
|
|
95
129
|
});
|
|
96
130
|
}
|
|
97
|
-
function
|
|
98
|
-
return
|
|
99
|
-
document:
|
|
100
|
-
variables: ({ bucketId:
|
|
101
|
-
id:
|
|
102
|
-
input:
|
|
131
|
+
function T() {
|
|
132
|
+
return c({
|
|
133
|
+
document: i,
|
|
134
|
+
variables: ({ bucketId: e, input: t }) => ({
|
|
135
|
+
id: e,
|
|
136
|
+
input: a(t, m)
|
|
103
137
|
}),
|
|
104
138
|
select: (e) => e?.updateBucket,
|
|
105
139
|
errorMessage: "Failed to update bucket"
|
|
106
140
|
});
|
|
107
141
|
}
|
|
108
|
-
function
|
|
109
|
-
return
|
|
110
|
-
document:
|
|
142
|
+
function E() {
|
|
143
|
+
return c({
|
|
144
|
+
document: t,
|
|
111
145
|
variables: (e) => ({ id: e }),
|
|
112
146
|
select: (e) => e?.deleteBucket,
|
|
113
147
|
errorMessage: "Failed to delete bucket"
|
|
114
148
|
});
|
|
115
149
|
}
|
|
116
|
-
|
|
117
|
-
export { _ as buildBucketTree, y as useBucketTree, v as useBuckets, b as useCreateBucket, S as useDeleteBucket, x as useUpdateBucket };
|
|
150
|
+
export { y as buildBucketTree, C as useBucket, x as useBucketTree, b as useBuckets, S as useChildBuckets, w as useCreateBucket, E as useDeleteBucket, T as useUpdateBucket };
|
|
118
151
|
|
|
119
152
|
//# sourceMappingURL=useBuckets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBuckets.js","names":[],"sources":["../../../src/botlit/hooks/useBuckets.ts"],"sourcesContent":["/**\n * Buckets Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBuckets` / `getBucket` / `createBucket` / `updateBucket`\n * / `deleteBucket` operations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateBucketDocument,\n DeleteBucketDocument,\n GetBucketDocument,\n ListBucketsDocument,\n UpdateBucketDocument,\n type CreateBucketMutation,\n type DeleteBucketMutation,\n type GetBucketQuery,\n type ListBucketsQuery,\n type UpdateBucketMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateBucketInput, UpdateBucketInput } from '../../generated/wspace-types';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface BucketRecord {\n id: string;\n name: string;\n slug: string;\n path: string;\n description?: string | null;\n color?: string | null;\n icon?: string | null;\n parentBucketId?: string | null;\n metadata?: Record<string, unknown> | null;\n deletedAt?: string | null;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\n/** A bucket plus its resolved children — the shape the tree view renders. */\nexport interface BucketTreeNode extends BucketRecord {\n children: BucketTreeNode[];\n}\n\n/**\n * `CreateBucketInput` minus the `workspaceId`/`context` the hook supplies.\n */\nexport type CreateBucketVariables = Omit<\n GraphQLInput<CreateBucketInput>,\n 'workspaceId' | 'context'\n>;\n\nexport interface UpdateBucketVariables {\n bucketId: string;\n input: GraphQLInput<UpdateBucketInput>;\n}\n\nconst CREATE_BUCKET_FIELDS = fieldsOf<CreateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n workspaceId: true,\n});\n\nconst UPDATE_BUCKET_FIELDS = fieldsOf<UpdateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n});\n\nconst NO_BUCKETS: BucketRecord[] = [];\nconst NO_BUCKET_TREE: BucketTreeNode[] = [];\n\nfunction selectBuckets(data: ListBucketsQuery | undefined): BucketRecord[] {\n return data?.listBuckets ?? NO_BUCKETS;\n}\n\nfunction selectBucket(data: GetBucketQuery | undefined): BucketRecord | null {\n return data?.getBucket ?? null;\n}\n\n/**\n * Builds the parent → children tree. Buckets whose parent is not in the result\n * set (filtered out, or not readable) are surfaced at the root rather than\n * silently dropped.\n */\nexport function buildBucketTree(buckets: readonly BucketRecord[]): BucketTreeNode[] {\n const nodes = new Map<string, BucketTreeNode>();\n for (const bucket of buckets) {\n nodes.set(bucket.id, { ...bucket, children: [] });\n }\n\n const roots: BucketTreeNode[] = [];\n for (const bucket of buckets) {\n const node = nodes.get(bucket.id);\n if (!node) continue;\n const parent = bucket.parentBucketId ? nodes.get(bucket.parentBucketId) : undefined;\n if (parent && parent !== node) {\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n }\n\n const byName = (a: BucketTreeNode, b: BucketTreeNode) => a.name.localeCompare(b.name);\n const sortRecursively = (list: BucketTreeNode[]) => {\n list.sort(byName);\n for (const child of list) sortRecursively(child.children);\n };\n sortRecursively(roots);\n\n return roots;\n}\n\nexport const bucketKeys = {\n all: ['buckets'] as const,\n lists: () => [...bucketKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...bucketKeys.lists(), filter] as const,\n tree: () => [...bucketKeys.all, 'tree'] as const,\n details: () => [...bucketKeys.all, 'detail'] as const,\n detail: (id: string) => [...bucketKeys.details(), id] as const,\n};\n\nexport function useBuckets(filter?: BaseFilter): QueryResult<BucketRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search;\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, search: search || undefined },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search]\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketRecord[]>({\n document: ListBucketsDocument,\n variables,\n select: selectBuckets,\n fallback: NO_BUCKETS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load buckets',\n });\n}\n\n/**\n * The bucket hierarchy. Derived from `listBuckets` — the service exposes the\n * parent link on every bucket, so no separate tree operation is needed.\n */\nexport function useBucketTree(): QueryResult<BucketTreeNode[]> {\n const workspaceId = useWorkspaceId();\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId]\n );\n\n const select = useCallback(\n (data: ListBucketsQuery | undefined) => buildBucketTree(data?.listBuckets ?? NO_BUCKETS),\n []\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketTreeNode[]>({\n document: ListBucketsDocument,\n variables,\n select,\n fallback: NO_BUCKET_TREE,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load the bucket tree',\n });\n}\n\nexport function useBucket(bucketId: string | undefined): QueryResult<BucketRecord | null> {\n const variables = useMemo(() => ({ id: bucketId ?? '' }), [bucketId]);\n\n return useWorkspaceQuery<GetBucketQuery, BucketRecord | null>({\n document: GetBucketDocument,\n variables,\n select: selectBucket,\n fallback: null,\n enabled: Boolean(bucketId),\n errorMessage: 'Failed to load bucket',\n });\n}\n\nexport function useCreateBucket() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateBucketVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_BUCKET_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<CreateBucketMutation, CreateBucketVariables, BucketRecord>({\n document: CreateBucketDocument,\n variables,\n select: (data) => data?.createBucket,\n errorMessage: 'Failed to create bucket',\n });\n}\n\nexport function useUpdateBucket() {\n return useWorkspaceMutation<UpdateBucketMutation, UpdateBucketVariables, BucketRecord>({\n document: UpdateBucketDocument,\n variables: ({ bucketId, input }) => ({\n id: bucketId,\n input: buildMutationInput(input, UPDATE_BUCKET_FIELDS),\n }),\n select: (data) => data?.updateBucket,\n errorMessage: 'Failed to update bucket',\n });\n}\n\nexport function useDeleteBucket() {\n return useWorkspaceMutation<DeleteBucketMutation, string, boolean>({\n document: DeleteBucketDocument,\n variables: (bucketId) => ({ id: bucketId }),\n select: (data) => data?.deleteBucket,\n errorMess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IAAY,QAAQ;IAAG;GAC7C,GACD,CAAC,GAAa,EAAO,CACtB;EAKC,QAAQ;EACR,UAAU;EACV,SAAS,EAAQ;EACjB,cAAc;EACf,CAAC;;AAOJ,SAAgB,IAA+C;CAC7D,IAAM,IAAc,GAAgB;AAepC,QAAO,EAAsD;EAC3D,UAAU;EACV,WAfgB,SACT;GACL,SAAS,EAAE,gBAAa;GACxB,YAAY;IAAE,OAAO;IAAY,QAAQ;IAAG;GAC7C,GACD,CAAC,EAAY,CACd;EAUC,QARa,GACZ,MAAuC,EAAgB,GAAM,eAAe,EAAW,EACxF,EAAE,CACH;EAMC,UAAU;EACV,SAAS,EAAQ;EACjB,cAAc;EACf,CAAC;;AAgBJ,SAAgB,IAAkB;CAChC,IAAM,IAAc,GAAgB;AASpC,QAAO,EAAgF;EACrF,UAAU;EACV,WATgB,GACf,OAAkC,EACjC,OAAO,EAAmB;GAAE,GAAG;GAAO;GAAa,EAAE,EAAqB,EAC3E,GACD,CAAC,EAAY,CACd;EAKC,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC;;AAGJ,SAAgB,IAAkB;AAChC,QAAO,EAAgF;EACrF,UAAU;EACV,YAAY,EAAE,aAAU,gBAAa;GACnC,IAAI;GACJ,OAAO,EAAmB,GAAO,EAAqB;GACvD;EACD,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC;;AAGJ,SAAgB,IAAkB;AAChC,QAAO,EAA4D;EACjE,UAAU;EACV,YAAY,OAAc,EAAE,IAAI,GAAU;EAC1C,SAAS,MAAS,GAAM;EACxB,cAAc;EACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"useBuckets.js","names":["LIST_LIMIT","CREATE_BUCKET_FIELDS","fieldsOf","UPDATE_BUCKET_FIELDS","NO_BUCKETS","NO_BUCKET_TREE","selectBuckets","data","selectBucket","buildBucketTree","nodes","bucket","buckets","roots","node","parent","byName","a","b","sortRecursively","child","list","useBuckets","workspaceId","useWorkspaceId","search","filter","variables","useMemo","useWorkspaceQuery","ListBucketsDocument","useBucketTree","select","useCallback","useChildBuckets","parentBucketId","useBucket","bucketId","GetBucketDocument","useCreateBucket","buildMutationInput","input","useWorkspaceMutation","CreateBucketDocument","useUpdateBucket","UpdateBucketDocument","useDeleteBucket","DeleteBucketDocument"],"sources":["../../../src/botlit/hooks/useBuckets.ts"],"sourcesContent":["/**\n * Buckets Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBuckets` / `getBucket` / `createBucket` / `updateBucket`\n * / `deleteBucket` operations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateBucketDocument,\n DeleteBucketDocument,\n GetBucketDocument,\n ListBucketsDocument,\n UpdateBucketDocument,\n type CreateBucketMutation,\n type DeleteBucketMutation,\n type GetBucketQuery,\n type ListBucketsQuery,\n type UpdateBucketMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateBucketInput, UpdateBucketInput } from '../../generated/wspace-types';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface BucketRecord {\n id: string;\n name: string;\n slug: string;\n path: string;\n description?: string | null;\n color?: string | null;\n icon?: string | null;\n parentBucketId?: string | null;\n metadata?: Record<string, unknown> | null;\n deletedAt?: string | null;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\n/** A bucket plus its resolved children — the shape the tree view renders. */\nexport interface BucketTreeNode extends BucketRecord {\n children: BucketTreeNode[];\n}\n\n/**\n * `CreateBucketInput` minus the `workspaceId`/`context` the hook supplies.\n */\nexport type CreateBucketVariables = Omit<\n GraphQLInput<CreateBucketInput>,\n 'workspaceId' | 'context'\n>;\n\nexport interface UpdateBucketVariables {\n bucketId: string;\n input: GraphQLInput<UpdateBucketInput>;\n}\n\nconst CREATE_BUCKET_FIELDS = fieldsOf<CreateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n workspaceId: true,\n});\n\nconst UPDATE_BUCKET_FIELDS = fieldsOf<UpdateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n});\n\nconst NO_BUCKETS: BucketRecord[] = [];\nconst NO_BUCKET_TREE: BucketTreeNode[] = [];\n\nfunction selectBuckets(data: ListBucketsQuery | undefined): BucketRecord[] {\n return data?.listBuckets ?? NO_BUCKETS;\n}\n\nfunction selectBucket(data: GetBucketQuery | undefined): BucketRecord | null {\n return data?.getBucket ?? null;\n}\n\n/**\n * Builds the parent → children tree. Buckets whose parent is not in the result\n * set (filtered out, or not readable) are surfaced at the root rather than\n * silently dropped.\n */\nexport function buildBucketTree(buckets: readonly BucketRecord[]): BucketTreeNode[] {\n const nodes = new Map<string, BucketTreeNode>();\n for (const bucket of buckets) {\n nodes.set(bucket.id, { ...bucket, children: [] });\n }\n\n const roots: BucketTreeNode[] = [];\n for (const bucket of buckets) {\n const node = nodes.get(bucket.id);\n if (!node) continue;\n const parent = bucket.parentBucketId ? nodes.get(bucket.parentBucketId) : undefined;\n if (parent && parent !== node) {\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n }\n\n const byName = (a: BucketTreeNode, b: BucketTreeNode) => a.name.localeCompare(b.name);\n const sortRecursively = (list: BucketTreeNode[]) => {\n list.sort(byName);\n for (const child of list) sortRecursively(child.children);\n };\n sortRecursively(roots);\n\n return roots;\n}\n\nexport const bucketKeys = {\n all: ['buckets'] as const,\n lists: () => [...bucketKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...bucketKeys.lists(), filter] as const,\n tree: () => [...bucketKeys.all, 'tree'] as const,\n details: () => [...bucketKeys.all, 'detail'] as const,\n detail: (id: string) => [...bucketKeys.details(), id] as const,\n};\n\nexport function useBuckets(filter?: BaseFilter): QueryResult<BucketRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search;\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, search: search || undefined },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search]\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketRecord[]>({\n document: ListBucketsDocument,\n variables,\n select: selectBuckets,\n fallback: NO_BUCKETS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load buckets',\n });\n}\n\n/**\n * The bucket hierarchy. Derived from `listBuckets` — the service exposes the\n * parent link on every bucket, so no separate tree operation is needed.\n */\nexport function useBucketTree(): QueryResult<BucketTreeNode[]> {\n const workspaceId = useWorkspaceId();\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId]\n );\n\n const select = useCallback(\n (data: ListBucketsQuery | undefined) => buildBucketTree(data?.listBuckets ?? NO_BUCKETS),\n []\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketTreeNode[]>({\n document: ListBucketsDocument,\n variables,\n select,\n fallback: NO_BUCKET_TREE,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load the bucket tree',\n });\n}\n\n/**\n * Direct children of one bucket, resolved via the `parentBucketId` filter on\n * `listBuckets`. Powers the sub-bucket section of the bucket detail page.\n */\nexport function useChildBuckets(parentBucketId: string | undefined): QueryResult<BucketRecord[]> {\n const workspaceId = useWorkspaceId();\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, parentBucketId: parentBucketId ?? '' },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, parentBucketId]\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketRecord[]>({\n document: ListBucketsDocument,\n variables,\n select: selectBuckets,\n fallback: NO_BUCKETS,\n enabled: Boolean(workspaceId && parentBucketId),\n errorMessage: 'Failed to load sub-buckets',\n });\n}\n\nexport function useBucket(bucketId: string | undefined): QueryResult<BucketRecord | null> {\n const variables = useMemo(() => ({ id: bucketId ?? '' }), [bucketId]);\n\n return useWorkspaceQuery<GetBucketQuery, BucketRecord | null>({\n document: GetBucketDocument,\n variables,\n select: selectBucket,\n fallback: null,\n enabled: Boolean(bucketId),\n errorMessage: 'Failed to load bucket',\n });\n}\n\nexport function useCreateBucket() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateBucketVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_BUCKET_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<CreateBucketMutation, CreateBucketVariables, BucketRecord>({\n document: CreateBucketDocument,\n variables,\n select: (data) => data?.createBucket,\n errorMessage: 'Failed to create bucket',\n });\n}\n\nexport function useUpdateBucket() {\n return useWorkspaceMutation<UpdateBucketMutation, UpdateBucketVariables, BucketRecord>({\n document: UpdateBucketDocument,\n variables: ({ bucketId, input }) => ({\n id: bucketId,\n input: buildMutationInput(input, UPDATE_BUCKET_FIELDS),\n }),\n select: (data) => data?.updateBucket,\n errorMessage: 'Failed to update bucket',\n });\n}\n\nexport function useDeleteBucket() {\n return useWorkspaceMutation<DeleteBucketMutation, string, boolean>({\n document: DeleteBucketDocument,\n variables: (bucketId) => ({ id: bucketId }),\n select: (data) => data?.deleteBucket,\n errorMessage: 'Failed to delete bucket',\n });\n}\n"],"mappings":";;;;;AA+BA,IAAMA,IAAa,KAsCbC,IAAuBC,EAA4B;CACvD,OAAO;CACP,SAAS;CACT,aAAa;CACb,MAAM;CACN,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,MAAM;CACN,aAAa;AACf,CAAC,GAEKC,IAAuBD,EAA4B;CACvD,OAAO;CACP,SAAS;CACT,aAAa;CACb,MAAM;CACN,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,MAAM;AACR,CAAC,GAEKE,IAA6B,CAAC,GAC9BC,IAAmC,CAAC;AAE1C,SAASC,EAAc,GAAoD;CACzE,OA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AgBuC,IAAkB;CAChC,OAAOJ,EAA4D;EACjE,UAAUK;EACV,YAAY,OAAc,EAAE,IAAIV,EAAS;EACzC,SAAS,MAAS9B,GAAM;EACxB,cAAc;CAChB,CAAC;AACH"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { CreateChannelConnectorInput, CreateChannelRouteInput, UpdateChannelConnectorInput, UpdateChannelRouteInput } from '../../generated/wspace-types';
|
|
2
|
+
import { ChannelFilter } from '../types';
|
|
3
|
+
import { GraphQLInput } from './internal/mutationInput';
|
|
4
|
+
import { QueryResult } from './internal/workspaceGateway';
|
|
5
|
+
export interface ChannelConnectorRecord {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
status: string;
|
|
10
|
+
visibility: string;
|
|
11
|
+
description?: string | null;
|
|
12
|
+
bucketId?: string | null;
|
|
13
|
+
credentialsRefId?: string | null;
|
|
14
|
+
defaultPolicyBindings?: Record<string, unknown> | null;
|
|
15
|
+
metadata?: Record<string, unknown> | null;
|
|
16
|
+
revision: number;
|
|
17
|
+
tags: string[];
|
|
18
|
+
createdAt: string;
|
|
19
|
+
updatedAt: string;
|
|
20
|
+
createdById: string;
|
|
21
|
+
updatedById: string;
|
|
22
|
+
workspaceId: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ChannelRouteRecord {
|
|
25
|
+
id: string;
|
|
26
|
+
appId: string;
|
|
27
|
+
connectorId: string;
|
|
28
|
+
locationId: string;
|
|
29
|
+
formatPolicyId?: string | null;
|
|
30
|
+
policyBindings?: Record<string, unknown> | null;
|
|
31
|
+
routingOverrides?: Record<string, unknown> | null;
|
|
32
|
+
metadata?: Record<string, unknown> | null;
|
|
33
|
+
revision: number;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
workspaceId: string;
|
|
37
|
+
}
|
|
38
|
+
/** `CreateChannelConnectorInput` minus the `workspaceId` the hook supplies. */
|
|
39
|
+
export type CreateChannelConnectorVariables = Omit<GraphQLInput<CreateChannelConnectorInput>, 'workspaceId'>;
|
|
40
|
+
export interface UpdateChannelConnectorVariables {
|
|
41
|
+
connectorId: string;
|
|
42
|
+
input: GraphQLInput<UpdateChannelConnectorInput>;
|
|
43
|
+
}
|
|
44
|
+
/** `CreateChannelRouteInput` minus the `workspaceId` the hook supplies. */
|
|
45
|
+
export type CreateChannelRouteVariables = Omit<GraphQLInput<CreateChannelRouteInput>, 'workspaceId'>;
|
|
46
|
+
export interface UpdateChannelRouteVariables {
|
|
47
|
+
routeId: string;
|
|
48
|
+
input: GraphQLInput<UpdateChannelRouteInput>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Web-widget appearance settings.
|
|
52
|
+
*
|
|
53
|
+
* `ChannelConnector` has no widget column — the settings live under
|
|
54
|
+
* `metadata.webWidget`, which is where the connector form writes them.
|
|
55
|
+
*/
|
|
56
|
+
export interface ChannelWidgetConfig {
|
|
57
|
+
allowedOrigins: string[];
|
|
58
|
+
primaryColor: string;
|
|
59
|
+
fontFamily: string;
|
|
60
|
+
starterPrompts: string[];
|
|
61
|
+
}
|
|
62
|
+
export declare const WIDGET_METADATA_KEY = "webWidget";
|
|
63
|
+
/** Reads the widget settings back, or `undefined` when none were saved. */
|
|
64
|
+
export declare function readWidgetConfig(connector: Pick<ChannelConnectorRecord, 'metadata'>): ChannelWidgetConfig | undefined;
|
|
65
|
+
/** Reads a display label the UI stashed on the route's free-form metadata. */
|
|
66
|
+
export declare function routeMetadataString(route: Pick<ChannelRouteRecord, 'metadata'>, key: string): string | undefined;
|
|
67
|
+
export declare const channelKeys: {
|
|
68
|
+
all: readonly ["channels"];
|
|
69
|
+
connectors: () => readonly ["channels", "connectors"];
|
|
70
|
+
connectorList: (filter?: ChannelFilter) => readonly ["channels", "connectors", "list", ChannelFilter | undefined];
|
|
71
|
+
connectorDetail: (id: string) => readonly ["channels", "connectors", "detail", string];
|
|
72
|
+
routes: () => readonly ["channels", "routes"];
|
|
73
|
+
routeList: (connectorId?: string) => readonly ["channels", "routes", "list", string | undefined];
|
|
74
|
+
routeDetail: (id: string) => readonly ["channels", "routes", "detail", string];
|
|
75
|
+
};
|
|
76
|
+
export declare function useChannelConnectors(filter?: ChannelFilter): QueryResult<ChannelConnectorRecord[]>;
|
|
77
|
+
export declare function useChannelConnector(connectorId: string | undefined): QueryResult<ChannelConnectorRecord | null>;
|
|
78
|
+
export declare function useCreateChannelConnector(): readonly [(input: CreateChannelConnectorVariables) => Promise<ChannelConnectorRecord>, import('./internal/workspaceGateway').MutationState<ChannelConnectorRecord>];
|
|
79
|
+
export declare function useUpdateChannelConnector(): readonly [(input: UpdateChannelConnectorVariables) => Promise<ChannelConnectorRecord>, import('./internal/workspaceGateway').MutationState<ChannelConnectorRecord>];
|
|
80
|
+
export declare function useDeleteChannelConnector(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];
|
|
81
|
+
export declare function useChannelRoutes(connectorId?: string): QueryResult<ChannelRouteRecord[]>;
|
|
82
|
+
/** Routes bound to a specific bot app (Bot Detail → Channels tab). */
|
|
83
|
+
export declare function useBotChannelRoutes(botId: string | undefined): QueryResult<ChannelRouteRecord[]>;
|
|
84
|
+
export declare function useChannelRoute(routeId: string | undefined): QueryResult<ChannelRouteRecord | null>;
|
|
85
|
+
export declare function useCreateChannelRoute(): readonly [(input: CreateChannelRouteVariables) => Promise<ChannelRouteRecord>, import('./internal/workspaceGateway').MutationState<ChannelRouteRecord>];
|
|
86
|
+
export declare function useUpdateChannelRoute(): readonly [(input: UpdateChannelRouteVariables) => Promise<ChannelRouteRecord>, import('./internal/workspaceGateway').MutationState<ChannelRouteRecord>];
|
|
87
|
+
export declare function useDeleteChannelRoute(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];
|