Skip to content

Refactor rendering logic to ensure DRY code and consistent generation#22

Open
aram-wealthmore wants to merge 1 commit into
aram-devdocs:mainfrom
aram-wealthmore:refactor-rendering-logic
Open

Refactor rendering logic to ensure DRY code and consistent generation#22
aram-wealthmore wants to merge 1 commit into
aram-devdocs:mainfrom
aram-wealthmore:refactor-rendering-logic

Conversation

@aram-wealthmore

@aram-wealthmore aram-wealthmore commented Jan 13, 2025

Copy link
Copy Markdown

Refactor the rendering logic to ensure DRY code and consistent generation of TypeScript interfaces and Zod schemas.

  • generator.ts

    • Refactor to use generateInterfaceFileInline and generateZodSchemaFileInline for rendering models, inputs, outputs, enums, and args.
    • Remove redundant logic and use shared utilities.
  • libs/renderers/interfaceRenderer.ts

    • Add a new file to handle rendering of TypeScript interfaces.
    • Use shared utility functions for generating interfaces.
    • Integrate InlineContext for managing context.
  • libs/renderers/zodSchemaRenderer.ts

    • Add a new file to handle rendering of Zod schemas.
    • Use shared utility functions for generating Zod schemas.
    • Integrate InlineContext for managing context.
  • libs/renderers/enumRenderer.ts

    • Use shared utility functions for generating enums.
    • Integrate InlineContext for managing context.
  • libs/utils/camelCase.ts

    • Add toCamelCase function for consistent naming conventions.
  • libs/utils/buildUnionType.ts

    • Simplify logic for handling union types.
  • Delete files

    • Remove libs/renderers/complexTypeRenderer.ts and libs/renderers/modelRenderer.ts.

For more details, open the Copilot Workspace session.

Refactor the rendering logic to ensure DRY code and consistent generation of TypeScript interfaces and Zod schemas.

* **generator.ts**
  - Refactor to use `generateInterfaceFileInline` and `generateZodSchemaFileInline` for rendering models, inputs, outputs, enums, and args.
  - Remove redundant logic and use shared utilities.

* **libs/renderers/interfaceRenderer.ts**
  - Add a new file to handle rendering of TypeScript interfaces.
  - Use shared utility functions for generating interfaces.
  - Integrate `InlineContext` for managing context.

* **libs/renderers/zodSchemaRenderer.ts**
  - Add a new file to handle rendering of Zod schemas.
  - Use shared utility functions for generating Zod schemas.
  - Integrate `InlineContext` for managing context.

* **libs/renderers/enumRenderer.ts**
  - Use shared utility functions for generating enums.
  - Integrate `InlineContext` for managing context.

* **libs/utils/camelCase.ts**
  - Add `toCamelCase` function for consistent naming conventions.

* **libs/utils/buildUnionType.ts**
  - Simplify logic for handling union types.

* **Delete files**
  - Remove `libs/renderers/complexTypeRenderer.ts` and `libs/renderers/modelRenderer.ts`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/aram-devdocs/prisma-dto-gen?shareId=XXXX-XXXX-XXXX-XXXX).
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.

1 participant