[int]
This commit is contained in:
parent
92d5779157
commit
20f2d93bfa
|
|
@ -5,7 +5,7 @@
|
||||||
"attentive_interval": 1,
|
"attentive_interval": 1,
|
||||||
"reminding_interval": 20
|
"reminding_interval": 20
|
||||||
},
|
},
|
||||||
"threshold": 3,
|
"threshold": 1,
|
||||||
"notifications": [
|
"notifications": [
|
||||||
{
|
{
|
||||||
"kind": "console",
|
"kind": "console",
|
||||||
|
|
@ -15,6 +15,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"includes": [
|
"includes": [
|
||||||
"file_state.hmdl.json"
|
"tls_certificate.hmdl.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,7 @@
|
||||||
"kind": "tls_certificate",
|
"kind": "tls_certificate",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"host": "greenscale.de",
|
"host": "greenscale.de",
|
||||||
"expiry_threshold": 50
|
"expiry_threshold": 74
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test2",
|
|
||||||
"kind": "tls_certificate",
|
|
||||||
"parameters": {
|
|
||||||
"host": "chemnitz-gesundheit.de"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
215
lib/plankton/plankton.d.ts
vendored
215
lib/plankton/plankton.d.ts
vendored
|
|
@ -202,154 +202,6 @@ declare class class_observer {
|
||||||
/**
|
/**
|
||||||
* @author frac
|
* @author frac
|
||||||
*/
|
*/
|
||||||
declare module lib_maybe {
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
type type_maybe<type_value> = {
|
|
||||||
kind: string;
|
|
||||||
parameters: Object;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function make_nothing<type_value>(): type_maybe<type_value>;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function make_just<type_value>(value: type_value): type_maybe<type_value>;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function is_nothing<type_value>(maybe: type_maybe<type_value>): boolean;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function is_just<type_value>(maybe: type_maybe<type_value>): boolean;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function cull<type_value>(maybe: type_maybe<type_value>): type_value;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function propagate<type_value, type_value_>(maybe: type_maybe<type_value>, function_: (value: type_value) => type_maybe<type_value_>): type_maybe<type_value_>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
declare class class_maybe<type_value> implements interface_showable {
|
|
||||||
/**
|
|
||||||
* @desc whether the wrapper is nothing
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
is_nothing(): boolean;
|
|
||||||
/**
|
|
||||||
* @desc whether the wrapper is just
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
is_just(): boolean;
|
|
||||||
/**
|
|
||||||
* @desc return the value, stored in the maybe-wrapper
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
cull(): type_value;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
toString(): string;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
distinguish(action_just: (value?: type_value) => void, action_nothing?: (reason?: string) => void): void;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
propagate<type_value_>(action: (value: type_value) => class_maybe<type_value_>): class_maybe<type_value_>;
|
|
||||||
/**
|
|
||||||
* @desc [implementation]
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
_show(): string;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
declare class class_nothing<type_value> extends class_maybe<type_value> {
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
private reason;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
constructor(reason?: string);
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
is_nothing(): boolean;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
is_just(): boolean;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
cull(): type_value;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
toString(): string;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
reason_get(): string;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
distinguish(action_just: (value?: type_value) => void, action_nothing?: (reason?: string) => void): void;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
propagate<type_value_>(action: (value: type_value) => class_maybe<type_value_>): class_maybe<type_value_>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
declare class class_just<type_value> extends class_maybe<type_value> {
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
private value;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
constructor(value: type_value);
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
is_nothing(): boolean;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
is_just(): boolean;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
cull(): type_value;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
toString(): string;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
distinguish(action_just: (value?: type_value) => void, action_nothing?: (reason?: string) => void): void;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
propagate<type_value_>(action: (value: type_value) => class_maybe<type_value_>): class_maybe<type_value_>;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @author frac
|
* @author frac
|
||||||
*/
|
*/
|
||||||
|
|
@ -383,6 +235,65 @@ declare namespace lib_plankton.base {
|
||||||
*/
|
*/
|
||||||
function object_merge(core: Record<string, any>, mantle: Record<string, any>): Record<string, any>;
|
function object_merge(core: Record<string, any>, mantle: Record<string, any>): Record<string, any>;
|
||||||
}
|
}
|
||||||
|
declare module lib_plankton.pod {
|
||||||
|
/**
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
type type_pod<type_value> = {
|
||||||
|
kind: ("empty" | "filled");
|
||||||
|
value?: type_value;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function make_empty<type_value>(): type_pod<type_value>;
|
||||||
|
/**
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function make_filled<type_value>(value: type_value): type_pod<type_value>;
|
||||||
|
/**
|
||||||
|
* whether the pod is filled
|
||||||
|
*
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function is_filled<type_value>(pod: type_pod<type_value>): boolean;
|
||||||
|
/**
|
||||||
|
* return the value, stored in the pod-wrapper
|
||||||
|
*
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function cull<type_value>(pod: type_pod<type_value>): type_value;
|
||||||
|
/**
|
||||||
|
* to pass on a empty-pod or to use a filled-pod
|
||||||
|
*
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function propagate<type_value, type_value_>(pod: type_pod<type_value>, function_: ((value: type_value) => type_value_)): type_pod<type_value_>;
|
||||||
|
/**
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function distinguish<type_value, type_result>(pod: type_pod<type_value>, function_empty: (() => type_result), function_filled: ((value: type_value) => type_result)): type_result;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function show<type_value>(pod: type_pod<type_value>, options?: {
|
||||||
|
show_value?: ((value: type_value) => string);
|
||||||
|
}): string;
|
||||||
|
}
|
||||||
|
declare module lib_plankton.pod {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class class_pod<type_value> {
|
||||||
|
private subject;
|
||||||
|
private constructor();
|
||||||
|
is_empty(): boolean;
|
||||||
|
is_filled(): boolean;
|
||||||
|
cull(): type_value;
|
||||||
|
show(show_value?: any): string;
|
||||||
|
toString(): string;
|
||||||
|
propagate<type_value_>(function_: ((value: type_value) => type_value_)): class_pod<type_value_>;
|
||||||
|
distinguish<type_result>(function_empty: (() => type_result), function_filled: ((value: type_value) => type_result)): type_result;
|
||||||
|
}
|
||||||
|
}
|
||||||
declare namespace lib_plankton.call {
|
declare namespace lib_plankton.call {
|
||||||
/**
|
/**
|
||||||
* @desc hacked class for postfix function application
|
* @desc hacked class for postfix function application
|
||||||
|
|
@ -544,11 +455,9 @@ declare namespace lib_plankton.call {
|
||||||
/**
|
/**
|
||||||
* @author fenris
|
* @author fenris
|
||||||
*/
|
*/
|
||||||
function promise_show<type_result, type_reason>(label: string): (result: type_result) => type_promise<type_result, type_reason>;
|
|
||||||
/**
|
/**
|
||||||
* @author fenris
|
* @author fenris
|
||||||
*/
|
*/
|
||||||
function promise_log<type_result, type_reason>(result: type_result): (result: type_result) => type_promise<type_result, type_reason>;
|
|
||||||
/**
|
/**
|
||||||
* @author fenris
|
* @author fenris
|
||||||
*/
|
*/
|
||||||
|
|
@ -1180,7 +1089,7 @@ declare namespace lib_plankton.string {
|
||||||
to: string;
|
to: string;
|
||||||
}>, options?: {}): string;
|
}>, options?: {}): string;
|
||||||
/**
|
/**
|
||||||
* @desc replaces occurences of "${name}" in a string by the corresponding values of an argument object
|
* @desc replaces occurences of "{{name}}" in a string by the corresponding values of an argument object
|
||||||
* @author fenris
|
* @author fenris
|
||||||
*/
|
*/
|
||||||
function coin(str: string, args: {
|
function coin(str: string, args: {
|
||||||
|
|
@ -1534,7 +1443,7 @@ declare namespace lib_plankton.translate {
|
||||||
*/
|
*/
|
||||||
function fetch(identifier: string, path: string, args?: {
|
function fetch(identifier: string, path: string, args?: {
|
||||||
[id: string]: string;
|
[id: string]: string;
|
||||||
}): class_maybe<string>;
|
}): lib_plankton.pod.type_pod<string>;
|
||||||
/**
|
/**
|
||||||
* @desc retrieves a string by going through the order and trying to fetch it for the current entry
|
* @desc retrieves a string by going through the order and trying to fetch it for the current entry
|
||||||
* @author fenris
|
* @author fenris
|
||||||
|
|
@ -1830,7 +1739,7 @@ declare namespace lib_plankton.http {
|
||||||
* @author fenris <frass@greenscale.de>
|
* @author fenris <frass@greenscale.de>
|
||||||
*/
|
*/
|
||||||
type type_response = {
|
type type_response = {
|
||||||
version: string;
|
version: (null | string);
|
||||||
status_code: int;
|
status_code: int;
|
||||||
headers: Record<string, string>;
|
headers: Record<string, string>;
|
||||||
body: Buffer;
|
body: Buffer;
|
||||||
|
|
|
||||||
|
|
@ -383,261 +383,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Lesser General Public License for more details.
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
|
||||||
along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
var lib_maybe;
|
|
||||||
(function (lib_maybe) {
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function make_nothing() {
|
|
||||||
return {
|
|
||||||
"kind": "nothing",
|
|
||||||
"parameters": {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
lib_maybe.make_nothing = make_nothing;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function make_just(value) {
|
|
||||||
return {
|
|
||||||
"kind": "just",
|
|
||||||
"parameters": {
|
|
||||||
"value": value
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
lib_maybe.make_just = make_just;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function is_nothing(maybe) {
|
|
||||||
return (maybe.kind === "nothing");
|
|
||||||
}
|
|
||||||
lib_maybe.is_nothing = is_nothing;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function is_just(maybe) {
|
|
||||||
return (maybe.kind === "just");
|
|
||||||
}
|
|
||||||
lib_maybe.is_just = is_just;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function cull(maybe) {
|
|
||||||
if (!is_just(maybe)) {
|
|
||||||
var message = "cull from nothing";
|
|
||||||
throw (new Error(message));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var value = maybe.parameters["value"];
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lib_maybe.cull = cull;
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function propagate(maybe, function_) {
|
|
||||||
if (!is_just(maybe)) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var value = maybe.parameters["value"];
|
|
||||||
var maybe_ = function_(value);
|
|
||||||
return maybe_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lib_maybe.propagate = propagate;
|
|
||||||
})(lib_maybe || (lib_maybe = {}));
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
/*export*/ var class_maybe = /** @class */ (function () {
|
|
||||||
function class_maybe() {
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @desc whether the wrapper is nothing
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_maybe.prototype.is_nothing = function () {
|
|
||||||
throw (new Error("not implemented: class_maybe.is_nothing"));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @desc whether the wrapper is just
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_maybe.prototype.is_just = function () {
|
|
||||||
throw (new Error("not implemented: class_maybe.is_just"));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @desc return the value, stored in the maybe-wrapper
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_maybe.prototype.cull = function () {
|
|
||||||
throw (new Error("not implemented: class_maybe.cull"));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_maybe.prototype.toString = function () {
|
|
||||||
throw (new Error("not implemented: class_maybe.cull"));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_maybe.prototype.distinguish = function (action_just, action_nothing) {
|
|
||||||
if (action_nothing === void 0) { action_nothing = function () { }; }
|
|
||||||
throw (new Error("not implemented: class_maybe.distinguish"));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_maybe.prototype.propagate = function (action) {
|
|
||||||
throw (new Error("not implemented: class_maybe.propagate"));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @desc [implementation]
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_maybe.prototype._show = function () {
|
|
||||||
return this.toString();
|
|
||||||
};
|
|
||||||
return class_maybe;
|
|
||||||
}());
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
/*export*/ var class_nothing = /** @class */ (function (_super) {
|
|
||||||
__extends(class_nothing, _super);
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function class_nothing(reason) {
|
|
||||||
if (reason === void 0) { reason = null; }
|
|
||||||
var _this = _super.call(this) || this;
|
|
||||||
_this.reason = reason;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_nothing.prototype.is_nothing = function () {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_nothing.prototype.is_just = function () {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_nothing.prototype.cull = function () {
|
|
||||||
var message = "you shouldn't cull a nothing-value …";
|
|
||||||
// lib_plankton.log.warn(message);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_nothing.prototype.toString = function () {
|
|
||||||
return "<\u00B7>";
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_nothing.prototype.reason_get = function () {
|
|
||||||
var content = ((this.reason == null) ? "·" : this.reason);
|
|
||||||
return "<- ".concat(content, " ->");
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_nothing.prototype.distinguish = function (action_just, action_nothing) {
|
|
||||||
if (action_nothing === void 0) { action_nothing = function () { }; }
|
|
||||||
action_nothing(this.reason);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_nothing.prototype.propagate = function (action) {
|
|
||||||
return (new class_nothing(this.reason));
|
|
||||||
};
|
|
||||||
return class_nothing;
|
|
||||||
}(class_maybe));
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
/*export*/ var class_just = /** @class */ (function (_super) {
|
|
||||||
__extends(class_just, _super);
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
function class_just(value) {
|
|
||||||
var _this = _super.call(this) || this;
|
|
||||||
_this.value = value;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_just.prototype.is_nothing = function () {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_just.prototype.is_just = function () {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_just.prototype.cull = function () {
|
|
||||||
return this.value;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_just.prototype.toString = function () {
|
|
||||||
var content = instance_show(this.value);
|
|
||||||
return "<+ ".concat(content, " +>");
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_just.prototype.distinguish = function (action_just, action_nothing) {
|
|
||||||
if (action_nothing === void 0) { action_nothing = function () { }; }
|
|
||||||
action_just(this.value);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @author fenris
|
|
||||||
*/
|
|
||||||
class_just.prototype.propagate = function (action) {
|
|
||||||
return action(this.value);
|
|
||||||
};
|
|
||||||
return class_just;
|
|
||||||
}(class_maybe));
|
|
||||||
/*
|
|
||||||
This file is part of »bacterio-plankton:base«.
|
|
||||||
|
|
||||||
Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
|
||||||
<info@greenscale.de>
|
|
||||||
|
|
||||||
»bacterio-plankton:base« is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
»bacterio-plankton:base« is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>.
|
along with »bacterio-plankton:base«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
@ -690,6 +435,148 @@ var lib_plankton;
|
||||||
})(base = lib_plankton.base || (lib_plankton.base = {}));
|
})(base = lib_plankton.base || (lib_plankton.base = {}));
|
||||||
})(lib_plankton || (lib_plankton = {}));
|
})(lib_plankton || (lib_plankton = {}));
|
||||||
/*
|
/*
|
||||||
|
This file is part of »bacterio-plankton:pod«.
|
||||||
|
|
||||||
|
Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
||||||
|
<info@greenscale.de>
|
||||||
|
|
||||||
|
»bacterio-plankton:pod« 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:pod« 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:pod«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
var lib_plankton;
|
||||||
|
(function (lib_plankton) {
|
||||||
|
var pod;
|
||||||
|
(function (pod_1) {
|
||||||
|
/**
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function make_empty() {
|
||||||
|
return {
|
||||||
|
"kind": "empty"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
pod_1.make_empty = make_empty;
|
||||||
|
/**
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function make_filled(value) {
|
||||||
|
return {
|
||||||
|
"kind": "filled",
|
||||||
|
"value": value
|
||||||
|
};
|
||||||
|
}
|
||||||
|
pod_1.make_filled = make_filled;
|
||||||
|
/**
|
||||||
|
* whether the pod is filled
|
||||||
|
*
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function is_filled(pod) {
|
||||||
|
return (pod.kind === "filled");
|
||||||
|
}
|
||||||
|
pod_1.is_filled = is_filled;
|
||||||
|
/**
|
||||||
|
* return the value, stored in the pod-wrapper
|
||||||
|
*
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function cull(pod) {
|
||||||
|
if (!is_filled(pod)) {
|
||||||
|
throw (new Error("cull from empty"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return pod.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pod_1.cull = cull;
|
||||||
|
/**
|
||||||
|
* to pass on a empty-pod or to use a filled-pod
|
||||||
|
*
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function propagate(pod, function_) {
|
||||||
|
if (!is_filled(pod)) {
|
||||||
|
return make_empty();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return make_filled(function_(pod.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pod_1.propagate = propagate;
|
||||||
|
/**
|
||||||
|
* @author fenris
|
||||||
|
*/
|
||||||
|
function distinguish(pod, function_empty, function_filled) {
|
||||||
|
return ((!is_filled(pod))
|
||||||
|
? function_empty()
|
||||||
|
: function_filled(pod.value));
|
||||||
|
}
|
||||||
|
pod_1.distinguish = distinguish;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function show(pod, options = {}) {
|
||||||
|
options = Object.assign({
|
||||||
|
"show_value": value => String(value),
|
||||||
|
}, options);
|
||||||
|
if (!is_filled(pod)) {
|
||||||
|
return "<·>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ("<- " + options.show_value(pod.value) + " ->");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pod_1.show = show;
|
||||||
|
})(pod = lib_plankton.pod || (lib_plankton.pod = {}));
|
||||||
|
})(lib_plankton || (lib_plankton = {}));
|
||||||
|
/*
|
||||||
|
This file is part of »bacterio-plankton:pod«.
|
||||||
|
|
||||||
|
Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
||||||
|
<info@greenscale.de>
|
||||||
|
|
||||||
|
»bacterio-plankton:pod« 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:pod« 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:pod«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
var lib_plankton;
|
||||||
|
(function (lib_plankton) {
|
||||||
|
var pod;
|
||||||
|
(function (pod) {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class class_pod {
|
||||||
|
constructor(subject) { this.subject = subject; }
|
||||||
|
is_empty() { return (!pod.is_filled(this.subject)); }
|
||||||
|
is_filled() { return pod.is_filled(this.subject); }
|
||||||
|
cull() { return pod.cull(this.subject); }
|
||||||
|
show(show_value = undefined) { return pod.show(this.subject, show_value); }
|
||||||
|
toString() { return this.show(); }
|
||||||
|
propagate(function_) { return new class_pod(pod.propagate(this.subject, function_)); }
|
||||||
|
distinguish(function_empty, function_filled) { return pod.distinguish(this.subject, function_empty, function_filled); }
|
||||||
|
}
|
||||||
|
pod.class_pod = class_pod;
|
||||||
|
})(pod = lib_plankton.pod || (lib_plankton.pod = {}));
|
||||||
|
})(lib_plankton || (lib_plankton = {}));
|
||||||
|
/*
|
||||||
This file is part of »bacterio-plankton:call«.
|
This file is part of »bacterio-plankton:call«.
|
||||||
|
|
||||||
Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
|
||||||
|
|
@ -1113,21 +1000,27 @@ var lib_plankton;
|
||||||
/**
|
/**
|
||||||
* @author fenris
|
* @author fenris
|
||||||
*/
|
*/
|
||||||
function promise_show(label) {
|
/*
|
||||||
return (result => promise_make((resolve, reject) => {
|
export function promise_show<type_result, type_reason>(label : string) : (result : type_result)=>type_promise<type_result, type_reason> {
|
||||||
|
return (
|
||||||
|
result => promise_make<type_result, type_reason>(
|
||||||
|
(resolve, reject) => {
|
||||||
// lib_plankton.log.info(label + ": " + instance_show(result));
|
// lib_plankton.log.info(label + ": " + instance_show(result));
|
||||||
process.stdout.write(label + ": " + instance_show(result));
|
process.stdout.write(label + ": " + instance_show(result));
|
||||||
resolve(result);
|
resolve(result);
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
call.promise_show = promise_show;
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @author fenris
|
* @author fenris
|
||||||
*/
|
*/
|
||||||
function promise_log(result) {
|
/*
|
||||||
return promise_show("log");
|
export function promise_log<type_result, type_reason>(result : type_result) : (result : type_result)=>type_promise<type_result, type_reason> {
|
||||||
|
return promise_show<type_result, type_reason>("log");
|
||||||
}
|
}
|
||||||
call.promise_log = promise_log;
|
*/
|
||||||
/**
|
/**
|
||||||
* @author fenris
|
* @author fenris
|
||||||
*/
|
*/
|
||||||
|
|
@ -1442,16 +1335,16 @@ var lib_plankton;
|
||||||
function deferral_compose_parallel({ "left": deferral_left, "right": deferral_right, }) {
|
function deferral_compose_parallel({ "left": deferral_left, "right": deferral_right, }) {
|
||||||
return (deferral_make((input, convey) => {
|
return (deferral_make((input, convey) => {
|
||||||
let object = {
|
let object = {
|
||||||
"left": lib_maybe.make_nothing(),
|
"left": lib_plankton.pod.make_empty(),
|
||||||
"right": lib_maybe.make_nothing(),
|
"right": lib_plankton.pod.make_empty(),
|
||||||
};
|
};
|
||||||
let finish = function () {
|
let finish = function () {
|
||||||
if (lib_maybe.is_just(object.left)
|
if (lib_plankton.pod.is_filled(object.left)
|
||||||
&&
|
&&
|
||||||
lib_maybe.is_just(object.right)) {
|
lib_plankton.pod.is_filled(object.right)) {
|
||||||
let result = {
|
let result = {
|
||||||
"left": lib_maybe.cull(object.left),
|
"left": lib_plankton.pod.cull(object.left),
|
||||||
"right": lib_maybe.cull(object.right),
|
"right": lib_plankton.pod.cull(object.right),
|
||||||
};
|
};
|
||||||
convey(result);
|
convey(result);
|
||||||
}
|
}
|
||||||
|
|
@ -1460,11 +1353,11 @@ var lib_plankton;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
deferral_use(deferral_left, input, output_left => {
|
deferral_use(deferral_left, input, output_left => {
|
||||||
object.left = lib_maybe.make_just(output_left);
|
object.left = lib_plankton.pod.make_filled(output_left);
|
||||||
finish();
|
finish();
|
||||||
});
|
});
|
||||||
deferral_use(deferral_right, input, output_right => {
|
deferral_use(deferral_right, input, output_right => {
|
||||||
object.right = lib_maybe.make_just(output_right);
|
object.right = lib_plankton.pod.make_filled(output_right);
|
||||||
finish();
|
finish();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
@ -2302,14 +2195,14 @@ var lib_plankton;
|
||||||
"info": lib_plankton.log.enum_level.info,
|
"info": lib_plankton.log.enum_level.info,
|
||||||
"notice": lib_plankton.log.enum_level.notice,
|
"notice": lib_plankton.log.enum_level.notice,
|
||||||
"warning": lib_plankton.log.enum_level.warning,
|
"warning": lib_plankton.log.enum_level.warning,
|
||||||
"error": lib_plankton.log.enum_level.error
|
"error": lib_plankton.log.enum_level.error,
|
||||||
}[type]),
|
}[type]),
|
||||||
"incident": message,
|
"incident": message,
|
||||||
"details": {
|
"details": {
|
||||||
"prefix": prefix,
|
"prefix": prefix,
|
||||||
"level": level,
|
"level": level,
|
||||||
"indent": indent
|
"indent": indent,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
lib_plankton.log.add(entry);
|
lib_plankton.log.add(entry);
|
||||||
}
|
}
|
||||||
|
|
@ -2445,7 +2338,7 @@ var lib_plankton;
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var nm_fs = require("fs");
|
var nm_fs = require("fs");
|
||||||
nm_fs.writeFile(this.path, {
|
nm_fs.writeFile(this.path, {
|
||||||
"flag": "a+"
|
"flag": "a+",
|
||||||
}, (("<" + (new Date(Date.now())).toISOString().slice(0, 19) + ">")
|
}, (("<" + (new Date(Date.now())).toISOString().slice(0, 19) + ">")
|
||||||
+
|
+
|
||||||
" "
|
" "
|
||||||
|
|
@ -2618,7 +2511,7 @@ var lib_plankton;
|
||||||
"info": log.enum_level.info,
|
"info": log.enum_level.info,
|
||||||
"notice": log.enum_level.notice,
|
"notice": log.enum_level.notice,
|
||||||
"warning": log.enum_level.warning,
|
"warning": log.enum_level.warning,
|
||||||
"error": log.enum_level.error
|
"error": log.enum_level.error,
|
||||||
}[level_string];
|
}[level_string];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -3185,7 +3078,7 @@ var lib_plankton;
|
||||||
}
|
}
|
||||||
string.replace = replace;
|
string.replace = replace;
|
||||||
/**
|
/**
|
||||||
* @desc replaces occurences of "${name}" in a string by the corresponding values of an argument object
|
* @desc replaces occurences of "{{name}}" in a string by the corresponding values of an argument object
|
||||||
* @author fenris
|
* @author fenris
|
||||||
*/
|
*/
|
||||||
function coin(str, args, options = {}) {
|
function coin(str, args, options = {}) {
|
||||||
|
|
@ -4081,7 +3974,7 @@ var lib_plankton;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
"keys": keys,
|
"keys": keys,
|
||||||
"data": from.map(function (line) { return keys.map(function (name) { return line[name]; }); })
|
"data": from.map(function (line) { return keys.map(function (name) { return line[name]; }); }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
code.flatten_encode = flatten_encode;
|
code.flatten_encode = flatten_encode;
|
||||||
|
|
@ -4274,7 +4167,7 @@ var lib_plankton;
|
||||||
return (new Promise(function (resolve, reject) {
|
return (new Promise(function (resolve, reject) {
|
||||||
nm_fs.readFile(path, {
|
nm_fs.readFile(path, {
|
||||||
"encoding": "utf8",
|
"encoding": "utf8",
|
||||||
"flag": "r"
|
"flag": "r",
|
||||||
}, function (error, content) {
|
}, function (error, content) {
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
resolve(content);
|
resolve(content);
|
||||||
|
|
@ -4293,7 +4186,7 @@ var lib_plankton;
|
||||||
var nm_fs = require("fs");
|
var nm_fs = require("fs");
|
||||||
return (new Promise(function (resolve, reject) {
|
return (new Promise(function (resolve, reject) {
|
||||||
nm_fs.readFile(path, {
|
nm_fs.readFile(path, {
|
||||||
"flag": "r"
|
"flag": "r",
|
||||||
}, function (error, content) {
|
}, function (error, content) {
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
resolve(content);
|
resolve(content);
|
||||||
|
|
@ -4330,13 +4223,13 @@ var lib_plankton;
|
||||||
function write(path, content, options) {
|
function write(path, content, options) {
|
||||||
if (options === void 0) { options = {}; }
|
if (options === void 0) { options = {}; }
|
||||||
options = Object.assign({
|
options = Object.assign({
|
||||||
"encoding": "utf-8"
|
"encoding": "utf-8",
|
||||||
}, options);
|
}, options);
|
||||||
var nm_fs = require("fs");
|
var nm_fs = require("fs");
|
||||||
return (new Promise(function (resolve, reject) {
|
return (new Promise(function (resolve, reject) {
|
||||||
nm_fs.writeFile(path, content, {
|
nm_fs.writeFile(path, content, {
|
||||||
"encoding": options.encoding,
|
"encoding": options.encoding,
|
||||||
"flag": "w"
|
"flag": "w",
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
resolve(undefined);
|
resolve(undefined);
|
||||||
|
|
@ -4357,7 +4250,7 @@ var lib_plankton;
|
||||||
var nm_fs = require("fs");
|
var nm_fs = require("fs");
|
||||||
return (new Promise(function (resolve, reject) {
|
return (new Promise(function (resolve, reject) {
|
||||||
nm_fs.writeFile(path, content, {
|
nm_fs.writeFile(path, content, {
|
||||||
"flag": "w"
|
"flag": "w",
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
resolve(undefined);
|
resolve(undefined);
|
||||||
|
|
@ -4502,7 +4395,7 @@ var lib_plankton;
|
||||||
if (translate._verbosity >= 1) {
|
if (translate._verbosity >= 1) {
|
||||||
console.warn(`${_logprefix} no package '${identifier}'`);
|
console.warn(`${_logprefix} no package '${identifier}'`);
|
||||||
}
|
}
|
||||||
return (new class_nothing());
|
return (lib_plankton.pod.make_empty());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// let str : string = lib_plankton.object.path_read<string>(_packages[identifier].tree, path);
|
// let str : string = lib_plankton.object.path_read<string>(_packages[identifier].tree, path);
|
||||||
|
|
@ -4511,7 +4404,7 @@ var lib_plankton;
|
||||||
if (translate._verbosity >= 1) {
|
if (translate._verbosity >= 1) {
|
||||||
console.warn(`${_logprefix} string '${path}' missing in package '${identifier}'`);
|
console.warn(`${_logprefix} string '${path}' missing in package '${identifier}'`);
|
||||||
}
|
}
|
||||||
return (new class_nothing());
|
return (lib_plankton.pod.make_empty());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// resolve references
|
// resolve references
|
||||||
|
|
@ -4539,13 +4432,13 @@ var lib_plankton;
|
||||||
// fetch referenced string
|
// fetch referenced string
|
||||||
{
|
{
|
||||||
let result_ = fetch(identifier, path_, args_);
|
let result_ = fetch(identifier, path_, args_);
|
||||||
if (result_.is_just()) {
|
if (lib_plankton.pod.is_filled(result_)) {
|
||||||
let front = str.slice(0, matching.index);
|
let front = str.slice(0, matching.index);
|
||||||
let back = str.slice(matching.index + matching[0].length);
|
let back = str.slice(matching.index + matching[0].length);
|
||||||
str = (front + result_.cull() + back);
|
str = (front + lib_plankton.pod.cull(result_) + back);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (new class_nothing());
|
return (lib_plankton.pod.make_empty());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4559,7 +4452,7 @@ var lib_plankton;
|
||||||
{
|
{
|
||||||
str = lib_plankton.string.coin(str, args);
|
str = lib_plankton.string.coin(str, args);
|
||||||
}
|
}
|
||||||
return (new class_just(str));
|
return (lib_plankton.pod.make_filled(str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4575,13 +4468,13 @@ var lib_plankton;
|
||||||
if (translate._verbosity >= 2) {
|
if (translate._verbosity >= 2) {
|
||||||
console.info(`${_logprefix} getting translation for string '${path}' with arguments ${JSON.stringify(args)} …`);
|
console.info(`${_logprefix} getting translation for string '${path}' with arguments ${JSON.stringify(args)} …`);
|
||||||
}
|
}
|
||||||
let result = new class_nothing();
|
let result = lib_plankton.pod.make_empty();
|
||||||
let found = _order.some(identifier => {
|
let found = _order.some(identifier => {
|
||||||
if (translate._verbosity >= 2) {
|
if (translate._verbosity >= 2) {
|
||||||
console.info(`${_logprefix} trying package '${identifier}' …`);
|
console.info(`${_logprefix} trying package '${identifier}' …`);
|
||||||
}
|
}
|
||||||
let result_ = fetch(identifier, path, args);
|
let result_ = fetch(identifier, path, args);
|
||||||
if (result_.is_just()) {
|
if (lib_plankton.pod.is_filled(result_)) {
|
||||||
result = result_;
|
result = result_;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -4590,7 +4483,7 @@ var lib_plankton;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (found) {
|
if (found) {
|
||||||
let str = result.cull();
|
let str = lib_plankton.pod.cull(result);
|
||||||
if (translate._verbosity >= 3) {
|
if (translate._verbosity >= 3) {
|
||||||
console.info(`${_logprefix} found translation: '${str}'`);
|
console.info(`${_logprefix} found translation: '${str}'`);
|
||||||
}
|
}
|
||||||
|
|
@ -4862,8 +4755,8 @@ var lib_plankton;
|
||||||
"info": info,
|
"info": info,
|
||||||
"hidden": hidden,
|
"hidden": hidden,
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"index": index
|
"index": index,
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
|
@ -4881,8 +4774,8 @@ var lib_plankton;
|
||||||
"hidden": hidden,
|
"hidden": hidden,
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"indicators_short": indicators_short,
|
"indicators_short": indicators_short,
|
||||||
"indicators_long": indicators_long
|
"indicators_long": indicators_long,
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
|
@ -5128,17 +5021,17 @@ var lib_plankton;
|
||||||
"symbols": {
|
"symbols": {
|
||||||
"delimiter": " ",
|
"delimiter": " ",
|
||||||
"prefix": "--",
|
"prefix": "--",
|
||||||
"assignment": "="
|
"assignment": "=",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"symbols": {
|
"symbols": {
|
||||||
"delimiter": "&",
|
"delimiter": "&",
|
||||||
"prefix": "",
|
"prefix": "",
|
||||||
"assignment": "="
|
"assignment": "=",
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @author fenris
|
* @author fenris
|
||||||
|
|
@ -5215,14 +5108,14 @@ var lib_plankton;
|
||||||
"pattern_from": pattern_from,
|
"pattern_from": pattern_from,
|
||||||
"pattern_to": pattern_to,
|
"pattern_to": pattern_to,
|
||||||
"input": input,
|
"input": input,
|
||||||
"result": result
|
"result": result,
|
||||||
});
|
});
|
||||||
input = result;
|
input = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lib_plankton.log.debug("lib_args:read:current_input", {
|
lib_plankton.log.debug("lib_args:read:current_input", {
|
||||||
"input": input
|
"input": input,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// parsing
|
// parsing
|
||||||
|
|
@ -5233,18 +5126,18 @@ var lib_plankton;
|
||||||
var index_expected_1 = 0;
|
var index_expected_1 = 0;
|
||||||
parts.forEach(function (part) {
|
parts.forEach(function (part) {
|
||||||
lib_plankton.log.debug("lib_args:read:analyzing", {
|
lib_plankton.log.debug("lib_args:read:analyzing", {
|
||||||
"part": part
|
"part": part,
|
||||||
});
|
});
|
||||||
var found = [
|
var found = [
|
||||||
function () {
|
function () {
|
||||||
lib_plankton.log.debug("lib_args:read:probing_as_volatile", {
|
lib_plankton.log.debug("lib_args:read:probing_as_volatile", {
|
||||||
"part": part
|
"part": part,
|
||||||
});
|
});
|
||||||
for (var _i = 0, _a = Object.entries(_this.filter(args.enum_kind.volatile)); _i < _a.length; _i++) {
|
for (var _i = 0, _a = Object.entries(_this.filter(args.enum_kind.volatile)); _i < _a.length; _i++) {
|
||||||
var _b = _a[_i], name = _b[0], argument = _b[1];
|
var _b = _a[_i], name = _b[0], argument = _b[1];
|
||||||
lib_plankton.log.debug("lib_args:read:probing_as_volatile:trying", {
|
lib_plankton.log.debug("lib_args:read:probing_as_volatile:trying", {
|
||||||
"part": part,
|
"part": part,
|
||||||
"argument": argument.toString()
|
"argument": argument.toString(),
|
||||||
});
|
});
|
||||||
var pattern = "";
|
var pattern = "";
|
||||||
{
|
{
|
||||||
|
|
@ -5263,12 +5156,12 @@ var lib_plankton;
|
||||||
pattern += pattern_back;
|
pattern += pattern_back;
|
||||||
}
|
}
|
||||||
lib_plankton.log.debug("lib_args:read:probing_as_volatile:pattern", {
|
lib_plankton.log.debug("lib_args:read:probing_as_volatile:pattern", {
|
||||||
"pattern": pattern
|
"pattern": pattern,
|
||||||
});
|
});
|
||||||
var regexp = new RegExp(pattern);
|
var regexp = new RegExp(pattern);
|
||||||
var matching = regexp.exec(part);
|
var matching = regexp.exec(part);
|
||||||
lib_plankton.log.debug("lib_args:read:probing_as_volatile:matching", {
|
lib_plankton.log.debug("lib_args:read:probing_as_volatile:matching", {
|
||||||
"matching": matching
|
"matching": matching,
|
||||||
});
|
});
|
||||||
if (matching == null) {
|
if (matching == null) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
@ -5282,7 +5175,7 @@ var lib_plankton;
|
||||||
},
|
},
|
||||||
function () {
|
function () {
|
||||||
lib_plankton.log.debug("lib_args:read:probing_as_positional", {
|
lib_plankton.log.debug("lib_args:read:probing_as_positional", {
|
||||||
"part": part
|
"part": part,
|
||||||
});
|
});
|
||||||
var positional = _this.filter(args.enum_kind.positional);
|
var positional = _this.filter(args.enum_kind.positional);
|
||||||
for (var _i = 0, _a = Object.entries(positional); _i < _a.length; _i++) {
|
for (var _i = 0, _a = Object.entries(positional); _i < _a.length; _i++) {
|
||||||
|
|
@ -5293,7 +5186,7 @@ var lib_plankton;
|
||||||
else {
|
else {
|
||||||
lib_plankton.log.debug("lib_args:read:probing_as_positional:trying", {
|
lib_plankton.log.debug("lib_args:read:probing_as_positional:trying", {
|
||||||
"part": part,
|
"part": part,
|
||||||
"argument": argument.toString()
|
"argument": argument.toString(),
|
||||||
});
|
});
|
||||||
var pattern = "";
|
var pattern = "";
|
||||||
{
|
{
|
||||||
|
|
@ -5302,12 +5195,12 @@ var lib_plankton;
|
||||||
pattern += pattern_back;
|
pattern += pattern_back;
|
||||||
}
|
}
|
||||||
lib_plankton.log.debug("lib_args:read:probing_as_positional:pattern", {
|
lib_plankton.log.debug("lib_args:read:probing_as_positional:pattern", {
|
||||||
"pattern": pattern
|
"pattern": pattern,
|
||||||
});
|
});
|
||||||
var regexp = new RegExp(pattern);
|
var regexp = new RegExp(pattern);
|
||||||
var matching = regexp.exec(part);
|
var matching = regexp.exec(part);
|
||||||
lib_plankton.log.debug("lib_args:read:probing_as_positional:matching", {
|
lib_plankton.log.debug("lib_args:read:probing_as_positional:matching", {
|
||||||
"matching": matching
|
"matching": matching,
|
||||||
});
|
});
|
||||||
if (matching == null) {
|
if (matching == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -5324,7 +5217,7 @@ var lib_plankton;
|
||||||
].some(function (x) { return x(); });
|
].some(function (x) { return x(); });
|
||||||
if (!found) {
|
if (!found) {
|
||||||
lib_plankton.log.warning("lib_args:read:could_not_parse", {
|
lib_plankton.log.warning("lib_args:read:could_not_parse", {
|
||||||
"part": part
|
"part": part,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -5797,7 +5690,10 @@ var lib_plankton;
|
||||||
function decode_response(response_raw) {
|
function decode_response(response_raw) {
|
||||||
const lines = response_raw.split(linebreak);
|
const lines = response_raw.split(linebreak);
|
||||||
const first = lines.shift();
|
const first = lines.shift();
|
||||||
const status_code = parseInt(first.split(" ")[1]);
|
const first_parts = first.split(" ");
|
||||||
|
const version = first_parts[0];
|
||||||
|
const status_code = parseInt(first_parts[1]);
|
||||||
|
// first_parts.slice(2) ? probably irrelevant
|
||||||
let headers = {};
|
let headers = {};
|
||||||
while (true) {
|
while (true) {
|
||||||
const line = lines.shift();
|
const line = lines.shift();
|
||||||
|
|
@ -5812,7 +5708,7 @@ var lib_plankton;
|
||||||
const body = Buffer["from"](lines.join(linebreak));
|
const body = Buffer["from"](lines.join(linebreak));
|
||||||
const response = {
|
const response = {
|
||||||
// TODO
|
// TODO
|
||||||
"version": "HTTP/1.1",
|
"version": version,
|
||||||
"status_code": status_code,
|
"status_code": status_code,
|
||||||
"headers": headers,
|
"headers": headers,
|
||||||
"body": body,
|
"body": body,
|
||||||
|
|
@ -5842,7 +5738,6 @@ var lib_plankton;
|
||||||
((request.query === null)
|
((request.query === null)
|
||||||
? ""
|
? ""
|
||||||
: request.query));
|
: request.query));
|
||||||
console.info({ target });
|
|
||||||
switch (options.implementation) {
|
switch (options.implementation) {
|
||||||
default: {
|
default: {
|
||||||
return Promise.reject("invalid implementation: " + options.implementation);
|
return Promise.reject("invalid implementation: " + options.implementation);
|
||||||
|
|
@ -5862,6 +5757,7 @@ var lib_plankton;
|
||||||
case http.enum_method.head: return "HEAD";
|
case http.enum_method.head: return "HEAD";
|
||||||
}
|
}
|
||||||
})(request.method)),
|
})(request.method)),
|
||||||
|
"headers": request.headers,
|
||||||
"redirect": (options.follow_redirects ? "follow" : "manual"),
|
"redirect": (options.follow_redirects ? "follow" : "manual"),
|
||||||
"signal": (signal ?? undefined),
|
"signal": (signal ?? undefined),
|
||||||
})
|
})
|
||||||
|
|
@ -5872,7 +5768,7 @@ var lib_plankton;
|
||||||
.then((response_raw) => (response_raw.text()
|
.then((response_raw) => (response_raw.text()
|
||||||
.then((body) => Promise.resolve({
|
.then((body) => Promise.resolve({
|
||||||
// TODO
|
// TODO
|
||||||
"version": "HTTP/1.1",
|
"version": null,
|
||||||
"status_code": response_raw.status,
|
"status_code": response_raw.status,
|
||||||
"headers": ((headers_raw => {
|
"headers": ((headers_raw => {
|
||||||
let headers = {};
|
let headers = {};
|
||||||
|
|
@ -5931,7 +5827,7 @@ var lib_plankton;
|
||||||
res.on("end", () => {
|
res.on("end", () => {
|
||||||
resolve({
|
resolve({
|
||||||
// TODO
|
// TODO
|
||||||
"version": "HTTP/1.1",
|
"version": null,
|
||||||
"status_code": res.statusCode,
|
"status_code": res.statusCode,
|
||||||
"headers": res.headers,
|
"headers": res.headers,
|
||||||
"body": response_body,
|
"body": response_body,
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,20 @@ async function main(
|
||||||
"info": lib_plankton.translate.get("help.args.time_to_live"),
|
"info": lib_plankton.translate.get("help.args.time_to_live"),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
"working_directory": new lib_plankton.args.class_argument(
|
||||||
|
{
|
||||||
|
"name": "working_directory",
|
||||||
|
"type": lib_plankton.args.enum_type.string,
|
||||||
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||||||
|
"mode": lib_plankton.args.enum_mode.replace,
|
||||||
|
"default": ".",
|
||||||
|
"parameters": {
|
||||||
|
"indicators_long": ["working-directory"],
|
||||||
|
"indicators_short": ["w"],
|
||||||
|
},
|
||||||
|
"info": lib_plankton.translate.get("help.args.working_directory"),
|
||||||
|
}
|
||||||
|
),
|
||||||
"verbosity": new lib_plankton.args.class_argument(
|
"verbosity": new lib_plankton.args.class_argument(
|
||||||
{
|
{
|
||||||
"name": "verbosity",
|
"name": "verbosity",
|
||||||
|
|
@ -235,9 +249,14 @@ async function main(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
const order_path : string = (
|
||||||
|
args["order_path"].startsWith("/")
|
||||||
|
? args["order_path"]
|
||||||
|
: (args["working_directory"] + "/" + args["order_path"])
|
||||||
|
);
|
||||||
const nm_path = require("path");
|
const nm_path = require("path");
|
||||||
const nm_fs = require("fs");
|
const nm_fs = require("fs");
|
||||||
if (! nm_fs.existsSync(args["order_path"])) {
|
if (! nm_fs.existsSync(order_path)) {
|
||||||
lib_plankton.log.error(
|
lib_plankton.log.error(
|
||||||
lib_plankton.translate.get("misc.order_file_not_found"),
|
lib_plankton.translate.get("misc.order_file_not_found"),
|
||||||
{
|
{
|
||||||
|
|
@ -247,7 +266,7 @@ async function main(
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const order : _heimdall.type_order = await _heimdall.order.load(
|
const order : _heimdall.type_order = await _heimdall.order.load(
|
||||||
nm_path.normalize(args["order_path"])
|
nm_path.normalize(order_path)
|
||||||
);
|
);
|
||||||
if (args["expose_full_order"]) {
|
if (args["expose_full_order"]) {
|
||||||
process.stdout.write(lib_plankton.json.encode(order, true) + "\n");
|
process.stdout.write(lib_plankton.json.encode(order, true) + "\n");
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
"help.args.show_schema": "nur das hmdl-JSON-Schema zur Standard-Ausgabe schreiben und beenden",
|
"help.args.show_schema": "nur das hmdl-JSON-Schema zur Standard-Ausgabe schreiben und beenden",
|
||||||
"help.args.expose_full_order": "nur den Pfad zur Datenbank-Datei zur Standard-Ausgabe schreiben und beenden (nützlich für Fehlersuche)",
|
"help.args.expose_full_order": "nur den Pfad zur Datenbank-Datei zur Standard-Ausgabe schreiben und beenden (nützlich für Fehlersuche)",
|
||||||
"help.args.show_version": "nur die Version zur Standard-Ausgabe schreiben und beenden",
|
"help.args.show_version": "nur die Version zur Standard-Ausgabe schreiben und beenden",
|
||||||
|
"help.args.working_directory": "Verzichnis in welchem die Auftrags-Datei zu finden ist, falls mit relativem Pfad angegeben",
|
||||||
"help.args.verbosity": "Schwellwert für Log-Ausgaben",
|
"help.args.verbosity": "Schwellwert für Log-Ausgaben",
|
||||||
"checks.script.execution_failed": "Ausführung gescheitert",
|
"checks.script.execution_failed": "Ausführung gescheitert",
|
||||||
"checks.script.invalid_return_code": "ungültiger Rückgabe-Code",
|
"checks.script.invalid_return_code": "ungültiger Rückgabe-Code",
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
"help.args.show_schema": "print the hmdl JSON schema to stdout and exit",
|
"help.args.show_schema": "print the hmdl JSON schema to stdout and exit",
|
||||||
"help.args.expose_full_order": "only print the extended order to stdout and exit (useful for debugging)",
|
"help.args.expose_full_order": "only print the extended order to stdout and exit (useful for debugging)",
|
||||||
"help.args.show_version": "only print the version to stdout and exit",
|
"help.args.show_version": "only print the version to stdout and exit",
|
||||||
|
"help.args.working_directory": "directory to loof for the order file, in case its path is specified relatively",
|
||||||
"help.args.verbosity": "threshold for log outputs",
|
"help.args.verbosity": "threshold for log outputs",
|
||||||
"checks.script.execution_failed": "execution failed",
|
"checks.script.execution_failed": "execution failed",
|
||||||
"checks.script.invalid_return_code": "invalid return code",
|
"checks.script.invalid_return_code": "invalid return code",
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ namespace _heimdall.master
|
||||||
);
|
);
|
||||||
lib_plankton.log.info(
|
lib_plankton.log.info(
|
||||||
lib_plankton.translate.get(
|
lib_plankton.translate.get(
|
||||||
"cleanup_info",
|
"misc.cleanup_info",
|
||||||
{
|
{
|
||||||
"count": count.toFixed(0),
|
"count": count.toFixed(0),
|
||||||
}
|
}
|
||||||
|
|
@ -264,7 +264,7 @@ namespace _heimdall.master
|
||||||
"count": count,
|
"count": count,
|
||||||
"last_notification_timestamp": last_notification_timestamp,
|
"last_notification_timestamp": last_notification_timestamp,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const timestamp : int = _heimdall.get_current_timestamp();
|
const timestamp : int = _heimdall.get_current_timestamp();
|
||||||
const due : boolean = determine_due(
|
const due : boolean = determine_due(
|
||||||
check,
|
check,
|
||||||
|
|
@ -373,6 +373,5 @@ namespace _heimdall.master
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
666
source/test/data.json
Normal file
666
source/test/data.json
Normal file
|
|
@ -0,0 +1,666 @@
|
||||||
|
{
|
||||||
|
"parameters": {
|
||||||
|
"check": {
|
||||||
|
"active": true,
|
||||||
|
"threshold": 1,
|
||||||
|
"schedule": {
|
||||||
|
"attentive_interval": 120,
|
||||||
|
"regular_interval": 3600,
|
||||||
|
"reminding_interval": 86400
|
||||||
|
},
|
||||||
|
"notifications": [],
|
||||||
|
"name": "test",
|
||||||
|
"title": "Test",
|
||||||
|
"kind": "BOGUS",
|
||||||
|
"parameters": {},
|
||||||
|
"custom": null,
|
||||||
|
"annoy": true
|
||||||
|
},
|
||||||
|
"old_item_state": {
|
||||||
|
"timestamp": "2023-01-15T11:00:00",
|
||||||
|
"last_notification_timestamp": "2023-01-15T10:00:00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cases": [
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":false,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": false,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"unknown\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "unknown",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"ok\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "ok",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"concerning\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "concerning",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":false,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": false,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"none\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "none"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"attentive\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "attentive"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"regular\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "regular"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "{\"annoy\":true,\"condition\":\"critical\",\"threshold_reached\":true,\"passed\":\"reminding\"}",
|
||||||
|
"input": {
|
||||||
|
"annoy": true,
|
||||||
|
"condition": "critical",
|
||||||
|
"threshold_reached": true,
|
||||||
|
"passed": "reminding"
|
||||||
|
},
|
||||||
|
"output": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
const nm_assert = require("assert");
|
const nm_assert = require("assert");
|
||||||
|
const nm_fs = require("fs");
|
||||||
|
|
||||||
declare var describe;
|
declare var describe;
|
||||||
declare var it;
|
declare var it;
|
||||||
|
|
@ -18,125 +19,10 @@ describe(
|
||||||
"critical": _heimdall.enum_condition.critical,
|
"critical": _heimdall.enum_condition.critical,
|
||||||
}[condition_raw];
|
}[condition_raw];
|
||||||
};
|
};
|
||||||
|
const data = JSON.parse(nm_fs.readFileSync("./test-data.json"));
|
||||||
describe(
|
describe(
|
||||||
"master.determine_due",
|
"master.determine_due",
|
||||||
() => {
|
() => {
|
||||||
const dimensions = [
|
|
||||||
{"name": "annoy", "elements": [false, true]},
|
|
||||||
{"name": "condition", "elements": ["unknown", "ok", "concerning", "critical"]},
|
|
||||||
{"name": "treshold_reached", "elements": [false, true]},
|
|
||||||
{"name": "passed", "elements": ["none", "attentive", "regular", "reminding"]},
|
|
||||||
];
|
|
||||||
const parameters = {
|
|
||||||
"check": {
|
|
||||||
"active": true,
|
|
||||||
"threshold": 1,
|
|
||||||
"schedule": {
|
|
||||||
"attentive_interval": 120,
|
|
||||||
"regular_interval": 3600,
|
|
||||||
"reminding_interval": 86400,
|
|
||||||
},
|
|
||||||
"notifications": [],
|
|
||||||
"name": "test",
|
|
||||||
"title": "Test",
|
|
||||||
"kind": "BOGUS",
|
|
||||||
"parameters": {},
|
|
||||||
"custom": null,
|
|
||||||
},
|
|
||||||
"old_item_state": {
|
|
||||||
"timestamp": "2023-01-15T11:00:00",
|
|
||||||
"last_notification_timestamp": "2023-01-15T10:00:00",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const cases = (
|
|
||||||
dimensions
|
|
||||||
.reduce<any>(
|
|
||||||
(product, dimension) => (
|
|
||||||
product
|
|
||||||
.map(
|
|
||||||
tuple => (
|
|
||||||
dimension.elements
|
|
||||||
.map(
|
|
||||||
element => Object.fromEntries(
|
|
||||||
Object.entries(tuple)
|
|
||||||
.concat([[dimension.name, element]])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.reduce(
|
|
||||||
((x, y) => x.concat(y)),
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
[{}]
|
|
||||||
)
|
|
||||||
.map(
|
|
||||||
input => ({
|
|
||||||
"name": JSON.stringify(input),
|
|
||||||
"input": input,
|
|
||||||
// "output": false,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const data = {
|
|
||||||
"parameters": parameters,
|
|
||||||
"cases": (
|
|
||||||
cases
|
|
||||||
.map(
|
|
||||||
case_ => {
|
|
||||||
// setup
|
|
||||||
const check : _heimdall.type_check = Object.assign(
|
|
||||||
parameters["check"],
|
|
||||||
{
|
|
||||||
"annoy": case_.input["annoy"],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const old_item_state : _heimdall.type_item_state = {
|
|
||||||
"timestamp": datetimestring_to_timestamp(parameters["old_item_state"]["timestamp"]),
|
|
||||||
"condition": resolve_condition(case_.input["condition"]),
|
|
||||||
"count": (case_.input["treshold_reached"] ? null : 0),
|
|
||||||
"last_notification_timestamp": datetimestring_to_timestamp(parameters["old_item_state"]["last_notification_timestamp"]),
|
|
||||||
};
|
|
||||||
const timestamp : int = (
|
|
||||||
datetimestring_to_timestamp(
|
|
||||||
parameters["old_item_state"]["timestamp"]
|
|
||||||
)
|
|
||||||
+
|
|
||||||
(
|
|
||||||
{
|
|
||||||
"none": 0,
|
|
||||||
"attentive": parameters["check"]["schedule"]["attentive_interval"],
|
|
||||||
"regular": parameters["check"]["schedule"]["regular_interval"],
|
|
||||||
"reminding": parameters["check"]["schedule"]["reminding_interval"]
|
|
||||||
}[case_.input["passed"]]
|
|
||||||
)
|
|
||||||
+
|
|
||||||
60
|
|
||||||
);
|
|
||||||
console.info({check,old_item_state,timestamp});
|
|
||||||
|
|
||||||
// execution
|
|
||||||
const result : boolean = _heimdall.master.determine_due(
|
|
||||||
check,
|
|
||||||
old_item_state,
|
|
||||||
{
|
|
||||||
"timestamp": timestamp,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return Object.assign(
|
|
||||||
case_,
|
|
||||||
{
|
|
||||||
"output": result,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
};
|
|
||||||
process.stdout.write(JSON.stringify(data, undefined, "\t") + "\n");
|
|
||||||
/*
|
|
||||||
data.cases.forEach(
|
data.cases.forEach(
|
||||||
case_ => {
|
case_ => {
|
||||||
it(
|
it(
|
||||||
|
|
@ -152,7 +38,7 @@ process.stdout.write(JSON.stringify(data, undefined, "\t") + "\n");
|
||||||
const old_item_state : _heimdall.type_item_state = {
|
const old_item_state : _heimdall.type_item_state = {
|
||||||
"timestamp": datetimestring_to_timestamp(data.parameters["old_item_state"]["timestamp"]),
|
"timestamp": datetimestring_to_timestamp(data.parameters["old_item_state"]["timestamp"]),
|
||||||
"condition": resolve_condition(case_.input["condition"]),
|
"condition": resolve_condition(case_.input["condition"]),
|
||||||
"count": (case_.input["treshold_reached"] ? null : 0),
|
"count": (case_.input["threshold_reached"] ? null : 0),
|
||||||
"last_notification_timestamp": datetimestring_to_timestamp(data.parameters["old_item_state"]["last_notification_timestamp"]),
|
"last_notification_timestamp": datetimestring_to_timestamp(data.parameters["old_item_state"]["last_notification_timestamp"]),
|
||||||
};
|
};
|
||||||
const timestamp : int = (
|
const timestamp : int = (
|
||||||
|
|
@ -171,7 +57,6 @@ process.stdout.write(JSON.stringify(data, undefined, "\t") + "\n");
|
||||||
+
|
+
|
||||||
60
|
60
|
||||||
);
|
);
|
||||||
console.info({check,old_item_state,timestamp});
|
|
||||||
|
|
||||||
// execution
|
// execution
|
||||||
const result : boolean = _heimdall.master.determine_due(
|
const result : boolean = _heimdall.master.determine_due(
|
||||||
|
|
@ -188,7 +73,6 @@ console.info({check,old_item_state,timestamp});
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
78
tools/build
78
tools/build
|
|
@ -1,25 +1,69 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
## vars
|
import os as _os
|
||||||
|
import shutil as _shutil
|
||||||
|
import argparse as _argparse
|
||||||
|
|
||||||
path_prj_core_from=tools/heimdall-core.prj.json
|
|
||||||
path_prj_core_to=heimdall-core.prj.json
|
def file_copy(
|
||||||
path_prj_app_from=tools/heimdall-app.prj.json
|
path_from,
|
||||||
path_prj_app_to=heimdall-app.prj.json
|
path_to
|
||||||
path_prj_test_from=tools/heimdall-test.prj.json
|
):
|
||||||
path_prj_test_to=heimdall-test.prj.json
|
_shutil.copyfile(path_from, path_to)
|
||||||
|
|
||||||
|
|
||||||
|
def file_remove(
|
||||||
|
path
|
||||||
|
):
|
||||||
|
_os.remove(path)
|
||||||
|
|
||||||
|
|
||||||
|
def shell_execute(
|
||||||
|
command
|
||||||
|
):
|
||||||
|
_os.system(command)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main(
|
||||||
|
):
|
||||||
|
## args
|
||||||
|
|
||||||
|
argument_parser = _argparse.ArgumentParser()
|
||||||
|
argument_parser.add_argument(
|
||||||
|
"-t",
|
||||||
|
"--include-tests",
|
||||||
|
action = "store_true"
|
||||||
|
)
|
||||||
|
args = argument_parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
## consts
|
||||||
|
|
||||||
|
path_prj_core_from = "tools/heimdall-core.prj.json"
|
||||||
|
path_prj_core_to = "heimdall-core.prj.json"
|
||||||
|
path_prj_app_from = "tools/heimdall-app.prj.json"
|
||||||
|
path_prj_app_to = "heimdall-app.prj.json"
|
||||||
|
path_prj_test_from = "tools/heimdall-test.prj.json"
|
||||||
|
path_prj_test_to = "heimdall-test.prj.json"
|
||||||
|
|
||||||
|
|
||||||
## exec
|
## exec
|
||||||
|
|
||||||
cp ${path_prj_core_from} ${path_prj_core_to}
|
file_copy(path_prj_core_from, path_prj_core_to)
|
||||||
cp ${path_prj_app_from} ${path_prj_app_to}
|
file_copy(path_prj_app_from, path_prj_app_to)
|
||||||
cp ${path_prj_test_from} ${path_prj_test_to}
|
file_copy(path_prj_test_from, path_prj_test_to)
|
||||||
|
|
||||||
koralle --execute ${path_prj_app_to}
|
shell_execute("koralle --execute %s" % path_prj_app_to)
|
||||||
chmod +r build/heimdall
|
shell_execute("chmod +r build/heimdall")
|
||||||
koralle --execute ${path_prj_test_to}
|
if (not args.include_tests):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
shell_execute("koralle --execute %s" % path_prj_test_to)
|
||||||
|
|
||||||
rm ${path_prj_test_to}
|
file_remove(path_prj_test_to)
|
||||||
rm ${path_prj_app_to}
|
file_remove(path_prj_app_to)
|
||||||
rm ${path_prj_core_to}
|
file_remove(path_prj_core_to)
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@
|
||||||
"heimdall-core.prj.json"
|
"heimdall-core.prj.json"
|
||||||
],
|
],
|
||||||
"roottask": {
|
"roottask": {
|
||||||
|
"name": "all",
|
||||||
|
"type": "group",
|
||||||
|
"sub": [
|
||||||
|
{
|
||||||
"name": "link",
|
"name": "link",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
|
|
@ -30,5 +34,15 @@
|
||||||
],
|
],
|
||||||
"output": "build/heimdall-test.mocha.js"
|
"output": "build/heimdall-test.mocha.js"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "data",
|
||||||
|
"type": "copy",
|
||||||
|
"parameters": {
|
||||||
|
"input": "source/test/data.json",
|
||||||
|
"output": "build/test-data.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,17 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
mkdir -p /usr/local/bin/
|
## args
|
||||||
cp build/heimdall /usr/local/bin/heimdall
|
|
||||||
|
|
||||||
mkdir -p /usr/local/share/icons/
|
if [ $# -ge 1 ] ; then directory=$1 && shift ; else directory="/opt/heimdall" ; fi
|
||||||
|
|
||||||
|
|
||||||
|
## exec
|
||||||
|
|
||||||
|
mkdir --parents ${directory}
|
||||||
|
cp --recursive --update --verbose build/* ${directory}/
|
||||||
|
|
||||||
|
mkdir --parents /usr/local/bin/
|
||||||
|
echo "dir=\$(pwd) && cd ${directory} && ./heimdall --working-directory=\${dir} \$@" > /usr/local/bin/heimdall
|
||||||
|
|
||||||
|
mkdir --parents /usr/local/share/icons/
|
||||||
cp media/icon.png /usr/local/share/icons/heimdall.png
|
cp media/icon.png /usr/local/share/icons/heimdall.png
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue