@muspellheim/shared 0.6.1 → 0.8.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.txt +1 -1
- package/README.md +11 -13
- package/dist/shared.d.ts +423 -0
- package/dist/shared.js +535 -0
- package/dist/shared.umd.cjs +1 -0
- package/package.json +27 -23
- package/.prettierignore +0 -3
- package/.prettierrc +0 -5
- package/deno.json +0 -15
- package/deno.mk +0 -68
- package/eslint.config.js +0 -23
- package/lib/assert.js +0 -15
- package/lib/browser/components.js +0 -165
- package/lib/browser/index.js +0 -3
- package/lib/color.js +0 -137
- package/lib/configurable-responses.js +0 -69
- package/lib/feature-toggle.js +0 -9
- package/lib/health.js +0 -510
- package/lib/index.js +0 -23
- package/lib/lang.js +0 -100
- package/lib/logging.js +0 -599
- package/lib/long-polling-client.js +0 -186
- package/lib/message-client.js +0 -68
- package/lib/messages.js +0 -68
- package/lib/metrics.js +0 -120
- package/lib/node/actuator-controller.js +0 -102
- package/lib/node/configuration-properties.js +0 -291
- package/lib/node/handler.js +0 -25
- package/lib/node/index.js +0 -9
- package/lib/node/logging.js +0 -60
- package/lib/node/long-polling.js +0 -83
- package/lib/node/sse-emitter.js +0 -104
- package/lib/node/static-files-controller.js +0 -15
- package/lib/output-tracker.js +0 -89
- package/lib/service-locator.js +0 -44
- package/lib/sse-client.js +0 -163
- package/lib/stop-watch.js +0 -54
- package/lib/store.js +0 -129
- package/lib/time.js +0 -445
- package/lib/util.js +0 -380
- package/lib/validation.js +0 -290
- package/lib/vector.js +0 -194
- package/lib/vitest/equality-testers.js +0 -19
- package/lib/vitest/index.js +0 -1
- package/lib/web-socket-client.js +0 -262
- package/tsconfig.json +0 -13
package/lib/health.js
DELETED
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-2024 Falko Schumann. All rights reserved. MIT license.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Actuator health indicator and endpoints.
|
|
5
|
-
*
|
|
6
|
-
* Portated from
|
|
7
|
-
* [Spring Boot's health package](https://docs.spring.io/spring-boot/api/java/org/springframework/boot/actuate/health/package-summary.html).
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { assertNotNull } from './assert.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Express state of a component.
|
|
16
|
-
*/
|
|
17
|
-
export class Status {
|
|
18
|
-
/**
|
|
19
|
-
* Indicates the component is in an unknown state.
|
|
20
|
-
*
|
|
21
|
-
* @type {Status}
|
|
22
|
-
*/
|
|
23
|
-
static UNKNOWN = new Status('UNKNOWN');
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Indicates the component is functioning as expected
|
|
27
|
-
*
|
|
28
|
-
* @type {Status}
|
|
29
|
-
*/
|
|
30
|
-
static UP = new Status('UP');
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Indicates the component has suffered an unexpected failure.
|
|
34
|
-
*
|
|
35
|
-
* @type {Status}
|
|
36
|
-
*/
|
|
37
|
-
static DOWN = new Status('DOWN');
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Indicates the component has been taken out of service and should not be used.
|
|
41
|
-
*
|
|
42
|
-
* @type {Status}
|
|
43
|
-
*/
|
|
44
|
-
static OUT_OF_SERVICE = new Status('OUT_OF_SERVICE');
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Creates a new status.
|
|
48
|
-
*
|
|
49
|
-
* @param {string} code The status code.
|
|
50
|
-
*/
|
|
51
|
-
constructor(code) {
|
|
52
|
-
assertNotNull(code, 'Code must not be null.');
|
|
53
|
-
this.code = code;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Returns a string representation of the status.
|
|
58
|
-
*
|
|
59
|
-
* @return {string} The status code.
|
|
60
|
-
*/
|
|
61
|
-
toString() {
|
|
62
|
-
return this.code;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Returns the value of the status.
|
|
67
|
-
*
|
|
68
|
-
* @return {string} The status code.
|
|
69
|
-
*/
|
|
70
|
-
valueOf() {
|
|
71
|
-
return this.code;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Returns the status code.
|
|
76
|
-
*
|
|
77
|
-
* @return {string} The status code.
|
|
78
|
-
*/
|
|
79
|
-
toJSON() {
|
|
80
|
-
return this.code;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Carry information about the health of a component.
|
|
86
|
-
*/
|
|
87
|
-
export class Health {
|
|
88
|
-
/**
|
|
89
|
-
* Creates a new health object with status {@link Status.UNKNOWN}.
|
|
90
|
-
*
|
|
91
|
-
* @param {object} options The health options.
|
|
92
|
-
* @param {Record<string, *>} [options.details] The details of the health.
|
|
93
|
-
*/
|
|
94
|
-
static unknown({ details } = {}) {
|
|
95
|
-
return Health.status({ status: Status.UNKNOWN, details });
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Creates a new health object with status {@link Status.UP}.
|
|
100
|
-
*
|
|
101
|
-
* @param {object} options The health options.
|
|
102
|
-
* @param {Record<string, *>} [options.details] The details of the health.
|
|
103
|
-
*/
|
|
104
|
-
static up({ details } = {}) {
|
|
105
|
-
return Health.status({ status: Status.UP, details });
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Creates a new health object with status {@link Status.DOWN}.
|
|
110
|
-
*
|
|
111
|
-
* @param {object} options The health options.
|
|
112
|
-
* @param {Record<string, *>} [options.details] The details of the health.
|
|
113
|
-
* @param {Error} [options.error] The error of the health.
|
|
114
|
-
*/
|
|
115
|
-
static down({ details, error } = {}) {
|
|
116
|
-
return Health.status({ status: Status.DOWN, details, error });
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Creates a new health object with status {@link Status.OUT_OF_SERVICE}.
|
|
121
|
-
*
|
|
122
|
-
* @param {object} options The health options.
|
|
123
|
-
* @param {Record<string, *>} [options.details] The details of the health.
|
|
124
|
-
*/
|
|
125
|
-
static outOfService({ details } = {}) {
|
|
126
|
-
return Health.status({ status: Status.OUT_OF_SERVICE, details });
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Creates a new health object.
|
|
131
|
-
*
|
|
132
|
-
* @param {object} options The health options.
|
|
133
|
-
* @param {Status} options.status The status of the health.
|
|
134
|
-
* @param {Record<string, *>} [options.details] The details of the health.
|
|
135
|
-
* @param {Error} [options.error] The error of the health.
|
|
136
|
-
*/
|
|
137
|
-
static status({ status = Status.UNKNOWN, details, error } = {}) {
|
|
138
|
-
if (error) {
|
|
139
|
-
details = { ...details, error: `${error.name}: ${error.message}` };
|
|
140
|
-
}
|
|
141
|
-
return new Health(status, details);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* The status of the health.
|
|
146
|
-
*
|
|
147
|
-
* @type {Status}
|
|
148
|
-
*/
|
|
149
|
-
status;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* The details of the health.
|
|
153
|
-
*
|
|
154
|
-
* @type {?Record<string, *>}
|
|
155
|
-
*/
|
|
156
|
-
details;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Creates a new health object.
|
|
160
|
-
*
|
|
161
|
-
* @param {Status} status The status of the health.
|
|
162
|
-
* @param {Record<string, *>} details The details of the health.
|
|
163
|
-
*/
|
|
164
|
-
constructor(status, details) {
|
|
165
|
-
assertNotNull(status, 'Status must not be null.');
|
|
166
|
-
// TODO assertNotNull(details, 'Details must not be null.');
|
|
167
|
-
|
|
168
|
-
this.status = status;
|
|
169
|
-
this.details = details;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* A {@link Health} that is composed of other {@link Health} instances.
|
|
175
|
-
*/
|
|
176
|
-
export class CompositeHealth {
|
|
177
|
-
/**
|
|
178
|
-
* The status of the component.
|
|
179
|
-
*
|
|
180
|
-
* @type {Status}
|
|
181
|
-
*/
|
|
182
|
-
status;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The components of the health.
|
|
186
|
-
*
|
|
187
|
-
* @type {?Record<string, Health|CompositeHealth>}
|
|
188
|
-
*/
|
|
189
|
-
components;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Creates a new composite health object.
|
|
193
|
-
*
|
|
194
|
-
* @param {Status} status The combined status of the components.
|
|
195
|
-
* @param {Record<string, Health|CompositeHealth>} [components] The components.
|
|
196
|
-
*/
|
|
197
|
-
constructor(
|
|
198
|
-
/** @type {Status} */ status,
|
|
199
|
-
/** @type {?Record<string, Health|CompositeHealth>} */ components,
|
|
200
|
-
) {
|
|
201
|
-
assertNotNull(status, 'Status must not be null.');
|
|
202
|
-
|
|
203
|
-
this.status = status;
|
|
204
|
-
this.components = components;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Strategy interface used to contribute {@link Health} to the results returned
|
|
210
|
-
* from the {@link HealthEndpoint}.
|
|
211
|
-
*
|
|
212
|
-
* @typedef {object} HealthIndicator
|
|
213
|
-
* @property {function(): Health} health Returns the health of the component.
|
|
214
|
-
*/
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* A named {@link HealthIndicator}.
|
|
218
|
-
*
|
|
219
|
-
* @typedef {object} NamedContributor
|
|
220
|
-
* @property {string} name The name of the contributor.
|
|
221
|
-
* @property {HealthIndicator} contributor The contributor.
|
|
222
|
-
*/
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* A registry of {@link HealthIndicator} instances.
|
|
226
|
-
*/
|
|
227
|
-
export class HealthContributorRegistry {
|
|
228
|
-
static #instance = new HealthContributorRegistry();
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Returns the default registry.
|
|
232
|
-
*
|
|
233
|
-
* @return {HealthContributorRegistry} The default registry.
|
|
234
|
-
*/
|
|
235
|
-
static getDefault() {
|
|
236
|
-
return HealthContributorRegistry.#instance;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
#contributors;
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Creates a new registry.
|
|
243
|
-
*
|
|
244
|
-
* @param {Map<string, HealthIndicator>} [contributors] The initial
|
|
245
|
-
* contributors.
|
|
246
|
-
*/
|
|
247
|
-
constructor(contributors) {
|
|
248
|
-
this.#contributors = contributors ?? new Map();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Registers a contributor.
|
|
253
|
-
*
|
|
254
|
-
* @param {string} name The name of the contributor.
|
|
255
|
-
* @param {HealthIndicator} contributor The contributor.
|
|
256
|
-
*/
|
|
257
|
-
registerContributor(name, contributor) {
|
|
258
|
-
this.#contributors.set(name, contributor);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Unregisters a contributor.
|
|
263
|
-
*
|
|
264
|
-
* @param {string} name The name of the contributor.
|
|
265
|
-
*/
|
|
266
|
-
unregisterContributor(name) {
|
|
267
|
-
this.#contributors.delete(name);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Returns a contributor by name.
|
|
272
|
-
*
|
|
273
|
-
* @param {string} name The name of the contributor.
|
|
274
|
-
* @return {HealthIndicator} The contributorm or `undefined` if not found.
|
|
275
|
-
*/
|
|
276
|
-
getContributor(name) {
|
|
277
|
-
return this.#contributors.get(name);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Returns an iterator over the named contributors.
|
|
282
|
-
*
|
|
283
|
-
* @return {IterableIterator<NamedContributor>} The iterator.
|
|
284
|
-
*/
|
|
285
|
-
*[Symbol.iterator]() {
|
|
286
|
-
for (const [name, contributor] of this.#contributors) {
|
|
287
|
-
yield { name, contributor };
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Strategy interface used to aggregate multiple {@link Status} instances into a
|
|
294
|
-
* single one.
|
|
295
|
-
*/
|
|
296
|
-
export class StatusAggregator {
|
|
297
|
-
/**
|
|
298
|
-
* Returns the default status aggregator.
|
|
299
|
-
*
|
|
300
|
-
* @return {StatusAggregator} The default status aggregator.
|
|
301
|
-
*/
|
|
302
|
-
static getDefault() {
|
|
303
|
-
return SimpleStatusAggregator.INSTANCE;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Returns the aggregate status of the given statuses.
|
|
308
|
-
*
|
|
309
|
-
* @param {Status[]} statuses The statuses to aggregate.
|
|
310
|
-
* @return {Status} The aggregate status.
|
|
311
|
-
* @abstract
|
|
312
|
-
*/
|
|
313
|
-
getAggregateStatus(_statuses) {
|
|
314
|
-
throw new Error('Method not implemented.');
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* A simple {@link StatusAggregator} that uses a predefined order to determine
|
|
320
|
-
* the aggregate status.
|
|
321
|
-
*
|
|
322
|
-
* @extends StatusAggregator
|
|
323
|
-
*/
|
|
324
|
-
export class SimpleStatusAggregator extends StatusAggregator {
|
|
325
|
-
static #DEFAULT_ORDER = [
|
|
326
|
-
Status.DOWN,
|
|
327
|
-
Status.OUT_OF_SERVICE,
|
|
328
|
-
Status.UP,
|
|
329
|
-
Status.UNKNOWN,
|
|
330
|
-
];
|
|
331
|
-
|
|
332
|
-
static INSTANCE = new SimpleStatusAggregator();
|
|
333
|
-
|
|
334
|
-
#order;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Creates a new aggregator.
|
|
338
|
-
*
|
|
339
|
-
* @param {Status[]} order The order of the statuses.
|
|
340
|
-
*/
|
|
341
|
-
constructor(order = SimpleStatusAggregator.#DEFAULT_ORDER) {
|
|
342
|
-
super();
|
|
343
|
-
this.#order = order;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/** @override */
|
|
347
|
-
getAggregateStatus(statuses) {
|
|
348
|
-
if (statuses.length === 0) {
|
|
349
|
-
return Status.UNKNOWN;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
statuses.sort((a, b) => this.#order.indexOf(a) - this.#order.indexOf(b));
|
|
353
|
-
return statuses[0];
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Strategy interface used to map {@link Status} instances to HTTP status codes.
|
|
359
|
-
*/
|
|
360
|
-
export class HttpCodeStatusMapper {
|
|
361
|
-
/**
|
|
362
|
-
* Returns the default HTTP code status mapper.
|
|
363
|
-
*
|
|
364
|
-
* @return {HttpCodeStatusMapper} The default HTTP code status mapper.
|
|
365
|
-
*/
|
|
366
|
-
static getDefault() {
|
|
367
|
-
return SimpleHttpCodeStatusMapper.INSTANCE;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Returns the HTTP status code for the given status.
|
|
372
|
-
*
|
|
373
|
-
* @param {Status} status The status.
|
|
374
|
-
* @return {number} The HTTP status code.
|
|
375
|
-
* @abstract
|
|
376
|
-
*/
|
|
377
|
-
getStatusCode(_status) {
|
|
378
|
-
throw new Error('Method not implemented.');
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* A simple {@link HttpCodeStatusMapper} that uses a predefined mapping to
|
|
384
|
-
* determine the HTTP status code.
|
|
385
|
-
*
|
|
386
|
-
* @extends HttpCodeStatusMapper
|
|
387
|
-
*/
|
|
388
|
-
export class SimpleHttpCodeStatusMapper extends HttpCodeStatusMapper {
|
|
389
|
-
static #DEFAULT_MAPPING = new Map([
|
|
390
|
-
[Status.DOWN, 503],
|
|
391
|
-
[Status.OUT_OF_SERVICE, 503],
|
|
392
|
-
]);
|
|
393
|
-
|
|
394
|
-
static INSTANCE = new SimpleHttpCodeStatusMapper();
|
|
395
|
-
|
|
396
|
-
#mappings;
|
|
397
|
-
|
|
398
|
-
constructor(mappings = SimpleHttpCodeStatusMapper.#DEFAULT_MAPPING) {
|
|
399
|
-
super();
|
|
400
|
-
this.#mappings = mappings;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/** @override */
|
|
404
|
-
getStatusCode(/** @type {Status} */ status) {
|
|
405
|
-
return this.#mappings.get(status) ?? 200;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* A logical grouping of health contributors that can be exposed by the
|
|
411
|
-
* {@link HealthEndpoint}.
|
|
412
|
-
*
|
|
413
|
-
* @typedef {object} HealthEndpointGroup
|
|
414
|
-
* @property {StatusAggregator} statusAggregator The status aggregator.
|
|
415
|
-
* @property {HttpCodeStatusMapper} httpCodeStatusMapper The HTTP code status
|
|
416
|
-
* mapper.
|
|
417
|
-
*/
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* A collection of groups for use with a health endpoint.
|
|
421
|
-
*
|
|
422
|
-
* @typedef {object} HealthEndpointGroups
|
|
423
|
-
* @property {HealthEndpointGroup} primary The primary group.
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Returned by an operation to provide addtional, web-specific information such
|
|
428
|
-
* as the HTTP status code.
|
|
429
|
-
*
|
|
430
|
-
* @typedef {object} EndpointResponse
|
|
431
|
-
* @property {number} status The HTTP status code.
|
|
432
|
-
* @property {Health | CompositeHealth} body The response body.
|
|
433
|
-
*/
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* A health endpoint that provides information about the health of the
|
|
437
|
-
* application.
|
|
438
|
-
*/
|
|
439
|
-
export class HealthEndpoint {
|
|
440
|
-
static ID = 'health';
|
|
441
|
-
|
|
442
|
-
static #INSTANCE = new HealthEndpoint(
|
|
443
|
-
HealthContributorRegistry.getDefault(),
|
|
444
|
-
{
|
|
445
|
-
primary: {
|
|
446
|
-
statusAggregator: StatusAggregator.getDefault(),
|
|
447
|
-
httpCodeStatusMapper: HttpCodeStatusMapper.getDefault(),
|
|
448
|
-
},
|
|
449
|
-
},
|
|
450
|
-
);
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Returns the default health endpoint.
|
|
454
|
-
*
|
|
455
|
-
* @return {HealthEndpoint} The default health endpoint.
|
|
456
|
-
*/
|
|
457
|
-
static getDefault() {
|
|
458
|
-
return HealthEndpoint.#INSTANCE;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
#registry;
|
|
462
|
-
#groups;
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Creates a new health endpoint.
|
|
466
|
-
*
|
|
467
|
-
* @param {HealthContributorRegistry} registry The health contributor
|
|
468
|
-
* registry.
|
|
469
|
-
* @param {HealthEndpointGroups} groups The health groups.
|
|
470
|
-
*/
|
|
471
|
-
constructor(/** @type {HealthContributorRegistry} */ registry, groups) {
|
|
472
|
-
assertNotNull(registry, 'Registry must not be null.');
|
|
473
|
-
assertNotNull(groups, 'Groups must not be null.');
|
|
474
|
-
this.#registry = registry;
|
|
475
|
-
this.#groups = groups;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Returns the health of the application.
|
|
480
|
-
*
|
|
481
|
-
* @return {EndpointResponse} The health response.
|
|
482
|
-
*/
|
|
483
|
-
health() {
|
|
484
|
-
const result = this.#getHealth();
|
|
485
|
-
const health = result.health;
|
|
486
|
-
const status = result.group.httpCodeStatusMapper.getStatusCode(
|
|
487
|
-
health.status,
|
|
488
|
-
);
|
|
489
|
-
return { status, body: health };
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
#getHealth() {
|
|
493
|
-
const statuses = [];
|
|
494
|
-
const components = {};
|
|
495
|
-
for (const { name, contributor } of this.#registry) {
|
|
496
|
-
components[name] = contributor.health();
|
|
497
|
-
statuses.push(components[name].status);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
let health;
|
|
501
|
-
if (statuses.length > 0) {
|
|
502
|
-
const status =
|
|
503
|
-
this.#groups.primary.statusAggregator.getAggregateStatus(statuses);
|
|
504
|
-
health = new CompositeHealth(status, components);
|
|
505
|
-
} else {
|
|
506
|
-
health = Health.up();
|
|
507
|
-
}
|
|
508
|
-
return { health, group: this.#groups.primary };
|
|
509
|
-
}
|
|
510
|
-
}
|
package/lib/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-2024 Falko Schumann. All rights reserved. MIT license.
|
|
2
|
-
|
|
3
|
-
export * from './assert.js';
|
|
4
|
-
export * from './color.js';
|
|
5
|
-
export * from './configurable-responses.js';
|
|
6
|
-
export * from './feature-toggle.js';
|
|
7
|
-
export * from './health.js';
|
|
8
|
-
export * from './lang.js';
|
|
9
|
-
export * from './logging.js';
|
|
10
|
-
export * from './long-polling-client.js';
|
|
11
|
-
export * from './message-client.js';
|
|
12
|
-
export * from './messages.js';
|
|
13
|
-
export * from './metrics.js';
|
|
14
|
-
export * from './output-tracker.js';
|
|
15
|
-
export * from './service-locator.js';
|
|
16
|
-
export * from './sse-client.js';
|
|
17
|
-
export * from './stop-watch.js';
|
|
18
|
-
export * from './store.js';
|
|
19
|
-
export * from './time.js';
|
|
20
|
-
export * from './util.js';
|
|
21
|
-
export * from './validation.js';
|
|
22
|
-
export * from './vector.js';
|
|
23
|
-
export * from './web-socket-client.js';
|
package/lib/lang.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-2024 Falko Schumann. All rights reserved. MIT license.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Contains missing language features.
|
|
5
|
-
*
|
|
6
|
-
* Portated from
|
|
7
|
-
* [Java Lang](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/package-summary.html).
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { ensureArguments } from './validation.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* This is a base class for creating enum objects.
|
|
16
|
-
*
|
|
17
|
-
* Example:
|
|
18
|
-
*
|
|
19
|
-
* ```js
|
|
20
|
-
* class YesNo extends Enum {
|
|
21
|
-
* static YES = new YesNo('YES', 0);
|
|
22
|
-
* static NO = new YesNo('NO', 1);
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export class Enum {
|
|
27
|
-
/**
|
|
28
|
-
* Returns all enum constants.
|
|
29
|
-
*
|
|
30
|
-
* @return {Enum[]} All enum constants.
|
|
31
|
-
*/
|
|
32
|
-
static values() {
|
|
33
|
-
return Object.values(this);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Returns an enum constant by its name.
|
|
38
|
-
*
|
|
39
|
-
* @param {string} name The name of the enum constant.
|
|
40
|
-
* @return {Enum} The enum constant.
|
|
41
|
-
*/
|
|
42
|
-
static valueOf(name) {
|
|
43
|
-
const value = this.values().find((v) => v.name === name);
|
|
44
|
-
if (value == null) {
|
|
45
|
-
throw new Error(`No enum constant ${this.name}.${name} exists.`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Creates an enum object.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} name The name of the enum constant.
|
|
55
|
-
* @param {number} ordinal The ordinal of the enum constant.
|
|
56
|
-
*/
|
|
57
|
-
constructor(name, ordinal) {
|
|
58
|
-
ensureArguments(arguments, [String, Number]);
|
|
59
|
-
this.name = name;
|
|
60
|
-
this.ordinal = ordinal;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Returns the name of the enum constant.
|
|
65
|
-
*
|
|
66
|
-
* @return {string} The name of the enum constant.
|
|
67
|
-
*/
|
|
68
|
-
toString() {
|
|
69
|
-
return this.name;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Returns the ordinal of the enum constant.
|
|
74
|
-
*
|
|
75
|
-
* @return {number} The ordinal of the enum constant.
|
|
76
|
-
*/
|
|
77
|
-
valueOf() {
|
|
78
|
-
return this.ordinal;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Returns the name of the enum constant.
|
|
83
|
-
*
|
|
84
|
-
* @return {string} The name of the enum constant.
|
|
85
|
-
*/
|
|
86
|
-
toJSON() {
|
|
87
|
-
return this.name;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Temporarily cease execution for the specified duration.
|
|
93
|
-
*
|
|
94
|
-
* @param {number} millis The duration to sleep in milliseconds.
|
|
95
|
-
* @return {Promise<void>} A promise that resolves after the specified
|
|
96
|
-
* duration.
|
|
97
|
-
*/
|
|
98
|
-
export async function sleep(millis) {
|
|
99
|
-
await new Promise((resolve) => setTimeout(resolve, millis));
|
|
100
|
-
}
|