[mod] conf:consolidated versions
This commit is contained in:
parent
0531331f0b
commit
2948b9c023
1 changed files with 234 additions and 736 deletions
970
source/conf.ts
970
source/conf.ts
|
@ -221,173 +221,227 @@ namespace _espe.conf
|
||||||
conf_raw : any
|
conf_raw : any
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
switch (conf_raw["version"]) {
|
const version : int = conf_raw["version"];
|
||||||
case 1: {
|
_data = {
|
||||||
_data = {
|
"general": (
|
||||||
"general": (
|
((node_general) => ({
|
||||||
((node_general) => ({
|
"language": (node_general["language"] ?? null),
|
||||||
"language": (node_general["language"] ?? null),
|
"verification_secret": (node_general["verification_secret"] ?? null),
|
||||||
"verification_secret": (node_general["verification_secret"] ?? null),
|
})) (conf_raw["general"] ?? {})
|
||||||
})) (conf_raw["general"] ?? {})
|
),
|
||||||
),
|
"log": (() => {
|
||||||
"log": [
|
switch (version) {
|
||||||
{
|
case 1: {
|
||||||
"kind": "stdout",
|
return [
|
||||||
"data": {
|
{
|
||||||
"threshold": ((conf_raw["general"] ?? {})["verbosity"] ?? "notice"),
|
"kind": "stdout",
|
||||||
}
|
"data": {
|
||||||
},
|
"threshold": ((conf_raw["general"] ?? {})["verbosity"] ?? "notice"),
|
||||||
],
|
|
||||||
"server": (
|
|
||||||
((node_server) => ({
|
|
||||||
"host": "::",
|
|
||||||
"port": (node_server["port"] ?? 4916),
|
|
||||||
"path_base": (node_server["path_base"] ?? ""),
|
|
||||||
})) (conf_raw["server"] ?? {})
|
|
||||||
),
|
|
||||||
"database": (
|
|
||||||
((node_database) => {
|
|
||||||
const kind : string = (node_database["kind"] ?? "sqlite");
|
|
||||||
const node_database_data_raw = (node_database["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "sqlite": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"path": (node_database_data_raw["path"] ?? "data.sqlite"),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "postgresql": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": node_database_data_raw,
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["database"] ?? {})
|
|
||||||
),
|
|
||||||
"email_sending": (
|
|
||||||
((node_email_sending) => {
|
|
||||||
const kind : string = (node_email_sending["kind"] ?? "console");
|
|
||||||
const data_raw = (node_email_sending["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "regular": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "redirect": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
"target": data_raw["target"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "console": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "drop": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["email_sending"] ?? {})
|
|
||||||
),
|
|
||||||
"session_management": (
|
|
||||||
((node_session_management) => ({
|
|
||||||
"in_memory": (node_session_management["in_memory"] ?? true),
|
|
||||||
"drop_all_at_start": (node_session_management["drop_all_at_start"] ?? true),
|
|
||||||
"lifetime": (node_session_management["lifetime"] ?? 900),
|
|
||||||
})) (conf_raw["session_management"] ?? {})
|
|
||||||
),
|
|
||||||
"settings": (
|
|
||||||
((node_settings) => ({
|
|
||||||
"organisation": {
|
|
||||||
"name": ((node_settings["organisation"] ?? {})["name"] ?? "Example Orginsation"), // TODO: mandatory?
|
|
||||||
"domain": ((node_settings["organisation"] ?? {})["domain"] ?? "example.org"), // TODO: mandatory?
|
|
||||||
},
|
},
|
||||||
"misc": (
|
];
|
||||||
((node_settings_misc) => ({
|
break;
|
||||||
"prefix_for_veiled_email_addresses": (node_settings_misc["prefix_for_veiled_email_addresses"] ?? "member-"),
|
}
|
||||||
"facultative_membership_number": (node_settings_misc["facultative_membership_number"] ?? false),
|
case 2:
|
||||||
"auto_register": (node_settings_misc["auto_register"] ?? false),
|
case 3:
|
||||||
})) (node_settings["misc"] ?? {})
|
case 4: {
|
||||||
),
|
const node_log = (
|
||||||
"summon_email": (
|
conf_raw["log"]
|
||||||
((node_settings_summon_email) => ({
|
??
|
||||||
"remark": (node_settings_summon_email["remark"] ?? null),
|
[
|
||||||
})) (node_settings["summon_email"] ?? {})
|
{
|
||||||
),
|
"kind": "console",
|
||||||
"password_policy": (
|
"data": {
|
||||||
((node_settings_password_policy) => ({
|
}
|
||||||
"minimum_length": (
|
},
|
||||||
("minimum_length" in node_settings_password_policy)
|
]
|
||||||
? node_settings_password_policy["minimum_length"]
|
);
|
||||||
: 8
|
return (
|
||||||
),
|
node_log.map(
|
||||||
"maximum_length": (
|
(node_log_entry : any) => ({
|
||||||
("maximum_length" in node_settings_password_policy)
|
"kind": node_log_entry["kind"],
|
||||||
? node_settings_password_policy["maximum_length"]
|
"data": Object.assign(
|
||||||
: 240
|
{
|
||||||
),
|
"format": "human_readable",
|
||||||
"must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true),
|
"threshold": "notice",
|
||||||
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? true),
|
},
|
||||||
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? true),
|
(node_log_entry["data"] ?? {})
|
||||||
})) (node_settings["password_policy"] ?? {})
|
)
|
||||||
),
|
})
|
||||||
"password_change": (
|
)
|
||||||
((node_settings_password_change) => ({
|
);
|
||||||
"cooldown_time": (node_settings_password_change["cooldown_time"] ?? 86400),
|
break;
|
||||||
})) (node_settings["password_change"] ?? {})
|
}
|
||||||
),
|
}
|
||||||
"name_index": (
|
}) (),
|
||||||
((node_settings_password_policy) => ({
|
"server": (
|
||||||
"veil": (node_settings_password_policy["veil"] ?? true),
|
((node_server) => ({
|
||||||
"salt": (node_settings_password_policy["salt"] ?? ""),
|
"host": (() => {
|
||||||
})) (node_settings["name_index"] ?? {})
|
switch (version) {
|
||||||
),
|
case 1:
|
||||||
"connections": (
|
case 2:
|
||||||
((node_settings_connections) => ({
|
case 3: {
|
||||||
"frontend_url_base": (node_settings_connections["frontend_url_base"] ?? null),
|
return "::";
|
||||||
"login_url": (node_settings_connections["login_url"] ?? null),
|
break;
|
||||||
})) (node_settings["connections"] ?? {})
|
}
|
||||||
),
|
case 4: {
|
||||||
})) (conf_raw["settings"] ?? {})
|
return (node_server["host"] ?? "::");
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) (),
|
||||||
|
"port": (node_server["port"] ?? 4916),
|
||||||
|
"path_base": (node_server["path_base"] ?? ""),
|
||||||
|
})) (conf_raw["server"] ?? {})
|
||||||
|
),
|
||||||
|
"database": (
|
||||||
|
((node_database) => {
|
||||||
|
const kind : string = (node_database["kind"] ?? "sqlite");
|
||||||
|
const node_database_data_raw = (node_database["data"] ?? {});
|
||||||
|
switch (kind) {
|
||||||
|
case "sqlite": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
"path": (node_database_data_raw["path"] ?? "data.sqlite"),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "postgresql": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": node_database_data_raw,
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw (new Error("unhandled"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) (conf_raw["database"] ?? {})
|
||||||
|
),
|
||||||
|
"email_sending": (
|
||||||
|
((node_email_sending) => {
|
||||||
|
const kind : string = (node_email_sending["kind"] ?? "console");
|
||||||
|
const data_raw = (node_email_sending["data"] ?? {});
|
||||||
|
switch (kind) {
|
||||||
|
case "regular": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
||||||
|
"sender": data_raw["sender"],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "redirect": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
||||||
|
"sender": data_raw["sender"],
|
||||||
|
"target": data_raw["target"],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "console": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "drop": {
|
||||||
|
return {
|
||||||
|
"kind": kind,
|
||||||
|
"data": {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw (new Error("unhandled"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) (conf_raw["email_sending"] ?? {})
|
||||||
|
),
|
||||||
|
"session_management": (
|
||||||
|
((node_session_management) => ({
|
||||||
|
"in_memory": (node_session_management["in_memory"] ?? true),
|
||||||
|
"drop_all_at_start": (node_session_management["drop_all_at_start"] ?? true),
|
||||||
|
"lifetime": (node_session_management["lifetime"] ?? 900),
|
||||||
|
})) (conf_raw["session_management"] ?? {})
|
||||||
|
),
|
||||||
|
"settings": (
|
||||||
|
((node_settings) => ({
|
||||||
|
"organisation": {
|
||||||
|
"name": ((node_settings["organisation"] ?? {})["name"] ?? "Example Orginsation"), // TODO: mandatory?
|
||||||
|
"domain": ((node_settings["organisation"] ?? {})["domain"] ?? "example.org"), // TODO: mandatory?
|
||||||
|
},
|
||||||
|
"misc": (
|
||||||
|
((node_settings_misc) => ({
|
||||||
|
"prefix_for_veiled_email_addresses": (node_settings_misc["prefix_for_veiled_email_addresses"] ?? "member-"),
|
||||||
|
"facultative_membership_number": (node_settings_misc["facultative_membership_number"] ?? false),
|
||||||
|
"auto_register": (node_settings_misc["auto_register"] ?? false),
|
||||||
|
})) (node_settings["misc"] ?? {})
|
||||||
),
|
),
|
||||||
"admins": (conf_raw["admins"] ?? []),
|
"summon_email": (
|
||||||
"outputs": (
|
((node_settings_summon_email) => ({
|
||||||
((node_output) => (
|
"remark": (node_settings_summon_email["remark"] ?? null),
|
||||||
|
})) (node_settings["summon_email"] ?? {})
|
||||||
|
),
|
||||||
|
"password_policy": (
|
||||||
|
((node_settings_password_policy) => ({
|
||||||
|
"minimum_length": (
|
||||||
|
("minimum_length" in node_settings_password_policy)
|
||||||
|
? node_settings_password_policy["minimum_length"]
|
||||||
|
: 8
|
||||||
|
),
|
||||||
|
"maximum_length": (
|
||||||
|
("maximum_length" in node_settings_password_policy)
|
||||||
|
? node_settings_password_policy["maximum_length"]
|
||||||
|
: 240
|
||||||
|
),
|
||||||
|
"must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true),
|
||||||
|
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? true),
|
||||||
|
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? true),
|
||||||
|
})) (node_settings["password_policy"] ?? {})
|
||||||
|
),
|
||||||
|
"password_change": (
|
||||||
|
((node_settings_password_change) => ({
|
||||||
|
"cooldown_time": (node_settings_password_change["cooldown_time"] ?? 86400),
|
||||||
|
})) (node_settings["password_change"] ?? {})
|
||||||
|
),
|
||||||
|
"name_index": (
|
||||||
|
((node_settings_password_policy) => ({
|
||||||
|
"veil": (node_settings_password_policy["veil"] ?? true),
|
||||||
|
"salt": (node_settings_password_policy["salt"] ?? ""),
|
||||||
|
})) (node_settings["name_index"] ?? {})
|
||||||
|
),
|
||||||
|
"connections": (
|
||||||
|
((node_settings_connections) => ({
|
||||||
|
"frontend_url_base": (node_settings_connections["frontend_url_base"] ?? null),
|
||||||
|
"login_url": (node_settings_connections["login_url"] ?? null),
|
||||||
|
})) (node_settings["connections"] ?? {})
|
||||||
|
),
|
||||||
|
})) (conf_raw["settings"] ?? {})
|
||||||
|
),
|
||||||
|
"admins": (conf_raw["admins"] ?? []),
|
||||||
|
"outputs": (() => {
|
||||||
|
switch (version) {
|
||||||
|
case 1:
|
||||||
|
case 2: {
|
||||||
|
const node_output = (conf_raw["output"] ?? {});
|
||||||
|
return (
|
||||||
("authelia" in node_output)
|
("authelia" in node_output)
|
||||||
? [
|
?
|
||||||
|
[
|
||||||
{
|
{
|
||||||
"kind": "authelia_file",
|
"kind": "authelia_file",
|
||||||
"data": {
|
"data": {
|
||||||
|
@ -395,571 +449,19 @@ namespace _espe.conf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
: [
|
:
|
||||||
]
|
|
||||||
)) (conf_raw["output"] ?? {})
|
|
||||||
),
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: {
|
|
||||||
_data = {
|
|
||||||
"general": (
|
|
||||||
((node_general) => ({
|
|
||||||
"language": (node_general["language"] ?? null),
|
|
||||||
"verification_secret": (node_general["verification_secret"] ?? null),
|
|
||||||
})) (conf_raw["general"] ?? {})
|
|
||||||
),
|
|
||||||
"log": (
|
|
||||||
((node_log) => node_log.map(
|
|
||||||
(node_log_entry : any) => ({
|
|
||||||
"kind": node_log_entry["kind"],
|
|
||||||
"data": Object.assign(
|
|
||||||
{
|
|
||||||
"format": "human_readable",
|
|
||||||
"threshold": "notice",
|
|
||||||
},
|
|
||||||
(node_log_entry["data"] ?? {})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
)) (
|
|
||||||
conf_raw["log"]
|
|
||||||
??
|
|
||||||
[
|
[
|
||||||
{
|
|
||||||
"kind": "console",
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
)
|
);
|
||||||
),
|
break;
|
||||||
"server": (
|
}
|
||||||
((node_server) => ({
|
case 3: {
|
||||||
"host": "::",
|
return (conf_raw["outputs"] ?? []);
|
||||||
"port": (node_server["port"] ?? 4916),
|
break;
|
||||||
"path_base": (node_server["path_base"] ?? ""),
|
}
|
||||||
})) (conf_raw["server"] ?? {})
|
case 4: {
|
||||||
),
|
const node_outputs = (conf_raw["outputs"] ?? []);
|
||||||
"database": (
|
return node_outputs.map(
|
||||||
((node_database) => {
|
|
||||||
const kind : string = (node_database["kind"] ?? "sqlite");
|
|
||||||
const node_database_data_raw = (node_database["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "sqlite": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"path": (node_database_data_raw["path"] ?? "data.sqlite"),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "postgresql": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": node_database_data_raw,
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["database"] ?? {})
|
|
||||||
),
|
|
||||||
"email_sending": (
|
|
||||||
((node_email_sending) => {
|
|
||||||
const kind : string = (node_email_sending["kind"] ?? "console");
|
|
||||||
const data_raw = (node_email_sending["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "regular": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "redirect": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
"target": data_raw["target"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "console": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "drop": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["email_sending"] ?? {})
|
|
||||||
),
|
|
||||||
"session_management": (
|
|
||||||
((node_session_management) => ({
|
|
||||||
"in_memory": (node_session_management["in_memory"] ?? true),
|
|
||||||
"drop_all_at_start": (node_session_management["drop_all_at_start"] ?? true),
|
|
||||||
"lifetime": (node_session_management["lifetime"] ?? 900),
|
|
||||||
})) (conf_raw["session_management"] ?? {})
|
|
||||||
),
|
|
||||||
"settings": (
|
|
||||||
((node_settings) => ({
|
|
||||||
"organisation": {
|
|
||||||
"name": ((node_settings["organisation"] ?? {})["name"] ?? "Example Orginsation"), // TODO: mandatory?
|
|
||||||
"domain": ((node_settings["organisation"] ?? {})["domain"] ?? "example.org"), // TODO: mandatory?
|
|
||||||
},
|
|
||||||
"misc": (
|
|
||||||
((node_settings_misc) => ({
|
|
||||||
"prefix_for_veiled_email_addresses": (node_settings_misc["prefix_for_veiled_email_addresses"] ?? "member-"),
|
|
||||||
"facultative_membership_number": (node_settings_misc["facultative_membership_number"] ?? false),
|
|
||||||
"auto_register": (node_settings_misc["auto_register"] ?? false),
|
|
||||||
})) (node_settings["misc"] ?? {})
|
|
||||||
),
|
|
||||||
"summon_email": (
|
|
||||||
((node_settings_summon_email) => ({
|
|
||||||
"remark": (node_settings_summon_email["remark"] ?? null),
|
|
||||||
})) (node_settings["summon_email"] ?? {})
|
|
||||||
),
|
|
||||||
"password_policy": (
|
|
||||||
((node_settings_password_policy) => ({
|
|
||||||
"minimum_length": (
|
|
||||||
("minimum_length" in node_settings_password_policy)
|
|
||||||
? node_settings_password_policy["minimum_length"]
|
|
||||||
: 8
|
|
||||||
),
|
|
||||||
"maximum_length": (
|
|
||||||
("maximum_length" in node_settings_password_policy)
|
|
||||||
? node_settings_password_policy["maximum_length"]
|
|
||||||
: 240
|
|
||||||
),
|
|
||||||
"must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true),
|
|
||||||
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? true),
|
|
||||||
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? true),
|
|
||||||
})) (node_settings["password_policy"] ?? {})
|
|
||||||
),
|
|
||||||
"password_change": (
|
|
||||||
((node_settings_password_change) => ({
|
|
||||||
"cooldown_time": (node_settings_password_change["cooldown_time"] ?? 86400),
|
|
||||||
})) (node_settings["password_change"] ?? {})
|
|
||||||
),
|
|
||||||
"name_index": (
|
|
||||||
((node_settings_password_policy) => ({
|
|
||||||
"veil": (node_settings_password_policy["veil"] ?? true),
|
|
||||||
"salt": (node_settings_password_policy["salt"] ?? ""),
|
|
||||||
})) (node_settings["name_index"] ?? {})
|
|
||||||
),
|
|
||||||
"connections": (
|
|
||||||
((node_settings_connections) => ({
|
|
||||||
"frontend_url_base": (node_settings_connections["frontend_url_base"] ?? null),
|
|
||||||
"login_url": (node_settings_connections["login_url"] ?? null),
|
|
||||||
})) (node_settings["connections"] ?? {})
|
|
||||||
),
|
|
||||||
})) (conf_raw["settings"] ?? {})
|
|
||||||
),
|
|
||||||
"admins": (conf_raw["admins"] ?? []),
|
|
||||||
"outputs": (
|
|
||||||
((node_output) => (
|
|
||||||
("authelia" in node_output)
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
"kind": "authelia_file",
|
|
||||||
"data": {
|
|
||||||
"path": node_output["authelia"],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
: [
|
|
||||||
]
|
|
||||||
)) (conf_raw["output"] ?? {})
|
|
||||||
),
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3: {
|
|
||||||
_data = {
|
|
||||||
"general": (
|
|
||||||
((node_general) => ({
|
|
||||||
"language": (node_general["language"] ?? null),
|
|
||||||
"verification_secret": (node_general["verification_secret"] ?? null),
|
|
||||||
})) (conf_raw["general"] ?? {})
|
|
||||||
),
|
|
||||||
"log": (
|
|
||||||
((node_log) => node_log.map(
|
|
||||||
(node_log_entry : any) => ({
|
|
||||||
"kind": node_log_entry["kind"],
|
|
||||||
"data": Object.assign(
|
|
||||||
{
|
|
||||||
"format": "human_readable",
|
|
||||||
"threshold": "notice",
|
|
||||||
},
|
|
||||||
(node_log_entry["data"] ?? {})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
)) (
|
|
||||||
conf_raw["log"]
|
|
||||||
??
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"kind": "console",
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"server": (
|
|
||||||
((node_server) => ({
|
|
||||||
"host": "::",
|
|
||||||
"port": (node_server["port"] ?? 4916),
|
|
||||||
"path_base": (node_server["path_base"] ?? ""),
|
|
||||||
})) (conf_raw["server"] ?? {})
|
|
||||||
),
|
|
||||||
"database": (
|
|
||||||
((node_database) => {
|
|
||||||
const kind : string = (node_database["kind"] ?? "sqlite");
|
|
||||||
const node_database_data_raw = (node_database["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "sqlite": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"path": (node_database_data_raw["path"] ?? "data.sqlite"),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "postgresql": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": node_database_data_raw,
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["database"] ?? {})
|
|
||||||
),
|
|
||||||
"email_sending": (
|
|
||||||
((node_email_sending) => {
|
|
||||||
const kind : string = (node_email_sending["kind"] ?? "console");
|
|
||||||
const data_raw = (node_email_sending["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "regular": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "redirect": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
"target": data_raw["target"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "console": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "drop": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["email_sending"] ?? {})
|
|
||||||
),
|
|
||||||
"session_management": (
|
|
||||||
((node_session_management) => ({
|
|
||||||
"in_memory": (node_session_management["in_memory"] ?? true),
|
|
||||||
"drop_all_at_start": (node_session_management["drop_all_at_start"] ?? true),
|
|
||||||
"lifetime": (node_session_management["lifetime"] ?? 900),
|
|
||||||
})) (conf_raw["session_management"] ?? {})
|
|
||||||
),
|
|
||||||
"settings": (
|
|
||||||
((node_settings) => ({
|
|
||||||
"organisation": {
|
|
||||||
"name": ((node_settings["organisation"] ?? {})["name"] ?? "Example Orginsation"), // TODO: mandatory?
|
|
||||||
"domain": ((node_settings["organisation"] ?? {})["domain"] ?? "example.org"), // TODO: mandatory?
|
|
||||||
},
|
|
||||||
"misc": (
|
|
||||||
((node_settings_misc) => ({
|
|
||||||
"prefix_for_veiled_email_addresses": (node_settings_misc["prefix_for_veiled_email_addresses"] ?? "member-"),
|
|
||||||
"facultative_membership_number": (node_settings_misc["facultative_membership_number"] ?? false),
|
|
||||||
"auto_register": (node_settings_misc["auto_register"] ?? false),
|
|
||||||
})) (node_settings["misc"] ?? {})
|
|
||||||
),
|
|
||||||
"summon_email": (
|
|
||||||
((node_settings_summon_email) => ({
|
|
||||||
"remark": (node_settings_summon_email["remark"] ?? null),
|
|
||||||
})) (node_settings["summon_email"] ?? {})
|
|
||||||
),
|
|
||||||
"password_policy": (
|
|
||||||
((node_settings_password_policy) => ({
|
|
||||||
"minimum_length": (
|
|
||||||
("minimum_length" in node_settings_password_policy)
|
|
||||||
? node_settings_password_policy["minimum_length"]
|
|
||||||
: 8
|
|
||||||
),
|
|
||||||
"maximum_length": (
|
|
||||||
("maximum_length" in node_settings_password_policy)
|
|
||||||
? node_settings_password_policy["maximum_length"]
|
|
||||||
: 240
|
|
||||||
),
|
|
||||||
"must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true),
|
|
||||||
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? true),
|
|
||||||
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? true),
|
|
||||||
})) (node_settings["password_policy"] ?? {})
|
|
||||||
),
|
|
||||||
"password_change": (
|
|
||||||
((node_settings_password_change) => ({
|
|
||||||
"cooldown_time": (node_settings_password_change["cooldown_time"] ?? 86400),
|
|
||||||
})) (node_settings["password_change"] ?? {})
|
|
||||||
),
|
|
||||||
"name_index": (
|
|
||||||
((node_settings_password_policy) => ({
|
|
||||||
"veil": (node_settings_password_policy["veil"] ?? true),
|
|
||||||
"salt": (node_settings_password_policy["salt"] ?? ""),
|
|
||||||
})) (node_settings["name_index"] ?? {})
|
|
||||||
),
|
|
||||||
"connections": (
|
|
||||||
((node_settings_connections) => ({
|
|
||||||
"frontend_url_base": (node_settings_connections["frontend_url_base"] ?? null),
|
|
||||||
"login_url": (node_settings_connections["login_url"] ?? null),
|
|
||||||
})) (node_settings["connections"] ?? {})
|
|
||||||
),
|
|
||||||
})) (conf_raw["settings"] ?? {})
|
|
||||||
),
|
|
||||||
"admins": (conf_raw["admins"] ?? []),
|
|
||||||
"outputs": (conf_raw["outputs"] ?? []),
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 4: {
|
|
||||||
_data = {
|
|
||||||
"general": (
|
|
||||||
((node_general) => ({
|
|
||||||
"language": (node_general["language"] ?? null),
|
|
||||||
"verification_secret": (node_general["verification_secret"] ?? null),
|
|
||||||
})) (conf_raw["general"] ?? {})
|
|
||||||
),
|
|
||||||
"log": (
|
|
||||||
((node_log) => node_log.map(
|
|
||||||
(node_log_entry : any) => ({
|
|
||||||
"kind": node_log_entry["kind"],
|
|
||||||
"data": Object.assign(
|
|
||||||
{
|
|
||||||
"format": "human_readable",
|
|
||||||
"threshold": "notice",
|
|
||||||
},
|
|
||||||
(node_log_entry["data"] ?? {})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
)) (
|
|
||||||
conf_raw["log"]
|
|
||||||
??
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"kind": "console",
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"server": (
|
|
||||||
((node_server) => ({
|
|
||||||
"host": (node_server["host"] ?? "::"),
|
|
||||||
"port": (node_server["port"] ?? 4916),
|
|
||||||
"path_base": (node_server["path_base"] ?? ""),
|
|
||||||
})) (conf_raw["server"] ?? {})
|
|
||||||
),
|
|
||||||
"database": (
|
|
||||||
((node_database) => {
|
|
||||||
const kind : string = (node_database["kind"] ?? "sqlite");
|
|
||||||
const node_database_data_raw = (node_database["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "sqlite": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"path": (node_database_data_raw["path"] ?? "data.sqlite"),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "postgresql": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": node_database_data_raw,
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["database"] ?? {})
|
|
||||||
),
|
|
||||||
"email_sending": (
|
|
||||||
((node_email_sending) => {
|
|
||||||
const kind : string = (node_email_sending["kind"] ?? "console");
|
|
||||||
const data_raw = (node_email_sending["data"] ?? {});
|
|
||||||
switch (kind) {
|
|
||||||
case "regular": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "redirect": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
"smtp_credentials": (data_raw["smtp_credentials"] ?? null),
|
|
||||||
"sender": data_raw["sender"],
|
|
||||||
"target": data_raw["target"],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "console": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "drop": {
|
|
||||||
return {
|
|
||||||
"kind": kind,
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw (new Error("unhandled"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (conf_raw["email_sending"] ?? {})
|
|
||||||
),
|
|
||||||
"session_management": (
|
|
||||||
((node_session_management) => ({
|
|
||||||
"in_memory": (node_session_management["in_memory"] ?? true),
|
|
||||||
"drop_all_at_start": (node_session_management["drop_all_at_start"] ?? true),
|
|
||||||
"lifetime": (node_session_management["lifetime"] ?? 900),
|
|
||||||
})) (conf_raw["session_management"] ?? {})
|
|
||||||
),
|
|
||||||
"settings": (
|
|
||||||
((node_settings) => ({
|
|
||||||
"organisation": {
|
|
||||||
"name": ((node_settings["organisation"] ?? {})["name"] ?? "Example Orginsation"), // TODO: mandatory?
|
|
||||||
"domain": ((node_settings["organisation"] ?? {})["domain"] ?? "example.org"), // TODO: mandatory?
|
|
||||||
},
|
|
||||||
"misc": (
|
|
||||||
((node_settings_misc) => ({
|
|
||||||
"prefix_for_veiled_email_addresses": (node_settings_misc["prefix_for_veiled_email_addresses"] ?? "member-"),
|
|
||||||
"facultative_membership_number": (node_settings_misc["facultative_membership_number"] ?? false),
|
|
||||||
"auto_register": (node_settings_misc["auto_register"] ?? false),
|
|
||||||
})) (node_settings["misc"] ?? {})
|
|
||||||
),
|
|
||||||
"summon_email": (
|
|
||||||
((node_settings_summon_email) => ({
|
|
||||||
"remark": (node_settings_summon_email["remark"] ?? null),
|
|
||||||
})) (node_settings["summon_email"] ?? {})
|
|
||||||
),
|
|
||||||
"password_policy": (
|
|
||||||
((node_settings_password_policy) => ({
|
|
||||||
"minimum_length": (
|
|
||||||
("minimum_length" in node_settings_password_policy)
|
|
||||||
? node_settings_password_policy["minimum_length"]
|
|
||||||
: 8
|
|
||||||
),
|
|
||||||
"maximum_length": (
|
|
||||||
("maximum_length" in node_settings_password_policy)
|
|
||||||
? node_settings_password_policy["maximum_length"]
|
|
||||||
: 240
|
|
||||||
),
|
|
||||||
"must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true),
|
|
||||||
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? true),
|
|
||||||
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? true),
|
|
||||||
})) (node_settings["password_policy"] ?? {})
|
|
||||||
),
|
|
||||||
"password_change": (
|
|
||||||
((node_settings_password_change) => ({
|
|
||||||
"cooldown_time": (node_settings_password_change["cooldown_time"] ?? 86400),
|
|
||||||
})) (node_settings["password_change"] ?? {})
|
|
||||||
),
|
|
||||||
"name_index": (
|
|
||||||
((node_settings_password_policy) => ({
|
|
||||||
"veil": (node_settings_password_policy["veil"] ?? true),
|
|
||||||
"salt": (node_settings_password_policy["salt"] ?? ""),
|
|
||||||
})) (node_settings["name_index"] ?? {})
|
|
||||||
),
|
|
||||||
"connections": (
|
|
||||||
((node_settings_connections) => ({
|
|
||||||
"frontend_url_base": (node_settings_connections["frontend_url_base"] ?? null),
|
|
||||||
"login_url": (node_settings_connections["login_url"] ?? null),
|
|
||||||
})) (node_settings["connections"] ?? {})
|
|
||||||
),
|
|
||||||
})) (conf_raw["settings"] ?? {})
|
|
||||||
),
|
|
||||||
"admins": (conf_raw["admins"] ?? []),
|
|
||||||
"outputs": (
|
|
||||||
((node_outputs) => node_outputs.map(
|
|
||||||
(output_description : {kind : string; data : any;}) => {
|
(output_description : {kind : string; data : any;}) => {
|
||||||
const kind : string = output_description["kind"];
|
const kind : string = output_description["kind"];
|
||||||
const node_options_data_raw = (output_description["data"] ?? {});
|
const node_options_data_raw = (output_description["data"] ?? {});
|
||||||
|
@ -1005,16 +507,12 @@ namespace _espe.conf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)) (conf_raw["outputs"] ?? [])
|
);
|
||||||
),
|
break;
|
||||||
};
|
}
|
||||||
break;
|
}
|
||||||
}
|
}) (),
|
||||||
default: {
|
};
|
||||||
throw (new Error("invalid conf version: " + conf_raw["version"]));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue