import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildFindOneDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class InfraObjectModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = 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', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'InfraObject',
            fieldName: 'infraObjects',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('InfraObject', 'infraObjects', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'InfraObjectFilter', 'InfraObjectOrderBy', connectionFieldsMap);
        return new 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 } = buildFindOneDocument('InfraObject', 'infraGetNodeAtPath', args.id, args.select, 'id', 'UUID!', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'InfraObject',
            fieldName: 'infraObject',
            document,
            variables,
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('InfraObject', 'createInfraObject', 'infraObject', args.select, args.data, 'CreateInfraObjectInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'InfraObject',
            fieldName: 'createInfraObject',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('InfraObject', 'updateInfraObject', 'infraObject', args.select, args.where.id, args.data, 'UpdateInfraObjectInput', 'id', 'infraObjectPatch', connectionFieldsMap, {
            scopeId: args.where.scopeId,
        });
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'InfraObject',
            fieldName: 'updateInfraObject',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('InfraObject', 'deleteInfraObject', 'infraObject', {
            id: args.where.id,
            scopeId: args.where.scopeId,
        }, 'DeleteInfraObjectInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'InfraObject',
            fieldName: 'deleteInfraObject',
            document,
            variables,
        });
    }
}
