@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,140 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Threading.Tasks;
4
+ using BBT.Workflow.Scripting;
5
+ using BBT.Workflow.Definitions;
6
+ /// <summary>
7
+ /// Mapping for GetCustomerInfoTask (DaprServiceTask - Type 3)
8
+ /// Fetches customer information (name, surname, segment) from the UserSegmentBaseUrl endpoint.
9
+ ///
10
+ /// Query parameters:
11
+ /// - customerId (required): customer identifier (TCKN or customer number)
12
+ ///
13
+ /// The task calls the external API configured via UserSegmentBaseUrl secret in Vault.
14
+ /// </summary>
15
+ public class GetCustomerInfoMapping : ScriptBase, IMapping
16
+ {
17
+ public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
18
+ {
19
+ var serviceTask = task as DaprServiceTask;
20
+ if (serviceTask == null)
21
+ throw new InvalidOperationException("Task must be a DaprServiceTask");
22
+
23
+ var customerId = ReadParam(context, "customerId");
24
+ if (string.IsNullOrEmpty(customerId))
25
+ {
26
+ return new ScriptResponse
27
+ {
28
+ Key = "validation-error",
29
+ Data = new
30
+ {
31
+ error = "customerId is required",
32
+ errorCode = "VALIDATION_ERROR"
33
+ }
34
+ };
35
+ }
36
+
37
+ var secretStore = context.DaprClient;
38
+ string baseUrl = "";
39
+ try
40
+ {
41
+ var secrets = await secretStore.GetSecretAsync("vault", "UserSegmentBaseUrl");
42
+ if (secrets != null && secrets.ContainsKey("UserSegmentBaseUrl"))
43
+ baseUrl = secrets["UserSegmentBaseUrl"];
44
+ }
45
+ catch
46
+ {
47
+ return new ScriptResponse
48
+ {
49
+ Key = "config-error",
50
+ Data = new
51
+ {
52
+ error = "UserSegmentBaseUrl secret not configured in Vault",
53
+ errorCode = "CONFIG_ERROR"
54
+ }
55
+ };
56
+ }
57
+
58
+ if (string.IsNullOrEmpty(baseUrl))
59
+ {
60
+ return new ScriptResponse
61
+ {
62
+ Key = "config-error",
63
+ Data = new
64
+ {
65
+ error = "UserSegmentBaseUrl is empty or not found",
66
+ errorCode = "CONFIG_ERROR"
67
+ }
68
+ };
69
+ }
70
+
71
+ serviceTask.SetUrl(baseUrl);
72
+ serviceTask.SetQueryString($"customerId={customerId}");
73
+
74
+ return new ScriptResponse();
75
+ }
76
+
77
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
78
+ {
79
+ try
80
+ {
81
+ var customerId = ReadParam(context, "customerId");
82
+ var response = context.Body;
83
+
84
+ if (response?.isSuccess == false)
85
+ {
86
+ return Task.FromResult(new ScriptResponse
87
+ {
88
+ Key = "service-error",
89
+ Data = new
90
+ {
91
+ error = "Failed to fetch customer info",
92
+ errorCode = "SERVICE_ERROR",
93
+ errorMessage = response?.errorMessage?.ToString()
94
+ },
95
+ Tags = new[] { "customer-info", "error" }
96
+ });
97
+ }
98
+
99
+ var data = response?.data ?? response;
100
+
101
+ return Task.FromResult(new ScriptResponse
102
+ {
103
+ Key = "customer-info-success",
104
+ Data = new
105
+ {
106
+ customerId,
107
+ name = data?.name?.ToString() ?? data?.firstName?.ToString() ?? "",
108
+ surname = data?.surname?.ToString() ?? data?.lastName?.ToString() ?? "",
109
+ segment = data?.segment?.ToString() ?? "",
110
+ channelSegment = data?.channelSegment?.ToString() ?? "",
111
+ email = data?.email?.ToString() ?? "",
112
+ phone = data?.phone?.ToString() ?? ""
113
+ },
114
+ Tags = new[] { "customer-info", "success" }
115
+ });
116
+ }
117
+ catch (Exception ex)
118
+ {
119
+ return Task.FromResult(new ScriptResponse
120
+ {
121
+ Key = "output-error",
122
+ Data = new
123
+ {
124
+ error = "Internal processing error",
125
+ errorCode = "PROCESSING_ERROR",
126
+ errorDescription = ex.Message
127
+ },
128
+ Tags = new[] { "customer-info", "error" }
129
+ });
130
+ }
131
+ }
132
+
133
+ private string ReadParam(ScriptContext context, string name)
134
+ {
135
+ if (context.QueryParameters == null || !HasProperty(context.QueryParameters, name))
136
+ return null;
137
+ var val = context.QueryParameters[name];
138
+ return val != null ? val.ToString() : null;
139
+ }
140
+ }
@@ -0,0 +1,197 @@
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-matrix-sync HttpTask (Type 6).
9
+ /// Flow-level function (scope: F) -- no instance context.
10
+ /// Reads user, since, timeout, roomId from query parameters.
11
+ /// Calls GET /_matrix/client/v3/sync via APISIX. Supports long polling.
12
+ /// Returns next_batch token and eventsByRoom (m.room.message events per room).
13
+ /// </summary>
14
+ public class GetMatrixSyncMapping : 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 user = ReadParam(context, "user");
27
+ if (string.IsNullOrWhiteSpace(user))
28
+ throw new InvalidOperationException("VALIDATION_ERROR: user query parameter is required");
29
+
30
+ var since = ReadParam(context, "since");
31
+ var timeout = ReadParam(context, "timeout");
32
+ if (string.IsNullOrWhiteSpace(timeout))
33
+ timeout = "30000";
34
+
35
+ var roomId = ReadParam(context, "roomId");
36
+
37
+ var qs = "timeout=" + Uri.EscapeDataString(timeout);
38
+ if (!string.IsNullOrWhiteSpace(since))
39
+ qs += "&since=" + Uri.EscapeDataString(since);
40
+ if (!string.IsNullOrWhiteSpace(roomId))
41
+ {
42
+ var filter = "{\"room\":{\"rooms\":[\"" + roomId.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"]}}";
43
+ qs += "&filter=" + Uri.EscapeDataString(filter);
44
+ }
45
+
46
+ var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/sync?" + qs;
47
+ httpTask.SetUrl(fullUrl);
48
+
49
+ var headers = new Dictionary<string, string>
50
+ {
51
+ ["Accept"] = "application/json",
52
+ ["X-Matrix-User"] = user
53
+ };
54
+ httpTask.SetHeaders(headers);
55
+
56
+ return new ScriptResponse();
57
+ }
58
+
59
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
60
+ {
61
+ try
62
+ {
63
+ var response = context.Body;
64
+ var bodyData = response?.data;
65
+
66
+ string errcode = GetString(bodyData, "errcode");
67
+ if (!string.IsNullOrEmpty(errcode))
68
+ {
69
+ string errorMsg = GetString(bodyData, "error");
70
+ return Task.FromResult(new ScriptResponse
71
+ {
72
+ Key = "get-matrix-sync-error",
73
+ Data = new
74
+ {
75
+ error = errorMsg,
76
+ errorCode = errcode,
77
+ nextBatch = (string)null,
78
+ eventsByRoom = new Dictionary<string, List<object>>()
79
+ },
80
+ Tags = new[] { "chat", "sync", "error" }
81
+ });
82
+ }
83
+
84
+ string nextBatch = GetString(bodyData, "next_batch");
85
+ var eventsByRoom = new Dictionary<string, List<object>>();
86
+
87
+ var rooms = GetPropertyValue(bodyData, "rooms");
88
+ if (rooms != null && HasProperty(rooms, "join"))
89
+ {
90
+ var join = GetPropertyValue(rooms, "join");
91
+ if (join != null)
92
+ {
93
+ try
94
+ {
95
+ foreach (dynamic kv in (System.Collections.IEnumerable)join)
96
+ {
97
+ string rId = kv.Key?.ToString();
98
+ if (string.IsNullOrWhiteSpace(rId)) continue;
99
+
100
+ dynamic roomData = kv.Value;
101
+ if (roomData == null) continue;
102
+
103
+ var timeline = roomData.timeline;
104
+ if (timeline == null) continue;
105
+
106
+ var events = timeline.events;
107
+ if (events == null) continue;
108
+
109
+ var msgList = new List<object>();
110
+ foreach (var evt in events)
111
+ {
112
+ var evtType = GetString(evt, "type");
113
+ if (evtType != "m.room.message") continue;
114
+
115
+ var content = GetPropertyValue(evt, "content");
116
+ if (content == null) continue;
117
+
118
+ string body = GetString(content, "body");
119
+ string msgtype = GetString(content, "msgtype");
120
+ string sender = GetString(evt, "sender");
121
+ string eventId = GetString(evt, "event_id");
122
+ var tsObj = GetPropertyValue(evt, "origin_server_ts");
123
+ string ts = tsObj != null ? tsObj.ToString() : null;
124
+
125
+ msgList.Add(new
126
+ {
127
+ eventId = eventId,
128
+ sender = sender,
129
+ body = body,
130
+ timestamp = ts,
131
+ msgtype = msgtype ?? "m.text"
132
+ });
133
+ }
134
+
135
+ if (msgList.Count > 0)
136
+ eventsByRoom[rId] = msgList;
137
+ }
138
+ }
139
+ catch (Exception)
140
+ {
141
+ // Fallback: join may have different structure
142
+ }
143
+ }
144
+ }
145
+
146
+ return Task.FromResult(new ScriptResponse
147
+ {
148
+ Key = "get-matrix-sync-success",
149
+ Data = new
150
+ {
151
+ nextBatch = nextBatch,
152
+ eventsByRoom = eventsByRoom
153
+ },
154
+ Tags = new[] { "chat", "sync", "success" }
155
+ });
156
+ }
157
+ catch (Exception ex)
158
+ {
159
+ return Task.FromResult(new ScriptResponse
160
+ {
161
+ Key = "get-matrix-sync-error",
162
+ Data = new
163
+ {
164
+ error = "Internal processing error",
165
+ errorCode = "PROCESSING_ERROR",
166
+ errorDescription = ex.Message,
167
+ nextBatch = (string)null,
168
+ eventsByRoom = new Dictionary<string, List<object>>()
169
+ },
170
+ Tags = new[] { "chat", "sync", "error" }
171
+ });
172
+ }
173
+ }
174
+
175
+ private string ReadParam(ScriptContext context, string name)
176
+ {
177
+ if (context.QueryParameters == null || !HasProperty(context.QueryParameters, name))
178
+ return null;
179
+ var val = context.QueryParameters[name];
180
+ return val != null ? val.ToString() : null;
181
+ }
182
+
183
+ private string GetString(dynamic obj, string name)
184
+ {
185
+ if (obj == null) return null;
186
+ try
187
+ {
188
+ if (HasProperty(obj, name))
189
+ {
190
+ var v = GetPropertyValue(obj, name);
191
+ return v?.ToString();
192
+ }
193
+ }
194
+ catch { }
195
+ return null;
196
+ }
197
+ }
@@ -0,0 +1,162 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Linq;
4
+ using System.Threading.Tasks;
5
+ using BBT.Workflow.Scripting;
6
+ using BBT.Workflow.Definitions;
7
+ /// <summary>
8
+ /// Mapping for GetAvailableSlotsTask (DaprServiceTask - Type 3)
9
+ /// Queries absence-entry workflow via Dapr service invocation to get public holidays,
10
+ /// working hours changes, and personal leaves.
11
+ /// Then calculates available appointment slots for the given advisor and date.
12
+ ///
13
+ /// Reference: https://github.com/burgan-tech/vnext-runtime/blob/main/doc/en/flow/tasks/dapr-service.md
14
+ /// </summary>
15
+ public class GetRezervationsMapping : ScriptBase, IMapping
16
+ {
17
+ public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
18
+ {
19
+ var serviceTask = task as DaprServiceTask;
20
+ if (serviceTask == null)
21
+ throw new InvalidOperationException("Task must be a DaprServiceTask");
22
+
23
+ var appId = GetConfigValue("DAPR_APP_ID");
24
+ if (!string.IsNullOrEmpty(appId))
25
+ serviceTask.SetAppId(appId);
26
+
27
+ // Read parameters from query string (GET request)
28
+ var advisorId = context.QueryParameters != null && HasProperty(context.QueryParameters, "advisorId") ? context.QueryParameters?["advisorId"]?.ToString() : string.Empty;
29
+ var userId = context.QueryParameters != null && HasProperty(context.QueryParameters, "userId") ? context.QueryParameters?["userId"]?.ToString() : string.Empty;
30
+ var managerId = context.QueryParameters != null && HasProperty(context.QueryParameters, "managerId") ? context.QueryParameters?["managerId"]?.ToString() : string.Empty;
31
+ var startDate = context.QueryParameters != null && HasProperty(context.QueryParameters, "startDate") ? context.QueryParameters?["startDate"]?.ToString() : string.Empty;
32
+ var endDate = context.QueryParameters != null && HasProperty(context.QueryParameters, "endDate") ? context.QueryParameters?["endDate"]?.ToString() : string.Empty;
33
+
34
+ // Build filter conditions
35
+ var conditions = new List<string>();
36
+
37
+ // CurrentState in ("active", "can-start-meeting", "accept-terms")
38
+ conditions.Add(
39
+ "{\"or\":[" +
40
+ "{\"currentState\":{\"eq\":\"active\"}}," +
41
+ "{\"currentState\":{\"eq\":\"in-meet\"}}," +
42
+ "{\"currentState\":{\"eq\":\"accept-terms\"}}" +
43
+ "]}");
44
+
45
+ // Status = "A"
46
+ conditions.Add("{\"status\":{\"eq\":\"A\"}}");
47
+
48
+ // Conditional: advisor filter
49
+ if (!string.IsNullOrEmpty(advisorId))
50
+ conditions.Add("{\"attributes\":{\"advisor\":{\"eq\":\"" + advisorId + "\"}}}");
51
+
52
+ // Conditional: user filter
53
+ if (!string.IsNullOrEmpty(userId))
54
+ conditions.Add("{\"attributes\":{\"user\":{\"eq\":\"" + userId + "\"}}}");
55
+
56
+ // Conditional: manager filter
57
+ if (!string.IsNullOrEmpty(managerId))
58
+ conditions.Add("{\"attributes\":{\"manager\":{\"eq\":\"" + managerId + "\"}}}");
59
+
60
+ // Conditional: startDate filter (attributes.startDateTime >= startDate)
61
+ if (!string.IsNullOrEmpty(startDate))
62
+ conditions.Add("{\"attributes\":{\"startDateTime\":{\"gte\":\"" + startDate + "\"}}}");
63
+
64
+ // Conditional: endDate filter (attributes.endDateTime <= endDate)
65
+ if (!string.IsNullOrEmpty(endDate))
66
+ conditions.Add("{\"attributes\":{\"endDateTime\":{\"lte\":\"" + endDate + "\"}}}");
67
+
68
+ var filterJson = "{\"and\":[" + string.Join(",", conditions) + "]}";
69
+
70
+ var queryParams = new List<string>{
71
+ "pageSize=100",
72
+ $"filter={filterJson}"
73
+ };
74
+
75
+ serviceTask.SetQueryString(string.Join("&", queryParams));
76
+ return Task.FromResult(new ScriptResponse());
77
+ }
78
+
79
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
80
+ {
81
+ try
82
+ {
83
+ var response = context.Body;
84
+
85
+ // Check if service call was successful
86
+ if (response?.isSuccess == false)
87
+ {
88
+ var errorType = ClassifyServiceError(response?.errorMessage?.ToString() ?? "");
89
+
90
+ return Task.FromResult(new ScriptResponse
91
+ {
92
+ Key = "service-error",
93
+ Data = new
94
+ {
95
+ error = "Failed to fetch absence entries",
96
+ errorCode = "SERVICE_ERROR",
97
+ errorType = errorType,
98
+ errorMessage = response?.errorMessage?.ToString(),
99
+ serviceInfo = new
100
+ {
101
+ appId = response?.metadata?.appId?.ToString(),
102
+ methodName = response?.metadata?.methodName?.ToString(),
103
+ httpVerb = response?.metadata?.httpVerb?.ToString()
104
+ }
105
+ },
106
+ Tags = new[] { "appointments", "error" }
107
+ });
108
+ }
109
+
110
+ // Get items from service response
111
+ // Response structure: { data: { items: [...] }, isSuccess: true, ... }
112
+ var responseData = response?.data;
113
+ var items = responseData?.items;
114
+
115
+ return Task.FromResult(new ScriptResponse
116
+ {
117
+ Key = "rezervations-success",
118
+ Data = new
119
+ {
120
+ items
121
+ },
122
+ Tags = new[] { "appointments", "availability", "success" }
123
+ });
124
+ }
125
+ catch (Exception ex)
126
+ {
127
+ return Task.FromResult(new ScriptResponse
128
+ {
129
+ Key = "output-error",
130
+ Data = new
131
+ {
132
+ error = "Internal processing error",
133
+ errorCode = "PROCESSING_ERROR",
134
+ errorDescription = ex.Message
135
+ },
136
+ Tags = new[] { "appointments", "error" }
137
+ });
138
+ }
139
+ }
140
+
141
+ #region Helper Methods
142
+
143
+ private string ClassifyServiceError(string errorMessage)
144
+ {
145
+ if (errorMessage.Contains("timeout", StringComparison.OrdinalIgnoreCase))
146
+ return "timeout";
147
+ if (errorMessage.Contains("unauthorized", StringComparison.OrdinalIgnoreCase))
148
+ return "authentication";
149
+ if (errorMessage.Contains("forbidden", StringComparison.OrdinalIgnoreCase))
150
+ return "authorization";
151
+ if (errorMessage.Contains("not found", StringComparison.OrdinalIgnoreCase))
152
+ return "not-found";
153
+ if (errorMessage.Contains("service unavailable", StringComparison.OrdinalIgnoreCase))
154
+ return "service-unavailable";
155
+ if (errorMessage.Contains("connection", StringComparison.OrdinalIgnoreCase))
156
+ return "connection-error";
157
+
158
+ return "general-error";
159
+ }
160
+
161
+ #endregion
162
+ }
@@ -0,0 +1,165 @@
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-matrix-room-messages HttpTask (Type 6).
9
+ /// Flow-level function (scope: F) -- no instance context.
10
+ /// Reads roomId, user, limit, from query parameters.
11
+ /// Calls GET /_matrix/client/v3/rooms/{roomId}/messages via APISIX.
12
+ /// Returns structured message list from Matrix response.
13
+ /// </summary>
14
+ public class GetRoomMessagesMapping : 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 roomId = ReadParam(context, "roomId");
27
+ var user = ReadParam(context, "user");
28
+
29
+ if (string.IsNullOrWhiteSpace(roomId))
30
+ throw new InvalidOperationException("VALIDATION_ERROR: roomId query parameter is required");
31
+ if (string.IsNullOrWhiteSpace(user))
32
+ throw new InvalidOperationException("VALIDATION_ERROR: user query parameter is required");
33
+
34
+ var limit = ReadParam(context, "limit");
35
+ if (string.IsNullOrWhiteSpace(limit))
36
+ limit = "50";
37
+
38
+ var from = ReadParam(context, "from");
39
+
40
+ var fullUrl = matrixBaseUrl.TrimEnd('/') + "/_matrix/client/v3/rooms/" + Uri.EscapeDataString(roomId) + "/messages";
41
+
42
+ var qs = "dir=b&limit=" + limit;
43
+ if (!string.IsNullOrWhiteSpace(from))
44
+ qs += "&from=" + Uri.EscapeDataString(from);
45
+
46
+ httpTask.SetUrl(fullUrl + "?" + qs);
47
+
48
+ var headers = new Dictionary<string, string>
49
+ {
50
+ ["Accept"] = "application/json",
51
+ ["X-Matrix-User"] = user
52
+ };
53
+ httpTask.SetHeaders(headers);
54
+
55
+ return new ScriptResponse();
56
+ }
57
+
58
+ public Task<ScriptResponse> OutputHandler(ScriptContext context)
59
+ {
60
+ try
61
+ {
62
+ var response = context.Body;
63
+ var bodyData = response?.data;
64
+
65
+ string errcode = GetString(bodyData, "errcode");
66
+ if (!string.IsNullOrEmpty(errcode))
67
+ {
68
+ string errorMsg = GetString(bodyData, "error");
69
+ return Task.FromResult(new ScriptResponse
70
+ {
71
+ Key = "get-room-messages-error",
72
+ Data = new
73
+ {
74
+ error = errorMsg,
75
+ errorCode = errcode,
76
+ messages = new List<object>()
77
+ },
78
+ Tags = new[] { "chat", "messages", "error" }
79
+ });
80
+ }
81
+
82
+ var messages = new List<object>();
83
+
84
+ if (HasProperty(bodyData, "chunk") && bodyData.chunk != null)
85
+ {
86
+ foreach (var evt in bodyData.chunk)
87
+ {
88
+ var evtType = GetString(evt, "type");
89
+ if (evtType != "m.room.message") continue;
90
+
91
+ var content = evt?.content;
92
+ if (content == null) continue;
93
+
94
+ string body = GetString(content, "body");
95
+ string msgtype = GetString(content, "msgtype");
96
+ string sender = GetString(evt, "sender");
97
+ string eventId = GetString(evt, "event_id");
98
+ string ts = GetString(evt, "origin_server_ts");
99
+
100
+ messages.Add(new
101
+ {
102
+ eventId = eventId,
103
+ sender = sender,
104
+ body = body,
105
+ timestamp = ts,
106
+ msgtype = msgtype
107
+ });
108
+ }
109
+ }
110
+
111
+ string nextToken = GetString(bodyData, "end");
112
+ string prevToken = GetString(bodyData, "start");
113
+
114
+ return Task.FromResult(new ScriptResponse
115
+ {
116
+ Key = "get-room-messages-success",
117
+ Data = new
118
+ {
119
+ messages = messages,
120
+ nextToken = nextToken,
121
+ prevToken = prevToken
122
+ },
123
+ Tags = new[] { "chat", "messages", "success" }
124
+ });
125
+ }
126
+ catch (Exception ex)
127
+ {
128
+ return Task.FromResult(new ScriptResponse
129
+ {
130
+ Key = "get-room-messages-error",
131
+ Data = new
132
+ {
133
+ error = "Internal processing error",
134
+ errorCode = "PROCESSING_ERROR",
135
+ errorDescription = ex.Message,
136
+ messages = new List<object>()
137
+ },
138
+ Tags = new[] { "chat", "messages", "error" }
139
+ });
140
+ }
141
+ }
142
+
143
+ private string ReadParam(ScriptContext context, string name)
144
+ {
145
+ if (context.QueryParameters == null || !HasProperty(context.QueryParameters, name))
146
+ return null;
147
+ var val = context.QueryParameters[name];
148
+ return val != null ? val.ToString() : null;
149
+ }
150
+
151
+ private string GetString(dynamic obj, string name)
152
+ {
153
+ if (obj == null) return null;
154
+ try
155
+ {
156
+ if (HasProperty(obj, name))
157
+ {
158
+ var v = GetPropertyValue(obj, name);
159
+ return v?.ToString();
160
+ }
161
+ }
162
+ catch { }
163
+ return null;
164
+ }
165
+ }