nestjs-typeorm3-kit 0.1.8 → 0.2.0
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/LICENSE +21 -0
- package/README.md +801 -148
- package/dist/common/decorator/index.d.ts.map +1 -1
- package/dist/common/decorator/index.js +1 -5
- package/dist/common/decorator/index.js.map +1 -1
- package/dist/controller/decorator/index.d.ts.map +1 -1
- package/dist/controller/decorator/index.js +66 -117
- package/dist/controller/decorator/index.js.map +1 -1
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +49 -10
- package/dist/helpers/index.js.map +1 -1
- package/dist/module/decorator/index.d.ts +1 -1
- package/dist/module/decorator/index.d.ts.map +1 -1
- package/dist/module/decorator/index.js +188 -19
- package/dist/module/decorator/index.js.map +1 -1
- package/dist/repository/config/constants.d.ts +1 -0
- package/dist/repository/config/constants.d.ts.map +1 -1
- package/dist/repository/config/constants.js +2 -1
- package/dist/repository/config/constants.js.map +1 -1
- package/dist/repository/config/types.d.ts +2 -2
- package/dist/repository/config/types.d.ts.map +1 -1
- package/dist/repository/config/types.js +34 -6
- package/dist/repository/config/types.js.map +1 -1
- package/dist/repository/config/utils.d.ts +1 -1
- package/dist/repository/config/utils.d.ts.map +1 -1
- package/dist/repository/config/utils.js +12 -13
- package/dist/repository/config/utils.js.map +1 -1
- package/dist/repository/decorator/index.d.ts +2 -2
- package/dist/repository/decorator/index.d.ts.map +1 -1
- package/dist/repository/decorator/index.js +1 -1
- package/dist/repository/decorator/index.js.map +1 -1
- package/dist/repository/module/index.d.ts +2 -5
- package/dist/repository/module/index.d.ts.map +1 -1
- package/dist/repository/module/index.js +23 -87
- package/dist/repository/module/index.js.map +1 -1
- package/dist/transaction/decorator/index.d.ts +5 -3
- package/dist/transaction/decorator/index.d.ts.map +1 -1
- package/dist/transaction/decorator/index.js +20 -19
- package/dist/transaction/decorator/index.js.map +1 -1
- package/dist/transaction/setup/index.d.ts +8 -3
- package/dist/transaction/setup/index.d.ts.map +1 -1
- package/dist/transaction/setup/index.js +19 -5
- package/dist/transaction/setup/index.js.map +1 -1
- package/dist/validate/decorator/index.d.ts.map +1 -1
- package/dist/validate/decorator/index.js +6 -4
- package/dist/validate/decorator/index.js.map +1 -1
- package/dist/vendor/transactional/common/constants.d.ts +6 -0
- package/dist/vendor/transactional/common/constants.d.ts.map +1 -0
- package/dist/vendor/transactional/common/constants.js +9 -0
- package/dist/vendor/transactional/common/constants.js.map +1 -0
- package/dist/vendor/transactional/common/index.d.ts +26 -0
- package/dist/vendor/transactional/common/index.d.ts.map +1 -0
- package/dist/vendor/transactional/common/index.js +136 -0
- package/dist/vendor/transactional/common/index.js.map +1 -0
- package/dist/vendor/transactional/decorators/transactional.d.ts +3 -0
- package/dist/vendor/transactional/decorators/transactional.d.ts.map +1 -0
- package/dist/vendor/transactional/decorators/transactional.js +20 -0
- package/dist/vendor/transactional/decorators/transactional.js.map +1 -0
- package/dist/vendor/transactional/enums/isolation-level.d.ts +7 -0
- package/dist/vendor/transactional/enums/isolation-level.d.ts.map +1 -0
- package/dist/vendor/transactional/enums/isolation-level.js +11 -0
- package/dist/vendor/transactional/enums/isolation-level.js.map +1 -0
- package/dist/vendor/transactional/enums/propagation.d.ts +10 -0
- package/dist/vendor/transactional/enums/propagation.d.ts.map +1 -0
- package/dist/vendor/transactional/enums/propagation.js +14 -0
- package/dist/vendor/transactional/enums/propagation.js.map +1 -0
- package/dist/vendor/transactional/enums/storage-driver.d.ts +5 -0
- package/dist/vendor/transactional/enums/storage-driver.d.ts.map +1 -0
- package/dist/vendor/transactional/enums/storage-driver.js +9 -0
- package/dist/vendor/transactional/enums/storage-driver.js.map +1 -0
- package/dist/vendor/transactional/errors/transactional.d.ts +4 -0
- package/dist/vendor/transactional/errors/transactional.d.ts.map +1 -0
- package/dist/vendor/transactional/errors/transactional.js +11 -0
- package/dist/vendor/transactional/errors/transactional.js.map +1 -0
- package/dist/vendor/transactional/errors/typeorm-updated-patch.d.ts +5 -0
- package/dist/vendor/transactional/errors/typeorm-updated-patch.d.ts.map +1 -0
- package/dist/vendor/transactional/errors/typeorm-updated-patch.js +11 -0
- package/dist/vendor/transactional/errors/typeorm-updated-patch.js.map +1 -0
- package/dist/vendor/transactional/hooks/index.d.ts +11 -0
- package/dist/vendor/transactional/hooks/index.d.ts.map +1 -0
- package/dist/vendor/transactional/hooks/index.js +79 -0
- package/dist/vendor/transactional/hooks/index.js.map +1 -0
- package/dist/vendor/transactional/index.d.ts +10 -0
- package/dist/vendor/transactional/index.d.ts.map +1 -0
- package/dist/vendor/transactional/index.js +27 -0
- package/dist/vendor/transactional/index.js.map +1 -0
- package/dist/vendor/transactional/storage/driver/async-local-storage/index.d.ts +9 -0
- package/dist/vendor/transactional/storage/driver/async-local-storage/index.d.ts.map +1 -0
- package/dist/vendor/transactional/storage/driver/async-local-storage/index.js +25 -0
- package/dist/vendor/transactional/storage/driver/async-local-storage/index.js.map +1 -0
- package/dist/vendor/transactional/storage/driver/interface.d.ts +10 -0
- package/dist/vendor/transactional/storage/driver/interface.d.ts.map +1 -0
- package/dist/vendor/transactional/storage/driver/interface.js +3 -0
- package/dist/vendor/transactional/storage/driver/interface.js.map +1 -0
- package/dist/vendor/transactional/storage/index.d.ts +3 -0
- package/dist/vendor/transactional/storage/index.d.ts.map +1 -0
- package/dist/vendor/transactional/storage/index.js +6 -0
- package/dist/vendor/transactional/storage/index.js.map +1 -0
- package/dist/vendor/transactional/storage/storage.d.ts +7 -0
- package/dist/vendor/transactional/storage/storage.d.ts.map +1 -0
- package/dist/vendor/transactional/storage/storage.js +21 -0
- package/dist/vendor/transactional/storage/storage.js.map +1 -0
- package/dist/vendor/transactional/transactions/nested-scope.d.ts +12 -0
- package/dist/vendor/transactional/transactions/nested-scope.d.ts.map +1 -0
- package/dist/vendor/transactional/transactions/nested-scope.js +42 -0
- package/dist/vendor/transactional/transactions/nested-scope.js.map +1 -0
- package/dist/vendor/transactional/transactions/run-in-transaction.d.ts +3 -0
- package/dist/vendor/transactional/transactions/run-in-transaction.d.ts.map +1 -0
- package/dist/vendor/transactional/transactions/run-in-transaction.js +9 -0
- package/dist/vendor/transactional/transactions/run-in-transaction.js.map +1 -0
- package/dist/vendor/transactional/transactions/wrap-in-transaction.d.ts +11 -0
- package/dist/vendor/transactional/transactions/wrap-in-transaction.d.ts.map +1 -0
- package/dist/vendor/transactional/transactions/wrap-in-transaction.js +109 -0
- package/dist/vendor/transactional/transactions/wrap-in-transaction.js.map +1 -0
- package/dist/vendor/transactional/utils/index.d.ts +3 -0
- package/dist/vendor/transactional/utils/index.d.ts.map +1 -0
- package/dist/vendor/transactional/utils/index.js +12 -0
- package/dist/vendor/transactional/utils/index.js.map +1 -0
- package/package.json +28 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/decorator/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,KACF,QAAQ,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,UAkBtD;AAED,wBAAgB,QAAQ,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/decorator/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,KACF,QAAQ,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,UAkBtD;AAED,wBAAgB,QAAQ,IAAI,cAAc,CAqBzC"}
|
|
@@ -23,11 +23,7 @@ function NewClass() {
|
|
|
23
23
|
return function (target) {
|
|
24
24
|
const original = target;
|
|
25
25
|
function construct(constructor, args) {
|
|
26
|
-
|
|
27
|
-
return constructor.apply(this, args);
|
|
28
|
-
};
|
|
29
|
-
c.prototype = constructor.prototype;
|
|
30
|
-
return new c();
|
|
26
|
+
return Reflect.construct(constructor, args);
|
|
31
27
|
}
|
|
32
28
|
const newConstructor = function (...args) {
|
|
33
29
|
return construct(original, args);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/decorator/index.ts"],"names":[],"mappings":";;AAAA,sBAmBC;AAED,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/decorator/index.ts"],"names":[],"mappings":";;AAAA,sBAmBC;AAED,4BAqBC;AA1CD,SAAgB,KAAK;IACnB,OAAO,UAAU,MAAc,EAAE,GAAoB;QACnD,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEtB,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;QACF,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE;YAEtB,GAAG,GAAG,MAAM,IAAI,KAAK,CAAC;QACxB,CAAC,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YACjC,GAAG,EAAE,MAAM;YACX,GAAG,EAAE,MAAM;YACX,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,QAAQ;IACtB,OAAO,UAAU,MAAgB;QAC/B,MAAM,QAAQ,GAAG,MAAM,CAAC;QAExB,SAAS,SAAS,CAAC,WAAqB,EAAE,IAAW;YAEnD,OAAO,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC;QAGD,MAAM,cAAc,GAAQ,UAAU,GAAG,IAAW;YAElD,OAAO,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC,CAAC;QAGF,cAAc,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;QAG9C,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controller/decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controller/decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,iBAAiB,EAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE/D,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,cAAc,CAAC;AAC1E,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,CAAC;AAW1E,wBAAgB,MAAM,CACpB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,gBAAyC,GACjD,eAAe,CAYjB;AAED,wBAAgB,OAAO,CACrB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,aAAmC,GAC3C,eAAe,CAmBjB;AAED,wBAAgB,MAAM,CACpB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,aAAmC,GAC3C,eAAe,CAmBjB;AAED,wBAAgB,QAAQ,CACtB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,aAAmC,GAC3C,eAAe,CAmBjB;AAED,wBAAgB,SAAS,CACvB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,GAAE,aAAmC,GAC3C,eAAe,CAmBjB"}
|
|
@@ -7,135 +7,84 @@ exports.DefPut = DefPut;
|
|
|
7
7
|
exports.DefPatch = DefPatch;
|
|
8
8
|
exports.DefDelete = DefDelete;
|
|
9
9
|
const common_1 = require("@nestjs/common");
|
|
10
|
-
const constants_1 = require("@nestjs/common/constants");
|
|
11
10
|
const swagger_1 = require("@nestjs/swagger");
|
|
12
11
|
const _types_1 = require("../../@types");
|
|
13
12
|
function DefController(options) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
console.log(JSON.stringify({ modulePath, pathMetadata }));
|
|
19
|
-
console.log('-------------------');
|
|
20
|
-
(0, swagger_1.ApiBearerAuth)()(target);
|
|
21
|
-
(0, common_1.Controller)(options)(target);
|
|
22
|
-
};
|
|
13
|
+
const nestController = options && !Array.isArray(options) && typeof options === 'object'
|
|
14
|
+
? (0, common_1.Controller)(options)
|
|
15
|
+
: (0, common_1.Controller)(options);
|
|
16
|
+
return (0, common_1.applyDecorators)((0, swagger_1.ApiBearerAuth)(), nestController);
|
|
23
17
|
}
|
|
24
18
|
function DefGet(path, options = new _types_1.MethodGetOptions()) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
Object.assign(output, {
|
|
39
|
-
...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return output;
|
|
43
|
-
};
|
|
19
|
+
const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined } = options || new _types_1.MethodGetOptions();
|
|
20
|
+
const decorators = [
|
|
21
|
+
(0, common_1.HttpCode)(statusCode),
|
|
22
|
+
(0, swagger_1.ApiOperation)({ summary }),
|
|
23
|
+
(0, common_1.Get)(path),
|
|
24
|
+
responseType
|
|
25
|
+
? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
|
|
26
|
+
: (0, swagger_1.ApiResponse)({ status: statusCode }),
|
|
27
|
+
];
|
|
28
|
+
return (0, common_1.applyDecorators)(...decorators);
|
|
44
29
|
}
|
|
45
30
|
function DefPost(path, options = new _types_1.MethodOptions()) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Object.assign(output, {
|
|
60
|
-
...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
if (bodyType) {
|
|
64
|
-
Object.assign(output, { ...(0, swagger_1.ApiBody)({ type: bodyType })(target, propertyKey, descriptor) });
|
|
65
|
-
}
|
|
66
|
-
return output;
|
|
67
|
-
};
|
|
31
|
+
const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options || new _types_1.MethodOptions();
|
|
32
|
+
const decorators = [
|
|
33
|
+
(0, common_1.HttpCode)(statusCode),
|
|
34
|
+
(0, swagger_1.ApiOperation)({ summary }),
|
|
35
|
+
(0, common_1.Post)(path),
|
|
36
|
+
responseType
|
|
37
|
+
? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
|
|
38
|
+
: (0, swagger_1.ApiResponse)({ status: statusCode }),
|
|
39
|
+
];
|
|
40
|
+
if (bodyType) {
|
|
41
|
+
decorators.push((0, swagger_1.ApiBody)({ type: bodyType }));
|
|
42
|
+
}
|
|
43
|
+
return (0, common_1.applyDecorators)(...decorators);
|
|
68
44
|
}
|
|
69
45
|
function DefPut(path, options = new _types_1.MethodOptions()) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Object.assign(output, {
|
|
84
|
-
...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (bodyType) {
|
|
88
|
-
Object.assign(output, { ...(0, swagger_1.ApiBody)({ type: bodyType })(target, propertyKey, descriptor) });
|
|
89
|
-
}
|
|
90
|
-
return output;
|
|
91
|
-
};
|
|
46
|
+
const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options || new _types_1.MethodOptions();
|
|
47
|
+
const decorators = [
|
|
48
|
+
(0, common_1.HttpCode)(statusCode),
|
|
49
|
+
(0, swagger_1.ApiOperation)({ summary }),
|
|
50
|
+
(0, common_1.Put)(path),
|
|
51
|
+
responseType
|
|
52
|
+
? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
|
|
53
|
+
: (0, swagger_1.ApiResponse)({ status: statusCode }),
|
|
54
|
+
];
|
|
55
|
+
if (bodyType) {
|
|
56
|
+
decorators.push((0, swagger_1.ApiBody)({ type: bodyType }));
|
|
57
|
+
}
|
|
58
|
+
return (0, common_1.applyDecorators)(...decorators);
|
|
92
59
|
}
|
|
93
60
|
function DefPatch(path, options = new _types_1.MethodOptions()) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
Object.assign(output, {
|
|
108
|
-
...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (bodyType) {
|
|
112
|
-
Object.assign(output, { ...(0, swagger_1.ApiBody)({ type: bodyType })(target, propertyKey, descriptor) });
|
|
113
|
-
}
|
|
114
|
-
return output;
|
|
115
|
-
};
|
|
61
|
+
const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options || new _types_1.MethodOptions();
|
|
62
|
+
const decorators = [
|
|
63
|
+
(0, common_1.HttpCode)(statusCode),
|
|
64
|
+
(0, swagger_1.ApiOperation)({ summary }),
|
|
65
|
+
(0, common_1.Patch)(path),
|
|
66
|
+
responseType
|
|
67
|
+
? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
|
|
68
|
+
: (0, swagger_1.ApiResponse)({ status: statusCode }),
|
|
69
|
+
];
|
|
70
|
+
if (bodyType) {
|
|
71
|
+
decorators.push((0, swagger_1.ApiBody)({ type: bodyType }));
|
|
72
|
+
}
|
|
73
|
+
return (0, common_1.applyDecorators)(...decorators);
|
|
116
74
|
}
|
|
117
75
|
function DefDelete(path, options = new _types_1.MethodOptions()) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Object.assign(output, {
|
|
132
|
-
...(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor),
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
if (bodyType) {
|
|
136
|
-
Object.assign(output, { ...(0, swagger_1.ApiBody)({ type: bodyType })(target, propertyKey, descriptor) });
|
|
137
|
-
}
|
|
138
|
-
return output;
|
|
139
|
-
};
|
|
76
|
+
const { statusCode = common_1.HttpStatus.OK, summary, responseType = undefined, bodyType = undefined, } = options || new _types_1.MethodOptions();
|
|
77
|
+
const decorators = [
|
|
78
|
+
(0, common_1.HttpCode)(statusCode),
|
|
79
|
+
(0, swagger_1.ApiOperation)({ summary }),
|
|
80
|
+
(0, common_1.Delete)(path),
|
|
81
|
+
responseType
|
|
82
|
+
? (0, swagger_1.ApiResponse)({ status: statusCode, type: responseType })
|
|
83
|
+
: (0, swagger_1.ApiResponse)({ status: statusCode }),
|
|
84
|
+
];
|
|
85
|
+
if (bodyType) {
|
|
86
|
+
decorators.push((0, swagger_1.ApiBody)({ type: bodyType }));
|
|
87
|
+
}
|
|
88
|
+
return (0, common_1.applyDecorators)(...decorators);
|
|
140
89
|
}
|
|
141
90
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controller/decorator/index.ts"],"names":[],"mappings":";;AAiBA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controller/decorator/index.ts"],"names":[],"mappings":";;AAiBA,sCAQC;AAED,wBAeC;AAED,0BAsBC;AAED,wBAsBC;AAED,4BAsBC;AAED,8BAsBC;AA1ID,2CAWwB;AACxB,6CAAoF;AACpF,yCAA+D;AAI/D,SAAgB,aAAa,CAC3B,OAA+C;IAE/C,MAAM,cAAc,GAClB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAC/D,CAAC,CAAC,IAAA,mBAAU,EAAC,OAAO,CAAC;QACrB,CAAC,CAAC,IAAA,mBAAU,EAAC,OAAwC,CAAC,CAAC;IAC3D,OAAO,IAAA,wBAAe,EAAC,IAAA,uBAAa,GAAE,EAAE,cAAc,CAAC,CAAC;AAC1D,CAAC;AAED,SAAgB,MAAM,CACpB,IAAwB,EACxB,UAA4B,IAAI,yBAAgB,EAAE;IAElD,MAAM,EAAE,UAAU,GAAG,mBAAU,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,SAAS,EAAE,GACrE,OAAO,IAAI,IAAI,yBAAgB,EAAE,CAAC;IACpC,MAAM,UAAU,GAAgE;QAC9E,IAAA,iBAAQ,EAAC,UAAU,CAAC;QACpB,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,CAAC;QACzB,IAAA,YAAG,EAAC,IAAI,CAAC;QACT,YAAY;YACV,CAAC,CAAC,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;YACzD,CAAC,CAAC,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;KACxC,CAAC;IACF,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,S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SAAS,EACxB,QAAQ,GAAG,SAAS,GACrB,GAAG,OAAO,IAAI,IAAI,sBAAa,EAAE,CAAC;IACnC,MAAM,UAAU,GAAgE;QAC9E,IAAA,iBAAQ,EAAC,UAAU,CAAC;QACpB,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,CAAC;QACzB,IAAA,eAAM,EAAC,IAAI,CAAC;QACZ,YAAY;YACV,CAAC,CAAC,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;YACzD,CAAC,CAAC,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;KACxC,CAAC;IACF,IAAI,QAAQ,EAAE,CAAC;QACb,UAAU,CAAC,IAAI,CAAC,IAAA,iBAAO,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { INestApplication } from "@nestjs/common";
|
|
2
|
+
import type { SwaggerDocumentOptions } from "@nestjs/swagger";
|
|
2
3
|
import { OpenAPIObject } from "@nestjs/swagger/dist/interfaces/open-api-spec.interface";
|
|
3
4
|
export declare const configSwaggerDocument: (app: INestApplication, document: OpenAPIObject, swaggerPath?: string) => void;
|
|
5
|
+
export declare function createScopedSwaggerDocument(app: INestApplication, config: Omit<OpenAPIObject, "paths">, options?: SwaggerDocumentOptions): OpenAPIObject;
|
|
4
6
|
import { Type } from "@nestjs/common";
|
|
5
7
|
export declare const lazyLoadClasses: (baseDir: string, suffixes: string[], additionalClasses?: Type<any>[]) => Type<any>[];
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EACL,aAAa,EAEd,MAAM,yDAAyD,CAAC;AAGjE,eAAO,MAAM,qBAAqB,GAChC,KAAK,gBAAgB,EACrB,UAAU,aAAa,EACvB,cAAa,MAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EACL,aAAa,EAEd,MAAM,yDAAyD,CAAC;AAGjE,eAAO,MAAM,qBAAqB,GAChC,KAAK,gBAAgB,EACrB,UAAU,aAAa,EACvB,cAAa,MAAkB,SAqChC,CAAC;AAOF,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EACpC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,aAAa,CAwBf;AAID,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAatC,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,UAAU,MAAM,EAAE,EAClB,oBAAmB,IAAI,CAAC,GAAG,CAAC,EAAO,KAClC,IAAI,CAAC,GAAG,CAAC,EAoCX,CAAC"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,30 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lazyLoadClasses = exports.configSwaggerDocument = void 0;
|
|
4
|
+
exports.createScopedSwaggerDocument = createScopedSwaggerDocument;
|
|
5
|
+
const core_1 = require("@nestjs/core");
|
|
4
6
|
const swagger_1 = require("@nestjs/swagger");
|
|
5
7
|
const class_validator_1 = require("class-validator");
|
|
6
8
|
const class_validator_jsonschema_1 = require("class-validator-jsonschema");
|
|
7
9
|
const configSwaggerDocument = (app, document, swaggerPath = "swagger") => {
|
|
8
|
-
|
|
9
|
-
.validationMetadatas;
|
|
10
|
+
document.components = document.components || {};
|
|
10
11
|
const targetSchemas = document.components.schemas || {};
|
|
11
|
-
const schemasBinding = (0, class_validator_jsonschema_1.validationMetadatasToSchemas)(
|
|
12
|
+
const schemasBinding = (0, class_validator_jsonschema_1.validationMetadatasToSchemas)({
|
|
13
|
+
classValidatorMetadataStorage: (0, class_validator_1.getMetadataStorage)(),
|
|
14
|
+
refPointerPrefix: "#/components/schemas/",
|
|
15
|
+
}) || {};
|
|
12
16
|
Object.keys(schemasBinding).forEach((key) => {
|
|
13
17
|
const value = schemasBinding[key];
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
const targetValue = targetSchemas[key];
|
|
19
|
+
if (!targetValue) {
|
|
20
|
+
targetSchemas[key] = value;
|
|
21
|
+
return;
|
|
16
22
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Object.assign(targetValue.properties, value.properties);
|
|
20
|
-
targetValue.required = value.required;
|
|
21
|
-
Object.assign(targetSchemas, { key: targetValue });
|
|
23
|
+
if ("$ref" in targetValue) {
|
|
24
|
+
return;
|
|
22
25
|
}
|
|
26
|
+
const properties = (targetValue.properties = targetValue.properties || {});
|
|
27
|
+
Object.keys(value.properties || {}).forEach((prop) => {
|
|
28
|
+
if (!(prop in properties))
|
|
29
|
+
properties[prop] = value.properties[prop];
|
|
30
|
+
});
|
|
31
|
+
const required = new Set([
|
|
32
|
+
...(targetValue.required || []),
|
|
33
|
+
...(value.required || []),
|
|
34
|
+
]);
|
|
35
|
+
if (required.size)
|
|
36
|
+
targetValue.required = [...required];
|
|
23
37
|
});
|
|
24
38
|
document.components.schemas = Object.assign({}, targetSchemas);
|
|
25
39
|
swagger_1.SwaggerModule.setup(swaggerPath, app, document);
|
|
26
40
|
};
|
|
27
41
|
exports.configSwaggerDocument = configSwaggerDocument;
|
|
42
|
+
function createScopedSwaggerDocument(app, config, options) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (!((_a = options === null || options === void 0 ? void 0 : options.include) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
45
|
+
return swagger_1.SwaggerModule.createDocument(app, config, options);
|
|
46
|
+
}
|
|
47
|
+
const included = new Set(options.include);
|
|
48
|
+
for (const module of app.get(core_1.ModulesContainer).values()) {
|
|
49
|
+
const moduleType = module.metatype;
|
|
50
|
+
if (typeof moduleType !== "function" || included.has(moduleType)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
let prototype = Object.getPrototypeOf(moduleType.prototype);
|
|
54
|
+
while (prototype) {
|
|
55
|
+
if (included.has(prototype.constructor)) {
|
|
56
|
+
included.add(moduleType);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return swagger_1.SwaggerModule.createDocument(app, config, {
|
|
63
|
+
...options,
|
|
64
|
+
include: [...included],
|
|
65
|
+
});
|
|
66
|
+
}
|
|
28
67
|
const path_1 = require("path");
|
|
29
68
|
const fs_1 = require("fs");
|
|
30
69
|
const lazyLoadClasses = (baseDir, suffixes, additionalClasses = []) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;AA0DA,kEA4BC;AArFD,uCAAgD;AAChD,6CAAgD;AAEhD,qDAAqD;AAKrD,2EAA0E;AAEnE,MAAM,qBAAqB,GAAG,CACnC,GAAqB,EACrB,QAAuB,EACvB,cAAsB,SAAS,EAC/B,EAAE;IAIF,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;IAChD,MAAM,aAAa,GAAG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AAa,CAAC,CAAC;YAC9B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,iCAAiC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAxCW,QAAA,eAAe,mBAwC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/module/decorator/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/module/decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,cAAc,EAAQ,MAAM,gBAAgB,CAAC;AAKvF,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAyND,wBAAgB,WAAW,CAAC,aAAa,CAAC,EAAE,oBAAoB,GAAG,cAAc,CA+BhF"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ChildModule = ChildModule;
|
|
4
|
-
const validate_module_keys_util_1 = require("@nestjs/common/utils/validate-module-keys.util");
|
|
5
4
|
const constants_1 = require("@nestjs/common/constants");
|
|
5
|
+
const validate_module_keys_util_1 = require("@nestjs/common/utils/validate-module-keys.util");
|
|
6
6
|
const swagger_1 = require("@nestjs/swagger");
|
|
7
|
-
const PREFIX_METADATA = '__prefix___';
|
|
8
7
|
function fixPath(strInput) {
|
|
9
8
|
let path = strInput;
|
|
10
9
|
const regex = new RegExp('//', 'g');
|
|
@@ -22,30 +21,200 @@ const toPascalCase = (str) => {
|
|
|
22
21
|
.replace(new RegExp(/\s/, 'g'), '')
|
|
23
22
|
.replace(new RegExp(/\w/), s => s.toUpperCase());
|
|
24
23
|
};
|
|
24
|
+
const SCOPED_IMPORTS = Symbol('child-module:scoped-imports');
|
|
25
|
+
const scopedModuleCache = new WeakMap();
|
|
26
|
+
const scopedDynamicCache = new WeakMap();
|
|
27
|
+
function pathOf(moduleType) {
|
|
28
|
+
const path = Reflect.getMetadata(constants_1.MODULE_PATH, moduleType);
|
|
29
|
+
return typeof path === 'string' ? fixPath(path) : '';
|
|
30
|
+
}
|
|
31
|
+
function isDynamicModule(item) {
|
|
32
|
+
return !!item && typeof item === 'object' && 'module' in item;
|
|
33
|
+
}
|
|
34
|
+
function isForwardReference(item) {
|
|
35
|
+
return !!item && typeof item === 'object' && 'forwardRef' in item;
|
|
36
|
+
}
|
|
37
|
+
function scopeModule(moduleType, parentPath) {
|
|
38
|
+
if (!parentPath) {
|
|
39
|
+
return moduleType;
|
|
40
|
+
}
|
|
41
|
+
let byPath = scopedModuleCache.get(moduleType);
|
|
42
|
+
const existing = byPath === null || byPath === void 0 ? void 0 : byPath.get(parentPath);
|
|
43
|
+
if (existing) {
|
|
44
|
+
return existing;
|
|
45
|
+
}
|
|
46
|
+
if (!byPath) {
|
|
47
|
+
byPath = new Map();
|
|
48
|
+
scopedModuleCache.set(moduleType, byPath);
|
|
49
|
+
}
|
|
50
|
+
class ScopedModule {
|
|
51
|
+
constructor(...args) {
|
|
52
|
+
return Reflect.construct(moduleType, args, new.target);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
Object.setPrototypeOf(ScopedModule.prototype, moduleType.prototype);
|
|
56
|
+
byPath.set(parentPath, ScopedModule);
|
|
57
|
+
Object.defineProperty(ScopedModule, 'name', { value: moduleType.name });
|
|
58
|
+
for (const key of Reflect.getMetadataKeys(moduleType)) {
|
|
59
|
+
Reflect.defineMetadata(key, Reflect.getMetadata(key, moduleType), ScopedModule);
|
|
60
|
+
}
|
|
61
|
+
const path = fixPath(`${parentPath}/${pathOf(moduleType)}`);
|
|
62
|
+
Reflect.defineMetadata(constants_1.MODULE_PATH, path ? `/${path}` : '', ScopedModule);
|
|
63
|
+
const imports = Reflect.getMetadata('imports', moduleType);
|
|
64
|
+
if (imports) {
|
|
65
|
+
const importParentPath = Reflect.getMetadata(SCOPED_IMPORTS, moduleType) ? parentPath : path;
|
|
66
|
+
const scoped = scopeLists(imports, Reflect.getMetadata('exports', moduleType), importParentPath);
|
|
67
|
+
Reflect.defineMetadata('imports', scoped.imports, ScopedModule);
|
|
68
|
+
Reflect.defineMetadata(SCOPED_IMPORTS, true, ScopedModule);
|
|
69
|
+
if (scoped.exports) {
|
|
70
|
+
Reflect.defineMetadata('exports', scoped.exports, ScopedModule);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return ScopedModule;
|
|
74
|
+
}
|
|
75
|
+
function scopeDynamicModule(item, parentPath) {
|
|
76
|
+
if (!parentPath) {
|
|
77
|
+
return item;
|
|
78
|
+
}
|
|
79
|
+
let byPath = scopedDynamicCache.get(item);
|
|
80
|
+
const existing = byPath === null || byPath === void 0 ? void 0 : byPath.get(parentPath);
|
|
81
|
+
if (existing) {
|
|
82
|
+
return existing;
|
|
83
|
+
}
|
|
84
|
+
if (!byPath) {
|
|
85
|
+
byPath = new Map();
|
|
86
|
+
scopedDynamicCache.set(item, byPath);
|
|
87
|
+
}
|
|
88
|
+
const scoped = Object.fromEntries(Object.entries(item));
|
|
89
|
+
byPath.set(parentPath, scoped);
|
|
90
|
+
scoped.module = scopeModule(item.module, parentPath);
|
|
91
|
+
if (item.imports) {
|
|
92
|
+
const importParentPath = item[SCOPED_IMPORTS]
|
|
93
|
+
? parentPath
|
|
94
|
+
: fixPath(pathOf(scoped.module));
|
|
95
|
+
const lists = scopeLists(item.imports, item.exports, importParentPath);
|
|
96
|
+
scoped.imports = lists.imports;
|
|
97
|
+
if (lists.exports) {
|
|
98
|
+
scoped.exports = lists.exports;
|
|
99
|
+
}
|
|
100
|
+
scoped[SCOPED_IMPORTS] = true;
|
|
101
|
+
}
|
|
102
|
+
return scoped;
|
|
103
|
+
}
|
|
104
|
+
function scopeImport(item, parentPath) {
|
|
105
|
+
if (!parentPath) {
|
|
106
|
+
return item;
|
|
107
|
+
}
|
|
108
|
+
if (typeof item === 'function') {
|
|
109
|
+
return scopeModule(item, parentPath);
|
|
110
|
+
}
|
|
111
|
+
if (item instanceof Promise) {
|
|
112
|
+
return item.then(resolved => scopeImport(resolved, parentPath));
|
|
113
|
+
}
|
|
114
|
+
if (isDynamicModule(item)) {
|
|
115
|
+
return scopeDynamicModule(item, parentPath);
|
|
116
|
+
}
|
|
117
|
+
if (isForwardReference(item)) {
|
|
118
|
+
return {
|
|
119
|
+
forwardRef: () => scopeImport(item.forwardRef(), parentPath),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return item;
|
|
123
|
+
}
|
|
124
|
+
function scopeLists(imports, exports, parentPath) {
|
|
125
|
+
if (!parentPath) {
|
|
126
|
+
return { imports, exports };
|
|
127
|
+
}
|
|
128
|
+
const scopedByOriginal = new Map();
|
|
129
|
+
const remember = (item, scoped) => {
|
|
130
|
+
if (typeof item === 'function' && typeof scoped === 'function') {
|
|
131
|
+
scopedByOriginal.set(item, scoped);
|
|
132
|
+
}
|
|
133
|
+
else if (isDynamicModule(item) && isDynamicModule(scoped)) {
|
|
134
|
+
scopedByOriginal.set(item.module, scoped.module);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const scopedImports = imports.map(item => {
|
|
138
|
+
if (item instanceof Promise) {
|
|
139
|
+
return item.then(resolved => {
|
|
140
|
+
const scoped = scopeImport(resolved, parentPath);
|
|
141
|
+
remember(resolved, scoped);
|
|
142
|
+
return scoped;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const scoped = scopeImport(item, parentPath);
|
|
146
|
+
remember(item, scoped);
|
|
147
|
+
return scoped;
|
|
148
|
+
});
|
|
149
|
+
if (!exports) {
|
|
150
|
+
return { imports: scopedImports };
|
|
151
|
+
}
|
|
152
|
+
const hasForwardImports = imports.some(isForwardReference);
|
|
153
|
+
const hasPromiseImports = imports.some(item => item instanceof Promise);
|
|
154
|
+
const scopedExports = exports.map(item => {
|
|
155
|
+
var _a;
|
|
156
|
+
if (isForwardReference(item)) {
|
|
157
|
+
return { forwardRef: () => scopeImport(item.forwardRef(), parentPath) };
|
|
158
|
+
}
|
|
159
|
+
if (typeof item === 'function') {
|
|
160
|
+
const direct = scopedByOriginal.get(item);
|
|
161
|
+
if (direct)
|
|
162
|
+
return direct;
|
|
163
|
+
if (hasForwardImports || hasPromiseImports) {
|
|
164
|
+
return {
|
|
165
|
+
forwardRef: () => {
|
|
166
|
+
const resolved = scopedByOriginal.get(item);
|
|
167
|
+
if (resolved)
|
|
168
|
+
return resolved;
|
|
169
|
+
const matches = imports.some(ref => {
|
|
170
|
+
if (!isForwardReference(ref))
|
|
171
|
+
return false;
|
|
172
|
+
const resolved = ref.forwardRef();
|
|
173
|
+
return resolved === item || (isDynamicModule(resolved) && resolved.module === item);
|
|
174
|
+
});
|
|
175
|
+
return matches ? scopeModule(item, parentPath) : item;
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return item;
|
|
180
|
+
}
|
|
181
|
+
if (isDynamicModule(item)) {
|
|
182
|
+
return (_a = scopedByOriginal.get(item.module)) !== null && _a !== void 0 ? _a : item;
|
|
183
|
+
}
|
|
184
|
+
return item;
|
|
185
|
+
});
|
|
186
|
+
return { imports: scopedImports, exports: scopedExports };
|
|
187
|
+
}
|
|
25
188
|
function ChildModule(childMetadata) {
|
|
26
|
-
|
|
189
|
+
const { prefix = '', ...metadata } = childMetadata || {};
|
|
27
190
|
const propsKeys = Object.keys(metadata);
|
|
28
191
|
(0, validate_module_keys_util_1.validateModuleKeys)(propsKeys);
|
|
29
192
|
return target => {
|
|
30
|
-
|
|
31
|
-
for (const property in metadata) {
|
|
32
|
-
if (metadata.hasOwnProperty(property)) {
|
|
33
|
-
Reflect.defineMetadata(property, metadata[property], target);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
193
|
+
var _a;
|
|
36
194
|
const defPrefix = fixPath(prefix);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
195
|
+
const scoped = metadata.imports
|
|
196
|
+
? scopeLists(metadata.imports, metadata.exports, defPrefix)
|
|
197
|
+
: undefined;
|
|
198
|
+
for (const property of Object.keys(metadata)) {
|
|
199
|
+
const value = property === 'imports'
|
|
200
|
+
? scoped === null || scoped === void 0 ? void 0 : scoped.imports
|
|
201
|
+
: property === 'exports'
|
|
202
|
+
? ((_a = scoped === null || scoped === void 0 ? void 0 : scoped.exports) !== null && _a !== void 0 ? _a : metadata.exports)
|
|
203
|
+
: metadata[property];
|
|
204
|
+
Reflect.defineMetadata(property, value, target);
|
|
205
|
+
}
|
|
206
|
+
if (metadata.imports) {
|
|
207
|
+
Reflect.defineMetadata(SCOPED_IMPORTS, true, target);
|
|
208
|
+
}
|
|
209
|
+
Reflect.defineMetadata(constants_1.MODULE_PATH, defPrefix ? `/${defPrefix}` : defPrefix, target);
|
|
210
|
+
const controllers = metadata.controllers || [];
|
|
211
|
+
for (const ctr of controllers) {
|
|
212
|
+
if (!ctr) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
46
215
|
const groupName = prefix ? `[${toPascalCase(prefix)}] ${ctr.name}` : `[API]${ctr.name}`;
|
|
47
216
|
(0, swagger_1.ApiTags)(groupName)(ctr);
|
|
48
|
-
}
|
|
217
|
+
}
|
|
49
218
|
};
|
|
50
219
|
}
|
|
51
220
|
//# sourceMappingURL=index.js.map
|