@xyo-network/xl1-system-status 3.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 ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @xyo-network/xl1-system-status
2
+
3
+ System status publishers for XYO Layer One.
4
+
5
+ The status model itself — the `SystemStatusRunner` hub, the `SystemStatusViewer`
6
+ read facade, and their interfaces — lives in `@xyo-network/xl1-protocol-lib` and
7
+ `@xyo-network/xl1-protocol-sdk`. This package provides the **publishers** that
8
+ emit that status outward:
9
+
10
+ - `ConsoleSystemStatusPublisher` — logs global status transitions via a logger.
11
+ - `HttpSystemStatusPublisher` — serves Kubernetes-style probes (`/healthz`,
12
+ `/livez`, `/readyz`) plus a `/status` JSON snapshot over `node:http`.
13
+
14
+ Both are plain start/stop observers (not creatable providers): they read the
15
+ Runner and never report their own lifecycle into it, so they cannot skew the
16
+ aggregate status (no false `/healthz` 200).
@@ -0,0 +1,27 @@
1
+ import type { Logger } from '@xylabs/sdk-js';
2
+ import type { SystemStatusPublisher, SystemStatusRunner } from '@xyo-network/xl1-protocol-lib';
3
+ /** Options for the console system-status publisher. */
4
+ export interface ConsoleSystemStatusPublisherOptions {
5
+ logger?: Logger;
6
+ }
7
+ /**
8
+ * Publishes system status to the console by subscribing to the Runner's global
9
+ * status transitions.
10
+ *
11
+ * It is a plain start/stop observer — NOT a CreatableProvider — so it never
12
+ * reports its own lifecycle into the Runner. A self-reporting publisher would
13
+ * report itself `started` before any real service is up, falsely flipping the
14
+ * aggregate status to `started` (and any HTTP `/healthz` derived from it to
15
+ * 200). Being a plain observer keeps the global status reflecting only the
16
+ * actual services.
17
+ */
18
+ export declare class ConsoleSystemStatusPublisher implements SystemStatusPublisher {
19
+ readonly moniker: "SystemStatusPublisher";
20
+ private _started;
21
+ private readonly options;
22
+ private readonly status;
23
+ constructor(status: SystemStatusRunner, options?: ConsoleSystemStatusPublisherOptions);
24
+ start(): void;
25
+ stop(): void;
26
+ }
27
+ //# sourceMappingURL=ConsoleSystemStatusPublisher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleSystemStatusPublisher.d.ts","sourceRoot":"","sources":["../../src/ConsoleSystemStatusPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAG9F,uDAAuD;AACvD,MAAM,WAAW,mCAAmC;IAClD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,4BAA6B,YAAW,qBAAqB;IACxE,QAAQ,CAAC,OAAO,0BAA+B;IAE/C,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;gBAE/B,MAAM,EAAE,kBAAkB,EAAE,OAAO,GAAE,mCAAwC;IAKzF,KAAK,IAAI,IAAI;IAUb,IAAI,IAAI,IAAI;CAGb"}
@@ -0,0 +1,45 @@
1
+ import type { Logger } from '@xylabs/sdk-js';
2
+ import type { SystemStatusPublisher, SystemStatusRunner, SystemStatusViewerMethods } from '@xyo-network/xl1-protocol-lib';
3
+ /** Options for the HTTP system-status publisher. */
4
+ export interface HttpSystemStatusPublisherOptions {
5
+ host?: string;
6
+ logger?: Logger;
7
+ port: number;
8
+ }
9
+ /** A resolved probe response (HTTP status code + JSON body). */
10
+ export interface StatusProbeResponse {
11
+ body: unknown;
12
+ statusCode: number;
13
+ }
14
+ /**
15
+ * Pure routing for the status probe endpoints. Extracted from the HTTP server
16
+ * so the routing logic is testable without binding a socket.
17
+ */
18
+ export declare function resolveStatusProbe(status: SystemStatusViewerMethods, url: string): StatusProbeResponse;
19
+ /**
20
+ * Publishes system status over HTTP with Kubernetes-style probes plus a richer
21
+ * `/status` snapshot:
22
+ * - `/healthz` — 200 once the global status is `started`, otherwise 500.
23
+ * - `/livez` — 200 unconditionally while the process is running.
24
+ * - `/readyz` — 503 while shutting down, 200 once `isReady()`, else 503.
25
+ * - `/status` — 200 with the full status snapshot as JSON.
26
+ *
27
+ * It publishes to two sinks: the HTTP endpoints above, and the logger (it logs
28
+ * each global status transition via the Runner's subscription).
29
+ *
30
+ * It is a plain start/stop observer (not a CreatableProvider) so it does not
31
+ * report its own lifecycle into the Runner — keeping the global status (and
32
+ * thus `/healthz`) reflecting only the actual services.
33
+ */
34
+ export declare class HttpSystemStatusPublisher implements SystemStatusPublisher {
35
+ readonly moniker: "SystemStatusPublisher";
36
+ private _server;
37
+ private _started;
38
+ private readonly options;
39
+ private readonly status;
40
+ constructor(status: SystemStatusRunner, options: HttpSystemStatusPublisherOptions);
41
+ start(): Promise<void>;
42
+ stop(): Promise<void>;
43
+ private handleRequest;
44
+ }
45
+ //# sourceMappingURL=HttpSystemStatusPublisher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpSystemStatusPublisher.d.ts","sourceRoot":"","sources":["../../src/HttpSystemStatusPublisher.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EACV,qBAAqB,EAAE,kBAAkB,EAAE,yBAAyB,EACrE,MAAM,+BAA+B,CAAA;AAGtC,oDAAoD;AACpD,MAAM,WAAW,gCAAgC;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb;AAED,gEAAgE;AAChE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAqBtG;AAOD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,yBAA0B,YAAW,qBAAqB;IACrE,QAAQ,CAAC,OAAO,0BAA+B;IAE/C,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;gBAE/B,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,gCAAgC;IAK3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,OAAO,CAAC,aAAa;CAItB"}
@@ -0,0 +1,3 @@
1
+ export * from './ConsoleSystemStatusPublisher.ts';
2
+ export * from './HttpSystemStatusPublisher.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA;AACjD,cAAc,gCAAgC,CAAA"}
@@ -0,0 +1,110 @@
1
+ // src/ConsoleSystemStatusPublisher.ts
2
+ import { SystemStatusPublisherMoniker } from "@xyo-network/xl1-protocol-lib";
3
+ var ConsoleSystemStatusPublisher = class {
4
+ moniker = SystemStatusPublisherMoniker;
5
+ _started = false;
6
+ options;
7
+ status;
8
+ constructor(status, options = {}) {
9
+ this.status = status;
10
+ this.options = options;
11
+ }
12
+ start() {
13
+ this._started = true;
14
+ const { logger } = this.options;
15
+ this.status.onGlobalTransition({}, (from, to) => {
16
+ if (!this._started) return;
17
+ logger?.log(`System status: ${from} -> ${to}`);
18
+ if (to === "started") logger?.log("All services started.");
19
+ });
20
+ }
21
+ stop() {
22
+ this._started = false;
23
+ }
24
+ };
25
+
26
+ // src/HttpSystemStatusPublisher.ts
27
+ import http from "node:http";
28
+ import { SystemStatusPublisherMoniker as SystemStatusPublisherMoniker2 } from "@xyo-network/xl1-protocol-lib";
29
+ function resolveStatusProbe(status, url) {
30
+ switch (url) {
31
+ case "/healthz": {
32
+ const global = status.getGlobalStatus();
33
+ return { statusCode: global === "started" ? 200 : 500, body: { status: global } };
34
+ }
35
+ case "/livez": {
36
+ return { statusCode: 200, body: { status: "live" } };
37
+ }
38
+ case "/readyz": {
39
+ if (status.isShuttingDown()) return { statusCode: 503, body: { status: "shutting-down" } };
40
+ if (status.isReady()) return { statusCode: 200, body: { status: "ready" } };
41
+ return { statusCode: 503, body: { status: "pending" } };
42
+ }
43
+ case "/status": {
44
+ return { statusCode: 200, body: status.snapshot() };
45
+ }
46
+ default: {
47
+ return { statusCode: 404, body: { status: "not found" } };
48
+ }
49
+ }
50
+ }
51
+ var sendJson = (res, statusCode, body) => {
52
+ res.writeHead(statusCode, { "Content-Type": "application/json" });
53
+ res.end(JSON.stringify(body));
54
+ };
55
+ var HttpSystemStatusPublisher = class {
56
+ moniker = SystemStatusPublisherMoniker2;
57
+ _server;
58
+ _started = false;
59
+ options;
60
+ status;
61
+ constructor(status, options) {
62
+ this.status = status;
63
+ this.options = options;
64
+ }
65
+ async start() {
66
+ this._started = true;
67
+ const {
68
+ host,
69
+ logger,
70
+ port
71
+ } = this.options;
72
+ this.status.onGlobalTransition({}, (from, to) => {
73
+ if (!this._started) return;
74
+ logger?.log(`System status: ${from} -> ${to}`);
75
+ });
76
+ const server = http.createServer((req, res) => this.handleRequest(req, res));
77
+ await new Promise((resolve, reject) => {
78
+ server.once("error", reject);
79
+ server.listen(port, host, () => {
80
+ logger?.log(`System status HTTP server running on http://${host ?? "localhost"}:${port}`);
81
+ logger?.log(" - /healthz");
82
+ logger?.log(" - /livez");
83
+ logger?.log(" - /readyz");
84
+ logger?.log(" - /status");
85
+ resolve();
86
+ });
87
+ });
88
+ this._server = server;
89
+ }
90
+ async stop() {
91
+ this._started = false;
92
+ const server = this._server;
93
+ this._server = void 0;
94
+ if (server !== void 0) {
95
+ await new Promise((resolve) => {
96
+ server.close(() => resolve());
97
+ });
98
+ }
99
+ }
100
+ handleRequest(req, res) {
101
+ const { statusCode, body } = resolveStatusProbe(this.status, req.url ?? "");
102
+ sendJson(res, statusCode, body);
103
+ }
104
+ };
105
+ export {
106
+ ConsoleSystemStatusPublisher,
107
+ HttpSystemStatusPublisher,
108
+ resolveStatusProbe
109
+ };
110
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ConsoleSystemStatusPublisher.ts", "../../src/HttpSystemStatusPublisher.ts"],
4
+ "sourcesContent": ["import type { Logger } from '@xylabs/sdk-js'\nimport type { SystemStatusPublisher, SystemStatusRunner } from '@xyo-network/xl1-protocol-lib'\nimport { SystemStatusPublisherMoniker } from '@xyo-network/xl1-protocol-lib'\n\n/** Options for the console system-status publisher. */\nexport interface ConsoleSystemStatusPublisherOptions {\n logger?: Logger\n}\n\n/**\n * Publishes system status to the console by subscribing to the Runner's global\n * status transitions.\n *\n * It is a plain start/stop observer \u2014 NOT a CreatableProvider \u2014 so it never\n * reports its own lifecycle into the Runner. A self-reporting publisher would\n * report itself `started` before any real service is up, falsely flipping the\n * aggregate status to `started` (and any HTTP `/healthz` derived from it to\n * 200). Being a plain observer keeps the global status reflecting only the\n * actual services.\n */\nexport class ConsoleSystemStatusPublisher implements SystemStatusPublisher {\n readonly moniker = SystemStatusPublisherMoniker\n\n private _started = false\n private readonly options: ConsoleSystemStatusPublisherOptions\n private readonly status: SystemStatusRunner\n\n constructor(status: SystemStatusRunner, options: ConsoleSystemStatusPublisherOptions = {}) {\n this.status = status\n this.options = options\n }\n\n start(): void {\n this._started = true\n const { logger } = this.options\n this.status.onGlobalTransition({}, (from, to) => {\n if (!this._started) return\n logger?.log(`System status: ${from} -> ${to}`)\n if (to === 'started') logger?.log('All services started.')\n })\n }\n\n stop(): void {\n this._started = false\n }\n}\n", "import type {\n IncomingMessage, Server, ServerResponse,\n} from 'node:http'\nimport http from 'node:http'\n\nimport type { Logger } from '@xylabs/sdk-js'\nimport type {\n SystemStatusPublisher, SystemStatusRunner, SystemStatusViewerMethods,\n} from '@xyo-network/xl1-protocol-lib'\nimport { SystemStatusPublisherMoniker } from '@xyo-network/xl1-protocol-lib'\n\n/** Options for the HTTP system-status publisher. */\nexport interface HttpSystemStatusPublisherOptions {\n host?: string\n logger?: Logger\n port: number\n}\n\n/** A resolved probe response (HTTP status code + JSON body). */\nexport interface StatusProbeResponse {\n body: unknown\n statusCode: number\n}\n\n/**\n * Pure routing for the status probe endpoints. Extracted from the HTTP server\n * so the routing logic is testable without binding a socket.\n */\nexport function resolveStatusProbe(status: SystemStatusViewerMethods, url: string): StatusProbeResponse {\n switch (url) {\n case '/healthz': {\n const global = status.getGlobalStatus()\n return { statusCode: global === 'started' ? 200 : 500, body: { status: global } }\n }\n case '/livez': {\n return { statusCode: 200, body: { status: 'live' } }\n }\n case '/readyz': {\n if (status.isShuttingDown()) return { statusCode: 503, body: { status: 'shutting-down' } }\n if (status.isReady()) return { statusCode: 200, body: { status: 'ready' } }\n return { statusCode: 503, body: { status: 'pending' } }\n }\n case '/status': {\n return { statusCode: 200, body: status.snapshot() }\n }\n default: {\n return { statusCode: 404, body: { status: 'not found' } }\n }\n }\n}\n\nconst sendJson = (res: ServerResponse, statusCode: number, body: unknown): void => {\n res.writeHead(statusCode, { 'Content-Type': 'application/json' })\n res.end(JSON.stringify(body))\n}\n\n/**\n * Publishes system status over HTTP with Kubernetes-style probes plus a richer\n * `/status` snapshot:\n * - `/healthz` \u2014 200 once the global status is `started`, otherwise 500.\n * - `/livez` \u2014 200 unconditionally while the process is running.\n * - `/readyz` \u2014 503 while shutting down, 200 once `isReady()`, else 503.\n * - `/status` \u2014 200 with the full status snapshot as JSON.\n *\n * It publishes to two sinks: the HTTP endpoints above, and the logger (it logs\n * each global status transition via the Runner's subscription).\n *\n * It is a plain start/stop observer (not a CreatableProvider) so it does not\n * report its own lifecycle into the Runner \u2014 keeping the global status (and\n * thus `/healthz`) reflecting only the actual services.\n */\nexport class HttpSystemStatusPublisher implements SystemStatusPublisher {\n readonly moniker = SystemStatusPublisherMoniker\n\n private _server: Server | undefined\n private _started = false\n private readonly options: HttpSystemStatusPublisherOptions\n private readonly status: SystemStatusRunner\n\n constructor(status: SystemStatusRunner, options: HttpSystemStatusPublisherOptions) {\n this.status = status\n this.options = options\n }\n\n async start(): Promise<void> {\n this._started = true\n const {\n host, logger, port,\n } = this.options\n // Console sink: log every global status transition via the logger.\n this.status.onGlobalTransition({}, (from, to) => {\n if (!this._started) return\n logger?.log(`System status: ${from} -> ${to}`)\n })\n const server = http.createServer((req, res) => this.handleRequest(req, res))\n await new Promise<void>((resolve, reject) => {\n server.once('error', reject)\n server.listen(port, host, () => {\n logger?.log(`System status HTTP server running on http://${host ?? 'localhost'}:${port}`)\n logger?.log(' - /healthz')\n logger?.log(' - /livez')\n logger?.log(' - /readyz')\n logger?.log(' - /status')\n resolve()\n })\n })\n this._server = server\n }\n\n async stop(): Promise<void> {\n this._started = false\n const server = this._server\n this._server = undefined\n if (server !== undefined) {\n await new Promise<void>((resolve) => {\n server.close(() => resolve())\n })\n }\n }\n\n private handleRequest(req: IncomingMessage, res: ServerResponse): void {\n const { statusCode, body } = resolveStatusProbe(this.status, req.url ?? '')\n sendJson(res, statusCode, body)\n }\n}\n"],
5
+ "mappings": "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",
6
+ "names": ["SystemStatusPublisherMoniker"]
7
+ }
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "$schema": "http://json.schemastore.org/package.json",
3
+ "name": "@xyo-network/xl1-system-status",
4
+ "version": "3.1.0",
5
+ "description": "XYO Layer One system status publishers (console + HTTP health endpoints)",
6
+ "homepage": "https://xylabs.com",
7
+ "bugs": {
8
+ "url": "https://github.com/XYOracleNetwork/xl1-protocol/issues",
9
+ "email": "support@xylabs.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/XYOracleNetwork/xl1-protocol.git"
14
+ },
15
+ "license": "LGPL-3.0-only",
16
+ "author": {
17
+ "name": "XY Labs Development Team",
18
+ "email": "support@xylabs.com",
19
+ "url": "https://xylabs.com"
20
+ },
21
+ "sideEffects": false,
22
+ "type": "module",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/node/index.d.ts",
26
+ "default": "./dist/node/index.mjs"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "!**/*.bench.*",
33
+ "!**/*.spec.*",
34
+ "!**/*.test.*",
35
+ "README.md"
36
+ ],
37
+ "dependencies": {
38
+ "@xyo-network/xl1-protocol-lib": "~3.1.0"
39
+ },
40
+ "devDependencies": {
41
+ "@bitauth/libauth": "~3.0.0",
42
+ "@metamask/providers": "^22.1.1",
43
+ "@noble/post-quantum": "~0.6.1",
44
+ "@opentelemetry/api": "^1.9.1",
45
+ "@opentelemetry/sdk-trace-base": "^2.8.0",
46
+ "@scure/base": "~2.2.0",
47
+ "@scure/bip39": "~2.2.0",
48
+ "@xylabs/geo": "^6.1.4",
49
+ "@xylabs/sdk-js": "^6.1.4",
50
+ "@xylabs/threads": "^6.1.4",
51
+ "@xylabs/toolchain": "~8.3.0",
52
+ "@xylabs/tsconfig": "~8.3.0",
53
+ "@xyo-network/sdk-js": "~7.0.1",
54
+ "@xyo-network/sdk-protocol-js": "~7.0.3",
55
+ "ajv": "^8.20.0",
56
+ "async-mutex": "^0.5.0",
57
+ "cosmiconfig": "^9.0.2",
58
+ "debug": "~4.4.3",
59
+ "eslint": "^10.5.0",
60
+ "ethers": "^6.17.0",
61
+ "hash-wasm": "~4.12.0",
62
+ "idb": "^8.0.3",
63
+ "lru-cache": "^11.5.1",
64
+ "observable-fns": "~0.6.1",
65
+ "typescript": "~6.0.3",
66
+ "vite": "^8.1.0",
67
+ "vitest": "~4.1.9",
68
+ "webextension-polyfill": "^0.12.0",
69
+ "zod": "~4.4.3",
70
+ "@xyo-network/xl1-protocol-sdk": "~3.1.0"
71
+ },
72
+ "peerDependencies": {
73
+ "@bitauth/libauth": "~3.0",
74
+ "@metamask/providers": "^22.1",
75
+ "@noble/post-quantum": "~0.6.1",
76
+ "@opentelemetry/api": "^1.9",
77
+ "@opentelemetry/sdk-trace-base": "^2.7",
78
+ "@scure/base": "~2.2",
79
+ "@scure/bip39": "~2.2",
80
+ "@xylabs/geo": "^6.0",
81
+ "@xylabs/sdk-js": "^6.0",
82
+ "@xylabs/threads": "^6.1",
83
+ "@xyo-network/sdk-js": "^7.0",
84
+ "@xyo-network/sdk-protocol-js": "~7.0",
85
+ "ajv": "^8.20",
86
+ "async-mutex": "^0.5",
87
+ "debug": "~4.4",
88
+ "ethers": "^6.16",
89
+ "hash-wasm": "~4.12",
90
+ "idb": "^8.0",
91
+ "lru-cache": "^11.3",
92
+ "observable-fns": "~0.6",
93
+ "webextension-polyfill": "^0.12",
94
+ "zod": "~4.4"
95
+ },
96
+ "engines": {
97
+ "node": ">=22.3"
98
+ },
99
+ "engineStrict": true,
100
+ "publishConfig": {
101
+ "access": "public"
102
+ }
103
+ }