test-entity-library-asm 1.0.0

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/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # test-entity-library-asm
2
+ Test de librería para probar las entidades de la base de datos asumano
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "test-entity-library-asm",
3
+ "version": "1.0.0",
4
+ "description": "Entidades de ejemplo para una base de datos",
5
+ "main": "index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC",
13
+ "dependencies": {
14
+ "typeorm": "^0.3.20"
15
+ },
16
+ "devDependencies": {
17
+ "@types/node": "^20.12.7",
18
+ "typescript": "^5.4.5"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/jesusgomez461/test-entity-library-asm"
23
+ },
24
+ "homepage": "https://github.com/jesusgomez461/test-entity-library-asm"
25
+ }
@@ -0,0 +1,21 @@
1
+ import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm';
2
+ import { Local } from './Local';
3
+
4
+ @Entity()
5
+ export class Category {
6
+ @PrimaryGeneratedColumn()
7
+ id: number;
8
+
9
+ @Column()
10
+ localId: number;
11
+
12
+ @Column({ length: 30 })
13
+ name: string;
14
+
15
+ @Column()
16
+ position: number;
17
+
18
+ @ManyToOne(() => Local)
19
+ @JoinColumn({ name: 'localId' })
20
+ local: Local;
21
+ }
@@ -0,0 +1,37 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { Region } from './Region'
10
+ import { User } from './User'
11
+ import { Company } from './Company'
12
+ import { Local } from './Local'
13
+
14
+ @Entity()
15
+ export class City {
16
+ @PrimaryGeneratedColumn()
17
+ id: number
18
+
19
+ @Column({ length: 50 })
20
+ name: string
21
+
22
+ @ManyToOne(() => Region, (region) => region.cities)
23
+ @JoinColumn({ name: 'region' })
24
+ region: Region
25
+
26
+ @Column({ default: 1 })
27
+ status: number
28
+
29
+ @OneToMany(() => User, (user) => user.city)
30
+ users: User[]
31
+
32
+ @OneToMany(() => Company, (Company) => Company.city)
33
+ companies: Company[]
34
+
35
+ @OneToMany(() => Local, (local) => local.city)
36
+ locals: Local[]
37
+ }
@@ -0,0 +1,35 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ } from 'typeorm'
8
+ import { DiscountCodeCompany } from './DiscountCodeCompany'
9
+ import { Company } from './Company'
10
+
11
+ @Entity('code_redemption_history_company')
12
+ export class CodeRedemptionHistoryCompany {
13
+ @PrimaryGeneratedColumn()
14
+ id: number
15
+
16
+ @ManyToOne(
17
+ () => DiscountCodeCompany,
18
+ (company) => company.code_redemptions_history_company
19
+ )
20
+ @JoinColumn({ name: 'discount_code_company' })
21
+ discount_code_company: DiscountCodeCompany
22
+
23
+ @ManyToOne(
24
+ () => Company,
25
+ (company) => company.code_redemption_history_company
26
+ )
27
+ @JoinColumn({ name: 'company' })
28
+ company: Company
29
+
30
+ @Column({ type: 'datetime' })
31
+ dateUsed: Date
32
+
33
+ @Column({ length: 10 })
34
+ discountApplied: string
35
+ }
@@ -0,0 +1,32 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ } from 'typeorm'
8
+ import { User } from './User'
9
+ import { DiscountCodeUser } from './DiscountCodeUser'
10
+
11
+ @Entity('code_redemption_history_user')
12
+ export class CodeRedemptionHistoryUser {
13
+ @PrimaryGeneratedColumn()
14
+ id: number
15
+
16
+ @ManyToOne(
17
+ () => DiscountCodeUser,
18
+ (discountCodeUser) => discountCodeUser.code_redemptions_history_users
19
+ )
20
+ @JoinColumn({ name: 'discount_code_user' })
21
+ discount_code_user: DiscountCodeUser
22
+
23
+ @ManyToOne(() => User, (user) => user.code_redemption_history_users)
24
+ @JoinColumn({ name: 'user' })
25
+ user: User
26
+
27
+ @Column({ type: 'datetime' })
28
+ date_used: Date
29
+
30
+ @Column({ length: 10 })
31
+ discount_applied: string
32
+ }
@@ -0,0 +1,113 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ ManyToMany,
8
+ JoinTable,
9
+ OneToMany,
10
+ } from 'typeorm'
11
+ import { City } from './City'
12
+ import { User } from './User'
13
+ import { Plan } from './Plan'
14
+ import { TypeFood } from './TypeFood'
15
+ import { Local } from './Local'
16
+ import { CodeRedemptionHistoryCompany } from './CodeRedemptionHistoryCompany'
17
+ import { DiscountCodeUser } from './DiscountCodeUser'
18
+ import { ProductTopping } from './ProductTopping'
19
+
20
+ @Entity()
21
+ export class Company {
22
+ @PrimaryGeneratedColumn()
23
+ id: number
24
+
25
+ @Column({ length: 50 })
26
+ name: string
27
+
28
+ @ManyToOne(() => City, (city) => city.companies)
29
+ @JoinColumn({ name: 'city' })
30
+ city: City
31
+
32
+ @ManyToOne(() => User, (city) => city.companies)
33
+ @JoinColumn({ name: 'user' })
34
+ user: User
35
+
36
+ @Column({
37
+ type: 'longtext',
38
+ nullable: true,
39
+ comment:
40
+ 'Campo de tipo JSON donde se guarda información necesaria para la empresa',
41
+ })
42
+ profile: string
43
+
44
+ @Column({ default: 1 })
45
+ quantity_locals: number
46
+
47
+ @Column({ default: 6 })
48
+ quantity_users: number
49
+
50
+ @Column({
51
+ type: 'longtext',
52
+ nullable: true,
53
+ comment:
54
+ 'Información de tipo JSON donde se guarda la información legal de la empresa',
55
+ })
56
+ legal_information: string
57
+
58
+ @Column({
59
+ type: 'longtext',
60
+ nullable: true,
61
+ comment:
62
+ 'Información de tipo JSON donde se guarda la información del representante legal del representante',
63
+ })
64
+ legal_agent: string
65
+
66
+ @ManyToOne(() => Plan, (plan) => plan.companies)
67
+ @JoinColumn({ name: 'plan' })
68
+ plan: Plan
69
+
70
+ @Column({ type: 'datetime' })
71
+ created: Date
72
+
73
+ @Column({ type: 'date', nullable: true })
74
+ expiration: Date
75
+
76
+ @Column({ type: 'datetime' })
77
+ updated: Date
78
+
79
+ @Column({ default: 1 })
80
+ status: number
81
+
82
+ @ManyToMany(() => TypeFood)
83
+ @JoinTable({
84
+ name: 'type_food_company',
85
+ joinColumn: {
86
+ name: 'company',
87
+ referencedColumnName: 'id',
88
+ },
89
+ inverseJoinColumn: {
90
+ name: 'type_food',
91
+ referencedColumnName: 'id',
92
+ },
93
+ })
94
+ types_food: TypeFood[]
95
+
96
+ @OneToMany(() => Local, (local) => local.company)
97
+ locals: Local[]
98
+
99
+ @OneToMany(
100
+ () => CodeRedemptionHistoryCompany,
101
+ (codeRedemptionHistoryCompany) => codeRedemptionHistoryCompany.company
102
+ )
103
+ code_redemption_history_company: CodeRedemptionHistoryCompany[]
104
+
105
+ @OneToMany(
106
+ () => DiscountCodeUser,
107
+ (discountCodeUser) => discountCodeUser.company
108
+ )
109
+ discount_code_users: DiscountCodeUser[]
110
+
111
+ @OneToMany(() => ProductTopping, (productTopping) => productTopping.company)
112
+ product_toppings: ProductTopping[]
113
+ }
@@ -0,0 +1,14 @@
1
+ import { Entity, Column, PrimaryColumn } from 'typeorm'
2
+
3
+ @Entity()
4
+ export class Configuration {
5
+ @PrimaryColumn({ length: 20 })
6
+ profile: string
7
+
8
+ @Column({
9
+ type: 'longtext',
10
+ comment:
11
+ 'Columna de tipo JSON para agregar la información y configuración respecto a la plataforma.',
12
+ })
13
+ settings: string
14
+ }
@@ -0,0 +1,44 @@
1
+ import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm'
2
+ import { Region } from './Region'
3
+
4
+ @Entity()
5
+ export class Country {
6
+ @PrimaryGeneratedColumn()
7
+ id: number
8
+
9
+ @Column({ length: 10 })
10
+ code: string
11
+
12
+ @Column({ length: 50 })
13
+ name: string
14
+
15
+ @Column({
16
+ length: 10,
17
+ comment:
18
+ 'Usamos esta columna para saber la moneda del país y sugerírsela al usuario o al local',
19
+ })
20
+ currency: string
21
+
22
+ @Column({ length: 10 })
23
+ prefix: string
24
+
25
+ @Column({
26
+ type: 'longtext',
27
+ comment:
28
+ 'Esta columna de tipo JSON nos sirve para agregar toda la información que se necesita a nivel de información legal de la empresa que se registre, ya que para cada país cambia la información',
29
+ })
30
+ legal_information: string
31
+
32
+ @Column({
33
+ type: 'longtext',
34
+ comment:
35
+ 'Columna de tipo JSON para almacenar la información que se necesita para la información del representante legal de la empresa',
36
+ })
37
+ legal_agent: string
38
+
39
+ @Column({ default: 1 })
40
+ status: number
41
+
42
+ @OneToMany(() => Region, (region) => region.country)
43
+ regions: Region[]
44
+ }
@@ -0,0 +1,13 @@
1
+ import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'
2
+
3
+ @Entity()
4
+ export class Day {
5
+ @PrimaryGeneratedColumn()
6
+ id: number
7
+
8
+ @Column({ length: 50 })
9
+ name: string
10
+
11
+ @Column({ default: 1 })
12
+ status: number
13
+ }
@@ -0,0 +1,59 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { User } from './User'
10
+ import { CodeRedemptionHistoryCompany } from './CodeRedemptionHistoryCompany'
11
+
12
+ @Entity('discount_code_company')
13
+ export class DiscountCodeCompany {
14
+ @PrimaryGeneratedColumn()
15
+ id: number
16
+
17
+ @Column({ length: 10 })
18
+ code: string
19
+
20
+ @Column({ length: 10 })
21
+ discount: string
22
+
23
+ @Column({
24
+ default: 1,
25
+ comment:
26
+ 'Campo para el tipo de descuento:\r\n1. Porcentaje.\r\n2. Valor en moneda.',
27
+ })
28
+ type: number
29
+
30
+ @Column({
31
+ default: 1,
32
+ comment:
33
+ 'Con esto validamos si la empresa puede usar el código una vez o varias veces:\r\n1. Una sola vez.\r\n0. Más de una vez.\r\n\r\nCon esto validamos sí tenemos qué ir a buscar a la tabla code_redemption_history_company',
34
+ })
35
+ single_use: number
36
+
37
+ @Column({ type: 'datetime' })
38
+ created: Date
39
+
40
+ @Column({ type: 'date' })
41
+ expiration: Date
42
+
43
+ @Column({ type: 'datetime' })
44
+ updated: Date
45
+
46
+ @Column({ default: 1 })
47
+ status: number
48
+
49
+ @ManyToOne(() => User, (user) => user.discount_code_companies)
50
+ @JoinColumn({ name: 'update_by' })
51
+ updated_by: User
52
+
53
+ @OneToMany(
54
+ () => CodeRedemptionHistoryCompany,
55
+ (codeRedemptionHistoryCompany) =>
56
+ codeRedemptionHistoryCompany.discount_code_company
57
+ )
58
+ code_redemptions_history_company: CodeRedemptionHistoryCompany[]
59
+ }
@@ -0,0 +1,63 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { User } from './User'
10
+ import { Company } from './Company'
11
+ import { CodeRedemptionHistoryUser } from './CodeRedemptionHistoryUser'
12
+
13
+ @Entity('discount_code_user')
14
+ export class DiscountCodeUser {
15
+ @PrimaryGeneratedColumn()
16
+ id: number
17
+
18
+ @ManyToOne(() => Company, (company) => company.discount_code_users)
19
+ @JoinColumn({ name: 'company' })
20
+ company: Company
21
+
22
+ @Column({ length: 10 })
23
+ code: string
24
+
25
+ @Column({ length: 10 })
26
+ discount: string
27
+
28
+ @Column({
29
+ comment:
30
+ 'Campo para el tipo de descuento: \r\n1. Porcentaje.\r\n2. Valor en moneda.',
31
+ })
32
+ type: number
33
+
34
+ @Column({
35
+ default: 1,
36
+ comment:
37
+ 'Con esto validamos si la empresa puede usar el código una vez o varias veces:\r\n1. Una sola vez.\r\n0. Más de una vez.\r\n\r\nCon esto validamos sí tenemos que ir a buscar a la tabla code_redemption_history_user',
38
+ })
39
+ single_use: number
40
+
41
+ @Column({ type: 'datetime' })
42
+ created: Date
43
+
44
+ @Column({ type: 'date' })
45
+ expiration: Date
46
+
47
+ @ManyToOne(() => User, (user) => user.discount_code_users)
48
+ @JoinColumn({ name: 'updated_by' })
49
+ updated_by: User
50
+
51
+ @Column({ type: 'datetime' })
52
+ updated: Date
53
+
54
+ @Column({ default: 1 })
55
+ status: number
56
+
57
+ @OneToMany(
58
+ () => CodeRedemptionHistoryUser,
59
+ (codeRedemptionHistoryUser) =>
60
+ codeRedemptionHistoryUser.discount_code_user
61
+ )
62
+ code_redemptions_history_users: CodeRedemptionHistoryUser[]
63
+ }
@@ -0,0 +1,86 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ ManyToMany,
8
+ JoinTable,
9
+ OneToMany,
10
+ } from 'typeorm'
11
+ import { Company } from './Company'
12
+ import { City } from './City'
13
+ import { User } from './User'
14
+ import { Product } from './Product'
15
+
16
+ @Entity()
17
+ export class Local {
18
+ @PrimaryGeneratedColumn()
19
+ id: number
20
+
21
+ @ManyToOne(() => Company, (company) => company.locals)
22
+ @JoinColumn({ name: 'company' })
23
+ company: Company
24
+
25
+ @Column({ length: 100 })
26
+ name: string
27
+
28
+ @ManyToOne(() => City, (city) => city.locals)
29
+ @JoinColumn({ name: 'city' })
30
+ city: City
31
+
32
+ @Column({ length: 120 })
33
+ address: string
34
+
35
+ @Column({ type: 'decimal', precision: 10, scale: 8 })
36
+ latitude: number
37
+
38
+ @Column({ type: 'decimal', precision: 10, scale: 8 })
39
+ longitude: number
40
+
41
+ @Column({
42
+ type: 'longtext',
43
+ nullable: true,
44
+ comment:
45
+ 'Campo de tipo JSON por si es necesario agregar información adicional',
46
+ })
47
+ details: string
48
+
49
+ @Column({ type: 'datetime' })
50
+ created: Date
51
+
52
+ @Column({ type: 'datetime' })
53
+ updated: Date
54
+
55
+ @ManyToOne(() => User, (user) => user.locals)
56
+ @JoinColumn({ name: 'update_by' })
57
+ updated_by: User
58
+
59
+ @Column({
60
+ type: 'int',
61
+ default: 0,
62
+ comment:
63
+ 'Me indica si el local está en una plazoleta o no:\r\n1. Plazoleta.\r\n0. No plazoleta.',
64
+ })
65
+ square: number
66
+
67
+ @Column({ default: 1 })
68
+ status: number
69
+
70
+ @ManyToMany(() => User)
71
+ @JoinTable({
72
+ name: 'local_user',
73
+ joinColumn: {
74
+ name: 'user',
75
+ referencedColumnName: 'id',
76
+ },
77
+ inverseJoinColumn: {
78
+ name: 'local',
79
+ referencedColumnName: 'id',
80
+ },
81
+ })
82
+ users: User[]
83
+
84
+ @OneToMany(() => Product, (product) => product.local)
85
+ products: Product[]
86
+ }
@@ -0,0 +1,15 @@
1
+ import { Entity, Column, PrimaryColumn, ManyToOne, JoinColumn } from 'typeorm'
2
+ import { User } from './User'
3
+
4
+ @Entity()
5
+ export class Master {
6
+ @PrimaryColumn()
7
+ id: number
8
+
9
+ @ManyToOne(() => User, (user) => user.masters)
10
+ @JoinColumn({ name: 'user' })
11
+ user: User
12
+
13
+ @Column({ default: 1 })
14
+ status: number
15
+ }
@@ -0,0 +1,40 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToMany,
6
+ JoinTable,
7
+ } from 'typeorm'
8
+ import { Role } from './Role'
9
+
10
+ @Entity()
11
+ export class Permission {
12
+ @PrimaryGeneratedColumn()
13
+ id: number
14
+
15
+ @Column({ length: 10, unique: true })
16
+ code: string
17
+
18
+ @Column({
19
+ length: 40,
20
+ comment:
21
+ 'Id de la variable que se encuentra en los archivos "locale" para el multilenguaje.',
22
+ })
23
+ name: string
24
+
25
+ @Column({
26
+ length: 40,
27
+ comment:
28
+ 'Id de la variable que se encuentra en los archivos "locale" para el multilenguaje.',
29
+ })
30
+ description: string
31
+
32
+ @Column({ default: 1 })
33
+ status: number
34
+
35
+ @ManyToMany(() => Role)
36
+ @JoinTable({
37
+ name: 'role_permission',
38
+ })
39
+ roles: Role[]
40
+ }
@@ -0,0 +1,57 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { User } from './User'
10
+ import { Company } from './Company'
11
+
12
+ @Entity()
13
+ export class Plan {
14
+ @PrimaryGeneratedColumn()
15
+ id: number
16
+
17
+ @Column({ length: 20, unique: true })
18
+ code: string
19
+
20
+ @Column({
21
+ length: 50,
22
+ comment:
23
+ 'Id de la variable que se encuentra en los archivos "locale" para el multilenguaje.',
24
+ })
25
+ name: string
26
+
27
+ @Column({
28
+ type: 'mediumtext',
29
+ nullable: true,
30
+ comment:
31
+ 'Campo de tipo JSON donde se guarda información necesaria para el plan',
32
+ })
33
+ description: string
34
+
35
+ @Column({
36
+ default: 0,
37
+ comment:
38
+ 'Con este campo sabemos sí el plan es o no es personalizado para una empresa en específico.\r\n1. Personalizado.\r\n0. No personalizado.',
39
+ })
40
+ customized: number
41
+
42
+ @Column({ type: 'datetime' })
43
+ created: Date
44
+
45
+ @Column({ type: 'date' })
46
+ expiration: Date
47
+
48
+ @ManyToOne(() => User, (user) => user.plans, { nullable: true })
49
+ @JoinColumn({ name: 'created_by' })
50
+ created_by: User
51
+
52
+ @Column({ default: 1 })
53
+ status: number
54
+
55
+ @OneToMany(() => Company, (company) => company.plan)
56
+ companies: Company[]
57
+ }
@@ -0,0 +1,64 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { Local } from './Local'
10
+ import { ProductGroup } from './ProductGroup'
11
+
12
+ @Entity()
13
+ export class Product {
14
+ @PrimaryGeneratedColumn()
15
+ id: number
16
+
17
+ @ManyToOne(() => Local, (local) => local.products)
18
+ @JoinColumn({ name: 'local' })
19
+ local: Local
20
+
21
+ @Column({ length: 50 })
22
+ name: string
23
+
24
+ @Column({ length: 400 })
25
+ details: string
26
+
27
+ @Column({ length: 20 })
28
+ price: string
29
+
30
+ @Column({
31
+ default: 0,
32
+ comment:
33
+ '¿El producto cuenta con restricción de edad?\r\n1. Cuenta con restricción.\r\n0. No cuenta con restricción.',
34
+ })
35
+ age_restriction: number
36
+
37
+ @Column({
38
+ default: 0,
39
+ comment: '¿El producto es un combo?\r\n1. Combo.\r\n0. No es un combo.',
40
+ })
41
+ combo: number
42
+
43
+ @Column()
44
+ position: number
45
+
46
+ @Column({
47
+ type: 'text',
48
+ nullable: true,
49
+ comment: 'Campo de tipo json para guardar el id y la url de la foto',
50
+ })
51
+ photo: string
52
+
53
+ @Column({ type: 'mediumtext', nullable: true })
54
+ additional_information: string
55
+
56
+ @Column({ type: 'datetime' })
57
+ created: Date
58
+
59
+ @Column({ type: 'datetime' })
60
+ updated: Date
61
+
62
+ @OneToMany(() => ProductGroup, (productGroup) => productGroup.product)
63
+ product_groups: ProductGroup[]
64
+ }
@@ -0,0 +1,62 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { Product } from './Product'
10
+ import { ProductTopping } from './ProductTopping'
11
+ import { ProductGroupComplement } from './productGroupComplement'
12
+
13
+ @Entity('product_group', {
14
+ comment: 'Grupos para agregar al topping por producto',
15
+ })
16
+ export class ProductGroup {
17
+ @PrimaryGeneratedColumn()
18
+ id: number
19
+
20
+ @ManyToOne(() => Product, (product) => product.product_groups)
21
+ @JoinColumn({ name: 'product' })
22
+ product: Product
23
+
24
+ @ManyToOne(
25
+ () => ProductTopping,
26
+ (productTopping) => productTopping.product_groups
27
+ )
28
+ @JoinColumn({ name: 'topping' })
29
+ topping: ProductTopping
30
+
31
+ @Column({ length: 30 })
32
+ name: string
33
+
34
+ @Column({
35
+ default: 1,
36
+ comment:
37
+ 'El "type" se refiere a si el grupo es opcional o si es requerido:\r\n1. Opcional.\r\n2. Requerido.',
38
+ })
39
+ type: number
40
+
41
+ @Column({
42
+ default: 0,
43
+ comment:
44
+ 'Cantidad mínima que el usuario puede agregar para el grupo.\r\n\r\n- Cuando "type" es "Requerido (2)" entonces la cantidad mínima debería ser 1.\r\n\r\n- Cuando "type" es "Opcional (1)" entonces la cantidad puede ser 0.',
45
+ })
46
+ minimum_quantity: number
47
+
48
+ @Column({
49
+ default: 0,
50
+ comment: 'Cantidad máxima que el usuario puede agregar para el grupo.',
51
+ })
52
+ maximum_quantity: number
53
+
54
+ @Column()
55
+ position: number
56
+
57
+ @OneToMany(
58
+ () => ProductGroupComplement,
59
+ (productGroupComplement) => productGroupComplement.group_id
60
+ )
61
+ groups_complement: ProductGroupComplement[]
62
+ }
@@ -0,0 +1,36 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { Company } from './Company'
10
+ import { ProductGroup } from './ProductGroup'
11
+
12
+ @Entity('product_topping', {
13
+ comment:
14
+ 'Tabla para crear toppings y poder agregarlos a los productos, hay toppings que ya están creados para que el usuario no tenga qué agregarlos, o que el usuario pueda agregar sus propios toppings.',
15
+ })
16
+ export class ProductTopping {
17
+ @PrimaryGeneratedColumn()
18
+ id: number
19
+
20
+ @ManyToOne(() => Company, (company) => company.product_toppings)
21
+ @JoinColumn({ name: 'company' })
22
+ company: Company
23
+
24
+ @Column({
25
+ length: 50,
26
+ comment:
27
+ 'El "name" se refiere al id de los archivos de lenguaje que está en "locale" del proyecto. Esto se hace para qué sirva el multilenguaje en el proyecto. Cabe recalcar qué las empresas pueden crear sus propios toppings, entonces no pasa nada el lenguaje en el que ellos lo escriban.',
28
+ })
29
+ name: string
30
+
31
+ @Column({ default: 1 })
32
+ status: number
33
+
34
+ @OneToMany(() => ProductGroup, (productGroup) => productGroup.topping)
35
+ product_groups: ProductGroup[]
36
+ }
@@ -0,0 +1,29 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { Country } from './Country'
10
+ import { City } from './City'
11
+
12
+ @Entity()
13
+ export class Region {
14
+ @PrimaryGeneratedColumn()
15
+ id: number
16
+
17
+ @Column({ length: 50 })
18
+ name: string
19
+
20
+ @ManyToOne(() => Country, (country) => country.regions)
21
+ @JoinColumn({ name: 'country' })
22
+ country: Country
23
+
24
+ @Column({ default: 1 })
25
+ status: number
26
+
27
+ @OneToMany(() => City, (city) => city.region)
28
+ cities: City[]
29
+ }
@@ -0,0 +1,57 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToMany,
6
+ JoinTable,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { Permission } from './Permission'
10
+ import { RoleVisibleTo } from './RoleVisibleTo'
11
+
12
+ @Entity()
13
+ export class Role {
14
+ @PrimaryGeneratedColumn()
15
+ id: number
16
+
17
+ @Column({ length: 10 })
18
+ code: string
19
+
20
+ @Column({
21
+ length: 40,
22
+ comment:
23
+ 'Id de la variable que se encuentra en los archivos "locale" para el multilenguaje.\r\n\r\nCabe recordar qué los usuarios también pueden crear roles, estos deben ir normal, sin id para el lenguaje.',
24
+ })
25
+ name: string
26
+
27
+ @Column({
28
+ length: 40,
29
+ nullable: true,
30
+ comment:
31
+ 'Id de la variable que se encuentra en los archivos "locale" para el multilenguaje.\r\n\r\nCabe recordar qué los usuarios también pueden crear roles, estos deben ir normal, sin id para el lenguaje.',
32
+ })
33
+ description: string | null
34
+
35
+ @Column({ default: 1 })
36
+ status: number
37
+
38
+ @ManyToMany(() => Permission)
39
+ @JoinTable({
40
+ name: 'role_permission',
41
+ joinColumn: {
42
+ name: 'permission',
43
+ referencedColumnName: 'id',
44
+ },
45
+ inverseJoinColumn: {
46
+ name: 'role',
47
+ referencedColumnName: 'id',
48
+ },
49
+ })
50
+ permissions: Permission[]
51
+
52
+ @OneToMany(() => RoleVisibleTo, (roleVisibleTo) => roleVisibleTo.role)
53
+ rolesVisibleTo: RoleVisibleTo[]
54
+
55
+ @OneToMany(() => RoleVisibleTo, (roleVisibleTo) => roleVisibleTo.visible_to)
56
+ visiblesTo: RoleVisibleTo[]
57
+ }
@@ -0,0 +1,25 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ } from 'typeorm'
8
+ import { Role } from './Role'
9
+
10
+ @Entity('role_visible_to', {
11
+ comment:
12
+ 'Con esta tabla validamos cuales son los roles que puede agregar a otros usuarios qué roles',
13
+ })
14
+ export class RoleVisibleTo {
15
+ @PrimaryGeneratedColumn()
16
+ id: number
17
+
18
+ @ManyToOne(() => Role, (role) => role.rolesVisibleTo)
19
+ @JoinColumn({ name: 'role' })
20
+ role: Role
21
+
22
+ @ManyToOne(() => Role, (role) => role.visiblesTo)
23
+ @JoinColumn({ name: 'visible_to' })
24
+ visible_to: Role
25
+ }
@@ -0,0 +1,32 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ } from 'typeorm'
8
+ import { Category } from './Category'
9
+ import { Day } from './Day'
10
+
11
+ @Entity('schedule_category', {
12
+ comment:
13
+ 'Acá podemos agregar los horarios para las categorías de los productos. O sea, si una categoría sólo está los miércoles, entonces podría agregar el día y los horarios.',
14
+ })
15
+ export class ScheduleCategory {
16
+ @PrimaryGeneratedColumn()
17
+ id: number
18
+
19
+ @ManyToOne(() => Category, { onDelete: 'CASCADE', onUpdate: 'NO ACTION' })
20
+ @JoinColumn({ name: 'category' })
21
+ category: Category
22
+
23
+ @ManyToOne(() => Day, { onDelete: 'CASCADE', onUpdate: 'NO ACTION' })
24
+ @JoinColumn({ name: 'day' })
25
+ day: Day
26
+
27
+ @Column()
28
+ start_time: string
29
+
30
+ @Column()
31
+ end_time: string
32
+ }
@@ -0,0 +1,47 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToMany,
6
+ JoinTable,
7
+ OneToMany,
8
+ } from 'typeorm'
9
+ import { User } from './User'
10
+ import { TerminalSession } from './TerminalSession'
11
+
12
+ @Entity()
13
+ export class Terminal {
14
+ @PrimaryGeneratedColumn()
15
+ id: number
16
+
17
+ @Column({ length: 50 })
18
+ name: string
19
+
20
+ @Column({
21
+ type: 'longtext',
22
+ nullable: true,
23
+ comment:
24
+ 'Campo de tipo JSON donde se guarda información necesaria para la terminal si es necesario',
25
+ })
26
+ settings: string
27
+
28
+ @Column({ default: 1 })
29
+ status: number
30
+
31
+ @ManyToMany(() => User)
32
+ @JoinTable({
33
+ name: 'user_terminal',
34
+ joinColumn: {
35
+ name: 'user',
36
+ referencedColumnName: 'id',
37
+ },
38
+ inverseJoinColumn: {
39
+ name: 'terminal',
40
+ referencedColumnName: 'id',
41
+ },
42
+ })
43
+ users: User[]
44
+
45
+ @OneToMany(() => TerminalSession, (terminalsUser) => terminalsUser.terminal)
46
+ terminalsUser: TerminalSession[]
47
+ }
@@ -0,0 +1,38 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ } from 'typeorm'
8
+ import { User } from './User'
9
+ import { Terminal } from './Terminal'
10
+
11
+ @Entity('terminal_session')
12
+ export class TerminalSession {
13
+ @PrimaryGeneratedColumn()
14
+ id: number
15
+
16
+ @ManyToOne(() => User, (user) => user.terminalUsers, { nullable: true })
17
+ @JoinColumn({ name: 'user' })
18
+ user: User
19
+
20
+ @ManyToOne(() => Terminal, (terminal) => terminal.terminalsUser, {
21
+ nullable: true,
22
+ })
23
+ @JoinColumn({ name: 'terminal' })
24
+ terminal: Terminal
25
+
26
+ @Column({ type: 'datetime' })
27
+ open: Date
28
+
29
+ @Column({ type: 'datetime' })
30
+ close: Date
31
+
32
+ @Column({
33
+ default: 1,
34
+ comment:
35
+ 'Se valida si la sesión está abierta o cerrada:\r\n1. Abierta.\r\n0. Cerrada.',
36
+ })
37
+ status: number
38
+ }
@@ -0,0 +1,26 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToMany,
6
+ JoinTable,
7
+ } from 'typeorm'
8
+ import { Company } from './Company'
9
+
10
+ @Entity('type_food')
11
+ export class TypeFood {
12
+ @PrimaryGeneratedColumn()
13
+ id: number
14
+
15
+ @Column({ length: 40 })
16
+ name: string
17
+
18
+ @Column({ default: 1 })
19
+ status: number
20
+
21
+ @ManyToMany(() => Company)
22
+ @JoinTable({
23
+ name: 'type_food_company',
24
+ })
25
+ companies: Company[]
26
+ }
@@ -0,0 +1,122 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ ManyToMany,
8
+ JoinTable,
9
+ OneToMany,
10
+ } from 'typeorm'
11
+ import { City } from './City'
12
+ import { Terminal } from './Terminal'
13
+ import { TerminalSession } from './TerminalSession'
14
+ import { Plan } from './Plan'
15
+ import { Company } from './Company'
16
+ import { Local } from './Local'
17
+ import { DiscountCodeCompany } from './DiscountCodeCompany'
18
+ import { DiscountCodeUser } from './DiscountCodeUser'
19
+ import { CodeRedemptionHistoryUser } from './CodeRedemptionHistoryUser'
20
+ import { Master } from './Master'
21
+
22
+ @Entity()
23
+ export class User {
24
+ @PrimaryGeneratedColumn()
25
+ id: number
26
+
27
+ @Column({ length: 30, unique: true })
28
+ code: string
29
+
30
+ @Column()
31
+ document: number
32
+
33
+ @Column({ length: 50 })
34
+ name: string
35
+
36
+ @Column({ length: 50 })
37
+ surname: string
38
+
39
+ @Column({ length: 60, unique: true })
40
+ email: string
41
+
42
+ @Column({ length: 12, unique: true })
43
+ phone: string
44
+
45
+ @ManyToOne(() => City, (city) => city.users)
46
+ @JoinColumn({ name: 'city' })
47
+ city: City
48
+
49
+ @Column({ nullable: true, length: 100 })
50
+ address: string
51
+
52
+ @Column({ type: 'decimal', precision: 10, scale: 8, nullable: true })
53
+ latitude: number
54
+
55
+ @Column({ type: 'decimal', precision: 10, scale: 8, nullable: true })
56
+ longitude: number
57
+
58
+ @Column({ length: 20 })
59
+ password: string
60
+
61
+ @Column({
62
+ type: 'longtext',
63
+ nullable: true,
64
+ comment:
65
+ 'Campo de tipo JSON donde se guarda información necesaria para el usuario',
66
+ })
67
+ profile: string
68
+
69
+ @Column({ type: 'datetime' })
70
+ created: Date
71
+
72
+ @Column({ type: 'datetime' })
73
+ updated: Date
74
+
75
+ @Column({ default: 1 })
76
+ status: number
77
+
78
+ @ManyToMany(() => Terminal)
79
+ @JoinTable({
80
+ name: 'user_terminal',
81
+ })
82
+ terminals: Terminal[]
83
+
84
+ @OneToMany(() => TerminalSession, (terminalSession) => terminalSession.user)
85
+ terminalUsers: TerminalSession[]
86
+
87
+ @OneToMany(() => Plan, (plan) => plan.created_by)
88
+ plans: Plan[]
89
+
90
+ @OneToMany(() => Company, (company) => company.user)
91
+ companies: Company[]
92
+
93
+ @OneToMany(() => Local, (local) => local.updated_by)
94
+ locals: Local[]
95
+
96
+ @OneToMany(
97
+ () => DiscountCodeCompany,
98
+ (discountCodeCompany) => discountCodeCompany.updated_by
99
+ )
100
+ discount_code_companies: DiscountCodeCompany[]
101
+
102
+ @OneToMany(
103
+ () => DiscountCodeUser,
104
+ (discountCodeUser) => discountCodeUser.updated_by
105
+ )
106
+ discount_code_users: DiscountCodeUser[]
107
+
108
+ @OneToMany(
109
+ () => CodeRedemptionHistoryUser,
110
+ (codeRedemptionHistoryUser) => codeRedemptionHistoryUser.user
111
+ )
112
+ code_redemption_history_users: CodeRedemptionHistoryUser[]
113
+
114
+ @ManyToMany(() => Local)
115
+ @JoinTable({
116
+ name: 'local_user',
117
+ })
118
+ locals_user: Local[]
119
+
120
+ @OneToMany(() => Master, (master) => master.user)
121
+ masters: Master[]
122
+ }
@@ -0,0 +1,32 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ } from 'typeorm'
8
+ import { ProductGroup } from './ProductGroup'
9
+
10
+ @Entity('product_group_complement', {
11
+ comment: 'Los complementos que tiene el grupo de un producto.',
12
+ })
13
+ export class ProductGroupComplement {
14
+ @PrimaryGeneratedColumn()
15
+ id: number
16
+
17
+ @ManyToOne(
18
+ () => ProductGroup,
19
+ (productGroup) => productGroup.groups_complement
20
+ )
21
+ @JoinColumn({ name: 'group_id' })
22
+ group_id: ProductGroup
23
+
24
+ @Column({ length: 30 })
25
+ name: string
26
+
27
+ @Column({ length: 20 })
28
+ price: string
29
+
30
+ @Column()
31
+ position: number
32
+ }
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { IShowEntity } from './interfaces'
2
+
3
+ // DOCUMENTATION: Función para retornar la entidad de una base de datos en específico por medio de un DataSource
4
+ export function showEntity({ entityName, connection }: IShowEntity): any {
5
+ return connection.getRepository(entityName)
6
+ }
@@ -0,0 +1,6 @@
1
+ import { DataSource } from 'typeorm'
2
+
3
+ export interface IShowEntity {
4
+ entityName: string
5
+ connection: DataSource
6
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "module": "commonjs",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "strict": true,
8
+ "emitDecoratorMetadata": true,
9
+ "experimentalDecorators": true,
10
+ "strictPropertyInitialization": false,
11
+ },
12
+ "include": ["src"]
13
+ }