Compare commits
No commits in common. "bf4f2fab6e28cb31901501ad9751ccecc83cbb2c" and "8163a12a684ab6b0fd439de8f0d0b6337dd442b4" have entirely different histories.
bf4f2fab6e
...
8163a12a68
|
|
@ -27,7 +27,6 @@
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "LV Lampukistan",
|
"name": "LV Lampukistan",
|
||||||
"access": {
|
"access": {
|
||||||
"public": true,
|
|
||||||
"default_level": "view",
|
"default_level": "view",
|
||||||
"attributed": [
|
"attributed": [
|
||||||
{
|
{
|
||||||
|
|
@ -48,20 +47,12 @@
|
||||||
"name": "Aufstand: Mieten",
|
"name": "Aufstand: Mieten",
|
||||||
"begin": {
|
"begin": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 14},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [-1]},
|
|
||||||
{"action": "shift_day", "args": [6]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 12, "minute": 0, "second": 0}
|
"time": {"hour": 12, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 14},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [-1]},
|
|
||||||
{"action": "shift_day", "args": [6]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 15, "minute": 0, "second": 0}
|
"time": {"hour": 15, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"location": "Porada Ninfu, Haupt-Markt",
|
"location": "Porada Ninfu, Haupt-Markt",
|
||||||
|
|
@ -71,20 +62,12 @@
|
||||||
"name": "Aufstand: Waffen",
|
"name": "Aufstand: Waffen",
|
||||||
"begin": {
|
"begin": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 21},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [0]},
|
|
||||||
{"action": "shift_day", "args": [6]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 12, "minute": 0, "second": 0}
|
"time": {"hour": 12, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 21},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [0]},
|
|
||||||
{"action": "shift_day", "args": [6]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 15, "minute": 0, "second": 0}
|
"time": {"hour": 15, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"location": "Tandreell, Stoiber-Platz",
|
"location": "Tandreell, Stoiber-Platz",
|
||||||
|
|
@ -94,20 +77,12 @@
|
||||||
"name": "Aufstand: Essen",
|
"name": "Aufstand: Essen",
|
||||||
"begin": {
|
"begin": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 10, "day": 28},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [1]},
|
|
||||||
{"action": "shift_day", "args": [6]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 12, "minute": 0, "second": 0}
|
"time": {"hour": 12, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 10, "day": 28},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [1]},
|
|
||||||
{"action": "shift_day", "args": [6]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 15, "minute": 0, "second": 0}
|
"time": {"hour": 15, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"location": "Kawanda, Nord-Bahnhof",
|
"location": "Kawanda, Nord-Bahnhof",
|
||||||
|
|
@ -121,7 +96,6 @@
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "KV Zepettel-Region",
|
"name": "KV Zepettel-Region",
|
||||||
"access": {
|
"access": {
|
||||||
"public": false,
|
|
||||||
"default_level": "view",
|
"default_level": "view",
|
||||||
"attributed": [
|
"attributed": [
|
||||||
{
|
{
|
||||||
|
|
@ -142,20 +116,12 @@
|
||||||
"name": "Feier: Bier",
|
"name": "Feier: Bier",
|
||||||
"begin": {
|
"begin": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 18},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [0]},
|
|
||||||
{"action": "shift_day", "args": [3]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 18, "minute": 0, "second": 0}
|
"time": {"hour": 18, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 18},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [0]},
|
|
||||||
{"action": "shift_day", "args": [3]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 23, "minute": 0, "second": 0}
|
"time": {"hour": 23, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"location": "Rudschadinedschad, Schlamm-Park",
|
"location": "Rudschadinedschad, Schlamm-Park",
|
||||||
|
|
@ -165,20 +131,12 @@
|
||||||
"name": "Feier: Schnapps",
|
"name": "Feier: Schnapps",
|
||||||
"begin": {
|
"begin": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 10, "day": 1},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [2]},
|
|
||||||
{"action": "shift_day", "args": [2]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 18, "minute": 0, "second": 0}
|
"time": {"hour": 18, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 10, "day": 1},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [2]},
|
|
||||||
{"action": "shift_day", "args": [2]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 23, "minute": 0, "second": 0}
|
"time": {"hour": 23, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"location": "Kawanda, Ratten-Platz",
|
"location": "Kawanda, Ratten-Platz",
|
||||||
|
|
@ -192,7 +150,6 @@
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"name": "OV Kawanda",
|
"name": "OV Kawanda",
|
||||||
"access": {
|
"access": {
|
||||||
"public": false,
|
|
||||||
"default_level": "view",
|
"default_level": "view",
|
||||||
"attributed": [
|
"attributed": [
|
||||||
{
|
{
|
||||||
|
|
@ -209,20 +166,12 @@
|
||||||
"name": "Aufräumen: Flaschen",
|
"name": "Aufräumen: Flaschen",
|
||||||
"begin": {
|
"begin": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 24},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [1]},
|
|
||||||
{"action": "shift_day", "args": [2]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 15, "minute": 0, "second": 0}
|
"time": {"hour": 15, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 24},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [1]},
|
|
||||||
{"action": "shift_day", "args": [2]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 17, "minute": 0, "second": 0}
|
"time": {"hour": 17, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"location": "Kawanda, Penner-Allee",
|
"location": "Kawanda, Penner-Allee",
|
||||||
|
|
@ -236,7 +185,6 @@
|
||||||
"id": 4,
|
"id": 4,
|
||||||
"name": "KV Zepettel-Region | intern",
|
"name": "KV Zepettel-Region | intern",
|
||||||
"access": {
|
"access": {
|
||||||
"public": false,
|
|
||||||
"default_level": "none",
|
"default_level": "none",
|
||||||
"attributed": [
|
"attributed": [
|
||||||
{
|
{
|
||||||
|
|
@ -257,20 +205,12 @@
|
||||||
"name": "Infostand",
|
"name": "Infostand",
|
||||||
"begin": {
|
"begin": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 16},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [0]},
|
|
||||||
{"action": "shift_day", "args": [1]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 10, "minute": 0, "second": 0}
|
"time": {"hour": 10, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date_relative": [
|
"date": {"year": 2025, "month": 9, "day": 16},
|
||||||
{"action": "trunc_week", "args": []},
|
|
||||||
{"action": "shift_week", "args": [0]},
|
|
||||||
{"action": "shift_day", "args": [1]}
|
|
||||||
],
|
|
||||||
"time": {"hour": 14, "minute": 0, "second": 0}
|
"time": {"hour": 14, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"location": "Rudschadinedschad, Schabracken-Markt",
|
"location": "Rudschadinedschad, Schabracken-Markt",
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ namespace _zeitbild.api
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
hue : float;
|
|
||||||
},
|
},
|
||||||
int
|
int
|
||||||
>(
|
>(
|
||||||
|
|
@ -138,8 +137,7 @@ namespace _zeitbild.api
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"resource_id": resource_id,
|
"resource_id": resource_id
|
||||||
"hue": stuff.input.hue,
|
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
_zeitbild.service.calendar.add(calendar_object)
|
_zeitbild.service.calendar.add(calendar_object)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ namespace _zeitbild.api
|
||||||
register<
|
register<
|
||||||
{
|
{
|
||||||
name : string;
|
name : string;
|
||||||
hue : float;
|
|
||||||
access : {
|
access : {
|
||||||
public : boolean;
|
public : boolean;
|
||||||
default_level : ("none" | "view" | "edit" | "admin");
|
default_level : ("none" | "view" | "edit" | "admin");
|
||||||
|
|
@ -74,7 +73,6 @@ namespace _zeitbild.api
|
||||||
);
|
);
|
||||||
const calendar_object_new : _zeitbild.type_calendar_object = {
|
const calendar_object_new : _zeitbild.type_calendar_object = {
|
||||||
"name": stuff.input.name,
|
"name": stuff.input.name,
|
||||||
"hue": stuff.input.hue,
|
|
||||||
"access": {
|
"access": {
|
||||||
"public": stuff.input.access.public,
|
"public": stuff.input.access.public,
|
||||||
"default_level": _zeitbild.value_object.access_level.from_string(stuff.input.access.default_level),
|
"default_level": _zeitbild.value_object.access_level.from_string(stuff.input.access.default_level),
|
||||||
|
|
@ -95,7 +93,7 @@ namespace _zeitbild.api
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"resource_id": calendar_object_old.resource_id,
|
"resource_id": calendar_object_old.resource_id
|
||||||
};
|
};
|
||||||
await _zeitbild.service.calendar.change(
|
await _zeitbild.service.calendar.change(
|
||||||
calendar_id,
|
calendar_id,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ namespace _zeitbild.api
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
name : string;
|
name : string;
|
||||||
hue : float;
|
|
||||||
access : {
|
access : {
|
||||||
default_level : string;
|
default_level : string;
|
||||||
attributed : Array<
|
attributed : Array<
|
||||||
|
|
@ -64,7 +63,6 @@ namespace _zeitbild.api
|
||||||
);
|
);
|
||||||
const result = {
|
const result = {
|
||||||
"name": calendar_object.name,
|
"name": calendar_object.name,
|
||||||
"hue": calendar_object.hue,
|
|
||||||
"access": {
|
"access": {
|
||||||
"public": calendar_object.access.public,
|
"public": calendar_object.access.public,
|
||||||
"default_level": _zeitbild.api.access_level_encode(calendar_object.access.default_level),
|
"default_level": _zeitbild.api.access_level_encode(calendar_object.access.default_level),
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ namespace _zeitbild.api
|
||||||
{
|
{
|
||||||
id : int;
|
id : int;
|
||||||
name : string;
|
name : string;
|
||||||
hue : float;
|
|
||||||
access_level : string;
|
access_level : string;
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
@ -60,10 +59,6 @@ namespace _zeitbild.api
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
},
|
},
|
||||||
"hue": {
|
|
||||||
"nullable": false,
|
|
||||||
"type": "number"
|
|
||||||
},
|
|
||||||
"access_level": {
|
"access_level": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"nullable": true,
|
"nullable": true,
|
||||||
|
|
@ -73,8 +68,8 @@ namespace _zeitbild.api
|
||||||
"required": [
|
"required": [
|
||||||
"id",
|
"id",
|
||||||
"name",
|
"name",
|
||||||
"hue",
|
"public",
|
||||||
"access_level",
|
"role",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -100,7 +95,6 @@ namespace _zeitbild.api
|
||||||
(entry) => ({
|
(entry) => ({
|
||||||
"id": entry.id,
|
"id": entry.id,
|
||||||
"name": entry.name,
|
"name": entry.name,
|
||||||
"hue": entry.hue,
|
|
||||||
"access_level": _zeitbild.value_object.access_level.to_string(entry.access_level),
|
"access_level": _zeitbild.value_object.access_level.to_string(entry.access_level),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ namespace _zeitbild.api
|
||||||
{
|
{
|
||||||
calendar_id : int;
|
calendar_id : int;
|
||||||
calendar_name : string;
|
calendar_name : string;
|
||||||
hue : float;
|
|
||||||
access_level : string;
|
access_level : string;
|
||||||
event_id : (null | int);
|
event_id : (null | int);
|
||||||
event_object : _zeitbild.type_event_object;
|
event_object : _zeitbild.type_event_object;
|
||||||
|
|
@ -81,10 +80,6 @@ namespace _zeitbild.api
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
"hue": {
|
|
||||||
"nullable": false,
|
|
||||||
"type": "number"
|
|
||||||
},
|
|
||||||
"access_level": {
|
"access_level": {
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -193,7 +188,6 @@ namespace _zeitbild.api
|
||||||
(entry) => ({
|
(entry) => ({
|
||||||
"calendar_id": entry.calendar_id,
|
"calendar_id": entry.calendar_id,
|
||||||
"calendar_name": entry.calendar_name,
|
"calendar_name": entry.calendar_name,
|
||||||
"hue": entry.hue,
|
|
||||||
"access_level": _zeitbild.api.access_level_encode(entry.access_level),
|
"access_level": _zeitbild.api.access_level_encode(entry.access_level),
|
||||||
"event_id": entry.event_id,
|
"event_id": entry.event_id,
|
||||||
"event_object": entry.event_object,
|
"event_object": entry.event_object,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace _zeitbild.database
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
const _compatible_revisions : Array<string> = [
|
const _compatible_revisions : Array<string> = [
|
||||||
"r5",
|
"r4",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
166
source/main.ts
166
source/main.ts
|
|
@ -19,6 +19,164 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
async function main(
|
async function main(
|
||||||
|
|
@ -69,8 +227,8 @@ async function main(
|
||||||
"description": "conf-expose"
|
"description": "conf-expose"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sample",
|
"name": "fill",
|
||||||
"description": "sample"
|
"description": "fill"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "help",
|
"name": "help",
|
||||||
|
|
@ -259,9 +417,9 @@ async function main(
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "sample":
|
case "fill":
|
||||||
{
|
{
|
||||||
await _zeitbild.sample.init(
|
await data_init(
|
||||||
lib_plankton.json.decode(
|
lib_plankton.json.decode(
|
||||||
await lib_plankton.file.read(args.data_path)
|
await lib_plankton.file.read(args.data_path)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,6 @@ along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace _zeitbild.repository.calendar
|
namespace _zeitbild.repository.calendar
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
const hue_scaling : int = 0xFFFF;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
type type_dispersal = {
|
type type_dispersal = {
|
||||||
|
|
@ -169,7 +164,6 @@ namespace _zeitbild.repository.calendar
|
||||||
return {
|
return {
|
||||||
"core_row": {
|
"core_row": {
|
||||||
"name": object.name,
|
"name": object.name,
|
||||||
"hue": Math.floor(object.hue * hue_scaling),
|
|
||||||
"access_public": object.access.public,
|
"access_public": object.access.public,
|
||||||
"access_level_default": encode_access_level(object.access.default_level),
|
"access_level_default": encode_access_level(object.access.default_level),
|
||||||
"resource_id": object.resource_id,
|
"resource_id": object.resource_id,
|
||||||
|
|
@ -196,7 +190,6 @@ namespace _zeitbild.repository.calendar
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
"name": dispersal.core_row["name"],
|
"name": dispersal.core_row["name"],
|
||||||
"hue": (dispersal.core_row["hue"] / hue_scaling),
|
|
||||||
"access": {
|
"access": {
|
||||||
"public": dispersal.core_row["access_public"],
|
"public": dispersal.core_row["access_public"],
|
||||||
"default_level": decode_access_level(dispersal.core_row["access_level_default"]),
|
"default_level": decode_access_level(dispersal.core_row["access_level_default"]),
|
||||||
|
|
@ -385,7 +378,6 @@ namespace _zeitbild.repository.calendar
|
||||||
type type_overview_entry = {
|
type type_overview_entry = {
|
||||||
id : _zeitbild.type_calendar_id;
|
id : _zeitbild.type_calendar_id;
|
||||||
name : string;
|
name : string;
|
||||||
hue : float;
|
|
||||||
access_level : _zeitbild.enum_access_level;
|
access_level : _zeitbild.enum_access_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -429,7 +421,6 @@ namespace _zeitbild.repository.calendar
|
||||||
(row : Record<string, any>) => ({
|
(row : Record<string, any>) => ({
|
||||||
"id": row["id"],
|
"id": row["id"],
|
||||||
"name": row["name"],
|
"name": row["name"],
|
||||||
"hue": (row["hue"] / hue_scaling),
|
|
||||||
/**
|
/**
|
||||||
* @todo unite with _zeitbild.service.calendar.get_access_level
|
* @todo unite with _zeitbild.service.calendar.get_access_level
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
SELECT
|
SELECT
|
||||||
x.id AS id,
|
x.id AS id,
|
||||||
x.name AS name,
|
x.name AS name,
|
||||||
x.hue AS hue,
|
|
||||||
x.access_public AS access_public,
|
x.access_public AS access_public,
|
||||||
x.access_level_default AS access_level_default,
|
x.access_level_default AS access_level_default,
|
||||||
y.level AS access_level_attributed
|
y.level AS access_level_attributed
|
||||||
|
|
|
||||||
347
source/sample.ts
347
source/sample.ts
|
|
@ -1,347 +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 = {
|
|
||||||
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<
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @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 : {
|
|
||||||
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) => {
|
|
||||||
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.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -109,7 +109,6 @@ namespace _zeitbild.service.calendar
|
||||||
id : _zeitbild.type_calendar_id;
|
id : _zeitbild.type_calendar_id;
|
||||||
name : string;
|
name : string;
|
||||||
access_level : _zeitbild.enum_access_level;
|
access_level : _zeitbild.enum_access_level;
|
||||||
hue : float;
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
|
|
@ -545,7 +544,6 @@ namespace _zeitbild.service.calendar
|
||||||
(event_entry) => ({
|
(event_entry) => ({
|
||||||
"calendar_id": calendar_id,
|
"calendar_id": calendar_id,
|
||||||
"calendar_name": calendar_object.name,
|
"calendar_name": calendar_object.name,
|
||||||
"hue": calendar_object.hue,
|
|
||||||
"access_level": access_level,
|
"access_level": access_level,
|
||||||
"event_id": event_entry.id,
|
"event_id": event_entry.id,
|
||||||
"event_object": event_entry.object,
|
"event_object": event_entry.object,
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,6 @@ namespace _zeitbild
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export type type_event_object = {
|
export type type_event_object = {
|
||||||
/**
|
|
||||||
* @todo rename to "title"
|
|
||||||
*/
|
|
||||||
name : string;
|
name : string;
|
||||||
begin : lib_plankton.pit.type_datetime;
|
begin : lib_plankton.pit.type_datetime;
|
||||||
end : (
|
end : (
|
||||||
|
|
@ -127,7 +124,6 @@ namespace _zeitbild
|
||||||
*/
|
*/
|
||||||
export type type_calendar_object = {
|
export type type_calendar_object = {
|
||||||
name : string;
|
name : string;
|
||||||
hue : float;
|
|
||||||
access : {
|
access : {
|
||||||
public : boolean;
|
public : boolean;
|
||||||
default_level : enum_access_level;
|
default_level : enum_access_level;
|
||||||
|
|
@ -145,7 +141,6 @@ namespace _zeitbild
|
||||||
export type type_event_extended = {
|
export type type_event_extended = {
|
||||||
calendar_id : type_calendar_id;
|
calendar_id : type_calendar_id;
|
||||||
calendar_name : string;
|
calendar_name : string;
|
||||||
hue : float;
|
|
||||||
access_level : enum_access_level;
|
access_level : enum_access_level;
|
||||||
event_id : (null | type_local_resource_event_id);
|
event_id : (null | type_local_resource_event_id);
|
||||||
event_object : type_event_object;
|
event_object : type_event_object;
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,6 @@ ${dir_temp}/zeitbild-unlinked.js: \
|
||||||
${dir_source}/api/actions/events.ts \
|
${dir_source}/api/actions/events.ts \
|
||||||
${dir_source}/api/actions/export_ics.ts \
|
${dir_source}/api/actions/export_ics.ts \
|
||||||
${dir_source}/api/functions.ts \
|
${dir_source}/api/functions.ts \
|
||||||
${dir_source}/sample.ts \
|
|
||||||
${dir_source}/main.ts
|
${dir_source}/main.ts
|
||||||
@ ${cmd_log} "compile …"
|
@ ${cmd_log} "compile …"
|
||||||
@ ${cmd_mkdir} $(dir $@)
|
@ ${cmd_mkdir} $(dir $@)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue