stalniy
released this
10 Aug 11:45
·
635 commits
to master
since this release
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
MongoQuery
type andbuildMongoQueryMatcher
function parameters. Influences users who implemented custom sift operators:MongoQuery
accepted a generic type of AdditionalOperators, now it accepts an object interface and custom operatorsMongoQueryOperators
is renamed toMongoQueryFieldOperators
and now acceptsValue
generic parameterbuildMongoQuery
now accepts 3 optional parameters: custom parsing instruction, custom operator interpreters and options for JavaScript interpretersAbility
does not compare objects anymore, so if you rely on value to equal specific object, then you need to either change your conditions or implement customequal
function
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, usedetectSubjectType
instead -
LegacyClaimRawRule
andLegacySubjectRawRule
are both removed, so you are no longer allowed to useactions
in rule definition, useaction
property instead -
Ability
throws an error if you specify a rule with propertyfield
to be an empty array -
Ability
no 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