From 966d80b0fc4821597626a273bbb20350d6c09b6e Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Thu, 25 Sep 2025 10:05:49 +0200 Subject: [PATCH] Fix parameter type definitions and metadata validation Updated parameter types in AutomationOperation and AutomationTool to allow undefined values. Fixed logic in useChangeMetadataParameters to use logical OR instead of nullish coalescing for metadata validation. --- .../useChangeMetadataParameters.ts | 5 +-- frontend/src/types/automation.ts | 36 ++----------------- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/frontend/src/hooks/tools/changeMetadata/useChangeMetadataParameters.ts b/frontend/src/hooks/tools/changeMetadata/useChangeMetadataParameters.ts index 74dc7010e..580edd68e 100644 --- a/frontend/src/hooks/tools/changeMetadata/useChangeMetadataParameters.ts +++ b/frontend/src/hooks/tools/changeMetadata/useChangeMetadataParameters.ts @@ -89,6 +89,7 @@ const validateParameters = (params: ChangeMetadataParameters): boolean => { } // At least one field should have content for the operation to be meaningful + /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ const hasStandardMetadata = !!( params.title.trim() || params.author.trim() @@ -97,8 +98,8 @@ const validateParameters = (params: ChangeMetadataParameters): boolean => { || params.creator.trim() || params.producer.trim() || params.creationDate - ?? params.modificationDate - ?? params.trapped !== TrappedStatus.UNKNOWN + || params.modificationDate + || params.trapped !== TrappedStatus.UNKNOWN ); const hasCustomMetadata = params.customMetadata.some( diff --git a/frontend/src/types/automation.ts b/frontend/src/types/automation.ts index cd65cb9c8..08a5b0a56 100644 --- a/frontend/src/types/automation.ts +++ b/frontend/src/types/automation.ts @@ -4,7 +4,7 @@ export interface AutomationOperation { operation: string; - parameters: Record; + parameters: Record; } export interface AutomationConfig { @@ -22,7 +22,7 @@ export interface AutomationTool { operation: string; name: string; configured: boolean; - parameters?: Record; + parameters?: Record; } export type AutomationStep = typeof import('../constants/automation').AUTOMATION_STEPS[keyof typeof import('../constants/automation').AUTOMATION_STEPS]; @@ -82,34 +82,4 @@ export type JsonValue = | JsonValue[] | { [key: string]: JsonValue }; -export type JsonObject = Record; - -export interface AutomationOperation { - operation: string; - // Wurde von Record auf JSON erweitert - parameters: Record; -} - -export interface AutomationConfig { - id: string; - name: string; - description?: string; - icon?: string; - operations: AutomationOperation[]; - createdAt: string; - updatedAt: string; -} - -export interface AutomationStepData { - step: AutomationStep; - mode?: AutomationMode; - automation?: AutomationConfig; -} - -export interface ExecutionStep { - id: string; - operation: string; - name: string; - status: 'pending' | 'running' | 'completed' | 'error'; - error?: string; -} +export type JsonObject = { [key: string]: JsonValue };