@acorex/modules 20.2.0-next.1 → 20.2.0-next.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.
Files changed (61) hide show
  1. package/auth/index.d.ts +58 -4
  2. package/conversation/README.md +1 -1
  3. package/conversation/index.d.ts +117 -71
  4. package/fesm2022/{acorex-modules-auth-acorex-modules-auth-y6rICHrT.mjs → acorex-modules-auth-acorex-modules-auth-BxqN76H7.mjs} +232 -84
  5. package/fesm2022/acorex-modules-auth-acorex-modules-auth-BxqN76H7.mjs.map +1 -0
  6. package/fesm2022/{acorex-modules-auth-app-chooser.component-Cpy0VN6n.mjs → acorex-modules-auth-app-chooser.component-5FbgqbVo.mjs} +6 -4
  7. package/fesm2022/acorex-modules-auth-app-chooser.component-5FbgqbVo.mjs.map +1 -0
  8. package/fesm2022/{acorex-modules-auth-login.module-ZEX4NMuJ.mjs → acorex-modules-auth-login.module-CmMM4TpQ.mjs} +4 -4
  9. package/fesm2022/{acorex-modules-auth-login.module-ZEX4NMuJ.mjs.map → acorex-modules-auth-login.module-CmMM4TpQ.mjs.map} +1 -1
  10. package/fesm2022/{acorex-modules-auth-master.layout-D-lIn4Pl.mjs → acorex-modules-auth-master.layout-eX5-7AeO.mjs} +2 -2
  11. package/fesm2022/{acorex-modules-auth-master.layout-D-lIn4Pl.mjs.map → acorex-modules-auth-master.layout-eX5-7AeO.mjs.map} +1 -1
  12. package/fesm2022/acorex-modules-auth-oauth-callback.component-C9s-5c7F.mjs +97 -0
  13. package/fesm2022/acorex-modules-auth-oauth-callback.component-C9s-5c7F.mjs.map +1 -0
  14. package/fesm2022/{acorex-modules-auth-password.component-CafZfqKe.mjs → acorex-modules-auth-password.component-CDrYHh1x.mjs} +7 -7
  15. package/fesm2022/{acorex-modules-auth-password.component-CafZfqKe.mjs.map → acorex-modules-auth-password.component-CDrYHh1x.mjs.map} +1 -1
  16. package/fesm2022/acorex-modules-auth-password.component-r_Lh8oGN.mjs +226 -0
  17. package/fesm2022/acorex-modules-auth-password.component-r_Lh8oGN.mjs.map +1 -0
  18. package/fesm2022/{acorex-modules-auth-routes-D9-qfC3V.mjs → acorex-modules-auth-routes-CMdsDZud.mjs} +2 -2
  19. package/fesm2022/{acorex-modules-auth-routes-D9-qfC3V.mjs.map → acorex-modules-auth-routes-CMdsDZud.mjs.map} +1 -1
  20. package/fesm2022/{acorex-modules-auth-tenant-chooser.component-B1aE-TOD.mjs → acorex-modules-auth-tenant-chooser.component-BdK5T-8X.mjs} +19 -10
  21. package/fesm2022/acorex-modules-auth-tenant-chooser.component-BdK5T-8X.mjs.map +1 -0
  22. package/fesm2022/{acorex-modules-auth-two-factor-code.component-BglerlU-.mjs → acorex-modules-auth-two-factor-code.component-DSWd06bn.mjs} +6 -6
  23. package/fesm2022/{acorex-modules-auth-two-factor-code.component-BglerlU-.mjs.map → acorex-modules-auth-two-factor-code.component-DSWd06bn.mjs.map} +1 -1
  24. package/fesm2022/{acorex-modules-auth-two-factor.module-D3N2XyOH.mjs → acorex-modules-auth-two-factor.module-YV9pDOnB.mjs} +3 -3
  25. package/fesm2022/{acorex-modules-auth-two-factor.module-D3N2XyOH.mjs.map → acorex-modules-auth-two-factor.module-YV9pDOnB.mjs.map} +1 -1
  26. package/fesm2022/acorex-modules-auth-user-sessions.component-KI9dYs78.mjs +135 -0
  27. package/fesm2022/acorex-modules-auth-user-sessions.component-KI9dYs78.mjs.map +1 -0
  28. package/fesm2022/acorex-modules-auth.mjs +1 -1
  29. package/fesm2022/acorex-modules-conversation.mjs +282 -204
  30. package/fesm2022/acorex-modules-conversation.mjs.map +1 -1
  31. package/fesm2022/acorex-modules-notification-management.mjs +109 -28
  32. package/fesm2022/acorex-modules-notification-management.mjs.map +1 -1
  33. package/fesm2022/acorex-modules-organization-management-branch.entity-CHp5WtIF.mjs.map +1 -1
  34. package/fesm2022/acorex-modules-organization-management-department.entity-BxCyXNtv.mjs.map +1 -1
  35. package/fesm2022/acorex-modules-organization-management-division.entity-DzQT2jpz.mjs.map +1 -1
  36. package/fesm2022/acorex-modules-organization-management-employee.entity-CSY_U9Bl.mjs.map +1 -1
  37. package/fesm2022/acorex-modules-organization-management-employment-type.entity-h9Hua7Xe.mjs.map +1 -1
  38. package/fesm2022/acorex-modules-organization-management-position-category.entity-CIir9UMg.mjs.map +1 -1
  39. package/fesm2022/acorex-modules-organization-management-position.entity-BpkjUsoZ.mjs.map +1 -1
  40. package/fesm2022/acorex-modules-organization-management-responsibility-category.entity-tJFpEylO.mjs.map +1 -1
  41. package/fesm2022/acorex-modules-organization-management-responsibility.entity-DmKSoxpL.mjs.map +1 -1
  42. package/fesm2022/acorex-modules-organization-management-role-category.entity-CAljzQcH.mjs.map +1 -1
  43. package/fesm2022/acorex-modules-organization-management-skill-category.entity-iIbc-pjJ.mjs.map +1 -1
  44. package/fesm2022/acorex-modules-organization-management-skill.entity-DoAsCzm9.mjs.map +1 -1
  45. package/fesm2022/acorex-modules-organization-management-team.entity-DMCfAZsr.mjs.map +1 -1
  46. package/fesm2022/acorex-modules-security-management.mjs +753 -217
  47. package/fesm2022/acorex-modules-security-management.mjs.map +1 -1
  48. package/fesm2022/{acorex-modules-workflow-management-acorex-modules-workflow-management-enYapFRb.mjs → acorex-modules-workflow-management-acorex-modules-workflow-management-DnSdOSmj.mjs} +6 -6
  49. package/fesm2022/{acorex-modules-workflow-management-acorex-modules-workflow-management-enYapFRb.mjs.map → acorex-modules-workflow-management-acorex-modules-workflow-management-DnSdOSmj.mjs.map} +1 -1
  50. package/fesm2022/{acorex-modules-workflow-management-task-board.page-CPL7HwN4.mjs → acorex-modules-workflow-management-task-board.page-Bzu4j4VW.mjs} +2 -2
  51. package/fesm2022/{acorex-modules-workflow-management-task-board.page-CPL7HwN4.mjs.map → acorex-modules-workflow-management-task-board.page-Bzu4j4VW.mjs.map} +1 -1
  52. package/fesm2022/acorex-modules-workflow-management.mjs +1 -1
  53. package/notification-management/index.d.ts +69 -59
  54. package/package.json +13 -13
  55. package/security-management/index.d.ts +13 -4
  56. package/workflow-management/index.d.ts +2 -2
  57. package/fesm2022/acorex-modules-auth-acorex-modules-auth-y6rICHrT.mjs.map +0 -1
  58. package/fesm2022/acorex-modules-auth-app-chooser.component-Cpy0VN6n.mjs.map +0 -1
  59. package/fesm2022/acorex-modules-auth-password.component-DLCb0_6e.mjs +0 -134
  60. package/fesm2022/acorex-modules-auth-password.component-DLCb0_6e.mjs.map +0 -1
  61. package/fesm2022/acorex-modules-auth-tenant-chooser.component-B1aE-TOD.mjs.map +0 -1
@@ -60,9 +60,9 @@ import { trigger, transition, style, animate } from '@angular/animations';
60
60
  import * as i10 from '@angular/forms';
61
61
  import { FormsModule } from '@angular/forms';
62
62
  import { Subject, filter, startWith } from 'rxjs';
63
+ import { AXMUsersEntityService } from '@acorex/modules/security-management';
63
64
  import { AXToastService } from '@acorex/components/toast';
64
65
  import { DomSanitizer } from '@angular/platform-browser';
65
- import { AXMUsersEntityService } from '@acorex/modules/security-management';
66
66
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
67
67
  import { AXBasePageComponent } from '@acorex/components/page';
68
68
  import { AXDomChangeDirective } from '@acorex/cdk/dom';
@@ -939,98 +939,54 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
939
939
  type: Injectable
940
940
  }] });
941
941
 
942
+ class AXMCommentRealtimeService {
943
+ }
944
+ class AXMCommentRealtimeServiceImpl extends AXMCommentRealtimeService {
945
+ constructor() {
946
+ super(...arguments);
947
+ this._comment$ = new Subject();
948
+ this.comment$ = this._comment$.asObservable();
949
+ this._thread$ = new Subject();
950
+ this.thread$ = this._thread$.asObservable();
951
+ }
952
+ notifyComment(event) {
953
+ this._comment$.next(event);
954
+ }
955
+ notifyThread(event) {
956
+ this._thread$.next(event);
957
+ }
958
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentRealtimeServiceImpl, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
959
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentRealtimeServiceImpl, providedIn: 'root' }); }
960
+ }
961
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentRealtimeServiceImpl, decorators: [{
962
+ type: Injectable,
963
+ args: [{
964
+ providedIn: 'root',
965
+ }]
966
+ }] });
967
+
942
968
  //#region ---- Abstract Comment Service ----
943
969
  class AXMCommentService {
944
970
  }
945
971
  //#endregion
946
972
  class AXMCommentServiceImpl {
947
973
  constructor() {
948
- //#region ---- Dependencies ----
949
974
  this.roomService = inject(AXMRoomService);
950
975
  this.messageService = inject(AXMMessageService);
951
- this.sessionService = inject(AXPSessionService);
952
- this.usersService = inject(AXMUsersEntityService);
953
976
  this.filterService = inject(AXPFilterOperatorMiddlewareService);
954
- //#endregion
955
- //#region ---- Observables ----
956
- this._commentAdded$ = new Subject();
957
- this.commentAdded$ = this._commentAdded$.asObservable();
958
- this._commentRemoved$ = new Subject();
959
- this.commentRemoved$ = this._commentRemoved$.asObservable();
960
- this._commentUpdated$ = new Subject();
961
- this.commentUpdated$ = this._commentUpdated$.asObservable();
962
- this._threadAdded$ = new Subject();
963
- this.threadAdded$ = this._threadAdded$.asObservable();
964
- this._threadRemoved$ = new Subject();
965
- this.threadRemoved$ = this._threadRemoved$.asObservable();
966
- }
967
- //#endregion
968
- //#region ---- Helper Methods ----
969
- getCurrentUser() {
970
- const user = this.sessionService.user;
971
- if (!user) {
972
- throw new Error('No authenticated user found.');
973
- }
974
- return {
975
- id: user.id,
976
- type: 'user',
977
- };
978
977
  }
979
- async getUserInfo(userId) {
980
- try {
981
- await this.usersService.getOne(userId); // check if user exists
982
- return { id: userId, type: 'user' };
983
- }
984
- catch {
985
- throw new Error(`User with ID ${userId} not found`);
986
- }
987
- }
988
- formatComment(message, depth = 0) {
989
- return {
990
- ...message,
991
- depth,
992
- replies: [],
993
- replyCount: 0,
994
- };
995
- }
996
- buildCommentTree(comments) {
997
- const commentMap = new Map(comments.map((c) => [c.id, c]));
998
- const tree = [];
999
- comments.forEach((comment) => {
1000
- if (comment.replyId && commentMap.has(comment.replyId)) {
1001
- const parent = commentMap.get(comment.replyId);
1002
- parent.replies.push(comment);
1003
- comment.depth = parent.depth + 1;
1004
- }
1005
- else {
1006
- tree.push(comment);
1007
- }
1008
- });
1009
- commentMap.forEach((comment) => {
1010
- comment.replyCount = comment.replies.length;
1011
- });
1012
- return tree;
1013
- }
1014
- //#endregion
1015
- //#region ---- Comment Thread Service Implementation ----
1016
- async createThread(entityRef, topic, title) {
1017
- const currentUser = this.getCurrentUser();
978
+ async createThread(creatorUser, entityRef, topic, title) {
1018
979
  const room = {
1019
980
  type: 'comment',
1020
981
  topic: topic,
1021
982
  title: title || `Comments for ${entityRef.type}#${entityRef.id}`,
1022
- members: [currentUser],
983
+ members: [creatorUser],
1023
984
  entityRef: entityRef,
1024
- createdBy: currentUser.id,
985
+ createdBy: creatorUser.id,
1025
986
  createdAt: new Date(),
1026
987
  };
1027
- await this.roomService.insertOne(room);
1028
- const newThread = await this.getThread(entityRef, topic);
1029
- if (!newThread) {
1030
- throw new Error('Failed to create or retrieve thread after creation.');
1031
- }
1032
- this._threadAdded$.next(newThread);
1033
- return newThread;
988
+ const newRoomId = await this.roomService.insertOne(room);
989
+ return this.roomService.getOne(newRoomId);
1034
990
  }
1035
991
  async getThread(entityRef, topic) {
1036
992
  const { items } = await this.roomService.query({
@@ -1057,16 +1013,7 @@ class AXMCommentServiceImpl {
1057
1013
  ],
1058
1014
  },
1059
1015
  });
1060
- const room = items[0];
1061
- if (!room) {
1062
- return null;
1063
- }
1064
- const comments = await this.getComments(room.id, true);
1065
- return {
1066
- ...room,
1067
- comments,
1068
- commentCount: comments.length,
1069
- };
1016
+ return items[0] || null;
1070
1017
  }
1071
1018
  async listThreads(entityRef, topic) {
1072
1019
  const { items } = await this.roomService.query({
@@ -1093,33 +1040,17 @@ class AXMCommentServiceImpl {
1093
1040
  ],
1094
1041
  },
1095
1042
  });
1096
- const threads = await Promise.all(items.map((room) => this.getThread(room.entityRef, room.topic)));
1097
- return threads.filter((t) => t !== null);
1043
+ return items;
1098
1044
  }
1099
- async updateThread(entityRef, topic, data) {
1100
- const thread = await this.getThread(entityRef, topic);
1101
- if (!thread) {
1102
- throw new Error(`Thread for entity ${entityRef.type}#${entityRef.id} not found.`);
1103
- }
1104
- await this.roomService.updateOne(thread.id, data);
1105
- const updatedThread = await this.getThread(entityRef, topic);
1106
- if (!updatedThread) {
1107
- throw new Error('Failed to retrieve thread after update.');
1108
- }
1109
- return updatedThread;
1045
+ async updateThread(threadId, data) {
1046
+ await this.roomService.updateOne(threadId, data);
1047
+ return this.roomService.getOne(threadId);
1110
1048
  }
1111
- async deleteThread(entityRef, topic) {
1112
- const thread = await this.getThread(entityRef, topic);
1113
- if (thread) {
1114
- await this.roomService.deleteOne(thread.id);
1115
- this._threadRemoved$.next(thread.id);
1116
- }
1049
+ async deleteThread(threadId) {
1050
+ await this.roomService.deleteOne(threadId);
1117
1051
  return true;
1118
1052
  }
1119
- //#endregion
1120
- //#region ---- Comment Service Implementation ----
1121
- async addComment(threadId, content, parentCommentId, contentType = 'text', userId) {
1122
- const author = userId ? await this.getUserInfo(userId) : this.getCurrentUser();
1053
+ async addComment(threadId, content, author, parentCommentId, contentType = 'text') {
1123
1054
  const messageContent = { content, contentType };
1124
1055
  const message = {
1125
1056
  roomId: threadId,
@@ -1132,96 +1063,232 @@ class AXMCommentServiceImpl {
1132
1063
  createdAt: new Date(),
1133
1064
  };
1134
1065
  const messageId = await this.messageService.insertOne(message);
1135
- const newComment = await this.getComment(messageId);
1136
- this._commentAdded$.next(newComment);
1137
- return newComment;
1066
+ return this.messageService.getOne(messageId);
1138
1067
  }
1139
- async getComments(threadId, nested = true) {
1068
+ async getComments(threadId) {
1140
1069
  const { items } = await this.messageService.query({
1141
1070
  skip: 0,
1142
1071
  filter: { field: 'roomId', value: threadId, operator: this.filterService.getOperator('equal') },
1143
1072
  sort: [{ field: 'createdAt', dir: 'asc' }],
1144
- take: 500, // Assuming a reasonable limit for comments per thread
1073
+ take: 500,
1145
1074
  });
1146
- const formattedComments = items.map((c) => this.formatComment(c));
1147
- if (nested) {
1148
- return this.buildCommentTree(formattedComments);
1149
- }
1150
- return formattedComments;
1075
+ return items;
1151
1076
  }
1152
1077
  async getComment(commentId) {
1153
- const message = await this.messageService.getOne(commentId);
1154
- return this.formatComment(message);
1078
+ return this.messageService.getOne(commentId);
1155
1079
  }
1156
- async editComment(commentId, content, contentType = 'text') {
1080
+ async editComment(commentId, content, editor, contentType = 'text') {
1157
1081
  const messageContent = { content, contentType };
1158
1082
  await this.messageService.updateOne(commentId, {
1159
1083
  message: messageContent,
1160
1084
  updatedAt: new Date(),
1161
- updatedBy: this.getCurrentUser().id,
1085
+ updatedBy: editor.id,
1162
1086
  });
1163
- const updatedComment = await this.getComment(commentId);
1164
- this._commentUpdated$.next(updatedComment);
1165
- return updatedComment;
1087
+ return this.messageService.getOne(commentId);
1166
1088
  }
1167
1089
  async deleteComment(commentId) {
1168
- // Note: This is a hard delete. Soft delete might be preferable.
1169
1090
  await this.messageService.deleteOne(commentId);
1170
- this._commentRemoved$.next(commentId);
1171
1091
  return true;
1172
1092
  }
1173
- //#endregion
1174
- //#region ---- Comment Reaction Service Implementation ----
1093
+ async updateReactions(commentId, reactions) {
1094
+ await this.messageService.updateOne(commentId, { reactions });
1095
+ return this.messageService.getOne(commentId);
1096
+ }
1097
+ async getReactions(commentId) {
1098
+ const comment = await this.messageService.getOne(commentId);
1099
+ return comment.reactions || [];
1100
+ }
1101
+ async pinComment(commentId, isPinned) {
1102
+ await this.messageService.updateOne(commentId, { isPinned });
1103
+ return this.messageService.getOne(commentId);
1104
+ }
1105
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentServiceImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1106
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentServiceImpl, providedIn: 'root' }); }
1107
+ }
1108
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentServiceImpl, decorators: [{
1109
+ type: Injectable,
1110
+ args: [{
1111
+ providedIn: 'root',
1112
+ }]
1113
+ }] });
1114
+
1115
+ class AXMCommentManagementService {
1116
+ constructor() {
1117
+ this.commentImplService = inject(AXMCommentServiceImpl);
1118
+ this.sessionService = inject(AXPSessionService);
1119
+ this.usersService = inject(AXMUsersEntityService);
1120
+ this.realtimeService = inject(AXMCommentRealtimeService);
1121
+ }
1122
+ getCurrentUser() {
1123
+ const user = this.sessionService.user;
1124
+ if (!user) {
1125
+ throw new Error('No authenticated user found.');
1126
+ }
1127
+ return {
1128
+ id: user.id,
1129
+ type: 'user',
1130
+ };
1131
+ }
1132
+ async getUserInfo(userId) {
1133
+ try {
1134
+ await this.usersService.getOne(userId);
1135
+ return { id: userId, type: 'user' };
1136
+ }
1137
+ catch {
1138
+ throw new Error(`User with ID ${userId} not found`);
1139
+ }
1140
+ }
1141
+ formatComment(message, depth = 0) {
1142
+ return {
1143
+ ...message,
1144
+ depth,
1145
+ replies: [],
1146
+ replyCount: 0,
1147
+ };
1148
+ }
1149
+ buildCommentTree(comments) {
1150
+ const commentMap = new Map(comments.map((c) => [c.id, c]));
1151
+ const tree = [];
1152
+ comments.forEach((comment) => {
1153
+ if (comment.replyId && commentMap.has(comment.replyId)) {
1154
+ const parent = commentMap.get(comment.replyId);
1155
+ parent.replies.push(comment);
1156
+ comment.depth = (parent.depth ?? 0) + 1;
1157
+ }
1158
+ else {
1159
+ tree.push(comment);
1160
+ }
1161
+ });
1162
+ commentMap.forEach((comment) => {
1163
+ comment.replyCount = comment.replies.length;
1164
+ });
1165
+ return tree;
1166
+ }
1167
+ async formatThread(room) {
1168
+ const comments = await this.getComments(room.id, true);
1169
+ return {
1170
+ ...room,
1171
+ comments,
1172
+ commentCount: comments.length,
1173
+ };
1174
+ }
1175
+ async createThread(entityRef, topic, title) {
1176
+ const currentUser = this.getCurrentUser();
1177
+ const newRoom = await this.commentImplService.createThread(currentUser, entityRef, topic, title);
1178
+ const newThread = await this.formatThread(newRoom);
1179
+ this.realtimeService.notifyThread({ type: 'add', payload: newThread });
1180
+ return newThread;
1181
+ }
1182
+ async getThread(entityRef, topic) {
1183
+ const room = await this.commentImplService.getThread(entityRef, topic);
1184
+ if (!room) {
1185
+ return null;
1186
+ }
1187
+ return this.formatThread(room);
1188
+ }
1189
+ async listThreads(entityRef, topic) {
1190
+ const rooms = await this.commentImplService.listThreads(entityRef, topic);
1191
+ return Promise.all(rooms.map((room) => this.formatThread(room)));
1192
+ }
1193
+ async updateThread(entityRef, topic, data) {
1194
+ const thread = await this.getThread(entityRef, topic);
1195
+ if (!thread) {
1196
+ throw new Error(`Thread for entity ${entityRef.type}#${entityRef.id} not found.`);
1197
+ }
1198
+ const updatedRoom = await this.commentImplService.updateThread(thread.id, data);
1199
+ const updatedThread = await this.formatThread(updatedRoom);
1200
+ this.realtimeService.notifyThread({ type: 'update', payload: updatedThread });
1201
+ return updatedThread;
1202
+ }
1203
+ async deleteThread(entityRef, topic) {
1204
+ const thread = await this.getThread(entityRef, topic);
1205
+ if (thread) {
1206
+ await this.commentImplService.deleteThread(thread.id);
1207
+ this.realtimeService.notifyThread({ type: 'remove', payload: thread.id });
1208
+ return true;
1209
+ }
1210
+ return false;
1211
+ }
1212
+ async addComment(threadId, content, parentCommentId, contentType = 'text', userId) {
1213
+ const author = userId ? await this.getUserInfo(userId) : this.getCurrentUser();
1214
+ const rawComment = await this.commentImplService.addComment(threadId, content, author, parentCommentId, contentType);
1215
+ const formattedComment = this.formatComment(rawComment);
1216
+ this.realtimeService.notifyComment({ type: 'add', payload: formattedComment });
1217
+ return formattedComment;
1218
+ }
1219
+ async getComments(threadId, nested) {
1220
+ const rawComments = await this.commentImplService.getComments(threadId);
1221
+ const formattedComments = rawComments.map((c) => this.formatComment(c));
1222
+ if (nested) {
1223
+ return this.buildCommentTree(formattedComments);
1224
+ }
1225
+ return formattedComments;
1226
+ }
1227
+ async getComment(commentId) {
1228
+ const rawComment = await this.commentImplService.getComment(commentId);
1229
+ return this.formatComment(rawComment);
1230
+ }
1231
+ async editComment(commentId, content, contentType = 'text') {
1232
+ const editor = this.getCurrentUser();
1233
+ const rawComment = await this.commentImplService.editComment(commentId, content, editor, contentType);
1234
+ const formattedComment = this.formatComment(rawComment);
1235
+ this.realtimeService.notifyComment({ type: 'update', payload: formattedComment });
1236
+ return formattedComment;
1237
+ }
1238
+ async deleteComment(commentId) {
1239
+ const result = await this.commentImplService.deleteComment(commentId);
1240
+ if (result) {
1241
+ this.realtimeService.notifyComment({ type: 'remove', payload: commentId });
1242
+ }
1243
+ return result;
1244
+ }
1175
1245
  async addReaction(commentId, type) {
1176
1246
  const author = this.getCurrentUser();
1177
- const comment = await this.messageService.getOne(commentId);
1247
+ const comment = await this.commentImplService.getComment(commentId);
1178
1248
  const reactions = comment.reactions || [];
1179
1249
  if (reactions.some((r) => r.author.id === author.id && r.type === type)) {
1180
1250
  return this.formatComment(comment);
1181
1251
  }
1182
1252
  const updatedReactions = [...reactions, { author, type }];
1183
- await this.messageService.updateOne(commentId, { reactions: updatedReactions });
1184
- const updatedComment = await this.getComment(commentId);
1185
- this._commentUpdated$.next(updatedComment);
1186
- return updatedComment;
1253
+ const rawComment = await this.commentImplService.updateReactions(commentId, updatedReactions);
1254
+ const formattedComment = this.formatComment(rawComment);
1255
+ this.realtimeService.notifyComment({ type: 'update', payload: formattedComment });
1256
+ return formattedComment;
1187
1257
  }
1188
1258
  async removeReaction(commentId, type) {
1189
1259
  const author = this.getCurrentUser();
1190
- const comment = await this.messageService.getOne(commentId);
1260
+ const comment = await this.commentImplService.getComment(commentId);
1191
1261
  const updatedReactions = (comment.reactions || []).filter((r) => !(r.author.id === author.id && r.type === type));
1192
- await this.messageService.updateOne(commentId, { reactions: updatedReactions });
1193
- const updatedComment = await this.getComment(commentId);
1194
- this._commentUpdated$.next(updatedComment);
1195
- return updatedComment;
1262
+ const rawComment = await this.commentImplService.updateReactions(commentId, updatedReactions);
1263
+ const formattedComment = this.formatComment(rawComment);
1264
+ this.realtimeService.notifyComment({ type: 'update', payload: formattedComment });
1265
+ return formattedComment;
1196
1266
  }
1197
- async getReactions(commentId) {
1198
- const comment = await this.messageService.getOne(commentId);
1199
- return comment.reactions || [];
1267
+ getReactions(commentId) {
1268
+ return this.commentImplService.getReactions(commentId);
1200
1269
  }
1201
- async likeComment(commentId) {
1270
+ likeComment(commentId) {
1202
1271
  return this.addReaction(commentId, 'like');
1203
1272
  }
1204
- async unlikeComment(commentId) {
1273
+ unlikeComment(commentId) {
1205
1274
  return this.removeReaction(commentId, 'like');
1206
1275
  }
1207
- //#endregion
1208
- //#region ---- Comment Pin Service Implementation ----
1209
1276
  async pinComment(commentId) {
1210
- await this.messageService.updateOne(commentId, { isPinned: true });
1211
- const updatedComment = await this.getComment(commentId);
1212
- this._commentUpdated$.next(updatedComment);
1213
- return updatedComment;
1277
+ const rawComment = await this.commentImplService.pinComment(commentId, true);
1278
+ const formattedComment = this.formatComment(rawComment);
1279
+ this.realtimeService.notifyComment({ type: 'update', payload: formattedComment });
1280
+ return formattedComment;
1214
1281
  }
1215
1282
  async unpinComment(commentId) {
1216
- await this.messageService.updateOne(commentId, { isPinned: false });
1217
- const updatedComment = await this.getComment(commentId);
1218
- this._commentUpdated$.next(updatedComment);
1219
- return updatedComment;
1283
+ const rawComment = await this.commentImplService.pinComment(commentId, false);
1284
+ const formattedComment = this.formatComment(rawComment);
1285
+ this.realtimeService.notifyComment({ type: 'update', payload: formattedComment });
1286
+ return formattedComment;
1220
1287
  }
1221
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentServiceImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1222
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentServiceImpl, providedIn: 'root' }); }
1288
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentManagementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1289
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentManagementService, providedIn: 'root' }); }
1223
1290
  }
1224
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentServiceImpl, decorators: [{
1291
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMCommentManagementService, decorators: [{
1225
1292
  type: Injectable,
1226
1293
  args: [{
1227
1294
  providedIn: 'root',
@@ -1244,7 +1311,8 @@ class AXMCommentComponent {
1244
1311
  this.activeEditComment = signal(undefined, ...(ngDevMode ? [{ debugName: "activeEditComment" }] : []));
1245
1312
  this.highlightedCommentId = signal(null, ...(ngDevMode ? [{ debugName: "highlightedCommentId" }] : []));
1246
1313
  this.wysiwygEditor = viewChild.required('w');
1247
- this.commentService = inject(AXMCommentService);
1314
+ this.commentService = inject(AXMCommentManagementService);
1315
+ this.realtimeService = inject(AXMCommentRealtimeService);
1248
1316
  this.sessionService = inject(AXPSessionService);
1249
1317
  this.toastService = inject(AXToastService);
1250
1318
  this.dialogService = inject(AXDialogService);
@@ -1280,36 +1348,51 @@ class AXMCommentComponent {
1280
1348
  this.isLoading.set(false);
1281
1349
  }, 250);
1282
1350
  });
1283
- this.commentService.commentAdded$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((comment) => {
1284
- if (comment.replyId) {
1285
- this.comments.update((comments) => {
1286
- return comments.map((c) => {
1287
- if (c.id === comment.replyId) {
1288
- const newReplies = c.replies ? [...c.replies, comment] : [comment];
1289
- return { ...c, replies: newReplies, replyCount: newReplies.length };
1290
- }
1291
- return c;
1292
- });
1293
- });
1294
- }
1295
- else {
1296
- this.comments.update((comments) => [...comments, comment]);
1351
+ this.realtimeService.comment$
1352
+ .pipe(takeUntilDestroyed(this.destroyRef), filter((event) => !!event))
1353
+ .subscribe((event) => {
1354
+ switch (event.type) {
1355
+ case 'add':
1356
+ this.handleAddComment(event.payload);
1357
+ break;
1358
+ case 'update':
1359
+ this.handleUpdateComment(event.payload);
1360
+ break;
1361
+ case 'remove':
1362
+ this.removeMessageById(event.payload);
1363
+ break;
1297
1364
  }
1298
1365
  });
1299
- this.commentService.commentUpdated$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((updatedComment) => {
1300
- const update = (list) => {
1301
- return list.map((c) => {
1302
- if (c.id === updatedComment.id) {
1303
- return { ...c, ...updatedComment, replies: updatedComment.replies || c.replies };
1304
- }
1305
- if (c.replies && c.replies.length > 0) {
1306
- return { ...c, replies: update(c.replies) };
1366
+ }
1367
+ handleAddComment(comment) {
1368
+ if (comment.replyId) {
1369
+ this.comments.update((comments) => {
1370
+ return comments.map((c) => {
1371
+ if (c.id === comment.replyId) {
1372
+ const newReplies = c.replies ? [...c.replies, comment] : [comment];
1373
+ return { ...c, replies: newReplies, replyCount: newReplies.length };
1307
1374
  }
1308
1375
  return c;
1309
1376
  });
1310
- };
1311
- this.comments.update((comments) => update(comments));
1312
- });
1377
+ });
1378
+ }
1379
+ else {
1380
+ this.comments.update((comments) => [...comments, comment]);
1381
+ }
1382
+ }
1383
+ handleUpdateComment(updatedComment) {
1384
+ const update = (list) => {
1385
+ return list.map((c) => {
1386
+ if (c.id === updatedComment.id) {
1387
+ return { ...c, ...updatedComment, replies: updatedComment.replies || c.replies };
1388
+ }
1389
+ if (c.replies && c.replies.length > 0) {
1390
+ return { ...c, replies: update(c.replies) };
1391
+ }
1392
+ return c;
1393
+ });
1394
+ };
1395
+ this.comments.update((comments) => update(comments));
1313
1396
  }
1314
1397
  getCurrentUser() {
1315
1398
  const user = this.sessionService.user;
@@ -1340,7 +1423,7 @@ class AXMCommentComponent {
1340
1423
  const thread = await this.commentService.getThread({ type: this.refrenceType(), id: this.refrenceId() }, this.subject());
1341
1424
  if (thread) {
1342
1425
  this.thread.set(thread);
1343
- this.comments.set(thread.comments);
1426
+ this.comments.set(thread.comments || []);
1344
1427
  }
1345
1428
  else {
1346
1429
  this.comments.set([]);
@@ -1376,7 +1459,7 @@ class AXMCommentComponent {
1376
1459
  this.activeReplyComment.set({ ...comment, userName: userName || '' });
1377
1460
  if (reply) {
1378
1461
  const author = reply.author.fullName || reply.author.id;
1379
- const mention = `<a data-id="${reply.id}">@${author}</a> `;
1462
+ const mention = `<strong><a data-id="${reply.author.username}">@${userName || author}</a></strong> `;
1380
1463
  this.commentContent.set(mention);
1381
1464
  document.getElementsByClassName('ql-editor')[0].innerHTML = mention;
1382
1465
  this.wysiwygEditor()?.focus();
@@ -1812,16 +1895,6 @@ const AXMCommentPopupWorkflow = {
1812
1895
  };
1813
1896
 
1814
1897
  function convertChatMessageToNotification(room, message, currentUser) {
1815
- const mapToNotificationUser = (user) => {
1816
- return {
1817
- id: user.id,
1818
- name: user.fullName || '',
1819
- image: '', // You might want to add an avatar URL here if available
1820
- username: user.username || '',
1821
- firstName: user.fullName?.split(' ')[0] || '',
1822
- lastName: user.fullName?.split(' ')[1] || '',
1823
- };
1824
- };
1825
1898
  return {
1826
1899
  channel: 'InApp',
1827
1900
  template: {
@@ -1832,14 +1905,11 @@ function convertChatMessageToNotification(room, message, currentUser) {
1832
1905
  },
1833
1906
  title: room.title || 'New Message',
1834
1907
  body: message.message.content,
1835
- user: mapToNotificationUser(message.author),
1836
- content: {
1837
- type: 'Notification',
1838
- data: {
1839
- roomId: room.id,
1840
- },
1841
- },
1908
+ sender: message.author,
1909
+ receiver: currentUser,
1910
+ content: message.message,
1842
1911
  readAt: null,
1912
+ type: 'Chat',
1843
1913
  };
1844
1914
  }
1845
1915
 
@@ -3505,6 +3575,10 @@ class AXMConversationModule {
3505
3575
  provide: AXMCommentService,
3506
3576
  useClass: AXMCommentServiceImpl,
3507
3577
  },
3578
+ {
3579
+ provide: AXMCommentRealtimeService,
3580
+ useClass: AXMCommentRealtimeServiceImpl,
3581
+ },
3508
3582
  // Entity Provider
3509
3583
  {
3510
3584
  provide: AXP_ENTITY_DEFINITION_LOADER,
@@ -3588,6 +3662,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
3588
3662
  provide: AXMCommentService,
3589
3663
  useClass: AXMCommentServiceImpl,
3590
3664
  },
3665
+ {
3666
+ provide: AXMCommentRealtimeService,
3667
+ useClass: AXMCommentRealtimeServiceImpl,
3668
+ },
3591
3669
  // Entity Provider
3592
3670
  {
3593
3671
  provide: AXP_ENTITY_DEFINITION_LOADER,
@@ -3621,5 +3699,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
3621
3699
  * Generated bundle index. Do not edit.
3622
3700
  */
3623
3701
 
3624
- export { AXMChatComponent, AXMChatItemComponent, AXMChatPreviewComponent, AXMChatService, AXMChatServiceImpl, AXMCommentComponent, AXMCommentPopupComponent, AXMCommentPopupStartAction, AXMCommentPopupWorkflow, AXMCommentService, AXMCommentServiceImpl, AXMCommentWidgetViewComponent, AXMConversationModule, AXMConversationTabService, AXMConversationTabServiceImpl, AXMMessageService, AXMMessageServiceImpl, AXMRoomService, AXMRoomServiceImpl, AXMUserLookupPopup, AXPCommentWidget, RootConfig, messageFactory, roomFactory, tabFactory };
3702
+ export { AXMChatComponent, AXMChatItemComponent, AXMChatPreviewComponent, AXMChatService, AXMChatServiceImpl, AXMCommentComponent, AXMCommentManagementService, AXMCommentPopupComponent, AXMCommentPopupStartAction, AXMCommentPopupWorkflow, AXMCommentRealtimeService, AXMCommentRealtimeServiceImpl, AXMCommentService, AXMCommentServiceImpl, AXMCommentWidgetViewComponent, AXMConversationModule, AXMConversationTabService, AXMConversationTabServiceImpl, AXMMessageService, AXMMessageServiceImpl, AXMRoomService, AXMRoomServiceImpl, AXMUserLookupPopup, AXPCommentWidget, RootConfig, messageFactory, roomFactory, tabFactory };
3625
3703
  //# sourceMappingURL=acorex-modules-conversation.mjs.map