From e5c0dc1999b1fd8208c68d50d302282c80f9346a Mon Sep 17 00:00:00 2001 From: Krzysztof Polak Date: Thu, 18 Dec 2025 09:31:06 +0100 Subject: [PATCH] refactor: Update value handling in automation rules and triggers --- .../steps/edit-automation-rules.ts | 6 ++--- .../retrieve-automation-triggers-by-event.ts | 26 +++++-------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/workflows/mpn-automation/steps/edit-automation-rules.ts b/src/workflows/mpn-automation/steps/edit-automation-rules.ts index e7328dc..01babc2 100644 --- a/src/workflows/mpn-automation/steps/edit-automation-rules.ts +++ b/src/workflows/mpn-automation/steps/edit-automation-rules.ts @@ -112,7 +112,7 @@ export const editAutomationRulesStep = createStep( await mpnAutomationService.updateMpnAutomationRuleValues( valuesToUpdate.map((value) => ({ id: value.id!, - value: value.value, + value: value.value as any, })) ) } @@ -121,7 +121,7 @@ export const editAutomationRulesStep = createStep( await mpnAutomationService.createMpnAutomationRuleValues( valuesToCreate.map((value) => ({ rule_id: rule.id!, - value: value.value, + value: value.value as any, })) ) } @@ -148,7 +148,7 @@ export const editAutomationRulesStep = createStep( await mpnAutomationService.createMpnAutomationRuleValues( rule.rule_values.map((value) => ({ rule_id: newRule[0].id, - value: value.value, + value: value.value as any, })) ) } diff --git a/src/workflows/mpn-automation/steps/retrieve-automation-triggers-by-event.ts b/src/workflows/mpn-automation/steps/retrieve-automation-triggers-by-event.ts index 03183d3..48df6b7 100644 --- a/src/workflows/mpn-automation/steps/retrieve-automation-triggers-by-event.ts +++ b/src/workflows/mpn-automation/steps/retrieve-automation-triggers-by-event.ts @@ -58,35 +58,23 @@ export const getAutomationTriggersByEventStep = createStep( id: trigger.id, name: trigger.name, description: trigger.description, - trigger_type: trigger.trigger_type as TriggerType, + trigger_type: trigger.trigger_type, event_name: trigger.event_name, interval_minutes: trigger.interval_minutes, active: trigger.active, - channels: trigger.channels as Record< - string, - boolean - > | null, - metadata: trigger.metadata as Record< - string, - any - > | null, + channels: trigger.channels, + metadata: trigger.metadata, rules: (trigger.rules || []).map((rule) => ({ id: rule.id, attribute: rule.attribute, operator: rule.operator, description: rule.description, - metadata: rule.metadata as Record< - string, - any - > | null, + metadata: rule.metadata, rule_values: (rule.rule_values || []).map( (value) => ({ id: value.id, - value: value.value, - metadata: value.metadata as Record< - string, - any - > | null, + value: value.value as any, + metadata: value.metadata, }) ), })), @@ -95,7 +83,7 @@ export const getAutomationTriggersByEventStep = createStep( action_type: action.action_type, config: action.config, })), - })) + })) as AutomationTrigger[] return new StepResponse(triggersData, triggersData) }