@pyreon/permissions 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/analysis/index.js.html +1 -1
- package/lib/index.js +51 -40
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +31 -31
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +14 -7
- package/src/context.ts +4 -4
- package/src/index.ts +4 -4
- package/src/permissions.ts +23 -13
- package/src/tests/permissions.test.ts +384 -247
- package/src/types.ts +3 -7
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Computed } from
|
|
1
|
+
import type { Computed } from "@pyreon/reactivity"
|
|
2
2
|
|
|
3
3
|
// ─── Permission values ───────────────────────────────────────────────────────
|
|
4
4
|
|
|
@@ -6,18 +6,14 @@ import type { Computed } from '@pyreon/reactivity'
|
|
|
6
6
|
* A permission predicate — receives optional context and returns a boolean.
|
|
7
7
|
* Used for instance-level checks (e.g., "can update THIS post?").
|
|
8
8
|
*/
|
|
9
|
-
export type PermissionPredicate<TContext = unknown> = (
|
|
10
|
-
context?: TContext,
|
|
11
|
-
) => boolean
|
|
9
|
+
export type PermissionPredicate<TContext = unknown> = (context?: TContext) => boolean
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* A permission value is either a static boolean or a predicate function.
|
|
15
13
|
* - `true` / `false` — static grant or denial
|
|
16
14
|
* - `(context?) => boolean` — dynamic, evaluated per-check
|
|
17
15
|
*/
|
|
18
|
-
export type PermissionValue<TContext = unknown> =
|
|
19
|
-
| boolean
|
|
20
|
-
| PermissionPredicate<TContext>
|
|
16
|
+
export type PermissionValue<TContext = unknown> = boolean | PermissionPredicate<TContext>
|
|
21
17
|
|
|
22
18
|
// ─── Permission map ──────────────────────────────────────────────────────────
|
|
23
19
|
|