mirror of
https://github.com/n8n-io/n8n.git
synced 2024-09-19 22:37:31 -07:00
Compare commits
10 commits
9675c3997b
...
0adfca8f17
Author | SHA1 | Date | |
---|---|---|---|
0adfca8f17 | |||
48294e7ec1 | |||
d2e178a677 | |||
eb6a74fa24 | |||
fdef6c9f0d | |||
220e1b60ee | |||
8fb31e8459 | |||
cee57b6504 | |||
f5474ff791 | |||
b86fd80fc9 |
|
@ -33,6 +33,9 @@
|
||||||
"enabled": false
|
"enabled": false
|
||||||
},
|
},
|
||||||
"javascript": {
|
"javascript": {
|
||||||
|
"parser": {
|
||||||
|
"unsafeParameterDecoratorsEnabled": true
|
||||||
|
},
|
||||||
"formatter": {
|
"formatter": {
|
||||||
"jsxQuoteStyle": "double",
|
"jsxQuoteStyle": "double",
|
||||||
"quoteProperties": "asNeeded",
|
"quoteProperties": "asNeeded",
|
||||||
|
|
|
@ -72,7 +72,6 @@
|
||||||
"chokidar": "3.5.2",
|
"chokidar": "3.5.2",
|
||||||
"esbuild": "^0.20.2",
|
"esbuild": "^0.20.2",
|
||||||
"formidable": "3.5.1",
|
"formidable": "3.5.1",
|
||||||
"prettier": "^3.2.5",
|
|
||||||
"pug": "^3.0.3",
|
"pug": "^3.0.3",
|
||||||
"semver": "^7.5.4",
|
"semver": "^7.5.4",
|
||||||
"tslib": "^2.6.2",
|
"tslib": "^2.6.2",
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lintfix": "eslint . --fix",
|
"lintfix": "eslint . --fix",
|
||||||
"watch": "tsc -p tsconfig.build.json --watch",
|
"watch": "tsc -p tsconfig.build.json --watch",
|
||||||
"test": "echo \"No tests yet\" && exit 0"
|
"test": "jest",
|
||||||
|
"test:dev": "jest --watch"
|
||||||
},
|
},
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
|
@ -21,5 +22,10 @@
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"n8n-workflow": "workspace:*"
|
"n8n-workflow": "workspace:*"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"xss": "catalog:",
|
||||||
|
"zod": "catalog:",
|
||||||
|
"zod-class": "0.0.15"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
packages/@n8n/api-types/src/dto/index.ts
Normal file
4
packages/@n8n/api-types/src/dto/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export { PasswordUpdateRequestDTO } from './user/password-update-request.dto';
|
||||||
|
export { RoleChangeRequestDTO } from './user/role-change-request.dto';
|
||||||
|
export { SettingsUpdateRequestDTO } from './user/settings-update-request.dto';
|
||||||
|
export { UserUpdateRequestDTO } from './user/user-update-request.dto';
|
|
@ -0,0 +1,50 @@
|
||||||
|
import { PasswordUpdateRequestDTO } from '../password-update-request.dto';
|
||||||
|
|
||||||
|
describe('PasswordUpdateRequestDTO', () => {
|
||||||
|
it('should fail validation with missing currentPassword', () => {
|
||||||
|
const data = {
|
||||||
|
newPassword: 'newPassword123',
|
||||||
|
mfaCode: '123456',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = PasswordUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path[0]).toBe('currentPassword');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail validation with missing newPassword', () => {
|
||||||
|
const data = {
|
||||||
|
currentPassword: 'oldPassword123',
|
||||||
|
mfaCode: '123456',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = PasswordUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path[0]).toBe('newPassword');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass validation with missing mfaCode', () => {
|
||||||
|
const data = {
|
||||||
|
currentPassword: 'oldPassword123',
|
||||||
|
newPassword: 'newPassword123',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = PasswordUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass validation with valid data', () => {
|
||||||
|
const data = {
|
||||||
|
currentPassword: 'oldPassword123',
|
||||||
|
newPassword: 'newPassword123',
|
||||||
|
mfaCode: '123456',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = PasswordUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { RoleChangeRequestDTO } from '../role-change-request.dto';
|
||||||
|
|
||||||
|
describe('RoleChangeRequestDTO', () => {
|
||||||
|
it('should fail validation with missing newRoleName', () => {
|
||||||
|
const data = {};
|
||||||
|
|
||||||
|
const result = RoleChangeRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path[0]).toBe('newRoleName');
|
||||||
|
expect(result.error?.issues[0].message).toBe('New role is required');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail validation with invalid newRoleName', () => {
|
||||||
|
const data = {
|
||||||
|
newRoleName: 'invalidRole',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = RoleChangeRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path[0]).toBe('newRoleName');
|
||||||
|
expect(result.error?.issues[0].message).toBe(
|
||||||
|
"Invalid enum value. Expected 'global:admin' | 'global:member', received 'invalidRole'",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass validation with valid data', () => {
|
||||||
|
const data = {
|
||||||
|
newRoleName: 'global:admin',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = RoleChangeRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,68 @@
|
||||||
|
import { SettingsUpdateRequestDTO } from '../settings-update-request.dto';
|
||||||
|
|
||||||
|
describe('SettingsUpdateRequestDTO', () => {
|
||||||
|
it('should pass validation with missing userActivated', () => {
|
||||||
|
const data = {
|
||||||
|
allowSSOManualLogin: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = SettingsUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass validation with missing allowSSOManualLogin', () => {
|
||||||
|
const data = {
|
||||||
|
userActivated: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = SettingsUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass validation with missing userActivated and allowSSOManualLogin', () => {
|
||||||
|
const data = {};
|
||||||
|
|
||||||
|
const result = SettingsUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail validation with invalid userActivated', () => {
|
||||||
|
const data = {
|
||||||
|
userActivated: 'invalid',
|
||||||
|
allowSSOManualLogin: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = SettingsUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path[0]).toBe('userActivated');
|
||||||
|
expect(result.error?.issues[0].message).toBe('Expected boolean, received string');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail validation with invalid allowSSOManualLogin', () => {
|
||||||
|
const data = {
|
||||||
|
userActivated: true,
|
||||||
|
allowSSOManualLogin: 'invalid',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = SettingsUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path[0]).toBe('allowSSOManualLogin');
|
||||||
|
expect(result.error?.issues[0].message).toBe('Expected boolean, received string');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass validation with valid data', () => {
|
||||||
|
const data = {
|
||||||
|
userActivated: true,
|
||||||
|
allowSSOManualLogin: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = SettingsUpdateRequestDTO.safeParse(data);
|
||||||
|
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,86 @@
|
||||||
|
import { UserUpdateRequestDTO } from '../user-update-request.dto';
|
||||||
|
|
||||||
|
describe('UserUpdateRequestDTO', () => {
|
||||||
|
it('should fail validation for an invalid email', () => {
|
||||||
|
const invalidRequest = {
|
||||||
|
email: 'invalid-email',
|
||||||
|
firstName: 'John',
|
||||||
|
lastName: 'Doe',
|
||||||
|
mfaCode: '123456',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = UserUpdateRequestDTO.safeParse(invalidRequest);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path).toEqual(['email']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail validation for a firstName with potential XSS attack', () => {
|
||||||
|
const invalidRequest = {
|
||||||
|
email: 'test@example.com',
|
||||||
|
firstName: '<script>alert("XSS")</script>',
|
||||||
|
lastName: 'Doe',
|
||||||
|
mfaCode: '123456',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = UserUpdateRequestDTO.safeParse(invalidRequest);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path).toEqual(['firstName']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail validation for a firstName with a URL', () => {
|
||||||
|
const invalidRequest = {
|
||||||
|
email: 'test@example.com',
|
||||||
|
firstName: 'test http://malicious.com',
|
||||||
|
lastName: 'Doe',
|
||||||
|
mfaCode: '123456',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = UserUpdateRequestDTO.safeParse(invalidRequest);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path).toEqual(['firstName']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail validation for a lastName with potential XSS attack', () => {
|
||||||
|
const invalidRequest = {
|
||||||
|
email: 'test@example.com',
|
||||||
|
firstName: 'John',
|
||||||
|
lastName: '<script>alert("XSS")</script>',
|
||||||
|
mfaCode: '123456',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = UserUpdateRequestDTO.safeParse(invalidRequest);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path).toEqual(['lastName']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail validation for a lastName with a URL', () => {
|
||||||
|
const invalidRequest = {
|
||||||
|
email: 'test@example.com',
|
||||||
|
firstName: 'John',
|
||||||
|
lastName: 'testing http://malicious.com',
|
||||||
|
mfaCode: '123456',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = UserUpdateRequestDTO.safeParse(invalidRequest);
|
||||||
|
|
||||||
|
expect(result.success).toBe(false);
|
||||||
|
expect(result.error?.issues[0].path).toEqual(['lastName']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate a valid user update request', () => {
|
||||||
|
const validRequest = {
|
||||||
|
email: 'test@example.com',
|
||||||
|
firstName: 'John',
|
||||||
|
lastName: 'Doe',
|
||||||
|
mfaCode: '123456',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = UserUpdateRequestDTO.safeParse(validRequest);
|
||||||
|
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { Z } from 'zod-class';
|
||||||
|
|
||||||
|
export class PasswordUpdateRequestDTO extends Z.class({
|
||||||
|
currentPassword: z.string(),
|
||||||
|
newPassword: z.string(),
|
||||||
|
mfaCode: z.string().optional(),
|
||||||
|
}) {}
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { Z } from 'zod-class';
|
||||||
|
|
||||||
|
export class RoleChangeRequestDTO extends Z.class({
|
||||||
|
newRoleName: z.enum(['global:admin', 'global:member'], {
|
||||||
|
required_error: 'New role is required',
|
||||||
|
}),
|
||||||
|
}) {}
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { Z } from 'zod-class';
|
||||||
|
|
||||||
|
export class SettingsUpdateRequestDTO extends Z.class({
|
||||||
|
userActivated: z.boolean().optional(),
|
||||||
|
allowSSOManualLogin: z.boolean().optional(),
|
||||||
|
}) {}
|
|
@ -0,0 +1,31 @@
|
||||||
|
import xss from 'xss';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { Z } from 'zod-class';
|
||||||
|
|
||||||
|
const xssCheck = (value: string) =>
|
||||||
|
value ===
|
||||||
|
xss(value, {
|
||||||
|
whiteList: {}, // no tags are allowed
|
||||||
|
});
|
||||||
|
|
||||||
|
const URL_REGEX = /^(https?:\/\/|www\.)|(\.[\p{L}\d-]+)/iu;
|
||||||
|
const urlCheck = (value: string) => !URL_REGEX.test(value);
|
||||||
|
|
||||||
|
const nameSchema = () =>
|
||||||
|
z
|
||||||
|
.string()
|
||||||
|
.min(1)
|
||||||
|
.max(32)
|
||||||
|
.refine(xssCheck, {
|
||||||
|
message: 'Potentially malicious string',
|
||||||
|
})
|
||||||
|
.refine(urlCheck, {
|
||||||
|
message: 'Potentially malicious string',
|
||||||
|
});
|
||||||
|
|
||||||
|
export class UserUpdateRequestDTO extends Z.class({
|
||||||
|
email: z.string().email(),
|
||||||
|
firstName: nameSchema().optional(),
|
||||||
|
lastName: nameSchema().optional(),
|
||||||
|
mfaCode: z.string().optional(),
|
||||||
|
}) {}
|
|
@ -1,4 +1,5 @@
|
||||||
export type * from './datetime';
|
export type * from './datetime';
|
||||||
|
export * from './dto';
|
||||||
export type * from './push';
|
export type * from './push';
|
||||||
export type * from './scaling';
|
export type * from './scaling';
|
||||||
export type * from './frontend-settings';
|
export type * from './frontend-settings';
|
||||||
|
|
|
@ -3,8 +3,9 @@ import { check } from 'k6';
|
||||||
|
|
||||||
const apiBaseUrl = __ENV.API_BASE_URL;
|
const apiBaseUrl = __ENV.API_BASE_URL;
|
||||||
|
|
||||||
const file = open(__ENV.SCRIPT_FILE_PATH, 'b');
|
// This creates a 2MB file (16 * 128 * 1024 = 2 * 1024 * 1024 = 2MB)
|
||||||
const filename = String(__ENV.SCRIPT_FILE_PATH).split('/').pop();
|
const file = Array.from({ length: 128 * 1024 }, () => Math.random().toString().slice(2)).join('');
|
||||||
|
const filename = 'test.bin';
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const data = {
|
const data = {
|
||||||
|
|
|
@ -77,7 +77,6 @@ export function handleSummary(data) {
|
||||||
env: {
|
env: {
|
||||||
API_BASE_URL: this.opts.n8nApiBaseUrl,
|
API_BASE_URL: this.opts.n8nApiBaseUrl,
|
||||||
K6_CLOUD_TOKEN: this.opts.k6ApiToken,
|
K6_CLOUD_TOKEN: this.opts.k6ApiToken,
|
||||||
SCRIPT_FILE_PATH: augmentedTestScriptPath,
|
|
||||||
},
|
},
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
})`${k6ExecutablePath} run ${flattedFlags} ${augmentedTestScriptPath}`;
|
})`${k6ExecutablePath} run ${flattedFlags} ${augmentedTestScriptPath}`;
|
||||||
|
|
|
@ -25,7 +25,6 @@ module.exports = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: ['**/*.vue'],
|
files: ['**/*.vue'],
|
||||||
plugins: isCI ? [] : ['eslint-plugin-prettier'],
|
|
||||||
rules: {
|
rules: {
|
||||||
'vue/no-deprecated-slot-attribute': 'error',
|
'vue/no-deprecated-slot-attribute': 'error',
|
||||||
'vue/no-deprecated-slot-scope-attribute': 'error',
|
'vue/no-deprecated-slot-scope-attribute': 'error',
|
||||||
|
@ -68,14 +67,6 @@ module.exports = {
|
||||||
],
|
],
|
||||||
'vue/no-v-html': 'error',
|
'vue/no-v-html': 'error',
|
||||||
|
|
||||||
...(isCI
|
|
||||||
? {}
|
|
||||||
: {
|
|
||||||
'prettier/prettier': ['error', { endOfLine: 'auto' }],
|
|
||||||
'arrow-body-style': 'off',
|
|
||||||
'prefer-arrow-callback': 'off',
|
|
||||||
}),
|
|
||||||
|
|
||||||
// TODO: remove these
|
// TODO: remove these
|
||||||
'vue/no-mutating-props': 'warn',
|
'vue/no-mutating-props': 'warn',
|
||||||
'vue/no-side-effects-in-computed-properties': 'warn',
|
'vue/no-side-effects-in-computed-properties': 'warn',
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"@types/eslint": "^8.56.5",
|
"@types/eslint": "^8.56.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
||||||
"@typescript-eslint/parser": "^7.2.0",
|
"@typescript-eslint/parser": "^7.2.0",
|
||||||
"@vue/eslint-config-prettier": "^9.0.0",
|
|
||||||
"@vue/eslint-config-typescript": "^13.0.0",
|
"@vue/eslint-config-typescript": "^13.0.0",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-airbnb-typescript": "^18.0.0",
|
"eslint-config-airbnb-typescript": "^18.0.0",
|
||||||
|
@ -15,7 +14,6 @@
|
||||||
"eslint-plugin-import": "^2.29.1",
|
"eslint-plugin-import": "^2.29.1",
|
||||||
"eslint-plugin-lodash": "^7.4.0",
|
"eslint-plugin-lodash": "^7.4.0",
|
||||||
"eslint-plugin-n8n-local-rules": "^1.0.0",
|
"eslint-plugin-n8n-local-rules": "^1.0.0",
|
||||||
"eslint-plugin-prettier": "^5.1.3",
|
|
||||||
"eslint-plugin-unicorn": "^51.0.1",
|
"eslint-plugin-unicorn": "^51.0.1",
|
||||||
"eslint-plugin-unused-imports": "^3.1.0",
|
"eslint-plugin-unused-imports": "^3.1.0",
|
||||||
"eslint-plugin-vue": "^9.23.0",
|
"eslint-plugin-vue": "^9.23.0",
|
||||||
|
|
|
@ -174,7 +174,7 @@
|
||||||
"ws": "8.17.1",
|
"ws": "8.17.1",
|
||||||
"xml2js": "catalog:",
|
"xml2js": "catalog:",
|
||||||
"xmllint-wasm": "3.0.1",
|
"xmllint-wasm": "3.0.1",
|
||||||
"xss": "^1.0.14",
|
"xss": "catalog:",
|
||||||
"yamljs": "0.3.0",
|
"yamljs": "0.3.0",
|
||||||
"zod": "catalog:"
|
"zod": "catalog:"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { UserUpdateRequestDTO } from '@n8n/api-types';
|
||||||
import type { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
import { mock, anyObject } from 'jest-mock-extended';
|
import { mock, anyObject } from 'jest-mock-extended';
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
|
@ -35,20 +36,6 @@ describe('MeController', () => {
|
||||||
const controller = Container.get(MeController);
|
const controller = Container.get(MeController);
|
||||||
|
|
||||||
describe('updateCurrentUser', () => {
|
describe('updateCurrentUser', () => {
|
||||||
it('should throw BadRequestError if email is missing in the payload', async () => {
|
|
||||||
const req = mock<MeRequest.UserUpdate>({});
|
|
||||||
await expect(controller.updateCurrentUser(req, mock())).rejects.toThrowError(
|
|
||||||
new BadRequestError('Email is mandatory'),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw BadRequestError if email is invalid', async () => {
|
|
||||||
const req = mock<MeRequest.UserUpdate>({ body: { email: 'invalid-email' } });
|
|
||||||
await expect(controller.updateCurrentUser(req, mock())).rejects.toThrowError(
|
|
||||||
new BadRequestError('Invalid email address'),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should update the user in the DB, and issue a new cookie', async () => {
|
it('should update the user in the DB, and issue a new cookie', async () => {
|
||||||
const user = mock<User>({
|
const user = mock<User>({
|
||||||
id: '123',
|
id: '123',
|
||||||
|
@ -58,24 +45,24 @@ describe('MeController', () => {
|
||||||
role: 'global:owner',
|
role: 'global:owner',
|
||||||
mfaEnabled: false,
|
mfaEnabled: false,
|
||||||
});
|
});
|
||||||
const req = mock<MeRequest.UserUpdate>({ user, browserId });
|
const payload = new UserUpdateRequestDTO({
|
||||||
req.body = {
|
|
||||||
email: 'valid@email.com',
|
email: 'valid@email.com',
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Potato',
|
lastName: 'Potato',
|
||||||
};
|
});
|
||||||
|
const req = mock<AuthenticatedRequest>({ user, browserId });
|
||||||
const res = mock<Response>();
|
const res = mock<Response>();
|
||||||
userRepository.findOneByOrFail.mockResolvedValue(user);
|
userRepository.findOneByOrFail.mockResolvedValue(user);
|
||||||
userRepository.findOneOrFail.mockResolvedValue(user);
|
userRepository.findOneOrFail.mockResolvedValue(user);
|
||||||
jest.spyOn(jwt, 'sign').mockImplementation(() => 'signed-token');
|
jest.spyOn(jwt, 'sign').mockImplementation(() => 'signed-token');
|
||||||
userService.toPublic.mockResolvedValue({} as unknown as PublicUser);
|
userService.toPublic.mockResolvedValue({} as unknown as PublicUser);
|
||||||
|
|
||||||
await controller.updateCurrentUser(req, res);
|
await controller.updateCurrentUser(req, res, payload);
|
||||||
|
|
||||||
expect(externalHooks.run).toHaveBeenCalledWith('user.profile.beforeUpdate', [
|
expect(externalHooks.run).toHaveBeenCalledWith('user.profile.beforeUpdate', [
|
||||||
user.id,
|
user.id,
|
||||||
user.email,
|
user.email,
|
||||||
req.body,
|
payload,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(userService.update).toHaveBeenCalled();
|
expect(userService.update).toHaveBeenCalled();
|
||||||
|
@ -100,35 +87,6 @@ describe('MeController', () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not allow updating any other fields on a user besides email and name', async () => {
|
|
||||||
const user = mock<User>({
|
|
||||||
id: '123',
|
|
||||||
password: 'password',
|
|
||||||
authIdentities: [],
|
|
||||||
role: 'global:member',
|
|
||||||
mfaEnabled: false,
|
|
||||||
});
|
|
||||||
const req = mock<MeRequest.UserUpdate>({ user, browserId });
|
|
||||||
req.body = { email: 'valid@email.com', firstName: 'John', lastName: 'Potato' };
|
|
||||||
const res = mock<Response>();
|
|
||||||
userRepository.findOneOrFail.mockResolvedValue(user);
|
|
||||||
jest.spyOn(jwt, 'sign').mockImplementation(() => 'signed-token');
|
|
||||||
|
|
||||||
// Add invalid data to the request payload
|
|
||||||
Object.assign(req.body, { id: '0', role: 'global:owner' });
|
|
||||||
|
|
||||||
await controller.updateCurrentUser(req, res);
|
|
||||||
|
|
||||||
expect(userService.update).toHaveBeenCalled();
|
|
||||||
|
|
||||||
const updatePayload = userService.update.mock.calls[0][1];
|
|
||||||
expect(updatePayload.email).toBe(req.body.email);
|
|
||||||
expect(updatePayload.firstName).toBe(req.body.firstName);
|
|
||||||
expect(updatePayload.lastName).toBe(req.body.lastName);
|
|
||||||
expect(updatePayload.id).toBeUndefined();
|
|
||||||
expect(updatePayload.role).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw BadRequestError if beforeUpdate hook throws BadRequestError', async () => {
|
it('should throw BadRequestError if beforeUpdate hook throws BadRequestError', async () => {
|
||||||
const user = mock<User>({
|
const user = mock<User>({
|
||||||
id: '123',
|
id: '123',
|
||||||
|
@ -137,9 +95,7 @@ describe('MeController', () => {
|
||||||
role: 'global:owner',
|
role: 'global:owner',
|
||||||
mfaEnabled: false,
|
mfaEnabled: false,
|
||||||
});
|
});
|
||||||
const reqBody = { email: 'valid@email.com', firstName: 'John', lastName: 'Potato' };
|
const req = mock<AuthenticatedRequest>({ user });
|
||||||
const req = mock<MeRequest.UserUpdate>({ user, body: reqBody });
|
|
||||||
req.body = reqBody; // We don't want the body to be a mock object
|
|
||||||
|
|
||||||
externalHooks.run.mockImplementationOnce(async (hookName) => {
|
externalHooks.run.mockImplementationOnce(async (hookName) => {
|
||||||
if (hookName === 'user.profile.beforeUpdate') {
|
if (hookName === 'user.profile.beforeUpdate') {
|
||||||
|
@ -147,9 +103,13 @@ describe('MeController', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await expect(controller.updateCurrentUser(req, mock())).rejects.toThrowError(
|
await expect(
|
||||||
new BadRequestError('Invalid email address'),
|
controller.updateCurrentUser(
|
||||||
);
|
req,
|
||||||
|
mock(),
|
||||||
|
mock({ email: 'valid@email.com', firstName: 'John', lastName: 'Potato' }),
|
||||||
|
),
|
||||||
|
).rejects.toThrowError(new BadRequestError('Invalid email address'));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when mfa is enabled', () => {
|
describe('when mfa is enabled', () => {
|
||||||
|
@ -162,12 +122,19 @@ describe('MeController', () => {
|
||||||
role: 'global:owner',
|
role: 'global:owner',
|
||||||
mfaEnabled: true,
|
mfaEnabled: true,
|
||||||
});
|
});
|
||||||
const req = mock<MeRequest.UserUpdate>({ user, browserId });
|
const req = mock<AuthenticatedRequest>({ user, browserId });
|
||||||
req.body = { email: 'new@email.com', firstName: 'John', lastName: 'Potato' };
|
|
||||||
|
|
||||||
await expect(controller.updateCurrentUser(req, mock())).rejects.toThrowError(
|
await expect(
|
||||||
new BadRequestError('Two-factor code is required to change email'),
|
controller.updateCurrentUser(
|
||||||
);
|
req,
|
||||||
|
mock(),
|
||||||
|
new UserUpdateRequestDTO({
|
||||||
|
email: 'new@email.com',
|
||||||
|
firstName: 'John',
|
||||||
|
lastName: 'Potato',
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).rejects.toThrowError(new BadRequestError('Two-factor code is required to change email'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw InvalidMfaCodeError if mfa code is invalid', async () => {
|
it('should throw InvalidMfaCodeError if mfa code is invalid', async () => {
|
||||||
|
@ -179,18 +146,21 @@ describe('MeController', () => {
|
||||||
role: 'global:owner',
|
role: 'global:owner',
|
||||||
mfaEnabled: true,
|
mfaEnabled: true,
|
||||||
});
|
});
|
||||||
const req = mock<MeRequest.UserUpdate>({ user, browserId });
|
const req = mock<AuthenticatedRequest>({ user, browserId });
|
||||||
req.body = {
|
mockMfaService.validateMfa.mockResolvedValue(false);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
controller.updateCurrentUser(
|
||||||
|
req,
|
||||||
|
mock(),
|
||||||
|
mock({
|
||||||
email: 'new@email.com',
|
email: 'new@email.com',
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Potato',
|
lastName: 'Potato',
|
||||||
mfaCode: 'invalid',
|
mfaCode: 'invalid',
|
||||||
};
|
}),
|
||||||
mockMfaService.validateMfa.mockResolvedValue(false);
|
),
|
||||||
|
).rejects.toThrow(InvalidMfaCodeError);
|
||||||
await expect(controller.updateCurrentUser(req, mock())).rejects.toThrow(
|
|
||||||
InvalidMfaCodeError,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should update the user's email if mfa code is valid", async () => {
|
it("should update the user's email if mfa code is valid", async () => {
|
||||||
|
@ -202,13 +172,7 @@ describe('MeController', () => {
|
||||||
role: 'global:owner',
|
role: 'global:owner',
|
||||||
mfaEnabled: true,
|
mfaEnabled: true,
|
||||||
});
|
});
|
||||||
const req = mock<MeRequest.UserUpdate>({ user, browserId });
|
const req = mock<AuthenticatedRequest>({ user, browserId });
|
||||||
req.body = {
|
|
||||||
email: 'new@email.com',
|
|
||||||
firstName: 'John',
|
|
||||||
lastName: 'Potato',
|
|
||||||
mfaCode: '123456',
|
|
||||||
};
|
|
||||||
const res = mock<Response>();
|
const res = mock<Response>();
|
||||||
userRepository.findOneByOrFail.mockResolvedValue(user);
|
userRepository.findOneByOrFail.mockResolvedValue(user);
|
||||||
userRepository.findOneOrFail.mockResolvedValue(user);
|
userRepository.findOneOrFail.mockResolvedValue(user);
|
||||||
|
@ -216,7 +180,16 @@ describe('MeController', () => {
|
||||||
userService.toPublic.mockResolvedValue({} as unknown as PublicUser);
|
userService.toPublic.mockResolvedValue({} as unknown as PublicUser);
|
||||||
mockMfaService.validateMfa.mockResolvedValue(true);
|
mockMfaService.validateMfa.mockResolvedValue(true);
|
||||||
|
|
||||||
const result = await controller.updateCurrentUser(req, res);
|
const result = await controller.updateCurrentUser(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
mock({
|
||||||
|
email: 'new@email.com',
|
||||||
|
firstName: 'John',
|
||||||
|
lastName: 'Potato',
|
||||||
|
mfaCode: '123456',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
expect(result).toEqual({});
|
expect(result).toEqual({});
|
||||||
});
|
});
|
||||||
|
@ -227,51 +200,59 @@ describe('MeController', () => {
|
||||||
const passwordHash = '$2a$10$ffitcKrHT.Ls.m9FfWrMrOod76aaI0ogKbc3S96Q320impWpCbgj6'; // Hashed 'old_password'
|
const passwordHash = '$2a$10$ffitcKrHT.Ls.m9FfWrMrOod76aaI0ogKbc3S96Q320impWpCbgj6'; // Hashed 'old_password'
|
||||||
|
|
||||||
it('should throw if the user does not have a password set', async () => {
|
it('should throw if the user does not have a password set', async () => {
|
||||||
const req = mock<MeRequest.Password>({
|
const req = mock<AuthenticatedRequest>({
|
||||||
user: mock({ password: undefined }),
|
user: mock({ password: undefined }),
|
||||||
body: { currentPassword: '', newPassword: '' },
|
|
||||||
});
|
});
|
||||||
await expect(controller.updatePassword(req, mock())).rejects.toThrowError(
|
await expect(
|
||||||
new BadRequestError('Requesting user not set up.'),
|
controller.updatePassword(req, mock(), mock({ currentPassword: '', newPassword: '' })),
|
||||||
);
|
).rejects.toThrowError(new BadRequestError('Requesting user not set up.'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw if currentPassword does not match the user's password", async () => {
|
it("should throw if currentPassword does not match the user's password", async () => {
|
||||||
const req = mock<MeRequest.Password>({
|
const req = mock<AuthenticatedRequest>({
|
||||||
user: mock({ password: passwordHash }),
|
user: mock({ password: passwordHash }),
|
||||||
body: { currentPassword: 'not_old_password', newPassword: '' },
|
|
||||||
});
|
});
|
||||||
await expect(controller.updatePassword(req, mock())).rejects.toThrowError(
|
await expect(
|
||||||
new BadRequestError('Provided current password is incorrect.'),
|
controller.updatePassword(
|
||||||
);
|
req,
|
||||||
|
mock(),
|
||||||
|
mock({ currentPassword: 'not_old_password', newPassword: '' }),
|
||||||
|
),
|
||||||
|
).rejects.toThrowError(new BadRequestError('Provided current password is incorrect.'));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('should throw if newPassword is not valid', () => {
|
describe('should throw if newPassword is not valid', () => {
|
||||||
Object.entries(badPasswords).forEach(([newPassword, errorMessage]) => {
|
Object.entries(badPasswords).forEach(([newPassword, errorMessage]) => {
|
||||||
it(newPassword, async () => {
|
it(newPassword, async () => {
|
||||||
const req = mock<MeRequest.Password>({
|
const req = mock<AuthenticatedRequest>({
|
||||||
user: mock({ password: passwordHash }),
|
user: mock({ password: passwordHash }),
|
||||||
body: { currentPassword: 'old_password', newPassword },
|
|
||||||
browserId,
|
browserId,
|
||||||
});
|
});
|
||||||
await expect(controller.updatePassword(req, mock())).rejects.toThrowError(
|
await expect(
|
||||||
new BadRequestError(errorMessage),
|
controller.updatePassword(
|
||||||
);
|
req,
|
||||||
|
mock(),
|
||||||
|
mock({ currentPassword: 'old_password', newPassword }),
|
||||||
|
),
|
||||||
|
).rejects.toThrowError(new BadRequestError(errorMessage));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the password in the DB, and issue a new cookie', async () => {
|
it('should update the password in the DB, and issue a new cookie', async () => {
|
||||||
const req = mock<MeRequest.Password>({
|
const req = mock<AuthenticatedRequest>({
|
||||||
user: mock({ password: passwordHash, mfaEnabled: false }),
|
user: mock({ password: passwordHash, mfaEnabled: false }),
|
||||||
body: { currentPassword: 'old_password', newPassword: 'NewPassword123' },
|
|
||||||
browserId,
|
browserId,
|
||||||
});
|
});
|
||||||
const res = mock<Response>();
|
const res = mock<Response>();
|
||||||
userRepository.save.calledWith(req.user).mockResolvedValue(req.user);
|
userRepository.save.calledWith(req.user).mockResolvedValue(req.user);
|
||||||
jest.spyOn(jwt, 'sign').mockImplementation(() => 'new-signed-token');
|
jest.spyOn(jwt, 'sign').mockImplementation(() => 'new-signed-token');
|
||||||
|
|
||||||
await controller.updatePassword(req, res);
|
await controller.updatePassword(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
mock({ currentPassword: 'old_password', newPassword: 'NewPassword123' }),
|
||||||
|
);
|
||||||
|
|
||||||
expect(req.user.password).not.toBe(passwordHash);
|
expect(req.user.password).not.toBe(passwordHash);
|
||||||
|
|
||||||
|
@ -299,34 +280,43 @@ describe('MeController', () => {
|
||||||
|
|
||||||
describe('mfa enabled', () => {
|
describe('mfa enabled', () => {
|
||||||
it('should throw BadRequestError if mfa code is missing', async () => {
|
it('should throw BadRequestError if mfa code is missing', async () => {
|
||||||
const req = mock<MeRequest.Password>({
|
const req = mock<AuthenticatedRequest>({
|
||||||
user: mock({ password: passwordHash, mfaEnabled: true }),
|
user: mock({ password: passwordHash, mfaEnabled: true }),
|
||||||
body: { currentPassword: 'old_password', newPassword: 'NewPassword123' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await expect(controller.updatePassword(req, mock())).rejects.toThrowError(
|
await expect(
|
||||||
|
controller.updatePassword(
|
||||||
|
req,
|
||||||
|
mock(),
|
||||||
|
mock({ currentPassword: 'old_password', newPassword: 'NewPassword123' }),
|
||||||
|
),
|
||||||
|
).rejects.toThrowError(
|
||||||
new BadRequestError('Two-factor code is required to change password.'),
|
new BadRequestError('Two-factor code is required to change password.'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw InvalidMfaCodeError if invalid mfa code is given', async () => {
|
it('should throw InvalidMfaCodeError if invalid mfa code is given', async () => {
|
||||||
const req = mock<MeRequest.Password>({
|
const req = mock<AuthenticatedRequest>({
|
||||||
user: mock({ password: passwordHash, mfaEnabled: true }),
|
user: mock({ password: passwordHash, mfaEnabled: true }),
|
||||||
body: { currentPassword: 'old_password', newPassword: 'NewPassword123', mfaCode: '123' },
|
|
||||||
});
|
});
|
||||||
mockMfaService.validateMfa.mockResolvedValue(false);
|
mockMfaService.validateMfa.mockResolvedValue(false);
|
||||||
|
|
||||||
await expect(controller.updatePassword(req, mock())).rejects.toThrow(InvalidMfaCodeError);
|
await expect(
|
||||||
|
controller.updatePassword(
|
||||||
|
req,
|
||||||
|
mock(),
|
||||||
|
mock({
|
||||||
|
currentPassword: 'old_password',
|
||||||
|
newPassword: 'NewPassword123',
|
||||||
|
mfaCode: '123',
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).rejects.toThrow(InvalidMfaCodeError);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should succeed when mfa code is correct', async () => {
|
it('should succeed when mfa code is correct', async () => {
|
||||||
const req = mock<MeRequest.Password>({
|
const req = mock<AuthenticatedRequest>({
|
||||||
user: mock({ password: passwordHash, mfaEnabled: true }),
|
user: mock({ password: passwordHash, mfaEnabled: true }),
|
||||||
body: {
|
|
||||||
currentPassword: 'old_password',
|
|
||||||
newPassword: 'NewPassword123',
|
|
||||||
mfaCode: 'valid',
|
|
||||||
},
|
|
||||||
browserId,
|
browserId,
|
||||||
});
|
});
|
||||||
const res = mock<Response>();
|
const res = mock<Response>();
|
||||||
|
@ -334,7 +324,15 @@ describe('MeController', () => {
|
||||||
jest.spyOn(jwt, 'sign').mockImplementation(() => 'new-signed-token');
|
jest.spyOn(jwt, 'sign').mockImplementation(() => 'new-signed-token');
|
||||||
mockMfaService.validateMfa.mockResolvedValue(true);
|
mockMfaService.validateMfa.mockResolvedValue(true);
|
||||||
|
|
||||||
const result = await controller.updatePassword(req, res);
|
const result = await controller.updatePassword(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
mock({
|
||||||
|
currentPassword: 'old_password',
|
||||||
|
newPassword: 'NewPassword123',
|
||||||
|
mfaCode: 'valid',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
expect(result).toEqual({ success: true });
|
expect(result).toEqual({ success: true });
|
||||||
expect(req.user.password).not.toBe(passwordHash);
|
expect(req.user.password).not.toBe(passwordHash);
|
||||||
|
@ -411,18 +409,6 @@ describe('MeController', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('updateCurrentUserSettings', () => {
|
|
||||||
it('should throw BadRequestError on XSS attempt', async () => {
|
|
||||||
const req = mock<AuthenticatedRequest>({
|
|
||||||
body: {
|
|
||||||
userActivated: '<script>alert("XSS")</script>',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(controller.updateCurrentUserSettings(req)).rejects.toThrowError(BadRequestError);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('API Key methods', () => {
|
describe('API Key methods', () => {
|
||||||
let req: AuthenticatedRequest;
|
let req: AuthenticatedRequest;
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { mock } from 'jest-mock-extended';
|
||||||
import type { User } from '@/databases/entities/user';
|
import type { User } from '@/databases/entities/user';
|
||||||
import type { UserRepository } from '@/databases/repositories/user.repository';
|
import type { UserRepository } from '@/databases/repositories/user.repository';
|
||||||
import type { EventService } from '@/events/event.service';
|
import type { EventService } from '@/events/event.service';
|
||||||
import type { UserRequest } from '@/requests';
|
import type { AuthenticatedRequest } from '@/requests';
|
||||||
import type { ProjectService } from '@/services/project.service';
|
import type { ProjectService } from '@/services/project.service';
|
||||||
|
|
||||||
import { UsersController } from '../users.controller';
|
import { UsersController } from '../users.controller';
|
||||||
|
@ -33,15 +33,18 @@ describe('UsersController', () => {
|
||||||
|
|
||||||
describe('changeGlobalRole', () => {
|
describe('changeGlobalRole', () => {
|
||||||
it('should emit event user-changed-role', async () => {
|
it('should emit event user-changed-role', async () => {
|
||||||
const request = mock<UserRequest.ChangeRole>({
|
const request = mock<AuthenticatedRequest>({
|
||||||
user: { id: '123' },
|
user: { id: '123' },
|
||||||
params: { id: '456' },
|
|
||||||
body: { newRoleName: 'global:member' },
|
|
||||||
});
|
});
|
||||||
userRepository.findOne.mockResolvedValue(mock<User>({ id: '456' }));
|
userRepository.findOneBy.mockResolvedValue(mock<User>({ id: '456' }));
|
||||||
projectService.getUserOwnedOrAdminProjects.mockResolvedValue([]);
|
projectService.getUserOwnedOrAdminProjects.mockResolvedValue([]);
|
||||||
|
|
||||||
await controller.changeGlobalRole(request);
|
await controller.changeGlobalRole(
|
||||||
|
request,
|
||||||
|
mock(),
|
||||||
|
mock({ newRoleName: 'global:member' }),
|
||||||
|
'456',
|
||||||
|
);
|
||||||
|
|
||||||
expect(eventService.emit).toHaveBeenCalledWith('user-changed-role', {
|
expect(eventService.emit).toHaveBeenCalledWith('user-changed-role', {
|
||||||
userId: '123',
|
userId: '123',
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
|
import {
|
||||||
|
PasswordUpdateRequestDTO,
|
||||||
|
SettingsUpdateRequestDTO,
|
||||||
|
UserUpdateRequestDTO,
|
||||||
|
} from '@n8n/api-types';
|
||||||
import { plainToInstance } from 'class-transformer';
|
import { plainToInstance } from 'class-transformer';
|
||||||
import { randomBytes } from 'crypto';
|
import { randomBytes } from 'crypto';
|
||||||
import { type RequestHandler, Response } from 'express';
|
import { type RequestHandler, Response } from 'express';
|
||||||
import validator from 'validator';
|
|
||||||
|
|
||||||
import { AuthService } from '@/auth/auth.service';
|
import { AuthService } from '@/auth/auth.service';
|
||||||
import type { User } from '@/databases/entities/user';
|
import type { User } from '@/databases/entities/user';
|
||||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||||
import { Delete, Get, Patch, Post, RestController } from '@/decorators';
|
import { Body, Delete, Get, Patch, Post, RestController } from '@/decorators';
|
||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.error';
|
import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.error';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
|
@ -16,12 +20,7 @@ import type { PublicUser } from '@/interfaces';
|
||||||
import { Logger } from '@/logger';
|
import { Logger } from '@/logger';
|
||||||
import { MfaService } from '@/mfa/mfa.service';
|
import { MfaService } from '@/mfa/mfa.service';
|
||||||
import { isApiEnabled } from '@/public-api';
|
import { isApiEnabled } from '@/public-api';
|
||||||
import {
|
import { AuthenticatedRequest, MeRequest } from '@/requests';
|
||||||
AuthenticatedRequest,
|
|
||||||
MeRequest,
|
|
||||||
UserSettingsUpdatePayload,
|
|
||||||
UserUpdatePayload,
|
|
||||||
} from '@/requests';
|
|
||||||
import { PasswordUtility } from '@/services/password.utility';
|
import { PasswordUtility } from '@/services/password.utility';
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers';
|
import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers';
|
||||||
|
@ -55,30 +54,14 @@ export class MeController {
|
||||||
* Update the logged-in user's properties, except password.
|
* Update the logged-in user's properties, except password.
|
||||||
*/
|
*/
|
||||||
@Patch('/')
|
@Patch('/')
|
||||||
async updateCurrentUser(req: MeRequest.UserUpdate, res: Response): Promise<PublicUser> {
|
async updateCurrentUser(
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response,
|
||||||
|
@Body payload: UserUpdateRequestDTO,
|
||||||
|
): Promise<PublicUser> {
|
||||||
const { id: userId, email: currentEmail, mfaEnabled } = req.user;
|
const { id: userId, email: currentEmail, mfaEnabled } = req.user;
|
||||||
|
|
||||||
const payload = plainToInstance(UserUpdatePayload, req.body, { excludeExtraneousValues: true });
|
|
||||||
|
|
||||||
const { email } = payload;
|
const { email } = payload;
|
||||||
if (!email) {
|
|
||||||
this.logger.debug('Request to update user email failed because of missing email in payload', {
|
|
||||||
userId,
|
|
||||||
payload,
|
|
||||||
});
|
|
||||||
throw new BadRequestError('Email is mandatory');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!validator.isEmail(email)) {
|
|
||||||
this.logger.debug('Request to update user email failed because of invalid email in payload', {
|
|
||||||
userId,
|
|
||||||
invalidEmail: email,
|
|
||||||
});
|
|
||||||
throw new BadRequestError('Invalid email address');
|
|
||||||
}
|
|
||||||
|
|
||||||
await validateEntity(payload);
|
|
||||||
|
|
||||||
const isEmailBeingChanged = email !== currentEmail;
|
const isEmailBeingChanged = email !== currentEmail;
|
||||||
|
|
||||||
// If SAML is enabled, we don't allow the user to change their email address
|
// If SAML is enabled, we don't allow the user to change their email address
|
||||||
|
@ -134,9 +117,13 @@ export class MeController {
|
||||||
* Update the logged-in user's password.
|
* Update the logged-in user's password.
|
||||||
*/
|
*/
|
||||||
@Patch('/password', { rateLimit: true })
|
@Patch('/password', { rateLimit: true })
|
||||||
async updatePassword(req: MeRequest.Password, res: Response) {
|
async updatePassword(
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
res: Response,
|
||||||
|
@Body payload: PasswordUpdateRequestDTO,
|
||||||
|
) {
|
||||||
const { user } = req;
|
const { user } = req;
|
||||||
const { currentPassword, newPassword, mfaCode } = req.body;
|
const { currentPassword, newPassword, mfaCode } = payload;
|
||||||
|
|
||||||
// If SAML is enabled, we don't allow the user to change their password
|
// If SAML is enabled, we don't allow the user to change their password
|
||||||
if (isSamlLicensedAndEnabled()) {
|
if (isSamlLicensedAndEnabled()) {
|
||||||
|
@ -270,13 +257,11 @@ export class MeController {
|
||||||
* Update the logged-in user's settings.
|
* Update the logged-in user's settings.
|
||||||
*/
|
*/
|
||||||
@Patch('/settings')
|
@Patch('/settings')
|
||||||
async updateCurrentUserSettings(req: MeRequest.UserSettingsUpdate): Promise<User['settings']> {
|
async updateCurrentUserSettings(
|
||||||
const payload = plainToInstance(UserSettingsUpdatePayload, req.body, {
|
req: AuthenticatedRequest,
|
||||||
excludeExtraneousValues: true,
|
_: Response,
|
||||||
});
|
@Body payload: SettingsUpdateRequestDTO,
|
||||||
|
): Promise<User['settings']> {
|
||||||
await validateEntity(payload);
|
|
||||||
|
|
||||||
const { id } = req.user;
|
const { id } = req.user;
|
||||||
|
|
||||||
await this.userService.updateSettings(id, payload);
|
await this.userService.updateSettings(id, payload);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { plainToInstance } from 'class-transformer';
|
import { RoleChangeRequestDTO, SettingsUpdateRequestDTO } from '@n8n/api-types';
|
||||||
|
import { Response } from 'express';
|
||||||
|
|
||||||
import { AuthService } from '@/auth/auth.service';
|
import { AuthService } from '@/auth/auth.service';
|
||||||
import { CredentialsService } from '@/credentials/credentials.service';
|
import { CredentialsService } from '@/credentials/credentials.service';
|
||||||
|
@ -9,22 +10,17 @@ import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||||
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
|
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
|
||||||
import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository';
|
import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository';
|
||||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||||
import { GlobalScope, Delete, Get, RestController, Patch, Licensed } from '@/decorators';
|
import { GlobalScope, Delete, Get, RestController, Patch, Licensed, Body } from '@/decorators';
|
||||||
|
import { Param } from '@/decorators/args';
|
||||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
||||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import { ExternalHooks } from '@/external-hooks';
|
import { ExternalHooks } from '@/external-hooks';
|
||||||
import { validateEntity } from '@/generic-helpers';
|
|
||||||
import type { PublicUser } from '@/interfaces';
|
import type { PublicUser } from '@/interfaces';
|
||||||
import { Logger } from '@/logger';
|
import { Logger } from '@/logger';
|
||||||
import { listQueryMiddleware } from '@/middlewares';
|
import { listQueryMiddleware } from '@/middlewares';
|
||||||
import {
|
import { AuthenticatedRequest, ListQuery, UserRequest } from '@/requests';
|
||||||
ListQuery,
|
|
||||||
UserRequest,
|
|
||||||
UserRoleChangePayload,
|
|
||||||
UserSettingsUpdatePayload,
|
|
||||||
} from '@/requests';
|
|
||||||
import { ProjectService } from '@/services/project.service';
|
import { ProjectService } from '@/services/project.service';
|
||||||
import { UserService } from '@/services/user.service';
|
import { UserService } from '@/services/user.service';
|
||||||
import { WorkflowService } from '@/workflows/workflow.service';
|
import { WorkflowService } from '@/workflows/workflow.service';
|
||||||
|
@ -124,13 +120,12 @@ export class UsersController {
|
||||||
|
|
||||||
@Patch('/:id/settings')
|
@Patch('/:id/settings')
|
||||||
@GlobalScope('user:update')
|
@GlobalScope('user:update')
|
||||||
async updateUserSettings(req: UserRequest.UserSettingsUpdate) {
|
async updateUserSettings(
|
||||||
const payload = plainToInstance(UserSettingsUpdatePayload, req.body, {
|
_req: AuthenticatedRequest,
|
||||||
excludeExtraneousValues: true,
|
_res: Response,
|
||||||
});
|
@Body payload: SettingsUpdateRequestDTO,
|
||||||
|
@Param('id') id: string,
|
||||||
const id = req.params.id;
|
) {
|
||||||
|
|
||||||
await this.userService.updateSettings(id, payload);
|
await this.userService.updateSettings(id, payload);
|
||||||
|
|
||||||
const user = await this.userRepository.findOneOrFail({
|
const user = await this.userRepository.findOneOrFail({
|
||||||
|
@ -263,18 +258,16 @@ export class UsersController {
|
||||||
@Patch('/:id/role')
|
@Patch('/:id/role')
|
||||||
@GlobalScope('user:changeRole')
|
@GlobalScope('user:changeRole')
|
||||||
@Licensed('feat:advancedPermissions')
|
@Licensed('feat:advancedPermissions')
|
||||||
async changeGlobalRole(req: UserRequest.ChangeRole) {
|
async changeGlobalRole(
|
||||||
|
req: AuthenticatedRequest,
|
||||||
|
_: Response,
|
||||||
|
@Body payload: RoleChangeRequestDTO,
|
||||||
|
@Param('id') id: string,
|
||||||
|
) {
|
||||||
const { NO_ADMIN_ON_OWNER, NO_USER, NO_OWNER_ON_OWNER } =
|
const { NO_ADMIN_ON_OWNER, NO_USER, NO_OWNER_ON_OWNER } =
|
||||||
UsersController.ERROR_MESSAGES.CHANGE_ROLE;
|
UsersController.ERROR_MESSAGES.CHANGE_ROLE;
|
||||||
|
|
||||||
const payload = plainToInstance(UserRoleChangePayload, req.body, {
|
const targetUser = await this.userRepository.findOneBy({ id });
|
||||||
excludeExtraneousValues: true,
|
|
||||||
});
|
|
||||||
await validateEntity(payload);
|
|
||||||
|
|
||||||
const targetUser = await this.userRepository.findOne({
|
|
||||||
where: { id: req.params.id },
|
|
||||||
});
|
|
||||||
if (targetUser === null) {
|
if (targetUser === null) {
|
||||||
throw new NotFoundError(NO_USER);
|
throw new NotFoundError(NO_USER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ import { ControllerRegistry, Get, Licensed, RestController } from '@/decorators'
|
||||||
import type { License } from '@/license';
|
import type { License } from '@/license';
|
||||||
import type { SuperAgentTest } from '@test-integration/types';
|
import type { SuperAgentTest } from '@test-integration/types';
|
||||||
|
|
||||||
|
import { Param } from '../args';
|
||||||
|
|
||||||
describe('ControllerRegistry', () => {
|
describe('ControllerRegistry', () => {
|
||||||
const license = mock<License>();
|
const license = mock<License>();
|
||||||
const authService = mock<AuthService>();
|
const authService = mock<AuthService>();
|
||||||
|
@ -114,4 +116,26 @@ describe('ControllerRegistry', () => {
|
||||||
expect(license.isFeatureEnabled).toHaveBeenCalled();
|
expect(license.isFeatureEnabled).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Args', () => {
|
||||||
|
@RestController('/test')
|
||||||
|
// @ts-expect-error tsc complains about unused class
|
||||||
|
class TestController {
|
||||||
|
@Get('/args/:id')
|
||||||
|
args(req: express.Request, res: express.Response, @Param('id') id: string) {
|
||||||
|
res.setHeader('Testing', 'true');
|
||||||
|
return { url: req.url, id };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
authService.authMiddleware.mockImplementation(async (_req, _res, next) => next());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass in correct args to the route handler', async () => {
|
||||||
|
const { headers, body } = await agent.get('/rest/test/args/1234').expect(200);
|
||||||
|
expect(headers.testing).toBe('true');
|
||||||
|
expect(body.data).toEqual({ url: '/args/1234', id: '1234' });
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
18
packages/cli/src/decorators/args.ts
Normal file
18
packages/cli/src/decorators/args.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import { getRouteMetadata } from './controller.registry';
|
||||||
|
import type { Arg, Controller } from './types';
|
||||||
|
|
||||||
|
const ArgDecorator =
|
||||||
|
(arg: Arg): ParameterDecorator =>
|
||||||
|
(target, handlerName, parameterIndex) => {
|
||||||
|
const routeMetadata = getRouteMetadata(target.constructor as Controller, String(handlerName));
|
||||||
|
routeMetadata.args[parameterIndex] = arg;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Injects the request body into the handler */
|
||||||
|
export const Body = ArgDecorator({ type: 'body' });
|
||||||
|
|
||||||
|
/** Injects the request query into the handler */
|
||||||
|
export const Query = ArgDecorator({ type: 'query' });
|
||||||
|
|
||||||
|
/** Injects a request parameter into the handler */
|
||||||
|
export const Param = (key: string) => ArgDecorator({ type: 'param', key });
|
|
@ -2,7 +2,9 @@ import { GlobalConfig } from '@n8n/config';
|
||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
import type { Application, Request, Response, RequestHandler } from 'express';
|
import type { Application, Request, Response, RequestHandler } from 'express';
|
||||||
import { rateLimit as expressRateLimit } from 'express-rate-limit';
|
import { rateLimit as expressRateLimit } from 'express-rate-limit';
|
||||||
|
import { ApplicationError } from 'n8n-workflow';
|
||||||
import { Container, Service } from 'typedi';
|
import { Container, Service } from 'typedi';
|
||||||
|
import type { ZodClass } from 'zod-class';
|
||||||
|
|
||||||
import { AuthService } from '@/auth/auth.service';
|
import { AuthService } from '@/auth/auth.service';
|
||||||
import { inProduction, RESPONSE_ERROR_MESSAGES } from '@/constants';
|
import { inProduction, RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||||
|
@ -42,6 +44,7 @@ export const getRouteMetadata = (controllerClass: Controller, handlerName: Handl
|
||||||
let route = metadata.routes.get(handlerName);
|
let route = metadata.routes.get(handlerName);
|
||||||
if (!route) {
|
if (!route) {
|
||||||
route = {} as RouteMetadata;
|
route = {} as RouteMetadata;
|
||||||
|
route.args = [];
|
||||||
metadata.routes.set(handlerName, route);
|
metadata.routes.set(handlerName, route);
|
||||||
}
|
}
|
||||||
return route;
|
return route;
|
||||||
|
@ -76,8 +79,31 @@ export class ControllerRegistry {
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const [handlerName, route] of metadata.routes) {
|
for (const [handlerName, route] of metadata.routes) {
|
||||||
const handler = async (req: Request, res: Response) =>
|
const argTypes = Reflect.getMetadata(
|
||||||
await controller[handlerName](req, res);
|
'design:paramtypes',
|
||||||
|
controller,
|
||||||
|
handlerName,
|
||||||
|
) as unknown[];
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
||||||
|
const handler = async (req: Request, res: Response) => {
|
||||||
|
const args: unknown[] = [req, res];
|
||||||
|
for (let index = 0; index < route.args.length; index++) {
|
||||||
|
const arg = route.args[index];
|
||||||
|
if (!arg) continue; // Skip args without any decorators
|
||||||
|
if (arg.type === 'param') args.push(req.params[arg.key]);
|
||||||
|
else if (['body', 'query'].includes(arg.type)) {
|
||||||
|
const paramType = argTypes[index] as ZodClass;
|
||||||
|
if (paramType && 'parse' in paramType) {
|
||||||
|
const output = paramType.safeParse(req[arg.type]);
|
||||||
|
if (output.success) args.push(output.data);
|
||||||
|
else {
|
||||||
|
return res.status(400).json(output.error.errors[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else throw new ApplicationError('Unknown arg type: ' + arg.type);
|
||||||
|
}
|
||||||
|
return await controller[handlerName](...args);
|
||||||
|
};
|
||||||
|
|
||||||
router[route.method](
|
router[route.method](
|
||||||
route.path,
|
route.path,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
export { Body } from './args';
|
||||||
export { RestController } from './rest-controller';
|
export { RestController } from './rest-controller';
|
||||||
export { Get, Post, Put, Patch, Delete } from './route';
|
export { Get, Post, Put, Patch, Delete } from './route';
|
||||||
export { Middleware } from './middleware';
|
export { Middleware } from './middleware';
|
||||||
|
|
|
@ -6,6 +6,8 @@ import type { BooleanLicenseFeature } from '@/interfaces';
|
||||||
|
|
||||||
export type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
export type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
||||||
|
|
||||||
|
export type Arg = { type: 'body' | 'query' } | { type: 'param'; key: string };
|
||||||
|
|
||||||
export interface RateLimit {
|
export interface RateLimit {
|
||||||
/**
|
/**
|
||||||
* The maximum number of requests to allow during the `window` before rate limiting the client.
|
* The maximum number of requests to allow during the `window` before rate limiting the client.
|
||||||
|
@ -35,6 +37,7 @@ export interface RouteMetadata {
|
||||||
rateLimit?: boolean | RateLimit;
|
rateLimit?: boolean | RateLimit;
|
||||||
licenseFeature?: BooleanLicenseFeature;
|
licenseFeature?: BooleanLicenseFeature;
|
||||||
accessScope?: AccessScope;
|
accessScope?: AccessScope;
|
||||||
|
args: Arg[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ControllerMetadata {
|
export interface ControllerMetadata {
|
||||||
|
|
|
@ -5,11 +5,6 @@ import type { CredentialsEntity } from '@/databases/entities/credentials-entity'
|
||||||
import type { TagEntity } from '@/databases/entities/tag-entity';
|
import type { TagEntity } from '@/databases/entities/tag-entity';
|
||||||
import type { User } from '@/databases/entities/user';
|
import type { User } from '@/databases/entities/user';
|
||||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||||
import type {
|
|
||||||
UserRoleChangePayload,
|
|
||||||
UserSettingsUpdatePayload,
|
|
||||||
UserUpdatePayload,
|
|
||||||
} from '@/requests';
|
|
||||||
|
|
||||||
import type { PersonalizationSurveyAnswersV4 } from './controllers/survey-answers.dto';
|
import type { PersonalizationSurveyAnswersV4 } from './controllers/survey-answers.dto';
|
||||||
import { BadRequestError } from './errors/response-errors/bad-request.error';
|
import { BadRequestError } from './errors/response-errors/bad-request.error';
|
||||||
|
@ -21,9 +16,6 @@ export async function validateEntity(
|
||||||
| TagEntity
|
| TagEntity
|
||||||
| AnnotationTagEntity
|
| AnnotationTagEntity
|
||||||
| User
|
| User
|
||||||
| UserUpdatePayload
|
|
||||||
| UserRoleChangePayload
|
|
||||||
| UserSettingsUpdatePayload
|
|
||||||
| PersonalizationSurveyAnswersV4,
|
| PersonalizationSurveyAnswersV4,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const errors = await validate(entity);
|
const errors = await validate(entity);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { RoleChangeRequestDTO } from '@n8n/api-types';
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
import type { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
import { Container } from 'typedi';
|
import { Container } from 'typedi';
|
||||||
|
@ -6,7 +7,7 @@ import { InvitationController } from '@/controllers/invitation.controller';
|
||||||
import { UsersController } from '@/controllers/users.controller';
|
import { UsersController } from '@/controllers/users.controller';
|
||||||
import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository';
|
import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import type { UserRequest } from '@/requests';
|
import type { AuthenticatedRequest, UserRequest } from '@/requests';
|
||||||
|
|
||||||
import { clean, getAllUsersAndCount, getUser } from './users.service.ee';
|
import { clean, getAllUsersAndCount, getUser } from './users.service.ee';
|
||||||
import {
|
import {
|
||||||
|
@ -19,7 +20,7 @@ import { encodeNextCursor } from '../../shared/services/pagination.service';
|
||||||
|
|
||||||
type Create = UserRequest.Invite;
|
type Create = UserRequest.Invite;
|
||||||
type Delete = UserRequest.Delete;
|
type Delete = UserRequest.Delete;
|
||||||
type ChangeRole = UserRequest.ChangeRole;
|
type ChangeRole = AuthenticatedRequest<{ id: string }, {}, RoleChangeRequestDTO, {}>;
|
||||||
|
|
||||||
export = {
|
export = {
|
||||||
getUser: [
|
getUser: [
|
||||||
|
@ -98,7 +99,19 @@ export = {
|
||||||
isLicensed('feat:advancedPermissions'),
|
isLicensed('feat:advancedPermissions'),
|
||||||
globalScope('user:changeRole'),
|
globalScope('user:changeRole'),
|
||||||
async (req: ChangeRole, res: Response) => {
|
async (req: ChangeRole, res: Response) => {
|
||||||
await Container.get(UsersController).changeGlobalRole(req);
|
const validation = RoleChangeRequestDTO.safeParse(req.body);
|
||||||
|
if (validation.error) {
|
||||||
|
return res.status(400).json({
|
||||||
|
message: validation.error.errors[0],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await Container.get(UsersController).changeGlobalRole(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
validation.data,
|
||||||
|
req.params.id,
|
||||||
|
);
|
||||||
|
|
||||||
return res.status(204).send();
|
return res.status(204).send();
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import type { Scope } from '@n8n/permissions';
|
import type { Scope } from '@n8n/permissions';
|
||||||
import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk';
|
import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk';
|
||||||
import { Expose } from 'class-transformer';
|
|
||||||
import { IsBoolean, IsEmail, IsIn, IsOptional, IsString, Length } from 'class-validator';
|
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
import type {
|
import type {
|
||||||
BannerName,
|
BannerName,
|
||||||
|
@ -18,61 +16,15 @@ import type {
|
||||||
|
|
||||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||||
import type { Project, ProjectType } from '@/databases/entities/project';
|
import type { Project, ProjectType } from '@/databases/entities/project';
|
||||||
import { AssignableRole } from '@/databases/entities/user';
|
import type { AssignableRole, GlobalRole, User } from '@/databases/entities/user';
|
||||||
import type { GlobalRole, User } from '@/databases/entities/user';
|
|
||||||
import type { Variables } from '@/databases/entities/variables';
|
import type { Variables } from '@/databases/entities/variables';
|
||||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||||
import type { WorkflowHistory } from '@/databases/entities/workflow-history';
|
import type { WorkflowHistory } from '@/databases/entities/workflow-history';
|
||||||
import type { PublicUser, SecretsProvider, SecretsProviderState } from '@/interfaces';
|
import type { PublicUser, SecretsProvider, SecretsProviderState } from '@/interfaces';
|
||||||
import { NoUrl } from '@/validators/no-url.validator';
|
|
||||||
import { NoXss } from '@/validators/no-xss.validator';
|
|
||||||
|
|
||||||
import type { ProjectRole } from './databases/entities/project-relation';
|
import type { ProjectRole } from './databases/entities/project-relation';
|
||||||
import type { ScopesField } from './services/role.service';
|
import type { ScopesField } from './services/role.service';
|
||||||
|
|
||||||
export class UserUpdatePayload implements Pick<User, 'email' | 'firstName' | 'lastName'> {
|
|
||||||
@Expose()
|
|
||||||
@IsEmail()
|
|
||||||
email: string;
|
|
||||||
|
|
||||||
@Expose()
|
|
||||||
@NoXss()
|
|
||||||
@NoUrl()
|
|
||||||
@IsString({ message: 'First name must be of type string.' })
|
|
||||||
@Length(1, 32, { message: 'First name must be $constraint1 to $constraint2 characters long.' })
|
|
||||||
firstName: string;
|
|
||||||
|
|
||||||
@Expose()
|
|
||||||
@NoXss()
|
|
||||||
@NoUrl()
|
|
||||||
@IsString({ message: 'Last name must be of type string.' })
|
|
||||||
@Length(1, 32, { message: 'Last name must be $constraint1 to $constraint2 characters long.' })
|
|
||||||
lastName: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@Expose()
|
|
||||||
@IsString({ message: 'Two factor code must be a string.' })
|
|
||||||
mfaCode?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UserSettingsUpdatePayload {
|
|
||||||
@Expose()
|
|
||||||
@IsBoolean({ message: 'userActivated should be a boolean' })
|
|
||||||
@IsOptional()
|
|
||||||
userActivated?: boolean;
|
|
||||||
|
|
||||||
@Expose()
|
|
||||||
@IsBoolean({ message: 'allowSSOManualLogin should be a boolean' })
|
|
||||||
@IsOptional()
|
|
||||||
allowSSOManualLogin?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UserRoleChangePayload {
|
|
||||||
@Expose()
|
|
||||||
@IsIn(['global:admin', 'global:member'])
|
|
||||||
newRoleName: AssignableRole;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type APIRequest<
|
export type APIRequest<
|
||||||
RouteParams = {},
|
RouteParams = {},
|
||||||
ResponseBody = {},
|
ResponseBody = {},
|
||||||
|
@ -230,13 +182,6 @@ export declare namespace CredentialRequest {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
export declare namespace MeRequest {
|
export declare namespace MeRequest {
|
||||||
export type UserSettingsUpdate = AuthenticatedRequest<{}, {}, UserSettingsUpdatePayload>;
|
|
||||||
export type UserUpdate = AuthenticatedRequest<{}, {}, UserUpdatePayload>;
|
|
||||||
export type Password = AuthenticatedRequest<
|
|
||||||
{},
|
|
||||||
{},
|
|
||||||
{ currentPassword: string; newPassword: string; mfaCode?: string }
|
|
||||||
>;
|
|
||||||
export type SurveyAnswers = AuthenticatedRequest<{}, {}, IPersonalizationSurveyAnswersV4>;
|
export type SurveyAnswers = AuthenticatedRequest<{}, {}, IPersonalizationSurveyAnswersV4>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,8 +256,6 @@ export declare namespace UserRequest {
|
||||||
{ transferId?: string; includeRole: boolean }
|
{ transferId?: string; includeRole: boolean }
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export type ChangeRole = AuthenticatedRequest<{ id: string }, {}, UserRoleChangePayload, {}>;
|
|
||||||
|
|
||||||
export type Get = AuthenticatedRequest<
|
export type Get = AuthenticatedRequest<
|
||||||
{ id: string; email: string; identifier: string },
|
{ id: string; email: string; identifier: string },
|
||||||
{},
|
{},
|
||||||
|
@ -322,12 +265,6 @@ export declare namespace UserRequest {
|
||||||
|
|
||||||
export type PasswordResetLink = AuthenticatedRequest<{ id: string }, {}, {}, {}>;
|
export type PasswordResetLink = AuthenticatedRequest<{ id: string }, {}, {}, {}>;
|
||||||
|
|
||||||
export type UserSettingsUpdate = AuthenticatedRequest<
|
|
||||||
{ id: string },
|
|
||||||
{},
|
|
||||||
UserSettingsUpdatePayload
|
|
||||||
>;
|
|
||||||
|
|
||||||
export type Reinvite = AuthenticatedRequest<{ id: string }>;
|
export type Reinvite = AuthenticatedRequest<{ id: string }>;
|
||||||
|
|
||||||
export type Update = AuthlessRequest<
|
export type Update = AuthlessRequest<
|
||||||
|
|
|
@ -225,6 +225,29 @@ describe('Users in Public API', () => {
|
||||||
expect(response.body).toHaveProperty('message', 'Forbidden');
|
expect(response.body).toHaveProperty('message', 'Forbidden');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return a 400 on invalid payload', async () => {
|
||||||
|
/**
|
||||||
|
* Arrange
|
||||||
|
*/
|
||||||
|
testServer.license.enable('feat:advancedPermissions');
|
||||||
|
const owner = await createOwner({ withApiKey: true });
|
||||||
|
const member = await createMember();
|
||||||
|
const payload = { newRoleName: 'invalid' };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Act
|
||||||
|
*/
|
||||||
|
const response = await testServer
|
||||||
|
.publicApiAgentFor(owner)
|
||||||
|
.patch(`/users/${member.id}/role`)
|
||||||
|
.send(payload);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assert
|
||||||
|
*/
|
||||||
|
expect(response.status).toBe(400);
|
||||||
|
});
|
||||||
|
|
||||||
it("should change a user's role", async () => {
|
it("should change a user's role", async () => {
|
||||||
/**
|
/**
|
||||||
* Arrange
|
* Arrange
|
||||||
|
|
|
@ -22,9 +22,11 @@ const testServer = utils.setupTestServer({
|
||||||
enabledFeatures: ['feat:saml'],
|
enabledFeatures: ['feat:saml'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const memberPassword = randomValidPassword();
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
owner = await createOwner();
|
owner = await createOwner();
|
||||||
someUser = await createUser();
|
someUser = await createUser({ password: memberPassword });
|
||||||
authOwnerAgent = testServer.authAgentFor(owner);
|
authOwnerAgent = testServer.authAgentFor(owner);
|
||||||
authMemberAgent = testServer.authAgentFor(someUser);
|
authMemberAgent = testServer.authAgentFor(someUser);
|
||||||
});
|
});
|
||||||
|
@ -60,10 +62,11 @@ describe('Instance owner', () => {
|
||||||
describe('PATCH /password', () => {
|
describe('PATCH /password', () => {
|
||||||
test('should throw BadRequestError if password is changed when SAML is enabled', async () => {
|
test('should throw BadRequestError if password is changed when SAML is enabled', async () => {
|
||||||
await enableSaml(true);
|
await enableSaml(true);
|
||||||
await authOwnerAgent
|
await authMemberAgent
|
||||||
.patch('/me/password')
|
.patch('/me/password')
|
||||||
.send({
|
.send({
|
||||||
password: randomValidPassword(),
|
currentPassword: memberPassword,
|
||||||
|
newPassword: randomValidPassword(),
|
||||||
})
|
})
|
||||||
.expect(400, {
|
.expect(400, {
|
||||||
code: 400,
|
code: 400,
|
||||||
|
|
|
@ -672,9 +672,6 @@ describe('PATCH /users/:id/role', () => {
|
||||||
])('%s', async (_, payload) => {
|
])('%s', async (_, payload) => {
|
||||||
const response = await adminAgent.patch(`/users/${member.id}/role`).send(payload);
|
const response = await adminAgent.patch(`/users/${member.id}/role`).send(payload);
|
||||||
expect(response.statusCode).toBe(400);
|
expect(response.statusCode).toBe(400);
|
||||||
expect(response.body.message).toBe(
|
|
||||||
'newRoleName must be one of the following values: global:admin, global:member',
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,6 @@
|
||||||
"vue": "catalog:frontend",
|
"vue": "catalog:frontend",
|
||||||
"vue-boring-avatars": "^1.3.0",
|
"vue-boring-avatars": "^1.3.0",
|
||||||
"vue-router": "^4.2.2",
|
"vue-router": "^4.2.2",
|
||||||
"xss": "^1.0.14"
|
"xss": "catalog:"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineProps, withDefaults } from 'vue';
|
|
||||||
|
|
||||||
import AssistantAvatar from '../AskAssistantAvatar/AssistantAvatar.vue';
|
import AssistantAvatar from '../AskAssistantAvatar/AssistantAvatar.vue';
|
||||||
|
|
||||||
withDefaults(
|
withDefaults(
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
"n8n-design-system": "workspace:*",
|
"n8n-design-system": "workspace:*",
|
||||||
"n8n-workflow": "workspace:*",
|
"n8n-workflow": "workspace:*",
|
||||||
"pinia": "^2.1.6",
|
"pinia": "^2.1.6",
|
||||||
"prettier": "^3.1.0",
|
"prettier": "^3.3.3",
|
||||||
"qrcode.vue": "^3.3.4",
|
"qrcode.vue": "^3.3.4",
|
||||||
"stream-browserify": "^3.0.0",
|
"stream-browserify": "^3.0.0",
|
||||||
"timeago.js": "^4.0.2",
|
"timeago.js": "^4.0.2",
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
"vue-markdown-render": "catalog:frontend",
|
"vue-markdown-render": "catalog:frontend",
|
||||||
"vue-router": "^4.2.2",
|
"vue-router": "^4.2.2",
|
||||||
"vue3-touch-events": "^4.1.3",
|
"vue3-touch-events": "^4.1.3",
|
||||||
"xss": "^1.0.14"
|
"xss": "catalog:"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@faker-js/faker": "^8.0.2",
|
"@faker-js/faker": "^8.0.2",
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
import type {
|
||||||
|
PasswordUpdateRequestDTO,
|
||||||
|
SettingsUpdateRequestDTO,
|
||||||
|
UserUpdateRequestDTO,
|
||||||
|
} from '@n8n/api-types';
|
||||||
import type {
|
import type {
|
||||||
CurrentUserResponse,
|
CurrentUserResponse,
|
||||||
IPersonalizationLatestVersion,
|
IPersonalizationLatestVersion,
|
||||||
|
@ -8,11 +13,6 @@ import type {
|
||||||
import type { IDataObject, IUserSettings } from 'n8n-workflow';
|
import type { IDataObject, IUserSettings } from 'n8n-workflow';
|
||||||
import { makeRestApiRequest } from '@/utils/apiUtils';
|
import { makeRestApiRequest } from '@/utils/apiUtils';
|
||||||
|
|
||||||
export interface IUpdateUserSettingsReqPayload {
|
|
||||||
allowSSOManualLogin?: boolean;
|
|
||||||
userActivated?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function loginCurrentUser(
|
export async function loginCurrentUser(
|
||||||
context: IRestApiContext,
|
context: IRestApiContext,
|
||||||
): Promise<CurrentUserResponse | null> {
|
): Promise<CurrentUserResponse | null> {
|
||||||
|
@ -89,23 +89,16 @@ export async function changePassword(
|
||||||
await makeRestApiRequest(context, 'POST', '/change-password', params);
|
await makeRestApiRequest(context, 'POST', '/change-password', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateCurrentUserParams = {
|
|
||||||
firstName?: string;
|
|
||||||
lastName?: string;
|
|
||||||
email: string;
|
|
||||||
mfaCode?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function updateCurrentUser(
|
export async function updateCurrentUser(
|
||||||
context: IRestApiContext,
|
context: IRestApiContext,
|
||||||
params: UpdateCurrentUserParams,
|
params: UserUpdateRequestDTO,
|
||||||
): Promise<IUserResponse> {
|
): Promise<IUserResponse> {
|
||||||
return await makeRestApiRequest(context, 'PATCH', '/me', params);
|
return await makeRestApiRequest(context, 'PATCH', '/me', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateCurrentUserSettings(
|
export async function updateCurrentUserSettings(
|
||||||
context: IRestApiContext,
|
context: IRestApiContext,
|
||||||
settings: IUpdateUserSettingsReqPayload,
|
settings: SettingsUpdateRequestDTO,
|
||||||
): Promise<IUserSettings> {
|
): Promise<IUserSettings> {
|
||||||
return await makeRestApiRequest(context, 'PATCH', '/me/settings', settings);
|
return await makeRestApiRequest(context, 'PATCH', '/me/settings', settings);
|
||||||
}
|
}
|
||||||
|
@ -113,20 +106,14 @@ export async function updateCurrentUserSettings(
|
||||||
export async function updateOtherUserSettings(
|
export async function updateOtherUserSettings(
|
||||||
context: IRestApiContext,
|
context: IRestApiContext,
|
||||||
userId: string,
|
userId: string,
|
||||||
settings: IUpdateUserSettingsReqPayload,
|
settings: SettingsUpdateRequestDTO,
|
||||||
): Promise<IUserSettings> {
|
): Promise<IUserSettings> {
|
||||||
return await makeRestApiRequest(context, 'PATCH', `/users/${userId}/settings`, settings);
|
return await makeRestApiRequest(context, 'PATCH', `/users/${userId}/settings`, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateUserPasswordParams = {
|
|
||||||
newPassword: string;
|
|
||||||
currentPassword: string;
|
|
||||||
mfaCode?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function updateCurrentUserPassword(
|
export async function updateCurrentUserPassword(
|
||||||
context: IRestApiContext,
|
context: IRestApiContext,
|
||||||
params: UpdateUserPasswordParams,
|
params: PasswordUpdateRequestDTO,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return await makeRestApiRequest(context, 'PATCH', '/me/password', params);
|
return await makeRestApiRequest(context, 'PATCH', '/me/password', params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineProps, defineEmits } from 'vue';
|
import { computed } from 'vue';
|
||||||
import TagsContainer from './TagsContainer.vue';
|
import TagsContainer from './TagsContainer.vue';
|
||||||
import { useAnnotationTagsStore } from '@/stores/tags.store';
|
import { useAnnotationTagsStore } from '@/stores/tags.store';
|
||||||
import type { ITag } from '@/Interface';
|
import type { ITag } from '@/Interface';
|
||||||
|
|
|
@ -77,7 +77,7 @@ const onDrag = (event: MouseEvent) => {
|
||||||
if (!isDragging.value && draggingElement.value) {
|
if (!isDragging.value && draggingElement.value) {
|
||||||
isDragging.value = true;
|
isDragging.value = true;
|
||||||
|
|
||||||
const data = props.targetDataKey ? draggingElement.value.dataset.value : props.data ?? '';
|
const data = props.targetDataKey ? draggingElement.value.dataset.value : (props.data ?? '');
|
||||||
|
|
||||||
ndvStore.draggableStartDragging({
|
ndvStore.draggableStartDragging({
|
||||||
type: props.type,
|
type: props.type,
|
||||||
|
|
|
@ -417,7 +417,7 @@ export default defineComponent({
|
||||||
type="secondary"
|
type="secondary"
|
||||||
hide-icon
|
hide-icon
|
||||||
:transparent="true"
|
:transparent="true"
|
||||||
:node-name="isActiveNodeConfig ? rootNode : currentNodeName ?? ''"
|
:node-name="isActiveNodeConfig ? rootNode : (currentNodeName ?? '')"
|
||||||
:label="$locale.baseText('ndv.input.noOutputData.executePrevious')"
|
:label="$locale.baseText('ndv.input.noOutputData.executePrevious')"
|
||||||
telemetry-source="inputs"
|
telemetry-source="inputs"
|
||||||
data-test-id="execute-previous-node"
|
data-test-id="execute-previous-node"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { withDefaults, defineProps, defineEmits, ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import {
|
import {
|
||||||
WEBHOOK_NODE_TYPE,
|
WEBHOOK_NODE_TYPE,
|
||||||
MANUAL_TRIGGER_NODE_TYPE,
|
MANUAL_TRIGGER_NODE_TYPE,
|
||||||
|
|
|
@ -26,7 +26,7 @@ const emit = defineEmits<{
|
||||||
projectRemoved: [value: ProjectSharingData];
|
projectRemoved: [value: ProjectSharingData];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const selectedProject = ref(Array.isArray(model.value) ? '' : model.value?.id ?? '');
|
const selectedProject = ref(Array.isArray(model.value) ? '' : (model.value?.id ?? ''));
|
||||||
const filter = ref('');
|
const filter = ref('');
|
||||||
const selectPlaceholder = computed(
|
const selectPlaceholder = computed(
|
||||||
() => props.placeholder ?? locale.baseText('projects.sharing.select.placeholder'),
|
() => props.placeholder ?? locale.baseText('projects.sharing.select.placeholder'),
|
||||||
|
|
|
@ -41,7 +41,7 @@ export default defineComponent({
|
||||||
const projectId = props.projectId ?? inferProjectIdFromRoute(route);
|
const projectId = props.projectId ?? inferProjectIdFromRoute(route);
|
||||||
const resourceType = props.resourceType ?? inferResourceTypeFromRoute(route);
|
const resourceType = props.resourceType ?? inferResourceTypeFromRoute(route);
|
||||||
const resourceId = resourceType
|
const resourceId = resourceType
|
||||||
? props.resourceId ?? inferResourceIdFromRoute(route)
|
? (props.resourceId ?? inferResourceIdFromRoute(route))
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return rbacStore.hasScope(
|
return rbacStore.hasScope(
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { nonExistingJsonPath } from '@/constants';
|
||||||
import { useExternalHooks } from '@/composables/useExternalHooks';
|
import { useExternalHooks } from '@/composables/useExternalHooks';
|
||||||
import TextWithHighlights from './TextWithHighlights.vue';
|
import TextWithHighlights from './TextWithHighlights.vue';
|
||||||
import { useTelemetry } from '@/composables/useTelemetry';
|
import { useTelemetry } from '@/composables/useTelemetry';
|
||||||
|
import { useElementSize } from '@vueuse/core';
|
||||||
|
|
||||||
const LazyRunDataJsonActions = defineAsyncComponent(
|
const LazyRunDataJsonActions = defineAsyncComponent(
|
||||||
async () => await import('@/components/RunDataJsonActions.vue'),
|
async () => await import('@/components/RunDataJsonActions.vue'),
|
||||||
|
@ -45,6 +46,9 @@ const telemetry = useTelemetry();
|
||||||
const selectedJsonPath = ref(nonExistingJsonPath);
|
const selectedJsonPath = ref(nonExistingJsonPath);
|
||||||
const draggingPath = ref<null | string>(null);
|
const draggingPath = ref<null | string>(null);
|
||||||
const displayMode = ref('json');
|
const displayMode = ref('json');
|
||||||
|
const jsonDataContainer = ref(null);
|
||||||
|
|
||||||
|
const { height } = useElementSize(jsonDataContainer);
|
||||||
|
|
||||||
const jsonData = computed(() => executionDataToJson(props.inputData));
|
const jsonData = computed(() => executionDataToJson(props.inputData));
|
||||||
|
|
||||||
|
@ -110,7 +114,7 @@ const getListItemName = (path: string) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="[$style.jsonDisplay, { [$style.highlight]: highlight }]">
|
<div ref="jsonDataContainer" :class="[$style.jsonDisplay, { [$style.highlight]: highlight }]">
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<LazyRunDataJsonActions
|
<LazyRunDataJsonActions
|
||||||
v-if="!editMode.enabled"
|
v-if="!editMode.enabled"
|
||||||
|
@ -141,6 +145,8 @@ const getListItemName = (path: string) => {
|
||||||
root-path=""
|
root-path=""
|
||||||
selectable-type="single"
|
selectable-type="single"
|
||||||
class="json-data"
|
class="json-data"
|
||||||
|
:virtual="true"
|
||||||
|
:height="height"
|
||||||
@update:selected-value="selectedJsonPath = $event"
|
@update:selected-value="selectedJsonPath = $event"
|
||||||
>
|
>
|
||||||
<template #renderNodeKey="{ node }">
|
<template #renderNodeKey="{ node }">
|
||||||
|
@ -192,11 +198,10 @@ const getListItemName = (path: string) => {
|
||||||
left: 0;
|
left: 0;
|
||||||
padding-left: var(--spacing-s);
|
padding-left: var(--spacing-s);
|
||||||
right: 0;
|
right: 0;
|
||||||
overflow-y: auto;
|
overflow-y: hidden;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
word-break: normal;
|
word-break: normal;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding-bottom: var(--spacing-3xl);
|
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
/* Shows .actionsGroup element from <run-data-json-actions /> child component */
|
/* Shows .actionsGroup element from <run-data-json-actions /> child component */
|
||||||
|
@ -299,4 +304,8 @@ const getListItemName = (path: string) => {
|
||||||
.vjs-tree .vjs-tree__content.has-line {
|
.vjs-tree .vjs-tree__content.has-line {
|
||||||
border-left: 1px dotted var(--color-json-line);
|
border-left: 1px dotted var(--color-json-line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vjs-tree .vjs-tree-list-holder-inner {
|
||||||
|
padding-bottom: var(--spacing-3xl);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -25,7 +25,7 @@ const i18n = useI18n();
|
||||||
|
|
||||||
const saveButtonLabel = computed(() => {
|
const saveButtonLabel = computed(() => {
|
||||||
return props.isSaving
|
return props.isSaving
|
||||||
? props.savingLabel ?? i18n.baseText('saveButton.saving')
|
? (props.savingLabel ?? i18n.baseText('saveButton.saving'))
|
||||||
: i18n.baseText('saveButton.save');
|
: i18n.baseText('saveButton.save');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ const valueToDisplay = computed<NodeParameterValue>(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isListMode.value) {
|
if (isListMode.value) {
|
||||||
return props.modelValue ? props.modelValue.cachedResultName ?? props.modelValue.value : '';
|
return props.modelValue ? (props.modelValue.cachedResultName ?? props.modelValue.value) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.modelValue ? props.modelValue.value : '';
|
return props.modelValue ? props.modelValue.value : '';
|
||||||
|
|
|
@ -2,6 +2,22 @@ import { createTestingPinia } from '@pinia/testing';
|
||||||
import { screen, cleanup } from '@testing-library/vue';
|
import { screen, cleanup } from '@testing-library/vue';
|
||||||
import RunDataJson from '@/components/RunDataJson.vue';
|
import RunDataJson from '@/components/RunDataJson.vue';
|
||||||
import { createComponentRenderer } from '@/__tests__/render';
|
import { createComponentRenderer } from '@/__tests__/render';
|
||||||
|
import { useElementSize } from '@vueuse/core'; // Import the composable to mock
|
||||||
|
|
||||||
|
vi.mock('@vueuse/core', async () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||||
|
const originalModule = await vi.importActual<typeof import('@vueuse/core')>('@vueuse/core');
|
||||||
|
|
||||||
|
return {
|
||||||
|
...originalModule, // Keep all original exports
|
||||||
|
useElementSize: vi.fn(), // Mock useElementSize
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
(useElementSize as jest.Mock).mockReturnValue({
|
||||||
|
height: 500, // Mocked height value
|
||||||
|
width: 300, // Mocked width value
|
||||||
|
});
|
||||||
|
|
||||||
const renderComponent = createComponentRenderer(RunDataJson, {
|
const renderComponent = createComponentRenderer(RunDataJson, {
|
||||||
props: {
|
props: {
|
||||||
|
@ -34,18 +50,6 @@ const renderComponent = createComponentRenderer(RunDataJson, {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
global: {
|
|
||||||
mocks: {
|
|
||||||
$locale: {
|
|
||||||
baseText() {
|
|
||||||
return '';
|
|
||||||
},
|
|
||||||
},
|
|
||||||
$store: {
|
|
||||||
getters: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('RunDataJson.vue', () => {
|
describe('RunDataJson.vue', () => {
|
||||||
|
|
|
@ -11,7 +11,19 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
||||||
>
|
>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="vjs-tree json-data"
|
class="vjs-tree is-virtual json-data"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="vjs-tree-list"
|
||||||
|
style="height: 500px;"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="vjs-tree-list-holder"
|
||||||
|
style="height: 340px;"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="vjs-tree-list-holder-inner"
|
||||||
|
style="transform: translateY(0px);"
|
||||||
>
|
>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
@ -828,6 +840,9 @@ exports[`RunDataJson.vue > renders json values properly 1`] = `
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!--teleport start-->
|
<!--teleport start-->
|
||||||
<!--teleport end-->
|
<!--teleport end-->
|
||||||
|
|
|
@ -37,7 +37,7 @@ const plusLineSize = computed(
|
||||||
small: 46,
|
small: 46,
|
||||||
medium: 66,
|
medium: 66,
|
||||||
large: 80,
|
large: 80,
|
||||||
})[renderOptions.value.outputs?.labelSize ?? runData.value ? 'large' : 'small'],
|
})[(renderOptions.value.outputs?.labelSize ?? runData.value) ? 'large' : 'small'],
|
||||||
);
|
);
|
||||||
|
|
||||||
function onMouseEnter() {
|
function onMouseEnter() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted, onBeforeUnmount, defineProps } from 'vue';
|
import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
|
||||||
import { useI18n } from '@/composables/useI18n';
|
import { useI18n } from '@/composables/useI18n';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineProps, defineEmits } from 'vue';
|
|
||||||
import type { AnnotationVote } from 'n8n-workflow';
|
import type { AnnotationVote } from 'n8n-workflow';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
|
|
@ -39,7 +39,7 @@ const router = useRouter();
|
||||||
const temporaryExecution = computed<ExecutionSummary | undefined>(() =>
|
const temporaryExecution = computed<ExecutionSummary | undefined>(() =>
|
||||||
props.executions.find((execution) => execution.id === props.execution?.id)
|
props.executions.find((execution) => execution.id === props.execution?.id)
|
||||||
? undefined
|
? undefined
|
||||||
: props.execution ?? undefined,
|
: (props.execution ?? undefined),
|
||||||
);
|
);
|
||||||
|
|
||||||
const hidePreview = computed(() => {
|
const hidePreview = computed(() => {
|
||||||
|
|
|
@ -356,9 +356,9 @@ export const useAssistantStore = defineStore(STORES.ASSISTANT, () => {
|
||||||
resetAssistantChat();
|
resetAssistantChat();
|
||||||
chatSessionTask.value = credentialType ? 'credentials' : 'support';
|
chatSessionTask.value = credentialType ? 'credentials' : 'support';
|
||||||
chatSessionCredType.value = credentialType;
|
chatSessionCredType.value = credentialType;
|
||||||
chatWindowOpen.value = true;
|
|
||||||
addUserMessage(userMessage, id);
|
addUserMessage(userMessage, id);
|
||||||
addLoadingAssistantMessage(locale.baseText('aiAssistant.thinkingSteps.thinking'));
|
addLoadingAssistantMessage(locale.baseText('aiAssistant.thinkingSteps.thinking'));
|
||||||
|
openChat();
|
||||||
streaming.value = true;
|
streaming.value = true;
|
||||||
|
|
||||||
let payload: ChatRequest.InitSupportChat | ChatRequest.InitCredHelp = {
|
let payload: ChatRequest.InitSupportChat | ChatRequest.InitCredHelp = {
|
||||||
|
|
|
@ -7,8 +7,9 @@ import {
|
||||||
hasDestinationId,
|
hasDestinationId,
|
||||||
saveDestinationToDb,
|
saveDestinationToDb,
|
||||||
sendTestMessageToDestination,
|
sendTestMessageToDestination,
|
||||||
} from '../api/eventbus.ee';
|
} from '@/api/eventbus.ee';
|
||||||
import { useRootStore } from './root.store';
|
import { useRootStore } from './root.store';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
export interface EventSelectionItem {
|
export interface EventSelectionItem {
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
|
@ -32,80 +33,142 @@ export interface DestinationSettingsStore {
|
||||||
[key: string]: DestinationStoreItem;
|
[key: string]: DestinationStoreItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useLogStreamingStore = defineStore('logStreaming', {
|
export const useLogStreamingStore = defineStore('logStreaming', () => {
|
||||||
state: () => ({
|
const items = ref<DestinationSettingsStore>({});
|
||||||
items: {} as DestinationSettingsStore,
|
const eventNames = ref(new Set<string>());
|
||||||
eventNames: new Set<string>(),
|
|
||||||
}),
|
const rootStore = useRootStore();
|
||||||
getters: {},
|
|
||||||
actions: {
|
const addDestination = (destination: MessageEventBusDestinationOptions) => {
|
||||||
addDestination(destination: MessageEventBusDestinationOptions) {
|
if (destination.id && items.value[destination.id]) {
|
||||||
if (destination.id && this.items[destination.id]) {
|
items.value[destination.id].destination = destination;
|
||||||
this.items[destination.id].destination = destination;
|
|
||||||
} else {
|
} else {
|
||||||
this.setSelectionAndBuildItems(destination);
|
setSelectionAndBuildItems(destination);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
getDestination(destinationId: string): MessageEventBusDestinationOptions | undefined {
|
|
||||||
if (this.items[destinationId]) {
|
const setSelectionAndBuildItems = (destination: MessageEventBusDestinationOptions) => {
|
||||||
return this.items[destinationId].destination;
|
if (destination.id) {
|
||||||
|
if (!items.value[destination.id]) {
|
||||||
|
items.value[destination.id] = {
|
||||||
|
destination,
|
||||||
|
selectedEvents: new Set<string>(),
|
||||||
|
eventGroups: [],
|
||||||
|
isNew: false,
|
||||||
|
} as DestinationStoreItem;
|
||||||
|
}
|
||||||
|
items.value[destination.id]?.selectedEvents?.clear();
|
||||||
|
if (destination.subscribedEvents) {
|
||||||
|
for (const eventName of destination.subscribedEvents) {
|
||||||
|
items.value[destination.id]?.selectedEvents?.add(eventName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items.value[destination.id].eventGroups = eventGroupsFromStringList(
|
||||||
|
eventNames.value,
|
||||||
|
items.value[destination.id]?.selectedEvents,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDestination = (destinationId: string) => {
|
||||||
|
if (items.value[destinationId]) {
|
||||||
|
return items.value[destinationId].destination;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
getAllDestinations(): MessageEventBusDestinationOptions[] {
|
|
||||||
|
const getAllDestinations = () => {
|
||||||
const destinations: MessageEventBusDestinationOptions[] = [];
|
const destinations: MessageEventBusDestinationOptions[] = [];
|
||||||
for (const key of Object.keys(this.items)) {
|
for (const key of Object.keys(items)) {
|
||||||
destinations.push(this.items[key].destination);
|
destinations.push(items.value[key].destination);
|
||||||
}
|
}
|
||||||
return destinations;
|
return destinations;
|
||||||
},
|
};
|
||||||
updateDestination(destination: MessageEventBusDestinationOptions) {
|
|
||||||
if (destination.id && this.items[destination.id]) {
|
const clearDestinations = () => {
|
||||||
this.$patch((state) => {
|
items.value = {};
|
||||||
if (destination.id && this.items[destination.id]) {
|
};
|
||||||
state.items[destination.id].destination = destination;
|
|
||||||
|
const addEventName = (name: string) => {
|
||||||
|
eventNames.value.add(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeEventName = (name: string) => {
|
||||||
|
eventNames.value.delete(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearEventNames = () => {
|
||||||
|
eventNames.value.clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
const addSelectedEvent = (id: string, name: string) => {
|
||||||
|
items.value[id]?.selectedEvents?.add(name);
|
||||||
|
setSelectedInGroup(id, name, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeSelectedEvent = (id: string, name: string) => {
|
||||||
|
items.value[id]?.selectedEvents?.delete(name);
|
||||||
|
setSelectedInGroup(id, name, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const setSelectedInGroup = (destinationId: string, name: string, isSelected: boolean) => {
|
||||||
|
if (items.value[destinationId]) {
|
||||||
|
const groupName = eventGroupFromEventName(name);
|
||||||
|
const groupIndex = items.value[destinationId].eventGroups.findIndex(
|
||||||
|
(e) => e.name === groupName,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (groupIndex > -1) {
|
||||||
|
if (groupName === name) {
|
||||||
|
items.value[destinationId].eventGroups[groupIndex].selected = isSelected;
|
||||||
|
} else {
|
||||||
|
const eventIndex = items.value[destinationId].eventGroups[groupIndex].children.findIndex(
|
||||||
|
(e) => e.name === name,
|
||||||
|
);
|
||||||
|
if (eventIndex > -1) {
|
||||||
|
items.value[destinationId].eventGroups[groupIndex].children[eventIndex].selected =
|
||||||
|
isSelected;
|
||||||
|
if (isSelected) {
|
||||||
|
items.value[destinationId].eventGroups[groupIndex].indeterminate = isSelected;
|
||||||
|
} else {
|
||||||
|
let anySelected = false;
|
||||||
|
for (
|
||||||
|
let i = 0;
|
||||||
|
i < items.value[destinationId].eventGroups[groupIndex].children.length;
|
||||||
|
i++
|
||||||
|
) {
|
||||||
|
anySelected =
|
||||||
|
anySelected ||
|
||||||
|
items.value[destinationId].eventGroups[groupIndex].children[i].selected;
|
||||||
}
|
}
|
||||||
// to trigger refresh
|
items.value[destinationId].eventGroups[groupIndex].indeterminate = anySelected;
|
||||||
state.items = { ...state.items };
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
removeDestination(destinationId: string) {
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeDestinationItemTree = (id: string) => {
|
||||||
|
delete items.value[id];
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateDestination = (destination: MessageEventBusDestinationOptions) => {
|
||||||
|
if (destination.id && items.value[destination.id]) {
|
||||||
|
items.value[destination.id].destination = destination;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeDestination = (destinationId: string) => {
|
||||||
if (!destinationId) return;
|
if (!destinationId) return;
|
||||||
delete this.items[destinationId];
|
delete items.value[destinationId];
|
||||||
if (this.items[destinationId]) {
|
};
|
||||||
this.$patch({
|
|
||||||
items: {
|
const getSelectedEvents = (destinationId: string): string[] => {
|
||||||
...this.items,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
clearDestinations() {
|
|
||||||
this.items = {};
|
|
||||||
},
|
|
||||||
addEventName(name: string) {
|
|
||||||
this.eventNames.add(name);
|
|
||||||
},
|
|
||||||
removeEventName(name: string) {
|
|
||||||
this.eventNames.delete(name);
|
|
||||||
},
|
|
||||||
clearEventNames() {
|
|
||||||
this.eventNames.clear();
|
|
||||||
},
|
|
||||||
addSelectedEvent(id: string, name: string) {
|
|
||||||
this.items[id]?.selectedEvents?.add(name);
|
|
||||||
this.setSelectedInGroup(id, name, true);
|
|
||||||
},
|
|
||||||
removeSelectedEvent(id: string, name: string) {
|
|
||||||
this.items[id]?.selectedEvents?.delete(name);
|
|
||||||
this.setSelectedInGroup(id, name, false);
|
|
||||||
},
|
|
||||||
getSelectedEvents(destinationId: string): string[] {
|
|
||||||
const selectedEvents: string[] = [];
|
const selectedEvents: string[] = [];
|
||||||
if (this.items[destinationId]) {
|
if (items.value[destinationId]) {
|
||||||
for (const group of this.items[destinationId].eventGroups) {
|
for (const group of items.value[destinationId].eventGroups) {
|
||||||
if (group.selected) {
|
if (group.selected) {
|
||||||
selectedEvents.push(group.name);
|
selectedEvents.push(group.name);
|
||||||
}
|
}
|
||||||
|
@ -117,136 +180,95 @@ export const useLogStreamingStore = defineStore('logStreaming', {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selectedEvents;
|
return selectedEvents;
|
||||||
},
|
};
|
||||||
setSelectedInGroup(destinationId: string, name: string, isSelected: boolean) {
|
|
||||||
if (this.items[destinationId]) {
|
const saveDestination = async (
|
||||||
const groupName = eventGroupFromEventName(name);
|
destination: MessageEventBusDestinationOptions,
|
||||||
const groupIndex = this.items[destinationId].eventGroups.findIndex(
|
): Promise<boolean> => {
|
||||||
(e) => e.name === groupName,
|
|
||||||
);
|
|
||||||
if (groupIndex > -1) {
|
|
||||||
if (groupName === name) {
|
|
||||||
this.$patch((state) => {
|
|
||||||
state.items[destinationId].eventGroups[groupIndex].selected = isSelected;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const eventIndex = this.items[destinationId].eventGroups[groupIndex].children.findIndex(
|
|
||||||
(e) => e.name === name,
|
|
||||||
);
|
|
||||||
if (eventIndex > -1) {
|
|
||||||
this.$patch((state) => {
|
|
||||||
state.items[destinationId].eventGroups[groupIndex].children[eventIndex].selected =
|
|
||||||
isSelected;
|
|
||||||
if (isSelected) {
|
|
||||||
state.items[destinationId].eventGroups[groupIndex].indeterminate = isSelected;
|
|
||||||
} else {
|
|
||||||
let anySelected = false;
|
|
||||||
for (
|
|
||||||
let i = 0;
|
|
||||||
i < state.items[destinationId].eventGroups[groupIndex].children.length;
|
|
||||||
i++
|
|
||||||
) {
|
|
||||||
anySelected =
|
|
||||||
anySelected ||
|
|
||||||
state.items[destinationId].eventGroups[groupIndex].children[i].selected;
|
|
||||||
}
|
|
||||||
state.items[destinationId].eventGroups[groupIndex].indeterminate = anySelected;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeDestinationItemTree(id: string) {
|
|
||||||
delete this.items[id];
|
|
||||||
},
|
|
||||||
clearDestinationItemTrees() {
|
|
||||||
this.items = {} as DestinationSettingsStore;
|
|
||||||
},
|
|
||||||
setSelectionAndBuildItems(destination: MessageEventBusDestinationOptions) {
|
|
||||||
if (destination.id) {
|
|
||||||
if (!this.items[destination.id]) {
|
|
||||||
this.items[destination.id] = {
|
|
||||||
destination,
|
|
||||||
selectedEvents: new Set<string>(),
|
|
||||||
eventGroups: [],
|
|
||||||
isNew: false,
|
|
||||||
} as DestinationStoreItem;
|
|
||||||
}
|
|
||||||
this.items[destination.id]?.selectedEvents?.clear();
|
|
||||||
if (destination.subscribedEvents) {
|
|
||||||
for (const eventName of destination.subscribedEvents) {
|
|
||||||
this.items[destination.id]?.selectedEvents?.add(eventName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.items[destination.id].eventGroups = eventGroupsFromStringList(
|
|
||||||
this.eventNames,
|
|
||||||
this.items[destination.id]?.selectedEvents,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async saveDestination(destination: MessageEventBusDestinationOptions): Promise<boolean> {
|
|
||||||
if (!hasDestinationId(destination)) {
|
if (!hasDestinationId(destination)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootStore = useRootStore();
|
const selectedEvents = getSelectedEvents(destination.id);
|
||||||
const selectedEvents = this.getSelectedEvents(destination.id);
|
|
||||||
try {
|
try {
|
||||||
await saveDestinationToDb(rootStore.restApiContext, destination, selectedEvents);
|
await saveDestinationToDb(rootStore.restApiContext, destination, selectedEvents);
|
||||||
this.updateDestination(destination);
|
updateDestination(destination);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
async sendTestMessage(destination: MessageEventBusDestinationOptions): Promise<boolean> {
|
|
||||||
|
const sendTestMessage = async (
|
||||||
|
destination: MessageEventBusDestinationOptions,
|
||||||
|
): Promise<boolean> => {
|
||||||
if (!hasDestinationId(destination)) {
|
if (!hasDestinationId(destination)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootStore = useRootStore();
|
|
||||||
const testResult = await sendTestMessageToDestination(rootStore.restApiContext, destination);
|
const testResult = await sendTestMessageToDestination(rootStore.restApiContext, destination);
|
||||||
return testResult;
|
return testResult;
|
||||||
},
|
};
|
||||||
async fetchEventNames(): Promise<string[]> {
|
|
||||||
const rootStore = useRootStore();
|
const fetchEventNames = async () => {
|
||||||
return await getEventNamesFromBackend(rootStore.restApiContext);
|
return await getEventNamesFromBackend(rootStore.restApiContext);
|
||||||
},
|
};
|
||||||
async fetchDestinations(): Promise<MessageEventBusDestinationOptions[]> {
|
|
||||||
const rootStore = useRootStore();
|
const fetchDestinations = async (): Promise<MessageEventBusDestinationOptions[]> => {
|
||||||
return await getDestinationsFromBackend(rootStore.restApiContext);
|
return await getDestinationsFromBackend(rootStore.restApiContext);
|
||||||
},
|
};
|
||||||
async deleteDestination(destinationId: string) {
|
|
||||||
const rootStore = useRootStore();
|
const deleteDestination = async (destinationId: string) => {
|
||||||
await deleteDestinationFromDb(rootStore.restApiContext, destinationId);
|
await deleteDestinationFromDb(rootStore.restApiContext, destinationId);
|
||||||
this.removeDestination(destinationId);
|
removeDestination(destinationId);
|
||||||
},
|
};
|
||||||
},
|
|
||||||
|
return {
|
||||||
|
addDestination,
|
||||||
|
setSelectionAndBuildItems,
|
||||||
|
getDestination,
|
||||||
|
getAllDestinations,
|
||||||
|
clearDestinations,
|
||||||
|
addEventName,
|
||||||
|
removeEventName,
|
||||||
|
clearEventNames,
|
||||||
|
addSelectedEvent,
|
||||||
|
removeSelectedEvent,
|
||||||
|
setSelectedInGroup,
|
||||||
|
removeDestinationItemTree,
|
||||||
|
updateDestination,
|
||||||
|
removeDestination,
|
||||||
|
getSelectedEvents,
|
||||||
|
saveDestination,
|
||||||
|
sendTestMessage,
|
||||||
|
fetchEventNames,
|
||||||
|
fetchDestinations,
|
||||||
|
deleteDestination,
|
||||||
|
items,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export function eventGroupFromEventName(eventName: string): string | undefined {
|
export const eventGroupFromEventName = (eventName: string): string | undefined => {
|
||||||
const matches = eventName.match(/^[\w\s]+\.[\w\s]+/);
|
const matches = eventName.match(/^[\w\s]+\.[\w\s]+/);
|
||||||
if (matches && matches?.length > 0) {
|
if (matches && matches?.length > 0) {
|
||||||
return matches[0];
|
return matches[0];
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
};
|
||||||
|
|
||||||
function prettifyEventName(label: string, group = ''): string {
|
const prettifyEventName = (label: string, group = ''): string => {
|
||||||
label = label.replace(group + '.', '');
|
label = label.replace(group + '.', '');
|
||||||
if (label.length > 0) {
|
if (label.length > 0) {
|
||||||
label = label[0].toUpperCase() + label.substring(1);
|
label = label[0].toUpperCase() + label.substring(1);
|
||||||
label = label.replaceAll('.', ' ');
|
label = label.replaceAll('.', ' ');
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
};
|
||||||
|
|
||||||
export function eventGroupsFromStringList(
|
export const eventGroupsFromStringList = (
|
||||||
dottedList: Set<string>,
|
dottedList: Set<string>,
|
||||||
selectionList: Set<string> = new Set(),
|
selectionList: Set<string> = new Set(),
|
||||||
) {
|
) => {
|
||||||
const result = [] as EventSelectionGroup[];
|
const result = [] as EventSelectionGroup[];
|
||||||
const eventNameArray = Array.from(dottedList.values());
|
const eventNameArray = Array.from(dottedList.values());
|
||||||
|
|
||||||
|
@ -287,4 +309,4 @@ export function eventGroupsFromStringList(
|
||||||
result.push(collection);
|
result.push(collection);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
};
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import type { IUpdateUserSettingsReqPayload, UpdateGlobalRolePayload } from '@/api/users';
|
import type {
|
||||||
|
PasswordUpdateRequestDTO,
|
||||||
|
SettingsUpdateRequestDTO,
|
||||||
|
UserUpdateRequestDTO,
|
||||||
|
} from '@n8n/api-types';
|
||||||
|
import type { UpdateGlobalRolePayload } from '@/api/users';
|
||||||
import * as usersApi from '@/api/users';
|
import * as usersApi from '@/api/users';
|
||||||
import { BROWSER_ID_STORAGE_KEY, PERSONALIZATION_MODAL_KEY, STORES, ROLE } from '@/constants';
|
import { BROWSER_ID_STORAGE_KEY, PERSONALIZATION_MODAL_KEY, STORES, ROLE } from '@/constants';
|
||||||
import type {
|
import type {
|
||||||
|
@ -226,12 +231,12 @@ export const useUsersStore = defineStore(STORES.USERS, () => {
|
||||||
await usersApi.changePassword(rootStore.restApiContext, params);
|
await usersApi.changePassword(rootStore.restApiContext, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateUser = async (params: usersApi.UpdateCurrentUserParams) => {
|
const updateUser = async (params: UserUpdateRequestDTO) => {
|
||||||
const user = await usersApi.updateCurrentUser(rootStore.restApiContext, params);
|
const user = await usersApi.updateCurrentUser(rootStore.restApiContext, params);
|
||||||
addUsers([user]);
|
addUsers([user]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateUserSettings = async (settings: IUpdateUserSettingsReqPayload) => {
|
const updateUserSettings = async (settings: SettingsUpdateRequestDTO) => {
|
||||||
const updatedSettings = await usersApi.updateCurrentUserSettings(
|
const updatedSettings = await usersApi.updateCurrentUserSettings(
|
||||||
rootStore.restApiContext,
|
rootStore.restApiContext,
|
||||||
settings,
|
settings,
|
||||||
|
@ -242,10 +247,7 @@ export const useUsersStore = defineStore(STORES.USERS, () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateOtherUserSettings = async (
|
const updateOtherUserSettings = async (userId: string, settings: SettingsUpdateRequestDTO) => {
|
||||||
userId: string,
|
|
||||||
settings: IUpdateUserSettingsReqPayload,
|
|
||||||
) => {
|
|
||||||
const updatedSettings = await usersApi.updateOtherUserSettings(
|
const updatedSettings = await usersApi.updateOtherUserSettings(
|
||||||
rootStore.restApiContext,
|
rootStore.restApiContext,
|
||||||
userId,
|
userId,
|
||||||
|
@ -255,7 +257,7 @@ export const useUsersStore = defineStore(STORES.USERS, () => {
|
||||||
addUsers([usersById.value[userId]]);
|
addUsers([usersById.value[userId]]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateCurrentUserPassword = async (params: usersApi.UpdateUserPasswordParams) => {
|
const updateCurrentUserPassword = async (params: PasswordUpdateRequestDTO) => {
|
||||||
await usersApi.updateCurrentUserPassword(rootStore.restApiContext, params);
|
await usersApi.updateCurrentUserPassword(rootStore.restApiContext, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -935,7 +935,7 @@ const workflowPermissions = computed(() => {
|
||||||
const projectPermissions = computed(() => {
|
const projectPermissions = computed(() => {
|
||||||
const project = route.query?.projectId
|
const project = route.query?.projectId
|
||||||
? projectsStore.myProjects.find((p) => p.id === route.query.projectId)
|
? projectsStore.myProjects.find((p) => p.id === route.query.projectId)
|
||||||
: projectsStore.currentProject ?? projectsStore.personalProject;
|
: (projectsStore.currentProject ?? projectsStore.personalProject);
|
||||||
return getResourcePermissions(project?.scopes);
|
return getResourcePermissions(project?.scopes);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -507,7 +507,7 @@ export default defineComponent({
|
||||||
projectPermissions() {
|
projectPermissions() {
|
||||||
const project = this.$route.query?.projectId
|
const project = this.$route.query?.projectId
|
||||||
? this.projectsStore.myProjects.find((p) => p.id === this.$route.query.projectId)
|
? this.projectsStore.myProjects.find((p) => p.id === this.$route.query.projectId)
|
||||||
: this.projectsStore.currentProject ?? this.projectsStore.personalProject;
|
: (this.projectsStore.currentProject ?? this.projectsStore.personalProject);
|
||||||
return getResourcePermissions(project?.scopes);
|
return getResourcePermissions(project?.scopes);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -95,7 +95,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
async getDestinationDataFromBackend(): Promise<void> {
|
async getDestinationDataFromBackend(): Promise<void> {
|
||||||
this.logStreamingStore.clearEventNames();
|
this.logStreamingStore.clearEventNames();
|
||||||
this.logStreamingStore.clearDestinationItemTrees();
|
this.logStreamingStore.clearDestinations();
|
||||||
this.allDestinations = [];
|
this.allDestinations = [];
|
||||||
const eventNamesData = await this.logStreamingStore.fetchEventNames();
|
const eventNamesData = await this.logStreamingStore.fetchEventNames();
|
||||||
if (eventNamesData) {
|
if (eventNamesData) {
|
||||||
|
|
|
@ -124,7 +124,7 @@ function resetNewVariablesList() {
|
||||||
const resourceToEnvironmentVariable = (data: IResource): EnvironmentVariable => ({
|
const resourceToEnvironmentVariable = (data: IResource): EnvironmentVariable => ({
|
||||||
id: data.id,
|
id: data.id,
|
||||||
key: data.name,
|
key: data.name,
|
||||||
value: 'value' in data ? data.value ?? '' : '',
|
value: 'value' in data ? (data.value ?? '') : '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const environmentVariableToResource = (data: EnvironmentVariable): IResource => ({
|
const environmentVariableToResource = (data: EnvironmentVariable): IResource => ({
|
||||||
|
|
131
pnpm-lock.yaml
131
pnpm-lock.yaml
|
@ -54,6 +54,9 @@ catalogs:
|
||||||
xml2js:
|
xml2js:
|
||||||
specifier: 0.6.2
|
specifier: 0.6.2
|
||||||
version: 0.6.2
|
version: 0.6.2
|
||||||
|
xss:
|
||||||
|
specifier: 1.0.15
|
||||||
|
version: 1.0.15
|
||||||
zod:
|
zod:
|
||||||
specifier: 3.23.8
|
specifier: 3.23.8
|
||||||
version: 3.23.8
|
version: 3.23.8
|
||||||
|
@ -88,7 +91,6 @@ overrides:
|
||||||
chokidar: 3.5.2
|
chokidar: 3.5.2
|
||||||
esbuild: ^0.20.2
|
esbuild: ^0.20.2
|
||||||
formidable: 3.5.1
|
formidable: 3.5.1
|
||||||
prettier: ^3.2.5
|
|
||||||
pug: ^3.0.3
|
pug: ^3.0.3
|
||||||
semver: ^7.5.4
|
semver: ^7.5.4
|
||||||
tslib: ^2.6.2
|
tslib: ^2.6.2
|
||||||
|
@ -231,6 +233,16 @@ importers:
|
||||||
version: link:../packages/workflow
|
version: link:../packages/workflow
|
||||||
|
|
||||||
packages/@n8n/api-types:
|
packages/@n8n/api-types:
|
||||||
|
dependencies:
|
||||||
|
xss:
|
||||||
|
specifier: 'catalog:'
|
||||||
|
version: 1.0.15
|
||||||
|
zod:
|
||||||
|
specifier: 'catalog:'
|
||||||
|
version: 3.23.8
|
||||||
|
zod-class:
|
||||||
|
specifier: 0.0.15
|
||||||
|
version: 0.0.15(zod@3.23.8)
|
||||||
devDependencies:
|
devDependencies:
|
||||||
n8n-workflow:
|
n8n-workflow:
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
|
@ -623,9 +635,6 @@ importers:
|
||||||
'@typescript-eslint/parser':
|
'@typescript-eslint/parser':
|
||||||
specifier: ^7.2.0
|
specifier: ^7.2.0
|
||||||
version: 7.2.0(eslint@8.57.0)(typescript@5.6.2)
|
version: 7.2.0(eslint@8.57.0)(typescript@5.6.2)
|
||||||
'@vue/eslint-config-prettier':
|
|
||||||
specifier: ^9.0.0
|
|
||||||
version: 9.0.0(@types/eslint@8.56.5)(eslint@8.57.0)(prettier@3.2.5)
|
|
||||||
'@vue/eslint-config-typescript':
|
'@vue/eslint-config-typescript':
|
||||||
specifier: ^13.0.0
|
specifier: ^13.0.0
|
||||||
version: 13.0.0(eslint-plugin-vue@9.23.0(eslint@8.57.0))(eslint@8.57.0)(typescript@5.6.2)
|
version: 13.0.0(eslint-plugin-vue@9.23.0(eslint@8.57.0))(eslint@8.57.0)(typescript@5.6.2)
|
||||||
|
@ -650,9 +659,6 @@ importers:
|
||||||
eslint-plugin-n8n-local-rules:
|
eslint-plugin-n8n-local-rules:
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
eslint-plugin-prettier:
|
|
||||||
specifier: ^5.1.3
|
|
||||||
version: 5.1.3(@types/eslint@8.56.5)(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.2.5)
|
|
||||||
eslint-plugin-unicorn:
|
eslint-plugin-unicorn:
|
||||||
specifier: ^51.0.1
|
specifier: ^51.0.1
|
||||||
version: 51.0.1(eslint@8.57.0)
|
version: 51.0.1(eslint@8.57.0)
|
||||||
|
@ -942,8 +948,8 @@ importers:
|
||||||
specifier: 3.0.1
|
specifier: 3.0.1
|
||||||
version: 3.0.1
|
version: 3.0.1
|
||||||
xss:
|
xss:
|
||||||
specifier: ^1.0.14
|
specifier: 'catalog:'
|
||||||
version: 1.0.14
|
version: 1.0.15
|
||||||
yamljs:
|
yamljs:
|
||||||
specifier: 0.3.0
|
specifier: 0.3.0
|
||||||
version: 0.3.0
|
version: 0.3.0
|
||||||
|
@ -1175,8 +1181,8 @@ importers:
|
||||||
specifier: ^4.2.2
|
specifier: ^4.2.2
|
||||||
version: 4.2.2(vue@3.4.21(typescript@5.6.2))
|
version: 4.2.2(vue@3.4.21(typescript@5.6.2))
|
||||||
xss:
|
xss:
|
||||||
specifier: ^1.0.14
|
specifier: 'catalog:'
|
||||||
version: 1.0.14
|
version: 1.0.15
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@n8n/storybook':
|
'@n8n/storybook':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
|
@ -1392,8 +1398,8 @@ importers:
|
||||||
specifier: ^2.1.6
|
specifier: ^2.1.6
|
||||||
version: 2.1.6(typescript@5.6.2)(vue@3.4.21(typescript@5.6.2))
|
version: 2.1.6(typescript@5.6.2)(vue@3.4.21(typescript@5.6.2))
|
||||||
prettier:
|
prettier:
|
||||||
specifier: ^3.2.5
|
specifier: ^3.3.3
|
||||||
version: 3.2.5
|
version: 3.3.3
|
||||||
qrcode.vue:
|
qrcode.vue:
|
||||||
specifier: ^3.3.4
|
specifier: ^3.3.4
|
||||||
version: 3.3.4(vue@3.4.21(typescript@5.6.2))
|
version: 3.3.4(vue@3.4.21(typescript@5.6.2))
|
||||||
|
@ -1434,8 +1440,8 @@ importers:
|
||||||
specifier: ^4.1.3
|
specifier: ^4.1.3
|
||||||
version: 4.1.3
|
version: 4.1.3
|
||||||
xss:
|
xss:
|
||||||
specifier: ^1.0.14
|
specifier: 'catalog:'
|
||||||
version: 1.0.14
|
version: 1.0.15
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@faker-js/faker':
|
'@faker-js/faker':
|
||||||
specifier: ^8.0.2
|
specifier: ^8.0.2
|
||||||
|
@ -3819,10 +3825,6 @@ packages:
|
||||||
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
|
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
|
|
||||||
'@pkgr/core@0.1.1':
|
|
||||||
resolution: {integrity: sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==}
|
|
||||||
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
|
||||||
|
|
||||||
'@protobufjs/aspromise@1.1.2':
|
'@protobufjs/aspromise@1.1.2':
|
||||||
resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}
|
resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}
|
||||||
|
|
||||||
|
@ -5435,12 +5437,6 @@ packages:
|
||||||
'@vue/devtools-api@6.5.0':
|
'@vue/devtools-api@6.5.0':
|
||||||
resolution: {integrity: sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==}
|
resolution: {integrity: sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==}
|
||||||
|
|
||||||
'@vue/eslint-config-prettier@9.0.0':
|
|
||||||
resolution: {integrity: sha512-z1ZIAAUS9pKzo/ANEfd2sO+v2IUalz7cM/cTLOZ7vRFOPk5/xuRKQteOu1DErFLAh/lYGXMVZ0IfYKlyInuDVg==}
|
|
||||||
peerDependencies:
|
|
||||||
eslint: '>= 8.0.0'
|
|
||||||
prettier: ^3.2.5
|
|
||||||
|
|
||||||
'@vue/eslint-config-typescript@13.0.0':
|
'@vue/eslint-config-typescript@13.0.0':
|
||||||
resolution: {integrity: sha512-MHh9SncG/sfqjVqjcuFLOLD6Ed4dRAis4HNt0dXASeAuLqIAx4YMB1/m2o4pUKK1vCt8fUvYG8KKX2Ot3BVZTg==}
|
resolution: {integrity: sha512-MHh9SncG/sfqjVqjcuFLOLD6Ed4dRAis4HNt0dXASeAuLqIAx4YMB1/m2o4pUKK1vCt8fUvYG8KKX2Ot3BVZTg==}
|
||||||
engines: {node: ^18.18.0 || >=20.0.0}
|
engines: {node: ^18.18.0 || >=20.0.0}
|
||||||
|
@ -7171,20 +7167,6 @@ packages:
|
||||||
resolution: {integrity: sha512-Qj8S+YgymYkt/5Fr1buwOTjl0jAERJBp3MA5V8M6NR1HYfErKazVjpOPEy5+04c0vAQZO1mPLGAzanxqqNUIng==}
|
resolution: {integrity: sha512-Qj8S+YgymYkt/5Fr1buwOTjl0jAERJBp3MA5V8M6NR1HYfErKazVjpOPEy5+04c0vAQZO1mPLGAzanxqqNUIng==}
|
||||||
engines: {node: '>=20.15', pnpm: '>=9.6'}
|
engines: {node: '>=20.15', pnpm: '>=9.6'}
|
||||||
|
|
||||||
eslint-plugin-prettier@5.1.3:
|
|
||||||
resolution: {integrity: sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==}
|
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
|
||||||
peerDependencies:
|
|
||||||
'@types/eslint': '>=8.0.0'
|
|
||||||
eslint: '>=8.0.0'
|
|
||||||
eslint-config-prettier: '*'
|
|
||||||
prettier: ^3.2.5
|
|
||||||
peerDependenciesMeta:
|
|
||||||
'@types/eslint':
|
|
||||||
optional: true
|
|
||||||
eslint-config-prettier:
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
eslint-plugin-unicorn@51.0.1:
|
eslint-plugin-unicorn@51.0.1:
|
||||||
resolution: {integrity: sha512-MuR/+9VuB0fydoI0nIn2RDA5WISRn4AsJyNSaNKLVwie9/ONvQhxOBbkfSICBPnzKrB77Fh6CZZXjgTt/4Latw==}
|
resolution: {integrity: sha512-MuR/+9VuB0fydoI0nIn2RDA5WISRn4AsJyNSaNKLVwie9/ONvQhxOBbkfSICBPnzKrB77Fh6CZZXjgTt/4Latw==}
|
||||||
engines: {node: '>=16'}
|
engines: {node: '>=16'}
|
||||||
|
@ -7388,9 +7370,6 @@ packages:
|
||||||
fast-deep-equal@3.1.3:
|
fast-deep-equal@3.1.3:
|
||||||
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
||||||
|
|
||||||
fast-diff@1.2.0:
|
|
||||||
resolution: {integrity: sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==}
|
|
||||||
|
|
||||||
fast-glob@3.2.12:
|
fast-glob@3.2.12:
|
||||||
resolution: {integrity: sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==}
|
resolution: {integrity: sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==}
|
||||||
engines: {node: '>=8.6.0'}
|
engines: {node: '>=8.6.0'}
|
||||||
|
@ -10440,12 +10419,8 @@ packages:
|
||||||
pretender@3.4.7:
|
pretender@3.4.7:
|
||||||
resolution: {integrity: sha512-jkPAvt1BfRi0RKamweJdEcnjkeu7Es8yix3bJ+KgBC5VpG/Ln4JE3hYN6vJym4qprm8Xo5adhWpm3HCoft1dOw==}
|
resolution: {integrity: sha512-jkPAvt1BfRi0RKamweJdEcnjkeu7Es8yix3bJ+KgBC5VpG/Ln4JE3hYN6vJym4qprm8Xo5adhWpm3HCoft1dOw==}
|
||||||
|
|
||||||
prettier-linter-helpers@1.0.0:
|
prettier@3.3.3:
|
||||||
resolution: {integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==}
|
resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==}
|
||||||
engines: {node: '>=6.0.0'}
|
|
||||||
|
|
||||||
prettier@3.2.5:
|
|
||||||
resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==}
|
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
@ -11516,10 +11491,6 @@ packages:
|
||||||
symbol-tree@3.2.4:
|
symbol-tree@3.2.4:
|
||||||
resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}
|
resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}
|
||||||
|
|
||||||
synckit@0.8.8:
|
|
||||||
resolution: {integrity: sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==}
|
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
|
||||||
|
|
||||||
syslog-client@1.1.1:
|
syslog-client@1.1.1:
|
||||||
resolution: {integrity: sha512-c3qKw8JzCuHt0mwrzKQr8eqOc3RB28HgOpFuwGMO3GLscVpfR+0ECevWLZq/yIJTbx3WTb3QXBFVpTFtKAPDrw==}
|
resolution: {integrity: sha512-c3qKw8JzCuHt0mwrzKQr8eqOc3RB28HgOpFuwGMO3GLscVpfR+0ECevWLZq/yIJTbx3WTb3QXBFVpTFtKAPDrw==}
|
||||||
|
|
||||||
|
@ -11889,6 +11860,10 @@ packages:
|
||||||
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
|
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
|
||||||
engines: {node: '>=12.20'}
|
engines: {node: '>=12.20'}
|
||||||
|
|
||||||
|
type-fest@4.26.1:
|
||||||
|
resolution: {integrity: sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==}
|
||||||
|
engines: {node: '>=16'}
|
||||||
|
|
||||||
type-is@1.6.18:
|
type-is@1.6.18:
|
||||||
resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==}
|
resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==}
|
||||||
engines: {node: '>= 0.6'}
|
engines: {node: '>= 0.6'}
|
||||||
|
@ -12570,8 +12545,8 @@ packages:
|
||||||
xregexp@2.0.0:
|
xregexp@2.0.0:
|
||||||
resolution: {integrity: sha512-xl/50/Cf32VsGq/1R8jJE5ajH1yMCQkpmoS10QbFZWl2Oor4H0Me64Pu2yxvsRWK3m6soJbmGfzSR7BYmDcWAA==}
|
resolution: {integrity: sha512-xl/50/Cf32VsGq/1R8jJE5ajH1yMCQkpmoS10QbFZWl2Oor4H0Me64Pu2yxvsRWK3m6soJbmGfzSR7BYmDcWAA==}
|
||||||
|
|
||||||
xss@1.0.14:
|
xss@1.0.15:
|
||||||
resolution: {integrity: sha512-og7TEJhXvn1a7kzZGQ7ETjdQVS2UfZyTlsEdDOqvQF7GoxNfY+0YLCzBy1kPdsDDx4QuNAonQPddpsn6Xl/7sw==}
|
resolution: {integrity: sha512-FVdlVVC67WOIPvfOwhoMETV72f6GbW7aOabBC3WxN/oUdoEMDyLz4OgRv5/gck2ZeNqEQu+Tb0kloovXOfpYVg==}
|
||||||
engines: {node: '>= 0.10.0'}
|
engines: {node: '>= 0.10.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
@ -12655,6 +12630,11 @@ packages:
|
||||||
engines: {node: '>=8.0.0'}
|
engines: {node: '>=8.0.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
zod-class@0.0.15:
|
||||||
|
resolution: {integrity: sha512-CD5B4e9unKPj1hiy7JOSwRV01WqbEBkFOlhws0C9s9wB0FSpECOnlKXOAkjo9tKYX2enQsXWyyOIBNPPNUHWRA==}
|
||||||
|
peerDependencies:
|
||||||
|
zod: ^3
|
||||||
|
|
||||||
zod-to-json-schema@3.23.2:
|
zod-to-json-schema@3.23.2:
|
||||||
resolution: {integrity: sha512-uSt90Gzc/tUfyNqxnjlfBs8W6WSGpNBv0rVsNxP/BVSMHMKGdthPYff4xtCHYloJGM0CFxFsb3NbC0eqPhfImw==}
|
resolution: {integrity: sha512-uSt90Gzc/tUfyNqxnjlfBs8W6WSGpNBv0rVsNxP/BVSMHMKGdthPYff4xtCHYloJGM0CFxFsb3NbC0eqPhfImw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
@ -15578,8 +15558,6 @@ snapshots:
|
||||||
'@pkgjs/parseargs@0.11.0':
|
'@pkgjs/parseargs@0.11.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@pkgr/core@0.1.1': {}
|
|
||||||
|
|
||||||
'@protobufjs/aspromise@1.1.2': {}
|
'@protobufjs/aspromise@1.1.2': {}
|
||||||
|
|
||||||
'@protobufjs/base64@1.1.2': {}
|
'@protobufjs/base64@1.1.2': {}
|
||||||
|
@ -17814,15 +17792,6 @@ snapshots:
|
||||||
|
|
||||||
'@vue/devtools-api@6.5.0': {}
|
'@vue/devtools-api@6.5.0': {}
|
||||||
|
|
||||||
'@vue/eslint-config-prettier@9.0.0(@types/eslint@8.56.5)(eslint@8.57.0)(prettier@3.2.5)':
|
|
||||||
dependencies:
|
|
||||||
eslint: 8.57.0
|
|
||||||
eslint-config-prettier: 9.1.0(eslint@8.57.0)
|
|
||||||
eslint-plugin-prettier: 5.1.3(@types/eslint@8.56.5)(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.2.5)
|
|
||||||
prettier: 3.2.5
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@types/eslint'
|
|
||||||
|
|
||||||
'@vue/eslint-config-typescript@13.0.0(eslint-plugin-vue@9.23.0(eslint@8.57.0))(eslint@8.57.0)(typescript@5.6.2)':
|
'@vue/eslint-config-typescript@13.0.0(eslint-plugin-vue@9.23.0(eslint@8.57.0))(eslint@8.57.0)(typescript@5.6.2)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/eslint-plugin': 7.2.0(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0)(typescript@5.6.2)
|
'@typescript-eslint/eslint-plugin': 7.2.0(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0)(typescript@5.6.2)
|
||||||
|
@ -19909,16 +19878,6 @@ snapshots:
|
||||||
- supports-color
|
- supports-color
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
eslint-plugin-prettier@5.1.3(@types/eslint@8.56.5)(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.2.5):
|
|
||||||
dependencies:
|
|
||||||
eslint: 8.57.0
|
|
||||||
prettier: 3.2.5
|
|
||||||
prettier-linter-helpers: 1.0.0
|
|
||||||
synckit: 0.8.8
|
|
||||||
optionalDependencies:
|
|
||||||
'@types/eslint': 8.56.5
|
|
||||||
eslint-config-prettier: 9.1.0(eslint@8.57.0)
|
|
||||||
|
|
||||||
eslint-plugin-unicorn@51.0.1(eslint@8.57.0):
|
eslint-plugin-unicorn@51.0.1(eslint@8.57.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/helper-validator-identifier': 7.22.20
|
'@babel/helper-validator-identifier': 7.22.20
|
||||||
|
@ -20233,8 +20192,6 @@ snapshots:
|
||||||
|
|
||||||
fast-deep-equal@3.1.3: {}
|
fast-deep-equal@3.1.3: {}
|
||||||
|
|
||||||
fast-diff@1.2.0: {}
|
|
||||||
|
|
||||||
fast-glob@3.2.12:
|
fast-glob@3.2.12:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@nodelib/fs.stat': 2.0.5
|
'@nodelib/fs.stat': 2.0.5
|
||||||
|
@ -23882,11 +23839,7 @@ snapshots:
|
||||||
fake-xml-http-request: 2.1.2
|
fake-xml-http-request: 2.1.2
|
||||||
route-recognizer: 0.3.4
|
route-recognizer: 0.3.4
|
||||||
|
|
||||||
prettier-linter-helpers@1.0.0:
|
prettier@3.3.3: {}
|
||||||
dependencies:
|
|
||||||
fast-diff: 1.2.0
|
|
||||||
|
|
||||||
prettier@3.2.5: {}
|
|
||||||
|
|
||||||
pretty-bytes@5.6.0: {}
|
pretty-bytes@5.6.0: {}
|
||||||
|
|
||||||
|
@ -25252,11 +25205,6 @@ snapshots:
|
||||||
|
|
||||||
symbol-tree@3.2.4: {}
|
symbol-tree@3.2.4: {}
|
||||||
|
|
||||||
synckit@0.8.8:
|
|
||||||
dependencies:
|
|
||||||
'@pkgr/core': 0.1.1
|
|
||||||
tslib: 2.6.2
|
|
||||||
|
|
||||||
syslog-client@1.1.1: {}
|
syslog-client@1.1.1: {}
|
||||||
|
|
||||||
tailwindcss@3.4.3(ts-node@10.9.2(@types/node@18.16.16)(typescript@5.6.2)):
|
tailwindcss@3.4.3(ts-node@10.9.2(@types/node@18.16.16)(typescript@5.6.2)):
|
||||||
|
@ -25630,6 +25578,8 @@ snapshots:
|
||||||
|
|
||||||
type-fest@2.19.0: {}
|
type-fest@2.19.0: {}
|
||||||
|
|
||||||
|
type-fest@4.26.1: {}
|
||||||
|
|
||||||
type-is@1.6.18:
|
type-is@1.6.18:
|
||||||
dependencies:
|
dependencies:
|
||||||
media-typer: 0.3.0
|
media-typer: 0.3.0
|
||||||
|
@ -26357,7 +26307,7 @@ snapshots:
|
||||||
|
|
||||||
xregexp@2.0.0: {}
|
xregexp@2.0.0: {}
|
||||||
|
|
||||||
xss@1.0.14:
|
xss@1.0.15:
|
||||||
dependencies:
|
dependencies:
|
||||||
commander: 2.20.3
|
commander: 2.20.3
|
||||||
cssfilter: 0.0.10
|
cssfilter: 0.0.10
|
||||||
|
@ -26457,6 +26407,11 @@ snapshots:
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
commander: 9.4.1
|
commander: 9.4.1
|
||||||
|
|
||||||
|
zod-class@0.0.15(zod@3.23.8):
|
||||||
|
dependencies:
|
||||||
|
type-fest: 4.26.1
|
||||||
|
zod: 3.23.8
|
||||||
|
|
||||||
zod-to-json-schema@3.23.2(zod@3.23.8):
|
zod-to-json-schema@3.23.2(zod@3.23.8):
|
||||||
dependencies:
|
dependencies:
|
||||||
zod: 3.23.8
|
zod: 3.23.8
|
||||||
|
|
|
@ -20,6 +20,7 @@ catalog:
|
||||||
typedi: 0.10.0
|
typedi: 0.10.0
|
||||||
uuid: 10.0.0
|
uuid: 10.0.0
|
||||||
xml2js: 0.6.2
|
xml2js: 0.6.2
|
||||||
|
xss: 1.0.15
|
||||||
zod: 3.23.8
|
zod: 3.23.8
|
||||||
'@langchain/core': 0.2.31
|
'@langchain/core': 0.2.31
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue