/**
 * Scoped sub-identities (API keys and agents) with precomputed SPRT
 * @generated by @constructive-io/graphql-codegen
 * DO NOT EDIT - changes will be overwritten
 */
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { getClient } from '../client';
import { buildSelectionArgs } from '../selection';
import { principalKeys } from '../query-keys';
import { principalMutationKeys } from '../mutation-keys';
export function useDeletePrincipalMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: principalMutationKeys.all,
        mutationFn: ({ principalId }) => getClient()
            .principal.delete({
            where: {
                principalId,
            },
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.removeQueries({
                queryKey: principalKeys.detail(variables.principalId),
            });
            queryClient.invalidateQueries({
                queryKey: principalKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
