import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class InfraRefModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('InfraRef', 'infraRefs', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'InfraRefFilter', 'InfraRefOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'InfraRef',
            fieldName: 'infraRefs',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('InfraRef', 'infraRefs', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'InfraRefFilter', 'InfraRefOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'InfraRef',
            fieldName: 'infraRef',
            document,
            variables,
            transform: (data) => ({
                infraRef: data.infraRefs?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('InfraRef', 'infraRefs', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'InfraRefFilter', 'InfraRefOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'InfraRef',
            fieldName: 'infraRef',
            document,
            variables,
            transform: (data) => ({
                infraRef: data.infraRefs?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('InfraRef', 'createInfraRef', 'infraRef', args.select, args.data, 'CreateInfraRefInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'InfraRef',
            fieldName: 'createInfraRef',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('InfraRef', 'updateInfraRef', 'infraRef', args.select, args.where.id, args.data, 'UpdateInfraRefInput', 'id', 'infraRefPatch', connectionFieldsMap, {
            databaseId: args.where.databaseId,
        });
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'InfraRef',
            fieldName: 'updateInfraRef',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('InfraRef', 'deleteInfraRef', 'infraRef', {
            id: args.where.id,
            databaseId: args.where.databaseId,
        }, 'DeleteInfraRefInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'InfraRef',
            fieldName: 'deleteInfraRef',
            document,
            variables,
        });
    }
}
