/**
 * Provisions security, fields, grants, and policies onto a table. Each row can independently: (1) create fields via nodes[] array (supporting multiple Data* modules per row), (2) grant privileges via grants[] array (supporting per-role privilege targeting), (3) create RLS policies via policies[] array (supporting multiple Authz* policies per row). Multiple rows can target the same table to compose different concerns. All three concerns are optional and independent.
 * @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 { secureTableProvisionKeys } from '../query-keys';
import { secureTableProvisionMutationKeys } from '../mutation-keys';
export function useDeleteSecureTableProvisionMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: secureTableProvisionMutationKeys.all,
        mutationFn: ({ id }) => getClient()
            .secureTableProvision.delete({
            where: {
                id,
            },
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.removeQueries({
                queryKey: secureTableProvisionKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: secureTableProvisionKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
