margin-ts 0.6.0 → 0.6.2

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.
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Streaming health updates via Server-Sent Events (SSE).
3
+ *
4
+ * Push health/drift/anomaly updates to browser dashboards in real-time.
5
+ *
6
+ * Express:
7
+ * app.get('/margin/stream', marginSSE(monitor));
8
+ *
9
+ * Next.js Pages Router:
10
+ * export default marginSSEHandler(monitor);
11
+ *
12
+ * Browser client:
13
+ * const source = new EventSource('/margin/stream');
14
+ * source.onmessage = (e) => {
15
+ * const health = JSON.parse(e.data);
16
+ * updateDashboard(health);
17
+ * };
18
+ *
19
+ * Zero dependencies. Works with any framework that supports
20
+ * writable response streams (Express, Fastify, Next.js, raw Node http).
21
+ */
22
+ import { Expression, Parser, DriftClassification, AnomalyClassification } from '../index.js';
23
+ export declare class StreamingMonitor {
24
+ private parser;
25
+ private windows;
26
+ private _expression;
27
+ private _step;
28
+ private maxWindow;
29
+ private minAnomalyRef;
30
+ constructor(parser: Parser, options?: {
31
+ window?: number;
32
+ minAnomalyRef?: number;
33
+ });
34
+ get expression(): Expression | null;
35
+ get step(): number;
36
+ update(values: Record<string, number>, now?: Date): Expression;
37
+ drift(component: string): DriftClassification | null;
38
+ anomaly(component: string): AnomalyClassification | null;
39
+ status(): Record<string, unknown>;
40
+ reset(): void;
41
+ }
42
+ /**
43
+ * Broadcast a status update to all connected SSE clients.
44
+ * Call this after each monitor.update().
45
+ */
46
+ export declare function broadcast(monitor: StreamingMonitor): void;
47
+ /**
48
+ * Express/Fastify route handler for SSE streaming.
49
+ *
50
+ * app.get('/margin/stream', marginSSE(monitor));
51
+ *
52
+ * Each connected browser receives real-time health updates.
53
+ * Call broadcast(monitor) after each monitor.update() to push.
54
+ */
55
+ export declare function marginSSE(monitor: StreamingMonitor): (req: any, res: any) => void;
56
+ /**
57
+ * Next.js Pages Router SSE handler.
58
+ *
59
+ * // pages/api/margin/stream.ts
60
+ * export default marginSSEHandler(monitor);
61
+ */
62
+ export declare function marginSSEHandler(monitor: StreamingMonitor): (req: any, res: any) => void;
63
+ /**
64
+ * Create a polling endpoint (for environments that don't support SSE).
65
+ * Returns the current status as JSON on each request.
66
+ *
67
+ * app.get('/margin/poll', marginPoll(monitor));
68
+ */
69
+ export declare function marginPoll(monitor: StreamingMonitor): (req: any, res: any) => void;
70
+ /** Number of connected SSE clients. */
71
+ export declare function connectedClients(): number;
72
+ /** Disconnect all SSE clients (for testing). */
73
+ export declare function resetClients(): void;
74
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/adapters/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAIL,UAAU,EACV,MAAM,EAKN,mBAAmB,EAInB,qBAAqB,EAEtB,MAAM,aAAa,CAAC;AAYrB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA2C;IAC1D,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAS;gBAElB,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAO;IAMrF,IAAI,UAAU,IAAI,UAAU,GAAG,IAAI,CAA6B;IAChE,IAAI,IAAI,IAAI,MAAM,CAAuB;IAEzC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,GAAG,UAAU;IAwB9D,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;IAMpD,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI;IAQxD,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAoBjC,KAAK,IAAI,IAAI;CAKd;AAeD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAWzD;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAoBjF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAExF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAIlF;AAED,uCAAuC;AACvC,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,gDAAgD;AAChD,wBAAgB,YAAY,IAAI,IAAI,CAMnC"}
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ /**
3
+ * Streaming health updates via Server-Sent Events (SSE).
4
+ *
5
+ * Push health/drift/anomaly updates to browser dashboards in real-time.
6
+ *
7
+ * Express:
8
+ * app.get('/margin/stream', marginSSE(monitor));
9
+ *
10
+ * Next.js Pages Router:
11
+ * export default marginSSEHandler(monitor);
12
+ *
13
+ * Browser client:
14
+ * const source = new EventSource('/margin/stream');
15
+ * source.onmessage = (e) => {
16
+ * const health = JSON.parse(e.data);
17
+ * updateDashboard(health);
18
+ * };
19
+ *
20
+ * Zero dependencies. Works with any framework that supports
21
+ * writable response streams (Express, Fastify, Next.js, raw Node http).
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.StreamingMonitor = void 0;
25
+ exports.broadcast = broadcast;
26
+ exports.marginSSE = marginSSE;
27
+ exports.marginSSEHandler = marginSSEHandler;
28
+ exports.marginPoll = marginPoll;
29
+ exports.connectedClients = connectedClients;
30
+ exports.resetClients = resetClients;
31
+ const index_js_1 = require("../index.js");
32
+ class StreamingMonitor {
33
+ parser;
34
+ windows = new Map();
35
+ _expression = null;
36
+ _step = 0;
37
+ maxWindow;
38
+ minAnomalyRef;
39
+ constructor(parser, options = {}) {
40
+ this.parser = parser;
41
+ this.maxWindow = options.window ?? 100;
42
+ this.minAnomalyRef = options.minAnomalyRef ?? 10;
43
+ }
44
+ get expression() { return this._expression; }
45
+ get step() { return this._step; }
46
+ update(values, now) {
47
+ now = now ?? new Date();
48
+ this._expression = this.parser.parse(values, { step: this._step });
49
+ this._step++;
50
+ // Update per-component windows
51
+ for (const obs of this._expression.observations) {
52
+ if (!this.windows.has(obs.name)) {
53
+ this.windows.set(obs.name, { values: [], observations: [], maxWindow: this.maxWindow });
54
+ }
55
+ const w = this.windows.get(obs.name);
56
+ w.values.push(obs.value);
57
+ // Stamp the observation with time for drift
58
+ const stamped = { ...obs, measuredAt: now };
59
+ w.observations.push(stamped);
60
+ if (w.values.length > this.maxWindow) {
61
+ w.values.shift();
62
+ w.observations.shift();
63
+ }
64
+ }
65
+ return this._expression;
66
+ }
67
+ drift(component) {
68
+ const w = this.windows.get(component);
69
+ if (!w || w.observations.length < 3)
70
+ return null;
71
+ return (0, index_js_1.classifyDrift)(w.observations);
72
+ }
73
+ anomaly(component) {
74
+ const w = this.windows.get(component);
75
+ if (!w || w.values.length < this.minAnomalyRef + 1)
76
+ return null;
77
+ const ref = w.values.slice(0, -1);
78
+ const current = w.values[w.values.length - 1];
79
+ return (0, index_js_1.classifyAnomaly)(current, ref, { component });
80
+ }
81
+ status() {
82
+ const drift = {};
83
+ const anomaly = {};
84
+ for (const [name] of this.windows) {
85
+ const dc = this.drift(name);
86
+ if (dc)
87
+ drift[name] = { state: dc.state, direction: dc.direction, rate: dc.rate };
88
+ const ac = this.anomaly(name);
89
+ if (ac)
90
+ anomaly[name] = { state: ac.state, zScore: ac.zScore };
91
+ }
92
+ return {
93
+ step: this._step,
94
+ expression: this._expression ? (0, index_js_1.expressionToString)(this._expression) : null,
95
+ health: this._expression ? (0, index_js_1.expressionToDict)(this._expression) : null,
96
+ drift,
97
+ anomaly,
98
+ };
99
+ }
100
+ reset() {
101
+ this.windows.clear();
102
+ this._expression = null;
103
+ this._step = 0;
104
+ }
105
+ }
106
+ exports.StreamingMonitor = StreamingMonitor;
107
+ let _clients = [];
108
+ let _clientIdCounter = 0;
109
+ /**
110
+ * Broadcast a status update to all connected SSE clients.
111
+ * Call this after each monitor.update().
112
+ */
113
+ function broadcast(monitor) {
114
+ const data = JSON.stringify(monitor.status());
115
+ const message = `data: ${data}\n\n`;
116
+ _clients = _clients.filter(client => {
117
+ try {
118
+ client.res.write(message);
119
+ return true;
120
+ }
121
+ catch {
122
+ return false; // client disconnected
123
+ }
124
+ });
125
+ }
126
+ /**
127
+ * Express/Fastify route handler for SSE streaming.
128
+ *
129
+ * app.get('/margin/stream', marginSSE(monitor));
130
+ *
131
+ * Each connected browser receives real-time health updates.
132
+ * Call broadcast(monitor) after each monitor.update() to push.
133
+ */
134
+ function marginSSE(monitor) {
135
+ return (req, res) => {
136
+ res.writeHead(200, {
137
+ 'Content-Type': 'text/event-stream',
138
+ 'Cache-Control': 'no-cache',
139
+ 'Connection': 'keep-alive',
140
+ 'Access-Control-Allow-Origin': '*',
141
+ });
142
+ // Send current state immediately
143
+ const initial = JSON.stringify(monitor.status());
144
+ res.write(`data: ${initial}\n\n`);
145
+ const client = { id: String(++_clientIdCounter), res };
146
+ _clients.push(client);
147
+ req.on('close', () => {
148
+ _clients = _clients.filter(c => c.id !== client.id);
149
+ });
150
+ };
151
+ }
152
+ /**
153
+ * Next.js Pages Router SSE handler.
154
+ *
155
+ * // pages/api/margin/stream.ts
156
+ * export default marginSSEHandler(monitor);
157
+ */
158
+ function marginSSEHandler(monitor) {
159
+ return marginSSE(monitor);
160
+ }
161
+ /**
162
+ * Create a polling endpoint (for environments that don't support SSE).
163
+ * Returns the current status as JSON on each request.
164
+ *
165
+ * app.get('/margin/poll', marginPoll(monitor));
166
+ */
167
+ function marginPoll(monitor) {
168
+ return (_req, res) => {
169
+ res.json(monitor.status());
170
+ };
171
+ }
172
+ /** Number of connected SSE clients. */
173
+ function connectedClients() {
174
+ return _clients.length;
175
+ }
176
+ /** Disconnect all SSE clients (for testing). */
177
+ function resetClients() {
178
+ for (const client of _clients) {
179
+ try {
180
+ client.res.end();
181
+ }
182
+ catch { }
183
+ }
184
+ _clients = [];
185
+ _clientIdCounter = 0;
186
+ }
187
+ //# sourceMappingURL=stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/adapters/stream.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAiIH,8BAWC;AAUD,8BAoBC;AAQD,4CAEC;AAQD,gCAIC;AAGD,4CAEC;AAGD,oCAMC;AA5MD,0CAgBqB;AAYrB,MAAa,gBAAgB;IACnB,MAAM,CAAS;IACf,OAAO,GAAiC,IAAI,GAAG,EAAE,CAAC;IAClD,WAAW,GAAsB,IAAI,CAAC;IACtC,KAAK,GAAG,CAAC,CAAC;IACV,SAAS,CAAS;IAClB,aAAa,CAAS;IAE9B,YAAY,MAAc,EAAE,UAAuD,EAAE;QACnF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC;IACnD,CAAC;IAED,IAAI,UAAU,KAAwB,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAChE,IAAI,IAAI,KAAa,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEzC,MAAM,CAAC,MAA8B,EAAE,GAAU;QAC/C,GAAG,GA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CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACpC,CAAC;IACD,QAAQ,GAAG,EAAE,CAAC;IACd,gBAAgB,GAAG,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Vitest/Jest test health reporter for margin.
3
+ *
4
+ * Classifies test suite health after every run: pass rate, duration,
5
+ * flake rate. The JS equivalent of margin's pytest plugin.
6
+ *
7
+ * Usage with vitest:
8
+ * // vitest.config.ts
9
+ * import { marginReporter } from 'margin-ts/adapters/vitest';
10
+ * export default { test: { reporters: ['default', marginReporter()] } };
11
+ *
12
+ * Or use standalone after collecting results:
13
+ * import { classifySuite } from 'margin-ts/adapters/vitest';
14
+ * const health = classifySuite({ passed: 95, failed: 3, skipped: 2, durationMs: 4500 });
15
+ */
16
+ import { Thresholds, Expression } from '../index.js';
17
+ export interface SuiteThresholds {
18
+ passRate: Thresholds;
19
+ skipRate: Thresholds;
20
+ meanDurationMs: Thresholds;
21
+ totalDurationMs: Thresholds;
22
+ }
23
+ export declare const DEFAULT_SUITE_THRESHOLDS: SuiteThresholds;
24
+ export interface SuiteResults {
25
+ passed: number;
26
+ failed: number;
27
+ skipped: number;
28
+ durationMs: number;
29
+ testDurations?: number[];
30
+ }
31
+ export declare function classifySuite(results: SuiteResults, thresholds?: SuiteThresholds, label?: string): Expression;
32
+ /**
33
+ * Format suite health as a printable string.
34
+ */
35
+ export declare function suiteHealthString(results: SuiteResults, thresholds?: SuiteThresholds): string;
36
+ //# sourceMappingURL=vitest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../../src/adapters/vitest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,UAAU,EAIV,UAAU,EAGX,MAAM,aAAa,CAAC;AAMrB,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,UAAU,CAAC;IACrB,QAAQ,EAAE,UAAU,CAAC;IACrB,cAAc,EAAE,UAAU,CAAC;IAC3B,eAAe,EAAE,UAAU,CAAC;CAC7B;AAED,eAAO,MAAM,wBAAwB,EAAE,eAKtC,CAAC;AAMF,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,YAAY,EACrB,UAAU,GAAE,eAA0C,EACtD,KAAK,SAAK,GACT,UAAU,CAiEZ;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,MAAM,CAQ7F"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ /**
3
+ * Vitest/Jest test health reporter for margin.
4
+ *
5
+ * Classifies test suite health after every run: pass rate, duration,
6
+ * flake rate. The JS equivalent of margin's pytest plugin.
7
+ *
8
+ * Usage with vitest:
9
+ * // vitest.config.ts
10
+ * import { marginReporter } from 'margin-ts/adapters/vitest';
11
+ * export default { test: { reporters: ['default', marginReporter()] } };
12
+ *
13
+ * Or use standalone after collecting results:
14
+ * import { classifySuite } from 'margin-ts/adapters/vitest';
15
+ * const health = classifySuite({ passed: 95, failed: 3, skipped: 2, durationMs: 4500 });
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.DEFAULT_SUITE_THRESHOLDS = void 0;
19
+ exports.classifySuite = classifySuite;
20
+ exports.suiteHealthString = suiteHealthString;
21
+ const index_js_1 = require("../index.js");
22
+ exports.DEFAULT_SUITE_THRESHOLDS = {
23
+ passRate: (0, index_js_1.createThresholds)(0.95, 0.70, true), // higher is better
24
+ skipRate: (0, index_js_1.createThresholds)(0.05, 0.20, false), // lower is better
25
+ meanDurationMs: (0, index_js_1.createThresholds)(100, 1000, false), // lower is better
26
+ totalDurationMs: (0, index_js_1.createThresholds)(30000, 120000, false), // lower is better
27
+ };
28
+ function classifySuite(results, thresholds = exports.DEFAULT_SUITE_THRESHOLDS, label = '') {
29
+ const total = results.passed + results.failed + results.skipped;
30
+ if (total === 0)
31
+ return (0, index_js_1.createExpression)([], [], label);
32
+ const passRate = results.passed / total;
33
+ const skipRate = results.skipped / total;
34
+ const meanDuration = results.testDurations && results.testDurations.length > 0
35
+ ? results.testDurations.reduce((a, b) => a + b, 0) / results.testDurations.length
36
+ : results.durationMs / total;
37
+ const now = new Date();
38
+ const observations = [
39
+ {
40
+ name: 'pass_rate',
41
+ health: (0, index_js_1.classify)(passRate, index_js_1.Confidence.HIGH, thresholds.passRate),
42
+ value: passRate,
43
+ baseline: 1.0,
44
+ confidence: index_js_1.Confidence.HIGH,
45
+ higherIsBetter: true,
46
+ provenance: [],
47
+ measuredAt: now,
48
+ },
49
+ {
50
+ name: 'skip_rate',
51
+ health: (0, index_js_1.classify)(skipRate, index_js_1.Confidence.HIGH, thresholds.skipRate),
52
+ value: skipRate,
53
+ baseline: 0.0,
54
+ confidence: index_js_1.Confidence.HIGH,
55
+ higherIsBetter: false,
56
+ provenance: [],
57
+ measuredAt: now,
58
+ },
59
+ {
60
+ name: 'mean_duration',
61
+ health: (0, index_js_1.classify)(meanDuration, index_js_1.Confidence.HIGH, thresholds.meanDurationMs),
62
+ value: meanDuration,
63
+ baseline: 50,
64
+ confidence: index_js_1.Confidence.HIGH,
65
+ higherIsBetter: false,
66
+ provenance: [],
67
+ measuredAt: now,
68
+ },
69
+ {
70
+ name: 'total_duration',
71
+ health: (0, index_js_1.classify)(results.durationMs, index_js_1.Confidence.MODERATE, thresholds.totalDurationMs),
72
+ value: results.durationMs,
73
+ baseline: 10000,
74
+ confidence: index_js_1.Confidence.MODERATE,
75
+ higherIsBetter: false,
76
+ provenance: [],
77
+ measuredAt: now,
78
+ },
79
+ {
80
+ name: 'failures',
81
+ health: (0, index_js_1.classify)(results.failed, index_js_1.Confidence.HIGH, (0, index_js_1.createThresholds)(0, 5, false)),
82
+ value: results.failed,
83
+ baseline: 0,
84
+ confidence: index_js_1.Confidence.HIGH,
85
+ higherIsBetter: false,
86
+ provenance: [],
87
+ measuredAt: now,
88
+ },
89
+ ];
90
+ return (0, index_js_1.createExpression)(observations, [], label || `suite (${total} tests)`);
91
+ }
92
+ /**
93
+ * Format suite health as a printable string.
94
+ */
95
+ function suiteHealthString(results, thresholds) {
96
+ const expr = classifySuite(results, thresholds);
97
+ const total = results.passed + results.failed + results.skipped;
98
+ const lines = [
99
+ `margin health: ${total} tests (${results.passed} passed, ${results.failed} failed, ${results.skipped} skipped)`,
100
+ ` ${(0, index_js_1.expressionToString)(expr)}`,
101
+ ];
102
+ return lines.join('\n');
103
+ }
104
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../src/adapters/vitest.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA4CH,sCAqEC;AAKD,8CAQC;AA5HD,0CAUqB;AAaR,QAAA,wBAAwB,GAAoB;IACvD,QAAQ,EAAE,IAAA,2BAAgB,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAS,mBAAmB;IACxE,QAAQ,EAAE,IAAA,2BAAgB,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAS,kBAAkB;IACxE,cAAc,EAAE,IAAA,2BAAgB,EAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,EAAI,kBAAkB;IACxE,eAAe,EAAE,IAAA,2BAAgB,EAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,kBAAkB;CAC5E,CAAC;AAcF,SAAgB,aAAa,CAC3B,OAAqB,EACrB,aAA8B,gCAAwB,EACtD,KAAK,GAAG,EAAE;IAEV,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,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AK,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAChE,MAAM,KAAK,GAAG;QACZ,kBAAkB,KAAK,WAAW,OAAO,CAAC,MAAM,YAAY,OAAO,CAAC,MAAM,YAAY,OAAO,CAAC,OAAO,WAAW;QAChH,KAAK,IAAA,6BAAkB,EAAC,IAAI,CAAC,EAAE;KAChC,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -11,4 +11,8 @@ export { Health, SEVERITY, Thresholds, createThresholds, isIntact, isAblated, cl
11
11
  export { Op, Observation, Correction, Expression, observationSigma, observationToAtom, observationToDict, observationFromDict, correctionIsActive, createExpression, healthOf, degraded, expressionToString, expressionToDict, Parser, } from './observation.js';
12
12
  export { DriftState, DriftDirection, DriftClassification, classifyDrift, } from './drift.js';
13
13
  export { AnomalyState, ANOMALY_SEVERITY, AnomalyClassification, classifyAnomaly, } from './anomaly.js';
14
+ export { marginMiddleware, marginHealthRoute, DEFAULT_THRESHOLDS as EXPRESS_THRESHOLDS, type MarginMiddlewareOptions, type MarginState, type EndpointThresholds, } from './adapters/express.js';
15
+ export { classifySuite, suiteHealthString, DEFAULT_SUITE_THRESHOLDS, type SuiteResults, type SuiteThresholds, } from './adapters/vitest.js';
16
+ export { withMargin, withMarginApp, marginHealthHandler, marginHealthAppHandler, resetRoutes, DEFAULT_NEXTJS_THRESHOLDS, type WithMarginOptions, type NextjsThresholds, } from './adapters/nextjs.js';
17
+ export { StreamingMonitor, broadcast, marginSSE, marginSSEHandler, marginPoll, connectedClients, resetClients, } from './adapters/stream.js';
14
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,a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AY,CAAC;AAEpB,OAAO,EACL,YAAY,EAAE,gBAAgB,EAAE,qBAAqB,EACrD,eAAe,GAChB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,gBAAgB,EAAE,iBAAiB,EACnC,kBAAkB,IAAI,kBAAkB,EACxC,KAAK,uBAAuB,EAAE,KAAK,WAAW,EAAE,KAAK,kBAAkB,GACxE,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,aAAa,EAAE,iBAAiB,EAChC,wBAAwB,EACxB,KAAK,YAAY,EAAE,KAAK,eAAe,GACxC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,UAAU,EAAE,aAAa,EACzB,mBAAmB,EAAE,sBAAsB,EAC3C,WAAW,EACX,yBAAyB,EACzB,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,GAC9C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,gBAAgB,EAChB,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAClD,gBAAgB,EAAE,YAAY,GAC/B,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * Copyright (c) 2026 Cope Labs LLC. MIT License.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.classifyAnomaly = exports.ANOMALY_SEVERITY = exports.AnomalyState = exports.classifyDrift = exports.DriftDirection = exports.DriftState = exports.Parser = exports.expressionToDict = exports.expressionToString = exports.degraded = exports.healthOf = exports.createExpression = exports.correctionIsActive = exports.observationFromDict = exports.observationToDict = exports.observationToAtom = exports.observationSigma = exports.Op = exports.classify = exports.isAblated = exports.isIntact = exports.createThresholds = exports.SEVERITY = exports.Health = exports.minConfidence = exports.confidenceLt = exports.confidenceGte = exports.confidenceRank = exports.Confidence = void 0;
11
+ exports.resetClients = exports.connectedClients = exports.marginPoll = exports.marginSSEHandler = exports.marginSSE = exports.broadcast = exports.StreamingMonitor = exports.DEFAULT_NEXTJS_THRESHOLDS = exports.resetRoutes = exports.marginHealthAppHandler = exports.marginHealthHandler = exports.withMarginApp = exports.withMargin = exports.DEFAULT_SUITE_THRESHOLDS = exports.suiteHealthString = exports.classifySuite = exports.EXPRESS_THRESHOLDS = exports.marginHealthRoute = exports.marginMiddleware = exports.classifyAnomaly = exports.ANOMALY_SEVERITY = exports.AnomalyState = exports.classifyDrift = exports.DriftDirection = exports.DriftState = exports.Parser = exports.expressionToDict = exports.expressionToString = exports.degraded = exports.healthOf = exports.createExpression = exports.correctionIsActive = exports.observationFromDict = exports.observationToDict = exports.observationToAtom = exports.observationSigma = exports.Op = exports.classify = exports.isAblated = exports.isIntact = exports.createThresholds = exports.SEVERITY = exports.Health = exports.minConfidence = exports.confidenceLt = exports.confidenceGte = exports.confidenceRank = exports.Confidence = void 0;
12
12
  var confidence_js_1 = require("./confidence.js");
13
13
  Object.defineProperty(exports, "Confidence", { enumerable: true, get: function () { return confidence_js_1.Confidence; } });
14
14
  Object.defineProperty(exports, "confidenceRank", { enumerable: true, get: function () { return confidence_js_1.confidenceRank; } });
@@ -43,4 +43,28 @@ var anomaly_js_1 = require("./anomaly.js");
43
43
  Object.defineProperty(exports, "AnomalyState", { enumerable: true, get: function () { return anomaly_js_1.AnomalyState; } });
44
44
  Object.defineProperty(exports, "ANOMALY_SEVERITY", { enumerable: true, get: function () { return anomaly_js_1.ANOMALY_SEVERITY; } });
45
45
  Object.defineProperty(exports, "classifyAnomaly", { enumerable: true, get: function () { return anomaly_js_1.classifyAnomaly; } });
46
+ // Adapters
47
+ var express_js_1 = require("./adapters/express.js");
48
+ Object.defineProperty(exports, "marginMiddleware", { enumerable: true, get: function () { return express_js_1.marginMiddleware; } });
49
+ Object.defineProperty(exports, "marginHealthRoute", { enumerable: true, get: function () { return express_js_1.marginHealthRoute; } });
50
+ Object.defineProperty(exports, "EXPRESS_THRESHOLDS", { enumerable: true, get: function () { return express_js_1.DEFAULT_THRESHOLDS; } });
51
+ var vitest_js_1 = require("./adapters/vitest.js");
52
+ Object.defineProperty(exports, "classifySuite", { enumerable: true, get: function () { return vitest_js_1.classifySuite; } });
53
+ Object.defineProperty(exports, "suiteHealthString", { enumerable: true, get: function () { return vitest_js_1.suiteHealthString; } });
54
+ Object.defineProperty(exports, "DEFAULT_SUITE_THRESHOLDS", { enumerable: true, get: function () { return vitest_js_1.DEFAULT_SUITE_THRESHOLDS; } });
55
+ var nextjs_js_1 = require("./adapters/nextjs.js");
56
+ Object.defineProperty(exports, "withMargin", { enumerable: true, get: function () { return nextjs_js_1.withMargin; } });
57
+ Object.defineProperty(exports, "withMarginApp", { enumerable: true, get: function () { return nextjs_js_1.withMarginApp; } });
58
+ Object.defineProperty(exports, "marginHealthHandler", { enumerable: true, get: function () { return nextjs_js_1.marginHealthHandler; } });
59
+ Object.defineProperty(exports, "marginHealthAppHandler", { enumerable: true, get: function () { return nextjs_js_1.marginHealthAppHandler; } });
60
+ Object.defineProperty(exports, "resetRoutes", { enumerable: true, get: function () { return nextjs_js_1.resetRoutes; } });
61
+ Object.defineProperty(exports, "DEFAULT_NEXTJS_THRESHOLDS", { enumerable: true, get: function () { return nextjs_js_1.DEFAULT_NEXTJS_THRESHOLDS; } });
62
+ var stream_js_1 = require("./adapters/stream.js");
63
+ Object.defineProperty(exports, "StreamingMonitor", { enumerable: true, get: function () { return stream_js_1.StreamingMonitor; } });
64
+ Object.defineProperty(exports, "broadcast", { enumerable: true, get: function () { return stream_js_1.broadcast; } });
65
+ Object.defineProperty(exports, "marginSSE", { enumerable: true, get: function () { return stream_js_1.marginSSE; } });
66
+ Object.defineProperty(exports, "marginSSEHandler", { enumerable: true, get: function () { return stream_js_1.marginSSEHandler; } });
67
+ Object.defineProperty(exports, "marginPoll", { enumerable: true, get: function () { return stream_js_1.marginPoll; } });
68
+ Object.defineProperty(exports, "connectedClients", { enumerable: true, get: function () { return stream_js_1.connectedClients; } });
69
+ Object.defineProperty(exports, "resetClients", { enumerable: true, get: function () { return stream_js_1.resetClients; } });
46
70
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,iDAAyG;AAAhG,2GAAA,UAAU,OAAA;AAAE,+GAAA,cAAc,OAAA;AAAE,8GAAA,aAAa,OAAA;AAAE,6GAAA,YAAY,OAAA;AAAE,8GAAA,aAAa,OAAA;AAE/E,yCAGqB;AAFnB,mGAAA,MAAM,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAAc,6GAAA,gBAAgB,OAAA;AAC9C,qGAAA,QAAQ,OAAA;AAAE,sGAAA,SAAS,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAG/B,mDAM0B;AALxB,oGAAA,EAAE,OAAA;AACF,kHAAA,gBAAgB,OAAA;AAAE,mHAAA,iBAAiB,OAAA;AAAE,mHAAA,iBAAiB,OAAA;AAAE,qHAAA,mBAAmB,OAAA;AAC3E,oHAAA,kBAAkB,OAAA;AAClB,kHAAA,gBAAgB,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAAE,oHAAA,kBAAkB,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AAC1E,wGAAA,MAAM,OAAA;AAGR,uCAGoB;AAFlB,sGAAA,UAAU,OAAA;AAAE,0GAAA,cAAc,OAAA;AAC1B,yGAAA,aAAa,OAAA;AAGf,2CAGsB;AAFpB,0GAAA,YAAY,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAC9B,6GAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,iDAAyG;AAAhG,2GAAA,UAAU,OAAA;AAAE,+GAAA,cAAc,OAAA;AAAE,8GAAA,aAAa,OAAA;AAAE,6GAAA,YAAY,OAAA;AAAE,8GAAA,aAAa,OAAA;AAE/E,yCAGqB;AAFnB,mGAAA,MAAM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AAE,yGAAA,YAAY,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "margin-ts",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Typed health classification for systems that measure things. Zero dependencies.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",