test-entity-library-asm 1.8.2 → 1.8.4

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.
@@ -1,3 +1,4 @@
1
+ import { BaseEntity } from 'typeorm';
1
2
  import { City } from './City';
2
3
  import { Company } from './Company';
3
4
  import { DiscountCodeUser } from './DiscountCodeUser';
@@ -5,7 +6,7 @@ import { Local } from './Local';
5
6
  import { PartnerRole } from './PartnerRole';
6
7
  import { Terminal } from './Terminal';
7
8
  import { TerminalSession } from './TerminalSession';
8
- export declare class Partner {
9
+ export declare class Partner extends BaseEntity {
9
10
  id: number;
10
11
  company: Company;
11
12
  code: string;
@@ -1,4 +1,19 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
2
17
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
18
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
19
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -20,8 +35,10 @@ var PartnerRole_1 = require("./PartnerRole");
20
35
  var Terminal_1 = require("./Terminal");
21
36
  var TerminalSession_1 = require("./TerminalSession");
22
37
  var dateTransformer_1 = require("../transformers/dateTransformer");
23
- var Partner = /** @class */ (function () {
38
+ var Partner = /** @class */ (function (_super) {
39
+ __extends(Partner, _super);
24
40
  function Partner() {
41
+ return _super !== null && _super.apply(this, arguments) || this;
25
42
  }
26
43
  __decorate([
27
44
  (0, typeorm_1.PrimaryGeneratedColumn)({
@@ -113,8 +130,8 @@ var Partner = /** @class */ (function () {
113
130
  __decorate([
114
131
  (0, typeorm_1.Column)({
115
132
  type: 'datetime',
116
- transformer: new dateTransformer_1.DateTransformer(),
117
133
  comment: 'Fecha de creación del registro.',
134
+ transformer: new dateTransformer_1.DateTransformer(),
118
135
  }),
119
136
  __metadata("design:type", String)
120
137
  ], Partner.prototype, "created", void 0);
@@ -199,5 +216,5 @@ var Partner = /** @class */ (function () {
199
216
  })
200
217
  ], Partner);
201
218
  return Partner;
202
- }());
219
+ }(typeorm_1.BaseEntity));
203
220
  exports.Partner = Partner;
@@ -6,13 +6,17 @@ var DateTransformer = /** @class */ (function () {
6
6
  function DateTransformer() {
7
7
  }
8
8
  DateTransformer.prototype.to = function (value) {
9
- console.log(value, 'Se lo trae del to');
10
- // No es necesario transformar al guardar, se guarda en UTC
9
+ // Al guardar, nos aseguramos de que la fecha esté en UTC
11
10
  return moment.utc(value).format('YYYY-MM-DD HH:mm:ss');
12
11
  };
13
12
  DateTransformer.prototype.from = function (value) {
14
- // Convertir de UTC a la zona horaria local
15
- return moment.utc(value).tz('America/Bogota').format('YYYY-MM-DD HH:mm:ss');
13
+ // Convertir de UTC a la zona horaria local (Bogotá)
14
+ var localDate = moment
15
+ .utc(value)
16
+ .tz('America/Bogota')
17
+ .format('YYYY-MM-DD HH:mm:ss');
18
+ console.log('Fecha UTC:', value, 'Convertido a zona horaria local:', localDate);
19
+ return localDate;
16
20
  };
17
21
  return DateTransformer;
18
22
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,5 @@
1
1
  import {
2
+ BaseEntity,
2
3
  Column,
3
4
  Entity,
4
5
  JoinColumn,
@@ -22,7 +23,7 @@ import { DateTransformer } from '../transformers/dateTransformer'
22
23
  comment:
23
24
  'Tabla agregada para los usuarios qué quieran registrar su local o empresa de comida rápida en la plataforma.\r\n\r\nEste usuario es independiente a los usuarios de la tabla `user` ya que tiene diferentes plataformas.\r\n\r\nTambién van a estar los usuarios qué el administrador/dueño desee agregar como empleados/colaboradores.',
24
25
  })
25
- export class Partner {
26
+ export class Partner extends BaseEntity {
26
27
  @PrimaryGeneratedColumn({
27
28
  comment: 'Número de identificación (ID) único de cada registro.',
28
29
  })
@@ -101,8 +102,8 @@ export class Partner {
101
102
 
102
103
  @Column({
103
104
  type: 'datetime',
104
- transformer: new DateTransformer(),
105
105
  comment: 'Fecha de creación del registro.',
106
+ transformer: new DateTransformer(),
106
107
  })
107
108
  created: string
108
109
 
@@ -3,14 +3,22 @@ import * as moment from 'moment-timezone'
3
3
 
4
4
  export class DateTransformer implements ValueTransformer {
5
5
  to(value: Date | string): string {
6
- console.log(value, 'Se lo trae del to')
7
-
8
- // No es necesario transformar al guardar, se guarda en UTC
6
+ // Al guardar, nos aseguramos de que la fecha esté en UTC
9
7
  return moment.utc(value).format('YYYY-MM-DD HH:mm:ss')
10
8
  }
11
9
 
12
10
  from(value: string): string {
13
- // Convertir de UTC a la zona horaria local
14
- return moment.utc(value).tz('America/Bogota').format('YYYY-MM-DD HH:mm:ss')
11
+ // Convertir de UTC a la zona horaria local (Bogotá)
12
+ const localDate = moment
13
+ .utc(value)
14
+ .tz('America/Bogota')
15
+ .format('YYYY-MM-DD HH:mm:ss')
16
+ console.log(
17
+ 'Fecha UTC:',
18
+ value,
19
+ 'Convertido a zona horaria local:',
20
+ localDate
21
+ )
22
+ return localDate
15
23
  }
16
24
  }