Finalize JamiSwig interface and implement account detail routes

Changes:
- Add missing methods to JamiSwig interface
- Create new stringMapToRecord and itToRecord functions
- Rename id to accountId everywhere for consistency
- Rename jamid to jamiSwig inside Jamid service for clarity
- Implement Jamid functionality:
    - getVolatileAccountDetails
    - getAccountDetails with AccountDetails interface
    - setAccountDetails
    - getDevices
    - getDefaultModerators
- Reorder and rename methods in Jamid for consistency with JamiSwig
- Implement all routes for accountRouter (GET/POST /account)
- Add various TODO comments for future work

Change-Id: Id14ddde3bc8b4484d82ad84c57384567d92bd70f
diff --git a/server/src/routers/account-router.ts b/server/src/routers/account-router.ts
index e1d4adc..0798fa7 100644
--- a/server/src/routers/account-router.ts
+++ b/server/src/routers/account-router.ts
@@ -16,7 +16,7 @@
  * <https://www.gnu.org/licenses/>.
  */
 import { Router } from 'express';
-import log from 'loglevel';
+import { AccountDetails } from 'jami-web-common';
 import { Container } from 'typedi';
 
 import { Jamid } from '../jamid/jamid.js';
@@ -26,12 +26,27 @@
 
 export const accountRouter = Router();
 
-accountRouter.get('/', authenticateToken, (req, res) => {
-  log.debug('TODO: Implement jamid.getAccount()');
-  res.send(`TODO: ${req.method} ${req.originalUrl} for account ID ${res.locals.accountId}`);
+accountRouter.use(authenticateToken);
+
+// TODO: If tokens can be generated on one daemon and used on another (transferrable between daemons),
+// then add middleware to check that the currently logged-in accountId is stored in this daemon instance
+
+accountRouter.get('/', (_req, res) => {
+  const accountId = res.locals.accountId;
+
+  res.json({
+    id: accountId,
+    details: jamid.getAccountDetails(accountId),
+    volatileDetails: jamid.getVolatileAccountDetails(accountId),
+    defaultModerators: jamid.getDefaultModerators(accountId),
+    devices: jamid.getDevices(accountId),
+  });
 });
 
-accountRouter.post('/', authenticateToken, (req, res) => {
-  log.debug('TODO: Implement jamid.getAccount().updateDetails()');
-  res.send(`TODO: ${req.method} ${req.originalUrl} for account ID ${res.locals.accountId}`);
+accountRouter.post('/', (req, res) => {
+  const accountId = res.locals.accountId;
+  const currentAccountDetails = jamid.getAccountDetails(accountId);
+  const newAccountDetails: AccountDetails = { ...currentAccountDetails, ...req.body };
+  jamid.setAccountDetails(res.locals.accountId, newAccountDetails);
+  res.end();
 });