import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class AppAdminGrantModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('AppAdminGrant', 'appAdminGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'AppAdminGrantFilter', 'AppAdminGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppAdminGrant',
            fieldName: 'appAdminGrants',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('AppAdminGrant', 'appAdminGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'AppAdminGrantFilter', 'AppAdminGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppAdminGrant',
            fieldName: 'appAdminGrant',
            document,
            variables,
            transform: (data) => ({
                appAdminGrant: data.appAdminGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('AppAdminGrant', 'appAdminGrants', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'AppAdminGrantFilter', 'AppAdminGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppAdminGrant',
            fieldName: 'appAdminGrant',
            document,
            variables,
            transform: (data) => ({
                appAdminGrant: data.appAdminGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('AppAdminGrant', 'createAppAdminGrant', 'appAdminGrant', args.select, args.data, 'CreateAppAdminGrantInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppAdminGrant',
            fieldName: 'createAppAdminGrant',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('AppAdminGrant', 'updateAppAdminGrant', 'appAdminGrant', args.select, args.where.id, args.data, 'UpdateAppAdminGrantInput', 'id', 'appAdminGrantPatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppAdminGrant',
            fieldName: 'updateAppAdminGrant',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('AppAdminGrant', 'deleteAppAdminGrant', 'appAdminGrant', {
            id: args.where.id,
        }, 'DeleteAppAdminGrantInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppAdminGrant',
            fieldName: 'deleteAppAdminGrant',
            document,
            variables,
        });
    }
}
