@ocpp-debugkit/core 0.1.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 (54) hide show
  1. package/LICENSE +201 -0
  2. package/dist/__fixtures__/connector-fault.d.ts +116 -0
  3. package/dist/__fixtures__/connector-fault.d.ts.map +1 -0
  4. package/dist/__fixtures__/connector-fault.js +231 -0
  5. package/dist/__fixtures__/connector-fault.js.map +1 -0
  6. package/dist/__fixtures__/failed-auth.d.ts +64 -0
  7. package/dist/__fixtures__/failed-auth.d.ts.map +1 -0
  8. package/dist/__fixtures__/failed-auth.js +173 -0
  9. package/dist/__fixtures__/failed-auth.js.map +1 -0
  10. package/dist/__fixtures__/normal-session.d.ts +108 -0
  11. package/dist/__fixtures__/normal-session.d.ts.map +1 -0
  12. package/dist/__fixtures__/normal-session.js +261 -0
  13. package/dist/__fixtures__/normal-session.js.map +1 -0
  14. package/dist/detection.d.ts +23 -0
  15. package/dist/detection.d.ts.map +1 -0
  16. package/dist/detection.js +226 -0
  17. package/dist/detection.js.map +1 -0
  18. package/dist/fixtures/index.d.ts +298 -0
  19. package/dist/fixtures/index.d.ts.map +1 -0
  20. package/dist/fixtures/index.js +19 -0
  21. package/dist/fixtures/index.js.map +1 -0
  22. package/dist/index.d.ts +14 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +22 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/normalizer.d.ts +83 -0
  27. package/dist/normalizer.d.ts.map +1 -0
  28. package/dist/normalizer.js +289 -0
  29. package/dist/normalizer.js.map +1 -0
  30. package/dist/parser.d.ts +53 -0
  31. package/dist/parser.d.ts.map +1 -0
  32. package/dist/parser.js +282 -0
  33. package/dist/parser.js.map +1 -0
  34. package/dist/schemas.d.ts +68 -0
  35. package/dist/schemas.d.ts.map +1 -0
  36. package/dist/schemas.js +81 -0
  37. package/dist/schemas.js.map +1 -0
  38. package/dist/summarizer.d.ts +25 -0
  39. package/dist/summarizer.d.ts.map +1 -0
  40. package/dist/summarizer.js +47 -0
  41. package/dist/summarizer.js.map +1 -0
  42. package/dist/timeline.d.ts +26 -0
  43. package/dist/timeline.d.ts.map +1 -0
  44. package/dist/timeline.js +318 -0
  45. package/dist/timeline.js.map +1 -0
  46. package/dist/types.d.ts +160 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/types.js +9 -0
  49. package/dist/types.js.map +1 -0
  50. package/dist/validator.d.ts +33 -0
  51. package/dist/validator.d.ts.map +1 -0
  52. package/dist/validator.js +122 -0
  53. package/dist/validator.js.map +1 -0
  54. package/package.json +61 -0
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Failure detection — analyzes events and sessions for known failure patterns.
3
+ *
4
+ * Three detection rules in v0.1:
5
+ * 1. FAILED_AUTHORIZATION — Authorize response with idTagInfo.status = "Invalid"
6
+ * 2. CONNECTOR_FAULT — StatusNotification with status = "Faulted" during active session
7
+ * 3. STATION_OFFLINE_DURING_SESSION — session has StartTransaction but no StopTransaction,
8
+ * or connector transitions to Unavailable/Offline during an active transaction
9
+ *
10
+ * @see ADR-0003
11
+ */
12
+ // ---------------------------------------------------------------------------
13
+ // Suggested steps per failure code
14
+ // ---------------------------------------------------------------------------
15
+ const SUGGESTED_STEPS = {
16
+ FAILED_AUTHORIZATION: [
17
+ 'Verify the idTag is valid and not expired',
18
+ 'Check the CSMS local authorization list',
19
+ 'Ensure the idTag is not blocked or deactivated',
20
+ 'Review the Authorize response payload for rejection reason',
21
+ ],
22
+ CONNECTOR_FAULT: [
23
+ 'Inspect the physical connector for damage or debris',
24
+ 'Check the connector lock mechanism',
25
+ 'Review the errorCode field for specific fault type',
26
+ 'Check station logs for hardware diagnostics',
27
+ 'Contact hardware vendor if fault persists',
28
+ ],
29
+ STATION_OFFLINE_DURING_SESSION: [
30
+ 'Check the network connection between station and CSMS',
31
+ 'Verify the station has not lost power',
32
+ 'Review the WebSocket connection stability',
33
+ 'Check if the station firmware has a known stability issue',
34
+ 'Investigate if maintenance was performed on the station',
35
+ ],
36
+ };
37
+ const SEVERITY = {
38
+ FAILED_AUTHORIZATION: 'warning',
39
+ CONNECTOR_FAULT: 'critical',
40
+ STATION_OFFLINE_DURING_SESSION: 'critical',
41
+ };
42
+ // ---------------------------------------------------------------------------
43
+ // Payload extraction helpers
44
+ // ---------------------------------------------------------------------------
45
+ /** Extract idTagInfo.status from an Authorize CallResult. */
46
+ function getAuthorizeStatus(event) {
47
+ if (event.messageType !== 'CallResult')
48
+ return null;
49
+ const payload = event.payload;
50
+ if (typeof payload?.idTagInfo?.status === 'string') {
51
+ return payload.idTagInfo.status;
52
+ }
53
+ return null;
54
+ }
55
+ /** Extract status from a StatusNotification Call. */
56
+ function getStatusNotificationStatus(event) {
57
+ if (event.messageType !== 'Call' || event.action !== 'StatusNotification')
58
+ return null;
59
+ const payload = event.payload;
60
+ if (typeof payload?.status === 'string') {
61
+ return payload.status;
62
+ }
63
+ return null;
64
+ }
65
+ /** Extract errorCode from a StatusNotification Call. */
66
+ function getStatusNotificationErrorCode(event) {
67
+ if (event.messageType !== 'Call' || event.action !== 'StatusNotification')
68
+ return null;
69
+ const payload = event.payload;
70
+ if (typeof payload?.errorCode === 'string') {
71
+ return payload.errorCode;
72
+ }
73
+ return null;
74
+ }
75
+ // ---------------------------------------------------------------------------
76
+ // Detection rules
77
+ // ---------------------------------------------------------------------------
78
+ /**
79
+ * Rule 1: FAILED_AUTHORIZATION
80
+ * Detects Authorize responses where idTagInfo.status is "Invalid".
81
+ */
82
+ function detectFailedAuthorization(events) {
83
+ const failures = [];
84
+ for (const event of events) {
85
+ // Look for Authorize CallResult responses
86
+ if (event.messageType !== 'CallResult')
87
+ continue;
88
+ // Check if the matching Call was an Authorize
89
+ // We match by messageId — find the Call with the same messageId
90
+ const matchingCall = events.find((e) => e.messageType === 'Call' && e.action === 'Authorize' && e.messageId === event.messageId);
91
+ if (!matchingCall)
92
+ continue;
93
+ const status = getAuthorizeStatus(event);
94
+ if (status === 'Invalid') {
95
+ failures.push({
96
+ code: 'FAILED_AUTHORIZATION',
97
+ description: `Authorization rejected: idTag returned "Invalid" status (messageId: ${event.messageId})`,
98
+ severity: SEVERITY.FAILED_AUTHORIZATION,
99
+ eventIds: [matchingCall.id, event.id],
100
+ suggestedSteps: SUGGESTED_STEPS.FAILED_AUTHORIZATION,
101
+ });
102
+ }
103
+ }
104
+ return failures;
105
+ }
106
+ /**
107
+ * Rule 2: CONNECTOR_FAULT
108
+ * Detects StatusNotification with status = "Faulted" during an active session.
109
+ * A "during active session" means there's a StartTransaction before the fault
110
+ * and either no StopTransaction yet, or the fault occurs before the StopTransaction.
111
+ */
112
+ function detectConnectorFault(events) {
113
+ const failures = [];
114
+ // Find all StartTransaction Call events
115
+ const startTxIndices = events
116
+ .filter((e) => e.messageType === 'Call' && e.action === 'StartTransaction')
117
+ .map((e) => events.indexOf(e));
118
+ for (const startIndex of startTxIndices) {
119
+ const startEvent = events[startIndex];
120
+ if (!startEvent)
121
+ continue;
122
+ // Find the corresponding StopTransaction (after this StartTransaction)
123
+ let stopIndex = -1;
124
+ for (let i = startIndex + 1; i < events.length; i++) {
125
+ const ev = events[i];
126
+ if (ev && ev.messageType === 'Call' && ev.action === 'StopTransaction') {
127
+ stopIndex = i;
128
+ break;
129
+ }
130
+ }
131
+ // Look for Faulted StatusNotification between StartTransaction and StopTransaction
132
+ // (or until the end of events if no StopTransaction)
133
+ const searchEnd = stopIndex > -1 ? stopIndex : events.length;
134
+ for (let i = startIndex; i < searchEnd; i++) {
135
+ const event = events[i];
136
+ if (!event)
137
+ continue;
138
+ const status = getStatusNotificationStatus(event);
139
+ if (status === 'Faulted') {
140
+ const errorCode = getStatusNotificationErrorCode(event);
141
+ failures.push({
142
+ code: 'CONNECTOR_FAULT',
143
+ description: `Connector fault detected during active session: status "Faulted"${errorCode ? `, errorCode "${errorCode}"` : ''} (messageId: ${event.messageId})`,
144
+ severity: SEVERITY.CONNECTOR_FAULT,
145
+ eventIds: [startEvent.id, event.id],
146
+ suggestedSteps: SUGGESTED_STEPS.CONNECTOR_FAULT,
147
+ });
148
+ break; // Only report one fault per session
149
+ }
150
+ }
151
+ }
152
+ return failures;
153
+ }
154
+ /**
155
+ * Rule 3: STATION_OFFLINE_DURING_SESSION
156
+ * Detects sessions where:
157
+ * - There's a StartTransaction but no StopTransaction (session never completed)
158
+ * - OR the connector transitions to Unavailable/Offline during an active transaction
159
+ */
160
+ function detectStationOfflineDuringSession(_events, sessions) {
161
+ const failures = [];
162
+ for (const session of sessions) {
163
+ if (session.transactionId === null)
164
+ continue;
165
+ const hasStart = session.events.some((e) => e.messageType === 'Call' && e.action === 'StartTransaction');
166
+ const hasStop = session.events.some((e) => e.messageType === 'Call' && e.action === 'StopTransaction');
167
+ if (hasStart && !hasStop) {
168
+ // Session never completed — station went offline or stopped communicating
169
+ failures.push({
170
+ code: 'STATION_OFFLINE_DURING_SESSION',
171
+ description: `Session ${session.sessionId} (transaction ${session.transactionId}) has a StartTransaction but no StopTransaction — station may have gone offline during an active session`,
172
+ severity: SEVERITY.STATION_OFFLINE_DURING_SESSION,
173
+ eventIds: session.events
174
+ .filter((e) => e.messageType === 'Call' && e.action === 'StartTransaction')
175
+ .map((e) => e.id),
176
+ suggestedSteps: SUGGESTED_STEPS.STATION_OFFLINE_DURING_SESSION,
177
+ });
178
+ continue;
179
+ }
180
+ // Check for Unavailable/Offline status during the session
181
+ if (hasStart && hasStop) {
182
+ const startIndex = session.events.findIndex((e) => e.messageType === 'Call' && e.action === 'StartTransaction');
183
+ const stopIndex = session.events.findIndex((e) => e.messageType === 'Call' && e.action === 'StopTransaction');
184
+ for (let i = startIndex; i <= stopIndex; i++) {
185
+ const event = session.events[i];
186
+ if (!event)
187
+ continue;
188
+ const status = getStatusNotificationStatus(event);
189
+ if (status === 'Unavailable' || status === 'Offline') {
190
+ failures.push({
191
+ code: 'STATION_OFFLINE_DURING_SESSION',
192
+ description: `Station reported "${status}" status during active session ${session.sessionId} (transaction ${session.transactionId})`,
193
+ severity: SEVERITY.STATION_OFFLINE_DURING_SESSION,
194
+ eventIds: [event.id],
195
+ suggestedSteps: SUGGESTED_STEPS.STATION_OFFLINE_DURING_SESSION,
196
+ });
197
+ break;
198
+ }
199
+ }
200
+ }
201
+ }
202
+ return failures;
203
+ }
204
+ // ---------------------------------------------------------------------------
205
+ // detectFailures()
206
+ // ---------------------------------------------------------------------------
207
+ /**
208
+ * Detect failures in a trace by analyzing events and sessions.
209
+ *
210
+ * @param events - All normalized events from the trace
211
+ * @param sessions - Sessions derived from the events
212
+ * @returns Array of detected failures
213
+ *
214
+ * @see ADR-0003
215
+ */
216
+ export function detectFailures(events, sessions) {
217
+ const failures = [];
218
+ // Rule 1: Failed authorization
219
+ failures.push(...detectFailedAuthorization(events));
220
+ // Rule 2: Connector fault during active session
221
+ failures.push(...detectConnectorFault(events));
222
+ // Rule 3: Station offline during session
223
+ failures.push(...detectStationOfflineDuringSession(events, sessions));
224
+ return failures;
225
+ }
226
+ //# sourceMappingURL=detection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detection.js","sourceRoot":"","sources":["../src/detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,8EAA8E;AAC9E,mCAAmC;AACnC,8EAA8E;AAE9E,MAAM,eAAe,GAAkC;IACrD,oBAAoB,EAAE;QACpB,2CAA2C;QAC3C,yCAAyC;QACzC,gDAAgD;QAChD,4DAA4D;KAC7D;IACD,eAAe,EAAE;QACf,qDAAqD;QACrD,oCAAoC;QACpC,oDAAoD;QACpD,6CAA6C;QAC7C,2CAA2C;KAC5C;IACD,8BAA8B,EAAE;QAC9B,uDAAuD;QACvD,uCAAuC;QACvC,2CAA2C;QAC3C,2DAA2D;QAC3D,yDAAyD;KAC1D;CACF,CAAC;AAEF,MAAM,QAAQ,GAAyC;IACrD,oBAAoB,EAAE,SAAS;IAC/B,eAAe,EAAE,UAAU;IAC3B,8BAA8B,EAAE,UAAU;CAC3C,CAAC;AAEF,8EAA8E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cAAc,CAAC,MAAe,EAAE,QAAmB;IACjE,MAAM,QAAQ,GAAc,EAAE,CAAC;IAE/B,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpD,gDAAgD;IAChD,QAAQ,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;IAE/C,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,GAAG,iCAAiC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEtE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,298 @@
1
+ /**
2
+ * Synthetic trace fixtures for testing and development.
3
+ *
4
+ * All fixtures are fully synthetic — no real station identifiers, transaction
5
+ * IDs, idTag values, or personal data.
6
+ *
7
+ * @see docs/trace-format-spec.md
8
+ */
9
+ import normalSession from '../__fixtures__/normal-session.js';
10
+ import failedAuth from '../__fixtures__/failed-auth.js';
11
+ import connectorFault from '../__fixtures__/connector-fault.js';
12
+ export { normalSession, failedAuth, connectorFault };
13
+ export declare const fixtures: {
14
+ readonly normalSession: {
15
+ traceId: string;
16
+ metadata: {
17
+ stationId: string;
18
+ ocppVersion: string;
19
+ source: string;
20
+ description: string;
21
+ };
22
+ events: ({
23
+ timestamp: string;
24
+ direction: string;
25
+ message: (string | number | {
26
+ chargePointVendor: string;
27
+ chargePointModel: string;
28
+ chargePointSerialNumber: string;
29
+ firmwareVersion: string;
30
+ })[];
31
+ } | {
32
+ timestamp: string;
33
+ direction: string;
34
+ message: (string | number | {
35
+ currentTime: string;
36
+ interval: number;
37
+ status: string;
38
+ })[];
39
+ } | {
40
+ timestamp: string;
41
+ direction: string;
42
+ message: (string | number | {
43
+ connectorId: number;
44
+ status: string;
45
+ errorCode: string;
46
+ })[];
47
+ } | {
48
+ timestamp: string;
49
+ direction: string;
50
+ message: {}[];
51
+ } | {
52
+ timestamp: string;
53
+ direction: string;
54
+ message: (string | number | {
55
+ idTag: string;
56
+ })[];
57
+ } | {
58
+ timestamp: string;
59
+ direction: string;
60
+ message: (string | number | {
61
+ idTagInfo: {
62
+ status: string;
63
+ expiryDate: string;
64
+ parentIdTag: string;
65
+ };
66
+ })[];
67
+ } | {
68
+ timestamp: string;
69
+ direction: string;
70
+ message: (string | number | {
71
+ connectorId: number;
72
+ idTag: string;
73
+ meterStart: number;
74
+ timestamp: string;
75
+ })[];
76
+ } | {
77
+ timestamp: string;
78
+ direction: string;
79
+ message: (string | number | {
80
+ transactionId: number;
81
+ idTagInfo: {
82
+ status: string;
83
+ };
84
+ })[];
85
+ } | {
86
+ timestamp: string;
87
+ direction: string;
88
+ message: (string | number | {
89
+ connectorId: number;
90
+ transactionId: number;
91
+ meterValue: {
92
+ timestamp: string;
93
+ sampledValue: {
94
+ value: string;
95
+ measurand: string;
96
+ unit: string;
97
+ }[];
98
+ }[];
99
+ })[];
100
+ } | {
101
+ timestamp: string;
102
+ direction: string;
103
+ message: (string | number | {
104
+ transactionId: number;
105
+ idTag: string;
106
+ meterStop: number;
107
+ timestamp: string;
108
+ reason: string;
109
+ })[];
110
+ } | {
111
+ timestamp: string;
112
+ direction: string;
113
+ message: (string | number | {
114
+ idTagInfo: {
115
+ status: string;
116
+ };
117
+ })[];
118
+ })[];
119
+ };
120
+ readonly failedAuth: {
121
+ traceId: string;
122
+ metadata: {
123
+ stationId: string;
124
+ ocppVersion: string;
125
+ source: string;
126
+ description: string;
127
+ };
128
+ events: ({
129
+ timestamp: string;
130
+ direction: string;
131
+ message: (string | number | {
132
+ chargePointVendor: string;
133
+ chargePointModel: string;
134
+ chargePointSerialNumber: string;
135
+ firmwareVersion: string;
136
+ })[];
137
+ } | {
138
+ timestamp: string;
139
+ direction: string;
140
+ message: (string | number | {
141
+ currentTime: string;
142
+ interval: number;
143
+ status: string;
144
+ })[];
145
+ } | {
146
+ timestamp: string;
147
+ direction: string;
148
+ message: (string | number | {
149
+ connectorId: number;
150
+ status: string;
151
+ errorCode: string;
152
+ })[];
153
+ } | {
154
+ timestamp: string;
155
+ direction: string;
156
+ message: {}[];
157
+ } | {
158
+ timestamp: string;
159
+ direction: string;
160
+ message: (string | number | {
161
+ idTag: string;
162
+ })[];
163
+ } | {
164
+ timestamp: string;
165
+ direction: string;
166
+ message: (string | number | {
167
+ idTagInfo: {
168
+ status: string;
169
+ };
170
+ })[];
171
+ } | {
172
+ timestamp: string;
173
+ direction: string;
174
+ message: (string | number | {
175
+ connectorId: number;
176
+ status: string;
177
+ errorCode: string;
178
+ info: string;
179
+ })[];
180
+ })[];
181
+ };
182
+ readonly connectorFault: {
183
+ traceId: string;
184
+ metadata: {
185
+ stationId: string;
186
+ ocppVersion: string;
187
+ source: string;
188
+ description: string;
189
+ };
190
+ events: ({
191
+ timestamp: string;
192
+ direction: string;
193
+ message: (string | number | {
194
+ chargePointVendor: string;
195
+ chargePointModel: string;
196
+ chargePointSerialNumber: string;
197
+ firmwareVersion: string;
198
+ })[];
199
+ } | {
200
+ timestamp: string;
201
+ direction: string;
202
+ message: (string | number | {
203
+ currentTime: string;
204
+ interval: number;
205
+ status: string;
206
+ })[];
207
+ } | {
208
+ timestamp: string;
209
+ direction: string;
210
+ message: (string | number | {
211
+ connectorId: number;
212
+ status: string;
213
+ errorCode: string;
214
+ })[];
215
+ } | {
216
+ timestamp: string;
217
+ direction: string;
218
+ message: {}[];
219
+ } | {
220
+ timestamp: string;
221
+ direction: string;
222
+ message: (string | number | {
223
+ idTag: string;
224
+ })[];
225
+ } | {
226
+ timestamp: string;
227
+ direction: string;
228
+ message: (string | number | {
229
+ idTagInfo: {
230
+ status: string;
231
+ expiryDate: string;
232
+ };
233
+ })[];
234
+ } | {
235
+ timestamp: string;
236
+ direction: string;
237
+ message: (string | number | {
238
+ connectorId: number;
239
+ idTag: string;
240
+ meterStart: number;
241
+ timestamp: string;
242
+ })[];
243
+ } | {
244
+ timestamp: string;
245
+ direction: string;
246
+ message: (string | number | {
247
+ transactionId: number;
248
+ idTagInfo: {
249
+ status: string;
250
+ };
251
+ })[];
252
+ } | {
253
+ timestamp: string;
254
+ direction: string;
255
+ message: (string | number | {
256
+ connectorId: number;
257
+ transactionId: number;
258
+ meterValue: {
259
+ timestamp: string;
260
+ sampledValue: {
261
+ value: string;
262
+ measurand: string;
263
+ unit: string;
264
+ }[];
265
+ }[];
266
+ })[];
267
+ } | {
268
+ timestamp: string;
269
+ direction: string;
270
+ message: (string | number | {
271
+ connectorId: number;
272
+ status: string;
273
+ errorCode: string;
274
+ info: string;
275
+ })[];
276
+ } | {
277
+ timestamp: string;
278
+ direction: string;
279
+ message: (string | number | {
280
+ transactionId: number;
281
+ idTag: string;
282
+ meterStop: number;
283
+ timestamp: string;
284
+ reason: string;
285
+ })[];
286
+ } | {
287
+ timestamp: string;
288
+ direction: string;
289
+ message: (string | number | {
290
+ idTagInfo: {
291
+ status: string;
292
+ };
293
+ })[];
294
+ })[];
295
+ };
296
+ };
297
+ export declare const fixtureNames: readonly ["normal-session", "failed-auth", "connector-fault"];
298
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixtures/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,aAAa,MAAM,mCAAmC,CAAC;AAC9D,OAAO,UAAU,MAAM,gCAAgC,CAAC;AACxD,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAErD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIX,CAAC;AAEX,eAAO,MAAM,YAAY,+DAAgE,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Synthetic trace fixtures for testing and development.
3
+ *
4
+ * All fixtures are fully synthetic — no real station identifiers, transaction
5
+ * IDs, idTag values, or personal data.
6
+ *
7
+ * @see docs/trace-format-spec.md
8
+ */
9
+ import normalSession from '../__fixtures__/normal-session.js';
10
+ import failedAuth from '../__fixtures__/failed-auth.js';
11
+ import connectorFault from '../__fixtures__/connector-fault.js';
12
+ export { normalSession, failedAuth, connectorFault };
13
+ export const fixtures = {
14
+ normalSession,
15
+ failedAuth,
16
+ connectorFault,
17
+ };
18
+ export const fixtureNames = ['normal-session', 'failed-auth', 'connector-fault'];
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fixtures/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,aAAa,MAAM,mCAAmC,CAAC;AAC9D,OAAO,UAAU,MAAM,gCAAgC,CAAC;AACxD,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAErD,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,aAAa;IACb,UAAU;IACV,cAAc;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,CAAU,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Barrel export for the @ocpp-debugkit/core package.
3
+ */
4
+ export * from './types.js';
5
+ export * from './schemas.js';
6
+ export { parseTrace, ParseError, MAX_INPUT_SIZE_BYTES, MAX_EVENT_COUNT } from './parser.js';
7
+ export type { TraceFormat } from './parser.js';
8
+ export { normalizeEvents, normalizeTimestamp, inferDirection, reverseDirection, classifyMessageType, extractAction, extractPayload, extractErrorCode, extractErrorDescription, } from './normalizer.js';
9
+ export { buildSessionTimeline } from './timeline.js';
10
+ export { detectFailures } from './detection.js';
11
+ export { summarizeSession, summarizeSessions } from './summarizer.js';
12
+ export { validateMessage, validateMessages } from './validator.js';
13
+ export * from './fixtures/index.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,YAAY,CAAC;AAG3B,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC5F,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGtE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGnE,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Barrel export for the @ocpp-debugkit/core package.
3
+ */
4
+ // Types
5
+ export * from './types.js';
6
+ // Schemas (Zod)
7
+ export * from './schemas.js';
8
+ // Parser
9
+ export { parseTrace, ParseError, MAX_INPUT_SIZE_BYTES, MAX_EVENT_COUNT } from './parser.js';
10
+ // Normalizer
11
+ export { normalizeEvents, normalizeTimestamp, inferDirection, reverseDirection, classifyMessageType, extractAction, extractPayload, extractErrorCode, extractErrorDescription, } from './normalizer.js';
12
+ // Timeline
13
+ export { buildSessionTimeline } from './timeline.js';
14
+ // Detection
15
+ export { detectFailures } from './detection.js';
16
+ // Summarizer
17
+ export { summarizeSession, summarizeSessions } from './summarizer.js';
18
+ // Validator
19
+ export { validateMessage, validateMessages } from './validator.js';
20
+ // Fixtures
21
+ export * from './fixtures/index.js';
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,QAAQ;AACR,cAAc,YAAY,CAAC;AAE3B,gBAAgB;AAChB,cAAc,cAAc,CAAC;AAE7B,SAAS;AACT,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG5F,aAAa;AACb,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,WAAW;AACX,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,aAAa;AACb,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEtE,YAAY;AACZ,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEnE,WAAW;AACX,cAAc,qBAAqB,CAAC"}