Skip to content

[WIP] Add JSON Structure to TypeScript conversion implementation - #74

Closed
clemensv with Copilot wants to merge 2 commits into
masterfrom
copilot/convert-json-structure-to-typescript
Closed

[WIP] Add JSON Structure to TypeScript conversion implementation#74
clemensv with Copilot wants to merge 2 commits into
masterfrom
copilot/convert-json-structure-to-typescript

Conversation

Copilot AI commented Nov 20, 2025

Copy link
Copy Markdown
Contributor

Plan for implementing structuretots: JSON Structure to TypeScript conversion

  • Explore and understand the codebase structure
    • Review avrotots.py for TypeScript output patterns and template usage
    • Review structuretocsharp.py for JSON Structure handling patterns
    • Review structuretopython.py for JSON Structure handling patterns
    • Examine template directories and test patterns
    • Check commands.json format for CLI integration
  • Create structuretots.py module
    • Implement StructureToTypeScript class with all JSON Structure type mappings
    • Support all JSON Structure Core types (primitives, extended types, compound types)
    • Handle namespaces, definitions, and type references
    • Support $extends and $offers/$uses (add-ins) - basic implementation
    • Support abstract types - basic implementation
    • Support required/optional properties
    • Support type annotations (maxLength, precision, scale, etc.) - delegated to TypeScript
  • Create Jinja templates for TypeScript generation
    • class_core.ts.jinja for object types
    • enum_core.ts.jinja for enums
    • Project configuration templates (tsconfig, package.json, gitignore)
  • Add CLI command integration
    • Register s2ts command in commands.json
  • Create comprehensive tests
    • Test basic types conversion
    • Test complex types (choice, tuple)
    • Test extended types (decimal, date, uuid, etc.)
    • Test collections (array, set, map)
    • Test inheritance and extensions
    • Test abstract types
    • Test validation constraints
  • Lint, build and validate changes
    • All tests passing
    • CLI command verified
    • Generated code manually inspected
  • Run code review and security scan
Original prompt

This section details on the original issue you should resolve

<issue_title>Add structuretots: JSON Structure to TypeScript conversion</issue_title>
<issue_description>## Overview
Implement conversion from JSON Structure schemas to TypeScript types.

Requirements

This conversion should:

  1. Lean on the corresponding Avro conversion (avrotots) as precedent for output structure, including use of Jinja templates where applicable
  2. Cover the full breadth of the JSON Structure Core spec as defined in draft-vasters-json-structure-core-00
  3. Follow the patterns established by structuretocsharp and structuretopython, including their continued support for Avro schemas

Implementation Guidance

  • Review avrotize/avrotots.py for output patterns and template usage
  • Review avrotize/structuretocsharp.py and avrotize/structuretopython.py for the JSON Structure handling patterns
  • Ensure all JSON Structure Core types are supported:
    • JSON Primitive Types: string, number, boolean, null
    • Extended Primitive Types: binary, int8-128, uint8-128, float8/float/double, decimal, date, datetime, time, duration, uuid, uri, jsonpointer
    • Compound Types: object, array, set, map, tuple, any, choice (both tagged and inline unions)
  • Support JSON Structure-specific features:
    • Namespaces and definitions
    • Type references ($ref)
    • Extensions ($extends) and add-ins ($offers/$uses)
    • Abstract types
    • Required/optional properties
    • Type annotations (maxLength, precision, scale, contentEncoding, etc.)

References

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Created structuretots.py module with StructureToTypeScript class
- Implemented all JSON Structure type mappings (primitives, extended types, compounds)
- Support for namespaces, definitions, and type references
- Support for enums with proper Utils class generation
- Support for choice types (unions)
- Support for tuple types
- Support for collections (array, set, map)
- Support for required/optional properties
- Created Jinja templates for class and enum generation
- Added s2ts command to commands.json CLI
- Created comprehensive test suite with 10 test cases
- All tests passing

Co-authored-by: clemensv <542030+clemensv@users.noreply.github.com>
@clemensv

Copy link
Copy Markdown
Owner

@copilot

Additional Requirements

Documentation

The README.md file needs to be updated to include documentation for this new conversion feature, following the pattern established for existing conversions.

Testing

All tests must follow the established testing patterns:

  • For programming language outputs (C#, Java, Python, TypeScript, JavaScript, C++, Go, Rust): Tests must run the embedded tests in the code outputs to verify correctness
  • For schema language outputs (CSV, Protobuf, XSD, GraphQL, etc.): Tests must compare the generated output to a desired output reference (-ref) schema stored in the /test/struct directory

This follows the pattern established for the Avro conversion tests in the repository.

@clemensv

Copy link
Copy Markdown
Owner

Closing duplicate PR for TypeScript conversion. Keeping the newer PR #97 for this issue.

@clemensv clemensv closed this Nov 20, 2025
@clemensv
clemensv deleted the copilot/convert-json-structure-to-typescript branch November 20, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add structuretots: JSON Structure to TypeScript conversion

2 participants