@burdenoff/microfe-theglobalfuel 2026.704.1 → 2026.705.2

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.
Files changed (133) hide show
  1. package/dist/node_modules/{.bun/clsx@2.1.1/node_modules/clsx → clsx}/dist/clsx.js +1 -1
  2. package/dist/node_modules/clsx/dist/clsx.js.map +1 -0
  3. package/dist/node_modules/{.bun/tailwind-merge@3.5.0/node_modules/tailwind-merge → tailwind-merge}/dist/bundle-mjs.js +212 -170
  4. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -0
  5. package/dist/theglobalfuel/components/DataTable.js +37 -27
  6. package/dist/theglobalfuel/components/DataTable.js.map +1 -1
  7. package/dist/theglobalfuel/hooks/index.js +1 -0
  8. package/dist/theglobalfuel/hooks/useNotify.js +19 -0
  9. package/dist/theglobalfuel/hooks/useNotify.js.map +1 -0
  10. package/dist/theglobalfuel/hooks/useTheFiles.js +4 -1
  11. package/dist/theglobalfuel/hooks/useTheFiles.js.map +1 -1
  12. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js +59 -31
  13. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js.map +1 -1
  14. package/dist/theglobalfuel/pages/assets/AssetDetailPage.js +367 -321
  15. package/dist/theglobalfuel/pages/assets/AssetDetailPage.js.map +1 -1
  16. package/dist/theglobalfuel/pages/assets/AssetsPage.js +66 -54
  17. package/dist/theglobalfuel/pages/assets/AssetsPage.js.map +1 -1
  18. package/dist/theglobalfuel/pages/compliance/CompliancePage.js +346 -182
  19. package/dist/theglobalfuel/pages/compliance/CompliancePage.js.map +1 -1
  20. package/dist/theglobalfuel/pages/contracts/ContractDetailPage.js +418 -390
  21. package/dist/theglobalfuel/pages/contracts/ContractDetailPage.js.map +1 -1
  22. package/dist/theglobalfuel/pages/contracts/ContractsPage.js +238 -230
  23. package/dist/theglobalfuel/pages/contracts/ContractsPage.js.map +1 -1
  24. package/dist/theglobalfuel/pages/dashboard/DashboardPage.js +5 -3
  25. package/dist/theglobalfuel/pages/dashboard/DashboardPage.js.map +1 -1
  26. package/dist/theglobalfuel/pages/emissions/EmissionsPage.js +201 -177
  27. package/dist/theglobalfuel/pages/emissions/EmissionsPage.js.map +1 -1
  28. package/dist/theglobalfuel/pages/inventory/InventoryPage.js +271 -238
  29. package/dist/theglobalfuel/pages/inventory/InventoryPage.js.map +1 -1
  30. package/dist/theglobalfuel/pages/production/ProductionPage.js +185 -177
  31. package/dist/theglobalfuel/pages/production/ProductionPage.js.map +1 -1
  32. package/dist/theglobalfuel/pages/reserves/ReservesPage.js +160 -138
  33. package/dist/theglobalfuel/pages/reserves/ReservesPage.js.map +1 -1
  34. package/dist/theglobalfuel/pages/shipments/ShipmentsPage.js +250 -198
  35. package/dist/theglobalfuel/pages/shipments/ShipmentsPage.js.map +1 -1
  36. package/dist/theglobalfuel/utils/cn.js +2 -2
  37. package/dist/theglobalfuel/utils/formatters.js +6 -1
  38. package/dist/theglobalfuel/utils/formatters.js.map +1 -1
  39. package/dist/theglobalfuel/utils/transitions.js +70 -0
  40. package/dist/theglobalfuel/utils/transitions.js.map +1 -0
  41. package/package.json +1 -1
  42. package/dist/dev/main.d.ts +0 -2
  43. package/dist/dev/main.d.ts.map +0 -1
  44. package/dist/index.d.ts +0 -2
  45. package/dist/index.d.ts.map +0 -1
  46. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js.map +0 -1
  47. package/dist/node_modules/.bun/tailwind-merge@3.5.0/node_modules/tailwind-merge/dist/bundle-mjs.js.map +0 -1
  48. package/dist/theglobalfuel/TheGlobalFuelRoot.d.ts +0 -5
  49. package/dist/theglobalfuel/TheGlobalFuelRoot.d.ts.map +0 -1
  50. package/dist/theglobalfuel/TheGlobalFuelRoutes.d.ts +0 -4
  51. package/dist/theglobalfuel/TheGlobalFuelRoutes.d.ts.map +0 -1
  52. package/dist/theglobalfuel/components/DataTable.d.ts +0 -28
  53. package/dist/theglobalfuel/components/DataTable.d.ts.map +0 -1
  54. package/dist/theglobalfuel/components/EmptyState.d.ts +0 -18
  55. package/dist/theglobalfuel/components/EmptyState.d.ts.map +0 -1
  56. package/dist/theglobalfuel/components/EvidenceUpload.d.ts +0 -14
  57. package/dist/theglobalfuel/components/EvidenceUpload.d.ts.map +0 -1
  58. package/dist/theglobalfuel/components/FileLink.d.ts +0 -15
  59. package/dist/theglobalfuel/components/FileLink.d.ts.map +0 -1
  60. package/dist/theglobalfuel/components/FilterTabs.d.ts +0 -18
  61. package/dist/theglobalfuel/components/FilterTabs.d.ts.map +0 -1
  62. package/dist/theglobalfuel/components/MetricsCard.d.ts +0 -23
  63. package/dist/theglobalfuel/components/MetricsCard.d.ts.map +0 -1
  64. package/dist/theglobalfuel/components/MiniBar.d.ts +0 -16
  65. package/dist/theglobalfuel/components/MiniBar.d.ts.map +0 -1
  66. package/dist/theglobalfuel/components/PageLayout.d.ts +0 -16
  67. package/dist/theglobalfuel/components/PageLayout.d.ts.map +0 -1
  68. package/dist/theglobalfuel/components/Pagination.d.ts +0 -22
  69. package/dist/theglobalfuel/components/Pagination.d.ts.map +0 -1
  70. package/dist/theglobalfuel/components/StateViews.d.ts +0 -24
  71. package/dist/theglobalfuel/components/StateViews.d.ts.map +0 -1
  72. package/dist/theglobalfuel/components/StatusBadge.d.ts +0 -9
  73. package/dist/theglobalfuel/components/StatusBadge.d.ts.map +0 -1
  74. package/dist/theglobalfuel/components/Tabs.d.ts +0 -17
  75. package/dist/theglobalfuel/components/Tabs.d.ts.map +0 -1
  76. package/dist/theglobalfuel/components/TheDiscussion.d.ts +0 -18
  77. package/dist/theglobalfuel/components/TheDiscussion.d.ts.map +0 -1
  78. package/dist/theglobalfuel/components/TheTags.d.ts +0 -17
  79. package/dist/theglobalfuel/components/TheTags.d.ts.map +0 -1
  80. package/dist/theglobalfuel/components/index.d.ts +0 -19
  81. package/dist/theglobalfuel/components/index.d.ts.map +0 -1
  82. package/dist/theglobalfuel/context/TheGlobalFuelContext.d.ts +0 -16
  83. package/dist/theglobalfuel/context/TheGlobalFuelContext.d.ts.map +0 -1
  84. package/dist/theglobalfuel/context/index.d.ts +0 -6
  85. package/dist/theglobalfuel/context/index.d.ts.map +0 -1
  86. package/dist/theglobalfuel/hooks/index.d.ts +0 -10
  87. package/dist/theglobalfuel/hooks/index.d.ts.map +0 -1
  88. package/dist/theglobalfuel/hooks/useCursorPager.d.ts +0 -33
  89. package/dist/theglobalfuel/hooks/useCursorPager.d.ts.map +0 -1
  90. package/dist/theglobalfuel/hooks/useTheComments.d.ts +0 -36
  91. package/dist/theglobalfuel/hooks/useTheComments.d.ts.map +0 -1
  92. package/dist/theglobalfuel/hooks/useTheFiles.d.ts +0 -47
  93. package/dist/theglobalfuel/hooks/useTheFiles.d.ts.map +0 -1
  94. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts +0 -75
  95. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts.map +0 -1
  96. package/dist/theglobalfuel/hooks/useTheTags.d.ts +0 -44
  97. package/dist/theglobalfuel/hooks/useTheTags.d.ts.map +0 -1
  98. package/dist/theglobalfuel/index.d.ts +0 -9
  99. package/dist/theglobalfuel/index.d.ts.map +0 -1
  100. package/dist/theglobalfuel/pages/assets/AssetDetailPage.d.ts +0 -13
  101. package/dist/theglobalfuel/pages/assets/AssetDetailPage.d.ts.map +0 -1
  102. package/dist/theglobalfuel/pages/assets/AssetsPage.d.ts +0 -10
  103. package/dist/theglobalfuel/pages/assets/AssetsPage.d.ts.map +0 -1
  104. package/dist/theglobalfuel/pages/compliance/CompliancePage.d.ts +0 -11
  105. package/dist/theglobalfuel/pages/compliance/CompliancePage.d.ts.map +0 -1
  106. package/dist/theglobalfuel/pages/contracts/ContractDetailPage.d.ts +0 -9
  107. package/dist/theglobalfuel/pages/contracts/ContractDetailPage.d.ts.map +0 -1
  108. package/dist/theglobalfuel/pages/contracts/ContractsPage.d.ts +0 -8
  109. package/dist/theglobalfuel/pages/contracts/ContractsPage.d.ts.map +0 -1
  110. package/dist/theglobalfuel/pages/dashboard/DashboardPage.d.ts +0 -13
  111. package/dist/theglobalfuel/pages/dashboard/DashboardPage.d.ts.map +0 -1
  112. package/dist/theglobalfuel/pages/emissions/EmissionsPage.d.ts +0 -12
  113. package/dist/theglobalfuel/pages/emissions/EmissionsPage.d.ts.map +0 -1
  114. package/dist/theglobalfuel/pages/inventory/InventoryPage.d.ts +0 -11
  115. package/dist/theglobalfuel/pages/inventory/InventoryPage.d.ts.map +0 -1
  116. package/dist/theglobalfuel/pages/production/ProductionPage.d.ts +0 -11
  117. package/dist/theglobalfuel/pages/production/ProductionPage.d.ts.map +0 -1
  118. package/dist/theglobalfuel/pages/reserves/ReservesPage.d.ts +0 -10
  119. package/dist/theglobalfuel/pages/reserves/ReservesPage.d.ts.map +0 -1
  120. package/dist/theglobalfuel/pages/shipments/ShipmentsPage.d.ts +0 -10
  121. package/dist/theglobalfuel/pages/shipments/ShipmentsPage.d.ts.map +0 -1
  122. package/dist/theglobalfuel/types/index.d.ts +0 -376
  123. package/dist/theglobalfuel/types/index.d.ts.map +0 -1
  124. package/dist/theglobalfuel/utils/cn.d.ts +0 -4
  125. package/dist/theglobalfuel/utils/cn.d.ts.map +0 -1
  126. package/dist/theglobalfuel/utils/formatters.d.ts +0 -36
  127. package/dist/theglobalfuel/utils/formatters.d.ts.map +0 -1
  128. package/dist/theglobalfuel/utils/i18n.d.ts +0 -6
  129. package/dist/theglobalfuel/utils/i18n.d.ts.map +0 -1
  130. package/dist/theglobalfuel/utils/index.d.ts +0 -9
  131. package/dist/theglobalfuel/utils/index.d.ts.map +0 -1
  132. package/dist/theglobalfuel/utils/navigation.d.ts +0 -14
  133. package/dist/theglobalfuel/utils/navigation.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useTheFiles.js","names":[],"sources":["../../../src/theglobalfuel/hooks/useTheFiles.ts"],"sourcesContent":["/**\n * TheGlobalFuel — wspace-files-svc REUSE hooks (Integration A).\n * @module theglobalfuel/hooks/useTheFiles\n *\n * Reuses the platform file store (`wspace-files-svc`) WITHOUT any eco-svc\n * change: the theglobalfuel schema already exposes `TheObservation.evidenceFileId` /\n * `TheReport.fileId`; this module lets the UI actually produce a `fileId` via\n * the canonical 3-step upload flow composed into the WORKSPACE supergraph:\n * 1. `initiateUpload(input)` → `{ uploadUrl, session { id } }`\n * 2. HTTP `PUT` the bytes to the returned signed `uploadUrl`\n * 3. `completeUpload(input: { sessionId })` → `{ fileId }`\n * plus `getFile(id)` to resolve an existing evidence/report file's name + URL.\n *\n * Transport mirrors `useTheGlobalFuelApi` exactly — `graphqlFetch({ gateway:\n * 'workspace', workspaceToken: true })` — so no ApolloProvider is required.\n * These hooks live in a SEPARATE file by design; `useTheGlobalFuelApi.ts` is\n * left untouched.\n */\n\nimport { useCallback, useState } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useTheGlobalFuel } from '../context';\n\n// ============================================================================\n// Shared workspace-gateway transport (reused by the comments + tags hooks too)\n// ============================================================================\n\ntype GraphqlReadCacheGlobals = {\n __graphqlFetchResponseCache?: { clear: () => void };\n __graphqlFetchPendingResponses?: { clear: () => void };\n __boffGraphQLResponseCache?: { clear: () => void };\n};\n\n/**\n * fe-libs `graphqlFetch` coalesces `query` responses in a short-lived in-memory\n * cache. After a write we drop those caches so the invalidation refetch that\n * follows reads fresh data (same remedy `useTheGlobalFuelApi` applies).\n */\nconst clearGraphqlReadCaches = (): void => {\n const g = globalThis as GraphqlReadCacheGlobals;\n g.__graphqlFetchResponseCache?.clear();\n g.__graphqlFetchPendingResponses?.clear();\n g.__boffGraphQLResponseCache?.clear();\n};\n\n/** Execute a workspace-gateway GraphQL operation with the workspace token. */\nexport const wspaceFetch = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n if (/^\\s*mutation\\b/.test(query)) {\n clearGraphqlReadCaches();\n }\n return response.data;\n};\n\n// ============================================================================\n// File upload (initiate → PUT → complete)\n// ============================================================================\n\nexport interface UploadedTheFile {\n fileId: string;\n fileName: string;\n}\n\n/** `PUT` the blob to the signed URL, reporting byte-progress via `onProgress`. */\nfunction putWithProgress(\n url: string,\n file: File,\n contentType: string,\n onProgress: (percent: number) => void\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.open('PUT', url);\n xhr.setRequestHeader('Content-Type', contentType);\n xhr.upload.onprogress = (event) => {\n if (event.lengthComputable) {\n onProgress(Math.round((event.loaded / event.total) * 100));\n }\n };\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n resolve();\n } else {\n reject(new Error(`File storage rejected the upload (HTTP ${xhr.status}).`));\n }\n };\n xhr.onerror = () => reject(new Error('Network error while uploading the file.'));\n xhr.onabort = () => reject(new Error('The upload was cancelled.'));\n xhr.send(file);\n });\n}\n\nexport interface UseTheFileUploadResult {\n upload: (file: File) => Promise<UploadedTheFile>;\n isUploading: boolean;\n /** 0–100 byte-progress of the signed-URL PUT. */\n progress: number;\n error: string | null;\n reset: () => void;\n}\n\n/**\n * Imperative upload hook: `await upload(file)` runs the platform 3-step flow and\n * resolves to `{ fileId, fileName }`. `fileId` is what the theglobalfuel mutations accept\n * (`ecoRecordObservation.evidenceFileId`, `ecoPublishReport.fileId`).\n */\nexport const useTheFileUpload = (): UseTheFileUploadResult => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const [isUploading, setIsUploading] = useState(false);\n const [progress, setProgress] = useState(0);\n const [error, setError] = useState<string | null>(null);\n\n const reset = useCallback(() => {\n setIsUploading(false);\n setProgress(0);\n setError(null);\n }, []);\n\n const upload = useCallback(\n async (file: File): Promise<UploadedTheFile> => {\n setIsUploading(true);\n setProgress(0);\n setError(null);\n try {\n const dotIndex = file.name.lastIndexOf('.');\n const extension = dotIndex > -1 ? file.name.slice(dotIndex + 1) : '';\n const mimeType = file.type || 'application/octet-stream';\n\n // 1. initiate\n const initiated = await wspaceFetch<{\n initiateUpload: { uploadUrl: string | null; session: { id: string } };\n }>(\n `mutation TheInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id }\n }\n }`,\n {\n input: {\n fileName: file.name,\n extension,\n mimeType,\n fileSize: String(file.size),\n visibility: 'WORKSPACE',\n },\n },\n apiGatewayUrl\n );\n\n const { uploadUrl } = initiated.initiateUpload;\n const sessionId = initiated.initiateUpload.session.id;\n if (!uploadUrl) {\n throw new Error('The file service did not return an upload URL.');\n }\n\n // 2. PUT the bytes\n await putWithProgress(uploadUrl, file, mimeType, setProgress);\n\n // 3. complete\n const completed = await wspaceFetch<{\n completeUpload: { fileId: string; file: { id: string; name: string } | null };\n }>(\n `mutation TheCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) {\n fileId\n file { id name }\n }\n }`,\n { input: { sessionId } },\n apiGatewayUrl\n );\n\n setProgress(100);\n return {\n fileId: completed.completeUpload.fileId,\n fileName: completed.completeUpload.file?.name ?? file.name,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : 'The file could not be uploaded.';\n setError(message);\n throw err instanceof Error ? err : new Error(message);\n } finally {\n setIsUploading(false);\n }\n },\n [apiGatewayUrl]\n );\n\n return { upload, isUploading, progress, error, reset };\n};\n\n// ============================================================================\n// Resolve an existing file (name + download URL) for rendering evidence links\n// ============================================================================\n\nexport interface TheFileMeta {\n id: string;\n name: string;\n downloadUrl: string | null;\n mimeType: string;\n size: string;\n}\n\nexport const useTheFile = (id: string | null | undefined) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: ['theglobalfuel', 'file', id ?? ''],\n enabled: Boolean(id),\n queryFn: async () => {\n const data = await wspaceFetch<{ getFile: TheFileMeta | null }>(\n `query TheGetFile($id: ID!) {\n getFile(id: $id) {\n id\n name\n downloadUrl\n mimeType\n size\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.getFile;\n },\n });\n};\n"],"mappings":";;;;;;AAwCA,IAAM,UAAqC;CACzC,IAAM,IAAI;AAGV,CAFA,EAAE,6BAA6B,OAAO,EACtC,EAAE,gCAAgC,OAAO,EACzC,EAAE,4BAA4B,OAAO;GAI1B,IAAc,OACzB,GACA,GACA,MACmB;CACnB,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;EACjB,CAAC;AAEF,KAAI,EAAS,QAAQ,OACnB,OAAU,MAAM,EAAS,OAAO,IAAI,WAAW,yBAAyB;AAE1E,KAAI,CAAC,EAAS,KACZ,OAAU,MAAM,wCAAwC;AAK1D,QAHI,iBAAiB,KAAK,EAAM,IAC9B,GAAwB,EAEnB,EAAS;;AAalB,SAAS,EACP,GACA,GACA,GACA,GACe;AACf,QAAO,IAAI,SAAe,GAAS,MAAW;EAC5C,IAAM,IAAM,IAAI,gBAAgB;AAiBhC,EAhBA,EAAI,KAAK,OAAO,EAAI,EACpB,EAAI,iBAAiB,gBAAgB,EAAY,EACjD,EAAI,OAAO,cAAc,MAAU;AACjC,GAAI,EAAM,oBACR,EAAW,KAAK,MAAO,EAAM,SAAS,EAAM,QAAS,IAAI,CAAC;KAG9D,EAAI,eAAe;AACjB,GAAI,EAAI,UAAU,OAAO,EAAI,SAAS,MACpC,GAAS,GAET,EAAO,gBAAI,MAAM,0CAA0C,EAAI,OAAO,IAAI,CAAC;KAG/E,EAAI,gBAAgB,EAAO,gBAAI,MAAM,0CAA0C,CAAC,EAChF,EAAI,gBAAgB,EAAO,gBAAI,MAAM,4BAA4B,CAAC,EAClE,EAAI,KAAK,EAAK;GACd;;AAiBJ,IAAa,UAAiD;CAC5D,IAAM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;GAAQ,KAAM;GAAG;EAC7C,SAAS,EAAQ;EACjB,SAAS,aACM,MAAM,EACjB,yLASA,EAAE,OAAI,EACN,EACD,EACW;EAEf,CAAC"}
1
+ {"version":3,"file":"useTheFiles.js","names":[],"sources":["../../../src/theglobalfuel/hooks/useTheFiles.ts"],"sourcesContent":["/**\n * TheGlobalFuel — wspace-files-svc REUSE hooks (Integration A).\n * @module theglobalfuel/hooks/useTheFiles\n *\n * Reuses the platform file store (`wspace-files-svc`) WITHOUT any eco-svc\n * change: the theglobalfuel schema already exposes `TheObservation.evidenceFileId` /\n * `TheReport.fileId`; this module lets the UI actually produce a `fileId` via\n * the canonical 3-step upload flow composed into the WORKSPACE supergraph:\n * 1. `initiateUpload(input)` → `{ uploadUrl, session { id } }`\n * 2. HTTP `PUT` the bytes to the returned signed `uploadUrl`\n * 3. `completeUpload(input: { sessionId })` → `{ fileId }`\n * plus `getFile(id)` to resolve an existing evidence/report file's name + URL.\n *\n * Transport mirrors `useTheGlobalFuelApi` exactly — `graphqlFetch({ gateway:\n * 'workspace', workspaceToken: true })` — so no ApolloProvider is required.\n * These hooks live in a SEPARATE file by design; `useTheGlobalFuelApi.ts` is\n * left untouched.\n */\n\nimport { useCallback, useState } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useTheGlobalFuel } from '../context';\n\n// ============================================================================\n// Shared workspace-gateway transport (reused by the comments + tags hooks too)\n// ============================================================================\n\ntype GraphqlReadCacheGlobals = {\n __graphqlFetchResponseCache?: { clear: () => void };\n __graphqlFetchPendingResponses?: { clear: () => void };\n __boffGraphQLResponseCache?: { clear: () => void };\n};\n\n/**\n * fe-libs `graphqlFetch` coalesces `query` responses in a short-lived in-memory\n * cache. After a write we drop those caches so the invalidation refetch that\n * follows reads fresh data (same remedy `useTheGlobalFuelApi` applies).\n */\nconst clearGraphqlReadCaches = (): void => {\n const g = globalThis as GraphqlReadCacheGlobals;\n g.__graphqlFetchResponseCache?.clear();\n g.__graphqlFetchPendingResponses?.clear();\n g.__boffGraphQLResponseCache?.clear();\n};\n\n/** Execute a workspace-gateway GraphQL operation with the workspace token. */\nexport const wspaceFetch = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n if (/^\\s*mutation\\b/.test(query)) {\n clearGraphqlReadCaches();\n }\n return response.data;\n};\n\n// ============================================================================\n// File upload (initiate → PUT → complete)\n// ============================================================================\n\nexport interface UploadedTheFile {\n fileId: string;\n fileName: string;\n}\n\n/** `PUT` the blob to the signed URL, reporting byte-progress via `onProgress`. */\nfunction putWithProgress(\n url: string,\n file: File,\n contentType: string,\n onProgress: (percent: number) => void\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.open('PUT', url);\n xhr.setRequestHeader('Content-Type', contentType);\n xhr.upload.onprogress = (event) => {\n if (event.lengthComputable) {\n onProgress(Math.round((event.loaded / event.total) * 100));\n }\n };\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n resolve();\n } else {\n reject(new Error(`File storage rejected the upload (HTTP ${xhr.status}).`));\n }\n };\n xhr.onerror = () => reject(new Error('Network error while uploading the file.'));\n xhr.onabort = () => reject(new Error('The upload was cancelled.'));\n xhr.send(file);\n });\n}\n\nexport interface UseTheFileUploadResult {\n upload: (file: File) => Promise<UploadedTheFile>;\n isUploading: boolean;\n /** 0–100 byte-progress of the signed-URL PUT. */\n progress: number;\n error: string | null;\n reset: () => void;\n}\n\n/**\n * Imperative upload hook: `await upload(file)` runs the platform 3-step flow and\n * resolves to `{ fileId, fileName }`. `fileId` is what the theglobalfuel mutations accept\n * (`ecoRecordObservation.evidenceFileId`, `ecoPublishReport.fileId`).\n */\nexport const useTheFileUpload = (): UseTheFileUploadResult => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const [isUploading, setIsUploading] = useState(false);\n const [progress, setProgress] = useState(0);\n const [error, setError] = useState<string | null>(null);\n\n const reset = useCallback(() => {\n setIsUploading(false);\n setProgress(0);\n setError(null);\n }, []);\n\n const upload = useCallback(\n async (file: File): Promise<UploadedTheFile> => {\n setIsUploading(true);\n setProgress(0);\n setError(null);\n try {\n const dotIndex = file.name.lastIndexOf('.');\n const extension = dotIndex > -1 ? file.name.slice(dotIndex + 1) : '';\n const mimeType = file.type || 'application/octet-stream';\n\n // 1. initiate\n const initiated = await wspaceFetch<{\n initiateUpload: { uploadUrl: string | null; session: { id: string } };\n }>(\n `mutation TheInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id }\n }\n }`,\n {\n input: {\n fileName: file.name,\n extension,\n mimeType,\n fileSize: String(file.size),\n visibility: 'WORKSPACE',\n },\n },\n apiGatewayUrl\n );\n\n const { uploadUrl } = initiated.initiateUpload;\n const sessionId = initiated.initiateUpload.session.id;\n if (!uploadUrl) {\n throw new Error('The file service did not return an upload URL.');\n }\n\n // 2. PUT the bytes\n await putWithProgress(uploadUrl, file, mimeType, setProgress);\n\n // 3. complete\n const completed = await wspaceFetch<{\n completeUpload: { fileId: string; file: { id: string; name: string } | null };\n }>(\n `mutation TheCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) {\n fileId\n file { id name }\n }\n }`,\n // `fileSize` is required by wspace-files-svc completeUpload for quota\n // tracking and MUST match the fileSize passed to initiateUpload — omitting\n // it makes the resolver throw INTERNAL_SERVER_ERROR.\n { input: { sessionId, fileSize: String(file.size) } },\n apiGatewayUrl\n );\n\n setProgress(100);\n return {\n fileId: completed.completeUpload.fileId,\n fileName: completed.completeUpload.file?.name ?? file.name,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : 'The file could not be uploaded.';\n setError(message);\n throw err instanceof Error ? err : new Error(message);\n } finally {\n setIsUploading(false);\n }\n },\n [apiGatewayUrl]\n );\n\n return { upload, isUploading, progress, error, reset };\n};\n\n// ============================================================================\n// Resolve an existing file (name + download URL) for rendering evidence links\n// ============================================================================\n\nexport interface TheFileMeta {\n id: string;\n name: string;\n downloadUrl: string | null;\n mimeType: string;\n size: string;\n}\n\nexport const useTheFile = (id: string | null | undefined) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: ['theglobalfuel', 'file', id ?? ''],\n enabled: Boolean(id),\n queryFn: async () => {\n const data = await wspaceFetch<{ getFile: TheFileMeta | null }>(\n `query TheGetFile($id: ID!) {\n getFile(id: $id) {\n id\n name\n downloadUrl\n mimeType\n size\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.getFile;\n },\n });\n};\n"],"mappings":";;;;;;AAwCA,IAAM,UAAqC;CACzC,IAAM,IAAI;AAGV,CAFA,EAAE,6BAA6B,OAAO,EACtC,EAAE,gCAAgC,OAAO,EACzC,EAAE,4BAA4B,OAAO;GAI1B,IAAc,OACzB,GACA,GACA,MACmB;CACnB,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;EACjB,CAAC;AAEF,KAAI,EAAS,QAAQ,OACnB,OAAU,MAAM,EAAS,OAAO,IAAI,WAAW,yBAAyB;AAE1E,KAAI,CAAC,EAAS,KACZ,OAAU,MAAM,wCAAwC;AAK1D,QAHI,iBAAiB,KAAK,EAAM,IAC9B,GAAwB,EAEnB,EAAS;;AAalB,SAAS,EACP,GACA,GACA,GACA,GACe;AACf,QAAO,IAAI,SAAe,GAAS,MAAW;EAC5C,IAAM,IAAM,IAAI,gBAAgB;AAiBhC,EAhBA,EAAI,KAAK,OAAO,EAAI,EACpB,EAAI,iBAAiB,gBAAgB,EAAY,EACjD,EAAI,OAAO,cAAc,MAAU;AACjC,GAAI,EAAM,oBACR,EAAW,K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IAAI,EACT;KACL,QAAQ,EAAU,eAAe;KACjC,UAAU,EAAU,eAAe,MAAM,QAAQ,EAAK;KACvD;YACM,GAAK;IACZ,IAAM,IAAU,aAAe,QAAQ,EAAI,UAAU;AAErD,UADA,EAAS,EAAQ,EACX,aAAe,QAAQ,IAAU,MAAM,EAAQ;aAC7C;AACR,MAAe,GAAM;;KAGzB,CAAC,EAAc,CAChB;EAEgB;EAAa;EAAU;EAAO;EAAO;GAe3C,KAAc,MAAkC;CAC3D,IAAM,EAAE,qBAAkB,GAAkB;AAC5C,QAAO,EAAS;EACd,UAAU;GAAC;GAAiB;GAAQ,KAAM;GAAG;EAC7C,SAAS,EAAQ;EACjB,SAAS,aACM,MAAM,EACjB,yLASA,EAAE,OAAI,EACN,EACD,EACW;EAEf,CAAC"}
@@ -121,20 +121,25 @@ var a = () => {
121
121
  i.invalidateQueries({ queryKey: s.production }), i.invalidateQueries({ queryKey: s.asset(e.assetId) });
122
122
  }
123
123
  });
124
- }, w = (t, r) => {
125
- let { apiGatewayUrl: i } = e();
124
+ }, w = (t, r, i) => {
125
+ let { apiGatewayUrl: a } = e();
126
126
  return n({
127
127
  queryKey: [
128
128
  ...s.reserves,
129
129
  t ?? null,
130
- r ?? null
130
+ r ?? null,
131
+ i ?? null
131
132
  ],
132
- queryFn: async () => (await o(`query TheListReserveEstimates($assetId: ID, $category: TheReserveCategory) {
133
- theListReserveEstimates(assetId: $assetId, category: $category) { ${d} }
133
+ queryFn: async () => (await o(`query TheListReserveEstimates($assetId: ID, $category: TheReserveCategory, $pagination: PaginationInput) {
134
+ theListReserveEstimates(assetId: $assetId, category: $category, pagination: $pagination) {
135
+ items { ${d} }
136
+ pageInfo { cursor hasMore }
137
+ }
134
138
  }`, {
135
139
  assetId: t,
136
- category: r
137
- }, i)).theListReserveEstimates
140
+ category: r,
141
+ pagination: i ?? c
142
+ }, a)).theListReserveEstimates
138
143
  });
139
144
  }, T = () => {
140
145
  let { apiGatewayUrl: n } = e(), i = r();
@@ -208,22 +213,40 @@ var a = () => {
208
213
  i.invalidateQueries({ queryKey: s.contracts }), i.invalidateQueries({ queryKey: s.contract(e.id) });
209
214
  }
210
215
  });
211
- }, j = (t, r) => {
212
- let { apiGatewayUrl: i } = e();
216
+ }, j = (t, r, i) => {
217
+ let { apiGatewayUrl: a } = e();
213
218
  return n({
214
219
  queryKey: [
215
220
  ...s.shipments,
216
221
  t ?? null,
217
- r ?? null
222
+ r ?? null,
223
+ i ?? null
218
224
  ],
219
- queryFn: async () => (await o(`query TheListShipments($contractId: ID, $status: TheShipmentStatus) {
220
- theListShipments(contractId: $contractId, status: $status) { ${p} }
225
+ queryFn: async () => (await o(`query TheListShipments($contractId: ID, $status: TheShipmentStatus, $pagination: PaginationInput) {
226
+ theListShipments(contractId: $contractId, status: $status, pagination: $pagination) {
227
+ items { ${p} }
228
+ pageInfo { cursor hasMore }
229
+ }
221
230
  }`, {
222
231
  contractId: t,
223
- status: r
224
- }, i)).theListShipments
232
+ status: r,
233
+ pagination: i ?? c
234
+ }, a)).theListShipments
225
235
  });
226
236
  }, M = () => {
237
+ let { apiGatewayUrl: n } = e(), i = r();
238
+ return t({
239
+ mutationFn: async ({ id: e, status: t }) => (await o(`mutation TheTransitionShipment($id: ID!, $status: TheShipmentStatus!) {
240
+ theTransitionShipment(id: $id, status: $status) { ${p} }
241
+ }`, {
242
+ id: e,
243
+ status: t
244
+ }, n)).theTransitionShipment,
245
+ onSuccess: (e) => {
246
+ i.invalidateQueries({ queryKey: s.shipments }), i.invalidateQueries({ queryKey: s.contract(e.contractId) });
247
+ }
248
+ });
249
+ }, N = () => {
227
250
  let { apiGatewayUrl: n } = e(), i = r();
228
251
  return t({
229
252
  mutationFn: async (e) => (await o(`mutation TheScheduleShipment($input: TheCreateShipmentInput!) {
@@ -233,7 +256,7 @@ var a = () => {
233
256
  i.invalidateQueries({ queryKey: s.shipments }), i.invalidateQueries({ queryKey: s.contract(e.contractId) });
234
257
  }
235
258
  });
236
- }, N = () => {
259
+ }, P = () => {
237
260
  let { apiGatewayUrl: n } = e(), i = r();
238
261
  return t({
239
262
  mutationFn: async (e) => (await o(`mutation TheDeliverShipment($id: ID!) {
@@ -243,7 +266,7 @@ var a = () => {
243
266
  i.invalidateQueries({ queryKey: s.shipments }), i.invalidateQueries({ queryKey: s.contracts }), i.invalidateQueries({ queryKey: s.contract(e.contractId) });
244
267
  }
245
268
  });
246
- }, P = (t = {}) => {
269
+ }, F = (t = {}) => {
247
270
  let { apiGatewayUrl: r } = e();
248
271
  return n({
249
272
  queryKey: [...s.inventory, t],
@@ -258,7 +281,7 @@ var a = () => {
258
281
  pagination: t.pagination ?? c
259
282
  }, r)).theListInventoryLots
260
283
  });
261
- }, F = () => {
284
+ }, I = () => {
262
285
  let { apiGatewayUrl: n } = e(), i = r();
263
286
  return t({
264
287
  mutationFn: async (e) => (await o(`mutation TheCreateInventoryLot($input: TheCreateInventoryLotInput!) {
@@ -266,7 +289,7 @@ var a = () => {
266
289
  }`, { input: e }, n)).theCreateInventoryLot,
267
290
  onSuccess: () => i.invalidateQueries({ queryKey: s.inventory })
268
291
  });
269
- }, I = () => {
292
+ }, L = () => {
270
293
  let { apiGatewayUrl: n } = e(), i = r();
271
294
  return t({
272
295
  mutationFn: async ({ id: e, status: t }) => (await o(`mutation TheSetInventoryLotStatus($id: ID!, $status: TheInventoryStatus!) {
@@ -277,7 +300,7 @@ var a = () => {
277
300
  }, n)).theSetInventoryLotStatus,
278
301
  onSuccess: () => i.invalidateQueries({ queryKey: s.inventory })
279
302
  });
280
- }, L = (t = {}) => {
303
+ }, R = (t = {}) => {
281
304
  let { apiGatewayUrl: r } = e();
282
305
  return n({
283
306
  queryKey: [...s.emissions, t],
@@ -292,7 +315,7 @@ var a = () => {
292
315
  pagination: t.pagination ?? c
293
316
  }, r)).theListEmissionRecords
294
317
  });
295
- }, R = () => {
318
+ }, z = () => {
296
319
  let { apiGatewayUrl: n } = e(), i = r();
297
320
  return t({
298
321
  mutationFn: async (e) => (await o(`mutation TheRecordEmission($input: TheRecordEmissionInput!) {
@@ -300,7 +323,7 @@ var a = () => {
300
323
  }`, { input: e }, n)).theRecordEmission,
301
324
  onSuccess: () => i.invalidateQueries({ queryKey: s.emissions })
302
325
  });
303
- }, z = () => {
326
+ }, B = () => {
304
327
  let { apiGatewayUrl: n } = e(), i = r();
305
328
  return t({
306
329
  mutationFn: async (e) => (await o(`mutation TheVerifyEmission($id: ID!) {
@@ -308,24 +331,29 @@ var a = () => {
308
331
  }`, { id: e }, n)).theVerifyEmission,
309
332
  onSuccess: () => i.invalidateQueries({ queryKey: s.emissions })
310
333
  });
311
- }, B = (t, r, i) => {
312
- let { apiGatewayUrl: a } = e();
334
+ }, V = (t, r, i, a) => {
335
+ let { apiGatewayUrl: l } = e();
313
336
  return n({
314
337
  queryKey: [
315
338
  ...s.compliance,
316
339
  t ?? null,
317
340
  r ?? null,
318
- i ?? null
341
+ i ?? null,
342
+ a ?? null
319
343
  ],
320
- queryFn: async () => (await o(`query TheListComplianceCerts($assetId: ID, $category: TheComplianceCategory, $status: TheComplianceStatus) {
321
- theListComplianceCerts(assetId: $assetId, category: $category, status: $status) { ${g} }
344
+ queryFn: async () => (await o(`query TheListComplianceCerts($assetId: ID, $category: TheComplianceCategory, $status: TheComplianceStatus, $pagination: PaginationInput) {
345
+ theListComplianceCerts(assetId: $assetId, category: $category, status: $status, pagination: $pagination) {
346
+ items { ${g} }
347
+ pageInfo { cursor hasMore }
348
+ }
322
349
  }`, {
323
350
  assetId: t,
324
351
  category: r,
325
- status: i
326
- }, a)).theListComplianceCerts
352
+ status: i,
353
+ pagination: a ?? c
354
+ }, l)).theListComplianceCerts
327
355
  });
328
- }, V = () => {
356
+ }, H = () => {
329
357
  let { apiGatewayUrl: n } = e(), i = r();
330
358
  return t({
331
359
  mutationFn: async (e) => (await o(`mutation TheCreateComplianceCert($input: TheCreateComplianceCertInput!) {
@@ -333,7 +361,7 @@ var a = () => {
333
361
  }`, { input: e }, n)).theCreateComplianceCert,
334
362
  onSuccess: () => i.invalidateQueries({ queryKey: s.compliance })
335
363
  });
336
- }, H = () => {
364
+ }, U = () => {
337
365
  let { apiGatewayUrl: n } = e(), i = r();
338
366
  return t({
339
367
  mutationFn: async ({ id: e, status: t }) => (await o(`mutation TheTransitionComplianceCert($id: ID!, $status: TheComplianceStatus!) {
@@ -348,6 +376,6 @@ var a = () => {
348
376
  });
349
377
  };
350
378
  //#endregion
351
- export { v as useTheAsset, _ as useTheAssets, B as useTheComplianceCerts, D as useTheContract, E as useTheContracts, y as useTheCreateAsset, V as useTheCreateComplianceCert, O as useTheCreateContract, F as useTheCreateInventoryLot, T as useTheCreateReserveEstimate, N as useTheDeliverShipment, L as useTheEmissionRecords, P as useTheInventoryLots, S as useTheProductionRecords, R as useTheRecordEmission, C as useTheRecordProduction, w as useTheReserveEstimates, x as useTheRetireAsset, M as useTheScheduleShipment, I as useTheSetInventoryLotStatus, j as useTheShipments, b as useTheTransitionAsset, H as useTheTransitionComplianceCert, A as useTheTransitionContract, k as useTheUpdateContract, z as useTheVerifyEmission };
379
+ export { v as useTheAsset, _ as useTheAssets, V as useTheComplianceCerts, D as useTheContract, E as useTheContracts, y as useTheCreateAsset, H as useTheCreateComplianceCert, O as useTheCreateContract, I as useTheCreateInventoryLot, T as useTheCreateReserveEstimate, P as useTheDeliverShipment, R as useTheEmissionRecords, F as useTheInventoryLots, S as useTheProductionRecords, z as useTheRecordEmission, C as useTheRecordProduction, w as useTheReserveEstimates, x as useTheRetireAsset, N as useTheScheduleShipment, L as useTheSetInventoryLotStatus, j as useTheShipments, b as useTheTransitionAsset, U as useTheTransitionComplianceCert, A as useTheTransitionContract, M as useTheTransitionShipment, k as useTheUpdateContract, B as useTheVerifyEmission };
352
380
 
353
381
  //# sourceMappingURL=useTheGlobalFuelApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTheGlobalFuelApi.js","names":[],"sources":["../../../src/theglobalfuel/hooks/useTheGlobalFuelApi.ts"],"sourcesContent":["/**\n * TheGlobalFuel API hooks\n * @module theglobalfuel/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-theglobalfuel-svc`\n * federated GraphQL contract (the `the*` operations). Every query/mutation\n * below uses an inline gql string whose fields match the svc\n * `.hive-schema.graphql` exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` —\n * the host shell supplies the gateway base URL + a workspace-scoped token.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useTheGlobalFuel } from '../context';\nimport type {\n TheConnection,\n TheAsset,\n TheAssetKind,\n TheAssetStatus,\n TheCommodityType,\n TheProductionRecord,\n TheReserveEstimate,\n TheReserveCategory,\n TheOfftakeContract,\n TheContractSide,\n TheContractStatus,\n TheShipment,\n TheShipmentStatus,\n TheInventoryLot,\n TheInventoryStatus,\n TheEmissionRecord,\n TheEmissionScope,\n TheComplianceCert,\n TheComplianceCategory,\n TheComplianceStatus,\n TheCreateAssetInput,\n TheUpdateAssetInput,\n TheRecordProductionInput,\n TheCreateReserveEstimateInput,\n TheCreateOfftakeContractInput,\n TheUpdateOfftakeContractInput,\n TheCreateShipmentInput,\n TheCreateInventoryLotInput,\n TheRecordEmissionInput,\n TheCreateComplianceCertInput,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\ntype GraphqlReadCacheGlobals = {\n __graphqlFetchResponseCache?: { clear: () => void };\n __graphqlFetchPendingResponses?: { clear: () => void };\n __boffGraphQLResponseCache?: { clear: () => void };\n};\n\n/**\n * fe-libs `graphqlFetch` coalesces `query` responses in a short-lived in-memory\n * cache keyed by operationName+variables (~15s; mutations never cached). A read\n * issued right after a write would otherwise return the pre-mutation snapshot\n * until the TTL expires — making just-created rows invisible. We clear those\n * caches after every mutation so every follow-up refetch reads fresh.\n */\nconst clearGraphqlReadCaches = (): void => {\n const g = globalThis as GraphqlReadCacheGlobals;\n g.__graphqlFetchResponseCache?.clear();\n g.__graphqlFetchPendingResponses?.clear();\n g.__boffGraphQLResponseCache?.clear();\n};\n\nconst theQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n if (/^\\s*mutation\\b/.test(query)) {\n clearGraphqlReadCaches();\n }\n return response.data;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n assets: ['theglobalfuel', 'assets'] as const,\n asset: (id: string) => ['theglobalfuel', 'asset', id] as const,\n production: ['theglobalfuel', 'production'] as const,\n reserves: ['theglobalfuel', 'reserves'] as const,\n contracts: ['theglobalfuel', 'contracts'] as const,\n contract: (id: string) => ['theglobalfuel', 'contract', id] as const,\n shipments: ['theglobalfuel', 'shipments'] as const,\n inventory: ['theglobalfuel', 'inventory'] as const,\n emissions: ['theglobalfuel', 'emissions'] as const,\n compliance: ['theglobalfuel', 'compliance'] as const,\n complianceCert: (id: string) => ['theglobalfuel', 'compliance', id] as const,\n};\n\nconst DEFAULT_PAGE: PaginationInput = { limit: 50 };\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness)\n// ============================================================================\n\nconst ASSET_FIELDS = `\n id workspaceId name code kind commodity status location latitude longitude\n capacityPerDay capacityUnit workingInterestPct operatorLeadId\n commissionedAt decommissionedAt tags createdAt updatedAt\n`;\n\nconst PRODUCTION_FIELDS = `\n id workspaceId assetId periodStart periodEnd volume unit grade downtimeHours\n notes createdAt updatedAt\n`;\n\nconst RESERVE_FIELDS = `\n id workspaceId assetId category asOfDate recoverable recoveryFactor unit\n methodology notes createdAt updatedAt\n`;\n\nconst CONTRACT_FIELDS = `\n id workspaceId reference counterparty commodity side status pricingBasis\n pricePerUnit priceIndex currency contractedVolume deliveredVolume unit\n deliveryLocation startDate endDate signedAt notes tags createdAt updatedAt\n`;\n\nconst SHIPMENT_FIELDS = `\n id workspaceId contractId reference mode status carrier origin destination\n volume unit scheduledAt departedAt deliveredAt document { id } notes\n createdAt updatedAt\n`;\n\nconst INVENTORY_FIELDS = `\n id workspaceId lotCode commodity assetId quantity unit grade status location\n unitValue currency producedAt notes createdAt updatedAt\n`;\n\nconst EMISSION_FIELDS = `\n id workspaceId assetId scope co2eTonnes periodStart periodEnd source\n methodology verified verifiedAt notes createdAt updatedAt\n`;\n\nconst COMPLIANCE_FIELDS = `\n id workspaceId title category status assetId authority certNumber ownerId\n issuedAt expiresAt evidence { id } notes tags createdAt updatedAt\n`;\n\n// ============================================================================\n// Registry — Assets\n// ============================================================================\n\nexport interface AssetFilters {\n commodity?: TheCommodityType;\n kind?: TheAssetKind;\n status?: TheAssetStatus;\n pagination?: PaginationInput;\n}\n\nexport const useTheAssets = (filters: AssetFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.assets, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListAssets: TheConnection<TheAsset> }>(\n `query TheListAssets($commodity: TheCommodityType, $kind: TheAssetKind, $status: TheAssetStatus, $pagination: PaginationInput) {\n theListAssets(commodity: $commodity, kind: $kind, status: $status, pagination: $pagination) {\n items { ${ASSET_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n commodity: filters.commodity,\n kind: filters.kind,\n status: filters.status,\n pagination: filters.pagination ?? DEFAULT_PAGE,\n },\n apiGatewayUrl\n );\n return data.theListAssets;\n },\n });\n};\n\nexport const useTheAsset = (id: string | undefined) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: KEY.asset(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const data = await theQuery<{ theAsset: TheAsset | null }>(\n `query TheAsset($id: ID!) {\n theAsset(id: $id) {\n ${ASSET_FIELDS}\n productionRecords { ${PRODUCTION_FIELDS} }\n reserveEstimates { ${RESERVE_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theAsset;\n },\n });\n};\n\nexport const useTheCreateAsset = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateAssetInput) => {\n const data = await theQuery<{ theCreateAsset: TheAsset }>(\n `mutation TheCreateAsset($input: TheCreateAssetInput!) {\n theCreateAsset(input: $input) { ${ASSET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateAsset;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.assets }),\n });\n};\n\nexport const useTheUpdateAsset = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, input }: { id: string; input: TheUpdateAssetInput }) => {\n const data = await theQuery<{ theUpdateAsset: TheAsset }>(\n `mutation TheUpdateAsset($id: ID!, $input: TheUpdateAssetInput!) {\n theUpdateAsset(id: $id, input: $input) { ${ASSET_FIELDS} }\n }`,\n { id, input },\n apiGatewayUrl\n );\n return data.theUpdateAsset;\n },\n onSuccess: (asset) => {\n qc.invalidateQueries({ queryKey: KEY.assets });\n qc.invalidateQueries({ queryKey: KEY.asset(asset.id) });\n },\n });\n};\n\nexport const useTheTransitionAsset = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: TheAssetStatus }) => {\n const data = await theQuery<{ theTransitionAsset: TheAsset }>(\n `mutation TheTransitionAsset($id: ID!, $status: TheAssetStatus!) {\n theTransitionAsset(id: $id, status: $status) { ${ASSET_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return data.theTransitionAsset;\n },\n onSuccess: (asset) => {\n qc.invalidateQueries({ queryKey: KEY.assets });\n qc.invalidateQueries({ queryKey: KEY.asset(asset.id) });\n },\n });\n};\n\nexport const useTheRetireAsset = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await theQuery<{ theRetireAsset: boolean }>(\n `mutation TheRetireAsset($id: ID!) { theRetireAsset(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return data.theRetireAsset;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.assets }),\n });\n};\n\n// ============================================================================\n// Registry — Production records\n// ============================================================================\n\nexport interface ProductionFilters {\n assetId?: string;\n pagination?: PaginationInput;\n}\n\nexport const useTheProductionRecords = (filters: ProductionFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.production, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListProductionRecords: TheConnection<TheProductionRecord> }>(\n `query TheListProductionRecords($assetId: ID, $pagination: PaginationInput) {\n theListProductionRecords(assetId: $assetId, pagination: $pagination) {\n items { ${PRODUCTION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { assetId: filters.assetId, pagination: filters.pagination ?? DEFAULT_PAGE },\n apiGatewayUrl\n );\n return data.theListProductionRecords;\n },\n });\n};\n\nexport const useTheRecordProduction = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheRecordProductionInput) => {\n const data = await theQuery<{ theRecordProduction: TheProductionRecord }>(\n `mutation TheRecordProduction($input: TheRecordProductionInput!) {\n theRecordProduction(input: $input) { ${PRODUCTION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theRecordProduction;\n },\n onSuccess: (rec) => {\n qc.invalidateQueries({ queryKey: KEY.production });\n qc.invalidateQueries({ queryKey: KEY.asset(rec.assetId) });\n },\n });\n};\n\n// ============================================================================\n// Registry — Reserve estimates\n// ============================================================================\n\nexport const useTheReserveEstimates = (assetId?: string, category?: TheReserveCategory) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.reserves, assetId ?? null, category ?? null],\n queryFn: async () => {\n const data = await theQuery<{ theListReserveEstimates: TheReserveEstimate[] }>(\n `query TheListReserveEstimates($assetId: ID, $category: TheReserveCategory) {\n theListReserveEstimates(assetId: $assetId, category: $category) { ${RESERVE_FIELDS} }\n }`,\n { assetId, category },\n apiGatewayUrl\n );\n return data.theListReserveEstimates;\n },\n });\n};\n\nexport const useTheCreateReserveEstimate = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateReserveEstimateInput) => {\n const data = await theQuery<{ theCreateReserveEstimate: TheReserveEstimate }>(\n `mutation TheCreateReserveEstimate($input: TheCreateReserveEstimateInput!) {\n theCreateReserveEstimate(input: $input) { ${RESERVE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateReserveEstimate;\n },\n onSuccess: (rec) => {\n qc.invalidateQueries({ queryKey: KEY.reserves });\n qc.invalidateQueries({ queryKey: KEY.asset(rec.assetId) });\n },\n });\n};\n\n// ============================================================================\n// Commerce — Offtake contracts\n// ============================================================================\n\nexport interface ContractFilters {\n commodity?: TheCommodityType;\n side?: TheContractSide;\n status?: TheContractStatus;\n pagination?: PaginationInput;\n}\n\nexport const useTheContracts = (filters: ContractFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.contracts, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListContracts: TheConnection<TheOfftakeContract> }>(\n `query TheListContracts($commodity: TheCommodityType, $side: TheContractSide, $status: TheContractStatus, $pagination: PaginationInput) {\n theListContracts(commodity: $commodity, side: $side, status: $status, pagination: $pagination) {\n items { ${CONTRACT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n commodity: filters.commodity,\n side: filters.side,\n status: filters.status,\n pagination: filters.pagination ?? DEFAULT_PAGE,\n },\n apiGatewayUrl\n );\n return data.theListContracts;\n },\n });\n};\n\nexport const useTheContract = (id: string | undefined) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: KEY.contract(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const data = await theQuery<{ theContract: TheOfftakeContract | null }>(\n `query TheContract($id: ID!) {\n theContract(id: $id) {\n ${CONTRACT_FIELDS}\n shipments { ${SHIPMENT_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theContract;\n },\n });\n};\n\nexport const useTheCreateContract = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateOfftakeContractInput) => {\n const data = await theQuery<{ theCreateContract: TheOfftakeContract }>(\n `mutation TheCreateContract($input: TheCreateOfftakeContractInput!) {\n theCreateContract(input: $input) { ${CONTRACT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateContract;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.contracts }),\n });\n};\n\nexport const useTheUpdateContract = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, input }: { id: string; input: TheUpdateOfftakeContractInput }) => {\n const data = await theQuery<{ theUpdateContract: TheOfftakeContract }>(\n `mutation TheUpdateContract($id: ID!, $input: TheUpdateOfftakeContractInput!) {\n theUpdateContract(id: $id, input: $input) { ${CONTRACT_FIELDS} }\n }`,\n { id, input },\n apiGatewayUrl\n );\n return data.theUpdateContract;\n },\n onSuccess: (c) => {\n qc.invalidateQueries({ queryKey: KEY.contracts });\n qc.invalidateQueries({ queryKey: KEY.contract(c.id) });\n },\n });\n};\n\nexport const useTheTransitionContract = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: TheContractStatus }) => {\n const data = await theQuery<{ theTransitionContract: TheOfftakeContract }>(\n `mutation TheTransitionContract($id: ID!, $status: TheContractStatus!) {\n theTransitionContract(id: $id, status: $status) { ${CONTRACT_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return data.theTransitionContract;\n },\n onSuccess: (c) => {\n qc.invalidateQueries({ queryKey: KEY.contracts });\n qc.invalidateQueries({ queryKey: KEY.contract(c.id) });\n },\n });\n};\n\n// ============================================================================\n// Commerce — Shipments\n// ============================================================================\n\nexport const useTheShipments = (contractId?: string, status?: TheShipmentStatus) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.shipments, contractId ?? null, status ?? null],\n queryFn: async () => {\n const data = await theQuery<{ theListShipments: TheShipment[] }>(\n `query TheListShipments($contractId: ID, $status: TheShipmentStatus) {\n theListShipments(contractId: $contractId, status: $status) { ${SHIPMENT_FIELDS} }\n }`,\n { contractId, status },\n apiGatewayUrl\n );\n return data.theListShipments;\n },\n });\n};\n\nexport const useTheScheduleShipment = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateShipmentInput) => {\n const data = await theQuery<{ theScheduleShipment: TheShipment }>(\n `mutation TheScheduleShipment($input: TheCreateShipmentInput!) {\n theScheduleShipment(input: $input) { ${SHIPMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theScheduleShipment;\n },\n onSuccess: (s) => {\n qc.invalidateQueries({ queryKey: KEY.shipments });\n qc.invalidateQueries({ queryKey: KEY.contract(s.contractId) });\n },\n });\n};\n\nexport const useTheDeliverShipment = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await theQuery<{ theDeliverShipment: TheShipment }>(\n `mutation TheDeliverShipment($id: ID!) {\n theDeliverShipment(id: $id) { ${SHIPMENT_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theDeliverShipment;\n },\n onSuccess: (s) => {\n qc.invalidateQueries({ queryKey: KEY.shipments });\n qc.invalidateQueries({ queryKey: KEY.contracts });\n qc.invalidateQueries({ queryKey: KEY.contract(s.contractId) });\n },\n });\n};\n\n// ============================================================================\n// Commerce — Inventory lots\n// ============================================================================\n\nexport interface InventoryFilters {\n commodity?: TheCommodityType;\n status?: TheInventoryStatus;\n pagination?: PaginationInput;\n}\n\nexport const useTheInventoryLots = (filters: InventoryFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.inventory, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListInventoryLots: TheConnection<TheInventoryLot> }>(\n `query TheListInventoryLots($commodity: TheCommodityType, $status: TheInventoryStatus, $pagination: PaginationInput) {\n theListInventoryLots(commodity: $commodity, status: $status, pagination: $pagination) {\n items { ${INVENTORY_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n commodity: filters.commodity,\n status: filters.status,\n pagination: filters.pagination ?? DEFAULT_PAGE,\n },\n apiGatewayUrl\n );\n return data.theListInventoryLots;\n },\n });\n};\n\nexport const useTheCreateInventoryLot = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateInventoryLotInput) => {\n const data = await theQuery<{ theCreateInventoryLot: TheInventoryLot }>(\n `mutation TheCreateInventoryLot($input: TheCreateInventoryLotInput!) {\n theCreateInventoryLot(input: $input) { ${INVENTORY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateInventoryLot;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.inventory }),\n });\n};\n\nexport const useTheSetInventoryLotStatus = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: TheInventoryStatus }) => {\n const data = await theQuery<{ theSetInventoryLotStatus: TheInventoryLot }>(\n `mutation TheSetInventoryLotStatus($id: ID!, $status: TheInventoryStatus!) {\n theSetInventoryLotStatus(id: $id, status: $status) { ${INVENTORY_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return data.theSetInventoryLotStatus;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.inventory }),\n });\n};\n\n// ============================================================================\n// Sustainability — Emission records\n// ============================================================================\n\nexport interface EmissionFilters {\n assetId?: string;\n scope?: TheEmissionScope;\n pagination?: PaginationInput;\n}\n\nexport const useTheEmissionRecords = (filters: EmissionFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.emissions, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListEmissionRecords: TheConnection<TheEmissionRecord> }>(\n `query TheListEmissionRecords($assetId: ID, $scope: TheEmissionScope, $pagination: PaginationInput) {\n theListEmissionRecords(assetId: $assetId, scope: $scope, pagination: $pagination) {\n items { ${EMISSION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n assetId: filters.assetId,\n scope: filters.scope,\n pagination: filters.pagination ?? DEFAULT_PAGE,\n },\n apiGatewayUrl\n );\n return data.theListEmissionRecords;\n },\n });\n};\n\nexport const useTheRecordEmission = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheRecordEmissionInput) => {\n const data = await theQuery<{ theRecordEmission: TheEmissionRecord }>(\n `mutation TheRecordEmission($input: TheRecordEmissionInput!) {\n theRecordEmission(input: $input) { ${EMISSION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theRecordEmission;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.emissions }),\n });\n};\n\nexport const useTheVerifyEmission = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await theQuery<{ theVerifyEmission: TheEmissionRecord }>(\n `mutation TheVerifyEmission($id: ID!) {\n theVerifyEmission(id: $id) { ${EMISSION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theVerifyEmission;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.emissions }),\n });\n};\n\n// ============================================================================\n// Sustainability — Compliance certifications\n// ============================================================================\n\nexport const useTheComplianceCerts = (\n assetId?: string,\n category?: TheComplianceCategory,\n status?: TheComplianceStatus\n) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.compliance, assetId ?? null, category ?? null, status ?? null],\n queryFn: async () => {\n const data = await theQuery<{ theListComplianceCerts: TheComplianceCert[] }>(\n `query TheListComplianceCerts($assetId: ID, $category: TheComplianceCategory, $status: TheComplianceStatus) {\n theListComplianceCerts(assetId: $assetId, category: $category, status: $status) { ${COMPLIANCE_FIELDS} }\n }`,\n { assetId, category, status },\n apiGatewayUrl\n );\n return data.theListComplianceCerts;\n },\n });\n};\n\nexport const useTheComplianceCert = (id: string | undefined) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: KEY.complianceCert(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const data = await theQuery<{ theComplianceCert: TheComplianceCert | null }>(\n `query TheComplianceCert($id: ID!) {\n theComplianceCert(id: $id) { ${COMPLIANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theComplianceCert;\n },\n });\n};\n\nexport const useTheCreateComplianceCert = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateComplianceCertInput) => {\n const data = await theQuery<{ theCreateComplianceCert: TheComplianceCert }>(\n `mutation TheCreateComplianceCert($input: TheCreateComplianceCertInput!) {\n theCreateComplianceCert(input: $input) { ${COMPLIANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateComplianceCert;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.compliance }),\n });\n};\n\nexport const useTheTransitionComplianceCert = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: TheComplianceStatus }) => {\n const data = await theQuery<{ theTransitionComplianceCert: TheComplianceCert }>(\n `mutation TheTransitionComplianceCert($id: ID!, $status: TheComplianceStatus!) {\n theTransitionComplianceCert(id: $id, status: $status) { ${COMPLIANCE_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return data.theTransitionComplianceCert;\n },\n onSuccess: (c) => {\n qc.invalidateQueries({ queryKey: KEY.compliance });\n qc.invalidateQueries({ queryKey: KEY.complianceCert(c.id) });\n },\n });\n};\n"],"mappings":";;;;;AAoEA,IAAM,UAAqC;CACzC,IAAM,IAAI;AAGV,CAFA,EAAE,6BAA6B,OAAO,EACtC,EAAE,gCAAgC,OAAO,EACzC,EAAE,4BAA4B,OAAO;GAGjC,IAAW,OACf,GACA,GACA,MACmB;CACnB,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;EACjB,CAAC;AAEF,KAAI,EAAS,QAAQ,OACnB,OAAU,MAAM,EAAS,OAAO,IAAI,WAAW,yBAAyB;AAE1E,KAAI,CAAC,EAAS,KACZ,OAAU,MAAM,wCAAwC;AAK1D,QAHI,iBAAiB,KAAK,EAAM,IAC9B,GAAwB,EAEnB,EAAS;GAIZ,IAAM;CACV,QAAQ,CAAC,iBAAiB,SAAS;CACnC,QAAQ,MAAe;EAAC;EAAiB;EAAS;EAAG;CACrD,YAAY,CAAC,iBAAiB,aAAa;CAC3C,UAAU,CAAC,iBAAiB,WAAW;CACvC,WAAW,CAAC,iBAAiB,YAAY;CACzC,WAAW,MAAe;EAAC;EAAiB;EAAY;EAAG;CAC3D,WAAW,CAAC,iBAAiB,YAAY;CACzC,WAAW,CAAC,iBAAiB,YAAY;CACzC,WAAW,CAAC,iBAAiB,YAAY;CACzC,YAAY,CAAC,iBAAiB,aAAa;CAC3C,iBAAiB,MAAe;EAAC;EAAiB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AClD,EAAG,kBAAkB,EAAE,UAAU,EAAI,eAAe,EAAE,GAAG,EAAE,CAAC;;EAE/D,CAAC"}
1
+ {"version":3,"file":"useTheGlobalFuelApi.js","names":[],"sources":["../../../src/theglobalfuel/hooks/useTheGlobalFuelApi.ts"],"sourcesContent":["/**\n * TheGlobalFuel API hooks\n * @module theglobalfuel/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-theglobalfuel-svc`\n * federated GraphQL contract (the `the*` operations). Every query/mutation\n * below uses an inline gql string whose fields match the svc\n * `.hive-schema.graphql` exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` —\n * the host shell supplies the gateway base URL + a workspace-scoped token.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useTheGlobalFuel } from '../context';\nimport type {\n TheConnection,\n TheAsset,\n TheAssetKind,\n TheAssetStatus,\n TheCommodityType,\n TheProductionRecord,\n TheReserveEstimate,\n TheReserveCategory,\n TheOfftakeContract,\n TheContractSide,\n TheContractStatus,\n TheShipment,\n TheShipmentStatus,\n TheInventoryLot,\n TheInventoryStatus,\n TheEmissionRecord,\n TheEmissionScope,\n TheComplianceCert,\n TheComplianceCategory,\n TheComplianceStatus,\n TheCreateAssetInput,\n TheUpdateAssetInput,\n TheRecordProductionInput,\n TheCreateReserveEstimateInput,\n TheCreateOfftakeContractInput,\n TheUpdateOfftakeContractInput,\n TheCreateShipmentInput,\n TheCreateInventoryLotInput,\n TheRecordEmissionInput,\n TheCreateComplianceCertInput,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\ntype GraphqlReadCacheGlobals = {\n __graphqlFetchResponseCache?: { clear: () => void };\n __graphqlFetchPendingResponses?: { clear: () => void };\n __boffGraphQLResponseCache?: { clear: () => void };\n};\n\n/**\n * fe-libs `graphqlFetch` coalesces `query` responses in a short-lived in-memory\n * cache keyed by operationName+variables (~15s; mutations never cached). A read\n * issued right after a write would otherwise return the pre-mutation snapshot\n * until the TTL expires — making just-created rows invisible. We clear those\n * caches after every mutation so every follow-up refetch reads fresh.\n */\nconst clearGraphqlReadCaches = (): void => {\n const g = globalThis as GraphqlReadCacheGlobals;\n g.__graphqlFetchResponseCache?.clear();\n g.__graphqlFetchPendingResponses?.clear();\n g.__boffGraphQLResponseCache?.clear();\n};\n\nconst theQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n if (/^\\s*mutation\\b/.test(query)) {\n clearGraphqlReadCaches();\n }\n return response.data;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n assets: ['theglobalfuel', 'assets'] as const,\n asset: (id: string) => ['theglobalfuel', 'asset', id] as const,\n production: ['theglobalfuel', 'production'] as const,\n reserves: ['theglobalfuel', 'reserves'] as const,\n contracts: ['theglobalfuel', 'contracts'] as const,\n contract: (id: string) => ['theglobalfuel', 'contract', id] as const,\n shipments: ['theglobalfuel', 'shipments'] as const,\n inventory: ['theglobalfuel', 'inventory'] as const,\n emissions: ['theglobalfuel', 'emissions'] as const,\n compliance: ['theglobalfuel', 'compliance'] as const,\n complianceCert: (id: string) => ['theglobalfuel', 'compliance', id] as const,\n};\n\nconst DEFAULT_PAGE: PaginationInput = { limit: 50 };\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness)\n// ============================================================================\n\nconst ASSET_FIELDS = `\n id workspaceId name code kind commodity status location latitude longitude\n capacityPerDay capacityUnit workingInterestPct operatorLeadId\n commissionedAt decommissionedAt tags createdAt updatedAt\n`;\n\nconst PRODUCTION_FIELDS = `\n id workspaceId assetId periodStart periodEnd volume unit grade downtimeHours\n notes createdAt updatedAt\n`;\n\nconst RESERVE_FIELDS = `\n id workspaceId assetId category asOfDate recoverable recoveryFactor unit\n methodology notes createdAt updatedAt\n`;\n\nconst CONTRACT_FIELDS = `\n id workspaceId reference counterparty commodity side status pricingBasis\n pricePerUnit priceIndex currency contractedVolume deliveredVolume unit\n deliveryLocation startDate endDate signedAt notes tags createdAt updatedAt\n`;\n\nconst SHIPMENT_FIELDS = `\n id workspaceId contractId reference mode status carrier origin destination\n volume unit scheduledAt departedAt deliveredAt document { id } notes\n createdAt updatedAt\n`;\n\nconst INVENTORY_FIELDS = `\n id workspaceId lotCode commodity assetId quantity unit grade status location\n unitValue currency producedAt notes createdAt updatedAt\n`;\n\nconst EMISSION_FIELDS = `\n id workspaceId assetId scope co2eTonnes periodStart periodEnd source\n methodology verified verifiedAt notes createdAt updatedAt\n`;\n\nconst COMPLIANCE_FIELDS = `\n id workspaceId title category status assetId authority certNumber ownerId\n issuedAt expiresAt evidence { id } notes tags createdAt updatedAt\n`;\n\n// ============================================================================\n// Registry — Assets\n// ============================================================================\n\nexport interface AssetFilters {\n commodity?: TheCommodityType;\n kind?: TheAssetKind;\n status?: TheAssetStatus;\n pagination?: PaginationInput;\n}\n\nexport const useTheAssets = (filters: AssetFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.assets, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListAssets: TheConnection<TheAsset> }>(\n `query TheListAssets($commodity: TheCommodityType, $kind: TheAssetKind, $status: TheAssetStatus, $pagination: PaginationInput) {\n theListAssets(commodity: $commodity, kind: $kind, status: $status, pagination: $pagination) {\n items { ${ASSET_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n commodity: filters.commodity,\n kind: filters.kind,\n status: filters.status,\n pagination: filters.pagination ?? DEFAULT_PAGE,\n },\n apiGatewayUrl\n );\n return data.theListAssets;\n },\n });\n};\n\nexport const useTheAsset = (id: string | undefined) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: KEY.asset(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const data = await theQuery<{ theAsset: TheAsset | null }>(\n `query TheAsset($id: ID!) {\n theAsset(id: $id) {\n ${ASSET_FIELDS}\n productionRecords { ${PRODUCTION_FIELDS} }\n reserveEstimates { ${RESERVE_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theAsset;\n },\n });\n};\n\nexport const useTheCreateAsset = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateAssetInput) => {\n const data = await theQuery<{ theCreateAsset: TheAsset }>(\n `mutation TheCreateAsset($input: TheCreateAssetInput!) {\n theCreateAsset(input: $input) { ${ASSET_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateAsset;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.assets }),\n });\n};\n\nexport const useTheUpdateAsset = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, input }: { id: string; input: TheUpdateAssetInput }) => {\n const data = await theQuery<{ theUpdateAsset: TheAsset }>(\n `mutation TheUpdateAsset($id: ID!, $input: TheUpdateAssetInput!) {\n theUpdateAsset(id: $id, input: $input) { ${ASSET_FIELDS} }\n }`,\n { id, input },\n apiGatewayUrl\n );\n return data.theUpdateAsset;\n },\n onSuccess: (asset) => {\n qc.invalidateQueries({ queryKey: KEY.assets });\n qc.invalidateQueries({ queryKey: KEY.asset(asset.id) });\n },\n });\n};\n\nexport const useTheTransitionAsset = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: TheAssetStatus }) => {\n const data = await theQuery<{ theTransitionAsset: TheAsset }>(\n `mutation TheTransitionAsset($id: ID!, $status: TheAssetStatus!) {\n theTransitionAsset(id: $id, status: $status) { ${ASSET_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return data.theTransitionAsset;\n },\n onSuccess: (asset) => {\n qc.invalidateQueries({ queryKey: KEY.assets });\n qc.invalidateQueries({ queryKey: KEY.asset(asset.id) });\n },\n });\n};\n\nexport const useTheRetireAsset = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await theQuery<{ theRetireAsset: boolean }>(\n `mutation TheRetireAsset($id: ID!) { theRetireAsset(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return data.theRetireAsset;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.assets }),\n });\n};\n\n// ============================================================================\n// Registry — Production records\n// ============================================================================\n\nexport interface ProductionFilters {\n assetId?: string;\n pagination?: PaginationInput;\n}\n\nexport const useTheProductionRecords = (filters: ProductionFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.production, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListProductionRecords: TheConnection<TheProductionRecord> }>(\n `query TheListProductionRecords($assetId: ID, $pagination: PaginationInput) {\n theListProductionRecords(assetId: $assetId, pagination: $pagination) {\n items { ${PRODUCTION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { assetId: filters.assetId, pagination: filters.pagination ?? DEFAULT_PAGE },\n apiGatewayUrl\n );\n return data.theListProductionRecords;\n },\n });\n};\n\nexport const useTheRecordProduction = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheRecordProductionInput) => {\n const data = await theQuery<{ theRecordProduction: TheProductionRecord }>(\n `mutation TheRecordProduction($input: TheRecordProductionInput!) {\n theRecordProduction(input: $input) { ${PRODUCTION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theRecordProduction;\n },\n onSuccess: (rec) => {\n qc.invalidateQueries({ queryKey: KEY.production });\n qc.invalidateQueries({ queryKey: KEY.asset(rec.assetId) });\n },\n });\n};\n\n// ============================================================================\n// Registry — Reserve estimates\n// ============================================================================\n\nexport const useTheReserveEstimates = (\n assetId?: string,\n category?: TheReserveCategory,\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.reserves, assetId ?? null, category ?? null, pagination ?? null],\n queryFn: async () => {\n const data = await theQuery<{ theListReserveEstimates: TheConnection<TheReserveEstimate> }>(\n `query TheListReserveEstimates($assetId: ID, $category: TheReserveCategory, $pagination: PaginationInput) {\n theListReserveEstimates(assetId: $assetId, category: $category, pagination: $pagination) {\n items { ${RESERVE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { assetId, category, pagination: pagination ?? DEFAULT_PAGE },\n apiGatewayUrl\n );\n return data.theListReserveEstimates;\n },\n });\n};\n\nexport const useTheCreateReserveEstimate = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateReserveEstimateInput) => {\n const data = await theQuery<{ theCreateReserveEstimate: TheReserveEstimate }>(\n `mutation TheCreateReserveEstimate($input: TheCreateReserveEstimateInput!) {\n theCreateReserveEstimate(input: $input) { ${RESERVE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateReserveEstimate;\n },\n onSuccess: (rec) => {\n qc.invalidateQueries({ queryKey: KEY.reserves });\n qc.invalidateQueries({ queryKey: KEY.asset(rec.assetId) });\n },\n });\n};\n\n// ============================================================================\n// Commerce — Offtake contracts\n// ============================================================================\n\nexport interface ContractFilters {\n commodity?: TheCommodityType;\n side?: TheContractSide;\n status?: TheContractStatus;\n pagination?: PaginationInput;\n}\n\nexport const useTheContracts = (filters: ContractFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.contracts, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListContracts: TheConnection<TheOfftakeContract> }>(\n `query TheListContracts($commodity: TheCommodityType, $side: TheContractSide, $status: TheContractStatus, $pagination: PaginationInput) {\n theListContracts(commodity: $commodity, side: $side, status: $status, pagination: $pagination) {\n items { ${CONTRACT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n commodity: filters.commodity,\n side: filters.side,\n status: filters.status,\n pagination: filters.pagination ?? DEFAULT_PAGE,\n },\n apiGatewayUrl\n );\n return data.theListContracts;\n },\n });\n};\n\nexport const useTheContract = (id: string | undefined) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: KEY.contract(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const data = await theQuery<{ theContract: TheOfftakeContract | null }>(\n `query TheContract($id: ID!) {\n theContract(id: $id) {\n ${CONTRACT_FIELDS}\n shipments { ${SHIPMENT_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theContract;\n },\n });\n};\n\nexport const useTheCreateContract = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateOfftakeContractInput) => {\n const data = await theQuery<{ theCreateContract: TheOfftakeContract }>(\n `mutation TheCreateContract($input: TheCreateOfftakeContractInput!) {\n theCreateContract(input: $input) { ${CONTRACT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateContract;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.contracts }),\n });\n};\n\nexport const useTheUpdateContract = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, input }: { id: string; input: TheUpdateOfftakeContractInput }) => {\n const data = await theQuery<{ theUpdateContract: TheOfftakeContract }>(\n `mutation TheUpdateContract($id: ID!, $input: TheUpdateOfftakeContractInput!) {\n theUpdateContract(id: $id, input: $input) { ${CONTRACT_FIELDS} }\n }`,\n { id, input },\n apiGatewayUrl\n );\n return data.theUpdateContract;\n },\n onSuccess: (c) => {\n qc.invalidateQueries({ queryKey: KEY.contracts });\n qc.invalidateQueries({ queryKey: KEY.contract(c.id) });\n },\n });\n};\n\nexport const useTheTransitionContract = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: TheContractStatus }) => {\n const data = await theQuery<{ theTransitionContract: TheOfftakeContract }>(\n `mutation TheTransitionContract($id: ID!, $status: TheContractStatus!) {\n theTransitionContract(id: $id, status: $status) { ${CONTRACT_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return data.theTransitionContract;\n },\n onSuccess: (c) => {\n qc.invalidateQueries({ queryKey: KEY.contracts });\n qc.invalidateQueries({ queryKey: KEY.contract(c.id) });\n },\n });\n};\n\n// ============================================================================\n// Commerce — Shipments\n// ============================================================================\n\nexport const useTheShipments = (\n contractId?: string,\n status?: TheShipmentStatus,\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.shipments, contractId ?? null, status ?? null, pagination ?? null],\n queryFn: async () => {\n const data = await theQuery<{ theListShipments: TheConnection<TheShipment> }>(\n `query TheListShipments($contractId: ID, $status: TheShipmentStatus, $pagination: PaginationInput) {\n theListShipments(contractId: $contractId, status: $status, pagination: $pagination) {\n items { ${SHIPMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { contractId, status, pagination: pagination ?? DEFAULT_PAGE },\n apiGatewayUrl\n );\n return data.theListShipments;\n },\n });\n};\n\nexport const useTheTransitionShipment = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: TheShipmentStatus }) => {\n const data = await theQuery<{ theTransitionShipment: TheShipment }>(\n `mutation TheTransitionShipment($id: ID!, $status: TheShipmentStatus!) {\n theTransitionShipment(id: $id, status: $status) { ${SHIPMENT_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return data.theTransitionShipment;\n },\n onSuccess: (s) => {\n qc.invalidateQueries({ queryKey: KEY.shipments });\n qc.invalidateQueries({ queryKey: KEY.contract(s.contractId) });\n },\n });\n};\n\nexport const useTheScheduleShipment = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateShipmentInput) => {\n const data = await theQuery<{ theScheduleShipment: TheShipment }>(\n `mutation TheScheduleShipment($input: TheCreateShipmentInput!) {\n theScheduleShipment(input: $input) { ${SHIPMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theScheduleShipment;\n },\n onSuccess: (s) => {\n qc.invalidateQueries({ queryKey: KEY.shipments });\n qc.invalidateQueries({ queryKey: KEY.contract(s.contractId) });\n },\n });\n};\n\nexport const useTheDeliverShipment = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await theQuery<{ theDeliverShipment: TheShipment }>(\n `mutation TheDeliverShipment($id: ID!) {\n theDeliverShipment(id: $id) { ${SHIPMENT_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theDeliverShipment;\n },\n onSuccess: (s) => {\n qc.invalidateQueries({ queryKey: KEY.shipments });\n qc.invalidateQueries({ queryKey: KEY.contracts });\n qc.invalidateQueries({ queryKey: KEY.contract(s.contractId) });\n },\n });\n};\n\n// ============================================================================\n// Commerce — Inventory lots\n// ============================================================================\n\nexport interface InventoryFilters {\n commodity?: TheCommodityType;\n status?: TheInventoryStatus;\n pagination?: PaginationInput;\n}\n\nexport const useTheInventoryLots = (filters: InventoryFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.inventory, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListInventoryLots: TheConnection<TheInventoryLot> }>(\n `query TheListInventoryLots($commodity: TheCommodityType, $status: TheInventoryStatus, $pagination: PaginationInput) {\n theListInventoryLots(commodity: $commodity, status: $status, pagination: $pagination) {\n items { ${INVENTORY_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n commodity: filters.commodity,\n status: filters.status,\n pagination: filters.pagination ?? DEFAULT_PAGE,\n },\n apiGatewayUrl\n );\n return data.theListInventoryLots;\n },\n });\n};\n\nexport const useTheCreateInventoryLot = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateInventoryLotInput) => {\n const data = await theQuery<{ theCreateInventoryLot: TheInventoryLot }>(\n `mutation TheCreateInventoryLot($input: TheCreateInventoryLotInput!) {\n theCreateInventoryLot(input: $input) { ${INVENTORY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateInventoryLot;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.inventory }),\n });\n};\n\nexport const useTheSetInventoryLotStatus = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: TheInventoryStatus }) => {\n const data = await theQuery<{ theSetInventoryLotStatus: TheInventoryLot }>(\n `mutation TheSetInventoryLotStatus($id: ID!, $status: TheInventoryStatus!) {\n theSetInventoryLotStatus(id: $id, status: $status) { ${INVENTORY_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return data.theSetInventoryLotStatus;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.inventory }),\n });\n};\n\n// ============================================================================\n// Sustainability — Emission records\n// ============================================================================\n\nexport interface EmissionFilters {\n assetId?: string;\n scope?: TheEmissionScope;\n pagination?: PaginationInput;\n}\n\nexport const useTheEmissionRecords = (filters: EmissionFilters = {}) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.emissions, filters],\n queryFn: async () => {\n const data = await theQuery<{ theListEmissionRecords: TheConnection<TheEmissionRecord> }>(\n `query TheListEmissionRecords($assetId: ID, $scope: TheEmissionScope, $pagination: PaginationInput) {\n theListEmissionRecords(assetId: $assetId, scope: $scope, pagination: $pagination) {\n items { ${EMISSION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n assetId: filters.assetId,\n scope: filters.scope,\n pagination: filters.pagination ?? DEFAULT_PAGE,\n },\n apiGatewayUrl\n );\n return data.theListEmissionRecords;\n },\n });\n};\n\nexport const useTheRecordEmission = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheRecordEmissionInput) => {\n const data = await theQuery<{ theRecordEmission: TheEmissionRecord }>(\n `mutation TheRecordEmission($input: TheRecordEmissionInput!) {\n theRecordEmission(input: $input) { ${EMISSION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theRecordEmission;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.emissions }),\n });\n};\n\nexport const useTheVerifyEmission = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await theQuery<{ theVerifyEmission: TheEmissionRecord }>(\n `mutation TheVerifyEmission($id: ID!) {\n theVerifyEmission(id: $id) { ${EMISSION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theVerifyEmission;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.emissions }),\n });\n};\n\n// ============================================================================\n// Sustainability — Compliance certifications\n// ============================================================================\n\nexport const useTheComplianceCerts = (\n assetId?: string,\n category?: TheComplianceCategory,\n status?: TheComplianceStatus,\n pagination?: PaginationInput\n) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: [...KEY.compliance, assetId ?? null, category ?? null, status ?? null, pagination ?? null],\n queryFn: async () => {\n const data = await theQuery<{ theListComplianceCerts: TheConnection<TheComplianceCert> }>(\n `query TheListComplianceCerts($assetId: ID, $category: TheComplianceCategory, $status: TheComplianceStatus, $pagination: PaginationInput) {\n theListComplianceCerts(assetId: $assetId, category: $category, status: $status, pagination: $pagination) {\n items { ${COMPLIANCE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { assetId, category, status, pagination: pagination ?? DEFAULT_PAGE },\n apiGatewayUrl\n );\n return data.theListComplianceCerts;\n },\n });\n};\n\nexport const useTheComplianceCert = (id: string | undefined) => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n return useQuery({\n queryKey: KEY.complianceCert(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const data = await theQuery<{ theComplianceCert: TheComplianceCert | null }>(\n `query TheComplianceCert($id: ID!) {\n theComplianceCert(id: $id) { ${COMPLIANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return data.theComplianceCert;\n },\n });\n};\n\nexport const useTheCreateComplianceCert = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: TheCreateComplianceCertInput) => {\n const data = await theQuery<{ theCreateComplianceCert: TheComplianceCert }>(\n `mutation TheCreateComplianceCert($input: TheCreateComplianceCertInput!) {\n theCreateComplianceCert(input: $input) { ${COMPLIANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.theCreateComplianceCert;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.compliance }),\n });\n};\n\nexport const useTheTransitionComplianceCert = () => {\n const { apiGatewayUrl } = useTheGlobalFuel();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async ({ id, status }: { id: string; status: TheComplianceStatus }) => {\n const data = await theQuery<{ theTransitionComplianceCert: TheComplianceCert }>(\n `mutation TheTransitionComplianceCert($id: ID!, $status: TheComplianceStatus!) {\n theTransitionComplianceCert(id: $id, status: $status) { ${COMPLIANCE_FIELDS} }\n }`,\n { id, status },\n apiGatewayUrl\n );\n return data.theTransitionComplianceCert;\n },\n onSu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