{# =============================================================================
   TYPESCRIPT API TYPES TEMPLATE - Generates request/response types
   Uses sparql_results array with ?-prefixed keys
   ============================================================================= #}
/**
 * Generated API request/response types from RDF ontology
 * DO NOT EDIT - auto-generated by ggen sync
 */

{%- set current_type = "" -%}
{%- for row in sparql_results -%}
{%- set entityName = row["?entityName"] | default(value="") -%}
{%- set operationType = row["?operationType"] | default(value="") -%}
{%- set propertyName = row["?propertyName"] | default(value="") -%}
{%- set propertyType = row["?propertyType"] | default(value="string") -%}
{%- set required = row["?required"] | default(value="false") -%}

{%- set type_name = "" -%}
{%- if operationType == "create" -%}
{%- set type_name = "Create" ~ entityName ~ "Request" -%}
{%- elif operationType == "update" -%}
{%- set type_name = "Update" ~ entityName ~ "Request" -%}
{%- endif -%}

{%- if type_name != "" and type_name != current_type -%}
{%- if current_type != "" %}
}

{% endif -%}
{%- set_global current_type = type_name %}
/**
 * {{ type_name }}
 */
export interface {{ type_name }} {
{%- endif %}
{%- if type_name != "" %}
  {{ propertyName }}{% if required != "true" %}?{% endif %}: {% if propertyType == "string" %}string{% elif propertyType == "integer" %}number{% elif propertyType == "number" %}number{% elif propertyType == "boolean" %}boolean{% else %}string{% endif %};
{%- endif %}
{%- endfor %}
}
