Skip to content

fix(typia): do not import @typia/utils from transformer.#1830

Merged
samchon merged 3 commits into
nextfrom
fix/import
May 1, 2026
Merged

fix(typia): do not import @typia/utils from transformer.#1830
samchon merged 3 commits into
nextfrom
fix/import

Conversation

@samchon
Copy link
Copy Markdown
Owner

@samchon samchon commented May 1, 2026

This pull request introduces significant improvements and refactoring to the LLM parameters and application schema conversion logic in the Typia codebase. The changes primarily focus on unifying and simplifying how parameters and schemas are converted, ensuring stricter and more consistent schema outputs, and removing special-case handling for runtime imports. Additionally, comprehensive new test suites have been added to validate the correctness of the schema conversion logic for both parameters and application-level schemas.

Core logic improvements and refactoring:

  • Refactored LLM parameter and application schema conversion to use a unified conversion function (llmApplicationProgrammer_convertParameters), ensuring consistent handling of config and schema details, and removed redundant or legacy functions. [1] [2] [3] [4] [5] [6]

Runtime import and alias handling cleanup:

  • Removed special-case handling for the __typia_utils alias in runtime import generation, alias collection, ranking, and module resolution, streamlining the logic for all runtime aliases. [1] [2] [3] [4]

Test coverage enhancements:

  • Added new comprehensive test suites for LLM parameter conversion (test_llm_parameters_converter_matrix.ts), parameter property specifications (test_llm_parameters_spec_properties.ts), and application schema conversion (test_llm_application_schema_converter_matrix.ts), covering edge cases and ensuring strictness and correctness of the generated schemas. [1] [2] [3]

These changes collectively improve the maintainability, correctness, and test coverage of the schema conversion logic in Typia, while removing unnecessary complexity and legacy code paths.

@samchon samchon self-assigned this May 1, 2026
@samchon samchon added the bug Something isn't working label May 1, 2026
@samchon samchon marked this pull request as ready for review May 1, 2026 10:55
Copilot AI review requested due to automatic review settings May 1, 2026 10:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the transformer/runtime dependency on @typia/utils for LLM schema generation by moving JSON-schema→LLM-schema conversion fully into the native (Go) compiler pipeline, while also adding/refining strict conversion behavior and expanding test coverage to validate the new outputs.

Changes:

  • Refactors LLM schema/parameters generation to emit literal schemas (no runtime @typia/utils converter / __typia_utils alias).
  • Adds “strict” conversion behavior (shifting certain constraints into description, cascading ref property docs to owner, etc.).
  • Adds new fixture + test suites to validate parameter/application/schema conversion and ensure no @typia/utils import appears in emitted output.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/typia/native/core/programmers/llm/LlmSchemaProgrammer.go Replaces runtime converter usage with compile-time conversion + strict-mode shaping and $defs population.
packages/typia/native/core/programmers/llm/LlmParametersProgrammer.go Emits parameters schema as a literal converted value (no runtime conversion/import).
packages/typia/native/core/programmers/llm/LlmApplicationProgrammer.go Unifies application parameter/output conversion via shared conversion helper.
packages/typia/native/adapter/cleanup.go Removes special casing for __typia_utils runtime alias/import injection.
tests/test-typia-ttsc/src/features/test_emit_llm_schema_no_utils_import.ts Ensures emitted JS has no @typia/utils, __typia_utils, or converter symbol references.
tests/test-typia-ttsc/fixtures/llm-schema/tsconfig.json Adds a dedicated fixture tsconfig for the new emit test.
tests/test-typia-ttsc/fixtures/llm-schema/src/main.ts Fixture source that emits typia.llm.schema + typia.llm.parameters.
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_converter_matrix.ts Adds matrix coverage for non-strict schema conversion.
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_strict_converter_matrix.ts Adds matrix coverage for strict-mode shifting/cascading behavior.
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_spec_atomic.ts Adds atomic-type schema spec tests.
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_spec_composite.ts Adds composite-type schema spec tests (object/record/ref/union/arrays).
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_spec_strict.ts Adds strict-mode spec tests for string/number/array/object shifting/cascading.
tests/test-typia-schema/src/features/llm.parameters/test_llm_parameters_converter_matrix.ts Adds matrix coverage for parameters conversion behavior.
tests/test-typia-schema/src/features/llm.parameters/test_llm_parameters_spec_properties.ts Adds spec coverage for parameters property conversion and $defs behavior.
tests/test-typia-schema/src/features/llm.application/test_llm_application_schema_converter_matrix.ts Adds matrix coverage for application schema generation (function description, params/output).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +50 to +51
false,
params.additionalProperties,
Comment on lines +87 to +88
false,
func.output.additionalProperties,
Comment on lines +441 to +449
func llmSchemaProgrammer_clone(input map[string]any) map[string]any {
output := map[string]any{}
for key, value := range input {
if llmSchemaProgrammer_is_nil_like(value) {
continue
}
output[key] = value
}
return output
Comment on lines +581 to +586
func llmSchemaProgrammer_is_reference(schema map[string]any) bool {
_, ok := schema["$ref"].(string)
return ok
}

func llmSchemaProgrammer_is_null(schema map[string]any) bool {
Comment on lines +24 to +25
false,
params.additionalProperties,
@samchon samchon merged commit 4bffb64 into next May 1, 2026
7 checks passed
@samchon samchon deleted the fix/import branch May 1, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants