@n8n/frontend-module-engine-v2 0.0.0-stage → 0.0.0-tp
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +88 -0
- package/README.md +86 -2
- package/biome.jsonc +4 -0
- package/oxlint.config.mts +4 -0
- package/package.json +54 -3
- package/src/__tests__/design-system-icons.test.ts +24 -0
- package/src/__tests__/mocks.ts +34 -0
- package/src/__tests__/setup.ts +4 -0
- package/src/components/EngineV2CompatibilityButton.test.ts +67 -0
- package/src/components/EngineV2CompatibilityButton.vue +53 -0
- package/src/components/EngineV2CompatibilityDialog.test.ts +301 -0
- package/src/components/EngineV2CompatibilityDialog.vue +109 -0
- package/src/components/severityIcon.ts +20 -0
- package/src/composables/useEngineV2Compatibility.test.ts +171 -0
- package/src/composables/useEngineV2Compatibility.ts +58 -0
- package/src/engine-v2.module.test.ts +9 -0
- package/src/engine-v2.module.ts +31 -0
- package/src/engineV2Check.test.ts +67 -0
- package/src/engineV2Check.ts +34 -0
- package/src/engineV2ReasonText.ts +106 -0
- package/src/index.ts +11 -0
- package/stylelint.config.mjs +9 -0
- package/vite.config.ts +52 -0
- package/vize-lint.config.mjs +3 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { useI18n, type BaseTextKey } from '@n8n/i18n';
|
|
2
|
+
import { render } from '@testing-library/vue';
|
|
3
|
+
|
|
4
|
+
import type { EngineCompatibilityReason } from '../engineV2Check';
|
|
5
|
+
import EngineV2CompatibilityDialog from './EngineV2CompatibilityDialog.vue';
|
|
6
|
+
|
|
7
|
+
type Code = EngineCompatibilityReason['code'];
|
|
8
|
+
type Kind = EngineCompatibilityReason['kind'];
|
|
9
|
+
|
|
10
|
+
const V1_ADVICE = 'Run this workflow on Engine v1 for now.';
|
|
11
|
+
|
|
12
|
+
// The dialog renders into `document.body`, where the queries of `render` look, after the mount.
|
|
13
|
+
async function renderDialog(reasons: EngineCompatibilityReason[]) {
|
|
14
|
+
const result = render(EngineV2CompatibilityDialog, { props: { reasons, open: true } });
|
|
15
|
+
await result.findByTestId('engine-v2-compatibility-dialog');
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function reasonTexts(getAllByTestId: (id: string) => HTMLElement[]) {
|
|
20
|
+
return getAllByTestId('engine-v2-compatibility-reason').map((item) => item.textContent?.trim());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function reason(
|
|
24
|
+
code: Code,
|
|
25
|
+
kind: Kind,
|
|
26
|
+
overrides: Partial<EngineCompatibilityReason> = {},
|
|
27
|
+
): EngineCompatibilityReason {
|
|
28
|
+
return {
|
|
29
|
+
code,
|
|
30
|
+
kind,
|
|
31
|
+
severity: 'blocking',
|
|
32
|
+
message: `Package message for ${code}.`,
|
|
33
|
+
...overrides,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The codes whose text the editor has: `[code, kind, key]`. */
|
|
38
|
+
const OWN_TEXT: Array<[Code, Kind, BaseTextKey]> = [
|
|
39
|
+
['ERROR_WORKFLOW', 'temporary', 'engineV2Compatibility.reason.errorWorkflow'],
|
|
40
|
+
['REDACTION_POLICY', 'temporary', 'engineV2Compatibility.reason.redactionPolicy'],
|
|
41
|
+
['END_USER_CREDENTIALS', 'temporary', 'engineV2Compatibility.reason.endUserCredentials'],
|
|
42
|
+
[
|
|
43
|
+
'TRIGGER_EXTERNAL_IDENTITY',
|
|
44
|
+
'temporary',
|
|
45
|
+
'engineV2Compatibility.reason.triggerExternalIdentity',
|
|
46
|
+
],
|
|
47
|
+
['AI_NODE', 'temporary', 'engineV2Compatibility.reason.aiNode'],
|
|
48
|
+
['CHAT_NODE', 'temporary', 'engineV2Compatibility.reason.unsupportedNode'],
|
|
49
|
+
['COMMUNITY_NODE', 'temporary', 'engineV2Compatibility.reason.communityNode'],
|
|
50
|
+
['EVALUATION_NODE', 'temporary', 'engineV2Compatibility.reason.unsupportedNode'],
|
|
51
|
+
['EXECUTION_DATA_NODE', 'temporary', 'engineV2Compatibility.reason.unsupportedNode'],
|
|
52
|
+
['FORM_NODE', 'temporary', 'engineV2Compatibility.reason.unsupportedNode'],
|
|
53
|
+
['MCP_SERVER_TRIGGER', 'temporary', 'engineV2Compatibility.reason.unsupportedNode'],
|
|
54
|
+
['MESSAGE_AN_AGENT_NODE', 'temporary', 'engineV2Compatibility.reason.unsupportedNode'],
|
|
55
|
+
['MICROSOFT_AGENT365_TRIGGER', 'temporary', 'engineV2Compatibility.reason.unsupportedNode'],
|
|
56
|
+
['TIME_SAVED_NODE', 'temporary', 'engineV2Compatibility.reason.unsupportedNode'],
|
|
57
|
+
['TRIGGER_WAITS_FOR_RUN', 'temporary', 'engineV2Compatibility.reason.unsupportedNode'],
|
|
58
|
+
['CONTINUE_ERROR_OUTPUT', 'temporary', 'engineV2Compatibility.reason.continueErrorOutput'],
|
|
59
|
+
['RETRY_ON_FAIL', 'temporary', 'engineV2Compatibility.reason.retryOnFail'],
|
|
60
|
+
['ALWAYS_OUTPUT_DATA', 'temporary', 'engineV2Compatibility.reason.alwaysOutputData'],
|
|
61
|
+
['EXECUTE_ONCE', 'temporary', 'engineV2Compatibility.reason.executeOnce'],
|
|
62
|
+
['MERGE_CHOOSE_BRANCH', 'temporary', 'engineV2Compatibility.reason.mergeChooseBranch'],
|
|
63
|
+
['MERGE_MODE_EXPRESSION', 'permanent', 'engineV2Compatibility.reason.mergeModeExpression'],
|
|
64
|
+
[
|
|
65
|
+
'SPLIT_IN_BATCHES_OPTIONS_EXPRESSION',
|
|
66
|
+
'permanent',
|
|
67
|
+
'engineV2Compatibility.reason.splitInBatchesOptionsExpression',
|
|
68
|
+
],
|
|
69
|
+
['SPLIT_IN_BATCHES_RESET', 'temporary', 'engineV2Compatibility.reason.splitInBatchesReset'],
|
|
70
|
+
[
|
|
71
|
+
'SPLIT_IN_BATCHES_BATCH_SIZE',
|
|
72
|
+
'permanent',
|
|
73
|
+
'engineV2Compatibility.reason.splitInBatchesBatchSize.expression',
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
'SPLIT_IN_BATCHES_BATCH_SIZE',
|
|
77
|
+
'invalid',
|
|
78
|
+
'engineV2Compatibility.reason.splitInBatchesBatchSize.invalid',
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
'SUB_WORKFLOW_FOR_EACH_ITEM',
|
|
82
|
+
'permanent',
|
|
83
|
+
'engineV2Compatibility.reason.subWorkflowForEachItem',
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
'SUB_WORKFLOW_NOT_IN_DATABASE',
|
|
87
|
+
'permanent',
|
|
88
|
+
'engineV2Compatibility.reason.subWorkflowNotInDatabase',
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
'CYCLE_WITHOUT_SPLIT_IN_BATCHES',
|
|
92
|
+
'temporary',
|
|
93
|
+
'engineV2Compatibility.reason.cycleWithoutSplitInBatches',
|
|
94
|
+
],
|
|
95
|
+
['LOOP_ENTERED_MID_BODY', 'permanent', 'engineV2Compatibility.reason.loopEnteredMidBody'],
|
|
96
|
+
['LOOP_WITHOUT_RETURN', 'permanent', 'engineV2Compatibility.reason.loopWithoutReturn'],
|
|
97
|
+
['LOOP_INPUT_NOT_FIRST', 'permanent', 'engineV2Compatibility.reason.loopInputNotFirst'],
|
|
98
|
+
[
|
|
99
|
+
'LOOP_DONE_OUTPUT_FEEDS_BODY',
|
|
100
|
+
'permanent',
|
|
101
|
+
'engineV2Compatibility.reason.loopDoneOutputFeedsBody',
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
'LOOP_OUTPUT_NOT_DONE_OR_LOOP',
|
|
105
|
+
'invalid',
|
|
106
|
+
'engineV2Compatibility.reason.loopOutputNotDoneOrLoop',
|
|
107
|
+
],
|
|
108
|
+
[
|
|
109
|
+
'NODE_REACHED_ONLY_THROUGH_DISABLED_NODE',
|
|
110
|
+
'invalid',
|
|
111
|
+
'engineV2Compatibility.reason.nodeReachedOnlyThroughDisabledNode',
|
|
112
|
+
],
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
/** The codes whose `message` carries details that a fixed text can't hold. */
|
|
116
|
+
const PACKAGE_MESSAGE: Code[] = [
|
|
117
|
+
'NESTED_LOOP',
|
|
118
|
+
'LOOP_EXITS_MID_BODY',
|
|
119
|
+
'LOOP_MULTIPLE_ENTRIES',
|
|
120
|
+
'LOOP_MULTIPLE_RETURNS',
|
|
121
|
+
'INPUT_SLOT_CONVERGENCE',
|
|
122
|
+
'NON_MAIN_CONNECTION',
|
|
123
|
+
'SPLIT_IN_BATCHES_VERSION',
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
describe('EngineV2CompatibilityDialog', () => {
|
|
127
|
+
const i18n = useI18n();
|
|
128
|
+
|
|
129
|
+
it('lists every reason', async () => {
|
|
130
|
+
const { getAllByTestId } = await renderDialog([
|
|
131
|
+
reason('MERGE_MODE_EXPRESSION', 'permanent'),
|
|
132
|
+
reason('LOOP_WITHOUT_RETURN', 'permanent'),
|
|
133
|
+
]);
|
|
134
|
+
|
|
135
|
+
expect(reasonTexts(getAllByTestId)).toEqual([
|
|
136
|
+
i18n.baseText('engineV2Compatibility.reason.mergeModeExpression'),
|
|
137
|
+
i18n.baseText('engineV2Compatibility.reason.loopWithoutReturn'),
|
|
138
|
+
]);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('shows the node name before the text when the reason has one', async () => {
|
|
142
|
+
const { getAllByTestId } = await renderDialog([
|
|
143
|
+
reason('LOOP_WITHOUT_RETURN', 'permanent', { nodeId: 'node-1', nodeName: 'Loop Over Items' }),
|
|
144
|
+
]);
|
|
145
|
+
|
|
146
|
+
expect(reasonTexts(getAllByTestId)).toEqual([
|
|
147
|
+
`Loop Over Items: ${i18n.baseText('engineV2Compatibility.reason.loopWithoutReturn')}`,
|
|
148
|
+
]);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it.each(OWN_TEXT)('shows its own text for %s (%s)', async (code, kind, key) => {
|
|
152
|
+
const { getAllByTestId } = await renderDialog([reason(code, kind)]);
|
|
153
|
+
|
|
154
|
+
const text = i18n.baseText(key);
|
|
155
|
+
expect(text).not.toBe(key);
|
|
156
|
+
expect(reasonTexts(getAllByTestId)).toEqual([
|
|
157
|
+
kind === 'temporary' ? `${text} ${V1_ADVICE}` : text,
|
|
158
|
+
]);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('tells the two meanings of SPLIT_IN_BATCHES_BATCH_SIZE apart', async () => {
|
|
162
|
+
const { getAllByTestId } = await renderDialog([
|
|
163
|
+
reason('SPLIT_IN_BATCHES_BATCH_SIZE', 'permanent'),
|
|
164
|
+
reason('SPLIT_IN_BATCHES_BATCH_SIZE', 'invalid'),
|
|
165
|
+
]);
|
|
166
|
+
|
|
167
|
+
const [expression, invalid] = reasonTexts(getAllByTestId);
|
|
168
|
+
expect(expression).not.toBe(invalid);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it.each(PACKAGE_MESSAGE)('shows the package message for %s, as it comes', async (code) => {
|
|
172
|
+
const message = `Details only the package knows. ${V1_ADVICE}`;
|
|
173
|
+
const { getAllByTestId } = await renderDialog([reason(code, 'temporary', { message })]);
|
|
174
|
+
|
|
175
|
+
expect(reasonTexts(getAllByTestId)).toEqual([message]);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('shows no node name before a package message that already names the node', async () => {
|
|
179
|
+
const { getAllByTestId } = await renderDialog([
|
|
180
|
+
reason('NESTED_LOOP', 'temporary', {
|
|
181
|
+
nodeName: 'Inner',
|
|
182
|
+
message: 'The loop of "Inner" is inside the loop of "Outer".',
|
|
183
|
+
}),
|
|
184
|
+
]);
|
|
185
|
+
|
|
186
|
+
expect(reasonTexts(getAllByTestId)).toEqual([
|
|
187
|
+
'The loop of "Inner" is inside the loop of "Outer".',
|
|
188
|
+
]);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('shows the node name before a package message that does not name the node', async () => {
|
|
192
|
+
const { getAllByTestId } = await renderDialog([
|
|
193
|
+
reason('NESTED_LOOP', 'temporary', { nodeName: 'Inner', message: "Loops can't nest yet." }),
|
|
194
|
+
]);
|
|
195
|
+
|
|
196
|
+
expect(reasonTexts(getAllByTestId)).toEqual(["Inner: Loops can't nest yet."]);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('shows the package message for an unknown code', async () => {
|
|
200
|
+
const { getAllByTestId } = await renderDialog([
|
|
201
|
+
// A newer package can return a code that this editor does not know.
|
|
202
|
+
reason('FUTURE_CODE' as Code, 'permanent', {
|
|
203
|
+
message: 'Engine v2 does not support this.',
|
|
204
|
+
}),
|
|
205
|
+
]);
|
|
206
|
+
|
|
207
|
+
expect(reasonTexts(getAllByTestId)).toEqual(['Engine v2 does not support this.']);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('uses the blocking title when a reason blocks', async () => {
|
|
211
|
+
const { getByTestId } = await renderDialog([
|
|
212
|
+
reason('REDACTION_POLICY', 'temporary', { severity: 'warning' }),
|
|
213
|
+
reason('ERROR_WORKFLOW', 'temporary'),
|
|
214
|
+
]);
|
|
215
|
+
|
|
216
|
+
expect(getByTestId('engine-v2-compatibility-dialog')).toHaveTextContent(
|
|
217
|
+
i18n.baseText('engineV2Compatibility.dialog.title'),
|
|
218
|
+
);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('explains the list, and how to publish, when a reason blocks', async () => {
|
|
222
|
+
const { getByTestId } = await renderDialog([
|
|
223
|
+
reason('REDACTION_POLICY', 'temporary', { severity: 'warning' }),
|
|
224
|
+
reason('ERROR_WORKFLOW', 'temporary'),
|
|
225
|
+
]);
|
|
226
|
+
|
|
227
|
+
expect(getByTestId('engine-v2-compatibility-intro')).toHaveTextContent(
|
|
228
|
+
i18n.baseText('engineV2Compatibility.dialog.intro'),
|
|
229
|
+
);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('explains the list of warnings when no reason blocks', async () => {
|
|
233
|
+
const { getByTestId } = await renderDialog([
|
|
234
|
+
reason('REDACTION_POLICY', 'temporary', { severity: 'warning' }),
|
|
235
|
+
]);
|
|
236
|
+
|
|
237
|
+
expect(getByTestId('engine-v2-compatibility-intro')).toHaveTextContent(
|
|
238
|
+
i18n.baseText('engineV2Compatibility.dialog.introWarnings'),
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('shows the introduction before the list', async () => {
|
|
243
|
+
const { getByTestId, getAllByTestId } = await renderDialog([
|
|
244
|
+
reason('ERROR_WORKFLOW', 'temporary'),
|
|
245
|
+
]);
|
|
246
|
+
|
|
247
|
+
const [firstReason] = getAllByTestId('engine-v2-compatibility-reason');
|
|
248
|
+
expect(
|
|
249
|
+
getByTestId('engine-v2-compatibility-intro').compareDocumentPosition(firstReason) &
|
|
250
|
+
Node.DOCUMENT_POSITION_FOLLOWING,
|
|
251
|
+
).toBeTruthy();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('uses the warning title when no reason blocks', async () => {
|
|
255
|
+
const { getByTestId } = await renderDialog([
|
|
256
|
+
reason('REDACTION_POLICY', 'temporary', { severity: 'warning' }),
|
|
257
|
+
]);
|
|
258
|
+
|
|
259
|
+
expect(getByTestId('engine-v2-compatibility-dialog')).toHaveTextContent(
|
|
260
|
+
i18n.baseText('engineV2Compatibility.dialog.titleWarnings'),
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('gives each entry the icon of its severity', async () => {
|
|
265
|
+
const { getAllByTestId } = await renderDialog([
|
|
266
|
+
reason('ERROR_WORKFLOW', 'temporary'),
|
|
267
|
+
reason('REDACTION_POLICY', 'temporary', { severity: 'warning' }),
|
|
268
|
+
]);
|
|
269
|
+
|
|
270
|
+
const icons = getAllByTestId('engine-v2-compatibility-reason').map((item) =>
|
|
271
|
+
item.querySelector('[data-icon]')?.getAttribute('data-icon'),
|
|
272
|
+
);
|
|
273
|
+
expect(icons).toEqual(['circle-x', 'triangle-alert']);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('lists blocking reasons first, each group in the order of the check', async () => {
|
|
277
|
+
const { getAllByTestId } = await renderDialog([
|
|
278
|
+
reason('ERROR_WORKFLOW', 'temporary', { severity: 'warning', nodeName: 'A' }),
|
|
279
|
+
reason('ERROR_WORKFLOW', 'temporary', { nodeName: 'B' }),
|
|
280
|
+
reason('ERROR_WORKFLOW', 'temporary', { severity: 'warning', nodeName: 'C' }),
|
|
281
|
+
reason('ERROR_WORKFLOW', 'temporary', { nodeName: 'D' }),
|
|
282
|
+
]);
|
|
283
|
+
|
|
284
|
+
const names = getAllByTestId('engine-v2-compatibility-reason').map(
|
|
285
|
+
(item) => item.querySelector('strong')?.textContent,
|
|
286
|
+
);
|
|
287
|
+
expect(names).toEqual(['B: ', 'D: ', 'A: ', 'C: ']);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('puts a long list in the scrolling body of the dialog', async () => {
|
|
291
|
+
const reasons = Array.from({ length: 60 }, (_, index) =>
|
|
292
|
+
reason('FORM_NODE', 'temporary', { nodeName: `Form ${index}` }),
|
|
293
|
+
);
|
|
294
|
+
const { getAllByTestId, baseElement } = await renderDialog(reasons);
|
|
295
|
+
|
|
296
|
+
const body = baseElement.querySelector('[data-slot="dialog-body"]');
|
|
297
|
+
const items = getAllByTestId('engine-v2-compatibility-reason');
|
|
298
|
+
expect(items).toHaveLength(60);
|
|
299
|
+
expect(items.every((item) => body?.contains(item))).toBe(true);
|
|
300
|
+
});
|
|
301
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { N8nDialog, N8nDialogBody, N8nIcon, N8nText } from '@n8n/design-system';
|
|
3
|
+
import { useI18n } from '@n8n/i18n';
|
|
4
|
+
import { computed } from 'vue';
|
|
5
|
+
|
|
6
|
+
import type { EngineCompatibilityReason } from '../engineV2Check';
|
|
7
|
+
import { describeCompatibilityReason } from '../engineV2ReasonText';
|
|
8
|
+
import { severityIcon, worstSeverity } from './severityIcon';
|
|
9
|
+
|
|
10
|
+
const { reasons } = defineProps<{
|
|
11
|
+
reasons: EngineCompatibilityReason[];
|
|
12
|
+
}>();
|
|
13
|
+
|
|
14
|
+
const open = defineModel<boolean>('open', { required: true });
|
|
15
|
+
|
|
16
|
+
const i18n = useI18n();
|
|
17
|
+
|
|
18
|
+
const isBlocked = computed(() => worstSeverity(reasons) === 'blocking');
|
|
19
|
+
|
|
20
|
+
const title = computed(() =>
|
|
21
|
+
i18n.baseText(
|
|
22
|
+
isBlocked.value
|
|
23
|
+
? 'engineV2Compatibility.dialog.title'
|
|
24
|
+
: 'engineV2Compatibility.dialog.titleWarnings',
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const intro = computed(() =>
|
|
29
|
+
i18n.baseText(
|
|
30
|
+
isBlocked.value
|
|
31
|
+
? 'engineV2Compatibility.dialog.intro'
|
|
32
|
+
: 'engineV2Compatibility.dialog.introWarnings',
|
|
33
|
+
),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Blocking reasons first. Each group keeps the order of the check.
|
|
37
|
+
const items = computed(() =>
|
|
38
|
+
[
|
|
39
|
+
...reasons.filter((reason) => reason.severity === 'blocking'),
|
|
40
|
+
...reasons.filter((reason) => reason.severity !== 'blocking'),
|
|
41
|
+
].map((reason, index) => ({
|
|
42
|
+
id: `${index}-${reason.code}`,
|
|
43
|
+
...severityIcon(reason.severity),
|
|
44
|
+
...describeCompatibilityReason(reason),
|
|
45
|
+
})),
|
|
46
|
+
);
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<N8nDialog
|
|
51
|
+
v-model:open="open"
|
|
52
|
+
size="medium"
|
|
53
|
+
:header="title"
|
|
54
|
+
data-test-id="engine-v2-compatibility-dialog"
|
|
55
|
+
>
|
|
56
|
+
<N8nDialogBody>
|
|
57
|
+
<N8nText
|
|
58
|
+
tag="p"
|
|
59
|
+
size="small"
|
|
60
|
+
:class="$style.intro"
|
|
61
|
+
data-test-id="engine-v2-compatibility-intro"
|
|
62
|
+
>
|
|
63
|
+
{{ intro }}
|
|
64
|
+
</N8nText>
|
|
65
|
+
<ul :class="$style.reasons">
|
|
66
|
+
<li
|
|
67
|
+
v-for="item in items"
|
|
68
|
+
:key="item.id"
|
|
69
|
+
:class="$style.reason"
|
|
70
|
+
data-test-id="engine-v2-compatibility-reason"
|
|
71
|
+
>
|
|
72
|
+
<N8nIcon :icon="item.icon" :color="item.color" :class="$style.icon" />
|
|
73
|
+
<span>
|
|
74
|
+
<strong v-if="item.nodeName">{{ item.nodeName }}: </strong>{{ item.text }}
|
|
75
|
+
</span>
|
|
76
|
+
</li>
|
|
77
|
+
</ul>
|
|
78
|
+
</N8nDialogBody>
|
|
79
|
+
</N8nDialog>
|
|
80
|
+
</template>
|
|
81
|
+
|
|
82
|
+
<style lang="scss" module>
|
|
83
|
+
.intro {
|
|
84
|
+
display: block;
|
|
85
|
+
margin: 0 0 var(--spacing--md);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.reasons {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
gap: var(--spacing--sm);
|
|
92
|
+
margin: 0;
|
|
93
|
+
padding: 0;
|
|
94
|
+
list-style: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.reason {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: flex-start;
|
|
100
|
+
gap: var(--spacing--xs);
|
|
101
|
+
font-size: var(--font-size--sm);
|
|
102
|
+
line-height: var(--line-height--lg);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.icon {
|
|
106
|
+
flex-shrink: 0;
|
|
107
|
+
margin-top: var(--spacing--5xs);
|
|
108
|
+
}
|
|
109
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IconColor, IconName } from '@n8n/design-system';
|
|
2
|
+
|
|
3
|
+
import type { EngineCompatibilityReason } from '../engineV2Check';
|
|
4
|
+
|
|
5
|
+
type Severity = EngineCompatibilityReason['severity'];
|
|
6
|
+
|
|
7
|
+
/** The icon depends on the severity only, so a new reason code needs no icon. */
|
|
8
|
+
const SEVERITY_ICONS: Record<Severity, { icon: IconName; color: IconColor }> = {
|
|
9
|
+
blocking: { icon: 'circle-x', color: 'danger' },
|
|
10
|
+
warning: { icon: 'triangle-alert', color: 'warning' },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function severityIcon(severity: Severity) {
|
|
14
|
+
return SEVERITY_ICONS[severity];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The icon of a list: blocking when any reason blocks. */
|
|
18
|
+
export function worstSeverity(reasons: EngineCompatibilityReason[]): Severity {
|
|
19
|
+
return reasons.some((reason) => reason.severity === 'blocking') ? 'blocking' : 'warning';
|
|
20
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { useSettingsStore } from '@n8n/stores/settings.store';
|
|
2
|
+
import type { IWorkflowSettings } from 'n8n-workflow';
|
|
3
|
+
import { ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
import { mockEngineV2Compatibility } from '../__tests__/mocks';
|
|
6
|
+
import type { EngineCompatibilityReason } from '../engineV2Check';
|
|
7
|
+
import { describeEngineV2Block, useEngineV2Compatibility } from './useEngineV2Compatibility';
|
|
8
|
+
|
|
9
|
+
const blockingReason: EngineCompatibilityReason = {
|
|
10
|
+
code: 'TRIGGER_EXTERNAL_IDENTITY',
|
|
11
|
+
kind: 'temporary',
|
|
12
|
+
severity: 'blocking',
|
|
13
|
+
nodeId: 'node-1',
|
|
14
|
+
nodeName: 'Webhook',
|
|
15
|
+
message: 'Engine v2 cannot run the "Webhook" trigger yet.',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const warningReason: EngineCompatibilityReason = {
|
|
19
|
+
code: 'ERROR_WORKFLOW',
|
|
20
|
+
kind: 'temporary',
|
|
21
|
+
severity: 'warning',
|
|
22
|
+
message: 'Engine v2 does not run an error workflow yet.',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function setup({
|
|
26
|
+
moduleActive,
|
|
27
|
+
settings,
|
|
28
|
+
}: {
|
|
29
|
+
moduleActive: boolean;
|
|
30
|
+
settings: IWorkflowSettings | undefined;
|
|
31
|
+
}) {
|
|
32
|
+
useSettingsStore().settings.activeModules = moduleActive ? ['engine-v2'] : [];
|
|
33
|
+
return useCompatibility(settings);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function useCompatibility(settings: IWorkflowSettings | undefined) {
|
|
37
|
+
const workflowSettings = ref(settings);
|
|
38
|
+
const settingsSnapshot = vi.fn(() => ({ ...workflowSettings.value }));
|
|
39
|
+
const compatibility = useEngineV2Compatibility({
|
|
40
|
+
nodes: () => [],
|
|
41
|
+
connections: () => ({}),
|
|
42
|
+
settings: () => workflowSettings.value,
|
|
43
|
+
settingsSnapshot,
|
|
44
|
+
});
|
|
45
|
+
return { workflowSettings, settingsSnapshot, ...compatibility };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe('useEngineV2Compatibility', () => {
|
|
49
|
+
it.each([
|
|
50
|
+
['the module is off', false, { engineType: 'v2' } satisfies IWorkflowSettings],
|
|
51
|
+
['the workflow runs on v1', true, { engineType: 'v1' } satisfies IWorkflowSettings],
|
|
52
|
+
['the workflow has no engine type', true, {}],
|
|
53
|
+
['the workflow has no settings', true, undefined],
|
|
54
|
+
])('reports nothing and never runs the check when %s', (_case, moduleActive, settings) => {
|
|
55
|
+
const { checkWorkflow, isNodeTypeSupported } = mockEngineV2Compatibility({
|
|
56
|
+
reasons: [blockingReason],
|
|
57
|
+
unsupportedNodeTypes: ['n8n-nodes-base.webhook'],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const { reasons, blockingReasons, isNodeTypeIncompatible, settingsSnapshot } = setup({
|
|
61
|
+
moduleActive,
|
|
62
|
+
settings,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
expect(reasons.value).toEqual([]);
|
|
66
|
+
expect(blockingReasons.value).toEqual([]);
|
|
67
|
+
expect(isNodeTypeIncompatible('n8n-nodes-base.webhook')).toBe(false);
|
|
68
|
+
expect(checkWorkflow).not.toHaveBeenCalled();
|
|
69
|
+
expect(isNodeTypeSupported).not.toHaveBeenCalled();
|
|
70
|
+
expect(settingsSnapshot).not.toHaveBeenCalled();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('reports nothing, and `false` for a node type, before the settings load', () => {
|
|
74
|
+
mockEngineV2Compatibility({ unsupportedNodeTypes: ['n8n-nodes-base.webhook'] });
|
|
75
|
+
useSettingsStore().settings.activeModules = undefined as unknown as string[];
|
|
76
|
+
|
|
77
|
+
const { reasons, isNodeTypeIncompatible } = useCompatibility({ engineType: 'v2' });
|
|
78
|
+
|
|
79
|
+
expect(reasons.value).toEqual([]);
|
|
80
|
+
expect(isNodeTypeIncompatible('n8n-nodes-base.webhook')).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('returns the reasons of the check when the module is on and the workflow runs on v2', () => {
|
|
84
|
+
mockEngineV2Compatibility({ reasons: [blockingReason, warningReason] });
|
|
85
|
+
|
|
86
|
+
const { reasons, blockingReasons } = setup({
|
|
87
|
+
moduleActive: true,
|
|
88
|
+
settings: { engineType: 'v2' },
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(reasons.value).toEqual([blockingReason, warningReason]);
|
|
92
|
+
expect(blockingReasons.value).toEqual([blockingReason]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('reports a node type as incompatible only when the check does not support it', () => {
|
|
96
|
+
mockEngineV2Compatibility({ unsupportedNodeTypes: ['n8n-nodes-base.webhook'] });
|
|
97
|
+
|
|
98
|
+
const { isNodeTypeIncompatible } = setup({
|
|
99
|
+
moduleActive: true,
|
|
100
|
+
settings: { engineType: 'v2' },
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
expect(isNodeTypeIncompatible('n8n-nodes-base.webhook')).toBe(true);
|
|
104
|
+
expect(isNodeTypeIncompatible('n8n-nodes-base.set')).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('does not run the workflow check to answer a node type question', () => {
|
|
108
|
+
const { checkWorkflow } = mockEngineV2Compatibility();
|
|
109
|
+
|
|
110
|
+
const { isNodeTypeIncompatible } = setup({
|
|
111
|
+
moduleActive: true,
|
|
112
|
+
settings: { engineType: 'v2' },
|
|
113
|
+
});
|
|
114
|
+
isNodeTypeIncompatible('n8n-nodes-base.webhook');
|
|
115
|
+
|
|
116
|
+
expect(checkWorkflow).not.toHaveBeenCalled();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('follows a change of the engine type', () => {
|
|
120
|
+
mockEngineV2Compatibility({
|
|
121
|
+
reasons: [blockingReason],
|
|
122
|
+
unsupportedNodeTypes: ['n8n-nodes-base.webhook'],
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const { workflowSettings, reasons, isNodeTypeIncompatible } = setup({
|
|
126
|
+
moduleActive: true,
|
|
127
|
+
settings: { engineType: 'v2' },
|
|
128
|
+
});
|
|
129
|
+
expect(reasons.value).toEqual([blockingReason]);
|
|
130
|
+
|
|
131
|
+
workflowSettings.value = { engineType: 'v1' };
|
|
132
|
+
|
|
133
|
+
expect(reasons.value).toEqual([]);
|
|
134
|
+
expect(isNodeTypeIncompatible('n8n-nodes-base.webhook')).toBe(false);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('passes the workflow to the check', () => {
|
|
138
|
+
const { checkWorkflow } = mockEngineV2Compatibility();
|
|
139
|
+
useSettingsStore().settings.activeModules = ['engine-v2'];
|
|
140
|
+
const node = {
|
|
141
|
+
id: 'node-1',
|
|
142
|
+
name: 'Webhook',
|
|
143
|
+
type: 'n8n-nodes-base.webhook',
|
|
144
|
+
typeVersion: 2,
|
|
145
|
+
position: [0, 0] as [number, number],
|
|
146
|
+
parameters: {},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const { reasons } = useEngineV2Compatibility({
|
|
150
|
+
nodes: () => [node],
|
|
151
|
+
connections: () => ({ Webhook: { main: [[]] } }),
|
|
152
|
+
settings: () => ({ engineType: 'v2' }),
|
|
153
|
+
settingsSnapshot: () => ({ engineType: 'v2' }),
|
|
154
|
+
});
|
|
155
|
+
void reasons.value;
|
|
156
|
+
|
|
157
|
+
expect(checkWorkflow).toHaveBeenCalledWith({
|
|
158
|
+
nodes: [node],
|
|
159
|
+
connections: { Webhook: { main: [[]] } },
|
|
160
|
+
settings: { engineType: 'v2' },
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe('describeEngineV2Block', () => {
|
|
166
|
+
it('returns the publish tooltip text', () => {
|
|
167
|
+
expect(describeEngineV2Block()).toBe(
|
|
168
|
+
"This workflow can't run on Engine v2 yet. Select the Engine v2 issues button on the canvas to see why.",
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useI18n } from '@n8n/i18n';
|
|
2
|
+
import { useSettingsStore } from '@n8n/stores/settings.store';
|
|
3
|
+
import type { IConnections, INode, IWorkflowSettings } from 'n8n-workflow';
|
|
4
|
+
import { computed } from 'vue';
|
|
5
|
+
|
|
6
|
+
import { EngineV2Module } from '../engine-v2.module';
|
|
7
|
+
import { engineV2Check, type EngineCompatibilityReason } from '../engineV2Check';
|
|
8
|
+
|
|
9
|
+
/** Getters for the open workflow. The shell owns the document store, so it passes them in. */
|
|
10
|
+
export interface EngineV2CompatibilityWorkflowSource {
|
|
11
|
+
nodes: () => INode[];
|
|
12
|
+
connections: () => IConnections;
|
|
13
|
+
/** The settings the gate reads on every call. A read-only view works. */
|
|
14
|
+
settings: () => Pick<IWorkflowSettings, 'engineType'> | undefined;
|
|
15
|
+
/** A copy of the settings for the check. Read only when the gate is open. */
|
|
16
|
+
settingsSnapshot: () => IWorkflowSettings;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The engine v2 compatibility of the open workflow. Everything reports "compatible" unless the
|
|
21
|
+
* `engine-v2` module is active and the workflow runs on engine v2.
|
|
22
|
+
*/
|
|
23
|
+
export function useEngineV2Compatibility(workflow: EngineV2CompatibilityWorkflowSource) {
|
|
24
|
+
const settingsStore = useSettingsStore();
|
|
25
|
+
|
|
26
|
+
const isActive = computed(
|
|
27
|
+
() =>
|
|
28
|
+
settingsStore.isModuleActive(EngineV2Module.id) && workflow.settings()?.engineType === 'v2',
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const reasons = computed((): EngineCompatibilityReason[] => {
|
|
32
|
+
if (!isActive.value) return [];
|
|
33
|
+
|
|
34
|
+
return engineV2Check.checkWorkflow({
|
|
35
|
+
nodes: workflow.nodes(),
|
|
36
|
+
connections: workflow.connections(),
|
|
37
|
+
settings: workflow.settingsSnapshot(),
|
|
38
|
+
}).reasons;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const blockingReasons = computed(() =>
|
|
42
|
+
reasons.value.filter((reason) => reason.severity === 'blocking'),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
/** Reads only the gate and the node-type answer, so a node creator row never runs the check. */
|
|
46
|
+
function isNodeTypeIncompatible(nodeTypeName: string): boolean {
|
|
47
|
+
// Not `isActive.value && …`: before the settings load, `isModuleActive` returns `undefined`.
|
|
48
|
+
if (!isActive.value) return false;
|
|
49
|
+
return !engineV2Check.isNodeTypeSupported(nodeTypeName);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return { reasons, blockingReasons, isNodeTypeIncompatible };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Why engine v2 blocks publishing. The publish tooltip and the publish toast use it. */
|
|
56
|
+
export function describeEngineV2Block(): string {
|
|
57
|
+
return useI18n().baseText('engineV2Compatibility.publishBlocked');
|
|
58
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EngineV2Module } from './engine-v2.module';
|
|
2
|
+
|
|
3
|
+
describe('EngineV2Module', () => {
|
|
4
|
+
it('keeps the id the backend module publishes in `activeModules`', () => {
|
|
5
|
+
// A mismatch is silent: `isModuleActive` compares strings, so the module would
|
|
6
|
+
// never report active. The twin is `packages/cli/src/modules/engine-v2`.
|
|
7
|
+
expect(EngineV2Module.id).toBe('engine-v2');
|
|
8
|
+
});
|
|
9
|
+
});
|