@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,80 @@
1
+ using System;
2
+ using System.Threading.Tasks;
3
+ using BBT.Workflow.Scripting;
4
+ using BBT.Workflow.Definitions;
5
+
6
+ /// <summary>
7
+ /// Mapping for get-rezervation-state-task in randevu-update flow.
8
+ /// Same logic as GetRezervationStateMapping - gets state by randevuKey.
9
+ /// </summary>
10
+ public class GetRezervationStateForRandevuUpdateMapping : ScriptBase, IMapping
11
+ {
12
+ public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
13
+ {
14
+ var serviceTask = task as DaprServiceTask;
15
+ if (serviceTask == null)
16
+ throw new InvalidOperationException("Task must be a DaprServiceTask");
17
+
18
+ var appId = GetConfigValue("DAPR_APP_ID");
19
+ if (!string.IsNullOrEmpty(appId))
20
+ serviceTask.SetAppId(appId);
21
+
22
+ var data = context.Instance?.Data;
23
+ var randevuKey = GetString(data, "randevuKey");
24
+ if (string.IsNullOrWhiteSpace(randevuKey))
25
+ throw new InvalidOperationException("randevuKey is required");
26
+
27
+ var path = $"api/v1/touch/workflows/rezervation/instances/{Uri.EscapeDataString(randevuKey)}/functions/state";
28
+ serviceTask.SetMethodName(path);
29
+
30
+ return Task.FromResult(new ScriptResponse());
31
+ }
32
+
33
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
34
+ {
35
+ var response = context.Body;
36
+ if (response?.isSuccess != true)
37
+ {
38
+ return Task.FromResult(new ScriptResponse
39
+ {
40
+ Key = "rezervation-not-found",
41
+ Data = new
42
+ {
43
+ state = (string)null,
44
+ error = response?.errorMessage?.ToString() ?? "Failed to get rezervation state",
45
+ errorCode = "REZERVATION_NOT_FOUND"
46
+ }
47
+ });
48
+ }
49
+
50
+ var respData = response?.data ?? response?.Data;
51
+ var state = GetString(respData, "state") ?? GetString(respData, "currentState");
52
+ var data = context.Instance?.Data;
53
+ var result = new
54
+ {
55
+ state = state ?? "unknown",
56
+ randevuKey = GetString(data, "randevuKey")
57
+ };
58
+
59
+ return Task.FromResult(new ScriptResponse
60
+ {
61
+ Key = "rezervation-state-success",
62
+ Data = result
63
+ });
64
+ }
65
+
66
+ private string GetString(dynamic obj, string name)
67
+ {
68
+ if (obj == null) return null;
69
+ try
70
+ {
71
+ if (HasProperty(obj, name))
72
+ {
73
+ var v = GetPropertyValue(obj, name);
74
+ return v?.ToString();
75
+ }
76
+ }
77
+ catch { }
78
+ return null;
79
+ }
80
+ }
@@ -0,0 +1,92 @@
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 get-rezervation-state-task DaprServiceTask.
9
+ /// Calls api/v1/touch/workflows/rezervation/instances/{randevuKey}/functions/state
10
+ /// State response: { "state": "active", "status": "A", "transitions": [...], ... } - NO user, advisor, chatIntegration.
11
+ /// Output: state only. Use get-rezervation-data-task for user, advisor, startDateTime, chatIntegration.
12
+ /// </summary>
13
+ public class GetRezervationStateMapping : ScriptBase, IMapping
14
+ {
15
+ public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
16
+ {
17
+ var serviceTask = task as DaprServiceTask;
18
+ if (serviceTask == null)
19
+ throw new InvalidOperationException("Task must be a DaprServiceTask");
20
+
21
+ var appId = GetConfigValue("DAPR_APP_ID");
22
+ if (!string.IsNullOrEmpty(appId))
23
+ serviceTask.SetAppId(appId);
24
+
25
+ var data = context.Instance?.Data;
26
+ var randevuKey = GetString(data, "randevuKey");
27
+ if (string.IsNullOrWhiteSpace(randevuKey))
28
+ throw new InvalidOperationException("randevuKey is required");
29
+
30
+ var path = $"api/v1/touch/workflows/rezervation/instances/{Uri.EscapeDataString(randevuKey)}/functions/state";
31
+ serviceTask.SetMethodName(path);
32
+
33
+ return Task.FromResult(new ScriptResponse());
34
+ }
35
+
36
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
37
+ {
38
+ var response = context.Body;
39
+ if (response?.isSuccess != true)
40
+ {
41
+ return Task.FromResult(new ScriptResponse
42
+ {
43
+ Key = "rezervation-not-found",
44
+ Data = new
45
+ {
46
+ state = (string)null,
47
+ error = response?.errorMessage?.ToString() ?? "Failed to get rezervation state",
48
+ errorCode = "REZERVATION_NOT_FOUND"
49
+ }
50
+ });
51
+ }
52
+
53
+ // State response: { "state": "active", "status": "A", "transitions": [...], "data": {...}, "view": {...} }
54
+ // state is at root level
55
+ var respData = response?.data ?? response?.Data;
56
+ var state = GetString(respData, "state") ?? GetString(respData, "currentState");
57
+
58
+ var data = context.Instance?.Data;
59
+ var result = new Dictionary<string, object>
60
+ {
61
+ { "state", state ?? "unknown" },
62
+ { "randevuKey", GetString(data, "randevuKey") }
63
+ };
64
+ var participantType = GetString(data, "participantType");
65
+ if (!string.IsNullOrEmpty(participantType))
66
+ result["participantType"] = participantType;
67
+ var invitedUserId = GetString(data, "invitedUserId");
68
+ if (!string.IsNullOrEmpty(invitedUserId))
69
+ result["invitedUserId"] = invitedUserId;
70
+
71
+ return Task.FromResult(new ScriptResponse
72
+ {
73
+ Key = "rezervation-state-success",
74
+ Data = result
75
+ });
76
+ }
77
+
78
+ private string GetString(dynamic obj, string name)
79
+ {
80
+ if (obj == null) return null;
81
+ try
82
+ {
83
+ if (HasProperty(obj, name))
84
+ {
85
+ var v = GetPropertyValue(obj, name);
86
+ return v?.ToString();
87
+ }
88
+ }
89
+ catch { }
90
+ return null;
91
+ }
92
+ }
@@ -0,0 +1,63 @@
1
+ using System;
2
+ using System.Threading.Tasks;
3
+ using BBT.Workflow.Scripting;
4
+ using BBT.Workflow.Scripting.Functions;
5
+ using BBT.Workflow.Definitions;
6
+
7
+ /// <summary>
8
+ /// Mapping for get-user-info-for-rezervation HttpTask.
9
+ /// Gets user from instance data (set at start by set-user-from-headers-for-rezervation from Headers sub), userSegmentBaseUrl from vault (GetSecretAsync), builds GET url/user-info/{user}, sets URL on HttpTask.
10
+ /// Output merges user-info response as userInfo for order 2 (start-notification-sender) to use.
11
+ /// </summary>
12
+ public class GetUserInfoForRezervationMapping : 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 data = context.Instance?.Data;
21
+ var user = GetString(data, "sub");
22
+ if (string.IsNullOrWhiteSpace(user))
23
+ throw new InvalidOperationException("Instance data sub is required for user-info call (set at start from Headers sub)");
24
+
25
+ var baseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "UserSegmentBaseUrl");
26
+ if (string.IsNullOrWhiteSpace(baseUrl))
27
+ throw new InvalidOperationException("UserSegmentBaseUrl secret is required");
28
+
29
+ var trimmedBase = baseUrl.TrimEnd('/');
30
+ var fullUrl = trimmedBase + "/user-info/" + Uri.EscapeDataString(user.Trim());
31
+
32
+ httpTask.SetUrl(fullUrl);
33
+
34
+ return new ScriptResponse();
35
+ }
36
+
37
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
38
+ {
39
+ var response = context.Body;
40
+ var raw = response?.data ?? response?.Data ?? response;
41
+ var userInfo = raw;
42
+
43
+ return Task.FromResult(new ScriptResponse
44
+ {
45
+ Data = new { userInfo }
46
+ });
47
+ }
48
+
49
+ private string GetString(dynamic obj, string name)
50
+ {
51
+ if (obj == null) return null;
52
+ try
53
+ {
54
+ if (HasProperty(obj, name))
55
+ {
56
+ var v = GetPropertyValue(obj, name);
57
+ return v?.ToString();
58
+ }
59
+ }
60
+ catch { }
61
+ return null;
62
+ }
63
+ }
@@ -0,0 +1,62 @@
1
+ using System;
2
+ using System.Threading.Tasks;
3
+ using BBT.Workflow.Scripting;
4
+ using BBT.Workflow.Definitions;
5
+
6
+ /// <summary>
7
+ /// Mapping for get-video-call-url Script Task (Type 7).
8
+ /// Builds LiveKit video call page URL: baseUrl/?room=roomName&amp;user=participantName&amp;autoJoin=1
9
+ /// participantName = user when status is customer-enter, advisor when status is staff-enter.
10
+ /// Base URL is read from vault (VideoCallBaseUrl).
11
+ /// </summary>
12
+ public class GetVideoCallUrlMapping : ScriptBase, IMapping
13
+ {
14
+ public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
15
+ {
16
+ return Task.FromResult(new ScriptResponse());
17
+ }
18
+
19
+ public async Task<ScriptResponse> OutputHandler(ScriptContext context)
20
+ {
21
+ var data = context.Instance?.Data;
22
+ var roomName = data?.roomName?.ToString()?.Trim();
23
+ if (string.IsNullOrEmpty(roomName) && data != null && HasProperty(data, "key"))
24
+ roomName = data.key?.ToString()?.Trim();
25
+
26
+ var status = data?.status?.ToString()?.Trim();
27
+ var user = data?.user?.ToString()?.Trim();
28
+ var advisor = data?.advisor?.ToString()?.Trim();
29
+
30
+ var participantName = status == "customer-enter" ? user : advisor;
31
+
32
+ if (string.IsNullOrEmpty(roomName) || string.IsNullOrEmpty(participantName))
33
+ {
34
+ return new ScriptResponse
35
+ {
36
+ Data = new
37
+ {
38
+ videoCallUrl = (string)null,
39
+ getTokenSuccess = false,
40
+ getTokenError = "Missing roomName or participantName"
41
+ }
42
+ };
43
+ }
44
+
45
+ var baseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "VideoCallBaseUrl");
46
+ if (string.IsNullOrWhiteSpace(baseUrl))
47
+ throw new InvalidOperationException("VideoCallBaseUrl secret is required");
48
+
49
+ var videoCallUrl = baseUrl.TrimEnd('/') + "?room=" + Uri.EscapeDataString(roomName)
50
+ + "&user=" + Uri.EscapeDataString(participantName)
51
+ + "&autoJoin=1";
52
+
53
+ return new ScriptResponse
54
+ {
55
+ Data = new
56
+ {
57
+ videoCallUrl,
58
+ getTokenSuccess = true
59
+ }
60
+ };
61
+ }
62
+ }
@@ -0,0 +1,28 @@
1
+ using System.Threading.Tasks;
2
+ using BBT.Workflow.Scripting;
3
+
4
+ /// <summary>
5
+ /// Condition for chat-init: hasExistingPermanentRoom == true AND existingRoomAdvisorMatches == false -> to-change-advisor transition to in-chat.
6
+ /// </summary>
7
+ public class HasChangedAdvisorRule : ScriptBase, IConditionMapping
8
+ {
9
+ public Task<bool> Handler(ScriptContext context)
10
+ {
11
+ var data = context.Instance?.Data;
12
+ if (data == null) return Task.FromResult(false);
13
+ try
14
+ {
15
+ return Task.FromResult(GetBool(data, "hasExistingPermanentRoom") && !GetBool(data, "existingRoomAdvisorMatches"));
16
+ }
17
+ catch { return Task.FromResult(false); }
18
+ }
19
+
20
+ private bool GetBool(dynamic data, string name)
21
+ {
22
+ if (data == null || !HasProperty(data, name)) return false;
23
+ var v = GetPropertyValue(data, name);
24
+ if (v == null) return false;
25
+ if (v is bool b) return b;
26
+ return string.Equals(v.ToString(), "true", System.StringComparison.OrdinalIgnoreCase);
27
+ }
28
+ }
@@ -0,0 +1,41 @@
1
+ using System;
2
+ using System.Threading.Tasks;
3
+ using BBT.Workflow.Scripting;
4
+ using BBT.Workflow.Definitions;
5
+
6
+ /// <summary>
7
+ /// Condition for add-participant-to-rezervation flow: chatIntegration exists and has roomId.
8
+ /// Returns true when chat room is available for inviting new participant.
9
+ /// </summary>
10
+ public class HasChatIntegrationRule : ScriptBase, IConditionMapping
11
+ {
12
+ public Task<bool> Handler(ScriptContext context)
13
+ {
14
+ var data = context.Instance?.Data;
15
+ if (data == null)
16
+ return Task.FromResult(false);
17
+
18
+ var chatIntegration = data?.chatIntegration;
19
+ if (chatIntegration == null)
20
+ return Task.FromResult(false);
21
+
22
+ var roomId = GetString(chatIntegration, "roomId");
23
+
24
+ return Task.FromResult(!string.IsNullOrWhiteSpace(roomId));
25
+ }
26
+
27
+ private string GetString(dynamic obj, string name)
28
+ {
29
+ if (obj == null) return null;
30
+ try
31
+ {
32
+ if (HasProperty(obj, name))
33
+ {
34
+ var v = GetPropertyValue(obj, name);
35
+ return v?.ToString();
36
+ }
37
+ }
38
+ catch { }
39
+ return null;
40
+ }
41
+ }
@@ -0,0 +1,28 @@
1
+ using System.Threading.Tasks;
2
+ using BBT.Workflow.Scripting;
3
+
4
+ /// <summary>
5
+ /// Condition for chat-init: hasExistingPermanentRoom == true AND existingRoomAdvisorMatches == true -> open-existing-room transition to in-chat.
6
+ /// </summary>
7
+ public class HasExistingPermanentRoomRule : ScriptBase, IConditionMapping
8
+ {
9
+ public Task<bool> Handler(ScriptContext context)
10
+ {
11
+ var data = context.Instance?.Data;
12
+ if (data == null) return Task.FromResult(false);
13
+ try
14
+ {
15
+ return Task.FromResult(GetBool(data, "hasExistingPermanentRoom") && GetBool(data, "existingRoomAdvisorMatches"));
16
+ }
17
+ catch { return Task.FromResult(false); }
18
+ }
19
+
20
+ private bool GetBool(dynamic data, string name)
21
+ {
22
+ if (data == null || !HasProperty(data, name)) return false;
23
+ var v = GetPropertyValue(data, name);
24
+ if (v == null) return false;
25
+ if (v is bool b) return b;
26
+ return string.Equals(v.ToString(), "true", System.StringComparison.OrdinalIgnoreCase);
27
+ }
28
+ }
@@ -0,0 +1,86 @@
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 invite-user-to-rezervation-room in randevu-update flow.
9
+ /// Invites new advisor to Matrix room when advisor has changed (advisor != originalAdvisor).
10
+ /// </summary>
11
+ public class InviteAdvisorForRandevuUpdateMapping : 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
+ if (data == null)
21
+ return new ScriptResponse();
22
+
23
+ var advisor = GetString(data, "advisor");
24
+ var originalAdvisor = GetString(data, "originalAdvisor");
25
+
26
+ if (string.IsNullOrEmpty(advisor) || string.Equals(advisor?.Trim(), originalAdvisor?.Trim(), StringComparison.Ordinal))
27
+ return new ScriptResponse();
28
+
29
+ var chatIntegration = GetValue(data, "chatIntegration");
30
+ var roomId = GetString(chatIntegration, "roomId");
31
+ var user = GetString(data, "user");
32
+
33
+ if (string.IsNullOrWhiteSpace(roomId) || string.IsNullOrWhiteSpace(user))
34
+ return new ScriptResponse();
35
+
36
+ var matrixBaseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "MatrixBaseUrl");
37
+ if (string.IsNullOrWhiteSpace(matrixBaseUrl))
38
+ throw new InvalidOperationException("MatrixBaseUrl secret is required");
39
+ var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/rooms/" + Uri.EscapeDataString(roomId ?? "") + "/invite";
40
+ httpTask.SetUrl(fullUrl);
41
+
42
+ var headers = new Dictionary<string, string>
43
+ {
44
+ ["Content-Type"] = "application/json",
45
+ ["Accept"] = "application/json",
46
+ ["x-matrix-user"] = user.Trim()
47
+ };
48
+ httpTask.SetHeaders(headers);
49
+ var userId = (advisor?.Trim() ?? "").StartsWith("@") ? advisor.Trim() : $"@{advisor?.Trim()}:localhost";
50
+ httpTask.SetBody(new { user_id = userId });
51
+
52
+ return new ScriptResponse();
53
+ }
54
+
55
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
56
+ {
57
+ return Task.FromResult(new ScriptResponse());
58
+ }
59
+
60
+ private string GetString(dynamic obj, string name)
61
+ {
62
+ if (obj == null) return null;
63
+ try
64
+ {
65
+ if (HasProperty(obj, name))
66
+ {
67
+ var v = GetPropertyValue(obj, name);
68
+ return v?.ToString();
69
+ }
70
+ }
71
+ catch { }
72
+ return null;
73
+ }
74
+
75
+ private object GetValue(dynamic obj, string name)
76
+ {
77
+ if (obj == null) return null;
78
+ try
79
+ {
80
+ if (HasProperty(obj, name))
81
+ return GetPropertyValue(obj, name);
82
+ }
83
+ catch { }
84
+ return null;
85
+ }
86
+ }
@@ -0,0 +1,78 @@
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 invite-user-to-rezervation-room HttpTask (Type 6).
9
+ /// Invites new advisor to existing Matrix room via native /_matrix/client/v3/rooms/{roomId}/invite.
10
+ /// APISIX converts X-Matrix-User header to Bearer token automatically.
11
+ /// Formats target user ID as @{user}:localhost per Matrix spec.
12
+ /// </summary>
13
+ public class InviteNewAdvisorToRezervationRoomMapping : ScriptBase, IMapping
14
+ {
15
+ public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
16
+ {
17
+ var httpTask = task as HttpTask;
18
+ if (httpTask == null)
19
+ throw new InvalidOperationException("Task must be an HttpTask");
20
+
21
+ var data = context.Instance?.Data;
22
+ if (data == null)
23
+ return new ScriptResponse();
24
+
25
+ var user = GetString(data, "user");
26
+ var advisor = GetString(data, "advisor");
27
+ var previousAdvisor = GetString(data, "previousAdvisor");
28
+
29
+ if (string.IsNullOrEmpty(advisor) || string.Equals(advisor?.Trim(), previousAdvisor?.Trim(), StringComparison.Ordinal))
30
+ return new ScriptResponse();
31
+
32
+ var chatIntegration = data?.chatIntegration;
33
+ var roomId = GetString(chatIntegration, "roomId");
34
+
35
+ if (string.IsNullOrWhiteSpace(roomId))
36
+ return new ScriptResponse();
37
+
38
+ var matrixBaseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "MatrixBaseUrl");
39
+ if (string.IsNullOrWhiteSpace(matrixBaseUrl))
40
+ throw new InvalidOperationException("MatrixBaseUrl secret is required");
41
+ var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/rooms/" + Uri.EscapeDataString(roomId) + "/invite";
42
+ httpTask.SetUrl(fullUrl);
43
+
44
+ var matrixUserId = advisor.Trim().StartsWith("@") ? advisor.Trim() : $"@{advisor.Trim()}:localhost";
45
+
46
+ var headers = new Dictionary<string, string>
47
+ {
48
+ ["Content-Type"] = "application/json",
49
+ ["Accept"] = "application/json",
50
+ ["X-Matrix-User"] = user
51
+ };
52
+ httpTask.SetHeaders(headers);
53
+
54
+ httpTask.SetBody(new { user_id = matrixUserId });
55
+
56
+ return new ScriptResponse();
57
+ }
58
+
59
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
60
+ {
61
+ return Task.FromResult(new ScriptResponse());
62
+ }
63
+
64
+ private string GetString(dynamic obj, string name)
65
+ {
66
+ if (obj == null) return null;
67
+ try
68
+ {
69
+ if (HasProperty(obj, name))
70
+ {
71
+ var v = GetPropertyValue(obj, name);
72
+ return v?.ToString();
73
+ }
74
+ }
75
+ catch { }
76
+ return null;
77
+ }
78
+ }
@@ -0,0 +1,88 @@
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 invite-user-to-rezervation-room HttpTask when used in add-participant-to-rezervation flow.
9
+ /// Invites newUserId to existing Matrix chat room. Uses x-matrix-user header; inviter = chatIntegration.username (or advisor).
10
+ /// </summary>
11
+ public class InviteNewParticipantToRandevuRoomMapping : 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
+ if (data == null)
21
+ return new ScriptResponse();
22
+
23
+ var newUserId = GetString(data, "newUserId");
24
+ if (string.IsNullOrWhiteSpace(newUserId))
25
+ return new ScriptResponse();
26
+
27
+ var chatIntegration = GetChatIntegration(data);
28
+ var roomId = GetString(chatIntegration, "roomId");
29
+ var inviter = GetString(chatIntegration, "username") ?? GetString(data, "advisor") ?? GetString(data, "user");
30
+
31
+ if (string.IsNullOrWhiteSpace(roomId))
32
+ return new ScriptResponse();
33
+
34
+ var matrixBaseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "MatrixBaseUrl");
35
+ if (string.IsNullOrWhiteSpace(matrixBaseUrl))
36
+ throw new InvalidOperationException("MatrixBaseUrl secret is required");
37
+ var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/rooms/" + Uri.EscapeDataString(roomId ?? "") + "/invite";
38
+ httpTask.SetUrl(fullUrl);
39
+
40
+ var headers = new Dictionary<string, string>
41
+ {
42
+ ["Content-Type"] = "application/json",
43
+ ["Accept"] = "application/json"
44
+ };
45
+ if (!string.IsNullOrWhiteSpace(inviter))
46
+ headers["x-matrix-user"] = inviter.Trim();
47
+
48
+ httpTask.SetHeaders(headers);
49
+ var userId = newUserId.Trim().StartsWith("@") ? newUserId.Trim() : $"@{newUserId.Trim()}:localhost";
50
+ httpTask.SetBody(new { user_id = userId });
51
+
52
+ return new ScriptResponse();
53
+ }
54
+
55
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
56
+ {
57
+ return Task.FromResult(new ScriptResponse());
58
+ }
59
+
60
+ private string GetString(dynamic obj, string name)
61
+ {
62
+ if (obj == null) return null;
63
+ try
64
+ {
65
+ if (HasProperty(obj, name))
66
+ {
67
+ var v = GetPropertyValue(obj, name);
68
+ return v?.ToString();
69
+ }
70
+ }
71
+ catch { }
72
+ return null;
73
+ }
74
+
75
+ private dynamic GetChatIntegration(dynamic data)
76
+ {
77
+ if (data == null) return null;
78
+ try
79
+ {
80
+ if (HasProperty(data, "chatIntegration"))
81
+ {
82
+ return GetPropertyValue(data, "chatIntegration");
83
+ }
84
+ }
85
+ catch { }
86
+ return null;
87
+ }
88
+ }