@stati/core 1.16.2 → 1.17.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.
Files changed (37) hide show
  1. package/dist/core/build.d.ts +41 -12
  2. package/dist/core/build.d.ts.map +1 -1
  3. package/dist/core/build.js +92 -11
  4. package/dist/core/dev.js +3 -3
  5. package/dist/core/index.d.ts +1 -1
  6. package/dist/core/index.d.ts.map +1 -1
  7. package/dist/core/isg/ttl.js +1 -1
  8. package/dist/core/templates.d.ts +10 -1
  9. package/dist/core/templates.d.ts.map +1 -1
  10. package/dist/core/templates.js +11 -14
  11. package/dist/core/utils/glob-patterns.utils.d.ts.map +1 -1
  12. package/dist/core/utils/glob-patterns.utils.js +1 -6
  13. package/dist/index.d.ts +3 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -0
  16. package/dist/metrics/index.d.ts +38 -0
  17. package/dist/metrics/index.d.ts.map +1 -0
  18. package/dist/metrics/index.js +42 -0
  19. package/dist/metrics/noop.d.ts +12 -0
  20. package/dist/metrics/noop.d.ts.map +1 -0
  21. package/dist/metrics/noop.js +88 -0
  22. package/dist/metrics/recorder.d.ts +31 -0
  23. package/dist/metrics/recorder.d.ts.map +1 -0
  24. package/dist/metrics/recorder.js +176 -0
  25. package/dist/metrics/types.d.ts +236 -0
  26. package/dist/metrics/types.d.ts.map +1 -0
  27. package/dist/metrics/types.js +7 -0
  28. package/dist/metrics/utils/index.d.ts +9 -0
  29. package/dist/metrics/utils/index.d.ts.map +1 -0
  30. package/dist/metrics/utils/index.js +9 -0
  31. package/dist/metrics/utils/system.utils.d.ts +44 -0
  32. package/dist/metrics/utils/system.utils.d.ts.map +1 -0
  33. package/dist/metrics/utils/system.utils.js +95 -0
  34. package/dist/metrics/utils/writer.utils.d.ts +64 -0
  35. package/dist/metrics/utils/writer.utils.d.ts.map +1 -0
  36. package/dist/metrics/utils/writer.utils.js +145 -0
  37. package/package.json +1 -1
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Noop MetricRecorder implementation.
3
+ * Used when metrics collection is disabled - has zero overhead.
4
+ * (Null Object Pattern)
5
+ */
6
+ /**
7
+ * Empty function that does nothing.
8
+ */
9
+ const noop = () => {
10
+ /* intentionally empty */
11
+ };
12
+ /**
13
+ * Noop implementation of MetricRecorder.
14
+ * All methods are no-ops with minimal overhead.
15
+ */
16
+ class NoopMetricRecorder {
17
+ enabled = false;
18
+ detailed = false;
19
+ startSpan(_name) {
20
+ return noop;
21
+ }
22
+ recordPhase(_name, _durationMs) {
23
+ /* noop */
24
+ }
25
+ addToPhase(_name, _durationMs) {
26
+ /* noop */
27
+ }
28
+ increment(_name, _amount) {
29
+ /* noop */
30
+ }
31
+ setGauge(_name, _value) {
32
+ /* noop */
33
+ }
34
+ recordPageTiming(_url, _durationMs, _cached, _templatesLoaded) {
35
+ /* noop */
36
+ }
37
+ snapshotMemory() {
38
+ /* noop */
39
+ }
40
+ setISGMetrics(_metrics) {
41
+ /* noop */
42
+ }
43
+ setIncrementalMetrics(_metrics) {
44
+ /* noop */
45
+ }
46
+ finalize() {
47
+ // Return minimal valid metrics object
48
+ return {
49
+ schemaVersion: '1',
50
+ meta: {
51
+ timestamp: new Date().toISOString(),
52
+ ci: false,
53
+ nodeVersion: process.version.replace(/^v/, ''),
54
+ platform: process.platform,
55
+ arch: process.arch,
56
+ cpuCount: 1,
57
+ statiVersion: 'unknown',
58
+ command: 'build',
59
+ flags: {},
60
+ },
61
+ totals: {
62
+ durationMs: 0,
63
+ peakRssBytes: 0,
64
+ heapUsedBytes: 0,
65
+ },
66
+ phases: {},
67
+ counts: {
68
+ totalPages: 0,
69
+ renderedPages: 0,
70
+ cachedPages: 0,
71
+ assetsCopied: 0,
72
+ templatesLoaded: 0,
73
+ markdownFilesProcessed: 0,
74
+ },
75
+ isg: {
76
+ enabled: false,
77
+ cacheHitRate: 0,
78
+ manifestEntries: 0,
79
+ invalidatedEntries: 0,
80
+ },
81
+ };
82
+ }
83
+ }
84
+ /**
85
+ * Singleton noop recorder instance.
86
+ * Use this when metrics are disabled for zero-overhead operation.
87
+ */
88
+ export const noopMetricRecorder = new NoopMetricRecorder();
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Active MetricRecorder implementation.
3
+ * Uses performance.now() from node:perf_hooks for high-resolution timing.
4
+ */
5
+ import type { MetricRecorder, MetricRecorderOptions } from './types.js';
6
+ /**
7
+ * Create a MetricRecorder instance.
8
+ * Returns a noop recorder when disabled for zero overhead.
9
+ *
10
+ * @param options - Recorder configuration
11
+ * @returns MetricRecorder instance
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Create an enabled recorder
16
+ * const recorder = createMetricRecorder({ enabled: true });
17
+ *
18
+ * // Start a span
19
+ * const endSpan = recorder.startSpan('configLoadMs');
20
+ * await loadConfig();
21
+ * endSpan(); // Records duration
22
+ *
23
+ * // Increment counters
24
+ * recorder.increment('renderedPages');
25
+ *
26
+ * // Finalize and get metrics
27
+ * const metrics = recorder.finalize();
28
+ * ```
29
+ */
30
+ export declare function createMetricRecorder(options?: MetricRecorderOptions): MetricRecorder;
31
+ //# sourceMappingURL=recorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../../src/metrics/recorder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAQtB,MAAM,YAAY,CAAC;AAiNpB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,cAAc,CAaxF"}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Active MetricRecorder implementation.
3
+ * Uses performance.now() from node:perf_hooks for high-resolution timing.
4
+ */
5
+ import { performance } from 'node:perf_hooks';
6
+ import { isCI, getGitCommit, getGitBranch, getCpuCount, getPlatform, getArch, getNodeVersion, getMemoryUsage, } from './utils/index.js';
7
+ import { noopMetricRecorder } from './noop.js';
8
+ /**
9
+ * Active metric recorder that collects build performance data.
10
+ */
11
+ class ActiveMetricRecorder {
12
+ enabled = true;
13
+ detailed;
14
+ startTime;
15
+ command;
16
+ flags;
17
+ statiVersion;
18
+ phases = {};
19
+ counts = {
20
+ totalPages: 0,
21
+ renderedPages: 0,
22
+ cachedPages: 0,
23
+ assetsCopied: 0,
24
+ templatesLoaded: 0,
25
+ markdownFilesProcessed: 0,
26
+ };
27
+ isgMetrics = {
28
+ enabled: false,
29
+ cacheHitRate: 0,
30
+ manifestEntries: 0,
31
+ invalidatedEntries: 0,
32
+ };
33
+ incrementalMetrics;
34
+ pageTimings = [];
35
+ gauges = new Map();
36
+ constructor(options = {}) {
37
+ this.startTime = performance.now();
38
+ this.detailed = options.detailed ?? false;
39
+ this.command = options.command ?? 'build';
40
+ this.flags = options.flags ?? {};
41
+ this.statiVersion = options.statiVersion ?? 'unknown';
42
+ // Take initial memory snapshot
43
+ this.snapshotMemory();
44
+ }
45
+ startSpan(name) {
46
+ const spanStart = performance.now();
47
+ return () => {
48
+ const duration = performance.now() - spanStart;
49
+ this.recordPhase(name, duration);
50
+ };
51
+ }
52
+ recordPhase(name, durationMs) {
53
+ // Record phase timing using the phase name directly (replaces)
54
+ this.phases[name] = durationMs;
55
+ }
56
+ addToPhase(name, durationMs) {
57
+ // Add to existing phase timing (accumulates)
58
+ const current = this.phases[name] ?? 0;
59
+ this.phases[name] = current + durationMs;
60
+ }
61
+ increment(name, amount = 1) {
62
+ const current = this.counts[name] ?? 0;
63
+ this.counts[name] = current + amount;
64
+ }
65
+ setGauge(name, value) {
66
+ // Gauges track the maximum value observed for a given name
67
+ const current = this.gauges.get(name) ?? 0;
68
+ this.gauges.set(name, Math.max(current, value));
69
+ }
70
+ recordPageTiming(url, durationMs, cached, templatesLoaded) {
71
+ if (this.detailed) {
72
+ const timing = { url, durationMs, cached };
73
+ if (templatesLoaded !== undefined) {
74
+ this.pageTimings.push({ ...timing, templatesLoaded });
75
+ }
76
+ else {
77
+ this.pageTimings.push(timing);
78
+ }
79
+ }
80
+ }
81
+ snapshotMemory() {
82
+ const usage = getMemoryUsage();
83
+ this.setGauge('peakRss', usage.rss);
84
+ }
85
+ setISGMetrics(metrics) {
86
+ this.isgMetrics = { ...this.isgMetrics, ...metrics };
87
+ }
88
+ setIncrementalMetrics(metrics) {
89
+ this.incrementalMetrics = metrics;
90
+ }
91
+ finalize() {
92
+ // Take final memory snapshot
93
+ this.snapshotMemory();
94
+ const finalMemory = getMemoryUsage();
95
+ const totalDuration = performance.now() - this.startTime;
96
+ // Build the meta object, excluding undefined git values
97
+ const gitCommit = getGitCommit();
98
+ const gitBranch = getGitBranch();
99
+ const meta = {
100
+ timestamp: new Date().toISOString(),
101
+ ci: isCI(),
102
+ nodeVersion: getNodeVersion(),
103
+ platform: getPlatform(),
104
+ arch: getArch(),
105
+ cpuCount: getCpuCount(),
106
+ statiVersion: this.statiVersion,
107
+ command: this.command,
108
+ flags: this.flags,
109
+ ...(gitCommit !== undefined && { gitCommit }),
110
+ ...(gitBranch !== undefined && { gitBranch }),
111
+ };
112
+ // Build the base metrics object
113
+ const baseMetrics = {
114
+ schemaVersion: '1',
115
+ meta,
116
+ totals: {
117
+ durationMs: totalDuration,
118
+ peakRssBytes: this.peakRss,
119
+ heapUsedBytes: finalMemory.heapUsed,
120
+ },
121
+ phases: this.phases,
122
+ counts: this.counts,
123
+ isg: this.isgMetrics,
124
+ };
125
+ // Add optional fields conditionally
126
+ const optionalFields = {};
127
+ if (this.detailed && this.pageTimings.length > 0) {
128
+ optionalFields.pageTimings = this.pageTimings;
129
+ }
130
+ if (this.incrementalMetrics) {
131
+ optionalFields.incremental = this.incrementalMetrics;
132
+ }
133
+ return { ...baseMetrics, ...optionalFields };
134
+ }
135
+ /**
136
+ * Get the peak RSS value from gauges.
137
+ */
138
+ get peakRss() {
139
+ return this.gauges.get('peakRss') ?? 0;
140
+ }
141
+ }
142
+ /**
143
+ * Create a MetricRecorder instance.
144
+ * Returns a noop recorder when disabled for zero overhead.
145
+ *
146
+ * @param options - Recorder configuration
147
+ * @returns MetricRecorder instance
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * // Create an enabled recorder
152
+ * const recorder = createMetricRecorder({ enabled: true });
153
+ *
154
+ * // Start a span
155
+ * const endSpan = recorder.startSpan('configLoadMs');
156
+ * await loadConfig();
157
+ * endSpan(); // Records duration
158
+ *
159
+ * // Increment counters
160
+ * recorder.increment('renderedPages');
161
+ *
162
+ * // Finalize and get metrics
163
+ * const metrics = recorder.finalize();
164
+ * ```
165
+ */
166
+ export function createMetricRecorder(options = {}) {
167
+ if (options.enabled === false) {
168
+ return noopMetricRecorder;
169
+ }
170
+ // Check environment variable for CI metrics
171
+ const envEnabled = process.env.STATI_METRICS === '1' || process.env.STATI_METRICS === 'true';
172
+ if (!options.enabled && !envEnabled) {
173
+ return noopMetricRecorder;
174
+ }
175
+ return new ActiveMetricRecorder(options);
176
+ }
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Build metrics type definitions for Stati performance measurement system.
3
+ *
4
+ * Schema version: 1
5
+ * This schema is versioned for backward compatibility.
6
+ */
7
+ /**
8
+ * Complete build metrics output format.
9
+ * Written to JSON files and used for CI regression detection.
10
+ */
11
+ export interface BuildMetrics {
12
+ /** Schema version for backward compatibility */
13
+ readonly schemaVersion: '1';
14
+ /** Run metadata */
15
+ readonly meta: MetricsMeta;
16
+ /** Total timings and memory */
17
+ readonly totals: MetricsTotals;
18
+ /** Phase breakdown (all times in milliseconds) */
19
+ readonly phases: MetricsPhases;
20
+ /** Counts */
21
+ readonly counts: MetricsCounts;
22
+ /** ISG cache metrics */
23
+ readonly isg: MetricsISG;
24
+ /** Per-page timing (optional, only when detailed tracing enabled) */
25
+ readonly pageTimings?: readonly PageTiming[];
26
+ /** Incremental rebuild metrics (dev mode only) */
27
+ readonly incremental?: IncrementalMetrics;
28
+ }
29
+ /**
30
+ * Run metadata for a build metrics report.
31
+ */
32
+ export interface MetricsMeta {
33
+ /** ISO timestamp of build start */
34
+ readonly timestamp: string;
35
+ /** Git commit SHA (if available) */
36
+ readonly gitCommit?: string;
37
+ /** Git branch (if available) */
38
+ readonly gitBranch?: string;
39
+ /** Whether running in CI environment */
40
+ readonly ci: boolean;
41
+ /** Node.js version */
42
+ readonly nodeVersion: string;
43
+ /** Platform (darwin, linux, win32) */
44
+ readonly platform: 'aix' | 'darwin' | 'freebsd' | 'linux' | 'openbsd' | 'sunos' | 'win32';
45
+ /** CPU architecture */
46
+ readonly arch: string;
47
+ /** Number of CPU cores */
48
+ readonly cpuCount: number;
49
+ /** Stati version */
50
+ readonly statiVersion: string;
51
+ /** Command executed */
52
+ readonly command: 'build' | 'dev';
53
+ /** CLI flags used */
54
+ readonly flags: MetricsFlags;
55
+ }
56
+ /**
57
+ * CLI flags captured in metrics.
58
+ */
59
+ export interface MetricsFlags {
60
+ readonly force?: boolean | undefined;
61
+ readonly clean?: boolean | undefined;
62
+ readonly includeDrafts?: boolean | undefined;
63
+ }
64
+ /**
65
+ * Total timings and memory measurements.
66
+ */
67
+ export interface MetricsTotals {
68
+ /** Total build duration in milliseconds */
69
+ readonly durationMs: number;
70
+ /** Peak RSS in bytes */
71
+ readonly peakRssBytes: number;
72
+ /** Heap used at end of build in bytes */
73
+ readonly heapUsedBytes: number;
74
+ }
75
+ /**
76
+ * Phase breakdown timings in milliseconds.
77
+ * All fields are optional as not all phases run in every build.
78
+ */
79
+ export interface MetricsPhases {
80
+ readonly configLoadMs?: number;
81
+ readonly contentDiscoveryMs?: number;
82
+ readonly navigationBuildMs?: number;
83
+ readonly cacheManifestLoadMs?: number;
84
+ readonly typescriptCompileMs?: number;
85
+ readonly pageRenderingMs?: number;
86
+ readonly assetCopyMs?: number;
87
+ readonly cacheManifestSaveMs?: number;
88
+ readonly sitemapGenerationMs?: number;
89
+ readonly rssGenerationMs?: number;
90
+ /** Build hooks - only recorded when hooks are configured */
91
+ readonly hookBeforeAllMs?: number;
92
+ readonly hookAfterAllMs?: number;
93
+ /** Aggregate time spent in beforeRender hooks across all pages */
94
+ readonly hookBeforeRenderTotalMs?: number;
95
+ /** Aggregate time spent in afterRender hooks across all pages */
96
+ readonly hookAfterRenderTotalMs?: number;
97
+ }
98
+ /**
99
+ * Phase names as a union type for type safety.
100
+ */
101
+ export type PhaseName = keyof MetricsPhases;
102
+ /**
103
+ * Counts of various build artifacts.
104
+ */
105
+ export interface MetricsCounts {
106
+ readonly totalPages: number;
107
+ readonly renderedPages: number;
108
+ readonly cachedPages: number;
109
+ readonly assetsCopied: number;
110
+ readonly templatesLoaded: number;
111
+ readonly markdownFilesProcessed: number;
112
+ }
113
+ /**
114
+ * Counter names as a union type for type safety.
115
+ */
116
+ export type CounterName = keyof MetricsCounts;
117
+ /**
118
+ * Known gauge names as a union type for type safety.
119
+ * Gauges are point-in-time values that can go up or down (unlike counters).
120
+ */
121
+ export type GaugeName = 'peakRss';
122
+ /**
123
+ * ISG cache metrics.
124
+ */
125
+ export interface MetricsISG {
126
+ /** Whether ISG caching is enabled */
127
+ readonly enabled: boolean;
128
+ /** Cache hit rate (0..1) */
129
+ readonly cacheHitRate: number;
130
+ /** Number of entries in manifest */
131
+ readonly manifestEntries: number;
132
+ /** Number of entries invalidated this build */
133
+ readonly invalidatedEntries: number;
134
+ }
135
+ /**
136
+ * Per-page timing information.
137
+ * Only collected when detailed metrics are enabled.
138
+ */
139
+ export interface PageTiming {
140
+ /** Page URL */
141
+ readonly url: string;
142
+ /** Render duration in milliseconds */
143
+ readonly durationMs: number;
144
+ /** Whether page was served from cache */
145
+ readonly cached: boolean;
146
+ /** Number of templates loaded for this page (undefined for cached pages) */
147
+ readonly templatesLoaded?: number;
148
+ }
149
+ /**
150
+ * Incremental rebuild metrics for dev server.
151
+ */
152
+ export interface IncrementalMetrics {
153
+ /** File that triggered the rebuild */
154
+ readonly triggerFile: string;
155
+ /** Type of file that changed */
156
+ readonly triggerType: 'markdown' | 'template' | 'static' | 'config';
157
+ /** Number of pages rendered */
158
+ readonly renderedPages: number;
159
+ /** Number of pages served from cache */
160
+ readonly cachedPages: number;
161
+ /** Total rebuild duration in milliseconds */
162
+ readonly durationMs: number;
163
+ }
164
+ /**
165
+ * Options for creating a MetricRecorder.
166
+ */
167
+ export interface MetricRecorderOptions {
168
+ /** Whether metrics collection is enabled */
169
+ enabled?: boolean | undefined;
170
+ /** Whether to collect per-page timings */
171
+ detailed?: boolean | undefined;
172
+ /** Command being executed */
173
+ command?: 'build' | 'dev' | undefined;
174
+ /** CLI flags used */
175
+ flags?: MetricsFlags | undefined;
176
+ /** Stati version string */
177
+ statiVersion?: string | undefined;
178
+ }
179
+ /**
180
+ * Interface for metrics collection.
181
+ * The noop implementation has zero overhead when disabled.
182
+ */
183
+ export interface MetricRecorder {
184
+ /**
185
+ * Start a named span, returns a function to end it.
186
+ * The returned function records the duration when called.
187
+ */
188
+ startSpan(name: PhaseName): () => void;
189
+ /**
190
+ * Record a phase duration directly (replaces existing value).
191
+ */
192
+ recordPhase(name: PhaseName, durationMs: number): void;
193
+ /**
194
+ * Add to an existing phase duration (for accumulating per-page hook times).
195
+ */
196
+ addToPhase(name: PhaseName, durationMs: number): void;
197
+ /**
198
+ * Increment a counter.
199
+ */
200
+ increment(name: CounterName, amount?: number): void;
201
+ /**
202
+ * Set a gauge value (for point-in-time metrics like peak memory).
203
+ * Gauges track the maximum value observed for a given name.
204
+ */
205
+ setGauge(name: GaugeName, value: number): void;
206
+ /**
207
+ * Record page timing (only when detailed mode enabled).
208
+ * @param templatesLoaded - Number of templates loaded (optional, typically undefined for cached pages)
209
+ */
210
+ recordPageTiming(url: string, durationMs: number, cached: boolean, templatesLoaded?: number): void;
211
+ /**
212
+ * Take memory snapshot to track peak RSS.
213
+ */
214
+ snapshotMemory(): void;
215
+ /**
216
+ * Set ISG metrics.
217
+ */
218
+ setISGMetrics(metrics: Partial<MetricsISG>): void;
219
+ /**
220
+ * Set incremental rebuild metrics (dev mode).
221
+ */
222
+ setIncrementalMetrics(metrics: IncrementalMetrics): void;
223
+ /**
224
+ * Finalize and return metrics object.
225
+ */
226
+ finalize(): BuildMetrics;
227
+ /**
228
+ * Whether metrics collection is enabled.
229
+ */
230
+ readonly enabled: boolean;
231
+ /**
232
+ * Whether detailed (per-page) metrics are enabled.
233
+ */
234
+ readonly detailed: boolean;
235
+ }
236
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/metrics/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC;IAE5B,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAE3B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAE/B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAE/B,aAAa;IACb,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAE/B,wBAAwB;IACxB,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAEzB,qEAAqE;IACrE,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAE7C,kDAAkD;IAClD,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,gCAAgC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,sBAAsB;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,sCAAsC;IACtC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UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtD;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpD;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/C;;;OAGG;IACH,gBAAgB,CACd,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,EACf,eAAe,CAAC,EAAE,MAAM,GACvB,IAAI,CAAC;IAER;;OAEG;IACH,cAAc,IAAI,IAAI,CAAC;IAEvB;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAElD;;OAEG;IACH,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAEzD;;OAEG;IACH,QAAQ,IAAI,YAAY,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Build metrics type definitions for Stati performance measurement system.
3
+ *
4
+ * Schema version: 1
5
+ * This schema is versioned for backward compatibility.
6
+ */
7
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Metrics utility functions barrel export.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { isCI, getGitCommit, getGitBranch, getCpuCount, getPlatform, getArch, getMemoryUsage, getNodeVersion, } from './system.utils.js';
7
+ export { DEFAULT_METRICS_DIR, generateMetricsFilename, writeMetrics, formatMetricsSummary, } from './writer.utils.js';
8
+ export type { WriteMetricsOptions, WriteMetricsResult } from './writer.utils.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metrics/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Metrics utility functions barrel export.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ // System utilities
7
+ export { isCI, getGitCommit, getGitBranch, getCpuCount, getPlatform, getArch, getMemoryUsage, getNodeVersion, } from './system.utils.js';
8
+ // Writer utilities
9
+ export { DEFAULT_METRICS_DIR, generateMetricsFilename, writeMetrics, formatMetricsSummary, } from './writer.utils.js';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * System information utilities for metrics collection.
3
+ * Uses only Node.js built-ins to avoid external dependencies.
4
+ */
5
+ import { platform } from 'node:os';
6
+ /**
7
+ * Detect if running in a CI environment.
8
+ */
9
+ export declare function isCI(): boolean;
10
+ /**
11
+ * Get the current Git commit SHA.
12
+ * Returns undefined if not in a git repository or git is not available.
13
+ */
14
+ export declare function getGitCommit(): string | undefined;
15
+ /**
16
+ * Get the current Git branch name.
17
+ * Returns undefined if not in a git repository or git is not available.
18
+ */
19
+ export declare function getGitBranch(): string | undefined;
20
+ /**
21
+ * Get the number of CPU cores.
22
+ */
23
+ export declare function getCpuCount(): number;
24
+ /**
25
+ * Get the current platform.
26
+ */
27
+ export declare function getPlatform(): ReturnType<typeof platform>;
28
+ /**
29
+ * Get the CPU architecture.
30
+ */
31
+ export declare function getArch(): string;
32
+ /**
33
+ * Get Node.js version string (without the 'v' prefix).
34
+ */
35
+ export declare function getNodeVersion(): string;
36
+ /**
37
+ * Get current memory usage snapshot.
38
+ */
39
+ export declare function getMemoryUsage(): {
40
+ rss: number;
41
+ heapUsed: number;
42
+ heapTotal: number;
43
+ };
44
+ //# sourceMappingURL=system.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.utils.d.ts","sourceRoot":"","sources":["../../../src/metrics/utils/system.utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAQ,QAAQ,EAAQ,MAAM,SAAS,CAAC;AAiB/C;;GAEG;AACH,wBAAgB,IAAI,IAAI,OAAO,CAE9B;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAWjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAWjD;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAEzD;AAED;;GAEG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAOA"}