import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class AppLimitCreditModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('AppLimitCredit', 'appLimitCredits', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'AppLimitCreditFilter', 'AppLimitCreditOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppLimitCredit',
            fieldName: 'appLimitCredits',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('AppLimitCredit', 'appLimitCredits', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'AppLimitCreditFilter', 'AppLimitCreditOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppLimitCredit',
            fieldName: 'appLimitCredit',
            document,
            variables,
            transform: (data) => ({
                appLimitCredit: data.appLimitCredits?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('AppLimitCredit', 'appLimitCredits', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'AppLimitCreditFilter', 'AppLimitCreditOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppLimitCredit',
            fieldName: 'appLimitCredit',
            document,
            variables,
            transform: (data) => ({
                appLimitCredit: data.appLimitCredits?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('AppLimitCredit', 'createAppLimitCredit', 'appLimitCredit', args.select, args.data, 'CreateAppLimitCreditInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppLimitCredit',
            fieldName: 'createAppLimitCredit',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('AppLimitCredit', 'updateAppLimitCredit', 'appLimitCredit', args.select, args.where.id, args.data, 'UpdateAppLimitCreditInput', 'id', 'appLimitCreditPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppLimitCredit',
            fieldName: 'updateAppLimitCredit',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('AppLimitCredit', 'deleteAppLimitCredit', 'appLimitCredit', {
            id: args.where.id,
        }, 'DeleteAppLimitCreditInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppLimitCredit',
            fieldName: 'deleteAppLimitCredit',
            document,
            variables,
        });
    }
}
