@burdenoff/microfe-botmanor 2026.1120.6 → 2026.1120.7

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.
Files changed (36) hide show
  1. package/dist/botlit/components/AssistantChannelPanel.js +3 -3
  2. package/dist/botlit/components/AssistantChannelPanel.js.map +1 -1
  3. package/dist/botlit/components/ChannelRoutesPanel.d.ts +9 -0
  4. package/dist/botlit/components/ChannelRoutesPanel.js +275 -0
  5. package/dist/botlit/components/ChannelRoutesPanel.js.map +1 -0
  6. package/dist/botlit/components/CreateChannelRouteDialog.d.ts +13 -0
  7. package/dist/botlit/components/CreateChannelRouteDialog.js +188 -0
  8. package/dist/botlit/components/CreateChannelRouteDialog.js.map +1 -0
  9. package/dist/botlit/hooks/index.d.ts +3 -3
  10. package/dist/botlit/hooks/index.js +19 -19
  11. package/dist/botlit/hooks/useBots.d.ts +5 -0
  12. package/dist/botlit/hooks/useBots.js +63 -50
  13. package/dist/botlit/hooks/useBots.js.map +1 -1
  14. package/dist/botlit/hooks/useChannels.d.ts +49 -23
  15. package/dist/botlit/hooks/useChannels.js +141 -135
  16. package/dist/botlit/hooks/useChannels.js.map +1 -1
  17. package/dist/botlit/pages/BotChannelsTab.js +12 -3
  18. package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
  19. package/dist/botlit/pages/ChannelDetailPage.js +642 -776
  20. package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
  21. package/dist/botlit/pages/ChannelRoutesPage.js +22 -208
  22. package/dist/botlit/pages/ChannelRoutesPage.js.map +1 -1
  23. package/dist/botlit/pages/ChannelsPage.js +314 -251
  24. package/dist/botlit/pages/ChannelsPage.js.map +1 -1
  25. package/dist/botlit/utils/channelConnectors.d.ts +13 -0
  26. package/dist/botlit/utils/channelConnectors.js +21 -1
  27. package/dist/botlit/utils/channelConnectors.js.map +1 -1
  28. package/dist/botlit/utils/errors.d.ts +8 -0
  29. package/dist/botlit/utils/errors.js +21 -1
  30. package/dist/botlit/utils/errors.js.map +1 -1
  31. package/dist/generated/wspace-operations.d.ts +57 -12
  32. package/dist/generated/wspace-operations.js +99 -91
  33. package/dist/generated/wspace-operations.js.map +1 -1
  34. package/dist/generated/wspace-types.d.ts +32 -0
  35. package/dist/generated/wspace-types.js.map +1 -1
  36. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreateChannelRouteDialog.js","names":["selectClassName","CreateChannelRouteDialog","props","CreateChannelRouteForm","t","useTr","idPrefix","useId","blank","useMemo","connectorId","form","setForm","useState","showErrors","setShowErrors","submitError","setSubmitError","connectors","useAllChannelConnectors","bots","useAllBots","createRoute","createState","useCreateChannelRoute","location","errors","hasErrors","isDirty","close","confirmAction","onOpenChange","submit","event","connector","row","bot","route","toast","onCreated","err","graphqlErrorMessage","fieldId","name","visibleError","ResponsiveDialog","next","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","FormField","Input","ResponsiveDialogFooter","Button"],"sources":["../../../src/botlit/components/CreateChannelRouteDialog.tsx"],"sourcesContent":["/**\n * Create Channel Route dialog (BOFF-12562)\n * @module botlit/components\n *\n * One create-route flow for every \"Create Route\" / \"Add Route\" entry point:\n * the Routes page, the Routes tab on /channels and a connector's detail page\n * (which passes its own connector). The user picks a connector, the location\n * on it (or `*` for every location) and the bot that answers there.\n *\n * It is a real form: Enter submits, missing values are named inline, the\n * service's own message (unknown bot, duplicate location) is shown in an\n * alert, and closing with typed values asks first.\n */\n\nimport type { FC, FormEvent } from 'react';\nimport { useId, useMemo, useState } from 'react';\nimport {\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { toast } from 'sonner';\nimport { useTr } from '../../shared/hooks/useTr';\nimport {\n useAllBots,\n useAllChannelConnectors,\n useCreateChannelRoute,\n type ChannelRouteRecord,\n} from '../hooks';\nimport { confirmAction } from '../utils/confirmAction';\nimport { graphqlErrorMessage } from '../utils/errors';\nimport { Button } from './Button';\nimport { FormField, Input } from './Input';\n\n/** The service stores at most this many characters for a location. */\nexport const ROUTE_LOCATION_MAX_LENGTH = 500;\n\ninterface RouteForm {\n connectorId: string;\n locationId: string;\n locationName: string;\n botId: string;\n isActive: boolean;\n}\n\ninterface CreateChannelRouteDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Set when the dialog is opened from one connector: the route is for it. */\n connectorId?: string;\n onCreated?: (route: ChannelRouteRecord) => void;\n}\n\nconst selectClassName =\n 'flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm';\n\nexport const CreateChannelRouteDialog: FC<CreateChannelRouteDialogProps> = (props) =>\n // Mounted only while open, so every opening starts from a blank form.\n props.open ? <CreateChannelRouteForm {...props} /> : null;\n\nconst CreateChannelRouteForm: FC<CreateChannelRouteDialogProps> = ({\n onOpenChange,\n connectorId,\n onCreated,\n}) => {\n const t = useTr();\n const idPrefix = useId();\n const blank = useMemo<RouteForm>(\n () => ({\n connectorId: connectorId ?? '',\n locationId: '*',\n locationName: '',\n botId: '',\n isActive: true,\n }),\n [connectorId]\n );\n const [form, setForm] = useState<RouteForm>(blank);\n const [showErrors, setShowErrors] = useState(false);\n const [submitError, setSubmitError] = useState<string | null>(null);\n const connectors = useAllChannelConnectors();\n const bots = useAllBots();\n const [createRoute, createState] = useCreateChannelRoute();\n\n const location = form.locationId.trim();\n const errors: Partial<Record<keyof RouteForm, string>> = {};\n if (!form.connectorId) {\n errors.connectorId = t(\n 'botlit.channelRoutes.create.errors.connectorRequired',\n 'Choose the channel connector this route belongs to.'\n );\n }\n if (!location) {\n errors.locationId = t(\n 'botlit.channelRoutes.create.errors.locationRequired',\n 'Enter the location this route answers, or * for every location.'\n );\n } else if (location.length > ROUTE_LOCATION_MAX_LENGTH) {\n errors.locationId = t(\n 'botlit.channelRoutes.create.errors.locationTooLong',\n 'The location can be at most {{max}} characters.',\n { max: ROUTE_LOCATION_MAX_LENGTH }\n );\n }\n if (!form.botId) {\n errors.botId = t(\n 'botlit.channelRoutes.create.errors.botRequired',\n 'Choose the bot that answers messages on this location.'\n );\n }\n const hasErrors = Object.keys(errors).length > 0;\n const isDirty = JSON.stringify(form) !== JSON.stringify(blank);\n\n const close = async () => {\n if (isDirty && !createState.loading) {\n const discard = await confirmAction({\n title: t('botlit.channelRoutes.create.discard.title', 'Discard this route?'),\n message: t(\n 'botlit.channelRoutes.create.discard.message',\n 'The route has not been created. Close the form and lose what you entered?'\n ),\n confirmLabel: t('botlit.common.discard', 'Discard'),\n cancelLabel: t('botlit.common.keepEditing', 'Keep editing'),\n });\n if (!discard) return;\n }\n onOpenChange(false);\n };\n\n const submit = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n setShowErrors(true);\n setSubmitError(null);\n if (hasErrors || createState.loading) return;\n const connector = connectors.data.find((row) => row.id === form.connectorId);\n const bot = bots.data.find((row) => row.id === form.botId);\n try {\n const route = await createRoute({\n connectorId: form.connectorId,\n locationId: location,\n appId: form.botId,\n isActive: form.isActive,\n metadata: {\n locationName: form.locationName.trim() || location,\n appName: bot?.name,\n connectorName: connector?.name,\n },\n });\n toast.success(\n t('botlit.channelRoutes.create.success', 'Route created: {{location}} goes to {{bot}}', {\n location: form.locationName.trim() || location,\n bot: bot?.name ?? form.botId,\n })\n );\n onOpenChange(false);\n if (route) onCreated?.(route);\n } catch (err) {\n setSubmitError(\n graphqlErrorMessage(\n err,\n t('botlit.channelRoutes.create.errors.failed', 'The route could not be created.')\n )\n );\n }\n };\n\n const fieldId = (name: string) => `${idPrefix}-${name}`;\n const visibleError = (name: keyof RouteForm) => (showErrors ? errors[name] : undefined);\n\n return (\n <ResponsiveDialog open onOpenChange={(next) => (next ? undefined : void close())}>\n <ResponsiveDialogContent>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {t('botlit.channelRoutes.create.title', 'Create route')}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {t(\n 'botlit.channelRoutes.create.description',\n 'Choose which bot answers messages that arrive at a location on a channel connector.'\n )}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n <form noValidate className=\"space-y-4\" onSubmit={(event) => void submit(event)}>\n {connectorId === undefined && (\n <FormField\n label={t('botlit.channelRoutes.create.connector', 'Channel connector')}\n htmlFor={fieldId('connector')}\n required\n error={visibleError('connectorId')}\n >\n <select\n id={fieldId('connector')}\n className={selectClassName}\n value={form.connectorId}\n aria-invalid={Boolean(visibleError('connectorId'))}\n onChange={(e) => setForm({ ...form, connectorId: e.target.value })}\n >\n <option value=\"\">\n {connectors.loading\n ? t('botlit.common.loading', 'Loading...')\n : connectors.data.length > 0\n ? t(\n 'botlit.channelRoutes.create.connectorPlaceholder',\n 'Select a connector...'\n )\n : t(\n 'botlit.channelRoutes.create.noConnectors',\n 'No connectors yet. Add a channel first.'\n )}\n </option>\n {connectors.data.map((connector) => (\n <option key={connector.id} value={connector.id}>\n {connector.name}\n </option>\n ))}\n </select>\n </FormField>\n )}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <FormField\n label={t('botlit.channelRoutes.create.location', 'Location ID')}\n htmlFor={fieldId('location')}\n description={t(\n 'botlit.channelRoutes.create.locationHint',\n '* for every location, or a platform channel ID'\n )}\n required\n error={visibleError('locationId')}\n >\n <Input\n id={fieldId('location')}\n value={form.locationId}\n maxLength={ROUTE_LOCATION_MAX_LENGTH}\n aria-invalid={Boolean(visibleError('locationId'))}\n onChange={(e) => setForm({ ...form, locationId: e.target.value })}\n />\n </FormField>\n <FormField\n label={t('botlit.channelRoutes.create.locationName', 'Location name')}\n htmlFor={fieldId('location-name')}\n description={t('botlit.channelRoutes.create.locationNameHint', 'Optional label')}\n >\n <Input\n id={fieldId('location-name')}\n value={form.locationName}\n maxLength={200}\n onChange={(e) => setForm({ ...form, locationName: e.target.value })}\n />\n </FormField>\n </div>\n <FormField\n label={t('botlit.channelRoutes.create.bot', 'Bot')}\n htmlFor={fieldId('bot')}\n required\n error={visibleError('botId')}\n >\n <select\n id={fieldId('bot')}\n className={selectClassName}\n value={form.botId}\n aria-invalid={Boolean(visibleError('botId'))}\n onChange={(e) => setForm({ ...form, botId: e.target.value })}\n >\n <option value=\"\">\n {bots.loading\n ? t('botlit.common.loading', 'Loading...')\n : bots.data.length > 0\n ? t('botlit.channelRoutes.create.botPlaceholder', 'Select a bot...')\n : t('botlit.channelRoutes.create.noBots', 'No bots yet. Create a bot first.')}\n </option>\n {bots.data.map((bot) => (\n <option key={bot.id} value={bot.id}>\n {bot.name}\n </option>\n ))}\n </select>\n </FormField>\n <label className=\"flex items-start gap-2 text-sm\">\n <input\n type=\"checkbox\"\n className=\"mt-1\"\n checked={form.isActive}\n onChange={(e) => setForm({ ...form, isActive: e.target.checked })}\n />\n <span>\n <span className=\"font-medium\">\n {t('botlit.channelRoutes.create.active', 'Turn the route on now')}\n </span>\n <span className=\"block text-text-secondary\">\n {t(\n 'botlit.channelRoutes.create.activeHint',\n 'A route that is off is ignored until you turn it on.'\n )}\n </span>\n </span>\n </label>\n {(connectors.error || bots.error) && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {t(\n 'botlit.channelRoutes.create.errors.optionsUnavailable',\n 'Connectors or bots could not be loaded. Close the form and try again.'\n )}\n </p>\n )}\n {submitError && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {submitError}\n </p>\n )}\n {showErrors && hasErrors && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {t(\n 'botlit.channelRoutes.create.errors.summary',\n 'Fill in the highlighted fields to create the route.'\n )}\n </p>\n )}\n <ResponsiveDialogFooter>\n <Button type=\"button\" variant=\"outline\" onClick={() => void close()}>\n {t('botlit.common.cancel', 'Cancel')}\n </Button>\n <Button type=\"submit\" isLoading={createState.loading}>\n {t('botlit.channelRoutes.create.submit', 'Create route')}\n </Button>\n </ResponsiveDialogFooter>\n </form>\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EACC,yDACA,uEACF;IACC,CAAA;IAEJY,KACC,kBAAC,KAAD;KAAG,MAAK;KAAQ,WAAU;KACvB,UAAAA;IACA,CAAA;IAEJF,KAAca,KACb,kBAAC,KAAD;KAAG,MAAK;KAAQ,WAAU;KACvB,UAAAvB,EACC,8CACA,qDACF;IACC,CAAA;IAEL,kBAACiD,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,eAAe,KAAKzB,EAAM;KAC/D,UAAAzB,EAAE,wBAAwB,QAAQ;IAC7B,CAAA,GACR,kBAACkD,GAAD;KAAQ,MAAK;KAAS,WAAW/B,EAAY;KAC1C,UAAAnB,EAAE,sCAAsC,cAAc;IACjD,CAAA,CACc,EAAA,CAAA;GACpB;EACiB,CAAA,CAAA,EAAA,CAAA;CACT,CAAA;AAEtB"}
@@ -2,7 +2,7 @@
2
2
  * Hooks Index
3
3
  * @module botlit/hooks
4
4
  */
5
- export { useBots, useBotAppCounts, useBot, useCreateBot, useUpdateBot, useDeleteBot, botKeys, } from './useBots';
5
+ export { useBots, useAllBots, useBotAppCounts, useBot, useCreateBot, useUpdateBot, useDeleteBot, botKeys, } from './useBots';
6
6
  export { useAgents, useAgentCounts, useAgent, useCreateAgent, useUpdateAgent, useDeleteAgent, agentKeys, } from './useAgents';
7
7
  export { useKnowledgeBases, useKnowledgeBase, useKnowledgeDocuments, useCreateKnowledgeBase, useUpdateKnowledgeBase, useDeleteKnowledgeBase, useRebuildKnowledgeBaseIndex, knowledgeBaseKeys, } from './useKnowledgeBases';
8
8
  export type { KnowledgeBaseRecord, KnowledgeDocumentRecord } from './useKnowledgeBases';
@@ -12,8 +12,8 @@ export { useMCPServers, useMCPServer, useMCPResources, useMCPTools, useCreateMCP
12
12
  export type { MCPServerRecord, MCPToolRecord, MCPResourceRecord } from './useMCPServers';
13
13
  export { useA2AAgents, useA2AAgent, useRegisterA2AAgent, useUpdateA2AAgent, useDeleteA2AAgent, useValidateA2AAgent, validateAgentCard, a2aAgentSkillCount, a2aKeys, } from './useA2A';
14
14
  export type { A2AAgentRecord } from './useA2A';
15
- export { useChannelConnectors, useAllChannelConnectors, useChannelConnector, useCreateChannelConnector, useUpdateChannelConnector, useDeleteChannelConnector, useFindChannelConnector, useChannelRoutes, useBotChannelRoutes, useChannelRoute, useCreateChannelRoute, useUpdateChannelRoute, useDeleteChannelRoute, routeMetadataString, channelKeys, } from './useChannels';
16
- export type { ChannelConnectorRecord, ChannelRouteRecord } from './useChannels';
15
+ export { useChannelConnectors, useAllChannelConnectors, useChannelConnector, useCreateChannelConnector, useUpdateChannelConnector, useDeleteChannelConnector, useFindChannelConnector, useChannelRoutes, useAllChannelRoutes, useChannelOverview, useBotChannelRoutes, useChannelRoute, useCreateChannelRoute, useUpdateChannelRoute, useDeleteChannelRoute, routeMetadataString, channelKeys, } from './useChannels';
16
+ export type { ChannelConnectorRecord, ChannelRouteRecord, ChannelOverview, ChannelRouteListFilter, } from './useChannels';
17
17
  export { PLATFORM_CREDENTIALS, connectorPlatform, generateSigningSecret, validateCredentials, useActiveOrganizationId, useInboundChannel, useProvisionChannel, } from './useChannelSetup';
18
18
  export type { CredentialFieldDefinition, PlatformCredentialDefinition, InboundChannelData, } from './useChannelSetup';
19
19
  export { usePolicies, usePolicy, useCreatePolicy, useUpdatePolicy, useDeletePolicy, usePoliciesByType, policyKeys, } from './usePolicies';
@@ -1,21 +1,21 @@
1
- import { useBots as e } from "./useBots.js";
2
- import { useAgents as t } from "./useAgents.js";
1
+ import { useAllBots as e, useBots as t } from "./useBots.js";
2
+ import { useAgents as n } from "./useAgents.js";
3
3
  import "./useKnowledgeBases.js";
4
- import { useRetrievalProfiles as n } from "./useRetrievalProfiles.js";
5
- import { isMCPServerHealthy as r, mcpServerDescription as i, mcpServerEndpoint as a, useCreateMCPServer as o, useDeleteMCPServer as s, useMCPResources as c, useMCPServer as l, useMCPTools as u, useTestMCPConnection as d, useUpdateMCPServer as f, useUpdateMCPTool as p } from "./useMCPServers.js";
6
- import { a2aAgentSkillCount as m, useA2AAgents as h } from "./useA2A.js";
7
- import { routeMetadataString as g, useAllChannelConnectors as _, useBotChannelRoutes as v, useChannelConnector as y, useChannelConnectors as b, useChannelRoutes as x, useCreateChannelConnector as S, useCreateChannelRoute as C, useDeleteChannelConnector as w, useDeleteChannelRoute as T, useFindChannelConnector as E, useUpdateChannelConnector as D } from "./useChannels.js";
8
- import { PLATFORM_CREDENTIALS as O, connectorPlatform as k, useActiveOrganizationId as A, useInboundChannel as j, useProvisionChannel as M, validateCredentials as N } from "./useChannelSetup.js";
9
- import { useCreatePolicy as P, useDeletePolicy as F, usePolicies as I, usePolicy as L, useUpdatePolicy as R } from "./usePolicies.js";
10
- import { useApplyRetention as z, useRetentionStatus as B } from "./useRetention.js";
11
- import { useCreateSkill as V, useDeleteSkill as H, useSkill as U, useSkills as W, useUpdateSkill as G } from "./useSkills.js";
12
- import { promptTemplateVariables as K, useCreatePromptTemplate as q, useDeletePromptTemplate as J, usePromptTemplate as Y, usePromptTemplates as X, useRenderPromptTemplate as Z, useUpdatePromptTemplate as Q } from "./usePromptTemplates.js";
13
- import { useAgentBindings as $, usePromptTemplateVersions as ee, useSavePromptTemplateVersion as te, useSetAgentBindings as ne, useTestPromptTemplate as re } from "./useAgentBindings.js";
14
- import { summariseExecutions as ie, useExecutions as ae } from "./useExecutions.js";
15
- import { buildBucketTree as oe, searchTreeRows as se, useAllBuckets as ce, useBucket as le, useBucketBranch as ue, useBucketContents as de, useBucketCount as fe, useBucketSearch as pe, useBuckets as me, useChildBuckets as he, useCreateBucket as ge, useDeleteBucket as _e, useUpdateBucket as ve } from "./useBuckets.js";
16
- import { storePackageDescription as ye, storePackageName as be, useInstallPackage as xe, useInstalledPackageCount as Se, useInstalledPackages as Ce, usePinPackageVersion as we, useStorePackage as Te, useStorePackageCount as Ee, useStorePackages as De, useUninstallPackage as Oe, useUpdateInstalledPackage as ke } from "./useStore.js";
4
+ import { useRetrievalProfiles as r } from "./useRetrievalProfiles.js";
5
+ import { isMCPServerHealthy as i, mcpServerDescription as a, mcpServerEndpoint as o, useCreateMCPServer as s, useDeleteMCPServer as c, useMCPResources as l, useMCPServer as u, useMCPTools as d, useTestMCPConnection as f, useUpdateMCPServer as p, useUpdateMCPTool as m } from "./useMCPServers.js";
6
+ import { a2aAgentSkillCount as h, useA2AAgents as g } from "./useA2A.js";
7
+ import { routeMetadataString as _, useAllChannelConnectors as v, useAllChannelRoutes as y, useBotChannelRoutes as b, useChannelConnector as x, useChannelConnectors as S, useChannelOverview as C, useChannelRoutes as w, useCreateChannelConnector as T, useCreateChannelRoute as E, useDeleteChannelConnector as D, useDeleteChannelRoute as O, useFindChannelConnector as k, useUpdateChannelConnector as A, useUpdateChannelRoute as j } from "./useChannels.js";
8
+ import { PLATFORM_CREDENTIALS as M, connectorPlatform as N, useActiveOrganizationId as P, useInboundChannel as F, useProvisionChannel as I, validateCredentials as L } from "./useChannelSetup.js";
9
+ import { useCreatePolicy as R, useDeletePolicy as z, usePolicies as B, usePolicy as V, useUpdatePolicy as H } from "./usePolicies.js";
10
+ import { useApplyRetention as U, useRetentionStatus as W } from "./useRetention.js";
11
+ import { useCreateSkill as G, useDeleteSkill as K, useSkill as q, useSkills as J, useUpdateSkill as Y } from "./useSkills.js";
12
+ import { promptTemplateVariables as X, useCreatePromptTemplate as Z, useDeletePromptTemplate as Q, usePromptTemplate as $, usePromptTemplates as ee, useRenderPromptTemplate as te, useUpdatePromptTemplate as ne } from "./usePromptTemplates.js";
13
+ import { useAgentBindings as re, usePromptTemplateVersions as ie, useSavePromptTemplateVersion as ae, useSetAgentBindings as oe, useTestPromptTemplate as se } from "./useAgentBindings.js";
14
+ import { summariseExecutions as ce, useExecutions as le } from "./useExecutions.js";
15
+ import { buildBucketTree as ue, searchTreeRows as de, useAllBuckets as fe, useBucket as pe, useBucketBranch as me, useBucketContents as he, useBucketCount as ge, useBucketSearch as _e, useBuckets as ve, useChildBuckets as ye, useCreateBucket as be, useDeleteBucket as xe, useUpdateBucket as Se } from "./useBuckets.js";
16
+ import { storePackageDescription as Ce, storePackageName as we, useInstallPackage as Te, useInstalledPackageCount as Ee, useInstalledPackages as De, usePinPackageVersion as Oe, useStorePackage as ke, useStorePackageCount as Ae, useStorePackages as je, useUninstallPackage as Me, useUpdateInstalledPackage as Ne } from "./useStore.js";
17
17
  import "./useLLMProviders.js";
18
- import { useGlobalChannels as Ae, useInitiateSlackConnect as je, useLinkIntegrationConnection as Me, useMyUserPlatformConnection as Ne, useRevokeSlackConnection as Pe, useToggleSlackNotifications as Fe } from "./useUserPlatformConnection.js";
19
- import { useConfigureSupervisor as Ie, useRunSupervisorNow as Le, useSupervisorConfig as Re, useSupervisorRuns as ze } from "./useAiOperations.js";
20
- import { useAcceptHandoff as Be, useHandoffConfig as Ve, useHandoffQueue as He, useRejectHandoff as Ue, useReleaseHandoff as We, useResolveHandoff as Ge, useUpsertHandoffConfig as Ke } from "./useHandoffs.js";
21
- export { O as PLATFORM_CREDENTIALS, m as a2aAgentSkillCount, oe as buildBucketTree, k as connectorPlatform, r as isMCPServerHealthy, i as mcpServerDescription, a as mcpServerEndpoint, K as promptTemplateVariables, g as routeMetadataString, se as searchTreeRows, ye as storePackageDescription, be as storePackageName, ie as summariseExecutions, h as useA2AAgents, Be as useAcceptHandoff, A as useActiveOrganizationId, $ as useAgentBindings, t as useAgents, ce as useAllBuckets, _ as useAllChannelConnectors, z as useApplyRetention, v as useBotChannelRoutes, e as useBots, le as useBucket, ue as useBucketBranch, de as useBucketContents, fe as useBucketCount, pe as useBucketSearch, me as useBuckets, y as useChannelConnector, b as useChannelConnectors, x as useChannelRoutes, he as useChildBuckets, Ie as useConfigureSupervisor, ge as useCreateBucket, S as useCreateChannelConnector, C as useCreateChannelRoute, o as useCreateMCPServer, P as useCreatePolicy, q as useCreatePromptTemplate, V as useCreateSkill, _e as useDeleteBucket, w as useDeleteChannelConnector, T as useDeleteChannelRoute, s as useDeleteMCPServer, F as useDeletePolicy, J as useDeletePromptTemplate, H as useDeleteSkill, ae as useExecutions, E as useFindChannelConnector, Ae as useGlobalChannels, Ve as useHandoffConfig, He as useHandoffQueue, j as useInboundChannel, je as useInitiateSlackConnect, xe as useInstallPackage, Se as useInstalledPackageCount, Ce as useInstalledPackages, Me as useLinkIntegrationConnection, c as useMCPResources, l as useMCPServer, u as useMCPTools, Ne as useMyUserPlatformConnection, we as usePinPackageVersion, I as usePolicies, L as usePolicy, Y as usePromptTemplate, ee as usePromptTemplateVersions, X as usePromptTemplates, M as useProvisionChannel, Ue as useRejectHandoff, We as useReleaseHandoff, Z as useRenderPromptTemplate, Ge as useResolveHandoff, B as useRetentionStatus, n as useRetrievalProfiles, Pe as useRevokeSlackConnection, Le as useRunSupervisorNow, te as useSavePromptTemplateVersion, ne as useSetAgentBindings, U as useSkill, W as useSkills, Te as useStorePackage, Ee as useStorePackageCount, De as useStorePackages, Re as useSupervisorConfig, ze as useSupervisorRuns, d as useTestMCPConnection, re as useTestPromptTemplate, Fe as useToggleSlackNotifications, Oe as useUninstallPackage, ve as useUpdateBucket, D as useUpdateChannelConnector, ke as useUpdateInstalledPackage, f as useUpdateMCPServer, p as useUpdateMCPTool, R as useUpdatePolicy, Q as useUpdatePromptTemplate, G as useUpdateSkill, Ke as useUpsertHandoffConfig, N as validateCredentials };
18
+ import { useGlobalChannels as Pe, useInitiateSlackConnect as Fe, useLinkIntegrationConnection as Ie, useMyUserPlatformConnection as Le, useRevokeSlackConnection as Re, useToggleSlackNotifications as ze } from "./useUserPlatformConnection.js";
19
+ import { useConfigureSupervisor as Be, useRunSupervisorNow as Ve, useSupervisorConfig as He, useSupervisorRuns as Ue } from "./useAiOperations.js";
20
+ import { useAcceptHandoff as We, useHandoffConfig as Ge, useHandoffQueue as Ke, useRejectHandoff as qe, useReleaseHandoff as Je, useResolveHandoff as Ye, useUpsertHandoffConfig as Xe } from "./useHandoffs.js";
21
+ export { M as PLATFORM_CREDENTIALS, h as a2aAgentSkillCount, ue as buildBucketTree, N as connectorPlatform, i as isMCPServerHealthy, a as mcpServerDescription, o as mcpServerEndpoint, X as promptTemplateVariables, _ as routeMetadataString, de as searchTreeRows, Ce as storePackageDescription, we as storePackageName, ce as summariseExecutions, g as useA2AAgents, We as useAcceptHandoff, P as useActiveOrganizationId, re as useAgentBindings, n as useAgents, e as useAllBots, fe as useAllBuckets, v as useAllChannelConnectors, y as useAllChannelRoutes, U as useApplyRetention, b as useBotChannelRoutes, t as useBots, pe as useBucket, me as useBucketBranch, he as useBucketContents, ge as useBucketCount, _e as useBucketSearch, ve as useBuckets, x as useChannelConnector, S as useChannelConnectors, C as useChannelOverview, w as useChannelRoutes, ye as useChildBuckets, Be as useConfigureSupervisor, be as useCreateBucket, T as useCreateChannelConnector, E as useCreateChannelRoute, s as useCreateMCPServer, R as useCreatePolicy, Z as useCreatePromptTemplate, G as useCreateSkill, xe as useDeleteBucket, D as useDeleteChannelConnector, O as useDeleteChannelRoute, c as useDeleteMCPServer, z as useDeletePolicy, Q as useDeletePromptTemplate, K as useDeleteSkill, le as useExecutions, k as useFindChannelConnector, Pe as useGlobalChannels, Ge as useHandoffConfig, Ke as useHandoffQueue, F as useInboundChannel, Fe as useInitiateSlackConnect, Te as useInstallPackage, Ee as useInstalledPackageCount, De as useInstalledPackages, Ie as useLinkIntegrationConnection, l as useMCPResources, u as useMCPServer, d as useMCPTools, Le as useMyUserPlatformConnection, Oe as usePinPackageVersion, B as usePolicies, V as usePolicy, $ as usePromptTemplate, ie as usePromptTemplateVersions, ee as usePromptTemplates, I as useProvisionChannel, qe as useRejectHandoff, Je as useReleaseHandoff, te as useRenderPromptTemplate, Ye as useResolveHandoff, W as useRetentionStatus, r as useRetrievalProfiles, Re as useRevokeSlackConnection, Ve as useRunSupervisorNow, ae as useSavePromptTemplateVersion, oe as useSetAgentBindings, q as useSkill, J as useSkills, ke as useStorePackage, Ae as useStorePackageCount, je as useStorePackages, He as useSupervisorConfig, Ue as useSupervisorRuns, f as useTestMCPConnection, se as useTestPromptTemplate, ze as useToggleSlackNotifications, Me as useUninstallPackage, Se as useUpdateBucket, A as useUpdateChannelConnector, j as useUpdateChannelRoute, Ne as useUpdateInstalledPackage, p as useUpdateMCPServer, m as useUpdateMCPTool, H as useUpdatePolicy, ne as useUpdatePromptTemplate, Y as useUpdateSkill, Xe as useUpsertHandoffConfig, L as validateCredentials };
@@ -55,6 +55,11 @@ export declare const botKeys: {
55
55
  detail: (id: string) => readonly ["bots", "detail", string];
56
56
  };
57
57
  export declare function useBots(filter?: BaseFilter): PaginatedQueryResult<BotAppRecord[]>;
58
+ /**
59
+ * Every bot of the workspace, all pages. For pickers that must offer each bot
60
+ * (a route can point at any of them), where `useBots` stops at one page.
61
+ */
62
+ export declare function useAllBots(): QueryResult<BotAppRecord[]>;
58
63
  /**
59
64
  * Exact bot counts by status for the workspace (BOFF-12426). Unlike `useBots`
60
65
  * this is not capped at one page, so it is the source for dashboard totals.
@@ -1,11 +1,11 @@
1
1
  import { useBotlit as e } from "../providers/BotlitProvider.js";
2
2
  import { buildMutationInput as t, fieldsOf as n } from "./internal/mutationInput.js";
3
- import { useWorkspacePaginatedQuery as r, useWorkspaceQuery as i } from "./internal/workspaceGateway.js";
4
- import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
5
- import { gql as l } from "@apollo/client";
6
- import { useGatewayClient as u } from "@burdenoff/fe-libs/shared/graphql";
3
+ import { useWorkspaceAllPagesQuery as r, useWorkspacePaginatedQuery as i, useWorkspaceQuery as a } from "./internal/workspaceGateway.js";
4
+ import { useCallback as o, useEffect as s, useMemo as c, useState as l } from "react";
5
+ import { gql as u } from "@apollo/client";
6
+ import { useGatewayClient as d } from "@burdenoff/fe-libs/shared/graphql";
7
7
  // src/botlit/hooks/useBots.ts
8
- var d = l`
8
+ var f = u`
9
9
  query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {
10
10
  listBotApps(filters: $filters, pagination: $pagination) {
11
11
  id
@@ -32,7 +32,7 @@ var d = l`
32
32
  workspaceId
33
33
  }
34
34
  }
35
- `, f = l`
35
+ `, p = u`
36
36
  query GetBotApp($id: ID!) {
37
37
  getBotApp(id: $id) {
38
38
  id
@@ -59,7 +59,7 @@ var d = l`
59
59
  workspaceId
60
60
  }
61
61
  }
62
- `, p = l`
62
+ `, m = u`
63
63
  mutation CreateBotApp($input: CreateBotAppInput!) {
64
64
  createBotApp(input: $input) {
65
65
  id
@@ -80,7 +80,7 @@ var d = l`
80
80
  workspaceId
81
81
  }
82
82
  }
83
- `, m = l`
83
+ `, h = u`
84
84
  mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {
85
85
  updateBotApp(id: $id, input: $input) {
86
86
  id
@@ -103,11 +103,11 @@ var d = l`
103
103
  workspaceId
104
104
  }
105
105
  }
106
- `, h = l`
106
+ `, g = u`
107
107
  mutation DeleteBotApp($id: ID!) {
108
108
  deleteBotApp(id: $id)
109
109
  }
110
- `, g = 100, _ = [], v = n({
110
+ `, _ = 100, v = [], y = n({
111
111
  bucketId: !0,
112
112
  context: !0,
113
113
  defaultAgentId: !0,
@@ -126,10 +126,10 @@ var d = l`
126
126
  welcomeMessage: !0,
127
127
  workflowId: !0
128
128
  });
129
- function y(e) {
129
+ function b(e) {
130
130
  return e;
131
131
  }
132
- function b(e, t) {
132
+ function x(e, t) {
133
133
  if (e || t) return {
134
134
  workspaceId: e,
135
135
  search: t?.search,
@@ -138,20 +138,33 @@ function b(e, t) {
138
138
  bucketId: t?.bucketId
139
139
  };
140
140
  }
141
- function x(t) {
142
- let { workspaceId: n } = e(), i = s(() => ({ filters: b(n, t) }), [t, n]);
143
- return r({
144
- document: d,
145
- variables: i,
146
- pageSize: g,
141
+ function S(t) {
142
+ let { workspaceId: n } = e(), r = c(() => ({ filters: x(n, t) }), [t, n]);
143
+ return i({
144
+ document: f,
145
+ variables: r,
146
+ pageSize: _,
147
147
  extractRows: (e) => e?.listBotApps ?? [],
148
148
  select: (e) => e,
149
- fallback: _,
149
+ fallback: v,
150
150
  enabled: !!n,
151
151
  errorMessage: "Failed to load bots"
152
152
  });
153
153
  }
154
- var S = l`
154
+ function C() {
155
+ let { workspaceId: t } = e(), n = c(() => ({ filters: x(t) }), [t]);
156
+ return r({
157
+ document: f,
158
+ variables: n,
159
+ pageSize: _,
160
+ extractRows: (e) => e?.listBotApps ?? [],
161
+ select: (e) => e,
162
+ fallback: v,
163
+ enabled: !!t,
164
+ errorMessage: "Failed to load bots"
165
+ });
166
+ }
167
+ var w = u`
155
168
  query GetBotAppCounts {
156
169
  getBotAppCounts {
157
170
  total
@@ -162,10 +175,10 @@ var S = l`
162
175
  }
163
176
  }
164
177
  `;
165
- function C(t = !0) {
166
- let { workspaceId: n } = e(), r = s(() => ({}), []);
167
- return i({
168
- document: S,
178
+ function T(t = !0) {
179
+ let { workspaceId: n } = e(), r = c(() => ({}), []);
180
+ return a({
181
+ document: w,
169
182
  variables: r,
170
183
  select: (e) => e?.getBotAppCounts ?? null,
171
184
  fallback: null,
@@ -173,42 +186,42 @@ function C(t = !0) {
173
186
  errorMessage: "Failed to load bot counts"
174
187
  });
175
188
  }
176
- function w(e) {
177
- let t = y(u("workspace")), [n, r] = c(null), [i, s] = c(!!e), [l, d] = c(), p = a(async () => {
178
- if (!e) r(null), s(!1);
189
+ function E(e) {
190
+ let t = b(d("workspace")), [n, r] = l(null), [i, a] = l(!!e), [c, u] = l(), f = o(async () => {
191
+ if (!e) r(null), a(!1);
179
192
  else {
180
- s(!0), d(void 0);
193
+ a(!0), u(void 0);
181
194
  try {
182
195
  let n = await t.query({
183
- query: f,
196
+ query: p,
184
197
  variables: { id: e },
185
198
  fetchPolicy: "network-only"
186
199
  }), i = n.error;
187
200
  if (i != null) throw i instanceof Error ? i : /* @__PURE__ */ Error("Failed to load bot");
188
201
  r(n.data?.getBotApp ?? null);
189
202
  } catch (e) {
190
- r(null), d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load bot"));
203
+ r(null), u(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load bot"));
191
204
  } finally {
192
- s(!1);
205
+ a(!1);
193
206
  }
194
207
  }
195
208
  }, [e, t]);
196
- return o(() => {
197
- p();
198
- }, [p]), {
209
+ return s(() => {
210
+ f();
211
+ }, [f]), {
199
212
  data: n,
200
213
  loading: i,
201
- error: l,
202
- refetch: p
214
+ error: c,
215
+ refetch: f
203
216
  };
204
217
  }
205
- function T() {
206
- let e = y(u("workspace")), [t, n] = c({
218
+ function D() {
219
+ let e = b(d("workspace")), [t, n] = l({
207
220
  data: void 0,
208
221
  loading: !1,
209
222
  error: void 0
210
223
  });
211
- return [a(async (t) => {
224
+ return [o(async (t) => {
212
225
  n({
213
226
  data: void 0,
214
227
  loading: !0,
@@ -216,7 +229,7 @@ function T() {
216
229
  });
217
230
  try {
218
231
  let r = (await e.mutate({
219
- mutation: p,
232
+ mutation: m,
220
233
  variables: { input: t }
221
234
  })).data?.createBotApp;
222
235
  if (!r) throw Error("Failed to create bot");
@@ -235,13 +248,13 @@ function T() {
235
248
  }
236
249
  }, [e]), t];
237
250
  }
238
- function E() {
239
- let e = y(u("workspace")), [n, r] = c({
251
+ function O() {
252
+ let e = b(d("workspace")), [n, r] = l({
240
253
  data: void 0,
241
254
  loading: !1,
242
255
  error: void 0
243
256
  });
244
- return [a(async ({ botId: n, input: i }) => {
257
+ return [o(async ({ botId: n, input: i }) => {
245
258
  r({
246
259
  data: void 0,
247
260
  loading: !0,
@@ -249,10 +262,10 @@ function E() {
249
262
  });
250
263
  try {
251
264
  let a = (await e.mutate({
252
- mutation: m,
265
+ mutation: h,
253
266
  variables: {
254
267
  id: n,
255
- input: t(i, v)
268
+ input: t(i, y)
256
269
  }
257
270
  })).data?.updateBotApp;
258
271
  if (!a) throw Error("Failed to update bot");
@@ -271,13 +284,13 @@ function E() {
271
284
  }
272
285
  }, [e]), n];
273
286
  }
274
- function D() {
275
- let e = y(u("workspace")), [t, n] = c({
287
+ function k() {
288
+ let e = b(d("workspace")), [t, n] = l({
276
289
  data: void 0,
277
290
  loading: !1,
278
291
  error: void 0
279
292
  });
280
- return [a(async (t) => {
293
+ return [o(async (t) => {
281
294
  n({
282
295
  data: void 0,
283
296
  loading: !0,
@@ -285,7 +298,7 @@ function D() {
285
298
  });
286
299
  try {
287
300
  let r = (await e.mutate({
288
- mutation: h,
301
+ mutation: g,
289
302
  variables: { id: t }
290
303
  })).data?.deleteBotApp ?? !1;
291
304
  return n({
@@ -303,6 +316,6 @@ function D() {
303
316
  }
304
317
  }, [e]), t];
305
318
  }
306
- export { w as useBot, C as useBotAppCounts, x as useBots, T as useCreateBot, D as useDeleteBot, E as useUpdateBot };
319
+ export { C as useAllBots, E as useBot, T as useBotAppCounts, S as useBots, D as useCreateBot, k as useDeleteBot, O as useUpdateBot };
307
320
 
308
321
  //# sourceMappingURL=useBots.js.map
@@ -1 +1 @@
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","LIST_PAGE_SIZE","NO_BOTS","UPDATE_BOT_APP_FIELDS","fieldsOf","getWorkspaceClient","client","buildBotFilter","workspaceId","filter","useBots","useBotlit","variables","useMemo","useWorkspacePaginatedQuery","data","rows","GET_BOT_APP_COUNTS_DOCUMENT","useBotAppCounts","useWorkspaceQuery","enabled","useBot","useGatewayClient","setData","useState","loading","setLoading","botId","error","setError","refetch","useCallback","result","operationError","queryError","useEffect","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';\nimport {\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\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 tags\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 tags\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 tags\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 tags\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 /** Entity-owned universal tag records (JSON). */\n tags?: unknown;\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\nconst LIST_PAGE_SIZE = 100;\nconst NO_BOTS: BotAppRecord[] = [];\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 visibility?: 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): PaginatedQueryResult<BotAppRecord[]> {\n const { workspaceId } = useBotlit();\n\n const variables = useMemo(\n () => ({ filters: buildBotFilter(workspaceId, filter) }),\n [filter, workspaceId]\n );\n\n return useWorkspacePaginatedQuery<ListBotAppsData, BotAppRecord, BotAppRecord[]>({\n document: LIST_BOT_APPS_DOCUMENT,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotApps ?? [],\n select: (rows) => rows,\n fallback: NO_BOTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load bots',\n });\n}\n\n/**\n * Exact bot counts by status for the workspace (BOFF-12426). Unlike `useBots`\n * this is not capped at one page, so it is the source for dashboard totals.\n * `total` counts every status; the dashboard shows `total - archived`.\n */\nexport interface BotAppCounts {\n total: number;\n draft: number;\n active: number;\n paused: number;\n archived: number;\n}\n\ninterface BotAppCountsData {\n getBotAppCounts?: BotAppCounts | null;\n}\n\nconst GET_BOT_APP_COUNTS_DOCUMENT = gql`\n query GetBotAppCounts {\n getBotAppCounts {\n total\n draft\n active\n paused\n archived\n }\n }\n`;\n\nexport function useBotAppCounts(enabled = true): QueryResult<BotAppCounts | null> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({}), []);\n\n return useWorkspaceQuery<BotAppCountsData, BotAppCounts | null>({\n document: GET_BOT_APP_COUNTS_DOCUMENT,\n variables,\n select: (data) => data?.getBotAppCounts ?? null,\n fallback: null,\n enabled: enabled && Boolean(workspaceId),\n errorMessage: 'Failed to load bot counts',\n });\n}\n\nexport function useBot(botId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<BotAppRecord | null>(null);\n // Loading from the first render when there is a bot to read, so a page that\n // depends on the bot never acts on \"no bot yet\" for the frame before the read.\n const [loading, setLoading] = useState(Boolean(botId));\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!botId) {\n setData(null);\n setLoading(false);\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 // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL errors.\n // Without this a FORBIDDEN read looked like \"bot not found\" (BOFF-12436).\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error ? operationError : new Error('Failed to load bot');\n }\n setData(result.data?.getBotApp ?? null);\n } catch (queryError) {\n setData(null);\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":";;;;;;;AAeA,IAAMA,IAAyB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6B5BC,IAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6B1BC,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;GAuB7BC,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;;;GAyB7BC,IAA0B,CAAG;;;;GAuC7BC,IAAiB,KACjBC,IAA0B,CAA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B;EACvB,EAAS;GAAE,MAAM,KAAA;GAAW,SAAS;GAAM,OAAO,KAAA;EAAU,CAAC;EAC7D,IAAI;GAMF,IAAMe,KAAU,MALKxC,EAAO,OAAyB;IACnD,UAAUN;IACV,WAAW,EAAE,IAAI2B,EAAM;GACzB,CAAC,EAAA,CAEsB,MAAM,gBAAgB;GAE7C,OADAW,EAAS;IAAE,MAAMQ;IAAS,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACrDA;EACT,SAASN,GAAe;GACtB,IAAMZ,IACJY,aAAyB,QAAQA,IAAgB,gBAAI,MAAM,sBAAsB;GAEnF,MADAF,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;GAAM,CAAC,GAC7CV;EACR;CACF,GACA,CAACtB,CAAM,CAGD,GAAW+B,CAAK;AAC1B"}
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","LIST_PAGE_SIZE","NO_BOTS","UPDATE_BOT_APP_FIELDS","fieldsOf","getWorkspaceClient","client","buildBotFilter","workspaceId","filter","useBots","useBotlit","variables","useMemo","useWorkspacePaginatedQuery","data","rows","useAllBots","useWorkspaceAllPagesQuery","GET_BOT_APP_COUNTS_DOCUMENT","useBotAppCounts","useWorkspaceQuery","enabled","useBot","useGatewayClient","setData","useState","loading","setLoading","botId","error","setError","refetch","useCallback","result","operationError","queryError","useEffect","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';\nimport {\n useWorkspaceAllPagesQuery,\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\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 tags\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 tags\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 tags\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 tags\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 /** Entity-owned universal tag records (JSON). */\n tags?: unknown;\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\nconst LIST_PAGE_SIZE = 100;\nconst NO_BOTS: BotAppRecord[] = [];\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 visibility?: 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): PaginatedQueryResult<BotAppRecord[]> {\n const { workspaceId } = useBotlit();\n\n const variables = useMemo(\n () => ({ filters: buildBotFilter(workspaceId, filter) }),\n [filter, workspaceId]\n );\n\n return useWorkspacePaginatedQuery<ListBotAppsData, BotAppRecord, BotAppRecord[]>({\n document: LIST_BOT_APPS_DOCUMENT,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotApps ?? [],\n select: (rows) => rows,\n fallback: NO_BOTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load bots',\n });\n}\n\n/**\n * Every bot of the workspace, all pages. For pickers that must offer each bot\n * (a route can point at any of them), where `useBots` stops at one page.\n */\nexport function useAllBots(): QueryResult<BotAppRecord[]> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({ filters: buildBotFilter(workspaceId) }), [workspaceId]);\n\n return useWorkspaceAllPagesQuery<ListBotAppsData, BotAppRecord, BotAppRecord[]>({\n document: LIST_BOT_APPS_DOCUMENT,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotApps ?? [],\n select: (rows) => rows,\n fallback: NO_BOTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load bots',\n });\n}\n\n/**\n * Exact bot counts by status for the workspace (BOFF-12426). Unlike `useBots`\n * this is not capped at one page, so it is the source for dashboard totals.\n * `total` counts every status; the dashboard shows `total - archived`.\n */\nexport interface BotAppCounts {\n total: number;\n draft: number;\n active: number;\n paused: number;\n archived: number;\n}\n\ninterface BotAppCountsData {\n getBotAppCounts?: BotAppCounts | null;\n}\n\nconst GET_BOT_APP_COUNTS_DOCUMENT = gql`\n query GetBotAppCounts {\n getBotAppCounts {\n total\n draft\n active\n paused\n archived\n }\n }\n`;\n\nexport function useBotAppCounts(enabled = true): QueryResult<BotAppCounts | null> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({}), []);\n\n return useWorkspaceQuery<BotAppCountsData, BotAppCounts | null>({\n document: GET_BOT_APP_COUNTS_DOCUMENT,\n variables,\n select: (data) => data?.getBotAppCounts ?? null,\n fallback: null,\n enabled: enabled && Boolean(workspaceId),\n errorMessage: 'Failed to load bot counts',\n });\n}\n\nexport function useBot(botId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<BotAppRecord | null>(null);\n // Loading from the first render when there is a bot to read, so a page that\n // depends on the bot never acts on \"no bot yet\" for the frame before the read.\n const [loading, setLoading] = useState(Boolean(botId));\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!botId) {\n setData(null);\n setLoading(false);\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 // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL errors.\n // Without this a FORBIDDEN read looked like \"bot not found\" (BOFF-12436).\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error ? operationError : new Error('Failed to load bot');\n }\n setData(result.data?.getBotApp ?? null);\n } catch (queryError) {\n setData(null);\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":";;;;;;;AAgBA,IAAMA,IAAyB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6B5BC,IAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6B1BC,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;GAuB7BC,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;;;GAyB7BC,IAA0B,CAAG;;;;GAuC7BC,IAAiB,KACjBC,IAA0B,CAAC,GAwC3BC,IAAwBC,EAA4B;CACxD,UAAU;CACV,SAAS;CACT,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,MAAM;CACN,UAAU;CACV,MAAM;CACN,iBAAiB;CACjB,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,MAAM;CACN,YAAY;CACZ,gBAAgB;CAChB,YAAY;AACd,CAAC;AAED,SAASC,EAAmB,GAAkC;CAC5D,OAAOC;AACT;AAEA,SAASC,EACP,GACA,GACqC;CACrC,IAAKC,KAAgBC,GAErB,OAAO;EACL;EACA,QAAQA,GAAQ;EAChB,QAAQA,GAAQ,SAAS;EACzB,YAAYA,GAAQ,aAAa;EACjC,UAAUA,GAAQ;CACpB;AACF;AAUA,SAAgBC,EAAQ,GAA2D;CACjF,IAAM,EAAE,mBAAgBC,EAAU,GAE5BC,IAAYC,SACT,EAAE,SAASN,EAAeC,GAAaC,CAAM,EAAE,IACtD,CAACA,GAAQD,CAAW,CACtB;CAEA,OAAOM,EAA0E;EAC/E,UAAUlB;EACV;EACA,UAAUK;EACV,cAAc,MAASc,GAAM,eAAe,CAAC;EAC7C,SAAS,MAASC;EAClB,UAAUd;EACV,SAAS,EAAQM;EACjB,cAAc;CAChB,CAAC;AAC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B,CAAM,CAGD,GAAWiC,CAAK;AAC1B"}
@@ -1,7 +1,7 @@
1
1
  import { CreateChannelConnectorInput, CreateChannelRouteInput, UpdateChannelConnectorInput, UpdateChannelRouteInput } from '../../generated/wspace-types';
2
2
  import { ChannelFilter } from '../types';
3
3
  import { GraphQLInput } from './internal/mutationInput';
4
- import { QueryResult } from './internal/workspaceGateway';
4
+ import { PaginatedQueryResult, QueryResult } from './internal/workspaceGateway';
5
5
  export interface ChannelConnectorRecord {
6
6
  id: string;
7
7
  name: string;
@@ -13,6 +13,9 @@ export interface ChannelConnectorRecord {
13
13
  credentialsRefId?: string | null;
14
14
  defaultPolicyBindings?: Record<string, unknown> | null;
15
15
  metadata?: Record<string, unknown> | null;
16
+ /** Inbound messages no live route answered (BOFF-12566). */
17
+ unroutedMessageCount: number;
18
+ lastUnroutedAt?: string | null;
16
19
  revision: number;
17
20
  tags: string[];
18
21
  createdAt: string;
@@ -26,9 +29,8 @@ export interface ChannelRouteRecord {
26
29
  appId: string;
27
30
  connectorId: string;
28
31
  locationId: string;
29
- formatPolicyId?: string | null;
30
- policyBindings?: Record<string, unknown> | null;
31
- routingOverrides?: Record<string, unknown> | null;
32
+ /** An inactive route is ignored by inbound routing (BOFF-12566). */
33
+ isActive: boolean;
32
34
  metadata?: Record<string, unknown> | null;
33
35
  revision: number;
34
36
  createdAt: string;
@@ -41,27 +43,19 @@ export interface UpdateChannelConnectorVariables {
41
43
  connectorId: string;
42
44
  input: GraphQLInput<UpdateChannelConnectorInput>;
43
45
  }
46
+ /**
47
+ * Route fields channel routing never applies. They are deprecated in the
48
+ * schema and the service refuses a value (BOFF-12567), so they are never sent.
49
+ */
50
+ type UnappliedRouteField = 'policyBindings' | 'formatPolicyId' | 'routingOverrides';
51
+ type SupportedCreateRouteInput = Omit<CreateChannelRouteInput, UnappliedRouteField>;
52
+ type SupportedUpdateRouteInput = Omit<UpdateChannelRouteInput, UnappliedRouteField>;
44
53
  /** `CreateChannelRouteInput` minus the `workspaceId` the hook supplies. */
45
- export type CreateChannelRouteVariables = Omit<GraphQLInput<CreateChannelRouteInput>, 'workspaceId'>;
54
+ export type CreateChannelRouteVariables = Omit<GraphQLInput<SupportedCreateRouteInput>, 'workspaceId'>;
46
55
  export interface UpdateChannelRouteVariables {
47
56
  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[];
57
+ input: GraphQLInput<SupportedUpdateRouteInput>;
61
58
  }
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
59
  /** Reads a display label the UI stashed on the route's free-form metadata. */
66
60
  export declare function routeMetadataString(route: Pick<ChannelRouteRecord, 'metadata'>, key: string): string | undefined;
67
61
  export declare const channelKeys: {
@@ -73,7 +67,12 @@ export declare const channelKeys: {
73
67
  routeList: (connectorId?: string) => readonly ["channels", "routes", "list", string | undefined];
74
68
  routeDetail: (id: string) => readonly ["channels", "routes", "detail", string];
75
69
  };
76
- export declare function useChannelConnectors(filter?: ChannelFilter): QueryResult<ChannelConnectorRecord[]>;
70
+ /**
71
+ * Connectors of the workspace, one page at a time (BOFF-12569): `loadMore`
72
+ * reaches every row past the first page. Search, type, status and bucket
73
+ * filters are applied by the service.
74
+ */
75
+ export declare function useChannelConnectors(filter?: ChannelFilter): PaginatedQueryResult<ChannelConnectorRecord[]>;
77
76
  export declare function useChannelConnector(connectorId: string | undefined): QueryResult<ChannelConnectorRecord | null>;
78
77
  /**
79
78
  * Every connector of the workspace, all pages (BOFF-15360). For pickers that
@@ -89,7 +88,33 @@ export declare function useFindChannelConnector(): (channelId: string) => Promis
89
88
  export declare function useCreateChannelConnector(): readonly [(input: CreateChannelConnectorVariables) => Promise<ChannelConnectorRecord>, import('./internal/workspaceGateway').MutationState<ChannelConnectorRecord>];
90
89
  export declare function useUpdateChannelConnector(): readonly [(input: UpdateChannelConnectorVariables) => Promise<ChannelConnectorRecord>, import('./internal/workspaceGateway').MutationState<ChannelConnectorRecord>];
91
90
  export declare function useDeleteChannelConnector(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];
92
- export declare function useChannelRoutes(connectorId?: string): QueryResult<ChannelRouteRecord[]>;
91
+ export interface ChannelRouteListFilter {
92
+ connectorId?: string;
93
+ /** Only routes that are on (true) or off (false); all when undefined. */
94
+ isActive?: boolean;
95
+ }
96
+ /**
97
+ * Routes of the workspace (optionally of one connector), one page at a time
98
+ * (BOFF-12569): `loadMore` reaches every row past the first page.
99
+ */
100
+ export declare function useChannelRoutes(filter?: ChannelRouteListFilter): PaginatedQueryResult<ChannelRouteRecord[]>;
101
+ /**
102
+ * Every route of the workspace (or of one connector), all pages. For derived
103
+ * figures that must not stop at the first page, such as route counts.
104
+ */
105
+ export declare function useAllChannelRoutes(connectorId?: string): QueryResult<ChannelRouteRecord[]>;
106
+ export interface ChannelOverview {
107
+ connectorCount: number;
108
+ activeConnectorCount: number;
109
+ routeCount: number;
110
+ activeRouteCount: number;
111
+ unroutedMessageCount: number;
112
+ }
113
+ /**
114
+ * The workspace's real channel totals from the service (BOFF-12569), so tab
115
+ * counts and "Active routes" never depend on how many rows were loaded.
116
+ */
117
+ export declare function useChannelOverview(): QueryResult<ChannelOverview | null>;
93
118
  /** Routes bound to a specific bot app (Bot Detail → Channels tab). */
94
119
  /**
95
120
  * Every route of one bot, all pages: the Channels tab derives which
@@ -100,3 +125,4 @@ export declare function useChannelRoute(routeId: string | undefined): QueryResul
100
125
  export declare function useCreateChannelRoute(): readonly [(input: CreateChannelRouteVariables) => Promise<ChannelRouteRecord>, import('./internal/workspaceGateway').MutationState<ChannelRouteRecord>];
101
126
  export declare function useUpdateChannelRoute(): readonly [(input: UpdateChannelRouteVariables) => Promise<ChannelRouteRecord>, import('./internal/workspaceGateway').MutationState<ChannelRouteRecord>];
102
127
  export declare function useDeleteChannelRoute(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];
128
+ export {};