import { CommonUtil } from './../utils/' ; import { IQueryInfo , Permission } from '../core' ; class inner memberof class Query { protected type { IQueryInfo } protected _ : IQueryInfo = { } ; protected type { Any } protected _grants : any ; private param { Any } grants param { string | Array < String > | IQueryInfo } role Either a single or array of roles or an
     *          {@link ?api=ac#AccessControl~IQueryInfo|`IQueryInfo` arbitrary object} .
      constructor ( grants , role ? ) { this . _grants = grants ; if ( CommonUtil . type ( role ) === 'object' ) { this . _ = < IQueryInfo > role ; } else { this . _ . role = < string | string [ ] > role ; } } param { String | Array < String > } roles returns { Query } role ( role ) { this . _ . role = role ; return this ; } param { String } resource returns { Query } resource ( resource ) { this . _ . resource = resource ; return this ; } param { String } resource throws returns { Permission } on ( resource , skipConditions ? ) { return this . _getPermission ( this . _ . action , resource , skipConditions || this . _ . skipConditions , this . _ . checkInSync ) ; } sync ( ) { this . _ . checkInSync = true ; return this ; } param { String } context returns { Query } context ( context ) { this . _ . context = context ; return this ; } param { Boolean } value returns { Query } skipConditions ( value ) { this . _ . skipConditions = value ; return this ; } /**
     *  Alias of `context`
     */ with ( context ) { return this . context ( context ) ; } param { String } action execute ( action ) { this . _ . action = action ; return this ; } private param { String } action param { String } resource returns { Permission | Promise < Permission > } private _getPermission ( action , resource ? , skipConditions ? , checkInSync ? ) { this . _ . action = action ; if ( resource ) this . _ . resource = resource ; if ( skipConditions !== undefined ) { this . _ . skipConditions = skipConditions ; } if ( checkInSync ) { return new Permission ( this . _ , CommonUtil . getUnionAttrsOfRolesSync ( this . _grants , this . _ ) ) ; } return CommonUtil . getUnionAttrsOfRoles ( this . _grants , this . _ ) . then ( ( attributes ) => new Permission ( this . _ , attributes ) ) ; } } export { Query } ;