"use strict";
/**
 * Provisions relational structure between tables. Supports four relation types:
     - RelationBelongsTo: adds a FK field on the source table referencing the target table (child perspective: "tasks belongs to projects" -> tasks.project_id).
     - RelationHasMany: adds a FK field on the target table referencing the source table (parent perspective: "projects has many tasks" -> tasks.project_id). Inverse of BelongsTo.
     - RelationHasOne: adds a FK field with a unique constraint on the source table referencing the target table. Also supports shared-primary-key patterns where the FK field IS the primary key (set field_name to the existing PK field name).
     - RelationManyToMany: creates a junction table with FK fields to both source and target tables, delegating table creation and security to secure_table_provision.
     This is a one-and-done structural provisioner. To layer additional security onto junction tables after creation, use secure_table_provision directly.
     All operations are graceful: existing fields, FK constraints, and unique constraints are reused if found.
     The trigger never injects values the caller did not provide. All security config is forwarded to secure_table_provision as-is.
 * @generated by @constructive-io/graphql-codegen
 * DO NOT EDIT - changes will be overwritten
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.relationProvisionQueryKey = void 0;
exports.useRelationProvisionQuery = useRelationProvisionQuery;
exports.fetchRelationProvisionQuery = fetchRelationProvisionQuery;
exports.prefetchRelationProvisionQuery = prefetchRelationProvisionQuery;
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.relationProvisionQueryKey = query_keys_1.relationProvisionKeys.detail;
function useRelationProvisionQuery(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.relationProvisionKeys.detail(params.id),
        queryFn: () => (0, client_1.getClient)()
            .relationProvision.findOne({
            id: params.id,
            select: args.select,
        })
            .unwrap(),
        ...queryOptions,
    });
}
async function fetchRelationProvisionQuery(params) {
    const args = (0, selection_1.buildSelectionArgs)(params.selection);
    return (0, client_1.getClient)()
        .relationProvision.findOne({
        id: params.id,
        select: args.select,
    })
        .unwrap();
}
async function prefetchRelationProvisionQuery(queryClient, params) {
    const args = (0, selection_1.buildSelectionArgs)(params.selection);
    await queryClient.prefetchQuery({
        queryKey: query_keys_1.relationProvisionKeys.detail(params.id),
        queryFn: () => (0, client_1.getClient)()
            .relationProvision.findOne({
            id: params.id,
            select: args.select,
        })
            .unwrap(),
    });
}
