@forinda/kickjs-devtools 2.0.1 → 2.2.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/dist/adapter.d.ts DELETED
@@ -1,109 +0,0 @@
1
- import { type AppAdapter, type AdapterContext, type AdapterMiddleware, type Ref, type ComputedRef } from '@forinda/kickjs';
2
- /** Per-route latency stats */
3
- interface RouteStats {
4
- count: number;
5
- totalMs: number;
6
- minMs: number;
7
- maxMs: number;
8
- }
9
- export interface DevToolsOptions {
10
- /** Base path for debug endpoints (default: '/_debug') */
11
- basePath?: string;
12
- /** Only enable when this is true (default: process.env.NODE_ENV !== 'production') */
13
- enabled?: boolean;
14
- /** Include environment variables (sanitized) at /_debug/config (default: false) */
15
- exposeConfig?: boolean;
16
- /** Env var prefixes to expose (default: ['APP_', 'NODE_ENV']). Others are redacted. */
17
- configPrefixes?: string[];
18
- /** Callback when error rate exceeds threshold */
19
- onErrorRateExceeded?: (rate: number) => void;
20
- /** Error rate threshold (default: 0.5 = 50%) */
21
- errorRateThreshold?: number;
22
- /** Other adapters to discover stats from (e.g., WsAdapter) */
23
- adapters?: any[];
24
- /**
25
- * Secret token to guard DevTools access. When set, all requests must
26
- * include this token as `x-devtools-token` header or `?token=` query param.
27
- *
28
- * Auto-generated on startup if not provided. The token is logged to the console.
29
- * Set to `false` to disable the guard entirely (not recommended).
30
- *
31
- * @example
32
- * ```ts
33
- * new DevToolsAdapter({ secret: process.env.DEVTOOLS_SECRET })
34
- * ```
35
- */
36
- secret?: string | false;
37
- }
38
- /**
39
- * DevToolsAdapter — Vue-style reactive introspection for KickJS applications.
40
- *
41
- * Exposes debug endpoints powered by reactive state (ref, computed, watch):
42
- * - `GET /_debug/routes` — all registered routes with middleware
43
- * - `GET /_debug/container` — DI registry with scopes and instantiation status
44
- * - `GET /_debug/metrics` — live request/error counts, error rate, uptime
45
- * - `GET /_debug/health` — deep health check with adapter status
46
- * - `GET /_debug/config` — sanitized environment variables (opt-in)
47
- * - `GET /_debug/state` — full reactive state snapshot
48
- *
49
- * @example
50
- * ```ts
51
- * import { DevToolsAdapter } from '@forinda/kickjs-devtools'
52
- *
53
- * bootstrap({
54
- * modules: [UserModule],
55
- * adapters: [
56
- * new DevToolsAdapter({
57
- * enabled: process.env.NODE_ENV !== 'production',
58
- * exposeConfig: true,
59
- * configPrefixes: ['APP_', 'DATABASE_'],
60
- * }),
61
- * ],
62
- * })
63
- * ```
64
- */
65
- export declare class DevToolsAdapter implements AppAdapter {
66
- readonly name = "DevToolsAdapter";
67
- private basePath;
68
- private enabled;
69
- private exposeConfig;
70
- private configPrefixes;
71
- private errorRateThreshold;
72
- private secret;
73
- /** Total requests received */
74
- readonly requestCount: Ref<number>;
75
- /** Total responses with status >= 500 */
76
- readonly errorCount: Ref<number>;
77
- /** Total responses with status >= 400 and < 500 */
78
- readonly clientErrorCount: Ref<number>;
79
- /** Server start time */
80
- readonly startedAt: Ref<number>;
81
- /** Computed error rate (server errors / total requests) */
82
- readonly errorRate: ComputedRef<number>;
83
- /** Computed uptime in seconds */
84
- readonly uptimeSeconds: ComputedRef<number>;
85
- /** Per-route latency tracking */
86
- readonly routeLatency: Record<string, RouteStats>;
87
- private routes;
88
- private container;
89
- private appRef;
90
- private adapterStatuses;
91
- private stopErrorWatch;
92
- private peerAdapters;
93
- constructor(options?: DevToolsOptions);
94
- /**
95
- * Resolve peer adapters at request time. Prefers live adapters from the
96
- * Application registry (survives HMR rebuild) and falls back to the
97
- * constructor-provided refs.
98
- */
99
- private getPeerAdapters;
100
- beforeMount({ app, container }: AdapterContext): void;
101
- middleware(): AdapterMiddleware[];
102
- onRouteMount(controllerClass: any, mountPath: string): void;
103
- afterStart({}: AdapterContext): void;
104
- shutdown(): void;
105
- /** Find the public/devtools directory relative to the built dist or source */
106
- private resolvePublicDir;
107
- }
108
- export {};
109
- //# sourceMappingURL=adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":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