@trapi/metadata 1.0.0-alpha.2 → 1.0.0-alpha.3
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/cache/driver.js.map +1 -1
- package/dist/decorator/constants.d.ts +13 -12
- package/dist/decorator/constants.d.ts.map +1 -1
- package/dist/decorator/constants.js +13 -12
- package/dist/decorator/constants.js.map +1 -1
- package/dist/decorator/preset/utils/load.d.ts.map +1 -1
- package/dist/decorator/preset/utils/load.js +1 -4
- package/dist/decorator/preset/utils/load.js.map +1 -1
- package/dist/decorator/property-manager/module.d.ts +6 -8
- package/dist/decorator/property-manager/module.d.ts.map +1 -1
- package/dist/decorator/property-manager/module.js +14 -20
- package/dist/decorator/property-manager/module.js.map +1 -1
- package/dist/decorator/property-manager/utils.d.ts +4 -5
- package/dist/decorator/property-manager/utils.d.ts.map +1 -1
- package/dist/decorator/property-manager/utils.js +55 -84
- package/dist/decorator/property-manager/utils.js.map +1 -1
- package/dist/decorator/sets/class.d.ts +2 -2
- package/dist/decorator/sets/class.d.ts.map +1 -1
- package/dist/decorator/sets/method.d.ts +2 -2
- package/dist/decorator/sets/method.d.ts.map +1 -1
- package/dist/decorator/sets/mixed.d.ts +6 -2
- package/dist/decorator/sets/mixed.d.ts.map +1 -1
- package/dist/decorator/sets/parameter.d.ts +2 -2
- package/dist/decorator/sets/parameter.d.ts.map +1 -1
- package/dist/decorator/sets/request.d.ts +2 -2
- package/dist/decorator/sets/request.d.ts.map +1 -1
- package/dist/decorator/sets/response.d.ts +3 -2
- package/dist/decorator/sets/response.d.ts.map +1 -1
- package/dist/decorator/type.d.ts +8 -15
- package/dist/decorator/type.d.ts.map +1 -1
- package/dist/error/index.d.ts +0 -1
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +0 -1
- package/dist/error/index.js.map +1 -1
- package/dist/generator/abstract.d.ts +6 -13
- package/dist/generator/abstract.d.ts.map +1 -1
- package/dist/generator/abstract.js +48 -56
- package/dist/generator/abstract.js.map +1 -1
- package/dist/generator/controller/module.d.ts +2 -2
- package/dist/generator/controller/module.d.ts.map +1 -1
- package/dist/generator/controller/module.js +24 -19
- package/dist/generator/controller/module.js.map +1 -1
- package/dist/generator/controller/type.d.ts +12 -7
- package/dist/generator/controller/type.d.ts.map +1 -1
- package/dist/generator/metadata/index.d.ts +1 -0
- package/dist/generator/metadata/index.d.ts.map +1 -1
- package/dist/generator/metadata/index.js +1 -0
- package/dist/generator/metadata/index.js.map +1 -1
- package/dist/generator/metadata/module.d.ts +0 -2
- package/dist/generator/metadata/module.d.ts.map +1 -1
- package/dist/generator/metadata/module.js +13 -33
- package/dist/generator/metadata/module.js.map +1 -1
- package/dist/generator/metadata/utils.d.ts +3 -0
- package/dist/generator/metadata/utils.d.ts.map +1 -0
- package/dist/generator/metadata/utils.js +19 -0
- package/dist/generator/metadata/utils.js.map +1 -0
- package/dist/generator/method/module.d.ts +8 -9
- package/dist/generator/method/module.d.ts.map +1 -1
- package/dist/generator/method/module.js +53 -72
- package/dist/generator/method/module.js.map +1 -1
- package/dist/generator/parameter/constants.d.ts +19 -0
- package/dist/generator/parameter/constants.d.ts.map +1 -0
- package/dist/generator/parameter/constants.js +30 -0
- package/dist/generator/parameter/constants.js.map +1 -0
- package/dist/generator/parameter/error.d.ts +35 -0
- package/dist/generator/parameter/error.d.ts.map +1 -0
- package/dist/generator/parameter/error.js +68 -0
- package/dist/generator/parameter/error.js.map +1 -0
- package/dist/generator/parameter/index.d.ts +2 -0
- package/dist/generator/parameter/index.d.ts.map +1 -1
- package/dist/generator/parameter/index.js +2 -0
- package/dist/generator/parameter/index.js.map +1 -1
- package/dist/generator/parameter/module.d.ts +7 -6
- package/dist/generator/parameter/module.d.ts.map +1 -1
- package/dist/generator/parameter/module.js +362 -196
- package/dist/generator/parameter/module.js.map +1 -1
- package/dist/generator/parameter/type.d.ts +8 -5
- package/dist/generator/parameter/type.d.ts.map +1 -1
- package/dist/generator/parameter/validator.d.ts.map +1 -1
- package/dist/generator/parameter/validator.js +15 -9
- package/dist/generator/parameter/validator.js.map +1 -1
- package/dist/generator/type.d.ts +8 -5
- package/dist/generator/type.d.ts.map +1 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +10 -3
- package/dist/module.js.map +1 -1
- package/dist/resolver/module.d.ts +1 -1
- package/dist/resolver/module.d.ts.map +1 -1
- package/dist/resolver/module.js +7 -7
- package/dist/resolver/module.js.map +1 -1
- package/dist/utils/js-doc/index.d.ts +1 -0
- package/dist/utils/js-doc/index.d.ts.map +1 -1
- package/dist/utils/js-doc/index.js +1 -0
- package/dist/utils/js-doc/index.js.map +1 -1
- package/dist/utils/js-doc/module.d.ts.map +1 -1
- package/dist/utils/js-doc/module.js +2 -7
- package/dist/utils/js-doc/module.js.map +1 -1
- package/dist/utils/js-doc/utils.d.ts +3 -0
- package/dist/utils/js-doc/utils.d.ts.map +1 -0
- package/dist/utils/js-doc/utils.js +29 -0
- package/dist/utils/js-doc/utils.js.map +1 -0
- package/dist/utils/object.d.ts.map +1 -1
- package/dist/utils/object.js +1 -0
- package/dist/utils/object.js.map +1 -1
- package/package.json +5 -4
- package/dist/error/parameter-invalid.d.ts +0 -4
- package/dist/error/parameter-invalid.d.ts.map +0 -1
- package/dist/error/parameter-invalid.js +0 -14
- package/dist/error/parameter-invalid.js.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.isMetadata = void 0;
|
|
10
|
+
const locter_1 = require("locter");
|
|
11
|
+
function isMetadata(input) {
|
|
12
|
+
return (0, locter_1.isObject)(input) &&
|
|
13
|
+
(0, locter_1.hasOwnProperty)(input, 'controllers') &&
|
|
14
|
+
Array.isArray(input.controllers) &&
|
|
15
|
+
(0, locter_1.hasOwnProperty)(input, 'referenceTypes') &&
|
|
16
|
+
(0, locter_1.isObject)(input.referenceTypes);
|
|
17
|
+
}
|
|
18
|
+
exports.isMetadata = isMetadata;
|
|
19
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/generator/metadata/utils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAkD;AAGlD,SAAgB,UAAU,CAAC,KAAc;IACrC,OAAO,IAAA,iBAAQ,EAAC,KAAK,CAAC;QAClB,IAAA,uBAAc,EAAC,KAAK,EAAE,aAAa,CAAC;QACpC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC;QAChC,IAAA,uBAAc,EAAC,KAAK,EAAE,gBAAgB,CAAC;QACvC,IAAA,iBAAQ,EAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AACvC,CAAC;AAND,gCAMC"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { MethodDeclaration } from 'typescript';
|
|
2
2
|
import { AbstractGenerator } from '../abstract';
|
|
3
3
|
import type { MetadataGenerator } from '../metadata';
|
|
4
4
|
import type { Method } from './type';
|
|
5
|
-
export declare class MethodGenerator extends AbstractGenerator<
|
|
6
|
-
private readonly controllerPath;
|
|
5
|
+
export declare class MethodGenerator extends AbstractGenerator<MethodDeclaration> {
|
|
7
6
|
private method;
|
|
8
|
-
constructor(node:
|
|
7
|
+
constructor(node: MethodDeclaration, current: MetadataGenerator);
|
|
9
8
|
isValid(): boolean;
|
|
10
9
|
getMethodName(): string;
|
|
11
|
-
generate(): Method;
|
|
10
|
+
generate(controllerPath: string): Method;
|
|
12
11
|
protected getCurrentLocation(): string;
|
|
13
12
|
private buildParameters;
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
13
|
+
private determineVerb;
|
|
14
|
+
private buildResponse;
|
|
15
|
+
private guessResponseType;
|
|
16
|
+
private getResponseExamples;
|
|
18
17
|
private mergeResponses;
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/generator/method/module.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/generator/method/module.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACsB,iBAAiB,EAClD,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrD,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAEjD,qBAAa,eAAgB,SAAQ,iBAAiB,CAAC,iBAAiB,CAAC;IACrE,OAAO,CAAC,MAAM,CAAa;gBAKvB,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,iBAAiB;IASvB,OAAO,IAAK,OAAO;IAInB,aAAa;IAKb,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAkC/C,SAAS,CAAC,kBAAkB;IAM5B,OAAO,CAAC,eAAe;IAsDvB,OAAO,CAAC,aAAa;IA+BrB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,iBAAiB;IAuBzB,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,cAAc;CAmBzB"}
|
|
@@ -5,36 +5,13 @@
|
|
|
5
5
|
* For the full copyright and license information,
|
|
6
6
|
* view the LICENSE file that was distributed with this source code.
|
|
7
7
|
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
10
|
};
|
|
34
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
12
|
exports.MethodGenerator = void 0;
|
|
36
13
|
const node_path_1 = __importDefault(require("node:path"));
|
|
37
|
-
const
|
|
14
|
+
const typescript_1 = require("typescript");
|
|
38
15
|
const decorator_1 = require("../../decorator");
|
|
39
16
|
const resolver_1 = require("../../resolver");
|
|
40
17
|
const utils_1 = require("../../utils");
|
|
@@ -42,32 +19,29 @@ const abstract_1 = require("../abstract");
|
|
|
42
19
|
const parameter_1 = require("../parameter");
|
|
43
20
|
class MethodGenerator extends abstract_1.AbstractGenerator {
|
|
44
21
|
// --------------------------------------------------------------------
|
|
45
|
-
constructor(node, current
|
|
22
|
+
constructor(node, current) {
|
|
46
23
|
super(node, current);
|
|
47
|
-
this.
|
|
48
|
-
this.processMethodDecorators();
|
|
24
|
+
this.determineVerb();
|
|
49
25
|
}
|
|
50
26
|
// --------------------------------------------------------------------
|
|
51
27
|
isValid() {
|
|
52
|
-
return
|
|
28
|
+
return typeof this.method !== 'undefined';
|
|
53
29
|
}
|
|
54
30
|
getMethodName() {
|
|
55
31
|
const identifier = this.node.name;
|
|
56
32
|
return identifier.text;
|
|
57
33
|
}
|
|
58
|
-
generate() {
|
|
59
|
-
if (!this.isValid()) {
|
|
60
|
-
throw new Error('This isn\'t a valid controller method.');
|
|
61
|
-
}
|
|
34
|
+
generate(controllerPath) {
|
|
62
35
|
let nodeType = this.node.type;
|
|
63
36
|
if (!nodeType) {
|
|
64
37
|
const { typeChecker } = this.current;
|
|
65
38
|
const signature = typeChecker.getSignatureFromDeclaration(this.node);
|
|
66
39
|
const implicitType = typeChecker.getReturnTypeOfSignature(signature);
|
|
67
|
-
nodeType = typeChecker.typeToTypeNode(implicitType, undefined,
|
|
40
|
+
nodeType = typeChecker.typeToTypeNode(implicitType, undefined, typescript_1.NodeBuilderFlags.NoTruncation);
|
|
68
41
|
}
|
|
69
42
|
const type = new resolver_1.TypeNodeResolver(nodeType, this.current).resolve();
|
|
70
|
-
const responses = this.mergeResponses(this.
|
|
43
|
+
const responses = this.mergeResponses(this.buildResponses(), this.buildResponse(type));
|
|
44
|
+
const methodPath = this.buildPath();
|
|
71
45
|
return {
|
|
72
46
|
// todo: implement extensions
|
|
73
47
|
consumes: this.getConsumes(),
|
|
@@ -77,14 +51,14 @@ class MethodGenerator extends abstract_1.AbstractGenerator {
|
|
|
77
51
|
hidden: this.isHidden(this.node),
|
|
78
52
|
method: this.method,
|
|
79
53
|
name: this.node.name.text,
|
|
80
|
-
|
|
81
|
-
path: this.path,
|
|
54
|
+
path: methodPath,
|
|
82
55
|
produces: this.getProduces(),
|
|
83
56
|
responses,
|
|
84
57
|
security: this.getSecurity(),
|
|
85
58
|
summary: (0, utils_1.getJSDocTagComment)(this.node, utils_1.JSDocTagName.SUMMARY),
|
|
86
59
|
tags: this.getTags(),
|
|
87
60
|
type,
|
|
61
|
+
parameters: this.buildParameters(controllerPath, methodPath),
|
|
88
62
|
};
|
|
89
63
|
}
|
|
90
64
|
getCurrentLocation() {
|
|
@@ -92,29 +66,32 @@ class MethodGenerator extends abstract_1.AbstractGenerator {
|
|
|
92
66
|
const controllerId = this.node.parent.name;
|
|
93
67
|
return `${controllerId.text}.${methodId.text}`;
|
|
94
68
|
}
|
|
95
|
-
buildParameters() {
|
|
96
|
-
const methodId = this.node.name;
|
|
69
|
+
buildParameters(controllerPath, methodPath) {
|
|
97
70
|
const controllerId = this.node.parent.name;
|
|
98
|
-
const
|
|
71
|
+
const methodId = this.node.name;
|
|
72
|
+
const fullPath = node_path_1.default.posix.join('/', controllerPath, methodPath);
|
|
73
|
+
const output = [];
|
|
99
74
|
let bodyParameterCount = 0;
|
|
100
75
|
let formParameterCount = 0;
|
|
101
76
|
for (let i = 0; i < this.node.parameters.length; i++) {
|
|
102
77
|
try {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
parameters.
|
|
78
|
+
const generator = new parameter_1.ParameterGenerator(this.node.parameters[i], this.method, fullPath, this.current);
|
|
79
|
+
const parameters = generator.generate();
|
|
80
|
+
for (let j = 0; j < parameters.length; j++) {
|
|
81
|
+
if (parameters[j].in === parameter_1.ParameterSource.BODY) {
|
|
82
|
+
bodyParameterCount++;
|
|
83
|
+
}
|
|
84
|
+
if (parameters[j].in === parameter_1.ParameterSource.FORM_DATA) {
|
|
85
|
+
formParameterCount++;
|
|
86
|
+
}
|
|
87
|
+
if (parameters[j].in !== parameter_1.ParameterSource.CONTEXT) {
|
|
88
|
+
output.push(parameters[j]);
|
|
89
|
+
}
|
|
113
90
|
}
|
|
114
91
|
}
|
|
115
92
|
catch (e) {
|
|
116
93
|
const parameterId = this.node.parameters[i].name;
|
|
117
|
-
throw new Error(`
|
|
94
|
+
throw new Error(`Parameter generation: '${controllerId.text}.${methodId.text}' argument: ${parameterId.text} ${e}`);
|
|
118
95
|
}
|
|
119
96
|
}
|
|
120
97
|
if (bodyParameterCount > 1) {
|
|
@@ -123,9 +100,9 @@ class MethodGenerator extends abstract_1.AbstractGenerator {
|
|
|
123
100
|
if (bodyParameterCount > 0 && formParameterCount > 0) {
|
|
124
101
|
throw new Error(`Choose either form-, file- or body-parameter in '${this.getCurrentLocation()}' method.`);
|
|
125
102
|
}
|
|
126
|
-
return
|
|
103
|
+
return output;
|
|
127
104
|
}
|
|
128
|
-
|
|
105
|
+
determineVerb() {
|
|
129
106
|
const methods = [
|
|
130
107
|
decorator_1.DecoratorID.ALL,
|
|
131
108
|
decorator_1.DecoratorID.DELETE,
|
|
@@ -149,57 +126,61 @@ class MethodGenerator extends abstract_1.AbstractGenerator {
|
|
|
149
126
|
return;
|
|
150
127
|
}
|
|
151
128
|
this.method = method.toLowerCase();
|
|
152
|
-
this.generatePath(decorator_1.DecoratorID.METHOD_PATH);
|
|
153
129
|
}
|
|
154
|
-
|
|
155
|
-
type = this.
|
|
130
|
+
buildResponse(type) {
|
|
131
|
+
type = this.guessResponseType(type);
|
|
156
132
|
return {
|
|
157
133
|
description: (0, resolver_1.isVoidType)(type) ? 'No content' : 'Ok',
|
|
158
|
-
examples: this.
|
|
134
|
+
examples: this.getResponseExamples(),
|
|
159
135
|
schema: type,
|
|
160
136
|
status: (0, resolver_1.isVoidType)(type) ? '204' : '200',
|
|
161
137
|
name: (0, resolver_1.isVoidType)(type) ? '204' : '200',
|
|
162
138
|
};
|
|
163
139
|
}
|
|
164
|
-
|
|
140
|
+
guessResponseType(type) {
|
|
165
141
|
if (!(0, resolver_1.isVoidType)(type)) {
|
|
166
142
|
return type;
|
|
167
143
|
}
|
|
168
|
-
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.
|
|
144
|
+
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.EXAMPLE, this.node);
|
|
169
145
|
if (typeof representation === 'undefined') {
|
|
170
146
|
return type;
|
|
171
147
|
}
|
|
172
|
-
const value = representation.
|
|
148
|
+
const value = representation.get('type');
|
|
173
149
|
if (typeof value !== 'undefined' &&
|
|
174
150
|
(0, utils_1.hasOwnProperty)(value, 'kind') &&
|
|
175
|
-
|
|
151
|
+
(0, typescript_1.isTypeNode)(value)) {
|
|
176
152
|
type = new resolver_1.TypeNodeResolver(value, this.current).resolve();
|
|
177
153
|
}
|
|
178
154
|
return type;
|
|
179
155
|
}
|
|
180
|
-
|
|
181
|
-
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.
|
|
156
|
+
getResponseExamples() {
|
|
157
|
+
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.EXAMPLE, this.node);
|
|
182
158
|
if (typeof representation === 'undefined') {
|
|
183
159
|
return [];
|
|
184
160
|
}
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
161
|
+
const output = [];
|
|
162
|
+
for (let i = 0; i < representation.decorators.length; i++) {
|
|
163
|
+
const value = representation.get('payload');
|
|
164
|
+
const label = representation.get('label');
|
|
165
|
+
if (typeof value !== 'undefined') {
|
|
166
|
+
output.push({ value, label });
|
|
167
|
+
}
|
|
188
168
|
}
|
|
189
|
-
return
|
|
169
|
+
return output;
|
|
190
170
|
}
|
|
191
|
-
mergeResponses(responses,
|
|
171
|
+
mergeResponses(responses, exampleResponse) {
|
|
192
172
|
if (!responses || !responses.length) {
|
|
193
|
-
return [
|
|
173
|
+
return [exampleResponse];
|
|
194
174
|
}
|
|
195
|
-
const index = responses.findIndex((resp) => resp.status ===
|
|
175
|
+
const index = responses.findIndex((resp) => resp.status === exampleResponse.status);
|
|
196
176
|
if (index >= 0) {
|
|
197
|
-
if (
|
|
198
|
-
responses[index].examples
|
|
177
|
+
if (exampleResponse.examples &&
|
|
178
|
+
(!responses[index].examples || !responses[index].examples.length)) {
|
|
179
|
+
responses[index].examples = exampleResponse.examples;
|
|
199
180
|
}
|
|
200
181
|
}
|
|
201
182
|
else {
|
|
202
|
-
responses.push(
|
|
183
|
+
responses.push(exampleResponse);
|
|
203
184
|
}
|
|
204
185
|
return responses;
|
|
205
186
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/generator/method/module.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/generator/method/module.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,0DAA6B;AAC7B,2CAA0D;AAI1D,+CAA8C;AAE9C,6CAA8D;AAC9D,uCAEqB;AACrB,0CAAgD;AAGhD,4CAAmE;AAInE,MAAa,eAAgB,SAAQ,4BAAoC;IAGrE,uEAAuE;IAEvE,YACI,IAAuB,EACvB,OAA0B;QAE1B,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAErB,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC;IAED,uEAAuE;IAEhE,OAAO;QACV,OAAO,OAAO,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC;IAC9C,CAAC;IAEM,aAAa;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAkB,CAAC;QAChD,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3B,CAAC;IAEM,QAAQ,CAAC,cAAsB;QAClC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,QAAQ,EAAE;YACX,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YACrC,MAAM,SAAS,GAAG,WAAW,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrE,MAAM,YAAY,GAAG,WAAW,CAAC,wBA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CAAC,QAAQ;gBACxB,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EACnE;gBACE,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC;aACxD;SACJ;aAAM;YACH,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;SACnC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AA9ND,0CA8NC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum ParameterSource {
|
|
2
|
+
BODY = "body",
|
|
3
|
+
BODY_PROP = "bodyProp",
|
|
4
|
+
CONTEXT = "context",
|
|
5
|
+
COOKIE = "cookie",
|
|
6
|
+
HEADER = "header",
|
|
7
|
+
FORM_DATA = "formData",
|
|
8
|
+
QUERY = "query",
|
|
9
|
+
QUERY_PROP = "queryProp",
|
|
10
|
+
PATH = "path"
|
|
11
|
+
}
|
|
12
|
+
export declare enum CollectionFormat {
|
|
13
|
+
CSV = "csv",
|
|
14
|
+
SSV = "ssv",
|
|
15
|
+
TSV = "tsv",
|
|
16
|
+
PIPES = "pipes",
|
|
17
|
+
MULTI = "multi"
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/generator/parameter/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,eAAe;IACvB,IAAI,SAAS;IACb,SAAS,aAAa;IACtB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,SAAS,aAAa;IACtB,KAAK,UAAU;IACf,UAAU,cAAc;IACxB,IAAI,SAAS;CAChB;AAED,oBAAY,gBAAgB;IACxB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,KAAK,UAAU;CAClB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CollectionFormat = exports.ParameterSource = void 0;
|
|
10
|
+
var ParameterSource;
|
|
11
|
+
(function (ParameterSource) {
|
|
12
|
+
ParameterSource["BODY"] = "body";
|
|
13
|
+
ParameterSource["BODY_PROP"] = "bodyProp";
|
|
14
|
+
ParameterSource["CONTEXT"] = "context";
|
|
15
|
+
ParameterSource["COOKIE"] = "cookie";
|
|
16
|
+
ParameterSource["HEADER"] = "header";
|
|
17
|
+
ParameterSource["FORM_DATA"] = "formData";
|
|
18
|
+
ParameterSource["QUERY"] = "query";
|
|
19
|
+
ParameterSource["QUERY_PROP"] = "queryProp";
|
|
20
|
+
ParameterSource["PATH"] = "path";
|
|
21
|
+
})(ParameterSource = exports.ParameterSource || (exports.ParameterSource = {}));
|
|
22
|
+
var CollectionFormat;
|
|
23
|
+
(function (CollectionFormat) {
|
|
24
|
+
CollectionFormat["CSV"] = "csv";
|
|
25
|
+
CollectionFormat["SSV"] = "ssv";
|
|
26
|
+
CollectionFormat["TSV"] = "tsv";
|
|
27
|
+
CollectionFormat["PIPES"] = "pipes";
|
|
28
|
+
CollectionFormat["MULTI"] = "multi";
|
|
29
|
+
})(CollectionFormat = exports.CollectionFormat || (exports.CollectionFormat = {}));
|
|
30
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/generator/parameter/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,IAAY,eAUX;AAVD,WAAY,eAAe;IACvB,gCAAa,CAAA;IACb,yCAAsB,CAAA;IACtB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,yCAAsB,CAAA;IACtB,kCAAe,CAAA;IACf,2CAAwB,CAAA;IACxB,gCAAa,CAAA;AACjB,CAAC,EAVW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAU1B;AAED,IAAY,gBAMX;AAND,WAAY,gBAAgB;IACxB,+BAAW,CAAA;IACX,+BAAW,CAAA;IACX,+BAAW,CAAA;IACX,mCAAe,CAAA;IACf,mCAAe,CAAA;AACnB,CAAC,EANW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAM3B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Node } from 'typescript';
|
|
2
|
+
import { BaseError } from '../../error';
|
|
3
|
+
import type { BaseType } from '../../resolver';
|
|
4
|
+
type UnsupportedTypeContext = {
|
|
5
|
+
decoratorName: string;
|
|
6
|
+
propertyName: string;
|
|
7
|
+
type: BaseType;
|
|
8
|
+
node?: Node;
|
|
9
|
+
};
|
|
10
|
+
type UnsupportedMethodContext = {
|
|
11
|
+
decoratorName: string;
|
|
12
|
+
propertyName: string;
|
|
13
|
+
method: string;
|
|
14
|
+
node?: Node;
|
|
15
|
+
};
|
|
16
|
+
type PathMatchInvalidContext = {
|
|
17
|
+
decoratorName: string;
|
|
18
|
+
propertyName: string;
|
|
19
|
+
path: string;
|
|
20
|
+
node?: Node;
|
|
21
|
+
};
|
|
22
|
+
type ScopeRequiredContext = {
|
|
23
|
+
decoratorName: string;
|
|
24
|
+
node?: Node;
|
|
25
|
+
};
|
|
26
|
+
export declare class ParameterError extends BaseError {
|
|
27
|
+
static typeUnsupported(context: UnsupportedTypeContext): ParameterError;
|
|
28
|
+
static methodUnsupported(context: UnsupportedMethodContext): ParameterError;
|
|
29
|
+
static invalidPathMatch(context: PathMatchInvalidContext): ParameterError;
|
|
30
|
+
static scopeRequired(context: ScopeRequiredContext): ParameterError;
|
|
31
|
+
static invalidExampleSchema(): ParameterError;
|
|
32
|
+
static getCurrentLocation(node: Node): string;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/generator/parameter/error.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,KAAK,sBAAsB,GAAG;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,IAAI,CAAA;CACd,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,IAAI,CAAA;CACd,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,IAAI,CAAA;CACd,CAAC;AAEF,KAAK,oBAAoB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,IAAI,CAAA;CACd,CAAC;AAEF,qBAAa,cAAe,SAAQ,SAAS;IACzC,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,sBAAsB;IAYtD,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,wBAAwB;IAY1D,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,uBAAuB;IAYxD,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,oBAAoB;IAYlD,MAAM,CAAC,oBAAoB;WAIb,kBAAkB,CAAC,IAAI,EAAE,IAAI;CAa9C"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParameterError = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2022-2023.
|
|
6
|
+
* Author Peter Placzek (tada5hi)
|
|
7
|
+
* For the full copyright and license information,
|
|
8
|
+
* view the LICENSE file that was distributed with this source code.
|
|
9
|
+
*/
|
|
10
|
+
const typescript_1 = require("typescript");
|
|
11
|
+
const error_1 = require("../../error");
|
|
12
|
+
class ParameterError extends error_1.BaseError {
|
|
13
|
+
static typeUnsupported(context) {
|
|
14
|
+
let text = `@${context.decoratorName}('${context.propertyName}') Does not support '${context.type.typeName}' type`;
|
|
15
|
+
if (context.node) {
|
|
16
|
+
const location = ParameterError.getCurrentLocation(context.node);
|
|
17
|
+
if (location) {
|
|
18
|
+
text += ` at location ${location}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return new ParameterError(`${text}.`);
|
|
22
|
+
}
|
|
23
|
+
static methodUnsupported(context) {
|
|
24
|
+
let text = `@${context.decoratorName}('${context.propertyName}') Does not support method ${context.method}`;
|
|
25
|
+
if (context.node) {
|
|
26
|
+
const location = ParameterError.getCurrentLocation(context.node);
|
|
27
|
+
if (location) {
|
|
28
|
+
text += ` at location ${location}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return new ParameterError(`${text}.`);
|
|
32
|
+
}
|
|
33
|
+
static invalidPathMatch(context) {
|
|
34
|
+
let text = `@${context.decoratorName}('${context.propertyName}') Does not exist in path ${context.path}`;
|
|
35
|
+
if (context.node) {
|
|
36
|
+
const location = ParameterError.getCurrentLocation(context.node);
|
|
37
|
+
if (location) {
|
|
38
|
+
text += ` at location ${location}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return new ParameterError(`${text}.`);
|
|
42
|
+
}
|
|
43
|
+
static scopeRequired(context) {
|
|
44
|
+
let text = `@${context.decoratorName}(xxx) a scope is required`;
|
|
45
|
+
if (context.node) {
|
|
46
|
+
const location = ParameterError.getCurrentLocation(context.node);
|
|
47
|
+
if (location) {
|
|
48
|
+
text += ` at location ${location}`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return new ParameterError(`${text}.`);
|
|
52
|
+
}
|
|
53
|
+
static invalidExampleSchema() {
|
|
54
|
+
return new ParameterError('The example jsdoc schema is invalid.');
|
|
55
|
+
}
|
|
56
|
+
static getCurrentLocation(node) {
|
|
57
|
+
const parts = [];
|
|
58
|
+
if ((0, typescript_1.isMethodDeclaration)(node.parent)) {
|
|
59
|
+
parts.push(node.parent.name.getText());
|
|
60
|
+
if ((0, typescript_1.isClassDeclaration)(node.parent.parent)) {
|
|
61
|
+
parts.unshift(node.parent.parent.name.text);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return parts.join('.');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ParameterError = ParameterError;
|
|
68
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/generator/parameter/error.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,2CAAqE;AAErE,uCAAwC;AA6BxC,MAAa,cAAe,SAAQ,iBAAS;IACzC,MAAM,CAAC,eAAe,CAAC,OAA+B;QAClD,IAAI,IAAI,GAAG,IAAI,OAAO,CAAC,aAAa,KAAK,OAAO,CAAC,YAAY,wBAAwB,OAAO,CAAC,IAAI,CAAC,QAAQ,QAAQ,CAAC;QACnH,IAAI,OAAO,CAAC,IAAI,EAAE;YACd,MAAM,QAAQ,GAAG,cAAc,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACjE,IAAI,QAAQ,EAAE;gB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BAAgB,QAAQ,EAAE,CAAC;aACtC;SACJ;QAED,OAAO,IAAI,cAAc,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,oBAAoB;QACvB,OAAO,IAAI,cAAc,CAAC,sCAAsC,CAAC,CAAC;IACtE,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAAC,IAAU;QACvC,MAAM,KAAK,GAAc,EAAE,CAAC;QAE5B,IAAI,IAAA,gCAAmB,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YAClC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YAEvC,IAAI,IAAA,+BAAkB,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;gBACxC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC/C;SACJ;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACJ;AAlED,wCAkEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generator/parameter/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generator/parameter/index.ts"],"names":[],"mappings":"AAOA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
|
|
@@ -20,6 +20,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./constants"), exports);
|
|
24
|
+
__exportStar(require("./error"), exports);
|
|
23
25
|
__exportStar(require("./module"), exports);
|
|
24
26
|
__exportStar(require("./validator"), exports);
|
|
25
27
|
__exportStar(require("./type"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generator/parameter/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,8CAA4B;AAC5B,yCAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generator/parameter/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,0CAAwB;AACxB,2CAAyB;AACzB,8CAA4B;AAC5B,yCAAuB"}
|
|
@@ -7,9 +7,9 @@ export declare class ParameterGenerator {
|
|
|
7
7
|
private readonly path;
|
|
8
8
|
private readonly current;
|
|
9
9
|
constructor(parameter: ts.ParameterDeclaration, method: string, path: string, current: MetadataGenerator);
|
|
10
|
-
generate(): Parameter;
|
|
11
|
-
private
|
|
12
|
-
private
|
|
10
|
+
generate(): Parameter[];
|
|
11
|
+
private buildParametersForObject;
|
|
12
|
+
private getParamParameter;
|
|
13
13
|
private getContextParameter;
|
|
14
14
|
private getFileParameter;
|
|
15
15
|
private getFormParameter;
|
|
@@ -17,12 +17,13 @@ export declare class ParameterGenerator {
|
|
|
17
17
|
private getBodyParameter;
|
|
18
18
|
private getHeaderParameter;
|
|
19
19
|
private getQueryParameter;
|
|
20
|
+
private isTypeSupportedForQueryParameter;
|
|
20
21
|
private getPathParameter;
|
|
21
22
|
private getParameterDescription;
|
|
22
23
|
private getParameterDeprecation;
|
|
23
|
-
private
|
|
24
|
-
private
|
|
25
|
-
private
|
|
24
|
+
private getParameterExample;
|
|
25
|
+
private isBodySupportedForMethod;
|
|
26
|
+
private isTypeSupported;
|
|
26
27
|
private getValidatedType;
|
|
27
28
|
}
|
|
28
29
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/generator/parameter/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/generator/parameter/module.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAejC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAoBxD,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IAEpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAE9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;gBAGxC,SAAS,EAAE,EAAE,CAAC,oBAAoB,EAClC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB;IAQvB,QAAQ,IAAI,SAAS,EAAE;IAyC9B,OAAO,CAAC,wBAAwB;IAuChC,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,gBAAgB;IA8CxB,OAAO,CAAC,gBAAgB;IAuCxB,OAAO,CAAC,kBAAkB;IAyD1B,OAAO,CAAC,gBAAgB;IA6CxB,OAAO,CAAC,kBAAkB;IAiD1B,OAAO,CAAC,iBAAiB;IAwFzB,OAAO,CAAC,gCAAgC;IAMxC,OAAO,CAAC,gBAAgB;IA+ExB,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,mBAAmB;IAoC3B,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,gBAAgB;CAa3B"}
|