@typia/interface 12.0.0-dev.20260309 → 12.0.0-dev.20260310

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 (83) hide show
  1. package/lib/http/IHttpLlmController.d.ts +5 -5
  2. package/lib/schema/IJsonParseResult.d.ts +1 -3
  3. package/lib/schema/ILlmController.d.ts +2 -5
  4. package/package.json +1 -1
  5. package/src/http/IHttpConnection.ts +200 -200
  6. package/src/http/IHttpLlmApplication.ts +72 -72
  7. package/src/http/IHttpLlmController.ts +96 -96
  8. package/src/http/IHttpLlmFunction.ts +34 -34
  9. package/src/http/IHttpMigrateApplication.ts +48 -48
  10. package/src/http/IHttpMigrateRoute.ts +165 -165
  11. package/src/http/IHttpResponse.ts +42 -42
  12. package/src/http/index.ts +7 -7
  13. package/src/index.ts +9 -9
  14. package/src/metadata/IJsDocTagInfo.ts +25 -25
  15. package/src/metadata/IMetadataComponents.ts +24 -24
  16. package/src/metadata/IMetadataSchema.ts +293 -293
  17. package/src/metadata/IMetadataSchemaCollection.ts +20 -20
  18. package/src/metadata/IMetadataSchemaUnit.ts +20 -20
  19. package/src/metadata/IMetadataTypeTag.ts +39 -39
  20. package/src/metadata/index.ts +6 -6
  21. package/src/openapi/OpenApi.ts +643 -643
  22. package/src/openapi/OpenApiV3.ts +655 -655
  23. package/src/openapi/OpenApiV3_1.ts +735 -735
  24. package/src/openapi/SwaggerV2.ts +559 -559
  25. package/src/openapi/index.ts +4 -4
  26. package/src/protobuf/ProtobufWire.ts +51 -51
  27. package/src/protobuf/index.ts +1 -1
  28. package/src/schema/IJsonParseResult.ts +134 -136
  29. package/src/schema/IJsonSchemaApplication.ts +274 -274
  30. package/src/schema/IJsonSchemaAttribute.ts +158 -158
  31. package/src/schema/IJsonSchemaCollection.ts +123 -123
  32. package/src/schema/IJsonSchemaTransformError.ts +86 -86
  33. package/src/schema/IJsonSchemaUnit.ts +120 -120
  34. package/src/schema/ILlmApplication.ts +99 -99
  35. package/src/schema/ILlmController.ts +54 -57
  36. package/src/schema/ILlmFunction.ts +145 -145
  37. package/src/schema/ILlmSchema.ts +484 -484
  38. package/src/schema/IResult.ts +84 -84
  39. package/src/schema/IValidation.ts +134 -134
  40. package/src/schema/index.ts +14 -14
  41. package/src/tags/Constant.ts +49 -49
  42. package/src/tags/ContentMediaType.ts +40 -40
  43. package/src/tags/Default.ts +50 -50
  44. package/src/tags/Example.ts +48 -48
  45. package/src/tags/Examples.ts +50 -50
  46. package/src/tags/ExclusiveMaximum.ts +46 -46
  47. package/src/tags/ExclusiveMinimum.ts +46 -46
  48. package/src/tags/Format.ts +76 -76
  49. package/src/tags/JsonSchemaPlugin.ts +45 -45
  50. package/src/tags/MaxItems.ts +39 -39
  51. package/src/tags/MaxLength.ts +37 -37
  52. package/src/tags/Maximum.ts +44 -44
  53. package/src/tags/MinItems.ts +39 -39
  54. package/src/tags/MinLength.ts +37 -37
  55. package/src/tags/Minimum.ts +44 -44
  56. package/src/tags/MultipleOf.ts +54 -54
  57. package/src/tags/Pattern.ts +59 -59
  58. package/src/tags/Sequence.ts +43 -43
  59. package/src/tags/TagBase.ts +131 -131
  60. package/src/tags/Type.ts +70 -70
  61. package/src/tags/UniqueItems.ts +44 -44
  62. package/src/tags/index.ts +21 -21
  63. package/src/typings/AssertionGuard.ts +12 -12
  64. package/src/typings/Atomic.ts +21 -21
  65. package/src/typings/CamelCase.ts +75 -75
  66. package/src/typings/ClassProperties.ts +15 -15
  67. package/src/typings/DeepPartial.ts +39 -39
  68. package/src/typings/OmitNever.ts +12 -12
  69. package/src/typings/PascalCase.ts +71 -71
  70. package/src/typings/Primitive.ts +71 -71
  71. package/src/typings/ProtobufAtomic.ts +30 -30
  72. package/src/typings/Resolved.ts +58 -58
  73. package/src/typings/SnakeCase.ts +126 -126
  74. package/src/typings/SpecialFields.ts +13 -13
  75. package/src/typings/ValidationPipe.ts +20 -20
  76. package/src/typings/index.ts +14 -14
  77. package/src/typings/internal/Equal.ts +14 -14
  78. package/src/typings/internal/IsTuple.ts +17 -17
  79. package/src/typings/internal/NativeClass.ts +31 -31
  80. package/src/typings/internal/ValueOf.ts +29 -29
  81. package/src/utils/IRandomGenerator.ts +105 -105
  82. package/src/utils/IReadableURLSearchParams.ts +25 -25
  83. package/src/utils/index.ts +2 -2
@@ -1,86 +1,86 @@
1
- import { OpenApi } from "../openapi";
2
-
3
- /**
4
- * Error information from JSON schema transformation.
5
- *
6
- * `IJsonSchemaTransformError` represents an error that occurred during
7
- * transformation or iteration of {@link OpenApi.IJsonSchema} types. This error
8
- * type is primarily generated when converting OpenAPI schemas to LLM-compatible
9
- * formats via {@link ILlmSchema}.
10
- *
11
- * Common transformation failures include:
12
- *
13
- * - **Missing references**: `$ref` pointing to non-existent schema definitions
14
- * - **Unsupported tuple types**: All LLM providers reject tuple schemas
15
- * - **Unsupported union types**: Gemini does not support `oneOf` schemas
16
- * - **Unsupported dynamic objects**: ChatGPT and Gemini reject
17
- * `additionalProperties`
18
- *
19
- * The {@link reasons} array provides detailed information about each failure,
20
- * including the problematic schema, its location path, and a human-readable
21
- * error message. Use this information to diagnose and fix schema compatibility
22
- * issues.
23
- *
24
- * @author Jeongho Nam - https://github.com/samchon
25
- */
26
- export interface IJsonSchemaTransformError {
27
- /**
28
- * Name of the method that caused the error.
29
- *
30
- * Identifies which transformation function failed, such as
31
- * `"HttpLlm.application"` or `"LlmSchemaConverter.schema"`.
32
- */
33
- method: string;
34
-
35
- /**
36
- * Summary error message.
37
- *
38
- * A human-readable description of the overall error. For detailed information
39
- * about specific failures, examine the {@link reasons} array.
40
- */
41
- message: string;
42
-
43
- /**
44
- * Detailed list of transformation failures.
45
- *
46
- * Each entry describes a specific schema that failed transformation,
47
- * including its location and the reason for failure. Multiple failures can
48
- * occur in a single transformation when processing complex schemas.
49
- */
50
- reasons: IJsonSchemaTransformError.IReason[];
51
- }
52
- export namespace IJsonSchemaTransformError {
53
- /**
54
- * Detailed information about a single transformation failure.
55
- *
56
- * Provides the specific schema that failed, its accessor path for locating it
57
- * within the document, and a message explaining why the transformation
58
- * failed.
59
- */
60
- export interface IReason {
61
- /**
62
- * The schema that caused the transformation failure.
63
- *
64
- * The actual JSON schema object that could not be transformed. Inspect this
65
- * to understand the problematic schema structure.
66
- */
67
- schema: OpenApi.IJsonSchema;
68
-
69
- /**
70
- * Path to the failing schema within the document.
71
- *
72
- * A dot-notation path (e.g., `"components.schemas.User.properties.tags"`)
73
- * that identifies where the problematic schema is located. Use this to
74
- * locate and fix the issue in the source OpenAPI document.
75
- */
76
- accessor: string;
77
-
78
- /**
79
- * Human-readable explanation of the failure.
80
- *
81
- * Describes why the schema could not be transformed, such as "Tuple type is
82
- * not supported" or "Cannot resolve $ref reference".
83
- */
84
- message: string;
85
- }
86
- }
1
+ import { OpenApi } from "../openapi";
2
+
3
+ /**
4
+ * Error information from JSON schema transformation.
5
+ *
6
+ * `IJsonSchemaTransformError` represents an error that occurred during
7
+ * transformation or iteration of {@link OpenApi.IJsonSchema} types. This error
8
+ * type is primarily generated when converting OpenAPI schemas to LLM-compatible
9
+ * formats via {@link ILlmSchema}.
10
+ *
11
+ * Common transformation failures include:
12
+ *
13
+ * - **Missing references**: `$ref` pointing to non-existent schema definitions
14
+ * - **Unsupported tuple types**: All LLM providers reject tuple schemas
15
+ * - **Unsupported union types**: Gemini does not support `oneOf` schemas
16
+ * - **Unsupported dynamic objects**: ChatGPT and Gemini reject
17
+ * `additionalProperties`
18
+ *
19
+ * The {@link reasons} array provides detailed information about each failure,
20
+ * including the problematic schema, its location path, and a human-readable
21
+ * error message. Use this information to diagnose and fix schema compatibility
22
+ * issues.
23
+ *
24
+ * @author Jeongho Nam - https://github.com/samchon
25
+ */
26
+ export interface IJsonSchemaTransformError {
27
+ /**
28
+ * Name of the method that caused the error.
29
+ *
30
+ * Identifies which transformation function failed, such as
31
+ * `"HttpLlm.application"` or `"LlmSchemaConverter.schema"`.
32
+ */
33
+ method: string;
34
+
35
+ /**
36
+ * Summary error message.
37
+ *
38
+ * A human-readable description of the overall error. For detailed information
39
+ * about specific failures, examine the {@link reasons} array.
40
+ */
41
+ message: string;
42
+
43
+ /**
44
+ * Detailed list of transformation failures.
45
+ *
46
+ * Each entry describes a specific schema that failed transformation,
47
+ * including its location and the reason for failure. Multiple failures can
48
+ * occur in a single transformation when processing complex schemas.
49
+ */
50
+ reasons: IJsonSchemaTransformError.IReason[];
51
+ }
52
+ export namespace IJsonSchemaTransformError {
53
+ /**
54
+ * Detailed information about a single transformation failure.
55
+ *
56
+ * Provides the specific schema that failed, its accessor path for locating it
57
+ * within the document, and a message explaining why the transformation
58
+ * failed.
59
+ */
60
+ export interface IReason {
61
+ /**
62
+ * The schema that caused the transformation failure.
63
+ *
64
+ * The actual JSON schema object that could not be transformed. Inspect this
65
+ * to understand the problematic schema structure.
66
+ */
67
+ schema: OpenApi.IJsonSchema;
68
+
69
+ /**
70
+ * Path to the failing schema within the document.
71
+ *
72
+ * A dot-notation path (e.g., `"components.schemas.User.properties.tags"`)
73
+ * that identifies where the problematic schema is located. Use this to
74
+ * locate and fix the issue in the source OpenAPI document.
75
+ */
76
+ accessor: string;
77
+
78
+ /**
79
+ * Human-readable explanation of the failure.
80
+ *
81
+ * Describes why the schema could not be transformed, such as "Tuple type is
82
+ * not supported" or "Cannot resolve $ref reference".
83
+ */
84
+ message: string;
85
+ }
86
+ }
@@ -1,120 +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
- }
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
+ }
@@ -1,99 +1,99 @@
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.validate}: Custom validation per method
15
- * - {@link ILlmSchema.IConfig.strict}: OpenAI structured output mode
16
- * - {@link ILlmSchema.IConfig.reference}: Control `$ref` inlining behavior
17
- *
18
- * @author Jeongho Nam - https://github.com/samchon
19
- * @template Class Source class/interface type
20
- */
21
- export interface ILlmApplication<Class extends object = any> {
22
- /**
23
- * Array of callable function schemas.
24
- *
25
- * Each function represents a method from the source class that the LLM can
26
- * invoke. Functions include parameter schemas, descriptions, and validation
27
- * logic for type-safe function calling.
28
- */
29
- functions: ILlmFunction[];
30
-
31
- /**
32
- * Configuration used to generate this application.
33
- *
34
- * Contains the settings that were applied during schema generation, including
35
- * reference handling, strict mode, and parameter separation.
36
- */
37
- config: ILlmApplication.IConfig<Class>;
38
-
39
- /**
40
- * Phantom property for TypeScript generic type preservation.
41
- *
42
- * This property exists only in the type system to preserve the `Class`
43
- * generic parameter at compile time. It is always `undefined` at runtime and
44
- * should not be accessed or used in application code.
45
- *
46
- * This pattern enables type inference to recover the original class type from
47
- * an `ILlmApplication` instance, useful for type-safe function routing.
48
- */
49
- __class?: Class | undefined;
50
- }
51
- export namespace ILlmApplication {
52
- /**
53
- * Configuration for LLM application generation.
54
- *
55
- * Extends {@link ILlmSchema.IConfig} with application-specific options for
56
- * custom validation. These settings control how the application schema is
57
- * generated from the source class.
58
- */
59
- export interface IConfig<Class extends object = any>
60
- extends ILlmSchema.IConfig {
61
- /**
62
- * Custom validation functions per method name.
63
- *
64
- * Allows overriding the default type-based validation with custom business
65
- * logic. Useful for complex validation rules that cannot be expressed in
66
- * JSON Schema.
67
- *
68
- * @default null (use default type validation)
69
- */
70
- validate: null | Partial<ILlmApplication.IValidationHook<Class>>;
71
- }
72
-
73
- /**
74
- * Type-safe mapping of method names to custom validators.
75
- *
76
- * Maps each method name to a validation function that receives the raw input
77
- * and returns a validation result. The type inference ensures validators
78
- * match the expected argument types.
79
- *
80
- * @template Class - The source class type for type inference
81
- */
82
- export type IValidationHook<Class extends object> = {
83
- [K in keyof Class]?: Class[K] extends (args: infer Argument) => unknown
84
- ? (input: unknown) => IValidation<Argument>
85
- : never;
86
- };
87
-
88
- /**
89
- * Internal type for typia transformer.
90
- *
91
- * @ignore
92
- */
93
- export interface __IPrimitive<Class extends object = any> extends Omit<
94
- ILlmApplication<Class>,
95
- "config" | "functions"
96
- > {
97
- functions: Omit<ILlmFunction, "parse" | "coerce">[];
98
- }
99
- }
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.validate}: Custom validation per method
15
+ * - {@link ILlmSchema.IConfig.strict}: OpenAI structured output mode
16
+ * - {@link ILlmSchema.IConfig.reference}: Control `$ref` inlining behavior
17
+ *
18
+ * @author Jeongho Nam - https://github.com/samchon
19
+ * @template Class Source class/interface type
20
+ */
21
+ export interface ILlmApplication<Class extends object = any> {
22
+ /**
23
+ * Array of callable function schemas.
24
+ *
25
+ * Each function represents a method from the source class that the LLM can
26
+ * invoke. Functions include parameter schemas, descriptions, and validation
27
+ * logic for type-safe function calling.
28
+ */
29
+ functions: ILlmFunction[];
30
+
31
+ /**
32
+ * Configuration used to generate this application.
33
+ *
34
+ * Contains the settings that were applied during schema generation, including
35
+ * reference handling, strict mode, and parameter separation.
36
+ */
37
+ config: ILlmApplication.IConfig<Class>;
38
+
39
+ /**
40
+ * Phantom property for TypeScript generic type preservation.
41
+ *
42
+ * This property exists only in the type system to preserve the `Class`
43
+ * generic parameter at compile time. It is always `undefined` at runtime and
44
+ * should not be accessed or used in application code.
45
+ *
46
+ * This pattern enables type inference to recover the original class type from
47
+ * an `ILlmApplication` instance, useful for type-safe function routing.
48
+ */
49
+ __class?: Class | undefined;
50
+ }
51
+ export namespace ILlmApplication {
52
+ /**
53
+ * Configuration for LLM application generation.
54
+ *
55
+ * Extends {@link ILlmSchema.IConfig} with application-specific options for
56
+ * custom validation. These settings control how the application schema is
57
+ * generated from the source class.
58
+ */
59
+ export interface IConfig<Class extends object = any>
60
+ extends ILlmSchema.IConfig {
61
+ /**
62
+ * Custom validation functions per method name.
63
+ *
64
+ * Allows overriding the default type-based validation with custom business
65
+ * logic. Useful for complex validation rules that cannot be expressed in
66
+ * JSON Schema.
67
+ *
68
+ * @default null (use default type validation)
69
+ */
70
+ validate: null | Partial<ILlmApplication.IValidationHook<Class>>;
71
+ }
72
+
73
+ /**
74
+ * Type-safe mapping of method names to custom validators.
75
+ *
76
+ * Maps each method name to a validation function that receives the raw input
77
+ * and returns a validation result. The type inference ensures validators
78
+ * match the expected argument types.
79
+ *
80
+ * @template Class - The source class type for type inference
81
+ */
82
+ export type IValidationHook<Class extends object> = {
83
+ [K in keyof Class]?: Class[K] extends (args: infer Argument) => unknown
84
+ ? (input: unknown) => IValidation<Argument>
85
+ : never;
86
+ };
87
+
88
+ /**
89
+ * Internal type for typia transformer.
90
+ *
91
+ * @ignore
92
+ */
93
+ export interface __IPrimitive<Class extends object = any> extends Omit<
94
+ ILlmApplication<Class>,
95
+ "config" | "functions"
96
+ > {
97
+ functions: Omit<ILlmFunction, "parse" | "coerce">[];
98
+ }
99
+ }