@burdenoff/microfe-subscriberbot 2026.719.1 → 2026.720.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSubscriberBotApi.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/hooks/useSubscriberBotApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,UAAU,EACV,QAAQ,EACR,uBAAuB,EACvB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,+BAA+B,EAC/B,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,0BAA0B,EAC1B,WAAW,EACX,iBAAiB,EAClB,MAAM,UAAU,CAAC;AA4HlB,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B;AAED,eAAO,MAAM,gBAAgB,GAAI,UAAS,uBAA4B,mGA6CrE,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,GAAG,SAAS,2FAgCrD,CAAC;AAEF,eAAO,MAAM,qBAAqB,sHAkBjC,CAAC;AAEF,eAAO,MAAM,yBAAyB;QAIO,MAAM;YAAU,qBAAqB;WAejF,CAAC;AAEF,eAAO,MAAM,qBAAqB,kGAmBjC,CAAC;AAEF,eAAO,MAAM,qBAAqB;QAIU,MAAM;WAAS,0BAA0B;WAepF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,OAAM;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,
|
|
1
|
+
{"version":3,"file":"useSubscriberBotApi.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/hooks/useSubscriberBotApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,UAAU,EACV,QAAQ,EACR,uBAAuB,EACvB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,+BAA+B,EAC/B,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,0BAA0B,EAC1B,WAAW,EACX,iBAAiB,EAClB,MAAM,UAAU,CAAC;AA4HlB,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC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C,CAAC;AAEF,eAAO,MAAM,gBAAgB,yHAkB5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,0GAkB5B,CAAC;AAMF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,SAAS,GAAI,UAAS,gBAAqB,iFAkBvD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,IAAI,MAAM,GAAG,SAAS,sFAsB9C,CAAC;AAEF,eAAO,MAAM,cAAc,0GAkB1B,CAAC;AAEF,eAAO,MAAM,iBAAiB;QAIe,MAAM;YAAU,cAAc;WAe1E,CAAC;AAEF,eAAO,MAAM,eAAe,0GAmB3B,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,iBAAiB,kFAetD,CAAC;AAEF,eAAO,MAAM,iBAAiB,8GAkB7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,8FAkB/B,CAAC"}
|
|
@@ -158,10 +158,10 @@ var c = async (e, t, n) => {
|
|
|
158
158
|
let { apiGatewayUrl: n } = e();
|
|
159
159
|
return i({
|
|
160
160
|
queryKey: [...l.renewals, t],
|
|
161
|
-
queryFn: async () => (await c("query SubRenewalEvents($relationshipId: ID, $upcomingOnly: Boolean) {\n subListRenewalEvents(relationshipId: $relationshipId, upcomingOnly: $upcomingOnly) {\n id relationshipId eventType occursAt amount currency detail notified\n
|
|
161
|
+
queryFn: async () => (await c("query SubRenewalEvents($relationshipId: ID, $upcomingOnly: Boolean) {\n subListRenewalEvents(relationshipId: $relationshipId, upcomingOnly: $upcomingOnly) {\n items {\n id relationshipId eventType occursAt amount currency detail notified\n workspaceId createdAt updatedAt\n }\n pageInfo { cursor hasMore }\n }\n }", {
|
|
162
162
|
relationshipId: t.relationshipId,
|
|
163
163
|
upcomingOnly: t.upcomingOnly
|
|
164
|
-
}, n)).subListRenewalEvents
|
|
164
|
+
}, n)).subListRenewalEvents.items
|
|
165
165
|
});
|
|
166
166
|
}, k = () => {
|
|
167
167
|
let t = a(), { apiGatewayUrl: n } = e();
|
|
@@ -178,8 +178,8 @@ var c = async (e, t, n) => {
|
|
|
178
178
|
return i({
|
|
179
179
|
queryKey: [...l.assets, "all"],
|
|
180
180
|
queryFn: async () => (await c(`query SubAllAssets {
|
|
181
|
-
subListAssets { ${v} }
|
|
182
|
-
}`, {}, t)).subListAssets
|
|
181
|
+
subListAssets { items { ${v} } pageInfo { cursor hasMore } }
|
|
182
|
+
}`, {}, t)).subListAssets.items
|
|
183
183
|
});
|
|
184
184
|
}, j = () => {
|
|
185
185
|
let t = a(), { apiGatewayUrl: n } = e();
|
|
@@ -316,8 +316,8 @@ var c = async (e, t, n) => {
|
|
|
316
316
|
queryKey: [...l.plans, t],
|
|
317
317
|
enabled: !!t,
|
|
318
318
|
queryFn: async () => (await c(`query SubPlans($providerId: ID) {
|
|
319
|
-
subListPlans(providerId: $providerId) { ${d} }
|
|
320
|
-
}`, { providerId: t }, n)).subListPlans
|
|
319
|
+
subListPlans(providerId: $providerId) { items { ${d} } pageInfo { cursor hasMore } }
|
|
320
|
+
}`, { providerId: t }, n)).subListPlans.items
|
|
321
321
|
});
|
|
322
322
|
}, B = () => {
|
|
323
323
|
let t = a(), { apiGatewayUrl: n } = e();
|
|
@@ -431,7 +431,7 @@ var c = async (e, t, n) => {
|
|
|
431
431
|
let { apiGatewayUrl: n } = e();
|
|
432
432
|
return i({
|
|
433
433
|
queryKey: [...l.paymentInstruments, t],
|
|
434
|
-
queryFn: async () => (await c("query SubPaymentInstruments($ownerId: ID) {\n subListPaymentInstruments(ownerId: $ownerId) {\n id label type status brand last4 expiryMonth expiryYear isDefault\n
|
|
434
|
+
queryFn: async () => (await c("query SubPaymentInstruments($ownerId: ID) {\n subListPaymentInstruments(ownerId: $ownerId) {\n items {\n id label type status brand last4 expiryMonth expiryYear isDefault\n ownerId workspaceId createdAt updatedAt\n }\n pageInfo { cursor hasMore }\n }\n }", { ownerId: t }, n)).subListPaymentInstruments.items
|
|
435
435
|
});
|
|
436
436
|
}, J = () => {
|
|
437
437
|
let t = a(), { apiGatewayUrl: n } = e();
|
|
@@ -455,7 +455,7 @@ var c = async (e, t, n) => {
|
|
|
455
455
|
let { apiGatewayUrl: n } = e();
|
|
456
456
|
return i({
|
|
457
457
|
queryKey: [...l.channels, t],
|
|
458
|
-
queryFn: async () => (await c("query SubChannels($ownerId: ID) {\n subListChannels(ownerId: $ownerId) {\n id label type status address ingestEnabled ownerId verifiedAt\n
|
|
458
|
+
queryFn: async () => (await c("query SubChannels($ownerId: ID) {\n subListChannels(ownerId: $ownerId) {\n items {\n id label type status address ingestEnabled ownerId verifiedAt\n workspaceId createdAt updatedAt\n }\n pageInfo { cursor hasMore }\n }\n }", { ownerId: t }, n)).subListChannels.items
|
|
459
459
|
});
|
|
460
460
|
}, Z = () => {
|
|
461
461
|
let t = a(), { apiGatewayUrl: n } = e();
|
|
@@ -483,13 +483,14 @@ var c = async (e, t, n) => {
|
|
|
483
483
|
queryKey: [...l.agents, t],
|
|
484
484
|
queryFn: async () => (await c(`query SubAgents($kind: SubAgentKind, $status: SubAgentStatus, $ownerId: ID) {
|
|
485
485
|
subListAgents(kind: $kind, status: $status, ownerId: $ownerId) {
|
|
486
|
-
${h}
|
|
486
|
+
items { ${h} }
|
|
487
|
+
pageInfo { cursor hasMore }
|
|
487
488
|
}
|
|
488
489
|
}`, {
|
|
489
490
|
kind: t.kind,
|
|
490
491
|
status: t.status,
|
|
491
492
|
ownerId: t.ownerId
|
|
492
|
-
}, n)).subListAgents
|
|
493
|
+
}, n)).subListAgents.items
|
|
493
494
|
});
|
|
494
495
|
}, te = (t) => {
|
|
495
496
|
let { apiGatewayUrl: n } = e();
|
|
@@ -544,8 +545,8 @@ var c = async (e, t, n) => {
|
|
|
544
545
|
return i({
|
|
545
546
|
queryKey: [...l.workflows, t],
|
|
546
547
|
queryFn: async () => (await c(`query SubWorkflows($status: SubWorkflowStatus) {
|
|
547
|
-
subListWorkflows(status: $status) { ${g} }
|
|
548
|
-
}`, { status: t }, n)).subListWorkflows
|
|
548
|
+
subListWorkflows(status: $status) { items { ${g} } pageInfo { cursor hasMore } }
|
|
549
|
+
}`, { status: t }, n)).subListWorkflows.items
|
|
549
550
|
});
|
|
550
551
|
}, oe = () => {
|
|
551
552
|
let t = a(), { apiGatewayUrl: n } = e();
|
|
@@ -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 { useCallback, useState } from 'react';\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 SubCreateAssetInput,\n SubCreateChannelInput,\n SubCreateEntitlementInput,\n SubCreateInvoiceInput,\n SubCreatePaymentInstrumentInput,\n SubCreatePlanInput,\n SubCreatePolicyInput,\n SubCreateProviderInput,\n SubCreateRelationshipInput,\n SubCreateWorkflowInput,\n SubEntitlement,\n SubInboxMessage,\n SubIngestMessageInput,\n SubInvoice,\n SubInvoiceStatus,\n SubMessageCategory,\n SubPaymentInstrument,\n SubPlan,\n SubPolicy,\n SubProvider,\n SubProviderCategory,\n SubProviderStatus,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubRenewalEvent,\n SubUpdateProviderInput,\n SubUpdateRelationshipInput,\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\nconst ENTITLEMENT_FIELDS = `\n id name description type relationshipId quota used unit isActive\n workspaceId createdAt updatedAt\n`;\n\nconst ASSET_FIELDS = `\n id name type relationshipId secretRef expiresAt workspaceId createdAt\n updatedAt file { id }\n`;\n\nconst PAYMENT_INSTRUMENT_FIELDS = `\n id label type status brand last4 expiryMonth expiryYear isDefault ownerId\n workspaceId createdAt updatedAt\n`;\n\nconst CHANNEL_FIELDS = `\n id label type status address ingestEnabled ownerId verifiedAt workspaceId\n createdAt updatedAt\n`;\n\nconst POLICY_FIELDS = `\n id name description action agentId isEnabled triggerCount lastTriggeredAt\n workspaceId 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 /** Case-insensitive substring match on the relationship label (server-side). */\n search?: 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 $search: String\n $pagination: PaginationInput\n ) {\n subListRelationships(\n kind: $kind\n status: $status\n providerId: $providerId\n ownerId: $ownerId\n search: $search\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 search: filters.search,\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 useUpdateRelationship = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, input }: { id: string; input: SubUpdateRelationshipInput }) => {\n const result = await subQuery<{ subUpdateRelationship: SubRelationship }>(\n `mutation SubUpdateRelationship($id: ID!, $input: SubUpdateRelationshipInput!) {\n subUpdateRelationship(id: $id, input: $input) { ${RELATIONSHIP_FIELDS} }\n }`,\n { id, input },\n apiGatewayUrl\n );\n return result.subUpdateRelationship;\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 useCreateEntitlement = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateEntitlementInput) => {\n const result = await subQuery<{ subCreateEntitlement: SubEntitlement }>(\n `mutation SubCreateEntitlement($input: SubCreateEntitlementInput!) {\n subCreateEntitlement(input: $input) { ${ENTITLEMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateEntitlement;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.entitlements });\n void queryClient.invalidateQueries({ queryKey: KEY.relationship(data.relationshipId) });\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/** Every asset in the workspace (Digital Asset Vault) — omits relationshipId. */\nexport const useAllAssets = () => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.assets, 'all'],\n queryFn: async () => {\n const result = await subQuery<{ subListAssets: SubAsset[] }>(\n `query SubAllAssets {\n subListAssets { ${ASSET_FIELDS} }\n }`,\n {},\n apiGatewayUrl\n );\n return result.subListAssets;\n },\n });\n};\n\nexport const useCreateAsset = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateAssetInput) => {\n const result = await subQuery<{ subCreateAsset: SubAsset }>(\n `mutation SubCreateAsset($input: SubCreateAssetInput!) {\n subCreateAsset(input: $input) { ${ASSET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateAsset;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.assets });\n void queryClient.invalidateQueries({ queryKey: KEY.relationship(data.relationshipId) });\n },\n });\n};\n\n/**\n * Upload a file to `wspace-files-svc` and return its File id, using the\n * platform-standard 3-step flow (initiateUpload → presigned PUT → completeUpload)\n * over the same `graphqlFetch` transport the rest of this MFE uses. Assets store\n * only the returned `fileId` on `SubCreateAssetInput`; blobs live in files-svc.\n *\n * `CompleteUploadInput.fileSize` is a REQUIRED BigInt (quota tracking) and must\n * match the value given to `initiateUpload` — we pass `String(file.size)` to both.\n */\nconst ASSET_FOLDER_PATH = '/SubscriberBot/Assets';\n\nexport const useUploadFile = () => {\n const { apiGatewayUrl } = useSubscriberBot();\n const [progress, setProgress] = useState(0);\n const [isUploading, setIsUploading] = useState(false);\n\n const uploadFile = useCallback(\n async (file: File): Promise<{ fileId: string; fileName: string }> => {\n setIsUploading(true);\n setProgress(0);\n try {\n // 1. Resolve (or create) the destination folder — File.folderId is a real FK.\n const folderRes = await subQuery<{ ensureFolderByPath: { id: string } | null }>(\n `mutation SubEnsureFolder($path: String!) {\n ensureFolderByPath(path: $path) { id }\n }`,\n { path: ASSET_FOLDER_PATH },\n apiGatewayUrl\n );\n const folderId = folderRes.ensureFolderByPath?.id;\n if (!folderId) throw new Error('Could not resolve the upload folder.');\n\n const mimeType = file.type || 'application/octet-stream';\n const dotIndex = file.name.lastIndexOf('.');\n const extension = dotIndex > -1 ? file.name.slice(dotIndex + 1) : 'bin';\n\n // 2. Open a presigned upload session.\n const initiated = await subQuery<{\n initiateUpload: { uploadUrl: string | null; session: { id: string } } | null;\n }>(\n `mutation SubInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id }\n }\n }`,\n {\n input: {\n fileName: file.name,\n extension,\n mimeType,\n fileSize: String(file.size),\n folderId,\n },\n },\n apiGatewayUrl\n );\n const uploadUrl = initiated.initiateUpload?.uploadUrl;\n const sessionId = initiated.initiateUpload?.session.id;\n if (!uploadUrl || !sessionId) {\n throw new Error('The files service did not return an upload URL.');\n }\n\n // 3. PUT the raw bytes to storage. Content-Type must match what was signed.\n await new Promise<void>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.open('PUT', uploadUrl);\n xhr.setRequestHeader('Content-Type', mimeType);\n xhr.upload.onprogress = (event) => {\n if (event.lengthComputable) {\n setProgress(Math.round((event.loaded / event.total) * 100));\n }\n };\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) resolve();\n else reject(new Error(`Upload to storage failed (${xhr.status}).`));\n };\n xhr.onerror = () => reject(new Error('Upload to storage failed.'));\n xhr.send(file);\n });\n\n // 4. Finalize — creates the File record. fileSize must match initiateUpload.\n const completed = await subQuery<{\n completeUpload: { fileId: string; file: { id: string; name: string } | null } | null;\n }>(\n `mutation SubCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) {\n fileId\n file { id name }\n }\n }`,\n { input: { sessionId, fileSize: String(file.size), folderId } },\n apiGatewayUrl\n );\n const fileId = completed.completeUpload?.file?.id ?? completed.completeUpload?.fileId;\n if (!fileId) throw new Error('The upload could not be finalized.');\n return { fileId, fileName: completed.completeUpload?.file?.name ?? file.name };\n } finally {\n setIsUploading(false);\n }\n },\n [apiGatewayUrl]\n );\n\n return { uploadFile, progress, isUploading };\n};\n\n/**\n * Resolve a short-lived presigned download URL for a `wspace-files-svc` File id.\n * Never select the federated arg-less `File.downloadUrl` (it mints a URL beyond\n * S3's 7-day cap and 500s the response) — use the root `getFileDownloadUrl`\n * query with a TTL under 604800s instead.\n */\nexport const useFileDownloadUrl = () => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useCallback(\n async (fileId: string): Promise<string> => {\n const result = await subQuery<{ getFileDownloadUrl: string }>(\n `query SubFileDownloadUrl($id: ID!, $expiresIn: Int) {\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n }`,\n { id: fileId, expiresIn: 21600 },\n apiGatewayUrl\n );\n return result.getFileDownloadUrl;\n },\n [apiGatewayUrl]\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 useUpdateProvider = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, input }: { id: string; input: SubUpdateProviderInput }) => {\n const result = await subQuery<{ subUpdateProvider: SubProvider }>(\n `mutation SubUpdateProvider($id: ID!, $input: SubUpdateProviderInput!) {\n subUpdateProvider(id: $id, input: $input) { ${PROVIDER_FIELDS} }\n }`,\n { id, input },\n apiGatewayUrl\n );\n return result.subUpdateProvider;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.providers });\n void queryClient.invalidateQueries({ queryKey: KEY.provider(data.id) });\n },\n });\n};\n\nexport const useArchiveProvider = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subArchiveProvider: boolean }>(\n `mutation SubArchiveProvider($id: ID!) {\n subArchiveProvider(id: $id)\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subArchiveProvider;\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\nexport const useCreatePlan = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreatePlanInput) => {\n const result = await subQuery<{ subCreatePlan: SubPlan }>(\n `mutation SubCreatePlan($input: SubCreatePlanInput!) {\n subCreatePlan(input: $input) { ${PLAN_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreatePlan;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.plans });\n void queryClient.invalidateQueries({ queryKey: KEY.provider(data.providerId) });\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\nexport const useIngestMessage = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubIngestMessageInput) => {\n const result = await subQuery<{ subIngestMessage: SubInboxMessage }>(\n `mutation SubIngestMessage($input: SubIngestMessageInput!) {\n subIngestMessage(input: $input) { ${INBOX_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subIngestMessage;\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\nexport const useCreateInvoice = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateInvoiceInput) => {\n const result = await subQuery<{ subCreateInvoice: SubInvoice }>(\n `mutation SubCreateInvoice($input: SubCreateInvoiceInput!) {\n subCreateInvoice(input: $input) { ${INVOICE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateInvoice;\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 useCreatePaymentInstrument = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreatePaymentInstrumentInput) => {\n const result = await subQuery<{ subCreatePaymentInstrument: SubPaymentInstrument }>(\n `mutation SubCreatePaymentInstrument($input: SubCreatePaymentInstrumentInput!) {\n subCreatePaymentInstrument(input: $input) { ${PAYMENT_INSTRUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreatePaymentInstrument;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.paymentInstruments });\n },\n });\n};\n\nexport const useRemovePaymentInstrument = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subRemovePaymentInstrument: boolean }>(\n `mutation SubRemovePaymentInstrument($id: ID!) {\n subRemovePaymentInstrument(id: $id)\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subRemovePaymentInstrument;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.paymentInstruments });\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\nexport const useCreateChannel = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateChannelInput) => {\n const result = await subQuery<{ subCreateChannel: SubCommunicationChannel }>(\n `mutation SubCreateChannel($input: SubCreateChannelInput!) {\n subCreateChannel(input: $input) { ${CHANNEL_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateChannel;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.channels });\n },\n });\n};\n\nexport const useVerifyChannel = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subVerifyChannel: SubCommunicationChannel }>(\n `mutation SubVerifyChannel($id: ID!) {\n subVerifyChannel(id: $id) { ${CHANNEL_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subVerifyChannel;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.channels });\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 useCreatePolicy = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreatePolicyInput) => {\n const result = await subQuery<{ subCreatePolicy: SubPolicy }>(\n `mutation SubCreatePolicy($input: SubCreatePolicyInput!) {\n subCreatePolicy(input: $input) { ${POLICY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreatePolicy;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.agents });\n void queryClient.invalidateQueries({ queryKey: KEY.agent(data.agentId) });\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.invalidate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kB,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,WAA0B;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,WAA4B;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 { useCallback, useState } from 'react';\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 SubCreateAssetInput,\n SubCreateChannelInput,\n SubCreateEntitlementInput,\n SubCreateInvoiceInput,\n SubCreatePaymentInstrumentInput,\n SubCreatePlanInput,\n SubCreatePolicyInput,\n SubCreateProviderInput,\n SubCreateRelationshipInput,\n SubCreateWorkflowInput,\n SubEntitlement,\n SubInboxMessage,\n SubIngestMessageInput,\n SubInvoice,\n SubInvoiceStatus,\n SubMessageCategory,\n SubPaymentInstrument,\n SubPlan,\n SubPolicy,\n SubProvider,\n SubProviderCategory,\n SubProviderStatus,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubRenewalEvent,\n SubUpdateProviderInput,\n SubUpdateRelationshipInput,\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\nconst ENTITLEMENT_FIELDS = `\n id name description type relationshipId quota used unit isActive\n workspaceId createdAt updatedAt\n`;\n\nconst ASSET_FIELDS = `\n id name type relationshipId secretRef expiresAt workspaceId createdAt\n updatedAt file { id }\n`;\n\nconst PAYMENT_INSTRUMENT_FIELDS = `\n id label type status brand last4 expiryMonth expiryYear isDefault ownerId\n workspaceId createdAt updatedAt\n`;\n\nconst CHANNEL_FIELDS = `\n id label type status address ingestEnabled ownerId verifiedAt workspaceId\n createdAt updatedAt\n`;\n\nconst POLICY_FIELDS = `\n id name description action agentId isEnabled triggerCount lastTriggeredAt\n workspaceId 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 /** Case-insensitive substring match on the relationship label (server-side). */\n search?: 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 $search: String\n $pagination: PaginationInput\n ) {\n subListRelationships(\n kind: $kind\n status: $status\n providerId: $providerId\n ownerId: $ownerId\n search: $search\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 search: filters.search,\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 useUpdateRelationship = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, input }: { id: string; input: SubUpdateRelationshipInput }) => {\n const result = await subQuery<{ subUpdateRelationship: SubRelationship }>(\n `mutation SubUpdateRelationship($id: ID!, $input: SubUpdateRelationshipInput!) {\n subUpdateRelationship(id: $id, input: $input) { ${RELATIONSHIP_FIELDS} }\n }`,\n { id, input },\n apiGatewayUrl\n );\n return result.subUpdateRelationship;\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 // subListRenewalEvents returns SubRenewalEventConnection (items/pageInfo),\n // not a bare list — matching every other subList* root field in this\n // schema (see useRelationships above). Selecting event fields directly\n // fails GraphQL validation server-side (`Cannot query field \"id\" on type\n // \"SubRenewalEventConnection\"`).\n const result = await subQuery<{\n subListRenewalEvents: SubConnection<SubRenewalEvent>;\n }>(\n `query SubRenewalEvents($relationshipId: ID, $upcomingOnly: Boolean) {\n subListRenewalEvents(relationshipId: $relationshipId, upcomingOnly: $upcomingOnly) {\n items {\n id relationshipId eventType occursAt amount currency detail notified\n workspaceId createdAt updatedAt\n }\n pageInfo { cursor hasMore }\n }\n }`,\n { relationshipId: args.relationshipId, upcomingOnly: args.upcomingOnly },\n apiGatewayUrl\n );\n return result.subListRenewalEvents.items;\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<{\n subListEntitlements: SubConnection<SubEntitlement>;\n }>(\n `query SubEntitlements($relationshipId: ID!) {\n subListEntitlements(relationshipId: $relationshipId) {\n items {\n id name description type relationshipId quota used unit isActive\n workspaceId createdAt updatedAt\n }\n pageInfo { cursor hasMore }\n }\n }`,\n { relationshipId },\n apiGatewayUrl\n );\n return result.subListEntitlements.items;\n },\n });\n};\n\nexport const useCreateEntitlement = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateEntitlementInput) => {\n const result = await subQuery<{ subCreateEntitlement: SubEntitlement }>(\n `mutation SubCreateEntitlement($input: SubCreateEntitlementInput!) {\n subCreateEntitlement(input: $input) { ${ENTITLEMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateEntitlement;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.entitlements });\n void queryClient.invalidateQueries({ queryKey: KEY.relationship(data.relationshipId) });\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: SubConnection<SubAsset> }>(\n `query SubAssets($relationshipId: ID!) {\n subListAssets(relationshipId: $relationshipId) {\n items {\n id name type relationshipId secretRef expiresAt workspaceId\n createdAt updatedAt file { id }\n }\n pageInfo { cursor hasMore }\n }\n }`,\n { relationshipId },\n apiGatewayUrl\n );\n return result.subListAssets.items;\n },\n });\n};\n\n/** Every asset in the workspace (Digital Asset Vault) — omits relationshipId. */\nexport const useAllAssets = () => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.assets, 'all'],\n queryFn: async () => {\n const result = await subQuery<{ subListAssets: SubConnection<SubAsset> }>(\n `query SubAllAssets {\n subListAssets { items { ${ASSET_FIELDS} } pageInfo { cursor hasMore } }\n }`,\n {},\n apiGatewayUrl\n );\n return result.subListAssets.items;\n },\n });\n};\n\nexport const useCreateAsset = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateAssetInput) => {\n const result = await subQuery<{ subCreateAsset: SubAsset }>(\n `mutation SubCreateAsset($input: SubCreateAssetInput!) {\n subCreateAsset(input: $input) { ${ASSET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateAsset;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.assets });\n void queryClient.invalidateQueries({ queryKey: KEY.relationship(data.relationshipId) });\n },\n });\n};\n\n/**\n * Upload a file to `wspace-files-svc` and return its File id, using the\n * platform-standard 3-step flow (initiateUpload → presigned PUT → completeUpload)\n * over the same `graphqlFetch` transport the rest of this MFE uses. Assets store\n * only the returned `fileId` on `SubCreateAssetInput`; blobs live in files-svc.\n *\n * `CompleteUploadInput.fileSize` is a REQUIRED BigInt (quota tracking) and must\n * match the value given to `initiateUpload` — we pass `String(file.size)` to both.\n */\nconst ASSET_FOLDER_PATH = '/SubscriberBot/Assets';\n\nexport const useUploadFile = () => {\n const { apiGatewayUrl } = useSubscriberBot();\n const [progress, setProgress] = useState(0);\n const [isUploading, setIsUploading] = useState(false);\n\n const uploadFile = useCallback(\n async (file: File): Promise<{ fileId: string; fileName: string }> => {\n setIsUploading(true);\n setProgress(0);\n try {\n // 1. Resolve (or create) the destination folder — File.folderId is a real FK.\n const folderRes = await subQuery<{ ensureFolderByPath: { id: string } | null }>(\n `mutation SubEnsureFolder($path: String!) {\n ensureFolderByPath(path: $path) { id }\n }`,\n { path: ASSET_FOLDER_PATH },\n apiGatewayUrl\n );\n const folderId = folderRes.ensureFolderByPath?.id;\n if (!folderId) throw new Error('Could not resolve the upload folder.');\n\n const mimeType = file.type || 'application/octet-stream';\n const dotIndex = file.name.lastIndexOf('.');\n const extension = dotIndex > -1 ? file.name.slice(dotIndex + 1) : 'bin';\n\n // 2. Open a presigned upload session.\n const initiated = await subQuery<{\n initiateUpload: { uploadUrl: string | null; session: { id: string } } | null;\n }>(\n `mutation SubInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id }\n }\n }`,\n {\n input: {\n fileName: file.name,\n extension,\n mimeType,\n fileSize: String(file.size),\n folderId,\n },\n },\n apiGatewayUrl\n );\n const uploadUrl = initiated.initiateUpload?.uploadUrl;\n const sessionId = initiated.initiateUpload?.session.id;\n if (!uploadUrl || !sessionId) {\n throw new Error('The files service did not return an upload URL.');\n }\n\n // 3. PUT the raw bytes to storage. Content-Type must match what was signed.\n await new Promise<void>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.open('PUT', uploadUrl);\n xhr.setRequestHeader('Content-Type', mimeType);\n xhr.upload.onprogress = (event) => {\n if (event.lengthComputable) {\n setProgress(Math.round((event.loaded / event.total) * 100));\n }\n };\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) resolve();\n else reject(new Error(`Upload to storage failed (${xhr.status}).`));\n };\n xhr.onerror = () => reject(new Error('Upload to storage failed.'));\n xhr.send(file);\n });\n\n // 4. Finalize — creates the File record. fileSize must match initiateUpload.\n const completed = await subQuery<{\n completeUpload: { fileId: string; file: { id: string; name: string } | null } | null;\n }>(\n `mutation SubCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) {\n fileId\n file { id name }\n }\n }`,\n { input: { sessionId, fileSize: String(file.size), folderId } },\n apiGatewayUrl\n );\n const fileId = completed.completeUpload?.file?.id ?? completed.completeUpload?.fileId;\n if (!fileId) throw new Error('The upload could not be finalized.');\n return { fileId, fileName: completed.completeUpload?.file?.name ?? file.name };\n } finally {\n setIsUploading(false);\n }\n },\n [apiGatewayUrl]\n );\n\n return { uploadFile, progress, isUploading };\n};\n\n/**\n * Resolve a short-lived presigned download URL for a `wspace-files-svc` File id.\n * Never select the federated arg-less `File.downloadUrl` (it mints a URL beyond\n * S3's 7-day cap and 500s the response) — use the root `getFileDownloadUrl`\n * query with a TTL under 604800s instead.\n */\nexport const useFileDownloadUrl = () => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useCallback(\n async (fileId: string): Promise<string> => {\n const result = await subQuery<{ getFileDownloadUrl: string }>(\n `query SubFileDownloadUrl($id: ID!, $expiresIn: Int) {\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n }`,\n { id: fileId, expiresIn: 21600 },\n apiGatewayUrl\n );\n return result.getFileDownloadUrl;\n },\n [apiGatewayUrl]\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 useUpdateProvider = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, input }: { id: string; input: SubUpdateProviderInput }) => {\n const result = await subQuery<{ subUpdateProvider: SubProvider }>(\n `mutation SubUpdateProvider($id: ID!, $input: SubUpdateProviderInput!) {\n subUpdateProvider(id: $id, input: $input) { ${PROVIDER_FIELDS} }\n }`,\n { id, input },\n apiGatewayUrl\n );\n return result.subUpdateProvider;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.providers });\n void queryClient.invalidateQueries({ queryKey: KEY.provider(data.id) });\n },\n });\n};\n\nexport const useArchiveProvider = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subArchiveProvider: boolean }>(\n `mutation SubArchiveProvider($id: ID!) {\n subArchiveProvider(id: $id)\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subArchiveProvider;\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: SubConnection<SubPlan> }>(\n `query SubPlans($providerId: ID) {\n subListPlans(providerId: $providerId) { items { ${PLAN_FIELDS} } pageInfo { cursor hasMore } }\n }`,\n { providerId },\n apiGatewayUrl\n );\n return result.subListPlans.items;\n },\n });\n};\n\nexport const useCreatePlan = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreatePlanInput) => {\n const result = await subQuery<{ subCreatePlan: SubPlan }>(\n `mutation SubCreatePlan($input: SubCreatePlanInput!) {\n subCreatePlan(input: $input) { ${PLAN_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreatePlan;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.plans });\n void queryClient.invalidateQueries({ queryKey: KEY.provider(data.providerId) });\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\nexport const useIngestMessage = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubIngestMessageInput) => {\n const result = await subQuery<{ subIngestMessage: SubInboxMessage }>(\n `mutation SubIngestMessage($input: SubIngestMessageInput!) {\n subIngestMessage(input: $input) { ${INBOX_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subIngestMessage;\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\nexport const useCreateInvoice = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateInvoiceInput) => {\n const result = await subQuery<{ subCreateInvoice: SubInvoice }>(\n `mutation SubCreateInvoice($input: SubCreateInvoiceInput!) {\n subCreateInvoice(input: $input) { ${INVOICE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateInvoice;\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<{\n subListPaymentInstruments: SubConnection<SubPaymentInstrument>;\n }>(\n `query SubPaymentInstruments($ownerId: ID) {\n subListPaymentInstruments(ownerId: $ownerId) {\n items {\n id label type status brand last4 expiryMonth expiryYear isDefault\n ownerId workspaceId createdAt updatedAt\n }\n pageInfo { cursor hasMore }\n }\n }`,\n { ownerId },\n apiGatewayUrl\n );\n return result.subListPaymentInstruments.items;\n },\n });\n};\n\nexport const useCreatePaymentInstrument = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreatePaymentInstrumentInput) => {\n const result = await subQuery<{ subCreatePaymentInstrument: SubPaymentInstrument }>(\n `mutation SubCreatePaymentInstrument($input: SubCreatePaymentInstrumentInput!) {\n subCreatePaymentInstrument(input: $input) { ${PAYMENT_INSTRUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreatePaymentInstrument;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.paymentInstruments });\n },\n });\n};\n\nexport const useRemovePaymentInstrument = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subRemovePaymentInstrument: boolean }>(\n `mutation SubRemovePaymentInstrument($id: ID!) {\n subRemovePaymentInstrument(id: $id)\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subRemovePaymentInstrument;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.paymentInstruments });\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<{\n subListChannels: SubConnection<SubCommunicationChannel>;\n }>(\n `query SubChannels($ownerId: ID) {\n subListChannels(ownerId: $ownerId) {\n items {\n id label type status address ingestEnabled ownerId verifiedAt\n workspaceId createdAt updatedAt\n }\n pageInfo { cursor hasMore }\n }\n }`,\n { ownerId },\n apiGatewayUrl\n );\n return result.subListChannels.items;\n },\n });\n};\n\nexport const useCreateChannel = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreateChannelInput) => {\n const result = await subQuery<{ subCreateChannel: SubCommunicationChannel }>(\n `mutation SubCreateChannel($input: SubCreateChannelInput!) {\n subCreateChannel(input: $input) { ${CHANNEL_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreateChannel;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.channels });\n },\n });\n};\n\nexport const useVerifyChannel = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await subQuery<{ subVerifyChannel: SubCommunicationChannel }>(\n `mutation SubVerifyChannel($id: ID!) {\n subVerifyChannel(id: $id) { ${CHANNEL_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.subVerifyChannel;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.channels });\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: SubConnection<SubAiAgent> }>(\n `query SubAgents($kind: SubAgentKind, $status: SubAgentStatus, $ownerId: ID) {\n subListAgents(kind: $kind, status: $status, ownerId: $ownerId) {\n items { ${AGENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { kind: filters.kind, status: filters.status, ownerId: filters.ownerId },\n apiGatewayUrl\n );\n return result.subListAgents.items;\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 useCreatePolicy = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async (input: SubCreatePolicyInput) => {\n const result = await subQuery<{ subCreatePolicy: SubPolicy }>(\n `mutation SubCreatePolicy($input: SubCreatePolicyInput!) {\n subCreatePolicy(input: $input) { ${POLICY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.subCreatePolicy;\n },\n onSuccess: (data) => {\n void queryClient.invalidateQueries({ queryKey: KEY.agents });\n void queryClient.invalidateQueries({ queryKey: KEY.agent(data.agentId) });\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: SubConnection<SubWorkflow> }>(\n `query SubWorkflows($status: SubWorkflowStatus) {\n subListWorkflows(status: $status) { items { ${WORKFLOW_FIELDS} } pageInfo { cursor hasMore } }\n }`,\n { status },\n apiGatewayUrl\n );\n return result.subListWorkflows.items;\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":";;;;;;;AAoEA,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;AAW1D,QAHI,iBAAiB,KAAK,EAAM,IAC9B,GAAgC,EAE3B,EAAS;GAIZ,IAAM;CACV,eAAe,CAAC,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