test-entity-library-asm 2.2.6 → 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/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export declare function showEntity(entityName: string): Promise<any>;
|
|
|
7
7
|
export declare function callStoredProcedure(storedProcedure: any, elements: any): Promise<any>;
|
|
8
8
|
export declare function timezoneMiddleware(req: Request, res: Response, next: NextFunction): void;
|
|
9
9
|
export declare function getTimeZone(): string;
|
|
10
|
-
export declare const getRepositoryByEntity: <T extends ObjectLiteral>(entity: EntityTarget<T>) => Promise<Repository<T
|
|
11
|
-
|
|
10
|
+
export declare const getRepositoryByEntity: <T extends ObjectLiteral>(entity: EntityTarget<T>) => Promise<Repository<T> & {
|
|
11
|
+
getVerifyLocals: Function;
|
|
12
|
+
}>;
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
3
|
if (k2 === undefined) k2 = k;
|
|
19
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -65,11 +50,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
65
50
|
}
|
|
66
51
|
};
|
|
67
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
-
exports.
|
|
53
|
+
exports.getRepositoryByEntity = exports.getTimeZone = exports.timezoneMiddleware = exports.callStoredProcedure = exports.showEntity = exports.showEntityNameEntity = exports.createDataBaseSource = void 0;
|
|
69
54
|
var async_hooks_1 = require("async_hooks");
|
|
70
55
|
var dotenv_1 = require("dotenv");
|
|
71
56
|
var path_1 = require("path");
|
|
72
57
|
var typeorm_1 = require("typeorm");
|
|
58
|
+
var VerifyLocalRepository_1 = require("./repositories/VerifyLocalRepository");
|
|
73
59
|
__exportStar(require("./entities.views.routes"), exports);
|
|
74
60
|
var asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
|
|
75
61
|
var connection = null;
|
|
@@ -210,19 +196,19 @@ var getRepositoryByEntity = function (entity) { return __awaiter(void 0, void 0,
|
|
|
210
196
|
case 1:
|
|
211
197
|
_a.sent();
|
|
212
198
|
_a.label = 2;
|
|
213
|
-
case 2: return [2 /*return*/, (0,
|
|
199
|
+
case 2: return [2 /*return*/, (0, VerifyLocalRepository_1.createCustomRepository)(entity, dataSource)];
|
|
214
200
|
}
|
|
215
201
|
});
|
|
216
202
|
}); };
|
|
217
203
|
exports.getRepositoryByEntity = getRepositoryByEntity;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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,13 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
getVerifyLocals(status: number | null, page: number, pageSize: number, filters: any): Promise<{
|
|
6
|
-
data: VerifyLocal[];
|
|
7
|
-
total: number;
|
|
8
|
-
page: number;
|
|
9
|
-
pageSize: number;
|
|
10
|
-
totalPages: number;
|
|
11
|
-
}>;
|
|
12
|
-
}
|
|
13
|
-
export default VerifyLocalRepository;
|
|
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
|
+
};
|
|
@@ -51,13 +51,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.createCustomRepository = void 0;
|
|
54
55
|
var typeorm_1 = require("typeorm");
|
|
55
|
-
var
|
|
56
|
-
__extends(
|
|
57
|
-
function
|
|
58
|
-
return _super.
|
|
56
|
+
var CustomRepository = /** @class */ (function (_super) {
|
|
57
|
+
__extends(CustomRepository, _super);
|
|
58
|
+
function CustomRepository() {
|
|
59
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
CustomRepository.prototype.getVerifyLocals = function (status, page, pageSize, filters) {
|
|
61
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
62
63
|
var queryBuilder, globalValue, _a, data, total;
|
|
63
64
|
return __generator(this, function (_b) {
|
|
@@ -132,6 +133,10 @@ var VerifyLocalRepository = /** @class */ (function (_super) {
|
|
|
132
133
|
});
|
|
133
134
|
});
|
|
134
135
|
};
|
|
135
|
-
return
|
|
136
|
+
return CustomRepository;
|
|
136
137
|
}(typeorm_1.Repository));
|
|
137
|
-
|
|
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
package/src/index.ts
CHANGED
|
@@ -2,13 +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
|
-
ObjectLiteral,
|
|
9
|
-
Repository
|
|
10
|
-
} from 'typeorm'
|
|
5
|
+
import { DataSource, EntityTarget, ObjectLiteral, Repository } from 'typeorm'
|
|
11
6
|
import { IType } from './interfaces'
|
|
7
|
+
import { createCustomRepository } from './repositories/VerifyLocalRepository'
|
|
12
8
|
export * from './entities.views.routes'
|
|
13
9
|
|
|
14
10
|
const asyncLocalStorage = new AsyncLocalStorage<Map<string, string>>()
|
|
@@ -128,22 +124,22 @@ export function getTimeZone(): string {
|
|
|
128
124
|
|
|
129
125
|
export const getRepositoryByEntity = async <T extends ObjectLiteral>(
|
|
130
126
|
entity: EntityTarget<T>
|
|
131
|
-
): Promise<Repository<T
|
|
132
|
-
const dataSource = createDataBaseSource()
|
|
127
|
+
): Promise<Repository<T> & { getVerifyLocals: Function }> => {
|
|
128
|
+
const dataSource = createDataBaseSource()
|
|
133
129
|
if (!dataSource.isInitialized) {
|
|
134
|
-
await dataSource.initialize()
|
|
130
|
+
await dataSource.initialize()
|
|
135
131
|
}
|
|
136
|
-
return createCustomRepository(entity, dataSource)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export const createCustomRepository = <T extends ObjectLiteral>(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
): Repository<T> => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
132
|
+
return createCustomRepository(entity, dataSource)
|
|
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,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { VerifyLocal } from '../entities/VerifyLocal'
|
|
3
|
-
|
|
4
|
-
class VerifyLocalRepository extends Repository<VerifyLocal> {
|
|
5
|
-
constructor(target: EntityTarget<VerifyLocal>, dataSource: DataSource) {
|
|
6
|
-
super(target, dataSource.manager)
|
|
7
|
-
}
|
|
1
|
+
import { DataSource, EntityTarget, Repository, ObjectLiteral } from 'typeorm'
|
|
8
2
|
|
|
3
|
+
class CustomRepository<T extends ObjectLiteral> extends Repository<T> {
|
|
9
4
|
async getVerifyLocals(
|
|
10
5
|
status: number | null,
|
|
11
6
|
page: number,
|
|
@@ -106,4 +101,12 @@ class VerifyLocalRepository extends Repository<VerifyLocal> {
|
|
|
106
101
|
}
|
|
107
102
|
}
|
|
108
103
|
|
|
109
|
-
export
|
|
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
|
+
}
|