ocpp-ws-io 2.2.0 → 2.2.2-beta.1
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 +29 -0
- package/dist/adapters/redis.d.mts +2 -2
- package/dist/adapters/redis.d.ts +2 -2
- package/dist/adapters/redis.js +1 -1
- package/dist/adapters/redis.mjs +1 -1
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/context-Cy7YIKyU.d.mts +21 -0
- package/dist/context-DcTIzhq-.d.ts +21 -0
- package/dist/express.d.mts +70 -0
- package/dist/express.d.ts +70 -0
- package/dist/express.js +2 -0
- package/dist/express.mjs +2 -0
- package/dist/fastify.d.mts +37 -0
- package/dist/fastify.d.ts +37 -0
- package/dist/fastify.js +2 -0
- package/dist/fastify.mjs +2 -0
- package/dist/hono.d.mts +51 -0
- package/dist/hono.d.ts +51 -0
- package/dist/hono.js +2 -0
- package/dist/hono.mjs +2 -0
- package/dist/{index-B98n5Et3.d.mts → index-B9rTwvbn.d.mts} +1 -1
- package/dist/{index-xx7uU8pY.d.ts → index-D5pJ3wS4.d.ts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/dist/nestjs.d.mts +169 -0
- package/dist/nestjs.d.ts +169 -0
- package/dist/nestjs.js +4826 -0
- package/dist/nestjs.mjs +4826 -0
- package/dist/plugins.d.mts +1017 -26
- package/dist/plugins.d.ts +1017 -26
- package/dist/plugins.js +1 -1
- package/dist/plugins.mjs +1 -1
- package/dist/{types-BunMs45p.d.mts → types-xFfIgIuS.d.mts} +108 -3
- package/dist/{types-BunMs45p.d.ts → types-xFfIgIuS.d.ts} +108 -3
- package/package.json +174 -113
- package/dist/browser.d.mts +0 -4971
- package/dist/browser.d.ts +0 -4971
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FastifyPluginAsync } from 'fastify';
|
|
2
|
+
import { O as OCPPServer } from './types-xFfIgIuS.js';
|
|
3
|
+
import { IncomingMessage } from 'node:http';
|
|
4
|
+
import { B as BaseOcppContext } from './context-DcTIzhq-.js';
|
|
5
|
+
import 'ws';
|
|
6
|
+
import 'node:https';
|
|
7
|
+
import 'node:events';
|
|
8
|
+
import 'node:stream';
|
|
9
|
+
import 'node:tls';
|
|
10
|
+
import 'voltlog-io';
|
|
11
|
+
import 'ajv';
|
|
12
|
+
|
|
13
|
+
interface OcppFastifyContext extends BaseOcppContext {
|
|
14
|
+
}
|
|
15
|
+
interface OcppFastifyPluginOptions {
|
|
16
|
+
ocppServer: OCPPServer;
|
|
17
|
+
/**
|
|
18
|
+
* Only requests with a URL starting with this prefix will be upgraded.
|
|
19
|
+
* E.g., "/ocpp" or ["/v1/ocpp", "/v2/ocpp"]
|
|
20
|
+
*/
|
|
21
|
+
upgradePathPrefix?: string | string[];
|
|
22
|
+
/**
|
|
23
|
+
* Advanced filter for upgrade requests. If provided, this overrides `upgradePathPrefix`.
|
|
24
|
+
* Return true to allow the upgrade.
|
|
25
|
+
*/
|
|
26
|
+
upgradeFilter?: (pathname: string, req: IncomingMessage) => boolean;
|
|
27
|
+
}
|
|
28
|
+
declare module "fastify" {
|
|
29
|
+
interface FastifyRequest {
|
|
30
|
+
ocpp: OcppFastifyContext;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare function createOcppFastifyContext(server: OCPPServer): OcppFastifyContext;
|
|
35
|
+
declare const ocppFastifyPlugin: FastifyPluginAsync<OcppFastifyPluginOptions>;
|
|
36
|
+
|
|
37
|
+
export { type OcppFastifyContext, type OcppFastifyPluginOptions, createOcppFastifyContext, ocppFastifyPlugin };
|
package/dist/fastify.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var y=require('fastify-plugin');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var y__default=/*#__PURE__*/_interopDefault(y);var i=class{constructor(t){this.server=t;}server;get clients(){return this.server.clients}stats(){return this.server.stats()}getClient(t){return this.server.getLocalClient(t)}getLocalClient(t){return this.server.getLocalClient(t)}hasLocalClient(t){return this.server.hasLocalClient(t)}hasClient(t){return this.server.isClientConnected(t)}async sendToClient(...t){return this.server.sendToClient.apply(this.server,t)}async safeSendToClient(...t){return this.server.safeSendToClient.apply(this.server,t)}close(t){return this.server.close(t)}};function l(e,t){if(e.headers.upgrade?.toLowerCase()!=="websocket")return false;let n=m(e);if(!n)return false;if(t.upgradeFilter)return t.upgradeFilter(n,e);let r=u(t.upgradePathPrefix);return r.length===0?true:r.some(s=>P(s,n))}function m(e){try{return new URL(e.url??"/",`http://${e.headers.host??"localhost"}`).pathname}catch{return}}function u(e){return e?(Array.isArray(e)?e:[e]).filter(Boolean):[]}function P(e,t){let n=e.endsWith("/*")?e.slice(0,-2):e;return n===""||n==="/"?true:t===n||t.startsWith(`${n}/`)}var p=class extends i{};function g(e){return new p(e)}var f=async(e,t)=>{let{ocppServer:n}=t;if(!n)throw new Error("ocppServer is required in OcppFastifyPluginOptions");let r=g(n);e.decorateRequest("ocpp",null),e.addHook("onRequest",async o=>{o.ocpp=r;});let s=(o,d,c)=>{l(o,t)&&n.handleUpgrade(o,d,c);};e.server.on("upgrade",s),e.addHook("onClose",async()=>{e.server.removeListener("upgrade",s),await r.close();});},R=y__default.default(f,{fastify:"4.x || 5.x",name:"ocpp-fastify"});
|
|
2
|
+
exports.createOcppFastifyContext=g;exports.ocppFastifyPlugin=R;
|
package/dist/fastify.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import g from'fastify-plugin';var i=class{constructor(t){this.server=t;}server;get clients(){return this.server.clients}stats(){return this.server.stats()}getClient(t){return this.server.getLocalClient(t)}getLocalClient(t){return this.server.getLocalClient(t)}hasLocalClient(t){return this.server.hasLocalClient(t)}hasClient(t){return this.server.isClientConnected(t)}async sendToClient(...t){return this.server.sendToClient.apply(this.server,t)}async safeSendToClient(...t){return this.server.safeSendToClient.apply(this.server,t)}close(t){return this.server.close(t)}};function d(e,t){if(e.headers.upgrade?.toLowerCase()!=="websocket")return false;let n=u(e);if(!n)return false;if(t.upgradeFilter)return t.upgradeFilter(n,e);let r=P(t.upgradePathPrefix);return r.length===0?true:r.some(s=>y(s,n))}function u(e){try{return new URL(e.url??"/",`http://${e.headers.host??"localhost"}`).pathname}catch{return}}function P(e){return e?(Array.isArray(e)?e:[e]).filter(Boolean):[]}function y(e,t){let n=e.endsWith("/*")?e.slice(0,-2):e;return n===""||n==="/"?true:t===n||t.startsWith(`${n}/`)}var l=class extends i{};function f(e){return new l(e)}var C=async(e,t)=>{let{ocppServer:n}=t;if(!n)throw new Error("ocppServer is required in OcppFastifyPluginOptions");let r=f(n);e.decorateRequest("ocpp",null),e.addHook("onRequest",async o=>{o.ocpp=r;});let s=(o,c,m)=>{d(o,t)&&n.handleUpgrade(o,c,m);};e.server.on("upgrade",s),e.addHook("onClose",async()=>{e.server.removeListener("upgrade",s),await r.close();});},S=g(C,{fastify:"4.x || 5.x",name:"ocpp-fastify"});
|
|
2
|
+
export{f as createOcppFastifyContext,S as ocppFastifyPlugin};
|
package/dist/hono.d.mts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IncomingMessage, Server } from 'node:http';
|
|
2
|
+
import { MiddlewareHandler } from 'hono';
|
|
3
|
+
import { O as OCPPServer } from './types-xFfIgIuS.mjs';
|
|
4
|
+
import { B as BaseOcppContext } from './context-Cy7YIKyU.mjs';
|
|
5
|
+
import 'ws';
|
|
6
|
+
import 'node:https';
|
|
7
|
+
import 'node:events';
|
|
8
|
+
import 'node:stream';
|
|
9
|
+
import 'node:tls';
|
|
10
|
+
import 'voltlog-io';
|
|
11
|
+
import 'ajv';
|
|
12
|
+
|
|
13
|
+
interface OcppHonoContext extends BaseOcppContext {
|
|
14
|
+
}
|
|
15
|
+
interface AttachOcppHonoOptions {
|
|
16
|
+
ocppServer: OCPPServer;
|
|
17
|
+
/**
|
|
18
|
+
* Only requests with a URL starting with this prefix will be upgraded.
|
|
19
|
+
* E.g., "/ocpp" or ["/v1/ocpp", "/v2/ocpp"]
|
|
20
|
+
*/
|
|
21
|
+
upgradePathPrefix?: string | string[];
|
|
22
|
+
/**
|
|
23
|
+
* Advanced filter for upgrade requests. If provided, this overrides `upgradePathPrefix`.
|
|
24
|
+
* Return true to allow the upgrade.
|
|
25
|
+
*/
|
|
26
|
+
upgradeFilter?: (pathname: string, req: IncomingMessage) => boolean;
|
|
27
|
+
}
|
|
28
|
+
declare module "hono" {
|
|
29
|
+
interface ContextVariableMap {
|
|
30
|
+
ocpp: OcppHonoContext;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare function createOcppHonoContext(server: OCPPServer): OcppHonoContext;
|
|
35
|
+
/**
|
|
36
|
+
* Hono Middleware that injects `c.get('ocpp')` into the context.
|
|
37
|
+
*/
|
|
38
|
+
declare function ocppMiddleware(server: OCPPServer): MiddlewareHandler;
|
|
39
|
+
interface OcppHonoNodeBinding {
|
|
40
|
+
server: OCPPServer;
|
|
41
|
+
httpServer: Server;
|
|
42
|
+
context: OcppHonoContext;
|
|
43
|
+
dispose: () => void;
|
|
44
|
+
close: (closeOptions?: any) => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Wrapper for `@hono/node-server` or raw Node.js `http.Server` to automatically handle upgrade events.
|
|
48
|
+
*/
|
|
49
|
+
declare function attachOcppHonoNode(httpServer: Server, server: OCPPServer, options?: Omit<AttachOcppHonoOptions, "ocppServer">): OcppHonoNodeBinding;
|
|
50
|
+
|
|
51
|
+
export { type AttachOcppHonoOptions, type OcppHonoContext, type OcppHonoNodeBinding, attachOcppHonoNode, createOcppHonoContext, ocppMiddleware };
|
package/dist/hono.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IncomingMessage, Server } from 'node:http';
|
|
2
|
+
import { MiddlewareHandler } from 'hono';
|
|
3
|
+
import { O as OCPPServer } from './types-xFfIgIuS.js';
|
|
4
|
+
import { B as BaseOcppContext } from './context-DcTIzhq-.js';
|
|
5
|
+
import 'ws';
|
|
6
|
+
import 'node:https';
|
|
7
|
+
import 'node:events';
|
|
8
|
+
import 'node:stream';
|
|
9
|
+
import 'node:tls';
|
|
10
|
+
import 'voltlog-io';
|
|
11
|
+
import 'ajv';
|
|
12
|
+
|
|
13
|
+
interface OcppHonoContext extends BaseOcppContext {
|
|
14
|
+
}
|
|
15
|
+
interface AttachOcppHonoOptions {
|
|
16
|
+
ocppServer: OCPPServer;
|
|
17
|
+
/**
|
|
18
|
+
* Only requests with a URL starting with this prefix will be upgraded.
|
|
19
|
+
* E.g., "/ocpp" or ["/v1/ocpp", "/v2/ocpp"]
|
|
20
|
+
*/
|
|
21
|
+
upgradePathPrefix?: string | string[];
|
|
22
|
+
/**
|
|
23
|
+
* Advanced filter for upgrade requests. If provided, this overrides `upgradePathPrefix`.
|
|
24
|
+
* Return true to allow the upgrade.
|
|
25
|
+
*/
|
|
26
|
+
upgradeFilter?: (pathname: string, req: IncomingMessage) => boolean;
|
|
27
|
+
}
|
|
28
|
+
declare module "hono" {
|
|
29
|
+
interface ContextVariableMap {
|
|
30
|
+
ocpp: OcppHonoContext;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare function createOcppHonoContext(server: OCPPServer): OcppHonoContext;
|
|
35
|
+
/**
|
|
36
|
+
* Hono Middleware that injects `c.get('ocpp')` into the context.
|
|
37
|
+
*/
|
|
38
|
+
declare function ocppMiddleware(server: OCPPServer): MiddlewareHandler;
|
|
39
|
+
interface OcppHonoNodeBinding {
|
|
40
|
+
server: OCPPServer;
|
|
41
|
+
httpServer: Server;
|
|
42
|
+
context: OcppHonoContext;
|
|
43
|
+
dispose: () => void;
|
|
44
|
+
close: (closeOptions?: any) => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Wrapper for `@hono/node-server` or raw Node.js `http.Server` to automatically handle upgrade events.
|
|
48
|
+
*/
|
|
49
|
+
declare function attachOcppHonoNode(httpServer: Server, server: OCPPServer, options?: Omit<AttachOcppHonoOptions, "ocppServer">): OcppHonoNodeBinding;
|
|
50
|
+
|
|
51
|
+
export { type AttachOcppHonoOptions, type OcppHonoContext, type OcppHonoNodeBinding, attachOcppHonoNode, createOcppHonoContext, ocppMiddleware };
|
package/dist/hono.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var i=class{constructor(e){this.server=e;}server;get clients(){return this.server.clients}stats(){return this.server.stats()}getClient(e){return this.server.getLocalClient(e)}getLocalClient(e){return this.server.getLocalClient(e)}hasLocalClient(e){return this.server.hasLocalClient(e)}hasClient(e){return this.server.isClientConnected(e)}async sendToClient(...e){return this.server.sendToClient.apply(this.server,e)}async safeSendToClient(...e){return this.server.safeSendToClient.apply(this.server,e)}close(e){return this.server.close(e)}};function c(t,e){if(t.headers.upgrade?.toLowerCase()!=="websocket")return false;let n=C(t);if(!n)return false;if(e.upgradeFilter)return e.upgradeFilter(n,t);let r=g(e.upgradePathPrefix);return r.length===0?true:r.some(o=>y(o,n))}function C(t){try{return new URL(t.url??"/",`http://${t.headers.host??"localhost"}`).pathname}catch{return}}function g(t){return t?(Array.isArray(t)?t:[t]).filter(Boolean):[]}function y(t,e){let n=t.endsWith("/*")?t.slice(0,-2):t;return n===""||n==="/"?true:e===n||e.startsWith(`${n}/`)}var p=class extends i{};function m(t){return new p(t)}function S(t){let e=m(t);return async(n,r)=>{n.set("ocpp",e),await r();}}function T(t,e,n={}){let r=m(e),o=false,l=(s,P,u)=>{c(s,n)&&e.handleUpgrade(s,P,u);};t.on("upgrade",l);let d=()=>{o||(t.removeListener("upgrade",l),o=true);};return {server:e,httpServer:t,context:r,dispose:d,async close(s){d(),await e.close(s);}}}
|
|
2
|
+
exports.attachOcppHonoNode=T;exports.createOcppHonoContext=m;exports.ocppMiddleware=S;
|
package/dist/hono.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var i=class{constructor(e){this.server=e;}server;get clients(){return this.server.clients}stats(){return this.server.stats()}getClient(e){return this.server.getLocalClient(e)}getLocalClient(e){return this.server.getLocalClient(e)}hasLocalClient(e){return this.server.hasLocalClient(e)}hasClient(e){return this.server.isClientConnected(e)}async sendToClient(...e){return this.server.sendToClient.apply(this.server,e)}async safeSendToClient(...e){return this.server.safeSendToClient.apply(this.server,e)}close(e){return this.server.close(e)}};function m(t,e){if(t.headers.upgrade?.toLowerCase()!=="websocket")return false;let n=g(t);if(!n)return false;if(e.upgradeFilter)return e.upgradeFilter(n,t);let r=y(e.upgradePathPrefix);return r.length===0?true:r.some(o=>O(o,n))}function g(t){try{return new URL(t.url??"/",`http://${t.headers.host??"localhost"}`).pathname}catch{return}}function y(t){return t?(Array.isArray(t)?t:[t]).filter(Boolean):[]}function O(t,e){let n=t.endsWith("/*")?t.slice(0,-2):t;return n===""||n==="/"?true:e===n||e.startsWith(`${n}/`)}var l=class extends i{};function P(t){return new l(t)}function T(t){let e=P(t);return async(n,r)=>{n.set("ocpp",e),await r();}}function H(t,e,n={}){let r=P(e),o=false,d=(s,u,C)=>{m(s,n)&&e.handleUpgrade(s,u,C);};t.on("upgrade",d);let c=()=>{o||(t.removeListener("upgrade",d),o=true);};return {server:e,httpServer:t,context:r,dispose:c,async close(s){c(),await e.close(s);}}}
|
|
2
|
+
export{H as attachOcppHonoNode,P as createOcppHonoContext,T as ocppMiddleware};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { E as EventAdapterInterface,
|
|
2
|
-
export {
|
|
3
|
-
import { R as RedisPubSubDriver, S as StreamEntry } from './index-
|
|
4
|
-
export { a as RedisAdapter } from './index-
|
|
1
|
+
import { E as EventAdapterInterface, g as AuthCallback, L as LoggerLike, h as LoggingConfig, M as MiddlewareFunction, i as MiddlewareContext, j as OCPPPlugin, k as ConnectionMiddleware, V as Validator } from './types-xFfIgIuS.mjs';
|
|
2
|
+
export { A as AllMethodNames, l as AnyOCPPProtocol, m as AuthAccept, n as AuthContext, o as CORSOptions, p as CallHandler, C as CallOptions, q as ClientEvents, r as ClientOptions, f as CloseOptions, s as CompressionOptions, t as ConnectionContext, u as ConnectionState, H as HandlerContext, v as HandshakeInfo, w as ListenOptions, x as MessageDirection, y as MessageEventContext, z as MessageEventPayload, B as MessageType, D as MiddlewareNext, F as MiddlewareStack, N as NOREPLY, G as OCPP16Methods, I as OCPP201Methods, J as OCPP21Methods, K as OCPPCall, P as OCPPCallError, Q as OCPPCallResult, R as OCPPClient, S as OCPPMessage, T as OCPPMethodMap, c as OCPPProtocol, U as OCPPProtocolKey, d as OCPPRequestType, e as OCPPResponseType, W as OCPPRouter, O as OCPPServer, a as OCPPServerClient, b as OCPPServerStats, X as RateLimitOptions, Y as RouterConfig, Z as SecurityEvent, _ as SecurityProfile, $ as ServerEvents, a0 as ServerOptions, a1 as SessionData, a2 as TLSOptions, a3 as TelemetryConfig, a4 as TypedEventEmitter, a5 as WildcardHandler, a6 as createRouter, a7 as createValidator } from './types-xFfIgIuS.mjs';
|
|
3
|
+
import { R as RedisPubSubDriver, S as StreamEntry } from './index-B9rTwvbn.mjs';
|
|
4
|
+
export { a as RedisAdapter } from './index-B9rTwvbn.mjs';
|
|
5
5
|
import { EventEmitter } from 'node:events';
|
|
6
6
|
import 'ws';
|
|
7
7
|
import 'node:https';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { E as EventAdapterInterface,
|
|
2
|
-
export {
|
|
3
|
-
import { R as RedisPubSubDriver, S as StreamEntry } from './index-
|
|
4
|
-
export { a as RedisAdapter } from './index-
|
|
1
|
+
import { E as EventAdapterInterface, g as AuthCallback, L as LoggerLike, h as LoggingConfig, M as MiddlewareFunction, i as MiddlewareContext, j as OCPPPlugin, k as ConnectionMiddleware, V as Validator } from './types-xFfIgIuS.js';
|
|
2
|
+
export { A as AllMethodNames, l as AnyOCPPProtocol, m as AuthAccept, n as AuthContext, o as CORSOptions, p as CallHandler, C as CallOptions, q as ClientEvents, r as ClientOptions, f as CloseOptions, s as CompressionOptions, t as ConnectionContext, u as ConnectionState, H as HandlerContext, v as HandshakeInfo, w as ListenOptions, x as MessageDirection, y as MessageEventContext, z as MessageEventPayload, B as MessageType, D as MiddlewareNext, F as MiddlewareStack, N as NOREPLY, G as OCPP16Methods, I as OCPP201Methods, J as OCPP21Methods, K as OCPPCall, P as OCPPCallError, Q as OCPPCallResult, R as OCPPClient, S as OCPPMessage, T as OCPPMethodMap, c as OCPPProtocol, U as OCPPProtocolKey, d as OCPPRequestType, e as OCPPResponseType, W as OCPPRouter, O as OCPPServer, a as OCPPServerClient, b as OCPPServerStats, X as RateLimitOptions, Y as RouterConfig, Z as SecurityEvent, _ as SecurityProfile, $ as ServerEvents, a0 as ServerOptions, a1 as SessionData, a2 as TLSOptions, a3 as TelemetryConfig, a4 as TypedEventEmitter, a5 as WildcardHandler, a6 as createRouter, a7 as createValidator } from './types-xFfIgIuS.js';
|
|
3
|
+
import { R as RedisPubSubDriver, S as StreamEntry } from './index-D5pJ3wS4.js';
|
|
4
|
+
export { a as RedisAdapter } from './index-D5pJ3wS4.js';
|
|
5
5
|
import { EventEmitter } from 'node:events';
|
|
6
6
|
import 'ws';
|
|
7
7
|
import 'node:https';
|