@trapi/metadata 1.0.0-alpha.1 → 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 +49 -57
- 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 +54 -73
- 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 +363 -197
- 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 +47 -36
- package/dist/resolver/module.js.map +1 -1
- package/dist/utils/js-doc/constants.d.ts +19 -0
- package/dist/utils/js-doc/constants.d.ts.map +1 -0
- package/dist/utils/js-doc/constants.js +30 -0
- package/dist/utils/js-doc/constants.js.map +1 -0
- package/dist/utils/js-doc/index.d.ts +4 -0
- package/dist/utils/js-doc/index.d.ts.map +1 -0
- package/dist/utils/js-doc/index.js +26 -0
- package/dist/utils/js-doc/index.js.map +1 -0
- package/dist/utils/js-doc/module.d.ts +9 -0
- package/dist/utils/js-doc/module.d.ts.map +1 -0
- package/dist/utils/{js-doc.js → js-doc/module.js} +11 -14
- package/dist/utils/js-doc/module.js.map +1 -0
- 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
- package/dist/utils/js-doc.d.ts +0 -8
- package/dist/utils/js-doc.d.ts.map +0 -1
- package/dist/utils/js-doc.js.map +0 -1
package/dist/decorator/type.d.ts
CHANGED
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
import type { DecoratorID } from './constants';
|
|
2
2
|
import type { DecoratorClassSetID, DecoratorClassSetProperties, DecoratorMethodSetID, DecoratorMethodSetProperties, DecoratorMixedSetID, DecoratorMixedSetProperties, DecoratorParameterSetID, DecoratorParameterSetProperties, DecoratorRequestSetID, DecoratorRequestSetProperties, DecoratorResponseSetID, DecoratorResponseSetProperties } from './sets';
|
|
3
3
|
export type DecoratorProperties<T extends `${DecoratorID}`> = T extends DecoratorClassSetID ? DecoratorClassSetProperties<T> : T extends DecoratorMethodSetID ? DecoratorMethodSetProperties<T> : T extends DecoratorMixedSetID ? DecoratorMixedSetProperties<T> : T extends DecoratorParameterSetID ? DecoratorParameterSetProperties<T> : T extends DecoratorRequestSetID ? DecoratorRequestSetProperties<T> : T extends DecoratorResponseSetID ? DecoratorResponseSetProperties<T> : never;
|
|
4
|
-
export type DecoratorPropertyStrategy = 'merge' |
|
|
4
|
+
export type DecoratorPropertyStrategy = 'merge' | ((...items: any[]) => any);
|
|
5
5
|
export type DecoratorPropertyConfig = {
|
|
6
|
-
/**
|
|
7
|
-
* Default: 'element'
|
|
8
|
-
*/
|
|
9
|
-
type?: 'element' | 'array';
|
|
10
6
|
/**
|
|
11
7
|
* Default: false
|
|
12
8
|
*/
|
|
13
|
-
isType
|
|
14
|
-
/**
|
|
15
|
-
* Default: 'argument'
|
|
16
|
-
*/
|
|
17
|
-
srcArgumentType?: 'argument' | 'typeArgument';
|
|
9
|
+
isType: boolean;
|
|
18
10
|
/**
|
|
19
11
|
* Default: 0
|
|
20
12
|
*/
|
|
21
|
-
|
|
13
|
+
index: number;
|
|
22
14
|
/**
|
|
23
15
|
* Default: undefined
|
|
24
16
|
*/
|
|
25
|
-
|
|
17
|
+
amount?: number;
|
|
26
18
|
/**
|
|
27
|
-
* Default:
|
|
19
|
+
* Default: undefined
|
|
28
20
|
*/
|
|
29
|
-
|
|
21
|
+
strategy?: DecoratorPropertyStrategy;
|
|
30
22
|
};
|
|
23
|
+
export type DecoratorPropertyConfigInput = Partial<DecoratorPropertyConfig>;
|
|
31
24
|
export type DecoratorPropertiesConfig<P extends Record<string, any>> = {
|
|
32
|
-
[K in keyof P]:
|
|
25
|
+
[K in keyof P]: DecoratorPropertyConfigInput;
|
|
33
26
|
};
|
|
34
27
|
export type DecoratorConfig<T extends `${DecoratorID}` = `${DecoratorID}`> = {
|
|
35
28
|
id: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/decorator/type.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EACR,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,+BAA+B,EAC/B,qBAAqB,EACrB,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,EACjC,MAAM,QAAQ,CAAC;AAEhB,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,GAAG,WAAW,EAAE,IACtD,CAAC,SAAS,mBAAmB,GACzB,2BAA2B,CAAC,CAAC,CAAC,GAC9B,CAAC,SAAS,oBAAoB,GAC1B,4BAA4B,CAAC,CAAC,CAAC,GAC/B,CAAC,SAAS,mBAAmB,GACzB,2BAA2B,CAAC,CAAC,CAAC,GAC9B,CAAC,SAAS,uBAAuB,GAC7B,+BAA+B,CAAC,CAAC,CAAC,GAClC,CAAC,SAAS,qBAAqB,GAC3B,6BAA6B,CAAC,CAAC,CAAC,GAChC,CAAC,SAAS,sBAAsB,GAC5B,8BAA8B,CAAC,CAAC,CAAC,GACjC,KAAK,CAAC;AAElC,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/decorator/type.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EACR,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,E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IACzE,EAAE,EAAE,CAAC,CAAC;IACN,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,yBAAyB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAA;CACjE,CAAC"}
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAOA,cAAc,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAOA,cAAc,QAAQ,CAAC"}
|
package/dist/error/index.js
CHANGED
|
@@ -21,5 +21,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
__exportStar(require("./base"), exports);
|
|
24
|
-
__exportStar(require("./parameter-invalid"), exports);
|
|
25
24
|
//# sourceMappingURL=index.js.map
|
package/dist/error/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,yCAAuB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,yCAAuB"}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import type { Response } from './type';
|
|
1
|
+
import type { Node } from 'typescript';
|
|
2
|
+
import type { Response, Security } from './type';
|
|
4
3
|
import type { MetadataGenerator } from './metadata';
|
|
5
4
|
export declare abstract class AbstractGenerator<T extends Node> {
|
|
6
|
-
protected current: MetadataGenerator;
|
|
7
|
-
protected path: string | undefined;
|
|
8
5
|
protected node: T;
|
|
6
|
+
protected current: MetadataGenerator;
|
|
9
7
|
protected constructor(node: T, current: MetadataGenerator);
|
|
10
|
-
protected
|
|
11
|
-
protected
|
|
12
|
-
protected getSecurity(): {
|
|
13
|
-
name: any;
|
|
14
|
-
scopes: string[];
|
|
15
|
-
}[];
|
|
16
|
-
protected handleRolesArray(argument: ArrayLiteralExpression): string[];
|
|
8
|
+
protected buildPath(): string;
|
|
9
|
+
protected getSecurity(): Security[];
|
|
17
10
|
protected getExamplesValue(argument: any): unknown[];
|
|
18
|
-
protected
|
|
11
|
+
protected buildResponses(): Response[];
|
|
19
12
|
getProduces(): string[];
|
|
20
13
|
getConsumes(): string[];
|
|
21
14
|
getTags(): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../src/generator/abstract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../src/generator/abstract.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,YAAY,CAAC;AAIjD,OAAO,KAAK,EAAW,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAI1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,8BAAsB,iBAAiB,CAAC,CAAC,SAAS,IAAI;IAClD,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAElB,SAAS,CAAC,OAAO,EAAG,iBAAiB,CAAC;IAItC,SAAS,aAAa,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB;IAOzD,SAAS,CAAC,SAAS,IAAK,MAAM;IAc9B,SAAS,CAAC,WAAW,IAAK,QAAQ,EAAE;IAiCpC,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAI,OAAO,EAAE;IAoBrD,SAAS,CAAC,cAAc,IAAI,QAAQ,EAAE;IAsC/B,WAAW,IAAK,MAAM,EAAE;IAcxB,WAAW,IAAK,MAAM,EAAE;IAgBxB,OAAO,IAAK,MAAM,EAAE;IAkB3B,SAAS,CAAC,QAAQ,CAAC,kBAAkB,IAAI,MAAM;IAIxC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAI,OAAO;IAI9B,YAAY,CAAC,IAAI,EAAE,IAAI,GAAI,OAAO;CAO5C"}
|
|
@@ -7,67 +7,53 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.AbstractGenerator = void 0;
|
|
10
|
-
const
|
|
10
|
+
const locter_1 = require("locter");
|
|
11
11
|
const decorator_1 = require("../decorator");
|
|
12
12
|
const resolver_1 = require("../resolver");
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
14
|
class AbstractGenerator {
|
|
15
15
|
// -------------------------------------------
|
|
16
16
|
constructor(node, current) {
|
|
17
|
-
this.current = current;
|
|
18
17
|
this.node = node;
|
|
18
|
+
this.current = current;
|
|
19
19
|
}
|
|
20
20
|
// --------------------------------------------------------------------
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const representation = this.current.decoratorResolver.match(key, this.node);
|
|
21
|
+
buildPath() {
|
|
22
|
+
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.MOUNT, this.node);
|
|
24
23
|
if (typeof representation !== 'undefined') {
|
|
25
|
-
const value = representation.
|
|
26
|
-
if (typeof value
|
|
27
|
-
|
|
24
|
+
const value = representation.get('value');
|
|
25
|
+
if (typeof value === 'string') {
|
|
26
|
+
return (0, utils_1.normalizePath)(value);
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
// --------------------------------------------------------------------
|
|
33
|
-
getDecoratorValues(decoratorName, acceptMultiple = false) {
|
|
34
|
-
const decorators = (0, utils_1.getNodeDecorators)(this.node, (decorator) => decorator.text === decoratorName);
|
|
35
|
-
if (!decorators || !decorators.length) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
if (!acceptMultiple && decorators.length > 1) {
|
|
39
|
-
throw new Error(`Only one ${decoratorName} decorator allowed in ${this.getCurrentLocation()}.`);
|
|
40
|
-
}
|
|
41
|
-
let result;
|
|
42
|
-
if (acceptMultiple) {
|
|
43
|
-
result = decorators.map((d) => d.arguments);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
const d = decorators[0];
|
|
47
|
-
result = d.arguments;
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
29
|
+
return '';
|
|
50
30
|
}
|
|
51
31
|
// -------------------------------------------
|
|
52
32
|
getSecurity() {
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
33
|
+
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.SECURITY, this.node);
|
|
34
|
+
if (typeof representation === 'undefined') {
|
|
35
|
+
return [];
|
|
56
36
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
37
|
+
const securities = [];
|
|
38
|
+
for (let i = 0; i < representation.decorators.length; i++) {
|
|
39
|
+
let name = representation.get('key');
|
|
40
|
+
// todo: check if Record<string, string[]>
|
|
41
|
+
if ((0, locter_1.isObject)(name)) {
|
|
42
|
+
securities.push(name);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
if (typeof name !== 'string' || !name) {
|
|
46
|
+
name = 'default';
|
|
47
|
+
}
|
|
48
|
+
const scopes = representation.get('value');
|
|
49
|
+
if (Array.isArray(scopes)) {
|
|
50
|
+
securities.push({
|
|
51
|
+
[name]: scopes,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
69
55
|
}
|
|
70
|
-
return
|
|
56
|
+
return securities;
|
|
71
57
|
}
|
|
72
58
|
// -------------------------------------------
|
|
73
59
|
getExamplesValue(argument) {
|
|
@@ -86,17 +72,23 @@ class AbstractGenerator {
|
|
|
86
72
|
return example;
|
|
87
73
|
}
|
|
88
74
|
// -------------------------------------------
|
|
89
|
-
|
|
90
|
-
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.
|
|
75
|
+
buildResponses() {
|
|
76
|
+
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.DESCRIPTION, this.node);
|
|
91
77
|
if (typeof representation === 'undefined') {
|
|
92
78
|
return [];
|
|
93
79
|
}
|
|
94
80
|
const responses = [];
|
|
95
81
|
for (let i = 0; i < representation.decorators.length; i++) {
|
|
96
|
-
const description = representation.
|
|
97
|
-
const status = representation.
|
|
98
|
-
const
|
|
99
|
-
const
|
|
82
|
+
const description = representation.get('description', i) || 'Ok';
|
|
83
|
+
const status = representation.get('statusCode', i) || '200';
|
|
84
|
+
const payload = representation.get('payload', i);
|
|
85
|
+
const examples = [];
|
|
86
|
+
if (typeof payload !== 'undefined') {
|
|
87
|
+
examples.push({
|
|
88
|
+
value: payload,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const type = representation.get('type');
|
|
100
92
|
const response = {
|
|
101
93
|
description,
|
|
102
94
|
examples,
|
|
@@ -110,22 +102,22 @@ class AbstractGenerator {
|
|
|
110
102
|
}
|
|
111
103
|
// -------------------------------------------
|
|
112
104
|
getProduces() {
|
|
113
|
-
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.
|
|
105
|
+
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.PRODUCES, this.node);
|
|
114
106
|
if (typeof representation === 'undefined') {
|
|
115
107
|
return [];
|
|
116
108
|
}
|
|
117
|
-
const value = representation.
|
|
109
|
+
const value = representation.get('value');
|
|
118
110
|
if (typeof value === 'undefined') {
|
|
119
111
|
return [];
|
|
120
112
|
}
|
|
121
113
|
return Array.isArray(value) ? value : [value];
|
|
122
114
|
}
|
|
123
115
|
getConsumes() {
|
|
124
|
-
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.
|
|
116
|
+
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.CONSUMES, this.node);
|
|
125
117
|
if (typeof representation === 'undefined') {
|
|
126
118
|
return [];
|
|
127
119
|
}
|
|
128
|
-
let value = representation.
|
|
120
|
+
let value = representation.get('value');
|
|
129
121
|
if (typeof value === 'undefined') {
|
|
130
122
|
return [];
|
|
131
123
|
}
|
|
@@ -133,11 +125,11 @@ class AbstractGenerator {
|
|
|
133
125
|
return value;
|
|
134
126
|
}
|
|
135
127
|
getTags() {
|
|
136
|
-
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.
|
|
128
|
+
const representation = this.current.decoratorResolver.match(decorator_1.DecoratorID.TAGS, this.node);
|
|
137
129
|
if (typeof representation === 'undefined') {
|
|
138
130
|
return [];
|
|
139
131
|
}
|
|
140
|
-
let value = representation.
|
|
132
|
+
let value = representation.get('value');
|
|
141
133
|
if (typeof value === 'undefined') {
|
|
142
134
|
return [];
|
|
143
135
|
}
|
|
@@ -149,7 +141,7 @@ class AbstractGenerator {
|
|
|
149
141
|
return typeof this.current.decoratorResolver.match(decorator_1.DecoratorID.HIDDEN, node) !== 'undefined';
|
|
150
142
|
}
|
|
151
143
|
isDeprecated(node) {
|
|
152
|
-
if ((0, utils_1.
|
|
144
|
+
if ((0, utils_1.hasJSDocTag)(node, utils_1.JSDocTagName.DEPRECATED)) {
|
|
153
145
|
return true;
|
|
154
146
|
}
|
|
155
147
|
return typeof this.current.decoratorResolver.match(decorator_1.DecoratorID.DEPRECATED, node) !== 'undefined';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../src/generator/abstract.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../src/generator/abstract.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAkC;AAElC,4CAA2C;AAC3C,0CAA+C;AAG/C,oCAEkB;AAGl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AI,CAAC,KAAK,WAAW,CAAC;IACjG,CAAC;IAEM,YAAY,CAAC,IAAU;QAC1B,IAAI,IAAA,mBAAW,EAAC,IAAI,EAAE,oBAAY,CAAC,UAAU,CAAC,EAAE;YAC5C,OAAO,IAAI,CAAC;SACf;QAED,OAAO,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,uBAAW,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,WAAW,CAAC;IACrG,CAAC;CACJ;AAtLD,8CAsLC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ClassDeclaration } from 'typescript';
|
|
2
2
|
import { AbstractGenerator } from '../abstract';
|
|
3
|
+
import type { Method } from '../method';
|
|
3
4
|
import type { MetadataGenerator } from '../metadata';
|
|
4
5
|
import type { Controller } from './type';
|
|
5
6
|
export declare class ControllerGenerator extends AbstractGenerator<ClassDeclaration> {
|
|
6
|
-
private genMethods;
|
|
7
7
|
constructor(node: ClassDeclaration, current: MetadataGenerator);
|
|
8
8
|
isValid(): boolean;
|
|
9
9
|
generate(): Controller;
|
|
10
10
|
protected getCurrentLocation(): string;
|
|
11
|
-
|
|
11
|
+
protected buildMethods(controllerPath: string): Method[];
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/generator/controller/module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/generator/controller/module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,qBAAa,mBAAoB,SAAQ,iBAAiB,CAAC,gBAAgB,CAAC;gBAE5D,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB;IAIvD,OAAO,IAAK,OAAO;IASnB,QAAQ,IAAI,UAAU;IAsB7B,SAAS,CAAC,kBAAkB,IAAI,MAAM;IAItC,SAAS,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,GAAI,MAAM,EAAE;CAwB5D"}
|
|
@@ -12,14 +12,13 @@ const decorator_1 = require("../../decorator");
|
|
|
12
12
|
const abstract_1 = require("../abstract");
|
|
13
13
|
const method_1 = require("../method");
|
|
14
14
|
class ControllerGenerator extends abstract_1.AbstractGenerator {
|
|
15
|
-
//
|
|
15
|
+
// eslint-disable-next-line no-useless-constructor,@typescript-eslint/no-useless-constructor
|
|
16
16
|
constructor(node, current) {
|
|
17
17
|
super(node, current);
|
|
18
|
-
this.genMethods = new Set();
|
|
19
|
-
this.generatePath(decorator_1.DecoratorID.CLASS_PATH);
|
|
20
18
|
}
|
|
21
19
|
isValid() {
|
|
22
|
-
|
|
20
|
+
const isController = this.current.decoratorResolver.match(decorator_1.DecoratorID.CONTROLLER, this.node);
|
|
21
|
+
return !!isController;
|
|
23
22
|
}
|
|
24
23
|
generate() {
|
|
25
24
|
if (!this.node.parent) {
|
|
@@ -29,34 +28,40 @@ class ControllerGenerator extends abstract_1.AbstractGenerator {
|
|
|
29
28
|
throw new Error('Controller node doesn\'t have a valid name.');
|
|
30
29
|
}
|
|
31
30
|
const sourceFile = this.node.parent.getSourceFile();
|
|
31
|
+
const path = this.buildPath();
|
|
32
32
|
return {
|
|
33
33
|
consumes: this.getConsumes(),
|
|
34
|
+
hidden: this.isHidden(this.node),
|
|
34
35
|
location: sourceFile.fileName,
|
|
35
|
-
methods: this.buildMethods(),
|
|
36
36
|
name: this.getCurrentLocation(),
|
|
37
|
-
path
|
|
37
|
+
path,
|
|
38
38
|
produces: this.getProduces(),
|
|
39
|
-
responses: this.
|
|
39
|
+
responses: this.buildResponses(),
|
|
40
40
|
security: this.getSecurity(),
|
|
41
41
|
tags: this.getTags(),
|
|
42
|
+
methods: this.buildMethods(path),
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
getCurrentLocation() {
|
|
45
46
|
return this.node.name.text;
|
|
46
47
|
}
|
|
47
|
-
buildMethods() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
this.genMethods.add(generator.getMethodName());
|
|
55
|
-
return true;
|
|
48
|
+
buildMethods(controllerPath) {
|
|
49
|
+
const set = new Set();
|
|
50
|
+
const output = [];
|
|
51
|
+
for (let i = 0; i < this.node.members.length; i++) {
|
|
52
|
+
const node = this.node.members[i];
|
|
53
|
+
if (!(0, typescript_1.isMethodDeclaration)(node) || this.isHidden(node)) {
|
|
54
|
+
continue;
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.
|
|
56
|
+
const generator = new method_1.MethodGenerator(node, this.current);
|
|
57
|
+
const methodName = generator.getMethodName();
|
|
58
|
+
if (set.has(methodName) || !generator.isValid()) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
set.add(methodName);
|
|
62
|
+
output.push(generator.generate(controllerPath));
|
|
63
|
+
}
|
|
64
|
+
return output;
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
exports.ControllerGenerator = ControllerGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/generator/controller/module.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/generator/controller/module.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,2CAAiD;AACjD,+CAA8C;AAC9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I,CAAC,IAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;IACrD,CAAC;IAES,YAAY,CAAC,cAAsB;QACzC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;QAC9B,MAAM,MAAM,GAAc,EAAE,CAAC;QAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAElC,IAAI,CAAC,IAAA,gCAAmB,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACnD,SAAS;aACZ;YAED,MAAM,SAAS,GAAG,IAAI,wBAAe,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1D,MAAM,UAAU,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC;YAC7C,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE;gBAC7C,SAAS;aACZ;YAED,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAEpB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;SACnD;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAjED,kDAiEC"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import type { Response, Security } from '../type';
|
|
2
2
|
import type { Method } from '../method';
|
|
3
3
|
export interface Controller {
|
|
4
|
+
/**
|
|
5
|
+
* Allowed Content-Types to pass
|
|
6
|
+
* data according the definition.
|
|
7
|
+
*
|
|
8
|
+
* i.e. ['application/json']
|
|
9
|
+
*/
|
|
10
|
+
consumes: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Is controller hidden, and should
|
|
13
|
+
* not be used/displayed in some scenarios.
|
|
14
|
+
*/
|
|
15
|
+
hidden: boolean;
|
|
4
16
|
/**
|
|
5
17
|
* File Location of the Controller.
|
|
6
18
|
*/
|
|
@@ -15,13 +27,6 @@ export interface Controller {
|
|
|
15
27
|
* The relative URL Path, i.e /users
|
|
16
28
|
*/
|
|
17
29
|
path: string;
|
|
18
|
-
/**
|
|
19
|
-
* Allowed Content-Types to pass
|
|
20
|
-
* data according the definition.
|
|
21
|
-
*
|
|
22
|
-
* i.e. ['application/json']
|
|
23
|
-
*/
|
|
24
|
-
consumes: string[];
|
|
25
30
|
/**
|
|
26
31
|
* Possible Content-Types to receive
|
|
27
32
|
* data according the definition.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/generator/controller/type.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,WAAW,UAAU;IACvB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/generator/controller/type.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,WAAW,UAAU;IACvB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB;;;;;OAKG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generator/metadata/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generator/metadata/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
@@ -22,4 +22,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
__exportStar(require("./module"), exports);
|
|
24
24
|
__exportStar(require("./type"), exports);
|
|
25
|
+
__exportStar(require("./utils"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generator/metadata/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,yCAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generator/metadata/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,yCAAuB;AACvB,0CAAwB"}
|
|
@@ -34,8 +34,6 @@ export declare class MetadataGenerator {
|
|
|
34
34
|
addReferenceType(referenceType: ReferenceType): void;
|
|
35
35
|
getReferenceType(refName: string): ReferenceType;
|
|
36
36
|
registerDependencyResolver(callback: DependencyResolver): void;
|
|
37
|
-
getClassDeclaration(className: string): Node;
|
|
38
|
-
getInterfaceDeclaration(className: string): Node;
|
|
39
37
|
private buildControllers;
|
|
40
38
|
}
|
|
41
39
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/generator/metadata/module.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/generator/metadata/module.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,IAAI,EAAuB,WAAW,EACzC,MAAM,YAAY,CAAC;AAKpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;AAIxF,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAEjE,qBAAa,iBAAiB;IAC1B,SAAgB,KAAK,EAAG,IAAI,EAAE,CAAC;IAE/B,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC,SAAgB,iBAAiB,EAAE,iBAAiB,CAAC;IAErD,SAAgB,MAAM,EAAE,OAAO,CAAC;IAEhC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAElC,OAAO,CAAC,KAAK,CAAe;IAE5B,OAAO,CAAC,WAAW,CAAe;IAElC,OAAO,CAAC,cAAc,CAAsB;IAE5C,OAAO,CAAC,2BAA2B,CAAmC;gBAI1D,OAAO,EAAE,wBAAwB;IAkBvC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IAiCnC,SAAS,CAAC,yBAAyB,IAAK,MAAM;IAuC9C;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAI,OAAO;IAQnD;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM;IAUjC,cAAc,CAAC,IAAI,EAAE,IAAI;IAMzB,gBAAgB,CAAC,aAAa,EAAE,aAAa;IAQ7C,gBAAgB,CAAC,OAAO,EAAE,MAAM;IAIhC,0BAA0B,CAAC,QAAQ,EAAE,kBAAkB;IAI9D,OAAO,CAAC,gBAAgB;CAiB3B"}
|
|
@@ -12,10 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.MetadataGenerator = void 0;
|
|
13
13
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
14
14
|
const typescript_1 = require("typescript");
|
|
15
|
+
const cache_1 = require("../../cache");
|
|
15
16
|
const decorator_1 = require("../../decorator");
|
|
16
17
|
const resolver_1 = require("../../resolver");
|
|
17
18
|
const controller_1 = require("../controller");
|
|
18
|
-
const cache_1 = require("../../cache");
|
|
19
19
|
class MetadataGenerator {
|
|
20
20
|
// -------------------------------------------------------------------------
|
|
21
21
|
constructor(context) {
|
|
@@ -124,39 +124,19 @@ class MetadataGenerator {
|
|
|
124
124
|
registerDependencyResolver(callback) {
|
|
125
125
|
this.circularDependencyResolvers.push(callback);
|
|
126
126
|
}
|
|
127
|
-
getClassDeclaration(className) {
|
|
128
|
-
const found = this.nodes
|
|
129
|
-
.filter((node) => {
|
|
130
|
-
const classDeclaration = node;
|
|
131
|
-
return (node.kind === typescript_1.SyntaxKind.ClassDeclaration && classDeclaration.name && classDeclaration.name.text === className);
|
|
132
|
-
});
|
|
133
|
-
if (found && found.length) {
|
|
134
|
-
return found[0];
|
|
135
|
-
}
|
|
136
|
-
return undefined;
|
|
137
|
-
}
|
|
138
|
-
getInterfaceDeclaration(className) {
|
|
139
|
-
const found = this.nodes
|
|
140
|
-
.filter((node) => {
|
|
141
|
-
const interfaceDeclaration = node;
|
|
142
|
-
return (node.kind === typescript_1.SyntaxKind.InterfaceDeclaration && interfaceDeclaration.name && interfaceDeclaration.name.text === className);
|
|
143
|
-
});
|
|
144
|
-
if (found && found.length) {
|
|
145
|
-
return found[0];
|
|
146
|
-
}
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
127
|
buildControllers() {
|
|
150
|
-
this.controllers =
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
128
|
+
this.controllers = [];
|
|
129
|
+
for (let i = 0; i < this.nodes.length; i++) {
|
|
130
|
+
const node = this.nodes[i];
|
|
131
|
+
if (!(0, typescript_1.isClassDeclaration)(node)) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const generator = new controller_1.ControllerGenerator(node, this);
|
|
135
|
+
if (!generator.isValid()) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
this.controllers.push(generator.generate());
|
|
139
|
+
}
|
|
160
140
|
}
|
|
161
141
|
}
|
|
162
142
|
exports.MetadataGenerator = MetadataGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/generator/metadata/module.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,0DAAkC;
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/generator/metadata/module.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,0DAAkC;AAIlC,2CAEoB;AACpB,uCAA0C;AAE1C,+CAAoD;AAEpD,6CAAkD;AAElD,8CAAoD;AAGpD,MAAa,iBAAiB;IAmB1B,4EAA4E;IAE5E,YAAY,OAAiC;QANrC,mBAAc,GAAmB,EAAE,CAAC;QAEpC,gCAA2B,GAAG,IAAI,KAAK,EAAsB,CAAC;QAKlE,IAAI,CAAC,KAAK,GAAG,EAA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