typia 7.0.0-dev.20241010 → 7.0.0-dev.20241011
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/index.mjs +7 -0
- package/lib/index.mjs.map +1 -1
- package/lib/internal/$httpParameterReadBigint.d.ts +1 -0
- package/lib/internal/{$httpParameterBigint.js → $httpParameterReadBigint.js} +4 -4
- package/lib/internal/$httpParameterReadBigint.js.map +1 -0
- package/lib/internal/$httpParameterReadBoolean.d.ts +1 -0
- package/lib/internal/{$httpParameterBoolean.js → $httpParameterReadBoolean.js} +4 -4
- package/lib/internal/$httpParameterReadBoolean.js.map +1 -0
- package/lib/internal/$httpParameterReadNumber.d.ts +1 -0
- package/lib/internal/{$httpParameterNumber.js → $httpParameterReadNumber.js} +4 -4
- package/lib/internal/$httpParameterReadNumber.js.map +1 -0
- package/lib/internal/$httpParameterReadString.d.ts +1 -0
- package/lib/internal/$httpParameterReadString.js +8 -0
- package/lib/internal/$httpParameterReadString.js.map +1 -0
- package/lib/json.d.ts +47 -13
- package/lib/json.js +7 -0
- package/lib/json.js.map +1 -1
- package/lib/module.d.ts +1 -0
- package/lib/module.js +1 -0
- package/lib/module.js.map +1 -1
- package/lib/programmers/json/JsonApplicationProgrammer.d.ts +6 -2
- package/lib/programmers/json/JsonApplicationProgrammer.js +200 -75
- package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonSchemasProgrammer.d.ts +6 -0
- package/lib/programmers/json/JsonSchemasProgrammer.js +109 -0
- package/lib/programmers/json/JsonSchemasProgrammer.js.map +1 -0
- package/lib/programmers/llm/LlmApplicationProgrammer.d.ts +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js +57 -39
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/schemas/json/IJsonApplication.d.ts +31 -12
- package/lib/schemas/json/IJsonSchemaList.d.ts +16 -0
- package/lib/schemas/json/IJsonSchemaList.js +3 -0
- package/lib/schemas/json/IJsonSchemaList.js.map +1 -0
- package/lib/transformers/CallExpressionTransformer.js +3 -1
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/json/JsonApplicationTransformer.d.ts +1 -1
- package/lib/transformers/features/json/JsonApplicationTransformer.js +27 -97
- package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/json/JsonSchemasTransformer.d.ts +5 -0
- package/lib/transformers/features/json/JsonSchemasTransformer.js +159 -0
- package/lib/transformers/features/json/JsonSchemasTransformer.js.map +1 -0
- package/lib/transformers/features/llm/LlmApplicationTransformer.js +1 -1
- package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
- package/package.json +1 -1
- package/src/factories/MetadataFactory.ts +400 -400
- package/src/factories/internal/metadata/IMetadataIteratorProps.ts +16 -16
- package/src/factories/internal/metadata/emplace_metadata_object.ts +206 -206
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +145 -145
- package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +32 -32
- package/src/factories/internal/metadata/iterate_metadata_function.ts +88 -88
- package/src/internal/{$httpParameterBigint.ts → $httpParameterReadBigint.ts} +1 -1
- package/src/internal/{$httpParameterBoolean.ts → $httpParameterReadBoolean.ts} +1 -1
- package/src/internal/{$httpParameterNumber.ts → $httpParameterReadNumber.ts} +1 -1
- package/src/internal/$httpParameterReadString.ts +2 -0
- package/src/json.ts +63 -17
- package/src/module.ts +1 -0
- package/src/programmers/json/JsonApplicationProgrammer.ts +249 -72
- package/src/programmers/json/JsonSchemasProgrammer.ts +94 -0
- package/src/programmers/llm/LlmApplicationProgrammer.ts +66 -41
- package/src/schemas/json/IJsonApplication.ts +61 -22
- package/src/schemas/json/IJsonSchemaList.ts +22 -0
- package/src/transformers/CallExpressionTransformer.ts +3 -1
- package/src/transformers/features/json/JsonApplicationTransformer.ts +29 -54
- package/src/transformers/features/json/JsonSchemasTransformer.ts +130 -0
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +1 -1
- package/lib/internal/$httpParameterBigint.d.ts +0 -1
- package/lib/internal/$httpParameterBigint.js.map +0 -1
- package/lib/internal/$httpParameterBoolean.d.ts +0 -1
- package/lib/internal/$httpParameterBoolean.js.map +0 -1
- package/lib/internal/$httpParameterNumber.d.ts +0 -1
- package/lib/internal/$httpParameterNumber.js.map +0 -1
- package/lib/internal/$httpParameterString.d.ts +0 -1
- package/lib/internal/$httpParameterString.js +0 -8
- package/lib/internal/$httpParameterString.js.map +0 -1
- package/src/internal/$httpParameterString.ts +0 -2
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
2
|
-
import { MetadataArrayType } from "../../../schemas/metadata/MetadataArrayType";
|
|
3
|
-
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
4
|
-
import { MetadataTupleType } from "../../../schemas/metadata/MetadataTupleType";
|
|
5
|
-
|
|
6
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
7
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
8
|
-
import { iterate_metadata_comment_tags } from "./iterate_metadata_comment_tags";
|
|
9
|
-
|
|
10
|
-
export const iterate_metadata_collection = (props: {
|
|
11
|
-
errors: MetadataFactory.IError[];
|
|
12
|
-
collection: MetadataCollection;
|
|
13
|
-
}): void => {
|
|
14
|
-
for (const array of props.collection.arrays())
|
|
15
|
-
if (array.recursive === null)
|
|
16
|
-
props.collection.setArrayRecursive(
|
|
17
|
-
array,
|
|
18
|
-
isArrayRecursive({
|
|
19
|
-
visited: new Set(),
|
|
20
|
-
array,
|
|
21
|
-
metadata: array.value,
|
|
22
|
-
}),
|
|
23
|
-
);
|
|
24
|
-
for (const tuple of props.collection.tuples())
|
|
25
|
-
if (tuple.recursive === null) {
|
|
26
|
-
const visited: Set<Metadata> = new Set();
|
|
27
|
-
props.collection.setTupleRecursive(
|
|
28
|
-
tuple,
|
|
29
|
-
tuple.elements.some((e) =>
|
|
30
|
-
isTupleRecursive({
|
|
31
|
-
visited,
|
|
32
|
-
tuple,
|
|
33
|
-
metadata: e,
|
|
34
|
-
}),
|
|
35
|
-
),
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
for (const object of props.collection.objects()) {
|
|
39
|
-
iterate_metadata_comment_tags({
|
|
40
|
-
errors: props.errors,
|
|
41
|
-
object,
|
|
42
|
-
});
|
|
43
|
-
if (object.recursive === null) {
|
|
44
|
-
const visited: Set<Metadata> = new Set();
|
|
45
|
-
props.collection.setObjectRecursive(
|
|
46
|
-
object,
|
|
47
|
-
object.properties.some((p) =>
|
|
48
|
-
isObjectRecursive({
|
|
49
|
-
visited,
|
|
50
|
-
object,
|
|
51
|
-
metadata: p.value,
|
|
52
|
-
}),
|
|
53
|
-
),
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const isArrayRecursive = (props: {
|
|
60
|
-
visited: Set<Metadata>;
|
|
61
|
-
array: MetadataArrayType;
|
|
62
|
-
metadata: Metadata;
|
|
63
|
-
}): boolean => {
|
|
64
|
-
if (props.visited.has(props.metadata)) return false;
|
|
65
|
-
props.visited.add(props.metadata);
|
|
66
|
-
|
|
67
|
-
const next = (metadata: Metadata): boolean =>
|
|
68
|
-
isArrayRecursive({
|
|
69
|
-
...props,
|
|
70
|
-
metadata,
|
|
71
|
-
});
|
|
72
|
-
return (
|
|
73
|
-
props.metadata.arrays.some(
|
|
74
|
-
(a) => a.type === props.array || next(a.type.value),
|
|
75
|
-
) ||
|
|
76
|
-
props.metadata.aliases.some((alias) => next(alias.value)) ||
|
|
77
|
-
props.metadata.tuples.some(
|
|
78
|
-
(t) => !t.type.recursive && t.type.elements.some(next),
|
|
79
|
-
) ||
|
|
80
|
-
props.metadata.maps.some((m) => next(m.value)) ||
|
|
81
|
-
props.metadata.sets.some(next) ||
|
|
82
|
-
(props.metadata.escaped !== null && next(props.metadata.escaped.returns)) ||
|
|
83
|
-
(props.metadata.rest !== null && next(props.metadata.rest))
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const isTupleRecursive = (props: {
|
|
88
|
-
visited: Set<Metadata>;
|
|
89
|
-
tuple: MetadataTupleType;
|
|
90
|
-
metadata: Metadata;
|
|
91
|
-
}): boolean => {
|
|
92
|
-
if (props.visited.has(props.metadata)) return false;
|
|
93
|
-
props.visited.add(props.metadata);
|
|
94
|
-
|
|
95
|
-
const next = (metadata: Metadata): boolean =>
|
|
96
|
-
isTupleRecursive({
|
|
97
|
-
...props,
|
|
98
|
-
metadata,
|
|
99
|
-
});
|
|
100
|
-
return (
|
|
101
|
-
props.metadata.tuples.some(
|
|
102
|
-
(t) => t.type === props.tuple || t.type.elements.some(next),
|
|
103
|
-
) ||
|
|
104
|
-
props.metadata.arrays.some(
|
|
105
|
-
(a) => !a.type.recursive && next(a.type.value),
|
|
106
|
-
) ||
|
|
107
|
-
props.metadata.maps.some((m) => next(m.value)) ||
|
|
108
|
-
props.metadata.sets.some((s) => next(s)) ||
|
|
109
|
-
props.metadata.aliases.some((alias) => next(alias.value)) ||
|
|
110
|
-
(props.metadata.escaped !== null && next(props.metadata.escaped.returns)) ||
|
|
111
|
-
(props.metadata.rest !== null && next(props.metadata.rest))
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const isObjectRecursive = (props: {
|
|
116
|
-
visited: Set<Metadata>;
|
|
117
|
-
object: MetadataObject;
|
|
118
|
-
metadata: Metadata;
|
|
119
|
-
}): boolean => {
|
|
120
|
-
if (props.visited.has(props.metadata)) return false;
|
|
121
|
-
props.visited.add(props.metadata);
|
|
122
|
-
|
|
123
|
-
const next = (metadata: Metadata): boolean =>
|
|
124
|
-
isObjectRecursive({
|
|
125
|
-
...props,
|
|
126
|
-
metadata,
|
|
127
|
-
});
|
|
128
|
-
return (
|
|
129
|
-
props.metadata.objects.some(
|
|
130
|
-
(o) =>
|
|
131
|
-
props.object === o || o.properties.some((prop) => next(prop.value)),
|
|
132
|
-
) ||
|
|
133
|
-
props.metadata.aliases.some((alias) => next(alias.value)) ||
|
|
134
|
-
props.metadata.arrays.some(
|
|
135
|
-
(array) => !array.type.recursive && next(array.type.value),
|
|
136
|
-
) ||
|
|
137
|
-
props.metadata.tuples.some(
|
|
138
|
-
(tuple) => !tuple.type.recursive && tuple.type.elements.some(next),
|
|
139
|
-
) ||
|
|
140
|
-
props.metadata.maps.some((map) => next(map.value)) ||
|
|
141
|
-
props.metadata.sets.some(next) ||
|
|
142
|
-
(props.metadata.escaped !== null && next(props.metadata.escaped.returns)) ||
|
|
143
|
-
(props.metadata.rest !== null && next(props.metadata.rest))
|
|
144
|
-
);
|
|
145
|
-
};
|
|
1
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
2
|
+
import { MetadataArrayType } from "../../../schemas/metadata/MetadataArrayType";
|
|
3
|
+
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
4
|
+
import { MetadataTupleType } from "../../../schemas/metadata/MetadataTupleType";
|
|
5
|
+
|
|
6
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
7
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
8
|
+
import { iterate_metadata_comment_tags } from "./iterate_metadata_comment_tags";
|
|
9
|
+
|
|
10
|
+
export const iterate_metadata_collection = (props: {
|
|
11
|
+
errors: MetadataFactory.IError[];
|
|
12
|
+
collection: MetadataCollection;
|
|
13
|
+
}): void => {
|
|
14
|
+
for (const array of props.collection.arrays())
|
|
15
|
+
if (array.recursive === null)
|
|
16
|
+
props.collection.setArrayRecursive(
|
|
17
|
+
array,
|
|
18
|
+
isArrayRecursive({
|
|
19
|
+
visited: new Set(),
|
|
20
|
+
array,
|
|
21
|
+
metadata: array.value,
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
for (const tuple of props.collection.tuples())
|
|
25
|
+
if (tuple.recursive === null) {
|
|
26
|
+
const visited: Set<Metadata> = new Set();
|
|
27
|
+
props.collection.setTupleRecursive(
|
|
28
|
+
tuple,
|
|
29
|
+
tuple.elements.some((e) =>
|
|
30
|
+
isTupleRecursive({
|
|
31
|
+
visited,
|
|
32
|
+
tuple,
|
|
33
|
+
metadata: e,
|
|
34
|
+
}),
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
for (const object of props.collection.objects()) {
|
|
39
|
+
iterate_metadata_comment_tags({
|
|
40
|
+
errors: props.errors,
|
|
41
|
+
object,
|
|
42
|
+
});
|
|
43
|
+
if (object.recursive === null) {
|
|
44
|
+
const visited: Set<Metadata> = new Set();
|
|
45
|
+
props.collection.setObjectRecursive(
|
|
46
|
+
object,
|
|
47
|
+
object.properties.some((p) =>
|
|
48
|
+
isObjectRecursive({
|
|
49
|
+
visited,
|
|
50
|
+
object,
|
|
51
|
+
metadata: p.value,
|
|
52
|
+
}),
|
|
53
|
+
),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const isArrayRecursive = (props: {
|
|
60
|
+
visited: Set<Metadata>;
|
|
61
|
+
array: MetadataArrayType;
|
|
62
|
+
metadata: Metadata;
|
|
63
|
+
}): boolean => {
|
|
64
|
+
if (props.visited.has(props.metadata)) return false;
|
|
65
|
+
props.visited.add(props.metadata);
|
|
66
|
+
|
|
67
|
+
const next = (metadata: Metadata): boolean =>
|
|
68
|
+
isArrayRecursive({
|
|
69
|
+
...props,
|
|
70
|
+
metadata,
|
|
71
|
+
});
|
|
72
|
+
return (
|
|
73
|
+
props.metadata.arrays.some(
|
|
74
|
+
(a) => a.type === props.array || next(a.type.value),
|
|
75
|
+
) ||
|
|
76
|
+
props.metadata.aliases.some((alias) => next(alias.value)) ||
|
|
77
|
+
props.metadata.tuples.some(
|
|
78
|
+
(t) => !t.type.recursive && t.type.elements.some(next),
|
|
79
|
+
) ||
|
|
80
|
+
props.metadata.maps.some((m) => next(m.value)) ||
|
|
81
|
+
props.metadata.sets.some(next) ||
|
|
82
|
+
(props.metadata.escaped !== null && next(props.metadata.escaped.returns)) ||
|
|
83
|
+
(props.metadata.rest !== null && next(props.metadata.rest))
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const isTupleRecursive = (props: {
|
|
88
|
+
visited: Set<Metadata>;
|
|
89
|
+
tuple: MetadataTupleType;
|
|
90
|
+
metadata: Metadata;
|
|
91
|
+
}): boolean => {
|
|
92
|
+
if (props.visited.has(props.metadata)) return false;
|
|
93
|
+
props.visited.add(props.metadata);
|
|
94
|
+
|
|
95
|
+
const next = (metadata: Metadata): boolean =>
|
|
96
|
+
isTupleRecursive({
|
|
97
|
+
...props,
|
|
98
|
+
metadata,
|
|
99
|
+
});
|
|
100
|
+
return (
|
|
101
|
+
props.metadata.tuples.some(
|
|
102
|
+
(t) => t.type === props.tuple || t.type.elements.some(next),
|
|
103
|
+
) ||
|
|
104
|
+
props.metadata.arrays.some(
|
|
105
|
+
(a) => !a.type.recursive && next(a.type.value),
|
|
106
|
+
) ||
|
|
107
|
+
props.metadata.maps.some((m) => next(m.value)) ||
|
|
108
|
+
props.metadata.sets.some((s) => next(s)) ||
|
|
109
|
+
props.metadata.aliases.some((alias) => next(alias.value)) ||
|
|
110
|
+
(props.metadata.escaped !== null && next(props.metadata.escaped.returns)) ||
|
|
111
|
+
(props.metadata.rest !== null && next(props.metadata.rest))
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const isObjectRecursive = (props: {
|
|
116
|
+
visited: Set<Metadata>;
|
|
117
|
+
object: MetadataObject;
|
|
118
|
+
metadata: Metadata;
|
|
119
|
+
}): boolean => {
|
|
120
|
+
if (props.visited.has(props.metadata)) return false;
|
|
121
|
+
props.visited.add(props.metadata);
|
|
122
|
+
|
|
123
|
+
const next = (metadata: Metadata): boolean =>
|
|
124
|
+
isObjectRecursive({
|
|
125
|
+
...props,
|
|
126
|
+
metadata,
|
|
127
|
+
});
|
|
128
|
+
return (
|
|
129
|
+
props.metadata.objects.some(
|
|
130
|
+
(o) =>
|
|
131
|
+
props.object === o || o.properties.some((prop) => next(prop.value)),
|
|
132
|
+
) ||
|
|
133
|
+
props.metadata.aliases.some((alias) => next(alias.value)) ||
|
|
134
|
+
props.metadata.arrays.some(
|
|
135
|
+
(array) => !array.type.recursive && next(array.type.value),
|
|
136
|
+
) ||
|
|
137
|
+
props.metadata.tuples.some(
|
|
138
|
+
(tuple) => !tuple.type.recursive && tuple.type.elements.some(next),
|
|
139
|
+
) ||
|
|
140
|
+
props.metadata.maps.some((map) => next(map.value)) ||
|
|
141
|
+
props.metadata.sets.some(next) ||
|
|
142
|
+
(props.metadata.escaped !== null && next(props.metadata.escaped.returns)) ||
|
|
143
|
+
(props.metadata.rest !== null && next(props.metadata.rest))
|
|
144
|
+
);
|
|
145
|
+
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
2
|
-
|
|
3
|
-
import { MetadataCommentTagFactory } from "../../MetadataCommentTagFactory";
|
|
4
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
5
|
-
|
|
6
|
-
export const iterate_metadata_comment_tags = (props: {
|
|
7
|
-
errors: MetadataFactory.IError[];
|
|
8
|
-
object: MetadataObject;
|
|
9
|
-
}) => {
|
|
10
|
-
if (props.object.tagged_ === true) return;
|
|
11
|
-
props.object.tagged_ = true;
|
|
12
|
-
|
|
13
|
-
for (const property of props.object.properties) {
|
|
14
|
-
MetadataCommentTagFactory.analyze({
|
|
15
|
-
errors: props.errors,
|
|
16
|
-
metadata: property.value,
|
|
17
|
-
tags: property.jsDocTags,
|
|
18
|
-
explore: {
|
|
19
|
-
top: false,
|
|
20
|
-
object: props.object,
|
|
21
|
-
property: property.key.isSoleLiteral()
|
|
22
|
-
? property.key.getSoleLiteral()!
|
|
23
|
-
: {},
|
|
24
|
-
parameter: null,
|
|
25
|
-
nested: null,
|
|
26
|
-
aliased: false,
|
|
27
|
-
escaped: false,
|
|
28
|
-
output: false,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
1
|
+
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
2
|
+
|
|
3
|
+
import { MetadataCommentTagFactory } from "../../MetadataCommentTagFactory";
|
|
4
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
5
|
+
|
|
6
|
+
export const iterate_metadata_comment_tags = (props: {
|
|
7
|
+
errors: MetadataFactory.IError[];
|
|
8
|
+
object: MetadataObject;
|
|
9
|
+
}) => {
|
|
10
|
+
if (props.object.tagged_ === true) return;
|
|
11
|
+
props.object.tagged_ = true;
|
|
12
|
+
|
|
13
|
+
for (const property of props.object.properties) {
|
|
14
|
+
MetadataCommentTagFactory.analyze({
|
|
15
|
+
errors: props.errors,
|
|
16
|
+
metadata: property.value,
|
|
17
|
+
tags: property.jsDocTags,
|
|
18
|
+
explore: {
|
|
19
|
+
top: false,
|
|
20
|
+
object: props.object,
|
|
21
|
+
property: property.key.isSoleLiteral()
|
|
22
|
+
? property.key.getSoleLiteral()!
|
|
23
|
+
: {},
|
|
24
|
+
parameter: null,
|
|
25
|
+
nested: null,
|
|
26
|
+
aliased: false,
|
|
27
|
+
escaped: false,
|
|
28
|
+
output: false,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { FunctionalGeneralProgrammer } from "../../../programmers/functional/internal/FunctionalGeneralProgrammer";
|
|
4
|
-
|
|
5
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
6
|
-
import { MetadataFunction } from "../../../schemas/metadata/MetadataFunction";
|
|
7
|
-
import { MetadataParameter } from "../../../schemas/metadata/MetadataParameter";
|
|
8
|
-
|
|
9
|
-
import { CommentFactory } from "../../CommentFactory";
|
|
10
|
-
import { TypeFactory } from "../../TypeFactory";
|
|
11
|
-
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
12
|
-
import { explore_metadata } from "./explore_metadata";
|
|
13
|
-
|
|
14
|
-
export const iterate_metadata_function = (
|
|
15
|
-
props: IMetadataIteratorProps,
|
|
16
|
-
): boolean => {
|
|
17
|
-
const declaration: ts.SignatureDeclaration | null = TypeFactory.getFunction(
|
|
18
|
-
props.type,
|
|
19
|
-
);
|
|
20
|
-
if (declaration === null) return false;
|
|
21
|
-
else if (!props.options.functional) {
|
|
22
|
-
if (props.metadata.functions.length === 0)
|
|
23
|
-
props.metadata.functions.push(
|
|
24
|
-
MetadataFunction.create({
|
|
25
|
-
parameters: [],
|
|
26
|
-
output: Metadata.initialize(),
|
|
27
|
-
async: false,
|
|
28
|
-
}),
|
|
29
|
-
);
|
|
30
|
-
} else {
|
|
31
|
-
const [signature] = props.type.getCallSignatures();
|
|
32
|
-
if (signature === undefined || signature.declaration === undefined)
|
|
33
|
-
props.metadata.functions.push(
|
|
34
|
-
MetadataFunction.create({
|
|
35
|
-
parameters: [],
|
|
36
|
-
output: Metadata.initialize(),
|
|
37
|
-
async: false,
|
|
38
|
-
}),
|
|
39
|
-
);
|
|
40
|
-
else {
|
|
41
|
-
const { async }: FunctionalGeneralProgrammer.IOutput =
|
|
42
|
-
FunctionalGeneralProgrammer.getReturnType({
|
|
43
|
-
checker: props.checker,
|
|
44
|
-
declaration,
|
|
45
|
-
});
|
|
46
|
-
props.metadata.functions.push(
|
|
47
|
-
MetadataFunction.create({
|
|
48
|
-
parameters: signature.parameters.map((p) =>
|
|
49
|
-
MetadataParameter.create({
|
|
50
|
-
name: p.name,
|
|
51
|
-
type: explore_metadata({
|
|
52
|
-
...props,
|
|
53
|
-
type: props.checker.getTypeOfSymbol(p),
|
|
54
|
-
explore: {
|
|
55
|
-
...props.explore,
|
|
56
|
-
top: false,
|
|
57
|
-
parameter: p.name,
|
|
58
|
-
},
|
|
59
|
-
}),
|
|
60
|
-
description: CommentFactory.description(p) ?? null,
|
|
61
|
-
jsDocTags: p?.getJsDocTags() ?? [],
|
|
62
|
-
}),
|
|
63
|
-
),
|
|
64
|
-
async,
|
|
65
|
-
output: explore_metadata({
|
|
66
|
-
...props,
|
|
67
|
-
options: {
|
|
68
|
-
...props.options,
|
|
69
|
-
functional: false,
|
|
70
|
-
},
|
|
71
|
-
type: async
|
|
72
|
-
? (props.checker.getTypeArguments(
|
|
73
|
-
signature.getReturnType() as ts.TypeReference,
|
|
74
|
-
)?.[0] ??
|
|
75
|
-
props.checker.getTypeFromTypeNode(TypeFactory.keyword("any")))
|
|
76
|
-
: signature.getReturnType(),
|
|
77
|
-
explore: {
|
|
78
|
-
...props.explore,
|
|
79
|
-
top: false,
|
|
80
|
-
output: true,
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
}),
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { FunctionalGeneralProgrammer } from "../../../programmers/functional/internal/FunctionalGeneralProgrammer";
|
|
4
|
+
|
|
5
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
6
|
+
import { MetadataFunction } from "../../../schemas/metadata/MetadataFunction";
|
|
7
|
+
import { MetadataParameter } from "../../../schemas/metadata/MetadataParameter";
|
|
8
|
+
|
|
9
|
+
import { CommentFactory } from "../../CommentFactory";
|
|
10
|
+
import { TypeFactory } from "../../TypeFactory";
|
|
11
|
+
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
12
|
+
import { explore_metadata } from "./explore_metadata";
|
|
13
|
+
|
|
14
|
+
export const iterate_metadata_function = (
|
|
15
|
+
props: IMetadataIteratorProps,
|
|
16
|
+
): boolean => {
|
|
17
|
+
const declaration: ts.SignatureDeclaration | null = TypeFactory.getFunction(
|
|
18
|
+
props.type,
|
|
19
|
+
);
|
|
20
|
+
if (declaration === null) return false;
|
|
21
|
+
else if (!props.options.functional) {
|
|
22
|
+
if (props.metadata.functions.length === 0)
|
|
23
|
+
props.metadata.functions.push(
|
|
24
|
+
MetadataFunction.create({
|
|
25
|
+
parameters: [],
|
|
26
|
+
output: Metadata.initialize(),
|
|
27
|
+
async: false,
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
} else {
|
|
31
|
+
const [signature] = props.type.getCallSignatures();
|
|
32
|
+
if (signature === undefined || signature.declaration === undefined)
|
|
33
|
+
props.metadata.functions.push(
|
|
34
|
+
MetadataFunction.create({
|
|
35
|
+
parameters: [],
|
|
36
|
+
output: Metadata.initialize(),
|
|
37
|
+
async: false,
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
40
|
+
else {
|
|
41
|
+
const { async }: FunctionalGeneralProgrammer.IOutput =
|
|
42
|
+
FunctionalGeneralProgrammer.getReturnType({
|
|
43
|
+
checker: props.checker,
|
|
44
|
+
declaration,
|
|
45
|
+
});
|
|
46
|
+
props.metadata.functions.push(
|
|
47
|
+
MetadataFunction.create({
|
|
48
|
+
parameters: signature.parameters.map((p) =>
|
|
49
|
+
MetadataParameter.create({
|
|
50
|
+
name: p.name,
|
|
51
|
+
type: explore_metadata({
|
|
52
|
+
...props,
|
|
53
|
+
type: props.checker.getTypeOfSymbol(p),
|
|
54
|
+
explore: {
|
|
55
|
+
...props.explore,
|
|
56
|
+
top: false,
|
|
57
|
+
parameter: p.name,
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
description: CommentFactory.description(p) ?? null,
|
|
61
|
+
jsDocTags: p?.getJsDocTags() ?? [],
|
|
62
|
+
}),
|
|
63
|
+
),
|
|
64
|
+
async,
|
|
65
|
+
output: explore_metadata({
|
|
66
|
+
...props,
|
|
67
|
+
options: {
|
|
68
|
+
...props.options,
|
|
69
|
+
functional: false,
|
|
70
|
+
},
|
|
71
|
+
type: async
|
|
72
|
+
? (props.checker.getTypeArguments(
|
|
73
|
+
signature.getReturnType() as ts.TypeReference,
|
|
74
|
+
)?.[0] ??
|
|
75
|
+
props.checker.getTypeFromTypeNode(TypeFactory.keyword("any")))
|
|
76
|
+
: signature.getReturnType(),
|
|
77
|
+
explore: {
|
|
78
|
+
...props.explore,
|
|
79
|
+
top: false,
|
|
80
|
+
output: true,
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
};
|