{%- macro generate(event) -%}
{
    "id" : "{{ uuid() }}",
    "time": "{% time %}",
    "specversion" : "1.0",
    {%- if "type" in event %}
    "type" : "{{ event.type.value }}",
    {%- endif %}
    {%- if "subject" in event %}
    "subject" : "{{ event.subject.value }}",
    {%- endif %}
    {%- if "dataschema" in event %}
    "dataschema" : "{{ event.dataschema.value }}",
    {%- endif %}
    {%- if "source" in event %}
    "source" : "{{ event.source.value }}",
    {%- endif %}
    {%- if "datacontenttype" in event %}
    "datacontenttype" : "{{ event.datacontenttype.value }}",
    {%- endif %}
    "data" : {
        "Hello" : "World"
    }
}
{% endmacro %}
{%- for messagegroupid, messagegroup in root.messagegroups.items() -%}
{%- for messageid, message in messagegroup.messages.items() %}
{{ generate(message.envelopemetadata) | pushfile("event_" + (messageid | strip_namespace | snake) + ".json") }}
{%- endfor %}
{%- endfor %}
{% exit %}