import { JoinNode } from '../operation-node/join-node.js' ; import { OperationNodeSource } from '../operation-node/operation-node-source.js' ; import { ExistsExpression , FilterOperator , FilterValueExpressionOrList , parseExistFilter , parseNotExistFilter , parseOnFilter , parseReferenceFilter , } from '../parser/filter-parser.js' ; import { ParseContext } from '../parser/parse-context.js' ; import { ReferenceExpression } from '../parser/reference-parser.js' ; import { freeze } from '../util/object-utils.js' ; import { preventAwait } from '../util/prevent-await.js' ; import { AnyRawBuilder } from '../util/type-utils.js' ; export class JoinBuilder < DB , TB extends keyof DB > implements OperationNodeSource { readonly #props : JoinBuilderProps ; constructor ( props ) { this . #props = freeze ( props ) ; } /**
     * Just like  WhereInterface . where but adds an item to the join's
     * `on` clause instead.
     *
     * See  WhereInterface . where for documentation and examples.
      on < RE extends ReferenceExpression < DB , TB > > ( lhs , op , rhs ) ; on ( grouper ) ; on ( raw ) ; on ( ... args ) { return new JoinBuilder ( { ... this . #props , joinNode : JoinNode . cloneWithOn ( this . #props . joinNode , parseOnFilter ( this . #props . parseContext , args ) ) , } ) ; } /**
     * Just like  WhereInterface . orWhere but adds an item to the join's
     * `on` clause instead.
     *
     * See  WhereInterface . orWhere for documentation and examples.
      orOn < RE extends ReferenceExpression < DB , TB > > ( lhs , op , rhs ) ; orOn ( grouper ) ; orOn ( raw ) ; orOn ( ... args ) { return new JoinBuilder ( { ... this . #props , joinNode : JoinNode . cloneWithOrOn ( this . #props . joinNode , parseOnFilter ( this . #props . parseContext , args ) ) , } ) ; } /**
     * Just like  WhereInterface . whereRef but adds an item to the join's
     * `on` clause instead.
     *
     * See  WhereInterface . whereRef for documentation and examples.
      onRef ( lhs , op , rhs ) { return new JoinBuilder ( { ... this . #props , joinNode : JoinNode . cloneWithOn ( this . #props . joinNode , parseReferenceFilter ( this . #props . parseContext , lhs , op , rhs ) ) , } ) ; } /**
     * Just like  WhereInterface . orWhereRef but adds an item to the join's
     * `on` clause instead.
     *
     * See  WhereInterface . orWhereRef for documentation and examples.
      orOnRef ( lhs , op , rhs ) { return new JoinBuilder ( { ... this . #props , joinNode : JoinNode . cloneWithOrOn ( this . #props . joinNode , parseReferenceFilter ( this . #props . parseContext , lhs , op , rhs ) ) , } ) ; } /**
     * Just like  WhereInterface . whereExists but adds an item to the join's
     * `on` clause instead.
     *
     * See  WhereInterface . whereExists for documentation and examples.
      onExists ( arg ) { return new JoinBuilder ( { ... this . #props , joinNode : JoinNode . cloneWithOn ( this . #props . joinNode , parseExistFilter ( this . #props . parseContext , arg ) ) , } ) ; } /**
     * Just like  WhereInterface . whereNotExists but adds an item to the join's
     * `on` clause instead.
     *
     * See  WhereInterface . whereNotExists for documentation and examples.
      onNotExists ( arg ) { return new JoinBuilder ( { ... this . #props , joinNode : JoinNode . cloneWithOn ( this . #props . joinNode , parseNotExistFilter ( this . #props . parseContext , arg ) ) , } ) ; } /**
     * Just like  WhereInterface . orWhereExists but adds an item to the join's
     * `on` clause instead.
     *
     * See  WhereInterface . orWhereExists for documentation and examples.
      orOnExists ( arg ) { return new JoinBuilder ( { ... this . #props , joinNode : JoinNode . cloneWithOrOn ( this . #props . joinNode , parseExistFilter ( this . #props . parseContext , arg ) ) , } ) ; } /**
     * Just like  WhereInterface . orWhereNotExists but adds an item to the join's
     * `on` clause instead.
     *
     * See  WhereInterface . orWhereNotExists for documentation and examples.
      orOnNotExists ( arg ) { return new JoinBuilder ( { ... this . #props , joinNode : JoinNode . cloneWithOrOn ( this . #props . joinNode , parseNotExistFilter ( this . #props . parseContext , arg ) ) , } ) ; } toOperationNode ( ) { return this . #props . joinNode ; } } preventAwait ( JoinBuilder , "don't await JoinBuilder instances. They are never executed directly and are always just a part of a query." ) ; export interface JoinBuilderProps { readonly joinNode : JoinNode ; readonly parseContext : ParseContext ; }