"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InfraObjectModel = void 0;
const query_builder_1 = require("../query-builder");
const input_types_1 = require("../input-types");
class InfraObjectModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = (0, query_builder_1.buildFindManyDocument)('InfraObject', 'infraObjects', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'InfraObjectFilter', 'InfraObjectOrderBy', input_types_1.connectionFieldsMap);
        return new query_builder_1.QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'InfraObject',
            fieldName: 'infraObjects',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = (0, query_builder_1.buildFindFirstDocument)('InfraObject', 'infraObjects', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'InfraObjectFilter', 'InfraObjectOrderBy', input_types_1.connectionFieldsMap);
        return new query_builder_1.QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'InfraObject',
            fieldName: 'infraObject',
            document,
            variables,
            transform: (data) => ({
                infraObject: data.infraObjects?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = (0, query_builder_1.buildFindOneDocument)('InfraObject', 'infraGetNodeAtPath', args.id, args.select, 'id', 'UUID!', input_types_1.connectionFieldsMap);
        return new query_builder_1.QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'InfraObject',
            fieldName: 'infraObject',
            document,
            variables,
        });
    }
    create(args) {
        const { document, variables } = (0, query_builder_1.buildCreateDocument)('InfraObject', 'createInfraObject', 'infraObject', args.select, args.data, 'CreateInfraObjectInput', input_types_1.connectionFieldsMap);
        return new query_builder_1.QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'InfraObject',
            fieldName: 'createInfraObject',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = (0, query_builder_1.buildUpdateByPkDocument)('InfraObject', 'updateInfraObject', 'infraObject', args.select, args.where.id, args.data, 'UpdateInfraObjectInput', 'id', 'infraObjectPatch', input_types_1.connectionFieldsMap, {
            databaseId: args.where.databaseId,
        });
        return new query_builder_1.QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'InfraObject',
            fieldName: 'updateInfraObject',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = (0, query_builder_1.buildDeleteByPkDocument)('InfraObject', 'deleteInfraObject', 'infraObject', {
            id: args.where.id,
            databaseId: args.where.databaseId,
        }, 'DeleteInfraObjectInput', args.select, input_types_1.connectionFieldsMap);
        return new query_builder_1.QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'InfraObject',
            fieldName: 'deleteInfraObject',
            document,
            variables,
        });
    }
}
exports.InfraObjectModel = InfraObjectModel;
