github stalniy/casl @casl/ability@5.1.0-next.12

latest releases: @casl/prisma@2.0.1, @casl/vue@3.0.0, @casl/react@7.0.0...
pre-release5 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 for permittedFieldsOf [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 library

  • extra: makes fieldsFrom option to be mandatory for permittedFieldsO f. This reduces confusion around why permittedFieldsOf returns empty array when user can manage entity fields. So, now this logic is just explicit and clear

    Before

    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']

Don't miss a new casl release

NewReleases is sending notifications on new releases.