import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class AppMembershipModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('AppMembership', 'appMemberships', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'AppMembershipFilter', 'AppMembershipOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppMembership',
            fieldName: 'appMemberships',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('AppMembership', 'appMemberships', args.select, {
            where: args?.where,
        }, 'AppMembershipFilter', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppMembership',
            fieldName: 'appMemberships',
            document,
            variables,
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('AppMembership', 'appMemberships', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'AppMembershipFilter', 'AppMembershipOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'AppMembership',
            fieldName: 'appMembership',
            document,
            variables,
            transform: (data) => ({
                appMembership: data.appMemberships?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('AppMembership', 'createAppMembership', 'appMembership', args.select, args.data, 'CreateAppMembershipInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppMembership',
            fieldName: 'createAppMembership',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('AppMembership', 'updateAppMembership', 'appMembership', args.select, args.where.id, args.data, 'UpdateAppMembershipInput', 'id', 'appMembershipPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppMembership',
            fieldName: 'updateAppMembership',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('AppMembership', 'deleteAppMembership', 'appMembership', {
            id: args.where.id,
        }, 'DeleteAppMembershipInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'AppMembership',
            fieldName: 'deleteAppMembership',
            document,
            variables,
        });
    }
}
