import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class DomainModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('Domain', 'domains', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'DomainFilter', 'DomainOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Domain',
            fieldName: 'domains',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('Domain', 'domains', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'DomainFilter', 'DomainOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Domain',
            fieldName: 'domain',
            document,
            variables,
            transform: (data) => ({
                domain: data.domains?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('Domain', 'domains', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'DomainFilter', 'DomainOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Domain',
            fieldName: 'domain',
            document,
            variables,
            transform: (data) => ({
                domain: data.domains?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('Domain', 'createDomain', 'domain', args.select, args.data, 'CreateDomainInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Domain',
            fieldName: 'createDomain',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('Domain', 'updateDomain', 'domain', args.select, args.where.id, args.data, 'UpdateDomainInput', 'id', 'domainPatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Domain',
            fieldName: 'updateDomain',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('Domain', 'deleteDomain', 'domain', {
            id: args.where.id,
        }, 'DeleteDomainInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Domain',
            fieldName: 'deleteDomain',
            document,
            variables,
        });
    }
}
