-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Sync partial execution version of FE and BE, also allow enforcin…
…g a specific version (#12840) Co-authored-by: Iván Ovejero <[email protected]>
- Loading branch information
1 parent
a65a9e6
commit a155043
Showing
21 changed files
with
193 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/@n8n/api-types/src/dto/workflows/__tests__/manual-run-query.dto.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { ManualRunQueryDto } from '../manual-run-query.dto'; | ||
|
||
describe('ManualRunQueryDto', () => { | ||
describe('Valid requests', () => { | ||
test.each([ | ||
{ name: 'version number 1', partialExecutionVersion: '1' }, | ||
{ name: 'version number 2', partialExecutionVersion: '2' }, | ||
{ name: 'missing version' }, | ||
])('should validate $name', ({ partialExecutionVersion }) => { | ||
const result = ManualRunQueryDto.safeParse({ partialExecutionVersion }); | ||
|
||
if (!result.success) { | ||
return fail('expected validation to succeed'); | ||
} | ||
expect(result.success).toBe(true); | ||
expect(typeof result.data.partialExecutionVersion).toBe('number'); | ||
}); | ||
}); | ||
|
||
describe('Invalid requests', () => { | ||
test.each([ | ||
{ | ||
name: 'invalid version 0', | ||
partialExecutionVersion: '0', | ||
expectedErrorPath: ['partialExecutionVersion'], | ||
}, | ||
{ | ||
name: 'invalid type (boolean)', | ||
partialExecutionVersion: true, | ||
expectedErrorPath: ['partialExecutionVersion'], | ||
}, | ||
{ | ||
name: 'invalid type (number)', | ||
partialExecutionVersion: 1, | ||
expectedErrorPath: ['partialExecutionVersion'], | ||
}, | ||
])('should fail validation for $name', ({ partialExecutionVersion, expectedErrorPath }) => { | ||
const result = ManualRunQueryDto.safeParse({ partialExecutionVersion }); | ||
|
||
if (result.success) { | ||
return fail('expected validation to fail'); | ||
} | ||
|
||
expect(result.error.issues[0].path).toEqual(expectedErrorPath); | ||
}); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/@n8n/api-types/src/dto/workflows/manual-run-query.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
export class ManualRunQueryDto extends Z.class({ | ||
partialExecutionVersion: z | ||
.enum(['1', '2']) | ||
.default('1') | ||
.transform((version) => Number.parseInt(version) as 1 | 2), | ||
}) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/@n8n/config/src/configs/partial-executions.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Config, Env } from '../decorators'; | ||
|
||
@Config | ||
export class PartialExecutionsConfig { | ||
/** Partial execution logic version to use by default. */ | ||
@Env('N8N_PARTIAL_EXECUTION_VERSION_DEFAULT') | ||
version: 1 | 2 = 1; | ||
|
||
/** Set this to true to enforce using the default version. Users cannot use the other version then by setting a local storage key. */ | ||
@Env('N8N_PARTIAL_EXECUTION_ENFORCE_VERSION') | ||
enforce: boolean = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.