Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perfomance and Accuracy #4

Open
2 of 14 tasks
aram-devdocs opened this issue Jan 12, 2025 · 0 comments · Fixed by #19
Open
2 of 14 tasks

Perfomance and Accuracy #4

aram-devdocs opened this issue Jan 12, 2025 · 0 comments · Fixed by #19
Milestone

Comments

@aram-devdocs
Copy link
Owner

aram-devdocs commented Jan 12, 2025

Performance and Accuracy Improvements

Current Problems

  • Generated files are becoming extremely large (tens of thousands of lines)
  • Complex inline type generation causing IDE and TypeScript server crashes
  • Circular dependencies leading to performance issues
  • Overuse of z.any and any types in generated schemas
  • Input/Output type accuracy needs improvement

Goals

Performance

  • Implement circular dependency management solution
  • Add caching system for previously encountered types
  • Add configurable "level of detail" for type generation
  • Make imports from other files optional vs inline generation
  • Implement depth limit in config to cap infinite nesting

Accuracy

  • Reduce/eliminate use of z.any in schema generation
  • Improve type accuracy in input/output files
  • Add relationship flattening configuration options
  • Implement type caching to better handle repeated types

Code Organization

  • Separate schema generation into dedicated module
  • Add pre-generation cleanup of output directory
  • Implement generation change logging
  • Consolidate file writing/generation logic
  • Add granular type definition controls

Key Areas to Focus

Code References

  1. Type Generation
// generator.ts:69-90
// Review model file generation loop
for (const m of models) {
  const content = generateModelFileInline(m, [...models, ...types], enumMap, modelMap, config);
  const filePath = resolvePath(outputDir, `model_${m.name}.ts`);
  await writeTsFile({ filePath, content, config });
  modelFiles.push(filePath);
}

2. Configuration
```ts
// generator.ts:24-45
// Expand config options for granular control
const config: Config = {
  // Add new options:
  // - relationshipFlatteningLevel
  // - typeGenerationDetail  
  // - importStrategy
  // - cacheStrategy
}
  1. File Management
// libs/utils/writeTsFile.ts
// Add pre-write cleanup and logging
export async function writeTsFile({
  filePath,
  content,
  config,
}: {
  filePath: string;
  content: string;
  config: Config;
})
@aram-devdocs aram-devdocs converted this from a draft issue Jan 12, 2025
@aram-devdocs aram-devdocs added this to the v1.0.0 milestone Jan 12, 2025
@aram-devdocs aram-devdocs linked a pull request Jan 12, 2025 that will close this issue
@github-project-automation github-project-automation bot moved this from In Progress to Done in v1.0.0 Release Jan 12, 2025
@aram-devdocs aram-devdocs reopened this Jan 12, 2025
@aram-devdocs aram-devdocs moved this from Done to In Progress in v1.0.0 Release Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

1 participant