import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class AppOwnerGrantModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('AppOwnerGrant', 'appOwnerGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'AppOwnerGrantFilter', 'AppOwnerGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppOwnerGrant',
            fieldName: 'appOwnerGrants',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('AppOwnerGrant', 'appOwnerGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'AppOwnerGrantFilter', 'AppOwnerGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppOwnerGrant',
            fieldName: 'appOwnerGrant',
            document,
            variables,
            transform: (data) => ({
                appOwnerGrant: data.appOwnerGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('AppOwnerGrant', 'appOwnerGrants', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'AppOwnerGrantFilter', 'AppOwnerGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppOwnerGrant',
            fieldName: 'appOwnerGrant',
            document,
            variables,
            transform: (data) => ({
                appOwnerGrant: data.appOwnerGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('AppOwnerGrant', 'createAppOwnerGrant', 'appOwnerGrant', args.select, args.data, 'CreateAppOwnerGrantInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppOwnerGrant',
            fieldName: 'createAppOwnerGrant',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('AppOwnerGrant', 'updateAppOwnerGrant', 'appOwnerGrant', args.select, args.where.id, args.data, 'UpdateAppOwnerGrantInput', 'id', 'appOwnerGrantPatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppOwnerGrant',
            fieldName: 'updateAppOwnerGrant',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('AppOwnerGrant', 'deleteAppOwnerGrant', 'appOwnerGrant', {
            id: args.where.id,
        }, 'DeleteAppOwnerGrantInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppOwnerGrant',
            fieldName: 'deleteAppOwnerGrant',
            document,
            variables,
        });
    }
}
