@svadmin/devtools 0.2.3 → 0.3.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/README.md +11 -1
- package/dist/index.d.ts +40 -0
- package/dist/index.js +49 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,6 +13,10 @@ and the CLI can share:
|
|
|
13
13
|
resource operations, menu visibility, provider routing, and route paths.
|
|
14
14
|
- `toPermissionDiagnostic(resource, action, result)` — normalizes access-control
|
|
15
15
|
results for display.
|
|
16
|
+
- `buildAdminDiagnostics(options)` — combines the complete application snapshot,
|
|
17
|
+
provider/resource/route diagnostics, and a healthy/warning/error summary.
|
|
18
|
+
- `buildDevtoolsHealthSummary(input)` — derives a small health summary for a
|
|
19
|
+
panel badge, CLI output, or readiness check.
|
|
16
20
|
- Re-exports the whole `@svadmin/devtools-contract` surface.
|
|
17
21
|
|
|
18
22
|
UI rendering stays in `@svadmin/ui` (`DevTools.svelte`); this package is the
|
|
@@ -34,6 +38,12 @@ collector.recordDiagnostic({
|
|
|
34
38
|
|
|
35
39
|
const snapshot = collector.snapshot({ requestId: 'req-1' });
|
|
36
40
|
const providers = buildProviderDiagnostics(config.providers);
|
|
41
|
+
const diagnostics = buildAdminDiagnostics({
|
|
42
|
+
providers: config.providers,
|
|
43
|
+
resources: config.resources,
|
|
44
|
+
basePath: '/admin',
|
|
45
|
+
});
|
|
46
|
+
diagnostics.health.status; // 'healthy' | 'warning' | 'error'
|
|
37
47
|
```
|
|
38
48
|
|
|
39
|
-
Secrets are redacted by `redactDevtoolsRecord` before a snapshot is produced.
|
|
49
|
+
Secrets are redacted by `redactDevtoolsRecord` before a snapshot is produced.
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,17 @@ export { createDevtoolsSnapshot, redactDevtoolsRecord } from '@svadmin/devtools-
|
|
|
10
10
|
export type { DevtoolsCacheDiagnostics, DevtoolsDiagnostic, DevtoolsEvent, DevtoolsLocation, DevtoolsProviderDiagnostic, DevtoolsQueryDiagnostic, DevtoolsSeverity, DevtoolsSnapshot, DevtoolsSource, DevtoolsTraceContext, SvadminDevtoolsSnapshot, } from '@svadmin/devtools-contract';
|
|
11
11
|
import { type DevtoolsDiagnostic, type DevtoolsEvent, type DevtoolsProviderDiagnostic, type DevtoolsSnapshot, type DevtoolsSource, type DevtoolsTraceContext } from '@svadmin/devtools-contract';
|
|
12
12
|
import type { ProviderBundle, ResourceDefinition } from '@svadmin/core';
|
|
13
|
+
export type DevtoolsHealthStatus = 'healthy' | 'warning' | 'error';
|
|
14
|
+
export interface DevtoolsHealthSummary {
|
|
15
|
+
status: DevtoolsHealthStatus;
|
|
16
|
+
errors: number;
|
|
17
|
+
warnings: number;
|
|
18
|
+
info: number;
|
|
19
|
+
configuredProviders: number;
|
|
20
|
+
totalProviders: number;
|
|
21
|
+
resources: number;
|
|
22
|
+
routes: number;
|
|
23
|
+
}
|
|
13
24
|
export interface DevtoolsCollectorOptions {
|
|
14
25
|
source?: DevtoolsSource;
|
|
15
26
|
maxEvents?: number;
|
|
@@ -24,6 +35,22 @@ export interface DevtoolsCollector {
|
|
|
24
35
|
snapshot(context?: DevtoolsTraceContext): DevtoolsSnapshot;
|
|
25
36
|
subscribe(listener: (snapshot: DevtoolsSnapshot) => void): () => void;
|
|
26
37
|
}
|
|
38
|
+
export interface DevtoolsAppDiagnostics {
|
|
39
|
+
snapshot: DevtoolsSnapshot;
|
|
40
|
+
providers: DevtoolsProviderDiagnostic[];
|
|
41
|
+
resources: DevtoolsResourceDiagnostic[];
|
|
42
|
+
routes: DevtoolsRouteDiagnostic[];
|
|
43
|
+
health: DevtoolsHealthSummary;
|
|
44
|
+
}
|
|
45
|
+
export interface BuildAdminDiagnosticsOptions {
|
|
46
|
+
providers: ProviderBundle;
|
|
47
|
+
resources: readonly ResourceDefinition[];
|
|
48
|
+
diagnostics?: readonly DevtoolsDiagnostic[];
|
|
49
|
+
events?: readonly DevtoolsEvent[];
|
|
50
|
+
source?: DevtoolsSource;
|
|
51
|
+
context?: DevtoolsTraceContext;
|
|
52
|
+
basePath?: string;
|
|
53
|
+
}
|
|
27
54
|
/**
|
|
28
55
|
* Bounded in-memory collector. Events and diagnostics are capped so a long-lived
|
|
29
56
|
* admin session cannot grow without limit; snapshots are redacted on build.
|
|
@@ -61,3 +88,16 @@ export declare function toPermissionDiagnostic(resource: string, action: string,
|
|
|
61
88
|
can: boolean;
|
|
62
89
|
reason?: string;
|
|
63
90
|
}): DevtoolsPermissionDiagnostic;
|
|
91
|
+
export declare function buildDevtoolsHealthSummary(input: {
|
|
92
|
+
diagnostics: readonly DevtoolsDiagnostic[];
|
|
93
|
+
providers: readonly DevtoolsProviderDiagnostic[];
|
|
94
|
+
resources: readonly DevtoolsResourceDiagnostic[];
|
|
95
|
+
routes: readonly DevtoolsRouteDiagnostic[];
|
|
96
|
+
}): DevtoolsHealthSummary;
|
|
97
|
+
/**
|
|
98
|
+
* Builds the complete JSON-safe application diagnostic view used by DevTools,
|
|
99
|
+
* the CLI, and integration tests. The input contains only provider/resource
|
|
100
|
+
* metadata and already-sanitized diagnostics/events; no runtime payloads are
|
|
101
|
+
* copied into the result.
|
|
102
|
+
*/
|
|
103
|
+
export declare function buildAdminDiagnostics(options: BuildAdminDiagnosticsOptions): DevtoolsAppDiagnostics;
|
package/dist/index.js
CHANGED
|
@@ -126,3 +126,52 @@ export function toPermissionDiagnostic(resource, action, result) {
|
|
|
126
126
|
...(result.reason !== undefined ? { reason: result.reason } : {}),
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
+
export function buildDevtoolsHealthSummary(input) {
|
|
130
|
+
const errors = input.diagnostics.filter((diagnostic) => diagnostic.severity === 'error').length;
|
|
131
|
+
const warnings = input.diagnostics.filter((diagnostic) => diagnostic.severity === 'warning').length;
|
|
132
|
+
const info = input.diagnostics.filter((diagnostic) => diagnostic.severity === 'info').length;
|
|
133
|
+
const status = errors > 0
|
|
134
|
+
? 'error'
|
|
135
|
+
: warnings > 0
|
|
136
|
+
? 'warning'
|
|
137
|
+
: 'healthy';
|
|
138
|
+
return {
|
|
139
|
+
status,
|
|
140
|
+
errors,
|
|
141
|
+
warnings,
|
|
142
|
+
info,
|
|
143
|
+
configuredProviders: input.providers.filter((provider) => provider.configured).length,
|
|
144
|
+
totalProviders: input.providers.length,
|
|
145
|
+
resources: input.resources.length,
|
|
146
|
+
routes: input.routes.length,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Builds the complete JSON-safe application diagnostic view used by DevTools,
|
|
151
|
+
* the CLI, and integration tests. The input contains only provider/resource
|
|
152
|
+
* metadata and already-sanitized diagnostics/events; no runtime payloads are
|
|
153
|
+
* copied into the result.
|
|
154
|
+
*/
|
|
155
|
+
export function buildAdminDiagnostics(options) {
|
|
156
|
+
const providers = buildProviderDiagnostics(options.providers);
|
|
157
|
+
const resources = buildResourceDiagnostics(options.resources);
|
|
158
|
+
const routes = buildRouteDiagnostics(options.resources, options.basePath);
|
|
159
|
+
const diagnostics = [...(options.diagnostics ?? [])];
|
|
160
|
+
const events = [...(options.events ?? [])];
|
|
161
|
+
const context = options.context ?? {};
|
|
162
|
+
const snapshot = createDevtoolsSnapshot({
|
|
163
|
+
source: options.source ?? 'frontend',
|
|
164
|
+
diagnostics,
|
|
165
|
+
events,
|
|
166
|
+
...(context.requestId !== undefined ? { requestId: context.requestId } : {}),
|
|
167
|
+
...(context.traceId !== undefined ? { traceId: context.traceId } : {}),
|
|
168
|
+
...(context.correlationId !== undefined ? { correlationId: context.correlationId } : {}),
|
|
169
|
+
});
|
|
170
|
+
return {
|
|
171
|
+
snapshot,
|
|
172
|
+
providers,
|
|
173
|
+
resources,
|
|
174
|
+
routes,
|
|
175
|
+
health: buildDevtoolsHealthSummary({ diagnostics, providers, resources, routes }),
|
|
176
|
+
};
|
|
177
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Headless diagnostics core for svadmin — query traces, provider diagnostics, permission/resource/route inspection",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@svadmin/devtools-contract": "^0.3.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@svadmin/core": "^0.
|
|
46
|
+
"@svadmin/core": "^0.60.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@svadmin/core": {
|