HomeContact
introducing ast-to-entity-definitions
Hiromi Shikata
Hiromi Shikata
November 18, 2024

introducing ast-to-entity-definitions

CircleCI code style: prettier semantic-release: angular

Welcome to ast-to-entity-definitions! 🎉 This tool allows you to easily generate EntityDefinition and EntityPropertyDefinition from your TypeScript type information. By automating this process, you can streamline the generation of source code that interacts with your domain model.

Motivation and Key Features

The motivation behind creating this library was the observation that a significant portion of domain model-driven source code can be automatically generated based on the TypeScript type definitions. Since the domain model is typically well-defined, a lot of the boilerplate code (such as repository implementations, GraphQL resolvers, and test scaffolding) can be generated from the TypeScript types.

This library works by parsing the TypeScript abstract syntax tree (AST) and converting the type information into EntityDefinition and EntityPropertyDefinition objects. These objects can then be used to generate various types of code, such as:

  • GraphQL schema and resolver code
  • Database repository implementations
  • Test fixtures and scaffolding

The key features of this library include:

  1. TypeScript AST parsing: The library can read TypeScript files and extract the necessary type information to generate the entity definitions.
  2. Flexible code generation: The generated entity definitions can be used to produce code in various languages and technologies, not just limited to TypeScript. The output is in the form of JSON, which can be easily integrated into your own code generation workflows.
  3. Extensibility: The library is designed to be extensible, allowing you to add your own custom code generators to suit your specific needs.

Getting Started

To get started, you can install the ast-to-entity-definitions package via npm or Yarn:

npm install ast-to-entity-definitions

or

yarn add ast-to-entity-definitions

Once installed, you can use the library in your project either through the provided CLI or by importing the getEntityDefinitions function directly.

We hope that ast-to-entity-definitions can help streamline your domain-driven development workflow. If you have any questions, feedback, or contributions, please don't hesitate to reach out!


Tags

#TypeScript#npm#npm-cli
© 2026, All Rights Reserved.
Powered By

Quick Links

Advertise with usAbout UsContact Us

Social Media