core/source/conf.ts

380 lines
7 KiB
TypeScript
Raw Normal View History

2025-09-24 12:39:22 +02:00
/*
This file is part of »mimir«.
Copyright 2025 kcf <fenris@folksprak.org>
»mimir« 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.
»mimir« 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 »mimir«. If not, see <http://www.gnu.org/licenses/>.
*/
2025-03-24 22:47:55 +01:00
namespace _mimir.conf
{
/**
*/
export const schema : lib_plankton.conf.type_schema = {
"nullable": false,
"type": "object",
"properties": {
2025-09-24 12:39:22 +02:00
"settings": {
2025-03-24 22:47:55 +01:00
"nullable": false,
2025-09-24 12:39:22 +02:00
"type": "object",
"properties": {
"temp_directory": {
"nullable": false,
"type": "string",
"default": "/tmp/mimir"
}
},
"additionalProperties": false,
"required": [
],
"default": {}
2025-03-24 22:47:55 +01:00
},
"target": {
"anyOf": [
{
"nullable": false,
"type": "object",
"properties": {
"kind": {
"nullable": false,
"type": "string",
2025-03-26 07:35:59 +01:00
"enum": ["local"]
2025-03-24 22:47:55 +01:00
},
"parameters": {
"nullable": false,
"type": "object",
"properties": {
2025-03-26 07:35:59 +01:00
"directory": {
"nullable": false,
"type": "string"
},
2025-03-24 22:47:55 +01:00
},
"additionalProperties": false,
"required": [
2025-03-26 07:35:59 +01:00
"directory",
2025-03-24 22:47:55 +01:00
]
},
},
"additionalProperties": false,
"required": [
"kind",
"parameters",
]
},
{
"nullable": false,
"type": "object",
"properties": {
"kind": {
"nullable": false,
"type": "string",
"enum": ["borg"]
},
"parameters": {
"nullable": false,
"type": "object",
"properties": {
"repository": {
"nullable": false,
"type": "string"
},
"compression": {
"nullable": false,
"type": "string",
"enum": [
"none",
"lz4",
"zlib",
"lzma",
],
"default": "lz4"
},
2025-09-24 12:39:22 +02:00
"pruning": {
"nullable": false,
"type": "object",
"properties": {
"keep_weekly": {
"nullable": false,
"type": "integer",
"default": 7
},
"keep_yearly": {
"nullable": false,
"type": "integer",
"default": 2
},
},
"additionalProperties": false,
"required": [
],
"default": {}
}
2025-03-24 22:47:55 +01:00
},
"required": [
"repository",
]
},
},
"additionalProperties": false,
"required": [
"kind",
"parameters",
]
}
]
},
/*
"defaults": {
},
*/
"concerns": {
"nullable": false,
"type": "array",
"items": {
"anyOf": [
{
"nullable": false,
"type": "object",
"properties": {
"active": {
"nullable": false,
"type": "boolean",
"default": true
},
"name": {
"nullable": false,
"type": "string"
},
"kind": {
"nullable": false,
"type": "string",
"enum": ["files"]
},
"parameters": {
"nullable": false,
"type": "object",
"properties": {
"path": {
"nullable": false,
"type": "string",
},
},
"additionalProperties": false,
"required": [
"path",
]
}
},
"additionalProperties": false,
"required": [
"name",
"kind",
"parameters",
]
},
{
"nullable": false,
"type": "object",
"properties": {
"active": {
"nullable": false,
"type": "boolean",
"default": true
},
"name": {
"nullable": false,
"type": "string"
},
"kind": {
"nullable": false,
"type": "string",
"enum": ["postgresql_dump"]
},
"parameters": {
"nullable": false,
"type": "object",
"properties": {
"credentials": {
"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",
},
"schema": {
"nullable": false,
"type": "string",
},
},
"additionalProperties": false,
"required": [
"host",
"username",
"password",
"schema",
]
},
},
"additionalProperties": false,
"required": [
"credentials",
]
}
},
"additionalProperties": false,
"required": [
"name",
"kind",
"parameters",
]
},
]
}
},
},
"additionalProperties": false,
"required": [
"version",
"target",
"concerns",
]
};
2025-09-24 12:39:22 +02:00
/**
*/
type type_settings = {
temp_directory : string;
};
2025-03-24 22:47:55 +01:00
/**
*/
2025-09-24 12:39:22 +02:00
type type_target_parameters_local = {
2025-03-26 07:35:59 +01:00
directory : string;
2025-03-24 22:47:55 +01:00
};
/**
*/
2025-09-24 12:39:22 +02:00
type type_target_parameters_borg = {
2025-03-24 22:47:55 +01:00
repository : string;
compression : string;
2025-09-24 12:39:22 +02:00
pruning : {
keep_weekly : int;
keep_yearly : int;
}
2025-03-24 22:47:55 +01:00
};
/**
*/
2025-09-24 12:39:22 +02:00
type type_concern_parameters_files = {
2025-03-24 22:47:55 +01:00
name : string;
path : string;
};
/**
2025-03-26 07:35:59 +01:00
*/
export type type_target = (
{
kind : "local";
parameters : type_target_parameters_local;
}
|
{
kind : "borg";
parameters : type_target_parameters_borg;
}
);
/**
2025-03-24 22:47:55 +01:00
*/
2025-09-24 12:39:22 +02:00
type type_concern_parameters_postgresql_dump = {
2025-03-24 22:47:55 +01:00
credentials : {
host : string;
port : int;
username : string;
password : string;
schema : string;
};
};
2025-03-26 07:35:59 +01:00
/**
*/
export type type_concern = (
{
kind : "files";
parameters : type_concern_parameters_files;
}
|
{
kind : "postgresql_dump";
parameters : type_concern_parameters_postgresql_dump;
}
);
2025-03-24 22:47:55 +01:00
/**
*/
2025-09-24 12:39:22 +02:00
type type_root = {
settings : type_settings;
2025-03-26 07:35:59 +01:00
target : type_target;
2025-03-24 22:47:55 +01:00
concerns : Array<
{
active ?: boolean;
name : string;
}
&
2025-03-26 07:35:59 +01:00
type_concern
2025-03-24 22:47:55 +01:00
>;
};
2025-09-24 12:39:22 +02:00
/**
*/
export type type_conf = type_root;
/**
*/
export function get(
path : string
) : Promise<type_conf>
{
return lib_plankton.conf.load(
schema,
path
);
}
2025-03-24 22:47:55 +01:00
}