@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.
- package/LICENSE +21 -0
- package/burgan-tech-morph-touch-runtime-0.0.2.tgz +0 -0
- package/package.json +21 -0
- package/touch/Extensions/.gitkeep +0 -0
- package/touch/Functions/.gitkeep +0 -0
- package/touch/Functions/check-livekit-room-access.1.0.0.json +28 -0
- package/touch/Functions/check-livekit-room-access.http +44 -0
- package/touch/Functions/get-absence-entry.1.0.0.json +28 -0
- package/touch/Functions/get-advisor-stats.1.0.0.json +27 -0
- package/touch/Functions/get-available-slots.1.0.0.json +30 -0
- package/touch/Functions/get-available-slots.http +29 -0
- package/touch/Functions/get-chat-rooms.1.0.0.json +28 -0
- package/touch/Functions/get-chat-rooms.http +62 -0
- package/touch/Functions/get-customer-info.1.0.0.json +27 -0
- package/touch/Functions/get-matrix-sync.1.0.0.json +28 -0
- package/touch/Functions/get-rezervations.1.0.0.json +26 -0
- package/touch/Functions/get-rezervations.http +59 -0
- package/touch/Functions/get-room-messages.1.0.0.json +29 -0
- package/touch/Functions/get-room-messages.http +45 -0
- package/touch/Functions/rezervation-transfer.http +118 -0
- package/touch/Functions/send-room-message.1.0.0.json +29 -0
- package/touch/Functions/src/CheckLivekitRoomAccessMapping.csx +238 -0
- package/touch/Functions/src/GetAbsenceEntryMapping.csx +225 -0
- package/touch/Functions/src/GetAdvisorStatsMapping.csx +190 -0
- package/touch/Functions/src/GetAvailableSlotsMapping.csx +468 -0
- package/touch/Functions/src/GetChatRoomsMapping.csx +202 -0
- package/touch/Functions/src/GetCustomerInfoMapping.csx +140 -0
- package/touch/Functions/src/GetMatrixSyncMapping.csx +197 -0
- package/touch/Functions/src/GetRezervationsMapping.csx +162 -0
- package/touch/Functions/src/GetRoomMessagesMapping.csx +165 -0
- package/touch/Functions/src/SendCancelNotificationMapping.csx +63 -0
- package/touch/Functions/src/SendRoomMessageMapping.csx +131 -0
- package/touch/Schemas/.gitkeep +0 -0
- package/touch/Schemas/absence-entry.1.0.0.json +232 -0
- package/touch/Schemas/advisor-chat-rooms.1.0.0.json +62 -0
- package/touch/Schemas/chat-room.1.0.0.json +110 -0
- package/touch/Schemas/notification-sender.1.0.0.json +159 -0
- package/touch/Schemas/portfolio-manager.1.0.0.json +63 -0
- package/touch/Schemas/rezervation.1.0.0.json +102 -0
- package/touch/Tasks/.gitkeep +0 -0
- package/touch/Tasks/cancel-absence-entry-for-rezervation.1.0.0.json +21 -0
- package/touch/Tasks/check-already-completed-chat-room.1.0.0.json +24 -0
- package/touch/Tasks/check-duplicate-portfolio-manager.1.0.0.json +23 -0
- package/touch/Tasks/check-duplicate-rezervation.1.0.0.json +23 -0
- package/touch/Tasks/check-existing-permanent-chat-room.1.0.0.json +21 -0
- package/touch/Tasks/check-randevu-time.1.0.0.json +17 -0
- package/touch/Tasks/create-permanent-chat-room.1.0.0.json +28 -0
- package/touch/Tasks/determine-transfer-type.1.0.0.json +16 -0
- package/touch/Tasks/enrich-rezervations-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/execute-permanent-chatroom-update.1.0.0.json +21 -0
- package/touch/Tasks/execute-rez-chatroom-transfer.1.0.0.json +21 -0
- package/touch/Tasks/execute-rezervation-transfer.1.0.0.json +19 -0
- package/touch/Tasks/fetch-absence-entries-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-advisors-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-permanent-chatrooms-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-rez-chatrooms-for-transfer.1.0.0.json +23 -0
- package/touch/Tasks/fetch-rezervations-for-transfer.1.0.0.json +22 -0
- package/touch/Tasks/get-absence-entry-task.1.0.0.json +23 -0
- package/touch/Tasks/get-available-slots-http.1.0.0.json +27 -0
- package/touch/Tasks/get-available-slots.1.0.0.json +24 -0
- package/touch/Tasks/get-chat-room-data-for-rezervation.1.0.0.json +23 -0
- package/touch/Tasks/get-chat-token.1.0.0.json +27 -0
- package/touch/Tasks/get-matrix-room-messages.1.0.0.json +25 -0
- package/touch/Tasks/get-matrix-sync.1.0.0.json +25 -0
- package/touch/Tasks/get-rezervation-data-task.1.0.0.json +22 -0
- package/touch/Tasks/get-rezervation-state-task.1.0.0.json +22 -0
- package/touch/Tasks/get-rezervations-task.1.0.0.json +21 -0
- package/touch/Tasks/get-user-info-for-rezervation.1.0.0.json +24 -0
- package/touch/Tasks/get-video-call-url.1.0.0.json +17 -0
- package/touch/Tasks/invite-user-to-rezervation-room.1.0.0.json +27 -0
- package/touch/Tasks/join-chat-room-for-rezervation.1.0.0.json +28 -0
- package/touch/Tasks/join-matrix-room.1.0.0.json +27 -0
- package/touch/Tasks/join-user-to-room.1.0.0.json +27 -0
- package/touch/Tasks/merge-invited-user.1.0.0.json +17 -0
- package/touch/Tasks/merge-rezervation-update.1.0.0.json +16 -0
- package/touch/Tasks/merge-target-advisor-for-transfer.1.0.0.json +17 -0
- package/touch/Tasks/merge-update-body-for-randevu-update.1.0.0.json +16 -0
- package/touch/Tasks/merge-video-call-urls.1.0.0.json +17 -0
- package/touch/Tasks/query-chat-room-instances.1.0.0.json +23 -0
- package/touch/Tasks/remove-member-from-room.1.0.0.json +28 -0
- package/touch/Tasks/send-matrix-room-message.1.0.0.json +26 -0
- package/touch/Tasks/send-push-notification.1.0.0.json +26 -0
- package/touch/Tasks/send-sms-notification.1.0.0.json +26 -0
- package/touch/Tasks/set-chat-room-status-active.1.0.0.json +16 -0
- package/touch/Tasks/set-chat-room-status-deactive.1.0.0.json +16 -0
- package/touch/Tasks/set-previous-advisor.1.0.0.json +16 -0
- package/touch/Tasks/set-user-from-headers-for-rezervation.1.0.0.json +17 -0
- package/touch/Tasks/start-absence-entry-for-rezervation.1.0.0.json +21 -0
- package/touch/Tasks/start-chat-room-for-rezervation.1.0.0.json +20 -0
- package/touch/Tasks/start-notification-sender.1.0.0.json +20 -0
- package/touch/Tasks/start-permanent-chat-room.1.0.0.json +21 -0
- package/touch/Tasks/start-transfer-from-absence-entry.1.0.0.json +19 -0
- package/touch/Tasks/start-video-call.1.0.0.json +22 -0
- package/touch/Tasks/trigger-chat-room-deactivate.1.0.0.json +21 -0
- package/touch/Tasks/trigger-chat-room-transfer.1.0.0.json +21 -0
- package/touch/Tasks/trigger-chat-room-update.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-add-invited-participant.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-apply-update.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-to-in-meet.1.0.0.json +20 -0
- package/touch/Tasks/trigger-rezervation-video-call-update.1.0.0.json +21 -0
- package/touch/Tasks/validate-date-for-rezervation.1.0.0.json +18 -0
- package/touch/Tasks/validate-slot-for-rezervation.1.0.0.json +24 -0
- package/touch/Tasks/validate-transfer-availability.1.0.0.json +23 -0
- package/touch/Views/.gitkeep +0 -0
- package/touch/Workflows/.gitkeep +0 -0
- package/touch/Workflows/absence-entry.http +458 -0
- package/touch/Workflows/absence-entry.json +179 -0
- package/touch/Workflows/add-participant-to-rezervation.http +47 -0
- package/touch/Workflows/add-participant-to-rezervation.json +340 -0
- package/touch/Workflows/chat-room.http +207 -0
- package/touch/Workflows/chat-room.json +452 -0
- package/touch/Workflows/investment-advisor.json +367 -0
- package/touch/Workflows/notification-sender.http +299 -0
- package/touch/Workflows/notification-sender.json +262 -0
- package/touch/Workflows/portfolio-manager.json +367 -0
- package/touch/Workflows/randevu-update.http +87 -0
- package/touch/Workflows/rezervation-start.json +467 -0
- package/touch/Workflows/rezervation-transfer.json +512 -0
- package/touch/Workflows/rezervation-update.http +87 -0
- package/touch/Workflows/rezervation-update.json +485 -0
- package/touch/Workflows/rezervation.http +214 -0
- package/touch/Workflows/rezervation.json +726 -0
- package/touch/Workflows/src/AllChatRoomsSuccessRule.csx +65 -0
- package/touch/Workflows/src/AlwaysTrueRule.csx +13 -0
- package/touch/Workflows/src/AnyChatRoomFailedRule.csx +64 -0
- package/touch/Workflows/src/AutoProcessRule.csx +38 -0
- package/touch/Workflows/src/BuildRezChatRoomPlanMapping.csx +160 -0
- package/touch/Workflows/src/CanStartRezervationTimerMapping.csx +48 -0
- package/touch/Workflows/src/CanStartTransferMapping.csx +14 -0
- package/touch/Workflows/src/CancelAbsenceEntryForRezervationMapping.csx +48 -0
- package/touch/Workflows/src/CancelAbsenceForRandevuUpdateMapping.csx +62 -0
- package/touch/Workflows/src/ChatRoomCreatedFailedRule.csx +54 -0
- package/touch/Workflows/src/ChatRoomCreatedSuccessRule.csx +54 -0
- package/touch/Workflows/src/ChatRoomRemoveMapping.csx +104 -0
- package/touch/Workflows/src/ChatRoomTransferInviteMapping.csx +109 -0
- package/touch/Workflows/src/ChatRoomTransferRemoveMapping.csx +71 -0
- package/touch/Workflows/src/ChatRoomUpdateMapping.csx +107 -0
- package/touch/Workflows/src/CheckAlreadyCompletedChatRoomMapping.csx +100 -0
- package/touch/Workflows/src/CheckDuplicatePortfolioManagerMapping.csx +119 -0
- package/touch/Workflows/src/CheckDuplicateRezervationMapping.csx +150 -0
- package/touch/Workflows/src/CheckExistingPermanentChatRoomMapping.csx +169 -0
- package/touch/Workflows/src/CheckRandevuTimeMapping.csx +67 -0
- package/touch/Workflows/src/CheckRezervationStateActiveOrInMeetRule.csx +14 -0
- package/touch/Workflows/src/CreateAbsenceEntryForRezervationMapping.csx +111 -0
- package/touch/Workflows/src/CreateAbsenceForRandevuUpdateMapping.csx +108 -0
- package/touch/Workflows/src/CreateChatRoomForRezervationMapping.csx +122 -0
- package/touch/Workflows/src/CreatePermanentChatRoomMapping.csx +140 -0
- package/touch/Workflows/src/CustomerControlToEndRule.csx +14 -0
- package/touch/Workflows/src/DetermineTransferTypeMapping.csx +92 -0
- package/touch/Workflows/src/EnrichRezervationsForTransferMapping.csx +495 -0
- package/touch/Workflows/src/ExecutePermanentChatRoomUpdateMapping.csx +124 -0
- package/touch/Workflows/src/ExecuteRezChatRoomTransferMapping.csx +95 -0
- package/touch/Workflows/src/ExecuteTransferMapping.csx +152 -0
- package/touch/Workflows/src/FetchAbsenceEntriesForTransferMapping.csx +116 -0
- package/touch/Workflows/src/FetchAdvisorsForTransferMapping.csx +145 -0
- package/touch/Workflows/src/FetchPermanentChatRoomsMapping.csx +128 -0
- package/touch/Workflows/src/FetchRezervationsForTransferMapping.csx +124 -0
- package/touch/Workflows/src/GetChatRoomDataForRezervationMapping.csx +100 -0
- package/touch/Workflows/src/GetChatTokenMapping.csx +85 -0
- package/touch/Workflows/src/GetRezervationDataForAddParticipantMapping.csx +105 -0
- package/touch/Workflows/src/GetRezervationDataForRandevuUpdateMapping.csx +110 -0
- package/touch/Workflows/src/GetRezervationDataMapping.csx +111 -0
- package/touch/Workflows/src/GetRezervationStateForRandevuUpdateMapping.csx +80 -0
- package/touch/Workflows/src/GetRezervationStateMapping.csx +92 -0
- package/touch/Workflows/src/GetUserInfoForRezervationMapping.csx +63 -0
- package/touch/Workflows/src/GetVideoCallUrlMapping.csx +62 -0
- package/touch/Workflows/src/HasChangedAdvisorRule.csx +28 -0
- package/touch/Workflows/src/HasChatIntegrationRule.csx +41 -0
- package/touch/Workflows/src/HasExistingPermanentRoomRule.csx +28 -0
- package/touch/Workflows/src/InviteAdvisorForRandevuUpdateMapping.csx +86 -0
- package/touch/Workflows/src/InviteNewAdvisorToRezervationRoomMapping.csx +78 -0
- package/touch/Workflows/src/InviteNewParticipantToRandevuRoomMapping.csx +88 -0
- package/touch/Workflows/src/InvitedUserMergeMapping.csx +77 -0
- package/touch/Workflows/src/InvitedUserNotAllowedRule.csx +71 -0
- package/touch/Workflows/src/InvitedUserNotInMeetRule.csx +19 -0
- package/touch/Workflows/src/IsNotfSentRule.csx +36 -0
- package/touch/Workflows/src/JoinChatRoomForAddParticipantMapping.csx +118 -0
- package/touch/Workflows/src/JoinChatRoomForRandevuStartMapping.csx +119 -0
- package/touch/Workflows/src/JoinChatRoomForRezervationMapping.csx +118 -0
- package/touch/Workflows/src/JoinMatrixRoomMapping.csx +100 -0
- package/touch/Workflows/src/JoinUserToRoomMapping.csx +118 -0
- package/touch/Workflows/src/LoginForAddParticipantChatMapping.csx +102 -0
- package/touch/Workflows/src/LoginForRandevuStartChatMapping.csx +96 -0
- package/touch/Workflows/src/MergeRezervationUpdateMapping.csx +82 -0
- package/touch/Workflows/src/MergeTargetAdvisorForTransferMapping.csx +79 -0
- package/touch/Workflows/src/MergeUpdateBodyForRandevuUpdateMapping.csx +91 -0
- package/touch/Workflows/src/NoExistingPermanentRoomRule.csx +23 -0
- package/touch/Workflows/src/NotificationCompleteAlwaysRule.csx +14 -0
- package/touch/Workflows/src/NotificationCompleteFromPendingRule.csx +41 -0
- package/touch/Workflows/src/NotificationCompleteFromSmsRule.csx +36 -0
- package/touch/Workflows/src/NotificationPushFromPendingRule.csx +42 -0
- package/touch/Workflows/src/NotificationPushFromSmsRule.csx +36 -0
- package/touch/Workflows/src/NotificationSmsPendingRule.csx +32 -0
- package/touch/Workflows/src/PermanentDoneRule.csx +44 -0
- package/touch/Workflows/src/PermanentProcessNextRule.csx +44 -0
- package/touch/Workflows/src/RezChatRoomProcessNextRule.csx +44 -0
- package/touch/Workflows/src/RezChatRoomsDoneRule.csx +44 -0
- package/touch/Workflows/src/SendPushNotificationMapping.csx +146 -0
- package/touch/Workflows/src/SendSmsNotificationMapping.csx +138 -0
- package/touch/Workflows/src/SetChatRoomStatusActiveMapping.csx +22 -0
- package/touch/Workflows/src/SetChatRoomStatusDeactiveMapping.csx +22 -0
- package/touch/Workflows/src/SetPreviousAdvisorMapping.csx +28 -0
- package/touch/Workflows/src/SetUserFromHeadersForRezervationMapping.csx +24 -0
- package/touch/Workflows/src/SlotAvailableRule.csx +33 -0
- package/touch/Workflows/src/SlotUnavailableRule.csx +33 -0
- package/touch/Workflows/src/StartChatRoomForRezervationMapping.csx +100 -0
- package/touch/Workflows/src/StartGetChatTokenForRezervationMapping.csx +71 -0
- package/touch/Workflows/src/StartNotificationForAdvisorMapping.csx +117 -0
- package/touch/Workflows/src/StartNotificationForRezervationFromUserInfoMapping.csx +128 -0
- package/touch/Workflows/src/StartNotificationForUserMapping.csx +117 -0
- package/touch/Workflows/src/StartPermanentChatRoomMapping.csx +92 -0
- package/touch/Workflows/src/StartTransferFromAbsenceEntryMapping.csx +94 -0
- package/touch/Workflows/src/StartVideoCallCustomerSubFlowMapping.csx +37 -0
- package/touch/Workflows/src/StartVideoCallForInvitedParticipantMapping.csx +54 -0
- package/touch/Workflows/src/StartVideoCallForRandevuStartMapping.csx +70 -0
- package/touch/Workflows/src/StartVideoCallStaffSubFlowMapping.csx +37 -0
- package/touch/Workflows/src/StateActiveForUpdateRule.csx +14 -0
- package/touch/Workflows/src/StateActiveRule.csx +14 -0
- package/touch/Workflows/src/StateInMeetRule.csx +14 -0
- package/touch/Workflows/src/StateNotActiveForUpdateRule.csx +14 -0
- package/touch/Workflows/src/StateNotActiveOrInMeetRule.csx +14 -0
- package/touch/Workflows/src/StatusCustomerEnterRule.csx +25 -0
- package/touch/Workflows/src/StatusStaffEnterRule.csx +25 -0
- package/touch/Workflows/src/SyncWorkingHoursRule.csx +46 -0
- package/touch/Workflows/src/TokenSuccessRule.csx +24 -0
- package/touch/Workflows/src/TransferAllDoneRule.csx +50 -0
- package/touch/Workflows/src/TransferHasInvalidRule.csx +34 -0
- package/touch/Workflows/src/TransferProcessNextRule.csx +50 -0
- package/touch/Workflows/src/TriggerChatRoomDeactivateMapping.csx +77 -0
- package/touch/Workflows/src/TriggerChatRoomTransferMapping.csx +93 -0
- package/touch/Workflows/src/TriggerChatRoomUpdateMapping.csx +99 -0
- package/touch/Workflows/src/TriggerRezervationAddInvitedParticipantMapping.csx +77 -0
- package/touch/Workflows/src/TriggerRezervationApplyUpdateMapping.csx +66 -0
- package/touch/Workflows/src/TriggerRezervationToInMeetMapping.csx +69 -0
- package/touch/Workflows/src/TriggerRezervationVideoCallUpdateMapping.csx +67 -0
- package/touch/Workflows/src/ValidateDateForRezervationMapping.csx +60 -0
- package/touch/Workflows/src/ValidateSlotForRandevuUpdateMapping.csx +211 -0
- package/touch/Workflows/src/ValidateSlotForRezervationMapping.csx +246 -0
- package/touch/Workflows/src/ValidateTransferMapping.csx +243 -0
- package/touch/Workflows/src/VideoCallUrlUpdateMergeMapping.csx +141 -0
- package/touch/Workflows/start-chat.json +217 -0
- package/touch/Workflows/start-video-call.http +93 -0
- package/touch/Workflows/start-video-call.json +206 -0
- package/vnext.config.json +58 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Definitions;
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Mapping for SendCancelNotification (DirectTriggerTask - Type 12)
|
|
7
|
+
/// Triggers notification-sender workflow when a reservation is cancelled.
|
|
8
|
+
/// Sends SMS/push notification to the customer about the cancellation.
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class SendCancelNotificationMapping : ScriptBase, IMapping
|
|
11
|
+
{
|
|
12
|
+
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
13
|
+
{
|
|
14
|
+
var triggerTask = task as DirectTriggerTask;
|
|
15
|
+
if (triggerTask == null)
|
|
16
|
+
throw new InvalidOperationException("Task must be a DirectTriggerTask");
|
|
17
|
+
|
|
18
|
+
var instance = context.Instance;
|
|
19
|
+
if (instance == null)
|
|
20
|
+
return Task.FromResult(new ScriptResponse());
|
|
21
|
+
|
|
22
|
+
var attrs = instance.Attributes;
|
|
23
|
+
string user = attrs?.user?.ToString() ?? "";
|
|
24
|
+
string advisor = attrs?.advisor?.ToString() ?? "";
|
|
25
|
+
string startDateTime = attrs?.startDateTime?.ToString() ?? "";
|
|
26
|
+
|
|
27
|
+
if (string.IsNullOrEmpty(user))
|
|
28
|
+
return Task.FromResult(new ScriptResponse());
|
|
29
|
+
|
|
30
|
+
string instanceKey = instance.Key?.ToString() ?? "";
|
|
31
|
+
string notifKey = $"cancel-notif-{instanceKey}-{DateTime.UtcNow:yyyyMMddHHmmss}";
|
|
32
|
+
|
|
33
|
+
triggerTask.SetTargetWorkflow("notification-sender");
|
|
34
|
+
triggerTask.SetTargetTransition("start");
|
|
35
|
+
triggerTask.SetInstanceKey(notifKey);
|
|
36
|
+
triggerTask.SetAttributes(new
|
|
37
|
+
{
|
|
38
|
+
recipientId = user,
|
|
39
|
+
type = "reservation-cancelled",
|
|
40
|
+
channel = "sms",
|
|
41
|
+
title = "Randevu İptali",
|
|
42
|
+
message = $"Randevunuz iptal edilmiştir. Tarih: {startDateTime}, Danışman: {advisor}",
|
|
43
|
+
metadata = new
|
|
44
|
+
{
|
|
45
|
+
reservationKey = instanceKey,
|
|
46
|
+
advisorId = advisor,
|
|
47
|
+
originalDateTime = startDateTime
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return Task.FromResult(new ScriptResponse());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
55
|
+
{
|
|
56
|
+
return Task.FromResult(new ScriptResponse
|
|
57
|
+
{
|
|
58
|
+
Key = "notification-sent",
|
|
59
|
+
Data = new { success = true },
|
|
60
|
+
Tags = new[] { "notification", "cancel" }
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
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 send-matrix-room-message HttpTask (Type 6).
|
|
9
|
+
/// Flow-level function (scope: F) -- no instance context.
|
|
10
|
+
/// Reads roomId, user, body from query parameters.
|
|
11
|
+
/// Calls POST /_matrix/client/v3/rooms/{roomId}/send/m.room.message/{txnId} via APISIX.
|
|
12
|
+
/// X-Matrix-User header is converted to Bearer token by APISIX automatically.
|
|
13
|
+
/// Returns event_id on success.
|
|
14
|
+
/// </summary>
|
|
15
|
+
public class SendRoomMessageMapping : ScriptBase, IMapping
|
|
16
|
+
{
|
|
17
|
+
public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
18
|
+
{
|
|
19
|
+
var httpTask = task as HttpTask;
|
|
20
|
+
if (httpTask == null)
|
|
21
|
+
throw new InvalidOperationException("Task must be an HttpTask");
|
|
22
|
+
|
|
23
|
+
var matrixBaseUrl = await GetSecretAsync("vnext-secret", "workflow-secret", "MatrixBaseUrl");
|
|
24
|
+
if (string.IsNullOrWhiteSpace(matrixBaseUrl))
|
|
25
|
+
throw new InvalidOperationException("MatrixBaseUrl secret is required");
|
|
26
|
+
|
|
27
|
+
var roomId = ReadParam(context, "roomId");
|
|
28
|
+
var user = ReadParam(context, "user");
|
|
29
|
+
var body = ReadParam(context, "body");
|
|
30
|
+
|
|
31
|
+
if (string.IsNullOrWhiteSpace(roomId))
|
|
32
|
+
throw new InvalidOperationException("VALIDATION_ERROR: roomId query parameter is required");
|
|
33
|
+
if (string.IsNullOrWhiteSpace(user))
|
|
34
|
+
throw new InvalidOperationException("VALIDATION_ERROR: user query parameter is required");
|
|
35
|
+
if (string.IsNullOrWhiteSpace(body))
|
|
36
|
+
throw new InvalidOperationException("VALIDATION_ERROR: body query parameter is required");
|
|
37
|
+
|
|
38
|
+
var txnId = Guid.NewGuid().ToString("N");
|
|
39
|
+
var fullUrl = matrixBaseUrl.TrimEnd('/') +
|
|
40
|
+
"/_matrix/client/v3/rooms/" + Uri.EscapeDataString(roomId) +
|
|
41
|
+
"/send/m.room.message/" + txnId;
|
|
42
|
+
|
|
43
|
+
httpTask.SetUrl(fullUrl);
|
|
44
|
+
|
|
45
|
+
var headers = new Dictionary<string, string>
|
|
46
|
+
{
|
|
47
|
+
["Content-Type"] = "application/json",
|
|
48
|
+
["Accept"] = "application/json",
|
|
49
|
+
["X-Matrix-User"] = user
|
|
50
|
+
};
|
|
51
|
+
httpTask.SetHeaders(headers);
|
|
52
|
+
|
|
53
|
+
httpTask.SetBody(new
|
|
54
|
+
{
|
|
55
|
+
msgtype = "m.text",
|
|
56
|
+
body = body
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return new ScriptResponse();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
63
|
+
{
|
|
64
|
+
try
|
|
65
|
+
{
|
|
66
|
+
var response = context.Body;
|
|
67
|
+
var bodyData = response?.data;
|
|
68
|
+
|
|
69
|
+
string errcode = GetString(bodyData, "errcode");
|
|
70
|
+
if (!string.IsNullOrEmpty(errcode))
|
|
71
|
+
{
|
|
72
|
+
string errorMsg = GetString(bodyData, "error");
|
|
73
|
+
return Task.FromResult(new ScriptResponse
|
|
74
|
+
{
|
|
75
|
+
Key = "send-room-message-error",
|
|
76
|
+
Data = new
|
|
77
|
+
{
|
|
78
|
+
error = errorMsg,
|
|
79
|
+
errorCode = errcode
|
|
80
|
+
},
|
|
81
|
+
Tags = new[] { "chat", "messages", "error" }
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
string eventId = GetString(bodyData, "event_id");
|
|
86
|
+
return Task.FromResult(new ScriptResponse
|
|
87
|
+
{
|
|
88
|
+
Key = "send-room-message-success",
|
|
89
|
+
Data = new { eventId = eventId },
|
|
90
|
+
Tags = new[] { "chat", "messages", "success" }
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch (Exception ex)
|
|
94
|
+
{
|
|
95
|
+
return Task.FromResult(new ScriptResponse
|
|
96
|
+
{
|
|
97
|
+
Key = "send-room-message-error",
|
|
98
|
+
Data = new
|
|
99
|
+
{
|
|
100
|
+
error = "Internal processing error",
|
|
101
|
+
errorCode = "PROCESSING_ERROR",
|
|
102
|
+
errorDescription = ex.Message
|
|
103
|
+
},
|
|
104
|
+
Tags = new[] { "chat", "messages", "error" }
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private string ReadParam(ScriptContext context, string name)
|
|
110
|
+
{
|
|
111
|
+
if (context.QueryParameters == null || !HasProperty(context.QueryParameters, name))
|
|
112
|
+
return null;
|
|
113
|
+
var val = context.QueryParameters[name];
|
|
114
|
+
return val != null ? val.ToString() : null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private string GetString(dynamic obj, string name)
|
|
118
|
+
{
|
|
119
|
+
if (obj == null) return null;
|
|
120
|
+
try
|
|
121
|
+
{
|
|
122
|
+
if (HasProperty(obj, name))
|
|
123
|
+
{
|
|
124
|
+
var v = GetPropertyValue(obj, name);
|
|
125
|
+
return v?.ToString();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch { }
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
{
|
|
2
|
+
"key": "absence-entry",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"domain": "touch",
|
|
5
|
+
"flow": "sys-schemas",
|
|
6
|
+
"flowVersion": "1.0.0",
|
|
7
|
+
"tags": [
|
|
8
|
+
"new"
|
|
9
|
+
],
|
|
10
|
+
"attributes": {
|
|
11
|
+
"type": "schema",
|
|
12
|
+
"schema": {
|
|
13
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
14
|
+
"$id": "https://schemas.touch.domain/absence-entry",
|
|
15
|
+
"title": "Absence Entry",
|
|
16
|
+
"type": "object",
|
|
17
|
+
"description": "Absence entry schema for advisor's calendar. Supports personal leave, working hours changes, and public holidays.",
|
|
18
|
+
"properties": {
|
|
19
|
+
"advisor": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Reference to Advisor. Required for personal-leave. Optional for working-hours-change (null = company-wide working hours). Not used for public-holiday. (format: touch.portfolio-manager.{key} or touch.investment-advisor.{key})"
|
|
22
|
+
},
|
|
23
|
+
"absenceType": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Main category of absence entry",
|
|
26
|
+
"oneOf": [
|
|
27
|
+
{
|
|
28
|
+
"const": "personal-leave",
|
|
29
|
+
"description": "Personal leave for a specific advisor (vacation, sick leave, meeting, etc.)"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"const": "working-hours-change",
|
|
33
|
+
"description": "Temporary or permanent change to advisor's working hours"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"const": "public-holiday",
|
|
37
|
+
"description": "Public holiday that affects all advisors in the domain"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"const": "rezervation",
|
|
41
|
+
"description": "Rezervation (randevu) kaynaklı blokaj."
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"startDateTime": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"format": "date-time",
|
|
48
|
+
"description": "Start date and time of the absence (ISO 8601 format)"
|
|
49
|
+
},
|
|
50
|
+
"endDateTime": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"format": "date-time",
|
|
53
|
+
"description": "End date and time of the absence (ISO 8601 format)"
|
|
54
|
+
},
|
|
55
|
+
"title": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"description": "Title or subject of the absence entry"
|
|
58
|
+
},
|
|
59
|
+
"customWorkingHours": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"description": "Custom working hours configuration. Used when absenceType is 'working-hours-change'. One entry per advisor (key: working-hour-{advisorId}) or one company-wide entry (key: working-hour). Subsequent changes update the existing instance.",
|
|
62
|
+
"properties": {
|
|
63
|
+
"monday": {
|
|
64
|
+
"type": "array",
|
|
65
|
+
"description": "Working hours for Monday",
|
|
66
|
+
"items": {
|
|
67
|
+
"$ref": "#/$defs/timeRange"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"tuesday": {
|
|
71
|
+
"type": "array",
|
|
72
|
+
"description": "Working hours for Tuesday",
|
|
73
|
+
"items": {
|
|
74
|
+
"$ref": "#/$defs/timeRange"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"wednesday": {
|
|
78
|
+
"type": "array",
|
|
79
|
+
"description": "Working hours for Wednesday",
|
|
80
|
+
"items": {
|
|
81
|
+
"$ref": "#/$defs/timeRange"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"thursday": {
|
|
85
|
+
"type": "array",
|
|
86
|
+
"description": "Working hours for Thursday",
|
|
87
|
+
"items": {
|
|
88
|
+
"$ref": "#/$defs/timeRange"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"friday": {
|
|
92
|
+
"type": "array",
|
|
93
|
+
"description": "Working hours for Friday",
|
|
94
|
+
"items": {
|
|
95
|
+
"$ref": "#/$defs/timeRange"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"saturday": {
|
|
99
|
+
"type": "array",
|
|
100
|
+
"description": "Working hours for Saturday",
|
|
101
|
+
"items": {
|
|
102
|
+
"$ref": "#/$defs/timeRange"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"sunday": {
|
|
106
|
+
"type": "array",
|
|
107
|
+
"description": "Working hours for Sunday",
|
|
108
|
+
"items": {
|
|
109
|
+
"$ref": "#/$defs/timeRange"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"required": [
|
|
114
|
+
"monday",
|
|
115
|
+
"tuesday",
|
|
116
|
+
"wednesday",
|
|
117
|
+
"thursday",
|
|
118
|
+
"friday",
|
|
119
|
+
"saturday",
|
|
120
|
+
"sunday"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"exchangeSync": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"description": "Exchange calendar synchronization information",
|
|
126
|
+
"properties": {
|
|
127
|
+
"synced": {
|
|
128
|
+
"type": "boolean",
|
|
129
|
+
"description": "Whether this entry is synced with Exchange calendar"
|
|
130
|
+
},
|
|
131
|
+
"exchangeId": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"description": "Exchange calendar event ID (if synced)"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"required": [
|
|
137
|
+
"synced"
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"$defs": {
|
|
142
|
+
"timeRange": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"description": "A time range within a day",
|
|
145
|
+
"properties": {
|
|
146
|
+
"start": {
|
|
147
|
+
"type": "string",
|
|
148
|
+
"pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9]$",
|
|
149
|
+
"description": "Start time in HH:mm format (e.g., '09:00')"
|
|
150
|
+
},
|
|
151
|
+
"end": {
|
|
152
|
+
"type": "string",
|
|
153
|
+
"pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9]$",
|
|
154
|
+
"description": "End time in HH:mm format (e.g., '18:00')"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"required": [
|
|
158
|
+
"start",
|
|
159
|
+
"end"
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"required": [
|
|
164
|
+
"absenceType",
|
|
165
|
+
"title"
|
|
166
|
+
],
|
|
167
|
+
"allOf": [
|
|
168
|
+
{
|
|
169
|
+
"if": {
|
|
170
|
+
"properties": {
|
|
171
|
+
"absenceType": {
|
|
172
|
+
"const": "personal-leave"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"then": {
|
|
177
|
+
"required": [
|
|
178
|
+
"advisor",
|
|
179
|
+
"startDateTime"
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"if": {
|
|
185
|
+
"properties": {
|
|
186
|
+
"absenceType": {
|
|
187
|
+
"const": "working-hours-change"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"then": {
|
|
192
|
+
"required": [
|
|
193
|
+
"customWorkingHours"
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"if": {
|
|
199
|
+
"properties": {
|
|
200
|
+
"absenceType": {
|
|
201
|
+
"const": "public-holiday"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"then": {
|
|
206
|
+
"required": [
|
|
207
|
+
"startDateTime",
|
|
208
|
+
"endDateTime"
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"if": {
|
|
214
|
+
"properties": {
|
|
215
|
+
"absenceType": {
|
|
216
|
+
"const": "rezervation"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
"then": {
|
|
221
|
+
"required": [
|
|
222
|
+
"advisor",
|
|
223
|
+
"startDateTime",
|
|
224
|
+
"endDateTime"
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
"additionalProperties": false
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"key": "advisor-chat-rooms",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"domain": "touch",
|
|
5
|
+
"flow": "sys-schemas",
|
|
6
|
+
"flowVersion": "1.0.0",
|
|
7
|
+
"tags": [
|
|
8
|
+
"advisor",
|
|
9
|
+
"chat",
|
|
10
|
+
"matrix"
|
|
11
|
+
],
|
|
12
|
+
"attributes": {
|
|
13
|
+
"type": "schema",
|
|
14
|
+
"schema": {
|
|
15
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
16
|
+
"$id": "https://schemas.touch.domain/advisor-chat-rooms",
|
|
17
|
+
"title": "Advisor Chat Rooms",
|
|
18
|
+
"type": "object",
|
|
19
|
+
"description": "Schema for flow that creates two persistent Matrix chat rooms (PM and IA) for a user.",
|
|
20
|
+
"properties": {
|
|
21
|
+
"user": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Reference to User entity (customer); used for chat login."
|
|
24
|
+
},
|
|
25
|
+
"portfolioManagerId": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "Reference to Portfolio Manager; used as invitedUser for first create-chat-room call."
|
|
28
|
+
},
|
|
29
|
+
"investmentAdvisorId": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "Reference to Investment Advisor; used as invitedUser for second create-chat-room call."
|
|
32
|
+
},
|
|
33
|
+
"chatIntegration": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"description": "Chat integration output: room IDs from Matrix Synapse API via APISIX.",
|
|
36
|
+
"properties": {
|
|
37
|
+
"portfolioManagerRoomId": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "Matrix room ID for PM room."
|
|
40
|
+
},
|
|
41
|
+
"investmentAdvisorRoomId": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Matrix room ID for IA room."
|
|
44
|
+
},
|
|
45
|
+
"error": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "Last error message."
|
|
48
|
+
},
|
|
49
|
+
"errorCode": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"description": "Last error code."
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": [
|
|
57
|
+
"user"
|
|
58
|
+
],
|
|
59
|
+
"additionalProperties": false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"key": "chat-room",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"domain": "touch",
|
|
5
|
+
"flow": "sys-schemas",
|
|
6
|
+
"flowVersion": "1.0.0",
|
|
7
|
+
"tags": [
|
|
8
|
+
"advisor",
|
|
9
|
+
"chat",
|
|
10
|
+
"matrix"
|
|
11
|
+
],
|
|
12
|
+
"attributes": {
|
|
13
|
+
"type": "schema",
|
|
14
|
+
"schema": {
|
|
15
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
16
|
+
"$id": "https://schemas.touch.domain/chat-room",
|
|
17
|
+
"title": "Chat Room",
|
|
18
|
+
"type": "object",
|
|
19
|
+
"description": "Schema for chat room management. Supports permanent advisor rooms (PM/IA) and rezervation meeting rooms. Each instance manages a single Matrix room.",
|
|
20
|
+
"properties": {
|
|
21
|
+
"user": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Reference to User entity (customer); used for chat login."
|
|
24
|
+
},
|
|
25
|
+
"advisorType": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "Type of advisor room to manage.",
|
|
28
|
+
"oneOf": [
|
|
29
|
+
{
|
|
30
|
+
"const": "PM",
|
|
31
|
+
"description": "Portfolio Manager room"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"const": "IA",
|
|
35
|
+
"description": "Investment Advisor room"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"advisorId": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Current advisor assigned to this room."
|
|
42
|
+
},
|
|
43
|
+
"roomType": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Type of chat room.",
|
|
46
|
+
"oneOf": [
|
|
47
|
+
{
|
|
48
|
+
"const": "permanent",
|
|
49
|
+
"description": "Permanent advisor room (PM/IA)"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"const": "rezervation",
|
|
53
|
+
"description": "Reservation meeting room"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"startDateTime": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"format": "date-time",
|
|
60
|
+
"description": "Meeting start time (rezervation rooms only)."
|
|
61
|
+
},
|
|
62
|
+
"endDateTime": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"format": "date-time",
|
|
65
|
+
"description": "Meeting end time (rezervation rooms only)."
|
|
66
|
+
},
|
|
67
|
+
"chatIntegration": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"description": "Chat integration output: room info from Matrix Synapse API via APISIX.",
|
|
70
|
+
"properties": {
|
|
71
|
+
"roomId": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"description": "Matrix room ID."
|
|
74
|
+
},
|
|
75
|
+
"error": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"description": "Last error message."
|
|
78
|
+
},
|
|
79
|
+
"errorCode": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"description": "Last error code."
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"lastMessageAt": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"format": "date-time",
|
|
88
|
+
"description": "Timestamp of the last message in this chat room. Updated on each new message for SLA tracking."
|
|
89
|
+
},
|
|
90
|
+
"lastReadAt": {
|
|
91
|
+
"type": "string",
|
|
92
|
+
"format": "date-time",
|
|
93
|
+
"description": "Timestamp of when the advisor last read messages in this room. Used with lastMessageAt to calculate SLA."
|
|
94
|
+
},
|
|
95
|
+
"slaBreached": {
|
|
96
|
+
"type": "boolean",
|
|
97
|
+
"description": "Whether the SLA response time has been breached for this room.",
|
|
98
|
+
"default": false
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"required": [
|
|
102
|
+
"user",
|
|
103
|
+
"advisorType",
|
|
104
|
+
"advisorId",
|
|
105
|
+
"roomType"
|
|
106
|
+
],
|
|
107
|
+
"additionalProperties": false
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|