"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrincipalModel = void 0;
const query_builder_1 = require("../query-builder");
const input_types_1 = require("../input-types");
class PrincipalModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = (0, query_builder_1.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', input_types_1.connectionFieldsMap);
        return new query_builder_1.QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Principal',
            fieldName: 'principals',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = (0, query_builder_1.buildFindFirstDocument)('Principal', 'principals', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'PrincipalFilter', 'PrincipalOrderBy', input_types_1.connectionFieldsMap);
        return new query_builder_1.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 } = (0, query_builder_1.buildFindManyDocument)('Principal', 'principals', args.select, {
            where: {
                principalId: {
                    equalTo: args.principalId,
                },
            },
            first: 1,
        }, 'PrincipalFilter', 'PrincipalOrderBy', input_types_1.connectionFieldsMap);
        return new query_builder_1.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 } = (0, query_builder_1.buildCreateDocument)('Principal', 'createPrincipal', 'principal', args.select, args.data, 'CreatePrincipalInput', input_types_1.connectionFieldsMap);
        return new query_builder_1.QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Principal',
            fieldName: 'createPrincipal',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = (0, query_builder_1.buildDeleteByPkDocument)('Principal', 'deletePrincipal', 'principal', {
            principalId: args.where.principalId,
        }, 'DeletePrincipalInput', args.select, input_types_1.connectionFieldsMap);
        return new query_builder_1.QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Principal',
            fieldName: 'deletePrincipal',
            document,
            variables,
        });
    }
}
exports.PrincipalModel = PrincipalModel;
