@burdenoff/microfe-integrations 2026.1113.3 → 2026.1113.4
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/generated/global-types.d.ts +5328 -728
- package/dist/generated/wspace-operations.d.ts +39 -0
- package/dist/generated/wspace-operations.js +76 -59
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +64079 -10557
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/integrations/components/SelfHostedReleaseSetting.d.ts +14 -0
- package/dist/integrations/components/SelfHostedReleaseSetting.js +78 -0
- package/dist/integrations/components/SelfHostedReleaseSetting.js.map +1 -0
- package/dist/integrations/constants/permissions.d.ts +1 -0
- package/dist/integrations/constants/permissions.js +1 -0
- package/dist/integrations/constants/permissions.js.map +1 -1
- package/dist/integrations/hooks/useConnections.d.ts +9 -0
- package/dist/integrations/hooks/useConnections.js +63 -49
- package/dist/integrations/hooks/useConnections.js.map +1 -1
- package/dist/integrations/pages/ConnectionDetail.js +345 -334
- package/dist/integrations/pages/ConnectionDetail.js.map +1 -1
- package/dist/integrations/translations/en.d.ts +10 -0
- package/dist/integrations/types/index.d.ts +5 -0
- package/dist/integrations/utils/mappers.js +2 -1
- package/dist/integrations/utils/mappers.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { IntegrationConnection } from '../types';
|
|
3
|
+
export interface SelfHostedReleaseSettingProps {
|
|
4
|
+
connection: IntegrationConnection;
|
|
5
|
+
/** Reports the outcome of a change, for the page's notification. */
|
|
6
|
+
onResult?: (outcome: {
|
|
7
|
+
ok: true;
|
|
8
|
+
allow: boolean;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
message: string;
|
|
12
|
+
}) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const SelfHostedReleaseSetting: FC<SelfHostedReleaseSettingProps>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { INTEGRATION_PERMISSIONS as e } from "../constants/permissions.js";
|
|
2
|
+
import { useSetConnectionSelfHostedRelease as t } from "../hooks/useConnections.js";
|
|
3
|
+
import { useTr as n } from "../hooks/useTr.js";
|
|
4
|
+
import { useState as r } from "react";
|
|
5
|
+
import { Loader2 as i, Server as a } from "lucide-react";
|
|
6
|
+
import { usePermissions as o } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
import { Switch as l } from "@burdenoff/fe-libs/ui";
|
|
9
|
+
// src/integrations/components/SelfHostedReleaseSetting.tsx
|
|
10
|
+
var u = ({ connection: u, onResult: d }) => {
|
|
11
|
+
let f = n(), { hasPermission: p } = o(), m = p(e.CONNECTION_ADMINISTER), { setSelfHostedRelease: h, loading: g } = t(), [_, v] = r(null);
|
|
12
|
+
if (typeof u.allowSelfHosted != "boolean") return null;
|
|
13
|
+
let y = _ ?? u.allowSelfHosted, b = `self-hosted-release-${u.id}`, x = g || _ !== null, S = async (e) => {
|
|
14
|
+
if (_ === null) {
|
|
15
|
+
v(e);
|
|
16
|
+
try {
|
|
17
|
+
let t = await h(u.id, e);
|
|
18
|
+
d?.({
|
|
19
|
+
ok: !0,
|
|
20
|
+
allow: t
|
|
21
|
+
});
|
|
22
|
+
} catch (e) {
|
|
23
|
+
d?.({
|
|
24
|
+
ok: !1,
|
|
25
|
+
message: e instanceof Error && e.message ? e.message : f("integrations.connectionDetail.selfHosted.failed", "The self-hosted worker setting could not be saved.")
|
|
26
|
+
});
|
|
27
|
+
} finally {
|
|
28
|
+
v(null);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ c("div", {
|
|
33
|
+
className: "flex items-start justify-between gap-4 rounded-lg border border-border-seam p-4",
|
|
34
|
+
"data-testid": "connection-self-hosted-release",
|
|
35
|
+
children: [/* @__PURE__ */ c("div", {
|
|
36
|
+
className: "flex min-w-0 items-start gap-3",
|
|
37
|
+
children: [/* @__PURE__ */ s(a, {
|
|
38
|
+
size: 18,
|
|
39
|
+
className: "mt-0.5 shrink-0 text-primary",
|
|
40
|
+
"aria-hidden": "true"
|
|
41
|
+
}), /* @__PURE__ */ c("div", {
|
|
42
|
+
className: "min-w-0",
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ s("label", {
|
|
45
|
+
htmlFor: b,
|
|
46
|
+
className: "text-sm font-medium text-text-primary",
|
|
47
|
+
children: f("integrations.connectionDetail.selfHosted.title", "Self-hosted workers")
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ s("p", {
|
|
50
|
+
className: "mt-0.5 text-sm text-text-secondary",
|
|
51
|
+
children: y ? f("integrations.connectionDetail.selfHosted.on", "FluidGrids workers you run yourself may receive this connection’s key when their worker token allows it. Every release is recorded in the run’s audit log.") : f("integrations.connectionDetail.selfHosted.off", "FluidGrids workers you run yourself never receive this connection’s key. Sign-in tokens that expire within a day can still reach a worker whose token allows the connection.")
|
|
52
|
+
}),
|
|
53
|
+
!m && /* @__PURE__ */ s("p", {
|
|
54
|
+
className: "mt-1 text-xs text-text-secondary",
|
|
55
|
+
children: f("integrations.connectionDetail.selfHosted.adminOnly", "Only workspace administrators can change this.")
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
})]
|
|
59
|
+
}), /* @__PURE__ */ c("div", {
|
|
60
|
+
className: "flex shrink-0 items-center gap-2",
|
|
61
|
+
children: [x && /* @__PURE__ */ s(i, {
|
|
62
|
+
size: 14,
|
|
63
|
+
className: "animate-spin text-text-secondary"
|
|
64
|
+
}), /* @__PURE__ */ s(l, {
|
|
65
|
+
id: b,
|
|
66
|
+
checked: y,
|
|
67
|
+
disabled: !m || x,
|
|
68
|
+
onCheckedChange: (e) => {
|
|
69
|
+
S(e);
|
|
70
|
+
},
|
|
71
|
+
"aria-label": f("integrations.connectionDetail.selfHosted.toggle", "Let self-hosted workers receive this connection’s key")
|
|
72
|
+
})]
|
|
73
|
+
})]
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
export { u as SelfHostedReleaseSetting };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=SelfHostedReleaseSetting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelfHostedReleaseSetting.js","names":["SelfHostedReleaseSetting","tr","useTr","usePermissions","canAdminister","hasPermission","INTEGRATION_PERMISSIONS","useSetConnectionSelfHostedRelease","pending","setPending","useState","connection","allowed","switchId","saving","loading","change","allow","saved","setSelfHostedRelease","error","Server","Loader2","Switch","next"],"sources":["../../../src/integrations/components/SelfHostedReleaseSetting.tsx"],"sourcesContent":["/**\n * Self-hosted release of a connection's credential (BOFF-13612, FluidGrids\n * code-first H2), on the connection detail page.\n *\n * A FluidGrids workflow can run an activity on a self-hosted worker, a machine\n * the workspace runs itself. The worker may receive this connection only when\n * its token's allow-list names the connection, and an API key or other\n * credential that does not expire leaves the platform only when a workspace\n * administrator turns this setting on. Everyone who can see the connection\n * sees the setting; only administrators can change it.\n */\nimport { useState, type FC } from 'react';\nimport { Loader2, Server } from 'lucide-react';\nimport { Switch } from '@burdenoff/fe-libs/ui';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\n\nimport { INTEGRATION_PERMISSIONS } from '../constants/permissions';\nimport { useSetConnectionSelfHostedRelease } from '../hooks/useConnections';\nimport { useTr } from '../hooks/useTr';\nimport type { IntegrationConnection } from '../types';\n\nexport interface SelfHostedReleaseSettingProps {\n connection: IntegrationConnection;\n /** Reports the outcome of a change, for the page's notification. */\n onResult?: (outcome: { ok: true; allow: boolean } | { ok: false; message: string }) => void;\n}\n\nexport const SelfHostedReleaseSetting: FC<SelfHostedReleaseSettingProps> = ({\n connection,\n onResult,\n}) => {\n const tr = useTr();\n const { hasPermission } = usePermissions();\n const canAdminister = hasPermission(INTEGRATION_PERMISSIONS.CONNECTION_ADMINISTER);\n const { setSelfHostedRelease, loading } = useSetConnectionSelfHostedRelease();\n // The cached connection updates when the mutation answers; until then the\n // switch shows the value being saved.\n const [pending, setPending] = useState<boolean | null>(null);\n\n // An older service that does not report the setting: show nothing rather\n // than a value that may be wrong.\n if (typeof connection.allowSelfHosted !== 'boolean') return null;\n const allowed = pending ?? connection.allowSelfHosted;\n const switchId = `self-hosted-release-${connection.id}`;\n\n const saving = loading || pending !== null;\n\n const change = async (allow: boolean) => {\n // One save at a time: `pending` is set before the request starts, so a\n // second click in the same frame is ignored rather than sent.\n if (pending !== null) return;\n setPending(allow);\n try {\n const saved = await setSelfHostedRelease(connection.id, allow);\n onResult?.({ ok: true, allow: saved });\n } catch (error) {\n onResult?.({\n ok: false,\n message:\n error instanceof Error && error.message\n ? error.message\n : tr(\n 'integrations.connectionDetail.selfHosted.failed',\n 'The self-hosted worker setting could not be saved.'\n ),\n });\n } finally {\n setPending(null);\n }\n };\n\n return (\n <div\n className=\"flex items-start justify-between gap-4 rounded-lg border border-border-seam p-4\"\n data-testid=\"connection-self-hosted-release\"\n >\n <div className=\"flex min-w-0 items-start gap-3\">\n <Server size={18} className=\"mt-0.5 shrink-0 text-primary\" aria-hidden=\"true\" />\n <div className=\"min-w-0\">\n <label htmlFor={switchId} className=\"text-sm font-medium text-text-primary\">\n {tr('integrations.connectionDetail.selfHosted.title', 'Self-hosted workers')}\n </label>\n <p className=\"mt-0.5 text-sm text-text-secondary\">\n {allowed\n ? tr(\n 'integrations.connectionDetail.selfHosted.on',\n 'FluidGrids workers you run yourself may receive this connection’s key when their worker token allows it. Every release is recorded in the run’s audit log.'\n )\n : tr(\n 'integrations.connectionDetail.selfHosted.off',\n 'FluidGrids workers you run yourself never receive this connection’s key. Sign-in tokens that expire within a day can still reach a worker whose token allows the connection.'\n )}\n </p>\n {!canAdminister && (\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'integrations.connectionDetail.selfHosted.adminOnly',\n 'Only workspace administrators can change this.'\n )}\n </p>\n )}\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {saving && <Loader2 size={14} className=\"animate-spin text-text-secondary\" />}\n <Switch\n id={switchId}\n checked={allowed}\n disabled={!canAdminister || saving}\n onCheckedChange={(next) => {\n void change(next);\n }}\n aria-label={tr(\n 'integrations.connectionDetail.selfHosted.toggle',\n 'Let self-hosted workers receive this connection’s key'\n )}\n />\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AA2BA,IAAaA,KAA+D,EAC1E,eACA,kBACI;CACJ,IAAMC,IAAKC,EAAM,GACX,EAAE,qBAAkBC,EAAe,GACnCC,IAAgBC,EAAcC,EAAwB,qBAAqB,GAC3E,EAAE,yBAAsB,eAAYC,EAAkC,GAGtE,CAACC,GAASC,KAAcC,EAAyB,IAAI;CAI3D,IAAI,OAAOC,EAAW,mBAAoB,WAAW,OAAO;CAC5D,IAAMC,IAAUJ,KAAWG,EAAW,iBAChCE,IAAW,uBAAuBF,EAAW,MAE7CG,IAASC,KAAWP,MAAY,MAEhCQ,IAAS,OAAO,MAAmB;EAGvC,IAAIR,MAAY,MAChB;KAAWS,CAAK;GAChB,IAAI;IACF,IAAMC,IAAQ,MAAMC,EAAqBR,EAAW,IAAIM,CAAK;IAC7D,IAAW;KAAE,IAAI;KAAM,OAAOC;IAAM,CAAC;GACvC,SAASE,GAAO;IACd,IAAW;KACT,IAAI;KACJ,SACEA,aAAiB,SAASA,EAAM,UAC5BA,EAAM,UACNnB,EACE,mDACA,oDACF;IACR,CAAC;GACH,UAAU;IACR,EAAW,IAAI;GACjB;EAjBgB;CAkBlB;CAEA,OACE,kBAAC,OAAD;EACE,WAAU;EACV,eAAY;EAFd,UAAA,CAIE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACoB,GAAD;IAAQ,MAAM;IAAI,WAAU;IAA+B,eAAY;GAAQ,CAAA,GAC/E,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,kBAAC,SAAD;MAAO,SAASR;MAAU,WAAU;MACjC,UAAAZ,EAAG,kDAAkD,qBAAqB;KACtE,CAAA;KACP,kBAAC,KAAD;MAAG,WAAU;MACV,UAAAW,IACGX,EACE,+CACA,4JACF,IACAA,EACE,gDACA,8KACF;KACH,CAAA;KACF,CAACG,KACA,kBAAC,KAAD;MAAG,WAAU;MACV,UAAAH,EACC,sDACA,gDACF;KACC,CAAA;IAEF;GACF,CAAA,CAAA;EACL,CAAA,GAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACGa,KAAU,kBAACQ,GAAD;IAAS,MAAM;IAAI,WAAU;GAAoC,CAAA,GAC5E,kBAACC,GAAD;IACE,IAAIV;IACJ,SAASD;IACT,UAAU,CAACR,KAAiBU;IAC5B,kBAAkB,MAAS;KACzB,EAAYU,CAAI;IAClB;IACA,cAAYvB,EACV,mDACA,uDACF;GACD,CAAA,CACE;EACF,CAAA,CAAA;;AAET"}
|
|
@@ -13,6 +13,7 @@ export declare const INTEGRATION_PERMISSIONS: {
|
|
|
13
13
|
readonly CONNECTION_UPDATE: "integration-connection:update";
|
|
14
14
|
readonly CONNECTION_DELETE: "integration-connection:delete";
|
|
15
15
|
readonly CONNECTION_SHARE: "integration-connection:share";
|
|
16
|
+
readonly CONNECTION_ADMINISTER: "integration-connection:administer";
|
|
16
17
|
readonly PROVIDER_READ: "integration-provider:read";
|
|
17
18
|
readonly PROVIDER_CREATE: "integration-provider:create";
|
|
18
19
|
readonly PROVIDER_UPDATE: "integration-provider:update";
|
|
@@ -9,6 +9,7 @@ var e = {
|
|
|
9
9
|
CONNECTION_UPDATE: "integration-connection:update",
|
|
10
10
|
CONNECTION_DELETE: "integration-connection:delete",
|
|
11
11
|
CONNECTION_SHARE: "integration-connection:share",
|
|
12
|
+
CONNECTION_ADMINISTER: "integration-connection:administer",
|
|
12
13
|
PROVIDER_READ: "integration-provider:read",
|
|
13
14
|
PROVIDER_CREATE: "integration-provider:create",
|
|
14
15
|
PROVIDER_UPDATE: "integration-provider:update",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","names":["INTEGRATION_PERMISSIONS"],"sources":["../../../src/integrations/constants/permissions.ts"],"sourcesContent":["/**\n * Integrations Permission Constants\n *\n * Usage: hasPermission(INTEGRATION_PERMISSIONS.CONNECTION_CREATE)\n */\n\nexport const INTEGRATION_PERMISSIONS = {\n // integration (module-level)\n // Note: the backend RBAC seed defines `integration:write` (not `update`) for\n // module-level config changes. Sub-resources use standard CRUD `update`.\n INTEGRATION_READ: 'integration:read',\n INTEGRATION_CREATE: 'integration:create',\n INTEGRATION_WRITE: 'integration:write',\n INTEGRATION_DELETE: 'integration:delete',\n\n // integration-connection\n CONNECTION_READ: 'integration-connection:read',\n CONNECTION_CREATE: 'integration-connection:create',\n CONNECTION_UPDATE: 'integration-connection:update',\n CONNECTION_DELETE: 'integration-connection:delete',\n // BOFF-9726: choose who can use a connection (owner, editors, admins)\n CONNECTION_SHARE: 'integration-connection:share',\n\n // integration-provider\n PROVIDER_READ: 'integration-provider:read',\n PROVIDER_CREATE: 'integration-provider:create',\n PROVIDER_UPDATE: 'integration-provider:update',\n PROVIDER_DELETE: 'integration-provider:delete',\n\n // integration-log\n LOG_READ: 'integration-log:read',\n\n // vault — owned by the security module, not this one, but a connection\n // cannot be stored without one, so the connection dialog offers to create a\n // vault inline and must know whether this user is allowed to.\n VAULT_CREATE: 'vault:create',\n} as const;\n\nexport type IntegrationPermission =\n (typeof INTEGRATION_PERMISSIONS)[keyof typeof INTEGRATION_PERMISSIONS];\n"],"mappings":";AAMA,IAAaA,IAA0B;CAIrC,kBAAkB;CAClB,oBAAoB;CACpB,mBAAmB;CACnB,oBAAoB;CAGpB,iBAAiB;CACjB,mBAAmB;CACnB,mBAAmB;CACnB,mBAAmB;CAEnB,kBAAkB;CAGlB,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CAGjB,UAAU;CAKV,cAAc;AAChB"}
|
|
1
|
+
{"version":3,"file":"permissions.js","names":["INTEGRATION_PERMISSIONS"],"sources":["../../../src/integrations/constants/permissions.ts"],"sourcesContent":["/**\n * Integrations Permission Constants\n *\n * Usage: hasPermission(INTEGRATION_PERMISSIONS.CONNECTION_CREATE)\n */\n\nexport const INTEGRATION_PERMISSIONS = {\n // integration (module-level)\n // Note: the backend RBAC seed defines `integration:write` (not `update`) for\n // module-level config changes. Sub-resources use standard CRUD `update`.\n INTEGRATION_READ: 'integration:read',\n INTEGRATION_CREATE: 'integration:create',\n INTEGRATION_WRITE: 'integration:write',\n INTEGRATION_DELETE: 'integration:delete',\n\n // integration-connection\n CONNECTION_READ: 'integration-connection:read',\n CONNECTION_CREATE: 'integration-connection:create',\n CONNECTION_UPDATE: 'integration-connection:update',\n CONNECTION_DELETE: 'integration-connection:delete',\n // BOFF-9726: choose who can use a connection (owner, editors, admins)\n CONNECTION_SHARE: 'integration-connection:share',\n // Workspace administrators: hand a connection over, and let self-hosted\n // workers receive its long-lived credential (BOFF-13612).\n CONNECTION_ADMINISTER: 'integration-connection:administer',\n\n // integration-provider\n PROVIDER_READ: 'integration-provider:read',\n PROVIDER_CREATE: 'integration-provider:create',\n PROVIDER_UPDATE: 'integration-provider:update',\n PROVIDER_DELETE: 'integration-provider:delete',\n\n // integration-log\n LOG_READ: 'integration-log:read',\n\n // vault — owned by the security module, not this one, but a connection\n // cannot be stored without one, so the connection dialog offers to create a\n // vault inline and must know whether this user is allowed to.\n VAULT_CREATE: 'vault:create',\n} as const;\n\nexport type IntegrationPermission =\n (typeof INTEGRATION_PERMISSIONS)[keyof typeof INTEGRATION_PERMISSIONS];\n"],"mappings":";AAMA,IAAaA,IAA0B;CAIrC,kBAAkB;CAClB,oBAAoB;CACpB,mBAAmB;CACnB,oBAAoB;CAGpB,iBAAiB;CACjB,mBAAmB;CACnB,mBAAmB;CACnB,mBAAmB;CAEnB,kBAAkB;CAGlB,uBAAuB;CAGvB,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CAGjB,UAAU;CAKV,cAAc;AAChB"}
|
|
@@ -70,6 +70,15 @@ export declare function useDeleteConnection(): {
|
|
|
70
70
|
deleteConnection: (id: string, deleteVaultSecret?: boolean) => Promise<void>;
|
|
71
71
|
loading: boolean;
|
|
72
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* BOFF-13612: let self-hosted FluidGrids workers receive a connection's
|
|
75
|
+
* long-lived credential, or stop them. Workspace administrators only; the
|
|
76
|
+
* answer updates the cached connection, so the detail page re-renders.
|
|
77
|
+
*/
|
|
78
|
+
export declare function useSetConnectionSelfHostedRelease(): {
|
|
79
|
+
setSelfHostedRelease: (connectionId: string, allow: boolean) => Promise<boolean>;
|
|
80
|
+
loading: boolean;
|
|
81
|
+
};
|
|
73
82
|
export declare function useInitiateOAuth(): {
|
|
74
83
|
initiateOAuth: (connectionId: string, redirectUri: string, providerKey: string, scopes?: string[]) => Promise<OAuthInitiationResult | null>;
|
|
75
84
|
loading: boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useAuthenticateWithApiKeyMutation as e, useAuthenticateWithBasicAuthMutation as t, useAuthenticateWithBearerTokenMutation as n, useCreateConnectionMutation as r, useDeleteConnectionMutation as i, useGetConnectionQuery as a, useGetConnectionsByProviderQuery as o, useGetConnectionsQuery as s, useInitiateOAuthMutation as c, useRefreshConnectionTokenMutation as l, useRevokeConnectionMutation as u,
|
|
2
|
-
import { useIntegrations as
|
|
3
|
-
import { useIntegrationsEventBus as
|
|
4
|
-
import { mapConnection as
|
|
5
|
-
import { useCallback as
|
|
6
|
-
import { gql as
|
|
7
|
-
import { useMutation as
|
|
1
|
+
import { useAuthenticateWithApiKeyMutation as e, useAuthenticateWithBasicAuthMutation as t, useAuthenticateWithBearerTokenMutation as n, useCreateConnectionMutation as r, useDeleteConnectionMutation as i, useGetConnectionQuery as a, useGetConnectionsByProviderQuery as o, useGetConnectionsQuery as s, useInitiateOAuthMutation as c, useRefreshConnectionTokenMutation as l, useRevokeConnectionMutation as u, useSetConnectionSelfHostedReleaseMutation as d, useTestConnectionMutation as f } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useIntegrations as p } from "../providers/IntegrationsProvider.js";
|
|
3
|
+
import { useIntegrationsEventBus as m } from "../events/useIntegrationsEventBus.js";
|
|
4
|
+
import { mapConnection as h } from "../utils/mappers.js";
|
|
5
|
+
import { useCallback as g } from "react";
|
|
6
|
+
import { gql as _ } from "@apollo/client";
|
|
7
|
+
import { useMutation as v } from "@apollo/client/react";
|
|
8
8
|
// src/integrations/hooks/useConnections.ts
|
|
9
|
-
function
|
|
10
|
-
let { workspaceId: t } =
|
|
9
|
+
function y(e) {
|
|
10
|
+
let { workspaceId: t } = p(), { data: n, loading: r, error: i, refetch: a } = s({
|
|
11
11
|
variables: {
|
|
12
12
|
filter: e,
|
|
13
13
|
pagination: { limit: 100 }
|
|
@@ -16,7 +16,7 @@ function v(e) {
|
|
|
16
16
|
errorPolicy: "all"
|
|
17
17
|
}), o = n?.getConnections !== void 0;
|
|
18
18
|
return {
|
|
19
|
-
connections: (n?.getConnections?.items ?? []).map((e) =>
|
|
19
|
+
connections: (n?.getConnections?.items ?? []).map((e) => h(e)),
|
|
20
20
|
total: n?.getConnections?.total ?? 0,
|
|
21
21
|
loading: r,
|
|
22
22
|
answered: o,
|
|
@@ -24,22 +24,22 @@ function v(e) {
|
|
|
24
24
|
refetch: a
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
let { workspaceId: t } =
|
|
27
|
+
function b(e) {
|
|
28
|
+
let { workspaceId: t } = p(), { data: n, loading: r, error: i, refetch: o } = a({
|
|
29
29
|
variables: { id: e },
|
|
30
30
|
skip: !t || !e,
|
|
31
31
|
errorPolicy: "all"
|
|
32
32
|
}), s = n?.getConnection !== void 0;
|
|
33
33
|
return {
|
|
34
|
-
connection: n?.getConnection ?
|
|
34
|
+
connection: n?.getConnection ? h(n.getConnection) : null,
|
|
35
35
|
loading: r,
|
|
36
36
|
answered: s,
|
|
37
37
|
error: i,
|
|
38
38
|
refetch: o
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
let { workspaceId: t } =
|
|
41
|
+
function x(e) {
|
|
42
|
+
let { workspaceId: t } = p(), { data: n, loading: r, error: i, refetch: a } = o({
|
|
43
43
|
variables: {
|
|
44
44
|
providerId: e,
|
|
45
45
|
pagination: { limit: 100 }
|
|
@@ -48,17 +48,17 @@ function b(e) {
|
|
|
48
48
|
errorPolicy: "all"
|
|
49
49
|
});
|
|
50
50
|
return {
|
|
51
|
-
connections: (n?.getConnectionsByProvider?.items ?? []).map((e) =>
|
|
51
|
+
connections: (n?.getConnectionsByProvider?.items ?? []).map((e) => h(e)),
|
|
52
52
|
total: n?.getConnectionsByProvider?.total ?? 0,
|
|
53
53
|
loading: r,
|
|
54
54
|
error: i,
|
|
55
55
|
refetch: a
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
let [e, { loading: t }] = r({ refetchQueries: ["GetConnections"] }), n =
|
|
58
|
+
function S() {
|
|
59
|
+
let [e, { loading: t }] = r({ refetchQueries: ["GetConnections"] }), n = m();
|
|
60
60
|
return {
|
|
61
|
-
createConnection:
|
|
61
|
+
createConnection: g(async (t) => {
|
|
62
62
|
let r = (await e({ variables: { input: t } })).data?.createConnection?.id;
|
|
63
63
|
return r && n.emit("integrations:connection-created", {
|
|
64
64
|
connectionId: r,
|
|
@@ -68,10 +68,10 @@ function x() {
|
|
|
68
68
|
loading: t
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
let [e, { loading: t }] = i({ refetchQueries: ["GetConnections"] }), n =
|
|
71
|
+
function C() {
|
|
72
|
+
let [e, { loading: t }] = i({ refetchQueries: ["GetConnections"] }), n = m();
|
|
73
73
|
return {
|
|
74
|
-
deleteConnection:
|
|
74
|
+
deleteConnection: g(async (t, r = !1) => {
|
|
75
75
|
await e({ variables: {
|
|
76
76
|
id: t,
|
|
77
77
|
deleteVaultSecret: r
|
|
@@ -80,10 +80,24 @@ function S() {
|
|
|
80
80
|
loading: t
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
let [e, { loading: t }] =
|
|
83
|
+
function w() {
|
|
84
|
+
let [e, { loading: t }] = d();
|
|
85
85
|
return {
|
|
86
|
-
|
|
86
|
+
setSelfHostedRelease: g(async (t, n) => {
|
|
87
|
+
let r = (await e({ variables: {
|
|
88
|
+
connectionId: t,
|
|
89
|
+
allow: n
|
|
90
|
+
} })).data?.setConnectionSelfHostedRelease;
|
|
91
|
+
if (!r) throw Error("The connection did not answer with its new setting");
|
|
92
|
+
return r.allowSelfHosted;
|
|
93
|
+
}, [e]),
|
|
94
|
+
loading: t
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function T() {
|
|
98
|
+
let [e, { loading: t }] = c(), n = m();
|
|
99
|
+
return {
|
|
100
|
+
initiateOAuth: g(async (t, r, i, a) => {
|
|
87
101
|
n.emit("integrations:oauth-started", {
|
|
88
102
|
connectionId: t,
|
|
89
103
|
providerKey: i
|
|
@@ -102,20 +116,20 @@ function C() {
|
|
|
102
116
|
loading: t
|
|
103
117
|
};
|
|
104
118
|
}
|
|
105
|
-
function
|
|
119
|
+
function E() {
|
|
106
120
|
let [t, { loading: n }] = e({ refetchQueries: ["GetConnection"] });
|
|
107
121
|
return {
|
|
108
|
-
authenticateWithApiKey:
|
|
122
|
+
authenticateWithApiKey: g(async (e, n) => (await t({ variables: { input: {
|
|
109
123
|
connectionId: e,
|
|
110
124
|
apiKey: n
|
|
111
125
|
} } })).data?.authenticateWithApiKey, [t]),
|
|
112
126
|
loading: n
|
|
113
127
|
};
|
|
114
128
|
}
|
|
115
|
-
function
|
|
129
|
+
function D() {
|
|
116
130
|
let [e, { loading: n }] = t({ refetchQueries: ["GetConnection"] });
|
|
117
131
|
return {
|
|
118
|
-
authenticateWithBasicAuth:
|
|
132
|
+
authenticateWithBasicAuth: g(async (t, n, r) => (await e({ variables: { input: {
|
|
119
133
|
connectionId: t,
|
|
120
134
|
username: n,
|
|
121
135
|
password: r
|
|
@@ -123,17 +137,17 @@ function T() {
|
|
|
123
137
|
loading: n
|
|
124
138
|
};
|
|
125
139
|
}
|
|
126
|
-
function
|
|
140
|
+
function O() {
|
|
127
141
|
let [e, { loading: t }] = n({ refetchQueries: ["GetConnection"] });
|
|
128
142
|
return {
|
|
129
|
-
authenticateWithBearerToken:
|
|
143
|
+
authenticateWithBearerToken: g(async (t, n) => (await e({ variables: { input: {
|
|
130
144
|
connectionId: t,
|
|
131
145
|
token: n
|
|
132
146
|
} } })).data?.authenticateWithBearerToken, [e]),
|
|
133
147
|
loading: t
|
|
134
148
|
};
|
|
135
149
|
}
|
|
136
|
-
var
|
|
150
|
+
var k = _`
|
|
137
151
|
mutation AuthenticateWithServiceAccount($input: ServiceAccountAuthInput!) {
|
|
138
152
|
authenticateWithServiceAccount(input: $input) {
|
|
139
153
|
id
|
|
@@ -141,17 +155,17 @@ var D = g`
|
|
|
141
155
|
}
|
|
142
156
|
}
|
|
143
157
|
`;
|
|
144
|
-
function
|
|
145
|
-
let [e, { loading: t }] =
|
|
158
|
+
function A() {
|
|
159
|
+
let [e, { loading: t }] = v(k, { refetchQueries: ["GetConnection"] });
|
|
146
160
|
return {
|
|
147
|
-
authenticateWithServiceAccount:
|
|
161
|
+
authenticateWithServiceAccount: g(async (t, n) => (await e({ variables: { input: {
|
|
148
162
|
connectionId: t,
|
|
149
163
|
scopes: n
|
|
150
164
|
} } })).data?.authenticateWithServiceAccount, [e]),
|
|
151
165
|
loading: t
|
|
152
166
|
};
|
|
153
167
|
}
|
|
154
|
-
var
|
|
168
|
+
var j = _`
|
|
155
169
|
mutation AuthenticateWithCustomConfig($input: CustomConfigAuthInput!) {
|
|
156
170
|
authenticateWithCustomConfig(input: $input) {
|
|
157
171
|
id
|
|
@@ -159,43 +173,43 @@ var k = g`
|
|
|
159
173
|
}
|
|
160
174
|
}
|
|
161
175
|
`;
|
|
162
|
-
function
|
|
163
|
-
let [e, { loading: t }] =
|
|
176
|
+
function M() {
|
|
177
|
+
let [e, { loading: t }] = v(j, { refetchQueries: ["GetConnection"] });
|
|
164
178
|
return {
|
|
165
|
-
authenticateWithCustomConfig:
|
|
179
|
+
authenticateWithCustomConfig: g(async (t, n) => (await e({ variables: { input: {
|
|
166
180
|
connectionId: t,
|
|
167
181
|
config: n
|
|
168
182
|
} } })).data?.authenticateWithCustomConfig, [e]),
|
|
169
183
|
loading: t
|
|
170
184
|
};
|
|
171
185
|
}
|
|
172
|
-
function
|
|
173
|
-
let [e, { loading: t }] = l({ refetchQueries: ["GetConnection"] }), n =
|
|
186
|
+
function N() {
|
|
187
|
+
let [e, { loading: t }] = l({ refetchQueries: ["GetConnection"] }), n = m();
|
|
174
188
|
return {
|
|
175
|
-
refreshToken:
|
|
189
|
+
refreshToken: g(async (t) => {
|
|
176
190
|
let r = await e({ variables: { connectionId: t } });
|
|
177
191
|
return r.data?.refreshConnectionToken && n.emit("integrations:token-refreshed", { connectionId: t }), r.data?.refreshConnectionToken;
|
|
178
192
|
}, [e, n]),
|
|
179
193
|
loading: t
|
|
180
194
|
};
|
|
181
195
|
}
|
|
182
|
-
function
|
|
183
|
-
let [e, { loading: t }] = u({ refetchQueries: ["GetConnection"] }), n =
|
|
196
|
+
function P() {
|
|
197
|
+
let [e, { loading: t }] = u({ refetchQueries: ["GetConnection"] }), n = m();
|
|
184
198
|
return {
|
|
185
|
-
revokeConnection:
|
|
199
|
+
revokeConnection: g(async (t) => {
|
|
186
200
|
let r = await e({ variables: { connectionId: t } });
|
|
187
201
|
return r.data?.revokeConnection && n.emit("integrations:token-revoked", { connectionId: t }), r.data?.revokeConnection;
|
|
188
202
|
}, [e, n]),
|
|
189
203
|
loading: t
|
|
190
204
|
};
|
|
191
205
|
}
|
|
192
|
-
function
|
|
193
|
-
let [e, { loading: t }] =
|
|
206
|
+
function F() {
|
|
207
|
+
let [e, { loading: t }] = f();
|
|
194
208
|
return {
|
|
195
|
-
testConnection:
|
|
209
|
+
testConnection: g(async (t) => (await e({ variables: { connectionId: t } })).data?.testConnection ?? null, [e]),
|
|
196
210
|
loading: t
|
|
197
211
|
};
|
|
198
212
|
}
|
|
199
|
-
export {
|
|
213
|
+
export { E as useAuthenticateWithApiKey, D as useAuthenticateWithBasicAuth, O as useAuthenticateWithBearerToken, M as useAuthenticateWithCustomConfig, A as useAuthenticateWithServiceAccount, b as useConnection, y as useConnections, x as useConnectionsByProvider, S as useCreateConnection, C as useDeleteConnection, T as useInitiateOAuth, N as useRefreshToken, P as useRevokeConnection, w as useSetConnectionSelfHostedRelease, F as useTestConnection };
|
|
200
214
|
|
|
201
215
|
//# sourceMappingURL=useConnections.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConnections.js","names":["useConnections","useIntegrations","useGetConnectionsQuery","workspaceId","answered","data","mapConnection","item","useConnection","useGetConnectionQuery","id","useConnectionsByProvider","useGetConnectionsByProviderQuery","providerId","useCreateConnection","mutate","useCreateConnectionMutation","eventBus","useIntegrationsEventBus","useCallback","input","useDeleteConnection","useDeleteConnectionMutation","useInitiateOAuth","useInitiateOAuthMutation","result","useAuthenticateWithApiKey","useAuthenticateWithApiKeyMutation","useAuthenticateWithBasicAuth","useAuthenticateWithBasicAuthMutation","useAuthenticateWithBearerToken","useAuthenticateWithBearerTokenMutation","AUTHENTICATE_WITH_SERVICE_ACCOUNT","useAuthenticateWithServiceAccount","useMutation","AUTHENTICATE_WITH_CUSTOM_CONFIG","useAuthenticateWithCustomConfig","useRefreshToken","useRefreshConnectionTokenMutation","useRevokeConnection","useRevokeConnectionMutation","useTestConnection","useTestConnectionMutation"],"sources":["../../../src/integrations/hooks/useConnections.ts"],"sourcesContent":["/**\n * Custom hooks wrapping GraphQL queries and mutations for connections.\n */\n\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation } from '@apollo/client/react';\nimport {\n useGetConnectionsQuery,\n useGetConnectionQuery,\n useGetConnectionsByProviderQuery,\n useCreateConnectionMutation,\n useInitiateOAuthMutation,\n useAuthenticateConnectionMutation,\n useAuthenticateWithApiKeyMutation,\n useAuthenticateWithBasicAuthMutation,\n useAuthenticateWithBearerTokenMutation,\n useRefreshConnectionTokenMutation,\n useRevokeConnectionMutation,\n useTestConnectionMutation,\n useDeleteConnectionMutation,\n} from '../../generated/wspace-operations';\nimport type { ConnectionAccessFilter } from '../../generated/wspace-types';\nimport { useIntegrations } from '../providers/IntegrationsProvider';\nimport { useIntegrationsEventBus } from '../events/useIntegrationsEventBus';\nimport { mapConnection } from '../utils/mappers';\nimport type {\n IntegrationConnection,\n ConnectionStatus,\n OAuthInitiationResult,\n ConnectionTestResult,\n} from '../types';\n\n/**\n * A query we never asked is NOT an empty result.\n *\n * ★★ THE BUG THIS EXISTS TO PREVENT. Apollo returns `loading: false`,\n * `error: undefined`, `data: undefined` for a SKIPPED query — identical, from a\n * caller's point of view, to a query that ran and found nothing. Pages then\n * render their empty state and tell the user, definitively, that they have no\n * connections.\n *\n * Measured in production 2026-09-13: `/integrations/connections` showed\n * \"No connections yet\" while the workspace held **46** connections — 8 ACTIVE\n * (Gmail, GitHub, Google Sheets, Linear, Anthropic), 1 EXPIRED, 37 PENDING_AUTH.\n * The assistant, asked the same question through the API, listed all 46. No\n * request left the browser and no error appeared anywhere.\n *\n * `workspaceId` is falsy whenever the active context has not resolved — and the\n * shell passes `activeContext.workspaceId ?? \"\"`, so \"not yet known\" arrives as\n * an empty string, which is falsy. Any render in that window produces a\n * confident, wrong answer.\n *\n * So `notReady` is returned separately and callers MUST NOT treat it as empty.\n * It is deliberately not folded into `loading`: a caller that shows a spinner is\n * right, and a caller that ignores it still cannot mistake it for \"none\".\n */\n\n// ─── Query Hooks ────────────────────────────────────────────────────────────\n\ninterface ConnectionFilterOptions {\n status?: ConnectionStatus;\n providerId?: string;\n search?: string;\n /** BOFF-9726: only the caller's own connections, or those shared with them. */\n access?: ConnectionAccessFilter;\n}\n\nexport function useConnections(filter?: ConnectionFilterOptions) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetConnectionsQuery({\n variables: { filter, pagination: { limit: 100 } },\n skip: !workspaceId,\n errorPolicy: 'all',\n });\n\n // ★ Keyed on the ABSENCE OF DATA, not on why it is absent. A skipped query, a\n // query still in flight and a query that resolved from an empty cache entry all\n // land here, and none of them is evidence that the workspace has no connections.\n const answered = data?.getConnections !== undefined;\n\n const connections: IntegrationConnection[] = (data?.getConnections?.items ?? []).map(\n (item: Record<string, unknown>) => mapConnection(item)\n );\n\n return {\n connections,\n total: data?.getConnections?.total ?? 0,\n loading,\n // ★ False until the server has actually told us. Callers MUST gate their\n // empty state on this — see the note above.\n answered,\n error,\n refetch,\n };\n}\n\nexport function useConnection(id: string) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetConnectionQuery({\n variables: { id },\n skip: !workspaceId || !id,\n errorPolicy: 'all',\n });\n\n const answered = data?.getConnection !== undefined;\n\n const connection: IntegrationConnection | null = data?.getConnection\n ? mapConnection(data.getConnection as Record<string, unknown>)\n : null;\n\n return { connection, loading, answered, error, refetch };\n}\n\nexport function useConnectionsByProvider(providerId: string) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetConnectionsByProviderQuery({\n variables: { providerId, pagination: { limit: 100 } },\n skip: !workspaceId || !providerId,\n errorPolicy: 'all',\n });\n\n const connections: IntegrationConnection[] = (data?.getConnectionsByProvider?.items ?? []).map(\n (item: Record<string, unknown>) => mapConnection(item)\n );\n\n return {\n connections,\n total: data?.getConnectionsByProvider?.total ?? 0,\n loading,\n error,\n refetch,\n };\n}\n\n// ─── Mutation Hooks ─────────────────────────────────────────────────────────\n\nexport function useCreateConnection() {\n const [mutate, { loading }] = useCreateConnectionMutation({\n refetchQueries: ['GetConnections'],\n });\n const eventBus = useIntegrationsEventBus();\n\n const createConnection = useCallback(\n async (input: {\n name: string;\n description?: string;\n providerId: string;\n authMethodKey?: string;\n vaultId?: string;\n credentialSecretId?: string;\n managedSecretName?: string;\n config?: Record<string, unknown>;\n }) => {\n const result = await mutate({ variables: { input } });\n const id = result.data?.createConnection?.id as string | undefined;\n if (id) {\n eventBus.emit('integrations:connection-created', {\n connectionId: id,\n providerKey: input.providerId,\n });\n }\n return id;\n },\n [mutate, eventBus]\n );\n\n return { createConnection, loading };\n}\n\nexport function useDeleteConnection() {\n const [mutate, { loading }] = useDeleteConnectionMutation({\n refetchQueries: ['GetConnections'],\n });\n const eventBus = useIntegrationsEventBus();\n\n const deleteConnection = useCallback(\n async (id: string, deleteVaultSecret = false) => {\n await mutate({ variables: { id, deleteVaultSecret } });\n eventBus.emit('integrations:connection-deleted', { connectionId: id });\n },\n [mutate, eventBus]\n );\n\n return { deleteConnection, loading };\n}\n\nexport function useInitiateOAuth() {\n const [mutate, { loading }] = useInitiateOAuthMutation();\n const eventBus = useIntegrationsEventBus();\n\n const initiateOAuth = useCallback(\n async (\n connectionId: string,\n redirectUri: string,\n providerKey: string,\n scopes?: string[]\n ): Promise<OAuthInitiationResult | null> => {\n eventBus.emit('integrations:oauth-started', { connectionId, providerKey });\n const result = await mutate({ variables: { input: { connectionId, redirectUri, scopes } } });\n if (result.error) {\n eventBus.emit('integrations:oauth-failed', {\n connectionId,\n providerKey,\n error: result.error.message,\n });\n }\n return result.data?.initiateOAuth ?? null;\n },\n [mutate, eventBus]\n );\n\n return { initiateOAuth, loading };\n}\n\n/**\n * Authenticate a connection with values shaped by its auth method's schema.\n *\n * Generic replacement for the per-auth-type hooks below: the caller passes\n * whatever the rendered form collected, so a new auth type needs no new hook,\n * no new mutation document and no new branch at the call site.\n */\nexport function useAuthenticateConnection() {\n const [mutate, { loading }] = useAuthenticateConnectionMutation({\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateConnection = useCallback(\n async (\n connectionId: string,\n authMethodKey: string | undefined,\n values: Record<string, unknown>\n ) => {\n const result = await mutate({\n variables: { input: { connectionId, authMethodKey, values } },\n });\n return result.data?.authenticateConnection;\n },\n [mutate]\n );\n\n return { authenticateConnection, loading };\n}\n\nexport function useAuthenticateWithApiKey() {\n const [mutate, { loading }] = useAuthenticateWithApiKeyMutation({\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithApiKey = useCallback(\n async (connectionId: string, apiKey: string) => {\n const result = await mutate({ variables: { input: { connectionId, apiKey } } });\n return result.data?.authenticateWithApiKey;\n },\n [mutate]\n );\n\n return { authenticateWithApiKey, loading };\n}\n\nexport function useAuthenticateWithBasicAuth() {\n const [mutate, { loading }] = useAuthenticateWithBasicAuthMutation({\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithBasicAuth = useCallback(\n async (connectionId: string, username: string, password: string) => {\n const result = await mutate({ variables: { input: { connectionId, username, password } } });\n return result.data?.authenticateWithBasicAuth;\n },\n [mutate]\n );\n\n return { authenticateWithBasicAuth, loading };\n}\n\nexport function useAuthenticateWithBearerToken() {\n const [mutate, { loading }] = useAuthenticateWithBearerTokenMutation({\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithBearerToken = useCallback(\n async (connectionId: string, token: string) => {\n const result = await mutate({ variables: { input: { connectionId, token } } });\n return result.data?.authenticateWithBearerToken;\n },\n [mutate]\n );\n\n return { authenticateWithBearerToken, loading };\n}\n\n/**\n * GraphQL document for the first-party SERVICE_ACCOUNT auth flow. Defined inline\n * (rather than via codegen) so it does not depend on a fresh `schema:pull` from\n * a gateway that already exposes the new `authenticateWithServiceAccount`\n * mutation. Once the gateway supergraph includes it, this can be migrated to an\n * `src/operations/...` document like the other mutations.\n */\nconst AUTHENTICATE_WITH_SERVICE_ACCOUNT = gql`\n mutation AuthenticateWithServiceAccount($input: ServiceAccountAuthInput!) {\n authenticateWithServiceAccount(input: $input) {\n id\n status\n }\n }\n`;\n\n/**\n * Connect a first-party SERVICE_ACCOUNT provider (e.g. Burdenoff). No user\n * credentials are collected — the platform mints an app-as-user token per\n * execution. Calling this records the user's consent (delegation) for the\n * reserved app and activates the connection.\n */\nexport function useAuthenticateWithServiceAccount() {\n const [mutate, { loading }] = useMutation<\n { authenticateWithServiceAccount: { id: string; status: ConnectionStatus } },\n { input: { connectionId: string; scopes?: string[] } }\n >(AUTHENTICATE_WITH_SERVICE_ACCOUNT, {\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithServiceAccount = useCallback(\n async (connectionId: string, scopes?: string[]) => {\n const result = await mutate({ variables: { input: { connectionId, scopes } } });\n return result.data?.authenticateWithServiceAccount;\n },\n [mutate]\n );\n\n return { authenticateWithServiceAccount, loading };\n}\n\n/**\n * GraphQL document for CUSTOM provider auth (configSchema-driven config, e.g.\n * Google Workspace Admin domain-wide delegation). Defined inline (rather than\n * via codegen) so it does not depend on a fresh `schema:pull` from a gateway\n * that already exposes the new `authenticateWithCustomConfig` mutation. Once\n * the gateway supergraph includes it, this can be migrated to an\n * `src/operations/...` document like the other mutations.\n */\nconst AUTHENTICATE_WITH_CUSTOM_CONFIG = gql`\n mutation AuthenticateWithCustomConfig($input: CustomConfigAuthInput!) {\n authenticateWithCustomConfig(input: $input) {\n id\n status\n }\n }\n`;\n\n/**\n * Connect a CUSTOM provider with a configSchema-shaped config object. The full\n * config is stored inside the encrypted credential payload (secrets never hit\n * plain columns); the connection becomes ACTIVE immediately.\n */\nexport function useAuthenticateWithCustomConfig() {\n const [mutate, { loading }] = useMutation<\n { authenticateWithCustomConfig: { id: string; status: ConnectionStatus } },\n { input: { connectionId: string; config: Record<string, unknown> } }\n >(AUTHENTICATE_WITH_CUSTOM_CONFIG, {\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithCustomConfig = useCallback(\n async (connectionId: string, config: Record<string, unknown>) => {\n const result = await mutate({ variables: { input: { connectionId, config } } });\n return result.data?.authenticateWithCustomConfig;\n },\n [mutate]\n );\n\n return { authenticateWithCustomConfig, loading };\n}\n\nexport function useRefreshToken() {\n const [mutate, { loading }] = useRefreshConnectionTokenMutation({\n refetchQueries: ['GetConnection'],\n });\n const eventBus = useIntegrationsEventBus();\n\n const refreshToken = useCallback(\n async (connectionId: string) => {\n const result = await mutate({ variables: { connectionId } });\n if (result.data?.refreshConnectionToken) {\n eventBus.emit('integrations:token-refreshed', { connectionId });\n }\n return result.data?.refreshConnectionToken;\n },\n [mutate, eventBus]\n );\n\n return { refreshToken, loading };\n}\n\nexport function useRevokeConnection() {\n const [mutate, { loading }] = useRevokeConnectionMutation({\n refetchQueries: ['GetConnection'],\n });\n const eventBus = useIntegrationsEventBus();\n\n const revokeConnection = useCallback(\n async (connectionId: string) => {\n const result = await mutate({ variables: { connectionId } });\n if (result.data?.revokeConnection) {\n eventBus.emit('integrations:token-revoked', { connectionId });\n }\n return result.data?.revokeConnection;\n },\n [mutate, eventBus]\n );\n\n return { revokeConnection, loading };\n}\n\nexport function useTestConnection() {\n const [mutate, { loading }] = useTestConnectionMutation();\n\n const testConnection = useCallback(\n async (connectionId: string): Promise<ConnectionTestResult | null> => {\n const result = await mutate({ variables: { connectionId } });\n return result.data?.testConnection ?? null;\n },\n [mutate]\n );\n\n return { testConnection, loading };\n}\n"],"mappings":";;;;;;;;AAoEA,SAAgBA,EAAe,GAAkC;CAC/D,IAAM,EAAE,mBAAgBC,EAAgB,GAClC,EAAE,SAAM,YAAS,UAAO,eAAYC,EAAuB;EAC/D,WAAW;GAAE;GAAQ,YAAY,EAAE,OAAO,IAAI;EAAE;EAChD,MAAM,CAACC;EACP,aAAa;CACf,CAAC,GAKKC,IAAWC,GAAM,mBAAmB,KAAA;CAM1C,OAAO;EACL,cAL4CA,GAAM,gBAAgB,SAAS,CAAC,EAAA,CAAG,KAC9E,MAAkCC,EAAcC,CAAI,CAIrD;EACA,OAAOF,GAAM,gBAAgB,SAAS;EACtC;EAGA;EACA;EACA;CACF;AACF;AAEA,SAAgBG,EAAc,GAAY;CACxC,IAAM,EAAE,mBAAgBP,EAAgB,GAClC,EAAE,SAAM,YAAS,UAAO,eAAYQ,EAAsB;EAC9D,WAAW,EAAE,MA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EAAE,CAAC;GAI3D,OAHIU,EAAO,MAAM,0BACfR,EAAS,KAAK,gCAAgC,EAAE,gBAAa,CAAC,GAEzDQ,EAAO,MAAM;EACtB,GACA,CAACV,GAAQE,CAAQ,CAGV;EAAc;CAAQ;AACjC;AAEA,SAAgBsB,IAAsB;CACpC,IAAM,CAACxB,GAAQ,EAAE,gBAAayB,EAA4B,EACxD,gBAAgB,CAAC,eAAe,EAClC,CAAC,GACKvB,IAAWC,EAAwB;CAazC,OAAO;EAAE,kBAXgBC,EACvB,OAAO,MAAyB;GAC9B,IAAMM,IAAS,MAAMV,EAAO,EAAE,WAAW,EAAE,gBAAa,EAAE,CAAC;GAI3D,OAHIU,EAAO,MAAM,oBACfR,EAAS,KAAK,8BAA8B,EAAE,gBAAa,CAAC,GAEvDQ,EAAO,MAAM;EACtB,GACA,CAACV,GAAQE,CAAQ,CAGV;EAAkB;CAAQ;AACrC;AAEA,SAAgBwB,IAAoB;CAClC,IAAM,CAAC1B,GAAQ,EAAE,gBAAa2B,EAA0B;CAUxD,OAAO;EAAE,gBARcvB,EACrB,OAAO,OAEE,MADcJ,EAAO,EAAE,WAAW,EAAE,gBAAa,EAAE,CAAC,EAAA,CAC7C,MAAM,kBAAkB,MAExC,CAACA,CAAM,CAGA;EAAgB;CAAQ;AACnC"}
|
|
1
|
+
{"version":3,"file":"useConnections.js","names":["useConnections","useIntegrations","useGetConnectionsQuery","workspaceId","answered","data","mapConnection","item","useConnection","useGetConnectionQuery","id","useConnectionsByProvider","useGetConnectionsByProviderQuery","providerId","useCreateConnection","mutate","useCreateConnectionMutation","eventBus","useIntegrationsEventBus","useCallback","input","useDeleteConnection","useDeleteConnectionMutation","useSetConnectionSelfHostedRelease","useSetConnectionSelfHostedReleaseMutation","updated","useInitiateOAuth","useInitiateOAuthMutation","result","useAuthenticateWithApiKey","useAuthenticateWithApiKeyMutation","useAuthenticateWithBasicAuth","useAuthenticateWithBasicAuthMutation","useAuthenticateWithBearerToken","useAuthenticateWithBearerTokenMutation","AUTHENTICATE_WITH_SERVICE_ACCOUNT","useAuthenticateWithServiceAccount","useMutation","AUTHENTICATE_WITH_CUSTOM_CONFIG","useAuthenticateWithCustomConfig","useRefreshToken","useRefreshConnectionTokenMutation","useRevokeConnection","useRevokeConnectionMutation","useTestConnection","useTestConnectionMutation"],"sources":["../../../src/integrations/hooks/useConnections.ts"],"sourcesContent":["/**\n * Custom hooks wrapping GraphQL queries and mutations for connections.\n */\n\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation } from '@apollo/client/react';\nimport {\n useGetConnectionsQuery,\n useGetConnectionQuery,\n useGetConnectionsByProviderQuery,\n useCreateConnectionMutation,\n useInitiateOAuthMutation,\n useAuthenticateConnectionMutation,\n useAuthenticateWithApiKeyMutation,\n useAuthenticateWithBasicAuthMutation,\n useAuthenticateWithBearerTokenMutation,\n useRefreshConnectionTokenMutation,\n useRevokeConnectionMutation,\n useTestConnectionMutation,\n useDeleteConnectionMutation,\n useSetConnectionSelfHostedReleaseMutation,\n} from '../../generated/wspace-operations';\nimport type { ConnectionAccessFilter } from '../../generated/wspace-types';\nimport { useIntegrations } from '../providers/IntegrationsProvider';\nimport { useIntegrationsEventBus } from '../events/useIntegrationsEventBus';\nimport { mapConnection } from '../utils/mappers';\nimport type {\n IntegrationConnection,\n ConnectionStatus,\n OAuthInitiationResult,\n ConnectionTestResult,\n} from '../types';\n\n/**\n * A query we never asked is NOT an empty result.\n *\n * ★★ THE BUG THIS EXISTS TO PREVENT. Apollo returns `loading: false`,\n * `error: undefined`, `data: undefined` for a SKIPPED query — identical, from a\n * caller's point of view, to a query that ran and found nothing. Pages then\n * render their empty state and tell the user, definitively, that they have no\n * connections.\n *\n * Measured in production 2026-09-13: `/integrations/connections` showed\n * \"No connections yet\" while the workspace held **46** connections — 8 ACTIVE\n * (Gmail, GitHub, Google Sheets, Linear, Anthropic), 1 EXPIRED, 37 PENDING_AUTH.\n * The assistant, asked the same question through the API, listed all 46. No\n * request left the browser and no error appeared anywhere.\n *\n * `workspaceId` is falsy whenever the active context has not resolved — and the\n * shell passes `activeContext.workspaceId ?? \"\"`, so \"not yet known\" arrives as\n * an empty string, which is falsy. Any render in that window produces a\n * confident, wrong answer.\n *\n * So `notReady` is returned separately and callers MUST NOT treat it as empty.\n * It is deliberately not folded into `loading`: a caller that shows a spinner is\n * right, and a caller that ignores it still cannot mistake it for \"none\".\n */\n\n// ─── Query Hooks ────────────────────────────────────────────────────────────\n\ninterface ConnectionFilterOptions {\n status?: ConnectionStatus;\n providerId?: string;\n search?: string;\n /** BOFF-9726: only the caller's own connections, or those shared with them. */\n access?: ConnectionAccessFilter;\n}\n\nexport function useConnections(filter?: ConnectionFilterOptions) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetConnectionsQuery({\n variables: { filter, pagination: { limit: 100 } },\n skip: !workspaceId,\n errorPolicy: 'all',\n });\n\n // ★ Keyed on the ABSENCE OF DATA, not on why it is absent. A skipped query, a\n // query still in flight and a query that resolved from an empty cache entry all\n // land here, and none of them is evidence that the workspace has no connections.\n const answered = data?.getConnections !== undefined;\n\n const connections: IntegrationConnection[] = (data?.getConnections?.items ?? []).map(\n (item: Record<string, unknown>) => mapConnection(item)\n );\n\n return {\n connections,\n total: data?.getConnections?.total ?? 0,\n loading,\n // ★ False until the server has actually told us. Callers MUST gate their\n // empty state on this — see the note above.\n answered,\n error,\n refetch,\n };\n}\n\nexport function useConnection(id: string) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetConnectionQuery({\n variables: { id },\n skip: !workspaceId || !id,\n errorPolicy: 'all',\n });\n\n const answered = data?.getConnection !== undefined;\n\n const connection: IntegrationConnection | null = data?.getConnection\n ? mapConnection(data.getConnection as Record<string, unknown>)\n : null;\n\n return { connection, loading, answered, error, refetch };\n}\n\nexport function useConnectionsByProvider(providerId: string) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useGetConnectionsByProviderQuery({\n variables: { providerId, pagination: { limit: 100 } },\n skip: !workspaceId || !providerId,\n errorPolicy: 'all',\n });\n\n const connections: IntegrationConnection[] = (data?.getConnectionsByProvider?.items ?? []).map(\n (item: Record<string, unknown>) => mapConnection(item)\n );\n\n return {\n connections,\n total: data?.getConnectionsByProvider?.total ?? 0,\n loading,\n error,\n refetch,\n };\n}\n\n// ─── Mutation Hooks ─────────────────────────────────────────────────────────\n\nexport function useCreateConnection() {\n const [mutate, { loading }] = useCreateConnectionMutation({\n refetchQueries: ['GetConnections'],\n });\n const eventBus = useIntegrationsEventBus();\n\n const createConnection = useCallback(\n async (input: {\n name: string;\n description?: string;\n providerId: string;\n authMethodKey?: string;\n vaultId?: string;\n credentialSecretId?: string;\n managedSecretName?: string;\n config?: Record<string, unknown>;\n }) => {\n const result = await mutate({ variables: { input } });\n const id = result.data?.createConnection?.id as string | undefined;\n if (id) {\n eventBus.emit('integrations:connection-created', {\n connectionId: id,\n providerKey: input.providerId,\n });\n }\n return id;\n },\n [mutate, eventBus]\n );\n\n return { createConnection, loading };\n}\n\nexport function useDeleteConnection() {\n const [mutate, { loading }] = useDeleteConnectionMutation({\n refetchQueries: ['GetConnections'],\n });\n const eventBus = useIntegrationsEventBus();\n\n const deleteConnection = useCallback(\n async (id: string, deleteVaultSecret = false) => {\n await mutate({ variables: { id, deleteVaultSecret } });\n eventBus.emit('integrations:connection-deleted', { connectionId: id });\n },\n [mutate, eventBus]\n );\n\n return { deleteConnection, loading };\n}\n\n/**\n * BOFF-13612: let self-hosted FluidGrids workers receive a connection's\n * long-lived credential, or stop them. Workspace administrators only; the\n * answer updates the cached connection, so the detail page re-renders.\n */\nexport function useSetConnectionSelfHostedRelease() {\n const [mutate, { loading }] = useSetConnectionSelfHostedReleaseMutation();\n\n const setSelfHostedRelease = useCallback(\n async (connectionId: string, allow: boolean): Promise<boolean> => {\n const result = await mutate({ variables: { connectionId, allow } });\n const updated = result.data?.setConnectionSelfHostedRelease;\n if (!updated) throw new Error('The connection did not answer with its new setting');\n return updated.allowSelfHosted;\n },\n [mutate]\n );\n\n return { setSelfHostedRelease, loading };\n}\n\nexport function useInitiateOAuth() {\n const [mutate, { loading }] = useInitiateOAuthMutation();\n const eventBus = useIntegrationsEventBus();\n\n const initiateOAuth = useCallback(\n async (\n connectionId: string,\n redirectUri: string,\n providerKey: string,\n scopes?: string[]\n ): Promise<OAuthInitiationResult | null> => {\n eventBus.emit('integrations:oauth-started', { connectionId, providerKey });\n const result = await mutate({ variables: { input: { connectionId, redirectUri, scopes } } });\n if (result.error) {\n eventBus.emit('integrations:oauth-failed', {\n connectionId,\n providerKey,\n error: result.error.message,\n });\n }\n return result.data?.initiateOAuth ?? null;\n },\n [mutate, eventBus]\n );\n\n return { initiateOAuth, loading };\n}\n\n/**\n * Authenticate a connection with values shaped by its auth method's schema.\n *\n * Generic replacement for the per-auth-type hooks below: the caller passes\n * whatever the rendered form collected, so a new auth type needs no new hook,\n * no new mutation document and no new branch at the call site.\n */\nexport function useAuthenticateConnection() {\n const [mutate, { loading }] = useAuthenticateConnectionMutation({\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateConnection = useCallback(\n async (\n connectionId: string,\n authMethodKey: string | undefined,\n values: Record<string, unknown>\n ) => {\n const result = await mutate({\n variables: { input: { connectionId, authMethodKey, values } },\n });\n return result.data?.authenticateConnection;\n },\n [mutate]\n );\n\n return { authenticateConnection, loading };\n}\n\nexport function useAuthenticateWithApiKey() {\n const [mutate, { loading }] = useAuthenticateWithApiKeyMutation({\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithApiKey = useCallback(\n async (connectionId: string, apiKey: string) => {\n const result = await mutate({ variables: { input: { connectionId, apiKey } } });\n return result.data?.authenticateWithApiKey;\n },\n [mutate]\n );\n\n return { authenticateWithApiKey, loading };\n}\n\nexport function useAuthenticateWithBasicAuth() {\n const [mutate, { loading }] = useAuthenticateWithBasicAuthMutation({\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithBasicAuth = useCallback(\n async (connectionId: string, username: string, password: string) => {\n const result = await mutate({ variables: { input: { connectionId, username, password } } });\n return result.data?.authenticateWithBasicAuth;\n },\n [mutate]\n );\n\n return { authenticateWithBasicAuth, loading };\n}\n\nexport function useAuthenticateWithBearerToken() {\n const [mutate, { loading }] = useAuthenticateWithBearerTokenMutation({\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithBearerToken = useCallback(\n async (connectionId: string, token: string) => {\n const result = await mutate({ variables: { input: { connectionId, token } } });\n return result.data?.authenticateWithBearerToken;\n },\n [mutate]\n );\n\n return { authenticateWithBearerToken, loading };\n}\n\n/**\n * GraphQL document for the first-party SERVICE_ACCOUNT auth flow. Defined inline\n * (rather than via codegen) so it does not depend on a fresh `schema:pull` from\n * a gateway that already exposes the new `authenticateWithServiceAccount`\n * mutation. Once the gateway supergraph includes it, this can be migrated to an\n * `src/operations/...` document like the other mutations.\n */\nconst AUTHENTICATE_WITH_SERVICE_ACCOUNT = gql`\n mutation AuthenticateWithServiceAccount($input: ServiceAccountAuthInput!) {\n authenticateWithServiceAccount(input: $input) {\n id\n status\n }\n }\n`;\n\n/**\n * Connect a first-party SERVICE_ACCOUNT provider (e.g. Burdenoff). No user\n * credentials are collected — the platform mints an app-as-user token per\n * execution. Calling this records the user's consent (delegation) for the\n * reserved app and activates the connection.\n */\nexport function useAuthenticateWithServiceAccount() {\n const [mutate, { loading }] = useMutation<\n { authenticateWithServiceAccount: { id: string; status: ConnectionStatus } },\n { input: { connectionId: string; scopes?: string[] } }\n >(AUTHENTICATE_WITH_SERVICE_ACCOUNT, {\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithServiceAccount = useCallback(\n async (connectionId: string, scopes?: string[]) => {\n const result = await mutate({ variables: { input: { connectionId, scopes } } });\n return result.data?.authenticateWithServiceAccount;\n },\n [mutate]\n );\n\n return { authenticateWithServiceAccount, loading };\n}\n\n/**\n * GraphQL document for CUSTOM provider auth (configSchema-driven config, e.g.\n * Google Workspace Admin domain-wide delegation). Defined inline (rather than\n * via codegen) so it does not depend on a fresh `schema:pull` from a gateway\n * that already exposes the new `authenticateWithCustomConfig` mutation. Once\n * the gateway supergraph includes it, this can be migrated to an\n * `src/operations/...` document like the other mutations.\n */\nconst AUTHENTICATE_WITH_CUSTOM_CONFIG = gql`\n mutation AuthenticateWithCustomConfig($input: CustomConfigAuthInput!) {\n authenticateWithCustomConfig(input: $input) {\n id\n status\n }\n }\n`;\n\n/**\n * Connect a CUSTOM provider with a configSchema-shaped config object. The full\n * config is stored inside the encrypted credential payload (secrets never hit\n * plain columns); the connection becomes ACTIVE immediately.\n */\nexport function useAuthenticateWithCustomConfig() {\n const [mutate, { loading }] = useMutation<\n { authenticateWithCustomConfig: { id: string; status: ConnectionStatus } },\n { input: { connectionId: string; config: Record<string, unknown> } }\n >(AUTHENTICATE_WITH_CUSTOM_CONFIG, {\n refetchQueries: ['GetConnection'],\n });\n\n const authenticateWithCustomConfig = useCallback(\n async (connectionId: string, config: Record<string, unknown>) => {\n const result = await mutate({ variables: { input: { connectionId, config } } });\n return result.data?.authenticateWithCustomConfig;\n },\n [mutate]\n );\n\n return { authenticateWithCustomConfig, loading };\n}\n\nexport function useRefreshToken() {\n const [mutate, { loading }] = useRefreshConnectionTokenMutation({\n refetchQueries: ['GetConnection'],\n });\n const eventBus = useIntegrationsEventBus();\n\n const refreshToken = useCallback(\n async (connectionId: string) => {\n const result = await mutate({ variables: { connectionId } });\n if (result.data?.refreshConnectionToken) {\n eventBus.emit('integrations:token-refreshed', { connectionId });\n }\n return result.data?.refreshConnectionToken;\n },\n [mutate, eventBus]\n );\n\n return { refreshToken, loading };\n}\n\nexport function useRevokeConnection() {\n const [mutate, { loading }] = useRevokeConnectionMutation({\n refetchQueries: ['GetConnection'],\n });\n const eventBus = useIntegrationsEventBus();\n\n const revokeConnection = useCallback(\n async (connectionId: string) => {\n const result = await mutate({ variables: { connectionId } });\n if (result.data?.revokeConnection) {\n eventBus.emit('integrations:token-revoked', { connectionId });\n }\n return result.data?.revokeConnection;\n },\n [mutate, eventBus]\n );\n\n return { revokeConnection, loading };\n}\n\nexport function useTestConnection() {\n const [mutate, { loading }] = useTestConnectionMutation();\n\n const testConnection = useCallback(\n async (connectionId: string): Promise<ConnectionTestResult | null> => {\n const result = await mutate({ variables: { connectionId } });\n return result.data?.testConnection ?? null;\n },\n [mutate]\n );\n\n return { testConnection, loading };\n}\n"],"mappings":";;;;;;;;AAqEA,SAAgBA,EAAe,GAAkC;CAC/D,IAAM,EAAE,mBAAgBC,EAAgB,GAClC,EAAE,SAAM,YAAS,UAAO,eAAYC,EAAuB;EAC/D,WAAW;GAAE;GAAQ,YAAY,EAAE,OAAO,IAAI;EAAE;EAChD,MAAM,CAACC;EACP,aAAa;CACf,CAAC,GAKKC,IAAWC,GAAM,mBAAmB,KAAA;CAM1C,OAAO;EACL,cAL4CA,GAAM,gBAAgB,SAAS,CAAC,EAAA,CAAG,KAC9E,MAAkCC,EAAcC,CAAI,CAIrD;EACA,OAAOF,GAAM,gBAAgB,SAAS;EACtC;EAGA;EACA;EACA;CACF;AACF;AAEA,SAAgBG,EAAc,GAAY;CACxC,IAAM,EAAE,mBAAgBP,EAAgB,GAClC,EAAE,SAAM,YAAS,UAAO,eAAYQ,EAAsB;EAC9D,WAAW,EAAE,MAAG;EAChB,MAAM,CAACN,KAAe,CAACO;EACvB,aAAa;CACf,CAAC,GAEKN,IAAWC,GAAM,kBAAkB,KAAA;CAMzC,OAAO;EAAE,YAJwCA,GAAM,gBACnDC,EAAcD,EAAK,aAAwC,IAC3D;EAEiB;EAAS;EAAU;EAAO;CAAQ;AACzD;AAEA,SAAgBM,EAAyB,GAAoB;CAC3D,IAAM,EAAE,mBAAgBV,EAAgB,GAClC,EAAE,SAAM,YAAS,UAAO,eAAYW,EAAiC;EACzE,WAAW;GAAE;GAAY,YAAY,EAAE,OAAO,IAAI;EAAE;EACpD,MAAM,CAACT,KAAe,CAACU;EACvB,aAAa;CACf,CAAC;CAMD,OAAO;EACL,cAL4CR,GAAM,0B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