import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class FunctionModuleModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('FunctionModule', 'functionModules', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'FunctionModuleFilter', 'FunctionModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'FunctionModule',
            fieldName: 'functionModules',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('FunctionModule', 'functionModules', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'FunctionModuleFilter', 'FunctionModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'FunctionModule',
            fieldName: 'functionModule',
            document,
            variables,
            transform: (data) => ({
                functionModule: data.functionModules?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('FunctionModule', 'functionModules', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'FunctionModuleFilter', 'FunctionModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'FunctionModule',
            fieldName: 'functionModule',
            document,
            variables,
            transform: (data) => ({
                functionModule: data.functionModules?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('FunctionModule', 'createFunctionModule', 'functionModule', args.select, args.data, 'CreateFunctionModuleInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'FunctionModule',
            fieldName: 'createFunctionModule',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('FunctionModule', 'updateFunctionModule', 'functionModule', args.select, args.where.id, args.data, 'UpdateFunctionModuleInput', 'id', 'functionModulePatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'FunctionModule',
            fieldName: 'updateFunctionModule',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('FunctionModule', 'deleteFunctionModule', 'functionModule', {
            id: args.where.id,
        }, 'DeleteFunctionModuleInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'FunctionModule',
            fieldName: 'deleteFunctionModule',
            document,
            variables,
        });
    }
}
