@burdenoff/microfe-integrations 2026.1109.2 → 2026.1113.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/integrations/components/ConnectionCard.js +19 -13
- package/dist/integrations/components/ConnectionCard.js.map +1 -1
- package/dist/integrations/hooks/useProviders.d.ts +30 -2
- package/dist/integrations/hooks/useProviders.js +71 -22
- package/dist/integrations/hooks/useProviders.js.map +1 -1
- package/dist/integrations/pages/ConnectionDetail.js +24 -19
- package/dist/integrations/pages/ConnectionDetail.js.map +1 -1
- package/dist/integrations/pages/IntegrationsOverview.js +144 -151
- package/dist/integrations/pages/IntegrationsOverview.js.map +1 -1
- package/package.json +2 -2
|
@@ -6,8 +6,9 @@ import { ChevronRight as i, Lock as a } from "lucide-react";
|
|
|
6
6
|
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
7
|
import { ProviderIcon as l } from "@burdenoff/fe-libs/connections";
|
|
8
8
|
import { GlassCard as u } from "@burdenoff/fe-libs/ui";
|
|
9
|
+
import { suggestAnchorProps as d } from "@burdenoff/fe-libs/shared/proactive";
|
|
9
10
|
// src/integrations/components/ConnectionCard.tsx
|
|
10
|
-
var
|
|
11
|
+
var f = ({ connection: e }) => {
|
|
11
12
|
let n = t();
|
|
12
13
|
if (e.visibility !== "RESTRICTED") return null;
|
|
13
14
|
let r = n("integrations.connectionCard.private", "Private: only the people it is shared with");
|
|
@@ -23,15 +24,19 @@ var d = ({ connection: e }) => {
|
|
|
23
24
|
children: r
|
|
24
25
|
})]
|
|
25
26
|
});
|
|
26
|
-
},
|
|
27
|
-
let
|
|
28
|
-
|
|
27
|
+
}, p = ({ connection: a, displayMode: p = "grid", onClick: m }) => {
|
|
28
|
+
let h = t(), g = n(), _ = d({
|
|
29
|
+
entityType: "connection",
|
|
30
|
+
entityId: a.id
|
|
31
|
+
});
|
|
32
|
+
return p === "list" ? /* @__PURE__ */ c(u, {
|
|
33
|
+
..._,
|
|
29
34
|
className: e("group flex items-center gap-4 p-4 border-border-seam", "cursor-pointer hover:shadow-[var(--shadow-pop)] hover:border-border-strong", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]", "animate-in fade-in-0"),
|
|
30
|
-
onClick: () =>
|
|
35
|
+
onClick: () => m?.(a),
|
|
31
36
|
role: "button",
|
|
32
37
|
tabIndex: 0,
|
|
33
38
|
onKeyDown: (e) => {
|
|
34
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
39
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), m?.(a));
|
|
35
40
|
},
|
|
36
41
|
children: [
|
|
37
42
|
/* @__PURE__ */ s(l, {
|
|
@@ -47,7 +52,7 @@ var d = ({ connection: e }) => {
|
|
|
47
52
|
className: "font-semibold text-text-primary truncate",
|
|
48
53
|
children: a.name
|
|
49
54
|
}),
|
|
50
|
-
/* @__PURE__ */ s(
|
|
55
|
+
/* @__PURE__ */ s(f, { connection: a }),
|
|
51
56
|
/* @__PURE__ */ s(r, { status: a.status })
|
|
52
57
|
]
|
|
53
58
|
}), /* @__PURE__ */ c("div", {
|
|
@@ -68,7 +73,7 @@ var d = ({ connection: e }) => {
|
|
|
68
73
|
className: "flex items-center gap-3 flex-shrink-0",
|
|
69
74
|
children: [/* @__PURE__ */ s("span", {
|
|
70
75
|
className: "text-xs text-text-secondary",
|
|
71
|
-
children:
|
|
76
|
+
children: h("integrations.connectionCard.lastUsed", "Last used {{time}}", { time: g(a.lastUsedAt) })
|
|
72
77
|
}), /* @__PURE__ */ s(i, {
|
|
73
78
|
size: 18,
|
|
74
79
|
className: "text-text-secondary group-hover:text-primary transition-colors"
|
|
@@ -76,12 +81,13 @@ var d = ({ connection: e }) => {
|
|
|
76
81
|
})
|
|
77
82
|
]
|
|
78
83
|
}) : /* @__PURE__ */ c(u, {
|
|
84
|
+
..._,
|
|
79
85
|
className: e("group relative flex flex-col p-5 border-border-seam", "cursor-pointer hover:shadow-[var(--shadow-pop)] hover:border-border-strong", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]", "animate-in fade-in-0"),
|
|
80
|
-
onClick: () =>
|
|
86
|
+
onClick: () => m?.(a),
|
|
81
87
|
role: "button",
|
|
82
88
|
tabIndex: 0,
|
|
83
89
|
onKeyDown: (e) => {
|
|
84
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
90
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), m?.(a));
|
|
85
91
|
},
|
|
86
92
|
children: [
|
|
87
93
|
/* @__PURE__ */ c("div", {
|
|
@@ -96,7 +102,7 @@ var d = ({ connection: e }) => {
|
|
|
96
102
|
children: [/* @__PURE__ */ s("h3", {
|
|
97
103
|
className: "font-semibold text-text-primary truncate",
|
|
98
104
|
children: a.name
|
|
99
|
-
}), /* @__PURE__ */ s(
|
|
105
|
+
}), /* @__PURE__ */ s(f, { connection: a })]
|
|
100
106
|
}),
|
|
101
107
|
/* @__PURE__ */ s("p", {
|
|
102
108
|
className: "text-sm text-text-secondary truncate",
|
|
@@ -114,7 +120,7 @@ var d = ({ connection: e }) => {
|
|
|
114
120
|
className: "flex items-center justify-between mt-auto pt-3 border-t border-border-seam",
|
|
115
121
|
children: [/* @__PURE__ */ s("span", {
|
|
116
122
|
className: "text-xs text-text-secondary",
|
|
117
|
-
children:
|
|
123
|
+
children: h("integrations.connectionCard.lastUsed", "Last used {{time}}", { time: g(a.lastUsedAt) })
|
|
118
124
|
}), /* @__PURE__ */ s(i, {
|
|
119
125
|
size: 16,
|
|
120
126
|
className: "text-text-secondary group-hover:text-primary transition-colors"
|
|
@@ -123,6 +129,6 @@ var d = ({ connection: e }) => {
|
|
|
123
129
|
]
|
|
124
130
|
});
|
|
125
131
|
};
|
|
126
|
-
export {
|
|
132
|
+
export { p as ConnectionCard };
|
|
127
133
|
|
|
128
134
|
//# sourceMappingURL=ConnectionCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionCard.js","names":["_Fragment","PrivateBadge","tr","useTr","connection","label","Lock","ConnectionCard","formatLastUsed","useFormatLastUsed","displayMode","GlassCard","cn","onClick","ProviderIcon","ConnectionStatusBadge","Fragment","ChevronRight"],"sources":["../../../src/integrations/components/ConnectionCard.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { ChevronRight, Lock } from 'lucide-react';\nimport { cn } from '../utils/cn';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../hooks/useTr';\nimport { useFormatLastUsed } from '../hooks/useFormatLastUsed';\nimport type { IntegrationConnection } from '../types';\nimport { ProviderIcon } from '@burdenoff/fe-libs/connections';\nimport { ConnectionStatusBadge } from './ConnectionStatusBadge';\n\ninterface ConnectionCardProps {\n connection: IntegrationConnection;\n displayMode?: 'grid' | 'list';\n onClick?: (connection: IntegrationConnection) => void;\n}\n\n/**\n * A lock for a connection only the people it is shared with can use (BOFF-9726).\n */\nconst PrivateBadge: FC<{ connection: IntegrationConnection }> = ({ connection }) => {\n const tr = useTr();\n if (connection.visibility !== 'RESTRICTED') return null;\n const label = tr(\n 'integrations.connectionCard.private',\n 'Private: only the people it is shared with'\n );\n return (\n <span\n className=\"inline-flex shrink-0 items-center text-text-secondary\"\n title={label}\n data-testid=\"connection-private-badge\"\n >\n <Lock size={13} aria-hidden=\"true\" />\n <span className=\"sr-only\">{label}</span>\n </span>\n );\n};\n\n/**\n * Card showing connection info (provider icon, connection name, account email, status badge, last used).\n */\nexport const ConnectionCard: FC<ConnectionCardProps> = ({\n connection,\n displayMode = 'grid',\n onClick,\n}) => {\n const tr = useTr();\n const formatLastUsed = useFormatLastUsed();\n\n if (displayMode === 'list') {\n return (\n <GlassCard\n className={cn(\n 'group flex items-center gap-4 p-4 border-border-seam',\n 'cursor-pointer hover:shadow-[var(--shadow-pop)] hover:border-border-strong',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]',\n 'animate-in fade-in-0'\n )}\n onClick={() => onClick?.(connection)}\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onClick?.(connection);\n }\n }}\n >\n <ProviderIcon provider={connection.provider} size={40} />\n\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <h3 className=\"font-semibold text-text-primary truncate\">{connection.name}</h3>\n <PrivateBadge connection={connection} />\n <ConnectionStatusBadge status={connection.status} />\n </div>\n <div className=\"flex items-center gap-2 mt-0.5\">\n <span className=\"text-sm text-text-secondary\">{connection.provider.name}</span>\n {connection.externalAccountEmail && (\n <>\n <span className=\"text-text-secondary\">·</span>\n <span className=\"text-sm text-text-secondary truncate\">\n {connection.externalAccountEmail}\n </span>\n </>\n )}\n </div>\n </div>\n\n <div className=\"flex items-center gap-3 flex-shrink-0\">\n <span className=\"text-xs text-text-secondary\">\n {tr('integrations.connectionCard.lastUsed', 'Last used {{time}}', {\n time: formatLastUsed(connection.lastUsedAt),\n })}\n </span>\n <ChevronRight\n size={18}\n className=\"text-text-secondary group-hover:text-primary transition-colors\"\n />\n </div>\n </GlassCard>\n );\n }\n\n return (\n <GlassCard\n className={cn(\n 'group relative flex flex-col p-5 border-border-seam',\n 'cursor-pointer hover:shadow-[var(--shadow-pop)] hover:border-border-strong',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]',\n 'animate-in fade-in-0'\n )}\n onClick={() => onClick?.(connection)}\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onClick?.(connection);\n }\n }}\n >\n <div className=\"flex items-start justify-between mb-3\">\n <ProviderIcon provider={connection.provider} size={44} />\n <ConnectionStatusBadge status={connection.status} />\n </div>\n\n <div className=\"mb-0.5 flex items-center gap-1.5\">\n <h3 className=\"font-semibold text-text-primary truncate\">{connection.name}</h3>\n <PrivateBadge connection={connection} />\n </div>\n <p className=\"text-sm text-text-secondary truncate\">{connection.provider.name}</p>\n\n {connection.externalAccountEmail && (\n <p className=\"text-xs text-text-secondary truncate mt-1\">\n {connection.externalAccountName || connection.externalAccountEmail}\n </p>\n )}\n\n {connection.description && (\n <p className=\"text-sm text-text-secondary line-clamp-2 mt-2\">{connection.description}</p>\n )}\n\n <div className=\"flex items-center justify-between mt-auto pt-3 border-t border-border-seam\">\n <span className=\"text-xs text-text-secondary\">\n {tr('integrations.connectionCard.lastUsed', 'Last used {{time}}', {\n time: formatLastUsed(connection.lastUsedAt),\n })}\n </span>\n <ChevronRight\n size={16}\n className=\"text-text-secondary group-hover:text-primary transition-colors\"\n />\n </div>\n </GlassCard>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConnectionCard.js","names":["_Fragment","PrivateBadge","tr","useTr","connection","label","Lock","ConnectionCard","formatLastUsed","useFormatLastUsed","anchorProps","suggestAnchorProps","displayMode","GlassCard","cn","onClick","ProviderIcon","ConnectionStatusBadge","Fragment","ChevronRight"],"sources":["../../../src/integrations/components/ConnectionCard.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { ChevronRight, Lock } from 'lucide-react';\nimport { cn } from '../utils/cn';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../hooks/useTr';\nimport { useFormatLastUsed } from '../hooks/useFormatLastUsed';\nimport type { IntegrationConnection } from '../types';\nimport { ProviderIcon } from '@burdenoff/fe-libs/connections';\nimport { suggestAnchorProps } from '@burdenoff/fe-libs/shared/proactive';\nimport { ConnectionStatusBadge } from './ConnectionStatusBadge';\n\ninterface ConnectionCardProps {\n connection: IntegrationConnection;\n displayMode?: 'grid' | 'list';\n onClick?: (connection: IntegrationConnection) => void;\n}\n\n/**\n * A lock for a connection only the people it is shared with can use (BOFF-9726).\n */\nconst PrivateBadge: FC<{ connection: IntegrationConnection }> = ({ connection }) => {\n const tr = useTr();\n if (connection.visibility !== 'RESTRICTED') return null;\n const label = tr(\n 'integrations.connectionCard.private',\n 'Private: only the people it is shared with'\n );\n return (\n <span\n className=\"inline-flex shrink-0 items-center text-text-secondary\"\n title={label}\n data-testid=\"connection-private-badge\"\n >\n <Lock size={13} aria-hidden=\"true\" />\n <span className=\"sr-only\">{label}</span>\n </span>\n );\n};\n\n/**\n * Card showing connection info (provider icon, connection name, account email, status badge, last used).\n */\nexport const ConnectionCard: FC<ConnectionCardProps> = ({\n connection,\n displayMode = 'grid',\n onClick,\n}) => {\n const tr = useTr();\n const formatLastUsed = useFormatLastUsed();\n // A proactive suggestion about this connection (an expired token, say) pins\n // to the card (contract C7, BOFF-13166).\n const anchorProps = suggestAnchorProps({ entityType: 'connection', entityId: connection.id });\n\n if (displayMode === 'list') {\n return (\n <GlassCard\n {...anchorProps}\n className={cn(\n 'group flex items-center gap-4 p-4 border-border-seam',\n 'cursor-pointer hover:shadow-[var(--shadow-pop)] hover:border-border-strong',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]',\n 'animate-in fade-in-0'\n )}\n onClick={() => onClick?.(connection)}\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onClick?.(connection);\n }\n }}\n >\n <ProviderIcon provider={connection.provider} size={40} />\n\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <h3 className=\"font-semibold text-text-primary truncate\">{connection.name}</h3>\n <PrivateBadge connection={connection} />\n <ConnectionStatusBadge status={connection.status} />\n </div>\n <div className=\"flex items-center gap-2 mt-0.5\">\n <span className=\"text-sm text-text-secondary\">{connection.provider.name}</span>\n {connection.externalAccountEmail && (\n <>\n <span className=\"text-text-secondary\">·</span>\n <span className=\"text-sm text-text-secondary truncate\">\n {connection.externalAccountEmail}\n </span>\n </>\n )}\n </div>\n </div>\n\n <div className=\"flex items-center gap-3 flex-shrink-0\">\n <span className=\"text-xs text-text-secondary\">\n {tr('integrations.connectionCard.lastUsed', 'Last used {{time}}', {\n time: formatLastUsed(connection.lastUsedAt),\n })}\n </span>\n <ChevronRight\n size={18}\n className=\"text-text-secondary group-hover:text-primary transition-colors\"\n />\n </div>\n </GlassCard>\n );\n }\n\n return (\n <GlassCard\n {...anchorProps}\n className={cn(\n 'group relative flex flex-col p-5 border-border-seam',\n 'cursor-pointer hover:shadow-[var(--shadow-pop)] hover:border-border-strong',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]',\n 'animate-in fade-in-0'\n )}\n onClick={() => onClick?.(connection)}\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onClick?.(connection);\n }\n }}\n >\n <div className=\"flex items-start justify-between mb-3\">\n <ProviderIcon provider={connection.provider} size={44} />\n <ConnectionStatusBadge status={connection.status} />\n </div>\n\n <div className=\"mb-0.5 flex items-center gap-1.5\">\n <h3 className=\"font-semibold text-text-primary truncate\">{connection.name}</h3>\n <PrivateBadge connection={connection} />\n </div>\n <p className=\"text-sm text-text-secondary truncate\">{connection.provider.name}</p>\n\n {connection.externalAccountEmail && (\n <p className=\"text-xs text-text-secondary truncate mt-1\">\n {connection.externalAccountName || connection.externalAccountEmail}\n </p>\n )}\n\n {connection.description && (\n <p className=\"text-sm text-text-secondary line-clamp-2 mt-2\">{connection.description}</p>\n )}\n\n <div className=\"flex items-center justify-between mt-auto pt-3 border-t border-border-seam\">\n <span className=\"text-xs text-text-secondary\">\n {tr('integrations.connectionCard.lastUsed', 'Last used {{time}}', {\n time: formatLastUsed(connection.lastUsedAt),\n })}\n </span>\n <ChevronRight\n size={16}\n className=\"text-text-secondary group-hover:text-primary transition-colors\"\n />\n </div>\n </GlassCard>\n );\n};\n"],"mappings":";;;;;;;;;;AAoBA,IAAMC,KAA2D,EAAE,oBAAiB;CAClF,IAAMC,IAAKC,EAAM;CACjB,IAAIC,EAAW,eAAe,cAAc,OAAO;C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,EAC5C,CAAC;IACG,CAAA,GACN,kBAACe,GAAD;KACE,MAAM;KACN,WAAU;IACX,CAAA,CACE;;EACI;;AAEf"}
|
|
@@ -4,12 +4,40 @@ interface ProviderFilterOptions {
|
|
|
4
4
|
pluginStatus?: PluginStatus;
|
|
5
5
|
search?: string;
|
|
6
6
|
}
|
|
7
|
+
/** The service caps one getProviders page at 100 rows. */
|
|
8
|
+
export declare const PROVIDER_PAGE_SIZE = 100;
|
|
9
|
+
type ProvidersPage = {
|
|
10
|
+
getProviders: {
|
|
11
|
+
items: ReadonlyArray<{
|
|
12
|
+
id: string;
|
|
13
|
+
}>;
|
|
14
|
+
total: number;
|
|
15
|
+
hasMore: boolean;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Appends a fetched page to the providers loaded so far. Rows already present
|
|
20
|
+
* (by id) are skipped so a catalog that shifts between pages never shows a
|
|
21
|
+
* provider twice, and a page that adds nothing ends paging so a stale
|
|
22
|
+
* `hasMore` cannot loop.
|
|
23
|
+
*/
|
|
24
|
+
export declare function mergeProviderPages<T extends ProvidersPage>(previous: T, next: T | undefined): T;
|
|
25
|
+
/**
|
|
26
|
+
* Loads every provider the filter matches. The catalog has grown past one
|
|
27
|
+
* page (BOFF-11224: providers seeded after the first 100 by display order,
|
|
28
|
+
* such as ClickSend, never reached the catalog or the add-connection wizard,
|
|
29
|
+
* whose search runs on the loaded rows), so the hook keeps fetching pages
|
|
30
|
+
* until the service reports no more.
|
|
31
|
+
*/
|
|
7
32
|
export declare function useProviders(filter?: ProviderFilterOptions): {
|
|
8
33
|
providers: IntegrationProvider[];
|
|
9
|
-
total:
|
|
34
|
+
total: any;
|
|
10
35
|
loading: boolean;
|
|
11
36
|
error: import('@apollo/client').ErrorLike | undefined;
|
|
12
|
-
refetch:
|
|
37
|
+
refetch: () => Promise<{
|
|
38
|
+
data: any;
|
|
39
|
+
error?: import('@apollo/client').ErrorLike;
|
|
40
|
+
}>;
|
|
13
41
|
};
|
|
14
42
|
export declare function useProvider(id: string): {
|
|
15
43
|
provider: IntegrationProvider | null;
|
|
@@ -1,26 +1,75 @@
|
|
|
1
1
|
import { useDeleteProviderAuthMethodMutation as e, useDisableProviderMutation as t, useEnableProviderMutation as n, useGetProviderByKeyQuery as r, useGetProviderQuery as i, useGetProvidersQuery as a, useInstallProviderPluginMutation as o, useUninstallProviderPluginMutation as s, useUpdateProviderPluginMutation as c, useUpsertProviderAuthMethodMutation as l } from "../../generated/wspace-operations.js";
|
|
2
2
|
import { mapProvider as u } from "../utils/mappers.js";
|
|
3
3
|
import { useIntegrations as d } from "../providers/IntegrationsProvider.js";
|
|
4
|
-
import { useCallback as f,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let
|
|
4
|
+
import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
5
|
+
function _(e, t) {
|
|
6
|
+
if (!t?.getProviders) return e;
|
|
7
|
+
let n = new Set(e.getProviders.items.map((e) => e.id)), r = t.getProviders.items.filter((e) => !n.has(e.id));
|
|
8
|
+
return {
|
|
9
|
+
...e,
|
|
10
|
+
getProviders: {
|
|
11
|
+
...t.getProviders,
|
|
12
|
+
items: [...e.getProviders.items, ...r],
|
|
13
|
+
hasMore: r.length > 0 && t.getProviders.hasMore
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function v(e) {
|
|
18
|
+
let { workspaceId: t } = d(), n = JSON.stringify(e ?? {}), r = m(() => n === "{}" ? void 0 : JSON.parse(n), [n]), { data: i, loading: o, error: s, refetch: c, fetchMore: l } = a({
|
|
8
19
|
variables: {
|
|
9
|
-
filter:
|
|
10
|
-
pagination: {
|
|
20
|
+
filter: r,
|
|
21
|
+
pagination: {
|
|
22
|
+
limit: 100,
|
|
23
|
+
offset: 0
|
|
24
|
+
}
|
|
11
25
|
},
|
|
12
26
|
skip: !t,
|
|
13
27
|
errorPolicy: "all"
|
|
14
|
-
}),
|
|
28
|
+
}), [v, y] = g(null), b = h(null), [x, S] = g(0), C = h(!0);
|
|
29
|
+
p(() => (C.current = !0, () => {
|
|
30
|
+
C.current = !1;
|
|
31
|
+
}), []);
|
|
32
|
+
let w = i?.getProviders?.items?.length ?? 0, T = i?.getProviders?.hasMore === !0 && w > 0;
|
|
33
|
+
p(() => {
|
|
34
|
+
if (o || !T || v || b.current !== null) return;
|
|
35
|
+
let e = w;
|
|
36
|
+
b.current = e;
|
|
37
|
+
let t = (e) => {
|
|
38
|
+
C.current && y(e instanceof Error ? e : Error(String(e)));
|
|
39
|
+
};
|
|
40
|
+
l({
|
|
41
|
+
variables: {
|
|
42
|
+
filter: r,
|
|
43
|
+
pagination: {
|
|
44
|
+
limit: 100,
|
|
45
|
+
offset: e
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
updateQuery: (e, { fetchMoreResult: t }) => _(e, t)
|
|
49
|
+
}).then((e) => {
|
|
50
|
+
(e.error || !e.data?.getProviders) && t(e.error ?? /* @__PURE__ */ Error("A providers page came back empty"));
|
|
51
|
+
}).catch(t).finally(() => {
|
|
52
|
+
b.current === e && (b.current = null), C.current && S((e) => e + 1);
|
|
53
|
+
});
|
|
54
|
+
}, [
|
|
55
|
+
o,
|
|
56
|
+
T,
|
|
57
|
+
w,
|
|
58
|
+
l,
|
|
59
|
+
r,
|
|
60
|
+
v,
|
|
61
|
+
x
|
|
62
|
+
]);
|
|
63
|
+
let E = f(() => (b.current = null, y(null), c()), [c]), D = m(() => (i?.getProviders?.items ?? []).map((e) => u(e)), [i]), O = T && !v;
|
|
15
64
|
return {
|
|
16
|
-
providers:
|
|
17
|
-
total:
|
|
18
|
-
loading:
|
|
19
|
-
error:
|
|
20
|
-
refetch:
|
|
65
|
+
providers: D,
|
|
66
|
+
total: i?.getProviders?.total ?? D.length,
|
|
67
|
+
loading: o || O,
|
|
68
|
+
error: s ?? v ?? void 0,
|
|
69
|
+
refetch: E
|
|
21
70
|
};
|
|
22
71
|
}
|
|
23
|
-
function
|
|
72
|
+
function y(e) {
|
|
24
73
|
let { workspaceId: t } = d(), { data: n, loading: r, error: a, refetch: o } = i({
|
|
25
74
|
variables: { id: e },
|
|
26
75
|
skip: !t || !e,
|
|
@@ -33,7 +82,7 @@ function h(e) {
|
|
|
33
82
|
refetch: o
|
|
34
83
|
};
|
|
35
84
|
}
|
|
36
|
-
function
|
|
85
|
+
function b(e) {
|
|
37
86
|
let { workspaceId: t } = d(), { data: n, loading: i, error: a, refetch: o } = r({
|
|
38
87
|
variables: { key: e },
|
|
39
88
|
skip: !t || !e,
|
|
@@ -46,7 +95,7 @@ function g(e) {
|
|
|
46
95
|
refetch: o
|
|
47
96
|
};
|
|
48
97
|
}
|
|
49
|
-
function
|
|
98
|
+
function x() {
|
|
50
99
|
let [e, { loading: t }] = o({ refetchQueries: [
|
|
51
100
|
"GetProviders",
|
|
52
101
|
"GetProvider",
|
|
@@ -57,7 +106,7 @@ function _() {
|
|
|
57
106
|
loading: t
|
|
58
107
|
};
|
|
59
108
|
}
|
|
60
|
-
function
|
|
109
|
+
function S() {
|
|
61
110
|
let [e, { loading: t }] = c({ refetchQueries: [
|
|
62
111
|
"GetProviders",
|
|
63
112
|
"GetProvider",
|
|
@@ -71,7 +120,7 @@ function v() {
|
|
|
71
120
|
loading: t
|
|
72
121
|
};
|
|
73
122
|
}
|
|
74
|
-
function
|
|
123
|
+
function C() {
|
|
75
124
|
let [e, { loading: t }] = s({ refetchQueries: [
|
|
76
125
|
"GetProviders",
|
|
77
126
|
"GetProvider",
|
|
@@ -82,21 +131,21 @@ function y() {
|
|
|
82
131
|
loading: t
|
|
83
132
|
};
|
|
84
133
|
}
|
|
85
|
-
function
|
|
134
|
+
function w() {
|
|
86
135
|
let [e, { loading: t }] = n({ refetchQueries: ["GetProviders", "GetProvider"] });
|
|
87
136
|
return {
|
|
88
137
|
enableProvider: f(async (t) => (await e({ variables: { id: t } })).data?.enableProvider, [e]),
|
|
89
138
|
loading: t
|
|
90
139
|
};
|
|
91
140
|
}
|
|
92
|
-
function
|
|
141
|
+
function T() {
|
|
93
142
|
let [e, { loading: n }] = t({ refetchQueries: ["GetProviders", "GetProvider"] });
|
|
94
143
|
return {
|
|
95
144
|
disableProvider: f(async (t) => (await e({ variables: { id: t } })).data?.disableProvider, [e]),
|
|
96
145
|
loading: n
|
|
97
146
|
};
|
|
98
147
|
}
|
|
99
|
-
function
|
|
148
|
+
function E() {
|
|
100
149
|
let [e, { loading: t }] = l({ refetchQueries: ["GetProvider", "GetProviders"] });
|
|
101
150
|
return {
|
|
102
151
|
upsertAuthMethod: f(async (t, n) => (await e({ variables: {
|
|
@@ -106,7 +155,7 @@ function S() {
|
|
|
106
155
|
loading: t
|
|
107
156
|
};
|
|
108
157
|
}
|
|
109
|
-
function
|
|
158
|
+
function D() {
|
|
110
159
|
let [t, { loading: n }] = e({ refetchQueries: ["GetProvider", "GetProviders"] });
|
|
111
160
|
return {
|
|
112
161
|
deleteAuthMethod: f(async (e, n) => (await t({ variables: {
|
|
@@ -116,6 +165,6 @@ function C() {
|
|
|
116
165
|
loading: n
|
|
117
166
|
};
|
|
118
167
|
}
|
|
119
|
-
export {
|
|
168
|
+
export { _ as mergeProviderPages, D as useDeleteAuthMethod, T as useDisableProvider, w as useEnableProvider, x as useInstallPlugin, y as useProvider, b as useProviderByKey, v as useProviders, C as useUninstallPlugin, S as useUpdatePlugin, E as useUpsertAuthMethod };
|
|
120
169
|
|
|
121
170
|
//# sourceMappingURL=useProviders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProviders.js","names":["useProviders","useIntegrations","useGetProvidersQuery","workspaceId","providers","useMemo","data","mapProvider","item","useProvider","useGetProviderQuery","id","useProviderByKey","useGetProviderByKeyQuery","key","useInstallPlugin","mutate","useInstallProviderPluginMutation","useCallback","useUpdatePlugin","useUpdateProviderPluginMutation","useUninstallPlugin","useUninstallProviderPluginMutation","useEnableProvider","useEnableProviderMutation","useDisableProvider","useDisableProviderMutation","useUpsertAuthMethod","useUpsertProviderAuthMethodMutation","useDeleteAuthMethod","useDeleteProviderAuthMethodMutation"],"sources":["../../../src/integrations/hooks/useProviders.ts"],"sourcesContent":["/**\n * Custom hooks wrapping GraphQL queries and mutations for providers.\n *\n * These hooks provide a stable API surface regardless of whether the\n * generated operations exist yet. Until codegen runs, they return\n * empty/loading state so the UI can render without errors.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n useGetProvidersQuery,\n useGetProviderQuery,\n useGetProviderByKeyQuery,\n useInstallProviderPluginMutation,\n useUpdateProviderPluginMutation,\n useUninstallProviderPluginMutation,\n useEnableProviderMutation,\n useDisableProviderMutation,\n useUpsertProviderAuthMethodMutation,\n useDeleteProviderAuthMethodMutation,\n} from '../../generated/wspace-operations';\nimport { mapProvider } from '../utils/mappers';\nimport { useIntegrations } from '../providers/IntegrationsProvider';\nimport type { IntegrationProvider, ProviderCategory, PluginStatus } from '../types';\n\n// ─── Hooks ──────────────────────────────────────────────────────────────────\n\ninterface ProviderFilterOptions {\n category?: ProviderCategory;\n pluginStatus?: PluginStatus;\n search?: string;\n}\n\nexport function useProviders(filter?: ProviderFilterOptions) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetProvidersQuery({\n variables: { filter, pagination: { limit: 100 } },\n skip: !workspaceId,\n errorPolicy: 'all',\n });\n\n // Memoized so the array reference is stable across renders (avoids re-running\n // downstream memos/effects keyed on `providers`).\n const providers = useMemo<IntegrationProvider[]>(() => {\n const all: IntegrationProvider[] = (data?.getProviders?.items ?? []).map(\n (item: Record<string, unknown>) => mapProvider(item)\n );\n // No frontend allowlist: visibility is `isEnabled` on the provider row, which\n // the admin console owns. See the note where VISIBLE_PROVIDER_KEYS used to be.\n return all;\n }, [data]);\n\n // NOTE: `total` is the returned count, not the server total. Safe today (no\n // consumer paginates on it; the query is capped at limit:100 and `hasMore` is\n // unused). Revisit if real pagination is added against this hook.\n return { providers, total: providers.length, loading, error, refetch };\n}\n\nexport function useProvider(id: string) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetProviderQuery({\n variables: { id },\n skip: !workspaceId || !id,\n errorPolicy: 'all',\n });\n\n const provider: IntegrationProvider | null = data?.getProvider\n ? mapProvider(data.getProvider as Record<string, unknown>)\n : null;\n\n return { provider, loading, error, refetch };\n}\n\nexport function useProviderByKey(key: string) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetProviderByKeyQuery({\n variables: { key },\n skip: !workspaceId || !key,\n errorPolicy: 'all',\n });\n\n const provider: IntegrationProvider | null = data?.getProviderByKey\n ? mapProvider(data.getProviderByKey as Record<string, unknown>)\n : null;\n\n return { provider, loading, error, refetch };\n}\n\nexport function useInstallPlugin() {\n const [mutate, { loading }] = useInstallProviderPluginMutation({\n refetchQueries: ['GetProviders', 'GetProvider', 'GetProviderCatalog'],\n });\n\n const installPlugin = useCallback(\n async (input: {\n key: string;\n name: string;\n description?: string;\n category: string;\n authType: string;\n icon?: string;\n color?: string;\n website?: string;\n docsUrl?: string;\n oauthConfig?: Record<string, unknown>;\n defaultScopes?: string[];\n availableScopes?: Record<string, unknown>;\n baseUrl?: string;\n apiVersion?: string;\n rateLimitConfig?: Record<string, unknown>;\n pluginVersion?: string;\n pluginAuthor?: string;\n pluginRepository?: string;\n displayOrder?: number;\n supportedFeatures?: string[];\n configSchema?: Record<string, unknown>;\n }) => {\n const result = await mutate({ variables: { input } });\n return result.data?.installProviderPlugin;\n },\n [mutate]\n );\n\n return { installPlugin, loading };\n}\n\nexport function useUpdatePlugin() {\n const [mutate, { loading }] = useUpdateProviderPluginMutation({\n refetchQueries: ['GetProviders', 'GetProvider', 'GetProviderCatalog'],\n });\n\n const updatePlugin = useCallback(\n async (\n id: string,\n input: {\n name?: string;\n description?: string;\n icon?: string;\n color?: string;\n website?: string;\n docsUrl?: string;\n oauthConfig?: Record<string, unknown>;\n defaultScopes?: string[];\n availableScopes?: Record<string, unknown>;\n baseUrl?: string;\n apiVersion?: string;\n rateLimitConfig?: Record<string, unknown>;\n pluginVersion?: string;\n pluginAuthor?: string;\n pluginRepository?: string;\n displayOrder?: number;\n supportedFeatures?: string[];\n configSchema?: Record<string, unknown>;\n isEnabled?: boolean;\n }\n ) => {\n const result = await mutate({ variables: { id, input } });\n return result.data?.updateProviderPlugin;\n },\n [mutate]\n );\n\n return { updatePlugin, loading };\n}\n\nexport function useUninstallPlugin() {\n const [mutate, { loading }] = useUninstallProviderPluginMutation({\n refetchQueries: ['GetProviders', 'GetProvider', 'GetProviderCatalog'],\n });\n\n const uninstallPlugin = useCallback(\n async (id: string) => {\n const result = await mutate({ variables: { id } });\n return result.data?.uninstallProviderPlugin as boolean;\n },\n [mutate]\n );\n\n return { uninstallPlugin, loading };\n}\n\nexport function useEnableProvider() {\n const [mutate, { loading }] = useEnableProviderMutation({\n refetchQueries: ['GetProviders', 'GetProvider'],\n });\n\n const enableProvider = useCallback(\n async (id: string) => {\n const result = await mutate({ variables: { id } });\n return result.data?.enableProvider;\n },\n [mutate]\n );\n\n return { enableProvider, loading };\n}\n\nexport function useDisableProvider() {\n const [mutate, { loading }] = useDisableProviderMutation({\n refetchQueries: ['GetProviders', 'GetProvider'],\n });\n\n const disableProvider = useCallback(\n async (id: string) => {\n const result = await mutate({ variables: { id } });\n return result.data?.disableProvider;\n },\n [mutate]\n );\n\n return { disableProvider, loading };\n}\n\n/**\n * Create or update one of a provider's authentication methods.\n *\n * This is what makes multi-auth an admin action rather than a code change: the\n * method's display name, type and field schema are all data, so offering a new\n * way to authenticate against an existing provider needs no deploy.\n */\nexport function useUpsertAuthMethod() {\n const [mutate, { loading }] = useUpsertProviderAuthMethodMutation({\n refetchQueries: ['GetProvider', 'GetProviders'],\n });\n\n const upsertAuthMethod = useCallback(\n async (\n providerId: string,\n input: {\n key: string;\n displayName: string;\n description?: string;\n authType: string;\n flow?: string;\n configSchema?: Record<string, unknown> | null;\n oauthConfig?: Record<string, unknown> | null;\n defaultScopes?: string[];\n isDefault?: boolean;\n isEnabled?: boolean;\n displayOrder?: number;\n }\n ) => {\n const result = await mutate({ variables: { providerId, input } });\n return result.data?.upsertProviderAuthMethod;\n },\n [mutate]\n );\n\n return { upsertAuthMethod, loading };\n}\n\nexport function useDeleteAuthMethod() {\n const [mutate, { loading }] = useDeleteProviderAuthMethodMutation({\n refetchQueries: ['GetProvider', 'GetProviders'],\n });\n\n const deleteAuthMethod = useCallback(\n async (providerId: string, key: string) => {\n const result = await mutate({ variables: { providerId, key } });\n return result.data?.deleteProviderAuthMethod;\n },\n [mutate]\n );\n\n return { deleteAuthMethod, loading };\n}\n"],"mappings":";;;;;AAiCA,SAAgBA,EAAa,GAAgC;CAC3D,IAAM,EAAE,mBAAgBC,EAAgB,GAClC,EAAE,SAAM,YAAS,UAAO,eAAYC,EAAqB;EAC7D,WAAW;GAAE;GAAQ,YAAY,EAAE,OAAO,IAAI;EAAE;EAChD,MAAM,CAACC;EACP,aAAa;CACf,CAAC,GAIKC,IAAYC,SACoBC,GAAM,cAAc,SAAS,CAAC,EAAA,CAAG,KAClE,MAAkCC,EAAYC,CAAI,CAI9C,GACN,CAACF,CAAI,CAAC;CAKT,OAAO;EAAE;EAAW,OAAOF,EAAU;EAAQ;EAAS;EAAO;CAAQ;AACvE;AAEA,SAAgBK,EAAY,GAAY;CACtC,IAAM,EAAE,mBAAgBR,EAAgB,GAClC,EAAE,SAAM,YAAS,UAAO,eAAYS,EAAoB;EAC5D,WAAW,EAAE,MAAG;EAChB,MAAM,CAACP,KAAe,CAACQ;EACvB,aAAa;CACf,CAAC;CAMD,OAAO;EAAE,UAJoCL,GAAM,cAC/CC,EAAYD,EAAK,WAAsC,IACvD;EAEe;EAAS;EAAO;CAAQ;AAC7C;AAEA,SAAgBM,EAAiB,GAAa;CAC5C,IAAM,EAAE,mBAAgBX,EAAgB,GAClC,EAAE,SAAM,YAAS,UAAO,eAAYY,EAAyB;EACjE,WAAW,EAAE,OAAI;EACjB,MAAM,CAACV,KAAe,CAACW;EACvB,aAAa;CACf,C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nC;AAEA,SAAgBS,IAAqB;CACnC,IAAM,CAACT,GAAQ,EAAE,gBAAaU,EAA2B,EACvD,gBAAgB,CAAC,gBAAgB,aAAa,EAChD,CAAC;CAUD,OAAO;EAAE,iBAReR,EACtB,OAAO,OAEE,MADcF,EAAO,EAAE,WAAW,EAAE,MAAG,EAAE,CAAC,EAAA,CACnC,MAAM,iBAEtB,CAACA,CAAM,CAGA;EAAiB;CAAQ;AACpC;AASA,SAAgBW,IAAsB;CACpC,IAAM,CAACX,GAAQ,EAAE,gBAAaY,EAAoC,EAChE,gBAAgB,CAAC,eAAe,cAAc,EAChD,CAAC;CAyBD,OAAO;EAAE,kBAvBgBV,EACvB,OACE,GACA,OAeO,MADcF,EAAO,EAAE,WAAW;GAAE;GAAY;EAAM,EAAE,CAAC,EAAA,CAClD,MAAM,0BAEtB,CAACA,CAAM,CAGA;EAAkB;CAAQ;AACrC;AAEA,SAAgBa,IAAsB;CACpC,IAAM,CAACb,GAAQ,EAAE,gBAAac,EAAoC,EAChE,gBAAgB,CAAC,eAAe,cAAc,EAChD,CAAC;CAUD,OAAO;EAAE,kBARgBZ,EACvB,OAAO,GAAoB,OAElB,MADcF,EAAO,EAAE,WAAW;GAAE;GAAY;EAAI,EAAE,CAAC,EAAA,CAChD,MAAM,0BAEtB,CAACA,CAAM,CAGA;EAAkB;CAAQ;AACrC"}
|
|
1
|
+
{"version":3,"file":"useProviders.js","names":["mergeProviderPages","next","previous","seen","item","added","useProviders","useIntegrations","filterKey","filter","stableFilter","useMemo","useGetProvidersQuery","workspaceId","pagingError","setPagingError","useState","inFlightOffset","useRef","settledPages","setSettledPages","mounted","loadedCount","data","hasMore","loading","offset","fail","err","fetchMoreResult","result","n","fetchMore","refetchAll","useCallback","refetch","providers","mapProvider","stillPaging","error","useProvider","useGetProviderQuery","id","useProviderByKey","useGetProviderByKeyQuery","key","useInstallPlugin","mutate","useInstallProviderPluginMutation","useUpdatePlugin","useUpdateProviderPluginMutation","useUninstallPlugin","useUninstallProviderPluginMutation","useEnableProvider","useEnableProviderMutation","useDisableProvider","useDisableProviderMutation","useUpsertAuthMethod","useUpsertProviderAuthMethodMutation","useDeleteAuthMethod","useDeleteProviderAuthMethodMutation"],"sources":["../../../src/integrations/hooks/useProviders.ts"],"sourcesContent":["/**\n * Custom hooks wrapping GraphQL queries and mutations for providers.\n *\n * These hooks provide a stable API surface regardless of whether the\n * generated operations exist yet. Until codegen runs, they return\n * empty/loading state so the UI can render without errors.\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n useGetProvidersQuery,\n useGetProviderQuery,\n useGetProviderByKeyQuery,\n useInstallProviderPluginMutation,\n useUpdateProviderPluginMutation,\n useUninstallProviderPluginMutation,\n useEnableProviderMutation,\n useDisableProviderMutation,\n useUpsertProviderAuthMethodMutation,\n useDeleteProviderAuthMethodMutation,\n} from '../../generated/wspace-operations';\nimport { mapProvider } from '../utils/mappers';\nimport { useIntegrations } from '../providers/IntegrationsProvider';\nimport type { IntegrationProvider, ProviderCategory, PluginStatus } from '../types';\n\n// ─── Hooks ──────────────────────────────────────────────────────────────────\n\ninterface ProviderFilterOptions {\n category?: ProviderCategory;\n pluginStatus?: PluginStatus;\n search?: string;\n}\n\n/** The service caps one getProviders page at 100 rows. */\nexport const PROVIDER_PAGE_SIZE = 100;\n\ntype ProvidersPage = {\n getProviders: { items: ReadonlyArray<{ id: string }>; total: number; hasMore: boolean };\n};\n\n/**\n * Appends a fetched page to the providers loaded so far. Rows already present\n * (by id) are skipped so a catalog that shifts between pages never shows a\n * provider twice, and a page that adds nothing ends paging so a stale\n * `hasMore` cannot loop.\n */\nexport function mergeProviderPages<T extends ProvidersPage>(previous: T, next: T | undefined): T {\n if (!next?.getProviders) return previous;\n const seen = new Set(previous.getProviders.items.map((item) => item.id));\n const added = next.getProviders.items.filter((item) => !seen.has(item.id));\n return {\n ...previous,\n getProviders: {\n ...next.getProviders,\n items: [...previous.getProviders.items, ...added],\n hasMore: added.length > 0 && next.getProviders.hasMore,\n },\n };\n}\n\n/**\n * Loads every provider the filter matches. The catalog has grown past one\n * page (BOFF-11224: providers seeded after the first 100 by display order,\n * such as ClickSend, never reached the catalog or the add-connection wizard,\n * whose search runs on the loaded rows), so the hook keeps fetching pages\n * until the service reports no more.\n */\nexport function useProviders(filter?: ProviderFilterOptions) {\n const { workspaceId } = useIntegrations();\n // Callers may pass a fresh object each render; key paging on its content.\n // The cast is safe: filterKey was serialised from a ProviderFilterOptions.\n const filterKey = JSON.stringify(filter ?? {});\n const stableFilter = useMemo<ProviderFilterOptions | undefined>(\n () => (filterKey === '{}' ? undefined : (JSON.parse(filterKey) as ProviderFilterOptions)),\n [filterKey]\n );\n const { data, loading, error, refetch, fetchMore } = useGetProvidersQuery({\n variables: { filter: stableFilter, pagination: { limit: PROVIDER_PAGE_SIZE, offset: 0 } },\n skip: !workspaceId,\n errorPolicy: 'all',\n });\n const [pagingError, setPagingError] = useState<Error | null>(null);\n // The offset of the page being fetched. fetchMore flips `loading`, which\n // re-runs the effect below; this ref, not the effect's lifetime, decides\n // whether a page is already on its way, so one page is never asked twice\n // and a failure is always recorded.\n const inFlightOffset = useRef<number | null>(null);\n // Bumped when a page settles, so the effect runs again even if the merged\n // result rendered before the request's promise chain finished.\n const [settledPages, setSettledPages] = useState(0);\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n const loadedCount = data?.getProviders?.items?.length ?? 0;\n const hasMore = data?.getProviders?.hasMore === true && loadedCount > 0;\n\n useEffect(() => {\n if (loading || !hasMore || pagingError || inFlightOffset.current !== null) return;\n const offset = loadedCount;\n inFlightOffset.current = offset;\n const fail = (err: unknown) => {\n if (mounted.current) setPagingError(err instanceof Error ? err : new Error(String(err)));\n };\n fetchMore({\n variables: { filter: stableFilter, pagination: { limit: PROVIDER_PAGE_SIZE, offset } },\n // The generated query type is structurally a ProvidersPage with more\n // fields; the merge only reads ids and spreads the rest through, so the\n // casts in and back out are lossless.\n updateQuery: (previous, { fetchMoreResult }) =>\n mergeProviderPages(\n previous as ProvidersPage,\n fetchMoreResult as ProvidersPage | undefined\n ) as typeof previous,\n })\n .then((result) => {\n // errorPolicy 'all' resolves a failed page instead of rejecting. Stop\n // paging until an explicit refetch rather than asking for it again.\n if (result.error || !result.data?.getProviders) {\n fail(result.error ?? new Error('A providers page came back empty'));\n }\n })\n .catch(fail)\n .finally(() => {\n if (inFlightOffset.current === offset) inFlightOffset.current = null;\n if (mounted.current) setSettledPages((n) => n + 1);\n });\n }, [loading, hasMore, loadedCount, fetchMore, stableFilter, pagingError, settledPages]);\n\n const refetchAll = useCallback(() => {\n inFlightOffset.current = null;\n setPagingError(null);\n return refetch();\n }, [refetch]);\n\n // Memoized so the array reference is stable across renders (avoids re-running\n // downstream memos/effects keyed on `providers`).\n const providers = useMemo<IntegrationProvider[]>(() => {\n const all: IntegrationProvider[] = (data?.getProviders?.items ?? []).map(\n (item: Record<string, unknown>) => mapProvider(item)\n );\n // No frontend allowlist: visibility is `isEnabled` on the provider row, which\n // the admin console owns. See the note where VISIBLE_PROVIDER_KEYS used to be.\n return all;\n }, [data]);\n\n // Report loading until every page is in, so client-side search and the\n // empty state never judge a partial catalog. A failed later page keeps the\n // rows already loaded and surfaces the error.\n const stillPaging = hasMore && !pagingError;\n return {\n providers,\n total: data?.getProviders?.total ?? providers.length,\n loading: loading || stillPaging,\n error: error ?? pagingError ?? undefined,\n refetch: refetchAll,\n };\n}\n\nexport function useProvider(id: string) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetProviderQuery({\n variables: { id },\n skip: !workspaceId || !id,\n errorPolicy: 'all',\n });\n\n const provider: IntegrationProvider | null = data?.getProvider\n ? mapProvider(data.getProvider as Record<string, unknown>)\n : null;\n\n return { provider, loading, error, refetch };\n}\n\nexport function useProviderByKey(key: string) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetProviderByKeyQuery({\n variables: { key },\n skip: !workspaceId || !key,\n errorPolicy: 'all',\n });\n\n const provider: IntegrationProvider | null = data?.getProviderByKey\n ? mapProvider(data.getProviderByKey as Record<string, unknown>)\n : null;\n\n return { provider, loading, error, refetch };\n}\n\nexport function useInstallPlugin() {\n const [mutate, { loading }] = useInstallProviderPluginMutation({\n refetchQueries: ['GetProviders', 'GetProvider', 'GetProviderCatalog'],\n });\n\n const installPlugin = useCallback(\n async (input: {\n key: string;\n name: string;\n description?: string;\n category: string;\n authType: string;\n icon?: string;\n color?: string;\n website?: string;\n docsUrl?: string;\n oauthConfig?: Record<string, unknown>;\n defaultScopes?: string[];\n availableScopes?: Record<string, unknown>;\n baseUrl?: string;\n apiVersion?: string;\n rateLimitConfig?: Record<string, unknown>;\n pluginVersion?: string;\n pluginAuthor?: string;\n pluginRepository?: string;\n displayOrder?: number;\n supportedFeatures?: string[];\n configSchema?: Record<string, unknown>;\n }) => {\n const result = await mutate({ variables: { input } });\n return result.data?.installProviderPlugin;\n },\n [mutate]\n );\n\n return { installPlugin, loading };\n}\n\nexport function useUpdatePlugin() {\n const [mutate, { loading }] = useUpdateProviderPluginMutation({\n refetchQueries: ['GetProviders', 'GetProvider', 'GetProviderCatalog'],\n });\n\n const updatePlugin = useCallback(\n async (\n id: string,\n input: {\n name?: string;\n description?: string;\n icon?: string;\n color?: string;\n website?: string;\n docsUrl?: string;\n oauthConfig?: Record<string, unknown>;\n defaultScopes?: string[];\n availableScopes?: Record<string, unknown>;\n baseUrl?: string;\n apiVersion?: string;\n rateLimitConfig?: Record<string, unknown>;\n pluginVersion?: string;\n pluginAuthor?: string;\n pluginRepository?: string;\n displayOrder?: number;\n supportedFeatures?: string[];\n configSchema?: Record<string, unknown>;\n isEnabled?: boolean;\n }\n ) => {\n const result = await mutate({ variables: { id, input } });\n return result.data?.updateProviderPlugin;\n },\n [mutate]\n );\n\n return { updatePlugin, loading };\n}\n\nexport function useUninstallPlugin() {\n const [mutate, { loading }] = useUninstallProviderPluginMutation({\n refetchQueries: ['GetProviders', 'GetProvider', 'GetProviderCatalog'],\n });\n\n const uninstallPlugin = useCallback(\n async (id: string) => {\n const result = await mutate({ variables: { id } });\n return result.data?.uninstallProviderPlugin as boolean;\n },\n [mutate]\n );\n\n return { uninstallPlugin, loading };\n}\n\nexport function useEnableProvider() {\n const [mutate, { loading }] = useEnableProviderMutation({\n refetchQueries: ['GetProviders', 'GetProvider'],\n });\n\n const enableProvider = useCallback(\n async (id: string) => {\n const result = await mutate({ variables: { id } });\n return result.data?.enableProvider;\n },\n [mutate]\n );\n\n return { enableProvider, loading };\n}\n\nexport function useDisableProvider() {\n const [mutate, { loading }] = useDisableProviderMutation({\n refetchQueries: ['GetProviders', 'GetProvider'],\n });\n\n const disableProvider = useCallback(\n async (id: string) => {\n const result = await mutate({ variables: { id } });\n return result.data?.disableProvider;\n },\n [mutate]\n );\n\n return { disableProvider, loading };\n}\n\n/**\n * Create or update one of a provider's authentication methods.\n *\n * This is what makes multi-auth an admin action rather than a code change: the\n * method's display name, type and field schema are all data, so offering a new\n * way to authenticate against an existing provider needs no deploy.\n */\nexport function useUpsertAuthMethod() {\n const [mutate, { loading }] = useUpsertProviderAuthMethodMutation({\n refetchQueries: ['GetProvider', 'GetProviders'],\n });\n\n const upsertAuthMethod = useCallback(\n async (\n providerId: string,\n input: {\n key: string;\n displayName: string;\n description?: string;\n authType: string;\n flow?: string;\n configSchema?: Record<string, unknown> | null;\n oauthConfig?: Record<string, unknown> | null;\n defaultScopes?: string[];\n isDefault?: boolean;\n isEnabled?: boolean;\n displayOrder?: number;\n }\n ) => {\n const result = await mutate({ variables: { providerId, input } });\n return result.data?.upsertProviderAuthMethod;\n },\n [mutate]\n );\n\n return { upsertAuthMethod, loading };\n}\n\nexport function useDeleteAuthMethod() {\n const [mutate, { loading }] = useDeleteProviderAuthMethodMutation({\n refetchQueries: ['GetProvider', 'GetProviders'],\n });\n\n const deleteAuthMethod = useCallback(\n async (providerId: string, key: string) => {\n const result = await mutate({ variables: { providerId, key } });\n return result.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SAAgBM,IAAoB;CAClC,IAAM,CAACN,GAAQ,EAAE,gBAAaO,EAA0B,EACtD,gBAAgB,CAAC,gBAAgB,aAAa,EAChD,CAAC;CAUD,OAAO;EAAE,gBARcpB,EACrB,OAAO,OAEE,MADca,EAAO,EAAE,WAAW,EAAE,MAAG,EAAE,CAAC,EAAA,CACnC,MAAM,gBAEtB,CAACA,CAAM,CAGA;EAAgB;CAAQ;AACnC;AAEA,SAAgBQ,IAAqB;CACnC,IAAM,CAACR,GAAQ,EAAE,gBAAaS,EAA2B,EACvD,gBAAgB,CAAC,gBAAgB,aAAa,EAChD,CAAC;CAUD,OAAO;EAAE,iBARetB,EACtB,OAAO,OAEE,MADca,EAAO,EAAE,WAAW,EAAE,MAAG,EAAE,CAAC,EAAA,CACnC,MAAM,iBAEtB,CAACA,CAAM,CAGA;EAAiB;CAAQ;AACpC;AASA,SAAgBU,IAAsB;CACpC,IAAM,CAACV,GAAQ,EAAE,gBAAaW,EAAoC,EAChE,gBAAgB,CAAC,eAAe,cAAc,EAChD,CAAC;CAyBD,OAAO;EAAE,kBAvBgBxB,EACvB,OACE,GACA,OAeO,MADca,EAAO,EAAE,WAAW;GAAE;GAAY;EAAM,EAAE,CAAC,EAAA,CAClD,MAAM,0BAEtB,CAACA,CAAM,CAGA;EAAkB;CAAQ;AACrC;AAEA,SAAgBY,IAAsB;CACpC,IAAM,CAACZ,GAAQ,EAAE,gBAAaa,EAAoC,EAChE,gBAAgB,CAAC,eAAe,cAAc,EAChD,CAAC;CAUD,OAAO;EAAE,kBARgB1B,EACvB,OAAO,GAAoB,OAElB,MADca,EAAO,EAAE,WAAW;GAAE;GAAY;EAAI,EAAE,CAAC,EAAA,CAChD,MAAM,0BAEtB,CAACA,CAAM,CAGA;EAAkB;CAAQ;AACrC"}
|
|
@@ -20,15 +20,16 @@ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
|
20
20
|
import { useFeatureFlag as we } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
21
21
|
import { ProviderIcon as Te, canManageSharing as Ee } from "@burdenoff/fe-libs/connections";
|
|
22
22
|
import { AlertDialog as De, AlertDialogAction as Oe, AlertDialogCancel as ke, AlertDialogContent as Ae, AlertDialogDescription as je, AlertDialogFooter as Me, AlertDialogHeader as v, AlertDialogTitle as y, Button as b, CTAOverflowMenu as x, EmphasisPanel as Ne, GlassCard as S, NextSteps as Pe, PagePurpose as Fe, ShowMore as C } from "@burdenoff/fe-libs/ui";
|
|
23
|
+
import { suggestAnchorProps as Ie } from "@burdenoff/fe-libs/shared/proactive";
|
|
23
24
|
// src/integrations/pages/ConnectionDetail.tsx
|
|
24
25
|
function w() {
|
|
25
|
-
let { connectionId: w } = Se(), { basePath: T = "/", navigate: E } = re(), D = t(),
|
|
26
|
+
let { connectionId: w } = Se(), { basePath: T = "/", navigate: E } = re(), D = t(), Le = ee(), Re = te(), O = ne(), { connection: k, loading: ze, error: A, refetch: j } = ae(w ?? ""), { testConnection: Be, loading: M } = le(), { refreshToken: Ve, loading: He } = se(), { revokeConnection: Ue, loading: N } = ce(), { deleteConnection: We, loading: P } = oe(), F = we(ie.OAUTH_REFRESH, !0), { hasPermission: I, isLoading: Ge } = Ce(), L = I(n.CONNECTION_UPDATE), R = I(n.CONNECTION_DELETE), Ke = I(n.CONNECTION_SHARE), [qe, z] = a(!1), [B, Je] = a(null), [V, H] = a(null), [Ye, U] = a(!1), [W, G] = a(!1), [Xe, K] = a(!1), q = (e, t) => {
|
|
26
27
|
H({
|
|
27
28
|
type: e,
|
|
28
29
|
message: t
|
|
29
30
|
}), setTimeout(() => H(null), 5e3);
|
|
30
31
|
};
|
|
31
|
-
if (
|
|
32
|
+
if (ze || Ge) return /* @__PURE__ */ _("div", {
|
|
32
33
|
className: "flex flex-col items-center justify-center py-20",
|
|
33
34
|
children: [/* @__PURE__ */ g(u, {
|
|
34
35
|
size: 48,
|
|
@@ -83,15 +84,15 @@ function w() {
|
|
|
83
84
|
})
|
|
84
85
|
});
|
|
85
86
|
let J = async () => {
|
|
86
|
-
let e = await
|
|
87
|
-
e && (
|
|
87
|
+
let e = await Be(k.id);
|
|
88
|
+
e && (Je(e), q(e.success ? "success" : "error", e.message));
|
|
88
89
|
}, Y = async () => {
|
|
89
|
-
await
|
|
90
|
-
}, Xe = async () => {
|
|
91
|
-
K(!0);
|
|
90
|
+
await Ve(k.id), q("success", D("integrations.connectionDetail.notifications.refreshSuccess", "Token refreshed successfully")), j();
|
|
92
91
|
}, Ze = async () => {
|
|
93
|
-
|
|
92
|
+
K(!0);
|
|
94
93
|
}, Qe = async () => {
|
|
94
|
+
await Ue(k.id), q("success", D("integrations.connectionDetail.notifications.revokeSuccess", "Connection revoked")), K(!1), j();
|
|
95
|
+
}, $e = async () => {
|
|
95
96
|
he("medium");
|
|
96
97
|
let e = await me({
|
|
97
98
|
title: D("integrations.connectionDetail.deleteDialog.title", "Delete Connection"),
|
|
@@ -102,11 +103,11 @@ function w() {
|
|
|
102
103
|
e === null ? U(!0) : e && await X();
|
|
103
104
|
}, X = async () => {
|
|
104
105
|
try {
|
|
105
|
-
await
|
|
106
|
+
await We(k.id, W), q("success", D("integrations.connectionDetail.notifications.deleteSuccess", "Connection deleted")), i("success"), U(!1), G(!1), E?.(r(T, "connections"));
|
|
106
107
|
} catch (e) {
|
|
107
108
|
q("error", e instanceof Error ? e.message : "Failed to delete connection"), i("error");
|
|
108
109
|
}
|
|
109
|
-
}, Z = M ||
|
|
110
|
+
}, Z = M || He || N || P, Q = Ke && Ee(k.myAccess ?? null), $ = !!(k.vaultId || k.credentialSecretId), et = [
|
|
110
111
|
{
|
|
111
112
|
id: "test",
|
|
112
113
|
label: D("integrations.connectionDetail.nextSteps.test.label", "Test the connection"),
|
|
@@ -145,7 +146,7 @@ function w() {
|
|
|
145
146
|
})]
|
|
146
147
|
}),
|
|
147
148
|
/* @__PURE__ */ g(De, {
|
|
148
|
-
open:
|
|
149
|
+
open: Ye,
|
|
149
150
|
onOpenChange: (e) => {
|
|
150
151
|
e || (U(!1), G(!1));
|
|
151
152
|
},
|
|
@@ -189,7 +190,7 @@ function w() {
|
|
|
189
190
|
})
|
|
190
191
|
}),
|
|
191
192
|
/* @__PURE__ */ g(pe, {
|
|
192
|
-
open:
|
|
193
|
+
open: Xe,
|
|
193
194
|
title: D("integrations.connectionDetail.confirm.revokeTitle", "Revoke connection"),
|
|
194
195
|
description: D("integrations.connectionDetail.confirm.revoke", "Are you sure you want to revoke this connection? This will disconnect the external service."),
|
|
195
196
|
confirmLabel: D("integrations.connectionDetail.actions.revoke", "Revoke"),
|
|
@@ -197,12 +198,12 @@ function w() {
|
|
|
197
198
|
loading: N,
|
|
198
199
|
destructive: !0,
|
|
199
200
|
icon: /* @__PURE__ */ g(f, { size: 20 }),
|
|
200
|
-
onConfirm:
|
|
201
|
+
onConfirm: Qe,
|
|
201
202
|
onCancel: () => K(!1)
|
|
202
203
|
}),
|
|
203
204
|
Q && /* @__PURE__ */ g(de, {
|
|
204
205
|
connection: k,
|
|
205
|
-
open:
|
|
206
|
+
open: qe,
|
|
206
207
|
onClose: () => z(!1),
|
|
207
208
|
onShared: () => {
|
|
208
209
|
q("success", D("integrations.connectionDetail.notifications.shareSuccess", "Sharing updated")), j();
|
|
@@ -228,6 +229,10 @@ function w() {
|
|
|
228
229
|
className: "flex-1",
|
|
229
230
|
children: [/* @__PURE__ */ _("div", {
|
|
230
231
|
className: "flex items-center gap-3",
|
|
232
|
+
...Ie({
|
|
233
|
+
entityType: "connection",
|
|
234
|
+
entityId: k.id
|
|
235
|
+
}),
|
|
231
236
|
children: [
|
|
232
237
|
/* @__PURE__ */ g("h1", {
|
|
233
238
|
className: "text-2xl sm:text-3xl font-bold text-text-primary",
|
|
@@ -244,7 +249,7 @@ function w() {
|
|
|
244
249
|
children: [
|
|
245
250
|
k.provider.name,
|
|
246
251
|
" · ",
|
|
247
|
-
|
|
252
|
+
Le(k.provider.authType)
|
|
248
253
|
]
|
|
249
254
|
})]
|
|
250
255
|
})
|
|
@@ -257,7 +262,7 @@ function w() {
|
|
|
257
262
|
}),
|
|
258
263
|
(L || R) && /* @__PURE__ */ g(Pe, {
|
|
259
264
|
storageKey: "integrations-connection-detail",
|
|
260
|
-
steps:
|
|
265
|
+
steps: et
|
|
261
266
|
}),
|
|
262
267
|
/* @__PURE__ */ _("div", {
|
|
263
268
|
className: "grid grid-cols-1 md:grid-cols-2 gap-4",
|
|
@@ -341,7 +346,7 @@ function w() {
|
|
|
341
346
|
]
|
|
342
347
|
}), /* @__PURE__ */ g("span", {
|
|
343
348
|
className: "text-sm text-text-primary",
|
|
344
|
-
children:
|
|
349
|
+
children: Re(k.lastUsedAt)
|
|
345
350
|
})]
|
|
346
351
|
}),
|
|
347
352
|
/* @__PURE__ */ _("div", {
|
|
@@ -492,14 +497,14 @@ function w() {
|
|
|
492
497
|
...R ? [{
|
|
493
498
|
label: D("integrations.connectionDetail.actions.revoke", "Revoke"),
|
|
494
499
|
onSelect: () => {
|
|
495
|
-
|
|
500
|
+
Ze();
|
|
496
501
|
},
|
|
497
502
|
disabled: Z,
|
|
498
503
|
icon: /* @__PURE__ */ g(f, { size: 14 })
|
|
499
504
|
}, {
|
|
500
505
|
label: D("integrations.connectionDetail.actions.delete", "Delete"),
|
|
501
506
|
onSelect: () => {
|
|
502
|
-
|
|
507
|
+
$e();
|
|
503
508
|
},
|
|
504
509
|
intent: "destructive",
|
|
505
510
|
disabled: Z,
|