@yelon/acl 17.3.2 → 18.0.0

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,46 +1,46 @@
1
- {
2
- "name": "@yelon/acl",
3
- "version": "17.3.2",
4
- "author": "yunzai-bot<yunzai-bot@outlook.com>",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/hbyunzai/yelon.git"
9
- },
10
- "bugs": {
11
- "url": "https://github.com/hbyunzai/ng-yunzai/issues"
12
- },
13
- "homepage": "https://ng.yunzainfo.com",
14
- "keywords": [
15
- "@yelon/acl",
16
- "angular acl",
17
- "ng acl",
18
- "ngx acl",
19
- "yelon",
20
- "ng-yunzai",
21
- "yunzai",
22
- "antd",
23
- "ng-zorro-antd",
24
- "acl",
25
- "angular",
26
- "component"
27
- ],
28
- "dependencies": {
29
- "@yelon/util": "^17.3.2",
30
- "tslib": "^2.3.0"
31
- },
32
- "module": "fesm2022/acl.mjs",
33
- "typings": "index.d.ts",
34
- "exports": {
35
- "./package.json": {
36
- "default": "./package.json"
37
- },
38
- ".": {
39
- "types": "./index.d.ts",
40
- "esm2022": "./esm2022/acl.mjs",
41
- "esm": "./esm2022/acl.mjs",
42
- "default": "./fesm2022/acl.mjs"
43
- }
44
- },
45
- "sideEffects": false
1
+ {
2
+ "name": "@yelon/acl",
3
+ "version": "18.0.0",
4
+ "author": "yunzai-bot<yunzai-bot@outlook.com>",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/hbyunzai/yelon.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/hbyunzai/ng-yunzai/issues"
12
+ },
13
+ "homepage": "https://ng.yunzainfo.com",
14
+ "keywords": [
15
+ "@yelon/acl",
16
+ "angular acl",
17
+ "ng acl",
18
+ "ngx acl",
19
+ "yelon",
20
+ "ng-yunzai",
21
+ "yunzai",
22
+ "antd",
23
+ "ng-zorro-antd",
24
+ "acl",
25
+ "angular",
26
+ "component"
27
+ ],
28
+ "dependencies": {
29
+ "@yelon/util": "^18.0.0",
30
+ "tslib": "^2.3.0"
31
+ },
32
+ "module": "fesm2022/acl.mjs",
33
+ "typings": "index.d.ts",
34
+ "exports": {
35
+ "./package.json": {
36
+ "default": "./package.json"
37
+ },
38
+ ".": {
39
+ "types": "./index.d.ts",
40
+ "esm2022": "./esm2022/acl.mjs",
41
+ "esm": "./esm2022/acl.mjs",
42
+ "default": "./fesm2022/acl.mjs"
43
+ }
44
+ },
45
+ "sideEffects": false
46
46
  }
@@ -1,48 +1,48 @@
1
- import { CanActivateChildFn, CanActivateFn, CanMatchFn } from '@angular/router';
2
- import { Observable } from 'rxjs';
3
- import type { ACLGuardData } from './acl.type';
4
- import * as i0 from "@angular/core";
5
- export declare class ACLGuardService {
6
- private readonly srv;
7
- private readonly router;
8
- private readonly injector;
9
- process(data?: ACLGuardData): Observable<boolean>;
10
- static ɵfac: i0.ɵɵFactoryDeclaration<ACLGuardService, never>;
11
- static ɵprov: i0.ɵɵInjectableDeclaration<ACLGuardService>;
12
- }
13
- /**
14
- * Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
15
- *
16
- * ```ts
17
- * data: {
18
- * path: 'home',
19
- * canActivate: [ aclCanActivate ],
20
- * data: { guard: 'user1' }
21
- * }
22
- * ```
23
- */
24
- export declare const aclCanActivate: CanActivateFn;
25
- /**
26
- * Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
27
- *
28
- * ```ts
29
- * data: {
30
- * path: 'home',
31
- * canActivateChild: [ aclCanActivateChild ],
32
- * data: { guard: 'user1' }
33
- * }
34
- * ```
35
- */
36
- export declare const aclCanActivateChild: CanActivateChildFn;
37
- /**
38
- * Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
39
- *
40
- * ```ts
41
- * data: {
42
- * path: 'home',
43
- * canMatch: [ aclCanMatch ],
44
- * data: { guard: 'user1' }
45
- * }
46
- * ```
47
- */
48
- export declare const aclCanMatch: CanMatchFn;
1
+ import { CanActivateChildFn, CanActivateFn, CanMatchFn } from '@angular/router';
2
+ import { Observable } from 'rxjs';
3
+ import type { ACLGuardData } from './acl.type';
4
+ import * as i0 from "@angular/core";
5
+ export declare class ACLGuardService {
6
+ private readonly srv;
7
+ private readonly router;
8
+ private readonly injector;
9
+ process(data?: ACLGuardData): Observable<boolean>;
10
+ static ɵfac: i0.ɵɵFactoryDeclaration<ACLGuardService, never>;
11
+ static ɵprov: i0.ɵɵInjectableDeclaration<ACLGuardService>;
12
+ }
13
+ /**
14
+ * Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
15
+ *
16
+ * ```ts
17
+ * data: {
18
+ * path: 'home',
19
+ * canActivate: [ aclCanActivate ],
20
+ * data: { guard: 'user1' }
21
+ * }
22
+ * ```
23
+ */
24
+ export declare const aclCanActivate: CanActivateFn;
25
+ /**
26
+ * Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
27
+ *
28
+ * ```ts
29
+ * data: {
30
+ * path: 'home',
31
+ * canActivateChild: [ aclCanActivateChild ],
32
+ * data: { guard: 'user1' }
33
+ * }
34
+ * ```
35
+ */
36
+ export declare const aclCanActivateChild: CanActivateChildFn;
37
+ /**
38
+ * Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
39
+ *
40
+ * ```ts
41
+ * data: {
42
+ * path: 'home',
43
+ * canMatch: [ aclCanMatch ],
44
+ * data: { guard: 'user1' }
45
+ * }
46
+ * ```
47
+ */
48
+ export declare const aclCanMatch: CanMatchFn;
@@ -1,25 +1,25 @@
1
- import { OnDestroy, TemplateRef } from '@angular/core';
2
- import { ACLCanType } from './acl.type';
3
- import * as i0 from "@angular/core";
4
- export declare class ACLIfDirective implements OnDestroy {
5
- private readonly srv;
6
- private readonly _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();
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
- static ɵfac: i0.ɵɵFactoryDeclaration<ACLIfDirective, never>;
24
- static ɵdir: i0.ɵɵDirectiveDeclaration<ACLIfDirective, "[aclIf]", ["aclIf"], { "aclIf": { "alias": "aclIf"; "required": false; }; "aclIfThen": { "alias": "aclIfThen"; "required": false; }; "aclIfElse": { "alias": "aclIfElse"; "required": false; }; "except": { "alias": "except"; "required": false; }; }, {}, never, never, true, never>;
25
- }
1
+ import { OnDestroy, TemplateRef } from '@angular/core';
2
+ import { ACLCanType } from './acl.type';
3
+ import * as i0 from "@angular/core";
4
+ export declare class ACLIfDirective implements OnDestroy {
5
+ private readonly srv;
6
+ private readonly _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();
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
+ static ɵfac: i0.ɵɵFactoryDeclaration<ACLIfDirective, never>;
24
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ACLIfDirective, "[aclIf]", ["aclIf"], { "aclIf": { "alias": "aclIf"; "required": false; }; "aclIfThen": { "alias": "aclIfThen"; "required": false; }; "aclIfElse": { "alias": "aclIfElse"; "required": false; }; "except": { "alias": "except"; "required": false; }; }, {}, never, never, true, never>;
25
+ }
@@ -1,2 +1,2 @@
1
- import type { YunzaiACLConfig } from '@yelon/util/config';
2
- export declare const ACL_DEFAULT_CONFIG: YunzaiACLConfig;
1
+ import type { YunzaiACLConfig } from '@yelon/util/config';
2
+ export declare const ACL_DEFAULT_CONFIG: YunzaiACLConfig;
@@ -1,17 +1,17 @@
1
- import { OnDestroy } from '@angular/core';
2
- import { ACLCanType } from './acl.type';
3
- import * as i0 from "@angular/core";
4
- export declare class ACLDirective implements OnDestroy {
5
- private readonly el;
6
- private readonly renderer;
7
- private readonly srv;
8
- private _value;
9
- private change$;
10
- set acl(value: ACLCanType);
11
- set ability(value: ACLCanType);
12
- private set;
13
- constructor();
14
- ngOnDestroy(): void;
15
- static ɵfac: i0.ɵɵFactoryDeclaration<ACLDirective, never>;
16
- static ɵdir: i0.ɵɵDirectiveDeclaration<ACLDirective, "[acl]", ["acl"], { "acl": { "alias": "acl"; "required": false; }; "ability": { "alias": "acl-ability"; "required": false; }; }, {}, never, never, true, never>;
17
- }
1
+ import { OnDestroy } from '@angular/core';
2
+ import { ACLCanType } from './acl.type';
3
+ import * as i0 from "@angular/core";
4
+ export declare class ACLDirective implements OnDestroy {
5
+ private readonly el;
6
+ private readonly renderer;
7
+ private readonly srv;
8
+ private _value;
9
+ private change$;
10
+ set acl(value: ACLCanType);
11
+ set ability(value: ACLCanType);
12
+ private set;
13
+ constructor();
14
+ ngOnDestroy(): void;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<ACLDirective, never>;
16
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ACLDirective, "[acl]", ["acl"], { "acl": { "alias": "acl"; "required": false; }; "ability": { "alias": "acl-ability"; "required": false; }; }, {}, never, never, true, never>;
17
+ }
@@ -1,9 +1,9 @@
1
- import * as i0 from "@angular/core";
2
- import * as i1 from "@angular/common";
3
- import * as i2 from "./acl.directive";
4
- import * as i3 from "./acl-if.directive";
5
- export declare class YelonACLModule {
6
- static ɵfac: i0.ɵɵFactoryDeclaration<YelonACLModule, never>;
7
- static ɵmod: i0.ɵɵNgModuleDeclaration<YelonACLModule, never, [typeof i1.CommonModule, typeof i2.ACLDirective, typeof i3.ACLIfDirective], [typeof i2.ACLDirective, typeof i3.ACLIfDirective]>;
8
- static ɵinj: i0.ɵɵInjectorDeclaration<YelonACLModule>;
9
- }
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "@angular/common";
3
+ import * as i2 from "./acl.directive";
4
+ import * as i3 from "./acl-if.directive";
5
+ export declare class YelonACLModule {
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<YelonACLModule, never>;
7
+ static ɵmod: i0.ɵɵNgModuleDeclaration<YelonACLModule, never, [typeof i1.CommonModule, typeof i2.ACLDirective, typeof i3.ACLIfDirective], [typeof i2.ACLDirective, typeof i3.ACLIfDirective]>;
8
+ static ɵinj: i0.ɵɵInjectorDeclaration<YelonACLModule>;
9
+ }
@@ -1,76 +1,76 @@
1
- import { Observable } from 'rxjs';
2
- import { YunzaiConfigService } from '@yelon/util/config';
3
- import { ACLCanType, ACLType } from './acl.type';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * ACL 控制服务,[在线文档](https://ng.yunzainfo.com/acl)
7
- */
8
- export declare class ACLService {
9
- private options;
10
- private roles;
11
- private abilities;
12
- private full;
13
- private aclChange;
14
- /** ACL变更通知 */
15
- get change(): Observable<ACLType | boolean | null>;
16
- /** 获取所有数据 */
17
- get data(): {
18
- full: boolean;
19
- roles: string[];
20
- abilities: Array<string | number>;
21
- };
22
- get guard_url(): string;
23
- constructor(configSrv: YunzaiConfigService);
24
- private parseACLType;
25
- /**
26
- * 设置当前用户角色或权限能力(会先清除所有)
27
- */
28
- set(value: ACLType): void;
29
- /**
30
- * 标识当前用户为全量,即不受限
31
- */
32
- setFull(val: boolean): void;
33
- /**
34
- * 设置当前用户权限能力(会先清除所有)
35
- */
36
- setAbility(abilities: Array<number | string>): void;
37
- /**
38
- * 设置当前用户角色(会先清除所有)
39
- */
40
- setRole(roles: string[]): void;
41
- /**
42
- * 为当前用户增加角色或权限能力
43
- */
44
- add(value: ACLType): void;
45
- /**
46
- * 为当前用户附加角色
47
- */
48
- attachRole(roles: string[]): void;
49
- /**
50
- * 为当前用户附加权限
51
- */
52
- attachAbility(abilities: Array<number | string>): void;
53
- /**
54
- * 为当前用户移除角色
55
- */
56
- removeRole(roles: string[]): void;
57
- /**
58
- * 为当前用户移除权限
59
- */
60
- removeAbility(abilities: Array<number | string>): void;
61
- /**
62
- * 当前用户是否有对应角色,其实 `number` 表示Ability
63
- *
64
- * - 当 `full: true` 或参数 `null` 时返回 `true`
65
- * - 若使用 `ACLType` 参数,可以指定 `mode` 校验模式
66
- */
67
- can(roleOrAbility: ACLCanType | null): boolean;
68
- /** @inner */
69
- parseAbility(value: ACLCanType): ACLCanType;
70
- /**
71
- * 当前用户是否有对应权限点
72
- */
73
- canAbility(value: ACLCanType): boolean;
74
- static ɵfac: i0.ɵɵFactoryDeclaration<ACLService, never>;
75
- static ɵprov: i0.ɵɵInjectableDeclaration<ACLService>;
76
- }
1
+ import { Observable } from 'rxjs';
2
+ import { YunzaiConfigService } from '@yelon/util/config';
3
+ import { ACLCanType, ACLType } from './acl.type';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * ACL 控制服务,[在线文档](https://ng.yunzainfo.com/acl)
7
+ */
8
+ export declare class ACLService {
9
+ private options;
10
+ private roles;
11
+ private abilities;
12
+ private full;
13
+ private aclChange;
14
+ /** ACL变更通知 */
15
+ get change(): Observable<ACLType | boolean | null>;
16
+ /** 获取所有数据 */
17
+ get data(): {
18
+ full: boolean;
19
+ roles: string[];
20
+ abilities: Array<string | number>;
21
+ };
22
+ get guard_url(): string;
23
+ constructor(configSrv: YunzaiConfigService);
24
+ private parseACLType;
25
+ /**
26
+ * 设置当前用户角色或权限能力(会先清除所有)
27
+ */
28
+ set(value: ACLType): void;
29
+ /**
30
+ * 标识当前用户为全量,即不受限
31
+ */
32
+ setFull(val: boolean): void;
33
+ /**
34
+ * 设置当前用户权限能力(会先清除所有)
35
+ */
36
+ setAbility(abilities: Array<number | string>): void;
37
+ /**
38
+ * 设置当前用户角色(会先清除所有)
39
+ */
40
+ setRole(roles: string[]): void;
41
+ /**
42
+ * 为当前用户增加角色或权限能力
43
+ */
44
+ add(value: ACLType): void;
45
+ /**
46
+ * 为当前用户附加角色
47
+ */
48
+ attachRole(roles: string[]): void;
49
+ /**
50
+ * 为当前用户附加权限
51
+ */
52
+ attachAbility(abilities: Array<number | string>): void;
53
+ /**
54
+ * 为当前用户移除角色
55
+ */
56
+ removeRole(roles: string[]): void;
57
+ /**
58
+ * 为当前用户移除权限
59
+ */
60
+ removeAbility(abilities: Array<number | string>): void;
61
+ /**
62
+ * 当前用户是否有对应角色,其实 `number` 表示Ability
63
+ *
64
+ * - 当 `full: true` 或参数 `null` 时返回 `true`
65
+ * - 若使用 `ACLType` 参数,可以指定 `mode` 校验模式
66
+ */
67
+ can(roleOrAbility: ACLCanType | null): boolean;
68
+ /** @inner */
69
+ parseAbility(value: ACLCanType): ACLCanType;
70
+ /**
71
+ * 当前用户是否有对应权限点
72
+ */
73
+ canAbility(value: ACLCanType): boolean;
74
+ static ɵfac: i0.ɵɵFactoryDeclaration<ACLService, never>;
75
+ static ɵprov: i0.ɵɵInjectableDeclaration<ACLService>;
76
+ }
package/src/acl.type.d.ts CHANGED
@@ -1,36 +1,36 @@
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 { ACLService } from './acl.service';
9
- export interface ACLType {
10
- /**
11
- * 角色
12
- */
13
- role?: string[];
14
- /**
15
- * 权限点
16
- */
17
- ability?: number[] | string[];
18
- /**
19
- * Validated against, default: `oneOf`
20
- * - `allOf` the value validates against all the roles or abilities
21
- * - `oneOf` the value validates against exactly one of the roles or abilities
22
- */
23
- mode?: 'allOf' | 'oneOf';
24
- /**
25
- * 是否取反,即结果为 `true` 时表示未授权
26
- */
27
- except?: boolean;
28
- [key: string]: any;
29
- }
30
- export type ACLCanType = number | number[] | string | string[] | ACLType;
31
- export type ACLGuardFunctionType = (srv: ACLService, injector: Injector) => Observable<ACLCanType>;
32
- export type ACLGuardType = ACLCanType | Observable<ACLCanType> | ACLGuardFunctionType;
33
- export interface ACLGuardData {
34
- guard?: ACLGuardType | null;
35
- guard_url?: string | null;
36
- }
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 { ACLService } from './acl.service';
9
+ export interface ACLType {
10
+ /**
11
+ * 角色
12
+ */
13
+ role?: string[];
14
+ /**
15
+ * 权限点
16
+ */
17
+ ability?: number[] | string[];
18
+ /**
19
+ * Validated against, default: `oneOf`
20
+ * - `allOf` the value validates against all the roles or abilities
21
+ * - `oneOf` the value validates against exactly one of the roles or abilities
22
+ */
23
+ mode?: 'allOf' | 'oneOf';
24
+ /**
25
+ * 是否取反,即结果为 `true` 时表示未授权
26
+ */
27
+ except?: boolean;
28
+ [key: string]: any;
29
+ }
30
+ export type ACLCanType = number | number[] | string | string[] | ACLType;
31
+ export type ACLGuardFunctionType = (srv: ACLService, injector: Injector) => Observable<ACLCanType>;
32
+ export type ACLGuardType = ACLCanType | Observable<ACLCanType> | ACLGuardFunctionType;
33
+ export interface ACLGuardData {
34
+ guard?: ACLGuardType | null;
35
+ guard_url?: string | null;
36
+ }
@@ -1,7 +1,7 @@
1
- /**
2
- * [ACL](https://ng.yunzainfo.com/acl/control) 使用 `display: none` 隐藏未授权元素
3
- * [ACL](https://ng.yunzainfo.com/acl/control) Hides the unauthorized element with `display: none`
4
- */
5
- .acl__hide {
6
- display: none !important;
7
- }
1
+ /**
2
+ * [ACL](https://ng.yunzainfo.com/acl/control) 使用 `display: none` 隐藏未授权元素
3
+ * [ACL](https://ng.yunzainfo.com/acl/control) Hides the unauthorized element with `display: none`
4
+ */
5
+ .acl__hide {
6
+ display: none !important;
7
+ }