feat: add modelsdk — auto-generated type-safe model SDK#335
Open
engalar wants to merge 1 commit intomendixlabs:mainfrom
Open
feat: add modelsdk — auto-generated type-safe model SDK#335engalar wants to merge 1 commit intomendixlabs:mainfrom
engalar wants to merge 1 commit intomendixlabs:mainfrom
Conversation
65bd533 to
00ac646
Compare
…undtrip Add a new `modelsdk/` package that provides a fundamentally better architecture for reading and writing Mendix MPR files compared to the existing hand-written `sdk/` layer. This is an additive, non-breaking change — no existing code is modified. The new package coexists with `sdk/` to enable gradual migration. Key improvements over current sdk/: - 1,500+ auto-generated types across 53 Mendix domains (vs ~480 hand-written) - Type registry with automatic init() registration (vs manual dispatch) - Dirty tracking via bitmap + container chain propagation - BSON roundtrip preservation — unknown fields survive read/write cycles - Lazy decode via InitFromRaw() — zero cost for unaccessed fields - Three-branch encoder: self-dirty / child-dirty / clean pass-through - Property abstraction: Primitive[T], Part[T], PartList[T], Enum[T], ByNameRef[T] - Per-property version metadata (introduced/deleted/public) - Reference registry for cross-domain relationship tracking Packages added: - modelsdk/codec — BSON encoder/decoder with type registry - modelsdk/element — Element interface with dirty tracking - modelsdk/property — Generic property types with lazy init - modelsdk/gen/ — 53 auto-generated domain packages - modelsdk/mpr — MPR v1/v2 reader/writer - modelsdk/widgets — Widget template handling - modelsdk/meta — System module metadata - modelsdk/version — Version compatibility info - cmd/modelsdk-codegen — Code generator from TS SDK reflection data - internal/codegen/dtsparser — TypeScript SDK parser - internal/codegen/emitter — Go code generation templates
00ac646 to
637565e
Compare
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
Add a new
modelsdk/package — a fundamentally better architecture for reading and writing Mendix MPR files. This is additive only (no existing code modified) and coexists withsdk/to enable gradual migration.Why this is a better solution
The current
sdk/layer has five structural problems that can't be fixed incrementally:sdk/modelsdk/init()→DefaultRegistrysupplements.json, re-run codegenArchitecture highlights
Primitive[T],Part[T],PartList[T],Enum[T],ByNameRef[T]unify field access with lazy init and dirty trackingInitFromRaw()parses BSON on first access; unaccessed fields cost nothingintroduced/deleted/publicversion info from Mendix metamodel$Typevalues decode to genericelement.Basepreserving raw bytes, so the document round-trips without data lossWhat's included
modelsdk/codec/modelsdk/element/modelsdk/property/modelsdk/gen/(53 packages)modelsdk/mpr/modelsdk/widgets/modelsdk/meta/cmd/modelsdk-codegen/internal/codegen/dtsparser/.jsfile parserinternal/codegen/emitter/Test plan
go build ./modelsdk/...compiles cleango build ./cmd/modelsdk-codegen/...compiles cleango test ./modelsdk/...— 7 packages pass (codec, element, property, version, widgets, mpk, model)🤖 Generated with Claude Code