/**
 * Periodic snapshot of a single metric for a database. Collected by the snapshot_usage() cron job in constructive-limits. Each row records one metric measurement (e.g. reads, writes, storage_bytes) at a point in time, with optional dimensions for sub-metric breakdowns.
 * @generated by @constructive-io/graphql-codegen
 * DO NOT EDIT - changes will be overwritten
 */
import { useQuery } from '@tanstack/react-query';
import { getClient } from '../client';
import { buildSelectionArgs } from '../selection';
import { usageSnapshotKeys } from '../query-keys';
/** Query key factory - re-exported from query-keys.ts */
export const usageSnapshotQueryKey = usageSnapshotKeys.detail;
export function useUsageSnapshotQuery(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...queryOptions } = params ?? {};
    void _selection;
    return useQuery({
        queryKey: usageSnapshotKeys.detail(params.id),
        queryFn: () => getClient()
            .usageSnapshot.findOne({
            id: params.id,
            select: args.select,
        })
            .unwrap(),
        ...queryOptions,
    });
}
export async function fetchUsageSnapshotQuery(params) {
    const args = buildSelectionArgs(params.selection);
    return getClient()
        .usageSnapshot.findOne({
        id: params.id,
        select: args.select,
    })
        .unwrap();
}
export async function prefetchUsageSnapshotQuery(queryClient, params) {
    const args = buildSelectionArgs(params.selection);
    await queryClient.prefetchQuery({
        queryKey: usageSnapshotKeys.detail(params.id),
        queryFn: () => getClient()
            .usageSnapshot.findOne({
            id: params.id,
            select: args.select,
        })
            .unwrap(),
    });
}
