import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class AgentThreadModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('AgentThread', 'agentThreads', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'AgentThreadFilter', 'AgentThreadOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AgentThread',
            fieldName: 'agentThreads',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('AgentThread', 'agentThreads', args.select, {
            where: args?.where,
        }, 'AgentThreadFilter', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AgentThread',
            fieldName: 'agentThreads',
            document,
            variables,
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('AgentThread', 'agentThreads', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'AgentThreadFilter', 'AgentThreadOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AgentThread',
            fieldName: 'agentThread',
            document,
            variables,
            transform: (data) => ({
                agentThread: data.agentThreads?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('AgentThread', 'createAgentThread', 'agentThread', args.select, args.data, 'CreateAgentThreadInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AgentThread',
            fieldName: 'createAgentThread',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('AgentThread', 'updateAgentThread', 'agentThread', args.select, args.where.id, args.data, 'UpdateAgentThreadInput', 'id', 'agentThreadPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AgentThread',
            fieldName: 'updateAgentThread',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('AgentThread', 'deleteAgentThread', 'agentThread', {
            id: args.where.id,
        }, 'DeleteAgentThreadInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AgentThread',
            fieldName: 'deleteAgentThread',
            document,
            variables,
        });
    }
}
