feat(generator): draft immutable AckType model generation - #132
Draft
leoafarias wants to merge 5 commits into
Draft
feat(generator): draft immutable AckType model generation#132leoafarias wants to merge 5 commits into
leoafarias wants to merge 5 commits into
Conversation
Replaces old code generation approach with new immutable model classes: - New model_emitter.dart for generating immutable AckType classes - schema_model_graph_builder.dart for schema analysis - Removes old schema_ast_analyzer, class_builder, and related models - Updates tests to use new v2 generation approach - Generates .ack.dart files instead of .g.dart - Updates documentation and examples
Ack now emits both .ack.dart model parts and .g.dart JSON helpers via an internal builder that delegates structural mapping to json_serializable while keeping schema validation and codecs in the source Ack schema. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
This draft replaces the map-backed
@AckType()extension-type generator with immutable Dart model classes while keeping Ack schemas responsible for validation, defaults, codecs, and boundary serialization.The branch is intentionally open for architecture and API review before validation. I was not able to run Dart tooling in this environment.
Main pieces included
ack_generatorfrom direct.g.dartownership toSharedPartBuilderplus thesource_gencombining builder.AckModelAdapter<Boundary, Runtime, Model>as the codec-safe bridge between Ack runtime values and generated classes.TypeBuilderextension-type emitter.@AckType(name: 'Member')generatesMemberexactly, without aTypesuffix.Intended generated API
Generated models do not implement
Map<String, Object?>and do not retain a backing map as their application data model.Serialization model
Nested models use
Nested.$ack.fromRuntime(...)andNested.$ack.toRuntime(...)instead of parsing an already-decoded runtime value again. This is required forDateTime,Uri,Duration, enums, and custom codecs.json_serializablerelationshipAck generates the conventional methods itself:
The intent is interoperability with
json_serializablecustom nested types. Ack does not emit@JsonSerializable, call its private generator APIs, or introduce a hidden second generation pass.Review focus
UserType->User).AckModelAdapteras the boundary/runtime bridge.SharedPartBuilderconfiguration and coexistence with other generators.Map<String, Object?>or gain a configurable field/type policy.Known draft gaps
Ack.lazyand recursive schema analysis are not wired yet.transform()encode capability are not propagated into generation yet.json_serializablestack.json_serializablecoexistence and custom nested-type fixtures are not included yet.Validation status
Not run locally in this environment.
dart pub getdart format --output=none --set-exit-if-changed .dart analyze --fatal-infosdart testdart run build_runner cleandart run build_runner build --delete-conflicting-outputsjson_serializablebuilder coexistence fixturejson_serializablecustom nested-type fixtureArchitecture notes
See
docs/architecture/acktype-model-generation.mdfor the full design, migration table, known constraints, and validation checklist.