[mod]
This commit is contained in:
parent
944043d873
commit
e552560887
5
lib/plankton/plankton.d.ts
vendored
5
lib/plankton/plankton.d.ts
vendored
|
|
@ -229,9 +229,10 @@ declare namespace lib_plankton.base {
|
|||
function object_merge(core: Record<string, any>, mantle: Record<string, any>): Record<string, any>;
|
||||
/**
|
||||
*/
|
||||
function buffer_show(buffer: Buffer, { "block_size": option_block_size, "break_char": option_break_char, }?: {
|
||||
function buffer_show(buffer: Buffer, { "block_size": option_block_size, "break_char": option_break_char, "render_readable_characters": render_readable_characters, }?: {
|
||||
block_size?: int;
|
||||
break_char?: string;
|
||||
render_readable_characters?: boolean;
|
||||
}): string;
|
||||
}
|
||||
declare module lib_plankton.pod {
|
||||
|
|
@ -4128,7 +4129,7 @@ declare namespace lib_plankton.server {
|
|||
};
|
||||
/**
|
||||
*/
|
||||
function make(handle: ((input: string, metadata?: type_metadata) => Promise<string>), options?: {
|
||||
function make(handle: ((input: string, metadata?: type_metadata) => Promise<string>), { "host": host, "port": port, "threshold": threshold, }?: {
|
||||
host?: string;
|
||||
port?: int;
|
||||
threshold?: (null | float);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,14 @@
|
|||
{
|
||||
"version": 1,
|
||||
"log": [
|
||||
{
|
||||
"kind": "file",
|
||||
"data": {
|
||||
"path": "/tmp/zeitbild/log.jsonl",
|
||||
"threshold": "info",
|
||||
"format": "jsonl_structured"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "stdout",
|
||||
"data": {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
{
|
||||
"id": 1,
|
||||
"name": "LV Lampukistan",
|
||||
"hue": 0.0000,
|
||||
"access": {
|
||||
"public": true,
|
||||
"default_level": "view",
|
||||
|
|
@ -120,6 +121,7 @@
|
|||
{
|
||||
"id": 2,
|
||||
"name": "KV Zepettel-Region",
|
||||
"hue": 0.3333,
|
||||
"access": {
|
||||
"public": false,
|
||||
"default_level": "view",
|
||||
|
|
@ -191,6 +193,7 @@
|
|||
{
|
||||
"id": 3,
|
||||
"name": "OV Kawanda",
|
||||
"hue": 0.6667,
|
||||
"access": {
|
||||
"public": false,
|
||||
"default_level": "view",
|
||||
|
|
@ -235,6 +238,7 @@
|
|||
{
|
||||
"id": 4,
|
||||
"name": "KV Zepettel-Region | intern",
|
||||
"hue": 0.8333,
|
||||
"access": {
|
||||
"public": false,
|
||||
"default_level": "none",
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ namespace _zeitbild.api
|
|||
hue : float;
|
||||
access : {
|
||||
public : boolean;
|
||||
default_level : ("none" | "view" | "edit" | "admin");
|
||||
default_level : string;
|
||||
attributed : Array<
|
||||
{
|
||||
user_id : int;
|
||||
level : ("none" | "view" | "edit" | "admin");
|
||||
level : string;
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ namespace _zeitbild.api
|
|||
register<
|
||||
_zeitbild.type_event_object, // TODO aufdröseln
|
||||
(
|
||||
null
|
||||
{
|
||||
local_resource_event_id : (null | int);
|
||||
hash : string;
|
||||
}
|
||||
|
|
||||
string
|
||||
)
|
||||
|
|
@ -88,10 +91,12 @@ namespace _zeitbild.api
|
|||
const session : {key : string; value : lib_plankton.session.type_session;} = await session_from_stuff(stuff);
|
||||
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.identify(session.value.name);
|
||||
|
||||
if (stuff.input === null) {
|
||||
if (stuff.input === null)
|
||||
{
|
||||
return Promise.reject(new Error("impossible"));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return (
|
||||
_zeitbild.service.calendar.event_add(
|
||||
parseInt(stuff.path_parameters["calendar_id"]),
|
||||
|
|
@ -99,9 +104,9 @@ namespace _zeitbild.api
|
|||
user_id
|
||||
)
|
||||
.then(
|
||||
() => Promise.resolve({
|
||||
(data) => Promise.resolve({
|
||||
"status_code": 200,
|
||||
"data": null,
|
||||
"data": data,
|
||||
})
|
||||
)
|
||||
// TODO distinguish
|
||||
|
|
|
|||
|
|
@ -88,10 +88,12 @@ namespace _zeitbild.api
|
|||
const session : {key : string; value : lib_plankton.session.type_session;} = await session_from_stuff(stuff);
|
||||
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.identify(session.value.name);
|
||||
|
||||
if (stuff.input === null) {
|
||||
if (stuff.input === null)
|
||||
{
|
||||
return Promise.reject(new Error("impossible"));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return (
|
||||
_zeitbild.service.calendar.event_change(
|
||||
parseInt(stuff.path_parameters["calendar_id"]),
|
||||
|
|
@ -100,17 +102,21 @@ namespace _zeitbild.api
|
|||
user_id
|
||||
)
|
||||
.then(
|
||||
() => Promise.resolve({
|
||||
"status_code": 200,
|
||||
"data": null,
|
||||
})
|
||||
() => Promise.resolve(
|
||||
{
|
||||
"status_code": 200,
|
||||
"data": null,
|
||||
}
|
||||
)
|
||||
)
|
||||
// TODO distinguish
|
||||
.catch(
|
||||
(reason) => Promise.resolve({
|
||||
"status_code": 403,
|
||||
"data": String(reason),
|
||||
})
|
||||
(reason) => Promise.resolve(
|
||||
{
|
||||
"status_code": 403,
|
||||
"data": String(reason),
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ namespace _zeitbild.api
|
|||
name : string;
|
||||
hue : float;
|
||||
access : {
|
||||
public : boolean;
|
||||
default_level : string;
|
||||
attributed : Array<
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ namespace _zeitbild.api
|
|||
null,
|
||||
{
|
||||
logged_in : boolean;
|
||||
name : (null | string);
|
||||
}
|
||||
>(
|
||||
rest_subject,
|
||||
|
|
@ -47,9 +48,14 @@ namespace _zeitbild.api
|
|||
"nullable": false,
|
||||
"type": "boolean",
|
||||
},
|
||||
"name": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"logged_in",
|
||||
"name",
|
||||
],
|
||||
}),
|
||||
"restriction": restriction_none,
|
||||
|
|
@ -64,11 +70,19 @@ namespace _zeitbild.api
|
|||
)
|
||||
.catch(x => Promise.resolve(null))
|
||||
);
|
||||
const user_object : (null | _zeitbild.type_user_object) = (
|
||||
(user_id === null)
|
||||
?
|
||||
null
|
||||
:
|
||||
await _zeitbild.service.user.get(user_id)
|
||||
);
|
||||
return Promise.resolve(
|
||||
{
|
||||
"status_code": 200,
|
||||
"data": {
|
||||
"logged_in": (user_id !== null),
|
||||
"name": ((user_object === null) ? null : user_object.name),
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,51 @@ namespace _zeitbild.conf
|
|||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"kind": {
|
||||
"nullable": false,
|
||||
"type": "string",
|
||||
"enum": ["file"]
|
||||
},
|
||||
"data": {
|
||||
"nullable": false,
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"nullable": false,
|
||||
"type": "string"
|
||||
},
|
||||
"threshold": {
|
||||
"nullable": false,
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"debug",
|
||||
"info",
|
||||
"notice",
|
||||
"warning",
|
||||
"error"
|
||||
],
|
||||
"default": "info"
|
||||
},
|
||||
"format": {
|
||||
"nullable": false,
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"human_readable",
|
||||
"jsonl",
|
||||
"jsonl_structured",
|
||||
],
|
||||
"default": "human_readable",
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
"default": [
|
||||
|
|
@ -291,7 +335,8 @@ namespace _zeitbild.conf
|
|||
"url_token",
|
||||
"url_userinfo",
|
||||
"client_id",
|
||||
"client_secret"
|
||||
"client_secret",
|
||||
"backend_url_base"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -172,6 +172,46 @@ async function main(
|
|||
};
|
||||
break;
|
||||
}
|
||||
case "file": {
|
||||
return {
|
||||
"kind": "minlevel",
|
||||
"data": {
|
||||
"core": {
|
||||
"kind": "file",
|
||||
"data": {
|
||||
"path": log_output.data.path,
|
||||
"format": lib_plankton.call.distinguish(
|
||||
{
|
||||
"kind": log_output.data.format,
|
||||
"data": null,
|
||||
},
|
||||
{
|
||||
"jsonl": () => ({
|
||||
"kind": "jsonl",
|
||||
"data": {
|
||||
"structured": false,
|
||||
}
|
||||
}),
|
||||
"jsonl_structured": () => ({
|
||||
"kind": "jsonl",
|
||||
"data": {
|
||||
"structured": true,
|
||||
}
|
||||
}),
|
||||
"human_readable": () => ({
|
||||
"kind": "human_readable",
|
||||
"data": {
|
||||
}
|
||||
}),
|
||||
}
|
||||
),
|
||||
}
|
||||
},
|
||||
"threshold": log_output.data.threshold,
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw (new Error("unhandled"));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ namespace _zeitbild.repository.calendar
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function read(
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ namespace _zeitbild.service.calendar
|
|||
return _zeitbild.repository.calendar.overview(user_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function get(
|
||||
|
|
@ -212,21 +212,31 @@ namespace _zeitbild.service.calendar
|
|||
calendar_id : _zeitbild.type_calendar_id,
|
||||
event_object : _zeitbild.type_event_object,
|
||||
user_id : _zeitbild.type_user_id
|
||||
) : Promise<void>
|
||||
) : Promise<
|
||||
{
|
||||
local_resource_event_id : (null | type_local_resource_event_id);
|
||||
hash : type_event_hash;
|
||||
}
|
||||
>
|
||||
{
|
||||
const calendar_object : _zeitbild.type_calendar_object = await _zeitbild.repository.calendar.read(
|
||||
calendar_id
|
||||
);
|
||||
return wrap_check_access_level<void>(
|
||||
return wrap_check_access_level(
|
||||
calendar_object,
|
||||
user_id,
|
||||
_zeitbild.enum_access_level.edit,
|
||||
async () => {
|
||||
/*const event_id : _zeitbild.type_local_resource_event_id = */await _zeitbild.service.resource.event_add(
|
||||
const local_resource_event_id : _zeitbild.type_local_resource_event_id = await _zeitbild.service.resource.event_add(
|
||||
calendar_object.resource_id,
|
||||
event_object
|
||||
);
|
||||
return Promise.resolve<void>(undefined);
|
||||
return Promise.resolve(
|
||||
{
|
||||
"local_resource_event_id": local_resource_event_id,
|
||||
"hash": get_event_hash_local(calendar_id, local_resource_event_id),
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -286,6 +296,45 @@ namespace _zeitbild.service.calendar
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function get_event_hash_local(
|
||||
calendar_id : _zeitbild.type_calendar_id,
|
||||
local_resource_event_id : _zeitbild.type_local_resource_event_id
|
||||
) : string
|
||||
{
|
||||
return lib_plankton.string.coin(
|
||||
"{{calendar_id}}:{{event_id}}",
|
||||
{
|
||||
"calendar_id": calendar_id.toFixed(0),
|
||||
"event_id": local_resource_event_id.toFixed(0),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function get_event_hash_ics_feed(
|
||||
calendar_id : _zeitbild.type_calendar_id,
|
||||
event_object : _zeitbild.type_event_object
|
||||
) : string
|
||||
{
|
||||
return lib_plankton.string.coin(
|
||||
"{{calendar_id}}~{{hash}}",
|
||||
{
|
||||
"calendar_id": calendar_id.toFixed(0),
|
||||
"hash": lib_plankton.call.convey(
|
||||
event_object,
|
||||
[
|
||||
(x : any) => lib_plankton.json.encode(x),
|
||||
(x : string) => lib_plankton.base64.encode(x),
|
||||
]
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo optimize by reducing the number of database queries
|
||||
*/
|
||||
|
|
@ -326,12 +375,9 @@ namespace _zeitbild.service.calendar
|
|||
(event_object) => Promise.resolve(
|
||||
{
|
||||
"id": event_id,
|
||||
"hash": lib_plankton.string.coin(
|
||||
"{{calendar_id}}:{{event_id}}",
|
||||
{
|
||||
"calendar_id": calendar_id.toFixed(0),
|
||||
"event_id": event_id.toFixed(0),
|
||||
}
|
||||
"hash": get_event_hash_local(
|
||||
calendar_id,
|
||||
event_id,
|
||||
),
|
||||
"object": event_object,
|
||||
}
|
||||
|
|
@ -457,19 +503,7 @@ namespace _zeitbild.service.calendar
|
|||
.map(
|
||||
(event) => ({
|
||||
"id": null,
|
||||
"hash": lib_plankton.string.coin(
|
||||
"{{calendar_id}}~{{hash}}",
|
||||
{
|
||||
"calendar_id": calendar_id.toFixed(0),
|
||||
"hash": lib_plankton.call.convey(
|
||||
event,
|
||||
[
|
||||
(x : any) => lib_plankton.json.encode(x),
|
||||
(x : string) => lib_plankton.base64.encode(x),
|
||||
]
|
||||
)
|
||||
}
|
||||
),
|
||||
"hash": get_event_hash_ics_feed(calendar_id, event),
|
||||
"object": event,
|
||||
})
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue