easywork-common-lib 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BaseEntity } from "../../common/database";
|
|
2
|
+
import { MinLength } from "class-validator";
|
|
3
|
+
import { Column, Entity, JoinColumn, OneToMany, OneToOne } from "typeorm";
|
|
4
|
+
import { Folder } from "./folder.entity";
|
|
5
|
+
import { EntityFile } from "../helpers/entity_file.entity";
|
|
6
|
+
|
|
7
|
+
@Entity()
|
|
8
|
+
export class File extends BaseEntity {
|
|
9
|
+
@MinLength(1)
|
|
10
|
+
name: string;
|
|
11
|
+
|
|
12
|
+
@OneToOne(() => Folder, {
|
|
13
|
+
onDelete: "CASCADE",
|
|
14
|
+
onUpdate: "CASCADE",
|
|
15
|
+
})
|
|
16
|
+
@JoinColumn()
|
|
17
|
+
folder: Folder;
|
|
18
|
+
|
|
19
|
+
@Column({ nullable: true })
|
|
20
|
+
url: string;
|
|
21
|
+
|
|
22
|
+
@Column({ nullable: true })
|
|
23
|
+
size: number;
|
|
24
|
+
|
|
25
|
+
@Column({ type: "bigint", nullable: true })
|
|
26
|
+
mimeType: string;
|
|
27
|
+
|
|
28
|
+
@Column({ nullable: true })
|
|
29
|
+
s3Key: string;
|
|
30
|
+
|
|
31
|
+
@Column({ default: false })
|
|
32
|
+
isDefault: boolean;
|
|
33
|
+
|
|
34
|
+
@OneToMany(() => EntityFile, (EntityFile) => EntityFile.file, {
|
|
35
|
+
onDelete: "CASCADE",
|
|
36
|
+
onUpdate: "CASCADE",
|
|
37
|
+
eager: true,
|
|
38
|
+
})
|
|
39
|
+
owners?: EntityFile[];
|
|
40
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseEntity } from "../../common/database";
|
|
2
2
|
import { MinLength } from "class-validator";
|
|
3
|
-
import { Column, Entity } from "typeorm";
|
|
3
|
+
import { Column, Entity, JoinColumn, OneToOne } from "typeorm";
|
|
4
4
|
|
|
5
5
|
@Entity()
|
|
6
6
|
export class Folder extends BaseEntity {
|
|
@@ -8,6 +8,10 @@ export class Folder extends BaseEntity {
|
|
|
8
8
|
@Column({ unique: true })
|
|
9
9
|
name: string;
|
|
10
10
|
|
|
11
|
-
@
|
|
12
|
-
|
|
11
|
+
@OneToOne(() => Folder, {
|
|
12
|
+
onDelete: "CASCADE",
|
|
13
|
+
onUpdate: "CASCADE",
|
|
14
|
+
})
|
|
15
|
+
@JoinColumn()
|
|
16
|
+
parent: Folder;
|
|
13
17
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity, ManyToOne } from "typeorm";
|
|
2
|
+
import { File } from "../drive/file.entity";
|
|
3
|
+
|
|
4
|
+
@Entity()
|
|
5
|
+
export class EntityFile extends BaseEntity {
|
|
6
|
+
@PrimaryGeneratedColumn("uuid")
|
|
7
|
+
id: string;
|
|
8
|
+
|
|
9
|
+
@Column("uuid")
|
|
10
|
+
entityId: string; // ID de la entidad asociada
|
|
11
|
+
|
|
12
|
+
@Column()
|
|
13
|
+
entityType: string; // Tipo de la entidad asociada (p.ej. 'User', 'Poliza', 'Contact', 'Company')
|
|
14
|
+
|
|
15
|
+
@Column()
|
|
16
|
+
fileId: string; // ID del archivo asociado
|
|
17
|
+
|
|
18
|
+
@Column({ nullable: true })
|
|
19
|
+
relation: string; // Descripción o tipo de relación (opcional)
|
|
20
|
+
|
|
21
|
+
@ManyToOne(() => File, file => file.owners, {
|
|
22
|
+
onDelete: "CASCADE",
|
|
23
|
+
onUpdate: "CASCADE",
|
|
24
|
+
})
|
|
25
|
+
public file: File;
|
|
26
|
+
}
|