| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
 | import { Schema } from 'jsonschema';
import { yellow, red, cyan, green, blue, magenta, Color, grey, gray, white, black } from 'colors';
const colorPattern = /black|red|green|yellow|blue|magenta|cyan|white|gray|grey/;
const identifierProperties: Schema = {
    type: 'object',
    properties: {
        text: {
            type: 'string',
            minLength: 1,
        },
        color: {
            type: 'string',
            pattern: colorPattern,
        },
    },
};
const portProperties: Schema = {
    type: 'number',
    minimum: 443,
    maximum: 65535,
};
export const configurationSchema: Schema = {
    id: '/configuration',
    type: 'object',
    properties: {
        showServerOutput: { type: 'boolean' },
        ports: {
            type: 'object',
            properties: {
                server: portProperties,
                socket: portProperties,
            },
            required: ['server'],
            additionalProperties: true,
        },
        identifiers: {
            type: 'object',
            properties: {
                master: identifierProperties,
                worker: identifierProperties,
                exec: identifierProperties,
            },
        },
        polling: {
            type: 'object',
            additionalProperties: false,
            properties: {
                intervalSeconds: {
                    type: 'number',
                    minimum: 1,
                    maximum: 86400,
                },
                route: {
                    type: 'string',
                    pattern: /\/[a-zA-Z]*/g,
                },
                failureTolerance: {
                    type: 'number',
                    minimum: 0,
                },
            },
        },
    },
};
type ColorLabel = 'yellow' | 'red' | 'cyan' | 'green' | 'blue' | 'magenta' | 'grey' | 'gray' | 'white' | 'black';
export const colorMapping: Map<ColorLabel, Color> = new Map([
    ['yellow', yellow],
    ['red', red],
    ['cyan', cyan],
    ['green', green],
    ['blue', blue],
    ['magenta', magenta],
    ['grey', grey],
    ['gray', gray],
    ['white', white],
    ['black', black],
]);
interface Identifier {
    text: string;
    color: ColorLabel;
}
export interface Identifiers {
    master: Identifier;
    worker: Identifier;
    exec: Identifier;
}
export interface Configuration {
    showServerOutput: boolean;
    identifiers: Identifiers;
    ports: { [description: string]: number };
    polling: {
        route: string;
        intervalSeconds: number;
        failureTolerance: number;
    };
}
export const defaultConfig: Configuration = {
    showServerOutput: false,
    identifiers: {
        master: {
            text: '__monitor__',
            color: 'yellow',
        },
        worker: {
            text: '__server__',
            color: 'magenta',
        },
        exec: {
            text: '__exec__',
            color: 'green',
        },
    },
    ports: { server: 1050 },
    polling: {
        route: '/',
        intervalSeconds: 30,
        failureTolerance: 0,
    },
};
 |