typia 14.0.6 → 15.0.1
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/README.md +3 -0
- package/lib/http.d.ts +49 -24
- package/lib/http.js.map +1 -1
- package/lib/http.mjs.map +1 -1
- package/lib/internal/_createLlmEvaluation.d.ts +1 -0
- package/lib/internal/_createLlmEvaluation.js +486 -0
- package/lib/internal/_createLlmEvaluation.js.map +1 -0
- package/lib/internal/_createLlmEvaluation.mjs +382 -0
- package/lib/internal/_createLlmEvaluation.mjs.map +1 -0
- package/lib/internal/_httpFormDataReadBigint.js +7 -5
- package/lib/internal/_httpFormDataReadBigint.js.map +1 -1
- package/lib/internal/_httpFormDataReadBigint.mjs +1 -1
- package/lib/internal/_httpFormDataReadBigint.mjs.map +1 -1
- package/lib/internal/_httpFormDataReadBoolean.js +12 -10
- package/lib/internal/_httpFormDataReadBoolean.js.map +1 -1
- package/lib/internal/_httpFormDataReadBoolean.mjs +1 -1
- package/lib/internal/_httpFormDataReadBoolean.mjs.map +1 -1
- package/lib/internal/_httpFormDataReadNumber.js +7 -5
- package/lib/internal/_httpFormDataReadNumber.js.map +1 -1
- package/lib/internal/_httpFormDataReadNumber.mjs +1 -1
- package/lib/internal/_httpFormDataReadNumber.mjs.map +1 -1
- package/lib/internal/_httpFormDataReadString.d.ts +9 -1
- package/lib/internal/_httpFormDataReadString.js +10 -2
- package/lib/internal/_httpFormDataReadString.js.map +1 -1
- package/lib/internal/_httpFormDataReadString.mjs +9 -1
- package/lib/internal/_httpFormDataReadString.mjs.map +1 -1
- package/lib/internal/_httpHeaderReadBigint.js +5 -1
- package/lib/internal/_httpHeaderReadBigint.js.map +1 -1
- package/lib/internal/_httpHeaderReadBigint.mjs +2 -1
- package/lib/internal/_httpHeaderReadBigint.mjs.map +1 -1
- package/lib/internal/_httpHeaderReadNumber.js +5 -1
- package/lib/internal/_httpHeaderReadNumber.js.map +1 -1
- package/lib/internal/_httpHeaderReadNumber.mjs +2 -1
- package/lib/internal/_httpHeaderReadNumber.mjs.map +1 -1
- package/lib/internal/_httpParameterReadBigint.js +4 -0
- package/lib/internal/_httpParameterReadBigint.js.map +1 -1
- package/lib/internal/_httpParameterReadBigint.mjs +1 -0
- package/lib/internal/_httpParameterReadBigint.mjs.map +1 -1
- package/lib/internal/_httpParameterReadNumber.js +4 -0
- package/lib/internal/_httpParameterReadNumber.js.map +1 -1
- package/lib/internal/_httpParameterReadNumber.mjs +1 -0
- package/lib/internal/_httpParameterReadNumber.mjs.map +1 -1
- package/lib/internal/_httpParameterReadString.d.ts +9 -1
- package/lib/internal/_httpParameterReadString.js +9 -1
- package/lib/internal/_httpParameterReadString.js.map +1 -1
- package/lib/internal/_httpParameterReadString.mjs +9 -1
- package/lib/internal/_httpParameterReadString.mjs.map +1 -1
- package/lib/internal/_httpQueryReadBigint.js +8 -1
- package/lib/internal/_httpQueryReadBigint.js.map +1 -1
- package/lib/internal/_httpQueryReadBigint.mjs +1 -1
- package/lib/internal/_httpQueryReadBigint.mjs.map +1 -1
- package/lib/internal/_httpQueryReadBoolean.js +4 -1
- package/lib/internal/_httpQueryReadBoolean.js.map +1 -1
- package/lib/internal/_httpQueryReadBoolean.mjs +1 -1
- package/lib/internal/_httpQueryReadBoolean.mjs.map +1 -1
- package/lib/internal/_httpQueryReadNumber.js +8 -1
- package/lib/internal/_httpQueryReadNumber.js.map +1 -1
- package/lib/internal/_httpQueryReadNumber.mjs +1 -1
- package/lib/internal/_httpQueryReadNumber.mjs.map +1 -1
- package/lib/internal/_httpQueryReadString.d.ts +9 -1
- package/lib/internal/_httpQueryReadString.js +9 -1
- package/lib/internal/_httpQueryReadString.js.map +1 -1
- package/lib/internal/_httpQueryReadString.mjs +9 -1
- package/lib/internal/_httpQueryReadString.mjs.map +1 -1
- package/lib/internal/_randomBigint.d.ts +12 -1
- package/lib/internal/_randomBigint.js +90 -2
- package/lib/internal/_randomBigint.js.map +1 -1
- package/lib/internal/_randomBigint.mjs +70 -2
- package/lib/internal/_randomBigint.mjs.map +1 -1
- package/lib/internal/_randomInteger.js +21 -12
- package/lib/internal/_randomInteger.js.map +1 -1
- package/lib/internal/_randomInteger.mjs +21 -16
- package/lib/internal/_randomInteger.mjs.map +1 -1
- package/lib/internal/_randomNumber.js +19 -10
- package/lib/internal/_randomNumber.js.map +1 -1
- package/lib/internal/_randomNumber.mjs +19 -14
- package/lib/internal/_randomNumber.mjs.map +1 -1
- package/lib/internal/_stringLengthGte.d.ts +1 -0
- package/lib/internal/_stringLengthGte.js +14 -0
- package/lib/internal/_stringLengthGte.js.map +1 -0
- package/lib/internal/_stringLengthGte.mjs +11 -0
- package/lib/internal/_stringLengthGte.mjs.map +1 -0
- package/lib/internal/_stringLengthLte.d.ts +1 -0
- package/lib/internal/_stringLengthLte.js +14 -0
- package/lib/internal/_stringLengthLte.js.map +1 -0
- package/lib/internal/_stringLengthLte.mjs +11 -0
- package/lib/internal/_stringLengthLte.mjs.map +1 -0
- package/lib/llm.d.ts +54 -1
- package/lib/llm.js +5 -0
- package/lib/llm.js.map +1 -1
- package/lib/llm.mjs +6 -1
- package/lib/llm.mjs.map +1 -1
- package/lib/re-exports.d.ts +1 -1
- package/lib/re-exports.js.map +1 -1
- package/native/cmd/ttsc-typia/build.go +2 -0
- package/native/cmd/ttsc-typia/dynamic_key_tags_transform_test.go +1 -1
- package/native/cmd/ttsc-typia/llm_evaluation_accepts_property_probability_test.go +27 -0
- package/native/cmd/ttsc-typia/llm_evaluation_accepts_unselected_source_probability_test.go +26 -0
- package/native/cmd/ttsc-typia/llm_evaluation_complete_object_shape_test.go +96 -0
- package/native/cmd/ttsc-typia/llm_evaluation_ignores_declaration_probability_without_call_test.go +18 -0
- package/native/cmd/ttsc-typia/llm_evaluation_plan_emission_transform_test.go +90 -0
- package/native/cmd/ttsc-typia/llm_evaluation_program_scan_dependencies_test.go +69 -0
- package/native/cmd/ttsc-typia/llm_evaluation_rejects_alias_comment_test.go +44 -0
- package/native/cmd/ttsc-typia/llm_evaluation_rejects_alias_refinement_test.go +45 -0
- package/native/cmd/ttsc-typia/llm_evaluation_rejects_computed_method_probability_test.go +30 -0
- package/native/cmd/ttsc-typia/llm_evaluation_rejects_imported_declaration_probability_test.go +48 -0
- package/native/cmd/ttsc-typia/llm_evaluation_rejects_invalid_probability_test.go +208 -0
- package/native/cmd/ttsc-typia/llm_evaluation_rejects_refinements_test.go +94 -0
- package/native/cmd/ttsc-typia/llm_evaluation_rejects_undecidable_types_test.go +232 -0
- package/native/cmd/ttsc-typia/metadata_type_tag_sole_malformed_diagnostic_test.go +94 -0
- package/native/cmd/ttsc-typia/random_recursive_min_items_diagnostic_test.go +18 -1
- package/native/cmd/ttsc-typia/template_literal_type_tags_transform_test.go +3 -2
- package/native/cmd/ttsc-typia/transform.go +2 -0
- package/native/cmd/ttsc-typia/transform_helpers_test.go +17 -3
- package/native/core/context/ITypiaContext.go +4 -0
- package/native/core/factories/ExpressionFactory.go +16 -1
- package/native/core/factories/IdentifierFactory.go +10 -0
- package/native/core/factories/LiteralFactory.go +16 -0
- package/native/core/factories/MetadataCommentTagFactory.go +185 -35
- package/native/core/factories/MetadataTypeTagFactory.go +97 -24
- package/native/core/factories/MetadataTypeTagSchemaFactory.go +5 -0
- package/native/core/factories/expression_factory_number_spells_non_finite_values_test.go +69 -0
- package/native/core/factories/internal/metadata/IMetadataIteratorProps.go +6 -2
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +49 -15
- package/native/core/factories/literal_factory_null_survives_objects_test.go +43 -0
- package/native/core/factories/metadata_comment_tag_factory_holds_bigint_tags_exact_test.go +168 -0
- package/native/core/factories/metadata_comment_tag_factory_reads_javascript_numbers_test.go +158 -0
- package/native/core/factories/metadata_comment_tag_factory_string_length_helpers_test.go +55 -0
- package/native/core/factories/metadata_type_tag_factory_reports_all_invalid_candidates_test.go +73 -0
- package/native/core/programmers/functional/FunctionalAssertParametersProgrammer.go +1 -3
- package/native/core/programmers/functional/FunctionalIsParametersProgrammer.go +107 -9
- package/native/core/programmers/functional/FunctionalValidateParametersProgrammer.go +1 -3
- package/native/core/programmers/http/HttpFormDataProgrammer.go +41 -2
- package/native/core/programmers/http/HttpHeadersProgrammer.go +56 -4
- package/native/core/programmers/http/HttpParameterProgrammer.go +1 -3
- package/native/core/programmers/http/HttpQueryProgrammer.go +26 -43
- package/native/core/programmers/iterate/json_schema_jsDocTags.go +10 -3
- package/native/core/programmers/iterate/json_schema_jsdoc_tags_cast_reads_javascript_numbers_test.go +64 -0
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +1 -0
- package/native/core/programmers/llm/LlmEvaluationProgrammer.go +559 -0
- package/native/core/programmers/llm/LlmParametersProgrammer.go +6 -5
- package/native/core/programmers/llm/LlmReferenceDescription.go +113 -0
- package/native/core/programmers/llm/LlmSchemaProgrammer.go +34 -4
- package/native/core/programmers/llm/llm_reference_description_test.go +134 -0
- package/native/core/schemas/metadata/MetadataDependency.go +9 -0
- package/native/core/utils/NumberUtil.go +195 -0
- package/native/core/utils/number_util_rational_keeps_written_value_test.go +62 -0
- package/native/core/utils/number_util_reads_javascript_number_grammar_test.go +147 -0
- package/native/transform/CallExpressionTransformer.go +1 -0
- package/native/transform/FileTransformer.go +5 -0
- package/native/transform/features/llm/LlmEvaluationProbabilityDeclarations.go +94 -0
- package/native/transform/features/llm/LlmEvaluationProbabilityDeclarations_test.go +50 -0
- package/native/transform/features/llm/LlmEvaluationTransformer.go +59 -0
- package/native/transform/features/llm/LlmSchemaTransformer.go +14 -11
- package/native/transform/features/llm/llm_transformer_entry_coverage_test.go +29 -27
- package/package.json +3 -3
- package/src/http.ts +61 -34
- package/src/internal/_createLlmEvaluation.ts +678 -0
- package/src/internal/_httpFormDataReadBigint.ts +3 -1
- package/src/internal/_httpFormDataReadBoolean.ts +3 -1
- package/src/internal/_httpFormDataReadNumber.ts +3 -1
- package/src/internal/_httpFormDataReadString.ts +10 -1
- package/src/internal/_httpHeaderReadBigint.ts +6 -1
- package/src/internal/_httpHeaderReadNumber.ts +6 -1
- package/src/internal/_httpParameterReadBigint.ts +3 -0
- package/src/internal/_httpParameterReadNumber.ts +3 -0
- package/src/internal/_httpParameterReadString.ts +12 -2
- package/src/internal/_httpQueryReadBigint.ts +7 -1
- package/src/internal/_httpQueryReadBoolean.ts +3 -1
- package/src/internal/_httpQueryReadNumber.ts +7 -1
- package/src/internal/_httpQueryReadString.ts +10 -1
- package/src/internal/_randomBigint.ts +111 -3
- package/src/internal/_randomInteger.ts +31 -16
- package/src/internal/_randomNumber.ts +23 -12
- package/src/internal/_stringLengthGte.ts +6 -0
- package/src/internal/_stringLengthLte.ts +6 -0
- package/src/llm.ts +64 -0
- package/src/re-exports.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomBigint.mjs","names":[],"sources":["../../src/internal/_randomBigint.ts"],"sourcesContent":["import { OpenApi } from \"@typia/interface\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"_randomBigint.mjs","names":[],"sources":["../../src/internal/_randomBigint.ts"],"sourcesContent":["import { OpenApi } from \"@typia/interface\";\n\nimport { _decimalIntegerStep } from \"./_decimal\";\n\n/**\n * Generates a random `bigint` satisfying an integer schema.\n *\n * The schema carries its bounds and step as numbers, but the value is a\n * `bigint`, so the draw runs on integers. Drawing through doubles rounded every\n * value past 2^53, and it checked `multipleOf` against a double's shortest\n * decimal text rather than the integer `BigInt` makes of it, so `random`\n * returned values the validator rejects, or gave up on a range that holds one\n * (#2457). An integral bound or step is read as the integer the double holds,\n * which is the integer the validator compares with.\n */\nexport const _randomBigint = (schema: OpenApi.IJsonSchema.IInteger): bigint => {\n const lower: bigint | null = boundary(\n schema.minimum,\n schema.exclusiveMinimum,\n \"lower\",\n );\n const upper: bigint | null = boundary(\n schema.maximum,\n schema.exclusiveMaximum,\n \"upper\",\n );\n const minimum: bigint =\n lower ?? (upper === null ? BigInt(0) : upper - BigInt(100));\n const maximum: bigint =\n upper ?? (lower === null ? BigInt(100) : lower + BigInt(100));\n if (minimum > maximum)\n throw new Error(\"Minimum value is greater than maximum value.\");\n if (schema.multipleOf === undefined) return between(minimum, maximum);\n\n const step: bigint | null = integerStep(schema.multipleOf);\n if (step === null || step <= BigInt(0))\n throw new Error(\"The multipleOf value must be a positive finite number.\");\n const first: bigint = ceilDivide(minimum, step);\n const last: bigint = floorDivide(maximum, step);\n if (first > last)\n throw new Error(\"The range does not contain a multipleOf value.\");\n return between(first, last) * step;\n};\n\n/**\n * Reads one side's inclusive integer bound.\n *\n * `-Infinity` below or `Infinity` above excludes no integer, so it is no bound\n * at all; `Infinity` below or `-Infinity` above excludes every integer.\n */\nconst boundary = (\n inclusive: number | undefined,\n exclusive: number | undefined,\n side: \"lower\" | \"upper\",\n): bigint | null => {\n const candidates: bigint[] = [];\n for (const [value, open] of [\n [inclusive, false],\n [exclusive, true],\n ] as const) {\n if (value === undefined) continue;\n if (Number.isFinite(value) === false) {\n if (value === (side === \"lower\" ? -Infinity : Infinity)) continue;\n throw new Error(\"Numeric range has no finite value.\");\n }\n candidates.push(\n side === \"lower\"\n ? open\n ? BigInt(Math.floor(value)) + BigInt(1)\n : BigInt(Math.ceil(value))\n : open\n ? BigInt(Math.ceil(value)) - BigInt(1)\n : BigInt(Math.floor(value)),\n );\n }\n if (candidates.length === 0) return null;\n return candidates.reduce((x, y) =>\n side === \"lower\" ? (x > y ? x : y) : x < y ? x : y,\n );\n};\n\n/**\n * The smallest positive integer a `multipleOf` divides.\n *\n * An integral step is the integer its double holds; a fractional one, such as\n * `1.5`, steps by its smallest integer multiple (`3`).\n */\nconst integerStep = (multipleOf: number): bigint | null => {\n if (Number.isFinite(multipleOf) === false) return null;\n if (Number.isInteger(multipleOf)) return BigInt(multipleOf);\n return _decimalIntegerStep(multipleOf)?.coefficient ?? null;\n};\n\nconst ceilDivide = (x: bigint, y: bigint): bigint => {\n const quotient: bigint = x / y;\n return x % y > BigInt(0) ? quotient + BigInt(1) : quotient;\n};\n\nconst floorDivide = (x: bigint, y: bigint): bigint => {\n const quotient: bigint = x / y;\n return x % y < BigInt(0) ? quotient - BigInt(1) : quotient;\n};\n\n/** Draws an integer in `[minimum, maximum]`, scaling one 53-bit sample. */\nconst between = (minimum: bigint, maximum: bigint): bigint => {\n const scale: bigint = BigInt(1) << BigInt(53);\n const sample: bigint = BigInt(\n Math.min(\n Number(scale - BigInt(1)),\n Math.floor(Math.max(0, Math.random()) * Number(scale)),\n ),\n );\n return minimum + ((maximum - minimum + BigInt(1)) * sample) / scale;\n};\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,iBAAiB,WAAiD;CAC7E,MAAM,QAAuB,SAC3B,OAAO,SACP,OAAO,kBACP,OACF;CACA,MAAM,QAAuB,SAC3B,OAAO,SACP,OAAO,kBACP,OACF;CACA,MAAM,UACJ,UAAU,UAAU,OAAO,OAAO,CAAC,IAAI,QAAQ,OAAO,GAAG;CAC3D,MAAM,UACJ,UAAU,UAAU,OAAO,OAAO,GAAG,IAAI,QAAQ,OAAO,GAAG;CAC7D,IAAI,UAAU,SACZ,MAAM,IAAI,MAAM,8CAA8C;CAChE,IAAI,OAAO,eAAe,KAAA,GAAW,OAAO,QAAQ,SAAS,OAAO;CAEpE,MAAM,OAAsB,YAAY,OAAO,UAAU;CACzD,IAAI,SAAS,QAAQ,QAAQ,OAAO,CAAC,GACnC,MAAM,IAAI,MAAM,wDAAwD;CAC1E,MAAM,QAAgB,WAAW,SAAS,IAAI;CAC9C,MAAM,OAAe,YAAY,SAAS,IAAI;CAC9C,IAAI,QAAQ,MACV,MAAM,IAAI,MAAM,gDAAgD;CAClE,OAAO,QAAQ,OAAO,IAAI,IAAI;AAChC;;;;;;;AAQA,MAAM,YACJ,WACA,WACA,SACkB;CAClB,MAAM,aAAuB,CAAC;CAC9B,KAAK,MAAM,CAAC,OAAO,SAAS,CAC1B,CAAC,WAAW,KAAK,GACjB,CAAC,WAAW,IAAI,CAClB,GAAY;EACV,IAAI,UAAU,KAAA,GAAW;EACzB,IAAI,OAAO,SAA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@ const scalar = (props) => {
|
|
|
30
30
|
return Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
|
|
31
31
|
};
|
|
32
32
|
const getLowerBoundary = (schema) => {
|
|
33
|
-
const inclusive = schema.minimum
|
|
34
|
-
|
|
35
|
-
: { value: schema.minimum, exclusive: false };
|
|
36
|
-
const exclusive = schema.exclusiveMinimum === undefined
|
|
37
|
-
? null
|
|
38
|
-
: { value: schema.exclusiveMinimum, exclusive: true };
|
|
33
|
+
const inclusive = boundary(schema.minimum, false, "lower");
|
|
34
|
+
const exclusive = boundary(schema.exclusiveMinimum, true, "lower");
|
|
39
35
|
const selected = selectBoundary(inclusive, exclusive, Math.max);
|
|
40
36
|
if (selected === null)
|
|
41
37
|
return null;
|
|
@@ -47,12 +43,8 @@ const getLowerBoundary = (schema) => {
|
|
|
47
43
|
};
|
|
48
44
|
};
|
|
49
45
|
const getUpperBoundary = (schema) => {
|
|
50
|
-
const inclusive = schema.maximum
|
|
51
|
-
|
|
52
|
-
: { value: schema.maximum, exclusive: false };
|
|
53
|
-
const exclusive = schema.exclusiveMaximum === undefined
|
|
54
|
-
? null
|
|
55
|
-
: { value: schema.exclusiveMaximum, exclusive: true };
|
|
46
|
+
const inclusive = boundary(schema.maximum, false, "upper");
|
|
47
|
+
const exclusive = boundary(schema.exclusiveMaximum, true, "upper");
|
|
56
48
|
const selected = selectBoundary(inclusive, exclusive, Math.min);
|
|
57
49
|
if (selected === null)
|
|
58
50
|
return null;
|
|
@@ -63,6 +55,23 @@ const getUpperBoundary = (schema) => {
|
|
|
63
55
|
exclusive: false,
|
|
64
56
|
};
|
|
65
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Reads one bound, which may be infinite.
|
|
60
|
+
*
|
|
61
|
+
* A type tag built from an overflowing literal (`Maximum<1e400>`) carries an
|
|
62
|
+
* infinite bound (#2452). `-Infinity` below or `Infinity` above excludes no
|
|
63
|
+
* finite number, so it is no bound at all; `Infinity` below or `-Infinity`
|
|
64
|
+
* above excludes every finite number, so no value can be generated.
|
|
65
|
+
*/
|
|
66
|
+
const boundary = (value, exclusive, side) => {
|
|
67
|
+
if (value === undefined)
|
|
68
|
+
return null;
|
|
69
|
+
if (Number.isFinite(value))
|
|
70
|
+
return { value, exclusive };
|
|
71
|
+
if (value === (side === "lower" ? -Infinity : Infinity))
|
|
72
|
+
return null;
|
|
73
|
+
throw new Error("Numeric range has no finite value.");
|
|
74
|
+
};
|
|
66
75
|
const selectBoundary = (x, y, compare) => {
|
|
67
76
|
if (x === null)
|
|
68
77
|
return y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomInteger.js","sourceRoot":"","sources":["../../src/internal/_randomInteger.ts"],"names":[],"mappings":";;;AAEA,uDAAoD;AAE7C,MAAM,cAAc,GAAG,CAC5B,MAAoC,EAC5B,EAAE;;IACV,MAAM,KAAK,GAAqB,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,KAAK,GAAqB,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,OAAO,SACX,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;IAC3D,MAAM,OAAO,SACX,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;IAC7D,IAAI,OAAO,GAAG,OAAO;QACnB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,OAAO,MAAM,CAAC,UAAU,KAAK,SAAS;QACpC,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAC9B,CAAC,CAAC,IAAA,iCAAe,EAAC;YACd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AEF;;;;;;;GAOG;AACH,MAAM,QAAQ,GAAG,CACf,KAAyB,EACzB,SAAkB,EAClB,IAAuB,EACL,EAAE;IACpB,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACrC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IACxD,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IACrE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CACrB,CAAmB,EACnB,CAAmB,EACnB,OAAyC,EACvB,EAAE;IACpB,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QACrB,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IACnE,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC"}
|
|
@@ -25,14 +25,8 @@ const scalar = (props) => {
|
|
|
25
25
|
return Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
|
|
26
26
|
};
|
|
27
27
|
const getLowerBoundary = (schema) => {
|
|
28
|
-
const inclusive = schema.minimum
|
|
29
|
-
|
|
30
|
-
exclusive: false
|
|
31
|
-
};
|
|
32
|
-
const exclusive = schema.exclusiveMinimum === void 0 ? null : {
|
|
33
|
-
value: schema.exclusiveMinimum,
|
|
34
|
-
exclusive: true
|
|
35
|
-
};
|
|
28
|
+
const inclusive = boundary(schema.minimum, false, "lower");
|
|
29
|
+
const exclusive = boundary(schema.exclusiveMinimum, true, "lower");
|
|
36
30
|
const selected = selectBoundary(inclusive, exclusive, Math.max);
|
|
37
31
|
if (selected === null) return null;
|
|
38
32
|
return {
|
|
@@ -41,14 +35,8 @@ const getLowerBoundary = (schema) => {
|
|
|
41
35
|
};
|
|
42
36
|
};
|
|
43
37
|
const getUpperBoundary = (schema) => {
|
|
44
|
-
const inclusive = schema.maximum
|
|
45
|
-
|
|
46
|
-
exclusive: false
|
|
47
|
-
};
|
|
48
|
-
const exclusive = schema.exclusiveMaximum === void 0 ? null : {
|
|
49
|
-
value: schema.exclusiveMaximum,
|
|
50
|
-
exclusive: true
|
|
51
|
-
};
|
|
38
|
+
const inclusive = boundary(schema.maximum, false, "upper");
|
|
39
|
+
const exclusive = boundary(schema.exclusiveMaximum, true, "upper");
|
|
52
40
|
const selected = selectBoundary(inclusive, exclusive, Math.min);
|
|
53
41
|
if (selected === null) return null;
|
|
54
42
|
return {
|
|
@@ -56,6 +44,23 @@ const getUpperBoundary = (schema) => {
|
|
|
56
44
|
exclusive: false
|
|
57
45
|
};
|
|
58
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Reads one bound, which may be infinite.
|
|
49
|
+
*
|
|
50
|
+
* A type tag built from an overflowing literal (`Maximum<1e400>`) carries an
|
|
51
|
+
* infinite bound (#2452). `-Infinity` below or `Infinity` above excludes no
|
|
52
|
+
* finite number, so it is no bound at all; `Infinity` below or `-Infinity`
|
|
53
|
+
* above excludes every finite number, so no value can be generated.
|
|
54
|
+
*/
|
|
55
|
+
const boundary = (value, exclusive, side) => {
|
|
56
|
+
if (value === void 0) return null;
|
|
57
|
+
if (Number.isFinite(value)) return {
|
|
58
|
+
value,
|
|
59
|
+
exclusive
|
|
60
|
+
};
|
|
61
|
+
if (value === (side === "lower" ? -Infinity : Infinity)) return null;
|
|
62
|
+
throw new Error("Numeric range has no finite value.");
|
|
63
|
+
};
|
|
59
64
|
const selectBoundary = (x, y, compare) => {
|
|
60
65
|
if (x === null) return y;
|
|
61
66
|
if (y === null) return x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomInteger.mjs","names":[],"sources":["../../src/internal/_randomInteger.ts"],"sourcesContent":["import { OpenApi } from \"@typia/interface\";\n\nimport { _randomMultiple } from \"./_randomMultiple\";\n\nexport const _randomInteger = (\n schema: OpenApi.IJsonSchema.IInteger,\n): number => {\n const lower: IBoundary | null = getLowerBoundary(schema);\n const upper: IBoundary | null = getUpperBoundary(schema);\n const minimum: number =\n lower?.value ?? (upper === null ? 0 : upper.value - 100);\n const maximum: number =\n upper?.value ?? (lower === null ? 100 : lower.value + 100);\n if (minimum > maximum)\n throw new Error(\"Minimum value is greater than maximum value.\");\n return schema.multipleOf === undefined\n ? scalar({ minimum, maximum })\n : _randomMultiple({\n minimum,\n maximum,\n multipleOf: schema.multipleOf,\n exclusiveMinimum: lower?.exclusive ?? false,\n exclusiveMaximum: upper?.exclusive ?? false,\n integer: true,\n });\n};\n\nconst scalar = (props: { minimum: number; maximum: number }): number => {\n const minimum: number = Math.ceil(props.minimum);\n const maximum: number = Math.floor(props.maximum);\n if (minimum > maximum) throw new Error(\"The integer range is empty.\");\n return Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;\n};\n\nconst getLowerBoundary = (\n schema: OpenApi.IJsonSchema.IInteger,\n): IBoundary | null => {\n const inclusive: IBoundary | null
|
|
1
|
+
{"version":3,"file":"_randomInteger.mjs","names":[],"sources":["../../src/internal/_randomInteger.ts"],"sourcesContent":["import { OpenApi } from \"@typia/interface\";\n\nimport { _randomMultiple } from \"./_randomMultiple\";\n\nexport const _randomInteger = (\n schema: OpenApi.IJsonSchema.IInteger,\n): number => {\n const lower: IBoundary | null = getLowerBoundary(schema);\n const upper: IBoundary | null = getUpperBoundary(schema);\n const minimum: number =\n lower?.value ?? (upper === null ? 0 : upper.value - 100);\n const maximum: number =\n upper?.value ?? (lower === null ? 100 : lower.value + 100);\n if (minimum > maximum)\n throw new Error(\"Minimum value is greater than maximum value.\");\n return schema.multipleOf === undefined\n ? scalar({ minimum, maximum })\n : _randomMultiple({\n minimum,\n maximum,\n multipleOf: schema.multipleOf,\n exclusiveMinimum: lower?.exclusive ?? false,\n exclusiveMaximum: upper?.exclusive ?? false,\n integer: true,\n });\n};\n\nconst scalar = (props: { minimum: number; maximum: number }): number => {\n const minimum: number = Math.ceil(props.minimum);\n const maximum: number = Math.floor(props.maximum);\n if (minimum > maximum) throw new Error(\"The integer range is empty.\");\n return Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;\n};\n\nconst getLowerBoundary = (\n schema: OpenApi.IJsonSchema.IInteger,\n): IBoundary | null => {\n const inclusive: IBoundary | null = boundary(schema.minimum, false, \"lower\");\n const exclusive: IBoundary | null = boundary(\n schema.exclusiveMinimum,\n true,\n \"lower\",\n );\n const selected: IBoundary | null = selectBoundary(\n inclusive,\n exclusive,\n Math.max,\n );\n if (selected === null) return null;\n return {\n value: selected.exclusive\n ? Math.floor(selected.value) + 1\n : Math.ceil(selected.value),\n exclusive: false,\n };\n};\n\nconst getUpperBoundary = (\n schema: OpenApi.IJsonSchema.IInteger,\n): IBoundary | null => {\n const inclusive: IBoundary | null = boundary(schema.maximum, false, \"upper\");\n const exclusive: IBoundary | null = boundary(\n schema.exclusiveMaximum,\n true,\n \"upper\",\n );\n const selected: IBoundary | null = selectBoundary(\n inclusive,\n exclusive,\n Math.min,\n );\n if (selected === null) return null;\n return {\n value: selected.exclusive\n ? Math.ceil(selected.value) - 1\n : Math.floor(selected.value),\n exclusive: false,\n };\n};\n\n/**\n * Reads one bound, which may be infinite.\n *\n * A type tag built from an overflowing literal (`Maximum<1e400>`) carries an\n * infinite bound (#2452). `-Infinity` below or `Infinity` above excludes no\n * finite number, so it is no bound at all; `Infinity` below or `-Infinity`\n * above excludes every finite number, so no value can be generated.\n */\nconst boundary = (\n value: number | undefined,\n exclusive: boolean,\n side: \"lower\" | \"upper\",\n): IBoundary | null => {\n if (value === undefined) return null;\n if (Number.isFinite(value)) return { value, exclusive };\n if (value === (side === \"lower\" ? -Infinity : Infinity)) return null;\n throw new Error(\"Numeric range has no finite value.\");\n};\n\nconst selectBoundary = (\n x: IBoundary | null,\n y: IBoundary | null,\n compare: (x: number, y: number) => number,\n): IBoundary | null => {\n if (x === null) return y;\n if (y === null) return x;\n if (x.value === y.value)\n return { value: x.value, exclusive: x.exclusive || y.exclusive };\n return compare(x.value, y.value) === x.value ? x : y;\n};\n\ninterface IBoundary {\n value: number;\n exclusive: boolean;\n}\n"],"mappings":";;AAIA,MAAa,kBACX,WACW;CACX,MAAM,QAA0B,iBAAiB,MAAM;CACvD,MAAM,QAA0B,iBAAiB,MAAM;CACvD,MAAM,UACJ,OAAO,UAAU,UAAU,OAAO,IAAI,MAAM,QAAQ;CACtD,MAAM,UACJ,OAAO,UAAU,UAAU,OAAO,MAAM,MAAM,QAAQ;CACxD,IAAI,UAAU,SACZ,MAAM,IAAI,MAAM,8CAA8C;CAChE,OAAO,OAAO,eAAe,KAAA,IACzB,OAAO;EAAE;EAAS;CAAQ,CAAC,IAC3B,gBAAgB;EACd;EACA;EACA,YAAY,OAAO;EACnB,kBAAkB,OAAO,aAAa;EACtC,kBAAkB,OAAO,aAAa;EACtC,SAAS;CACX,CAAC;AACP;AAEA,MAAM,UAAU,UAAwD;CACtE,MAAM,UAAkB,KAAK,KAAK,MAAM,OAAO;CAC/C,MAAM,UAAkB,KAAK,MAAM,MAAM,OAAO;CAChD,IAAI,UAAU,SAAS,MAAM,IAAI,MAAM,6BAA6B;CACpE,OAAO,KAAK,MAAM,KAAK,OAAO,KAAK,UAAU,UAAU,EAAE,IAAI;AAC/D;AAEA,MAAM,oBACJ,WACqB;CACrB,MAAM,YAA8B,SAAS,OAAO,SAAS,OAAO,OAAO;CAC3E,MAAM,YAA8B,SAClC,OAAO,kBACP,MACA,OACF;CACA,MAAM,WAA6B,eACjC,WACA,WACA,KAAK,GACP;CACA,IAAI,aAAa,MAAM,OAAO;CAC9B,OAAO;EACL,OAAO,SAAS,YACZ,KAAK,MAAM,SAAS,KAAK,IAAI,IAC7B,KAAK,KAAK,SAAS,KAAK;EAC5B,WAAW;CACb;AACF;AAEA,MAAM,oBACJ,WACqB;CACrB,MAAM,YAA8B,SAAS,OAAO,SAAS,OAAO,OAAO;CAC3E,MAAM,YAA8B,SAClC,OAAO,kBACP,MACA,OACF;CACA,MAAM,WAA6B,eACjC,WACA,WACA,KAAK,GACP;CACA,IAAI,aAAa,MAAM,OAAO;CAC9B,OAAO;EACL,OAAO,SAAS,YACZ,KAAK,KAAK,SAAS,KAAK,IAAI,IAC5B,KAAK,MAAM,SAAS,KAAK;EAC7B,WAAW;CACb;AACF;;;;;;;;;AAUA,MAAM,YACJ,OACA,WACA,SACqB;CACrB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,OAAO,SAAS,KAAK,GAAG,OAAO;EAAE;EAAO;CAAU;CACtD,IAAI,WAAW,SAAS,UAAU,YAAY,WAAW,OAAO;CAChE,MAAM,IAAI,MAAM,oCAAoC;AACtD;AAEA,MAAM,kBACJ,GACA,GACA,YACqB;CACrB,IAAI,MAAM,MAAM,OAAO;CACvB,IAAI,MAAM,MAAM,OAAO;CACvB,IAAI,EAAE,UAAU,EAAE,OAChB,OAAO;EAAE,OAAO,EAAE;EAAO,WAAW,EAAE,aAAa,EAAE;CAAU;CACjE,OAAO,QAAQ,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,QAAQ,IAAI;AACrD"}
|
|
@@ -41,16 +41,25 @@ const scalar = (props) => {
|
|
|
41
41
|
}
|
|
42
42
|
return value;
|
|
43
43
|
};
|
|
44
|
-
const getLowerBoundary = (schema) => selectBoundary(schema.minimum
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
const getLowerBoundary = (schema) => selectBoundary(boundary(schema.minimum, false, "lower"), boundary(schema.exclusiveMinimum, true, "lower"), Math.max);
|
|
45
|
+
const getUpperBoundary = (schema) => selectBoundary(boundary(schema.maximum, false, "upper"), boundary(schema.exclusiveMaximum, true, "upper"), Math.min);
|
|
46
|
+
/**
|
|
47
|
+
* Reads one bound, which may be infinite.
|
|
48
|
+
*
|
|
49
|
+
* A type tag built from an overflowing literal (`Maximum<1e400>`) carries an
|
|
50
|
+
* infinite bound (#2452). `-Infinity` below or `Infinity` above excludes no
|
|
51
|
+
* finite number, so it is no bound at all; `Infinity` below or `-Infinity`
|
|
52
|
+
* above excludes every finite number, so no value can be generated.
|
|
53
|
+
*/
|
|
54
|
+
const boundary = (value, exclusive, side) => {
|
|
55
|
+
if (value === undefined)
|
|
56
|
+
return null;
|
|
57
|
+
if (Number.isFinite(value))
|
|
58
|
+
return { value, exclusive };
|
|
59
|
+
if (value === (side === "lower" ? -Infinity : Infinity))
|
|
60
|
+
return null;
|
|
61
|
+
throw new Error("Numeric range has no finite value.");
|
|
62
|
+
};
|
|
54
63
|
const selectBoundary = (x, y, compare) => {
|
|
55
64
|
if (x === null)
|
|
56
65
|
return y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomNumber.js","sourceRoot":"","sources":["../../src/internal/_randomNumber.ts"],"names":[],"mappings":";;;AAEA,uDAAoD;AAE7C,MAAM,aAAa,GAAG,CAAC,MAAmC,EAAU,EAAE;;IAC3E,MAAM,KAAK,GAAqB,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,KAAK,GAAqB,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,OAAO,SACX,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CACrB,CAAmB,EACnB,CAAmB,EACnB,OAAyC,EACvB,EAAE;IACpB,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QACrB,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IACnE,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC"}
|
|
@@ -30,20 +30,25 @@ const scalar = (props) => {
|
|
|
30
30
|
}
|
|
31
31
|
return value;
|
|
32
32
|
};
|
|
33
|
-
const getLowerBoundary = (schema) => selectBoundary(schema.minimum
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
value
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
const getLowerBoundary = (schema) => selectBoundary(boundary(schema.minimum, false, "lower"), boundary(schema.exclusiveMinimum, true, "lower"), Math.max);
|
|
34
|
+
const getUpperBoundary = (schema) => selectBoundary(boundary(schema.maximum, false, "upper"), boundary(schema.exclusiveMaximum, true, "upper"), Math.min);
|
|
35
|
+
/**
|
|
36
|
+
* Reads one bound, which may be infinite.
|
|
37
|
+
*
|
|
38
|
+
* A type tag built from an overflowing literal (`Maximum<1e400>`) carries an
|
|
39
|
+
* infinite bound (#2452). `-Infinity` below or `Infinity` above excludes no
|
|
40
|
+
* finite number, so it is no bound at all; `Infinity` below or `-Infinity`
|
|
41
|
+
* above excludes every finite number, so no value can be generated.
|
|
42
|
+
*/
|
|
43
|
+
const boundary = (value, exclusive, side) => {
|
|
44
|
+
if (value === void 0) return null;
|
|
45
|
+
if (Number.isFinite(value)) return {
|
|
46
|
+
value,
|
|
47
|
+
exclusive
|
|
48
|
+
};
|
|
49
|
+
if (value === (side === "lower" ? -Infinity : Infinity)) return null;
|
|
50
|
+
throw new Error("Numeric range has no finite value.");
|
|
51
|
+
};
|
|
47
52
|
const selectBoundary = (x, y, compare) => {
|
|
48
53
|
if (x === null) return y;
|
|
49
54
|
if (y === null) return x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomNumber.mjs","names":[],"sources":["../../src/internal/_randomNumber.ts"],"sourcesContent":["import { OpenApi } from \"@typia/interface\";\n\nimport { _randomMultiple } from \"./_randomMultiple\";\n\nexport const _randomNumber = (schema: OpenApi.IJsonSchema.INumber): number => {\n const lower: IBoundary | null = getLowerBoundary(schema);\n const upper: IBoundary | null = getUpperBoundary(schema);\n const minimum: number =\n lower?.value ?? (upper === null ? 0 : upper.value - 100);\n const maximum: number =\n upper?.value ?? (lower === null ? 100 : lower.value + 100);\n if (minimum > maximum)\n throw new Error(\"Minimum value is greater than maximum value.\");\n return schema.multipleOf === undefined\n ? scalar({\n minimum,\n maximum,\n exclusiveMinimum: lower?.exclusive ?? false,\n exclusiveMaximum: upper?.exclusive ?? false,\n })\n : _randomMultiple({\n minimum,\n maximum,\n multipleOf: schema.multipleOf,\n exclusiveMinimum: lower?.exclusive ?? false,\n exclusiveMaximum: upper?.exclusive ?? false,\n integer: false,\n });\n};\n\nconst scalar = (props: {\n minimum: number;\n maximum: number;\n exclusiveMinimum: boolean;\n exclusiveMaximum: boolean;\n}): number => {\n if (\n props.minimum === props.maximum &&\n (props.exclusiveMinimum || props.exclusiveMaximum)\n )\n throw new Error(\"Exclusive numeric range is empty.\");\n const value: number =\n Math.random() * (props.maximum - props.minimum) + props.minimum;\n if (\n (props.exclusiveMinimum && value === props.minimum) ||\n (props.exclusiveMaximum && value === props.maximum)\n ) {\n const middle: number = props.minimum + (props.maximum - props.minimum) / 2;\n if (middle <= props.minimum || middle >= props.maximum)\n throw new Error(\"Exclusive numeric range has no representable value.\");\n return middle;\n }\n return value;\n};\n\nconst getLowerBoundary = (\n schema: OpenApi.IJsonSchema.INumber,\n): IBoundary | null =>\n selectBoundary(\n schema.minimum
|
|
1
|
+
{"version":3,"file":"_randomNumber.mjs","names":[],"sources":["../../src/internal/_randomNumber.ts"],"sourcesContent":["import { OpenApi } from \"@typia/interface\";\n\nimport { _randomMultiple } from \"./_randomMultiple\";\n\nexport const _randomNumber = (schema: OpenApi.IJsonSchema.INumber): number => {\n const lower: IBoundary | null = getLowerBoundary(schema);\n const upper: IBoundary | null = getUpperBoundary(schema);\n const minimum: number =\n lower?.value ?? (upper === null ? 0 : upper.value - 100);\n const maximum: number =\n upper?.value ?? (lower === null ? 100 : lower.value + 100);\n if (minimum > maximum)\n throw new Error(\"Minimum value is greater than maximum value.\");\n return schema.multipleOf === undefined\n ? scalar({\n minimum,\n maximum,\n exclusiveMinimum: lower?.exclusive ?? false,\n exclusiveMaximum: upper?.exclusive ?? false,\n })\n : _randomMultiple({\n minimum,\n maximum,\n multipleOf: schema.multipleOf,\n exclusiveMinimum: lower?.exclusive ?? false,\n exclusiveMaximum: upper?.exclusive ?? false,\n integer: false,\n });\n};\n\nconst scalar = (props: {\n minimum: number;\n maximum: number;\n exclusiveMinimum: boolean;\n exclusiveMaximum: boolean;\n}): number => {\n if (\n props.minimum === props.maximum &&\n (props.exclusiveMinimum || props.exclusiveMaximum)\n )\n throw new Error(\"Exclusive numeric range is empty.\");\n const value: number =\n Math.random() * (props.maximum - props.minimum) + props.minimum;\n if (\n (props.exclusiveMinimum && value === props.minimum) ||\n (props.exclusiveMaximum && value === props.maximum)\n ) {\n const middle: number = props.minimum + (props.maximum - props.minimum) / 2;\n if (middle <= props.minimum || middle >= props.maximum)\n throw new Error(\"Exclusive numeric range has no representable value.\");\n return middle;\n }\n return value;\n};\n\nconst getLowerBoundary = (\n schema: OpenApi.IJsonSchema.INumber,\n): IBoundary | null =>\n selectBoundary(\n boundary(schema.minimum, false, \"lower\"),\n boundary(schema.exclusiveMinimum, true, \"lower\"),\n Math.max,\n );\n\nconst getUpperBoundary = (\n schema: OpenApi.IJsonSchema.INumber,\n): IBoundary | null =>\n selectBoundary(\n boundary(schema.maximum, false, \"upper\"),\n boundary(schema.exclusiveMaximum, true, \"upper\"),\n Math.min,\n );\n\n/**\n * Reads one bound, which may be infinite.\n *\n * A type tag built from an overflowing literal (`Maximum<1e400>`) carries an\n * infinite bound (#2452). `-Infinity` below or `Infinity` above excludes no\n * finite number, so it is no bound at all; `Infinity` below or `-Infinity`\n * above excludes every finite number, so no value can be generated.\n */\nconst boundary = (\n value: number | undefined,\n exclusive: boolean,\n side: \"lower\" | \"upper\",\n): IBoundary | null => {\n if (value === undefined) return null;\n if (Number.isFinite(value)) return { value, exclusive };\n if (value === (side === \"lower\" ? -Infinity : Infinity)) return null;\n throw new Error(\"Numeric range has no finite value.\");\n};\n\nconst selectBoundary = (\n x: IBoundary | null,\n y: IBoundary | null,\n compare: (x: number, y: number) => number,\n): IBoundary | null => {\n if (x === null) return y;\n if (y === null) return x;\n if (x.value === y.value)\n return { value: x.value, exclusive: x.exclusive || y.exclusive };\n return compare(x.value, y.value) === x.value ? x : y;\n};\n\ninterface IBoundary {\n value: number;\n exclusive: boolean;\n}\n"],"mappings":";;AAIA,MAAa,iBAAiB,WAAgD;CAC5E,MAAM,QAA0B,iBAAiB,MAAM;CACvD,MAAM,QAA0B,iBAAiB,MAAM;CACvD,MAAM,UACJ,OAAO,UAAU,UAAU,OAAO,IAAI,MAAM,QAAQ;CACtD,MAAM,UACJ,OAAO,UAAU,UAAU,OAAO,MAAM,MAAM,QAAQ;CACxD,IAAI,UAAU,SACZ,MAAM,IAAI,MAAM,8CAA8C;CAChE,OAAO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OAChB,OAAO;EAAE,OAAO,EAAE;EAAO,WAAW,EAAE,aAAa,EAAE;CAAU;CACjE,OAAO,QAAQ,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,QAAQ,IAAI;AACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const _stringLengthGte: (value: string, length: number) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._stringLengthGte = void 0;
|
|
4
|
+
const _stringLengthGte = (value, length) => {
|
|
5
|
+
let count = 0;
|
|
6
|
+
if (length <= count)
|
|
7
|
+
return true;
|
|
8
|
+
for (const _ch of value)
|
|
9
|
+
if (length <= ++count)
|
|
10
|
+
return true;
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
13
|
+
exports._stringLengthGte = _stringLengthGte;
|
|
14
|
+
//# sourceMappingURL=_stringLengthGte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_stringLengthGte.js","sourceRoot":"","sources":["../../src/internal/_stringLengthGte.ts"],"names":[],"mappings":";;;AAAO,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAE,MAAc,EAAW,EAAE;IACzE,IAAI,KAAK,GAAW,CAAC,CAAC;IACtB,IAAI,MAAM,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IACjC,KAAK,MAAM,GAAG,IAAI,KAAK;QAAE,IAAI,MAAM,IAAI,EAAE,KAAK;YAAE,OAAO,IAAI,CAAC;IAC5D,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AALW,QAAA,gBAAgB,GAAhB,gBAAgB,CAK3B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/internal/_stringLengthGte.ts
|
|
2
|
+
const _stringLengthGte = (value, length) => {
|
|
3
|
+
let count = 0;
|
|
4
|
+
if (length <= count) return true;
|
|
5
|
+
for (const _ch of value) if (length <= ++count) return true;
|
|
6
|
+
return false;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _stringLengthGte };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=_stringLengthGte.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_stringLengthGte.mjs","names":[],"sources":["../../src/internal/_stringLengthGte.ts"],"sourcesContent":["export const _stringLengthGte = (value: string, length: number): boolean => {\n let count: number = 0;\n if (length <= count) return true;\n for (const _ch of value) if (length <= ++count) return true;\n return false;\n};\n"],"mappings":";AAAA,MAAa,oBAAoB,OAAe,WAA4B;CAC1E,IAAI,QAAgB;CACpB,IAAI,UAAU,OAAO,OAAO;CAC5B,KAAK,MAAM,OAAO,OAAO,IAAI,UAAU,EAAE,OAAO,OAAO;CACvD,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const _stringLengthLte: (value: string, length: number) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._stringLengthLte = void 0;
|
|
4
|
+
const _stringLengthLte = (value, length) => {
|
|
5
|
+
let count = 0;
|
|
6
|
+
if (!(count <= length))
|
|
7
|
+
return false;
|
|
8
|
+
for (const _ch of value)
|
|
9
|
+
if (!(++count <= length))
|
|
10
|
+
return false;
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
exports._stringLengthLte = _stringLengthLte;
|
|
14
|
+
//# sourceMappingURL=_stringLengthLte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_stringLengthLte.js","sourceRoot":"","sources":["../../src/internal/_stringLengthLte.ts"],"names":[],"mappings":";;;AAAO,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAE,MAAc,EAAW,EAAE;IACzE,IAAI,KAAK,GAAW,CAAC,CAAC;IACtB,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,KAAK,MAAM,GAAG,IAAI,KAAK;QAAE,IAAI,CAAC,CAAC,EAAE,KAAK,IAAI,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC;IAChE,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,gBAAgB,GAAhB,gBAAgB,CAK3B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/internal/_stringLengthLte.ts
|
|
2
|
+
const _stringLengthLte = (value, length) => {
|
|
3
|
+
let count = 0;
|
|
4
|
+
if (!(count <= length)) return false;
|
|
5
|
+
for (const _ch of value) if (!(++count <= length)) return false;
|
|
6
|
+
return true;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _stringLengthLte };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=_stringLengthLte.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_stringLengthLte.mjs","names":[],"sources":["../../src/internal/_stringLengthLte.ts"],"sourcesContent":["export const _stringLengthLte = (value: string, length: number): boolean => {\n let count: number = 0;\n if (!(count <= length)) return false;\n for (const _ch of value) if (!(++count <= length)) return false;\n return true;\n};\n"],"mappings":";AAAA,MAAa,oBAAoB,OAAe,WAA4B;CAC1E,IAAI,QAAgB;CACpB,IAAI,EAAE,SAAS,SAAS,OAAO;CAC/B,KAAK,MAAM,OAAO,OAAO,IAAI,EAAE,EAAE,SAAS,SAAS,OAAO;CAC1D,OAAO;AACT"}
|
package/lib/llm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IJsonParseResult, ILlmApplication, ILlmController, ILlmSchema, ILlmStructuredOutput } from "@typia/interface";
|
|
1
|
+
import { IJsonParseResult, ILlmApplication, ILlmController, ILlmEvaluation, ILlmSchema, ILlmStructuredOutput } from "@typia/interface";
|
|
2
2
|
/**
|
|
3
3
|
* Creates LLM function calling controller.
|
|
4
4
|
*
|
|
@@ -141,6 +141,59 @@ export declare function structuredOutput<T extends Record<string, any>, Config e
|
|
|
141
141
|
*/
|
|
142
142
|
equals: boolean;
|
|
143
143
|
}> = {}>(): ILlmStructuredOutput<T>;
|
|
144
|
+
/**
|
|
145
|
+
* Creates LLM evaluation questions.
|
|
146
|
+
*
|
|
147
|
+
* @danger You must configure the generic argument `T`
|
|
148
|
+
*/
|
|
149
|
+
export declare function evaluation(): never;
|
|
150
|
+
/**
|
|
151
|
+
* Creates LLM evaluation questions from TypeScript object type.
|
|
152
|
+
*
|
|
153
|
+
* Generates {@link ILlmEvaluation} for evaluation models, which answer typed
|
|
154
|
+
* questions about a shared state with probabilities instead of generating text:
|
|
155
|
+
* TypeSafe's Jev natively, and OpenAI, Anthropic, and Google through Vercel AI
|
|
156
|
+
* SDK's `experimental_evaluate()`.
|
|
157
|
+
*
|
|
158
|
+
* Every leaf property of `T` becomes one question, and its JSDoc description
|
|
159
|
+
* becomes the question text:
|
|
160
|
+
*
|
|
161
|
+
* - `boolean` → boolean question
|
|
162
|
+
* - String enum or string literal union → choice question
|
|
163
|
+
* - Numeric enum or numeric literal union → score question
|
|
164
|
+
* - Array of a string literal union or string enum → one boolean question per
|
|
165
|
+
* member
|
|
166
|
+
* - Nested object → flattened, one question per leaf
|
|
167
|
+
*
|
|
168
|
+
* Types an evaluation model cannot answer, such as `string`, `number`, optional
|
|
169
|
+
* properties, or a leaf without a JSDoc description, are compile errors. Use
|
|
170
|
+
* `tags.Probability<N>` or `@probability N` to set decision thresholds and
|
|
171
|
+
* acceptance minimums. Once one choice, score, or set member declares a
|
|
172
|
+
* requirement, every member must declare one or inherit the property's
|
|
173
|
+
* `@probability` default. A nested object's own JSDoc description is not sent
|
|
174
|
+
* to the model; only the leaves' descriptions become question text. Other
|
|
175
|
+
* validation refinements that the answer decoder cannot enforce are compile
|
|
176
|
+
* errors.
|
|
177
|
+
*
|
|
178
|
+
* This feature is experimental. It follows Vercel AI SDK's evaluation model
|
|
179
|
+
* specification, which is itself experimental and may change in patch
|
|
180
|
+
* releases.
|
|
181
|
+
*
|
|
182
|
+
* Workflow:
|
|
183
|
+
*
|
|
184
|
+
* 1. Pass {@link ILlmEvaluation.questions} to the evaluation model
|
|
185
|
+
* 2. Receive the answer map keyed by the same question IDs
|
|
186
|
+
* 3. Use {@link ILlmEvaluation.decode} to fold the answers back into `T`; pass the
|
|
187
|
+
* model's declared rounding precision when available
|
|
188
|
+
*
|
|
189
|
+
* Related functions:
|
|
190
|
+
*
|
|
191
|
+
* - {@link structuredOutput} — Structured output generated as text by an LLM
|
|
192
|
+
*
|
|
193
|
+
* @template T Target decision type (object with static properties)
|
|
194
|
+
* @returns LLM evaluation questions with a checked answer decoder
|
|
195
|
+
*/
|
|
196
|
+
export declare function evaluation<T extends Record<string, any>>(): ILlmEvaluation<T>;
|
|
144
197
|
/**
|
|
145
198
|
* Creates LLM parameters schema.
|
|
146
199
|
*
|
package/lib/llm.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.controller = controller;
|
|
4
4
|
exports.application = application;
|
|
5
5
|
exports.structuredOutput = structuredOutput;
|
|
6
|
+
exports.evaluation = evaluation;
|
|
6
7
|
exports.parameters = parameters;
|
|
7
8
|
exports.schema = schema;
|
|
8
9
|
exports.parse = parse;
|
|
@@ -23,6 +24,10 @@ function structuredOutput() {
|
|
|
23
24
|
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("llm.structuredOutput");
|
|
24
25
|
}
|
|
25
26
|
/** @internal */
|
|
27
|
+
function evaluation() {
|
|
28
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("llm.evaluation");
|
|
29
|
+
}
|
|
30
|
+
/** @internal */
|
|
26
31
|
function parameters() {
|
|
27
32
|
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("llm.parameters");
|
|
28
33
|
}
|
package/lib/llm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA,gGAA6F;AAmE7F,gBAAgB;AAChB,oBAA2B,GAAG,KAAY;IACxC,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,CAAC;AAClD,CAAC;AA0DD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,iBAAiB,CAAC,CAAC;AACnD,CAAC;AA2DD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,sBAAsB,CAAC,CAAC;AACxD,CAAC;AA4DD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,CAAC;AAClD,CAAC;AAuCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,CAAC;AAClD,CAAC;AAsCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,YAAY,CAAC,CAAC;AAC9C,CAAC;AAoDD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,WAAW,CAAC,CAAC;AAC7C,CAAC;AAuCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,YAAY,CAAC,CAAC;AAC9C,CAAC;AAiDD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,iBAAiB,CAAC,CAAC;AACnD,CAAC;AA2CD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC"}
|
package/lib/llm.mjs
CHANGED
|
@@ -7,6 +7,7 @@ var llm_exports = /* @__PURE__ */ __exportAll({
|
|
|
7
7
|
controller: () => controller,
|
|
8
8
|
createCoerce: () => createCoerce,
|
|
9
9
|
createParse: () => createParse,
|
|
10
|
+
evaluation: () => evaluation,
|
|
10
11
|
parameters: () => parameters,
|
|
11
12
|
parse: () => parse,
|
|
12
13
|
schema: () => schema,
|
|
@@ -25,6 +26,10 @@ function structuredOutput() {
|
|
|
25
26
|
NoTransformConfigurationError("llm.structuredOutput");
|
|
26
27
|
}
|
|
27
28
|
/** @internal */
|
|
29
|
+
function evaluation() {
|
|
30
|
+
NoTransformConfigurationError("llm.evaluation");
|
|
31
|
+
}
|
|
32
|
+
/** @internal */
|
|
28
33
|
function parameters() {
|
|
29
34
|
NoTransformConfigurationError("llm.parameters");
|
|
30
35
|
}
|
|
@@ -49,6 +54,6 @@ function createCoerce() {
|
|
|
49
54
|
NoTransformConfigurationError("llm.createCoerce");
|
|
50
55
|
}
|
|
51
56
|
//#endregion
|
|
52
|
-
export { application, coerce, controller, createCoerce, createParse, llm_exports, parameters, parse, schema, structuredOutput };
|
|
57
|
+
export { application, coerce, controller, createCoerce, createParse, evaluation, llm_exports, parameters, parse, schema, structuredOutput };
|
|
53
58
|
|
|
54
59
|
//# sourceMappingURL=llm.mjs.map
|
package/lib/llm.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.mjs","names":[],"sources":["../src/llm.ts"],"sourcesContent":["import {\n IJsonParseResult,\n ILlmApplication,\n ILlmController,\n ILlmSchema,\n ILlmStructuredOutput,\n} from \"@typia/interface\";\n\nimport { NoTransformConfigurationError } from \"./transformers/NoTransformConfigurationError\";\n\n/* -----------------------------------------------------------\n FUNCTION CALLING\n----------------------------------------------------------- */\n/**\n * Creates LLM function calling controller.\n *\n * @danger You must configure the generic argument `Class`\n */\nexport function controller(\n name: string,\n execute: object,\n config?: Partial<Pick<ILlmApplication.IConfig<any>, \"validate\">>,\n): never;\n\n/**\n * Creates LLM function calling controller from class/interface.\n *\n * Generates {@link ILlmController} from a TypeScript class or interface,\n * containing both function calling schemas ({@link ILlmFunction}) and an\n * executor ({@link ILlmController.execute}).\n *\n * Each {@link ILlmFunction} includes a built-in {@link ILlmFunction.validate}\n * function that validates LLM-generated arguments before execution. When\n * validation fails, use `LlmJson.stringify()` from `@typia/utils` to format\n * errors for LLM feedback, enabling auto-correction.\n *\n * When passed to LLM providers (ChatGPT, Claude, Gemini, etc.), the LLM\n * automatically selects functions and fills arguments from conversation.\n * Execute the selected function via {@link ILlmController.execute}.\n *\n * Related functions:\n *\n * - {@link application} — Schemas only, without executor\n * - {@link parameters} — Single parameters schema for structured output\n * - {@link schema} — Single type schema\n *\n * @template Class Target class or interface type\n * @template Config LLM schema configuration\n * @param name Controller identifier name\n * @param execute Executor instance\n * @param config LLM application options\n * @returns LLM function calling controller\n */\nexport function controller<\n Class extends Record<string, any>,\n Config extends Partial<\n ILlmSchema.IConfig & {\n /**\n * Whether to disallow superfluous properties or not.\n *\n * If configure as `true`, {@link validateEquals} function would be used\n * for validation feedback, which is more strict than {@link validate}\n * function.\n *\n * @default false\n */\n equals: boolean;\n }\n > = {},\n>(\n name: string,\n execute: Class,\n config?: Partial<Pick<ILlmApplication.IConfig<Class>, \"validate\">>,\n): ILlmController<Class>;\n\n/** @internal */\nexport function controller(..._args: any[]): never {\n NoTransformConfigurationError(\"llm.controller\");\n}\n\n/**\n * Creates LLM function calling application.\n *\n * @danger You must configure the generic argument `Class`\n */\nexport function application(\n config?: Partial<Pick<ILlmApplication.IConfig<any>, \"validate\">>,\n): never;\n\n/**\n * Creates LLM function calling application from class/interface.\n *\n * Generates {@link ILlmApplication} from a TypeScript class or interface,\n * containing function calling schemas ({@link ILlmFunction}). Does not include\n * an executor—use {@link controller} if you need execution capability.\n *\n * Each {@link ILlmFunction} includes a built-in {@link ILlmFunction.validate}\n * function that validates LLM-generated arguments before execution. When\n * validation fails, use `LlmJson.stringify()` from `@typia/utils` to format\n * errors for LLM feedback, enabling auto-correction.\n *\n * When passed to LLM providers (ChatGPT, Claude, Gemini, etc.), the LLM\n * automatically selects functions and fills arguments from conversation. You\n * execute the function manually with the LLM-prepared arguments.\n *\n * Related functions:\n *\n * - {@link controller} — Includes executor alongside schemas\n * - {@link parameters} — Single parameters schema for structured output\n * - {@link schema} — Single type schema\n *\n * @template Class Target class or interface type\n * @template Config LLM schema configuration\n * @param config LLM application options\n * @returns LLM function calling application\n */\nexport function application<\n Class extends Record<string, any>,\n Config extends Partial<\n ILlmSchema.IConfig & {\n /**\n * Whether to disallow superfluous properties or not.\n *\n * If configure as `true`, {@link validateEquals} function would be used\n * for validation feedback, which is more strict than {@link validate}\n * function.\n *\n * @default false\n */\n equals: boolean;\n }\n > = {},\n>(\n config?: Partial<Pick<ILlmApplication.IConfig<Class>, \"validate\">>,\n): ILlmApplication<Class>;\n\n/** @internal */\nexport function application(): never {\n NoTransformConfigurationError(\"llm.application\");\n}\n\n/**\n * Creates LLM structured output interface.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function structuredOutput(): never;\n\n/**\n * Creates LLM structured output interface from TypeScript object type.\n *\n * Generates {@link ILlmStructuredOutput} containing everything needed for\n * handling LLM structured outputs: the JSON schema for prompting, and functions\n * for parsing, coercing, and validating responses.\n *\n * Structured outputs allow LLMs to generate data conforming to a predefined\n * schema instead of free-form text. This is useful for:\n *\n * - Extracting structured data from conversations\n * - Generating typed responses for downstream processing\n * - Ensuring consistent output formats across LLM calls\n *\n * Workflow:\n *\n * 1. Pass {@link ILlmStructuredOutput.parameters} schema to LLM provider\n * 2. Receive LLM response (JSON string or pre-parsed object)\n * 3. Use {@link ILlmStructuredOutput.parse} for raw strings or\n * {@link ILlmStructuredOutput.coerce} for pre-parsed objects\n * 4. Use {@link ILlmStructuredOutput.validate} to check the result\n *\n * Related functions:\n *\n * - {@link parameters} — Schema only, without parse/coerce/validate\n * - {@link application} — Multiple function schemas from class/interface\n * - {@link controller} — Application with executor\n *\n * @template T Target output type (object with static properties)\n * @template Config LLM schema configuration\n * @returns LLM structured output interface\n */\nexport function structuredOutput<\n T extends Record<string, any>,\n Config extends Partial<\n ILlmSchema.IConfig & {\n /**\n * Whether to disallow superfluous properties or not.\n *\n * If configure as `true`, {@link validateEquals} function would be used\n * for validation feedback, which is more strict than {@link validate}\n * function.\n *\n * @default false\n */\n equals: boolean;\n }\n > = {},\n>(): ILlmStructuredOutput<T>;\n\n/** @internal */\nexport function structuredOutput(): never {\n NoTransformConfigurationError(\"llm.structuredOutput\");\n}\n\n/* -----------------------------------------------------------\n RAW SCHEMAS\n----------------------------------------------------------- */\n/**\n * Creates LLM parameters schema.\n *\n * @danger You must configure the generic argument `Parameters`\n */\nexport function parameters(): never;\n\n/**\n * Creates LLM parameters schema from TypeScript object type.\n *\n * Generates {@link ILlmSchema.IParameters} for LLM function calling or\n * structured outputs. LLMs use keyworded arguments only, so the type must be an\n * object with static properties (no dynamic properties allowed).\n *\n * Use cases:\n *\n * - Function calling: LLM fills parameters from conversation\n * - Structured outputs: LLM generates structured data, not plain text\n *\n * Related functions:\n *\n * - {@link application} — Multiple function schemas from class/interface\n * - {@link controller} — Application with executor\n * - {@link schema} — Single type schema (not parameters-specific)\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @returns LLM parameters schema\n */\nexport function parameters<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(): ILlmSchema.IParameters;\n\n/** @internal */\nexport function parameters(): never {\n NoTransformConfigurationError(\"llm.parameters\");\n}\n\n/**\n * Creates LLM type schema.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function schema(): never;\n\n/**\n * Creates LLM type schema from TypeScript type.\n *\n * Generates {@link ILlmSchema} for use in LLM function calling. For actual\n * function calling with TypeScript functions, use {@link application}. For\n * structured output generation, use {@link parameters}.\n *\n * LLM function calling flow:\n *\n * 1. LLM selects function and fills arguments from conversation\n * 2. You execute the function with LLM-prepared arguments\n * 3. Return value is passed back to LLM via system prompt\n * 4. LLM continues conversation based on return value\n *\n * Related functions:\n *\n * - {@link application} — Multiple function schemas from class/interface\n * - {@link controller} — Application with executor\n * - {@link parameters} — Parameters schema for structured output\n *\n * @template T Target type\n * @template Config LLM schema configuration\n * @param $defs Shared schema definitions for `$ref` referencing\n * @returns LLM type schema\n */\nexport function schema<T, Config = {}>(\n $defs: Record<string, ILlmSchema>,\n): ILlmSchema;\n\n/** @internal */\nexport function schema(): never {\n NoTransformConfigurationError(\"llm.schema\");\n}\n\n/* -----------------------------------------------------------\n UTILITY FUNCTIONS\n----------------------------------------------------------- */\n/**\n * Parse LLM response JSON with type coercion.\n *\n * @danger You must configure the generic argument `Parameters`\n */\nexport function parse(input: string): never;\n\n/**\n * Parse lenient JSON with schema-based type coercion.\n *\n * Handles incomplete or malformed JSON commonly produced by LLMs:\n *\n * - Unclosed brackets, strings, trailing commas\n * - JavaScript-style comments (`//` and multi-line)\n * - Unquoted object keys, incomplete keywords (`tru`, `fal`, `nul`)\n * - Markdown code block extraction, junk prefix skipping\n *\n * Also coerces double-stringified values based on the `Parameters` schema:\n *\n * - `\"42\"` → `42` (when schema expects number)\n * - `\"true\"` → `true` (when schema expects boolean)\n * - `\"null\"` → `null` (when schema expects null)\n * - `\"{...}\"` → `{...}` (when schema expects object)\n * - `\"[...]\"` → `[...]` (when schema expects array)\n *\n * Type validation is NOT performed—use {@link ILlmFunction.validate} or\n * `typia.validate()` for that.\n *\n * For repeated parsing, use {@link createParse} to avoid regenerating the schema\n * each time.\n *\n * Related functions:\n *\n * - {@link createParse} — Create reusable parser function\n * - {@link coerce} — Type coercion for already-parsed objects\n * - {@link parameters} — Generate parameters schema from type\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @param input Raw JSON string (potentially incomplete or malformed)\n * @returns Parse result with typed data on success, or partial data with errors\n */\nexport function parse<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(input: string): IJsonParseResult<Parameters>;\n\n/** @internal */\nexport function parse(): never {\n NoTransformConfigurationError(\"llm.parse\");\n}\n\n/**\n * Coerce LLM arguments to match expected schema types.\n *\n * LLMs often return values with incorrect types (e.g., numbers as strings).\n * This function recursively coerces values based on the `Parameters` schema:\n *\n * - `\"42\"` → `42` (when schema expects number)\n * - `\"true\"` → `true` (when schema expects boolean)\n * - `\"null\"` → `null` (when schema expects null)\n * - `\"{...}\"` → `{...}` (when schema expects object)\n * - `\"[...]\"` → `[...]` (when schema expects array)\n *\n * Use this when your SDK provides already-parsed objects but values may have\n * wrong types. For raw JSON strings, use {@link parse} instead.\n *\n * For repeated coercion, use {@link createCoerce} to avoid regenerating the\n * schema each time.\n *\n * Type validation is NOT performed—use {@link ILlmFunction.validate} or\n * `typia.validate()` for that.\n *\n * Related functions:\n *\n * - {@link createCoerce} — Create reusable coercer function\n * - {@link parse} — Parse and coerce raw JSON strings\n * - {@link parameters} — Generate parameters schema from type\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @param input Parsed arguments object from LLM (with potentially wrong types)\n * @returns Coerced arguments with corrected types\n */\nexport function coerce<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(input: Parameters): Parameters;\n\n/** @internal */\nexport function coerce(): never {\n NoTransformConfigurationError(\"llm.coerce\");\n}\n\n/**\n * Create reusable LLM JSON parser with type coercion.\n *\n * @danger You must configure the generic argument `Parameters`\n */\nexport function createParse(): never;\n\n/**\n * Create reusable lenient JSON parser with schema-based type coercion.\n *\n * Returns a parser function that handles incomplete or malformed JSON commonly\n * produced by LLMs:\n *\n * - Unclosed brackets, strings, trailing commas\n * - JavaScript-style comments (`//` and multi-line)\n * - Unquoted object keys, incomplete keywords (`tru`, `fal`, `nul`)\n * - Markdown code block extraction, junk prefix skipping\n *\n * Also coerces double-stringified values based on the `Parameters` schema:\n *\n * - `\"42\"` → `42` (when schema expects number)\n * - `\"true\"` → `true` (when schema expects boolean)\n * - `\"null\"` → `null` (when schema expects null)\n * - `\"{...}\"` → `{...}` (when schema expects object)\n * - `\"[...]\"` → `[...]` (when schema expects array)\n *\n * Use this instead of {@link parse} when parsing multiple inputs to avoid\n * regenerating the schema each time.\n *\n * Type validation is NOT performed—use {@link ILlmFunction.validate} or\n * `typia.validate()` for that.\n *\n * Related functions:\n *\n * - {@link parse} — One-shot parsing (regenerates schema each call)\n * - {@link createCoerce} — Create reusable coercer function\n * - {@link parameters} — Generate parameters schema from type\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @returns Reusable parser function\n */\nexport function createParse<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(): (input: string) => IJsonParseResult<Parameters>;\n\n/** @internal */\nexport function createParse(): never {\n NoTransformConfigurationError(\"llm.createParse\");\n}\n\n/**\n * Create reusable LLM arguments coercer.\n *\n * @danger You must configure the generic argument `Parameters`\n */\nexport function createCoerce(): never;\n\n/**\n * Create reusable coercer for LLM arguments.\n *\n * Returns a coercer function that fixes incorrect types commonly returned by\n * LLMs (e.g., numbers as strings). Coerces values based on the `Parameters`\n * schema:\n *\n * - `\"42\"` → `42` (when schema expects number)\n * - `\"true\"` → `true` (when schema expects boolean)\n * - `\"null\"` → `null` (when schema expects null)\n * - `\"{...}\"` → `{...}` (when schema expects object)\n * - `\"[...]\"` → `[...]` (when schema expects array)\n *\n * Use this instead of {@link coerce} when coercing multiple inputs to avoid\n * regenerating the schema each time.\n *\n * Type validation is NOT performed—use {@link ILlmFunction.validate} or\n * `typia.validate()` for that.\n *\n * Related functions:\n *\n * - {@link coerce} — One-shot coercion (regenerates schema each call)\n * - {@link createParse} — Create reusable parser function\n * - {@link parameters} — Generate parameters schema from type\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @returns Reusable coercer function\n */\nexport function createCoerce<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(): (input: Parameters) => Parameters;\n\n/** @internal */\nexport function createCoerce(): never {\n NoTransformConfigurationError(\"llm.createCoerce\");\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4EA,SAAgB,WAAW,GAAG,OAAqB;CACjD,8BAA8B,gBAAgB;AAChD;;AA2DA,SAAgB,cAAqB;CACnC,8BAA8B,iBAAiB;AACjD;;AA4DA,SAAgB,mBAA0B;CACxC,8BAA8B,sBAAsB;AACtD;;AAwCA,SAAgB,aAAoB;CAClC,8BAA8B,gBAAgB;AAChD;;AAuCA,SAAgB,SAAgB;CAC9B,8BAA8B,YAAY;AAC5C;;AAqDA,SAAgB,QAAe;CAC7B,8BAA8B,WAAW;AAC3C;;AAwCA,SAAgB,SAAgB;CAC9B,8BAA8B,YAAY;AAC5C;;AAkDA,SAAgB,cAAqB;CACnC,8BAA8B,iBAAiB;AACjD;;AA4CA,SAAgB,eAAsB;CACpC,8BAA8B,kBAAkB;AAClD"}
|
|
1
|
+
{"version":3,"file":"llm.mjs","names":[],"sources":["../src/llm.ts"],"sourcesContent":["import {\n IJsonParseResult,\n ILlmApplication,\n ILlmController,\n ILlmEvaluation,\n ILlmSchema,\n ILlmStructuredOutput,\n} from \"@typia/interface\";\n\nimport { NoTransformConfigurationError } from \"./transformers/NoTransformConfigurationError\";\n\n/* -----------------------------------------------------------\n FUNCTION CALLING\n----------------------------------------------------------- */\n/**\n * Creates LLM function calling controller.\n *\n * @danger You must configure the generic argument `Class`\n */\nexport function controller(\n name: string,\n execute: object,\n config?: Partial<Pick<ILlmApplication.IConfig<any>, \"validate\">>,\n): never;\n\n/**\n * Creates LLM function calling controller from class/interface.\n *\n * Generates {@link ILlmController} from a TypeScript class or interface,\n * containing both function calling schemas ({@link ILlmFunction}) and an\n * executor ({@link ILlmController.execute}).\n *\n * Each {@link ILlmFunction} includes a built-in {@link ILlmFunction.validate}\n * function that validates LLM-generated arguments before execution. When\n * validation fails, use `LlmJson.stringify()` from `@typia/utils` to format\n * errors for LLM feedback, enabling auto-correction.\n *\n * When passed to LLM providers (ChatGPT, Claude, Gemini, etc.), the LLM\n * automatically selects functions and fills arguments from conversation.\n * Execute the selected function via {@link ILlmController.execute}.\n *\n * Related functions:\n *\n * - {@link application} — Schemas only, without executor\n * - {@link parameters} — Single parameters schema for structured output\n * - {@link schema} — Single type schema\n *\n * @template Class Target class or interface type\n * @template Config LLM schema configuration\n * @param name Controller identifier name\n * @param execute Executor instance\n * @param config LLM application options\n * @returns LLM function calling controller\n */\nexport function controller<\n Class extends Record<string, any>,\n Config extends Partial<\n ILlmSchema.IConfig & {\n /**\n * Whether to disallow superfluous properties or not.\n *\n * If configure as `true`, {@link validateEquals} function would be used\n * for validation feedback, which is more strict than {@link validate}\n * function.\n *\n * @default false\n */\n equals: boolean;\n }\n > = {},\n>(\n name: string,\n execute: Class,\n config?: Partial<Pick<ILlmApplication.IConfig<Class>, \"validate\">>,\n): ILlmController<Class>;\n\n/** @internal */\nexport function controller(..._args: any[]): never {\n NoTransformConfigurationError(\"llm.controller\");\n}\n\n/**\n * Creates LLM function calling application.\n *\n * @danger You must configure the generic argument `Class`\n */\nexport function application(\n config?: Partial<Pick<ILlmApplication.IConfig<any>, \"validate\">>,\n): never;\n\n/**\n * Creates LLM function calling application from class/interface.\n *\n * Generates {@link ILlmApplication} from a TypeScript class or interface,\n * containing function calling schemas ({@link ILlmFunction}). Does not include\n * an executor—use {@link controller} if you need execution capability.\n *\n * Each {@link ILlmFunction} includes a built-in {@link ILlmFunction.validate}\n * function that validates LLM-generated arguments before execution. When\n * validation fails, use `LlmJson.stringify()` from `@typia/utils` to format\n * errors for LLM feedback, enabling auto-correction.\n *\n * When passed to LLM providers (ChatGPT, Claude, Gemini, etc.), the LLM\n * automatically selects functions and fills arguments from conversation. You\n * execute the function manually with the LLM-prepared arguments.\n *\n * Related functions:\n *\n * - {@link controller} — Includes executor alongside schemas\n * - {@link parameters} — Single parameters schema for structured output\n * - {@link schema} — Single type schema\n *\n * @template Class Target class or interface type\n * @template Config LLM schema configuration\n * @param config LLM application options\n * @returns LLM function calling application\n */\nexport function application<\n Class extends Record<string, any>,\n Config extends Partial<\n ILlmSchema.IConfig & {\n /**\n * Whether to disallow superfluous properties or not.\n *\n * If configure as `true`, {@link validateEquals} function would be used\n * for validation feedback, which is more strict than {@link validate}\n * function.\n *\n * @default false\n */\n equals: boolean;\n }\n > = {},\n>(\n config?: Partial<Pick<ILlmApplication.IConfig<Class>, \"validate\">>,\n): ILlmApplication<Class>;\n\n/** @internal */\nexport function application(): never {\n NoTransformConfigurationError(\"llm.application\");\n}\n\n/**\n * Creates LLM structured output interface.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function structuredOutput(): never;\n\n/**\n * Creates LLM structured output interface from TypeScript object type.\n *\n * Generates {@link ILlmStructuredOutput} containing everything needed for\n * handling LLM structured outputs: the JSON schema for prompting, and functions\n * for parsing, coercing, and validating responses.\n *\n * Structured outputs allow LLMs to generate data conforming to a predefined\n * schema instead of free-form text. This is useful for:\n *\n * - Extracting structured data from conversations\n * - Generating typed responses for downstream processing\n * - Ensuring consistent output formats across LLM calls\n *\n * Workflow:\n *\n * 1. Pass {@link ILlmStructuredOutput.parameters} schema to LLM provider\n * 2. Receive LLM response (JSON string or pre-parsed object)\n * 3. Use {@link ILlmStructuredOutput.parse} for raw strings or\n * {@link ILlmStructuredOutput.coerce} for pre-parsed objects\n * 4. Use {@link ILlmStructuredOutput.validate} to check the result\n *\n * Related functions:\n *\n * - {@link parameters} — Schema only, without parse/coerce/validate\n * - {@link application} — Multiple function schemas from class/interface\n * - {@link controller} — Application with executor\n *\n * @template T Target output type (object with static properties)\n * @template Config LLM schema configuration\n * @returns LLM structured output interface\n */\nexport function structuredOutput<\n T extends Record<string, any>,\n Config extends Partial<\n ILlmSchema.IConfig & {\n /**\n * Whether to disallow superfluous properties or not.\n *\n * If configure as `true`, {@link validateEquals} function would be used\n * for validation feedback, which is more strict than {@link validate}\n * function.\n *\n * @default false\n */\n equals: boolean;\n }\n > = {},\n>(): ILlmStructuredOutput<T>;\n\n/** @internal */\nexport function structuredOutput(): never {\n NoTransformConfigurationError(\"llm.structuredOutput\");\n}\n\n/* -----------------------------------------------------------\n EVALUATION\n----------------------------------------------------------- */\n/**\n * Creates LLM evaluation questions.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function evaluation(): never;\n\n/**\n * Creates LLM evaluation questions from TypeScript object type.\n *\n * Generates {@link ILlmEvaluation} for evaluation models, which answer typed\n * questions about a shared state with probabilities instead of generating text:\n * TypeSafe's Jev natively, and OpenAI, Anthropic, and Google through Vercel AI\n * SDK's `experimental_evaluate()`.\n *\n * Every leaf property of `T` becomes one question, and its JSDoc description\n * becomes the question text:\n *\n * - `boolean` → boolean question\n * - String enum or string literal union → choice question\n * - Numeric enum or numeric literal union → score question\n * - Array of a string literal union or string enum → one boolean question per\n * member\n * - Nested object → flattened, one question per leaf\n *\n * Types an evaluation model cannot answer, such as `string`, `number`, optional\n * properties, or a leaf without a JSDoc description, are compile errors. Use\n * `tags.Probability<N>` or `@probability N` to set decision thresholds and\n * acceptance minimums. Once one choice, score, or set member declares a\n * requirement, every member must declare one or inherit the property's\n * `@probability` default. A nested object's own JSDoc description is not sent\n * to the model; only the leaves' descriptions become question text. Other\n * validation refinements that the answer decoder cannot enforce are compile\n * errors.\n *\n * This feature is experimental. It follows Vercel AI SDK's evaluation model\n * specification, which is itself experimental and may change in patch\n * releases.\n *\n * Workflow:\n *\n * 1. Pass {@link ILlmEvaluation.questions} to the evaluation model\n * 2. Receive the answer map keyed by the same question IDs\n * 3. Use {@link ILlmEvaluation.decode} to fold the answers back into `T`; pass the\n * model's declared rounding precision when available\n *\n * Related functions:\n *\n * - {@link structuredOutput} — Structured output generated as text by an LLM\n *\n * @template T Target decision type (object with static properties)\n * @returns LLM evaluation questions with a checked answer decoder\n */\nexport function evaluation<T extends Record<string, any>>(): ILlmEvaluation<T>;\n\n/** @internal */\nexport function evaluation(): never {\n NoTransformConfigurationError(\"llm.evaluation\");\n}\n\n/* -----------------------------------------------------------\n RAW SCHEMAS\n----------------------------------------------------------- */\n/**\n * Creates LLM parameters schema.\n *\n * @danger You must configure the generic argument `Parameters`\n */\nexport function parameters(): never;\n\n/**\n * Creates LLM parameters schema from TypeScript object type.\n *\n * Generates {@link ILlmSchema.IParameters} for LLM function calling or\n * structured outputs. LLMs use keyworded arguments only, so the type must be an\n * object with static properties (no dynamic properties allowed).\n *\n * Use cases:\n *\n * - Function calling: LLM fills parameters from conversation\n * - Structured outputs: LLM generates structured data, not plain text\n *\n * Related functions:\n *\n * - {@link application} — Multiple function schemas from class/interface\n * - {@link controller} — Application with executor\n * - {@link schema} — Single type schema (not parameters-specific)\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @returns LLM parameters schema\n */\nexport function parameters<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(): ILlmSchema.IParameters;\n\n/** @internal */\nexport function parameters(): never {\n NoTransformConfigurationError(\"llm.parameters\");\n}\n\n/**\n * Creates LLM type schema.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function schema(): never;\n\n/**\n * Creates LLM type schema from TypeScript type.\n *\n * Generates {@link ILlmSchema} for use in LLM function calling. For actual\n * function calling with TypeScript functions, use {@link application}. For\n * structured output generation, use {@link parameters}.\n *\n * LLM function calling flow:\n *\n * 1. LLM selects function and fills arguments from conversation\n * 2. You execute the function with LLM-prepared arguments\n * 3. Return value is passed back to LLM via system prompt\n * 4. LLM continues conversation based on return value\n *\n * Related functions:\n *\n * - {@link application} — Multiple function schemas from class/interface\n * - {@link controller} — Application with executor\n * - {@link parameters} — Parameters schema for structured output\n *\n * @template T Target type\n * @template Config LLM schema configuration\n * @param $defs Shared schema definitions for `$ref` referencing\n * @returns LLM type schema\n */\nexport function schema<T, Config = {}>(\n $defs: Record<string, ILlmSchema>,\n): ILlmSchema;\n\n/** @internal */\nexport function schema(): never {\n NoTransformConfigurationError(\"llm.schema\");\n}\n\n/* -----------------------------------------------------------\n UTILITY FUNCTIONS\n----------------------------------------------------------- */\n/**\n * Parse LLM response JSON with type coercion.\n *\n * @danger You must configure the generic argument `Parameters`\n */\nexport function parse(input: string): never;\n\n/**\n * Parse lenient JSON with schema-based type coercion.\n *\n * Handles incomplete or malformed JSON commonly produced by LLMs:\n *\n * - Unclosed brackets, strings, trailing commas\n * - JavaScript-style comments (`//` and multi-line)\n * - Unquoted object keys, incomplete keywords (`tru`, `fal`, `nul`)\n * - Markdown code block extraction, junk prefix skipping\n *\n * Also coerces double-stringified values based on the `Parameters` schema:\n *\n * - `\"42\"` → `42` (when schema expects number)\n * - `\"true\"` → `true` (when schema expects boolean)\n * - `\"null\"` → `null` (when schema expects null)\n * - `\"{...}\"` → `{...}` (when schema expects object)\n * - `\"[...]\"` → `[...]` (when schema expects array)\n *\n * Type validation is NOT performed—use {@link ILlmFunction.validate} or\n * `typia.validate()` for that.\n *\n * For repeated parsing, use {@link createParse} to avoid regenerating the schema\n * each time.\n *\n * Related functions:\n *\n * - {@link createParse} — Create reusable parser function\n * - {@link coerce} — Type coercion for already-parsed objects\n * - {@link parameters} — Generate parameters schema from type\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @param input Raw JSON string (potentially incomplete or malformed)\n * @returns Parse result with typed data on success, or partial data with errors\n */\nexport function parse<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(input: string): IJsonParseResult<Parameters>;\n\n/** @internal */\nexport function parse(): never {\n NoTransformConfigurationError(\"llm.parse\");\n}\n\n/**\n * Coerce LLM arguments to match expected schema types.\n *\n * LLMs often return values with incorrect types (e.g., numbers as strings).\n * This function recursively coerces values based on the `Parameters` schema:\n *\n * - `\"42\"` → `42` (when schema expects number)\n * - `\"true\"` → `true` (when schema expects boolean)\n * - `\"null\"` → `null` (when schema expects null)\n * - `\"{...}\"` → `{...}` (when schema expects object)\n * - `\"[...]\"` → `[...]` (when schema expects array)\n *\n * Use this when your SDK provides already-parsed objects but values may have\n * wrong types. For raw JSON strings, use {@link parse} instead.\n *\n * For repeated coercion, use {@link createCoerce} to avoid regenerating the\n * schema each time.\n *\n * Type validation is NOT performed—use {@link ILlmFunction.validate} or\n * `typia.validate()` for that.\n *\n * Related functions:\n *\n * - {@link createCoerce} — Create reusable coercer function\n * - {@link parse} — Parse and coerce raw JSON strings\n * - {@link parameters} — Generate parameters schema from type\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @param input Parsed arguments object from LLM (with potentially wrong types)\n * @returns Coerced arguments with corrected types\n */\nexport function coerce<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(input: Parameters): Parameters;\n\n/** @internal */\nexport function coerce(): never {\n NoTransformConfigurationError(\"llm.coerce\");\n}\n\n/**\n * Create reusable LLM JSON parser with type coercion.\n *\n * @danger You must configure the generic argument `Parameters`\n */\nexport function createParse(): never;\n\n/**\n * Create reusable lenient JSON parser with schema-based type coercion.\n *\n * Returns a parser function that handles incomplete or malformed JSON commonly\n * produced by LLMs:\n *\n * - Unclosed brackets, strings, trailing commas\n * - JavaScript-style comments (`//` and multi-line)\n * - Unquoted object keys, incomplete keywords (`tru`, `fal`, `nul`)\n * - Markdown code block extraction, junk prefix skipping\n *\n * Also coerces double-stringified values based on the `Parameters` schema:\n *\n * - `\"42\"` → `42` (when schema expects number)\n * - `\"true\"` → `true` (when schema expects boolean)\n * - `\"null\"` → `null` (when schema expects null)\n * - `\"{...}\"` → `{...}` (when schema expects object)\n * - `\"[...]\"` → `[...]` (when schema expects array)\n *\n * Use this instead of {@link parse} when parsing multiple inputs to avoid\n * regenerating the schema each time.\n *\n * Type validation is NOT performed—use {@link ILlmFunction.validate} or\n * `typia.validate()` for that.\n *\n * Related functions:\n *\n * - {@link parse} — One-shot parsing (regenerates schema each call)\n * - {@link createCoerce} — Create reusable coercer function\n * - {@link parameters} — Generate parameters schema from type\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @returns Reusable parser function\n */\nexport function createParse<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(): (input: string) => IJsonParseResult<Parameters>;\n\n/** @internal */\nexport function createParse(): never {\n NoTransformConfigurationError(\"llm.createParse\");\n}\n\n/**\n * Create reusable LLM arguments coercer.\n *\n * @danger You must configure the generic argument `Parameters`\n */\nexport function createCoerce(): never;\n\n/**\n * Create reusable coercer for LLM arguments.\n *\n * Returns a coercer function that fixes incorrect types commonly returned by\n * LLMs (e.g., numbers as strings). Coerces values based on the `Parameters`\n * schema:\n *\n * - `\"42\"` → `42` (when schema expects number)\n * - `\"true\"` → `true` (when schema expects boolean)\n * - `\"null\"` → `null` (when schema expects null)\n * - `\"{...}\"` → `{...}` (when schema expects object)\n * - `\"[...]\"` → `[...]` (when schema expects array)\n *\n * Use this instead of {@link coerce} when coercing multiple inputs to avoid\n * regenerating the schema each time.\n *\n * Type validation is NOT performed—use {@link ILlmFunction.validate} or\n * `typia.validate()` for that.\n *\n * Related functions:\n *\n * - {@link coerce} — One-shot coercion (regenerates schema each call)\n * - {@link createParse} — Create reusable parser function\n * - {@link parameters} — Generate parameters schema from type\n *\n * @template Parameters Target parameters type (object with static properties)\n * @template Config LLM schema configuration\n * @returns Reusable coercer function\n */\nexport function createCoerce<\n Parameters extends Record<string, any>,\n Config extends Partial<ILlmSchema.IConfig> = {},\n>(): (input: Parameters) => Parameters;\n\n/** @internal */\nexport function createCoerce(): never {\n NoTransformConfigurationError(\"llm.createCoerce\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6EA,SAAgB,WAAW,GAAG,OAAqB;CACjD,8BAA8B,gBAAgB;AAChD;;AA2DA,SAAgB,cAAqB;CACnC,8BAA8B,iBAAiB;AACjD;;AA4DA,SAAgB,mBAA0B;CACxC,8BAA8B,sBAAsB;AACtD;;AA6DA,SAAgB,aAAoB;CAClC,8BAA8B,gBAAgB;AAChD;;AAwCA,SAAgB,aAAoB;CAClC,8BAA8B,gBAAgB;AAChD;;AAuCA,SAAgB,SAAgB;CAC9B,8BAA8B,YAAY;AAC5C;;AAqDA,SAAgB,QAAe;CAC7B,8BAA8B,WAAW;AAC3C;;AAwCA,SAAgB,SAAgB;CAC9B,8BAA8B,YAAY;AAC5C;;AAkDA,SAAgB,cAAqB;CACnC,8BAA8B,iBAAiB;AACjD;;AA4CA,SAAgB,eAAsB;CACpC,8BAA8B,kBAAkB;AAClD"}
|
package/lib/re-exports.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { AssertionGuard, IJsonParseResult, IValidation, IRandomGenerator, StandardSchemaV1, OpenApi, IJsonSchemaApplication, IJsonSchemaCollection, IJsonSchemaUnit, ILlmController, ILlmApplication, ILlmFunction, ILlmStructuredOutput, ILlmSchema, IMetadataSchema, IMetadataSchemaCollection, IMetadataSchemaUnit, IMetadataComponents, IMetadataTypeTag, IJsDocTagInfo, Atomic, Classifiable, ClassifyResult, Primitive, Resolved, CamelCase, KebabCase, PascalCase, SnakeCase, IReadableURLSearchParams, } from "@typia/interface";
|
|
1
|
+
export type { AssertionGuard, IJsonParseResult, IValidation, IRandomGenerator, StandardSchemaV1, OpenApi, IJsonSchemaApplication, IJsonSchemaCollection, IJsonSchemaUnit, ILlmController, ILlmApplication, ILlmFunction, ILlmStructuredOutput, ILlmEvaluation, ILlmSchema, IMetadataSchema, IMetadataSchemaCollection, IMetadataSchemaUnit, IMetadataComponents, IMetadataTypeTag, IJsDocTagInfo, Atomic, Classifiable, ClassifyResult, Primitive, Resolved, CamelCase, KebabCase, PascalCase, SnakeCase, IReadableURLSearchParams, } from "@typia/interface";
|
|
2
2
|
export { tags } from "@typia/interface";
|
package/lib/re-exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"re-exports.js","sourceRoot":"","sources":["../src/re-exports.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"re-exports.js","sourceRoot":"","sources":["../src/re-exports.ts"],"names":[],"mappings":";;;AAkDA,0EAA0E;AAC1E,sEAAsE;AACtE,0EAA0E;AAC1E,mEAAmE;AACnE,sBAAsB;AACtB,8CAAwC;AAA/B,iGAAA,IAAI,OAAA"}
|