easywork-common-lib 1.0.7 → 1.0.9

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.
@@ -0,0 +1,13 @@
1
+ import { BaseEntity } from "../../common/database";
2
+ import { Folder } from "./folder.entity";
3
+ import { EntityFile } from "../helpers/entity_file.entity";
4
+ export declare class File extends BaseEntity {
5
+ name: string;
6
+ folder: Folder;
7
+ url: string;
8
+ size: number;
9
+ mimeType: string;
10
+ s3Key: string;
11
+ isDefault: boolean;
12
+ owners?: EntityFile[];
13
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.File = void 0;
13
+ const database_1 = require("../../common/database");
14
+ const class_validator_1 = require("class-validator");
15
+ const typeorm_1 = require("typeorm");
16
+ const folder_entity_1 = require("./folder.entity");
17
+ const entity_file_entity_1 = require("../helpers/entity_file.entity");
18
+ let File = class File extends database_1.BaseEntity {
19
+ name;
20
+ folder;
21
+ url;
22
+ size;
23
+ mimeType;
24
+ s3Key;
25
+ isDefault;
26
+ owners;
27
+ };
28
+ exports.File = File;
29
+ __decorate([
30
+ (0, class_validator_1.MinLength)(1),
31
+ __metadata("design:type", String)
32
+ ], File.prototype, "name", void 0);
33
+ __decorate([
34
+ (0, typeorm_1.OneToOne)(() => folder_entity_1.Folder, {
35
+ onDelete: "CASCADE",
36
+ onUpdate: "CASCADE",
37
+ }),
38
+ (0, typeorm_1.JoinColumn)(),
39
+ __metadata("design:type", folder_entity_1.Folder)
40
+ ], File.prototype, "folder", void 0);
41
+ __decorate([
42
+ (0, typeorm_1.Column)({ nullable: true }),
43
+ __metadata("design:type", String)
44
+ ], File.prototype, "url", void 0);
45
+ __decorate([
46
+ (0, typeorm_1.Column)({ nullable: true }),
47
+ __metadata("design:type", Number)
48
+ ], File.prototype, "size", void 0);
49
+ __decorate([
50
+ (0, typeorm_1.Column)({ type: "bigint", nullable: true }),
51
+ __metadata("design:type", String)
52
+ ], File.prototype, "mimeType", void 0);
53
+ __decorate([
54
+ (0, typeorm_1.Column)({ nullable: true }),
55
+ __metadata("design:type", String)
56
+ ], File.prototype, "s3Key", void 0);
57
+ __decorate([
58
+ (0, typeorm_1.Column)({ default: false }),
59
+ __metadata("design:type", Boolean)
60
+ ], File.prototype, "isDefault", void 0);
61
+ __decorate([
62
+ (0, typeorm_1.OneToMany)(() => entity_file_entity_1.EntityFile, (EntityFile) => EntityFile.file, {
63
+ onDelete: "CASCADE",
64
+ onUpdate: "CASCADE",
65
+ eager: true,
66
+ }),
67
+ __metadata("design:type", Array)
68
+ ], File.prototype, "owners", void 0);
69
+ exports.File = File = __decorate([
70
+ (0, typeorm_1.Entity)()
71
+ ], File);
72
+ //# sourceMappingURL=file.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.entity.js","sourceRoot":"","sources":["../../../src/entities/drive/file.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAmD;AACnD,qDAA4C;AAC5C,qCAA0E;AAC1E,mDAAyC;AACzC,sEAA2D;AAGpD,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,qBAAU;IAEhC,IAAI,CAAS;IAOb,MAAM,CAAS;IAGf,GAAG,CAAS;IAGZ,IAAI,CAAS;IAGb,QAAQ,CAAS;IAGjB,KAAK,CAAS;IAGd,SAAS,CAAU;IAOnB,MAAM,CAAgB;CACzB,CAAA;AAhCY,oBAAI;AAEb;IADC,IAAA,2BAAS,EAAC,CAAC,CAAC;;kCACA;AAOb;IALC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,sBAAM,EAAE;QACpB,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,SAAS;KACtB,CAAC;IACD,IAAA,oBAAU,GAAE;8BACL,sBAAM;oCAAC;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iCACf;AAGZ;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kCACd;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCAC1B;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mCACb;AAGd;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;uCACR;AAOnB;IALC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,+BAAU,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE;QAC1D,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,SAAS;QACnB,KAAK,EAAE,IAAI;KACd,CAAC;;oCACoB;eA/Bb,IAAI;IADhB,IAAA,gBAAM,GAAE;GACI,IAAI,CAgChB"}
@@ -1,5 +1,5 @@
1
1
  import { BaseEntity } from "../../common/database";
2
2
  export declare class Folder extends BaseEntity {
3
3
  name: string;
4
- isDefault: boolean;
4
+ parent: Folder;
5
5
  }
@@ -15,7 +15,7 @@ const class_validator_1 = require("class-validator");
15
15
  const typeorm_1 = require("typeorm");
16
16
  let Folder = class Folder extends database_1.BaseEntity {
17
17
  name;
18
- isDefault;
18
+ parent;
19
19
  };
20
20
  exports.Folder = Folder;
21
21
  __decorate([
@@ -24,9 +24,13 @@ __decorate([
24
24
  __metadata("design:type", String)
25
25
  ], Folder.prototype, "name", void 0);
26
26
  __decorate([
27
- (0, typeorm_1.Column)({ default: false }),
28
- __metadata("design:type", Boolean)
29
- ], Folder.prototype, "isDefault", void 0);
27
+ (0, typeorm_1.OneToOne)(() => Folder, {
28
+ onDelete: "CASCADE",
29
+ onUpdate: "CASCADE",
30
+ }),
31
+ (0, typeorm_1.JoinColumn)(),
32
+ __metadata("design:type", Folder)
33
+ ], Folder.prototype, "parent", void 0);
30
34
  exports.Folder = Folder = __decorate([
31
35
  (0, typeorm_1.Entity)()
32
36
  ], Folder);
@@ -1 +1 @@
1
- {"version":3,"file":"folder.entity.js","sourceRoot":"","sources":["../../../src/entities/drive/folder.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAmD;AACnD,qDAA4C;AAC5C,qCAAyC;AAGlC,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,qBAAU;IAGlC,IAAI,CAAS;IAGb,SAAS,CAAU;CACtB,CAAA;AAPY,wBAAM;AAGf;IAFC,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;oCACZ;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;yCACR;iBANV,MAAM;IADlB,IAAA,gBAAM,GAAE;GACI,MAAM,CAOlB"}
1
+ {"version":3,"file":"folder.entity.js","sourceRoot":"","sources":["../../../src/entities/drive/folder.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAmD;AACnD,qDAA4C;AAC5C,qCAA+D;AAGxD,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,qBAAU;IAGlC,IAAI,CAAS;IAOb,MAAM,CAAS;CAClB,CAAA;AAXY,wBAAM;AAGf;IAFC,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;oCACZ;AAOb;IALC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE;QACpB,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,SAAS;KACtB,CAAC;IACD,IAAA,oBAAU,GAAE;8BACL,MAAM;sCAAC;iBAVN,MAAM;IADlB,IAAA,gBAAM,GAAE;GACI,MAAM,CAWlB"}
@@ -0,0 +1,10 @@
1
+ import { BaseEntity } from "typeorm";
2
+ import { File } from "../drive/file.entity";
3
+ export declare class EntityFile extends BaseEntity {
4
+ id: string;
5
+ entityId: string;
6
+ entityType: string;
7
+ fileId: string;
8
+ relation: string;
9
+ file: File;
10
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EntityFile = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const file_entity_1 = require("../drive/file.entity");
15
+ let EntityFile = class EntityFile extends typeorm_1.BaseEntity {
16
+ id;
17
+ entityId;
18
+ entityType;
19
+ fileId;
20
+ relation;
21
+ file;
22
+ };
23
+ exports.EntityFile = EntityFile;
24
+ __decorate([
25
+ (0, typeorm_1.PrimaryGeneratedColumn)("uuid"),
26
+ __metadata("design:type", String)
27
+ ], EntityFile.prototype, "id", void 0);
28
+ __decorate([
29
+ (0, typeorm_1.Column)("uuid"),
30
+ __metadata("design:type", String)
31
+ ], EntityFile.prototype, "entityId", void 0);
32
+ __decorate([
33
+ (0, typeorm_1.Column)(),
34
+ __metadata("design:type", String)
35
+ ], EntityFile.prototype, "entityType", void 0);
36
+ __decorate([
37
+ (0, typeorm_1.Column)(),
38
+ __metadata("design:type", String)
39
+ ], EntityFile.prototype, "fileId", void 0);
40
+ __decorate([
41
+ (0, typeorm_1.Column)({ nullable: true }),
42
+ __metadata("design:type", String)
43
+ ], EntityFile.prototype, "relation", void 0);
44
+ __decorate([
45
+ (0, typeorm_1.ManyToOne)(() => file_entity_1.File, file => file.owners, {
46
+ onDelete: "CASCADE",
47
+ onUpdate: "CASCADE",
48
+ }),
49
+ __metadata("design:type", file_entity_1.File)
50
+ ], EntityFile.prototype, "file", void 0);
51
+ exports.EntityFile = EntityFile = __decorate([
52
+ (0, typeorm_1.Entity)()
53
+ ], EntityFile);
54
+ //# sourceMappingURL=entity_file.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity_file.entity.js","sourceRoot":"","sources":["../../../src/entities/helpers/entity_file.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwF;AACxF,sDAA4C;AAGrC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,oBAAU;IAExC,EAAE,CAAS;IAGX,QAAQ,CAAS;IAGjB,UAAU,CAAS;IAGnB,MAAM,CAAS;IAGf,QAAQ,CAAS;IAMV,IAAI,CAAO;CACnB,CAAA;AArBY,gCAAU;AAErB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;sCACpB;AAGX;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;;4CACE;AAGjB;IADC,IAAA,gBAAM,GAAE;;8CACU;AAGnB;IADC,IAAA,gBAAM,GAAE;;0CACM;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACV;AAMV;IAJN,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE;QAC1C,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,SAAS;KACpB,CAAC;8BACW,kBAAI;wCAAC;qBApBP,UAAU;IADtB,IAAA,gBAAM,GAAE;GACI,UAAU,CAqBtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easywork-common-lib",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Librería común de Easywork",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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
- @Column({ default: false })
12
- isDefault: boolean;
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
+ }