statcon 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +36 -0
- package/dist/serializeCasing.d.ts +10 -0
- package/dist/serializeCasing.js +17 -0
- package/dist/structures/Alerting.d.ts +26 -0
- package/dist/structures/Alerting.js +47 -0
- package/dist/structures/Announcement.d.ts +15 -0
- package/dist/structures/Announcement.js +23 -0
- package/dist/structures/Base.d.ts +6 -0
- package/dist/structures/Base.js +5 -0
- package/dist/structures/Client.d.ts +57 -0
- package/dist/structures/Client.js +126 -0
- package/dist/structures/Configuration.d.ts +54 -0
- package/dist/structures/Configuration.js +215 -0
- package/dist/structures/Endpoint.d.ts +84 -0
- package/dist/structures/Endpoint.js +163 -0
- package/dist/structures/ExternalEndpoint.d.ts +22 -0
- package/dist/structures/ExternalEndpoint.js +44 -0
- package/dist/structures/Maintenance.d.ts +18 -0
- package/dist/structures/Maintenance.js +31 -0
- package/dist/structures/Security.d.ts +44 -0
- package/dist/structures/Security.js +91 -0
- package/dist/structures/Storage.d.ts +18 -0
- package/dist/structures/Storage.js +31 -0
- package/dist/structures/Tunnel.d.ts +20 -0
- package/dist/structures/Tunnel.js +35 -0
- package/dist/structures/UI.d.ts +34 -0
- package/dist/structures/UI.js +55 -0
- package/dist/structures/Web.d.ts +18 -0
- package/dist/structures/Web.js +31 -0
- package/dist/structures/index.d.ts +13 -0
- package/dist/structures/index.js +13 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.js +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { Alerting } from "./Alerting.js";
|
|
2
|
+
import { Announcement } from "./Announcement.js";
|
|
3
|
+
import { Base } from "./Base.js";
|
|
4
|
+
import { Endpoint } from "./Endpoint.js";
|
|
5
|
+
import { ExternalEndpoint, } from "./ExternalEndpoint.js";
|
|
6
|
+
import { Maintenance } from "./Maintenance.js";
|
|
7
|
+
import { Security } from "./Security.js";
|
|
8
|
+
import { Storage } from "./Storage.js";
|
|
9
|
+
import { Tunnel } from "./Tunnel.js";
|
|
10
|
+
import { UI } from "./UI.js";
|
|
11
|
+
import { Web } from "./Web.js";
|
|
12
|
+
export class Configuration extends Base {
|
|
13
|
+
data;
|
|
14
|
+
constructor(data) {
|
|
15
|
+
super();
|
|
16
|
+
this.data = data;
|
|
17
|
+
}
|
|
18
|
+
metrics(enabled) {
|
|
19
|
+
this.data.metrics = enabled;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
concurrency(concurrency) {
|
|
23
|
+
this.data.concurrency = concurrency;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
skipInvalidConfigUpdate(skip) {
|
|
27
|
+
this.data.skipInvalidConfigUpdate = skip;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
storage(baseOrStorage, storage) {
|
|
31
|
+
let storageInstance;
|
|
32
|
+
if (typeof baseOrStorage === "function") {
|
|
33
|
+
storageInstance = baseOrStorage(new Storage({}));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
storageInstance = new Storage(baseOrStorage);
|
|
37
|
+
if (storage)
|
|
38
|
+
storageInstance = storage(storageInstance);
|
|
39
|
+
}
|
|
40
|
+
this.data.storage = storageInstance;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
web(baseOrWeb, web) {
|
|
44
|
+
let webInstance;
|
|
45
|
+
if (typeof baseOrWeb === "function") {
|
|
46
|
+
webInstance = baseOrWeb(new Web({}));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
webInstance = new Web(baseOrWeb);
|
|
50
|
+
if (web)
|
|
51
|
+
webInstance = web(webInstance);
|
|
52
|
+
}
|
|
53
|
+
this.data.web = webInstance;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
ui(baseOrUi, ui) {
|
|
57
|
+
let uiInstance;
|
|
58
|
+
if (typeof baseOrUi === "function") {
|
|
59
|
+
uiInstance = baseOrUi(new UI({}));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
uiInstance = new UI(baseOrUi);
|
|
63
|
+
if (ui)
|
|
64
|
+
uiInstance = ui(uiInstance);
|
|
65
|
+
}
|
|
66
|
+
this.data.ui = uiInstance;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
security(baseOrSecurity, security) {
|
|
70
|
+
let securityInstance;
|
|
71
|
+
if (typeof baseOrSecurity === "function") {
|
|
72
|
+
securityInstance = baseOrSecurity(new Security({}));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
securityInstance = new Security(baseOrSecurity);
|
|
76
|
+
if (security)
|
|
77
|
+
securityInstance = security(securityInstance);
|
|
78
|
+
}
|
|
79
|
+
this.data.security = securityInstance;
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
alert(baseOrAlert, alert) {
|
|
83
|
+
let alertInstance;
|
|
84
|
+
if (typeof baseOrAlert === "function") {
|
|
85
|
+
alertInstance = baseOrAlert(new Alerting({}));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
alertInstance = new Alerting(baseOrAlert);
|
|
89
|
+
if (alert)
|
|
90
|
+
alertInstance = alert(alertInstance);
|
|
91
|
+
}
|
|
92
|
+
if (!this.data.alerting) {
|
|
93
|
+
this.data.alerting = [];
|
|
94
|
+
}
|
|
95
|
+
this.data.alerting.push(alertInstance);
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
announcement(baseOrAnnouncement, announcement) {
|
|
99
|
+
let announcementInstance;
|
|
100
|
+
if (typeof baseOrAnnouncement === "function") {
|
|
101
|
+
announcementInstance = baseOrAnnouncement(new Announcement({}));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
announcementInstance = new Announcement(baseOrAnnouncement);
|
|
105
|
+
if (announcement)
|
|
106
|
+
announcementInstance = announcement(announcementInstance);
|
|
107
|
+
}
|
|
108
|
+
if (!this.data.announcements) {
|
|
109
|
+
this.data.announcements = [];
|
|
110
|
+
}
|
|
111
|
+
this.data.announcements.push(announcementInstance);
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
maintenance(baseOrMaintenance, maintenance) {
|
|
115
|
+
let maintenanceInstance;
|
|
116
|
+
if (typeof baseOrMaintenance === "function") {
|
|
117
|
+
maintenanceInstance = baseOrMaintenance(new Maintenance({}));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
maintenanceInstance = new Maintenance(baseOrMaintenance);
|
|
121
|
+
if (maintenance)
|
|
122
|
+
maintenanceInstance = maintenance(maintenanceInstance);
|
|
123
|
+
}
|
|
124
|
+
if (!this.data.maintenance) {
|
|
125
|
+
this.data.maintenance = [];
|
|
126
|
+
}
|
|
127
|
+
this.data.maintenance.push(maintenanceInstance);
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
endpoint(baseOrEndpoint, endpoint) {
|
|
131
|
+
let endpointInstance;
|
|
132
|
+
if (typeof baseOrEndpoint === "function") {
|
|
133
|
+
endpointInstance = baseOrEndpoint(new Endpoint({}));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
endpointInstance = new Endpoint(baseOrEndpoint);
|
|
137
|
+
if (endpoint)
|
|
138
|
+
endpointInstance = endpoint(endpointInstance);
|
|
139
|
+
}
|
|
140
|
+
if (!this.data.endpoints) {
|
|
141
|
+
this.data.endpoints = [];
|
|
142
|
+
}
|
|
143
|
+
this.data.endpoints.push(endpointInstance);
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
externalEndpoint(baseOrEndpoint, endpoint) {
|
|
147
|
+
let endpointInstance;
|
|
148
|
+
if (typeof baseOrEndpoint === "function") {
|
|
149
|
+
endpointInstance = baseOrEndpoint(new ExternalEndpoint({}));
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
endpointInstance = new ExternalEndpoint(baseOrEndpoint);
|
|
153
|
+
if (endpoint)
|
|
154
|
+
endpointInstance = endpoint(endpointInstance);
|
|
155
|
+
}
|
|
156
|
+
if (!this.data.externalEndpoints) {
|
|
157
|
+
this.data.externalEndpoints = [];
|
|
158
|
+
}
|
|
159
|
+
this.data.externalEndpoints.push(endpointInstance);
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
tunnel(name, baseOrTunnel, tunnel) {
|
|
163
|
+
let tunnelInstance;
|
|
164
|
+
if (typeof baseOrTunnel === "function") {
|
|
165
|
+
tunnelInstance = baseOrTunnel(new Tunnel({}));
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
tunnelInstance = new Tunnel(baseOrTunnel);
|
|
169
|
+
if (tunnel)
|
|
170
|
+
tunnelInstance = tunnel(tunnelInstance);
|
|
171
|
+
}
|
|
172
|
+
if (!this.data.tunneling) {
|
|
173
|
+
this.data.tunneling = {};
|
|
174
|
+
}
|
|
175
|
+
this.data.tunneling[name] = tunnelInstance;
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
serialize() {
|
|
179
|
+
let output = { ...this.data };
|
|
180
|
+
if (this.data.alerting) {
|
|
181
|
+
output.alerting = this.data.alerting.map((alert) => alert.serialize());
|
|
182
|
+
}
|
|
183
|
+
if (this.data.announcements) {
|
|
184
|
+
output.announcements = this.data.announcements.map((announcement) => announcement.serialize());
|
|
185
|
+
}
|
|
186
|
+
if (this.data.endpoints) {
|
|
187
|
+
output.endpoints = this.data.endpoints.map((endpoint) => endpoint.serialize());
|
|
188
|
+
}
|
|
189
|
+
if (this.data.externalEndpoints) {
|
|
190
|
+
output.externalEndpoints = Object.fromEntries(Object.entries(this.data.externalEndpoints).map(([key, endpoint]) => [key, endpoint.serialize()]));
|
|
191
|
+
}
|
|
192
|
+
if (this.data.maintenance) {
|
|
193
|
+
output.maintenance = this.data.maintenance.map((maintenance) => maintenance.serialize());
|
|
194
|
+
}
|
|
195
|
+
if (this.data.tunneling) {
|
|
196
|
+
output.tunneling = Object.fromEntries(Object.entries(this.data.tunneling).map(([key, tunnel]) => [
|
|
197
|
+
key,
|
|
198
|
+
tunnel.serialize(),
|
|
199
|
+
]));
|
|
200
|
+
}
|
|
201
|
+
if (this.data.security) {
|
|
202
|
+
output.security = this.data.security.serialize();
|
|
203
|
+
}
|
|
204
|
+
if (this.data.storage) {
|
|
205
|
+
output.storage = this.data.storage.serialize();
|
|
206
|
+
}
|
|
207
|
+
if (this.data.web) {
|
|
208
|
+
output.web = this.data.web.serialize();
|
|
209
|
+
}
|
|
210
|
+
if (this.data.ui) {
|
|
211
|
+
output.ui = this.data.ui.serialize();
|
|
212
|
+
}
|
|
213
|
+
return output;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Alerting, AlertingConfiguration } from "./Alerting.js";
|
|
2
|
+
import { Base, Serialize } from "./Base.js";
|
|
3
|
+
import { Client, ClientConfiguration } from "./Client.js";
|
|
4
|
+
import { Maintenance, MaintenanceConfiguration } from "./Maintenance.js";
|
|
5
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
6
|
+
export type DnsRecordType = "A" | "AAAA" | "CNAME" | "MX" | "TXT" | "SRV" | "NS" | "PTR";
|
|
7
|
+
export type Condition = string;
|
|
8
|
+
export type EndpointConfiguration = {
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
name?: string;
|
|
11
|
+
group?: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
method?: HttpMethod;
|
|
14
|
+
conditions?: Condition[];
|
|
15
|
+
interval?: string;
|
|
16
|
+
graphql?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
You may use the following placeholders in the body (endpoints[].body):
|
|
19
|
+
[ENDPOINT_NAME] (resolved from endpoints[].name)
|
|
20
|
+
[ENDPOINT_GROUP] (resolved from endpoints[].group)
|
|
21
|
+
[ENDPOINT_URL] (resolved from endpoints[].url)
|
|
22
|
+
[LOCAL_ADDRESS] (resolves to the local IP and port like 192.0.2.1:25 or [2001:db8::1]:80)
|
|
23
|
+
[RANDOM_STRING_N] (resolves to a random string of numbers and letters of length N (max: 8192))
|
|
24
|
+
*/
|
|
25
|
+
body?: string;
|
|
26
|
+
headers?: Record<string, string>;
|
|
27
|
+
dns?: {
|
|
28
|
+
queryName: string;
|
|
29
|
+
queryType: DnsRecordType;
|
|
30
|
+
};
|
|
31
|
+
ssh?: {
|
|
32
|
+
username: string;
|
|
33
|
+
password: string;
|
|
34
|
+
};
|
|
35
|
+
alerts?: Alerting[];
|
|
36
|
+
maintenanceWindows?: Maintenance[];
|
|
37
|
+
client?: Client;
|
|
38
|
+
ui?: {
|
|
39
|
+
hideConditions?: boolean;
|
|
40
|
+
hideHostname?: boolean;
|
|
41
|
+
hidePort?: boolean;
|
|
42
|
+
hideUrl?: boolean;
|
|
43
|
+
hideErrors?: boolean;
|
|
44
|
+
dontResolveFailedConditions?: boolean;
|
|
45
|
+
badge?: {
|
|
46
|
+
responseTime?: number[];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
extraLabels?: Record<string, string>;
|
|
50
|
+
};
|
|
51
|
+
export declare class EndpointUI extends Base implements Serialize {
|
|
52
|
+
data: NonNullable<EndpointConfiguration["ui"]>;
|
|
53
|
+
constructor(data: NonNullable<EndpointConfiguration["ui"]>);
|
|
54
|
+
hideConditions(hide: boolean): this;
|
|
55
|
+
hideHostname(hide: boolean): this;
|
|
56
|
+
hidePort(hide: boolean): this;
|
|
57
|
+
hideUrl(hide: boolean): this;
|
|
58
|
+
hideErrors(hide: boolean): this;
|
|
59
|
+
dontResolveFailedConditions(dontResolve: boolean): this;
|
|
60
|
+
badgeResponseTime(thresholds: number[]): this;
|
|
61
|
+
serialize(): Record<string, any>;
|
|
62
|
+
}
|
|
63
|
+
export declare class Endpoint extends Base implements Serialize {
|
|
64
|
+
data: EndpointConfiguration;
|
|
65
|
+
constructor(data: EndpointConfiguration);
|
|
66
|
+
name(name: string): this;
|
|
67
|
+
enabled(enabled: boolean): this;
|
|
68
|
+
group(group: string): this;
|
|
69
|
+
url(url: string): this;
|
|
70
|
+
method(method: HttpMethod): this;
|
|
71
|
+
addCondition(condition: Condition): this;
|
|
72
|
+
interval(interval: string): this;
|
|
73
|
+
graphql(enabled: boolean): this;
|
|
74
|
+
body(body: string): this;
|
|
75
|
+
header(key: string, value: string): this;
|
|
76
|
+
dns(queryName: string, queryType: DnsRecordType): this;
|
|
77
|
+
ssh(username: string, password: string): this;
|
|
78
|
+
alert(base: AlertingConfiguration, cb?: (alert: Alerting) => Alerting): this;
|
|
79
|
+
maintenance(base: MaintenanceConfiguration, cb?: (maintenance: Maintenance) => Maintenance): this;
|
|
80
|
+
client(base: ClientConfiguration, cb?: (client: Client) => Client): this;
|
|
81
|
+
ui(base: NonNullable<EndpointConfiguration["ui"]>, cb?: (ui: EndpointUI) => EndpointUI): this;
|
|
82
|
+
extraLabel(key: string, value: string): this;
|
|
83
|
+
serialize(): Record<string, any>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Alerting } from "./Alerting.js";
|
|
2
|
+
import { Base } from "./Base.js";
|
|
3
|
+
import { Client } from "./Client.js";
|
|
4
|
+
import { Maintenance } from "./Maintenance.js";
|
|
5
|
+
export class EndpointUI extends Base {
|
|
6
|
+
data;
|
|
7
|
+
constructor(data) {
|
|
8
|
+
super();
|
|
9
|
+
this.data = data;
|
|
10
|
+
}
|
|
11
|
+
hideConditions(hide) {
|
|
12
|
+
this.data.hideConditions = hide;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
hideHostname(hide) {
|
|
16
|
+
this.data.hideHostname = hide;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
hidePort(hide) {
|
|
20
|
+
this.data.hidePort = hide;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
hideUrl(hide) {
|
|
24
|
+
this.data.hideUrl = hide;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
hideErrors(hide) {
|
|
28
|
+
this.data.hideErrors = hide;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
dontResolveFailedConditions(dontResolve) {
|
|
32
|
+
this.data.dontResolveFailedConditions = dontResolve;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
badgeResponseTime(thresholds) {
|
|
36
|
+
if (!this.data.badge) {
|
|
37
|
+
this.data.badge = {};
|
|
38
|
+
}
|
|
39
|
+
this.data.badge.responseTime = thresholds;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
serialize() {
|
|
43
|
+
return this.data;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export class Endpoint extends Base {
|
|
47
|
+
data;
|
|
48
|
+
constructor(data) {
|
|
49
|
+
super();
|
|
50
|
+
this.data = data;
|
|
51
|
+
}
|
|
52
|
+
name(name) {
|
|
53
|
+
this.data.name = name;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
enabled(enabled) {
|
|
57
|
+
this.data.enabled = enabled;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
group(group) {
|
|
61
|
+
this.data.group = group;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
url(url) {
|
|
65
|
+
this.data.url = url;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
method(method) {
|
|
69
|
+
this.data.method = method;
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
addCondition(condition) {
|
|
73
|
+
if (!this.data.conditions) {
|
|
74
|
+
this.data.conditions = [];
|
|
75
|
+
}
|
|
76
|
+
this.data.conditions.push(condition);
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
interval(interval) {
|
|
80
|
+
this.data.interval = interval;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
graphql(enabled) {
|
|
84
|
+
this.data.graphql = enabled;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
body(body) {
|
|
88
|
+
this.data.body = body;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
header(key, value) {
|
|
92
|
+
if (!this.data.headers) {
|
|
93
|
+
this.data.headers = {};
|
|
94
|
+
}
|
|
95
|
+
this.data.headers[key] = value;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
dns(queryName, queryType) {
|
|
99
|
+
this.data.dns = { queryName, queryType };
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
ssh(username, password) {
|
|
103
|
+
this.data.ssh = { username, password };
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
alert(base, cb) {
|
|
107
|
+
if (!this.data.alerts) {
|
|
108
|
+
this.data.alerts = [];
|
|
109
|
+
}
|
|
110
|
+
let alertInstance = new Alerting(base);
|
|
111
|
+
if (cb)
|
|
112
|
+
alertInstance = cb(alertInstance);
|
|
113
|
+
this.data.alerts.push(alertInstance);
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
maintenance(base, cb) {
|
|
117
|
+
if (!this.data.maintenanceWindows) {
|
|
118
|
+
this.data.maintenanceWindows = [];
|
|
119
|
+
}
|
|
120
|
+
let maintenanceInstance = new Maintenance(base);
|
|
121
|
+
if (cb)
|
|
122
|
+
maintenanceInstance = cb(maintenanceInstance);
|
|
123
|
+
this.data.maintenanceWindows.push(maintenanceInstance);
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
client(base, cb) {
|
|
127
|
+
let clientInstance = new Client(base);
|
|
128
|
+
if (cb)
|
|
129
|
+
clientInstance = cb(clientInstance);
|
|
130
|
+
this.data.client = clientInstance;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
ui(base, cb) {
|
|
134
|
+
let uiInstance = new EndpointUI(base);
|
|
135
|
+
if (cb)
|
|
136
|
+
uiInstance = cb(uiInstance);
|
|
137
|
+
this.data.ui = uiInstance.data;
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
extraLabel(key, value) {
|
|
141
|
+
if (!this.data.extraLabels) {
|
|
142
|
+
this.data.extraLabels = {};
|
|
143
|
+
}
|
|
144
|
+
this.data.extraLabels[key] = value;
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
serialize() {
|
|
148
|
+
let output = { ...this.data };
|
|
149
|
+
if (this.data.alerts) {
|
|
150
|
+
output.alerts = this.data.alerts?.map((alert) => alert.serialize());
|
|
151
|
+
}
|
|
152
|
+
if (this.data.maintenanceWindows) {
|
|
153
|
+
output.maintenanceWindows = this.data.maintenanceWindows.map((m) => m.serialize());
|
|
154
|
+
}
|
|
155
|
+
if (this.data.client) {
|
|
156
|
+
output.client = this.data.client.serialize();
|
|
157
|
+
}
|
|
158
|
+
if (this.data.ui) {
|
|
159
|
+
output.ui = this.data.ui;
|
|
160
|
+
}
|
|
161
|
+
return output;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Alerting, AlertingConfiguration } from "./Alerting.js";
|
|
2
|
+
import { Base, Serialize } from "./Base.js";
|
|
3
|
+
export type ExternalEndpointConfiguration = {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
name?: string;
|
|
6
|
+
group?: string;
|
|
7
|
+
token?: string;
|
|
8
|
+
alerts?: Alerting[];
|
|
9
|
+
heartbeat?: {
|
|
10
|
+
interval?: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare class ExternalEndpoint extends Base implements Serialize {
|
|
14
|
+
data: ExternalEndpointConfiguration;
|
|
15
|
+
constructor(data: ExternalEndpointConfiguration);
|
|
16
|
+
enabled(enabled: boolean): this;
|
|
17
|
+
group(group: string): this;
|
|
18
|
+
token(token: string): this;
|
|
19
|
+
heartbeatInterval(interval: string): this;
|
|
20
|
+
alert(base: AlertingConfiguration, alert?: (alert: Alerting) => Alerting): this;
|
|
21
|
+
serialize(): Record<string, any>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Alerting } from "./Alerting.js";
|
|
2
|
+
import { Base } from "./Base.js";
|
|
3
|
+
export class ExternalEndpoint extends Base {
|
|
4
|
+
data;
|
|
5
|
+
constructor(data) {
|
|
6
|
+
super();
|
|
7
|
+
this.data = data;
|
|
8
|
+
}
|
|
9
|
+
enabled(enabled) {
|
|
10
|
+
this.data.enabled = enabled;
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
group(group) {
|
|
14
|
+
this.data.group = group;
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
token(token) {
|
|
18
|
+
this.data.token = token;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
heartbeatInterval(interval) {
|
|
22
|
+
if (!this.data.heartbeat) {
|
|
23
|
+
this.data.heartbeat = {};
|
|
24
|
+
}
|
|
25
|
+
this.data.heartbeat.interval = interval;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
alert(base, alert) {
|
|
29
|
+
if (!this.data.alerts) {
|
|
30
|
+
this.data.alerts = [];
|
|
31
|
+
}
|
|
32
|
+
let alertInstance = new Alerting(base);
|
|
33
|
+
if (alert)
|
|
34
|
+
alertInstance = alert(alertInstance);
|
|
35
|
+
this.data.alerts.push(alertInstance);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
serialize() {
|
|
39
|
+
return {
|
|
40
|
+
...this.data,
|
|
41
|
+
alerts: this.data.alerts?.map((alert) => alert.serialize()),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Base, Serialize } from "./Base.js";
|
|
2
|
+
export type MaintenanceConfiguration = {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
start?: string;
|
|
5
|
+
duration?: string;
|
|
6
|
+
timezone?: string;
|
|
7
|
+
every?: string[];
|
|
8
|
+
};
|
|
9
|
+
export declare class Maintenance extends Base implements Serialize {
|
|
10
|
+
data: MaintenanceConfiguration;
|
|
11
|
+
constructor(data: MaintenanceConfiguration);
|
|
12
|
+
enabled(enabled: boolean): this;
|
|
13
|
+
start(start: string): this;
|
|
14
|
+
duration(duration: string): this;
|
|
15
|
+
timezone(timezone: string): this;
|
|
16
|
+
every(every: string[]): this;
|
|
17
|
+
serialize(): Record<string, any>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Base } from "./Base.js";
|
|
2
|
+
export class Maintenance extends Base {
|
|
3
|
+
data;
|
|
4
|
+
constructor(data) {
|
|
5
|
+
super();
|
|
6
|
+
this.data = data;
|
|
7
|
+
}
|
|
8
|
+
enabled(enabled) {
|
|
9
|
+
this.data.enabled = enabled;
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
start(start) {
|
|
13
|
+
this.data.start = start;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
duration(duration) {
|
|
17
|
+
this.data.duration = duration;
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
timezone(timezone) {
|
|
21
|
+
this.data.timezone = timezone;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
every(every) {
|
|
25
|
+
this.data.every = every;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
serialize() {
|
|
29
|
+
return this.data;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Base, Serialize } from "./Base.js";
|
|
2
|
+
export type SecurityConfiguration = {
|
|
3
|
+
basic?: {
|
|
4
|
+
username?: string;
|
|
5
|
+
passwordBcryptBase64?: string;
|
|
6
|
+
};
|
|
7
|
+
oidc?: {
|
|
8
|
+
issuerUrl?: string;
|
|
9
|
+
redirectUrl?: string;
|
|
10
|
+
clientId?: string;
|
|
11
|
+
clientSecret?: string;
|
|
12
|
+
scopes?: string[];
|
|
13
|
+
allowedSubjects?: string[];
|
|
14
|
+
sessionTtl?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare class BasicSecurity extends Base implements Serialize {
|
|
18
|
+
data: NonNullable<SecurityConfiguration["basic"]>;
|
|
19
|
+
constructor(data: NonNullable<SecurityConfiguration["basic"]>);
|
|
20
|
+
username(username: string): this;
|
|
21
|
+
passwordBcryptBase64(password: string): this;
|
|
22
|
+
serialize(): Record<string, any>;
|
|
23
|
+
}
|
|
24
|
+
export declare class OidcSecurity extends Base implements Serialize {
|
|
25
|
+
data: NonNullable<SecurityConfiguration["oidc"]>;
|
|
26
|
+
constructor(data: NonNullable<SecurityConfiguration["oidc"]>);
|
|
27
|
+
issuerUrl(url: string): this;
|
|
28
|
+
redirectUrl(url: string): this;
|
|
29
|
+
clientId(id: string): this;
|
|
30
|
+
clientSecret(secret: string): this;
|
|
31
|
+
scopes(scopes: string[]): this;
|
|
32
|
+
allowedSubjects(subjects: string[]): this;
|
|
33
|
+
sessionTtl(ttl: string): this;
|
|
34
|
+
serialize(): Record<string, any>;
|
|
35
|
+
}
|
|
36
|
+
export declare class Security extends Base implements Serialize {
|
|
37
|
+
data: SecurityConfiguration;
|
|
38
|
+
constructor(data: SecurityConfiguration);
|
|
39
|
+
basic(base: NonNullable<SecurityConfiguration["basic"]>, cb: (basic: BasicSecurity) => BasicSecurity): this;
|
|
40
|
+
basic(cb: (basic: BasicSecurity) => BasicSecurity): this;
|
|
41
|
+
oidc(base: NonNullable<SecurityConfiguration["oidc"]>, cb: (oidc: OidcSecurity) => OidcSecurity): this;
|
|
42
|
+
oidc(cb: (oidc: OidcSecurity) => OidcSecurity): this;
|
|
43
|
+
serialize(): Record<string, any>;
|
|
44
|
+
}
|