test-entity-library-asm 1.7.4 → 1.7.6

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.
@@ -18,8 +18,8 @@ var Local_1 = require("./Local");
18
18
  var PartnerRole_1 = require("./PartnerRole");
19
19
  var Terminal_1 = require("./Terminal");
20
20
  var TerminalSession_1 = require("./TerminalSession");
21
- var transformations_1 = require("../transformations");
22
21
  var dateTransformer_1 = require("../transformers/dateTransformer");
22
+ var jsonTransformer_1 = require("../transformers/jsonTransformer");
23
23
  var Partner = /** @class */ (function () {
24
24
  function Partner() {
25
25
  }
@@ -98,7 +98,7 @@ var Partner = /** @class */ (function () {
98
98
  (0, typeorm_1.Column)({
99
99
  type: 'longtext',
100
100
  nullable: true,
101
- transformer: transformations_1.jsonTransformer,
101
+ transformer: jsonTransformer_1.jsonTransformer,
102
102
  comment: 'Campo de tipo JSON donde se guarda información necesaria para el registro.',
103
103
  }),
104
104
  __metadata("design:type", Object)
@@ -2,6 +2,6 @@ import { ValueTransformer } from 'typeorm';
2
2
  export declare class DateTransformer implements ValueTransformer {
3
3
  private format;
4
4
  constructor(format?: string);
5
- from(value: Date): string;
6
5
  to(value: Date): Date;
6
+ from(value: Date): string;
7
7
  }
@@ -8,13 +8,19 @@ var DateTransformer = /** @class */ (function () {
8
8
  if (format === void 0) { format = 'yyyy-MM-dd HH:mm:ss'; }
9
9
  this.format = format;
10
10
  }
11
+ DateTransformer.prototype.to = function (value) {
12
+ console.log("Converting ".concat(value, " to UTC TO"));
13
+ console.log("Converted date: ".concat((0, date_fns_tz_1.toDate)(value), " TEST TO"));
14
+ return (0, date_fns_tz_1.toDate)(value); // Assuming the input is already in UTC
15
+ };
11
16
  DateTransformer.prototype.from = function (value) {
12
17
  var timeZone = (0, __1.getTimeZone)();
18
+ console.log("Converting ".concat(value, " from UTC to ").concat(timeZone));
13
19
  var zonedDate = (0, date_fns_tz_1.toZonedTime)(value, timeZone);
14
- return (0, date_fns_tz_1.format)(zonedDate, this.format, { timeZone: timeZone });
15
- };
16
- DateTransformer.prototype.to = function (value) {
17
- return new Date(value); // Assuming the input is already in UTC
20
+ console.log("Converted date: ".concat(zonedDate));
21
+ var formattedDate = (0, date_fns_tz_1.format)(zonedDate, this.format, { timeZone: timeZone });
22
+ console.log("Formatted date to return: ".concat(formattedDate));
23
+ return formattedDate;
18
24
  };
19
25
  return DateTransformer;
20
26
  }());
@@ -0,0 +1,4 @@
1
+ export declare const jsonTransformer: {
2
+ to: (value: any) => string;
3
+ from: (value: string) => any;
4
+ };
@@ -1 +1,16 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsonTransformer = void 0;
4
+ // DOCUMENTATION: Variable creada para poder transformar los elementos a tipo objeto a los que están en la base de datos como strings que son objetos.
5
+ exports.jsonTransformer = {
6
+ to: function (value) { return JSON.stringify(value); },
7
+ from: function (value) {
8
+ try {
9
+ return JSON.parse(value);
10
+ }
11
+ catch (error) {
12
+ console.error('Error parsing JSON:', error);
13
+ return null;
14
+ }
15
+ },
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,8 +15,8 @@ import { Local } from './Local'
15
15
  import { PartnerRole } from './PartnerRole'
16
16
  import { Terminal } from './Terminal'
17
17
  import { TerminalSession } from './TerminalSession'
18
- import { jsonTransformer } from '../transformations'
19
18
  import { DateTransformer } from '../transformers/dateTransformer'
19
+ import { jsonTransformer } from '../transformers/jsonTransformer'
20
20
 
21
21
  @Entity({
22
22
  comment:
@@ -1,6 +1,6 @@
1
1
  // dateTransformer.ts
2
2
  import { ValueTransformer } from 'typeorm'
3
- import { format, toZonedTime } from 'date-fns-tz'
3
+ import { format, toDate, toZonedTime } from 'date-fns-tz'
4
4
  import { getTimeZone } from '..'
5
5
 
6
6
  export class DateTransformer implements ValueTransformer {
@@ -10,13 +10,19 @@ export class DateTransformer implements ValueTransformer {
10
10
  this.format = format
11
11
  }
12
12
 
13
+ to(value: Date): Date {
14
+ console.log(`Converting ${value} to UTC TO`)
15
+ console.log(`Converted date: ${toDate(value)} TEST TO`)
16
+
17
+ return toDate(value) // Assuming the input is already in UTC
18
+ }
13
19
  from(value: Date): string {
14
20
  const timeZone = getTimeZone()
21
+ console.log(`Converting ${value} from UTC to ${timeZone}`)
15
22
  const zonedDate = toZonedTime(value, timeZone)
16
- return format(zonedDate, this.format, { timeZone })
17
- }
18
-
19
- to(value: Date): Date {
20
- return new Date(value) // Assuming the input is already in UTC
23
+ console.log(`Converted date: ${zonedDate}`)
24
+ const formattedDate = format(zonedDate, this.format, { timeZone })
25
+ console.log(`Formatted date to return: ${formattedDate}`)
26
+ return formattedDate
21
27
  }
22
28
  }
@@ -0,0 +1,13 @@
1
+ // DOCUMENTATION: Variable creada para poder transformar los elementos a tipo objeto a los que están en la base de datos como strings que son objetos.
2
+ export const jsonTransformer = {
3
+ to: (value: any) => JSON.stringify(value),
4
+ from: (value: string) => {
5
+ try {
6
+ return JSON.parse(value)
7
+ } catch (error) {
8
+ console.error('Error parsing JSON:', error)
9
+ return null
10
+ }
11
+ },
12
+ }
13
+
@@ -1,12 +0,0 @@
1
- // DOCUMENTATION: Variable creada para poder transformar los elementos a tipo objeto a los que están en la base de datos como strings que son objetos.
2
- export const jsonTransformer = {
3
- to: (value: any) => JSON.stringify(value),
4
- from: (value: string) => {
5
- try {
6
- return JSON.parse(value)
7
- } catch (error) {
8
- console.error('Error parsing JSON:', error)
9
- return null
10
- }
11
- },
12
- }