import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class PrincipalModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('Principal', 'principals', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'PrincipalFilter', 'PrincipalOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Principal',
            fieldName: 'principals',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('Principal', 'principals', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'PrincipalFilter', 'PrincipalOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Principal',
            fieldName: 'principal',
            document,
            variables,
            transform: (data) => ({
                principal: data.principals?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('Principal', 'principals', args.select, {
            where: {
                principalId: {
                    equalTo: args.principalId,
                },
            },
            first: 1,
        }, 'PrincipalFilter', 'PrincipalOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Principal',
            fieldName: 'principal',
            document,
            variables,
            transform: (data) => ({
                principal: data.principals?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('Principal', 'createPrincipal', 'principal', args.select, args.data, 'CreatePrincipalInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Principal',
            fieldName: 'createPrincipal',
            document,
            variables,
        });
    }
}
