@burdenoff/microfe-botmanor 2026.1118.7 → 2026.1119.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botlit/components/A2ATrustBadge.d.ts +9 -0
- package/dist/botlit/components/A2ATrustBadge.js +55 -0
- package/dist/botlit/components/A2ATrustBadge.js.map +1 -0
- package/dist/botlit/components/ChannelSelectorSheet.d.ts +9 -2
- package/dist/botlit/components/ChannelSelectorSheet.js.map +1 -1
- package/dist/botlit/hooks/index.d.ts +1 -1
- package/dist/botlit/hooks/index.js +14 -14
- package/dist/botlit/hooks/internal/globalWorkspaceScope.d.ts +15 -0
- package/dist/botlit/hooks/internal/globalWorkspaceScope.js +21 -0
- package/dist/botlit/hooks/internal/globalWorkspaceScope.js.map +1 -0
- package/dist/botlit/hooks/internal/workspaceGateway.d.ts +7 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +42 -22
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
- package/dist/botlit/hooks/useA2A.d.ts +107 -9
- package/dist/botlit/hooks/useA2A.js +215 -80
- package/dist/botlit/hooks/useA2A.js.map +1 -1
- package/dist/botlit/hooks/useChannelSetup.d.ts +2 -1
- package/dist/botlit/hooks/useChannelSetup.js +61 -52
- package/dist/botlit/hooks/useChannelSetup.js.map +1 -1
- package/dist/botlit/hooks/useChannels.d.ts +9 -0
- package/dist/botlit/hooks/useChannels.js +83 -73
- package/dist/botlit/hooks/useChannels.js.map +1 -1
- package/dist/botlit/hooks/useUserPlatformConnection.js +98 -78
- package/dist/botlit/hooks/useUserPlatformConnection.js.map +1 -1
- package/dist/botlit/pages/A2AAgentDetailPage.js +715 -503
- package/dist/botlit/pages/A2AAgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/A2ARegistryPage.js +278 -179
- package/dist/botlit/pages/A2ARegistryPage.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.js +457 -242
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/ExecutionsPage.js +1 -1
- package/dist/botlit/pages/InstalledPackagesPage.js +154 -154
- package/dist/botlit/pages/InstalledPackagesPage.js.map +1 -1
- package/dist/botlit/pages/PromptStudioPage.js +172 -172
- package/dist/botlit/pages/PromptStudioPage.js.map +1 -1
- package/dist/botlit/pages/StorePage.js +8 -8
- package/dist/botlit/pages/StorePage.js.map +1 -1
- package/dist/botlit/permissions/index.js +3 -3
- package/dist/botlit/permissions/useBotmanorPermissions.js +5 -2
- package/dist/botlit/permissions/useBotmanorPermissions.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { TrustLevel } from '../types';
|
|
3
|
+
export declare const A2A_TRUST_LEVELS: readonly TrustLevel[];
|
|
4
|
+
export declare function toTrustLevel(value: string | null | undefined): TrustLevel;
|
|
5
|
+
/** Translated name of a trust level. */
|
|
6
|
+
export declare function useTrustLevelLabel(): (level: TrustLevel) => string;
|
|
7
|
+
export declare const A2ATrustBadge: FC<{
|
|
8
|
+
level: string;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
|
+
import { Badge as t } from "./Badge.js";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import { AlertCircle as i, CheckCircle as a, Shield as o } from "lucide-react";
|
|
5
|
+
// src/botlit/components/A2ATrustBadge.tsx
|
|
6
|
+
var s = [
|
|
7
|
+
"UNVERIFIED",
|
|
8
|
+
"VERIFIED_PUBLISHER",
|
|
9
|
+
"INTERNAL"
|
|
10
|
+
];
|
|
11
|
+
function c(e) {
|
|
12
|
+
return s.includes(e) ? e : "UNVERIFIED";
|
|
13
|
+
}
|
|
14
|
+
function l() {
|
|
15
|
+
let t = e();
|
|
16
|
+
return (e) => {
|
|
17
|
+
switch (e) {
|
|
18
|
+
case "INTERNAL": return t("botlit.a2aRegistry.trustBadge.internal", "Internal");
|
|
19
|
+
case "VERIFIED_PUBLISHER": return t("botlit.a2aRegistry.trustBadge.verified", "Verified publisher");
|
|
20
|
+
default: return t("botlit.a2aRegistry.trustBadge.unverified", "Unverified");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
var u = ({ level: e }) => {
|
|
25
|
+
let s = l(), u = c(e);
|
|
26
|
+
switch (u) {
|
|
27
|
+
case "INTERNAL": return /* @__PURE__ */ r(t, {
|
|
28
|
+
variant: "success",
|
|
29
|
+
className: "flex items-center gap-1",
|
|
30
|
+
children: [/* @__PURE__ */ n(o, {
|
|
31
|
+
size: 12,
|
|
32
|
+
"aria-hidden": "true"
|
|
33
|
+
}), s(u)]
|
|
34
|
+
});
|
|
35
|
+
case "VERIFIED_PUBLISHER": return /* @__PURE__ */ r(t, {
|
|
36
|
+
variant: "default",
|
|
37
|
+
className: "flex items-center gap-1",
|
|
38
|
+
children: [/* @__PURE__ */ n(a, {
|
|
39
|
+
size: 12,
|
|
40
|
+
"aria-hidden": "true"
|
|
41
|
+
}), s(u)]
|
|
42
|
+
});
|
|
43
|
+
default: return /* @__PURE__ */ r(t, {
|
|
44
|
+
variant: "outline",
|
|
45
|
+
className: "flex items-center gap-1",
|
|
46
|
+
children: [/* @__PURE__ */ n(i, {
|
|
47
|
+
size: 12,
|
|
48
|
+
"aria-hidden": "true"
|
|
49
|
+
}), s(u)]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export { u as A2ATrustBadge, s as A2A_TRUST_LEVELS, c as toTrustLevel, l as useTrustLevelLabel };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=A2ATrustBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A2ATrustBadge.js","names":["A2A_TRUST_LEVELS","toTrustLevel","value","useTrustLevelLabel","useTr","level","A2ATrustBadge","label","trust","Badge","Shield","CheckCircle","AlertCircle"],"sources":["../../../src/botlit/components/A2ATrustBadge.tsx"],"sourcesContent":["/**\n * A2A trust level badge and labels (BOFF-12507)\n * @module botlit/components\n *\n * One translated label per trust level, shared by the registry list and the\n * entry page, so the same level never reads differently on two pages.\n */\n\nimport type { FC } from 'react';\nimport { AlertCircle, CheckCircle, Shield } from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\nimport type { TrustLevel } from '../types';\nimport { Badge } from './Badge';\n\nexport const A2A_TRUST_LEVELS: readonly TrustLevel[] = [\n 'UNVERIFIED',\n 'VERIFIED_PUBLISHER',\n 'INTERNAL',\n];\n\nexport function toTrustLevel(value: string | null | undefined): TrustLevel {\n return A2A_TRUST_LEVELS.includes(value as TrustLevel) ? (value as TrustLevel) : 'UNVERIFIED';\n}\n\n/** Translated name of a trust level. */\nexport function useTrustLevelLabel(): (level: TrustLevel) => string {\n const t = useTr();\n return (level) => {\n switch (level) {\n case 'INTERNAL':\n return t('botlit.a2aRegistry.trustBadge.internal', 'Internal');\n case 'VERIFIED_PUBLISHER':\n return t('botlit.a2aRegistry.trustBadge.verified', 'Verified publisher');\n default:\n return t('botlit.a2aRegistry.trustBadge.unverified', 'Unverified');\n }\n };\n}\n\nexport const A2ATrustBadge: FC<{ level: string }> = ({ level }) => {\n const label = useTrustLevelLabel();\n const trust = toTrustLevel(level);\n switch (trust) {\n case 'INTERNAL':\n return (\n <Badge variant=\"success\" className=\"flex items-center gap-1\">\n <Shield size={12} aria-hidden=\"true\" />\n {label(trust)}\n </Badge>\n );\n case 'VERIFIED_PUBLISHER':\n return (\n <Badge variant=\"default\" className=\"flex items-center gap-1\">\n <CheckCircle size={12} aria-hidden=\"true\" />\n {label(trust)}\n </Badge>\n );\n default:\n return (\n <Badge variant=\"outline\" className=\"flex items-center gap-1\">\n <AlertCircle size={12} aria-hidden=\"true\" />\n {label(trust)}\n </Badge>\n );\n }\n};\n"],"mappings":";;;;;AAcA,IAAaA,IAA0C;CACrD;CACA;CACA;AACF;AAEA,SAAgBC,EAAa,GAA8C;CACzE,OAAOD,EAAiB,SAASE,CAAmB,IAAKA,IAAuB;AAClF;AAGA,SAAgBC,IAAoD;CAClE,IAAM,IAAIC,EAAM;CAChB,QAAQ,MAAU;EAChB,QAAQC,GAAR;GACE,KAAK,YACH,OAAO,EAAE,0CAA0C,UAAU;GAC/D,KAAK,sBACH,OAAO,EAAE,0CAA0C,oBAAoB;GACzE,SACE,OAAO,EAAE,4CAA4C,YAAY;EACrE;CACF;AACF;AAEA,IAAaC,KAAwC,EAAE,eAAY;CACjE,IAAMC,IAAQJ,EAAmB,GAC3BK,IAAQP,EAAaI,CAAK;CAChC,QAAQG,GAAR;EACE,KAAK,YACH,OACE,kBAACC,GAAD;GAAO,SAAQ;GAAU,WAAU;GAAnC,UAAA,CACE,kBAACC,GAAD;IAAQ,MAAM;IAAI,eAAY;GAAQ,CAAA,GACrCH,EAAMC,CAAK,CACP;;EAEX,KAAK,sBACH,OACE,kBAACC,GAAD;GAAO,SAAQ;GAAU,WAAU;GAAnC,UAAA,CACE,kBAACE,GAAD;IAAa,MAAM;IAAI,eAAY;GAAQ,CAAA,GAC1CJ,EAAMC,CAAK,CACP;;EAEX,SACE,OACE,kBAACC,GAAD;GAAO,SAAQ;GAAU,WAAU;GAAnC,UAAA,CACE,kBAACG,GAAD;IAAa,MAAM;IAAI,eAAY;GAAQ,CAAA,GAC1CL,EAAMC,CAAK,CACP;;CAEb;AACF"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
-
|
|
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:
|
|
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';\
|
|
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,WAAU;CACV,MAAK;CACL,cAAW;CACX,mBAAgB;CAJlB,UAAA;EAOE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;IAAI,IAAG;IAAyB,WAAU;IAAwB,UAAA;GAE9D,CAAA,GACJ,kBAAC,KAAD;IAAG,WAAU;IAAqC,UAAA;GAE/C,CAAA,CACA,EAAA,CAAA,GACL,kBAACC,GAAD;IACE,SAAQ;IACR,MAAK;IACL,SAASD;IACT,WAAU;IACV,cAAW;IAEX,UAAA,kBAACE,GAAD,EAAG,MAAM,GAAK,CAAA;GACR,CAAA,CACL;;EAGL,kBAAC,OAAD;GAAK,WAAU;GACZ,UAAAC,EAAkB,WAAW,IAC5B,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CAC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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,
|
|
8
|
-
import { PLATFORM_CREDENTIALS as
|
|
9
|
-
import { useCreatePolicy as
|
|
10
|
-
import { useApplyRetention as
|
|
11
|
-
import { useCreateSkill as
|
|
12
|
-
import { promptTemplateVariables as
|
|
13
|
-
import { useAgentBindings as
|
|
14
|
-
import { summariseExecutions as
|
|
15
|
-
import { useBucket as
|
|
16
|
-
import { storePackageDescription as
|
|
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
|
|
19
|
-
import { useConfigureSupervisor as
|
|
20
|
-
import { useAcceptHandoff as
|
|
21
|
-
export {
|
|
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]),
|
|
64
|
-
n ?
|
|
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
|
-
})
|
|
77
|
-
if (a
|
|
78
|
-
let o =
|
|
79
|
-
|
|
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
|
-
|
|
93
|
-
]),
|
|
94
|
-
l ? await
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
]),
|
|
100
|
-
l && !E && await
|
|
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
|
-
|
|
107
|
+
M
|
|
105
108
|
]);
|
|
106
109
|
return r(() => {
|
|
107
|
-
|
|
108
|
-
}, [
|
|
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:
|
|
115
|
-
loadMore:
|
|
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,
|
|
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,EAAUM,EAAQ,MAAM,GACpCG,IAAcT,EAAUM,EAAQ,QAAQ,GAExC,CAACI,GAAMC,KAAWC,EAAkBN,EAAQ,QAAQ,GACpD,CAACO,GAASC,KAAcF,EAAS,EAAK,GACtC,CAACG,GAAOC,KAAYJ,EAA4B,GAEhDK,IAAUC,EAAY,YAAY;EACtC,IAAI,CAACC,GAEH,AADAR,EAAQF,EAAY,OAAO,GAC3BO,EAAS,KAAA,CAAS;OAIpB;GACA,AADAF,EAAW,EAAI,GACfE,EAAS,KAAA,CAAS;GAClB,IAAI;IACF,IAAMI,IAAS,MAAMb,EAAO,MAAa;KACvC,OAAOc;KACP;KACA,aAAa;IACf,CAAC,GAGKC,IAAkBF,EAA+B;IACvD,IAAIE,KAAkB,MACpB,MAAM3B,EAAQ2B,GAAgBC,CAAY;IAE5C,EAA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ACN,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,WAAWwB,EAAa,QAAQG,CAAK;GACvC,CAAC,GAKK1B,IAAkBF,EAA+B;GACvD,IAAIE,KAAkB,MACpB,MAAM3B,EAAQ2B,GAAgBC,CAAY;GAE5C,IAAM0B,IAAWzC,EAAU,QAAQY,EAAO,QAAQ,KAAA,CAAS;GAC3D,IAAI6B,MAAa,KAAA,GACf,MAAU,MAAM1B,CAAY;GAG9B,OADAwB,EAAS;IAAE,MAAME;IAAU,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACtDA;EACT,SAASC,GAAe;GACtB,IAAMC,IAAUxD,EAAQuD,GAAe3B,CAAY;GAEnD,MADAwB,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO,OAAOI;GAAQ,CAAC,GACtDA;EACR;CACF,GACA;EAAC5C;EAAQc;EAAUE;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;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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