mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
⚡ Restructure IPushData union types (#1836)
* ✨ Send console.log messages to editor-UI * ⚡ Send message only to session which started workflow * ⚡ Made it also work in own process * ⚡ Add support for console.log UI forward also to FunctionItem Node * 👕 Fix lint issue * 👕 Fix linting issue * ⚡ Restructure IPushData unions in /cli * ⚡ Restructure IPushData unions in /editor-ui * 🔥 Remove unneeded castings * 🔥 Remove commented code * ⚡ Improve code Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com> Co-authored-by: Jan <janober@users.noreply.github.com>
This commit is contained in:
parent
fe354baa55
commit
40e41f7506
|
@ -336,12 +336,45 @@ export interface IPackageVersions {
|
||||||
cli: string;
|
cli: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPushData {
|
export type IPushDataType = IPushData['type'];
|
||||||
data: IPushDataExecutionFinished | IPushDataNodeExecuteAfter | IPushDataNodeExecuteBefore | IPushDataTestWebhook | IPushDataConsoleMessage;
|
|
||||||
type: IPushDataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type IPushDataType = 'executionFinished' | 'executionStarted' | 'nodeExecuteAfter' | 'nodeExecuteBefore' | 'sendConsoleMessage' | 'testWebhookDeleted' | 'testWebhookReceived';
|
export type IPushData =
|
||||||
|
| PushDataExecutionFinished
|
||||||
|
| PushDataExecutionStarted
|
||||||
|
| PushDataExecuteAfter
|
||||||
|
| PushDataExecuteBefore
|
||||||
|
| PushDataConsoleMessage
|
||||||
|
| PushDataTestWebhook;
|
||||||
|
|
||||||
|
type PushDataExecutionFinished = {
|
||||||
|
data: IPushDataExecutionFinished;
|
||||||
|
type: 'executionFinished';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataExecutionStarted = {
|
||||||
|
data: IPushDataExecutionStarted;
|
||||||
|
type: 'executionStarted';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataExecuteAfter = {
|
||||||
|
data: IPushDataNodeExecuteAfter;
|
||||||
|
type: 'nodeExecuteAfter';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataExecuteBefore = {
|
||||||
|
data: IPushDataNodeExecuteBefore;
|
||||||
|
type: 'nodeExecuteBefore';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataConsoleMessage = {
|
||||||
|
data: IPushDataConsoleMessage;
|
||||||
|
type: 'sendConsoleMessage';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataTestWebhook = {
|
||||||
|
data: IPushDataTestWebhook;
|
||||||
|
type: 'testWebhookDeleted' | 'testWebhookReceived';
|
||||||
|
};
|
||||||
|
|
||||||
export interface IPushDataExecutionFinished {
|
export interface IPushDataExecutionFinished {
|
||||||
data: IRun;
|
data: IRun;
|
||||||
|
|
|
@ -355,12 +355,45 @@ export interface IExecutionDeleteFilter {
|
||||||
ids?: string[];
|
ids?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPushData {
|
export type IPushDataType = IPushData['type'];
|
||||||
data: IPushDataExecutionFinished | IPushDataNodeExecuteAfter | IPushDataNodeExecuteBefore | IPushDataTestWebhook | IPushDataConsoleMessage;
|
|
||||||
type: IPushDataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type IPushDataType = 'executionFinished' | 'executionStarted' | 'nodeExecuteAfter' | 'nodeExecuteBefore' | 'sendConsoleMessage' | 'testWebhookDeleted' | 'testWebhookReceived';
|
export type IPushData =
|
||||||
|
| PushDataExecutionFinished
|
||||||
|
| PushDataExecutionStarted
|
||||||
|
| PushDataExecuteAfter
|
||||||
|
| PushDataExecuteBefore
|
||||||
|
| PushDataConsoleMessage
|
||||||
|
| PushDataTestWebhook;
|
||||||
|
|
||||||
|
type PushDataExecutionFinished = {
|
||||||
|
data: IPushDataExecutionFinished;
|
||||||
|
type: 'executionFinished';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataExecutionStarted = {
|
||||||
|
data: IPushDataExecutionStarted;
|
||||||
|
type: 'executionStarted';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataExecuteAfter = {
|
||||||
|
data: IPushDataNodeExecuteAfter;
|
||||||
|
type: 'nodeExecuteAfter';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataExecuteBefore = {
|
||||||
|
data: IPushDataNodeExecuteBefore;
|
||||||
|
type: 'nodeExecuteBefore';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataConsoleMessage = {
|
||||||
|
data: IPushDataConsoleMessage;
|
||||||
|
type: 'sendConsoleMessage';
|
||||||
|
};
|
||||||
|
|
||||||
|
type PushDataTestWebhook = {
|
||||||
|
data: IPushDataTestWebhook;
|
||||||
|
type: 'testWebhookDeleted' | 'testWebhookReceived';
|
||||||
|
};
|
||||||
|
|
||||||
export interface IPushDataExecutionStarted {
|
export interface IPushDataExecutionStarted {
|
||||||
executionId: string;
|
executionId: string;
|
||||||
|
|
|
@ -163,7 +163,7 @@ export const pushConnection = mixins(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receivedData.type === 'sendConsoleMessage') {
|
if (receivedData.type === 'sendConsoleMessage') {
|
||||||
const pushData = receivedData.data as IPushDataConsoleMessage;
|
const pushData = receivedData.data;
|
||||||
console.log(pushData.source, pushData.message); // eslint-disable-line no-console
|
console.log(pushData.source, pushData.message); // eslint-disable-line no-console
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -175,12 +175,12 @@ export const pushConnection = mixins(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['nodeExecuteAfter', 'nodeExecuteBefore'].includes(receivedData.type)) {
|
if (receivedData.type === 'nodeExecuteAfter' || receivedData.type === 'nodeExecuteBefore') {
|
||||||
if (this.$store.getters.isActionActive('workflowRunning') === false) {
|
if (this.$store.getters.isActionActive('workflowRunning') === false) {
|
||||||
// No workflow is running so ignore the messages
|
// No workflow is running so ignore the messages
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const pushData = receivedData.data as IPushDataNodeExecuteBefore;
|
const pushData = receivedData.data;
|
||||||
if (this.$store.getters.activeExecutionId !== pushData.executionId) {
|
if (this.$store.getters.activeExecutionId !== pushData.executionId) {
|
||||||
// The data is not for the currently active execution or
|
// The data is not for the currently active execution or
|
||||||
// we do not have the execution id yet.
|
// we do not have the execution id yet.
|
||||||
|
@ -193,7 +193,7 @@ export const pushConnection = mixins(
|
||||||
|
|
||||||
if (receivedData.type === 'executionFinished') {
|
if (receivedData.type === 'executionFinished') {
|
||||||
// The workflow finished executing
|
// The workflow finished executing
|
||||||
const pushData = receivedData.data as IPushDataExecutionFinished;
|
const pushData = receivedData.data;
|
||||||
|
|
||||||
this.$store.commit('finishActiveExecution', pushData);
|
this.$store.commit('finishActiveExecution', pushData);
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ export const pushConnection = mixins(
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (receivedData.type === 'executionStarted') {
|
} else if (receivedData.type === 'executionStarted') {
|
||||||
const pushData = receivedData.data as IPushDataExecutionStarted;
|
const pushData = receivedData.data;
|
||||||
|
|
||||||
const executionData: IExecutionsCurrentSummaryExtended = {
|
const executionData: IExecutionsCurrentSummaryExtended = {
|
||||||
id: pushData.executionId,
|
id: pushData.executionId,
|
||||||
|
@ -294,15 +294,15 @@ export const pushConnection = mixins(
|
||||||
this.$store.commit('addActiveExecution', executionData);
|
this.$store.commit('addActiveExecution', executionData);
|
||||||
} else if (receivedData.type === 'nodeExecuteAfter') {
|
} else if (receivedData.type === 'nodeExecuteAfter') {
|
||||||
// A node finished to execute. Add its data
|
// A node finished to execute. Add its data
|
||||||
const pushData = receivedData.data as IPushDataNodeExecuteAfter;
|
const pushData = receivedData.data;
|
||||||
this.$store.commit('addNodeExecutionData', pushData);
|
this.$store.commit('addNodeExecutionData', pushData);
|
||||||
} else if (receivedData.type === 'nodeExecuteBefore') {
|
} else if (receivedData.type === 'nodeExecuteBefore') {
|
||||||
// A node started to be executed. Set it as executing.
|
// A node started to be executed. Set it as executing.
|
||||||
const pushData = receivedData.data as IPushDataNodeExecuteBefore;
|
const pushData = receivedData.data;
|
||||||
this.$store.commit('setExecutingNode', pushData.nodeName);
|
this.$store.commit('setExecutingNode', pushData.nodeName);
|
||||||
} else if (receivedData.type === 'testWebhookDeleted') {
|
} else if (receivedData.type === 'testWebhookDeleted') {
|
||||||
// A test-webhook got deleted
|
// A test-webhook got deleted
|
||||||
const pushData = receivedData.data as IPushDataTestWebhook;
|
const pushData = receivedData.data;
|
||||||
|
|
||||||
if (pushData.workflowId === this.$store.getters.workflowId) {
|
if (pushData.workflowId === this.$store.getters.workflowId) {
|
||||||
this.$store.commit('setExecutionWaitingForWebhook', false);
|
this.$store.commit('setExecutionWaitingForWebhook', false);
|
||||||
|
@ -310,7 +310,7 @@ export const pushConnection = mixins(
|
||||||
}
|
}
|
||||||
} else if (receivedData.type === 'testWebhookReceived') {
|
} else if (receivedData.type === 'testWebhookReceived') {
|
||||||
// A test-webhook did get called
|
// A test-webhook did get called
|
||||||
const pushData = receivedData.data as IPushDataTestWebhook;
|
const pushData = receivedData.data;
|
||||||
|
|
||||||
if (pushData.workflowId === this.$store.getters.workflowId) {
|
if (pushData.workflowId === this.$store.getters.workflowId) {
|
||||||
this.$store.commit('setExecutionWaitingForWebhook', false);
|
this.$store.commit('setExecutionWaitingForWebhook', false);
|
||||||
|
|
Loading…
Reference in a new issue