Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexzPurewoko committed Dec 22, 2023
1 parent 36c8b3c commit a7ea4d2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
6 changes: 3 additions & 3 deletions dist/cjs/core/comparator/abilityChecker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ export declare class AbilityChecker {
*
* @returns {boolean} true if the current user has the capabilities for current rule
*/
can(): boolean;
can(...args: any[]): boolean;
/**
* A negated approach for checking the user abilities.
* See `can()` for more information.
*
* @return bool true if the current user does not have the capabilities for current rule
*/
cannot(): boolean;
cannot(...args: any[]): boolean;
/**
* Use the same approach as method `can()` does. But via customized syntax or rules.
* Via Syntax :
* scope:resource/field:action
*
*
* @param {(Rule|string)} $ruleOrSyntax A syntax (string) for defining rules or with using Rule
* @param {(Rule|string)} ruleOrSyntax A syntax (string) for defining rules or with using Rule
* @return {boolean} true if the current user has the rule
*/
hasRule(ruleOrSyntax: (Rule | string)): boolean;
Expand Down
21 changes: 10 additions & 11 deletions dist/cjs/core/comparator/abilityChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class AbilityChecker {
*
* @returns {boolean} true if the current user has the capabilities for current rule
*/
can() {
const argumentLength = arguments.length;
can(...args) {
const argumentLength = args.length;
let scope = 'global'; // default scope
let resource = '';
let action = '';
Expand All @@ -50,7 +50,7 @@ class AbilityChecker {
throw new Error('Cannot pass with empty argument');
}
if (argumentLength === 1) {
let rule = arguments[0];
let rule = args[0];
if (!(rule instanceof rule_1.Rule)) {
rule = ruleCompiler_1.RuleCompiler.compile(rule);
}
Expand All @@ -60,10 +60,10 @@ class AbilityChecker {
field = rule.getResource().getField();
}
else {
action = arguments[0];
resource = arguments[1];
scope = argumentLength >= 3 ? arguments[2] : scope;
field = argumentLength >= 4 ? arguments[3] : null;
action = args[0];
resource = args[1];
scope = argumentLength >= 3 ? args[2] : scope;
field = argumentLength >= 4 ? args[3] : null;
}
const specificActionRules = this.compiledRules.queryRule(scope, resource, action);
const specificNormalRules = [];
Expand Down Expand Up @@ -99,18 +99,17 @@ class AbilityChecker {
*
* @return bool true if the current user does not have the capabilities for current rule
*/
cannot() {
cannot(...args) {
// @ts-ignore
// @todo Please overload this function!
return !this.can(...arguments);
return !this.can(...args);
}
/**
* Use the same approach as method `can()` does. But via customized syntax or rules.
* Via Syntax :
* scope:resource/field:action
*
*
* @param {(Rule|string)} $ruleOrSyntax A syntax (string) for defining rules or with using Rule
* @param {(Rule|string)} ruleOrSyntax A syntax (string) for defining rules or with using Rule
* @return {boolean} true if the current user has the rule
*/
hasRule(ruleOrSyntax) {
Expand Down
6 changes: 3 additions & 3 deletions dist/esm/core/comparator/abilityChecker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ export declare class AbilityChecker {
*
* @returns {boolean} true if the current user has the capabilities for current rule
*/
can(): boolean;
can(...args: any[]): boolean;
/**
* A negated approach for checking the user abilities.
* See `can()` for more information.
*
* @return bool true if the current user does not have the capabilities for current rule
*/
cannot(): boolean;
cannot(...args: any[]): boolean;
/**
* Use the same approach as method `can()` does. But via customized syntax or rules.
* Via Syntax :
* scope:resource/field:action
*
*
* @param {(Rule|string)} $ruleOrSyntax A syntax (string) for defining rules or with using Rule
* @param {(Rule|string)} ruleOrSyntax A syntax (string) for defining rules or with using Rule
* @return {boolean} true if the current user has the rule
*/
hasRule(ruleOrSyntax: (Rule | string)): boolean;
Expand Down
21 changes: 10 additions & 11 deletions dist/esm/core/comparator/abilityChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export class AbilityChecker {
*
* @returns {boolean} true if the current user has the capabilities for current rule
*/
can() {
const argumentLength = arguments.length;
can(...args) {
const argumentLength = args.length;
let scope = 'global'; // default scope
let resource = '';
let action = '';
Expand All @@ -47,7 +47,7 @@ export class AbilityChecker {
throw new Error('Cannot pass with empty argument');
}
if (argumentLength === 1) {
let rule = arguments[0];
let rule = args[0];
if (!(rule instanceof Rule)) {
rule = RuleCompiler.compile(rule);
}
Expand All @@ -57,10 +57,10 @@ export class AbilityChecker {
field = rule.getResource().getField();
}
else {
action = arguments[0];
resource = arguments[1];
scope = argumentLength >= 3 ? arguments[2] : scope;
field = argumentLength >= 4 ? arguments[3] : null;
action = args[0];
resource = args[1];
scope = argumentLength >= 3 ? args[2] : scope;
field = argumentLength >= 4 ? args[3] : null;
}
const specificActionRules = this.compiledRules.queryRule(scope, resource, action);
const specificNormalRules = [];
Expand Down Expand Up @@ -96,18 +96,17 @@ export class AbilityChecker {
*
* @return bool true if the current user does not have the capabilities for current rule
*/
cannot() {
cannot(...args) {
// @ts-ignore
// @todo Please overload this function!
return !this.can(...arguments);
return !this.can(...args);
}
/**
* Use the same approach as method `can()` does. But via customized syntax or rules.
* Via Syntax :
* scope:resource/field:action
*
*
* @param {(Rule|string)} $ruleOrSyntax A syntax (string) for defining rules or with using Rule
* @param {(Rule|string)} ruleOrSyntax A syntax (string) for defining rules or with using Rule
* @return {boolean} true if the current user has the rule
*/
hasRule(ruleOrSyntax) {
Expand Down

0 comments on commit a7ea4d2

Please sign in to comment.