@burdenoff/microfe-botmanor 2026.1118.7 → 2026.1118.8

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.
@@ -1,5 +1,12 @@
1
1
  import { FC, ReactNode } from 'react';
2
- import { GlobalChannelData } from '../hooks/useUserPlatformConnection';
2
+ /** One thing a bot can be connected to: a workspace connector or a global channel. */
3
+ export interface SelectableChannel {
4
+ id: string;
5
+ name: string;
6
+ /** Platform or connector type (SLACK, WEBHOOK, WEB_WIDGET, …). */
7
+ platform: string;
8
+ description?: string | null;
9
+ }
3
10
  interface ChannelSelectorSheetProps {
4
11
  /** Controls visibility of the sheet */
5
12
  open: boolean;
@@ -8,7 +15,7 @@ interface ChannelSelectorSheetProps {
8
15
  /** Callback when a channel is selected */
9
16
  onSelectChannel: (channelId: string, platform: string) => void;
10
17
  /** Available channels to display (already filtered by backend) */
11
- availableChannels: GlobalChannelData[];
18
+ availableChannels: SelectableChannel[];
12
19
  /** Platform icons mapping */
13
20
  platformIcons: Record<string, ReactNode>;
14
21
  /** Platform metadata mapping */
@@ -1 +1 @@
1
- {"version":3,"file":"ChannelSelectorSheet.js","names":["_Fragment","Fragment$1","ChannelSelectorSheet","useEffect","open","handleEscape","onClose","Button","X","availableChannels","platform","channel","meta","platformMeta","icon","platformIcons","onSelectChannel","Badge"],"sources":["../../../src/botlit/components/ChannelSelectorSheet.tsx"],"sourcesContent":["/**\n * ChannelSelectorSheet\n * @module botlit/components\n *\n * A slide-in sheet component that displays available communication channels\n * for selection when setting up bot integrations.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { useEffect } from 'react';\nimport { X } from 'lucide-react';\nimport { Button } from './Button';\nimport { Badge } from './Badge';\nimport type { GlobalChannelData } from '../hooks/useUserPlatformConnection';\n\ninterface ChannelSelectorSheetProps {\n /** Controls visibility of the sheet */\n open: boolean;\n /** Callback when sheet is closed */\n onClose: () => void;\n /** Callback when a channel is selected */\n onSelectChannel: (channelId: string, platform: string) => void;\n /** Available channels to display (already filtered by backend) */\n availableChannels: GlobalChannelData[];\n /** Platform icons mapping */\n platformIcons: Record<string, ReactNode>;\n /** Platform metadata mapping */\n platformMeta: Record<\n string,\n { label: string; badgeClass: string; accentBg: string; accentText: string }\n >;\n}\n\nexport const ChannelSelectorSheet: FC<ChannelSelectorSheetProps> = ({\n open,\n onClose,\n onSelectChannel,\n availableChannels,\n platformIcons,\n platformMeta,\n}) => {\n // Lock body scroll when sheet is open\n useEffect(() => {\n if (open) {\n document.body.style.overflow = 'hidden';\n } else {\n document.body.style.overflow = '';\n }\n return () => {\n document.body.style.overflow = '';\n };\n }, [open]);\n\n // Close on Escape key\n useEffect(() => {\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === 'Escape' && open) {\n onClose();\n }\n };\n window.addEventListener('keydown', handleEscape);\n return () => window.removeEventListener('keydown', handleEscape);\n }, [open, onClose]);\n\n if (!open) return null;\n\n return (\n <>\n {/* Backdrop */}\n <div\n className=\"fixed inset-0 bg-bg-overlay z-40 transition-opacity duration-300\"\n onClick={onClose}\n aria-hidden=\"true\"\n />\n\n {/* Sheet */}\n <div\n className=\"fixed inset-y-0 right-0 z-50 w-full sm:max-w-md bg-bg-surface shadow-xl transform transition-transform duration-300 ease-out flex flex-col\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"channel-selector-title\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between px-6 py-4 border-b border-border-subtle shrink-0\">\n <div>\n <h2 id=\"channel-selector-title\" className=\"text-lg font-semibold\">\n Select a Channel\n </h2>\n <p className=\"text-sm text-text-secondary mt-0.5\">\n Choose a platform to connect to your bot\n </p>\n </div>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={onClose}\n className=\"shrink-0\"\n aria-label=\"Close\"\n >\n <X size={18} />\n </Button>\n </div>\n\n {/* Content */}\n <div className=\"flex-1 overflow-y-auto px-6 py-4\">\n {availableChannels.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <p className=\"text-sm text-text-secondary\">No channels available to configure.</p>\n <p className=\"text-xs text-text-secondary mt-2\">\n All available channels have already been connected to this bot.\n </p>\n </div>\n ) : (\n <div className=\"space-y-3\">\n {availableChannels.map((channel) => {\n const platform = channel.platform as string;\n const meta = platformMeta[platform] || {\n label: platform,\n badgeClass: 'bg-bg-sunken text-text-secondary',\n accentBg: 'bg-accent',\n accentText: 'text-text-primary',\n };\n const icon = platformIcons[platform];\n\n return (\n <button\n key={channel.id}\n onClick={() => {\n onSelectChannel(channel.id, platform);\n onClose();\n }}\n className=\"w-full text-left p-4 rounded-lg border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] focus:ring-offset-2\"\n >\n <div className=\"flex items-start gap-3\">\n {/* Icon */}\n <div className={`p-2 rounded-md ${meta.accentBg} shrink-0`}>\n <span className={meta.accentText}>{icon}</span>\n </div>\n\n {/* Content */}\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 mb-1\">\n <h3 className=\"font-medium text-sm\">{channel.name}</h3>\n <Badge className={`text-xs ${meta.badgeClass}`}>{meta.label}</Badge>\n </div>\n {channel.description && (\n <p className=\"text-xs text-text-secondary line-clamp-2\">\n {channel.description}\n </p>\n )}\n </div>\n\n {/* Arrow indicator */}\n <div className=\"shrink-0 self-center text-text-secondary\">\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M6 12L10 8L6 4\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </div>\n </div>\n </button>\n );\n })}\n </div>\n )}\n </div>\n\n {/* Footer */}\n <div className=\"px-6 py-4 border-t border-border-subtle shrink-0\">\n <Button variant=\"outline\" onClick={onClose} className=\"w-full\">\n Cancel\n </Button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AAA,CAAA,EAAA,CAAA,IAzHc"}
1
+ {"version":3,"file":"ChannelSelectorSheet.js","names":["_Fragment","Fragment$1","ChannelSelectorSheet","useEffect","open","handleEscape","onClose","Button","X","availableChannels","platform","channel","meta","platformMeta","icon","platformIcons","onSelectChannel","Badge"],"sources":["../../../src/botlit/components/ChannelSelectorSheet.tsx"],"sourcesContent":["/**\n * ChannelSelectorSheet\n * @module botlit/components\n *\n * A slide-in sheet component that displays available communication channels\n * for selection when setting up bot integrations.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { useEffect } from 'react';\nimport { X } from 'lucide-react';\nimport { Button } from './Button';\nimport { Badge } from './Badge';\n\n/** One thing a bot can be connected to: a workspace connector or a global channel. */\nexport interface SelectableChannel {\n id: string;\n name: string;\n /** Platform or connector type (SLACK, WEBHOOK, WEB_WIDGET, …). */\n platform: string;\n description?: string | null;\n}\n\ninterface ChannelSelectorSheetProps {\n /** Controls visibility of the sheet */\n open: boolean;\n /** Callback when sheet is closed */\n onClose: () => void;\n /** Callback when a channel is selected */\n onSelectChannel: (channelId: string, platform: string) => void;\n /** Available channels to display (already filtered by backend) */\n availableChannels: SelectableChannel[];\n /** Platform icons mapping */\n platformIcons: Record<string, ReactNode>;\n /** Platform metadata mapping */\n platformMeta: Record<\n string,\n { label: string; badgeClass: string; accentBg: string; accentText: string }\n >;\n}\n\nexport const ChannelSelectorSheet: FC<ChannelSelectorSheetProps> = ({\n open,\n onClose,\n onSelectChannel,\n availableChannels,\n platformIcons,\n platformMeta,\n}) => {\n // Lock body scroll when sheet is open\n useEffect(() => {\n if (open) {\n document.body.style.overflow = 'hidden';\n } else {\n document.body.style.overflow = '';\n }\n return () => {\n document.body.style.overflow = '';\n };\n }, [open]);\n\n // Close on Escape key\n useEffect(() => {\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === 'Escape' && open) {\n onClose();\n }\n };\n window.addEventListener('keydown', handleEscape);\n return () => window.removeEventListener('keydown', handleEscape);\n }, [open, onClose]);\n\n if (!open) return null;\n\n return (\n <>\n {/* Backdrop */}\n <div\n className=\"fixed inset-0 bg-bg-overlay z-40 transition-opacity duration-300\"\n onClick={onClose}\n aria-hidden=\"true\"\n />\n\n {/* Sheet */}\n <div\n className=\"fixed inset-y-0 right-0 z-50 w-full sm:max-w-md bg-bg-surface shadow-xl transform transition-transform duration-300 ease-out flex flex-col\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"channel-selector-title\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between px-6 py-4 border-b border-border-subtle shrink-0\">\n <div>\n <h2 id=\"channel-selector-title\" className=\"text-lg font-semibold\">\n Select a Channel\n </h2>\n <p className=\"text-sm text-text-secondary mt-0.5\">\n Choose a platform to connect to your bot\n </p>\n </div>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={onClose}\n className=\"shrink-0\"\n aria-label=\"Close\"\n >\n <X size={18} />\n </Button>\n </div>\n\n {/* Content */}\n <div className=\"flex-1 overflow-y-auto px-6 py-4\">\n {availableChannels.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <p className=\"text-sm text-text-secondary\">No channels available to configure.</p>\n <p className=\"text-xs text-text-secondary mt-2\">\n All available channels have already been connected to this bot.\n </p>\n </div>\n ) : (\n <div className=\"space-y-3\">\n {availableChannels.map((channel) => {\n const platform = channel.platform;\n const meta = platformMeta[platform] || {\n label: platform,\n badgeClass: 'bg-bg-sunken text-text-secondary',\n accentBg: 'bg-accent',\n accentText: 'text-text-primary',\n };\n const icon = platformIcons[platform];\n\n return (\n <button\n key={channel.id}\n onClick={() => {\n onSelectChannel(channel.id, platform);\n onClose();\n }}\n className=\"w-full text-left p-4 rounded-lg border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] focus:ring-offset-2\"\n >\n <div className=\"flex items-start gap-3\">\n {/* Icon */}\n <div className={`p-2 rounded-md ${meta.accentBg} shrink-0`}>\n <span className={meta.accentText}>{icon}</span>\n </div>\n\n {/* Content */}\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 mb-1\">\n <h3 className=\"font-medium text-sm\">{channel.name}</h3>\n <Badge className={`text-xs ${meta.badgeClass}`}>{meta.label}</Badge>\n </div>\n {channel.description && (\n <p className=\"text-xs text-text-secondary line-clamp-2\">\n {channel.description}\n </p>\n )}\n </div>\n\n {/* Arrow indicator */}\n <div className=\"shrink-0 self-center text-text-secondary\">\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M6 12L10 8L6 4\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </div>\n </div>\n </button>\n );\n })}\n </div>\n )}\n </div>\n\n {/* Footer */}\n <div className=\"px-6 py-4 border-t border-border-subtle shrink-0\">\n <Button variant=\"outline\" onClick={onClose} className=\"w-full\">\n Cancel\n </Button>\n </div>\n </div>\n </>\n );\n};\n"],"mappings":";;;;;;AAyCA,IAAaE,KAAuD,EAClE,SACA,YACA,oBACA,sBACA,kBACA,uBAGAC,SACMC,IACF,SAAS,KAAK,MAAM,WAAW,WAE/B,SAAS,KAAK,MAAM,WAAW,UAEpB;CACX,SAAS,KAAK,MAAM,WAAW;AACjC,IACC,CAACA,CAAI,CAAC,GAGTD,QAAgB;CACd,IAAME,KAAgB,MAAqB;EACzC,AAAI,EAAE,QAAQ,YAAYD,KACxBE,EAAQ;CAEZ;CAEA,OADA,OAAO,iBAAiB,WAAWD,CAAY,SAClC,OAAO,oBAAoB,WAAWA,CAAY;AACjE,GAAG,CAACD,GAAME,CAAO,CAAC,GAEbF,IAGH,kBAAAJ,GAAA,EAAA,UAAA,CAEE,kBAAC,OAAD;CACE,WAAU;CACV,SAASM;CACT,eAAY;AACb,CAAA,GAGD,kBAAC,OAAD;CACE,W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D;WAAI,WAAU;WAAuB,UAAAH,EAAQ;UAAS,CAAA,GACtD,kBAACM,GAAD;WAAO,WAAW,WAAWL,EAAK;WAAe,UAAAA,EAAK;UAAa,CAAA,CAChE;SACJ,CAAA,GAAAD,EAAQ,eACP,kBAAC,KAAD;UAAG,WAAU;UACV,UAAAA,EAAQ;SACR,CAAA,CAEF;;QAGL,kBAAC,OAAD;SAAK,WAAU;SACb,UAAA,kBAAC,OAAD;UACE,OAAM;UACN,QAAO;UACP,SAAQ;UACR,MAAK;UACL,OAAM;UAEN,UAAA,kBAAC,QAAD;WACE,GAAE;WACF,QAAO;WACP,aAAY;WACZ,eAAc;WACd,gBAAe;UAChB,CAAA;SACE,CAAA;QACF,CAAA;OACF;;KACC,GA7CDA,EAAQ,EA6CP;IAEZ,CAAC;GACE,CAAA;EAEJ,CAAA;EAGL,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAACJ,GAAD;IAAQ,SAAQ;IAAU,SAASD;IAAS,WAAU;IAAS,UAAA;GAEvD,CAAA;EACL,CAAA;CACF;AACL,CAAA,CAAA,EAAA,CAAA,IAzHc"}
@@ -12,7 +12,7 @@ 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, useChannelConnector, useCreateChannelConnector, useUpdateChannelConnector, useDeleteChannelConnector, useFindChannelConnector, useChannelRoutes, useBotChannelRoutes, useChannelRoute, useCreateChannelRoute, useUpdateChannelRoute, useDeleteChannelRoute, routeMetadataString, channelKeys, } from './useChannels';
15
+ export { useChannelConnectors, useAllChannelConnectors, useChannelConnector, useCreateChannelConnector, useUpdateChannelConnector, useDeleteChannelConnector, useFindChannelConnector, useChannelRoutes, useBotChannelRoutes, useChannelRoute, useCreateChannelRoute, useUpdateChannelRoute, useDeleteChannelRoute, routeMetadataString, channelKeys, } from './useChannels';
16
16
  export type { ChannelConnectorRecord, ChannelRouteRecord } from './useChannels';
17
17
  export { PLATFORM_CREDENTIALS, connectorPlatform, generateSigningSecret, validateCredentials, useActiveOrganizationId, useInboundChannel, useProvisionChannel, } from './useChannelSetup';
18
18
  export type { CredentialFieldDefinition, PlatformCredentialDefinition, InboundChannelData, } from './useChannelSetup';
@@ -4,18 +4,18 @@ import "./useKnowledgeBases.js";
4
4
  import { useRetrievalProfiles as n } from "./useRetrievalProfiles.js";
5
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
6
  import { a2aAgentSkillCount as m, useA2AAgents as h } from "./useA2A.js";
7
- import { routeMetadataString as g, useBotChannelRoutes as _, useChannelConnector as v, useChannelConnectors as y, useChannelRoutes as b, useCreateChannelConnector as x, useCreateChannelRoute as S, useDeleteChannelConnector as C, useDeleteChannelRoute as w, useFindChannelConnector as T, useUpdateChannelConnector as E } from "./useChannels.js";
8
- import { PLATFORM_CREDENTIALS as D, connectorPlatform as O, useActiveOrganizationId as k, useInboundChannel as A, useProvisionChannel as j, validateCredentials as M } from "./useChannelSetup.js";
9
- import { useCreatePolicy as N, useDeletePolicy as P, usePolicies as F, usePolicy as I, useUpdatePolicy as L } from "./usePolicies.js";
10
- import { useApplyRetention as R, useRetentionStatus as z } from "./useRetention.js";
11
- import { useCreateSkill as B, useDeleteSkill as V, useSkill as H, useSkills as U, useUpdateSkill as W } from "./useSkills.js";
12
- import { promptTemplateVariables as G, useCreatePromptTemplate as K, useDeletePromptTemplate as q, usePromptTemplate as J, usePromptTemplates as Y, useRenderPromptTemplate as X, useUpdatePromptTemplate as Z } from "./usePromptTemplates.js";
13
- import { useAgentBindings as Q, usePromptTemplateVersions as $, useSavePromptTemplateVersion as ee, useSetAgentBindings as te, useTestPromptTemplate as ne } from "./useAgentBindings.js";
14
- import { summariseExecutions as re, useExecutions as ie } from "./useExecutions.js";
15
- import { useBucket as ae, useBucketTree as oe, useBuckets as se, useChildBuckets as ce, useCreateBucket as le, useDeleteBucket as ue, useUpdateBucket as de } from "./useBuckets.js";
16
- import { storePackageDescription as fe, storePackageName as pe, useInstallPackage as me, useInstalledPackages as he, usePinPackageVersion as ge, useStorePackage as _e, useStorePackages as ve, useUninstallPackage as ye, useUpdateInstalledPackage as be } from "./useStore.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 { useBucket as oe, useBucketTree as se, useBuckets as ce, useChildBuckets as le, useCreateBucket as ue, useDeleteBucket as de, useUpdateBucket as fe } from "./useBuckets.js";
16
+ import { storePackageDescription as pe, storePackageName as me, useInstallPackage as he, useInstalledPackages as ge, usePinPackageVersion as _e, useStorePackage as ve, useStorePackages as ye, useUninstallPackage as be, useUpdateInstalledPackage as xe } from "./useStore.js";
17
17
  import "./useLLMProviders.js";
18
- import { useGlobalChannels as xe, useInitiateSlackConnect as Se, useLinkIntegrationConnection as Ce, useMyUserPlatformConnection as we, useRevokeSlackConnection as Te, useToggleSlackNotifications as Ee } from "./useUserPlatformConnection.js";
19
- import { useConfigureSupervisor as De, useRunSupervisorNow as Oe, useSupervisorConfig as ke, useSupervisorRuns as Ae } from "./useAiOperations.js";
20
- import { useAcceptHandoff as je, useHandoffConfig as Me, useHandoffQueue as Ne, useRejectHandoff as Pe, useReleaseHandoff as Fe, useResolveHandoff as Ie, useUpsertHandoffConfig as Le } from "./useHandoffs.js";
21
- export { D as PLATFORM_CREDENTIALS, m as a2aAgentSkillCount, O as connectorPlatform, r as isMCPServerHealthy, i as mcpServerDescription, a as mcpServerEndpoint, G as promptTemplateVariables, g as routeMetadataString, fe as storePackageDescription, pe as storePackageName, re as summariseExecutions, h as useA2AAgents, je as useAcceptHandoff, k as useActiveOrganizationId, Q as useAgentBindings, t as useAgents, R as useApplyRetention, _ as useBotChannelRoutes, e as useBots, ae as useBucket, oe as useBucketTree, se as useBuckets, v as useChannelConnector, y as useChannelConnectors, b as useChannelRoutes, ce as useChildBuckets, De as useConfigureSupervisor, le as useCreateBucket, x as useCreateChannelConnector, S as useCreateChannelRoute, o as useCreateMCPServer, N as useCreatePolicy, K as useCreatePromptTemplate, B as useCreateSkill, ue as useDeleteBucket, C as useDeleteChannelConnector, w as useDeleteChannelRoute, s as useDeleteMCPServer, P as useDeletePolicy, q as useDeletePromptTemplate, V as useDeleteSkill, ie as useExecutions, T as useFindChannelConnector, xe as useGlobalChannels, Me as useHandoffConfig, Ne as useHandoffQueue, A as useInboundChannel, Se as useInitiateSlackConnect, me as useInstallPackage, he as useInstalledPackages, Ce as useLinkIntegrationConnection, c as useMCPResources, l as useMCPServer, u as useMCPTools, we as useMyUserPlatformConnection, ge as usePinPackageVersion, F as usePolicies, I as usePolicy, J as usePromptTemplate, $ as usePromptTemplateVersions, Y as usePromptTemplates, j as useProvisionChannel, Pe as useRejectHandoff, Fe as useReleaseHandoff, X as useRenderPromptTemplate, Ie as useResolveHandoff, z as useRetentionStatus, n as useRetrievalProfiles, Te as useRevokeSlackConnection, Oe as useRunSupervisorNow, ee as useSavePromptTemplateVersion, te as useSetAgentBindings, H as useSkill, U as useSkills, _e as useStorePackage, ve as useStorePackages, ke as useSupervisorConfig, Ae as useSupervisorRuns, d as useTestMCPConnection, ne as useTestPromptTemplate, Ee as useToggleSlackNotifications, ye as useUninstallPackage, de as useUpdateBucket, E as useUpdateChannelConnector, be as useUpdateInstalledPackage, f as useUpdateMCPServer, p as useUpdateMCPTool, L as useUpdatePolicy, Z as useUpdatePromptTemplate, W as useUpdateSkill, Le as useUpsertHandoffConfig, M as validateCredentials };
18
+ import { useGlobalChannels as Se, useInitiateSlackConnect as Ce, useLinkIntegrationConnection as we, useMyUserPlatformConnection as Te, useRevokeSlackConnection as Ee, useToggleSlackNotifications as De } from "./useUserPlatformConnection.js";
19
+ import { useConfigureSupervisor as Oe, useRunSupervisorNow as ke, useSupervisorConfig as Ae, useSupervisorRuns as je } from "./useAiOperations.js";
20
+ import { useAcceptHandoff as Me, useHandoffConfig as Ne, useHandoffQueue as Pe, useRejectHandoff as Fe, useReleaseHandoff as Ie, useResolveHandoff as Le, useUpsertHandoffConfig as Re } from "./useHandoffs.js";
21
+ export { O as PLATFORM_CREDENTIALS, m as a2aAgentSkillCount, k as connectorPlatform, r as isMCPServerHealthy, i as mcpServerDescription, a as mcpServerEndpoint, K as promptTemplateVariables, g as routeMetadataString, pe as storePackageDescription, me as storePackageName, ie as summariseExecutions, h as useA2AAgents, Me as useAcceptHandoff, A as useActiveOrganizationId, $ as useAgentBindings, t as useAgents, _ as useAllChannelConnectors, z as useApplyRetention, v as useBotChannelRoutes, e as useBots, oe as useBucket, se as useBucketTree, ce as useBuckets, y as useChannelConnector, b as useChannelConnectors, x as useChannelRoutes, le as useChildBuckets, Oe as useConfigureSupervisor, ue as useCreateBucket, S as useCreateChannelConnector, C as useCreateChannelRoute, o as useCreateMCPServer, P as useCreatePolicy, q as useCreatePromptTemplate, V as useCreateSkill, de 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, Se as useGlobalChannels, Ne as useHandoffConfig, Pe as useHandoffQueue, j as useInboundChannel, Ce as useInitiateSlackConnect, he as useInstallPackage, ge as useInstalledPackages, we as useLinkIntegrationConnection, c as useMCPResources, l as useMCPServer, u as useMCPTools, Te as useMyUserPlatformConnection, _e as usePinPackageVersion, I as usePolicies, L as usePolicy, Y as usePromptTemplate, ee as usePromptTemplateVersions, X as usePromptTemplates, M as useProvisionChannel, Fe as useRejectHandoff, Ie as useReleaseHandoff, Z as useRenderPromptTemplate, Le as useResolveHandoff, B as useRetentionStatus, n as useRetrievalProfiles, Ee as useRevokeSlackConnection, ke as useRunSupervisorNow, te as useSavePromptTemplateVersion, ne as useSetAgentBindings, U as useSkill, W as useSkills, ve as useStorePackage, ye as useStorePackages, Ae as useSupervisorConfig, je as useSupervisorRuns, d as useTestMCPConnection, re as useTestPromptTemplate, De as useToggleSlackNotifications, be as useUninstallPackage, fe as useUpdateBucket, D as useUpdateChannelConnector, xe as useUpdateInstalledPackage, f as useUpdateMCPServer, p as useUpdateMCPTool, R as useUpdatePolicy, Q as useUpdatePromptTemplate, G as useUpdateSkill, Re as useUpsertHandoffConfig, N as validateCredentials };
@@ -0,0 +1,15 @@
1
+ import { ApolloClient, DefaultContext } from '../../../../node_modules/@apollo/client';
2
+ export interface WorkspaceScopedGlobalClient {
3
+ /** The shell's global-gateway client. */
4
+ client: ApolloClient;
5
+ /** Apollo operation context to pass on every call made through `client`. */
6
+ context: DefaultContext;
7
+ }
8
+ /**
9
+ * Operation context that scopes a global call to `workspaceId`'s organization.
10
+ * Without a workspace there is nothing to scope to and the call keeps the
11
+ * account scope.
12
+ */
13
+ export declare function workspaceScopeContext(workspaceId: string | null | undefined): DefaultContext;
14
+ /** The global client plus the context that scopes its calls to the active workspace. */
15
+ export declare function useWorkspaceScopedGlobalClient(): WorkspaceScopedGlobalClient;
@@ -0,0 +1,21 @@
1
+ import { useBotlit as e } from "../../providers/BotlitProvider.js";
2
+ import { useMemo as t } from "react";
3
+ import { useGatewayClient as n } from "@burdenoff/fe-libs/shared/graphql";
4
+ // src/botlit/hooks/internal/globalWorkspaceScope.ts
5
+ function r(e) {
6
+ return e ? {
7
+ requiredWorkspaceAuth: !0,
8
+ requiredWorkspaceId: e,
9
+ queryDeduplication: !1
10
+ } : {};
11
+ }
12
+ function i() {
13
+ let i = n("global"), { workspaceId: a } = e();
14
+ return t(() => ({
15
+ client: i,
16
+ context: r(a)
17
+ }), [i, a]);
18
+ }
19
+ export { i as useWorkspaceScopedGlobalClient, r as workspaceScopeContext };
20
+
21
+ //# sourceMappingURL=globalWorkspaceScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalWorkspaceScope.js","names":["workspaceScopeContext","workspaceId","useWorkspaceScopedGlobalClient","client","useGatewayClient","useBotlit","useMemo"],"sources":["../../../../src/botlit/hooks/internal/globalWorkspaceScope.ts"],"sourcesContent":["/**\n * Global-gateway calls made for the active workspace\n * @module botlit/hooks/internal\n *\n * Global channels (and the platform connections on them) belong to an\n * organization. The global public gateway takes a user session's organization\n * from the account JWT — the user's home organization — and never from a\n * header. A workspace of another organization therefore created its channels\n * in the home organization (the connector bind then failed with \"The channel\n * was not found in this organization\") and could not list its own channels\n * (`GetChannels` 403) (BOFF-15360).\n *\n * The shell's global client attaches the active workspace's token when an\n * operation asks for workspace scope (`requiredWorkspaceAuth`); the gateway\n * then takes the organization, tenant and workspace from that verified token.\n * Required, not preferred: a channel created in the account organization is\n * the bug, so a missing token or a workspace switch mid-request must fail the\n * operation instead of silently falling back.\n */\n\nimport type { ApolloClient, DefaultContext } from '@apollo/client';\nimport { useMemo } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../../providers/BotlitProvider';\n\nexport interface WorkspaceScopedGlobalClient {\n /** The shell's global-gateway client. */\n client: ApolloClient;\n /** Apollo operation context to pass on every call made through `client`. */\n context: DefaultContext;\n}\n\n/**\n * Operation context that scopes a global call to `workspaceId`'s organization.\n * Without a workspace there is nothing to scope to and the call keeps the\n * account scope.\n */\nexport function workspaceScopeContext(workspaceId: string | null | undefined): DefaultContext {\n if (!workspaceId) return {};\n // Deduplication could hand one workspace's in-flight answer to another.\n return {\n requiredWorkspaceAuth: true,\n requiredWorkspaceId: workspaceId,\n queryDeduplication: false,\n };\n}\n\n/** The global client plus the context that scopes its calls to the active workspace. */\nexport function useWorkspaceScopedGlobalClient(): WorkspaceScopedGlobalClient {\n const client = useGatewayClient('global');\n const { workspaceId } = useBotlit();\n return useMemo(\n () => ({ client, context: workspaceScopeContext(workspaceId) }),\n [client, workspaceId]\n );\n}\n"],"mappings":";;;;AAsCA,SAAgBA,EAAsB,GAAwD;CAG5F,OAFKC,IAEE;EACL,uBAAuB;EACvB,qBAAqBA;EACrB,oBAAoB;CACtB,IANyB,CAAC;AAO5B;AAGA,SAAgBC,IAA8D;CAC5E,IAAMC,IAASC,EAAiB,QAAQ,GAClC,EAAE,mBAAgBC,EAAU;CAClC,OAAOC,SACE;EAAE;EAAQ,SAASN,EAAsBC,CAAW;CAAE,IAC7D,CAACE,GAAQF,CAAW,CACtB;AACF"}
@@ -83,6 +83,13 @@ export interface WorkspacePaginatedQueryOptions<TData, TRow, TResult> {
83
83
  * (e.g. executions search) sees every loaded page, not just the last one.
84
84
  */
85
85
  export declare function useWorkspacePaginatedQuery<TData, TRow, TResult>(options: WorkspacePaginatedQueryOptions<TData, TRow, TResult>): PaginatedQueryResult<TResult>;
86
+ /**
87
+ * Every page of an offset-paginated list (BOFF-15360), for callers that must
88
+ * see the whole list at once (pickers, "already configured" checks).
89
+ * `loading` holds until the last page has arrived; a failed page stops paging
90
+ * and sets `error`. `refetch` restarts from page one.
91
+ */
92
+ export declare function useWorkspaceAllPagesQuery<TData, TRow, TResult>(options: WorkspacePaginatedQueryOptions<TData, TRow, TResult>): QueryResult<TResult>;
86
93
  export interface WorkspaceMutationOptions<TData, TInput, TResult> {
87
94
  /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */
88
95
  document: DocumentNode;
@@ -58,10 +58,11 @@ function f(e) {
58
58
  }
59
59
  var p = [];
60
60
  function m(e) {
61
- let { document: t, variables: i, pageSize: s, enabled: l, errorMessage: f } = e, m = c(), h = d(e.select), g = d(e.extractRows), [_, v] = o([]), y = a([]), [b, x] = o(e.fallback), [S, C] = o(!1), [w, T] = o(!1), [E, D] = o(!0), [O, k] = o(), A = n((e) => {
61
+ let { document: t, variables: i, pageSize: s, enabled: l, errorMessage: f } = e, m = c(), h = d(e.select), g = d(e.extractRows), [_, v] = o([]), y = a([]), [b, x] = o(e.fallback), [S, C] = o(!1), [w, T] = o(!1), [E, D] = o(!0), [O, k] = o(), A = a(0), j = n((e) => {
62
62
  y.current = e, v(e), x(h.current(e));
63
- }, [h]), j = n(async (e, n) => {
64
- n ? T(!0) : C(!0), k(void 0);
63
+ }, [h]), M = n(async (e, n) => {
64
+ let r = n ? A.current : ++A.current, a = () => r === A.current;
65
+ n ? T(!0) : (C(!0), T(!1)), k(void 0);
65
66
  try {
66
67
  let r = await m.query({
67
68
  query: t,
@@ -73,14 +74,16 @@ function m(e) {
73
74
  }
74
75
  },
75
76
  fetchPolicy: "network-only"
76
- }), a = r.error;
77
- if (a != null) throw u(a, f);
78
- let o = g.current(r.data ?? void 0) ?? [];
79
- A(n ? [...y.current, ...o] : o), D(o.length < s);
77
+ });
78
+ if (!a()) return;
79
+ let o = r.error;
80
+ if (o != null) throw u(o, f);
81
+ let c = g.current(r.data ?? void 0) ?? [];
82
+ j(n ? [...y.current, ...c] : c), D(c.length < s);
80
83
  } catch (e) {
81
- k(u(e, f));
84
+ a() && k(u(e, f));
82
85
  } finally {
83
- n ? T(!1) : C(!1);
86
+ a() && (n ? T(!1) : C(!1));
84
87
  }
85
88
  }, [
86
89
  m,
@@ -89,33 +92,50 @@ function m(e) {
89
92
  s,
90
93
  f,
91
94
  g,
92
- A
93
- ]), M = n(async () => {
94
- l ? await j(0, !1) : (A(p), D(!0), k(void 0));
95
+ j
96
+ ]), N = n(async () => {
97
+ l ? await M(0, !1) : (j(p), D(!0), k(void 0));
95
98
  }, [
96
99
  l,
97
- j,
98
- A
99
- ]), N = n(async () => {
100
- l && !E && await j(y.current.length, !0);
100
+ M,
101
+ j
102
+ ]), P = n(async () => {
103
+ l && !E && await M(y.current.length, !0);
101
104
  }, [
102
105
  l,
103
106
  E,
104
- j
107
+ M
105
108
  ]);
106
109
  return r(() => {
107
- M();
108
- }, [M]), {
110
+ N();
111
+ }, [N]), {
109
112
  data: b,
110
113
  loading: S,
111
114
  loadingMore: w,
112
115
  hasMore: !E,
113
116
  error: O,
114
- refetch: M,
115
- loadMore: N
117
+ refetch: N,
118
+ loadMore: P
116
119
  };
117
120
  }
118
121
  function h(e) {
122
+ let { data: t, loading: n, loadingMore: i, hasMore: a, error: o, refetch: s, loadMore: c } = m(e);
123
+ return r(() => {
124
+ a && !n && !i && !o && c();
125
+ }, [
126
+ a,
127
+ n,
128
+ i,
129
+ o,
130
+ c
131
+ ]), {
132
+ data: t,
133
+ loading: n || i || a && !o,
134
+ error: o,
135
+ refetch: s
136
+ };
137
+ }
138
+ function g(e) {
119
139
  let { document: t, errorMessage: r } = e, i = c(), a = d(e.variables), s = d(e.select), [l, f] = o({
120
140
  data: void 0,
121
141
  loading: !1,
@@ -156,6 +176,6 @@ function h(e) {
156
176
  a
157
177
  ]), l];
158
178
  }
159
- export { c as useWorkspaceClient, l as useWorkspaceId, h as useWorkspaceMutation, m as useWorkspacePaginatedQuery, f as useWorkspaceQuery };
179
+ export { h as useWorkspaceAllPagesQuery, c as useWorkspaceClient, l as useWorkspaceId, g as useWorkspaceMutation, m as useWorkspacePaginatedQuery, f as useWorkspaceQuery };
160
180
 
161
181
  //# sourceMappingURL=workspaceGateway.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspaceGateway.js","names":["useWorkspaceClient","useGatewayClient","useWorkspaceId","useBotlit","toError","message","extractGraphqlFailureMessage","cause","fallbackMessage","useLatest","ref","useRef","value","useLayoutEffect","useWorkspaceQuery","options","client","selectRef","fallbackRef","data","setData","useState","loading","setLoading","error","setError","refetch","useCallback","enabled","result","document","operationError","errorMessage","queryError","variables","useEffect","NO_ROWS","useWorkspacePaginatedQuery","extractRowsRef","rows","setRows","rowsRef","loadingMore","setLoadingMore","exhausted","setExhausted","replaceRows","next","fetchPage","append","pageSize","pageRows","loadMore","useWorkspaceMutation","variablesRef","state","setState","input","selected","mutationError","failure"],"sources":["../../../../src/botlit/hooks/internal/workspaceGateway.ts"],"sourcesContent":["/**\n * Workspace gateway hook primitives\n * @module botlit/hooks/internal\n *\n * Every BotManor hook talks to the workspace public gateway through the Apollo\n * client the shell installs (`useGatewayClient('workspace')`) — never through a\n * client of its own. These primitives capture the exact shape used by the\n * reference hooks (`useAgents`, `useBots`): `network-only` reads, an explicit\n * `Error` in state rather than a thrown promise, and a `refetch` the caller can\n * run after a mutation.\n */\n\nimport type { ApolloClient, DocumentNode } from '@apollo/client';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../../providers/BotlitProvider';\nimport { extractGraphqlFailureMessage } from '../../utils/errors';\n\nexport type WorkspaceClient = ApolloClient;\n\n/** Apollo client for the workspace gateway, provided by the host shell. */\nexport function useWorkspaceClient(): WorkspaceClient {\n return useGatewayClient('workspace');\n}\n\n/** Current workspace id from the BotManor context (undefined until the shell resolves it). */\nexport function useWorkspaceId(): string | undefined {\n return useBotlit().workspaceId;\n}\n\nexport interface QueryResult<T> {\n data: T;\n loading: boolean;\n /** Set only when the request FAILED. An empty `data` with no `error` means \"no records yet\". */\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\nexport interface PaginatedQueryResult<T> extends QueryResult<T> {\n /** True while the next page is being appended. */\n loadingMore: boolean;\n /**\n * True when the most recent page came back full, i.e. another page may\n * exist. False before the first page resolves and once a short page\n * (or an empty one) marks the end of the list.\n */\n hasMore: boolean;\n /**\n * Fetches the next page (current row count as offset) and appends it.\n * No-op while a fetch is in flight or when `hasMore` is false.\n */\n loadMore: () => Promise<void>;\n}\n\nexport interface MutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\n/**\n * Normalises any mutation failure to an Error with the server's\n * user-actionable message where one exists.\n *\n * Apollo Client v4 does not reject with a plain Error: failures arrive as\n * `{ networkError }` / `{ graphQLErrors }` objects, and the batched fetch\n * layer attaches the structured GraphQL errors as `.errors` on the\n * networkError. `extractGraphqlFailureMessage` unwraps all of those; only\n * when nothing user-actionable is present do we fall back to the hook's\n * generic `errorMessage`.\n */\nfunction toError(cause: unknown, fallbackMessage: string): Error {\n const message = extractGraphqlFailureMessage(cause);\n if (message) {\n // Preserve the original rejection on the chain so error monitoring can\n // still reach the structured GraphQL errors (extensions.code, requestId…).\n return new Error(message, { cause });\n }\n if (cause instanceof Error) return cause;\n return new Error(fallbackMessage, { cause });\n}\n\n/** Keeps a mutable ref pointing at the latest value without re-running effects. */\nfunction useLatest<T>(value: T): { readonly current: T } {\n const ref = useRef(value);\n useLayoutEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n\nexport interface WorkspaceQueryOptions<TData, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Must be referentially stable — memoize at the call site. */\n variables: Record<string, unknown> | undefined;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id / no entity id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Reads from the workspace gateway and keeps `{ data, loading, error, refetch }`\n * in sync. `error` is reserved for real failures so callers can tell an empty\n * collection apart from a failed request.\n */\nexport function useWorkspaceQuery<TData, TResult>(\n options: WorkspaceQueryOptions<TData, TResult>\n): QueryResult<TResult> {\n const { document, variables, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const fallbackRef = useLatest(options.fallback);\n\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n setData(fallbackRef.current);\n setError(undefined);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables,\n fetchPolicy: 'network-only',\n });\n // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL\n // errors — same handling as useWorkspaceMutation.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n setData(selectRef.current(result.data ?? undefined));\n } catch (queryError) {\n setData(fallbackRef.current);\n setError(toError(queryError, errorMessage));\n } finally {\n setLoading(false);\n }\n // fallbackRef/selectRef are stable refs by construction\n }, [client, document, variables, enabled, errorMessage, fallbackRef, selectRef]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\n/** Shared empty page, so a disabled paginated query keeps one stable value. */\nconst NO_ROWS: never[] = [];\n\nexport interface WorkspacePaginatedQueryOptions<TData, TRow, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /**\n * Base variables (filters, ids, …) WITHOUT `pagination` — the hook adds\n * `{ limit: pageSize, offset }` per fetch. Must be referentially stable;\n * a new identity resets the accumulation back to page one.\n */\n variables: Record<string, unknown> | undefined;\n /** Page size for each fetch. */\n pageSize: number;\n /** Extracts the raw row list from a page payload; missing data yields []. */\n extractRows: (data: TData | undefined) => TRow[] | undefined;\n /** Projects the ACCUMULATED raw rows onto the record shape the UI consumes. */\n select: (rows: TRow[]) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Offset-paginated variant of `useWorkspaceQuery` for unbounded lists.\n *\n * `refetch()` restarts at offset 0 and REPLACES the accumulated rows;\n * `loadMore()` fetches the next page and appends it. A page that returns\n * fewer rows than `pageSize` marks the list exhausted (`hasMore` false).\n * `select` runs over the accumulated raw rows, so client-side narrowing\n * (e.g. executions search) sees every loaded page, not just the last one.\n */\nexport function useWorkspacePaginatedQuery<TData, TRow, TResult>(\n options: WorkspacePaginatedQueryOptions<TData, TRow, TResult>\n): PaginatedQueryResult<TResult> {\n const { document, variables, pageSize, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const extractRowsRef = useLatest(options.extractRows);\n\n const [rows, setRows] = useState<TRow[]>([]);\n const rowsRef = useRef<TRow[]>([]);\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [loadingMore, setLoadingMore] = useState(false);\n const [exhausted, setExhausted] = useState(true);\n const [error, setError] = useState<Error | undefined>();\n\n const replaceRows = useCallback(\n (next: TRow[]) => {\n rowsRef.current = next;\n setRows(next);\n setData(selectRef.current(next));\n },\n [selectRef]\n );\n\n const fetchPage = useCallback(\n async (offset: number, append: boolean) => {\n if (append) setLoadingMore(true);\n else setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables: { ...variables, pagination: { limit: pageSize, offset } },\n fetchPolicy: 'network-only',\n });\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n const pageRows = extractRowsRef.current(result.data ?? undefined) ?? [];\n replaceRows(append ? [...rowsRef.current, ...pageRows] : pageRows);\n setExhausted(pageRows.length < pageSize);\n } catch (queryError) {\n setError(toError(queryError, errorMessage));\n } finally {\n if (append) setLoadingMore(false);\n else setLoading(false);\n }\n },\n [client, document, variables, pageSize, errorMessage, extractRowsRef, replaceRows]\n );\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n // The same empty list every time: a disabled query must not change state, or a\n // caller whose client identity changes per render would refetch forever.\n replaceRows(NO_ROWS);\n setExhausted(true);\n setError(undefined);\n return;\n }\n await fetchPage(0, false);\n }, [enabled, fetchPage, replaceRows]);\n\n const loadMore = useCallback(async () => {\n if (!enabled || exhausted) return;\n await fetchPage(rowsRef.current.length, true);\n }, [enabled, exhausted, fetchPage]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, loadingMore, hasMore: !exhausted, error, refetch, loadMore };\n}\n\nexport interface WorkspaceMutationOptions<TData, TInput, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Maps the caller's input onto GraphQL variables. */\n variables: (input: TInput) => Record<string, unknown>;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult | undefined;\n /** Thrown (and stored) when the payload is missing or the request fails. */\n errorMessage: string;\n}\n\n/**\n * Writes to the workspace gateway. Returns the `[mutate, state]` tuple used by\n * the reference hooks. `mutate` REJECTS on failure so callers cannot mistake a\n * failed write for a successful one.\n */\nexport function useWorkspaceMutation<TData, TInput, TResult>(\n options: WorkspaceMutationOptions<TData, TInput, TResult>\n): readonly [(input: TInput) => Promise<TResult>, MutationState<TResult>] {\n const { document, errorMessage } = options;\n const client = useWorkspaceClient();\n const variablesRef = useLatest(options.variables);\n const selectRef = useLatest(options.select);\n\n const [state, setState] = useState<MutationState<TResult>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const mutate = useCallback(\n async (input: TInput): Promise<TResult> => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<TData>({\n mutation: document,\n variables: variablesRef.current(input),\n });\n // Apollo v4 does not reject on GraphQL errors by default: the mutation\n // RESOLVES with `data` undefined and the failure on `result.error`\n // (CombinedGraphQLErrors / networkError). Surface it like a rejection\n // so callers see the server's field-level message, not the fallback.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n const selected = selectRef.current(result.data ?? undefined);\n if (selected === undefined) {\n throw new Error(errorMessage);\n }\n setState({ data: selected, loading: false, error: undefined });\n return selected;\n } catch (mutationError) {\n const failure = toError(mutationError, errorMessage);\n setState({ data: undefined, loading: false, error: failure });\n throw failure;\n }\n },\n [client, document, errorMessage, selectRef, variablesRef]\n );\n\n return [mutate, state] as const;\n}\n"],"mappings":";;;;;AAsBA,SAAgBA,IAAsC;CACpD,OAAOC,EAAiB,WAAW;AACrC;AAGA,SAAgBC,IAAqC;CACnD,OAAOC,EAAU,CAAC,CAAC;AACrB;AA2CA,SAASC,EAAQ,GAAgB,GAAgC;CAC/D,IAAMC,IAAUC,EAA6BC,CAAK;CAOlD,OANIF,IAGS,MAAMA,GAAS,EAAE,SAAM,CAAC,IAEjCE,aAAiB,QAAcA,IACxB,MAAMC,GAAiB,EAAE,SAAM,CAAC;AAC7C;AAGA,SAASC,EAAa,GAAmC;CACvD,IAAMC,IAAMC,EAAOC,CAAK;CAIxB,OAHAC,QAAsB;EACpB,EAAI,UAAUD;CAChB,GAAG,CAACA,CAAK,CAAC,GACHF;AACT;AAsBA,SAAgBI,EACd,GACsB;CACtB,IAAM,EAAE,aAAU,cAAW,YAAS,oBAAiBC,GACjDC,IAAShB,EAAmB,GAC5BiB,IAAYR,EAA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;EAAcf;EAAWqC;CAAY,CAGlD,GAAQC,CAAK;AACvB"}
1
+ {"version":3,"file":"workspaceGateway.js","names":["useWorkspaceClient","useGatewayClient","useWorkspaceId","useBotlit","toError","message","extractGraphqlFailureMessage","cause","fallbackMessage","useLatest","ref","useRef","value","useLayoutEffect","useWorkspaceQuery","options","client","selectRef","fallbackRef","data","setData","useState","loading","setLoading","error","setError","refetch","useCallback","enabled","result","document","operationError","errorMessage","queryError","variables","useEffect","NO_ROWS","useWorkspacePaginatedQuery","extractRowsRef","rows","setRows","rowsRef","loadingMore","setLoadingMore","exhausted","setExhausted","generationRef","replaceRows","next","fetchPage","generation","append","isCurrent","pageSize","pageRows","loadMore","useWorkspaceAllPagesQuery","hasMore","useWorkspaceMutation","variablesRef","state","setState","input","selected","mutationError","failure"],"sources":["../../../../src/botlit/hooks/internal/workspaceGateway.ts"],"sourcesContent":["/**\n * Workspace gateway hook primitives\n * @module botlit/hooks/internal\n *\n * Every BotManor hook talks to the workspace public gateway through the Apollo\n * client the shell installs (`useGatewayClient('workspace')`) — never through a\n * client of its own. These primitives capture the exact shape used by the\n * reference hooks (`useAgents`, `useBots`): `network-only` reads, an explicit\n * `Error` in state rather than a thrown promise, and a `refetch` the caller can\n * run after a mutation.\n */\n\nimport type { ApolloClient, DocumentNode } from '@apollo/client';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../../providers/BotlitProvider';\nimport { extractGraphqlFailureMessage } from '../../utils/errors';\n\nexport type WorkspaceClient = ApolloClient;\n\n/** Apollo client for the workspace gateway, provided by the host shell. */\nexport function useWorkspaceClient(): WorkspaceClient {\n return useGatewayClient('workspace');\n}\n\n/** Current workspace id from the BotManor context (undefined until the shell resolves it). */\nexport function useWorkspaceId(): string | undefined {\n return useBotlit().workspaceId;\n}\n\nexport interface QueryResult<T> {\n data: T;\n loading: boolean;\n /** Set only when the request FAILED. An empty `data` with no `error` means \"no records yet\". */\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\nexport interface PaginatedQueryResult<T> extends QueryResult<T> {\n /** True while the next page is being appended. */\n loadingMore: boolean;\n /**\n * True when the most recent page came back full, i.e. another page may\n * exist. False before the first page resolves and once a short page\n * (or an empty one) marks the end of the list.\n */\n hasMore: boolean;\n /**\n * Fetches the next page (current row count as offset) and appends it.\n * No-op while a fetch is in flight or when `hasMore` is false.\n */\n loadMore: () => Promise<void>;\n}\n\nexport interface MutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\n/**\n * Normalises any mutation failure to an Error with the server's\n * user-actionable message where one exists.\n *\n * Apollo Client v4 does not reject with a plain Error: failures arrive as\n * `{ networkError }` / `{ graphQLErrors }` objects, and the batched fetch\n * layer attaches the structured GraphQL errors as `.errors` on the\n * networkError. `extractGraphqlFailureMessage` unwraps all of those; only\n * when nothing user-actionable is present do we fall back to the hook's\n * generic `errorMessage`.\n */\nfunction toError(cause: unknown, fallbackMessage: string): Error {\n const message = extractGraphqlFailureMessage(cause);\n if (message) {\n // Preserve the original rejection on the chain so error monitoring can\n // still reach the structured GraphQL errors (extensions.code, requestId…).\n return new Error(message, { cause });\n }\n if (cause instanceof Error) return cause;\n return new Error(fallbackMessage, { cause });\n}\n\n/** Keeps a mutable ref pointing at the latest value without re-running effects. */\nfunction useLatest<T>(value: T): { readonly current: T } {\n const ref = useRef(value);\n useLayoutEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n\nexport interface WorkspaceQueryOptions<TData, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Must be referentially stable — memoize at the call site. */\n variables: Record<string, unknown> | undefined;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id / no entity id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Reads from the workspace gateway and keeps `{ data, loading, error, refetch }`\n * in sync. `error` is reserved for real failures so callers can tell an empty\n * collection apart from a failed request.\n */\nexport function useWorkspaceQuery<TData, TResult>(\n options: WorkspaceQueryOptions<TData, TResult>\n): QueryResult<TResult> {\n const { document, variables, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const fallbackRef = useLatest(options.fallback);\n\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n setData(fallbackRef.current);\n setError(undefined);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables,\n fetchPolicy: 'network-only',\n });\n // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL\n // errors — same handling as useWorkspaceMutation.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n setData(selectRef.current(result.data ?? undefined));\n } catch (queryError) {\n setData(fallbackRef.current);\n setError(toError(queryError, errorMessage));\n } finally {\n setLoading(false);\n }\n // fallbackRef/selectRef are stable refs by construction\n }, [client, document, variables, enabled, errorMessage, fallbackRef, selectRef]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\n/** Shared empty page, so a disabled paginated query keeps one stable value. */\nconst NO_ROWS: never[] = [];\n\nexport interface WorkspacePaginatedQueryOptions<TData, TRow, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /**\n * Base variables (filters, ids, …) WITHOUT `pagination` — the hook adds\n * `{ limit: pageSize, offset }` per fetch. Must be referentially stable;\n * a new identity resets the accumulation back to page one.\n */\n variables: Record<string, unknown> | undefined;\n /** Page size for each fetch. */\n pageSize: number;\n /** Extracts the raw row list from a page payload; missing data yields []. */\n extractRows: (data: TData | undefined) => TRow[] | undefined;\n /** Projects the ACCUMULATED raw rows onto the record shape the UI consumes. */\n select: (rows: TRow[]) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Offset-paginated variant of `useWorkspaceQuery` for unbounded lists.\n *\n * `refetch()` restarts at offset 0 and REPLACES the accumulated rows;\n * `loadMore()` fetches the next page and appends it. A page that returns\n * fewer rows than `pageSize` marks the list exhausted (`hasMore` false).\n * `select` runs over the accumulated raw rows, so client-side narrowing\n * (e.g. executions search) sees every loaded page, not just the last one.\n */\nexport function useWorkspacePaginatedQuery<TData, TRow, TResult>(\n options: WorkspacePaginatedQueryOptions<TData, TRow, TResult>\n): PaginatedQueryResult<TResult> {\n const { document, variables, pageSize, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const extractRowsRef = useLatest(options.extractRows);\n\n const [rows, setRows] = useState<TRow[]>([]);\n const rowsRef = useRef<TRow[]>([]);\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [loadingMore, setLoadingMore] = useState(false);\n const [exhausted, setExhausted] = useState(true);\n const [error, setError] = useState<Error | undefined>();\n // Bumped by every page-one read: a page from a superseded read (e.g. a\n // workspace switch mid-paging) must not touch the newer read's state.\n const generationRef = useRef(0);\n\n const replaceRows = useCallback(\n (next: TRow[]) => {\n rowsRef.current = next;\n setRows(next);\n setData(selectRef.current(next));\n },\n [selectRef]\n );\n\n const fetchPage = useCallback(\n async (offset: number, append: boolean) => {\n const generation = append ? generationRef.current : ++generationRef.current;\n const isCurrent = () => generation === generationRef.current;\n if (append) setLoadingMore(true);\n else {\n setLoading(true);\n // A new page-one read supersedes any in-flight append; that append\n // no longer owns `loadingMore` and will not clear it.\n setLoadingMore(false);\n }\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables: { ...variables, pagination: { limit: pageSize, offset } },\n fetchPolicy: 'network-only',\n });\n if (!isCurrent()) return;\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n const pageRows = extractRowsRef.current(result.data ?? undefined) ?? [];\n replaceRows(append ? [...rowsRef.current, ...pageRows] : pageRows);\n setExhausted(pageRows.length < pageSize);\n } catch (queryError) {\n if (isCurrent()) setError(toError(queryError, errorMessage));\n } finally {\n // Only the current read owns the flags: a superseded append must not\n // clear a newer read's `loadingMore` (that would start a duplicate\n // append at the same offset).\n if (isCurrent()) {\n if (append) setLoadingMore(false);\n else setLoading(false);\n }\n }\n },\n [client, document, variables, pageSize, errorMessage, extractRowsRef, replaceRows]\n );\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n // The same empty list every time: a disabled query must not change state, or a\n // caller whose client identity changes per render would refetch forever.\n replaceRows(NO_ROWS);\n setExhausted(true);\n setError(undefined);\n return;\n }\n await fetchPage(0, false);\n }, [enabled, fetchPage, replaceRows]);\n\n const loadMore = useCallback(async () => {\n if (!enabled || exhausted) return;\n await fetchPage(rowsRef.current.length, true);\n }, [enabled, exhausted, fetchPage]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, loadingMore, hasMore: !exhausted, error, refetch, loadMore };\n}\n\n/**\n * Every page of an offset-paginated list (BOFF-15360), for callers that must\n * see the whole list at once (pickers, \"already configured\" checks).\n * `loading` holds until the last page has arrived; a failed page stops paging\n * and sets `error`. `refetch` restarts from page one.\n */\nexport function useWorkspaceAllPagesQuery<TData, TRow, TResult>(\n options: WorkspacePaginatedQueryOptions<TData, TRow, TResult>\n): QueryResult<TResult> {\n const { data, loading, loadingMore, hasMore, error, refetch, loadMore } =\n useWorkspacePaginatedQuery(options);\n\n useEffect(() => {\n if (hasMore && !loading && !loadingMore && !error) void loadMore();\n }, [hasMore, loading, loadingMore, error, loadMore]);\n\n return { data, loading: loading || loadingMore || (hasMore && !error), error, refetch };\n}\n\nexport interface WorkspaceMutationOptions<TData, TInput, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Maps the caller's input onto GraphQL variables. */\n variables: (input: TInput) => Record<string, unknown>;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult | undefined;\n /** Thrown (and stored) when the payload is missing or the request fails. */\n errorMessage: string;\n}\n\n/**\n * Writes to the workspace gateway. Returns the `[mutate, state]` tuple used by\n * the reference hooks. `mutate` REJECTS on failure so callers cannot mistake a\n * failed write for a successful one.\n */\nexport function useWorkspaceMutation<TData, TInput, TResult>(\n options: WorkspaceMutationOptions<TData, TInput, TResult>\n): readonly [(input: TInput) => Promise<TResult>, MutationState<TResult>] {\n const { document, errorMessage } = options;\n const client = useWorkspaceClient();\n const variablesRef = useLatest(options.variables);\n const selectRef = useLatest(options.select);\n\n const [state, setState] = useState<MutationState<TResult>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const mutate = useCallback(\n async (input: TInput): Promise<TResult> => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<TData>({\n mutation: document,\n variables: variablesRef.current(input),\n });\n // Apollo v4 does not reject on GraphQL errors by default: the mutation\n // RESOLVES with `data` undefined and the failure on `result.error`\n // (CombinedGraphQLErrors / networkError). Surface it like a rejection\n // so callers see the server's field-level message, not the fallback.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n const selected = selectRef.current(result.data ?? undefined);\n if (selected === undefined) {\n throw new Error(errorMessage);\n }\n setState({ data: selected, loading: false, error: undefined });\n return selected;\n } catch (mutationError) {\n const failure = toError(mutationError, errorMessage);\n setState({ data: undefined, loading: false, error: failure });\n throw failure;\n }\n },\n [client, document, errorMessage, selectRef, variablesRef]\n );\n\n return [mutate, state] as const;\n}\n"],"mappings":";;;;;AAsBA,SAAgBA,IAAsC;CACpD,OAAOC,EAAiB,WAAW;AACr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nC;EAASoB;EAAalB;EAAO+B;CAAQ,CAAC,GAE5C;EAAE;EAAM,SAASjC,KAAWoB,KAAgBe,KAAW,CAACjC;EAAQ;EAAO;CAAQ;AACxF;AAkBA,SAAgBkC,EACd,GACwE;CACxE,IAAM,EAAE,aAAU,oBAAiB3C,GAC7BC,IAAShB,EAAmB,GAC5B2D,IAAelD,EAAUM,EAAQ,SAAS,GAC1CE,IAAYR,EAAUM,EAAQ,MAAM,GAEpC,CAAC6C,GAAOC,KAAYxC,EAAiC;EACzD,MAAM,KAAA;EACN,SAAS;EACT,OAAO,KAAA;CACT,CAAC;CAiCD,OAAO,CA/BQM,EACb,OAAO,MAAoC;EACzC,EAAS;GAAE,MAAM,KAAA;GAAW,SAAS;GAAM,OAAO,KAAA;EAAU,CAAC;EAC7D,IAAI;GACF,IAAME,IAAS,MAAMb,EAAO,OAAc;IACxC,UAAUc;IACV,WAAW6B,EAAa,QAAQG,CAAK;GACvC,CAAC,GAKK/B,IAAkBF,EAA+B;GACvD,IAAIE,KAAkB,MACpB,MAAM3B,EAAQ2B,GAAgBC,CAAY;GAE5C,IAAM+B,IAAW9C,EAAU,QAAQY,EAAO,QAAQ,KAAA,CAAS;GAC3D,IAAIkC,MAAa,KAAA,GACf,MAAU,MAAM/B,CAAY;GAG9B,OADA6B,EAAS;IAAE,MAAME;IAAU,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACtDA;EACT,SAASC,GAAe;GACtB,IAAMC,IAAU7D,EAAQ4D,GAAehC,CAAY;GAEnD,MADA6B,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO,OAAOI;GAAQ,CAAC,GACtDA;EACR;CACF,GACA;EAACjD;EAAQc;EAAUE;EAAcf;EAAW0C;CAAY,CAGlD,GAAQC,CAAK;AACvB"}
@@ -11,7 +11,8 @@
11
11
  *
12
12
  * These hooks let the connector form create that channel with its credentials
13
13
  * and the detail page show its inbound URL, all through the shell's global
14
- * gateway client. The documents are written inline, like `GetChannels` in
14
+ * gateway client, scoped to the active workspace's organization (see
15
+ * `internal/globalWorkspaceScope`). The documents are written inline, like `GetChannels` in
15
16
  * `useUserPlatformConnection`: `inboundWebhookUrl` / `inboundWorkspaceId` are
16
17
  * newer than the checked-in `graphql/global.graphql`, which cannot be
17
18
  * re-pulled while gateway introspection is disabled.
@@ -1,8 +1,8 @@
1
1
  import { useBotlit as e } from "../providers/BotlitProvider.js";
2
2
  import { extractGraphqlFailureMessage as t } from "../utils/errors.js";
3
- import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
4
- import { gql as o } from "@apollo/client";
5
- import { useGatewayClient as s } from "@burdenoff/fe-libs/shared/graphql";
3
+ import { useWorkspaceScopedGlobalClient as n } from "./internal/globalWorkspaceScope.js";
4
+ import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
5
+ import { gql as s } from "@apollo/client";
6
6
  // src/botlit/hooks/useChannelSetup.ts
7
7
  var c = {
8
8
  SLACK: {
@@ -76,7 +76,7 @@ function f(e, t) {
76
76
  function p() {
77
77
  return e().organizationId || null;
78
78
  }
79
- var m = o`
79
+ var m = s`
80
80
  query BotmanorInboundChannel($id: ID!) {
81
81
  getChannel(id: $id) {
82
82
  id
@@ -88,19 +88,19 @@ var m = o`
88
88
  inboundWebhookUrl
89
89
  }
90
90
  }
91
- `, h = o`
91
+ `, h = s`
92
92
  mutation BotmanorCreateSetupChannel($input: CreateChannelInput!) {
93
93
  createChannel(input: $input) {
94
94
  id
95
95
  }
96
96
  }
97
- `, g = o`
97
+ `, g = s`
98
98
  mutation BotmanorCreateSetupConnection($input: CreateConnectionInput!) {
99
99
  createConnection(input: $input) {
100
100
  id
101
101
  }
102
102
  }
103
- `, _ = o`
103
+ `, _ = s`
104
104
  mutation BotmanorDeleteSetupChannel($id: ID!) {
105
105
  deleteChannel(id: $id)
106
106
  }
@@ -113,87 +113,96 @@ function y(e, t) {
113
113
  let n = e.error;
114
114
  if (n != null) throw v(n, t);
115
115
  }
116
- function b() {
117
- return s("global");
118
- }
119
- function x(e) {
120
- let t = b(), [o, s] = a(null), [c, l] = a(!1), [u, d] = a(void 0), f = i(0), p = n(async () => {
121
- let n = ++f.current, r = () => n === f.current;
122
- if (s(null), d(void 0), e) {
123
- l(!0);
116
+ function b(e) {
117
+ let { client: t, context: s } = n(), [c, l] = o(null), [u, d] = o(!1), [f, p] = o(void 0), h = a(0), g = r(async () => {
118
+ let n = ++h.current, r = () => n === h.current;
119
+ if (l(null), p(void 0), e) {
120
+ d(!0);
124
121
  try {
125
122
  let n = await t.query({
126
123
  query: m,
127
124
  variables: { id: e },
128
- fetchPolicy: "network-only"
125
+ fetchPolicy: "network-only",
126
+ context: s
129
127
  });
130
- y(n, "Failed to load the channel"), r() && s(n.data?.getChannel ?? null);
128
+ y(n, "Failed to load the channel"), r() && l(n.data?.getChannel ?? null);
131
129
  } catch (e) {
132
- r() && d(v(e, "Failed to load the channel"));
130
+ r() && p(v(e, "Failed to load the channel"));
133
131
  } finally {
134
- r() && l(!1);
132
+ r() && d(!1);
135
133
  }
136
134
  }
137
- }, [e, t]);
138
- return r(() => {
139
- p();
140
- }, [p]), {
141
- data: o,
142
- loading: c,
143
- error: u,
144
- refetch: p
135
+ }, [
136
+ e,
137
+ t,
138
+ s
139
+ ]);
140
+ return i(() => {
141
+ g();
142
+ }, [g]), {
143
+ data: c,
144
+ loading: u,
145
+ error: f,
146
+ refetch: g
145
147
  };
146
148
  }
147
- function S() {
148
- let e = b(), [t, r] = a(!1), i = n(async (t) => {
149
+ function x() {
150
+ let { client: e, context: t } = n(), [i, a] = o(!1), s = r(async (n) => {
149
151
  y(await e.mutate({
150
152
  mutation: _,
151
- variables: { id: t }
153
+ variables: { id: n },
154
+ context: t
152
155
  }), "Failed to delete the channel");
153
- }, [e]);
156
+ }, [e, t]);
154
157
  return {
155
- provision: n(async ({ name: t, description: n, organizationId: a, definition: o, credentials: s }) => {
156
- r(!0);
158
+ provision: r(async ({ name: n, description: r, organizationId: i, definition: o, credentials: c }) => {
159
+ a(!0);
157
160
  try {
158
- let r;
161
+ let a;
159
162
  try {
160
- let i = await e.mutate({
163
+ let s = await e.mutate({
161
164
  mutation: h,
162
165
  variables: { input: {
163
- name: t,
164
- description: n || void 0,
166
+ name: n,
167
+ description: r || void 0,
165
168
  platform: o.platform,
166
169
  channelType: "COMMUNICATION",
167
- organizationId: a
168
- } }
170
+ organizationId: i
171
+ } },
172
+ context: t
169
173
  });
170
- y(i, "Failed to create the channel"), r = i.data?.createChannel?.id;
174
+ y(s, "Failed to create the channel"), a = s.data?.createChannel?.id;
171
175
  } catch (e) {
172
176
  throw v(e, "Failed to create the channel");
173
177
  }
174
- if (!r) throw Error("Failed to create the channel");
175
- let c = Object.fromEntries(o.fields.map((e) => [e.key, s[e.key]?.trim() ?? ""]));
178
+ if (!a) throw Error("Failed to create the channel");
179
+ let l = Object.fromEntries(o.fields.map((e) => [e.key, c[e.key]?.trim() ?? ""]));
176
180
  try {
177
181
  y(await e.mutate({
178
182
  mutation: g,
179
183
  variables: { input: {
180
- channelId: r,
184
+ channelId: a,
181
185
  authType: o.authType,
182
- credentials: c
183
- } }
186
+ credentials: l
187
+ } },
188
+ context: t
184
189
  }), "Failed to save the channel credentials");
185
190
  } catch (e) {
186
- throw await i(r).catch(() => void 0), v(e, "Failed to save the channel credentials");
191
+ throw await s(a).catch(() => void 0), v(e, "Failed to save the channel credentials");
187
192
  }
188
- return r;
193
+ return a;
189
194
  } finally {
190
- r(!1);
195
+ a(!1);
191
196
  }
192
- }, [e, i]),
193
- discard: i,
194
- loading: t
197
+ }, [
198
+ e,
199
+ t,
200
+ s
201
+ ]),
202
+ discard: s,
203
+ loading: i
195
204
  };
196
205
  }
197
- export { c as PLATFORM_CREDENTIALS, u as connectorPlatform, d as generateSigningSecret, p as useActiveOrganizationId, x as useInboundChannel, S as useProvisionChannel, f as validateCredentials };
206
+ export { c as PLATFORM_CREDENTIALS, u as connectorPlatform, d as generateSigningSecret, p as useActiveOrganizationId, b as useInboundChannel, x as useProvisionChannel, f as validateCredentials };
198
207
 
199
208
  //# sourceMappingURL=useChannelSetup.js.map