import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class OrgGrantModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('OrgGrant', 'orgGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'OrgGrantFilter', 'OrgGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'OrgGrant',
            fieldName: 'orgGrants',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('OrgGrant', 'orgGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'OrgGrantFilter', 'OrgGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'OrgGrant',
            fieldName: 'orgGrant',
            document,
            variables,
            transform: (data) => ({
                orgGrant: data.orgGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('OrgGrant', 'orgGrants', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'OrgGrantFilter', 'OrgGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'OrgGrant',
            fieldName: 'orgGrant',
            document,
            variables,
            transform: (data) => ({
                orgGrant: data.orgGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('OrgGrant', 'createOrgGrant', 'orgGrant', args.select, args.data, 'CreateOrgGrantInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'OrgGrant',
            fieldName: 'createOrgGrant',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('OrgGrant', 'updateOrgGrant', 'orgGrant', args.select, args.where.id, args.data, 'UpdateOrgGrantInput', 'id', 'orgGrantPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'OrgGrant',
            fieldName: 'updateOrgGrant',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('OrgGrant', 'deleteOrgGrant', 'orgGrant', {
            id: args.where.id,
        }, 'DeleteOrgGrantInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'OrgGrant',
            fieldName: 'deleteOrgGrant',
            document,
            variables,
        });
    }
}
