diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index 1d88d33..9b721c0 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -1,11 +1,11 @@ /** * @author fenris */ -declare type int = number; +type int = number; /** * @author fenris */ -declare type float = number; +type float = number; declare class Buffer { constructor(x: string, modifier?: string); toString(modifier?: string): string; @@ -19,7 +19,7 @@ declare namespace lib_plankton.base { /** * @author fenris */ -declare type type_pseudopointer = { +type type_pseudopointer = { value: type_value; }; /** @@ -583,6 +583,10 @@ declare namespace lib_plankton.call { * @author fenris */ export function timeout(procedure: (() => void), delay_in_seconds: float): int; + /** + * @author fenris + */ + export function loop(procedure: (() => void), delay_in_seconds: float): int; /** * Promise version of "setTimeout" * @@ -1381,6 +1385,696 @@ declare var printf: typeof lib_plankton.string.printf; declare var eml_log: any; declare var track_exports: any; declare var make_logger: (prefix: any, current_loglevel: any) => (obj: any, lvl: any) => void; +declare namespace lib_plankton.pair { + /** + */ + type type_pair = { + first: type_first; + second: type_second; + }; +} +declare namespace lib_plankton.pair { + /** + */ + function swap(pair: type_pair): type_pair; + /** + */ + function show(pair: type_pair, options?: { + show_first?: ((first: type_first) => string); + show_second?: ((second: type_second) => string); + }): string; +} +declare namespace lib_plankton.list { + /** + */ + type type_separation = { + yes: Array; + no: Array; + }; + /** + */ + type type_result_max = (null | { + index: int; + element: type_element; + value: type_value; + }); +} +declare namespace lib_plankton.list { + /** + * returns a certain list of integer numbers + */ + function range(from: int, to: int, options?: { + step?: int; + }): Array; + /** + * returns a certain list of consecutiv integer numbers, beginning with 0 + */ + function sequence(length: int): Array; + /** + */ + function from_iterator(iterator: Iterator): Array; + /** + */ + function is_empty(list: Array): boolean; + /** + * combines two lists into one + * + * @param {boolean} [options.cut] whether the result list will be as long as the shortest input list or an exception is thrown if they have different lengths; default: true + */ + function zip(list_first: Array, list_second: Array, options?: { + cut?: boolean; + }): Array>; + /** + * checks whether two lists are equal + * + * @todo define common function "equals" and default predicate to + */ + function equals(list1: Array, list2: Array, options?: { + collate_element?: ((element1: type_element, element2: type_element) => boolean); + }): boolean; + /** + * creates a list with the elements from the input list, which fulfil a certain predicate (~ filter) + */ + function keep(list: Array, predicate: ((element: type_element) => boolean)): Array; + /** + * creates a list with the elements from the input list, which do not fulfil a certain predicate (~ dual filter) + */ + function drop(list: Array, predicate: ((element: type_element) => boolean)): Array; + /** + */ + function filter_inplace(list: Array, predicate: ((element: type_element) => boolean)): void; + /** + * returns a list with no duplicates (like unix' "unique") + */ + function cleaned(list: Array, options?: { + collate_element?: ((x: type_element, y: type_element) => boolean); + }): Array; + /** + * creates a binary partition of the list according to a given predicate + */ + function separate(list: Array, predicate: ((element: type_element) => boolean)): type_separation; + /** + */ + function clone(list: Array): Array; + /** + */ + function reversed(list: Array): Array; + /** + * @todo use Array.toSorted? + */ + function sorted(list: Array, options: { + compare_element?: ((element1: type_element, element2: type_element) => boolean); + }): Array; + /** + * die Liste in gleich große Blöcke zerlegen + */ + function chop(list: Array, chunk_size: int): Array>; + /** + */ + function group(list: Array, collate_element: ((x: type_element, y: type_element) => boolean)): Array>; + /** + */ + function has(list: Array, predicate: ((element: type_element) => boolean)): boolean; + /** + * @deprecate use Array.includes or Array.some + */ + function contains(list: Array, element: type_element, options: { + collate_element?: ((element1: type_element, element2: type_element) => boolean); + }): boolean; + /** + * retrieves the element and its index of the list, which has the maximum value + */ + function max(list: Array, target_function: ((element: type_element) => type_value), options: { + compare_value: ((value1: type_value, value2: type_value) => boolean); + }): type_result_max; + /** + * retrieves the element and its index of the list, which has the mininum value + */ + function min(list: Array, target_function: (element: type_element) => type_value, options: { + compare_value: ((value1: type_value, value2: type_value) => boolean); + }): type_result_max; + /** + * implements the idea of arithmetic distribution like in "(a+b)·(c+d) = (a·c)+(a·d)+(b·c)+(b·d)" + * example: distribute([[1,2],[3],[4,5,6]]) = [[1,3,4],[1,3,5],[1,3,6],[2,3,4],[2,3,5],[2,3,6]] + */ + function distribute(lists: Array>): Array>; + /** + */ + function contrast(list_left: Array, extract_key_left: ((left: type_left) => string), list_right: Array, extract_key_right: ((right: type_right) => string)): { + both: Array<{ + key: string; + left: type_left; + right: type_right; + }>; + only_left: Array<{ + key: string; + left: type_left; + }>; + only_right: Array<{ + key: string; + right: type_right; + }>; + }; +} +declare namespace lib_plankton.shape { + /** + * @todo + */ + type type_jsonschema = any; + /** + * @todo + */ + type type_oas_schema = any; + /** + * @author fenris + */ + type type_inspection = { + flaws: Array; + sub: Array<{ + position: string; + inspection: type_inspection; + }>; + }; + /** + * @author fenris + */ + function inspection_create(): type_inspection; + /** + * @author fenris + */ + function inspection_add(main: type_inspection, flaw: string): void; + /** + * @author fenris + */ + function inspection_extend(main: type_inspection, prefix: string, sub: type_inspection): void; + /** + */ + type type_shape = { + kind: string; + parameters: Record; + }; + /** + * @author fenris + */ + type type_logic = { + inspect: ((sub_inspect: ((shape: type_shape, value: any) => type_inspection), value: any) => type_inspection); + show: ((sub_show: ((shape: type_shape) => string)) => string); + to_typescript_type: ((sub_to_typescript_type: ((shape: type_shape) => string)) => string); + to_jsonschema: ((sub_to_json_schema: ((shape: type_shape) => type_jsonschema)) => type_jsonschema); + to_oas_schema: ((sub_to_oas_schema: ((shape: type_shape) => type_oas_schema)) => type_oas_schema); + example: ((sub_example: ((shape: type_shape) => any)) => any); + }; + /** + */ + function inspect(shape: type_shape, value: any): type_inspection; + /** + */ + function inspect_flat(shape: type_shape, value: any): Array; + /** + */ + function show(shape: type_shape): string; + /** + */ + function to_typescript_type(shape: type_shape): string; + /** + */ + function to_jsonschema(shape: type_shape): type_jsonschema; + /** + */ + function to_oas_schema(shape: type_shape): type_oas_schema; + /** + */ + function example(shape: type_shape): any; + /** + */ + function register(name: string, construct: ((parameters: type_parameters) => type_subject), logic: ((subject: type_subject) => type_logic)): void; +} +declare namespace lib_plankton.shape.any { + /** + */ + type type_subject = {}; + /** + */ + export function make(options?: {}): type_subject; + export {}; +} +declare namespace lib_plankton.shape.null_ { + /** + */ + type type_subject = {}; + /** + */ + export function make(options?: {}): type_subject; + export {}; +} +declare namespace lib_plankton.shape.boolean { + /** + */ + type type_subject = { + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | boolean); + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.integer { + /** + */ + type type_subject = { + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + minimum: lib_plankton.pod.type_pod; + maximum: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | int); + description?: string; + minimum?: int; + maximum?: int; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.float { + /** + */ + type type_subject = { + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + minimum: lib_plankton.pod.type_pod; + maximum: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | float); + description?: string; + minimum?: float; + maximum?: float; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.string { + /** + */ + type type_subject = { + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + pattern: lib_plankton.pod.type_pod; + min_length: lib_plankton.pod.type_pod; + max_length: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | int); + description?: string; + pattern?: string; + min_length?: int; + max_length?: int; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.email { + /** + */ + type type_subject = { + core: type_shape; + }; + /** + */ + export function make(options?: { + soft?: boolean; + defaultvalue?: (null | int); + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.list_ { + /** + */ + type type_subject = { + shape_element: type_shape; + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(shape_element: type_shape, options?: { + soft?: boolean; + defaultvalue?: any; + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.map { + /** + */ + type type_subject = { + shape_key: type_shape; + shape_value: type_shape; + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(shape_key: type_shape, shape_value: type_shape, options?: { + soft?: boolean; + defaultvalue?: any; + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.shape.record { + /** + */ + type type_field = { + name: string; + shape: type_shape; + required: boolean; + }; + /** + */ + type type_subject = { + fields: Array; + soft: boolean; + defaultvalue: lib_plankton.pod.type_pod; + description: lib_plankton.pod.type_pod; + }; + /** + */ + export function make(fields_raw: Array<{ + name: string; + shape: type_shape; + required?: boolean; + }>, options?: { + soft?: boolean; + defaultvalue?: any; + description?: string; + }): type_subject; + export {}; +} +declare namespace lib_plankton.www_form { + /** + */ + type type_source = Record; + /** + */ + type type_target = string; + /** + * @author fenris + */ + function encode(source: type_source): type_target; + /** + * @author fenris + */ + function decode(target: type_target): type_source; +} +declare namespace lib_plankton.www_form { + /** + * @author fenris + */ + class class_www_form implements lib_plankton.code.interface_code { + /** + * @author fenris + */ + constructor(); + /** + * @implementation + * @author fenris + */ + encode(source: type_source): type_target; + /** + * @implementation + * @author fenris + */ + decode(target: type_target): type_source; + } +} +declare namespace lib_plankton.url { + /** + * @author fenris + */ + type type_url = { + scheme: (null | string); + host: (null | string); + username: (null | string); + password: (null | string); + port: (null | int); + path: (null | string); + query: (null | string); + hash: (null | string); + }; +} +declare namespace lib_plankton.url { + /** + * @author fenris + */ + function encode(url: type_url): string; + /** + * @author fenris + * @todo arguments + */ + function decode(url_raw: string): type_url; + /** + * @author fenris + */ + function implementation_code(): lib_plankton.code.type_code; +} +declare namespace lib_plankton.url { + /** + * @author fenris + */ + class class_url implements lib_plankton.code.interface_code { + /** + * @author fenris + */ + constructor(); + /** + * @implementation + * @author fenris + */ + encode(x: any): string; + /** + * @implementation + * @author fenris + */ + decode(x: string): any; + } +} +declare namespace lib_plankton.random { + /** + * @author fenris + */ + type type_state = { + builtin: boolean; + seed?: int; + }; + /** + * @author fenris + */ + function state_push(state: type_state): void; + /** + * @author fenris + */ + function state_pop(): type_state; + /** + * returns a random floating point number in the interval [0,1[ + * + * @author fenris + */ + function generate_unit(): float; + /** + * returns a random boolean value + * + * @param {float} [probability] the probability for the return-value "true"; default: 0.5 + * @author fenris + */ + function generate_boolean(options?: { + probability?: float; + }): boolean; + /** + * returns a random integer number in the interval [a,b] + * + * @param {int} [minimum] the left side of the halfopen interval (i.e. the smallest included value in the range) + * @param {int} [minimum] the right side of the halfopen interval (i.e. the smallest excluded value in the range) + * @author fenris + */ + function generate_integer(options?: { + minimum?: int; + maximum?: int; + }): int; + var generate_int: typeof generate_integer; + /** + * returns a random floating point number in the given interval + * + * @author fenris + */ + function generate_float(options?: { + minimum?: int; + maximum?: int; + }): float; + /** + * returns a random date + * + * @author fenris + */ + function generate_date(options?: { + minimum?: Date; + maximum?: Date; + }): Date; + /** + * @author fenris + */ + function generate_hexdigit(): string; + /** + * generates a random string with an optional prefix + * + * @author fenris + */ + function generate_string(options?: { + length?: int; + }): string; + /** + * chooses a value randomly from a list of values with weights (a higher weight means a higher probability to be chosen) + * + * @author fenris + */ + function choose_weighted(sets: Array<{ + weight: float; + value: type_value; + }>): type_value; + /** + * chooses a value randomly from a list of values with equal probabilities + * + * @author fenris + */ + function choose_uniformly(values: Array): type_value; + /** + * @author fenris + */ + function shuffle(list: Array): Array; + /** + * @author fenris + */ + function generate_vowel(): string; + /** + * @author fenris + */ + function generate_halfvowel(): string; + /** + * @author fenris + */ + function generate_consonant(): string; + /** + * @author fenris + */ + function generate_letter(): string; + /** + * @author fenris + */ + function generate_syllable(): string; + /** + * @author fenris + */ + function generate_word(options?: { + syllable_count_minimum?: int; + syllable_count_maximum?: int; + }): string; + /** + * @author fenris + */ + function generate_text(options?: { + word_count?: int; + }): string; + /** + * @author fenris + */ + function generate_city(): string; + /** + * @author fenris + */ + function generate_street(): string; + /** + * @author fenris + */ + function generate_guid(options?: { + with_braces?: boolean; + }): string; + /** + * @author fenris + */ + function generate_url(): string; + /** + * @author fenris + */ + function generate_email_address(): string; + /** + * @author fenris + */ + function generate_telephone_number(): string; + /** + * @author fenris + */ + function generate_time(): any; + /** + * @author fenris + * @deprecated + * @todo remove + */ + function generate_for_shape(shape: any): any; + /** + * @author fenris + */ +} +declare namespace lib_plankton.password { + /** + */ + type char = string; + /** + */ + type type_policy = { + minimum_length: (null | int); + maximum_length: (null | int); + must_contain_letter: boolean; + must_contain_number: boolean; + must_contain_special_character: boolean; + }; + /** + */ + enum enum_character_class { + number_ = "number", + letter = "letter", + special = "special" + } +} +declare namespace lib_plankton.password { + /** + */ + function validate(settings: type_policy, password: string): Array<{ + incident: string; + details: Record; + }>; + /** + */ + function generate(policy: type_policy): string; +} declare namespace lib_plankton.object { /** * @author fenris @@ -1841,7 +2535,7 @@ declare namespace lib_plankton.storage.memory { clear(): Promise; write(key: any, value: any): Promise; delete(key: any): Promise; - read(key: any): Promise; + read(key: any): Promise>; search(term: any): Promise<{ key: string; preview: string; @@ -1954,6 +2648,191 @@ declare namespace lib_plankton.cache { encode_input?: ((input: type_input) => string); }): Promise; } +declare namespace lib_plankton.zoo_widget { + /** + */ + interface interface_widget { + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_empty implements interface_widget { + /** + */ + constructor(); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_string implements interface_widget { + /** + */ + private content; + /** + */ + constructor(content: string); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_link implements interface_widget { + /** + */ + private target; + /** + */ + private text; + /** + */ + private open_in_new_tab; + /** + */ + constructor(target: string, { "text": text, "open_in_new_tab": open_in_new_tab, }?: { + text?: (null | string); + open_in_new_tab?: boolean; + }); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_text implements interface_widget { + /** + */ + private paragraphs; + /** + */ + constructor(paragraphs: Array); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_list implements interface_widget { + /** + */ + private elements; + /** + */ + constructor(elements: Array); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel implements interface_widget { + /** + */ + private content; + /** + */ + private collapseable; + /** + */ + private collapsed_initial_value; + /** + */ + private classes; + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + /** + */ + load(target_element: HTMLElement): Promise; + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel_info extends class_panel { + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel_warning extends class_panel { + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel_error extends class_panel { + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_panel_success extends class_panel { + /** + */ + constructor(content: interface_widget, { "collapseable": collapseable, "collapsed_initial_value": collapsed_initial_value, "classes": classes, }?: { + collapseable?: boolean; + collapsed_initial_value?: boolean; + classes?: Array; + }); + } +} +declare namespace lib_plankton.zoo_widget { + /** + */ + class class_bunch implements interface_widget { + /** + */ + private elements; + /** + */ + constructor(elements: Array); + /** + */ + load(target_element: HTMLElement): Promise; + } +} declare namespace lib_plankton.map { /** */ @@ -2729,12 +3608,31 @@ declare namespace lib_plankton.zoo_input { * @author fenris */ class class_input_password implements interface_input { + /** + */ + private exhibit; + /** + */ + private character_hide; + /** + */ + private character_show; /** */ private dom_input; /** */ - constructor(); + private dom_exhibit; + /** + */ + constructor({ "exhibit_initial_value": exhibit_initial_value, "character_hide": character_hide, "character_show": character_show, }?: { + exhibit_initial_value?: boolean; + character_hide?: string; + character_show?: string; + }); + /** + */ + private toggle_exhibition; /** * [implementation] */ @@ -2816,7 +3714,7 @@ declare namespace lib_plankton.zoo_input { name: string; input: interface_input; label?: (null | string); - help?: (null | string); + help?: (null | lib_plankton.zoo_widget.interface_widget); }>); /** * [implementation] @@ -3121,29 +4019,39 @@ declare namespace lib_plankton.zoo_page { /** */ type type_handler = ((parameters: Record, target_element: Element) => void); + /** + */ + type type_nav_entry_definition = { + location: type_location; + label: string; + groups: Array; + }; /** */ export let _pool: Record; /** */ export function encode(location: type_location): string; - /** - */ - export function add_nav_entry(location: type_location, options?: { - label?: (null | string); - }): void; /** * encodes a location in the URL and loads it */ export function set(location: type_location): void; /** */ - export function register(location_name: string, handler: type_handler, options?: {}): void; + export function reload(): Promise; /** */ - export function init(target_element: Element, options?: { + export function register(location_name: string, handler: type_handler): void; + /** + */ + export function nav_set_groups(groups: (null | Array)): void; + /** + */ + export function init(target_element: Element, { "pool": pool, "fallback": fallback, "nav_entries": nav_entries, "nav_initial_groups": nav_initial_groups, }?: { pool?: Record; fallback?: (null | type_location); + nav_entries?: Array; + nav_initial_groups?: (null | Array); }): void; /** */ diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index bab9870..cc41edf 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -1339,6 +1339,14 @@ var lib_plankton; /*window.*/ setTimeout(procedure, Math.floor(delay_in_seconds * 1000))); } call.timeout = timeout; + /** + * @author fenris + */ + function loop(procedure, delay_in_seconds) { + return ( + /*window.*/ setInterval(procedure, Math.floor(delay_in_seconds * 1000))); + } + call.loop = loop; /** * Promise version of "setTimeout" * @@ -2232,7 +2240,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (_) try { + while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -4022,6 +4030,3169 @@ var make_logger = (function () { return make_logger; })(); /* +This file is part of »bacterio-plankton:pair«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:pair« 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:pair« 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:pair«. If not, see . + */ +/* +This file is part of »bacterio-plankton:pair«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:pair« 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:pair« 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:pair«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var pair; + (function (pair_1) { + /** + */ + function swap(pair) { + return { + "first": pair.second, + "second": pair.first + }; + } + pair_1.swap = swap; + /** + */ + function show(pair, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "show_first": instance_show, + "show_second": instance_show + }, options); + return ("(" + + + options.show_first(pair.first) + + + "," + + + options.show_second(pair.second) + + + ")"); + } + pair_1.show = show; + })(pair = lib_plankton.pair || (lib_plankton.pair = {})); +})(lib_plankton || (lib_plankton = {})); +"use strict"; +/* +This file is part of »bacterio-plankton:list«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:list« 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:list« 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:list«. If not, see . + */ +/* +This file is part of »bacterio-plankton:list«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:list« 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:list« 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:list«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var list; + (function (list_1) { + /** + * returns a certain list of integer numbers + */ + function range(from, to, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "step": 1 + }, options); + var list = []; + for (var value = from; value <= to; value += options.step) { + list.push(value); + } + return list; + } + list_1.range = range; + /** + * returns a certain list of consecutiv integer numbers, beginning with 0 + */ + function sequence(length) { + return range(0, length - 1); + } + list_1.sequence = sequence; + /** + */ + function from_iterator(iterator) { + var list = []; + // @ts-ignore + for (var _i = 0, iterator_1 = iterator; _i < iterator_1.length; _i++) { + var element = iterator_1[_i]; + list.push(element); + } + return list; + } + list_1.from_iterator = from_iterator; + /** + */ + function is_empty(list) { + return (list.length <= 0); + } + list_1.is_empty = is_empty; + /** + * combines two lists into one + * + * @param {boolean} [options.cut] whether the result list will be as long as the shortest input list or an exception is thrown if they have different lengths; default: true + */ + function zip(list_first, list_second, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "cut": true + }, options); + var empty_first = is_empty(list_first); + var empty_second = is_empty(list_second); + if (empty_first || empty_second) { + if (options.cut || (empty_first && empty_second)) { + return []; + } + else { + throw (new Error("lists have different lengths")); + } + } + else { + return ([{ "first": list_first[0], "second": list_second[0] }] + .concat(zip(list_first.slice(1), list_second.slice(1), { + "cut": options.cut + }))); + } + } + list_1.zip = zip; + /** + * checks whether two lists are equal + * + * @todo define common function "equals" and default predicate to + */ + function equals(list1, list2, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "collate_element": instance_collate + }, options); + if (list1.length == list2.length) { + return (zip(list1, list2, { "cut": true }) + .every(function (pair) { return options.collate_element(pair.first, pair.second); })); + } + else { + return false; + } + } + list_1.equals = equals; + /** + * creates a list with the elements from the input list, which fulfil a certain predicate (~ filter) + */ + function keep(list, predicate) { + return (list + .filter(function (element, index) { return predicate(element); })); + } + list_1.keep = keep; + /** + * creates a list with the elements from the input list, which do not fulfil a certain predicate (~ dual filter) + */ + function drop(list, predicate) { + return (list + .filter(function (element, index) { return (!predicate(element)); })); + } + list_1.drop = drop; + /** + */ + function filter_inplace(list, predicate) { + var index = 0; + while (index < list.length) { + var element = list[index]; + if (predicate(element)) { + index += 1; + } + else { + list.splice(index, 1); + } + } + } + list_1.filter_inplace = filter_inplace; + /** + * returns a list with no duplicates (like unix' "unique") + */ + function cleaned(list, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "collate_element": instance_collate + }, options); + var list_ = []; + list.forEach(function (element) { + if (!list_.some(function (element_) { return options.collate_element(element, element_); })) { + list_.push(element); + } + else { + // do nothing + } + }); + return list_; + } + list_1.cleaned = cleaned; + /** + * creates a binary partition of the list according to a given predicate + */ + function separate(list, predicate) { + return (list + .reduce(function (seperation, element) { + return (predicate(element) + ? { "yes": seperation.yes.concat([element]), "no": seperation["no"] } + : { "yes": seperation.yes, "no": seperation["no"].concat([element]) }); + }, { "yes": [], "no": [] })); + } + list_1.separate = separate; + ; + /** + */ + function clone(list) { + return keep(list, function (x) { return true; }); + } + list_1.clone = clone; + /** + */ + function reversed(list) { + var list_ = clone(list); + list_.reverse(); + return list_; + } + list_1.reversed = reversed; + /** + * @todo use Array.toSorted? + */ + function sorted(list, options) { + options = Object.assign({ + "compare_element": instance_compare + }, options); + var list_ = clone(list); + list_.sort(function (x, y) { return (options.compare_element(x, y) ? -1 : +1); }); + return list_; + } + list_1.sorted = sorted; + /** + * die Liste in gleich große Blöcke zerlegen + */ + function chop(list, chunk_size) { + var chunks = []; + var index = 0; + while (index < list.length) { + var chunk = list.slice(index, Math.min(list.length, index + chunk_size)); + index += chunk_size; + chunks.push(chunk); + } + return chunks; + } + list_1.chop = chop; + /** + */ + function group(list, collate_element) { + var result = []; + list.forEach(function (element) { + var target = result.find( + // @ts-ignore + function (group) { return collate_element(group[0], element); }); + if (target === undefined) { + target = []; + result.push(target); + } + target.push(element); + }); + return result; + } + list_1.group = group; + /** + */ + function has(list, predicate) { + return (list.find(predicate) !== undefined); + } + list_1.has = has; + /** + * @deprecate use Array.includes or Array.some + */ + function contains(list, element, options) { + options = Object.assign({ + "collate": instance_collate + }, options); + return has(list, function (element_) { return options.collate_element(element_, element); }); + } + list_1.contains = contains; + /** + * retrieves the element and its index of the list, which has the maximum value + */ + function max(list, target_function, options) { + options = Object.assign({ + "compare_value": instance_compare + }, options); + if (is_empty(list)) { + throw (new Error("the max-arg of an empty list is not defined")); + } + else { + return (list + .reduce(function (result, element, index) { + var value = target_function(element); + if ((result == null) + || + (!options.compare_value(value, result.value))) { + return { "index": index, "element": element, "value": value }; + } + else { + return result; + } + }, null)); + } + } + list_1.max = max; + /** + * retrieves the element and its index of the list, which has the mininum value + */ + function min(list, target_function, options) { + options = Object.assign({ + "compare_value": instance_compare + }, options); + return max(list, target_function, { + "compare_value": function (x, y) { return options.compare_value(y, x); } + }); + } + list_1.min = min; + /** + * implements the idea of arithmetic distribution like in "(a+b)·(c+d) = (a·c)+(a·d)+(b·c)+(b·d)" + * example: distribute([[1,2],[3],[4,5,6]]) = [[1,3,4],[1,3,5],[1,3,6],[2,3,4],[2,3,5],[2,3,6]] + */ + function distribute(lists) { + if (is_empty(lists)) { + return [[]]; + } + else { + var subresult_1 = distribute(lists.slice(1)); + return (lists[0] + .map(function (element) { return subresult_1.map(function (list) { return [element].concat(list); }); }) + .reduce(function (x, y) { return x.concat(y); }, [])); + } + } + list_1.distribute = distribute; + /** + */ + function contrast(list_left, extract_key_left, list_right, extract_key_right) { + var gathering = {}; + list_left.forEach(function (source_left) { + var _a; + var key = extract_key_left(source_left); + gathering[key] = Object.assign(((_a = gathering[key]) !== null && _a !== void 0 ? _a : {}), { "left": source_left }); + }); + list_right.forEach(function (source_right) { + var _a; + var key = extract_key_right(source_right); + gathering[key] = Object.assign(((_a = gathering[key]) !== null && _a !== void 0 ? _a : {}), { "right": source_right }); + }); + var result = { + "both": [], + "only_left": [], + "only_right": [] + }; + Object.entries(gathering).forEach(function (_a) { + var key = _a[0], value = _a[1]; + if ("left" in value) { + if ("right" in value) { + result.both.push({ "key": key, "left": value.left, "right": value.right }); + } + else { + result.only_left.push({ "key": key, "left": value.left }); + } + } + else { + if ("right" in value) { + result.only_right.push({ "key": key, "right": value.right }); + } + else { + // impossible + // do nothing + } + } + }); + return result; + } + list_1.contrast = contrast; + })(list = lib_plankton.list || (lib_plankton.list = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_1) { + /** + * @author fenris + */ + function inspection_create() { + return { + "flaws": [], + "sub": [] + }; + } + shape_1.inspection_create = inspection_create; + /** + * @author fenris + */ + function inspection_add(main, flaw) { + main.flaws.push(flaw); + } + shape_1.inspection_add = inspection_add; + /** + * @author fenris + */ + function inspection_extend(main, prefix, sub) { + if ((sub.flaws.length <= 0) + && + (sub.sub.length <= 0)) { + // do nothing + } + else { + main.sub.push({ "position": prefix, "inspection": sub }); + } + } + shape_1.inspection_extend = inspection_extend; + /** + */ + function inspection_flatten(inspection) { + return (inspection.flaws + .concat(inspection.sub + .map((entry) => (inspection_flatten(entry.inspection) + .map(rest => lib_plankton.string.coin("[{{position}}] {{rest}}", { + "position": entry.position, + "rest": rest + })))) + .reduce((x, y) => x.concat(y), []))); + } + /** + */ + var _pool = {}; + /** + * @todo cache + */ + function construct(shape) { + return _pool[shape.kind].construct(shape.parameters); + } + /** + */ + function get_logic(shape) { + if (!(shape.kind in _pool)) { + throw (new Error("missing shape: " + shape.kind)); + } + else { + return _pool[shape.kind].logic(construct(shape)); + } + } + /** + */ + function inspect(shape, value) { + return get_logic(shape).inspect(inspect, value); + } + shape_1.inspect = inspect; + /** + */ + function inspect_flat(shape, value) { + return inspection_flatten(inspect(shape, value)); + } + shape_1.inspect_flat = inspect_flat; + /** + */ + function show(shape) { + return get_logic(shape).show(show); + } + shape_1.show = show; + /** + */ + function to_typescript_type(shape) { + return get_logic(shape).to_typescript_type(to_typescript_type); + } + shape_1.to_typescript_type = to_typescript_type; + /** + */ + function to_jsonschema(shape) { + return get_logic(shape).to_jsonschema(to_jsonschema); + } + shape_1.to_jsonschema = to_jsonschema; + /** + */ + function to_oas_schema(shape) { + return get_logic(shape).to_oas_schema(to_oas_schema); + } + shape_1.to_oas_schema = to_oas_schema; + /** + */ + function example(shape) { + return get_logic(shape).example(example); + } + shape_1.example = example; + /** + */ + function register(name, construct, logic) { + _pool[name] = { + "construct": construct, + "logic": logic, + }; + } + shape_1.register = register; + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_2) { + var any; + (function (any) { + /** + */ + function make(options = {}) { + return {}; + } + any.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_2.inspection_create(); + return inspection; + } + /** + */ + function show(sub_show, subject) { + return "any"; + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + return "any"; + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + return {}; + } + /** + */ + function example(sub_example, subject) { + return null; + } + shape_2.register("any", (parameters) => make({}), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(any = shape_2.any || (shape_2.any = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_3) { + var null_; + (function (null_) { + /** + */ + function make(options = {}) { + return {}; + } + null_.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_3.inspection_create(); + if (!(value === null)) { + shape_3.inspection_add(inspection, "null expected"); + } + else { + // all good + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + return "null"; + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + return "null"; + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + return { + "type": "null", + }; + } + /** + */ + function example(sub_example, subject) { + return null; + } + shape_3.register("null", (parameters) => make({}), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(null_ = shape_3.null_ || (shape_3.null_ = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_4) { + var boolean; + (function (boolean) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + }, options); + return { + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + }; + } + boolean.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_4.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_4.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "boolean"; + if (jstype_actual === jstype_expected) { + // all good + } + else { + shape_4.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = "boolean"; + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = "boolean"; + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "boolean", + }; + return (subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ], + } + : core); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft ? null : false); + } + shape_4.register("boolean", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(boolean = shape_4.boolean || (shape_4.boolean = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_5) { + var integer; + (function (integer) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + "minimum": undefined, + "maximum": undefined, + }, options); + return { + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + "minimum": ((options.minimum === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.minimum)), + "maximum": ((options.minimum === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.maximum)), + }; + } + integer.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_5.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_5.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "number"; + if (!(jstype_actual === jstype_expected)) { + shape_5.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + else { + if (isNaN(parseInt(value))) { + shape_5.inspection_add(inspection, "value is not parsable to a valid int"); + } + else { + // minimum + { + if (!lib_plankton.pod.distinguish(subject.minimum, () => true, x => (value >= x))) { + shape_5.inspection_add(inspection, lib_plankton.string.coin("value is below the minimum of '{{minimum}}'", { + "minimum": lib_plankton.pod.cull(subject.minimum).toFixed(0), + })); + } + else { + // do nothing + } + } + // maximum + { + if (!lib_plankton.pod.distinguish(subject.maximum, () => true, x => (value <= x))) { + shape_5.inspection_add(inspection, lib_plankton.string.coin("value is beyond the maximum of '{{maximum}}'", { + "maximum": lib_plankton.pod.cull(subject.maximum).toFixed(0), + })); + } + else { + // do nothing + } + } + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = "integer"; + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = "number"; + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "integer", + "minimum": lib_plankton.pod.distinguish(subject.minimum, () => undefined, x => x), + "maximum": lib_plankton.pod.distinguish(subject.maximum, () => undefined, x => x), + }; + return (subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ], + } + : core); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft ? null : 0); + } + shape_5.register("integer", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + "minimum": parameters.minimum, + "maximum": parameters.maximum, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(integer = shape_5.integer || (shape_5.integer = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_6) { + var float; + (function (float) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + "minimum": undefined, + "maximum": undefined, + }, options); + return { + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + "minimum": ((options.minimum === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.minimum)), + "maximum": ((options.minimum === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.maximum)), + }; + } + float.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_6.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_6.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "number"; + if (!(jstype_actual === jstype_expected)) { + shape_6.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + else { + if (isNaN(parseInt(value))) { + shape_6.inspection_add(inspection, "value is not parsable to a valid float"); + } + else { + // minimum + { + if (!lib_plankton.pod.distinguish(subject.minimum, () => true, x => (value >= x))) { + shape_6.inspection_add(inspection, lib_plankton.string.coin("value is below the minimum of '{{minimum}}'", { + "minimum": lib_plankton.pod.cull(subject.minimum).toFixed(0), + })); + } + else { + // do nothing + } + } + // maximum + { + if (!lib_plankton.pod.distinguish(subject.maximum, () => true, x => (value <= x))) { + shape_6.inspection_add(inspection, lib_plankton.string.coin("value is beyond the maximum of '{{maximum}}'", { + "maximum": lib_plankton.pod.cull(subject.maximum).toFixed(0), + })); + } + else { + // do nothing + } + } + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = "float"; + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = "number"; + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "float", + "minimum": lib_plankton.pod.distinguish(subject.minimum, () => undefined, x => x), + "maximum": lib_plankton.pod.distinguish(subject.maximum, () => undefined, x => x), + }; + return (subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ], + } + : core); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft ? null : 0); + } + shape_6.register("float", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + "minimum": parameters.minimum, + "maximum": parameters.maximum, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(float = shape_6.float || (shape_6.float = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_7) { + var string; + (function (string) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + "pattern": undefined, + "min_length": undefined, + "max_lenth": undefined, + }, options); + return { + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + "pattern": ((options.pattern === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.pattern)), + "min_length": ((options.min_length === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.min_length)), + "max_length": ((options.max_length === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.max_length)), + }; + } + string.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_7.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_7.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "string"; + if (!(jstype_actual === jstype_expected)) { + shape_7.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + else { + const value_ = value; + // pattern + { + if (!lib_plankton.pod.distinguish(subject.pattern, () => true, x => (new RegExp(x)).test(value_))) { + shape_7.inspection_add(inspection, lib_plankton.string.coin("string does not match the pattern '{{pattern}}'", { + "pattern": lib_plankton.pod.cull(subject.pattern), + })); + } + else { + // do nothing + } + } + // min_length + { + if (!lib_plankton.pod.distinguish(subject.min_length, () => true, x => (value_.length >= x))) { + shape_7.inspection_add(inspection, lib_plankton.string.coin("string is shorter than '{{min_length}}'", { + "min_length": lib_plankton.pod.cull(subject.min_length).toFixed(0), + })); + } + else { + // do nothing + } + } + // max_length + { + if (!lib_plankton.pod.distinguish(subject.max_length, () => true, x => (value_.length <= x))) { + shape_7.inspection_add(inspection, lib_plankton.string.coin("string is longer than '{{max_length}}'", { + "min_length": lib_plankton.pod.cull(subject.max_length).toFixed(0), + })); + } + else { + // do nothing + } + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = "string"; + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = "string"; + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "string", + // TODO: transform? + "pattern": lib_plankton.pod.distinguish(subject.pattern, () => undefined, x => x), + "minLength": lib_plankton.pod.distinguish(subject.min_length, () => undefined, x => x), + "maxLenth": lib_plankton.pod.distinguish(subject.max_length, () => undefined, x => x), + }; + return (subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ], + } + : core); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft ? null : ""); + } + shape_7.register("string", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + "pattern": parameters.pattern, + "min_length": parameters.min_length, + "max_length": parameters.max_length, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_chema) => to_jsonschema(sub_to_oas_chema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(string = shape_7.string || (shape_7.string = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_8) { + var email; + (function (email) { + /** + */ + function make(options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": undefined, + "description": undefined, + }, options); + return { + "core": { + "kind": "string", + "parameters": { + "soft": options.soft, + "defaultvalue": options.defaultvalue, + "description": options.description, + "pattern": "[^@]*@[^@]*", + "min_length": 0, + "max_length": 255, + } + }, + }; + } + email.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + return sub_inspect(subject.core, value); + } + /** + */ + function show(sub_show, subject) { + return sub_show(subject.core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + return sub_to_typescript_type(subject.core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + return sub_to_jsonschema(subject.core); + } + /** + */ + function example(sub_example, subject) { + return sub_example(subject.core); + } + shape_8.register("email", (parameters) => make({ + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_chema) => to_jsonschema(sub_to_oas_chema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(email = shape_8.email || (shape_8.email = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_9) { + var list_; + (function (list_) { + /** + */ + function make(shape_element, options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": lib_plankton.pod.make_empty(), + "description": lib_plankton.pod.make_empty(), + }, options); + return { + "shape_element": shape_element, + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + }; + } + list_.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_9.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_9.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "object"; + if (!(jstype_actual === jstype_expected)) { + lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + }); + } + else { + if (!(value instanceof Array)) { + shape_9.inspection_add(inspection, "value does not seem to be an array-instance"); + } + else { + value.forEach((element, index) => { + shape_9.inspection_extend(inspection, lib_plankton.string.coin("element #{{index}}", { + "index": index.toFixed(0), + }), + // subject.shape_element.inspect(element) + sub_inspect(subject.shape_element, element)); + }); + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = lib_plankton.string.coin("list<{{element}}>", { + "element": sub_show(subject.shape_element), + }); + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = lib_plankton.string.coin("Array<{{element}}>", { + "element": sub_to_typescript_type(subject.shape_element), + }); + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "array", + "items": sub_to_jsonschema(subject.shape_element), + }; + return ((subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ] + } + : core)); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft + ? null + : [ + sub_example(subject.shape_element) + ]); + } + shape_9.register("list", (parameters) => make(parameters.shape_element, { + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(list_ = shape_9.list_ || (shape_9.list_ = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_10) { + var map; + (function (map) { + /** + */ + function make(shape_key, shape_value, options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": lib_plankton.pod.make_empty(), + "description": lib_plankton.pod.make_empty(), + }, options); + return { + "shape_key": shape_key, + "shape_value": shape_value, + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + }; + } + map.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_10.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_10.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "object"; + if (!(jstype_actual === jstype_expected)) { + lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + }); + } + else { + Object.entries(value) + .forEach(([key, value]) => { + shape_10.inspection_extend(inspection, lib_plankton.string.coin("key '{{key}}'", { + "key": String(key), + }), sub_inspect(subject.shape_key, key)); + shape_10.inspection_extend(inspection, lib_plankton.string.coin("value for '{{key}}'", { + "key": String(key), + }), sub_inspect(subject.shape_value, value)); + }); + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = lib_plankton.string.coin("map<{{key}},{{value}}>", { + "key": sub_show(subject.shape_key), + "value": sub_show(subject.shape_value), + }); + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = lib_plankton.string.coin("Record<{{key}},{{value}}>", { + "key": sub_to_typescript_type(subject.shape_key), + "value": sub_to_typescript_type(subject.shape_key), + }); + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "object", + "additionalProperties": sub_to_jsonschema(subject.shape_value), + "properties": {}, + "required": [], + }; + return ((subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ] + } + : core)); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft + ? null + : {}); + } + shape_10.register("map", (parameters) => make(parameters.shape_key, parameters.shape_value, { + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(map = shape_10.map || (shape_10.map = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:shape«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:shape« 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:shape« 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:shape«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var shape; + (function (shape_11) { + var record; + (function (record) { + /** + */ + function make(fields_raw, options = {}) { + options = Object.assign({ + "soft": false, + "defaultvalue": lib_plankton.pod.make_empty(), + "description": lib_plankton.pod.make_empty(), + }, options); + return { + "fields": fields_raw.map(field_raw => ({ + "name": field_raw.name, + "shape": field_raw.shape, + "required": (field_raw.required ?? true) + })), + "soft": options.soft, + "defaultvalue": ((options.defaultvalue === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.defaultvalue)), + "description": ((options.description === undefined) + ? lib_plankton.pod.make_empty() + : lib_plankton.pod.make_filled(options.description)), + }; + } + record.make = make; + /** + */ + function inspect(sub_inspect, subject, value) { + let inspection = shape_11.inspection_create(); + if (value === null) { + if (subject.soft) { + // all good + } + else { + shape_11.inspection_add(inspection, "null is not allowed"); + } + } + else { + const jstype_actual = typeof (value); + const jstype_expected = "object"; + if (!(jstype_actual === jstype_expected)) { + shape_11.inspection_add(inspection, lib_plankton.string.coin("expected JS-type '{{expected}}' but got '{{actual}}'", { + "expected": jstype_expected, + "actual": jstype_actual, + })); + } + else { + subject.fields.forEach(field => { + if (!(field.name in value)) { + if (field.required) { + shape_11.inspection_add(inspection, "missing field '" + field.name + "'"); + } + else { + // do nothing + } + } + else { + const value_ = value[field.name]; + shape_11.inspection_extend(inspection, ("field '" + field.name + "'"), sub_inspect(field.shape, value_)); + } + }); + // extra fields + { + const allowed = subject.fields.map(field => field.name); + (Object.keys(value) + .filter(name => (!allowed.includes(name))) + .forEach(name => { + shape_11.inspection_add(inspection, "extra field '" + name + "'"); + })); + } + } + } + return inspection; + } + /** + */ + function show(sub_show, subject) { + const core = lib_plankton.string.coin("record<{{fields}}>", { + "fields": (subject.fields + .map(field => lib_plankton.string.coin("{{prefix}}{{name}}:{{shape}}", { + "prefix": (field.required ? "" : "?"), + "name": field.name, + "shape": sub_show(field.shape), + })) + .join(",")), + }); + return (subject.soft ? ("~" + core) : core); + } + /** + */ + function to_typescript_type(sub_to_typescript_type, subject) { + const core = lib_plankton.string.coin("{{{fields}}}", { + "fields": (subject.fields + .map(field => lib_plankton.string.coin("{{name}}{{infix}}{{shape}}", { + "name": field.name, + "infix": (field.required ? ":" : "?:"), + "shape": sub_to_typescript_type(field.shape), + })) + .join(";")), + }); + return (subject.soft ? ("(null | " + core + ")") : core); + } + /** + */ + function to_jsonschema(sub_to_jsonschema, subject) { + const common = { + "description": lib_plankton.pod.distinguish(subject.description, () => undefined, x => x), + "default": lib_plankton.pod.distinguish(subject.defaultvalue, () => undefined, x => x), + }; + const core = { + "type": "object", + "additionalProperties": false, + "properties": (Object.fromEntries(subject.fields + .map(field => ([ + field.name, + sub_to_jsonschema(field.shape) + ])))), + "required": (subject.fields + .filter(field => field.required) + .map(field => field.name)), + }; + return ((subject.soft + ? { + "anyOf": [ + Object.assign({ "type": "null" }, common), + Object.assign(core, common), + ] + } + : core)); + } + /** + */ + function example(sub_example, subject) { + return (subject.soft + ? null + : (Object.fromEntries(subject.fields + .filter(field => field.required) + .map(field => ([ + field.name, + sub_example(field.shape) + ]))))); + } + shape_11.register("record", (parameters) => make((parameters.fields + .map(field_raw => ({ + "name": field_raw.name, + "shape": field_raw.shape, + "required": field_raw.required, + }))), { + "soft": parameters.soft, + "description": parameters.description, + "defaultvalue": parameters.defaultvalue, + }), (subject) => ({ + "inspect": (sub_inspect, value) => inspect(sub_inspect, subject, value), + "show": (sub_show) => show(sub_show, subject), + "to_typescript_type": (sub_to_typescript_type) => to_typescript_type(sub_to_typescript_type, subject), + "to_jsonschema": (sub_to_jsonschema) => to_jsonschema(sub_to_jsonschema, subject), + "to_oas_schema": (sub_to_oas_schema) => to_jsonschema(sub_to_oas_schema, subject), + "example": (sub_example) => example(sub_example, subject), + })); + })(record = shape_11.record || (shape_11.record = {})); + })(shape = lib_plankton.shape || (lib_plankton.shape = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:www_form«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:www_form« 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:www_form« 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:www_form«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var www_form; + (function (www_form) { + /** + * @author fenris + */ + function encode(source) { + return (Object.entries(source) + .map(function (_a) { + var key = _a[0], value = _a[1]; + return (key + "=" + encodeURIComponent(value)); + }) + .join("&")); + } + www_form.encode = encode; + /** + * @author fenris + */ + function decode(target) { + return (Object.fromEntries(target.split("&") + .map(function (part) { + var components = part.split("="); + var key = components[0]; + var value = decodeURIComponent(components.slice(1).join("=")); + return [key, value]; + }))); + } + www_form.decode = decode; + })(www_form = lib_plankton.www_form || (lib_plankton.www_form = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:www_form«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:www_form« 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:www_form« 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:www_form«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var www_form; + (function (www_form) { + /** + * @author fenris + */ + var class_www_form = /** @class */ (function () { + /** + * @author fenris + */ + function class_www_form() { + } + /** + * @implementation + * @author fenris + */ + class_www_form.prototype.encode = function (source) { + return www_form.encode(source); + }; + /** + * @implementation + * @author fenris + */ + class_www_form.prototype.decode = function (target) { + return www_form.decode(target); + }; + return class_www_form; + }()); + www_form.class_www_form = class_www_form; + })(www_form = lib_plankton.www_form || (lib_plankton.www_form = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:url«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:url« 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:url« 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:url«. If not, see . + */ +/* +This file is part of »bacterio-plankton:url«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:url« 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:url« 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:url«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var url; + (function (url_1) { + /** + * @author fenris + */ + function encode(url) { + let result = ""; + // scheme + { + if (url.scheme !== null) { + result += (url.scheme + ":"); + } + } + // host + { + if (url.host !== null) { + result += "//"; + // username + { + if (url.username !== null) { + result += url.username; + // password + { + if (url.password !== null) { + result += (":" + url.password); + } + } + result += "@"; + } + } + result += url.host; + } + } + // port + { + if (url.port !== null) { + result += (":" + url.port.toString()); + } + } + // path + { + if (url.path !== null) { + result += url.path; + } + } + // query + { + if (url.query !== null) { + result += ("?" + url.query); + } + } + // hash + { + if (url.hash !== null) { + result += ("#" + url.hash); + } + } + return result; + } + url_1.encode = encode; + /** + * @author fenris + * @todo arguments + */ + function decode(url_raw) { + const builtin_url = new URL(url_raw); + return { + "scheme": builtin_url.protocol.slice(0, -1), + "host": builtin_url.hostname, + "username": ((builtin_url.username !== "") + ? + builtin_url.username + : + null), + "password": ((builtin_url.password !== "") + ? + builtin_url.password + : + null), + "port": ((builtin_url.port !== "") + ? + parseInt(builtin_url.port) + : + null), + "path": builtin_url.pathname, + "query": builtin_url.search.slice(1), + "hash": ((builtin_url.hash !== "") + ? + builtin_url.hash.slice(1) + : + null), + }; + } + url_1.decode = decode; + /** + * @author fenris + */ + function implementation_code() { + return { + "encode": encode, + "decode": decode, + }; + } + url_1.implementation_code = implementation_code; + })(url = lib_plankton.url || (lib_plankton.url = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:url«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:url« 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:url« 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:url«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var url; + (function (url) { + /** + * @author fenris + */ + class class_url { + /** + * @author fenris + */ + constructor() { + } + /** + * @implementation + * @author fenris + */ + encode(x) { + return url.encode(x); + } + /** + * @implementation + * @author fenris + */ + decode(x) { + return url.decode(x); + } + } + url.class_url = class_url; + })(url = lib_plankton.url || (lib_plankton.url = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:random«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:random« 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:random« 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:random«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var random; + (function (random) { + /** + * @author fenris + */ + function sequence(n) { + return ((n <= 0) ? [] : sequence(n - 1).concat([n - 1])); + } + /** + * @author fenris + */ + function interpolate(x, y, t) { + return (((1 - t) * x) + (t * y)); + } + /** + * @author fenris + */ + var _statestack = [ + { + "builtin": true, + "seed": Date.now() + }, + ]; + /** + * @author fenris + */ + function state_get() { + return _statestack[_statestack.length - 1]; + } + /** + * @author fenris + */ + function state_push(state) { + _statestack.push(state); + } + random.state_push = state_push; + /** + * @author fenris + */ + function state_pop() { + if (_statestack.length <= 1) { + throw (new Error("no state to pop")); + } + else { + return _statestack.pop(); + } + } + random.state_pop = state_pop; + /** + * @author fenris + */ + function seed_tick() { + var state = state_get(); + state.seed = ((state.seed << 8) % 99767); + } + /** + * @author fenris + */ + function seed_get(tick) { + if (tick === void 0) { tick = true; } + if (tick) { + seed_tick(); + } + else { + // do nothing + } + return state_get().seed; + } + /** + * returns a random floating point number in the interval [0,1[ + * + * @author fenris + */ + function generate_unit() { + if (state_get().builtin) { + return Math.random(); + } + else { + return ((Math.sin(seed_get() << 8) + 1) / 2); + } + } + random.generate_unit = generate_unit; + /** + * returns a random boolean value + * + * @param {float} [probability] the probability for the return-value "true"; default: 0.5 + * @author fenris + */ + function generate_boolean(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "probability": 0.5 + }, options); + return (generate_unit() < options.probability); + } + random.generate_boolean = generate_boolean; + /** + * returns a random integer number in the interval [a,b] + * + * @param {int} [minimum] the left side of the halfopen interval (i.e. the smallest included value in the range) + * @param {int} [minimum] the right side of the halfopen interval (i.e. the smallest excluded value in the range) + * @author fenris + */ + function generate_integer(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "minimum": 0, + "maximum": ((1 << 16) - 1) + }, options); + return Math.floor(interpolate(options.minimum, options.maximum + 1, generate_unit())); + } + random.generate_integer = generate_integer; + random.generate_int = generate_integer; + /** + * returns a random floating point number in the given interval + * + * @author fenris + */ + function generate_float(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "minimum": 0.0, + "maximum": 1.0 + }, options); + return interpolate(options.minimum, options.maximum, generate_unit()); + } + random.generate_float = generate_float; + /** + * returns a random date + * + * @author fenris + */ + function generate_date(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "minimum": new Date(0), + "maximum": new Date(Date.now()) + }, options); + return (new Date(generate_integer({ + "minimum": options.minimum.getTime(), + "maximum": options.maximum.getTime() + }))); + } + random.generate_date = generate_date; + /** + * @author fenris + */ + function generate_hexdigit() { + return (this.generate_integer({ "minimum": 0, "maximum": 15 }).toString(16).toUpperCase()); + } + random.generate_hexdigit = generate_hexdigit; + /** + * generates a random string with an optional prefix + * + * @author fenris + */ + function generate_string(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "length": 8 + }, options); + return (sequence(options.length) + .map(function (x) { return generate_integer({ "minimum": 65, "maximum": 90 }); }) + .map(function (x) { return String.fromCharCode(x); }) + .join("") + .toLowerCase()); + } + random.generate_string = generate_string; + /** + * chooses a value randomly from a list of values with weights (a higher weight means a higher probability to be chosen) + * + * @author fenris + */ + function choose_weighted(sets) { + var sum = sets.reduce(function (sum, set_) { return (sum + set_.weight); }, 0); + if (sum === 0) { + throw (new Error("weights sum up to zero; are all zero or are negative weights included?")); + } + else { + var position_1 = generate_unit(); + return (sets.reduce(function (current, set_) { + var next = { "index": null, "value": null }; + next.index = (current.index + (set_.weight / sum)); + next.value = (((current.index <= position_1) && (position_1 < next.index)) + ? set_.value + : current.value); + return next; + }, { "index": 0, "value": null }).value); + } + } + random.choose_weighted = choose_weighted; + /** + * chooses a value randomly from a list of values with equal probabilities + * + * @author fenris + */ + function choose_uniformly(values) { + return (choose_weighted(values.map(function (value) { return ({ "weight": 1, "value": value }); }))); + } + random.choose_uniformly = choose_uniformly; + /** + * @author fenris + */ + function shuffle(list) { + var list_ = []; + list.forEach(function (element) { + var index = generate_integer({ "minimum": 0, "maximum": list_.length }); + list_.splice(index, 0, element); + }); + return list_; + } + random.shuffle = shuffle; + /** + * @author fenris + */ + function generate_vowel() { + return (choose_weighted([ + { "weight": 1.0, "value": "u" }, + { "weight": 4.0, "value": "o" }, + { "weight": 6.0, "value": "a" }, + { "weight": 4.0, "value": "e" }, + { "weight": 1.0, "value": "i" }, + ])); + } + random.generate_vowel = generate_vowel; + /** + * @author fenris + */ + function generate_halfvowel() { + return (choose_weighted([ + { "weight": 4.0, "value": "y" }, + { "weight": 1.0, "value": "w" }, + ])); + } + random.generate_halfvowel = generate_halfvowel; + /** + * @author fenris + */ + function generate_consonant() { + return (choose_weighted([ + { "weight": 5.0, "value": "l" }, + { "weight": 5.0, "value": "m" }, + { "weight": 5.0, "value": "n" }, + { "weight": 4.0, "value": "b" }, + { "weight": 4.0, "value": "p" }, + { "weight": 4.0, "value": "d" }, + { "weight": 2.0, "value": "dj" }, + { "weight": 4.0, "value": "t" }, + { "weight": 2.0, "value": "tc" }, + { "weight": 4.0, "value": "g" }, + { "weight": 4.0, "value": "k" }, + { "weight": 3.0, "value": "v" }, + { "weight": 3.0, "value": "f" }, + { "weight": 3.0, "value": "z" }, + { "weight": 3.0, "value": "s" }, + { "weight": 3.0, "value": "j" }, + { "weight": 3.0, "value": "c" }, + { "weight": 2.0, "value": "r" }, + { "weight": 1.0, "value": "h" }, + { "weight": 1.0, "value": "x" }, + ])); + } + random.generate_consonant = generate_consonant; + /** + * @author fenris + */ + function generate_letter() { + return choose_uniformly([ + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + ]); + } + random.generate_letter = generate_letter; + /** + * @author fenris + */ + function generate_syllable() { + return (generate_consonant() + + + generate_vowel() + + + (generate_boolean({ "probability": 1 / 8 }) + ? generate_halfvowel() + : "") + + + (generate_boolean({ "probability": 1 / 4 }) + ? generate_consonant() + : "")); + } + random.generate_syllable = generate_syllable; + /** + * @author fenris + */ + function generate_word(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "syllable_count_minimum": 2, + "syllable_count_maximum": 5 + }, options); + return (sequence(generate_integer({ + "minimum": options.syllable_count_minimum, + "maximum": options.syllable_count_maximum + })) + .map(function (x) { return generate_syllable(); }) + .join("")); + } + random.generate_word = generate_word; + /** + * @author fenris + */ + function generate_text(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "word_count": generate_integer({ "minimum": 20, "maximum": 80 }) + }, options); + return sequence(options.word_count).map(function (x) { return generate_word(); }).join(" "); + } + random.generate_text = generate_text; + /** + * @author fenris + */ + function generate_city() { + var str = ( + // prefix + (generate_boolean({ "probability": 0.25 }) + ? choose_uniformly([ + "unter", + "ober", + "mittel", + "groß", + "klein", + "neu", + "alt", + ]) + : "") + + + // infix + choose_uniformly([ + "stein", + "frei", + "berns", + "kirch", + "fels", + "weiden", + "buchen", + "eichen", + "eiben", + "linden", + "ulmen", + "birken", + "eschen", + "erlen", + "grün", + "kreuz", + "wald", + "reichen", + "lieben", + "schön", + "heinrichs", + "friedrichs", + "johann", + "walters", + "günthers", + "rupperts", + "wilhems", + "albert", + ]) + + + // suffix + choose_uniformly([ + "feld", + "thal", + "berg", + "burg", + "stadt", + "dorf", + "heim", + "bach", + "au", + "rode", + "ing", + "nitz", + "hausen", + ])); + return (str[0].toUpperCase() + str.substring(1)); + } + random.generate_city = generate_city; + /** + * @author fenris + */ + function generate_street() { + var str = ( + // prefix + choose_uniformly([ + "haupt", + "neben", + "bahnhof", + "markt", + "augustus", + "wilhelm", + "albert", + "friedrich", + "maximilian", + "wagner", + "linden", + "eichen", + "buchen", + "tannen", + "pappel", + "ulmen", + "eschen", + ]) + + + // core + choose_uniformly([ + "straße", + "weg", + "allee", + "pfad", + "hain", + "anger", + "passage", + "platz", + ]) + + + // number + (" " + generate_integer({ "minimum": 1, "maximum": 80 }).toString())); + return (str[0].toUpperCase() + str.substring(1)); + } + random.generate_street = generate_street; + /** + * @author fenris + */ + function generate_guid(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "with_braces": false + }, options); + /* + return ( + [8,4,4,4,12] + .map(length => sequence(length).map(_ => this.generate_hexdigit()).join("")) + .join("-") + ); + */ + var guid = ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(new RegExp("[xy]", "g"), function (symbol) { + var r = generate_integer({ "minimum": 0, "maximum": 15 }); + var v = ((symbol == "y") ? ((r & 0x3) | 0x8) : r); + return (v.toString(16).toUpperCase()); + })); + return (options.with_braces + ? ("{" + guid + "}") + : guid); + } + random.generate_guid = generate_guid; + /** + * @author fenris + */ + function generate_domain(options) { + if (options === void 0) { options = {}; } + options = lib_plankton.base.object_merge({ + "steps": 3 + }, options); + return (sequence(generate_integer({ "minimum": 1, "maximum": options.steps })) + .map(function () { return generate_word(); }) + // tld + .concat(sequence(generate_integer({ "minimum": 2, "maximum": 3 })) + .map(function () { return generate_letter(); }) + .join(""))).join("."); + } + /** + * @author fenris + */ + function generate_url() { + return (lib_plankton.url.encode({ + "scheme": choose_uniformly([ + "http", + "https", + "git", + "smb", + "ftp", + ]), + "host": generate_domain(), + "username": null, + "password": null, + "port": generate_integer({ "minimum": 20, "maximum": 99999 }), + "path": ("/" + + + (sequence(generate_integer({ "minimum": 0, "maximum": 3 })) + .map(function () { return generate_word(); }) + .join("/"))), + "query": choose_uniformly([ + null, + lib_plankton.www_form.encode(Object.fromEntries(sequence(generate_integer({ "minimum": 0, "maximum": 3 })) + .map(function () { return ([ + generate_word(), + generate_integer().toFixed(0), + ]); }))), + ]), + "hash": null + })); + } + random.generate_url = generate_url; + /** + * @author fenris + */ + function generate_email_address() { + return ( + // user + generate_word() + + + "@" + + + generate_domain({ "steps": 1 })); + } + random.generate_email_address = generate_email_address; + /** + * @author fenris + */ + function generate_telephone_number() { + return ( + // country prefix + ("+" + + + generate_integer({ "minimum": 1, "maximum": 999 }).toFixed(0)) + + + " " + + + // provider + +(sequence(3) + .map(function () { return generate_integer({ "minimum": 0, "maximum": 9 }); }) + .join("")) + + + " " + + + // custom + +(sequence(7) + .map(function () { return generate_integer({ "minimum": 0, "maximum": 9 }); }) + .join(""))); + } + random.generate_telephone_number = generate_telephone_number; + /** + * @author fenris + */ + function generate_time() { + return { + "hour": generate_integer({ "minimum": 0, "maximum": 23 }), + "minute": generate_integer({ "minimum": 0, "maximum": 59 }), + "second": generate_integer({ "minimum": 0, "maximum": 59 }) + }; + } + random.generate_time = generate_time; + /** + * @author fenris + * @deprecated + * @todo remove + */ + function generate_for_shape(shape) { + throw (new Error("deprecated! use lib_shape!")); + } + random.generate_for_shape = generate_for_shape; + /** + * @author fenris + */ + /* + export function generate_for_shape_( + shape : lib_plankton.shape.type_shape + ) : any + { + switch (shape.name) { + case "boolean": { + return generate_boolean(); + break; + } + case "int": { + const min = shape.parameters["min"]; + const max = shape.parameters["max"]; + return generate_integer( + { + "minimum": ((min == null) ? undefined : min), + "maximum": ((max == null) ? undefined : max), + } + ); + break; + } + case "float": { + return generate_float( + { + "minimum": shape.parameters["min"], + "maximum": shape.parameters["max"], + } + ); + break; + } + case "string": { + return generate_string(); + break; + } + case "url": { + return generate_url(); + break; + } + case "email": { + return generate_email_address(); + break; + } + case "time": { + return generate_time(); + break; + } + case "array": { + return ( + sequence(generate_integer({"minimum": 2, "maximum": 5})) + .map(() => generate_for_shape_(shape.parameters["shape_element"])) + ); + break; + } + case "object": { + return Object.fromEntries( + shape.parameters["fields"] + .map( + field => ([ + field["name"], + generate_for_shape_(field["shape"]), + ]) + ) + ); + break; + } + case "date": { + return generate_date(); + break; + } + case "enumeration": { + return choose_uniformly(shape.parameters["options"])["value"]; + break; + } + default: { + const message : string = `unhandled shape kind '${shape.name}'`; + // console.warn(message); + // return null; + throw (new Error(message)); + break; + } + } + } + */ + })(random = lib_plankton.random || (lib_plankton.random = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:password«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:password« 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:password« 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:password«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var password; + (function (password) { + /** + */ + let enum_character_class; + (function (enum_character_class) { + enum_character_class["number_"] = "number"; + enum_character_class["letter"] = "letter"; + enum_character_class["special"] = "special"; + })(enum_character_class = password.enum_character_class || (password.enum_character_class = {})); + })(password = lib_plankton.password || (lib_plankton.password = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:password«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:password« 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:password« 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:password«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var password; + (function (password_1) { + /** + */ + const character_classification = { + [password_1.enum_character_class.number_]: [ + 0x30, + 0x31, + 0x32, + 0x33, + 0x34, + 0x35, + 0x36, + 0x37, + 0x38, + 0x39, + ], + [password_1.enum_character_class.letter]: [ + 0x41, + 0x42, + 0x43, + 0x44, + 0x45, + 0x46, + 0x47, + 0x48, + 0x49, + 0x4A, + 0x4B, + 0x4C, + 0x4D, + 0x4E, + 0x4F, + 0x50, + 0x51, + 0x52, + 0x53, + 0x54, + 0x55, + 0x56, + 0x56, + 0x58, + 0x59, + 0x5A, + 0x61, + 0x62, + 0x63, + 0x64, + 0x65, + 0x66, + 0x67, + 0x68, + 0x69, + 0x6A, + 0x6B, + 0x6C, + 0x6D, + 0x6E, + 0x6F, + 0x70, + 0x71, + 0x72, + 0x73, + 0x74, + 0x75, + 0x76, + 0x77, + 0x78, + 0x79, + 0x7A, + ], + [password_1.enum_character_class.special]: [ + 0x20, + 0x21, + 0x22, + 0x23, + 0x24, + 0x25, + 0x26, + 0x27, + 0x28, + 0x29, + 0x2A, + 0x2B, + 0x2C, + 0x2D, + 0x2E, + 0x2F, + 0x3A, + 0x3B, + 0x3C, + 0x3D, + 0x3E, + 0x3F, + 0x40, + 0x5B, + 0x5C, + 0x5D, + 0x5E, + 0x5F, + 0x60, + 0x7B, + 0x7C, + 0x7D, + 0x7E, + ], + }; + /** + */ + function character_is_number(character) { + if (character.length !== 1) { + throw (new Error("not a character")); + } + else { + const code = character.charCodeAt(0); + return character_classification[password_1.enum_character_class.number_].includes(code); + } + } + /** + */ + function character_is_letter(character) { + if (character.length !== 1) { + throw (new Error("not a character")); + } + else { + const code = character.charCodeAt(0); + return character_classification[password_1.enum_character_class.letter].includes(code); + } + } + /** + */ + function character_is_special(character) { + if (character.length !== 1) { + throw (new Error("not a character")); + } + else { + const code = character.charCodeAt(0); + return character_classification[password_1.enum_character_class.special].includes(code); + } + } + /** + */ + function validate(settings, password) { + let flaws = []; + const characters = password.split(""); + if ((settings.minimum_length !== null) + && + (password.length < settings.minimum_length)) { + flaws.push({ + "incident": "too_short", + "details": { + "minimum_length": settings.minimum_length, + "actual_length": password.length, + } + }); + } + if ((settings.maximum_length !== null) + && + (password.length > settings.maximum_length)) { + flaws.push({ + "incident": "too_long", + "details": { + "maximum_length": settings.maximum_length, + "actual_length": password.length, + } + }); + } + if (settings.must_contain_letter + && + (!characters.some(character => character_is_letter(character)))) { + flaws.push({ + "incident": "lacks_letter", + "details": {} + }); + } + if (settings.must_contain_number + && + (!characters.some(character => character_is_number(character)))) { + flaws.push({ + "incident": "lacks_number", + "details": {} + }); + } + if (settings.must_contain_special_character + && + (!characters.some(character => character_is_special(character)))) { + flaws.push({ + "incident": "lacks_special_character", + "details": {} + }); + } + return flaws; + } + password_1.validate = validate; + /** + */ + function generate(policy) { + const count_number = (policy.must_contain_number ? 1 : 0); + const count_special = (policy.must_contain_special_character ? 1 : 0); + const count_letter_raw = ((policy.minimum_length ?? 8) - count_number - count_special); + const count_letter = ((policy.must_contain_letter && (count_letter_raw <= 0)) ? 1 : count_letter_raw); + if ((policy.maximum_length !== null) + && + ((count_letter + count_number + count_special) > policy.maximum_length)) { + throw (new Error("impossible")); + } + else { + return lib_plankton.call.convey(([] + .concat(lib_plankton.list.sequence(count_letter) + .map(x => lib_plankton.random.choose_uniformly(character_classification[password_1.enum_character_class.letter]))) + .concat(lib_plankton.list.sequence(count_number) + .map(x => lib_plankton.random.choose_uniformly(character_classification[password_1.enum_character_class.number_]))) + .concat(lib_plankton.list.sequence(count_special) + .map(x => lib_plankton.random.choose_uniformly(character_classification[password_1.enum_character_class.special])))), [ + (lib_plankton.random.shuffle), + (x) => x.map(y => String.fromCharCode(y)), + (x) => x.join(""), + ]); + } + } + password_1.generate = generate; + })(password = lib_plankton.password || (lib_plankton.password = {})); +})(lib_plankton || (lib_plankton = {})); +/* This file is part of »bacterio-plankton:object«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -5343,6 +8514,525 @@ var lib_plankton; })(cache = lib_plankton.cache || (lib_plankton.cache = {})); })(lib_plankton || (lib_plankton = {})); /* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_empty { + /** + */ + constructor() { + } + /** + */ + load(target_element) { + return Promise.resolve(undefined); + } + } + zoo_widget.class_empty = class_empty; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_string { + /** + */ + constructor(content) { + this.content = content; + } + /** + */ + load(target_element) { + const dom_element = document.createElement("span"); + dom_element.classList.add("widget-string"); + dom_element.textContent = this.content; + target_element.appendChild(dom_element); + return Promise.resolve(undefined); + } + } + zoo_widget.class_string = class_string; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_link { + /** + */ + constructor(target, { "text": text = null, "open_in_new_tab": open_in_new_tab = false, } = {}) { + this.target = target; + this.text = text; + this.open_in_new_tab = open_in_new_tab; + } + /** + */ + load(target_element) { + const dom_element = document.createElement("a"); + dom_element.classList.add("widget-link"); + dom_element.textContent = (this.text ?? this.target); + dom_element.setAttribute("href", this.target); + dom_element.setAttribute("target", this.open_in_new_tab ? "_blank" : "_self"); + target_element.appendChild(dom_element); + return Promise.resolve(undefined); + } + } + zoo_widget.class_link = class_link; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_text { + /** + */ + constructor(paragraphs) { + this.paragraphs = paragraphs; + } + /** + */ + load(target_element) { + const dom_container = document.createElement("div"); + dom_container.classList.add("widget-text"); + this.paragraphs.forEach(paragraph => { + const dom_paragraph = document.createElement("p"); + dom_paragraph.textContent = paragraph; + dom_container.appendChild(dom_paragraph); + }); + target_element.appendChild(dom_container); + return Promise.resolve(undefined); + } + } + zoo_widget.class_text = class_text; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_list { + /** + */ + constructor(elements) { + this.elements = elements; + } + /** + */ + async load(target_element) { + const dom_ul = document.createElement("ul"); + dom_ul.classList.add("widget-list"); + for (const element of this.elements) { + const dom_li = document.createElement("li"); + dom_li.classList.add("widget-list-element"); + await element.load(dom_li); + dom_ul.appendChild(dom_li); + } + target_element.appendChild(dom_ul); + } + } + zoo_widget.class_list = class_list; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + this.content = content; + this.collapseable = collapseable; + this.collapsed_initial_value = collapsed_initial_value; + this.classes = classes; + } + /** + */ + async load(target_element) { + const dom_container = document.createElement("div"); + dom_container.classList.add("widget-panel"); + this.classes.forEach(class_ => { + dom_container.classList.add(class_); + }); + // vertical rule + { + const dom_rule = document.createElement("div"); + dom_rule.classList.add("widget-panel-rule"); + if (!this.collapseable) { + // do nothing + } + else { + dom_rule.addEventListener("click", () => { + dom_container.classList.toggle("widget-panel-collapsed"); + }); + } + dom_container.classList.toggle("widget-panel-collapsed", this.collapsed_initial_value); + dom_container.appendChild(dom_rule); + } + // content + { + const dom_content = document.createElement("div"); + dom_content.classList.add("widget-panel-content"); + await this.content.load(dom_content); + dom_container.appendChild(dom_content); + } + target_element.appendChild(dom_container); + } + } + zoo_widget.class_panel = class_panel; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel_info extends zoo_widget.class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + super(content, { + "collapseable": collapseable, + "collapsed_initial_value": collapsed_initial_value, + "classes": ["widget-panel_info"].concat(classes), + }); + } + } + zoo_widget.class_panel_info = class_panel_info; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel_warning extends zoo_widget.class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + super(content, { + "collapseable": collapseable, + "collapsed_initial_value": collapsed_initial_value, + "classes": ["widget-panel_warning"].concat(classes), + }); + } + } + zoo_widget.class_panel_warning = class_panel_warning; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel_error extends zoo_widget.class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + super(content, { + "collapseable": collapseable, + "collapsed_initial_value": collapsed_initial_value, + "classes": ["widget-panel_error"].concat(classes), + }); + } + } + zoo_widget.class_panel_error = class_panel_error; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_panel_success extends zoo_widget.class_panel { + /** + */ + constructor(content, { "collapseable": collapseable = true, "collapsed_initial_value": collapsed_initial_value = false, "classes": classes = [], } = {}) { + super(content, { + "collapseable": collapseable, + "collapsed_initial_value": collapsed_initial_value, + "classes": ["widget-panel_success"].concat(classes), + }); + } + } + zoo_widget.class_panel_success = class_panel_success; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-widget«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-widget« 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:zoo-widget« 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:zoo-widget«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_widget; + (function (zoo_widget) { + /** + */ + class class_bunch { + /** + */ + constructor(elements) { + this.elements = elements; + } + /** + */ + async load(target_element) { + const dom_container = document.createElement("div"); + dom_container.classList.add("widget-bunch"); + for (const element of this.elements) { + const dom_li = document.createElement("li"); + await element.load(dom_li); + dom_container.appendChild(dom_li); + } + target_element.appendChild(dom_container); + } + } + zoo_widget.class_bunch = class_bunch; + })(zoo_widget = lib_plankton.zoo_widget || (lib_plankton.zoo_widget = {})); +})(lib_plankton || (lib_plankton = {})); +/* This file is part of »bacterio-plankton:map«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -7551,16 +11241,56 @@ var lib_plankton; class class_input_password { /** */ - constructor() { + constructor({ "exhibit_initial_value": exhibit_initial_value = false, "character_hide": character_hide = "~", "character_show": character_show = "o", } = {}) { + this.exhibit = exhibit_initial_value; + this.character_hide = character_hide; + this.character_show = character_show; this.dom_input = null; + this.dom_exhibit = null; + } + /** + */ + toggle_exhibition({ "value": value = null, } = {}) { + this.exhibit = ((value !== null) + ? + value + : + (!this.exhibit)); + this.dom_exhibit.textContent = (this.exhibit + ? + this.character_hide + : + this.character_show); + this.dom_input.setAttribute("type", (this.exhibit + ? + "text" + : + "password")); } /** * [implementation] */ setup(parent) { - this.dom_input = document.createElement("input"); - this.dom_input.setAttribute("type", "password"); - parent.appendChild(this.dom_input); + const dom_container = document.createElement("div"); + dom_container.classList.add("plankton_input_password_container"); + // input + { + this.dom_input = document.createElement("input"); + this.dom_input.setAttribute("type", "password"); + this.dom_input.classList.add("plankton_input_password_input"); + dom_container.appendChild(this.dom_input); + } + // exhibit + { + this.dom_exhibit = document.createElement("button"); + this.dom_exhibit.classList.add("plankton_input_password_exhibit"); + this.dom_exhibit.addEventListener("click", () => { + this.toggle_exhibition(); + }); + dom_container.appendChild(this.dom_exhibit); + } + parent.appendChild(dom_container); + this.toggle_exhibition({ "value": this.exhibit }); return Promise.resolve(undefined); } /** @@ -7779,7 +11509,7 @@ var lib_plankton; dom_field.setAttribute("rel", field.name); await Promise.all([ // label - new Promise((resolve, reject) => { + (async () => { if (field.label === null) { // do nothing } @@ -7789,22 +11519,19 @@ var lib_plankton; dom_label.textContent = field.label; dom_field.appendChild(dom_label); } - resolve(undefined); - }), + })(), // help - new Promise((resolve, reject) => { + (async () => { if (field.help === null) { // do nothing } else { - let dom_help = document.createElement("span"); - dom_help.classList.add("plankton_input_group_field_help"); - dom_help.textContent = "(?)"; - dom_help.setAttribute("title", field.help); - dom_field.appendChild(dom_help); + let dom_help_content = document.createElement("div"); + dom_help_content.classList.add("plankton_input_group_field_help_content"); + dom_field.appendChild(dom_help_content); + await field.help.load(dom_help_content); } - resolve(undefined); - }), + })(), // input field.input.setup(dom_field), ]); @@ -8999,6 +12726,9 @@ var lib_plankton; /** */ let _target_element = null; + /** + */ + let _nav_entries; /** */ function encode(location) { @@ -9052,25 +12782,6 @@ var lib_plankton; } } } - /** - */ - function add_nav_entry(location, options = {}) { - options = Object.assign({ - "label": null, - }, options); - let ul_element = document.querySelector("nav > ul"); - { - let li_element = document.createElement("li"); - { - let a_element = document.createElement("a"); - a_element.setAttribute("href", encode(location)); - a_element.textContent = (options.label ?? location.name); - li_element.appendChild(a_element); - } - ul_element.appendChild(li_element); - } - } - zoo_page.add_nav_entry = add_nav_entry; /** * retrieves the location from the set URL */ @@ -9086,21 +12797,33 @@ var lib_plankton; zoo_page.set = set; /** */ - function register(location_name, handler, options = {}) { - options = Object.assign({}, options); + function reload() { + return load(get()); + } + zoo_page.reload = reload; + /** + */ + function register(location_name, handler) { zoo_page._pool[location_name] = handler; } zoo_page.register = register; /** */ - function init(target_element, options = {}) { - options = Object.assign({ - "pool": {}, - "fallback": null, - }, options); + function nav_set_groups(groups) { + _nav_entries.forEach(nav_entry => { + const active = ((groups === null) + || + groups.some(group => nav_entry.definition.groups.includes(group))); + nav_entry.element.classList.toggle("active", active); + }); + } + zoo_page.nav_set_groups = nav_set_groups; + /** + */ + function init(target_element, { "pool": pool = {}, "fallback": fallback = null, "nav_entries": nav_entries = [], "nav_initial_groups": nav_initial_groups = null, } = {}) { _target_element = target_element; - _fallback = options.fallback; - Object.entries(options.pool).forEach(([location_name, handler]) => { + _fallback = fallback; + Object.entries(pool).forEach(([location_name, handler]) => { register(location_name, handler); }); window.addEventListener("hashchange", () => { @@ -9121,6 +12844,25 @@ var lib_plankton; // do nothing } }); + // nav + { + let ul_element = document.querySelector("nav > ul"); + _nav_entries = nav_entries.map(nav_entry_definition => { + let li_element = document.createElement("li"); + { + let a_element = document.createElement("a"); + a_element.setAttribute("href", encode(nav_entry_definition.location)); + a_element.textContent = (nav_entry_definition.label ?? nav_entry_definition.location.name); + li_element.appendChild(a_element); + } + ul_element.appendChild(li_element); + return { + "definition": nav_entry_definition, + "element": li_element, + }; + }); + nav_set_groups(nav_initial_groups); + } } zoo_page.init = init; /** diff --git a/tools/update-plankton b/tools/update-plankton index fbc3aa6..2981aed 100755 --- a/tools/update-plankton +++ b/tools/update-plankton @@ -2,7 +2,7 @@ ## consts -dir=lib/plankton +dir=$(pwd)/lib/plankton modules="" modules="${modules} base" @@ -10,9 +10,11 @@ modules="${modules} file" modules="${modules} json" modules="${modules} base64" modules="${modules} string" +modules="${modules} password" modules="${modules} translate" modules="${modules} storage" modules="${modules} cache" +modules="${modules} zoo-widget" modules="${modules} zoo-input" modules="${modules} zoo-form" modules="${modules} zoo-search" @@ -22,7 +24,17 @@ modules="${modules} zoo-page" ## exec -mkdir -p ${dir} -cd ${dir} -ptk bundle web ${modules} -cd - > /dev/null +if false +then + mkdir -p ${dir} + cd ${dir} + ptk bundle web ${modules} + cd - > /dev/null +else + mkdir -p ${dir} + mkdir /tmp/sandbox -p + cd /tmp/sandbox + ptk fetch web ${modules} + schwamm --include=/tmp/sandbox/plankton.swm.json --output=dump:logic-decl > ${dir}/plankton.d.ts + schwamm --include=/tmp/sandbox/plankton.swm.json --output=dump:logic-impl > ${dir}/plankton.js +fi