-
-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] Refactor type random() methods
#12
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
Conversation
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
|
Copilot, please resume the task. |
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Task completed! I've successfully removed all individual |
streamich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add unit tests for the src/random/ module:
- Create a "fixtures" file with few JSON Type schemas. According to
src/schema/rules. - Put the fixtures file in
src/__tests__/for reuse by all modules. - Use the schema fixtures to generate random values.
- Validate that the produced values pass JSON Type value validation routine.
src/random/array.ts
Outdated
| @@ -0,0 +1,14 @@ | |||
| import type {ArrayType} from '../type/classes/ArrayType'; | |||
|
|
|||
| export function randomArray(type: ArrayType<any>): unknown[] { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Put all individual type random generator functions into a single module.
- Use ArrowFunction:
export const arr = () => ... - Use short names for exports, such as "arr", instead of "randomArr".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented! Consolidated all individual type random generator functions into a single generators.ts module using arrow functions with short names like arr, str, num, etc. Removed all individual generator files and updated the main router. Commit: 7156590
src/type/classes/AbstractType.ts
Outdated
| import type {TypeExportContext} from '../../system/TypeExportContext'; | ||
| import type {Validators} from './types'; | ||
| import type * as jtd from '../../jtd/types'; | ||
| import {generateRandom} from '../../random/generator'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just call the main export as "random", instead of "generateRandom".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Renamed the main export from generateRandom to random in both the generator module and AbstractType import/usage. Commit: 7156590
- Rename generateRandom to random in main export - Consolidate all individual type random generators into single module with arrow functions and short names - Update generator.ts to use consolidated generators - Remove individual generator files - All tests passing Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
- Create fixtures file with JSON Type schemas for reuse across modules - Add 20 comprehensive tests for individual generators and main router - Test validates generated values pass JSON Type validation - Test edge cases, constraints, and complex nested structures - Test deterministic behavior with controlled randomness - All 497 tests passing Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Complete! Added comprehensive unit tests for the
All 497 tests passing. Commit: c64769b |
streamich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve merge conflicts with the latest master.
Verify that tests, linter, and formatter pass.
…ethods, remove random() methods
…tor methods and random functionality Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Merge conflicts resolved! Successfully merged with latest master while preserving all functionality - capacity estimator methods from master are kept and the refactored random system remains intact. All tests, linting, and formatting pass. Commit: 8589e57 |
streamich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove codegenCapacityEstimator() method from all types but abstract type.
Make sure Prettier passes.
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Done! Removed |
|
🎉 This PR is included in version 1.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Current status: Successfully created the random generators folder with individual functions for each type and a main router function. Updated AbstractType to use the new system. All tests are passing.
Next: Remove the individual random() methods from concrete type classes.
Fixes #11.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.