/** */ namespace _dali { /** */ export enum enum_access_level { none, view, edit, admin } /** */ export type type_user_id = int; /** */ export type type_user_object = { name : string; email_address : ( null | string ); }; /** * @todo deprecate? */ export type type_local_resource_event_id = int; /** * info: das ist nicht deckungsgleich mit der Event-ID aus dem Backend; hiermit werden sowohl lokale als auch * extern eingebundene Events kodiert * * @example "local:1234" * @example "ics~2345" */ export type type_event_key = string; /** */ export type type_event_object = { name : string; begin : lib_plankton.pit.type_datetime; end : ( null | lib_plankton.pit.type_datetime ); location : ( null | string ); link : ( null | string ); description : ( null | string ); }; /** */ export type type_event_entry = { id : (null | type_local_resource_event_id); key : type_event_key; object : type_event_object; }; /** */ export type type_event_object_extended = { key : type_event_key; calendar_id : type_calendar_id; calendar_name : string; hue : float; access_level : enum_access_level; event_id : (null | type_local_resource_event_id); event_object : type_event_object; }; /** */ export type type_resource_id = int; /** */ export type type_resource_object = ( { kind : "local"; data : { events : Array< type_event_object >; }; } | { kind : "caldav"; data : { read_only : boolean; url : string; }; } ); /** */ export type type_calendar_id = int; /** */ export type type_calendar_object = { name : string; hue : float; access : { public : boolean; default_level : enum_access_level; attributed : lib_plankton.map.type_map< type_user_id, enum_access_level >; }; resource_id : type_resource_id; }; /** */ export type type_calendar_object_reduced = { name : string; hue : float; access_level : enum_access_level; }; /** */ export type type_calendar_object_reduced_with_id = { id : type_calendar_id; name : string; hue : float; access_level : enum_access_level; }; /** */ export enum enum_view_mode { week, list, } /** */ export function access_level_encode( access_level : _dali.enum_access_level ) : ("none" | "view" | "edit" | "admin") { switch (access_level) { case _dali.enum_access_level.none: return "none"; case _dali.enum_access_level.view: return "view"; case _dali.enum_access_level.edit: return "edit"; case _dali.enum_access_level.admin: return "admin"; } } /** */ export function access_level_decode( representation : /*("none" | "view" | "edit" | "admin")*/string ) : _dali.enum_access_level { switch (representation) { case "none": return _dali.enum_access_level.none; case "view": return _dali.enum_access_level.view; case "edit": return _dali.enum_access_level.edit; case "admin": return _dali.enum_access_level.admin; default: throw (new Error("invalid access level representation: " + representation)); } } /** */ export function view_mode_encode( mode : _dali.enum_view_mode ) : string { switch (mode) { case _dali.enum_view_mode.week: {return "week"; break;} case _dali.enum_view_mode.list: {return "list"; break;} default: {throw (new Error("invalid mode"));} } } /** */ export function view_mode_decode( view_mode_encoded : string ) : _dali.enum_view_mode { const map : Record = { "week": _dali.enum_view_mode.week, "list": _dali.enum_view_mode.list, }; if (! (view_mode_encoded in map)) { throw (new Error("invalid mode: " + view_mode_encoded)); } else { return map[view_mode_encoded]; } } }