This commit is contained in:
roydfalk 2025-08-21 21:46:05 +00:00
parent ff75196d26
commit ebc9baa4b3
11 changed files with 359 additions and 31 deletions

View file

@ -31,28 +31,28 @@
"members": [ "members": [
{ {
"id": 1, "id": 1,
"name": "Alexandra Ahorn", "name": "alexandra",
"email_address_private": "alex-rockt@example.org", "email_address": "alex-rockt@example.org",
"groups": [1, 2, 3] "groups": [1, 2, 3]
}, },
{ {
"id": 2, "id": 2,
"name": "Berthold Buche", "name": "berthold",
"email_address_private": "bert-ohne-ernie@example.org", "email_address": "bert-ohne-ernie@example.org",
"groups": [4, 5, 2] "groups": [4, 5, 2]
}, },
{ {
"id": 3, "id": 3,
"name": "Charlotte Castania", "name": "charlotte",
"email_adress_private": "charly-the-unicorn@example.org", "email_address": "charly-the-unicorn@example.org",
"groups": [4, 1] "groups": [4, 1]
} }
], ],
"invites": [ "invitations": [
{ {
"id": 1, "id": 1,
"name_changeable": true, "name_changeable": true,
"name_value": "Daniel Distel", "name_value": "daniel",
"email_address_changeable": true, "email_address_changeable": true,
"email_address_value": "duesentrieb@example.org", "email_address_value": "duesentrieb@example.org",
"groups_changeable": false, "groups_changeable": false,

View file

@ -0,0 +1,69 @@
/*
Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Backend
Copyright (C) 2024 Christian Fraß
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see
<https://www.gnu.org/licenses/>.
*/
namespace _espe.api
{
/**
*/
export function register_group_add(
rest_subject : lib_plankton.rest_http.type_rest
) : void
{
lib_plankton.rest_http.register<
string,
(string | _espe.type.group_id)
>(
rest_subject,
lib_plankton.http.enum_method.post,
_espe.api.full_path("/group/add"),
{
/**
* @todo translation
*/
"description": () => "erstellt eine Gruppe",
"input_schema": () => ({
"nullable": false,
"type": "string",
}),
"output_schema": () => ({
"nullable": false,
"type": "number",
}),
"restriction": () => restriction_logged_in,
"execution": () => async ({"input": input}) => {
if (input === null) {
return Promise.resolve({
"status_code": 400,
"data": ""
});
}
else {
const data = await _espe.service.group.add(
{
"name": input
}
);
return Promise.resolve({
"status_code": 200,
"data": data
});
}
}
}
);
}
}

View file

@ -0,0 +1,75 @@
/*
Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Backend
Copyright (C) 2024 Christian Fraß
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see
<https://www.gnu.org/licenses/>.
*/
namespace _espe.api
{
/**
*/
export function register_group_list(
rest_subject : lib_plankton.rest_http.type_rest
) : void
{
lib_plankton.rest_http.register<
null,
Array<
{
id : _espe.type.invitation_id;
name : string;
}
>
>(
rest_subject,
lib_plankton.http.enum_method.get,
_espe.api.full_path("/group/list"),
{
/**
* @todo translation
*/
"description": () => "listet alle Gruppen auf",
"output_schema": () => ({
"type": "object",
"nullable": false,
"additionalProperties": false,
"properties": {
"id": {
"nullable": false,
"type": "intiger",
"description": "ID"
},
"name": {
"nullable": false,
"type": "string",
"description": "Name"
},
},
"required": [
"id",
"name",
]
}),
"restriction": () => restriction_logged_in,
"execution": () => async ({}) => {
const data = await _espe.service.group.list();
return Promise.resolve({
"status_code": 200,
"data": data
});
}
}
);
}
}

View file

@ -0,0 +1,83 @@
/*
Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Backend
Copyright (C) 2024 Christian Fraß
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see
<https://www.gnu.org/licenses/>.
*/
namespace _espe.api
{
/**
*/
export function register_group_modify(
rest_subject : lib_plankton.rest_http.type_rest
) : void
{
lib_plankton.rest_http.register<
{
name : string;
},
null
>(
rest_subject,
lib_plankton.http.enum_method.patch,
_espe.api.full_path("/group/modify/:id"),
{
/**
* @todo translation
*/
"description": () => "ändert eine Gruppe",
"input_schema": () => ({
"nullable": false,
"type": "object",
"properties": {
"name": {
"nullable": false,
"type": "string",
}
},
"additionalProperties": false,
"required": [
"name",
]
}),
"output_schema": () => ({
"nullable": true,
}),
"restriction": () => restriction_logged_in,
"execution": () => async ({"path_parameters": path_parameters, "input": input}) => {
if (input === null) {
return Promise.resolve({
"status_code": 400,
"data": null
});
}
else {
const group_id : _espe.type.group_id = parseInt(path_parameters["id"]);
const group_object : _espe.type.group_object = {
"name": input.name,
};
const data = await _espe.service.group.modify(
group_id,
group_object
);
return Promise.resolve({
"status_code": 200,
"data": null
});
}
}
}
);
}
}

View file

@ -0,0 +1,66 @@
/*
Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Backend
Copyright (C) 2024 Christian Fraß
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see
<https://www.gnu.org/licenses/>.
*/
namespace _espe.api
{
/**
*/
export function register_group_read(
rest_subject : lib_plankton.rest_http.type_rest
) : void
{
lib_plankton.rest_http.register<
null,
{
name : string;
}
>(
rest_subject,
lib_plankton.http.enum_method.get,
_espe.api.full_path("/group/read/:id"),
{
/**
* @todo translation
*/
"description": () => "gibt die Daten zu einer Gruppen aus",
"output_schema": () => ({
"nullable": false,
"type": "object",
"properties": {
"name": {
"nullable": false,
"type": "string",
}
},
"additionalProperties": false,
"required": [
"name",
]
}),
"restriction": () => restriction_logged_in,
"execution": () => async ({"path_parameters": path_parameters}) => {
const group_id : _espe.type.group_id = parseInt(path_parameters["id"]);
const group_object : _espe.type.group_object = await _espe.service.group.get(group_id);
return Promise.resolve({
"status_code": 200,
"data": group_object
});
}
}
);
}
}

View file

@ -43,6 +43,13 @@ namespace _espe.api
_espe.api.register_session_begin(rest_subject); _espe.api.register_session_begin(rest_subject);
_espe.api.register_session_end(rest_subject); _espe.api.register_session_end(rest_subject);
} }
// group
{
_espe.api.register_group_list(rest_subject);
_espe.api.register_group_read(rest_subject);
_espe.api.register_group_add(rest_subject);
_espe.api.register_group_modify(rest_subject);
}
// member // member
{ {
_espe.api.register_member_summon(rest_subject); _espe.api.register_member_summon(rest_subject);

View file

@ -84,7 +84,7 @@ namespace _espe.repository.group
) : _espe.type.group_object ) : _espe.type.group_object
{ {
return { return {
"name": dispersal.core_row["name"], "name": dispersal["name"],
}; };
} }
@ -98,9 +98,7 @@ namespace _espe.repository.group
Array< Array<
{ {
id : _espe.type.group_id; id : _espe.type.group_id;
preview : {
name : string; name : string;
};
} }
> >
> >
@ -123,9 +121,7 @@ namespace _espe.repository.group
.map( .map(
({"key": key, "preview": preview}) => ({ ({"key": key, "preview": preview}) => ({
"id": key, "id": key,
"preview": {
"name": preview["name"], "name": preview["name"],
}
}) })
) )
); );
@ -138,11 +134,9 @@ namespace _espe.repository.group
id : _espe.type.group_id id : _espe.type.group_id
) : Promise<_espe.type.group_object> ) : Promise<_espe.type.group_object>
{ {
const core_row : Record<string, any> = await get_store().read(id); const row : Record<string, any> = await get_store().read(id);
const dispersal : type_dispersal = { const dispersal : type_dispersal = row;
"core_row": core_row,
};
return decode(dispersal); return decode(dispersal);
} }
@ -157,7 +151,7 @@ namespace _espe.repository.group
const dispersal : type_dispersal = encode(value); const dispersal : type_dispersal = encode(value);
// core // core
const id : _espe.type.group_id = await get_store().create(dispersal.core_row); const id : _espe.type.group_id = await get_store().create(dispersal);
return id; return id;
} }
@ -174,7 +168,7 @@ namespace _espe.repository.group
const dispersal : type_dispersal = encode(value); const dispersal : type_dispersal = encode(value);
// core // core
await get_store().update(id, dispersal.core_row); await get_store().update(id, dispersal);
} }

View file

@ -88,7 +88,7 @@ namespace _espe.repository.invitation
{ {
"database_implementation": _espe.helpers.database_implementation(), "database_implementation": _espe.helpers.database_implementation(),
"table_name": "invitation_groups", "table_name": "invitation_groups",
"key_names": ["invitation_id","group_name"], "key_names": ["invitation_id","group_id"],
} }
); );
} }
@ -128,8 +128,8 @@ namespace _espe.repository.invitation
"group_rows": ( "group_rows": (
(object.groups_value ?? []) (object.groups_value ?? [])
.map( .map(
group => ({ group_id => ({
"group_name": group, "group_id": group_id,
}) })
) )
) )
@ -152,7 +152,7 @@ namespace _espe.repository.invitation
"email_address_value": dispersal.core_row["email_address_value"], "email_address_value": dispersal.core_row["email_address_value"],
"groups_changeable": _espe.helpers.dbbool_decode(dispersal.core_row["groups_changeable"]), "groups_changeable": _espe.helpers.dbbool_decode(dispersal.core_row["groups_changeable"]),
"groups_value": lib_plankton.list.sorted<_espe.type.group_id>( "groups_value": lib_plankton.list.sorted<_espe.type.group_id>(
dispersal.group_rows.map(row => row["group_name"]), dispersal.group_rows.map(row => row["group_id"]),
{ {
"compare_element": (group1, group2) => (group1 <= group2) "compare_element": (group1, group2) => (group1 <= group2)
} }
@ -218,7 +218,7 @@ namespace _espe.repository.invitation
"core_row": core_row, "core_row": core_row,
"group_rows": group_hits.map( "group_rows": group_hits.map(
hit => ({ hit => ({
"group_name": hit.preview["group_name"] "group_id": hit.preview["group_id"]
}) })
), ),
}; };
@ -243,7 +243,7 @@ namespace _espe.repository.invitation
await get_group_chest().write( await get_group_chest().write(
[ [
id, id,
group_row["group_name"], group_row["group_id"],
], ],
{ {
"_dummy": null, "_dummy": null,

View file

@ -93,7 +93,7 @@ namespace _espe.sample
{ {
"name": member_raw.name, "name": member_raw.name,
"email_address": member_raw.email_address, "email_address": member_raw.email_address,
"groups": member_raw.groups.map(track_groups.get), "groups": member_raw.groups.map(group_id => track_groups.get(group_id)),
}, },
{ {
"silent": true, "silent": true,
@ -115,7 +115,7 @@ namespace _espe.sample
"email_address_changeable": invitation_raw.email_address_changeable, "email_address_changeable": invitation_raw.email_address_changeable,
"email_address_value": invitation_raw.email_address_value, "email_address_value": invitation_raw.email_address_value,
"groups_changeable": invitation_raw.groups_changeable, "groups_changeable": invitation_raw.groups_changeable,
"groups_value": invitation_raw.groups_value.map(track_groups.get), "groups_value": invitation_raw.groups_value.map(group_id => track_groups.get(group_id)),
} }
); );
} }

View file

@ -16,13 +16,43 @@ You should have received a copy of the GNU General Public License along with thi
namespace _espe.service.group namespace _espe.service.group
{ {
/**
*/
export function list(
) : Promise<Array<{id : _espe.type.group_id; name : string;}>>
{
return _espe.repository.group.list(null);
}
/**
*/
export function get(
id : _espe.type.group_id
) : Promise<_espe.type.group_object>
{
return _espe.repository.group.read(id);
}
/** /**
*/ */
export function add( export function add(
group_object : _espe.type.group_object object : _espe.type.group_object
) : Promise<_espe.type.group_id> ) : Promise<_espe.type.group_id>
{ {
return _espe.repository.group.create(group_object); return _espe.repository.group.create(object);
}
/**
*/
export function modify(
id : _espe.type.group_id,
object : _espe.type.group_object
) : Promise<void>
{
return _espe.repository.group.update(id, object);
} }
} }

View file

@ -61,6 +61,10 @@ ${dir_temp}/espe-core.js ${dir_temp}/espe-core.d.ts: \
${dir_source}/api/actions/meta_spec.ts \ ${dir_source}/api/actions/meta_spec.ts \
${dir_source}/api/actions/session_begin.ts \ ${dir_source}/api/actions/session_begin.ts \
${dir_source}/api/actions/session_end.ts \ ${dir_source}/api/actions/session_end.ts \
${dir_source}/api/actions/group_list.ts \
${dir_source}/api/actions/group_read.ts \
${dir_source}/api/actions/group_add.ts \
${dir_source}/api/actions/group_modify.ts \
${dir_source}/api/actions/member_summon.ts \ ${dir_source}/api/actions/member_summon.ts \
${dir_source}/api/actions/member_list.ts \ ${dir_source}/api/actions/member_list.ts \
${dir_source}/api/actions/member_read.ts \ ${dir_source}/api/actions/member_read.ts \