test-entity-library-asm 2.3.7 → 2.3.9

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,9 +1,11 @@
1
1
  import { CodeRedemptionHistoryUser } from './CodeRedemptionHistoryUser';
2
2
  import { Company } from './Company';
3
3
  import { Partner } from './Partner';
4
+ import { Local } from '..';
4
5
  export declare class DiscountCodeUser {
5
6
  id: number;
6
7
  company: Company;
8
+ local: Local;
7
9
  code: string;
8
10
  discount: string;
9
11
  type: number;
@@ -14,6 +14,7 @@ var typeorm_1 = require("typeorm");
14
14
  var CodeRedemptionHistoryUser_1 = require("./CodeRedemptionHistoryUser");
15
15
  var Company_1 = require("./Company");
16
16
  var Partner_1 = require("./Partner");
17
+ var __1 = require("..");
17
18
  var DiscountCodeUser = /** @class */ (function () {
18
19
  function DiscountCodeUser() {
19
20
  }
@@ -31,6 +32,15 @@ var DiscountCodeUser = /** @class */ (function () {
31
32
  (0, typeorm_1.JoinColumn)({ name: 'company' }),
32
33
  __metadata("design:type", Company_1.Company)
33
34
  ], DiscountCodeUser.prototype, "company", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.ManyToOne)(function () { return __1.Local; }, function (local) { return local.discount_code_locals; }, {
37
+ onDelete: 'CASCADE',
38
+ onUpdate: 'NO ACTION',
39
+ nullable: true,
40
+ }),
41
+ (0, typeorm_1.JoinColumn)({ name: 'local' }),
42
+ __metadata("design:type", __1.Local)
43
+ ], DiscountCodeUser.prototype, "local", void 0);
34
44
  __decorate([
35
45
  (0, typeorm_1.Column)({ length: 10, comment: 'Código del descuento para compartirlo.' }),
36
46
  __metadata("design:type", String)
@@ -10,7 +10,7 @@ import { Terminal } from './Terminal';
10
10
  import { User } from './User';
11
11
  import { Partner } from './Partner';
12
12
  import { BusinessTypeProduct } from './BusinessTypeProduct';
13
- import { PosSystem } from '..';
13
+ import { DiscountCodeUser, PosSystem } from '..';
14
14
  export declare class Local {
15
15
  id: number;
16
16
  company: Company;
@@ -36,4 +36,5 @@ export declare class Local {
36
36
  terminals: Terminal[];
37
37
  users_favorite_local: User[];
38
38
  business_type_products: BusinessTypeProduct[];
39
+ discount_code_locals: DiscountCodeUser[];
39
40
  }
@@ -187,6 +187,10 @@ var Local = /** @class */ (function () {
187
187
  }),
188
188
  __metadata("design:type", Array)
189
189
  ], Local.prototype, "business_type_products", void 0);
190
+ __decorate([
191
+ (0, typeorm_1.OneToMany)(function () { return __1.DiscountCodeUser; }, function (discountCodeUser) { return discountCodeUser.local; }),
192
+ __metadata("design:type", Array)
193
+ ], Local.prototype, "discount_code_locals", void 0);
190
194
  Local = __decorate([
191
195
  (0, typeorm_1.Entity)({ comment: 'Locales disponibles de las empresas (company).' })
192
196
  ], Local);
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.7",
3
+ "version": "2.3.9",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,6 +9,7 @@ import {
9
9
  import { CodeRedemptionHistoryUser } from './CodeRedemptionHistoryUser'
10
10
  import { Company } from './Company'
11
11
  import { Partner } from './Partner'
12
+ import { Local } from '..'
12
13
 
13
14
  @Entity('discount_code_user', {
14
15
  comment: 'Códigos de descuento para los usuarios.',
@@ -26,6 +27,14 @@ export class DiscountCodeUser {
26
27
  @JoinColumn({ name: 'company' })
27
28
  company: Company
28
29
 
30
+ @ManyToOne(() => Local, (local) => local.discount_code_locals, {
31
+ onDelete: 'CASCADE',
32
+ onUpdate: 'NO ACTION',
33
+ nullable: true,
34
+ })
35
+ @JoinColumn({ name: 'local' })
36
+ local: Local
37
+
29
38
  @Column({ length: 10, comment: 'Código del descuento para compartirlo.' })
30
39
  code: string
31
40
 
@@ -20,7 +20,7 @@ import { Terminal } from './Terminal'
20
20
  import { User } from './User'
21
21
  import { Partner } from './Partner'
22
22
  import { BusinessTypeProduct } from './BusinessTypeProduct'
23
- import { PosSystem } from '..'
23
+ import { DiscountCodeUser, PosSystem } from '..'
24
24
  import { jsonTransformer } from '../transformers/jsonTransformer'
25
25
 
26
26
  @Entity({ comment: 'Locales disponibles de las empresas (company).' })
@@ -165,4 +165,8 @@ export class Local {
165
165
  },
166
166
  })
167
167
  business_type_products: BusinessTypeProduct[]
168
+
169
+ @OneToMany(() => DiscountCodeUser, (discountCodeUser) => discountCodeUser.local)
170
+ discount_code_locals: DiscountCodeUser[]
168
171
  }
172
+
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>> => {