You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, users sometimes have valid reasons for wanting their own sort order.
Our use case: as an example
Background: a table registry in smithy
We manage database tables via a registry of smithy IDL files (in a git repo). Users sometimes write their IDL from scratch, but usually they start by making a table in a sandbox area of the database. When they are done developing the table, they want to bring it into the registry, so our tooling includes the ability to translate the table into a smithy IDL file on demand.
The problem: readable smithy IDL
For style and readability reasons, we want to put the table's Struct at the end of the file after all the shapes (column data types, etc) that build up to it. We can't sort the model since it's intrinsically unsorted (a good thing) and sorting the output would be too finicky. If there were an AST between the model and the text output, we could sort that very fluently, but the only options we've found render text directly from the model.
Workaround: faking source location
Long story short, we're faking source location for each shape to get the desired output. It works, but obviously it's very ugly and wouldn't work for anyone who really needs the source location and control of the component order.
Proposal: let user bring their own comparator
A Comparator might not always be the easiest way to specify a sort. For example, in our case, we mostly just want the table's shape to show up last and there are many easier ways to express that. But any sorting logic can ultimately be specified with a comparator and most logics will be better or best expressed that way anyway.
So, adding this one feature would allow all possible sorts (but IDK how hard it is to add).
The text was updated successfully, but these errors were encountered:
Currently, SmithyIdlComponentOrder only takes 3 values:
ALPHA_NUMERIC
SOURCE_LOCATION
PREFERRED
However, users sometimes have valid reasons for wanting their own sort order.
Our use case: as an example
Background: a table registry in smithy
We manage database tables via a registry of smithy IDL files (in a git repo). Users sometimes write their IDL from scratch, but usually they start by making a table in a sandbox area of the database. When they are done developing the table, they want to bring it into the registry, so our tooling includes the ability to translate the table into a smithy IDL file on demand.
The problem: readable smithy IDL
For style and readability reasons, we want to put the table's Struct at the end of the file after all the shapes (column data types, etc) that build up to it. We can't sort the model since it's intrinsically unsorted (a good thing) and sorting the output would be too finicky. If there were an AST between the model and the text output, we could sort that very fluently, but the only options we've found render text directly from the model.
Workaround: faking source location
Long story short, we're faking source location for each shape to get the desired output. It works, but obviously it's very ugly and wouldn't work for anyone who really needs the source location and control of the component order.
Proposal: let user bring their own comparator
A
Comparator
might not always be the easiest way to specify a sort. For example, in our case, we mostly just want the table's shape to show up last and there are many easier ways to express that. But any sorting logic can ultimately be specified with a comparator and most logics will be better or best expressed that way anyway.So, adding this one feature would allow all possible sorts (but IDK how hard it is to add).
The text was updated successfully, but these errors were encountered: