import { Expr , query as q } from 'faunadb' ; import { Fn } from '~/types/db' ; import { Fauna , FaunaRule , FaunaRuleLambda } from '~/types/fauna' ; export function RuleBuilder ( rule ) { return ( ... args ) => ( ( rule || { } ) . query as Fn < Fauna . Expr > ) ( ... args ) ; } export function Rule ( rule ) { return ( rule || { } ) . query ; } export function Rules ( rules ) { if ( rules . length > 1 ) { return q . Or ( ... rules ) ; } else { return rules [ 0 ] ; } }