CASL v5.1.0-next.12 Release Notes
Release Date: 2020-11-18 // over 3 years ago-
5.1.0-next.12 (2020-11-18)
๐ Bug Fixes
- ability: replaces getters with functions to ensure terser properly minifies them (386ecb6)
- extra: makes
permittedFieldsOf
to iterate from the end of array (81e6409)
๐จ Code Refactoring
- extra: makes
fieldsFrom
option to be mandatory forpermittedFieldsOf
[skip release] (df29b0d) - types: restricts which utility types are exported by library (e98618f)
โช Reverts
- ๐ builder: reverts back
AbilityBuilder
generic parameter (aa7b45f)
๐ฅ BREAKING CHANGES
types: types
AliasesMap
,TaggedInterface
,AbilityTupleType
,ToAbilityTypes
,AnyObject
are no longer exported by the libraryextra: makes
fieldsFrom
option to be mandatory forpermittedFieldsO f
. This reduces confusion around whypermittedFieldsOf
returns empty array when user can manage entity fields. So, now this logic is just explicit and clearBefore
import { defineAbility } from '@casl/ability';import { permittedFieldsOf } from '@casl/ability/extra';const ability = defineAbility((can) =\> {can('read', 'Article');});const fields = permittedFieldsOf(ability, 'read', 'Article'); // []
After
import { defineAbility } from '@casl/ability';import { permittedFieldsOf } from '@casl/ability/extra';const ability = defineAbility((can) =\> {can('read', 'Article');});const ARTICLE\_FIELDS = ['id', 'title', 'description'];const fields = permittedFieldsOf(ability, 'read', 'Article', {fieldsFrom: rule =\> rule.fields || ARTICLE\_FIELDS}); // ['id', 'title', 'description']