test-entity-library-asm 2.3.8 → 2.4.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.
@@ -6,9 +6,9 @@ export declare class Country {
6
6
  currency: string;
7
7
  prefix: string;
8
8
  structure_phone: string;
9
- legal_information: string;
10
- legal_agent: string;
11
- details: string;
9
+ legal_information: any;
10
+ legal_agent: any;
11
+ details: any;
12
12
  status: number;
13
13
  regions: Region[];
14
14
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Country = void 0;
13
13
  var typeorm_1 = require("typeorm");
14
14
  var Region_1 = require("./Region");
15
+ var jsonTransformer_1 = require("../transformers/jsonTransformer");
15
16
  var Country = /** @class */ (function () {
16
17
  function Country() {
17
18
  }
@@ -50,24 +51,27 @@ var Country = /** @class */ (function () {
50
51
  __decorate([
51
52
  (0, typeorm_1.Column)({
52
53
  type: 'longtext',
54
+ transformer: jsonTransformer_1.jsonTransformer,
53
55
  comment: '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.',
54
56
  }),
55
- __metadata("design:type", String)
57
+ __metadata("design:type", Object)
56
58
  ], Country.prototype, "legal_information", void 0);
57
59
  __decorate([
58
60
  (0, typeorm_1.Column)({
59
61
  type: 'longtext',
62
+ transformer: jsonTransformer_1.jsonTransformer,
60
63
  comment: 'Columna de tipo JSON para almacenar la información que se necesita para la información del representante legal de la empresa.',
61
64
  }),
62
- __metadata("design:type", String)
65
+ __metadata("design:type", Object)
63
66
  ], Country.prototype, "legal_agent", void 0);
64
67
  __decorate([
65
68
  (0, typeorm_1.Column)({
66
69
  type: 'longtext',
67
70
  nullable: true,
71
+ transformer: jsonTransformer_1.jsonTransformer,
68
72
  comment: 'Columna de tipo JSON para almacenar información adicional sobre el país.',
69
73
  }),
70
- __metadata("design:type", String)
74
+ __metadata("design:type", Object)
71
75
  ], Country.prototype, "details", void 0);
72
76
  __decorate([
73
77
  (0, typeorm_1.Column)({
package/dist/index.d.ts CHANGED
@@ -8,4 +8,5 @@ export declare function showEntity(entityName: string): Promise<any>;
8
8
  export declare function callStoredProcedure(storedProcedure: any, elements: any): Promise<any>;
9
9
  export declare function timezoneMiddleware(req: Request, res: Response, next: NextFunction): void;
10
10
  export declare function getTimeZone(): string;
11
+ export declare function getTimezoneOffset(timezone: string): string;
11
12
  export declare const getRepositoryByEntity: <T extends ObjectLiteral>(entity: EntityTarget<T>) => Promise<CustomRepository<T>>;
package/dist/index.js CHANGED
@@ -50,12 +50,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
50
50
  }
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.getRepositoryByEntity = exports.getTimeZone = exports.timezoneMiddleware = exports.callStoredProcedure = exports.showEntity = exports.showEntityNameEntity = exports.createDataBaseSource = void 0;
53
+ exports.getRepositoryByEntity = exports.getTimezoneOffset = exports.getTimeZone = exports.timezoneMiddleware = exports.callStoredProcedure = exports.showEntity = exports.showEntityNameEntity = exports.createDataBaseSource = void 0;
54
54
  var async_hooks_1 = require("async_hooks");
55
55
  var dotenv_1 = require("dotenv");
56
56
  var path_1 = require("path");
57
57
  var typeorm_1 = require("typeorm");
58
58
  var _1 = require(".");
59
+ var moment = require("moment-timezone");
59
60
  __exportStar(require("./entities.views.routes"), exports);
60
61
  var asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
61
62
  var connection = null;
@@ -171,6 +172,12 @@ function getTimeZone() {
171
172
  return (_a = store === null || store === void 0 ? void 0 : store.get('timezone')) !== null && _a !== void 0 ? _a : 'UTC';
172
173
  }
173
174
  exports.getTimeZone = getTimeZone;
175
+ function getTimezoneOffset(timezone) {
176
+ var now = moment.tz(timezone);
177
+ var offset = now.format('Z');
178
+ return offset;
179
+ }
180
+ exports.getTimezoneOffset = getTimezoneOffset;
174
181
  var getRepositoryByEntity = function (entity) { return __awaiter(void 0, void 0, void 0, function () {
175
182
  return __generator(this, function (_a) {
176
183
  switch (_a.label) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "2.3.8",
3
+ "version": "2.4.0",
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,5 +1,6 @@
1
1
  import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'
2
2
  import { Region } from './Region'
3
+ import { jsonTransformer } from '../transformers/jsonTransformer'
3
4
 
4
5
  @Entity({ comment: 'Países donde está disponible la plataforma.' })
5
6
  export class Country {
@@ -32,25 +33,28 @@ export class Country {
32
33
 
33
34
  @Column({
34
35
  type: 'longtext',
36
+ transformer: jsonTransformer,
35
37
  comment:
36
38
  '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.',
37
39
  })
38
- legal_information: string
40
+ legal_information: any
39
41
 
40
42
  @Column({
41
43
  type: 'longtext',
44
+ transformer: jsonTransformer,
42
45
  comment:
43
46
  'Columna de tipo JSON para almacenar la información que se necesita para la información del representante legal de la empresa.',
44
47
  })
45
- legal_agent: string
48
+ legal_agent: any
46
49
 
47
50
  @Column({
48
51
  type: 'longtext',
49
52
  nullable: true,
53
+ transformer: jsonTransformer,
50
54
  comment:
51
55
  'Columna de tipo JSON para almacenar información adicional sobre el país.',
52
56
  })
53
- details: string
57
+ details: any
54
58
 
55
59
  @Column({
56
60
  default: 1,
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import { resolve } from 'path'
5
5
  import { DataSource, EntityTarget, ObjectLiteral, Repository } from 'typeorm'
6
6
  import { IType } from './interfaces'
7
7
  import { CustomRepository } from '.'
8
+ import moment = require('moment-timezone')
8
9
  export * from './entities.views.routes'
9
10
 
10
11
  const asyncLocalStorage = new AsyncLocalStorage<Map<string, string>>()
@@ -106,6 +107,12 @@ export function getTimeZone(): string {
106
107
  return store?.get('timezone') ?? 'UTC'
107
108
  }
108
109
 
110
+ export function getTimezoneOffset(timezone: string) {
111
+ const now = moment.tz(timezone)
112
+ const offset = now.format('Z')
113
+ return offset
114
+ }
115
+
109
116
  export const getRepositoryByEntity = async <T extends ObjectLiteral>(
110
117
  entity: EntityTarget<T>
111
118
  ): Promise<CustomRepository<T>> => {