@typia/interface 12.0.0-dev.20260225
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/LICENSE +21 -0
- package/README.md +23 -0
- package/lib/http/IHttpConnection.d.ts +163 -0
- package/lib/http/IHttpConnection.js +4 -0
- package/lib/http/IHttpConnection.js.map +1 -0
- package/lib/http/IHttpLlmApplication.d.ts +73 -0
- package/lib/http/IHttpLlmApplication.js +3 -0
- package/lib/http/IHttpLlmApplication.js.map +1 -0
- package/lib/http/IHttpLlmController.d.ts +86 -0
- package/lib/http/IHttpLlmController.js +3 -0
- package/lib/http/IHttpLlmController.js.map +1 -0
- package/lib/http/IHttpLlmFunction.d.ts +79 -0
- package/lib/http/IHttpLlmFunction.js +3 -0
- package/lib/http/IHttpLlmFunction.js.map +1 -0
- package/lib/http/IHttpMigrateApplication.d.ts +42 -0
- package/lib/http/IHttpMigrateApplication.js +3 -0
- package/lib/http/IHttpMigrateApplication.js.map +1 -0
- package/lib/http/IHttpMigrateRoute.d.ts +121 -0
- package/lib/http/IHttpMigrateRoute.js +3 -0
- package/lib/http/IHttpMigrateRoute.js.map +1 -0
- package/lib/http/IHttpResponse.d.ts +40 -0
- package/lib/http/IHttpResponse.js +3 -0
- package/lib/http/IHttpResponse.js.map +1 -0
- package/lib/http/index.d.ts +7 -0
- package/lib/http/index.js +24 -0
- package/lib/http/index.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +48 -0
- package/lib/index.js.map +1 -0
- package/lib/metadata/IJsDocTagInfo.d.ts +23 -0
- package/lib/metadata/IJsDocTagInfo.js +3 -0
- package/lib/metadata/IJsDocTagInfo.js.map +1 -0
- package/lib/metadata/IMetadataComponents.d.ts +20 -0
- package/lib/metadata/IMetadataComponents.js +3 -0
- package/lib/metadata/IMetadataComponents.js.map +1 -0
- package/lib/metadata/IMetadataSchema.d.ts +219 -0
- package/lib/metadata/IMetadataSchema.js +3 -0
- package/lib/metadata/IMetadataSchema.js.map +1 -0
- package/lib/metadata/IMetadataSchemaCollection.d.ts +18 -0
- package/lib/metadata/IMetadataSchemaCollection.js +3 -0
- package/lib/metadata/IMetadataSchemaCollection.js.map +1 -0
- package/lib/metadata/IMetadataSchemaUnit.d.ts +18 -0
- package/lib/metadata/IMetadataSchemaUnit.js +3 -0
- package/lib/metadata/IMetadataSchemaUnit.js.map +1 -0
- package/lib/metadata/IMetadataTypeTag.d.ts +28 -0
- package/lib/metadata/IMetadataTypeTag.js +3 -0
- package/lib/metadata/IMetadataTypeTag.js.map +1 -0
- package/lib/metadata/index.d.ts +6 -0
- package/lib/metadata/index.js +23 -0
- package/lib/metadata/index.js.map +1 -0
- package/lib/openapi/OpenApi.d.ts +454 -0
- package/lib/openapi/OpenApi.js +3 -0
- package/lib/openapi/OpenApi.js.map +1 -0
- package/lib/openapi/OpenApiV3.d.ts +420 -0
- package/lib/openapi/OpenApiV3.js +3 -0
- package/lib/openapi/OpenApiV3.js.map +1 -0
- package/lib/openapi/OpenApiV3_1.d.ts +463 -0
- package/lib/openapi/OpenApiV3_1.js +3 -0
- package/lib/openapi/OpenApiV3_1.js.map +1 -0
- package/lib/openapi/SwaggerV2.d.ts +343 -0
- package/lib/openapi/SwaggerV2.js +3 -0
- package/lib/openapi/SwaggerV2.js.map +1 -0
- package/lib/openapi/index.d.ts +4 -0
- package/lib/openapi/index.js +21 -0
- package/lib/openapi/index.js.map +1 -0
- package/lib/protobuf/ProtobufWire.d.ts +46 -0
- package/lib/protobuf/ProtobufWire.js +3 -0
- package/lib/protobuf/ProtobufWire.js.map +1 -0
- package/lib/protobuf/index.d.ts +1 -0
- package/lib/protobuf/index.js +18 -0
- package/lib/protobuf/index.js.map +1 -0
- package/lib/schema/IJsonSchemaApplication.d.ts +232 -0
- package/lib/schema/IJsonSchemaApplication.js +3 -0
- package/lib/schema/IJsonSchemaApplication.js.map +1 -0
- package/lib/schema/IJsonSchemaAttribute.d.ts +152 -0
- package/lib/schema/IJsonSchemaAttribute.js +3 -0
- package/lib/schema/IJsonSchemaAttribute.js.map +1 -0
- package/lib/schema/IJsonSchemaCollection.d.ts +109 -0
- package/lib/schema/IJsonSchemaCollection.js +3 -0
- package/lib/schema/IJsonSchemaCollection.js.map +1 -0
- package/lib/schema/IJsonSchemaTransformError.d.ts +81 -0
- package/lib/schema/IJsonSchemaTransformError.js +3 -0
- package/lib/schema/IJsonSchemaTransformError.js.map +1 -0
- package/lib/schema/IJsonSchemaUnit.d.ts +106 -0
- package/lib/schema/IJsonSchemaUnit.js +3 -0
- package/lib/schema/IJsonSchemaUnit.js.map +1 -0
- package/lib/schema/ILlmApplication.d.ts +95 -0
- package/lib/schema/ILlmApplication.js +3 -0
- package/lib/schema/ILlmApplication.js.map +1 -0
- package/lib/schema/ILlmController.d.ts +53 -0
- package/lib/schema/ILlmController.js +3 -0
- package/lib/schema/ILlmController.js.map +1 -0
- package/lib/schema/ILlmFunction.d.ts +134 -0
- package/lib/schema/ILlmFunction.js +3 -0
- package/lib/schema/ILlmFunction.js.map +1 -0
- package/lib/schema/ILlmSchema.d.ts +412 -0
- package/lib/schema/ILlmSchema.js +3 -0
- package/lib/schema/ILlmSchema.js.map +1 -0
- package/lib/schema/IResult.d.ts +81 -0
- package/lib/schema/IResult.js +3 -0
- package/lib/schema/IResult.js.map +1 -0
- package/lib/schema/IValidation.d.ts +123 -0
- package/lib/schema/IValidation.js +3 -0
- package/lib/schema/IValidation.js.map +1 -0
- package/lib/schema/index.d.ts +11 -0
- package/lib/schema/index.js +28 -0
- package/lib/schema/index.js.map +1 -0
- package/lib/tags/Constant.d.ts +44 -0
- package/lib/tags/Constant.js +3 -0
- package/lib/tags/Constant.js.map +1 -0
- package/lib/tags/ContentMediaType.d.ts +39 -0
- package/lib/tags/ContentMediaType.js +3 -0
- package/lib/tags/ContentMediaType.js.map +1 -0
- package/lib/tags/Default.d.ts +42 -0
- package/lib/tags/Default.js +3 -0
- package/lib/tags/Default.js.map +1 -0
- package/lib/tags/Example.d.ts +38 -0
- package/lib/tags/Example.js +3 -0
- package/lib/tags/Example.js.map +1 -0
- package/lib/tags/Examples.d.ts +44 -0
- package/lib/tags/Examples.js +3 -0
- package/lib/tags/Examples.js.map +1 -0
- package/lib/tags/ExclusiveMaximum.d.ts +39 -0
- package/lib/tags/ExclusiveMaximum.js +3 -0
- package/lib/tags/ExclusiveMaximum.js.map +1 -0
- package/lib/tags/ExclusiveMinimum.d.ts +39 -0
- package/lib/tags/ExclusiveMinimum.js +3 -0
- package/lib/tags/ExclusiveMinimum.js.map +1 -0
- package/lib/tags/Format.d.ts +43 -0
- package/lib/tags/Format.js +3 -0
- package/lib/tags/Format.js.map +1 -0
- package/lib/tags/JsonSchemaPlugin.d.ts +44 -0
- package/lib/tags/JsonSchemaPlugin.js +3 -0
- package/lib/tags/JsonSchemaPlugin.js.map +1 -0
- package/lib/tags/MaxItems.d.ts +38 -0
- package/lib/tags/MaxItems.js +3 -0
- package/lib/tags/MaxItems.js.map +1 -0
- package/lib/tags/MaxLength.d.ts +36 -0
- package/lib/tags/MaxLength.js +3 -0
- package/lib/tags/MaxLength.js.map +1 -0
- package/lib/tags/Maximum.d.ts +41 -0
- package/lib/tags/Maximum.js +3 -0
- package/lib/tags/Maximum.js.map +1 -0
- package/lib/tags/MinItems.d.ts +38 -0
- package/lib/tags/MinItems.js +3 -0
- package/lib/tags/MinItems.js.map +1 -0
- package/lib/tags/MinLength.d.ts +36 -0
- package/lib/tags/MinLength.js +3 -0
- package/lib/tags/MinLength.js.map +1 -0
- package/lib/tags/Minimum.d.ts +41 -0
- package/lib/tags/Minimum.js +3 -0
- package/lib/tags/Minimum.js.map +1 -0
- package/lib/tags/MultipleOf.d.ts +49 -0
- package/lib/tags/MultipleOf.js +3 -0
- package/lib/tags/MultipleOf.js.map +1 -0
- package/lib/tags/Pattern.d.ts +51 -0
- package/lib/tags/Pattern.js +3 -0
- package/lib/tags/Pattern.js.map +1 -0
- package/lib/tags/Sequence.d.ts +42 -0
- package/lib/tags/Sequence.js +3 -0
- package/lib/tags/Sequence.js.map +1 -0
- package/lib/tags/TagBase.d.ts +109 -0
- package/lib/tags/TagBase.js +3 -0
- package/lib/tags/TagBase.js.map +1 -0
- package/lib/tags/Type.d.ts +53 -0
- package/lib/tags/Type.js +3 -0
- package/lib/tags/Type.js.map +1 -0
- package/lib/tags/UniqueItems.d.ts +41 -0
- package/lib/tags/UniqueItems.js +3 -0
- package/lib/tags/UniqueItems.js.map +1 -0
- package/lib/tags/index.d.ts +21 -0
- package/lib/tags/index.js +38 -0
- package/lib/tags/index.js.map +1 -0
- package/lib/typings/AssertionGuard.d.ts +12 -0
- package/lib/typings/AssertionGuard.js +3 -0
- package/lib/typings/AssertionGuard.js.map +1 -0
- package/lib/typings/Atomic.d.ts +19 -0
- package/lib/typings/Atomic.js +3 -0
- package/lib/typings/Atomic.js.map +1 -0
- package/lib/typings/CamelCase.d.ts +26 -0
- package/lib/typings/CamelCase.js +3 -0
- package/lib/typings/CamelCase.js.map +1 -0
- package/lib/typings/ClassProperties.d.ts +14 -0
- package/lib/typings/ClassProperties.js +3 -0
- package/lib/typings/ClassProperties.js.map +1 -0
- package/lib/typings/OmitNever.d.ts +11 -0
- package/lib/typings/OmitNever.js +3 -0
- package/lib/typings/OmitNever.js.map +1 -0
- package/lib/typings/PascalCase.d.ts +25 -0
- package/lib/typings/PascalCase.js +3 -0
- package/lib/typings/PascalCase.js.map +1 -0
- package/lib/typings/Primitive.d.ts +29 -0
- package/lib/typings/Primitive.js +3 -0
- package/lib/typings/Primitive.js.map +1 -0
- package/lib/typings/ProtobufAtomic.d.ts +15 -0
- package/lib/typings/ProtobufAtomic.js +3 -0
- package/lib/typings/ProtobufAtomic.js.map +1 -0
- package/lib/typings/Resolved.d.ts +23 -0
- package/lib/typings/Resolved.js +3 -0
- package/lib/typings/Resolved.js.map +1 -0
- package/lib/typings/SnakeCase.d.ts +31 -0
- package/lib/typings/SnakeCase.js +3 -0
- package/lib/typings/SnakeCase.js.map +1 -0
- package/lib/typings/SpecialFields.d.ts +13 -0
- package/lib/typings/SpecialFields.js +3 -0
- package/lib/typings/SpecialFields.js.map +1 -0
- package/lib/typings/ValidationPipe.d.ts +18 -0
- package/lib/typings/ValidationPipe.js +3 -0
- package/lib/typings/ValidationPipe.js.map +1 -0
- package/lib/typings/index.d.ts +12 -0
- package/lib/typings/index.js +29 -0
- package/lib/typings/index.js.map +1 -0
- package/lib/typings/internal/Equal.d.ts +11 -0
- package/lib/typings/internal/Equal.js +3 -0
- package/lib/typings/internal/Equal.js.map +1 -0
- package/lib/typings/internal/IsTuple.d.ts +13 -0
- package/lib/typings/internal/IsTuple.js +3 -0
- package/lib/typings/internal/IsTuple.js.map +1 -0
- package/lib/typings/internal/NativeClass.d.ts +9 -0
- package/lib/typings/internal/NativeClass.js +3 -0
- package/lib/typings/internal/NativeClass.js.map +1 -0
- package/lib/typings/internal/ValueOf.d.ts +15 -0
- package/lib/typings/internal/ValueOf.js +3 -0
- package/lib/typings/internal/ValueOf.js.map +1 -0
- package/lib/utils/IRandomGenerator.d.ts +68 -0
- package/lib/utils/IRandomGenerator.js +3 -0
- package/lib/utils/IRandomGenerator.js.map +1 -0
- package/lib/utils/IReadableURLSearchParams.d.ts +22 -0
- package/lib/utils/IReadableURLSearchParams.js +3 -0
- package/lib/utils/IReadableURLSearchParams.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +19 -0
- package/lib/utils/index.js.map +1 -0
- package/package.json +79 -0
- package/src/http/IHttpConnection.ts +200 -0
- package/src/http/IHttpLlmApplication.ts +83 -0
- package/src/http/IHttpLlmController.ts +96 -0
- package/src/http/IHttpLlmFunction.ts +93 -0
- package/src/http/IHttpMigrateApplication.ts +48 -0
- package/src/http/IHttpMigrateRoute.ts +165 -0
- package/src/http/IHttpResponse.ts +42 -0
- package/src/http/index.ts +7 -0
- package/src/index.ts +9 -0
- package/src/metadata/IJsDocTagInfo.ts +25 -0
- package/src/metadata/IMetadataComponents.ts +24 -0
- package/src/metadata/IMetadataSchema.ts +293 -0
- package/src/metadata/IMetadataSchemaCollection.ts +20 -0
- package/src/metadata/IMetadataSchemaUnit.ts +20 -0
- package/src/metadata/IMetadataTypeTag.ts +39 -0
- package/src/metadata/index.ts +6 -0
- package/src/openapi/OpenApi.ts +643 -0
- package/src/openapi/OpenApiV3.ts +655 -0
- package/src/openapi/OpenApiV3_1.ts +735 -0
- package/src/openapi/SwaggerV2.ts +559 -0
- package/src/openapi/index.ts +4 -0
- package/src/protobuf/ProtobufWire.ts +51 -0
- package/src/protobuf/index.ts +1 -0
- package/src/schema/IJsonSchemaApplication.ts +274 -0
- package/src/schema/IJsonSchemaAttribute.ts +158 -0
- package/src/schema/IJsonSchemaCollection.ts +123 -0
- package/src/schema/IJsonSchemaTransformError.ts +86 -0
- package/src/schema/IJsonSchemaUnit.ts +120 -0
- package/src/schema/ILlmApplication.ts +103 -0
- package/src/schema/ILlmController.ts +57 -0
- package/src/schema/ILlmFunction.ts +144 -0
- package/src/schema/ILlmSchema.ts +484 -0
- package/src/schema/IResult.ts +84 -0
- package/src/schema/IValidation.ts +134 -0
- package/src/schema/index.ts +13 -0
- package/src/tags/Constant.ts +49 -0
- package/src/tags/ContentMediaType.ts +40 -0
- package/src/tags/Default.ts +50 -0
- package/src/tags/Example.ts +48 -0
- package/src/tags/Examples.ts +50 -0
- package/src/tags/ExclusiveMaximum.ts +46 -0
- package/src/tags/ExclusiveMinimum.ts +46 -0
- package/src/tags/Format.ts +76 -0
- package/src/tags/JsonSchemaPlugin.ts +45 -0
- package/src/tags/MaxItems.ts +39 -0
- package/src/tags/MaxLength.ts +37 -0
- package/src/tags/Maximum.ts +44 -0
- package/src/tags/MinItems.ts +39 -0
- package/src/tags/MinLength.ts +37 -0
- package/src/tags/Minimum.ts +44 -0
- package/src/tags/MultipleOf.ts +54 -0
- package/src/tags/Pattern.ts +59 -0
- package/src/tags/Sequence.ts +43 -0
- package/src/tags/TagBase.ts +131 -0
- package/src/tags/Type.ts +70 -0
- package/src/tags/UniqueItems.ts +44 -0
- package/src/tags/index.ts +21 -0
- package/src/typings/AssertionGuard.ts +12 -0
- package/src/typings/Atomic.ts +21 -0
- package/src/typings/CamelCase.ts +75 -0
- package/src/typings/ClassProperties.ts +15 -0
- package/src/typings/OmitNever.ts +12 -0
- package/src/typings/PascalCase.ts +71 -0
- package/src/typings/Primitive.ts +71 -0
- package/src/typings/ProtobufAtomic.ts +30 -0
- package/src/typings/Resolved.ts +58 -0
- package/src/typings/SnakeCase.ts +126 -0
- package/src/typings/SpecialFields.ts +13 -0
- package/src/typings/ValidationPipe.ts +20 -0
- package/src/typings/index.ts +13 -0
- package/src/typings/internal/Equal.ts +14 -0
- package/src/typings/internal/IsTuple.ts +17 -0
- package/src/typings/internal/NativeClass.ts +31 -0
- package/src/typings/internal/ValueOf.ts +29 -0
- package/src/utils/IRandomGenerator.ts +105 -0
- package/src/utils/IReadableURLSearchParams.ts +25 -0
- package/src/utils/index.ts +2 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { OpenApi } from "../openapi/OpenApi";
|
|
2
|
+
import { OpenApiV3 } from "../openapi/OpenApiV3";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Single JSON schema unit for one TypeScript type.
|
|
6
|
+
*
|
|
7
|
+
* `IJsonSchemaUnit` represents a complete JSON schema for a single TypeScript
|
|
8
|
+
* type, including the main schema definition and any referenced component
|
|
9
|
+
* schemas. Generated by `typia.json.schema<T>()` at compile time.
|
|
10
|
+
*
|
|
11
|
+
* The result contains:
|
|
12
|
+
*
|
|
13
|
+
* - {@link IV3_0.schema | schema}: The main JSON schema for the type
|
|
14
|
+
* - {@link IV3_0.components | components}: Shared schemas referenced via `$ref`
|
|
15
|
+
* - {@link IV3_0.__type | __type}: Phantom property for TypeScript type inference
|
|
16
|
+
*
|
|
17
|
+
* Use this for single-type schema generation. For multiple types, see
|
|
18
|
+
* {@link IJsonSchemaCollection}. For function schemas, see
|
|
19
|
+
* {@link IJsonSchemaApplication}.
|
|
20
|
+
*
|
|
21
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
22
|
+
* @template Version OpenAPI version ("3.0" or "3.1")
|
|
23
|
+
* @template Type Original TypeScript type
|
|
24
|
+
*/
|
|
25
|
+
export type IJsonSchemaUnit<
|
|
26
|
+
Version extends "3.0" | "3.1" = "3.1",
|
|
27
|
+
Type = unknown,
|
|
28
|
+
> = Version extends "3.0"
|
|
29
|
+
? IJsonSchemaUnit.IV3_0<Type>
|
|
30
|
+
: IJsonSchemaUnit.IV3_1<Type>;
|
|
31
|
+
|
|
32
|
+
export namespace IJsonSchemaUnit {
|
|
33
|
+
/**
|
|
34
|
+
* JSON Schema unit for OpenAPI v3.0 specification.
|
|
35
|
+
*
|
|
36
|
+
* Uses OpenAPI v3.0 compatible JSON Schema format. In v3.0, nullable types
|
|
37
|
+
* are expressed with `nullable: true` rather than v3.1's `type: ["string",
|
|
38
|
+
* "null"]`.
|
|
39
|
+
*
|
|
40
|
+
* @template Type Original TypeScript type for phantom type preservation
|
|
41
|
+
*/
|
|
42
|
+
export interface IV3_0<Type> {
|
|
43
|
+
/**
|
|
44
|
+
* OpenAPI specification version.
|
|
45
|
+
*
|
|
46
|
+
* Always `"3.0"` for this variant. Use this discriminator to determine
|
|
47
|
+
* which schema format is in use.
|
|
48
|
+
*/
|
|
49
|
+
version: "3.0";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The main JSON schema definition for the type.
|
|
53
|
+
*
|
|
54
|
+
* Contains the complete schema for the target TypeScript type. May include
|
|
55
|
+
* `$ref` references to schemas in {@link components}.
|
|
56
|
+
*/
|
|
57
|
+
schema: OpenApiV3.IJsonSchema;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Reusable schema definitions for `$ref` references.
|
|
61
|
+
*
|
|
62
|
+
* Contains named schemas that can be referenced throughout the main schema.
|
|
63
|
+
* Essential for recursive types and reducing duplication.
|
|
64
|
+
*/
|
|
65
|
+
components: OpenApiV3.IComponents;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Phantom property for TypeScript generic type preservation.
|
|
69
|
+
*
|
|
70
|
+
* This property exists only in the type system to preserve the `Type`
|
|
71
|
+
* generic parameter. It is always `undefined` at runtime and should not be
|
|
72
|
+
* accessed or used in application code.
|
|
73
|
+
*/
|
|
74
|
+
__type?: Type | undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* JSON Schema unit for OpenAPI v3.1 specification.
|
|
79
|
+
*
|
|
80
|
+
* Uses OpenAPI v3.1 compatible JSON Schema format. v3.1 aligns more closely
|
|
81
|
+
* with JSON Schema draft 2020-12, supporting features like `type` arrays for
|
|
82
|
+
* nullable types and `const` values.
|
|
83
|
+
*
|
|
84
|
+
* @template Type Original TypeScript type for phantom type preservation
|
|
85
|
+
*/
|
|
86
|
+
export interface IV3_1<Type> {
|
|
87
|
+
/**
|
|
88
|
+
* OpenAPI specification version.
|
|
89
|
+
*
|
|
90
|
+
* Always `"3.1"` for this variant. Use this discriminator to determine
|
|
91
|
+
* which schema format is in use.
|
|
92
|
+
*/
|
|
93
|
+
version: "3.1";
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The main JSON schema definition for the type.
|
|
97
|
+
*
|
|
98
|
+
* Contains the complete schema for the target TypeScript type. May include
|
|
99
|
+
* `$ref` references to schemas in {@link components}.
|
|
100
|
+
*/
|
|
101
|
+
schema: OpenApi.IJsonSchema;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Reusable schema definitions for `$ref` references.
|
|
105
|
+
*
|
|
106
|
+
* Contains named schemas that can be referenced throughout the main schema.
|
|
107
|
+
* Essential for recursive types and reducing duplication.
|
|
108
|
+
*/
|
|
109
|
+
components: OpenApi.IComponents;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Phantom property for TypeScript generic type preservation.
|
|
113
|
+
*
|
|
114
|
+
* This property exists only in the type system to preserve the `Type`
|
|
115
|
+
* generic parameter. It is always `undefined` at runtime and should not be
|
|
116
|
+
* accessed or used in application code.
|
|
117
|
+
*/
|
|
118
|
+
__type?: Type | undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ILlmFunction } from "./ILlmFunction";
|
|
2
|
+
import { ILlmSchema } from "./ILlmSchema";
|
|
3
|
+
import { IValidation } from "./IValidation";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* LLM function calling application.
|
|
7
|
+
*
|
|
8
|
+
* `ILlmApplication` is a collection of {@link ILlmFunction} schemas generated
|
|
9
|
+
* from a TypeScript class or interface by `typia.llm.application<App>()`. Each
|
|
10
|
+
* public method becomes an {@link ILlmFunction} that LLM agents can invoke.
|
|
11
|
+
*
|
|
12
|
+
* Configure behavior via {@link ILlmApplication.IConfig}:
|
|
13
|
+
*
|
|
14
|
+
* - {@link ILlmApplication.IConfig.separate}: Split parameters into LLM-fillable
|
|
15
|
+
* vs human-required (e.g., file uploads, passwords)
|
|
16
|
+
* - {@link ILlmApplication.IConfig.validate}: Custom validation per method
|
|
17
|
+
* - {@link ILlmSchema.IConfig.strict}: OpenAI structured output mode
|
|
18
|
+
* - {@link ILlmSchema.IConfig.reference}: Control `$ref` inlining behavior
|
|
19
|
+
*
|
|
20
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
21
|
+
* @template Class Source class/interface type
|
|
22
|
+
*/
|
|
23
|
+
export interface ILlmApplication<Class extends object = any> {
|
|
24
|
+
/**
|
|
25
|
+
* Array of callable function schemas.
|
|
26
|
+
*
|
|
27
|
+
* Each function represents a method from the source class that the LLM can
|
|
28
|
+
* invoke. Functions include parameter schemas, descriptions, and validation
|
|
29
|
+
* logic for type-safe function calling.
|
|
30
|
+
*/
|
|
31
|
+
functions: ILlmFunction[];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Configuration used to generate this application.
|
|
35
|
+
*
|
|
36
|
+
* Contains the settings that were applied during schema generation, including
|
|
37
|
+
* reference handling, strict mode, and parameter separation.
|
|
38
|
+
*/
|
|
39
|
+
config: ILlmApplication.IConfig<Class>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Phantom property for TypeScript generic type preservation.
|
|
43
|
+
*
|
|
44
|
+
* This property exists only in the type system to preserve the `Class`
|
|
45
|
+
* generic parameter at compile time. It is always `undefined` at runtime and
|
|
46
|
+
* should not be accessed or used in application code.
|
|
47
|
+
*
|
|
48
|
+
* This pattern enables type inference to recover the original class type from
|
|
49
|
+
* an `ILlmApplication` instance, useful for type-safe function routing.
|
|
50
|
+
*/
|
|
51
|
+
__class?: Class | undefined;
|
|
52
|
+
}
|
|
53
|
+
export namespace ILlmApplication {
|
|
54
|
+
/**
|
|
55
|
+
* Configuration for LLM application generation.
|
|
56
|
+
*
|
|
57
|
+
* Extends {@link ILlmSchema.IConfig} with application-specific options for
|
|
58
|
+
* parameter separation and custom validation. These settings control how the
|
|
59
|
+
* application schema is generated from the source class.
|
|
60
|
+
*/
|
|
61
|
+
export interface IConfig<Class extends object = any>
|
|
62
|
+
extends ILlmSchema.IConfig {
|
|
63
|
+
/**
|
|
64
|
+
* Function to separate LLM-fillable from human-required parameters.
|
|
65
|
+
*
|
|
66
|
+
* When provided, this function is called for each parameter schema to
|
|
67
|
+
* determine if it should be filled by the LLM (`false`) or require human
|
|
68
|
+
* input (`true`). Use this for sensitive data like passwords, file uploads,
|
|
69
|
+
* or data the LLM cannot generate.
|
|
70
|
+
*
|
|
71
|
+
* @default null (no separation)
|
|
72
|
+
* @param schema - The parameter schema to evaluate
|
|
73
|
+
* @returns `true` if human input required, `false` if LLM can fill
|
|
74
|
+
*/
|
|
75
|
+
separate: null | ((schema: ILlmSchema) => boolean);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Custom validation functions per method name.
|
|
79
|
+
*
|
|
80
|
+
* Allows overriding the default type-based validation with custom business
|
|
81
|
+
* logic. Useful for complex validation rules that cannot be expressed in
|
|
82
|
+
* JSON Schema.
|
|
83
|
+
*
|
|
84
|
+
* @default null (use default type validation)
|
|
85
|
+
*/
|
|
86
|
+
validate: null | Partial<ILlmApplication.IValidationHook<Class>>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Type-safe mapping of method names to custom validators.
|
|
91
|
+
*
|
|
92
|
+
* Maps each method name to a validation function that receives the raw input
|
|
93
|
+
* and returns a validation result. The type inference ensures validators
|
|
94
|
+
* match the expected argument types.
|
|
95
|
+
*
|
|
96
|
+
* @template Class - The source class type for type inference
|
|
97
|
+
*/
|
|
98
|
+
export type IValidationHook<Class extends object> = {
|
|
99
|
+
[K in keyof Class]?: Class[K] extends (args: infer Argument) => unknown
|
|
100
|
+
? (input: unknown) => IValidation<Argument>
|
|
101
|
+
: never;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ILlmApplication } from "./ILlmApplication";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Controller of TypeScript class-based LLM function calling.
|
|
5
|
+
*
|
|
6
|
+
* `ILlmController` is a controller for registering TypeScript class methods as
|
|
7
|
+
* LLM function calling tools. It contains {@link ILlmApplication} with
|
|
8
|
+
* {@link ILlmFunction function calling schemas}, {@link name identifier}, and
|
|
9
|
+
* {@link execute class instance} for method execution.
|
|
10
|
+
*
|
|
11
|
+
* You can create this controller with `typia.llm.controller<Class>()` function,
|
|
12
|
+
* and register it to MCP server with {@link registerMcpControllers}:
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
16
|
+
* import typia from "typia";
|
|
17
|
+
* import { registerMcpControllers } from "@typia/mcp";
|
|
18
|
+
*
|
|
19
|
+
* class Calculator {
|
|
20
|
+
* add(input: { a: number; b: number }): number {
|
|
21
|
+
* return input.a + input.b;
|
|
22
|
+
* }
|
|
23
|
+
* subtract(input: { a: number; b: number }): number {
|
|
24
|
+
* return input.a - input.b;
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* const server = new McpServer({ name: "my-server", version: "1.0.0" });
|
|
29
|
+
* registerMcpControllers({
|
|
30
|
+
* server,
|
|
31
|
+
* controllers: [
|
|
32
|
+
* typia.llm.controller<Calculator>(
|
|
33
|
+
* "calculator",
|
|
34
|
+
* new Calculator(),
|
|
35
|
+
* ),
|
|
36
|
+
* ],
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* For OpenAPI/HTTP-based controller, use {@link IHttpLlmController} instead.
|
|
41
|
+
*
|
|
42
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
43
|
+
* @template Class Class type of the function executor
|
|
44
|
+
*/
|
|
45
|
+
export interface ILlmController<Class extends object = any> {
|
|
46
|
+
/** Protocol discriminator. */
|
|
47
|
+
protocol: "class";
|
|
48
|
+
|
|
49
|
+
/** Identifier name of the controller. */
|
|
50
|
+
name: string;
|
|
51
|
+
|
|
52
|
+
/** Application schema of function calling. */
|
|
53
|
+
application: ILlmApplication<Class>;
|
|
54
|
+
|
|
55
|
+
/** Target class instance for function execution. */
|
|
56
|
+
execute: Class;
|
|
57
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { ILlmSchema } from "./ILlmSchema";
|
|
2
|
+
import { IValidation } from "./IValidation";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* LLM function calling metadata.
|
|
6
|
+
*
|
|
7
|
+
* `ILlmFunction` describes a single callable function for LLM agents. Generated
|
|
8
|
+
* as part of {@link ILlmApplication} by `typia.llm.application<App>()`.
|
|
9
|
+
*
|
|
10
|
+
* Contains the function {@link name} (max 64 chars for OpenAI),
|
|
11
|
+
* {@link parameters} schema for input types, optional {@link output} schema for
|
|
12
|
+
* return type, and {@link description} for LLM to understand the function's
|
|
13
|
+
* purpose.
|
|
14
|
+
*
|
|
15
|
+
* The built-in {@link validate} function checks LLM-generated arguments against
|
|
16
|
+
* the schema, enabling auto-correction when the LLM makes type errors (e.g.,
|
|
17
|
+
* returning `"123"` instead of `123`).
|
|
18
|
+
*
|
|
19
|
+
* Use {@link separated} when some parameters require human input (files,
|
|
20
|
+
* passwords) via {@link ILlmApplication.IConfig.separate}.
|
|
21
|
+
*
|
|
22
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
23
|
+
*/
|
|
24
|
+
export interface ILlmFunction {
|
|
25
|
+
/**
|
|
26
|
+
* Function name for LLM invocation.
|
|
27
|
+
*
|
|
28
|
+
* The identifier used by the LLM to call this function. Must be unique within
|
|
29
|
+
* the application. OpenAI limits function names to 64 characters.
|
|
30
|
+
*
|
|
31
|
+
* @maxLength 64
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Schema for function parameters.
|
|
37
|
+
*
|
|
38
|
+
* Defines the expected argument types as a JSON Schema object. Contains
|
|
39
|
+
* `$defs` for shared type definitions and `properties` for each named
|
|
40
|
+
* parameter.
|
|
41
|
+
*/
|
|
42
|
+
parameters: ILlmSchema.IParameters;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Parameters split between LLM and human input.
|
|
46
|
+
*
|
|
47
|
+
* Present when {@link ILlmApplication.IConfig.separate} is configured. Allows
|
|
48
|
+
* separating parameters that the LLM can fill from those requiring human
|
|
49
|
+
* input (e.g., file uploads, passwords).
|
|
50
|
+
*/
|
|
51
|
+
separated?: ILlmFunction.ISeparated;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Schema for the return type.
|
|
55
|
+
*
|
|
56
|
+
* Defines the expected output type as a JSON Schema. `undefined` when the
|
|
57
|
+
* function returns `void` or has no meaningful return value.
|
|
58
|
+
*/
|
|
59
|
+
output?: ILlmSchema | undefined;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Human-readable function description.
|
|
63
|
+
*
|
|
64
|
+
* Explains what the function does, when to use it, and any important
|
|
65
|
+
* considerations. This description is crucial for LLMs to understand when to
|
|
66
|
+
* invoke this function. Extracted from JSDoc comments.
|
|
67
|
+
*/
|
|
68
|
+
description?: string | undefined;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Whether this function is deprecated.
|
|
72
|
+
*
|
|
73
|
+
* When `true`, indicates the function should no longer be used. LLMs may
|
|
74
|
+
* still invoke deprecated functions but should prefer non-deprecated
|
|
75
|
+
* alternatives when available.
|
|
76
|
+
*/
|
|
77
|
+
deprecated?: boolean | undefined;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Category tags for function organization.
|
|
81
|
+
*
|
|
82
|
+
* Extracted from `@tag` JSDoc annotations. Useful for grouping related
|
|
83
|
+
* functions and filtering the function list.
|
|
84
|
+
*/
|
|
85
|
+
tags?: string[] | undefined;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Validates LLM-generated arguments against the schema.
|
|
89
|
+
*
|
|
90
|
+
* LLMs frequently make type errors such as returning strings instead of
|
|
91
|
+
* numbers or missing required properties. Use this validator to check
|
|
92
|
+
* arguments before execution.
|
|
93
|
+
*
|
|
94
|
+
* When validation fails, use `stringifyValidationFailure()` from
|
|
95
|
+
* `@typia/utils` to format the error for LLM feedback. The formatted output
|
|
96
|
+
* shows the invalid JSON with inline error comments, helping the LLM
|
|
97
|
+
* understand and correct its mistakes in the next turn.
|
|
98
|
+
*
|
|
99
|
+
* @param args The arguments generated by the LLM
|
|
100
|
+
* @returns Validation result with success status and any errors
|
|
101
|
+
* @see stringifyValidationFailure Format errors for LLM auto-correction
|
|
102
|
+
*/
|
|
103
|
+
validate: (args: unknown) => IValidation<unknown>;
|
|
104
|
+
}
|
|
105
|
+
export namespace ILlmFunction {
|
|
106
|
+
/**
|
|
107
|
+
* Separated parameter schemas for hybrid LLM/human input.
|
|
108
|
+
*
|
|
109
|
+
* When a function has parameters that cannot or should not be filled by the
|
|
110
|
+
* LLM (e.g., file uploads, passwords, sensitive data), the parameters are
|
|
111
|
+
* split into two schemas.
|
|
112
|
+
*/
|
|
113
|
+
export interface ISeparated {
|
|
114
|
+
/**
|
|
115
|
+
* Parameters the LLM should fill.
|
|
116
|
+
*
|
|
117
|
+
* Contains only the parameters that are safe and appropriate for the LLM to
|
|
118
|
+
* generate values for.
|
|
119
|
+
*/
|
|
120
|
+
llm: ILlmSchema.IParameters;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Parameters requiring human input.
|
|
124
|
+
*
|
|
125
|
+
* Contains parameters that must be provided by the user directly, such as
|
|
126
|
+
* file uploads, passwords, or other sensitive data. `null` when all
|
|
127
|
+
* parameters can be filled by the LLM.
|
|
128
|
+
*/
|
|
129
|
+
human: ILlmSchema.IParameters | null;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Validates the LLM portion of separated parameters.
|
|
133
|
+
*
|
|
134
|
+
* Validates only the LLM-fillable portion, allowing human parameters to be
|
|
135
|
+
* validated separately with appropriate handling.
|
|
136
|
+
*
|
|
137
|
+
* When validation fails, use `stringifyValidationFailure()` from
|
|
138
|
+
* `@typia/utils` to format the error for LLM feedback.
|
|
139
|
+
*
|
|
140
|
+
* @see stringifyValidationFailure Format errors for LLM auto-correction
|
|
141
|
+
*/
|
|
142
|
+
validate?: ((args: unknown) => IValidation<unknown>) | undefined;
|
|
143
|
+
}
|
|
144
|
+
}
|