@yelon/acl 12.0.17 → 12.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from './src/acl.service';
2
- export * from './src/acl-if.directive';
3
- export * from './src/acl.directive';
4
- export * from './src/acl.config';
5
- export * from './src/acl.type';
6
- export * from './src/acl-guard';
7
- export * from './src/acl.module';
1
+ export * from './src/acl.service';
2
+ export * from './src/acl-if.directive';
3
+ export * from './src/acl.directive';
4
+ export * from './src/acl.config';
5
+ export * from './src/acl.type';
6
+ export * from './src/acl-guard';
7
+ export * from './src/acl.module';
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@yelon/acl",
3
- "version": "12.0.17",
3
+ "version": "12.0.18",
4
4
  "author": "devcui<devcui@outlook.com>",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "@yelon/util": "^12.0.17",
7
+ "@yelon/util": "^12.0.18",
8
8
  "tslib": "^2.2.0"
9
9
  },
10
10
  "main": "bundles/acl.umd.js",
@@ -1,25 +1,25 @@
1
- import { Injector } from '@angular/core';
2
- import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, CanLoad, Route, Router, RouterStateSnapshot } from '@angular/router';
3
- import { Observable } from 'rxjs';
4
- import { ACLService } from './acl.service';
5
- /**
6
- * Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
7
- *
8
- * ```ts
9
- * data: {
10
- * path: 'home',
11
- * canActivate: [ ACLGuard ],
12
- * data: { guard: 'user1' }
13
- * }
14
- * ```
15
- */
16
- export declare class ACLGuard implements CanActivate, CanActivateChild, CanLoad {
17
- private srv;
18
- private router;
19
- private injector;
20
- constructor(srv: ACLService, router: Router, injector: Injector);
21
- private process;
22
- canLoad(route: Route): Observable<boolean>;
23
- canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean>;
24
- canActivate(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot | null): Observable<boolean>;
25
- }
1
+ import { Injector } from '@angular/core';
2
+ import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, CanLoad, Route, Router, RouterStateSnapshot } from '@angular/router';
3
+ import { Observable } from 'rxjs';
4
+ import { ACLService } from './acl.service';
5
+ /**
6
+ * Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
7
+ *
8
+ * ```ts
9
+ * data: {
10
+ * path: 'home',
11
+ * canActivate: [ ACLGuard ],
12
+ * data: { guard: 'user1' }
13
+ * }
14
+ * ```
15
+ */
16
+ export declare class ACLGuard implements CanActivate, CanActivateChild, CanLoad {
17
+ private srv;
18
+ private router;
19
+ private injector;
20
+ constructor(srv: ACLService, router: Router, injector: Injector);
21
+ private process;
22
+ canLoad(route: Route): Observable<boolean>;
23
+ canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean>;
24
+ canActivate(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot | null): Observable<boolean>;
25
+ }
@@ -1,23 +1,23 @@
1
- import { OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
2
- import { ACLService } from './acl.service';
3
- import { ACLCanType } from './acl.type';
4
- export declare class ACLIfDirective implements OnDestroy {
5
- private srv;
6
- private _viewContainer;
7
- static ngAcceptInputType_except: boolean | string | undefined | null;
8
- private _value;
9
- private _change$;
10
- private _thenTemplateRef;
11
- private _elseTemplateRef;
12
- private _thenViewRef;
13
- private _elseViewRef;
14
- private _except;
15
- constructor(templateRef: TemplateRef<void>, srv: ACLService, _viewContainer: ViewContainerRef);
16
- set aclIf(value: ACLCanType);
17
- set aclIfThen(templateRef: TemplateRef<void> | null);
18
- set aclIfElse(templateRef: TemplateRef<void> | null);
19
- set except(value: boolean);
20
- get except(): boolean;
21
- protected _updateView(): void;
22
- ngOnDestroy(): void;
23
- }
1
+ import { OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
2
+ import { ACLService } from './acl.service';
3
+ import { ACLCanType } from './acl.type';
4
+ export declare class ACLIfDirective implements OnDestroy {
5
+ private srv;
6
+ private _viewContainer;
7
+ static ngAcceptInputType_except: boolean | string | undefined | null;
8
+ private _value;
9
+ private _change$;
10
+ private _thenTemplateRef;
11
+ private _elseTemplateRef;
12
+ private _thenViewRef;
13
+ private _elseViewRef;
14
+ private _except;
15
+ constructor(templateRef: TemplateRef<void>, srv: ACLService, _viewContainer: ViewContainerRef);
16
+ set aclIf(value: ACLCanType);
17
+ set aclIfThen(templateRef: TemplateRef<void> | null);
18
+ set aclIfElse(templateRef: TemplateRef<void> | null);
19
+ set except(value: boolean);
20
+ get except(): boolean;
21
+ protected _updateView(): void;
22
+ ngOnDestroy(): void;
23
+ }
@@ -1,2 +1,2 @@
1
- import { YunzaiACLConfig } from '@yelon/util/config';
2
- export declare const ACL_DEFAULT_CONFIG: YunzaiACLConfig;
1
+ import { YunzaiACLConfig } from '@yelon/util/config';
2
+ export declare const ACL_DEFAULT_CONFIG: YunzaiACLConfig;
@@ -1,15 +1,15 @@
1
- import { ElementRef, OnDestroy, Renderer2 } from '@angular/core';
2
- import { ACLService } from './acl.service';
3
- import { ACLCanType } from './acl.type';
4
- export declare class ACLDirective implements OnDestroy {
5
- private el;
6
- private renderer;
7
- protected srv: ACLService;
8
- private _value;
9
- private change$;
10
- set acl(value: ACLCanType);
11
- set ability(value: ACLCanType);
12
- private set;
13
- constructor(el: ElementRef, renderer: Renderer2, srv: ACLService);
14
- ngOnDestroy(): void;
15
- }
1
+ import { ElementRef, OnDestroy, Renderer2 } from '@angular/core';
2
+ import { ACLService } from './acl.service';
3
+ import { ACLCanType } from './acl.type';
4
+ export declare class ACLDirective implements OnDestroy {
5
+ private el;
6
+ private renderer;
7
+ protected srv: ACLService;
8
+ private _value;
9
+ private change$;
10
+ set acl(value: ACLCanType);
11
+ set ability(value: ACLCanType);
12
+ private set;
13
+ constructor(el: ElementRef, renderer: Renderer2, srv: ACLService);
14
+ ngOnDestroy(): void;
15
+ }
@@ -1,4 +1,4 @@
1
- import { ModuleWithProviders } from '@angular/core';
2
- export declare class YelonACLModule {
3
- static forRoot(): ModuleWithProviders<YelonACLModule>;
4
- }
1
+ import { ModuleWithProviders } from '@angular/core';
2
+ export declare class YelonACLModule {
3
+ static forRoot(): ModuleWithProviders<YelonACLModule>;
4
+ }
@@ -1,75 +1,75 @@
1
- import { Observable } from 'rxjs';
2
- import { YunzaiConfigService } from '@yelon/util/config';
3
- import { ACLCanType, ACLType } from './acl.type';
4
- /**
5
- * ACL 控制服务,[在线文档](https://ng.yunzainfo.com/acl)
6
- *
7
- * 务必在根目录注册 `YelonACLModule.forRoot()` 才能使用服务
8
- */
9
- export declare class ACLService {
10
- private options;
11
- private roles;
12
- private abilities;
13
- private full;
14
- private aclChange;
15
- /** ACL变更通知 */
16
- get change(): Observable<ACLType | boolean | null>;
17
- /** 获取所有数据 */
18
- get data(): {
19
- full: boolean;
20
- roles: string[];
21
- abilities: Array<string | number>;
22
- };
23
- get guard_url(): string;
24
- constructor(configSrv: YunzaiConfigService);
25
- private parseACLType;
26
- /**
27
- * 设置当前用户角色或权限能力(会先清除所有)
28
- */
29
- set(value: ACLType): void;
30
- /**
31
- * 标识当前用户为全量,即不受限
32
- */
33
- setFull(val: boolean): void;
34
- /**
35
- * 设置当前用户权限能力(会先清除所有)
36
- */
37
- setAbility(abilities: Array<number | string>): void;
38
- /**
39
- * 设置当前用户角色(会先清除所有)
40
- */
41
- setRole(roles: string[]): void;
42
- /**
43
- * 为当前用户增加角色或权限能力
44
- */
45
- add(value: ACLType): void;
46
- /**
47
- * 为当前用户附加角色
48
- */
49
- attachRole(roles: string[]): void;
50
- /**
51
- * 为当前用户附加权限
52
- */
53
- attachAbility(abilities: Array<number | string>): void;
54
- /**
55
- * 为当前用户移除角色
56
- */
57
- removeRole(roles: string[]): void;
58
- /**
59
- * 为当前用户移除权限
60
- */
61
- removeAbility(abilities: Array<number | string>): void;
62
- /**
63
- * 当前用户是否有对应角色,其实 `number` 表示Ability
64
- *
65
- * - 当 `full: true` 或参数 `null` 时返回 `true`
66
- * - 若使用 `ACLType` 参数,可以指定 `mode` 校验模式
67
- */
68
- can(roleOrAbility: ACLCanType | null): boolean;
69
- /** @inner */
70
- parseAbility(value: ACLCanType): ACLCanType;
71
- /**
72
- * 当前用户是否有对应权限点
73
- */
74
- canAbility(value: ACLCanType): boolean;
75
- }
1
+ import { Observable } from 'rxjs';
2
+ import { YunzaiConfigService } from '@yelon/util/config';
3
+ import { ACLCanType, ACLType } from './acl.type';
4
+ /**
5
+ * ACL 控制服务,[在线文档](https://ng.yunzainfo.com/acl)
6
+ *
7
+ * 务必在根目录注册 `YelonACLModule.forRoot()` 才能使用服务
8
+ */
9
+ export declare class ACLService {
10
+ private options;
11
+ private roles;
12
+ private abilities;
13
+ private full;
14
+ private aclChange;
15
+ /** ACL变更通知 */
16
+ get change(): Observable<ACLType | boolean | null>;
17
+ /** 获取所有数据 */
18
+ get data(): {
19
+ full: boolean;
20
+ roles: string[];
21
+ abilities: Array<string | number>;
22
+ };
23
+ get guard_url(): string;
24
+ constructor(configSrv: YunzaiConfigService);
25
+ private parseACLType;
26
+ /**
27
+ * 设置当前用户角色或权限能力(会先清除所有)
28
+ */
29
+ set(value: ACLType): void;
30
+ /**
31
+ * 标识当前用户为全量,即不受限
32
+ */
33
+ setFull(val: boolean): void;
34
+ /**
35
+ * 设置当前用户权限能力(会先清除所有)
36
+ */
37
+ setAbility(abilities: Array<number | string>): void;
38
+ /**
39
+ * 设置当前用户角色(会先清除所有)
40
+ */
41
+ setRole(roles: string[]): void;
42
+ /**
43
+ * 为当前用户增加角色或权限能力
44
+ */
45
+ add(value: ACLType): void;
46
+ /**
47
+ * 为当前用户附加角色
48
+ */
49
+ attachRole(roles: string[]): void;
50
+ /**
51
+ * 为当前用户附加权限
52
+ */
53
+ attachAbility(abilities: Array<number | string>): void;
54
+ /**
55
+ * 为当前用户移除角色
56
+ */
57
+ removeRole(roles: string[]): void;
58
+ /**
59
+ * 为当前用户移除权限
60
+ */
61
+ removeAbility(abilities: Array<number | string>): void;
62
+ /**
63
+ * 当前用户是否有对应角色,其实 `number` 表示Ability
64
+ *
65
+ * - 当 `full: true` 或参数 `null` 时返回 `true`
66
+ * - 若使用 `ACLType` 参数,可以指定 `mode` 校验模式
67
+ */
68
+ can(roleOrAbility: ACLCanType | null): boolean;
69
+ /** @inner */
70
+ parseAbility(value: ACLCanType): ACLCanType;
71
+ /**
72
+ * 当前用户是否有对应权限点
73
+ */
74
+ canAbility(value: ACLCanType): boolean;
75
+ }
package/src/acl.type.d.ts CHANGED
@@ -1,33 +1,33 @@
1
- /**
2
- * NOTE:`ACLType` 类型可能会被其他类库所引用,为了减少类库间彼此的依赖性,其他类库会以复制的形式存在
3
- * 当这里有变化时,请务必同步更新,涉及:`MenuService.acl`、`util.YunzaiACLType`
4
- * TODO: 尝试增加 `@yelon/core` 类库用于处理这种通用型
5
- */
6
- import { Injector } from '@angular/core';
7
- import { Observable } from 'rxjs';
8
- import type { NzSafeAny } from 'ng-zorro-antd/core/types';
9
- import { ACLService } from './acl.service';
10
- export interface ACLType {
11
- /**
12
- * 角色
13
- */
14
- role?: string[];
15
- /**
16
- * 权限点
17
- */
18
- ability?: number[] | string[];
19
- /**
20
- * Validated against, default: `oneOf`
21
- * - `allOf` the value validates against all the roles or abilities
22
- * - `oneOf` the value validates against exactly one of the roles or abilities
23
- */
24
- mode?: 'allOf' | 'oneOf';
25
- /**
26
- * 是否取反,即结果为 `true` 时表示未授权
27
- */
28
- except?: boolean;
29
- [key: string]: NzSafeAny;
30
- }
31
- export declare type ACLCanType = number | number[] | string | string[] | ACLType;
32
- export declare type ACLGuardFunctionType = (srv: ACLService, injector: Injector) => Observable<ACLCanType>;
33
- export declare type ACLGuardType = ACLCanType | Observable<ACLCanType> | ACLGuardFunctionType;
1
+ /**
2
+ * NOTE:`ACLType` 类型可能会被其他类库所引用,为了减少类库间彼此的依赖性,其他类库会以复制的形式存在
3
+ * 当这里有变化时,请务必同步更新,涉及:`MenuService.acl`、`util.YunzaiACLType`
4
+ * TODO: 尝试增加 `@yelon/core` 类库用于处理这种通用型
5
+ */
6
+ import { Injector } from '@angular/core';
7
+ import { Observable } from 'rxjs';
8
+ import type { NzSafeAny } from 'ng-zorro-antd/core/types';
9
+ import { ACLService } from './acl.service';
10
+ export interface ACLType {
11
+ /**
12
+ * 角色
13
+ */
14
+ role?: string[];
15
+ /**
16
+ * 权限点
17
+ */
18
+ ability?: number[] | string[];
19
+ /**
20
+ * Validated against, default: `oneOf`
21
+ * - `allOf` the value validates against all the roles or abilities
22
+ * - `oneOf` the value validates against exactly one of the roles or abilities
23
+ */
24
+ mode?: 'allOf' | 'oneOf';
25
+ /**
26
+ * 是否取反,即结果为 `true` 时表示未授权
27
+ */
28
+ except?: boolean;
29
+ [key: string]: NzSafeAny;
30
+ }
31
+ export declare type ACLCanType = number | number[] | string | string[] | ACLType;
32
+ export declare type ACLGuardFunctionType = (srv: ACLService, injector: Injector) => Observable<ACLCanType>;
33
+ export declare type ACLGuardType = ACLCanType | Observable<ACLCanType> | ACLGuardFunctionType;