@burgan-tech/morph-touch-runtime 0.0.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 (244) hide show
  1. package/LICENSE +21 -0
  2. package/burgan-tech-morph-touch-runtime-0.0.2.tgz +0 -0
  3. package/package.json +21 -0
  4. package/touch/Extensions/.gitkeep +0 -0
  5. package/touch/Functions/.gitkeep +0 -0
  6. package/touch/Functions/check-livekit-room-access.1.0.0.json +28 -0
  7. package/touch/Functions/check-livekit-room-access.http +44 -0
  8. package/touch/Functions/get-absence-entry.1.0.0.json +28 -0
  9. package/touch/Functions/get-advisor-stats.1.0.0.json +27 -0
  10. package/touch/Functions/get-available-slots.1.0.0.json +30 -0
  11. package/touch/Functions/get-available-slots.http +29 -0
  12. package/touch/Functions/get-chat-rooms.1.0.0.json +28 -0
  13. package/touch/Functions/get-chat-rooms.http +62 -0
  14. package/touch/Functions/get-customer-info.1.0.0.json +27 -0
  15. package/touch/Functions/get-matrix-sync.1.0.0.json +28 -0
  16. package/touch/Functions/get-rezervations.1.0.0.json +26 -0
  17. package/touch/Functions/get-rezervations.http +59 -0
  18. package/touch/Functions/get-room-messages.1.0.0.json +29 -0
  19. package/touch/Functions/get-room-messages.http +45 -0
  20. package/touch/Functions/rezervation-transfer.http +118 -0
  21. package/touch/Functions/send-room-message.1.0.0.json +29 -0
  22. package/touch/Functions/src/CheckLivekitRoomAccessMapping.csx +238 -0
  23. package/touch/Functions/src/GetAbsenceEntryMapping.csx +225 -0
  24. package/touch/Functions/src/GetAdvisorStatsMapping.csx +190 -0
  25. package/touch/Functions/src/GetAvailableSlotsMapping.csx +468 -0
  26. package/touch/Functions/src/GetChatRoomsMapping.csx +202 -0
  27. package/touch/Functions/src/GetCustomerInfoMapping.csx +140 -0
  28. package/touch/Functions/src/GetMatrixSyncMapping.csx +197 -0
  29. package/touch/Functions/src/GetRezervationsMapping.csx +162 -0
  30. package/touch/Functions/src/GetRoomMessagesMapping.csx +165 -0
  31. package/touch/Functions/src/SendCancelNotificationMapping.csx +63 -0
  32. package/touch/Functions/src/SendRoomMessageMapping.csx +131 -0
  33. package/touch/Schemas/.gitkeep +0 -0
  34. package/touch/Schemas/absence-entry.1.0.0.json +232 -0
  35. package/touch/Schemas/advisor-chat-rooms.1.0.0.json +62 -0
  36. package/touch/Schemas/chat-room.1.0.0.json +110 -0
  37. package/touch/Schemas/notification-sender.1.0.0.json +159 -0
  38. package/touch/Schemas/portfolio-manager.1.0.0.json +63 -0
  39. package/touch/Schemas/rezervation.1.0.0.json +102 -0
  40. package/touch/Tasks/.gitkeep +0 -0
  41. package/touch/Tasks/cancel-absence-entry-for-rezervation.1.0.0.json +21 -0
  42. package/touch/Tasks/check-already-completed-chat-room.1.0.0.json +24 -0
  43. package/touch/Tasks/check-duplicate-portfolio-manager.1.0.0.json +23 -0
  44. package/touch/Tasks/check-duplicate-rezervation.1.0.0.json +23 -0
  45. package/touch/Tasks/check-existing-permanent-chat-room.1.0.0.json +21 -0
  46. package/touch/Tasks/check-randevu-time.1.0.0.json +17 -0
  47. package/touch/Tasks/create-permanent-chat-room.1.0.0.json +28 -0
  48. package/touch/Tasks/determine-transfer-type.1.0.0.json +16 -0
  49. package/touch/Tasks/enrich-rezervations-for-transfer.1.0.0.json +23 -0
  50. package/touch/Tasks/execute-permanent-chatroom-update.1.0.0.json +21 -0
  51. package/touch/Tasks/execute-rez-chatroom-transfer.1.0.0.json +21 -0
  52. package/touch/Tasks/execute-rezervation-transfer.1.0.0.json +19 -0
  53. package/touch/Tasks/fetch-absence-entries-for-transfer.1.0.0.json +23 -0
  54. package/touch/Tasks/fetch-advisors-for-transfer.1.0.0.json +23 -0
  55. package/touch/Tasks/fetch-permanent-chatrooms-for-transfer.1.0.0.json +23 -0
  56. package/touch/Tasks/fetch-rez-chatrooms-for-transfer.1.0.0.json +23 -0
  57. package/touch/Tasks/fetch-rezervations-for-transfer.1.0.0.json +22 -0
  58. package/touch/Tasks/get-absence-entry-task.1.0.0.json +23 -0
  59. package/touch/Tasks/get-available-slots-http.1.0.0.json +27 -0
  60. package/touch/Tasks/get-available-slots.1.0.0.json +24 -0
  61. package/touch/Tasks/get-chat-room-data-for-rezervation.1.0.0.json +23 -0
  62. package/touch/Tasks/get-chat-token.1.0.0.json +27 -0
  63. package/touch/Tasks/get-matrix-room-messages.1.0.0.json +25 -0
  64. package/touch/Tasks/get-matrix-sync.1.0.0.json +25 -0
  65. package/touch/Tasks/get-rezervation-data-task.1.0.0.json +22 -0
  66. package/touch/Tasks/get-rezervation-state-task.1.0.0.json +22 -0
  67. package/touch/Tasks/get-rezervations-task.1.0.0.json +21 -0
  68. package/touch/Tasks/get-user-info-for-rezervation.1.0.0.json +24 -0
  69. package/touch/Tasks/get-video-call-url.1.0.0.json +17 -0
  70. package/touch/Tasks/invite-user-to-rezervation-room.1.0.0.json +27 -0
  71. package/touch/Tasks/join-chat-room-for-rezervation.1.0.0.json +28 -0
  72. package/touch/Tasks/join-matrix-room.1.0.0.json +27 -0
  73. package/touch/Tasks/join-user-to-room.1.0.0.json +27 -0
  74. package/touch/Tasks/merge-invited-user.1.0.0.json +17 -0
  75. package/touch/Tasks/merge-rezervation-update.1.0.0.json +16 -0
  76. package/touch/Tasks/merge-target-advisor-for-transfer.1.0.0.json +17 -0
  77. package/touch/Tasks/merge-update-body-for-randevu-update.1.0.0.json +16 -0
  78. package/touch/Tasks/merge-video-call-urls.1.0.0.json +17 -0
  79. package/touch/Tasks/query-chat-room-instances.1.0.0.json +23 -0
  80. package/touch/Tasks/remove-member-from-room.1.0.0.json +28 -0
  81. package/touch/Tasks/send-matrix-room-message.1.0.0.json +26 -0
  82. package/touch/Tasks/send-push-notification.1.0.0.json +26 -0
  83. package/touch/Tasks/send-sms-notification.1.0.0.json +26 -0
  84. package/touch/Tasks/set-chat-room-status-active.1.0.0.json +16 -0
  85. package/touch/Tasks/set-chat-room-status-deactive.1.0.0.json +16 -0
  86. package/touch/Tasks/set-previous-advisor.1.0.0.json +16 -0
  87. package/touch/Tasks/set-user-from-headers-for-rezervation.1.0.0.json +17 -0
  88. package/touch/Tasks/start-absence-entry-for-rezervation.1.0.0.json +21 -0
  89. package/touch/Tasks/start-chat-room-for-rezervation.1.0.0.json +20 -0
  90. package/touch/Tasks/start-notification-sender.1.0.0.json +20 -0
  91. package/touch/Tasks/start-permanent-chat-room.1.0.0.json +21 -0
  92. package/touch/Tasks/start-transfer-from-absence-entry.1.0.0.json +19 -0
  93. package/touch/Tasks/start-video-call.1.0.0.json +22 -0
  94. package/touch/Tasks/trigger-chat-room-deactivate.1.0.0.json +21 -0
  95. package/touch/Tasks/trigger-chat-room-transfer.1.0.0.json +21 -0
  96. package/touch/Tasks/trigger-chat-room-update.1.0.0.json +20 -0
  97. package/touch/Tasks/trigger-rezervation-add-invited-participant.1.0.0.json +20 -0
  98. package/touch/Tasks/trigger-rezervation-apply-update.1.0.0.json +20 -0
  99. package/touch/Tasks/trigger-rezervation-to-in-meet.1.0.0.json +20 -0
  100. package/touch/Tasks/trigger-rezervation-video-call-update.1.0.0.json +21 -0
  101. package/touch/Tasks/validate-date-for-rezervation.1.0.0.json +18 -0
  102. package/touch/Tasks/validate-slot-for-rezervation.1.0.0.json +24 -0
  103. package/touch/Tasks/validate-transfer-availability.1.0.0.json +23 -0
  104. package/touch/Views/.gitkeep +0 -0
  105. package/touch/Workflows/.gitkeep +0 -0
  106. package/touch/Workflows/absence-entry.http +458 -0
  107. package/touch/Workflows/absence-entry.json +179 -0
  108. package/touch/Workflows/add-participant-to-rezervation.http +47 -0
  109. package/touch/Workflows/add-participant-to-rezervation.json +340 -0
  110. package/touch/Workflows/chat-room.http +207 -0
  111. package/touch/Workflows/chat-room.json +452 -0
  112. package/touch/Workflows/investment-advisor.json +367 -0
  113. package/touch/Workflows/notification-sender.http +299 -0
  114. package/touch/Workflows/notification-sender.json +262 -0
  115. package/touch/Workflows/portfolio-manager.json +367 -0
  116. package/touch/Workflows/randevu-update.http +87 -0
  117. package/touch/Workflows/rezervation-start.json +467 -0
  118. package/touch/Workflows/rezervation-transfer.json +512 -0
  119. package/touch/Workflows/rezervation-update.http +87 -0
  120. package/touch/Workflows/rezervation-update.json +485 -0
  121. package/touch/Workflows/rezervation.http +214 -0
  122. package/touch/Workflows/rezervation.json +726 -0
  123. package/touch/Workflows/src/AllChatRoomsSuccessRule.csx +65 -0
  124. package/touch/Workflows/src/AlwaysTrueRule.csx +13 -0
  125. package/touch/Workflows/src/AnyChatRoomFailedRule.csx +64 -0
  126. package/touch/Workflows/src/AutoProcessRule.csx +38 -0
  127. package/touch/Workflows/src/BuildRezChatRoomPlanMapping.csx +160 -0
  128. package/touch/Workflows/src/CanStartRezervationTimerMapping.csx +48 -0
  129. package/touch/Workflows/src/CanStartTransferMapping.csx +14 -0
  130. package/touch/Workflows/src/CancelAbsenceEntryForRezervationMapping.csx +48 -0
  131. package/touch/Workflows/src/CancelAbsenceForRandevuUpdateMapping.csx +62 -0
  132. package/touch/Workflows/src/ChatRoomCreatedFailedRule.csx +54 -0
  133. package/touch/Workflows/src/ChatRoomCreatedSuccessRule.csx +54 -0
  134. package/touch/Workflows/src/ChatRoomRemoveMapping.csx +104 -0
  135. package/touch/Workflows/src/ChatRoomTransferInviteMapping.csx +109 -0
  136. package/touch/Workflows/src/ChatRoomTransferRemoveMapping.csx +71 -0
  137. package/touch/Workflows/src/ChatRoomUpdateMapping.csx +107 -0
  138. package/touch/Workflows/src/CheckAlreadyCompletedChatRoomMapping.csx +100 -0
  139. package/touch/Workflows/src/CheckDuplicatePortfolioManagerMapping.csx +119 -0
  140. package/touch/Workflows/src/CheckDuplicateRezervationMapping.csx +150 -0
  141. package/touch/Workflows/src/CheckExistingPermanentChatRoomMapping.csx +169 -0
  142. package/touch/Workflows/src/CheckRandevuTimeMapping.csx +67 -0
  143. package/touch/Workflows/src/CheckRezervationStateActiveOrInMeetRule.csx +14 -0
  144. package/touch/Workflows/src/CreateAbsenceEntryForRezervationMapping.csx +111 -0
  145. package/touch/Workflows/src/CreateAbsenceForRandevuUpdateMapping.csx +108 -0
  146. package/touch/Workflows/src/CreateChatRoomForRezervationMapping.csx +122 -0
  147. package/touch/Workflows/src/CreatePermanentChatRoomMapping.csx +140 -0
  148. package/touch/Workflows/src/CustomerControlToEndRule.csx +14 -0
  149. package/touch/Workflows/src/DetermineTransferTypeMapping.csx +92 -0
  150. package/touch/Workflows/src/EnrichRezervationsForTransferMapping.csx +495 -0
  151. package/touch/Workflows/src/ExecutePermanentChatRoomUpdateMapping.csx +124 -0
  152. package/touch/Workflows/src/ExecuteRezChatRoomTransferMapping.csx +95 -0
  153. package/touch/Workflows/src/ExecuteTransferMapping.csx +152 -0
  154. package/touch/Workflows/src/FetchAbsenceEntriesForTransferMapping.csx +116 -0
  155. package/touch/Workflows/src/FetchAdvisorsForTransferMapping.csx +145 -0
  156. package/touch/Workflows/src/FetchPermanentChatRoomsMapping.csx +128 -0
  157. package/touch/Workflows/src/FetchRezervationsForTransferMapping.csx +124 -0
  158. package/touch/Workflows/src/GetChatRoomDataForRezervationMapping.csx +100 -0
  159. package/touch/Workflows/src/GetChatTokenMapping.csx +85 -0
  160. package/touch/Workflows/src/GetRezervationDataForAddParticipantMapping.csx +105 -0
  161. package/touch/Workflows/src/GetRezervationDataForRandevuUpdateMapping.csx +110 -0
  162. package/touch/Workflows/src/GetRezervationDataMapping.csx +111 -0
  163. package/touch/Workflows/src/GetRezervationStateForRandevuUpdateMapping.csx +80 -0
  164. package/touch/Workflows/src/GetRezervationStateMapping.csx +92 -0
  165. package/touch/Workflows/src/GetUserInfoForRezervationMapping.csx +63 -0
  166. package/touch/Workflows/src/GetVideoCallUrlMapping.csx +62 -0
  167. package/touch/Workflows/src/HasChangedAdvisorRule.csx +28 -0
  168. package/touch/Workflows/src/HasChatIntegrationRule.csx +41 -0
  169. package/touch/Workflows/src/HasExistingPermanentRoomRule.csx +28 -0
  170. package/touch/Workflows/src/InviteAdvisorForRandevuUpdateMapping.csx +86 -0
  171. package/touch/Workflows/src/InviteNewAdvisorToRezervationRoomMapping.csx +78 -0
  172. package/touch/Workflows/src/InviteNewParticipantToRandevuRoomMapping.csx +88 -0
  173. package/touch/Workflows/src/InvitedUserMergeMapping.csx +77 -0
  174. package/touch/Workflows/src/InvitedUserNotAllowedRule.csx +71 -0
  175. package/touch/Workflows/src/InvitedUserNotInMeetRule.csx +19 -0
  176. package/touch/Workflows/src/IsNotfSentRule.csx +36 -0
  177. package/touch/Workflows/src/JoinChatRoomForAddParticipantMapping.csx +118 -0
  178. package/touch/Workflows/src/JoinChatRoomForRandevuStartMapping.csx +119 -0
  179. package/touch/Workflows/src/JoinChatRoomForRezervationMapping.csx +118 -0
  180. package/touch/Workflows/src/JoinMatrixRoomMapping.csx +100 -0
  181. package/touch/Workflows/src/JoinUserToRoomMapping.csx +118 -0
  182. package/touch/Workflows/src/LoginForAddParticipantChatMapping.csx +102 -0
  183. package/touch/Workflows/src/LoginForRandevuStartChatMapping.csx +96 -0
  184. package/touch/Workflows/src/MergeRezervationUpdateMapping.csx +82 -0
  185. package/touch/Workflows/src/MergeTargetAdvisorForTransferMapping.csx +79 -0
  186. package/touch/Workflows/src/MergeUpdateBodyForRandevuUpdateMapping.csx +91 -0
  187. package/touch/Workflows/src/NoExistingPermanentRoomRule.csx +23 -0
  188. package/touch/Workflows/src/NotificationCompleteAlwaysRule.csx +14 -0
  189. package/touch/Workflows/src/NotificationCompleteFromPendingRule.csx +41 -0
  190. package/touch/Workflows/src/NotificationCompleteFromSmsRule.csx +36 -0
  191. package/touch/Workflows/src/NotificationPushFromPendingRule.csx +42 -0
  192. package/touch/Workflows/src/NotificationPushFromSmsRule.csx +36 -0
  193. package/touch/Workflows/src/NotificationSmsPendingRule.csx +32 -0
  194. package/touch/Workflows/src/PermanentDoneRule.csx +44 -0
  195. package/touch/Workflows/src/PermanentProcessNextRule.csx +44 -0
  196. package/touch/Workflows/src/RezChatRoomProcessNextRule.csx +44 -0
  197. package/touch/Workflows/src/RezChatRoomsDoneRule.csx +44 -0
  198. package/touch/Workflows/src/SendPushNotificationMapping.csx +146 -0
  199. package/touch/Workflows/src/SendSmsNotificationMapping.csx +138 -0
  200. package/touch/Workflows/src/SetChatRoomStatusActiveMapping.csx +22 -0
  201. package/touch/Workflows/src/SetChatRoomStatusDeactiveMapping.csx +22 -0
  202. package/touch/Workflows/src/SetPreviousAdvisorMapping.csx +28 -0
  203. package/touch/Workflows/src/SetUserFromHeadersForRezervationMapping.csx +24 -0
  204. package/touch/Workflows/src/SlotAvailableRule.csx +33 -0
  205. package/touch/Workflows/src/SlotUnavailableRule.csx +33 -0
  206. package/touch/Workflows/src/StartChatRoomForRezervationMapping.csx +100 -0
  207. package/touch/Workflows/src/StartGetChatTokenForRezervationMapping.csx +71 -0
  208. package/touch/Workflows/src/StartNotificationForAdvisorMapping.csx +117 -0
  209. package/touch/Workflows/src/StartNotificationForRezervationFromUserInfoMapping.csx +128 -0
  210. package/touch/Workflows/src/StartNotificationForUserMapping.csx +117 -0
  211. package/touch/Workflows/src/StartPermanentChatRoomMapping.csx +92 -0
  212. package/touch/Workflows/src/StartTransferFromAbsenceEntryMapping.csx +94 -0
  213. package/touch/Workflows/src/StartVideoCallCustomerSubFlowMapping.csx +37 -0
  214. package/touch/Workflows/src/StartVideoCallForInvitedParticipantMapping.csx +54 -0
  215. package/touch/Workflows/src/StartVideoCallForRandevuStartMapping.csx +70 -0
  216. package/touch/Workflows/src/StartVideoCallStaffSubFlowMapping.csx +37 -0
  217. package/touch/Workflows/src/StateActiveForUpdateRule.csx +14 -0
  218. package/touch/Workflows/src/StateActiveRule.csx +14 -0
  219. package/touch/Workflows/src/StateInMeetRule.csx +14 -0
  220. package/touch/Workflows/src/StateNotActiveForUpdateRule.csx +14 -0
  221. package/touch/Workflows/src/StateNotActiveOrInMeetRule.csx +14 -0
  222. package/touch/Workflows/src/StatusCustomerEnterRule.csx +25 -0
  223. package/touch/Workflows/src/StatusStaffEnterRule.csx +25 -0
  224. package/touch/Workflows/src/SyncWorkingHoursRule.csx +46 -0
  225. package/touch/Workflows/src/TokenSuccessRule.csx +24 -0
  226. package/touch/Workflows/src/TransferAllDoneRule.csx +50 -0
  227. package/touch/Workflows/src/TransferHasInvalidRule.csx +34 -0
  228. package/touch/Workflows/src/TransferProcessNextRule.csx +50 -0
  229. package/touch/Workflows/src/TriggerChatRoomDeactivateMapping.csx +77 -0
  230. package/touch/Workflows/src/TriggerChatRoomTransferMapping.csx +93 -0
  231. package/touch/Workflows/src/TriggerChatRoomUpdateMapping.csx +99 -0
  232. package/touch/Workflows/src/TriggerRezervationAddInvitedParticipantMapping.csx +77 -0
  233. package/touch/Workflows/src/TriggerRezervationApplyUpdateMapping.csx +66 -0
  234. package/touch/Workflows/src/TriggerRezervationToInMeetMapping.csx +69 -0
  235. package/touch/Workflows/src/TriggerRezervationVideoCallUpdateMapping.csx +67 -0
  236. package/touch/Workflows/src/ValidateDateForRezervationMapping.csx +60 -0
  237. package/touch/Workflows/src/ValidateSlotForRandevuUpdateMapping.csx +211 -0
  238. package/touch/Workflows/src/ValidateSlotForRezervationMapping.csx +246 -0
  239. package/touch/Workflows/src/ValidateTransferMapping.csx +243 -0
  240. package/touch/Workflows/src/VideoCallUrlUpdateMergeMapping.csx +141 -0
  241. package/touch/Workflows/start-chat.json +217 -0
  242. package/touch/Workflows/start-video-call.http +93 -0
  243. package/touch/Workflows/start-video-call.json +206 -0
  244. package/vnext.config.json +58 -0
@@ -0,0 +1,77 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Threading.Tasks;
4
+ using BBT.Workflow.Scripting;
5
+ using BBT.Workflow.Definitions;
6
+
7
+ /// <summary>
8
+ /// Merges invitedUserId from transition body into existing invitedUser array on rezervation instance.
9
+ /// Appends new user if not already present. Returns Data.invitedUser for instance merge.
10
+ /// </summary>
11
+ public class InvitedUserMergeMapping : ScriptBase, IMapping
12
+ {
13
+ public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
14
+ {
15
+ return Task.FromResult(new ScriptResponse());
16
+ }
17
+
18
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
19
+ {
20
+ var instanceData = context.Instance?.Data;
21
+ var body = context.Body;
22
+ var invitedUserId = GetString(body, "invitedUserId");
23
+ if (string.IsNullOrWhiteSpace(invitedUserId))
24
+ return Task.FromResult(new ScriptResponse { Data = new Dictionary<string, object>() });
25
+
26
+ var existingList = GetInvitedUserList(instanceData);
27
+ var trimmed = invitedUserId.Trim();
28
+ if (!existingList.Contains(trimmed))
29
+ existingList.Add(trimmed);
30
+
31
+ return Task.FromResult(new ScriptResponse
32
+ {
33
+ Data = new Dictionary<string, object> { { "invitedUser", existingList } }
34
+ });
35
+ }
36
+
37
+ private List<string> GetInvitedUserList(dynamic source)
38
+ {
39
+ if (source == null) return new List<string>();
40
+ try
41
+ {
42
+ if (!HasProperty(source, "invitedUser")) return new List<string>();
43
+ var arr = source.invitedUser;
44
+ if (arr == null) return new List<string>();
45
+ var list = arr as System.Collections.IEnumerable;
46
+ if (list == null || list is string) return new List<string>();
47
+ var result = new List<string>();
48
+ foreach (var item in list)
49
+ {
50
+ if (item != null)
51
+ {
52
+ var s = item.ToString()?.Trim();
53
+ if (!string.IsNullOrEmpty(s))
54
+ result.Add(s);
55
+ }
56
+ }
57
+ return result;
58
+ }
59
+ catch { }
60
+ return new List<string>();
61
+ }
62
+
63
+ private string GetString(dynamic obj, string name)
64
+ {
65
+ if (obj == null) return null;
66
+ try
67
+ {
68
+ if (HasProperty(obj, name))
69
+ {
70
+ var v = GetPropertyValue(obj, name);
71
+ return v?.ToString();
72
+ }
73
+ }
74
+ catch { }
75
+ return null;
76
+ }
77
+ }
@@ -0,0 +1,71 @@
1
+ using System;
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using System.Threading.Tasks;
5
+ using BBT.Workflow.Scripting;
6
+
7
+ /// <summary>
8
+ /// Condition for check-rezervation-state: when participantType=invited and invitedUserId is not in rezervation invitedUser array -> not-allowed.
9
+ /// </summary>
10
+ public class InvitedUserNotAllowedRule : ScriptBase, IConditionMapping
11
+ {
12
+ public Task<bool> Handler(ScriptContext context)
13
+ {
14
+ var data = context.Instance?.Data;
15
+ var participantType = GetString(data, "participantType");
16
+ if (participantType != "invited")
17
+ return Task.FromResult(false);
18
+
19
+ var invitedUserId = GetString(data, "invitedUserId");
20
+ if (string.IsNullOrWhiteSpace(invitedUserId))
21
+ return Task.FromResult(true);
22
+
23
+ var invitedUserList = GetInvitedUserList(data);
24
+ if (invitedUserList == null || invitedUserList.Count == 0)
25
+ return Task.FromResult(true);
26
+
27
+ var trimmed = invitedUserId.Trim();
28
+ return Task.FromResult(!invitedUserList.Contains(trimmed));
29
+ }
30
+
31
+ private List<string> GetInvitedUserList(dynamic source)
32
+ {
33
+ if (source == null) return new List<string>();
34
+ try
35
+ {
36
+ if (!HasProperty(source, "invitedUser")) return new List<string>();
37
+ var arr = source.invitedUser;
38
+ if (arr == null) return new List<string>();
39
+ var list = arr as IEnumerable;
40
+ if (list == null || list is string) return new List<string>();
41
+ var result = new List<string>();
42
+ foreach (var item in list)
43
+ {
44
+ if (item != null)
45
+ {
46
+ var s = item.ToString()?.Trim();
47
+ if (!string.IsNullOrEmpty(s))
48
+ result.Add(s);
49
+ }
50
+ }
51
+ return result;
52
+ }
53
+ catch { }
54
+ return new List<string>();
55
+ }
56
+
57
+ private string GetString(dynamic obj, string name)
58
+ {
59
+ if (obj == null) return null;
60
+ try
61
+ {
62
+ if (HasProperty(obj, name))
63
+ {
64
+ var v = GetPropertyValue(obj, name);
65
+ return v?.ToString();
66
+ }
67
+ }
68
+ catch { }
69
+ return null;
70
+ }
71
+ }
@@ -0,0 +1,19 @@
1
+ using System.Threading.Tasks;
2
+ using BBT.Workflow.Scripting;
3
+
4
+ /// <summary>
5
+ /// Condition for check-time: when participantType=invited and state != in-meet -> meet-not-started.
6
+ /// </summary>
7
+ public class InvitedUserNotInMeetRule : ScriptBase, IConditionMapping
8
+ {
9
+ public Task<bool> Handler(ScriptContext context)
10
+ {
11
+ var data = context.Instance?.Data;
12
+ var participantType = data?.participantType?.ToString()?.Trim();
13
+ if (participantType != "invited")
14
+ return Task.FromResult(false);
15
+
16
+ var state = data?.state?.ToString()?.Trim();
17
+ return Task.FromResult(state != "in-meet");
18
+ }
19
+ }
@@ -0,0 +1,36 @@
1
+ using System;
2
+ using System.Threading.Tasks;
3
+ using BBT.Workflow.Scripting;
4
+
5
+ /// <summary>
6
+ /// Condition mapping for send-user-notification auto transition in rezervation active state.
7
+ /// Rule: transition runs when IsNotfSent is missing or false; does not run when IsNotfSent == true.
8
+ /// </summary>
9
+ public class IsNotfSentRule : ScriptBase, IConditionMapping
10
+ {
11
+ public Task<bool> Handler(ScriptContext context)
12
+ {
13
+ try
14
+ {
15
+ if (context?.Instance?.Data == null)
16
+ return Task.FromResult(false);
17
+
18
+ var data = context.Instance.Data;
19
+
20
+ dynamic sent = null;
21
+ if (HasProperty(data, "isNotfSent"))
22
+ sent = data.isNotfSent;
23
+ else if (HasProperty(data, "IsNotfSent"))
24
+ sent = data.IsNotfSent;
25
+
26
+ if (sent == null)
27
+ return Task.FromResult(true);
28
+
29
+ return Task.FromResult(sent != true);
30
+ }
31
+ catch (Exception)
32
+ {
33
+ return Task.FromResult(false);
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,118 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Threading.Tasks;
4
+ using BBT.Workflow.Scripting;
5
+ using BBT.Workflow.Definitions;
6
+
7
+ /// <summary>
8
+ /// Mapping for join-chat-room-for-rezervation when used in add-participant-to-rezervation flow.
9
+ /// Uses x-matrix-user = newUserId (the invited participant joining). No login/sessionId.
10
+ /// </summary>
11
+ public class JoinChatRoomForAddParticipantMapping : ScriptBase, IMapping
12
+ {
13
+ public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
14
+ {
15
+ var httpTask = task as HttpTask;
16
+ if (httpTask == null)
17
+ throw new InvalidOperationException("Task must be an HttpTask");
18
+
19
+ var data = context.Instance?.Data;
20
+ var chatIntegration = GetChatIntegration(data);
21
+ var roomId = GetString(chatIntegration, "roomId");
22
+ var newUserId = GetString(data, "newUserId");
23
+
24
+ if (string.IsNullOrWhiteSpace(roomId))
25
+ return new ScriptResponse();
26
+
27
+ if (string.IsNullOrWhiteSpace(newUserId))
28
+ return new ScriptResponse();
29
+
30
+ var matrixBaseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "MatrixBaseUrl");
31
+ if (string.IsNullOrWhiteSpace(matrixBaseUrl))
32
+ throw new InvalidOperationException("MatrixBaseUrl secret is required");
33
+ var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/join/" + Uri.EscapeDataString(roomId ?? "");
34
+ httpTask.SetUrl(fullUrl);
35
+
36
+ var headers = new Dictionary<string, string>
37
+ {
38
+ ["Content-Type"] = "application/json",
39
+ ["Accept"] = "application/json",
40
+ ["x-matrix-user"] = newUserId.Trim()
41
+ };
42
+
43
+ httpTask.SetHeaders(headers);
44
+ httpTask.SetBody(new { });
45
+
46
+ return new ScriptResponse();
47
+ }
48
+
49
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
50
+ {
51
+ var result = new ScriptResponse();
52
+ var response = context.Body;
53
+ var instanceData = context.Instance?.Data;
54
+ var chatIntegration = GetChatIntegration(instanceData);
55
+ var newUserId = GetString(instanceData, "newUserId");
56
+
57
+ if (response?.isSuccess == true)
58
+ {
59
+ dynamic data = response.data;
60
+ string joinedRoomId = GetString(data, "room_id") ?? GetString(data, "roomId") ?? GetString(data, "RoomId");
61
+
62
+ result.Data = new
63
+ {
64
+ chatIntegration = new
65
+ {
66
+ username = newUserId,
67
+ roomId = joinedRoomId ?? GetString(chatIntegration, "roomId"),
68
+ error = (string)null,
69
+ errorCode = (string)null
70
+ }
71
+ };
72
+ }
73
+ else
74
+ {
75
+ string errorMessage = response?.errorMessage?.ToString() ?? "Failed to join room";
76
+ string statusCode = response?.statusCode != null ? response.statusCode.ToString() : null;
77
+ result.Data = new
78
+ {
79
+ chatIntegration = new
80
+ {
81
+ username = newUserId,
82
+ roomId = (string)null,
83
+ error = errorMessage,
84
+ errorCode = statusCode
85
+ }
86
+ };
87
+ }
88
+
89
+ return Task.FromResult(result);
90
+ }
91
+
92
+ private string GetString(dynamic obj, string name)
93
+ {
94
+ if (obj == null) return null;
95
+ try
96
+ {
97
+ if (HasProperty(obj, name))
98
+ {
99
+ var v = GetPropertyValue(obj, name);
100
+ return v?.ToString();
101
+ }
102
+ }
103
+ catch { }
104
+ return null;
105
+ }
106
+
107
+ private dynamic GetChatIntegration(dynamic data)
108
+ {
109
+ if (data == null) return null;
110
+ try
111
+ {
112
+ if (HasProperty(data, "chatIntegration"))
113
+ return GetPropertyValue(data, "chatIntegration");
114
+ }
115
+ catch { }
116
+ return null;
117
+ }
118
+ }
@@ -0,0 +1,119 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Threading.Tasks;
4
+ using BBT.Workflow.Scripting;
5
+ using BBT.Workflow.Definitions;
6
+
7
+ /// <summary>
8
+ /// Mapping for join-chat-room-for-rezervation when used in rezervation-start flow.
9
+ /// Uses chatIntegration.roomId from rezervation. Uses x-matrix-user header instead of login/sessionId.
10
+ /// </summary>
11
+ public class JoinChatRoomForRandevuStartMapping : ScriptBase, IMapping
12
+ {
13
+ public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
14
+ {
15
+ var httpTask = task as HttpTask;
16
+ if (httpTask == null)
17
+ throw new InvalidOperationException("Task must be an HttpTask");
18
+
19
+ var matrixBaseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "MatrixBaseUrl");
20
+ if (string.IsNullOrWhiteSpace(matrixBaseUrl))
21
+ throw new InvalidOperationException("MatrixBaseUrl secret is required");
22
+
23
+ var data = context.Instance?.Data;
24
+ var chatIntegration = data?.chatIntegration;
25
+ var roomId = GetString(chatIntegration, "roomId");
26
+ var participantType = GetString(data, "participantType");
27
+ var user = GetString(data, "user");
28
+ var advisorId = GetString(data, "advisor");
29
+ var invitedUserId = GetString(data, "invitedUserId");
30
+
31
+ if (string.IsNullOrWhiteSpace(roomId))
32
+ throw new InvalidOperationException("chatIntegration.roomId is required to join room");
33
+
34
+ var xMatrixUser = participantType == "advisor" ? advisorId
35
+ : participantType == "invited" ? invitedUserId
36
+ : user;
37
+ if (string.IsNullOrWhiteSpace(xMatrixUser))
38
+ throw new InvalidOperationException("Cannot determine x-matrix-user: participantType, user, advisor, or invitedUserId missing");
39
+
40
+ var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/join/" + Uri.EscapeDataString(roomId ?? "");
41
+ httpTask.SetUrl(fullUrl);
42
+
43
+ var headers = new Dictionary<string, string>
44
+ {
45
+ ["Content-Type"] = "application/json",
46
+ ["Accept"] = "application/json",
47
+ ["x-matrix-user"] = xMatrixUser.Trim()
48
+ };
49
+
50
+ httpTask.SetHeaders(headers);
51
+ httpTask.SetBody(new { });
52
+
53
+ return new ScriptResponse();
54
+ }
55
+
56
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
57
+ {
58
+ var result = new ScriptResponse();
59
+ var response = context.Body;
60
+ var data = context.Instance?.Data;
61
+ var participantType = GetString(data, "participantType");
62
+ var user = GetString(data, "user");
63
+ var advisorId = GetString(data, "advisor");
64
+ var invitedUserId = GetString(data, "invitedUserId");
65
+ var chatIntegration = data?.chatIntegration;
66
+ var username = participantType == "advisor" ? advisorId
67
+ : participantType == "invited" ? invitedUserId
68
+ : user;
69
+
70
+ if (response?.isSuccess == true)
71
+ {
72
+ dynamic respData = response.data;
73
+ string joinedRoomId = GetString(respData, "room_id") ?? GetString(respData, "roomId") ?? GetString(respData, "RoomId");
74
+
75
+ result.Data = new
76
+ {
77
+ chatIntegration = new
78
+ {
79
+ username,
80
+ roomId = joinedRoomId ?? GetString(chatIntegration, "roomId"),
81
+ error = (string)null,
82
+ errorCode = (string)null
83
+ }
84
+ };
85
+ }
86
+ else
87
+ {
88
+ string errorMessage = response?.errorMessage?.ToString() ?? "Failed to join room";
89
+ string statusCode = response?.statusCode != null ? response.statusCode.ToString() : null;
90
+ result.Data = new
91
+ {
92
+ chatIntegration = new
93
+ {
94
+ username,
95
+ roomId = (string)null,
96
+ error = errorMessage,
97
+ errorCode = statusCode
98
+ }
99
+ };
100
+ }
101
+
102
+ return Task.FromResult(result);
103
+ }
104
+
105
+ private string GetString(dynamic obj, string name)
106
+ {
107
+ if (obj == null) return null;
108
+ try
109
+ {
110
+ if (HasProperty(obj, name))
111
+ {
112
+ var v = GetPropertyValue(obj, name);
113
+ return v?.ToString();
114
+ }
115
+ }
116
+ catch { }
117
+ return null;
118
+ }
119
+ }
@@ -0,0 +1,118 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Threading.Tasks;
4
+ using BBT.Workflow.Scripting;
5
+ using BBT.Workflow.Definitions;
6
+
7
+ /// <summary>
8
+ /// Mapping for join-chat-room-for-rezervation HttpTask (Type 6).
9
+ /// Joins an existing Matrix chat room when rezervation is already in-meet (second participant).
10
+ /// Uses x-matrix-user header. URL path includes roomIdOrAlias, body is empty.
11
+ /// </summary>
12
+ public class JoinChatRoomForRezervationMapping : ScriptBase, IMapping
13
+ {
14
+ public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
15
+ {
16
+ var httpTask = task as HttpTask;
17
+ if (httpTask == null)
18
+ throw new InvalidOperationException("Task must be an HttpTask");
19
+
20
+ var matrixBaseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "MatrixBaseUrl");
21
+ if (string.IsNullOrWhiteSpace(matrixBaseUrl))
22
+ throw new InvalidOperationException("MatrixBaseUrl secret is required");
23
+
24
+ var data = context.Instance?.Data;
25
+ var chatIntegration = data?.chatIntegration;
26
+
27
+ var roomId = GetString(chatIntegration, "roomId");
28
+ var xMatrixUser = GetString(data, "user") ?? GetString(data, "advisor") ?? GetString(chatIntegration, "username");
29
+
30
+ if (string.IsNullOrWhiteSpace(roomId))
31
+ throw new InvalidOperationException("chatIntegration.roomId is required to join room");
32
+ if (string.IsNullOrWhiteSpace(xMatrixUser))
33
+ throw new InvalidOperationException("user or advisor is required for x-matrix-user");
34
+
35
+ var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/join/" + Uri.EscapeDataString(roomId ?? "");
36
+ httpTask.SetUrl(fullUrl);
37
+
38
+ var headers = new Dictionary<string, string>
39
+ {
40
+ ["Content-Type"] = "application/json",
41
+ ["Accept"] = "application/json",
42
+ ["x-matrix-user"] = xMatrixUser.Trim()
43
+ };
44
+
45
+ httpTask.SetHeaders(headers);
46
+ httpTask.SetBody(new { });
47
+
48
+ return new ScriptResponse();
49
+ }
50
+
51
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
52
+ {
53
+ var result = new ScriptResponse();
54
+ var response = context.Body;
55
+
56
+ if (response?.isSuccess == true)
57
+ {
58
+ dynamic data = response.data;
59
+ string joinedRoomId = GetString(data, "room_id") ?? GetString(data, "roomId") ?? GetString(data, "RoomId");
60
+
61
+ var instanceData = context.Instance?.Data;
62
+ var chatIntegration = instanceData?.chatIntegration;
63
+ string userId = GetString(chatIntegration, "userId");
64
+ string username = GetString(chatIntegration, "username");
65
+
66
+ result.Data = new
67
+ {
68
+ chatIntegration = new
69
+ {
70
+ userId,
71
+ username,
72
+ roomId = joinedRoomId ?? GetString(chatIntegration, "roomId"),
73
+ error = (string)null,
74
+ errorCode = (string)null
75
+ }
76
+ };
77
+ }
78
+ else
79
+ {
80
+ string errorMessage = response?.errorMessage?.ToString() ?? "Failed to join room";
81
+ string errorCode = response?.statusCode != null ? response.statusCode.ToString() : null;
82
+
83
+ var instanceData = context.Instance?.Data;
84
+ var chatIntegration = instanceData?.chatIntegration;
85
+ string userId = GetString(chatIntegration, "userId");
86
+ string username = GetString(chatIntegration, "username");
87
+
88
+ result.Data = new
89
+ {
90
+ chatIntegration = new
91
+ {
92
+ userId,
93
+ username,
94
+ roomId = (string)null,
95
+ error = errorMessage,
96
+ errorCode = errorCode
97
+ }
98
+ };
99
+ }
100
+
101
+ return Task.FromResult(result);
102
+ }
103
+
104
+ private string GetString(dynamic obj, string name)
105
+ {
106
+ if (obj == null) return null;
107
+ try
108
+ {
109
+ if (HasProperty(obj, name))
110
+ {
111
+ var v = GetPropertyValue(obj, name);
112
+ return v?.ToString();
113
+ }
114
+ }
115
+ catch { }
116
+ return null;
117
+ }
118
+ }
@@ -0,0 +1,100 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Text.RegularExpressions;
4
+ using System.Threading.Tasks;
5
+ using BBT.Workflow.Scripting;
6
+ using BBT.Workflow.Definitions;
7
+
8
+ /// <summary>
9
+ /// Mapping for join-matrix-room HttpTask (Type 6).
10
+ /// Joins an existing Matrix room by alias via native /_matrix/client/v3/join/{roomIdOrAlias}.
11
+ /// Used as M_ROOM_IN_USE error boundary fallback.
12
+ /// APISIX converts X-Matrix-User header to Bearer token automatically.
13
+ /// </summary>
14
+ public class JoinMatrixRoomMapping : ScriptBase, IMapping
15
+ {
16
+ public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
17
+ {
18
+ var httpTask = task as HttpTask;
19
+ if (httpTask == null)
20
+ throw new InvalidOperationException("Task must be an HttpTask");
21
+
22
+ var matrixBaseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "MatrixBaseUrl");
23
+ if (string.IsNullOrWhiteSpace(matrixBaseUrl))
24
+ throw new InvalidOperationException("MatrixBaseUrl secret is required");
25
+
26
+ var data = context.Instance?.Data;
27
+ var user = data?.user?.ToString();
28
+ var instanceKey = context.Instance?.Key;
29
+
30
+ var prefixedName = $"{user}_{instanceKey}";
31
+ var aliasName = Regex.Replace(prefixedName.ToLower(), @"[^a-z0-9_]", "-");
32
+ var alias = $"#{aliasName}:localhost";
33
+ var encodedAlias = Uri.EscapeDataString(alias);
34
+
35
+ var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/join/" + encodedAlias;
36
+ httpTask.SetUrl(fullUrl);
37
+
38
+ var headers = new Dictionary<string, string>
39
+ {
40
+ ["Content-Type"] = "application/json",
41
+ ["X-Matrix-User"] = user
42
+ };
43
+ httpTask.SetHeaders(headers);
44
+ httpTask.SetBody(new { });
45
+
46
+ return new ScriptResponse();
47
+ }
48
+
49
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
50
+ {
51
+ var result = new ScriptResponse();
52
+ var response = context.Body;
53
+
54
+ string roomId = GetString(response, "room_id");
55
+ string errcode = GetString(response, "errcode");
56
+ string errorMsg = GetString(response, "error");
57
+
58
+ if (!string.IsNullOrEmpty(errcode))
59
+ {
60
+ result.Data = new
61
+ {
62
+ chatIntegration = new
63
+ {
64
+ roomId = (string)null,
65
+ error = errorMsg,
66
+ errorCode = errcode
67
+ }
68
+ };
69
+ }
70
+ else
71
+ {
72
+ result.Data = new
73
+ {
74
+ chatIntegration = new
75
+ {
76
+ roomId,
77
+ error = (string)null,
78
+ errorCode = (string)null
79
+ }
80
+ };
81
+ }
82
+
83
+ return Task.FromResult(result);
84
+ }
85
+
86
+ private string GetString(dynamic obj, string name)
87
+ {
88
+ if (obj == null) return null;
89
+ try
90
+ {
91
+ if (HasProperty(obj, name))
92
+ {
93
+ var v = GetPropertyValue(obj, name);
94
+ return v?.ToString();
95
+ }
96
+ }
97
+ catch { }
98
+ return null;
99
+ }
100
+ }