nestjs-typeorm3-kit 0.1.1
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/@types/index.d.ts +17 -0
- package/dist/@types/index.d.ts.map +1 -0
- package/dist/@types/index.js +15 -0
- package/dist/@types/index.js.map +1 -0
- package/dist/common/decorator/index.d.ts +3 -0
- package/dist/common/decorator/index.d.ts.map +1 -0
- package/dist/common/decorator/index.js +39 -0
- package/dist/common/decorator/index.js.map +1 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +18 -0
- package/dist/common/index.js.map +1 -0
- package/dist/controller/decorator/index.d.ts +10 -0
- package/dist/controller/decorator/index.d.ts.map +1 -0
- package/dist/controller/decorator/index.js +141 -0
- package/dist/controller/decorator/index.js.map +1 -0
- package/dist/controller/index.d.ts +2 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +18 -0
- package/dist/controller/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/module/decorator/index.d.ts +6 -0
- package/dist/module/decorator/index.d.ts.map +1 -0
- package/dist/module/decorator/index.js +51 -0
- package/dist/module/decorator/index.js.map +1 -0
- package/dist/module/index.d.ts +2 -0
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +18 -0
- package/dist/module/index.js.map +1 -0
- package/dist/repository/config/constants.d.ts +5 -0
- package/dist/repository/config/constants.d.ts.map +1 -0
- package/dist/repository/config/constants.js +8 -0
- package/dist/repository/config/constants.js.map +1 -0
- package/dist/repository/config/index.d.ts +4 -0
- package/dist/repository/config/index.d.ts.map +1 -0
- package/dist/repository/config/index.js +20 -0
- package/dist/repository/config/index.js.map +1 -0
- package/dist/repository/config/types.d.ts +5 -0
- package/dist/repository/config/types.d.ts.map +1 -0
- package/dist/repository/config/types.js +3 -0
- package/dist/repository/config/types.js.map +1 -0
- package/dist/repository/config/utils.d.ts +6 -0
- package/dist/repository/config/utils.d.ts.map +1 -0
- package/dist/repository/config/utils.js +93 -0
- package/dist/repository/config/utils.js.map +1 -0
- package/dist/repository/decorator/index.d.ts +7 -0
- package/dist/repository/decorator/index.d.ts.map +1 -0
- package/dist/repository/decorator/index.js +16 -0
- package/dist/repository/decorator/index.js.map +1 -0
- package/dist/repository/index.d.ts +4 -0
- package/dist/repository/index.d.ts.map +1 -0
- package/dist/repository/index.js +20 -0
- package/dist/repository/index.js.map +1 -0
- package/dist/repository/module/index.d.ts +25 -0
- package/dist/repository/module/index.d.ts.map +1 -0
- package/dist/repository/module/index.js +134 -0
- package/dist/repository/module/index.js.map +1 -0
- package/dist/transaction/decorator/index.d.ts +7 -0
- package/dist/transaction/decorator/index.d.ts.map +1 -0
- package/dist/transaction/decorator/index.js +32 -0
- package/dist/transaction/decorator/index.js.map +1 -0
- package/dist/transaction/index.d.ts +3 -0
- package/dist/transaction/index.d.ts.map +1 -0
- package/dist/transaction/index.js +19 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction/setup/index.d.ts +2 -0
- package/dist/transaction/setup/index.d.ts.map +1 -0
- package/dist/transaction/setup/index.js +8 -0
- package/dist/transaction/setup/index.js.map +1 -0
- package/dist/validate/decorator/index.d.ts +9 -0
- package/dist/validate/decorator/index.d.ts.map +1 -0
- package/dist/validate/decorator/index.js +48 -0
- package/dist/validate/decorator/index.js.map +1 -0
- package/dist/validate/index.d.ts +2 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +18 -0
- package/dist/validate/index.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getDefRepositoryToken = getDefRepositoryToken;
|
|
40
|
+
exports.getEntityByRepository = getEntityByRepository;
|
|
41
|
+
exports.loadRepositoriesFromPath = loadRepositoriesFromPath;
|
|
42
|
+
const typeorm_1 = require("typeorm");
|
|
43
|
+
const constants_1 = require("./constants");
|
|
44
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
45
|
+
function getDefRepositoryToken(repository, dataSource = constants_1.DEFAULT_CONNECTION_NAME) {
|
|
46
|
+
if (!repository) {
|
|
47
|
+
throw new Error('repository is not empty');
|
|
48
|
+
}
|
|
49
|
+
const connectionPrefix = getDataSourcePrefix(dataSource);
|
|
50
|
+
if (repository instanceof Function && repository.prototype instanceof typeorm_1.Repository) {
|
|
51
|
+
if (!connectionPrefix) {
|
|
52
|
+
return repository;
|
|
53
|
+
}
|
|
54
|
+
return `${connectionPrefix}${getToken(repository)}`;
|
|
55
|
+
}
|
|
56
|
+
return `${connectionPrefix}${repository.name}Repository`;
|
|
57
|
+
}
|
|
58
|
+
function getEntityByRepository(repository) {
|
|
59
|
+
const entity = Reflect.getMetadata(constants_1.ENTITY_METADATA_KEY, repository);
|
|
60
|
+
if (!entity) {
|
|
61
|
+
throw new Error(`Repository: ${repository.name} undetermined entity`);
|
|
62
|
+
}
|
|
63
|
+
return entity;
|
|
64
|
+
}
|
|
65
|
+
function getToken(repository) {
|
|
66
|
+
return repository.name;
|
|
67
|
+
}
|
|
68
|
+
function getDataSourcePrefix(dataSource = constants_1.DEFAULT_CONNECTION_NAME) {
|
|
69
|
+
if (dataSource === constants_1.DEFAULT_CONNECTION_NAME) {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
if (typeof dataSource === 'string') {
|
|
73
|
+
return dataSource + '_';
|
|
74
|
+
}
|
|
75
|
+
if (dataSource.name === constants_1.DEFAULT_CONNECTION_NAME || !dataSource.name) {
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
return dataSource.name + '_';
|
|
79
|
+
}
|
|
80
|
+
async function loadRepositoriesFromPath(pattern) {
|
|
81
|
+
const files = await (0, fast_glob_1.default)(pattern, { absolute: true });
|
|
82
|
+
const repositories = [];
|
|
83
|
+
for (const file of files) {
|
|
84
|
+
const moduleExports = await Promise.resolve(`${file}`).then(s => __importStar(require(s)));
|
|
85
|
+
for (const value of Object.values(moduleExports)) {
|
|
86
|
+
if (typeof value === 'function') {
|
|
87
|
+
repositories.push(value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return repositories;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/repository/config/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,sDAeC;AAED,sDAOC;AAoBD,4DAcC;AAhED,qCAAyF;AAEzF,2CAA2E;AAE3E,0DAAiC;AAEjC,SAAgB,qBAAqB,CACnC,UAAsB,EACtB,aAAsD,mCAAuB;IAE7E,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACzD,IAAI,UAAU,YAAY,QAAQ,IAAI,UAAU,CAAC,SAAS,YAAY,oBAAiB,EAAE,CAAC;QACxF,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;IACtD,CAAC;IACD,OAAO,GAAG,gBAAgB,GAAG,UAAU,CAAC,IAAI,YAAY,CAAC;AAC3D,CAAC;AAED,SAAgB,qBAAqB,CAAC,UAAsB;IAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,+BAAmB,EAAE,UAAU,CAAC,CAAC;IACpE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,CAAC,IAAI,sBAAsB,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,QAAQ,CAAC,UAAsB;IACtC,OAAO,UAAU,CAAC,IAAI,CAAC;AACzB,CAAC;AAED,SAAS,mBAAmB,CAC1B,aAAsD,mCAAuB;IAE7E,IAAI,UAAU,KAAK,mCAAuB,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,UAAU,GAAG,GAAG,CAAC;IAC1B,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,KAAK,mCAAuB,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACpE,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,GAAG,GAAG,CAAC;AAC/B,CAAC;AACM,KAAK,UAAU,wBAAwB,CAAC,OAAe;IAC5D,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAQ,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,MAAM,YAAY,GAAU,EAAE,CAAC;IAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,aAAa,GAAG,yBAAa,IAAI,uCAAC,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;YACjD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DataSource, DataSourceOptions, EntityTarget, ObjectLiteral } from 'typeorm';
|
|
2
|
+
import { Repository } from '../config/types';
|
|
3
|
+
export declare function DefEntityRepository(target: EntityTarget<ObjectLiteral>): (constructor: {
|
|
4
|
+
new (...args: any[]): any;
|
|
5
|
+
}) => void;
|
|
6
|
+
export declare function InjectRepo(repository: Repository, dataSource?: string | DataSource | DataSourceOptions): PropertyDecorator & ParameterDecorator;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repository/decorator/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1F,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,aAAa,CAAC,IACpD,aAAa;IAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;CAAE,UAG5D;AAED,wBAAgB,UAAU,CACxB,UAAU,EAAE,UAAU,EACtB,UAAU,GAAE,MAAM,GAAG,UAAU,GAAG,iBAA6B,0CAGhE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefEntityRepository = DefEntityRepository;
|
|
4
|
+
exports.InjectRepo = InjectRepo;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const constants_1 = require("../config/constants");
|
|
7
|
+
const utils_1 = require("../config/utils");
|
|
8
|
+
function DefEntityRepository(target) {
|
|
9
|
+
return function (constructor) {
|
|
10
|
+
Reflect.defineMetadata(constants_1.ENTITY_METADATA_KEY, target, constructor);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function InjectRepo(repository, dataSource = 'default') {
|
|
14
|
+
return (0, common_1.Inject)((0, utils_1.getDefRepositoryToken)(repository, dataSource));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repository/decorator/index.ts"],"names":[],"mappings":";;AAMA,kDAIC;AAED,gCAKC;AAjBD,2CAAwC;AAExC,mDAA0D;AAE1D,2CAAwD;AAExD,SAAgB,mBAAmB,CAAC,MAAmC;IACrE,OAAO,UAAU,WAA0C;QACzD,OAAO,CAAC,cAAc,CAAC,+BAAmB,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACnE,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CACxB,UAAsB,EACtB,aAAsD,SAAS;IAE/D,OAAO,IAAA,eAAM,EAAC,IAAA,6BAAqB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repository/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config"), exports);
|
|
18
|
+
__exportStar(require("./decorator"), exports);
|
|
19
|
+
__exportStar(require("./module"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repository/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DynamicModule, ModuleMetadata, Type } from "@nestjs/common";
|
|
2
|
+
import type { DataSource, DataSourceOptions } from "typeorm";
|
|
3
|
+
import type { Repository } from "../config/types";
|
|
4
|
+
export interface DefRepositoryModuleOptions {
|
|
5
|
+
globPattern: string;
|
|
6
|
+
dataSource?: string | DataSource | DataSourceOptions;
|
|
7
|
+
}
|
|
8
|
+
export interface DefRepositoryOptionsFactory {
|
|
9
|
+
createDefRepositoryOptions(): Promise<DefRepositoryModuleOptions> | DefRepositoryModuleOptions;
|
|
10
|
+
}
|
|
11
|
+
export interface DefRepositoryModuleAsyncOptions extends Pick<ModuleMetadata, "imports"> {
|
|
12
|
+
useFactory?: (...args: any[]) => Promise<DefRepositoryModuleOptions> | DefRepositoryModuleOptions;
|
|
13
|
+
useClass?: Type<DefRepositoryOptionsFactory>;
|
|
14
|
+
useExisting?: Type<DefRepositoryOptionsFactory>;
|
|
15
|
+
inject?: any[];
|
|
16
|
+
}
|
|
17
|
+
export declare class DefRepositoryModule {
|
|
18
|
+
static forFeature(repositories: Repository[], dataSource?: string | DataSource | DataSourceOptions): DynamicModule;
|
|
19
|
+
static forRoot(options: DefRepositoryModuleOptions): Promise<DynamicModule>;
|
|
20
|
+
static forRootAsync(options: DefRepositoryModuleAsyncOptions): Promise<DynamicModule>;
|
|
21
|
+
private static createAsyncProviders;
|
|
22
|
+
private static resolveOptions;
|
|
23
|
+
private static loadRepositories;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repository/module/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAY,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQlD,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,iBAAiB,CAAC;CACtD;AAED,MAAM,WAAW,2BAA2B;IAC1C,0BAA0B,IACtB,OAAO,CAAC,0BAA0B,CAAC,GACnC,0BAA0B,CAAC;CAChC;AAED,MAAM,WAAW,+BACf,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC;IACvC,UAAU,CAAC,EAAE,CACX,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,OAAO,CAAC,0BAA0B,CAAC,GAAG,0BAA0B,CAAC;IACtE,QAAQ,CAAC,EAAE,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC7C,WAAW,CAAC,EAAE,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAChD,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAsBD,qBAAa,mBAAmB;IAI9B,MAAM,CAAC,UAAU,CACf,YAAY,EAAE,UAAU,EAAE,EAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,iBAAiB,GACnD,aAAa;WAQH,OAAO,CAClB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,aAAa,CAAC;WAYZ,YAAY,CACvB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,aAAa,CAAC;IAuBzB,OAAO,CAAC,MAAM,CAAC,oBAAoB;mBAmCd,cAAc;mBAiBd,gBAAgB;CAmBtC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DefRepositoryModule = void 0;
|
|
40
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
41
|
+
const utils_1 = require("../config/utils");
|
|
42
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
43
|
+
const constants_1 = require("../config/constants");
|
|
44
|
+
function getProviders(repositories, dataSource) {
|
|
45
|
+
return repositories.map((repository) => {
|
|
46
|
+
const entity = (0, utils_1.getEntityByRepository)(repository);
|
|
47
|
+
return {
|
|
48
|
+
provide: (0, utils_1.getDefRepositoryToken)(repository, dataSource),
|
|
49
|
+
useFactory: (dataSource) => {
|
|
50
|
+
return new repository(entity, dataSource.manager, dataSource === null || dataSource === void 0 ? void 0 : dataSource.createQueryRunner());
|
|
51
|
+
},
|
|
52
|
+
inject: [(0, typeorm_1.getDataSourceToken)(dataSource)],
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
class DefRepositoryModule {
|
|
57
|
+
static forFeature(repositories, dataSource) {
|
|
58
|
+
const providers = getProviders(repositories, dataSource);
|
|
59
|
+
return { module: DefRepositoryModule, providers, exports: providers };
|
|
60
|
+
}
|
|
61
|
+
static async forRoot(options) {
|
|
62
|
+
const repositories = await DefRepositoryModule.loadRepositories(options.globPattern);
|
|
63
|
+
console.log("==== forRoot ===", repositories);
|
|
64
|
+
const providers = getProviders(repositories, options.dataSource);
|
|
65
|
+
return { module: DefRepositoryModule, providers, exports: providers };
|
|
66
|
+
}
|
|
67
|
+
static async forRootAsync(options) {
|
|
68
|
+
const asyncProviders = DefRepositoryModule.createAsyncProviders(options);
|
|
69
|
+
const opts = await DefRepositoryModule.resolveOptions(options);
|
|
70
|
+
const repositories = await DefRepositoryModule.loadRepositories(opts.globPattern);
|
|
71
|
+
const providers = getProviders(repositories, opts.dataSource);
|
|
72
|
+
return {
|
|
73
|
+
module: DefRepositoryModule,
|
|
74
|
+
imports: options.imports || [],
|
|
75
|
+
providers: [...asyncProviders, ...providers],
|
|
76
|
+
exports: [...providers],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
static createAsyncProviders(options) {
|
|
80
|
+
if (options.useFactory) {
|
|
81
|
+
return [
|
|
82
|
+
{
|
|
83
|
+
provide: constants_1.DEF_REPOSITORY_OPTIONS,
|
|
84
|
+
useFactory: options.useFactory,
|
|
85
|
+
inject: options.inject || [],
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
const injectClass = options.useClass || options.useExisting;
|
|
90
|
+
if (!injectClass) {
|
|
91
|
+
throw new Error("Invalid async configuration. Must provide useFactory, useClass, or useExisting.");
|
|
92
|
+
}
|
|
93
|
+
const providers = [
|
|
94
|
+
{
|
|
95
|
+
provide: constants_1.DEF_REPOSITORY_OPTIONS,
|
|
96
|
+
useFactory: async (factory) => factory.createDefRepositoryOptions(),
|
|
97
|
+
inject: [injectClass],
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
if (options.useClass) {
|
|
101
|
+
providers.push({ provide: injectClass, useClass: injectClass });
|
|
102
|
+
}
|
|
103
|
+
return providers;
|
|
104
|
+
}
|
|
105
|
+
static async resolveOptions(options) {
|
|
106
|
+
if (options.useFactory) {
|
|
107
|
+
return await options.useFactory(...(options.inject || []));
|
|
108
|
+
}
|
|
109
|
+
const injectClass = options.useClass || options.useExisting;
|
|
110
|
+
if (!injectClass) {
|
|
111
|
+
throw new Error("Missing configuration provider (useClass, useExisting or useFactory).");
|
|
112
|
+
}
|
|
113
|
+
const instance = new injectClass();
|
|
114
|
+
return await instance.createDefRepositoryOptions();
|
|
115
|
+
}
|
|
116
|
+
static async loadRepositories(globPattern) {
|
|
117
|
+
const files = await (0, fast_glob_1.default)(globPattern, { absolute: true });
|
|
118
|
+
const repositories = [];
|
|
119
|
+
for (const file of files) {
|
|
120
|
+
const moduleExports = await Promise.resolve(`${file}`).then(s => __importStar(require(s)));
|
|
121
|
+
for (const exported of Object.values(moduleExports)) {
|
|
122
|
+
if (typeof exported === "function") {
|
|
123
|
+
const hasEntityMeta = Reflect.hasMetadata(constants_1.ENTITY_METADATA_KEY, exported);
|
|
124
|
+
if (hasEntityMeta) {
|
|
125
|
+
repositories.push(exported);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return repositories;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.DefRepositoryModule = DefRepositoryModule;
|
|
134
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repository/module/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAqD;AAGrD,2CAA+E;AAE/E,0DAAiC;AACjC,mDAI6B;AAuB7B,SAAS,YAAY,CACnB,YAA0B,EAC1B,UAAoD;IAEpD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAA,6BAAqB,EAAC,UAAU,CAAC,CAAC;QACjD,OAAO;YACL,OAAO,EAAE,IAAA,6BAAqB,EAAC,UAAU,EAAE,UAAU,CAAC;YACtD,UAAU,EAAE,CAAC,UAAsB,EAAE,EAAE;gBACrC,OAAO,IAAI,UAAU,CACnB,MAAM,EACN,UAAU,CAAC,OAAO,EAClB,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,EAAE,CAChC,CAAC;YACJ,CAAC;YACD,MAAM,EAAE,CAAC,IAAA,4BAAkB,EAAC,UAAU,CAAC,CAAC;SACzC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAa,mBAAmB;IAI9B,MAAM,CAAC,UAAU,CACf,YAA0B,EAC1B,UAAoD;QAEpD,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,EAAE,UAAU,CA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AAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9D,MAAM,YAAY,GAAU,EAAE,CAAC;QAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,aAAa,GAAG,yBAAa,IAAI,uCAAC,CAAC;YACzC,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;gBACpD,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;oBACnC,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CACvC,+BAAmB,EACnB,QAAQ,CACT,CAAC;oBACF,IAAI,aAAa,EAAE,CAAC;wBAClB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBAC9B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AA7HD,kDA6HC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Propagation } from 'typeorm-transactional';
|
|
2
|
+
export declare function DefTransaction(options?: {
|
|
3
|
+
connectionName?: string | (() => string | undefined);
|
|
4
|
+
propagation?: Propagation;
|
|
5
|
+
isoLevel?: 'READ_UNCOMMITTED' | 'READ_COMMITTED' | 'REPEATABLE_READ' | 'SERIALIZABLE';
|
|
6
|
+
}): MethodDecorator;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAiB,MAAM,uBAAuB,CAAC;AAOnF,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE;IACvC,cAAc,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;IACrD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,kBAAkB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,cAAc,CAAC;CACvF,GAAG,eAAe,CAoClB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefTransaction = DefTransaction;
|
|
4
|
+
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
5
|
+
function DefTransaction(options) {
|
|
6
|
+
if (!options) {
|
|
7
|
+
return function (target, propertyKey, descriptor) {
|
|
8
|
+
return (0, typeorm_transactional_1.Transactional)({})(target, propertyKey, descriptor);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const { connectionName = undefined, propagation = undefined, isoLevel = undefined } = options;
|
|
12
|
+
let isolationLevel = undefined;
|
|
13
|
+
Object.keys(typeorm_transactional_1.IsolationLevel).forEach(key => {
|
|
14
|
+
if (isoLevel === key) {
|
|
15
|
+
isolationLevel = typeorm_transactional_1.IsolationLevel[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const mixOptions = {};
|
|
19
|
+
if (connectionName) {
|
|
20
|
+
Object.assign(mixOptions, { connectionName });
|
|
21
|
+
}
|
|
22
|
+
if (propagation) {
|
|
23
|
+
Object.assign(mixOptions, { propagation });
|
|
24
|
+
}
|
|
25
|
+
if (isoLevel) {
|
|
26
|
+
Object.assign(mixOptions, { isoLevel });
|
|
27
|
+
}
|
|
28
|
+
return function (target, propertyKey, descriptor) {
|
|
29
|
+
return (0, typeorm_transactional_1.Transactional)(mixOptions)(target, propertyKey, descriptor);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transaction/decorator/index.ts"],"names":[],"mappings":";;AAOA,wCAwCC;AA/CD,iEAAmF;AAOnF,SAAgB,cAAc,CAAC,OAI9B;IACC,IAAI,C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5B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./decorator"), exports);
|
|
18
|
+
__exportStar(require("./setup"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transaction/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":"AACA,wBAAgB,uBAAuB,SAEtC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupTransactionContext = setupTransactionContext;
|
|
4
|
+
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
5
|
+
function setupTransactionContext() {
|
|
6
|
+
(0, typeorm_transactional_1.initializeTransactionalContext)();
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":";;AACA,0DAEC;AAHD,iEAAuE;AACvE,SAAgB,uBAAuB;IACrC,IAAA,sDAA8B,GAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ValidationOptions } from "class-validator";
|
|
2
|
+
import { CountryCode } from "libphonenumber-js";
|
|
3
|
+
export interface IValidationOptions extends ValidationOptions {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function IsPhoneNumber(region: CountryCode, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
7
|
+
export declare function IsNumber(validationOptions?: IValidationOptions): PropertyDecorator;
|
|
8
|
+
export declare function IsLongerThan(property: string, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validate/decorator/index.ts"],"names":[],"mappings":"AACA,OAAO,EAML,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAKD,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,EACnB,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,iBAAiB,CAKnB;AAKD,wBAAgB,QAAQ,CACtB,iBAAiB,CAAC,EAAE,kBAAkB,GACrC,iBAAiB,CAWnB;AAKD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,iBAAiB,GAAE,iBAAsB,GACxC,iBAAiB,CAyBnB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsPhoneNumber = IsPhoneNumber;
|
|
4
|
+
exports.IsNumber = IsNumber;
|
|
5
|
+
exports.IsLongerThan = IsLongerThan;
|
|
6
|
+
const class_transformer_1 = require("class-transformer");
|
|
7
|
+
const class_validator_1 = require("class-validator");
|
|
8
|
+
function IsPhoneNumber(region, validationOptions) {
|
|
9
|
+
return function (target, propertyKey) {
|
|
10
|
+
(0, class_transformer_1.Type)(() => String)(target, propertyKey);
|
|
11
|
+
(0, class_validator_1.IsPhoneNumber)(region, validationOptions)(target, propertyKey);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function IsNumber(validationOptions) {
|
|
15
|
+
return function (target, propertyKey) {
|
|
16
|
+
var _a;
|
|
17
|
+
const isRequired = (_a = validationOptions === null || validationOptions === void 0 ? void 0 : validationOptions.required) !== null && _a !== void 0 ? _a : false;
|
|
18
|
+
if (!isRequired) {
|
|
19
|
+
(0, class_validator_1.IsOptional)({ each: true })(target, propertyKey);
|
|
20
|
+
}
|
|
21
|
+
(0, class_transformer_1.Type)(() => Number)(target, propertyKey);
|
|
22
|
+
(0, class_validator_1.IsNumber)({ allowNaN: false }, validationOptions)(target, propertyKey);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function IsLongerThan(property, validationOptions = {}) {
|
|
26
|
+
return function (object, propertyKey) {
|
|
27
|
+
if (!validationOptions.message) {
|
|
28
|
+
validationOptions.message = `${String(propertyKey)} must be longer than ${property}`;
|
|
29
|
+
}
|
|
30
|
+
(0, class_validator_1.registerDecorator)({
|
|
31
|
+
name: "isLongerThan",
|
|
32
|
+
target: object.constructor,
|
|
33
|
+
propertyName: propertyKey,
|
|
34
|
+
constraints: [property],
|
|
35
|
+
options: validationOptions,
|
|
36
|
+
validator: {
|
|
37
|
+
validate(value, args) {
|
|
38
|
+
const [relatedPropertyName] = args.constraints;
|
|
39
|
+
const relatedValue = args.object[relatedPropertyName];
|
|
40
|
+
return (typeof value === "string" &&
|
|
41
|
+
typeof relatedValue === "string" &&
|
|
42
|
+
value.length > relatedValue.length);
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validate/decorator/index.ts"],"names":[],"mappings":";;AAkBA,sCAQC;AAKD,4BAaC;AAKD,oCA4BC;AA7ED,yDAAyC;AACzC,qDAOyB;AAUzB,SAAgB,aAAa,CAC3B,MAAmB,EACnB,iBAAqC;IAErC,OAAO,UAAU,MAAc,EAAE,WAA4B;QAC3D,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACxC,IAAA,+BAAgB,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnE,CAAC,CAAC;AACJ,CAAC;AAKD,SAAgB,QAAQ,CACtB,iBAAsC;IAEtC,OAAO,UAAU,MAAc,EAAE,WAA4B;;QAC3D,MAAM,UAAU,GAAG,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,QAAQ,mCAAI,KAAK,CAAC;QAExD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,IAAA,4BAAU,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAClD,CAAC;QAED,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACxC,IAAA,0BAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,iBAAiB,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAKD,SAAgB,YAAY,CAC1B,QAAgB,EAChB,oBAAuC,EAAE;IAEzC,OAAO,UAAU,MAAc,EAAE,WAA4B;QAC3D,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;YAC/B,iBAAiB,CAAC,OAAO,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,wBAAwB,QAAQ,EAAE,CAAC;QACvF,CAAC;QAED,IAAA,mCAAiB,EAAC;YAChB,IAAI,EAAE,cAAc;YACpB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,WAAqB;YACnC,WAAW,EAAE,CAAC,QAAQ,CAAC;YACvB,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE;gBACT,QAAQ,CAAC,KAAU,EAAE,IAAyB;oBAC5C,MAAM,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;oBAC/C,MAAM,YAAY,GAAI,IAAI,CAAC,MAAc,CAAC,mBAAmB,CAAC,CAAC;oBAC/D,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;wBACzB,OAAO,YAAY,KAAK,QAAQ;wBAChC,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CACnC,CAAC;gBACJ,CAAC;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./decorator"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nestjs-typeorm3-kit",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "NestJS utilities for TypeORM v0.3+",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rimraf dist && tsc",
|
|
12
|
+
"test": "jest --config ./tests/jest.config.json --detectOpenHandles",
|
|
13
|
+
"prepare": "yarn build"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/x302502/nestjs-typeorm3-kit.git"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"nestjs",
|
|
21
|
+
"typeorm",
|
|
22
|
+
"typescript"
|
|
23
|
+
],
|
|
24
|
+
"author": "thanhluan.bkhn <thanhluan.bkhn@gmail.com>",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/x302502/nestjs-typeorm3-kit/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/x302502/nestjs-typeorm3-kit#readme",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@nestjs/common": ">=8.0.0",
|
|
32
|
+
"@nestjs/core": ">=8.0.0",
|
|
33
|
+
"@nestjs/typeorm": ">=8.1.0",
|
|
34
|
+
"class-transformer": "^0.5.1",
|
|
35
|
+
"class-validator": "^0.14.0",
|
|
36
|
+
"libphonenumber-js": "^1.10.20",
|
|
37
|
+
"reflect-metadata": ">=0.1.13",
|
|
38
|
+
"rxjs": ">=7.2.0",
|
|
39
|
+
"typeorm": ">=0.3.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@nestjs/common": "^11.1.3",
|
|
43
|
+
"@nestjs/core": "^11.1.3",
|
|
44
|
+
"@nestjs/swagger": "^11.2.0",
|
|
45
|
+
"@nestjs/typeorm": "^11.0.0",
|
|
46
|
+
"@types/jest": "^30.0.0",
|
|
47
|
+
"class-transformer": "^0.5.1",
|
|
48
|
+
"class-validator": "^0.14.2",
|
|
49
|
+
"eslint": "^9.29.0",
|
|
50
|
+
"fast-glob": "^3.3.3",
|
|
51
|
+
"jest": "^30.0.3",
|
|
52
|
+
"libphonenumber-js": "^1.12.9",
|
|
53
|
+
"prettier": "^3.6.2",
|
|
54
|
+
"reflect-metadata": "^0.2.2",
|
|
55
|
+
"rimraf": "^6.0.1",
|
|
56
|
+
"ts-jest": "^29.4.0",
|
|
57
|
+
"typeorm": "^0.3.25",
|
|
58
|
+
"typeorm-transactional": "^0.5.0",
|
|
59
|
+
"typescript": "^5.8.3"
|
|
60
|
+
}
|
|
61
|
+
}
|