diff --git a/misc/sampledata.json b/misc/sampledata.json
index abe7e82..56ef685 100644
--- a/misc/sampledata.json
+++ b/misc/sampledata.json
@@ -31,28 +31,28 @@
"members": [
{
"id": 1,
- "name": "Alexandra Ahorn",
- "email_address_private": "alex-rockt@example.org",
+ "name": "alexandra",
+ "email_address": "alex-rockt@example.org",
"groups": [1, 2, 3]
},
{
"id": 2,
- "name": "Berthold Buche",
- "email_address_private": "bert-ohne-ernie@example.org",
+ "name": "berthold",
+ "email_address": "bert-ohne-ernie@example.org",
"groups": [4, 5, 2]
},
{
"id": 3,
- "name": "Charlotte Castania",
- "email_adress_private": "charly-the-unicorn@example.org",
+ "name": "charlotte",
+ "email_address": "charly-the-unicorn@example.org",
"groups": [4, 1]
}
],
- "invites": [
+ "invitations": [
{
"id": 1,
"name_changeable": true,
- "name_value": "Daniel Distel",
+ "name_value": "daniel",
"email_address_changeable": true,
"email_address_value": "duesentrieb@example.org",
"groups_changeable": false,
diff --git a/source/api/actions/group_add.ts b/source/api/actions/group_add.ts
new file mode 100644
index 0000000..c9bd86c
--- /dev/null
+++ b/source/api/actions/group_add.ts
@@ -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
+.
+ */
+
+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
+ });
+ }
+ }
+ }
+ );
+ }
+
+}
diff --git a/source/api/actions/group_list.ts b/source/api/actions/group_list.ts
new file mode 100644
index 0000000..ff9ee23
--- /dev/null
+++ b/source/api/actions/group_list.ts
@@ -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
+.
+ */
+
+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
+ });
+ }
+ }
+ );
+ }
+
+}
diff --git a/source/api/actions/group_modify.ts b/source/api/actions/group_modify.ts
new file mode 100644
index 0000000..450b135
--- /dev/null
+++ b/source/api/actions/group_modify.ts
@@ -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
+.
+ */
+
+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
+ });
+ }
+ }
+ }
+ );
+ }
+
+}
diff --git a/source/api/actions/group_read.ts b/source/api/actions/group_read.ts
new file mode 100644
index 0000000..4e9edbf
--- /dev/null
+++ b/source/api/actions/group_read.ts
@@ -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
+.
+ */
+
+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
+ });
+ }
+ }
+ );
+ }
+
+}
diff --git a/source/api/functions.ts b/source/api/functions.ts
index 5e465ee..3b910fc 100644
--- a/source/api/functions.ts
+++ b/source/api/functions.ts
@@ -43,6 +43,13 @@ namespace _espe.api
_espe.api.register_session_begin(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
{
_espe.api.register_member_summon(rest_subject);
diff --git a/source/repositories/group.ts b/source/repositories/group.ts
index 9129ba7..c4c4ace 100644
--- a/source/repositories/group.ts
+++ b/source/repositories/group.ts
@@ -84,7 +84,7 @@ namespace _espe.repository.group
) : _espe.type.group_object
{
return {
- "name": dispersal.core_row["name"],
+ "name": dispersal["name"],
};
}
@@ -98,9 +98,7 @@ namespace _espe.repository.group
Array<
{
id : _espe.type.group_id;
- preview : {
- name : string;
- };
+ name : string;
}
>
>
@@ -123,9 +121,7 @@ namespace _espe.repository.group
.map(
({"key": key, "preview": preview}) => ({
"id": key,
- "preview": {
- "name": preview["name"],
- }
+ "name": preview["name"],
})
)
);
@@ -138,11 +134,9 @@ namespace _espe.repository.group
id : _espe.type.group_id
) : Promise<_espe.type.group_object>
{
- const core_row : Record = await get_store().read(id);
+ const row : Record = await get_store().read(id);
- const dispersal : type_dispersal = {
- "core_row": core_row,
- };
+ const dispersal : type_dispersal = row;
return decode(dispersal);
}
@@ -157,7 +151,7 @@ namespace _espe.repository.group
const dispersal : type_dispersal = encode(value);
// 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;
}
@@ -174,7 +168,7 @@ namespace _espe.repository.group
const dispersal : type_dispersal = encode(value);
// core
- await get_store().update(id, dispersal.core_row);
+ await get_store().update(id, dispersal);
}
diff --git a/source/repositories/invitation.ts b/source/repositories/invitation.ts
index 9042d72..78bf4e2 100644
--- a/source/repositories/invitation.ts
+++ b/source/repositories/invitation.ts
@@ -88,7 +88,7 @@ namespace _espe.repository.invitation
{
"database_implementation": _espe.helpers.database_implementation(),
"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": (
(object.groups_value ?? [])
.map(
- group => ({
- "group_name": group,
+ group_id => ({
+ "group_id": group_id,
})
)
)
@@ -152,7 +152,7 @@ namespace _espe.repository.invitation
"email_address_value": dispersal.core_row["email_address_value"],
"groups_changeable": _espe.helpers.dbbool_decode(dispersal.core_row["groups_changeable"]),
"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)
}
@@ -218,7 +218,7 @@ namespace _espe.repository.invitation
"core_row": core_row,
"group_rows": group_hits.map(
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(
[
id,
- group_row["group_name"],
+ group_row["group_id"],
],
{
"_dummy": null,
diff --git a/source/sample.ts b/source/sample.ts
index cb9a93f..42e4500 100644
--- a/source/sample.ts
+++ b/source/sample.ts
@@ -93,7 +93,7 @@ namespace _espe.sample
{
"name": member_raw.name,
"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,
@@ -115,7 +115,7 @@ namespace _espe.sample
"email_address_changeable": invitation_raw.email_address_changeable,
"email_address_value": invitation_raw.email_address_value,
"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)),
}
);
}
diff --git a/source/services/group.ts b/source/services/group.ts
index 123b295..9ebd9f0 100644
--- a/source/services/group.ts
+++ b/source/services/group.ts
@@ -16,13 +16,43 @@ You should have received a copy of the GNU General Public License along with thi
namespace _espe.service.group
{
+ /**
+ */
+ export function list(
+ ) : Promise>
+ {
+ 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(
- group_object : _espe.type.group_object
+ object : _espe.type.group_object
) : 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
+ {
+ return _espe.repository.group.update(id, object);
}
}
diff --git a/tools/makefile b/tools/makefile
index 95edf91..14a7d0e 100644
--- a/tools/makefile
+++ b/tools/makefile
@@ -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/session_begin.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_list.ts \
${dir_source}/api/actions/member_read.ts \