law-common 14.0.8-beta.0 → 14.0.8-beta.2

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.
@@ -11,11 +11,11 @@ const to_do_list_status_enum_1 = require("../enums/to_do_list_status_enum");
11
11
  *
12
12
  * @Post() TO_DO_LIST_CREATE_ORG, _CREATE_PROJECT, _CREATE_SELF
13
13
  * @Patch(":id") TO_DO_LIST_UPDATE_ORG, _UPDATE_PROJECT, _UPDATE_SELF
14
- * @Delete(":id") TO_DO_LIST_DELETE_ORG, _DELETE_PROJECT
14
+ * @Delete(":id") TO_DO_LIST_DELETE_ORG, _DELETE_PROJECT, _DELETE_SELF
15
15
  *
16
- * DELETE carries only two: TO_DO_LIST_DELETE_SELF has never been seeded, so a user whose only
17
- * to-do-list authority is over their own rows cannot delete. That matches today's behaviour and is
18
- * preserved rather than fixed here.
16
+ * DELETE now carries all three. TO_DO_LIST_DELETE_SELF is seeded in higher environments (not in the
17
+ * original 1752573777447-ToDoListEntityPermissions migration) and scopes deletes to the acting
18
+ * user's own rows via the V2 getDeletePermissionFilterFunction.
19
19
  *
20
20
  * DEACTIVATE / ACTIVATE / RESTORE are unscoped - LW-826 seeded them flat - so those keep single-name
21
21
  * arrays. Mixing the two shapes in one config is deliberate: each action names the rows that exist.
@@ -28,7 +28,7 @@ const to_do_list_status_enum_1 = require("../enums/to_do_list_status_enum");
28
28
  */
29
29
  const TO_DO_LIST_CREATE_PERMISSION = ["TO_DO_LIST_CREATE_ORG", "TO_DO_LIST_CREATE_PROJECT", "TO_DO_LIST_CREATE_SELF"];
30
30
  const TO_DO_LIST_UPDATE_PERMISSION = ["TO_DO_LIST_UPDATE_ORG", "TO_DO_LIST_UPDATE_PROJECT", "TO_DO_LIST_UPDATE_SELF"];
31
- const TO_DO_LIST_DELETE_PERMISSION = ["TO_DO_LIST_DELETE_ORG", "TO_DO_LIST_DELETE_PROJECT"];
31
+ const TO_DO_LIST_DELETE_PERMISSION = ["TO_DO_LIST_DELETE_ORG", "TO_DO_LIST_DELETE_PROJECT", "TO_DO_LIST_DELETE_SELF"];
32
32
  const TO_DO_LIST_DEACTIVATE_PERMISSION = ["TO_DO_LIST_DEACTIVATE"];
33
33
  const TO_DO_LIST_ACTIVATE_PERMISSION = ["TO_DO_LIST_ACTIVATE"];
34
34
  const TO_DO_LIST_RESTORE_PERMISSION = ["TO_DO_LIST_RESTORE"];
@@ -1,3 +1,4 @@
1
+ import { ProjectUserStatusEnum } from "../enums/project_user_status.enum";
1
2
  import { UserRoleEnum } from "../enums/user_role_enum";
2
3
  import { UserStatusEnum } from "../enums/user_status_enum";
3
4
  import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
@@ -57,5 +58,8 @@ export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> im
57
58
  get roleEntityModel(): RoleEntityModel;
58
59
  hasPermission(permissionName: string): boolean;
59
60
  get projects(): ProjectEntityModel[];
61
+ get activeProjects(): ProjectEntityModel[];
62
+ get inactiveProjects(): ProjectEntityModel[];
63
+ getProjectUserStatus(projectId: number): ProjectUserStatusEnum | null;
60
64
  get isOwnerPartnerRoleUser(): boolean;
61
65
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserEntityModel = void 0;
4
+ const project_user_status_enum_1 = require("../enums/project_user_status.enum");
4
5
  const relation_type_enum_1 = require("../enums/relation_type_enum");
5
6
  const user_role_enum_1 = require("../enums/user_role_enum");
6
7
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
@@ -51,6 +52,22 @@ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
51
52
  get projects() {
52
53
  return this.projecUserMappings.map((mapping) => mapping.project).filter((project) => !!project);
53
54
  }
55
+ get activeProjects() {
56
+ return this.projecUserMappings
57
+ .filter((mapping) => mapping.status === project_user_status_enum_1.ProjectUserStatusEnum.ACTIVE)
58
+ .map((mapping) => mapping.project)
59
+ .filter((project) => !!project);
60
+ }
61
+ get inactiveProjects() {
62
+ return this.projecUserMappings
63
+ .filter((mapping) => mapping.status === project_user_status_enum_1.ProjectUserStatusEnum.INACTIVE)
64
+ .map((mapping) => mapping.project)
65
+ .filter((project) => !!project);
66
+ }
67
+ getProjectUserStatus(projectId) {
68
+ var _a, _b;
69
+ return (_b = (_a = this.projecUserMappings.find((mapping) => mapping.projectId === projectId)) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : null;
70
+ }
54
71
  get isOwnerPartnerRoleUser() {
55
72
  return [user_role_enum_1.UserRoleEnum.OWNER, user_role_enum_1.UserRoleEnum.PARTNER].includes(this.role);
56
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "14.0.8-beta.0",
3
+ "version": "14.0.8-beta.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [