munin/libs/plankton/plankton.d.ts

2921 lines
84 KiB
TypeScript
Raw Permalink Normal View History

2025-04-25 00:48:05 +02:00
/**
* @author fenris
*/
2025-05-06 21:07:38 +02:00
type int = number;
2025-04-25 00:48:05 +02:00
/**
* @author fenris
*/
2025-05-06 21:07:38 +02:00
type float = number;
2025-04-25 00:48:05 +02:00
declare var process: any;
declare var require: any;
declare class Buffer {
constructor(x: string, modifier?: string);
static from(x: string, encoding?: string): any;
toString(modifier?: string): string;
}
declare namespace lib_plankton.base {
/**
* @author fenris
*/
function environment(): string;
}
/**
* @author fenris
*/
2025-05-06 21:07:38 +02:00
type type_pseudopointer<type_value> = {
2025-04-25 00:48:05 +02:00
value: type_value;
};
/**
* @author fenris
*/
declare function pseudopointer_null<type_value>(): type_pseudopointer<type_value>;
/**
* @author fenris
*/
declare function pseudopointer_make<type_value>(value: type_value): type_pseudopointer<type_value>;
/**
* @author fenris
*/
declare function pseudopointer_isset<type_value>(pseudopointer: type_pseudopointer<type_value>): boolean;
/**
* @author fenris
*/
declare function pseudopointer_read<type_value>(pseudopointer: type_pseudopointer<type_value>): type_value;
/**
* @author fenris
*/
declare function pseudopointer_write<type_value>(pseudopointer: type_pseudopointer<type_value>, value: type_value): void;
/**
* @author fenris
*/
declare var instance_verbosity: int;
/**
* @desc the ability to check for equality with another element of the same domain
* @author fenris
*/
interface interface_collatable<type_value> {
/**
* @author fenris
*/
_collate(value: type_value): boolean;
}
/**
* @author fenris
*/
declare function instance_collate<type_value>(value1: (type_value & {
_collate?: ((value: type_value) => boolean);
}), value2: type_value): boolean;
/**
* @desc the ability to compare with another element of the same domain for determining if the first is "smaller than or equal to" the latter
* @author fenris
*/
interface interface_comparable<type_value> {
/**
* @author fenris
*/
_compare(value: type_value): boolean;
}
/**
* @author fenris
*/
declare function instance_compare<type_value>(value1: (type_value & {
_compare: ((value: type_value) => boolean);
}), value2: type_value): boolean;
/**
* @desc the ability to create an exact copy
* @author fenris
*/
interface interface_cloneable<type_value> {
/**
* @author fenris
*/
_clone(): type_value;
}
/**
* @author fenris
*/
declare function instance_clone<type_value>(value: (type_value & {
_clone?: (() => type_value);
})): type_value;
/**
* @author fenris
*/
interface interface_hashable {
/**
* @author fenris
*/
_hash(): string;
}
/**
* @desc the ability to generate a string out of the element, which identifies it to a high degree
* @author fenris
*/
declare function instance_hash<type_value>(value: (type_value & {
_hash?: (() => string);
})): string;
/**
* @author fenris
*/
interface interface_showable {
/**
* @author fenris
*/
_show(): string;
}
/**
* @desc the ability to map the element to a textual representation (most likely not injective)
* @author fenris
*/
declare function instance_show<type_value>(value: (type_value & {
_show?: (() => string);
})): string;
/**
* @author frac
*/
interface interface_decorator<type_core> {
/**
* @author frac
*/
core: type_core;
}
/**
* @author frac
*/
declare class class_observer {
/**
* @author frac
*/
protected counter: int;
/**
* @author frac
*/
protected actions: {
[id: string]: (information: Object) => void;
};
/**
* @author frac
*/
protected buffer: Array<Object>;
/**
* @author frac
*/
constructor();
/**
* @author frac
*/
empty(): boolean;
/**
* @author frac
*/
flush(): void;
/**
* @author frac
*/
set(id: string, action: (information: Object) => void): void;
/**
* @author frac
*/
del(id: string): void;
/**
* @author frac
*/
add(action: (information: Object) => void): void;
/**
* @author frac
*/
notify(information?: Object, delayed?: boolean): void;
/**
* @author frac
*/
rollout(): void;
}
/**
* @author frac
*/
/**
* @author frac
*/
/**
* @author frac
*/
declare class class_error extends Error {
/**
* @author frac
*/
protected suberrors: Array<Error>;
/**
* @author frac
*/
protected mess: string;
/**
* @author frac
*/
constructor(message: string, suberrors?: Array<Error>);
/**
* @override
* @author frac
*/
toString(): string;
}
declare namespace lib_plankton.base {
/**
* returns the current UNIX timestamp
*
* @author fenris
*/
function get_current_timestamp(rounded?: boolean): float;
/**
*/
function object_merge(core: Record<string, any>, mantle: Record<string, any>): Record<string, any>;
/**
*/
function buffer_show(buffer: Buffer, { "block_size": option_block_size, "break_char": option_break_char, }?: {
block_size?: int;
break_char?: string;
}): string;
}
declare module lib_plankton.pod {
/**
* @author fenris
*/
type type_pod<type_value> = {
kind: ("empty" | "filled");
value?: type_value;
};
/**
* @author fenris
*/
function make_empty<type_value>(): type_pod<type_value>;
/**
* @author fenris
*/
function make_filled<type_value>(value: type_value): type_pod<type_value>;
/**
* whether the pod is filled
*
* @author fenris
*/
function is_filled<type_value>(pod: type_pod<type_value>): boolean;
/**
* return the value, stored in the pod-wrapper
*
* @author fenris
*/
function cull<type_value>(pod: type_pod<type_value>): type_value;
/**
* to pass on a empty-pod or to use a filled-pod
*
* @author fenris
*/
function propagate<type_value, type_value_>(pod: type_pod<type_value>, function_: ((value: type_value) => type_value_)): type_pod<type_value_>;
/**
* @author fenris
*/
function distinguish<type_value, type_result>(pod: type_pod<type_value>, function_empty: (() => type_result), function_filled: ((value: type_value) => type_result)): type_result;
/**
*/
function show<type_value>(pod: type_pod<type_value>, options?: {
show_value?: ((value: type_value) => string);
}): string;
}
declare module lib_plankton.pod {
/**
*/
class class_pod<type_value> {
private subject;
constructor(subject: type_pod<type_value>);
tear(): type_pod<type_value>;
static empty<type_value>(): class_pod<type_value>;
static filled<type_value>(value: type_value): class_pod<type_value>;
is_empty(): boolean;
is_filled(): boolean;
cull(): type_value;
show(show_value?: any): string;
toString(): string;
propagate<type_value_>(function_: ((value: type_value) => type_value_)): class_pod<type_value_>;
distinguish<type_result>(function_empty: (() => type_result), function_filled: ((value: type_value) => type_result)): type_result;
}
}
/**
* might be completely obsolete
*/
declare namespace lib_plankton.call {
/**
* @author fenris
*/
type type_promise<type_result, type_reason> = Promise<type_result>;
/**
* @author fenris
*/
function promise_reject<type_result, type_reason>(reason: type_reason): type_promise<type_result, type_reason>;
/**
* @author fenris
*/
function promise_resolve<type_result, type_reason>(result: type_result): type_promise<type_result, type_reason>;
/**
* @author fenris
*/
function promise_make<type_result, type_reason>(executor: (resolve: ((result?: type_result) => void), reject: ((reason?: type_reason) => void)) => void): type_promise<type_result, type_reason>;
/**
* @author fenris
*/
function promise_then_close<type_result, type_reason>(promise: type_promise<type_result, type_reason>, resolver: ((result: type_result) => void), rejector: ((reason: type_reason) => void)): void;
/**
* @author fenris
*/
function promise_then_append<type_result, type_reason, type_result_>(promise: type_promise<type_result, type_reason>, resolver: ((result: type_result) => type_promise<type_result_, type_reason>), rejector?: ((reason: type_reason) => type_promise<type_result_, type_reason>)): type_promise<type_result_, type_result>;
/**
* @author fenris
*/
function promise_all<type_result, type_reason>(promises: Array<type_promise<type_result, type_reason>>): type_promise<Array<type_result>, type_reason>;
/**
* @author fenris
*/
function promise_chain<type_result, type_reason>(promises: (Array<(input: type_result) => type_promise<type_result, type_reason>>), start?: type_result): type_promise<type_result, type_reason>;
/**
* @author fenris
*/
function promise_condense<type_element, type_reason>(promises: Array<() => type_promise<type_element, type_reason>>): type_promise<Array<type_element>, type_reason>;
/**
* @author fenris
*/
function promise_group<type_reason>(promises: Record<string, (() => type_promise<any, type_reason>)>, options?: {
serial?: boolean;
}): type_promise<Record<string, any>, type_reason>;
/**
* @author fenris
*/
function promise_wrap<type_result_inner, type_result_outer, type_reason>(promise: type_promise<type_result_inner, type_reason>, transformator_result: ((reason: type_result_inner) => type_result_outer), transformator_reason?: ((reason: type_reason) => type_reason)): type_promise<type_result_outer, type_reason>;
/**
* @author fenris
*/
/**
* @author fenris
*/
/**
* @author fenris
*/
function promise_attach<type_reason>(state: Record<string, any>, promise: type_promise<any, type_reason>, name: string): type_promise<Record<string, any>, type_reason>;
/**
* @author fenris
*/
function promise_delay<type_result, type_reason>(promise: type_promise<type_result, type_reason>, delay: int): type_promise<type_result, type_reason>;
}
/**
* initializer might be obsolete, since promises are reusable after having been resolved or rejected
*/
declare namespace lib_plankton.call {
/**
* @author fenris
*/
enum enum_initializer_state {
initial = 0,
waiting = 1,
successful = 2,
failed = 3
}
/**
* @author fenris
*/
type type_initializer<type_result, type_reason> = {
fetcher: (() => type_promise<type_result, type_reason>);
state?: enum_initializer_state;
queue: Array<{
resolve: ((result?: type_result) => void);
reject: ((reason?: type_reason) => void);
}>;
result?: type_result;
reason?: type_reason;
};
/**
* @author fenris
*/
function initializer_make<type_result, type_reason>(fetcher: (() => type_promise<type_result, type_reason>)): type_initializer<type_result, type_reason>;
/**
* @author fenris
*/
function initializer_reset<type_result, type_reason>(subject: type_initializer<type_result, type_reason>): void;
/**
* @author fenris
*/
function initializer_state<type_result, type_reason>(subject: type_initializer<type_result, type_reason>): enum_initializer_state;
/**
* @author fenris
*/
function initializer_get<type_result, type_reason>(subject: type_initializer<type_result, type_reason>): type_promise<type_result, type_reason>;
}
declare namespace lib_plankton.call {
/**
* @author fenris
*/
type type_deferral<type_input, type_output> = {
representation: (input: type_input) => Promise<type_output>;
};
/**
* @author fenris
* @desc activates the deferral and handles its output according to a given procedure
* @param {(value : type_value)=>void} procedure a function which receives the output of the deferral as argument
*/
function deferral_use<type_input, type_output>(deferral: type_deferral<type_input, type_output>, input: type_input, procedure: (output: type_output) => void): void;
/**
* @author fenris
* @desc creates a deferral-subject (similar to "new Promise", where "convey" reflects "resolve"/"reject")
*/
function deferral_make<type_input, type_output>(handler: (input: type_input, convey: (output: type_output) => void) => void): type_deferral<type_input, type_output>;
/**
* @author fenris
* @desc wraps a simple function into a deferral (similar to "Promise.resolve"/"Promise.reject")
*/
function deferral_wrap<type_input, type_output>(function_: (input: type_input) => type_output): type_deferral<type_input, type_output>;
/**
* @author fenris
*/
function deferral_id<type_value>(): type_deferral<type_value, type_value>;
/**
* @author fenris
*/
function deferral_const<type_value>(value: type_value): type_deferral<type_value, type_value>;
/**
* @author fenris
*/
function deferral_delay<type_output>(output: type_output, delay: int): type_deferral<any, type_output>;
/**
* @author fenris
* @desc connects two deferrals to form a new one; the output of the first is taken as input for the second
* (similar to "Promise.then" when passing a function which returns a new promise)
* @param {type_deferral<type_value1>} first a simple deferral
* @param {(value1 : type_value1)=>type_deferral<type_value2>} second a function depending from a value returning a deferral
*/
function deferral_compose_serial<type_input, type_between, type_output>(first: type_deferral<type_input, type_between>, second: type_deferral<type_between, type_output>): type_deferral<type_input, type_output>;
/**
* @author fenris
*/
function deferral_compose_parallel<type_input, type_output_left, type_output_right>({ "left": deferral_left, "right": deferral_right, }: {
left: type_deferral<type_input, type_output_left>;
right: type_deferral<type_input, type_output_right>;
}): type_deferral<type_input, {
left: type_output_left;
right: type_output_right;
}>;
/**
* @author fenris
* @desc repeatedly applied serial composition
*/
function deferral_chain<type_value>(members: Array<type_deferral<type_value, type_value>>): type_deferral<type_value, type_value>;
/**
* @author fenris
*/
}
declare namespace lib_plankton.call {
/**
* @author fenris
*/
class class_deferral<type_input, type_output> {
/**
* @author fenris
*/
private subject;
/**
* @author fenris
*/
private constructor();
/**
* @author fenris
*/
private static _cram;
/**
* @author fenris
*/
private static _tear;
/**
* @author fenris
*/
static make<type_input, type_output>(handler: (input: type_input, convey: (value: type_output) => void) => void): class_deferral<type_input, type_output>;
/**
* @author fenris
*/
use(input: type_input, procedure: (value: type_output) => void): void;
/**
* @author fenris
*/
compose_serial<type_output_>(second: class_deferral<type_output, type_output_>): class_deferral<type_input, type_output_>;
/**
* @author fenris
*/
static chain<type_value>(members: Array<class_deferral<type_value, type_value>>): class_deferral<type_value, type_value>;
/**
* @author fenris
*/
static wrap<type_input, type_output>(function_: (input: type_input) => type_output): class_deferral<type_input, type_output>;
/**
* @author fenris
*/
static const_<type_value>(value: type_value): class_deferral<type_value, type_value>;
/**
* @author fenris
*/
static delay<type_output>(output: type_output, delay: int): class_deferral<any, type_output>;
}
}
declare namespace lib_plankton.call {
/**
* converts the "arguments"-map into an array
*
* @param {Object} args
* @author fenris
*/
export function args2list(args: any): Array<any>;
/**
* just the empty function; useful for some callbacks etc.
*
* @author fenris
*/
export function nothing(): void;
/**
* just the identity; useful for some callbacks etc.; defined as function instead of const for using type parameters
*
* @author fenris
*/
export function id<type_value>(x: type_value): type_value;
/**
* just the identity; useful for some callbacks etc.
*
* @author fenris
*/
export function const_<type_value>(x: type_value): ((y: any) => type_value);
/**
* composes two functions (i.e. returns a function that return the result of the successive execution of both input-functions)
*
* @param {function} function_f
* @param {function} function_g
* @author fenris
*/
export function compose<type_x, type_y, type_z>(function_f: ((type_x: any) => type_y), function_g: ((type_y: any) => type_z)): ((value: type_x) => type_z);
/**
* transforms a function with sequential input to a function with leveled input; example: add(2,3) = curryfy(add)(2)(3)
*
* @param {function} f
* @return {function} the currified version of the in put function
* @author fenris
*/
export function curryfy(f: Function): Function;
/**
* @author fenris
*/
export function convey(value: any, functions: Array<Function>): any;
/**
*/
class class_value_wrapper<type_value> {
/**
*/
private value;
/**
*/
constructor(value: type_value);
/**
*/
convey<type_value_result>(function_: ((value: type_value) => type_value_result)): class_value_wrapper<type_value_result>;
/**
*/
cull(): type_value;
}
/**
*/
export function wrap<type_value>(value: type_value): class_value_wrapper<type_value>;
/**
* @author fenris
*/
export function timeout(procedure: (() => void), delay_in_seconds: float): int;
/**
* Promise version of "setTimeout"
*
* @author fenris
*/
export function defer<type_result>(seconds: float, action: (() => type_result)): Promise<type_result>;
/**
* a definition for a value being "defined"
*
* @author neuc
*/
export function is_def<type_value>(obj: type_value, options?: {
null_is_valid?: boolean;
}): boolean;
/**
* returns the value if set and, when a type is specified, if the type is correct, if not return default_value
*
* @author neuc
*/
export function def_val(value: any, default_value: any, options?: {
type?: (null | string);
null_is_valid?: boolean;
}): any;
/**
* provides the call for an attribute of a class as a regular function; useful for processing lists of objects
*
* @param {string} name the name of the attribute
* @return {function}
* @author fenris
*/
export function attribute<type_object, type_attribute>(name: string): ((object: type_object) => type_attribute);
/**
* provides a method of a class as a regular function; useful for processing lists of objects
*
* @param {string} name the name of the method
* @return {function}
* @author fenris
*/
export function method<type_object, type_output>(name: string): ((object: type_object) => type_output);
/**
* @author fenris
*/
export type type_coproduct = {
kind: string;
data?: any;
};
/**
* @author fenris
*/
export function distinguish<type_output>(coproduct: type_coproduct, handlers: Record<string, ((data?: any) => type_output)>, options?: {
fallback?: (null | ((coproduct?: type_coproduct) => type_output));
}): type_output;
/**
*/
export function try_catch_wrap<type_value>(get_value: (() => type_value)): {
value: (null | type_value);
error: (null | any);
};
/**
*/
export function try_catch_wrap_async<type_value>(get_value: (() => Promise<type_value>)): Promise<{
value: (null | type_value);
error: (null | any);
}>;
/**
*/
export function sleep(seconds: float): Promise<void>;
2025-04-25 00:48:05 +02:00
export {};
}
declare namespace lib_plankton.email {
/**
*/
function send(smtp_credentials: {
host: string;
port: int;
username: string;
password: string;
}, sender: string, receivers: Array<string>, subject: string, content: string): Promise<void>;
}
declare namespace lib_plankton.log {
/**
*/
enum enum_level {
debug = 0,
info = 1,
notice = 2,
warning = 3,
error = 4
}
/**
*/
type type_entry = {
level: enum_level;
incident: string;
tags: Array<string>;
details: any;
};
/**
*/
type type_channel_description = lib_plankton.call.type_coproduct;
/**
*/
type type_channel_logic = {
send: ((entry: type_entry) => void);
};
/**
*/
type type_logger_data = Array<type_channel_description>;
/**
*/
type type_logger_logic = Array<type_channel_logic>;
/**
*/
type type_format_definition = ({
kind: "jsonl";
data: {
structured: boolean;
};
} | {
kind: "human_readable";
data: {};
});
}
declare namespace lib_plankton.log {
/**
*/
function level_order(level1: enum_level, level2: enum_level): boolean;
/**
*/
function level_show(level: enum_level, { "abbreviated": option_abbreviated, }?: {
abbreviated?: boolean;
}): string;
/**
*/
function level_decode(level_string: string): enum_level;
}
declare namespace lib_plankton.log {
/**
* @todo use label
*/
function get_logger_logic(logger_data: type_logger_data): type_logger_logic;
/**
*/
function format_entry(format_definition: type_format_definition, entry: type_entry): string;
/**
*/
function parse_format_definition(format_definition_raw: any): type_format_definition;
}
declare namespace lib_plankton.log.channel.filtered {
/**
*/
type type_predicate = ((entry: type_entry) => boolean);
/**
*/
type type_subject = {
/**
* @todo check if it has to be logic
*/
core: type_channel_logic;
predicate: type_predicate;
};
/**
*/
function predicate_incident(substring: string): type_predicate;
/**
*/
function predicate_level(threshold: enum_level): type_predicate;
/**
*/
function predicate_tag(tag: string): type_predicate;
/**
* combines other predicates in disjunctive normal form
*/
function predicate_complex(definition: Array<Array<{
mode: boolean;
item: type_predicate;
}>>): type_predicate;
/**
*/
function send(subject: type_subject, entry: type_entry): void;
/**
*/
function logic(subject: type_subject): type_channel_logic;
}
declare namespace lib_plankton.log.channel.minlevel {
/**
*/
type type_subject = {
/**
* @todo check if it has to be logic
*/
core: type_channel_logic;
threshold: enum_level;
};
/**
*/
function send(subject: type_subject, entry: type_entry): void;
/**
*/
function logic(subject: type_subject): type_channel_logic;
}
declare namespace lib_plankton.log.channel.std {
/**
*/
type type_subject = {
target: ("stdout" | "stderr");
format: type_format_definition;
};
/**
*/
function send(subject: type_subject, entry: type_entry): void;
/**
*/
function logic(subject: type_subject): type_channel_logic;
}
declare namespace lib_plankton.log.channel.file {
/**
*/
type type_subject = {
path: string;
format: type_format_definition;
};
/**
*/
function send(subject: type_subject, entry: type_entry): void;
/**
*/
function logic(subject: type_subject): type_channel_logic;
}
declare namespace lib_plankton.log.channel.notify {
/**
*/
type type_subject = {};
/**
* @todo tags
*/
function send(subject: type_subject, entry: type_entry): void;
/**
*/
function logic(subject: type_subject): type_channel_logic;
}
declare namespace lib_plankton.log.channel.email {
/**
*/
type type_subject = {
smtp_credentials: {
host: string;
port: int;
username: string;
password: string;
};
sender: string;
receivers: Array<string>;
};
/**
* @todo tags
*/
function send(subject: type_subject, entry: type_entry): void;
/**
*/
function logic(subject: type_subject): type_channel_logic;
}
declare namespace lib_plankton.log {
/**
*/
function get_channel_logic(channel_description: type_channel_description): type_channel_logic;
}
declare namespace lib_plankton.log {
/**
*/
function default_logger(): type_logger_data;
}
declare namespace lib_plankton.log {
/**
*/
function set_main_logger(logger_data: type_logger_data): void;
/**
* consumes a log entry, i.e. sends it to all channels
*/
function send_(logger: type_logger_logic, entry: type_entry): void;
/**
* [convenience]
*
* @todo rename to "send"
*/
function debug_(logger: type_logger_logic, incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*
* @todo rename to "info"
*/
function info_(logger: type_logger_logic, incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*
* @todo rename to "notice"
*/
function notice_(logger: type_logger_logic, incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*
* @todo rename to "warning"
*/
function warning_(logger: type_logger_logic, incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*
* @todo rename to "error"
*/
function error_(logger: type_logger_logic, incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*/
function _send(entry: type_entry): void;
/**
* [convenience]
*/
function _debug(incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*/
function _info(incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*/
function _notice(incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*/
function _warning(incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*/
function _error(incident: string, { "tags": option_tags, "details": option_details, }?: {
tags?: Array<string>;
details?: any;
}): void;
/**
* [convenience]
*
* @deprecated use ._debug instead!
*/
function debug(incident: string, details?: any, tags?: Array<string>): void;
/**
* [convenience]
*
* @deprecated use ._info instead!
*/
function info(incident: string, details?: any, tags?: Array<string>): void;
/**
* [convenience]
*
* @deprecated use ._notice instead!
*/
function notice(incident: string, details?: any, tags?: Array<string>): void;
/**
* [convenience]
*
* @deprecated use ._warning instead!
*/
function warning(incident: string, details?: any, tags?: Array<string>): void;
/**
* [convenience]
*
* @deprecated use ._error instead!
*/
function error(incident: string, details?: any, tags?: Array<string>): void;
}
declare var plain_text_to_html: (text: string) => string;
/**
* @desc makes a valid
*/
declare var format_sentence: (str: string, rtl?: boolean, caseSense?: boolean) => string;
declare var fill_string_template: (template_string: string, object: any, fabric: Function, delimiter: string, default_string: string, sloppy: boolean) => string;
declare var make_string_template: (_template: string, _fabrics?: Object) => (object: {
[key: string]: string;
}) => string;
declare var make_eml_header: (object: {
[key: string]: string;
}) => string;
declare var make_eml_body: Object;
declare namespace lib_plankton.string {
/**
* @author neuc,frac
*/
function empty(str: string): boolean;
/**
* @desc returns a unique string
* @param {string} prefix an optional prefix for the generated string
* @return {string}
* @author fenris
*/
function generate(prefix?: string): string;
/**
* @author fenris
*/
function join(parts: Array<string>, glue?: string): string;
/**
* @desc splits a string, but returns an empty list, if the string is empty
* @param {string} chain
* @param {string} separator
* @return {Array<string>}
* @author fenris
*/
function split(chain: string, separator: string): Array<string>;
/**
* @author neu3no
*/
function explode(str: string, needle: string, max: int): Array<string>;
/**
* @desc concats a given word with itself n times
* @param {string} word
* @param {int}
* @return {string}
* @author fenris
*/
function repeat(word: string, count: int): string;
/**
* @desc lengthens a string by repeatedly appending or prepending another string
* @param {string} word the string to pad
* @param {int} length the length, which the result shall have
* @param {string} symbol the string, which will be added (multiple times)
* @param {boolean} [prepend]; whether to prepend (~true) or append (~false); default: false
* @return {string} the padded string
* @author fenris
*/
function pad(word: string, length: int, symbol?: string, mode?: string): string;
/**
* @desc checks if a given string conttains a certain substring
* @param {string} string
* @param {string} part
* @return {boolean}
* @author fenris
*/
function contains(chain: string, part: string): boolean;
/**
* @desc checks if a given string starts with a certain substring
* @param {string} string
* @param {string} part
* @return {boolean}
* @author fenris
*/
function startsWith(chain: string, part: string): boolean;
/**
* @desc checks if a given string ends with a certain substring
* @param {string} string
* @param {string} part
* @return {boolean}
* @author fenris
*/
function endsWith(chain: string, part: string): boolean;
/**
* @desc count the occourrences of a string in a string
* @param string haystack_string the string wich should be examined
* @param string needle_string the string which should be counted
* @author neuc
*/
function count_occourrences(haystack_string: string, needle_string: string, check_escape: boolean): int;
/**
* @author fenris
*/
function replace(str: string, replacements: Array<{
from: string;
to: string;
}>, options?: {}): string;
/**
* @desc replaces occurences of "{{name}}" in a string by the corresponding values of an argument object
* @author fenris
*/
function coin(str: string, args: {
[id: string]: string;
}, options?: {
legacy?: boolean;
open?: string;
close?: string;
}): string;
/**
* @author fenris
* @deprecated use limit
*/
function cut(str: string, length: int, delimiter?: string): string;
/**
*/
function limit(str: string, options?: {
length?: int;
indicator?: string;
}): string;
/**
*/
function slice(str: string, size: int): Array<string>;
/**
*/
function capitalize(str: string): string;
}
/**
* @deprecated
*/
declare namespace lib_string {
const empty: typeof lib_plankton.string.empty;
const generate: typeof lib_plankton.string.generate;
const split: typeof lib_plankton.string.split;
const explode: typeof lib_plankton.string.repeat;
const repeat: typeof lib_plankton.string.repeat;
const pad: typeof lib_plankton.string.pad;
const contains: typeof lib_plankton.string.contains;
const startsWith: typeof lib_plankton.string.startsWith;
const endsWith: typeof lib_plankton.string.endsWith;
const count_occourrences: typeof lib_plankton.string.count_occourrences;
const coin: typeof lib_plankton.string.coin;
const stance: typeof lib_plankton.string.coin;
const cut: typeof lib_plankton.string.cut;
}
declare namespace lib_plankton.string {
/**
* an implementation of c sprintf
* @param {string} string format string
* @param {array} args arguments which should be filled into
* @returns {string}
*/
var sprintf: (input: string, args?: Array<any>, original?: any) => string;
/**
* an implementation of c printf
* @param {string} string format string
* @param {array} args arguments which should be filled into
* @returns {string}
*/
function printf(format: any, args: any): void;
}
declare var sprintf: (input: string, args?: Array<any>, original?: any) => string;
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.pit {
/**
*/
type type_date = {
year: int;
month: int;
day: int;
};
/**
*/
type type_ywd = {
year: int;
week: int;
day: int;
};
/**
*/
type type_time = {
hour: int;
minute: int;
second: int;
};
/**
*/
type type_datetime = {
timezone_shift: int;
date: type_date;
time: (null | type_time);
};
/**
*/
type type_pit = int;
}
declare namespace lib_plankton.pit {
/**
* @todo complete
*/
function timezone_name_to_timezone_shift(timezone_name: string): int;
/**
*/
function date_object_get_week_of_year(date: Date): int;
/**
*/
function to_unix_timestamp(pit: type_pit): int;
/**
*/
function from_unix_timestamp(unix_timestamp: int): type_pit;
/**
*/
function to_date_object(pit: type_pit): Date;
/**
* @todo test
*/
function to_datetime(pit: type_pit, { "timezone_shift": option_timezone_shift, }?: {
timezone_shift?: int;
}): type_datetime;
/**
*/
function from_datetime(datetime: type_datetime): type_pit;
/**
*/
function is_before(pit: type_pit, reference: type_pit): boolean;
2025-04-25 10:54:41 +02:00
/**
*/
function is_after(pit: type_pit, reference: type_pit): boolean;
2025-04-25 00:48:05 +02:00
/**
*/
function is_between(pit: type_pit, reference_left: type_pit, reference_right: type_pit): boolean;
/**
*/
function shift_hour(pit: type_pit, increment: int): type_pit;
/**
*/
function shift_day(pit: type_pit, increment: int): type_pit;
/**
*/
function shift_week(pit: type_pit, increment: int): type_pit;
2025-04-25 10:54:41 +02:00
/**
*/
function shift_year(pit: type_pit, increment: int): type_pit;
/**
*/
function trunc_minute(pit: type_pit): type_pit;
/**
*/
function trunc_hour(pit: type_pit): type_pit;
/**
*/
function trunc_day(pit: type_pit): type_pit;
2025-04-25 00:48:05 +02:00
/**
*/
function trunc_week(pit: type_pit): type_pit;
2025-04-25 10:54:41 +02:00
/**
*/
function trunc_month(pit: type_pit): type_pit;
/**
*/
function trunc_year(pit: type_pit): type_pit;
2025-04-25 00:48:05 +02:00
/**
*/
function now(): type_pit;
/**
* @param year year according to specified timezone shift
* @param week week according to specified timezone shift
* @return the begin of the week (monday, 00:00)
*/
function from_ywd(ywd: type_ywd, { "timezone_shift": option_timezone_shift, }?: {
timezone_shift?: int;
}): type_pit;
/**
* @todo timezone
*/
function to_ywd(pit: type_pit, { "timezone_shift": option_timezone_shift, }?: {
timezone_shift?: int;
}): type_ywd;
/**
* computes the point in time for switching to central european summer time
*
* @todo write tests
*/
function cest_switch_on(year: int): type_pit;
/**
* computes the point in time for switching away from central european summer time
*
* @todo write tests
*/
function cest_switch_off(year: int): type_pit;
/**
*/
function timezone_shift_ce(pit: type_pit): int;
/**
* [convenience]
*/
function to_datetime_ce(pit: type_pit): type_datetime;
/**
*/
function datetime_translate(datetime: type_datetime, timezone_shift: int): type_datetime;
/**
* [convenience]
*/
function datetime_translate_ce(datetime: type_datetime): type_datetime;
/**
*/
function timezone_shift_format(timezone_shift: int): string;
/**
*/
function date_format(date: type_date): string;
/**
*/
function time_format(time: type_time, { "show_seconds": option_show_seconds, }?: {
show_seconds?: boolean;
}): string;
/**
* @todo show timezone
*/
function datetime_format(datetime: (null | type_datetime), { "timezone_indicator": option_timezone_indicator, "show_timezone": option_show_timezone, "adjust_to_ce": option_adjust_to_ce, "omit_date": option_omit_date, }?: {
timezone_indicator?: string;
show_timezone?: boolean;
adjust_to_ce?: boolean;
omit_date?: boolean;
}): string;
/**
*/
function timespan_format(from: type_datetime, to: (null | type_datetime), { "timezone_indicator": option_timezone_indicator, "show_timezone": option_show_timezone, "adjust_to_ce": option_adjust_to_ce, "omit_date": option_omit_date, }?: {
timezone_indicator?: string;
show_timezone?: boolean;
adjust_to_ce?: boolean;
omit_date?: boolean;
}): string;
}
declare namespace lib_plankton.http_base {
/**
*/
type type_request<type_method> = {
scheme: ("http" | "https");
host: (null | string);
path: string;
version: string;
method: type_method;
query: (null | string);
headers: Record<string, string>;
body: (null | Buffer);
};
/**
*/
type type_response<type_status_code> = {
version: (null | string);
status_code: type_status_code;
headers: Record<string, string>;
body: (null | Buffer);
};
}
declare namespace lib_plankton.http_base {
/**
*/
function encode_request<type_method>(encode_method: ((method: type_method) => string), request: type_request<type_method>): string;
/**
*/
function decode_request<type_method, type_request_actual>(decode_method: ((method_raw: string) => type_method), has_body: ((method: type_method) => boolean), request_raw: string): type_request<type_method>;
/**
*/
function encode_response<type_status_code>(encode_status_code: ((status_code: type_status_code) => string), get_status_text: ((status_code: type_status_code) => string), response: type_response<type_status_code>): string;
/**
*/
function decode_response<type_status_code>(decode_status_code: ((status_code_raw: string) => type_status_code), response_raw: string): type_response<type_status_code>;
/**
* executes an HTTP request
*
* @todo define type_signal
*/
function call<type_method, type_status_code>(has_body: ((method: type_method) => boolean), encode_method: ((method: type_method) => string), decode_status_code: ((status_code_raw: string) => type_status_code), request: type_request<type_method>, { "timeout": option_timeout, "follow_redirects": option_follow_redirects, "implementation": option_implementation, }?: {
timeout?: (null | float);
follow_redirects?: boolean;
implementation?: ("fetch" | "http_module");
}): Promise<type_response<type_status_code>>;
}
declare namespace lib_plankton.http {
/**
* @author fenris <frass@greenscale.de>
*/
enum enum_method {
options = "options",
head = "head",
get = "get",
delete = "delete",
post = "post",
put = "put",
patch = "patch"
}
/**
*/
enum enum_status_code {
continue_ = 100,
switching_protocols = 101,
early_hints = 103,
ok = 200,
created = 201,
accepted = 202,
non_authoritative_information = 203,
no_content = 204,
reset_content = 205,
partial_coentent = 206,
multiple_choices = 300,
moved_permanently = 301,
found = 302,
see_other = 303,
not_modified = 304,
temporary_redirect = 307,
permanent_redirect = 308,
bad_request = 400,
unauthorized = 401,
payment_required = 402,
forbidden = 403,
not_found = 404,
method_not_allowed = 405,
not_acceptable = 406,
proxy_authentication_required = 407,
request_timeout = 408,
conflict = 409,
gone = 410,
length_required = 411,
precondition_failed = 412,
payload_too_large = 413,
uri_too_long = 414,
unsupported_media_type = 415,
range_not_satisfiable = 416,
expectation_failed = 417,
i_m_a_teapot = 418,
unprocessable_entity = 422,
too_early = 425,
upgrade_required = 426,
precondition_required = 428,
too_many_requests = 429,
request_header_fields_too_large = 431,
unavailable_for_legal_reasons = 451,
internal_server_error = 500,
not_implemented = 501,
bad_gateway = 502,
service_unavailable = 503,
gateway_timeout = 504,
http_version_not_supported = 505,
variant_also_negotiates = 506,
insufficient_storage = 507,
loop_detected = 508,
not_extended = 510,
network_authentication = 511
}
/**
* @author fenris <frass@greenscale.de>
*/
type type_request = lib_plankton.http_base.type_request<enum_method>;
/**
* @author fenris <frass@greenscale.de>
*/
type type_response = lib_plankton.http_base.type_response<enum_status_code>;
}
declare namespace lib_plankton.http {
/**
* @author fenris <frass@greenscale.de>
*/
function encode_method(method: enum_method): string;
/**
* @author fenris <frass@greenscale.de>
*/
function decode_method(method_raw: string): enum_method;
/**
* @author fenris <frass@greenscale.de>
*/
function has_body(method: enum_method): boolean;
/**
* @author fenris <frass@greenscale.de>
*/
function encode_request(request: type_request): string;
/**
* @author fenris <frass@greenscale.de>
*/
function decode_request(request_raw: string): type_request;
/**
* @author fenris <frass@greenscale.de>
*/
function encode_response(response: type_response): string;
/**
* @author fenris <frass@greenscale.de>
*/
function decode_response(response_raw: string): type_response;
/**
* executes an HTTP request
*
* @todo define type_signal
*/
function call(request: type_request, { "timeout": option_timeout, "follow_redirects": option_follow_redirects, "implementation": option_implementation, }?: {
timeout?: (null | float);
follow_redirects?: boolean;
implementation?: ("fetch" | "http_module");
}): Promise<type_response>;
}
declare namespace lib_plankton.ical {
/**
*/
type type_rrule = {
freq?: string;
byday?: string;
bymonth?: string;
};
/**
*/
type type_offset = string;
/**
*/
/**
*/
export enum enum_class {
public = "public",
private = "private",
confidential = "confidential"
}
/**
*/
export enum enum_event_status {
tentative = "tentative",
confirmed = "confirmed",
cancelled = "cancelled"
}
/**
*/
export enum enum_transp {
opaque = "opaque",
transparent = "transparent"
}
/**
*/
type type_tzid = string;
/**
*/
export type type_date = {
year: int;
month: int;
day: int;
};
/**
*/
export type type_time = {
hour: int;
minute: int;
second: int;
utc: boolean;
};
/**
*/
export type type_datetime = {
date: type_date;
time: (null | type_time);
};
/**
*/
export type type_dt = {
tzid: type_tzid;
value: type_datetime;
};
/**
*/
type type_duration = {
negative: boolean;
weeks?: int;
days?: int;
hours?: int;
minutes?: int;
seconds?: int;
};
/**
*/
type type_vtimezone = {
tzid?: type_tzid;
standard?: {
dtstart: type_datetime;
rrule: type_rrule;
tzoffsetfrom?: type_offset;
tzoffsetto?: type_offset;
};
daylight?: {
dtstart: type_datetime;
rrule: type_rrule;
tzoffsetfrom?: type_offset;
tzoffsetto?: type_offset;
};
};
/**
* @see https://www.rfc-editor.org/rfc/rfc5545#section-3.6.1
*/
export type type_vevent = {
uid: string;
dtstamp: type_datetime;
dtstart?: type_dt;
class?: enum_class;
created?: type_datetime;
description?: string;
geo?: {
latitude: float;
longitude: float;
};
last_modified?: type_datetime;
location?: string;
/**
* @see https://www.rfc-editor.org/rfc/rfc5545#section-3.8.4.3
*/
organizer?: {
value?: string;
cn?: string;
dir?: string;
sent_by?: string;
};
priority?: int;
sequence?: int;
status?: enum_event_status;
summary?: string;
transp?: enum_transp;
url?: string;
recurid?: any;
rrule?: type_rrule;
dtend?: type_dt;
duration?: type_duration;
attach?: any;
attendee?: string;
categories?: Array<string>;
comment?: any;
contact?: any;
exdate?: any;
rstatus?: any;
related?: any;
resources?: any;
rdate?: any;
x_props?: Record<string, string>;
iana_props?: Record<string, string>;
};
/**
* @see https://www.rfc-editor.org/rfc/rfc5545#section-3.4
*/
export type type_vcalendar = {
version: string;
prodid: string;
vevents: Array<type_vevent>;
calscale?: string;
method?: string;
vtimezone?: type_vtimezone;
x_props?: Record<string, string>;
iana_props?: Record<string, string>;
};
export {};
}
declare namespace lib_plankton.ical {
/**
*/
function datetime_to_unixtimestamp(datetime: type_datetime): int;
/**
* @see https://www.rfc-editor.org/rfc/rfc5545
* @see https://icalendar.org/iCalendar-RFC-5545/
* @todo implement edge cases
*/
function ics_decode_multi(ics_raw: string, { ignore_unhandled_instruction_keys, from_fucked_up_wordpress, }?: {
ignore_unhandled_instruction_keys?: boolean;
from_fucked_up_wordpress?: boolean;
}): Array<type_vcalendar>;
/**
* @see https://www.rfc-editor.org/rfc/rfc5545
* @see https://icalendar.org/iCalendar-RFC-5545/
* @todo implement edge cases
*/
function ics_decode(ics: string, { ignore_unhandled_instruction_keys, from_fucked_up_wordpress, }?: {
ignore_unhandled_instruction_keys?: boolean;
from_fucked_up_wordpress?: boolean;
}): type_vcalendar;
/**
* @todo method
* @todo add missing fields
*/
function ics_encode(vcalendar: type_vcalendar): string;
}
declare namespace lib_plankton.code {
/**
* @author fenris
*/
interface interface_code<type_from, type_to> {
/**
* @author fenris
*/
encode(x: type_from): type_to;
/**
* @author fenris
*/
decode(x: type_to): type_from;
}
}
declare namespace lib_plankton.code {
/**
* @author fenris
*/
type type_code<type_from, type_to> = {
/**
* @author fenris
*/
encode: (x: type_from) => type_to;
/**
* @author fenris
*/
decode: (x: type_to) => type_from;
};
}
declare namespace lib_plankton.code {
/**
* @author fenris
*/
function inverse_encode<type_from, type_to>(decode: (to: type_to) => type_from, to: type_to): type_from;
/**
* @author fenris
*/
function inverse_decode<type_from, type_to>(encode: (from: type_from) => type_to, from: type_from): type_to;
}
declare namespace lib_plankton.code {
/**
* @author fenris
*/
class class_code_inverse<type_from, type_to> implements interface_code<type_to, type_from> {
/**
* @author fenris
*/
protected subject: interface_code<type_from, type_to>;
/**
* @author fenris
*/
constructor(subject: interface_code<type_from, type_to>);
/**
* @implementation
* @author fenris
*/
encode(to: type_to): type_from;
/**
* @implementation
* @author fenris
*/
decode(from: type_from): type_to;
}
}
declare namespace lib_plankton.code {
/**
* @author fenris
*/
function pair_encode<type_from, type_between, type_to>(encode_first: (from: type_from) => type_between, encode_second: (between: type_between) => type_to, from: type_from): type_to;
/**
* @author fenris
*/
function pair_decode<type_from, type_between, type_to>(decode_first: (between: type_between) => type_from, decode_second: (to: type_to) => type_between, to: type_to): type_from;
}
declare namespace lib_plankton.code {
/**
* @author fenris
*/
class class_code_pair<type_from, type_between, type_to> implements interface_code<type_from, type_to> {
/**
* @author fenris
*/
protected first: interface_code<type_from, type_between>;
/**
* @author fenris
*/
protected second: interface_code<type_between, type_to>;
/**
* @author fenris
*/
constructor(first: interface_code<type_from, type_between>, second: interface_code<type_between, type_to>);
/**
* @implementation
* @author fenris
*/
encode(from: type_from): type_to;
/**
* @implementation
* @author fenris
*/
decode(to: type_to): type_from;
}
}
declare namespace lib_plankton.code {
/**
* @author fenris
*/
function chain_encode(encode_links: Array<(from: any) => any>, from: any): any;
/**
* @author fenris
*/
function chain_decode(decode_links: Array<(to: any) => any>, to: any): any;
}
declare namespace lib_plankton.code {
/**
* @author fenris
*/
class class_code_chain implements interface_code<any, any> {
/**
* @author fenris
*/
protected links: Array<interface_code<any, any>>;
/**
* @author fenris
*/
constructor(links: Array<interface_code<any, any>>);
/**
* @implementation
* @author fenris
*/
encode(from: any): any;
/**
* @implementation
* @author fenris
*/
decode(to: any): any;
}
}
declare namespace lib_plankton.code {
/**
* @author Christian Fraß <frass@greenscale.de>
*/
type type_flatten_from = Array<{
[name: string]: any;
}>;
/**
* @author Christian Fraß <frass@greenscale.de>
*/
type type_flatten_to = {
keys: Array<string>;
data: Array<Array<any>>;
};
/**
* @author Christian Fraß <frass@greenscale.de>
*/
function flatten_encode(from: type_flatten_from, keys?: Array<string>): type_flatten_to;
/**
* @author Christian Fraß <frass@greenscale.de>
*/
function flatten_decode(to: type_flatten_to): type_flatten_from;
}
declare namespace lib_plankton.code {
/**
* @author fenris
*/
class class_code_flatten implements interface_code<type_flatten_from, type_flatten_to> {
/**
* @author fenris
*/
constructor();
/**
* @implementation
* @author fenris
*/
encode(x: type_flatten_from): type_flatten_to;
/**
* @implementation
* @author fenris
*/
decode(x: type_flatten_to): type_flatten_from;
}
}
declare namespace lib_plankton.json {
/**
*/
type type_source = any;
/**
*/
type type_target = string;
/**
* @author fenris
*/
export function encode(source: type_source, options?: {
formatted?: boolean;
}): type_target;
/**
* @author fenris
*/
export function decode(target: type_target): type_source;
/**
* @author fenris
*/
export function implementation_code(): lib_plankton.code.type_code<type_source, type_target>;
export {};
}
declare namespace lib_plankton.json {
/**
* @author fenris
*/
class class_json implements lib_plankton.code.interface_code<any, string> {
/**
* @author fenris
*/
constructor();
/**
* @implementation
* @author fenris
*/
encode(x: any): string;
/**
* @implementation
* @author fenris
*/
decode(x: string): any;
}
}
declare namespace lib_plankton.telegram {
/**
*/
type type_chat_id = int;
/**
* @see https://core.telegram.org/bots/api#user
*/
type type_user = {
id: int;
is_bot?: boolean;
first_name: string;
last_name?: string;
username?: string;
language_code?: string;
is_premium?: boolean;
added_to_attachment_menu?: boolean;
can_join_groups?: boolean;
can_read_all_group_messages?: boolean;
supports_inline_queries?: boolean;
can_connect_to_business?: boolean;
has_main_web_app?: boolean;
};
/**
* @see https://core.telegram.org/bots/api#chat
*/
type type_chat = {
id: int;
type: string;
title?: string;
username?: string;
first_name?: string;
last_name?: string;
is_forum?: boolean;
};
/**
* @see https://core.telegram.org/bots/api#chatfullinfo
* @todo complete
*/
type type_chat_full_info = {
id: int;
type: string;
accent_color_id: int;
max_reaction_count: int;
};
/**
* @see https://core.telegram.org/bots/api#message
* @todo complete
*/
type type_message = {
message_id: int;
message_thread_id?: int;
from?: type_user;
sender_chat?: type_chat;
sender_boost_count?: int;
sender_business_bot?: type_user;
date: int;
business_connection_id?: string;
chat: type_chat;
forward_origin?: type_message_origin;
is_topic_message?: boolean;
is_automatic_forward?: boolean;
reply_to_message?: type_message;
external_reply?: type_external_reply_info;
quote?: type_text_quote;
reply_to_story?: type_story;
via_bot?: type_user;
edit_date?: int;
has_protected_content?: boolean;
is_from_offline?: boolean;
media_group_id?: string;
author_signature?: string;
paid_star_count?: int;
text?: string;
entities?: Array<type_message_entity>;
link_preview_options?: type_link_preview_options;
effect_id?: string;
animation?: type_animation;
audio?: type_audio;
document?: type_document;
paid_media?: type_paid_media_info;
photo?: Array<type_photo_size>;
sticker?: type_sticker;
story?: type_story;
video?: type_video;
video_note?: type_video_note;
voice?: type_voice;
caption?: string;
caption_entities?: Array<type_message_entity>;
show_caption_above_media?: boolean;
has_media_spoiler?: boolean;
contact?: type_contact;
dice?: type_dice;
game?: type_game;
};
/**
* @see https://core.telegram.org/bots/api#messageid
*/
type type_message_id = {
message_id: int;
};
/**
* @see https://core.telegram.org/bots/api#inaccessiblemessage
*/
type type_inaccessible_message = {
chat: type_chat;
message_id: int;
date: int;
};
/**
* @see https://core.telegram.org/bots/api#maybeinaccessiblemessage
*/
type type_maybe_inaccessible_message = (type_message | type_inaccessible_message);
/**
* @see https://core.telegram.org/bots/api#messageentity
*/
type type_message_entity = {
type: string;
offset: int;
length: int;
url?: string;
user?: type_user;
language?: string;
custom_emoji_id?: string;
};
/**
* @see https://core.telegram.org/bots/api#textquote
*/
type type_text_quote = {
text: string;
entities?: Array<type_message_entity>;
position: int;
is_manual?: boolean;
};
/**
* @see https://core.telegram.org/bots/api#externalreplyinfo
* @todo complete
*/
type type_external_reply_info = {
origin: type_message_origin;
chat?: type_chat;
};
/**
* @see https://core.telegram.org/bots/api#replyparameters
* @todo complete
*/
type type_reply_parameters = {
message_id: int;
chat_id?: (int | string);
};
/**
* @see https://core.telegram.org/bots/api#messageorigin
*/
type type_message_origin = (type_message_origin_user | type_message_origin_hidden_user | type_message_origin_chat | type_message_origin_channel);
/**
* @see https://core.telegram.org/bots/api#messageoriginuser
*/
type type_message_origin_user = {
type: string;
date: int;
sender_user: type_user;
};
/**
* @see https://core.telegram.org/bots/api#messageoriginhiddenuser
*/
type type_message_origin_hidden_user = {
type: string;
date: int;
sender_user_name: string;
};
/**
* @see https://core.telegram.org/bots/api#messageoriginchat
*/
type type_message_origin_chat = {
type: string;
date: int;
sender_chat: type_chat;
author_signature?: string;
};
/**
* @see https://core.telegram.org/bots/api#messageoriginchannel
*/
type type_message_origin_channel = {
type: string;
date: int;
chat: type_chat;
message_id: int;
author_signature?: string;
};
/**
* @see https://core.telegram.org/bots/api#photosize
*/
type type_photo_size = {
file_id: string;
file_unique_id: string;
width: int;
height: int;
file_size?: int;
};
/**
* @see https://core.telegram.org/bots/api#animation
*/
type type_animation = {
file_id: string;
file_unique_id: string;
width: int;
height: int;
duration: int;
thumbnail?: type_photo_size;
file_name?: string;
mime_type?: string;
file_size?: int;
};
/**
* @see https://core.telegram.org/bots/api#audio
* @todo complete
*/
type type_audio = {
file_id: string;
file_unique_id: string;
duration: int;
};
/**
* @see https://core.telegram.org/bots/api#document
* @todo complete
*/
type type_document = {
file_id: string;
file_unique_id: string;
thumbnait?: type_photo_size;
};
/**
* @see https://core.telegram.org/bots/api#story
*/
type type_story = {
chat: type_chat;
id: int;
};
/**
* @see https://core.telegram.org/bots/api#video
* @todo complete
*/
type type_video = {
file_id: string;
file_unique_id: string;
width: int;
height: int;
duration: int;
};
/**
* @see https://core.telegram.org/bots/api#videonote
*/
type type_video_note = {
file_id: string;
file_unique_id: string;
length: int;
duration: int;
thumbnail?: type_photo_size;
file_size?: int;
};
/**
* @see https://core.telegram.org/bots/api#videonote
*/
type type_voice = {
file_id: string;
file_unique_id: string;
length: int;
duration: int;
mime_type?: string;
file_size?: int;
};
/**
* @see https://core.telegram.org/bots/api#paidmediainfo
*/
type type_paid_media_info = {
star_count: int;
paid_media: Array<type_paid_media>;
};
/**
* @see https://core.telegram.org/bots/api#paidmedia
*/
type type_paid_media = (type_paid_media_preview | type_paid_media_photo | type_paid_media_video);
/**
* @see https://core.telegram.org/bots/api#paidmediapreview
*/
type type_paid_media_preview = {
type: string;
width?: int;
height?: int;
duration?: int;
};
/**
* @see https://core.telegram.org/bots/api#paidmediaphoto
*/
type type_paid_media_photo = {
type: string;
photo: Array<type_photo_size>;
};
/**
* @see https://core.telegram.org/bots/api#paidmediavideo
*/
type type_paid_media_video = {
type: string;
video: type_video;
};
/**
* @see https://core.telegram.org/bots/api#contact
*/
type type_contact = {
phone_number: string;
first_name: string;
last_name?: string;
user_id?: int;
vcard: string;
};
/**
* @see https://core.telegram.org/bots/api#dice
*/
type type_dice = {
emoji: string;
value: int;
};
/**
* @see https://core.telegram.org/bots/api#linkpreviewoptions
*/
type type_link_preview_options = {
is_disabled?: boolean;
url?: string;
prefer_small_media?: boolean;
prefer_large_media?: boolean;
show_above_text?: boolean;
};
/**
* @see https://core.telegram.org/bots/api#sticker
* @todo complete
*/
type type_sticker = {
file_id: string;
file_unique_id: string;
type: string;
width: int;
height: int;
is_animated: boolean;
is_video: boolean;
};
/**
* @see https://core.telegram.org/bots/api#game
*/
type type_game = {
title: string;
description: string;
photo: Array<type_photo_size>;
text?: string;
text_entities?: Array<type_message_entity>;
animation?: type_animation;
};
/**
* @see https://core.telegram.org/bots/api#update
* @todo complete
*/
type type_update = {
update_id: int;
};
}
declare namespace lib_plankton.telegram {
/**
* @see https://core.telegram.org/bots/api#getupdates
*/
function bot_call_get_updates(token: string): Promise<Array<type_update>>;
/**
* @see https://core.telegram.org/bots/api#sendmessage
*/
2025-04-25 12:50:13 +02:00
function bot_call_send_message(token: string, chat_id: (int | string), text: string, { "parse_mode": parse_mode, }?: {
parse_mode?: (null | string);
}): Promise<void>;
2025-04-25 00:48:05 +02:00
}
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<type_url, string>;
}
declare namespace lib_plankton.url {
/**
* @author fenris
*/
class class_url implements lib_plankton.code.interface_code<type_url, string> {
/**
* @author fenris
*/
constructor();
/**
* @implementation
* @author fenris
*/
encode(x: any): string;
/**
* @implementation
* @author fenris
*/
decode(x: string): any;
}
}
2025-04-25 00:48:05 +02:00
declare namespace lib_plankton.file {
/**
* @author fenris
*/
function exists(path: string): Promise<boolean>;
/**
* @author fenris
*/
function read(path: string): Promise<string>;
/**
* @author fenris
*/
function read_buffer(path: string): Promise<Buffer>;
/**
* @author fenris
*/
function read_stdin(): Promise<string>;
/**
* @author fenris
*/
function write(path: string, content: string, options?: {
encoding?: string;
}): Promise<void>;
/**
* @author fenris
*/
function write_buffer(path: string, content: Buffer, options?: {}): Promise<void>;
/**
*/
function delete_(path: string): Promise<void>;
}
declare namespace lib_plankton.object {
/**
* @author fenris
* @deprecated use the "??" operator instead
*/
function fetch<type_value>(object: Object, fieldname: string, options?: {
fallback?: type_value;
escalate?: boolean;
}): type_value;
/**
*/
function map<type_from, type_to>(object_from: Record<string, type_from>, transformator: ((value_from: type_from, key?: string) => type_to)): Record<string, type_to>;
/**
* gibt ein Objekt mit bestimmten Einträgen des Eingabe-Objekts zurück
*/
function filter<type_value>(object_from: Record<string, type_value>, predicate: ((value_from: type_value, key?: string) => boolean)): Record<string, type_value>;
/**
* wandelt ein Array mit Einträgen der Form {key,value} in ein entsprechendes Objekt um
*
* @deprecated use Object.fromEntries instead!
*/
function from_array<type_value>(array: Array<{
key: string;
value: type_value;
}>): Record<string, type_value>;
/**
* wandelt ein Objekt in ein entsprechendes Array mit Einträgen der Form {key,value} um
*
* @deprecated use Object.entries insetad!
*/
function to_array<type_value>(object: Record<string, type_value>): Array<{
key: string;
value: type_value;
}>;
/**
* gibt eine Liste von Schlüsseln eines Objekts zurück
*
* @deprecated use Object.keys instead!
*/
function keys(object: Record<string, any>): Array<string>;
/**
* gibt eine Liste von Werten eines Objekts zurück
*
* @deprecated use Object.values instead!
*/
function values<type_value>(object: Record<string, type_value>): Array<type_value>;
/**
* liest ein Baum-artiges Objekt an einer bestimmten Stelle aus
*/
function path_read<type_value>(object: Object, path: string, options?: {
fallback?: type_value;
escalate?: boolean;
}): type_value;
/**
* schreibt einen Wert an eine bestimmte Stelle in einem Baum-artigen Objekt
*/
function path_write<type_value>(object: Object, path: string, value: type_value, construct?: boolean): void;
/**
* prüft ob ein Objekt einem bestimmten Muster entspricht
*
* @deprecated not very useful
*/
function matches<type_value_object, type_value_pattern>(object: Record<string, type_value_object>, pattern: Record<string, type_value_pattern>, options?: {
collate?: ((value_pattern: type_value_pattern, value_object: type_value_object) => boolean);
}): boolean;
/**
* erzeugt eine Projektion eines Baum-artigen Objekts in ein Listen-artiges Objekt
*/
function flatten(value: any, options?: {
separator?: string;
key_for_array_element?: ((index: int) => string);
}): Record<string, any>;
/**
* @deprecated use Object.assign instead!
*/
function clash(x: Record<string, any>, y: Record<string, any>, options?: {
overwrite?: boolean;
hooks?: {
existing?: ((key?: string, value_old?: any, value_new?: any) => void);
};
}): Record<string, any>;
/**
* @deprecated use Object.assign instead!
*/
function patch(core: (null | Record<string, any>), mantle: (null | Record<string, any>), options?: {
deep?: boolean;
path?: (null | string);
}): void;
/**
* @deprecated use Object.assign instead!
*/
function patched(core: Record<string, any>, mantle: Record<string, any>, options?: {
deep?: boolean;
}): Record<string, any>;
/**
* @deprecated use Object.assign instead!
*/
function attached(object: Record<string, any>, key: string, value: any): Record<string, any>;
/**
* @author fenris
*/
function copy(object: Record<string, any>): Record<string, any>;
}
declare namespace lib_plankton.pair {
/**
*/
type type_pair<type_first, type_second> = {
first: type_first;
second: type_second;
};
}
declare namespace lib_plankton.pair {
/**
*/
function swap<type_first, type_second>(pair: type_pair<type_first, type_second>): type_pair<type_second, type_first>;
/**
*/
function show<type_first, type_second>(pair: type_pair<type_first, type_second>, options?: {
show_first?: ((first: type_first) => string);
show_second?: ((second: type_second) => string);
}): string;
}
declare namespace lib_plankton.list {
/**
*/
type type_separation<type_element> = {
yes: Array<type_element>;
no: Array<type_element>;
};
/**
*/
type type_result_max<type_element, type_value> = (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<int>;
/**
* returns a certain list of consecutiv integer numbers, beginning with 0
*/
function sequence(length: int): Array<int>;
/**
*/
function from_iterator<type_element>(iterator: Iterator<type_element>): Array<type_element>;
/**
*/
function is_empty<type_element>(list: Array<type_element>): 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<type_element_first, type_element_second>(list_first: Array<type_element_first>, list_second: Array<type_element_second>, options?: {
cut?: boolean;
}): Array<lib_plankton.pair.type_pair<type_element_first, type_element_second>>;
/**
* checks whether two lists are equal
*
* @todo define common function "equals" and default predicate to
*/
function equals<type_element>(list1: Array<type_element>, list2: Array<type_element>, 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<type_element>(list: Array<type_element>, predicate: ((element: type_element) => boolean)): Array<type_element>;
/**
* creates a list with the elements from the input list, which do not fulfil a certain predicate (~ dual filter)
*/
function drop<type_element>(list: Array<type_element>, predicate: ((element: type_element) => boolean)): Array<type_element>;
/**
*/
function filter_inplace<type_element>(list: Array<type_element>, predicate: ((element: type_element) => boolean)): void;
/**
* returns a list with no duplicates (like unix' "unique")
*/
function cleaned<type_element>(list: Array<type_element>, options?: {
collate_element?: ((x: type_element, y: type_element) => boolean);
}): Array<type_element>;
/**
* creates a binary partition of the list according to a given predicate
*/
function separate<type_element>(list: Array<type_element>, predicate: ((element: type_element) => boolean)): type_separation<type_element>;
/**
*/
function clone<type_element>(list: Array<type_element>): Array<type_element>;
/**
*/
function reversed<type_element>(list: Array<type_element>): Array<type_element>;
/**
* @todo use Array.toSorted?
*/
function sorted<type_element>(list: Array<type_element>, options: {
compare_element?: ((element1: type_element, element2: type_element) => boolean);
}): Array<type_element>;
/**
* die Liste in gleich große Blöcke zerlegen
*/
function chop<type_element>(list: Array<type_element>, chunk_size: int): Array<Array<type_element>>;
/**
*/
function group<type_element>(list: Array<type_element>, collate_element: ((x: type_element, y: type_element) => boolean)): Array<Array<type_element>>;
/**
*/
function has<type_element>(list: Array<type_element>, predicate: ((element: type_element) => boolean)): boolean;
/**
* @deprecate use Array.includes or Array.some
*/
function contains<type_element>(list: Array<type_element>, 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<type_element, type_value>(list: Array<type_element>, target_function: ((element: type_element) => type_value), options: {
compare_value: ((value1: type_value, value2: type_value) => boolean);
}): type_result_max<type_element, type_value>;
/**
* retrieves the element and its index of the list, which has the mininum value
*/
function min<type_element, type_value>(list: Array<type_element>, target_function: (element: type_element) => type_value, options: {
compare_value: ((value1: type_value, value2: type_value) => boolean);
}): type_result_max<type_element, type_value>;
/**
* 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<type_element>(lists: Array<Array<type_element>>): Array<Array<type_element>>;
/**
*/
function contrast<type_left, type_right>(list_left: Array<type_left>, extract_key_left: ((left: type_left) => string), list_right: Array<type_right>, 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.conf {
/**
*/
type type_schema = ({
enum?: Array<any>;
default?: any;
description?: string;
} | {
type: "null";
description?: string;
} | {
type: "boolean";
nullable?: boolean;
enum?: Array<boolean>;
default?: boolean;
description?: string;
} | {
type: "integer";
nullable?: boolean;
enum?: Array<int>;
default?: int;
description?: string;
} | {
type: "number";
nullable?: boolean;
enum?: Array<number>;
default?: number;
description?: string;
} | {
type: "string";
nullable?: boolean;
enum?: Array<string>;
default?: string;
description?: string;
} | {
type: "array";
nullable?: boolean;
items: type_schema;
enum?: Array<Array<any>>;
default?: Array<any>;
description?: string;
} | {
type: "object";
nullable?: boolean;
properties?: Record<string, type_schema>;
required?: Array<string>;
additionalProperties?: (false | type_schema);
enum?: Array<Record<string, any>>;
default?: Record<string, any>;
description?: string;
} | {
anyOf: Array<type_schema>;
default?: any;
} | {
allOf: Array<type_schema>;
} | {
oneOf: Array<type_schema>;
} | {
not: type_schema;
});
/**
*/
type type_sheet<type_content> = {
version: (null | string);
content: type_content;
};
2025-04-25 00:48:05 +02:00
/**
*/
type type_report = {
incident: string;
details: Record<string, any>;
};
/**
*/
type type_adaption<type_result> = {
reports: Array<type_report>;
result: lib_plankton.pod.type_pod<type_result>;
};
/**
*/
type type_migration<type_from, type_to> = (null | {
target: string;
function: ((content: type_from) => type_to);
});
2025-04-25 00:48:05 +02:00
}
declare namespace lib_plankton.conf {
/**
*/
function refine<type_result>(schema: type_schema, content: any): type_result;
2025-04-25 00:48:05 +02:00
/**
* @deprecated
2025-04-25 00:48:05 +02:00
*/
function load<type_result>(schema: type_schema, path: (null | string)): Promise<type_result>;
/**
*/
function load_versioned(path: string, get_schema: ((version: string) => type_schema), migrations: Record<string, type_migration<any, any>>): Promise<type_sheet<any>>;
2025-04-25 00:48:05 +02:00
}
declare namespace lib_plankton.args {
/**
*/
enum enum_environment {
cli = "cli",
url = "url"
}
/**
*/
enum enum_kind {
positional = "positional",
volatile = "volatile"
}
/**
*/
enum enum_type {
boolean = "boolean",
integer = "int",
float = "float",
string = "string"
}
/**
*/
enum enum_mode {
replace = "replace",
accumulate = "accumulate"
}
}
declare namespace lib_plankton.args {
/**
* @author fenris
*/
class class_argument {
/**
* @author fenris
*/
protected name: string;
/**
* @author fenris
*/
protected kind: enum_kind;
/**
* @author fenris
*/
protected type: enum_type;
/**
* @author fenris
*/
protected mode: enum_mode;
/**
* @author fenris
*/
protected default_: any;
/**
* @author fenris
*/
protected info: string;
/**
* @author fenris
*/
protected parameters: Object;
/**
* @author fenris
*/
protected hidden: boolean;
/**
* @author fenris
*/
constructor({ "name": name, "type": type, "kind": kind, "mode": mode, "default": default_, "info": info, "parameters": parameters, "hidden": hidden, }: {
name: string;
type?: enum_type;
kind?: enum_kind;
mode?: enum_mode;
default?: any;
info?: string;
parameters?: Object;
hidden?: boolean;
});
/**
* @author fenris
*/
static positional({ "name": name, "type": type, "mode": mode, "default": default_, "info": info, "hidden": hidden, "index": index, }: {
name: string;
type?: enum_type;
mode?: enum_mode;
default?: any;
info?: string;
hidden?: boolean;
index: int;
}): class_argument;
/**
* @author fenris
*/
static volatile({ "name": name, "type": type, "mode": mode, "default": default_, "info": info, "hidden": hidden, "indicators_short": indicators_short, "indicators_long": indicators_long, }: {
name: string;
type?: enum_type;
mode?: enum_mode;
default?: any;
info?: string;
hidden?: boolean;
indicators_short: Array<string>;
indicators_long: Array<string>;
}): class_argument;
/**
* @author fenris
*/
check(): boolean;
/**
* @author fenris
*/
name_get(): string;
/**
* @author fenris
*/
kind_get(): enum_kind;
/**
* @author fenris
*/
type_get(): enum_type;
/**
* @author fenris
*/
mode_get(): enum_mode;
/**
* @author fenris
*/
default_get(): any;
/**
* @author fenris
*/
parameters_get(): Object;
/**
* @author fenris
*/
hidden_get(): boolean;
/**
* @author fenris
*/
toString(): string;
/**
* @author fenris
*/
indicator_main(): string;
/**
* @author fenris
*/
pattern_value(): string;
/**
* @author fenris
*/
extract(raw: string): any;
/**
* @author fenris
*/
assign(data: Object, target: string, raw: string): void;
/**
* @author fenris
*/
make(data: Object, target: string): string;
/**
* @author fenris
*/
generate_help(): string;
}
}
declare namespace lib_plankton.args {
/**
* @author fenris
*/
var verbosity: int;
/**
* @author fenris
* @todo check validity
*/
class class_handler {
/**
* @author fenris
*/
protected arguments_: {
[name: string]: class_argument;
};
/**
* @author fenris
*/
constructor(arguments_: {
[name: string]: class_argument;
});
/**
* @author fenris
*/
filter(kind: enum_kind): {
[name: string]: class_argument;
};
/**
* @author fenris
*/
read(environment: enum_environment, input: string, data?: {
[name: string]: any;
}): {
[name: string]: any;
};
/**
* @author fenris
* @todo handle if the data object doesn't have the required field or the type is wrong or sth.
*/
write(environment: enum_environment, data: {
[name: string]: any;
}): string;
/**
* @desc manpage-like info-sheet
* @author fenris
*/
generate_help({ "programname": programname, "author": author, "description": description, "executable": executable, }: {
programname?: string;
author?: string;
description?: string;
executable?: string;
}): string;
}
}