[mod] types
This commit is contained in:
parent
2f6514c10b
commit
7ead0d85bc
11 changed files with 127 additions and 127 deletions
|
@ -57,7 +57,7 @@ namespace _zeitbild.api
|
|||
"restriction": restriction_logged_in,
|
||||
"execution": async (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 (
|
||||
_zeitbild.service.calendar.overview(user_id)
|
||||
|
|
|
@ -15,14 +15,14 @@ namespace _zeitbild.api
|
|||
calendar_ids : (
|
||||
null
|
||||
|
|
||||
Array<_zeitbild.type.calendar_id>
|
||||
Array<_zeitbild.type_calendar_id>
|
||||
);
|
||||
},
|
||||
Array<
|
||||
{
|
||||
calendar_id : int;
|
||||
calendar_name : string;
|
||||
event : _zeitbild.type.event_object;
|
||||
event : _zeitbild.type_event_object;
|
||||
}
|
||||
>
|
||||
>(
|
||||
|
@ -103,11 +103,11 @@ namespace _zeitbild.api
|
|||
"restriction": restriction_none, // TODO
|
||||
"execution": async (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 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)
|
||||
&&
|
||||
|
@ -125,11 +125,11 @@ namespace _zeitbild.api
|
|||
:
|
||||
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))
|
||||
.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)
|
||||
?
|
||||
|
|
|
@ -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 : {
|
||||
user : Record<
|
||||
int,
|
||||
_zeitbild.type.user_id
|
||||
_zeitbild.type_user_id
|
||||
>;
|
||||
calendar : Record<
|
||||
int,
|
||||
_zeitbild.type.user_id
|
||||
_zeitbild.type_user_id
|
||||
>;
|
||||
} = {
|
||||
"user": {},
|
||||
"calendar": {},
|
||||
};
|
||||
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,
|
||||
"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
|
||||
);
|
||||
await _zeitbild.service.auth_internal.set(
|
||||
|
@ -63,11 +63,11 @@ async function data_init(
|
|||
track.user[user_raw.id] = user_id;
|
||||
}
|
||||
for await (const calendar_raw of data.calendars) {
|
||||
const resource_object : _zeitbild.type.resource_object = calendar_raw.resource;
|
||||
const resource_id : _zeitbild.type.resource_id = await _zeitbild.service.resource.add(
|
||||
const resource_object : _zeitbild.type_resource_object = calendar_raw.resource;
|
||||
const resource_id : _zeitbild.type_resource_id = await _zeitbild.service.resource.add(
|
||||
resource_object
|
||||
);
|
||||
const calendar_object : _zeitbild.type.calendar_object = {
|
||||
const calendar_object : _zeitbild.type_calendar_object = {
|
||||
"name": calendar_raw.name,
|
||||
"access": {
|
||||
"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,
|
||||
};
|
||||
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
|
||||
);
|
||||
track.calendar[calendar_raw.id] = calendar_id;
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace _zeitbild.repository.calendar
|
|||
null
|
||||
|
|
||||
lib_plankton.storage.type_store<
|
||||
_zeitbild.type.calendar_id,
|
||||
_zeitbild.type_calendar_id,
|
||||
Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
|
@ -52,7 +52,7 @@ namespace _zeitbild.repository.calendar
|
|||
*/
|
||||
function get_core_store(
|
||||
) : lib_plankton.storage.type_store<
|
||||
_zeitbild.type.calendar_id,
|
||||
_zeitbild.type_calendar_id,
|
||||
Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
|
@ -105,15 +105,15 @@ namespace _zeitbild.repository.calendar
|
|||
/**
|
||||
*/
|
||||
function encode_access_level(
|
||||
access_level : _zeitbild.type.enum_access_level
|
||||
access_level : _zeitbild.enum_access_level
|
||||
) : int
|
||||
{
|
||||
return (
|
||||
[
|
||||
_zeitbild.type.enum_access_level.none,
|
||||
_zeitbild.type.enum_access_level.view,
|
||||
_zeitbild.type.enum_access_level.edit,
|
||||
_zeitbild.type.enum_access_level.admin,
|
||||
_zeitbild.enum_access_level.none,
|
||||
_zeitbild.enum_access_level.view,
|
||||
_zeitbild.enum_access_level.edit,
|
||||
_zeitbild.enum_access_level.admin,
|
||||
].indexOf(access_level)
|
||||
);
|
||||
}
|
||||
|
@ -123,14 +123,14 @@ namespace _zeitbild.repository.calendar
|
|||
*/
|
||||
function decode_access_level(
|
||||
access_level_encoded : int
|
||||
) : _zeitbild.type.enum_access_level
|
||||
) : _zeitbild.enum_access_level
|
||||
{
|
||||
return (
|
||||
[
|
||||
_zeitbild.type.enum_access_level.none,
|
||||
_zeitbild.type.enum_access_level.view,
|
||||
_zeitbild.type.enum_access_level.edit,
|
||||
_zeitbild.type.enum_access_level.admin,
|
||||
_zeitbild.enum_access_level.none,
|
||||
_zeitbild.enum_access_level.view,
|
||||
_zeitbild.enum_access_level.edit,
|
||||
_zeitbild.enum_access_level.admin,
|
||||
][access_level_encoded]
|
||||
);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ namespace _zeitbild.repository.calendar
|
|||
/**
|
||||
*/
|
||||
function encode(
|
||||
object : _zeitbild.type.calendar_object
|
||||
object : _zeitbild.type_calendar_object
|
||||
) : type_dispersal
|
||||
{
|
||||
return {
|
||||
|
@ -166,7 +166,7 @@ namespace _zeitbild.repository.calendar
|
|||
*/
|
||||
function decode(
|
||||
dispersal : type_dispersal
|
||||
) : _zeitbild.type.calendar_object
|
||||
) : _zeitbild.type_calendar_object
|
||||
{
|
||||
return {
|
||||
"name": dispersal.core_row["name"],
|
||||
|
@ -196,7 +196,7 @@ namespace _zeitbild.repository.calendar
|
|||
) : Promise<
|
||||
Array<
|
||||
{
|
||||
id : _zeitbild.type.calendar_id;
|
||||
id : _zeitbild.type_calendar_id;
|
||||
preview : {
|
||||
name : string;
|
||||
};
|
||||
|
@ -242,8 +242,8 @@ namespace _zeitbild.repository.calendar
|
|||
/**
|
||||
*/
|
||||
export function read(
|
||||
id : _zeitbild.type.calendar_id
|
||||
) : Promise<_zeitbild.type.calendar_object>
|
||||
id : _zeitbild.type_calendar_id
|
||||
) : Promise<_zeitbild.type_calendar_object>
|
||||
{
|
||||
return (
|
||||
get_core_store().read(id)
|
||||
|
@ -266,7 +266,7 @@ namespace _zeitbild.repository.calendar
|
|||
)
|
||||
)
|
||||
.then(
|
||||
(dispersal) => Promise.resolve<_zeitbild.type.calendar_object>(
|
||||
(dispersal) => Promise.resolve<_zeitbild.type_calendar_object>(
|
||||
decode(dispersal)
|
||||
)
|
||||
)
|
||||
|
@ -279,18 +279,18 @@ namespace _zeitbild.repository.calendar
|
|||
/**
|
||||
*/
|
||||
export function create(
|
||||
calendar_object : _zeitbild.type.calendar_object
|
||||
) : Promise<_zeitbild.type.calendar_id>
|
||||
calendar_object : _zeitbild.type_calendar_object
|
||||
) : Promise<_zeitbild.type_calendar_id>
|
||||
{
|
||||
return (
|
||||
Promise.resolve<_zeitbild.type.calendar_object>(calendar_object)
|
||||
Promise.resolve<_zeitbild.type_calendar_object>(calendar_object)
|
||||
.then<type_dispersal>(
|
||||
(calendar_object) => Promise.resolve<type_dispersal>(encode(calendar_object))
|
||||
)
|
||||
.then<_zeitbild.type.calendar_id>(
|
||||
.then<_zeitbild.type_calendar_id>(
|
||||
(dispersal) => (
|
||||
get_core_store().create(dispersal.core_row)
|
||||
.then<_zeitbild.type.calendar_id>(
|
||||
.then<_zeitbild.type_calendar_id>(
|
||||
(calendar_id) => (
|
||||
Promise.all(
|
||||
dispersal.access_attributed_rows
|
||||
|
@ -302,7 +302,7 @@ namespace _zeitbild.repository.calendar
|
|||
)
|
||||
)
|
||||
.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(
|
||||
user_id : _zeitbild.type.user_id
|
||||
user_id : _zeitbild.type_user_id
|
||||
) : Promise<
|
||||
Array<
|
||||
{
|
||||
id : _zeitbild.type.calendar_id;
|
||||
id : _zeitbild.type_calendar_id;
|
||||
name : string;
|
||||
access_level : _zeitbild.type.enum_access_level;
|
||||
access_level : _zeitbild.enum_access_level;
|
||||
}
|
||||
>
|
||||
>
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace _zeitbild.repository.resource
|
|||
null
|
||||
|
|
||||
lib_plankton.storage.type_store<
|
||||
_zeitbild.type.resource_id,
|
||||
_zeitbild.type_resource_id,
|
||||
Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
|
@ -147,7 +147,7 @@ namespace _zeitbild.repository.resource
|
|||
*/
|
||||
function get_resource_core_store(
|
||||
) : lib_plankton.storage.type_store<
|
||||
_zeitbild.type.resource_id,
|
||||
_zeitbild.type_resource_id,
|
||||
Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
|
@ -175,7 +175,7 @@ namespace _zeitbild.repository.resource
|
|||
/*
|
||||
function encode_resource_core(
|
||||
stuff : {
|
||||
object : _zeitbild.type.resource_object;
|
||||
object : _zeitbild.type_resource_object;
|
||||
sub_id : int;
|
||||
}
|
||||
) : Record<string, any>
|
||||
|
@ -195,7 +195,7 @@ namespace _zeitbild.repository.resource
|
|||
function decode_resource_core(
|
||||
row : Record<string, any>
|
||||
) : {
|
||||
object : _zeitbild.type.resource_object;
|
||||
object : _zeitbild.type_resource_object;
|
||||
sub_id : int;
|
||||
}
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ namespace _zeitbild.repository.resource
|
|||
/**
|
||||
*/
|
||||
function encode_event(
|
||||
event : _zeitbild.type.event_object,
|
||||
event : _zeitbild.type_event_object,
|
||||
local_resource_id : int
|
||||
) : Record<string, any>
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ namespace _zeitbild.repository.resource
|
|||
*/
|
||||
function decode_event(
|
||||
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 parts : Array<string> = datetime_raw.split("|");
|
||||
|
@ -351,8 +351,8 @@ namespace _zeitbild.repository.resource
|
|||
/**
|
||||
*/
|
||||
export async function read(
|
||||
resource_id : _zeitbild.type.resource_id
|
||||
) : Promise<_zeitbild.type.resource_object>
|
||||
resource_id : _zeitbild.type_resource_id
|
||||
) : Promise<_zeitbild.type_resource_object>
|
||||
{
|
||||
const dataset_core : Record<string, any> = await get_resource_core_store().read(resource_id);
|
||||
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",
|
||||
"data": {
|
||||
|
@ -377,7 +377,7 @@ namespace _zeitbild.repository.resource
|
|||
}
|
||||
case "caldav": {
|
||||
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",
|
||||
"data": {
|
||||
|
@ -389,7 +389,7 @@ namespace _zeitbild.repository.resource
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
return Promise.reject<_zeitbild.type.resource_object>(
|
||||
return Promise.reject<_zeitbild.type_resource_object>(
|
||||
new Error("invalid resource kind: " + dataset_core.kind)
|
||||
);
|
||||
break;
|
||||
|
@ -401,8 +401,8 @@ namespace _zeitbild.repository.resource
|
|||
/**
|
||||
*/
|
||||
export async function create(
|
||||
resource_object : _zeitbild.type.resource_object
|
||||
) : Promise<_zeitbild.type.resource_id>
|
||||
resource_object : _zeitbild.type_resource_object
|
||||
) : Promise<_zeitbild.type_resource_id>
|
||||
{
|
||||
switch (resource_object.kind) {
|
||||
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",
|
||||
"sub_id": local_resource_id,
|
||||
}
|
||||
);
|
||||
return Promise.resolve<_zeitbild.type.resource_id>(resource_id);
|
||||
return Promise.resolve<_zeitbild.type_resource_id>(resource_id);
|
||||
break;
|
||||
}
|
||||
case "caldav": {
|
||||
|
@ -435,13 +435,13 @@ namespace _zeitbild.repository.resource
|
|||
"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",
|
||||
"sub_id": caldav_resource_id,
|
||||
}
|
||||
);
|
||||
return Promise.resolve<_zeitbild.type.resource_id>(resource_id);
|
||||
return Promise.resolve<_zeitbild.type_resource_id>(resource_id);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace _zeitbild.repository.user
|
|||
null
|
||||
|
|
||||
lib_plankton.storage.type_store<
|
||||
_zeitbild.type.user_id,
|
||||
_zeitbild.type_user_id,
|
||||
Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
|
@ -21,7 +21,7 @@ namespace _zeitbild.repository.user
|
|||
*/
|
||||
function get_store(
|
||||
) : lib_plankton.storage.type_store<
|
||||
_zeitbild.type.user_id,
|
||||
_zeitbild.type_user_id,
|
||||
Record<string, any>,
|
||||
{},
|
||||
lib_plankton.storage.type_sql_table_autokey_search_term,
|
||||
|
@ -47,7 +47,7 @@ namespace _zeitbild.repository.user
|
|||
/**
|
||||
*/
|
||||
function encode(
|
||||
user_object : _zeitbild.type.user_object
|
||||
user_object : _zeitbild.type_user_object
|
||||
) : Record<string, any>
|
||||
{
|
||||
return {
|
||||
|
@ -61,7 +61,7 @@ namespace _zeitbild.repository.user
|
|||
*/
|
||||
function decode(
|
||||
row : Record<string, any>
|
||||
) : _zeitbild.type.user_object
|
||||
) : _zeitbild.type_user_object
|
||||
{
|
||||
return {
|
||||
"name": row["name"],
|
||||
|
@ -73,24 +73,24 @@ namespace _zeitbild.repository.user
|
|||
/**
|
||||
*/
|
||||
export async function read(
|
||||
user_id : _zeitbild.type.user_id
|
||||
) : Promise<_zeitbild.type.user_object>
|
||||
user_id : _zeitbild.type_user_id
|
||||
) : Promise<_zeitbild.type_user_object>
|
||||
{
|
||||
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);
|
||||
const user_object : _zeitbild.type_user_object = decode(row);
|
||||
return Promise.resolve<_zeitbild.type_user_object>(user_object);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function create(
|
||||
user_object : _zeitbild.type.user_object
|
||||
) : Promise<_zeitbild.type.user_id>
|
||||
user_object : _zeitbild.type_user_object
|
||||
) : Promise<_zeitbild.type_user_id>
|
||||
{
|
||||
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);
|
||||
const user_id : _zeitbild.type_user_id = await get_store().create(row);
|
||||
return Promise.resolve<_zeitbild.type_user_id>(user_id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,9 +98,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 : any;}> = await get_store().search(
|
||||
const hits : Array<{key : _zeitbild.type_user_id; preview : any;}> = await get_store().search(
|
||||
{
|
||||
"expression": "(name = $name)",
|
||||
"arguments": {
|
||||
|
@ -109,10 +109,10 @@ namespace _zeitbild.repository.user
|
|||
}
|
||||
);
|
||||
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 {
|
||||
return Promise.resolve<_zeitbild.type.user_id>(hits[0].key);
|
||||
return Promise.resolve<_zeitbild.type_user_id>(hits[0].key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace _zeitbild.service.calendar
|
|||
/**
|
||||
*/
|
||||
export function add(
|
||||
calendar_object : _zeitbild.type.calendar_object
|
||||
) : Promise<_zeitbild.type.calendar_id>
|
||||
calendar_object : _zeitbild.type_calendar_object
|
||||
) : Promise<_zeitbild.type_calendar_id>
|
||||
{
|
||||
return _zeitbild.repository.calendar.create(calendar_object);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace _zeitbild.service.calendar
|
|||
) : Promise<
|
||||
Array<
|
||||
{
|
||||
id : _zeitbild.type.calendar_id;
|
||||
id : _zeitbild.type_calendar_id;
|
||||
preview : {
|
||||
name : string;
|
||||
}
|
||||
|
@ -44,13 +44,13 @@ namespace _zeitbild.service.calendar
|
|||
/**
|
||||
*/
|
||||
export function overview(
|
||||
user_id : _zeitbild.type.user_id
|
||||
user_id : _zeitbild.type_user_id
|
||||
) : Promise<
|
||||
Array<
|
||||
{
|
||||
id : _zeitbild.type.calendar_id;
|
||||
id : _zeitbild.type_calendar_id;
|
||||
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(
|
||||
calendar_id : _zeitbild.type.calendar_id
|
||||
) : Promise<_zeitbild.type.calendar_object>
|
||||
calendar_id : _zeitbild.type_calendar_id
|
||||
) : Promise<_zeitbild.type_calendar_object>
|
||||
{
|
||||
return _zeitbild.repository.calendar.read(calendar_id);
|
||||
}
|
||||
|
@ -72,23 +72,23 @@ namespace _zeitbild.service.calendar
|
|||
/**
|
||||
*/
|
||||
async function get_events(
|
||||
calendar_id : _zeitbild.type.calendar_id,
|
||||
calendar_id : _zeitbild.type_calendar_id,
|
||||
from_pit : _zeitbild.helpers.type_pit,
|
||||
to_pit : _zeitbild.helpers.type_pit
|
||||
) : Promise<
|
||||
Array<
|
||||
_zeitbild.type.event_object
|
||||
_zeitbild.type_event_object
|
||||
>
|
||||
>
|
||||
{
|
||||
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 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);
|
||||
switch (resource_object.kind) {
|
||||
case "local": {
|
||||
return Promise.resolve(
|
||||
resource_object.data.events
|
||||
.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),
|
||||
from_pit,
|
||||
to_pit
|
||||
|
@ -190,15 +190,15 @@ namespace _zeitbild.service.calendar
|
|||
/**
|
||||
*/
|
||||
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,
|
||||
to_pit : _zeitbild.helpers.type_pit
|
||||
) : Promise<
|
||||
Array<
|
||||
{
|
||||
calendar_id : _zeitbild.type.calendar_id;
|
||||
calendar_id : _zeitbild.type_calendar_id;
|
||||
calendar_name : string;
|
||||
event : _zeitbild.type.event_object;
|
||||
event : _zeitbild.type_event_object;
|
||||
}
|
||||
>
|
||||
>
|
||||
|
@ -208,10 +208,10 @@ namespace _zeitbild.service.calendar
|
|||
calendar_ids
|
||||
.map(
|
||||
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
|
||||
);
|
||||
const events : Array<_zeitbild.type.event_object> = await get_events(
|
||||
const events : Array<_zeitbild.type_event_object> = await get_events(
|
||||
calendar_id,
|
||||
from_pit,
|
||||
to_pit
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace _zeitbild.service.resource
|
|||
/**
|
||||
*/
|
||||
export function add(
|
||||
resource_object : _zeitbild.type.resource_object
|
||||
) : Promise<_zeitbild.type.resource_id>
|
||||
resource_object : _zeitbild.type_resource_object
|
||||
) : Promise<_zeitbild.type_resource_id>
|
||||
{
|
||||
return _zeitbild.repository.resource.create(resource_object);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace _zeitbild.service.user
|
|||
/**
|
||||
*/
|
||||
export function add(
|
||||
user_object : _zeitbild.type.user_object
|
||||
) : Promise<_zeitbild.type.user_id>
|
||||
user_object : _zeitbild.type_user_object
|
||||
) : Promise<_zeitbild.type_user_id>
|
||||
{
|
||||
return _zeitbild.repository.user.create(user_object);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace _zeitbild.service.user
|
|||
*/
|
||||
export function identify(
|
||||
name : string
|
||||
) : Promise<_zeitbild.type.user_id>
|
||||
) : Promise<_zeitbild.type_user_id>
|
||||
{
|
||||
return _zeitbild.repository.user.identify(name);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
email_address : (
|
||||
null
|
||||
|
@ -33,7 +33,7 @@ namespace _zeitbild.type
|
|||
|
||||
/**
|
||||
*/
|
||||
export type event_object = {
|
||||
export type type_event_object = {
|
||||
name : string;
|
||||
begin : _zeitbild.helpers.type_datetime;
|
||||
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";
|
||||
data : {
|
||||
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;
|
||||
access : {
|
||||
default_level : enum_access_level;
|
||||
attributed : lib_plankton.map.type_map<
|
||||
user_id,
|
||||
type_user_id,
|
||||
enum_access_level
|
||||
>;
|
||||
};
|
||||
resource_id : resource_id;
|
||||
resource_id : type_resource_id;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@ namespace _zeitbild.value_object.access_level
|
|||
/**
|
||||
*/
|
||||
export function to_string(
|
||||
access_level : _zeitbild.type.enum_access_level
|
||||
access_level : _zeitbild.enum_access_level
|
||||
) : string
|
||||
{
|
||||
switch (access_level) {
|
||||
case _zeitbild.type.enum_access_level.none: {return "none";}
|
||||
case _zeitbild.type.enum_access_level.view: {return "view";}
|
||||
case _zeitbild.type.enum_access_level.edit: {return "edit";}
|
||||
case _zeitbild.type.enum_access_level.admin: {return "admin";}
|
||||
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)));}
|
||||
}
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ namespace _zeitbild.value_object.access_level
|
|||
*/
|
||||
export function from_string(
|
||||
access_level_ : string
|
||||
) : _zeitbild.type.enum_access_level
|
||||
) : _zeitbild.enum_access_level
|
||||
{
|
||||
switch (access_level_) {
|
||||
case "none": {return _zeitbild.type.enum_access_level.none;}
|
||||
case "view": {return _zeitbild.type.enum_access_level.view;}
|
||||
case "edit": {return _zeitbild.type.enum_access_level.edit;}
|
||||
case "admin": {return _zeitbild.type.enum_access_level.admin;}
|
||||
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_)));}
|
||||
}
|
||||
}
|
||||
|
@ -39,15 +39,15 @@ namespace _zeitbild.value_object.access_level
|
|||
/**
|
||||
*/
|
||||
export function order(
|
||||
x : _zeitbild.type.enum_access_level,
|
||||
y : _zeitbild.type.enum_access_level
|
||||
x : _zeitbild.enum_access_level,
|
||||
y : _zeitbild.enum_access_level
|
||||
) : boolean
|
||||
{
|
||||
const list : Array<_zeitbild.type.enum_access_level> = [
|
||||
_zeitbild.type.enum_access_level.none,
|
||||
_zeitbild.type.enum_access_level.view,
|
||||
_zeitbild.type.enum_access_level.edit,
|
||||
_zeitbild.type.enum_access_level.admin,
|
||||
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));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue