typia 7.0.0-dev.20241010-2 → 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/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/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
|
@@ -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
|
+
};
|
package/src/json.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IJsonApplication } from "./schemas/json/IJsonApplication";
|
|
2
|
+
import { IJsonSchemaCollection } from "./schemas/json/IJsonSchemaList";
|
|
2
3
|
|
|
3
4
|
import { IValidation } from "./IValidation";
|
|
4
5
|
import { Primitive } from "./Primitive";
|
|
@@ -6,41 +7,86 @@ import { TypeGuardError } from "./TypeGuardError";
|
|
|
6
7
|
|
|
7
8
|
/* ===========================================================
|
|
8
9
|
JSON
|
|
9
|
-
-
|
|
10
|
+
- METADATA
|
|
10
11
|
- PARSE
|
|
11
12
|
- STRINGIFY
|
|
12
13
|
- FACTORY FUNCTIONS
|
|
13
14
|
==============================================================
|
|
14
|
-
|
|
15
|
+
METADATA
|
|
15
16
|
----------------------------------------------------------- */
|
|
17
|
+
/**
|
|
18
|
+
* > You must configure the generic argument `App`.
|
|
19
|
+
*
|
|
20
|
+
* TypeScript functions to JSON schema based application schema.
|
|
21
|
+
*
|
|
22
|
+
* Creates an application schema collecting the functions' schema based on the
|
|
23
|
+
* JSON schema specification.
|
|
24
|
+
*
|
|
25
|
+
* The default version of the OpenAPI specification is `"3.1"`, but you can
|
|
26
|
+
* specify the version by configuring the second generic argument `Version`.
|
|
27
|
+
*
|
|
28
|
+
* @template App Target class or interface type collecting the functions
|
|
29
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
30
|
+
* @returns Application schema of JSON schema based
|
|
31
|
+
*
|
|
32
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
33
|
+
*/
|
|
34
|
+
export function application(): never;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* TypeScript functions to JSON schema based application schema.
|
|
38
|
+
*
|
|
39
|
+
* Creates an application schema collecting the functions' schema based on the
|
|
40
|
+
* JSON schema specification.
|
|
41
|
+
*
|
|
42
|
+
* The default version of the OpenAPI specification is `"3.1"`, but you can
|
|
43
|
+
* specify the version by configuring the second generic argument `Version`.
|
|
44
|
+
*
|
|
45
|
+
* @template App Target class or interface type collecting the functions
|
|
46
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
47
|
+
* @returns Application schema of JSON schema based
|
|
48
|
+
*
|
|
49
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
50
|
+
*/
|
|
51
|
+
export function application<
|
|
52
|
+
App extends object,
|
|
53
|
+
Version extends "3.0" | "3.1" = "3.1",
|
|
54
|
+
>(): IJsonApplication<Version, App>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export function application(): never {
|
|
60
|
+
halt("application");
|
|
61
|
+
}
|
|
62
|
+
|
|
16
63
|
/**
|
|
17
64
|
* > You must configure the generic argument `Types`.
|
|
18
65
|
*
|
|
19
|
-
* JSON Schema
|
|
66
|
+
* JSON Schema List.
|
|
20
67
|
*
|
|
21
|
-
* Creates a JSON schema
|
|
22
|
-
* components. Note that, all of the named types are stored in the
|
|
23
|
-
* {@link
|
|
68
|
+
* Creates a JSON schema list which contains both main JSON schemas
|
|
69
|
+
* and components. Note that, all of the named types are stored in the
|
|
70
|
+
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
|
|
24
71
|
*
|
|
25
72
|
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
26
73
|
* argument `Version`. For reference, the default version is `"3.1"`, and key
|
|
27
74
|
* different of `"3.0"` and `"3.1"` is whether supporting the tuple type or not.
|
|
28
75
|
*
|
|
29
76
|
* @template Types Tuple of target types
|
|
30
|
-
* @template
|
|
31
|
-
* @
|
|
32
|
-
* @return JSON schema application
|
|
77
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
78
|
+
* @return JSON schema list
|
|
33
79
|
*
|
|
34
80
|
* @author Jeongho Nam - https://github.com/samchon
|
|
35
81
|
*/
|
|
36
|
-
export function
|
|
82
|
+
export function schemas(): never;
|
|
37
83
|
|
|
38
84
|
/**
|
|
39
85
|
* JSON Schema Application.
|
|
40
86
|
*
|
|
41
|
-
* Creates a JSON schema
|
|
42
|
-
* components. Note that, all of the named types are stored in the
|
|
43
|
-
* {@link
|
|
87
|
+
* Creates a JSON schema list which contains both main JSON schemas
|
|
88
|
+
* and components. Note that, all of the named types are stored in the
|
|
89
|
+
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
|
|
44
90
|
*
|
|
45
91
|
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
46
92
|
* argument `Version`. For reference, the default version is `"3.1"`, and key
|
|
@@ -48,19 +94,19 @@ export function application(): never;
|
|
|
48
94
|
*
|
|
49
95
|
* @template Types Tuple of target types
|
|
50
96
|
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
51
|
-
* @return JSON schema
|
|
97
|
+
* @return JSON schema list
|
|
52
98
|
*
|
|
53
99
|
* @author Jeongho Nam - https://github.com/samchon
|
|
54
100
|
*/
|
|
55
|
-
export function
|
|
101
|
+
export function schemas<
|
|
56
102
|
Types extends unknown[],
|
|
57
103
|
Version extends "3.0" | "3.1" = "3.1",
|
|
58
|
-
>():
|
|
104
|
+
>(): IJsonSchemaCollection<Version, Types>;
|
|
59
105
|
|
|
60
106
|
/**
|
|
61
107
|
* @internal
|
|
62
108
|
*/
|
|
63
|
-
export function
|
|
109
|
+
export function schemas(): never {
|
|
64
110
|
halt("application");
|
|
65
111
|
}
|
|
66
112
|
|
package/src/module.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * as tags from "./tags";
|
|
|
16
16
|
|
|
17
17
|
export * from "./schemas/metadata/IJsDocTagInfo";
|
|
18
18
|
export * from "./schemas/json/IJsonApplication";
|
|
19
|
+
export * from "./schemas/json/IJsonSchemaList";
|
|
19
20
|
export * from "./AssertionGuard";
|
|
20
21
|
export * from "./IRandomGenerator";
|
|
21
22
|
export * from "./IValidation";
|