@burdenoff/microfe-govcitizenhub 2026.730.2 → 2026.730.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"useIntelligenceApi.js","names":[],"sources":["../../../src/govcitizenhub/hooks/useIntelligenceApi.ts"],"sourcesContent":["/**\n * GovCitizenHub — Community Intelligence API hooks (BOFF-5666)\n * @module govcitizenhub/hooks\n *\n * React-Query hooks wired DIRECTLY to the FROZEN `wspace-govcitizenhub-svc`\n * `intelligence` subgraph contract. Every operation below uses an inline gql\n * string whose field and argument names match\n * `src/modules/intelligence/schema/*.gql` exactly. No mock data anywhere.\n *\n * Transport is the shared `govQuery` from `./useGovApi` —\n * `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` with the\n * partial-success handling and the pre/post-write response-cache clear. The\n * `page()` helper is likewise reused so the service never sees `cursor: null`\n * (see `svc-cursor-null-pagination-bug`).\n *\n * IMPORTANT CONTRACT NOTES\n * - Connections are `{ items, pageInfo { cursor hasMore } }`. There is NO\n * `totalCount` — never render `items.length` as a corpus total.\n * - `User` / `File` are id-only federation stubs. File references are opaque\n * `*FileId` strings resolved through the `useFiles` hook — we never select\n * `file { url }` or an office holder's platform account name.\n * - Queries that take an id are `enabled` only once the id is present.\n */\n\nimport { useMutation, useQuery, useQueryClient, type QueryClient } from '@tanstack/react-query';\n\nimport { useGovCitizenHub } from '../context';\nimport { govQuery, page } from './useGovApi';\nimport type {\n GovAdminLevel,\n GovAdminLevelConnection,\n GovAssetCategoryCount,\n GovBenchmarkResult,\n GovBenchmarkScope,\n GovBudget,\n GovBudgetConnection,\n GovBudgetExecution,\n GovBudgetFilterInput,\n GovBudgetLineInput,\n GovConsultation,\n GovConsultationConnection,\n GovConsultationFilterInput,\n GovConsultationResponse,\n GovConsultationResults,\n GovCreateAdminLevelInput,\n GovCreateBudgetInput,\n GovCreateConsultationInput,\n GovCreateDatasetInput,\n GovCreateElectionInput,\n GovCreateIndicatorInput,\n GovCreateJurisdictionEventInput,\n GovCreateJurisdictionInput,\n GovCreateOfficialCommitmentInput,\n GovCreateOfficialInput,\n GovCreateProjectInput,\n GovCreateProjectMilestoneInput,\n GovCreatePublicAssetInput,\n GovDataChangeProposal,\n GovDataChangeProposalConnection,\n GovDataChangeProposalFilterInput,\n GovDataset,\n GovDatasetConnection,\n GovDatasetFilterInput,\n GovElection,\n GovElectionConnection,\n GovElectionFilterInput,\n GovElectionResultInput,\n GovGrievanceInsights,\n GovIndicator,\n GovIndicatorConnection,\n GovIndicatorDomain,\n GovIndicatorFilterInput,\n GovIndicatorSeries,\n GovIndicatorValue,\n GovIndicatorValueConnection,\n GovIndicatorValueFilterInput,\n GovJurisdiction,\n GovJurisdictionConnection,\n GovJurisdictionEvent,\n GovJurisdictionEventConnection,\n GovJurisdictionFilterInput,\n GovJurisdictionFollow,\n GovJurisdictionInsight,\n GovJurisdictionOverview,\n GovJurisdictionScorecard,\n GovJurisdictionTreeNode,\n GovOfficial,\n GovOfficialCommitment,\n GovOfficialCommitmentConnection,\n GovOfficialCommitmentFilterInput,\n GovOfficialConnection,\n GovOfficialFilterInput,\n GovProject,\n GovProjectConnection,\n GovProjectFilterInput,\n GovProjectMilestone,\n GovProjectStatus,\n GovProposalStatus,\n GovPublicAsset,\n GovPublicAssetConnection,\n GovPublicAssetFilterInput,\n GovRecordIndicatorValueInput,\n GovServicePerformance,\n GovSubmitConsultationResponseInput,\n GovSubmitDataChangeProposalInput,\n GovUpdateAdminLevelInput,\n GovUpdateBudgetInput,\n GovUpdateConsultationInput,\n GovUpdateDatasetInput,\n GovUpdateElectionInput,\n GovUpdateIndicatorInput,\n GovUpdateIndicatorValueInput,\n GovUpdateJurisdictionEventInput,\n GovUpdateJurisdictionInput,\n GovUpdateOfficialCommitmentInput,\n GovUpdateOfficialInput,\n GovUpdateProjectInput,\n GovUpdateProjectMilestoneInput,\n GovUpdatePublicAssetInput,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// React-Query key roots — one `intel*` namespace per Community Intelligence\n// surface. Every entry is a PREFIX: `invalidateQueries({ queryKey: KEY.intelX })`\n// therefore also drops every id-scoped/derived entry built from it.\n// ============================================================================\n\nconst ROOT = ['govcitizenhub', 'intel'] as const;\n\nconst KEY = {\n intelAdminLevels: [...ROOT, 'admin-levels'] as const,\n intelAdminLevel: (id: string) => [...ROOT, 'admin-level', id] as const,\n intelJurisdictions: [...ROOT, 'jurisdictions'] as const,\n intelJurisdiction: (id: string) => [...ROOT, 'jurisdiction', id] as const,\n intelJurisdictionBySlug: (slug: string) => [...ROOT, 'jurisdiction-by-slug', slug] as const,\n intelJurisdictionTree: [...ROOT, 'jurisdiction-tree'] as const,\n intelOverview: [...ROOT, 'jurisdiction-overview'] as const,\n intelOverviewFor: (jurisdictionId: string) =>\n [...ROOT, 'jurisdiction-overview', jurisdictionId] as const,\n intelOfficials: [...ROOT, 'officials'] as const,\n intelOfficial: (id: string) => [...ROOT, 'official', id] as const,\n intelCommitments: [...ROOT, 'official-commitments'] as const,\n intelElections: [...ROOT, 'elections'] as const,\n intelElection: (id: string) => [...ROOT, 'election', id] as const,\n intelEvents: [...ROOT, 'jurisdiction-events'] as const,\n intelEventsFor: (jurisdictionId: string) =>\n [...ROOT, 'jurisdiction-events', jurisdictionId] as const,\n intelBudgets: [...ROOT, 'budgets'] as const,\n intelBudget: (id: string) => [...ROOT, 'budget', id] as const,\n intelBudgetExecution: [...ROOT, 'budget-execution'] as const,\n intelBudgetExecutionFor: (budgetId: string) => [...ROOT, 'budget-execution', budgetId] as const,\n intelProjects: [...ROOT, 'projects'] as const,\n intelProject: (id: string) => [...ROOT, 'project', id] as const,\n intelIndicators: [...ROOT, 'indicators'] as const,\n intelIndicator: (id: string) => [...ROOT, 'indicator', id] as const,\n intelIndicatorValues: [...ROOT, 'indicator-values'] as const,\n intelIndicatorSeries: [...ROOT, 'indicator-series'] as const,\n intelScorecard: [...ROOT, 'scorecard'] as const,\n intelBenchmark: [...ROOT, 'benchmark'] as const,\n intelInsights: [...ROOT, 'insights'] as const,\n intelServicePerformance: [...ROOT, 'service-performance'] as const,\n intelGrievanceInsights: [...ROOT, 'grievance-insights'] as const,\n intelAssets: [...ROOT, 'public-assets'] as const,\n intelAsset: (id: string) => [...ROOT, 'public-asset', id] as const,\n intelAssetSummary: [...ROOT, 'public-asset-summary'] as const,\n intelAssetSummaryFor: (jurisdictionId: string) =>\n [...ROOT, 'public-asset-summary', jurisdictionId] as const,\n intelConsultations: [...ROOT, 'consultations'] as const,\n intelConsultation: (id: string) => [...ROOT, 'consultation', id] as const,\n intelConsultationResults: [...ROOT, 'consultation-results'] as const,\n intelConsultationResultsFor: (consultationId: string) =>\n [...ROOT, 'consultation-results', consultationId] as const,\n intelMyConsultationResponse: [...ROOT, 'my-consultation-response'] as const,\n intelMyConsultationResponseFor: (consultationId: string) =>\n [...ROOT, 'my-consultation-response', consultationId] as const,\n intelDatasets: [...ROOT, 'datasets'] as const,\n intelDataset: (id: string) => [...ROOT, 'dataset', id] as const,\n intelMyFollowed: [...ROOT, 'my-followed-jurisdictions'] as const,\n intelProposals: [...ROOT, 'data-change-proposals'] as const,\n intelProposal: (id: string) => [...ROOT, 'data-change-proposal', id] as const,\n intelMyProposals: [...ROOT, 'my-data-change-proposals'] as const,\n};\n\n/**\n * `govQuery` treats an all-null payload as a failed request — it cannot tell a\n * dropped response from a legitimately-null field. Several intelligence reads\n * resolve to null as their NORMAL state (`govMyConsultationResponse` before the\n * actor has responded, `govJurisdictionScorecard` before any core indicator is\n * measured). This unwraps that specific case back to a plain `null`; a real\n * gateway/service error still carries a server message and still throws.\n */\nconst NO_DATA_MESSAGE = 'GraphQL response did not include data';\n\nconst govNullableQuery = async <TField>(\n query: string,\n variables: Record<string, unknown>,\n field: string,\n baseUrl?: string\n): Promise<TField | null> => {\n try {\n const result = await govQuery<Record<string, TField | null>>(query, variables, baseUrl);\n return result[field] ?? null;\n } catch (error) {\n if (error instanceof Error && error.message === NO_DATA_MESSAGE) return null;\n throw error;\n }\n};\n\n/**\n * Derived surfaces (overview tiles, scorecard, insights, benchmark, series) are\n * computed live from indicators, budgets, projects, assets, datasets and\n * consultations — so any write to those has to drop them too.\n */\nconst invalidateDerived = (qc: QueryClient): void => {\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n qc.invalidateQueries({ queryKey: KEY.intelScorecard });\n qc.invalidateQueries({ queryKey: KEY.intelInsights });\n qc.invalidateQueries({ queryKey: KEY.intelBenchmark });\n};\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness). Every name below is\n// verified against the frozen SDL.\n// ============================================================================\n\nconst ADMIN_LEVEL_FIELDS = `\n id workspaceId countryCode rank code name pluralName description isElectoral\n jurisdictionCount createdAt updatedAt\n`;\n\nconst JURISDICTION_FIELDS = `\n id workspaceId parentId adminLevelId countryCode name localName officialCode slug status\n path depth summary establishedOn headquarters officialWebsite contactEmail contactPhone\n emergencyNumbers timezone languages currencyCode climateSummary areaSqKm population\n populationYear households centroidLat centroidLng populationDensity boundaryFileId\n bannerFileId crestFileId tags sourceName sourceUrl verification publishedAt\n createdAt updatedAt\n`;\n\n/**\n * Narrower selection for nested parent / ancestor / child jurisdictions. It\n * still covers every NON-NULL field of `GovJurisdiction`, so the value we hand\n * back genuinely satisfies the type — it just omits the long-form profile prose.\n */\nconst JURISDICTION_REF_FIELDS = `\n id workspaceId parentId adminLevelId countryCode name localName officialCode slug status\n path depth areaSqKm population populationYear populationDensity crestFileId bannerFileId\n languages tags verification publishedAt createdAt updatedAt\n`;\n\nconst TREE_NODE_FIELDS = `\n id name slug status depth adminLevelCode adminLevelName population childCount\n`;\n\n/**\n * `govJurisdictionTree` clamps `maxDepth` to 6 tiers. We nest ONE level deeper\n * than that so every node the service can actually return has its `children`\n * selected — the deepest selection can never be reached, which keeps\n * `GovJurisdictionTreeNode.children` non-optional and honest.\n */\nconst treeNodeSelection = (remaining: number): string =>\n remaining <= 0\n ? TREE_NODE_FIELDS\n : `${TREE_NODE_FIELDS} children { ${treeNodeSelection(remaining - 1)} }`;\n\nconst TREE_SELECTION = treeNodeSelection(7);\n\nconst OFFICIAL_FIELDS = `\n id workspaceId jurisdictionId fullName localName officeTitle officeType department party\n isIndependent photoFileId biography contactEmail contactPhone officeAddress officeHours\n socialProfiles termStart termEnd termDurationMonths electedOn nextElectionOn\n attendancePercent votingRecordUrl committees responsibilities isCurrent displayOrder\n linkedUserId sourceName sourceUrl verification commitmentDeliveryRate createdAt updatedAt\n`;\n\nconst COMMITMENT_FIELDS = `\n id workspaceId officialId jurisdictionId title description domain promisedOn targetDate\n status progressPercent linkedProjectId evidenceUrl evidenceFileIds sourceName sourceUrl\n verification isOverdue createdAt updatedAt\n`;\n\nconst ELECTION_FIELDS = `\n id workspaceId jurisdictionId name electionType officeTitle electionDate status\n registeredVoters votesCast validVotes invalidVotes turnoutPercent resultDeclaredOn\n sourceName sourceUrl verification winningMarginVotes winningMarginPercent\n createdAt updatedAt\n`;\n\nconst ELECTION_RESULT_FIELDS = `\n id workspaceId electionId candidateName party isIndependent votes votePercent position\n isWinner photoFileId officialId createdAt updatedAt\n`;\n\nconst EVENT_FIELDS = `\n id workspaceId jurisdictionId title description occurredOn category impact\n linkedProjectId linkedElectionId linkedBudgetId imageFileId sourceName sourceUrl\n verification createdAt updatedAt\n`;\n\nconst BUDGET_FIELDS = `\n id workspaceId jurisdictionId fiscalYear periodStart periodEnd currencyCode status\n totalRevenuePlanned totalRevenueActual totalExpensePlanned totalExpenseActual\n populationAtPublication summary documentFileId approvedOn publishedAt sourceName\n sourceUrl verification createdAt updatedAt\n`;\n\nconst BUDGET_LINE_FIELDS = `\n id workspaceId budgetId kind category label department functionCode plannedAmount\n actualAmount previousYearAmount notes displayOrder variance variancePercent\n createdAt updatedAt\n`;\n\nconst BUDGET_EXECUTION_FIELDS = `\n budgetId fiscalYear currencyCode plannedRevenue actualRevenue plannedExpense\n actualExpense executionPercent perCapitaExpense perCapitaActualExpense\n byCategory { kind category planned actual variance variancePercent sharePercent }\n`;\n\nconst PROJECT_FIELDS = `\n id workspaceId jurisdictionId agencyId name code description domain department\n contractorName contractorRegistrationId fundingSource budgetAmount actualCost\n currencyCode tenderReference tenderUrl awardedOn startDate plannedCompletionDate\n actualCompletionDate status progressPercent delayReason locationLabel latitude longitude\n imageFileIds documentFileIds beneficiaryCount tags sourceName sourceUrl verification\n publishedAt delayDays costVariance createdAt updatedAt\n`;\n\nconst MILESTONE_FIELDS = `\n id workspaceId projectId name description dueDate completedOn status progressPercent\n evidenceFileId displayOrder isOverdue createdAt updatedAt\n`;\n\nconst INDICATOR_FIELDS = `\n id workspaceId code name description domain unit valueType direction periodicity\n methodology targetValue minValue maxValue isCore weight isActive sdgGoal sourceName\n sourceUrl createdAt updatedAt\n`;\n\nconst INDICATOR_VALUE_FIELDS = `\n id workspaceId indicatorId jurisdictionId periodLabel periodStart periodEnd value\n numerator denominator targetValue sourceName sourceUrl sourceDate datasetId verification\n notes publishedAt createdAt updatedAt\n`;\n\nconst INDICATOR_SERIES_FIELDS = `\n jurisdictionId latestValue latestPeriodLabel changePercent trend\n indicator { ${INDICATOR_FIELDS} }\n points { periodLabel periodStart value targetValue verification }\n`;\n\nconst SCORECARD_FIELDS = `\n jurisdictionId jurisdictionName periodLabel overallScore coveragePercent indicatorCount\n measuredCount generatedAt\n domains { domain score indicatorCount measuredCount trend changePercent }\n`;\n\nconst INSIGHT_FIELDS = `\n kind severity title detail domain indicatorCode evidence generatedAt\n`;\n\nconst BENCHMARK_ENTRY_FIELDS = `jurisdictionId jurisdictionName value rank`;\n\nconst BENCHMARK_FIELDS = `\n jurisdictionId periodLabel scope peerCount percentile average median isRankPublished\n indicator { ${INDICATOR_FIELDS} }\n subject { ${BENCHMARK_ENTRY_FIELDS} }\n peers { ${BENCHMARK_ENTRY_FIELDS} }\n best { ${BENCHMARK_ENTRY_FIELDS} }\n worst { ${BENCHMARK_ENTRY_FIELDS} }\n`;\n\nconst SERVICE_PERFORMANCE_FIELDS = `\n jurisdictionId totalApplications approvedCount rejectedCount pendingCount approvalRate\n avgProcessingHours slaBreachedCount slaCompliancePercent\n byService {\n serviceId serviceName applications approved rejected pending avgProcessingHours\n slaDays slaCompliancePercent\n }\n byAgency {\n agencyId agencyName applications approved rejected pending avgProcessingHours\n slaCompliancePercent\n }\n`;\n\nconst GRIEVANCE_INSIGHTS_FIELDS = `\n jurisdictionId total open inProgress resolved avgResolutionHours\n byCategory { category total resolved avgResolutionHours }\n hotspots { locationLabel latitude longitude count topCategory }\n`;\n\nconst PUBLIC_ASSET_FIELDS = `\n id workspaceId jurisdictionId name category subCategory description operator status\n address latitude longitude capacity capacityUnit contactPhone contactEmail website\n openingHours isAccessible establishedOn imageFileId metadata tags sourceName sourceUrl\n verification createdAt updatedAt\n`;\n\nconst CONSULTATION_FIELDS = `\n id workspaceId jurisdictionId title description consultationType status opensAt closesAt\n questions allowAnonymous budgetAmount currencyCode responseCount resultsSummary\n resultsPublishedAt documentFileId tags isAcceptingResponses hasRespondedByMe\n createdAt updatedAt\n`;\n\nconst CONSULTATION_RESPONSE_FIELDS = `\n id workspaceId consultationId jurisdictionId respondentActorId answers sentiment submittedAt\n`;\n\nconst CONSULTATION_RESULTS_FIELDS = `\n consultationId status responseCount resultsPublishedAt isSuppressed\n questions { questionId label type responseCount aggregate }\n`;\n\nconst DATASET_FIELDS = `\n id workspaceId jurisdictionId name slug description domain format license licenseUrl\n version fileId externalUrl periodStart periodEnd updateFrequency rowCount sizeBytes\n publisher contactEmail status publishedAt downloadCount tags createdAt updatedAt\n`;\n\nconst FOLLOW_FIELDS = `\n id workspaceId jurisdictionId actorId channels topics createdAt\n`;\n\nconst PROPOSAL_FIELDS = `\n id workspaceId jurisdictionId entityType entityId fieldPath currentValue proposedValue\n rationale evidenceUrl evidenceFileIds status submittedByActorId submittedAt\n reviewedByActorId reviewedAt reviewNote appliedAt createdAt updatedAt\n`;\n\nconst OVERVIEW_FIELDS = `\n childCount officialCount activeProjectCount completedProjectCount publishedDatasetCount\n openConsultationCount publicAssetCount followerCount isFollowedByMe\n jurisdiction { ${JURISDICTION_FIELDS} }\n adminLevel { ${ADMIN_LEVEL_FIELDS} }\n parent { ${JURISDICTION_REF_FIELDS} }\n currentBudget { ${BUDGET_FIELDS} }\n scorecard { ${SCORECARD_FIELDS} }\n insights { ${INSIGHT_FIELDS} }\n`;\n\n// ============================================================================\n// Administrative hierarchy — GovAdminLevel\n// ============================================================================\n\nexport const useGovAdminLevels = (countryCode?: string, pagination?: PaginationInput) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelAdminLevels, countryCode ?? null, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govAdminLevels: GovAdminLevelConnection }>(\n `query GovAdminLevels($countryCode: String, $pagination: PaginationInput) {\n govAdminLevels(countryCode: $countryCode, pagination: $pagination) {\n items { ${ADMIN_LEVEL_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { countryCode, pagination: page(pagination ?? { limit: 100 }) },\n apiGatewayUrl\n );\n return result.govAdminLevels;\n },\n });\n};\n\nexport const useGovAdminLevel = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelAdminLevel(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovAdminLevel>(\n `query GovAdminLevel($id: ID!) {\n govAdminLevel(id: $id) { ${ADMIN_LEVEL_FIELDS} }\n }`,\n { id },\n 'govAdminLevel',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateAdminLevel = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateAdminLevelInput) => {\n const result = await govQuery<{ govCreateAdminLevel: GovAdminLevel }>(\n `mutation GovCreateAdminLevel($input: GovCreateAdminLevelInput!) {\n govCreateAdminLevel(input: $input) { ${ADMIN_LEVEL_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateAdminLevel;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelAdminLevels }),\n });\n};\n\nexport const useGovUpdateAdminLevel = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateAdminLevelInput }) => {\n const result = await govQuery<{ govUpdateAdminLevel: GovAdminLevel }>(\n `mutation GovUpdateAdminLevel($id: ID!, $input: GovUpdateAdminLevelInput!) {\n govUpdateAdminLevel(id: $id, input: $input) { ${ADMIN_LEVEL_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateAdminLevel;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelAdminLevels });\n qc.invalidateQueries({ queryKey: KEY.intelAdminLevel(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n },\n });\n};\n\nexport const useGovDeleteAdminLevel = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteAdminLevel: boolean }>(\n `mutation GovDeleteAdminLevel($id: ID!) { govDeleteAdminLevel(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteAdminLevel;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelAdminLevels }),\n });\n};\n\n/** Bootstrap a country's hierarchy from a named preset. Additive and idempotent. */\nexport const useGovSeedAdminLevels = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { countryCode: string; preset?: string | null }) => {\n const result = await govQuery<{ govSeedAdminLevels: GovAdminLevel[] }>(\n `mutation GovSeedAdminLevels($countryCode: String!, $preset: String) {\n govSeedAdminLevels(countryCode: $countryCode, preset: $preset) { ${ADMIN_LEVEL_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govSeedAdminLevels;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelAdminLevels }),\n });\n};\n\n// ============================================================================\n// Jurisdictions\n// ============================================================================\n\nexport const useGovJurisdictions = (\n filter: GovJurisdictionFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelJurisdictions, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictions: GovJurisdictionConnection }>(\n `query GovJurisdictions($filter: GovJurisdictionFilterInput, $pagination: PaginationInput) {\n govJurisdictions(filter: $filter, pagination: $pagination) {\n items { ${JURISDICTION_FIELDS} adminLevel { ${ADMIN_LEVEL_FIELDS} } }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govJurisdictions;\n },\n });\n};\n\nexport const useGovJurisdiction = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelJurisdiction(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovJurisdiction>(\n `query GovJurisdiction($id: ID!) {\n govJurisdiction(id: $id) {\n ${JURISDICTION_FIELDS}\n adminLevel { ${ADMIN_LEVEL_FIELDS} }\n parent { ${JURISDICTION_REF_FIELDS} }\n ancestors { ${JURISDICTION_REF_FIELDS} }\n children { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { id },\n 'govJurisdiction',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovJurisdictionBySlug = (slug: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelJurisdictionBySlug(slug ?? ''),\n enabled: Boolean(slug),\n queryFn: async () =>\n govNullableQuery<GovJurisdiction>(\n `query GovJurisdictionBySlug($slug: String!) {\n govJurisdictionBySlug(slug: $slug) {\n ${JURISDICTION_FIELDS}\n adminLevel { ${ADMIN_LEVEL_FIELDS} }\n ancestors { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { slug },\n 'govJurisdictionBySlug',\n apiGatewayUrl\n ),\n });\n};\n\n/** The administrative hierarchy as a tree. `maxDepth` is clamped to 6 tiers by the service. */\nexport const useGovJurisdictionTree = (rootId?: string | null, maxDepth?: number) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelJurisdictionTree, rootId ?? null, maxDepth ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionTree: GovJurisdictionTreeNode[] }>(\n `query GovJurisdictionTree($rootId: ID, $maxDepth: Int) {\n govJurisdictionTree(rootId: $rootId, maxDepth: $maxDepth) { ${TREE_SELECTION} }\n }`,\n { rootId: rootId ?? undefined, maxDepth },\n apiGatewayUrl\n );\n return result.govJurisdictionTree;\n },\n });\n};\n\n/** Single page-load aggregate for the jurisdiction profile screen. */\nexport const useGovJurisdictionOverview = (jurisdictionId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelOverviewFor(jurisdictionId ?? ''),\n enabled: Boolean(jurisdictionId),\n queryFn: async () =>\n govNullableQuery<GovJurisdictionOverview>(\n `query GovJurisdictionOverview($jurisdictionId: ID!) {\n govJurisdictionOverview(jurisdictionId: $jurisdictionId) { ${OVERVIEW_FIELDS} }\n }`,\n { jurisdictionId },\n 'govJurisdictionOverview',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateJurisdictionInput) => {\n const result = await govQuery<{ govCreateJurisdiction: GovJurisdiction }>(\n `mutation GovCreateJurisdiction($input: GovCreateJurisdictionInput!) {\n govCreateJurisdiction(input: $input) { ${JURISDICTION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateJurisdiction;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n qc.invalidateQueries({ queryKey: KEY.intelAdminLevels });\n },\n });\n};\n\nexport const useGovUpdateJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateJurisdictionInput }) => {\n const result = await govQuery<{ govUpdateJurisdiction: GovJurisdiction }>(\n `mutation GovUpdateJurisdiction($id: ID!, $input: GovUpdateJurisdictionInput!) {\n govUpdateJurisdiction(id: $id, input: $input) { ${JURISDICTION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateJurisdiction;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdiction(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionBySlug(data.slug) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovPublishJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govPublishJurisdiction: GovJurisdiction }>(\n `mutation GovPublishJurisdiction($id: ID!) {\n govPublishJurisdiction(id: $id) { ${JURISDICTION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPublishJurisdiction;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdiction(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovArchiveJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govArchiveJurisdiction: GovJurisdiction }>(\n `mutation GovArchiveJurisdiction($id: ID!) {\n govArchiveJurisdiction(id: $id) { ${JURISDICTION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govArchiveJurisdiction;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdiction(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovDeleteJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteJurisdiction: boolean }>(\n `mutation GovDeleteJurisdiction($id: ID!) { govDeleteJurisdiction(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteJurisdiction;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n invalidateDerived(qc);\n },\n });\n};\n\n// ============================================================================\n// Officials & commitments\n// ============================================================================\n\nexport const useGovOfficials = (\n filter: GovOfficialFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelOfficials, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govOfficials: GovOfficialConnection }>(\n `query GovOfficials($filter: GovOfficialFilterInput, $pagination: PaginationInput) {\n govOfficials(filter: $filter, pagination: $pagination) {\n items { ${OFFICIAL_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govOfficials;\n },\n });\n};\n\nexport const useGovOfficial = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelOfficial(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovOfficial>(\n `query GovOfficial($id: ID!) {\n govOfficial(id: $id) {\n ${OFFICIAL_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n commitments { ${COMMITMENT_FIELDS} }\n }\n }`,\n { id },\n 'govOfficial',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovOfficialCommitments = (\n filter: GovOfficialCommitmentFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelCommitments, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govOfficialCommitments: GovOfficialCommitmentConnection }>(\n `query GovOfficialCommitments($filter: GovOfficialCommitmentFilterInput, $pagination: PaginationInput) {\n govOfficialCommitments(filter: $filter, pagination: $pagination) {\n items { ${COMMITMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govOfficialCommitments;\n },\n });\n};\n\nexport const useGovCreateOfficial = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateOfficialInput) => {\n const result = await govQuery<{ govCreateOfficial: GovOfficial }>(\n `mutation GovCreateOfficial($input: GovCreateOfficialInput!) {\n govCreateOfficial(input: $input) { ${OFFICIAL_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateOfficial;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateOfficial = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateOfficialInput }) => {\n const result = await govQuery<{ govUpdateOfficial: GovOfficial }>(\n `mutation GovUpdateOfficial($id: ID!, $input: GovUpdateOfficialInput!) {\n govUpdateOfficial(id: $id, input: $input) { ${OFFICIAL_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateOfficial;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n qc.invalidateQueries({ queryKey: KEY.intelOfficial(data.id) });\n },\n });\n};\n\nexport const useGovDeleteOfficial = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteOfficial: boolean }>(\n `mutation GovDeleteOfficial($id: ID!) { govDeleteOfficial(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteOfficial;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n qc.invalidateQueries({ queryKey: KEY.intelCommitments });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovCreateOfficialCommitment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateOfficialCommitmentInput) => {\n const result = await govQuery<{ govCreateOfficialCommitment: GovOfficialCommitment }>(\n `mutation GovCreateOfficialCommitment($input: GovCreateOfficialCommitmentInput!) {\n govCreateOfficialCommitment(input: $input) { ${COMMITMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateOfficialCommitment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelCommitments });\n qc.invalidateQueries({ queryKey: KEY.intelOfficial(data.officialId) });\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n },\n });\n};\n\nexport const useGovUpdateOfficialCommitment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateOfficialCommitmentInput }) => {\n const result = await govQuery<{ govUpdateOfficialCommitment: GovOfficialCommitment }>(\n `mutation GovUpdateOfficialCommitment($id: ID!, $input: GovUpdateOfficialCommitmentInput!) {\n govUpdateOfficialCommitment(id: $id, input: $input) { ${COMMITMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateOfficialCommitment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelCommitments });\n qc.invalidateQueries({ queryKey: KEY.intelOfficial(data.officialId) });\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n },\n });\n};\n\nexport const useGovDeleteOfficialCommitment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteOfficialCommitment: boolean }>(\n `mutation GovDeleteOfficialCommitment($id: ID!) { govDeleteOfficialCommitment(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteOfficialCommitment;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelCommitments });\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n },\n });\n};\n\n// ============================================================================\n// Elections\n// ============================================================================\n\nexport const useGovElections = (\n filter: GovElectionFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelElections, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govElections: GovElectionConnection }>(\n `query GovElections($filter: GovElectionFilterInput, $pagination: PaginationInput) {\n govElections(filter: $filter, pagination: $pagination) {\n items { ${ELECTION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govElections;\n },\n });\n};\n\nexport const useGovElection = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelElection(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovElection>(\n `query GovElection($id: ID!) {\n govElection(id: $id) {\n ${ELECTION_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n results { ${ELECTION_RESULT_FIELDS} }\n }\n }`,\n { id },\n 'govElection',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateElection = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateElectionInput) => {\n const result = await govQuery<{ govCreateElection: GovElection }>(\n `mutation GovCreateElection($input: GovCreateElectionInput!) {\n govCreateElection(input: $input) { ${ELECTION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateElection;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelElections }),\n });\n};\n\nexport const useGovUpdateElection = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateElectionInput }) => {\n const result = await govQuery<{ govUpdateElection: GovElection }>(\n `mutation GovUpdateElection($id: ID!, $input: GovUpdateElectionInput!) {\n govUpdateElection(id: $id, input: $input) { ${ELECTION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateElection;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelElections });\n qc.invalidateQueries({ queryKey: KEY.intelElection(data.id) });\n },\n });\n};\n\nexport const useGovDeleteElection = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteElection: boolean }>(\n `mutation GovDeleteElection($id: ID!) { govDeleteElection(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteElection;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelElections }),\n });\n};\n\n/** Replace an election's declared results in one transaction. */\nexport const useGovRecordElectionResults = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { electionId: string; results: GovElectionResultInput[] }) => {\n const result = await govQuery<{ govRecordElectionResults: GovElection }>(\n `mutation GovRecordElectionResults($electionId: ID!, $results: [GovElectionResultInput!]!) {\n govRecordElectionResults(electionId: $electionId, results: $results) {\n ${ELECTION_FIELDS}\n results { ${ELECTION_RESULT_FIELDS} }\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govRecordElectionResults;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelElections });\n qc.invalidateQueries({ queryKey: KEY.intelElection(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Jurisdiction timeline events\n// ============================================================================\n\nexport const useGovJurisdictionEvents = (\n jurisdictionId: string | undefined,\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelEventsFor(jurisdictionId ?? ''), pagination ?? null],\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionEvents: GovJurisdictionEventConnection }>(\n `query GovJurisdictionEvents($jurisdictionId: ID!, $pagination: PaginationInput) {\n govJurisdictionEvents(jurisdictionId: $jurisdictionId, pagination: $pagination) {\n items { ${EVENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { jurisdictionId, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govJurisdictionEvents;\n },\n });\n};\n\nexport const useGovCreateJurisdictionEvent = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateJurisdictionEventInput) => {\n const result = await govQuery<{ govCreateJurisdictionEvent: GovJurisdictionEvent }>(\n `mutation GovCreateJurisdictionEvent($input: GovCreateJurisdictionEventInput!) {\n govCreateJurisdictionEvent(input: $input) { ${EVENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateJurisdictionEvent;\n },\n onSuccess: (data) =>\n qc.invalidateQueries({ queryKey: KEY.intelEventsFor(data.jurisdictionId) }),\n });\n};\n\nexport const useGovUpdateJurisdictionEvent = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateJurisdictionEventInput }) => {\n const result = await govQuery<{ govUpdateJurisdictionEvent: GovJurisdictionEvent }>(\n `mutation GovUpdateJurisdictionEvent($id: ID!, $input: GovUpdateJurisdictionEventInput!) {\n govUpdateJurisdictionEvent(id: $id, input: $input) { ${EVENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateJurisdictionEvent;\n },\n onSuccess: (data) =>\n qc.invalidateQueries({ queryKey: KEY.intelEventsFor(data.jurisdictionId) }),\n });\n};\n\nexport const useGovDeleteJurisdictionEvent = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteJurisdictionEvent: boolean }>(\n `mutation GovDeleteJurisdictionEvent($id: ID!) { govDeleteJurisdictionEvent(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteJurisdictionEvent;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelEvents }),\n });\n};\n\n// ============================================================================\n// Budgets\n// ============================================================================\n\nexport const useGovBudgets = (filter: GovBudgetFilterInput = {}, pagination?: PaginationInput) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelBudgets, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govBudgets: GovBudgetConnection }>(\n `query GovBudgets($filter: GovBudgetFilterInput, $pagination: PaginationInput) {\n govBudgets(filter: $filter, pagination: $pagination) {\n items { ${BUDGET_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govBudgets;\n },\n });\n};\n\nexport const useGovBudget = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelBudget(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovBudget>(\n `query GovBudget($id: ID!) {\n govBudget(id: $id) {\n ${BUDGET_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n lines { ${BUDGET_LINE_FIELDS} }\n }\n }`,\n { id },\n 'govBudget',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovBudgetExecution = (budgetId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelBudgetExecutionFor(budgetId ?? ''),\n enabled: Boolean(budgetId),\n queryFn: async () =>\n govNullableQuery<GovBudgetExecution>(\n `query GovBudgetExecution($budgetId: ID!) {\n govBudgetExecution(budgetId: $budgetId) { ${BUDGET_EXECUTION_FIELDS} }\n }`,\n { budgetId },\n 'govBudgetExecution',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateBudget = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateBudgetInput) => {\n const result = await govQuery<{ govCreateBudget: GovBudget }>(\n `mutation GovCreateBudget($input: GovCreateBudgetInput!) {\n govCreateBudget(input: $input) { ${BUDGET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateBudget;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateBudget = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateBudgetInput }) => {\n const result = await govQuery<{ govUpdateBudget: GovBudget }>(\n `mutation GovUpdateBudget($id: ID!, $input: GovUpdateBudgetInput!) {\n govUpdateBudget(id: $id, input: $input) { ${BUDGET_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateBudget;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudget(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecutionFor(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovPublishBudget = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govPublishBudget: GovBudget }>(\n `mutation GovPublishBudget($id: ID!) {\n govPublishBudget(id: $id) { ${BUDGET_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPublishBudget;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudget(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecutionFor(data.id) });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovDeleteBudget = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteBudget: boolean }>(\n `mutation GovDeleteBudget($id: ID!) { govDeleteBudget(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteBudget;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecution });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Create/update budget lines in one transaction; the service re-derives the totals. */\nexport const useGovUpsertBudgetLines = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { budgetId: string; lines: GovBudgetLineInput[] }) => {\n const result = await govQuery<{ govUpsertBudgetLines: GovBudget }>(\n `mutation GovUpsertBudgetLines($budgetId: ID!, $lines: [GovBudgetLineInput!]!) {\n govUpsertBudgetLines(budgetId: $budgetId, lines: $lines) {\n ${BUDGET_FIELDS}\n lines { ${BUDGET_LINE_FIELDS} }\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpsertBudgetLines;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudget(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecutionFor(data.id) });\n },\n });\n};\n\nexport const useGovDeleteBudgetLine = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; budgetId?: string }) => {\n const result = await govQuery<{ govDeleteBudgetLine: boolean }>(\n `mutation GovDeleteBudgetLine($id: ID!) { govDeleteBudgetLine(id: $id) }`,\n { id: vars.id },\n apiGatewayUrl\n );\n return result.govDeleteBudgetLine;\n },\n onSuccess: (_data, vars) => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecution });\n if (vars.budgetId) qc.invalidateQueries({ queryKey: KEY.intelBudget(vars.budgetId) });\n },\n });\n};\n\n// ============================================================================\n// Development projects & milestones\n// ============================================================================\n\nexport const useGovProjects = (\n filter: GovProjectFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelProjects, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govProjects: GovProjectConnection }>(\n `query GovProjects($filter: GovProjectFilterInput, $pagination: PaginationInput) {\n govProjects(filter: $filter, pagination: $pagination) {\n items { ${PROJECT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govProjects;\n },\n });\n};\n\nexport const useGovProject = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelProject(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovProject>(\n `query GovProject($id: ID!) {\n govProject(id: $id) {\n ${PROJECT_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n milestones { ${MILESTONE_FIELDS} }\n }\n }`,\n { id },\n 'govProject',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateProject = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateProjectInput) => {\n const result = await govQuery<{ govCreateProject: GovProject }>(\n `mutation GovCreateProject($input: GovCreateProjectInput!) {\n govCreateProject(input: $input) { ${PROJECT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateProject;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelProjects });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateProject = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateProjectInput }) => {\n const result = await govQuery<{ govUpdateProject: GovProject }>(\n `mutation GovUpdateProject($id: ID!, $input: GovUpdateProjectInput!) {\n govUpdateProject(id: $id, input: $input) { ${PROJECT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateProject;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelProjects });\n qc.invalidateQueries({ queryKey: KEY.intelProject(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Advance a project's delivery status, optionally recording progress and a delay reason. */\nexport const useGovUpdateProjectStatus = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovProjectStatus;\n progressPercent?: number | null;\n delayReason?: string | null;\n }) => {\n const result = await govQuery<{ govUpdateProjectStatus: GovProject }>(\n `mutation GovUpdateProjectStatus($id: ID!, $status: GovProjectStatus!, $progressPercent: Int, $delayReason: String) {\n govUpdateProjectStatus(id: $id, status: $status, progressPercent: $progressPercent, delayReason: $delayReason) {\n ${PROJECT_FIELDS}\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateProjectStatus;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelProjects });\n qc.invalidateQueries({ queryKey: KEY.intelProject(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n qc.invalidateQueries({ queryKey: KEY.intelInsights });\n },\n });\n};\n\nexport const useGovDeleteProject = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteProject: boolean }>(\n `mutation GovDeleteProject($id: ID!) { govDeleteProject(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteProject;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelProjects });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovCreateProjectMilestone = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateProjectMilestoneInput) => {\n const result = await govQuery<{ govCreateProjectMilestone: GovProjectMilestone }>(\n `mutation GovCreateProjectMilestone($input: GovCreateProjectMilestoneInput!) {\n govCreateProjectMilestone(input: $input) { ${MILESTONE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateProjectMilestone;\n },\n onSuccess: (data) => qc.invalidateQueries({ queryKey: KEY.intelProject(data.projectId) }),\n });\n};\n\nexport const useGovUpdateProjectMilestone = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateProjectMilestoneInput }) => {\n const result = await govQuery<{ govUpdateProjectMilestone: GovProjectMilestone }>(\n `mutation GovUpdateProjectMilestone($id: ID!, $input: GovUpdateProjectMilestoneInput!) {\n govUpdateProjectMilestone(id: $id, input: $input) { ${MILESTONE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateProjectMilestone;\n },\n onSuccess: (data) => qc.invalidateQueries({ queryKey: KEY.intelProject(data.projectId) }),\n });\n};\n\nexport const useGovDeleteProjectMilestone = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; projectId?: string }) => {\n const result = await govQuery<{ govDeleteProjectMilestone: boolean }>(\n `mutation GovDeleteProjectMilestone($id: ID!) { govDeleteProjectMilestone(id: $id) }`,\n { id: vars.id },\n apiGatewayUrl\n );\n return result.govDeleteProjectMilestone;\n },\n onSuccess: (_data, vars) => {\n if (vars.projectId) qc.invalidateQueries({ queryKey: KEY.intelProject(vars.projectId) });\n else qc.invalidateQueries({ queryKey: KEY.intelProjects });\n },\n });\n};\n\n// ============================================================================\n// Indicator catalogue & values\n// ============================================================================\n\nexport const useGovIndicators = (\n filter: GovIndicatorFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelIndicators, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govIndicators: GovIndicatorConnection }>(\n `query GovIndicators($filter: GovIndicatorFilterInput, $pagination: PaginationInput) {\n govIndicators(filter: $filter, pagination: $pagination) {\n items { ${INDICATOR_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govIndicators;\n },\n });\n};\n\nexport const useGovIndicator = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelIndicator(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovIndicator>(\n `query GovIndicator($id: ID!) {\n govIndicator(id: $id) { ${INDICATOR_FIELDS} }\n }`,\n { id },\n 'govIndicator',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovIndicatorValues = (\n filter: GovIndicatorValueFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelIndicatorValues, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govIndicatorValues: GovIndicatorValueConnection }>(\n `query GovIndicatorValues($filter: GovIndicatorValueFilterInput, $pagination: PaginationInput) {\n govIndicatorValues(filter: $filter, pagination: $pagination) {\n items { ${INDICATOR_VALUE_FIELDS} indicator { ${INDICATOR_FIELDS} } }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govIndicatorValues;\n },\n });\n};\n\n/** An indicator's full published history for one jurisdiction, keyed by indicator CODE. */\nexport const useGovIndicatorSeries = (\n jurisdictionId: string | undefined,\n indicatorCode: string | undefined,\n range: { fromPeriod?: string; toPeriod?: string } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelIndicatorSeries, jurisdictionId ?? '', indicatorCode ?? '', range],\n enabled: Boolean(jurisdictionId) && Boolean(indicatorCode),\n queryFn: async () =>\n govNullableQuery<GovIndicatorSeries>(\n `query GovIndicatorSeries($jurisdictionId: ID!, $indicatorCode: String!, $fromPeriod: String, $toPeriod: String) {\n govIndicatorSeries(jurisdictionId: $jurisdictionId, indicatorCode: $indicatorCode, fromPeriod: $fromPeriod, toPeriod: $toPeriod) {\n ${INDICATOR_SERIES_FIELDS}\n }\n }`,\n {\n jurisdictionId,\n indicatorCode,\n fromPeriod: range.fromPeriod,\n toPeriod: range.toPeriod,\n },\n 'govIndicatorSeries',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateIndicator = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateIndicatorInput) => {\n const result = await govQuery<{ govCreateIndicator: GovIndicator }>(\n `mutation GovCreateIndicator($input: GovCreateIndicatorInput!) {\n govCreateIndicator(input: $input) { ${INDICATOR_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateIndicator;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicators });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovUpdateIndicator = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateIndicatorInput }) => {\n const result = await govQuery<{ govUpdateIndicator: GovIndicator }>(\n `mutation GovUpdateIndicator($id: ID!, $input: GovUpdateIndicatorInput!) {\n govUpdateIndicator(id: $id, input: $input) { ${INDICATOR_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateIndicator;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicators });\n qc.invalidateQueries({ queryKey: KEY.intelIndicator(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovDeleteIndicator = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteIndicator: boolean }>(\n `mutation GovDeleteIndicator($id: ID!) { govDeleteIndicator(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteIndicator;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicators });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\n/** Seed the country-neutral standard indicator catalogue. Additive and idempotent. */\nexport const useGovSeedIndicatorCatalog = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (domains?: GovIndicatorDomain[]) => {\n const result = await govQuery<{ govSeedIndicatorCatalog: GovIndicator[] }>(\n `mutation GovSeedIndicatorCatalog($domains: [GovIndicatorDomain!]) {\n govSeedIndicatorCatalog(domains: $domains) { ${INDICATOR_FIELDS} }\n }`,\n { domains },\n apiGatewayUrl\n );\n return result.govSeedIndicatorCatalog;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicators });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovRecordIndicatorValue = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovRecordIndicatorValueInput) => {\n const result = await govQuery<{ govRecordIndicatorValue: GovIndicatorValue }>(\n `mutation GovRecordIndicatorValue($input: GovRecordIndicatorValueInput!) {\n govRecordIndicatorValue(input: $input) { ${INDICATOR_VALUE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govRecordIndicatorValue;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\n/** Record many values in one transaction. Existing period rows are updated in place. */\nexport const useGovBulkRecordIndicatorValues = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovRecordIndicatorValueInput[]) => {\n const result = await govQuery<{ govBulkRecordIndicatorValues: GovIndicatorValue[] }>(\n `mutation GovBulkRecordIndicatorValues($input: [GovRecordIndicatorValueInput!]!) {\n govBulkRecordIndicatorValues(input: $input) { ${INDICATOR_VALUE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govBulkRecordIndicatorValues;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovUpdateIndicatorValue = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateIndicatorValueInput }) => {\n const result = await govQuery<{ govUpdateIndicatorValue: GovIndicatorValue }>(\n `mutation GovUpdateIndicatorValue($id: ID!, $input: GovUpdateIndicatorValueInput!) {\n govUpdateIndicatorValue(id: $id, input: $input) { ${INDICATOR_VALUE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateIndicatorValue;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovDeleteIndicatorValue = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteIndicatorValue: boolean }>(\n `mutation GovDeleteIndicatorValue($id: ID!) { govDeleteIndicatorValue(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteIndicatorValue;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\n// ============================================================================\n// Scorecard, benchmark, insights & reused performance rollups\n// ============================================================================\n\nexport const useGovJurisdictionScorecard = (\n jurisdictionId: string | undefined,\n periodLabel?: string\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelScorecard, jurisdictionId ?? '', periodLabel ?? null],\n enabled: Boolean(jurisdictionId),\n queryFn: async () =>\n govNullableQuery<GovJurisdictionScorecard>(\n `query GovJurisdictionScorecard($jurisdictionId: ID!, $periodLabel: String) {\n govJurisdictionScorecard(jurisdictionId: $jurisdictionId, periodLabel: $periodLabel) {\n ${SCORECARD_FIELDS}\n }\n }`,\n { jurisdictionId, periodLabel },\n 'govJurisdictionScorecard',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovJurisdictionBenchmark = (\n jurisdictionId: string | undefined,\n indicatorCode: string | undefined,\n options: { scope?: GovBenchmarkScope; periodLabel?: string; peerIds?: string[] } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelBenchmark, jurisdictionId ?? '', indicatorCode ?? '', options],\n enabled: Boolean(jurisdictionId) && Boolean(indicatorCode),\n queryFn: async () =>\n govNullableQuery<GovBenchmarkResult>(\n `query GovJurisdictionBenchmark($jurisdictionId: ID!, $indicatorCode: String!, $scope: GovBenchmarkScope!, $periodLabel: String, $peerIds: [ID!]) {\n govJurisdictionBenchmark(jurisdictionId: $jurisdictionId, indicatorCode: $indicatorCode, scope: $scope, periodLabel: $periodLabel, peerIds: $peerIds) {\n ${BENCHMARK_FIELDS}\n }\n }`,\n {\n jurisdictionId,\n indicatorCode,\n scope: options.scope ?? 'SIBLINGS',\n periodLabel: options.periodLabel,\n peerIds: options.peerIds,\n },\n 'govJurisdictionBenchmark',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovJurisdictionInsights = (jurisdictionId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelInsights, jurisdictionId ?? ''],\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionInsights: GovJurisdictionInsight[] }>(\n `query GovJurisdictionInsights($jurisdictionId: ID!) {\n govJurisdictionInsights(jurisdictionId: $jurisdictionId) { ${INSIGHT_FIELDS} }\n }`,\n { jurisdictionId },\n apiGatewayUrl\n );\n return result.govJurisdictionInsights;\n },\n });\n};\n\n/** Service-delivery performance computed live from the catalogue + casework models. */\nexport const useGovJurisdictionServicePerformance = (\n jurisdictionId: string | undefined,\n range: { from?: string; to?: string } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelServicePerformance, jurisdictionId ?? '', range],\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionServicePerformance: GovServicePerformance }>(\n `query GovJurisdictionServicePerformance($jurisdictionId: ID!, $from: DateTime, $to: DateTime) {\n govJurisdictionServicePerformance(jurisdictionId: $jurisdictionId, from: $from, to: $to) {\n ${SERVICE_PERFORMANCE_FIELDS}\n }\n }`,\n { jurisdictionId, from: range.from, to: range.to },\n apiGatewayUrl\n );\n return result.govJurisdictionServicePerformance;\n },\n });\n};\n\n/** Citizen-issue insight computed live from the existing grievance model. */\nexport const useGovJurisdictionGrievanceInsights = (\n jurisdictionId: string | undefined,\n range: { from?: string; to?: string } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelGrievanceInsights, jurisdictionId ?? '', range],\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionGrievanceInsights: GovGrievanceInsights }>(\n `query GovJurisdictionGrievanceInsights($jurisdictionId: ID!, $from: DateTime, $to: DateTime) {\n govJurisdictionGrievanceInsights(jurisdictionId: $jurisdictionId, from: $from, to: $to) {\n ${GRIEVANCE_INSIGHTS_FIELDS}\n }\n }`,\n { jurisdictionId, from: range.from, to: range.to },\n apiGatewayUrl\n );\n return result.govJurisdictionGrievanceInsights;\n },\n });\n};\n\n// ============================================================================\n// Public asset registry\n// ============================================================================\n\nexport const useGovPublicAssets = (\n filter: GovPublicAssetFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelAssets, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govPublicAssets: GovPublicAssetConnection }>(\n `query GovPublicAssets($filter: GovPublicAssetFilterInput, $pagination: PaginationInput) {\n govPublicAssets(filter: $filter, pagination: $pagination) {\n items { ${PUBLIC_ASSET_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govPublicAssets;\n },\n });\n};\n\nexport const useGovPublicAsset = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelAsset(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovPublicAsset>(\n `query GovPublicAsset($id: ID!) {\n govPublicAsset(id: $id) { ${PUBLIC_ASSET_FIELDS} }\n }`,\n { id },\n 'govPublicAsset',\n apiGatewayUrl\n ),\n });\n};\n\n/** Asset counts by category — drives map legends and registry summaries. */\nexport const useGovPublicAssetSummary = (jurisdictionId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelAssetSummaryFor(jurisdictionId ?? ''),\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govPublicAssetSummary: GovAssetCategoryCount[] }>(\n `query GovPublicAssetSummary($jurisdictionId: ID!) {\n govPublicAssetSummary(jurisdictionId: $jurisdictionId) { category count }\n }`,\n { jurisdictionId },\n apiGatewayUrl\n );\n return result.govPublicAssetSummary;\n },\n });\n};\n\nexport const useGovCreatePublicAsset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreatePublicAssetInput) => {\n const result = await govQuery<{ govCreatePublicAsset: GovPublicAsset }>(\n `mutation GovCreatePublicAsset($input: GovCreatePublicAssetInput!) {\n govCreatePublicAsset(input: $input) { ${PUBLIC_ASSET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreatePublicAsset;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelAssets });\n qc.invalidateQueries({ queryKey: KEY.intelAssetSummaryFor(data.jurisdictionId) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdatePublicAsset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdatePublicAssetInput }) => {\n const result = await govQuery<{ govUpdatePublicAsset: GovPublicAsset }>(\n `mutation GovUpdatePublicAsset($id: ID!, $input: GovUpdatePublicAssetInput!) {\n govUpdatePublicAsset(id: $id, input: $input) { ${PUBLIC_ASSET_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdatePublicAsset;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelAssets });\n qc.invalidateQueries({ queryKey: KEY.intelAsset(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelAssetSummaryFor(data.jurisdictionId) });\n },\n });\n};\n\nexport const useGovDeletePublicAsset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeletePublicAsset: boolean }>(\n `mutation GovDeletePublicAsset($id: ID!) { govDeletePublicAsset(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeletePublicAsset;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelAssets });\n qc.invalidateQueries({ queryKey: KEY.intelAssetSummary });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n// ============================================================================\n// Consultations & participation\n// ============================================================================\n\nexport const useGovConsultations = (\n filter: GovConsultationFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelConsultations, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govConsultations: GovConsultationConnection }>(\n `query GovConsultations($filter: GovConsultationFilterInput, $pagination: PaginationInput) {\n govConsultations(filter: $filter, pagination: $pagination) {\n items { ${CONSULTATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govConsultations;\n },\n });\n};\n\nexport const useGovConsultation = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelConsultation(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovConsultation>(\n `query GovConsultation($id: ID!) {\n govConsultation(id: $id) {\n ${CONSULTATION_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { id },\n 'govConsultation',\n apiGatewayUrl\n ),\n });\n};\n\n/** Aggregate, publishable results. Raw responses are never exposed. */\nexport const useGovConsultationResults = (consultationId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelConsultationResultsFor(consultationId ?? ''),\n enabled: Boolean(consultationId),\n queryFn: async () =>\n govNullableQuery<GovConsultationResults>(\n `query GovConsultationResults($consultationId: ID!) {\n govConsultationResults(consultationId: $consultationId) { ${CONSULTATION_RESULTS_FIELDS} }\n }`,\n { consultationId },\n 'govConsultationResults',\n apiGatewayUrl\n ),\n });\n};\n\n/**\n * The calling actor's own response, if any. Resolving to `null` is the normal\n * pre-submission state — not an error.\n */\nexport const useGovMyConsultationResponse = (consultationId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelMyConsultationResponseFor(consultationId ?? ''),\n enabled: Boolean(consultationId),\n queryFn: async () =>\n govNullableQuery<GovConsultationResponse>(\n `query GovMyConsultationResponse($consultationId: ID!) {\n govMyConsultationResponse(consultationId: $consultationId) { ${CONSULTATION_RESPONSE_FIELDS} }\n }`,\n { consultationId },\n 'govMyConsultationResponse',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateConsultationInput) => {\n const result = await govQuery<{ govCreateConsultation: GovConsultation }>(\n `mutation GovCreateConsultation($input: GovCreateConsultationInput!) {\n govCreateConsultation(input: $input) { ${CONSULTATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateConsultation;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateConsultationInput }) => {\n const result = await govQuery<{ govUpdateConsultation: GovConsultation }>(\n `mutation GovUpdateConsultation($id: ID!, $input: GovUpdateConsultationInput!) {\n govUpdateConsultation(id: $id, input: $input) { ${CONSULTATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateConsultation;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.id) });\n },\n });\n};\n\nexport const useGovOpenConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govOpenConsultation: GovConsultation }>(\n `mutation GovOpenConsultation($id: ID!) {\n govOpenConsultation(id: $id) { ${CONSULTATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govOpenConsultation;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovCloseConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govCloseConsultation: GovConsultation }>(\n `mutation GovCloseConsultation($id: ID!) {\n govCloseConsultation(id: $id) { ${CONSULTATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govCloseConsultation;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Compute and publish the aggregate result set. Raw responses are never published. */\nexport const useGovPublishConsultationResults = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govPublishConsultationResults: GovConsultation }>(\n `mutation GovPublishConsultationResults($id: ID!) {\n govPublishConsultationResults(id: $id) { ${CONSULTATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPublishConsultationResults;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelConsultationResultsFor(data.id) });\n },\n });\n};\n\nexport const useGovDeleteConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteConsultation: boolean }>(\n `mutation GovDeleteConsultation($id: ID!) { govDeleteConsultation(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteConsultation;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Submit the calling actor's response. One response per actor per consultation. */\nexport const useGovSubmitConsultationResponse = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovSubmitConsultationResponseInput) => {\n const result = await govQuery<{ govSubmitConsultationResponse: GovConsultationResponse }>(\n `mutation GovSubmitConsultationResponse($input: GovSubmitConsultationResponseInput!) {\n govSubmitConsultationResponse(input: $input) { ${CONSULTATION_RESPONSE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govSubmitConsultationResponse;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.consultationId) });\n qc.invalidateQueries({\n queryKey: KEY.intelMyConsultationResponseFor(data.consultationId),\n });\n qc.invalidateQueries({ queryKey: KEY.intelConsultationResultsFor(data.consultationId) });\n },\n });\n};\n\n// ============================================================================\n// Open data catalogue\n// ============================================================================\n\nexport const useGovDatasets = (\n filter: GovDatasetFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelDatasets, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govDatasets: GovDatasetConnection }>(\n `query GovDatasets($filter: GovDatasetFilterInput, $pagination: PaginationInput) {\n govDatasets(filter: $filter, pagination: $pagination) {\n items { ${DATASET_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govDatasets;\n },\n });\n};\n\nexport const useGovDataset = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelDataset(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovDataset>(\n `query GovDataset($id: ID!) {\n govDataset(id: $id) {\n ${DATASET_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { id },\n 'govDataset',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateDataset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateDatasetInput) => {\n const result = await govQuery<{ govCreateDataset: GovDataset }>(\n `mutation GovCreateDataset($input: GovCreateDatasetInput!) {\n govCreateDataset(input: $input) { ${DATASET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateDataset;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateDataset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateDatasetInput }) => {\n const result = await govQuery<{ govUpdateDataset: GovDataset }>(\n `mutation GovUpdateDataset($id: ID!, $input: GovUpdateDatasetInput!) {\n govUpdateDataset(id: $id, input: $input) { ${DATASET_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateDataset;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelDataset(data.id) });\n },\n });\n};\n\nexport const useGovPublishDataset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govPublishDataset: GovDataset }>(\n `mutation GovPublishDataset($id: ID!) {\n govPublishDataset(id: $id) { ${DATASET_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPublishDataset;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelDataset(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovDeleteDataset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteDataset: boolean }>(\n `mutation GovDeleteDataset($id: ID!) { govDeleteDataset(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteDataset;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Increment a dataset's download counter. */\nexport const useGovRecordDatasetDownload = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govRecordDatasetDownload: GovDataset }>(\n `mutation GovRecordDatasetDownload($id: ID!) {\n govRecordDatasetDownload(id: $id) { ${DATASET_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govRecordDatasetDownload;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelDataset(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Following (self-scoped)\n// ============================================================================\n\nexport const useGovMyFollowedJurisdictions = (pagination?: PaginationInput) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelMyFollowed, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govMyFollowedJurisdictions: GovJurisdictionConnection }>(\n `query GovMyFollowedJurisdictions($pagination: PaginationInput) {\n govMyFollowedJurisdictions(pagination: $pagination) {\n items { ${JURISDICTION_FIELDS} adminLevel { ${ADMIN_LEVEL_FIELDS} } }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govMyFollowedJurisdictions;\n },\n });\n};\n\nexport const useGovFollowJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n jurisdictionId: string;\n topics?: string[] | null;\n channels?: string[] | null;\n }) => {\n const result = await govQuery<{ govFollowJurisdiction: GovJurisdictionFollow }>(\n `mutation GovFollowJurisdiction($jurisdictionId: ID!, $topics: [String!], $channels: [String!]) {\n govFollowJurisdiction(jurisdictionId: $jurisdictionId, topics: $topics, channels: $channels) {\n ${FOLLOW_FIELDS}\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govFollowJurisdiction;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelMyFollowed });\n qc.invalidateQueries({ queryKey: KEY.intelOverviewFor(data.jurisdictionId) });\n },\n });\n};\n\nexport const useGovUnfollowJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (jurisdictionId: string) => {\n const result = await govQuery<{ govUnfollowJurisdiction: boolean }>(\n `mutation GovUnfollowJurisdiction($jurisdictionId: ID!) {\n govUnfollowJurisdiction(jurisdictionId: $jurisdictionId)\n }`,\n { jurisdictionId },\n apiGatewayUrl\n );\n return result.govUnfollowJurisdiction;\n },\n onSuccess: (_data, jurisdictionId) => {\n qc.invalidateQueries({ queryKey: KEY.intelMyFollowed });\n qc.invalidateQueries({ queryKey: KEY.intelOverviewFor(jurisdictionId) });\n },\n });\n};\n\n// ============================================================================\n// Data-change proposals (citizen corrections)\n// ============================================================================\n\nexport const useGovDataChangeProposals = (\n filter: GovDataChangeProposalFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelProposals, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govDataChangeProposals: GovDataChangeProposalConnection }>(\n `query GovDataChangeProposals($filter: GovDataChangeProposalFilterInput, $pagination: PaginationInput) {\n govDataChangeProposals(filter: $filter, pagination: $pagination) {\n items { ${PROPOSAL_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govDataChangeProposals;\n },\n });\n};\n\nexport const useGovDataChangeProposal = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelProposal(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovDataChangeProposal>(\n `query GovDataChangeProposal($id: ID!) {\n govDataChangeProposal(id: $id) {\n ${PROPOSAL_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { id },\n 'govDataChangeProposal',\n apiGatewayUrl\n ),\n });\n};\n\n/** Corrections the calling actor has submitted. */\nexport const useGovMyDataChangeProposals = (pagination?: PaginationInput) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelMyProposals, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govMyDataChangeProposals: GovDataChangeProposalConnection }>(\n `query GovMyDataChangeProposals($pagination: PaginationInput) {\n govMyDataChangeProposals(pagination: $pagination) {\n items { ${PROPOSAL_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govMyDataChangeProposals;\n },\n });\n};\n\nexport const useGovSubmitDataChangeProposal = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovSubmitDataChangeProposalInput) => {\n const result = await govQuery<{ govSubmitDataChangeProposal: GovDataChangeProposal }>(\n `mutation GovSubmitDataChangeProposal($input: GovSubmitDataChangeProposalInput!) {\n govSubmitDataChangeProposal(input: $input) { ${PROPOSAL_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govSubmitDataChangeProposal;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelProposals });\n qc.invalidateQueries({ queryKey: KEY.intelMyProposals });\n },\n });\n};\n\nexport const useGovWithdrawDataChangeProposal = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govWithdrawDataChangeProposal: GovDataChangeProposal }>(\n `mutation GovWithdrawDataChangeProposal($id: ID!) {\n govWithdrawDataChangeProposal(id: $id) { ${PROPOSAL_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govWithdrawDataChangeProposal;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelProposals });\n qc.invalidateQueries({ queryKey: KEY.intelMyProposals });\n qc.invalidateQueries({ queryKey: KEY.intelProposal(data.id) });\n },\n });\n};\n\n/**\n * Record a review decision. ACCEPTED records the accepted correction and stamps\n * `appliedAt`; it never silently mutates the target record.\n */\nexport const useGovReviewDataChangeProposal = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n decision: GovProposalStatus;\n reviewNote?: string | null;\n }) => {\n const result = await govQuery<{ govReviewDataChangeProposal: GovDataChangeProposal }>(\n `mutation GovReviewDataChangeProposal($id: ID!, $decision: GovProposalStatus!, $reviewNote: String) {\n govReviewDataChangeProposal(id: $id, decision: $decision, reviewNote: $reviewNote) {\n ${PROPOSAL_FIELDS}\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govReviewDataChangeProposal;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelProposals });\n qc.invalidateQueries({ queryKey: KEY.intelMyProposals });\n qc.invalidateQueries({ queryKey: KEY.intelProposal(data.id) });\n },\n });\n};\n"],"mappings":";;;;;AAgIA,IAAM,IAAO,CAAC,iBAAiB,OAAO,GAEhC,IAAM;CACV,kBAAkB,CAAC,GAAG,GAAM,cAAc;CAC1C,kBAAkB,MAAe;EAAC,GAAG;EAAM;EAAe;CAAE;CAC5D,oBAAoB,CAAC,GAAG,GAAM,eAAe;CAC7C,oBAAoB,MAAe;EAAC,GAAG;EAAM;EAAgB;CAAE;CAC/D,0BAA0B,MAAiB;EAAC,GAAG;EAAM;EAAwB;CAAI;CACjF,uBAAuB,CAAC,GAAG,GAAM,mBAAmB;CACpD,eAAe,CAAC,GAAG,GAAM,uBAAuB;CAChD,mBAAmB,MACjB;EAAC,GAAG;EAAM;EAAyB;CAAc;CACnD,gBAAgB,CAAC,GAAG,GAAM,WAAW;CACrC,gBAAgB,MAAe;EAAC,GAAG;EAAM;EAAY;CAAE;CACvD,kBAAkB,CAAC,GAAG,GAAM,sBAAsB;CAClD,gBAAgB,CAAC,GAAG,GAAM,WAAW;CACrC,gBAAgB,MAA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,CACF,GACc;CAElB,CAAC;AACH,GAEa,WAAuC;CAClD,IAAM,EAAE,qBAAkB,EAAiB,GACrC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAQV,MAPc,EACnB;yDACiD,EAAgB;YAEjE,EAAE,SAAM,GACR,CACF,GACc;EAEhB,iBAAiB;GAEf,AADA,EAAG,kBAAkB,EAAE,UAAU,EAAI,eAAe,CAAC,GACrD,EAAG,kBAAkB,EAAE,UAAU,EAAI,iBAAiB,CAAC;EACzD;CACF,CAAC;AACH,GAEa,WAAyC;CACpD,IAAM,EAAE,qBAAkB,EAAiB,GACrC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAQV,MAPc,EACnB;qDAC6C,EAAgB;YAE7D,EAAE,MAAG,GACL,CACF,GACc;EAEhB,YAAY,MAAS;GAGnB,AAFA,EAAG,kBAAkB,EAAE,UAAU,EAAI,eAAe,CAAC,GACrD,EAAG,kBAAkB,EAAE,UAAU,EAAI,iBAAiB,CAAC,GACvD,EAAG,kBAAkB,EAAE,UAAU,EAAI,cAAc,EAAK,EAAE,EAAE,CAAC;EAC/D;CACF,CAAC;AACH,GAMa,WAAuC;CAClD,IAAM,EAAE,qBAAkB,EAAiB,GACrC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAcV,MATc,EACnB;;cAEM,EAAgB;;YAGtB,GACA,CACF,GACc;EAEhB,YAAY,MAAS;GAGnB,AAFA,EAAG,kBAAkB,EAAE,UAAU,EAAI,eAAe,CAAC,GACrD,EAAG,kBAAkB,EAAE,UAAU,EAAI,iBAAiB,CAAC,GACvD,EAAG,kBAAkB,EAAE,UAAU,EAAI,cAAc,EAAK,EAAE,EAAE,CAAC;EAC/D;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"useIntelligenceApi.js","names":[],"sources":["../../../src/govcitizenhub/hooks/useIntelligenceApi.ts"],"sourcesContent":["/**\n * GovCitizenHub — Community Intelligence API hooks (BOFF-5666)\n * @module govcitizenhub/hooks\n *\n * React-Query hooks wired DIRECTLY to the FROZEN `wspace-govcitizenhub-svc`\n * `intelligence` subgraph contract. Every operation below uses an inline gql\n * string whose field and argument names match\n * `src/modules/intelligence/schema/*.gql` exactly. No mock data anywhere.\n *\n * Transport is the shared `govQuery` from `./useGovApi` —\n * `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` with the\n * partial-success handling and the pre/post-write response-cache clear. The\n * `page()` helper is likewise reused so the service never sees `cursor: null`\n * (see `svc-cursor-null-pagination-bug`).\n *\n * IMPORTANT CONTRACT NOTES\n * - Connections are `{ items, pageInfo { cursor hasMore } }`. There is NO\n * `totalCount` — never render `items.length` as a corpus total.\n * - `User` / `File` are id-only federation stubs. File references are opaque\n * `*FileId` strings resolved through the `useFiles` hook — we never select\n * `file { url }` or an office holder's platform account name.\n * - Queries that take an id are `enabled` only once the id is present.\n */\n\nimport { useMutation, useQuery, useQueryClient, type QueryClient } from '@tanstack/react-query';\n\nimport { useGovCitizenHub } from '../context';\nimport { govQuery, page } from './useGovApi';\nimport type {\n GovAdminLevel,\n GovAdminLevelPreset,\n GovAdminLevelConnection,\n GovAssetCategoryCount,\n GovBenchmarkResult,\n GovBenchmarkScope,\n GovBudget,\n GovBudgetConnection,\n GovBudgetExecution,\n GovBudgetFilterInput,\n GovBudgetLineInput,\n GovConsultation,\n GovConsultationConnection,\n GovConsultationFilterInput,\n GovConsultationResponse,\n GovConsultationResults,\n GovCreateAdminLevelInput,\n GovCreateBudgetInput,\n GovCreateConsultationInput,\n GovCreateDatasetInput,\n GovCreateElectionInput,\n GovCreateIndicatorInput,\n GovCreateJurisdictionEventInput,\n GovCreateJurisdictionInput,\n GovCreateOfficialCommitmentInput,\n GovCreateOfficialInput,\n GovCreateProjectInput,\n GovCreateProjectMilestoneInput,\n GovCreatePublicAssetInput,\n GovDataChangeProposal,\n GovDataChangeProposalConnection,\n GovDataChangeProposalFilterInput,\n GovDataset,\n GovDatasetConnection,\n GovDatasetFilterInput,\n GovElection,\n GovElectionConnection,\n GovElectionFilterInput,\n GovElectionResultInput,\n GovGrievanceInsights,\n GovIndicator,\n GovIndicatorConnection,\n GovIndicatorDomain,\n GovIndicatorFilterInput,\n GovIndicatorSeries,\n GovIndicatorValue,\n GovIndicatorValueConnection,\n GovIndicatorValueFilterInput,\n GovJurisdiction,\n GovJurisdictionConnection,\n GovJurisdictionEvent,\n GovJurisdictionEventConnection,\n GovJurisdictionFilterInput,\n GovJurisdictionFollow,\n GovJurisdictionInsight,\n GovJurisdictionOverview,\n GovJurisdictionScorecard,\n GovJurisdictionTreeNode,\n GovOfficial,\n GovOfficialCommitment,\n GovOfficialCommitmentConnection,\n GovOfficialCommitmentFilterInput,\n GovOfficialConnection,\n GovOfficialFilterInput,\n GovProject,\n GovProjectConnection,\n GovProjectFilterInput,\n GovProjectMilestone,\n GovProjectStatus,\n GovProposalStatus,\n GovPublicAsset,\n GovPublicAssetConnection,\n GovPublicAssetFilterInput,\n GovRecordIndicatorValueInput,\n GovServicePerformance,\n GovSubmitConsultationResponseInput,\n GovSubmitDataChangeProposalInput,\n GovUpdateAdminLevelInput,\n GovUpdateBudgetInput,\n GovUpdateConsultationInput,\n GovUpdateDatasetInput,\n GovUpdateElectionInput,\n GovUpdateIndicatorInput,\n GovUpdateIndicatorValueInput,\n GovUpdateJurisdictionEventInput,\n GovUpdateJurisdictionInput,\n GovUpdateOfficialCommitmentInput,\n GovUpdateOfficialInput,\n GovUpdateProjectInput,\n GovUpdateProjectMilestoneInput,\n GovUpdatePublicAssetInput,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// React-Query key roots — one `intel*` namespace per Community Intelligence\n// surface. Every entry is a PREFIX: `invalidateQueries({ queryKey: KEY.intelX })`\n// therefore also drops every id-scoped/derived entry built from it.\n// ============================================================================\n\nconst ROOT = ['govcitizenhub', 'intel'] as const;\n\nconst KEY = {\n intelAdminLevels: [...ROOT, 'admin-levels'] as const,\n intelAdminLevelPresets: ['govcitizenhub', 'intel', 'admin-level-presets'] as const,\n intelAdminLevel: (id: string) => [...ROOT, 'admin-level', id] as const,\n intelJurisdictions: [...ROOT, 'jurisdictions'] as const,\n intelJurisdiction: (id: string) => [...ROOT, 'jurisdiction', id] as const,\n intelJurisdictionBySlug: (slug: string) => [...ROOT, 'jurisdiction-by-slug', slug] as const,\n intelJurisdictionTree: [...ROOT, 'jurisdiction-tree'] as const,\n intelOverview: [...ROOT, 'jurisdiction-overview'] as const,\n intelOverviewFor: (jurisdictionId: string) =>\n [...ROOT, 'jurisdiction-overview', jurisdictionId] as const,\n intelOfficials: [...ROOT, 'officials'] as const,\n intelOfficial: (id: string) => [...ROOT, 'official', id] as const,\n intelCommitments: [...ROOT, 'official-commitments'] as const,\n intelElections: [...ROOT, 'elections'] as const,\n intelElection: (id: string) => [...ROOT, 'election', id] as const,\n intelEvents: [...ROOT, 'jurisdiction-events'] as const,\n intelEventsFor: (jurisdictionId: string) =>\n [...ROOT, 'jurisdiction-events', jurisdictionId] as const,\n intelBudgets: [...ROOT, 'budgets'] as const,\n intelBudget: (id: string) => [...ROOT, 'budget', id] as const,\n intelBudgetExecution: [...ROOT, 'budget-execution'] as const,\n intelBudgetExecutionFor: (budgetId: string) => [...ROOT, 'budget-execution', budgetId] as const,\n intelProjects: [...ROOT, 'projects'] as const,\n intelProject: (id: string) => [...ROOT, 'project', id] as const,\n intelIndicators: [...ROOT, 'indicators'] as const,\n intelIndicator: (id: string) => [...ROOT, 'indicator', id] as const,\n intelIndicatorValues: [...ROOT, 'indicator-values'] as const,\n intelIndicatorSeries: [...ROOT, 'indicator-series'] as const,\n intelScorecard: [...ROOT, 'scorecard'] as const,\n intelBenchmark: [...ROOT, 'benchmark'] as const,\n intelInsights: [...ROOT, 'insights'] as const,\n intelServicePerformance: [...ROOT, 'service-performance'] as const,\n intelGrievanceInsights: [...ROOT, 'grievance-insights'] as const,\n intelAssets: [...ROOT, 'public-assets'] as const,\n intelAsset: (id: string) => [...ROOT, 'public-asset', id] as const,\n intelAssetSummary: [...ROOT, 'public-asset-summary'] as const,\n intelAssetSummaryFor: (jurisdictionId: string) =>\n [...ROOT, 'public-asset-summary', jurisdictionId] as const,\n intelConsultations: [...ROOT, 'consultations'] as const,\n intelConsultation: (id: string) => [...ROOT, 'consultation', id] as const,\n intelConsultationResults: [...ROOT, 'consultation-results'] as const,\n intelConsultationResultsFor: (consultationId: string) =>\n [...ROOT, 'consultation-results', consultationId] as const,\n intelMyConsultationResponse: [...ROOT, 'my-consultation-response'] as const,\n intelMyConsultationResponseFor: (consultationId: string) =>\n [...ROOT, 'my-consultation-response', consultationId] as const,\n intelDatasets: [...ROOT, 'datasets'] as const,\n intelDataset: (id: string) => [...ROOT, 'dataset', id] as const,\n intelMyFollowed: [...ROOT, 'my-followed-jurisdictions'] as const,\n intelProposals: [...ROOT, 'data-change-proposals'] as const,\n intelProposal: (id: string) => [...ROOT, 'data-change-proposal', id] as const,\n intelMyProposals: [...ROOT, 'my-data-change-proposals'] as const,\n};\n\n/**\n * `govQuery` treats an all-null payload as a failed request — it cannot tell a\n * dropped response from a legitimately-null field. Several intelligence reads\n * resolve to null as their NORMAL state (`govMyConsultationResponse` before the\n * actor has responded, `govJurisdictionScorecard` before any core indicator is\n * measured). This unwraps that specific case back to a plain `null`; a real\n * gateway/service error still carries a server message and still throws.\n */\nconst NO_DATA_MESSAGE = 'GraphQL response did not include data';\n\nconst govNullableQuery = async <TField>(\n query: string,\n variables: Record<string, unknown>,\n field: string,\n baseUrl?: string\n): Promise<TField | null> => {\n try {\n const result = await govQuery<Record<string, TField | null>>(query, variables, baseUrl);\n return result[field] ?? null;\n } catch (error) {\n if (error instanceof Error && error.message === NO_DATA_MESSAGE) return null;\n throw error;\n }\n};\n\n/**\n * Derived surfaces (overview tiles, scorecard, insights, benchmark, series) are\n * computed live from indicators, budgets, projects, assets, datasets and\n * consultations — so any write to those has to drop them too.\n */\nconst invalidateDerived = (qc: QueryClient): void => {\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n qc.invalidateQueries({ queryKey: KEY.intelScorecard });\n qc.invalidateQueries({ queryKey: KEY.intelInsights });\n qc.invalidateQueries({ queryKey: KEY.intelBenchmark });\n};\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness). Every name below is\n// verified against the frozen SDL.\n// ============================================================================\n\nconst ADMIN_LEVEL_FIELDS = `\n id workspaceId countryCode rank code name pluralName description isElectoral\n jurisdictionCount createdAt updatedAt\n`;\n\nconst JURISDICTION_FIELDS = `\n id workspaceId parentId adminLevelId countryCode name localName officialCode slug status\n path depth summary establishedOn headquarters officialWebsite contactEmail contactPhone\n emergencyNumbers timezone languages currencyCode climateSummary areaSqKm population\n populationYear households centroidLat centroidLng populationDensity boundaryFileId\n bannerFileId crestFileId tags sourceName sourceUrl verification publishedAt\n createdAt updatedAt\n`;\n\n/**\n * Narrower selection for nested parent / ancestor / child jurisdictions. It\n * still covers every NON-NULL field of `GovJurisdiction`, so the value we hand\n * back genuinely satisfies the type — it just omits the long-form profile prose.\n */\nconst JURISDICTION_REF_FIELDS = `\n id workspaceId parentId adminLevelId countryCode name localName officialCode slug status\n path depth areaSqKm population populationYear populationDensity crestFileId bannerFileId\n languages tags verification publishedAt createdAt updatedAt\n`;\n\nconst TREE_NODE_FIELDS = `\n id name slug status depth adminLevelCode adminLevelName population childCount\n`;\n\n/**\n * `govJurisdictionTree` clamps `maxDepth` to 6 tiers. We nest ONE level deeper\n * than that so every node the service can actually return has its `children`\n * selected — the deepest selection can never be reached, which keeps\n * `GovJurisdictionTreeNode.children` non-optional and honest.\n */\nconst treeNodeSelection = (remaining: number): string =>\n remaining <= 0\n ? TREE_NODE_FIELDS\n : `${TREE_NODE_FIELDS} children { ${treeNodeSelection(remaining - 1)} }`;\n\nconst TREE_SELECTION = treeNodeSelection(7);\n\nconst OFFICIAL_FIELDS = `\n id workspaceId jurisdictionId fullName localName officeTitle officeType department party\n isIndependent photoFileId biography contactEmail contactPhone officeAddress officeHours\n socialProfiles termStart termEnd termDurationMonths electedOn nextElectionOn\n attendancePercent votingRecordUrl committees responsibilities isCurrent displayOrder\n linkedUserId sourceName sourceUrl verification commitmentDeliveryRate createdAt updatedAt\n`;\n\nconst COMMITMENT_FIELDS = `\n id workspaceId officialId jurisdictionId title description domain promisedOn targetDate\n status progressPercent linkedProjectId evidenceUrl evidenceFileIds sourceName sourceUrl\n verification isOverdue createdAt updatedAt\n`;\n\nconst ELECTION_FIELDS = `\n id workspaceId jurisdictionId name electionType officeTitle electionDate status\n registeredVoters votesCast validVotes invalidVotes turnoutPercent resultDeclaredOn\n sourceName sourceUrl verification winningMarginVotes winningMarginPercent\n createdAt updatedAt\n`;\n\nconst ELECTION_RESULT_FIELDS = `\n id workspaceId electionId candidateName party isIndependent votes votePercent position\n isWinner photoFileId officialId createdAt updatedAt\n`;\n\nconst EVENT_FIELDS = `\n id workspaceId jurisdictionId title description occurredOn category impact\n linkedProjectId linkedElectionId linkedBudgetId imageFileId sourceName sourceUrl\n verification createdAt updatedAt\n`;\n\nconst BUDGET_FIELDS = `\n id workspaceId jurisdictionId fiscalYear periodStart periodEnd currencyCode status\n totalRevenuePlanned totalRevenueActual totalExpensePlanned totalExpenseActual\n populationAtPublication summary documentFileId approvedOn publishedAt sourceName\n sourceUrl verification createdAt updatedAt\n`;\n\nconst BUDGET_LINE_FIELDS = `\n id workspaceId budgetId kind category label department functionCode plannedAmount\n actualAmount previousYearAmount notes displayOrder variance variancePercent\n createdAt updatedAt\n`;\n\nconst BUDGET_EXECUTION_FIELDS = `\n budgetId fiscalYear currencyCode plannedRevenue actualRevenue plannedExpense\n actualExpense executionPercent perCapitaExpense perCapitaActualExpense\n byCategory { kind category planned actual variance variancePercent sharePercent }\n`;\n\nconst PROJECT_FIELDS = `\n id workspaceId jurisdictionId agencyId name code description domain department\n contractorName contractorRegistrationId fundingSource budgetAmount actualCost\n currencyCode tenderReference tenderUrl awardedOn startDate plannedCompletionDate\n actualCompletionDate status progressPercent delayReason locationLabel latitude longitude\n imageFileIds documentFileIds beneficiaryCount tags sourceName sourceUrl verification\n publishedAt delayDays costVariance createdAt updatedAt\n`;\n\nconst MILESTONE_FIELDS = `\n id workspaceId projectId name description dueDate completedOn status progressPercent\n evidenceFileId displayOrder isOverdue createdAt updatedAt\n`;\n\nconst INDICATOR_FIELDS = `\n id workspaceId code name description domain unit valueType direction periodicity\n methodology targetValue minValue maxValue isCore weight isActive sdgGoal sourceName\n sourceUrl createdAt updatedAt\n`;\n\nconst INDICATOR_VALUE_FIELDS = `\n id workspaceId indicatorId jurisdictionId periodLabel periodStart periodEnd value\n numerator denominator targetValue sourceName sourceUrl sourceDate datasetId verification\n notes publishedAt createdAt updatedAt\n`;\n\nconst INDICATOR_SERIES_FIELDS = `\n jurisdictionId latestValue latestPeriodLabel changePercent trend\n indicator { ${INDICATOR_FIELDS} }\n points { periodLabel periodStart value targetValue verification }\n`;\n\nconst SCORECARD_FIELDS = `\n jurisdictionId jurisdictionName periodLabel overallScore coveragePercent indicatorCount\n measuredCount generatedAt\n domains { domain score indicatorCount measuredCount trend changePercent }\n`;\n\nconst INSIGHT_FIELDS = `\n kind severity title detail domain indicatorCode evidence generatedAt\n`;\n\nconst BENCHMARK_ENTRY_FIELDS = `jurisdictionId jurisdictionName value rank`;\n\nconst BENCHMARK_FIELDS = `\n jurisdictionId periodLabel scope peerCount percentile average median isRankPublished\n indicator { ${INDICATOR_FIELDS} }\n subject { ${BENCHMARK_ENTRY_FIELDS} }\n peers { ${BENCHMARK_ENTRY_FIELDS} }\n best { ${BENCHMARK_ENTRY_FIELDS} }\n worst { ${BENCHMARK_ENTRY_FIELDS} }\n`;\n\nconst SERVICE_PERFORMANCE_FIELDS = `\n jurisdictionId totalApplications approvedCount rejectedCount pendingCount approvalRate\n avgProcessingHours slaBreachedCount slaCompliancePercent\n byService {\n serviceId serviceName applications approved rejected pending avgProcessingHours\n slaDays slaCompliancePercent\n }\n byAgency {\n agencyId agencyName applications approved rejected pending avgProcessingHours\n slaCompliancePercent\n }\n`;\n\nconst GRIEVANCE_INSIGHTS_FIELDS = `\n jurisdictionId total open inProgress resolved avgResolutionHours\n byCategory { category total resolved avgResolutionHours }\n hotspots { locationLabel latitude longitude count topCategory }\n`;\n\nconst PUBLIC_ASSET_FIELDS = `\n id workspaceId jurisdictionId name category subCategory description operator status\n address latitude longitude capacity capacityUnit contactPhone contactEmail website\n openingHours isAccessible establishedOn imageFileId metadata tags sourceName sourceUrl\n verification createdAt updatedAt\n`;\n\nconst CONSULTATION_FIELDS = `\n id workspaceId jurisdictionId title description consultationType status opensAt closesAt\n questions allowAnonymous budgetAmount currencyCode responseCount resultsSummary\n resultsPublishedAt documentFileId tags isAcceptingResponses hasRespondedByMe\n createdAt updatedAt\n`;\n\nconst CONSULTATION_RESPONSE_FIELDS = `\n id workspaceId consultationId jurisdictionId respondentActorId answers sentiment submittedAt\n`;\n\nconst CONSULTATION_RESULTS_FIELDS = `\n consultationId status responseCount resultsPublishedAt isSuppressed\n questions { questionId label type responseCount aggregate }\n`;\n\nconst DATASET_FIELDS = `\n id workspaceId jurisdictionId name slug description domain format license licenseUrl\n version fileId externalUrl periodStart periodEnd updateFrequency rowCount sizeBytes\n publisher contactEmail status publishedAt downloadCount tags createdAt updatedAt\n`;\n\nconst FOLLOW_FIELDS = `\n id workspaceId jurisdictionId actorId channels topics createdAt\n`;\n\nconst PROPOSAL_FIELDS = `\n id workspaceId jurisdictionId entityType entityId fieldPath currentValue proposedValue\n rationale evidenceUrl evidenceFileIds status submittedByActorId submittedAt\n reviewedByActorId reviewedAt reviewNote appliedAt createdAt updatedAt\n`;\n\nconst OVERVIEW_FIELDS = `\n childCount officialCount activeProjectCount completedProjectCount publishedDatasetCount\n openConsultationCount publicAssetCount followerCount isFollowedByMe\n jurisdiction { ${JURISDICTION_FIELDS} }\n adminLevel { ${ADMIN_LEVEL_FIELDS} }\n parent { ${JURISDICTION_REF_FIELDS} }\n currentBudget { ${BUDGET_FIELDS} }\n scorecard { ${SCORECARD_FIELDS} }\n insights { ${INSIGHT_FIELDS} }\n`;\n\n// ============================================================================\n// Administrative hierarchy — GovAdminLevel\n// ============================================================================\n\nexport const useGovAdminLevels = (countryCode?: string, pagination?: PaginationInput) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelAdminLevels, countryCode ?? null, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govAdminLevels: GovAdminLevelConnection }>(\n `query GovAdminLevels($countryCode: String, $pagination: PaginationInput) {\n govAdminLevels(countryCode: $countryCode, pagination: $pagination) {\n items { ${ADMIN_LEVEL_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { countryCode, pagination: page(pagination ?? { limit: 100 }) },\n apiGatewayUrl\n );\n return result.govAdminLevels;\n },\n });\n};\n\n/**\n * Presets the given country can be seeded from, best first.\n *\n * Drives the seed picker so an officer sees the tier names that will actually be\n * created — States and Districts for India, Counties and Sub-counties for Kenya\n * — instead of a generic label that hides what they are about to get.\n */\nexport const useGovAdminLevelPresets = (countryCode: string | null | undefined) =>\n useQuery({\n queryKey: [...KEY.intelAdminLevelPresets, countryCode ?? ''],\n enabled: Boolean(countryCode),\n queryFn: () =>\n govQuery<{ govAdminLevelPresets: GovAdminLevelPreset[] }>(\n `query($countryCode: String!){ govAdminLevelPresets(countryCode: $countryCode){ key label description isCountrySpecific tiers { rank code name pluralName isElectoral } } }`,\n { countryCode }\n ).then((d) => d.govAdminLevelPresets),\n });\n\nexport const useGovAdminLevel = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelAdminLevel(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovAdminLevel>(\n `query GovAdminLevel($id: ID!) {\n govAdminLevel(id: $id) { ${ADMIN_LEVEL_FIELDS} }\n }`,\n { id },\n 'govAdminLevel',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateAdminLevel = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateAdminLevelInput) => {\n const result = await govQuery<{ govCreateAdminLevel: GovAdminLevel }>(\n `mutation GovCreateAdminLevel($input: GovCreateAdminLevelInput!) {\n govCreateAdminLevel(input: $input) { ${ADMIN_LEVEL_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateAdminLevel;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelAdminLevels }),\n });\n};\n\nexport const useGovUpdateAdminLevel = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateAdminLevelInput }) => {\n const result = await govQuery<{ govUpdateAdminLevel: GovAdminLevel }>(\n `mutation GovUpdateAdminLevel($id: ID!, $input: GovUpdateAdminLevelInput!) {\n govUpdateAdminLevel(id: $id, input: $input) { ${ADMIN_LEVEL_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateAdminLevel;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelAdminLevels });\n qc.invalidateQueries({ queryKey: KEY.intelAdminLevel(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n },\n });\n};\n\nexport const useGovDeleteAdminLevel = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteAdminLevel: boolean }>(\n `mutation GovDeleteAdminLevel($id: ID!) { govDeleteAdminLevel(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteAdminLevel;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelAdminLevels }),\n });\n};\n\n/** Bootstrap a country's hierarchy from a named preset. Additive and idempotent. */\nexport const useGovSeedAdminLevels = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { countryCode: string; preset?: string | null }) => {\n const result = await govQuery<{ govSeedAdminLevels: GovAdminLevel[] }>(\n `mutation GovSeedAdminLevels($countryCode: String!, $preset: String) {\n govSeedAdminLevels(countryCode: $countryCode, preset: $preset) { ${ADMIN_LEVEL_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govSeedAdminLevels;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelAdminLevels }),\n });\n};\n\n// ============================================================================\n// Jurisdictions\n// ============================================================================\n\nexport const useGovJurisdictions = (\n filter: GovJurisdictionFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelJurisdictions, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictions: GovJurisdictionConnection }>(\n `query GovJurisdictions($filter: GovJurisdictionFilterInput, $pagination: PaginationInput) {\n govJurisdictions(filter: $filter, pagination: $pagination) {\n items { ${JURISDICTION_FIELDS} adminLevel { ${ADMIN_LEVEL_FIELDS} } }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govJurisdictions;\n },\n });\n};\n\nexport const useGovJurisdiction = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelJurisdiction(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovJurisdiction>(\n `query GovJurisdiction($id: ID!) {\n govJurisdiction(id: $id) {\n ${JURISDICTION_FIELDS}\n adminLevel { ${ADMIN_LEVEL_FIELDS} }\n parent { ${JURISDICTION_REF_FIELDS} }\n ancestors { ${JURISDICTION_REF_FIELDS} }\n children { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { id },\n 'govJurisdiction',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovJurisdictionBySlug = (slug: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelJurisdictionBySlug(slug ?? ''),\n enabled: Boolean(slug),\n queryFn: async () =>\n govNullableQuery<GovJurisdiction>(\n `query GovJurisdictionBySlug($slug: String!) {\n govJurisdictionBySlug(slug: $slug) {\n ${JURISDICTION_FIELDS}\n adminLevel { ${ADMIN_LEVEL_FIELDS} }\n ancestors { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { slug },\n 'govJurisdictionBySlug',\n apiGatewayUrl\n ),\n });\n};\n\n/** The administrative hierarchy as a tree. `maxDepth` is clamped to 6 tiers by the service. */\nexport const useGovJurisdictionTree = (rootId?: string | null, maxDepth?: number) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelJurisdictionTree, rootId ?? null, maxDepth ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionTree: GovJurisdictionTreeNode[] }>(\n `query GovJurisdictionTree($rootId: ID, $maxDepth: Int) {\n govJurisdictionTree(rootId: $rootId, maxDepth: $maxDepth) { ${TREE_SELECTION} }\n }`,\n { rootId: rootId ?? undefined, maxDepth },\n apiGatewayUrl\n );\n return result.govJurisdictionTree;\n },\n });\n};\n\n/** Single page-load aggregate for the jurisdiction profile screen. */\nexport const useGovJurisdictionOverview = (jurisdictionId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelOverviewFor(jurisdictionId ?? ''),\n enabled: Boolean(jurisdictionId),\n queryFn: async () =>\n govNullableQuery<GovJurisdictionOverview>(\n `query GovJurisdictionOverview($jurisdictionId: ID!) {\n govJurisdictionOverview(jurisdictionId: $jurisdictionId) { ${OVERVIEW_FIELDS} }\n }`,\n { jurisdictionId },\n 'govJurisdictionOverview',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateJurisdictionInput) => {\n const result = await govQuery<{ govCreateJurisdiction: GovJurisdiction }>(\n `mutation GovCreateJurisdiction($input: GovCreateJurisdictionInput!) {\n govCreateJurisdiction(input: $input) { ${JURISDICTION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateJurisdiction;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n qc.invalidateQueries({ queryKey: KEY.intelAdminLevels });\n },\n });\n};\n\nexport const useGovUpdateJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateJurisdictionInput }) => {\n const result = await govQuery<{ govUpdateJurisdiction: GovJurisdiction }>(\n `mutation GovUpdateJurisdiction($id: ID!, $input: GovUpdateJurisdictionInput!) {\n govUpdateJurisdiction(id: $id, input: $input) { ${JURISDICTION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateJurisdiction;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdiction(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionBySlug(data.slug) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovPublishJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govPublishJurisdiction: GovJurisdiction }>(\n `mutation GovPublishJurisdiction($id: ID!) {\n govPublishJurisdiction(id: $id) { ${JURISDICTION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPublishJurisdiction;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdiction(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovArchiveJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govArchiveJurisdiction: GovJurisdiction }>(\n `mutation GovArchiveJurisdiction($id: ID!) {\n govArchiveJurisdiction(id: $id) { ${JURISDICTION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govArchiveJurisdiction;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdiction(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovDeleteJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteJurisdiction: boolean }>(\n `mutation GovDeleteJurisdiction($id: ID!) { govDeleteJurisdiction(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteJurisdiction;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictions });\n qc.invalidateQueries({ queryKey: KEY.intelJurisdictionTree });\n invalidateDerived(qc);\n },\n });\n};\n\n// ============================================================================\n// Officials & commitments\n// ============================================================================\n\nexport const useGovOfficials = (\n filter: GovOfficialFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelOfficials, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govOfficials: GovOfficialConnection }>(\n `query GovOfficials($filter: GovOfficialFilterInput, $pagination: PaginationInput) {\n govOfficials(filter: $filter, pagination: $pagination) {\n items { ${OFFICIAL_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govOfficials;\n },\n });\n};\n\nexport const useGovOfficial = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelOfficial(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovOfficial>(\n `query GovOfficial($id: ID!) {\n govOfficial(id: $id) {\n ${OFFICIAL_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n commitments { ${COMMITMENT_FIELDS} }\n }\n }`,\n { id },\n 'govOfficial',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovOfficialCommitments = (\n filter: GovOfficialCommitmentFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelCommitments, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govOfficialCommitments: GovOfficialCommitmentConnection }>(\n `query GovOfficialCommitments($filter: GovOfficialCommitmentFilterInput, $pagination: PaginationInput) {\n govOfficialCommitments(filter: $filter, pagination: $pagination) {\n items { ${COMMITMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govOfficialCommitments;\n },\n });\n};\n\nexport const useGovCreateOfficial = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateOfficialInput) => {\n const result = await govQuery<{ govCreateOfficial: GovOfficial }>(\n `mutation GovCreateOfficial($input: GovCreateOfficialInput!) {\n govCreateOfficial(input: $input) { ${OFFICIAL_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateOfficial;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateOfficial = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateOfficialInput }) => {\n const result = await govQuery<{ govUpdateOfficial: GovOfficial }>(\n `mutation GovUpdateOfficial($id: ID!, $input: GovUpdateOfficialInput!) {\n govUpdateOfficial(id: $id, input: $input) { ${OFFICIAL_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateOfficial;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n qc.invalidateQueries({ queryKey: KEY.intelOfficial(data.id) });\n },\n });\n};\n\nexport const useGovDeleteOfficial = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteOfficial: boolean }>(\n `mutation GovDeleteOfficial($id: ID!) { govDeleteOfficial(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteOfficial;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n qc.invalidateQueries({ queryKey: KEY.intelCommitments });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovCreateOfficialCommitment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateOfficialCommitmentInput) => {\n const result = await govQuery<{ govCreateOfficialCommitment: GovOfficialCommitment }>(\n `mutation GovCreateOfficialCommitment($input: GovCreateOfficialCommitmentInput!) {\n govCreateOfficialCommitment(input: $input) { ${COMMITMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateOfficialCommitment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelCommitments });\n qc.invalidateQueries({ queryKey: KEY.intelOfficial(data.officialId) });\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n },\n });\n};\n\nexport const useGovUpdateOfficialCommitment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateOfficialCommitmentInput }) => {\n const result = await govQuery<{ govUpdateOfficialCommitment: GovOfficialCommitment }>(\n `mutation GovUpdateOfficialCommitment($id: ID!, $input: GovUpdateOfficialCommitmentInput!) {\n govUpdateOfficialCommitment(id: $id, input: $input) { ${COMMITMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateOfficialCommitment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelCommitments });\n qc.invalidateQueries({ queryKey: KEY.intelOfficial(data.officialId) });\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n },\n });\n};\n\nexport const useGovDeleteOfficialCommitment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteOfficialCommitment: boolean }>(\n `mutation GovDeleteOfficialCommitment($id: ID!) { govDeleteOfficialCommitment(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteOfficialCommitment;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelCommitments });\n qc.invalidateQueries({ queryKey: KEY.intelOfficials });\n },\n });\n};\n\n// ============================================================================\n// Elections\n// ============================================================================\n\nexport const useGovElections = (\n filter: GovElectionFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelElections, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govElections: GovElectionConnection }>(\n `query GovElections($filter: GovElectionFilterInput, $pagination: PaginationInput) {\n govElections(filter: $filter, pagination: $pagination) {\n items { ${ELECTION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govElections;\n },\n });\n};\n\nexport const useGovElection = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelElection(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovElection>(\n `query GovElection($id: ID!) {\n govElection(id: $id) {\n ${ELECTION_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n results { ${ELECTION_RESULT_FIELDS} }\n }\n }`,\n { id },\n 'govElection',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateElection = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateElectionInput) => {\n const result = await govQuery<{ govCreateElection: GovElection }>(\n `mutation GovCreateElection($input: GovCreateElectionInput!) {\n govCreateElection(input: $input) { ${ELECTION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateElection;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelElections }),\n });\n};\n\nexport const useGovUpdateElection = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateElectionInput }) => {\n const result = await govQuery<{ govUpdateElection: GovElection }>(\n `mutation GovUpdateElection($id: ID!, $input: GovUpdateElectionInput!) {\n govUpdateElection(id: $id, input: $input) { ${ELECTION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateElection;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelElections });\n qc.invalidateQueries({ queryKey: KEY.intelElection(data.id) });\n },\n });\n};\n\nexport const useGovDeleteElection = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteElection: boolean }>(\n `mutation GovDeleteElection($id: ID!) { govDeleteElection(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteElection;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelElections }),\n });\n};\n\n/** Replace an election's declared results in one transaction. */\nexport const useGovRecordElectionResults = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { electionId: string; results: GovElectionResultInput[] }) => {\n const result = await govQuery<{ govRecordElectionResults: GovElection }>(\n `mutation GovRecordElectionResults($electionId: ID!, $results: [GovElectionResultInput!]!) {\n govRecordElectionResults(electionId: $electionId, results: $results) {\n ${ELECTION_FIELDS}\n results { ${ELECTION_RESULT_FIELDS} }\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govRecordElectionResults;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelElections });\n qc.invalidateQueries({ queryKey: KEY.intelElection(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Jurisdiction timeline events\n// ============================================================================\n\nexport const useGovJurisdictionEvents = (\n jurisdictionId: string | undefined,\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelEventsFor(jurisdictionId ?? ''), pagination ?? null],\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionEvents: GovJurisdictionEventConnection }>(\n `query GovJurisdictionEvents($jurisdictionId: ID!, $pagination: PaginationInput) {\n govJurisdictionEvents(jurisdictionId: $jurisdictionId, pagination: $pagination) {\n items { ${EVENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { jurisdictionId, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govJurisdictionEvents;\n },\n });\n};\n\nexport const useGovCreateJurisdictionEvent = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateJurisdictionEventInput) => {\n const result = await govQuery<{ govCreateJurisdictionEvent: GovJurisdictionEvent }>(\n `mutation GovCreateJurisdictionEvent($input: GovCreateJurisdictionEventInput!) {\n govCreateJurisdictionEvent(input: $input) { ${EVENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateJurisdictionEvent;\n },\n onSuccess: (data) =>\n qc.invalidateQueries({ queryKey: KEY.intelEventsFor(data.jurisdictionId) }),\n });\n};\n\nexport const useGovUpdateJurisdictionEvent = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateJurisdictionEventInput }) => {\n const result = await govQuery<{ govUpdateJurisdictionEvent: GovJurisdictionEvent }>(\n `mutation GovUpdateJurisdictionEvent($id: ID!, $input: GovUpdateJurisdictionEventInput!) {\n govUpdateJurisdictionEvent(id: $id, input: $input) { ${EVENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateJurisdictionEvent;\n },\n onSuccess: (data) =>\n qc.invalidateQueries({ queryKey: KEY.intelEventsFor(data.jurisdictionId) }),\n });\n};\n\nexport const useGovDeleteJurisdictionEvent = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteJurisdictionEvent: boolean }>(\n `mutation GovDeleteJurisdictionEvent($id: ID!) { govDeleteJurisdictionEvent(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteJurisdictionEvent;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.intelEvents }),\n });\n};\n\n// ============================================================================\n// Budgets\n// ============================================================================\n\nexport const useGovBudgets = (filter: GovBudgetFilterInput = {}, pagination?: PaginationInput) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelBudgets, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govBudgets: GovBudgetConnection }>(\n `query GovBudgets($filter: GovBudgetFilterInput, $pagination: PaginationInput) {\n govBudgets(filter: $filter, pagination: $pagination) {\n items { ${BUDGET_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govBudgets;\n },\n });\n};\n\nexport const useGovBudget = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelBudget(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovBudget>(\n `query GovBudget($id: ID!) {\n govBudget(id: $id) {\n ${BUDGET_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n lines { ${BUDGET_LINE_FIELDS} }\n }\n }`,\n { id },\n 'govBudget',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovBudgetExecution = (budgetId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelBudgetExecutionFor(budgetId ?? ''),\n enabled: Boolean(budgetId),\n queryFn: async () =>\n govNullableQuery<GovBudgetExecution>(\n `query GovBudgetExecution($budgetId: ID!) {\n govBudgetExecution(budgetId: $budgetId) { ${BUDGET_EXECUTION_FIELDS} }\n }`,\n { budgetId },\n 'govBudgetExecution',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateBudget = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateBudgetInput) => {\n const result = await govQuery<{ govCreateBudget: GovBudget }>(\n `mutation GovCreateBudget($input: GovCreateBudgetInput!) {\n govCreateBudget(input: $input) { ${BUDGET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateBudget;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateBudget = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateBudgetInput }) => {\n const result = await govQuery<{ govUpdateBudget: GovBudget }>(\n `mutation GovUpdateBudget($id: ID!, $input: GovUpdateBudgetInput!) {\n govUpdateBudget(id: $id, input: $input) { ${BUDGET_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateBudget;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudget(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecutionFor(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovPublishBudget = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govPublishBudget: GovBudget }>(\n `mutation GovPublishBudget($id: ID!) {\n govPublishBudget(id: $id) { ${BUDGET_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPublishBudget;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudget(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecutionFor(data.id) });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovDeleteBudget = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteBudget: boolean }>(\n `mutation GovDeleteBudget($id: ID!) { govDeleteBudget(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteBudget;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecution });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Create/update budget lines in one transaction; the service re-derives the totals. */\nexport const useGovUpsertBudgetLines = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { budgetId: string; lines: GovBudgetLineInput[] }) => {\n const result = await govQuery<{ govUpsertBudgetLines: GovBudget }>(\n `mutation GovUpsertBudgetLines($budgetId: ID!, $lines: [GovBudgetLineInput!]!) {\n govUpsertBudgetLines(budgetId: $budgetId, lines: $lines) {\n ${BUDGET_FIELDS}\n lines { ${BUDGET_LINE_FIELDS} }\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpsertBudgetLines;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudget(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecutionFor(data.id) });\n },\n });\n};\n\nexport const useGovDeleteBudgetLine = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; budgetId?: string }) => {\n const result = await govQuery<{ govDeleteBudgetLine: boolean }>(\n `mutation GovDeleteBudgetLine($id: ID!) { govDeleteBudgetLine(id: $id) }`,\n { id: vars.id },\n apiGatewayUrl\n );\n return result.govDeleteBudgetLine;\n },\n onSuccess: (_data, vars) => {\n qc.invalidateQueries({ queryKey: KEY.intelBudgets });\n qc.invalidateQueries({ queryKey: KEY.intelBudgetExecution });\n if (vars.budgetId) qc.invalidateQueries({ queryKey: KEY.intelBudget(vars.budgetId) });\n },\n });\n};\n\n// ============================================================================\n// Development projects & milestones\n// ============================================================================\n\nexport const useGovProjects = (\n filter: GovProjectFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelProjects, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govProjects: GovProjectConnection }>(\n `query GovProjects($filter: GovProjectFilterInput, $pagination: PaginationInput) {\n govProjects(filter: $filter, pagination: $pagination) {\n items { ${PROJECT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govProjects;\n },\n });\n};\n\nexport const useGovProject = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelProject(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovProject>(\n `query GovProject($id: ID!) {\n govProject(id: $id) {\n ${PROJECT_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n milestones { ${MILESTONE_FIELDS} }\n }\n }`,\n { id },\n 'govProject',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateProject = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateProjectInput) => {\n const result = await govQuery<{ govCreateProject: GovProject }>(\n `mutation GovCreateProject($input: GovCreateProjectInput!) {\n govCreateProject(input: $input) { ${PROJECT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateProject;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelProjects });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateProject = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateProjectInput }) => {\n const result = await govQuery<{ govUpdateProject: GovProject }>(\n `mutation GovUpdateProject($id: ID!, $input: GovUpdateProjectInput!) {\n govUpdateProject(id: $id, input: $input) { ${PROJECT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateProject;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelProjects });\n qc.invalidateQueries({ queryKey: KEY.intelProject(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Advance a project's delivery status, optionally recording progress and a delay reason. */\nexport const useGovUpdateProjectStatus = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovProjectStatus;\n progressPercent?: number | null;\n delayReason?: string | null;\n }) => {\n const result = await govQuery<{ govUpdateProjectStatus: GovProject }>(\n `mutation GovUpdateProjectStatus($id: ID!, $status: GovProjectStatus!, $progressPercent: Int, $delayReason: String) {\n govUpdateProjectStatus(id: $id, status: $status, progressPercent: $progressPercent, delayReason: $delayReason) {\n ${PROJECT_FIELDS}\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateProjectStatus;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelProjects });\n qc.invalidateQueries({ queryKey: KEY.intelProject(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n qc.invalidateQueries({ queryKey: KEY.intelInsights });\n },\n });\n};\n\nexport const useGovDeleteProject = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteProject: boolean }>(\n `mutation GovDeleteProject($id: ID!) { govDeleteProject(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteProject;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelProjects });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovCreateProjectMilestone = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateProjectMilestoneInput) => {\n const result = await govQuery<{ govCreateProjectMilestone: GovProjectMilestone }>(\n `mutation GovCreateProjectMilestone($input: GovCreateProjectMilestoneInput!) {\n govCreateProjectMilestone(input: $input) { ${MILESTONE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateProjectMilestone;\n },\n onSuccess: (data) => qc.invalidateQueries({ queryKey: KEY.intelProject(data.projectId) }),\n });\n};\n\nexport const useGovUpdateProjectMilestone = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateProjectMilestoneInput }) => {\n const result = await govQuery<{ govUpdateProjectMilestone: GovProjectMilestone }>(\n `mutation GovUpdateProjectMilestone($id: ID!, $input: GovUpdateProjectMilestoneInput!) {\n govUpdateProjectMilestone(id: $id, input: $input) { ${MILESTONE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateProjectMilestone;\n },\n onSuccess: (data) => qc.invalidateQueries({ queryKey: KEY.intelProject(data.projectId) }),\n });\n};\n\nexport const useGovDeleteProjectMilestone = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; projectId?: string }) => {\n const result = await govQuery<{ govDeleteProjectMilestone: boolean }>(\n `mutation GovDeleteProjectMilestone($id: ID!) { govDeleteProjectMilestone(id: $id) }`,\n { id: vars.id },\n apiGatewayUrl\n );\n return result.govDeleteProjectMilestone;\n },\n onSuccess: (_data, vars) => {\n if (vars.projectId) qc.invalidateQueries({ queryKey: KEY.intelProject(vars.projectId) });\n else qc.invalidateQueries({ queryKey: KEY.intelProjects });\n },\n });\n};\n\n// ============================================================================\n// Indicator catalogue & values\n// ============================================================================\n\nexport const useGovIndicators = (\n filter: GovIndicatorFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelIndicators, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govIndicators: GovIndicatorConnection }>(\n `query GovIndicators($filter: GovIndicatorFilterInput, $pagination: PaginationInput) {\n govIndicators(filter: $filter, pagination: $pagination) {\n items { ${INDICATOR_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govIndicators;\n },\n });\n};\n\nexport const useGovIndicator = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelIndicator(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovIndicator>(\n `query GovIndicator($id: ID!) {\n govIndicator(id: $id) { ${INDICATOR_FIELDS} }\n }`,\n { id },\n 'govIndicator',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovIndicatorValues = (\n filter: GovIndicatorValueFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelIndicatorValues, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govIndicatorValues: GovIndicatorValueConnection }>(\n `query GovIndicatorValues($filter: GovIndicatorValueFilterInput, $pagination: PaginationInput) {\n govIndicatorValues(filter: $filter, pagination: $pagination) {\n items { ${INDICATOR_VALUE_FIELDS} indicator { ${INDICATOR_FIELDS} } }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govIndicatorValues;\n },\n });\n};\n\n/** An indicator's full published history for one jurisdiction, keyed by indicator CODE. */\nexport const useGovIndicatorSeries = (\n jurisdictionId: string | undefined,\n indicatorCode: string | undefined,\n range: { fromPeriod?: string; toPeriod?: string } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelIndicatorSeries, jurisdictionId ?? '', indicatorCode ?? '', range],\n enabled: Boolean(jurisdictionId) && Boolean(indicatorCode),\n queryFn: async () =>\n govNullableQuery<GovIndicatorSeries>(\n `query GovIndicatorSeries($jurisdictionId: ID!, $indicatorCode: String!, $fromPeriod: String, $toPeriod: String) {\n govIndicatorSeries(jurisdictionId: $jurisdictionId, indicatorCode: $indicatorCode, fromPeriod: $fromPeriod, toPeriod: $toPeriod) {\n ${INDICATOR_SERIES_FIELDS}\n }\n }`,\n {\n jurisdictionId,\n indicatorCode,\n fromPeriod: range.fromPeriod,\n toPeriod: range.toPeriod,\n },\n 'govIndicatorSeries',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateIndicator = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateIndicatorInput) => {\n const result = await govQuery<{ govCreateIndicator: GovIndicator }>(\n `mutation GovCreateIndicator($input: GovCreateIndicatorInput!) {\n govCreateIndicator(input: $input) { ${INDICATOR_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateIndicator;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicators });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovUpdateIndicator = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateIndicatorInput }) => {\n const result = await govQuery<{ govUpdateIndicator: GovIndicator }>(\n `mutation GovUpdateIndicator($id: ID!, $input: GovUpdateIndicatorInput!) {\n govUpdateIndicator(id: $id, input: $input) { ${INDICATOR_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateIndicator;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicators });\n qc.invalidateQueries({ queryKey: KEY.intelIndicator(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovDeleteIndicator = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteIndicator: boolean }>(\n `mutation GovDeleteIndicator($id: ID!) { govDeleteIndicator(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteIndicator;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicators });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\n/** Seed the country-neutral standard indicator catalogue. Additive and idempotent. */\nexport const useGovSeedIndicatorCatalog = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (domains?: GovIndicatorDomain[]) => {\n const result = await govQuery<{ govSeedIndicatorCatalog: GovIndicator[] }>(\n `mutation GovSeedIndicatorCatalog($domains: [GovIndicatorDomain!]) {\n govSeedIndicatorCatalog(domains: $domains) { ${INDICATOR_FIELDS} }\n }`,\n { domains },\n apiGatewayUrl\n );\n return result.govSeedIndicatorCatalog;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicators });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovRecordIndicatorValue = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovRecordIndicatorValueInput) => {\n const result = await govQuery<{ govRecordIndicatorValue: GovIndicatorValue }>(\n `mutation GovRecordIndicatorValue($input: GovRecordIndicatorValueInput!) {\n govRecordIndicatorValue(input: $input) { ${INDICATOR_VALUE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govRecordIndicatorValue;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\n/** Record many values in one transaction. Existing period rows are updated in place. */\nexport const useGovBulkRecordIndicatorValues = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovRecordIndicatorValueInput[]) => {\n const result = await govQuery<{ govBulkRecordIndicatorValues: GovIndicatorValue[] }>(\n `mutation GovBulkRecordIndicatorValues($input: [GovRecordIndicatorValueInput!]!) {\n govBulkRecordIndicatorValues(input: $input) { ${INDICATOR_VALUE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govBulkRecordIndicatorValues;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovUpdateIndicatorValue = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateIndicatorValueInput }) => {\n const result = await govQuery<{ govUpdateIndicatorValue: GovIndicatorValue }>(\n `mutation GovUpdateIndicatorValue($id: ID!, $input: GovUpdateIndicatorValueInput!) {\n govUpdateIndicatorValue(id: $id, input: $input) { ${INDICATOR_VALUE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateIndicatorValue;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\nexport const useGovDeleteIndicatorValue = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteIndicatorValue: boolean }>(\n `mutation GovDeleteIndicatorValue($id: ID!) { govDeleteIndicatorValue(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteIndicatorValue;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorValues });\n qc.invalidateQueries({ queryKey: KEY.intelIndicatorSeries });\n invalidateDerived(qc);\n },\n });\n};\n\n// ============================================================================\n// Scorecard, benchmark, insights & reused performance rollups\n// ============================================================================\n\nexport const useGovJurisdictionScorecard = (\n jurisdictionId: string | undefined,\n periodLabel?: string\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelScorecard, jurisdictionId ?? '', periodLabel ?? null],\n enabled: Boolean(jurisdictionId),\n queryFn: async () =>\n govNullableQuery<GovJurisdictionScorecard>(\n `query GovJurisdictionScorecard($jurisdictionId: ID!, $periodLabel: String) {\n govJurisdictionScorecard(jurisdictionId: $jurisdictionId, periodLabel: $periodLabel) {\n ${SCORECARD_FIELDS}\n }\n }`,\n { jurisdictionId, periodLabel },\n 'govJurisdictionScorecard',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovJurisdictionBenchmark = (\n jurisdictionId: string | undefined,\n indicatorCode: string | undefined,\n options: { scope?: GovBenchmarkScope; periodLabel?: string; peerIds?: string[] } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelBenchmark, jurisdictionId ?? '', indicatorCode ?? '', options],\n enabled: Boolean(jurisdictionId) && Boolean(indicatorCode),\n queryFn: async () =>\n govNullableQuery<GovBenchmarkResult>(\n `query GovJurisdictionBenchmark($jurisdictionId: ID!, $indicatorCode: String!, $scope: GovBenchmarkScope!, $periodLabel: String, $peerIds: [ID!]) {\n govJurisdictionBenchmark(jurisdictionId: $jurisdictionId, indicatorCode: $indicatorCode, scope: $scope, periodLabel: $periodLabel, peerIds: $peerIds) {\n ${BENCHMARK_FIELDS}\n }\n }`,\n {\n jurisdictionId,\n indicatorCode,\n scope: options.scope ?? 'SIBLINGS',\n periodLabel: options.periodLabel,\n peerIds: options.peerIds,\n },\n 'govJurisdictionBenchmark',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovJurisdictionInsights = (jurisdictionId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelInsights, jurisdictionId ?? ''],\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionInsights: GovJurisdictionInsight[] }>(\n `query GovJurisdictionInsights($jurisdictionId: ID!) {\n govJurisdictionInsights(jurisdictionId: $jurisdictionId) { ${INSIGHT_FIELDS} }\n }`,\n { jurisdictionId },\n apiGatewayUrl\n );\n return result.govJurisdictionInsights;\n },\n });\n};\n\n/** Service-delivery performance computed live from the catalogue + casework models. */\nexport const useGovJurisdictionServicePerformance = (\n jurisdictionId: string | undefined,\n range: { from?: string; to?: string } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelServicePerformance, jurisdictionId ?? '', range],\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionServicePerformance: GovServicePerformance }>(\n `query GovJurisdictionServicePerformance($jurisdictionId: ID!, $from: DateTime, $to: DateTime) {\n govJurisdictionServicePerformance(jurisdictionId: $jurisdictionId, from: $from, to: $to) {\n ${SERVICE_PERFORMANCE_FIELDS}\n }\n }`,\n { jurisdictionId, from: range.from, to: range.to },\n apiGatewayUrl\n );\n return result.govJurisdictionServicePerformance;\n },\n });\n};\n\n/** Citizen-issue insight computed live from the existing grievance model. */\nexport const useGovJurisdictionGrievanceInsights = (\n jurisdictionId: string | undefined,\n range: { from?: string; to?: string } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelGrievanceInsights, jurisdictionId ?? '', range],\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govJurisdictionGrievanceInsights: GovGrievanceInsights }>(\n `query GovJurisdictionGrievanceInsights($jurisdictionId: ID!, $from: DateTime, $to: DateTime) {\n govJurisdictionGrievanceInsights(jurisdictionId: $jurisdictionId, from: $from, to: $to) {\n ${GRIEVANCE_INSIGHTS_FIELDS}\n }\n }`,\n { jurisdictionId, from: range.from, to: range.to },\n apiGatewayUrl\n );\n return result.govJurisdictionGrievanceInsights;\n },\n });\n};\n\n// ============================================================================\n// Public asset registry\n// ============================================================================\n\nexport const useGovPublicAssets = (\n filter: GovPublicAssetFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelAssets, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govPublicAssets: GovPublicAssetConnection }>(\n `query GovPublicAssets($filter: GovPublicAssetFilterInput, $pagination: PaginationInput) {\n govPublicAssets(filter: $filter, pagination: $pagination) {\n items { ${PUBLIC_ASSET_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govPublicAssets;\n },\n });\n};\n\nexport const useGovPublicAsset = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelAsset(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovPublicAsset>(\n `query GovPublicAsset($id: ID!) {\n govPublicAsset(id: $id) { ${PUBLIC_ASSET_FIELDS} }\n }`,\n { id },\n 'govPublicAsset',\n apiGatewayUrl\n ),\n });\n};\n\n/** Asset counts by category — drives map legends and registry summaries. */\nexport const useGovPublicAssetSummary = (jurisdictionId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelAssetSummaryFor(jurisdictionId ?? ''),\n enabled: Boolean(jurisdictionId),\n queryFn: async () => {\n const result = await govQuery<{ govPublicAssetSummary: GovAssetCategoryCount[] }>(\n `query GovPublicAssetSummary($jurisdictionId: ID!) {\n govPublicAssetSummary(jurisdictionId: $jurisdictionId) { category count }\n }`,\n { jurisdictionId },\n apiGatewayUrl\n );\n return result.govPublicAssetSummary;\n },\n });\n};\n\nexport const useGovCreatePublicAsset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreatePublicAssetInput) => {\n const result = await govQuery<{ govCreatePublicAsset: GovPublicAsset }>(\n `mutation GovCreatePublicAsset($input: GovCreatePublicAssetInput!) {\n govCreatePublicAsset(input: $input) { ${PUBLIC_ASSET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreatePublicAsset;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelAssets });\n qc.invalidateQueries({ queryKey: KEY.intelAssetSummaryFor(data.jurisdictionId) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdatePublicAsset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdatePublicAssetInput }) => {\n const result = await govQuery<{ govUpdatePublicAsset: GovPublicAsset }>(\n `mutation GovUpdatePublicAsset($id: ID!, $input: GovUpdatePublicAssetInput!) {\n govUpdatePublicAsset(id: $id, input: $input) { ${PUBLIC_ASSET_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdatePublicAsset;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelAssets });\n qc.invalidateQueries({ queryKey: KEY.intelAsset(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelAssetSummaryFor(data.jurisdictionId) });\n },\n });\n};\n\nexport const useGovDeletePublicAsset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeletePublicAsset: boolean }>(\n `mutation GovDeletePublicAsset($id: ID!) { govDeletePublicAsset(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeletePublicAsset;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelAssets });\n qc.invalidateQueries({ queryKey: KEY.intelAssetSummary });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n// ============================================================================\n// Consultations & participation\n// ============================================================================\n\nexport const useGovConsultations = (\n filter: GovConsultationFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelConsultations, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govConsultations: GovConsultationConnection }>(\n `query GovConsultations($filter: GovConsultationFilterInput, $pagination: PaginationInput) {\n govConsultations(filter: $filter, pagination: $pagination) {\n items { ${CONSULTATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govConsultations;\n },\n });\n};\n\nexport const useGovConsultation = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelConsultation(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovConsultation>(\n `query GovConsultation($id: ID!) {\n govConsultation(id: $id) {\n ${CONSULTATION_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { id },\n 'govConsultation',\n apiGatewayUrl\n ),\n });\n};\n\n/** Aggregate, publishable results. Raw responses are never exposed. */\nexport const useGovConsultationResults = (consultationId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelConsultationResultsFor(consultationId ?? ''),\n enabled: Boolean(consultationId),\n queryFn: async () =>\n govNullableQuery<GovConsultationResults>(\n `query GovConsultationResults($consultationId: ID!) {\n govConsultationResults(consultationId: $consultationId) { ${CONSULTATION_RESULTS_FIELDS} }\n }`,\n { consultationId },\n 'govConsultationResults',\n apiGatewayUrl\n ),\n });\n};\n\n/**\n * The calling actor's own response, if any. Resolving to `null` is the normal\n * pre-submission state — not an error.\n */\nexport const useGovMyConsultationResponse = (consultationId: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelMyConsultationResponseFor(consultationId ?? ''),\n enabled: Boolean(consultationId),\n queryFn: async () =>\n govNullableQuery<GovConsultationResponse>(\n `query GovMyConsultationResponse($consultationId: ID!) {\n govMyConsultationResponse(consultationId: $consultationId) { ${CONSULTATION_RESPONSE_FIELDS} }\n }`,\n { consultationId },\n 'govMyConsultationResponse',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateConsultationInput) => {\n const result = await govQuery<{ govCreateConsultation: GovConsultation }>(\n `mutation GovCreateConsultation($input: GovCreateConsultationInput!) {\n govCreateConsultation(input: $input) { ${CONSULTATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateConsultation;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateConsultationInput }) => {\n const result = await govQuery<{ govUpdateConsultation: GovConsultation }>(\n `mutation GovUpdateConsultation($id: ID!, $input: GovUpdateConsultationInput!) {\n govUpdateConsultation(id: $id, input: $input) { ${CONSULTATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateConsultation;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.id) });\n },\n });\n};\n\nexport const useGovOpenConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govOpenConsultation: GovConsultation }>(\n `mutation GovOpenConsultation($id: ID!) {\n govOpenConsultation(id: $id) { ${CONSULTATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govOpenConsultation;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovCloseConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govCloseConsultation: GovConsultation }>(\n `mutation GovCloseConsultation($id: ID!) {\n govCloseConsultation(id: $id) { ${CONSULTATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govCloseConsultation;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Compute and publish the aggregate result set. Raw responses are never published. */\nexport const useGovPublishConsultationResults = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govPublishConsultationResults: GovConsultation }>(\n `mutation GovPublishConsultationResults($id: ID!) {\n govPublishConsultationResults(id: $id) { ${CONSULTATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPublishConsultationResults;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelConsultationResultsFor(data.id) });\n },\n });\n};\n\nexport const useGovDeleteConsultation = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteConsultation: boolean }>(\n `mutation GovDeleteConsultation($id: ID!) { govDeleteConsultation(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteConsultation;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Submit the calling actor's response. One response per actor per consultation. */\nexport const useGovSubmitConsultationResponse = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovSubmitConsultationResponseInput) => {\n const result = await govQuery<{ govSubmitConsultationResponse: GovConsultationResponse }>(\n `mutation GovSubmitConsultationResponse($input: GovSubmitConsultationResponseInput!) {\n govSubmitConsultationResponse(input: $input) { ${CONSULTATION_RESPONSE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govSubmitConsultationResponse;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelConsultations });\n qc.invalidateQueries({ queryKey: KEY.intelConsultation(data.consultationId) });\n qc.invalidateQueries({\n queryKey: KEY.intelMyConsultationResponseFor(data.consultationId),\n });\n qc.invalidateQueries({ queryKey: KEY.intelConsultationResultsFor(data.consultationId) });\n },\n });\n};\n\n// ============================================================================\n// Open data catalogue\n// ============================================================================\n\nexport const useGovDatasets = (\n filter: GovDatasetFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelDatasets, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govDatasets: GovDatasetConnection }>(\n `query GovDatasets($filter: GovDatasetFilterInput, $pagination: PaginationInput) {\n govDatasets(filter: $filter, pagination: $pagination) {\n items { ${DATASET_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govDatasets;\n },\n });\n};\n\nexport const useGovDataset = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelDataset(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovDataset>(\n `query GovDataset($id: ID!) {\n govDataset(id: $id) {\n ${DATASET_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { id },\n 'govDataset',\n apiGatewayUrl\n ),\n });\n};\n\nexport const useGovCreateDataset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateDatasetInput) => {\n const result = await govQuery<{ govCreateDataset: GovDataset }>(\n `mutation GovCreateDataset($input: GovCreateDatasetInput!) {\n govCreateDataset(input: $input) { ${DATASET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateDataset;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovUpdateDataset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateDatasetInput }) => {\n const result = await govQuery<{ govUpdateDataset: GovDataset }>(\n `mutation GovUpdateDataset($id: ID!, $input: GovUpdateDatasetInput!) {\n govUpdateDataset(id: $id, input: $input) { ${DATASET_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateDataset;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelDataset(data.id) });\n },\n });\n};\n\nexport const useGovPublishDataset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govPublishDataset: GovDataset }>(\n `mutation GovPublishDataset($id: ID!) {\n govPublishDataset(id: $id) { ${DATASET_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPublishDataset;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelDataset(data.id) });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\nexport const useGovDeleteDataset = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteDataset: boolean }>(\n `mutation GovDeleteDataset($id: ID!) { govDeleteDataset(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteDataset;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelOverview });\n },\n });\n};\n\n/** Increment a dataset's download counter. */\nexport const useGovRecordDatasetDownload = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govRecordDatasetDownload: GovDataset }>(\n `mutation GovRecordDatasetDownload($id: ID!) {\n govRecordDatasetDownload(id: $id) { ${DATASET_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govRecordDatasetDownload;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelDatasets });\n qc.invalidateQueries({ queryKey: KEY.intelDataset(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Following (self-scoped)\n// ============================================================================\n\nexport const useGovMyFollowedJurisdictions = (pagination?: PaginationInput) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelMyFollowed, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govMyFollowedJurisdictions: GovJurisdictionConnection }>(\n `query GovMyFollowedJurisdictions($pagination: PaginationInput) {\n govMyFollowedJurisdictions(pagination: $pagination) {\n items { ${JURISDICTION_FIELDS} adminLevel { ${ADMIN_LEVEL_FIELDS} } }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govMyFollowedJurisdictions;\n },\n });\n};\n\nexport const useGovFollowJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n jurisdictionId: string;\n topics?: string[] | null;\n channels?: string[] | null;\n }) => {\n const result = await govQuery<{ govFollowJurisdiction: GovJurisdictionFollow }>(\n `mutation GovFollowJurisdiction($jurisdictionId: ID!, $topics: [String!], $channels: [String!]) {\n govFollowJurisdiction(jurisdictionId: $jurisdictionId, topics: $topics, channels: $channels) {\n ${FOLLOW_FIELDS}\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govFollowJurisdiction;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelMyFollowed });\n qc.invalidateQueries({ queryKey: KEY.intelOverviewFor(data.jurisdictionId) });\n },\n });\n};\n\nexport const useGovUnfollowJurisdiction = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (jurisdictionId: string) => {\n const result = await govQuery<{ govUnfollowJurisdiction: boolean }>(\n `mutation GovUnfollowJurisdiction($jurisdictionId: ID!) {\n govUnfollowJurisdiction(jurisdictionId: $jurisdictionId)\n }`,\n { jurisdictionId },\n apiGatewayUrl\n );\n return result.govUnfollowJurisdiction;\n },\n onSuccess: (_data, jurisdictionId) => {\n qc.invalidateQueries({ queryKey: KEY.intelMyFollowed });\n qc.invalidateQueries({ queryKey: KEY.intelOverviewFor(jurisdictionId) });\n },\n });\n};\n\n// ============================================================================\n// Data-change proposals (citizen corrections)\n// ============================================================================\n\nexport const useGovDataChangeProposals = (\n filter: GovDataChangeProposalFilterInput = {},\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelProposals, filter, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govDataChangeProposals: GovDataChangeProposalConnection }>(\n `query GovDataChangeProposals($filter: GovDataChangeProposalFilterInput, $pagination: PaginationInput) {\n govDataChangeProposals(filter: $filter, pagination: $pagination) {\n items { ${PROPOSAL_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { filter, pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govDataChangeProposals;\n },\n });\n};\n\nexport const useGovDataChangeProposal = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.intelProposal(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () =>\n govNullableQuery<GovDataChangeProposal>(\n `query GovDataChangeProposal($id: ID!) {\n govDataChangeProposal(id: $id) {\n ${PROPOSAL_FIELDS}\n jurisdiction { ${JURISDICTION_REF_FIELDS} }\n }\n }`,\n { id },\n 'govDataChangeProposal',\n apiGatewayUrl\n ),\n });\n};\n\n/** Corrections the calling actor has submitted. */\nexport const useGovMyDataChangeProposals = (pagination?: PaginationInput) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.intelMyProposals, pagination ?? null],\n queryFn: async () => {\n const result = await govQuery<{ govMyDataChangeProposals: GovDataChangeProposalConnection }>(\n `query GovMyDataChangeProposals($pagination: PaginationInput) {\n govMyDataChangeProposals(pagination: $pagination) {\n items { ${PROPOSAL_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govMyDataChangeProposals;\n },\n });\n};\n\nexport const useGovSubmitDataChangeProposal = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovSubmitDataChangeProposalInput) => {\n const result = await govQuery<{ govSubmitDataChangeProposal: GovDataChangeProposal }>(\n `mutation GovSubmitDataChangeProposal($input: GovSubmitDataChangeProposalInput!) {\n govSubmitDataChangeProposal(input: $input) { ${PROPOSAL_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govSubmitDataChangeProposal;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.intelProposals });\n qc.invalidateQueries({ queryKey: KEY.intelMyProposals });\n },\n });\n};\n\nexport const useGovWithdrawDataChangeProposal = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govWithdrawDataChangeProposal: GovDataChangeProposal }>(\n `mutation GovWithdrawDataChangeProposal($id: ID!) {\n govWithdrawDataChangeProposal(id: $id) { ${PROPOSAL_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govWithdrawDataChangeProposal;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelProposals });\n qc.invalidateQueries({ queryKey: KEY.intelMyProposals });\n qc.invalidateQueries({ queryKey: KEY.intelProposal(data.id) });\n },\n });\n};\n\n/**\n * Record a review decision. ACCEPTED records the accepted correction and stamps\n * `appliedAt`; it never silently mutates the target record.\n */\nexport const useGovReviewDataChangeProposal = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n decision: GovProposalStatus;\n reviewNote?: string | null;\n }) => {\n const result = await govQuery<{ govReviewDataChangeProposal: GovDataChangeProposal }>(\n `mutation GovReviewDataChangeProposal($id: ID!, $decision: GovProposalStatus!, $reviewNote: String) {\n govReviewDataChangeProposal(id: $id, decision: $decision, reviewNote: $reviewNote) {\n ${PROPOSAL_FIELDS}\n }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govReviewDataChangeProposal;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.intelProposals });\n qc.invalidateQueries({ queryKey: KEY.intelMyProposals });\n qc.invalidateQueries({ queryKey: KEY.intelProposal(data.id) });\n },\n });\n};\n"],"mappings":";;;;;AAiIA,IAAM,IAAO,CAAC,iBAAiB,OAAO,GAEhC,IAAM;CACV,kBAAkB,CAAC,GAAG,GAAM,cAAc;CAC1C,wBAAwB;EAAC;EAAiB;EAAS;CAAqB;CACxE,kBAAkB,MAAe;EAAC,GAAG;EAAM;EAAe;CAAE;CAC5D,oBAAoB,CAAC,GAAG,GAAM,eAAe;CAC7C,oBAAoB,MAAe;EAAC,GAAG;EAAM;EAAgB;CAAE;CAC/D,0BAA0B,MAAiB;EAAC,GAAG;EAAM;EAAwB;CAAI;CACjF,uBAAuB,CAAC,GAAG,GAAM,mBAAmB;CACpD,e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