-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(package): replaces siftjs with @ucast/mongo2js
This allows to use AST generated by @ucast/mongo to convert the conditions to different languages and interpret them BREAKING CHANGE: replaces siftjs with @ucast/mongo2js. This changed `MongoQuery` type and `buildMongoQueryMatcher` function parameters. Influences users who implemented custom sift operators: * `MongoQuery` accepted a generic type of AdditionalOperators, now it accepts an object interface and custom operators * `MongoQueryOperators` is renamed to `MongoQueryFieldOperators` and now accepts `Value` generic parameter * `buildMongoQuery` now accepts 3 optional parameters: [custom parsing instruction](https://www.npmjs.com/package/@ucast/mongo#custom-operator), [custom operator interpreters](https://www.npmjs.com/package/@ucast/js#custom-operator-interpreter) and [options for JavaScript interpreters](https://www.npmjs.com/package/@ucast/js#custom-interpreter) * `Ability` 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 custom `equal` function **Before** ```ts 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** ```ts 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 }); ``` Relates to #350
- Loading branch information
Showing
8 changed files
with
136 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.