namespace _zeitbild.api { /** */ export function register_davina_event_list( rest_subject : lib_plankton.rest_caldav.type_rest ) : void { register< null, ( Array< { event_id : (null | int); event_name : string; } > | string ) >( rest_subject, lib_plankton.http.enum_method.get, "/davina/event_list", { "output_schema": () => ({ "type": "array", "items": { "nullable": false, "type": "object", "additionalProperties": false, "properties": { "event_id": { "nullable": true, "type": "number", }, "event_name": { "nullable": false, "type": "string", }, }, "required": [ "event_id", "event_name", ], } }), "restriction": restriction_web_auth, "execution": async (stuff) => { const user : {id : _zeitbild.type_user_id; object : _zeitbild.type_user_object;} = await _zeitbild.api.user_from_web_auth(stuff); /** * @todo */ const from : lib_plankton.pit.type_pit = 0; const to : lib_plankton.pit.type_pit = 1800000000; const calendar_id : int = parseInt(stuff.query_parameters["calendar_id"]); return ( _zeitbild.service.calendar.gather_events( [calendar_id], from, to, user.id ) .then( (data) => Promise.resolve( { "status_code": 200, "data": ( data .map( (entry) => ({ "event_id": entry.event_id, "event_name": entry.event_object.name, }) ) ), } ) ) .catch( (reason) => Promise.resolve( { "status_code": 403, "data": String(reason), } ) ) ); } } ); } }