import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class OrgLimitCreditModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('OrgLimitCredit', 'orgLimitCredits', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'OrgLimitCreditFilter', 'OrgLimitCreditOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'OrgLimitCredit',
            fieldName: 'orgLimitCredits',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('OrgLimitCredit', 'orgLimitCredits', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'OrgLimitCreditFilter', 'OrgLimitCreditOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'OrgLimitCredit',
            fieldName: 'orgLimitCredit',
            document,
            variables,
            transform: (data) => ({
                orgLimitCredit: data.orgLimitCredits?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('OrgLimitCredit', 'orgLimitCredits', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'OrgLimitCreditFilter', 'OrgLimitCreditOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'OrgLimitCredit',
            fieldName: 'orgLimitCredit',
            document,
            variables,
            transform: (data) => ({
                orgLimitCredit: data.orgLimitCredits?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('OrgLimitCredit', 'createOrgLimitCredit', 'orgLimitCredit', args.select, args.data, 'CreateOrgLimitCreditInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'OrgLimitCredit',
            fieldName: 'createOrgLimitCredit',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('OrgLimitCredit', 'updateOrgLimitCredit', 'orgLimitCredit', args.select, args.where.id, args.data, 'UpdateOrgLimitCreditInput', 'id', 'orgLimitCreditPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'OrgLimitCredit',
            fieldName: 'updateOrgLimitCredit',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('OrgLimitCredit', 'deleteOrgLimitCredit', 'orgLimitCredit', {
            id: args.where.id,
        }, 'DeleteOrgLimitCreditInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'OrgLimitCredit',
            fieldName: 'deleteOrgLimitCredit',
            document,
            variables,
        });
    }
}
