This commit is contained in:
Fenris Wolf 2024-10-30 07:20:13 +01:00
parent 1127130b00
commit 9d1fd0b55f
28 changed files with 2020 additions and 109 deletions

View file

@ -3348,18 +3348,22 @@ declare namespace lib_plankton.http {
patch = "patch" patch = "patch"
} }
/** /**
* @author fenris <frass@greenscale.de> * @author roydfalk <roydfalk@folksprak.org>
*/ */
type type_request = { type type_request_generic<type_method> = {
scheme: ("http" | "https"); scheme: ("http" | "https");
host: (null | string); host: (null | string);
path: string; path: string;
version: string; version: string;
method: enum_method; method: type_method;
query: (null | string); query: (null | string);
headers: Record<string, string>; headers: Record<string, string>;
body: (null | Buffer); body: (null | Buffer);
}; };
/**
* @author fenris <frass@greenscale.de>
*/
type type_request = type_request_generic<enum_method>;
/** /**
* @author fenris <frass@greenscale.de> * @author fenris <frass@greenscale.de>
*/ */
@ -3375,10 +3379,22 @@ declare namespace lib_plankton.http {
* @author fenris <frass@greenscale.de> * @author fenris <frass@greenscale.de>
*/ */
function encode_method(method: enum_method): string; function encode_method(method: enum_method): string;
/**
* @author fenris <frass@greenscale.de>
*/
function decode_method(method_raw: string): enum_method;
/** /**
* @author fenris <frass@greenscale.de> * @author fenris <frass@greenscale.de>
*/ */
function encode_request(request: type_request): string; function encode_request(request: type_request): string;
/**
* @author fenris <frass@greenscale.de>
*/
function has_body(method: enum_method): boolean;
/**
* @author fenris <frass@greenscale.de>
*/
function decode_request_generic<type_method, type_request_actual>(decode_method_: ((method_raw: string) => type_method), has_body: ((method: type_method) => boolean), request_raw: string): type_request_generic<type_method>;
/** /**
* @author fenris <frass@greenscale.de> * @author fenris <frass@greenscale.de>
*/ */
@ -3442,6 +3458,260 @@ declare namespace lib_plankton.http {
decode(x: string): type_response; decode(x: string): type_response;
} }
} }
/**
* @author fenris
*/
declare namespace lib_plankton.xml {
/**
* @author fenris
*/
abstract class class_node {
/**
* @author fenris
*/
abstract compile(depth?: int): string;
}
/**
* @author fenris
*/
class class_node_text extends class_node {
/**
* @author fenris
*/
protected content: string;
/**
* @author fenris
*/
constructor(content: string);
/**
* @author fenris
*/
compile(depth?: int): string;
}
/**
* @author fenris
*/
class class_node_comment extends class_node {
/**
* @author fenris
*/
protected content: string;
/**
* @author fenris
*/
constructor(content: string);
/**
* @author fenris
*/
compile(depth?: int): string;
}
/**
* @author fenris
*/
class class_node_complex extends class_node {
/**
* @author fenris
*/
protected name: string;
/**
* @author fenris
*/
protected attributes: {
[key: string]: string;
};
/**
* @author fenris
*/
protected children: Array<class_node>;
/**
* @author fenris
*/
constructor(name: string, attributes?: {
[key: string]: string;
}, children?: any[]);
/**
* @author fenris
*/
compile(depth?: int): string;
}
}
declare namespace lib_plankton.webdav {
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
enum enum_method {
options = "options",
head = "head",
get = "get",
delete = "delete",
post = "post",
put = "put",
patch = "patch",
propfind = "propfind",
proppatch = "proppatch",
mkcol = "mkcol",
copy = "copy",
move = "move",
lock = "lock",
unlock = "unlock"
}
/**
* @author roydfalk <roydfalk@folksprak.org>
* @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_href
*/
type type_data_href = string;
/**
* @author roydfalk <roydfalk@folksprak.org>
* @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_status
*/
type type_data_status = string;
/**
* @author roydfalk <roydfalk@folksprak.org>
* @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_prop
*/
type type_data_prop = {
name: string;
value: (null | string);
};
/**
* @author roydfalk <roydfalk@folksprak.org>
* @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_propstat
*/
type type_data_propstat = {
prop: Array<type_data_prop>;
status: string;
description: (null | string);
};
/**
* @author roydfalk <roydfalk@folksprak.org>
* @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_response
*/
type type_data_response = {
href: type_data_href;
body: ({
hrefs: Array<type_data_href>;
status: string;
} | {
propstats: Array<type_data_propstat>;
});
description: (null | string);
};
/**
* @author roydfalk <roydfalk@folksprak.org>
* @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_multistatus
*/
type type_data_multistatus = {
responses: Array<type_data_response>;
description: (null | string);
};
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
type type_request = lib_plankton.http.type_request_generic<enum_method>;
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
type type_response = {
version: (null | string);
status_code: int;
headers: Record<string, string>;
body: Buffer;
};
}
declare namespace lib_plankton.webdav {
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
function is_special_method(method: enum_method): boolean;
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
function encode_method(method: enum_method): string;
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
function decode_method(method_raw: string): enum_method;
/**
*/
function data_multistatus_encode(data_multistatus: type_data_multistatus): string;
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
function has_body(method: enum_method): boolean;
/**
* @author fenris <frass@greenscale.de>
*/
function decode_request(request_raw: string): type_request;
/**
* @author fenris <frass@greenscale.de>
* @todo try to base on lib_plankton.http.encode_response
*/
function encode_response(response: type_response): string;
}
declare namespace lib_plankton.caldav {
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
enum enum_method {
options = "options",
head = "head",
get = "get",
delete = "delete",
post = "post",
put = "put",
patch = "patch",
propfind = "propfind",
proppatch = "proppatch",
mkcol = "mkcol",
copy = "copy",
move = "move",
lock = "lock",
unlock = "unlock",
report = "report",
mkcalendar = "mkcalendar",
acl = "acl"
}
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
type type_request = lib_plankton.http.type_request_generic<enum_method>;
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
type type_response = {
version: (null | string);
status_code: int;
headers: Record<string, string>;
body: Buffer;
};
}
declare namespace lib_plankton.caldav {
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
function is_special_method(method: enum_method): boolean;
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
function encode_method(method: enum_method): string;
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
function decode_method(method_raw: string): enum_method;
/**
* @author roydfalk <roydfalk@folksprak.org>
*/
function has_body(method: enum_method): boolean;
/**
* @author fenris <frass@greenscale.de>
*/
function decode_request(request_raw: string): type_request;
/**
* @author fenris <frass@greenscale.de>
* @todo try to base on lib_plankton.http.encode_response
*/
function encode_response(response: type_response): string;
}
declare namespace lib_plankton.markdown { declare namespace lib_plankton.markdown {
/** /**
* @author fenris * @author fenris
@ -3586,7 +3856,7 @@ declare namespace lib_plankton.api {
generate_documentation(): string; generate_documentation(): string;
} }
} }
declare namespace lib_plankton.rest { declare namespace lib_plankton.rest_base {
/** /**
*/ */
type type_oas_schema = ({} | { type type_oas_schema = ({} | {
@ -3689,7 +3959,110 @@ declare namespace lib_plankton.rest {
}); });
}; };
} }
declare namespace lib_plankton.rest { declare namespace lib_plankton.rest_base {
/**
*/
function make<type_http_method>(encode_http_method: ((http_method: type_http_method) => string), options?: {
title?: (null | string);
versioning_method?: ("none" | "path" | "header" | "query");
versioning_header_name?: (null | string);
versioning_query_key?: (null | string);
header_parameters?: Array<{
name: string;
description: (null | string);
required: boolean;
}>;
set_access_control_headers?: boolean;
authentication?: ({
kind: "none";
parameters: {};
} | {
kind: "key_header";
parameters: {
name: string;
};
});
actions?: Array<{
http_method: type_http_method;
path: string;
options: {
active?: ((version: string) => boolean);
restriction?: (null | type_restriction<any>);
execution?: type_execution<any, any>;
title?: (null | string);
description?: (null | string);
query_parameters?: ((version: string) => Array<{
name: string;
description: (null | string);
required: boolean;
}>);
input_schema?: ((version: string) => type_oas_schema);
output_schema?: ((version: string) => type_oas_schema);
request_body_mimetype?: string;
request_body_decode?: ((http_request_body: Buffer, http_request_header_content_type: (null | string)) => any);
response_body_mimetype?: string;
response_body_encode?: ((output: any) => Buffer);
};
}>;
}): type_rest;
/**
*/
function register<type_http_method, type_input, type_output>(encode_http_method: ((http_method: type_http_method) => string), rest: type_rest, http_method: type_http_method, path: string, options: {
active?: ((version: string) => boolean);
restriction?: (null | type_restriction<type_input>);
execution?: type_execution<type_input, type_output>;
title?: (null | string);
description?: (null | string);
query_parameters?: ((version: string) => Array<{
name: string;
description: (null | string);
required: boolean;
}>);
input_schema?: ((version: (null | string)) => type_oas_schema);
output_schema?: ((version: (null | string)) => type_oas_schema);
request_body_mimetype?: string;
request_body_decode?: ((http_request_body: Buffer, http_request_header_content_type: (null | string)) => any);
response_body_mimetype?: string;
response_body_encode?: ((output: any) => Buffer);
}): void;
/**
* @todo check request body mimetype?
* @todo check query paramater validity
*/
function call<type_http_method, type_http_request extends lib_plankton.http.type_request_generic<type_http_method>>(encode_http_method: ((http_method: type_http_method) => string), rest: type_rest, http_request: type_http_request, options?: {
checklevel_restriction?: lib_plankton.api.enum_checklevel;
checklevel_input?: lib_plankton.api.enum_checklevel;
checklevel_output?: lib_plankton.api.enum_checklevel;
}): Promise<lib_plankton.http.type_response>;
/**
* @see https://swagger.io/specification/#openrest-object
*/
function to_oas<type_method>(http_request_method_to_oas: ((http_request_method: type_method) => string), rest: type_rest, options?: {
version?: (null | string);
servers?: Array<string>;
}): any;
}
declare namespace lib_plankton.rest_http {
/**
*/
type type_oas_schema = lib_plankton.rest_base.type_oas_schema;
/**
*/
type type_execution<type_input, type_output> = lib_plankton.rest_base.type_execution<type_input, type_output>;
/**
*/
type type_restriction<type_input> = lib_plankton.rest_base.type_restriction<type_input>;
/**
*/
type type_operation<type_input, type_output> = lib_plankton.rest_base.type_operation<type_input, type_output>;
/**
*/
type type_routenode = lib_plankton.rest_base.type_routenode;
/**
*/
type type_rest = lib_plankton.rest_base.type_rest;
}
declare namespace lib_plankton.rest_http {
/** /**
*/ */
function make(options?: { function make(options?: {
@ -3772,6 +4145,212 @@ declare namespace lib_plankton.rest {
servers?: Array<string>; servers?: Array<string>;
}): any; }): any;
} }
declare namespace lib_plankton.rest_webdav {
/**
*/
type type_oas_schema = lib_plankton.rest_base.type_oas_schema;
/**
*/
type type_execution<type_input, type_output> = lib_plankton.rest_base.type_execution<type_input, type_output>;
/**
*/
type type_restriction<type_input> = lib_plankton.rest_base.type_restriction<type_input>;
/**
*/
type type_operation<type_input, type_output> = lib_plankton.rest_base.type_operation<type_input, type_output>;
/**
*/
type type_routenode = lib_plankton.rest_base.type_routenode;
/**
*/
type type_rest = lib_plankton.rest_base.type_rest;
}
declare namespace lib_plankton.rest_webdav {
/**
*/
function make(options?: {
title?: (null | string);
versioning_method?: ("none" | "path" | "header" | "query");
versioning_header_name?: (null | string);
versioning_query_key?: (null | string);
header_parameters?: Array<{
name: string;
description: (null | string);
required: boolean;
}>;
set_access_control_headers?: boolean;
authentication?: ({
kind: "none";
parameters: {};
} | {
kind: "key_header";
parameters: {
name: string;
};
});
actions?: Array<{
http_method: lib_plankton.webdav.enum_method;
path: string;
options: {
active?: ((version: string) => boolean);
restriction?: (null | type_restriction<any>);
execution?: type_execution<any, any>;
title?: (null | string);
description?: (null | string);
query_parameters?: ((version: string) => Array<{
name: string;
description: (null | string);
required: boolean;
}>);
input_schema?: ((version: string) => type_oas_schema);
output_schema?: ((version: string) => type_oas_schema);
request_body_mimetype?: string;
request_body_decode?: ((http_request_body: Buffer, http_request_header_content_type: (null | string)) => any);
response_body_mimetype?: string;
response_body_encode?: ((output: any) => Buffer);
};
}>;
}): type_rest;
/**
*/
function register<type_input, type_output>(rest: type_rest, http_method: lib_plankton.webdav.enum_method, path: string, options: {
active?: ((version: string) => boolean);
restriction?: (null | type_restriction<type_input>);
execution?: type_execution<type_input, type_output>;
title?: (null | string);
description?: (null | string);
query_parameters?: ((version: string) => Array<{
name: string;
description: (null | string);
required: boolean;
}>);
input_schema?: ((version: (null | string)) => type_oas_schema);
output_schema?: ((version: (null | string)) => type_oas_schema);
request_body_mimetype?: string;
request_body_decode?: ((http_request_body: Buffer, http_request_header_content_type: (null | string)) => any);
response_body_mimetype?: string;
response_body_encode?: ((output: any) => Buffer);
}): void;
/**
* @todo check request body mimetype?
* @todo check query paramater validity
*/
function call(rest: type_rest, http_request: lib_plankton.webdav.type_request, options?: {
checklevel_restriction?: lib_plankton.api.enum_checklevel;
checklevel_input?: lib_plankton.api.enum_checklevel;
checklevel_output?: lib_plankton.api.enum_checklevel;
}): Promise<lib_plankton.webdav.type_response>;
/**
* @see https://swagger.io/specification/#openrest-object
*/
function to_oas(rest: type_rest, options?: {
version?: (null | string);
servers?: Array<string>;
}): any;
}
declare namespace lib_plankton.rest_caldav {
/**
*/
type type_oas_schema = lib_plankton.rest_base.type_oas_schema;
/**
*/
type type_execution<type_input, type_output> = lib_plankton.rest_base.type_execution<type_input, type_output>;
/**
*/
type type_restriction<type_input> = lib_plankton.rest_base.type_restriction<type_input>;
/**
*/
type type_operation<type_input, type_output> = lib_plankton.rest_base.type_operation<type_input, type_output>;
/**
*/
type type_routenode = lib_plankton.rest_base.type_routenode;
/**
*/
type type_rest = lib_plankton.rest_base.type_rest;
}
declare namespace lib_plankton.rest_caldav {
/**
*/
function make(options?: {
title?: (null | string);
versioning_method?: ("none" | "path" | "header" | "query");
versioning_header_name?: (null | string);
versioning_query_key?: (null | string);
header_parameters?: Array<{
name: string;
description: (null | string);
required: boolean;
}>;
set_access_control_headers?: boolean;
authentication?: ({
kind: "none";
parameters: {};
} | {
kind: "key_header";
parameters: {
name: string;
};
});
actions?: Array<{
http_method: lib_plankton.caldav.enum_method;
path: string;
options: {
active?: ((version: string) => boolean);
restriction?: (null | type_restriction<any>);
execution?: type_execution<any, any>;
title?: (null | string);
description?: (null | string);
query_parameters?: ((version: string) => Array<{
name: string;
description: (null | string);
required: boolean;
}>);
input_schema?: ((version: string) => type_oas_schema);
output_schema?: ((version: string) => type_oas_schema);
request_body_mimetype?: string;
request_body_decode?: ((http_request_body: Buffer, http_request_header_content_type: (null | string)) => any);
response_body_mimetype?: string;
response_body_encode?: ((output: any) => Buffer);
};
}>;
}): type_rest;
/**
*/
function register<type_input, type_output>(rest: type_rest, http_method: lib_plankton.caldav.enum_method, path: string, options: {
active?: ((version: string) => boolean);
restriction?: (null | type_restriction<type_input>);
execution?: type_execution<type_input, type_output>;
title?: (null | string);
description?: (null | string);
query_parameters?: ((version: string) => Array<{
name: string;
description: (null | string);
required: boolean;
}>);
input_schema?: ((version: (null | string)) => type_oas_schema);
output_schema?: ((version: (null | string)) => type_oas_schema);
request_body_mimetype?: string;
request_body_decode?: ((http_request_body: Buffer, http_request_header_content_type: (null | string)) => any);
response_body_mimetype?: string;
response_body_encode?: ((output: any) => Buffer);
}): void;
/**
* @todo check request body mimetype?
* @todo check query paramater validity
*/
function call(rest: type_rest, http_request: lib_plankton.caldav.type_request, options?: {
checklevel_restriction?: lib_plankton.api.enum_checklevel;
checklevel_input?: lib_plankton.api.enum_checklevel;
checklevel_output?: lib_plankton.api.enum_checklevel;
}): Promise<lib_plankton.caldav.type_response>;
/**
* @see https://swagger.io/specification/#openrest-object
*/
function to_oas(rest: type_rest, options?: {
version?: (null | string);
servers?: Array<string>;
}): any;
}
declare namespace lib_plankton.server { declare namespace lib_plankton.server {
/** /**
* @author fenris * @author fenris
@ -4359,3 +4938,9 @@ declare namespace lib_plankton.auth.oidc {
}>; }>;
export {}; export {};
} }
declare namespace lib_plankton.sha256 {
/**
* @author fenris
*/
function get(value: string, secret?: string): string;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,166 @@
namespace _zeitbild.api
{
/**
*/
export function register_caldav_get(
rest_subject : lib_plankton.rest_caldav.type_rest
) : void
{
register<
null,
(
lib_plankton.ical.type_vcalendar
|
string
)
>(
rest_subject,
lib_plankton.caldav.enum_method.report,
"/caldav",
{
"description": "trägt Veranstaltungen aus verschiedenen Kalendern zusammen im ical-Format",
"query_parameters": () => ([
{
"name": "from",
"required": false,
"description": "UNIX timestamp",
},
{
"name": "to",
"required": false,
"description": "UNIX timestamp",
},
{
"name": "calendar_ids",
"required": false,
"description": "comma separated",
},
{
"name": "auth",
"required": true,
"description": "",
},
]),
"output_schema": () => ({
"nullable": false,
"type": "string",
}),
"response_body_mimetype": "text/calendar",
"response_body_encode": (output) => Buffer.from(
(typeof(output) === "string")
?
output
:
lib_plankton.ical.ics_encode(output)
),
"restriction": restriction_none,
"execution": async (stuff) => {
const user_id : (null | _zeitbild.type_user_id) = await (
session_from_stuff(stuff)
.then(
(session : {key : string; value : lib_plankton.session.type_session;}) => (
_zeitbild.service.user.identify(session.value.name)
.catch(x => Promise.resolve(null))
)
)
.catch(x => Promise.resolve(null))
);
const from : lib_plankton.pit.type_pit = (
("from" in stuff.query_parameters)
?
parseInt(stuff.query_parameters["from"])
:
lib_plankton.pit.shift_week(
lib_plankton.pit.now(),
-2
)
);
const to : lib_plankton.pit.type_pit = (
("to" in stuff.query_parameters)
?
parseInt(stuff.query_parameters["to"])
:
lib_plankton.pit.shift_week(
lib_plankton.pit.now(),
+6
)
);
const calendar_ids_wanted : (null | Array<_zeitbild.type_calendar_id>) = (
(
("calendar_ids" in stuff.query_parameters)
&&
(stuff.query_parameters["calendar_ids"] !== null)
)
?
lib_plankton.call.convey(
stuff.query_parameters["calendar_ids"],
[
(x : string) => x.split(","),
(x : Array<string>) => x.map(parseInt),
(x : Array<int>) => x.filter(y => (! isNaN(y)))
]
)
:
null
);
const auth_hash_shall : string = lib_plankton.sha256.get(
(stuff.query_parameters["calendar_ids"] ?? ""),
_zeitbild.conf.get()["misc"]["auth_salt"]
);
const auth_hash_is : string = stuff.query_parameters["auth"];
/**
* @todo remove
*/
lib_plankton.log.info(
"auth_hashes",
{
"shall": auth_hash_shall,
"is": auth_hash_is,
}
);
if (! (auth_hash_is === auth_hash_shall)) {
return Promise.resolve(
{
"status_code": 403,
"data": "not authorized",
}
);
}
else {
return (
_zeitbild.service.calendar.gather_events(
calendar_ids_wanted,
from,
to,
user_id
)
.then(
(data) => Promise.resolve(
{
"status_code": 200,
"data": _zeitbild.helpers.ical_vcalendar_from_own_event_list(
data.map(entry => entry.event_object)
)
}
)
)
.catch(
(reason) => Promise.resolve(
{
"status_code": 403,
"data": String(reason),
}
)
)
);
}
}
}
);
}
}

View file

@ -0,0 +1,100 @@
namespace _zeitbild.api
{
/**
*/
export function register_caldav_probe(
rest_subject : lib_plankton.rest_caldav.type_rest
) : void
{
register<
any,
any
>(
rest_subject,
lib_plankton.caldav.enum_method.propfind,
"/caldav",
{
"query_parameters": () => ([
{
"name": "from",
"required": false,
"description": "UNIX timestamp",
},
{
"name": "to",
"required": false,
"description": "UNIX timestamp",
},
{
"name": "calendar_ids",
"required": false,
"description": "comma separated",
},
{
"name": "auth",
"required": true,
"description": "",
},
]),
"output_schema": () => ({
"nullable": false,
"type": "string",
}),
"response_body_mimetype": "application/xml",
"response_body_encode": output => Buffer.from(output),
"restriction": restriction_none,
/**
* @todo examine body
*/
"execution": async (stuff) => {
return Promise.resolve(
{
"status_code": 207,
"data": (
/*"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
+*/
lib_plankton.webdav.data_multistatus_encode(
{
"responses": [
{
"href": "/caldav/events",
"body": {
"propstats": [
{
"prop": [
{"name": "d:displayname", "value": "default"},
// {"name": "cs:getctag", "value": "47"}, // TODO correct value
// {"name": "current-user-privilege-set", "value": ""},
/*
"uid",
"dtstamp",
"dtstart",
"dtend",
"summary",
"description",
"url",
"location",
*/
],
"status": "HTTP/2.0 200 OK",
"description": null,
},
]
},
"description": null,
}
],
"description": null,
}
)
),
}
);
}
}
);
}
}

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_calendar_add( export function register_calendar_add(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_calendar_change( export function register_calendar_change(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_calendar_event_add( export function register_calendar_event_add(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_calendar_event_change( export function register_calendar_event_change(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_calendar_event_get( export function register_calendar_event_get(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_calendar_event_remove( export function register_calendar_event_remove(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_calendar_get( export function register_calendar_get(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_calendar_list( export function register_calendar_list(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_calendar_remove( export function register_calendar_remove(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_events( export function register_events(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -4,8 +4,8 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_export_caldav( export function register_export_ical(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<
@ -18,9 +18,9 @@ namespace _zeitbild.api
>( >(
rest_subject, rest_subject,
lib_plankton.http.enum_method.get, lib_plankton.http.enum_method.get,
"/export/caldav", "/export/ical",
{ {
"description": "trägt Veranstaltungen aus verschiedenen Kalendern zusammen im CalDAV-Format", "description": "trägt Veranstaltungen aus verschiedenen Kalendern zusammen im ical-Format",
"query_parameters": () => ([ "query_parameters": () => ([
{ {
"name": "from", "name": "from",

View file

@ -5,10 +5,10 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_meta_ping( export function register_meta_ping(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
lib_plankton.rest.register< lib_plankton.rest_caldav.register<
null, null,
string string
> >

View file

@ -5,10 +5,10 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_meta_spec( export function register_meta_spec(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
lib_plankton.rest.register< lib_plankton.rest_caldav.register<
null, null,
any any
> >
@ -27,7 +27,7 @@ namespace _zeitbild.api
"execution": () => { "execution": () => {
return Promise.resolve({ return Promise.resolve({
"status_code": 200, "status_code": 200,
"data": lib_plankton.rest.to_oas(rest_subject), "data": lib_plankton.rest_caldav.to_oas(rest_subject),
}); });
}, },
} }

View file

@ -5,10 +5,10 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_session_begin( export function register_session_begin(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
lib_plankton.rest.register< lib_plankton.rest_caldav.register<
{ {
name : string; name : string;
password : string; password : string;

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_session_end( export function register_session_end(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register<null, null>( register<null, null>(

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_session_oidc( export function register_session_oidc(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -5,10 +5,10 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_session_prepare( export function register_session_prepare(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
lib_plankton.rest.register< lib_plankton.rest_caldav.register<
any, any,
{ {
kind : string; kind : string;

View file

@ -5,7 +5,7 @@ namespace _zeitbild.api
/** /**
*/ */
export function register_users( export function register_users(
rest_subject : lib_plankton.rest.type_rest rest_subject : lib_plankton.rest_caldav.type_rest
) : void ) : void
{ {
register< register<

View file

@ -27,7 +27,7 @@ namespace _zeitbild.api
/** /**
*/ */
export const restriction_logged_in : lib_plankton.rest.type_restriction<any> = ( export const restriction_logged_in : lib_plankton.rest_caldav.type_restriction<any> = (
(stuff) => ( (stuff) => (
session_from_stuff(stuff) session_from_stuff(stuff)
.then(() => Promise.resolve<boolean>(true)) .then(() => Promise.resolve<boolean>(true))
@ -38,7 +38,7 @@ namespace _zeitbild.api
/** /**
*/ */
export const restriction_none : lib_plankton.rest.type_restriction<any> = ( export const restriction_none : lib_plankton.rest_caldav.type_restriction<any> = (
(stuff) => Promise.resolve<boolean>(true) (stuff) => Promise.resolve<boolean>(true)
); );
@ -46,13 +46,13 @@ namespace _zeitbild.api
/** /**
*/ */
export function register<type_input, type_output>( export function register<type_input, type_output>(
rest_subject : lib_plankton.rest.type_rest, rest_subject : lib_plankton.rest_caldav.type_rest,
http_method : lib_plankton.http.enum_method, http_method : lib_plankton.caldav.enum_method,
path : string, path : string,
options : { options : {
active ?: ((version : string) => boolean); active ?: ((version : string) => boolean);
restriction ?: (null | lib_plankton.rest.type_restriction<type_input>); restriction ?: (null | lib_plankton.rest_caldav.type_restriction<type_input>);
execution ?: lib_plankton.rest.type_execution<type_input, type_output>; execution ?: lib_plankton.rest_caldav.type_execution<type_input, type_output>;
title ?: (null | string); title ?: (null | string);
description ?: (null | string); description ?: (null | string);
query_parameters ?: ((version : (null | string)) => Array< query_parameters ?: ((version : (null | string)) => Array<
@ -62,8 +62,8 @@ namespace _zeitbild.api
required : boolean; required : boolean;
} }
>); >);
input_schema ?: ((version: (null | string)) => lib_plankton.rest.type_oas_schema); input_schema ?: ((version: (null | string)) => lib_plankton.rest_caldav.type_oas_schema);
output_schema ?: ((version: (null | string)) => lib_plankton.rest.type_oas_schema); output_schema ?: ((version: (null | string)) => lib_plankton.rest_caldav.type_oas_schema);
request_body_mimetype ?: string; request_body_mimetype ?: string;
request_body_decode ?: ((http_request_body : Buffer, http_request_header_content_type : (null | string)) => any); request_body_decode ?: ((http_request_body : Buffer, http_request_header_content_type : (null | string)) => any);
response_body_mimetype ?: string; response_body_mimetype ?: string;
@ -76,7 +76,7 @@ namespace _zeitbild.api
}, },
options options
); );
lib_plankton.rest.register<type_input, type_output>( lib_plankton.rest_caldav.register<type_input, type_output>(
rest_subject, rest_subject,
http_method, http_method,
(_zeitbild.conf.get().server.path_base + path), (_zeitbild.conf.get().server.path_base + path),

View file

@ -5,9 +5,9 @@ namespace _zeitbild.api
/** /**
*/ */
export function make( export function make(
) : lib_plankton.rest.type_rest ) : lib_plankton.rest_caldav.type_rest
{ {
const rest_subject : lib_plankton.rest.type_rest = lib_plankton.rest.make( const rest_subject : lib_plankton.rest_caldav.type_rest = lib_plankton.rest_caldav.make(
{ {
"title": "zeitbild", "title": "zeitbild",
"versioning_method": "header", "versioning_method": "header",
@ -48,7 +48,12 @@ namespace _zeitbild.api
} }
// export // export
{ {
_zeitbild.api.register_export_caldav(rest_subject); _zeitbild.api.register_export_ical(rest_subject);
}
// caldav
{
_zeitbild.api.register_caldav_probe(rest_subject);
_zeitbild.api.register_caldav_get(rest_subject);
} }
// misc // misc
{ {

View file

@ -8,7 +8,7 @@ namespace _zeitbild.api
options : { options : {
nullable ?: boolean; nullable ?: boolean;
} = {} } = {}
) : lib_plankton.rest.type_oas_schema ) : lib_plankton.rest_caldav.type_oas_schema
{ {
options = Object.assign( options = Object.assign(
{ {
@ -49,7 +49,7 @@ namespace _zeitbild.api
options : { options : {
nullable ?: boolean; nullable ?: boolean;
} = {} } = {}
) : lib_plankton.rest.type_oas_schema ) : lib_plankton.rest_caldav.type_oas_schema
{ {
options = Object.assign( options = Object.assign(
{ {
@ -90,7 +90,7 @@ namespace _zeitbild.api
options : { options : {
nullable ?: boolean; nullable ?: boolean;
} = {} } = {}
) : lib_plankton.rest.type_oas_schema ) : lib_plankton.rest_caldav.type_oas_schema
{ {
options = Object.assign( options = Object.assign(
{ {

View file

@ -320,11 +320,11 @@ async function main(
} }
case "api-doc": { case "api-doc": {
lib_plankton.log.conf_push([]); lib_plankton.log.conf_push([]);
const rest_subject : lib_plankton.rest.type_rest = _zeitbild.api.make(); const rest_subject : lib_plankton.rest_caldav.type_rest = _zeitbild.api.make();
lib_plankton.log.conf_pop(); lib_plankton.log.conf_pop();
process.stdout.write( process.stdout.write(
JSON.stringify( JSON.stringify(
lib_plankton.rest.to_oas(rest_subject), lib_plankton.rest_caldav.to_oas(rest_subject),
undefined, undefined,
"\t" "\t"
) )
@ -376,11 +376,11 @@ async function main(
await _zeitbild.auth.init(); await _zeitbild.auth.init();
const rest_subject : lib_plankton.rest.type_rest = _zeitbild.api.make(); const rest_subject : lib_plankton.rest_caldav.type_rest = _zeitbild.api.make();
const server : lib_plankton.server.type_subject = lib_plankton.server.make( const server : lib_plankton.server.type_subject = lib_plankton.server.make(
async (input, metadata) => { async (input, metadata) => {
const http_request : lib_plankton.http.type_request = lib_plankton.http.decode_request(input.toString()); const http_request : lib_plankton.caldav.type_request = lib_plankton.caldav.decode_request(input.toString());
const http_response : lib_plankton.http.type_response = await lib_plankton.rest.call( const http_response : lib_plankton.caldav.type_response = await lib_plankton.rest_caldav.call(
rest_subject, rest_subject,
http_request, http_request,
{ {
@ -389,7 +389,7 @@ async function main(
// "checklevel_output": lib_plankton.api.enum_checklevel.soft, // "checklevel_output": lib_plankton.api.enum_checklevel.soft,
} }
); );
const output : string = lib_plankton.http.encode_response(http_response); const output : string = lib_plankton.caldav.encode_response(http_response);
return output; return output;
}, },
{ {

View file

@ -75,7 +75,9 @@ ${dir_temp}/zeitbild-unlinked.js: \
${dir_source}/api/actions/calendar_event_change.ts \ ${dir_source}/api/actions/calendar_event_change.ts \
${dir_source}/api/actions/calendar_event_remove.ts \ ${dir_source}/api/actions/calendar_event_remove.ts \
${dir_source}/api/actions/events.ts \ ${dir_source}/api/actions/events.ts \
${dir_source}/api/actions/export_caldav.ts \ ${dir_source}/api/actions/export_ical.ts \
${dir_source}/api/actions/caldav_probe.ts \
${dir_source}/api/actions/caldav_get.ts \
${dir_source}/api/functions.ts \ ${dir_source}/api/functions.ts \
${dir_source}/main.ts ${dir_source}/main.ts
@ ${cmd_log} "compile …" @ ${cmd_log} "compile …"

View file

@ -21,15 +21,20 @@ modules="${modules} order"
modules="${modules} ical" modules="${modules} ical"
modules="${modules} url" modules="${modules} url"
modules="${modules} http" modules="${modules} http"
modules="${modules} webdav"
modules="${modules} caldav"
modules="${modules} api" modules="${modules} api"
modules="${modules} rest" modules="${modules} rest"
modules="${modules} rest" modules="${modules} rest_http"
modules="${modules} rest_webdav"
modules="${modules} rest_caldav"
modules="${modules} server" modules="${modules} server"
modules="${modules} args" modules="${modules} args"
modules="${modules} bcrypt" modules="${modules} bcrypt"
modules="${modules} map" modules="${modules} map"
modules="${modules} pit" modules="${modules} pit"
modules="${modules} auth" modules="${modules} auth"
modules="${modules} sha256"
## exec ## exec