@careflair/common 1.0.41 → 1.0.42

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.
@@ -10,17 +10,18 @@ export type Actions = "create" | "read" | "update" | "delete" | "apply" | "initi
10
10
  export type Subjects = "Job" | "Chat" | "NDISScreening" | "WorkingWithChildren" | "Profile" | "all";
11
11
  /**
12
12
  * AppAbility type for type-safe permission checks
13
- * Uses PureAbility (modern API) instead of deprecated Ability
13
+ * Uses PureAbility (modern API) + mongoQueryMatcher so we can define conditional rules
14
+ * (e.g. { postedBy: user.id }) without runtime errors.
14
15
  */
15
- export type AppAbility = PureAbility<[Actions, Subjects]>;
16
+ export type AppAbility = PureAbility<[Actions, Subjects], any>;
16
17
  /**
17
- * User interface for ability definition
18
+ * User type for ability definition
18
19
  * Only requires id and role - minimal interface for permission checks
19
20
  */
20
- export interface UserForAbility {
21
+ export type UserForAbility = {
21
22
  id: string;
22
23
  role: UserRole;
23
- }
24
+ };
24
25
  /**
25
26
  * Define abilities for a user based on their role
26
27
  * This is the SINGLE SOURCE OF TRUTH for permissions
@@ -64,5 +64,7 @@ function defineAbilitiesFor(user) {
64
64
  can("read", "Profile", { user: user.id });
65
65
  can("update", "Profile", { user: user.id });
66
66
  }
67
- return build();
67
+ return build({
68
+ conditionsMatcher: ability_1.mongoQueryMatcher,
69
+ });
68
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@careflair/common",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "Shared assets for CareFlair",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",