5.0.0 (2020-08-10)
Bug Fixes
- ability: removes sift specific types from casl (9f18b31)
Code Refactoring
- ability: removes deprecated types and fields (bf5ef73), closes #355
- package: replaces siftjs with @ucast/mongo2js (41e53aa), closes #350
Features
BREAKING CHANGES
-
package: replaces siftjs with @ucast/mongo2js. This changed
MongoQuerytype andbuildMongoQueryMatcherfunction parameters. Influences users who implemented custom sift operators:MongoQueryaccepted a generic type of AdditionalOperators, now it accepts an object interface and custom operatorsMongoQueryOperatorsis renamed toMongoQueryFieldOperatorsand now acceptsValuegeneric parameterbuildMongoQuerynow accepts 3 optional parameters: custom parsing instruction, custom operator interpreters and options for JavaScript interpretersAbilitydoes not compare objects anymore, so if you rely on value to equal specific object, then you need to either change your conditions or implement customequalfunction
Before
import { MongoQuery, MongoQueryOperators, buildMongoQueryMatcher } from '@casl/ability'; import { $nor } from 'sift'; type CustomMongoQuery = MongoQuery<{ $customOperator: Function }>; type $eq = MongoQueryOperators['$eq']; const matcher = buildMongoQueryMatcher({ $nor })
After
import { MongoQuery, MongoQueryFieldOperators, buildMongoQueryMatcher } from '@casl/ ability'; import { $nor, nor } from '@ucast/mongo2js' type CustomMongoQuery<T> = MongoQuery<T, { toplevel: { // can be used only on document level $customOperator: Function }, field: { // can be used only on field level $my: boolean } }> type $eq = MongoQueryFieldOperators['$eq']; // accepts optional `Value` generic parameter const matcher = buildMongoQueryMatcher({ $nor }, { nor }); ```
-
ability: removes deprecated options and types:
-
AbilityOptions['subjectName']has been removed, usedetectSubjectTypeinstead -
LegacyClaimRawRuleandLegacySubjectRawRuleare both removed, so you are no longer allowed to useactionsin rule definition, useactionproperty instead -
Abilitythrows an error if you specify a rule with propertyfieldto be an empty array -
Abilityno longer warns about using only inverted rules. This may be done by intention, so now it's left up to developer to decide whether it's fine or not