namespace _lixer_event_reminder.sources.kalender_digital { /** */ export type type_parameters = { id : string; filtration : { category_blacklist : Array; title_blacklist : Array; }; }; /** */ async function fetch( parameters : type_parameters ) : Promise> { const http_request : lib_plankton.http.type_request = { "scheme": "https", "host": "export.kalender.digital", "path": lib_plankton.string.coin( "/ics/0/{{id}}/gesamterkalender.ics", { "id": parameters.id, } ), "version": "HTTP/2", "method": lib_plankton.http.enum_method.get, "query": lib_plankton.string.coin( "?past_months={{past_months}}&future_months={{future_months}}", { "past_months": (0).toFixed(0), "future_months": (2).toFixed(0), } ), "headers": {}, "body": null, }; const http_response : lib_plankton.http.type_response = await lib_plankton.http.call(http_request); const ics : string = http_response.body.toString(); const vcalendar : lib_plankton.ical.type_vcalendar = lib_plankton.ical.ics_decode(ics); const events : Array<_lixer_event_reminder.type_event> = ( vcalendar.vevents .filter( vevent => ( vevent.categories.every(category => ! parameters.filtration.category_blacklist.includes(category)) && parameters.filtration.title_blacklist.every(title => ! vevent.summary.toLowerCase().includes(title.toLowerCase())) ) ) .map( vevent => { const begin : lib_plankton.pit.type_datetime = { "timezone_shift": 0, "date": vevent.dtstart.value.date, "time": vevent.dtstart.value.time, }; const end : lib_plankton.pit.type_datetime = { "timezone_shift": 0, "date": vevent.dtend.value.date, "time": vevent.dtend.value.time, }; const event : _lixer_event_reminder.type_event = { "title": vevent.summary, "begin": begin, "end": end, "location": vevent.location, }; return event; } ) ); return events; } /** */ export function implementation_source( parameters : type_parameters ) : _lixer_event_reminder.type_source { return { "fetch": () => fetch(parameters), }; } }