@burdenoff/microfe-botmanor 2026.1118.6 → 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.
Files changed (43) hide show
  1. package/dist/botlit/components/AgentBindingsPanel.d.ts +4 -0
  2. package/dist/botlit/components/AgentBindingsPanel.js +305 -0
  3. package/dist/botlit/components/AgentBindingsPanel.js.map +1 -0
  4. package/dist/botlit/components/ChannelSelectorSheet.d.ts +9 -2
  5. package/dist/botlit/components/ChannelSelectorSheet.js.map +1 -1
  6. package/dist/botlit/hooks/index.d.ts +3 -1
  7. package/dist/botlit/hooks/index.js +14 -13
  8. package/dist/botlit/hooks/internal/globalWorkspaceScope.d.ts +15 -0
  9. package/dist/botlit/hooks/internal/globalWorkspaceScope.js +21 -0
  10. package/dist/botlit/hooks/internal/globalWorkspaceScope.js.map +1 -0
  11. package/dist/botlit/hooks/internal/workspaceGateway.d.ts +7 -0
  12. package/dist/botlit/hooks/internal/workspaceGateway.js +42 -22
  13. package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
  14. package/dist/botlit/hooks/useAgentBindings.d.ts +58 -0
  15. package/dist/botlit/hooks/useAgentBindings.js +87 -0
  16. package/dist/botlit/hooks/useAgentBindings.js.map +1 -0
  17. package/dist/botlit/hooks/useChannelSetup.d.ts +2 -1
  18. package/dist/botlit/hooks/useChannelSetup.js +61 -52
  19. package/dist/botlit/hooks/useChannelSetup.js.map +1 -1
  20. package/dist/botlit/hooks/useChannels.d.ts +9 -0
  21. package/dist/botlit/hooks/useChannels.js +83 -73
  22. package/dist/botlit/hooks/useChannels.js.map +1 -1
  23. package/dist/botlit/hooks/useUserPlatformConnection.js +98 -78
  24. package/dist/botlit/hooks/useUserPlatformConnection.js.map +1 -1
  25. package/dist/botlit/pages/AgentDetailPage.js +56 -55
  26. package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
  27. package/dist/botlit/pages/BotChannelsTab.js +457 -242
  28. package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
  29. package/dist/botlit/pages/PromptStudioPage.js +365 -175
  30. package/dist/botlit/pages/PromptStudioPage.js.map +1 -1
  31. package/dist/botlit/permissions/index.js +3 -3
  32. package/dist/botlit/permissions/useBotmanorPermissions.js +5 -2
  33. package/dist/botlit/permissions/useBotmanorPermissions.js.map +1 -1
  34. package/dist/botlit/utils/promptVariables.d.ts +6 -0
  35. package/dist/botlit/utils/promptVariables.js +20 -0
  36. package/dist/botlit/utils/promptVariables.js.map +1 -0
  37. package/dist/generated/wspace-operations.d.ts +314 -0
  38. package/dist/generated/wspace-operations.js +189 -101
  39. package/dist/generated/wspace-operations.js.map +1 -1
  40. package/dist/generated/wspace-types.d.ts +139 -0
  41. package/dist/generated/wspace-types.js +3 -1
  42. package/dist/generated/wspace-types.js.map +1 -1
  43. package/package.json +1 -1
@@ -1,44 +1,48 @@
1
1
  import { LinkIntegrationConnectionDocument as e, MyUserPlatformConnectionDocument as t, RevokeUserPlatformConnectionDocument as n, UpdateUserPlatformConnectionNotificationsDocument as r } from "../../generated/global-operations.js";
2
2
  import { ChannelType as i } from "../../generated/global-types.js";
3
- import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
4
- import { gql as l } from "@apollo/client";
5
- import { useGatewayClient as u } from "@burdenoff/fe-libs/shared/graphql";
3
+ import { useWorkspaceScopedGlobalClient as a } from "./internal/globalWorkspaceScope.js";
4
+ import { useCallback as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
5
+ import { gql as d } from "@apollo/client";
6
6
  // src/botlit/hooks/useUserPlatformConnection.ts
7
- function d() {
8
- return u("global");
9
- }
10
7
  function f(e) {
11
- let n = d(), [r, i] = c(null), [s, l] = c(!1), [u, f] = c(null), p = a(async () => {
12
- if (!e) i(null), l(!1), f(null);
8
+ let { client: n, context: r } = a(), [i, c] = u(null), [d, f] = u(!1), [p, m] = u(null), h = l(0), g = o(async () => {
9
+ let i = ++h.current, a = () => i === h.current;
10
+ if (!e) c(null), f(!1), m(null);
13
11
  else {
14
- l(!0), f(null);
12
+ f(!0), m(null);
15
13
  try {
16
- let r = await n.query({
14
+ let i = await n.query({
17
15
  query: t,
18
16
  variables: { channelId: e },
19
- fetchPolicy: "network-only"
17
+ fetchPolicy: "network-only",
18
+ context: r
20
19
  });
21
- i(r.data?.myUserPlatformConnection ?? null);
20
+ if (!a()) return;
21
+ c(i.data?.myUserPlatformConnection ?? null);
22
22
  } catch (e) {
23
- f(e);
23
+ a() && m(e);
24
24
  } finally {
25
- l(!1);
25
+ a() && f(!1);
26
26
  }
27
27
  }
28
- }, [e, n]);
29
- return o(() => {
30
- p();
31
- }, [p]), {
32
- data: r,
33
- loading: s,
34
- error: u,
35
- refetch: p
28
+ }, [
29
+ e,
30
+ n,
31
+ r
32
+ ]);
33
+ return s(() => {
34
+ g();
35
+ }, [g]), {
36
+ data: i,
37
+ loading: d,
38
+ error: p,
39
+ refetch: g
36
40
  };
37
41
  }
38
42
  function p() {
39
- let [e] = c(!1), [t] = c(null);
43
+ let [e] = u(!1), [t] = u(null);
40
44
  return {
41
- initiate: a((e, t) => {
45
+ initiate: o((e, t) => {
42
46
  let n = new URL("/integrations/connections", window.location.origin);
43
47
  n.searchParams.set("provider", "slack-user"), n.searchParams.set("returnUrl", t), n.searchParams.set("channelId", e), window.location.href = n.toString();
44
48
  }, []),
@@ -47,72 +51,75 @@ function p() {
47
51
  };
48
52
  }
49
53
  function m() {
50
- let e = d(), [t, n] = c(!1), [i, o] = c(null);
54
+ let { client: e, context: t } = a(), [n, i] = u(!1), [s, c] = u(null);
51
55
  return {
52
- toggle: a(async (t, i) => {
53
- n(!0), o(null);
56
+ toggle: o(async (n, a) => {
57
+ i(!0), c(null);
54
58
  try {
55
59
  return (await e.mutate({
56
60
  mutation: r,
57
61
  variables: {
58
- id: t,
59
- notificationsEnabled: i
60
- }
62
+ id: n,
63
+ notificationsEnabled: a
64
+ },
65
+ context: t
61
66
  })).data?.updateUserPlatformConnectionNotifications ?? null;
62
67
  } catch (e) {
63
- return o(e), null;
68
+ return c(e), null;
64
69
  } finally {
65
- n(!1);
70
+ i(!1);
66
71
  }
67
- }, [e]),
68
- loading: t,
69
- error: i
72
+ }, [e, t]),
73
+ loading: n,
74
+ error: s
70
75
  };
71
76
  }
72
77
  function h() {
73
- let e = d(), [t, r] = c(!1), [i, o] = c(null);
78
+ let { client: e, context: t } = a(), [r, i] = u(!1), [s, c] = u(null);
74
79
  return {
75
- revoke: a(async (t) => {
76
- r(!0), o(null);
80
+ revoke: o(async (r) => {
81
+ i(!0), c(null);
77
82
  try {
78
83
  return (await e.mutate({
79
84
  mutation: n,
80
- variables: { id: t }
85
+ variables: { id: r },
86
+ context: t
81
87
  })).data?.revokeUserPlatformConnection?.dmAllowed === !1;
82
88
  } catch (e) {
83
- return o(e), !1;
89
+ return c(e), !1;
84
90
  } finally {
85
- r(!1);
91
+ i(!1);
86
92
  }
87
- }, [e]),
88
- loading: t,
89
- error: i
93
+ }, [e, t]),
94
+ loading: r,
95
+ error: s
90
96
  };
91
97
  }
92
98
  function g() {
93
- let t = d(), [n, r] = c(!1), [i, o] = c(null);
99
+ let { client: t, context: n } = a(), [r, i] = u(!1), [s, c] = u(null);
94
100
  return {
95
- link: a(async (n, i) => {
96
- r(!0), o(null);
101
+ link: o(async (r, a) => {
102
+ i(!0), c(null);
97
103
  try {
98
104
  return (await t.mutate({
99
105
  mutation: e,
100
106
  variables: {
101
- integrationConnectionId: n,
102
- channelId: i
103
- }
107
+ integrationConnectionId: r,
108
+ channelId: a
109
+ },
110
+ context: n
104
111
  })).data?.linkIntegrationConnection ?? null;
105
112
  } catch (e) {
106
- return o(e), null;
113
+ return c(e), null;
107
114
  } finally {
108
- r(!1);
115
+ i(!1);
109
116
  }
110
- }, [t]),
111
- loading: n,
112
- error: i
117
+ }, [t, n]),
118
+ loading: r,
119
+ error: s
113
120
  };
114
121
  }
115
- var _ = l`
122
+ var _ = d`
116
123
  query GetChannels($filter: ChannelFilterInput, $pagination: ChannelPaginationInput) {
117
124
  getChannels(filter: $filter, pagination: $pagination) {
118
125
  items {
@@ -137,35 +144,48 @@ var _ = l`
137
144
  limit: 50
138
145
  };
139
146
  function b(e, t) {
140
- let n = d(), [r, i] = c([]), [l, u] = c(!1), [f, p] = c(null), m = s(() => e ?? v, [e]), h = s(() => t ?? y, [t]), g = a(async () => {
141
- u(!0), p(null);
147
+ let { client: n, context: r } = a(), [i, d] = u([]), [f, p] = u(!1), [m, h] = u(null), g = l(0), b = c(() => e ?? v, [e]), x = c(() => t ?? y, [t]), S = o(async () => {
148
+ let e = ++g.current, t = () => e === g.current;
149
+ p(!0), h(null);
142
150
  try {
143
- let e = await n.query({
144
- query: _,
145
- variables: {
146
- filter: m,
147
- pagination: h
148
- },
149
- fetchPolicy: "network-only"
150
- });
151
- i(e.data?.getChannels?.items ?? []);
151
+ let e = [], i = x.limit ?? y.limit ?? 50;
152
+ for (let t = x.offset ?? 0;; t += i) {
153
+ let a = await n.query({
154
+ query: _,
155
+ variables: {
156
+ filter: b,
157
+ pagination: {
158
+ ...x,
159
+ offset: t,
160
+ limit: i
161
+ }
162
+ },
163
+ fetchPolicy: "network-only",
164
+ context: r
165
+ }), o = a.error;
166
+ if (o != null) throw o;
167
+ let s = a.data?.getChannels;
168
+ if (e.push(...s?.items ?? []), !s?.hasMore || (s.items ?? []).length === 0) break;
169
+ }
170
+ t() && d(e);
152
171
  } catch (e) {
153
- p(e);
172
+ t() && h(e);
154
173
  } finally {
155
- u(!1);
174
+ t() && p(!1);
156
175
  }
157
176
  }, [
158
177
  n,
159
- m,
160
- h
178
+ r,
179
+ b,
180
+ x
161
181
  ]);
162
- return o(() => {
163
- g();
164
- }, [g]), {
165
- data: r,
166
- loading: l,
167
- error: f,
168
- refetch: g
182
+ return s(() => {
183
+ S();
184
+ }, [S]), {
185
+ data: i,
186
+ loading: f,
187
+ error: m,
188
+ refetch: S
169
189
  };
170
190
  }
171
191
  export { b as useGlobalChannels, p as useInitiateSlackConnect, g as useLinkIntegrationConnection, f as useMyUserPlatformConnection, h as useRevokeSlackConnection, m as useToggleSlackNotifications };
@@ -1 +1 @@
1
- {"version":3,"file":"useUserPlatformConnection.js","names":["GlobalChannelType","useGlobalApolloClient","useGatewayClient","useMyUserPlatformConnection","globalClient","data","setData","useState","loading","setLoading","error","setError","fetch","useCallback","channelId","result","MyUserPlatformConnectionDocument","err","useEffect","useInitiateSlackConnect","integrationsUrl","redirectUri","useToggleSlackNotifications","UpdateUserPlatformConnectionNotificationsDocument","useRevokeSlackConnection","RevokeUserPlatformConnectionDocument","useLinkIntegrationConnection","LinkIntegrationConnectionDocument","GetChannelsDocument","DEFAULT_CHANNEL_FILTER","ChannelType","DEFAULT_CHANNEL_PAGINATION","useGlobalChannels","stableFilter","useMemo","filter","stablePagination","pagination"],"sources":["../../../src/botlit/hooks/useUserPlatformConnection.ts"],"sourcesContent":["/**\n * UserPlatformConnection Hooks\n * Phase 7: Slack personal account connect for channel users\n * @module botlit/hooks\n */\n\nimport { useState, useEffect, useCallback, useMemo } from 'react';\nimport { gql, type ApolloClient } from '@apollo/client';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\nimport {\n MyUserPlatformConnectionDocument,\n UpdateUserPlatformConnectionNotificationsDocument,\n RevokeUserPlatformConnectionDocument,\n LinkIntegrationConnectionDocument,\n} from '../../generated/global-operations';\nimport type {\n MyUserPlatformConnectionQuery,\n MyUserPlatformConnectionQueryVariables,\n UpdateUserPlatformConnectionNotificationsMutation,\n UpdateUserPlatformConnectionNotificationsMutationVariables,\n RevokeUserPlatformConnectionMutation,\n RevokeUserPlatformConnectionMutationVariables,\n LinkIntegrationConnectionMutation,\n LinkIntegrationConnectionMutationVariables,\n} from '../../generated/global-operations';\nimport type {\n ChannelPlatform,\n ChannelStatus,\n AdapterType,\n ChannelFilterInput,\n ChannelPaginationInput,\n} from '../../generated/global-types';\n// Value import: `channelType` on the filter is the generated enum, not the\n// local display-only `ChannelType` alias declared below.\nimport { ChannelType as GlobalChannelType } from '../../generated/global-types';\n\n// BOFF-1866 resolved: linkIntegrationConnection is published on global-channel-svc and\n// already codegen'd (see src/operations/global/channel/user-platform-connection.graphql).\n// Use the generated document/types instead of a hand-rolled one — the previous inline\n// gql selected a non-existent `success` field on UserPlatformConnection, which always\n// failed GraphQL validation server-side (BOFF-4691).\n\ntype ChannelType = string;\n\n// ============================================================================\n// Internal: global gateway client\n//\n// BOFF-5428: this module used to build its own ApolloClient defaulting to the\n// local-dev global gateway (port 4000) whenever the shell did not pass a\n// `globalApiGatewayUrl` prop — which it never did, so production shipped every\n// call to the caller's own machine. The shell already installs a configured\n// global-gateway client (correct URL, `x-workspace-id`, auth refresh + retry),\n// so use that and only that. Do NOT reintroduce a bespoke client or a\n// hardcoded gateway host here.\n// ============================================================================\n\nfunction useGlobalApolloClient(): ApolloClient {\n return useGatewayClient('global');\n}\n\n// ============================================================================\n// Exported types\n// ============================================================================\n\nexport interface UserPlatformConnectionData {\n id: string;\n channelId: string;\n platform: string;\n externalUserId: string;\n externalUsername?: string | null;\n externalDisplayName?: string | null;\n dmAllowed: boolean;\n notificationsEnabled: boolean;\n connectedAt?: string | null;\n canReceiveDm: boolean;\n isTokenExpired: boolean;\n userTokenExpiresAt?: string | null;\n integrationConnectionId?: string | null;\n}\n\n// ============================================================================\n// Hook: useMyUserPlatformConnection\n// ============================================================================\n\ninterface UseMyUserPlatformConnectionResult {\n data: UserPlatformConnectionData | null;\n loading: boolean;\n error: Error | null;\n refetch: () => Promise<void>;\n}\n\nexport function useMyUserPlatformConnection(\n channelId: string | undefined\n): UseMyUserPlatformConnectionResult {\n const globalClient = useGlobalApolloClient();\n\n const [data, setData] = useState<UserPlatformConnectionData | null>(null);\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const fetch = useCallback(async () => {\n if (!channelId) {\n setData(null);\n setLoading(false);\n setError(null);\n return;\n }\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.query<\n MyUserPlatformConnectionQuery,\n MyUserPlatformConnectionQueryVariables\n >({\n query: MyUserPlatformConnectionDocument,\n variables: { channelId },\n fetchPolicy: 'network-only',\n });\n setData(\n (result.data?.myUserPlatformConnection as UserPlatformConnectionData | null | undefined) ??\n null\n );\n } catch (err) {\n setError(err as Error);\n } finally {\n setLoading(false);\n }\n }, [channelId, globalClient]);\n\n useEffect(() => {\n fetch();\n }, [fetch]);\n\n return { data, loading, error, refetch: fetch };\n}\n\n// ============================================================================\n// Hook: useInitiateSlackConnect\n// DEPRECATED: Use integrations UI flow instead\n// Redirect user to: /integrations/connections?provider=slack-user&returnUrl=<current-page>&channelId=<channel-id>\n// After OAuth completes, integrations will redirect back with ?integrationConnectionId=<id>\n// Then call useLinkIntegrationConnection to link the connection to the channel\n// ============================================================================\n\ninterface UseInitiateSlackConnectResult {\n initiate: (channelId: string, redirectUri: string) => void;\n loading: boolean;\n error: Error | null;\n}\n\n/**\n * @deprecated Use integrations UI OAuth flow + useLinkIntegrationConnection instead\n */\nexport function useInitiateSlackConnect(): UseInitiateSlackConnectResult {\n const [loading] = useState<boolean>(false);\n const [error] = useState<Error | null>(null);\n\n const initiate = useCallback((channelId: string, redirectUri: string): void => {\n // Construct integrations URL with return parameters\n const integrationsUrl = new URL('/integrations/connections', window.location.origin);\n integrationsUrl.searchParams.set('provider', 'slack-user');\n integrationsUrl.searchParams.set('returnUrl', redirectUri);\n integrationsUrl.searchParams.set('channelId', channelId);\n\n // Redirect to integrations UI\n window.location.href = integrationsUrl.toString();\n }, []);\n\n return { initiate, loading, error };\n}\n\n// ============================================================================\n// Hook: useToggleSlackNotifications\n// ============================================================================\n\ninterface UseToggleSlackNotificationsResult {\n toggle: (id: string, notificationsEnabled: boolean) => Promise<UserPlatformConnectionData | null>;\n loading: boolean;\n error: Error | null;\n}\n\nexport function useToggleSlackNotifications(): UseToggleSlackNotificationsResult {\n const globalClient = useGlobalApolloClient();\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const toggle = useCallback(\n async (\n id: string,\n notificationsEnabled: boolean\n ): Promise<UserPlatformConnectionData | null> => {\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.mutate<\n UpdateUserPlatformConnectionNotificationsMutation,\n UpdateUserPlatformConnectionNotificationsMutationVariables\n >({\n mutation: UpdateUserPlatformConnectionNotificationsDocument,\n variables: { id, notificationsEnabled },\n });\n return (\n (result.data?.updateUserPlatformConnectionNotifications as\n UserPlatformConnectionData | null | undefined) ?? null\n );\n } catch (err) {\n setError(err as Error);\n return null;\n } finally {\n setLoading(false);\n }\n },\n [globalClient]\n );\n\n return { toggle, loading, error };\n}\n\n// ============================================================================\n// Hook: useRevokeSlackConnection\n// ============================================================================\n\ninterface UseRevokeSlackConnectionResult {\n revoke: (id: string) => Promise<boolean>;\n loading: boolean;\n error: Error | null;\n}\n\nexport function useRevokeSlackConnection(): UseRevokeSlackConnectionResult {\n const globalClient = useGlobalApolloClient();\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const revoke = useCallback(\n async (id: string): Promise<boolean> => {\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.mutate<\n RevokeUserPlatformConnectionMutation,\n RevokeUserPlatformConnectionMutationVariables\n >({\n mutation: RevokeUserPlatformConnectionDocument,\n variables: { id },\n });\n return result.data?.revokeUserPlatformConnection?.dmAllowed === false;\n } catch (err) {\n setError(err as Error);\n return false;\n } finally {\n setLoading(false);\n }\n },\n [globalClient]\n );\n\n return { revoke, loading, error };\n}\n\n// ============================================================================\n// Hook: useCompleteSlackConnect\n// DEPRECATED: OAuth now handled by integrations UI\n// After integrations OAuth completes, use useLinkIntegrationConnection instead\n// ============================================================================\n\ninterface UseCompleteSlackConnectResult {\n complete: (code: string, state: string) => Promise<UserPlatformConnectionData | null>;\n loading: boolean;\n error: Error | null;\n}\n\n/**\n * @deprecated OAuth is now handled by integrations UI. Use useLinkIntegrationConnection instead.\n */\nexport function useCompleteSlackConnect(): UseCompleteSlackConnectResult {\n const [loading] = useState<boolean>(false);\n const [error] = useState<Error | null>(null);\n\n const complete = useCallback(\n async (_code: string, _state: string): Promise<UserPlatformConnectionData | null> => {\n console.warn(\n 'useCompleteSlackConnect is deprecated. Use useLinkIntegrationConnection instead.'\n );\n return null;\n },\n []\n );\n\n return { complete, loading, error };\n}\n\n// ============================================================================\n// Hook: useLinkIntegrationConnection\n// Links a completed IntegrationConnection (from wspace-integrations-svc) to a\n// bot channel, creating/upserting a UserPlatformConnection on global-channel-svc.\n// Called by BotChannelsTab after the user returns from microfe-integrations with\n// ?integrationConnectionId=<id>&channelId=<id> in the URL.\n// Uses the generated LinkIntegrationConnectionDocument (schema-pulled + codegenned).\n// ============================================================================\n\ninterface UseLinkIntegrationConnectionResult {\n link: (\n integrationConnectionId: string,\n channelId: string\n ) => Promise<UserPlatformConnectionData | null>;\n loading: boolean;\n error: Error | null;\n}\n\nexport function useLinkIntegrationConnection(): UseLinkIntegrationConnectionResult {\n const globalClient = useGlobalApolloClient();\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const link = useCallback(\n async (\n integrationConnectionId: string,\n channelId: string\n ): Promise<UserPlatformConnectionData | null> => {\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.mutate<\n LinkIntegrationConnectionMutation,\n LinkIntegrationConnectionMutationVariables\n >({\n mutation: LinkIntegrationConnectionDocument,\n variables: { integrationConnectionId, channelId },\n });\n return (\n (result.data?.linkIntegrationConnection as\n UserPlatformConnectionData | null | undefined) ?? null\n );\n } catch (err) {\n setError(err as Error);\n return null;\n } finally {\n setLoading(false);\n }\n },\n [globalClient]\n );\n\n return { link, loading, error };\n}\n\n// ============================================================================\n// GQL document: getChannels (queried directly — no codegen needed)\n// ============================================================================\n\nconst GetChannelsDocument = gql`\n query GetChannels($filter: ChannelFilterInput, $pagination: ChannelPaginationInput) {\n getChannels(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n organizationId\n platform\n adapterType\n channelType\n status\n isConnected\n description\n priority\n connectionHealth\n }\n total\n hasMore\n }\n }\n`;\n\n// ============================================================================\n// Exported types: GlobalChannelData\n// ============================================================================\n\nexport interface GlobalChannelData {\n id: string;\n name: string;\n organizationId: string;\n platform: ChannelPlatform;\n adapterType: AdapterType | null;\n channelType: ChannelType;\n status: ChannelStatus;\n isConnected: boolean;\n description?: string | null;\n priority: number;\n connectionHealth: string;\n}\n\ninterface GetChannelsQueryResult {\n getChannels: {\n items: GlobalChannelData[];\n total: number;\n hasMore: boolean;\n };\n}\n\n// ============================================================================\n// Hook: useGlobalChannels\n// Fetches all ACTIVE channels from global-channel-svc via the global GraphQL gateway\n// ============================================================================\n\ninterface UseGlobalChannelsResult {\n data: GlobalChannelData[];\n loading: boolean;\n error: Error | null;\n refetch: () => Promise<void>;\n}\n\n/** Bot channels are the COMMUNICATION ones; the rest are not addressable here. */\nconst DEFAULT_CHANNEL_FILTER: ChannelFilterInput = {\n channelType: GlobalChannelType.Communication,\n};\nconst DEFAULT_CHANNEL_PAGINATION: ChannelPaginationInput = { offset: 0, limit: 50 };\n\nexport function useGlobalChannels(\n filter?: ChannelFilterInput,\n pagination?: ChannelPaginationInput\n): UseGlobalChannelsResult {\n const globalClient = useGlobalApolloClient();\n\n const [data, setData] = useState<GlobalChannelData[]>([]);\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n // Stable references so useCallback doesn't re-create on every render. The\n // defaults are module constants, so an omitted argument yields the same\n // object every render without hiding the argument from the dependency list.\n const stableFilter = useMemo(() => filter ?? DEFAULT_CHANNEL_FILTER, [filter]);\n const stablePagination = useMemo(() => pagination ?? DEFAULT_CHANNEL_PAGINATION, [pagination]);\n\n const fetch = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.query<GetChannelsQueryResult>({\n query: GetChannelsDocument,\n variables: { filter: stableFilter, pagination: stablePagination },\n fetchPolicy: 'network-only',\n });\n setData(result.data?.getChannels?.items ?? []);\n } catch (err) {\n setError(err as Error);\n } finally {\n setLoading(false);\n }\n }, [globalClient, stableFilter, stablePagination]);\n\n useEffect(() => {\n fetch();\n }, [fetch]);\n\n return { data, loading, error, refetch: fetch };\n}\n"],"mappings":";;;;;;AAwDA,SAASC,IAAsC;CAC7C,OAAOC,EAAiB,QAAQ;AAClC;AAiCA,SAAgBC,EACd,GACmC;CACnC,IAAMC,IAAeH,EAAsB,GAErC,CAACI,GAAMC,KAAWC,EAA4C,IAAI,GAClE,CAACC,GAASC,KAAcF,EAAkB,EAAK,GAC/C,CAACG,GAAOC,KAAYJ,EAAuB,IAAI,GAE/CK,IAAQC,EAAY,YAAY;EACpC,IAAI,CAACC,GAGH,AAFAR,EAAQ,IAAI,GACZG,EAAW,EAAK,GAChBE,EAAS,IAAI;OAGf;GACA,AADAF,EAAW,EAAI,GACfE,EAAS,IAAI;GACb,IAAI;IACF,IAAMI,IAAS,MAAMX,EAAa,MAGhC;KACA,OAAOY;KACP,WAAW,EAAE,aAAU;KACvB,aAAa;IACf,CAAC;IACD,EACGD,EAAO,MAAM,4BACZ,IACJ;GACF,SAASE,GAAK;IACZ,EAASA,CAAY;GACvB,UAAU;IACR,EAAW,EAAK;GAClB;EAnBe;CAoBjB,GAAG,CAACH,GAAWV,CAAY,CAAC;CAM5B,OAJAc,QAAgB;EACd,EAAM;CACR,GAAG,CAACN,CAAK,CAAC,GAEH;EAAE;EAAM;EAAS;EAAO,SAASA;CAAM;AAChD;AAmBA,SAAgBO,IAAyD;CACvE,IAAM,CAACX,KAAWD,EAAkB,EAAK,GACnC,CAACG,KAASH,EAAuB,IAAI;CAa3C,OAAO;EAAE,UAXQM,GAAa,GAAmB,MAA8B;GAE7E,IAAMO,IAAkB,IAAI,IAAI,6BAA6B,OAAO,SAAS,MAAM;GAMnF,AALAA,EAAgB,aAAa,IAAI,YAAY,YAAY,GACzDA,EAAgB,aAAa,IAAI,aAAaC,CAAW,GACzDD,EAAgB,aAAa,IAAI,aAA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ChD"}
1
+ {"version":3,"file":"useUserPlatformConnection.js","names":["GlobalChannelType","useMyUserPlatformConnection","globalClient","scopeContext","useWorkspaceScopedGlobalClient","data","setData","useState","loading","setLoading","error","setError","generationRef","useRef","fetch","useCallback","generation","isCurrent","channelId","result","MyUserPlatformConnectionDocument","err","useEffect","useInitiateSlackConnect","integrationsUrl","redirectUri","useToggleSlackNotifications","UpdateUserPlatformConnectionNotificationsDocument","useRevokeSlackConnection","RevokeUserPlatformConnectionDocument","useLinkIntegrationConnection","LinkIntegrationConnectionDocument","GetChannelsDocument","DEFAULT_CHANNEL_FILTER","ChannelType","DEFAULT_CHANNEL_PAGINATION","useGlobalChannels","stableFilter","useMemo","filter","stablePagination","pagination","items","limit","offset","operationError","page"],"sources":["../../../src/botlit/hooks/useUserPlatformConnection.ts"],"sourcesContent":["/**\n * UserPlatformConnection Hooks\n * Phase 7: Slack personal account connect for channel users\n * @module botlit/hooks\n */\n\nimport { useState, useEffect, useCallback, useMemo, useRef } from 'react';\nimport { gql } from '@apollo/client';\nimport {\n MyUserPlatformConnectionDocument,\n UpdateUserPlatformConnectionNotificationsDocument,\n RevokeUserPlatformConnectionDocument,\n LinkIntegrationConnectionDocument,\n} from '../../generated/global-operations';\nimport type {\n MyUserPlatformConnectionQuery,\n MyUserPlatformConnectionQueryVariables,\n UpdateUserPlatformConnectionNotificationsMutation,\n UpdateUserPlatformConnectionNotificationsMutationVariables,\n RevokeUserPlatformConnectionMutation,\n RevokeUserPlatformConnectionMutationVariables,\n LinkIntegrationConnectionMutation,\n LinkIntegrationConnectionMutationVariables,\n} from '../../generated/global-operations';\nimport type {\n ChannelPlatform,\n ChannelStatus,\n AdapterType,\n ChannelFilterInput,\n ChannelPaginationInput,\n} from '../../generated/global-types';\n// Value import: `channelType` on the filter is the generated enum, not the\n// local display-only `ChannelType` alias declared below.\nimport { ChannelType as GlobalChannelType } from '../../generated/global-types';\nimport { useWorkspaceScopedGlobalClient } from './internal/globalWorkspaceScope';\n\n// BOFF-1866 resolved: linkIntegrationConnection is published on global-channel-svc and\n// already codegen'd (see src/operations/global/channel/user-platform-connection.graphql).\n// Use the generated document/types instead of a hand-rolled one — the previous inline\n// gql selected a non-existent `success` field on UserPlatformConnection, which always\n// failed GraphQL validation server-side (BOFF-4691).\n\ntype ChannelType = string;\n\n// ============================================================================\n// Internal: global gateway client\n//\n// BOFF-5428: this module used to build its own ApolloClient defaulting to the\n// local-dev global gateway (port 4000). The shell already installs a\n// configured global-gateway client (correct URL, auth refresh + retry), so use\n// that and only that. Do NOT reintroduce a bespoke client or a hardcoded\n// gateway host here.\n//\n// BOFF-15360: channels belong to the active workspace's organization, not the\n// user's home one, so every call carries the workspace scope context\n// (see `internal/globalWorkspaceScope`).\n// ============================================================================\n\n// ============================================================================\n// Exported types\n// ============================================================================\n\nexport interface UserPlatformConnectionData {\n id: string;\n channelId: string;\n platform: string;\n externalUserId: string;\n externalUsername?: string | null;\n externalDisplayName?: string | null;\n dmAllowed: boolean;\n notificationsEnabled: boolean;\n connectedAt?: string | null;\n canReceiveDm: boolean;\n isTokenExpired: boolean;\n userTokenExpiresAt?: string | null;\n integrationConnectionId?: string | null;\n}\n\n// ============================================================================\n// Hook: useMyUserPlatformConnection\n// ============================================================================\n\ninterface UseMyUserPlatformConnectionResult {\n data: UserPlatformConnectionData | null;\n loading: boolean;\n error: Error | null;\n refetch: () => Promise<void>;\n}\n\nexport function useMyUserPlatformConnection(\n channelId: string | undefined\n): UseMyUserPlatformConnectionResult {\n const { client: globalClient, context: scopeContext } = useWorkspaceScopedGlobalClient();\n\n const [data, setData] = useState<UserPlatformConnectionData | null>(null);\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n // Bumped per read: a superseded read (workspace switch) must not land.\n const generationRef = useRef(0);\n\n const fetch = useCallback(async () => {\n const generation = ++generationRef.current;\n const isCurrent = () => generation === generationRef.current;\n if (!channelId) {\n setData(null);\n setLoading(false);\n setError(null);\n return;\n }\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.query<\n MyUserPlatformConnectionQuery,\n MyUserPlatformConnectionQueryVariables\n >({\n query: MyUserPlatformConnectionDocument,\n variables: { channelId },\n fetchPolicy: 'network-only',\n context: scopeContext,\n });\n if (!isCurrent()) return;\n setData(\n (result.data?.myUserPlatformConnection as UserPlatformConnectionData | null | undefined) ??\n null\n );\n } catch (err) {\n if (isCurrent()) setError(err as Error);\n } finally {\n if (isCurrent()) setLoading(false);\n }\n }, [channelId, globalClient, scopeContext]);\n\n useEffect(() => {\n fetch();\n }, [fetch]);\n\n return { data, loading, error, refetch: fetch };\n}\n\n// ============================================================================\n// Hook: useInitiateSlackConnect\n// DEPRECATED: Use integrations UI flow instead\n// Redirect user to: /integrations/connections?provider=slack-user&returnUrl=<current-page>&channelId=<channel-id>\n// After OAuth completes, integrations will redirect back with ?integrationConnectionId=<id>\n// Then call useLinkIntegrationConnection to link the connection to the channel\n// ============================================================================\n\ninterface UseInitiateSlackConnectResult {\n initiate: (channelId: string, redirectUri: string) => void;\n loading: boolean;\n error: Error | null;\n}\n\n/**\n * @deprecated Use integrations UI OAuth flow + useLinkIntegrationConnection instead\n */\nexport function useInitiateSlackConnect(): UseInitiateSlackConnectResult {\n const [loading] = useState<boolean>(false);\n const [error] = useState<Error | null>(null);\n\n const initiate = useCallback((channelId: string, redirectUri: string): void => {\n // Construct integrations URL with return parameters\n const integrationsUrl = new URL('/integrations/connections', window.location.origin);\n integrationsUrl.searchParams.set('provider', 'slack-user');\n integrationsUrl.searchParams.set('returnUrl', redirectUri);\n integrationsUrl.searchParams.set('channelId', channelId);\n\n // Redirect to integrations UI\n window.location.href = integrationsUrl.toString();\n }, []);\n\n return { initiate, loading, error };\n}\n\n// ============================================================================\n// Hook: useToggleSlackNotifications\n// ============================================================================\n\ninterface UseToggleSlackNotificationsResult {\n toggle: (id: string, notificationsEnabled: boolean) => Promise<UserPlatformConnectionData | null>;\n loading: boolean;\n error: Error | null;\n}\n\nexport function useToggleSlackNotifications(): UseToggleSlackNotificationsResult {\n const { client: globalClient, context: scopeContext } = useWorkspaceScopedGlobalClient();\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const toggle = useCallback(\n async (\n id: string,\n notificationsEnabled: boolean\n ): Promise<UserPlatformConnectionData | null> => {\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.mutate<\n UpdateUserPlatformConnectionNotificationsMutation,\n UpdateUserPlatformConnectionNotificationsMutationVariables\n >({\n mutation: UpdateUserPlatformConnectionNotificationsDocument,\n variables: { id, notificationsEnabled },\n context: scopeContext,\n });\n return (\n (result.data?.updateUserPlatformConnectionNotifications as\n UserPlatformConnectionData | null | undefined) ?? null\n );\n } catch (err) {\n setError(err as Error);\n return null;\n } finally {\n setLoading(false);\n }\n },\n [globalClient, scopeContext]\n );\n\n return { toggle, loading, error };\n}\n\n// ============================================================================\n// Hook: useRevokeSlackConnection\n// ============================================================================\n\ninterface UseRevokeSlackConnectionResult {\n revoke: (id: string) => Promise<boolean>;\n loading: boolean;\n error: Error | null;\n}\n\nexport function useRevokeSlackConnection(): UseRevokeSlackConnectionResult {\n const { client: globalClient, context: scopeContext } = useWorkspaceScopedGlobalClient();\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const revoke = useCallback(\n async (id: string): Promise<boolean> => {\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.mutate<\n RevokeUserPlatformConnectionMutation,\n RevokeUserPlatformConnectionMutationVariables\n >({\n mutation: RevokeUserPlatformConnectionDocument,\n variables: { id },\n context: scopeContext,\n });\n return result.data?.revokeUserPlatformConnection?.dmAllowed === false;\n } catch (err) {\n setError(err as Error);\n return false;\n } finally {\n setLoading(false);\n }\n },\n [globalClient, scopeContext]\n );\n\n return { revoke, loading, error };\n}\n\n// ============================================================================\n// Hook: useCompleteSlackConnect\n// DEPRECATED: OAuth now handled by integrations UI\n// After integrations OAuth completes, use useLinkIntegrationConnection instead\n// ============================================================================\n\ninterface UseCompleteSlackConnectResult {\n complete: (code: string, state: string) => Promise<UserPlatformConnectionData | null>;\n loading: boolean;\n error: Error | null;\n}\n\n/**\n * @deprecated OAuth is now handled by integrations UI. Use useLinkIntegrationConnection instead.\n */\nexport function useCompleteSlackConnect(): UseCompleteSlackConnectResult {\n const [loading] = useState<boolean>(false);\n const [error] = useState<Error | null>(null);\n\n const complete = useCallback(\n async (_code: string, _state: string): Promise<UserPlatformConnectionData | null> => {\n console.warn(\n 'useCompleteSlackConnect is deprecated. Use useLinkIntegrationConnection instead.'\n );\n return null;\n },\n []\n );\n\n return { complete, loading, error };\n}\n\n// ============================================================================\n// Hook: useLinkIntegrationConnection\n// Links a completed IntegrationConnection (from wspace-integrations-svc) to a\n// bot channel, creating/upserting a UserPlatformConnection on global-channel-svc.\n// Called by BotChannelsTab after the user returns from microfe-integrations with\n// ?integrationConnectionId=<id>&channelId=<id> in the URL.\n// Uses the generated LinkIntegrationConnectionDocument (schema-pulled + codegenned).\n// ============================================================================\n\ninterface UseLinkIntegrationConnectionResult {\n link: (\n integrationConnectionId: string,\n channelId: string\n ) => Promise<UserPlatformConnectionData | null>;\n loading: boolean;\n error: Error | null;\n}\n\nexport function useLinkIntegrationConnection(): UseLinkIntegrationConnectionResult {\n const { client: globalClient, context: scopeContext } = useWorkspaceScopedGlobalClient();\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const link = useCallback(\n async (\n integrationConnectionId: string,\n channelId: string\n ): Promise<UserPlatformConnectionData | null> => {\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.mutate<\n LinkIntegrationConnectionMutation,\n LinkIntegrationConnectionMutationVariables\n >({\n mutation: LinkIntegrationConnectionDocument,\n variables: { integrationConnectionId, channelId },\n context: scopeContext,\n });\n return (\n (result.data?.linkIntegrationConnection as\n UserPlatformConnectionData | null | undefined) ?? null\n );\n } catch (err) {\n setError(err as Error);\n return null;\n } finally {\n setLoading(false);\n }\n },\n [globalClient, scopeContext]\n );\n\n return { link, loading, error };\n}\n\n// ============================================================================\n// GQL document: getChannels (queried directly — no codegen needed)\n// ============================================================================\n\nconst GetChannelsDocument = gql`\n query GetChannels($filter: ChannelFilterInput, $pagination: ChannelPaginationInput) {\n getChannels(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n organizationId\n platform\n adapterType\n channelType\n status\n isConnected\n description\n priority\n connectionHealth\n }\n total\n hasMore\n }\n }\n`;\n\n// ============================================================================\n// Exported types: GlobalChannelData\n// ============================================================================\n\nexport interface GlobalChannelData {\n id: string;\n name: string;\n organizationId: string;\n platform: ChannelPlatform;\n adapterType: AdapterType | null;\n channelType: ChannelType;\n status: ChannelStatus;\n isConnected: boolean;\n description?: string | null;\n priority: number;\n connectionHealth: string;\n}\n\ninterface GetChannelsQueryResult {\n getChannels: {\n items: GlobalChannelData[];\n total: number;\n hasMore: boolean;\n };\n}\n\n// ============================================================================\n// Hook: useGlobalChannels\n// Fetches all ACTIVE channels from global-channel-svc via the global GraphQL\n// gateway, every page (`pagination` sets the page size and start offset)\n// ============================================================================\n\ninterface UseGlobalChannelsResult {\n data: GlobalChannelData[];\n loading: boolean;\n error: Error | null;\n refetch: () => Promise<void>;\n}\n\n/** Bot channels are the COMMUNICATION ones; the rest are not addressable here. */\nconst DEFAULT_CHANNEL_FILTER: ChannelFilterInput = {\n channelType: GlobalChannelType.Communication,\n};\nconst DEFAULT_CHANNEL_PAGINATION: ChannelPaginationInput = { offset: 0, limit: 50 };\n\nexport function useGlobalChannels(\n filter?: ChannelFilterInput,\n pagination?: ChannelPaginationInput\n): UseGlobalChannelsResult {\n const { client: globalClient, context: scopeContext } = useWorkspaceScopedGlobalClient();\n\n const [data, setData] = useState<GlobalChannelData[]>([]);\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n // Bumped per read: a read superseded by a newer one (e.g. a workspace\n // switch mid-paging) must not overwrite the newer read's state.\n const generationRef = useRef(0);\n\n // Stable references so useCallback doesn't re-create on every render. The\n // defaults are module constants, so an omitted argument yields the same\n // object every render without hiding the argument from the dependency list.\n const stableFilter = useMemo(() => filter ?? DEFAULT_CHANNEL_FILTER, [filter]);\n const stablePagination = useMemo(() => pagination ?? DEFAULT_CHANNEL_PAGINATION, [pagination]);\n\n const fetch = useCallback(async () => {\n const generation = ++generationRef.current;\n const isCurrent = () => generation === generationRef.current;\n setLoading(true);\n setError(null);\n try {\n // Every page (BOFF-15360): callers classify connectors by this list, so\n // a channel past the first page must not be missed.\n const items: GlobalChannelData[] = [];\n const limit = stablePagination.limit ?? DEFAULT_CHANNEL_PAGINATION.limit ?? 50;\n for (let offset = stablePagination.offset ?? 0; ; offset += limit) {\n const result = await globalClient.query<GetChannelsQueryResult>({\n query: GetChannelsDocument,\n variables: { filter: stableFilter, pagination: { ...stablePagination, offset, limit } },\n fetchPolicy: 'network-only',\n context: scopeContext,\n });\n // Apollo v4 resolves with `error` set on GraphQL errors.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) throw operationError;\n const page = result.data?.getChannels;\n items.push(...(page?.items ?? []));\n if (!page?.hasMore || (page.items ?? []).length === 0) break;\n }\n if (isCurrent()) setData(items);\n } catch (err) {\n if (isCurrent()) setError(err as Error);\n } finally {\n if (isCurrent()) setLoading(false);\n }\n }, [globalClient, scopeContext, stableFilter, stablePagination]);\n\n useEffect(() => {\n fetch();\n }, [fetch]);\n\n return { data, loading, error, refetch: fetch };\n}\n"],"mappings":";;;;;;AAyFA,SAAgBC,EACd,GACmC;CACnC,IAAM,EAAE,QAAQC,GAAc,SAASC,MAAiBC,EAA+B,GAEjF,CAACC,GAAMC,KAAWC,EAA4C,IAAI,GAClE,CAACC,GAASC,KAAcF,EAAkB,EAAK,GAC/C,CAACG,GAAOC,KAAYJ,EAAuB,IAAI,GAE/CK,IAAgBC,EAAO,CAAC,GAExBC,IAAQC,EAAY,YAAY;EACpC,IAAMC,IAAa,EAAEJ,EAAc,SAC7BK,UAAkBD,MAAeJ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