@bymax-one/nest-core 1.0.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/CHANGELOG.md +77 -0
- package/LICENSE +21 -0
- package/README.md +716 -0
- package/dist/health/index.cjs +2 -0
- package/dist/health/index.d.cts +64 -0
- package/dist/health/index.d.ts +64 -0
- package/dist/health/index.mjs +1 -0
- package/dist/index.cjs +984 -0
- package/dist/index.d.cts +550 -0
- package/dist/index.d.ts +550 -0
- package/dist/index.mjs +960 -0
- package/dist/pagination/index.cjs +112 -0
- package/dist/pagination/index.d.cts +146 -0
- package/dist/pagination/index.d.ts +146 -0
- package/dist/pagination/index.mjs +105 -0
- package/package.json +169 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Health-check contracts. Consumers implement
|
|
3
|
+
* {@link IHealthIndicator} against a client they already own (a cache, a
|
|
4
|
+
* database, an external service) and register it under the
|
|
5
|
+
* `BYMAX_HEALTH_INDICATORS` multi-token; the aggregation service runs every
|
|
6
|
+
* registered indicator and folds the results into a {@link HealthResponse}.
|
|
7
|
+
* A rejecting or slow indicator is converted to a `down` entry by the
|
|
8
|
+
* aggregator: an indicator implementation never needs to guard its own
|
|
9
|
+
* timeout or catch its own errors.
|
|
10
|
+
* @layer Contract
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The outcome of a single indicator check.
|
|
14
|
+
*/
|
|
15
|
+
interface HealthIndicatorResult {
|
|
16
|
+
/** Whether the checked dependency is reachable and healthy. */
|
|
17
|
+
status: 'up' | 'down';
|
|
18
|
+
/**
|
|
19
|
+
* Optional diagnostic detail. Must never include secrets, connection
|
|
20
|
+
* strings, credentials, or a raw internal error object: only safe,
|
|
21
|
+
* human-readable fields belong here.
|
|
22
|
+
*/
|
|
23
|
+
details?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A pluggable readiness check. Implementations are registered under the
|
|
27
|
+
* `BYMAX_HEALTH_INDICATORS` multi-token and run concurrently by the
|
|
28
|
+
* aggregation service.
|
|
29
|
+
*/
|
|
30
|
+
interface IHealthIndicator {
|
|
31
|
+
/** Unique name reported in the {@link HealthResponse.checks} array. */
|
|
32
|
+
readonly name: string;
|
|
33
|
+
/**
|
|
34
|
+
* Perform the check.
|
|
35
|
+
*
|
|
36
|
+
* @returns The indicator's outcome.
|
|
37
|
+
* @throws Any error; a rejection is converted to a `down` entry by the
|
|
38
|
+
* aggregator and never propagates to the caller.
|
|
39
|
+
*/
|
|
40
|
+
check(): Promise<HealthIndicatorResult>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One entry in a {@link HealthResponse.checks} array: an indicator's result,
|
|
44
|
+
* tagged with the name that identifies it.
|
|
45
|
+
*/
|
|
46
|
+
interface HealthCheckEntry {
|
|
47
|
+
/** The indicator's {@link IHealthIndicator.name}. */
|
|
48
|
+
name: string;
|
|
49
|
+
/** The indicator's resolved status. */
|
|
50
|
+
status: 'up' | 'down';
|
|
51
|
+
/** The indicator's optional diagnostic detail, when present. */
|
|
52
|
+
details?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The stable, versioned response body served by the health endpoints.
|
|
56
|
+
*/
|
|
57
|
+
interface HealthResponse {
|
|
58
|
+
/** `'ok'` when every check is `up`; `'error'` when any check is `down`. */
|
|
59
|
+
status: 'ok' | 'error';
|
|
60
|
+
/** Every indicator's result. Empty for the liveness endpoint. */
|
|
61
|
+
checks: HealthCheckEntry[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type { HealthCheckEntry, HealthIndicatorResult, HealthResponse, IHealthIndicator };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Health-check contracts. Consumers implement
|
|
3
|
+
* {@link IHealthIndicator} against a client they already own (a cache, a
|
|
4
|
+
* database, an external service) and register it under the
|
|
5
|
+
* `BYMAX_HEALTH_INDICATORS` multi-token; the aggregation service runs every
|
|
6
|
+
* registered indicator and folds the results into a {@link HealthResponse}.
|
|
7
|
+
* A rejecting or slow indicator is converted to a `down` entry by the
|
|
8
|
+
* aggregator: an indicator implementation never needs to guard its own
|
|
9
|
+
* timeout or catch its own errors.
|
|
10
|
+
* @layer Contract
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The outcome of a single indicator check.
|
|
14
|
+
*/
|
|
15
|
+
interface HealthIndicatorResult {
|
|
16
|
+
/** Whether the checked dependency is reachable and healthy. */
|
|
17
|
+
status: 'up' | 'down';
|
|
18
|
+
/**
|
|
19
|
+
* Optional diagnostic detail. Must never include secrets, connection
|
|
20
|
+
* strings, credentials, or a raw internal error object: only safe,
|
|
21
|
+
* human-readable fields belong here.
|
|
22
|
+
*/
|
|
23
|
+
details?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A pluggable readiness check. Implementations are registered under the
|
|
27
|
+
* `BYMAX_HEALTH_INDICATORS` multi-token and run concurrently by the
|
|
28
|
+
* aggregation service.
|
|
29
|
+
*/
|
|
30
|
+
interface IHealthIndicator {
|
|
31
|
+
/** Unique name reported in the {@link HealthResponse.checks} array. */
|
|
32
|
+
readonly name: string;
|
|
33
|
+
/**
|
|
34
|
+
* Perform the check.
|
|
35
|
+
*
|
|
36
|
+
* @returns The indicator's outcome.
|
|
37
|
+
* @throws Any error; a rejection is converted to a `down` entry by the
|
|
38
|
+
* aggregator and never propagates to the caller.
|
|
39
|
+
*/
|
|
40
|
+
check(): Promise<HealthIndicatorResult>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One entry in a {@link HealthResponse.checks} array: an indicator's result,
|
|
44
|
+
* tagged with the name that identifies it.
|
|
45
|
+
*/
|
|
46
|
+
interface HealthCheckEntry {
|
|
47
|
+
/** The indicator's {@link IHealthIndicator.name}. */
|
|
48
|
+
name: string;
|
|
49
|
+
/** The indicator's resolved status. */
|
|
50
|
+
status: 'up' | 'down';
|
|
51
|
+
/** The indicator's optional diagnostic detail, when present. */
|
|
52
|
+
details?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The stable, versioned response body served by the health endpoints.
|
|
56
|
+
*/
|
|
57
|
+
interface HealthResponse {
|
|
58
|
+
/** `'ok'` when every check is `up`; `'error'` when any check is `down`. */
|
|
59
|
+
status: 'ok' | 'error';
|
|
60
|
+
/** Every indicator's result. Empty for the liveness endpoint. */
|
|
61
|
+
checks: HealthCheckEntry[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type { HealthCheckEntry, HealthIndicatorResult, HealthResponse, IHealthIndicator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|