<#ftl output_format="JSON">
<#-- The macro for generating view and template metadata for a new Group -->
<#macro newDatatype request uuid name typeNamespace>
{
    <#-- recipe section -->
    "objectStatus": "NEW",
    "replaceable": true,
    "recipeObjectId": "DATATYPE-0",
    "templateForCreate": "createDatatype.ftlx",

    <#-- bindings section -->
    "versionUuids": ["${request.generateUuid("DATATYPE_VERSION")}"],
    "namespace": "${typeNamespace}",
    "typeNamespace": "${typeNamespace}",
    "tableName": "${request.getTargetObject().fields.tableName?json_string}",
    "uuid": "${uuid}",
    "schemaLocation": [
    <#list request.getTargetObject().fields.schemaLocations as schemaLocation>
        "${schemaLocation}"
        <#if schemaLocation?has_next>
        ,
        </#if>
    </#list>
    ],
    "fields": [
    <#list request.getTargetObject().fields.recordSourceFields as f>
        {
            <#if f.properties.constraints?has_content>
            "constraints": "${f.properties.constraints?json_string}",
            </#if>
            <#if f.properties.type.array>
            "maxOccurs": ${f.properties.maxOccurs},
            "minOccurs": ${f.properties.minOccurs},
            </#if>
            "name": "${f.name}",
            "nillable": ${f.properties.nillable?c},
            "type": {
                "xsdType": "${f.properties.type.xsdType}",
                "array": ${f.properties.type.array?c}
            }
        <#if f?has_next>
        },
        <#else>
        }
        </#if>
    </#list>
    ],
    "name": "${name?json_string}",

    <#-- i18n section -->
    "description": "${request.getTextWithKey("recordActionTemplateRecipe.object.dataType.description.baseDataStructure", request.getTargetObjectNameWithoutPrefix())?json_string}"
}
</#macro>