RFC: Self-hosting - Use generated protocol models and metamodels #263
Labels
Studio Core Team
Opened by a member of the Studio core team
Type: Discussion
Type: Mega-thread
Tracker for multiple related issues
Type: Refactor
Milestone
💬 Request for Comments
We are a modelling tool, in fact, our protocols and metamodels are models we could build in Pure as well, and worse yet, we are not auto-generating these models but repeating their definition in 3 code bases
legend-studio
,legend-engine
andlegend-pure
. We should model these in Pure and code-gen their definition into Typescript for consumption in Studio codebase.Simplify metamodel
We need to simplify metamodels so that these can be auto-generated from models in Pure. After this, we're sure that the structure of metamodel more consistent and easier for code-generation
lambdaId
to stores - Stabilize relational mapping editor and compilation error handling in form mode #227PackageableElementSelectOption
back intostores
, don't leave those ingraph
andmetamodels
label
, e.g.MappingElementLabel
- optimize path and element resolution when building graph #1068owner
,parentClass
, etc.) that are not in the actual metamodel, we should prefix them with
_, such as
_owner` - simplify metamodels #1153MappingHelpers
,PackageableElementHelpers
like infinos/legend-pure
- removeStubable
and more metamodel simplifications #1159- Detailed in Feature request: Metamodel verifier #288 but no longer deem neededIMPORTANT
Add field integrity verification tohashCode
(basically check if properties annotated with ! are actually non-null)Stubable
interface -> Have a factory to create stub and check for stub maybe? -> move the logic out for stubable to a factory or some helper methods to initialize new instances - removeStubable
and more metamodel simplifications #1159- see belowHashable
interface, we don't need models to implement this interface anymore.Move- we will most likely do this later in Feature request: Support global linter/validator #1168validation
logic totop-down
as well@computed
cases (e.g.allSuperClasses
,allSubClassses
) we might not need that ascomputed
value at all - removeStubable
and more metamodel simplifications #1159MAYBE
Turn ALL metadata fields (fields likeProperty
'sowner
,uuid
etc.) toreadonly
and leave the access modifier aspublic
- ONLY during initialization do we allow to change thesereadonly
property using theWritable
improved mapped type modifiers trick in Typescript, write a good doc there to explain why thisabuse
should only be treated as a hack used ONLY during graph initialization. Or we can simply useObject.assign
syntax... - simplify metamodels #1153constructor
, in fact, we couldremove/make private
the constructor all together and replace them bystatic
creator methods!
and?
in the property definitionhashing
andvalidation
logic, revisit spots where we should useisStubbed_...
method and use them, right now to avoid bad dependencies between models and the helpers method, we don't do thisDSL Diagram classes
out to helpers.Packageable Element
outhashing
in the reactive manner is still the best, but we will seeOther considerations
CONSIDER
We probably would need to take care of visitors as part of code generation.JS
does not support overloading likeJava
so we can't really have 2accept()
methods, we would need to have them differentiated, e.g.accept_SetImplementationVisitor()
andaccept_PropertyMappingVisitor()
for embedded property mappings.CONSIDER
How do we support Typescriptunion type
? Maybe we can useAny
in Pure and then use a tagged-value to annotate union type?Class/Interface swap:
Since
Pure
support multiple inheritance, we might need to do whatlegend-pure
does by turning metamodels intointerfaces
to support multiple-inheritance (withC3 linearization
support?), something like the followingCoreInstance
interface andConcreteCoreInstance
class:_Impl
(that extendsConcreteCoreInstance
) and have everything as interface that extendsCoreInstance
: i.e.Class
vsClassImpl
.MAYBE
We should have optional UUID to eachCoreInstance
, add a method to allow setting this UUID. NOTE that if we make this non-optional, we're adding a lot of data to the graphinstanceof
, to recover, for each interface, we can do the following:The text was updated successfully, but these errors were encountered: