element_registry
A registry for mapping element names to dataclasses.
| CLASS | DESCRIPTION |
|---|---|
ElementDescriptor |
A descriptor for a BPMN element. |
ElementProperty |
A property of a BPMN element. |
ElementRegistry |
A registry for BPMN elements. |
| FUNCTION | DESCRIPTION |
|---|---|
dataclass_fields |
Get the fields of a dataclass. |
descriptor_from_class |
Create a descriptor from a BPMN element class. |
get_base_type |
Extract the most basic type from complex type annotations. |
register_element |
Register an element in the global element registry. |
type_hint_to_property |
Converts a type hint represented as a dictionary into an |
Classes¶
ElementDescriptor
dataclass
¶
A descriptor for a BPMN element.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The XML name of the BPMN element.
TYPE:
|
properties |
A mapping of BPMN attribute names to ElementProperty objects.
TYPE:
|
q_name |
The qualified name of the BPMN element.
TYPE:
|
type |
The class of the BPMN element.
TYPE:
|
Attributes¶
properties
instance-attribute
¶
properties: dict[QName, ElementProperty]
A mapping of BPMN attribute names to ElementProperty objects.
ElementProperty
dataclass
¶
ElementProperty(
property_name: str,
type: str,
type_qname: Optional[QName] = None,
is_attr: bool = False,
is_many: bool = False,
is_optional: bool = False,
is_reference: bool = False,
)
A property of a BPMN element.
| ATTRIBUTE | DESCRIPTION |
|---|---|
is_attr |
Whether the attribute is serialized as an XML attribute.
TYPE:
|
is_many |
Whether the attribute is an array or a single value. Automatically set based on the type.
TYPE:
|
is_optional |
Whether the attribute is optional. Automatically set based on the type.
TYPE:
|
is_reference |
Whether the attribute is a reference to another element.
TYPE:
|
property_name |
The name of the attribute on the element class.
TYPE:
|
type |
The type of the attribute on the element class.
TYPE:
|
type_qname |
The base type of the attribute on the element class. Automatically set based on the type. |
Attributes¶
is_attr
class-attribute
instance-attribute
¶
is_attr: bool = False
Whether the attribute is serialized as an XML attribute.
is_many
class-attribute
instance-attribute
¶
is_many: bool = False
Whether the attribute is an array or a single value. Automatically set based on the type.
is_optional
class-attribute
instance-attribute
¶
is_optional: bool = False
Whether the attribute is optional. Automatically set based on the type.
is_reference
class-attribute
instance-attribute
¶
is_reference: bool = False
Whether the attribute is a reference to another element.
ElementRegistry
¶
ElementRegistry()
Functions¶
dataclass_fields
¶
Get the fields of a dataclass.
descriptor_from_class
¶
descriptor_from_class(element_class: Any) -> ElementDescriptor
Create a descriptor from a BPMN element class.
get_base_type
¶
Extract the most basic type from complex type annotations.
This function handles various typing constructs including: - Optional types (Union[T, None]) - List types (list[T]) - Dictionary types (dict[K, V]) - Union types (Union[T1, T2, …])
Examples:
Optional[list[str]] -> str list[str] -> str str -> str list[dict[str, int]] -> dict Union[int, float] -> Raises ValueError (multiple non-None types)
| PARAMETER | DESCRIPTION |
|---|---|
type_
|
The type annotation to extract the base type from
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
The base type |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If Union contains multiple non-None types |
register_element
¶
Register an element in the global element registry.
type_hint_to_property
¶
type_hint_to_property(
name: str, type_hint: Any, field_metadata: dict[str, Any]
) -> ElementProperty
Converts a type hint represented as a dictionary into an ElementProperty object.
This function introspects a provided type hint, extracting metadata and attributes of the type hint to create an
ElementProperty. The extracted information includes whether the type is optional, represents multiple items, or
is associated with an attribute. The function relies on type inspection utilities to derive these characteristics
and use them to initialize the ElementProperty.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name associated with the type hint or field.
TYPE:
|
type_hint
|
The type hint which defines the expected type or structure.
TYPE:
|
field_metadata
|
Metadata associated with the field, containing information about whether the field is an attribute or an element. |
| RETURNS | DESCRIPTION |
|---|---|
ElementProperty
|
Returns an |
ElementProperty
|
inferred from the type hint. |