Version 3 of the kit: - Radix UI replaced with Base UI (using the Shadcn UI patterns) - next-intl replaces react-i18next - enhanceAction deprecated; usage moved to next-safe-action - main layout now wrapped with [locale] path segment - Teams only mode - Layout updates - Zod v4 - Next.js 16.2 - Typescript 6 - All other dependencies updated - Removed deprecated Edge CSRF - Dynamic Github Action runner
20 lines
1.0 KiB
Markdown
20 lines
1.0 KiB
Markdown
# @kit/policies — Registry-Based Policy System
|
|
|
|
## Non-Negotiables
|
|
|
|
1. ALWAYS use `definePolicy` with a unique `id` and register in a registry via `createPolicyRegistry()`
|
|
2. NEVER write inline policies in feature code — define in a registry file
|
|
3. ALWAYS use `allow()`/`deny()` returns with error codes and remediation messages
|
|
4. ALWAYS assign stages (`preliminary`, `submission`) for stage-aware evaluation
|
|
5. ALWAYS use `createPoliciesFromRegistry()` to load policies by ID — supports config tuples like `['max-invitations', { maxInvitations: 5 }]`
|
|
6. ALWAYS use `createPolicyEvaluator()` and call `evaluatePolicies()` or `evaluateGroups()`
|
|
7. NEVER evaluate policies without specifying an operator (`ALL` = AND, `ANY` = OR)
|
|
|
|
## Key Imports
|
|
|
|
- `definePolicy`, `allow`, `deny`, `createPolicyRegistry`, `createPoliciesFromRegistry`, `createPolicyEvaluator` — all from `@kit/policies`
|
|
|
|
## Exemplar
|
|
|
|
- `packages/features/team-accounts/src/server/policies/policies.ts` — real-world registry with stage-aware, configurable policies
|