law-common 14.1.4-beta.6 → 14.1.4-beta.8

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.
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * api/v2 - the new flow contracts.
3
3
  *
4
- * Intentionally empty: to_do_list's v2 create/update DTO interfaces are generated, not hand-written,
5
- * and have not been generated yet. The generator writes them to api/v2/interface/ (checklist 12.4,
6
- * and 9.1 rows 4 and 7).
7
- *
8
- * The empty export keeps this a module so `export * as v2` in api/index.ts resolves.
4
+ * Namespaced under `v2` by the `export * as v2` in api/index.ts, so these deliberately reuse the
5
+ * same export names as the frozen api/v1 (and legacy api/interface) contracts — an entity's v1
6
+ * consumers and v2 consumers each resolve their own shape from their own module path.
9
7
  */
10
8
  export * from "./interface/to_do_list.create.dto.interface";
11
9
  export * from "./interface/to_do_list.update.dto.interface";
12
10
  export * from "./interface/expense_type.create.dto.interface";
13
11
  export * from "./interface/expense_type.update.dto.interface";
12
+ export * from "./interface/task.create.dto.interface";
13
+ export * from "./interface/task.update.dto.interface";
@@ -2,11 +2,9 @@
2
2
  /**
3
3
  * api/v2 - the new flow contracts.
4
4
  *
5
- * Intentionally empty: to_do_list's v2 create/update DTO interfaces are generated, not hand-written,
6
- * and have not been generated yet. The generator writes them to api/v2/interface/ (checklist 12.4,
7
- * and 9.1 rows 4 and 7).
8
- *
9
- * The empty export keeps this a module so `export * as v2` in api/index.ts resolves.
5
+ * Namespaced under `v2` by the `export * as v2` in api/index.ts, so these deliberately reuse the
6
+ * same export names as the frozen api/v1 (and legacy api/interface) contracts — an entity's v1
7
+ * consumers and v2 consumers each resolve their own shape from their own module path.
10
8
  */
11
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
10
  if (k2 === undefined) k2 = k;
@@ -23,9 +21,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
21
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
22
  };
25
23
  Object.defineProperty(exports, "__esModule", { value: true });
26
- // export {
27
- // };
28
24
  __exportStar(require("./interface/to_do_list.create.dto.interface"), exports);
29
25
  __exportStar(require("./interface/to_do_list.update.dto.interface"), exports);
30
26
  __exportStar(require("./interface/expense_type.create.dto.interface"), exports);
31
27
  __exportStar(require("./interface/expense_type.update.dto.interface"), exports);
28
+ __exportStar(require("./interface/task.create.dto.interface"), exports);
29
+ __exportStar(require("./interface/task.update.dto.interface"), exports);
@@ -0,0 +1,5 @@
1
+ import { IEntityCreateDto } from "../../../entities";
2
+ import { ITaskEntity } from "../../../entities/interface/task.entity.interface";
3
+ export type ITaskCreateExclude = "status";
4
+ export interface ITaskCreateDto extends Omit<IEntityCreateDto<ITaskEntity>, ITaskCreateExclude> {
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import { DeepPartialButRequired } from "../../interface/api.utils.interface";
2
+ import { TaskActionEnum } from "../../../entities";
3
+ import { ITaskCreateDto } from "./task.create.dto.interface";
4
+ export type ITaskUpdateDto = DeepPartialButRequired<ITaskCreateDto, never> & {
5
+ actionData: ITaskActionDataDto;
6
+ } & {
7
+ id?: number;
8
+ };
9
+ export interface ITaskActionDataDto {
10
+ action: TaskActionEnum;
11
+ remark?: string;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,6 @@
1
- import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IBaseEntityApiResponse, VirtualEntityEnum } from "../interface/entity.utils.interface";
1
+ import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IBaseEntityApiResponse, ISearchIncludeEntity, VirtualEntityEnum } from "../interface/entity.utils.interface";
2
+ import { PermissionGroupEnum } from "../enums/permission_group_enum";
3
+ import { IUserEntity } from "../interface/user.entity.interface";
2
4
  import { BaseEntityModel } from "./base.entity.model";
3
5
  export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
4
6
  export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
@@ -51,4 +53,11 @@ export declare class EntityModelRelationHelper {
51
53
  mergeHelperFrom(other: EntityModelRelationHelper, config?: {
52
54
  populateRelations?: boolean;
53
55
  }): EntityModelRelationHelper;
56
+ /**
57
+ * Builds the role-scoped permission search entity: ROLE (caller's role) -> ROLE_PERMISSION_MAPPING -> PERMISSION
58
+ * (entity + org + action groups). Append to `filter.entities` so the caller's permissions land in the helper.
59
+ */
60
+ static getRoleFilterFromDtos<T extends EntityEnum>(currentUser: IUserEntity, entity: T, dtos: {
61
+ getActionPermissionGroup(): PermissionGroupEnum;
62
+ }[]): ISearchIncludeEntity<EntityEnum>;
54
63
  }
@@ -485,5 +485,34 @@ class EntityModelRelationHelper {
485
485
  }
486
486
  return EntityModelRelationHelper.getClone(this);
487
487
  }
488
+ /**
489
+ * Builds the role-scoped permission search entity: ROLE (caller's role) -> ROLE_PERMISSION_MAPPING -> PERMISSION
490
+ * (entity + org + action groups). Append to `filter.entities` so the caller's permissions land in the helper.
491
+ */
492
+ static getRoleFilterFromDtos(currentUser, entity, dtos) {
493
+ const permissionSearch = {
494
+ name: entity_utils_interface_1.EntityEnum.PERMISSION,
495
+ include: {
496
+ entity: [entity],
497
+ organizationId: [currentUser.organizationId],
498
+ group: [...new Set(dtos.map((dto) => dto.getActionPermissionGroup()))],
499
+ },
500
+ };
501
+ const rolePermissionMappingSearch = {
502
+ name: entity_utils_interface_1.EntityEnum.ROLE_PERMISSION_MAPPING,
503
+ columnKeys: ["roleId", "permissionId", "id"],
504
+ relations: [permissionSearch],
505
+ };
506
+ const roleSearch = {
507
+ name: entity_utils_interface_1.EntityEnum.ROLE,
508
+ columnKeys: ["id", "name", "organizationId"],
509
+ include: {
510
+ name: [currentUser.role],
511
+ organizationId: [currentUser.organizationId],
512
+ },
513
+ relations: [rolePermissionMappingSearch],
514
+ };
515
+ return roleSearch;
516
+ }
488
517
  }
489
518
  exports.EntityModelRelationHelper = EntityModelRelationHelper;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "14.1.4-beta.6",
3
+ "version": "14.1.4-beta.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [