import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class HttpRouteModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('HttpRoute', 'httpRoutes', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'HttpRouteFilter', 'HttpRouteOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'HttpRoute',
            fieldName: 'httpRoutes',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('HttpRoute', 'httpRoutes', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'HttpRouteFilter', 'HttpRouteOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'HttpRoute',
            fieldName: 'httpRoute',
            document,
            variables,
            transform: (data) => ({
                httpRoute: data.httpRoutes?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('HttpRoute', 'httpRoutes', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'HttpRouteFilter', 'HttpRouteOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'HttpRoute',
            fieldName: 'httpRoute',
            document,
            variables,
            transform: (data) => ({
                httpRoute: data.httpRoutes?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('HttpRoute', 'createHttpRoute', 'httpRoute', args.select, args.data, 'CreateHttpRouteInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'HttpRoute',
            fieldName: 'createHttpRoute',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('HttpRoute', 'updateHttpRoute', 'httpRoute', args.select, args.where.id, args.data, 'UpdateHttpRouteInput', 'id', 'httpRoutePatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'HttpRoute',
            fieldName: 'updateHttpRoute',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('HttpRoute', 'deleteHttpRoute', 'httpRoute', {
            id: args.where.id,
        }, 'DeleteHttpRouteInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'HttpRoute',
            fieldName: 'deleteHttpRoute',
            document,
            variables,
        });
    }
}
