@burdenoff/microfe-subscriberbot 2026.731.1 → 2026.827.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/SubscriberBotRoutes.js +1 -1
- package/dist/subscriberbot/SubscriberBotRoutes.js.map +1 -1
- package/dist/subscriberbot/components/viz.js +51 -27
- package/dist/subscriberbot/components/viz.js.map +1 -1
- package/dist/subscriberbot/context/SubscriberBotContext.js +1 -1
- package/dist/subscriberbot/context/SubscriberBotContext.js.map +1 -1
- package/dist/subscriberbot/hooks/index.d.ts +1 -1
- package/dist/subscriberbot/hooks/index.d.ts.map +1 -1
- package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts +12 -1
- package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts.map +1 -1
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js +82 -56
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
- package/dist/subscriberbot/pages/AssetVaultPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/AssetVaultPage.js +134 -78
- package/dist/subscriberbot/pages/AssetVaultPage.js.map +1 -1
- package/dist/subscriberbot/pages/InvoicesPage.d.ts +3 -2
- package/dist/subscriberbot/pages/InvoicesPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/InvoicesPage.js +43 -31
- package/dist/subscriberbot/pages/InvoicesPage.js.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentDetailPage.d.ts +3 -1
- package/dist/subscriberbot/pages/agents/AgentDetailPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentDetailPage.js +195 -159
- package/dist/subscriberbot/pages/agents/AgentDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.d.ts +4 -2
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.js +368 -266
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
- package/dist/subscriberbot/types/index.d.ts +37 -0
- package/dist/subscriberbot/types/index.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -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 SubAdapterSubmission,\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 SubMarketplaceReport,\n SubMessageCategory,\n SubModerationAction,\n SubPaymentInstrument,\n SubPlan,\n SubPolicy,\n SubProvider,\n SubProviderCategory,\n SubProviderStatus,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubRenewalEvent,\n SubReportStatus,\n SubSubmissionStatus,\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 adapterSubmissions: ['subscriberbot', 'admin', 'adapter-submissions'] as const,\n marketplaceReports: ['subscriberbot', 'admin', 'marketplace-reports'] 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\nconst ADAPTER_SUBMISSION_FIELDS = `\n id workspaceId adapterId submitterWorkspaceId status notes createdAt updatedAt\n`;\n\nconst MARKETPLACE_REPORT_FIELDS = `\n id workspaceId listingId reporterWorkspaceId reason status resolutionReason\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 /** 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\n// ============================================================================\n// Admin governance (adapter approvals + marketplace moderation)\n// ============================================================================\n\nexport interface AdapterSubmissionListFilters {\n status?: SubSubmissionStatus;\n pagination?: PaginationInput;\n}\n\nexport const useAdapterSubmissions = (filters: AdapterSubmissionListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.adapterSubmissions, filters],\n queryFn: async () => {\n const result = await subQuery<{\n subListAdapterSubmissions: SubConnection<SubAdapterSubmission>;\n }>(\n `query SubAdapterSubmissions($status: SubSubmissionStatus, $pagination: PaginationInput) {\n subListAdapterSubmissions(status: $status, pagination: $pagination) {\n items { ${ADAPTER_SUBMISSION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n status: filters.status,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListAdapterSubmissions;\n },\n });\n};\n\nexport const useApproveAdapter = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, notes }: { id: string; notes?: string }) => {\n const result = await subQuery<{ subApproveAdapter: SubAdapterSubmission }>(\n `mutation SubApproveAdapter($id: ID!, $notes: String) {\n subApproveAdapter(id: $id, notes: $notes) { ${ADAPTER_SUBMISSION_FIELDS} }\n }`,\n { id, notes },\n apiGatewayUrl\n );\n return result.subApproveAdapter;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.adapterSubmissions });\n },\n });\n};\n\nexport const useRejectAdapter = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, reason }: { id: string; reason: string }) => {\n const result = await subQuery<{ subRejectAdapter: SubAdapterSubmission }>(\n `mutation SubRejectAdapter($id: ID!, $reason: String!) {\n subRejectAdapter(id: $id, reason: $reason) { ${ADAPTER_SUBMISSION_FIELDS} }\n }`,\n { id, reason },\n apiGatewayUrl\n );\n return result.subRejectAdapter;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.adapterSubmissions });\n },\n });\n};\n\nexport interface MarketplaceReportListFilters {\n status?: SubReportStatus;\n pagination?: PaginationInput;\n}\n\nexport const useMarketplaceReports = (filters: MarketplaceReportListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.marketplaceReports, filters],\n queryFn: async () => {\n const result = await subQuery<{\n subListMarketplaceReports: SubConnection<SubMarketplaceReport>;\n }>(\n `query SubMarketplaceReports($status: SubReportStatus, $pagination: PaginationInput) {\n subListMarketplaceReports(status: $status, pagination: $pagination) {\n items { ${MARKETPLACE_REPORT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n status: filters.status,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListMarketplaceReports;\n },\n });\n};\n\nexport const useModerateListing = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({\n id,\n action,\n reason,\n }: {\n id: string;\n action: SubModerationAction;\n reason: string;\n }) => {\n const result = await subQuery<{ subModerateListing: SubMarketplaceReport }>(\n `mutation SubModerateListing($id: ID!, $action: SubModerationAction!, $reason: String!) {\n subModerateListing(id: $id, action: $action, reason: $reason) { ${MARKETPLACE_REPORT_FIELDS} }\n }`,\n { id, action, reason },\n apiGatewayUrl\n );\n return result.subModerateListing;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.marketplaceReports });\n },\n });\n};\n"],"mappings":";;;;;;;AAyEA,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,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;EAA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gB,EAC9B,EAAE,qBAAkB,GAAkB;AAC5C,QAAO,EAAY;EACjB,YAAY,OAAO,EACjB,OACA,WACA,iBAMe,MAAM,EACnB;4EACoE,EAA0B;YAE9F;GAAE;GAAI;GAAQ;GAAQ,EACtB,EACD,EACa;EAEhB,iBAAiB;AACV,KAAY,kBAAkB,EAAE,UAAU,EAAI,oBAAoB,CAAC;;EAE3E,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 SubAdapterSubmission,\n SubAgentKind,\n SubAgentStatus,\n SubAiAgent,\n SubAsset,\n SubBenchmarkDataPoint,\n SubBenchmarkFilterInput,\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 SubMarketplaceReport,\n SubMessageCategory,\n SubModerationAction,\n SubPaymentInstrument,\n SubPlan,\n SubPolicy,\n SubProvider,\n SubProviderCategory,\n SubProviderStatus,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubRenewalEvent,\n SubReportStatus,\n SubSubmissionStatus,\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 benchmarks: (providerSlug: string) => ['subscriberbot', 'benchmarks', providerSlug] 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 adapterSubmissions: ['subscriberbot', 'admin', 'adapter-submissions'] as const,\n marketplaceReports: ['subscriberbot', 'admin', 'marketplace-reports'] 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 condition isEnabled triggerCount\n lastTriggeredAt workspaceId createdAt updatedAt\n`;\n\nconst BENCHMARK_DATA_POINT_FIELDS = `\n id providerSlug providerName planName region currency interval amount\n contractSizeSeats sourceKind sourceLabel notes observedAt createdAt\n`;\n\nconst ADAPTER_SUBMISSION_FIELDS = `\n id workspaceId adapterId submitterWorkspaceId status notes createdAt updatedAt\n`;\n\nconst MARKETPLACE_REPORT_FIELDS = `\n id workspaceId listingId reporterWorkspaceId reason status resolutionReason\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 /** 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 * Observed price points for one provider, newest first from the server.\n *\n * Backs the provider \"Price history\" card. The benchmark dataset is read\n * GLOBALLY (`@rbac(..., public: true)` on the svc) — it is the same for every\n * workspace — so nothing here is workspace scoped. Matching is by\n * `providerSlug`, which is an exact match server-side; `providerName` is a\n * fuzzy `contains` match and would risk attributing another vendor's prices to\n * this provider, so the query stays disabled until a slug exists.\n */\nexport const useBenchmarkDataPoints = (providerSlug: string | null | undefined) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: KEY.benchmarks(providerSlug ?? ''),\n enabled: Boolean(providerSlug),\n queryFn: async () => {\n const filter: SubBenchmarkFilterInput = { providerSlug: providerSlug ?? undefined };\n const result = await subQuery<{\n subListBenchmarkDataPoints: SubConnection<SubBenchmarkDataPoint>;\n }>(\n `query SubBenchmarkDataPoints(\n $filter: SubBenchmarkFilterInput\n $pagination: PaginationInput\n ) {\n subListBenchmarkDataPoints(filter: $filter, pagination: $pagination) {\n items { ${BENCHMARK_DATA_POINT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: { limit: 100, offset: 0 } },\n apiGatewayUrl\n );\n return result.subListBenchmarkDataPoints.items;\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 { ${POLICY_FIELDS} }\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\n// ============================================================================\n// Admin governance (adapter approvals + marketplace moderation)\n// ============================================================================\n\nexport interface AdapterSubmissionListFilters {\n status?: SubSubmissionStatus;\n pagination?: PaginationInput;\n}\n\nexport const useAdapterSubmissions = (filters: AdapterSubmissionListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.adapterSubmissions, filters],\n queryFn: async () => {\n const result = await subQuery<{\n subListAdapterSubmissions: SubConnection<SubAdapterSubmission>;\n }>(\n `query SubAdapterSubmissions($status: SubSubmissionStatus, $pagination: PaginationInput) {\n subListAdapterSubmissions(status: $status, pagination: $pagination) {\n items { ${ADAPTER_SUBMISSION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n status: filters.status,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListAdapterSubmissions;\n },\n });\n};\n\nexport const useApproveAdapter = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, notes }: { id: string; notes?: string }) => {\n const result = await subQuery<{ subApproveAdapter: SubAdapterSubmission }>(\n `mutation SubApproveAdapter($id: ID!, $notes: String) {\n subApproveAdapter(id: $id, notes: $notes) { ${ADAPTER_SUBMISSION_FIELDS} }\n }`,\n { id, notes },\n apiGatewayUrl\n );\n return result.subApproveAdapter;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.adapterSubmissions });\n },\n });\n};\n\nexport const useRejectAdapter = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({ id, reason }: { id: string; reason: string }) => {\n const result = await subQuery<{ subRejectAdapter: SubAdapterSubmission }>(\n `mutation SubRejectAdapter($id: ID!, $reason: String!) {\n subRejectAdapter(id: $id, reason: $reason) { ${ADAPTER_SUBMISSION_FIELDS} }\n }`,\n { id, reason },\n apiGatewayUrl\n );\n return result.subRejectAdapter;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.adapterSubmissions });\n },\n });\n};\n\nexport interface MarketplaceReportListFilters {\n status?: SubReportStatus;\n pagination?: PaginationInput;\n}\n\nexport const useMarketplaceReports = (filters: MarketplaceReportListFilters = {}) => {\n const { apiGatewayUrl } = useSubscriberBot();\n return useQuery({\n queryKey: [...KEY.marketplaceReports, filters],\n queryFn: async () => {\n const result = await subQuery<{\n subListMarketplaceReports: SubConnection<SubMarketplaceReport>;\n }>(\n `query SubMarketplaceReports($status: SubReportStatus, $pagination: PaginationInput) {\n subListMarketplaceReports(status: $status, pagination: $pagination) {\n items { ${MARKETPLACE_REPORT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n status: filters.status,\n pagination: filters.pagination ?? { limit: 50, offset: 0 },\n },\n apiGatewayUrl\n );\n return result.subListMarketplaceReports;\n },\n });\n};\n\nexport const useModerateListing = () => {\n const queryClient = useQueryClient();\n const { apiGatewayUrl } = useSubscriberBot();\n return useMutation({\n mutationFn: async ({\n id,\n action,\n reason,\n }: {\n id: string;\n action: SubModerationAction;\n reason: string;\n }) => {\n const result = await subQuery<{ subModerateListing: SubMarketplaceReport }>(\n `mutation SubModerateListing($id: ID!, $action: SubModerationAction!, $reason: String!) {\n subModerateListing(id: $id, action: $action, reason: $reason) { ${MARKETPLACE_REPORT_FIELDS} }\n }`,\n { id, action, reason },\n apiGatewayUrl\n );\n return result.subModerateListing;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: KEY.marketplaceReports });\n },\n });\n};\n"],"mappings":";;;;;;;AA2EA,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,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,aAAa,MAAyB;EAAC;EAAiB;EAAc;EAAa;CACnF,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;CAC/C,oBAAoB;EAAC;EAAiB;EAAS;EAAsB;CACrE,oBAAoB;EAAC;EAAiB;EAAS;EAAsB;CACtE,EAMK,IAAk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EAAQ;GAChB,YAAY,EAAQ,cAAc;IAAE,OAAO;IAAI,QAAQ;IAAG;GAC3D,EACD,EACD,EACa;EAEjB,CAAC;GAGS,WAA2B;CACtC,IAAM,IAAc,GAAgB,EAC9B,EAAE,qBAAkB,GAAkB;AAC5C,QAAO,EAAY;EACjB,YAAY,OAAO,EACjB,OACA,WACA,iBAMe,MAAM,EACnB;4EACoE,EAA0B;YAE9F;GAAE;GAAI;GAAQ;GAAQ,EACtB,EACD,EACa;EAEhB,iBAAiB;AACV,KAAY,kBAAkB,EAAE,UAAU,EAAI,oBAAoB,CAAC;;EAE3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetVaultPage.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/pages/AssetVaultPage.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"AssetVaultPage.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/pages/AssetVaultPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAqB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAoHnD,eAAO,MAAM,cAAc,EAAE,EAgL5B,CAAC"}
|
|
@@ -7,20 +7,20 @@ import { ErrorView as o, LoadingView as s, Section as c } from "../components/St
|
|
|
7
7
|
import "../components/index.js";
|
|
8
8
|
import { useAllAssets as l, useFileDownloadUrl as u, useRelationships as d } from "../hooks/useSubscriberBotApi.js";
|
|
9
9
|
import { useMemo as f, useState as p } from "react";
|
|
10
|
-
import {
|
|
11
|
-
import { jsx as
|
|
12
|
-
import { GlassCard as
|
|
10
|
+
import { AlarmClock as m, Award as h, Download as g, File as _, FileKey as v, FileText as y, Globe as b, Receipt as x, Search as S, ShieldCheck as C, Vault as w } from "lucide-react";
|
|
11
|
+
import { jsx as T, jsxs as E } from "react/jsx-runtime";
|
|
12
|
+
import { GlassCard as D, PagePurpose as O } from "@burdenoff/fe-libs/ui";
|
|
13
13
|
//#region src/subscriberbot/pages/AssetVaultPage.tsx
|
|
14
|
-
var
|
|
15
|
-
CONTRACT:
|
|
16
|
-
LICENSE_KEY:
|
|
17
|
-
CREDENTIAL:
|
|
18
|
-
CERTIFICATE:
|
|
19
|
-
INVOICE:
|
|
20
|
-
RECEIPT:
|
|
21
|
-
WARRANTY:
|
|
22
|
-
DOMAIN:
|
|
23
|
-
},
|
|
14
|
+
var k = {
|
|
15
|
+
CONTRACT: y,
|
|
16
|
+
LICENSE_KEY: v,
|
|
17
|
+
CREDENTIAL: v,
|
|
18
|
+
CERTIFICATE: h,
|
|
19
|
+
INVOICE: x,
|
|
20
|
+
RECEIPT: x,
|
|
21
|
+
WARRANTY: C,
|
|
22
|
+
DOMAIN: b
|
|
23
|
+
}, A = [
|
|
24
24
|
"CONTRACT",
|
|
25
25
|
"LICENSE_KEY",
|
|
26
26
|
"CREDENTIAL",
|
|
@@ -29,47 +29,51 @@ var O = {
|
|
|
29
29
|
"RECEIPT",
|
|
30
30
|
"WARRANTY",
|
|
31
31
|
"DOMAIN"
|
|
32
|
-
],
|
|
32
|
+
], j = (e) => {
|
|
33
33
|
if (!e) return !1;
|
|
34
34
|
let t = new Date(e).getTime();
|
|
35
35
|
if (Number.isNaN(t)) return !1;
|
|
36
36
|
let n = (t - Date.now()) / 864e5;
|
|
37
37
|
return n >= 0 && n <= 30;
|
|
38
|
+
}, M = (e) => {
|
|
39
|
+
if (!e) return Infinity;
|
|
40
|
+
let t = new Date(e).getTime();
|
|
41
|
+
return Number.isNaN(t) ? Infinity : t;
|
|
38
42
|
};
|
|
39
|
-
function
|
|
40
|
-
let a = u(), [o, s] = p(!1), c =
|
|
41
|
-
return /* @__PURE__ */
|
|
43
|
+
function N({ asset: t, subscription: n }) {
|
|
44
|
+
let a = u(), [o, s] = p(!1), c = k[t.type] ?? _, l = j(t.expiresAt);
|
|
45
|
+
return /* @__PURE__ */ E(D, {
|
|
42
46
|
treatment: "metric",
|
|
43
47
|
className: "flex items-start gap-3 p-4",
|
|
44
48
|
children: [
|
|
45
|
-
/* @__PURE__ */
|
|
49
|
+
/* @__PURE__ */ T("span", {
|
|
46
50
|
className: "grid h-10 w-10 shrink-0 place-items-center rounded-lg bg-accent-wash text-text-link",
|
|
47
|
-
children: /* @__PURE__ */
|
|
51
|
+
children: /* @__PURE__ */ T(c, { className: "h-5 w-5" })
|
|
48
52
|
}),
|
|
49
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ E("div", {
|
|
50
54
|
className: "min-w-0 flex-1",
|
|
51
55
|
children: [
|
|
52
|
-
/* @__PURE__ */
|
|
56
|
+
/* @__PURE__ */ T("p", {
|
|
53
57
|
className: "truncate font-medium text-text-primary",
|
|
54
58
|
children: t.name
|
|
55
59
|
}),
|
|
56
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ T("p", {
|
|
57
61
|
className: "truncate text-xs text-text-secondary",
|
|
58
62
|
children: n
|
|
59
63
|
}),
|
|
60
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ E("div", {
|
|
61
65
|
className: "mt-1 flex flex-wrap items-center gap-2 text-xs",
|
|
62
|
-
children: [/* @__PURE__ */
|
|
66
|
+
children: [/* @__PURE__ */ T("span", {
|
|
63
67
|
className: "rounded bg-bg-sunken px-1.5 py-0.5 text-text-secondary",
|
|
64
68
|
children: i(t.type)
|
|
65
|
-
}), t.expiresAt && /* @__PURE__ */
|
|
69
|
+
}), t.expiresAt && /* @__PURE__ */ E("span", {
|
|
66
70
|
className: e(l ? "text-status-warning-text" : "text-text-secondary"),
|
|
67
71
|
children: ["Expires ", r(t.expiresAt)]
|
|
68
72
|
})]
|
|
69
73
|
})
|
|
70
74
|
]
|
|
71
75
|
}),
|
|
72
|
-
t.file?.id && /* @__PURE__ */
|
|
76
|
+
t.file?.id && /* @__PURE__ */ T("button", {
|
|
73
77
|
type: "button",
|
|
74
78
|
onClick: async () => {
|
|
75
79
|
if (!(!t.file?.id || o)) {
|
|
@@ -85,98 +89,150 @@ function j({ asset: t, subscription: n }) {
|
|
|
85
89
|
disabled: o,
|
|
86
90
|
"aria-label": `Download ${t.name}`,
|
|
87
91
|
className: "shrink-0 rounded-lg border border-border-subtle p-2 text-text-secondary hover:text-text-primary disabled:opacity-50",
|
|
88
|
-
children: /* @__PURE__ */
|
|
92
|
+
children: /* @__PURE__ */ T(g, { className: "h-4 w-4" })
|
|
89
93
|
})
|
|
90
94
|
]
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
|
-
var
|
|
94
|
-
let
|
|
97
|
+
var P = () => {
|
|
98
|
+
let u = l(), h = d({ pagination: { limit: 100 } }), [g, v] = p(""), [b, x] = p("ALL"), k = f(() => {
|
|
95
99
|
let e = /* @__PURE__ */ new Map();
|
|
96
|
-
for (let t of
|
|
100
|
+
for (let t of h.data?.items ?? []) e.set(t.id, t.label);
|
|
97
101
|
return e;
|
|
98
|
-
}, [
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
]),
|
|
102
|
+
}, [h.data]), P = f(() => u.data ?? [], [u.data]), F = f(() => P.filter((e) => (b === "ALL" || e.type === b) && (!g || e.name.toLowerCase().includes(g.toLowerCase()))), [
|
|
103
|
+
P,
|
|
104
|
+
b,
|
|
105
|
+
g
|
|
106
|
+
]), I = f(() => {
|
|
103
107
|
let e = /* @__PURE__ */ new Map();
|
|
104
|
-
for (let t of
|
|
105
|
-
return
|
|
106
|
-
}, [
|
|
107
|
-
return
|
|
108
|
+
for (let t of F) e.set(t.type, [...e.get(t.type) ?? [], t]);
|
|
109
|
+
return A.filter((t) => e.has(t)).map((t) => [t, e.get(t)]);
|
|
110
|
+
}, [F]), L = f(() => P.filter((e) => j(e.expiresAt)).sort((e, t) => M(e.expiresAt) - M(t.expiresAt)), [P]);
|
|
111
|
+
return u.isLoading ? /* @__PURE__ */ T(s, { label: "Loading your asset vault…" }) : u.isError ? /* @__PURE__ */ T(o, {
|
|
108
112
|
message: "Could not load the asset vault.",
|
|
109
|
-
onRetry: () => void
|
|
110
|
-
}) : /* @__PURE__ */
|
|
113
|
+
onRetry: () => void u.refetch()
|
|
114
|
+
}) : /* @__PURE__ */ E(t, {
|
|
111
115
|
title: "Asset vault",
|
|
112
116
|
description: "Every contract, receipt, license key and document attached to your subscriptions — in one secure place.",
|
|
113
117
|
children: [
|
|
114
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ T(O, {
|
|
115
119
|
className: "mb-2",
|
|
116
120
|
children: "Your subscription documents, together — contracts, receipts, license keys and more. Assets are stored in the shared files service and linked to the subscription they belong to. Attach new documents from any relationship’s detail page."
|
|
117
121
|
}),
|
|
118
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ E("div", {
|
|
119
123
|
className: "grid grid-cols-1 gap-4 sm:grid-cols-3",
|
|
120
124
|
children: [
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
icon: /* @__PURE__ */
|
|
123
|
-
value:
|
|
125
|
+
/* @__PURE__ */ T(n, {
|
|
126
|
+
icon: /* @__PURE__ */ T(_, { className: "h-5 w-5" }),
|
|
127
|
+
value: P.length,
|
|
124
128
|
label: "Documents stored"
|
|
125
129
|
}),
|
|
126
|
-
/* @__PURE__ */
|
|
127
|
-
icon: /* @__PURE__ */
|
|
128
|
-
value:
|
|
130
|
+
/* @__PURE__ */ T(n, {
|
|
131
|
+
icon: /* @__PURE__ */ T(y, { className: "h-5 w-5" }),
|
|
132
|
+
value: I.length,
|
|
129
133
|
label: "Document types"
|
|
130
134
|
}),
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
icon: /* @__PURE__ */
|
|
133
|
-
value:
|
|
135
|
+
/* @__PURE__ */ T(n, {
|
|
136
|
+
icon: /* @__PURE__ */ T(C, { className: "h-5 w-5" }),
|
|
137
|
+
value: L.length,
|
|
134
138
|
label: "Expiring within 30 days",
|
|
135
|
-
trend:
|
|
139
|
+
trend: L.length > 0 ? "down" : void 0
|
|
136
140
|
})
|
|
137
141
|
]
|
|
138
142
|
}),
|
|
139
|
-
/* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ E(D, {
|
|
140
144
|
treatment: "plain",
|
|
141
145
|
className: "flex flex-col gap-3 p-4 sm:flex-row sm:items-center",
|
|
142
|
-
children: [/* @__PURE__ */
|
|
146
|
+
children: [/* @__PURE__ */ E("div", {
|
|
143
147
|
className: "relative flex-1",
|
|
144
|
-
children: [/* @__PURE__ */
|
|
145
|
-
value:
|
|
146
|
-
onChange: (e) =>
|
|
148
|
+
children: [/* @__PURE__ */ T(S, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ T("input", {
|
|
149
|
+
value: g,
|
|
150
|
+
onChange: (e) => v(e.target.value),
|
|
147
151
|
placeholder: "Search documents…",
|
|
148
152
|
"aria-label": "Search documents",
|
|
149
153
|
className: "w-full rounded-lg border border-border-subtle bg-bg-surface py-2 pl-9 pr-3 text-sm text-text-primary placeholder:text-text-secondary"
|
|
150
154
|
})]
|
|
151
|
-
}), /* @__PURE__ */
|
|
155
|
+
}), /* @__PURE__ */ T("div", {
|
|
152
156
|
className: "flex flex-wrap gap-1.5",
|
|
153
|
-
children: ["ALL", ...
|
|
157
|
+
children: ["ALL", ...A].map((t) => /* @__PURE__ */ T("button", {
|
|
154
158
|
type: "button",
|
|
155
|
-
onClick: () =>
|
|
156
|
-
"aria-pressed":
|
|
157
|
-
className: e("rounded-full px-3 py-1 text-xs font-medium transition-colors",
|
|
159
|
+
onClick: () => x(t),
|
|
160
|
+
"aria-pressed": b === t,
|
|
161
|
+
className: e("rounded-full px-3 py-1 text-xs font-medium transition-colors", b === t ? "bg-accent-primary text-accent-foreground" : "bg-bg-sunken text-text-secondary hover:text-text-primary"),
|
|
158
162
|
children: t === "ALL" ? "All" : i(t)
|
|
159
163
|
}, t))
|
|
160
164
|
})]
|
|
161
165
|
}),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
166
|
+
/* @__PURE__ */ E("div", {
|
|
167
|
+
className: "grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1fr)_20rem]",
|
|
168
|
+
children: [/* @__PURE__ */ T("div", {
|
|
169
|
+
className: "min-w-0",
|
|
170
|
+
children: F.length === 0 ? /* @__PURE__ */ T(a, {
|
|
171
|
+
icon: /* @__PURE__ */ T(w, { className: "h-8 w-8" }),
|
|
172
|
+
title: P.length === 0 ? "No documents yet" : "No matching documents",
|
|
173
|
+
description: P.length === 0 ? "Attach a contract, receipt or license key from any subscription’s detail page and it will appear here." : "Try a different search or type filter."
|
|
174
|
+
}) : I.map(([e, t]) => /* @__PURE__ */ T(c, {
|
|
175
|
+
title: `${i(e)} · ${t.length}`,
|
|
176
|
+
children: /* @__PURE__ */ T("div", {
|
|
177
|
+
className: "grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",
|
|
178
|
+
children: t.map((e) => /* @__PURE__ */ T(N, {
|
|
179
|
+
asset: e,
|
|
180
|
+
subscription: k.get(e.relationshipId) ?? "—"
|
|
181
|
+
}, e.id))
|
|
182
|
+
})
|
|
183
|
+
}, e))
|
|
184
|
+
}), P.length > 0 && /* @__PURE__ */ T("aside", {
|
|
185
|
+
className: "lg:sticky lg:top-4 lg:self-start",
|
|
186
|
+
children: /* @__PURE__ */ E(D, {
|
|
187
|
+
treatment: "insight",
|
|
188
|
+
className: "p-5",
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ E("h3", {
|
|
191
|
+
className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
|
|
192
|
+
children: [/* @__PURE__ */ T(m, {
|
|
193
|
+
className: "h-4 w-4 text-status-warning-text",
|
|
194
|
+
"aria-hidden": !0
|
|
195
|
+
}), "Expiring soon"]
|
|
196
|
+
}),
|
|
197
|
+
/* @__PURE__ */ T("p", {
|
|
198
|
+
className: "mt-0.5 text-xs text-text-secondary",
|
|
199
|
+
children: "Documents lapsing in the next 30 days"
|
|
200
|
+
}),
|
|
201
|
+
L.length === 0 ? /* @__PURE__ */ T("p", {
|
|
202
|
+
className: "mt-4 text-sm text-text-secondary",
|
|
203
|
+
children: "Nothing in the vault expires in the next 30 days."
|
|
204
|
+
}) : /* @__PURE__ */ T("ul", {
|
|
205
|
+
className: "mt-4 space-y-2.5",
|
|
206
|
+
children: L.map((e) => /* @__PURE__ */ E("li", {
|
|
207
|
+
className: "rounded-lg border border-status-warning-border bg-status-warning-bg-subtle p-3",
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ T("p", {
|
|
210
|
+
className: "truncate text-sm font-medium text-status-warning-text",
|
|
211
|
+
children: e.name
|
|
212
|
+
}),
|
|
213
|
+
/* @__PURE__ */ T("p", {
|
|
214
|
+
className: "truncate text-xs text-text-secondary",
|
|
215
|
+
children: k.get(e.relationshipId) ?? "—"
|
|
216
|
+
}),
|
|
217
|
+
/* @__PURE__ */ E("p", {
|
|
218
|
+
className: "mt-1 text-xs text-text-secondary",
|
|
219
|
+
children: [
|
|
220
|
+
i(e.type),
|
|
221
|
+
" · Expires ",
|
|
222
|
+
r(e.expiresAt)
|
|
223
|
+
]
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
}, e.id))
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
})
|
|
230
|
+
})]
|
|
231
|
+
})
|
|
176
232
|
]
|
|
177
233
|
});
|
|
178
234
|
};
|
|
179
235
|
//#endregion
|
|
180
|
-
export {
|
|
236
|
+
export { P as AssetVaultPage };
|
|
181
237
|
|
|
182
238
|
//# sourceMappingURL=AssetVaultPage.js.map
|