refactor: extract filter ops to generic types, unify schema output#61
Closed
directormac wants to merge 2 commits intoash-project:mainfrom
Closed
refactor: extract filter ops to generic types, unify schema output#61directormac wants to merge 2 commits intoash-project:mainfrom
directormac wants to merge 2 commits intoash-project:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributor checklist
Leave anything that you believe does not apply unchecked.
Summary
This PR refactors
ash_typescript's code generation to prioritize Developer Experience (DX), reduce output bloat, and improve TypeScript compiler performance. We've shifted from massive inline object definitions to reusable generic templates and extracted internal metadata into clean, developer-consumable public types.Key Changes & Results
1. Clean Public Domain Models
Before: Developers used
UserResourceSchema, which included noisy internal engine fields like__typeand__primitiveFields.After: We export a pristine
Usertype. All internal metadata is hidden via a recursiveClean<T>utility.2. Reusable Generic Filter Types
Before: Every resource field inlined its own filter operations, leading to massive duplication (e.g., repeating
{ eq?: string, in?: string[] }hundreds of times).After: All filters now reference shared generic templates (
StringFilter,NumberFilter<T>,BooleanFilter, etc.).Result: Drastic reduction in
generated.tsfile size and faster TS compilation.3. Extracted
as constEnums & Field ListsBefore: Field names and enum values were inlined as static unions.
After: They are extracted into
as constarrays, providing runtime utility for developers (e.g., building dynamic forms).4. Formatter-Aware Filter Operations
Generic filter operations (e.g.,
notEq,greaterThanOrEqual) now dynamically respect the project's:output_field_formattersetting (camelCase, PascalCase, snake_case), ensuring total consistency across the generated API.New Configuration Options
In
config :ash_typescript:extra_structs[Module]Ash.TypedStructmodules to include as root-level schema types, even if not referenced by a resource.generate_filter_schemasbooleanUserFilterSchema). Defaults tofalse.generate_clean_typesbooleantrue.Contributor Checklist
Verification Results
mix test(2207 tests passed, 0 failures).npm run compileGenerated,compileShouldPass, andcompileShouldFail, ``. All passed.