[int]
This commit is contained in:
parent
1e9a6e2f4f
commit
2b6e350e3b
|
|
@ -33,7 +33,7 @@ namespace _heimdall.check_kinds.http_request
|
||||||
},
|
},
|
||||||
"timeout": {
|
"timeout": {
|
||||||
"description": "maximum allowed execution time in seconds",
|
"description": "maximum allowed execution time in seconds",
|
||||||
"type": "float",
|
"type": "number",
|
||||||
"default": 5.0
|
"default": 5.0
|
||||||
},
|
},
|
||||||
"follow_redirects": {
|
"follow_redirects": {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ namespace _heimdall.helpers.json_schema
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
type type_type = (
|
type type_name = (
|
||||||
"null"
|
"null"
|
||||||
|
|
|
|
||||||
"boolean"
|
"boolean"
|
||||||
|
|
@ -21,13 +21,60 @@ namespace _heimdall.helpers.json_schema
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @see https://json-schema.org/
|
||||||
|
* @see https://json-schema.org/understanding-json-schema/reference/type.html
|
||||||
*/
|
*/
|
||||||
export type type_schema = {
|
export type type_schema = (
|
||||||
type ?: (
|
{
|
||||||
type_type
|
description ?: string;
|
||||||
|
deprecated ?: boolean;
|
||||||
|
}
|
||||||
|
&
|
||||||
|
(
|
||||||
|
{
|
||||||
|
type : "null";
|
||||||
|
}
|
||||||
|
|
|
|
||||||
Array<type_type>
|
{
|
||||||
);
|
type : "boolean";
|
||||||
|
default ?: boolean;
|
||||||
|
enum ?: Array<boolean>;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
{
|
||||||
|
type : "integer";
|
||||||
|
default ?: int;
|
||||||
|
enum ?: Array<int>;
|
||||||
|
minimum ?: int;
|
||||||
|
exclusiveMinimum ?: int;
|
||||||
|
maximum ?: int;
|
||||||
|
exclusiveMaximum ?: int;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
{
|
||||||
|
type : "number";
|
||||||
|
default ?: float;
|
||||||
|
enum ?: Array<float>;
|
||||||
|
minimum ?: float;
|
||||||
|
exclusiveMinimum ?: float;
|
||||||
|
maximum ?: float;
|
||||||
|
exclusiveMaximum ?: float;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
{
|
||||||
|
type : "string";
|
||||||
|
default ?: string;
|
||||||
|
enum ?: Array<string>;
|
||||||
|
minLength ?: int;
|
||||||
|
maxLength ?: int;
|
||||||
|
pattern ?: string;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
/**
|
||||||
|
* @see https://json-schema.org/understanding-json-schema/reference/object.html#object
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
type : "object";
|
||||||
additionalProperties ?: (
|
additionalProperties ?: (
|
||||||
false
|
false
|
||||||
|
|
|
|
||||||
|
|
@ -35,16 +82,30 @@ namespace _heimdall.helpers.json_schema
|
||||||
);
|
);
|
||||||
properties ?: Record<string, type_schema>;
|
properties ?: Record<string, type_schema>;
|
||||||
required ?: Array<string>;
|
required ?: Array<string>;
|
||||||
description ?: string;
|
unevaluatedProperties ?: boolean;
|
||||||
default ?: any;
|
default ?: Object;
|
||||||
minimum ?: int;
|
enum ?: Array<Object>;
|
||||||
exclusiveMinimum ?: int;
|
}
|
||||||
maximum ?: int;
|
|
|
||||||
exclusiveMaximum ?: int;
|
{
|
||||||
enum ?: Array<any>;
|
type ?: "array";
|
||||||
items ?: type_schema;
|
items ?: type_schema;
|
||||||
|
default ?: Array<any>;
|
||||||
|
enum ?: Array<Array<any>>;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
{
|
||||||
|
type ?: Array<type_name>;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
{
|
||||||
anyOf ?: Array<type_schema>;
|
anyOf ?: Array<type_schema>;
|
||||||
deprecated ?: boolean;
|
}
|
||||||
};
|
|
|
||||||
|
{
|
||||||
|
allOf ?: Array<type_schema>;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -372,7 +372,7 @@ async function main(
|
||||||
"last_notification_timestamp": last_notification_timestamp,
|
"last_notification_timestamp": last_notification_timestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestamp = (Date.now() / 1000);
|
const timestamp : int = Math.floor(Date.now() / 1000);
|
||||||
const due : boolean = (
|
const due : boolean = (
|
||||||
(old_item_state === null)
|
(old_item_state === null)
|
||||||
||
|
||
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,31 @@ namespace _heimdall.order
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo
|
|
||||||
*/
|
*/
|
||||||
type type_schedule = any;
|
type type_interval = (
|
||||||
|
null
|
||||||
|
|
|
||||||
|
int
|
||||||
|
|
|
||||||
|
(
|
||||||
|
"minute"
|
||||||
|
|
|
||||||
|
"hour"
|
||||||
|
|
|
||||||
|
"day"
|
||||||
|
|
|
||||||
|
"week"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
type type_schedule = {
|
||||||
|
regular_interval : type_interval;
|
||||||
|
attentive_interval : type_interval;
|
||||||
|
reminding_interval : type_interval;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,6 +72,8 @@ namespace _heimdall.order
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function schema_active(
|
function schema_active(
|
||||||
) : _heimdall.helpers.json_schema.type_schema
|
) : _heimdall.helpers.json_schema.type_schema
|
||||||
{
|
{
|
||||||
|
|
@ -61,6 +85,8 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function schema_threshold(
|
function schema_threshold(
|
||||||
) : _heimdall.helpers.json_schema.type_schema
|
) : _heimdall.helpers.json_schema.type_schema
|
||||||
{
|
{
|
||||||
|
|
@ -73,6 +99,8 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function schema_annoy(
|
function schema_annoy(
|
||||||
) : _heimdall.helpers.json_schema.type_schema
|
) : _heimdall.helpers.json_schema.type_schema
|
||||||
{
|
{
|
||||||
|
|
@ -84,8 +112,10 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function schema_interval(
|
function schema_interval(
|
||||||
allow_null,
|
allow_null : boolean,
|
||||||
default_
|
default_
|
||||||
) : _heimdall.helpers.json_schema.type_schema
|
) : _heimdall.helpers.json_schema.type_schema
|
||||||
{
|
{
|
||||||
|
|
@ -112,8 +142,10 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function schema_schedule(
|
function schema_schedule(
|
||||||
)
|
) : _heimdall.helpers.json_schema.type_schema
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
@ -129,9 +161,11 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function schema_notifications(
|
function schema_notifications(
|
||||||
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>
|
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>
|
||||||
)
|
) : _heimdall.helpers.json_schema.type_schema
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|
@ -169,10 +203,12 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
export function schema_root(
|
export function schema_root(
|
||||||
check_kind_implementations : Record<string, _heimdall.check_kinds.type_check_kind>,
|
check_kind_implementations : Record<string, _heimdall.check_kinds.type_check_kind>,
|
||||||
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
||||||
)
|
) : _heimdall.helpers.json_schema.type_schema
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
@ -262,9 +298,11 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function normalize_interval(
|
function normalize_interval(
|
||||||
interval_raw
|
interval_raw
|
||||||
)
|
) : (null | type_interval)
|
||||||
{
|
{
|
||||||
if (interval_raw === null) {
|
if (interval_raw === null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -274,7 +312,7 @@ namespace _heimdall.order
|
||||||
return interval_raw;
|
return interval_raw;
|
||||||
}
|
}
|
||||||
else if (typeof(interval_raw) === "string") {
|
else if (typeof(interval_raw) === "string") {
|
||||||
const map_ = {
|
const map_ : Record<("minute" | "hour" | "day" | "week"), int> = {
|
||||||
"minute": (60),
|
"minute": (60),
|
||||||
"hour": (60 * 60),
|
"hour": (60 * 60),
|
||||||
"day": (60 * 60 * 24),
|
"day": (60 * 60 * 24),
|
||||||
|
|
@ -294,9 +332,11 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function normalize_schedule(
|
function normalize_schedule(
|
||||||
node
|
node
|
||||||
)
|
) : type_schedule
|
||||||
{
|
{
|
||||||
const node_ = Object.assign(
|
const node_ = Object.assign(
|
||||||
{
|
{
|
||||||
|
|
@ -314,10 +354,12 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function normalize_notification(
|
function normalize_notification(
|
||||||
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
||||||
node
|
node : any
|
||||||
)
|
) : type_notification
|
||||||
{
|
{
|
||||||
if (! (node["kind"] in notification_kind_implementations)) {
|
if (! (node["kind"] in notification_kind_implementations)) {
|
||||||
throw new Error("invalid notification kind: " + node["kind"]);
|
throw new Error("invalid notification kind: " + node["kind"]);
|
||||||
|
|
@ -331,10 +373,12 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
function normalize_defaults(
|
function normalize_defaults(
|
||||||
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
||||||
node
|
node : any
|
||||||
)
|
) : type_check_common
|
||||||
{
|
{
|
||||||
const node_ = Object.assign(
|
const node_ = Object.assign(
|
||||||
{
|
{
|
||||||
|
|
@ -441,7 +485,7 @@ namespace _heimdall.order
|
||||||
function normalize_root(
|
function normalize_root(
|
||||||
check_kind_implementations : Record<string, _heimdall.check_kinds.type_check_kind>,
|
check_kind_implementations : Record<string, _heimdall.check_kinds.type_check_kind>,
|
||||||
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
||||||
node,
|
node : any,
|
||||||
options : {
|
options : {
|
||||||
use_implicit_default_values ?: boolean;
|
use_implicit_default_values ?: boolean;
|
||||||
} = {}
|
} = {}
|
||||||
|
|
@ -521,6 +565,8 @@ namespace _heimdall.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
export async function load(
|
export async function load(
|
||||||
check_kind_implementations : Record<string, _heimdall.check_kinds.type_check_kind>,
|
check_kind_implementations : Record<string, _heimdall.check_kinds.type_check_kind>,
|
||||||
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
notification_kind_implementations : Record<string, _heimdall.notification_kinds.type_notification_kind>,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue