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

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 (85) hide show
  1. package/lib/http/IHttpLlmController.d.ts +5 -5
  2. package/lib/schema/IJsonParseResult.d.ts +1 -3
  3. package/lib/schema/ILlmApplication.d.ts +1 -2
  4. package/lib/schema/ILlmController.d.ts +2 -5
  5. package/lib/schema/ILlmSchema.d.ts +1 -11
  6. package/package.json +1 -1
  7. package/src/http/IHttpConnection.ts +200 -200
  8. package/src/http/IHttpLlmApplication.ts +72 -72
  9. package/src/http/IHttpLlmController.ts +96 -96
  10. package/src/http/IHttpLlmFunction.ts +34 -34
  11. package/src/http/IHttpMigrateApplication.ts +48 -48
  12. package/src/http/IHttpMigrateRoute.ts +165 -165
  13. package/src/http/IHttpResponse.ts +42 -42
  14. package/src/http/index.ts +7 -7
  15. package/src/index.ts +9 -9
  16. package/src/metadata/IJsDocTagInfo.ts +25 -25
  17. package/src/metadata/IMetadataComponents.ts +24 -24
  18. package/src/metadata/IMetadataSchema.ts +293 -293
  19. package/src/metadata/IMetadataSchemaCollection.ts +20 -20
  20. package/src/metadata/IMetadataSchemaUnit.ts +20 -20
  21. package/src/metadata/IMetadataTypeTag.ts +39 -39
  22. package/src/metadata/index.ts +6 -6
  23. package/src/openapi/OpenApi.ts +643 -643
  24. package/src/openapi/OpenApiV3.ts +655 -655
  25. package/src/openapi/OpenApiV3_1.ts +735 -735
  26. package/src/openapi/SwaggerV2.ts +559 -559
  27. package/src/openapi/index.ts +4 -4
  28. package/src/protobuf/ProtobufWire.ts +51 -51
  29. package/src/protobuf/index.ts +1 -1
  30. package/src/schema/IJsonParseResult.ts +134 -136
  31. package/src/schema/IJsonSchemaApplication.ts +274 -274
  32. package/src/schema/IJsonSchemaAttribute.ts +158 -158
  33. package/src/schema/IJsonSchemaCollection.ts +123 -123
  34. package/src/schema/IJsonSchemaTransformError.ts +86 -86
  35. package/src/schema/IJsonSchemaUnit.ts +120 -120
  36. package/src/schema/ILlmApplication.ts +98 -99
  37. package/src/schema/ILlmController.ts +54 -57
  38. package/src/schema/ILlmFunction.ts +145 -145
  39. package/src/schema/ILlmSchema.ts +473 -484
  40. package/src/schema/IResult.ts +84 -84
  41. package/src/schema/IValidation.ts +134 -134
  42. package/src/schema/index.ts +14 -14
  43. package/src/tags/Constant.ts +49 -49
  44. package/src/tags/ContentMediaType.ts +40 -40
  45. package/src/tags/Default.ts +50 -50
  46. package/src/tags/Example.ts +48 -48
  47. package/src/tags/Examples.ts +50 -50
  48. package/src/tags/ExclusiveMaximum.ts +46 -46
  49. package/src/tags/ExclusiveMinimum.ts +46 -46
  50. package/src/tags/Format.ts +76 -76
  51. package/src/tags/JsonSchemaPlugin.ts +45 -45
  52. package/src/tags/MaxItems.ts +39 -39
  53. package/src/tags/MaxLength.ts +37 -37
  54. package/src/tags/Maximum.ts +44 -44
  55. package/src/tags/MinItems.ts +39 -39
  56. package/src/tags/MinLength.ts +37 -37
  57. package/src/tags/Minimum.ts +44 -44
  58. package/src/tags/MultipleOf.ts +54 -54
  59. package/src/tags/Pattern.ts +59 -59
  60. package/src/tags/Sequence.ts +43 -43
  61. package/src/tags/TagBase.ts +131 -131
  62. package/src/tags/Type.ts +70 -70
  63. package/src/tags/UniqueItems.ts +44 -44
  64. package/src/tags/index.ts +21 -21
  65. package/src/typings/AssertionGuard.ts +12 -12
  66. package/src/typings/Atomic.ts +21 -21
  67. package/src/typings/CamelCase.ts +75 -75
  68. package/src/typings/ClassProperties.ts +15 -15
  69. package/src/typings/DeepPartial.ts +39 -39
  70. package/src/typings/OmitNever.ts +12 -12
  71. package/src/typings/PascalCase.ts +71 -71
  72. package/src/typings/Primitive.ts +71 -71
  73. package/src/typings/ProtobufAtomic.ts +30 -30
  74. package/src/typings/Resolved.ts +58 -58
  75. package/src/typings/SnakeCase.ts +126 -126
  76. package/src/typings/SpecialFields.ts +13 -13
  77. package/src/typings/ValidationPipe.ts +20 -20
  78. package/src/typings/index.ts +14 -14
  79. package/src/typings/internal/Equal.ts +14 -14
  80. package/src/typings/internal/IsTuple.ts +17 -17
  81. package/src/typings/internal/NativeClass.ts +31 -31
  82. package/src/typings/internal/ValueOf.ts +29 -29
  83. package/src/utils/IRandomGenerator.ts +105 -105
  84. package/src/utils/IReadableURLSearchParams.ts +25 -25
  85. package/src/utils/index.ts +2 -2
@@ -1,484 +1,473 @@
1
- import { tags } from "../index";
2
- import { IJsonSchemaAttribute } from "./IJsonSchemaAttribute";
3
-
4
- /**
5
- * Type schema for LLM function calling.
6
- *
7
- * `ILlmSchema` is a JSON Schema subset designed for LLM function calling
8
- * compatibility. Most LLMs (OpenAI GPT, Anthropic Claude, Google Gemini, etc.)
9
- * do not fully support JSON Schema, so this simplified schema omits unsupported
10
- * features like tuples, `const`, and mixed union types.
11
- *
12
- * Generated by `typia.llm.schema<T>()` for single types or included in
13
- * {@link ILlmApplication} via `typia.llm.application<Class>()`. Shared type
14
- * definitions use `$defs` with `$ref` references to reduce duplication and
15
- * handle recursive structures.
16
- *
17
- * Set {@link ILlmSchema.IConfig.strict} to `true` for OpenAI's structured output
18
- * mode, which requires all properties to be `required` and
19
- * `additionalProperties: false`.
20
- *
21
- * @author Jeongho Nam - https://github.com/samchon
22
- */
23
- export type ILlmSchema =
24
- | ILlmSchema.IBoolean
25
- | ILlmSchema.IInteger
26
- | ILlmSchema.INumber
27
- | ILlmSchema.IString
28
- | ILlmSchema.IArray
29
- | ILlmSchema.IObject
30
- | ILlmSchema.IReference
31
- | ILlmSchema.IAnyOf
32
- | ILlmSchema.INull
33
- | ILlmSchema.IUnknown;
34
- export namespace ILlmSchema {
35
- /**
36
- * Configuration options for LLM schema generation.
37
- *
38
- * Controls how TypeScript types are converted to LLM-compatible JSON schemas.
39
- * These settings affect reference handling and OpenAI structured output
40
- * compatibility.
41
- */
42
- export interface IConfig {
43
- /**
44
- * Whether to allow `$ref` references everywhere.
45
- *
46
- * When `false`, references are inlined except for recursive types.
47
- * References reduce token cost but may cause hallucination.
48
- *
49
- * @default true
50
- */
51
- reference: boolean;
52
-
53
- /**
54
- * Whether to enable strict mode (OpenAI structured output).
55
- *
56
- * When `true`, all properties become required and `additionalProperties` is
57
- * forced to `false`.
58
- *
59
- * @default false
60
- */
61
- strict: boolean;
62
- }
63
-
64
- /**
65
- * Function parameters schema with shared type definitions.
66
- *
67
- * Extends the object schema to include a `$defs` map for named type
68
- * definitions that can be referenced via `$ref`. This structure allows
69
- * recursive types and reduces schema duplication.
70
- *
71
- * The `additionalProperties` is always `false` for parameters to ensure
72
- * strict argument validation and prevent unexpected properties.
73
- */
74
- export interface IParameters extends Omit<IObject, "additionalProperties"> {
75
- /**
76
- * Named schema definitions for reference.
77
- *
78
- * Contains type definitions that can be referenced throughout the schema
79
- * using `$ref: "#/$defs/TypeName"`. Essential for recursive types and
80
- * shared structures.
81
- */
82
- $defs: Record<string, ILlmSchema>;
83
-
84
- /**
85
- * Whether additional properties are allowed.
86
- *
87
- * Always `false` for function parameters to ensure strict type checking.
88
- * This prevents LLMs from hallucinating extra properties.
89
- */
90
- additionalProperties: false;
91
- }
92
-
93
- /**
94
- * Boolean type schema.
95
- *
96
- * Represents a JSON Schema boolean type with optional enum constraints and
97
- * default value. Used for true/false parameters and flags.
98
- */
99
- export interface IBoolean extends IJsonSchemaAttribute.IBoolean {
100
- /**
101
- * Allowed boolean values.
102
- *
103
- * Restricts the value to specific boolean literals. Typically unused since
104
- * booleans only have two possible values, but supported for consistency
105
- * with other types.
106
- */
107
- enum?: Array<boolean>;
108
-
109
- /**
110
- * Default value when not provided.
111
- *
112
- * The boolean value to use when the LLM omits this parameter.
113
- */
114
- default?: boolean;
115
- }
116
-
117
- /**
118
- * Integer type schema.
119
- *
120
- * Represents a JSON Schema integer type with numeric constraints. Maps to
121
- * TypeScript `number` with integer validation. Supports range constraints,
122
- * enum restrictions, and divisibility checks.
123
- */
124
- export interface IInteger extends IJsonSchemaAttribute.IInteger {
125
- /**
126
- * Allowed integer values.
127
- *
128
- * Restricts the value to specific integer literals. Useful for representing
129
- * enum-like integer codes or limited value sets.
130
- */
131
- enum?: Array<number & tags.Type<"int64">>;
132
-
133
- /**
134
- * Default value when not provided.
135
- *
136
- * The integer value to use when the LLM omits this parameter.
137
- */
138
- default?: number & tags.Type<"int64">;
139
-
140
- /**
141
- * Minimum value (inclusive).
142
- *
143
- * The value must be greater than or equal to this number.
144
- */
145
- minimum?: number & tags.Type<"int64">;
146
-
147
- /**
148
- * Maximum value (inclusive).
149
- *
150
- * The value must be less than or equal to this number.
151
- */
152
- maximum?: number & tags.Type<"int64">;
153
-
154
- /**
155
- * Exclusive minimum value.
156
- *
157
- * The value must be strictly greater than this number.
158
- */
159
- exclusiveMinimum?: number & tags.Type<"int64">;
160
-
161
- /**
162
- * Exclusive maximum value.
163
- *
164
- * The value must be strictly less than this number.
165
- */
166
- exclusiveMaximum?: number & tags.Type<"int64">;
167
-
168
- /**
169
- * Value must be divisible by this number.
170
- *
171
- * Used for constraints like "must be even" (multipleOf: 2) or "must be a
172
- * multiple of 100" (multipleOf: 100).
173
- */
174
- multipleOf?: number & tags.Type<"uint64"> & tags.ExclusiveMinimum<0>;
175
- }
176
-
177
- /**
178
- * Number (floating-point) type schema.
179
- *
180
- * Represents a JSON Schema number type for floating-point values. Maps to
181
- * TypeScript `number` type. Supports range constraints, enum restrictions,
182
- * and precision checks via multipleOf.
183
- */
184
- export interface INumber extends IJsonSchemaAttribute.INumber {
185
- /**
186
- * Allowed numeric values.
187
- *
188
- * Restricts the value to specific number literals. Useful for representing
189
- * specific valid values like percentages or rates.
190
- */
191
- enum?: Array<number>;
192
-
193
- /**
194
- * Default value when not provided.
195
- *
196
- * The number to use when the LLM omits this parameter.
197
- */
198
- default?: number;
199
-
200
- /**
201
- * Minimum value (inclusive).
202
- *
203
- * The value must be greater than or equal to this number.
204
- */
205
- minimum?: number;
206
-
207
- /**
208
- * Maximum value (inclusive).
209
- *
210
- * The value must be less than or equal to this number.
211
- */
212
- maximum?: number;
213
-
214
- /**
215
- * Exclusive minimum value.
216
- *
217
- * The value must be strictly greater than this number.
218
- */
219
- exclusiveMinimum?: number;
220
-
221
- /**
222
- * Exclusive maximum value.
223
- *
224
- * The value must be strictly less than this number.
225
- */
226
- exclusiveMaximum?: number;
227
-
228
- /**
229
- * Value must be divisible by this number.
230
- *
231
- * Useful for decimal precision constraints like "two decimal places"
232
- * (multipleOf: 0.01) or currency amounts (multipleOf: 0.01).
233
- */
234
- multipleOf?: number & tags.ExclusiveMinimum<0>;
235
- }
236
-
237
- /**
238
- * String type schema.
239
- *
240
- * Represents a JSON Schema string type with format validation, pattern
241
- * matching, and length constraints. Maps to TypeScript `string` type with
242
- * optional semantic format annotations.
243
- */
244
- export interface IString extends IJsonSchemaAttribute.IString {
245
- /**
246
- * Allowed string values.
247
- *
248
- * Restricts the value to specific string literals. Maps directly to
249
- * TypeScript string literal union types.
250
- */
251
- enum?: Array<string>;
252
-
253
- /**
254
- * Default value when not provided.
255
- *
256
- * The string to use when the LLM omits this parameter.
257
- */
258
- default?: string;
259
-
260
- /**
261
- * Semantic format specifier.
262
- *
263
- * Indicates the string represents a specific format like email, UUID, or
264
- * date-time. LLMs may use this to generate appropriate values. Common
265
- * formats include "email", "uri", "uuid", "date-time".
266
- */
267
- format?:
268
- | "binary"
269
- | "byte"
270
- | "password"
271
- | "regex"
272
- | "uuid"
273
- | "email"
274
- | "hostname"
275
- | "idn-email"
276
- | "idn-hostname"
277
- | "iri"
278
- | "iri-reference"
279
- | "ipv4"
280
- | "ipv6"
281
- | "uri"
282
- | "uri-reference"
283
- | "uri-template"
284
- | "url"
285
- | "date-time"
286
- | "date"
287
- | "time"
288
- | "duration"
289
- | "json-pointer"
290
- | "relative-json-pointer"
291
- | (string & {});
292
-
293
- /**
294
- * Regular expression pattern for validation.
295
- *
296
- * The string must match this regex pattern. Note that LLMs may struggle
297
- * with complex regex patterns; simple patterns work best.
298
- */
299
- pattern?: string;
300
-
301
- /**
302
- * MIME type of the string content.
303
- *
304
- * Indicates the content type when the string contains encoded binary data,
305
- * such as "application/json" or "image/png".
306
- */
307
- contentMediaType?: string;
308
-
309
- /**
310
- * Minimum string length.
311
- *
312
- * The string must have at least this many characters.
313
- */
314
- minLength?: number & tags.Type<"uint64">;
315
-
316
- /**
317
- * Maximum string length.
318
- *
319
- * The string must have at most this many characters.
320
- */
321
- maxLength?: number & tags.Type<"uint64">;
322
- }
323
-
324
- /**
325
- * Array type schema.
326
- *
327
- * Represents a JSON Schema array type with item type validation and size
328
- * constraints. Maps to TypeScript `T[]` or `Array<T>` types. Note: Tuple
329
- * types are not supported by LLM schemas.
330
- */
331
- export interface IArray extends IJsonSchemaAttribute.IArray {
332
- /**
333
- * Schema for array elements.
334
- *
335
- * All elements in the array must conform to this schema. For heterogeneous
336
- * arrays, use an `anyOf` schema.
337
- */
338
- items: ILlmSchema;
339
-
340
- /**
341
- * Whether elements must be unique.
342
- *
343
- * When `true`, no two elements may be equal. Maps to TypeScript `Set<T>`
344
- * semantics but represented as an array.
345
- */
346
- uniqueItems?: boolean;
347
-
348
- /**
349
- * Minimum number of elements.
350
- *
351
- * The array must contain at least this many items.
352
- */
353
- minItems?: number & tags.Type<"uint64">;
354
-
355
- /**
356
- * Maximum number of elements.
357
- *
358
- * The array must contain at most this many items.
359
- */
360
- maxItems?: number & tags.Type<"uint64">;
361
- }
362
-
363
- /**
364
- * Object type schema.
365
- *
366
- * Represents a JSON Schema object type with named properties. Maps to
367
- * TypeScript interface or object type. Supports required property
368
- * declarations and dynamic additional properties.
369
- */
370
- export interface IObject extends IJsonSchemaAttribute.IObject {
371
- /**
372
- * Property name to schema mapping.
373
- *
374
- * Defines the type of each named property on the object. All properties are
375
- * defined here regardless of whether they are required or optional.
376
- */
377
- properties: Record<string, ILlmSchema>;
378
-
379
- /**
380
- * Schema for dynamic/additional properties.
381
- *
382
- * - `false` (default): No additional properties allowed
383
- * - `true`: Any additional properties allowed
384
- * - Schema: Additional properties must match this schema
385
- *
386
- * Note: ChatGPT and Gemini do not support `additionalProperties`. Use
387
- * {@link ILlmSchema.IConfig.strict} mode for OpenAI compatibility.
388
- */
389
- additionalProperties?: ILlmSchema | boolean;
390
-
391
- /**
392
- * List of required property names.
393
- *
394
- * Properties in this array must be present in the object. In strict mode,
395
- * all properties become required automatically.
396
- */
397
- required: string[];
398
- }
399
-
400
- /**
401
- * Reference to a named schema definition.
402
- *
403
- * Points to a schema defined in the `$defs` map using a JSON pointer. Used to
404
- * avoid schema duplication and enable recursive type definitions. The
405
- * reference path format is `#/$defs/TypeName`.
406
- */
407
- export interface IReference extends IJsonSchemaAttribute {
408
- /**
409
- * JSON pointer to the referenced schema.
410
- *
411
- * Must be in the format `#/$defs/TypeName` where TypeName is a key in the
412
- * parent schema's `$defs` map.
413
- */
414
- $ref: string;
415
- }
416
-
417
- /**
418
- * Union type schema (A | B | C).
419
- *
420
- * Represents a TypeScript union type where the value can match any one of the
421
- * member schemas. Note: Gemini does not support `anyOf`/`oneOf` schemas. Use
422
- * discriminated unions with `x-discriminator` when possible for better LLM
423
- * comprehension.
424
- */
425
- export interface IAnyOf extends IJsonSchemaAttribute {
426
- /**
427
- * Array of possible schemas.
428
- *
429
- * The value must match at least one of these schemas. Nested `anyOf`
430
- * schemas are flattened to avoid deep nesting.
431
- */
432
- anyOf: Exclude<ILlmSchema, ILlmSchema.IAnyOf>[];
433
-
434
- /**
435
- * Discriminator for tagged/discriminated unions.
436
- *
437
- * Helps LLMs understand which variant to select based on a discriminating
438
- * property value. Improves type inference accuracy.
439
- */
440
- "x-discriminator"?: IAnyOf.IDiscriminator;
441
- }
442
- export namespace IAnyOf {
443
- /**
444
- * Discriminator configuration for tagged unions.
445
- *
446
- * Specifies which property distinguishes between union variants and maps
447
- * discriminator values to their corresponding schemas.
448
- */
449
- export interface IDiscriminator {
450
- /**
451
- * Name of the discriminating property.
452
- *
453
- * This property must exist on all union member object schemas and contain
454
- * unique literal values that identify each variant.
455
- */
456
- propertyName: string;
457
-
458
- /**
459
- * Mapping from discriminator values to schema references.
460
- *
461
- * Keys are the literal values of the discriminator property, values are
462
- * `$ref` paths to the corresponding schemas.
463
- */
464
- mapping?: Record<string, string>;
465
- }
466
- }
467
-
468
- /**
469
- * Null type schema.
470
- *
471
- * Represents the JSON null value. In TypeScript union types like `T | null`,
472
- * this schema appears in an `anyOf` alongside the T schema.
473
- */
474
- export interface INull extends IJsonSchemaAttribute.INull {}
475
-
476
- /**
477
- * Unknown/any type schema.
478
- *
479
- * Represents TypeScript `any` or `unknown` types where no specific type
480
- * constraint is defined. Use sparingly as LLMs may generate unexpected values
481
- * for unconstrained types.
482
- */
483
- export interface IUnknown extends IJsonSchemaAttribute.IUnknown {}
484
- }
1
+ import { tags } from "../index";
2
+ import { IJsonSchemaAttribute } from "./IJsonSchemaAttribute";
3
+
4
+ /**
5
+ * Type schema for LLM function calling.
6
+ *
7
+ * `ILlmSchema` is a JSON Schema subset designed for LLM function calling
8
+ * compatibility. Most LLMs (OpenAI GPT, Anthropic Claude, Google Gemini, etc.)
9
+ * do not fully support JSON Schema, so this simplified schema omits unsupported
10
+ * features like tuples, `const`, and mixed union types.
11
+ *
12
+ * Generated by `typia.llm.schema<T>()` for single types or included in
13
+ * {@link ILlmApplication} via `typia.llm.application<Class>()`. Shared type
14
+ * definitions use `$defs` with `$ref` references to reduce duplication and
15
+ * handle recursive structures.
16
+ *
17
+ * Set {@link ILlmSchema.IConfig.strict} to `true` for OpenAI's structured output
18
+ * mode, which requires all properties to be `required` and
19
+ * `additionalProperties: false`.
20
+ *
21
+ * @author Jeongho Nam - https://github.com/samchon
22
+ */
23
+ export type ILlmSchema =
24
+ | ILlmSchema.IBoolean
25
+ | ILlmSchema.IInteger
26
+ | ILlmSchema.INumber
27
+ | ILlmSchema.IString
28
+ | ILlmSchema.IArray
29
+ | ILlmSchema.IObject
30
+ | ILlmSchema.IReference
31
+ | ILlmSchema.IAnyOf
32
+ | ILlmSchema.INull
33
+ | ILlmSchema.IUnknown;
34
+ export namespace ILlmSchema {
35
+ /**
36
+ * Configuration options for LLM schema generation.
37
+ *
38
+ * Controls how TypeScript types are converted to LLM-compatible JSON schemas.
39
+ * These settings affect OpenAI structured output compatibility.
40
+ */
41
+ export interface IConfig {
42
+ /**
43
+ * Whether to enable strict mode (OpenAI structured output).
44
+ *
45
+ * When `true`, all properties become required and `additionalProperties` is
46
+ * forced to `false`.
47
+ *
48
+ * @default false
49
+ */
50
+ strict: boolean;
51
+ }
52
+
53
+ /**
54
+ * Function parameters schema with shared type definitions.
55
+ *
56
+ * Extends the object schema to include a `$defs` map for named type
57
+ * definitions that can be referenced via `$ref`. This structure allows
58
+ * recursive types and reduces schema duplication.
59
+ *
60
+ * The `additionalProperties` is always `false` for parameters to ensure
61
+ * strict argument validation and prevent unexpected properties.
62
+ */
63
+ export interface IParameters extends Omit<IObject, "additionalProperties"> {
64
+ /**
65
+ * Named schema definitions for reference.
66
+ *
67
+ * Contains type definitions that can be referenced throughout the schema
68
+ * using `$ref: "#/$defs/TypeName"`. Essential for recursive types and
69
+ * shared structures.
70
+ */
71
+ $defs: Record<string, ILlmSchema>;
72
+
73
+ /**
74
+ * Whether additional properties are allowed.
75
+ *
76
+ * Always `false` for function parameters to ensure strict type checking.
77
+ * This prevents LLMs from hallucinating extra properties.
78
+ */
79
+ additionalProperties: false;
80
+ }
81
+
82
+ /**
83
+ * Boolean type schema.
84
+ *
85
+ * Represents a JSON Schema boolean type with optional enum constraints and
86
+ * default value. Used for true/false parameters and flags.
87
+ */
88
+ export interface IBoolean extends IJsonSchemaAttribute.IBoolean {
89
+ /**
90
+ * Allowed boolean values.
91
+ *
92
+ * Restricts the value to specific boolean literals. Typically unused since
93
+ * booleans only have two possible values, but supported for consistency
94
+ * with other types.
95
+ */
96
+ enum?: Array<boolean>;
97
+
98
+ /**
99
+ * Default value when not provided.
100
+ *
101
+ * The boolean value to use when the LLM omits this parameter.
102
+ */
103
+ default?: boolean;
104
+ }
105
+
106
+ /**
107
+ * Integer type schema.
108
+ *
109
+ * Represents a JSON Schema integer type with numeric constraints. Maps to
110
+ * TypeScript `number` with integer validation. Supports range constraints,
111
+ * enum restrictions, and divisibility checks.
112
+ */
113
+ export interface IInteger extends IJsonSchemaAttribute.IInteger {
114
+ /**
115
+ * Allowed integer values.
116
+ *
117
+ * Restricts the value to specific integer literals. Useful for representing
118
+ * enum-like integer codes or limited value sets.
119
+ */
120
+ enum?: Array<number & tags.Type<"int64">>;
121
+
122
+ /**
123
+ * Default value when not provided.
124
+ *
125
+ * The integer value to use when the LLM omits this parameter.
126
+ */
127
+ default?: number & tags.Type<"int64">;
128
+
129
+ /**
130
+ * Minimum value (inclusive).
131
+ *
132
+ * The value must be greater than or equal to this number.
133
+ */
134
+ minimum?: number & tags.Type<"int64">;
135
+
136
+ /**
137
+ * Maximum value (inclusive).
138
+ *
139
+ * The value must be less than or equal to this number.
140
+ */
141
+ maximum?: number & tags.Type<"int64">;
142
+
143
+ /**
144
+ * Exclusive minimum value.
145
+ *
146
+ * The value must be strictly greater than this number.
147
+ */
148
+ exclusiveMinimum?: number & tags.Type<"int64">;
149
+
150
+ /**
151
+ * Exclusive maximum value.
152
+ *
153
+ * The value must be strictly less than this number.
154
+ */
155
+ exclusiveMaximum?: number & tags.Type<"int64">;
156
+
157
+ /**
158
+ * Value must be divisible by this number.
159
+ *
160
+ * Used for constraints like "must be even" (multipleOf: 2) or "must be a
161
+ * multiple of 100" (multipleOf: 100).
162
+ */
163
+ multipleOf?: number & tags.Type<"uint64"> & tags.ExclusiveMinimum<0>;
164
+ }
165
+
166
+ /**
167
+ * Number (floating-point) type schema.
168
+ *
169
+ * Represents a JSON Schema number type for floating-point values. Maps to
170
+ * TypeScript `number` type. Supports range constraints, enum restrictions,
171
+ * and precision checks via multipleOf.
172
+ */
173
+ export interface INumber extends IJsonSchemaAttribute.INumber {
174
+ /**
175
+ * Allowed numeric values.
176
+ *
177
+ * Restricts the value to specific number literals. Useful for representing
178
+ * specific valid values like percentages or rates.
179
+ */
180
+ enum?: Array<number>;
181
+
182
+ /**
183
+ * Default value when not provided.
184
+ *
185
+ * The number to use when the LLM omits this parameter.
186
+ */
187
+ default?: number;
188
+
189
+ /**
190
+ * Minimum value (inclusive).
191
+ *
192
+ * The value must be greater than or equal to this number.
193
+ */
194
+ minimum?: number;
195
+
196
+ /**
197
+ * Maximum value (inclusive).
198
+ *
199
+ * The value must be less than or equal to this number.
200
+ */
201
+ maximum?: number;
202
+
203
+ /**
204
+ * Exclusive minimum value.
205
+ *
206
+ * The value must be strictly greater than this number.
207
+ */
208
+ exclusiveMinimum?: number;
209
+
210
+ /**
211
+ * Exclusive maximum value.
212
+ *
213
+ * The value must be strictly less than this number.
214
+ */
215
+ exclusiveMaximum?: number;
216
+
217
+ /**
218
+ * Value must be divisible by this number.
219
+ *
220
+ * Useful for decimal precision constraints like "two decimal places"
221
+ * (multipleOf: 0.01) or currency amounts (multipleOf: 0.01).
222
+ */
223
+ multipleOf?: number & tags.ExclusiveMinimum<0>;
224
+ }
225
+
226
+ /**
227
+ * String type schema.
228
+ *
229
+ * Represents a JSON Schema string type with format validation, pattern
230
+ * matching, and length constraints. Maps to TypeScript `string` type with
231
+ * optional semantic format annotations.
232
+ */
233
+ export interface IString extends IJsonSchemaAttribute.IString {
234
+ /**
235
+ * Allowed string values.
236
+ *
237
+ * Restricts the value to specific string literals. Maps directly to
238
+ * TypeScript string literal union types.
239
+ */
240
+ enum?: Array<string>;
241
+
242
+ /**
243
+ * Default value when not provided.
244
+ *
245
+ * The string to use when the LLM omits this parameter.
246
+ */
247
+ default?: string;
248
+
249
+ /**
250
+ * Semantic format specifier.
251
+ *
252
+ * Indicates the string represents a specific format like email, UUID, or
253
+ * date-time. LLMs may use this to generate appropriate values. Common
254
+ * formats include "email", "uri", "uuid", "date-time".
255
+ */
256
+ format?:
257
+ | "binary"
258
+ | "byte"
259
+ | "password"
260
+ | "regex"
261
+ | "uuid"
262
+ | "email"
263
+ | "hostname"
264
+ | "idn-email"
265
+ | "idn-hostname"
266
+ | "iri"
267
+ | "iri-reference"
268
+ | "ipv4"
269
+ | "ipv6"
270
+ | "uri"
271
+ | "uri-reference"
272
+ | "uri-template"
273
+ | "url"
274
+ | "date-time"
275
+ | "date"
276
+ | "time"
277
+ | "duration"
278
+ | "json-pointer"
279
+ | "relative-json-pointer"
280
+ | (string & {});
281
+
282
+ /**
283
+ * Regular expression pattern for validation.
284
+ *
285
+ * The string must match this regex pattern. Note that LLMs may struggle
286
+ * with complex regex patterns; simple patterns work best.
287
+ */
288
+ pattern?: string;
289
+
290
+ /**
291
+ * MIME type of the string content.
292
+ *
293
+ * Indicates the content type when the string contains encoded binary data,
294
+ * such as "application/json" or "image/png".
295
+ */
296
+ contentMediaType?: string;
297
+
298
+ /**
299
+ * Minimum string length.
300
+ *
301
+ * The string must have at least this many characters.
302
+ */
303
+ minLength?: number & tags.Type<"uint64">;
304
+
305
+ /**
306
+ * Maximum string length.
307
+ *
308
+ * The string must have at most this many characters.
309
+ */
310
+ maxLength?: number & tags.Type<"uint64">;
311
+ }
312
+
313
+ /**
314
+ * Array type schema.
315
+ *
316
+ * Represents a JSON Schema array type with item type validation and size
317
+ * constraints. Maps to TypeScript `T[]` or `Array<T>` types. Note: Tuple
318
+ * types are not supported by LLM schemas.
319
+ */
320
+ export interface IArray extends IJsonSchemaAttribute.IArray {
321
+ /**
322
+ * Schema for array elements.
323
+ *
324
+ * All elements in the array must conform to this schema. For heterogeneous
325
+ * arrays, use an `anyOf` schema.
326
+ */
327
+ items: ILlmSchema;
328
+
329
+ /**
330
+ * Whether elements must be unique.
331
+ *
332
+ * When `true`, no two elements may be equal. Maps to TypeScript `Set<T>`
333
+ * semantics but represented as an array.
334
+ */
335
+ uniqueItems?: boolean;
336
+
337
+ /**
338
+ * Minimum number of elements.
339
+ *
340
+ * The array must contain at least this many items.
341
+ */
342
+ minItems?: number & tags.Type<"uint64">;
343
+
344
+ /**
345
+ * Maximum number of elements.
346
+ *
347
+ * The array must contain at most this many items.
348
+ */
349
+ maxItems?: number & tags.Type<"uint64">;
350
+ }
351
+
352
+ /**
353
+ * Object type schema.
354
+ *
355
+ * Represents a JSON Schema object type with named properties. Maps to
356
+ * TypeScript interface or object type. Supports required property
357
+ * declarations and dynamic additional properties.
358
+ */
359
+ export interface IObject extends IJsonSchemaAttribute.IObject {
360
+ /**
361
+ * Property name to schema mapping.
362
+ *
363
+ * Defines the type of each named property on the object. All properties are
364
+ * defined here regardless of whether they are required or optional.
365
+ */
366
+ properties: Record<string, ILlmSchema>;
367
+
368
+ /**
369
+ * Schema for dynamic/additional properties.
370
+ *
371
+ * - `false` (default): No additional properties allowed
372
+ * - `true`: Any additional properties allowed
373
+ * - Schema: Additional properties must match this schema
374
+ *
375
+ * Note: ChatGPT and Gemini do not support `additionalProperties`. Use
376
+ * {@link ILlmSchema.IConfig.strict} mode for OpenAI compatibility.
377
+ */
378
+ additionalProperties?: ILlmSchema | boolean;
379
+
380
+ /**
381
+ * List of required property names.
382
+ *
383
+ * Properties in this array must be present in the object. In strict mode,
384
+ * all properties become required automatically.
385
+ */
386
+ required: string[];
387
+ }
388
+
389
+ /**
390
+ * Reference to a named schema definition.
391
+ *
392
+ * Points to a schema defined in the `$defs` map using a JSON pointer. Used to
393
+ * avoid schema duplication and enable recursive type definitions. The
394
+ * reference path format is `#/$defs/TypeName`.
395
+ */
396
+ export interface IReference extends IJsonSchemaAttribute {
397
+ /**
398
+ * JSON pointer to the referenced schema.
399
+ *
400
+ * Must be in the format `#/$defs/TypeName` where TypeName is a key in the
401
+ * parent schema's `$defs` map.
402
+ */
403
+ $ref: string;
404
+ }
405
+
406
+ /**
407
+ * Union type schema (A | B | C).
408
+ *
409
+ * Represents a TypeScript union type where the value can match any one of the
410
+ * member schemas. Note: Gemini does not support `anyOf`/`oneOf` schemas. Use
411
+ * discriminated unions with `x-discriminator` when possible for better LLM
412
+ * comprehension.
413
+ */
414
+ export interface IAnyOf extends IJsonSchemaAttribute {
415
+ /**
416
+ * Array of possible schemas.
417
+ *
418
+ * The value must match at least one of these schemas. Nested `anyOf`
419
+ * schemas are flattened to avoid deep nesting.
420
+ */
421
+ anyOf: Exclude<ILlmSchema, ILlmSchema.IAnyOf>[];
422
+
423
+ /**
424
+ * Discriminator for tagged/discriminated unions.
425
+ *
426
+ * Helps LLMs understand which variant to select based on a discriminating
427
+ * property value. Improves type inference accuracy.
428
+ */
429
+ "x-discriminator"?: IAnyOf.IDiscriminator;
430
+ }
431
+ export namespace IAnyOf {
432
+ /**
433
+ * Discriminator configuration for tagged unions.
434
+ *
435
+ * Specifies which property distinguishes between union variants and maps
436
+ * discriminator values to their corresponding schemas.
437
+ */
438
+ export interface IDiscriminator {
439
+ /**
440
+ * Name of the discriminating property.
441
+ *
442
+ * This property must exist on all union member object schemas and contain
443
+ * unique literal values that identify each variant.
444
+ */
445
+ propertyName: string;
446
+
447
+ /**
448
+ * Mapping from discriminator values to schema references.
449
+ *
450
+ * Keys are the literal values of the discriminator property, values are
451
+ * `$ref` paths to the corresponding schemas.
452
+ */
453
+ mapping?: Record<string, string>;
454
+ }
455
+ }
456
+
457
+ /**
458
+ * Null type schema.
459
+ *
460
+ * Represents the JSON null value. In TypeScript union types like `T | null`,
461
+ * this schema appears in an `anyOf` alongside the T schema.
462
+ */
463
+ export interface INull extends IJsonSchemaAttribute.INull {}
464
+
465
+ /**
466
+ * Unknown/any type schema.
467
+ *
468
+ * Represents TypeScript `any` or `unknown` types where no specific type
469
+ * constraint is defined. Use sparingly as LLMs may generate unexpected values
470
+ * for unconstrained types.
471
+ */
472
+ export interface IUnknown extends IJsonSchemaAttribute.IUnknown {}
473
+ }