@casl/angular 6.0.0 → 7.1.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/README.md +36 -5
- package/dist/es5m/index.js +20 -2
- package/dist/es5m/index.js.map +1 -1
- package/dist/es6m/index.mjs +19 -2
- package/dist/es6m/index.mjs.map +1 -1
- package/dist/types/AbilityService.d.ts +9 -0
- package/dist/types/pipes.d.ts +1 -2
- package/dist/types/public.d.ts +1 -0
- package/dist/umd/index.js +19 -0
- package/dist/umd/index.js.map +1 -1
- package/package.json +20 -15
- package/CHANGELOG.md +0 -438
package/README.md
CHANGED
|
@@ -121,7 +121,40 @@ export class LoginForm {
|
|
|
121
121
|
}
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
## Check permissions in templates
|
|
124
|
+
## Check permissions in templates using AbilityService
|
|
125
|
+
|
|
126
|
+
`AbilityService` is a service that provides `ability$` observable. This observable injects provided in DI `PureAbility` instance and emits it each time its rules are changed. This allows efficiently use permissions checks, especially in case we use `ChangeDetectionStrategy.OnPush`.
|
|
127
|
+
|
|
128
|
+
Let's first see how it can be used in any component:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
@Component({
|
|
132
|
+
selector: 'my-home',
|
|
133
|
+
template: `
|
|
134
|
+
<ng-container *ngIf="ability$ | async as ability">
|
|
135
|
+
<h1>Home Page</h1>
|
|
136
|
+
<button *ngIf="ability.can('create', 'Post')">Create Post</button>
|
|
137
|
+
</ng-container>
|
|
138
|
+
`
|
|
139
|
+
})
|
|
140
|
+
export class HomeComponent {
|
|
141
|
+
readonly ability$: Observable<AppAbility>;
|
|
142
|
+
|
|
143
|
+
constructor(abilityService: AbilityService<AppAbility>) {
|
|
144
|
+
this.ability$ = abilityService.ability$;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
It also can be safely used inside `*ngFor` and other directives. If we use `ChangeDetectionStrategy.OnPush`, it will give us additional performance improvements because `ability.can(...)` won't be called without a need.
|
|
150
|
+
|
|
151
|
+
This approach works good from performance point of view because it creates only single subscription per component (not per check as in case of `ablePure` pipe) and doesn't require our component to use `Default` or `OnPush` strategy.
|
|
152
|
+
|
|
153
|
+
**Note**: provide this service at root injector level as we need only 1 instance of it.
|
|
154
|
+
|
|
155
|
+
But let's also see how we can do permission checks using pipes and what are performance implications of that:
|
|
156
|
+
|
|
157
|
+
## Check permissions in templates using pipe
|
|
125
158
|
|
|
126
159
|
To check permissions in any template you can use `AblePipe`:
|
|
127
160
|
|
|
@@ -131,9 +164,7 @@ To check permissions in any template you can use `AblePipe`:
|
|
|
131
164
|
</div>
|
|
132
165
|
```
|
|
133
166
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
## Why pipe and not directive?
|
|
167
|
+
### Why pipe and not directive?
|
|
137
168
|
|
|
138
169
|
Directive cannot be used to pass values into inputs of other components. For example, we need to enable or disable a button based on user's ability to create a post. With directive we cannot do this but we can do this with pipe:
|
|
139
170
|
|
|
@@ -141,7 +172,7 @@ Directive cannot be used to pass values into inputs of other components. For exa
|
|
|
141
172
|
<button [disabled]="!('create' | able: 'Post')">Add Post</button>
|
|
142
173
|
```
|
|
143
174
|
|
|
144
|
-
|
|
175
|
+
### Performance considerations
|
|
145
176
|
|
|
146
177
|
There are 2 pipes in `@casl/angular`:
|
|
147
178
|
|
package/dist/es5m/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Pipe, Inject, NgModule } from '@angular/core';
|
|
2
|
+
import { Pipe, Inject, NgModule, Injectable } from '@angular/core';
|
|
3
3
|
import { PureAbility } from '@casl/ability';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
|
|
@@ -83,5 +83,23 @@ var AbilityModule = /** @class */ (function () {
|
|
|
83
83
|
AblePurePipe], exports: [AblePipe,
|
|
84
84
|
AblePurePipe] }); })();
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
var AbilityService = /** @class */ (function () {
|
|
87
|
+
function AbilityService(ability) {
|
|
88
|
+
this.ability$ = new Observable(function (observer) {
|
|
89
|
+
observer.next(ability);
|
|
90
|
+
return ability.on('updated', function () { return observer.next(ability); });
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
AbilityService.ɵfac = function AbilityService_Factory(t) { return new (t || AbilityService)(i0.ɵɵinject(PureAbility)); };
|
|
94
|
+
AbilityService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AbilityService, factory: AbilityService.ɵfac });
|
|
95
|
+
return AbilityService;
|
|
96
|
+
}());
|
|
97
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AbilityService, [{
|
|
98
|
+
type: Injectable
|
|
99
|
+
}], function () { return [{ type: undefined, decorators: [{
|
|
100
|
+
type: Inject,
|
|
101
|
+
args: [PureAbility]
|
|
102
|
+
}] }]; }, null); })();
|
|
103
|
+
|
|
104
|
+
export { AbilityModule, AbilityService, AblePipe, AblePurePipe };
|
|
87
105
|
//# sourceMappingURL=index.js.map
|
package/dist/es5m/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/pipes.ts","../../src/AbilityModule.ts"],"sourcesContent":["import { Pipe, Inject, PipeTransform } from '@angular/core';\nimport { PureAbility,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/pipes.ts","../../src/AbilityModule.ts","../../src/AbilityService.ts"],"sourcesContent":["import { Pipe, Inject, PipeTransform } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Pipe({ name: 'able', pure: false })\nexport class AblePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n transform(...args: Parameters<T['can']>): boolean {\n return this._ability.can(...args);\n }\n}\n\n@Pipe({ name: 'ablePure' })\nexport class AblePurePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n // TODO: `Observable` can be removed after https://github.com/angular/angular/issues/15041\n transform(...args: Parameters<T['can']>): Observable<boolean> {\n return new Observable((s) => {\n const emit = () => s.next(this._ability.can(...args));\n emit();\n return this._ability.on('updated', emit);\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { AblePipe, AblePurePipe } from './pipes';\n\n@NgModule({\n declarations: [\n AblePipe,\n AblePurePipe,\n ],\n exports: [\n AblePipe,\n AblePurePipe,\n ],\n})\nexport class AbilityModule {\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Injectable()\nexport class AbilityService<T extends AnyAbility> {\n readonly ability$: Observable<T>;\n\n constructor(@Inject(PureAbility) ability: T) {\n this.ability$ = new Observable((observer) => {\n observer.next(ability);\n return ability.on('updated', () => observer.next(ability));\n });\n }\n}\n"],"names":[],"mappings":";;;;;;IAQE,kBAAiC,OAAU;QACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;KACzB;IAED,4BAAS,GAAT;;QAAU,cAA6B;aAA7B,UAA6B,EAA7B,qBAA6B,EAA7B,IAA6B;YAA7B,yBAA6B;;QACrC,OAAO,CAAA,KAAA,IAAI,CAAC,QAAQ,EAAC,GAAG,WAAI,IAAI,EAAE;KACnC;oEATU,QAAQ,uBAGC,WAAW;yEAHpB,QAAQ;mBALrB;CAIA,IAWC;uFAVY,QAAQ;cADpB,IAAI;eAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE;;sBAIpB,MAAM;uBAAC,WAAW;;;IAa/B,sBAAiC,OAAU;QACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;KACzB;;IAGD,gCAAS,GAAT;QAAA,iBAMC;QANS,cAA6B;aAA7B,UAA6B,EAA7B,qBAA6B,EAA7B,IAA6B;YAA7B,yBAA6B;;QACrC,OAAO,IAAI,UAAU,CAAC,UAAC,CAAC;YACtB,IAAM,IAAI,GAAG;;gBAAM,OAAA,CAAC,CAAC,IAAI,CAAC,CAAA,KAAA,KAAI,CAAC,QAAQ,EAAC,GAAG,WAAI,IAAI,EAAE;aAAA,CAAC;YACtD,IAAI,EAAE,CAAC;YACP,OAAO,KAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;SAC1C,CAAC,CAAC;KACJ;4EAdU,YAAY,uBAGH,WAAW;iFAHpB,YAAY;uBAlBzB;CAiBA,IAgBC;uFAfY,YAAY;cADxB,IAAI;eAAC,EAAE,IAAI,EAAE,UAAU,EAAE;;sBAIX,MAAM;uBAAC,WAAW;;;;IClBjC;KAWC;8EADY,aAAa;mEAAb,aAAa;;wBAb1B;CAGA,IAWC;uFADY,aAAa;cAVzB,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,QAAQ;oBACR,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,QAAQ;oBACR,YAAY;iBACb;aACF;;wFACY,aAAa,mBARtB,QAAQ;QACR,YAAY,aAGZ,QAAQ;QACR,YAAY;;;ICFd,wBAAiC,OAAU;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,UAAU,CAAC,UAAC,QAAQ;YACtC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,OAAO,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,cAAM,OAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAA,CAAC,CAAC;SAC5D,CAAC,CAAC;KACJ;gFARU,cAAc,cAGL,WAAW;wEAHpB,cAAc,WAAd,cAAc;yBAL3B;CAIA,IAUC;uFATY,cAAc;cAD1B,UAAU;;sBAII,MAAM;uBAAC,WAAW;;;;;"}
|
package/dist/es6m/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Pipe, Inject, NgModule } from '@angular/core';
|
|
2
|
+
import { Pipe, Inject, NgModule, Injectable } from '@angular/core';
|
|
3
3
|
import { PureAbility } from '@casl/ability';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
|
|
@@ -65,5 +65,22 @@ AbilityModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
|
65
65
|
AblePurePipe], exports: [AblePipe,
|
|
66
66
|
AblePurePipe] }); })();
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
class AbilityService {
|
|
69
|
+
constructor(ability) {
|
|
70
|
+
this.ability$ = new Observable((observer) => {
|
|
71
|
+
observer.next(ability);
|
|
72
|
+
return ability.on('updated', () => observer.next(ability));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
AbilityService.ɵfac = function AbilityService_Factory(t) { return new (t || AbilityService)(i0.ɵɵinject(PureAbility)); };
|
|
77
|
+
AbilityService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AbilityService, factory: AbilityService.ɵfac });
|
|
78
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AbilityService, [{
|
|
79
|
+
type: Injectable
|
|
80
|
+
}], function () { return [{ type: undefined, decorators: [{
|
|
81
|
+
type: Inject,
|
|
82
|
+
args: [PureAbility]
|
|
83
|
+
}] }]; }, null); })();
|
|
84
|
+
|
|
85
|
+
export { AbilityModule, AbilityService, AblePipe, AblePurePipe };
|
|
69
86
|
//# sourceMappingURL=index.mjs.map
|
package/dist/es6m/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/pipes.ts","../../src/AbilityModule.ts"],"sourcesContent":["import { Pipe, Inject, PipeTransform } from '@angular/core';\nimport { PureAbility,
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/pipes.ts","../../src/AbilityModule.ts","../../src/AbilityService.ts"],"sourcesContent":["import { Pipe, Inject, PipeTransform } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Pipe({ name: 'able', pure: false })\nexport class AblePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n transform(...args: Parameters<T['can']>): boolean {\n return this._ability.can(...args);\n }\n}\n\n@Pipe({ name: 'ablePure' })\nexport class AblePurePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n // TODO: `Observable` can be removed after https://github.com/angular/angular/issues/15041\n transform(...args: Parameters<T['can']>): Observable<boolean> {\n return new Observable((s) => {\n const emit = () => s.next(this._ability.can(...args));\n emit();\n return this._ability.on('updated', emit);\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { AblePipe, AblePurePipe } from './pipes';\n\n@NgModule({\n declarations: [\n AblePipe,\n AblePurePipe,\n ],\n exports: [\n AblePipe,\n AblePurePipe,\n ],\n})\nexport class AbilityModule {\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Injectable()\nexport class AbilityService<T extends AnyAbility> {\n readonly ability$: Observable<T>;\n\n constructor(@Inject(PureAbility) ability: T) {\n this.ability$ = new Observable((observer) => {\n observer.next(ability);\n return ability.on('updated', () => observer.next(ability));\n });\n }\n}\n"],"names":[],"mappings":";;;;;MAKa,QAAQ;IAGnB,YAAiC,OAAU;QACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;KACzB;IAED,SAAS,CAAC,GAAG,IAA0B;QACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;KACnC;;gEATU,QAAQ,uBAGC,WAAW;qEAHpB,QAAQ;uFAAR,QAAQ;cADpB,IAAI;eAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE;;sBAIpB,MAAM;uBAAC,WAAW;;MAUpB,YAAY;IAGvB,YAAiC,OAAU;QACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;KACzB;;IAGD,SAAS,CAAC,GAAG,IAA0B;QACrC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC;YACtB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YACtD,IAAI,EAAE,CAAC;YACP,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;SAC1C,CAAC,CAAC;KACJ;;wEAdU,YAAY,uBAGH,WAAW;6EAHpB,YAAY;uFAAZ,YAAY;cADxB,IAAI;eAAC,EAAE,IAAI,EAAE,UAAU,EAAE;;sBAIX,MAAM;uBAAC,WAAW;;;MCRpB,aAAa;;0EAAb,aAAa;+DAAb,aAAa;;uFAAb,aAAa;cAVzB,QAAQ;eAAC;gBACR,YAAY,EAAE;oBACZ,QAAQ;oBACR,YAAY;iBACb;gBACD,OAAO,EAAE;oBACP,QAAQ;oBACR,YAAY;iBACb;aACF;;wFACY,aAAa,mBARtB,QAAQ;QACR,YAAY,aAGZ,QAAQ;QACR,YAAY;;MCLH,cAAc;IAGzB,YAAiC,OAAU;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,UAAU,CAAC,CAAC,QAAQ;YACtC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,OAAO,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;SAC5D,CAAC,CAAC;KACJ;;4EARU,cAAc,cAGL,WAAW;oEAHpB,cAAc,WAAd,cAAc;uFAAd,cAAc;cAD1B,UAAU;;sBAII,MAAM;uBAAC,WAAW;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AnyAbility } from '@casl/ability';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class AbilityService<T extends AnyAbility> {
|
|
5
|
+
readonly ability$: Observable<T>;
|
|
6
|
+
constructor(ability: T);
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AbilityService<any>, never>;
|
|
8
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AbilityService<any>>;
|
|
9
|
+
}
|
package/dist/types/pipes.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { PipeTransform } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { AnyAbility } from '@casl/ability';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
export declare class AblePipe<T extends AnyAbility> implements PipeTransform {
|
|
6
|
-
protected _unsubscribeFromAbility?: Unsubscribe;
|
|
7
6
|
private _ability;
|
|
8
7
|
constructor(ability: T);
|
|
9
8
|
transform(...args: Parameters<T['can']>): boolean;
|
package/dist/types/public.d.ts
CHANGED
package/dist/umd/index.js
CHANGED
|
@@ -106,7 +106,26 @@
|
|
|
106
106
|
AblePurePipe], exports: [AblePipe,
|
|
107
107
|
AblePurePipe] }); })();
|
|
108
108
|
|
|
109
|
+
var AbilityService = /** @class */ (function () {
|
|
110
|
+
function AbilityService(ability) {
|
|
111
|
+
this.ability$ = new rxjs.Observable(function (observer) {
|
|
112
|
+
observer.next(ability);
|
|
113
|
+
return ability.on('updated', function () { return observer.next(ability); });
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
AbilityService.ɵfac = function AbilityService_Factory(t) { return new (t || AbilityService)(i0__namespace.ɵɵinject(ability.PureAbility)); };
|
|
117
|
+
AbilityService.ɵprov = /*@__PURE__*/ i0__namespace.ɵɵdefineInjectable({ token: AbilityService, factory: AbilityService.ɵfac });
|
|
118
|
+
return AbilityService;
|
|
119
|
+
}());
|
|
120
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(AbilityService, [{
|
|
121
|
+
type: i0.Injectable
|
|
122
|
+
}], function () { return [{ type: undefined, decorators: [{
|
|
123
|
+
type: i0.Inject,
|
|
124
|
+
args: [ability.PureAbility]
|
|
125
|
+
}] }]; }, null); })();
|
|
126
|
+
|
|
109
127
|
exports.AbilityModule = AbilityModule;
|
|
128
|
+
exports.AbilityService = AbilityService;
|
|
110
129
|
exports.AblePipe = AblePipe;
|
|
111
130
|
exports.AblePurePipe = AblePurePipe;
|
|
112
131
|
|
package/dist/umd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/pipes.ts","../../src/AbilityModule.ts"],"sourcesContent":["import { Pipe, Inject, PipeTransform } from '@angular/core';\nimport { PureAbility,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/pipes.ts","../../src/AbilityModule.ts","../../src/AbilityService.ts"],"sourcesContent":["import { Pipe, Inject, PipeTransform } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Pipe({ name: 'able', pure: false })\nexport class AblePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n transform(...args: Parameters<T['can']>): boolean {\n return this._ability.can(...args);\n }\n}\n\n@Pipe({ name: 'ablePure' })\nexport class AblePurePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n // TODO: `Observable` can be removed after https://github.com/angular/angular/issues/15041\n transform(...args: Parameters<T['can']>): Observable<boolean> {\n return new Observable((s) => {\n const emit = () => s.next(this._ability.can(...args));\n emit();\n return this._ability.on('updated', emit);\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { AblePipe, AblePurePipe } from './pipes';\n\n@NgModule({\n declarations: [\n AblePipe,\n AblePurePipe,\n ],\n exports: [\n AblePipe,\n AblePurePipe,\n ],\n})\nexport class AbilityModule {\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Injectable()\nexport class AbilityService<T extends AnyAbility> {\n readonly ability$: Observable<T>;\n\n constructor(@Inject(PureAbility) ability: T) {\n this.ability$ = new Observable((observer) => {\n observer.next(ability);\n return ability.on('updated', () => observer.next(ability));\n });\n }\n}\n"],"names":["PureAbility","Pipe","Inject","Observable","NgModule","Injectable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAQE,kBAAiC,OAAU;YACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;SACzB;QAED,4BAAS,GAAT;;YAAU,cAA6B;iBAA7B,UAA6B,EAA7B,qBAA6B,EAA7B,IAA6B;gBAA7B,yBAA6B;;YACrC,OAAO,CAAA,KAAA,IAAI,CAAC,QAAQ,EAAC,GAAG,WAAI,IAAI,EAAE;SACnC;wEATU,QAAQ,kCAGCA,mBAAW;wFAHpB,QAAQ;uBALrB;KAIA,IAWC;sGAVY,QAAQ;kBADpBC,OAAI;mBAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE;;0BAIpBC,SAAM;2BAACF,mBAAW;;;QAa/B,sBAAiC,OAAU;YACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;SACzB;;QAGD,gCAAS,GAAT;YAAA,iBAMC;YANS,cAA6B;iBAA7B,UAA6B,EAA7B,qBAA6B,EAA7B,IAA6B;gBAA7B,yBAA6B;;YACrC,OAAO,IAAIG,eAAU,CAAC,UAAC,CAAC;gBACtB,IAAM,IAAI,GAAG;;oBAAM,OAAA,CAAC,CAAC,IAAI,CAAC,CAAA,KAAA,KAAI,CAAC,QAAQ,EAAC,GAAG,WAAI,IAAI,EAAE;iBAAA,CAAC;gBACtD,IAAI,EAAE,CAAC;gBACP,OAAO,KAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;aAC1C,CAAC,CAAC;SACJ;gFAdU,YAAY,kCAGHH,mBAAW;gGAHpB,YAAY;2BAlBzB;KAiBA,IAgBC;sGAfY,YAAY;kBADxBC,OAAI;mBAAC,EAAE,IAAI,EAAE,UAAU,EAAE;;0BAIXC,SAAM;2BAACF,mBAAW;;;;QClBjC;SAWC;kFADY,aAAa;kFAAb,aAAa;;4BAb1B;KAGA,IAWC;sGADY,aAAa;kBAVzBI,WAAQ;mBAAC;oBACR,YAAY,EAAE;wBACZ,QAAQ;wBACR,YAAY;qBACb;oBACD,OAAO,EAAE;wBACP,QAAQ;wBACR,YAAY;qBACb;iBACF;;uGACY,aAAa,mBARtB,QAAQ;YACR,YAAY,aAGZ,QAAQ;YACR,YAAY;;;QCFd,wBAAiC,OAAU;YACzC,IAAI,CAAC,QAAQ,GAAG,IAAID,eAAU,CAAC,UAAC,QAAQ;gBACtC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACvB,OAAO,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,cAAM,OAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAA,CAAC,CAAC;aAC5D,CAAC,CAAC;SACJ;oFARU,cAAc,yBAGLH,mBAAW;uFAHpB,cAAc,WAAd,cAAc;6BAL3B;KAIA,IAUC;sGATY,cAAc;kBAD1BK,aAAU;;0BAIIH,SAAM;2BAACF,mBAAW;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casl/angular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "Angular module for CASL which makes it easy to add permissions in any Angular app",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"module": "dist/es5m/index.js",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/stalniy/casl.git"
|
|
17
|
+
"url": "https://github.com/stalniy/casl.git",
|
|
18
|
+
"directory": "packages/casl-angular"
|
|
18
19
|
},
|
|
19
20
|
"homepage": "https://casl.js.org",
|
|
20
21
|
"publishConfig": {
|
|
@@ -45,24 +46,28 @@
|
|
|
45
46
|
"author": "Sergii Stotskyi <sergiy.stotskiy@gmail.com>",
|
|
46
47
|
"license": "MIT",
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"@angular/core": "^
|
|
49
|
-
"@casl/ability": "^3.0.0 || ^4.0.0 || ^5.1.0",
|
|
50
|
-
"rxjs": "^
|
|
49
|
+
"@angular/core": "^13.0.0",
|
|
50
|
+
"@casl/ability": "^3.0.0 || ^4.0.0 || ^5.1.0 || ^6.0.0",
|
|
51
|
+
"rxjs": "^7.5.5",
|
|
51
52
|
"tslib": "^2.0.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@abraham/reflection": "^0.
|
|
55
|
-
"@angular/common": "^
|
|
56
|
-
"@angular/compiler": "^
|
|
57
|
-
"@angular/compiler-cli": "^
|
|
58
|
-
"@angular/core": "^
|
|
59
|
-
"@angular/platform-browser": "^
|
|
60
|
-
"@angular/platform-browser-dynamic": "^
|
|
61
|
-
"@
|
|
55
|
+
"@abraham/reflection": "^0.10.0",
|
|
56
|
+
"@angular/common": "^13.0.0",
|
|
57
|
+
"@angular/compiler": "^13.0.0",
|
|
58
|
+
"@angular/compiler-cli": "^13.0.0",
|
|
59
|
+
"@angular/core": "^13.0.0",
|
|
60
|
+
"@angular/platform-browser": "^13.0.0",
|
|
61
|
+
"@angular/platform-browser-dynamic": "^13.0.0",
|
|
62
|
+
"@angular-devkit/build-angular": "^13.0.0",
|
|
63
|
+
"jest": "^28.0.0",
|
|
64
|
+
"@casl/ability": "^6.0.0",
|
|
62
65
|
"@casl/dx": "workspace:^1.0.0",
|
|
63
|
-
"
|
|
66
|
+
"@types/jest": "^28.0.0",
|
|
67
|
+
"jest-preset-angular": "^12.0.0",
|
|
68
|
+
"rxjs": "^7.5.5",
|
|
64
69
|
"tslib": "^2.0.0",
|
|
65
|
-
"typescript": "~4.
|
|
70
|
+
"typescript": "~4.4.4",
|
|
66
71
|
"zone.js": "~0.11.4"
|
|
67
72
|
},
|
|
68
73
|
"files": [
|
package/CHANGELOG.md
DELETED
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
# [6.0.0](https://github.com/stalniy/casl/compare/@casl/angular@5.1.2...@casl/angular@6.0.0) (2021-05-31)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Code Refactoring
|
|
9
|
-
|
|
10
|
-
* **angular:** removes deprecated CanPipe and stick to Ivy compiler ([82b61f5](https://github.com/stalniy/casl/commit/82b61f5e46dc3c031aef42ae499eca25f2698fdb))
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### BREAKING CHANGES
|
|
14
|
-
|
|
15
|
-
* **angular:** there are few important changes:
|
|
16
|
-
|
|
17
|
-
* deprecated `CanPipe` was removed, use `AblePipe` instead
|
|
18
|
-
* library is compiled by Ivy and no longer support ViewEngine
|
|
19
|
-
|
|
20
|
-
## [5.1.2](https://github.com/stalniy/casl/compare/@casl/angular@5.1.1...@casl/angular@5.1.2) (2021-05-31)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### chore
|
|
24
|
-
|
|
25
|
-
* **deps:** updates angular to v12 ([#516](https://github.com/stalniy/casl/issues/516)) ([ff4212c](https://github.com/stalniy/casl/commit/ff4212c7f32f1fbc8a73e6b3a6615af65991e39a)), closes [#514](https://github.com/stalniy/casl/issues/514) [#512](https://github.com/stalniy/casl/issues/512)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### BREAKING CHANGES
|
|
29
|
-
|
|
30
|
-
* **deps:** there are 2 important changes:
|
|
31
|
-
|
|
32
|
-
* deprecated CanPipe was removed, use AblePipe instead
|
|
33
|
-
* library is compiled by Ivy and no longer support ViewEngine
|
|
34
|
-
|
|
35
|
-
## [5.1.1](https://github.com/stalniy/casl/compare/@casl/angular@5.1.0...@casl/angular@5.1.1) (2021-05-12)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### Bug Fixes
|
|
39
|
-
|
|
40
|
-
* adjusts package tags to improve discoverability ([73e88b0](https://github.com/stalniy/casl/commit/73e88b0a256625b193b2cd9dc4a219f2e1193cbc))
|
|
41
|
-
|
|
42
|
-
# [5.1.0](https://github.com/stalniy/casl/compare/@casl/angular@5.0.2...@casl/angular@5.1.0) (2021-01-14)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### Features
|
|
46
|
-
|
|
47
|
-
* **angular:** updates angular to v11 ([#421](https://github.com/stalniy/casl/issues/421)) ([ec16bf9](https://github.com/stalniy/casl/commit/ec16bf9e93536c4ec249d2520cf336c1497615a9))
|
|
48
|
-
|
|
49
|
-
## [5.0.2](https://github.com/stalniy/casl/compare/@casl/angular@5.0.1...@casl/angular@5.0.2) (2021-01-10)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
### Bug Fixes
|
|
53
|
-
|
|
54
|
-
* **angular:** changes ES6M distribution to use `.js` ext instead of `.mjs` ([06bd5be](https://github.com/stalniy/casl/commit/06bd5be0904b3194733c9f6fc3a3dd34cc069aba)), closes [#427](https://github.com/stalniy/casl/issues/427)
|
|
55
|
-
|
|
56
|
-
## [5.0.1](https://github.com/stalniy/casl/compare/@casl/angular@5.0.0...@casl/angular@5.0.1) (2020-12-28)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
### Bug Fixes
|
|
60
|
-
|
|
61
|
-
* **dist:** adds separate `tsconfig.build.json` to every completementary project ([87742ce](https://github.com/stalniy/casl/commit/87742cec518a8a68d5fc29be2bbc9561cbc7da6c)), closes [#419](https://github.com/stalniy/casl/issues/419)
|
|
62
|
-
|
|
63
|
-
# [5.0.0](https://github.com/stalniy/casl/compare/@casl/angular@4.1.6...@casl/angular@5.0.0) (2020-12-26)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
### Bug Fixes
|
|
67
|
-
|
|
68
|
-
* **package:** removes `engine` section that points to npm@6 ([eecd12a](https://github.com/stalniy/casl/commit/eecd12ac49f56d6a0f57d1a57fb37487335b5f03)), closes [#417](https://github.com/stalniy/casl/issues/417)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### Code Refactoring
|
|
72
|
-
|
|
73
|
-
* **angular:** removes support for Angular < 9.x and casl < 3.x ([3530cdf](https://github.com/stalniy/casl/commit/3530cdf5b73d19b9a6da9be675f292f67e44db32))
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
### Features
|
|
77
|
-
|
|
78
|
-
* **builder:** improves typings for AbilityBuilder [skip release] ([ebd4d17](https://github.com/stalniy/casl/commit/ebd4d17a355a2646467033118a3d6efee4321d27)), closes [#379](https://github.com/stalniy/casl/issues/379)
|
|
79
|
-
* **esm:** adds ESM support for latest Node.js through `exports` prop in package.json ([cac2506](https://github.com/stalniy/casl/commit/cac2506a80c18f194210c2d89108d1d094751fa4)), closes [#331](https://github.com/stalniy/casl/issues/331)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
### BREAKING CHANGES
|
|
83
|
-
|
|
84
|
-
* **angular:** removes support for Angular < 9.x and casl < 3.x
|
|
85
|
-
* **builder:** changes main generic parameter to be a class instead of instance and makes `defineAbility` to accept options as the 2nd argument.
|
|
86
|
-
|
|
87
|
-
**Before**
|
|
88
|
-
|
|
89
|
-
```ts
|
|
90
|
-
import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
|
|
91
|
-
|
|
92
|
-
const resolveAction = (action: string) => {/* custom implementation */ };
|
|
93
|
-
const ability = defineAbility({ resolveAction }, (can) => can('read', 'Item'));
|
|
94
|
-
const builder = new AbilityBuilder<Ability>(Ability);
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**After**
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
|
|
101
|
-
|
|
102
|
-
const resolveAction = (action: string) => {/* custom implementation */ };
|
|
103
|
-
const ability = defineAbility((can) => can('read', 'Item'), { resolveAction });
|
|
104
|
-
const builder = new AbilityBuilder(Ability); // first argument is now mandatory!
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
The 1st parameter to `AbilityBuilder` is now madatory. This allows to infer generic parameters from it and makes AbilityType that is built to be explicit.
|
|
108
|
-
|
|
109
|
-
## [4.1.6](https://github.com/stalniy/casl/compare/@casl/angular@4.1.5...@casl/angular@4.1.6) (2020-10-21)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
### Bug Fixes
|
|
113
|
-
|
|
114
|
-
* **README:** adds semi-colon ([cad1daa](https://github.com/stalniy/casl/commit/cad1daaabf8a7ad45d5736394d3ba3dc42207614))
|
|
115
|
-
|
|
116
|
-
## [4.1.5](https://github.com/stalniy/casl/compare/@casl/angular@4.1.4...@casl/angular@4.1.5) (2020-09-03)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
### Bug Fixes
|
|
120
|
-
|
|
121
|
-
* **angular:** fixes sourcemap generation for the code built by ngc ([7715263](https://github.com/stalniy/casl/commit/771526379ff8203170a433d71b68644a48ff44eb)), closes [#387](https://github.com/stalniy/casl/issues/387) [#382](https://github.com/stalniy/casl/issues/382)
|
|
122
|
-
|
|
123
|
-
## [4.1.4](https://github.com/stalniy/casl/compare/@casl/angular@4.1.3...@casl/angular@4.1.4) (2020-06-09)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
### Bug Fixes
|
|
127
|
-
|
|
128
|
-
* **docs:** ensure README and docs for all packages are in sync ([8df3684](https://github.com/stalniy/casl/commit/8df3684b139de0af60c9c37f284a5028ffbf2224)), closes [#338](https://github.com/stalniy/casl/issues/338)
|
|
129
|
-
|
|
130
|
-
## [4.1.3](https://github.com/stalniy/casl/compare/@casl/angular@4.1.2...@casl/angular@4.1.3) (2020-06-08)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
### Bug Fixes
|
|
134
|
-
|
|
135
|
-
* **package:** makes sure the latest casl works with Angular 8.x ([91ee505](https://github.com/stalniy/casl/commit/91ee505f25b77c7ddf13a066d9d0c22f6d8d2f99)), closes [#337](https://github.com/stalniy/casl/issues/337)
|
|
136
|
-
|
|
137
|
-
## [4.1.2](https://github.com/stalniy/casl/compare/@casl/angular@4.1.1...@casl/angular@4.1.2) (2020-06-02)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
### Bug Fixes
|
|
141
|
-
|
|
142
|
-
* **angular:** widen peer dependency for @angular/core ([aa2c3c4](https://github.com/stalniy/casl/commit/aa2c3c4e5a1e3cf14cebc83125571d3ab15c1451))
|
|
143
|
-
|
|
144
|
-
## [4.1.1](https://github.com/stalniy/casl/compare/@casl/angular@4.1.0...@casl/angular@4.1.1) (2020-05-19)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
### Bug Fixes
|
|
148
|
-
|
|
149
|
-
* **angular:** updates README for the latest release ([1103dec](https://github.com/stalniy/casl/commit/1103dec36b331a67944a5a9b9554daaeabc2b5bf)), closes [#276](https://github.com/stalniy/casl/issues/276)
|
|
150
|
-
|
|
151
|
-
# [4.1.0](https://github.com/stalniy/casl/compare/@casl/angular@4.0.4...@casl/angular@4.1.0) (2020-05-19)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
### Features
|
|
155
|
-
|
|
156
|
-
* **pipe:** adds pure `ablePure` pipe in `@casl/angular` ([23c851c](https://github.com/stalniy/casl/commit/23c851cb0fc4a9cb523a651308f8ad65e137b379)), closes [#276](https://github.com/stalniy/casl/issues/276)
|
|
157
|
-
|
|
158
|
-
## [4.0.4](https://github.com/stalniy/casl/compare/@casl/angular@4.0.3...@casl/angular@4.0.4) (2020-04-14)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
### Bug Fixes
|
|
162
|
-
|
|
163
|
-
* **angular:** removes ngcc `publishOnly` hook ([6e5c570](https://github.com/stalniy/casl/commit/6e5c570b92150e23e4e5c463ed4b497a4860db03))
|
|
164
|
-
|
|
165
|
-
## [4.0.3](https://github.com/stalniy/casl/compare/@casl/angular@4.0.2...@casl/angular@4.0.3) (2020-04-14)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
### Bug Fixes
|
|
169
|
-
|
|
170
|
-
* **package:** allows to disable minification through `LIB_MINIFY` env var ([de70838](https://github.com/stalniy/casl/commit/de70838a7a6e52ee4af52635f6dd91f3b767bdca))
|
|
171
|
-
|
|
172
|
-
## [4.0.2](https://github.com/stalniy/casl/compare/@casl/angular@4.0.1...@casl/angular@4.0.2) (2020-04-10)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
### Bug Fixes
|
|
176
|
-
|
|
177
|
-
* **angular:** ensure that terser doesn't mangle reserved required props ([5371166](https://github.com/stalniy/casl/commit/53711660cfd306bd713a9c59abc0b95d5d1d13c1))
|
|
178
|
-
|
|
179
|
-
## [4.0.1](https://github.com/stalniy/casl/compare/@casl/angular@4.0.0...@casl/angular@4.0.1) (2020-04-09)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
### Bug Fixes
|
|
183
|
-
|
|
184
|
-
* **angular:** adds support for casl/ability@4 in package.json ([9d65071](https://github.com/stalniy/casl/commit/9d65071fb2cd14bfef34e2cff8f7e79c9d595bdb))
|
|
185
|
-
|
|
186
|
-
# [4.0.0](https://github.com/stalniy/casl/compare/@casl/angular@3.0.6...@casl/angular@4.0.0) (2020-04-09)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
### Features
|
|
190
|
-
|
|
191
|
-
* **ability:** improves typing for `GetSubjectName` and adds default values for generics ([c089293](https://github.com/stalniy/casl/commit/c08929301a1b06880c054cbb2f21cda3725028a4)), closes [#256](https://github.com/stalniy/casl/issues/256)
|
|
192
|
-
* **angular:** adds generics to `CanPipe` ([68bd287](https://github.com/stalniy/casl/commit/68bd287e7af165b82bbf8076ea88e83b51754a31)), closes [#256](https://github.com/stalniy/casl/issues/256)
|
|
193
|
-
* **angular:** adds support for action only checks ([0462edb](https://github.com/stalniy/casl/commit/0462edb854ba4094e735287744404ea2d378defb)), closes [#107](https://github.com/stalniy/casl/issues/107)
|
|
194
|
-
* **angular:** allows to use custom `Ability` instances and improves tree shaking support ([2e7a149](https://github.com/stalniy/casl/commit/2e7a1498c27d0c542e9f6507ba9b5195ae3a1da8)), closes [#249](https://github.com/stalniy/casl/issues/249)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
### BREAKING CHANGES
|
|
198
|
-
|
|
199
|
-
* **angular:** the module doesn't provide `Ability` instance anymore thus it doesn't need `forRoot` static method anymore
|
|
200
|
-
|
|
201
|
-
Before
|
|
202
|
-
|
|
203
|
-
```js
|
|
204
|
-
import { NgModule } from '@angular/core';
|
|
205
|
-
import { AbilityModule } from '@casl/angular';
|
|
206
|
-
|
|
207
|
-
@NgModule({
|
|
208
|
-
imports: [
|
|
209
|
-
// other modules
|
|
210
|
-
AbilityModule.forRoot()
|
|
211
|
-
],
|
|
212
|
-
// other properties
|
|
213
|
-
})
|
|
214
|
-
export class AppModule {}
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
After
|
|
218
|
-
|
|
219
|
-
```js
|
|
220
|
-
import { NgModule } from '@angular/core';
|
|
221
|
-
import { AbilityModule } from '@casl/angular';
|
|
222
|
-
import { Ability, PureAbility } from '@casl/ability';
|
|
223
|
-
|
|
224
|
-
@NgModule({
|
|
225
|
-
imports: [
|
|
226
|
-
// other modules
|
|
227
|
-
AbilityModule
|
|
228
|
-
],
|
|
229
|
-
providers: [
|
|
230
|
-
{ provide: Ability, useValue: new Ability() },
|
|
231
|
-
{ provide: PureAbility, useExisting: Ability }
|
|
232
|
-
]
|
|
233
|
-
// other properties
|
|
234
|
-
})
|
|
235
|
-
export class AppModule {}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
See docs of `@casl/angular` for details
|
|
239
|
-
|
|
240
|
-
* **pipe:** `CanPipe` is deprecated in favor of `AblePipe`
|
|
241
|
-
|
|
242
|
-
Before
|
|
243
|
-
|
|
244
|
-
```html
|
|
245
|
-
<div *ngIf="'Post' | can: 'read'">hidden content</div>
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
After
|
|
249
|
-
|
|
250
|
-
```html
|
|
251
|
-
<div *ngIf="'read' | able: 'Post'">hidden content</div>
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
## [3.0.6](https://github.com/stalniy/casl/compare/@casl/angular@3.0.5...@casl/angular@3.0.6) (2020-03-06)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
### Bug Fixes
|
|
258
|
-
|
|
259
|
-
* **angular:** reverts back anngular to not use Ivy as it was not recommend by angular team ([b883118](https://github.com/stalniy/casl/commit/b8831184f4bbfc3924e95f1fd4f2861d88b43fdf)), closes [#270](https://github.com/stalniy/casl/issues/270)
|
|
260
|
-
|
|
261
|
-
## [3.0.5](https://github.com/stalniy/casl/compare/@casl/angular@3.0.4...@casl/angular@3.0.5) (2020-02-21)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
### Bug Fixes
|
|
265
|
-
|
|
266
|
-
* **angular:** moves postinstall hook to postbootstrap hook which links modules ([769e099](https://github.com/stalniy/casl/commit/769e099902eca821e17d4f6a3e5a44fd29191915)), closes [#266](https://github.com/stalniy/casl/issues/266)
|
|
267
|
-
|
|
268
|
-
## [3.0.4](https://github.com/stalniy/casl/compare/@casl/angular@3.0.3...@casl/angular@3.0.4) (2020-02-21)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
### Bug Fixes
|
|
272
|
-
|
|
273
|
-
* **angular:** adds postinstall script into npm package ([c753d44](https://github.com/stalniy/casl/commit/c753d446532a994766860631939f8000b69f06ae)), closes [#266](https://github.com/stalniy/casl/issues/266)
|
|
274
|
-
|
|
275
|
-
## [3.0.3](https://github.com/stalniy/casl/compare/@casl/angular@3.0.2...@casl/angular@3.0.3) (2020-02-21)
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
### Bug Fixes
|
|
279
|
-
|
|
280
|
-
* **angular:** reverts back prerelease hook ([1fc60c2](https://github.com/stalniy/casl/commit/1fc60c248d7e837fae39eb760cb308a73959b59d)), closes [#266](https://github.com/stalniy/casl/issues/266)
|
|
281
|
-
|
|
282
|
-
## [3.0.2](https://github.com/stalniy/casl/compare/@casl/angular@3.0.1...@casl/angular@3.0.2) (2020-02-20)
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
### Bug Fixes
|
|
286
|
-
|
|
287
|
-
* **angular:** adds missing file exists utility ([732e253](https://github.com/stalniy/casl/commit/732e253f65801631a3128fc92e2514bdb6f79987)), closes [#266](https://github.com/stalniy/casl/issues/266)
|
|
288
|
-
|
|
289
|
-
## [3.0.1](https://github.com/stalniy/casl/compare/@casl/angular@3.0.0...@casl/angular@3.0.1) (2020-02-20)
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
### Bug Fixes
|
|
293
|
-
|
|
294
|
-
* **angular:** ensures postinstall script uses node to check whether file exists ([eba8ef4](https://github.com/stalniy/casl/commit/eba8ef460dec655783204819fbb0e0721c34db13))
|
|
295
|
-
|
|
296
|
-
# [3.0.0](https://github.com/stalniy/casl/compare/@casl/angular@2.2.0...@casl/angular@3.0.0) (2020-02-17)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
### Bug Fixes
|
|
300
|
-
|
|
301
|
-
* **angular:** ensure postinstall hook is executed only during local dev ([a47bac8](https://github.com/stalniy/casl/commit/a47bac8f60c544b90be476ae73a17e0ddfdc479c))
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
### BREAKING CHANGES
|
|
305
|
-
|
|
306
|
-
* **angular:** upgrades angular to v9
|
|
307
|
-
|
|
308
|
-
# [2.2.0](https://github.com/stalniy/casl/compare/@casl/angular@2.1.1...@casl/angular@2.2.0) (2020-02-17)
|
|
309
|
-
|
|
310
|
-
**Deprecated because of invalid package.json peerDependencies and postinstall hook**
|
|
311
|
-
|
|
312
|
-
### Features
|
|
313
|
-
|
|
314
|
-
* **angular:** upgrades angular to v9 ([#260](https://github.com/stalniy/casl/issues/260)) ([3452636](https://github.com/stalniy/casl/commit/34526360ddd3c03605127223823c3beadc6fff84)), closes [#265](https://github.com/stalniy/casl/issues/265)
|
|
315
|
-
|
|
316
|
-
# [@casl/angular-v2.1.1](https://github.com/stalniy/casl/compare/@casl/angular@2.1.0...@casl/angular@2.1.1) (2019-12-09)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
### Performance Improvements
|
|
320
|
-
|
|
321
|
-
* **angular:** makes casl-angular much smaller by utilizing tslib.es6 ([093cefa](https://github.com/stalniy/casl/commit/093cefa2e26aa4b2cd9e733b0e77aaff1664dbcf))
|
|
322
|
-
|
|
323
|
-
# [@casl/angular-v2.1.0](https://github.com/stalniy/casl/compare/@casl/angular@2.0.0...@casl/angular@2.1.0) (2019-07-01)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
### Features
|
|
327
|
-
|
|
328
|
-
* **angular:** upgrades Angular and typescript ([08591f4](https://github.com/stalniy/casl/commit/08591f4)), closes [#158](https://github.com/stalniy/casl/issues/158) [#195](https://github.com/stalniy/casl/issues/195)
|
|
329
|
-
|
|
330
|
-
# [@casl/angular-v2.0.0](https://github.com/stalniy/casl/compare/@casl/angular@1.0.0...@casl/angular@2.0.0) (2019-02-10)
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
### Bug Fixes
|
|
334
|
-
|
|
335
|
-
* **packages:** increases peerDependency of [@casl](https://github.com/casl)/ability ([9f6a7b8](https://github.com/stalniy/casl/commit/9f6a7b8)), closes [#119](https://github.com/stalniy/casl/issues/119)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
### Features
|
|
339
|
-
|
|
340
|
-
* **ability:** adds support for `manage` action ([d9ab56c](https://github.com/stalniy/casl/commit/d9ab56c)), closes [#119](https://github.com/stalniy/casl/issues/119)
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
### BREAKING CHANGES
|
|
344
|
-
|
|
345
|
-
* **ability:** `manage` is not anymore an alias for CRUD but represents any action.
|
|
346
|
-
|
|
347
|
-
Let's consider the next example:
|
|
348
|
-
|
|
349
|
-
```js
|
|
350
|
-
const ability = AbilityBuilder.define((can) => {
|
|
351
|
-
can('manage', 'Post')
|
|
352
|
-
can('read', 'User')
|
|
353
|
-
})
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
In @casl/ability@2.x the definition above produces the next results:
|
|
357
|
-
|
|
358
|
-
```js
|
|
359
|
-
ability.can('read', 'Post') // true
|
|
360
|
-
ability.can('publish', 'Post') // false, because `manage` is an alias for CRUD
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
In @casl/ability@3.x the results:
|
|
364
|
-
|
|
365
|
-
```js
|
|
366
|
-
ability.can('read', 'Post') // true
|
|
367
|
-
ability.can('publish', 'Post') // true, because `manage` represents any action
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
To migrate the code, just replace `manage` with `crud` and everything will work as previously.
|
|
371
|
-
|
|
372
|
-
# [@casl/angular-v1.0.0](https://github.com/stalniy/casl/compare/@casl/angular@0.4.1...@casl/angular@1.0.0) (2018-12-02)
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
### Bug Fixes
|
|
376
|
-
|
|
377
|
-
* **angular:** adds possibility to use angular module in lazy loaded routes ([0c7c3c1](https://github.com/stalniy/casl/commit/0c7c3c1))
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
### BREAKING CHANGES
|
|
381
|
-
|
|
382
|
-
* **angular:** Fixes #131
|
|
383
|
-
|
|
384
|
-
# [@casl/angular-v0.4.1](https://github.com/stalniy/casl/compare/@casl/angular@0.4.0...@casl/angular@0.4.1) (2018-11-11)
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
### Bug Fixes
|
|
388
|
-
|
|
389
|
-
* **angular:** makes `field` to be optional argument ([a3eec63](https://github.com/stalniy/casl/commit/a3eec63)), closes [#126](https://github.com/stalniy/casl/issues/126)
|
|
390
|
-
|
|
391
|
-
# [@casl/angular-v0.4.0](https://github.com/stalniy/casl/compare/@casl/angular@0.3.1...@casl/angular@0.4.0) (2018-11-11)
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
### Bug Fixes
|
|
395
|
-
|
|
396
|
-
* **angular:** converts source to typescript ([565936d](https://github.com/stalniy/casl/commit/565936d)), closes [#126](https://github.com/stalniy/casl/issues/126)
|
|
397
|
-
* **README:** changes links to [@casl](https://github.com/casl)/ability to point to npm package instead to git root [skip ci] ([a74086b](https://github.com/stalniy/casl/commit/a74086b)), closes [#102](https://github.com/stalniy/casl/issues/102)
|
|
398
|
-
* **semantic-release:** test ([cab3f4b](https://github.com/stalniy/casl/commit/cab3f4b)), closes [#94](https://github.com/stalniy/casl/issues/94)
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
### Features
|
|
402
|
-
|
|
403
|
-
* **react:can:** updates typescript declarations ([213dcde](https://github.com/stalniy/casl/commit/213dcde))
|
|
404
|
-
|
|
405
|
-
<a name="@casl/angular-v0.3.1"></a>
|
|
406
|
-
# [@casl/angular-v0.3.1](https://github.com/stalniy/casl/compare/@casl/angular@0.3.0...@casl/angular@0.3.1) (2018-07-02)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
### Bug Fixes
|
|
410
|
-
|
|
411
|
-
* **package:** changes location of ES5M modules ([2b1ad4e](https://github.com/stalniy/casl/commit/2b1ad4e)), closes [#89](https://github.com/stalniy/casl/issues/89)
|
|
412
|
-
|
|
413
|
-
<a name="0.3.0"></a>
|
|
414
|
-
# 0.3.0 (2018-05-14)
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
### Features
|
|
418
|
-
|
|
419
|
-
* **angular:** supports per field abilities ([8268bb4](https://github.com/stalniy/casl/commit/8268bb4))
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
<a name="0.2.0"></a>
|
|
424
|
-
# 0.2.0 (2018-04-26)
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
### Features
|
|
428
|
-
|
|
429
|
-
* **angular:** adds typings ([98644ba](https://github.com/stalniy/casl/commit/98644ba)), closes [#38](https://github.com/stalniy/casl/issues/38)
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
<a name="0.1.0"></a>
|
|
433
|
-
# 0.1.0 (2018-03-23)
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
### Features
|
|
437
|
-
|
|
438
|
-
* **angular:** adds angular integration and tests, closes [#24](https://github.com/stalniy/casl/issues/24)
|