import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class ApiModuleModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('ApiModule', 'apiModules', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'ApiModuleFilter', 'ApiModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'ApiModule',
            fieldName: 'apiModules',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('ApiModule', 'apiModules', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'ApiModuleFilter', 'ApiModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'ApiModule',
            fieldName: 'apiModule',
            document,
            variables,
            transform: (data) => ({
                apiModule: data.apiModules?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('ApiModule', 'apiModules', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'ApiModuleFilter', 'ApiModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'ApiModule',
            fieldName: 'apiModule',
            document,
            variables,
            transform: (data) => ({
                apiModule: data.apiModules?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('ApiModule', 'createApiModule', 'apiModule', args.select, args.data, 'CreateApiModuleInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'ApiModule',
            fieldName: 'createApiModule',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('ApiModule', 'updateApiModule', 'apiModule', args.select, args.where.id, args.data, 'UpdateApiModuleInput', 'id', 'apiModulePatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'ApiModule',
            fieldName: 'updateApiModule',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('ApiModule', 'deleteApiModule', 'apiModule', {
            id: args.where.id,
        }, 'DeleteApiModuleInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'ApiModule',
            fieldName: 'deleteApiModule',
            document,
            variables,
        });
    }
}
