@burdenoff/microfe-govcitizenhub 2026.704.2 → 2026.705.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"useFiles.js","names":[],"sources":["../../../src/govcitizenhub/hooks/useFiles.ts"],"sourcesContent":["/**\n * File hooks — documents & permit PDFs via wspace-files-svc (NO duplication).\n * @module govcitizenhub/hooks\n *\n * GovCitizenHub never stores blobs. Documents/permits reference files owned by\n * wspace-files-svc by id. Upload uses the SAME proven `graphqlFetch` transport\n * as every other read/write in this MFE (the shell's workspace gateway + token),\n * driving the wspace-files 3-step presigned flow directly:\n * ensureFolderByPath -> initiateUpload -> HTTP PUT -> completeUpload\n * Display resolves a file id to a presigned URL via `getFileDownloadUrl`.\n *\n * NOTE: we deliberately do NOT use the Apollo-based `uploadBlobToFiles` /\n * `getWorkspaceClient()` helper here — this shell wires its data plane through\n * `graphqlFetch`, not a global Apollo client, so `getWorkspaceClient()` returns\n * an un-networked client and the upload silently no-ops. `graphqlFetch` is the\n * transport the whole MFE already uses successfully.\n */\n\nimport { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useGovCitizenHub } from '../context';\n\n/** One year — permit PDFs / document scans are long-lived references. */\nconst DOWNLOAD_URL_TTL_SECONDS = 31_536_000;\n\nexport const FILE_FOLDERS = {\n documents: '/GovCitizenHub/Documents',\n permits: '/GovCitizenHub/Permits',\n grievances: '/GovCitizenHub/Grievances',\n} as const;\n\nexport interface UploadedFile {\n id: string;\n url: string;\n name: string;\n}\n\n/** Thin wrapper over the workspace gateway using the MFE's proven transport. */\nasync function filesFetch<TData>(query: string, variables: Record<string, unknown>): Promise<TData> {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n query,\n variables,\n workspaceToken: true,\n });\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'Files request failed');\n }\n if (!response.data) {\n throw new Error('Files response did not include data');\n }\n return response.data;\n}\n\nconst ENSURE_FOLDER = `\n mutation GovEnsureFolder($path: String!) {\n ensureFolderByPath(path: $path) { id }\n }\n`;\n\nconst INITIATE_UPLOAD = `\n mutation GovInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id }\n }\n }\n`;\n\nconst COMPLETE_UPLOAD = `\n mutation GovCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) {\n fileId\n file { id name }\n }\n }\n`;\n\nconst GET_FILE_DOWNLOAD_URL = `\n query GovGetFileDownloadUrl($id: ID!, $expiresIn: Int) {\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n }\n`;\n\nfunction fileExtension(name: string, mimeType: string): string {\n const dot = name.lastIndexOf('.');\n if (dot > -1 && dot < name.length - 1) return name.slice(dot + 1).toLowerCase();\n const fromMime = mimeType.split('/')[1];\n return (fromMime ?? 'bin').toLowerCase();\n}\n\n/**\n * Upload a file to wspace-files-svc and return its id + a presigned URL. The\n * caller persists the id (e.g. via `govAddDocument({ fileId })`); the URL is used\n * for an immediate preview / download link.\n */\nexport async function uploadFileToFiles(file: File, folderPath: string): Promise<UploadedFile> {\n // 1. Resolve (or create) the destination folder — File.folderId is a real FK.\n const folder = await filesFetch<{ ensureFolderByPath?: { id: string } | null }>(ENSURE_FOLDER, {\n path: folderPath,\n });\n const folderId = folder.ensureFolderByPath?.id;\n if (!folderId) {\n throw new Error('Could not resolve the upload folder.');\n }\n\n const mimeType = file.type || 'application/octet-stream';\n const fileSize = file.size;\n\n // 2. Open a presigned upload session.\n const initiated = await filesFetch<{\n initiateUpload?: { uploadUrl?: string | null; session: { id: string } } | null;\n }>(INITIATE_UPLOAD, {\n input: {\n fileName: file.name,\n extension: fileExtension(file.name, mimeType),\n fileSize,\n mimeType,\n folderId,\n },\n });\n const uploadUrl = initiated.initiateUpload?.uploadUrl;\n const sessionId = initiated.initiateUpload?.session.id;\n if (!uploadUrl || !sessionId) {\n throw new Error('The files service did not return an upload URL.');\n }\n\n // 3. PUT the bytes straight to storage using the presigned URL. Content-Type\n // must match what was signed at initiateUpload.\n const putResponse = await fetch(uploadUrl, {\n method: 'PUT',\n body: file,\n headers: { 'Content-Type': mimeType },\n });\n if (!putResponse.ok) {\n throw new Error(`Upload to storage failed (${putResponse.status}).`);\n }\n\n // 4. Finalize — creates the File record. fileSize must match initiateUpload.\n const completed = await filesFetch<{\n completeUpload?: { fileId: string; file: { id: string; name: string } } | null;\n }>(COMPLETE_UPLOAD, {\n input: { sessionId, fileSize, folderId },\n });\n const fileRecord = completed.completeUpload?.file;\n if (!fileRecord?.id) {\n throw new Error('The upload could not be finalized.');\n }\n\n // 5. Resolve a presigned URL for immediate preview/download (best-effort).\n let url = '';\n try {\n const urlData = await filesFetch<{ getFileDownloadUrl?: string | null }>(GET_FILE_DOWNLOAD_URL, {\n id: fileRecord.id,\n expiresIn: DOWNLOAD_URL_TTL_SECONDS,\n });\n url = urlData.getFileDownloadUrl ?? '';\n } catch {\n url = '';\n }\n\n return { id: fileRecord.id, url, name: fileRecord.name };\n}\n\n/** Resolve a wspace-files-svc file id to a presigned download URL for display. */\nexport function useFileUrl(fileId?: string | null) {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'file-url', fileId ?? ''],\n enabled: Boolean(fileId),\n staleTime: 30 * 60 * 1000,\n retry: 1,\n queryFn: async () => {\n const response = await graphqlFetch<{ getFileDownloadUrl: string | null }>({\n gateway: 'workspace',\n baseUrl: apiGatewayUrl,\n workspaceToken: true,\n query: GET_FILE_DOWNLOAD_URL,\n variables: { id: fileId, expiresIn: DOWNLOAD_URL_TTL_SECONDS },\n });\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'Could not resolve file URL');\n }\n return response.data?.getFileDownloadUrl ?? null;\n },\n });\n}\n"],"mappings":";;;;AAwBA,IAAM,IAA2B,SAEpB,IAAe;CAC1B,WAAW;CACX,SAA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;EAAU,EACzC,CAAC,EAC2B,gBAAgB;AAC7C,KAAI,CAAC,GAAY,GACf,OAAU,MAAM,qCAAqC;CAIvD,IAAI,IAAM;AACV,KAAI;AAKF,OAJgB,MAAM,EAAmD,GAAuB;GAC9F,IAAI,EAAW;GACf,WAAW;GACZ,CAAC,EACY,sBAAsB;SAC9B;AACN,MAAM;;AAGR,QAAO;EAAE,IAAI,EAAW;EAAI;EAAK,MAAM,EAAW;EAAM"}
1
+ {"version":3,"file":"useFiles.js","names":[],"sources":["../../../src/govcitizenhub/hooks/useFiles.ts"],"sourcesContent":["/**\n * File hooks — documents & permit PDFs via wspace-files-svc (NO duplication).\n * @module govcitizenhub/hooks\n *\n * GovCitizenHub never stores blobs. Documents/permits reference files owned by\n * wspace-files-svc by id. Upload uses the SAME proven `graphqlFetch` transport\n * as every other read/write in this MFE (the shell's workspace gateway + token),\n * driving the wspace-files 3-step presigned flow directly:\n * ensureFolderByPath -> initiateUpload -> HTTP PUT -> completeUpload\n * Display resolves a file id to a presigned URL via `getFileDownloadUrl`.\n *\n * NOTE: we deliberately do NOT use the Apollo-based `uploadBlobToFiles` /\n * `getWorkspaceClient()` helper here — this shell wires its data plane through\n * `graphqlFetch`, not a global Apollo client, so `getWorkspaceClient()` returns\n * an un-networked client and the upload silently no-ops. `graphqlFetch` is the\n * transport the whole MFE already uses successfully.\n */\n\nimport { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useGovCitizenHub } from '../context';\n\n/** One year — permit PDFs / document scans are long-lived references. */\nconst DOWNLOAD_URL_TTL_SECONDS = 31_536_000;\n\nexport const FILE_FOLDERS = {\n documents: '/GovCitizenHub/Documents',\n permits: '/GovCitizenHub/Permits',\n grievances: '/GovCitizenHub/Grievances',\n} as const;\n\nexport interface UploadedFile {\n id: string;\n url: string;\n name: string;\n}\n\n/** Thin wrapper over the workspace gateway using the MFE's proven transport. */\nasync function filesFetch<TData>(\n query: string,\n variables: Record<string, unknown>\n): Promise<TData> {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n query,\n variables,\n workspaceToken: true,\n });\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'Files request failed');\n }\n if (!response.data) {\n throw new Error('Files response did not include data');\n }\n return response.data;\n}\n\nconst ENSURE_FOLDER = `\n mutation GovEnsureFolder($path: String!) {\n ensureFolderByPath(path: $path) { id }\n }\n`;\n\nconst INITIATE_UPLOAD = `\n mutation GovInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id }\n }\n }\n`;\n\nconst COMPLETE_UPLOAD = `\n mutation GovCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) {\n fileId\n file { id name }\n }\n }\n`;\n\nconst GET_FILE_DOWNLOAD_URL = `\n query GovGetFileDownloadUrl($id: ID!, $expiresIn: Int) {\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n }\n`;\n\nfunction fileExtension(name: string, mimeType: string): string {\n const dot = name.lastIndexOf('.');\n if (dot > -1 && dot < name.length - 1) return name.slice(dot + 1).toLowerCase();\n const fromMime = mimeType.split('/')[1];\n return (fromMime ?? 'bin').toLowerCase();\n}\n\n/**\n * Upload a file to wspace-files-svc and return its id + a presigned URL. The\n * caller persists the id (e.g. via `govAddDocument({ fileId })`); the URL is used\n * for an immediate preview / download link.\n */\nexport async function uploadFileToFiles(file: File, folderPath: string): Promise<UploadedFile> {\n // 1. Resolve (or create) the destination folder — File.folderId is a real FK.\n const folder = await filesFetch<{ ensureFolderByPath?: { id: string } | null }>(ENSURE_FOLDER, {\n path: folderPath,\n });\n const folderId = folder.ensureFolderByPath?.id;\n if (!folderId) {\n throw new Error('Could not resolve the upload folder.');\n }\n\n const mimeType = file.type || 'application/octet-stream';\n const fileSize = file.size;\n\n // 2. Open a presigned upload session.\n const initiated = await filesFetch<{\n initiateUpload?: { uploadUrl?: string | null; session: { id: string } } | null;\n }>(INITIATE_UPLOAD, {\n input: {\n fileName: file.name,\n extension: fileExtension(file.name, mimeType),\n fileSize,\n mimeType,\n folderId,\n },\n });\n const uploadUrl = initiated.initiateUpload?.uploadUrl;\n const sessionId = initiated.initiateUpload?.session.id;\n if (!uploadUrl || !sessionId) {\n throw new Error('The files service did not return an upload URL.');\n }\n\n // 3. PUT the bytes straight to storage using the presigned URL. Content-Type\n // must match what was signed at initiateUpload.\n const putResponse = await fetch(uploadUrl, {\n method: 'PUT',\n body: file,\n headers: { 'Content-Type': mimeType },\n });\n if (!putResponse.ok) {\n throw new Error(`Upload to storage failed (${putResponse.status}).`);\n }\n\n // 4. Finalize — creates the File record. fileSize must match initiateUpload.\n const completed = await filesFetch<{\n completeUpload?: { fileId: string; file: { id: string; name: string } } | null;\n }>(COMPLETE_UPLOAD, {\n input: { sessionId, fileSize, folderId },\n });\n const fileRecord = completed.completeUpload?.file;\n if (!fileRecord?.id) {\n throw new Error('The upload could not be finalized.');\n }\n\n // 5. Resolve a presigned URL for immediate preview/download (best-effort).\n let url = '';\n try {\n const urlData = await filesFetch<{ getFileDownloadUrl?: string | null }>(\n GET_FILE_DOWNLOAD_URL,\n {\n id: fileRecord.id,\n expiresIn: DOWNLOAD_URL_TTL_SECONDS,\n }\n );\n url = urlData.getFileDownloadUrl ?? '';\n } catch {\n url = '';\n }\n\n return { id: fileRecord.id, url, name: fileRecord.name };\n}\n\n/** Resolve a wspace-files-svc file id to a presigned download URL for display. */\nexport function useFileUrl(fileId?: string | null) {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'file-url', fileId ?? ''],\n enabled: Boolean(fileId),\n staleTime: 30 * 60 * 1000,\n retry: 1,\n queryFn: async () => {\n const response = await graphqlFetch<{ getFileDownloadUrl: string | null }>({\n gateway: 'workspace',\n baseUrl: apiGatewayUrl,\n workspaceToken: true,\n query: GET_FILE_DOWNLOAD_URL,\n variables: { id: fileId, expiresIn: DOWNLOAD_URL_TTL_SECONDS },\n });\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'Could not resolve file URL');\n }\n return response.data?.getFileDownloadUrl ?? null;\n },\n });\n}\n"],"mappings":";;;;AAwBA,IAAM,IAA2B,SAEpB,IAAe;CAC1B,WAAW;CACX,SAAS;CACT,YAAY;CACb;AASD,eAAe,EACb,GACA,GACgB;CAChB,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA,gBAAgB;EACjB,CAAC;AACF,KAAI,EAAS,QAAQ,OACnB,OAAU,MAAM,EAAS,OAAO,IAAI,WAAW,uBAAuB;AAExE,KAAI,CAAC,EAAS,KACZ,OAAU,MAAM,sCAAsC;AAExD,QAAO,EAAS;;AAGlB,IAAM,IAAgB,qGAMhB,IAAkB,4JASlB,IAAkB,2JASlB,IAAwB;AAM9B,SAAS,EAAc,GAAc,GAA0B;CAC7D,IAAM,IAAM,EAAK,YAAY,IAAI;AAGjC,QAFI,IAAM,MAAM,IAAM,EAAK,SAAS,IAAU,EAAK,MAAM,IAAM,EAAE,CAAC,aAAa,IAC9D,EAAS,MAAM,IAAI,CAAC,MACjB,OAAO,aAAa;;AAQ1C,eAAsB,EAAkB,GAAY,GAA2C;CAK7F,IAAM,KAHS,MAAM,EAA2D,GAAe,EAC7F,MAAM,GACP,CAAC,EACsB,oBAAoB;AAC5C,KAAI,CAAC,EACH,OAAU,MAAM,uCAAuC;CAGzD,IAAM,IAAW,EAAK,QAAQ,4BACxB,IAAW,EAAK,MAGhB,IAAY,MAAM,EAErB,GAAiB,EAClB,OAAO;EACL,UAAU,EAAK;EACf,WAAW,EAAc,EAAK,MAAM,EAAS;EAC7C;EACA;EACA;EACD,EACF,CAAC,EACI,IAAY,EAAU,gBAAgB,WACtC,IAAY,EAAU,gBAAgB,QAAQ;AACpD,KAAI,CAAC,KAAa,CAAC,EACjB,OAAU,MAAM,kDAAkD;CAKpE,IAAM,IAAc,MAAM,MAAM,GAAW;EACzC,QAAQ;EACR,MAAM;EACN,SAAS,EAAE,gBAAgB,GAAU;EACtC,CAAC;AACF,KAAI,CAAC,EAAY,GACf,OAAU,MAAM,6BAA6B,EAAY,OAAO,IAAI;CAStE,IAAM,KALY,MAAM,EAErB,GAAiB,EAClB,OAAO;EAAE;EAAW;EAAU;EAAU,EACzC,CAAC,EAC2B,gBAAgB;AAC7C,KAAI,CAAC,GAAY,GACf,OAAU,MAAM,qCAAqC;CAIvD,IAAI,IAAM;AACV,KAAI;AAQF,OAPgB,MAAM,EACpB,GACA;GACE,IAAI,EAAW;GACf,WAAW;GACZ,CACF,EACa,sBAAsB;SAC9B;AACN,MAAM;;AAGR,QAAO;EAAE,IAAI,EAAW;EAAI;EAAK,MAAM,EAAW;EAAM"}
@@ -18,6 +18,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
18
18
  if (!s.data) throw Error("GraphQL response did not include data");
19
19
  return s.data;
20
20
  }, c = {
21
+ dashboard: ["govcitizenhub", "dashboard-summary"],
21
22
  agencies: ["govcitizenhub", "agencies"],
22
23
  agency: (e) => [
23
24
  "govcitizenhub",
@@ -52,7 +53,13 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
52
53
  }, l = { limit: 50 }, u = (e) => {
53
54
  let t = e ?? l, n = { limit: t.limit ?? l.limit };
54
55
  return t.offset != null && (n.offset = t.offset), t.cursor != null && (n.cursor = t.cursor), n;
55
- }, d = "\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n", f = "\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n", p = "\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n", m = "\n id workspaceId applicationId authorId body type createdAt updatedAt\n", h = "\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n", g = "\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n", _ = "\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n", v = "\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n", y = (t = {}) => {
56
+ }, d = "\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n", f = "\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n", p = "\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n", m = "\n id workspaceId applicationId authorId body type createdAt updatedAt\n", h = "\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n", g = "\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n", _ = "\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n", v = "\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n", y = () => {
57
+ let { apiGatewayUrl: t } = e();
58
+ return r({
59
+ queryKey: c.dashboard,
60
+ queryFn: async () => (await s("query GovDashboardSummary {\n govDashboardSummary {\n applicationsTotal\n applicationsByStatus { status count }\n pendingPayments\n pendingPaymentsAmount\n openGrievances\n activePermits\n publishedServices\n activeAgencies\n }\n }", {}, t)).govDashboardSummary
61
+ });
62
+ }, b = (t = {}) => {
56
63
  let { apiGatewayUrl: n } = e();
57
64
  return r({
58
65
  queryKey: [...c.agencies, t],
@@ -63,7 +70,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
63
70
  pagination: u(t.pagination ?? { limit: 100 })
64
71
  }, n)).govListAgencies
65
72
  });
66
- }, b = () => {
73
+ }, x = () => {
67
74
  let { apiGatewayUrl: t } = e(), r = i();
68
75
  return n({
69
76
  mutationFn: async (e) => (await s(`mutation GovCreateAgency($input: GovCreateAgencyInput!) {
@@ -71,7 +78,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
71
78
  }`, { input: e }, t)).govCreateAgency,
72
79
  onSuccess: () => r.invalidateQueries({ queryKey: c.agencies })
73
80
  });
74
- }, x = () => {
81
+ }, S = () => {
75
82
  let { apiGatewayUrl: t } = e(), r = i();
76
83
  return n({
77
84
  mutationFn: async (e) => (await s(`mutation GovUpdateAgency($id: ID!, $input: GovUpdateAgencyInput!) {
@@ -81,13 +88,13 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
81
88
  r.invalidateQueries({ queryKey: c.agencies }), r.invalidateQueries({ queryKey: c.agency(e.id) });
82
89
  }
83
90
  });
84
- }, S = () => {
91
+ }, C = () => {
85
92
  let { apiGatewayUrl: t } = e(), r = i();
86
93
  return n({
87
94
  mutationFn: async (e) => (await s("mutation GovArchiveAgency($id: ID!) { govArchiveAgency(id: $id) }", { id: e }, t)).govArchiveAgency,
88
95
  onSuccess: () => r.invalidateQueries({ queryKey: c.agencies })
89
96
  });
90
- }, C = (t = {}) => {
97
+ }, w = (t = {}) => {
91
98
  let { apiGatewayUrl: n } = e();
92
99
  return r({
93
100
  queryKey: [...c.services, t],
@@ -103,7 +110,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
103
110
  pagination: u(t.pagination)
104
111
  }, n)).govListServices
105
112
  });
106
- }, w = (t) => {
113
+ }, T = (t) => {
107
114
  let { apiGatewayUrl: n } = e();
108
115
  return r({
109
116
  queryKey: c.service(t ?? ""),
@@ -112,7 +119,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
112
119
  govService(id: $id) { ${f} agency { ${d} } }
113
120
  }`, { id: t }, n)).govService
114
121
  });
115
- }, T = () => {
122
+ }, E = () => {
116
123
  let { apiGatewayUrl: t } = e(), r = i();
117
124
  return n({
118
125
  mutationFn: async (e) => (await s(`mutation GovCreateService($input: GovCreateServiceInput!) {
@@ -120,7 +127,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
120
127
  }`, { input: e }, t)).govCreateService,
121
128
  onSuccess: () => r.invalidateQueries({ queryKey: c.services })
122
129
  });
123
- }, E = () => {
130
+ }, D = () => {
124
131
  let { apiGatewayUrl: t } = e(), r = i();
125
132
  return n({
126
133
  mutationFn: async (e) => (await s(`mutation GovUpdateService($id: ID!, $input: GovUpdateServiceInput!) {
@@ -130,7 +137,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
130
137
  r.invalidateQueries({ queryKey: c.services }), r.invalidateQueries({ queryKey: c.service(e.id) });
131
138
  }
132
139
  });
133
- }, D = () => {
140
+ }, O = () => {
134
141
  let { apiGatewayUrl: t } = e(), r = i();
135
142
  return n({
136
143
  mutationFn: async (e) => (await s(`mutation GovTransitionService($id: ID!, $status: GovServiceStatus!) {
@@ -140,7 +147,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
140
147
  r.invalidateQueries({ queryKey: c.services }), r.invalidateQueries({ queryKey: c.service(e.id) });
141
148
  }
142
149
  });
143
- }, O = (t = {}) => {
150
+ }, k = (t = {}) => {
144
151
  let { apiGatewayUrl: n } = e();
145
152
  return r({
146
153
  queryKey: [...c.applications, t],
@@ -157,7 +164,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
157
164
  pagination: u(t.pagination)
158
165
  }, n)).govListApplications
159
166
  });
160
- }, k = (t) => {
167
+ }, A = (t) => {
161
168
  let { apiGatewayUrl: n } = e();
162
169
  return r({
163
170
  queryKey: c.application(t ?? ""),
@@ -172,7 +179,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
172
179
  }
173
180
  }`, { id: t }, n)).govApplication
174
181
  });
175
- }, A = () => {
182
+ }, j = () => {
176
183
  let { apiGatewayUrl: t } = e(), r = i();
177
184
  return n({
178
185
  mutationFn: async (e) => (await s(`mutation GovCreateApplication($input: GovCreateApplicationInput!) {
@@ -180,7 +187,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
180
187
  }`, { input: e }, t)).govCreateApplication,
181
188
  onSuccess: () => r.invalidateQueries({ queryKey: c.applications })
182
189
  });
183
- }, j = () => {
190
+ }, M = () => {
184
191
  let { apiGatewayUrl: t } = e(), r = i();
185
192
  return n({
186
193
  mutationFn: async (e) => (await s(`mutation GovUpdateApplication($id: ID!, $input: GovUpdateApplicationInput!) {
@@ -190,7 +197,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
190
197
  r.invalidateQueries({ queryKey: c.applications }), r.invalidateQueries({ queryKey: c.application(e.id) });
191
198
  }
192
199
  });
193
- }, M = () => {
200
+ }, N = () => {
194
201
  let { apiGatewayUrl: t } = e(), r = i();
195
202
  return n({
196
203
  mutationFn: async (e) => (await s(`mutation GovSubmitApplication($id: ID!) {
@@ -200,7 +207,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
200
207
  r.invalidateQueries({ queryKey: c.applications }), r.invalidateQueries({ queryKey: c.application(e.id) });
201
208
  }
202
209
  });
203
- }, N = () => {
210
+ }, P = () => {
204
211
  let { apiGatewayUrl: t } = e(), r = i();
205
212
  return n({
206
213
  mutationFn: async (e) => (await s(`mutation GovTransitionApplication($id: ID!, $status: GovApplicationStatus!, $reason: String) {
@@ -210,7 +217,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
210
217
  r.invalidateQueries({ queryKey: c.applications }), r.invalidateQueries({ queryKey: c.application(e.id) });
211
218
  }
212
219
  });
213
- }, P = () => {
220
+ }, F = () => {
214
221
  let { apiGatewayUrl: t } = e(), r = i();
215
222
  return n({
216
223
  mutationFn: async (e) => (await s(`mutation GovAddDocument($input: GovAddDocumentInput!) {
@@ -220,7 +227,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
220
227
  r.invalidateQueries({ queryKey: c.application(e.applicationId) }), r.invalidateQueries({ queryKey: c.applications });
221
228
  }
222
229
  });
223
- }, F = () => {
230
+ }, I = () => {
224
231
  let { apiGatewayUrl: t } = e(), r = i();
225
232
  return n({
226
233
  mutationFn: async (e) => (await s(`mutation GovReviewDocument($id: ID!, $status: GovDocumentStatus!, $rejectionReason: String) {
@@ -234,7 +241,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
234
241
  r.invalidateQueries({ queryKey: c.application(e.applicationId) });
235
242
  }
236
243
  });
237
- }, I = () => {
244
+ }, L = () => {
238
245
  let { apiGatewayUrl: t } = e(), r = i();
239
246
  return n({
240
247
  mutationFn: async (e) => (await s(`mutation GovAddCaseNote($input: GovAddCaseNoteInput!) {
@@ -244,7 +251,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
244
251
  r.invalidateQueries({ queryKey: c.application(e.applicationId) });
245
252
  }
246
253
  });
247
- }, L = (t = {}) => {
254
+ }, R = (t = {}) => {
248
255
  let { apiGatewayUrl: n } = e();
249
256
  return r({
250
257
  queryKey: [...c.payments, t],
@@ -260,7 +267,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
260
267
  pagination: u(t.pagination)
261
268
  }, n)).govListPayments
262
269
  });
263
- }, R = () => {
270
+ }, z = () => {
264
271
  let { apiGatewayUrl: t } = e(), r = i();
265
272
  return n({
266
273
  mutationFn: async (e) => (await s(`mutation GovCreatePayment($input: GovCreatePaymentInput!) {
@@ -270,7 +277,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
270
277
  r.invalidateQueries({ queryKey: c.payments }), e.applicationId && r.invalidateQueries({ queryKey: c.application(e.applicationId) });
271
278
  }
272
279
  });
273
- }, z = () => {
280
+ }, B = () => {
274
281
  let { apiGatewayUrl: t } = e(), r = i();
275
282
  return n({
276
283
  mutationFn: async (e) => (await s(`mutation GovMarkPaymentPaid($id: ID!, $providerRef: String) {
@@ -278,7 +285,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
278
285
  }`, e, t)).govMarkPaymentPaid,
279
286
  onSuccess: () => r.invalidateQueries({ queryKey: c.payments })
280
287
  });
281
- }, B = () => {
288
+ }, V = () => {
282
289
  let { apiGatewayUrl: t } = e(), r = i();
283
290
  return n({
284
291
  mutationFn: async (e) => (await s(`mutation GovRefundPayment($id: ID!) {
@@ -286,19 +293,20 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
286
293
  }`, { id: e }, t)).govRefundPayment,
287
294
  onSuccess: () => r.invalidateQueries({ queryKey: c.payments })
288
295
  });
289
- }, V = (t = {}) => {
296
+ }, H = (t = {}) => {
290
297
  let { apiGatewayUrl: n } = e();
291
298
  return r({
292
299
  queryKey: [...c.permits, t],
293
- queryFn: async () => (await s(`query GovListPermits($holderId: ID, $serviceId: ID, $status: GovPermitStatus) {
294
- govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status) { ${h} }
300
+ queryFn: async () => (await s(`query GovListPermits($holderId: ID, $serviceId: ID, $status: GovPermitStatus, $pagination: PaginationInput) {
301
+ govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status, pagination: $pagination) { ${h} }
295
302
  }`, {
296
303
  holderId: t.holderId,
297
304
  serviceId: t.serviceId,
298
- status: t.status
305
+ status: t.status,
306
+ pagination: u(t.pagination)
299
307
  }, n)).govListPermits
300
308
  });
301
- }, H = () => {
309
+ }, U = () => {
302
310
  let { apiGatewayUrl: t } = e(), r = i();
303
311
  return n({
304
312
  mutationFn: async (e) => (await s(`mutation GovIssuePermit($input: GovIssuePermitInput!) {
@@ -308,7 +316,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
308
316
  r.invalidateQueries({ queryKey: c.permits }), e.applicationId && r.invalidateQueries({ queryKey: c.application(e.applicationId) });
309
317
  }
310
318
  });
311
- }, U = () => {
319
+ }, W = () => {
312
320
  let { apiGatewayUrl: t } = e(), r = i();
313
321
  return n({
314
322
  mutationFn: async (e) => (await s(`mutation GovRevokePermit($id: ID!, $reason: String) {
@@ -316,7 +324,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
316
324
  }`, e, t)).govRevokePermit,
317
325
  onSuccess: () => r.invalidateQueries({ queryKey: c.permits })
318
326
  });
319
- }, W = (t) => {
327
+ }, G = (t) => {
320
328
  let { apiGatewayUrl: n } = e();
321
329
  return r({
322
330
  queryKey: [
@@ -330,7 +338,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
330
338
  govVerifyPermit(verificationCode: $verificationCode) { ${h} }
331
339
  }`, { verificationCode: t }, n)).govVerifyPermit
332
340
  });
333
- }, G = (t = {}) => {
341
+ }, K = (t = {}) => {
334
342
  let { apiGatewayUrl: n } = e();
335
343
  return r({
336
344
  queryKey: [...c.grievances, t],
@@ -346,7 +354,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
346
354
  pagination: u(t.pagination)
347
355
  }, n)).govListGrievances
348
356
  });
349
- }, K = (t) => {
357
+ }, q = (t) => {
350
358
  let { apiGatewayUrl: n } = e();
351
359
  return r({
352
360
  queryKey: c.grievance(t ?? ""),
@@ -355,7 +363,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
355
363
  govGrievance(id: $id) { ${v} }
356
364
  }`, { id: t }, n)).govGrievance
357
365
  });
358
- }, q = () => {
366
+ }, J = () => {
359
367
  let { apiGatewayUrl: t } = e(), r = i();
360
368
  return n({
361
369
  mutationFn: async (e) => (await s(`mutation GovReportGrievance($input: GovReportGrievanceInput!) {
@@ -363,7 +371,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
363
371
  }`, { input: e }, t)).govReportGrievance,
364
372
  onSuccess: () => r.invalidateQueries({ queryKey: c.grievances })
365
373
  });
366
- }, J = () => {
374
+ }, Y = () => {
367
375
  let { apiGatewayUrl: t } = e(), r = i();
368
376
  return n({
369
377
  mutationFn: async (e) => (await s(`mutation GovUpdateGrievance($id: ID!, $input: GovUpdateGrievanceInput!) {
@@ -373,7 +381,7 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
373
381
  r.invalidateQueries({ queryKey: c.grievances }), r.invalidateQueries({ queryKey: c.grievance(e.id) });
374
382
  }
375
383
  });
376
- }, Y = () => {
384
+ }, X = () => {
377
385
  let { apiGatewayUrl: t } = e(), r = i();
378
386
  return n({
379
387
  mutationFn: async (e) => (await s(`mutation GovTransitionGrievance($id: ID!, $status: GovGrievanceStatus!, $resolution: String) {
@@ -385,6 +393,6 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
385
393
  });
386
394
  };
387
395
  //#endregion
388
- export { I as useGovAddCaseNote, P as useGovAddDocument, y as useGovAgencies, k as useGovApplication, O as useGovApplications, S as useGovArchiveAgency, b as useGovCreateAgency, A as useGovCreateApplication, R as useGovCreatePayment, T as useGovCreateService, K as useGovGrievance, G as useGovGrievances, H as useGovIssuePermit, z as useGovMarkPaymentPaid, L as useGovPayments, V as useGovPermits, B as useGovRefundPayment, q as useGovReportGrievance, F as useGovReviewDocument, U as useGovRevokePermit, w as useGovService, C as useGovServices, M as useGovSubmitApplication, N as useGovTransitionApplication, Y as useGovTransitionGrievance, D as useGovTransitionService, x as useGovUpdateAgency, j as useGovUpdateApplication, J as useGovUpdateGrievance, E as useGovUpdateService, W as useGovVerifyPermit };
396
+ export { L as useGovAddCaseNote, F as useGovAddDocument, b as useGovAgencies, A as useGovApplication, k as useGovApplications, C as useGovArchiveAgency, x as useGovCreateAgency, j as useGovCreateApplication, z as useGovCreatePayment, E as useGovCreateService, y as useGovDashboardSummary, q as useGovGrievance, K as useGovGrievances, U as useGovIssuePermit, B as useGovMarkPaymentPaid, R as useGovPayments, H as useGovPermits, V as useGovRefundPayment, J as useGovReportGrievance, I as useGovReviewDocument, W as useGovRevokePermit, T as useGovService, w as useGovServices, N as useGovSubmitApplication, P as useGovTransitionApplication, X as useGovTransitionGrievance, O as useGovTransitionService, S as useGovUpdateAgency, M as useGovUpdateApplication, Y as useGovUpdateGrievance, D as useGovUpdateService, G as useGovVerifyPermit };
389
397
 
390
398
  //# sourceMappingURL=useGovApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useGovApi.js","names":[],"sources":["../../../src/govcitizenhub/hooks/useGovApi.ts"],"sourcesContent":["/**\n * GovCitizenHub API hooks\n * @module govcitizenhub/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-govcitizenhub-svc`\n * federated GraphQL contract (the `gov*` operations). Every query/mutation below\n * uses an inline gql string whose fields match the svc `.hive-schema.graphql`\n * exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` — the\n * host shell supplies the gateway base URL + a workspace-scoped token.\n *\n * IMPORTANT: `User`/`File` are id-only federation stubs in this subgraph. We\n * never select `citizen { firstName }` or `file { url }`.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useGovCitizenHub } from '../context';\nimport { clearGraphqlResponseCache } from '../lib/graphql-cache';\nimport type {\n GovConnection,\n GovAgency,\n GovService,\n GovServiceCategory,\n GovServiceStatus,\n GovApplication,\n GovApplicationStatus,\n GovDocument,\n GovDocumentStatus,\n GovCaseNote,\n GovPermit,\n GovPermitStatus,\n GovPayment,\n GovPaymentStatus,\n GovGrievance,\n GovGrievanceStatus,\n GovCreateAgencyInput,\n GovUpdateAgencyInput,\n GovCreateServiceInput,\n GovUpdateServiceInput,\n GovCreateApplicationInput,\n GovUpdateApplicationInput,\n GovAddDocumentInput,\n GovAddCaseNoteInput,\n GovCreatePaymentInput,\n GovIssuePermitInput,\n GovReportGrievanceInput,\n GovUpdateGrievanceInput,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst isMutation = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nconst govQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n // A mutation must never be served from — or coalesced onto — the read cache,\n // and the resolved read cache must be dropped once it commits so the\n // React-Query refetch that follows sees the new state, not a stale (≤15s)\n // pre-write response. Clear before AND after the write.\n const mutating = isMutation(query);\n if (mutating) clearGraphqlResponseCache();\n\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (mutating) clearGraphqlResponseCache();\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n return response.data;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n agencies: ['govcitizenhub', 'agencies'] as const,\n agency: (id: string) => ['govcitizenhub', 'agency', id] as const,\n services: ['govcitizenhub', 'services'] as const,\n service: (id: string) => ['govcitizenhub', 'service', id] as const,\n applications: ['govcitizenhub', 'applications'] as const,\n application: (id: string) => ['govcitizenhub', 'application', id] as const,\n payments: ['govcitizenhub', 'payments'] as const,\n payment: (id: string) => ['govcitizenhub', 'payment', id] as const,\n permits: ['govcitizenhub', 'permits'] as const,\n grievances: ['govcitizenhub', 'grievances'] as const,\n grievance: (id: string) => ['govcitizenhub', 'grievance', id] as const,\n};\n\nconst DEFAULT_PAGE: PaginationInput = { limit: 50 };\n\n/** Build a clean PaginationInput, dropping nullish cursor so the svc never sees `cursor: null`. */\nconst page = (p?: PaginationInput): PaginationInput => {\n const base = p ?? DEFAULT_PAGE;\n const result: PaginationInput = { limit: base.limit ?? DEFAULT_PAGE.limit };\n if (base.offset != null) result.offset = base.offset;\n if (base.cursor != null) result.cursor = base.cursor;\n return result;\n};\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness)\n// ============================================================================\n\nconst AGENCY_FIELDS = `\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n`;\n\nconst SERVICE_FIELDS = `\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n`;\n\nconst DOCUMENT_FIELDS = `\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n`;\n\nconst CASE_NOTE_FIELDS = `\n id workspaceId applicationId authorId body type createdAt updatedAt\n`;\n\nconst PERMIT_FIELDS = `\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n`;\n\nconst PAYMENT_FIELDS = `\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n`;\n\nconst APPLICATION_FIELDS = `\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n`;\n\nconst GRIEVANCE_FIELDS = `\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n`;\n\n// ============================================================================\n// Agencies (list = ARRAY, not a connection)\n// ============================================================================\n\nexport interface AgencyFilters {\n isActive?: boolean;\n pagination?: PaginationInput;\n}\n\nexport const useGovAgencies = (filters: AgencyFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.agencies, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListAgencies: GovAgency[] }>(\n `query GovListAgencies($isActive: Boolean, $pagination: PaginationInput) {\n govListAgencies(isActive: $isActive, pagination: $pagination) { ${AGENCY_FIELDS} }\n }`,\n { isActive: filters.isActive, pagination: page(filters.pagination ?? { limit: 100 }) },\n apiGatewayUrl\n );\n return result.govListAgencies;\n },\n });\n};\n\nexport const useGovAgency = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.agency(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govAgency: GovAgency | null }>(\n `query GovAgency($id: ID!) {\n govAgency(id: $id) { ${AGENCY_FIELDS} services { ${SERVICE_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govAgency;\n },\n });\n};\n\nexport const useGovCreateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateAgencyInput) => {\n const result = await govQuery<{ govCreateAgency: GovAgency }>(\n `mutation GovCreateAgency($input: GovCreateAgencyInput!) {\n govCreateAgency(input: $input) { ${AGENCY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\nexport const useGovUpdateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateAgencyInput }) => {\n const result = await govQuery<{ govUpdateAgency: GovAgency }>(\n `mutation GovUpdateAgency($id: ID!, $input: GovUpdateAgencyInput!) {\n govUpdateAgency(id: $id, input: $input) { ${AGENCY_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateAgency;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.agencies });\n qc.invalidateQueries({ queryKey: KEY.agency(data.id) });\n },\n });\n};\n\nexport const useGovArchiveAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govArchiveAgency: boolean }>(\n `mutation GovArchiveAgency($id: ID!) { govArchiveAgency(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govArchiveAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\n// ============================================================================\n// Services (connection)\n// ============================================================================\n\nexport interface ServiceFilters {\n agencyId?: string;\n category?: GovServiceCategory;\n status?: GovServiceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovServices = (filters: ServiceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.services, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListServices: GovConnection<GovService> }>(\n `query GovListServices($agencyId: ID, $category: GovServiceCategory, $status: GovServiceStatus, $pagination: PaginationInput) {\n govListServices(agencyId: $agencyId, category: $category, status: $status, pagination: $pagination) {\n items { ${SERVICE_FIELDS} agency { id name } }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n category: filters.category,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListServices;\n },\n });\n};\n\nexport const useGovService = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.service(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govService: GovService | null }>(\n `query GovService($id: ID!) {\n govService(id: $id) { ${SERVICE_FIELDS} agency { ${AGENCY_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govService;\n },\n });\n};\n\nexport const useGovCreateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateServiceInput) => {\n const result = await govQuery<{ govCreateService: GovService }>(\n `mutation GovCreateService($input: GovCreateServiceInput!) {\n govCreateService(input: $input) { ${SERVICE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateService;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.services }),\n });\n};\n\nexport const useGovUpdateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateServiceInput }) => {\n const result = await govQuery<{ govUpdateService: GovService }>(\n `mutation GovUpdateService($id: ID!, $input: GovUpdateServiceInput!) {\n govUpdateService(id: $id, input: $input) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\nexport const useGovTransitionService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; status: GovServiceStatus }) => {\n const result = await govQuery<{ govTransitionService: GovService }>(\n `mutation GovTransitionService($id: ID!, $status: GovServiceStatus!) {\n govTransitionService(id: $id, status: $status) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Applications (connection)\n// ============================================================================\n\nexport interface ApplicationFilters {\n assignedToId?: string;\n citizenId?: string;\n serviceId?: string;\n status?: GovApplicationStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovApplications = (filters: ApplicationFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.applications, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListApplications: GovConnection<GovApplication> }>(\n `query GovListApplications($assignedToId: ID, $citizenId: ID, $serviceId: ID, $status: GovApplicationStatus, $pagination: PaginationInput) {\n govListApplications(assignedToId: $assignedToId, citizenId: $citizenId, serviceId: $serviceId, status: $status, pagination: $pagination) {\n items { ${APPLICATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n assignedToId: filters.assignedToId,\n citizenId: filters.citizenId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListApplications;\n },\n });\n};\n\nexport const useGovApplication = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.application(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govApplication: GovApplication | null }>(\n `query GovApplication($id: ID!) {\n govApplication(id: $id) {\n ${APPLICATION_FIELDS}\n formData\n documents { ${DOCUMENT_FIELDS} }\n notes { ${CASE_NOTE_FIELDS} }\n permits { ${PERMIT_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govApplication;\n },\n });\n};\n\nexport const useGovCreateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateApplicationInput) => {\n const result = await govQuery<{ govCreateApplication: GovApplication }>(\n `mutation GovCreateApplication($input: GovCreateApplicationInput!) {\n govCreateApplication(input: $input) { ${APPLICATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateApplication;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.applications }),\n });\n};\n\nexport const useGovUpdateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateApplicationInput }) => {\n const result = await govQuery<{ govUpdateApplication: GovApplication }>(\n `mutation GovUpdateApplication($id: ID!, $input: GovUpdateApplicationInput!) {\n govUpdateApplication(id: $id, input: $input) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovSubmitApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govSubmitApplication: GovApplication }>(\n `mutation GovSubmitApplication($id: ID!) {\n govSubmitApplication(id: $id) { ${APPLICATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govSubmitApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovTransitionApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovApplicationStatus;\n reason?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionApplication: GovApplication }>(\n `mutation GovTransitionApplication($id: ID!, $status: GovApplicationStatus!, $reason: String) {\n govTransitionApplication(id: $id, status: $status, reason: $reason) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Documents (attached to an application)\n// ============================================================================\n\nexport const useGovAddDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddDocumentInput) => {\n const result = await govQuery<{ govAddDocument: GovDocument }>(\n `mutation GovAddDocument($input: GovAddDocumentInput!) {\n govAddDocument(input: $input) { ${DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.applications });\n },\n });\n};\n\nexport const useGovReviewDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovDocumentStatus;\n rejectionReason?: string | null;\n applicationId?: string;\n }) => {\n const result = await govQuery<{ govReviewDocument: GovDocument }>(\n `mutation GovReviewDocument($id: ID!, $status: GovDocumentStatus!, $rejectionReason: String) {\n govReviewDocument(id: $id, status: $status, rejectionReason: $rejectionReason) { ${DOCUMENT_FIELDS} }\n }`,\n { id: vars.id, status: vars.status, rejectionReason: vars.rejectionReason },\n apiGatewayUrl\n );\n return result.govReviewDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Case notes (domain-owned casework timeline)\n// ============================================================================\n\nexport const useGovAddCaseNote = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddCaseNoteInput) => {\n const result = await govQuery<{ govAddCaseNote: GovCaseNote }>(\n `mutation GovAddCaseNote($input: GovAddCaseNoteInput!) {\n govAddCaseNote(input: $input) { ${CASE_NOTE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddCaseNote;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Payments (connection)\n// ============================================================================\n\nexport interface PaymentFilters {\n applicationId?: string;\n payerId?: string;\n status?: GovPaymentStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovPayments = (filters: PaymentFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.payments, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPayments: GovConnection<GovPayment> }>(\n `query GovListPayments($applicationId: ID, $payerId: ID, $status: GovPaymentStatus, $pagination: PaginationInput) {\n govListPayments(applicationId: $applicationId, payerId: $payerId, status: $status, pagination: $pagination) {\n items { ${PAYMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n applicationId: filters.applicationId,\n payerId: filters.payerId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPayments;\n },\n });\n};\n\nexport const useGovCreatePayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreatePaymentInput) => {\n const result = await govQuery<{ govCreatePayment: GovPayment }>(\n `mutation GovCreatePayment($input: GovCreatePaymentInput!) {\n govCreatePayment(input: $input) { ${PAYMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreatePayment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.payments });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovMarkPaymentPaid = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; providerRef?: string | null }) => {\n const result = await govQuery<{ govMarkPaymentPaid: GovPayment }>(\n `mutation GovMarkPaymentPaid($id: ID!, $providerRef: String) {\n govMarkPaymentPaid(id: $id, providerRef: $providerRef) { ${PAYMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govMarkPaymentPaid;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\nexport const useGovRefundPayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govRefundPayment: GovPayment }>(\n `mutation GovRefundPayment($id: ID!) {\n govRefundPayment(id: $id) { ${PAYMENT_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govRefundPayment;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\n// ============================================================================\n// Permits (list = ARRAY, no pagination) + public verification\n// ============================================================================\n\nexport interface PermitFilters {\n holderId?: string;\n serviceId?: string;\n status?: GovPermitStatus;\n}\n\nexport const useGovPermits = (filters: PermitFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.permits, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPermits: GovPermit[] }>(\n `query GovListPermits($holderId: ID, $serviceId: ID, $status: GovPermitStatus) {\n govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status) { ${PERMIT_FIELDS} }\n }`,\n { holderId: filters.holderId, serviceId: filters.serviceId, status: filters.status },\n apiGatewayUrl\n );\n return result.govListPermits;\n },\n });\n};\n\nexport const useGovIssuePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovIssuePermitInput) => {\n const result = await govQuery<{ govIssuePermit: GovPermit }>(\n `mutation GovIssuePermit($input: GovIssuePermitInput!) {\n govIssuePermit(input: $input) { ${PERMIT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govIssuePermit;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.permits });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovRevokePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; reason?: string | null }) => {\n const result = await govQuery<{ govRevokePermit: GovPermit }>(\n `mutation GovRevokePermit($id: ID!, $reason: String) {\n govRevokePermit(id: $id, reason: $reason) { ${PERMIT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govRevokePermit;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.permits }),\n });\n};\n\n/**\n * Public permit verification by printed code. `govVerifyPermit` is a PUBLIC field\n * (no auth), but we keep the workspace-token transport for a consistent gateway\n * path. `enabled` is false until a code is supplied so the query is manual.\n */\nexport const useGovVerifyPermit = (verificationCode: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'verify-permit', verificationCode ?? ''],\n enabled: Boolean(verificationCode),\n retry: false,\n queryFn: async () => {\n const result = await govQuery<{ govVerifyPermit: GovPermit | null }>(\n `query GovVerifyPermit($verificationCode: String!) {\n govVerifyPermit(verificationCode: $verificationCode) { ${PERMIT_FIELDS} }\n }`,\n { verificationCode },\n apiGatewayUrl\n );\n return result.govVerifyPermit;\n },\n });\n};\n\n// ============================================================================\n// Grievances (connection)\n// ============================================================================\n\nexport interface GrievanceFilters {\n agencyId?: string;\n reporterId?: string;\n status?: GovGrievanceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovGrievances = (filters: GrievanceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListGrievances: GovConnection<GovGrievance> }>(\n `query GovListGrievances($agencyId: ID, $reporterId: ID, $status: GovGrievanceStatus, $pagination: PaginationInput) {\n govListGrievances(agencyId: $agencyId, reporterId: $reporterId, status: $status, pagination: $pagination) {\n items { ${GRIEVANCE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n reporterId: filters.reporterId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListGrievances;\n },\n });\n};\n\nexport const useGovGrievance = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.grievance(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govGrievance: GovGrievance | null }>(\n `query GovGrievance($id: ID!) {\n govGrievance(id: $id) { ${GRIEVANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govGrievance;\n },\n });\n};\n\nexport const useGovReportGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovReportGrievanceInput) => {\n const result = await govQuery<{ govReportGrievance: GovGrievance }>(\n `mutation GovReportGrievance($input: GovReportGrievanceInput!) {\n govReportGrievance(input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govReportGrievance;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.grievances }),\n });\n};\n\nexport const useGovUpdateGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateGrievanceInput }) => {\n const result = await govQuery<{ govUpdateGrievance: GovGrievance }>(\n `mutation GovUpdateGrievance($id: ID!, $input: GovUpdateGrievanceInput!) {\n govUpdateGrievance(id: $id, input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n\nexport const useGovTransitionGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovGrievanceStatus;\n resolution?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionGrievance: GovGrievance }>(\n `mutation GovTransitionGrievance($id: ID!, $status: GovGrievanceStatus!, $resolution: String) {\n govTransitionGrievance(id: $id, status: $status, resolution: $resolution) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n"],"mappings":";;;;;;AAyDA,IAAM,KAAc,MAA2B,iBAAiB,KAAK,EAAM,EAErE,IAAW,OACf,GACA,GACA,MACmB;CAKnB,IAAM,IAAW,EAAW,EAAM;AAClC,CAAI,KAAU,GAA2B;CAEzC,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;EACjB,CAAC;AAIF,KAFI,KAAU,GAA2B,EAErC,EAAS,QAAQ,OACnB,OAAU,MAAM,EAAS,OAAO,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B;AAC5C,QAAO,EAAS;EACd,UAAU,EAAI,UAAU,KAAM,GAAG;EACjC,SAAS,EAAQ;EACjB,SAAS,aACQ,MAAM,EACnB;oCAC4B,EAAiB;YAE7C,EAAE,OAAI,EACN,EACD,EACa;EAEjB,CAAC;GAGS,UAA8B;CACzC,IAAM,EAAE,qBAAkB,GAAkB,EACtC,IAAK,GAAgB;AAC3B,QAAO,EAAY;EACjB,YAAY,OAAO,OACF,MAAM,EACnB;gDACwC,EAAiB;YAEzD,EAAE,UAAO,EACT,EACD,EACa;EAEhB,iBAAiB,EAAG,kBAAkB,EAAE,UAAU,EAAI,YAAY,CAAC;EACpE,CAAC;GAGS,UAA8B;CACzC,IAAM,EAAE,qBAAkB,GAAkB,EACtC,IAAK,GAAgB;AAC3B,QAAO,EAAY;EACjB,YAAY,OAAO,OACF,MAAM,EACnB;yDACiD,EAAiB;YAElE,GACA,EACD,EACa;EAEhB,YAAY,MAAS;AAEnB,GADA,EAAG,kBAAkB,EAAE,UAAU,EAAI,YAAY,CAAC,EAClD,EAAG,kBAAkB,EAAE,UAAU,EAAI,UAAU,EAAK,GAAG,EAAE,CAAC;;EAE7D,CAAC;GAGS,UAAkC;CAC7C,IAAM,EAAE,qBAAkB,GAAkB,EACtC,IAAK,GAAgB;AAC3B,QAAO,EAAY;EACjB,YAAY,OAAO,OAKF,MAAM,EACnB;wFACgF,EAAiB;YAEjG,GACA,EACD,EACa;EAEhB,YAAY,MAAS;AAEnB,GADA,EAAG,kBAAkB,EAAE,UAAU,EAAI,YAAY,CAAC,EAClD,EAAG,kBAAkB,EAAE,UAAU,EAAI,UAAU,EAAK,GAAG,EAAE,CAAC;;EAE7D,CAAC"}
1
+ {"version":3,"file":"useGovApi.js","names":[],"sources":["../../../src/govcitizenhub/hooks/useGovApi.ts"],"sourcesContent":["/**\n * GovCitizenHub API hooks\n * @module govcitizenhub/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-govcitizenhub-svc`\n * federated GraphQL contract (the `gov*` operations). Every query/mutation below\n * uses an inline gql string whose fields match the svc `.hive-schema.graphql`\n * exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` — the\n * host shell supplies the gateway base URL + a workspace-scoped token.\n *\n * IMPORTANT: `User`/`File` are id-only federation stubs in this subgraph. We\n * never select `citizen { firstName }` or `file { url }`.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useGovCitizenHub } from '../context';\nimport { clearGraphqlResponseCache } from '../lib/graphql-cache';\nimport type {\n GovConnection,\n GovAgency,\n GovService,\n GovServiceCategory,\n GovServiceStatus,\n GovApplication,\n GovApplicationStatus,\n GovDocument,\n GovDocumentStatus,\n GovCaseNote,\n GovPermit,\n GovPermitStatus,\n GovPayment,\n GovPaymentStatus,\n GovGrievance,\n GovGrievanceStatus,\n GovCreateAgencyInput,\n GovUpdateAgencyInput,\n GovCreateServiceInput,\n GovUpdateServiceInput,\n GovCreateApplicationInput,\n GovUpdateApplicationInput,\n GovAddDocumentInput,\n GovAddCaseNoteInput,\n GovCreatePaymentInput,\n GovIssuePermitInput,\n GovReportGrievanceInput,\n GovUpdateGrievanceInput,\n GovDashboardSummary,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst isMutation = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nconst govQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n // A mutation must never be served from — or coalesced onto — the read cache,\n // and the resolved read cache must be dropped once it commits so the\n // React-Query refetch that follows sees the new state, not a stale (≤15s)\n // pre-write response. Clear before AND after the write.\n const mutating = isMutation(query);\n if (mutating) clearGraphqlResponseCache();\n\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (mutating) clearGraphqlResponseCache();\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n return response.data;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n dashboard: ['govcitizenhub', 'dashboard-summary'] as const,\n agencies: ['govcitizenhub', 'agencies'] as const,\n agency: (id: string) => ['govcitizenhub', 'agency', id] as const,\n services: ['govcitizenhub', 'services'] as const,\n service: (id: string) => ['govcitizenhub', 'service', id] as const,\n applications: ['govcitizenhub', 'applications'] as const,\n application: (id: string) => ['govcitizenhub', 'application', id] as const,\n payments: ['govcitizenhub', 'payments'] as const,\n payment: (id: string) => ['govcitizenhub', 'payment', id] as const,\n permits: ['govcitizenhub', 'permits'] as const,\n grievances: ['govcitizenhub', 'grievances'] as const,\n grievance: (id: string) => ['govcitizenhub', 'grievance', id] as const,\n};\n\nconst DEFAULT_PAGE: PaginationInput = { limit: 50 };\n\n/** Build a clean PaginationInput, dropping nullish cursor so the svc never sees `cursor: null`. */\nconst page = (p?: PaginationInput): PaginationInput => {\n const base = p ?? DEFAULT_PAGE;\n const result: PaginationInput = { limit: base.limit ?? DEFAULT_PAGE.limit };\n if (base.offset != null) result.offset = base.offset;\n if (base.cursor != null) result.cursor = base.cursor;\n return result;\n};\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness)\n// ============================================================================\n\nconst AGENCY_FIELDS = `\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n`;\n\nconst SERVICE_FIELDS = `\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n`;\n\nconst DOCUMENT_FIELDS = `\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n`;\n\nconst CASE_NOTE_FIELDS = `\n id workspaceId applicationId authorId body type createdAt updatedAt\n`;\n\nconst PERMIT_FIELDS = `\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n`;\n\nconst PAYMENT_FIELDS = `\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n`;\n\nconst APPLICATION_FIELDS = `\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n`;\n\nconst GRIEVANCE_FIELDS = `\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n`;\n\n// ============================================================================\n// Dashboard summary (authoritative, backend-computed counts)\n// ============================================================================\n\n/**\n * Reads `govDashboardSummary` — the svc-computed operations totals. These are\n * authoritative (full-corpus counts, not a capped client-side window), so the\n * dashboard tiles and status donut MUST source from here, never from a paged\n * list's `items.length`.\n */\nexport const useGovDashboardSummary = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.dashboard,\n queryFn: async () => {\n const result = await govQuery<{ govDashboardSummary: GovDashboardSummary }>(\n `query GovDashboardSummary {\n govDashboardSummary {\n applicationsTotal\n applicationsByStatus { status count }\n pendingPayments\n pendingPaymentsAmount\n openGrievances\n activePermits\n publishedServices\n activeAgencies\n }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govDashboardSummary;\n },\n });\n};\n\n// ============================================================================\n// Agencies (list = ARRAY, not a connection)\n// ============================================================================\n\nexport interface AgencyFilters {\n isActive?: boolean;\n pagination?: PaginationInput;\n}\n\nexport const useGovAgencies = (filters: AgencyFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.agencies, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListAgencies: GovAgency[] }>(\n `query GovListAgencies($isActive: Boolean, $pagination: PaginationInput) {\n govListAgencies(isActive: $isActive, pagination: $pagination) { ${AGENCY_FIELDS} }\n }`,\n { isActive: filters.isActive, pagination: page(filters.pagination ?? { limit: 100 }) },\n apiGatewayUrl\n );\n return result.govListAgencies;\n },\n });\n};\n\nexport const useGovAgency = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.agency(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govAgency: GovAgency | null }>(\n `query GovAgency($id: ID!) {\n govAgency(id: $id) { ${AGENCY_FIELDS} services { ${SERVICE_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govAgency;\n },\n });\n};\n\nexport const useGovCreateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateAgencyInput) => {\n const result = await govQuery<{ govCreateAgency: GovAgency }>(\n `mutation GovCreateAgency($input: GovCreateAgencyInput!) {\n govCreateAgency(input: $input) { ${AGENCY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\nexport const useGovUpdateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateAgencyInput }) => {\n const result = await govQuery<{ govUpdateAgency: GovAgency }>(\n `mutation GovUpdateAgency($id: ID!, $input: GovUpdateAgencyInput!) {\n govUpdateAgency(id: $id, input: $input) { ${AGENCY_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateAgency;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.agencies });\n qc.invalidateQueries({ queryKey: KEY.agency(data.id) });\n },\n });\n};\n\nexport const useGovArchiveAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govArchiveAgency: boolean }>(\n `mutation GovArchiveAgency($id: ID!) { govArchiveAgency(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govArchiveAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\n// ============================================================================\n// Services (connection)\n// ============================================================================\n\nexport interface ServiceFilters {\n agencyId?: string;\n category?: GovServiceCategory;\n status?: GovServiceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovServices = (filters: ServiceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.services, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListServices: GovConnection<GovService> }>(\n `query GovListServices($agencyId: ID, $category: GovServiceCategory, $status: GovServiceStatus, $pagination: PaginationInput) {\n govListServices(agencyId: $agencyId, category: $category, status: $status, pagination: $pagination) {\n items { ${SERVICE_FIELDS} agency { id name } }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n category: filters.category,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListServices;\n },\n });\n};\n\nexport const useGovService = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.service(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govService: GovService | null }>(\n `query GovService($id: ID!) {\n govService(id: $id) { ${SERVICE_FIELDS} agency { ${AGENCY_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govService;\n },\n });\n};\n\nexport const useGovCreateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateServiceInput) => {\n const result = await govQuery<{ govCreateService: GovService }>(\n `mutation GovCreateService($input: GovCreateServiceInput!) {\n govCreateService(input: $input) { ${SERVICE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateService;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.services }),\n });\n};\n\nexport const useGovUpdateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateServiceInput }) => {\n const result = await govQuery<{ govUpdateService: GovService }>(\n `mutation GovUpdateService($id: ID!, $input: GovUpdateServiceInput!) {\n govUpdateService(id: $id, input: $input) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\nexport const useGovTransitionService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; status: GovServiceStatus }) => {\n const result = await govQuery<{ govTransitionService: GovService }>(\n `mutation GovTransitionService($id: ID!, $status: GovServiceStatus!) {\n govTransitionService(id: $id, status: $status) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Applications (connection)\n// ============================================================================\n\nexport interface ApplicationFilters {\n assignedToId?: string;\n citizenId?: string;\n serviceId?: string;\n status?: GovApplicationStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovApplications = (filters: ApplicationFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.applications, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListApplications: GovConnection<GovApplication> }>(\n `query GovListApplications($assignedToId: ID, $citizenId: ID, $serviceId: ID, $status: GovApplicationStatus, $pagination: PaginationInput) {\n govListApplications(assignedToId: $assignedToId, citizenId: $citizenId, serviceId: $serviceId, status: $status, pagination: $pagination) {\n items { ${APPLICATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n assignedToId: filters.assignedToId,\n citizenId: filters.citizenId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListApplications;\n },\n });\n};\n\nexport const useGovApplication = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.application(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govApplication: GovApplication | null }>(\n `query GovApplication($id: ID!) {\n govApplication(id: $id) {\n ${APPLICATION_FIELDS}\n formData\n documents { ${DOCUMENT_FIELDS} }\n notes { ${CASE_NOTE_FIELDS} }\n permits { ${PERMIT_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govApplication;\n },\n });\n};\n\nexport const useGovCreateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateApplicationInput) => {\n const result = await govQuery<{ govCreateApplication: GovApplication }>(\n `mutation GovCreateApplication($input: GovCreateApplicationInput!) {\n govCreateApplication(input: $input) { ${APPLICATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateApplication;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.applications }),\n });\n};\n\nexport const useGovUpdateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateApplicationInput }) => {\n const result = await govQuery<{ govUpdateApplication: GovApplication }>(\n `mutation GovUpdateApplication($id: ID!, $input: GovUpdateApplicationInput!) {\n govUpdateApplication(id: $id, input: $input) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovSubmitApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govSubmitApplication: GovApplication }>(\n `mutation GovSubmitApplication($id: ID!) {\n govSubmitApplication(id: $id) { ${APPLICATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govSubmitApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovTransitionApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovApplicationStatus;\n reason?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionApplication: GovApplication }>(\n `mutation GovTransitionApplication($id: ID!, $status: GovApplicationStatus!, $reason: String) {\n govTransitionApplication(id: $id, status: $status, reason: $reason) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Documents (attached to an application)\n// ============================================================================\n\nexport const useGovAddDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddDocumentInput) => {\n const result = await govQuery<{ govAddDocument: GovDocument }>(\n `mutation GovAddDocument($input: GovAddDocumentInput!) {\n govAddDocument(input: $input) { ${DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.applications });\n },\n });\n};\n\nexport const useGovReviewDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovDocumentStatus;\n rejectionReason?: string | null;\n applicationId?: string;\n }) => {\n const result = await govQuery<{ govReviewDocument: GovDocument }>(\n `mutation GovReviewDocument($id: ID!, $status: GovDocumentStatus!, $rejectionReason: String) {\n govReviewDocument(id: $id, status: $status, rejectionReason: $rejectionReason) { ${DOCUMENT_FIELDS} }\n }`,\n { id: vars.id, status: vars.status, rejectionReason: vars.rejectionReason },\n apiGatewayUrl\n );\n return result.govReviewDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Case notes (domain-owned casework timeline)\n// ============================================================================\n\nexport const useGovAddCaseNote = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddCaseNoteInput) => {\n const result = await govQuery<{ govAddCaseNote: GovCaseNote }>(\n `mutation GovAddCaseNote($input: GovAddCaseNoteInput!) {\n govAddCaseNote(input: $input) { ${CASE_NOTE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddCaseNote;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Payments (connection)\n// ============================================================================\n\nexport interface PaymentFilters {\n applicationId?: string;\n payerId?: string;\n status?: GovPaymentStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovPayments = (filters: PaymentFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.payments, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPayments: GovConnection<GovPayment> }>(\n `query GovListPayments($applicationId: ID, $payerId: ID, $status: GovPaymentStatus, $pagination: PaginationInput) {\n govListPayments(applicationId: $applicationId, payerId: $payerId, status: $status, pagination: $pagination) {\n items { ${PAYMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n applicationId: filters.applicationId,\n payerId: filters.payerId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPayments;\n },\n });\n};\n\nexport const useGovCreatePayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreatePaymentInput) => {\n const result = await govQuery<{ govCreatePayment: GovPayment }>(\n `mutation GovCreatePayment($input: GovCreatePaymentInput!) {\n govCreatePayment(input: $input) { ${PAYMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreatePayment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.payments });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovMarkPaymentPaid = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; providerRef?: string | null }) => {\n const result = await govQuery<{ govMarkPaymentPaid: GovPayment }>(\n `mutation GovMarkPaymentPaid($id: ID!, $providerRef: String) {\n govMarkPaymentPaid(id: $id, providerRef: $providerRef) { ${PAYMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govMarkPaymentPaid;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\nexport const useGovRefundPayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govRefundPayment: GovPayment }>(\n `mutation GovRefundPayment($id: ID!) {\n govRefundPayment(id: $id) { ${PAYMENT_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govRefundPayment;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\n// ============================================================================\n// Permits (list = ARRAY, no pagination) + public verification\n// ============================================================================\n\nexport interface PermitFilters {\n holderId?: string;\n serviceId?: string;\n status?: GovPermitStatus;\n pagination?: PaginationInput;\n}\n\n/**\n * `govListPermits` returns a bare ARRAY (not a connection), but now accepts an\n * optional offset `pagination` arg (default page size 50). Callers page with\n * `{ limit, offset }`; `hasMore` is inferred from a full-length page since the\n * svc does not return a total.\n */\nexport const useGovPermits = (filters: PermitFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.permits, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPermits: GovPermit[] }>(\n `query GovListPermits($holderId: ID, $serviceId: ID, $status: GovPermitStatus, $pagination: PaginationInput) {\n govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status, pagination: $pagination) { ${PERMIT_FIELDS} }\n }`,\n {\n holderId: filters.holderId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPermits;\n },\n });\n};\n\nexport const useGovIssuePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovIssuePermitInput) => {\n const result = await govQuery<{ govIssuePermit: GovPermit }>(\n `mutation GovIssuePermit($input: GovIssuePermitInput!) {\n govIssuePermit(input: $input) { ${PERMIT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govIssuePermit;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.permits });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovRevokePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; reason?: string | null }) => {\n const result = await govQuery<{ govRevokePermit: GovPermit }>(\n `mutation GovRevokePermit($id: ID!, $reason: String) {\n govRevokePermit(id: $id, reason: $reason) { ${PERMIT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govRevokePermit;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.permits }),\n });\n};\n\n/**\n * Public permit verification by printed code. `govVerifyPermit` is a PUBLIC field\n * (no auth), but we keep the workspace-token transport for a consistent gateway\n * path. `enabled` is false until a code is supplied so the query is manual.\n */\nexport const useGovVerifyPermit = (verificationCode: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'verify-permit', verificationCode ?? ''],\n enabled: Boolean(verificationCode),\n retry: false,\n queryFn: async () => {\n const result = await govQuery<{ govVerifyPermit: GovPermit | null }>(\n `query GovVerifyPermit($verificationCode: String!) {\n govVerifyPermit(verificationCode: $verificationCode) { ${PERMIT_FIELDS} }\n }`,\n { verificationCode },\n apiGatewayUrl\n );\n return result.govVerifyPermit;\n },\n });\n};\n\n// ============================================================================\n// Grievances (connection)\n// ============================================================================\n\nexport interface GrievanceFilters {\n agencyId?: string;\n reporterId?: string;\n status?: GovGrievanceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovGrievances = (filters: GrievanceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListGrievances: GovConnection<GovGrievance> }>(\n `query GovListGrievances($agencyId: ID, $reporterId: ID, $status: GovGrievanceStatus, $pagination: PaginationInput) {\n govListGrievances(agencyId: $agencyId, reporterId: $reporterId, status: $status, pagination: $pagination) {\n items { ${GRIEVANCE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n reporterId: filters.reporterId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListGrievances;\n },\n });\n};\n\nexport const useGovGrievance = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.grievance(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govGrievance: GovGrievance | null }>(\n `query GovGrievance($id: ID!) {\n govGrievance(id: $id) { ${GRIEVANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govGrievance;\n },\n });\n};\n\nexport const useGovReportGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovReportGrievanceInput) => {\n const result = await govQuery<{ govReportGrievance: GovGrievance }>(\n `mutation GovReportGrievance($input: GovReportGrievanceInput!) {\n govReportGrievance(input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govReportGrievance;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.grievances }),\n });\n};\n\nexport const useGovUpdateGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateGrievanceInput }) => {\n const result = await govQuery<{ govUpdateGrievance: GovGrievance }>(\n `mutation GovUpdateGrievance($id: ID!, $input: GovUpdateGrievanceInput!) {\n govUpdateGrievance(id: $id, input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n\nexport const useGovTransitionGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovGrievanceStatus;\n resolution?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionGrievance: GovGrievance }>(\n `mutation GovTransitionGrievance($id: ID!, $status: GovGrievanceStatus!, $resolution: String) {\n govTransitionGrievance(id: $id, status: $status, resolution: $resolution) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\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