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.
Files changed (49) hide show
  1. package/lib/index.mjs +7 -0
  2. package/lib/index.mjs.map +1 -1
  3. package/lib/json.d.ts +47 -13
  4. package/lib/json.js +7 -0
  5. package/lib/json.js.map +1 -1
  6. package/lib/module.d.ts +1 -0
  7. package/lib/module.js +1 -0
  8. package/lib/module.js.map +1 -1
  9. package/lib/programmers/json/JsonApplicationProgrammer.d.ts +6 -2
  10. package/lib/programmers/json/JsonApplicationProgrammer.js +200 -75
  11. package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
  12. package/lib/programmers/json/JsonSchemasProgrammer.d.ts +6 -0
  13. package/lib/programmers/json/JsonSchemasProgrammer.js +109 -0
  14. package/lib/programmers/json/JsonSchemasProgrammer.js.map +1 -0
  15. package/lib/programmers/llm/LlmApplicationProgrammer.d.ts +1 -1
  16. package/lib/programmers/llm/LlmApplicationProgrammer.js +57 -39
  17. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  18. package/lib/schemas/json/IJsonApplication.d.ts +31 -12
  19. package/lib/schemas/json/IJsonSchemaList.d.ts +16 -0
  20. package/lib/schemas/json/IJsonSchemaList.js +3 -0
  21. package/lib/schemas/json/IJsonSchemaList.js.map +1 -0
  22. package/lib/transformers/CallExpressionTransformer.js +3 -1
  23. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  24. package/lib/transformers/features/json/JsonApplicationTransformer.d.ts +1 -1
  25. package/lib/transformers/features/json/JsonApplicationTransformer.js +27 -97
  26. package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
  27. package/lib/transformers/features/json/JsonSchemasTransformer.d.ts +5 -0
  28. package/lib/transformers/features/json/JsonSchemasTransformer.js +159 -0
  29. package/lib/transformers/features/json/JsonSchemasTransformer.js.map +1 -0
  30. package/lib/transformers/features/llm/LlmApplicationTransformer.js +1 -1
  31. package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/factories/MetadataFactory.ts +400 -400
  34. package/src/factories/internal/metadata/IMetadataIteratorProps.ts +16 -16
  35. package/src/factories/internal/metadata/emplace_metadata_object.ts +206 -206
  36. package/src/factories/internal/metadata/iterate_metadata_collection.ts +145 -145
  37. package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +32 -32
  38. package/src/factories/internal/metadata/iterate_metadata_function.ts +88 -88
  39. package/src/json.ts +63 -17
  40. package/src/module.ts +1 -0
  41. package/src/programmers/json/JsonApplicationProgrammer.ts +249 -72
  42. package/src/programmers/json/JsonSchemasProgrammer.ts +94 -0
  43. package/src/programmers/llm/LlmApplicationProgrammer.ts +66 -41
  44. package/src/schemas/json/IJsonApplication.ts +61 -22
  45. package/src/schemas/json/IJsonSchemaList.ts +22 -0
  46. package/src/transformers/CallExpressionTransformer.ts +3 -1
  47. package/src/transformers/features/json/JsonApplicationTransformer.ts +29 -54
  48. package/src/transformers/features/json/JsonSchemasTransformer.ts +130 -0
  49. package/src/transformers/features/llm/LlmApplicationTransformer.ts +1 -1
@@ -1,92 +1,269 @@
1
- import { OpenApi, OpenApiV3 } from "@samchon/openapi";
1
+ import { MetadataFactory } from "../../factories/MetadataFactory";
2
2
 
3
3
  import { IJsonApplication } from "../../schemas/json/IJsonApplication";
4
4
  import { Metadata } from "../../schemas/metadata/Metadata";
5
+ import { MetadataFunction } from "../../schemas/metadata/MetadataFunction";
6
+ import { MetadataObject } from "../../schemas/metadata/MetadataObject";
5
7
 
6
- import { TransformerError } from "../../transformers/TransformerError";
7
-
8
- import { AtomicPredicator } from "../helpers/AtomicPredicator";
9
- import { application_v30_schema } from "../internal/application_v30_schema";
10
- import { application_v31_schema } from "../internal/application_v31_schema";
8
+ import { IJsDocTagInfo } from "../../module";
9
+ import { JsonSchemasProgrammer } from "./JsonSchemasProgrammer";
11
10
 
12
11
  export namespace JsonApplicationProgrammer {
13
- export const validate = (meta: Metadata): string[] => {
12
+ export const validate = (
13
+ metadata: Metadata,
14
+ explore: MetadataFactory.IExplore,
15
+ ): string[] => {
16
+ if (explore.top === false) return JsonSchemasProgrammer.validate(metadata);
17
+
14
18
  const output: string[] = [];
15
- if (
16
- meta.atomics.some((a) => a.type === "bigint") ||
17
- meta.constants.some((c) => c.type === "bigint")
18
- )
19
- output.push("JSON schema does not support bigint type.");
20
- if (
21
- meta.tuples.some((t) =>
22
- t.type.elements.some((e) => e.isRequired() === false),
23
- ) ||
24
- meta.arrays.some((a) => a.type.value.isRequired() === false)
25
- )
26
- output.push("JSON schema does not support undefined type in array.");
27
- if (meta.maps.length) output.push("JSON schema does not support Map type.");
28
- if (meta.sets.length) output.push("JSON schema does not support Set type.");
29
- for (const native of meta.natives)
30
- if (
31
- AtomicPredicator.native(native) === false &&
32
- native !== "Date" &&
33
- native !== "Blob" &&
34
- native !== "File"
35
- )
36
- output.push(`JSON schema does not support ${native} type.`);
19
+ const valid: boolean =
20
+ metadata.size() === 1 &&
21
+ metadata.objects.length === 1 &&
22
+ metadata.isRequired() === true &&
23
+ metadata.nullable === false;
24
+ if (valid === false)
25
+ output.push(
26
+ "JSON application's generic arugment must be a class/interface type.",
27
+ );
28
+
29
+ const object: MetadataObject | undefined = metadata.objects[0];
30
+ if (object !== undefined) {
31
+ if (object.properties.some((p) => p.key.isSoleLiteral() === false))
32
+ output.push("JSON application does not allow dynamic keys.");
33
+ let least: boolean = false;
34
+ for (const p of object.properties) {
35
+ const value: Metadata = p.value;
36
+ if (value.functions.length) {
37
+ least ||= true;
38
+ if (valid === false) {
39
+ if (value.functions.length !== 1 || value.size() !== 1)
40
+ output.push(
41
+ "JSON application's function type does not allow union type.",
42
+ );
43
+ if (value.isRequired() === false)
44
+ output.push("JSON application's function type must be required.");
45
+ if (value.nullable === true)
46
+ output.push(
47
+ "JSON application's function type must not be nullable.",
48
+ );
49
+ }
50
+ }
51
+ }
52
+ if (least === false)
53
+ output.push(
54
+ "JSON application's target type must have at least a function type.",
55
+ );
56
+ }
37
57
  return output;
38
58
  };
39
59
 
40
- export const write = <Version extends "3.0" | "3.1">(version: Version) =>
41
- version === "3.0" ? v30 : v31;
60
+ export const write = <Version extends "3.0" | "3.1">(props: {
61
+ version: Version;
62
+ metadata: Metadata;
63
+ }): IJsonApplication<Version> => {
64
+ const errors: string[] = validate(props.metadata, {
65
+ top: true,
66
+ object: null,
67
+ property: null,
68
+ parameter: null,
69
+ nested: null,
70
+ aliased: false,
71
+ escaped: false,
72
+ output: false,
73
+ });
74
+ if (errors.length)
75
+ throw new Error("Failed to write LLM application: " + errors.join("\n"));
76
+
77
+ const object: MetadataObject = props.metadata.objects[0]!;
78
+ const definitions: Metadata[] = [];
79
+ const setters: Array<(schema: IJsonApplication.Schema<Version>) => void> =
80
+ [];
81
+ const collect = (
82
+ metadata: Metadata,
83
+ setter: (schema: IJsonApplication.Schema<Version>) => void,
84
+ ): void => {
85
+ definitions.push(metadata);
86
+ setters.push(setter);
87
+ };
42
88
 
43
- const v30 = (metadatas: Array<Metadata>): IJsonApplication<"3.0"> => {
44
- const components: OpenApiV3.IComponents = {};
45
- const generator = (meta: Metadata): OpenApiV3.IJsonSchema | null =>
46
- application_v30_schema({
47
- blockNever: true,
48
- components,
49
- attribute: {},
50
- metadata: meta,
51
- });
89
+ const functions: IJsonApplication.IFunction<
90
+ IJsonApplication.Schema<Version>
91
+ >[] = object.properties
92
+ .filter(
93
+ (p) =>
94
+ p.key.isSoleLiteral() &&
95
+ p.value.size() === 1 &&
96
+ p.value.nullable === false &&
97
+ p.value.isRequired() === true &&
98
+ p.value.functions.length === 1,
99
+ )
100
+ .map((r) =>
101
+ collectFunction({
102
+ version: props.version,
103
+ name: r.key.getSoleLiteral()!,
104
+ function: r.value.functions[0]!,
105
+ description: r.description,
106
+ jsDocTags: r.jsDocTags,
107
+ collect,
108
+ }),
109
+ );
110
+ const { components, schemas } = JsonSchemasProgrammer.write(props.version)(
111
+ definitions,
112
+ );
113
+ schemas.forEach((s, i) =>
114
+ setters[i]?.(s as IJsonApplication.Schema<Version>),
115
+ );
52
116
  return {
53
- version: "3.0",
54
- components,
55
- schemas: metadatas.map((meta, i) => {
56
- const schema: OpenApiV3.IJsonSchema | null = generator(meta);
57
- if (schema === null)
58
- throw new TransformerError({
59
- code: "typia.json.application",
60
- message: `invalid type on argument - (${meta.getName()}, ${i})`,
61
- });
62
- return schema;
63
- }),
117
+ version: props.version,
118
+ components: components as any,
119
+ functions,
64
120
  };
65
121
  };
66
122
 
67
- const v31 = (metadatas: Array<Metadata>): IJsonApplication<"3.1"> => {
68
- const components: OpenApi.IComponents = {
69
- schemas: {},
70
- };
71
- const generator = (meta: Metadata): OpenApi.IJsonSchema | null =>
72
- application_v31_schema({
73
- blockNever: true,
74
- components,
75
- attribute: {},
76
- metadata: meta,
77
- });
123
+ const collectFunction = <Version extends "3.0" | "3.1">(props: {
124
+ version: Version;
125
+ name: string;
126
+ function: MetadataFunction;
127
+ description: string | null;
128
+ jsDocTags: IJsDocTagInfo[];
129
+ collect: (
130
+ metadata: Metadata,
131
+ setter: (schema: IJsonApplication.Schema<Version>) => void,
132
+ ) => void;
133
+ }): IJsonApplication.IFunction<IJsonApplication.Schema<Version>> => {
134
+ const deprecated: boolean = props.jsDocTags.some(
135
+ (tag) => tag.name === "deprecated",
136
+ );
137
+ const tags: string[] = props.jsDocTags
138
+ .map((tag) =>
139
+ tag.name === "tag"
140
+ ? (tag.text?.filter((elem) => elem.kind === "text") ?? [])
141
+ : [],
142
+ )
143
+ .flat()
144
+ .map((elem) => elem.text)
145
+ .map((str) => str.trim().split(" ")[0] ?? "")
146
+ .filter((str) => !!str.length);
78
147
  return {
79
- version: "3.1",
80
- components,
81
- schemas: metadatas.map((meta, i) => {
82
- const schema: OpenApi.IJsonSchema | null = generator(meta);
83
- if (schema === null)
84
- throw new TransformerError({
85
- code: "typia.json.application",
86
- message: `invalid type on argument - (${meta.getName()}, ${i})`,
87
- });
88
- return schema;
148
+ name: props.name,
149
+ async: props.function.async,
150
+ parameters: props.function.parameters.map((param) => {
151
+ const appParam: IJsonApplication.IParameter<
152
+ IJsonApplication.Schema<Version>
153
+ > = {
154
+ name: param.name,
155
+ ...writeDescription({
156
+ description:
157
+ param.description ??
158
+ param.jsDocTags.find((tag) => tag.name === "description")
159
+ ?.text?.[0]?.text ??
160
+ props.jsDocTags
161
+ .find(
162
+ (tag) =>
163
+ tag.name === "param" && tag.text?.[0]?.text === param.name,
164
+ )
165
+ ?.text?.map((e) => e.text)
166
+ .join("")
167
+ .substring(param.name.length) ??
168
+ null,
169
+ jsDocTags: props.jsDocTags,
170
+ kind: "title",
171
+ }),
172
+ required: param.type.isRequired(),
173
+ schema: null!,
174
+ };
175
+ props.collect(param.type, (schema) => (appParam.schema = schema));
176
+ return appParam;
89
177
  }),
178
+ output: props.function.output.size()
179
+ ? (() => {
180
+ const appOutput: IJsonApplication.IOutput<
181
+ IJsonApplication.Schema<Version>
182
+ > = {
183
+ schema: null!,
184
+ required: props.function.output.isRequired(),
185
+ description:
186
+ writeDescriptionFromJsDocTag({
187
+ jsDocTags: props.jsDocTags,
188
+ name: "return",
189
+ }) ??
190
+ writeDescriptionFromJsDocTag({
191
+ jsDocTags: props.jsDocTags,
192
+ name: "returns",
193
+ }) ??
194
+ undefined,
195
+ };
196
+ props.collect(
197
+ props.function.output,
198
+ (schema) => (appOutput.schema = schema),
199
+ );
200
+ return appOutput;
201
+ })()
202
+ : undefined,
203
+ description: props.description ?? undefined,
204
+ deprecated: deprecated || undefined,
205
+ tags: tags.length ? tags : undefined,
90
206
  };
91
207
  };
92
208
  }
209
+
210
+ const writeDescription = <Kind extends "summary" | "title">(props: {
211
+ description: string | null;
212
+ jsDocTags: IJsDocTagInfo[];
213
+ kind: Kind;
214
+ }): Kind extends "summary"
215
+ ? { summary?: string; description?: string }
216
+ : { title?: string; description?: string } => {
217
+ const title: string | undefined = (() => {
218
+ const [explicit] = getJsDocTexts({
219
+ jsDocTags: props.jsDocTags,
220
+ name: props.kind,
221
+ });
222
+ if (explicit?.length) return explicit;
223
+ else if (!props.description?.length) return undefined;
224
+
225
+ const index: number = props.description.indexOf("\n");
226
+ const top: string = (
227
+ index === -1 ? props.description : props.description.substring(0, index)
228
+ ).trim();
229
+ return top.endsWith(".") ? top.substring(0, top.length - 1) : undefined;
230
+ })();
231
+ return {
232
+ [props.kind]: title,
233
+ description: props.description?.length ? props.description : undefined,
234
+ } as any;
235
+ };
236
+
237
+ const writeDescriptionFromJsDocTag = (props: {
238
+ jsDocTags: IJsDocTagInfo[];
239
+ name: string;
240
+ parameter?: string;
241
+ }): string | null => {
242
+ const parametric: (elem: IJsDocTagInfo) => boolean = props.parameter
243
+ ? (tag) =>
244
+ tag.text!.find(
245
+ (elem) =>
246
+ elem.kind === "parameterName" && elem.text === props.parameter,
247
+ ) !== undefined
248
+ : () => true;
249
+ const tag: IJsDocTagInfo | undefined = props.jsDocTags.find(
250
+ (tag) => tag.name === props.name && tag.text && parametric(tag),
251
+ );
252
+ return tag && tag.text
253
+ ? (tag.text.find((elem) => elem.kind === "text")?.text ?? null)
254
+ : null;
255
+ };
256
+
257
+ const getJsDocTexts = (props: {
258
+ jsDocTags: IJsDocTagInfo[];
259
+ name: string;
260
+ }): string[] =>
261
+ props.jsDocTags
262
+ .filter(
263
+ (tag) =>
264
+ tag.name === props.name &&
265
+ tag.text &&
266
+ tag.text.find((elem) => elem.kind === "text" && elem.text.length) !==
267
+ undefined,
268
+ )
269
+ .map((tag) => tag.text!.find((elem) => elem.kind === "text")!.text);
@@ -0,0 +1,94 @@
1
+ import { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
+
3
+ import { IJsonSchemaCollection } from "../../schemas/json/IJsonSchemaList";
4
+ import { Metadata } from "../../schemas/metadata/Metadata";
5
+
6
+ import { TransformerError } from "../../transformers/TransformerError";
7
+
8
+ import { AtomicPredicator } from "../helpers/AtomicPredicator";
9
+ import { application_v30_schema } from "../internal/application_v30_schema";
10
+ import { application_v31_schema } from "../internal/application_v31_schema";
11
+
12
+ export namespace JsonSchemasProgrammer {
13
+ export const validate = (metadata: Metadata): string[] => {
14
+ const output: string[] = [];
15
+ if (
16
+ metadata.atomics.some((a) => a.type === "bigint") ||
17
+ metadata.constants.some((c) => c.type === "bigint")
18
+ )
19
+ output.push("JSON schema does not support bigint type.");
20
+ if (
21
+ metadata.tuples.some((t) =>
22
+ t.type.elements.some((e) => e.isRequired() === false),
23
+ ) ||
24
+ metadata.arrays.some((a) => a.type.value.isRequired() === false)
25
+ )
26
+ output.push("JSON schema does not support undefined type in array.");
27
+ if (metadata.maps.length)
28
+ output.push("JSON schema does not support Map type.");
29
+ if (metadata.sets.length)
30
+ output.push("JSON schema does not support Set type.");
31
+ for (const native of metadata.natives)
32
+ if (
33
+ AtomicPredicator.native(native) === false &&
34
+ native !== "Date" &&
35
+ native !== "Blob" &&
36
+ native !== "File"
37
+ )
38
+ output.push(`JSON schema does not support ${native} type.`);
39
+ return output;
40
+ };
41
+
42
+ export const write = <Version extends "3.0" | "3.1">(version: Version) =>
43
+ version === "3.0" ? v30 : v31;
44
+
45
+ const v30 = (medadataList: Array<Metadata>): IJsonSchemaCollection<"3.0"> => {
46
+ const components: OpenApiV3.IComponents = {};
47
+ const generator = (metadata: Metadata): OpenApiV3.IJsonSchema | null =>
48
+ application_v30_schema({
49
+ blockNever: true,
50
+ components,
51
+ attribute: {},
52
+ metadata,
53
+ });
54
+ return {
55
+ version: "3.0",
56
+ components,
57
+ schemas: medadataList.map((meta, i) => {
58
+ const schema: OpenApiV3.IJsonSchema | null = generator(meta);
59
+ if (schema === null)
60
+ throw new TransformerError({
61
+ code: "typia.json.application",
62
+ message: `invalid type on argument - (${meta.getName()}, ${i})`,
63
+ });
64
+ return schema;
65
+ }),
66
+ };
67
+ };
68
+
69
+ const v31 = (metadataList: Array<Metadata>): IJsonSchemaCollection<"3.1"> => {
70
+ const components: OpenApi.IComponents = {
71
+ schemas: {},
72
+ };
73
+ const generator = (metadata: Metadata): OpenApi.IJsonSchema | null =>
74
+ application_v31_schema({
75
+ blockNever: true,
76
+ components,
77
+ attribute: {},
78
+ metadata,
79
+ });
80
+ return {
81
+ version: "3.1",
82
+ components,
83
+ schemas: metadataList.map((meta, i) => {
84
+ const schema: OpenApi.IJsonSchema | null = generator(meta);
85
+ if (schema === null)
86
+ throw new TransformerError({
87
+ code: "typia.json.application",
88
+ message: `invalid type on argument - (${meta.getName()}, ${i})`,
89
+ });
90
+ return schema;
91
+ }),
92
+ };
93
+ };
94
+ }
@@ -11,56 +11,81 @@ import { IJsDocTagInfo } from "../../module";
11
11
  import { LlmSchemaProgrammer } from "./LlmSchemaProgrammer";
12
12
 
13
13
  export namespace LlmApplicationProgrammer {
14
- export const validate = (
15
- metadata: Metadata,
16
- explore: MetadataFactory.IExplore,
17
- ): string[] => {
18
- if (explore.top === false) return LlmSchemaProgrammer.validate(metadata);
14
+ export const validate = () => {
15
+ let top: Metadata | undefined;
16
+ return (
17
+ metadata: Metadata,
18
+ explore: MetadataFactory.IExplore,
19
+ ): string[] => {
20
+ top ??= metadata;
21
+ if (explore.top === false)
22
+ if (
23
+ explore.object === top?.objects[0] &&
24
+ typeof explore.property === "string" &&
25
+ metadata.size() === 1 &&
26
+ metadata.nullable === false &&
27
+ metadata.isRequired() === true &&
28
+ metadata.functions.length === 1
29
+ )
30
+ return validateFunction(metadata.functions[0]!);
31
+ else return LlmSchemaProgrammer.validate(metadata);
19
32
 
20
- const output: string[] = [];
21
- const valid: boolean =
22
- metadata.size() === 1 &&
23
- metadata.objects.length === 1 &&
24
- metadata.isRequired() === true &&
25
- metadata.nullable === false;
26
- if (valid === false)
27
- output.push(
28
- "LLM application's generic arugment must be a class/interface type.",
29
- );
33
+ const output: string[] = [];
34
+ const valid: boolean =
35
+ metadata.size() === 1 &&
36
+ metadata.objects.length === 1 &&
37
+ metadata.isRequired() === true &&
38
+ metadata.nullable === false;
39
+ if (valid === false)
40
+ output.push(
41
+ "LLM application's generic arugment must be a class/interface type.",
42
+ );
30
43
 
31
- const object: MetadataObject | undefined = metadata.objects[0];
32
- if (object !== undefined) {
33
- if (object.properties.some((p) => p.key.isSoleLiteral() === false))
34
- output.push("LLM application does not allow dynamic keys.");
35
- let least: boolean = false;
36
- for (const p of object.properties) {
37
- const value: Metadata = p.value;
38
- if (value.functions.length) {
39
- least ||= true;
40
- if (valid === false) {
41
- if (value.functions.length !== 1 || value.size() !== 1)
42
- output.push(
43
- "LLM application's function type does not allow union type.",
44
- );
45
- if (value.isRequired() === false)
46
- output.push("LLM application's function type must be required.");
47
- if (value.nullable === true)
48
- output.push(
49
- "LLM application's function type must not be nullable.",
50
- );
44
+ const object: MetadataObject | undefined = metadata.objects[0];
45
+ if (object !== undefined) {
46
+ if (object.properties.some((p) => p.key.isSoleLiteral() === false))
47
+ output.push("LLM application does not allow dynamic keys.");
48
+ let least: boolean = false;
49
+ for (const p of object.properties) {
50
+ const value: Metadata = p.value;
51
+ if (value.functions.length) {
52
+ least ||= true;
53
+ if (valid === false) {
54
+ if (value.functions.length !== 1 || value.size() !== 1)
55
+ output.push(
56
+ "LLM application's function type does not allow union type.",
57
+ );
58
+ if (value.isRequired() === false)
59
+ output.push(
60
+ "LLM application's function type must be required.",
61
+ );
62
+ if (value.nullable === true)
63
+ output.push(
64
+ "LLM application's function type must not be nullable.",
65
+ );
66
+ }
51
67
  }
52
68
  }
69
+ if (least === false)
70
+ output.push(
71
+ "LLM application's target type must have at least a function type.",
72
+ );
53
73
  }
54
- if (least === false)
55
- output.push(
56
- "LLM application's target type must have at least a function type.",
57
- );
58
- }
74
+ return output;
75
+ };
76
+ };
77
+
78
+ const validateFunction = (func: MetadataFunction): string[] => {
79
+ const output: string[] = [];
80
+ if (func.output.size() && func.output.isRequired() === false)
81
+ output.push(
82
+ "LLM application's function return type must not be union type with undefined.",
83
+ );
59
84
  return output;
60
85
  };
61
86
 
62
87
  export const write = (metadata: Metadata): ILlmApplication => {
63
- const errors: string[] = validate(metadata, {
88
+ const errors: string[] = validate()(metadata, {
64
89
  top: true,
65
90
  object: null,
66
91
  property: null,
@@ -1,22 +1,61 @@
1
- import type { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
-
3
- export type IJsonApplication<
4
- Version extends "3.0" | "3.1" = "3.1",
5
- Types = unknown[],
6
- > = Version extends "3.0"
7
- ? IJsonApplication.IV3_0<Types>
8
- : IJsonApplication.IV3_1<Types>;
9
- export namespace IJsonApplication {
10
- export interface IV3_0<Types = unknown[]> {
11
- version: "3.0";
12
- schemas: OpenApiV3.IJsonSchema[];
13
- components: OpenApiV3.IComponents;
14
- __types?: Types | undefined;
15
- }
16
- export interface IV3_1<Types = unknown[]> {
17
- version: "3.1";
18
- components: OpenApi.IComponents;
19
- schemas: OpenApi.IJsonSchema[];
20
- __types?: Types | undefined;
21
- }
22
- }
1
+ import { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
+
3
+ export interface IJsonApplication<
4
+ Version extends "3.0" | "3.1" = "3.1",
5
+ App extends any = object,
6
+ > {
7
+ version: Version;
8
+ components: IJsonApplication.IComponents<IJsonApplication.Schema<Version>>;
9
+ functions: IJsonApplication.IFunction<IJsonApplication.Schema<Version>>[];
10
+ __application?: App | undefined;
11
+ }
12
+ export namespace IJsonApplication {
13
+ export type Schema<Version extends "3.0" | "3.1"> = Version extends "3.1"
14
+ ? OpenApi.IJsonSchema
15
+ : OpenApiV3.IJsonSchema;
16
+
17
+ export interface IComponents<
18
+ Schema extends
19
+ | OpenApi.IJsonSchema
20
+ | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
21
+ > {
22
+ schemas?: Record<string, Schema>;
23
+ }
24
+
25
+ export interface IFunction<
26
+ Schema extends
27
+ | OpenApi.IJsonSchema
28
+ | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
29
+ > {
30
+ async: boolean;
31
+ name: string;
32
+ parameters: IParameter<Schema>[];
33
+ output: IOutput<Schema> | undefined;
34
+ summary?: string | undefined;
35
+ description?: string | undefined;
36
+ deprecated?: boolean;
37
+ tags?: string[];
38
+ }
39
+
40
+ export interface IParameter<
41
+ Schema extends
42
+ | OpenApi.IJsonSchema
43
+ | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
44
+ > {
45
+ name: string;
46
+ required: boolean;
47
+ schema: Schema;
48
+ title?: string | undefined;
49
+ description?: string | undefined;
50
+ }
51
+
52
+ export interface IOutput<
53
+ Schema extends
54
+ | OpenApi.IJsonSchema
55
+ | OpenApiV3.IJsonSchema = OpenApi.IJsonSchema,
56
+ > {
57
+ schema: Schema;
58
+ required: boolean;
59
+ description?: string | undefined;
60
+ }
61
+ }
@@ -0,0 +1,22 @@
1
+ import type { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
+
3
+ export type IJsonSchemaCollection<
4
+ Version extends "3.0" | "3.1" = "3.1",
5
+ Types = unknown[],
6
+ > = Version extends "3.0"
7
+ ? IJsonSchemaCollection.IV3_0<Types>
8
+ : IJsonSchemaCollection.IV3_1<Types>;
9
+ export namespace IJsonSchemaCollection {
10
+ export interface IV3_0<Types = unknown[]> {
11
+ version: "3.0";
12
+ schemas: OpenApiV3.IJsonSchema[];
13
+ components: OpenApiV3.IComponents;
14
+ __types?: Types | undefined;
15
+ }
16
+ export interface IV3_1<Types = unknown[]> {
17
+ version: "3.1";
18
+ components: OpenApi.IComponents;
19
+ schemas: OpenApi.IJsonSchema[];
20
+ __types?: Types | undefined;
21
+ }
22
+ }