@ocpp-debugkit/toolkit 0.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/LICENSE +201 -0
- package/NOTICE +14 -0
- package/README.md +35 -0
- package/dist/cli/commands/inspect.d.ts +8 -0
- package/dist/cli/commands/inspect.d.ts.map +1 -0
- package/dist/cli/commands/inspect.js +63 -0
- package/dist/cli/commands/inspect.js.map +1 -0
- package/dist/cli/commands/report.d.ts +9 -0
- package/dist/cli/commands/report.d.ts.map +1 -0
- package/dist/cli/commands/report.js +54 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/scenario.d.ts +10 -0
- package/dist/cli/commands/scenario.d.ts.map +1 -0
- package/dist/cli/commands/scenario.js +104 -0
- package/dist/cli/commands/scenario.js.map +1 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +47 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils.d.ts +13 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +43 -0
- package/dist/cli/utils.js.map +1 -0
- package/dist/core/__fixtures__/connector-fault.d.ts +116 -0
- package/dist/core/__fixtures__/connector-fault.d.ts.map +1 -0
- package/dist/core/__fixtures__/connector-fault.js +231 -0
- package/dist/core/__fixtures__/connector-fault.js.map +1 -0
- package/dist/core/__fixtures__/failed-auth.d.ts +64 -0
- package/dist/core/__fixtures__/failed-auth.d.ts.map +1 -0
- package/dist/core/__fixtures__/failed-auth.js +173 -0
- package/dist/core/__fixtures__/failed-auth.js.map +1 -0
- package/dist/core/__fixtures__/normal-session.d.ts +108 -0
- package/dist/core/__fixtures__/normal-session.d.ts.map +1 -0
- package/dist/core/__fixtures__/normal-session.js +261 -0
- package/dist/core/__fixtures__/normal-session.js.map +1 -0
- package/dist/core/detection.d.ts +23 -0
- package/dist/core/detection.d.ts.map +1 -0
- package/dist/core/detection.js +226 -0
- package/dist/core/detection.js.map +1 -0
- package/dist/core/fixtures/index.d.ts +298 -0
- package/dist/core/fixtures/index.d.ts.map +1 -0
- package/dist/core/fixtures/index.js +19 -0
- package/dist/core/fixtures/index.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/normalizer.d.ts +83 -0
- package/dist/core/normalizer.d.ts.map +1 -0
- package/dist/core/normalizer.js +289 -0
- package/dist/core/normalizer.js.map +1 -0
- package/dist/core/parser.d.ts +53 -0
- package/dist/core/parser.d.ts.map +1 -0
- package/dist/core/parser.js +282 -0
- package/dist/core/parser.js.map +1 -0
- package/dist/core/schemas.d.ts +68 -0
- package/dist/core/schemas.d.ts.map +1 -0
- package/dist/core/schemas.js +81 -0
- package/dist/core/schemas.js.map +1 -0
- package/dist/core/summarizer.d.ts +25 -0
- package/dist/core/summarizer.d.ts.map +1 -0
- package/dist/core/summarizer.js +47 -0
- package/dist/core/summarizer.js.map +1 -0
- package/dist/core/timeline.d.ts +26 -0
- package/dist/core/timeline.d.ts.map +1 -0
- package/dist/core/timeline.js +318 -0
- package/dist/core/timeline.js.map +1 -0
- package/dist/core/types.d.ts +160 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +9 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/validator.d.ts +33 -0
- package/dist/core/validator.d.ts.map +1 -0
- package/dist/core/validator.js +122 -0
- package/dist/core/validator.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/react/components.d.ts +50 -0
- package/dist/react/components.d.ts.map +1 -0
- package/dist/react/components.js +49 -0
- package/dist/react/components.js.map +1 -0
- package/dist/react/index.d.ts +11 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +10 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/types.d.ts +33 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/types.js +5 -0
- package/dist/react/types.js.map +1 -0
- package/dist/replay/engine.d.ts +55 -0
- package/dist/replay/engine.d.ts.map +1 -0
- package/dist/replay/engine.js +86 -0
- package/dist/replay/engine.js.map +1 -0
- package/dist/replay/index.d.ts +11 -0
- package/dist/replay/index.d.ts.map +1 -0
- package/dist/replay/index.js +11 -0
- package/dist/replay/index.js.map +1 -0
- package/dist/reporter/index.d.ts +6 -0
- package/dist/reporter/index.d.ts.map +1 -0
- package/dist/reporter/index.js +5 -0
- package/dist/reporter/index.js.map +1 -0
- package/dist/reporter/markdown.d.ts +20 -0
- package/dist/reporter/markdown.d.ts.map +1 -0
- package/dist/reporter/markdown.js +181 -0
- package/dist/reporter/markdown.js.map +1 -0
- package/dist/reporter/types.d.ts +34 -0
- package/dist/reporter/types.d.ts.map +1 -0
- package/dist/reporter/types.js +9 -0
- package/dist/reporter/types.js.map +1 -0
- package/dist/scenarios/__scenarios__/station-offline.d.ts +94 -0
- package/dist/scenarios/__scenarios__/station-offline.d.ts.map +1 -0
- package/dist/scenarios/__scenarios__/station-offline.js +168 -0
- package/dist/scenarios/__scenarios__/station-offline.js.map +1 -0
- package/dist/scenarios/__scenarios__/unexpected-stop-reason.d.ts +112 -0
- package/dist/scenarios/__scenarios__/unexpected-stop-reason.d.ts.map +1 -0
- package/dist/scenarios/__scenarios__/unexpected-stop-reason.js +216 -0
- package/dist/scenarios/__scenarios__/unexpected-stop-reason.js.map +1 -0
- package/dist/scenarios/index.d.ts +21 -0
- package/dist/scenarios/index.d.ts.map +1 -0
- package/dist/scenarios/index.js +61 -0
- package/dist/scenarios/index.js.map +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for OCPP DebugKit.
|
|
3
|
+
*
|
|
4
|
+
* These are the proposed canonical types from the M0.5 design phase
|
|
5
|
+
* (ADR-0003 through ADR-0006). They will be fully implemented with Zod
|
|
6
|
+
* schemas in v0.1.0 (Issue #13).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Direction of an OCPP message.
|
|
10
|
+
* @see ADR-0004
|
|
11
|
+
*/
|
|
12
|
+
export type Direction = 'CS_TO_CSMS' | 'CSMS_TO_CS' | 'UNKNOWN';
|
|
13
|
+
/**
|
|
14
|
+
* OCPP 1.6 JSON message type.
|
|
15
|
+
* - Call (2): request from one side to the other.
|
|
16
|
+
* - CallResult (3): successful response.
|
|
17
|
+
* - CallError (4): error response.
|
|
18
|
+
*/
|
|
19
|
+
export type MessageType = 'Call' | 'CallResult' | 'CallError';
|
|
20
|
+
/**
|
|
21
|
+
* A raw OCPP 1.6 JSON message as it appears on the wire.
|
|
22
|
+
* The shape depends on the message type:
|
|
23
|
+
* - Call: [2, UniqueId, Action, Payload]
|
|
24
|
+
* - CallResult: [3, UniqueId, Payload]
|
|
25
|
+
* - CallError: [4, UniqueId, ErrorCode, ErrorDescription, ErrorDetails]
|
|
26
|
+
*/
|
|
27
|
+
export type RawOcppMessage = [number, string, ...unknown[]];
|
|
28
|
+
/**
|
|
29
|
+
* A trace event entry as it appears in a trace file (JSON Object or JSONL).
|
|
30
|
+
* This is the input shape before normalization.
|
|
31
|
+
*/
|
|
32
|
+
export interface TraceEventInput {
|
|
33
|
+
/** ISO 8601 string or Unix epoch (ms or s). Optional. */
|
|
34
|
+
timestamp?: string | number | null;
|
|
35
|
+
/** Direction of the message. Inferred if absent. */
|
|
36
|
+
direction?: Direction;
|
|
37
|
+
/** Raw OCPP 1.6 JSON message array. */
|
|
38
|
+
message: RawOcppMessage;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The canonical normalized event used internally by DebugKit.
|
|
42
|
+
* @see ADR-0003
|
|
43
|
+
*/
|
|
44
|
+
export interface Event {
|
|
45
|
+
/** Generated unique event ID (sequential, stable within a parse). */
|
|
46
|
+
id: string;
|
|
47
|
+
/** OCPP UniqueId from the message array. */
|
|
48
|
+
messageId: string;
|
|
49
|
+
/** Normalized timestamp in epoch milliseconds. null if missing. */
|
|
50
|
+
timestamp: number | null;
|
|
51
|
+
/** Direction of the message. */
|
|
52
|
+
direction: Direction;
|
|
53
|
+
/** OCPP message type. */
|
|
54
|
+
messageType: MessageType;
|
|
55
|
+
/** OCPP action name (e.g., "BootNotification"). Present only for Call messages. */
|
|
56
|
+
action: string | null;
|
|
57
|
+
/** OCPP payload object. */
|
|
58
|
+
payload: unknown;
|
|
59
|
+
/** Error code, present only for CallError messages. */
|
|
60
|
+
errorCode: string | null;
|
|
61
|
+
/** Error description, present only for CallError messages. */
|
|
62
|
+
errorDescription: string | null;
|
|
63
|
+
/** The original raw OCPP message array, unmodified. */
|
|
64
|
+
rawMessage: RawOcppMessage;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Metadata for a trace file.
|
|
68
|
+
*/
|
|
69
|
+
export interface TraceMetadata {
|
|
70
|
+
stationId?: string;
|
|
71
|
+
ocppVersion?: string;
|
|
72
|
+
source?: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The JSON Object trace format.
|
|
77
|
+
* @see ADR-0002, docs/trace-format-spec.md
|
|
78
|
+
*/
|
|
79
|
+
export interface Trace {
|
|
80
|
+
traceId?: string;
|
|
81
|
+
metadata?: TraceMetadata;
|
|
82
|
+
events: TraceEventInput[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A logical charging session derived from trace events.
|
|
86
|
+
* @see ADR-0006
|
|
87
|
+
*/
|
|
88
|
+
export interface Session {
|
|
89
|
+
sessionId: string;
|
|
90
|
+
stationId: string;
|
|
91
|
+
connectorId: number | null;
|
|
92
|
+
transactionId: number | null;
|
|
93
|
+
startTime: number | null;
|
|
94
|
+
endTime: number | null;
|
|
95
|
+
events: Event[];
|
|
96
|
+
status: 'active' | 'completed' | 'aborted';
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A warning produced during parsing when an individual event is malformed.
|
|
100
|
+
* @see ADR-0007
|
|
101
|
+
*/
|
|
102
|
+
export interface ParseWarning {
|
|
103
|
+
index: number;
|
|
104
|
+
message: string;
|
|
105
|
+
rawInput?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Result of parsing a trace.
|
|
109
|
+
*/
|
|
110
|
+
export interface ParseResult {
|
|
111
|
+
events: Event[];
|
|
112
|
+
warnings: ParseWarning[];
|
|
113
|
+
}
|
|
114
|
+
/** Severity of a detected failure. */
|
|
115
|
+
export type FailureSeverity = 'critical' | 'warning' | 'info';
|
|
116
|
+
/** Failure rule codes implemented in v0.1. */
|
|
117
|
+
export type FailureCode = 'FAILED_AUTHORIZATION' | 'CONNECTOR_FAULT' | 'STATION_OFFLINE_DURING_SESSION';
|
|
118
|
+
/**
|
|
119
|
+
* A detected failure in a trace.
|
|
120
|
+
*/
|
|
121
|
+
export interface Failure {
|
|
122
|
+
/** Failure rule code. */
|
|
123
|
+
code: FailureCode;
|
|
124
|
+
/** Human-readable description. */
|
|
125
|
+
description: string;
|
|
126
|
+
/** Severity level. */
|
|
127
|
+
severity: FailureSeverity;
|
|
128
|
+
/** Event IDs associated with the failure. */
|
|
129
|
+
eventIds: string[];
|
|
130
|
+
/** Suggested next steps for resolution. */
|
|
131
|
+
suggestedSteps: string[];
|
|
132
|
+
}
|
|
133
|
+
/** Summary statistics for a charging session. */
|
|
134
|
+
export interface SessionSummary {
|
|
135
|
+
sessionId: string;
|
|
136
|
+
stationId: string;
|
|
137
|
+
connectorId: number | null;
|
|
138
|
+
transactionId: number | null;
|
|
139
|
+
status: 'active' | 'completed' | 'aborted';
|
|
140
|
+
eventCount: number;
|
|
141
|
+
durationMs: number | null;
|
|
142
|
+
failureCount: number;
|
|
143
|
+
/** Ordered list of actions in the session. */
|
|
144
|
+
actionSequence: string[];
|
|
145
|
+
}
|
|
146
|
+
/** Result of validating a single OCPP message. */
|
|
147
|
+
export interface ValidationResult {
|
|
148
|
+
valid: boolean;
|
|
149
|
+
errors: string[];
|
|
150
|
+
}
|
|
151
|
+
/** A scenario fixture for testing the analysis engine. */
|
|
152
|
+
export interface Scenario {
|
|
153
|
+
name: string;
|
|
154
|
+
description: string;
|
|
155
|
+
/** The trace data to analyze. */
|
|
156
|
+
trace: Trace;
|
|
157
|
+
/** Failure codes expected to be detected. */
|
|
158
|
+
expectedFailures: FailureCode[];
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,CAAC;AAM9D;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACnC,oDAAoD;IACpD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,uCAAuC;IACvC,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gCAAgC;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,yBAAyB;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,mFAAmF;IACnF,MAAM,EAAE,MAA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|
+
*
|
|
4
|
+
* These are the proposed canonical types from the M0.5 design phase
|
|
5
|
+
* (ADR-0003 through ADR-0006). They will be fully implemented with Zod
|
|
6
|
+
* schemas in v0.1.0 (Issue #13).
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OCPP message validator — checks structural compliance of individual messages.
|
|
3
|
+
*
|
|
4
|
+
* Validates that an OCPP 1.6 JSON message conforms to the protocol's
|
|
5
|
+
* structural requirements.
|
|
6
|
+
*
|
|
7
|
+
* @see docs/trace-format-spec.md
|
|
8
|
+
*/
|
|
9
|
+
import type { Event, ValidationResult } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Validate a single OCPP message for structural compliance.
|
|
12
|
+
*
|
|
13
|
+
* Checks:
|
|
14
|
+
* - Message array has correct minimum length for its type
|
|
15
|
+
* - MessageTypeId is 2, 3, or 4
|
|
16
|
+
* - UniqueId is a non-empty string
|
|
17
|
+
* - Call messages have a string Action
|
|
18
|
+
* - CallError messages have ErrorCode and ErrorDescription
|
|
19
|
+
* - MessageType field is consistent with raw message's MessageTypeId
|
|
20
|
+
*
|
|
21
|
+
* @param event - The event to validate
|
|
22
|
+
* @param allEvents - Optional: all events in the trace (for Call/Response matching)
|
|
23
|
+
* @returns Validation result with errors array
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateMessage(event: Event, allEvents?: Event[]): ValidationResult;
|
|
26
|
+
/**
|
|
27
|
+
* Validate all events in a trace.
|
|
28
|
+
*
|
|
29
|
+
* @param events - All events in the trace
|
|
30
|
+
* @returns Map of event ID to validation result
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateMessages(events: Event[]): Map<string, ValidationResult>;
|
|
33
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/core/validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAe,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA+FvE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAcnF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAQ/E"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OCPP message validator — checks structural compliance of individual messages.
|
|
3
|
+
*
|
|
4
|
+
* Validates that an OCPP 1.6 JSON message conforms to the protocol's
|
|
5
|
+
* structural requirements.
|
|
6
|
+
*
|
|
7
|
+
* @see docs/trace-format-spec.md
|
|
8
|
+
*/
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Validation rules
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
/**
|
|
13
|
+
* Validate the message structure based on its type.
|
|
14
|
+
*
|
|
15
|
+
* Call (2): [2, UniqueId, Action, Payload] — 4+ elements, Action is string
|
|
16
|
+
* CallResult (3): [3, UniqueId, Payload] — 3+ elements
|
|
17
|
+
* CallError (4): [4, UniqueId, ErrorCode, ErrorDescription, ErrorDetails] — 5+ elements
|
|
18
|
+
*/
|
|
19
|
+
function validateMessageStructure(event) {
|
|
20
|
+
const errors = [];
|
|
21
|
+
const msg = event.rawMessage;
|
|
22
|
+
const msgType = event.messageType;
|
|
23
|
+
// Check minimum length
|
|
24
|
+
const minLength = msgType === 'Call' ? 4 : msgType === 'CallResult' ? 3 : 5;
|
|
25
|
+
if (msg.length < minLength) {
|
|
26
|
+
errors.push(`${msgType} message must have at least ${minLength} elements (has ${msg.length})`);
|
|
27
|
+
}
|
|
28
|
+
// Check MessageTypeId (index 0)
|
|
29
|
+
if (msg[0] !== 2 && msg[0] !== 3 && msg[0] !== 4) {
|
|
30
|
+
errors.push(`Invalid MessageTypeId: ${msg[0]} (expected 2, 3, or 4)`);
|
|
31
|
+
}
|
|
32
|
+
// Check UniqueId (index 1)
|
|
33
|
+
if (typeof msg[1] !== 'string' || msg[1] === '') {
|
|
34
|
+
errors.push('UniqueId (index 1) must be a non-empty string');
|
|
35
|
+
}
|
|
36
|
+
// Call-specific: Action (index 2) must be a string
|
|
37
|
+
if (msgType === 'Call') {
|
|
38
|
+
if (typeof msg[2] !== 'string' || msg[2] === '') {
|
|
39
|
+
errors.push('Call Action (index 2) must be a non-empty string');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// CallError-specific: ErrorCode and ErrorDescription
|
|
43
|
+
if (msgType === 'CallError') {
|
|
44
|
+
if (typeof msg[2] !== 'string' || msg[2] === '') {
|
|
45
|
+
errors.push('CallError ErrorCode (index 2) must be a non-empty string');
|
|
46
|
+
}
|
|
47
|
+
if (typeof msg[3] !== 'string') {
|
|
48
|
+
errors.push('CallError ErrorDescription (index 3) must be a string');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return errors;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Validate that the event's messageType matches the raw message's MessageTypeId.
|
|
55
|
+
*/
|
|
56
|
+
function validateTypeConsistency(event) {
|
|
57
|
+
const errors = [];
|
|
58
|
+
const expectedType = event.rawMessage[0] === 2 ? 'Call' : event.rawMessage[0] === 3 ? 'CallResult' : 'CallError';
|
|
59
|
+
if (event.messageType !== expectedType) {
|
|
60
|
+
errors.push(`MessageType mismatch: event says "${event.messageType}" but raw message has MessageTypeId ${event.rawMessage[0]} ("${expectedType}")`);
|
|
61
|
+
}
|
|
62
|
+
return errors;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Validate that CallResult/CallError have a matching Call.
|
|
66
|
+
* This is a soft validation — the function checks if there's a Call with
|
|
67
|
+
* the same messageId in the provided event list.
|
|
68
|
+
*/
|
|
69
|
+
function validateResponseHasCall(event, allEvents) {
|
|
70
|
+
const errors = [];
|
|
71
|
+
if (event.messageType === 'CallResult' || event.messageType === 'CallError') {
|
|
72
|
+
const hasCall = allEvents.some((e) => e.messageType === 'Call' && e.messageId === event.messageId);
|
|
73
|
+
if (!hasCall) {
|
|
74
|
+
errors.push(`${event.messageType} with messageId "${event.messageId}" has no matching Call`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return errors;
|
|
78
|
+
}
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// validateMessage()
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
/**
|
|
83
|
+
* Validate a single OCPP message for structural compliance.
|
|
84
|
+
*
|
|
85
|
+
* Checks:
|
|
86
|
+
* - Message array has correct minimum length for its type
|
|
87
|
+
* - MessageTypeId is 2, 3, or 4
|
|
88
|
+
* - UniqueId is a non-empty string
|
|
89
|
+
* - Call messages have a string Action
|
|
90
|
+
* - CallError messages have ErrorCode and ErrorDescription
|
|
91
|
+
* - MessageType field is consistent with raw message's MessageTypeId
|
|
92
|
+
*
|
|
93
|
+
* @param event - The event to validate
|
|
94
|
+
* @param allEvents - Optional: all events in the trace (for Call/Response matching)
|
|
95
|
+
* @returns Validation result with errors array
|
|
96
|
+
*/
|
|
97
|
+
export function validateMessage(event, allEvents) {
|
|
98
|
+
const errors = [];
|
|
99
|
+
errors.push(...validateMessageStructure(event));
|
|
100
|
+
errors.push(...validateTypeConsistency(event));
|
|
101
|
+
if (allEvents) {
|
|
102
|
+
errors.push(...validateResponseHasCall(event, allEvents));
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
valid: errors.length === 0,
|
|
106
|
+
errors,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Validate all events in a trace.
|
|
111
|
+
*
|
|
112
|
+
* @param events - All events in the trace
|
|
113
|
+
* @returns Map of event ID to validation result
|
|
114
|
+
*/
|
|
115
|
+
export function validateMessages(events) {
|
|
116
|
+
const results = new Map();
|
|
117
|
+
for (const event of events) {
|
|
118
|
+
results.set(event.id, validateMessage(event, events));
|
|
119
|
+
}
|
|
120
|
+
return results;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/core/validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;GAMG;AACH,SAAS,wBAAwB,CAAC,KAAY;IAC5C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC;IAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC;IAElC,uBAAuB;IACvB,MAAM,SAAS,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,IAAI,GAAG,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,+BAA+B,SAAS,kBAAkB,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;IACjG,CAAC;IAED,gCAAgC;IAChC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,MAAM,CAAC,IAAI,CAAC,0BAA0B,GAAG,CAAC,CAAC,CAAC,wBAA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J,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,MAAM,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEpD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ocpp-debugkit/toolkit — Open-source DevTools for debugging OCPP charging sessions.
|
|
3
|
+
*
|
|
4
|
+
* @module @ocpp-debugkit/toolkit
|
|
5
|
+
*
|
|
6
|
+
* The root barrel re-exports the most commonly used functions from the
|
|
7
|
+
* core module. For full modular consumption, use subpath exports:
|
|
8
|
+
*
|
|
9
|
+
* import { parseTrace } from '@ocpp-debugkit/toolkit/core';
|
|
10
|
+
* import { builtInScenarios } from '@ocpp-debugkit/toolkit/scenarios';
|
|
11
|
+
* import { generateMarkdownReport } from '@ocpp-debugkit/toolkit/reporter';
|
|
12
|
+
* import { ReplayEngine } from '@ocpp-debugkit/toolkit/replay';
|
|
13
|
+
* import { SessionTimeline } from '@ocpp-debugkit/toolkit/react';
|
|
14
|
+
*/
|
|
15
|
+
export { parseTrace, ParseError, MAX_INPUT_SIZE_BYTES, MAX_EVENT_COUNT, type TraceFormat, } from './core/index.js';
|
|
16
|
+
export { normalizeEvents, normalizeTimestamp, inferDirection, reverseDirection, classifyMessageType, extractAction, extractPayload, extractErrorCode, extractErrorDescription, } from './core/index.js';
|
|
17
|
+
export { buildSessionTimeline } from './core/index.js';
|
|
18
|
+
export { detectFailures } from './core/index.js';
|
|
19
|
+
export { summarizeSession, summarizeSessions } from './core/index.js';
|
|
20
|
+
export { validateMessage, validateMessages } from './core/index.js';
|
|
21
|
+
export type { Trace, Event, Session, Failure, Scenario, SessionSummary, ValidationResult, RawOcppMessage, Direction, MessageType, FailureSeverity, FailureCode, TraceEventInput, TraceMetadata, ParseWarning, ParseResult, } from './core/index.js';
|
|
22
|
+
export { directionSchema, messageTypeSchema, rawOcppMessageSchema, traceEventInputSchema, traceMetadataSchema, traceSchema, bareArraySchema, } from './core/index.js';
|
|
23
|
+
export { fixtures, fixtureNames } from './core/index.js';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EACL,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGpE,YAAY,EACV,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,WAAW,EACX,eAAe,EACf,WAAW,EACX,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ocpp-debugkit/toolkit — Open-source DevTools for debugging OCPP charging sessions.
|
|
3
|
+
*
|
|
4
|
+
* @module @ocpp-debugkit/toolkit
|
|
5
|
+
*
|
|
6
|
+
* The root barrel re-exports the most commonly used functions from the
|
|
7
|
+
* core module. For full modular consumption, use subpath exports:
|
|
8
|
+
*
|
|
9
|
+
* import { parseTrace } from '@ocpp-debugkit/toolkit/core';
|
|
10
|
+
* import { builtInScenarios } from '@ocpp-debugkit/toolkit/scenarios';
|
|
11
|
+
* import { generateMarkdownReport } from '@ocpp-debugkit/toolkit/reporter';
|
|
12
|
+
* import { ReplayEngine } from '@ocpp-debugkit/toolkit/replay';
|
|
13
|
+
* import { SessionTimeline } from '@ocpp-debugkit/toolkit/react';
|
|
14
|
+
*/
|
|
15
|
+
// Re-export the most commonly used core functions for convenience
|
|
16
|
+
export { parseTrace, ParseError, MAX_INPUT_SIZE_BYTES, MAX_EVENT_COUNT, } from './core/index.js';
|
|
17
|
+
export { normalizeEvents, normalizeTimestamp, inferDirection, reverseDirection, classifyMessageType, extractAction, extractPayload, extractErrorCode, extractErrorDescription, } from './core/index.js';
|
|
18
|
+
export { buildSessionTimeline } from './core/index.js';
|
|
19
|
+
export { detectFailures } from './core/index.js';
|
|
20
|
+
export { summarizeSession, summarizeSessions } from './core/index.js';
|
|
21
|
+
export { validateMessage, validateMessages } from './core/index.js';
|
|
22
|
+
// Re-export schemas
|
|
23
|
+
export { directionSchema, messageTypeSchema, rawOcppMessageSchema, traceEventInputSchema, traceMetadataSchema, traceSchema, bareArraySchema, } from './core/index.js';
|
|
24
|
+
// Re-export fixtures
|
|
25
|
+
export { fixtures, fixtureNames } from './core/index.js';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,kEAAkE;AAClE,OAAO,EACL,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAsBpE,oBAAoB;AACpB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,qBAAqB;AACrB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React component stubs for @ocpp-debugkit/toolkit/react.
|
|
3
|
+
*
|
|
4
|
+
* v0.2.0: These are stub implementations — presentational components
|
|
5
|
+
* that will be fully extracted from the Inspector in Phase 4.
|
|
6
|
+
* They are functional but minimal, using no external CSS framework.
|
|
7
|
+
*/
|
|
8
|
+
import type { SessionTimelineProps, MessageInspectorProps, FailureSummaryProps, ReportViewerProps, ReplayControlsProps } from './types.js';
|
|
9
|
+
export declare function SessionTimeline({ events, selectedEventId, onSelectEvent }: SessionTimelineProps): {
|
|
10
|
+
readonly type: "SessionTimeline";
|
|
11
|
+
readonly props: {
|
|
12
|
+
readonly events: import("../index.js").Event[];
|
|
13
|
+
readonly selectedEventId: string | null | undefined;
|
|
14
|
+
readonly onSelectEvent: ((eventId: string) => void) | undefined;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function MessageInspector({ event }: MessageInspectorProps): {
|
|
18
|
+
readonly type: "MessageInspector";
|
|
19
|
+
readonly props: {
|
|
20
|
+
readonly event: import("../index.js").Event | null;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare function FailureSummary({ failures }: FailureSummaryProps): {
|
|
24
|
+
readonly type: "FailureSummary";
|
|
25
|
+
readonly props: {
|
|
26
|
+
readonly failures: import("../index.js").Failure[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare function ReportViewer({ html }: ReportViewerProps): {
|
|
30
|
+
readonly type: "ReportViewer";
|
|
31
|
+
readonly props: {
|
|
32
|
+
readonly html: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare function ReplayControls({ isPlaying, currentIndex, totalEvents, onPlay, onPause, onStep, onStepBack, onJump, speed, onSpeedChange, }: ReplayControlsProps): {
|
|
36
|
+
readonly type: "ReplayControls";
|
|
37
|
+
readonly props: {
|
|
38
|
+
readonly isPlaying: boolean;
|
|
39
|
+
readonly currentIndex: number;
|
|
40
|
+
readonly totalEvents: number;
|
|
41
|
+
readonly onPlay: () => void;
|
|
42
|
+
readonly onPause: () => void;
|
|
43
|
+
readonly onStep: () => void;
|
|
44
|
+
readonly onStepBack: () => void;
|
|
45
|
+
readonly onJump: (index: number) => void;
|
|
46
|
+
readonly speed: number | undefined;
|
|
47
|
+
readonly onSpeedChange: ((speed: number) => void) | undefined;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/react/components.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,EAAE,oBAAoB;;;;;;;EAK/F;AAED,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE,qBAAqB;;;;;EAKhE;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,mBAAmB;;;;;EAK/D;AAED,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE,iBAAiB;;;;;EAKvD;AAED,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,YAAY,EACZ,WAAW,EACX,MAAM,EACN,OAAO,EACP,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,aAAa,GACd,EAAE,mBAAmB;;;;;;;;;;;;;;EAgBrB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React component stubs for @ocpp-debugkit/toolkit/react.
|
|
3
|
+
*
|
|
4
|
+
* v0.2.0: These are stub implementations — presentational components
|
|
5
|
+
* that will be fully extracted from the Inspector in Phase 4.
|
|
6
|
+
* They are functional but minimal, using no external CSS framework.
|
|
7
|
+
*/
|
|
8
|
+
export function SessionTimeline({ events, selectedEventId, onSelectEvent }) {
|
|
9
|
+
return {
|
|
10
|
+
type: 'SessionTimeline',
|
|
11
|
+
props: { events, selectedEventId, onSelectEvent },
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function MessageInspector({ event }) {
|
|
15
|
+
return {
|
|
16
|
+
type: 'MessageInspector',
|
|
17
|
+
props: { event },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function FailureSummary({ failures }) {
|
|
21
|
+
return {
|
|
22
|
+
type: 'FailureSummary',
|
|
23
|
+
props: { failures },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function ReportViewer({ html }) {
|
|
27
|
+
return {
|
|
28
|
+
type: 'ReportViewer',
|
|
29
|
+
props: { html },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function ReplayControls({ isPlaying, currentIndex, totalEvents, onPlay, onPause, onStep, onStepBack, onJump, speed, onSpeedChange, }) {
|
|
33
|
+
return {
|
|
34
|
+
type: 'ReplayControls',
|
|
35
|
+
props: {
|
|
36
|
+
isPlaying,
|
|
37
|
+
currentIndex,
|
|
38
|
+
totalEvents,
|
|
39
|
+
onPlay,
|
|
40
|
+
onPause,
|
|
41
|
+
onStep,
|
|
42
|
+
onStepBack,
|
|
43
|
+
onJump,
|
|
44
|
+
speed,
|
|
45
|
+
onSpeedChange,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/react/components.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,MAAM,UAAU,eAAe,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAwB;IAC9F,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE;KACzC,CAAC;AACb,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAE,KAAK,EAAyB;IAC/D,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,EAAE,KAAK,EAAE;KACR,CAAC;AACb,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAuB;IAC9D,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,EAAE,QAAQ,EAAE;KACX,CAAC;AACb,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAE,IAAI,EAAqB;IACtD,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,EAAE,IAAI,EAAE;KACP,CAAC;AACb,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAC7B,SAAS,EACT,YAAY,EACZ,WAAW,EACX,MAAM,EACN,OAAO,EACP,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,aAAa,GACO;IACpB,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE;YACL,SAAS;YACT,YAAY;YACZ,WAAW;YACX,MAAM;YACN,OAAO;YACP,MAAM;YACN,UAAU;YACV,MAAM;YACN,KAAK;YACL,aAAa;SACd;KACO,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable React components for OCPP DebugKit.
|
|
3
|
+
*
|
|
4
|
+
* @module @ocpp-debugkit/toolkit/react
|
|
5
|
+
*
|
|
6
|
+
* These components are presentational — they accept data as props and
|
|
7
|
+
* render UI. They are SSR-safe (no window/document access at module level).
|
|
8
|
+
*/
|
|
9
|
+
export type { SessionTimelineProps, MessageInspectorProps, FailureSummaryProps, ReportViewerProps, ReplayControlsProps, } from './types.js';
|
|
10
|
+
export { SessionTimeline, MessageInspector, FailureSummary, ReportViewer, ReplayControls, } from './components.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable React components for OCPP DebugKit.
|
|
3
|
+
*
|
|
4
|
+
* @module @ocpp-debugkit/toolkit/react
|
|
5
|
+
*
|
|
6
|
+
* These components are presentational — they accept data as props and
|
|
7
|
+
* render UI. They are SSR-safe (no window/document access at module level).
|
|
8
|
+
*/
|
|
9
|
+
export { SessionTimeline, MessageInspector, FailureSummary, ReportViewer, ReplayControls, } from './components.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop types for the React components in @ocpp-debugkit/toolkit/react.
|
|
3
|
+
*/
|
|
4
|
+
import type { Event, Failure, SessionSummary } from '../core/index.js';
|
|
5
|
+
export interface SessionTimelineProps {
|
|
6
|
+
events: Event[];
|
|
7
|
+
selectedEventId?: string | null;
|
|
8
|
+
onSelectEvent?: (eventId: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface MessageInspectorProps {
|
|
11
|
+
event: Event | null;
|
|
12
|
+
}
|
|
13
|
+
export interface FailureSummaryProps {
|
|
14
|
+
failures: Failure[];
|
|
15
|
+
}
|
|
16
|
+
export interface ReportViewerProps {
|
|
17
|
+
/** The HTML report string (from generateHtmlReport). */
|
|
18
|
+
html: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ReplayControlsProps {
|
|
21
|
+
isPlaying: boolean;
|
|
22
|
+
currentIndex: number;
|
|
23
|
+
totalEvents: number;
|
|
24
|
+
onPlay: () => void;
|
|
25
|
+
onPause: () => void;
|
|
26
|
+
onStep: () => void;
|
|
27
|
+
onStepBack: () => void;
|
|
28
|
+
onJump: (index: number) => void;
|
|
29
|
+
speed?: number;
|
|
30
|
+
onSpeedChange?: (speed: number) => void;
|
|
31
|
+
}
|
|
32
|
+
export type { SessionSummary };
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/react/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAGD,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/react/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replay engine — replays OCPP trace events in timestamp order.
|
|
3
|
+
*
|
|
4
|
+
* @module @ocpp-debugkit/toolkit/replay
|
|
5
|
+
*/
|
|
6
|
+
import type { Event, Failure } from '../core/index.js';
|
|
7
|
+
export interface ReplayEvent {
|
|
8
|
+
/** The normalized event. */
|
|
9
|
+
event: Event;
|
|
10
|
+
/** Failures detected at this event's position. */
|
|
11
|
+
failures: Failure[];
|
|
12
|
+
/** Zero-based index in the original event array. */
|
|
13
|
+
index: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ReplayState {
|
|
16
|
+
/** Events replayed so far. */
|
|
17
|
+
played: ReplayEvent[];
|
|
18
|
+
/** Events remaining. */
|
|
19
|
+
remaining: Event[];
|
|
20
|
+
/** Whether the replay is complete. */
|
|
21
|
+
complete: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ReplayOptions {
|
|
24
|
+
/** Playback speed multiplier (1 = real-time, 2 = 2x, etc.). Default: 1. */
|
|
25
|
+
speed?: number;
|
|
26
|
+
/** Start from this event index. Default: 0. */
|
|
27
|
+
startIndex?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Deterministic replay engine for OCPP traces.
|
|
31
|
+
*
|
|
32
|
+
* The engine is pure — it does not use timers or I/O. The consumer
|
|
33
|
+
* calls `step()`, `stepBack()`, or `jumpTo()` to advance the replay.
|
|
34
|
+
*/
|
|
35
|
+
export declare class ReplayEngine {
|
|
36
|
+
private readonly events;
|
|
37
|
+
private readonly failures;
|
|
38
|
+
private currentIndex;
|
|
39
|
+
constructor(events: Event[], failures?: Failure[], options?: ReplayOptions);
|
|
40
|
+
/** Total number of events. */
|
|
41
|
+
get totalEvents(): number;
|
|
42
|
+
/** Current event index (0-based). Returns -1 if no events. */
|
|
43
|
+
get current(): number;
|
|
44
|
+
/** Step forward one event. Returns the replay event, or null if complete. */
|
|
45
|
+
step(): ReplayEvent | null;
|
|
46
|
+
/** Step backward one event. Returns the replay event, or null if at start. */
|
|
47
|
+
stepBack(): ReplayEvent | null;
|
|
48
|
+
/** Jump to a specific event index. Returns the replay event, or null if out of range. */
|
|
49
|
+
jumpTo(index: number): ReplayEvent | null;
|
|
50
|
+
/** Get the current replay state snapshot. */
|
|
51
|
+
getState(): ReplayState;
|
|
52
|
+
/** Reset the replay to the beginning. */
|
|
53
|
+
reset(): void;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=engine.d.ts.map
|