/**
 * Provisions the principals subsystem: a principals table, a principal_entities junction table, create/delete mutations, and org API key management. Supports both human-owned principals (AuthzDirectOwner, AuthzHumanOnly) and org-owned principals (AuthzEntityMembership with is_admin). Org principal and org API key functions are only generated when an org-scoped memberships_module exists for the database.
 * @generated by @constructive-io/graphql-codegen
 * DO NOT EDIT - changes will be overwritten
 */
import { useQuery } from '@tanstack/react-query';
import { getClient } from '../client';
import { buildListSelectionArgs } from '../selection';
import { principalAuthModuleKeys } from '../query-keys';
/** Query key factory - re-exported from query-keys.ts */
export const principalAuthModulesQueryKey = principalAuthModuleKeys.list;
export function usePrincipalAuthModulesQuery(params) {
    const args = buildListSelectionArgs(params.selection);
    const { selection: _selection, ...queryOptions } = params ?? {};
    void _selection;
    return useQuery({
        queryKey: principalAuthModuleKeys.list(args),
        queryFn: () => getClient().principalAuthModule.findMany(args).unwrap(),
        ...queryOptions,
    });
}
export async function fetchPrincipalAuthModulesQuery(params) {
    const args = buildListSelectionArgs(params.selection);
    return getClient().principalAuthModule.findMany(args).unwrap();
}
export async function prefetchPrincipalAuthModulesQuery(queryClient, params) {
    const args = buildListSelectionArgs(params.selection);
    await queryClient.prefetchQuery({
        queryKey: principalAuthModuleKeys.list(args),
        queryFn: () => getClient().principalAuthModule.findMany(args).unwrap(),
    });
}
