Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance typing #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Enhance typing #112

wants to merge 1 commit into from

Conversation

qwertycxz
Copy link

@qwertycxz qwertycxz commented Jun 15, 2024

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. :)

@wangjue666
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants