refactor(core): Stronger typing for workflow settings (no-changelog) (#5754)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-03-24 13:11:48 +01:00
committed by GitHub
parent d33a1ac1e9
commit c9d9069c0e
11 changed files with 77 additions and 101 deletions

View File

@@ -66,7 +66,7 @@ export class Expression {
if (value instanceof Date) {
// We don't want to use JSON.stringify for dates since it disregards workflow timezone
result = DateTime.fromJSDate(value, {
zone: this.workflow.settings.timezone?.toString() ?? 'default',
zone: this.workflow.settings?.timezone ?? 'default',
}).toISO();
} else {
result = JSON.stringify(value);

View File

@@ -1709,8 +1709,21 @@ export interface IWorkflowHooksOptionalParameters {
sessionId?: string;
}
export namespace WorkflowSettings {
export type CallerPolicy = 'any' | 'none' | 'workflowsFromAList' | 'workflowsFromSameOwner';
export type SaveDataExecution = 'DEFAULT' | 'all' | 'none';
}
export interface IWorkflowSettings {
[key: string]: IDataObject | string | number | boolean | undefined;
timezone?: 'DEFAULT' | string;
errorWorkflow?: string;
callerIds?: string;
callerPolicy?: WorkflowSettings.CallerPolicy;
saveDataErrorExecution?: WorkflowSettings.SaveDataExecution;
saveDataSuccessExecution?: WorkflowSettings.SaveDataExecution;
saveManualExecutions?: 'DEFAULT' | boolean;
saveExecutionProgress?: 'DEFAULT' | boolean;
executionTimeout?: number;
}
export type LogTypes = 'debug' | 'verbose' | 'info' | 'warn' | 'error';

View File

@@ -111,7 +111,7 @@ export class WorkflowDataProxy {
this.siblingParameters = siblingParameters;
this.mode = mode;
this.defaultTimezone = defaultTimezone;
this.timezone = (this.workflow.settings.timezone as string) || this.defaultTimezone;
this.timezone = workflow.settings?.timezone ?? defaultTimezone;
this.selfData = selfData;
this.additionalKeys = additionalKeys;
this.executeData = executeData;