diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index 462ad6e..56da519 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -650,6 +650,9 @@ declare namespace lib_plankton.call { value: (null | type_value); error: (null | any); }>; + /** + */ + export function sleep(seconds: float): Promise; export {}; } declare namespace lib_plankton.email { @@ -1550,6 +1553,12 @@ declare namespace lib_plankton.conf { } | { not: type_schema; }); + /** + */ + type type_sheet = { + version: (null | string); + content: type_content; + }; /** */ type type_report = { @@ -1562,15 +1571,24 @@ declare namespace lib_plankton.conf { reports: Array; result: lib_plankton.pod.type_pod; }; + /** + */ + type type_migration = (null | { + target: string; + function: ((content: type_from) => type_to); + }); } declare namespace lib_plankton.conf { /** - * @todo versioning */ - function refine(schema: type_schema, value_raw: any): type_result; + function refine(schema: type_schema, content: any): type_result; + /** + * @deprecated + */ + function load(schema: type_schema, path: (null | string)): Promise; /** */ - function load(schema: type_schema, path: (null | string)): Promise; + function load_versioned(path: string, get_schema: ((version: string) => type_schema), migrations: Record>): Promise>; } declare var plain_text_to_html: (text: string) => string; /** @@ -3189,18 +3207,45 @@ declare namespace lib_plankton.pit { /** */ function is_before(pit: type_pit, reference: type_pit): boolean; + /** + */ + function is_after(pit: type_pit, reference: type_pit): boolean; + /** + */ + function is_equal_or_after(pit: type_pit, reference: type_pit): boolean; /** */ 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; + /** + */ + 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; /** */ function trunc_week(pit: type_pit): type_pit; + /** + */ + function trunc_month(pit: type_pit): type_pit; + /** + */ + function trunc_year(pit: type_pit): type_pit; /** */ function now(): type_pit; @@ -3620,352 +3665,6 @@ declare namespace lib_plankton.http { implementation?: ("fetch" | "http_module"); }): Promise; } -declare namespace lib_plankton.xml { - /** - */ - type type_node_data = ({ - kind: "root"; - data: { - version: string; - encoding: string; - content: type_node_data; - }; - } | { - kind: "comment"; - data: string; - } | { - kind: "text"; - data: string; - } | { - kind: "complex"; - data: { - tag: string; - attributes: Record; - children: Array; - }; - }); - /** - */ - type type_node_logic = { - compile: ((depths: int) => string); - }; - /** - */ - function get_node_logic(node_data: type_node_data): type_node_logic; - /** - */ - function parse(xml_string: string): Promise; -} -declare namespace lib_plankton.webdav { - /** - * @todo try to base on lib_plankton.http.enum_method - */ - enum enum_method { - options = "options", - head = "head", - get = "get", - delete = "delete", - post = "post", - put = "put", - patch = "patch", - propfind = "propfind", - proppatch = "proppatch", - mkcol = "mkcol", - copy = "copy", - move = "move", - lock = "lock", - unlock = "unlock" - } - /** - * @todo try to base on lib_plankton.http.enum_status_code - */ - 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, - multistatus = 207, - 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 - } - /** - * @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_href - */ - type type_data_href = string; - /** - * @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_status - */ - type type_data_status = string; - /** - */ - type type_data_prop_value = ({ - kind: "none"; - data: null; - } | { - kind: "primitive"; - data: string; - } | { - kind: "href"; - data: string; - } | { - kind: "resourcetype"; - data: { - kind: string; - type: string; - }; - } | { - kind: "privileges"; - data: Array; - } | { - kind: "component_set"; - data: { - name: string; - items: Array; - }; - }); - /** - * @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_prop - */ - type type_data_prop = { - name: string; - value: type_data_prop_value; - }; - /** - * @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_propstat - */ - type type_data_propstat = { - prop: Array; - status: string; - description: (null | string); - }; - /** - * @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_response - */ - type type_data_response = { - href: type_data_href; - body: ({ - hrefs: Array; - status: string; - } | { - propstats: Array; - }); - description: (null | string); - }; - /** - * @see http://www.webdav.org/specs/rfc2518.html#ELEMENT_multistatus - */ - type type_data_multistatus = { - responses: Array; - description: (null | string); - }; - /** - */ - type type_request = lib_plankton.http_base.type_request; - /** - */ - type type_response = lib_plankton.http_base.type_response; -} -declare namespace lib_plankton.webdav { - /** - */ - function is_special_method(method: enum_method): boolean; - /** - * @author roydfalk - */ - function encode_method(method: enum_method): string; - /** - * @author roydfalk - */ - function decode_method(method_raw: string): enum_method; - /** - * @todo check - */ - function has_body(method: enum_method): boolean; - /** - */ - function decode_request(request_raw: string): type_request; - /** - */ - function encode_response(response: type_response): string; - /** - */ - function decode_response(response_raw: string): type_response; - /** - */ - function encode_request(request: type_request): string; - /** - * @todo description - */ - function data_multistatus_encode_xml(data_multistatus: type_data_multistatus): lib_plankton.xml.type_node_data; - /** - */ - function data_multistatus_encode(data_multistatus: type_data_multistatus): string; -} -declare namespace lib_plankton.caldav { - /** - * @todo try to base on lib_plankton.webdav.enum_method - */ - enum enum_method { - options = "options", - head = "head", - get = "get", - delete = "delete", - post = "post", - put = "put", - patch = "patch", - propfind = "propfind", - proppatch = "proppatch", - mkcol = "mkcol", - copy = "copy", - move = "move", - lock = "lock", - unlock = "unlock", - report = "report", - mkcalendar = "mkcalendar", - acl = "acl" - } - /** - * @todo try to base on lib_plankton.webdav.enum_status_code - */ - 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, - multistatus = 207, - 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 - } - /** - */ - type type_request = lib_plankton.http_base.type_request; - /** - */ - type type_response = lib_plankton.http_base.type_response; -} -declare namespace lib_plankton.caldav { - /** - */ - function is_special_method(method: enum_method): boolean; - /** - */ - function encode_method(method: enum_method): string; - /** - */ - function decode_method(method_raw: string): enum_method; - /** - * @todo check - */ - function has_body(method: enum_method): boolean; - /** - */ - function encode_request(request: type_request): string; - /** - */ - function decode_request(request_raw: string): type_request; - /** - */ - function encode_response(response: type_response): string; - /** - */ - function decode_response(response_raw: string): type_response; -} declare namespace lib_plankton.markdown { /** * @author fenris @@ -3979,6 +3678,10 @@ declare namespace lib_plankton.markdown { * @author fenris */ function sectionhead(level: int, content: string): string; + /** + * @author fenris + */ + function list(level: int, elements: Array): string; } declare namespace lib_plankton.api { /** @@ -4286,7 +3989,7 @@ declare namespace lib_plankton.rest_base { servers?: Array; }): any; } -declare namespace lib_plankton.rest_caldav { +declare namespace lib_plankton.rest_http { /** */ type type_oas_schema = lib_plankton.rest_base.type_oas_schema; @@ -4306,7 +4009,7 @@ declare namespace lib_plankton.rest_caldav { */ type type_rest = lib_plankton.rest_base.type_rest; } -declare namespace lib_plankton.rest_caldav { +declare namespace lib_plankton.rest_http { /** */ function make(options?: { @@ -4330,25 +4033,25 @@ declare namespace lib_plankton.rest_caldav { }; }); actions?: Array<{ - http_method: lib_plankton.caldav.enum_method; + http_method: lib_plankton.http.enum_method; path: string; options: lib_plankton.rest_base.type_action_options; }>; }): type_rest; /** */ - function register(rest: type_rest, http_method: lib_plankton.caldav.enum_method, path: string, options: lib_plankton.rest_base.type_action_options): void; + function register(rest: type_rest, http_method: lib_plankton.http.enum_method, path: string, options: lib_plankton.rest_base.type_action_options): void; /** * @todo check request body mimetype? * @todo check query paramater validity * @todo improve status code mapping */ - function call(rest: type_rest, http_request: lib_plankton.caldav.type_request, { "checklevel_restriction": option_checklevel_restriction, "checklevel_input": option_checklevel_input, "checklevel_output": option_checklevel_output, "set_content_length": option_set_content_length, }?: { + function call(rest: type_rest, http_request: lib_plankton.http.type_request, { "checklevel_restriction": option_checklevel_restriction, "checklevel_input": option_checklevel_input, "checklevel_output": option_checklevel_output, "set_content_length": option_set_content_length, }?: { checklevel_restriction?: lib_plankton.api.enum_checklevel; checklevel_input?: lib_plankton.api.enum_checklevel; checklevel_output?: lib_plankton.api.enum_checklevel; set_content_length?: boolean; - }): Promise; + }): Promise; /** * @see https://swagger.io/specification/#openrest-object */ diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index 7275231..9caec5f 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -1459,6 +1459,16 @@ var lib_plankton; }))); } call.try_catch_wrap_async = try_catch_wrap_async; + /** + */ + function sleep(seconds) { + return (new Promise((resolve, reject) => { + setTimeout(() => { + resolve(undefined); + }, Math.floor(seconds * 1000)); + })); + } + call.sleep = sleep; })(call = lib_plankton.call || (lib_plankton.call = {})); })(lib_plankton || (lib_plankton = {})); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -4623,10 +4633,9 @@ var lib_plankton; } } /** - * @todo versioning */ - function refine(schema, value_raw) { - const adaption = adapt(schema, value_raw); + function refine(schema, content) { + const adaption = adapt(schema, content); if (!lib_plankton.pod.is_filled(adaption.result)) { throw (new Error("conf could not be loaded:\n" + @@ -4640,6 +4649,7 @@ var lib_plankton; } conf.refine = refine; /** + * @deprecated */ function load(schema, path) { return (((path === null) @@ -4651,6 +4661,37 @@ var lib_plankton; .then((data_raw) => Promise.resolve(refine(schema, data_raw)))); } conf.load = load; + /** + */ + async function load_versioned(path, get_schema, migrations) { + const file_content = await lib_plankton.file.read(path); + const sheet_raw = lib_plankton.json.decode(file_content); + const schema = get_schema(sheet_raw.version); + let sheet = { + "version": sheet_raw.version, + "content": refine(schema, sheet_raw.content), + }; + while (sheet.version in migrations) { + const migration = migrations[sheet.version]; + if (!(migration === null)) { + lib_plankton.log._info("plankton.conf.load.migration", { + "details": { + "from": sheet.version, + "to": migration.target, + } + }); + sheet = { + "version": migration.target, + "content": migration.function(sheet.content), + }; + } + else { + break; + } + } + return sheet; + } + conf.load_versioned = load_versioned; })(conf = lib_plankton.conf || (lib_plankton.conf = {})); })(lib_plankton || (lib_plankton = {})); /* @@ -10786,10 +10827,17 @@ var lib_plankton; function is_after(pit, reference) { return (pit > reference); } + pit_1.is_after = is_after; + /** + */ + function is_equal_or_after(pit, reference) { + return (pit >= reference); + } + pit_1.is_equal_or_after = is_equal_or_after; /** */ function is_between(pit, reference_left, reference_right) { - return (is_after(pit, reference_left) + return (is_equal_or_after(pit, reference_left) && is_before(pit, reference_right)); } @@ -10799,6 +10847,7 @@ var lib_plankton; function shift_hour(pit, increment) { return (pit + (60 * 60 * increment)); } + pit_1.shift_hour = shift_hour; /** */ function shift_day(pit, increment) { @@ -10816,6 +10865,7 @@ var lib_plankton; function shift_year(pit, increment) { return (pit + (60 * 60 * 24 * 365 * increment)); } + pit_1.shift_year = shift_year; /** */ function trunc_minute(pit) { @@ -10843,6 +10893,7 @@ var lib_plankton; }; return from_datetime(datetime_output); } + pit_1.trunc_minute = trunc_minute; /** */ function trunc_hour(pit) { @@ -10866,6 +10917,7 @@ var lib_plankton; }; return from_datetime(datetime_output); } + pit_1.trunc_hour = trunc_hour; /** */ function trunc_day(pit) { @@ -10885,6 +10937,7 @@ var lib_plankton; }; return from_datetime(datetime_output); } + pit_1.trunc_day = trunc_day; /** */ function trunc_week(pit) { @@ -10916,6 +10969,7 @@ var lib_plankton; }; return from_datetime(datetime_output); } + pit_1.trunc_month = trunc_month; /** */ function trunc_year(pit) { @@ -10935,6 +10989,7 @@ var lib_plankton; }; return from_datetime(datetime_output); } + pit_1.trunc_year = trunc_year; /** */ function now() { @@ -12129,11 +12184,11 @@ var lib_plankton; })); } // categories - if ((vevent.categories !== undefined) && (vevent.categories.length > 0)) { - content_lines.push(lib_plankton.string.coin("CATEGORIES:{{categories}}", { - "categories": vevent.categories.join(","), - })); - } + if ((vevent.categories !== undefined) && (vevent.categories.length > 0)) { + content_lines.push(lib_plankton.string.coin("CATEGORIES:{{categories}}", { + "categories": vevent.categories.join(","), + })); + } } content_lines.push("END:VEVENT"); }); @@ -12762,1007 +12817,6 @@ var lib_plankton; })(http = lib_plankton.http || (lib_plankton.http = {})); })(lib_plankton || (lib_plankton = {})); /* -This file is part of »bacterio-plankton:xml«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:xml« 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:xml« 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:xml«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var xml; - (function (xml) { - /** - */ - function string_repeat(symbol, count) { - return ((count <= 0) ? "" : (string_repeat(symbol, count - 1) + symbol)); - } - /** - */ - function get_node_logic(node_data) { - return lib_plankton.call.distinguish(node_data, { - "root": function (_a) { - var version = _a["version"], encoding = _a["encoding"], content = _a["content"]; - return ({ - "compile": function (depth) { return (("") - + - "\n" - + - get_node_logic(content).compile(depth)); } - }); - }, - "comment": function (content) { return ({ - "compile": function (depth) { return (string_repeat("\t", depth) - + - content); } - }); }, - "text": function (content) { return ({ - "compile": function (depth) { return (string_repeat("\t", depth) - + - content); } - }); }, - "complex": function (_a) { - var tag = _a["tag"], attributes = _a["attributes"], children = _a["children"]; - return ({ - "compile": function (depth) { - var output = ""; - var attributes_string = (Object.keys(attributes) - .filter(function (key) { return (attributes[key] !== null); }) - .map(function (key) { return (" " + key + "=" + ("\"" + attributes[key] + "\"")); }) - .join("")); - if (children.length === 0) { - output += (string_repeat("\t", depth) - + - ("<" + tag + attributes_string + "/>") - + - "\n"); - } - else if ((children.length === 1) - && - (children[0].kind === "text")) { - output += (string_repeat("\t", depth) - + - ("<" + tag + attributes_string + ">") - + - get_node_logic(children[0]).compile(0) - + - ("") - + - "\n"); - } - else { - output += (string_repeat("\t", depth) - + - ("<" + tag + attributes_string + ">") - + - "\n"); - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - output += get_node_logic(child).compile(depth + 1); - } - output += (string_repeat("\t", depth) - + - ("") - + - "\n"); - } - return output; - } - }); - } - }); - } - xml.get_node_logic = get_node_logic; - /** - */ - function convert_xml2js_data_to_node(is_root, tag, xml2js_data) { - if (typeof (xml2js_data) === "string") { - return ((tag === null) - ? - { - "kind": "text", - "data": xml2js_data - } - : - { - "kind": "complex", - "data": { - "tag": tag, - "attributes": {}, - "children": ((xml2js_data === "") - ? - [] - : - [ - { - "kind": "text", - "data": xml2js_data - } - ]) - } - }); - } - else { - if (tag === null) { - throw (new Error("tag required")); - } - else { - var attributes = {}; - var children = []; - for (var _i = 0, _a = Object.entries(xml2js_data); _i < _a.length; _i++) { - var _b = _a[_i], key = _b[0], value = _b[1]; - if (key === "$") { - attributes = value; - } - else { - if (value instanceof Array) { - for (var _c = 0, _d = value; _c < _d.length; _c++) { - var sub = _d[_c]; - children.push(convert_xml2js_data_to_node(false, key, sub)); - } - } - else { - children.push(convert_xml2js_data_to_node(false, key, value)); - } - } - } - if (is_root - && - (Object.keys(attributes).length === 0) - && - (children.length === 1)) { - return children[0]; - } - else { - return { - "kind": "complex", - "data": { - "tag": tag, - "attributes": attributes, - "children": children - } - }; - } - } - } - } - /** - */ - function parse(xml_string) { - var nm_xml2js = require("xml2js"); - return (nm_xml2js.parseStringPromise(xml_string) - .then(function (data_raw) { return Promise.resolve(data_raw); }) - .then(function (xml2js_data) { return Promise.resolve(convert_xml2js_data_to_node(true, "_", xml2js_data)); })); - } - xml.parse = parse; - })(xml = lib_plankton.xml || (lib_plankton.xml = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:webdav«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:webdav« 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:webdav« 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:webdav«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var webdav; - (function (webdav) { - /** - * @todo try to base on lib_plankton.http.enum_method - */ - let enum_method; - (function (enum_method) { - enum_method["options"] = "options"; - enum_method["head"] = "head"; - enum_method["get"] = "get"; - enum_method["delete"] = "delete"; - enum_method["post"] = "post"; - enum_method["put"] = "put"; - enum_method["patch"] = "patch"; - enum_method["propfind"] = "propfind"; - enum_method["proppatch"] = "proppatch"; - enum_method["mkcol"] = "mkcol"; - enum_method["copy"] = "copy"; - enum_method["move"] = "move"; - enum_method["lock"] = "lock"; - enum_method["unlock"] = "unlock"; - })(enum_method = webdav.enum_method || (webdav.enum_method = {})); - ; - /** - * @todo try to base on lib_plankton.http.enum_status_code - */ - let enum_status_code; - (function (enum_status_code) { - enum_status_code[enum_status_code["continue_"] = 100] = "continue_"; - enum_status_code[enum_status_code["switching_protocols"] = 101] = "switching_protocols"; - enum_status_code[enum_status_code["early_hints"] = 103] = "early_hints"; - enum_status_code[enum_status_code["ok"] = 200] = "ok"; - enum_status_code[enum_status_code["created"] = 201] = "created"; - enum_status_code[enum_status_code["accepted"] = 202] = "accepted"; - enum_status_code[enum_status_code["non_authoritative_information"] = 203] = "non_authoritative_information"; - enum_status_code[enum_status_code["no_content"] = 204] = "no_content"; - enum_status_code[enum_status_code["reset_content"] = 205] = "reset_content"; - enum_status_code[enum_status_code["partial_coentent"] = 206] = "partial_coentent"; - enum_status_code[enum_status_code["multistatus"] = 207] = "multistatus"; - enum_status_code[enum_status_code["multiple_choices"] = 300] = "multiple_choices"; - enum_status_code[enum_status_code["moved_permanently"] = 301] = "moved_permanently"; - enum_status_code[enum_status_code["found"] = 302] = "found"; - enum_status_code[enum_status_code["see_other"] = 303] = "see_other"; - enum_status_code[enum_status_code["not_modified"] = 304] = "not_modified"; - enum_status_code[enum_status_code["temporary_redirect"] = 307] = "temporary_redirect"; - enum_status_code[enum_status_code["permanent_redirect"] = 308] = "permanent_redirect"; - enum_status_code[enum_status_code["bad_request"] = 400] = "bad_request"; - enum_status_code[enum_status_code["unauthorized"] = 401] = "unauthorized"; - enum_status_code[enum_status_code["payment_required"] = 402] = "payment_required"; - enum_status_code[enum_status_code["forbidden"] = 403] = "forbidden"; - enum_status_code[enum_status_code["not_found"] = 404] = "not_found"; - enum_status_code[enum_status_code["method_not_allowed"] = 405] = "method_not_allowed"; - enum_status_code[enum_status_code["not_acceptable"] = 406] = "not_acceptable"; - enum_status_code[enum_status_code["proxy_authentication_required"] = 407] = "proxy_authentication_required"; - enum_status_code[enum_status_code["request_timeout"] = 408] = "request_timeout"; - enum_status_code[enum_status_code["conflict"] = 409] = "conflict"; - enum_status_code[enum_status_code["gone"] = 410] = "gone"; - enum_status_code[enum_status_code["length_required"] = 411] = "length_required"; - enum_status_code[enum_status_code["precondition_failed"] = 412] = "precondition_failed"; - enum_status_code[enum_status_code["payload_too_large"] = 413] = "payload_too_large"; - enum_status_code[enum_status_code["uri_too_long"] = 414] = "uri_too_long"; - enum_status_code[enum_status_code["unsupported_media_type"] = 415] = "unsupported_media_type"; - enum_status_code[enum_status_code["range_not_satisfiable"] = 416] = "range_not_satisfiable"; - enum_status_code[enum_status_code["expectation_failed"] = 417] = "expectation_failed"; - enum_status_code[enum_status_code["i_m_a_teapot"] = 418] = "i_m_a_teapot"; - enum_status_code[enum_status_code["unprocessable_entity"] = 422] = "unprocessable_entity"; - enum_status_code[enum_status_code["too_early"] = 425] = "too_early"; - enum_status_code[enum_status_code["upgrade_required"] = 426] = "upgrade_required"; - enum_status_code[enum_status_code["precondition_required"] = 428] = "precondition_required"; - enum_status_code[enum_status_code["too_many_requests"] = 429] = "too_many_requests"; - enum_status_code[enum_status_code["request_header_fields_too_large"] = 431] = "request_header_fields_too_large"; - enum_status_code[enum_status_code["unavailable_for_legal_reasons"] = 451] = "unavailable_for_legal_reasons"; - enum_status_code[enum_status_code["internal_server_error"] = 500] = "internal_server_error"; - enum_status_code[enum_status_code["not_implemented"] = 501] = "not_implemented"; - enum_status_code[enum_status_code["bad_gateway"] = 502] = "bad_gateway"; - enum_status_code[enum_status_code["service_unavailable"] = 503] = "service_unavailable"; - enum_status_code[enum_status_code["gateway_timeout"] = 504] = "gateway_timeout"; - enum_status_code[enum_status_code["http_version_not_supported"] = 505] = "http_version_not_supported"; - enum_status_code[enum_status_code["variant_also_negotiates"] = 506] = "variant_also_negotiates"; - enum_status_code[enum_status_code["insufficient_storage"] = 507] = "insufficient_storage"; - enum_status_code[enum_status_code["loop_detected"] = 508] = "loop_detected"; - enum_status_code[enum_status_code["not_extended"] = 510] = "not_extended"; - enum_status_code[enum_status_code["network_authentication"] = 511] = "network_authentication"; - })(enum_status_code = webdav.enum_status_code || (webdav.enum_status_code = {})); - })(webdav = lib_plankton.webdav || (lib_plankton.webdav = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:webdav«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:webdav« 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:webdav« 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:webdav«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var webdav; - (function (webdav) { - /** - */ - function is_special_method(method) { - return ((method === webdav.enum_method.propfind) - || - (method === webdav.enum_method.proppatch) - || - (method === webdav.enum_method.mkcol) - || - (method === webdav.enum_method.copy) - || - (method === webdav.enum_method.move) - || - (method === webdav.enum_method.lock) - || - (method === webdav.enum_method.unlock)); - } - webdav.is_special_method = is_special_method; - /** - * @author roydfalk - */ - function encode_method(method) { - switch (method) { - case webdav.enum_method.get: return "GET"; - case webdav.enum_method.post: return "POST"; - case webdav.enum_method.patch: return "PATCH"; - case webdav.enum_method.put: return "PUT"; - case webdav.enum_method.delete: return "DELETE"; - case webdav.enum_method.options: return "OPTIONS"; - case webdav.enum_method.head: return "HEAD"; - case webdav.enum_method.propfind: return "PROPFIND"; - case webdav.enum_method.proppatch: return "PROPPATCH"; - case webdav.enum_method.mkcol: return "MKCOL"; - case webdav.enum_method.copy: return "COPY"; - case webdav.enum_method.move: return "MOVE"; - case webdav.enum_method.lock: return "LOCK"; - case webdav.enum_method.unlock: return "UNLOCK"; - default: throw (new Error("impossible")); - } - } - webdav.encode_method = encode_method; - /** - * @author roydfalk - */ - function decode_method(method_raw) { - switch (method_raw) { - case "GET": return webdav.enum_method.get; - case "POST": return webdav.enum_method.post; - case "PATCH": return webdav.enum_method.patch; - case "PUT": return webdav.enum_method.put; - case "DELETE": return webdav.enum_method.delete; - case "OPTIONS": return webdav.enum_method.options; - case "HEAD": return webdav.enum_method.head; - case "PROPFIND": return webdav.enum_method.propfind; - case "PROPPATCH": return webdav.enum_method.proppatch; - case "MKCOL": return webdav.enum_method.mkcol; - case "COPY": return webdav.enum_method.copy; - case "MOVE": return webdav.enum_method.move; - case "LOCK": return webdav.enum_method.lock; - case "UNLOCK": return webdav.enum_method.unlock; - default: throw (new Error("unhandled methoD: " + method_raw)); - } - } - webdav.decode_method = decode_method; - /** - */ - function encode_status_code(status_code) { - return status_code.toFixed(0); - } - /** - * @todo check for existance - */ - function decode_status_code(status_code_raw) { - return parseInt(status_code_raw); - } - /** - */ - function get_status_text(statuscode) { - switch (statuscode) { - case 100: return "Continue"; - case 101: return "Switching Protocols"; - case 103: return "Early Hints"; - case 200: return "OK"; - case 201: return "Created"; - case 202: return "Accepted"; - case 203: return "Non-Authoritative Information"; - case 204: return "No Content"; - case 205: return "Reset Content"; - case 206: return "Partial Content"; - case 207: return "Multistatus"; - case 300: return "Multiple Choices"; - case 301: return "Moved Permanently"; - case 302: return "Found"; - case 303: return "See Other"; - case 304: return "Not Modified"; - case 307: return "Temporary Redirect"; - case 308: return "Permanent Redirect"; - case 400: return "Bad Request"; - case 401: return "Unauthorized"; - case 402: return "Payment Required"; - case 403: return "Forbidden"; - case 404: return "Not Found"; - case 405: return "Method Not Allowed"; - case 406: return "Not Acceptable"; - case 407: return "Proxy Authentication Required"; - case 408: return "Request Timeout"; - case 409: return "Conflict"; - case 410: return "Gone"; - case 411: return "Length Required"; - case 412: return "Precondition Failed"; - case 413: return "Payload Too Large"; - case 414: return "URI Too Long"; - case 415: return "Unsupported Media Type"; - case 416: return "Range Not Satisfiable"; - case 417: return "Expectation Failed"; - case 418: return "I'm a teapot"; - case 422: return "Unprocessable Entity"; - case 425: return "Too Early"; - case 426: return "Upgrade Required"; - case 428: return "Precondition Required"; - case 429: return "Too Many Requests"; - case 431: return "Request Header Fields Too Large"; - case 451: return "Unavailable For Legal Reasons"; - case 500: return "Internal Server Error"; - case 501: return "Not Implemented"; - case 502: return "Bad Gateway"; - case 503: return "Service Unavailable"; - case 504: return "Gateway Timeout"; - case 505: return "HTTP Version Not Supported"; - case 506: return "Variant Also Negotiates"; - case 507: return "Insufficient Storage"; - case 508: return "Loop Detected"; - case 510: return "Not Extended"; - case 511: return "Network Authentication"; - default: throw (new Error("unhandled statuscode: " + statuscode.toFixed(0))); - } - } - /** - * @todo check - */ - function has_body(method) { - return [ - webdav.enum_method.post, - webdav.enum_method.put, - webdav.enum_method.patch, - webdav.enum_method.propfind, - webdav.enum_method.proppatch, - webdav.enum_method.mkcol, - webdav.enum_method.copy, - webdav.enum_method.move, - webdav.enum_method.lock, - ].includes(method); - } - webdav.has_body = has_body; - /** - */ - function decode_request(request_raw) { - return lib_plankton.http_base.decode_request(decode_method, has_body, request_raw); - } - webdav.decode_request = decode_request; - /** - */ - function encode_response(response) { - return lib_plankton.http_base.encode_response(encode_status_code, get_status_text, response); - } - webdav.encode_response = encode_response; - /** - */ - function decode_response(response_raw) { - return lib_plankton.http_base.decode_response(decode_status_code, response_raw); - } - webdav.decode_response = decode_response; - /** - */ - function encode_request(request) { - return lib_plankton.http_base.encode_request(encode_method, request); - } - webdav.encode_request = encode_request; - /** - */ - function data_href_encode_xml(data_href) { - return { - "kind": "complex", - "data": { - "tag": "D:href", - "attributes": {}, - "children": [ - { - "kind": "text", - "data": data_href, - }, - ] - } - }; - } - /** - */ - function data_status_encode_xml(data_status) { - return { - "kind": "complex", - "data": { - "tag": "D:status", - "attributes": {}, - "children": [ - { - "kind": "text", - "data": data_status, - }, - ] - } - }; - } - /** - */ - function data_prop_encode_xml(data_prop) { - return { - "kind": "complex", - "data": { - "tag": data_prop.name, - "attributes": {}, - "children": lib_plankton.call.distinguish(data_prop.value, { - "none": () => ([]), - "primitive": (content) => ([ - { - "kind": "text", - "data": content - }, - ]), - "href": (url) => ([ - { - "kind": "complex", - "data": { - "tag": "D:href", - "attributes": {}, - "children": [ - { - "kind": "text", - "data": url - } - ] - } - }, - ]), - "resourcetype": ({ "kind": kind, "type": type }) => ([ - { - "kind": "complex", - "data": { - "tag": ("D:" + kind), - "attributes": {}, - "children": [] - } - }, - { - "kind": "complex", - "data": { - "tag": ("C:" + type), - "attributes": {}, - "children": [] - } - }, - ]), - "privileges": (items) => ([ - { - "kind": "complex", - "data": { - "tag": "D:privilege", - "attributes": {}, - "children": items.map(item => ({ - "kind": "complex", - "data": { - "tag": ("D:" + item), - "attributes": {}, - "children": [] - } - })) - } - }, - ]), - "component_set": ({ "name": name, "items": items }) => (items.map(item => ({ - "kind": "complex", - "data": { - "tag": "C:comp", - "attributes": { - "name": item - }, - "children": [] - } - }))), - }) - } - }; - } - /** - */ - function data_propstat_encode_xml(data_propstat) { - return { - "kind": "complex", - "data": { - "tag": "D:propstat", - "attributes": { - // todo xmlns:R - }, - "children": [ - { - "kind": "complex", - "data": { - "tag": "D:prop", - "attributes": { - // todo xmlns:R - }, - "children": data_propstat.prop.map(data_prop_encode_xml), - }, - }, - data_status_encode_xml(data_propstat.status), - ] - } - }; - } - /** - */ - function data_response_encode_xml(data_response) { - return { - "kind": "complex", - "data": { - "tag": "D:response", - "attributes": {}, - "children": ([ - data_href_encode_xml(data_response.href), - ] - .concat(("hrefs" in data_response.body) - ? - (data_response.body.hrefs.map(data_href_encode_xml) - .concat([ - data_status_encode_xml(data_response.body.status), - ])) - : - data_response.body.propstats.map(data_propstat_encode_xml))) - } - }; - } - /** - * @todo description - */ - function data_multistatus_encode_xml(data_multistatus) { - return { - "kind": "complex", - "data": { - "tag": "D:multistatus", - "attributes": { - "xmlns:D": "DAV:", - "xmlns:C": "urn:ietf:params:xml:ns:caldav", - "xmlns:CS": "http://calendarserver.org/ns/", - }, - "children": data_multistatus.responses.map(data_response_encode_xml), - } - }; - } - webdav.data_multistatus_encode_xml = data_multistatus_encode_xml; - /** - */ - function data_multistatus_encode(data_multistatus) { - return lib_plankton.xml.get_node_logic(data_multistatus_encode_xml(data_multistatus)).compile(0); - } - webdav.data_multistatus_encode = data_multistatus_encode; - })(webdav = lib_plankton.webdav || (lib_plankton.webdav = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:caldav«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:caldav« 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:caldav« 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:caldav«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var caldav; - (function (caldav) { - /** - * @todo try to base on lib_plankton.webdav.enum_method - */ - let enum_method; - (function (enum_method) { - enum_method["options"] = "options"; - enum_method["head"] = "head"; - enum_method["get"] = "get"; - enum_method["delete"] = "delete"; - enum_method["post"] = "post"; - enum_method["put"] = "put"; - enum_method["patch"] = "patch"; - enum_method["propfind"] = "propfind"; - enum_method["proppatch"] = "proppatch"; - enum_method["mkcol"] = "mkcol"; - enum_method["copy"] = "copy"; - enum_method["move"] = "move"; - enum_method["lock"] = "lock"; - enum_method["unlock"] = "unlock"; - enum_method["report"] = "report"; - enum_method["mkcalendar"] = "mkcalendar"; - enum_method["acl"] = "acl"; - })(enum_method = caldav.enum_method || (caldav.enum_method = {})); - ; - /** - * @todo try to base on lib_plankton.webdav.enum_status_code - */ - let enum_status_code; - (function (enum_status_code) { - enum_status_code[enum_status_code["continue_"] = 100] = "continue_"; - enum_status_code[enum_status_code["switching_protocols"] = 101] = "switching_protocols"; - enum_status_code[enum_status_code["early_hints"] = 103] = "early_hints"; - enum_status_code[enum_status_code["ok"] = 200] = "ok"; - enum_status_code[enum_status_code["created"] = 201] = "created"; - enum_status_code[enum_status_code["accepted"] = 202] = "accepted"; - enum_status_code[enum_status_code["non_authoritative_information"] = 203] = "non_authoritative_information"; - enum_status_code[enum_status_code["no_content"] = 204] = "no_content"; - enum_status_code[enum_status_code["reset_content"] = 205] = "reset_content"; - enum_status_code[enum_status_code["partial_coentent"] = 206] = "partial_coentent"; - enum_status_code[enum_status_code["multistatus"] = 207] = "multistatus"; - enum_status_code[enum_status_code["multiple_choices"] = 300] = "multiple_choices"; - enum_status_code[enum_status_code["moved_permanently"] = 301] = "moved_permanently"; - enum_status_code[enum_status_code["found"] = 302] = "found"; - enum_status_code[enum_status_code["see_other"] = 303] = "see_other"; - enum_status_code[enum_status_code["not_modified"] = 304] = "not_modified"; - enum_status_code[enum_status_code["temporary_redirect"] = 307] = "temporary_redirect"; - enum_status_code[enum_status_code["permanent_redirect"] = 308] = "permanent_redirect"; - enum_status_code[enum_status_code["bad_request"] = 400] = "bad_request"; - enum_status_code[enum_status_code["unauthorized"] = 401] = "unauthorized"; - enum_status_code[enum_status_code["payment_required"] = 402] = "payment_required"; - enum_status_code[enum_status_code["forbidden"] = 403] = "forbidden"; - enum_status_code[enum_status_code["not_found"] = 404] = "not_found"; - enum_status_code[enum_status_code["method_not_allowed"] = 405] = "method_not_allowed"; - enum_status_code[enum_status_code["not_acceptable"] = 406] = "not_acceptable"; - enum_status_code[enum_status_code["proxy_authentication_required"] = 407] = "proxy_authentication_required"; - enum_status_code[enum_status_code["request_timeout"] = 408] = "request_timeout"; - enum_status_code[enum_status_code["conflict"] = 409] = "conflict"; - enum_status_code[enum_status_code["gone"] = 410] = "gone"; - enum_status_code[enum_status_code["length_required"] = 411] = "length_required"; - enum_status_code[enum_status_code["precondition_failed"] = 412] = "precondition_failed"; - enum_status_code[enum_status_code["payload_too_large"] = 413] = "payload_too_large"; - enum_status_code[enum_status_code["uri_too_long"] = 414] = "uri_too_long"; - enum_status_code[enum_status_code["unsupported_media_type"] = 415] = "unsupported_media_type"; - enum_status_code[enum_status_code["range_not_satisfiable"] = 416] = "range_not_satisfiable"; - enum_status_code[enum_status_code["expectation_failed"] = 417] = "expectation_failed"; - enum_status_code[enum_status_code["i_m_a_teapot"] = 418] = "i_m_a_teapot"; - enum_status_code[enum_status_code["unprocessable_entity"] = 422] = "unprocessable_entity"; - enum_status_code[enum_status_code["too_early"] = 425] = "too_early"; - enum_status_code[enum_status_code["upgrade_required"] = 426] = "upgrade_required"; - enum_status_code[enum_status_code["precondition_required"] = 428] = "precondition_required"; - enum_status_code[enum_status_code["too_many_requests"] = 429] = "too_many_requests"; - enum_status_code[enum_status_code["request_header_fields_too_large"] = 431] = "request_header_fields_too_large"; - enum_status_code[enum_status_code["unavailable_for_legal_reasons"] = 451] = "unavailable_for_legal_reasons"; - enum_status_code[enum_status_code["internal_server_error"] = 500] = "internal_server_error"; - enum_status_code[enum_status_code["not_implemented"] = 501] = "not_implemented"; - enum_status_code[enum_status_code["bad_gateway"] = 502] = "bad_gateway"; - enum_status_code[enum_status_code["service_unavailable"] = 503] = "service_unavailable"; - enum_status_code[enum_status_code["gateway_timeout"] = 504] = "gateway_timeout"; - enum_status_code[enum_status_code["http_version_not_supported"] = 505] = "http_version_not_supported"; - enum_status_code[enum_status_code["variant_also_negotiates"] = 506] = "variant_also_negotiates"; - enum_status_code[enum_status_code["insufficient_storage"] = 507] = "insufficient_storage"; - enum_status_code[enum_status_code["loop_detected"] = 508] = "loop_detected"; - enum_status_code[enum_status_code["not_extended"] = 510] = "not_extended"; - enum_status_code[enum_status_code["network_authentication"] = 511] = "network_authentication"; - })(enum_status_code = caldav.enum_status_code || (caldav.enum_status_code = {})); - })(caldav = lib_plankton.caldav || (lib_plankton.caldav = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:caldav«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:caldav« 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:caldav« 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:caldav«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var caldav; - (function (caldav) { - /** - */ - function is_special_method(method) { - return ((method === caldav.enum_method.propfind) - || - (method === caldav.enum_method.proppatch) - || - (method === caldav.enum_method.mkcol) - || - (method === caldav.enum_method.copy) - || - (method === caldav.enum_method.move) - || - (method === caldav.enum_method.lock) - || - (method === caldav.enum_method.unlock)); - } - caldav.is_special_method = is_special_method; - /** - */ - function encode_method(method) { - switch (method) { - case caldav.enum_method.get: return "GET"; - case caldav.enum_method.post: return "POST"; - case caldav.enum_method.patch: return "PATCH"; - case caldav.enum_method.put: return "PUT"; - case caldav.enum_method.delete: return "DELETE"; - case caldav.enum_method.options: return "OPTIONS"; - case caldav.enum_method.head: return "HEAD"; - case caldav.enum_method.propfind: return "PROPFIND"; - case caldav.enum_method.proppatch: return "PROPPATCH"; - case caldav.enum_method.mkcol: return "MKCOL"; - case caldav.enum_method.copy: return "COPY"; - case caldav.enum_method.move: return "MOVE"; - case caldav.enum_method.lock: return "LOCK"; - case caldav.enum_method.unlock: return "UNLOCK"; - case caldav.enum_method.report: return "REPORT"; - case caldav.enum_method.mkcalendar: return "MKCALENDAR"; - case caldav.enum_method.acl: return "ACL"; - default: throw (new Error("unhandled method: " + method)); - } - } - caldav.encode_method = encode_method; - /** - */ - function decode_method(method_raw) { - switch (method_raw) { - case "GET": return caldav.enum_method.get; - case "POST": return caldav.enum_method.post; - case "PATCH": return caldav.enum_method.patch; - case "PUT": return caldav.enum_method.put; - case "DELETE": return caldav.enum_method.delete; - case "OPTIONS": return caldav.enum_method.options; - case "HEAD": return caldav.enum_method.head; - case "PROPFIND": return caldav.enum_method.propfind; - case "PROPPATCH": return caldav.enum_method.proppatch; - case "MKCOL": return caldav.enum_method.mkcol; - case "COPY": return caldav.enum_method.copy; - case "MOVE": return caldav.enum_method.move; - case "LOCK": return caldav.enum_method.lock; - case "UNLOCK": return caldav.enum_method.unlock; - case "REPORT": return caldav.enum_method.report; - case "MKCALENDAR": return caldav.enum_method.mkcalendar; - case "ACL": return caldav.enum_method.acl; - default: throw (new Error("unhandled method: " + method_raw)); - } - } - caldav.decode_method = decode_method; - /** - */ - function encode_status_code(status_code) { - return status_code.toFixed(0); - } - /** - * @todo check for existance - */ - function decode_status_code(status_code_raw) { - return parseInt(status_code_raw); - } - /** - */ - function get_status_text(statuscode) { - switch (statuscode) { - case 100: return "Continue"; - case 101: return "Switching Protocols"; - case 103: return "Early Hints"; - case 200: return "OK"; - case 201: return "Created"; - case 202: return "Accepted"; - case 203: return "Non-Authoritative Information"; - case 204: return "No Content"; - case 205: return "Reset Content"; - case 206: return "Partial Content"; - case 207: return "Multistatus"; - case 300: return "Multiple Choices"; - case 301: return "Moved Permanently"; - case 302: return "Found"; - case 303: return "See Other"; - case 304: return "Not Modified"; - case 307: return "Temporary Redirect"; - case 308: return "Permanent Redirect"; - case 400: return "Bad Request"; - case 401: return "Unauthorized"; - case 402: return "Payment Required"; - case 403: return "Forbidden"; - case 404: return "Not Found"; - case 405: return "Method Not Allowed"; - case 406: return "Not Acceptable"; - case 407: return "Proxy Authentication Required"; - case 408: return "Request Timeout"; - case 409: return "Conflict"; - case 410: return "Gone"; - case 411: return "Length Required"; - case 412: return "Precondition Failed"; - case 413: return "Payload Too Large"; - case 414: return "URI Too Long"; - case 415: return "Unsupported Media Type"; - case 416: return "Range Not Satisfiable"; - case 417: return "Expectation Failed"; - case 418: return "I'm a teapot"; - case 422: return "Unprocessable Entity"; - case 425: return "Too Early"; - case 426: return "Upgrade Required"; - case 428: return "Precondition Required"; - case 429: return "Too Many Requests"; - case 431: return "Request Header Fields Too Large"; - case 451: return "Unavailable For Legal Reasons"; - case 500: return "Internal Server Error"; - case 501: return "Not Implemented"; - case 502: return "Bad Gateway"; - case 503: return "Service Unavailable"; - case 504: return "Gateway Timeout"; - case 505: return "HTTP Version Not Supported"; - case 506: return "Variant Also Negotiates"; - case 507: return "Insufficient Storage"; - case 508: return "Loop Detected"; - case 510: return "Not Extended"; - case 511: return "Network Authentication"; - default: throw (new Error("unhandled statuscode: " + statuscode.toFixed(0))); - } - } - /** - * @todo check - */ - function has_body(method) { - return [ - caldav.enum_method.post, - caldav.enum_method.put, - caldav.enum_method.patch, - caldav.enum_method.propfind, - caldav.enum_method.proppatch, - caldav.enum_method.mkcol, - caldav.enum_method.copy, - caldav.enum_method.move, - caldav.enum_method.lock, - ].includes(method); - } - caldav.has_body = has_body; - /** - */ - function encode_request(request) { - return lib_plankton.http_base.encode_request(encode_method, request); - } - caldav.encode_request = encode_request; - /** - */ - function decode_request(request_raw) { - return lib_plankton.http_base.decode_request(decode_method, has_body, request_raw); - } - caldav.decode_request = decode_request; - /** - */ - function encode_response(response) { - return lib_plankton.http_base.encode_response(encode_status_code, get_status_text, response); - } - caldav.encode_response = encode_response; - /** - */ - function decode_response(response_raw) { - return lib_plankton.http_base.decode_response(decode_status_code, response_raw); - } - caldav.decode_response = decode_response; - })(caldav = lib_plankton.caldav || (lib_plankton.caldav = {})); -})(lib_plankton || (lib_plankton = {})); -/* This file is part of »bacterio-plankton:markdown«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -13813,6 +12867,18 @@ var lib_plankton; }); } markdown.sectionhead = sectionhead; + /** + * @author fenris + */ + function list(level, elements) { + return (elements + .map(function (element) { return lib_plankton.string.coin("{{spaces}} {{content}}\n", { + "spaces": lib_plankton.string.repeat(" ", level), + "content": element + }); }) + .join("")); + } + markdown.list = list; })(markdown = lib_plankton.markdown || (lib_plankton.markdown = {})); })(lib_plankton || (lib_plankton = {})); /* @@ -14963,105 +14029,95 @@ var lib_plankton; })(rest_base = lib_plankton.rest_base || (lib_plankton.rest_base = {})); })(lib_plankton || (lib_plankton = {})); /* -This file is part of »bacterio-plankton:rest_caldav«. +This file is part of »bacterio-plankton:rest_http«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' -»bacterio-plankton:rest_caldav« is free software: you can redistribute it and/or modify +»bacterio-plankton:rest_http« 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:rest_caldav« is distributed in the hope that it will be useful, +»bacterio-plankton:rest_http« 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:rest_caldav«. If not, see . +along with »bacterio-plankton:rest_http«. If not, see . */ /* -This file is part of »bacterio-plankton:rest_caldav«. +This file is part of »bacterio-plankton:rest_http«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' -»bacterio-plankton:rest_caldav« is free software: you can redistribute it and/or modify +»bacterio-plankton:rest_http« 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:rest_caldav« is distributed in the hope that it will be useful, +»bacterio-plankton:rest_http« 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:rest_caldav«. If not, see . +along with »bacterio-plankton:rest_http«. If not, see . */ var lib_plankton; (function (lib_plankton) { - var rest_caldav; - (function (rest_caldav) { + var rest_http; + (function (rest_http) { /** */ function http_request_method_to_oas(http_request_method) { switch (http_request_method) { - case lib_plankton.caldav.enum_method.get: return "get"; - case lib_plankton.caldav.enum_method.post: return "post"; - case lib_plankton.caldav.enum_method.patch: return "patch"; - case lib_plankton.caldav.enum_method.head: return "head"; - case lib_plankton.caldav.enum_method.delete: return "delete"; - case lib_plankton.caldav.enum_method.options: return "options"; - case lib_plankton.caldav.enum_method.put: return "put"; - case lib_plankton.caldav.enum_method.propfind: return "propfind"; - case lib_plankton.caldav.enum_method.proppatch: return "proppatch"; - case lib_plankton.caldav.enum_method.mkcol: return "mkcol"; - case lib_plankton.caldav.enum_method.copy: return "copy"; - case lib_plankton.caldav.enum_method.move: return "move"; - case lib_plankton.caldav.enum_method.lock: return "lock"; - case lib_plankton.caldav.enum_method.unlock: return "unlock"; - case lib_plankton.caldav.enum_method.report: return "report"; - case lib_plankton.caldav.enum_method.mkcalendar: return "mkcalendar"; - case lib_plankton.caldav.enum_method.acl: return "acl"; + case lib_plankton.http.enum_method.get: return "get"; + case lib_plankton.http.enum_method.post: return "post"; + case lib_plankton.http.enum_method.patch: return "patch"; + case lib_plankton.http.enum_method.head: return "head"; + case lib_plankton.http.enum_method.delete: return "delete"; + case lib_plankton.http.enum_method.options: return "options"; + case lib_plankton.http.enum_method.put: return "put"; default: throw (new Error("impossible")); } } /** */ function make(options = {}) { - return lib_plankton.rest_base.make(lib_plankton.caldav.encode_method, options); + return lib_plankton.rest_base.make(lib_plankton.http.encode_method, options); } - rest_caldav.make = make; + rest_http.make = make; /** */ function register(rest, http_method, path, options) { - lib_plankton.rest_base.register(lib_plankton.caldav.encode_method, rest, http_method, path, options); + lib_plankton.rest_base.register(lib_plankton.http.encode_method, rest, http_method, path, options); } - rest_caldav.register = register; + rest_http.register = register; /** * @todo check request body mimetype? * @todo check query paramater validity * @todo improve status code mapping */ async function call(rest, http_request, { "checklevel_restriction": option_checklevel_restriction = lib_plankton.api.enum_checklevel.hard, "checklevel_input": option_checklevel_input = lib_plankton.api.enum_checklevel.soft, "checklevel_output": option_checklevel_output = lib_plankton.api.enum_checklevel.soft, "set_content_length": option_set_content_length = false, } = {}) { - return lib_plankton.rest_base.call(lib_plankton.caldav.encode_method, (x => (x === lib_plankton.caldav.enum_method.options)), (x => x), rest, http_request, { + return lib_plankton.rest_base.call(lib_plankton.http.encode_method, (x => (x === lib_plankton.http.enum_method.options)), (x => x), rest, http_request, { "checklevel_restriction": option_checklevel_restriction, "checklevel_input": option_checklevel_input, "checklevel_output": option_checklevel_output, "set_content_length": option_set_content_length, }); } - rest_caldav.call = call; + rest_http.call = call; /** * @see https://swagger.io/specification/#openrest-object */ function to_oas(rest, options = {}) { - return lib_plankton.rest_base.to_oas(http_request_method_to_oas, lib_plankton.caldav.has_body, rest, options); + return lib_plankton.rest_base.to_oas(http_request_method_to_oas, lib_plankton.http.has_body, rest, options); } - rest_caldav.to_oas = to_oas; - })(rest_caldav = lib_plankton.rest_caldav || (lib_plankton.rest_caldav = {})); + rest_http.to_oas = to_oas; + })(rest_http = lib_plankton.rest_http || (lib_plankton.rest_http = {})); })(lib_plankton || (lib_plankton = {})); /* This file is part of »bacterio-plankton:server«. diff --git a/source/api/actions/calendar_add.ts b/source/api/actions/calendar_add.ts index 32a404f..21e741a 100644 --- a/source/api/actions/calendar_add.ts +++ b/source/api/actions/calendar_add.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_calendar_add( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< @@ -29,10 +29,9 @@ namespace _zeitbild.api } | { - kind : "caldav"; + kind : "ics_feed"; data : { url : string; - read_only : boolean; from_fucked_up_wordpress : boolean; }; } @@ -64,7 +63,8 @@ namespace _zeitbild.api else { // TODO move logic to calendar service let resource_object : _zeitbild.type_resource_object; - switch (stuff.input.resource.kind) { + switch (stuff.input.resource.kind) + { case "local": { resource_object = { "kind": "local", @@ -74,12 +74,11 @@ namespace _zeitbild.api }; break; } - case "caldav": { + case "ics_feed": { resource_object = { - "kind": "caldav", + "kind": "ics_feed", "data": { "url": stuff.input.resource.data.url, - "read_only": stuff.input.resource.data.read_only, "from_fucked_up_wordpress": stuff.input.resource.data.from_fucked_up_wordpress, } }; diff --git a/source/api/actions/calendar_change.ts b/source/api/actions/calendar_change.ts index 6ce095e..9ba5733 100644 --- a/source/api/actions/calendar_change.ts +++ b/source/api/actions/calendar_change.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_calendar_change( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/calendar_event_add.ts b/source/api/actions/calendar_event_add.ts index b7a4b47..0dfd8a1 100644 --- a/source/api/actions/calendar_event_add.ts +++ b/source/api/actions/calendar_event_add.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_calendar_event_add( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/calendar_event_change.ts b/source/api/actions/calendar_event_change.ts index 9fe6963..9e78895 100644 --- a/source/api/actions/calendar_event_change.ts +++ b/source/api/actions/calendar_event_change.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_calendar_event_change( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/calendar_event_get.ts b/source/api/actions/calendar_event_get.ts index 8fb59c2..cd6f352 100644 --- a/source/api/actions/calendar_event_get.ts +++ b/source/api/actions/calendar_event_get.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_calendar_event_get( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/calendar_event_remove.ts b/source/api/actions/calendar_event_remove.ts index 7df847a..f5271cc 100644 --- a/source/api/actions/calendar_event_remove.ts +++ b/source/api/actions/calendar_event_remove.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_calendar_event_remove( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/calendar_get.ts b/source/api/actions/calendar_get.ts index a042ab7..f22d098 100644 --- a/source/api/actions/calendar_get.ts +++ b/source/api/actions/calendar_get.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_calendar_get( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/calendar_list.ts b/source/api/actions/calendar_list.ts index 6770c75..a00596b 100644 --- a/source/api/actions/calendar_list.ts +++ b/source/api/actions/calendar_list.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_calendar_list( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/calendar_remove.ts b/source/api/actions/calendar_remove.ts index f430477..10c3066 100644 --- a/source/api/actions/calendar_remove.ts +++ b/source/api/actions/calendar_remove.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_calendar_remove( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/events.ts b/source/api/actions/events.ts index 37ab836..cf59c3e 100644 --- a/source/api/actions/events.ts +++ b/source/api/actions/events.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_events( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/export_ics.ts b/source/api/actions/export_ics.ts index efc1f28..0f0d554 100644 --- a/source/api/actions/export_ics.ts +++ b/source/api/actions/export_ics.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_export_ics( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/meta_ping.ts b/source/api/actions/meta_ping.ts index 5a1dcca..7fee0d3 100644 --- a/source/api/actions/meta_ping.ts +++ b/source/api/actions/meta_ping.ts @@ -5,10 +5,10 @@ namespace _zeitbild.api /** */ export function register_meta_ping( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { - lib_plankton.rest_caldav.register< + lib_plankton.rest_http.register< null, string > diff --git a/source/api/actions/meta_spec.ts b/source/api/actions/meta_spec.ts index a0d81dd..cf0fd7d 100644 --- a/source/api/actions/meta_spec.ts +++ b/source/api/actions/meta_spec.ts @@ -5,10 +5,10 @@ namespace _zeitbild.api /** */ export function register_meta_spec( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { - lib_plankton.rest_caldav.register< + lib_plankton.rest_http.register< null, any > @@ -27,7 +27,7 @@ namespace _zeitbild.api "execution": () => () => { return Promise.resolve({ "status_code": 200, - "data": lib_plankton.rest_caldav.to_oas(rest_subject), + "data": lib_plankton.rest_http.to_oas(rest_subject), }); }, } diff --git a/source/api/actions/session_begin.ts b/source/api/actions/session_begin.ts index bba0b31..2cc384e 100644 --- a/source/api/actions/session_begin.ts +++ b/source/api/actions/session_begin.ts @@ -5,10 +5,10 @@ namespace _zeitbild.api /** */ export function register_session_begin( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { - lib_plankton.rest_caldav.register< + lib_plankton.rest_http.register< { name : string; password : string; diff --git a/source/api/actions/session_end.ts b/source/api/actions/session_end.ts index 3ecbba7..08c723c 100644 --- a/source/api/actions/session_end.ts +++ b/source/api/actions/session_end.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_session_end( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register( diff --git a/source/api/actions/session_oidc.ts b/source/api/actions/session_oidc.ts index fefd354..7855a06 100644 --- a/source/api/actions/session_oidc.ts +++ b/source/api/actions/session_oidc.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_session_oidc( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/actions/session_prepare.ts b/source/api/actions/session_prepare.ts index 965c262..7081000 100644 --- a/source/api/actions/session_prepare.ts +++ b/source/api/actions/session_prepare.ts @@ -5,10 +5,10 @@ namespace _zeitbild.api /** */ export function register_session_prepare( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { - lib_plankton.rest_caldav.register< + lib_plankton.rest_http.register< any, { kind : string; diff --git a/source/api/actions/users.ts b/source/api/actions/users.ts index 3f667bc..2b190db 100644 --- a/source/api/actions/users.ts +++ b/source/api/actions/users.ts @@ -5,7 +5,7 @@ namespace _zeitbild.api /** */ export function register_users( - rest_subject : lib_plankton.rest_caldav.type_rest + rest_subject : lib_plankton.rest_http.type_rest ) : void { register< diff --git a/source/api/base.ts b/source/api/base.ts index 08991a2..a8a23e8 100644 --- a/source/api/base.ts +++ b/source/api/base.ts @@ -126,14 +126,14 @@ namespace _zeitbild.api /** */ - export const restriction_none : lib_plankton.rest_caldav.type_restriction = ( + export const restriction_none : lib_plankton.rest_http.type_restriction = ( (stuff) => Promise.resolve(true) ); /** */ - export const restriction_web_auth : lib_plankton.rest_caldav.type_restriction = ( + export const restriction_web_auth : lib_plankton.rest_http.type_restriction = ( stuff => ( user_from_web_auth(stuff) .then(() => Promise.resolve(true)) @@ -144,7 +144,7 @@ namespace _zeitbild.api /** */ - export const restriction_logged_in : lib_plankton.rest_caldav.type_restriction = ( + export const restriction_logged_in : lib_plankton.rest_http.type_restriction = ( (stuff) => ( session_from_stuff(stuff) .then(() => Promise.resolve(true)) @@ -156,13 +156,13 @@ namespace _zeitbild.api /** */ export function register( - rest_subject : lib_plankton.rest_caldav.type_rest, - http_method : lib_plankton.caldav.enum_method, + rest_subject : lib_plankton.rest_http.type_rest, + http_method : lib_plankton.http.enum_method, path : string, options : { active ?: ((version : (null | string)) => boolean); - restriction ?: (null | lib_plankton.rest_caldav.type_restriction); - execution ?: lib_plankton.rest_caldav.type_execution; + restriction ?: (null | lib_plankton.rest_http.type_restriction); + execution ?: lib_plankton.rest_http.type_execution; title ?: (null | string); description ?: (null | string); query_parameters ?: ((version : (null | string)) => Array< @@ -172,8 +172,8 @@ namespace _zeitbild.api required : boolean; } >); - input_schema ?: ((version: (null | string)) => lib_plankton.rest_caldav.type_oas_schema); - output_schema ?: ((version: (null | string)) => lib_plankton.rest_caldav.type_oas_schema); + input_schema ?: ((version: (null | string)) => lib_plankton.rest_http.type_oas_schema); + output_schema ?: ((version: (null | string)) => lib_plankton.rest_http.type_oas_schema); request_body_mimetype ?: ( (version : (null | string)) => @@ -200,7 +200,7 @@ namespace _zeitbild.api }, options ); - lib_plankton.rest_caldav.register( + lib_plankton.rest_http.register( rest_subject, http_method, (_zeitbild.conf.get().server.path_base + path), @@ -214,7 +214,7 @@ namespace _zeitbild.api ? undefined : - (version) => (options.restriction as lib_plankton.rest_caldav.type_restriction) + (version) => (options.restriction as lib_plankton.rest_http.type_restriction) ), /** * @todo heed version @@ -224,7 +224,7 @@ namespace _zeitbild.api ? undefined : - (version) => (options.execution as lib_plankton.rest_caldav.type_execution) + (version) => (options.execution as lib_plankton.rest_http.type_execution) ), /** * @todo heed version diff --git a/source/api/functions.ts b/source/api/functions.ts index 13c3c09..0fae129 100644 --- a/source/api/functions.ts +++ b/source/api/functions.ts @@ -5,9 +5,9 @@ namespace _zeitbild.api /** */ export function make( - ) : lib_plankton.rest_caldav.type_rest + ) : lib_plankton.rest_http.type_rest { - const rest_subject : lib_plankton.rest_caldav.type_rest = lib_plankton.rest_caldav.make( + const rest_subject : lib_plankton.rest_http.type_rest = lib_plankton.rest_http.make( { "title": "zeitbild", "versioning_method": "header", @@ -56,7 +56,6 @@ namespace _zeitbild.api _zeitbild.api.register_events(rest_subject); } - return rest_subject; } diff --git a/source/api/transformations/datetime.ts b/source/api/transformations/datetime.ts index 72f515e..bc47058 100644 --- a/source/api/transformations/datetime.ts +++ b/source/api/transformations/datetime.ts @@ -8,7 +8,7 @@ namespace _zeitbild.api options : { nullable ?: boolean; } = {} - ) : lib_plankton.rest_caldav.type_oas_schema + ) : lib_plankton.rest_http.type_oas_schema { options = Object.assign( { @@ -49,7 +49,7 @@ namespace _zeitbild.api options : { nullable ?: boolean; } = {} - ) : lib_plankton.rest_caldav.type_oas_schema + ) : lib_plankton.rest_http.type_oas_schema { options = Object.assign( { @@ -90,7 +90,7 @@ namespace _zeitbild.api options : { nullable ?: boolean; } = {} - ) : lib_plankton.rest_caldav.type_oas_schema + ) : lib_plankton.rest_http.type_oas_schema { options = Object.assign( { diff --git a/source/main.ts b/source/main.ts index 697a1e9..eda9f53 100644 --- a/source/main.ts +++ b/source/main.ts @@ -37,10 +37,9 @@ type type_data = { } | { - kind : "caldav"; + kind : "ics_feed"; data : { url : string; - read_only : boolean; from_fucked_up_wordpress ?: boolean; }; } @@ -69,7 +68,8 @@ async function data_init( "user": {}, "calendar": {}, }; - for await (const user_raw of data.users) { + for await (const user_raw of data.users) + { const user_object : _zeitbild.type_user_object = { "name": user_raw.name, "email_address": user_raw.email_address, @@ -84,11 +84,14 @@ async function data_init( ); track.user[user_raw.id] = user_id; } - for await (const calendar_raw of data.calendars) { + for await (const calendar_raw of data.calendars) + { let resource_object : _zeitbild.type_resource_object; let resource_id : _zeitbild.type_resource_id; - switch (calendar_raw.resource.kind) { - case "local": { + switch (calendar_raw.resource.kind) + { + case "local": + { resource_object = { "kind": "local", "data": { @@ -106,12 +109,12 @@ async function data_init( ); break; } - case "caldav": { + case "ics_feed": + { resource_object = { - "kind": "caldav", + "kind": "ics_feed", "data": { "url": calendar_raw.resource.data.url, - "read_only": calendar_raw.resource.data.read_only, "from_fucked_up_wordpress": (calendar_raw.resource.data.from_fucked_up_wordpress ?? false), } }; @@ -121,7 +124,8 @@ async function data_init( break; } } - const calendar_object : _zeitbild.type_calendar_object = { + const calendar_object : _zeitbild.type_calendar_object = + { "name": calendar_raw.name, "access": { "public": (calendar_raw.access.public ?? false), @@ -379,10 +383,10 @@ async function main( } case "api-doc": { lib_plankton.log.set_main_logger([]); - const rest_subject : lib_plankton.rest_caldav.type_rest = _zeitbild.api.make(); + const rest_subject : lib_plankton.rest_http.type_rest = _zeitbild.api.make(); process.stdout.write( JSON.stringify( - lib_plankton.rest_caldav.to_oas(rest_subject), + lib_plankton.rest_http.to_oas(rest_subject), undefined, "\t" ) @@ -434,11 +438,11 @@ async function main( await _zeitbild.auth.init(); - const rest_subject : lib_plankton.rest_caldav.type_rest = _zeitbild.api.make(); + const rest_subject : lib_plankton.rest_http.type_rest = _zeitbild.api.make(); const server : lib_plankton.server.type_subject = lib_plankton.server.make( async (input, metadata) => { - const http_request : lib_plankton.caldav.type_request = lib_plankton.caldav.decode_request(input.toString()); - const http_response : lib_plankton.caldav.type_response = await lib_plankton.rest_caldav.call( + const http_request : lib_plankton.http.type_request = lib_plankton.http.decode_request(input.toString()); + const http_response : lib_plankton.http.type_response = await lib_plankton.rest_http.call( rest_subject, http_request, { @@ -448,7 +452,7 @@ async function main( "set_content_length": false, } ); - const output : string = lib_plankton.caldav.encode_response(http_response); + const output : string = lib_plankton.http.encode_response(http_response); return output; }, { diff --git a/source/repositories/resource.ts b/source/repositories/resource.ts index a191bfd..a3f90c8 100644 --- a/source/repositories/resource.ts +++ b/source/repositories/resource.ts @@ -42,7 +42,7 @@ namespace _zeitbild.repository.resource /** */ - var _caldav_resource_store : ( + var _ics_feed_resource_store : ( null | lib_plankton.storage.type_store< @@ -126,7 +126,7 @@ namespace _zeitbild.repository.resource /** */ - function get_caldav_resource_store( + function get_ics_feed_resource_store( ) : lib_plankton.storage.type_store< int, Record, @@ -135,11 +135,11 @@ namespace _zeitbild.repository.resource Record > { - if (_caldav_resource_store === null) { - _caldav_resource_store = lib_plankton.storage.sql_table_autokey_store( + if (_ics_feed_resource_store === null) { + _ics_feed_resource_store = lib_plankton.storage.sql_table_autokey_store( { "database_implementation": _zeitbild.database.get_implementation(), - "table_name": "caldav_resources", + "table_name": "ics_feed_resources", "key_name": "id", } ); @@ -147,7 +147,7 @@ namespace _zeitbild.repository.resource else { // do nothing } - return _caldav_resource_store; + return _ics_feed_resource_store; } @@ -358,15 +358,14 @@ namespace _zeitbild.repository.resource } ); } - case "caldav": { - const dataset_extra_caldav : Record = await get_caldav_resource_store().read(dataset_core.sub_id); + case "ics_feed": { + const dataset_extra_ics_feed : Record = await get_ics_feed_resource_store().read(dataset_core.sub_id); return Promise.resolve<_zeitbild.type_resource_object>( { - "kind": "caldav", + "kind": "ics_feed", "data": { - "url": dataset_extra_caldav["url"], - "read_only": dataset_extra_caldav["read_only"], - "from_fucked_up_wordpress": dataset_extra_caldav["from_fucked_up_wordpress"], + "url": dataset_extra_ics_feed["url"], + "from_fucked_up_wordpress": dataset_extra_ics_feed["from_fucked_up_wordpress"], } } ); @@ -405,18 +404,17 @@ namespace _zeitbild.repository.resource return Promise.resolve<_zeitbild.type_resource_id>(resource_id); break; } - case "caldav": { - const caldav_resource_id : int = await get_caldav_resource_store().create( + case "ics_feed": { + const ics_feed_resource_id : int = await get_ics_feed_resource_store().create( { "url": resource_object.data.url, - "read_only": resource_object.data.read_only, "from_fucked_up_wordpress": resource_object.data.from_fucked_up_wordpress, } ); const resource_id : _zeitbild.type_resource_id = await get_resource_core_store().create( { - "kind": "caldav", - "sub_id": caldav_resource_id, + "kind": "ics_feed", + "sub_id": ics_feed_resource_id, } ); await lib_plankton.cache.clear(_zeitbild.cache_regular); @@ -491,12 +489,12 @@ namespace _zeitbild.repository.resource */ break; } - case "caldav": { - await get_caldav_resource_store().update( + case "ics_feed": { + await get_ics_feed_resource_store().update( dataset_core["sub_id"], { "url": resource_object.data.url, - "read_only": resource_object.data.read_only, + "from_fucked_up_wordpress": resource_object.data.from_fucked_up_wordpress, } ); await lib_plankton.cache.clear(_zeitbild.cache_regular); diff --git a/source/services/caldav.ts b/source/services/caldav.ts deleted file mode 100644 index 441a2ff..0000000 --- a/source/services/caldav.ts +++ /dev/null @@ -1,511 +0,0 @@ - -namespace _zeitbild.service.caldav -{ - - /** - */ - function get_answers( - ) : Record< - string, - (stuff : any) => lib_plankton.webdav.type_data_prop_value - > - { - return { - // RFC2518 - - /** - * @see https://datatracker.ietf.org/doc/html/rfc2518#section-13.2 - */ - "displayname": (stuff) => ({ - "kind": "primitive", - "data": stuff["name"] - }), - /** - * @see https://datatracker.ietf.org/doc/html/rfc2518#section-13.4 - */ - /* - "getcontentlength": { - "kind": "none", - "data": null - }, - */ - /** - * @see https://datatracker.ietf.org/doc/html/rfc2518#section-13.5 - */ - "getcontenttype": (stuff) => ({ - "kind": "primitive", - "data": stuff["content_type"] - }), - /** - * @see https://datatracker.ietf.org/doc/html/rfc2518#section-13.7 - */ - /* - "getlastmodified": { - "kind": "none", - "data": null - }, - */ - /** - * @see https://datatracker.ietf.org/doc/html/rfc2518#section-13.9 - */ - "resourcetype": (stuff) => ({ - "kind": "resourcetype", - "data": { - "kind": "collection", - "type": "calendar", - } - }), - - // RFCP3744 - - /** - * @see https://datatracker.ietf.org/doc/html/rfc3744#section-4.2 - */ - "principal-url": (stuff) => ({ - "kind": "href", - "data": "/caldav" - }), - /** - * @see https://datatracker.ietf.org/doc/html/rfc3744#section-5.1 - */ - "owner": (stuff) => ({ - "kind": "primitive", - "data": "" - }), - /** - * @see https://datatracker.ietf.org/doc/html/rfc3744#section-5.4 - */ - "current-user-privilege-set": (stuff) => ({ - "kind": "privileges", - "data": [ - "read" - ] - }), - - // RFC4791 - - /** - * @see https://datatracker.ietf.org/doc/html/rfc4791#section-5.2.3 - */ - "supported-calendar-component-set": (stuff) => ({ - "kind": "component_set", - "data": { - "name": "C:supported-calendar-component-set", - "items": [ - "VCALENDAR" - ] - } - }), - /** - * @see https://datatracker.ietf.org/doc/html/rfc4791#section-6.2.1 - */ - "calendar-home-set": (stuff) => ({ - "kind": "href", - "data": "/caldav/project" - }), - - // RFC4918 - - /** - * @see https://datatracker.ietf.org/doc/html/rfc4918#section-15.6 - */ - "getetag": (stuff) => ({ - "kind": "primitive", - "data": "" - }), - - // RFC5397 - - /** - * @see https://datatracker.ietf.org/doc/html/rfc5397#section-3 - */ - "current-user-principal": (stuff) => ({ - "kind": "href", - "data": "/caldav" - }), - - // RFC6638 - - /** - * @see https://datatracker.ietf.org/doc/html/rfc6638#section-2.4.1 - */ - "calendar-user-address-set": (stuff) => ({ - "kind": "primitive", - "data": "" - }), - - // unknown - - /* - "calendar-color": { - "kind": "none", - "data": null - }, - "executable": { - "kind": "none", - "data": null - }, - "checked-in": { - "kind": "none", - "data": null - }, - "checked-out": { - "kind": "none", - "data": null - }, - */ - }; - } - - - /** - * @todo use pod for output - * @todo get api paths in props from config - * @todo consider to outsorce to plankton - */ - export function probe( - input : (null | lib_plankton.xml.type_node_data), - { - "force_props": force_props = null, - } : { - force_props ?: (null | Array); - } = { - } - ) : (null | lib_plankton.xml.type_node_data) - { - const http_protocol : string = "HTTP/1.1"; - let props : (null | Array); - if (force_props) { - props = force_props; - } - else { - if ( - (input !== null) - && - (input.kind === "complex") - && - ( - (input.data.tag.toLowerCase() === "d:propfind") - || - (input.data.tag.toLowerCase() === "propfind") - ) - && - (input.data.children.length === 1) - && - (input.data.children[0].kind === "complex") - && - ( - (input.data.children[0].data.tag.toLowerCase() === "d:prop") - || - (input.data.children[0].data.tag.toLowerCase() === "prop") - ) - ) { - props = input.data.children[0].data.children.map( - node => { - switch (node.kind) { - case "complex": { - return node.data.tag; - break; - } - default: { - throw (new Error("unexpected node type for prop")); - break; - } - } - } - ); - props.sort(); - } - else { - props = null; - } - } - if (props === null) { - lib_plankton.log.notice( - "service.caldav.probe.unexpected_input", - { - "input": input, - } - ); - return null; - } - else { - const answers : Record< - string, - (stuff : any) => lib_plankton.webdav.type_data_prop_value - > = get_answers(); - return { - "kind": "root", - "data": { - "version": "1.0", - "encoding": "utf-8", - "content": lib_plankton.webdav.data_multistatus_encode_xml( - { - "responses": [ - { - "href": "/caldav/project", - "body": { - /** - * @todo maybe propstats needs to be filled with props (.map …) - */ - "propstats": ( - false - ? - // probably the wrong way - [ - { - "prop": (props ?? []).map( - (prop) => { - const prop_parts : Array = prop.toLowerCase().split(":"); - const prop_normalized : string = ((prop_parts.length <= 1) ? prop_parts[0] : prop_parts.slice(1).join(":")); - if (! (prop_normalized in answers)) { - lib_plankton.log.error( - "api.caldav_probe.unhandled_prop", - prop_normalized - ); - throw (new Error("unhandled prop: " + prop_normalized)); - } - else { - return { - "name": prop, - "value": ( - answers[prop_normalized]({"name": "projects", "content_type": "text/xml"}) - ?? - { - "kind": "none", - "data": null, - } - ), - }; - } - } - ), - "status": (http_protocol + " 200 OK"), - "description": null, - }, - ] - : - // probably the right way - props.map( - (prop) => { - const prop_parts : Array = prop.toLowerCase().split(":"); - const prop_normalized : string = ( - (prop_parts.length <= 1) - ? - prop_parts[0] - : - prop_parts.slice(1).join(":") - ); - if (! (prop_normalized in answers)) { - lib_plankton.log.notice( - "api.caldav_probe.unhandled_prop", - prop_normalized - ); - /* - throw (new Error("unhandled prop: " + prop_normalized)); - */ - return { - "prop": [ - { - "name": prop, - "value": { - "kind": "none", - "data": null, - } - }, - ], - "status": (http_protocol + " 404 Not Found"), - "description": null, - }; - } - else { - return { - "prop": [ - { - "name": prop, - "value": answers[prop_normalized]({"name": "projects", "content_type": "text/xml"}), - }, - ], - "status": (http_protocol + " 200 OK"), - "description": null, - }; - }; - } - ) - ) - }, - "description": null, - } - ], - "description": null, - } - ) - } - }; - } - } - - - /** - * @todo heed input properly - */ - export function projects( - input : lib_plankton.xml.type_node_data, - user_id : type_user_id - ) : Promise - { - const http_protocol : string = "HTTP/1.1"; - const answers : Record< - string, - (stuff : any) => lib_plankton.webdav.type_data_prop_value - > = get_answers(); - /** - * @todo remove - */ - lib_plankton.log.info( - "service.caldav.input", - input - ); - /** - * @todo check data structure - */ - if ( - ! ( - (input.kind === "complex") - && - (input.data.tag === "propfind") - && - (input.data.children.length === 1) - && - (input.data.children[0].kind === "complex") - && - (input.data.children[0].data.tag === "prop") - && - input.data.children[0].data.children.every( - node => (node.kind === "complex") - ) - ) - ) { - throw (new Error("wrong input structure")); - } - else { - const props : Array = ( - input - .data.children - [0] - .data.children - .map( - (node) => node.data.tag - ) - ); - /** - * @todo remove - */ - lib_plankton.log.info( - "service.caldav.props", - props - ); - return ( - _zeitbild.service.calendar.overview(user_id) - .then( - (data_raw) => Promise.resolve( - data_raw - .map( - (entry) => ({ - "id": entry.id, - "name": entry.name, - "access_level": _zeitbild.value_object.access_level.to_string(entry.access_level), - }) - ) - ) - ) - .then( - (data) => Promise.resolve( - { - "kind": "root", - "data": { - "version": "1.0", - "encoding": "utf-8", - "content": lib_plankton.webdav.data_multistatus_encode_xml( - { - "responses": data.map( - (entry) => ({ - "href": lib_plankton.string.coin( - "/caldav/project/{{id}}", - { - "id": entry.id.toFixed(0), - } - ), - "body": { - "propstats": ( - lib_plankton.call.wrap>(props) - .convey>( - (props_raw) => props_raw.map( - (prop_raw) => { - const prop_parts : Array = prop_raw.toLowerCase().split(":"); - const prop_normalized : string = ((prop_parts.length <= 1) ? prop_parts[0] : prop_parts.slice(1).join(":")); - return ( - (prop_normalized in answers) - ? - { - "found": true, - "prop": { - "name": prop_raw, - "value": answers[prop_normalized]({"name": entry.name, "content_type": "text/calendar"}), - } - } - : - { - "found": false, - "prop": { - "name": prop_raw, - "value": {"kind": "none", "data": null} - } - } - ); - } - ) - ) - .convey>>( - (props_transformed) => lib_plankton.list.group( - props_transformed, - (x, y) => (x.found === y.found) - ) - ) - .convey>( - (props_grouped) => props_grouped.map( - group => ( - group[0].found - ? - { - "prop": group.map(member => member.prop), - "status": (http_protocol + " 200 OK"), - "description": null, - } - : - { - "prop": group.map(member => member.prop), - "status": (http_protocol + " 404 Not Found"), - "description": null, - } - ) - ) - ) - .cull() - ), - }, - "description": null, - }) - ), - "description": null, - } - ) - } - } - ) - ) - ); - } - } - -} diff --git a/source/services/calendar.ts b/source/services/calendar.ts index 2055515..c0106fd 100644 --- a/source/services/calendar.ts +++ b/source/services/calendar.ts @@ -327,7 +327,7 @@ namespace _zeitbild.service.calendar ); break; } - case "caldav": { + case "ics_feed": { // TODO readonly const vcalendar : lib_plankton.ical.type_vcalendar = await lib_plankton.cache.get( _zeitbild.cache_external_resources, diff --git a/source/services/resource.ts b/source/services/resource.ts index ba5b53e..7b66ee0 100644 --- a/source/services/resource.ts +++ b/source/services/resource.ts @@ -31,7 +31,7 @@ namespace _zeitbild.service.resource return Promise.resolve<_zeitbild.type_event_object>(event_object); break; } - case "caldav": { + case "ics_feed": { // TODO return Promise.reject(new Error("not implemented")); break; @@ -63,14 +63,8 @@ namespace _zeitbild.service.resource return Promise.resolve<_zeitbild.type_local_resource_event_id>(local_resource_event_id); break; } - case "caldav": { - if (resource_object.data.read_only) { - return Promise.reject(new Error("can not add event to read only caldav resource")); - } - else { - // TODO - return Promise.reject(new Error("not implemented")); - } + case "ics_feed": { + return Promise.reject(new Error("unavailable")); break; } default: { @@ -102,14 +96,8 @@ namespace _zeitbild.service.resource return Promise.resolve(undefined); break; } - case "caldav": { - if (resource_object.data.read_only) { - return Promise.reject(new Error("can not change event of read only caldav resource")); - } - else { - // TODO - return Promise.reject(new Error("not implemented")); - } + case "ics_feed": { + return Promise.reject(new Error("unavailable")); break; } default: { @@ -139,14 +127,8 @@ namespace _zeitbild.service.resource return Promise.resolve(undefined); break; } - case "caldav": { - if (resource_object.data.read_only) { - return Promise.reject(new Error("can not delete event from read only caldav resource")); - } - else { - // TODO - return Promise.reject(new Error("not implemented")); - } + case "ics_feed": { + return Promise.reject(new Error("unavailable")); break; } default: { diff --git a/source/types.ts b/source/types.ts index 181082f..200a6f9 100644 --- a/source/types.ts +++ b/source/types.ts @@ -87,13 +87,9 @@ namespace _zeitbild } | { - /** - * @todo rename to "ics_feed" or sth. - */ - kind : "caldav"; + kind : "ics_feed"; data : { url : string; - read_only : boolean; from_fucked_up_wordpress : boolean; }; } diff --git a/tools/makefile b/tools/makefile index d6c2da1..401af4e 100644 --- a/tools/makefile +++ b/tools/makefile @@ -56,7 +56,6 @@ ${dir_temp}/zeitbild-unlinked.js: \ ${dir_source}/services/user.ts \ ${dir_source}/services/resource.ts \ ${dir_source}/services/calendar.ts \ - ${dir_source}/services/caldav.ts \ ${dir_source}/api/base.ts \ ${dir_source}/api/transformations/datetime.ts \ ${dir_source}/api/actions/meta_ping.ts \ diff --git a/tools/update-plankton b/tools/update-plankton index b74d7d8..d340081 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" @@ -21,12 +21,12 @@ modules="${modules} order" modules="${modules} ical" modules="${modules} url" modules="${modules} http" -modules="${modules} webdav" -modules="${modules} caldav" +# modules="${modules} webdav" +# modules="${modules} caldav" modules="${modules} api" -# modules="${modules} rest_http" +modules="${modules} rest_http" # modules="${modules} rest_webdav" -modules="${modules} rest_caldav" +# modules="${modules} rest_caldav" modules="${modules} server" modules="${modules} args" modules="${modules} bcrypt" @@ -38,6 +38,13 @@ modules="${modules} sha256" ## exec +mkdir /tmp/sandbox -p +cd /tmp/sandbox +ptk fetch node ${modules} +schwamm --include=plankton.swm.json --output=dump:logic-decl > ${dir}/plankton.d.ts +schwamm --include=plankton.swm.json --output=dump:logic-impl > ${dir}/plankton.js +exit + mkdir -p ${dir} cd ${dir} ptk bundle node ${modules}