import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class OrgMembershipModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('OrgMembership', 'orgMemberships', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'OrgMembershipFilter', 'OrgMembershipOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'OrgMembership',
            fieldName: 'orgMemberships',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('OrgMembership', 'orgMemberships', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'OrgMembershipFilter', 'OrgMembershipOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'OrgMembership',
            fieldName: 'orgMembership',
            document,
            variables,
            transform: (data) => ({
                orgMembership: data.orgMemberships?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('OrgMembership', 'orgMemberships', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'OrgMembershipFilter', 'OrgMembershipOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'OrgMembership',
            fieldName: 'orgMembership',
            document,
            variables,
            transform: (data) => ({
                orgMembership: data.orgMemberships?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('OrgMembership', 'createOrgMembership', 'orgMembership', args.select, args.data, 'CreateOrgMembershipInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'OrgMembership',
            fieldName: 'createOrgMembership',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('OrgMembership', 'updateOrgMembership', 'orgMembership', args.select, args.where.id, args.data, 'UpdateOrgMembershipInput', 'id', 'orgMembershipPatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'OrgMembership',
            fieldName: 'updateOrgMembership',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('OrgMembership', 'deleteOrgMembership', 'orgMembership', {
            id: args.where.id,
        }, 'DeleteOrgMembershipInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'OrgMembership',
            fieldName: 'deleteOrgMembership',
            document,
            variables,
        });
    }
}
