2024-09-12 00:02:12 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
2025-09-25 17:54:20 +02:00
|
|
|
namespace _dali.backend
|
2024-09-12 00:02:12 +02:00
|
|
|
{
|
|
|
|
|
|
2025-10-17 00:10:28 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
type type_conf = {
|
|
|
|
|
scheme : string;
|
|
|
|
|
host : string;
|
|
|
|
|
port : int;
|
|
|
|
|
path : string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
type type_request = {
|
|
|
|
|
method : lib_plankton.http.enum_method;
|
|
|
|
|
action : string;
|
|
|
|
|
input : (null | any);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
type type_event_object = {
|
|
|
|
|
name : string;
|
|
|
|
|
begin : {
|
|
|
|
|
timezone_shift: int;
|
|
|
|
|
date: {
|
|
|
|
|
year: int;
|
|
|
|
|
month: int;
|
|
|
|
|
day: int;
|
|
|
|
|
};
|
|
|
|
|
time: (
|
|
|
|
|
null
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
hour: int;
|
|
|
|
|
minute: int;
|
|
|
|
|
second: int;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
end : (
|
|
|
|
|
null
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
timezone_shift: int;
|
|
|
|
|
date: {
|
|
|
|
|
year: int;
|
|
|
|
|
month: int;
|
|
|
|
|
day: int;
|
|
|
|
|
};
|
|
|
|
|
time: (
|
|
|
|
|
null
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
hour: int;
|
|
|
|
|
minute: int;
|
|
|
|
|
second: int;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
location : (
|
|
|
|
|
null
|
|
|
|
|
|
|
|
|
|
|
string
|
|
|
|
|
);
|
|
|
|
|
link : (
|
|
|
|
|
null
|
|
|
|
|
|
|
|
|
|
|
string
|
|
|
|
|
);
|
|
|
|
|
description : (
|
|
|
|
|
null
|
|
|
|
|
|
|
|
|
|
|
string
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
var _conf : type_conf;
|
|
|
|
|
|
|
|
|
|
|
2024-09-12 00:02:12 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
2024-09-19 10:17:43 +02:00
|
|
|
var _data_chest : (
|
|
|
|
|
null
|
|
|
|
|
|
|
|
|
|
|
lib_plankton.storage.type_chest<string, string, void, string, string>
|
|
|
|
|
) = null;
|
|
|
|
|
|
|
|
|
|
|
2024-09-26 10:52:31 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
2025-10-14 22:10:56 +02:00
|
|
|
var _cache : (
|
|
|
|
|
null
|
|
|
|
|
|
|
|
|
|
|
lib_plankton.cache.type_subject<boolean>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2024-09-26 10:52:31 +02:00
|
|
|
*/
|
2025-10-17 00:10:28 +02:00
|
|
|
var _queue : {
|
|
|
|
|
items : Array<
|
|
|
|
|
{
|
|
|
|
|
request : type_request;
|
|
|
|
|
resolve : ((result : any) => void);
|
|
|
|
|
reject : ((reason : any) => void);
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
busy : boolean;
|
|
|
|
|
};
|
2024-09-26 10:52:31 +02:00
|
|
|
|
|
|
|
|
|
2024-09-19 10:17:43 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
2025-10-17 00:10:28 +02:00
|
|
|
export async function initialize(
|
|
|
|
|
conf : type_conf
|
|
|
|
|
)
|
|
|
|
|
: Promise<void>
|
2024-09-19 10:17:43 +02:00
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
_conf = conf;
|
2024-09-19 10:17:43 +02:00
|
|
|
_data_chest = lib_plankton.storage.localstorage.implementation_chest(
|
|
|
|
|
{
|
|
|
|
|
"corner": "zeitbild",
|
|
|
|
|
}
|
|
|
|
|
);
|
2025-10-14 22:10:56 +02:00
|
|
|
_cache = lib_plankton.cache.make<boolean>(
|
|
|
|
|
/*
|
|
|
|
|
lib_plankton.storage.memory.implementation_chest(
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
*/
|
|
|
|
|
);
|
2025-10-17 00:10:28 +02:00
|
|
|
_queue = {
|
|
|
|
|
"items": [],
|
|
|
|
|
"busy": false,
|
|
|
|
|
};
|
2024-09-19 10:17:43 +02:00
|
|
|
return Promise.resolve<void>(undefined);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
async function get_session_key(
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<(null | string)>
|
2024-09-19 10:17:43 +02:00
|
|
|
{
|
2025-10-02 17:00:17 +02:00
|
|
|
try
|
|
|
|
|
{
|
2024-09-19 10:17:43 +02:00
|
|
|
return (await _data_chest.read("session_key"));
|
|
|
|
|
}
|
2025-10-02 17:00:17 +02:00
|
|
|
catch (error)
|
|
|
|
|
{
|
2024-09-19 10:17:43 +02:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-12 00:02:12 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
2025-10-17 00:10:28 +02:00
|
|
|
async function call_real(
|
|
|
|
|
request : type_request
|
|
|
|
|
)
|
|
|
|
|
: Promise<any>
|
2024-09-19 01:40:27 +02:00
|
|
|
{
|
|
|
|
|
const with_body : boolean = (
|
|
|
|
|
[
|
|
|
|
|
lib_plankton.http.enum_method.post,
|
|
|
|
|
lib_plankton.http.enum_method.put,
|
|
|
|
|
lib_plankton.http.enum_method.patch,
|
2025-10-17 00:10:28 +02:00
|
|
|
].includes(request.method)
|
2024-09-19 01:40:27 +02:00
|
|
|
);
|
2024-09-19 10:17:43 +02:00
|
|
|
const session_key : (null | string) = await get_session_key();
|
2024-09-19 01:40:27 +02:00
|
|
|
const http_request : lib_plankton.http.type_request = {
|
|
|
|
|
"version": "HTTP/2",
|
|
|
|
|
"scheme": (
|
2025-10-17 00:10:28 +02:00
|
|
|
(_conf.scheme === "http")
|
2024-09-19 01:40:27 +02:00
|
|
|
?
|
|
|
|
|
"http"
|
|
|
|
|
:
|
|
|
|
|
"https"
|
|
|
|
|
),
|
|
|
|
|
"host": lib_plankton.string.coin(
|
|
|
|
|
"{{host}}:{{port}}",
|
|
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
"host": _conf.host,
|
|
|
|
|
"port": _conf.port.toFixed(0),
|
2024-09-19 01:40:27 +02:00
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
"path": lib_plankton.string.coin(
|
|
|
|
|
"{{base}}{{action}}",
|
|
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
"base": _conf.path,
|
|
|
|
|
"action": request.action,
|
2024-09-19 01:40:27 +02:00
|
|
|
}
|
|
|
|
|
),
|
2025-10-17 00:10:28 +02:00
|
|
|
"method": request.method,
|
2024-09-19 01:40:27 +02:00
|
|
|
"query": (
|
2025-10-17 00:10:28 +02:00
|
|
|
(with_body || (request.input === null))
|
2024-09-19 01:40:27 +02:00
|
|
|
?
|
|
|
|
|
null
|
|
|
|
|
:
|
2025-10-17 00:10:28 +02:00
|
|
|
("?" + lib_plankton.www_form.encode(request.input))
|
2024-09-19 01:40:27 +02:00
|
|
|
),
|
|
|
|
|
"headers": Object.assign(
|
|
|
|
|
{},
|
|
|
|
|
(
|
|
|
|
|
(! with_body)
|
|
|
|
|
?
|
|
|
|
|
{}
|
|
|
|
|
:
|
|
|
|
|
{"Content-Type": "application/json"}
|
|
|
|
|
),
|
|
|
|
|
(
|
2024-09-19 10:17:43 +02:00
|
|
|
(session_key === null)
|
2024-09-19 01:40:27 +02:00
|
|
|
?
|
|
|
|
|
{}
|
|
|
|
|
:
|
2024-09-19 10:17:43 +02:00
|
|
|
{"X-Session-Key": session_key}
|
2024-09-19 01:40:27 +02:00
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
"body": (
|
2025-10-17 00:10:28 +02:00
|
|
|
((! with_body) || (request.input === null))
|
2024-09-19 01:40:27 +02:00
|
|
|
?
|
|
|
|
|
null
|
|
|
|
|
:
|
2025-10-17 00:10:28 +02:00
|
|
|
/*Buffer.from*/(lib_plankton.json.encode(request.input))
|
2024-09-19 01:40:27 +02:00
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
const http_response : lib_plankton.http.type_response = await lib_plankton.http.call(http_request);
|
2024-09-19 10:17:43 +02:00
|
|
|
if (
|
|
|
|
|
! (
|
|
|
|
|
(http_response.status_code >= 200)
|
|
|
|
|
&&
|
|
|
|
|
(http_response.status_code < 300)
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
return Promise.reject<any>(http_response.body.toString());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
const output : any = lib_plankton.json.decode(http_response.body.toString());
|
|
|
|
|
return Promise.resolve<any>(output);
|
|
|
|
|
}
|
2024-09-19 01:40:27 +02:00
|
|
|
}
|
2025-10-17 00:10:28 +02:00
|
|
|
|
2025-10-02 17:00:17 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2025-10-17 00:10:28 +02:00
|
|
|
async function process(
|
|
|
|
|
)
|
|
|
|
|
: Promise<void>
|
2025-10-02 17:00:17 +02:00
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
if (_queue.busy)
|
|
|
|
|
{
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_queue.busy = true;
|
|
|
|
|
while (_queue.items.length > 0)
|
|
|
|
|
{
|
|
|
|
|
const entry = _queue.items.shift();
|
|
|
|
|
let successful : boolean;
|
|
|
|
|
let reason : any;
|
|
|
|
|
let result : any;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = await call_real(entry.request);
|
|
|
|
|
successful = true;
|
|
|
|
|
}
|
|
|
|
|
catch (error)
|
|
|
|
|
{
|
|
|
|
|
reason = error;
|
|
|
|
|
successful = false;
|
|
|
|
|
}
|
|
|
|
|
if (successful)
|
|
|
|
|
{
|
|
|
|
|
entry.resolve(result);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entry.reject(reason);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_queue.busy = false;
|
|
|
|
|
// process();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
async function call(
|
|
|
|
|
method : lib_plankton.http.enum_method,
|
|
|
|
|
action : string,
|
|
|
|
|
input : (null | any)
|
|
|
|
|
)
|
|
|
|
|
: Promise<any>
|
|
|
|
|
{
|
|
|
|
|
const request : type_request = {
|
|
|
|
|
"method": method,
|
|
|
|
|
"action": action,
|
|
|
|
|
"input": input,
|
|
|
|
|
};
|
|
|
|
|
const promise : Promise<any> = new Promise<any>(
|
|
|
|
|
(resolve, reject) => {
|
|
|
|
|
_queue.items.push(
|
|
|
|
|
{
|
|
|
|
|
"request": request,
|
|
|
|
|
"resolve": resolve,
|
|
|
|
|
"reject": reject,
|
|
|
|
|
}
|
2025-10-14 22:10:56 +02:00
|
|
|
);
|
|
|
|
|
}
|
2025-10-02 17:00:17 +02:00
|
|
|
);
|
2025-10-17 00:10:28 +02:00
|
|
|
process();
|
|
|
|
|
return promise;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export function status(
|
|
|
|
|
)
|
|
|
|
|
: Promise<
|
|
|
|
|
{
|
|
|
|
|
logged_in : boolean;
|
2025-10-17 00:43:10 +02:00
|
|
|
name : (null | string);
|
2025-10-17 00:10:28 +02:00
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.get,
|
|
|
|
|
"/session/status",
|
|
|
|
|
null
|
|
|
|
|
)
|
2025-10-02 17:00:17 +02:00
|
|
|
}
|
2024-09-19 01:40:27 +02:00
|
|
|
|
|
|
|
|
|
2024-09-19 13:34:24 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function session_prepare(
|
2024-09-26 19:01:05 +02:00
|
|
|
input : any
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<{kind : string; data : any;}>
|
2024-09-19 13:34:24 +02:00
|
|
|
{
|
|
|
|
|
return call(
|
2024-09-26 19:01:05 +02:00
|
|
|
lib_plankton.http.enum_method.post,
|
2024-09-19 13:34:24 +02:00
|
|
|
"/session/prepare",
|
2024-09-26 19:01:05 +02:00
|
|
|
input
|
2024-09-19 13:34:24 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export function set_session_key(
|
|
|
|
|
session_key : string
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<void>
|
2024-09-19 13:34:24 +02:00
|
|
|
{
|
|
|
|
|
return (
|
|
|
|
|
_data_chest.write("session_key", session_key)
|
|
|
|
|
.then<void>(() => Promise.resolve<void>(undefined))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-19 01:40:27 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function session_begin(
|
|
|
|
|
name : string,
|
|
|
|
|
password : string
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<void>
|
2024-09-12 00:02:12 +02:00
|
|
|
{
|
2024-09-19 10:17:43 +02:00
|
|
|
const session_key : string = await call(
|
2024-09-19 01:40:27 +02:00
|
|
|
lib_plankton.http.enum_method.post,
|
|
|
|
|
"/session/begin",
|
|
|
|
|
{
|
|
|
|
|
"name": name,
|
|
|
|
|
"password": password,
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-09-19 10:17:43 +02:00
|
|
|
await _data_chest.write("session_key", session_key);
|
2024-09-12 00:02:12 +02:00
|
|
|
return Promise.resolve<void>(undefined);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-19 01:40:27 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function session_end(
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<void>
|
2024-09-19 01:40:27 +02:00
|
|
|
{
|
2024-09-19 10:17:43 +02:00
|
|
|
await call(
|
2024-09-19 01:40:27 +02:00
|
|
|
lib_plankton.http.enum_method.delete,
|
|
|
|
|
"/session/end",
|
|
|
|
|
null
|
|
|
|
|
);
|
2024-09-19 10:17:43 +02:00
|
|
|
await _data_chest.delete("session_key");
|
|
|
|
|
return Promise.resolve<void>(undefined);
|
2024-09-19 01:40:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-10-23 11:35:57 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export function group_list(
|
|
|
|
|
)
|
|
|
|
|
: Promise<
|
|
|
|
|
Array<
|
|
|
|
|
{
|
|
|
|
|
id : int;
|
|
|
|
|
name : string;
|
|
|
|
|
label : string;
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.get,
|
|
|
|
|
"/groups",
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-30 20:20:14 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
2025-09-25 17:08:18 +02:00
|
|
|
export function user_list(
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<
|
2024-09-30 20:20:14 +02:00
|
|
|
Array<
|
|
|
|
|
{
|
|
|
|
|
id : int;
|
|
|
|
|
name : string;
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.get,
|
|
|
|
|
"/users",
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-09-25 17:08:18 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export function user_dav_conf(
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<
|
2025-09-25 17:08:18 +02:00
|
|
|
(
|
|
|
|
|
null
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
address : string;
|
|
|
|
|
username : string;
|
|
|
|
|
password : string;
|
|
|
|
|
setup_hints : Array<
|
|
|
|
|
{
|
|
|
|
|
label : string;
|
|
|
|
|
link : string;
|
|
|
|
|
remark : (null | string);
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.get,
|
|
|
|
|
"/user_dav_conf",
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export function user_dav_token(
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<void>
|
2025-09-25 17:08:18 +02:00
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.patch,
|
|
|
|
|
"/user_dav_token",
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-12 00:02:12 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function calendar_list(
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<
|
2024-09-19 10:17:43 +02:00
|
|
|
Array<
|
2024-09-12 00:02:12 +02:00
|
|
|
{
|
2024-09-26 13:38:25 +02:00
|
|
|
id : int;
|
|
|
|
|
name : string;
|
2025-10-13 13:22:53 +02:00
|
|
|
hue : float;
|
2025-10-17 00:10:28 +02:00
|
|
|
access_level : string;
|
2024-09-12 00:02:12 +02:00
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.get,
|
|
|
|
|
"/calendar",
|
|
|
|
|
null
|
2024-09-26 10:33:57 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-30 20:20:14 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function calendar_get(
|
2025-10-17 00:10:28 +02:00
|
|
|
calendar_id : int
|
|
|
|
|
)
|
|
|
|
|
: Promise<
|
|
|
|
|
{
|
|
|
|
|
name : string;
|
|
|
|
|
hue : float;
|
|
|
|
|
access : {
|
|
|
|
|
public : boolean;
|
|
|
|
|
default_level : string;
|
2025-10-23 11:35:57 +02:00
|
|
|
attributed_group : Array<
|
|
|
|
|
{
|
|
|
|
|
group_id : int;
|
|
|
|
|
level : string;
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
attributed_user : Array<
|
2024-09-30 20:20:14 +02:00
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
user_id : int;
|
|
|
|
|
level : string;
|
2024-09-30 20:20:14 +02:00
|
|
|
}
|
2025-10-23 11:35:57 +02:00
|
|
|
>;
|
2025-10-17 00:10:28 +02:00
|
|
|
};
|
|
|
|
|
resource_id : int;
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.get,
|
|
|
|
|
lib_plankton.string.coin(
|
|
|
|
|
"/calendar/{{calendar_id}}",
|
|
|
|
|
{
|
|
|
|
|
"calendar_id": calendar_id.toFixed(0),
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
null
|
2024-09-30 20:20:14 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-26 10:52:31 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function calendar_add(
|
2025-10-17 00:10:28 +02:00
|
|
|
data : {
|
|
|
|
|
name : string;
|
|
|
|
|
access : {
|
|
|
|
|
public : boolean;
|
|
|
|
|
default_level : string;
|
2025-10-23 11:35:57 +02:00
|
|
|
attributed_group : Array<
|
|
|
|
|
{
|
|
|
|
|
group_id : int;
|
|
|
|
|
level : string;
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
attributed_user : Array<
|
2025-10-17 00:10:28 +02:00
|
|
|
{
|
|
|
|
|
user_id : int;
|
|
|
|
|
level : string;
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
};
|
|
|
|
|
resource : (
|
|
|
|
|
{
|
|
|
|
|
kind : "local";
|
|
|
|
|
data : {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
kind : "ics_feed";
|
|
|
|
|
data : {
|
|
|
|
|
url : string;
|
|
|
|
|
from_fucked_up_wordpress : boolean;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
hue : float;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
: Promise<
|
|
|
|
|
int
|
2024-09-26 10:52:31 +02:00
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.post,
|
2024-09-30 20:20:14 +02:00
|
|
|
lib_plankton.string.coin(
|
|
|
|
|
"/calendar",
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
),
|
2025-10-17 00:10:28 +02:00
|
|
|
data
|
2024-09-26 10:52:31 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-30 20:20:14 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function calendar_change(
|
2025-10-17 00:10:28 +02:00
|
|
|
id : int,
|
2025-10-13 13:22:53 +02:00
|
|
|
data : {
|
|
|
|
|
name : string;
|
|
|
|
|
hue : float;
|
|
|
|
|
access : {
|
|
|
|
|
public : boolean;
|
2025-10-17 00:10:28 +02:00
|
|
|
default_level : string;
|
2025-10-23 11:35:57 +02:00
|
|
|
attributed_group : Array<
|
|
|
|
|
{
|
|
|
|
|
group_id : int;
|
|
|
|
|
level : string;
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
attributed_user : Array<
|
2025-10-17 00:10:28 +02:00
|
|
|
{
|
|
|
|
|
user_id : int;
|
|
|
|
|
level : string;
|
|
|
|
|
}
|
2025-10-13 13:22:53 +02:00
|
|
|
>;
|
|
|
|
|
};
|
|
|
|
|
}
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<
|
2024-09-30 20:20:14 +02:00
|
|
|
void
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.put,
|
|
|
|
|
lib_plankton.string.coin(
|
2025-10-17 00:10:28 +02:00
|
|
|
"/calendar/{{id}}",
|
2024-09-30 20:20:14 +02:00
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
"id": id.toFixed(0),
|
2024-09-30 20:20:14 +02:00
|
|
|
}
|
|
|
|
|
),
|
2025-10-17 00:10:28 +02:00
|
|
|
data
|
2024-09-30 20:20:14 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function calendar_remove(
|
2025-10-17 00:10:28 +02:00
|
|
|
id : int
|
|
|
|
|
)
|
|
|
|
|
: Promise<
|
2024-09-30 20:20:14 +02:00
|
|
|
void
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.delete,
|
|
|
|
|
lib_plankton.string.coin(
|
2025-10-17 00:10:28 +02:00
|
|
|
"/calendar/{{id}}",
|
2024-09-30 20:20:14 +02:00
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
"id": id.toFixed(0),
|
2024-09-30 20:20:14 +02:00
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-17 00:10:28 +02:00
|
|
|
|
2024-09-30 12:06:41 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function calendar_event_get(
|
2025-10-17 00:10:28 +02:00
|
|
|
calendar_id : int,
|
|
|
|
|
event_id : int
|
|
|
|
|
)
|
|
|
|
|
: Promise<
|
|
|
|
|
type_event_object
|
|
|
|
|
>
|
2024-09-30 12:06:41 +02:00
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.get,
|
|
|
|
|
lib_plankton.string.coin(
|
|
|
|
|
"/calendar/{{calendar_id}}/event/{{event_id}}",
|
|
|
|
|
{
|
|
|
|
|
"calendar_id": calendar_id.toFixed(0),
|
|
|
|
|
"event_id": event_id.toFixed(0),
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-26 10:33:57 +02:00
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function calendar_event_add(
|
2025-10-17 00:10:28 +02:00
|
|
|
calendar_id : int,
|
|
|
|
|
event_data : type_event_object
|
|
|
|
|
)
|
|
|
|
|
: Promise<
|
|
|
|
|
{
|
|
|
|
|
local_resource_event_id : (null | int);
|
|
|
|
|
hash : string;
|
|
|
|
|
}
|
|
|
|
|
>
|
2024-09-26 10:33:57 +02:00
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.post,
|
|
|
|
|
lib_plankton.string.coin(
|
|
|
|
|
"/calendar/{{calendar_id}}/event",
|
|
|
|
|
{
|
2024-09-26 10:52:31 +02:00
|
|
|
"calendar_id": calendar_id.toFixed(0),
|
2024-09-26 10:33:57 +02:00
|
|
|
}
|
|
|
|
|
),
|
2025-10-17 00:10:28 +02:00
|
|
|
event_data
|
2024-09-26 10:33:57 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-14 00:16:22 +02:00
|
|
|
* @todo Möglichkeit den Kalender zu ändern
|
2024-09-30 12:06:41 +02:00
|
|
|
*/
|
|
|
|
|
export async function calendar_event_change(
|
2025-10-17 00:10:28 +02:00
|
|
|
calendar_id : int,
|
|
|
|
|
event_id : int,
|
|
|
|
|
event_object : type_event_object
|
|
|
|
|
)
|
|
|
|
|
: Promise<void>
|
2024-09-30 12:06:41 +02:00
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.put,
|
|
|
|
|
lib_plankton.string.coin(
|
|
|
|
|
"/calendar/{{calendar_id}}/event/{{event_id}}",
|
|
|
|
|
{
|
|
|
|
|
"calendar_id": calendar_id.toFixed(0),
|
|
|
|
|
"event_id": event_id.toFixed(0),
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
event_object
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2024-09-26 10:33:57 +02:00
|
|
|
*/
|
|
|
|
|
export async function calendar_event_remove(
|
2025-10-17 00:10:28 +02:00
|
|
|
calendar_id : int,
|
|
|
|
|
event_id : int
|
|
|
|
|
)
|
|
|
|
|
: Promise<void>
|
2024-09-26 10:33:57 +02:00
|
|
|
{
|
|
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.delete,
|
|
|
|
|
lib_plankton.string.coin(
|
|
|
|
|
"/calendar/{{calendar_id}}/event/{{event_id}}",
|
|
|
|
|
{
|
2024-09-26 10:52:31 +02:00
|
|
|
"calendar_id": calendar_id.toFixed(0),
|
|
|
|
|
"event_id": event_id.toFixed(0),
|
2024-09-26 10:33:57 +02:00
|
|
|
}
|
|
|
|
|
),
|
2024-09-19 01:40:27 +02:00
|
|
|
null
|
2024-09-12 00:02:12 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo prevent loops
|
|
|
|
|
*/
|
2024-09-19 01:40:27 +02:00
|
|
|
export async function events(
|
2025-10-17 00:10:28 +02:00
|
|
|
from_timestamp : int,
|
|
|
|
|
to_timestamp : int,
|
2025-10-14 22:10:56 +02:00
|
|
|
{
|
|
|
|
|
"calendar_ids": calendar_ids = null,
|
|
|
|
|
}
|
|
|
|
|
:
|
|
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
calendar_ids ?: (null | Array<int>);
|
2025-10-14 22:10:56 +02:00
|
|
|
}
|
|
|
|
|
=
|
|
|
|
|
{
|
|
|
|
|
}
|
2025-10-17 00:10:28 +02:00
|
|
|
)
|
|
|
|
|
: Promise<
|
2024-09-12 00:02:12 +02:00
|
|
|
Array<
|
|
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
hash : string;
|
|
|
|
|
calendar_id : int;
|
2024-09-12 00:02:12 +02:00
|
|
|
calendar_name : string;
|
2025-10-13 13:22:53 +02:00
|
|
|
hue : float;
|
2025-10-17 00:10:28 +02:00
|
|
|
access_level : string;
|
|
|
|
|
event_id : (null | int);
|
|
|
|
|
event_object : type_event_object;
|
2024-09-12 00:02:12 +02:00
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
{
|
2025-10-17 00:10:28 +02:00
|
|
|
return call(
|
|
|
|
|
lib_plankton.http.enum_method.get,
|
|
|
|
|
"/events",
|
|
|
|
|
Object.assign(
|
|
|
|
|
{
|
|
|
|
|
"from": from_timestamp,
|
|
|
|
|
"to": to_timestamp,
|
|
|
|
|
},
|
|
|
|
|
(
|
|
|
|
|
(calendar_ids === null)
|
|
|
|
|
?
|
|
|
|
|
{}
|
|
|
|
|
:
|
|
|
|
|
{"calendar_ids": calendar_ids.join(",")}
|
2024-09-19 01:40:27 +02:00
|
|
|
)
|
|
|
|
|
)
|
2024-09-12 00:02:12 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|