CASL v5.1.0-next.10 Release Notes

Release Date: 2020-10-17 // over 3 years ago
  • 5.1.0-next.10 (2020-10-17)

    ๐Ÿ”จ Code Refactoring

    • ruleIndex: removes possibility to pass subject to rulesFor and possibleRulesFor [skip release] (b8c324d)

    ๐ŸŽ Performance Improvements

    • ruleIndex: removes subject type detection from _buildIndexFor (13fe934)

    ๐Ÿ’ฅ BREAKING CHANGES

    ruleIndex: rulesFor, possibleRulesFor, rulesToQuery, ruleToAST, rulesToFields accepts only subject type now!

    Before

    import { Ability } from '@casl/ability';const ability = new Ability([{ action: 'read', subject: 'Post' }]);class Post {}console.log(ability.rulesFor('read', new Post())); // [Rule]console.log(ability.rulesFor('read', 'Post')); // [Rule]
    

    After

    import { Ability } from '@casl/ability';const ability = new Ability([{ action: 'read', subject: 'Post' }]);class Post {}console.log(ability.rulesFor('read', new Post())); // throws exceptionconsole.log(ability.rulesFor('read', 'Post')); // [Rule]
    

    Other functions and methods have the same behavior