import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class PrincipalEntityModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('PrincipalEntity', 'principalEntities', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'PrincipalEntityFilter', 'PrincipalEntityOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'PrincipalEntity',
            fieldName: 'principalEntities',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('PrincipalEntity', 'principalEntities', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'PrincipalEntityFilter', 'PrincipalEntityOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'PrincipalEntity',
            fieldName: 'principalEntity',
            document,
            variables,
            transform: (data) => ({
                principalEntity: data.principalEntities?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('PrincipalEntity', 'principalEntities', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'PrincipalEntityFilter', 'PrincipalEntityOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'PrincipalEntity',
            fieldName: 'principalEntity',
            document,
            variables,
            transform: (data) => ({
                principalEntity: data.principalEntities?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('PrincipalEntity', 'createPrincipalEntity', 'principalEntity', args.select, args.data, 'CreatePrincipalEntityInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'PrincipalEntity',
            fieldName: 'createPrincipalEntity',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('PrincipalEntity', 'updatePrincipalEntity', 'principalEntity', args.select, args.where.id, args.data, 'UpdatePrincipalEntityInput', 'id', 'principalEntityPatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'PrincipalEntity',
            fieldName: 'updatePrincipalEntity',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('PrincipalEntity', 'deletePrincipalEntity', 'principalEntity', {
            id: args.where.id,
        }, 'DeletePrincipalEntityInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'PrincipalEntity',
            fieldName: 'deletePrincipalEntity',
            document,
            variables,
        });
    }
}
