rez_core 2.2.7 → 2.2.9

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.
Files changed (216) hide show
  1. package/dist/constant/global.constant.d.ts +2 -1
  2. package/dist/constant/global.constant.js +3 -2
  3. package/dist/constant/global.constant.js.map +1 -1
  4. package/dist/module/enterprise/repository/school.repository.js +18 -2
  5. package/dist/module/enterprise/repository/school.repository.js.map +1 -1
  6. package/dist/module/filter/controller/filter.controller.d.ts +1 -1
  7. package/dist/module/filter/controller/filter.controller.js +7 -4
  8. package/dist/module/filter/controller/filter.controller.js.map +1 -1
  9. package/dist/module/filter/dto/filter-request.dto.d.ts +1 -0
  10. package/dist/module/filter/service/filter.service.js +26 -4
  11. package/dist/module/filter/service/filter.service.js.map +1 -1
  12. package/dist/module/layout_preference/controller/layout_preference.controller.js +4 -4
  13. package/dist/module/layout_preference/controller/layout_preference.controller.js.map +1 -1
  14. package/dist/module/layout_preference/entity/layout_preference.entity.d.ts +2 -0
  15. package/dist/module/layout_preference/entity/layout_preference.entity.js +13 -0
  16. package/dist/module/layout_preference/entity/layout_preference.entity.js.map +1 -1
  17. package/dist/module/layout_preference/repository/layout_preference.repository.d.ts +1 -1
  18. package/dist/module/layout_preference/repository/layout_preference.repository.js +4 -2
  19. package/dist/module/layout_preference/repository/layout_preference.repository.js.map +1 -1
  20. package/dist/module/layout_preference/service/layout_preference.service.d.ts +1 -1
  21. package/dist/module/layout_preference/service/layout_preference.service.js +17 -4
  22. package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
  23. package/dist/module/listmaster/entity/list-master-items.entity.js +5 -5
  24. package/dist/module/listmaster/entity/list-master-items.entity.js.map +1 -1
  25. package/dist/module/meta/controller/media.controller.d.ts +1 -1
  26. package/dist/module/meta/controller/media.controller.js +1 -1
  27. package/dist/module/meta/controller/media.controller.js.map +1 -1
  28. package/dist/module/meta/entity/base-entity.entity.js.map +1 -1
  29. package/dist/module/module/controller/module-access.controller.d.ts +1 -1
  30. package/dist/module/module/controller/module-access.controller.js +6 -6
  31. package/dist/module/module/controller/module-access.controller.js.map +1 -1
  32. package/dist/module/module/service/module-access.service.d.ts +2 -1
  33. package/dist/module/module/service/module-access.service.js +5 -3
  34. package/dist/module/module/service/module-access.service.js.map +1 -1
  35. package/dist/module/workflow/controller/action-category.controller.d.ts +8 -0
  36. package/dist/module/workflow/controller/action-category.controller.js +45 -0
  37. package/dist/module/workflow/controller/action-category.controller.js.map +1 -0
  38. package/dist/module/workflow/controller/action.controller.d.ts +28 -0
  39. package/dist/module/workflow/controller/action.controller.js +88 -0
  40. package/dist/module/workflow/controller/action.controller.js.map +1 -0
  41. package/dist/module/workflow/controller/comm-template.controller.d.ts +11 -0
  42. package/dist/module/workflow/controller/comm-template.controller.js +44 -0
  43. package/dist/module/workflow/controller/comm-template.controller.js.map +1 -0
  44. package/dist/module/workflow/controller/entity-modification.controller.d.ts +8 -0
  45. package/dist/module/workflow/controller/entity-modification.controller.js +44 -0
  46. package/dist/module/workflow/controller/entity-modification.controller.js.map +1 -0
  47. package/dist/module/workflow/controller/stage-group.controller.d.ts +10 -0
  48. package/dist/module/workflow/controller/stage-group.controller.js +43 -0
  49. package/dist/module/workflow/controller/stage-group.controller.js.map +1 -0
  50. package/dist/module/workflow/controller/stage.controller.d.ts +13 -0
  51. package/dist/module/workflow/controller/stage.controller.js +56 -0
  52. package/dist/module/workflow/controller/stage.controller.js.map +1 -0
  53. package/dist/module/workflow/controller/task.controller.d.ts +21 -0
  54. package/dist/module/workflow/controller/task.controller.js +58 -0
  55. package/dist/module/workflow/controller/task.controller.js.map +1 -0
  56. package/dist/module/workflow/controller/workflow-meta.controller.d.ts +15 -0
  57. package/dist/module/workflow/controller/workflow-meta.controller.js +70 -0
  58. package/dist/module/workflow/controller/workflow-meta.controller.js.map +1 -0
  59. package/dist/module/workflow/controller/workflow.controller.d.ts +25 -10
  60. package/dist/module/workflow/controller/workflow.controller.js +32 -15
  61. package/dist/module/workflow/controller/workflow.controller.js.map +1 -1
  62. package/dist/module/workflow/entity/action-category.entity.d.ts +1 -0
  63. package/dist/module/workflow/entity/action-category.entity.js +4 -0
  64. package/dist/module/workflow/entity/action-category.entity.js.map +1 -1
  65. package/dist/module/workflow/entity/action-data.entity.d.ts +15 -0
  66. package/dist/module/workflow/entity/action-data.entity.js +70 -0
  67. package/dist/module/workflow/entity/action-data.entity.js.map +1 -0
  68. package/dist/module/workflow/entity/action.entity.d.ts +7 -2
  69. package/dist/module/workflow/entity/action.entity.js +30 -10
  70. package/dist/module/workflow/entity/action.entity.js.map +1 -1
  71. package/dist/module/workflow/entity/comm-template.entity.d.ts +5 -0
  72. package/dist/module/workflow/entity/comm-template.entity.js +21 -1
  73. package/dist/module/workflow/entity/comm-template.entity.js.map +1 -1
  74. package/dist/module/workflow/entity/entity-modification.entity.d.ts +13 -0
  75. package/dist/module/workflow/entity/entity-modification.entity.js +63 -0
  76. package/dist/module/workflow/entity/entity-modification.entity.js.map +1 -0
  77. package/dist/module/workflow/entity/stage-group.entity.d.ts +1 -1
  78. package/dist/module/workflow/entity/stage-group.entity.js +1 -1
  79. package/dist/module/workflow/entity/stage-group.entity.js.map +1 -1
  80. package/dist/module/workflow/entity/stage-movement-data.entity.d.ts +4 -0
  81. package/dist/module/workflow/entity/stage-movement-data.entity.js +16 -0
  82. package/dist/module/workflow/entity/stage-movement-data.entity.js.map +1 -1
  83. package/dist/module/workflow/entity/stage.entity.d.ts +2 -2
  84. package/dist/module/workflow/entity/stage.entity.js +5 -5
  85. package/dist/module/workflow/entity/stage.entity.js.map +1 -1
  86. package/dist/module/workflow/entity/task-data.entity.d.ts +25 -0
  87. package/dist/module/workflow/entity/task-data.entity.js +110 -0
  88. package/dist/module/workflow/entity/task-data.entity.js.map +1 -0
  89. package/dist/module/workflow/entity/template-attach-mapper.entity.d.ts +11 -0
  90. package/dist/module/workflow/entity/template-attach-mapper.entity.js +54 -0
  91. package/dist/module/workflow/entity/template-attach-mapper.entity.js.map +1 -0
  92. package/dist/module/workflow/entity/workflow-level-mapping.entity.d.ts +7 -0
  93. package/dist/module/workflow/entity/workflow-level-mapping.entity.js +38 -0
  94. package/dist/module/workflow/entity/workflow-level-mapping.entity.js.map +1 -0
  95. package/dist/module/workflow/entity/workflow.entity.d.ts +2 -0
  96. package/dist/module/workflow/entity/workflow.entity.js +8 -0
  97. package/dist/module/workflow/entity/workflow.entity.js.map +1 -1
  98. package/dist/module/workflow/repository/action-data.repository.d.ts +10 -0
  99. package/dist/module/workflow/repository/action-data.repository.js +85 -0
  100. package/dist/module/workflow/repository/action-data.repository.js.map +1 -0
  101. package/dist/module/workflow/repository/action.repository.d.ts +17 -0
  102. package/dist/module/workflow/repository/action.repository.js +97 -0
  103. package/dist/module/workflow/repository/action.repository.js.map +1 -0
  104. package/dist/module/workflow/repository/comm-template.repository.d.ts +14 -0
  105. package/dist/module/workflow/repository/comm-template.repository.js +87 -0
  106. package/dist/module/workflow/repository/comm-template.repository.js.map +1 -0
  107. package/dist/module/workflow/repository/stage-group.repository.d.ts +7 -0
  108. package/dist/module/workflow/repository/stage-group.repository.js +50 -0
  109. package/dist/module/workflow/repository/stage-group.repository.js.map +1 -0
  110. package/dist/module/workflow/repository/stage-movement.repository.d.ts +23 -0
  111. package/dist/module/workflow/repository/stage-movement.repository.js +142 -0
  112. package/dist/module/workflow/repository/stage-movement.repository.js.map +1 -0
  113. package/dist/module/workflow/repository/stage.repository.d.ts +7 -0
  114. package/dist/module/workflow/repository/stage.repository.js +50 -0
  115. package/dist/module/workflow/repository/stage.repository.js.map +1 -0
  116. package/dist/module/workflow/repository/task.repository.d.ts +10 -0
  117. package/dist/module/workflow/repository/task.repository.js +77 -0
  118. package/dist/module/workflow/repository/task.repository.js.map +1 -0
  119. package/dist/module/workflow/repository/workflow.repository.d.ts +9 -1
  120. package/dist/module/workflow/repository/workflow.repository.js +38 -6
  121. package/dist/module/workflow/repository/workflow.repository.js.map +1 -1
  122. package/dist/module/workflow/service/action-category.service.d.ts +5 -0
  123. package/dist/module/workflow/service/action-category.service.js +23 -1
  124. package/dist/module/workflow/service/action-category.service.js.map +1 -1
  125. package/dist/module/workflow/service/action-data.service.d.ts +11 -0
  126. package/dist/module/workflow/service/action-data.service.js +36 -0
  127. package/dist/module/workflow/service/action-data.service.js.map +1 -0
  128. package/dist/module/workflow/service/action.service.d.ts +19 -1
  129. package/dist/module/workflow/service/action.service.js +159 -10
  130. package/dist/module/workflow/service/action.service.js.map +1 -1
  131. package/dist/module/workflow/service/comm-template.service.d.ts +11 -0
  132. package/dist/module/workflow/service/comm-template.service.js +59 -1
  133. package/dist/module/workflow/service/comm-template.service.js.map +1 -1
  134. package/dist/module/workflow/service/entity-modification.service.d.ts +8 -0
  135. package/dist/module/workflow/service/entity-modification.service.js +52 -0
  136. package/dist/module/workflow/service/entity-modification.service.js.map +1 -0
  137. package/dist/module/workflow/service/populate-workflow.service.d.ts +21 -0
  138. package/dist/module/workflow/service/populate-workflow.service.js +124 -0
  139. package/dist/module/workflow/service/populate-workflow.service.js.map +1 -0
  140. package/dist/module/workflow/service/stage-group.service.d.ts +13 -0
  141. package/dist/module/workflow/service/stage-group.service.js +39 -1
  142. package/dist/module/workflow/service/stage-group.service.js.map +1 -1
  143. package/dist/module/workflow/service/stage.service.d.ts +14 -4
  144. package/dist/module/workflow/service/stage.service.js +57 -13
  145. package/dist/module/workflow/service/stage.service.js.map +1 -1
  146. package/dist/module/workflow/service/task.service.d.ts +18 -0
  147. package/dist/module/workflow/service/task.service.js +63 -0
  148. package/dist/module/workflow/service/task.service.js.map +1 -0
  149. package/dist/module/workflow/service/workflow-list-master.service.js +4 -4
  150. package/dist/module/workflow/service/workflow-meta.service.d.ts +20 -0
  151. package/dist/module/workflow/service/workflow-meta.service.js +137 -0
  152. package/dist/module/workflow/service/workflow-meta.service.js.map +1 -0
  153. package/dist/module/workflow/service/workflow.service.d.ts +28 -5
  154. package/dist/module/workflow/service/workflow.service.js +108 -41
  155. package/dist/module/workflow/service/workflow.service.js.map +1 -1
  156. package/dist/module/workflow/workflow.module.js +82 -15
  157. package/dist/module/workflow/workflow.module.js.map +1 -1
  158. package/dist/tsconfig.build.tsbuildinfo +1 -1
  159. package/package.json +1 -1
  160. package/src/constant/global.constant.ts +3 -1
  161. package/src/module/enterprise/repository/school.repository.ts +23 -2
  162. package/src/module/filter/controller/filter.controller.ts +10 -4
  163. package/src/module/filter/dto/filter-request.dto.ts +1 -0
  164. package/src/module/filter/service/filter.service.ts +39 -5
  165. package/src/module/layout_preference/controller/layout_preference.controller.ts +6 -4
  166. package/src/module/layout_preference/entity/layout_preference.entity.ts +11 -0
  167. package/src/module/layout_preference/repository/layout_preference.repository.ts +6 -2
  168. package/src/module/layout_preference/service/layout_preference.service.ts +31 -6
  169. package/src/module/listmaster/entity/list-master-items.entity.ts +5 -5
  170. package/src/module/meta/controller/media.controller.ts +5 -7
  171. package/src/module/meta/entity/base-entity.entity.ts +1 -1
  172. package/src/module/module/controller/module-access.controller.ts +9 -4
  173. package/src/module/module/service/module-access.service.ts +15 -8
  174. package/src/module/workflow/controller/action-category.controller.ts +35 -0
  175. package/src/module/workflow/controller/action.controller.ts +73 -0
  176. package/src/module/workflow/controller/comm-template.controller.ts +32 -0
  177. package/src/module/workflow/controller/entity-modification.controller.ts +35 -0
  178. package/src/module/workflow/controller/stage-group.controller.ts +33 -0
  179. package/src/module/workflow/controller/stage.controller.ts +50 -0
  180. package/src/module/workflow/controller/task.controller.ts +57 -0
  181. package/src/module/workflow/controller/workflow-meta.controller.ts +76 -0
  182. package/src/module/workflow/controller/workflow.controller.ts +32 -12
  183. package/src/module/workflow/entity/action-category.entity.ts +3 -0
  184. package/src/module/workflow/entity/action-data.entity.ts +43 -0
  185. package/src/module/workflow/entity/action.entity.ts +18 -3
  186. package/src/module/workflow/entity/comm-template.entity.ts +18 -1
  187. package/src/module/workflow/entity/entity-modification.entity.ts +38 -0
  188. package/src/module/workflow/entity/stage-group.entity.ts +1 -1
  189. package/src/module/workflow/entity/stage-movement-data.entity.ts +12 -0
  190. package/src/module/workflow/entity/stage.entity.ts +4 -4
  191. package/src/module/workflow/entity/task-data.entity.ts +73 -0
  192. package/src/module/workflow/entity/template-attach-mapper.entity.ts +30 -0
  193. package/src/module/workflow/entity/workflow-level-mapping.entity.ts +18 -0
  194. package/src/module/workflow/entity/workflow.entity.ts +6 -0
  195. package/src/module/workflow/repository/action-data.repository.ts +93 -0
  196. package/src/module/workflow/repository/action.repository.ts +104 -0
  197. package/src/module/workflow/repository/comm-template.repository.ts +102 -0
  198. package/src/module/workflow/repository/stage-group.repository.ts +46 -0
  199. package/src/module/workflow/repository/stage-movement.repository.ts +219 -0
  200. package/src/module/workflow/repository/stage.repository.ts +47 -0
  201. package/src/module/workflow/repository/task.repository.ts +85 -0
  202. package/src/module/workflow/repository/workflow.repository.ts +40 -2
  203. package/src/module/workflow/service/action-category.service.ts +26 -1
  204. package/src/module/workflow/service/action-data.service.ts +45 -0
  205. package/src/module/workflow/service/action-template-mapping.service.ts +1 -1
  206. package/src/module/workflow/service/action.service.ts +279 -19
  207. package/src/module/workflow/service/comm-template.service.ts +90 -1
  208. package/src/module/workflow/service/entity-modification.service.ts +67 -0
  209. package/src/module/workflow/service/populate-workflow.service.ts +189 -0
  210. package/src/module/workflow/service/stage-group.service.ts +67 -2
  211. package/src/module/workflow/service/stage.service.ts +104 -28
  212. package/src/module/workflow/service/task.service.ts +95 -0
  213. package/src/module/workflow/service/workflow-list-master.service.ts +4 -4
  214. package/src/module/workflow/service/workflow-meta.service.ts +231 -0
  215. package/src/module/workflow/service/workflow.service.ts +181 -50
  216. package/src/module/workflow/workflow.module.ts +82 -15
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ActionDataService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const entity_service_impl_service_1 = require("../../meta/service/entity-service-impl.service");
15
+ const typeorm_1 = require("typeorm");
16
+ const action_data_repository_1 = require("../repository/action-data.repository");
17
+ let ActionDataService = class ActionDataService extends entity_service_impl_service_1.EntityServiceImpl {
18
+ constructor(dataSource, actionDataRepo) {
19
+ super();
20
+ this.dataSource = dataSource;
21
+ this.actionDataRepo = actionDataRepo;
22
+ }
23
+ async saveActionData(action, loggedInUser, mapped_entity_id, mapped_entity_type) {
24
+ return this.actionDataRepo.saveActionData(action, loggedInUser, mapped_entity_id, mapped_entity_type);
25
+ }
26
+ async updateActionStatus(loggedInUser, mapped_entity_type, mapped_entity_id, stage_id, action_id) {
27
+ return this.actionDataRepo.updateActionStatus(loggedInUser, mapped_entity_type, mapped_entity_id, stage_id, action_id);
28
+ }
29
+ };
30
+ exports.ActionDataService = ActionDataService;
31
+ exports.ActionDataService = ActionDataService = __decorate([
32
+ (0, common_1.Injectable)(),
33
+ __metadata("design:paramtypes", [typeorm_1.DataSource,
34
+ action_data_repository_1.ActionDataRepository])
35
+ ], ActionDataService);
36
+ //# sourceMappingURL=action-data.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-data.service.js","sourceRoot":"","sources":["../../../../src/module/workflow/service/action-data.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,gGAAwF;AAExF,qCAAqC;AACrC,iFAA4E;AAGrE,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,+CAAiB;IACtD,YACmB,UAAsB,EACtB,cAAoC;QAErD,KAAK,EAAE,CAAC;QAHS,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAsB;IAGvD,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,MAAW,EACX,YAAsB,EACtB,gBAAgB,EAChB,kBAAkB;QAElB,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CACvC,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,CACnB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,YAAsB,EACtB,kBAA0B,EAC1B,gBAAwB,EACxB,QAAgB,EAChB,SAAiB;QAEjB,OAAO,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAC3C,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,SAAS,CACV,CAAC;IACJ,CAAC;CACF,CAAA;AArCY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAGoB,oBAAU;QACN,6CAAoB;GAH5C,iBAAiB,CAqC7B"}
@@ -2,8 +2,26 @@ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
2
2
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
3
3
  import { UserData } from 'src/module/user/entity/user.entity';
4
4
  import { DataSource, EntityManager } from 'typeorm';
5
+ import { ActionRepository } from '../repository/action.repository';
5
6
  export declare class ActionService extends EntityServiceImpl {
6
7
  private readonly dataSource;
7
- constructor(dataSource: DataSource);
8
+ private readonly actionRepository;
9
+ constructor(dataSource: DataSource, actionRepository: ActionRepository);
10
+ getEntityData(entityType: string, id: number, loggedInUser: any): Promise<any>;
8
11
  createEntity(entityData: BaseEntity, loggedInUser: UserData | null, manager?: EntityManager | null, appcode?: string): Promise<any>;
12
+ updateEntity(entityData: BaseEntity, loggedInUser: UserData): Promise<any>;
13
+ deleteEntity(entityType: string, id: number, loggedInUser: UserData): Promise<any>;
14
+ getReasonCode(loggedInUser: UserData): Promise<any>;
15
+ defaultReasonCode(list_type: string, loggedInUser: UserData): Promise<any>;
16
+ getActions(loggedInUser: UserData, stage_id: number): Promise<any[]>;
17
+ getAction(loggedInUser: UserData, stage_id: number, mapped_entity_id: number, mapped_entity_type: string): Promise<{
18
+ value: any;
19
+ label: any;
20
+ modalName: any;
21
+ logo: any;
22
+ name: any;
23
+ is_current: any;
24
+ is_done: any;
25
+ is_mandatory: any;
26
+ }[]>;
9
27
  }
@@ -13,13 +13,23 @@ exports.ActionService = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const entity_service_impl_service_1 = require("../../meta/service/entity-service-impl.service");
15
15
  const typeorm_1 = require("typeorm");
16
+ const action_repository_1 = require("../repository/action.repository");
16
17
  let ActionService = class ActionService extends entity_service_impl_service_1.EntityServiceImpl {
17
- constructor(dataSource) {
18
+ constructor(dataSource, actionRepository) {
18
19
  super();
19
20
  this.dataSource = dataSource;
21
+ this.actionRepository = actionRepository;
22
+ }
23
+ async getEntityData(entityType, id, loggedInUser) {
24
+ const actionData = await super.getEntityData(entityType, id, loggedInUser);
25
+ if (!actionData) {
26
+ return null;
27
+ }
28
+ const template = await this.dataSource.query(`SELECT template_code FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id =
29
+ (SELECT id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM')`, [actionData.id]);
30
+ return { ...actionData, template: template.map((t) => t.template_code) };
20
31
  }
21
32
  async createEntity(entityData, loggedInUser, manager, appcode) {
22
- console.log('entityData', entityData);
23
33
  let actionData = entityData;
24
34
  let action = await super.createEntity(entityData, loggedInUser, manager, appcode);
25
35
  let stageActionMapping = {
@@ -31,13 +41,7 @@ let ActionService = class ActionService extends entity_service_impl_service_1.En
31
41
  if (Array.isArray(actionData.template) && actionData.template.length > 0) {
32
42
  const templates = actionData.template;
33
43
  for (let i = 0; i < templates.length; i++) {
34
- const templateId = templates[i];
35
- const templateResult = await this.dataSource.query(`SELECT code FROM cr_wf_comm_template WHERE id = ?`, [templateId]);
36
- if (templateResult.length === 0) {
37
- console.warn(`Template not found for id: ${templateId}`);
38
- continue;
39
- }
40
- const templateCode = templateResult[0].code;
44
+ const templateCode = templates[i];
41
45
  const actionTemplateMapping = {
42
46
  stg_act_mapping_id: stageActionMappingData.id,
43
47
  template_code: templateCode,
@@ -48,10 +52,155 @@ let ActionService = class ActionService extends entity_service_impl_service_1.En
48
52
  }
49
53
  return actionData;
50
54
  }
55
+ async updateEntity(entityData, loggedInUser) {
56
+ console.log('entityData', entityData);
57
+ const { template, stage_id, ...actionData } = entityData;
58
+ let action = await super.updateEntity({ ...actionData }, loggedInUser);
59
+ if (!action) {
60
+ throw new Error('Action not found or could not be updated');
61
+ }
62
+ const stageMapID = await this.dataSource.query(`SELECT id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM'`, [action.id]);
63
+ let stageActionMapping = {
64
+ action_id: action.id,
65
+ stage_id: stage_id,
66
+ entity_type: 'STGM',
67
+ id: stageMapID.length > 0 ? stageMapID[0].id : null,
68
+ };
69
+ let stageActionMappingData = await super.updateEntity(stageActionMapping, loggedInUser);
70
+ await this.dataSource.query(`DELETE FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id = ?`, [stageActionMappingData.id]);
71
+ if (Array.isArray(template) && template.length > 0) {
72
+ for (let i = 0; i < template.length; i++) {
73
+ const templateCode = template[i];
74
+ const actionTemplateMapping = {
75
+ stg_act_mapping_id: stageActionMappingData.id,
76
+ template_code: templateCode,
77
+ entity_type: 'ATMP',
78
+ };
79
+ await super.createEntity(actionTemplateMapping, loggedInUser);
80
+ }
81
+ }
82
+ return action;
83
+ }
84
+ async deleteEntity(entityType, id, loggedInUser) {
85
+ await this.dataSource.query(`DELETE FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id IN (SELECT
86
+ id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM')`, [id]);
87
+ await this.dataSource.query(`DELETE FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type ='STGM'`, [id]);
88
+ const deleteAction = await super.deleteEntity(entityType, id, loggedInUser);
89
+ return deleteAction;
90
+ }
91
+ async getReasonCode(loggedInUser) {
92
+ const { organization_id } = loggedInUser;
93
+ const result = await this.dataSource.query(`
94
+ SELECT name, type
95
+ FROM cr_list_master
96
+ WHERE organization_id = ? AND source = 'master'
97
+ `, [organization_id]);
98
+ const formatted = result.map((item) => ({
99
+ label: item.name,
100
+ value: item.type,
101
+ }));
102
+ return formatted;
103
+ }
104
+ async defaultReasonCode(list_type, loggedInUser) {
105
+ const { organization_id } = loggedInUser;
106
+ if (!list_type) {
107
+ throw new common_1.BadRequestException('list_type is required');
108
+ }
109
+ const result = await this.dataSource.query(`
110
+ SELECT name, id
111
+ FROM cr_list_master_items
112
+ WHERE listtype = ? AND organization_id = ?
113
+ `, [list_type, organization_id]);
114
+ return result.map((row) => ({
115
+ label: row.name,
116
+ value: row.id,
117
+ }));
118
+ }
119
+ async getActions(loggedInUser, stage_id) {
120
+ const { organization_id } = loggedInUser;
121
+ const stageActions = await this.dataSource.query(`
122
+ SELECT id, action_id
123
+ FROM cr_wf_stage_action_mapping
124
+ WHERE stage_id = ?
125
+ `, [stage_id]);
126
+ if (!stageActions?.length)
127
+ return [];
128
+ const actionIds = stageActions.map((sa) => sa.action_id);
129
+ const mappingIds = stageActions.map((sa) => sa.id);
130
+ const templateMappings = await this.dataSource.query(`
131
+ SELECT stg_act_mapping_id, template_code
132
+ FROM cr_wf_action_template_mapping
133
+ WHERE stg_act_mapping_id IN (${mappingIds.map(() => '?').join(',')})
134
+ `, mappingIds);
135
+ const templateCodes = templateMappings.map((tm) => tm.template_code);
136
+ const templateCodeToName = {};
137
+ if (templateCodes.length > 0) {
138
+ const templates = await this.dataSource
139
+ .createQueryBuilder()
140
+ .select(['t.code AS code', 't.name AS name'])
141
+ .from('cr_wf_comm_template', 't')
142
+ .where('t.code IN (:...codes)', { codes: templateCodes })
143
+ .andWhere('t.organization_id = :orgId', { orgId: organization_id })
144
+ .getRawMany();
145
+ templates.forEach((tpl) => {
146
+ templateCodeToName[tpl.code] = tpl.name;
147
+ });
148
+ }
149
+ const mappingIdToTemplates = {};
150
+ for (const tm of templateMappings) {
151
+ const mappingId = tm.stg_act_mapping_id;
152
+ const name = templateCodeToName[tm.template_code];
153
+ if (name) {
154
+ if (!mappingIdToTemplates[mappingId]) {
155
+ mappingIdToTemplates[mappingId] = [];
156
+ }
157
+ mappingIdToTemplates[mappingId].push(name);
158
+ }
159
+ }
160
+ const actionIdToTemplates = {};
161
+ for (const sa of stageActions) {
162
+ const mappingId = sa.id;
163
+ const templates = mappingIdToTemplates[mappingId];
164
+ if (templates?.length) {
165
+ if (!actionIdToTemplates[sa.action_id]) {
166
+ actionIdToTemplates[sa.action_id] = [];
167
+ }
168
+ actionIdToTemplates[sa.action_id].push(...templates);
169
+ }
170
+ }
171
+ const actionResults = await this.dataSource
172
+ .createQueryBuilder()
173
+ .select([
174
+ 'a.*',
175
+ 'ac.name AS action_category',
176
+ 'ar.name AS action_requirement',
177
+ ])
178
+ .from('cr_wf_action', 'a')
179
+ .leftJoin('cr_wf_action_category', 'ac', 'ac.id = a.action_category')
180
+ .leftJoin('cr_list_master_items', 'ar', `ar.id = a.action_requirement AND ar.listtype = 'ACRQ' AND ar.organization_id = :orgId`, { orgId: organization_id })
181
+ .where('a.organization_id = :orgId', { orgId: organization_id })
182
+ .andWhere('a.id IN (:...actionIds)', { actionIds })
183
+ .getRawMany();
184
+ const enrichedResult = actionResults.map((row) => {
185
+ const actionId = Number(row.id);
186
+ const templates = actionIdToTemplates[actionId] || [];
187
+ const uniqueTemplates = [...new Set(templates)];
188
+ return {
189
+ ...row,
190
+ template: uniqueTemplates.join(', '),
191
+ };
192
+ });
193
+ return enrichedResult;
194
+ }
195
+ async getAction(loggedInUser, stage_id, mapped_entity_id, mapped_entity_type) {
196
+ const { organization_id } = loggedInUser;
197
+ return this.actionRepository.getAction(organization_id, stage_id, mapped_entity_id, mapped_entity_type);
198
+ }
51
199
  };
52
200
  exports.ActionService = ActionService;
53
201
  exports.ActionService = ActionService = __decorate([
54
202
  (0, common_1.Injectable)(),
55
- __metadata("design:paramtypes", [typeorm_1.DataSource])
203
+ __metadata("design:paramtypes", [typeorm_1.DataSource,
204
+ action_repository_1.ActionRepository])
56
205
  ], ActionService);
57
206
  //# sourceMappingURL=action.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"action.service.js","sourceRoot":"","sources":["../../../../src/module/workflow/service/action.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,gGAAwF;AAExF,qCAAoD;AAG7C,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,+CAAiB;IAClD,YAA6B,UAAsB;QACjD,KAAK,EAAE,CAAC;QADmB,eAAU,GAAV,UAAU,CAAY;IAEnD,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,UAAsB,EACtB,YAA6B,EAC7B,OAA8B,EAC9B,OAAgB;QAEhB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAEtC,IAAI,UAAU,GAAG,UAAiB,CAAC;QAEnC,IAAI,MAAM,GAAG,MAAM,KAAK,CAAC,YAAY,CACnC,UAAU,EACV,YAAY,EACZ,OAAO,EACP,OAAO,CACR,CAAC;QAEF,IAAI,kBAAkB,GAAG;YACvB,SAAS,EAAE,MAAM,CAAC,EAAE;YACpB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,WAAW,EAAE,MAAM;SACb,CAAC;QAET,IAAI,sBAAsB,GAAG,MAAM,KAAK,CAAC,YAAY,CACnD,kBAAkB,EAClB,YAAY,EACZ,OAAO,EACP,OAAO,CACR,CAAC;QAEF,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzE,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC;YAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC1C,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;gBAGhC,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAChD,mDAAmD,EACnD,CAAC,UAAU,CAAC,CACb,CAAC;gBAEF,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAChC,OAAO,CAAC,IAAI,CAAC,8BAA8B,UAAU,EAAE,CAAC,CAAC;oBACzD,SAAS;gBACX,CAAC;gBAED,MAAM,YAAY,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAG5C,MAAM,qBAAqB,GAAG;oBAC5B,kBAAkB,EAAE,sBAAsB,CAAC,EAAE;oBAC7C,aAAa,EAAE,YAAY;oBAC3B,WAAW,EAAE,MAAM;iBACb,CAAC;gBAET,MAAM,KAAK,CAAC,YAAY,CACtB,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,OAAO,CACR,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF,CAAA;AAxEY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE8B,oBAAU;GADxC,aAAa,CAwEzB"}
1
+ {"version":3,"file":"action.service.js","sourceRoot":"","sources":["../../../../src/module/workflow/service/action.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AAEjE,gGAAwF;AAExF,qCAAgE;AAChE,uEAAmE;AAI5D,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,+CAAiB;IAClD,YACmB,UAAsB,EACtB,gBAAkC;QAEnD,KAAK,EAAE,CAAC;QAHS,eAAU,GAAV,UAAU,CAAY;QACtB,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;YAChC,MAAM,SAAS,GAAG,mBAAmB,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACtD,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;YAEhD,OAAO;gBACL,GAAG,GAAG;gBACN,QAAQ,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;aACrC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,SAAS,CACb,YAAsB,EACtB,QAAgB,EAChB,gBAAwB,EACxB,kBAA0B;QAE1B,MAAM,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC;QACzC,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,CACpC,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,CACnB,CAAC;IACJ,CAAC;CACF,CAAA;AA1UY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAGoB,oBAAU;QACJ,oCAAgB;GAH1C,aAAa,CA0UzB"}
@@ -1,3 +1,14 @@
1
+ import { CommTemplateRepository } from '../repository/comm-template.repository';
1
2
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
3
+ import { UserData } from 'src/module/user/entity/user.entity';
2
4
  export declare class CommTemplateService extends EntityServiceImpl {
5
+ private readonly commTemplateRepository;
6
+ constructor(commTemplateRepository: CommTemplateRepository);
7
+ createEntity(entityData: any, loggedInUser: any): Promise<any>;
8
+ updateEntity(entityData: any, loggedInUser: UserData): Promise<any>;
9
+ getEntityData(entityType: string, id: number, loggedInUser: any): Promise<any>;
10
+ getAllCommTemplate(entity_type: string, loggedInUser: any): Promise<{
11
+ value: string;
12
+ label: string;
13
+ }[]>;
3
14
  }
@@ -5,14 +5,72 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.CommTemplateService = void 0;
10
13
  const common_1 = require("@nestjs/common");
14
+ const comm_template_repository_1 = require("../repository/comm-template.repository");
11
15
  const entity_service_impl_service_1 = require("../../meta/service/entity-service-impl.service");
12
16
  let CommTemplateService = class CommTemplateService extends entity_service_impl_service_1.EntityServiceImpl {
17
+ constructor(commTemplateRepository) {
18
+ super();
19
+ this.commTemplateRepository = commTemplateRepository;
20
+ }
21
+ async createEntity(entityData, loggedInUser) {
22
+ const { attachments, ...templateData } = entityData;
23
+ const tempData = await super.createEntity(templateData, loggedInUser);
24
+ if (attachments && attachments.length > 0) {
25
+ const attachmentEntities = attachments.map((attachment) => ({
26
+ entity_type: templateData.entity_type,
27
+ template_id: tempData.id,
28
+ media_id: attachment,
29
+ organization_id: loggedInUser.organization_id,
30
+ appcode: loggedInUser.appcode,
31
+ level_id: loggedInUser.level_id,
32
+ level_type: loggedInUser.level_type,
33
+ }));
34
+ await this.commTemplateRepository.save(attachmentEntities);
35
+ }
36
+ return tempData;
37
+ }
38
+ async updateEntity(entityData, loggedInUser) {
39
+ const { attachments, ...templateData } = entityData;
40
+ const tempData = await super.updateEntity(templateData, loggedInUser);
41
+ await this.commTemplateRepository.delete({
42
+ template_id: tempData.id,
43
+ });
44
+ if (attachments && attachments.length > 0) {
45
+ const attachmentEntities = attachments.map((attachment) => ({
46
+ entity_type: templateData.entity_type,
47
+ template_id: tempData.id,
48
+ media_id: attachment,
49
+ organization_id: loggedInUser.organization_id,
50
+ appcode: loggedInUser.appcode,
51
+ level_id: loggedInUser.level_id,
52
+ level_type: loggedInUser.level_type,
53
+ }));
54
+ await this.commTemplateRepository.save(attachmentEntities);
55
+ }
56
+ return tempData;
57
+ }
58
+ async getEntityData(entityType, id, loggedInUser) {
59
+ const getTemplate = await this.commTemplateRepository.getTemplateByCode(entityType, id, loggedInUser);
60
+ return getTemplate;
61
+ }
62
+ async getAllCommTemplate(entity_type, loggedInUser) {
63
+ const commTemplateData = await this.commTemplateRepository.getAllCommTemplate(entity_type, loggedInUser);
64
+ const response = commTemplateData.map((item) => ({
65
+ value: item.code,
66
+ label: item.name,
67
+ }));
68
+ return response;
69
+ }
13
70
  };
14
71
  exports.CommTemplateService = CommTemplateService;
15
72
  exports.CommTemplateService = CommTemplateService = __decorate([
16
- (0, common_1.Injectable)()
73
+ (0, common_1.Injectable)(),
74
+ __metadata("design:paramtypes", [comm_template_repository_1.CommTemplateRepository])
17
75
  ], CommTemplateService);
18
76
  //# sourceMappingURL=comm-template.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"comm-template.service.js","sourceRoot":"","sources":["../../../../src/module/workflow/service/comm-template.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,gGAAwF;AAGjF,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,+CAAiB;CAAG,CAAA;AAAhD,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CAA6B"}
1
+ {"version":3,"file":"comm-template.service.js","sourceRoot":"","sources":["../../../../src/module/workflow/service/comm-template.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,qFAAgF;AAChF,gGAAwF;AAKjF,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,+CAAiB;IACxD,YAA6B,sBAA8C;QACzE,KAAK,EAAE,CAAC;QADmB,2BAAsB,GAAtB,sBAAsB,CAAwB;IAE3E,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,UAAe,EAAE,YAAiB;QACnD,MAAM,EAAE,WAAW,EAAE,GAAG,YAAY,EAAE,GAAG,UAAU,CAAC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YAAY,CAAC,eAAe;gBAC7C,OAAO,EAAE,YAAY,CAAC,OAAO;gBAC7B,QAAQ,EAAE,YAAY,CAAC,QAAQ;gBAC/B,UAAU,EAAE,YAAY,CAAC,UAAU;aACpC,CAAC,CAAC,CAAC;YAEJ,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC7D,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,UAAkB,EAClB,EAAU,EACV,YAAY;QAIZ,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CACrE,UAAU,EACV,EAAE,EACF,YAAY,CACb,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,WAAmB,EAAE,YAAY;QACxD,MAAM,gBAAgB,GACpB,MAAM,IAAI,CAAC,sBAAsB,CAAC,kBAAkB,CAClD,WAAW,EACX,YAAY,CACb,CAAC;QAEJ,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC/C,KAAK,EAAE,IAAI,CAAC,IAAI;YAChB,KAAK,EAAE,IAAI,CAAC,IAAI;SACjB,CAAC,CAAC,CAAC;QAEJ,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAtFY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAE0C,iDAAsB;GADhE,mBAAmB,CAsF/B"}
@@ -0,0 +1,8 @@
1
+ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
2
+ import { UserData } from 'src/module/user/entity/user.entity';
3
+ import { DataSource } from 'typeorm';
4
+ export declare class EntityModificationService extends EntityServiceImpl {
5
+ private readonly dataSource;
6
+ constructor(dataSource: DataSource);
7
+ logModification(modificationData: any, loggedInUser: UserData): Promise<any>;
8
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EntityModificationService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const entity_service_impl_service_1 = require("../../meta/service/entity-service-impl.service");
15
+ const typeorm_1 = require("typeorm");
16
+ let EntityModificationService = class EntityModificationService extends entity_service_impl_service_1.EntityServiceImpl {
17
+ constructor(dataSource) {
18
+ super();
19
+ this.dataSource = dataSource;
20
+ }
21
+ async logModification(modificationData, loggedInUser) {
22
+ const { mapped_entity_type, mapped_entity_id, attribute_key } = modificationData;
23
+ const { organization_id } = loggedInUser;
24
+ if (!mapped_entity_type || !mapped_entity_id || !attribute_key) {
25
+ throw new common_1.BadRequestException('Missing required modification data: mapped_entity_type, mapped_entity_id, or attribute_key');
26
+ }
27
+ const [entityMeta] = await this.dataSource.query(`
28
+ SELECT db_table_name
29
+ FROM cr_entity_master
30
+ WHERE mapped_entity_type = ? AND organization_id = ?
31
+ `, [mapped_entity_type, organization_id]);
32
+ if (!entityMeta || !entityMeta.db_table_name) {
33
+ throw new common_1.NotFoundException('Entity metadata not found in cr_entity_master');
34
+ }
35
+ const tableName = entityMeta.db_table_name;
36
+ const [entityRow] = await this.dataSource.query(`
37
+ SELECT * FROM ${tableName} WHERE id = ?
38
+ `, [mapped_entity_id]);
39
+ if (!entityRow) {
40
+ throw new common_1.NotFoundException(`No record found in ${tableName} with ID ${mapped_entity_id}`);
41
+ }
42
+ const currentAttributeValue = entityRow[attribute_key];
43
+ modificationData.current_value = currentAttributeValue;
44
+ return await super.createEntity(modificationData, loggedInUser);
45
+ }
46
+ };
47
+ exports.EntityModificationService = EntityModificationService;
48
+ exports.EntityModificationService = EntityModificationService = __decorate([
49
+ (0, common_1.Injectable)(),
50
+ __metadata("design:paramtypes", [typeorm_1.DataSource])
51
+ ], EntityModificationService);
52
+ //# sourceMappingURL=entity-modification.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-modification.service.js","sourceRoot":"","sources":["../../../../src/module/workflow/service/entity-modification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAIwB;AACxB,gGAAwF;AAExF,qCAAqC;AAG9B,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,+CAAiB;IAC9D,YAA6B,UAAsB;QACjD,KAAK,EAAE,CAAC;QADmB,eAAU,GAAV,UAAU,CAAY;IAEnD,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,gBAAqB,EAAE,YAAsB;QACjE,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,EAAE,GAC3D,gBAAgB,CAAC;QACnB,MAAM,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC;QAEzC,IAAI,CAAC,kBAAkB,IAAI,CAAC,gBAAgB,IAAI,CAAC,aAAa,EAAE,CAAC;YAC/D,MAAM,IAAI,4BAAmB,CAC3B,4FAA4F,CAC7F,CAAC;QACJ,CAAC;QAGD,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAC9C;;;;KAID,EACC,CAAC,kBAAkB,EAAE,eAAe,CAAC,CACtC,CAAC;QAEF,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YAC7C,MAAM,IAAI,0BAAiB,CACzB,+CAA+C,CAChD,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC;QAG3C,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAC7C;oBACc,SAAS;KACxB,EACC,CAAC,gBAAgB,CAAC,CACnB,CAAC;QAEF,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,0BAAiB,CACzB,sBAAsB,SAAS,YAAY,gBAAgB,EAAE,CAC9D,CAAC;QACJ,CAAC;QAGD,MAAM,qBAAqB,GAAG,SAAS,CAAC,aAAa,CAAC,CAAC;QAGvD,gBAAgB,CAAC,aAAa,GAAG,qBAAqB,CAAC;QAGvD,OAAO,MAAM,KAAK,CAAC,YAAY,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AAxDY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;qCAE8B,oBAAU;GADxC,yBAAyB,CAwDrC"}
@@ -0,0 +1,21 @@
1
+ import { DataSource } from 'typeorm';
2
+ import { PopulateMetaService } from './../../meta/service/populate-meta.service';
3
+ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
4
+ import { WorkflowService } from './workflow.service';
5
+ import { UserData } from 'src/module/user/entity/user.entity';
6
+ import { StageGroupService } from './stage-group.service';
7
+ import { StageService } from './stage.service';
8
+ import { ActionService } from './action.service';
9
+ export declare class PopulateWorkflowService extends EntityServiceImpl {
10
+ private readonly populateMetaService;
11
+ private readonly dataSource;
12
+ private readonly workflowService;
13
+ private readonly stageGroupService;
14
+ private readonly stageService;
15
+ private readonly actionService;
16
+ constructor(populateMetaService: PopulateMetaService, dataSource: DataSource, workflowService: WorkflowService, stageGroupService: StageGroupService, stageService: StageService, actionService: ActionService);
17
+ populateWorkflowData(organization_id: number, loggedInUser: UserData): Promise<{
18
+ message: string;
19
+ status: string;
20
+ }>;
21
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PopulateWorkflowService = void 0;
16
+ const typeorm_1 = require("typeorm");
17
+ const populate_meta_service_1 = require("./../../meta/service/populate-meta.service");
18
+ const common_1 = require("@nestjs/common");
19
+ const entity_service_impl_service_1 = require("../../meta/service/entity-service-impl.service");
20
+ const workflow_service_1 = require("./workflow.service");
21
+ const stage_group_service_1 = require("./stage-group.service");
22
+ const stage_service_1 = require("./stage.service");
23
+ const action_service_1 = require("./action.service");
24
+ let PopulateWorkflowService = class PopulateWorkflowService extends entity_service_impl_service_1.EntityServiceImpl {
25
+ constructor(populateMetaService, dataSource, workflowService, stageGroupService, stageService, actionService) {
26
+ super();
27
+ this.populateMetaService = populateMetaService;
28
+ this.dataSource = dataSource;
29
+ this.workflowService = workflowService;
30
+ this.stageGroupService = stageGroupService;
31
+ this.stageService = stageService;
32
+ this.actionService = actionService;
33
+ }
34
+ async populateWorkflowData(organization_id, loggedInUser) {
35
+ const workflowTables = [
36
+ { table: 'cr_workflow', entityType: 'WRFW', service: 'workflowService' },
37
+ {
38
+ table: 'cr_wf_stage_group',
39
+ entityType: 'STGP',
40
+ service: 'stageGroupService',
41
+ },
42
+ { table: 'cr_wf_stage', entityType: 'STG', service: 'stageService' },
43
+ { table: 'cr_wf_action', entityType: 'ACTN', service: 'actionService' },
44
+ ];
45
+ const getAllFactoryData = async (table) => this.dataSource.query(`SELECT * FROM ${table.table} WHERE organization_id = -1 AND level_type = 'ORG' AND level_id = -1`);
46
+ const factoryData = await Promise.all(workflowTables.map(getAllFactoryData));
47
+ const [workflows, stageGroups, stages, actions] = factoryData;
48
+ const workflowIdMap = {};
49
+ for (const row of workflows) {
50
+ const { id, ...rest } = row;
51
+ const newWf = await this.workflowService.createEntity({
52
+ ...rest,
53
+ organization_id,
54
+ level_id: organization_id,
55
+ entity_type: 'WRFW',
56
+ }, loggedInUser);
57
+ workflowIdMap[id] = newWf.id;
58
+ }
59
+ const stageGroupIdMap = {};
60
+ const stageGroupToWorkflowMap = {};
61
+ for (const row of stageGroups) {
62
+ const { id, workflow_id, ...rest } = row;
63
+ const newSg = await this.stageGroupService.createEntity({
64
+ ...rest,
65
+ workflow_id: workflowIdMap[workflow_id],
66
+ organization_id,
67
+ level_id: organization_id,
68
+ entity_type: 'STGP',
69
+ }, loggedInUser);
70
+ stageGroupIdMap[id] = newSg.id;
71
+ stageGroupToWorkflowMap[id] = workflow_id;
72
+ }
73
+ const stageIdMap = {};
74
+ const stageToStageGroupMap = {};
75
+ for (const row of stages) {
76
+ const { id, stage_group_id, ...rest } = row;
77
+ const originalWorkflowId = stageGroupToWorkflowMap[stage_group_id];
78
+ const newStage = await this.stageService.createEntity({
79
+ ...rest,
80
+ stage_group_id: stageGroupIdMap[stage_group_id],
81
+ workflow_id: workflowIdMap[originalWorkflowId],
82
+ organization_id,
83
+ level_id: organization_id,
84
+ entity_type: 'STG',
85
+ }, loggedInUser);
86
+ stageIdMap[id] = newStage.id;
87
+ stageToStageGroupMap[id] = stage_group_id;
88
+ }
89
+ for (const row of actions) {
90
+ const { id, stage_id, created_date, modified_date, ...rest } = row;
91
+ const newStageId = stageIdMap[stage_id];
92
+ const oldStageGroupId = stageToStageGroupMap[stage_id];
93
+ const oldWorkflowId = stageGroupToWorkflowMap[oldStageGroupId];
94
+ const newWorkflowId = workflowIdMap[oldWorkflowId];
95
+ await this.actionService.createEntity({
96
+ ...rest,
97
+ stage_id: newStageId,
98
+ workflow_id: newWorkflowId,
99
+ organization_id,
100
+ level_id: organization_id,
101
+ entity_type: 'ACTN',
102
+ }, loggedInUser);
103
+ }
104
+ return {
105
+ message: 'Workflow data populated successfully',
106
+ status: 'success',
107
+ };
108
+ }
109
+ };
110
+ exports.PopulateWorkflowService = PopulateWorkflowService;
111
+ exports.PopulateWorkflowService = PopulateWorkflowService = __decorate([
112
+ (0, common_1.Injectable)(),
113
+ __param(2, (0, common_1.Inject)('WorkflowService')),
114
+ __param(3, (0, common_1.Inject)('StageGroupService')),
115
+ __param(4, (0, common_1.Inject)('StageService')),
116
+ __param(5, (0, common_1.Inject)('ActionService')),
117
+ __metadata("design:paramtypes", [populate_meta_service_1.PopulateMetaService,
118
+ typeorm_1.DataSource,
119
+ workflow_service_1.WorkflowService,
120
+ stage_group_service_1.StageGroupService,
121
+ stage_service_1.StageService,
122
+ action_service_1.ActionService])
123
+ ], PopulateWorkflowService);
124
+ //# sourceMappingURL=populate-workflow.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"populate-workflow.service.js","sourceRoot":"","sources":["../../../../src/module/workflow/service/populate-workflow.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qCAAqC;AACrC,sFAAiF;AACjF,2CAAoD;AACpD,gGAAwF;AACxF,yDAAqD;AAErD,+DAA0D;AAC1D,mDAA+C;AAC/C,qDAAiD;AAG1C,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,+CAAiB;IAC5D,YACmB,mBAAwC,EACxC,UAAsB,EAEtB,eAAgC,EAEhC,iBAAoC,EAEpC,YAA0B,EAE1B,aAA4B;QAE7C,KAAK,EAAE,CAAC;QAX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ityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
2
+ import { StageGroupRepository } from '../repository/stage-group.repository';
3
+ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
4
+ import { UserData } from 'src/module/user/entity/user.entity';
5
+ import { StageService } from './stage.service';
6
+ import { DataSource } from 'typeorm';
2
7
  export declare class StageGroupService extends EntityServiceImpl {
8
+ private readonly stageGroupRepository;
9
+ private readonly stageService;
10
+ private readonly dataSource;
11
+ constructor(stageGroupRepository: StageGroupRepository, stageService: StageService, dataSource: DataSource);
12
+ getAllStageGroup(workflow_id: number, level_id: string, level_type: string): Promise<import("../entity/stage-group.entity").StageGroup[]>;
13
+ updateEntity(entityData: BaseEntity, loggedInUser: UserData): Promise<any>;
14
+ getEntityData(entityType: string, id: number, loggedInUser?: UserData): Promise<BaseEntity | null>;
15
+ deleteEntity(entityType: string, id: number, loggedInUser: UserData): Promise<any>;
3
16
  }