proflores-db-model 0.1.34 → 0.2.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.
Files changed (105) hide show
  1. package/dist/entities/Bank/BankAccount.js +2 -2
  2. package/dist/entities/Bank/TransactionBank.js +2 -2
  3. package/dist/entities/BranchImage.js +2 -2
  4. package/dist/entities/Branches.js +2 -2
  5. package/dist/entities/CategoryForCosting.js +2 -2
  6. package/dist/entities/CategoryForPlantType.js +2 -2
  7. package/dist/entities/ContainerType.js +2 -2
  8. package/dist/entities/ExpenseDetail.js +2 -2
  9. package/dist/entities/ExpenseTransaction.js +2 -2
  10. package/dist/entities/ExpenseType.js +2 -2
  11. package/dist/entities/Inventory.js +2 -2
  12. package/dist/entities/InventoryImage.js +2 -2
  13. package/dist/entities/InventoryItem.js +2 -2
  14. package/dist/entities/InventoryMovement.js +2 -2
  15. package/dist/entities/ProductImage.js +2 -2
  16. package/dist/entities/Products.js +2 -2
  17. package/dist/entities/ProjectOrder.js +2 -2
  18. package/dist/entities/SupplierImage.js +2 -2
  19. package/dist/entities/Suppliers.js +2 -2
  20. package/dist/entities/UnitOfMesure.js +2 -2
  21. package/dist/entities/User.js +2 -2
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/models/technical-sheet/CareInstructions.d.ts +16 -0
  25. package/dist/models/technical-sheet/CareInstructions.js +68 -0
  26. package/dist/models/technical-sheet/ClimateIdeal.d.ts +11 -0
  27. package/dist/models/technical-sheet/ClimateIdeal.js +48 -0
  28. package/dist/models/technical-sheet/FertilizationInfo.d.ts +20 -0
  29. package/dist/models/technical-sheet/FertilizationInfo.js +64 -0
  30. package/dist/models/technical-sheet/GrowthClassInfo.d.ts +15 -0
  31. package/dist/models/technical-sheet/GrowthClassInfo.js +49 -0
  32. package/dist/models/technical-sheet/HumidityInfo.d.ts +10 -0
  33. package/dist/models/technical-sheet/HumidityInfo.js +44 -0
  34. package/dist/models/technical-sheet/ImageInfo.d.ts +29 -0
  35. package/dist/models/technical-sheet/ImageInfo.js +134 -0
  36. package/dist/models/technical-sheet/LightInfo.d.ts +10 -0
  37. package/dist/models/technical-sheet/LightInfo.js +44 -0
  38. package/dist/models/technical-sheet/PestInfo.d.ts +18 -0
  39. package/dist/models/technical-sheet/PestInfo.js +76 -0
  40. package/dist/models/technical-sheet/PlantGrowthType.d.ts +15 -0
  41. package/dist/models/technical-sheet/PlantGrowthType.js +53 -0
  42. package/dist/models/technical-sheet/PlantSize.d.ts +14 -0
  43. package/dist/models/technical-sheet/PlantSize.js +62 -0
  44. package/dist/models/technical-sheet/PlantTechnicalSheet.d.ts +33 -0
  45. package/dist/models/technical-sheet/PlantTechnicalSheet.js +117 -0
  46. package/dist/models/technical-sheet/PropagationMethodInfo.d.ts +12 -0
  47. package/dist/models/technical-sheet/PropagationMethodInfo.js +52 -0
  48. package/dist/models/technical-sheet/SubstrateInfo.d.ts +13 -0
  49. package/dist/models/technical-sheet/SubstrateInfo.js +58 -0
  50. package/dist/models/technical-sheet/catalogs/climate-ideal.d.ts +11 -0
  51. package/dist/models/technical-sheet/catalogs/climate-ideal.js +14 -0
  52. package/dist/models/technical-sheet/catalogs/fertilization-info.d.ts +34 -0
  53. package/dist/models/technical-sheet/catalogs/fertilization-info.js +35 -0
  54. package/dist/models/technical-sheet/catalogs/growth-class.d.ts +10 -0
  55. package/dist/models/technical-sheet/catalogs/growth-class.js +14 -0
  56. package/dist/models/technical-sheet/catalogs/growth-type.d.ts +32 -0
  57. package/dist/models/technical-sheet/catalogs/growth-type.js +35 -0
  58. package/dist/models/technical-sheet/catalogs/humidity-info.d.ts +9 -0
  59. package/dist/models/technical-sheet/catalogs/humidity-info.js +12 -0
  60. package/dist/models/technical-sheet/catalogs/light-info.d.ts +9 -0
  61. package/dist/models/technical-sheet/catalogs/light-info.js +13 -0
  62. package/dist/models/technical-sheet/catalogs/pest-info.d.ts +32 -0
  63. package/dist/models/technical-sheet/catalogs/pest-info.js +33 -0
  64. package/dist/models/technical-sheet/catalogs/plant-size.d.ts +11 -0
  65. package/dist/models/technical-sheet/catalogs/plant-size.js +15 -0
  66. package/dist/models/technical-sheet/catalogs/propagation-method.d.ts +14 -0
  67. package/dist/models/technical-sheet/catalogs/propagation-method.js +18 -0
  68. package/dist/models/technical-sheet/catalogs/substrate-info.d.ts +17 -0
  69. package/dist/models/technical-sheet/catalogs/substrate-info.js +21 -0
  70. package/dist/models/technical-sheet/index.d.ts +13 -0
  71. package/dist/models/technical-sheet/index.js +29 -0
  72. package/dist/models/technical-sheet/utils/enumColumn.d.ts +6 -0
  73. package/dist/models/technical-sheet/utils/enumColumn.js +12 -0
  74. package/dist/models/technical-sheet/utils/makeCatalog.d.ts +8 -0
  75. package/dist/models/technical-sheet/utils/makeCatalog.js +19 -0
  76. package/dist/types/MovementType.js +1 -1
  77. package/package.json +5 -5
  78. package/src/entities/Inventory.ts +1 -0
  79. package/src/index.ts +1 -0
  80. package/src/models/technical-sheet/CareInstructions.ts +52 -0
  81. package/src/models/technical-sheet/ClimateIdeal.ts +34 -0
  82. package/src/models/technical-sheet/FertilizationInfo.ts +59 -0
  83. package/src/models/technical-sheet/GrowthClassInfo.ts +38 -0
  84. package/src/models/technical-sheet/HumidityInfo.ts +31 -0
  85. package/src/models/technical-sheet/ImageInfo.ts +111 -0
  86. package/src/models/technical-sheet/LightInfo.ts +31 -0
  87. package/src/models/technical-sheet/PestInfo.ts +65 -0
  88. package/src/models/technical-sheet/PlantGrowthType.ts +41 -0
  89. package/src/models/technical-sheet/PlantSize.ts +48 -0
  90. package/src/models/technical-sheet/PlantTechnicalSheet.ts +93 -0
  91. package/src/models/technical-sheet/PropagationMethodInfo.ts +37 -0
  92. package/src/models/technical-sheet/SubstrateInfo.ts +45 -0
  93. package/src/models/technical-sheet/catalogs/climate-ideal.ts +16 -0
  94. package/src/models/technical-sheet/catalogs/fertilization-info.ts +41 -0
  95. package/src/models/technical-sheet/catalogs/growth-class.ts +14 -0
  96. package/src/models/technical-sheet/catalogs/growth-type.ts +37 -0
  97. package/src/models/technical-sheet/catalogs/humidity-info.ts +12 -0
  98. package/src/models/technical-sheet/catalogs/light-info.ts +13 -0
  99. package/src/models/technical-sheet/catalogs/pest-info.ts +36 -0
  100. package/src/models/technical-sheet/catalogs/plant-size.ts +15 -0
  101. package/src/models/technical-sheet/catalogs/propagation-method.ts +18 -0
  102. package/src/models/technical-sheet/catalogs/substrate-info.ts +21 -0
  103. package/src/models/technical-sheet/index.ts +14 -0
  104. package/src/models/technical-sheet/utils/enumColumn.ts +17 -0
  105. package/src/models/technical-sheet/utils/makeCatalog.ts +17 -0
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUBSTRATE = void 0;
4
+ // src/models/technical-sheet/catalogs/substrate-info.ts
5
+ const makeCatalog_1 = require("../utils/makeCatalog");
6
+ exports.SUBSTRATE = (0, makeCatalog_1.makeCatalog)({
7
+ UNIVERSAL: 'Mezcla equilibrada.',
8
+ INTERIOR_LIGERO: 'Turba + perlita.',
9
+ CACTUS_SUCULENTAS: 'Arena + grava, baja materia orgánica.',
10
+ ORQUÍDEAS_EPÍFITAS: 'Corteza gruesa + carbón.',
11
+ BROMELIAS: 'Fibra coco + corteza.',
12
+ ACUÁTICO: 'Arcilla y arena sumergida.',
13
+ HELECHOS_HUMEDOS: 'Turba + musgo esfagno.',
14
+ SEMILLERO: 'Turba fina esterilizada.',
15
+ BONSAI: 'Akadama + kiryuzuna + grava.',
16
+ HIDROPONÍA: 'Sustrato inerte.',
17
+ ARENA_GRAVILLA: '100 % mineral.',
18
+ FIBRA_COCO_PURA: 'Coco hidratado.',
19
+ TURBA: 'Turba rubia o negra.',
20
+ COMPOST_HOJARASCA: 'Orgánico descompuesto.',
21
+ });
@@ -0,0 +1,13 @@
1
+ export * from './PlantTechnicalSheet';
2
+ export * from './GrowthClassInfo';
3
+ export * from './CareInstructions';
4
+ export * from './ImageInfo';
5
+ export * from './LightInfo';
6
+ export * from './HumidityInfo';
7
+ export * from './PestInfo';
8
+ export * from './PlantGrowthType';
9
+ export * from './PlantSize';
10
+ export * from './SubstrateInfo';
11
+ export * from './ClimateIdeal';
12
+ export * from './FertilizationInfo';
13
+ export * from './PropagationMethodInfo';
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./PlantTechnicalSheet"), exports);
18
+ __exportStar(require("./GrowthClassInfo"), exports);
19
+ __exportStar(require("./CareInstructions"), exports);
20
+ __exportStar(require("./ImageInfo"), exports);
21
+ __exportStar(require("./LightInfo"), exports);
22
+ __exportStar(require("./HumidityInfo"), exports);
23
+ __exportStar(require("./PestInfo"), exports);
24
+ __exportStar(require("./PlantGrowthType"), exports);
25
+ __exportStar(require("./PlantSize"), exports);
26
+ __exportStar(require("./SubstrateInfo"), exports);
27
+ __exportStar(require("./ClimateIdeal"), exports);
28
+ __exportStar(require("./FertilizationInfo"), exports);
29
+ __exportStar(require("./PropagationMethodInfo"), exports);
@@ -0,0 +1,6 @@
1
+ import { ColumnOptions } from "typeorm";
2
+ /**
3
+ * Utilidad para columnas enum basadas en catálogos TypeScript.
4
+ * Permite usar `keyof typeof ENUM` como tipo en la entidad.
5
+ */
6
+ export declare function EnumColumn<T extends string>(values: readonly T[], options?: Omit<ColumnOptions, "type" | "enum">): PropertyDecorator;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnumColumn = EnumColumn;
4
+ // src/models/technical-sheet/utils/enumColumn.ts
5
+ const typeorm_1 = require("typeorm");
6
+ /**
7
+ * Utilidad para columnas enum basadas en catálogos TypeScript.
8
+ * Permite usar `keyof typeof ENUM` como tipo en la entidad.
9
+ */
10
+ function EnumColumn(values, options = {}) {
11
+ return (0, typeorm_1.Column)(Object.assign({ type: "enum", enum: values }, options));
12
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Define un catálogo estático e inmutable y devuelve el mismo objeto.
3
+ * TypeScript infiere correctamente los tipos de clave.
4
+ *
5
+ * @param c Objeto Record<string, string> que representa el catálogo
6
+ * @returns El mismo objeto `c`, como constante tipada
7
+ */
8
+ export declare function makeCatalog<C extends Record<string, string>>(c: C): C;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /* =============================================================================
3
+ * UTILITY ───────────── makeCatalog
4
+ * ---------------------------------------------------------------------------
5
+ * Crea un Record<K, string> inmutable para catálogos
6
+ * y permite derivar tipos clave (keyof).
7
+ * ===========================================================================*/
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.makeCatalog = makeCatalog;
10
+ /**
11
+ * Define un catálogo estático e inmutable y devuelve el mismo objeto.
12
+ * TypeScript infiere correctamente los tipos de clave.
13
+ *
14
+ * @param c Objeto Record<string, string> que representa el catálogo
15
+ * @returns El mismo objeto `c`, como constante tipada
16
+ */
17
+ function makeCatalog(c) {
18
+ return c;
19
+ }
@@ -8,4 +8,4 @@ var MovementType;
8
8
  MovementType["ADJUSTMENT"] = "ADJUSTMENT";
9
9
  MovementType["TRANSFER_IN"] = "TRANSFER_IN";
10
10
  MovementType["TRANSFER_OUT"] = "TRANSFER_OUT";
11
- })(MovementType = exports.MovementType || (exports.MovementType = {}));
11
+ })(MovementType || (exports.MovementType = MovementType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proflores-db-model",
3
- "version": "0.1.34",
3
+ "version": "0.2.0",
4
4
  "description": "Data model for managing expenses and transactions for Proflores nursery business",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,12 +11,12 @@
11
11
  "prepublishOnly": "yarn build"
12
12
  },
13
13
  "dependencies": {
14
- "reflect-metadata": "^0.1.13",
15
- "typeorm": "^0.2.45"
14
+ "reflect-metadata": "^0.2.2",
15
+ "typeorm": "^0.3.22"
16
16
  },
17
17
  "devDependencies": {
18
- "@types/node": "^22.8.7",
18
+ "@types/node": "^22.15.3",
19
19
  "ts-node": "^10.0.0",
20
- "typescript": "^4.0.0"
20
+ "typescript": "^5.8.3"
21
21
  }
22
22
  }
@@ -14,6 +14,7 @@ import { ContainerType } from "./ContainerType";
14
14
  import { Supplier } from "./Suppliers";
15
15
  import { InventoryImage } from "./InventoryImage";
16
16
  import { InventoryMovement } from "./InventoryMovement";
17
+
17
18
  @Entity("inventory")
18
19
  export class Inventory implements ObjectLiteral {
19
20
  @PrimaryGeneratedColumn("increment")
package/src/index.ts CHANGED
@@ -21,3 +21,4 @@ export { SupplierImage } from "./entities/SupplierImage";
21
21
  export { InventoryImage } from "./entities/InventoryImage";
22
22
 
23
23
  export * from "./types";
24
+ export * from "./models/technical-sheet";
@@ -0,0 +1,52 @@
1
+ // src/models/technical-sheet/entities/CareInstructions.ts
2
+
3
+ import {
4
+ Entity,
5
+ Column,
6
+ PrimaryGeneratedColumn,
7
+ ObjectLiteral,
8
+ OneToOne,
9
+ JoinColumn,
10
+ } from 'typeorm';
11
+ import { PlantTechnicalSheet } from './PlantTechnicalSheet';
12
+
13
+ @Entity('care_instructions')
14
+ export class CareInstructions implements ObjectLiteral {
15
+ @PrimaryGeneratedColumn('increment')
16
+ idCareInstructions!: number;
17
+
18
+ @Column('text')
19
+ light!: string;
20
+
21
+ @Column('text')
22
+ watering!: string;
23
+
24
+ @Column('text')
25
+ humidity!: string;
26
+
27
+ @Column('text')
28
+ temperature!: string;
29
+
30
+ @Column('text')
31
+ substrate!: string;
32
+
33
+ @Column('text')
34
+ fertilization!: string;
35
+
36
+ @Column('text')
37
+ pruning!: string;
38
+
39
+ @Column('text', { nullable: true })
40
+ notes?: string;
41
+
42
+ /** Relación inversa con la ficha técnica */
43
+ @OneToOne(() => PlantTechnicalSheet, (sheet) => sheet.care, {
44
+ onDelete: 'CASCADE',
45
+ })
46
+ @JoinColumn({ name: 'plantTechnicalSheetId' })
47
+ plantTechnicalSheet?: PlantTechnicalSheet;
48
+
49
+ @Column({ type: 'boolean', default: true })
50
+ isActive!: boolean;
51
+ }
52
+
@@ -0,0 +1,34 @@
1
+ import {
2
+ Column,
3
+ Entity,
4
+ PrimaryGeneratedColumn,
5
+ OneToMany,
6
+ ObjectLiteral,
7
+ } from 'typeorm';
8
+ import { CLIMATE, ClimateType } from './catalogs/climate-ideal';
9
+ import { ImageInfo } from './ImageInfo';
10
+ import { EnumColumn } from './utils/enumColumn';
11
+
12
+ @Entity('climate_ideal')
13
+ export class ClimateIdeal implements ObjectLiteral {
14
+ @PrimaryGeneratedColumn('increment')
15
+ idClimateIdeal!: number;
16
+
17
+ @EnumColumn(Object.keys(CLIMATE) as ClimateType[])
18
+ type!: ClimateType;
19
+
20
+ @Column('text', { nullable: true })
21
+ description?: string;
22
+
23
+ @Column('simple-json', { nullable: true })
24
+ temperatureRangeC?: [number, number];
25
+
26
+ @OneToMany(() => ImageInfo, (image) => image.climateIdeal, {
27
+ cascade: true,
28
+ })
29
+ images?: ImageInfo[];
30
+
31
+ @Column({ type: 'boolean', default: true })
32
+ isActive!: boolean;
33
+ }
34
+
@@ -0,0 +1,59 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ ManyToOne,
6
+ OneToMany,
7
+ ObjectLiteral,
8
+ } from "typeorm";
9
+ import {
10
+ FERTILIZER_TYPE,
11
+ FERTILIZER_FREQ,
12
+ FERTILIZER_METHOD,
13
+ FertilizerType,
14
+ FertilizerFrequency,
15
+ FertilizerMethod,
16
+ } from "./catalogs/fertilization-info";
17
+ import { PlantTechnicalSheet } from "./PlantTechnicalSheet";
18
+ import { ImageInfo } from "./ImageInfo";
19
+ import { EnumColumn } from "./utils/enumColumn";
20
+
21
+ @Entity("fertilization_info")
22
+ export class FertilizationInfo implements ObjectLiteral {
23
+ @PrimaryGeneratedColumn("increment")
24
+ idFertilizationInfo!: number;
25
+
26
+ /** Tipo de fertilizante según catálogo */
27
+ @EnumColumn(Object.keys(FERTILIZER_TYPE) as FertilizerType[])
28
+ type!: FertilizerType;
29
+
30
+ /** Frecuencia de aplicación según catálogo */
31
+ @EnumColumn(Object.keys(FERTILIZER_FREQ) as FertilizerFrequency[])
32
+ frequency!: FertilizerFrequency;
33
+
34
+ /** Método de aplicación según catálogo */
35
+ @EnumColumn(Object.keys(FERTILIZER_METHOD) as FertilizerMethod[])
36
+ method!: FertilizerMethod;
37
+
38
+ @Column("text", { nullable: true })
39
+ formula?: string;
40
+
41
+ @Column("text", { nullable: true })
42
+ notes?: string;
43
+
44
+ /** Imágenes asociadas */
45
+ @OneToMany(() => ImageInfo, (image) => image.fertilizationInfo, {
46
+ cascade: true,
47
+ })
48
+ images?: ImageInfo[];
49
+
50
+ /** Ficha técnica a la que pertenece esta fertilización */
51
+ @ManyToOne(() => PlantTechnicalSheet, (sheet) => sheet.fertilization, {
52
+ nullable: false,
53
+ onDelete: "CASCADE",
54
+ })
55
+ plant!: PlantTechnicalSheet;
56
+
57
+ @Column({ type: "boolean", default: true })
58
+ isActive!: boolean;
59
+ }
@@ -0,0 +1,38 @@
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ OneToMany,
6
+ ObjectLiteral,
7
+ } from 'typeorm';
8
+ import { GROWTH_CLASS, GrowthClass } from './catalogs/growth-class';
9
+ import { PlantTechnicalSheet } from './PlantTechnicalSheet';
10
+ import { ImageInfo } from './ImageInfo';
11
+ import { EnumColumn } from './utils/enumColumn';
12
+
13
+ @Entity('growth_class_info')
14
+ export class GrowthClassInfo implements ObjectLiteral {
15
+ @PrimaryGeneratedColumn('increment')
16
+ idGrowthClassInfo!: number;
17
+
18
+ /** Clase de crecimiento (catálogo) */
19
+ @EnumColumn(Object.keys(GROWTH_CLASS) as GrowthClass[])
20
+ type!: GrowthClass;
21
+
22
+ @Column('text', { nullable: true })
23
+ description?: string;
24
+
25
+ /** Imágenes asociadas */
26
+ @OneToMany(() => ImageInfo, (image) => image.growthClassInfo, {
27
+ cascade: true,
28
+ })
29
+ images?: ImageInfo[];
30
+
31
+ /** Fichas técnicas asociadas */
32
+ @OneToMany(() => PlantTechnicalSheet, (sheet) => sheet.growthClass)
33
+ sheets!: PlantTechnicalSheet[];
34
+
35
+ @Column({ type: 'boolean', default: true })
36
+ isActive!: boolean;
37
+ }
38
+
@@ -0,0 +1,31 @@
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ OneToMany,
6
+ ObjectLiteral,
7
+ } from 'typeorm';
8
+ import { HUMIDITY, HumidityRequirement } from './catalogs/humidity-info';
9
+ import { ImageInfo } from './ImageInfo';
10
+ import { EnumColumn } from './utils/enumColumn';
11
+
12
+ @Entity('humidity_info')
13
+ export class HumidityInfo implements ObjectLiteral {
14
+ @PrimaryGeneratedColumn('increment')
15
+ idHumidityInfo!: number;
16
+
17
+ @EnumColumn(Object.keys(HUMIDITY) as HumidityRequirement[])
18
+ type!: HumidityRequirement;
19
+
20
+ @Column('text', { nullable: true })
21
+ description?: string;
22
+
23
+ @OneToMany(() => ImageInfo, (image) => image.humidityInfo, {
24
+ cascade: true,
25
+ })
26
+ images?: ImageInfo[];
27
+
28
+ @Column({ type: 'boolean', default: true })
29
+ isActive!: boolean;
30
+ }
31
+
@@ -0,0 +1,111 @@
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ ObjectLiteral,
6
+ ManyToOne,
7
+ JoinColumn,
8
+ } from "typeorm";
9
+ import { PlantTechnicalSheet } from "./PlantTechnicalSheet";
10
+ import { PlantGrowthType } from "./PlantGrowthType";
11
+ import { LightInfo } from "./LightInfo";
12
+ import { HumidityInfo } from "./HumidityInfo";
13
+ import { ClimateIdeal } from "./ClimateIdeal";
14
+ import { SubstrateInfo } from "./SubstrateInfo";
15
+ import { FertilizationInfo } from "./FertilizationInfo";
16
+ import { PestInfo } from "./PestInfo";
17
+ import { PropagationMethodInfo } from "./PropagationMethodInfo";
18
+ import { PlantSize } from "./PlantSize";
19
+ import { GrowthClassInfo } from "./GrowthClassInfo";
20
+
21
+ @Entity("technical_sheet_images")
22
+ export class ImageInfo implements ObjectLiteral {
23
+ @PrimaryGeneratedColumn("increment")
24
+ idImage!: number;
25
+
26
+ @Column("varchar", { length: 500 })
27
+ url!: string;
28
+
29
+ @Column("text", { nullable: true })
30
+ description?: string;
31
+
32
+ @Column({ type: "boolean", default: true })
33
+ isActive!: boolean;
34
+
35
+ @ManyToOne(() => PlantTechnicalSheet, (sheet) => sheet.images, {
36
+ nullable: true,
37
+ onDelete: "CASCADE",
38
+ })
39
+ @JoinColumn({ name: "plantTechnicalSheetId" })
40
+ plantTechnicalSheet?: PlantTechnicalSheet;
41
+
42
+ @ManyToOne(() => PlantGrowthType, (growthType) => growthType.images, {
43
+ nullable: true,
44
+ onDelete: "CASCADE",
45
+ })
46
+ @JoinColumn({ name: "plantGrowthTypeId" })
47
+ plantGrowthType?: PlantGrowthType;
48
+
49
+ @ManyToOne(() => LightInfo, (lightInfo) => lightInfo.images, {
50
+ nullable: true,
51
+ onDelete: "CASCADE",
52
+ })
53
+ @JoinColumn({ name: "lightInfoId" })
54
+ lightInfo?: LightInfo;
55
+
56
+ @ManyToOne(() => HumidityInfo, (humidityInfo) => humidityInfo.images, {
57
+ nullable: true,
58
+ onDelete: "CASCADE",
59
+ })
60
+ @JoinColumn({ name: "humidityInfoId" })
61
+ humidityInfo?: HumidityInfo;
62
+
63
+ @ManyToOne(() => ClimateIdeal, (climate) => climate.images, {
64
+ nullable: true,
65
+ onDelete: "CASCADE",
66
+ })
67
+ @JoinColumn({ name: "climateIdealId" })
68
+ climateIdeal?: ClimateIdeal;
69
+
70
+ @ManyToOne(() => SubstrateInfo, (substrate) => substrate.images, {
71
+ nullable: true,
72
+ onDelete: "CASCADE",
73
+ })
74
+ @JoinColumn({ name: "substrateInfoId" })
75
+ substrateInfo?: SubstrateInfo;
76
+
77
+ @ManyToOne(() => FertilizationInfo, (f) => f.images, {
78
+ nullable: true,
79
+ onDelete: "CASCADE",
80
+ })
81
+ @JoinColumn({ name: "fertilizationInfoId" })
82
+ fertilizationInfo?: FertilizationInfo;
83
+
84
+ @ManyToOne(() => PestInfo, (pest) => pest.images, {
85
+ nullable: true,
86
+ onDelete: "CASCADE",
87
+ })
88
+ @JoinColumn({ name: "pestId" })
89
+ pest?: PestInfo;
90
+
91
+ @ManyToOne(() => PropagationMethodInfo, (info) => info.images, {
92
+ nullable: true,
93
+ onDelete: "CASCADE",
94
+ })
95
+ @JoinColumn({ name: "propagationMethodId" })
96
+ propagationMethod?: PropagationMethodInfo;
97
+
98
+ @ManyToOne(() => PlantSize, (size) => size.images, {
99
+ nullable: true,
100
+ onDelete: "CASCADE",
101
+ })
102
+ @JoinColumn({ name: "plantSizeId" })
103
+ plantSize?: PlantSize;
104
+
105
+ @ManyToOne(() => GrowthClassInfo, (growthClass) => growthClass.images, {
106
+ nullable: true,
107
+ onDelete: "CASCADE",
108
+ })
109
+ @JoinColumn({ name: "growthClassInfoId" })
110
+ growthClassInfo?: GrowthClassInfo;
111
+ }
@@ -0,0 +1,31 @@
1
+ import {
2
+ Entity,
3
+ Column,
4
+ PrimaryGeneratedColumn,
5
+ OneToMany,
6
+ ObjectLiteral,
7
+ } from 'typeorm';
8
+ import { LIGHT, LightRequirement } from './catalogs/light-info';
9
+ import { ImageInfo } from './ImageInfo';
10
+ import { EnumColumn } from './utils/enumColumn';
11
+
12
+ @Entity('light_info')
13
+ export class LightInfo implements ObjectLiteral {
14
+ @PrimaryGeneratedColumn('increment')
15
+ idLightInfo!: number;
16
+
17
+ @EnumColumn(Object.keys(LIGHT) as LightRequirement[])
18
+ type!: LightRequirement;
19
+
20
+ @Column('text', { nullable: true })
21
+ description?: string;
22
+
23
+ @OneToMany(() => ImageInfo, (image) => image.lightInfo, {
24
+ cascade: true,
25
+ })
26
+ images?: ImageInfo[];
27
+
28
+ @Column({ type: 'boolean', default: true })
29
+ isActive!: boolean;
30
+ }
31
+
@@ -0,0 +1,65 @@
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ ObjectLiteral,
6
+ ManyToOne,
7
+ JoinColumn,
8
+ OneToMany,
9
+ } from 'typeorm';
10
+ import { PlantTechnicalSheet } from './PlantTechnicalSheet';
11
+ import { ImageInfo } from './ImageInfo';
12
+ import {
13
+ PEST_TYPE,
14
+ PestType,
15
+ PLANT_PART,
16
+ PlantPart,
17
+ CONTROL_METHOD,
18
+ ControlMethod,
19
+ } from './catalogs/pest-info';
20
+ import { EnumColumn } from './utils/enumColumn';
21
+
22
+ @Entity('pests')
23
+ export class PestInfo implements ObjectLiteral {
24
+ @PrimaryGeneratedColumn('increment')
25
+ idPestInfo!: number;
26
+
27
+ @Column('varchar', { length: 255 })
28
+ commonName!: string;
29
+
30
+ @Column('varchar', { nullable: true, length: 255 })
31
+ scientificName?: string;
32
+
33
+ @EnumColumn(Object.keys(PEST_TYPE) as PestType[])
34
+ type!: PestType;
35
+
36
+ @EnumColumn(Object.keys(PLANT_PART) as PlantPart[])
37
+ affectedParts!: PlantPart;
38
+
39
+ @Column('text')
40
+ symptoms!: string;
41
+
42
+ @Column('text', { nullable: true })
43
+ appearanceConditions?: string;
44
+
45
+ @EnumColumn(Object.keys(CONTROL_METHOD) as ControlMethod[])
46
+ controlMethod!: ControlMethod;
47
+
48
+ @Column('text', { nullable: true })
49
+ controlNotes?: string;
50
+
51
+ @ManyToOne(() => PlantTechnicalSheet, (sheet) => sheet.pests, {
52
+ onDelete: 'CASCADE',
53
+ })
54
+ @JoinColumn({ name: 'technicalSheetId' })
55
+ technicalSheet!: PlantTechnicalSheet;
56
+
57
+ @OneToMany(() => ImageInfo, (image) => image.pest, {
58
+ cascade: true,
59
+ })
60
+ images?: ImageInfo[];
61
+
62
+ @Column({ type: 'boolean', default: true })
63
+ isActive!: boolean;
64
+ }
65
+
@@ -0,0 +1,41 @@
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ ObjectLiteral,
6
+ OneToMany,
7
+ } from 'typeorm';
8
+ import { EnumColumn } from './utils/enumColumn';
9
+ import { GROWTH_AREA, GROWTH_HABIT } from './catalogs/growth-type';
10
+ import { PlantTechnicalSheet } from './PlantTechnicalSheet';
11
+ import { ImageInfo } from './ImageInfo';
12
+
13
+ export type PlantGrowthArea = keyof typeof GROWTH_AREA;
14
+ export type PlantGrowthHabit = keyof typeof GROWTH_HABIT;
15
+
16
+ @Entity('plant_growth_types')
17
+ export class PlantGrowthType implements ObjectLiteral {
18
+ @PrimaryGeneratedColumn('increment')
19
+ idPlantGrowthType!: number;
20
+
21
+ @EnumColumn(Object.keys(GROWTH_AREA) as PlantGrowthArea[])
22
+ area!: PlantGrowthArea;
23
+
24
+ @EnumColumn(Object.keys(GROWTH_HABIT) as PlantGrowthHabit[])
25
+ habit!: PlantGrowthHabit;
26
+
27
+ @Column('text', { nullable: true })
28
+ description?: string;
29
+
30
+ @OneToMany(() => ImageInfo, (image) => image.plantGrowthType, {
31
+ cascade: true,
32
+ })
33
+ images?: ImageInfo[];
34
+
35
+ @OneToMany(() => PlantTechnicalSheet, (sheet) => sheet.plantType)
36
+ sheets!: PlantTechnicalSheet[];
37
+
38
+ @Column({ type: 'boolean', default: true })
39
+ isActive!: boolean;
40
+ }
41
+