@burdenoff/microfe-subscriberbot 2026.628.1 → 2026.706.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/subscriberbot/SubscriberBotRoot.js.map +1 -1
- package/dist/subscriberbot/components/StateViews.js.map +1 -1
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js +91 -90
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
- package/dist/subscriberbot/pages/DashboardPage.js.map +1 -1
- package/dist/subscriberbot/pages/InboxPage.js.map +1 -1
- package/dist/subscriberbot/pages/WorkflowsPage.js.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentsListPage.js.map +1 -1
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriberBotRoot.js","names":[],"sources":["../../src/subscriberbot/SubscriberBotRoot.tsx"],"sourcesContent":["/**\n * SubscriberBot Root Component\n * @module subscriberbot\n */\n\nimport type { FC } from 'react';\nimport { useCallback, useEffect } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {
|
|
1
|
+
{"version":3,"file":"SubscriberBotRoot.js","names":[],"sources":["../../src/subscriberbot/SubscriberBotRoot.tsx"],"sourcesContent":["/**\n * SubscriberBot Root Component\n * @module subscriberbot\n */\n\nimport type { FC } from 'react';\nimport { useCallback, useEffect } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { LayoutDashboard, Repeat2, Building2, Inbox, Receipt, Bot, Workflow } from 'lucide-react';\nimport { SubscriberBotProvider } from './context/SubscriberBotContext';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { SubscriberBotRoutes } from './SubscriberBotRoutes';\nimport type { SubscriberBotRootProps, NavItem } from './types';\n\n// Create a query client for this microfrontend\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 5 * 60 * 1000,\n retry: 1,\n },\n },\n});\n\nexport const SubscriberBotRoot: FC<SubscriberBotRootProps> = (props) => {\n const { registerNavItems, registerFooterItems, basePath = '/' } = props;\n const { t: translate } = useI18n();\n const t = useCallback(\n (key: string, fallback: string): string => {\n const value = translate(key);\n return value === key ? fallback : value;\n },\n [translate]\n );\n\n // Helper to join paths correctly\n const joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n };\n\n // Register navigation items with shell on mount\n useEffect(() => {\n if (!registerNavItems) return;\n\n const navItems: NavItem[] = [\n {\n id: 'subscriberbot-overview',\n label: t('subscriberbot.nav.overview', 'Overview'),\n path: joinPath(basePath, ''),\n icon: <LayoutDashboard size={20} />,\n order: 1,\n group: 'subscriberbot',\n },\n {\n id: 'subscriberbot-relationships',\n label: t('subscriberbot.nav.relationships', 'Relationships'),\n path: joinPath(basePath, 'relationships'),\n icon: <Repeat2 size={20} />,\n order: 2,\n group: 'subscriberbot',\n },\n {\n id: 'subscriberbot-providers',\n label: t('subscriberbot.nav.providers', 'Providers'),\n path: joinPath(basePath, 'providers'),\n icon: <Building2 size={20} />,\n order: 3,\n group: 'subscriberbot',\n },\n {\n id: 'subscriberbot-inbox',\n label: t('subscriberbot.nav.inbox', 'Universal Inbox'),\n path: joinPath(basePath, 'inbox'),\n icon: <Inbox size={20} />,\n order: 4,\n group: 'subscriberbot',\n },\n {\n id: 'subscriberbot-invoices',\n label: t('subscriberbot.nav.invoices', 'Invoices'),\n path: joinPath(basePath, 'invoices'),\n icon: <Receipt size={20} />,\n order: 5,\n group: 'subscriberbot',\n },\n {\n id: 'subscriberbot-agents',\n label: t('subscriberbot.nav.agents', 'AI Agents'),\n path: joinPath(basePath, 'agents'),\n icon: <Bot size={20} />,\n order: 6,\n group: 'subscriberbot',\n },\n {\n id: 'subscriberbot-workflows',\n label: t('subscriberbot.nav.workflows', 'Workflows'),\n path: joinPath(basePath, 'workflows'),\n icon: <Workflow size={20} />,\n order: 7,\n group: 'subscriberbot',\n },\n ];\n\n const cleanup = registerNavItems(navItems);\n return cleanup;\n }, [registerNavItems, basePath, t]);\n\n // Register footer items\n useEffect(() => {\n if (!registerFooterItems) return;\n\n const footerItems = [\n {\n id: 'subscriberbot-status',\n label: t('subscriberbot.footer.ready', 'SubscriberBot Ready'),\n type: 'status' as const,\n order: 10,\n section: 'left' as const,\n },\n ];\n\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems, t]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <SubscriberBotProvider {...props}>\n <SubscriberBotRoutes />\n </SubscriberBotProvider>\n </FeatureFlagProvider>\n </QueryClientProvider>\n );\n};\n"],"mappings":";;;;;;;;;AAgBA,IAAM,IAAc,IAAI,EAAY,EAClC,gBAAgB,EACd,SAAS;CACP,WAAW,MAAS;CACpB,OAAO;CACR,EACF,EACF,CAAC,EAEW,KAAiD,MAAU;CACtE,IAAM,EAAE,qBAAkB,wBAAqB,cAAW,QAAQ,GAC5D,EAAE,GAAG,MAAc,GAAS,EAC5B,IAAI,GACP,GAAa,MAA6B;EACzC,IAAM,IAAQ,EAAU,EAAI;AAC5B,SAAO,MAAU,IAAM,IAAW;IAEpC,CAAC,EAAU,CACZ,EAGK,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM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;EAAC;EAAkB;EAAU;EAAE,CAAC,EAGnC,QAAgB;AACT,QAaL,QADgB,EAVI,CAClB;GACE,IAAI;GACJ,OAAO,EAAE,8BAA8B,sBAAsB;GAC7D,MAAM;GACN,OAAO;GACP,SAAS;GACV,CACF,CAE+C;IAE/C,CAAC,GAAqB,EAAE,CAAC,EAG1B,kBAAC,GAAD;EAAqB,QAAQ;YAC3B,kBAAC,GAAD;GAAqB,aAAa;GAAM,SAAQ;GAAS,gBAAgB;aACvE,kBAAC,GAAD;IAAuB,GAAI;cACzB,kBAAC,GAAD,EAAuB,CAAA;IACD,CAAA;GACJ,CAAA;EACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateViews.js","names":[],"sources":["../../../src/subscriberbot/components/StateViews.tsx"],"sourcesContent":["/**\n * Shared loading / error state views\n * @module subscriberbot/components\n *\n * Small reusable building blocks so every page renders consistent\n * loading / error / empty states without re-implementing them.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { AlertCircle } from 'lucide-react';\nimport { Spinner } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\n\ninterface LoadingViewProps {\n label?: string;\n className?: string;\n}\n\nexport const LoadingView: FC<LoadingViewProps> = ({ label = 'Loading…', className }) => (\n <div className={cn('flex min-h-[40vh] flex-col items-center justify-center gap-3', className)}>\n <Spinner size=\"lg\" />\n <p className=\"text-sm text-text-secondary\">{label}</p>\n </div>\n);\n\ninterface ErrorViewProps {\n title?: string;\n message?: string;\n onRetry?: () => void;\n className?: string;\n}\n\nexport const ErrorView: FC<ErrorViewProps> = ({\n title = 'Something went wrong',\n message,\n onRetry,\n className,\n}) => (\n <div\n className={cn('flex min-h-[40vh] flex-col items-center justify-center gap-4 text-center'
|
|
1
|
+
{"version":3,"file":"StateViews.js","names":[],"sources":["../../../src/subscriberbot/components/StateViews.tsx"],"sourcesContent":["/**\n * Shared loading / error state views\n * @module subscriberbot/components\n *\n * Small reusable building blocks so every page renders consistent\n * loading / error / empty states without re-implementing them.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { AlertCircle } from 'lucide-react';\nimport { Spinner } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\n\ninterface LoadingViewProps {\n label?: string;\n className?: string;\n}\n\nexport const LoadingView: FC<LoadingViewProps> = ({ label = 'Loading…', className }) => (\n <div className={cn('flex min-h-[40vh] flex-col items-center justify-center gap-3', className)}>\n <Spinner size=\"lg\" />\n <p className=\"text-sm text-text-secondary\">{label}</p>\n </div>\n);\n\ninterface ErrorViewProps {\n title?: string;\n message?: string;\n onRetry?: () => void;\n className?: string;\n}\n\nexport const ErrorView: FC<ErrorViewProps> = ({\n title = 'Something went wrong',\n message,\n onRetry,\n className,\n}) => (\n <div\n className={cn(\n 'flex min-h-[40vh] flex-col items-center justify-center gap-4 text-center',\n className\n )}\n >\n <AlertCircle className=\"h-10 w-10 text-status-error-text\" />\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">{title}</h2>\n {message && <p className=\"mt-1 max-w-md text-sm text-text-secondary\">{message}</p>}\n </div>\n {onRetry && (\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n Retry\n </button>\n )}\n </div>\n);\n\ninterface SectionProps {\n title: string;\n description?: string;\n action?: ReactNode;\n children: ReactNode;\n className?: string;\n}\n\nexport const Section: FC<SectionProps> = ({ title, description, action, children, className }) => (\n <section className={cn('mt-8 first:mt-0', className)}>\n <div className=\"mb-3 flex items-end justify-between gap-3\">\n <div>\n <h2 className=\"text-base font-semibold text-text-primary\">{title}</h2>\n {description && <p className=\"mt-0.5 text-sm text-text-secondary\">{description}</p>}\n </div>\n {action && <div className=\"shrink-0\">{action}</div>}\n </div>\n {children}\n </section>\n);\n"],"mappings":";;;;;AAkBA,IAAa,KAAqC,EAAE,WAAQ,YAAY,mBACtE,kBAAC,OAAD;CAAK,WAAW,EAAG,gEAAgE,EAAU;WAA7F,CACE,kBAAC,GAAD,EAAS,MAAK,MAAO,CAAA,EACrB,kBAAC,KAAD;EAAG,WAAU;YAA+B;EAAU,CAAA,CAClD;IAUK,KAAiC,EAC5C,WAAQ,wBACR,YACA,YACA,mBAEA,kBAAC,OAAD;CACE,WAAW,EACT,4EACA,EACD;WAJH;EAME,kBAAC,GAAD,EAAa,WAAU,oCAAqC,CAAA;EAC5D,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;GAAI,WAAU;aAA2C;GAAW,CAAA,EACnE,KAAW,kBAAC,KAAD;GAAG,WAAU;aAA6C;GAAY,CAAA,CAC9E,EAAA,CAAA;EACL,KACC,kBAAC,UAAD;GACE,MAAK;GACL,SAAS;GACT,WAAU;aACX;GAEQ,CAAA;EAEP;IAWK,KAA6B,EAAE,UAAO,gBAAa,WAAQ,aAAU,mBAChF,kBAAC,WAAD;CAAS,WAAW,EAAG,mBAAmB,EAAU;WAApD,CACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;GAAI,WAAU;aAA6C;GAAW,CAAA,EACrE,KAAe,kBAAC,KAAD;GAAG,WAAU;aAAsC;GAAgB,CAAA,CAC/E,EAAA,CAAA,EACL,KAAU,kBAAC,OAAD;GAAK,WAAU;aAAY;GAAa,CAAA,CAC/C;KACL,EACO"}
|
|
@@ -2,8 +2,9 @@ import { useSubscriberBot as e } from "../context/SubscriberBotContext.js";
|
|
|
2
2
|
import "../context/index.js";
|
|
3
3
|
import { useMutation as t, useQuery as n, useQueryClient as r } from "@tanstack/react-query";
|
|
4
4
|
import { graphqlFetch as i } from "@burdenoff/fe-libs/shared/graphql";
|
|
5
|
+
import { clearGraphqlFetchResponseCache as a } from "@burdenoff/fe-libs/shared/graphql/fetch";
|
|
5
6
|
//#region src/subscriberbot/hooks/useSubscriberBotApi.ts
|
|
6
|
-
var
|
|
7
|
+
var o = async (e, t, n) => {
|
|
7
8
|
let r = await i({
|
|
8
9
|
gateway: "workspace",
|
|
9
10
|
baseUrl: n,
|
|
@@ -13,8 +14,8 @@ var a = async (e, t, n) => {
|
|
|
13
14
|
});
|
|
14
15
|
if (r.errors?.length) throw Error(r.errors[0]?.message ?? "GraphQL request failed");
|
|
15
16
|
if (!r.data) throw Error("GraphQL response did not include data");
|
|
16
|
-
return r.data;
|
|
17
|
-
},
|
|
17
|
+
return /^\s*mutation\b/.test(e) && a(), r.data;
|
|
18
|
+
}, s = {
|
|
18
19
|
relationships: ["subscriberbot", "relationships"],
|
|
19
20
|
relationship: (e) => [
|
|
20
21
|
"subscriberbot",
|
|
@@ -42,11 +43,11 @@ var a = async (e, t, n) => {
|
|
|
42
43
|
renewals: ["subscriberbot", "renewals"],
|
|
43
44
|
assets: ["subscriberbot", "assets"],
|
|
44
45
|
entitlements: ["subscriberbot", "entitlements"]
|
|
45
|
-
},
|
|
46
|
+
}, c = "\n id name slug category status description industry region language websiteUrl\n logoFileId tags churnRiskScore vendorHealthScore workspaceId createdAt updatedAt\n", l = "\n id name description providerId amount currency interval features isActive\n workspaceId createdAt updatedAt\n", u = "\n id label kind status amount currency interval autoRenew discoverySource notes\n tags healthScore ownerId providerId planId startedAt renewsAt trialEndsAt\n cancelledAt workspaceId createdAt updatedAt\n", d = "\n id subject preview category categoryConfidence channelId relationshipId\n externalId actionRequired isRead receivedAt workspaceId createdAt updatedAt\n", f = "\n id number relationshipId status currency subtotal taxAmount total issueDate\n dueDate paidAt paymentInstrumentId workspaceId createdAt updatedAt\n", p = "\n id name description kind status ownerId lastRunAt workspaceId createdAt updatedAt\n", m = "\n id name description triggerEvent status runCount lastRunAt workspaceId\n createdAt updatedAt\n", h = (t = {}) => {
|
|
46
47
|
let { apiGatewayUrl: r } = e();
|
|
47
48
|
return n({
|
|
48
|
-
queryKey: [...
|
|
49
|
-
queryFn: async () => (await
|
|
49
|
+
queryKey: [...s.relationships, t],
|
|
50
|
+
queryFn: async () => (await o(`query SubRelationships(
|
|
50
51
|
$kind: SubRelationshipKind
|
|
51
52
|
$status: SubRelationshipStatus
|
|
52
53
|
$providerId: ID
|
|
@@ -61,7 +62,7 @@ var a = async (e, t, n) => {
|
|
|
61
62
|
pagination: $pagination
|
|
62
63
|
) {
|
|
63
64
|
items {
|
|
64
|
-
${
|
|
65
|
+
${u}
|
|
65
66
|
provider { id name category status logoFileId }
|
|
66
67
|
plan { id name amount currency interval }
|
|
67
68
|
}
|
|
@@ -78,16 +79,16 @@ var a = async (e, t, n) => {
|
|
|
78
79
|
}
|
|
79
80
|
}, r)).subListRelationships
|
|
80
81
|
});
|
|
81
|
-
},
|
|
82
|
+
}, g = (t) => {
|
|
82
83
|
let { apiGatewayUrl: r } = e();
|
|
83
84
|
return n({
|
|
84
|
-
queryKey:
|
|
85
|
+
queryKey: s.relationship(t ?? ""),
|
|
85
86
|
enabled: !!t,
|
|
86
|
-
queryFn: async () => (await
|
|
87
|
+
queryFn: async () => (await o(`query SubRelationship($id: ID!) {
|
|
87
88
|
subRelationship(id: $id) {
|
|
88
|
-
${
|
|
89
|
-
provider { ${
|
|
90
|
-
plan { ${
|
|
89
|
+
${u}
|
|
90
|
+
provider { ${c} }
|
|
91
|
+
plan { ${l} }
|
|
91
92
|
entitlements {
|
|
92
93
|
id name description type relationshipId quota used unit isActive
|
|
93
94
|
workspaceId createdAt updatedAt
|
|
@@ -103,53 +104,53 @@ var a = async (e, t, n) => {
|
|
|
103
104
|
}
|
|
104
105
|
}`, { id: t }, r)).subRelationship
|
|
105
106
|
});
|
|
106
|
-
},
|
|
107
|
+
}, _ = () => {
|
|
107
108
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
108
109
|
return t({
|
|
109
|
-
mutationFn: async (e) => (await
|
|
110
|
-
subCreateRelationship(input: $input) { ${
|
|
110
|
+
mutationFn: async (e) => (await o(`mutation SubCreateRelationship($input: SubCreateRelationshipInput!) {
|
|
111
|
+
subCreateRelationship(input: $input) { ${u} }
|
|
111
112
|
}`, { input: e }, i)).subCreateRelationship,
|
|
112
113
|
onSuccess: () => {
|
|
113
|
-
n.invalidateQueries({ queryKey:
|
|
114
|
+
n.invalidateQueries({ queryKey: s.relationships });
|
|
114
115
|
}
|
|
115
116
|
});
|
|
116
|
-
},
|
|
117
|
+
}, v = () => {
|
|
117
118
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
118
119
|
return t({
|
|
119
|
-
mutationFn: async ({ id: e, status: t }) => (await
|
|
120
|
-
subTransitionRelationship(id: $id, status: $status) { ${
|
|
120
|
+
mutationFn: async ({ id: e, status: t }) => (await o(`mutation SubTransitionRelationship($id: ID!, $status: SubRelationshipStatus!) {
|
|
121
|
+
subTransitionRelationship(id: $id, status: $status) { ${u} }
|
|
121
122
|
}`, {
|
|
122
123
|
id: e,
|
|
123
124
|
status: t
|
|
124
125
|
}, i)).subTransitionRelationship,
|
|
125
126
|
onSuccess: (e) => {
|
|
126
|
-
n.invalidateQueries({ queryKey:
|
|
127
|
+
n.invalidateQueries({ queryKey: s.relationships }), n.invalidateQueries({ queryKey: s.relationship(e.id) });
|
|
127
128
|
}
|
|
128
129
|
});
|
|
129
|
-
},
|
|
130
|
+
}, y = () => {
|
|
130
131
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
131
132
|
return t({
|
|
132
|
-
mutationFn: async (e) => (await
|
|
133
|
-
subCancelRelationship(id: $id) { ${
|
|
133
|
+
mutationFn: async (e) => (await o(`mutation SubCancelRelationship($id: ID!) {
|
|
134
|
+
subCancelRelationship(id: $id) { ${u} }
|
|
134
135
|
}`, { id: e }, i)).subCancelRelationship,
|
|
135
136
|
onSuccess: (e) => {
|
|
136
|
-
n.invalidateQueries({ queryKey:
|
|
137
|
+
n.invalidateQueries({ queryKey: s.relationships }), n.invalidateQueries({ queryKey: s.relationship(e.id) });
|
|
137
138
|
}
|
|
138
139
|
});
|
|
139
|
-
},
|
|
140
|
+
}, b = (t = {}) => {
|
|
140
141
|
let { apiGatewayUrl: r } = e();
|
|
141
142
|
return n({
|
|
142
|
-
queryKey: [...
|
|
143
|
-
queryFn: async () => (await
|
|
143
|
+
queryKey: [...s.renewals, t],
|
|
144
|
+
queryFn: async () => (await o("query SubRenewalEvents($relationshipId: ID, $upcomingOnly: Boolean) {\n subListRenewalEvents(relationshipId: $relationshipId, upcomingOnly: $upcomingOnly) {\n id relationshipId eventType occursAt amount currency detail notified\n workspaceId createdAt updatedAt\n }\n }", {
|
|
144
145
|
relationshipId: t.relationshipId,
|
|
145
146
|
upcomingOnly: t.upcomingOnly
|
|
146
147
|
}, r)).subListRenewalEvents
|
|
147
148
|
});
|
|
148
|
-
},
|
|
149
|
+
}, x = (t = {}) => {
|
|
149
150
|
let { apiGatewayUrl: r } = e();
|
|
150
151
|
return n({
|
|
151
|
-
queryKey: [...
|
|
152
|
-
queryFn: async () => (await
|
|
152
|
+
queryKey: [...s.providers, t],
|
|
153
|
+
queryFn: async () => (await o(`query SubProviders(
|
|
153
154
|
$category: SubProviderCategory
|
|
154
155
|
$status: SubProviderStatus
|
|
155
156
|
$search: String
|
|
@@ -161,7 +162,7 @@ var a = async (e, t, n) => {
|
|
|
161
162
|
search: $search
|
|
162
163
|
pagination: $pagination
|
|
163
164
|
) {
|
|
164
|
-
items { ${
|
|
165
|
+
items { ${c} }
|
|
165
166
|
pageInfo { cursor hasMore }
|
|
166
167
|
}
|
|
167
168
|
}`, {
|
|
@@ -174,42 +175,42 @@ var a = async (e, t, n) => {
|
|
|
174
175
|
}
|
|
175
176
|
}, r)).subListProviders
|
|
176
177
|
});
|
|
177
|
-
},
|
|
178
|
+
}, S = (t) => {
|
|
178
179
|
let { apiGatewayUrl: r } = e();
|
|
179
180
|
return n({
|
|
180
|
-
queryKey:
|
|
181
|
+
queryKey: s.provider(t ?? ""),
|
|
181
182
|
enabled: !!t,
|
|
182
|
-
queryFn: async () => (await
|
|
183
|
+
queryFn: async () => (await o(`query SubProvider($id: ID!) {
|
|
183
184
|
subProvider(id: $id) {
|
|
184
|
-
${
|
|
185
|
-
plans { ${
|
|
185
|
+
${c}
|
|
186
|
+
plans { ${l} }
|
|
186
187
|
}
|
|
187
188
|
}`, { id: t }, r)).subProvider
|
|
188
189
|
});
|
|
189
|
-
},
|
|
190
|
+
}, C = () => {
|
|
190
191
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
191
192
|
return t({
|
|
192
|
-
mutationFn: async (e) => (await
|
|
193
|
-
subCreateProvider(input: $input) { ${
|
|
193
|
+
mutationFn: async (e) => (await o(`mutation SubCreateProvider($input: SubCreateProviderInput!) {
|
|
194
|
+
subCreateProvider(input: $input) { ${c} }
|
|
194
195
|
}`, { input: e }, i)).subCreateProvider,
|
|
195
196
|
onSuccess: () => {
|
|
196
|
-
n.invalidateQueries({ queryKey:
|
|
197
|
+
n.invalidateQueries({ queryKey: s.providers });
|
|
197
198
|
}
|
|
198
199
|
});
|
|
199
|
-
},
|
|
200
|
+
}, w = (t) => {
|
|
200
201
|
let { apiGatewayUrl: r } = e();
|
|
201
202
|
return n({
|
|
202
|
-
queryKey: [...
|
|
203
|
+
queryKey: [...s.plans, t],
|
|
203
204
|
enabled: !!t,
|
|
204
|
-
queryFn: async () => (await
|
|
205
|
-
subListPlans(providerId: $providerId) { ${
|
|
205
|
+
queryFn: async () => (await o(`query SubPlans($providerId: ID) {
|
|
206
|
+
subListPlans(providerId: $providerId) { ${l} }
|
|
206
207
|
}`, { providerId: t }, r)).subListPlans
|
|
207
208
|
});
|
|
208
|
-
},
|
|
209
|
+
}, T = (t = {}) => {
|
|
209
210
|
let { apiGatewayUrl: r } = e();
|
|
210
211
|
return n({
|
|
211
|
-
queryKey: [...
|
|
212
|
-
queryFn: async () => (await
|
|
212
|
+
queryKey: [...s.inbox, t],
|
|
213
|
+
queryFn: async () => (await o(`query SubInboxMessages(
|
|
213
214
|
$category: SubMessageCategory
|
|
214
215
|
$channelId: ID
|
|
215
216
|
$relationshipId: ID
|
|
@@ -223,7 +224,7 @@ var a = async (e, t, n) => {
|
|
|
223
224
|
unreadOnly: $unreadOnly
|
|
224
225
|
pagination: $pagination
|
|
225
226
|
) {
|
|
226
|
-
items { ${
|
|
227
|
+
items { ${d} }
|
|
227
228
|
pageInfo { cursor hasMore }
|
|
228
229
|
}
|
|
229
230
|
}`, {
|
|
@@ -237,21 +238,21 @@ var a = async (e, t, n) => {
|
|
|
237
238
|
}
|
|
238
239
|
}, r)).subListInboxMessages
|
|
239
240
|
});
|
|
240
|
-
},
|
|
241
|
+
}, E = () => {
|
|
241
242
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
242
243
|
return t({
|
|
243
|
-
mutationFn: async (e) => (await
|
|
244
|
-
subMarkMessageRead(id: $id) { ${
|
|
244
|
+
mutationFn: async (e) => (await o(`mutation SubMarkMessageRead($id: ID!) {
|
|
245
|
+
subMarkMessageRead(id: $id) { ${d} }
|
|
245
246
|
}`, { id: e }, i)).subMarkMessageRead,
|
|
246
247
|
onSuccess: () => {
|
|
247
|
-
n.invalidateQueries({ queryKey:
|
|
248
|
+
n.invalidateQueries({ queryKey: s.inbox });
|
|
248
249
|
}
|
|
249
250
|
});
|
|
250
|
-
},
|
|
251
|
+
}, D = (t = {}) => {
|
|
251
252
|
let { apiGatewayUrl: r } = e();
|
|
252
253
|
return n({
|
|
253
|
-
queryKey: [...
|
|
254
|
-
queryFn: async () => (await
|
|
254
|
+
queryKey: [...s.invoices, t],
|
|
255
|
+
queryFn: async () => (await o(`query SubInvoices(
|
|
255
256
|
$status: SubInvoiceStatus
|
|
256
257
|
$relationshipId: ID
|
|
257
258
|
$pagination: PaginationInput
|
|
@@ -261,7 +262,7 @@ var a = async (e, t, n) => {
|
|
|
261
262
|
relationshipId: $relationshipId
|
|
262
263
|
pagination: $pagination
|
|
263
264
|
) {
|
|
264
|
-
items { ${
|
|
265
|
+
items { ${f} }
|
|
265
266
|
pageInfo { cursor hasMore }
|
|
266
267
|
}
|
|
267
268
|
}`, {
|
|
@@ -273,23 +274,23 @@ var a = async (e, t, n) => {
|
|
|
273
274
|
}
|
|
274
275
|
}, r)).subListInvoices
|
|
275
276
|
});
|
|
276
|
-
},
|
|
277
|
+
}, O = () => {
|
|
277
278
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
278
279
|
return t({
|
|
279
|
-
mutationFn: async (e) => (await
|
|
280
|
-
subMarkInvoicePaid(id: $id) { ${
|
|
280
|
+
mutationFn: async (e) => (await o(`mutation SubMarkInvoicePaid($id: ID!) {
|
|
281
|
+
subMarkInvoicePaid(id: $id) { ${f} }
|
|
281
282
|
}`, { id: e }, i)).subMarkInvoicePaid,
|
|
282
283
|
onSuccess: () => {
|
|
283
|
-
n.invalidateQueries({ queryKey:
|
|
284
|
+
n.invalidateQueries({ queryKey: s.invoices });
|
|
284
285
|
}
|
|
285
286
|
});
|
|
286
|
-
},
|
|
287
|
+
}, k = (t = {}) => {
|
|
287
288
|
let { apiGatewayUrl: r } = e();
|
|
288
289
|
return n({
|
|
289
|
-
queryKey: [...
|
|
290
|
-
queryFn: async () => (await
|
|
290
|
+
queryKey: [...s.agents, t],
|
|
291
|
+
queryFn: async () => (await o(`query SubAgents($kind: SubAgentKind, $status: SubAgentStatus, $ownerId: ID) {
|
|
291
292
|
subListAgents(kind: $kind, status: $status, ownerId: $ownerId) {
|
|
292
|
-
${
|
|
293
|
+
${p}
|
|
293
294
|
}
|
|
294
295
|
}`, {
|
|
295
296
|
kind: t.kind,
|
|
@@ -297,14 +298,14 @@ var a = async (e, t, n) => {
|
|
|
297
298
|
ownerId: t.ownerId
|
|
298
299
|
}, r)).subListAgents
|
|
299
300
|
});
|
|
300
|
-
},
|
|
301
|
+
}, A = (t) => {
|
|
301
302
|
let { apiGatewayUrl: r } = e();
|
|
302
303
|
return n({
|
|
303
|
-
queryKey:
|
|
304
|
+
queryKey: s.agent(t ?? ""),
|
|
304
305
|
enabled: !!t,
|
|
305
|
-
queryFn: async () => (await
|
|
306
|
+
queryFn: async () => (await o(`query SubAgent($id: ID!) {
|
|
306
307
|
subAgent(id: $id) {
|
|
307
|
-
${
|
|
308
|
+
${p}
|
|
308
309
|
policies {
|
|
309
310
|
id name description action agentId isEnabled triggerCount
|
|
310
311
|
lastTriggeredAt workspaceId createdAt updatedAt
|
|
@@ -312,59 +313,59 @@ var a = async (e, t, n) => {
|
|
|
312
313
|
}
|
|
313
314
|
}`, { id: t }, r)).subAgent
|
|
314
315
|
});
|
|
315
|
-
},
|
|
316
|
+
}, j = () => {
|
|
316
317
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
317
318
|
return t({
|
|
318
|
-
mutationFn: async (e) => (await
|
|
319
|
-
subCreateAgent(input: $input) { ${
|
|
319
|
+
mutationFn: async (e) => (await o(`mutation SubCreateAgent($input: SubCreateAgentInput!) {
|
|
320
|
+
subCreateAgent(input: $input) { ${p} }
|
|
320
321
|
}`, { input: e }, i)).subCreateAgent,
|
|
321
322
|
onSuccess: () => {
|
|
322
|
-
n.invalidateQueries({ queryKey:
|
|
323
|
+
n.invalidateQueries({ queryKey: s.agents });
|
|
323
324
|
}
|
|
324
325
|
});
|
|
325
|
-
},
|
|
326
|
+
}, M = () => {
|
|
326
327
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
327
328
|
return t({
|
|
328
|
-
mutationFn: async ({ id: e, status: t }) => (await
|
|
329
|
-
subSetAgentStatus(id: $id, status: $status) { ${
|
|
329
|
+
mutationFn: async ({ id: e, status: t }) => (await o(`mutation SubSetAgentStatus($id: ID!, $status: SubAgentStatus!) {
|
|
330
|
+
subSetAgentStatus(id: $id, status: $status) { ${p} }
|
|
330
331
|
}`, {
|
|
331
332
|
id: e,
|
|
332
333
|
status: t
|
|
333
334
|
}, i)).subSetAgentStatus,
|
|
334
335
|
onSuccess: (e) => {
|
|
335
|
-
n.invalidateQueries({ queryKey:
|
|
336
|
+
n.invalidateQueries({ queryKey: s.agents }), n.invalidateQueries({ queryKey: s.agent(e.id) });
|
|
336
337
|
}
|
|
337
338
|
});
|
|
338
|
-
},
|
|
339
|
+
}, N = (t) => {
|
|
339
340
|
let { apiGatewayUrl: r } = e();
|
|
340
341
|
return n({
|
|
341
|
-
queryKey: [...
|
|
342
|
-
queryFn: async () => (await
|
|
343
|
-
subListWorkflows(status: $status) { ${
|
|
342
|
+
queryKey: [...s.workflows, t],
|
|
343
|
+
queryFn: async () => (await o(`query SubWorkflows($status: SubWorkflowStatus) {
|
|
344
|
+
subListWorkflows(status: $status) { ${m} }
|
|
344
345
|
}`, { status: t }, r)).subListWorkflows
|
|
345
346
|
});
|
|
346
|
-
},
|
|
347
|
+
}, P = () => {
|
|
347
348
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
348
349
|
return t({
|
|
349
|
-
mutationFn: async (e) => (await
|
|
350
|
-
subCreateWorkflow(input: $input) { ${
|
|
350
|
+
mutationFn: async (e) => (await o(`mutation SubCreateWorkflow($input: SubCreateWorkflowInput!) {
|
|
351
|
+
subCreateWorkflow(input: $input) { ${m} }
|
|
351
352
|
}`, { input: e }, i)).subCreateWorkflow,
|
|
352
353
|
onSuccess: () => {
|
|
353
|
-
n.invalidateQueries({ queryKey:
|
|
354
|
+
n.invalidateQueries({ queryKey: s.workflows });
|
|
354
355
|
}
|
|
355
356
|
});
|
|
356
|
-
},
|
|
357
|
+
}, F = () => {
|
|
357
358
|
let n = r(), { apiGatewayUrl: i } = e();
|
|
358
359
|
return t({
|
|
359
|
-
mutationFn: async (e) => (await
|
|
360
|
-
subActivateWorkflow(id: $id) { ${
|
|
360
|
+
mutationFn: async (e) => (await o(`mutation SubActivateWorkflow($id: ID!) {
|
|
361
|
+
subActivateWorkflow(id: $id) { ${m} }
|
|
361
362
|
}`, { id: e }, i)).subActivateWorkflow,
|
|
362
363
|
onSuccess: () => {
|
|
363
|
-
n.invalidateQueries({ queryKey:
|
|
364
|
+
n.invalidateQueries({ queryKey: s.workflows });
|
|
364
365
|
}
|
|
365
366
|
});
|
|
366
367
|
};
|
|
367
368
|
//#endregion
|
|
368
|
-
export {
|
|
369
|
+
export { F as useActivateWorkflow, A as useAgent, k as useAgents, y as useCancelRelationship, j as useCreateAgent, C as useCreateProvider, _ as useCreateRelationship, P as useCreateWorkflow, T as useInboxMessages, D as useInvoices, O as useMarkInvoicePaid, E as useMarkMessageRead, w as usePlans, S as useProvider, x as useProviders, g as useRelationship, h as useRelationships, b as useRenewalEvents, M as useSetAgentStatus, v as useTransitionRelationship, N as useWorkflows };
|
|
369
370
|
|
|
370
371
|
//# sourceMappingURL=useSubscriberBotApi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSubscriberBotApi.js","names":[],"sources":["../../../src/subscriberbot/hooks/useSubscriberBotApi.ts"],"sourcesContent":["/**\n * SubscriberBot API hooks\n * @module subscriberbot/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-subscriberbot-svc`\n * federated GraphQL contract (the `Sub*` operations). Every query/mutation\n * below uses an inline gql string whose fields match the svc\n * `.hive-schema.graphql` exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })`\n * — the same pattern the workspace MFEs use; the host shell supplies the\n * gateway base URL + a workspace-scoped token.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useSubscriberBot } from '../context';\nimport type {\n PaginationInput,\n SubAgentKind,\n SubAgentStatus,\n SubAiAgent,\n SubAsset,\n SubCommunicationChannel,\n SubConnection,\n SubCreateAgentInput,\n SubCreateProviderInput,\n SubCreateRelationshipInput,\n SubCreateWorkflowInput,\n SubEntitlement,\n SubInboxMessage,\n SubInvoice,\n SubInvoiceStatus,\n SubMessageCategory,\n SubPaymentInstrument,\n SubPlan,\n SubProvider,\n SubProviderCategory,\n SubProviderStatus,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubRenewalEvent,\n SubWorkflow,\n SubWorkflowStatus,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst subQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n return response.data;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n relationships: ['subscriberbot', 'relationships'] as const,\n relationship: (id: string) => ['subscriberbot', 'relationship', id] as const,\n providers: ['subscriberbot', 'providers'] as const,\n provider: (id: string) => ['subscriberbot', 'provider', id] as const,\n plans: ['subscriberbot', 'plans'] as const,\n inbox: ['subscriberbot', 'inbox'] as const,\n invoices: ['subscriberbot', 'invoices'] as const,\n paymentInstruments: ['subscriberbot', 'payment-instruments'] as const,\n channels: ['subscriberbot', 'channels'] as const,\n agents: ['subscriberbot', 'agents'] as const,\n agent: (id: string) => ['subscriberbot', 'agent', id] as const,\n workflows: ['subscriberbot', 'workflows'] as const,\n renewals: ['subscriberbot', 'renewals'] as const,\n assets: ['subscriberbot', 'assets'] as const,\n entitlements: ['subscriberbot', 'entitlements'] as const,\n} as const;\n\n// ============================================================================\n// Reusable gql field selections (kept inline-string for codegen-free strictness)\n// ============================================================================\n\nconst PROVIDER_FIELDS = `\n id name slug category status description industry region language websiteUrl\n logoFileId tags churnRiskScore vendorHealthScore workspaceId createdAt updatedAt\n`;\n\nconst PLAN_FIELDS = `\n id name description providerId amount currency interval features isActive\n workspaceId createdAt updatedAt\n`;\n\nconst RELATIONSHIP_FIELDS = `\n id label kind status amount currency interval autoRenew discoverySource notes\n tags healthScore ownerId providerId planId startedAt renewsAt trialEndsAt\n cancelledAt workspaceId createdAt updatedAt\n`;\n\nconst INBOX_FIELDS = `\n id subject preview category categoryConfidence channelId relationshipId\n externalId actionRequired isRead receivedAt workspaceId createdAt updatedAt\n`;\n\nconst INVOICE_FIELDS = `\n id number relationshipId status currency subtotal taxAmount total issueDate\n dueDate paidAt paymentInstrumentId workspaceId createdAt updatedAt\n`;\n\nconst AGENT_FIELDS = `\n id name description kind status ownerId lastRunAt workspaceId createdAt updatedAt\n`;\n\nconst WORKFLOW_FIELDS = `\n id name description triggerEvent status runCount lastRunAt workspaceId\n createdAt updatedAt\n`;\n\n// ============================================================================\n// Relationships (the core domain object)\n// ============================================================================\n\nexport interface RelationshipListFilters {\n kind?: SubRelationshipKind;\n status?: SubRelationshipStatus;\n providerId?: string;\n ownerId?: string;\n pagination?: PaginationInput;\n}\n\nexport const useRelationships = (filters: RelationshipListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.relationships, filters],\n queryFn: async () => {\n const result = await subQuery<{\n subListRelationships: SubConnection<SubRelationship>;\n }>(\n `query SubRelationships(\n $kind: SubRelationshipKind\n $status: SubRelationshipStatus\n $providerId: ID\n $ownerId: ID\n $pagination: PaginationInput\n ) {\n subListRelationships(\n kind: $kind\n status: $status\n providerId: $providerId\n ownerId: $ownerId\n pagination: $pagination\n ) {\n items {\n ${RELATIONSHIP_FIELDS}\n provider { id name category status logoFileId }\n plan { id name amount currency interval }\n }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n kind: filters.kind,\n status: filters.status,\n providerId: filters.providerId,\n ownerId: filters.ownerId,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListRelationships;\n },\n });\n};\n\nexport const useRelationship = (id: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: KEY.relationship(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await subQuery<{ subRelationship: SubRelationship | null }>(\n `query SubRelationship($id: ID!) {\n subRelationship(id: $id) {\n ${RELATIONSHIP_FIELDS}\n provider { ${PROVIDER_FIELDS} }\n plan { ${PLAN_FIELDS} }\n entitlements {\n id name description type relationshipId quota used unit isActive\n workspaceId createdAt updatedAt\n }\n assets {\n id name type relationshipId secretRef expiresAt workspaceId\n createdAt updatedAt file { id }\n }\n renewalEvents {\n id relationshipId eventType occursAt amount currency detail\n notified workspaceId createdAt updatedAt\n }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subRelationship;\n },\n });\n};\n\nexport const useCreateRelationship = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateRelationshipInput) => {\n const result = await subQuery<{ subCreateRelationship: SubRelationship }>(\n `mutation SubCreateRelationship($input: SubCreateRelationshipInput!) {\n subCreateRelationship(input: $input) { ${RELATIONSHIP_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateRelationship;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.relationships });\n },\n });\n};\n\nexport const useTransitionRelationship = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: SubRelationshipStatus }) => {\n const result = await subQuery<{ subTransitionRelationship: SubRelationship }>(\n `mutation SubTransitionRelationship($id: ID!, $status: SubRelationshipStatus!) {\n subTransitionRelationship(id: $id, status: $status) { ${RELATIONSHIP_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return result.subTransitionRelationship;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.relationships });\n void queryClient.invalidateQueries({ queryKey: KEY.relationship(data.id) });\n },\n });\n};\n\nexport const useCancelRelationship = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subCancelRelationship: SubRelationship }>(\n `mutation SubCancelRelationship($id: ID!) {\n subCancelRelationship(id: $id) { ${RELATIONSHIP_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subCancelRelationship;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.relationships });\n void queryClient.invalidateQueries({ queryKey: KEY.relationship(data.id) });\n },\n });\n};\n\nexport const useRenewalEvents = (\n args: { relationshipId?: string; upcomingOnly?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.renewals, args],\n queryFn: async () => {\n const result = await subQuery<{ subListRenewalEvents: SubRenewalEvent[] }>(\n `query SubRenewalEvents($relationshipId: ID, $upcomingOnly: Boolean) {\n subListRenewalEvents(relationshipId: $relationshipId, upcomingOnly: $upcomingOnly) {\n id relationshipId eventType occursAt amount currency detail notified\n workspaceId createdAt updatedAt\n }\n }`,\n { relationshipId: args.relationshipId, upcomingOnly: args.upcomingOnly },\n apiGatewayUrl\n );\n return result.subListRenewalEvents;\n },\n });\n};\n\nexport const useEntitlements = (relationshipId: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.entitlements, relationshipId],\n enabled: Boolean(relationshipId),\n queryFn: async () => {\n const result = await subQuery<{ subListEntitlements: SubEntitlement[] }>(\n `query SubEntitlements($relationshipId: ID!) {\n subListEntitlements(relationshipId: $relationshipId) {\n id name description type relationshipId quota used unit isActive\n workspaceId createdAt updatedAt\n }\n }`,\n { relationshipId },\n apiGatewayUrl\n );\n return result.subListEntitlements;\n },\n });\n};\n\nexport const useAssets = (relationshipId: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.assets, relationshipId],\n enabled: Boolean(relationshipId),\n queryFn: async () => {\n const result = await subQuery<{ subListAssets: SubAsset[] }>(\n `query SubAssets($relationshipId: ID!) {\n subListAssets(relationshipId: $relationshipId) {\n id name type relationshipId secretRef expiresAt workspaceId\n createdAt updatedAt file { id }\n }\n }`,\n { relationshipId },\n apiGatewayUrl\n );\n return result.subListAssets;\n },\n });\n};\n\n// ============================================================================\n// Providers (the global discovery registry)\n// ============================================================================\n\nexport interface ProviderListFilters {\n category?: SubProviderCategory;\n status?: SubProviderStatus;\n search?: string;\n pagination?: PaginationInput;\n}\n\nexport const useProviders = (filters: ProviderListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.providers, filters],\n queryFn: async () => {\n const result = await subQuery<{ subListProviders: SubConnection<SubProvider> }>(\n `query SubProviders(\n $category: SubProviderCategory\n $status: SubProviderStatus\n $search: String\n $pagination: PaginationInput\n ) {\n subListProviders(\n category: $category\n status: $status\n search: $search\n pagination: $pagination\n ) {\n items { ${PROVIDER_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n category: filters.category,\n status: filters.status,\n search: filters.search,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListProviders;\n },\n });\n};\n\nexport const useProvider = (id: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: KEY.provider(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await subQuery<{ subProvider: SubProvider | null }>(\n `query SubProvider($id: ID!) {\n subProvider(id: $id) {\n ${PROVIDER_FIELDS}\n plans { ${PLAN_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subProvider;\n },\n });\n};\n\nexport const useCreateProvider = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateProviderInput) => {\n const result = await subQuery<{ subCreateProvider: SubProvider }>(\n `mutation SubCreateProvider($input: SubCreateProviderInput!) {\n subCreateProvider(input: $input) { ${PROVIDER_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateProvider;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.providers });\n },\n });\n};\n\nexport const usePlans = (providerId: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.plans, providerId],\n enabled: Boolean(providerId),\n queryFn: async () => {\n const result = await subQuery<{ subListPlans: SubPlan[] }>(\n `query SubPlans($providerId: ID) {\n subListPlans(providerId: $providerId) { ${PLAN_FIELDS} }\n }`,\n { providerId },\n apiGatewayUrl\n );\n return result.subListPlans;\n },\n });\n};\n\n// ============================================================================\n// Universal Inbox\n// ============================================================================\n\nexport interface InboxListFilters {\n category?: SubMessageCategory;\n channelId?: string;\n relationshipId?: string;\n unreadOnly?: boolean;\n pagination?: PaginationInput;\n}\n\nexport const useInboxMessages = (filters: InboxListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.inbox, filters],\n queryFn: async () => {\n const result = await subQuery<{\n subListInboxMessages: SubConnection<SubInboxMessage>;\n }>(\n `query SubInboxMessages(\n $category: SubMessageCategory\n $channelId: ID\n $relationshipId: ID\n $unreadOnly: Boolean\n $pagination: PaginationInput\n ) {\n subListInboxMessages(\n category: $category\n channelId: $channelId\n relationshipId: $relationshipId\n unreadOnly: $unreadOnly\n pagination: $pagination\n ) {\n items { ${INBOX_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n category: filters.category,\n channelId: filters.channelId,\n relationshipId: filters.relationshipId,\n unreadOnly: filters.unreadOnly,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListInboxMessages;\n },\n });\n};\n\nexport const useMarkMessageRead = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subMarkMessageRead: SubInboxMessage }>(\n `mutation SubMarkMessageRead($id: ID!) {\n subMarkMessageRead(id: $id) { ${INBOX_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subMarkMessageRead;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.inbox });\n },\n });\n};\n\n// ============================================================================\n// Invoices (Universal Billing Layer)\n// ============================================================================\n\nexport interface InvoiceListFilters {\n status?: SubInvoiceStatus;\n relationshipId?: string;\n pagination?: PaginationInput;\n}\n\nexport const useInvoices = (filters: InvoiceListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.invoices, filters],\n queryFn: async () => {\n const result = await subQuery<{ subListInvoices: SubConnection<SubInvoice> }>(\n `query SubInvoices(\n $status: SubInvoiceStatus\n $relationshipId: ID\n $pagination: PaginationInput\n ) {\n subListInvoices(\n status: $status\n relationshipId: $relationshipId\n pagination: $pagination\n ) {\n items { ${INVOICE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n status: filters.status,\n relationshipId: filters.relationshipId,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListInvoices;\n },\n });\n};\n\nexport const useMarkInvoicePaid = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subMarkInvoicePaid: SubInvoice }>(\n `mutation SubMarkInvoicePaid($id: ID!) {\n subMarkInvoicePaid(id: $id) { ${INVOICE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subMarkInvoicePaid;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.invoices });\n },\n });\n};\n\n// ============================================================================\n// Payment instruments & communication channels\n// ============================================================================\n\nexport const usePaymentInstruments = (ownerId?: string) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.paymentInstruments, ownerId],\n queryFn: async () => {\n const result = await subQuery<{ subListPaymentInstruments: SubPaymentInstrument[] }>(\n `query SubPaymentInstruments($ownerId: ID) {\n subListPaymentInstruments(ownerId: $ownerId) {\n id label type status brand last4 expiryMonth expiryYear isDefault\n ownerId workspaceId createdAt updatedAt\n }\n }`,\n { ownerId },\n apiGatewayUrl\n );\n return result.subListPaymentInstruments;\n },\n });\n};\n\nexport const useChannels = (ownerId?: string) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.channels, ownerId],\n queryFn: async () => {\n const result = await subQuery<{ subListChannels: SubCommunicationChannel[] }>(\n `query SubChannels($ownerId: ID) {\n subListChannels(ownerId: $ownerId) {\n id label type status address ingestEnabled ownerId verifiedAt\n workspaceId createdAt updatedAt\n }\n }`,\n { ownerId },\n apiGatewayUrl\n );\n return result.subListChannels;\n },\n });\n};\n\n// ============================================================================\n// AI Agents & workflows (automation)\n// ============================================================================\n\nexport interface AgentListFilters {\n kind?: SubAgentKind;\n status?: SubAgentStatus;\n ownerId?: string;\n}\n\nexport const useAgents = (filters: AgentListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.agents, filters],\n queryFn: async () => {\n const result = await subQuery<{ subListAgents: SubAiAgent[] }>(\n `query SubAgents($kind: SubAgentKind, $status: SubAgentStatus, $ownerId: ID) {\n subListAgents(kind: $kind, status: $status, ownerId: $ownerId) {\n ${AGENT_FIELDS}\n }\n }`,\n { kind: filters.kind, status: filters.status, ownerId: filters.ownerId },\n apiGatewayUrl\n );\n return result.subListAgents;\n },\n });\n};\n\nexport const useAgent = (id: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: KEY.agent(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await subQuery<{ subAgent: SubAiAgent | null }>(\n `query SubAgent($id: ID!) {\n subAgent(id: $id) {\n ${AGENT_FIELDS}\n policies {\n id name description action agentId isEnabled triggerCount\n lastTriggeredAt workspaceId createdAt updatedAt\n }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subAgent;\n },\n });\n};\n\nexport const useCreateAgent = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateAgentInput) => {\n const result = await subQuery<{ subCreateAgent: SubAiAgent }>(\n `mutation SubCreateAgent($input: SubCreateAgentInput!) {\n subCreateAgent(input: $input) { ${AGENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateAgent;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.agents });\n },\n });\n};\n\nexport const useSetAgentStatus = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: SubAgentStatus }) => {\n const result = await subQuery<{ subSetAgentStatus: SubAiAgent }>(\n `mutation SubSetAgentStatus($id: ID!, $status: SubAgentStatus!) {\n subSetAgentStatus(id: $id, status: $status) { ${AGENT_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return result.subSetAgentStatus;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.agents });\n void queryClient.invalidateQueries({ queryKey: KEY.agent(data.id) });\n },\n });\n};\n\nexport const useWorkflows = (status?: SubWorkflowStatus) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.workflows, status],\n queryFn: async () => {\n const result = await subQuery<{ subListWorkflows: SubWorkflow[] }>(\n `query SubWorkflows($status: SubWorkflowStatus) {\n subListWorkflows(status: $status) { ${WORKFLOW_FIELDS} }\n }`,\n { status },\n apiGatewayUrl\n );\n return result.subListWorkflows;\n },\n });\n};\n\nexport const useCreateWorkflow = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateWorkflowInput) => {\n const result = await subQuery<{ subCreateWorkflow: SubWorkflow }>(\n `mutation SubCreateWorkflow($input: SubCreateWorkflowInput!) {\n subCreateWorkflow(input: $input) { ${WORKFLOW_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateWorkflow;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.workflows });\n },\n });\n};\n\nexport const useActivateWorkflow = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subActivateWorkflow: SubWorkflow }>(\n `mutation SubActivateWorkflow($id: ID!) {\n subActivateWorkflow(id: $id) { ${WORKFLOW_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subActivateWorkflow;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.workflows });\n },\n });\n};\n"],"mappings":";;;;;AAoDA,IAAM,IAAW,OACf,GACA,GACA,MACmB;CACnB,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;EACjB,CAAC;AAEF,KAAI,EAAS,QAAQ,OACnB,OAAU,MAAM,EAAS,OAAO,IAAI,WAAW,yBAAyB;AAE1E,KAAI,CAAC,EAAS,KACZ,OAAU,MAAM,wCAAwC;AAE1D,QAAO,EAAS;GAIZ,IAAM;CACV,eAAe,CAAC,iBAAiB,gBAAgB;CACjD,eAAe,MAAe;EAAC;EAAiB;EAAgB;EAAG;CACnE,WAAW,CAAC,iBAAiB,YAAY;CACzC,WAAW,MAAe;EAAC;EAAiB;EAAY;EAAG;CAC3D,OAAO,CAAC,iBAAiB,QAAQ;CACjC,OAAO,CAAC,iBAAiB,QAAQ;CACjC,UAAU,CAAC,iBAAiB,WAAW;CACvC,oBAAoB,CAAC,iBAAiB,sBAAsB;CAC5D,UAAU,CAAC,iBAAiB,WAAW;CACvC,QAAQ,CAAC,iBAAiB,SAAS;CACnC,QAAQ,MAAe;EAAC;EAAiB;EAAS;EAAG;CACrD,WAAW,CAAC,iBAAiB,YAAY;CACzC,UAAU,CAAC,iBAAiB,WAAW;CACvC,QAAQ,CAAC,iBAAiB,SAAS;CACnC,cAAc,CAAC,iBAAiB,eAAe;CAChD,EAMK,IAAkB,0KAKlB,IAAc,sHAKd,IAAsB,mNAMtB,IAAe,gKAKf,IAAiB,2JAKjB,IAAe,2FAIf,IAAkB,uGAiBX,KAAoB,IAAmC,EAAE,KAA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ACd,EACD,EACa;EAEhB,YAAY,MAAS;AAEd,GADA,EAAY,kBAAkB,EAAE,UAAU,EAAI,QAAQ,CAAC,EACvD,EAAY,kBAAkB,EAAE,UAAU,EAAI,MAAM,EAAK,GAAG,EAAE,CAAC;;EAEvE,CAAC;GAGS,KAAgB,MAA+B;CAC1D,IAAM,EAAE,qBAAkB,GAAkB;AAC5C,QAAO,EAAS;EACd,UAAU,CAAC,GAAG,EAAI,WAAW,EAAO;EACpC,SAAS,aACQ,MAAM,EACnB;gDACwC,EAAgB;YAExD,EAAE,WAAQ,EACV,EACD,EACa;EAEjB,CAAC;GAGS,UAA0B;CACrC,IAAM,IAAc,GAAgB,EAC9B,EAAE,qBAAkB,GAAkB;AAC5C,QAAO,EAAY;EACjB,YAAY,OAAO,OACF,MAAM,EACnB;+CACuC,EAAgB;YAEvD,EAAE,UAAO,EACT,EACD,EACa;EAEhB,iBAAiB;AACV,KAAY,kBAAkB,EAAE,UAAU,EAAI,WAAW,CAAC;;EAElE,CAAC;GAGS,UAA4B;CACvC,IAAM,IAAc,GAAgB,EAC9B,EAAE,qBAAkB,GAAkB;AAC5C,QAAO,EAAY;EACjB,YAAY,OAAO,OACF,MAAM,EACnB;2CACmC,EAAgB;YAEnD,EAAE,OAAI,EACN,EACD,EACa;EAEhB,iBAAiB;AACV,KAAY,kBAAkB,EAAE,UAAU,EAAI,WAAW,CAAC;;EAElE,CAAC"}
|
|
1
|
+
{"version":3,"file":"useSubscriberBotApi.js","names":[],"sources":["../../../src/subscriberbot/hooks/useSubscriberBotApi.ts"],"sourcesContent":["/**\n * SubscriberBot API hooks\n * @module subscriberbot/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-subscriberbot-svc`\n * federated GraphQL contract (the `Sub*` operations). Every query/mutation\n * below uses an inline gql string whose fields match the svc\n * `.hive-schema.graphql` exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })`\n * — the same pattern the workspace MFEs use; the host shell supplies the\n * gateway base URL + a workspace-scoped token.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n// clearGraphqlFetchResponseCache is re-exported from the barrel only in newer\n// fe-libs; import it from its defining module so this works on the pinned\n// 2026.625.5 without forcing a risky fe-libs major bump.\nimport { clearGraphqlFetchResponseCache } from '@burdenoff/fe-libs/shared/graphql/fetch';\n\nimport { useSubscriberBot } from '../context';\nimport type {\n PaginationInput,\n SubAgentKind,\n SubAgentStatus,\n SubAiAgent,\n SubAsset,\n SubCommunicationChannel,\n SubConnection,\n SubCreateAgentInput,\n SubCreateProviderInput,\n SubCreateRelationshipInput,\n SubCreateWorkflowInput,\n SubEntitlement,\n SubInboxMessage,\n SubInvoice,\n SubInvoiceStatus,\n SubMessageCategory,\n SubPaymentInstrument,\n SubPlan,\n SubProvider,\n SubProviderCategory,\n SubProviderStatus,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubRenewalEvent,\n SubWorkflow,\n SubWorkflowStatus,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst subQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n // A mutation just changed server state. fe-libs' graphqlFetch keeps a ~15s\n // global response micro-cache keyed by query+vars, so the react-query refetch\n // that an onSuccess triggers would otherwise be served the STALE pre-write\n // response (a newly created provider/relationship/agent wouldn't appear, a\n // just-marked-read message would still show unread) until the TTL expires.\n // Drop that cache here — centralized so no mutation call site can forget it.\n if (/^\\s*mutation\\b/.test(query)) {\n clearGraphqlFetchResponseCache();\n }\n return response.data;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n relationships: ['subscriberbot', 'relationships'] as const,\n relationship: (id: string) => ['subscriberbot', 'relationship', id] as const,\n providers: ['subscriberbot', 'providers'] as const,\n provider: (id: string) => ['subscriberbot', 'provider', id] as const,\n plans: ['subscriberbot', 'plans'] as const,\n inbox: ['subscriberbot', 'inbox'] as const,\n invoices: ['subscriberbot', 'invoices'] as const,\n paymentInstruments: ['subscriberbot', 'payment-instruments'] as const,\n channels: ['subscriberbot', 'channels'] as const,\n agents: ['subscriberbot', 'agents'] as const,\n agent: (id: string) => ['subscriberbot', 'agent', id] as const,\n workflows: ['subscriberbot', 'workflows'] as const,\n renewals: ['subscriberbot', 'renewals'] as const,\n assets: ['subscriberbot', 'assets'] as const,\n entitlements: ['subscriberbot', 'entitlements'] as const,\n} as const;\n\n// ============================================================================\n// Reusable gql field selections (kept inline-string for codegen-free strictness)\n// ============================================================================\n\nconst PROVIDER_FIELDS = `\n id name slug category status description industry region language websiteUrl\n logoFileId tags churnRiskScore vendorHealthScore workspaceId createdAt updatedAt\n`;\n\nconst PLAN_FIELDS = `\n id name description providerId amount currency interval features isActive\n workspaceId createdAt updatedAt\n`;\n\nconst RELATIONSHIP_FIELDS = `\n id label kind status amount currency interval autoRenew discoverySource notes\n tags healthScore ownerId providerId planId startedAt renewsAt trialEndsAt\n cancelledAt workspaceId createdAt updatedAt\n`;\n\nconst INBOX_FIELDS = `\n id subject preview category categoryConfidence channelId relationshipId\n externalId actionRequired isRead receivedAt workspaceId createdAt updatedAt\n`;\n\nconst INVOICE_FIELDS = `\n id number relationshipId status currency subtotal taxAmount total issueDate\n dueDate paidAt paymentInstrumentId workspaceId createdAt updatedAt\n`;\n\nconst AGENT_FIELDS = `\n id name description kind status ownerId lastRunAt workspaceId createdAt updatedAt\n`;\n\nconst WORKFLOW_FIELDS = `\n id name description triggerEvent status runCount lastRunAt workspaceId\n createdAt updatedAt\n`;\n\n// ============================================================================\n// Relationships (the core domain object)\n// ============================================================================\n\nexport interface RelationshipListFilters {\n kind?: SubRelationshipKind;\n status?: SubRelationshipStatus;\n providerId?: string;\n ownerId?: string;\n pagination?: PaginationInput;\n}\n\nexport const useRelationships = (filters: RelationshipListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.relationships, filters],\n queryFn: async () => {\n const result = await subQuery<{\n subListRelationships: SubConnection<SubRelationship>;\n }>(\n `query SubRelationships(\n $kind: SubRelationshipKind\n $status: SubRelationshipStatus\n $providerId: ID\n $ownerId: ID\n $pagination: PaginationInput\n ) {\n subListRelationships(\n kind: $kind\n status: $status\n providerId: $providerId\n ownerId: $ownerId\n pagination: $pagination\n ) {\n items {\n ${RELATIONSHIP_FIELDS}\n provider { id name category status logoFileId }\n plan { id name amount currency interval }\n }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n kind: filters.kind,\n status: filters.status,\n providerId: filters.providerId,\n ownerId: filters.ownerId,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListRelationships;\n },\n });\n};\n\nexport const useRelationship = (id: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: KEY.relationship(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await subQuery<{ subRelationship: SubRelationship | null }>(\n `query SubRelationship($id: ID!) {\n subRelationship(id: $id) {\n ${RELATIONSHIP_FIELDS}\n provider { ${PROVIDER_FIELDS} }\n plan { ${PLAN_FIELDS} }\n entitlements {\n id name description type relationshipId quota used unit isActive\n workspaceId createdAt updatedAt\n }\n assets {\n id name type relationshipId secretRef expiresAt workspaceId\n createdAt updatedAt file { id }\n }\n renewalEvents {\n id relationshipId eventType occursAt amount currency detail\n notified workspaceId createdAt updatedAt\n }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subRelationship;\n },\n });\n};\n\nexport const useCreateRelationship = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateRelationshipInput) => {\n const result = await subQuery<{ subCreateRelationship: SubRelationship }>(\n `mutation SubCreateRelationship($input: SubCreateRelationshipInput!) {\n subCreateRelationship(input: $input) { ${RELATIONSHIP_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateRelationship;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.relationships });\n },\n });\n};\n\nexport const useTransitionRelationship = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: SubRelationshipStatus }) => {\n const result = await subQuery<{ subTransitionRelationship: SubRelationship }>(\n `mutation SubTransitionRelationship($id: ID!, $status: SubRelationshipStatus!) {\n subTransitionRelationship(id: $id, status: $status) { ${RELATIONSHIP_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return result.subTransitionRelationship;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.relationships });\n void queryClient.invalidateQueries({ queryKey: KEY.relationship(data.id) });\n },\n });\n};\n\nexport const useCancelRelationship = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subCancelRelationship: SubRelationship }>(\n `mutation SubCancelRelationship($id: ID!) {\n subCancelRelationship(id: $id) { ${RELATIONSHIP_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subCancelRelationship;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.relationships });\n void queryClient.invalidateQueries({ queryKey: KEY.relationship(data.id) });\n },\n });\n};\n\nexport const useRenewalEvents = (\n args: { relationshipId?: string; upcomingOnly?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.renewals, args],\n queryFn: async () => {\n const result = await subQuery<{ subListRenewalEvents: SubRenewalEvent[] }>(\n `query SubRenewalEvents($relationshipId: ID, $upcomingOnly: Boolean) {\n subListRenewalEvents(relationshipId: $relationshipId, upcomingOnly: $upcomingOnly) {\n id relationshipId eventType occursAt amount currency detail notified\n workspaceId createdAt updatedAt\n }\n }`,\n { relationshipId: args.relationshipId, upcomingOnly: args.upcomingOnly },\n apiGatewayUrl\n );\n return result.subListRenewalEvents;\n },\n });\n};\n\nexport const useEntitlements = (relationshipId: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.entitlements, relationshipId],\n enabled: Boolean(relationshipId),\n queryFn: async () => {\n const result = await subQuery<{ subListEntitlements: SubEntitlement[] }>(\n `query SubEntitlements($relationshipId: ID!) {\n subListEntitlements(relationshipId: $relationshipId) {\n id name description type relationshipId quota used unit isActive\n workspaceId createdAt updatedAt\n }\n }`,\n { relationshipId },\n apiGatewayUrl\n );\n return result.subListEntitlements;\n },\n });\n};\n\nexport const useAssets = (relationshipId: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.assets, relationshipId],\n enabled: Boolean(relationshipId),\n queryFn: async () => {\n const result = await subQuery<{ subListAssets: SubAsset[] }>(\n `query SubAssets($relationshipId: ID!) {\n subListAssets(relationshipId: $relationshipId) {\n id name type relationshipId secretRef expiresAt workspaceId\n createdAt updatedAt file { id }\n }\n }`,\n { relationshipId },\n apiGatewayUrl\n );\n return result.subListAssets;\n },\n });\n};\n\n// ============================================================================\n// Providers (the global discovery registry)\n// ============================================================================\n\nexport interface ProviderListFilters {\n category?: SubProviderCategory;\n status?: SubProviderStatus;\n search?: string;\n pagination?: PaginationInput;\n}\n\nexport const useProviders = (filters: ProviderListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.providers, filters],\n queryFn: async () => {\n const result = await subQuery<{ subListProviders: SubConnection<SubProvider> }>(\n `query SubProviders(\n $category: SubProviderCategory\n $status: SubProviderStatus\n $search: String\n $pagination: PaginationInput\n ) {\n subListProviders(\n category: $category\n status: $status\n search: $search\n pagination: $pagination\n ) {\n items { ${PROVIDER_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n category: filters.category,\n status: filters.status,\n search: filters.search,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListProviders;\n },\n });\n};\n\nexport const useProvider = (id: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: KEY.provider(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await subQuery<{ subProvider: SubProvider | null }>(\n `query SubProvider($id: ID!) {\n subProvider(id: $id) {\n ${PROVIDER_FIELDS}\n plans { ${PLAN_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subProvider;\n },\n });\n};\n\nexport const useCreateProvider = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateProviderInput) => {\n const result = await subQuery<{ subCreateProvider: SubProvider }>(\n `mutation SubCreateProvider($input: SubCreateProviderInput!) {\n subCreateProvider(input: $input) { ${PROVIDER_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateProvider;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.providers });\n },\n });\n};\n\nexport const usePlans = (providerId: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.plans, providerId],\n enabled: Boolean(providerId),\n queryFn: async () => {\n const result = await subQuery<{ subListPlans: SubPlan[] }>(\n `query SubPlans($providerId: ID) {\n subListPlans(providerId: $providerId) { ${PLAN_FIELDS} }\n }`,\n { providerId },\n apiGatewayUrl\n );\n return result.subListPlans;\n },\n });\n};\n\n// ============================================================================\n// Universal Inbox\n// ============================================================================\n\nexport interface InboxListFilters {\n category?: SubMessageCategory;\n channelId?: string;\n relationshipId?: string;\n unreadOnly?: boolean;\n pagination?: PaginationInput;\n}\n\nexport const useInboxMessages = (filters: InboxListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.inbox, filters],\n queryFn: async () => {\n const result = await subQuery<{\n subListInboxMessages: SubConnection<SubInboxMessage>;\n }>(\n `query SubInboxMessages(\n $category: SubMessageCategory\n $channelId: ID\n $relationshipId: ID\n $unreadOnly: Boolean\n $pagination: PaginationInput\n ) {\n subListInboxMessages(\n category: $category\n channelId: $channelId\n relationshipId: $relationshipId\n unreadOnly: $unreadOnly\n pagination: $pagination\n ) {\n items { ${INBOX_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n category: filters.category,\n channelId: filters.channelId,\n relationshipId: filters.relationshipId,\n unreadOnly: filters.unreadOnly,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListInboxMessages;\n },\n });\n};\n\nexport const useMarkMessageRead = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subMarkMessageRead: SubInboxMessage }>(\n `mutation SubMarkMessageRead($id: ID!) {\n subMarkMessageRead(id: $id) { ${INBOX_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subMarkMessageRead;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.inbox });\n },\n });\n};\n\n// ============================================================================\n// Invoices (Universal Billing Layer)\n// ============================================================================\n\nexport interface InvoiceListFilters {\n status?: SubInvoiceStatus;\n relationshipId?: string;\n pagination?: PaginationInput;\n}\n\nexport const useInvoices = (filters: InvoiceListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.invoices, filters],\n queryFn: async () => {\n const result = await subQuery<{ subListInvoices: SubConnection<SubInvoice> }>(\n `query SubInvoices(\n $status: SubInvoiceStatus\n $relationshipId: ID\n $pagination: PaginationInput\n ) {\n subListInvoices(\n status: $status\n relationshipId: $relationshipId\n pagination: $pagination\n ) {\n items { ${INVOICE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n status: filters.status,\n relationshipId: filters.relationshipId,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListInvoices;\n },\n });\n};\n\nexport const useMarkInvoicePaid = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subMarkInvoicePaid: SubInvoice }>(\n `mutation SubMarkInvoicePaid($id: ID!) {\n subMarkInvoicePaid(id: $id) { ${INVOICE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subMarkInvoicePaid;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.invoices });\n },\n });\n};\n\n// ============================================================================\n// Payment instruments & communication channels\n// ============================================================================\n\nexport const usePaymentInstruments = (ownerId?: string) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.paymentInstruments, ownerId],\n queryFn: async () => {\n const result = await subQuery<{ subListPaymentInstruments: SubPaymentInstrument[] }>(\n `query SubPaymentInstruments($ownerId: ID) {\n subListPaymentInstruments(ownerId: $ownerId) {\n id label type status brand last4 expiryMonth expiryYear isDefault\n ownerId workspaceId createdAt updatedAt\n }\n }`,\n { ownerId },\n apiGatewayUrl\n );\n return result.subListPaymentInstruments;\n },\n });\n};\n\nexport const useChannels = (ownerId?: string) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.channels, ownerId],\n queryFn: async () => {\n const result = await subQuery<{ subListChannels: SubCommunicationChannel[] }>(\n `query SubChannels($ownerId: ID) {\n subListChannels(ownerId: $ownerId) {\n id label type status address ingestEnabled ownerId verifiedAt\n workspaceId createdAt updatedAt\n }\n }`,\n { ownerId },\n apiGatewayUrl\n );\n return result.subListChannels;\n },\n });\n};\n\n// ============================================================================\n// AI Agents & workflows (automation)\n// ============================================================================\n\nexport interface AgentListFilters {\n kind?: SubAgentKind;\n status?: SubAgentStatus;\n ownerId?: string;\n}\n\nexport const useAgents = (filters: AgentListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.agents, filters],\n queryFn: async () => {\n const result = await subQuery<{ subListAgents: SubAiAgent[] }>(\n `query SubAgents($kind: SubAgentKind, $status: SubAgentStatus, $ownerId: ID) {\n subListAgents(kind: $kind, status: $status, ownerId: $ownerId) {\n ${AGENT_FIELDS}\n }\n }`,\n { kind: filters.kind, status: filters.status, ownerId: filters.ownerId },\n apiGatewayUrl\n );\n return result.subListAgents;\n },\n });\n};\n\nexport const useAgent = (id: string | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: KEY.agent(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await subQuery<{ subAgent: SubAiAgent | null }>(\n `query SubAgent($id: ID!) {\n subAgent(id: $id) {\n ${AGENT_FIELDS}\n policies {\n id name description action agentId isEnabled triggerCount\n lastTriggeredAt workspaceId createdAt updatedAt\n }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subAgent;\n },\n });\n};\n\nexport const useCreateAgent = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateAgentInput) => {\n const result = await subQuery<{ subCreateAgent: SubAiAgent }>(\n `mutation SubCreateAgent($input: SubCreateAgentInput!) {\n subCreateAgent(input: $input) { ${AGENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateAgent;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.agents });\n },\n });\n};\n\nexport const useSetAgentStatus = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: SubAgentStatus }) => {\n const result = await subQuery<{ subSetAgentStatus: SubAiAgent }>(\n `mutation SubSetAgentStatus($id: ID!, $status: SubAgentStatus!) {\n subSetAgentStatus(id: $id, status: $status) { ${AGENT_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return result.subSetAgentStatus;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.agents });\n void queryClient.invalidateQueries({ queryKey: KEY.agent(data.id) });\n },\n });\n};\n\nexport const useWorkflows = (status?: SubWorkflowStatus) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.workflows, status],\n queryFn: async () => {\n const result = await subQuery<{ subListWorkflows: SubWorkflow[] }>(\n `query SubWorkflows($status: SubWorkflowStatus) {\n subListWorkflows(status: $status) { ${WORKFLOW_FIELDS} }\n }`,\n { status },\n apiGatewayUrl\n );\n return result.subListWorkflows;\n },\n });\n};\n\nexport const useCreateWorkflow = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateWorkflowInput) => {\n const result = await subQuery<{ subCreateWorkflow: SubWorkflow }>(\n `mutation SubCreateWorkflow($input: SubCreateWorkflowInput!) {\n subCreateWorkflow(input: $input) { ${WORKFLOW_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateWorkflow;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.workflows });\n },\n });\n};\n\nexport const useActivateWorkflow = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subActivateWorkflow: SubWorkflow }>(\n `mutation SubActivateWorkflow($id: ID!) {\n subActivateWorkflow(id: $id) { ${WORKFLOW_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subActivateWorkflow;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.work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