"use strict";
/**
 * Scoped sub-identities (API keys and agents) with precomputed SPRT
 * @generated by @constructive-io/graphql-codegen
 * DO NOT EDIT - changes will be overwritten
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.principalQueryKey = void 0;
exports.usePrincipalQuery = usePrincipalQuery;
exports.fetchPrincipalQuery = fetchPrincipalQuery;
exports.prefetchPrincipalQuery = prefetchPrincipalQuery;
const react_query_1 = require("@tanstack/react-query");
const client_1 = require("../client");
const selection_1 = require("../selection");
const query_keys_1 = require("../query-keys");
/** Query key factory - re-exported from query-keys.ts */
exports.principalQueryKey = query_keys_1.principalKeys.detail;
function usePrincipalQuery(params) {
    const args = (0, selection_1.buildSelectionArgs)(params.selection);
    const { selection: _selection, ...queryOptions } = params ?? {};
    void _selection;
    return (0, react_query_1.useQuery)({
        queryKey: query_keys_1.principalKeys.detail(params.principalId),
        queryFn: () => (0, client_1.getClient)()
            .principal.findOne({
            principalId: params.principalId,
            select: args.select,
        })
            .unwrap(),
        ...queryOptions,
    });
}
async function fetchPrincipalQuery(params) {
    const args = (0, selection_1.buildSelectionArgs)(params.selection);
    return (0, client_1.getClient)()
        .principal.findOne({
        principalId: params.principalId,
        select: args.select,
    })
        .unwrap();
}
async function prefetchPrincipalQuery(queryClient, params) {
    const args = (0, selection_1.buildSelectionArgs)(params.selection);
    await queryClient.prefetchQuery({
        queryKey: query_keys_1.principalKeys.detail(params.principalId),
        queryFn: () => (0, client_1.getClient)()
            .principal.findOne({
            principalId: params.principalId,
            select: args.select,
        })
            .unwrap(),
    });
}
