frontend-dali/source/resources/conf.ts
2025-10-23 23:16:11 +02:00

142 lines
2.6 KiB
TypeScript

/*
This file is part of »dali«.
Copyright 2025 'kcf' <fenris@folksprak.org>
»dali« 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.
»dali« 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 »dali«. If not, see <http://www.gnu.org/licenses/>.
*/
namespace _dali.conf
{
/**
*/
const _schema : lib_plankton.conf.type_schema = {
"nullable": false,
"type": "object",
"properties": {
"version": {
"nullable": false,
"type": "integer",
"enum": [1]
},
"backend": {
"nullable": false,
"type": "object",
"properties": {
"scheme": {
"nullable": false,
"type": "string",
"default": "http"
},
"host": {
"nullable": false,
"type": "string",
"default": "localhost"
},
"port": {
"nullable": false,
"type": "integer",
"default": 7845
},
"path": {
"nullable": false,
"type": "string",
"default": ""
}
},
"required": [
],
"additionalProperties": false,
"default": {}
},
"misc": {
"nullable": false,
"type": "object",
"properties": {
"oidc_redirect_uri_template": {
"nullable": true,
"type": "string",
"default": "http://localhost:8888/#oidc_finish,session_key={{session_key}}"
},
"use_central_europe_specific_datetime_inputs": {
"nullable": true,
"type": "boolean",
"default": false
},
"update_interval": {
"nullable": false,
"type": "integer",
"default": 60
},
},
"required": [
],
"additionalProperties": false,
"default": {}
},
},
"required": [
"version",
],
"additionalProperties": false
};
/**
*/
var _data : (null | any) = null;
/**
*/
export function schema(
) : lib_plankton.conf.type_schema
{
return _schema;
}
/**
*/
export function get(
) : any
{
if (_data === null)
{
throw (new Error("conf not loaded yet"));
}
else {
return _data;
}
}
/**
*/
export async function init(
path : string
) : Promise<void>
{
_data = await lib_plankton.conf.load(
_schema,
path
);
return Promise.resolve<void>(undefined);
}
}