backend/source/api/actions/davina_calendars.ts

69 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-08-29 10:52:37 +00:00
namespace _zeitbild.api
{
/**
*/
export function register_davina_calendars(
rest_subject : lib_plankton.rest_caldav.type_rest
) : void
{
register<
null,
2025-09-04 07:46:49 +00:00
(
null
|
Array<
{
id : int;
name : string;
access_level : string;
}
>
)
2025-08-29 10:52:37 +00:00
>
(
rest_subject,
lib_plankton.http.enum_method.get,
"/davina/calendars",
{
"input_schema": () => ({
"nullable": true,
}),
"output_schema": () => ({
"nullable": false,
"type": "boolean",
}),
2025-09-04 07:46:49 +00:00
"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);
2025-08-29 10:52:37 +00:00
return (
2025-09-04 07:46:49 +00:00
_zeitbild.service.calendar.overview(user.id)
2025-08-29 10:52:37 +00:00
.then(
(data_raw) => Promise.resolve(
data_raw
.map(
(entry) => ({
"id": entry.id,
"name": entry.name,
"access_level": _zeitbild.value_object.access_level.to_string(entry.access_level),
})
)
)
)
.then(
(data) => Promise.resolve({
"status_code": 200,
"data": data,
})
)
);
},
}
);
}
}