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