test-entity-library-asm 2.2.5 → 2.2.7
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.
- package/dist/entities.views.routes.d.ts +0 -1
- package/dist/entities.views.routes.js +1 -3
- package/dist/index.d.ts +3 -2
- package/dist/index.js +41 -28
- package/dist/repositories/VerifyLocalRepository.d.ts +4 -11
- package/dist/repositories/VerifyLocalRepository.js +11 -17
- package/package.json +1 -1
- package/src/entities.views.routes.ts +0 -2
- package/src/index.ts +36 -20
- package/src/repositories/VerifyLocalRepository.ts +12 -4
|
@@ -42,4 +42,3 @@ export { BusinessType } from './entities/BusinessType';
|
|
|
42
42
|
export { AuthenticationCredential } from './entities/AuthenticationCredential';
|
|
43
43
|
export { PosSystem } from './entities/PosSystem';
|
|
44
44
|
export { VerifyLocal } from './entities/VerifyLocal';
|
|
45
|
-
export { VerifyLocalRepository } from './repositories/VerifyLocalRepository';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.VerifyLocal = exports.PosSystem = exports.AuthenticationCredential = exports.BusinessType = exports.LocalsCompany = exports.UserAddress = exports.User = exports.TypeMeasureIngredient = exports.TerminalSession = exports.Terminal = exports.Square = exports.RequestStatus = exports.RequestProductGroupComplement = exports.RequestProduct = exports.Request = exports.Region = exports.ProductTopping = exports.ProductIngredient = exports.ProductGroupComplement = exports.ProductGroup = exports.Product = exports.Plan = exports.PaymentMethod = exports.PartnerRole = exports.PartnerPermission = exports.PartnerNotification = exports.Partner = exports.MasterRole = exports.MasterPermission = exports.Master = exports.LocalQualification = exports.Local = exports.DiscountCodeUser = exports.DiscountCodeCompany = exports.Day = exports.Country = exports.Configuration = exports.Company = exports.CodeRedemptionHistoryUser = exports.CodeRedemptionHistoryCompany = exports.City = exports.ScheduleCategory = exports.Category = exports.BusinessTypeProduct = void 0;
|
|
4
4
|
var BusinessTypeProduct_1 = require("./entities/BusinessTypeProduct");
|
|
5
5
|
Object.defineProperty(exports, "BusinessTypeProduct", { enumerable: true, get: function () { return BusinessTypeProduct_1.BusinessTypeProduct; } });
|
|
6
6
|
var Category_1 = require("./entities/Category");
|
|
@@ -89,5 +89,3 @@ var PosSystem_1 = require("./entities/PosSystem");
|
|
|
89
89
|
Object.defineProperty(exports, "PosSystem", { enumerable: true, get: function () { return PosSystem_1.PosSystem; } });
|
|
90
90
|
var VerifyLocal_1 = require("./entities/VerifyLocal");
|
|
91
91
|
Object.defineProperty(exports, "VerifyLocal", { enumerable: true, get: function () { return VerifyLocal_1.VerifyLocal; } });
|
|
92
|
-
var VerifyLocalRepository_1 = require("./repositories/VerifyLocalRepository");
|
|
93
|
-
Object.defineProperty(exports, "VerifyLocalRepository", { enumerable: true, get: function () { return VerifyLocalRepository_1.VerifyLocalRepository; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
2
|
import { DataSource, EntityTarget, ObjectLiteral, Repository } from 'typeorm';
|
|
3
|
-
import { VerifyLocalRepository } from '.';
|
|
4
3
|
export * from './entities.views.routes';
|
|
5
4
|
export declare function createDataBaseSource(): DataSource;
|
|
6
5
|
export declare function showEntityNameEntity<T extends ObjectLiteral>(entity: EntityTarget<T>): Promise<Repository<T>>;
|
|
@@ -8,4 +7,6 @@ export declare function showEntity(entityName: string): Promise<any>;
|
|
|
8
7
|
export declare function callStoredProcedure(storedProcedure: any, elements: any): Promise<any>;
|
|
9
8
|
export declare function timezoneMiddleware(req: Request, res: Response, next: NextFunction): void;
|
|
10
9
|
export declare function getTimeZone(): string;
|
|
11
|
-
export declare
|
|
10
|
+
export declare const getRepositoryByEntity: <T extends ObjectLiteral>(entity: EntityTarget<T>) => Promise<Repository<T> & {
|
|
11
|
+
getVerifyLocals: Function;
|
|
12
|
+
}>;
|
package/dist/index.js
CHANGED
|
@@ -50,12 +50,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.
|
|
53
|
+
exports.getRepositoryByEntity = 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
|
-
var
|
|
58
|
+
var VerifyLocalRepository_1 = require("./repositories/VerifyLocalRepository");
|
|
59
59
|
__exportStar(require("./entities.views.routes"), exports);
|
|
60
60
|
var asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
|
|
61
61
|
var connection = null;
|
|
@@ -172,30 +172,43 @@ function getTimeZone() {
|
|
|
172
172
|
}
|
|
173
173
|
exports.getTimeZone = getTimeZone;
|
|
174
174
|
// Función para obtener repositorios personalizados
|
|
175
|
-
function getRepositoryByName(repositoryName) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
175
|
+
// export async function getRepositoryByName(repositoryName: string) {
|
|
176
|
+
// if (!connection) {
|
|
177
|
+
// connection = createDataBaseSource()
|
|
178
|
+
// await connection.initialize()
|
|
179
|
+
// }
|
|
180
|
+
// switch (repositoryName) {
|
|
181
|
+
// case 'VerifyLocalRepository':
|
|
182
|
+
// return connection.getCustomRepository(VerifyLocalRepository)
|
|
183
|
+
// // return getCustomRepository(VerifyLocalRepository)
|
|
184
|
+
// default:
|
|
185
|
+
// return null
|
|
186
|
+
// }
|
|
187
|
+
// }
|
|
188
|
+
var getRepositoryByEntity = function (entity) { return __awaiter(void 0, void 0, void 0, function () {
|
|
189
|
+
var dataSource;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0:
|
|
193
|
+
dataSource = createDataBaseSource();
|
|
194
|
+
if (!!dataSource.isInitialized) return [3 /*break*/, 2];
|
|
195
|
+
return [4 /*yield*/, dataSource.initialize()];
|
|
196
|
+
case 1:
|
|
197
|
+
_a.sent();
|
|
198
|
+
_a.label = 2;
|
|
199
|
+
case 2: return [2 /*return*/, (0, VerifyLocalRepository_1.createCustomRepository)(entity, dataSource)];
|
|
200
|
+
}
|
|
199
201
|
});
|
|
200
|
-
}
|
|
201
|
-
exports.
|
|
202
|
+
}); };
|
|
203
|
+
exports.getRepositoryByEntity = getRepositoryByEntity;
|
|
204
|
+
// export const createCustomRepository = <T extends ObjectLiteral>(
|
|
205
|
+
// entity: EntityTarget<T>,
|
|
206
|
+
// dataSource: DataSource
|
|
207
|
+
// ): Repository<T> => {
|
|
208
|
+
// class CustomRepository extends Repository<T> {
|
|
209
|
+
// constructor(target: EntityTarget<T>, dataSource: DataSource) {
|
|
210
|
+
// super(target, dataSource.manager);
|
|
211
|
+
// }
|
|
212
|
+
// }
|
|
213
|
+
// return new CustomRepository(entity, dataSource);
|
|
214
|
+
// }
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import { Repository } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
data: VerifyLocal[];
|
|
6
|
-
total: number;
|
|
7
|
-
page: number;
|
|
8
|
-
pageSize: number;
|
|
9
|
-
totalPages: number;
|
|
10
|
-
}>;
|
|
11
|
-
}
|
|
1
|
+
import { DataSource, EntityTarget, Repository, ObjectLiteral } from 'typeorm';
|
|
2
|
+
export declare const createCustomRepository: <T extends ObjectLiteral>(entity: EntityTarget<T>, dataSource: DataSource) => Repository<T> & {
|
|
3
|
+
getVerifyLocals: Function;
|
|
4
|
+
};
|
|
@@ -14,12 +14,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
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;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
17
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -57,15 +51,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
57
51
|
}
|
|
58
52
|
};
|
|
59
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
-
exports.
|
|
54
|
+
exports.createCustomRepository = void 0;
|
|
61
55
|
var typeorm_1 = require("typeorm");
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
function VerifyLocalRepository() {
|
|
56
|
+
var CustomRepository = /** @class */ (function (_super) {
|
|
57
|
+
__extends(CustomRepository, _super);
|
|
58
|
+
function CustomRepository() {
|
|
66
59
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
67
60
|
}
|
|
68
|
-
|
|
61
|
+
CustomRepository.prototype.getVerifyLocals = function (status, page, pageSize, filters) {
|
|
69
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
70
63
|
var queryBuilder, globalValue, _a, data, total;
|
|
71
64
|
return __generator(this, function (_b) {
|
|
@@ -140,9 +133,10 @@ var VerifyLocalRepository = /** @class */ (function (_super) {
|
|
|
140
133
|
});
|
|
141
134
|
});
|
|
142
135
|
};
|
|
143
|
-
|
|
144
|
-
(0, typeorm_1.EntityRepository)(VerifyLocal_1.VerifyLocal)
|
|
145
|
-
], VerifyLocalRepository);
|
|
146
|
-
return VerifyLocalRepository;
|
|
136
|
+
return CustomRepository;
|
|
147
137
|
}(typeorm_1.Repository));
|
|
148
|
-
|
|
138
|
+
var createCustomRepository = function (entity, dataSource) {
|
|
139
|
+
var baseRepository = dataSource.getRepository(entity);
|
|
140
|
+
return baseRepository.extend(CustomRepository.prototype);
|
|
141
|
+
};
|
|
142
|
+
exports.createCustomRepository = createCustomRepository;
|
package/package.json
CHANGED
|
@@ -42,5 +42,3 @@ export { BusinessType } from './entities/BusinessType'
|
|
|
42
42
|
export { AuthenticationCredential } from './entities/AuthenticationCredential'
|
|
43
43
|
export { PosSystem } from './entities/PosSystem'
|
|
44
44
|
export { VerifyLocal } from './entities/VerifyLocal'
|
|
45
|
-
|
|
46
|
-
export { VerifyLocalRepository } from './repositories/VerifyLocalRepository'
|
package/src/index.ts
CHANGED
|
@@ -2,15 +2,9 @@ import { AsyncLocalStorage } from 'async_hooks'
|
|
|
2
2
|
import { config } from 'dotenv'
|
|
3
3
|
import { NextFunction, Request, Response } from 'express'
|
|
4
4
|
import { resolve } from 'path'
|
|
5
|
-
import {
|
|
6
|
-
DataSource,
|
|
7
|
-
EntityTarget,
|
|
8
|
-
getCustomRepository,
|
|
9
|
-
ObjectLiteral,
|
|
10
|
-
Repository,
|
|
11
|
-
} from 'typeorm'
|
|
5
|
+
import { DataSource, EntityTarget, ObjectLiteral, Repository } from 'typeorm'
|
|
12
6
|
import { IType } from './interfaces'
|
|
13
|
-
import {
|
|
7
|
+
import { createCustomRepository } from './repositories/VerifyLocalRepository'
|
|
14
8
|
export * from './entities.views.routes'
|
|
15
9
|
|
|
16
10
|
const asyncLocalStorage = new AsyncLocalStorage<Map<string, string>>()
|
|
@@ -113,17 +107,39 @@ export function getTimeZone(): string {
|
|
|
113
107
|
}
|
|
114
108
|
|
|
115
109
|
// Función para obtener repositorios personalizados
|
|
116
|
-
export async function getRepositoryByName(repositoryName: string) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
110
|
+
// export async function getRepositoryByName(repositoryName: string) {
|
|
111
|
+
// if (!connection) {
|
|
112
|
+
// connection = createDataBaseSource()
|
|
113
|
+
// await connection.initialize()
|
|
114
|
+
// }
|
|
115
|
+
|
|
116
|
+
// switch (repositoryName) {
|
|
117
|
+
// case 'VerifyLocalRepository':
|
|
118
|
+
// return connection.getCustomRepository(VerifyLocalRepository)
|
|
119
|
+
// // return getCustomRepository(VerifyLocalRepository)
|
|
120
|
+
// default:
|
|
121
|
+
// return null
|
|
122
|
+
// }
|
|
123
|
+
// }
|
|
124
|
+
|
|
125
|
+
export const getRepositoryByEntity = async <T extends ObjectLiteral>(
|
|
126
|
+
entity: EntityTarget<T>
|
|
127
|
+
): Promise<Repository<T> & { getVerifyLocals: Function }> => {
|
|
128
|
+
const dataSource = createDataBaseSource()
|
|
129
|
+
if (!dataSource.isInitialized) {
|
|
130
|
+
await dataSource.initialize()
|
|
128
131
|
}
|
|
132
|
+
return createCustomRepository(entity, dataSource)
|
|
129
133
|
}
|
|
134
|
+
|
|
135
|
+
// export const createCustomRepository = <T extends ObjectLiteral>(
|
|
136
|
+
// entity: EntityTarget<T>,
|
|
137
|
+
// dataSource: DataSource
|
|
138
|
+
// ): Repository<T> => {
|
|
139
|
+
// class CustomRepository extends Repository<T> {
|
|
140
|
+
// constructor(target: EntityTarget<T>, dataSource: DataSource) {
|
|
141
|
+
// super(target, dataSource.manager);
|
|
142
|
+
// }
|
|
143
|
+
// }
|
|
144
|
+
// return new CustomRepository(entity, dataSource);
|
|
145
|
+
// }
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { VerifyLocal } from '../entities/VerifyLocal'
|
|
1
|
+
import { DataSource, EntityTarget, Repository, ObjectLiteral } from 'typeorm'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
export class VerifyLocalRepository extends Repository<VerifyLocal> {
|
|
3
|
+
class CustomRepository<T extends ObjectLiteral> extends Repository<T> {
|
|
6
4
|
async getVerifyLocals(
|
|
7
5
|
status: number | null,
|
|
8
6
|
page: number,
|
|
@@ -102,3 +100,13 @@ export class VerifyLocalRepository extends Repository<VerifyLocal> {
|
|
|
102
100
|
}
|
|
103
101
|
}
|
|
104
102
|
}
|
|
103
|
+
|
|
104
|
+
export const createCustomRepository = <T extends ObjectLiteral>(
|
|
105
|
+
entity: EntityTarget<T>,
|
|
106
|
+
dataSource: DataSource
|
|
107
|
+
): Repository<T> & { getVerifyLocals: Function } => {
|
|
108
|
+
const baseRepository = dataSource.getRepository(entity)
|
|
109
|
+
return baseRepository.extend(CustomRepository.prototype) as Repository<T> & {
|
|
110
|
+
getVerifyLocals: Function
|
|
111
|
+
}
|
|
112
|
+
}
|