import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildFindOneDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class ObjectModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('Object', 'objects', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'ObjectFilter', 'ObjectOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Object',
            fieldName: 'objects',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('Object', 'objects', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'ObjectFilter', 'ObjectOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Object',
            fieldName: 'object',
            document,
            variables,
            transform: (data) => ({
                object: data.objects?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindOneDocument('Object', 'getNodeAtPath', args.id, args.select, 'id', 'UUID!', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Object',
            fieldName: 'object',
            document,
            variables,
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('Object', 'createObject', 'object', args.select, args.data, 'CreateObjectInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Object',
            fieldName: 'createObject',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('Object', 'updateObject', 'object', args.select, args.where.id, args.data, 'UpdateObjectInput', 'id', 'objectPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Object',
            fieldName: 'updateObject',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('Object', 'deleteObject', 'object', {
            id: args.where.id,
        }, 'DeleteObjectInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Object',
            fieldName: 'deleteObject',
            document,
            variables,
        });
    }
}
