commit 720c8a6623dd930bbddecb5832416f688e9d79f8 Author: Fenris Wolf Date: Thu Sep 12 00:02:55 2024 +0200 [ini] diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e82584a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,27 @@ +# see https://EditorConfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = tab +indent_style = tab +tab_width = 4 +insert_final_newline = true +max_line_length = 80 +trim_trailing_whitespace = true +curly_bracket_next_line = false +indent_brace_style = K&R +spaces_around_operators = true +spaces_around_brackets = false +quote_type = double + +[*.y{,a}ml{,lint}] +indent_style = space +indent_size = 2 + +[*.md] +indent_style = space +indent_size = 2 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a3af69a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/build/ +/.geany diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..dd5dc83 --- /dev/null +++ b/readme.md @@ -0,0 +1,11 @@ +# Zeitbild | Datamodel + +## Beschreibung + +- Datenmodell für Zeitbild + + +## Nutzung + +- siehe `tools/build -h` + diff --git a/source/structure/r1.sindri.json b/source/structure/r1.sindri.json new file mode 100644 index 0000000..466e572 --- /dev/null +++ b/source/structure/r1.sindri.json @@ -0,0 +1,102 @@ +{ + "domains": [ + { + "name": "sessions", + "data_fields": [ + { + "name": "key", + "type": "string_medium", + "nullable": false + }, + { + "name": "data", + "type": "string_long", + "nullable": false + } + ], + "constraints": [ + { + "kind": "unique", + "parameters": { + "fields": ["key"] + } + } + ] + }, + { + "name": "users", + "key_field": { + "name": "id" + }, + "data_fields": [ + ], + "constraints": [ + ] + }, + { + "name": "events", + "key_field": { + "name": "id" + }, + "data_fields": [ + { + "name": "name", + "type": "string_medium", + "nullable": false + }, + { + "name": "begin", + "type": "string_medium", + "nullable": false + }, + { + "name": "end", + "type": "string_medium", + "nullable": true + }, + { + "name": "location", + "type": "string_medium", + "nullable": true + }, + { + "name": "description", + "type": "string_long", + "nullable": true + } + ], + "constraints": [ + ] + }, + { + "name": "calendars", + "key_field": { + "name": "id" + }, + "data_fields": [ + { + "name": "name", + "type": "string_medium", + "nullable": false + }, + { + "name": "private", + "type": "boolean", + "nullable": false + }, + { + "name": "kind", + "type": "string_short", + "nullable": false + }, + { + "name": "data", + "type": "string_long", + "nullable": false + } + ], + "constraints": [ + ] + } + ] +} diff --git a/tools/build b/tools/build new file mode 100755 index 0000000..a42df61 --- /dev/null +++ b/tools/build @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +import typing as _typing +import sys as _sys +import os as _os +import argparse as _argparse + + +def main(): + ## consts + dir_source = "source" + + ## args + argument_parser = _argparse.ArgumentParser() + argument_parser.add_argument( + "-r", + "--revision", + type = str, + dest = "revision", + default = None, + help = "use '.' for latest", + ) + argument_parser.add_argument( + "-f", + "--format", + type = str, + dest = "format", + default = "sqlite", + ) + args = argument_parser.parse_args() + + ## vars + revisions = sorted( + list( + map( + lambda name: name.split(".sindri.json")[0], + _os.listdir(_os.path.join(dir_source, "structure")) + ) + ) + ) + revision = ( + args.revision + if + ( + (not (args.revision is None)) + and + (not (args.revision == "")) + and + (not (args.revision == ".")) + ) + else + revisions[-1] + ) + + ## exec + if (not (revision in set(revisions))): + _sys.stderr.write("-- invalid revision: %s\n" % revision) + _sys.exit(1) + else: + _sys.stderr.write("-- data\n") + _os.system( + "cat %s/structure/%s.sindri.json | tools/sindri/sindri --format='database:%s'" + % ( + dir_source, + revision, + args.format, + ) + ) + _sys.stderr.write("-- meta\n") + _sys.stdout.write("DROP TABLE IF EXISTS _meta;\n") + _sys.stdout.write("CREATE TABLE _meta(revision VARCHAR(15) NOT NULL);\n") + _sys.stdout.write("INSERT INTO _meta(revision) VALUES ('%s');\n" % revision) + + +main() diff --git a/tools/sindri/sindri b/tools/sindri/sindri new file mode 100755 index 0000000..e58c3b8 --- /dev/null +++ b/tools/sindri/sindri @@ -0,0 +1,6652 @@ +#!/usr/bin/env node +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +/* +This file is part of »bacterio-plankton:base«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:base« 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. + +»bacterio-plankton:base« 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 »bacterio-plankton:base«. If not, see . + */ +// } +/* +This file is part of »bacterio-plankton:base«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:base« 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. + +»bacterio-plankton:base« 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 »bacterio-plankton:base«. If not, see . + */ +; +var lib_plankton; +(function (lib_plankton) { + var base; + (function (base) { + /** + * @author fenris + */ + function environment() { + return "node"; + } + base.environment = environment; + })(base = lib_plankton.base || (lib_plankton.base = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:base«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:base« 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. + +»bacterio-plankton:base« 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 »bacterio-plankton:base«. If not, see . + */ +/** + * @author fenris + */ +/*export*/ function pseudopointer_null() { + return { + "value": null + }; +} +/** + * @author fenris + */ +/*export*/ function pseudopointer_make(value) { + return { + "value": value + }; +} +/** + * @author fenris + */ +/*export*/ function pseudopointer_isset(pseudopointer) { + return (pseudopointer.value != null); +} +/** + * @author fenris + */ +/*export*/ function pseudopointer_read(pseudopointer) { + if (pseudopointer.value != null) { + return pseudopointer.value; + } + else { + var message = "nullpointer dereferencation"; + throw (new Error(message)); + } +} +/** + * @author fenris + */ +/*export*/ function pseudopointer_write(pseudopointer, value) { + pseudopointer.value = value; +} +/* +This file is part of »bacterio-plankton:base«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:base« 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. + +»bacterio-plankton:base« 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 »bacterio-plankton:base«. If not, see . + */ +/** + * @author fenris + */ +var instance_verbosity = 0; +/** + * @author fenris + */ +function instance_collate(value1, value2) { + if (typeof (value1) === "object") { + if (value1 == null) { + return (value2 == null); + } + else { + if ("_collate" in value1) { + return value1["_collate"](value2); + } + else { + throw (new Error("[collate]" + " " + "object has no such method")); + } + } + } + else { + if (instance_verbosity >= 1) { + // lib_plankton.log.warn("[collate]" + " " + "primitive value; using default implementation"); + } + return (value1 === value2); + } +} +/** + * @author fenris + */ +function instance_compare(value1, value2) { + if (typeof (value1) === "object") { + if ("_compare" in value1) { + return value1["_compare"](value2); + } + else { + throw (new Error("[compare]" + " " + "object has no such method")); + } + } + else { + if (instance_verbosity >= 1) { + // lib_plankton.log.warn("[compare]" + " " + "primitive value; using default implementation"); + } + return (value1 <= value2); + } +} +/** + * @author fenris + */ +function instance_clone(value) { + if (typeof (value) === "object") { + if ("_clone" in value) { + return value["_clone"](); + } + else { + throw (new Error("[clone]" + " " + "object has no such method")); + } + } + else { + if (instance_verbosity >= 1) { + // lib_plankton.log.warn("[clone]" + " " + "primitive value; using default implementation"); + } + return value; + } +} +/** + * @desc the ability to generate a string out of the element, which identifies it to a high degree + * @author fenris + */ +function instance_hash(value) { + if (typeof (value) === "object") { + if ("_hash" in value) { + return value["_hash"](); + } + else { + throw (new Error("[hash]" + " " + "object has no such method")); + } + } + else { + if (instance_verbosity >= 1) { + // lib_plankton.log.warn("[hash]" + " " + "primitive value; using default implementation"); + } + return String(value); + } +} +/** + * @desc the ability to map the element to a textual representation (most likely not injective) + * @author fenris + */ +function instance_show(value) { + if (typeof (value) === "object") { + if (value == null) { + return "NULL"; + } + else { + if ("_show" in value) { + return value["_show"](); + } + else { + // throw (new Error("[show]" + " " + "object has no such method")); + return JSON.stringify(value); + } + } + } + else { + if (instance_verbosity >= 1) { + // lib_plankton.log.warn("[show]" + " " + "primitive value; using default implementation"); + } + return String(value); + } +} +/* +This file is part of »bacterio-plankton:base«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:base« 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. + +»bacterio-plankton:base« 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 »bacterio-plankton:base«. If not, see . + */ +/** + * @author frac + */ +var class_observer = /** @class */ (function () { + /** + * @author frac + */ + function class_observer() { + this.counter = 0; + this.actions = {}; + this.buffer = []; + } + /** + * @author frac + */ + class_observer.prototype.empty = function () { + return (Object.keys(this.actions).length == 0); + }; + /** + * @author frac + */ + class_observer.prototype.flush = function () { + this.actions = {}; + }; + /** + * @author frac + */ + class_observer.prototype.set = function (id, action) { + this.actions[id] = action; + }; + /** + * @author frac + */ + class_observer.prototype.del = function (id) { + delete this.actions[id]; + }; + /** + * @author frac + */ + class_observer.prototype.add = function (action) { + this.set((this.counter++).toString(), action); + }; + /** + * @author frac + */ + class_observer.prototype.notify = function (information, delayed) { + var _this = this; + if (information === void 0) { information = {}; } + if (delayed === void 0) { delayed = false; } + if (delayed) { + this.buffer.push(information); + } + else { + Object.keys(this.actions).forEach(function (id) { return _this.actions[id](information); }); + } + }; + /** + * @author frac + */ + class_observer.prototype.rollout = function () { + var _this = this; + this.buffer.forEach(function (information) { return _this.notify(information, false); }); + this.buffer = []; + }; + return class_observer; +}()); +/** + * @author frac + */ +/* +export interface interface_readable { + + |** + * @author frac + *| + read() : type_executor; + +} + */ +/** + * @author frac + */ +/* +export interface interface_writeable { + + |** + * @author frac + *| + write(value : type_value) : type_executor; + +} + */ +/* +This file is part of »bacterio-plankton:base«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:base« 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. + +»bacterio-plankton:base« 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 »bacterio-plankton:base«. If not, see . + */ +var lib_maybe; +(function (lib_maybe) { + /** + * @author fenris + */ + function make_nothing() { + return { + "kind": "nothing", + "parameters": {} + }; + } + lib_maybe.make_nothing = make_nothing; + /** + * @author fenris + */ + function make_just(value) { + return { + "kind": "just", + "parameters": { + "value": value + } + }; + } + lib_maybe.make_just = make_just; + /** + * @author fenris + */ + function is_nothing(maybe) { + return (maybe.kind === "nothing"); + } + lib_maybe.is_nothing = is_nothing; + /** + * @author fenris + */ + function is_just(maybe) { + return (maybe.kind === "just"); + } + lib_maybe.is_just = is_just; + /** + * @author fenris + */ + function cull(maybe) { + if (!is_just(maybe)) { + var message = "cull from nothing"; + throw (new Error(message)); + } + else { + var value = maybe.parameters["value"]; + return value; + } + } + lib_maybe.cull = cull; + /** + * @author fenris + */ + function propagate(maybe, function_) { + if (!is_just(maybe)) { + } + else { + var value = maybe.parameters["value"]; + var maybe_ = function_(value); + return maybe_; + } + } + lib_maybe.propagate = propagate; +})(lib_maybe || (lib_maybe = {})); +/** + * @author fenris + */ +/*export*/ var class_maybe = /** @class */ (function () { + function class_maybe() { + } + /** + * @desc whether the wrapper is nothing + * @author fenris + */ + class_maybe.prototype.is_nothing = function () { + throw (new Error("not implemented: class_maybe.is_nothing")); + }; + /** + * @desc whether the wrapper is just + * @author fenris + */ + class_maybe.prototype.is_just = function () { + throw (new Error("not implemented: class_maybe.is_just")); + }; + /** + * @desc return the value, stored in the maybe-wrapper + * @author fenris + */ + class_maybe.prototype.cull = function () { + throw (new Error("not implemented: class_maybe.cull")); + }; + /** + * @author fenris + */ + class_maybe.prototype.toString = function () { + throw (new Error("not implemented: class_maybe.cull")); + }; + /** + * @author fenris + */ + class_maybe.prototype.distinguish = function (action_just, action_nothing) { + if (action_nothing === void 0) { action_nothing = function () { }; } + throw (new Error("not implemented: class_maybe.distinguish")); + }; + /** + * @author fenris + */ + class_maybe.prototype.propagate = function (action) { + throw (new Error("not implemented: class_maybe.propagate")); + }; + /** + * @desc [implementation] + * @author fenris + */ + class_maybe.prototype._show = function () { + return this.toString(); + }; + return class_maybe; +}()); +/** + * @author fenris + */ +/*export*/ var class_nothing = /** @class */ (function (_super) { + __extends(class_nothing, _super); + /** + * @author fenris + */ + function class_nothing(reason) { + if (reason === void 0) { reason = null; } + var _this = _super.call(this) || this; + _this.reason = reason; + return _this; + } + /** + * @author fenris + */ + class_nothing.prototype.is_nothing = function () { + return true; + }; + /** + * @author fenris + */ + class_nothing.prototype.is_just = function () { + return false; + }; + /** + * @author fenris + */ + class_nothing.prototype.cull = function () { + var message = "you shouldn't cull a nothing-value …"; + // lib_plankton.log.warn(message); + return null; + }; + /** + * @author fenris + */ + class_nothing.prototype.toString = function () { + return "<\u00B7>"; + }; + /** + * @author fenris + */ + class_nothing.prototype.reason_get = function () { + var content = ((this.reason == null) ? "·" : this.reason); + return "<- ".concat(content, " ->"); + }; + /** + * @author fenris + */ + class_nothing.prototype.distinguish = function (action_just, action_nothing) { + if (action_nothing === void 0) { action_nothing = function () { }; } + action_nothing(this.reason); + }; + /** + * @author fenris + */ + class_nothing.prototype.propagate = function (action) { + return (new class_nothing(this.reason)); + }; + return class_nothing; +}(class_maybe)); +/** + * @author fenris + */ +/*export*/ var class_just = /** @class */ (function (_super) { + __extends(class_just, _super); + /** + * @author fenris + */ + function class_just(value) { + var _this = _super.call(this) || this; + _this.value = value; + return _this; + } + /** + * @author fenris + */ + class_just.prototype.is_nothing = function () { + return false; + }; + /** + * @author fenris + */ + class_just.prototype.is_just = function () { + return true; + }; + /** + * @author fenris + */ + class_just.prototype.cull = function () { + return this.value; + }; + /** + * @author fenris + */ + class_just.prototype.toString = function () { + var content = instance_show(this.value); + return "<+ ".concat(content, " +>"); + }; + /** + * @author fenris + */ + class_just.prototype.distinguish = function (action_just, action_nothing) { + if (action_nothing === void 0) { action_nothing = function () { }; } + action_just(this.value); + }; + /** + * @author fenris + */ + class_just.prototype.propagate = function (action) { + return action(this.value); + }; + return class_just; +}(class_maybe)); +/* +This file is part of »bacterio-plankton:base«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:base« 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. + +»bacterio-plankton:base« 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 »bacterio-plankton:base«. If not, see . + */ +/** + * @author frac + */ +var class_error = /** @class */ (function (_super) { + __extends(class_error, _super); + /** + * @author frac + */ + function class_error(message, suberrors) { + if (suberrors === void 0) { suberrors = []; } + var _this = _super.call(this, message) || this; + _this.suberrors = suberrors; + _this.mess = message; + return _this; + } + /** + * @override + * @author frac + */ + class_error.prototype.toString = function () { + return ( /*super.toString()*/this.mess + " " + ("[" + this.suberrors.map(function (x) { return x.toString(); }).join(",") + "]")); + }; + return class_error; +}(Error)); +var lib_plankton; +(function (lib_plankton) { + var base; + (function (base) { + /** + * returns the current UNIX timestamp + * + * @author fenris + */ + function get_current_timestamp(rounded) { + if (rounded === void 0) { rounded = false; } + var x = (Date.now() / 1000); + return (rounded ? Math.round(x) : x); + ; + } + base.get_current_timestamp = get_current_timestamp; + /** + */ + function object_merge(core, mantle) { + return Object.assign(core, mantle); + } + base.object_merge = object_merge; + })(base = lib_plankton.base || (lib_plankton.base = {})); +})(lib_plankton || (lib_plankton = {})); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +/* +This file is part of »bacterio-plankton:log«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:log« 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. + +»bacterio-plankton:lang« 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 »bacterio-plankton:log«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var log; + (function (log) { + /** + */ + var enum_level; + (function (enum_level) { + enum_level[enum_level["debug"] = 0] = "debug"; + enum_level[enum_level["info"] = 1] = "info"; + enum_level[enum_level["notice"] = 2] = "notice"; + enum_level[enum_level["warning"] = 3] = "warning"; + enum_level[enum_level["error"] = 4] = "error"; + })(enum_level = log.enum_level || (log.enum_level = {})); + ; + /** + */ + function level_order(level1, level2) { + return (level1 <= level2); + } + log.level_order = level_order; + /** + */ + function level_show(level) { + switch (level) { + case enum_level.debug: return "debug"; + case enum_level.info: return "info"; + case enum_level.notice: return "notice"; + case enum_level.warning: return "warning"; + case enum_level.error: return "error"; + default: return "(unknown)"; + } + } + log.level_show = level_show; + })(log = lib_plankton.log || (lib_plankton.log = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:log«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:log« 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. + +»bacterio-plankton:lang« 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 »bacterio-plankton:lang«. If not, see . + */ +/** + * @deprecated + * @todo remove + */ +var lib_plankton; +(function (lib_plankton) { + var log; + (function (log) { + /** + * @author fenris + */ + /*export*/ var level_stack = [0]; + function level_push(level) { level_stack.push(level); } + log.level_push = level_push; + function level_pop() { if (level_stack.length > 1) { + level_stack.pop(); + } } + log.level_pop = level_pop; + function level_get() { return level_stack.slice(-1)[0]; } + /* + export function level_inc() : void {level_push(level_get()+1);} + export function level_dec() : void {level_push(level_get()-1);} + */ + /** + * @author fenris + */ + var indent_stack = [0]; + function indent_push(indent) { indent_stack.push(indent); } + log.indent_push = indent_push; + function indent_pop() { if (indent_stack.length > 1) { + indent_stack.pop(); + } } + log.indent_pop = indent_pop; + function indent_get() { return level_stack.slice(-1)[0]; } + function indent_inc() { level_push(level_get() + 1); } + log.indent_inc = indent_inc; + function indent_dec() { level_push(level_get() - 1); } + log.indent_dec = indent_dec; + /** + * @author fenris + */ + function write(_a) { + var message = _a["message"], _b = _a["type"], type = _b === void 0 ? null : _b, _c = _a["prefix"], prefix = _c === void 0 ? null : _c, _d = _a["level"], level = _d === void 0 ? 0 : _d, _e = _a["indent"], indent = _e === void 0 ? 0 : _e; + var entry = { + "level": ((type === null) + ? lib_plankton.log.enum_level.info + : { + "debug": lib_plankton.log.enum_level.debug, + "info": lib_plankton.log.enum_level.info, + "notice": lib_plankton.log.enum_level.notice, + "warning": lib_plankton.log.enum_level.warning, + "error": lib_plankton.log.enum_level.error + }[type]), + "incident": message, + "details": { + "prefix": prefix, + "level": level, + "indent": indent + } + }; + lib_plankton.log.add(entry); + } + log.write = write; + })(log = lib_plankton.log || (lib_plankton.log = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:log«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:log« 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. + +»bacterio-plankton:lang« 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 »bacterio-plankton:log«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var log; + (function (log) { + /** + */ + var class_channel = /** @class */ (function () { + function class_channel() { + } + return class_channel; + }()); + log.class_channel = class_channel; + })(log = lib_plankton.log || (lib_plankton.log = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:log«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:log« 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. + +»bacterio-plankton:lang« 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 »bacterio-plankton:log«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var log; + (function (log) { + /** + * output for writing log entries to stdout + */ + var class_channel_stdout = /** @class */ (function (_super) { + __extends(class_channel_stdout, _super); + function class_channel_stdout() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + */ + class_channel_stdout.prototype.add = function (entry) { + process.stdout.write(("<" + (new Date(Date.now())).toISOString().slice(0, 19) + ">") + + + " " + + + ("[" + log.level_show(entry.level) + "]") + + + " " + + + ("" + entry.incident + "") + + + ": " + + + JSON.stringify(entry.details, undefined, " ") + + + "\n"); + }; + return class_channel_stdout; + }(log.class_channel)); + log.class_channel_stdout = class_channel_stdout; + })(log = lib_plankton.log || (lib_plankton.log = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:log«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:log« 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. + +»bacterio-plankton:lang« 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 »bacterio-plankton:log«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var log; + (function (log) { + /** + */ + var class_channel_file = /** @class */ (function (_super) { + __extends(class_channel_file, _super); + /** + * [constructor] + */ + function class_channel_file(path) { + var _this = _super.call(this) || this; + _this.path = path; + return _this; + } + /** + */ + class_channel_file.prototype.add = function (entry) { + var _this = this; + var nm_fs = require("fs"); + nm_fs.writeFile(this.path, { + "flag": "a+" + }, (("<" + (new Date(Date.now())).toISOString().slice(0, 19) + ">") + + + " " + + + ("[" + log.level_show(entry.level) + "]") + + + " " + + + ("" + entry.incident + "") + + + ": " + + + JSON.stringify(entry.details, undefined, " ") + + + "\n"), function (error) { + process.stderr.write('-- [plankton] could not add log entry to file ' + _this.path + "\n"); + }); + }; + return class_channel_file; + }(log.class_channel)); + log.class_channel_file = class_channel_file; + })(log = lib_plankton.log || (lib_plankton.log = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:log«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:log« 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. + +»bacterio-plankton:lang« 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 »bacterio-plankton:log«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var log; + (function (log) { + /** + * output for desktop notifications via "libnotify" + */ + var class_channel_notify = /** @class */ (function (_super) { + __extends(class_channel_notify, _super); + function class_channel_notify() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + */ + class_channel_notify.prototype.add = function (entry) { + var nm_child_process = require("child_process"); + var command = ("notify-send" + + + " " + + + ("'" + + + ("[" + log.level_show(entry.level) + "]") + + + " " + + + entry.incident + + + "'") + + + " " + + + ("'" + + + (Object.keys(entry.details) + .map(function (key) { return (key + ": " + JSON.stringify(entry.details[key])); }) + .join("\n")) + + + "'")); + nm_child_process.exec(command, function (error, stdout, stderr) { + // do noting + }); + }; + return class_channel_notify; + }(log.class_channel)); + log.class_channel_notify = class_channel_notify; + })(log = lib_plankton.log || (lib_plankton.log = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:log«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:log« 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. + +»bacterio-plankton:lang« 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 »bacterio-plankton:log«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var log; + (function (log) { + /** + * decorator for filtering out log entries below a certain level threshold + */ + var class_channel_minlevel = /** @class */ (function (_super) { + __extends(class_channel_minlevel, _super); + /** + */ + function class_channel_minlevel(core, threshold) { + var _this = _super.call(this) || this; + _this.core = core; + _this.threshold = threshold; + return _this; + } + /** + */ + class_channel_minlevel.prototype.add = function (entry) { + if (!log.level_order(this.threshold, entry.level)) { + // do nothing + } + else { + this.core.add(entry); + } + }; + return class_channel_minlevel; + }(log.class_channel)); + log.class_channel_minlevel = class_channel_minlevel; + })(log = lib_plankton.log || (lib_plankton.log = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:log«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:log« 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. + +»bacterio-plankton:lang« 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 »bacterio-plankton:log«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var log; + (function (log) { + /** + */ + function translate_level(level_string) { + return { + "debug": log.enum_level.debug, + "info": log.enum_level.info, + "notice": log.enum_level.notice, + "warning": log.enum_level.warning, + "error": log.enum_level.error + }[level_string]; + } + /** + */ + function channel_make(description) { + var _a, _b, _c, _d; + switch (description.kind) { + default: { + throw (new Error("unhandled log channel kind: " + description.kind)); + break; + } + case "stdout": { + return (new log.class_channel_minlevel(new log.class_channel_stdout(), translate_level((_a = description.data["threshold"]) !== null && _a !== void 0 ? _a : "debug"))); + break; + } + case "file": { + return (new log.class_channel_minlevel(new log.class_channel_file((_b = description.data["path"]) !== null && _b !== void 0 ? _b : "/tmp/plankton.log"), translate_level((_c = description.data["threshold"]) !== null && _c !== void 0 ? _c : "debug"))); + break; + } + case "notify": { + return (new log.class_channel_minlevel(new log.class_channel_notify(), translate_level((_d = description.data["threshold"]) !== null && _d !== void 0 ? _d : "debug"))); + break; + } + } + } + log.channel_make = channel_make; + /** + */ + function conf_default() { + return [ + new log.class_channel_minlevel(new log.class_channel_stdout(), log.enum_level.notice), + new log.class_channel_minlevel(new log.class_channel_notify(), log.enum_level.error), + ]; + } + log.conf_default = conf_default; + })(log = lib_plankton.log || (lib_plankton.log = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:log«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:log« 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. + +»bacterio-plankton:lang« 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 »bacterio-plankton:log«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var log; + (function (log) { + /** + */ + var _channel_stack = null; + /** + * pushes a new configuration on the stack and activates it + */ + function conf_push(channels) { + if (_channel_stack === null) { + _channel_stack = []; + } + _channel_stack.push(channels); + } + log.conf_push = conf_push; + /** + * pops the current active configuration from the stack + */ + function conf_pop() { + if (_channel_stack.length > 0) { + _channel_stack.pop(); + } + else { + // do nothing + } + } + log.conf_pop = conf_pop; + /** + * makes the logging system ready + */ + function setup() { + if (_channel_stack === null) { + _channel_stack = []; + conf_push(log.conf_default()); + } + else { + // do nothing + } + } + /** + * consumes a log entry, i.e. sends it to the currently active outputs + */ + function add(entry) { + setup(); + _channel_stack.slice(-1)[0].forEach(function (channel) { return channel.add(entry); }); + } + log.add = add; + /** + */ + function debug(incident, details) { + if (details === void 0) { details = {}; } + add({ "level": log.enum_level.debug, "incident": incident, "details": details }); + } + log.debug = debug; + /** + */ + function info(incident, details) { + if (details === void 0) { details = {}; } + add({ "level": log.enum_level.info, "incident": incident, "details": details }); + } + log.info = info; + /** + */ + function notice(incident, details) { + if (details === void 0) { details = {}; } + add({ "level": log.enum_level.notice, "incident": incident, "details": details }); + } + log.notice = notice; + /** + */ + function warning(incident, details) { + if (details === void 0) { details = {}; } + add({ "level": log.enum_level.warning, "incident": incident, "details": details }); + } + log.warning = warning; + /** + */ + function error(incident, details) { + if (details === void 0) { details = {}; } + add({ "level": log.enum_level.error, "incident": incident, "details": details }); + } + log.error = error; + })(log = lib_plankton.log || (lib_plankton.log = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:string«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:string« 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. + +»bacterio-plankton:string« 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 »bacterio-plankton:string«. If not, see . + */ +var plain_text_to_html = function (text) { + let ret = text; + ret = ret.replace(/ /g, "  "); // convert multiple whitespace to forced ones + ret = ret.split("\n").join("
"); + return ret; +}; +/** + * @desc makes a valid + */ +var format_sentence = function (str, rtl = false, caseSense = true) { + if (str === "") { + return str; + } + else { + let marks = { + ".": true, + "?": true, + "!": true + }; + let default_mark = "."; + let ret = str.split(""); + if (!rtl) { + ret[0] = ret[0].toLocaleUpperCase(); + if (!(ret[ret.length - 1] in marks)) { + ret.push(default_mark); + } + } + else { + ret[ret.length - 1] = ret[ret.length - 1].toLocaleUpperCase(); + if (!(ret[0] in marks)) { + ret.unshift(default_mark); + } + } + return ret.join(""); + } +}; +var fill_string_template = function (template_string, object, fabric = function (object, key) { return object[key]; }, delimiter = "%", default_string = null, sloppy) { + function get_tags(str) { + let r = new RegExp(delimiter + "[^\\s^" + delimiter + "]+" + delimiter, "gi"); + return ((str.match(r) || []).map(function (e) { + return e.slice(delimiter.length, e.length - delimiter.length); + })); + } + function replace_tag(str, tag, value) { + let r = new RegExp(delimiter + tag + delimiter, "gi"); + return str.replace(r, value); + } + function replace_tags(str, obj) { + return (get_tags(str).reduce(function (ret, key) { + let value = ""; + try { + value = fabric(obj, key); + if ((!sloppy && (value === void 0)) || (sloppy && (value == void 0))) { + value = default_string; + } + } + catch (e) { + console.warn("invalid placeholder " + key); + value = default_string; + } + return replace_tag(ret, key, value); + }, str)); + } + return replace_tags(template_string, object); +}; +var make_string_template = function (_template, _fabrics = {}) { + function replace_tag(str, tag, value) { + var r = new RegExp("%" + tag + "%", "gi"); + return str.replace(r, value); + } + function replace_tags(str, obj) { + return (Object.keys(obj).reduce(function (ret, key) { + return replace_tag(ret, key, _fabrics[key] || obj[key]); + }, str)); + } + return (function (tags) { + return replace_tags(_template, tags); + }); +}; +var make_eml_header = (function () { + let _template = ""; + _template += "From: %from%\n"; + _template += "To: %recipient%\n"; + _template += "Subject: %subject%\n"; + _template += "X-Mailer: greenscale-plankton.emlgen\n"; + return make_string_template(_template); +})(); +var make_eml_body = (function () { + let exports = {}; + exports["simple_body"] = make_string_template("Content-Type: %contenttype%\n\n%body%\n\n"); + // very basic implementation + // parts = [{contenttype:"text/html; charset=UTF-8", body: "

foo

" }, {...}] + exports["body_boundrary"] = function (parts, boundrary) { + let _template = ""; + _template += "--%boundrary%\n"; + _template += "Content-Type: %contenttype%\n\n%body%\n\n"; + //_template += "--%boundrary%--\n\n"; + let maker = make_string_template(_template); + return (parts.reduce(function (prev, curr) { + curr.boundrary = boundrary; + return [prev, maker(curr)].join(""); + }, "")); + }; + // body must be base64 encoded! + exports["attachment_boundrary"] = function (parts, boundrary) { + let _template = ""; + _template += "--%boundrary%\n"; + _template += "Content-Type: %contenttype%\n"; + _template += "Content-Transfer-Encoding: base64\n"; + _template += "Content-Disposition: %disposition%; filename=\"%name%\"\n\n"; + _template += "%body%\n\n"; + //_template += "--%boundrary%--\n\n"; + let maker = make_string_template(_template); + return (parts.reduce(function (prev, curr) { + curr.boundrary = boundrary; + if (curr.disposition === void 0) + curr.disposition = "inline"; + return [prev, maker(curr)].join(""); + }, "")); + }; + exports["gen_boundrary"] = function () { + return ("xxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g, function (c) { + let r = crypto.getRandomValues(new Uint8Array(1))[0] % 16 | 0, v = c == "x" ? r : (r & 0x3 | 0x8); + return v.toString(16); + })); + }; + // simple implementation without alternatives (old rfc) + exports["complete_boundrary"] = function (bodyparts, attachments) { + let ret = ""; + let boundrary = exports["gen_boundrary"](); + ret += exports["body_boundrary"](bodyparts, boundrary); + ret += exports["attachment_boundrary"](attachments, boundrary); + ret += "--" + boundrary + "--\n\nINVISIBLE!!!!"; + return (exports["simple_body"]({ + "contenttype": sprintf("multipart/mixed; boundary=%s", [boundrary]), + "body": ret + })); + }; + return exports; +})(); +/* +This file is part of »bacterio-plankton:string«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:string« 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. + +»bacterio-plankton:string« 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 »bacterio-plankton:string«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var string; + (function (string) { + /** + * @author fenris + */ + const hexdigits = 4; + /** + * @author fenris + */ + const index_max = (1 << (4 * hexdigits)); + /** + * @author fenris + */ + var index_is = 0; + /** + * @author neuc,frac + */ + function empty(str) { + return (str.trim() === ""); + } + string.empty = empty; + /** + * @desc returns a unique string + * @param {string} prefix an optional prefix for the generated string + * @return {string} + * @author fenris + */ + function generate(prefix = "string_") { + if (index_is > index_max) { + throw (new Error("[string_generate] out of valid indices")); + } + else { + return string.sprintf(prefix + "%0" + hexdigits.toString() + "X", [index_is++]); + } + } + string.generate = generate; + /** + * @author fenris + */ + function join(parts, glue = " ") { + if (parts.length == 0) { + return ""; + } + else { + return parts.join(glue); + } + } + string.join = join; + /** + * @desc splits a string, but returns an empty list, if the string is empty + * @param {string} chain + * @param {string} separator + * @return {Array} + * @author fenris + */ + function split(chain, separator = " ") { + if (chain.length == 0) { + return []; + } + else { + return chain.split(separator); + } + } + string.split = split; + /** + * @author neu3no + */ + function explode(str, needle, max) { + let temp = str.split(needle); + const right = temp.splice(max - 1); + temp.push(right.join(needle)); + return temp; + } + string.explode = explode; + /** + * @desc concats a given word with itself n times + * @param {string} word + * @param {int} + * @return {string} + * @author fenris + */ + function repeat(word, count) { + // return ((count == 0) ? "" : (word + repeat(word, count-1))); + let result = ""; + for (let n = 0; n < count; n += 1) { + result += word; + } + return result; + } + string.repeat = repeat; + /** + * @desc lengthens a string by repeatedly appending or prepending another string + * @param {string} word the string to pad + * @param {int} length the length, which the result shall have + * @param {string} symbol the string, which will be added (multiple times) + * @param {boolean} [prepend]; whether to prepend (~true) or append (~false); default: false + * @return {string} the padded string + * @author fenris + */ + function pad(word, length, symbol = " ", mode = "append") { + switch (mode) { + case "prepend": { + // insert symbols only at the beginning + while (word.length < length) + word = symbol + word; + return word.substring(word.length - length); + break; + } + case "append": { + // insert symbols only at the end + while (word.length < length) + word = word + symbol; + return word.substring(0, length); + break; + } + case "widen": { + // insert symbols at both sides + let left = (((length - word.length) & 1) === 0); + while (word.length < length) { + word = (left + ? (symbol + word) + : (word + symbol)); + left = (!left); + } + return word.substring(0, length); + break; + } + default: { + const message = ("unhandled mode '" + mode + "'"); + console.warn(message); + return word; + break; + } + } + } + string.pad = pad; + /** + * @desc checks if a given string conttains a certain substring + * @param {string} string + * @param {string} part + * @return {boolean} + * @author fenris + */ + function contains(chain, part) { + if (typeof (chain) !== "string") { + return false; + } + return (chain.indexOf(part) >= 0); + } + string.contains = contains; + /** + * @desc checks if a given string starts with a certain substring + * @param {string} string + * @param {string} part + * @return {boolean} + * @author fenris + */ + function startsWith(chain, part) { + if (typeof (chain) !== "string") { + return false; + } + // return (string.indexOf(part) === 0); + return ((function (m, n) { + if (n === 0) { + return true; + } + else { + if (m === 0) { + return false; + } + else { + return ((chain[0] == part[0]) + && + startsWith(chain.substring(1), part.substring(1))); + } + } + })(chain.length, part.length)); + } + string.startsWith = startsWith; + /** + * @desc checks if a given string ends with a certain substring + * @param {string} string + * @param {string} part + * @return {boolean} + * @author fenris + */ + function endsWith(chain, part) { + if (typeof (chain) !== "string") { + return false; + } + // return (string.lastIndexOf(part) === string.length-part.length); + return ((function (m, n) { + if (n === 0) { + return true; + } + else { + if (m === 0) { + return false; + } + else { + // console.info(("(" + string[m-1] + " == " + part[n-1] + ")") + " = " + String(string[m-1] == part[n-1])); + return ((chain[m - 1] === part[n - 1]) + && + endsWith(chain.substring(0, m - 1), part.substring(0, n - 1))); + } + } + })(chain.length, part.length)); + } + string.endsWith = endsWith; + /** + * @desc count the occourrences of a string in a string + * @param string haystack_string the string wich should be examined + * @param string needle_string the string which should be counted + * @author neuc + */ + function count_occourrences(haystack_string, needle_string, check_escape) { + let cnt = 0; + let pos = -1; + do { + pos = haystack_string.indexOf(needle_string, pos + 1); + if ((!check_escape) || (haystack_string[pos - 1] != "\\")) { + cnt++; + } + } while (pos >= 0); + return (cnt - 1); + } + string.count_occourrences = count_occourrences; + /** + * @author fenris + */ + function replace(str, replacements, options = {}) { + options = Object.assign({}, options); + let result = str; + replacements.forEach(replacement => { + lib_plankton.log.debug("lib_plankton.string.replace", { + "from": replacement.from, + "to": replacement.to, + }); + result = result.replace(new RegExp(replacement.from, "g"), replacement.to); + }); + return result; + } + string.replace = replace; + /** + * @desc replaces occurences of "{{name}}" in a string by the corresponding values of an argument object + * @author fenris + */ + function coin(str, args, options = {}) { + options = Object.assign({ + "legacy": false, + "open": "{{", + "close": "}}", + }, options); + Object.keys(args).forEach((key) => { + // old syntax + { + if (options.legacy) { + const value = args[key]; + const regexp_argument = new RegExp("\\${" + key + "}", "g"); + lib_plankton.log.debug("lib_plankton.string.coin", { + "key": key, + "regex": regexp_argument.toString(), + "value": value, + }); + str = str.replace(regexp_argument, value); + } + } + // new syntax + { + const value = args[key]; + const regexp_argument = new RegExp(options.open + key + options.close, "g"); + lib_plankton.log.debug("lib_plankton.string.coin", { + "key": key, + "regex": regexp_argument.toString(), + "value": value, + }); + str = str.replace(regexp_argument, value); + } + }); + return str; + } + string.coin = coin; + /** + * @author fenris + * @deprecated use limit + */ + function cut(str, length, delimiter = "…") { + if (str.length <= length) { + return str; + } + else { + return (str.slice(0, length - delimiter.length) + delimiter); + } + } + string.cut = cut; + /** + */ + function limit(str, options = {}) { + options = Object.assign({ + "length": 120, + "indicator": "…", + }, options); + return ((str.length <= options.length) + ? str + : (str.slice(0, options.length - options.indicator.length) + options.indicator)); + } + string.limit = limit; + /** + */ + function slice(str, size) { + let slices = []; + let rest = str; + while (rest.length > 0) { + slices.push(rest.slice(0, size)); + rest = rest.slice(size); + } + return slices; + } + string.slice = slice; + })(string = lib_plankton.string || (lib_plankton.string = {})); +})(lib_plankton || (lib_plankton = {})); +/** + * @deprecated + */ +var lib_string; +(function (lib_string) { + lib_string.empty = lib_plankton.string.empty; + lib_string.generate = lib_plankton.string.generate; + lib_string.split = lib_plankton.string.split; + lib_string.explode = lib_plankton.string.repeat; + lib_string.repeat = lib_plankton.string.repeat; + lib_string.pad = lib_plankton.string.pad; + lib_string.contains = lib_plankton.string.contains; + lib_string.startsWith = lib_plankton.string.startsWith; + lib_string.endsWith = lib_plankton.string.endsWith; + lib_string.count_occourrences = lib_plankton.string.count_occourrences; + lib_string.coin = lib_plankton.string.coin; + lib_string.stance = lib_plankton.string.coin; + lib_string.cut = lib_plankton.string.cut; +})(lib_string || (lib_string = {})); +/* +This file is part of »bacterio-plankton:string«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:string« 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. + +»bacterio-plankton:string« 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 »bacterio-plankton:string«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var string; + (function (string) { + var pattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/; + var gpattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/g; + function split_format(format) { + var tmp = format.match(pattern); + if (tmp === null) + return null; + return { + 'flags': tmp[1].split(""), + 'width': Number(tmp[2]), + 'precision': tmp[3] === '' ? null : Number(tmp[3]), + 'specifier': tmp[4], + 'string': format + }; + } + function make_err(format, arg, should) { + return ("[sprintf]" + " " + "argument for '" + format.string + "' has to be '" + should + "' but '" + arg + "' is '" + typeof arg + "'!"); + } + function test_arg(format, arg, should) { + if (typeof arg !== should) { + console.warn(make_err(format, arg, should)); + return false; + } + return true; + } + function string_fill(str, char, len, left) { + while (str.length < len) { + if (left) { + str += char; + } + else { + str = char + str; + } + } + return str; + } + /** + * the known_parameters are used to parse the different identifiers for the welln known syntax: + * flag width precision identifier + * %{[0#+- ]}{[0-9]*}.{[0-9]*}[fFdiueEgGsoxXaAsn] + * flags: + * 0 - fill with '0' instead of ' ' if the string length < width + * # - not implemented + * - - left-justified -> fill on the right side to reach width + * + - force using '+' on positive numbers + * ' ' - add a single space before positive numbers + * + * identifiers + * %f, %F - interpret given number as float, width: the minimal total width (fill with ' ' or '0' if the + * resulting string is too short, precision: cut more then given decimal places + * %d, %i, %u - interpret number as integer, decimal places will be cut. width: like float, precision: + * fill with '0' on right side until length given in precision is reached + * %e - interpret as float and write as scientifical number, width & precision like in float + * %E - same es %e but uppercase 'E' + * %g - use the shortest string of %f or %e + * %G - use the shortest string of %E or %E + * %s - simply print a string + * %o - print the given number in octal notation + * %x - print the given number in hex notation + * %X - same as %x but with uppercase characters + * %a - alias to %x + * %A - alias to %X + * %n - just print nothing + * @type {{}} + */ + var known_params = {}; + known_params["f"] = function (format, arg) { + if (!test_arg(format, arg, "number")) + return "Ø"; + var tmp = Math.abs(arg); + var sign = (arg < 0) ? -1 : 1; + var tmp_result = null; + if (format.precision !== null) { + tmp = Math.floor(Math.pow(10, format.precision) * tmp) / Math.pow(10, format.precision); + var tmp_ = (tmp * sign).toString().split("."); + if (tmp_.length === 1) + tmp_.push(""); + tmp_[1] = string_fill(tmp_[1], "0", format.precision, true); + tmp_result = tmp_.join("."); + } + else { + tmp_result = (sign * tmp).toString(); + } + if ((format.flags.indexOf(" ") >= 0) && (arg >= 0)) { + tmp_result = " " + tmp; + } + else if ((format.flags.indexOf("+") >= 0) && (arg >= 0)) { + tmp_result = "+" + tmp; + } + tmp_result = string_fill(tmp, (format.flags.indexOf("0") >= 0) ? "0" : " ", format.width, (format.flags.indexOf("-") >= 0)); + return tmp_result; + }; + known_params["F"] = known_params["f"]; + known_params["d"] = function (format, arg) { + if (!test_arg(format, arg, 'number')) + return 'Ø'; + var tmp = (((arg < 0 && format.specifier !== 'u') ? -1 : 1) * Math.floor(Math.abs(arg))).toString(); + if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf(' ') >= 0 && arg >= 0) { + tmp = ' ' + tmp; + } + else if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf('+') >= 0 && arg >= 0) { + tmp = '+' + tmp; + } + tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); + tmp = string_fill(tmp, '0', format.precision === null ? 0 : format.precision, false); + return tmp; + }; + known_params["i"] = known_params["d"]; + known_params["u"] = known_params["d"]; + known_params["e"] = function (format, arg) { + if (!test_arg(format, arg, 'number')) + return 'Ø'; + var tmp = arg.toExponential(format.precision === null ? undefined : format.precision).toString(); + if (format.flags.indexOf(' ') >= 0 && arg >= 0) { + tmp = ' ' + tmp; + } + else if (format.flags.indexOf('+') >= 0 && arg >= 0) { + tmp = '+' + tmp; + } + tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); + return tmp; + }; + known_params["E"] = function (format, arg) { + return known_params["e"](format, arg).toUpperCase(); + }; + known_params["g"] = function (format, arg) { + if (!test_arg(format, arg, 'number')) + return 'Ø'; + var tmpf = known_params["f"](format, arg); + var tmpe = known_params["e"](format, arg); + if (tmpf.length < tmpe.length) { + return tmpf; + } + else { + return tmpe; + } + }; + known_params["G"] = function (format, arg) { + return known_params["g"](format, arg).toUpperCase(); + }; + known_params["s"] = function (format, arg) { + if (!test_arg(format, arg, 'string')) + return 'o.O'; + var tmp = format.precision !== null ? arg.substr(0, format.precision) : arg; + tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); + return tmp; + }; + known_params["o"] = function (format, arg) { + if (!test_arg(format, arg, 'number')) + return 'Ø'; + var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); + return known_params["s"](format, tmp.toString(8)); + }; + known_params["x"] = function (format, arg) { + if (!test_arg(format, arg, 'number')) + return 'Ø'; + var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); + return known_params["s"](format, tmp.toString(16)); + }; + known_params["a"] = known_params["x"]; + known_params["X"] = function (format, arg) { + if (!test_arg(format, arg, 'number')) + return 'Ø'; + return known_params["x"](format, arg).toUpperCase(); + }; + known_params["A"] = known_params["X"]; + known_params["c"] = function (format, arg) { + var tmp = ""; + if (typeof arg === "number") { + tmp = String.fromCharCode(arg); + } + else if ((typeof arg === "string") && (arg.length === 1)) { + tmp = arg[0]; + } + else { + console.warn(make_err(format, arg, "number|string") + " and if string it needs to have the length of 1!"); + } + return known_params["s"](format, tmp); + }; + known_params["n"] = function () { + return ""; + }; + var decompose = function (chain, regexp) { + var result = regexp.exec(chain); + if (result == null) { + return null; + } + else { + var front = chain.substring(0, result.index); + var back = chain.substring(result.index + result[0].length); + return { "front": front, "match": result[0], "back": back }; + } + }; + /** + * an implementation of c sprintf + * @param {string} string format string + * @param {array} args arguments which should be filled into + * @returns {string} + */ + string.sprintf = function (input, args = [], original = null) { + if (original == null) + original = input; + var components = decompose(input, pattern); + if (components == null) { + if (args.length > 0) { + console.warn("[sprintf] superfluous arguments while formatting '" + original + "': ", args); + } + return input; + } + else { + var arg; + var rest; + if (args.length > 0) { + arg = args[0]; + rest = args.slice(1); + } + else { + console.warn("[sprintf] out of arguments while formatting '" + original + "'"); + arg = null; + rest = []; + return input; + } + var fmt = split_format(components["match"]); + return (components["front"] + + known_params[fmt.specifier](fmt, arg) + + string.sprintf(components["back"], rest, original)); + } + }; + /** + * an implementation of c printf + * @param {string} string format string + * @param {array} args arguments which should be filled into + * @returns {string} + */ + function printf(format, args) { + console.log(string.sprintf(format, args)); + } + string.printf = printf; + })(string = lib_plankton.string || (lib_plankton.string = {})); +})(lib_plankton || (lib_plankton = {})); +var sprintf = lib_plankton.string.sprintf; +var printf = lib_plankton.string.printf; +/* +This file is part of »bacterio-plankton:string«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:string« 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. + +»bacterio-plankton:string« 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 »bacterio-plankton:string«. If not, see . + */ +var make_logger = (function () { + var _loggers = {}; + var make_logger = function (prefix, current_loglevel) { + var log = []; + var level = [ + "LOG", "INFO", "WARNING", "DEBUG" + ]; + var logger = function (obj, lvl) { + var txt = obj.txt || obj; + if (lvl == void 0) + lvl = 0; + var date = new Date(); + log.push({ + "message": sprintf("%s [%s:%s] %s", [date.toString(), level[lvl], prefix, txt]), + "timeStamp": +(date) + }); + if (lvl <= current_loglevel) { + var msg = ["[" + prefix + "]", txt]; + if (obj.arg) + msg = ["[" + prefix + "]"].concat(Array.prototype.slice.call(obj.arg)); + if (lvl === 0) + console["_log"].apply(console, msg); + else if (lvl === 1) + console["_info"].apply(console, msg); + else if (lvl === 2) + console["_warn"].apply(console, msg); + else if (lvl >= 3) + console["_log"].apply(console, msg); + } + }; + _loggers[prefix] = { + "logger": logger, + "log": log + }; + return logger; + }; + make_logger["loggers"] = _loggers; + make_logger["complete_log"] = function () { + var logs = Object.keys(_loggers) + .reduce(function (p, c) { + return [].concat(p, _loggers[c].log); + }, []); + logs.sort(function (x, y) { + return ((x.timeStamp > y.timeStamp) ? -1 : +1); + }); + return logs.map(function (x, i, a) { + return x.message; + }); + }; + if ( /*!track_exports*/true) { + var _log_all = function (log, lvl, next = function () { }) { + return function () { + var msg = []; + for (var i = 0; i < arguments.length; i++) { + if (typeof arguments[i] === "string") { + msg.push(arguments[i]); + } + else { + msg.push(JSON.stringify(arguments[i])); + } + } + var obj = { + txt: msg.join("\t"), + arg: arguments + }; + log(obj, lvl); + next(); + }; + }; + { + var __warn = make_logger("deprecated console.warn", 99); + var __error = make_logger("deprecated console.error", 99); + var __log = make_logger("deprecated console.log", 99); + var __info = make_logger("deprecated console.info", 99); + // bad ass + console["_log"] = console.log; + console["_error"] = console.error; + console["_warn"] = console.warn; + console["_info"] = console.info; + /* + console["log"] = _log_all(__log, 0); + console["error"] = _log_all(__error, 2); + console["warn"] = _log_all(__warn, 2); + console["info"] = _log_all(__info, 0); + */ + } + /* + { + make_logger["send_log"] = function(){ + eml_log( + function () { + alert("fehlerbericht wurde gesendet!"); + } + ); + }; + var error_log = make_logger("global.error", 99); + window.onerror = _log_all( + error_log, + 1, + function(){ + if (global_config == undefined) { + return false; + } + if (global_config.report_error) { + make_logger["send_log"](); + } + } + ); + } + */ + } + return make_logger; +})(); +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var code; + (function (code) { + /** + * @author fenris + */ + function inverse_encode(decode, to) { + return decode(to); + } + code.inverse_encode = inverse_encode; + /** + * @author fenris + */ + function inverse_decode(encode, from) { + return encode(from); + } + code.inverse_decode = inverse_decode; + })(code = lib_plankton.code || (lib_plankton.code = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var code; + (function (code) { + /** + * @author fenris + */ + var class_code_inverse = /** @class */ (function () { + /** + * @author fenris + */ + function class_code_inverse(subject) { + this.subject = subject; + } + /** + * @implementation + * @author fenris + */ + class_code_inverse.prototype.encode = function (to) { + var _this = this; + return code.inverse_encode(function (x) { return _this.subject.decode(x); }, to); + }; + /** + * @implementation + * @author fenris + */ + class_code_inverse.prototype.decode = function (from) { + var _this = this; + return code.inverse_decode(function (x) { return _this.subject.encode(x); }, from); + }; + return class_code_inverse; + }()); + code.class_code_inverse = class_code_inverse; + })(code = lib_plankton.code || (lib_plankton.code = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var code; + (function (code) { + /** + * @author fenris + */ + function pair_encode(encode_first, encode_second, from) { + var between = encode_first(from); + var to = encode_second(between); + return to; + } + code.pair_encode = pair_encode; + /** + * @author fenris + */ + function pair_decode(decode_first, decode_second, to) { + var between = decode_second(to); + var from = decode_first(between); + return from; + } + code.pair_decode = pair_decode; + })(code = lib_plankton.code || (lib_plankton.code = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var code; + (function (code) { + /** + * @author fenris + */ + var class_code_pair = /** @class */ (function () { + /** + * @author fenris + */ + function class_code_pair(first, second) { + this.first = first; + this.second = second; + } + /** + * @implementation + * @author fenris + */ + class_code_pair.prototype.encode = function (from) { + var _this = this; + return code.pair_encode(function (x) { return _this.first.encode(x); }, function (x) { return _this.second.encode(x); }, from); + }; + /** + * @implementation + * @author fenris + */ + class_code_pair.prototype.decode = function (to) { + var _this = this; + return code.pair_decode(function (x) { return _this.first.decode(x); }, function (x) { return _this.second.decode(x); }, to); + }; + return class_code_pair; + }()); + code.class_code_pair = class_code_pair; + })(code = lib_plankton.code || (lib_plankton.code = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var code; + (function (code) { + /** + * @author fenris + */ + function chain_encode(encode_links, from) { + var value = from; + encode_links + .forEach(function (link) { + value = link(value); + }); + return value; + } + code.chain_encode = chain_encode; + /** + * @author fenris + */ + function chain_decode(decode_links, to) { + var value = to; + decode_links + .reverse() + .forEach(function (link) { + value = link(value); + }); + return value; + } + code.chain_decode = chain_decode; + })(code = lib_plankton.code || (lib_plankton.code = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var code; + (function (code) { + /** + * @author fenris + */ + var class_code_chain = /** @class */ (function () { + /** + * @author fenris + */ + function class_code_chain(links) { + this.links = links; + } + /** + * @implementation + * @author fenris + */ + class_code_chain.prototype.encode = function (from) { + return code.chain_encode(this.links.map(function (link) { return (function (x) { return link.encode(x); }); }), from); + }; + /** + * @implementation + * @author fenris + */ + class_code_chain.prototype.decode = function (to) { + return code.chain_decode(this.links.map(function (link) { return (function (x) { return link.decode(x); }); }), to); + }; + return class_code_chain; + }()); + code.class_code_chain = class_code_chain; + })(code = lib_plankton.code || (lib_plankton.code = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var code; + (function (code) { + /** + * @author Christian Fraß + */ + function flatten_encode(from, keys) { + if (keys === void 0) { keys = null; } + if (keys === null) { + if (from.length > 0) { + keys = Object.keys(from[0]); + } + else { + throw (new Error("encoding impossible")); + } + } + return { + "keys": keys, + "data": from.map(function (line) { return keys.map(function (name) { return line[name]; }); }) + }; + } + code.flatten_encode = flatten_encode; + /** + * @author Christian Fraß + */ + function flatten_decode(to) { + return (to.data + .map(function (dataset) { + var dataset_ = {}; + dataset + .forEach(function (value, index) { + var name = to.keys[index]; + dataset_[name] = value; + }); + return dataset_; + })); + } + code.flatten_decode = flatten_decode; + })(code = lib_plankton.code || (lib_plankton.code = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:code«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:code« 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. + +»bacterio-plankton:code« 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 »bacterio-plankton:code«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var code; + (function (code) { + /** + * @author fenris + */ + var class_code_flatten = /** @class */ (function () { + /** + * @author fenris + */ + function class_code_flatten() { + } + /** + * @implementation + * @author fenris + */ + class_code_flatten.prototype.encode = function (x) { + return code.flatten_encode(x); + }; + /** + * @implementation + * @author fenris + */ + class_code_flatten.prototype.decode = function (x) { + return code.flatten_decode(x); + }; + return class_code_flatten; + }()); + code.class_code_flatten = class_code_flatten; + })(code = lib_plankton.code || (lib_plankton.code = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:json«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:json« 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. + +»bacterio-plankton:json« 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 »bacterio-plankton:json«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var json; + (function (json) { + /** + * @author fenris + */ + function encode(x, formatted = false) { + return JSON.stringify(x, undefined, formatted ? "\t" : undefined); + } + json.encode = encode; + /** + * @author fenris + */ + function decode(x) { + return JSON.parse(x); + } + json.decode = decode; + })(json = lib_plankton.json || (lib_plankton.json = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:json«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:json« 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. + +»bacterio-plankton:json« 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 »bacterio-plankton:json«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var json; + (function (json) { + /** + * @author fenris + */ + class class_json { + /** + * @author fenris + */ + constructor() { + } + /** + * @implementation + * @author fenris + */ + encode(x) { + return json.encode(x); + } + /** + * @implementation + * @author fenris + */ + decode(x) { + return json.decode(x); + } + } + json.class_json = class_json; + })(json = lib_plankton.json || (lib_plankton.json = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:file«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:file« 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. + +»bacterio-plankton:file« 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 »bacterio-plankton:file«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var file; + (function (file) { + /** + * @author fenris + */ + function read(path) { + var nm_fs = require("fs"); + return (new Promise(function (resolve, reject) { + nm_fs.readFile(path, { + "encoding": "utf8", + "flag": "r", + }, function (error, content) { + if (error == null) { + resolve(content); + } + else { + reject(error); + } + }); + })); + } + file.read = read; + /** + * @author fenris + */ + function read_buffer(path) { + var nm_fs = require("fs"); + return (new Promise(function (resolve, reject) { + nm_fs.readFile(path, { + "flag": "r", + }, function (error, content) { + if (error == null) { + resolve(content); + } + else { + reject(error); + } + }); + })); + } + file.read_buffer = read_buffer; + /** + * @author fenris + */ + function read_stdin() { + return (new Promise(function (resolve, reject) { + var input_raw = ""; + process.stdin.setEncoding("utf8"); + process.stdin.on("readable", function () { + var chunk; + while ((chunk = process.stdin.read()) !== null) { + input_raw += chunk; + } + }); + process.stdin.on("end", function () { + resolve(input_raw); + }); + })); + } + file.read_stdin = read_stdin; + /** + * @author fenris + */ + function write(path, content, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "encoding": "utf-8", + }, options); + var nm_fs = require("fs"); + return (new Promise(function (resolve, reject) { + nm_fs.writeFile(path, content, { + "encoding": options.encoding, + "flag": "w", + }, function (error) { + if (error == null) { + resolve(undefined); + } + else { + reject(error); + } + }); + })); + } + file.write = write; + /** + * @author fenris + */ + function write_buffer(path, content, options) { + if (options === void 0) { options = {}; } + options = Object.assign({}, options); + var nm_fs = require("fs"); + return (new Promise(function (resolve, reject) { + nm_fs.writeFile(path, content, { + "flag": "w", + }, function (error) { + if (error == null) { + resolve(undefined); + } + else { + reject(error); + } + }); + })); + } + file.write_buffer = write_buffer; + /** + */ + function delete_(path) { + var nm_fs = require("fs"); + return (new Promise(function (resolve, reject) { + nm_fs.unlink(path, function () { + resolve(undefined); + }); + })); + } + file.delete_ = delete_; + })(file = lib_plankton.file || (lib_plankton.file = {})); +})(lib_plankton || (lib_plankton = {})); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type = /** @class */ (function () { + function struct_type() { + } + return struct_type; + }()); + prog.struct_type = struct_type; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_literal = /** @class */ (function (_super) { + __extends(struct_type_literal, _super); + function struct_type_literal(value) { + var _this = _super.call(this) || this; + _this.value = value; + return _this; + } + return struct_type_literal; + }(prog.struct_type)); + prog.struct_type_literal = struct_type_literal; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_any = /** @class */ (function (_super) { + __extends(struct_type_any, _super); + function struct_type_any() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_any; + }(prog.struct_type)); + prog.struct_type_any = struct_type_any; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_void = /** @class */ (function (_super) { + __extends(struct_type_void, _super); + function struct_type_void() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_void; + }(prog.struct_type)); + prog.struct_type_void = struct_type_void; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_boolean = /** @class */ (function (_super) { + __extends(struct_type_boolean, _super); + function struct_type_boolean() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_boolean; + }(prog.struct_type)); + prog.struct_type_boolean = struct_type_boolean; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_integer = /** @class */ (function (_super) { + __extends(struct_type_integer, _super); + function struct_type_integer() { + return _super.call(this) || this; + } + return struct_type_integer; + }(prog.struct_type)); + prog.struct_type_integer = struct_type_integer; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_string = /** @class */ (function (_super) { + __extends(struct_type_string, _super); + function struct_type_string() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_string; + }(prog.struct_type)); + prog.struct_type_string = struct_type_string; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_list = /** @class */ (function (_super) { + __extends(struct_type_list, _super); + function struct_type_list(element) { + var _this = _super.call(this) || this; + _this.element = element; + return _this; + } + return struct_type_list; + }(prog.struct_type)); + prog.struct_type_list = struct_type_list; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_map = /** @class */ (function (_super) { + __extends(struct_type_map, _super); + function struct_type_map(key, value) { + var _this = _super.call(this) || this; + _this.key = key; + _this.value = value; + return _this; + } + return struct_type_map; + }(prog.struct_type)); + prog.struct_type_map = struct_type_map; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_record = /** @class */ (function (_super) { + __extends(struct_type_record, _super); + function struct_type_record(fields) { + var _this = _super.call(this) || this; + _this.fields = fields; + return _this; + } + return struct_type_record; + }(prog.struct_type)); + prog.struct_type_record = struct_type_record; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_function = /** @class */ (function (_super) { + __extends(struct_type_function, _super); + function struct_type_function() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_function; + }(prog.struct_type)); + prog.struct_type_function = struct_type_function; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_construction = /** @class */ (function (_super) { + __extends(struct_type_construction, _super); + function struct_type_construction(name, arguments_) { + var _this = _super.call(this) || this; + _this.name = name; + _this.arguments = arguments_; + return _this; + } + return struct_type_construction; + }(prog.struct_type)); + prog.struct_type_construction = struct_type_construction; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_union = /** @class */ (function (_super) { + __extends(struct_type_union, _super); + function struct_type_union(left, right) { + var _this = _super.call(this) || this; + _this.left = left; + _this.right = right; + return _this; + } + return struct_type_union; + }(prog.struct_type)); + prog.struct_type_union = struct_type_union; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_type_intersection = /** @class */ (function (_super) { + __extends(struct_type_intersection, _super); + function struct_type_intersection() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_intersection; + }(prog.struct_type)); + prog.struct_type_intersection = struct_type_intersection; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression = /** @class */ (function () { + function struct_expression() { + } + return struct_expression; + }()); + prog.struct_expression = struct_expression; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_variable = /** @class */ (function (_super) { + __extends(struct_expression_variable, _super); + function struct_expression_variable(name) { + var _this = _super.call(this) || this; + _this.name = name; + return _this; + } + return struct_expression_variable; + }(prog.struct_expression)); + prog.struct_expression_variable = struct_expression_variable; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_literal = /** @class */ (function (_super) { + __extends(struct_expression_literal, _super); + function struct_expression_literal(value) { + var _this = _super.call(this) || this; + _this.value = value; + return _this; + } + return struct_expression_literal; + }(prog.struct_expression)); + prog.struct_expression_literal = struct_expression_literal; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_list = /** @class */ (function (_super) { + __extends(struct_expression_list, _super); + function struct_expression_list(elements) { + var _this = _super.call(this) || this; + _this.elements = elements; + return _this; + } + return struct_expression_list; + }(prog.struct_expression)); + prog.struct_expression_list = struct_expression_list; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_dict = /** @class */ (function (_super) { + __extends(struct_expression_dict, _super); + function struct_expression_dict(fields) { + var _this = _super.call(this) || this; + _this.fields = fields; + return _this; + } + return struct_expression_dict; + }(prog.struct_expression)); + prog.struct_expression_dict = struct_expression_dict; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_abstraction = /** @class */ (function (_super) { + __extends(struct_expression_abstraction, _super); + function struct_expression_abstraction(arguments_, output_type, body, options) { + if (options === void 0) { options = {}; } + var _this = this; + options = Object.assign({ + "async": false + }, options); + _this = _super.call(this) || this; + _this.arguments = arguments_; + _this.output_type = output_type; + _this.body = body; + _this.async_ = options.async; + return _this; + } + return struct_expression_abstraction; + }(prog.struct_expression)); + prog.struct_expression_abstraction = struct_expression_abstraction; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + * @todo rename to function_call + */ + var struct_expression_function_application = /** @class */ (function (_super) { + __extends(struct_expression_function_application, _super); + function struct_expression_function_application(head, arguments_) { + var _this = _super.call(this) || this; + _this.head = head; + _this.arguments = arguments_; + return _this; + } + return struct_expression_function_application; + }(prog.struct_expression)); + prog.struct_expression_function_application = struct_expression_function_application; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_projection = /** @class */ (function (_super) { + __extends(struct_expression_projection, _super); + function struct_expression_projection(source, index) { + var _this = _super.call(this) || this; + _this.source = source; + _this.index = index; + return _this; + } + return struct_expression_projection; + }(prog.struct_expression)); + prog.struct_expression_projection = struct_expression_projection; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_fieldaccess = /** @class */ (function (_super) { + __extends(struct_expression_fieldaccess, _super); + function struct_expression_fieldaccess(structure, fieldname) { + var _this = _super.call(this) || this; + _this.structure = structure; + _this.fieldname = fieldname; + return _this; + } + return struct_expression_fieldaccess; + }(prog.struct_expression)); + prog.struct_expression_fieldaccess = struct_expression_fieldaccess; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_operation_comparison = /** @class */ (function (_super) { + __extends(struct_expression_operation_comparison, _super); + function struct_expression_operation_comparison(left, right) { + var _this = _super.call(this) || this; + _this.left = left; + _this.right = right; + return _this; + } + return struct_expression_operation_comparison; + }(prog.struct_expression)); + prog.struct_expression_operation_comparison = struct_expression_operation_comparison; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_await = /** @class */ (function (_super) { + __extends(struct_expression_await, _super); + function struct_expression_await(target) { + var _this = _super.call(this) || this; + _this.target = target; + return _this; + } + return struct_expression_await; + }(prog.struct_expression)); + prog.struct_expression_await = struct_expression_await; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_cast = /** @class */ (function (_super) { + __extends(struct_expression_cast, _super); + function struct_expression_cast(expression, type) { + var _this = _super.call(this) || this; + _this.expression = expression; + _this.type = type; + return _this; + } + return struct_expression_cast; + }(prog.struct_expression)); + prog.struct_expression_cast = struct_expression_cast; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement = /** @class */ (function () { + function struct_statement() { + } + return struct_statement; + }()); + prog.struct_statement = struct_statement; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_comment = /** @class */ (function (_super) { + __extends(struct_statement_comment, _super); + function struct_statement_comment(block, lines) { + var _this = _super.call(this) || this; + _this.block = block; + _this.lines = lines; + return _this; + } + return struct_statement_comment; + }(prog.struct_statement)); + prog.struct_statement_comment = struct_statement_comment; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_block = /** @class */ (function (_super) { + __extends(struct_statement_block, _super); + function struct_statement_block(statements) { + var _this = _super.call(this) || this; + _this.statements = statements; + return _this; + } + return struct_statement_block; + }(prog.struct_statement)); + prog.struct_statement_block = struct_statement_block; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_type_definition = /** @class */ (function (_super) { + __extends(struct_statement_type_definition, _super); + function struct_statement_type_definition(name, type, options) { + if (options === void 0) { options = {}; } + var _this = this; + options = Object.assign({ + "export": false, + }, options); + _this = _super.call(this) || this; + _this.name = name; + _this.type = type; + _this.export_ = options.export; + return _this; + } + return struct_statement_type_definition; + }(prog.struct_statement)); + prog.struct_statement_type_definition = struct_statement_type_definition; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_declaration = /** @class */ (function (_super) { + __extends(struct_statement_declaration, _super); + function struct_statement_declaration(constant, name, type, value, options) { + if (options === void 0) { options = {}; } + var _this = this; + options = Object.assign({ + "export": false, + }, options); + _this = _super.call(this) || this; + _this.constant = constant; + _this.name = name; + _this.type = type; + _this.value = value; + _this.export_ = options.export; + return _this; + } + return struct_statement_declaration; + }(prog.struct_statement)); + prog.struct_statement_declaration = struct_statement_declaration; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_assignment = /** @class */ (function (_super) { + __extends(struct_statement_assignment, _super); + function struct_statement_assignment(name, value) { + var _this = _super.call(this) || this; + _this.name = name; + _this.value = value; + return _this; + } + return struct_statement_assignment; + }(prog.struct_statement)); + prog.struct_statement_assignment = struct_statement_assignment; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_procedure_call = /** @class */ (function (_super) { + __extends(struct_statement_procedure_call, _super); + function struct_statement_procedure_call(head, arguments_) { + var _this = _super.call(this) || this; + _this.head = head; + _this.arguments = arguments_; + return _this; + } + return struct_statement_procedure_call; + }(prog.struct_statement)); + prog.struct_statement_procedure_call = struct_statement_procedure_call; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_function_definition = /** @class */ (function (_super) { + __extends(struct_statement_function_definition, _super); + function struct_statement_function_definition(name, arguments_, output_type, body, options) { + if (options === void 0) { options = {}; } + var _this = this; + options = Object.assign({ + "async": false + }, options); + _this = _super.call(this) || this; + _this.name = name; + _this.arguments = arguments_; + _this.output_type = output_type; + _this.body = body; + _this.async_ = options.async; + return _this; + } + return struct_statement_function_definition; + }(prog.struct_statement)); + prog.struct_statement_function_definition = struct_statement_function_definition; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_return = /** @class */ (function (_super) { + __extends(struct_statement_return, _super); + function struct_statement_return(expression) { + var _this = _super.call(this) || this; + _this.expression = expression; + return _this; + } + return struct_statement_return; + }(prog.struct_statement)); + prog.struct_statement_return = struct_statement_return; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_program = /** @class */ (function () { + function struct_program(statements) { + this.statements = statements; + } + return struct_program; + }()); + prog.struct_program = struct_program; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« 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. + +»bacterio-plankton:prog« 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 »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + var typescript; + (function (typescript) { + /** + */ + function indentation(active, level) { + return (active + ? "\t".repeat(level) + : ""); + } + /** + */ + function render_type(type, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "indent": true, + "level": 0, + }, options); + if (type instanceof prog.struct_type_literal) { + var type_literal = type; + return lib_plankton.string.coin("{{indentation}}{{value}}", { + "indentation": indentation(options.indent, options.level), + "value": render_expression(type_literal.value, { + "level": (options.level + 1), + }), + }); + } + else if (type instanceof prog.struct_type_any) { + var type_any = type; + return lib_plankton.string.coin("{{indentation}}any", { + "indentation": indentation(options.indent, options.level), + }); + } + else if (type instanceof prog.struct_type_void) { + var type_void = type; + return lib_plankton.string.coin("{{indentation}}void", { + "indentation": indentation(options.indent, options.level), + }); + } + else if (type instanceof prog.struct_type_boolean) { + var type_boolean = type; + return lib_plankton.string.coin("{{indentation}}boolean", { + "indentation": indentation(options.indent, options.level), + }); + } + else if (type instanceof prog.struct_type_integer) { + var type_integer = type; + return lib_plankton.string.coin("{{indentation}}number", { + "indentation": indentation(options.indent, options.level), + }); + } + else if (type instanceof prog.struct_type_string) { + var type_string = type; + return lib_plankton.string.coin("{{indentation}}string", { + "indentation": indentation(options.indent, options.level), + }); + } + else if (type instanceof prog.struct_type_list) { + var type_list = type; + return render_type(new prog.struct_type_construction("Array", [ + type_list.element, + ])); + } + else if (type instanceof prog.struct_type_map) { + var type_map = type; + return render_type(new prog.struct_type_construction("Record", [ + type_map.key, + type_map.value, + ])); + } + else if (type instanceof prog.struct_type_record) { + var type_record = type; + return lib_plankton.string.coin("{{indentation1}}{\n{{fields}}\n{{indentation2}}}", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "fields": (type_record.fields + .map(function (field) { return lib_plankton.string.coin("{{indentation}}{{name}} {{assignment}} {{type}}", { + "indentation": indentation(true, options.level + 1), + "name": field.name, + "assignment": (field.mandatory ? ":" : "?:"), + "type": render_type(field.type, { + "indent": false, + "level": (options.level + 1), + }), + }); }) + .join(";\n")), + }); + } + else if (type instanceof prog.struct_type_function) { + var type_function = type; + return lib_plankton.string.coin("{{indentation1}}(({{arguments}})\n{{indentation2}}=>\n{{target}})", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "arguments": (type_function.arguments + .map(function (argument) { return render_type(argument, { + "level": (options.level + 1), + }); }) + .join(", ")), + "target": render_type(type_function.target, { + "level": (options.level + 1), + }), + }); + } + else if (type instanceof prog.struct_type_construction) { + var type_construction = type; + return lib_plankton.string.coin("{{indentation}}{{name}}{{macro_arguments}}", { + "indentation": indentation(options.indent, options.level), + "name": type_construction.name, + "macro_arguments": ((type_construction.arguments === null) + ? "" + : lib_plankton.string.coin("<\n{{arguments}}\n{{indentation}}>", { + "indentation": indentation(true, options.level), + "arguments": (type_construction.arguments + .map(function (argument) { return render_type(argument, { + "level": (options.level + 1), + }); }) + .join(",\n")), + })), + }); + } + else if (type instanceof prog.struct_type_union) { + var type_union = type; + return lib_plankton.string.coin("{{indentation1}}(\n{{left}}\n{{indentation3}}|\n{{right}}\n{{indentation2}})", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "indentation3": indentation(true, options.level + 1), + "left": render_type(type_union.left, { + "level": (options.level + 1), + }), + "right": render_type(type_union.right, { + "level": (options.level + 1), + }), + }); + } + else if (type instanceof prog.struct_type_intersection) { + var type_intersection = type; + return lib_plankton.string.coin("{{indentation1}}(\n{{left}}\n{{indentation2}}&\n{{right}}\n{{indentation2}})", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level + 1), + "left": render_type(type_intersection.left, { + "level": (options.level + 1), + }), + "right": render_type(type_intersection.right, { + "level": (options.level + 1), + }), + }); + } + else { + throw (new Error("unhandled type kind: " + String(type))); + } + } + typescript.render_type = render_type; + /** + */ + function render_expression(expression, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "indent": false, + "level": 0, + }, options); + if (expression instanceof prog.struct_expression_variable) { + var expression_variable = expression; + return lib_plankton.string.coin("{{indentation}}{{name}}", { + "indentation": indentation(options.indent, options.level), + "name": expression.name, + }); + } + else if (expression instanceof prog.struct_expression_literal) { + var expression_literal = expression; + return lib_plankton.string.coin("{{indentation}}{{value}}", { + "indentation": indentation(options.indent, options.level), + "value": JSON.stringify(expression_literal.value), + }); + } + else if (expression instanceof prog.struct_expression_list) { + var expression_list = expression; + return lib_plankton.string.coin("{{indentation1}}[\n{{elements}}\n{{indentation2}}]", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "elements": (expression_list.elements + .map(function (element) { return lib_plankton.string.coin("{{indentation}}{{value}}", { + "indentation": indentation(true, options.level + 1), + "value": render_expression(element, { + "indent": false, + "level": (options.level + 1), + }), + }); }) + .join(",\n")), + }); + } + else if (expression instanceof prog.struct_expression_dict) { + var expression_dict = expression; + return lib_plankton.string.coin("{{indentation1}}{\n{{fields}}\n{{indentation2}}}", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "fields": (expression_dict.fields + .map(function (field) { return lib_plankton.string.coin("{{indentation}}\"{{key}}\": {{value}}", { + "indentation": indentation(true, options.level + 1), + "key": field.key, + "value": render_expression(field.value, { + "indent": false, + "level": (options.level + 1), + }), + }); }) + .join(",\n")), + }); + } + else if (expression instanceof prog.struct_expression_abstraction) { + var expression_abstraction = expression; + return lib_plankton.string.coin("{{indentation1}}{{macro_async}}function ({{arguments}}){{macro_output_type}} {\n{{body}}{{indentation2}}}", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "macro_async": (expression_abstraction.async_ + ? "async " + : ""), + "arguments": (expression_abstraction.arguments + .map(function (argument) { return lib_plankton.string.coin("{{name}}{{macro_type}}", { + "name": argument.name, + "macro_type": ((argument.type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(argument.type) + })), + }); }) + .join(", ")), + "macro_output_type": ((expression_abstraction.output_type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(expression_abstraction.output_type, { + "indent": false, + "level": (options.level + 1), + }) + })), + "body": (expression_abstraction.body + .map(function (statement) { return render_statement(statement, { + "level": (options.level + 1), + }); }) + .join("")), + }); + } + else if (expression instanceof prog.struct_expression_function_application) { + var expression_function_application = expression; + return lib_plankton.string.coin("{{indentation1}}{{name}}(\n{{arguments}}\n{{indentation2}})", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "name": render_expression(expression_function_application.head, { + "indent": false, + "level": (options.level + 0), + }), + "arguments": (expression_function_application.arguments + .map(function (argument) { return lib_plankton.string.coin("{{argument}}", { + "argument": render_expression(argument, { + "indent": true, + "level": (options.level + 1), + }), + }); }) + .join(",\n")), + }); + } + else if (expression instanceof prog.struct_expression_projection) { + var expression_projection = expression; + return lib_plankton.string.coin("{{indentation}}{{source}}[{{index}}]", { + "indentation": indentation(options.indent, options.level), + "source": render_expression(expression_projection.source), + "index": render_expression(expression_projection.index), + }); + } + else if (expression instanceof prog.struct_expression_fieldaccess) { + var expression_fieldaccess = expression; + return lib_plankton.string.coin("{{indentation}}{{structure}}.{{fieldname}}", { + "indentation": indentation(options.indent, options.level), + "structure": render_expression(expression_fieldaccess.structure, { + "level": (options.level + 1), + }), + "fieldname": expression_fieldaccess.fieldname, + }); + } + else if (expression instanceof prog.struct_expression_operation_comparison) { + var expression_operation_comparison = expression; + return lib_plankton.string.coin("{{indentation}}({{left}} === {{right}})", { + "indentation": indentation(options.indent, options.level), + "left": render_expression(expression_operation_comparison.left, { + "indent": false, + "level": (options.level + 0), + }), + "right": render_expression(expression_operation_comparison.right, { + "indent": false, + "level": (options.level + 0), + }), + }); + } + else if (expression instanceof prog.struct_expression_await) { + var expression_await = expression; + return lib_plankton.string.coin("{{indentation}}await {{target}}", { + "indentation": indentation(options.indent, options.level), + "target": render_expression(expression_await.target, { + "indent": false, + "level": (options.level + 0), + }), + }); + } + else if (expression instanceof prog.struct_expression_cast) { + var expression_cast = expression; + return lib_plankton.string.coin("{{indentation}}({{expression}} as {{type}})", { + "indentation": indentation(options.indent, options.level), + "expression": render_expression(expression_cast.expression, { + "indent": false, + "level": (options.level + 0), + }), + "type": render_type(expression_cast.type, { + "indent": false, + "level": (options.level + 0), + }), + }); + } + else { + throw (new Error("unhandled expression: " + String(expression))); + } + } + typescript.render_expression = render_expression; + /** + */ + function render_statement(statement, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "indent": true, + "level": 0, + }, options); + if (statement instanceof prog.struct_statement_comment) { + var statement_comment = statement; + return (statement_comment.block + ? lib_plankton.string.coin("{{indentation}}/**\n{{lines}}{{indentation}} */\n", { + "indentation": indentation(options.indent, options.level), + "lines": (statement_comment.lines + .map(function (line) { return lib_plankton.string.coin("{{indentation}} * {{line}}\n", { + "indentation": indentation(options.indent, options.level), + "line": line, + }); }) + .join("")), + }) + : lib_plankton.string.coin("{{lines}}", { + "lines": (statement_comment.lines + .map(function (line) { return lib_plankton.string.coin("{{indentation}}// {{line}}\n", { + "indentation": indentation(options.indent, options.level), + "line": line, + }); }) + .join("")), + })); + } + else if (statement instanceof prog.struct_statement_block) { + var statement_block = statement; + return lib_plankton.string.coin("{{indentation}}{\n{{statements}}{{indentation}}}\n", { + "indentation": indentation(options.indent, options.level), + "statements": (statement_block.statements + .map(function (statement) { return render_statement(statement, { + "level": (options.level + 1), + }); }) + .join("")), + }); + } + else if (statement instanceof prog.struct_statement_type_definition) { + var statement_type_definition = statement; + return lib_plankton.string.coin("{{indentation}}{{macro_export}}type {{name}} = {{type}};\n", { + "indentation": indentation(options.indent, options.level), + "name": statement_type_definition.name, + "macro_export": ((!statement_type_definition.export_) + ? "" + : "export "), + "type": render_type(statement_type_definition.type, { + "indent": false, + "level": (options.level + 0), + }), + }); + } + else if (statement instanceof prog.struct_statement_declaration) { + var statement_declaration = statement; + return lib_plankton.string.coin("{{indentation}}{{macro_export}}{{kind}} {{name}}{{macro_type}}{{macro_value}};\n", { + "indentation": indentation(options.indent, options.level), + "kind": (statement_declaration.constant + ? "const" + : "let"), + "name": statement_declaration.name, + "macro_export": ((!statement_declaration.export_) + ? "" + : "export "), + "macro_type": ((statement_declaration.type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(statement_declaration.type, { + "indent": false, + "level": (options.level + 0), + }), + })), + "macro_value": ((statement_declaration.value === null) + ? "" + : lib_plankton.string.coin(" = {{value}}", { + "value": render_expression(statement_declaration.value, { + "indent": false, + "level": (options.level + 0), + }), + })), + }); + } + else if (statement instanceof prog.struct_statement_assignment) { + var statement_assignment = statement; + return lib_plankton.string.coin("{{indentation}}{{name}} = {{value}};\n", { + "indentation": indentation(options.indent, options.level), + "name": statement_assignment.name, + "value": render_expression(statement_assignment.value, { + "indent": false, + "level": (options.level + 1), + }), + }); + } + else if (statement instanceof prog.struct_statement_procedure_call) { + var statement_procedure_call = statement; + return lib_plankton.string.coin("{{indentation1}}{{name}}(\n{{arguments}}\n{{indentation2}});\n", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "name": render_expression(statement_procedure_call.head, { + "indent": false, + "level": (options.level + 0), + }), + "arguments": (statement_procedure_call.arguments + .map(function (argument) { return lib_plankton.string.coin("{{argument}}", { + "argument": render_expression(argument, { + "indent": true, + "level": (options.level + 1), + }), + }); }) + .join(",\n")), + }); + } + else if (statement instanceof prog.struct_statement_function_definition) { + var statement_function_definition = statement; + return lib_plankton.string.coin("{{indentation1}}{{macro_async}}function {{name}}(\n{{arguments}}\n{{indentation2}}){{macro_output_type}}\n{{indentation2}}{\n{{body}}{{indentation2}}}\n", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "macro_async": (statement_function_definition.async_ + ? "async " + : ""), + "name": statement_function_definition.name, + "arguments": (statement_function_definition.arguments + .map(function (argument) { return lib_plankton.string.coin("{{indentation}}{{name}}{{macro_type}}", { + "indentation": indentation(true, (options.level + 1)), + "name": argument.name, + "macro_type": ((argument.type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(argument.type, { + "indent": false, + "level": (options.level + 2), + }) + })), + }); }) + .join(",\n")), + "macro_output_type": ((statement_function_definition.output_type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(statement_function_definition.output_type, { + "indent": false, + "level": (options.level + 0), + }) + })), + "body": (statement_function_definition.body + .map(function (statement) { return render_statement(statement, { + "indent": true, + "level": (options.level + 1), + }); }) + .join("")), + }); + } + else if (statement instanceof prog.struct_statement_return) { + var statement_return = statement; + return lib_plankton.string.coin("{{indentation}}return {{expression}};\n", { + "indentation": indentation(options.indent, options.level), + "expression": render_expression(statement_return.expression, { + "indent": false, + "level": (options.level + 0), + }), + }); + } + else { + throw (new Error("unhandled statement: " + (statement.constructor.name))); + } + } + typescript.render_statement = render_statement; + /** + */ + function render_program(program) { + return (program.statements + .map(function (statement) { return render_statement(statement, { + "indent": true, + "level": 0, + }); }) + .join("\n")); + } + typescript.render_program = render_program; + /** + */ + function output_typescript() { + return { + "render_expression": render_expression, + "render_type": render_type, + "render_statement": render_statement, + "render_program": render_program, + }; + } + typescript.output_typescript = output_typescript; + })(typescript = prog.typescript || (prog.typescript = {})); + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:args«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:args« 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. + +»bacterio-plankton:args« 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 »bacterio-plankton:args«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var args; + (function (args) { + /** + */ + var enum_environment; + (function (enum_environment) { + enum_environment["cli"] = "cli"; + enum_environment["url"] = "url"; + })(enum_environment = args.enum_environment || (args.enum_environment = {})); + ; + /** + */ + var enum_kind; + (function (enum_kind) { + enum_kind["positional"] = "positional"; + enum_kind["volatile"] = "volatile"; + })(enum_kind = args.enum_kind || (args.enum_kind = {})); + ; + /** + */ + var enum_type; + (function (enum_type) { + enum_type["boolean"] = "boolean"; + enum_type["integer"] = "int"; + enum_type["float"] = "float"; + enum_type["string"] = "string"; + })(enum_type = args.enum_type || (args.enum_type = {})); + ; + /** + */ + var enum_mode; + (function (enum_mode) { + enum_mode["replace"] = "replace"; + enum_mode["accumulate"] = "accumulate"; + })(enum_mode = args.enum_mode || (args.enum_mode = {})); + ; + })(args = lib_plankton.args || (lib_plankton.args = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:args«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:args« 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. + +»bacterio-plankton:args« 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 »bacterio-plankton:args«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var args; + (function (args) { + /* + export enum_mode { + replace = "replace", + accumulate = "accumulate", + }; + */ + /** + * @author fenris + */ + var class_argument = /** @class */ (function () { + /** + * @author fenris + */ + function class_argument(_a) { + var name = _a["name"], _b = _a["type"], type = _b === void 0 ? args.enum_type.string : _b, _c = _a["kind"], kind = _c === void 0 ? args.enum_kind.positional : _c, _d = _a["mode"], mode = _d === void 0 ? args.enum_mode.replace : _d, _e = _a["default"], default_ = _e === void 0 ? null : _e, _f = _a["info"], info = _f === void 0 ? null : _f, _g = _a["parameters"], parameters = _g === void 0 ? {} : _g, _h = _a["hidden"], hidden = _h === void 0 ? false : _h; + this.name = name; + this.type = type; + this.kind = kind; + this.mode = mode; + this.default_ = default_; + this.info = info; + this.parameters = parameters; + this.hidden = hidden; + if (!this.check()) { + throw (new Error("invalid argument-setup")); + } + } + /** + * @author fenris + */ + class_argument.positional = function (_a) { + var name = _a["name"], _b = _a["type"], type = _b === void 0 ? args.enum_type.string : _b, _c = _a["mode"], mode = _c === void 0 ? args.enum_mode.replace : _c, _d = _a["default"], default_ = _d === void 0 ? null : _d, _e = _a["info"], info = _e === void 0 ? null : _e, _f = _a["hidden"], hidden = _f === void 0 ? false : _f, index = _a["index"]; + return (new class_argument({ + "name": name, + "kind": args.enum_kind.positional, + "type": type, + "mode": mode, + "default": default_, + "info": info, + "hidden": hidden, + "parameters": { + "index": index, + }, + })); + }; + /** + * @author fenris + */ + class_argument.volatile = function (_a) { + var name = _a["name"], _b = _a["type"], type = _b === void 0 ? args.enum_type.string : _b, _c = _a["mode"], mode = _c === void 0 ? args.enum_mode.replace : _c, _d = _a["default"], default_ = _d === void 0 ? null : _d, _e = _a["info"], info = _e === void 0 ? null : _e, _f = _a["hidden"], hidden = _f === void 0 ? false : _f, indicators_short = _a["indicators_short"], indicators_long = _a["indicators_long"]; + return (new class_argument({ + "name": name, + "kind": args.enum_kind.volatile, + "type": type, + "mode": mode, + "default": default_, + "info": info, + "hidden": hidden, + "parameters": { + "indicators_short": indicators_short, + "indicators_long": indicators_long, + }, + })); + }; + /** + * @author fenris + */ + class_argument.prototype.check = function () { + var _this = this; + return [ + function () { return ((!(_this.kind == args.enum_kind.volatile)) + || + (("indicators_long" in _this.parameters) + && + (_this.parameters["indicators_long"]["length"] >= 0))); }, + ].every(function (condition) { return condition(); }); + }; + /** + * @author fenris + */ + class_argument.prototype.name_get = function () { + return this.name; + }; + /** + * @author fenris + */ + class_argument.prototype.kind_get = function () { + return this.kind; + }; + /** + * @author fenris + */ + class_argument.prototype.type_get = function () { + return this.type; + }; + /** + * @author fenris + */ + class_argument.prototype.mode_get = function () { + return this.mode; + }; + /** + * @author fenris + */ + class_argument.prototype.default_get = function () { + return this.default_; + }; + /** + * @author fenris + */ + class_argument.prototype.parameters_get = function () { + return this.parameters; + }; + /** + * @author fenris + */ + class_argument.prototype.hidden_get = function () { + return this.hidden; + }; + /** + * @author fenris + */ + class_argument.prototype.toString = function () { + return "<".concat(this.name, ">"); + }; + /** + * @author fenris + */ + class_argument.prototype.indicator_main = function () { + if (this.kind === args.enum_kind.volatile) { + return this.parameters["indicators_long"][0]; + } + else { + return null; + } + }; + /** + * @author fenris + */ + class_argument.prototype.pattern_value = function () { + switch (this.type) { + case args.enum_type.boolean: { + return "false|true"; + break; + } + case args.enum_type.integer: { + return "[0-9]+"; + break; + } + case args.enum_type.float: { + return "\\d*(?:\\.\\d+)?"; + break; + } + case args.enum_type.string: { + return "\\S+"; + break; + } + default: { + throw (new Error("unhandled type ".concat(this.type))); + break; + } + } + }; + /** + * @author fenris + */ + class_argument.prototype.extract = function (raw) { + switch (this.type) { + case args.enum_type.boolean: { + return (raw != "false"); + break; + } + case args.enum_type.integer: { + return parseInt(raw); + break; + } + case args.enum_type.float: { + return parseFloat(raw); + break; + } + case args.enum_type.string: { + return raw; + break; + } + default: { + throw (new Error("unhandled type ".concat(this.type))); + break; + } + } + }; + /** + * @author fenris + */ + class_argument.prototype.assign = function (data, target, raw) { + var value = this.extract(raw); + switch (this.mode) { + case args.enum_mode.replace: { + data[target] = value; + break; + } + case args.enum_mode.accumulate: { + /* + if (! (this.name in data)) { + data[this.name] = []; + } + */ + data[target].push(value); + break; + } + default: { + throw (new Error("unhandled mode ".concat(this.mode))); + } + } + }; + /** + * @author fenris + */ + class_argument.prototype.make = function (data, target) { + var value = data[target]; + return value.toString(); + }; + /** + * @author fenris + */ + class_argument.prototype.generate_help = function () { + var _this = this; + var _a, _b, _c, _d; + var output = ""; + { + switch (this.kind) { + case args.enum_kind.positional: { + var line = ""; + line += "\t"; + line += "<".concat(this.name, ">"); + line += "\n"; + output += line; + } + case args.enum_kind.volatile: { + var line = ""; + line += "\t"; + if (this.type === args.enum_type.boolean) { + line += ([] + .concat(((_a = this.parameters["indicators_short"]) !== null && _a !== void 0 ? _a : []).map(function (indicator) { return ("-" + indicator); })) + .concat(((_b = this.parameters["indicators_long"]) !== null && _b !== void 0 ? _b : []).map(function (indicator) { return ("--" + indicator); })) + .join(" | ")); + } + else { + line += ([] + .concat(((_c = this.parameters["indicators_short"]) !== null && _c !== void 0 ? _c : []).map(function (indicator) { return ("-" + indicator + " " + ("<" + _this.name + ">")); })) + .concat(((_d = this.parameters["indicators_long"]) !== null && _d !== void 0 ? _d : []).map(function (indicator) { return ("--" + indicator + "=" + ("<" + _this.name + ">")); })) + .join(" | ")); + } + line += "\n"; + output += line; + } + } + } + { + var line = ""; + line += "\t\t"; + var infotext = ((this.info == null) ? "(no info available)" : this.info); + line += infotext; + if ((this.type != "boolean") && (this.default_ != null)) { + line += "; default: ".concat(this.default_.toString()); + } + line += "\n"; + output += line; + } + return output; + }; + return class_argument; + }()); + args.class_argument = class_argument; + })(args = lib_plankton.args || (lib_plankton.args = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:args«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:args« 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. + +»bacterio-plankton:args« 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 »bacterio-plankton:args«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var args; + (function (args) { + /** + * @author fenris + */ + var settings = { + "environment": { + "cli": { + "symbols": { + "delimiter": " ", + "prefix": "--", + "assignment": "=", + }, + }, + "url": { + "symbols": { + "delimiter": "&", + "prefix": "", + "assignment": "=", + } + } + }, + }; + /** + * @author fenris + */ + args.verbosity = 0; + /** + * @author fenris + * @todo check validity + */ + var class_handler = /** @class */ (function () { + /** + * @author fenris + */ + function class_handler(arguments_) { + this.arguments_ = arguments_; + } + /** + * @author fenris + */ + class_handler.prototype.filter = function (kind) { + var arguments_ = {}; + for (var _i = 0, _a = Object.entries(this.arguments_); _i < _a.length; _i++) { + var _b = _a[_i], name = _b[0], argument = _b[1]; + if (argument.kind_get() == kind) { + arguments_[name] = argument; + } + } + return arguments_; + }; + /** + * @author fenris + */ + class_handler.prototype.read = function (environment, input, data) { + var _this = this; + if (data === void 0) { data = {}; } + switch (environment) { + case args.enum_environment.cli: + case args.enum_environment.url: { + // default values + { + for (var _i = 0, _a = Object.entries(this.arguments_); _i < _a.length; _i++) { + var _b = _a[_i], name = _b[0], argument = _b[1]; + data[name] = argument.default_get(); + } + } + // preprocessing + { + // short indicators (lil hacky ...) + { + if (environment == args.enum_environment.cli) { + for (var _c = 0, _d = Object.entries(this.filter(args.enum_kind.volatile)); _c < _d.length; _c++) { + var _e = _d[_c], name = _e[0], argument = _e[1]; + // console.info(argument.parameters_get()["indicators_short"].join("|")); + var pattern_from = ""; + { + pattern_from += "(?:^|".concat(settings["environment"][environment]["symbols"]["delimiter"], ")"); + pattern_from += "-".concat(argument.parameters_get()["indicators_short"].join("|")); + pattern_from += "(?:$|".concat(settings["environment"][environment]["symbols"]["delimiter"], ")"); + } + var pattern_to = ""; + { + pattern_to += settings["environment"][environment]["symbols"]["delimiter"]; + pattern_to += settings["environment"][environment]["symbols"]["prefix"]; + pattern_to += argument.indicator_main(); + if (argument.type_get() == args.enum_type.boolean) { + pattern_to += settings["environment"][environment]["symbols"]["delimiter"]; + } + else { + pattern_to += settings["environment"][environment]["symbols"]["assignment"]; + } + } + var result = input.replace(new RegExp(pattern_from, "g"), pattern_to); + lib_plankton.log.debug("lib_args:read:replacing", { + "pattern_from": pattern_from, + "pattern_to": pattern_to, + "input": input, + "result": result, + }); + input = result; + } + } + } + lib_plankton.log.debug("lib_args:read:current_input", { + "input": input, + }); + } + // parsing + { + var parts = input + .split(settings["environment"][environment]["symbols"]["delimiter"]) + .filter(function (x) { return (x != ""); }); + var index_expected_1 = 0; + parts.forEach(function (part) { + lib_plankton.log.debug("lib_args:read:analyzing", { + "part": part, + }); + var found = [ + function () { + lib_plankton.log.debug("lib_args:read:probing_as_volatile", { + "part": part, + }); + for (var _i = 0, _a = Object.entries(_this.filter(args.enum_kind.volatile)); _i < _a.length; _i++) { + var _b = _a[_i], name = _b[0], argument = _b[1]; + lib_plankton.log.debug("lib_args:read:probing_as_volatile:trying", { + "part": part, + "argument": argument.toString(), + }); + var pattern = ""; + { + var pattern_front = ""; + pattern_front += "".concat(settings["environment"][environment]["symbols"]["prefix"]); + pattern_front += "(?:".concat(argument.parameters_get()["indicators_long"].join("|"), ")"); + pattern += pattern_front; + } + { + var pattern_back = ""; + pattern_back += "".concat(settings["environment"][environment]["symbols"]["assignment"]); + pattern_back += "(".concat(argument.pattern_value(), ")"); + if (argument.type_get() == args.enum_type.boolean) { + pattern_back = "(?:".concat(pattern_back, ")?"); + } + pattern += pattern_back; + } + lib_plankton.log.debug("lib_args:read:probing_as_volatile:pattern", { + "pattern": pattern, + }); + var regexp = new RegExp(pattern); + var matching = regexp.exec(part); + lib_plankton.log.debug("lib_args:read:probing_as_volatile:matching", { + "matching": matching, + }); + if (matching == null) { + // do nothing + } + else { + argument.assign(data, name, matching[1]); + return true; + } + } + return false; + }, + function () { + lib_plankton.log.debug("lib_args:read:probing_as_positional", { + "part": part, + }); + var positional = _this.filter(args.enum_kind.positional); + for (var _i = 0, _a = Object.entries(positional); _i < _a.length; _i++) { + var _b = _a[_i], name = _b[0], argument = _b[1]; + if (argument.parameters_get()['index'] !== index_expected_1) { + // do nothing + } + else { + lib_plankton.log.debug("lib_args:read:probing_as_positional:trying", { + "part": part, + "argument": argument.toString(), + }); + var pattern = ""; + { + var pattern_back = ""; + pattern_back += "(".concat(argument.pattern_value(), ")"); + pattern += pattern_back; + } + lib_plankton.log.debug("lib_args:read:probing_as_positional:pattern", { + "pattern": pattern, + }); + var regexp = new RegExp(pattern); + var matching = regexp.exec(part); + lib_plankton.log.debug("lib_args:read:probing_as_positional:matching", { + "matching": matching, + }); + if (matching == null) { + return false; + } + else { + argument.assign(data, name, matching[1]); + index_expected_1 += 1; + return true; + } + } + } + return false; + }, + ].some(function (x) { return x(); }); + if (!found) { + lib_plankton.log.warning("lib_args:read:could_not_parse", { + "part": part, + }); + } + }); + } + return data; + break; + } + default: { + throw (new Error("unhandled environment ".concat(environment))); + break; + } + } + }; + /** + * @author fenris + * @todo handle if the data object doesn't have the required field or the type is wrong or sth. + */ + class_handler.prototype.write = function (environment, data) { + switch (environment) { + case args.enum_environment.cli: { + return (([] + .concat(Object.entries(this.filter(args.enum_kind.volatile)).map(function (_a) { + var name = _a[0], argument = _a[1]; + var values; + switch (argument.mode_get()) { + case args.enum_mode.replace: { + values = [data[argument.name_get()]]; + break; + } + case args.enum_mode.accumulate: { + values = data[argument.name_get()]; + break; + } + } + return (values + .map(function (value) { return ((settings["environment"][environment]["symbols"]["prefix"] + + + argument.parameters_get()["indicators_long"][0]) + + + (settings["environment"][environment]["symbols"]["assignment"] + + + value.toString())); }) + .join(" ")); + })) + .concat(Object.entries(this.filter(args.enum_kind.positional)).map(function (_a) { + var name = _a[0], argument = _a[1]; + var raw = ""; + { + var raw_back = ""; + raw_back += argument.make(data, name); + raw += raw_back; + } + return raw; + }))) + .join(settings["environment"][environment]["symbols"]["delimiter"])); + break; + } + default: { + throw (new Error("unhandled environment ".concat(environment))); + break; + } + } + }; + /** + * @desc manpage-like info-sheet + * @author fenris + */ + class_handler.prototype.generate_help = function (_a) { + var _b = _a["programname"], programname = _b === void 0 ? null : _b, _c = _a["author"], author = _c === void 0 ? null : _c, _d = _a["description"], description = _d === void 0 ? null : _d, _e = _a["executable"], executable = _e === void 0 ? null : _e; + var environment = args.enum_environment.cli; + var output = ""; + { + var section = ""; + { + var line = ""; + line += ""; + line += "INFO"; + line += "\n"; + section += line; + } + { + var line = ""; + line += "\t"; + line += "".concat(programname, " -- ").concat(description); + line += "\n"; + section += line; + } + section += "\n"; + output += section; + } + { + if (author != null) { + var section = ""; + { + var line = ""; + line += ""; + line += "AUTHOR"; + line += "\n"; + section += line; + } + { + var line = ""; + line += "\t"; + line += "".concat(author); + line += "\n"; + section += line; + } + section += "\n"; + output += section; + } + } + { + var section = ""; + { + var line = ""; + line += ""; + line += "SYNOPSIS"; + line += "\n"; + section += line; + } + { + var line = ""; + line += "\t"; + line += executable; + line += settings["environment"][environment]["symbols"]["delimiter"]; + line += Object.entries(this.filter(args.enum_kind.positional)) + .map(function (_a) { + var name = _a[0], argument = _a[1]; + var part = ""; + part += "<".concat(argument.name_get(), ">"); + return part; + }) + .join(settings["environment"][environment]["symbols"]["delimiter"]); + line += settings["environment"][environment]["symbols"]["delimiter"]; + line += Object.entries(this.filter(args.enum_kind.volatile)) + .filter(function (_a) { + var name = _a[0], argument = _a[1]; + return (!argument.hidden_get()); + }) + .map(function (_a) { + var name = _a[0], argument = _a[1]; + var part = ""; + // part += settings["environment"][environment]["symbols"]["prefix"]; + part += "-"; + part += argument.parameters_get()["indicators_short"][0]; + if (argument.type_get() != "boolean") { + /* + part += settings["environment"][environment]["symbols"]["assignment"]; + part += `<${argument.name_get()}>`; + */ + part += " "; + part += "<".concat(argument.name_get(), ">"); + } + part = "[".concat(part, "]"); + return part; + }) + .join(settings["environment"][environment]["symbols"]["delimiter"]); + line += "\n"; + section += line; + } + section += "\n"; + output += section; + } + { + var section = ""; + { + var line = ""; + line += ""; + line += "OPTIONS"; + line += "\n"; + section += line; + } + { + section += (Object.entries(this.arguments_) + .filter(function (_a) { + var name = _a[0], argument = _a[1]; + return (!argument.hidden_get()); + }) + .map(function (_a) { + var name = _a[0], argument = _a[1]; + return argument.generate_help(); + }) + .join("\n")); + } + section += "\n"; + output += section; + } + return output; + }; + return class_handler; + }()); + args.class_handler = class_handler; + })(args = lib_plankton.args || (lib_plankton.args = {})); +})(lib_plankton || (lib_plankton = {})); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var _sindri; +(function (_sindri) { + /** + */ + let enum_realm; + (function (enum_realm) { + enum_realm["database"] = "database"; + enum_realm["backend"] = "backend"; + enum_realm["frontend"] = "frontend"; + enum_realm["other"] = "other"; + })(enum_realm = _sindri.enum_realm || (_sindri.enum_realm = {})); + /** + */ + var _outputs = { + [enum_realm.database]: {}, + [enum_realm.backend]: {}, + [enum_realm.frontend]: {}, + [enum_realm.other]: {}, + }; + /** + */ + function add_output(realm, implementation, output) { + _outputs[realm][implementation] = output; + } + _sindri.add_output = add_output; + /** + */ + function get_output(realm, implementation) { + return _outputs[realm][implementation]; + } + _sindri.get_output = get_output; + /** + */ + function list_outputs() { + return (Object.entries(_outputs) + .map(([realm, group]) => (Object.keys(group) + .map(implementation => ({ "realm": realm, "implementation": implementation })))) + .reduce((x, y) => x.concat(y), [])); + } + _sindri.list_outputs = list_outputs; + /** + */ + function get_template(realm, implementation, name) { + return lib_plankton.file.read([__dirname, "templates", realm, implementation, name].join("/")); + } + _sindri.get_template = get_template; +})(_sindri || (_sindri = {})); +var _sindri; +(function (_sindri) { + var outputs; + (function (outputs) { + var other; + (function (other) { + var jsonschema; + (function (jsonschema) { + /** + */ + function render(input_data) { + return lib_plankton.json.encode(Object.fromEntries(input_data.domains.map(domain => { + var _a; + return ([ + domain.name, + { + "type": ["array"], + "items": { + "type": ["object"], + "additionalProperties": false, + "properties": Object.fromEntries([] + .concat((domain.key_field === null) + ? [] + : [ + [ + domain.key_field.name, + { + "type": ["integer"], + "description": ((_a = domain.key_field.description) !== null && _a !== void 0 ? _a : undefined), + } + ] + ]) + .concat(domain.data_fields + .map(data_field => { + var _a; + return ([ + data_field.name, + { + "type": ([] + .concat(data_field.nullable + ? ["null"] + : []) + .concat([ + { + "boolean": "boolean", + "integer": "integer", + "float": "number", + "string_short": "string", + "string_medium": "string", + "string_long": "string", + }[data_field.type] + ])), + "description": ((_a = data_field.description) !== null && _a !== void 0 ? _a : undefined), + } + ]); + }))), + "required": ([] + .concat((domain.key_field === null) + ? [] + : [domain.key_field.name]) + .concat(domain.data_fields + .map(data_field => data_field.name))) + }, + } + ]); + })), true); + } + jsonschema.render = render; + })(jsonschema = other.jsonschema || (other.jsonschema = {})); + })(other = outputs.other || (outputs.other = {})); + })(outputs = _sindri.outputs || (_sindri.outputs = {})); +})(_sindri || (_sindri = {})); +/** + */ +_sindri.add_output(_sindri.enum_realm.other, "jsonschema", { + "render": (x) => Promise.resolve(_sindri.outputs.backend.typescript.render(x)), +}); +var _sindri; +(function (_sindri) { + var outputs; + (function (outputs) { + var database; + (function (database) { + var sqlite; + (function (sqlite) { + /** + */ + function value_encode(value) { + if (value === null) { + return "NULL"; + } + else { + switch (typeof (value)) { + case "boolean": { + return (value ? "TRUE" : "FALSE"); + break; + } + case "number": { + return value.toString(); + break; + } + case "string": { + return ("'" + value + "'"); + break; + } + default: { + throw (new Error("unhandled")); + break; + } + } + } + } + /** + */ + function render(input_data) { + return (input_data["domains"] + .map((domain) => lib_plankton.string.coin("CREATE TABLE\n\t`{{name}}`(\n{{entries}}\n\t)\n;", { + "name": domain.name, + "entries": (([] + // key field + .concat((domain.key_field === null) + ? [] + : lib_plankton.string.coin("`{{name}}` {{parameters}}", { + "name": domain.key_field.name, + "parameters": ([ + "INTEGER", + "PRIMARY KEY", + "AUTOINCREMENT", + ] + .join(" ")), + })) + // data fields + .concat(domain.data_fields + .map((data_field) => lib_plankton.string.coin("`{{name}}` {{parameters}}", { + "name": data_field.name, + "parameters": (( + // type + [ + { + "boolean": "BOOLEAN", + "integer": "INTEGER", + "string_short": "VARCHAR(63)", + "string_medium": "VARCHAR(255)", + "string_long": "TEXT", + }[data_field.type], + ] + // nullability + .concat(data_field.nullable + ? [] + : ["NOT NULL"]) + // default + .concat((data_field.default === undefined) + ? [] + : [ + lib_plankton.string.coin("DEFAULT {{value}}", { + "value": value_encode(data_field.default), + }), + ])) + .join(" ")) + }))) + // constraints + .concat(domain.constraints + .map((constraint) => { + switch (constraint.kind) { + default: { + throw (new Error("unhandled constraint kind: " + constraint.kind)); + break; + } + case "foreign_key": { + return lib_plankton.string.coin("FOREIGN KEY ({{fields}}) REFERENCES `{{reference_name}}`({{reference_fields}})", { + "fields": (constraint.parameters["fields"] + .map(x => ('`' + x + '`')) + .join(",")), + "reference_name": constraint.parameters["reference"]["name"], + "reference_fields": (constraint.parameters["reference"]["fields"] + .map(x => ('`' + x + '`')) + .join(",")), + }); + break; + } + case "unique": { + return lib_plankton.string.coin("UNIQUE ({{fields}})", { + "fields": (constraint.parameters["fields"] + .map(x => ('`' + x + '`')) + .join(",")), + }); + break; + } + } + }))) + .map(x => ("\t\t" + x)) + .join(",\n")), + })) + .map(x => (x + "\n")) + .join("\n")); + } + sqlite.render = render; + })(sqlite = database.sqlite || (database.sqlite = {})); + })(database = outputs.database || (outputs.database = {})); + })(outputs = _sindri.outputs || (_sindri.outputs = {})); +})(_sindri || (_sindri = {})); +_sindri.add_output(_sindri.enum_realm.database, "sqlite", { + "render": (x) => Promise.resolve(_sindri.outputs.database.sqlite.render(x)), +}); +var _sindri; +(function (_sindri) { + var outputs; + (function (outputs) { + var database; + (function (database) { + var mysql; + (function (mysql) { + /** + */ + function value_encode(value) { + if (value === null) { + return "NULL"; + } + else { + switch (typeof (value)) { + case "boolean": { + return (value ? "TRUE" : "FALSE"); + break; + } + case "number": { + return value.toString(); + break; + } + case "string": { + return ("'" + value + "'"); + break; + } + default: { + throw (new Error("unhandled")); + break; + } + } + } + } + /** + */ + function render(input_data) { + return (input_data.domains + .map((domain) => lib_plankton.string.coin("CREATE TABLE\n\t`{{name}}`(\n{{entries}}\n\t){{comment}}\n;", { + "name": domain.name, + "comment": ((domain.description === null) + ? "" + : lib_plankton.string.coin(" COMMENT '{{comment}}'", { + "comment": domain.description, + })), + "entries": (([] + // key field + .concat((domain.key_field === null) + ? [] + : lib_plankton.string.coin("`{{name}}` {{parameters}}", { + "name": domain.key_field.name, + "parameters": ([ + "INTEGER", + "PRIMARY KEY", + "AUTO INCREMENT", + ] + .concat((domain.key_field.description === null) + ? [] + : [ + lib_plankton.string.coin("COMMENT '{{comment}}'", { + "comment": domain.key_field.description, + }), + ]) + .join(" ")), + })) + // data fields + .concat(domain.data_fields + .map((data_field) => lib_plankton.string.coin("`{{name}}` {{parameters}}", { + "name": data_field.name, + "parameters": (( + // type + [ + { + "boolean": "BOOLEAN", + "integer": "INTEGER", + "string_short": "VARCHAR(63)", + "string_medium": "VARCHAR(255)", + "string_long": "TEXT", + }[data_field.type], + ] + // nullability + .concat(data_field.nullable + ? ["NULL"] + : []) + // default + .concat((data_field.default === undefined) + ? [] + : [ + lib_plankton.string.coin("DEFAULT {{value}}", { + "value": value_encode(data_field.default), + }), + ]) + // comment + .concat((data_field.description === null) + ? [] + : [ + lib_plankton.string.coin("COMMENT '{{comment}}'", { + "comment": data_field.description, + }), + ])) + .join(" ")) + }))) + // constraints + .concat(domain["constraints"] + .map((constraint) => { + switch (constraint.kind) { + default: { + throw (new Error("unhandled constraint kind: " + constraint.kind)); + break; + } + case "foreign_key": { + return lib_plankton.string.coin("FOREIGN KEY ({{fields}}) REFERENCES `{{reference_name}}`({{reference_fields}})", { + "fields": (constraint.parameters["fields"] + .map(x => ('`' + x + '`')) + .join(",")), + "reference_name": constraint.parameters["reference"]["name"], + "reference_fields": (constraint.parameters["reference"]["fields"] + .map(x => ('`' + x + '`')) + .join(",")), + }); + break; + } + case "unique": { + return lib_plankton.string.coin("UNIQUE ({{fields}})", { + "fields": (constraint.parameters["fields"] + .map(x => ('`' + x + '`')) + .join(",")), + }); + break; + } + } + }))) + .map(x => ("\t\t" + x)) + .join(",\n")), + })) + .map(x => (x + "\n")) + .join("\n")); + } + mysql.render = render; + })(mysql = database.mysql || (database.mysql = {})); + })(database = outputs.database || (outputs.database = {})); + })(outputs = _sindri.outputs || (_sindri.outputs = {})); +})(_sindri || (_sindri = {})); +/** + */ +_sindri.add_output(_sindri.enum_realm.database, "mysql", { + "render": (x) => Promise.resolve(_sindri.outputs.database.mysql.render(x)), +}); +var _sindri; +(function (_sindri) { + var outputs; + (function (outputs) { + var database; + (function (database) { + var postgresql; + (function (postgresql) { + /** + */ + function value_encode(value) { + if (value === null) { + return "NULL"; + } + else { + switch (typeof (value)) { + case "boolean": { + return (value ? "TRUE" : "FALSE"); + break; + } + case "number": { + return value.toString(); + break; + } + case "string": { + return ("'" + value + "'"); + break; + } + default: { + throw (new Error("unhandled")); + break; + } + } + } + } + /** + */ + function render(input_data) { + return (input_data.domains + .map((domain) => lib_plankton.string.coin("CREATE TABLE\n\t{{name}}(\n{{entries}}\n\t)\n;\n{{comments}}", { + "name": domain.name, + "entries": (([] + // key field + .concat((domain.key_field === null) + ? [] + : lib_plankton.string.coin("{{name}} {{parameters}}", { + "name": domain.key_field.name, + "parameters": ([ + "SERIAL", + ] + .join(" ")), + })) + // data fields + .concat(domain.data_fields + .map((data_field) => lib_plankton.string.coin("{{name}} {{parameters}}", { + "name": data_field.name, + "parameters": (( + // type + [ + { + "boolean": "BOOLEAN", + "integer": "INTEGER", + "string_short": "VARCHAR(63)", + "string_medium": "VARCHAR(255)", + "string_long": "TEXT", + }[data_field.type], + ] + // nullability + .concat(data_field.nullable + ? [] + : ["NOT NULL"]) + // default + .concat((data_field.default === undefined) + ? [] + : [ + lib_plankton.string.coin("DEFAULT {{value}}", { + "value": value_encode(data_field.default), + }), + ])) + .join(" ")) + }))) + // constraints + .concat(domain["constraints"] + .map((constraint) => { + switch (constraint.kind) { + default: { + throw (new Error("unhandled constraint kind: " + constraint.kind)); + break; + } + case "foreign_key": { + return lib_plankton.string.coin("FOREIGN KEY ({{fields}}) REFERENCES {{reference_name}}({{reference_fields}})", { + "fields": (constraint.parameters["fields"] + .map(x => ('' + x + '')) + .join(",")), + "reference_name": constraint.parameters["reference"]["name"], + "reference_fields": (constraint.parameters["reference"]["fields"] + .map(x => ('' + x + '')) + .join(",")), + }); + break; + } + case "unique": { + return lib_plankton.string.coin("UNIQUE ({{fields}})", { + "fields": (constraint.parameters["fields"] + .map(x => ('' + x + '')) + .join(",")), + }); + break; + } + } + }))) + .map(x => ("\t\t" + x)) + .join(",\n")), + "comments": (([] + .concat((!(domain.description === null)) + ? [ + { + "kind": "TABLE", + "subject": domain.name, + "value": domain.description, + } + ] + : []) + .concat(((!(domain.key_field === null)) + && + (!(domain.key_field.description === null))) + ? [ + { + "kind": "COLUMN", + "subject": (domain.name + "." + domain.key_field.name), + "value": domain.key_field.description, + } + ] + : []) + .concat(domain.data_fields + .filter(data_field => (!(data_field.description === null))) + .map(data_field => ({ + "kind": "COLUMN", + "subject": (domain.name + "." + data_field.name), + "value": data_field.description, + })))) + .map(entry => lib_plankton.string.coin("COMMENT ON {{kind}} {{subject}} IS '{{value}}';", { + "kind": entry.kind, + "subject": entry.subject, + "value": entry.value, + })) + .join("\n")), + })) + .map(x => (x + "\n")) + .join("\n")); + } + postgresql.render = render; + })(postgresql = database.postgresql || (database.postgresql = {})); + })(database = outputs.database || (outputs.database = {})); + })(outputs = _sindri.outputs || (_sindri.outputs = {})); +})(_sindri || (_sindri = {})); +/** + */ +_sindri.add_output(_sindri.enum_realm.database, "postgresql", { + "render": (x) => Promise.resolve(_sindri.outputs.database.postgresql.render(x)), +}); +var _sindri; +(function (_sindri) { + var outputs; + (function (outputs) { + var backend; + (function (backend) { + var typescript; + (function (typescript) { + /** + */ + function get_template(name) { + return __awaiter(this, void 0, void 0, function* () { + return _sindri.get_template(_sindri.enum_realm.backend, "typescript", name + ".ts.tpl"); + }); + } + /** + */ + function coin(template_name, values) { + return __awaiter(this, void 0, void 0, function* () { + return lib_plankton.string.coin(yield get_template(template_name), values, { + "open": "<<", + "close": ">>", + }); + }); + } + /** + */ + function render(input_data) { + return __awaiter(this, void 0, void 0, function* () { + // TODO as command line argument? + const conf_internal = { + "namespace_base": "_sindri.", + }; + const map_primitive_type = function (typename) { + const mymap = { + "boolean": new lib_plankton.prog.struct_type_boolean(), + "integer": new lib_plankton.prog.struct_type_integer(), + // "float": new lib_plankton.prog.struct_type_integer(), + "string_short": new lib_plankton.prog.struct_type_string(), + "string_medium": new lib_plankton.prog.struct_type_string(), + "string_long": new lib_plankton.prog.struct_type_string(), + }; + return mymap[typename]; + }; + const name_table = function (domain) { return (domain.name); }; + const database_path = lib_plankton.string.coin("/tmp/{{name}}.sqlite", { + "name": "sindri", + }); + const namespace_entity = function (domain) { + return lib_plankton.string.coin("{{base}}entities.{{domain_name}}", { + "base": conf_internal.namespace_base, + "domain_name": domain.name, + }); + }; + const name_entity_type = function (fully_qualified, domain) { + return lib_plankton.string.coin("{{prefix}}type_value", { + "prefix": (fully_qualified + ? (namespace_entity(domain) + ".") + : ""), + }); + }; + const namespace_repository = function (domain) { + return lib_plankton.string.coin("{{base}}repositories", { + "base": conf_internal.namespace_base, + }); + }; + const name_repository_function = function (fully_qualified, domain, action) { + return lib_plankton.string.coin("{{prefix}}{{action}}", { + "prefix": (fully_qualified + ? namespace_repository(domain) + : ""), + "action": action, + }); + }; + return coin("master", { + "namespace_base": conf_internal.namespace_base, + "entities": ((yield Promise.all(input_data["domains"] + .map((domain) => coin("entity", { + "domain_name": domain.name, + "defs": lib_plankton.prog.typescript.render_statement(new lib_plankton.prog.struct_statement_type_definition(name_entity_type(false, domain), new lib_plankton.prog.struct_type_record(domain.data_fields + .map((data_field) => ({ + "name": data_field.name, + "type": (data_field.nullable + ? new lib_plankton.prog.struct_type_union(new lib_plankton.prog.struct_type_literal(new lib_plankton.prog.struct_expression_literal(null)), map_primitive_type(data_field["type"])) + : map_primitive_type(data_field["type"])), + "mandatory": true, + }))), { + "export": true, + }), { + "level": 2, + }) + })))) + .join("")), + "repositories": ((yield Promise.all(input_data["domains"] + .map((domain) => coin("repository", { + "domain_name": domain.name, + "type_name": name_entity_type(true, domain), + "table_name": name_table(domain), + "list_function_name": name_repository_function(false, domain, "list"), + "list_query_fields": ([domain.key_field.name] + .concat(domain.data_fields.map(field => field.name)) + .join(",")), + "list_result": lib_plankton.prog.typescript.render_expression(new lib_plankton.prog.struct_expression_dict([ + { + "key": "key", + "value": new lib_plankton.prog.struct_expression_projection(new lib_plankton.prog.struct_expression_variable("row"), new lib_plankton.prog.struct_expression_literal(domain.key_field.name)), + }, + { + "key": "value", + "value": new lib_plankton.prog.struct_expression_dict(domain.data_fields + .map((field, index) => ({ + "key": field.name, + "value": new lib_plankton.prog.struct_expression_projection(new lib_plankton.prog.struct_expression_variable("row"), new lib_plankton.prog.struct_expression_literal(field.name)) + }))), + }, + ]), { + "indent": false, + "level": 8, + }), + "read_function_name": name_repository_function(false, domain, "read"), + "read_query_fields": ([] + .concat(domain.data_fields.map(field => field.name)) + .join(",")), + "read_result_fields": lib_plankton.prog.typescript.render_expression(new lib_plankton.prog.struct_expression_dict(domain.data_fields + .map((field, index) => ({ + "key": field.name, + "value": new lib_plankton.prog.struct_expression_projection(new lib_plankton.prog.struct_expression_variable("row"), new lib_plankton.prog.struct_expression_literal(field.name)) + }))), { + "indent": false, + "level": 6, + }), + "create_function_name": name_repository_function(false, domain, "create"), + "create_query_field_names": (domain.data_fields + .map(field => field.name) + .join(",")), + "create_query_field_placeholders": (domain.data_fields + .map(field => (":" + field.name)) + .join(",")), + "create_query_field_values": lib_plankton.prog.typescript.render_expression(new lib_plankton.prog.struct_expression_dict(domain.data_fields + .map(field => ({ + "key": field.name, + "value": new lib_plankton.prog.struct_expression_fieldaccess(new lib_plankton.prog.struct_expression_variable("value"), field.name), + }))), { + "indent": false, + "level": 6, + }), + "update_function_name": name_repository_function(false, domain, "update"), + "update_query_assignments": (domain.data_fields + .map(field => lib_plankton.string.coin("{{key}} = {{value}}", { + "key": field.name, + "value": (":" + ("value_" + field.name)), + })) + .join(", ")), + "update_query_values": lib_plankton.prog.typescript.render_expression(new lib_plankton.prog.struct_expression_dict([] + .concat([ + { + "key": "key", + "value": new lib_plankton.prog.struct_expression_variable("key"), + }, + ]) + .concat(domain.data_fields + .map(field => ({ + "key": ("value_" + field.name), + "value": new lib_plankton.prog.struct_expression_fieldaccess(new lib_plankton.prog.struct_expression_variable("value"), field.name), + })))), { + "indent": false, + "level": 7, + }), + "delete_function_name": name_repository_function(false, domain, "delete"), + })))) + .join("")), + "api": ((yield Promise.all(input_data["domains"] + .map((domain) => coin("api", { + "domain_name": domain.name, + "type_name": name_entity_type(true, domain), + "repository_function_list": name_repository_function(true, domain, "list"), + "repository_function_read": name_repository_function(true, domain, "read"), + "repository_function_create": name_repository_function(true, domain, "create"), + "repository_function_update": name_repository_function(true, domain, "update"), + "repository_function_delete": name_repository_function(true, domain, "delete"), + })))) + .join("")), + }); + }); + } + typescript.render = render; + })(typescript = backend.typescript || (backend.typescript = {})); + })(backend = outputs.backend || (outputs.backend = {})); + })(outputs = _sindri.outputs || (_sindri.outputs = {})); +})(_sindri || (_sindri = {})); +_sindri.add_output(_sindri.enum_realm.backend, "typescript", { + "render": _sindri.outputs.backend.typescript.render, +}); +var _sindri; +(function (_sindri) { + var outputs; + (function (outputs) { + var frontend; + (function (frontend) { + var typescript; + (function (typescript) { + /** + */ + function get_template(name) { + return __awaiter(this, void 0, void 0, function* () { + return _sindri.get_template(_sindri.enum_realm.frontend, "typescript", name); + }); + } + /** + */ + function render(input_data) { + return __awaiter(this, void 0, void 0, function* () { + return lib_plankton.string.coin(yield get_template("core.ts.tpl"), { + "value": JSON.stringify(input_data, undefined, "\t"), + }); + }); + } + typescript.render = render; + })(typescript = frontend.typescript || (frontend.typescript = {})); + })(frontend = outputs.frontend || (outputs.frontend = {})); + })(outputs = _sindri.outputs || (_sindri.outputs = {})); +})(_sindri || (_sindri = {})); +_sindri.add_output(_sindri.enum_realm.frontend, "typescript", { + "render": _sindri.outputs.frontend.typescript.render, +}); +var _sindri; +(function (_sindri) { + /** + * @todo generate generic + */ + function input_schema() { + return { + "type": "object", + "additionalProperties": false, + "properties": { + "domains": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": ["null", "string"], + "default": null + }, + "key_field": { + "type": ["null", "object"], + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": ["null", "string"], + "default": null + } + }, + "required": [ + "name" + ], + "default": null + }, + "data_fields": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": ["null", "string"], + "default": null + }, + "type": { + "type": "string", + "enum": [ + "boolean", + "integer", + "float", + "string_short", + "string_medium", + "string_long" + ] + }, + "nullable": { + "type": "boolean", + "default": true + }, + "default": { + "type": ["null", "boolean", "integer", "float", "string"], + "default": null + } + }, + "required": [ + "name", + "type" + ] + }, + "default": [] + }, + "constraints": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "kind": { + "type": "string", + "enum": [ + "unique", + "foreign_key" + ] + }, + "parameters": { + "type": "object", + "additionalProperties": "string", + "properties": {}, + "required": [] + } + }, + "required": [ + "kind" + ] + }, + "default": [] + } + }, + "required": [ + "name" + ] + } + } + }, + "required": [ + "domains" + ] + }; + } + _sindri.input_schema = input_schema; + /** + */ + function input_normalize(input_raw) { + // validate + if (!input_raw.hasOwnProperty("domains")) { + throw (new Error("input node is missing mandatory field 'domains'")); + } + else { + // sanitize + return { + "domains": (input_raw["domains"] + .map(domain_raw => { + var _a, _b; + return ({ + "name": domain_raw["name"], + "description": ((_a = domain_raw["description"]) !== null && _a !== void 0 ? _a : null), + "key_field": ((domain_raw.hasOwnProperty("key_field") && (domain_raw["key_field"] !== null)) + ? { + "name": domain_raw["key_field"]["name"], + "description": ((_b = domain_raw["key_field"]["description"]) !== null && _b !== void 0 ? _b : null), + } + : null), + "data_fields": ((domain_raw.hasOwnProperty("data_fields") && (domain_raw["data_fields"] !== null)) + ? (domain_raw["data_fields"] + .map(data_field_raw => { + var _a, _b; + return ({ + "name": data_field_raw["name"], + "description": ((_a = data_field_raw["description"]) !== null && _a !== void 0 ? _a : null), + "type": data_field_raw["type"], + "nullable": ((_b = data_field_raw["nullable"]) !== null && _b !== void 0 ? _b : true), + "default": data_field_raw["default"], + }); + })) + : []), + "constraints": ((domain_raw.hasOwnProperty("constraints") && (domain_raw["constraints"] !== null)) + ? (domain_raw["constraints"] + .map(constraint_raw => { + var _a; + return ({ + "kind": constraint_raw["kind"], + "parameters": ((_a = constraint_raw["parameters"]) !== null && _a !== void 0 ? _a : {}), + }); + })) + : []), + }); + })), + }; + } + } + _sindri.input_normalize = input_normalize; +})(_sindri || (_sindri = {})); +var _sindri; +(function (_sindri) { + /** + */ + function main(args_raw) { + return __awaiter(this, void 0, void 0, function* () { + const arg_handler = new lib_plankton.args.class_handler({ + "format": new lib_plankton.args.class_argument({ + "name": "format", + "type": lib_plankton.args.enum_type.string, + "kind": lib_plankton.args.enum_kind.volatile, + "mode": lib_plankton.args.enum_mode.replace, + "default": "database:sqlite", + "parameters": { + "indicators_long": ["format"], + "indicators_short": ["f"], + }, + "info": "output format", + }), + "list": new lib_plankton.args.class_argument({ + "name": "list", + "type": lib_plankton.args.enum_type.boolean, + "kind": lib_plankton.args.enum_kind.volatile, + "mode": lib_plankton.args.enum_mode.replace, + "default": false, + "parameters": { + "indicators_long": ["list"], + "indicators_short": ["l"], + }, + "info": "list available output formats", + }), + "schema": new lib_plankton.args.class_argument({ + "name": "schema", + "type": lib_plankton.args.enum_type.boolean, + "kind": lib_plankton.args.enum_kind.volatile, + "mode": lib_plankton.args.enum_mode.replace, + "default": false, + "parameters": { + "indicators_long": ["schema"], + "indicators_short": ["s"], + }, + "info": "print sindri JSON schema to stdout and exit", + }), + "help": new lib_plankton.args.class_argument({ + "name": "help", + "type": lib_plankton.args.enum_type.boolean, + "kind": lib_plankton.args.enum_kind.volatile, + "mode": lib_plankton.args.enum_mode.replace, + "default": false, + "parameters": { + "indicators_long": ["help"], + "indicators_short": ["h"], + }, + "info": "print help to stdout and exit", + }), + }); + const args = arg_handler.read(lib_plankton.args.enum_environment.cli, args_raw.join(" ")); + if (args["help"]) { + process.stdout.write(arg_handler.generate_help({ + "programname": "sindri", + "author": "Christian Fraß ", + "description": "create data model scripts in different output formats (MySQL, SQLite, …) on basis of an abstract description; feed with .sindri.json file via stdin!", + "executable": "sindri", + })); + } + else { + if (args["schema"]) { + process.stdout.write(JSON.stringify(_sindri.input_schema(), undefined, "\t")); + } + else { + if (args["list"]) { + process.stdout.write(_sindri.list_outputs() + .map(entry => lib_plankton.string.coin("{{realm}}:{{implementation}}\n", { + "realm": entry.realm, + "implementation": entry.implementation, + })) + .join("")); + } + else { + const input_content = yield lib_plankton.file.read_stdin(); + const input_data_raw = lib_plankton.json.decode(input_content); + const input_data = _sindri.input_normalize(input_data_raw); + const format_parts = args["format"].split(":"); + const realm_encoded = format_parts[0]; + const realm = { + "database": _sindri.enum_realm.database, + "backend": _sindri.enum_realm.backend, + "frontend": _sindri.enum_realm.frontend, + "other": _sindri.enum_realm.other, + }[realm_encoded]; + const name = format_parts.slice(1).join(":"); + let output; + try { + output = _sindri.get_output(realm, name); + } + catch (error) { + output = null; + } + if (output === null) { + throw (new Error("unhandled output format: " + args["format"])); + } + else { + const output_content = yield output.render(input_data); + process.stdout.write(output_content); + } + } + } + } + }); + } + _sindri.main = main; +})(_sindri || (_sindri = {})); +_sindri.main(process.argv.slice(2)); diff --git a/tools/sindri/templates/backend/typescript/api.ts.tpl b/tools/sindri/templates/backend/typescript/api.ts.tpl new file mode 100644 index 0000000..35767e7 --- /dev/null +++ b/tools/sindri/templates/backend/typescript/api.ts.tpl @@ -0,0 +1,118 @@ + // <> + { + lib_plankton.rest.register( + rest, + lib_plankton.http.enum_method.get, + lib_plankton.string.coin( + "/{{base_path}}{{domain_name}}", + { + "base_path": _brock.conf.api_base_path, + "domain_name": "<>", + } + ), + { + "execution": async function (stuff) { + return { + "status_code": 200, + "data": await <>( + + ) + }; + } + } + ); + lib_plankton.rest.register( + rest, + lib_plankton.http.enum_method.get, + lib_plankton.string.coin( + "/{{base_path}}{{domain_name}}/:id", + { + "base_path": _brock.conf.api_base_path, + "domain_name": "<>", + } + ), + { + "execution": async function (stuff) { + return { + "status_code": 200, + "data": await <>( + parseInt( + stuff.path_parameters["id"] + ) + ) + }; + } + } + ); + lib_plankton.rest.register( + rest, + lib_plankton.http.enum_method.post, + lib_plankton.string.coin( + "/{{base_path}}{{domain_name}}", + { + "base_path": _brock.conf.api_base_path, + "domain_name": "<>", + } + ), + { + "execution": async function (stuff) { + const id = await <>( + (stuff.input as <>) + ); + return { + "status_code": 201, + "data": id + }; + } + } + ); + lib_plankton.rest.register( + rest, + lib_plankton.http.enum_method.patch, + lib_plankton.string.coin( + "/{{base_path}}{{domain_name}}/:id", + { + "base_path": _brock.conf.api_base_path, + "domain_name": "<>", + } + ), + { + "execution": async function (stuff) { + const dummy = await <>( + parseInt( + stuff.path_parameters["id"] + ), + (stuff.input as <>) + ); + return { + "status_code": 200, + "data": null + }; + } + } + ); + lib_plankton.rest.register( + rest, + lib_plankton.http.enum_method.delete, + lib_plankton.string.coin( + "/{{base_path}}{{domain_name}}/:id", + { + "base_path": _brock.conf.api_base_path, + "domain_name": "<>", + } + ), + { + "execution": async function (stuff) { + const dummy = await <>( + parseInt( + stuff.path_parameters["id"] + ) + ); + return { + "status_code": 200, + "data": null + }; + } + } + ); + } diff --git a/tools/sindri/templates/backend/typescript/entity.ts.tpl b/tools/sindri/templates/backend/typescript/entity.ts.tpl new file mode 100644 index 0000000..a9d6cb7 --- /dev/null +++ b/tools/sindri/templates/backend/typescript/entity.ts.tpl @@ -0,0 +1,4 @@ + export namespace <> + { +<> + } diff --git a/tools/sindri/templates/backend/typescript/master.ts.tpl b/tools/sindri/templates/backend/typescript/master.ts.tpl new file mode 100644 index 0000000..967d7c5 --- /dev/null +++ b/tools/sindri/templates/backend/typescript/master.ts.tpl @@ -0,0 +1,74 @@ +// declare var require; + +namespace <>entities +{ +<> +} + + +namespace <>repositories +{ +<> +} + + +namespace <>main +{ + // run + export function run( + ) : void + { + lib_plankton.log.conf_push( + [ + new lib_plankton.log.class_channel_stdout( + + ) + ] + ); + + // define api + { + // meta + { + lib_plankton.rest.register( + rest, + lib_plankton.http.enum_method.get, + "/_spec", + { + "execution": async function (stuff) { + return { + "status_code": 200, + "data": lib_plankton.rest.to_oas( + rest + ) + }; + } + } + ); + } +<> + } + + // setup server + const server = lib_plankton.server.make( + _brock.conf.server_port, + async function (input) { + const http_request : lib_plankton.http.type_request = lib_plankton.http.decode_request( + input + ); + const http_response : lib_plankton.http.type_response = await lib_plankton.rest.call( + rest, + http_request + ); + return lib_plankton.http.encode_response( + http_response + ); + } + ); + + // start + lib_plankton.server.start( + server + ); + } +} diff --git a/tools/sindri/templates/backend/typescript/repository-list.ts.tpl b/tools/sindri/templates/backend/typescript/repository-list.ts.tpl new file mode 100644 index 0000000..7156f3a --- /dev/null +++ b/tools/sindri/templates/backend/typescript/repository-list.ts.tpl @@ -0,0 +1,37 @@ +function repository_{{domain_name}}_list( + +) : Promise< + Array< + { + key : number; + value : {{type_name}} + } + > +> +{ + return lib_plankton.sqlite.query_get( + conf.database_path, + { + "template": "SELECT {{query_fields}} FROM {{table_name}};", + "arguments": { + + } + } + ).then( + function (rows) { + return rows.map( + function (row) { + return { + "key": row["id"], + "value": { + {{value_mapping}} + "name": row["name"], + "description": row["description"], + "hue": row["hue"] + } + }; + } + ); + } + ); +} diff --git a/tools/sindri/templates/backend/typescript/repository.ts.tpl b/tools/sindri/templates/backend/typescript/repository.ts.tpl new file mode 100644 index 0000000..0dfc38a --- /dev/null +++ b/tools/sindri/templates/backend/typescript/repository.ts.tpl @@ -0,0 +1,113 @@ + export namespace <> + { + + // list + export function <>( + ) : Promise>;}>> + { + return ( + lib_plankton.sqlite.query_get( + _brock.conf.database_path, + { + "template": "SELECT <> FROM <>;", + "arguments": { + + } + } + ) + .then( + (rows) => rows.map( + (row) => <> + ) + ) + ); + } + + // read + export function <>( + key : number + ) : Promise<<>> + { + return ( + lib_plankton.sqlite.query_get( + _brock.conf.database_path, + { + "template": "SELECT <> FROM <> WHERE (id = :key);", + "arguments": { + "key": key + } + } + ) + .then( + (rows) { + const row = rows[0]; + return <>; + } + ) + ); + } + + // create + export function <>( + value : <> + ) : Promise + { + return ( + lib_plankton.sqlite.query_put( + _brock.conf.database_path, + { + "template": "INSERT INTO <>(<>) VALUES (<>);", + "arguments": <> + } + ) + .then( + (result) => result.id + ) + ); + } + + // update + export function <>( + key : number, + value : <> + ) : Promise + { + return ( + lib_plankton.sqlite.query_put( + _brock.conf.database_path, + { + "template": "UPDATE <> SET <> WHERE (id = :key);", + "arguments": { + "key": key, + <> + } + } + ) + .then( + (result) => {} + ) + ); + } + + // delete + export function <>( + key : number + ) : Promise + { + return ( + lib_plankton.sqlite.query_put( + _brock.conf.database_path, + { + "template": "DELETE FROM <> WHERE (id = :key);", + "arguments": { + "key": key + } + } + ) + .then( + (result) => {} + ) + ); + } + + } diff --git a/tools/sindri/templates/frontend/typescript/core.ts.tpl b/tools/sindri/templates/frontend/typescript/core.ts.tpl new file mode 100644 index 0000000..c065713 --- /dev/null +++ b/tools/sindri/templates/frontend/typescript/core.ts.tpl @@ -0,0 +1,251 @@ +namespace _sindri +{ + + /** + */ + const abstract = {{value}}; + + + /** + * @todo headers + * @todo query + */ + export function api_call( + method : string, + path : string, + input : any = null + ) : Promise + { + return ( + fetch( + (conf.backend.scheme + "://" + conf.backend.host + ":" + conf.backend.port.toFixed() + path), + { + "method": method, + "headers": { + "Content-Type": "application/json", + }, + "body": ( + (input === null) + ? undefined + : /*Buffer.from*/(JSON.stringify(input)) + ), + } + ) + .then( + x => x.json() + ) + ); + } + + + /** + */ + export function editor( + domain_description : any, + hook_switch : (null | ((state : lib_plankton.zoo_editor.type_state) => void)) + ) : lib_plankton.zoo_editor.type_editor + { + return lib_plankton.zoo_editor.make( + // store + { + "setup": () => Promise.resolve(undefined), + "search": (term) => ( + api_call( + "GET", + lib_plankton.string.coin( + "/{{name}}", + { + "name": domain_description.name, + } + ), + null + ) + .then( + (entries) => Promise.resolve>( + entries + .filter( + entry => ( + entry.key.toFixed().includes(term.toLowerCase()) + || + ( + /* + (term.length >= 3) + && + */ + domain_description.data_fields + .some( + data_field => JSON.stringify(entry.value[data_field.name]).toLowerCase().includes(term.toLowerCase()) + ) + ) + ) + ) + .map( + entry => ({ + "key": entry.key, + "preview": entry.value, + }) + ) + ) + ) + ), + "read": (id) => api_call( + "GET", + lib_plankton.string.coin( + "/{{name}}/{{id}}", + { + "name": domain_description.name, + "id": id.toFixed(0), + } + ), + null + ), + "create": (object) => api_call( + "POST", + lib_plankton.string.coin( + "/{{name}}", + { + "name": domain_description.name, + } + ), + object + ), + "update": (id, object) => api_call( + "PATCH", + lib_plankton.string.coin( + "/{{name}}/{{id}}", + { + "name": domain_description.name, + "id": id.toFixed(0), + } + ), + object + ), + "delete": (id) => api_call( + "DELETE", + lib_plankton.string.coin( + "/{{name}}/{{id}}", + { + "name": domain_description.name, + "id": id.toFixed(0), + } + ), + null + ), + }, + // form + lib_plankton.zoo_form.make( + // method + "GET", + // fields + ( + domain_description.data_fields.map( + data_field => ({ + "name": data_field.name, + "type": { + "string_short": "text", + "string_medium": "text", + "string_long": "text", + "integer": "number", + "float": "number", + }[data_field.type], + }) + ) + ), + // encode + (object) => object, + // decode + (object_encoded) => object_encoded, + ), + // options + { + "hook_switch": hook_switch, + } + ); + } + + + /** + */ + export function edit_location_name( + domain_description + ) : string + { + return lib_plankton.string.coin( + "edit_{{name}}", + { + "name": domain_description.name, + } + ); + } + + + /** + */ + export function register_editor_page_for_domain( + domain_description + ) : void + { + const location_name : string = edit_location_name(domain_description); + lib_plankton.zoo_page.register( + location_name, + async (parameters, element_main) => { + const id : (null | int) = ((! ("id" in parameters)) ? null : parseInt(parameters["id"])); + const mode : lib_plankton.zoo_editor.enum_mode = editor_decode_mode(parameters["mode"], id); + const search_term : (null | string) = (parameters["search"] ?? null); + lib_plankton.zoo_editor.render( + editor( + domain_description, + (state) => { + lib_plankton.zoo_page.set( + { + "name": location_name, + "parameters": { + "mode": state.mode, + "id": ((state.key === null) ? null : state.key.toFixed(0)), + "search": state.search_state.term, + }, + } + ); + } + ), + element_main, + { + "state": { + "mode": mode, + "key": id, + "search_state": {"term": search_term}, + } + } + ); + } + ); + lib_plankton.zoo_page.add_nav_entry( + { + "name": location_name, + "parameters": { + "mode": "find", + "key": null, + "search": "" + } + }, + { + "label": (domain_description.name + "s"), + } + ); + } + + + /** + */ + export function init( + ) : Promise + { + abstract.domains.forEach( + domain_description => { + register_editor_page_for_domain(domain_description); + } + ); + return Promise.resolve(undefined); + } + +} diff --git a/tools/sindri/templates/frontend/typescript/index.html.tpl b/tools/sindri/templates/frontend/typescript/index.html.tpl new file mode 100644 index 0000000..99cc137 --- /dev/null +++ b/tools/sindri/templates/frontend/typescript/index.html.tpl @@ -0,0 +1,19 @@ + + + + + + + + <<title>> + + + +
+
+
+ + diff --git a/tools/sindri/templates/frontend/typescript/main.ts.tpl b/tools/sindri/templates/frontend/typescript/main.ts.tpl new file mode 100644 index 0000000..18f927b --- /dev/null +++ b/tools/sindri/templates/frontend/typescript/main.ts.tpl @@ -0,0 +1,44 @@ +/** + */ +async function init( +) : Promise +{ + lib_plankton.zoo_page.init( + document.querySelector("main"), + { + "fallback": { + "name": "view", + "parameters": { + } + }, + } + ); + await _sindri.init(); + + lib_plankton.zoo_page.start(); + + return Promise.resolve(undefined); +} + + +/** + */ +function main( +) : void +{ +} + + +/** + */ +function entry( +) : void +{ + document.addEventListener( + "DOMContentLoaded", + async () => { + await init(); + main(); + } + ); +} diff --git a/tools/update-sindri b/tools/update-sindri new file mode 100755 index 0000000..c5c11f5 --- /dev/null +++ b/tools/update-sindri @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +cp \ + --recursive \ + --update \ + ~/projekte/greenscale/misc/sindri/build/* \ + tools/sindri/