[upd] plankton

This commit is contained in:
Fenris Wolf 2024-09-10 01:11:51 +02:00
parent b4e6a26d54
commit 04192d6ea2
3 changed files with 3067 additions and 0 deletions

View file

@ -2405,3 +2405,677 @@ declare namespace lib_plankton.xml {
compile(depth?: int): string; compile(depth?: int): string;
} }
} }
declare module lib_et {
/**
* @desc type of extended timestamp
* @author fenris
*/
type type_et = {
era: int;
stamp: int;
};
/**
* @desc type of UNIX timestamp
* @author fenris
*/
type type_timestamp = int;
/**
* @desc type of Javascript Date object
* @author fenris
*/
type type_jsdate = Date;
/**
* @author fenris
*/
type type_components = {
year: int;
month: int;
day: int;
hour: int;
minute: int;
second: int;
};
/**
* @author fenris
*/
type type_ywd = {
year: int;
week: int;
day: int;
};
/**
* @author fenris
*/
function part(et1: type_et, et2: type_et): type_et;
/**
* @desc less
* @author fenris
*/
function before(reference: type_et, et: type_et): boolean;
/**
* @desc greater
* @author fenris
*/
function after(reference: type_et, et: type_et): boolean;
/**
* @author fenris
*/
function between(begin: type_et, end: type_et, et: type_et): boolean;
/**
* @author fenris
*/
function intersect(begin1: type_et, end1: type_et, begin2: type_et, end2: type_et): boolean;
/**
* @author fenris
*/
function move(base: type_et, span: type_et): type_et;
/**
* @desc currified version of "move"
* @author fenris
*/
function move_(span: type_et): (base: type_et) => type_et;
/**
* @author fenris
*/
function from_timestamp(timestamp: type_timestamp): type_et;
/**
* @author fenris
*/
function to_timestamp(et: type_et): type_timestamp;
/**
* @author fenris
*/
function from_jsdate(jsdate: type_jsdate): type_et;
/**
* @author fenris
*/
function to_jsdate(et: type_et): type_jsdate;
/**
* @author fenris
*/
function from_components(components: type_components): type_et;
/**
* @author fenris
*/
function to_components(et: type_et): type_components;
/**
* @author fenris
*/
function now(): type_et;
/**
* @author fenris
*/
function to_string(et: type_et): string;
/**
* @author fenris
*/
function to_string_ywd(et: type_et): string;
/**
* @desc retrieve week of year
* @author fenris
*/
function get_woy(et: type_et): int;
/**
* @desc retrieve day of week
* @author fenris
*/
function get_dow(et: type_et): int;
/**
* @author fenris
*/
function trunc_minute(et?: type_et): type_et;
/**
* @author fenris
*/
function trunc_hour(et?: type_et): type_et;
/**
* @author fenris
*/
function trunc_day(et?: type_et): type_et;
/**
* @author fenris
*/
function trunc_month(et?: type_et): type_et;
/**
* @author fenris
*/
function trunc_year(et?: type_et): type_et;
/**
* @author fenris
*/
function trunc_week(et?: type_et): type_et;
/**
* @author fenris
*/
function span_second(seconds?: int): type_et;
/**
* @author fenris
*/
function span_minute(minutes?: int): type_et;
/**
* @author fenris
*/
function span_hour(hours?: int): type_et;
/**
* @author fenris
*/
function span_day(days?: int): type_et;
/**
* @author fenris
*/
function span_week(weeks?: int): type_et;
/**
* @author fenris
*/
function span_year(years?: int): type_et;
}
declare module lib_et {
/**
* @author fenris
*/
class class_et {
/**
* @author fenris
*/
protected subject: type_et;
/**
* @author fenris
*/
constructor(subject: type_et);
/**
* @author fenris
*/
move(et: class_et): class_et;
/**
* @author fenris
*/
before(et: class_et): boolean;
/**
* @author fenris
*/
after(et: class_et): boolean;
/**
* @author fenris
*/
between(et1: class_et, et2: class_et): boolean;
/**
* @author fenris
*/
trunc_minute(): class_et;
/**
* @author fenris
*/
trunc_hour(): class_et;
/**
* @author fenris
*/
trunc_day(): class_et;
/**
* @author fenris
*/
trunc_month(): class_et;
/**
* @author fenris
*/
trunc_year(): class_et;
/**
* @author fenris
*/
trunc_week(): class_et;
/**
* @author fenris
*/
static now(): class_et;
/**
* @author fenris
*/
static span_second(count?: int): class_et;
/**
* @author fenris
*/
static span_minute(count?: int): class_et;
/**
* @author fenris
*/
static span_hour(count?: int): class_et;
/**
* @author fenris
*/
static span_day(count?: int): class_et;
/**
* @author fenris
*/
static span_week(count?: int): class_et;
/**
* @author fenris
*/
static span_year(count?: int): class_et;
/**
* @author fenris
*/
static from_timestamp(timestamp: type_timestamp): class_et;
/**
* @author fenris
*/
to_timestamp(): type_timestamp;
/**
* @author fenris
*/
static from_jsdate(jsdate: type_jsdate): class_et;
/**
* @author fenris
*/
to_jsdate(): type_jsdate;
/**
* @author fenris
*/
static from_components(components: type_components): class_et;
/**
* @author fenris
*/
to_components(): type_components;
/**
* @author fenris
*/
get_woy(): int;
/**
* @author fenris
*/
get_dow(): int;
/**
* @author fenris
*/
to_string(): string;
}
}
declare var global_config: any;
/**
* @author neuc
*/
declare namespace lib_plankton.date {
/**
* @author neu3no, fenris
*/
function set_days(day_names: Array<string>): void;
/**
* @author neu3no, fenris
*/
function set_months(month_names: Array<string>): void;
/**
* @desc week of year
* @param {Date} date
* @return {int}
* @author fenris
*/
function get_week(date: Date): int;
/**
* @author neu3no, fenris
*/
function set_currentDate(date: Date): void;
/**
* @author neu3no, fenris
*/
function parse(format: string, date?: Date): string;
/**
* @author neu3no, fenris
*/
function locale_date(date?: Date, ignore_error?: boolean): string;
/**
*/
type type_unixtimestamp = int;
/**
*/
type type_components = {
timezone_offset: int;
year: int;
month: int;
day: int;
hour: int;
minute: int;
second: int;
};
/**
*/
function now(): type_unixtimestamp;
/**
*/
function from_components(components: type_components): type_unixtimestamp;
/**
*/
function to_components(unixtimestamp: type_unixtimestamp): type_components;
/**
*/
function get_timestamp_from_year_and_week_and_day(year: int, week: int, day: int): type_unixtimestamp;
}
declare var strftime: typeof lib_plankton.date;
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;
organizer?: {
cn?: string;
value?: 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): lib_plankton.date.type_unixtimestamp;
/**
* @see https://www.rfc-editor.org/rfc/rfc5545
* @see https://icalendar.org/iCalendar-RFC-5545/
* @todo implement edge cases
*/
function ics_decode(ics: string, options?: {
debug?: boolean;
}): type_vcalendar;
/**
* @todo method
* @todo add missing fields
*/
function ics_encode(vcalendar: type_vcalendar): string;
}
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"
}
/**
* @author fenris <frass@greenscale.de>
*/
type type_request = {
scheme: ("http" | "https");
host: (null | string);
path: string;
version: string;
method: enum_method;
query: (null | string);
headers: Record<string, string>;
body: (null | Buffer);
};
/**
* @author fenris <frass@greenscale.de>
*/
type type_response = {
version: (null | string);
status_code: int;
headers: Record<string, string>;
body: Buffer;
};
}
declare namespace lib_plankton.http {
/**
* @author fenris <frass@greenscale.de>
*/
function encode_method(method: enum_method): string;
/**
* @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, options?: {
timeout?: (null | float);
follow_redirects?: boolean;
implementation?: ("fetch" | "http_module");
}): Promise<type_response>;
}
declare namespace lib_plankton.http {
/**
* @author fenris
*/
class class_http_request implements lib_plankton.code.interface_code<type_request, string> {
/**
* @author fenris
*/
constructor();
/**
* @implementation
* @author fenris
*/
encode(x: type_request): string;
/**
* @implementation
* @author fenris
*/
decode(x: string): type_request;
}
/**
* @author fenris
*/
class class_http_response implements lib_plankton.code.interface_code<type_response, string> {
/**
* @author fenris
*/
constructor();
/**
* @implementation
* @author fenris
*/
encode(x: type_response): string;
/**
* @implementation
* @author fenris
*/
decode(x: string): type_response;
}
}
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 {
/**
*/
function query_args_encode(query_args: Record<string, string>): string;
/**
*/
function query_args_decode(query: string): Record<string, string>;
/**
* @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;
}
}

File diff suppressed because it is too large Load diff

View file

@ -13,6 +13,10 @@ modules="${modules} args"
modules="${modules} string" modules="${modules} string"
modules="${modules} color" modules="${modules} color"
modules="${modules} xml" modules="${modules} xml"
modules="${modules} ical"
modules="${modules} http"
modules="${modules} log"
modules="${modules} url"
## exec ## exec