#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
import { useQuery } from "@tanstack/react-query";
import { qk } from "@processor/queries/keys";
import { toAsyncState } from "@processor/queries/adapters";
import type { AsyncState } from "@processor/hooks/useAsync";
import { fetchFleetStats, type FleetStats } from "@processor/api/fleetStats";
import {
fetchAuditLog,
type AuditLogResponse,
} from "@processor/api/infrastructure";
import {
fetchEditorDeployment,
type EditorDeploymentResponse,
} from "@processor/api/editorDeploy";
import type { Tier } from "@processor/contexts/TierContext";
import { useFleetStatsAccess } from "@processor/hooks/useFleetStatsAccess";
/** Optional fleet metrics: unauthorized sessions never fetch, and failures leave figures unavailable. */
export function useFleetStats(): AsyncState<FleetStats> {
const scope = useFleetStatsAccess();
const enabled = scope !== null;
const query = useQuery({
queryKey: [...qk.fleetStats(), scope],
queryFn: ({ signal }) => fetchFleetStats(enabled, signal),
enabled,
retry: false,
});
return {
data: enabled ? (query.data ?? null) : null,
loading: enabled && query.isPending,
error: null,
};
}
/** Base query: recent audit-log activity (tier-scoped). */
export function useAuditLog(tier: Tier): AsyncState<AuditLogResponse> {
return toAsyncState(
useQuery({
queryKey: qk.auditLog(tier),
queryFn: () => fetchAuditLog(tier),
}),
);
}
/** Base query: editor deployment health (tier-scoped). Read by Home's hero
* status card. Best-effort — callers tolerate a 404 on a bare backend, so no
* retry. */
export function useEditorDeployment(
tier: Tier,
): AsyncState<EditorDeploymentResponse> {
return toAsyncState(
useQuery({
queryKey: qk.editorDeployment(tier),
queryFn: () => fetchEditorDeployment(tier),
retry: false,
}),
);
}