Skip to content

@casl/ability@5.1.0-next.10

Pre-release
Pre-release

Choose a tag to compare

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 exception
    console.log(ability.rulesFor('read', 'Post')); // [Rule]

    Other functions and methods have the same behavior