test-entity-library-asm 3.9.44 → 3.9.46

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,6 +1,5 @@
1
1
  import { CodeRedemptionHistoryCompany } from "./CodeRedemptionHistoryCompany";
2
2
  import { Master } from "./Master";
3
- import { ServiceDiscountsPlan } from "./ServiceDiscountsPlan";
4
3
  export declare class DiscountCodeCompany {
5
4
  id: number;
6
5
  code: string;
@@ -16,5 +15,4 @@ export declare class DiscountCodeCompany {
16
15
  status: number;
17
16
  updated_by: Master;
18
17
  code_redemptions_history_company: CodeRedemptionHistoryCompany[];
19
- service_discounts_plans: ServiceDiscountsPlan[];
20
18
  }
@@ -14,7 +14,7 @@ const typeorm_1 = require("typeorm");
14
14
  const jsonTransformer_1 = require("../transformers/jsonTransformer");
15
15
  const CodeRedemptionHistoryCompany_1 = require("./CodeRedemptionHistoryCompany");
16
16
  const Master_1 = require("./Master");
17
- const ServiceDiscountsPlan_1 = require("./ServiceDiscountsPlan");
17
+ // import { ServiceDiscountsPlan } from "./ServiceDiscountsPlan";
18
18
  let DiscountCodeCompany = class DiscountCodeCompany {
19
19
  };
20
20
  exports.DiscountCodeCompany = DiscountCodeCompany;
@@ -126,10 +126,6 @@ __decorate([
126
126
  (0, typeorm_1.OneToMany)(() => CodeRedemptionHistoryCompany_1.CodeRedemptionHistoryCompany, (codeRedemptionHistoryCompany) => codeRedemptionHistoryCompany.discount_code_company),
127
127
  __metadata("design:type", Array)
128
128
  ], DiscountCodeCompany.prototype, "code_redemptions_history_company", void 0);
129
- __decorate([
130
- (0, typeorm_1.OneToMany)(() => ServiceDiscountsPlan_1.ServiceDiscountsPlan, (serviceDiscountsPlan) => serviceDiscountsPlan.discount),
131
- __metadata("design:type", Array)
132
- ], DiscountCodeCompany.prototype, "service_discounts_plans", void 0);
133
129
  exports.DiscountCodeCompany = DiscountCodeCompany = __decorate([
134
130
  (0, typeorm_1.Entity)("discount_code_company", {
135
131
  comment: "Códigos de descuento para las empresas.",
@@ -1,5 +1,4 @@
1
1
  import { Master } from "./Master";
2
- import { ServiceDiscountsPlan } from "./ServiceDiscountsPlan";
3
2
  export declare class ServicePlan {
4
3
  id_service_plan: number;
5
4
  name: string;
@@ -15,5 +14,4 @@ export declare class ServicePlan {
15
14
  created: Date;
16
15
  updated: Date | null;
17
16
  updated_by: Master | null;
18
- service_discounts_plan: ServiceDiscountsPlan[];
19
17
  }
@@ -13,7 +13,7 @@ exports.ServicePlan = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const jsonTransformer_1 = require("../transformers/jsonTransformer");
15
15
  const Master_1 = require("./Master");
16
- const ServiceDiscountsPlan_1 = require("./ServiceDiscountsPlan");
16
+ // import { ServiceDiscountsPlan } from "./ServiceDiscountsPlan";
17
17
  let ServicePlan = class ServicePlan {
18
18
  };
19
19
  exports.ServicePlan = ServicePlan;
@@ -88,10 +88,6 @@ __decorate([
88
88
  (0, typeorm_1.JoinColumn)({ name: "updated_by" }),
89
89
  __metadata("design:type", Object)
90
90
  ], ServicePlan.prototype, "updated_by", void 0);
91
- __decorate([
92
- (0, typeorm_1.OneToMany)(() => ServiceDiscountsPlan_1.ServiceDiscountsPlan, (serviceDiscountsPlan) => serviceDiscountsPlan.servicePlan),
93
- __metadata("design:type", Array)
94
- ], ServicePlan.prototype, "service_discounts_plan", void 0);
95
91
  exports.ServicePlan = ServicePlan = __decorate([
96
92
  (0, typeorm_1.Entity)("service_plan"),
97
93
  (0, typeorm_1.Unique)(["code"])
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { NextFunction, Request, Response } from "express";
2
2
  import { DataSource, EntityTarget, ObjectLiteral, Repository } from "typeorm";
3
- import { CustomRepository } from "./entities.views.routes";
3
+ import { IBasicCompany, IBasicLazyEvent, IPropsDiscountUserOrCompany, IPropsLocalReserve, IPropsQueryVerifyLocalInformation } from "./interfaces";
4
4
  export * from "./entities.views.routes";
5
5
  export declare function createDataBaseSource(): DataSource;
6
6
  export declare function showEntityNameEntity<T extends ObjectLiteral>(entity: EntityTarget<T>): Promise<Repository<T>>;
@@ -9,4 +9,29 @@ export declare function callStoredProcedure(storedProcedure: any, elements: any)
9
9
  export declare function timezoneMiddleware(req: Request, res: Response, next: NextFunction): void;
10
10
  export declare function getTimeZone(): string;
11
11
  export declare function getTimezoneOffset(timezone: string): string;
12
- export declare const getRepositoryByEntity: <T extends ObjectLiteral>(entity: EntityTarget<T>) => Promise<CustomRepository<T>>;
12
+ export declare const getRepositoryByEntity: <T extends ObjectLiteral>(entity: EntityTarget<T>) => Promise<Repository<T> & {
13
+ getDiscountsCodeUserWrapper(params: IPropsDiscountUserOrCompany): Promise<{
14
+ data: any[];
15
+ totalRecords: number;
16
+ }>;
17
+ getDiscountsCodeCompanyWrapper(params: IBasicLazyEvent): Promise<{
18
+ data: any[];
19
+ totalRecords: number;
20
+ }>;
21
+ getLocalsCompanyInformationWrapper(params: IBasicCompany): Promise<{
22
+ data: any[];
23
+ totalRecords: number;
24
+ }>;
25
+ getVerifyLocalsInformationWrapper(params: IPropsQueryVerifyLocalInformation): Promise<{
26
+ data: any[];
27
+ totalRecords: number;
28
+ }>;
29
+ getLocalReservesInformationWrapper(params: IPropsLocalReserve): Promise<{
30
+ data: any[];
31
+ totalRecords: number;
32
+ }>;
33
+ getLocalsCompanyInformationForTheTableWrapper(params: IBasicCompany): Promise<{
34
+ data: any[];
35
+ totalRecords: number;
36
+ }>;
37
+ }>;
package/dist/index.js CHANGED
@@ -146,16 +146,47 @@ const getRepositoryByEntity = async (entity) => {
146
146
  if (!connection || !connection.isInitialized) {
147
147
  connection = createDataBaseSource();
148
148
  await connection.initialize();
149
- console.log("METADATA CARGADA:", connection.entityMetadatas.map((e) => e.name));
150
149
  }
151
- return connection
152
- .getRepository(entity)
153
- .extend(entities_views_routes_1.CustomRepository.prototype);
150
+ return connection.getRepository(entity).extend({
151
+ async getDiscountsCodeUserWrapper(params) {
152
+ return (0, entities_views_routes_1.getDiscountsCodeUserInformation)(this, params);
153
+ },
154
+ async getDiscountsCodeCompanyWrapper(params) {
155
+ return (0, entities_views_routes_1.getDiscountsCodeCompanyInformation)(this, params);
156
+ },
157
+ async getLocalsCompanyInformationWrapper(params) {
158
+ return (0, entities_views_routes_1.getLocalsCompanyInformation)(this, params);
159
+ },
160
+ async getVerifyLocalsInformationWrapper(params) {
161
+ return (0, entities_views_routes_1.getVerifyLocalsInformation)(this, params);
162
+ },
163
+ async getLocalReservesInformationWrapper(params) {
164
+ return (0, entities_views_routes_1.getLocalReservesInformation)(this, params);
165
+ },
166
+ async getLocalsCompanyInformationForTheTableWrapper(params) {
167
+ return (0, entities_views_routes_1.getLocalsCompanyInformationTable)(this, params);
168
+ },
169
+ });
154
170
  };
155
171
  exports.getRepositoryByEntity = getRepositoryByEntity;
156
172
  // export const getRepositoryByEntity = async <T extends ObjectLiteral>(
157
173
  // entity: EntityTarget<T>,
158
174
  // ): Promise<CustomRepository<T>> => {
175
+ // if (!connection || !connection.isInitialized) {
176
+ // connection = createDataBaseSource();
177
+ // await connection.initialize();
178
+ // console.log(
179
+ // "METADATA CARGADA:",
180
+ // connection.entityMetadatas.map((e) => e.name),
181
+ // );
182
+ // }
183
+ // return connection
184
+ // .getRepository(entity)
185
+ // .extend(CustomRepository.prototype) as CustomRepository<T>;
186
+ // };
187
+ // export const getRepositoryByEntity = async <T extends ObjectLiteral>(
188
+ // entity: EntityTarget<T>,
189
+ // ): Promise<CustomRepository<T>> => {
159
190
  // if (!connection) {
160
191
  // connection = createDataBaseSource();
161
192
  // await connection.initialize();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "3.9.44",
3
+ "version": "3.9.46",
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,7 +9,7 @@ import {
9
9
  import { jsonTransformer } from "../transformers/jsonTransformer";
10
10
  import { CodeRedemptionHistoryCompany } from "./CodeRedemptionHistoryCompany";
11
11
  import { Master } from "./Master";
12
- import { ServiceDiscountsPlan } from "./ServiceDiscountsPlan";
12
+ // import { ServiceDiscountsPlan } from "./ServiceDiscountsPlan";
13
13
 
14
14
  @Entity("discount_code_company", {
15
15
  comment: "Códigos de descuento para las empresas.",
@@ -118,9 +118,9 @@ export class DiscountCodeCompany {
118
118
  )
119
119
  code_redemptions_history_company: CodeRedemptionHistoryCompany[];
120
120
 
121
- @OneToMany(
122
- () => ServiceDiscountsPlan,
123
- (serviceDiscountsPlan) => serviceDiscountsPlan.discount,
124
- )
125
- service_discounts_plans: ServiceDiscountsPlan[];
121
+ // @OneToMany(
122
+ // () => ServiceDiscountsPlan,
123
+ // (serviceDiscountsPlan) => serviceDiscountsPlan.discount,
124
+ // )
125
+ // service_discounts_plans: ServiceDiscountsPlan[];
126
126
  }
@@ -9,7 +9,7 @@ import {
9
9
  } from "typeorm";
10
10
  import { jsonTransformer } from "../transformers/jsonTransformer";
11
11
  import { Master } from "./Master";
12
- import { ServiceDiscountsPlan } from "./ServiceDiscountsPlan";
12
+ // import { ServiceDiscountsPlan } from "./ServiceDiscountsPlan";
13
13
 
14
14
  @Entity("service_plan")
15
15
  @Unique(["code"])
@@ -71,9 +71,9 @@ export class ServicePlan {
71
71
  @JoinColumn({ name: "updated_by" })
72
72
  updated_by: Master | null;
73
73
 
74
- @OneToMany(
75
- () => ServiceDiscountsPlan,
76
- (serviceDiscountsPlan) => serviceDiscountsPlan.servicePlan,
77
- )
78
- service_discounts_plan: ServiceDiscountsPlan[];
74
+ // @OneToMany(
75
+ // () => ServiceDiscountsPlan,
76
+ // (serviceDiscountsPlan) => serviceDiscountsPlan.servicePlan,
77
+ // )
78
+ // service_discounts_plan: ServiceDiscountsPlan[];
79
79
  }
package/src/index.ts CHANGED
@@ -3,9 +3,24 @@ import { config } from "dotenv";
3
3
  import { NextFunction, Request, Response } from "express";
4
4
  import { resolve } from "path";
5
5
  import { DataSource, EntityTarget, ObjectLiteral, Repository } from "typeorm";
6
- import { IType } from "./interfaces";
6
+ import {
7
+ IBasicCompany,
8
+ IBasicLazyEvent,
9
+ IPropsDiscountUserOrCompany,
10
+ IPropsLocalReserve,
11
+ IPropsQueryVerifyLocalInformation,
12
+ IType,
13
+ } from "./interfaces";
7
14
  import moment = require("moment-timezone");
8
- import { CustomRepository } from "./entities.views.routes";
15
+ import {
16
+ CustomRepository,
17
+ getDiscountsCodeCompanyInformation,
18
+ getDiscountsCodeUserInformation,
19
+ getLocalReservesInformation,
20
+ getLocalsCompanyInformation,
21
+ getLocalsCompanyInformationTable,
22
+ getVerifyLocalsInformation,
23
+ } from "./entities.views.routes";
9
24
  export * from "./entities.views.routes";
10
25
  import * as EntitiesViewsRoutes from "./entities.index";
11
26
 
@@ -134,20 +149,57 @@ export function getTimezoneOffset(timezone: string) {
134
149
 
135
150
  export const getRepositoryByEntity = async <T extends ObjectLiteral>(
136
151
  entity: EntityTarget<T>,
137
- ): Promise<CustomRepository<T>> => {
152
+ ) => {
138
153
  if (!connection || !connection.isInitialized) {
139
154
  connection = createDataBaseSource();
140
155
  await connection.initialize();
141
- console.log(
142
- "METADATA CARGADA:",
143
- connection.entityMetadatas.map((e) => e.name),
144
- );
145
156
  }
146
157
 
147
- return connection
148
- .getRepository(entity)
149
- .extend(CustomRepository.prototype) as CustomRepository<T>;
158
+ return connection.getRepository(entity).extend({
159
+ async getDiscountsCodeUserWrapper(params: IPropsDiscountUserOrCompany) {
160
+ return getDiscountsCodeUserInformation(this, params);
161
+ },
162
+
163
+ async getDiscountsCodeCompanyWrapper(params: IBasicLazyEvent) {
164
+ return getDiscountsCodeCompanyInformation(this, params);
165
+ },
166
+
167
+ async getLocalsCompanyInformationWrapper(params: IBasicCompany) {
168
+ return getLocalsCompanyInformation(this, params);
169
+ },
170
+
171
+ async getVerifyLocalsInformationWrapper(
172
+ params: IPropsQueryVerifyLocalInformation,
173
+ ) {
174
+ return getVerifyLocalsInformation(this, params);
175
+ },
176
+
177
+ async getLocalReservesInformationWrapper(params: IPropsLocalReserve) {
178
+ return getLocalReservesInformation(this, params);
179
+ },
180
+
181
+ async getLocalsCompanyInformationForTheTableWrapper(params: IBasicCompany) {
182
+ return getLocalsCompanyInformationTable(this, params);
183
+ },
184
+ });
150
185
  };
186
+
187
+ // export const getRepositoryByEntity = async <T extends ObjectLiteral>(
188
+ // entity: EntityTarget<T>,
189
+ // ): Promise<CustomRepository<T>> => {
190
+ // if (!connection || !connection.isInitialized) {
191
+ // connection = createDataBaseSource();
192
+ // await connection.initialize();
193
+ // console.log(
194
+ // "METADATA CARGADA:",
195
+ // connection.entityMetadatas.map((e) => e.name),
196
+ // );
197
+ // }
198
+
199
+ // return connection
200
+ // .getRepository(entity)
201
+ // .extend(CustomRepository.prototype) as CustomRepository<T>;
202
+ // };
151
203
  // export const getRepositoryByEntity = async <T extends ObjectLiteral>(
152
204
  // entity: EntityTarget<T>,
153
205
  // ): Promise<CustomRepository<T>> => {
@@ -1,7 +0,0 @@
1
- import { ServicePlan } from './ServicePlan';
2
- import { DiscountCodeCompany } from './DiscountCodeCompany';
3
- export declare class ServiceDiscountsPlan {
4
- id: number;
5
- servicePlan: ServicePlan | null;
6
- discount: DiscountCodeCompany | null;
7
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ServiceDiscountsPlan = void 0;
13
- const typeorm_1 = require("typeorm");
14
- const ServicePlan_1 = require("./ServicePlan");
15
- const DiscountCodeCompany_1 = require("./DiscountCodeCompany");
16
- let ServiceDiscountsPlan = class ServiceDiscountsPlan {
17
- };
18
- exports.ServiceDiscountsPlan = ServiceDiscountsPlan;
19
- __decorate([
20
- (0, typeorm_1.PrimaryGeneratedColumn)(),
21
- __metadata("design:type", Number)
22
- ], ServiceDiscountsPlan.prototype, "id", void 0);
23
- __decorate([
24
- (0, typeorm_1.ManyToOne)(() => ServicePlan_1.ServicePlan, (servicePlan) => servicePlan.service_discounts_plan, {
25
- onDelete: 'CASCADE',
26
- onUpdate: 'CASCADE',
27
- }),
28
- (0, typeorm_1.JoinColumn)({ name: 'id_service_plan' }),
29
- __metadata("design:type", Object)
30
- ], ServiceDiscountsPlan.prototype, "servicePlan", void 0);
31
- __decorate([
32
- (0, typeorm_1.ManyToOne)(() => DiscountCodeCompany_1.DiscountCodeCompany, (discountCodeCompany) => discountCodeCompany.discount, {
33
- onDelete: 'CASCADE',
34
- onUpdate: 'CASCADE',
35
- }),
36
- (0, typeorm_1.JoinColumn)({ name: 'id_discount' }),
37
- __metadata("design:type", Object)
38
- ], ServiceDiscountsPlan.prototype, "discount", void 0);
39
- exports.ServiceDiscountsPlan = ServiceDiscountsPlan = __decorate([
40
- (0, typeorm_1.Entity)('service_discounts_plan', {
41
- comment: 'Entidad que enlaza un plan de servicio con un código de descuento de una empresa',
42
- })
43
- ], ServiceDiscountsPlan);
@@ -1,25 +0,0 @@
1
- import { Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
2
- import { ServicePlan } from './ServicePlan';
3
- import { DiscountCodeCompany } from './DiscountCodeCompany';
4
-
5
- @Entity('service_discounts_plan', {
6
- comment: 'Entidad que enlaza un plan de servicio con un código de descuento de una empresa',
7
- })
8
- export class ServiceDiscountsPlan {
9
- @PrimaryGeneratedColumn()
10
- id: number;
11
-
12
- @ManyToOne(() => ServicePlan, (servicePlan) => servicePlan.service_discounts_plan, {
13
- onDelete: 'CASCADE',
14
- onUpdate: 'CASCADE',
15
- })
16
- @JoinColumn({ name: 'id_service_plan' })
17
- servicePlan: ServicePlan | null;
18
-
19
- @ManyToOne(() => DiscountCodeCompany, (discountCodeCompany) => discountCodeCompany.discount, {
20
- onDelete: 'CASCADE',
21
- onUpdate: 'CASCADE',
22
- })
23
- @JoinColumn({ name: 'id_discount' })
24
- discount: DiscountCodeCompany | null;
25
- }