@typia/interface 12.0.0-dev.20260311 → 12.0.0-dev.20260312
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/http/IHttpLlmApplication.d.ts +1 -1
- package/lib/http/IHttpLlmFunction.d.ts +1 -1
- package/lib/http/IHttpMigrateApplication.d.ts +1 -1
- package/lib/http/IHttpMigrateRoute.d.ts +2 -2
- package/lib/openapi/OpenApi.d.ts +35 -10
- package/lib/openapi/OpenApiV3.d.ts +7 -0
- package/lib/openapi/OpenApiV3_1.d.ts +7 -0
- package/lib/openapi/OpenApiV3_2.d.ts +489 -0
- package/lib/openapi/OpenApiV3_2.js +3 -0
- package/lib/openapi/OpenApiV3_2.js.map +1 -0
- package/lib/openapi/SwaggerV2.d.ts +7 -0
- package/lib/openapi/index.d.ts +1 -0
- package/lib/openapi/index.js +1 -0
- package/lib/openapi/index.js.map +1 -1
- package/lib/schema/ILlmStructuredOutput.d.ts +108 -0
- package/lib/schema/ILlmStructuredOutput.js +3 -0
- package/lib/schema/ILlmStructuredOutput.js.map +1 -0
- package/lib/schema/index.d.ts +1 -0
- package/lib/schema/index.js +1 -0
- package/lib/schema/index.js.map +1 -1
- package/package.json +1 -1
- package/src/http/IHttpLlmApplication.ts +72 -72
- package/src/http/IHttpLlmFunction.ts +34 -34
- package/src/http/IHttpMigrateApplication.ts +48 -48
- package/src/http/IHttpMigrateRoute.ts +165 -165
- package/src/openapi/OpenApi.ts +680 -643
- package/src/openapi/OpenApiV3.ts +663 -655
- package/src/openapi/OpenApiV3_1.ts +743 -735
- package/src/openapi/OpenApiV3_2.ts +773 -0
- package/src/openapi/SwaggerV2.ts +567 -559
- package/src/openapi/index.ts +5 -4
- package/src/schema/ILlmStructuredOutput.ts +112 -0
- package/src/schema/index.ts +15 -14
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { IJsonSchemaAttribute } from "../schema/IJsonSchemaAttribute";
|
|
2
|
+
import * as tags from "../tags";
|
|
3
|
+
/**
|
|
4
|
+
* OpenAPI v3.2 specification types (raw, unemended).
|
|
5
|
+
*
|
|
6
|
+
* `OpenApiV3_2` contains TypeScript type definitions for raw OpenAPI v3.2
|
|
7
|
+
* documents as-is from the specification. Unlike {@link OpenApi}, this preserves
|
|
8
|
+
* the original structure including `$ref` references and `allOf` compositions
|
|
9
|
+
* without normalization.
|
|
10
|
+
*
|
|
11
|
+
* Key features in v3.2:
|
|
12
|
+
*
|
|
13
|
+
* - `query` HTTP method for safe read operations with request body
|
|
14
|
+
* - `additionalOperations` for non-standard HTTP methods (LINK, UNLINK, etc.)
|
|
15
|
+
* - `in: "querystring"` parameter location for full query schema
|
|
16
|
+
* - Enhanced Tag structure with `summary`, `parent`, `kind`
|
|
17
|
+
* - `itemSchema` for streaming (SSE, JSON Lines, etc.)
|
|
18
|
+
* - OAuth2 Device Authorization Flow
|
|
19
|
+
*
|
|
20
|
+
* For a normalized format that simplifies schema processing, use
|
|
21
|
+
* {@link OpenApi}.
|
|
22
|
+
*
|
|
23
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
24
|
+
*/
|
|
25
|
+
export declare namespace OpenApiV3_2 {
|
|
26
|
+
/** HTTP method of the operation. */
|
|
27
|
+
type Method = "get" | "post" | "put" | "delete" | "options" | "head" | "patch" | "trace" | "query";
|
|
28
|
+
/** OpenAPI document structure. */
|
|
29
|
+
interface IDocument {
|
|
30
|
+
/** OpenAPI version. */
|
|
31
|
+
openapi: `3.2.${number}`;
|
|
32
|
+
/** List of servers. */
|
|
33
|
+
servers?: IServer[];
|
|
34
|
+
/** API metadata. */
|
|
35
|
+
info?: IDocument.IInfo;
|
|
36
|
+
/** Reusable components. */
|
|
37
|
+
components?: IComponents;
|
|
38
|
+
/** API paths and operations. */
|
|
39
|
+
paths?: Record<string, IPath>;
|
|
40
|
+
/** Webhook definitions. */
|
|
41
|
+
webhooks?: Record<string, IJsonSchema.IReference<`#/components/pathItems/${string}`> | IPath>;
|
|
42
|
+
/** Global security requirements. */
|
|
43
|
+
security?: Record<string, string[]>[];
|
|
44
|
+
/** Tag definitions. */
|
|
45
|
+
tags?: IDocument.ITag[];
|
|
46
|
+
}
|
|
47
|
+
namespace IDocument {
|
|
48
|
+
/** API metadata. */
|
|
49
|
+
interface IInfo {
|
|
50
|
+
/** API title. */
|
|
51
|
+
title: string;
|
|
52
|
+
/** Short summary. */
|
|
53
|
+
summary?: string;
|
|
54
|
+
/** Full description. */
|
|
55
|
+
description?: string;
|
|
56
|
+
/** Terms of service URL. */
|
|
57
|
+
termsOfService?: string;
|
|
58
|
+
/** Contact information. */
|
|
59
|
+
contact?: IContact;
|
|
60
|
+
/** License information. */
|
|
61
|
+
license?: ILicense;
|
|
62
|
+
/** API version. */
|
|
63
|
+
version: string;
|
|
64
|
+
}
|
|
65
|
+
/** Tag for grouping operations. */
|
|
66
|
+
interface ITag {
|
|
67
|
+
/** Tag name. */
|
|
68
|
+
name: string;
|
|
69
|
+
/** Short summary for display in tag lists. */
|
|
70
|
+
summary?: string;
|
|
71
|
+
/** Tag description. */
|
|
72
|
+
description?: string;
|
|
73
|
+
/** Parent tag name for hierarchical organization. */
|
|
74
|
+
parent?: string;
|
|
75
|
+
/** Tag classification (e.g., "nav", "badge"). */
|
|
76
|
+
kind?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Contact information. */
|
|
79
|
+
interface IContact {
|
|
80
|
+
/** Contact name. */
|
|
81
|
+
name?: string;
|
|
82
|
+
/** Contact URL. */
|
|
83
|
+
url?: string;
|
|
84
|
+
/** Contact email. */
|
|
85
|
+
email?: string & tags.Format<"email">;
|
|
86
|
+
}
|
|
87
|
+
/** License information. */
|
|
88
|
+
interface ILicense {
|
|
89
|
+
/** License name. */
|
|
90
|
+
name: string;
|
|
91
|
+
/** SPDX license identifier. */
|
|
92
|
+
identifier?: string;
|
|
93
|
+
/** License URL. */
|
|
94
|
+
url?: string;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Server providing the API. */
|
|
98
|
+
interface IServer {
|
|
99
|
+
/** Server URL. */
|
|
100
|
+
url: string;
|
|
101
|
+
/** Server description. */
|
|
102
|
+
description?: string;
|
|
103
|
+
/** URL template variables. */
|
|
104
|
+
variables?: Record<string, IServer.IVariable>;
|
|
105
|
+
}
|
|
106
|
+
namespace IServer {
|
|
107
|
+
/** URL template variable. */
|
|
108
|
+
interface IVariable {
|
|
109
|
+
/** Default value. */
|
|
110
|
+
default: string;
|
|
111
|
+
/** Allowed values. @minItems 1 */
|
|
112
|
+
enum?: string[];
|
|
113
|
+
/** Variable description. */
|
|
114
|
+
description?: string;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Path item containing operations by HTTP method. */
|
|
118
|
+
interface IPath extends Partial<Record<Method, IOperation>> {
|
|
119
|
+
/** Path-level parameters. */
|
|
120
|
+
parameters?: Array<IOperation.IParameter | IJsonSchema.IReference<`#/components/headers/${string}`> | IJsonSchema.IReference<`#/components/parameters/${string}`>>;
|
|
121
|
+
/** Path-level servers. */
|
|
122
|
+
servers?: IServer[];
|
|
123
|
+
/** Path summary. */
|
|
124
|
+
summary?: string;
|
|
125
|
+
/** Path description. */
|
|
126
|
+
description?: string;
|
|
127
|
+
/** Additional non-standard HTTP method operations (e.g., LINK, UNLINK, PURGE). */
|
|
128
|
+
additionalOperations?: Record<string, IOperation>;
|
|
129
|
+
}
|
|
130
|
+
/** API operation metadata. */
|
|
131
|
+
interface IOperation {
|
|
132
|
+
/** Unique operation identifier. */
|
|
133
|
+
operationId?: string;
|
|
134
|
+
/** Operation parameters. */
|
|
135
|
+
parameters?: Array<IOperation.IParameter | IJsonSchema.IReference<`#/components/headers/${string}`> | IJsonSchema.IReference<`#/components/parameters/${string}`>>;
|
|
136
|
+
/** Request body. */
|
|
137
|
+
requestBody?: IOperation.IRequestBody | IJsonSchema.IReference<`#/components/requestBodies/${string}`>;
|
|
138
|
+
/** Response definitions by status code. */
|
|
139
|
+
responses?: Record<string, IOperation.IResponse | IJsonSchema.IReference<`#/components/responses/${string}`>>;
|
|
140
|
+
/** Operation-level servers. */
|
|
141
|
+
servers?: IServer[];
|
|
142
|
+
/** Short summary. */
|
|
143
|
+
summary?: string;
|
|
144
|
+
/** Full description. */
|
|
145
|
+
description?: string;
|
|
146
|
+
/** Security requirements. */
|
|
147
|
+
security?: Record<string, string[]>[];
|
|
148
|
+
/** Operation tags. */
|
|
149
|
+
tags?: string[];
|
|
150
|
+
/** Whether deprecated. */
|
|
151
|
+
deprecated?: boolean;
|
|
152
|
+
}
|
|
153
|
+
namespace IOperation {
|
|
154
|
+
/** Operation parameter. */
|
|
155
|
+
interface IParameter {
|
|
156
|
+
/** Parameter name. */
|
|
157
|
+
name?: string;
|
|
158
|
+
/** Parameter location. */
|
|
159
|
+
in: "path" | "query" | "querystring" | "header" | "cookie";
|
|
160
|
+
/** Parameter schema. */
|
|
161
|
+
schema: IJsonSchema;
|
|
162
|
+
/** Whether required. */
|
|
163
|
+
required?: boolean;
|
|
164
|
+
/** Parameter description. */
|
|
165
|
+
description?: string;
|
|
166
|
+
/** Example value. */
|
|
167
|
+
example?: any;
|
|
168
|
+
/** Named examples. */
|
|
169
|
+
examples?: Record<string, IExample | IJsonSchema.IReference<`#/components/examples/${string}`>>;
|
|
170
|
+
}
|
|
171
|
+
/** Request body. */
|
|
172
|
+
interface IRequestBody {
|
|
173
|
+
/** Body description. */
|
|
174
|
+
description?: string;
|
|
175
|
+
/** Whether required. */
|
|
176
|
+
required?: boolean;
|
|
177
|
+
/** Body content by media type. */
|
|
178
|
+
content?: Record<string, IMediaType>;
|
|
179
|
+
}
|
|
180
|
+
/** Response definition. */
|
|
181
|
+
interface IResponse {
|
|
182
|
+
/** Response content by media type. */
|
|
183
|
+
content?: Record<string, IMediaType>;
|
|
184
|
+
/** Response headers. */
|
|
185
|
+
headers?: Record<string, Omit<IOperation.IParameter, "in"> | IJsonSchema.IReference<`#/components/headers/${string}`>>;
|
|
186
|
+
/** Response description. */
|
|
187
|
+
description?: string;
|
|
188
|
+
}
|
|
189
|
+
/** Media type definition. */
|
|
190
|
+
interface IMediaType {
|
|
191
|
+
/** Content schema. */
|
|
192
|
+
schema?: IJsonSchema;
|
|
193
|
+
/** Schema for streaming items (SSE, JSON Lines, etc.). */
|
|
194
|
+
itemSchema?: IJsonSchema;
|
|
195
|
+
/** Example value. */
|
|
196
|
+
example?: any;
|
|
197
|
+
/** Named examples. */
|
|
198
|
+
examples?: Record<string, IExample | IJsonSchema.IReference<`#/components/examples/${string}`>>;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/** Example value definition. */
|
|
202
|
+
interface IExample {
|
|
203
|
+
/** Example summary. */
|
|
204
|
+
summary?: string;
|
|
205
|
+
/** Example description. */
|
|
206
|
+
description?: string;
|
|
207
|
+
/** Example value. */
|
|
208
|
+
value?: any;
|
|
209
|
+
/** External value URL. */
|
|
210
|
+
externalValue?: string;
|
|
211
|
+
}
|
|
212
|
+
/** Reusable components storage. */
|
|
213
|
+
interface IComponents {
|
|
214
|
+
/** Named schemas. */
|
|
215
|
+
schemas?: Record<string, IJsonSchema>;
|
|
216
|
+
/** Named path items. */
|
|
217
|
+
pathItems?: Record<string, IPath>;
|
|
218
|
+
/** Named responses. */
|
|
219
|
+
responses?: Record<string, IOperation.IResponse>;
|
|
220
|
+
/** Named parameters. */
|
|
221
|
+
parameters?: Record<string, IOperation.IParameter>;
|
|
222
|
+
/** Named request bodies. */
|
|
223
|
+
requestBodies?: Record<string, IOperation.IRequestBody>;
|
|
224
|
+
/** Named security schemes. */
|
|
225
|
+
securitySchemes?: Record<string, ISecurityScheme>;
|
|
226
|
+
/** Named headers. */
|
|
227
|
+
headers?: Record<string, Omit<IOperation.IParameter, "in">>;
|
|
228
|
+
/** Named examples. */
|
|
229
|
+
examples?: Record<string, IExample>;
|
|
230
|
+
}
|
|
231
|
+
/** JSON Schema type for OpenAPI v3.1. */
|
|
232
|
+
type IJsonSchema = IJsonSchema.IMixed | IJsonSchema.IConstant | IJsonSchema.IBoolean | IJsonSchema.IInteger | IJsonSchema.INumber | IJsonSchema.IString | IJsonSchema.IArray | IJsonSchema.IObject | IJsonSchema.IReference | IJsonSchema.IRecursiveReference | IJsonSchema.IAllOf | IJsonSchema.IAnyOf | IJsonSchema.IOneOf | IJsonSchema.INull | IJsonSchema.IUnknown;
|
|
233
|
+
namespace IJsonSchema {
|
|
234
|
+
/** Mixed type (multiple types in array). */
|
|
235
|
+
interface IMixed extends IConstant, Omit<IBoolean, "type" | "default" | "enum">, Omit<INumber, "type" | "default" | "enum">, Omit<IString, "type" | "default" | "enum">, Omit<IArray, "type">, Omit<IObject, "type">, IOneOf, IAnyOf, IAllOf, IReference {
|
|
236
|
+
/** Array of type discriminators. */
|
|
237
|
+
type: Array<"boolean" | "integer" | "number" | "string" | "array" | "object" | "null">;
|
|
238
|
+
/** Default value. */
|
|
239
|
+
default?: any[] | null;
|
|
240
|
+
/** Allowed values. */
|
|
241
|
+
enum?: any[];
|
|
242
|
+
}
|
|
243
|
+
/** Constant value type. */
|
|
244
|
+
interface IConstant extends __IAttribute {
|
|
245
|
+
/** Constant value. */
|
|
246
|
+
const: boolean | number | string;
|
|
247
|
+
/** Whether nullable. */
|
|
248
|
+
nullable?: boolean;
|
|
249
|
+
}
|
|
250
|
+
/** Boolean type. */
|
|
251
|
+
interface IBoolean extends Omit<IJsonSchemaAttribute.IBoolean, "examples">, __IAttribute {
|
|
252
|
+
/** Whether nullable. */
|
|
253
|
+
nullable?: boolean;
|
|
254
|
+
/** Default value. */
|
|
255
|
+
default?: boolean | null;
|
|
256
|
+
/** Allowed values. */
|
|
257
|
+
enum?: Array<boolean | null>;
|
|
258
|
+
}
|
|
259
|
+
/** Integer type. */
|
|
260
|
+
interface IInteger extends Omit<IJsonSchemaAttribute.IInteger, "examples">, __IAttribute {
|
|
261
|
+
/** Whether nullable. */
|
|
262
|
+
nullable?: boolean;
|
|
263
|
+
/** Default value. */
|
|
264
|
+
default?: (number & tags.Type<"int64">) | null;
|
|
265
|
+
/** Allowed values. */
|
|
266
|
+
enum?: Array<(number & tags.Type<"int64">) | null>;
|
|
267
|
+
/** Minimum value. */
|
|
268
|
+
minimum?: number & tags.Type<"int64">;
|
|
269
|
+
/** Maximum value. */
|
|
270
|
+
maximum?: number & tags.Type<"int64">;
|
|
271
|
+
/** Exclusive minimum. */
|
|
272
|
+
exclusiveMinimum?: (number & tags.Type<"int64">) | boolean;
|
|
273
|
+
/** Exclusive maximum. */
|
|
274
|
+
exclusiveMaximum?: (number & tags.Type<"int64">) | boolean;
|
|
275
|
+
/** Multiple of constraint. */
|
|
276
|
+
multipleOf?: number & tags.ExclusiveMinimum<0>;
|
|
277
|
+
}
|
|
278
|
+
/** Number (double) type. */
|
|
279
|
+
interface INumber extends Omit<IJsonSchemaAttribute.INumber, "examples">, __IAttribute {
|
|
280
|
+
/** Whether nullable. */
|
|
281
|
+
nullable?: boolean;
|
|
282
|
+
/** Default value. */
|
|
283
|
+
default?: number | null;
|
|
284
|
+
/** Allowed values. */
|
|
285
|
+
enum?: Array<number | null>;
|
|
286
|
+
/** Minimum value. */
|
|
287
|
+
minimum?: number;
|
|
288
|
+
/** Maximum value. */
|
|
289
|
+
maximum?: number;
|
|
290
|
+
/** Exclusive minimum. */
|
|
291
|
+
exclusiveMinimum?: number | boolean;
|
|
292
|
+
/** Exclusive maximum. */
|
|
293
|
+
exclusiveMaximum?: number | boolean;
|
|
294
|
+
/** Multiple of constraint. */
|
|
295
|
+
multipleOf?: number & tags.ExclusiveMinimum<0>;
|
|
296
|
+
}
|
|
297
|
+
/** String type. */
|
|
298
|
+
interface IString extends Omit<IJsonSchemaAttribute.IString, "examples">, __IAttribute {
|
|
299
|
+
/** Whether nullable. */
|
|
300
|
+
nullable?: boolean;
|
|
301
|
+
/** Default value. */
|
|
302
|
+
default?: string | null;
|
|
303
|
+
/** Allowed values. */
|
|
304
|
+
enum?: Array<string | null>;
|
|
305
|
+
/** String format. */
|
|
306
|
+
format?: "binary" | "byte" | "password" | "regex" | "uuid" | "email" | "hostname" | "idn-email" | "idn-hostname" | "iri" | "iri-reference" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "uri-template" | "url" | "date-time" | "date" | "time" | "duration" | "json-pointer" | "relative-json-pointer" | (string & {});
|
|
307
|
+
/** Regex pattern. */
|
|
308
|
+
pattern?: string;
|
|
309
|
+
/** Content media type. */
|
|
310
|
+
contentMediaType?: string;
|
|
311
|
+
/** Minimum length. */
|
|
312
|
+
minLength?: number & tags.Type<"uint64">;
|
|
313
|
+
/** Maximum length. */
|
|
314
|
+
maxLength?: number & tags.Type<"uint64">;
|
|
315
|
+
}
|
|
316
|
+
/** Object type. */
|
|
317
|
+
interface IObject extends Omit<IJsonSchemaAttribute.IObject, "examples">, __IAttribute {
|
|
318
|
+
/** Whether nullable. */
|
|
319
|
+
nullable?: boolean;
|
|
320
|
+
/** Property schemas. */
|
|
321
|
+
properties?: Record<string, IJsonSchema>;
|
|
322
|
+
/** Required property names. */
|
|
323
|
+
required?: string[];
|
|
324
|
+
/** Additional properties schema. */
|
|
325
|
+
additionalProperties?: boolean | IJsonSchema;
|
|
326
|
+
/** Maximum properties. */
|
|
327
|
+
maxProperties?: number;
|
|
328
|
+
/** Minimum properties. */
|
|
329
|
+
minProperties?: number;
|
|
330
|
+
}
|
|
331
|
+
/** Array type. */
|
|
332
|
+
interface IArray extends Omit<IJsonSchemaAttribute.IArray, "examples">, __IAttribute {
|
|
333
|
+
/** Whether nullable. */
|
|
334
|
+
nullable?: boolean;
|
|
335
|
+
/** Element type (or tuple types). */
|
|
336
|
+
items?: IJsonSchema | IJsonSchema[];
|
|
337
|
+
/** Tuple prefix items. */
|
|
338
|
+
prefixItems?: IJsonSchema[];
|
|
339
|
+
/** Whether elements must be unique. */
|
|
340
|
+
uniqueItems?: boolean;
|
|
341
|
+
/** Additional items schema. */
|
|
342
|
+
additionalItems?: boolean | IJsonSchema;
|
|
343
|
+
/** Minimum items. */
|
|
344
|
+
minItems?: number & tags.Type<"uint64">;
|
|
345
|
+
/** Maximum items. */
|
|
346
|
+
maxItems?: number & tags.Type<"uint64">;
|
|
347
|
+
}
|
|
348
|
+
/** Reference to a named schema. */
|
|
349
|
+
interface IReference<Key = string> extends __IAttribute {
|
|
350
|
+
/** Reference path. */
|
|
351
|
+
$ref: Key;
|
|
352
|
+
}
|
|
353
|
+
/** Recursive reference. */
|
|
354
|
+
interface IRecursiveReference extends __IAttribute {
|
|
355
|
+
/** Recursive reference path. */
|
|
356
|
+
$recursiveRef: string;
|
|
357
|
+
}
|
|
358
|
+
/** All-of combination. */
|
|
359
|
+
interface IAllOf extends __IAttribute {
|
|
360
|
+
/** Schemas to combine. */
|
|
361
|
+
allOf: IJsonSchema[];
|
|
362
|
+
}
|
|
363
|
+
/** Any-of union. */
|
|
364
|
+
interface IAnyOf extends __IAttribute {
|
|
365
|
+
/** Union member schemas. */
|
|
366
|
+
anyOf: IJsonSchema[];
|
|
367
|
+
}
|
|
368
|
+
/** One-of union. */
|
|
369
|
+
interface IOneOf extends __IAttribute {
|
|
370
|
+
/** Union member schemas. */
|
|
371
|
+
oneOf: IJsonSchema[];
|
|
372
|
+
/** Discriminator for tagged unions. */
|
|
373
|
+
discriminator?: IOneOf.IDiscriminator;
|
|
374
|
+
}
|
|
375
|
+
namespace IOneOf {
|
|
376
|
+
/** Discriminator for tagged unions. */
|
|
377
|
+
interface IDiscriminator {
|
|
378
|
+
/** Discriminator property name. */
|
|
379
|
+
propertyName: string;
|
|
380
|
+
/** Value to schema mapping. */
|
|
381
|
+
mapping?: Record<string, string>;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/** Null type. */
|
|
385
|
+
interface INull extends Omit<IJsonSchemaAttribute.INull, "examples">, __IAttribute {
|
|
386
|
+
/** Default value. */
|
|
387
|
+
default?: null;
|
|
388
|
+
}
|
|
389
|
+
/** Unknown type. */
|
|
390
|
+
interface IUnknown extends Omit<IJsonSchemaAttribute.IUnknown, "examples">, __IAttribute {
|
|
391
|
+
/** Type discriminator (undefined for unknown). */
|
|
392
|
+
type?: undefined;
|
|
393
|
+
/** Default value. */
|
|
394
|
+
default?: any;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
/** Security scheme types. */
|
|
398
|
+
type ISecurityScheme = ISecurityScheme.IApiKey | ISecurityScheme.IHttpBasic | ISecurityScheme.IHttpBearer | ISecurityScheme.IOAuth2 | ISecurityScheme.IOpenId;
|
|
399
|
+
namespace ISecurityScheme {
|
|
400
|
+
/** API key authentication. */
|
|
401
|
+
interface IApiKey {
|
|
402
|
+
/** Scheme type. */
|
|
403
|
+
type: "apiKey";
|
|
404
|
+
/** Key location. */
|
|
405
|
+
in?: "header" | "query" | "cookie";
|
|
406
|
+
/** Key name. */
|
|
407
|
+
name?: string;
|
|
408
|
+
/** Scheme description. */
|
|
409
|
+
description?: string;
|
|
410
|
+
}
|
|
411
|
+
/** HTTP basic authentication. */
|
|
412
|
+
interface IHttpBasic {
|
|
413
|
+
/** Scheme type. */
|
|
414
|
+
type: "http";
|
|
415
|
+
/** Authentication scheme. */
|
|
416
|
+
scheme: "basic";
|
|
417
|
+
/** Scheme description. */
|
|
418
|
+
description?: string;
|
|
419
|
+
}
|
|
420
|
+
/** HTTP bearer authentication. */
|
|
421
|
+
interface IHttpBearer {
|
|
422
|
+
/** Scheme type. */
|
|
423
|
+
type: "http";
|
|
424
|
+
/** Authentication scheme. */
|
|
425
|
+
scheme: "bearer";
|
|
426
|
+
/** Bearer token format hint. */
|
|
427
|
+
bearerFormat?: string;
|
|
428
|
+
/** Scheme description. */
|
|
429
|
+
description?: string;
|
|
430
|
+
}
|
|
431
|
+
/** OAuth2 authentication. */
|
|
432
|
+
interface IOAuth2 {
|
|
433
|
+
/** Scheme type. */
|
|
434
|
+
type: "oauth2";
|
|
435
|
+
/** OAuth2 flows. */
|
|
436
|
+
flows: IOAuth2.IFlowSet;
|
|
437
|
+
/** OAuth2 metadata discovery URL. */
|
|
438
|
+
oauth2MetadataUrl?: string;
|
|
439
|
+
/** Scheme description. */
|
|
440
|
+
description?: string;
|
|
441
|
+
}
|
|
442
|
+
/** OpenID Connect authentication. */
|
|
443
|
+
interface IOpenId {
|
|
444
|
+
/** Scheme type. */
|
|
445
|
+
type: "openIdConnect";
|
|
446
|
+
/** OpenID Connect discovery URL. */
|
|
447
|
+
openIdConnectUrl: string;
|
|
448
|
+
/** Scheme description. */
|
|
449
|
+
description?: string;
|
|
450
|
+
}
|
|
451
|
+
namespace IOAuth2 {
|
|
452
|
+
/** OAuth2 flow configurations. */
|
|
453
|
+
interface IFlowSet {
|
|
454
|
+
/** Authorization code flow. */
|
|
455
|
+
authorizationCode?: IFlow;
|
|
456
|
+
/** Implicit flow. */
|
|
457
|
+
implicit?: Omit<IFlow, "tokenUrl">;
|
|
458
|
+
/** Password flow. */
|
|
459
|
+
password?: Omit<IFlow, "authorizationUrl">;
|
|
460
|
+
/** Client credentials flow. */
|
|
461
|
+
clientCredentials?: Omit<IFlow, "authorizationUrl">;
|
|
462
|
+
/** Device authorization flow. */
|
|
463
|
+
deviceAuthorization?: IDeviceFlow;
|
|
464
|
+
}
|
|
465
|
+
/** OAuth2 flow configuration. */
|
|
466
|
+
interface IFlow {
|
|
467
|
+
/** Authorization URL. */
|
|
468
|
+
authorizationUrl?: string;
|
|
469
|
+
/** Token URL. */
|
|
470
|
+
tokenUrl?: string;
|
|
471
|
+
/** Refresh URL. */
|
|
472
|
+
refreshUrl?: string;
|
|
473
|
+
/** Available scopes. */
|
|
474
|
+
scopes?: Record<string, string>;
|
|
475
|
+
}
|
|
476
|
+
/** OAuth2 device authorization flow. */
|
|
477
|
+
interface IDeviceFlow {
|
|
478
|
+
/** Device authorization URL. */
|
|
479
|
+
deviceAuthorizationUrl: string;
|
|
480
|
+
/** Token URL. */
|
|
481
|
+
tokenUrl: string;
|
|
482
|
+
/** Refresh URL. */
|
|
483
|
+
refreshUrl?: string;
|
|
484
|
+
/** Available scopes. */
|
|
485
|
+
scopes?: Record<string, string>;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApiV3_2.js","sourceRoot":"","sources":["../../src/openapi/OpenApiV3_2.ts"],"names":[],"mappings":""}
|
|
@@ -92,6 +92,13 @@ export declare namespace SwaggerV2 {
|
|
|
92
92
|
interface IPath extends Partial<Record<Method, IOperation | undefined>> {
|
|
93
93
|
/** Path-level parameters. */
|
|
94
94
|
parameters?: Array<IOperation.IParameter | IJsonSchema.IReference<`#/parameters/${string}`>>;
|
|
95
|
+
/**
|
|
96
|
+
* Non-standard HTTP method operations (extension).
|
|
97
|
+
*
|
|
98
|
+
* Used when downgrading from OpenAPI v3.2 to preserve
|
|
99
|
+
* non-standard methods like `query` or custom methods.
|
|
100
|
+
*/
|
|
101
|
+
"x-additionalOperations"?: Record<string, IOperation>;
|
|
95
102
|
}
|
|
96
103
|
/** API operation metadata. */
|
|
97
104
|
interface IOperation {
|
package/lib/openapi/index.d.ts
CHANGED
package/lib/openapi/index.js
CHANGED
|
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./OpenApi"), exports);
|
|
18
18
|
__exportStar(require("./OpenApiV3"), exports);
|
|
19
19
|
__exportStar(require("./OpenApiV3_1"), exports);
|
|
20
|
+
__exportStar(require("./OpenApiV3_2"), exports);
|
|
20
21
|
__exportStar(require("./SwaggerV2"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/lib/openapi/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/openapi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,8CAA4B;AAC5B,gDAA8B;AAC9B,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/openapi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,8CAA4B;AAC5B,gDAA8B;AAC9B,gDAA8B;AAC9B,8CAA4B"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { IJsonParseResult } from "./IJsonParseResult";
|
|
2
|
+
import { ILlmSchema } from "./ILlmSchema";
|
|
3
|
+
import { IValidation } from "./IValidation";
|
|
4
|
+
/**
|
|
5
|
+
* LLM structured output schema with parsing and validation utilities.
|
|
6
|
+
*
|
|
7
|
+
* `ILlmStructuredOutput<T>` is generated by `typia.llm.structuredOutput<T>()`
|
|
8
|
+
* to provide everything needed for handling LLM structured outputs: the JSON
|
|
9
|
+
* schema for prompting, and functions for parsing, coercing, and validating
|
|
10
|
+
* responses.
|
|
11
|
+
*
|
|
12
|
+
* Structured outputs allow LLMs to generate data conforming to a predefined
|
|
13
|
+
* schema instead of free-form text. This is useful for:
|
|
14
|
+
*
|
|
15
|
+
* - Extracting structured data from conversations
|
|
16
|
+
* - Generating typed responses for downstream processing
|
|
17
|
+
* - Ensuring consistent output formats across LLM calls
|
|
18
|
+
*
|
|
19
|
+
* Workflow:
|
|
20
|
+
*
|
|
21
|
+
* 1. Pass {@link parameters} schema to LLM provider
|
|
22
|
+
* 2. Receive LLM response (JSON string or pre-parsed object)
|
|
23
|
+
* 3. Use {@link parse} for raw strings or {@link coerce} for pre-parsed objects
|
|
24
|
+
* 4. Use {@link validate} to check the result and get detailed errors
|
|
25
|
+
*
|
|
26
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
27
|
+
* @template T The expected output type
|
|
28
|
+
*/
|
|
29
|
+
export interface ILlmStructuredOutput<T = unknown> {
|
|
30
|
+
/**
|
|
31
|
+
* JSON schema for the structured output.
|
|
32
|
+
*
|
|
33
|
+
* Pass this schema to LLM providers (OpenAI, Anthropic, Google, etc.) to
|
|
34
|
+
* constrain the output format. The schema includes `$defs` for shared type
|
|
35
|
+
* definitions and `properties` for the output structure.
|
|
36
|
+
*
|
|
37
|
+
* Most LLM providers accept this directly in their structured output or
|
|
38
|
+
* response format configuration.
|
|
39
|
+
*/
|
|
40
|
+
parameters: ILlmSchema.IParameters;
|
|
41
|
+
/**
|
|
42
|
+
* Lenient JSON parser with schema-based type coercion.
|
|
43
|
+
*
|
|
44
|
+
* Handles incomplete or malformed JSON commonly produced by LLMs:
|
|
45
|
+
*
|
|
46
|
+
* - Unclosed brackets, strings, trailing commas
|
|
47
|
+
* - JavaScript-style comments (`//` and multi-line)
|
|
48
|
+
* - Unquoted object keys, incomplete keywords (`tru`, `fal`, `nul`)
|
|
49
|
+
* - Markdown code block extraction, junk prefix skipping
|
|
50
|
+
*
|
|
51
|
+
* Also coerces double-stringified values based on the schema:
|
|
52
|
+
*
|
|
53
|
+
* - `"42"` → `42` (when schema expects number)
|
|
54
|
+
* - `"true"` → `true` (when schema expects boolean)
|
|
55
|
+
* - `"null"` → `null` (when schema expects null)
|
|
56
|
+
* - `"{...}"` → `{...}` (when schema expects object)
|
|
57
|
+
* - `"[...]"` → `[...]` (when schema expects array)
|
|
58
|
+
*
|
|
59
|
+
* Type validation is NOT performed — use {@link validate} after parsing.
|
|
60
|
+
*
|
|
61
|
+
* If the SDK (e.g., LangChain, Vercel AI, MCP) already parses JSON internally
|
|
62
|
+
* and provides a pre-parsed object, use {@link coerce} instead.
|
|
63
|
+
*
|
|
64
|
+
* @param input Raw JSON string from LLM output
|
|
65
|
+
* @returns Parse result with data on success, or partial data with errors
|
|
66
|
+
*/
|
|
67
|
+
parse: (input: string) => IJsonParseResult<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Coerce pre-parsed output to match expected schema types.
|
|
70
|
+
*
|
|
71
|
+
* **Use this only when the SDK already parses JSON internally.** For raw JSON
|
|
72
|
+
* strings from LLM output, use {@link parse} instead — it handles both lenient
|
|
73
|
+
* parsing and type coercion in one step.
|
|
74
|
+
*
|
|
75
|
+
* LLMs often return values with incorrect types even after parsing:
|
|
76
|
+
*
|
|
77
|
+
* - `"42"` → `42` (when schema expects number)
|
|
78
|
+
* - `"true"` → `true` (when schema expects boolean)
|
|
79
|
+
* - `"null"` → `null` (when schema expects null)
|
|
80
|
+
* - `"{...}"` → `{...}` (when schema expects object)
|
|
81
|
+
* - `"[...]"` → `[...]` (when schema expects array)
|
|
82
|
+
*
|
|
83
|
+
* This function recursively coerces these double-stringified values based on
|
|
84
|
+
* the {@link parameters} schema.
|
|
85
|
+
*
|
|
86
|
+
* Type validation is NOT performed — use {@link validate} after coercion.
|
|
87
|
+
*
|
|
88
|
+
* @param input Pre-parsed output object from SDK
|
|
89
|
+
* @returns Coerced output with corrected types
|
|
90
|
+
*/
|
|
91
|
+
coerce: (input: unknown) => T;
|
|
92
|
+
/**
|
|
93
|
+
* Validates LLM-generated output against the schema.
|
|
94
|
+
*
|
|
95
|
+
* LLMs frequently make type errors such as returning strings instead of
|
|
96
|
+
* numbers or missing required properties. Use this validator to check output
|
|
97
|
+
* before further processing.
|
|
98
|
+
*
|
|
99
|
+
* When validation fails, use {@link LlmJson.stringify} from `@typia/utils` to
|
|
100
|
+
* format the error for LLM feedback. The formatted output shows the invalid
|
|
101
|
+
* JSON with inline error comments, helping the LLM understand and correct its
|
|
102
|
+
* mistakes in the next turn.
|
|
103
|
+
*
|
|
104
|
+
* @param input The output generated by the LLM
|
|
105
|
+
* @returns Validation result with success status and any errors
|
|
106
|
+
*/
|
|
107
|
+
validate: (input: unknown) => IValidation<T>;
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ILlmStructuredOutput.js","sourceRoot":"","sources":["../../src/schema/ILlmStructuredOutput.ts"],"names":[],"mappings":""}
|
package/lib/schema/index.d.ts
CHANGED
package/lib/schema/index.js
CHANGED
|
@@ -25,5 +25,6 @@ __exportStar(require("./ILlmController"), exports);
|
|
|
25
25
|
__exportStar(require("./ILlmApplication"), exports);
|
|
26
26
|
__exportStar(require("./ILlmFunction"), exports);
|
|
27
27
|
__exportStar(require("./ILlmSchema"), exports);
|
|
28
|
+
__exportStar(require("./ILlmStructuredOutput"), exports);
|
|
28
29
|
__exportStar(require("./IJsonParseResult"), exports);
|
|
29
30
|
//# sourceMappingURL=index.js.map
|
package/lib/schema/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,gDAA8B;AAE9B,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC;AACxC,oDAAkC;AAClC,yDAAuC;AAEvC,mDAAiC;AACjC,oDAAkC;AAClC,iDAA+B;AAC/B,+CAA6B;AAC7B,qDAAmC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,gDAA8B;AAE9B,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC;AACxC,oDAAkC;AAClC,yDAAuC;AAEvC,mDAAiC;AACjC,oDAAkC;AAClC,iDAA+B;AAC/B,+CAA6B;AAC7B,yDAAuC;AACvC,qDAAmC"}
|