@zenofolio/hyper-decor 1.0.7 → 1.0.8
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/.agent/rules/philosophy.md +103 -0
- package/.agent/rules/writing.md +32 -0
- package/README.md +103 -201
- package/dist/__internals/constants.d.ts +1 -62
- package/dist/__internals/constants.js +3 -69
- package/dist/__internals/helpers/merge-metadata.d.ts +2 -3
- package/dist/__internals/helpers/merge-metadata.js +31 -7
- package/dist/__internals/helpers/prepare.helper.d.ts +4 -10
- package/dist/__internals/helpers/prepare.helper.js +325 -281
- package/dist/__internals/stores/hyper.store.d.ts +5 -0
- package/dist/__internals/stores/hyper.store.js +5 -0
- package/dist/__internals/stores/index.d.ts +4 -0
- package/dist/{lib/openapi/helpers → __internals/stores}/index.js +4 -7
- package/dist/__internals/stores/meta.store.d.ts +34 -0
- package/dist/__internals/stores/meta.store.js +107 -0
- package/dist/{stores → __internals/stores}/scope.store.d.ts +1 -1
- package/dist/__internals/transform/middleware.transform.d.ts +1 -1
- package/dist/__internals/transform/middleware.transform.js +1 -1
- package/dist/__internals/transform/role.transform.d.ts +1 -1
- package/dist/__internals/transform/role.transform.js +4 -4
- package/dist/__internals/transform/scope.transfrom.d.ts +1 -1
- package/dist/__internals/transform/scope.transfrom.js +2 -2
- package/dist/__internals/types.d.ts +53 -4
- package/dist/common/bootstrap.d.ts +6 -2
- package/dist/common/bootstrap.js +49 -10
- package/dist/common/testing.d.ts +56 -0
- package/dist/common/testing.js +193 -0
- package/dist/common/transport.d.ts +1 -0
- package/dist/common/transport.js +27 -14
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -1
- package/dist/decorators.d.ts +1 -0
- package/dist/{stores/index.js → decorators.js} +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +7 -5
- package/dist/lib/event/meta.store.d.ts +4 -0
- package/dist/lib/event/meta.store.js +5 -0
- package/dist/lib/openapi/collectors/class.collector.d.ts +5 -9
- package/dist/lib/openapi/collectors/class.collector.js +6 -63
- package/dist/lib/openapi/collectors/index.d.ts +3 -4
- package/dist/lib/openapi/collectors/index.js +0 -1
- package/dist/lib/openapi/collectors/method.collector.d.ts +6 -1
- package/dist/lib/openapi/collectors/method.collector.js +92 -59
- package/dist/lib/openapi/collectors/schema.collector.d.ts +3 -8
- package/dist/lib/openapi/collectors/schema.collector.js +17 -25
- package/dist/lib/openapi/constants.d.ts +1 -0
- package/dist/lib/openapi/constants.js +2 -2
- package/dist/lib/openapi/decorators.d.ts +16 -0
- package/dist/lib/openapi/decorators.js +93 -0
- package/dist/lib/openapi/index.d.ts +29 -5
- package/dist/lib/openapi/index.js +119 -5
- package/dist/lib/openapi/metadata.d.ts +7 -0
- package/dist/lib/openapi/metadata.js +8 -0
- package/dist/lib/openapi/metadata.registry.d.ts +1 -1
- package/dist/lib/server/decorators/File.d.ts +37 -0
- package/dist/{decorators → lib/server/decorators}/File.js +62 -75
- package/dist/lib/server/decorators/Http.d.ts +12 -0
- package/dist/lib/server/decorators/Http.js +56 -0
- package/dist/lib/server/decorators/HyperApp.d.ts +7 -0
- package/dist/lib/server/decorators/HyperApp.js +14 -0
- package/dist/lib/server/decorators/HyperController.d.ts +6 -0
- package/dist/lib/server/decorators/HyperController.js +15 -0
- package/dist/lib/server/decorators/HyperModule.d.ts +6 -0
- package/dist/lib/server/decorators/HyperModule.js +13 -0
- package/dist/lib/server/decorators/HyperService.d.ts +12 -0
- package/dist/lib/server/decorators/HyperService.js +30 -0
- package/dist/lib/server/decorators/Messaging.d.ts +8 -0
- package/dist/lib/server/decorators/Messaging.js +19 -0
- package/dist/{decorators → lib/server/decorators}/Middleware.d.ts +5 -12
- package/dist/lib/server/decorators/Middleware.js +52 -0
- package/dist/lib/server/decorators/Output.d.ts +6 -0
- package/dist/lib/server/decorators/Output.js +14 -0
- package/dist/lib/server/decorators/Pass.d.ts +10 -0
- package/dist/lib/server/decorators/Pass.js +13 -0
- package/dist/lib/server/decorators/Role.d.ts +7 -0
- package/dist/lib/server/decorators/Role.js +14 -0
- package/dist/lib/server/decorators/Routes.d.ts +14 -0
- package/dist/lib/server/decorators/Routes.js +39 -0
- package/dist/lib/server/decorators/Scope.d.ts +7 -0
- package/dist/lib/server/decorators/Scope.js +14 -0
- package/dist/{decorators → lib/server/decorators}/index.d.ts +6 -4
- package/dist/{decorators → lib/server/decorators}/index.js +6 -4
- package/dist/lib/server/decorators/metadata.d.ts +1 -0
- package/dist/lib/server/decorators/metadata.js +5 -0
- package/dist/{decorators → lib/server/decorators}/types.d.ts +16 -15
- package/dist/{exeptions → lib/server/exeptions}/HyperException.d.ts +2 -1
- package/dist/{exeptions → lib/server/exeptions}/HyperException.js +2 -1
- package/dist/{exeptions → lib/server/exeptions}/HyperFileException.js +1 -1
- package/dist/{exeptions → lib/server/exeptions}/NotRoleException.js +1 -1
- package/dist/{exeptions → lib/server/exeptions}/NotScopeException.js +1 -1
- package/dist/{__internals/helpers/tree.helper.d.ts → lib/tree/tree.d.ts} +12 -12
- package/dist/lib/tree/tree.js +106 -0
- package/package.json +10 -2
- package/scripts/clean.js +54 -54
- package/scripts/test-server.ts +85 -85
- package/vitest.config.mjs +1 -1
- package/debug.txt +0 -1
- package/dist/__internals/creators/request.creator.d.ts +0 -11
- package/dist/__internals/creators/request.creator.js +0 -55
- package/dist/__internals/creators/routes.creator.d.ts +0 -9
- package/dist/__internals/creators/routes.creator.js +0 -39
- package/dist/__internals/decorator-base.d.ts +0 -30
- package/dist/__internals/decorator-base.js +0 -122
- package/dist/__internals/helpers/imports.helper.d.ts +0 -8
- package/dist/__internals/helpers/imports.helper.js +0 -92
- package/dist/__internals/helpers/tree.helper.js +0 -81
- package/dist/__internals/stores/metadata.store.d.ts +0 -15
- package/dist/__internals/stores/metadata.store.js +0 -37
- package/dist/decorators/File.d.ts +0 -65
- package/dist/decorators/Http.d.ts +0 -62
- package/dist/decorators/Http.js +0 -139
- package/dist/decorators/HyperApp.d.ts +0 -3
- package/dist/decorators/HyperApp.js +0 -96
- package/dist/decorators/HyperController.d.ts +0 -2
- package/dist/decorators/HyperController.js +0 -20
- package/dist/decorators/HyperModule.d.ts +0 -5
- package/dist/decorators/HyperModule.js +0 -14
- package/dist/decorators/HyperService.d.ts +0 -15
- package/dist/decorators/HyperService.js +0 -29
- package/dist/decorators/Messaging.d.ts +0 -10
- package/dist/decorators/Messaging.js +0 -22
- package/dist/decorators/Middleware.js +0 -65
- package/dist/decorators/Output.d.ts +0 -9
- package/dist/decorators/Output.js +0 -18
- package/dist/decorators/Pass.d.ts +0 -15
- package/dist/decorators/Pass.js +0 -32
- package/dist/decorators/Role.d.ts +0 -6
- package/dist/decorators/Role.js +0 -34
- package/dist/decorators/Routes.d.ts +0 -15
- package/dist/decorators/Routes.js +0 -21
- package/dist/decorators/Scope.d.ts +0 -6
- package/dist/decorators/Scope.js +0 -25
- package/dist/decorators/Transform.d.ts +0 -14
- package/dist/decorators/Transform.js +0 -18
- package/dist/lib/openapi/collectors/param.collector.d.ts +0 -2
- package/dist/lib/openapi/collectors/param.collector.js +0 -64
- package/dist/lib/openapi/decorators/api-bearer-auth.decorator.d.ts +0 -2
- package/dist/lib/openapi/decorators/api-bearer-auth.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-method.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-method.decorator.js +0 -11
- package/dist/lib/openapi/decorators/api-parameter.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-parameter.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-request-body.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-request-body.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-response.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-response.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-security.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-security.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-tag.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-tag.decorator.js +0 -13
- package/dist/lib/openapi/decorators/index.d.ts +0 -7
- package/dist/lib/openapi/decorators/index.js +0 -23
- package/dist/lib/openapi/helpers/index.d.ts +0 -7
- package/dist/lib/openapi/helpers/method.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/method.helper.js +0 -20
- package/dist/lib/openapi/helpers/openapi.helper.d.ts +0 -7
- package/dist/lib/openapi/helpers/openapi.helper.js +0 -51
- package/dist/lib/openapi/helpers/parameter.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/parameter.helper.js +0 -16
- package/dist/lib/openapi/helpers/request-body.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/request-body.helper.js +0 -9
- package/dist/lib/openapi/helpers/response.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/response.helper.js +0 -18
- package/dist/lib/openapi/helpers/security.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/security.helper.js +0 -17
- package/dist/lib/openapi/helpers/tag.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/tag.helper.js +0 -10
- package/dist/stores/index.d.ts +0 -1
- package/vitest.json +0 -0
- /package/dist/{stores → __internals/stores}/scope.store.js +0 -0
- /package/dist/__internals/stores/{service.store.d.ts → serivces.store.d.ts} +0 -0
- /package/dist/__internals/stores/{service.store.js → serivces.store.js} +0 -0
- /package/dist/{decorators → lib/server/decorators}/types.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicateControllerPathException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicateControllerPathException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicatedException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicatedException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicatedHandlerException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicatedHandlerException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/HyperFileException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/MethodNotFountException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/MethodNotFountException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/NotPropertyException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/NotPropertyException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/NotRoleException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/NotScopeException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/WrongPlaceException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/WrongPlaceException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/index.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/index.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/types.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/types.js +0 -0
package/dist/common/transport.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
2
8
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
9
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
10
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,25 +16,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
16
|
};
|
|
11
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
18
|
exports.InternalTransport = void 0;
|
|
19
|
+
const tsyringe_1 = require("tsyringe");
|
|
13
20
|
const eventemitter3_1 = require("eventemitter3");
|
|
14
|
-
class InternalTransport {
|
|
21
|
+
let InternalTransport = class InternalTransport {
|
|
15
22
|
constructor() {
|
|
16
23
|
this.emitter = new eventemitter3_1.EventEmitter();
|
|
24
|
+
this.wildcardHandlers = [];
|
|
17
25
|
}
|
|
18
26
|
listen(topic, handler) {
|
|
19
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
// Basic wildcard support: user.* -> user.created, user.updated
|
|
21
|
-
// We'll use a simple regex for this internal transport
|
|
22
28
|
if (topic.includes("*")) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
handler(data);
|
|
31
|
-
}
|
|
29
|
+
const patternString = topic
|
|
30
|
+
.replace(/[+?^${}()|[\]\\]/g, "\\$&")
|
|
31
|
+
.replace(/\./g, "\\.")
|
|
32
|
+
.replace(/\*/g, ".*");
|
|
33
|
+
this.wildcardHandlers.push({
|
|
34
|
+
pattern: new RegExp(`^${patternString}$`),
|
|
35
|
+
handler,
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
38
|
else {
|
|
@@ -38,9 +42,18 @@ class InternalTransport {
|
|
|
38
42
|
}
|
|
39
43
|
emit(topic, data) {
|
|
40
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
// 1. Regular emit
|
|
41
46
|
this.emitter.emit(topic, data);
|
|
42
|
-
|
|
47
|
+
// 2. Wildcard checks
|
|
48
|
+
for (const item of this.wildcardHandlers) {
|
|
49
|
+
if (item.pattern.test(topic)) {
|
|
50
|
+
yield item.handler(data);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
43
53
|
});
|
|
44
54
|
}
|
|
45
|
-
}
|
|
55
|
+
};
|
|
46
56
|
exports.InternalTransport = InternalTransport;
|
|
57
|
+
exports.InternalTransport = InternalTransport = __decorate([
|
|
58
|
+
(0, tsyringe_1.singleton)()
|
|
59
|
+
], InternalTransport);
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HYPER_PASS_KEY = exports.HYPER_ROLE_KEY = exports.HYPER_SCOPES_KEY = void 0;
|
|
3
|
+
exports.FULL_ACCESS = exports.HYPER_PASS_KEY = exports.HYPER_ROLE_KEY = exports.HYPER_SCOPES_KEY = void 0;
|
|
4
4
|
exports.HYPER_SCOPES_KEY = "__HYPER_SCOPES_KEY";
|
|
5
5
|
exports.HYPER_ROLE_KEY = "__HYPER_ROLE_KEY";
|
|
6
6
|
exports.HYPER_PASS_KEY = "__HYPER_PASS_KEY";
|
|
7
|
+
exports.FULL_ACCESS = "*";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./lib/server/decorators";
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./lib/server/decorators"), exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import "./extension";
|
|
2
|
+
export * from "./lib/server/exeptions";
|
|
2
3
|
export * from "./constants";
|
|
3
4
|
export * from "./extension";
|
|
4
|
-
export * from "./decorators";
|
|
5
|
+
export * from "./lib/server/decorators";
|
|
5
6
|
export * from "./common/helpers";
|
|
6
|
-
export * from "./
|
|
7
|
+
export * from "./lib/tree/tree";
|
|
7
8
|
export * from "./common/bootstrap";
|
|
8
9
|
export * from "hyper-express";
|
|
9
10
|
export * from "tsyringe";
|
|
10
|
-
export * from "./stores";
|
|
11
|
-
export * from "./
|
|
11
|
+
export * from "./__internals/stores";
|
|
12
|
+
export * from "./__internals/types";
|
|
12
13
|
export * from "./common/transport";
|
|
13
14
|
export * from "./common/message-bus";
|
|
14
15
|
export * from "./__internals/transform/transform.registry";
|
|
15
16
|
export * from "./lib/openapi";
|
|
17
|
+
export * from "./common/testing";
|
package/dist/index.js
CHANGED
|
@@ -14,18 +14,20 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
17
|
+
require("./extension");
|
|
18
|
+
__exportStar(require("./lib/server/exeptions"), exports);
|
|
18
19
|
__exportStar(require("./constants"), exports);
|
|
19
20
|
__exportStar(require("./extension"), exports);
|
|
20
|
-
__exportStar(require("./decorators"), exports);
|
|
21
|
+
__exportStar(require("./lib/server/decorators"), exports);
|
|
21
22
|
__exportStar(require("./common/helpers"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./lib/tree/tree"), exports);
|
|
23
24
|
__exportStar(require("./common/bootstrap"), exports);
|
|
24
25
|
__exportStar(require("hyper-express"), exports);
|
|
25
26
|
__exportStar(require("tsyringe"), exports);
|
|
26
|
-
__exportStar(require("./stores"), exports);
|
|
27
|
-
__exportStar(require("./
|
|
27
|
+
__exportStar(require("./__internals/stores"), exports);
|
|
28
|
+
__exportStar(require("./__internals/types"), exports);
|
|
28
29
|
__exportStar(require("./common/transport"), exports);
|
|
29
30
|
__exportStar(require("./common/message-bus"), exports);
|
|
30
31
|
__exportStar(require("./__internals/transform/transform.registry"), exports);
|
|
31
32
|
__exportStar(require("./lib/openapi"), exports);
|
|
33
|
+
__exportStar(require("./common/testing"), exports);
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
methods: {
|
|
7
|
-
[methodName: string]: Operation;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
1
|
+
import { Constructor } from '../../server/decorators/types';
|
|
2
|
+
/**
|
|
3
|
+
* 🏢 Extracts class-level OpenAPI metadata (Tags, Security, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export declare function collectClassMetadata(Target: Constructor): object;
|
|
@@ -1,67 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.collectClassMetadata = collectClassMetadata;
|
|
4
|
-
require("
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _a;
|
|
11
|
-
const prototype = Reflect.getPrototypeOf(target);
|
|
12
|
-
const constructor = prototype === null || prototype === void 0 ? void 0 : prototype.constructor;
|
|
13
|
-
const name = target.name || (constructor === null || constructor === void 0 ? void 0 : constructor.name) || ((_a = target === null || target === void 0 ? void 0 : target.constructor) === null || _a === void 0 ? void 0 : _a.name);
|
|
14
|
-
// Extraemos las metadata de la clase
|
|
15
|
-
let tags = Reflect.getMetadata(constants_1.TAGS, target) || [];
|
|
16
|
-
let security = Reflect.getMetadata(constants_1.SECURITY, target) || [];
|
|
17
|
-
// Invoke custom class collectors
|
|
18
|
-
metadata_registry_1.openApiRegistry.getCollectors("class").forEach(collector => {
|
|
19
|
-
const data = collector(target);
|
|
20
|
-
if (data === null || data === void 0 ? void 0 : data.tags)
|
|
21
|
-
tags = [...tags, ...data.tags];
|
|
22
|
-
if (data === null || data === void 0 ? void 0 : data.security)
|
|
23
|
-
security = [...security, ...data.security];
|
|
24
|
-
});
|
|
25
|
-
// Si no tenemos tags, intentamos inferirlos
|
|
26
|
-
if (tags.length === 0) {
|
|
27
|
-
tags.push({ name });
|
|
28
|
-
}
|
|
29
|
-
// Si no tenemos seguridad, intentamos asignar un valor predeterminado
|
|
30
|
-
if (security.length === 0) {
|
|
31
|
-
security.push({ bearerAuth: [] });
|
|
32
|
-
}
|
|
33
|
-
// Obtenemos todos los métodos de la clase
|
|
34
|
-
const methodNames = Object.getOwnPropertyNames(target.prototype || {}).filter((method) => method !== "constructor");
|
|
35
|
-
// Creamos una lista con la metadata de cada uno de los métodos
|
|
36
|
-
const methods = {};
|
|
37
|
-
methodNames.forEach((methodName) => {
|
|
38
|
-
let methodMetadata = (0, method_collector_1.collectMethodMetadata)(target.prototype, methodName);
|
|
39
|
-
// Invoke custom method collectors
|
|
40
|
-
metadata_registry_1.openApiRegistry.getCollectors("method").forEach(collector => {
|
|
41
|
-
const data = collector(target.prototype, methodName);
|
|
42
|
-
methodMetadata = Object.assign(Object.assign({}, methodMetadata), data);
|
|
43
|
-
});
|
|
44
|
-
// Si el método no tiene parámetros definidos, intentamos inferirlos
|
|
45
|
-
if (!methodMetadata.parameters || methodMetadata.parameters.length === 0) {
|
|
46
|
-
const methodParams = (0, function_util_1.extractArgsNames)(target.prototype[methodName]);
|
|
47
|
-
methodParams === null || methodParams === void 0 ? void 0 : methodParams.forEach((paramName, index) => {
|
|
48
|
-
const inferredParam = {
|
|
49
|
-
name: paramName || `param${index}`,
|
|
50
|
-
in: "query",
|
|
51
|
-
required: true,
|
|
52
|
-
schema: {
|
|
53
|
-
type: "string",
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
methodMetadata.parameters || (methodMetadata.parameters = []);
|
|
57
|
-
methodMetadata.parameters.push(inferredParam);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
methods[methodName] = methodMetadata;
|
|
61
|
-
});
|
|
62
|
-
return {
|
|
63
|
-
tags,
|
|
64
|
-
security,
|
|
65
|
-
methods,
|
|
66
|
-
};
|
|
4
|
+
const metadata_1 = require("../metadata");
|
|
5
|
+
/**
|
|
6
|
+
* 🏢 Extracts class-level OpenAPI metadata (Tags, Security, etc.)
|
|
7
|
+
*/
|
|
8
|
+
function collectClassMetadata(Target) {
|
|
9
|
+
return metadata_1.SwaggerMeta.get(Target);
|
|
67
10
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from "./schema.collector";
|
|
1
|
+
export * from './class.collector';
|
|
2
|
+
export * from './method.collector';
|
|
3
|
+
export * from './schema.collector';
|
|
@@ -16,5 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./class.collector"), exports);
|
|
18
18
|
__exportStar(require("./method.collector"), exports);
|
|
19
|
-
__exportStar(require("./param.collector"), exports);
|
|
20
19
|
__exportStar(require("./schema.collector"), exports);
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
1
2
|
import { Operation } from '../types';
|
|
2
|
-
|
|
3
|
+
import { Constructor } from '../../server/decorators/types';
|
|
4
|
+
/**
|
|
5
|
+
* 🛠️ Consolidates framework metadata and OpenAPI decorators into a single Operation object.
|
|
6
|
+
*/
|
|
7
|
+
export declare function collectMethodMetadata(target: Constructor, propertyKey?: string): Operation | undefined;
|
|
@@ -1,68 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.collectMethodMetadata = collectMethodMetadata;
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const metadata_1 = require("../metadata");
|
|
6
|
+
const metadata_2 = require("../../server/decorators/metadata");
|
|
7
7
|
const transform_registry_1 = require("../../../__internals/transform/transform.registry");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
const
|
|
19
|
-
//
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
8
|
+
const constants_1 = require("../../../__internals/constants");
|
|
9
|
+
const schema_collector_1 = require("./schema.collector");
|
|
10
|
+
/**
|
|
11
|
+
* 🛠️ Consolidates framework metadata and OpenAPI decorators into a single Operation object.
|
|
12
|
+
*/
|
|
13
|
+
function collectMethodMetadata(target, propertyKey) {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
15
|
+
if (!propertyKey)
|
|
16
|
+
return undefined;
|
|
17
|
+
// 1. Get user-defined OpenAPI metadata from decorators
|
|
18
|
+
const baseOperation = metadata_1.SwaggerMeta.get(target, propertyKey);
|
|
19
|
+
// 2. Get framework metadata (params, route, etc.)
|
|
20
|
+
const hyperMeta = metadata_2.HyperMeta.get(target, propertyKey);
|
|
21
|
+
const operation = Object.assign(Object.assign({}, baseOperation), { parameters: [...(baseOperation.parameters || [])], responses: Object.assign({}, (baseOperation.responses || {})) });
|
|
22
|
+
// 3. Bridge Parameters (@Query, @Param, @Headers)
|
|
23
|
+
if ((_a = hyperMeta.params) === null || _a === void 0 ? void 0 : _a.params) {
|
|
24
|
+
hyperMeta.params.params.forEach((param) => {
|
|
25
|
+
const inType = mapParamIn(param.decorator);
|
|
26
|
+
if (!inType)
|
|
27
|
+
return; // Skip 'body' or unknown
|
|
28
|
+
const name = param.picker || param.name || param.decorator || 'param';
|
|
29
|
+
const schema = param.schema
|
|
30
|
+
? (transform_registry_1.transformRegistry.getOpenApiSchema(param.schema) || (0, schema_collector_1.collectSchema)(param.schema))
|
|
31
|
+
: { type: 'string' };
|
|
32
|
+
// If it's an object, we might want to explode it (if it's Query/Headers)
|
|
33
|
+
// Or if it's a DTO (whole source)
|
|
34
|
+
if (schema.type === 'object' && schema.properties && (inType === 'query' || inType === 'header')) {
|
|
35
|
+
Object.entries(schema.properties).forEach(([propName, prop]) => {
|
|
36
|
+
operation.parameters.push({
|
|
37
|
+
name: propName,
|
|
38
|
+
in: inType,
|
|
39
|
+
required: true,
|
|
40
|
+
schema: prop
|
|
41
|
+
});
|
|
42
|
+
});
|
|
38
43
|
}
|
|
39
|
-
|
|
44
|
+
else {
|
|
45
|
+
operation.parameters.push({
|
|
46
|
+
name,
|
|
47
|
+
in: inType,
|
|
48
|
+
required: inType === 'path' ? true : undefined,
|
|
49
|
+
schema
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
40
53
|
}
|
|
41
|
-
//
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
// 4. Bridge Request Body (@Body)
|
|
55
|
+
const bodyParam = (_c = (_b = hyperMeta.params) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.find((p) => p.decorator === 'Body');
|
|
56
|
+
if (bodyParam && !operation.requestBody) {
|
|
57
|
+
let schema = bodyParam.schema
|
|
58
|
+
? (transform_registry_1.transformRegistry.getOpenApiSchema(bodyParam.schema) || (0, schema_collector_1.collectSchema)(bodyParam.schema))
|
|
59
|
+
: { type: 'object' };
|
|
60
|
+
// If a specific picker was requested, wrap the schema in an object
|
|
61
|
+
if (bodyParam.picker && bodyParam.picker !== 'body') {
|
|
62
|
+
schema = {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
[bodyParam.picker]: schema
|
|
66
|
+
},
|
|
67
|
+
required: [bodyParam.picker]
|
|
68
|
+
};
|
|
50
69
|
}
|
|
70
|
+
operation.requestBody = {
|
|
71
|
+
content: {
|
|
72
|
+
"application/json": { schema }
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// 5. Bridge Responses (@Output)
|
|
77
|
+
const outputSchema = ((_g = (_f = (_e = (_d = baseOperation.responses) === null || _d === void 0 ? void 0 : _d["200"]) === null || _e === void 0 ? void 0 : _e.content) === null || _f === void 0 ? void 0 : _f["application/json"]) === null || _g === void 0 ? void 0 : _g.schema)
|
|
78
|
+
|| hyperMeta[constants_1.KEY_OUTPUT_SCHEMA]
|
|
79
|
+
|| hyperMeta.output;
|
|
80
|
+
if (outputSchema && !operation.responses["200"]) {
|
|
81
|
+
const schema = transform_registry_1.transformRegistry.getOpenApiSchema(outputSchema) || (0, schema_collector_1.collectSchema)(outputSchema);
|
|
82
|
+
operation.responses["200"] = {
|
|
83
|
+
description: "OK",
|
|
84
|
+
content: {
|
|
85
|
+
"application/json": { schema }
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
else if (Object.keys(operation.responses).length === 0) {
|
|
90
|
+
operation.responses["200"] = { description: "OK" };
|
|
91
|
+
}
|
|
92
|
+
return operation;
|
|
93
|
+
}
|
|
94
|
+
function mapParamIn(decorator) {
|
|
95
|
+
switch (decorator.toLowerCase()) {
|
|
96
|
+
case 'query': return 'query';
|
|
97
|
+
case 'param': return 'path';
|
|
98
|
+
case 'headers': return 'header';
|
|
99
|
+
default: return undefined;
|
|
51
100
|
}
|
|
52
|
-
// Asignamos las propiedades al objeto de metadata solo si existen
|
|
53
|
-
if (summary)
|
|
54
|
-
methodMetadata.summary = summary;
|
|
55
|
-
if (operationId)
|
|
56
|
-
methodMetadata.operationId = operationId;
|
|
57
|
-
if (tags)
|
|
58
|
-
methodMetadata.tags = tags;
|
|
59
|
-
if (security)
|
|
60
|
-
methodMetadata.security = security;
|
|
61
|
-
if (responses && Object.keys(responses).length > 0)
|
|
62
|
-
methodMetadata.responses = responses;
|
|
63
|
-
if (parameters.length > 0)
|
|
64
|
-
methodMetadata.parameters = parameters;
|
|
65
|
-
if (requestBody.content)
|
|
66
|
-
methodMetadata.requestBody = requestBody;
|
|
67
|
-
return methodMetadata;
|
|
68
101
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Schema } from "../types";
|
|
1
|
+
import { Schema } from '../types';
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* 🔍 Extracts a basic OpenAPI schema from a DTO class.
|
|
4
|
+
* This is a fallback when no specific transformer (Zod, etc.) is registered.
|
|
6
5
|
*/
|
|
7
6
|
export declare function collectSchema(Target: any): Schema;
|
|
8
|
-
/**
|
|
9
|
-
* Infer OpenAPI type from JavaScript constructor names.
|
|
10
|
-
*/
|
|
11
|
-
export declare function inferType(constructorName: string): string;
|
|
@@ -1,37 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.collectSchema = collectSchema;
|
|
4
|
-
exports.inferType = inferType;
|
|
5
|
-
require("reflect-metadata");
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* 🔍 Extracts a basic OpenAPI schema from a DTO class.
|
|
6
|
+
* This is a fallback when no specific transformer (Zod, etc.) is registered.
|
|
9
7
|
*/
|
|
10
8
|
function collectSchema(Target) {
|
|
11
|
-
if (
|
|
12
|
-
return { type:
|
|
9
|
+
if (typeof Target !== 'function') {
|
|
10
|
+
return { type: 'string' };
|
|
13
11
|
}
|
|
14
12
|
const schema = {
|
|
15
|
-
type:
|
|
13
|
+
type: 'object',
|
|
16
14
|
properties: {},
|
|
17
15
|
};
|
|
18
|
-
// Note: Standard
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
16
|
+
// Note: Standard TS reflection doesn't expose fields without decorators.
|
|
17
|
+
// However, we can try to instantiate or use metadata if available.
|
|
18
|
+
// For now, we provide a placeholder that can be extended.
|
|
19
|
+
// If it's a primitive constructor
|
|
20
|
+
if (Target === String)
|
|
21
|
+
return { type: 'string' };
|
|
22
|
+
if (Target === Number)
|
|
23
|
+
return { type: 'number' };
|
|
24
|
+
if (Target === Boolean)
|
|
25
|
+
return { type: 'boolean' };
|
|
26
|
+
if (Target === Date)
|
|
27
|
+
return { type: 'string', format: 'date-time' };
|
|
22
28
|
return schema;
|
|
23
29
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Infer OpenAPI type from JavaScript constructor names.
|
|
26
|
-
*/
|
|
27
|
-
function inferType(constructorName) {
|
|
28
|
-
const map = {
|
|
29
|
-
String: "string",
|
|
30
|
-
Number: "number",
|
|
31
|
-
Boolean: "boolean",
|
|
32
|
-
Array: "array",
|
|
33
|
-
Object: "object",
|
|
34
|
-
Date: "string", // Dates are strings in OpenAPI
|
|
35
|
-
};
|
|
36
|
-
return map[constructorName] || "string";
|
|
37
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// constants.ts
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.SECURITY_OIDC = exports.SECURITY_OAUTH2 = exports.SECURITY_API_KEY = exports.COMPONENTS_SECURITY_SCHEMES = exports.COMPONENTS_PARAMETERS = exports.COMPONENTS_RESPONSES = exports.COMPONENTS_SCHEMAS = exports.COMPONENTS = exports.METHOD_TAGS = exports.METHOD_OPERATION_ID = exports.METHOD_SUMMARY = exports.METHOD_METADATA = exports.TAG_DESCRIPTION = exports.TAG_NAME = exports.TAGS = exports.SECURITY_SCHEME = exports.SECURITY = exports.RESPONSE_SCHEMA = exports.RESPONSE_CONTENT = exports.RESPONSE_DESCRIPTION = exports.RESPONSES = exports.REQUEST_BODY_CONTENT = exports.REQUEST_BODY_DESCRIPTION = exports.REQUEST_BODY = exports.PARAM_SCHEMA = exports.PARAM_DESCRIPTION = exports.PARAM_REQUIRED = exports.PARAM_IN = exports.PARAM_NAME = exports.PARAMETERS = exports.METHOD_TRACE = exports.METHOD_OPTIONS = exports.METHOD_HEAD = exports.METHOD_PATCH = exports.METHOD_DELETE = exports.METHOD_PUT = exports.METHOD_POST = exports.METHOD_GET = exports.PATHS = exports.INFO_LICENSE = exports.INFO_CONTACT = exports.INFO_TERMS_OF_SERVICE = exports.INFO_VERSION = exports.INFO_DESCRIPTION = exports.INFO_TITLE = exports.OPENAPI_VERSION = void 0;
|
|
3
|
+
exports.SECURITY_OIDC = exports.SECURITY_OAUTH2 = exports.SECURITY_API_KEY = exports.COMPONENTS_SECURITY_SCHEMES = exports.COMPONENTS_PARAMETERS = exports.COMPONENTS_RESPONSES = exports.COMPONENTS_SCHEMAS = exports.COMPONENTS = exports.METHOD_TAGS = exports.METHOD_OPERATION_ID = exports.METHOD_SUMMARY = exports.METHOD_METADATA = exports.TAG_DESCRIPTION = exports.TAG_NAME = exports.TAGS = exports.SECURITY_SCHEME = exports.SECURITY = exports.RESPONSE_SCHEMA = exports.RESPONSE_CONTENT = exports.RESPONSE_DESCRIPTION = exports.RESPONSES = exports.REQUEST_BODY_CONTENT = exports.REQUEST_BODY_DESCRIPTION = exports.REQUEST_BODY = exports.PARAM_SCHEMA = exports.PARAM_DESCRIPTION = exports.PARAM_REQUIRED = exports.PARAM_IN = exports.PARAM_NAME = exports.PARAMETERS = exports.METHOD_TRACE = exports.METHOD_OPTIONS = exports.METHOD_HEAD = exports.METHOD_PATCH = exports.METHOD_DELETE = exports.METHOD_PUT = exports.METHOD_POST = exports.METHOD_GET = exports.PATHS = exports.INFO_LICENSE = exports.INFO_CONTACT = exports.INFO_TERMS_OF_SERVICE = exports.INFO_VERSION = exports.INFO_DESCRIPTION = exports.INFO_TITLE = exports.OPENAPI_VERSION = exports.KEY_OPENAPI = void 0;
|
|
4
|
+
exports.KEY_OPENAPI = "hyper:openapi";
|
|
5
5
|
// OpenAPI Version
|
|
6
6
|
exports.OPENAPI_VERSION = "3.0.0";
|
|
7
7
|
// Info Metadata (Información general sobre la API)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Tag, OpenApiResponses, OpenApiParameter, RequestBody, SecurityRequirement, Operation } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* 📝 OpenAPI Decorators consolidated for better performance and clean imports.
|
|
4
|
+
*/
|
|
5
|
+
export declare function ApiSummary(summary: string): (target: any, propertyKey: any) => void;
|
|
6
|
+
export declare function ApiDescription(description: string): (target: any, propertyKey: any) => void;
|
|
7
|
+
export declare function ApiOperationId(operationId: string): (target: any, propertyKey: any) => void;
|
|
8
|
+
export declare function ApiTag(options: Tag | string): (target: any, propertyKey?: any) => void;
|
|
9
|
+
export declare function ApiResponse(options: OpenApiResponses): (target: any, propertyKey?: any) => void;
|
|
10
|
+
export declare function ApiParameter(options: OpenApiParameter): (target: any, propertyKey: any) => void;
|
|
11
|
+
export declare function ApiRequestBody(options: RequestBody): (target: any, propertyKey: any) => void;
|
|
12
|
+
export declare function ApiSecurity(options: SecurityRequirement): (target: any, propertyKey?: any) => void;
|
|
13
|
+
export declare function ApiBearerAuth(name?: string): (target: any, propertyKey?: any) => void;
|
|
14
|
+
export declare function ApiMethod(options: Partial<Operation>): (target: any, propertyKey: any) => void;
|
|
15
|
+
export declare function ApiNamespace(name: string): (target: any, propertyKey?: any) => void;
|
|
16
|
+
export declare function ApiIgnore(): (target: any, propertyKey?: any) => void;
|