ocpp-ws-io 2.1.15 → 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/README.md +242 -170
- package/dist/adapters/redis.d.mts +2 -2
- package/dist/adapters/redis.d.ts +2 -2
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/{index-C0mn42-8.d.mts → index-B98n5Et3.d.mts} +1 -1
- package/dist/{index-s9f97CmV.d.ts → index-xx7uU8pY.d.ts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/index.mjs +5 -5
- package/dist/plugins.d.mts +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/{types-BZXEmDQ1.d.mts → types-BunMs45p.d.mts} +37 -1
- package/dist/{types-BZXEmDQ1.d.ts → types-BunMs45p.d.ts} +37 -1
- package/package.json +113 -109
package/dist/plugins.d.ts
CHANGED
|
@@ -4735,6 +4735,16 @@ declare class OCPPClient<P extends OCPPProtocol = OCPPProtocol> extends OCPPClie
|
|
|
4735
4735
|
sendRaw(message: string): void;
|
|
4736
4736
|
reconfigure(options: Partial<ClientOptions>): void;
|
|
4737
4737
|
protected _attachWebsocket(ws: WebSocket__default): void;
|
|
4738
|
+
/**
|
|
4739
|
+
* Build an enriched message event context from middleware context.
|
|
4740
|
+
* Adds timestamp and optional latency metadata.
|
|
4741
|
+
*/
|
|
4742
|
+
private _buildMessageEventContext;
|
|
4743
|
+
/**
|
|
4744
|
+
* Emit a message event with enriched payload (direction + context).
|
|
4745
|
+
* Replaces separate call/callResult/callError events for unified observability.
|
|
4746
|
+
*/
|
|
4747
|
+
private _emitMessageEvent;
|
|
4738
4748
|
protected _onMessage(rawData: WebSocket__default.RawData, preParsed?: unknown): void;
|
|
4739
4749
|
private _handleIncomingCall;
|
|
4740
4750
|
private _handleCallResult;
|
|
@@ -5669,6 +5679,30 @@ interface AuthAccept<TSession = Record<string, unknown>> {
|
|
|
5669
5679
|
session?: TSession;
|
|
5670
5680
|
}
|
|
5671
5681
|
type AuthCallback<TSession = Record<string, unknown>> = (ctx: AuthContext<TSession>) => void | Promise<void>;
|
|
5682
|
+
/** Indicates whether a message is incoming (from peer) or outgoing (to peer) */
|
|
5683
|
+
type MessageDirection = "IN" | "OUT";
|
|
5684
|
+
/**
|
|
5685
|
+
* Enriched context for message events, combining metadata from middleware
|
|
5686
|
+
* and message flow tracking. Uses type intersection since MiddlewareContext is a union.
|
|
5687
|
+
*/
|
|
5688
|
+
type MessageEventContext = MiddlewareContext & {
|
|
5689
|
+
/** Message timestamp (ISO 8601) */
|
|
5690
|
+
timestamp: string;
|
|
5691
|
+
/** Latency in milliseconds (only for responses/results) */
|
|
5692
|
+
latencyMs?: number;
|
|
5693
|
+
};
|
|
5694
|
+
/**
|
|
5695
|
+
* Enriched message event payload with direction and context.
|
|
5696
|
+
* Replaces the simple OCPPMessage tuple for better observability.
|
|
5697
|
+
*/
|
|
5698
|
+
interface MessageEventPayload {
|
|
5699
|
+
/** The raw OCPP message */
|
|
5700
|
+
message: OCPPMessage;
|
|
5701
|
+
/** Direction of the message: IN (from peer) or OUT (to peer) */
|
|
5702
|
+
direction: MessageDirection;
|
|
5703
|
+
/** Enriched context with metadata */
|
|
5704
|
+
ctx: MessageEventContext;
|
|
5705
|
+
}
|
|
5672
5706
|
interface ClientEvents {
|
|
5673
5707
|
open: [{
|
|
5674
5708
|
response: IncomingMessage;
|
|
@@ -5689,7 +5723,7 @@ interface ClientEvents {
|
|
|
5689
5723
|
attempt: number;
|
|
5690
5724
|
delay: number;
|
|
5691
5725
|
}];
|
|
5692
|
-
message: [
|
|
5726
|
+
message: [MessageEventPayload];
|
|
5693
5727
|
call: [OCPPCall];
|
|
5694
5728
|
callResult: [OCPPCallResult];
|
|
5695
5729
|
callError: [OCPPCallError];
|
|
@@ -5740,6 +5774,8 @@ interface ServerEvents {
|
|
|
5740
5774
|
close: [];
|
|
5741
5775
|
/** I3: Structured security event for SIEM/audit pipelines */
|
|
5742
5776
|
securityEvent: [SecurityEvent];
|
|
5777
|
+
/** Enriched message event with direction and context */
|
|
5778
|
+
message: [MessageEventPayload];
|
|
5743
5779
|
connection: [
|
|
5744
5780
|
socket: WebSocket.WebSocket,
|
|
5745
5781
|
request: node_http.IncomingMessage
|
|
@@ -4735,6 +4735,16 @@ declare class OCPPClient<P extends OCPPProtocol = OCPPProtocol> extends OCPPClie
|
|
|
4735
4735
|
sendRaw(message: string): void;
|
|
4736
4736
|
reconfigure(options: Partial<ClientOptions>): void;
|
|
4737
4737
|
protected _attachWebsocket(ws: WebSocket__default): void;
|
|
4738
|
+
/**
|
|
4739
|
+
* Build an enriched message event context from middleware context.
|
|
4740
|
+
* Adds timestamp and optional latency metadata.
|
|
4741
|
+
*/
|
|
4742
|
+
private _buildMessageEventContext;
|
|
4743
|
+
/**
|
|
4744
|
+
* Emit a message event with enriched payload (direction + context).
|
|
4745
|
+
* Replaces separate call/callResult/callError events for unified observability.
|
|
4746
|
+
*/
|
|
4747
|
+
private _emitMessageEvent;
|
|
4738
4748
|
protected _onMessage(rawData: WebSocket__default.RawData, preParsed?: unknown): void;
|
|
4739
4749
|
private _handleIncomingCall;
|
|
4740
4750
|
private _handleCallResult;
|
|
@@ -5669,6 +5679,30 @@ interface AuthAccept<TSession = Record<string, unknown>> {
|
|
|
5669
5679
|
session?: TSession;
|
|
5670
5680
|
}
|
|
5671
5681
|
type AuthCallback<TSession = Record<string, unknown>> = (ctx: AuthContext<TSession>) => void | Promise<void>;
|
|
5682
|
+
/** Indicates whether a message is incoming (from peer) or outgoing (to peer) */
|
|
5683
|
+
type MessageDirection = "IN" | "OUT";
|
|
5684
|
+
/**
|
|
5685
|
+
* Enriched context for message events, combining metadata from middleware
|
|
5686
|
+
* and message flow tracking. Uses type intersection since MiddlewareContext is a union.
|
|
5687
|
+
*/
|
|
5688
|
+
type MessageEventContext = MiddlewareContext & {
|
|
5689
|
+
/** Message timestamp (ISO 8601) */
|
|
5690
|
+
timestamp: string;
|
|
5691
|
+
/** Latency in milliseconds (only for responses/results) */
|
|
5692
|
+
latencyMs?: number;
|
|
5693
|
+
};
|
|
5694
|
+
/**
|
|
5695
|
+
* Enriched message event payload with direction and context.
|
|
5696
|
+
* Replaces the simple OCPPMessage tuple for better observability.
|
|
5697
|
+
*/
|
|
5698
|
+
interface MessageEventPayload {
|
|
5699
|
+
/** The raw OCPP message */
|
|
5700
|
+
message: OCPPMessage;
|
|
5701
|
+
/** Direction of the message: IN (from peer) or OUT (to peer) */
|
|
5702
|
+
direction: MessageDirection;
|
|
5703
|
+
/** Enriched context with metadata */
|
|
5704
|
+
ctx: MessageEventContext;
|
|
5705
|
+
}
|
|
5672
5706
|
interface ClientEvents {
|
|
5673
5707
|
open: [{
|
|
5674
5708
|
response: IncomingMessage;
|
|
@@ -5689,7 +5723,7 @@ interface ClientEvents {
|
|
|
5689
5723
|
attempt: number;
|
|
5690
5724
|
delay: number;
|
|
5691
5725
|
}];
|
|
5692
|
-
message: [
|
|
5726
|
+
message: [MessageEventPayload];
|
|
5693
5727
|
call: [OCPPCall];
|
|
5694
5728
|
callResult: [OCPPCallResult];
|
|
5695
5729
|
callError: [OCPPCallError];
|
|
@@ -5740,6 +5774,8 @@ interface ServerEvents {
|
|
|
5740
5774
|
close: [];
|
|
5741
5775
|
/** I3: Structured security event for SIEM/audit pipelines */
|
|
5742
5776
|
securityEvent: [SecurityEvent];
|
|
5777
|
+
/** Enriched message event with direction and context */
|
|
5778
|
+
message: [MessageEventPayload];
|
|
5743
5779
|
connection: [
|
|
5744
5780
|
socket: WebSocket.WebSocket,
|
|
5745
5781
|
request: node_http.IncomingMessage
|
package/package.json
CHANGED
|
@@ -1,111 +1,115 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
2
|
+
"name": "ocpp-ws-io",
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "OCPP RPC WebSocket client and server for OCPP 1.6J, 2.0.1, and 2.1. Type-safe TypeScript toolkit for EV charging, CSMS backends, Redis scaling, and protocol validation.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/rohittiwari-dev/ocpp-ws-io.git"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"module": "dist/index.mjs",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"require": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./adapters/redis": {
|
|
19
|
+
"types": "./dist/adapters/redis.d.ts",
|
|
20
|
+
"import": "./dist/adapters/redis.mjs",
|
|
21
|
+
"require": "./dist/adapters/redis.js"
|
|
22
|
+
},
|
|
23
|
+
"./browser": {
|
|
24
|
+
"types": "./dist/browser.d.ts",
|
|
25
|
+
"import": "./dist/browser.mjs",
|
|
26
|
+
"require": "./dist/browser.js"
|
|
27
|
+
},
|
|
28
|
+
"./logger": {
|
|
29
|
+
"types": "./dist/logger.d.ts",
|
|
30
|
+
"import": "./dist/logger.mjs",
|
|
31
|
+
"require": "./dist/logger.js"
|
|
32
|
+
},
|
|
33
|
+
"./plugins": {
|
|
34
|
+
"types": "./dist/plugins.d.ts",
|
|
35
|
+
"import": "./dist/plugins.mjs",
|
|
36
|
+
"require": "./dist/plugins.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"generate": "node scripts/generate-types.js",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest",
|
|
44
|
+
"test:coverage": "vitest run --coverage",
|
|
45
|
+
"prepublishOnly": "npm run build"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18.0.0"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"ocpp",
|
|
52
|
+
"ocpp-rpc",
|
|
53
|
+
"ocpp-j",
|
|
54
|
+
"ocpp1.6",
|
|
55
|
+
"ocpp1.6j",
|
|
56
|
+
"ocpp2.0.1",
|
|
57
|
+
"ocpp2.0.1j",
|
|
58
|
+
"ocpp2.1",
|
|
59
|
+
"websocket",
|
|
60
|
+
"ocpp-websocket",
|
|
61
|
+
"rpc",
|
|
62
|
+
"websocket-rpc",
|
|
63
|
+
"json-rpc",
|
|
64
|
+
"ocpp-client",
|
|
65
|
+
"ocpp-server",
|
|
66
|
+
"charge-point",
|
|
67
|
+
"charging-station",
|
|
68
|
+
"ev-charging",
|
|
69
|
+
"evse",
|
|
70
|
+
"csms",
|
|
71
|
+
"cpo",
|
|
72
|
+
"emsp",
|
|
73
|
+
"wamp",
|
|
74
|
+
"rpc-server",
|
|
75
|
+
"rpc-client",
|
|
76
|
+
"type-safe",
|
|
77
|
+
"typescript",
|
|
78
|
+
"node",
|
|
79
|
+
"nodejs",
|
|
80
|
+
"redis",
|
|
81
|
+
"redis-pubsub",
|
|
82
|
+
"clustering",
|
|
83
|
+
"browser",
|
|
84
|
+
"simulator",
|
|
85
|
+
"ocpp-simulator",
|
|
86
|
+
"testing-cli",
|
|
87
|
+
"ocpp-testing",
|
|
88
|
+
"ocpp-implementation",
|
|
89
|
+
"ocpp-protocol"
|
|
90
|
+
],
|
|
91
|
+
"author": "Rohit Tiwari <rohit@rohittiwari.me>",
|
|
92
|
+
"homepage": "https://ocpp-ws-io.rohittiwari.me",
|
|
93
|
+
"bugs": {
|
|
94
|
+
"url": "https://github.com/rohittiwari-dev/ocpp-ws-io/issues"
|
|
95
|
+
},
|
|
96
|
+
"files": [
|
|
97
|
+
"dist"
|
|
98
|
+
],
|
|
99
|
+
"license": "MIT",
|
|
100
|
+
"dependencies": {
|
|
101
|
+
"ajv": "^8.18.0",
|
|
102
|
+
"ajv-formats": "^3.0.1",
|
|
103
|
+
"voltlog-io": "^1.0.8",
|
|
104
|
+
"ws": "^8.19.0"
|
|
105
|
+
},
|
|
106
|
+
"devDependencies": {
|
|
107
|
+
"@types/node": "^22.19.11",
|
|
108
|
+
"@types/ws": "^8.18.1",
|
|
109
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
110
|
+
"ioredis-mock": "^8.13.1",
|
|
111
|
+
"tsup": "^8.5.1",
|
|
112
|
+
"typescript": "^5.9.3",
|
|
113
|
+
"vitest": "^3.2.4"
|
|
114
|
+
}
|
|
111
115
|
}
|