-
Notifications
You must be signed in to change notification settings - Fork 114
Description
Category
Cedar validation features
Describe the feature you'd like to request
The Cedar schema supports commonTypes definitions to help avoid duplicating attribute types in entity types shapes and actions contexts, but commonTypes cannot currently be used inside other common types definitions.
The Cedar schema should support commonTypes defined in terms of other commonTypes. It should however, not support recursive types.
Describe the solution you'd like
The schema parser will construct a directed graph of the type definitions, with an edge from each type to the other types it depends on. It will then check that the graph is acyclic. This can be done using our existing functions for checking that the entity hierarchy is a DAG. We can safely inline common type definitions once we know the dependency graph does not have cycles.
Describe alternatives you've considered
If we depend on the order of commonTypes being significant, we could require that a type is declared before it is referenced, making cycles impossible to create.
The order of entries in a JSON map is not generally significant, so we would either need to break from this convention by making the order significant, or use an association list of pairs instead. Depending on the order of the map is not acceptable because it is likely to cause issues if the a schema document is processed by standard JSON tools which may not preserve order. Using an association list would make common types use a different structure than the entity types and actions list.
Additional context
No response
Is this something that you'd be interested in working on?
- 👋 I may be able to implement this feature request
-
⚠️ This feature might incur a breaking change