accesscontrol icon indicating copy to clipboard operation
accesscontrol copied to clipboard

Enhance typing

Open qwertycxz opened this issue 1 year ago • 1 comments

OverView

This PR makes a lot of typing enhancements for TypeScript, with (basically) no functionaly changes.

  1. Use generics and method overloads. For example:
filter<T>(data: T): Partial<T>;
filter<T>(data: T[]): Partial<T>[];

This means we will get a partial of the data if the argument is an object, or an array of partials of the data if the argument is an array. 2. #90. This has not changed how to use the two enums but is really helpful for TypeScript. 3. Action enum now has value such as create:own. You cannot pretend that they are not part of Action. 4. Make util as class rather than a constant. This allows for method overloads. 5. Move lock from util.ts to AccessControl.ts. _lock is private, thus it shouldn't be modified by other files. 6. Update tsconfig and package-lock to be up-to-date.

Cover

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 97.55 96.62 94.59 97.33
src 100 99.29 100 100
AccessControl.ts 100 100 100 100
utils.ts 100 99.05 100 100 369,757
src/core 90.59 76.92 84.31 90.3
Access.ts 93.98 95 83.33 93.83 88,164,165,337,399
AccessControlError.ts 100 100 100 100
Permission.ts 100 100 100 100
Query.ts 78.85 33.33 76.47 78.43 ... 87,181,228,275
index.ts 100 100 100 100
src/enums 100 100 100 100
Action.ts 100 100 100 100
Possession.ts 100 100 100 100
index.ts 100 100 100 100

Test Suites: 2 passed, 2 total Tests: 51 passed, 51 total Snapshots: 0 total Time: 3.428s Ran all test suites.

Mumbles

The last commit was 3 years ago. It’s a pity that such a good repository has been abandoned! I hope @onury may come back for code reviews. Anyone who is willing (or already has) to take over this repository are free to use my PR. :)

qwertycxz avatar Jun 15 '24 14:06 qwertycxz

https://github.com/sellerartifact/accesscontrol hi, We plan to maintain this repo and have merged this pr

wangjue666 avatar Jun 20 '24 08:06 wangjue666