ci: Break most of the circular dependencies in code (no-changelog) (#4990)
This commit is contained in:
committed by
GitHub
parent
82f763589b
commit
5db9c46043
@@ -1,7 +1,7 @@
|
||||
import type { ICredentialNodeAccess } from 'n8n-workflow';
|
||||
import { Column, Entity, Index, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { IsArray, IsObject, IsString, Length } from 'class-validator';
|
||||
import { SharedCredentials } from './SharedCredentials';
|
||||
import type { SharedCredentials } from './SharedCredentials';
|
||||
import { AbstractEntity, jsonColumnType } from './AbstractEntity';
|
||||
import type { ICredentialsDb } from '@/Interfaces';
|
||||
|
||||
@@ -28,7 +28,7 @@ export class CredentialsEntity extends AbstractEntity implements ICredentialsDb
|
||||
})
|
||||
type: string;
|
||||
|
||||
@OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.credentials)
|
||||
@OneToMany('SharedCredentials', 'credentials')
|
||||
shared: SharedCredentials[];
|
||||
|
||||
@Column(jsonColumnType)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';
|
||||
import { InstalledPackages } from './InstalledPackages';
|
||||
import type { InstalledPackages } from './InstalledPackages';
|
||||
|
||||
@Entity()
|
||||
export class InstalledNodes {
|
||||
@@ -12,10 +12,7 @@ export class InstalledNodes {
|
||||
@Column()
|
||||
latestVersion: string;
|
||||
|
||||
@ManyToOne(
|
||||
() => InstalledPackages,
|
||||
(installedPackages: InstalledPackages) => installedPackages.installedNodes,
|
||||
)
|
||||
@ManyToOne('InstalledPackages', 'installedNodes')
|
||||
@JoinColumn({ name: 'package', referencedColumnName: 'packageName' })
|
||||
package: InstalledPackages;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Column, Entity, JoinColumn, OneToMany, PrimaryColumn } from 'typeorm';
|
||||
import { InstalledNodes } from './InstalledNodes';
|
||||
import type { InstalledNodes } from './InstalledNodes';
|
||||
import { AbstractEntity } from './AbstractEntity';
|
||||
|
||||
@Entity()
|
||||
@@ -16,7 +16,7 @@ export class InstalledPackages extends AbstractEntity {
|
||||
@Column()
|
||||
authorEmail?: string;
|
||||
|
||||
@OneToMany(() => InstalledNodes, (installedNode) => installedNode.package)
|
||||
@OneToMany('InstalledNodes', 'package')
|
||||
@JoinColumn({ referencedColumnName: 'package' })
|
||||
installedNodes: InstalledNodes[];
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn, Unique } from 'typeorm';
|
||||
import { IsString, Length } from 'class-validator';
|
||||
|
||||
import { User } from './User';
|
||||
import { SharedWorkflow } from './SharedWorkflow';
|
||||
import { SharedCredentials } from './SharedCredentials';
|
||||
import type { User } from './User';
|
||||
import type { SharedWorkflow } from './SharedWorkflow';
|
||||
import type { SharedCredentials } from './SharedCredentials';
|
||||
import { AbstractEntity } from './AbstractEntity';
|
||||
|
||||
export type RoleNames = 'owner' | 'member' | 'user' | 'editor';
|
||||
@@ -23,12 +23,12 @@ export class Role extends AbstractEntity {
|
||||
@Column()
|
||||
scope: RoleScopes;
|
||||
|
||||
@OneToMany(() => User, (user) => user.globalRole)
|
||||
@OneToMany('User', 'globalRole')
|
||||
globalForUsers: User[];
|
||||
|
||||
@OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.role)
|
||||
@OneToMany('SharedWorkflow', 'role')
|
||||
sharedWorkflows: SharedWorkflow[];
|
||||
|
||||
@OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.role)
|
||||
@OneToMany('SharedCredentials', 'role')
|
||||
sharedCredentials: SharedCredentials[];
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { Entity, ManyToOne, RelationId } from 'typeorm';
|
||||
import { CredentialsEntity } from './CredentialsEntity';
|
||||
import { User } from './User';
|
||||
import { Role } from './Role';
|
||||
import type { CredentialsEntity } from './CredentialsEntity';
|
||||
import type { User } from './User';
|
||||
import type { Role } from './Role';
|
||||
import { AbstractEntity } from './AbstractEntity';
|
||||
|
||||
@Entity()
|
||||
export class SharedCredentials extends AbstractEntity {
|
||||
@ManyToOne(() => Role, (role) => role.sharedCredentials, { nullable: false })
|
||||
@ManyToOne('Role', 'sharedCredentials', { nullable: false })
|
||||
role: Role;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.sharedCredentials, { primary: true })
|
||||
@ManyToOne('User', 'sharedCredentials', { primary: true })
|
||||
user: User;
|
||||
|
||||
@RelationId((sharedCredential: SharedCredentials) => sharedCredential.user)
|
||||
userId: string;
|
||||
|
||||
@ManyToOne(() => CredentialsEntity, (credentials) => credentials.shared, {
|
||||
@ManyToOne('CredentialsEntity', 'shared', {
|
||||
primary: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { Entity, ManyToOne, RelationId } from 'typeorm';
|
||||
import { WorkflowEntity } from './WorkflowEntity';
|
||||
import { User } from './User';
|
||||
import { Role } from './Role';
|
||||
import type { WorkflowEntity } from './WorkflowEntity';
|
||||
import type { User } from './User';
|
||||
import type { Role } from './Role';
|
||||
import { AbstractEntity } from './AbstractEntity';
|
||||
|
||||
@Entity()
|
||||
export class SharedWorkflow extends AbstractEntity {
|
||||
@ManyToOne(() => Role, (role) => role.sharedWorkflows, { nullable: false })
|
||||
@ManyToOne('Role', 'sharedWorkflows', { nullable: false })
|
||||
role: Role;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.sharedWorkflows, { primary: true })
|
||||
@ManyToOne('User', 'sharedWorkflows', { primary: true })
|
||||
user: User;
|
||||
|
||||
@RelationId((sharedWorkflow: SharedWorkflow) => sharedWorkflow.user)
|
||||
userId: string;
|
||||
|
||||
@ManyToOne(() => WorkflowEntity, (workflow) => workflow.shared, {
|
||||
@ManyToOne('WorkflowEntity', 'shared', {
|
||||
primary: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Column, Entity, Generated, Index, ManyToMany, PrimaryColumn } from 'typeorm';
|
||||
import { IsString, Length } from 'class-validator';
|
||||
|
||||
import { ITagDb } from '@/Interfaces';
|
||||
import type { ITagDb } from '@/Interfaces';
|
||||
import { idStringifier } from '../utils/transformers';
|
||||
import { WorkflowEntity } from './WorkflowEntity';
|
||||
import type { WorkflowEntity } from './WorkflowEntity';
|
||||
import { AbstractEntity } from './AbstractEntity';
|
||||
|
||||
@Entity()
|
||||
@@ -20,6 +20,6 @@ export class TagEntity extends AbstractEntity implements ITagDb {
|
||||
@Length(1, 24, { message: 'Tag name must be $constraint1 to $constraint2 characters long.' })
|
||||
name: string;
|
||||
|
||||
@ManyToMany(() => WorkflowEntity, (workflow) => workflow.tags)
|
||||
@ManyToMany('WorkflowEntity', 'tags')
|
||||
workflows: WorkflowEntity[];
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ import {
|
||||
} from 'typeorm';
|
||||
import { IsEmail, IsString, Length } from 'class-validator';
|
||||
import type { IUser } from 'n8n-workflow';
|
||||
import { Role } from './Role';
|
||||
import { SharedWorkflow } from './SharedWorkflow';
|
||||
import { SharedCredentials } from './SharedCredentials';
|
||||
import type { Role } from './Role';
|
||||
import type { SharedWorkflow } from './SharedWorkflow';
|
||||
import type { SharedCredentials } from './SharedCredentials';
|
||||
import { NoXss } from '../utils/customValidators';
|
||||
import { objectRetriever, lowerCaser } from '../utils/transformers';
|
||||
import { AbstractEntity, jsonColumnType } from './AbstractEntity';
|
||||
@@ -74,16 +74,16 @@ export class User extends AbstractEntity implements IUser {
|
||||
})
|
||||
settings: IUserSettings | null;
|
||||
|
||||
@ManyToOne(() => Role, (role) => role.globalForUsers, {
|
||||
@ManyToOne('Role', 'globalForUsers', {
|
||||
cascade: true,
|
||||
nullable: false,
|
||||
})
|
||||
globalRole: Role;
|
||||
|
||||
@OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.user)
|
||||
@OneToMany('SharedWorkflow', 'user')
|
||||
sharedWorkflows: SharedWorkflow[];
|
||||
|
||||
@OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.user)
|
||||
@OneToMany('SharedCredentials', 'user')
|
||||
sharedCredentials: SharedCredentials[];
|
||||
|
||||
@BeforeInsert()
|
||||
|
||||
@@ -21,11 +21,11 @@ import {
|
||||
} from 'typeorm';
|
||||
|
||||
import config from '@/config';
|
||||
import { TagEntity } from './TagEntity';
|
||||
import { SharedWorkflow } from './SharedWorkflow';
|
||||
import type { TagEntity } from './TagEntity';
|
||||
import type { SharedWorkflow } from './SharedWorkflow';
|
||||
import type { WorkflowStatistics } from './WorkflowStatistics';
|
||||
import { objectRetriever, sqlite } from '../utils/transformers';
|
||||
import { AbstractEntity, jsonColumnType } from './AbstractEntity';
|
||||
import { WorkflowStatistics } from './WorkflowStatistics';
|
||||
import type { IWorkflowDb } from '@/Interfaces';
|
||||
|
||||
@Entity()
|
||||
@@ -63,7 +63,7 @@ export class WorkflowEntity extends AbstractEntity implements IWorkflowDb {
|
||||
})
|
||||
staticData?: IDataObject;
|
||||
|
||||
@ManyToMany(() => TagEntity, (tag) => tag.workflows)
|
||||
@ManyToMany('TagEntity', 'workflows')
|
||||
@JoinTable({
|
||||
name: 'workflows_tags', // table name for the junction table of this relation
|
||||
joinColumn: {
|
||||
@@ -77,13 +77,10 @@ export class WorkflowEntity extends AbstractEntity implements IWorkflowDb {
|
||||
})
|
||||
tags?: TagEntity[];
|
||||
|
||||
@OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.workflow)
|
||||
@OneToMany('SharedWorkflow', 'workflow')
|
||||
shared: SharedWorkflow[];
|
||||
|
||||
@OneToMany(
|
||||
() => WorkflowStatistics,
|
||||
(workflowStatistics: WorkflowStatistics) => workflowStatistics.workflow,
|
||||
)
|
||||
@OneToMany('WorkflowStatistics', 'workflow')
|
||||
@JoinColumn({ referencedColumnName: 'workflow' })
|
||||
statistics: WorkflowStatistics[];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Column, Entity, RelationId, ManyToOne, PrimaryColumn } from 'typeorm';
|
||||
import { datetimeColumnType } from './AbstractEntity';
|
||||
import { WorkflowEntity } from './WorkflowEntity';
|
||||
import type { WorkflowEntity } from './WorkflowEntity';
|
||||
|
||||
export enum StatisticsNames {
|
||||
productionSuccess = 'production_success',
|
||||
@@ -20,7 +20,7 @@ export class WorkflowStatistics {
|
||||
@PrimaryColumn({ length: 128 })
|
||||
name: StatisticsNames;
|
||||
|
||||
@ManyToOne(() => WorkflowEntity, (workflow) => workflow.shared, {
|
||||
@ManyToOne('WorkflowEntity', 'shared', {
|
||||
primary: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user