import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class AppPermissionModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('AppPermission', 'appPermissions', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'AppPermissionFilter', 'AppPermissionOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppPermission',
            fieldName: 'appPermissions',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('AppPermission', 'appPermissions', args.select, {
            where: args?.where,
        }, 'AppPermissionFilter', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppPermission',
            fieldName: 'appPermissions',
            document,
            variables,
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('AppPermission', 'appPermissions', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'AppPermissionFilter', 'AppPermissionOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppPermission',
            fieldName: 'appPermission',
            document,
            variables,
            transform: (data) => ({
                appPermission: data.appPermissions?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('AppPermission', 'createAppPermission', 'appPermission', args.select, args.data, 'CreateAppPermissionInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppPermission',
            fieldName: 'createAppPermission',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('AppPermission', 'updateAppPermission', 'appPermission', args.select, args.where.id, args.data, 'UpdateAppPermissionInput', 'id', 'appPermissionPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppPermission',
            fieldName: 'updateAppPermission',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('AppPermission', 'deleteAppPermission', 'appPermission', {
            id: args.where.id,
        }, 'DeleteAppPermissionInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppPermission',
            fieldName: 'deleteAppPermission',
            document,
            variables,
        });
    }
}
