@nestia/core 3.7.0-dev.20240711 → 3.7.0-dev.20240712
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/lib/decorators/SwaggerExample.d.ts +11 -0
- package/lib/decorators/SwaggerExample.js +56 -0
- package/lib/decorators/SwaggerExample.js.map +1 -0
- package/lib/module.d.ts +1 -0
- package/lib/module.js +1 -0
- package/lib/module.js.map +1 -1
- package/package.json +3 -3
- package/src/decorators/SwaggerExample.ts +100 -0
- package/src/decorators/WebSocketRoute.ts +1 -1
- package/src/module.ts +1 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare namespace SwaggerExample {
|
|
2
|
+
function Response<T>(value: T): MethodDecorator;
|
|
3
|
+
function Response<T>(key: string, value: T): MethodDecorator;
|
|
4
|
+
function Parameter<T>(value: T): ParameterDecorator;
|
|
5
|
+
function Parameter<T>(key: string, value: T): ParameterDecorator;
|
|
6
|
+
interface IData<T> {
|
|
7
|
+
examples?: Record<string, T>;
|
|
8
|
+
example?: T;
|
|
9
|
+
index?: number;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SwaggerExample = void 0;
|
|
4
|
+
var SwaggerExample;
|
|
5
|
+
(function (SwaggerExample) {
|
|
6
|
+
function Response(...args) {
|
|
7
|
+
return function SwaggerExampleResponse(_target, _propertyKey, descriptor) {
|
|
8
|
+
emplaceValue(emplaceOfResponse(descriptor))(args);
|
|
9
|
+
return descriptor;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
SwaggerExample.Response = Response;
|
|
13
|
+
function Parameter(...args) {
|
|
14
|
+
return function SwaggerExampleParameter(target, propertyKey, index) {
|
|
15
|
+
emplaceValue(emplaceOfParameter(target, propertyKey !== null && propertyKey !== void 0 ? propertyKey : "", index))(args);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
SwaggerExample.Parameter = Parameter;
|
|
19
|
+
})(SwaggerExample || (exports.SwaggerExample = SwaggerExample = {}));
|
|
20
|
+
const emplaceValue = (data) => (args) => {
|
|
21
|
+
var _a;
|
|
22
|
+
if (args.length === 1)
|
|
23
|
+
data.example = args[0];
|
|
24
|
+
else {
|
|
25
|
+
const key = args[0];
|
|
26
|
+
const value = args[1];
|
|
27
|
+
(_a = data.examples) !== null && _a !== void 0 ? _a : (data.examples = {});
|
|
28
|
+
data.examples[key] = value;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const emplaceOfResponse = (descriptor) => {
|
|
32
|
+
const oldbie = Reflect.getMetadata("nestia/SwaggerExample/Response", descriptor.value);
|
|
33
|
+
if (oldbie !== undefined)
|
|
34
|
+
return oldbie;
|
|
35
|
+
const newbie = {};
|
|
36
|
+
Reflect.defineMetadata("nestia/SwaggerExample/Response", newbie, descriptor.value);
|
|
37
|
+
return newbie;
|
|
38
|
+
};
|
|
39
|
+
const emplaceOfParameter = (target, propertyKey, index) => {
|
|
40
|
+
const array = emplaceArrayOfParameters(target, propertyKey);
|
|
41
|
+
const oldibe = array.find((e) => e.index === index);
|
|
42
|
+
if (oldibe !== undefined)
|
|
43
|
+
return oldibe;
|
|
44
|
+
const data = { index };
|
|
45
|
+
array.push(data);
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
const emplaceArrayOfParameters = (target, propertyKey) => {
|
|
49
|
+
const array = Reflect.getMetadata("nestia/SwaggerExample/Parameters", target, propertyKey);
|
|
50
|
+
if (array !== undefined)
|
|
51
|
+
return array;
|
|
52
|
+
const newbie = [];
|
|
53
|
+
Reflect.defineMetadata("nestia/SwaggerExample/Parameters", newbie, target, propertyKey);
|
|
54
|
+
return newbie;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=SwaggerExample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwaggerExample.js","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edModule";
|
|
14
14
|
export * from "./decorators/PlainBody";
|
|
15
15
|
export * from "./decorators/SwaggerCustomizer";
|
|
16
|
+
export * from "./decorators/SwaggerExample";
|
|
16
17
|
export * from "./adaptors/WebSocketAdaptor";
|
|
17
18
|
export * from "./decorators/WebSocketRoute";
|
package/lib/module.js
CHANGED
|
@@ -29,6 +29,7 @@ __exportStar(require("./decorators/EncryptedBody"), exports);
|
|
|
29
29
|
__exportStar(require("./decorators/EncryptedModule"), exports);
|
|
30
30
|
__exportStar(require("./decorators/PlainBody"), exports);
|
|
31
31
|
__exportStar(require("./decorators/SwaggerCustomizer"), exports);
|
|
32
|
+
__exportStar(require("./decorators/SwaggerExample"), exports);
|
|
32
33
|
__exportStar(require("./adaptors/WebSocketAdaptor"), exports);
|
|
33
34
|
__exportStar(require("./decorators/WebSocketRoute"), exports);
|
|
34
35
|
//# sourceMappingURL=module.js.map
|
package/lib/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,2DAAyC;AAEzC,0DAAwC;AACxC,yDAAuC;AACvC,0DAAwC;AACxC,8DAA4C;AAC5C,4DAA0C;AAC1C,6DAA2C;AAC3C,0DAAwC;AAExC,mEAAiD;AACjD,8DAA4C;AAC5C,6DAA2C;AAC3C,+DAA6C;AAC7C,yDAAuC;AACvC,iEAA+C;
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,2DAAyC;AAEzC,0DAAwC;AACxC,yDAAuC;AACvC,0DAAwC;AACxC,8DAA4C;AAC5C,4DAA0C;AAC1C,6DAA2C;AAC3C,0DAAwC;AAExC,mEAAiD;AACjD,8DAA4C;AAC5C,6DAA2C;AAC3C,+DAA6C;AAC7C,yDAAuC;AACvC,iEAA+C;AAC/C,8DAA4C;AAE5C,8DAA4C;AAC5C,8DAA4C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/core",
|
|
3
|
-
"version": "3.7.0-dev.
|
|
3
|
+
"version": "3.7.0-dev.20240712",
|
|
4
4
|
"description": "Super-fast validation decorators of NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://nestia.io",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nestia/fetcher": "^3.7.0-dev.
|
|
39
|
+
"@nestia/fetcher": "^3.7.0-dev.20240712",
|
|
40
40
|
"@nestjs/common": ">=7.0.1",
|
|
41
41
|
"@nestjs/core": ">=7.0.1",
|
|
42
42
|
"@samchon/openapi": "^0.3.4",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"ws": "^7.5.3"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@nestia/fetcher": ">=3.7.0-dev.
|
|
56
|
+
"@nestia/fetcher": ">=3.7.0-dev.20240712",
|
|
57
57
|
"@nestjs/common": ">=7.0.1",
|
|
58
58
|
"@nestjs/core": ">=7.0.1",
|
|
59
59
|
"reflect-metadata": ">=0.1.12",
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export namespace SwaggerExample {
|
|
2
|
+
export function Response<T>(value: T): MethodDecorator;
|
|
3
|
+
export function Response<T>(key: string, value: T): MethodDecorator;
|
|
4
|
+
export function Response(...args: any[]): MethodDecorator {
|
|
5
|
+
return function SwaggerExampleResponse(
|
|
6
|
+
_target: Object,
|
|
7
|
+
_propertyKey: string | symbol,
|
|
8
|
+
descriptor: TypedPropertyDescriptor<any>,
|
|
9
|
+
): TypedPropertyDescriptor<any> {
|
|
10
|
+
emplaceValue(emplaceOfResponse(descriptor))(args);
|
|
11
|
+
return descriptor;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function Parameter<T>(value: T): ParameterDecorator;
|
|
16
|
+
export function Parameter<T>(key: string, value: T): ParameterDecorator;
|
|
17
|
+
export function Parameter(...args: any[]): ParameterDecorator {
|
|
18
|
+
return function SwaggerExampleParameter(
|
|
19
|
+
target: Object,
|
|
20
|
+
propertyKey: string | symbol | undefined,
|
|
21
|
+
index: number,
|
|
22
|
+
): void {
|
|
23
|
+
emplaceValue(emplaceOfParameter(target, propertyKey ?? "", index))(args);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface IData<T> {
|
|
28
|
+
examples?: Record<string, T>;
|
|
29
|
+
example?: T;
|
|
30
|
+
index?: number;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const emplaceValue =
|
|
35
|
+
<T>(data: SwaggerExample.IData<T>) =>
|
|
36
|
+
(args: any[]) => {
|
|
37
|
+
if (args.length === 1) data.example = args[0];
|
|
38
|
+
else {
|
|
39
|
+
const key: string = args[0];
|
|
40
|
+
const value: T = args[1];
|
|
41
|
+
data.examples ??= {};
|
|
42
|
+
data.examples[key] = value;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const emplaceOfResponse = <T>(
|
|
47
|
+
descriptor: TypedPropertyDescriptor<any>,
|
|
48
|
+
): SwaggerExample.IData<T> => {
|
|
49
|
+
const oldbie: SwaggerExample.IData<T> | undefined = Reflect.getMetadata(
|
|
50
|
+
"nestia/SwaggerExample/Response",
|
|
51
|
+
descriptor.value,
|
|
52
|
+
);
|
|
53
|
+
if (oldbie !== undefined) return oldbie;
|
|
54
|
+
const newbie: SwaggerExample.IData<T> = {};
|
|
55
|
+
Reflect.defineMetadata(
|
|
56
|
+
"nestia/SwaggerExample/Response",
|
|
57
|
+
newbie,
|
|
58
|
+
descriptor.value,
|
|
59
|
+
);
|
|
60
|
+
return newbie;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const emplaceOfParameter = (
|
|
64
|
+
target: Object,
|
|
65
|
+
propertyKey: string | symbol,
|
|
66
|
+
index: number,
|
|
67
|
+
): SwaggerExample.IData<any> => {
|
|
68
|
+
const array: SwaggerExample.IData<any>[] = emplaceArrayOfParameters(
|
|
69
|
+
target,
|
|
70
|
+
propertyKey,
|
|
71
|
+
);
|
|
72
|
+
const oldibe: SwaggerExample.IData<any> | undefined = array.find(
|
|
73
|
+
(e) => e.index === index,
|
|
74
|
+
);
|
|
75
|
+
if (oldibe !== undefined) return oldibe;
|
|
76
|
+
|
|
77
|
+
const data: SwaggerExample.IData<any> = { index };
|
|
78
|
+
array.push(data);
|
|
79
|
+
return data;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const emplaceArrayOfParameters = (
|
|
83
|
+
target: Object,
|
|
84
|
+
propertyKey: string | symbol,
|
|
85
|
+
): SwaggerExample.IData<any>[] => {
|
|
86
|
+
const array: SwaggerExample.IData<any>[] | undefined = Reflect.getMetadata(
|
|
87
|
+
"nestia/SwaggerExample/Parameters",
|
|
88
|
+
target,
|
|
89
|
+
propertyKey,
|
|
90
|
+
);
|
|
91
|
+
if (array !== undefined) return array;
|
|
92
|
+
const newbie: SwaggerExample.IData<any>[] = [];
|
|
93
|
+
Reflect.defineMetadata(
|
|
94
|
+
"nestia/SwaggerExample/Parameters",
|
|
95
|
+
newbie,
|
|
96
|
+
target,
|
|
97
|
+
propertyKey,
|
|
98
|
+
);
|
|
99
|
+
return newbie;
|
|
100
|
+
};
|
package/src/module.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./decorators/EncryptedBody";
|
|
|
15
15
|
export * from "./decorators/EncryptedModule";
|
|
16
16
|
export * from "./decorators/PlainBody";
|
|
17
17
|
export * from "./decorators/SwaggerCustomizer";
|
|
18
|
+
export * from "./decorators/SwaggerExample";
|
|
18
19
|
|
|
19
20
|
export * from "./adaptors/WebSocketAdaptor";
|
|
20
21
|
export * from "./decorators/WebSocketRoute";
|