🔨 Infer typings for config schema (#2656)

* 🚚 Move schema to standalone file

*  Add assertions to string literal arrays

*  Infer typings for convict schema

* 🔥 Remove unneeded assertions

* 🔨 Fix errors surfaced by typings

*  Type nodes.include/exclude per docs

*  Account for types for exception paths

*  Set method alias to flag incorrect paths

*  Replace original with alias

*  Make allowance for nodes.include

*  Adjust leftover calls

* 🔀 Fix conflicts

* 🔥 Remove unneeded castings

* 📘 Simplify exception path type

* 📦 Update package-lock.json

* 🔥 Remove unneeded imports

* 🔥 Remove unrelated file

*  Update schema

*  Update interface

* 📦 Update package-lock.json

* 📦 Update package-lock.json

* 🔥 Remove leftover assertions

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Iván Ovejero
2022-04-08 19:37:27 +02:00
committed by GitHub
parent 23f0501f4c
commit 37a6e329af
82 changed files with 1393 additions and 1256 deletions

View File

@@ -67,7 +67,7 @@ import {
} from './UserManagement/UserManagementHelper';
import { whereClause } from './WorkflowHelpers';
const ERROR_TRIGGER_TYPE = config.get('nodes.errorTriggerType') as string;
const ERROR_TRIGGER_TYPE = config.getEnv('nodes.errorTriggerType');
/**
* Checks if there was an error and if errorWorkflow or a trigger is defined. If so it collects
@@ -171,8 +171,8 @@ function pruneExecutionData(this: WorkflowHooks): void {
Logger.verbose('Pruning execution data from database');
throttling = true;
const timeout = config.get('executions.pruneDataTimeout') as number; // in seconds
const maxAge = config.get('executions.pruneDataMaxAge') as number; // in h
const timeout = config.getEnv('executions.pruneDataTimeout'); // in seconds
const maxAge = config.getEnv('executions.pruneDataMaxAge'); // in h
const date = new Date(); // today
date.setHours(date.getHours() - maxAge);
@@ -357,11 +357,11 @@ export function hookFunctionsPreExecute(parentProcessMode?: string): IWorkflowEx
}
if (
this.workflowData.settings.saveExecutionProgress !== true &&
!config.get('executions.saveExecutionProgress')
!config.getEnv('executions.saveExecutionProgress')
) {
return;
}
} else if (!config.get('executions.saveExecutionProgress')) {
} else if (!config.getEnv('executions.saveExecutionProgress')) {
return;
}
@@ -466,7 +466,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
});
// Prune old execution data
if (config.get('executions.pruneData')) {
if (config.getEnv('executions.pruneData')) {
pruneExecutionData.call(this);
}
@@ -492,7 +492,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
}
}
let saveManualExecutions = config.get('executions.saveDataManualExecutions') as boolean;
let saveManualExecutions = config.getEnv('executions.saveDataManualExecutions');
if (
this.workflowData.settings !== undefined &&
this.workflowData.settings.saveManualExecutions !== undefined
@@ -512,8 +512,8 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
}
// Check config to know if execution should be saved or not
let saveDataErrorExecution = config.get('executions.saveDataOnError') as string;
let saveDataSuccessExecution = config.get('executions.saveDataOnSuccess') as string;
let saveDataErrorExecution = config.getEnv('executions.saveDataOnError') as string;
let saveDataSuccessExecution = config.getEnv('executions.saveDataOnSuccess') as string;
if (this.workflowData.settings !== undefined) {
saveDataErrorExecution =
(this.workflowData.settings.saveDataErrorExecution as string) ||
@@ -800,7 +800,7 @@ export async function getWorkflowData(
const user = await getUserById(userId);
let relations = ['workflow', 'workflow.tags'];
if (config.get('workflowTagsDisabled')) {
if (config.getEnv('workflowTagsDisabled')) {
relations = relations.filter((relation) => relation !== 'workflow.tags');
}
@@ -1028,10 +1028,10 @@ export async function getBase(
): Promise<IWorkflowExecuteAdditionalData> {
const urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl();
const timezone = config.get('generic.timezone') as string;
const webhookBaseUrl = urlBaseWebhook + config.get('endpoints.webhook');
const webhookWaitingBaseUrl = urlBaseWebhook + config.get('endpoints.webhookWaiting');
const webhookTestBaseUrl = urlBaseWebhook + config.get('endpoints.webhookTest');
const timezone = config.getEnv('generic.timezone');
const webhookBaseUrl = urlBaseWebhook + config.getEnv('endpoints.webhook');
const webhookWaitingBaseUrl = urlBaseWebhook + config.getEnv('endpoints.webhookWaiting');
const webhookTestBaseUrl = urlBaseWebhook + config.getEnv('endpoints.webhookTest');
const encryptionKey = await UserSettings.getEncryptionKey();
if (encryptionKey === undefined) {
@@ -1042,7 +1042,7 @@ export async function getBase(
credentialsHelper: new CredentialsHelper(encryptionKey),
encryptionKey,
executeWorkflow,
restApiUrl: urlBaseWebhook + config.get('endpoints.rest'),
restApiUrl: urlBaseWebhook + config.getEnv('endpoints.rest'),
timezone,
webhookBaseUrl,
webhookWaitingBaseUrl,