@careflair/common 1.0.42 → 1.0.43
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/dist/abilities/index.d.ts +14 -3
- package/package.json +1 -1
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
import { PureAbility } from "@casl/ability";
|
|
1
|
+
import { PureAbility, MongoQuery } from "@casl/ability";
|
|
2
2
|
import { UserRole } from "../enums";
|
|
3
3
|
/**
|
|
4
4
|
* Actions that users can perform
|
|
5
5
|
*/
|
|
6
6
|
export type Actions = "create" | "read" | "update" | "delete" | "apply" | "initiate" | "respond" | "submit" | "manage";
|
|
7
|
+
/**
|
|
8
|
+
* Subject types with their fields for conditional checks
|
|
9
|
+
*/
|
|
10
|
+
type Job = {
|
|
11
|
+
postedBy: string;
|
|
12
|
+
};
|
|
13
|
+
type Profile = {
|
|
14
|
+
user: string;
|
|
15
|
+
};
|
|
7
16
|
/**
|
|
8
17
|
* Subjects/resources that users act upon
|
|
18
|
+
* Includes both string literals (for rule definition) and object types (for instance checking)
|
|
9
19
|
*/
|
|
10
|
-
export type Subjects = "Job" | "Chat" | "NDISScreening" | "WorkingWithChildren" | "Profile" | "all";
|
|
20
|
+
export type Subjects = "Job" | "Chat" | "NDISScreening" | "WorkingWithChildren" | "Profile" | "all" | Job | Profile;
|
|
11
21
|
/**
|
|
12
22
|
* AppAbility type for type-safe permission checks
|
|
13
23
|
* Uses PureAbility (modern API) + mongoQueryMatcher so we can define conditional rules
|
|
14
24
|
* (e.g. { postedBy: user.id }) without runtime errors.
|
|
15
25
|
*/
|
|
16
|
-
export type AppAbility = PureAbility<[Actions, Subjects],
|
|
26
|
+
export type AppAbility = PureAbility<[Actions, Subjects], MongoQuery>;
|
|
17
27
|
/**
|
|
18
28
|
* User type for ability definition
|
|
19
29
|
* Only requires id and role - minimal interface for permission checks
|
|
@@ -31,3 +41,4 @@ export type UserForAbility = {
|
|
|
31
41
|
* @returns AppAbility instance with user's permissions
|
|
32
42
|
*/
|
|
33
43
|
export declare function defineAbilitiesFor(user: UserForAbility): AppAbility;
|
|
44
|
+
export {};
|