mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
refactor(core): Move interrelated entities to @n8n/db (#15050)
This commit is contained in:
@@ -23,11 +23,14 @@
|
||||
"dependencies": {
|
||||
"@n8n/config": "workspace:^",
|
||||
"@n8n/di": "workspace:^",
|
||||
"@n8n/permissions": "workspace:^",
|
||||
"@n8n/typeorm": "catalog:",
|
||||
"class-validator": "0.14.0",
|
||||
"n8n-core": "workspace:^",
|
||||
"n8n-workflow": "workspace:^",
|
||||
"nanoid": "catalog:",
|
||||
"reflect-metadata": "catalog:"
|
||||
"reflect-metadata": "catalog:",
|
||||
"xss": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@n8n/typescript-config": "workspace:*"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { JsonColumn, WithTimestampsAndStringId } from '@n8n/db';
|
||||
import type { ApiKeyScope } from '@n8n/permissions';
|
||||
import { Column, Entity, Index, ManyToOne, Unique } from '@n8n/typeorm';
|
||||
|
||||
import { JsonColumn, WithTimestampsAndStringId } from './abstract-entity';
|
||||
import { User } from './user';
|
||||
|
||||
@Entity('user_api_keys')
|
||||
@@ -1,10 +1,9 @@
|
||||
import { WithTimestamps } from '@n8n/db';
|
||||
import { Column, Entity, ManyToOne, PrimaryColumn, Unique } from '@n8n/typeorm';
|
||||
|
||||
import { WithTimestamps } from './abstract-entity';
|
||||
import { AuthProviderType } from './types-db';
|
||||
import { User } from './user';
|
||||
|
||||
export type AuthProviderType = 'ldap' | 'email' | 'saml'; // | 'google';
|
||||
|
||||
@Entity()
|
||||
@Unique(['providerId', 'providerType'])
|
||||
export class AuthIdentity extends WithTimestamps {
|
||||
@@ -1,10 +1,9 @@
|
||||
import { WithTimestampsAndStringId } from '@n8n/db';
|
||||
import { Column, Entity, Index, OneToMany } from '@n8n/typeorm';
|
||||
import { IsObject, IsString, Length } from 'class-validator';
|
||||
|
||||
import type { ICredentialsDb } from '@/types-db';
|
||||
|
||||
import { WithTimestampsAndStringId } from './abstract-entity';
|
||||
import type { SharedCredentials } from './shared-credentials';
|
||||
import type { ICredentialsDb } from './types-db';
|
||||
|
||||
@Entity()
|
||||
export class CredentialsEntity extends WithTimestampsAndStringId implements ICredentialsDb {
|
||||
@@ -1,4 +1,3 @@
|
||||
import { WithTimestampsAndStringId } from '@n8n/db';
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
@@ -9,14 +8,10 @@ import {
|
||||
OneToMany,
|
||||
} from '@n8n/typeorm';
|
||||
|
||||
import { WithTimestampsAndStringId } from './abstract-entity';
|
||||
import { Project } from './project';
|
||||
import { TagEntity } from './tag-entity';
|
||||
import { type WorkflowEntity } from './workflow-entity';
|
||||
|
||||
export type FolderWithWorkflowAndSubFolderCount = Folder & {
|
||||
workflowCount: boolean;
|
||||
subFolderCount: number;
|
||||
};
|
||||
import type { WorkflowEntity } from './workflow-entity';
|
||||
|
||||
@Entity()
|
||||
export class Folder extends WithTimestampsAndStringId {
|
||||
@@ -1,11 +1,25 @@
|
||||
import { ApiKey } from './api-key';
|
||||
import { AuthIdentity } from './auth-identity';
|
||||
import { CredentialsEntity } from './credentials-entity';
|
||||
import { EventDestinations } from './event-destinations';
|
||||
import { Folder } from './folder';
|
||||
import { FolderTagMapping } from './folder-tag-mapping';
|
||||
import { InstalledNodes } from './installed-nodes';
|
||||
import { InstalledPackages } from './installed-packages';
|
||||
import { InvalidAuthToken } from './invalid-auth-token';
|
||||
import { ProcessedData } from './processed-data';
|
||||
import { Project } from './project';
|
||||
import { ProjectRelation } from './project-relation';
|
||||
import { Settings } from './settings';
|
||||
import { SharedCredentials } from './shared-credentials';
|
||||
import { SharedWorkflow } from './shared-workflow';
|
||||
import { TagEntity } from './tag-entity';
|
||||
import { User } from './user';
|
||||
import { Variables } from './variables';
|
||||
import { WebhookEntity } from './webhook-entity';
|
||||
import { WorkflowEntity } from './workflow-entity';
|
||||
import { WorkflowStatistics } from './workflow-statistics';
|
||||
import { WorkflowTagMapping } from './workflow-tag-mapping';
|
||||
|
||||
export {
|
||||
EventDestinations,
|
||||
@@ -15,5 +29,19 @@ export {
|
||||
ProcessedData,
|
||||
Settings,
|
||||
Variables,
|
||||
ApiKey,
|
||||
WebhookEntity,
|
||||
AuthIdentity,
|
||||
CredentialsEntity,
|
||||
Folder,
|
||||
Project,
|
||||
ProjectRelation,
|
||||
SharedCredentials,
|
||||
SharedWorkflow,
|
||||
TagEntity,
|
||||
User,
|
||||
WorkflowEntity,
|
||||
WorkflowStatistics,
|
||||
WorkflowTagMapping,
|
||||
FolderTagMapping,
|
||||
};
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { ProjectRole } from '@n8n/api-types';
|
||||
import { WithTimestamps } from '@n8n/db';
|
||||
import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm';
|
||||
|
||||
import { WithTimestamps } from './abstract-entity';
|
||||
import { Project } from './project';
|
||||
import { User } from './user';
|
||||
|
||||
@Entity()
|
||||
export class ProjectRelation extends WithTimestamps {
|
||||
@Column({ type: 'varchar' })
|
||||
role: ProjectRole;
|
||||
role: 'project:personalOwner' | 'project:admin' | 'project:editor' | 'project:viewer';
|
||||
|
||||
@ManyToOne('User', 'projectRelations')
|
||||
user: User;
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ProjectIcon, ProjectType } from '@n8n/api-types';
|
||||
import { WithTimestampsAndStringId } from '@n8n/db';
|
||||
import { Column, Entity, OneToMany } from '@n8n/typeorm';
|
||||
|
||||
import { WithTimestampsAndStringId } from './abstract-entity';
|
||||
import type { ProjectRelation } from './project-relation';
|
||||
import type { SharedCredentials } from './shared-credentials';
|
||||
import type { SharedWorkflow } from './shared-workflow';
|
||||
@@ -12,10 +11,10 @@ export class Project extends WithTimestampsAndStringId {
|
||||
name: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 36 })
|
||||
type: ProjectType;
|
||||
type: 'personal' | 'team';
|
||||
|
||||
@Column({ type: 'json', nullable: true })
|
||||
icon: ProjectIcon;
|
||||
icon: { type: 'emoji' | 'icon'; value: string } | null;
|
||||
|
||||
@OneToMany('ProjectRelation', 'project')
|
||||
projectRelations: ProjectRelation[];
|
||||
@@ -1,10 +1,9 @@
|
||||
import { WithTimestamps } from '@n8n/db';
|
||||
import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm';
|
||||
|
||||
import { WithTimestamps } from './abstract-entity';
|
||||
import { CredentialsEntity } from './credentials-entity';
|
||||
import { Project } from './project';
|
||||
|
||||
export type CredentialSharingRole = 'credential:owner' | 'credential:user';
|
||||
import { CredentialSharingRole } from './types-db';
|
||||
|
||||
@Entity()
|
||||
export class SharedCredentials extends WithTimestamps {
|
||||
@@ -1,11 +1,10 @@
|
||||
import { WithTimestamps } from '@n8n/db';
|
||||
import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm';
|
||||
|
||||
import { WithTimestamps } from './abstract-entity';
|
||||
import { Project } from './project';
|
||||
import { WorkflowSharingRole } from './types-db';
|
||||
import { WorkflowEntity } from './workflow-entity';
|
||||
|
||||
export type WorkflowSharingRole = 'workflow:owner' | 'workflow:editor';
|
||||
|
||||
@Entity()
|
||||
export class SharedWorkflow extends WithTimestamps {
|
||||
@Column()
|
||||
@@ -1,7 +1,7 @@
|
||||
import { WithTimestampsAndStringId } from '@n8n/db';
|
||||
import { Column, Entity, Index, ManyToMany, OneToMany } from '@n8n/typeorm';
|
||||
import { IsString, Length } from 'class-validator';
|
||||
|
||||
import { WithTimestampsAndStringId } from './abstract-entity';
|
||||
import type { FolderTagMapping } from './folder-tag-mapping';
|
||||
import type { WorkflowEntity } from './workflow-entity';
|
||||
import type { WorkflowTagMapping } from './workflow-tag-mapping';
|
||||
@@ -12,15 +12,14 @@ import type {
|
||||
IUser,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { AuthProviderType } from '@/databases/entities/auth-identity';
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import type { Folder } from '@/databases/entities/folder';
|
||||
import type { Project } from '@/databases/entities/project';
|
||||
import type { SharedCredentials } from '@/databases/entities/shared-credentials';
|
||||
import type { SharedWorkflow } from '@/databases/entities/shared-workflow';
|
||||
import type { TagEntity } from '@/databases/entities/tag-entity';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import type { CredentialsEntity } from './credentials-entity';
|
||||
import type { Folder } from './folder';
|
||||
import type { Project } from './project';
|
||||
import type { SharedCredentials } from './shared-credentials';
|
||||
import type { SharedWorkflow } from './shared-workflow';
|
||||
import type { TagEntity } from './tag-entity';
|
||||
import type { User } from './user';
|
||||
import type { WorkflowEntity } from './workflow-entity';
|
||||
|
||||
export type UsageCount = {
|
||||
usageCount: number;
|
||||
@@ -260,3 +259,22 @@ export namespace ListQueryDb {
|
||||
type SlimUser = Pick<IUser, 'id' | 'email' | 'firstName' | 'lastName'>;
|
||||
|
||||
export type ScopesField = { scopes: Scope[] };
|
||||
|
||||
export const enum StatisticsNames {
|
||||
productionSuccess = 'production_success',
|
||||
productionError = 'production_error',
|
||||
manualSuccess = 'manual_success',
|
||||
manualError = 'manual_error',
|
||||
dataLoaded = 'data_loaded',
|
||||
}
|
||||
|
||||
export type CredentialSharingRole = 'credential:owner' | 'credential:user';
|
||||
|
||||
export type WorkflowSharingRole = 'workflow:owner' | 'workflow:editor';
|
||||
|
||||
export type AuthProviderType = 'ldap' | 'email' | 'saml'; // | 'google';
|
||||
|
||||
export type FolderWithWorkflowAndSubFolderCount = Folder & {
|
||||
workflowCount: boolean;
|
||||
subFolderCount: number;
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { JsonColumn, WithTimestamps, objectRetriever, lowerCaser } from '@n8n/db';
|
||||
import { hasScope, type ScopeOptions, type Scope, GlobalRole } from '@n8n/permissions';
|
||||
import { GLOBAL_OWNER_SCOPES, GLOBAL_MEMBER_SCOPES, GLOBAL_ADMIN_SCOPES } from '@n8n/permissions';
|
||||
import {
|
||||
AfterLoad,
|
||||
AfterUpdate,
|
||||
@@ -14,20 +14,16 @@ import {
|
||||
import { IsEmail, IsString, Length } from 'class-validator';
|
||||
import type { IUser, IUserSettings } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
GLOBAL_OWNER_SCOPES,
|
||||
GLOBAL_MEMBER_SCOPES,
|
||||
GLOBAL_ADMIN_SCOPES,
|
||||
} from '@/permissions.ee/global-roles';
|
||||
import type { IPersonalizationSurveyAnswers } from '@/types-db';
|
||||
import { NoUrl } from '@/validators/no-url.validator';
|
||||
import { NoXss } from '@/validators/no-xss.validator';
|
||||
|
||||
import { JsonColumn, WithTimestamps } from './abstract-entity';
|
||||
import type { ApiKey } from './api-key';
|
||||
import type { AuthIdentity } from './auth-identity';
|
||||
import type { ProjectRelation } from './project-relation';
|
||||
import type { SharedCredentials } from './shared-credentials';
|
||||
import type { SharedWorkflow } from './shared-workflow';
|
||||
import type { IPersonalizationSurveyAnswers } from './types-db';
|
||||
import { lowerCaser, objectRetriever } from '../utils/transformers';
|
||||
import { NoUrl } from '../utils/validators/no-url.validator';
|
||||
import { NoXss } from '../utils/validators/no-xss.validator';
|
||||
|
||||
const STATIC_SCOPE_MAP: Record<GlobalRole, Scope[]> = {
|
||||
'global:owner': GLOBAL_OWNER_SCOPES,
|
||||
@@ -1,4 +1,3 @@
|
||||
import { JsonColumn, WithTimestampsAndStringId, dbType, objectRetriever, sqlite } from '@n8n/db';
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
@@ -13,13 +12,14 @@ import { Length } from 'class-validator';
|
||||
import { IConnections, IDataObject, IWorkflowSettings, WorkflowFEMeta } from 'n8n-workflow';
|
||||
import type { IBinaryKeyData, INode, IPairedItemData } from 'n8n-workflow';
|
||||
|
||||
import type { IWorkflowDb } from '@/types-db';
|
||||
|
||||
import { JsonColumn, WithTimestampsAndStringId, dbType } from './abstract-entity';
|
||||
import { type Folder } from './folder';
|
||||
import type { SharedWorkflow } from './shared-workflow';
|
||||
import type { TagEntity } from './tag-entity';
|
||||
import type { IWorkflowDb } from './types-db';
|
||||
import type { WorkflowStatistics } from './workflow-statistics';
|
||||
import type { WorkflowTagMapping } from './workflow-tag-mapping';
|
||||
import { objectRetriever, sqlite } from '../utils/transformers';
|
||||
|
||||
@Entity()
|
||||
export class WorkflowEntity extends WithTimestampsAndStringId implements IWorkflowDb {
|
||||
@@ -1,16 +1,9 @@
|
||||
import { DateTimeColumn } from '@n8n/db';
|
||||
import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm';
|
||||
|
||||
import { DateTimeColumn } from './abstract-entity';
|
||||
import { StatisticsNames } from './types-db';
|
||||
import { WorkflowEntity } from './workflow-entity';
|
||||
|
||||
export const enum StatisticsNames {
|
||||
productionSuccess = 'production_success',
|
||||
productionError = 'production_error',
|
||||
manualSuccess = 'manual_success',
|
||||
manualError = 'manual_error',
|
||||
dataLoaded = 'data_loaded',
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class WorkflowStatistics {
|
||||
@Column()
|
||||
@@ -14,13 +14,5 @@ export { isStringArray } from './utils/is-string-array';
|
||||
export { separate } from './utils/separate';
|
||||
export { idStringifier, lowerCaser, objectRetriever, sqlite } from './utils/transformers';
|
||||
|
||||
export {
|
||||
EventDestinations,
|
||||
InstalledNodes,
|
||||
InstalledPackages,
|
||||
InvalidAuthToken,
|
||||
ProcessedData,
|
||||
Settings,
|
||||
Variables,
|
||||
WebhookEntity,
|
||||
} from './entities';
|
||||
export * from './entities';
|
||||
export * from './entities/types-db';
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { validate } from 'class-validator';
|
||||
|
||||
import { NoUrl } from '../no-url.validator';
|
||||
|
||||
describe('NoUrl', () => {
|
||||
class Entity {
|
||||
@NoUrl()
|
||||
name = '';
|
||||
}
|
||||
|
||||
const entity = new Entity();
|
||||
|
||||
describe('URLs', () => {
|
||||
const URLS = ['http://google.com', 'www.domain.tld', 'n8n.io'];
|
||||
|
||||
for (const str of URLS) {
|
||||
test(`should block ${str}`, async () => {
|
||||
entity.name = str;
|
||||
const errors = await validate(entity);
|
||||
expect(errors).toHaveLength(1);
|
||||
const [error] = errors;
|
||||
expect(error.property).toEqual('name');
|
||||
expect(error.constraints).toEqual({ NoUrl: 'Potentially malicious string' });
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
import { validate } from 'class-validator';
|
||||
|
||||
import { NoXss } from '../no-xss.validator';
|
||||
|
||||
describe('NoXss', () => {
|
||||
class Entity {
|
||||
@NoXss()
|
||||
name = '';
|
||||
|
||||
@NoXss()
|
||||
timestamp = '';
|
||||
|
||||
@NoXss()
|
||||
version = '';
|
||||
|
||||
@NoXss({ each: true })
|
||||
categories: string[] = [];
|
||||
}
|
||||
|
||||
const entity = new Entity();
|
||||
|
||||
describe('Scripts', () => {
|
||||
// eslint-disable-next-line n8n-local-rules/no-unneeded-backticks
|
||||
const XSS_STRINGS = ['<script src/>', "<script>alert('xss')</script>", `<a href="#">Jack</a>`];
|
||||
|
||||
for (const str of XSS_STRINGS) {
|
||||
test(`should block ${str}`, async () => {
|
||||
entity.name = str;
|
||||
const errors = await validate(entity);
|
||||
expect(errors).toHaveLength(1);
|
||||
const [error] = errors;
|
||||
expect(error.property).toEqual('name');
|
||||
expect(error.constraints).toEqual({ NoXss: 'Potentially malicious string' });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('Names', () => {
|
||||
const VALID_NAMES = [
|
||||
'Johann Strauß',
|
||||
'Вагиф Сәмәдоғлу',
|
||||
'René Magritte',
|
||||
'সুকুমার রায়',
|
||||
'མགོན་པོ་རྡོ་རྗེ།',
|
||||
'عبدالحليم حافظ',
|
||||
];
|
||||
|
||||
for (const name of VALID_NAMES) {
|
||||
test(`should allow ${name}`, async () => {
|
||||
entity.name = name;
|
||||
await expect(validate(entity)).resolves.toHaveLength(0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('ISO-8601 timestamps', () => {
|
||||
const VALID_TIMESTAMPS = ['2022-01-01T00:00:00.000Z', '2022-01-01T00:00:00.000+02:00'];
|
||||
|
||||
for (const timestamp of VALID_TIMESTAMPS) {
|
||||
test(`should allow ${timestamp}`, async () => {
|
||||
entity.timestamp = timestamp;
|
||||
await expect(validate(entity)).resolves.toHaveLength(0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('Semver versions', () => {
|
||||
const VALID_VERSIONS = ['1.0.0', '1.0.0-alpha.1'];
|
||||
|
||||
for (const version of VALID_VERSIONS) {
|
||||
test(`should allow ${version}`, async () => {
|
||||
entity.version = version;
|
||||
await expect(validate(entity)).resolves.toHaveLength(0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('Miscellaneous strings', () => {
|
||||
const VALID_MISCELLANEOUS_STRINGS = ['CI/CD'];
|
||||
|
||||
for (const str of VALID_MISCELLANEOUS_STRINGS) {
|
||||
test(`should allow ${str}`, async () => {
|
||||
entity.name = str;
|
||||
await expect(validate(entity)).resolves.toHaveLength(0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('Array of strings', () => {
|
||||
const VALID_STRING_ARRAYS = [
|
||||
['cloud-infrastructure-orchestration', 'ci-cd', 'reporting'],
|
||||
['automationGoalDevops', 'cloudComputing', 'containerization'],
|
||||
];
|
||||
|
||||
for (const arr of VALID_STRING_ARRAYS) {
|
||||
test(`should allow array: ${JSON.stringify(arr)}`, async () => {
|
||||
entity.categories = arr;
|
||||
await expect(validate(entity)).resolves.toHaveLength(0);
|
||||
});
|
||||
}
|
||||
|
||||
const INVALID_STRING_ARRAYS = [
|
||||
['valid-string', '<script>alert("xss")</script>', 'another-valid-string'],
|
||||
['<img src="x" onerror="alert(\'XSS\')">', 'valid-string'],
|
||||
];
|
||||
|
||||
for (const arr of INVALID_STRING_ARRAYS) {
|
||||
test(`should reject array containing invalid string: ${JSON.stringify(arr)}`, async () => {
|
||||
entity.categories = arr;
|
||||
const errors = await validate(entity);
|
||||
expect(errors).toHaveLength(1);
|
||||
const [error] = errors;
|
||||
expect(error.property).toEqual('categories');
|
||||
expect(error.constraints).toEqual({ NoXss: 'Potentially malicious string' });
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
27
packages/@n8n/db/src/utils/validators/no-url.validator.ts
Normal file
27
packages/@n8n/db/src/utils/validators/no-url.validator.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
|
||||
import { registerDecorator, ValidatorConstraint } from 'class-validator';
|
||||
|
||||
const URL_REGEX = /^(https?:\/\/|www\.)|(\.[\p{L}\d-]+)/iu;
|
||||
|
||||
@ValidatorConstraint({ name: 'NoUrl', async: false })
|
||||
class NoUrlConstraint implements ValidatorConstraintInterface {
|
||||
validate(value: string) {
|
||||
return !URL_REGEX.test(value);
|
||||
}
|
||||
|
||||
defaultMessage() {
|
||||
return 'Potentially malicious string';
|
||||
}
|
||||
}
|
||||
|
||||
export function NoUrl(options?: ValidationOptions) {
|
||||
return function (object: object, propertyName: string) {
|
||||
registerDecorator({
|
||||
name: 'NoUrl',
|
||||
target: object.constructor,
|
||||
propertyName,
|
||||
options,
|
||||
validator: NoUrlConstraint,
|
||||
});
|
||||
};
|
||||
}
|
||||
33
packages/@n8n/db/src/utils/validators/no-xss.validator.ts
Normal file
33
packages/@n8n/db/src/utils/validators/no-xss.validator.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
|
||||
import { registerDecorator, ValidatorConstraint } from 'class-validator';
|
||||
import xss from 'xss';
|
||||
|
||||
@ValidatorConstraint({ name: 'NoXss', async: false })
|
||||
class NoXssConstraint implements ValidatorConstraintInterface {
|
||||
validate(value: unknown) {
|
||||
if (typeof value !== 'string') return false;
|
||||
|
||||
return (
|
||||
value ===
|
||||
xss(value, {
|
||||
whiteList: {}, // no tags are allowed
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
defaultMessage() {
|
||||
return 'Potentially malicious string';
|
||||
}
|
||||
}
|
||||
|
||||
export function NoXss(options?: ValidationOptions) {
|
||||
return function (object: object, propertyName: string) {
|
||||
registerDecorator({
|
||||
name: 'NoXss',
|
||||
target: object.constructor,
|
||||
propertyName,
|
||||
options,
|
||||
validator: NoXssConstraint,
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
import type { Scope } from './types.ee';
|
||||
|
||||
export const GLOBAL_OWNER_SCOPES: Scope[] = [
|
||||
'annotationTag:create',
|
||||
@@ -2,3 +2,6 @@ export type * from './types.ee';
|
||||
export * from './constants.ee';
|
||||
export * from './hasScope.ee';
|
||||
export * from './combineScopes.ee';
|
||||
export * from './global-roles.ee';
|
||||
export * from './project-roles.ee';
|
||||
export * from './resource-roles.ee';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
import type { Scope } from './types.ee';
|
||||
|
||||
/**
|
||||
* Diff between admin in personal project and admin in other projects:
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
import type { Scope } from './types.ee';
|
||||
|
||||
export const CREDENTIALS_SHARING_OWNER_SCOPES: Scope[] = [
|
||||
'credential:read',
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { WorkflowEntity } from '@n8n/db';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { InstanceSettings } from 'n8n-core';
|
||||
import type {
|
||||
@@ -10,7 +11,6 @@ import type {
|
||||
import { Workflow } from 'n8n-workflow';
|
||||
|
||||
import { ActiveWorkflowManager } from '@/active-workflow-manager';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import type { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
||||
import type { NodeTypes } from '@/node-types';
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import type { Project } from '@n8n/db';
|
||||
import { nanoId, date, firstName, lastName, email } from 'minifaker';
|
||||
import 'minifaker/locales/en';
|
||||
|
||||
import type { Project } from '@/databases/entities/project';
|
||||
|
||||
type RawProjectData = Pick<Project, 'name' | 'type' | 'createdAt' | 'updatedAt' | 'id'>;
|
||||
|
||||
const projectName = `${firstName()} ${lastName()} <${email}>`;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { Project } from '@n8n/db';
|
||||
import type { IExecutionResponse } from '@n8n/db';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { InstanceSettings } from 'n8n-core';
|
||||
import type { IRun, IWorkflowBase } from 'n8n-workflow';
|
||||
import { createDeferredPromise } from 'n8n-workflow';
|
||||
|
||||
import type { ActiveExecutions } from '@/active-executions';
|
||||
import type { Project } from '@/databases/entities/project';
|
||||
import type { ExecutionRepository } from '@/databases/repositories/execution.repository';
|
||||
import type { MultiMainSetup } from '@/scaling/multi-main-setup.ee';
|
||||
import type { OwnershipService } from '@/services/ownership.service';
|
||||
import type { IExecutionResponse } from '@/types-db';
|
||||
import { WaitTracker } from '@/wait-tracker';
|
||||
import type { WorkflowRunner } from '@/workflow-runner';
|
||||
import { mockLogger } from '@test/mocking';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import type { WorkflowEntity } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { IWorkflowBase } from 'n8n-workflow';
|
||||
@@ -13,7 +14,6 @@ import type PCancelable from 'p-cancelable';
|
||||
|
||||
import { ActiveExecutions } from '@/active-executions';
|
||||
import { CredentialsHelper } from '@/credentials-helper';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
|
||||
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
||||
import { VariablesService } from '@/environments.ee/variables/variables.service.ee';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { DirectedGraph, WorkflowExecute } from 'n8n-core';
|
||||
@@ -20,7 +21,6 @@ import PCancelable from 'p-cancelable';
|
||||
import { ActiveExecutions } from '@/active-executions';
|
||||
import config from '@/config';
|
||||
import type { ExecutionEntity } from '@/databases/entities/execution-entity';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { ExecutionNotFoundError } from '@/errors/execution-not-found-error';
|
||||
import { CredentialsPermissionChecker } from '@/executions/pre-execution-checks';
|
||||
import { ManualExecutionService } from '@/manual-execution.service';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { CreateExecutionPayload, IExecutionDb } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { Logger } from 'n8n-core';
|
||||
import type {
|
||||
@@ -18,7 +19,6 @@ import { isWorkflowIdValid } from '@/utils';
|
||||
|
||||
import { ConcurrencyControlService } from './concurrency/concurrency-control.service';
|
||||
import config from './config';
|
||||
import type { CreateExecutionPayload, IExecutionDb } from './types-db';
|
||||
|
||||
@Service()
|
||||
export class ActiveExecutions {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
import { WorkflowsConfig } from '@n8n/config';
|
||||
import type { WorkflowEntity, IWorkflowDb } from '@n8n/db';
|
||||
import { OnLeaderStepdown, OnLeaderTakeover, OnShutdown } from '@n8n/decorators';
|
||||
import { Service } from '@n8n/di';
|
||||
import { chunk } from 'lodash';
|
||||
@@ -41,7 +42,6 @@ import {
|
||||
WORKFLOW_REACTIVATE_INITIAL_TIMEOUT,
|
||||
WORKFLOW_REACTIVATE_MAX_TIMEOUT,
|
||||
} from '@/constants';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
||||
import { executeErrorWorkflow } from '@/execution-lifecycle/execute-error-workflow';
|
||||
import { ExecutionService } from '@/executions/execution.service';
|
||||
@@ -50,7 +50,6 @@ import { NodeTypes } from '@/node-types';
|
||||
import { Publisher } from '@/scaling/pubsub/publisher.service';
|
||||
import { ActiveWorkflowsService } from '@/services/active-workflows.service';
|
||||
import { OrchestrationService } from '@/services/orchestration.service';
|
||||
import type { IWorkflowDb } from '@/types-db';
|
||||
import * as WebhookHelpers from '@/webhooks/webhook-helpers';
|
||||
import { WebhookService } from '@/webhooks/webhook.service';
|
||||
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { GlobalConfig } from '@n8n/config';
|
||||
import type { User } from '@n8n/db';
|
||||
import type { NextFunction, Response } from 'express';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import jwt from 'jsonwebtoken';
|
||||
@@ -6,7 +7,6 @@ import jwt from 'jsonwebtoken';
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import config from '@/config';
|
||||
import { AUTH_COOKIE_NAME, Time } from '@/constants';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import type { InvalidAuthTokenRepository } from '@/databases/repositories/invalid-auth-token.repository';
|
||||
import type { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import type { AuthenticatedRequest } from '@/requests';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import type { User } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { createHash } from 'crypto';
|
||||
import type { NextFunction, Response } from 'express';
|
||||
@@ -7,7 +8,6 @@ import { Logger } from 'n8n-core';
|
||||
|
||||
import config from '@/config';
|
||||
import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES, Time } from '@/constants';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { InvalidAuthTokenRepository } from '@/databases/repositories/invalid-auth-token.repository';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import { AuthError } from '@/errors/response-errors/auth.error';
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import type { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import type { Response } from 'express';
|
||||
|
||||
import type { User } from '@/databases/entities/user';
|
||||
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
// This method is still used by cloud hooks.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import { AuthError } from '@/errors/response-errors/auth.error';
|
||||
import { EventService } from '@/events/event.service';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { EventService } from '@/events/event.service';
|
||||
import {
|
||||
createLdapUserOnLocalDb,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { PushPayload } from '@n8n/api-types';
|
||||
import type { User } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { ErrorReporter } from 'n8n-core';
|
||||
import type { Workflow } from 'n8n-workflow';
|
||||
import { UnexpectedError } from 'n8n-workflow';
|
||||
|
||||
import { CollaborationState } from '@/collaboration/collaboration.state';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import { Push } from '@/push';
|
||||
import type { OnPushMessage } from '@/push/types';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { Iso8601DateTimeString } from '@n8n/api-types';
|
||||
import type { User } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { Workflow } from 'n8n-workflow';
|
||||
|
||||
import { Time } from '@/constants';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { CacheService } from '@/services/cache/cache.service';
|
||||
|
||||
type WorkflowCacheHash = Record<User['id'], Iso8601DateTimeString>;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { type InstalledNodes } from '@n8n/db';
|
||||
import { type CredentialsEntity } from '@n8n/db';
|
||||
import { type User } from '@n8n/db';
|
||||
import { type Config } from '@oclif/core';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import { type CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import { type User } from '@/databases/entities/user';
|
||||
|
||||
import { CommunityNode } from '../community-node';
|
||||
|
||||
describe('uninstallCredential', () => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { type InstalledNodes, type InstalledPackages } from '@n8n/db';
|
||||
import { type InstalledNodes, type InstalledPackages, type User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { Flags } from '@oclif/core';
|
||||
|
||||
import { CredentialsService } from '@/credentials/credentials.service';
|
||||
import { type User } from '@/databases/entities/user';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { InstalledNodesRepository } from '@/databases/repositories/installed-nodes.repository';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/no-loop-func */
|
||||
import type { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { Flags } from '@oclif/core';
|
||||
import fs from 'fs';
|
||||
@@ -10,7 +11,6 @@ import os from 'os';
|
||||
import { sep } from 'path';
|
||||
|
||||
import { ActiveExecutions } from '@/active-executions';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
||||
import { OwnershipService } from '@/services/ownership.service';
|
||||
import { findCliWorkflowStart } from '@/utils';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ICredentialsDb } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { Flags } from '@oclif/core';
|
||||
import fs from 'fs';
|
||||
@@ -7,7 +8,6 @@ import path from 'path';
|
||||
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import type { ICredentialsDecryptedDb } from '@/interfaces';
|
||||
import type { ICredentialsDb } from '@/types-db';
|
||||
|
||||
import { BaseCommand } from '../base-command';
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { CredentialsEntity, Project, User, SharedCredentials } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
|
||||
import type { EntityManager } from '@n8n/typeorm';
|
||||
@@ -9,10 +10,6 @@ import type { ICredentialsEncrypted } from 'n8n-workflow';
|
||||
import { jsonParse, UserError } from 'n8n-workflow';
|
||||
|
||||
import { UM_FIX_INSTRUCTION } from '@/constants';
|
||||
import { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import { Project } from '@/databases/entities/project';
|
||||
import { SharedCredentials } from '@/databases/entities/shared-credentials';
|
||||
import { User } from '@/databases/entities/user';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import * as Db from '@/db';
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { generateNanoId } from '@n8n/db';
|
||||
import type { WorkflowEntity } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { Flags } from '@oclif/core';
|
||||
import glob from 'fast-glob';
|
||||
@@ -7,7 +8,6 @@ import type { IWorkflowBase, WorkflowId } from 'n8n-workflow';
|
||||
import { jsonParse, UserError } from 'n8n-workflow';
|
||||
|
||||
import { UM_FIX_INSTRUCTION } from '@/constants';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { CredentialsEntity } from '@n8n/db';
|
||||
import { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import { User } from '@/databases/entities/user';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import { SettingsRepository } from '@/databases/repositories/settings.repository';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { User } from '@n8n/db';
|
||||
import type { ApiKey } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import type { ApiKey } from '@/databases/entities/api-key';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { EventService } from '@/events/event.service';
|
||||
import type { AuthenticatedRequest } from '@/requests';
|
||||
import { PublicApiKeyService } from '@/services/public-api-key.service';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { LoginRequestDto } from '@n8n/api-types';
|
||||
import type { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import type { Response } from 'express';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
@@ -7,7 +8,6 @@ import { Logger } from 'n8n-core';
|
||||
import * as auth from '@/auth';
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import config from '@/config';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import { EventService } from '@/events/event.service';
|
||||
import { License } from '@/license';
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { UserUpdateRequestDto } from '@n8n/api-types';
|
||||
import type { User } from '@n8n/db';
|
||||
import type { PublicUser } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import type { Response } from 'express';
|
||||
import { mock, anyObject } from 'jest-mock-extended';
|
||||
@@ -6,7 +8,6 @@ import jwt from 'jsonwebtoken';
|
||||
|
||||
import { AUTH_COOKIE_NAME } from '@/constants';
|
||||
import { MeController } from '@/controllers/me.controller';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { AuthUserRepository } from '@/databases/repositories/auth-user.repository';
|
||||
import { InvalidAuthTokenRepository } from '@/databases/repositories/invalid-auth-token.repository';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
@@ -18,7 +19,6 @@ import { License } from '@/license';
|
||||
import { MfaService } from '@/mfa/mfa.service';
|
||||
import type { AuthenticatedRequest, MeRequest } from '@/requests';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import type { PublicUser } from '@/types-db';
|
||||
import { mockInstance } from '@test/mocking';
|
||||
import { badPasswords } from '@test/test-data';
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { DismissBannerRequestDto, OwnerSetupRequestDto } from '@n8n/api-types';
|
||||
import type { User } from '@n8n/db';
|
||||
import type { PublicUser } from '@n8n/db';
|
||||
import type { Response } from 'express';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { Logger } from 'n8n-core';
|
||||
@@ -6,7 +8,6 @@ import type { Logger } from 'n8n-core';
|
||||
import type { AuthService } from '@/auth/auth.service';
|
||||
import config from '@/config';
|
||||
import { OwnerController } from '@/controllers/owner.controller';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import type { SettingsRepository } from '@/databases/repositories/settings.repository';
|
||||
import type { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
@@ -14,7 +15,6 @@ import type { EventService } from '@/events/event.service';
|
||||
import type { AuthenticatedRequest } from '@/requests';
|
||||
import type { PasswordUtility } from '@/services/password.utility';
|
||||
import type { UserService } from '@/services/user.service';
|
||||
import type { PublicUser } from '@/types-db';
|
||||
|
||||
describe('OwnerController', () => {
|
||||
const configGetSpy = jest.spyOn(config, 'getEnv');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { User } from '@n8n/db';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import type { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import type { EventService } from '@/events/event.service';
|
||||
import type { AuthenticatedRequest } from '@/requests';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { LoginRequestDto, ResolveSignupTokenQueryDto } from '@n8n/api-types';
|
||||
import type { User, PublicUser } from '@n8n/db';
|
||||
import { Body, Get, Post, Query, RestController } from '@n8n/decorators';
|
||||
import { isEmail } from 'class-validator';
|
||||
import { Response } from 'express';
|
||||
@@ -7,7 +8,6 @@ import { Logger } from 'n8n-core';
|
||||
import { handleEmailLogin, handleLdapLogin } from '@/auth';
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import { AuthError } from '@/errors/response-errors/auth.error';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
isLdapCurrentAuthenticationMethod,
|
||||
isSamlCurrentAuthenticationMethod,
|
||||
} from '@/sso.ee/sso-helpers';
|
||||
import type { PublicUser } from '@/types-db';
|
||||
|
||||
@RestController()
|
||||
export class AuthController {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { AcceptInvitationRequestDto, InviteUsersRequestDto } from '@n8n/api-types';
|
||||
import type { User } from '@n8n/db';
|
||||
import { Post, GlobalScope, RestController, Body, Param } from '@n8n/decorators';
|
||||
import { Response } from 'express';
|
||||
import { Logger } from 'n8n-core';
|
||||
@@ -6,7 +7,6 @@ import { Logger } from 'n8n-core';
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import config from '@/config';
|
||||
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
||||
|
||||
@@ -4,13 +4,13 @@ import {
|
||||
SettingsUpdateRequestDto,
|
||||
UserUpdateRequestDto,
|
||||
} from '@n8n/api-types';
|
||||
import type { User, PublicUser } from '@n8n/db';
|
||||
import { Body, Patch, Post, RestController } from '@n8n/decorators';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { Response } from 'express';
|
||||
import { Logger } from 'n8n-core';
|
||||
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { UserRepository } from '@/databases/repositories/user.repository';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.error';
|
||||
@@ -22,7 +22,6 @@ import { AuthenticatedRequest, MeRequest } from '@/requests';
|
||||
import { PasswordUtility } from '@/services/password.utility';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import { isSamlLicensedAndEnabled } from '@/sso.ee/saml/saml-helpers';
|
||||
import type { PublicUser } from '@/types-db';
|
||||
|
||||
import { PersonalizationSurveyAnswersV4 } from './survey-answers.dto';
|
||||
@RestController('/me')
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { CredentialsEntity } from '@n8n/db';
|
||||
import type { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import Csrf from 'csrf';
|
||||
import type { Response } from 'express';
|
||||
@@ -10,8 +12,6 @@ import { Time } from '@/constants';
|
||||
import { OAuth1CredentialController } from '@/controllers/oauth/oauth1-credential.controller';
|
||||
import { CredentialsFinderService } from '@/credentials/credentials-finder.service';
|
||||
import { CredentialsHelper } from '@/credentials-helper';
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { VariablesService } from '@/environments.ee/variables/variables.service.ee';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { CredentialsEntity } from '@n8n/db';
|
||||
import type { User } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import Csrf from 'csrf';
|
||||
import { type Response } from 'express';
|
||||
@@ -10,8 +12,6 @@ import { CREDENTIAL_BLANKING_VALUE, Time } from '@/constants';
|
||||
import { OAuth2CredentialController } from '@/controllers/oauth/oauth2-credential.controller';
|
||||
import { CredentialsFinderService } from '@/credentials/credentials-finder.service';
|
||||
import { CredentialsHelper } from '@/credentials-helper';
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { VariablesService } from '@/environments.ee/variables/variables.service.ee';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import type { CredentialsEntity, ICredentialsDb } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import Csrf from 'csrf';
|
||||
import type { Response } from 'express';
|
||||
@@ -9,7 +10,6 @@ import { jsonParse, UnexpectedError } from 'n8n-workflow';
|
||||
import { RESPONSE_ERROR_MESSAGES, Time } from '@/constants';
|
||||
import { CredentialsFinderService } from '@/credentials/credentials-finder.service';
|
||||
import { CredentialsHelper } from '@/credentials-helper';
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { AuthError } from '@/errors/response-errors/auth.error';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
@@ -17,7 +17,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||
import { ExternalHooks } from '@/external-hooks';
|
||||
import type { AuthenticatedRequest, OAuthRequest } from '@/requests';
|
||||
import { UrlService } from '@/services/url.service';
|
||||
import type { ICredentialsDb } from '@/types-db';
|
||||
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
||||
|
||||
type CsrfStateParam = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CreateProjectDto, DeleteProjectDto, UpdateProjectDto } from '@n8n/api-types';
|
||||
import type { Project } from '@n8n/db';
|
||||
import {
|
||||
Get,
|
||||
Post,
|
||||
@@ -18,7 +19,6 @@ import type { Scope } from '@n8n/permissions';
|
||||
import { In, Not } from '@n8n/typeorm';
|
||||
import { Response } from 'express';
|
||||
|
||||
import type { Project } from '@/databases/entities/project';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { RoleChangeRequestDto, SettingsUpdateRequestDto } from '@n8n/api-types';
|
||||
import type { PublicUser } from '@n8n/db';
|
||||
import { Project, User, AuthIdentity } from '@n8n/db';
|
||||
import {
|
||||
GlobalScope,
|
||||
Delete,
|
||||
@@ -14,9 +16,6 @@ import { Logger } from 'n8n-core';
|
||||
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import { CredentialsService } from '@/credentials/credentials.service';
|
||||
import { AuthIdentity } from '@/databases/entities/auth-identity';
|
||||
import { Project } from '@/databases/entities/project';
|
||||
import { User } from '@/databases/entities/user';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
|
||||
import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository';
|
||||
@@ -31,7 +30,6 @@ import { ListQuery, AuthenticatedRequest, UserRequest } from '@/requests';
|
||||
import { FolderService } from '@/services/folder.service';
|
||||
import { ProjectService } from '@/services/project.service.ee';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import type { PublicUser } from '@/types-db';
|
||||
import { WorkflowService } from '@/workflows/workflow.service';
|
||||
|
||||
@RestController('/users')
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { WorkflowStatistics } from '@n8n/db';
|
||||
import { StatisticsNames } from '@n8n/db';
|
||||
import { Get, Middleware, RestController } from '@n8n/decorators';
|
||||
import { Response, NextFunction } from 'express';
|
||||
import { Logger } from 'n8n-core';
|
||||
|
||||
import type { WorkflowStatistics } from '@/databases/entities/workflow-statistics';
|
||||
import { StatisticsNames } from '@/databases/entities/workflow-statistics';
|
||||
import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository';
|
||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||
import type { IWorkflowStatisticsDataLoaded } from '@/interfaces';
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
import type { CredentialsEntity, ICredentialsDb } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
|
||||
import { In } from '@n8n/typeorm';
|
||||
@@ -30,10 +31,8 @@ import { ICredentialsHelper, NodeHelpers, Workflow, UnexpectedError } from 'n8n-
|
||||
|
||||
import { CredentialTypes } from '@/credential-types';
|
||||
import { CredentialsOverwrites } from '@/credentials-overwrites';
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
|
||||
import type { ICredentialsDb } from '@/types-db';
|
||||
|
||||
import { RESPONSE_ERROR_MESSAGES } from './constants';
|
||||
import { CredentialNotFoundError } from './errors/credential-not-found.error';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { CredentialsEntity } from '@n8n/db';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { CREDENTIAL_ERRORS, CredentialDataError, Credentials, type ErrorReporter } from 'n8n-core';
|
||||
import { CREDENTIAL_EMPTY_VALUE, type ICredentialType } from 'n8n-workflow';
|
||||
@@ -5,7 +6,6 @@ import { CREDENTIAL_EMPTY_VALUE, type ICredentialType } from 'n8n-workflow';
|
||||
import { CREDENTIAL_BLANKING_VALUE } from '@/constants';
|
||||
import type { CredentialTypes } from '@/credential-types';
|
||||
import { CredentialsService } from '@/credentials/credentials.service';
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import type { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
|
||||
describe('CredentialsService', () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ProjectRole } from '@n8n/api-types';
|
||||
import type { CredentialsEntity, SharedCredentials, CredentialSharingRole, User } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
|
||||
@@ -6,12 +7,6 @@ import type { EntityManager, FindOptionsWhere } from '@n8n/typeorm';
|
||||
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
|
||||
import { In } from '@n8n/typeorm';
|
||||
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import type {
|
||||
SharedCredentials,
|
||||
CredentialSharingRole,
|
||||
} from '@/databases/entities/shared-credentials';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
GenerateCredentialNameRequestQuery,
|
||||
} from '@n8n/api-types';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { SharedCredentials } from '@n8n/db';
|
||||
import {
|
||||
Delete,
|
||||
Get,
|
||||
@@ -25,7 +26,6 @@ import { deepCopy } from 'n8n-workflow';
|
||||
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { SharedCredentials } from '@/databases/entities/shared-credentials';
|
||||
import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository';
|
||||
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
|
||||
import * as Db from '@/db';
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { Project, SharedCredentials } from '@n8n/db';
|
||||
import type { CredentialsEntity, User } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
|
||||
import { In, type EntityManager } from '@n8n/typeorm';
|
||||
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
|
||||
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import { Project } from '@/databases/entities/project';
|
||||
import { SharedCredentials } from '@/databases/entities/shared-credentials';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
|
||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||
import { TransferCredentialError } from '@/errors/response-errors/transfer-credential.error';
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { CreateCredentialDto } from '@n8n/api-types';
|
||||
import type { Project, User, ICredentialsDb, ScopesField } from '@n8n/db';
|
||||
import { CredentialsEntity, SharedCredentials } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
|
||||
@@ -20,10 +22,6 @@ import { CREDENTIAL_EMPTY_VALUE, deepCopy, NodeHelpers, UnexpectedError } from '
|
||||
import { CREDENTIAL_BLANKING_VALUE } from '@/constants';
|
||||
import { CredentialTypes } from '@/credential-types';
|
||||
import { createCredentialsFromCredentialsEntity } from '@/credentials-helper';
|
||||
import { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import type { Project } from '@/databases/entities/project';
|
||||
import { SharedCredentials } from '@/databases/entities/shared-credentials';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository';
|
||||
@@ -39,7 +37,6 @@ import { CredentialsTester } from '@/services/credentials-tester.service';
|
||||
import { OwnershipService } from '@/services/ownership.service';
|
||||
import { ProjectService } from '@/services/project.service.ee';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
import type { ICredentialsDb, ScopesField } from '@/types-db';
|
||||
|
||||
import { CredentialsFinderService } from './credentials-finder.service';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { User } from '@/databases/entities/user';
|
||||
import { User } from '@n8n/db';
|
||||
|
||||
describe('User Entity', () => {
|
||||
describe('JSON.stringify', () => {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { DateTimeColumn } from '@n8n/db';
|
||||
import { DateTimeColumn, AuthProviderType } from '@n8n/db';
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from '@n8n/typeorm';
|
||||
|
||||
import { AuthProviderType } from './auth-identity';
|
||||
|
||||
export type RunningMode = 'dry' | 'live';
|
||||
export type SyncStatus = 'success' | 'error';
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { User } from '@n8n/db';
|
||||
import { Column, Entity } from '@n8n/typeorm';
|
||||
|
||||
import { User } from './user';
|
||||
|
||||
@Entity({ name: 'user' })
|
||||
export class AuthUser extends User {
|
||||
@Column({ type: String, nullable: true })
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DateTimeColumn, datetimeColumnType, idStringifier } from '@n8n/db';
|
||||
import { DateTimeColumn, datetimeColumnType, idStringifier, WorkflowEntity } from '@n8n/db';
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
@@ -18,7 +18,6 @@ import type { ExecutionAnnotation } from '@/databases/entities/execution-annotat
|
||||
|
||||
import type { ExecutionData } from './execution-data';
|
||||
import type { ExecutionMetadata } from './execution-metadata';
|
||||
import { WorkflowEntity } from './workflow-entity';
|
||||
|
||||
@Entity()
|
||||
@Index(['workflowId', 'id'])
|
||||
|
||||
@@ -7,35 +7,35 @@ import {
|
||||
Settings,
|
||||
Variables,
|
||||
WebhookEntity,
|
||||
AuthIdentity,
|
||||
User,
|
||||
WorkflowEntity,
|
||||
CredentialsEntity,
|
||||
ApiKey,
|
||||
Folder,
|
||||
FolderTagMapping,
|
||||
Project,
|
||||
ProjectRelation,
|
||||
SharedCredentials,
|
||||
SharedWorkflow,
|
||||
TagEntity,
|
||||
WorkflowStatistics,
|
||||
WorkflowTagMapping,
|
||||
} from '@n8n/db';
|
||||
|
||||
import { AnnotationTagEntity } from './annotation-tag-entity.ee';
|
||||
import { AnnotationTagMapping } from './annotation-tag-mapping.ee';
|
||||
import { ApiKey } from './api-key';
|
||||
import { AuthIdentity } from './auth-identity';
|
||||
import { AuthProviderSyncHistory } from './auth-provider-sync-history';
|
||||
import { AuthUser } from './auth-user';
|
||||
import { CredentialsEntity } from './credentials-entity';
|
||||
import { ExecutionAnnotation } from './execution-annotation.ee';
|
||||
import { ExecutionData } from './execution-data';
|
||||
import { ExecutionEntity } from './execution-entity';
|
||||
import { ExecutionMetadata } from './execution-metadata';
|
||||
import { Folder } from './folder';
|
||||
import { FolderTagMapping } from './folder-tag-mapping';
|
||||
import { Project } from './project';
|
||||
import { ProjectRelation } from './project-relation';
|
||||
import { SharedCredentials } from './shared-credentials';
|
||||
import { SharedWorkflow } from './shared-workflow';
|
||||
import { TagEntity } from './tag-entity';
|
||||
import { TestCaseExecution } from './test-case-execution.ee';
|
||||
import { TestDefinition } from './test-definition.ee';
|
||||
import { TestMetric } from './test-metric.ee';
|
||||
import { TestRun } from './test-run.ee';
|
||||
import { User } from './user';
|
||||
import { WorkflowEntity } from './workflow-entity';
|
||||
import { WorkflowHistory } from './workflow-history';
|
||||
import { WorkflowStatistics } from './workflow-statistics';
|
||||
import { WorkflowTagMapping } from './workflow-tag-mapping';
|
||||
import { InsightsByPeriod } from '../../modules/insights/database/entities/insights-by-period';
|
||||
import { InsightsMetadata } from '../../modules/insights/database/entities/insights-metadata';
|
||||
import { InsightsRaw } from '../../modules/insights/database/entities/insights-raw';
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { JsonColumn, WithTimestampsAndStringId } from '@n8n/db';
|
||||
import { JsonColumn, WithTimestampsAndStringId, WorkflowEntity } from '@n8n/db';
|
||||
import { Column, Entity, Index, ManyToOne, OneToMany, RelationId } from '@n8n/typeorm';
|
||||
import { Length } from 'class-validator';
|
||||
|
||||
import { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity.ee';
|
||||
import type { TestMetric } from '@/databases/entities/test-metric.ee';
|
||||
import { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
|
||||
// Entity representing a node in a workflow under test, for which data should be mocked during test execution
|
||||
export type MockedNodeItem = {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { JsonColumn, WithTimestamps } from '@n8n/db';
|
||||
import { JsonColumn, WithTimestamps, WorkflowEntity } from '@n8n/db';
|
||||
import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm';
|
||||
import { IConnections } from 'n8n-workflow';
|
||||
import type { INode } from 'n8n-workflow';
|
||||
|
||||
import { WorkflowEntity } from './workflow-entity';
|
||||
|
||||
@Entity()
|
||||
export class WorkflowHistory extends WithTimestamps {
|
||||
@PrimaryColumn()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import type { WorkflowEntity } from '@n8n/db';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
|
||||
export class UniqueWorkflowNames1620821879465 implements ReversibleMigration {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { CredentialsEntity, WorkflowEntity } from '@n8n/db';
|
||||
import type { IWorkflowBase } from 'n8n-workflow';
|
||||
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
|
||||
type Credential = Pick<CredentialsEntity, 'id' | 'name' | 'type'>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { WorkflowEntity } from '@n8n/db';
|
||||
import type { INode } from 'n8n-workflow';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
|
||||
type Workflow = Pick<WorkflowEntity, 'id'> & { nodes: string | INode[] };
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { StatisticsNames } from '@/databases/entities/workflow-statistics';
|
||||
import { StatisticsNames } from '@n8n/db';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
|
||||
export class RemoveWorkflowDataLoadedFlag1671726148419 implements ReversibleMigration {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { WorkflowEntity } from '@n8n/db';
|
||||
import { UserError } from 'n8n-workflow';
|
||||
|
||||
import { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
|
||||
|
||||
export class PurgeInvalidWorkflowConnections1675940580449 implements IrreversibleMigration {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { ProjectRole } from '@n8n/api-types';
|
||||
import { generateNanoId } from '@n8n/db';
|
||||
import type { User } from '@n8n/db';
|
||||
import { UserError } from 'n8n-workflow';
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
|
||||
const projectAdminRole: ProjectRole = 'project:personalOwner';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { generateNanoId } from '@n8n/db';
|
||||
import type { ApiKey } from '@n8n/db';
|
||||
|
||||
import type { ApiKey } from '@/databases/entities/api-key';
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
|
||||
export class AddApiKeysTable1724951148974 implements ReversibleMigration {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApiKey } from '@n8n/db';
|
||||
import type { GlobalRole } from '@n8n/permissions';
|
||||
|
||||
import { ApiKey } from '@/databases/entities/api-key';
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import { getApiKeyScopesForRole } from '@/public-api/permissions.ee';
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { UserSettings } from '@n8n/db';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { UserSettings } from '@/types-db';
|
||||
|
||||
export class AddUserActivatedProperty1681134145996 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { UserSettings } from '@n8n/db';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { UserSettings } from '@/types-db';
|
||||
|
||||
export class AddUserActivatedProperty1681134145996 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { UserSettings } from '@n8n/db';
|
||||
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
import type { UserSettings } from '@/types-db';
|
||||
|
||||
export class AddUserActivatedProperty1681134145996 implements ReversibleMigration {
|
||||
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { generateNanoId } from '@n8n/db';
|
||||
import type { ApiKey } from '@n8n/db';
|
||||
|
||||
import type { ApiKey } from '@/databases/entities/api-key';
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
|
||||
export class AddApiKeysTable1724951148974 implements ReversibleMigration {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CredentialsEntity } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import { mockEntityManager } from '@test/mocking';
|
||||
|
||||
import { CredentialsRepository } from '../credentials.repository';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import type { SqliteConfig } from '@n8n/config/src/configs/database.config';
|
||||
import type { IExecutionResponse } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import type { SelectQueryBuilder } from '@n8n/typeorm';
|
||||
import { Not, LessThanOrEqual } from '@n8n/typeorm';
|
||||
@@ -10,7 +11,6 @@ import { nanoid } from 'nanoid';
|
||||
|
||||
import { ExecutionEntity } from '@/databases/entities/execution-entity';
|
||||
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
|
||||
import type { IExecutionResponse } from '@/types-db';
|
||||
import { mockInstance, mockEntityManager } from '@test/mocking';
|
||||
|
||||
describe('ExecutionRepository', () => {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { Project } from '@n8n/db';
|
||||
import type { User } from '@n8n/db';
|
||||
import type { Folder } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
import type { Folder } from '@/databases/entities/folder';
|
||||
import type { Project } from '@/databases/entities/project';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { createFolder } from '@test-integration/db/folders';
|
||||
import { getPersonalProject } from '@test-integration/db/projects';
|
||||
import { createTag } from '@test-integration/db/tags';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { StatisticsNames, WorkflowStatistics } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { type InsertResult, QueryFailedError } from '@n8n/typeorm';
|
||||
import { mock, mockClear } from 'jest-mock-extended';
|
||||
|
||||
import { StatisticsNames, WorkflowStatistics } from '@/databases/entities/workflow-statistics';
|
||||
import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository';
|
||||
import { mockEntityManager } from '@test/mocking';
|
||||
import { createWorkflow } from '@test-integration/db/workflows';
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { ApiKey } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { DataSource, Repository } from '@n8n/typeorm';
|
||||
|
||||
import { ApiKey } from '../entities/api-key';
|
||||
|
||||
@Service()
|
||||
export class ApiKeyRepository extends Repository<ApiKey> {
|
||||
constructor(dataSource: DataSource) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { AuthIdentity } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { DataSource, Repository } from '@n8n/typeorm';
|
||||
|
||||
import { AuthIdentity } from '../entities/auth-identity';
|
||||
|
||||
@Service()
|
||||
export class AuthIdentityRepository extends Repository<AuthIdentity> {
|
||||
constructor(dataSource: DataSource) {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { CredentialsEntity } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { DataSource, In, Repository, Like } from '@n8n/typeorm';
|
||||
import type { FindManyOptions } from '@n8n/typeorm';
|
||||
|
||||
import type { ListQuery } from '@/requests';
|
||||
|
||||
import { CredentialsEntity } from '../entities/credentials-entity';
|
||||
|
||||
@Service()
|
||||
export class CredentialsRepository extends Repository<CredentialsEntity> {
|
||||
constructor(dataSource: DataSource) {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { separate } from '@n8n/db';
|
||||
import type {
|
||||
CreateExecutionPayload,
|
||||
IExecutionFlattedDb,
|
||||
IExecutionBase,
|
||||
IExecutionResponse,
|
||||
ExecutionSummaries,
|
||||
} from '@n8n/db';
|
||||
import { separate, SharedWorkflow, WorkflowEntity } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type {
|
||||
FindManyOptions,
|
||||
@@ -36,20 +43,11 @@ import { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity.
|
||||
import { AnnotationTagMapping } from '@/databases/entities/annotation-tag-mapping.ee';
|
||||
import { ExecutionAnnotation } from '@/databases/entities/execution-annotation.ee';
|
||||
import { PostgresLiveRowsRetrievalError } from '@/errors/postgres-live-rows-retrieval.error';
|
||||
import type {
|
||||
CreateExecutionPayload,
|
||||
IExecutionFlattedDb,
|
||||
IExecutionBase,
|
||||
IExecutionResponse,
|
||||
ExecutionSummaries,
|
||||
} from '@/types-db';
|
||||
|
||||
import { ExecutionDataRepository } from './execution-data.repository';
|
||||
import { ExecutionData } from '../entities/execution-data';
|
||||
import { ExecutionEntity } from '../entities/execution-entity';
|
||||
import { ExecutionMetadata } from '../entities/execution-metadata';
|
||||
import { SharedWorkflow } from '../entities/shared-workflow';
|
||||
import { WorkflowEntity } from '../entities/workflow-entity';
|
||||
|
||||
export interface IGetExecutionsQueryFilter {
|
||||
id?: FindOperator<string> | string;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { FolderTagMapping } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { DataSource, Repository } from '@n8n/typeorm';
|
||||
|
||||
import { FolderTagMapping } from '../entities/folder-tag-mapping';
|
||||
|
||||
@Service()
|
||||
export class FolderTagMappingRepository extends Repository<FolderTagMapping> {
|
||||
constructor(dataSource: DataSource) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { FolderWithWorkflowAndSubFolderCount } from '@n8n/db';
|
||||
import { Folder, FolderTagMapping, TagEntity } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { EntityManager, SelectQueryBuilder } from '@n8n/typeorm';
|
||||
import { DataSource, Repository } from '@n8n/typeorm';
|
||||
@@ -5,11 +7,6 @@ import { PROJECT_ROOT } from 'n8n-workflow';
|
||||
|
||||
import type { ListQuery } from '@/requests';
|
||||
|
||||
import type { FolderWithWorkflowAndSubFolderCount } from '../entities/folder';
|
||||
import { Folder } from '../entities/folder';
|
||||
import { FolderTagMapping } from '../entities/folder-tag-mapping';
|
||||
import { TagEntity } from '../entities/tag-entity';
|
||||
|
||||
@Service()
|
||||
export class FolderRepository extends Repository<FolderWithWorkflowAndSubFolderCount> {
|
||||
constructor(dataSource: DataSource) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type { ProjectRole } from '@n8n/api-types';
|
||||
import { ProjectRelation } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { DataSource, In, Repository } from '@n8n/typeorm';
|
||||
|
||||
import { ProjectRelation } from '../entities/project-relation';
|
||||
|
||||
@Service()
|
||||
export class ProjectRelationRepository extends Repository<ProjectRelation> {
|
||||
constructor(dataSource: DataSource) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Project } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { EntityManager } from '@n8n/typeorm';
|
||||
import { DataSource, Repository } from '@n8n/typeorm';
|
||||
|
||||
import { Project } from '../entities/project';
|
||||
|
||||
@Service()
|
||||
export class ProjectRepository extends Repository<Project> {
|
||||
constructor(dataSource: DataSource) {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import type { ProjectRole } from '@n8n/api-types';
|
||||
import { SharedCredentials } from '@n8n/db';
|
||||
import type { Project, CredentialSharingRole } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import type { EntityManager, FindOptionsWhere } from '@n8n/typeorm';
|
||||
import { DataSource, In, Not, Repository } from '@n8n/typeorm';
|
||||
|
||||
import type { Project } from '../entities/project';
|
||||
import { type CredentialSharingRole, SharedCredentials } from '../entities/shared-credentials';
|
||||
|
||||
@Service()
|
||||
export class SharedCredentialsRepository extends Repository<SharedCredentials> {
|
||||
constructor(dataSource: DataSource) {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { SharedWorkflow } from '@n8n/db';
|
||||
import type { Project, WorkflowSharingRole } from '@n8n/db';
|
||||
import { Service } from '@n8n/di';
|
||||
import { DataSource, Repository, In, Not } from '@n8n/typeorm';
|
||||
import type { EntityManager, FindManyOptions, FindOptionsWhere } from '@n8n/typeorm';
|
||||
|
||||
import type { Project } from '../entities/project';
|
||||
import { SharedWorkflow, type WorkflowSharingRole } from '../entities/shared-workflow';
|
||||
|
||||
@Service()
|
||||
export class SharedWorkflowRepository extends Repository<SharedWorkflow> {
|
||||
constructor(dataSource: DataSource) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user