Hi! Thanks for the great work on Gatehouse-TS.
While integrating the library, one DX issue stood out: the need to repeatedly specify
<User, Resource, Action, Context> every time we create policies or instantiate PermissionChecker.
Example today:
const policy = buildAbacPolicy<User, Resource, Action, Context>({ ... });
In larger projects this becomes boilerplate, increases visual noise, and can lead to inconsistent generics across files.
Suggested solution: a policy factory
Introduce something like:
const {
buildAbacPolicy,
buildRebacPolicy,
buildAndPolicy,
buildOrPolicy,
PermissionChecker,
} = createPolicyFactory<User, Resource, Action, Context>();
So policy code becomes:
const policy = buildAbacPolicy({ ... });
Benefits:
- Removes repeated generics
- Preserves full type safety
- No breaking changes
- Works well even with multiple authorization domains
Would you be open to this improvement?
If yes, I can open a PR implementing the factory.
Thanks!
Hi! Thanks for the great work on Gatehouse-TS.
While integrating the library, one DX issue stood out: the need to repeatedly specify
<User, Resource, Action, Context>every time we create policies or instantiatePermissionChecker.Example today:
In larger projects this becomes boilerplate, increases visual noise, and can lead to inconsistent generics across files.
Suggested solution: a policy factory
Introduce something like:
So policy code becomes:
Benefits:
Would you be open to this improvement?
If yes, I can open a PR implementing the factory.
Thanks!