namespace _sindri.outputs.other.jsonschema { /** */ export function render( input_data ) : string { return lib_plankton.json.encode( Object.fromEntries( input_data.domains.map( domain => ([ domain.name, { "type": ["array"], "items": { "type": ["object"], "additionalProperties": false, "properties": Object.fromEntries( [] .concat( (domain.key_field === null) ? [] : [ [ domain.key_field.name, { "type": ["integer"], "description": (domain.key_field.description ?? undefined), } ] ] ) .concat( domain.data_fields .map( data_field => ([ data_field.name, { "type": ( [] .concat( data_field.nullable ? ["null"] : [] ) .concat( [ { "boolean": "boolean", "integer": "integer", "float": "number", "string_short": "string", "string_medium": "string", "string_long": "string", }[data_field.type] ] ) ), "description": (data_field.description ?? undefined), } ]) ) ) ), "required": ( [] .concat( (domain.key_field === null) ? [] : [domain.key_field.name] ) .concat( domain.data_fields .map( data_field => data_field.name ) ) ) }, } ]) ) ), true ); } } /** */ _sindri.add_output( _sindri.enum_realm.other, "jsonschema", { "render": (x) => Promise.resolve(_sindri.outputs.backend.typescript.render(x)), } );