All notable changes to this project will be documented in this file.
2.2.2 (2024-02-14)
2.2.1 (2022-12-17)
2.2.0 (2022-08-28)
2.1.3 (2022-07-25)
2.1.2 (2021-10-07)
2.1.1 (2021-07-05)
2.1.0 (2021-05-12)
- adjusts package tags to improve discoverability (73e88b0)
2.0.2 (2021-01-25)
2.0.1 (2021-01-23)
2.0.0 (2021-01-22)
-
vue: refactor to use Vue 3 what introduces a bunch of breaking changes:
-
Ability
instance is not a required plugin parameter. Previously, we could decide whether to pass ability as plugin parameter or as root component option. Now, the only way is to pass it in plugin:Before
import { abilitiesPlugin } from '@casl/vue'; import Vue from 'vue'; import { ability } from './services/AppAbility'; Vue.use(abilitiesPlugin); new Vue({ ability }).$mount('#app')
After
import { abilitiesPlugin } from '@casl/vue'; import { createApp } from 'vue'; import { ability } from './services/AppAbility'; createApp() .use(abilitiesPlugin, ability) .mount('#app');
-
abilitiesPlugin
no more define global$ability
and$can
properties, instead a recommended way to getAppAbility
instance is by injecting it through provide/inject API. To get previous behavior, passuseGlobalProperties: true
option:Before
import { abilitiesPlugin } from '@casl/vue'; import Vue from 'vue'; import { ability } from './services/AppAbility'; Vue.use(abilitiesPlugin); const root = new Vue({ ability }).$mount('#app') console.log(root.$ability)
After
Recommended way:
import { abilitiesPlugin, ABILITY_TOKEN } from '@casl/vue'; import { createApp } from 'vue'; import { ability } from './services/AppAbility'; const App = { name: 'App', inject: { $ability: { from: ABILITY_TOKEN } } }; const root = createApp(App) .use(abilitiesPlugin, ability, { useGlobalProperties: true }) .mount('#app'); console.log(root.$ability)
Backward compatible way:
import { abilitiesPlugin } from '@casl/vue'; import { createApp } from 'vue'; import { ability } from './services/AppAbility'; const root = createApp() .use(abilitiesPlugin, ability, { useGlobalProperties: true }) .mount('#app'); console.log(root.$ability)
-
AllCanProps<TAbility>
type was renamed toCanProps<TAbility>
-
@casl/vue
no more augment vue types, so if you decide to use global properties, you will need to augment types by yourselfBefore
@casl/vue augments type of
$ability
toAnyAbility
and$can
totypeof $ability['can']
After
create a separate file
src/ability-shim.d.ts
with the next content:import { AppAbility } from './AppAbility' declare module 'vue' { interface ComponentCustomProperties { $ability: AppAbility; $can(this: this, ...args: Parameters<this['$ability']['can']>): boolean; } }
-
1.2.1 (2020-12-28)
1.2.0 (2020-12-26)
- angular: fixes sourcemap generation for the code built by ngc (7715263), closes #387 #382
- package: removes
engine
section that points to npm@6 (eecd12a), closes #417
- builder: improves typings for AbilityBuilder [skip release] (ebd4d17), closes #379
- esm: adds ESM support for latest Node.js through
exports
prop in package.json (cac2506), closes #331
-
builder: changes main generic parameter to be a class instead of instance and makes
defineAbility
to accept options as the 2nd argument.Before
import { AbilityBuilder, defineAbility, Ability } from '@casl/ability'; const resolveAction = (action: string) => {/* custom implementation */ }; const ability = defineAbility({ resolveAction }, (can) => can('read', 'Item')); const builder = new AbilityBuilder<Ability>(Ability);
After
import { AbilityBuilder, defineAbility, Ability } from '@casl/ability'; const resolveAction = (action: string) => {/* custom implementation */ }; const ability = defineAbility((can) => can('read', 'Item'), { resolveAction }); const builder = new AbilityBuilder(Ability); // first argument is now mandatory!
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.
1.1.1 (2020-06-09)
1.1.0 (2020-05-12)
1.0.3 (2020-04-22)
- types: use
AnyAbility
in ComponentOptions and in Vue augmentation modules (7f9be6f)
1.0.2 (2020-04-10)
- vue: ensure that terser doesn't mangle reserved required props (7fa234c)
1.0.1 (2020-04-09)
- vue: removes
of
alias from<can>
component (bd658e2)
1.0.0 (2020-04-09)
- ability: updates typings for vue (8ac4ca1), closes #256
- vue: adds better generics typying for Vue (5cc7b60), closes #107
- vue: migrates vue to typescript (7bacadd), closes #248
- vue: throws exception if
Ability
is not provided (aacd952), closes #248
-
typescript: weak hand written declaration files are removed as
@casl/vue
has been completely rewritten to TypeScript. TypeScript now checks that you correctly use property aliases -
Can:
of
alias is removed and field was extracted to a separate propBefore
<can I="read title" of="Post">...</can>
After
<can I="read" a="Post" field="title">...</can>
@casl/vue-v0.5.1 (2019-02-10)
@casl/vue-v0.5.0 (2018-11-25)
- README: changes links to @casl/ability to point to npm package instead to git root [skip ci] (a74086b), closes #102
- react:can: updates typescript declarations (213dcde)
- vue: adds
passThrough
prop toCan
(28ca883), closes #105
@casl/vue-v0.4.3 (2018-07-14)
@casl/vue-v0.4.2 (2018-07-02)
@casl/vue-v0.4.1 (2018-06-04)
@casl/vue-v0.4.0 (2018-06-01)
@casl/vue-v0.3.0 (2018-05-30)
@casl/vue-v0.2.1 (2018-05-29)
- vue: fixes issue with wrong type definition for
abilitiesPlugin
(a7e2251)