[mod] types

This commit is contained in:
Fenris Wolf 2024-09-21 11:05:24 +02:00
parent 2f6514c10b
commit 7ead0d85bc
11 changed files with 127 additions and 127 deletions

View file

@ -57,7 +57,7 @@ namespace _zeitbild.api
"restriction": restriction_logged_in, "restriction": restriction_logged_in,
"execution": async (stuff) => { "execution": async (stuff) => {
const session : {key : string; value : lib_plankton.session.type_session;} = await session_from_stuff(stuff); 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); const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.identify(session.value.name);
return ( return (
_zeitbild.service.calendar.overview(user_id) _zeitbild.service.calendar.overview(user_id)

View file

@ -15,14 +15,14 @@ namespace _zeitbild.api
calendar_ids : ( calendar_ids : (
null null
| |
Array<_zeitbild.type.calendar_id> Array<_zeitbild.type_calendar_id>
); );
}, },
Array< Array<
{ {
calendar_id : int; calendar_id : int;
calendar_name : string; calendar_name : string;
event : _zeitbild.type.event_object; event : _zeitbild.type_event_object;
} }
> >
>( >(
@ -103,11 +103,11 @@ namespace _zeitbild.api
"restriction": restriction_none, // TODO "restriction": restriction_none, // TODO
"execution": async (stuff) => { "execution": async (stuff) => {
const session : {key : string; value : lib_plankton.session.type_session;} = await session_from_stuff(stuff); 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); const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.identify(session.value.name);
const from : _zeitbild.helpers.type_pit = parseInt(stuff.query_parameters["from"]); const from : _zeitbild.helpers.type_pit = parseInt(stuff.query_parameters["from"]);
const to : _zeitbild.helpers.type_pit = parseInt(stuff.query_parameters["to"]); const to : _zeitbild.helpers.type_pit = parseInt(stuff.query_parameters["to"]);
const calendar_ids_wanted : Array<_zeitbild.type.calendar_id> = ( const calendar_ids_wanted : Array<_zeitbild.type_calendar_id> = (
( (
("calendar_ids" in stuff.query_parameters) ("calendar_ids" in stuff.query_parameters)
&& &&
@ -125,11 +125,11 @@ namespace _zeitbild.api
: :
null null
); );
const calendar_ids_allowed : Array<_zeitbild.type.calendar_id> = ( const calendar_ids_allowed : Array<_zeitbild.type_calendar_id> = (
(await _zeitbild.service.calendar.overview(user_id)) (await _zeitbild.service.calendar.overview(user_id))
.map((x : any) => x.id) .map((x : any) => x.id)
); );
const calendar_ids : Array<_zeitbild.type.calendar_id> = ( const calendar_ids : Array<_zeitbild.type_calendar_id> = (
( (
(calendar_ids_wanted === null) (calendar_ids_wanted === null)
? ?

View file

@ -23,7 +23,7 @@ type type_data = {
} }
>; >;
}; };
resource : _zeitbild.type.resource_object; resource : _zeitbild.type_resource_object;
} }
>; >;
}; };
@ -38,22 +38,22 @@ async function data_init(
let track : { let track : {
user : Record< user : Record<
int, int,
_zeitbild.type.user_id _zeitbild.type_user_id
>; >;
calendar : Record< calendar : Record<
int, int,
_zeitbild.type.user_id _zeitbild.type_user_id
>; >;
} = { } = {
"user": {}, "user": {},
"calendar": {}, "calendar": {},
}; };
for await (const user_raw of data.users) { for await (const user_raw of data.users) {
const user_object : _zeitbild.type.user_object = { const user_object : _zeitbild.type_user_object = {
"name": user_raw.name, "name": user_raw.name,
"email_address": user_raw.email_address, "email_address": user_raw.email_address,
}; };
const user_id : _zeitbild.type.user_id = await _zeitbild.service.user.add( const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.add(
user_object user_object
); );
await _zeitbild.service.auth_internal.set( await _zeitbild.service.auth_internal.set(
@ -63,11 +63,11 @@ async function data_init(
track.user[user_raw.id] = user_id; track.user[user_raw.id] = user_id;
} }
for await (const calendar_raw of data.calendars) { for await (const calendar_raw of data.calendars) {
const resource_object : _zeitbild.type.resource_object = calendar_raw.resource; const resource_object : _zeitbild.type_resource_object = calendar_raw.resource;
const resource_id : _zeitbild.type.resource_id = await _zeitbild.service.resource.add( const resource_id : _zeitbild.type_resource_id = await _zeitbild.service.resource.add(
resource_object resource_object
); );
const calendar_object : _zeitbild.type.calendar_object = { const calendar_object : _zeitbild.type_calendar_object = {
"name": calendar_raw.name, "name": calendar_raw.name,
"access": { "access": {
"default_level": _zeitbild.value_object.access_level.from_string(calendar_raw.access.default_level), "default_level": _zeitbild.value_object.access_level.from_string(calendar_raw.access.default_level),
@ -90,7 +90,7 @@ async function data_init(
}, },
"resource_id": resource_id, "resource_id": resource_id,
}; };
const calendar_id : _zeitbild.type.calendar_id = await _zeitbild.service.calendar.add( const calendar_id : _zeitbild.type_calendar_id = await _zeitbild.service.calendar.add(
calendar_object calendar_object
); );
track.calendar[calendar_raw.id] = calendar_id; track.calendar[calendar_raw.id] = calendar_id;

View file

@ -24,7 +24,7 @@ namespace _zeitbild.repository.calendar
null null
| |
lib_plankton.storage.type_store< lib_plankton.storage.type_store<
_zeitbild.type.calendar_id, _zeitbild.type_calendar_id,
Record<string, any>, Record<string, any>,
{}, {},
lib_plankton.storage.type_sql_table_autokey_search_term, lib_plankton.storage.type_sql_table_autokey_search_term,
@ -52,7 +52,7 @@ namespace _zeitbild.repository.calendar
*/ */
function get_core_store( function get_core_store(
) : lib_plankton.storage.type_store< ) : lib_plankton.storage.type_store<
_zeitbild.type.calendar_id, _zeitbild.type_calendar_id,
Record<string, any>, Record<string, any>,
{}, {},
lib_plankton.storage.type_sql_table_autokey_search_term, lib_plankton.storage.type_sql_table_autokey_search_term,
@ -105,15 +105,15 @@ namespace _zeitbild.repository.calendar
/** /**
*/ */
function encode_access_level( function encode_access_level(
access_level : _zeitbild.type.enum_access_level access_level : _zeitbild.enum_access_level
) : int ) : int
{ {
return ( return (
[ [
_zeitbild.type.enum_access_level.none, _zeitbild.enum_access_level.none,
_zeitbild.type.enum_access_level.view, _zeitbild.enum_access_level.view,
_zeitbild.type.enum_access_level.edit, _zeitbild.enum_access_level.edit,
_zeitbild.type.enum_access_level.admin, _zeitbild.enum_access_level.admin,
].indexOf(access_level) ].indexOf(access_level)
); );
} }
@ -123,14 +123,14 @@ namespace _zeitbild.repository.calendar
*/ */
function decode_access_level( function decode_access_level(
access_level_encoded : int access_level_encoded : int
) : _zeitbild.type.enum_access_level ) : _zeitbild.enum_access_level
{ {
return ( return (
[ [
_zeitbild.type.enum_access_level.none, _zeitbild.enum_access_level.none,
_zeitbild.type.enum_access_level.view, _zeitbild.enum_access_level.view,
_zeitbild.type.enum_access_level.edit, _zeitbild.enum_access_level.edit,
_zeitbild.type.enum_access_level.admin, _zeitbild.enum_access_level.admin,
][access_level_encoded] ][access_level_encoded]
); );
} }
@ -139,7 +139,7 @@ namespace _zeitbild.repository.calendar
/** /**
*/ */
function encode( function encode(
object : _zeitbild.type.calendar_object object : _zeitbild.type_calendar_object
) : type_dispersal ) : type_dispersal
{ {
return { return {
@ -166,7 +166,7 @@ namespace _zeitbild.repository.calendar
*/ */
function decode( function decode(
dispersal : type_dispersal dispersal : type_dispersal
) : _zeitbild.type.calendar_object ) : _zeitbild.type_calendar_object
{ {
return { return {
"name": dispersal.core_row["name"], "name": dispersal.core_row["name"],
@ -196,7 +196,7 @@ namespace _zeitbild.repository.calendar
) : Promise< ) : Promise<
Array< Array<
{ {
id : _zeitbild.type.calendar_id; id : _zeitbild.type_calendar_id;
preview : { preview : {
name : string; name : string;
}; };
@ -242,8 +242,8 @@ namespace _zeitbild.repository.calendar
/** /**
*/ */
export function read( export function read(
id : _zeitbild.type.calendar_id id : _zeitbild.type_calendar_id
) : Promise<_zeitbild.type.calendar_object> ) : Promise<_zeitbild.type_calendar_object>
{ {
return ( return (
get_core_store().read(id) get_core_store().read(id)
@ -266,7 +266,7 @@ namespace _zeitbild.repository.calendar
) )
) )
.then( .then(
(dispersal) => Promise.resolve<_zeitbild.type.calendar_object>( (dispersal) => Promise.resolve<_zeitbild.type_calendar_object>(
decode(dispersal) decode(dispersal)
) )
) )
@ -279,18 +279,18 @@ namespace _zeitbild.repository.calendar
/** /**
*/ */
export function create( export function create(
calendar_object : _zeitbild.type.calendar_object calendar_object : _zeitbild.type_calendar_object
) : Promise<_zeitbild.type.calendar_id> ) : Promise<_zeitbild.type_calendar_id>
{ {
return ( return (
Promise.resolve<_zeitbild.type.calendar_object>(calendar_object) Promise.resolve<_zeitbild.type_calendar_object>(calendar_object)
.then<type_dispersal>( .then<type_dispersal>(
(calendar_object) => Promise.resolve<type_dispersal>(encode(calendar_object)) (calendar_object) => Promise.resolve<type_dispersal>(encode(calendar_object))
) )
.then<_zeitbild.type.calendar_id>( .then<_zeitbild.type_calendar_id>(
(dispersal) => ( (dispersal) => (
get_core_store().create(dispersal.core_row) get_core_store().create(dispersal.core_row)
.then<_zeitbild.type.calendar_id>( .then<_zeitbild.type_calendar_id>(
(calendar_id) => ( (calendar_id) => (
Promise.all( Promise.all(
dispersal.access_attributed_rows dispersal.access_attributed_rows
@ -302,7 +302,7 @@ namespace _zeitbild.repository.calendar
) )
) )
.then( .then(
() => Promise.resolve<_zeitbild.type.calendar_id>(calendar_id) () => Promise.resolve<_zeitbild.type_calendar_id>(calendar_id)
) )
) )
) )
@ -315,13 +315,13 @@ namespace _zeitbild.repository.calendar
/** /**
*/ */
export async function overview( export async function overview(
user_id : _zeitbild.type.user_id user_id : _zeitbild.type_user_id
) : Promise< ) : Promise<
Array< Array<
{ {
id : _zeitbild.type.calendar_id; id : _zeitbild.type_calendar_id;
name : string; name : string;
access_level : _zeitbild.type.enum_access_level; access_level : _zeitbild.enum_access_level;
} }
> >
> >

View file

@ -53,7 +53,7 @@ namespace _zeitbild.repository.resource
null null
| |
lib_plankton.storage.type_store< lib_plankton.storage.type_store<
_zeitbild.type.resource_id, _zeitbild.type_resource_id,
Record<string, any>, Record<string, any>,
{}, {},
lib_plankton.storage.type_sql_table_autokey_search_term, lib_plankton.storage.type_sql_table_autokey_search_term,
@ -147,7 +147,7 @@ namespace _zeitbild.repository.resource
*/ */
function get_resource_core_store( function get_resource_core_store(
) : lib_plankton.storage.type_store< ) : lib_plankton.storage.type_store<
_zeitbild.type.resource_id, _zeitbild.type_resource_id,
Record<string, any>, Record<string, any>,
{}, {},
lib_plankton.storage.type_sql_table_autokey_search_term, lib_plankton.storage.type_sql_table_autokey_search_term,
@ -175,7 +175,7 @@ namespace _zeitbild.repository.resource
/* /*
function encode_resource_core( function encode_resource_core(
stuff : { stuff : {
object : _zeitbild.type.resource_object; object : _zeitbild.type_resource_object;
sub_id : int; sub_id : int;
} }
) : Record<string, any> ) : Record<string, any>
@ -195,7 +195,7 @@ namespace _zeitbild.repository.resource
function decode_resource_core( function decode_resource_core(
row : Record<string, any> row : Record<string, any>
) : { ) : {
object : _zeitbild.type.resource_object; object : _zeitbild.type_resource_object;
sub_id : int; sub_id : int;
} }
{ {
@ -213,7 +213,7 @@ namespace _zeitbild.repository.resource
/** /**
*/ */
function encode_event( function encode_event(
event : _zeitbild.type.event_object, event : _zeitbild.type_event_object,
local_resource_id : int local_resource_id : int
) : Record<string, any> ) : Record<string, any>
{ {
@ -300,7 +300,7 @@ namespace _zeitbild.repository.resource
*/ */
function decode_event( function decode_event(
row : Record<string, any> row : Record<string, any>
) : _zeitbild.type.event_object ) : _zeitbild.type_event_object
{ {
const decode_datetime : ((datetime_raw : string) => _zeitbild.helpers.type_datetime) = ((datetime_raw) => { const decode_datetime : ((datetime_raw : string) => _zeitbild.helpers.type_datetime) = ((datetime_raw) => {
const parts : Array<string> = datetime_raw.split("|"); const parts : Array<string> = datetime_raw.split("|");
@ -351,8 +351,8 @@ namespace _zeitbild.repository.resource
/** /**
*/ */
export async function read( export async function read(
resource_id : _zeitbild.type.resource_id resource_id : _zeitbild.type_resource_id
) : Promise<_zeitbild.type.resource_object> ) : Promise<_zeitbild.type_resource_object>
{ {
const dataset_core : Record<string, any> = await get_resource_core_store().read(resource_id); const dataset_core : Record<string, any> = await get_resource_core_store().read(resource_id);
switch (dataset_core.kind) { switch (dataset_core.kind) {
@ -366,7 +366,7 @@ namespace _zeitbild.repository.resource
} }
} }
); );
return Promise.resolve<_zeitbild.type.resource_object>( return Promise.resolve<_zeitbild.type_resource_object>(
{ {
"kind": "local", "kind": "local",
"data": { "data": {
@ -377,7 +377,7 @@ namespace _zeitbild.repository.resource
} }
case "caldav": { case "caldav": {
const dataset_extra_caldav : Record<string, any> = await get_caldav_resource_store().read(dataset_core.sub_id); const dataset_extra_caldav : Record<string, any> = await get_caldav_resource_store().read(dataset_core.sub_id);
return Promise.resolve<_zeitbild.type.resource_object>( return Promise.resolve<_zeitbild.type_resource_object>(
{ {
"kind": "caldav", "kind": "caldav",
"data": { "data": {
@ -389,7 +389,7 @@ namespace _zeitbild.repository.resource
break; break;
} }
default: { default: {
return Promise.reject<_zeitbild.type.resource_object>( return Promise.reject<_zeitbild.type_resource_object>(
new Error("invalid resource kind: " + dataset_core.kind) new Error("invalid resource kind: " + dataset_core.kind)
); );
break; break;
@ -401,8 +401,8 @@ namespace _zeitbild.repository.resource
/** /**
*/ */
export async function create( export async function create(
resource_object : _zeitbild.type.resource_object resource_object : _zeitbild.type_resource_object
) : Promise<_zeitbild.type.resource_id> ) : Promise<_zeitbild.type_resource_id>
{ {
switch (resource_object.kind) { switch (resource_object.kind) {
case "local": { case "local": {
@ -419,13 +419,13 @@ namespace _zeitbild.repository.resource
) )
) )
} }
const resource_id : _zeitbild.type.resource_id = await get_resource_core_store().create( const resource_id : _zeitbild.type_resource_id = await get_resource_core_store().create(
{ {
"kind": "local", "kind": "local",
"sub_id": local_resource_id, "sub_id": local_resource_id,
} }
); );
return Promise.resolve<_zeitbild.type.resource_id>(resource_id); return Promise.resolve<_zeitbild.type_resource_id>(resource_id);
break; break;
} }
case "caldav": { case "caldav": {
@ -435,13 +435,13 @@ namespace _zeitbild.repository.resource
"read_only": resource_object.data.read_only, "read_only": resource_object.data.read_only,
} }
); );
const resource_id : _zeitbild.type.resource_id = await get_resource_core_store().create( const resource_id : _zeitbild.type_resource_id = await get_resource_core_store().create(
{ {
"kind": "caldav", "kind": "caldav",
"sub_id": caldav_resource_id, "sub_id": caldav_resource_id,
} }
); );
return Promise.resolve<_zeitbild.type.resource_id>(resource_id); return Promise.resolve<_zeitbild.type_resource_id>(resource_id);
break; break;
} }
default: { default: {

View file

@ -8,7 +8,7 @@ namespace _zeitbild.repository.user
null null
| |
lib_plankton.storage.type_store< lib_plankton.storage.type_store<
_zeitbild.type.user_id, _zeitbild.type_user_id,
Record<string, any>, Record<string, any>,
{}, {},
lib_plankton.storage.type_sql_table_autokey_search_term, lib_plankton.storage.type_sql_table_autokey_search_term,
@ -21,7 +21,7 @@ namespace _zeitbild.repository.user
*/ */
function get_store( function get_store(
) : lib_plankton.storage.type_store< ) : lib_plankton.storage.type_store<
_zeitbild.type.user_id, _zeitbild.type_user_id,
Record<string, any>, Record<string, any>,
{}, {},
lib_plankton.storage.type_sql_table_autokey_search_term, lib_plankton.storage.type_sql_table_autokey_search_term,
@ -47,7 +47,7 @@ namespace _zeitbild.repository.user
/** /**
*/ */
function encode( function encode(
user_object : _zeitbild.type.user_object user_object : _zeitbild.type_user_object
) : Record<string, any> ) : Record<string, any>
{ {
return { return {
@ -61,7 +61,7 @@ namespace _zeitbild.repository.user
*/ */
function decode( function decode(
row : Record<string, any> row : Record<string, any>
) : _zeitbild.type.user_object ) : _zeitbild.type_user_object
{ {
return { return {
"name": row["name"], "name": row["name"],
@ -73,24 +73,24 @@ namespace _zeitbild.repository.user
/** /**
*/ */
export async function read( export async function read(
user_id : _zeitbild.type.user_id user_id : _zeitbild.type_user_id
) : Promise<_zeitbild.type.user_object> ) : Promise<_zeitbild.type_user_object>
{ {
const row : Record<string, any> = await get_store().read(user_id); const row : Record<string, any> = await get_store().read(user_id);
const user_object : _zeitbild.type.user_object = decode(row); const user_object : _zeitbild.type_user_object = decode(row);
return Promise.resolve<_zeitbild.type.user_object>(user_object); return Promise.resolve<_zeitbild.type_user_object>(user_object);
} }
/** /**
*/ */
export async function create( export async function create(
user_object : _zeitbild.type.user_object user_object : _zeitbild.type_user_object
) : Promise<_zeitbild.type.user_id> ) : Promise<_zeitbild.type_user_id>
{ {
const row : Record<string, any> = encode(user_object); const row : Record<string, any> = encode(user_object);
const user_id : _zeitbild.type.user_id = await get_store().create(row); const user_id : _zeitbild.type_user_id = await get_store().create(row);
return Promise.resolve<_zeitbild.type.user_id>(user_id); return Promise.resolve<_zeitbild.type_user_id>(user_id);
} }
@ -98,9 +98,9 @@ namespace _zeitbild.repository.user
*/ */
export async function identify( export async function identify(
name : string name : string
) : Promise<_zeitbild.type.user_id> ) : Promise<_zeitbild.type_user_id>
{ {
const hits : Array<{key : _zeitbild.type.user_id; preview : any;}> = await get_store().search( const hits : Array<{key : _zeitbild.type_user_id; preview : any;}> = await get_store().search(
{ {
"expression": "(name = $name)", "expression": "(name = $name)",
"arguments": { "arguments": {
@ -109,10 +109,10 @@ namespace _zeitbild.repository.user
} }
); );
if (hits.length <= 0) { if (hits.length <= 0) {
return Promise.reject<_zeitbild.type.user_id>(new Error("not found")); return Promise.reject<_zeitbild.type_user_id>(new Error("not found"));
} }
else { else {
return Promise.resolve<_zeitbild.type.user_id>(hits[0].key); return Promise.resolve<_zeitbild.type_user_id>(hits[0].key);
} }
} }

View file

@ -5,8 +5,8 @@ namespace _zeitbild.service.calendar
/** /**
*/ */
export function add( export function add(
calendar_object : _zeitbild.type.calendar_object calendar_object : _zeitbild.type_calendar_object
) : Promise<_zeitbild.type.calendar_id> ) : Promise<_zeitbild.type_calendar_id>
{ {
return _zeitbild.repository.calendar.create(calendar_object); return _zeitbild.repository.calendar.create(calendar_object);
} }
@ -19,7 +19,7 @@ namespace _zeitbild.service.calendar
) : Promise< ) : Promise<
Array< Array<
{ {
id : _zeitbild.type.calendar_id; id : _zeitbild.type_calendar_id;
preview : { preview : {
name : string; name : string;
} }
@ -44,13 +44,13 @@ namespace _zeitbild.service.calendar
/** /**
*/ */
export function overview( export function overview(
user_id : _zeitbild.type.user_id user_id : _zeitbild.type_user_id
) : Promise< ) : Promise<
Array< Array<
{ {
id : _zeitbild.type.calendar_id; id : _zeitbild.type_calendar_id;
name : string; name : string;
access_level : _zeitbild.type.enum_access_level; access_level : _zeitbild.enum_access_level;
} }
> >
> >
@ -62,8 +62,8 @@ namespace _zeitbild.service.calendar
/** /**
*/ */
export async function get( export async function get(
calendar_id : _zeitbild.type.calendar_id calendar_id : _zeitbild.type_calendar_id
) : Promise<_zeitbild.type.calendar_object> ) : Promise<_zeitbild.type_calendar_object>
{ {
return _zeitbild.repository.calendar.read(calendar_id); return _zeitbild.repository.calendar.read(calendar_id);
} }
@ -72,23 +72,23 @@ namespace _zeitbild.service.calendar
/** /**
*/ */
async function get_events( async function get_events(
calendar_id : _zeitbild.type.calendar_id, calendar_id : _zeitbild.type_calendar_id,
from_pit : _zeitbild.helpers.type_pit, from_pit : _zeitbild.helpers.type_pit,
to_pit : _zeitbild.helpers.type_pit to_pit : _zeitbild.helpers.type_pit
) : Promise< ) : Promise<
Array< Array<
_zeitbild.type.event_object _zeitbild.type_event_object
> >
> >
{ {
const calendar_object : _zeitbild.type.calendar_object = await _zeitbild.repository.calendar.read(calendar_id); const calendar_object : _zeitbild.type_calendar_object = await _zeitbild.repository.calendar.read(calendar_id);
const resource_object : _zeitbild.type.resource_object = await _zeitbild.repository.resource.read(calendar_object.resource_id); const resource_object : _zeitbild.type_resource_object = await _zeitbild.repository.resource.read(calendar_object.resource_id);
switch (resource_object.kind) { switch (resource_object.kind) {
case "local": { case "local": {
return Promise.resolve( return Promise.resolve(
resource_object.data.events resource_object.data.events
.filter( .filter(
(event : _zeitbild.type.event_object) => _zeitbild.helpers.pit_is_between( (event : _zeitbild.type_event_object) => _zeitbild.helpers.pit_is_between(
_zeitbild.helpers.pit_from_datetime(event.begin), _zeitbild.helpers.pit_from_datetime(event.begin),
from_pit, from_pit,
to_pit to_pit
@ -190,15 +190,15 @@ namespace _zeitbild.service.calendar
/** /**
*/ */
export async function gather_events( export async function gather_events(
calendar_ids : Array<_zeitbild.type.calendar_id>, calendar_ids : Array<_zeitbild.type_calendar_id>,
from_pit : _zeitbild.helpers.type_pit, from_pit : _zeitbild.helpers.type_pit,
to_pit : _zeitbild.helpers.type_pit to_pit : _zeitbild.helpers.type_pit
) : Promise< ) : Promise<
Array< Array<
{ {
calendar_id : _zeitbild.type.calendar_id; calendar_id : _zeitbild.type_calendar_id;
calendar_name : string; calendar_name : string;
event : _zeitbild.type.event_object; event : _zeitbild.type_event_object;
} }
> >
> >
@ -208,10 +208,10 @@ namespace _zeitbild.service.calendar
calendar_ids calendar_ids
.map( .map(
async (calendar_id) => { async (calendar_id) => {
const calendar_object : _zeitbild.type.calendar_object = await _zeitbild.repository.calendar.read( const calendar_object : _zeitbild.type_calendar_object = await _zeitbild.repository.calendar.read(
calendar_id calendar_id
); );
const events : Array<_zeitbild.type.event_object> = await get_events( const events : Array<_zeitbild.type_event_object> = await get_events(
calendar_id, calendar_id,
from_pit, from_pit,
to_pit to_pit

View file

@ -5,8 +5,8 @@ namespace _zeitbild.service.resource
/** /**
*/ */
export function add( export function add(
resource_object : _zeitbild.type.resource_object resource_object : _zeitbild.type_resource_object
) : Promise<_zeitbild.type.resource_id> ) : Promise<_zeitbild.type_resource_id>
{ {
return _zeitbild.repository.resource.create(resource_object); return _zeitbild.repository.resource.create(resource_object);
} }

View file

@ -5,8 +5,8 @@ namespace _zeitbild.service.user
/** /**
*/ */
export function add( export function add(
user_object : _zeitbild.type.user_object user_object : _zeitbild.type_user_object
) : Promise<_zeitbild.type.user_id> ) : Promise<_zeitbild.type_user_id>
{ {
return _zeitbild.repository.user.create(user_object); return _zeitbild.repository.user.create(user_object);
} }
@ -16,7 +16,7 @@ namespace _zeitbild.service.user
*/ */
export function identify( export function identify(
name : string name : string
) : Promise<_zeitbild.type.user_id> ) : Promise<_zeitbild.type_user_id>
{ {
return _zeitbild.repository.user.identify(name); return _zeitbild.repository.user.identify(name);
} }

View file

@ -1,7 +1,7 @@
/** /**
*/ */
namespace _zeitbild.type namespace _zeitbild
{ {
/** /**
@ -16,12 +16,12 @@ namespace _zeitbild.type
/** /**
*/ */
export type user_id = int; export type type_user_id = int;
/** /**
*/ */
export type user_object = { export type type_user_object = {
name : string; name : string;
email_address : ( email_address : (
null null
@ -33,7 +33,7 @@ namespace _zeitbild.type
/** /**
*/ */
export type event_object = { export type type_event_object = {
name : string; name : string;
begin : _zeitbild.helpers.type_datetime; begin : _zeitbild.helpers.type_datetime;
end : ( end : (
@ -56,17 +56,17 @@ namespace _zeitbild.type
/** /**
*/ */
export type resource_id = int; export type type_resource_id = int;
/** /**
*/ */
export type resource_object = ( export type type_resource_object = (
{ {
kind : "local"; kind : "local";
data : { data : {
events : Array< events : Array<
event_object type_event_object
>; >;
}; };
} }
@ -83,21 +83,21 @@ namespace _zeitbild.type
/** /**
*/ */
export type calendar_id = int; export type type_calendar_id = int;
/** /**
*/ */
export type calendar_object = { export type type_calendar_object = {
name : string; name : string;
access : { access : {
default_level : enum_access_level; default_level : enum_access_level;
attributed : lib_plankton.map.type_map< attributed : lib_plankton.map.type_map<
user_id, type_user_id,
enum_access_level enum_access_level
>; >;
}; };
resource_id : resource_id; resource_id : type_resource_id;
}; };
} }

View file

@ -7,14 +7,14 @@ namespace _zeitbild.value_object.access_level
/** /**
*/ */
export function to_string( export function to_string(
access_level : _zeitbild.type.enum_access_level access_level : _zeitbild.enum_access_level
) : string ) : string
{ {
switch (access_level) { switch (access_level) {
case _zeitbild.type.enum_access_level.none: {return "none";} case _zeitbild.enum_access_level.none: {return "none";}
case _zeitbild.type.enum_access_level.view: {return "view";} case _zeitbild.enum_access_level.view: {return "view";}
case _zeitbild.type.enum_access_level.edit: {return "edit";} case _zeitbild.enum_access_level.edit: {return "edit";}
case _zeitbild.type.enum_access_level.admin: {return "admin";} case _zeitbild.enum_access_level.admin: {return "admin";}
default: {throw (new Error("invalid access level: " + String(access_level)));} default: {throw (new Error("invalid access level: " + String(access_level)));}
} }
} }
@ -24,13 +24,13 @@ namespace _zeitbild.value_object.access_level
*/ */
export function from_string( export function from_string(
access_level_ : string access_level_ : string
) : _zeitbild.type.enum_access_level ) : _zeitbild.enum_access_level
{ {
switch (access_level_) { switch (access_level_) {
case "none": {return _zeitbild.type.enum_access_level.none;} case "none": {return _zeitbild.enum_access_level.none;}
case "view": {return _zeitbild.type.enum_access_level.view;} case "view": {return _zeitbild.enum_access_level.view;}
case "edit": {return _zeitbild.type.enum_access_level.edit;} case "edit": {return _zeitbild.enum_access_level.edit;}
case "admin": {return _zeitbild.type.enum_access_level.admin;} case "admin": {return _zeitbild.enum_access_level.admin;}
default: {throw (new Error("invalid encoded access level: " + String(access_level_)));} default: {throw (new Error("invalid encoded access level: " + String(access_level_)));}
} }
} }
@ -39,15 +39,15 @@ namespace _zeitbild.value_object.access_level
/** /**
*/ */
export function order( export function order(
x : _zeitbild.type.enum_access_level, x : _zeitbild.enum_access_level,
y : _zeitbild.type.enum_access_level y : _zeitbild.enum_access_level
) : boolean ) : boolean
{ {
const list : Array<_zeitbild.type.enum_access_level> = [ const list : Array<_zeitbild.enum_access_level> = [
_zeitbild.type.enum_access_level.none, _zeitbild.enum_access_level.none,
_zeitbild.type.enum_access_level.view, _zeitbild.enum_access_level.view,
_zeitbild.type.enum_access_level.edit, _zeitbild.enum_access_level.edit,
_zeitbild.type.enum_access_level.admin, _zeitbild.enum_access_level.admin,
]; ];
return (list.indexOf(x) <= list.indexOf(y)); return (list.indexOf(x) <= list.indexOf(y));
} }