2025-09-25 17:18:16 +02:00
|
|
|
/*
|
|
|
|
|
This file is part of »zeitbild«.
|
|
|
|
|
|
|
|
|
|
Copyright 2025 'kcf' <fenris@folksprak.org>
|
|
|
|
|
|
|
|
|
|
»zeitbild« is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
»zeitbild« 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 Lesser General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
along with »zeitbild«. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2024-09-12 00:03:29 +02:00
|
|
|
|
|
|
|
|
namespace _zeitbild.conf
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2024-09-18 18:17:25 +02:00
|
|
|
const _schema : lib_plankton.conf.type_schema = {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"version": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "integer",
|
|
|
|
|
"enum": [1]
|
|
|
|
|
},
|
|
|
|
|
"log": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "array",
|
|
|
|
|
"items": {
|
|
|
|
|
"anyOf": [
|
|
|
|
|
{
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"kind": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"enum": ["stdout"]
|
|
|
|
|
},
|
|
|
|
|
"data": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"threshold": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"enum": [
|
|
|
|
|
"debug",
|
|
|
|
|
"info",
|
|
|
|
|
"notice",
|
|
|
|
|
"warning",
|
|
|
|
|
"error"
|
|
|
|
|
],
|
|
|
|
|
"default": "info"
|
2025-09-25 16:35:22 +02:00
|
|
|
},
|
|
|
|
|
"format": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"enum": [
|
|
|
|
|
"human_readable",
|
|
|
|
|
"jsonl",
|
|
|
|
|
"jsonl_structured",
|
|
|
|
|
],
|
|
|
|
|
"default": "human_readable",
|
|
|
|
|
},
|
2024-09-18 18:17:25 +02:00
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"default": [
|
|
|
|
|
{
|
|
|
|
|
"kind": "stdout",
|
|
|
|
|
"data": {
|
|
|
|
|
"threshold": "info"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"server": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"address": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"default": "::"
|
|
|
|
|
},
|
|
|
|
|
"port": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "integer",
|
|
|
|
|
"default": 7845
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
],
|
|
|
|
|
"additionalProperties": false,
|
|
|
|
|
"default": {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"database": {
|
|
|
|
|
"anyOf": [
|
|
|
|
|
{
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"kind": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"enum": ["sqlite"]
|
|
|
|
|
},
|
|
|
|
|
"data": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"path": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"default": "data.sqlite"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
],
|
|
|
|
|
"default": {}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"kind"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"kind": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"enum": ["postgresql"]
|
|
|
|
|
},
|
|
|
|
|
"data": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"host": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"port": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "integer",
|
|
|
|
|
"default": 5432
|
|
|
|
|
},
|
|
|
|
|
"username": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"password": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
2024-10-26 13:37:57 +02:00
|
|
|
"schema": {
|
2024-09-18 18:17:25 +02:00
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"host",
|
|
|
|
|
"username",
|
|
|
|
|
"password",
|
|
|
|
|
"scheme"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"kind",
|
|
|
|
|
"data"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"default": {
|
|
|
|
|
"kind": "sqlite"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"session_management": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"in_memory": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "boolean",
|
|
|
|
|
"default": true
|
|
|
|
|
},
|
|
|
|
|
"drop_all_at_start": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "boolean",
|
|
|
|
|
"default": true
|
|
|
|
|
},
|
|
|
|
|
"lifetime": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "integer",
|
2025-10-02 16:57:36 +02:00
|
|
|
"default": 3600,
|
|
|
|
|
},
|
|
|
|
|
"prolongation": {
|
|
|
|
|
"nullable": true,
|
|
|
|
|
"type": "integer",
|
|
|
|
|
"default": 300,
|
|
|
|
|
},
|
2024-09-18 18:17:25 +02:00
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
],
|
|
|
|
|
"additionalProperties": false,
|
|
|
|
|
"default": {}
|
2024-09-19 13:34:07 +02:00
|
|
|
},
|
|
|
|
|
"authentication": {
|
|
|
|
|
"anyOf": [
|
|
|
|
|
{
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"kind": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"enum": ["internal"]
|
|
|
|
|
},
|
|
|
|
|
"data": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
],
|
|
|
|
|
"default": {}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"kind"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"kind": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"enum": ["oidc"]
|
|
|
|
|
},
|
|
|
|
|
"data": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"url_authorization": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"url_token": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"url_userinfo": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"client_id": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"client_secret": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"backend_url_base": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"label": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"default": "OIDC"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"url_authorization",
|
|
|
|
|
"url_token",
|
|
|
|
|
"url_userinfo",
|
|
|
|
|
"client_id",
|
|
|
|
|
"client_secret"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"kind",
|
|
|
|
|
"data"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"default": {
|
|
|
|
|
"kind": "internal",
|
|
|
|
|
"data": {
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-25 17:05:15 +02:00
|
|
|
},
|
|
|
|
|
"external_resources": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"lifetime": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "integer",
|
|
|
|
|
"default": 14400
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"additionalProperties": false,
|
|
|
|
|
"required": [
|
|
|
|
|
],
|
|
|
|
|
"default": {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"caldav": {
|
|
|
|
|
"nullable": true,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"address": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"username": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"password": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"setup_hints": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "array",
|
|
|
|
|
"items": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"label": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"link": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string"
|
|
|
|
|
},
|
|
|
|
|
"remark": {
|
|
|
|
|
"nullable": true,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"default": null
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"label",
|
|
|
|
|
"link",
|
|
|
|
|
],
|
|
|
|
|
"additionalProperties": false
|
|
|
|
|
},
|
|
|
|
|
"default": []
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"address",
|
|
|
|
|
"username",
|
|
|
|
|
"password"
|
|
|
|
|
],
|
|
|
|
|
"additionalProperties": false,
|
|
|
|
|
"default": null
|
|
|
|
|
},
|
|
|
|
|
"misc": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
/**
|
|
|
|
|
* @todo make mandatory
|
|
|
|
|
*/
|
|
|
|
|
"auth_salt": {
|
|
|
|
|
"nullable": false,
|
|
|
|
|
"type": "string",
|
|
|
|
|
"default": "unsafe_auth_salt"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
],
|
|
|
|
|
"additionalProperties": false,
|
|
|
|
|
"default": {}
|
|
|
|
|
},
|
2024-09-18 18:17:25 +02:00
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
"version"
|
|
|
|
|
],
|
|
|
|
|
"additionalProperties": false
|
2024-09-12 00:03:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2024-09-18 18:17:25 +02:00
|
|
|
var _data : (null | any) = null;
|
2024-09-12 00:03:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2024-09-18 18:17:25 +02:00
|
|
|
export function schema(
|
|
|
|
|
) : lib_plankton.conf.type_schema
|
2024-09-12 00:03:29 +02:00
|
|
|
{
|
2024-09-18 18:17:25 +02:00
|
|
|
return _schema;
|
2024-09-12 00:03:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2024-09-18 18:17:25 +02:00
|
|
|
export function get(
|
|
|
|
|
) : any
|
2024-09-12 00:03:29 +02:00
|
|
|
{
|
2024-09-18 18:17:25 +02:00
|
|
|
if (_data === null) {
|
|
|
|
|
throw (new Error("conf not loaded yet"));
|
2024-09-12 00:03:29 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2024-09-18 18:17:25 +02:00
|
|
|
return _data;
|
2024-09-12 00:03:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2024-09-18 18:17:25 +02:00
|
|
|
export async function init(
|
|
|
|
|
path : string
|
|
|
|
|
) : Promise<void>
|
2024-09-12 00:03:29 +02:00
|
|
|
{
|
2024-09-18 18:17:25 +02:00
|
|
|
_data = await lib_plankton.conf.load(
|
|
|
|
|
_schema,
|
|
|
|
|
path
|
|
|
|
|
);
|
|
|
|
|
return Promise.resolve<void>(undefined);
|
2024-09-12 00:03:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|