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.
This commit is contained in:
Ludy87 2025-09-25 10:05:49 +02:00
parent c3b604791a
commit 966d80b0fc
No known key found for this signature in database
GPG Key ID: 92696155E0220F94
2 changed files with 6 additions and 35 deletions

View File

@ -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(

View File

@ -4,7 +4,7 @@
export interface AutomationOperation {
operation: string;
parameters: Record<string, JsonValue>;
parameters: Record<string, JsonValue | undefined>;
}
export interface AutomationConfig {
@ -22,7 +22,7 @@ export interface AutomationTool {
operation: string;
name: string;
configured: boolean;
parameters?: Record<string, JsonValue>;
parameters?: Record<string, JsonValue | undefined>;
}
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<string, JsonValue>;
export interface AutomationOperation {
operation: string;
// Wurde von Record<string, string | number | boolean | null> auf JSON erweitert
parameters: Record<string, JsonValue>;
}
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 };