import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class AppGrantModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('AppGrant', 'appGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'AppGrantFilter', 'AppGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppGrant',
            fieldName: 'appGrants',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('AppGrant', 'appGrants', args.select, {
            where: args?.where,
        }, 'AppGrantFilter', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppGrant',
            fieldName: 'appGrants',
            document,
            variables,
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('AppGrant', 'appGrants', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'AppGrantFilter', 'AppGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppGrant',
            fieldName: 'appGrant',
            document,
            variables,
            transform: (data) => ({
                appGrant: data.appGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('AppGrant', 'createAppGrant', 'appGrant', args.select, args.data, 'CreateAppGrantInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppGrant',
            fieldName: 'createAppGrant',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('AppGrant', 'updateAppGrant', 'appGrant', args.select, args.where.id, args.data, 'UpdateAppGrantInput', 'id', 'appGrantPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppGrant',
            fieldName: 'updateAppGrant',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('AppGrant', 'deleteAppGrant', 'appGrant', {
            id: args.where.id,
        }, 'DeleteAppGrantInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppGrant',
            fieldName: 'deleteAppGrant',
            document,
            variables,
        });
    }
}
