11import { Access , IAccessInfo , Query , IQueryInfo , Permission } from './core' ;
2+ import type { ValidRoleOrArray , ValidRole } from '.' ;
23/**
34 * @classdesc
45 * AccessControl class that implements RBAC (Role-Based Access Control) basics
@@ -118,7 +119,7 @@ declare class AccessControl {
118119 * @name AccessControl#isLocked
119120 * @type {Boolean }
120121 */
121- readonly isLocked : boolean ;
122+ get isLocked ( ) : boolean ;
122123 /**
123124 * Gets the internal grants object that stores all current grants.
124125 *
@@ -234,7 +235,7 @@ declare class AccessControl {
234235 * @throws {AccessControlError } - If a role is extended by itself or a
235236 * non-existent role. Or if called after `.lock()` is called.
236237 */
237- extendRole ( roles : string | string [ ] , extenderRoles : string | string [ ] ) : AccessControl ;
238+ extendRole ( roles : ValidRoleOrArray , extenderRoles : ValidRoleOrArray ) : AccessControl ;
238239 /**
239240 * Removes all the given role(s) and their granted permissions, at once.
240241 * @chainable
@@ -246,7 +247,7 @@ declare class AccessControl {
246247 *
247248 * @throws {AccessControlError } - If called after `.lock()` is called.
248249 */
249- removeRoles ( roles : string | string [ ] ) : AccessControl ;
250+ removeRoles ( roles : ValidRoleOrArray ) : AccessControl ;
250251 /**
251252 * Removes all the given resources for all roles, at once.
252253 * Pass the `roles` argument to remove access to resources for those
@@ -263,7 +264,7 @@ declare class AccessControl {
263264 *
264265 * @throws {AccessControlError } - If called after `.lock()` is called.
265266 */
266- removeResources ( resources : string | string [ ] , roles ?: string | string [ ] ) : AccessControl ;
267+ removeResources ( resources : ValidRoleOrArray , roles ?: ValidRoleOrArray ) : AccessControl ;
267268 /**
268269 * Gets all the unique roles that have at least one access information.
269270 *
@@ -284,12 +285,12 @@ declare class AccessControl {
284285 *
285286 * @returns {Array<String> }
286287 */
287- getInheritedRolesOf ( role : string ) : string [ ] ;
288+ getInheritedRolesOf ( role : ValidRole ) : ValidRole [ ] ;
288289 /**
289290 * Alias of `getInheritedRolesOf`
290291 * @private
291292 */
292- getExtendedRolesOf ( role : string ) : string [ ] ;
293+ getExtendedRolesOf ( role : ValidRole ) : ValidRole [ ] ;
293294 /**
294295 * Gets all the unique resources that are granted access for at
295296 * least one role.
@@ -305,7 +306,7 @@ declare class AccessControl {
305306 *
306307 * @returns {Boolean }
307308 */
308- hasRole ( role : string | string [ ] ) : boolean ;
309+ hasRole ( role : ValidRoleOrArray ) : boolean ;
309310 /**
310311 * Checks whether grants include the given resource or resources.
311312 *
@@ -314,7 +315,7 @@ declare class AccessControl {
314315 *
315316 * @returns {Boolean }
316317 */
317- hasResource ( resource : string | string [ ] ) : boolean ;
318+ hasResource ( resource : ValidRoleOrArray ) : boolean ;
318319 /**
319320 * Gets an instance of `Query` object. This is used to check whether the
320321 * defined access is allowed for the given role(s) and resource. This
@@ -347,12 +348,12 @@ declare class AccessControl {
347348 * ac.can(['admin', 'user']).createOwn('profile');
348349 * // Note: when multiple roles checked, acquired attributes are unioned (merged).
349350 */
350- can ( role : string | string [ ] | IQueryInfo ) : Query ;
351+ can ( role : ValidRoleOrArray | IQueryInfo ) : Query ;
351352 /**
352353 * Alias of `can()`.
353354 * @private
354355 */
355- query ( role : string | string [ ] | IQueryInfo ) : Query ;
356+ query ( role : ValidRoleOrArray | IQueryInfo ) : Query ;
356357 /**
357358 * Gets an instance of `Permission` object that checks and defines the
358359 * granted access permissions for the target resource and role. Normally
@@ -437,12 +438,12 @@ declare class AccessControl {
437438 * // Note: when attributes is omitted, it will default to `['*']`
438439 * // which means all attributes (of the resource) are allowed.
439440 */
440- grant ( role ?: string | string [ ] | IAccessInfo ) : Access ;
441+ grant ( role ?: ValidRoleOrArray | IAccessInfo ) : Access ;
441442 /**
442443 * Alias of `grant()`.
443444 * @private
444445 */
445- allow ( role ?: string | string [ ] | IAccessInfo ) : Access ;
446+ allow ( role ?: ValidRoleOrArray | IAccessInfo ) : Access ;
446447 /**
447448 * Gets an instance of `Access` object. This is used to deny access to
448449 * specified resource(s) for the given role(s). Denying will only remove a
@@ -495,31 +496,31 @@ declare class AccessControl {
495496 * // To deny same resource for multiple roles:
496497 * ac.deny(['admin', 'user']).createOwn('profile');
497498 */
498- deny ( role ?: string | string [ ] | IAccessInfo ) : Access ;
499+ deny ( role ?: ValidRoleOrArray | IAccessInfo ) : Access ;
499500 /**
500501 * Alias of `deny()`.
501502 * @private
502503 */
503- reject ( role ?: string | string [ ] | IAccessInfo ) : Access ;
504+ reject ( role ?: ValidRoleOrArray | IAccessInfo ) : Access ;
504505 /**
505506 * @private
506507 */
507- _removePermission ( resources : string | string [ ] , roles ?: string | string [ ] , actionPossession ?: string ) : void ;
508+ _removePermission ( resources : ValidRoleOrArray , roles ?: ValidRoleOrArray , actionPossession ?: string ) : void ;
508509 /**
509510 * Documented separately in enums/Action
510511 * @private
511512 */
512- static readonly Action : any ;
513+ static get Action ( ) : any ;
513514 /**
514515 * Documented separately in enums/Possession
515516 * @private
516517 */
517- static readonly Possession : any ;
518+ static get Possession ( ) : any ;
518519 /**
519520 * Documented separately in AccessControlError
520521 * @private
521522 */
522- static readonly Error : any ;
523+ static get Error ( ) : any ;
523524 /**
524525 * A utility method for deep cloning the given data object(s) while
525526 * filtering its properties by the given attribute (glob) notations.
0 commit comments