Closed dbvcode closed 2 years ago
I don't know. The official casl docs have this as well (as seen here: https://casl.js.org/v5/en/guide/intro#update-rules). I'm not the maintainer of the official casl package, just the adapter for feathers.
The official documentation also says:
https://casl.js.org/v5/en/api/casl-ability#ability-builder-constructor
import { AbilityBuilder, Ability } from '@casl/ability';
const { can, build } = new AbilityBuilder(Ability);
Could you check and confirm that?
I confirm it works! After opening the issue I kept on searching and ended in the casl for angular section and I saw that. Until answering my own question, you beat me to the punch. I guess it should be in the docs?
Thanks
Could you open a PR with the change to the docs? That would be awesome! I would merge it immediately.
Maybe even an issue/PR over at the official casl repo would be nice.
Steps to reproduce
I just installed feathers-casl in a typescript feathers project. While figuring casl out I just started from your basic example to define the rules for the newly authenticated user.
const { can, cannot, rules } = new AbilityBuilder();
throws the errorExpected 1 arguments, but got 0.
and expectsAbilityType: AnyClass<T>
as input.How do I deal with this? And funny enough am I the first one to get the error?
Expected behavior
Should work according to the docs :)
Actual behavior
It throws the error and does not compile.
System configuration
Not much to say here.
Module versions: "@angular/animations": "13.1.1", "@angular/common": "13.1.1", "@angular/compiler": "13.1.1", "@angular/core": "13.1.1", "@angular/forms": "13.1.1", "@angular/platform-browser": "13.1.1", "@angular/platform-browser-dynamic": "13.1.1", "@angular/router": "13.1.1", "@angular/service-worker": "^13.1.1", "@casl/ability": "^5.4.3", "@casl/angular": "^6.0.0", "@feathersjs/authentication": "^4.5.12", "@feathersjs/authentication-client": "^4.5.13", "@feathersjs/authentication-local": "^4.5.12", "@feathersjs/configuration": "^4.5.12", "@feathersjs/express": "^4.5.12", "@feathersjs/socketio": "^4.5.13", "@feathersjs/socketio-client": "^4.5.13", "@nrwl/angular": "13.4.6", "@nrwl/web": "13.4.6", "axios": "^0.21.4", "compression": "^1.7.4", "cors": "^2.8.5", "express": "4.17.1", "feathers-authentication-management-ts": "^2.1.2", "feathers-casl": "^0.7.1", "feathers-hooks-common": "^5.0.6", "feathers-mongodb": "^6.4.1", "feathers-reactive": "^0.8.2", "feathers-validate-joi": "^4.0.1", "helmet": "^4.6.0", "joi": "^17.5.0", "lodash": "^4.17.21", "luxon": "^2.3.0", "mongodb": "^3.7.3", "mongodb-core": "^3.2.7", "ng-zorro-antd": "^12.1.1", "nodemailer": "^6.7.2", "rxjs": "~6.6.0", "shx": "^0.3.4", "ts-node-dev": "^1.1.8", "tslib": "^2.3.1", "winston": "^3.4.0", "zone.js": "0.11.4"
NodeJS version: v14.18.2