Compare commits
36 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c91365f98 | ||
|
|
193a21277f | ||
|
|
8264936f21 | ||
|
|
8a9d552760 | ||
|
|
47319b9e10 | ||
|
|
4b75e06057 | ||
|
|
a7a90e8ab8 | ||
|
|
e46be87a99 | ||
|
|
58791676e5 | ||
|
|
74f79ae0b7 | ||
|
|
a716cf6852 | ||
|
|
e549d7b088 | ||
|
|
31194c8c41 | ||
|
|
4e9f7f634d | ||
|
|
bbfc07478f | ||
|
|
5afc562b18 | ||
|
|
6309422429 | ||
|
|
2683d49bba | ||
|
|
1df1fa3ac9 | ||
|
|
5ab91664ed | ||
|
|
fc228fb274 | ||
|
|
6ad47e1943 | ||
|
|
00f416a126 | ||
|
|
64652af779 | ||
|
|
9eab32d573 | ||
|
|
2cb46cd485 | ||
|
|
6f1437b55a | ||
|
|
8ddba38bd5 | ||
|
|
c5d52a7df5 | ||
|
|
b86e1b62e2 | ||
|
|
ef879bb81b | ||
|
|
54e27f2ad9 | ||
|
|
b5b5dde9e3 | ||
|
|
5de4728901 | ||
|
|
9d1fd0b55f | ||
|
|
1127130b00 |
|
|
@ -26,9 +26,7 @@
|
|||
{
|
||||
"id": 1,
|
||||
"name": "LV Lampukistan",
|
||||
"hue": 0.0000,
|
||||
"access": {
|
||||
"public": true,
|
||||
"default_level": "view",
|
||||
"attributed": [
|
||||
{
|
||||
|
|
@ -49,20 +47,12 @@
|
|||
"name": "Aufstand: Mieten",
|
||||
"begin": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [-1]},
|
||||
{"action": "shift_day", "args": [6]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 14},
|
||||
"time": {"hour": 12, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [-1]},
|
||||
{"action": "shift_day", "args": [6]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 14},
|
||||
"time": {"hour": 15, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Porada Ninfu, Haupt-Markt",
|
||||
|
|
@ -72,20 +62,12 @@
|
|||
"name": "Aufstand: Waffen",
|
||||
"begin": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [0]},
|
||||
{"action": "shift_day", "args": [6]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 21},
|
||||
"time": {"hour": 12, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [0]},
|
||||
{"action": "shift_day", "args": [6]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 21},
|
||||
"time": {"hour": 15, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Tandreell, Stoiber-Platz",
|
||||
|
|
@ -95,20 +77,12 @@
|
|||
"name": "Aufstand: Essen",
|
||||
"begin": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [6]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 10, "day": 28},
|
||||
"time": {"hour": 12, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [6]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 10, "day": 28},
|
||||
"time": {"hour": 15, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Kawanda, Nord-Bahnhof",
|
||||
|
|
@ -121,9 +95,7 @@
|
|||
{
|
||||
"id": 2,
|
||||
"name": "KV Zepettel-Region",
|
||||
"hue": 0.3333,
|
||||
"access": {
|
||||
"public": false,
|
||||
"default_level": "view",
|
||||
"attributed": [
|
||||
{
|
||||
|
|
@ -144,20 +116,12 @@
|
|||
"name": "Feier: Bier",
|
||||
"begin": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [0]},
|
||||
{"action": "shift_day", "args": [3]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 18},
|
||||
"time": {"hour": 18, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [0]},
|
||||
{"action": "shift_day", "args": [3]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 18},
|
||||
"time": {"hour": 23, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Rudschadinedschad, Schlamm-Park",
|
||||
|
|
@ -167,20 +131,12 @@
|
|||
"name": "Feier: Schnapps",
|
||||
"begin": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [2]},
|
||||
{"action": "shift_day", "args": [2]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 10, "day": 1},
|
||||
"time": {"hour": 18, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [2]},
|
||||
{"action": "shift_day", "args": [2]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 10, "day": 1},
|
||||
"time": {"hour": 23, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Kawanda, Ratten-Platz",
|
||||
|
|
@ -193,9 +149,7 @@
|
|||
{
|
||||
"id": 3,
|
||||
"name": "OV Kawanda",
|
||||
"hue": 0.6667,
|
||||
"access": {
|
||||
"public": false,
|
||||
"default_level": "view",
|
||||
"attributed": [
|
||||
{
|
||||
|
|
@ -212,20 +166,12 @@
|
|||
"name": "Aufräumen: Flaschen",
|
||||
"begin": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [2]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 24},
|
||||
"time": {"hour": 15, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [2]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 24},
|
||||
"time": {"hour": 17, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Kawanda, Penner-Allee",
|
||||
|
|
@ -238,9 +184,7 @@
|
|||
{
|
||||
"id": 4,
|
||||
"name": "KV Zepettel-Region | intern",
|
||||
"hue": 0.8333,
|
||||
"access": {
|
||||
"public": false,
|
||||
"default_level": "none",
|
||||
"attributed": [
|
||||
{
|
||||
|
|
@ -261,20 +205,12 @@
|
|||
"name": "Infostand",
|
||||
"begin": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [0]},
|
||||
{"action": "shift_day", "args": [1]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 16},
|
||||
"time": {"hour": 10, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 2,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [0]},
|
||||
{"action": "shift_day", "args": [1]}
|
||||
],
|
||||
"date": {"year": 2025, "month": 9, "day": 16},
|
||||
"time": {"hour": 14, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Rudschadinedschad, Schabracken-Markt",
|
||||
94
doc/konzept.md
Normal file
94
doc/konzept.md
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
# Konzept
|
||||
|
||||
## Notizen
|
||||
|
||||
- Kalender sollen unabhängig von Nutzern bestehen können
|
||||
- Zugriffs-Stufen
|
||||
- `none`: kein Zugriff
|
||||
- `view`: nur lesend
|
||||
- `edit`: lesend und schreibend
|
||||
- `admin`: kann alles (auch Kalender löschen)
|
||||
- einem Kalender können beliebig viele Nutzer zugeordnet werden, die jeweils bestimmte Zugriffs-Stufen zugewiesen haben
|
||||
- Veranstaltungen bilden keine eigene Domäne
|
||||
- es gibt verschiedene Arten von Quellen:
|
||||
- lokal
|
||||
- enthält Veranstaltungen
|
||||
- caldav
|
||||
- enthält keine eigenen Veranstaltungen
|
||||
- sollte read-only- und read/write-Modus haben
|
||||
- nach dem Anmelden sieht man eine Kalender-Ansicht mit folgenden Kalendern kombiniert angezeigt:
|
||||
- öffentliche Kalender
|
||||
- nicht öffentliche Kalendar, bei welchen man mindestens Lese-Berechtigung hat
|
||||
- öffentliche Kalendar können ohne Anmeldung betrachtet werden, jedoch nur mit einem schwer bis gar nicht erratbaren Link
|
||||
|
||||
|
||||
## Zugriffssteuerung
|
||||
|
||||
Es gibt folgende Zugriffsstufen :
|
||||
|
||||
- `none`: kein Zugriff
|
||||
- `view`: nur Lese-Zugriff
|
||||
- `edit`: Lese- und Schreib-Zugriff
|
||||
- `admin`: Lese- und Schreib-Zugriff + Bearbeitung von Kalender-Eigenschaften
|
||||
|
||||
Zur Bestimmung welche Zugriffsstufe ein Nutzer auf einen Kalender/Termin hat, werden drei Werte betrachtet:
|
||||
|
||||
- Öffentlichkeit des Kalenders (`public`)
|
||||
- Standard-Zugriffsstufe des Kalenders (`default_level`)
|
||||
- dem Nutzer zugewiesene Zugriffsstufe für den Kalender (`attributed_level`)
|
||||
|
||||
Diese Angaben fließen in folgende Formel ein:
|
||||
|
||||
```
|
||||
access_level = max(
|
||||
(if public then 'view' else 'none'),
|
||||
(if (attributed = NULL) then default_level else attributed_level)
|
||||
)
|
||||
```
|
||||
|
||||
… wobei die Ordnung der Zugriffsstufen der oben ersichtlichen Reihenfolge entspricht.
|
||||
|
||||
Einzeln aufgeführt ergibt das:
|
||||
|
||||
| public | default level | attributed level | result |
|
||||
|-- |-- |-- |-- |
|
||||
| no | none | - | none |
|
||||
| no | none | none | none |
|
||||
| no | none | view | view |
|
||||
| no | none | edit | edit |
|
||||
| no | none | admin | admin |
|
||||
| no | view | - | view |
|
||||
| no | view | none | none |
|
||||
| no | view | view | view |
|
||||
| no | view | edit | edit |
|
||||
| no | view | admin | admin |
|
||||
| no | edit | - | edit |
|
||||
| no | edit | none | none |
|
||||
| no | edit | view | view |
|
||||
| no | edit | edit | edit |
|
||||
| no | edit | admin | admin |
|
||||
| no | admin | - | admin |
|
||||
| no | admin | none | none |
|
||||
| no | admin | view | view |
|
||||
| no | admin | edit | edit |
|
||||
| no | admin | admin | admin |
|
||||
| yes | none | - | view |
|
||||
| yes | none | none | view |
|
||||
| yes | none | view | view |
|
||||
| yes | none | edit | edit |
|
||||
| yes | none | admin | admin |
|
||||
| yes | view | - | view |
|
||||
| yes | view | none | view |
|
||||
| yes | view | view | view |
|
||||
| yes | view | edit | edit |
|
||||
| yes | view | admin | admin |
|
||||
| yes | edit | - | edit |
|
||||
| yes | edit | none | view |
|
||||
| yes | edit | view | view |
|
||||
| yes | edit | edit | edit |
|
||||
| yes | edit | admin | admin |
|
||||
| yes | admin | - | admin |
|
||||
| yes | admin | none | none |
|
||||
| yes | admin | view | view |
|
||||
| yes | admin | edit | edit |
|
||||
| yes | admin | admin | admin |
|
||||
121
lib/plankton/plankton.d.ts
vendored
121
lib/plankton/plankton.d.ts
vendored
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type int = number;
|
||||
declare type int = number;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type float = number;
|
||||
declare type float = number;
|
||||
declare var process: any;
|
||||
declare var require: any;
|
||||
declare class Buffer {
|
||||
|
|
@ -22,7 +22,7 @@ declare namespace lib_plankton.base {
|
|||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_pseudopointer<type_value> = {
|
||||
declare type type_pseudopointer<type_value> = {
|
||||
value: type_value;
|
||||
};
|
||||
/**
|
||||
|
|
@ -229,10 +229,9 @@ 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, "render_readable_characters": render_readable_characters, }?: {
|
||||
function buffer_show(buffer: Buffer, { "block_size": option_block_size, "break_char": option_break_char, }?: {
|
||||
block_size?: int;
|
||||
break_char?: string;
|
||||
render_readable_characters?: boolean;
|
||||
}): string;
|
||||
}
|
||||
declare module lib_plankton.pod {
|
||||
|
|
@ -587,10 +586,6 @@ declare namespace lib_plankton.call {
|
|||
* @author fenris
|
||||
*/
|
||||
export function timeout(procedure: (() => void), delay_in_seconds: float): int;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
export function loop(procedure: (() => void), delay_in_seconds: float): int;
|
||||
/**
|
||||
* Promise version of "setTimeout"
|
||||
*
|
||||
|
|
@ -658,9 +653,6 @@ declare namespace lib_plankton.call {
|
|||
/**
|
||||
*/
|
||||
export function sleep(seconds: float): Promise<void>;
|
||||
/**
|
||||
*/
|
||||
export function null_prop<type_value_from, type_value_to>(value_from: (null | type_value_from), function_: ((value: type_value_from) => type_value_to)): (null | type_value_to);
|
||||
export {};
|
||||
}
|
||||
declare namespace lib_plankton.email {
|
||||
|
|
@ -2323,7 +2315,7 @@ declare namespace lib_plankton.storage.memory {
|
|||
clear(): Promise<void>;
|
||||
write(key: any, value: any): Promise<boolean>;
|
||||
delete(key: any): Promise<void>;
|
||||
read(key: any): Promise<Awaited<type_item>>;
|
||||
read(key: any): Promise<type_item>;
|
||||
search(term: any): Promise<{
|
||||
key: string;
|
||||
preview: string;
|
||||
|
|
@ -3081,73 +3073,26 @@ declare namespace lib_plankton.session {
|
|||
};
|
||||
/**
|
||||
*/
|
||||
function begin(name: string, { "lifetime": lifetime, "data": data, }?: {
|
||||
function begin(name: string, options?: {
|
||||
lifetime?: int;
|
||||
data?: any;
|
||||
}): Promise<string>;
|
||||
/**
|
||||
*/
|
||||
function get(key: string, { "prolongation": prolongation, }?: {
|
||||
prolongation?: (null | int);
|
||||
}): Promise<type_session>;
|
||||
function get(key: string): Promise<type_session>;
|
||||
/**
|
||||
*/
|
||||
function end(key: string): Promise<void>;
|
||||
/**
|
||||
*/
|
||||
function setup({ "key_length": key_length, "key_max_attempts": key_max_attempts, "default_lifetime": default_lifetime, "default_prolongation": default_prolongation, "data_chest": data_chest, "clear": clear, }?: {
|
||||
function setup(options?: {
|
||||
key_length?: int;
|
||||
key_max_attempts?: int;
|
||||
default_lifetime?: int;
|
||||
default_prolongation?: (null | int);
|
||||
data_chest?: lib_plankton.storage.type_chest<string, any, void, string, string>;
|
||||
clear?: boolean;
|
||||
}): Promise<void>;
|
||||
}
|
||||
declare namespace lib_plankton.base64 {
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_source = string;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_target = string;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
export function encode(source: type_source): type_target;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
export function decode(target: type_target): type_source;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
export function implementation_code(): lib_plankton.code.type_code<type_source, type_target>;
|
||||
export {};
|
||||
}
|
||||
declare namespace lib_plankton.base64 {
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
class class_base64 implements lib_plankton.code.interface_code<string, string> {
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* @implementation
|
||||
* @author fenris
|
||||
*/
|
||||
encode(x: string): string;
|
||||
/**
|
||||
* @implementation
|
||||
* @author fenris
|
||||
*/
|
||||
decode(x: string): string;
|
||||
}
|
||||
}
|
||||
declare namespace lib_plankton {
|
||||
namespace order {
|
||||
/**
|
||||
|
|
@ -4132,7 +4077,7 @@ declare namespace lib_plankton.server {
|
|||
};
|
||||
/**
|
||||
*/
|
||||
function make(handle: ((input: string, metadata?: type_metadata) => Promise<string>), { "host": host, "port": port, "threshold": threshold, }?: {
|
||||
function make(handle: ((input: string, metadata?: type_metadata) => Promise<string>), options?: {
|
||||
host?: string;
|
||||
port?: int;
|
||||
threshold?: (null | float);
|
||||
|
|
@ -4556,6 +4501,50 @@ declare namespace lib_plankton.map.collatemap {
|
|||
export function implementation_map<type_key, type_value>(subject: type_subject<type_key, type_value>): type_map<type_key, type_value>;
|
||||
export {};
|
||||
}
|
||||
declare namespace lib_plankton.base64 {
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_source = string;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
type type_target = string;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
export function encode(source: type_source): type_target;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
export function decode(target: type_target): type_source;
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
export function implementation_code(): lib_plankton.code.type_code<type_source, type_target>;
|
||||
export {};
|
||||
}
|
||||
declare namespace lib_plankton.base64 {
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
class class_base64 implements lib_plankton.code.interface_code<string, string> {
|
||||
/**
|
||||
* @author fenris
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* @implementation
|
||||
* @author fenris
|
||||
*/
|
||||
encode(x: string): string;
|
||||
/**
|
||||
* @implementation
|
||||
* @author fenris
|
||||
*/
|
||||
decode(x: string): string;
|
||||
}
|
||||
}
|
||||
declare namespace lib_plankton.auth {
|
||||
/**
|
||||
*/
|
||||
|
|
@ -4597,11 +4586,9 @@ declare namespace lib_plankton.auth.oidc {
|
|||
type type_token = string;
|
||||
/**
|
||||
*/
|
||||
export type type_userinfo = {
|
||||
type type_userinfo = {
|
||||
name: (null | string);
|
||||
label: (null | string);
|
||||
email: (null | string);
|
||||
groups: (null | Array<string>);
|
||||
};
|
||||
/**
|
||||
*/
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,14 +1,6 @@
|
|||
{
|
||||
"version": 1,
|
||||
"log": [
|
||||
{
|
||||
"kind": "file",
|
||||
"data": {
|
||||
"path": "/tmp/zeitbild/log.jsonl",
|
||||
"threshold": "info",
|
||||
"format": "jsonl_structured"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "stdout",
|
||||
"data": {
|
||||
|
|
@ -33,17 +25,13 @@
|
|||
}
|
||||
},
|
||||
"caldav": {
|
||||
"address": "http://localhost:8000/calendars/-/demo",
|
||||
"username": "demo-{{username}}",
|
||||
"address": "http://localhost:8000/calendars/-/lampukistan",
|
||||
"username": "lampukistan-{{username}}",
|
||||
"password": "{{password}}",
|
||||
"setup_hints": [
|
||||
{
|
||||
"label": "Liste von Clients",
|
||||
"link": "https://devguide.calconnect.org/CalDAV/Client-Implementations/"
|
||||
},
|
||||
{
|
||||
"label": "Android",
|
||||
"link": "https://goneuland.de/davx5-android-kalender-per-caldav-integrieren-z-b-nextcloud/",
|
||||
"link": "https://www.android-user.de/caldavcarddav-kalender-und-adressbuecher-ohne-google-synchronisieren/",
|
||||
"remark": null
|
||||
},
|
||||
{
|
||||
|
|
@ -62,8 +50,8 @@
|
|||
},
|
||||
{
|
||||
"label": "MS Outlook",
|
||||
"link": "https://all-inkl.com/wichtig/anleitungen/programme/e-mail/caldav-kalenderfunktion/outlook-2019_468.html",
|
||||
"remark": "eigentlich für Server 'all-inkl.com' — Zugangsdaten müssen entsprechend geändert werden"
|
||||
"link": "https://www.united-domains.de/help/faq-article/wie-synchronisiere-ich-meinen-kalender-caldav-mit-ms-outlook/",
|
||||
"remark": null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,328 +0,0 @@
|
|||
{
|
||||
"groups": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "gaertner",
|
||||
"label": "Gärtner"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "bewohner",
|
||||
"label": "Bewohner"
|
||||
}
|
||||
],
|
||||
"users": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "alice",
|
||||
"groups": [1],
|
||||
"email_address": "alice@example.org",
|
||||
"dav_token": null,
|
||||
"password": "alice"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "bob",
|
||||
"groups": [2],
|
||||
"email_address": "bob@example.org",
|
||||
"dav_token": null,
|
||||
"password": "bob"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "charlie",
|
||||
"groups": [1, 2],
|
||||
"email_address": "charlie@example.org",
|
||||
"dav_token": "charlie_dav",
|
||||
"password": "charlie"
|
||||
}
|
||||
],
|
||||
"calendars": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Feiertage",
|
||||
"hue": 0.0000,
|
||||
"access": {
|
||||
"public": true,
|
||||
"default_level": "view",
|
||||
"attributed_group": [
|
||||
],
|
||||
"attributed_user": [
|
||||
{
|
||||
"user_id": 3,
|
||||
"level": "admin"
|
||||
}
|
||||
]
|
||||
},
|
||||
"resource": {
|
||||
"kind": "local",
|
||||
"data": {
|
||||
"events": [
|
||||
{
|
||||
"name": "Tag des Wassers",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": [0]},
|
||||
{"action": "shift_week", "args": [-1]},
|
||||
{"action": "shift_day", "args": [1]}
|
||||
],
|
||||
"time": null
|
||||
},
|
||||
"end": null,
|
||||
"location": null,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"name": "Tag der Erde",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": [0]},
|
||||
{"action": "shift_week", "args": [0]},
|
||||
{"action": "shift_day", "args": [6]}
|
||||
],
|
||||
"time": null
|
||||
},
|
||||
"end": null,
|
||||
"location": null,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"name": "Tag der Luft",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": [0]},
|
||||
{"action": "shift_week", "args": [2]},
|
||||
{"action": "shift_day", "args": [4]}
|
||||
],
|
||||
"time": null
|
||||
},
|
||||
"end": null,
|
||||
"location": null,
|
||||
"description": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Garten",
|
||||
"hue": 0.3333,
|
||||
"access": {
|
||||
"public": false,
|
||||
"default_level": "none",
|
||||
"attributed_group": [
|
||||
{
|
||||
"group_id": 1,
|
||||
"level": "view"
|
||||
}
|
||||
],
|
||||
"attributed_user": [
|
||||
{
|
||||
"user_id": 1,
|
||||
"level": "admin"
|
||||
}
|
||||
]
|
||||
},
|
||||
"resource": {
|
||||
"kind": "local",
|
||||
"data": {
|
||||
"events": [
|
||||
{
|
||||
"name": "Unkraut jähten",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [-1]},
|
||||
{"action": "shift_day", "args": [3]}
|
||||
],
|
||||
"time": {"hour": 10, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [-1]},
|
||||
{"action": "shift_day", "args": [3]}
|
||||
],
|
||||
"time": {"hour": 11, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Drosselweg 7",
|
||||
"description": "Giersch und Rainkohl haben wider gewuchert"
|
||||
},
|
||||
{
|
||||
"name": "Holz hacken",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [0]},
|
||||
{"action": "shift_day", "args": [0]}
|
||||
],
|
||||
"time": {"hour": 13, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [0]},
|
||||
{"action": "shift_day", "args": [0]}
|
||||
],
|
||||
"time": {"hour": 14, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Drosselweg 7",
|
||||
"description": "die alte Birke ist bereits in Segmente geschnitten und muss nun noch in handliche Scheite zerlegt werden"
|
||||
},
|
||||
{
|
||||
"name": "Blumen gießen",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [2]}
|
||||
],
|
||||
"time": {"hour": 18, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [2]}
|
||||
],
|
||||
"time": {"hour": 19, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Drosselweg 7",
|
||||
"description": "erst in der Abendzeit, damit die Sonne tief steht und das Gießen sich lohnt"
|
||||
},
|
||||
{
|
||||
"name": "Grill-Fete",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [5]}
|
||||
],
|
||||
"time": {"hour": 18, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [5]}
|
||||
],
|
||||
"time": {"hour": 23, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Drosselweg 7",
|
||||
"description": "Grillgut ist selbst mitzubringen; Getränke sind bereits vor Ort"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Haus",
|
||||
"hue": 0.6667,
|
||||
"access": {
|
||||
"public": false,
|
||||
"default_level": "none",
|
||||
"attributed_group": [
|
||||
{
|
||||
"group_id": 2,
|
||||
"level": "view"
|
||||
}
|
||||
],
|
||||
"attributed_user": [
|
||||
{
|
||||
"user_id": 2,
|
||||
"level": "admin"
|
||||
}
|
||||
]
|
||||
},
|
||||
"resource": {
|
||||
"kind": "local",
|
||||
"data": {
|
||||
"events": [
|
||||
{
|
||||
"name": "Bad putzen",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [-1]},
|
||||
{"action": "shift_day", "args": [4]}
|
||||
],
|
||||
"time": {"hour": 8, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [-1]},
|
||||
{"action": "shift_day", "args": [4]}
|
||||
],
|
||||
"time": {"hour": 9, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Eschenhain 11",
|
||||
"description": "das Waschbecken sollte unbedingt von Keimen befreit werden"
|
||||
},
|
||||
{
|
||||
"name": "Abstellkammer aufräumen",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [0]}
|
||||
],
|
||||
"time": {"hour": 12, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [1]},
|
||||
{"action": "shift_day", "args": [0]}
|
||||
],
|
||||
"time": {"hour": 13, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Eschenhain 11",
|
||||
"description": "einiges davon kann vermutlich gleich entsorgt werden"
|
||||
},
|
||||
{
|
||||
"name": "Treppe wischen",
|
||||
"begin": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [2]},
|
||||
{"action": "shift_day", "args": [1]}
|
||||
],
|
||||
"time": {"hour": 14, "minute": 0, "second": 0}
|
||||
},
|
||||
"end": {
|
||||
"timezone_shift": 0,
|
||||
"date_relative": [
|
||||
{"action": "trunc_week", "args": []},
|
||||
{"action": "shift_week", "args": [2]},
|
||||
{"action": "shift_day", "args": [1]}
|
||||
],
|
||||
"time": {"hour": 15, "minute": 0, "second": 0}
|
||||
},
|
||||
"location": "Eschenhain 11",
|
||||
"description": "die dreckigen Schuhe haben ihre Spuren hinterlassen"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"users": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "user",
|
||||
"email_address": "user@example.org",
|
||||
"dav_token": null,
|
||||
"password": "user"
|
||||
}
|
||||
],
|
||||
"calendars": [
|
||||
]
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Beschreibung
|
||||
|
||||
- Hintergrund-Dienst für [zeitbild](/zeitbild/meta)
|
||||
- Hintergrund-Dienst für Kalendar-Erstellung und -Darstellung
|
||||
|
||||
|
||||
## Erstellung
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -33,13 +14,7 @@ namespace _zeitbild.api
|
|||
access : {
|
||||
public : boolean;
|
||||
default_level : string;
|
||||
attributed_group : Array<
|
||||
{
|
||||
group_id : int;
|
||||
level : string;
|
||||
}
|
||||
>;
|
||||
attributed_user : Array<
|
||||
attributed : Array<
|
||||
{
|
||||
user_id : int;
|
||||
level : string;
|
||||
|
|
@ -61,7 +36,6 @@ namespace _zeitbild.api
|
|||
};
|
||||
}
|
||||
);
|
||||
hue : float;
|
||||
},
|
||||
int
|
||||
>(
|
||||
|
|
@ -118,33 +92,17 @@ namespace _zeitbild.api
|
|||
"name": stuff.input.name,
|
||||
"access": {
|
||||
"public": stuff.input.access.public,
|
||||
"default_level": _zeitbild.access_level_from_string(stuff.input.access.default_level),
|
||||
"attributed_group": lib_plankton.map.hashmap.implementation_map(
|
||||
"default_level": _zeitbild.value_object.access_level.from_string(stuff.input.access.default_level),
|
||||
"attributed": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
stuff.input.access.attributed_group
|
||||
.map(
|
||||
(entry) => ({
|
||||
"key": entry.group_id,
|
||||
"value": _zeitbild.access_level_from_string(entry.level),
|
||||
})
|
||||
)
|
||||
),
|
||||
}
|
||||
)
|
||||
),
|
||||
"attributed_user": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
stuff.input.access.attributed_user
|
||||
stuff.input.access.attributed
|
||||
.map(
|
||||
(entry) => ({
|
||||
"key": entry.user_id,
|
||||
"value": _zeitbild.access_level_from_string(entry.level),
|
||||
"value": _zeitbild.value_object.access_level.from_string(entry.level),
|
||||
})
|
||||
)
|
||||
.concat(
|
||||
|
|
@ -160,8 +118,7 @@ namespace _zeitbild.api
|
|||
)
|
||||
),
|
||||
},
|
||||
"resource_id": resource_id,
|
||||
"hue": stuff.input.hue,
|
||||
"resource_id": resource_id
|
||||
};
|
||||
return (
|
||||
_zeitbild.service.calendar.add(calendar_object)
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -30,20 +11,13 @@ namespace _zeitbild.api
|
|||
register<
|
||||
{
|
||||
name : string;
|
||||
hue : float;
|
||||
access : {
|
||||
public : boolean;
|
||||
default_level : string;
|
||||
attributed_group : Array<
|
||||
{
|
||||
group_id : int;
|
||||
level : string;
|
||||
}
|
||||
>;
|
||||
attributed_user : Array<
|
||||
default_level : ("none" | "view" | "edit" | "admin");
|
||||
attributed : Array<
|
||||
{
|
||||
user_id : int;
|
||||
level : string;
|
||||
level : ("none" | "view" | "edit" | "admin");
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
|
@ -80,36 +54,19 @@ namespace _zeitbild.api
|
|||
);
|
||||
const calendar_object_new : _zeitbild.type_calendar_object = {
|
||||
"name": stuff.input.name,
|
||||
"hue": stuff.input.hue,
|
||||
"access": {
|
||||
"public": stuff.input.access.public,
|
||||
"default_level": _zeitbild.access_level_from_string(stuff.input.access.default_level),
|
||||
"attributed_group": lib_plankton.map.hashmap.implementation_map(
|
||||
"default_level": _zeitbild.value_object.access_level.from_string(stuff.input.access.default_level),
|
||||
"attributed": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
stuff.input.access.attributed_group
|
||||
.map(
|
||||
(entry) => ({
|
||||
"key": entry.group_id,
|
||||
"value": _zeitbild.access_level_from_string(entry.level),
|
||||
})
|
||||
)
|
||||
),
|
||||
}
|
||||
)
|
||||
),
|
||||
"attributed_user": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
stuff.input.access.attributed_user
|
||||
stuff.input.access.attributed
|
||||
.map(
|
||||
(entry) => ({
|
||||
"key": entry.user_id,
|
||||
"value": _zeitbild.access_level_from_string(entry.level),
|
||||
"value": _zeitbild.value_object.access_level.from_string(entry.level),
|
||||
})
|
||||
)
|
||||
),
|
||||
|
|
@ -117,7 +74,7 @@ namespace _zeitbild.api
|
|||
)
|
||||
),
|
||||
},
|
||||
"resource_id": calendar_object_old.resource_id,
|
||||
"resource_id": calendar_object_old.resource_id
|
||||
};
|
||||
await _zeitbild.service.calendar.change(
|
||||
calendar_id,
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -30,10 +11,7 @@ namespace _zeitbild.api
|
|||
register<
|
||||
_zeitbild.type_event_object, // TODO aufdröseln
|
||||
(
|
||||
{
|
||||
local_resource_event_id : (null | int);
|
||||
hash : string;
|
||||
}
|
||||
null
|
||||
|
|
||||
string
|
||||
)
|
||||
|
|
@ -91,12 +69,10 @@ 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"]),
|
||||
|
|
@ -104,9 +80,9 @@ namespace _zeitbild.api
|
|||
user_id
|
||||
)
|
||||
.then(
|
||||
(data) => Promise.resolve({
|
||||
() => Promise.resolve({
|
||||
"status_code": 200,
|
||||
"data": data,
|
||||
"data": null,
|
||||
})
|
||||
)
|
||||
// TODO distinguish
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -88,12 +69,10 @@ 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"]),
|
||||
|
|
@ -102,21 +81,17 @@ 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),
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -31,22 +12,14 @@ namespace _zeitbild.api
|
|||
null,
|
||||
{
|
||||
name : string;
|
||||
hue : float;
|
||||
access : {
|
||||
public : boolean;
|
||||
default_level : string;
|
||||
attributed_group : Array<
|
||||
{
|
||||
group_id : int;
|
||||
level : string;
|
||||
}
|
||||
>;
|
||||
attributed_user : Array<
|
||||
attributed : Array<
|
||||
{
|
||||
user_id : int;
|
||||
level : string;
|
||||
}
|
||||
>;
|
||||
>
|
||||
};
|
||||
resource_id : int;
|
||||
}
|
||||
|
|
@ -71,27 +44,11 @@ namespace _zeitbild.api
|
|||
);
|
||||
const result = {
|
||||
"name": calendar_object.name,
|
||||
"hue": calendar_object.hue,
|
||||
"access": {
|
||||
"public": calendar_object.access.public,
|
||||
"default_level": _zeitbild.api.access_level_encode(calendar_object.access.default_level),
|
||||
"attributed_group": lib_plankton.call.convey(
|
||||
calendar_object.access.attributed_group,
|
||||
[
|
||||
lib_plankton.map.dump,
|
||||
(pairs : Array<{key : _zeitbild.type_group_id; value : _zeitbild.enum_access_level;}>) => (
|
||||
pairs
|
||||
.map(
|
||||
(pair : {key : _zeitbild.type_group_id; value : _zeitbild.enum_access_level;}) => ({
|
||||
"group_id": pair.key,
|
||||
"level": _zeitbild.api.access_level_encode(pair.value)
|
||||
})
|
||||
)
|
||||
)
|
||||
]
|
||||
),
|
||||
"attributed_user": lib_plankton.call.convey(
|
||||
calendar_object.access.attributed_user,
|
||||
"attributed": lib_plankton.call.convey(
|
||||
calendar_object.access.attributed,
|
||||
[
|
||||
lib_plankton.map.dump,
|
||||
(pairs : Array<{key : _zeitbild.type_user_id; value : _zeitbild.enum_access_level;}>) => (
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -33,7 +14,6 @@ namespace _zeitbild.api
|
|||
{
|
||||
id : int;
|
||||
name : string;
|
||||
hue : float;
|
||||
access_level : string;
|
||||
}
|
||||
>
|
||||
|
|
@ -60,10 +40,6 @@ namespace _zeitbild.api
|
|||
"type": "string",
|
||||
"nullable": false,
|
||||
},
|
||||
"hue": {
|
||||
"nullable": false,
|
||||
"type": "number"
|
||||
},
|
||||
"access_level": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
|
|
@ -73,8 +49,8 @@ namespace _zeitbild.api
|
|||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"hue",
|
||||
"access_level",
|
||||
"public",
|
||||
"role",
|
||||
],
|
||||
}
|
||||
}),
|
||||
|
|
@ -100,8 +76,7 @@ namespace _zeitbild.api
|
|||
(entry) => ({
|
||||
"id": entry.id,
|
||||
"name": entry.name,
|
||||
"hue": entry.hue,
|
||||
"access_level": _zeitbild.access_level_to_string(entry.access_level),
|
||||
"access_level": _zeitbild.value_object.access_level.to_string(entry.access_level),
|
||||
})
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -32,10 +13,8 @@ namespace _zeitbild.api
|
|||
(
|
||||
Array<
|
||||
{
|
||||
hash : _zeitbild.type_event_hash;
|
||||
calendar_id : int;
|
||||
calendar_name : string;
|
||||
hue : float;
|
||||
access_level : string;
|
||||
event_id : (null | int);
|
||||
event_object : _zeitbild.type_event_object;
|
||||
|
|
@ -74,10 +53,6 @@ namespace _zeitbild.api
|
|||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"hash": {
|
||||
"nullable": false,
|
||||
"type": "string",
|
||||
},
|
||||
"calendar_id": {
|
||||
"nullable": false,
|
||||
"type": "number",
|
||||
|
|
@ -86,10 +61,6 @@ namespace _zeitbild.api
|
|||
"nullable": false,
|
||||
"type": "string",
|
||||
},
|
||||
"hue": {
|
||||
"nullable": false,
|
||||
"type": "number"
|
||||
},
|
||||
"access_level": {
|
||||
"nullable": false,
|
||||
"type": "string",
|
||||
|
|
@ -196,11 +167,8 @@ namespace _zeitbild.api
|
|||
data
|
||||
.map(
|
||||
(entry) => ({
|
||||
// todo
|
||||
"hash": entry.hash,
|
||||
"calendar_id": entry.calendar_id,
|
||||
"calendar_name": entry.calendar_name,
|
||||
"hue": entry.hue,
|
||||
"access_level": _zeitbild.api.access_level_encode(entry.access_level),
|
||||
"event_id": entry.event_id,
|
||||
"event_object": entry.event_object,
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
export function register_group_list(
|
||||
rest_subject : lib_plankton.rest_http.type_rest
|
||||
) : void
|
||||
{
|
||||
register<
|
||||
null,
|
||||
Array<
|
||||
{
|
||||
id : int;
|
||||
name : string;
|
||||
label : string;
|
||||
}
|
||||
>
|
||||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.get,
|
||||
"/groups",
|
||||
{
|
||||
"description": "listet alle Gruppen auf",
|
||||
"query_parameters": () => ([
|
||||
{
|
||||
"name": "term",
|
||||
"required": false,
|
||||
"description": "search term",
|
||||
},
|
||||
]),
|
||||
"output_schema": () => ({
|
||||
"type": "array",
|
||||
"items": {
|
||||
"nullable": false,
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
"nullable": false,
|
||||
"type": "number",
|
||||
},
|
||||
"name": {
|
||||
"nullable": false,
|
||||
"type": "string",
|
||||
},
|
||||
"label": {
|
||||
"nullable": false,
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"label",
|
||||
],
|
||||
}
|
||||
}),
|
||||
"restriction": restriction_logged_in,
|
||||
"execution": async (stuff) => {
|
||||
const result : Array<
|
||||
{
|
||||
id : _zeitbild.type_group_id;
|
||||
name : string;
|
||||
label : string;
|
||||
}
|
||||
> = (
|
||||
(await _zeitbild.service.group.list())
|
||||
.map(
|
||||
entry => (
|
||||
{
|
||||
"id": entry.id,
|
||||
"name": entry.object.name,
|
||||
"label": entry.object.label,
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
return Promise.resolve(
|
||||
{
|
||||
"status_code": 200,
|
||||
"data": result,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -65,30 +46,23 @@ namespace _zeitbild.api
|
|||
}),
|
||||
"restriction": () => restriction_none,
|
||||
"execution": () => async ({"input": input}) => {
|
||||
if (input === null)
|
||||
{
|
||||
if (input === null) {
|
||||
return Promise.reject(new Error("impossible"));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
const passed : boolean = await _zeitbild.service.auth_internal.check(input.name, input.password);
|
||||
if (! passed)
|
||||
{
|
||||
return Promise.resolve(
|
||||
{
|
||||
"status_code": 403,
|
||||
"data": null,
|
||||
}
|
||||
);
|
||||
if (! passed) {
|
||||
return Promise.resolve({
|
||||
"status_code": 403,
|
||||
"data": null,
|
||||
});
|
||||
}
|
||||
else {
|
||||
const session_key : string = await lib_plankton.session.begin(input.name);
|
||||
return Promise.resolve(
|
||||
{
|
||||
"status_code": 201,
|
||||
"data": session_key,
|
||||
}
|
||||
);
|
||||
return Promise.resolve({
|
||||
"status_code": 201,
|
||||
"data": session_key,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -43,12 +24,10 @@ namespace _zeitbild.api
|
|||
"execution": async (stuff) => {
|
||||
const session : {key : string; value : lib_plankton.session.type_session} = await session_from_stuff(stuff);
|
||||
await lib_plankton.session.end(session.key);
|
||||
return Promise.resolve(
|
||||
{
|
||||
"status_code": 200,
|
||||
"data": null,
|
||||
}
|
||||
);
|
||||
return Promise.resolve({
|
||||
"status_code": 200,
|
||||
"data": null,
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -71,39 +52,66 @@ namespace _zeitbild.api
|
|||
"execution": async (stuff) => {
|
||||
const data : {
|
||||
token : string;
|
||||
userinfo : lib_plankton.auth.oidc.type_userinfo;
|
||||
userinfo : {
|
||||
name : (null | string);
|
||||
email : (null | string);
|
||||
};
|
||||
redirect_uri_template : string;
|
||||
} = await _zeitbild.auth.oidc_handle_authorization_callback(
|
||||
(stuff.headers["Cookie"] ?? stuff.headers["cookie"] ?? null),
|
||||
stuff.query_parameters
|
||||
);
|
||||
|
||||
const user = await _zeitbild.auth.oidc_adapt_user(data.userinfo);
|
||||
|
||||
const session_key : string = await lib_plankton.session.begin(
|
||||
user.object.name,
|
||||
{
|
||||
"data": {
|
||||
"oidc_token": data.token,
|
||||
}
|
||||
}
|
||||
);
|
||||
return Promise.resolve(
|
||||
{
|
||||
"status_code": 200,
|
||||
"data": lib_plankton.string.coin(
|
||||
"<html><head><meta http-equiv=\"refresh\" content=\"0; url={{url}}\" /></head><body></body></html>",
|
||||
if (data.userinfo.name === null) {
|
||||
return Promise.reject(
|
||||
new Error(
|
||||
"IDP did not return user name"
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
await _zeitbild.service.user.add(
|
||||
{
|
||||
"url": lib_plankton.string.coin(
|
||||
data.redirect_uri_template,
|
||||
{
|
||||
"session_key": session_key,
|
||||
}
|
||||
),
|
||||
"name": data.userinfo.name,
|
||||
"email_address": data.userinfo.email,
|
||||
"dav_token": null,
|
||||
}
|
||||
),
|
||||
);
|
||||
lib_plankton.log.info(
|
||||
"user_provisioned",
|
||||
{
|
||||
"name": data.userinfo.name,
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
catch (error) {
|
||||
// do nothing
|
||||
}
|
||||
const session_key : string = await lib_plankton.session.begin(
|
||||
data.userinfo.name,
|
||||
{
|
||||
"data": {
|
||||
"oidc_token": data.token,
|
||||
}
|
||||
}
|
||||
);
|
||||
return Promise.resolve(
|
||||
{
|
||||
"status_code": 200,
|
||||
"data": lib_plankton.string.coin(
|
||||
"<html><head><meta http-equiv=\"refresh\" content=\"0; url={{url}}\" /></head><body></body></html>",
|
||||
{
|
||||
"url": lib_plankton.string.coin(
|
||||
data.redirect_uri_template,
|
||||
{
|
||||
"session_key": session_key,
|
||||
}
|
||||
),
|
||||
}
|
||||
),
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
export function register_session_status(
|
||||
rest_subject : lib_plankton.rest_http.type_rest
|
||||
) : void
|
||||
{
|
||||
register<
|
||||
null,
|
||||
{
|
||||
logged_in : boolean;
|
||||
name : (null | string);
|
||||
}
|
||||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.get,
|
||||
"/session/status",
|
||||
{
|
||||
"description": "gibt Information über den Nutzer aus",
|
||||
"output_schema": () => ({
|
||||
"nullable": false,
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"logged_in": {
|
||||
"nullable": false,
|
||||
"type": "boolean",
|
||||
},
|
||||
"name": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"logged_in",
|
||||
"name",
|
||||
],
|
||||
}),
|
||||
"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 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),
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,23 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
@ -49,11 +30,6 @@ namespace _zeitbild.api
|
|||
_zeitbild.api.register_session_begin(rest_subject);
|
||||
_zeitbild.api.register_session_end(rest_subject);
|
||||
_zeitbild.api.register_session_oidc(rest_subject);
|
||||
_zeitbild.api.register_session_status(rest_subject);
|
||||
}
|
||||
// groups
|
||||
{
|
||||
_zeitbild.api.register_group_list(rest_subject);
|
||||
}
|
||||
// user
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.api
|
||||
{
|
||||
|
|
|
|||
217
source/auth.ts
217
source/auth.ts
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.auth
|
||||
{
|
||||
|
|
@ -52,12 +33,10 @@ namespace _zeitbild.auth
|
|||
key : string
|
||||
) : string
|
||||
{
|
||||
if (_oidc_redict_uri_template_map === null)
|
||||
{
|
||||
if (_oidc_redict_uri_template_map === null) {
|
||||
throw (new Error("apparently not initialized yet"));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return _oidc_redict_uri_template_map.get(key);
|
||||
}
|
||||
}
|
||||
|
|
@ -69,8 +48,7 @@ namespace _zeitbild.auth
|
|||
) : Promise<void>
|
||||
{
|
||||
switch (_zeitbild.conf.get().authentication.kind) {
|
||||
case "internal":
|
||||
{
|
||||
case "internal": {
|
||||
_subject = lib_plankton.auth.internal.implementation_auth(
|
||||
{
|
||||
"password_image_chest": {
|
||||
|
|
@ -86,8 +64,7 @@ namespace _zeitbild.auth
|
|||
);
|
||||
break;
|
||||
}
|
||||
case "oidc":
|
||||
{
|
||||
case "oidc": {
|
||||
_subject_oidc = lib_plankton.auth.oidc.make(
|
||||
{
|
||||
"url_authorization": _zeitbild.conf.get().authentication.data.url_authorization,
|
||||
|
|
@ -100,7 +77,6 @@ namespace _zeitbild.auth
|
|||
"openid",
|
||||
"profile",
|
||||
"email",
|
||||
"groups",
|
||||
],
|
||||
"label": _zeitbild.conf.get().authentication.data.label,
|
||||
}
|
||||
|
|
@ -113,8 +89,7 @@ namespace _zeitbild.auth
|
|||
return Promise.resolve(undefined);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
|
|
@ -129,16 +104,12 @@ namespace _zeitbild.auth
|
|||
input : any
|
||||
) : Promise<{kind : string; data : any;}>
|
||||
{
|
||||
switch (_zeitbild.conf.get().authentication.kind)
|
||||
{
|
||||
case "oidc":
|
||||
{
|
||||
if ((_subject_oidc === null) || (_oidc_redict_uri_template_map === null))
|
||||
{
|
||||
switch (_zeitbild.conf.get().authentication.kind) {
|
||||
case "oidc": {
|
||||
if ((_subject_oidc === null) || (_oidc_redict_uri_template_map === null)) {
|
||||
throw (new Error("not initialized yet"));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
const stuff : {state : string; authorization_url : string;} = lib_plankton.auth.oidc.prepare_login(_subject_oidc);
|
||||
_oidc_redict_uri_template_map.set(
|
||||
stuff.state,
|
||||
|
|
@ -156,14 +127,11 @@ namespace _zeitbild.auth
|
|||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (_subject === null)
|
||||
{
|
||||
default: {
|
||||
if (_subject === null) {
|
||||
return Promise.reject(new Error("not initialized yet"));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return (
|
||||
_subject.login_prepare()
|
||||
.then(
|
||||
|
|
@ -188,21 +156,25 @@ namespace _zeitbild.auth
|
|||
) : Promise<
|
||||
{
|
||||
token : string;
|
||||
userinfo : lib_plankton.auth.oidc.type_userinfo;
|
||||
userinfo : {
|
||||
name : (null | string);
|
||||
email : (null | string);
|
||||
};
|
||||
redirect_uri_template : string;
|
||||
}
|
||||
>
|
||||
{
|
||||
if ((_subject_oidc === null) || (_oidc_redict_uri_template_map === null))
|
||||
{
|
||||
if ((_subject_oidc === null) || (_oidc_redict_uri_template_map === null)) {
|
||||
throw (new Error("not initialized yet"));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
const state : string = data["state"];
|
||||
const result : {
|
||||
token : string;
|
||||
userinfo : lib_plankton.auth.oidc.type_userinfo;
|
||||
userinfo : {
|
||||
name : (null | string);
|
||||
email : (null | string);
|
||||
};
|
||||
} = await lib_plankton.auth.oidc.handle_authorization_callback(
|
||||
_subject_oidc,
|
||||
cookie,
|
||||
|
|
@ -211,7 +183,10 @@ namespace _zeitbild.auth
|
|||
return Promise.resolve<
|
||||
{
|
||||
token : string;
|
||||
userinfo : lib_plankton.auth.oidc.type_userinfo;
|
||||
userinfo : {
|
||||
name : (null | string);
|
||||
email : (null | string);
|
||||
};
|
||||
redirect_uri_template : string;
|
||||
}
|
||||
>(
|
||||
|
|
@ -224,144 +199,4 @@ namespace _zeitbild.auth
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @todo switch for enabling/disabling auto provisioning
|
||||
*/
|
||||
export async function oidc_adapt_user(
|
||||
userinfo : lib_plankton.auth.oidc.type_userinfo
|
||||
)
|
||||
: Promise<
|
||||
{
|
||||
id : _zeitbild.type_user_id;
|
||||
object : _zeitbild.type_user_object;
|
||||
}
|
||||
>
|
||||
{
|
||||
if (userinfo.name === null)
|
||||
{
|
||||
return Promise.reject(new Error("IDP did not return user name"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// groups
|
||||
const group_ids : Array<_zeitbild.type_group_id> = await (async () => {
|
||||
const derive_name : ((group_name_raw : string) => string) = (
|
||||
(group_name_raw) => lib_plankton.string.coin(
|
||||
"auto-{{name_raw}}",
|
||||
{
|
||||
"name_raw": group_name_raw,
|
||||
}
|
||||
)
|
||||
);
|
||||
const derive_label : ((group_name_raw : string) => string) = (
|
||||
(group_name_raw) => lib_plankton.string.coin(
|
||||
"{{name_raw}}",
|
||||
{
|
||||
"name_raw": group_name_raw,
|
||||
}
|
||||
)
|
||||
);
|
||||
return Promise.all<_zeitbild.type_group_id>(
|
||||
(userinfo.groups ?? [])
|
||||
.map(
|
||||
async (group_name_raw) => {
|
||||
const group_name : string = derive_name(group_name_raw);
|
||||
const group_id_raw : (null | _zeitbild.type_group_id) = await (
|
||||
_zeitbild.repository.group.identify(group_name)
|
||||
.catch(() => Promise.resolve(null))
|
||||
);
|
||||
if (group_id_raw === null)
|
||||
{
|
||||
// create
|
||||
const group_id : _zeitbild.type_group_id = await _zeitbild.service.group.add(
|
||||
{
|
||||
"name": group_name,
|
||||
"label": derive_label(group_name_raw),
|
||||
}
|
||||
);
|
||||
lib_plankton.log.info(
|
||||
"zeitbild.oidc_adapt_user.auto_provisioned_group",
|
||||
{
|
||||
"id": group_id,
|
||||
"name": group_name,
|
||||
}
|
||||
);
|
||||
return group_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// update
|
||||
const group_id : _zeitbild.type_group_id = group_id_raw;
|
||||
await _zeitbild.service.group.change(
|
||||
group_id,
|
||||
{
|
||||
"name": group_name,
|
||||
"label": derive_label(group_name_raw),
|
||||
}
|
||||
);
|
||||
return group_id;
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}) ();
|
||||
|
||||
// user
|
||||
const user : {
|
||||
id : _zeitbild.type_user_id;
|
||||
object : _zeitbild.type_user_object;
|
||||
} = await (async () => {
|
||||
const user_id_raw : (null | _zeitbild.type_user_id) = await (
|
||||
_zeitbild.service.user.identify(userinfo.name as string)
|
||||
.catch(() => Promise.resolve(null))
|
||||
);
|
||||
if (user_id_raw === null)
|
||||
{
|
||||
// provision
|
||||
const user_object : _zeitbild.type_user_object = {
|
||||
"name": (userinfo.name as string),
|
||||
"groups": group_ids,
|
||||
"email_address": userinfo.email,
|
||||
"dav_token": null,
|
||||
};
|
||||
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.add(
|
||||
user_object
|
||||
);
|
||||
lib_plankton.log.info(
|
||||
"user_provisioned",
|
||||
{
|
||||
"id": user_id,
|
||||
"name": user_object.name,
|
||||
}
|
||||
);
|
||||
return {"id": user_id, "object": user_object};
|
||||
}
|
||||
else
|
||||
{
|
||||
// update
|
||||
const user_id : _zeitbild.type_user_id = user_id_raw;
|
||||
const user_object : _zeitbild.type_user_object = await _zeitbild.service.user.get(user_id);
|
||||
user_object.name = (userinfo.name as string);
|
||||
user_object.groups = group_ids;
|
||||
user_object.email_address = userinfo.email;
|
||||
await _zeitbild.service.user.change(
|
||||
user_id,
|
||||
user_object
|
||||
);
|
||||
lib_plankton.log.info(
|
||||
"user_updated",
|
||||
{
|
||||
"id": user_id,
|
||||
"name": user_object.name,
|
||||
}
|
||||
);
|
||||
return {"id": user_id, "object": user_object};
|
||||
}
|
||||
}) ();
|
||||
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.conf
|
||||
{
|
||||
|
|
@ -76,51 +57,7 @@ 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": [
|
||||
|
|
@ -251,13 +188,8 @@ namespace _zeitbild.conf
|
|||
"lifetime": {
|
||||
"nullable": false,
|
||||
"type": "integer",
|
||||
"default": 3600,
|
||||
},
|
||||
"prolongation": {
|
||||
"nullable": true,
|
||||
"type": "integer",
|
||||
"default": 300,
|
||||
},
|
||||
"default": 900
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
],
|
||||
|
|
@ -335,8 +267,7 @@ namespace _zeitbild.conf
|
|||
"url_token",
|
||||
"url_userinfo",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"backend_url_base"
|
||||
"client_secret"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.database
|
||||
{
|
||||
|
|
@ -24,7 +5,7 @@ namespace _zeitbild.database
|
|||
/**
|
||||
*/
|
||||
const _compatible_revisions : Array<string> = [
|
||||
"r6",
|
||||
"r4",
|
||||
];
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
@ -78,35 +59,30 @@ namespace _zeitbild.helpers
|
|||
|
||||
|
||||
/**
|
||||
* @todo timezone
|
||||
*/
|
||||
export function icalendar_dt_from_own_datetime(
|
||||
datetime : lib_plankton.pit.type_datetime
|
||||
) : lib_plankton.ical.type_dt
|
||||
{
|
||||
const datetime_normalized : lib_plankton.pit.type_datetime = lib_plankton.pit.to_datetime(
|
||||
lib_plankton.pit.from_datetime(datetime),
|
||||
{
|
||||
"timezone_shift": 0,
|
||||
}
|
||||
);
|
||||
return {
|
||||
"tzid": "UTC",
|
||||
"tzid": "Europe/Berlin",
|
||||
"value": {
|
||||
"date": {
|
||||
"year": datetime_normalized.date.year,
|
||||
"month": datetime_normalized.date.month,
|
||||
"day": datetime_normalized.date.day,
|
||||
"year": datetime.date.year,
|
||||
"month": datetime.date.month,
|
||||
"day": datetime.date.day,
|
||||
},
|
||||
"time": (
|
||||
(datetime_normalized.time === null)
|
||||
(datetime.time === null)
|
||||
?
|
||||
null
|
||||
:
|
||||
{
|
||||
"utc": true,
|
||||
"hour": datetime_normalized.time.hour,
|
||||
"minute": datetime_normalized.time.minute,
|
||||
"second": datetime_normalized.time.second,
|
||||
"hour": datetime.time.hour,
|
||||
"minute": datetime.time.minute,
|
||||
"second": datetime.time.second,
|
||||
}
|
||||
)
|
||||
},
|
||||
|
|
|
|||
199
source/logic.ts
199
source/logic.ts
|
|
@ -1,199 +0,0 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
namespace _zeitbild
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function access_level_to_string(
|
||||
access_level : _zeitbild.enum_access_level
|
||||
)
|
||||
: string
|
||||
{
|
||||
switch (access_level)
|
||||
{
|
||||
case _zeitbild.enum_access_level.none: {return "none";}
|
||||
case _zeitbild.enum_access_level.view: {return "view";}
|
||||
case _zeitbild.enum_access_level.edit: {return "edit";}
|
||||
case _zeitbild.enum_access_level.admin: {return "admin";}
|
||||
default: {throw (new Error("invalid access level: " + String(access_level)));}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function access_level_from_string(
|
||||
representation : string
|
||||
)
|
||||
: _zeitbild.enum_access_level
|
||||
{
|
||||
switch (representation)
|
||||
{
|
||||
case "none": {return _zeitbild.enum_access_level.none;}
|
||||
case "view": {return _zeitbild.enum_access_level.view;}
|
||||
case "edit": {return _zeitbild.enum_access_level.edit;}
|
||||
case "admin": {return _zeitbild.enum_access_level.admin;}
|
||||
default: {throw (new Error("invalid encoded access level: " + String(representation)));}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function access_level_order(
|
||||
x : _zeitbild.enum_access_level,
|
||||
y : _zeitbild.enum_access_level
|
||||
)
|
||||
: boolean
|
||||
{
|
||||
const list : Array<_zeitbild.enum_access_level> = [
|
||||
_zeitbild.enum_access_level.none,
|
||||
_zeitbild.enum_access_level.view,
|
||||
_zeitbild.enum_access_level.edit,
|
||||
_zeitbild.enum_access_level.admin,
|
||||
];
|
||||
return (list.indexOf(x) <= list.indexOf(y));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function access_level_determine_raw(
|
||||
public_ : boolean,
|
||||
access_level_attributed : (
|
||||
null
|
||||
|
|
||||
{
|
||||
default : _zeitbild.enum_access_level,
|
||||
group : Array<_zeitbild.enum_access_level>;
|
||||
user : (null | _zeitbild.enum_access_level);
|
||||
}
|
||||
)
|
||||
)
|
||||
: _zeitbild.enum_access_level
|
||||
{
|
||||
return lib_plankton.call.convey(
|
||||
_zeitbild.enum_access_level.none,
|
||||
[
|
||||
// if public
|
||||
(x : _zeitbild.enum_access_level) => (
|
||||
public_
|
||||
?
|
||||
_zeitbild.enum_access_level.view
|
||||
:
|
||||
x
|
||||
),
|
||||
// if logged in
|
||||
(x : _zeitbild.enum_access_level) => (
|
||||
(access_level_attributed === null)
|
||||
?
|
||||
x
|
||||
:
|
||||
lib_plankton.call.convey(
|
||||
x,
|
||||
[
|
||||
// default
|
||||
(y : _zeitbild.enum_access_level) => access_level_attributed.default,
|
||||
// group
|
||||
(y : _zeitbild.enum_access_level) => (
|
||||
lib_plankton.call.null_prop(
|
||||
lib_plankton.list.max<_zeitbild.enum_access_level, _zeitbild.enum_access_level>(
|
||||
access_level_attributed.group,
|
||||
z => z,
|
||||
{
|
||||
"compare_value": _zeitbild.access_level_order,
|
||||
}
|
||||
),
|
||||
z => z.value
|
||||
)
|
||||
??
|
||||
y
|
||||
),
|
||||
// user
|
||||
(y : _zeitbild.enum_access_level) => (
|
||||
(access_level_attributed.user === null)
|
||||
?
|
||||
y
|
||||
:
|
||||
access_level_attributed.user
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function access_level_determine(
|
||||
calendar_object : _zeitbild.type_calendar_object,
|
||||
user : (
|
||||
null
|
||||
|
|
||||
{
|
||||
id : _zeitbild.type_user_id;
|
||||
object : _zeitbild.type_user_object;
|
||||
}
|
||||
)
|
||||
)
|
||||
: _zeitbild.enum_access_level
|
||||
{
|
||||
return access_level_determine_raw(
|
||||
calendar_object.access.public,
|
||||
(
|
||||
(user === null)
|
||||
?
|
||||
null
|
||||
:
|
||||
{
|
||||
"default": calendar_object.access.default_level,
|
||||
"group": (
|
||||
user.object.groups
|
||||
.map<(null | _zeitbild.enum_access_level)>(
|
||||
group_id => (
|
||||
calendar_object.access.attributed_group.has(group_id)
|
||||
?
|
||||
calendar_object.access.attributed_group.get(group_id)
|
||||
:
|
||||
null
|
||||
)
|
||||
)
|
||||
.filter(
|
||||
x => (x !== null)
|
||||
)
|
||||
),
|
||||
"user": (
|
||||
lib_plankton.call.try_catch_wrap<_zeitbild.enum_access_level>(
|
||||
() => calendar_object.access.attributed_user.get(user.id)
|
||||
).value
|
||||
)
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
247
source/main.ts
247
source/main.ts
|
|
@ -1,23 +1,162 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
*/
|
||||
type type_data = {
|
||||
users : Array<
|
||||
{
|
||||
id : int;
|
||||
name : string;
|
||||
email_address : string;
|
||||
dav_token : (null | string);
|
||||
password : string;
|
||||
}
|
||||
>;
|
||||
calendars : Array<
|
||||
{
|
||||
id : int;
|
||||
name : string;
|
||||
access : {
|
||||
public ?: boolean;
|
||||
default_level : ("none" | "view" | "edit" | "admin");
|
||||
attributed : Array<
|
||||
{
|
||||
user_id : int;
|
||||
level : ("none" | "view" | "edit" | "admin");
|
||||
}
|
||||
>;
|
||||
};
|
||||
resource : (
|
||||
{
|
||||
kind : "local";
|
||||
data : {
|
||||
events : Array<
|
||||
_zeitbild.type_event_object
|
||||
>
|
||||
};
|
||||
}
|
||||
|
|
||||
{
|
||||
kind : "ics_feed";
|
||||
data : {
|
||||
url : string;
|
||||
from_fucked_up_wordpress ?: boolean;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
async function data_init(
|
||||
data : type_data
|
||||
) : Promise<void>
|
||||
{
|
||||
let track : {
|
||||
user : Record<
|
||||
int,
|
||||
_zeitbild.type_user_id
|
||||
>;
|
||||
calendar : Record<
|
||||
int,
|
||||
_zeitbild.type_user_id
|
||||
>;
|
||||
} = {
|
||||
"user": {},
|
||||
"calendar": {},
|
||||
};
|
||||
for await (const user_raw of data.users)
|
||||
{
|
||||
const user_object : _zeitbild.type_user_object = {
|
||||
"name": user_raw.name,
|
||||
"email_address": user_raw.email_address,
|
||||
"dav_token": user_raw.dav_token,
|
||||
};
|
||||
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.add(
|
||||
user_object
|
||||
);
|
||||
await _zeitbild.service.auth_internal.set(
|
||||
user_raw.name,
|
||||
user_raw.password
|
||||
);
|
||||
track.user[user_raw.id] = user_id;
|
||||
}
|
||||
for await (const calendar_raw of data.calendars)
|
||||
{
|
||||
let resource_object : _zeitbild.type_resource_object;
|
||||
let resource_id : _zeitbild.type_resource_id;
|
||||
switch (calendar_raw.resource.kind)
|
||||
{
|
||||
case "local":
|
||||
{
|
||||
resource_object = {
|
||||
"kind": "local",
|
||||
"data": {
|
||||
"event_ids": [],
|
||||
}
|
||||
};
|
||||
resource_id = await _zeitbild.service.resource.add(
|
||||
resource_object
|
||||
);
|
||||
/*const event_ids : Array<_zeitbild.type_local_resource_event_id> = */await Promise.all(
|
||||
calendar_raw.resource.data.events
|
||||
.map(
|
||||
(event_raw : _zeitbild.type_event_object) => _zeitbild.service.resource.event_add(resource_id, event_raw)
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "ics_feed":
|
||||
{
|
||||
resource_object = {
|
||||
"kind": "ics_feed",
|
||||
"data": {
|
||||
"url": calendar_raw.resource.data.url,
|
||||
"from_fucked_up_wordpress": (calendar_raw.resource.data.from_fucked_up_wordpress ?? false),
|
||||
}
|
||||
};
|
||||
resource_id = await _zeitbild.service.resource.add(
|
||||
resource_object
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const calendar_object : _zeitbild.type_calendar_object =
|
||||
{
|
||||
"name": calendar_raw.name,
|
||||
"access": {
|
||||
"public": (calendar_raw.access.public ?? false),
|
||||
"default_level": _zeitbild.value_object.access_level.from_string(calendar_raw.access.default_level),
|
||||
"attributed": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
calendar_raw.access.attributed
|
||||
.map(
|
||||
(entry) => ({
|
||||
"key": track.user[entry.user_id],
|
||||
"value": _zeitbild.value_object.access_level.from_string(entry.level),
|
||||
})
|
||||
)
|
||||
),
|
||||
}
|
||||
)
|
||||
),
|
||||
},
|
||||
"resource_id": resource_id,
|
||||
};
|
||||
const calendar_id : _zeitbild.type_calendar_id = await _zeitbild.service.calendar.add(
|
||||
calendar_object
|
||||
);
|
||||
track.calendar[calendar_raw.id] = calendar_id;
|
||||
}
|
||||
return Promise.resolve<void>(undefined);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
@ -69,8 +208,8 @@ async function main(
|
|||
"description": "conf-expose"
|
||||
},
|
||||
{
|
||||
"name": "sample",
|
||||
"description": "sample"
|
||||
"name": "fill",
|
||||
"description": "fill"
|
||||
},
|
||||
{
|
||||
"name": "help",
|
||||
|
|
@ -172,46 +311,6 @@ 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;
|
||||
|
|
@ -248,10 +347,8 @@ async function main(
|
|||
);
|
||||
}
|
||||
else {
|
||||
switch (args["action"])
|
||||
{
|
||||
default:
|
||||
{
|
||||
switch (args["action"]) {
|
||||
default: {
|
||||
lib_plankton.log.error(
|
||||
"main_invalid_action",
|
||||
{
|
||||
|
|
@ -260,8 +357,7 @@ async function main(
|
|||
);
|
||||
break;
|
||||
}
|
||||
case "conf-schema":
|
||||
{
|
||||
case "conf-schema": {
|
||||
process.stdout.write(
|
||||
JSON.stringify(
|
||||
_zeitbild.conf.schema(),
|
||||
|
|
@ -273,8 +369,7 @@ async function main(
|
|||
);
|
||||
break;
|
||||
}
|
||||
case "conf-expose":
|
||||
{
|
||||
case "conf-expose": {
|
||||
process.stdout.write(
|
||||
JSON.stringify(
|
||||
_zeitbild.conf.get(),
|
||||
|
|
@ -286,8 +381,7 @@ async function main(
|
|||
);
|
||||
break;
|
||||
}
|
||||
case "api-doc":
|
||||
{
|
||||
case "api-doc": {
|
||||
lib_plankton.log.set_main_logger([]);
|
||||
const rest_subject : lib_plankton.rest_http.type_rest = _zeitbild.api.make();
|
||||
process.stdout.write(
|
||||
|
|
@ -299,9 +393,8 @@ async function main(
|
|||
);
|
||||
break;
|
||||
}
|
||||
case "sample":
|
||||
{
|
||||
await _zeitbild.sample.init(
|
||||
case "fill": {
|
||||
await data_init(
|
||||
lib_plankton.json.decode(
|
||||
await lib_plankton.file.read(args.data_path)
|
||||
)
|
||||
|
|
@ -309,23 +402,16 @@ async function main(
|
|||
process.stdout.write("-- done\n");
|
||||
break;
|
||||
}
|
||||
case "serve":
|
||||
{
|
||||
case "serve": {
|
||||
// prepare database
|
||||
await _zeitbild.database.check();
|
||||
|
||||
/**
|
||||
* @todo clear old sessions
|
||||
*/
|
||||
|
||||
await lib_plankton.session.setup(
|
||||
{
|
||||
"data_chest": (
|
||||
_zeitbild.conf.get().session_management.in_memory
|
||||
?
|
||||
lib_plankton.storage.memory.implementation_chest<lib_plankton.session.type_session>({})
|
||||
:
|
||||
lib_plankton.call.convey(
|
||||
? lib_plankton.storage.memory.implementation_chest<lib_plankton.session.type_session>({})
|
||||
: lib_plankton.call.convey(
|
||||
lib_plankton.storage.sql_table_common.chest(
|
||||
{
|
||||
"database_implementation": _zeitbild.database.get_implementation(),
|
||||
|
|
@ -347,7 +433,6 @@ async function main(
|
|||
)
|
||||
),
|
||||
"default_lifetime": _zeitbild.conf.get().session_management.lifetime,
|
||||
"default_prolongation": _zeitbild.conf.get().session_management.prolongation,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.repository.auth_internal
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,85 +1,23 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.repository.calendar
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_core_row = {
|
||||
name : string;
|
||||
hue : int;
|
||||
access_public : boolean;
|
||||
access_level_default : int;
|
||||
resource_id : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_access_attributed_group_row = {
|
||||
// calendar_id : int;
|
||||
group_id : int;
|
||||
level : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_access_attributed_group_preview = {
|
||||
group_id : int;
|
||||
level : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_access_attributed_user_row = {
|
||||
// calendar_id : int;
|
||||
user_id : int;
|
||||
level : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_access_attributed_user_preview = {
|
||||
user_id : int;
|
||||
level : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_dispersal = {
|
||||
core_row : type_core_row;
|
||||
access_attributed_group_rows : Array<type_access_attributed_group_row>;
|
||||
access_attributed_user_rows : Array<type_access_attributed_user_row>;
|
||||
core_row : Record<
|
||||
string,
|
||||
any
|
||||
>;
|
||||
access_attributed_rows : Array<
|
||||
Record<
|
||||
string,
|
||||
any
|
||||
>
|
||||
>;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
const hue_scaling : int = 0xFFFF;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
var _core_store : (
|
||||
|
|
@ -97,22 +35,7 @@ namespace _zeitbild.repository.calendar
|
|||
|
||||
/**
|
||||
*/
|
||||
var _access_attributed_group_chest : (
|
||||
null
|
||||
|
|
||||
lib_plankton.storage.type_chest<
|
||||
Array<any>,
|
||||
Record<string, any>,
|
||||
lib_plankton.database.type_description_create_table,
|
||||
lib_plankton.storage.sql_table_common.type_sql_table_common_search_term,
|
||||
Record<string, any>
|
||||
>
|
||||
) = null;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
var _access_attributed_user_chest : (
|
||||
var _access_attributed_chest : (
|
||||
null
|
||||
|
|
||||
lib_plankton.storage.type_chest<
|
||||
|
|
@ -128,8 +51,7 @@ namespace _zeitbild.repository.calendar
|
|||
/**
|
||||
*/
|
||||
function get_core_store(
|
||||
)
|
||||
: lib_plankton.storage.type_store<
|
||||
) : lib_plankton.storage.type_store<
|
||||
_zeitbild.type_calendar_id,
|
||||
Record<string, any>,
|
||||
{},
|
||||
|
|
@ -137,8 +59,7 @@ namespace _zeitbild.repository.calendar
|
|||
Record<string, any>
|
||||
>
|
||||
{
|
||||
if (_core_store === null)
|
||||
{
|
||||
if (_core_store === null) {
|
||||
_core_store = lib_plankton.storage.sql_table_autokey_store(
|
||||
{
|
||||
"database_implementation": _zeitbild.database.get_implementation(),
|
||||
|
|
@ -147,8 +68,7 @@ namespace _zeitbild.repository.calendar
|
|||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// do nothing
|
||||
}
|
||||
return _core_store;
|
||||
|
|
@ -157,7 +77,7 @@ namespace _zeitbild.repository.calendar
|
|||
|
||||
/**
|
||||
*/
|
||||
function get_access_attributed_group_chest(
|
||||
function get_access_attributed_chest(
|
||||
) : lib_plankton.storage.type_chest<
|
||||
Array<any>,
|
||||
Record<string, any>,
|
||||
|
|
@ -166,51 +86,19 @@ namespace _zeitbild.repository.calendar
|
|||
Record<string, any>
|
||||
>
|
||||
{
|
||||
if (_access_attributed_group_chest === null)
|
||||
{
|
||||
_access_attributed_group_chest = lib_plankton.storage.sql_table_common.chest(
|
||||
if (_access_attributed_chest === null) {
|
||||
_access_attributed_chest = lib_plankton.storage.sql_table_common.chest(
|
||||
{
|
||||
"database_implementation": _zeitbild.database.get_implementation(),
|
||||
"table_name": "calendar_access_attributed_group",
|
||||
"key_names": ["calendar_id","group_id"],
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
return _access_attributed_group_chest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function get_access_attributed_user_chest(
|
||||
)
|
||||
: lib_plankton.storage.type_chest<
|
||||
Array<any>,
|
||||
Record<string, any>,
|
||||
lib_plankton.database.type_description_create_table,
|
||||
lib_plankton.storage.sql_table_common.type_sql_table_common_search_term,
|
||||
Record<string, any>
|
||||
>
|
||||
{
|
||||
if (_access_attributed_user_chest === null)
|
||||
{
|
||||
_access_attributed_user_chest = lib_plankton.storage.sql_table_common.chest(
|
||||
{
|
||||
"database_implementation": _zeitbild.database.get_implementation(),
|
||||
"table_name": "calendar_access_attributed_user",
|
||||
"table_name": "calendar_access_attributed",
|
||||
"key_names": ["calendar_id","user_id"],
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// do nothing
|
||||
}
|
||||
return _access_attributed_user_chest;
|
||||
}
|
||||
return _access_attributed_chest;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -252,29 +140,17 @@ namespace _zeitbild.repository.calendar
|
|||
*/
|
||||
function encode(
|
||||
object : _zeitbild.type_calendar_object
|
||||
)
|
||||
: type_dispersal
|
||||
) : type_dispersal
|
||||
{
|
||||
return {
|
||||
"core_row": {
|
||||
"name": object.name,
|
||||
"hue": Math.floor(object.hue * hue_scaling),
|
||||
"access_public": object.access.public,
|
||||
"access_level_default": encode_access_level(object.access.default_level),
|
||||
"resource_id": object.resource_id,
|
||||
},
|
||||
"access_attributed_group_rows": (
|
||||
lib_plankton.map.dump(object.access.attributed_group)
|
||||
.map(
|
||||
({"key": group_id, "value": level}) => ({
|
||||
// "calendar_id": calendar_id,
|
||||
"group_id": group_id,
|
||||
"level": encode_access_level(level),
|
||||
})
|
||||
)
|
||||
),
|
||||
"access_attributed_user_rows": (
|
||||
lib_plankton.map.dump(object.access.attributed_user)
|
||||
"access_attributed_rows": (
|
||||
lib_plankton.map.dump(object.access.attributed)
|
||||
.map(
|
||||
({"key": user_id, "value": level}) => ({
|
||||
// "calendar_id": calendar_id,
|
||||
|
|
@ -291,47 +167,24 @@ namespace _zeitbild.repository.calendar
|
|||
*/
|
||||
function decode(
|
||||
dispersal : type_dispersal
|
||||
)
|
||||
: _zeitbild.type_calendar_object
|
||||
) : _zeitbild.type_calendar_object
|
||||
{
|
||||
return {
|
||||
"name": dispersal.core_row.name,
|
||||
"hue": (dispersal.core_row.hue / hue_scaling),
|
||||
"name": dispersal.core_row["name"],
|
||||
"access": {
|
||||
"public": dispersal.core_row.access_public,
|
||||
"default_level": decode_access_level(dispersal.core_row.access_level_default),
|
||||
"attributed_group": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make<_zeitbild.type_group_id, _zeitbild.enum_access_level>(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
dispersal.access_attributed_group_rows
|
||||
.map(
|
||||
(access_attributed_group_row) => ({
|
||||
// "calendar_id": access_attributed_group_row["calendar_id"],
|
||||
// "key": access_attributed_group_row["preview"]["user_id"],
|
||||
"key": access_attributed_group_row.group_id,
|
||||
// "value": decode_access_level(access_attributed_group_row["preview"]["level"]),
|
||||
"value": decode_access_level(access_attributed_group_row.level),
|
||||
})
|
||||
)
|
||||
),
|
||||
}
|
||||
)
|
||||
),
|
||||
"attributed_user": lib_plankton.map.hashmap.implementation_map(
|
||||
"public": dispersal.core_row["access_public"],
|
||||
"default_level": decode_access_level(dispersal.core_row["access_level_default"]),
|
||||
"attributed": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make<_zeitbild.type_user_id, _zeitbild.enum_access_level>(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
dispersal.access_attributed_user_rows
|
||||
dispersal.access_attributed_rows
|
||||
.map(
|
||||
(access_attributed_user_row) => ({
|
||||
// "calendar_id": access_attributed_user_row["calendar_id"],
|
||||
// "key": access_attributed_user_row["preview"]["user_id"],
|
||||
"key": access_attributed_user_row.user_id,
|
||||
// "value": decode_access_level(access_attributed_user_row["preview"]["level"]),
|
||||
"value": decode_access_level(access_attributed_user_row.level),
|
||||
(access_attributed_row) => ({
|
||||
// "calendar_id": access_attributed_row["calendar_id"],
|
||||
"key": access_attributed_row["preview"]["user_id"],
|
||||
"value": decode_access_level(access_attributed_row["preview"]["level"]),
|
||||
})
|
||||
)
|
||||
),
|
||||
|
|
@ -339,74 +192,45 @@ namespace _zeitbild.repository.calendar
|
|||
)
|
||||
),
|
||||
},
|
||||
"resource_id": dispersal.core_row.resource_id,
|
||||
"resource_id": dispersal.core_row["resource_id"],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function read(
|
||||
export function read(
|
||||
id : _zeitbild.type_calendar_id
|
||||
)
|
||||
: Promise<_zeitbild.type_calendar_object>
|
||||
) : Promise<_zeitbild.type_calendar_object>
|
||||
{
|
||||
const core_row : type_core_row = ((await get_core_store().read(id)) as type_core_row);
|
||||
const access_attributed_group_rows : Array<type_access_attributed_group_row> = await (
|
||||
get_access_attributed_group_chest().search(
|
||||
{
|
||||
"expression": "(calendar_id = $calendar_id)",
|
||||
"arguments": {
|
||||
"calendar_id": id,
|
||||
}
|
||||
}
|
||||
)
|
||||
return (
|
||||
get_core_store().read(id)
|
||||
.then(
|
||||
(hits) => Promise.resolve<Array<type_access_attributed_group_row>>(
|
||||
hits
|
||||
.map(
|
||||
hit => (
|
||||
{
|
||||
// "calendar_id": null,
|
||||
"group_id": hit.preview.group_id,
|
||||
"level": hit.preview.level,
|
||||
(core_row) => (
|
||||
get_access_attributed_chest().search(
|
||||
{
|
||||
"expression": "(calendar_id = $calendar_id)",
|
||||
"arguments": {
|
||||
"calendar_id": id,
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(
|
||||
(access_attributed_rows) => Promise.resolve<type_dispersal>(
|
||||
{
|
||||
"core_row": core_row,
|
||||
"access_attributed_rows": access_attributed_rows,
|
||||
}
|
||||
)
|
||||
)
|
||||
.then(
|
||||
(dispersal) => Promise.resolve<_zeitbild.type_calendar_object>(
|
||||
decode(dispersal)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
const access_attributed_user_rows : Array<type_access_attributed_user_row> = await (
|
||||
get_access_attributed_user_chest().search(
|
||||
{
|
||||
"expression": "(calendar_id = $calendar_id)",
|
||||
"arguments": {
|
||||
"calendar_id": id,
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(
|
||||
(hits) => Promise.resolve<Array<type_access_attributed_user_row>>(
|
||||
hits
|
||||
.map(
|
||||
hit => (
|
||||
{
|
||||
// "calendar_id": null,
|
||||
"user_id": hit.preview.user_id,
|
||||
"level": hit.preview.level,
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
const dispersal : type_dispersal = {
|
||||
"core_row": core_row,
|
||||
"access_attributed_group_rows": access_attributed_group_rows,
|
||||
"access_attributed_user_rows": access_attributed_user_rows,
|
||||
};
|
||||
const calendar_object : _zeitbild.type_calendar_object = decode(dispersal);
|
||||
return calendar_object;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -421,18 +245,10 @@ namespace _zeitbild.repository.calendar
|
|||
const calendar_id : _zeitbild.type_calendar_id = await core_store.create(
|
||||
dispersal.core_row
|
||||
);
|
||||
for await (const access_attributed_group_row of dispersal.access_attributed_group_rows)
|
||||
{
|
||||
get_access_attributed_group_chest().write(
|
||||
[calendar_id, access_attributed_group_row.group_id],
|
||||
{"level": access_attributed_group_row.level}
|
||||
);
|
||||
}
|
||||
for await (const access_attributed_user_row of dispersal.access_attributed_user_rows)
|
||||
{
|
||||
get_access_attributed_user_chest().write(
|
||||
[calendar_id, access_attributed_user_row.user_id],
|
||||
{"level": access_attributed_user_row.level}
|
||||
for await (const access_attributed_row of dispersal.access_attributed_rows) {
|
||||
get_access_attributed_chest().write(
|
||||
[calendar_id, access_attributed_row["user_id"]],
|
||||
{"level": access_attributed_row["level"]}
|
||||
);
|
||||
}
|
||||
await lib_plankton.cache.clear(_zeitbild.cache_regular);
|
||||
|
|
@ -456,117 +272,44 @@ namespace _zeitbild.repository.calendar
|
|||
dispersal.core_row
|
||||
);
|
||||
}
|
||||
// attributed:group
|
||||
// attributed access
|
||||
{
|
||||
const access_attributed_group_chest = get_access_attributed_group_chest();
|
||||
const hits : Array<{key : Array<any>; preview : type_access_attributed_group_row;}> = (
|
||||
(await access_attributed_group_chest.search(
|
||||
{
|
||||
"expression": "(calendar_id = $calendar_id)",
|
||||
"arguments": {
|
||||
"calendar_id": calendar_id,
|
||||
}
|
||||
const access_attributed_chest = get_access_attributed_chest();
|
||||
const hits : Array<Record<string, any>> = await access_attributed_chest.search(
|
||||
{
|
||||
"expression": "(calendar_id = $calendar_id)",
|
||||
"arguments": {
|
||||
"calendar_id": calendar_id,
|
||||
}
|
||||
))
|
||||
.map(
|
||||
hit => (
|
||||
{
|
||||
"key": hit.key,
|
||||
"preview": {
|
||||
"group_id": hit.preview["group_id"],
|
||||
"level": hit.preview["level"],
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
);
|
||||
const contrast = lib_plankton.list.contrast<
|
||||
{key : Array<any>; preview : type_access_attributed_group_row;},
|
||||
type_access_attributed_group_row
|
||||
Record<string, any>,
|
||||
Record<string, any>
|
||||
>(
|
||||
hits,
|
||||
hit => hit.preview.group_id.toFixed(0),
|
||||
dispersal.access_attributed_group_rows,
|
||||
row => row.group_id.toFixed(0)
|
||||
hit => hit["user_id"],
|
||||
dispersal.access_attributed_rows,
|
||||
row => row["user_id"]
|
||||
);
|
||||
// delete
|
||||
for await (const entry of contrast.only_left)
|
||||
{
|
||||
await access_attributed_group_chest.delete(
|
||||
[calendar_id, entry.left.preview.group_id]
|
||||
for await (const entry of contrast.only_left) {
|
||||
await access_attributed_chest.delete(
|
||||
[calendar_id, entry.left["user_id"]]
|
||||
);
|
||||
}
|
||||
// update
|
||||
for await (const entry of contrast.both)
|
||||
{
|
||||
await access_attributed_group_chest.write(
|
||||
[calendar_id, entry.right.group_id],
|
||||
{"level": entry.right.level}
|
||||
for await (const entry of contrast.both) {
|
||||
await access_attributed_chest.write(
|
||||
[calendar_id, entry.right["user_id"]],
|
||||
{"level": entry.right["level"]}
|
||||
);
|
||||
}
|
||||
// create
|
||||
for await (const entry of contrast.only_right)
|
||||
{
|
||||
await access_attributed_group_chest.write(
|
||||
[calendar_id, entry.right.group_id],
|
||||
{"level": entry.right.level}
|
||||
);
|
||||
}
|
||||
}
|
||||
// attributed:user
|
||||
{
|
||||
const access_attributed_user_chest = get_access_attributed_user_chest();
|
||||
const hits : Array<{key : Array<any>; preview : type_access_attributed_user_row;}> = (
|
||||
(await access_attributed_user_chest.search(
|
||||
{
|
||||
"expression": "(calendar_id = $calendar_id)",
|
||||
"arguments": {
|
||||
"calendar_id": calendar_id,
|
||||
}
|
||||
}
|
||||
))
|
||||
.map(
|
||||
hit => (
|
||||
{
|
||||
"key": hit.key,
|
||||
"preview": {
|
||||
"user_id": hit.preview["user_id"],
|
||||
"level": hit.preview["level"],
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
const contrast = lib_plankton.list.contrast<
|
||||
{key : Array<any>; preview : type_access_attributed_user_row;},
|
||||
type_access_attributed_user_row
|
||||
>(
|
||||
hits,
|
||||
hit => hit.preview.user_id.toFixed(0),
|
||||
dispersal.access_attributed_user_rows,
|
||||
row => row.user_id.toFixed(0)
|
||||
);
|
||||
// delete
|
||||
for await (const entry of contrast.only_left)
|
||||
{
|
||||
await access_attributed_user_chest.delete(
|
||||
[calendar_id, entry.left.preview.user_id]
|
||||
);
|
||||
}
|
||||
// update
|
||||
for await (const entry of contrast.both)
|
||||
{
|
||||
await access_attributed_user_chest.write(
|
||||
[calendar_id, entry.right.user_id],
|
||||
{"level": entry.right.level}
|
||||
);
|
||||
}
|
||||
// create
|
||||
for await (const entry of contrast.only_right)
|
||||
{
|
||||
await access_attributed_user_chest.write(
|
||||
[calendar_id, entry.right.user_id],
|
||||
{"level": entry.right.level}
|
||||
for await (const entry of contrast.only_right) {
|
||||
await access_attributed_chest.write(
|
||||
[calendar_id, entry.right["user_id"]],
|
||||
{"level": entry.right["level"]}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -577,25 +320,17 @@ namespace _zeitbild.repository.calendar
|
|||
|
||||
/**
|
||||
* @todo remove events from resource?
|
||||
* @todo remove resource
|
||||
*/
|
||||
export async function delete_(
|
||||
calendar_id : _zeitbild.type_calendar_id
|
||||
)
|
||||
: Promise<void>
|
||||
) : Promise<void>
|
||||
{
|
||||
await lib_plankton.cache.clear(_zeitbild.cache_regular);
|
||||
const core_store = get_core_store();
|
||||
const access_attributed_user_chest = get_access_attributed_user_chest();
|
||||
// attributed:user
|
||||
const access_attributed_chest = get_access_attributed_chest();
|
||||
// attributed access
|
||||
{
|
||||
const chest = get_access_attributed_user_chest();
|
||||
const hits : Array<
|
||||
{
|
||||
key : Array<any>;
|
||||
preview : Record<string, any>;
|
||||
}
|
||||
> = await chest.search(
|
||||
const hits : Array<Record<string, any>> = await access_attributed_chest.search(
|
||||
{
|
||||
"expression": "(calendar_id = $calendar_id)",
|
||||
"arguments": {
|
||||
|
|
@ -603,30 +338,10 @@ namespace _zeitbild.repository.calendar
|
|||
}
|
||||
}
|
||||
);
|
||||
for (const hit of hits)
|
||||
{
|
||||
await chest.delete(hit.key);
|
||||
}
|
||||
}
|
||||
// attributed:group
|
||||
{
|
||||
const chest = get_access_attributed_group_chest();
|
||||
const hits : Array<
|
||||
{
|
||||
key : Array<any>;
|
||||
preview : Record<string, any>;
|
||||
}
|
||||
> = await chest.search(
|
||||
{
|
||||
"expression": "(calendar_id = $calendar_id)",
|
||||
"arguments": {
|
||||
"calendar_id": calendar_id,
|
||||
}
|
||||
}
|
||||
);
|
||||
for (const hit of hits)
|
||||
{
|
||||
await chest.delete(hit.key);
|
||||
for await (const hit of hits) {
|
||||
await access_attributed_chest.delete(
|
||||
[calendar_id, hit["user_id"]]
|
||||
);
|
||||
}
|
||||
}
|
||||
// core
|
||||
|
|
@ -644,168 +359,93 @@ namespace _zeitbild.repository.calendar
|
|||
type type_overview_entry = {
|
||||
id : _zeitbild.type_calendar_id;
|
||||
name : string;
|
||||
hue : float;
|
||||
access_level : _zeitbild.enum_access_level;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @todo caching
|
||||
*/
|
||||
export async function overview(
|
||||
user_id : (null | _zeitbild.type_user_id)
|
||||
)
|
||||
: Promise<
|
||||
) : Promise<
|
||||
Array<
|
||||
type_overview_entry
|
||||
>
|
||||
>
|
||||
{
|
||||
type type_data = {
|
||||
hits_core : Array<
|
||||
{
|
||||
key : int;
|
||||
preview : Record<string, any>;
|
||||
}
|
||||
>;
|
||||
hits_access_attributed_group : Array<
|
||||
{
|
||||
key : int;
|
||||
preview : Record<string, any>;
|
||||
}
|
||||
>;
|
||||
hits_access_attributed_user : Array<
|
||||
{
|
||||
key : int;
|
||||
preview : Record<string, any>;
|
||||
}
|
||||
>;
|
||||
};
|
||||
return lib_plankton.cache.get_complex<any, Array<type_overview_entry>>(
|
||||
_zeitbild.cache_regular,
|
||||
"calendar_overview",
|
||||
{
|
||||
"user_id": user_id,
|
||||
},
|
||||
60,
|
||||
async () => lib_plankton.call.convey(
|
||||
{
|
||||
"hits_core": await get_core_store().search(
|
||||
null,
|
||||
() => (
|
||||
lib_plankton.file.read("sql/calendar_overview.sql")
|
||||
.then(
|
||||
(template) => _zeitbild.database.get_implementation().query_free_get(
|
||||
{
|
||||
"expression": "TRUE",
|
||||
"arguments": {}
|
||||
"template": template,
|
||||
"arguments": {
|
||||
"user_id": user_id,
|
||||
}
|
||||
}
|
||||
),
|
||||
"hits_access_attributed_group": await get_access_attributed_group_chest().search(
|
||||
(user_id === null)
|
||||
?
|
||||
{
|
||||
"expression": "TRUE",
|
||||
"arguments": {}
|
||||
}
|
||||
:
|
||||
{
|
||||
"expression": "(group_id IN (SELECT group_id FROM user_groups WHERE (user_id = $user_id)))",
|
||||
"arguments": {"user_id": user_id}
|
||||
}
|
||||
),
|
||||
"hits_access_attributed_user": await get_access_attributed_user_chest().search(
|
||||
(user_id === null)
|
||||
?
|
||||
{
|
||||
"expression": "TRUE",
|
||||
"arguments": {}
|
||||
}
|
||||
:
|
||||
{
|
||||
"expression": "(user_id = $user_id)",
|
||||
"arguments": {"user_id": user_id}
|
||||
}
|
||||
),
|
||||
},
|
||||
[
|
||||
// transform
|
||||
(data : type_data) => data.hits_core.map(
|
||||
(hit_core) => {
|
||||
const calendar_id : _zeitbild.type_calendar_id = hit_core.key;
|
||||
return {
|
||||
"id": calendar_id,
|
||||
"name": hit_core.preview["name"],
|
||||
"hue": (hit_core.preview["hue"] / hue_scaling),
|
||||
"access_level": _zeitbild.access_level_determine_raw(
|
||||
hit_core.preview["access_public"],
|
||||
(
|
||||
(user_id === null)
|
||||
?
|
||||
null
|
||||
:
|
||||
{
|
||||
"default": decode_access_level(hit_core.preview["access_level_default"]),
|
||||
"group": lib_plankton.call.convey(
|
||||
data.hits_access_attributed_group,
|
||||
[
|
||||
(x : Array<{key : int; preview : Record<string, any>}>) => x.filter(
|
||||
hit_access_attributed_group => (
|
||||
(hit_access_attributed_group.preview.calendar_id === calendar_id)
|
||||
)
|
||||
),
|
||||
(x : Array<{key : int; preview : Record<string, any>}>) => x.map(
|
||||
hit_access_attributed_group => hit_access_attributed_group.preview.level
|
||||
),
|
||||
(x : Array<int>) => x.map(
|
||||
decode_access_level
|
||||
),
|
||||
]
|
||||
),
|
||||
"user": lib_plankton.call.convey(
|
||||
data.hits_access_attributed_user,
|
||||
[
|
||||
(x : Array<{key : int; preview : Record<string, any>}>) => x.filter(
|
||||
hits_access_attributed_user => (
|
||||
(hits_access_attributed_user.preview.calendar_id === calendar_id)
|
||||
)
|
||||
),
|
||||
(x : Array<{key : int; preview : Record<string, any>}>) => x.map(
|
||||
hits_access_attributed_user => hits_access_attributed_user.preview.level
|
||||
),
|
||||
(x : Array<int>) => x.map(
|
||||
decode_access_level
|
||||
),
|
||||
(x : Array<_zeitbild.enum_access_level>) => (x[0] ?? null),
|
||||
]
|
||||
),
|
||||
}
|
||||
)
|
||||
)
|
||||
.then(
|
||||
(rows) => Promise.resolve(
|
||||
lib_plankton.call.convey(
|
||||
rows,
|
||||
[
|
||||
(x : Array<Record<string, any>>) => x.map(
|
||||
(row : Record<string, any>) => ({
|
||||
"id": row["id"],
|
||||
"name": row["name"],
|
||||
/**
|
||||
* @todo unite with _zeitbild.service.calendar.get_access_level
|
||||
*/
|
||||
"access_level": decode_access_level(
|
||||
Math.max(
|
||||
(row["access_public"] ? 1 : 0),
|
||||
(
|
||||
(user_id === null)
|
||||
?
|
||||
0
|
||||
:
|
||||
(row["access_level_attributed"] ?? row["access_level_default"])
|
||||
)
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
(x : Array<type_overview_entry>) => x.filter(
|
||||
(row) => (
|
||||
! _zeitbild.value_object.access_level.order(
|
||||
row.access_level,
|
||||
_zeitbild.enum_access_level.none
|
||||
)
|
||||
)
|
||||
),
|
||||
};
|
||||
}
|
||||
),
|
||||
// only keep visible calendars
|
||||
(x : Array<type_overview_entry>) => x.filter(
|
||||
(row) => (
|
||||
! _zeitbild.access_level_order(
|
||||
row.access_level,
|
||||
_zeitbild.enum_access_level.none
|
||||
)
|
||||
(x : Array<type_overview_entry>) => lib_plankton.list.sorted<type_overview_entry>(
|
||||
x,
|
||||
{
|
||||
"compare_element": lib_plankton.order.order_lexicographic_pair_wrapped<type_overview_entry, _zeitbild.enum_access_level, int>(
|
||||
row => row.access_level,
|
||||
row => row.id,
|
||||
{
|
||||
"order_first": (a, b) => _zeitbild.value_object.access_level.order(b, a),
|
||||
"order_second": (a, b) => (a <= b)
|
||||
}
|
||||
),
|
||||
}
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
// sort by access level and name
|
||||
(x : Array<type_overview_entry>) => lib_plankton.list.sorted<type_overview_entry>(
|
||||
x,
|
||||
{
|
||||
"compare_element": lib_plankton.order.order_lexicographic_pair_wrapped<type_overview_entry, _zeitbild.enum_access_level, int>(
|
||||
row => row.access_level,
|
||||
row => row.id,
|
||||
{
|
||||
"order_first": (a, b) => _zeitbild.access_level_order(b, a),
|
||||
"order_second": (a, b) => (a <= b)
|
||||
}
|
||||
),
|
||||
}
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.repository.group
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_row = {
|
||||
name : string;
|
||||
label : string;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_preview = {
|
||||
name : string;
|
||||
label : string;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
var _store : (
|
||||
null
|
||||
|
|
||||
lib_plankton.storage.type_store<
|
||||
_zeitbild.type_user_id,
|
||||
/*type_row*/Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
/*type_preview*/Record<string, any>
|
||||
>
|
||||
) = null;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function get_store(
|
||||
)
|
||||
: lib_plankton.storage.type_store<
|
||||
_zeitbild.type_user_id,
|
||||
/*type_row*/Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
/*type_preview*/Record<string, any>
|
||||
>
|
||||
{
|
||||
if (_store === null)
|
||||
{
|
||||
_store = lib_plankton.storage.sql_table_autokey_store(
|
||||
{
|
||||
"database_implementation": _zeitbild.database.get_implementation(),
|
||||
"table_name": "groups",
|
||||
"key_name": "id",
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
return _store;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function encode(
|
||||
group_object : _zeitbild.type_group_object
|
||||
)
|
||||
: type_row
|
||||
{
|
||||
return {
|
||||
"name": group_object.name,
|
||||
"label": group_object.label,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function decode(
|
||||
row : type_row
|
||||
)
|
||||
: _zeitbild.type_group_object
|
||||
{
|
||||
return {
|
||||
"name": row.name,
|
||||
"label": row.label,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function list(
|
||||
)
|
||||
: Promise<
|
||||
Array<
|
||||
{
|
||||
id : _zeitbild.type_group_id;
|
||||
object : _zeitbild.type_group_object;
|
||||
}
|
||||
>
|
||||
>
|
||||
{
|
||||
const hits : Array<{key : int; preview : /*type_preview*/Record<string, any>;}> = await get_store().search({"expression": "TRUE", "arguments": {}});
|
||||
return Promise.resolve(
|
||||
hits
|
||||
.map(
|
||||
(hit) => ({
|
||||
"id": hit.key,
|
||||
"object": {
|
||||
"name": hit.preview.name,
|
||||
"label": hit.preview.label,
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function read(
|
||||
group_id : _zeitbild.type_group_id
|
||||
)
|
||||
: Promise<_zeitbild.type_group_object>
|
||||
{
|
||||
const row : type_row = ((await get_store().read(group_id)) as type_row);
|
||||
const group_object : _zeitbild.type_group_object = decode(row);
|
||||
return Promise.resolve<_zeitbild.type_group_object>(group_object);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function create(
|
||||
group_object : _zeitbild.type_group_object
|
||||
)
|
||||
: Promise<_zeitbild.type_group_id>
|
||||
{
|
||||
const row : type_row = encode(group_object);
|
||||
const group_id : _zeitbild.type_group_id = await get_store().create(row);
|
||||
return Promise.resolve<_zeitbild.type_group_id>(group_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function update(
|
||||
group_id : _zeitbild.type_group_id,
|
||||
group_object : _zeitbild.type_group_object
|
||||
)
|
||||
: Promise<void>
|
||||
{
|
||||
const row : type_row = encode(group_object);
|
||||
await get_store().update(group_id, row);
|
||||
return Promise.resolve<void>(undefined);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function identify(
|
||||
name : string
|
||||
)
|
||||
: Promise<_zeitbild.type_group_id>
|
||||
{
|
||||
const hits : Array<{key : _zeitbild.type_group_id; preview : /*type_preview*/Record<string, any>;}> = await get_store().search(
|
||||
{
|
||||
"expression": "(name = $name)",
|
||||
"arguments": {
|
||||
"name": name,
|
||||
}
|
||||
}
|
||||
);
|
||||
if (hits.length <= 0)
|
||||
{
|
||||
return Promise.reject<_zeitbild.type_group_id>(new Error("not found"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Promise.resolve<_zeitbild.type_group_id>(hits[0].key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,42 +1,7 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.repository.resource
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_row = {
|
||||
kind : string;
|
||||
sub_id : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_preview = {
|
||||
kind : string;
|
||||
sub_id : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_local_resource_event_stuff = {
|
||||
|
|
@ -97,10 +62,10 @@ namespace _zeitbild.repository.resource
|
|||
|
|
||||
lib_plankton.storage.type_store<
|
||||
_zeitbild.type_resource_id,
|
||||
/*type_row*/Record<string, any>,
|
||||
Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
/*type_preview*/Record<string, any>
|
||||
Record<string, any>
|
||||
>
|
||||
) = null;
|
||||
|
||||
|
|
|
|||
14
source/repositories/sql/calendar_overview.sql
Normal file
14
source/repositories/sql/calendar_overview.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
-- Für gewöhnlich würde man hier gruppieren. Aufgrund des UNIQUE-constraints in "calendar_access_attributed" ist das
|
||||
-- jedoch nicht nötig, da dadurch für jeden Eintrag in "calendar" mit gegebener "user_id" höchstens ein Eintrag in
|
||||
-- "calendar_access_attributed" passt und da es ein LEFT OUTER JOIN ist, wird es _genau_ ein Eintrag sein
|
||||
|
||||
SELECT
|
||||
x.id AS id,
|
||||
x.name AS name,
|
||||
x.access_public AS access_public,
|
||||
x.access_level_default AS access_level_default,
|
||||
y.level AS access_level_attributed
|
||||
FROM
|
||||
calendars AS x
|
||||
LEFT OUTER JOIN calendar_access_attributed AS y ON ((x.id = y.calendar_id) AND (y.user_id = $user_id))
|
||||
;
|
||||
|
|
@ -1,88 +1,15 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.repository.user
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_core_row = {
|
||||
name : string;
|
||||
email_address : (null | string);
|
||||
dav_token : (null | string);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_group_row_slim = {
|
||||
group_id : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_group_row_fat = {
|
||||
user_id : int;
|
||||
group_id : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_preview = {
|
||||
name : string;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_dispersal = {
|
||||
core : type_core_row;
|
||||
groups : Array<type_group_row_slim>;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
var _store_core : (
|
||||
var _store : (
|
||||
null
|
||||
|
|
||||
lib_plankton.storage.type_store<
|
||||
_zeitbild.type_user_id,
|
||||
/*type_core_row*/Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
/*type_preview*/Record<string, any>
|
||||
>
|
||||
) = null;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
var _store_groups : (
|
||||
null
|
||||
|
|
||||
lib_plankton.storage.type_store<
|
||||
int,
|
||||
/*type_group_row_fat*/Record<string, any>,
|
||||
Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
Record<string, any>
|
||||
|
|
@ -92,19 +19,17 @@ namespace _zeitbild.repository.user
|
|||
|
||||
/**
|
||||
*/
|
||||
function get_store_core(
|
||||
)
|
||||
: lib_plankton.storage.type_store<
|
||||
function get_store(
|
||||
) : lib_plankton.storage.type_store<
|
||||
_zeitbild.type_user_id,
|
||||
/*type_core_row*/Record<string, any>,
|
||||
Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
/*type_preview*/Record<string, any>
|
||||
Record<string, any>
|
||||
>
|
||||
{
|
||||
if (_store_core === null)
|
||||
{
|
||||
_store_core = lib_plankton.storage.sql_table_autokey_store(
|
||||
if (_store === null) {
|
||||
_store = lib_plankton.storage.sql_table_autokey_store(
|
||||
{
|
||||
"database_implementation": _zeitbild.database.get_implementation(),
|
||||
"table_name": "users",
|
||||
|
|
@ -112,41 +37,10 @@ namespace _zeitbild.repository.user
|
|||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// do nothing
|
||||
}
|
||||
return _store_core;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function get_store_groups(
|
||||
)
|
||||
: lib_plankton.storage.type_store<
|
||||
int,
|
||||
/*type_group_row_fat*/Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
Record<string, any>
|
||||
>
|
||||
{
|
||||
if (_store_groups === null)
|
||||
{
|
||||
_store_groups = lib_plankton.storage.sql_table_autokey_store(
|
||||
{
|
||||
"database_implementation": _zeitbild.database.get_implementation(),
|
||||
"table_name": "user_groups",
|
||||
"key_name": "id",
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
return _store_groups;
|
||||
}
|
||||
return _store;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -154,24 +48,12 @@ namespace _zeitbild.repository.user
|
|||
*/
|
||||
function encode(
|
||||
user_object : _zeitbild.type_user_object
|
||||
)
|
||||
: type_dispersal
|
||||
) : Record<string, any>
|
||||
{
|
||||
return {
|
||||
"core": {
|
||||
"name": user_object.name,
|
||||
"email_address": user_object.email_address,
|
||||
"dav_token": user_object.dav_token,
|
||||
},
|
||||
"groups": (
|
||||
user_object.groups.map(
|
||||
group_id => (
|
||||
{
|
||||
"group_id": group_id,
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
"name": user_object.name,
|
||||
"email_address": user_object.email_address,
|
||||
"dav_token": user_object.dav_token,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -179,19 +61,13 @@ namespace _zeitbild.repository.user
|
|||
/**
|
||||
*/
|
||||
function decode(
|
||||
dispersal : type_dispersal
|
||||
)
|
||||
: _zeitbild.type_user_object
|
||||
row : Record<string, any>
|
||||
) : _zeitbild.type_user_object
|
||||
{
|
||||
return {
|
||||
"name": dispersal.core.name,
|
||||
"groups": (
|
||||
dispersal.groups.map(
|
||||
group_row => group_row.group_id,
|
||||
)
|
||||
),
|
||||
"email_address": dispersal.core.email_address,
|
||||
"dav_token": dispersal.core.dav_token,
|
||||
"name": row["name"],
|
||||
"email_address": row["email_address"],
|
||||
"dav_token": row["dav_token"],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -199,8 +75,7 @@ namespace _zeitbild.repository.user
|
|||
/**
|
||||
*/
|
||||
export async function list(
|
||||
)
|
||||
: Promise<
|
||||
) : Promise<
|
||||
Array<
|
||||
{
|
||||
id : _zeitbild.type_user_id;
|
||||
|
|
@ -209,12 +84,7 @@ namespace _zeitbild.repository.user
|
|||
>
|
||||
>
|
||||
{
|
||||
const hits : Array<{key : int; preview : /*type_preview*/Record<string, any>;}> = await get_store_core().search(
|
||||
{
|
||||
"expression": "TRUE",
|
||||
"arguments": {}
|
||||
}
|
||||
);
|
||||
const hits : Array<{key : int; preview : Record<string, any>;}> = await get_store().search({"expression": "TRUE", "arguments": {}});
|
||||
return Promise.resolve(
|
||||
hits
|
||||
.map(
|
||||
|
|
@ -231,43 +101,10 @@ namespace _zeitbild.repository.user
|
|||
*/
|
||||
export async function read(
|
||||
user_id : _zeitbild.type_user_id
|
||||
)
|
||||
: Promise<_zeitbild.type_user_object>
|
||||
) : Promise<_zeitbild.type_user_object>
|
||||
{
|
||||
const core_row : type_core_row = ((await get_store_core().read(user_id)) as type_core_row);
|
||||
const group_rows : Array<type_group_row_fat> = (
|
||||
(
|
||||
await get_store_groups().search(
|
||||
{
|
||||
"expression": "(user_id = $user_id)",
|
||||
"arguments": {
|
||||
"user_id": user_id,
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
.map(
|
||||
hit => (
|
||||
{
|
||||
"user_id": hit.preview.user_id,
|
||||
"group_id": hit.preview.group_id,
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
const dispersal : type_dispersal = {
|
||||
"core": core_row,
|
||||
"groups": (
|
||||
group_rows.map(
|
||||
group_row_fat => (
|
||||
{
|
||||
"group_id": group_row_fat.group_id,
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
};
|
||||
const user_object : _zeitbild.type_user_object = decode(dispersal);
|
||||
const row : Record<string, any> = await get_store().read(user_id);
|
||||
const user_object : _zeitbild.type_user_object = decode(row);
|
||||
return Promise.resolve<_zeitbild.type_user_object>(user_object);
|
||||
}
|
||||
|
||||
|
|
@ -276,25 +113,10 @@ namespace _zeitbild.repository.user
|
|||
*/
|
||||
export async function create(
|
||||
user_object : _zeitbild.type_user_object
|
||||
)
|
||||
: Promise<_zeitbild.type_user_id>
|
||||
) : Promise<_zeitbild.type_user_id>
|
||||
{
|
||||
const dispersal : type_dispersal = encode(user_object);
|
||||
// core
|
||||
const user_id : _zeitbild.type_user_id = await (() => {
|
||||
return get_store_core().create(dispersal.core);
|
||||
}) ();
|
||||
// groups
|
||||
{
|
||||
for (const group_row_slim of dispersal.groups)
|
||||
{
|
||||
const group_row_fat : type_group_row_fat = {
|
||||
"user_id": user_id,
|
||||
"group_id": group_row_slim.group_id,
|
||||
};
|
||||
await get_store_groups().create(group_row_fat);
|
||||
}
|
||||
}
|
||||
const row : Record<string, any> = encode(user_object);
|
||||
const user_id : _zeitbild.type_user_id = await get_store().create(row);
|
||||
return Promise.resolve<_zeitbild.type_user_id>(user_id);
|
||||
}
|
||||
|
||||
|
|
@ -304,60 +126,10 @@ namespace _zeitbild.repository.user
|
|||
export async function update(
|
||||
user_id : _zeitbild.type_user_id,
|
||||
user_object : _zeitbild.type_user_object
|
||||
)
|
||||
: Promise<void>
|
||||
) : Promise<void>
|
||||
{
|
||||
const dispersal : type_dispersal = encode(user_object);
|
||||
// core
|
||||
{
|
||||
await get_store_core().update(user_id, dispersal.core);
|
||||
}
|
||||
// groups
|
||||
{
|
||||
const hits : Array<{key : int; preview : Record<string, any>;}> = await get_store_groups().search(
|
||||
{
|
||||
"expression": "(user_id = $user_id)",
|
||||
"arguments": {
|
||||
"user_id": user_id,
|
||||
}
|
||||
}
|
||||
);
|
||||
const contrast = lib_plankton.list.contrast(
|
||||
hits,
|
||||
hit => hit.preview.group_id.toFixed(0),
|
||||
dispersal.groups,
|
||||
group_row_slim => group_row_slim.group_id.toFixed(0)
|
||||
);
|
||||
// delete
|
||||
{
|
||||
for (const entry of contrast.only_left)
|
||||
{
|
||||
await get_store_groups().delete(entry.left.key);
|
||||
}
|
||||
}
|
||||
// update
|
||||
{
|
||||
for (const entry of contrast.both)
|
||||
{
|
||||
const row_group_fat : type_group_row_fat = {
|
||||
"user_id": user_id,
|
||||
"group_id": entry.right.group_id,
|
||||
};
|
||||
await get_store_groups().update(entry.left.key, row_group_fat);
|
||||
}
|
||||
}
|
||||
// create
|
||||
{
|
||||
for (const entry of contrast.only_right)
|
||||
{
|
||||
const row_group_fat : type_group_row_fat = {
|
||||
"user_id": user_id,
|
||||
"group_id": entry.right.group_id,
|
||||
};
|
||||
await get_store_groups().create(row_group_fat);
|
||||
}
|
||||
}
|
||||
}
|
||||
const dispersal : Record<string, any> = encode(user_object);
|
||||
await get_store().update(user_id, dispersal);
|
||||
return Promise.resolve<void>(undefined);
|
||||
}
|
||||
|
||||
|
|
@ -366,10 +138,9 @@ namespace _zeitbild.repository.user
|
|||
*/
|
||||
export async function identify(
|
||||
name : string
|
||||
)
|
||||
: Promise<_zeitbild.type_user_id>
|
||||
) : Promise<_zeitbild.type_user_id>
|
||||
{
|
||||
const hits : Array<{key : _zeitbild.type_user_id; preview : /*type_preview*/Record<string, any>;}> = await get_store_core().search(
|
||||
const hits : Array<{key : _zeitbild.type_user_id; preview : any;}> = await get_store().search(
|
||||
{
|
||||
"expression": "(name = $name)",
|
||||
"arguments": {
|
||||
|
|
@ -377,12 +148,10 @@ namespace _zeitbild.repository.user
|
|||
}
|
||||
}
|
||||
);
|
||||
if (hits.length <= 0)
|
||||
{
|
||||
if (hits.length <= 0) {
|
||||
return Promise.reject<_zeitbild.type_user_id>(new Error("not found"));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return Promise.resolve<_zeitbild.type_user_id>(hits[0].key);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
403
source/sample.ts
403
source/sample.ts
|
|
@ -1,403 +0,0 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.sample
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_date_absolute = {
|
||||
year : int;
|
||||
month : int;
|
||||
day : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_date_relative = Array<
|
||||
{
|
||||
action : "trunc_week";
|
||||
args : [int];
|
||||
}
|
||||
|
|
||||
{
|
||||
action : "shift_week";
|
||||
args : [int];
|
||||
}
|
||||
|
|
||||
{
|
||||
action : "shift_day";
|
||||
args : [int];
|
||||
}
|
||||
>;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_ywd = {
|
||||
year : int;
|
||||
week : int;
|
||||
day : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_time = {
|
||||
hour : int;
|
||||
minute : int;
|
||||
second : int;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_datetime = (
|
||||
{
|
||||
timezone_shift : int;
|
||||
time : (null | type_time);
|
||||
}
|
||||
&
|
||||
(
|
||||
{
|
||||
date_absolute : type_date_absolute;
|
||||
}
|
||||
|
|
||||
{
|
||||
date_relative : type_date_relative;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
type type_data = {
|
||||
groups : Array<
|
||||
{
|
||||
id : int;
|
||||
name : string;
|
||||
label ?: string;
|
||||
}
|
||||
>;
|
||||
users : Array<
|
||||
{
|
||||
id : int;
|
||||
name : string;
|
||||
groups ?: Array<int>;
|
||||
email_address : string;
|
||||
dav_token ?: (null | string);
|
||||
password : string;
|
||||
}
|
||||
>;
|
||||
calendars : Array<
|
||||
{
|
||||
id : int;
|
||||
name : string;
|
||||
access : {
|
||||
public ?: boolean;
|
||||
default_level : ("none" | "view" | "edit" | "admin");
|
||||
attributed_group ?: Array<
|
||||
{
|
||||
group_id : int;
|
||||
level : ("none" | "view" | "edit" | "admin");
|
||||
}
|
||||
>;
|
||||
attributed_user ?: Array<
|
||||
{
|
||||
user_id : int;
|
||||
level : ("none" | "view" | "edit" | "admin");
|
||||
}
|
||||
>;
|
||||
};
|
||||
resource : (
|
||||
{
|
||||
kind : "local";
|
||||
data : {
|
||||
events : Array<
|
||||
{
|
||||
/**
|
||||
* @todo rename to "title"
|
||||
*/
|
||||
name : string;
|
||||
begin : type_datetime;
|
||||
end : (
|
||||
null
|
||||
|
|
||||
type_datetime
|
||||
);
|
||||
location : (
|
||||
null
|
||||
|
|
||||
string
|
||||
);
|
||||
link : (
|
||||
null
|
||||
|
|
||||
string
|
||||
);
|
||||
description : (
|
||||
null
|
||||
|
|
||||
string
|
||||
);
|
||||
}
|
||||
>
|
||||
};
|
||||
}
|
||||
|
|
||||
{
|
||||
kind : "ics_feed";
|
||||
data : {
|
||||
url : string;
|
||||
from_fucked_up_wordpress ?: boolean;
|
||||
};
|
||||
}
|
||||
);
|
||||
hue ?: (null | float);
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
const phi : float = ((Math.sqrt(5) - 1) / 2);
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function decode_datetime(
|
||||
datetime : type_datetime
|
||||
) : lib_plankton.pit.type_datetime
|
||||
{
|
||||
if ("date_relative" in datetime)
|
||||
{
|
||||
return {
|
||||
"timezone_shift": datetime.timezone_shift,
|
||||
"date": lib_plankton.call.convey(
|
||||
lib_plankton.pit.now(),
|
||||
(
|
||||
datetime.date_relative.map<(x : any) => any>(
|
||||
entry => {
|
||||
switch (entry.action)
|
||||
{
|
||||
// default: {throw (new Error("unhandled action: " + entry.action));}
|
||||
case "trunc_week": {return (x => lib_plankton.pit.trunc_week(x));}
|
||||
case "shift_week": {return (x => lib_plankton.pit.shift_week(x, entry.args[0]));}
|
||||
case "shift_day": {return (x => lib_plankton.pit.shift_day(x, entry.args[0]));}
|
||||
}
|
||||
}
|
||||
)
|
||||
.concat(
|
||||
[
|
||||
lib_plankton.pit.to_datetime,
|
||||
x => x.date,
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
"time": datetime.time,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return {
|
||||
"timezone_shift": datetime.timezone_shift,
|
||||
"date": datetime.date_absolute,
|
||||
"time": datetime.time,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function init(
|
||||
data : type_data
|
||||
) : Promise<void>
|
||||
{
|
||||
let track : {
|
||||
group : Record<
|
||||
int,
|
||||
_zeitbild.type_group_id
|
||||
>;
|
||||
user : Record<
|
||||
int,
|
||||
_zeitbild.type_user_id
|
||||
>;
|
||||
calendar : Record<
|
||||
int,
|
||||
_zeitbild.type_user_id
|
||||
>;
|
||||
} = {
|
||||
"group": {},
|
||||
"user": {},
|
||||
"calendar": {},
|
||||
};
|
||||
// groups
|
||||
{
|
||||
for await (const group_raw of data.groups)
|
||||
{
|
||||
const group_object : _zeitbild.type_group_object = {
|
||||
"name": group_raw.name,
|
||||
"label": (group_raw.label ?? group_raw.name),
|
||||
};
|
||||
const group_id : _zeitbild.type_group_id = await _zeitbild.service.group.add(
|
||||
group_object
|
||||
);
|
||||
track.group[group_raw.id] = group_id;
|
||||
}
|
||||
}
|
||||
// users
|
||||
{
|
||||
for await (const user_raw of data.users)
|
||||
{
|
||||
const user_object : _zeitbild.type_user_object = {
|
||||
"name": user_raw.name,
|
||||
"groups": (user_raw.groups ?? []),
|
||||
"email_address": user_raw.email_address,
|
||||
"dav_token": (user_raw.dav_token ?? null),
|
||||
};
|
||||
const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.add(
|
||||
user_object
|
||||
);
|
||||
await _zeitbild.service.auth_internal.set(
|
||||
user_raw.name,
|
||||
user_raw.password
|
||||
);
|
||||
track.user[user_raw.id] = user_id;
|
||||
}
|
||||
}
|
||||
// calendars
|
||||
{
|
||||
for await (const calendar_raw of data.calendars)
|
||||
{
|
||||
let resource_object : _zeitbild.type_resource_object;
|
||||
let resource_id : _zeitbild.type_resource_id;
|
||||
switch (calendar_raw.resource.kind)
|
||||
{
|
||||
case "local":
|
||||
{
|
||||
resource_object = {
|
||||
"kind": "local",
|
||||
"data": {
|
||||
"event_ids": [],
|
||||
}
|
||||
};
|
||||
resource_id = await _zeitbild.service.resource.add(
|
||||
resource_object
|
||||
);
|
||||
/*const event_ids : Array<_zeitbild.type_local_resource_event_id> = */await Promise.all(
|
||||
calendar_raw.resource.data.events
|
||||
.map(
|
||||
(event_raw) => {
|
||||
const event : _zeitbild.type_event_object = {
|
||||
"name": event_raw.name,
|
||||
"begin": decode_datetime(event_raw.begin),
|
||||
"end": (
|
||||
(event_raw.end === null)
|
||||
?
|
||||
null
|
||||
:
|
||||
decode_datetime(event_raw.end)
|
||||
),
|
||||
"location": event_raw.location,
|
||||
"link": event_raw.link,
|
||||
"description": event_raw.description,
|
||||
};
|
||||
return _zeitbild.service.resource.event_add(resource_id, event);
|
||||
}
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "ics_feed":
|
||||
{
|
||||
resource_object = {
|
||||
"kind": "ics_feed",
|
||||
"data": {
|
||||
"url": calendar_raw.resource.data.url,
|
||||
"from_fucked_up_wordpress": (calendar_raw.resource.data.from_fucked_up_wordpress ?? false),
|
||||
}
|
||||
};
|
||||
resource_id = await _zeitbild.service.resource.add(
|
||||
resource_object
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const calendar_object : _zeitbild.type_calendar_object =
|
||||
{
|
||||
"name": calendar_raw.name,
|
||||
"hue": (
|
||||
calendar_raw.hue
|
||||
??
|
||||
((calendar_raw.id * phi) % 1)
|
||||
),
|
||||
"access": {
|
||||
"public": (calendar_raw.access.public ?? false),
|
||||
"default_level": _zeitbild.access_level_from_string(calendar_raw.access.default_level),
|
||||
"attributed_group": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
(calendar_raw.access.attributed_group ?? [])
|
||||
.map(
|
||||
(entry) => ({
|
||||
"key": track.user[entry.group_id],
|
||||
"value": _zeitbild.access_level_from_string(entry.level),
|
||||
})
|
||||
)
|
||||
),
|
||||
}
|
||||
)
|
||||
),
|
||||
"attributed_user": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
(calendar_raw.access.attributed_user ?? [])
|
||||
.map(
|
||||
(entry) => ({
|
||||
"key": track.user[entry.user_id],
|
||||
"value": _zeitbild.access_level_from_string(entry.level),
|
||||
})
|
||||
)
|
||||
),
|
||||
}
|
||||
)
|
||||
),
|
||||
},
|
||||
"resource_id": resource_id,
|
||||
};
|
||||
const calendar_id : _zeitbild.type_calendar_id = await _zeitbild.service.calendar.add(
|
||||
calendar_object
|
||||
);
|
||||
track.calendar[calendar_raw.id] = calendar_id;
|
||||
}
|
||||
}
|
||||
return Promise.resolve<void>(undefined);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.service.auth_internal
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,46 +1,44 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.service.calendar
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
async function get_access_level(
|
||||
function get_access_level(
|
||||
calendar_object : _zeitbild.type_calendar_object,
|
||||
user_id : (null | _zeitbild.type_user_id)
|
||||
)
|
||||
: Promise<_zeitbild.enum_access_level>
|
||||
) : _zeitbild.enum_access_level
|
||||
{
|
||||
return _zeitbild.access_level_determine(
|
||||
calendar_object,
|
||||
(
|
||||
(user_id === null)
|
||||
?
|
||||
null
|
||||
:
|
||||
return (
|
||||
lib_plankton.list.max<_zeitbild.enum_access_level, _zeitbild.enum_access_level>(
|
||||
[
|
||||
(
|
||||
calendar_object.access.public
|
||||
?
|
||||
_zeitbild.enum_access_level.view
|
||||
:
|
||||
_zeitbild.enum_access_level.none
|
||||
),
|
||||
(
|
||||
(user_id === null)
|
||||
?
|
||||
_zeitbild.enum_access_level.none
|
||||
:
|
||||
calendar_object.access.attributed.get(
|
||||
user_id,
|
||||
lib_plankton.pod.make_filled<_zeitbild.enum_access_level>(
|
||||
calendar_object.access.default_level
|
||||
)
|
||||
)
|
||||
),
|
||||
],
|
||||
x => x,
|
||||
{
|
||||
"id": user_id,
|
||||
"object": (await _zeitbild.service.user.get(user_id)),
|
||||
"compare_value": _zeitbild.value_object.access_level.order,
|
||||
}
|
||||
)
|
||||
)?.value
|
||||
??
|
||||
_zeitbild.enum_access_level.none
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +46,7 @@ namespace _zeitbild.service.calendar
|
|||
/**
|
||||
* checks if a user has a sufficient access level
|
||||
*/
|
||||
async function wrap_check_access_level<type_result>(
|
||||
function wrap_check_access_level<type_result>(
|
||||
calendar_object : _zeitbild.type_calendar_object,
|
||||
user_id : (null | _zeitbild.type_user_id),
|
||||
threshold : _zeitbild.enum_access_level,
|
||||
|
|
@ -57,29 +55,26 @@ namespace _zeitbild.service.calendar
|
|||
=>
|
||||
Promise<type_result>
|
||||
)
|
||||
)
|
||||
: Promise<type_result>
|
||||
) : Promise<type_result>
|
||||
{
|
||||
const access_level : _zeitbild.enum_access_level = await get_access_level(
|
||||
const access_level : _zeitbild.enum_access_level = get_access_level(
|
||||
calendar_object,
|
||||
user_id
|
||||
);
|
||||
if (! _zeitbild.access_level_order(threshold, access_level))
|
||||
{
|
||||
if (! _zeitbild.value_object.access_level.order(threshold, access_level)) {
|
||||
return Promise.reject<type_result>(
|
||||
new Error(
|
||||
lib_plankton.string.coin(
|
||||
"insufficient access level; at least required: {{threshold}}, actual: {{actual}}",
|
||||
{
|
||||
"threshold": _zeitbild.access_level_to_string(threshold),
|
||||
"actual": _zeitbild.access_level_to_string(access_level),
|
||||
"threshold": _zeitbild.value_object.access_level.to_string(threshold),
|
||||
"actual": _zeitbild.value_object.access_level.to_string(access_level),
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return success_handler(access_level);
|
||||
}
|
||||
}
|
||||
|
|
@ -95,7 +90,6 @@ namespace _zeitbild.service.calendar
|
|||
id : _zeitbild.type_calendar_id;
|
||||
name : string;
|
||||
access_level : _zeitbild.enum_access_level;
|
||||
hue : float;
|
||||
}
|
||||
>
|
||||
>
|
||||
|
|
@ -103,7 +97,7 @@ namespace _zeitbild.service.calendar
|
|||
return _zeitbild.repository.calendar.overview(user_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function get(
|
||||
|
|
@ -198,31 +192,21 @@ namespace _zeitbild.service.calendar
|
|||
calendar_id : _zeitbild.type_calendar_id,
|
||||
event_object : _zeitbild.type_event_object,
|
||||
user_id : _zeitbild.type_user_id
|
||||
) : Promise<
|
||||
{
|
||||
local_resource_event_id : (null | type_local_resource_event_id);
|
||||
hash : type_event_hash;
|
||||
}
|
||||
>
|
||||
) : Promise<void>
|
||||
{
|
||||
const calendar_object : _zeitbild.type_calendar_object = await _zeitbild.repository.calendar.read(
|
||||
calendar_id
|
||||
);
|
||||
return wrap_check_access_level(
|
||||
return wrap_check_access_level<void>(
|
||||
calendar_object,
|
||||
user_id,
|
||||
_zeitbild.enum_access_level.edit,
|
||||
async () => {
|
||||
const local_resource_event_id : _zeitbild.type_local_resource_event_id = await _zeitbild.service.resource.event_add(
|
||||
/*const event_id : _zeitbild.type_local_resource_event_id = */await _zeitbild.service.resource.event_add(
|
||||
calendar_object.resource_id,
|
||||
event_object
|
||||
);
|
||||
return Promise.resolve(
|
||||
{
|
||||
"local_resource_event_id": local_resource_event_id,
|
||||
"hash": get_event_hash_local(calendar_id, local_resource_event_id),
|
||||
}
|
||||
);
|
||||
return Promise.resolve<void>(undefined);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -282,45 +266,6 @@ 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
|
||||
*/
|
||||
|
|
@ -333,14 +278,13 @@ namespace _zeitbild.service.calendar
|
|||
Array<
|
||||
{
|
||||
id : (null | _zeitbild.type_local_resource_event_id);
|
||||
hash : _zeitbild.type_event_hash;
|
||||
object : _zeitbild.type_event_object;
|
||||
}
|
||||
>
|
||||
>
|
||||
{
|
||||
const calendar_object : _zeitbild.type_calendar_object = await _zeitbild.repository.calendar.read(calendar_id);
|
||||
return wrap_check_access_level<Array<{id : (null | _zeitbild.type_local_resource_event_id); hash : _zeitbild.type_event_hash; object : _zeitbild.type_event_object;}>>(
|
||||
return wrap_check_access_level<Array<{id : (null | _zeitbild.type_local_resource_event_id); object : _zeitbild.type_event_object;}>>(
|
||||
calendar_object,
|
||||
user_id,
|
||||
_zeitbild.enum_access_level.view,
|
||||
|
|
@ -361,10 +305,6 @@ namespace _zeitbild.service.calendar
|
|||
(event_object) => Promise.resolve(
|
||||
{
|
||||
"id": event_id,
|
||||
"hash": get_event_hash_local(
|
||||
calendar_id,
|
||||
event_id,
|
||||
),
|
||||
"object": event_object,
|
||||
}
|
||||
)
|
||||
|
|
@ -489,7 +429,6 @@ namespace _zeitbild.service.calendar
|
|||
.map(
|
||||
(event) => ({
|
||||
"id": null,
|
||||
"hash": get_event_hash_ics_feed(calendar_id, event),
|
||||
"object": event,
|
||||
})
|
||||
)
|
||||
|
|
@ -565,14 +504,13 @@ namespace _zeitbild.service.calendar
|
|||
const calendar_object : _zeitbild.type_calendar_object = await _zeitbild.repository.calendar.read(
|
||||
calendar_id
|
||||
);
|
||||
const access_level : _zeitbild.enum_access_level = await get_access_level(
|
||||
const access_level : _zeitbild.enum_access_level = get_access_level(
|
||||
calendar_object,
|
||||
user_id
|
||||
);
|
||||
const events : Array<
|
||||
{
|
||||
id : (null | _zeitbild.type_local_resource_event_id);
|
||||
hash : _zeitbild.type_event_hash;
|
||||
object : _zeitbild.type_event_object;
|
||||
}
|
||||
> = await get_events(
|
||||
|
|
@ -585,10 +523,8 @@ namespace _zeitbild.service.calendar
|
|||
events
|
||||
.map(
|
||||
(event_entry) => ({
|
||||
"hash": event_entry.hash,
|
||||
"calendar_id": calendar_id,
|
||||
"calendar_name": calendar_object.name,
|
||||
"hue": calendar_object.hue,
|
||||
"access_level": access_level,
|
||||
"event_id": event_entry.id,
|
||||
"event_object": event_entry.object,
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.service.group
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
export function list(
|
||||
)
|
||||
: Promise<
|
||||
Array<
|
||||
{
|
||||
id : _zeitbild.type_group_id;
|
||||
object : _zeitbild.type_group_object;
|
||||
}
|
||||
>
|
||||
>
|
||||
{
|
||||
return _zeitbild.repository.group.list();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function add(
|
||||
group_object : _zeitbild.type_group_object
|
||||
)
|
||||
: Promise<_zeitbild.type_group_id>
|
||||
{
|
||||
return _zeitbild.repository.group.create(group_object);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function change(
|
||||
group_id : _zeitbild.type_group_id,
|
||||
group_object : _zeitbild.type_group_object
|
||||
)
|
||||
: Promise<void>
|
||||
{
|
||||
return _zeitbild.repository.group.update(group_id, group_object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.service.resource
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace _zeitbild.service.user
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
/*
|
||||
This file is part of »zeitbild«.
|
||||
|
||||
Copyright 2025 'kcf' <fenris@folksprak.org>
|
||||
|
||||
»zeitbild« is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
»zeitbild« is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
@ -33,19 +14,6 @@ namespace _zeitbild
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export type type_group_id = int;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export type type_group_object = {
|
||||
name : string;
|
||||
label : string;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export type type_user_id = int;
|
||||
|
|
@ -55,9 +23,6 @@ namespace _zeitbild
|
|||
*/
|
||||
export type type_user_object = {
|
||||
name : string;
|
||||
groups : Array<
|
||||
type_group_id
|
||||
>;
|
||||
email_address : (
|
||||
null
|
||||
|
|
||||
|
|
@ -74,9 +39,6 @@ namespace _zeitbild
|
|||
/**
|
||||
*/
|
||||
export type type_event_object = {
|
||||
/**
|
||||
* @todo rename to "title"
|
||||
*/
|
||||
name : string;
|
||||
begin : lib_plankton.pit.type_datetime;
|
||||
end : (
|
||||
|
|
@ -143,15 +105,10 @@ namespace _zeitbild
|
|||
*/
|
||||
export type type_calendar_object = {
|
||||
name : string;
|
||||
hue : float;
|
||||
access : {
|
||||
public : boolean;
|
||||
default_level : enum_access_level;
|
||||
attributed_group : lib_plankton.map.type_map<
|
||||
type_group_id,
|
||||
enum_access_level
|
||||
>;
|
||||
attributed_user : lib_plankton.map.type_map<
|
||||
attributed : lib_plankton.map.type_map<
|
||||
type_user_id,
|
||||
enum_access_level
|
||||
>;
|
||||
|
|
@ -160,18 +117,11 @@ namespace _zeitbild
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export type type_event_hash = string;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export type type_event_extended = {
|
||||
hash : type_event_hash;
|
||||
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;
|
||||
|
|
|
|||
55
source/value_objects/access_level.ts
Normal file
55
source/value_objects/access_level.ts
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
/**
|
||||
*/
|
||||
namespace _zeitbild.value_object.access_level
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
export function to_string(
|
||||
access_level : _zeitbild.enum_access_level
|
||||
) : string
|
||||
{
|
||||
switch (access_level) {
|
||||
case _zeitbild.enum_access_level.none: {return "none";}
|
||||
case _zeitbild.enum_access_level.view: {return "view";}
|
||||
case _zeitbild.enum_access_level.edit: {return "edit";}
|
||||
case _zeitbild.enum_access_level.admin: {return "admin";}
|
||||
default: {throw (new Error("invalid access level: " + String(access_level)));}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function from_string(
|
||||
access_level_ : string
|
||||
) : _zeitbild.enum_access_level
|
||||
{
|
||||
switch (access_level_) {
|
||||
case "none": {return _zeitbild.enum_access_level.none;}
|
||||
case "view": {return _zeitbild.enum_access_level.view;}
|
||||
case "edit": {return _zeitbild.enum_access_level.edit;}
|
||||
case "admin": {return _zeitbild.enum_access_level.admin;}
|
||||
default: {throw (new Error("invalid encoded access level: " + String(access_level_)));}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function order(
|
||||
x : _zeitbild.enum_access_level,
|
||||
y : _zeitbild.enum_access_level
|
||||
) : boolean
|
||||
{
|
||||
const list : Array<_zeitbild.enum_access_level> = [
|
||||
_zeitbild.enum_access_level.none,
|
||||
_zeitbild.enum_access_level.view,
|
||||
_zeitbild.enum_access_level.edit,
|
||||
_zeitbild.enum_access_level.admin,
|
||||
];
|
||||
return (list.indexOf(x) <= list.indexOf(y));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -47,7 +47,6 @@ def main():
|
|||
"--verbose",
|
||||
"--exclude='conf.json'",
|
||||
"--exclude='data.sqlite'",
|
||||
"--exclude='log.jsonl'",
|
||||
("%s/" % args.build_directory),
|
||||
(
|
||||
("%s" % args.target_directory)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ cmd_tsc := ${dir_tools}/typescript/node_modules/.bin/tsc
|
|||
## rules
|
||||
|
||||
.PHONY: default
|
||||
default: node_modules ${dir_build}/zeitbild node_modules
|
||||
default: node_modules sql ${dir_build}/zeitbild node_modules
|
||||
|
||||
.PHONY: node_modules
|
||||
node_modules:
|
||||
|
|
@ -26,6 +26,13 @@ node_modules:
|
|||
@ ${cmd_log} "node modules …"
|
||||
@ ${cmd_cp} -r -u ${dir_lib}/node/node_modules/* ${dir_build}/node_modules/
|
||||
|
||||
.PHONY: sql
|
||||
sql: \
|
||||
$(wildcard ${dir_source}/repositories/sql/*)
|
||||
@ ${cmd_log} "sql …"
|
||||
@ ${cmd_mkdir} ${dir_build}/sql
|
||||
@ ${cmd_cp} -r -u $^ ${dir_build}/sql/
|
||||
|
||||
${dir_temp}/conf.ts: \
|
||||
${dir_source}/conf.ts.tpl \
|
||||
${dir_source}/conf.schema.json
|
||||
|
|
@ -40,14 +47,12 @@ ${dir_temp}/zeitbild-unlinked.js: \
|
|||
${dir_source}/database.ts \
|
||||
${dir_source}/auth.ts \
|
||||
${dir_source}/types.ts \
|
||||
${dir_source}/logic.ts \
|
||||
${dir_source}/value_objects/access_level.ts \
|
||||
${dir_source}/repositories/auth_internal.ts \
|
||||
${dir_source}/repositories/group.ts \
|
||||
${dir_source}/repositories/user.ts \
|
||||
${dir_source}/repositories/resource.ts \
|
||||
${dir_source}/repositories/calendar.ts \
|
||||
${dir_source}/services/auth_internal.ts \
|
||||
${dir_source}/services/group.ts \
|
||||
${dir_source}/services/user.ts \
|
||||
${dir_source}/services/resource.ts \
|
||||
${dir_source}/services/calendar.ts \
|
||||
|
|
@ -59,8 +64,6 @@ ${dir_temp}/zeitbild-unlinked.js: \
|
|||
${dir_source}/api/actions/session_begin.ts \
|
||||
${dir_source}/api/actions/session_oidc.ts \
|
||||
${dir_source}/api/actions/session_end.ts \
|
||||
${dir_source}/api/actions/session_status.ts \
|
||||
${dir_source}/api/actions/group_list.ts \
|
||||
${dir_source}/api/actions/users.ts \
|
||||
${dir_source}/api/actions/user_dav_conf.ts \
|
||||
${dir_source}/api/actions/user_dav_token.ts \
|
||||
|
|
@ -76,7 +79,6 @@ ${dir_temp}/zeitbild-unlinked.js: \
|
|||
${dir_source}/api/actions/events.ts \
|
||||
${dir_source}/api/actions/export_ics.ts \
|
||||
${dir_source}/api/functions.ts \
|
||||
${dir_source}/sample.ts \
|
||||
${dir_source}/main.ts
|
||||
@ ${cmd_log} "compile …"
|
||||
@ ${cmd_mkdir} $(dir $@)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ modules="${modules} session"
|
|||
modules="${modules} file"
|
||||
modules="${modules} string"
|
||||
modules="${modules} json"
|
||||
modules="${modules} base64"
|
||||
modules="${modules} list"
|
||||
modules="${modules} order"
|
||||
modules="${modules} ical"
|
||||
|
|
@ -44,8 +43,8 @@ mkdir -p ${dir}
|
|||
mkdir /tmp/sandbox -p
|
||||
cd /tmp/sandbox
|
||||
ptk fetch node ${modules}
|
||||
schwamm --include=/tmp/sandbox/plankton.swm.json --output=dump:logic-decl > ${dir}/plankton.d.ts
|
||||
schwamm --include=/tmp/sandbox/plankton.swm.json --output=dump:logic-impl > ${dir}/plankton.js
|
||||
schwamm --include=/tmp/sandboxplankton.swm.json --output=dump:logic-decl > ${dir}/plankton.d.ts
|
||||
schwamm --include=/tmp/sandboxplankton.swm.json --output=dump:logic-impl > ${dir}/plankton.js
|
||||
exit
|
||||
|
||||
mkdir -p ${dir}
|
||||
|
|
|
|||
Loading…
Reference in a new issue