ocpp-ws-io 2.2.1 → 2.2.2
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/dist/adapters/redis.d.mts +2 -2
- package/dist/adapters/redis.d.ts +2 -2
- 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-Defn9aOS.d.mts → index-B9rTwvbn.d.mts} +1 -1
- package/dist/{index-BefjKqkS.d.ts → index-D5pJ3wS4.d.ts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- 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 +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/{types-BHIHsj__.d.mts → types-xFfIgIuS.d.mts} +2 -2
- package/dist/{types-BHIHsj__.d.ts → types-xFfIgIuS.d.ts} +2 -2
- package/package.json +62 -1
- package/dist/browser.d.mts +0 -4982
- package/dist/browser.d.ts +0 -4982
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import '../types-
|
|
2
|
-
export { a as RedisAdapter, b as RedisAdapterOptions } from '../index-
|
|
1
|
+
import '../types-xFfIgIuS.mjs';
|
|
2
|
+
export { a as RedisAdapter, b as RedisAdapterOptions } from '../index-B9rTwvbn.mjs';
|
|
3
3
|
import 'ws';
|
|
4
4
|
import 'node:https';
|
|
5
5
|
import 'node:http';
|
package/dist/adapters/redis.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import '../types-
|
|
2
|
-
export { a as RedisAdapter, b as RedisAdapterOptions } from '../index-
|
|
1
|
+
import '../types-xFfIgIuS.js';
|
|
2
|
+
export { a as RedisAdapter, b as RedisAdapterOptions } from '../index-D5pJ3wS4.js';
|
|
3
3
|
import 'ws';
|
|
4
4
|
import 'node:https';
|
|
5
5
|
import 'node:http';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { O as OCPPServer, a as OCPPServerClient, b as OCPPServerStats, c as OCPPProtocol, A as AllMethodNames, d as OCPPRequestType, C as CallOptions, e as OCPPResponseType, f as CloseOptions } from './types-xFfIgIuS.mjs';
|
|
2
|
+
|
|
3
|
+
declare abstract class BaseOcppContext {
|
|
4
|
+
readonly server: OCPPServer;
|
|
5
|
+
constructor(server: OCPPServer);
|
|
6
|
+
get clients(): ReadonlySet<OCPPServerClient>;
|
|
7
|
+
stats(): OCPPServerStats;
|
|
8
|
+
getClient(identity: string): OCPPServerClient | undefined;
|
|
9
|
+
getLocalClient(identity: string): OCPPServerClient | undefined;
|
|
10
|
+
hasLocalClient(identity: string): boolean;
|
|
11
|
+
hasClient(identity: string): Promise<boolean>;
|
|
12
|
+
sendToClient<V extends OCPPProtocol, M extends AllMethodNames<V>>(identity: string, version: V, method: M, params: OCPPRequestType<V, M>, options?: CallOptions): Promise<OCPPResponseType<V, M> | undefined>;
|
|
13
|
+
sendToClient<M extends AllMethodNames<any>>(identity: string, method: M, params: OCPPRequestType<any, M>, options?: CallOptions): Promise<OCPPResponseType<any, M> | undefined>;
|
|
14
|
+
sendToClient<TResult = any>(identity: string, method: string, params: Record<string, any>, options?: CallOptions): Promise<TResult | undefined>;
|
|
15
|
+
safeSendToClient<V extends OCPPProtocol, M extends AllMethodNames<V>>(identity: string, version: V, method: M, params: OCPPRequestType<V, M>, options?: CallOptions): Promise<OCPPResponseType<V, M> | undefined>;
|
|
16
|
+
safeSendToClient<M extends AllMethodNames<any>>(identity: string, method: M, params: OCPPRequestType<any, M>, options?: CallOptions): Promise<OCPPResponseType<any, M> | undefined>;
|
|
17
|
+
safeSendToClient<TResult = any>(identity: string, method: string, params: Record<string, any>, options?: CallOptions): Promise<TResult | undefined>;
|
|
18
|
+
close(options?: CloseOptions): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { BaseOcppContext as B };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { O as OCPPServer, a as OCPPServerClient, b as OCPPServerStats, c as OCPPProtocol, A as AllMethodNames, d as OCPPRequestType, C as CallOptions, e as OCPPResponseType, f as CloseOptions } from './types-xFfIgIuS.js';
|
|
2
|
+
|
|
3
|
+
declare abstract class BaseOcppContext {
|
|
4
|
+
readonly server: OCPPServer;
|
|
5
|
+
constructor(server: OCPPServer);
|
|
6
|
+
get clients(): ReadonlySet<OCPPServerClient>;
|
|
7
|
+
stats(): OCPPServerStats;
|
|
8
|
+
getClient(identity: string): OCPPServerClient | undefined;
|
|
9
|
+
getLocalClient(identity: string): OCPPServerClient | undefined;
|
|
10
|
+
hasLocalClient(identity: string): boolean;
|
|
11
|
+
hasClient(identity: string): Promise<boolean>;
|
|
12
|
+
sendToClient<V extends OCPPProtocol, M extends AllMethodNames<V>>(identity: string, version: V, method: M, params: OCPPRequestType<V, M>, options?: CallOptions): Promise<OCPPResponseType<V, M> | undefined>;
|
|
13
|
+
sendToClient<M extends AllMethodNames<any>>(identity: string, method: M, params: OCPPRequestType<any, M>, options?: CallOptions): Promise<OCPPResponseType<any, M> | undefined>;
|
|
14
|
+
sendToClient<TResult = any>(identity: string, method: string, params: Record<string, any>, options?: CallOptions): Promise<TResult | undefined>;
|
|
15
|
+
safeSendToClient<V extends OCPPProtocol, M extends AllMethodNames<V>>(identity: string, version: V, method: M, params: OCPPRequestType<V, M>, options?: CallOptions): Promise<OCPPResponseType<V, M> | undefined>;
|
|
16
|
+
safeSendToClient<M extends AllMethodNames<any>>(identity: string, method: M, params: OCPPRequestType<any, M>, options?: CallOptions): Promise<OCPPResponseType<any, M> | undefined>;
|
|
17
|
+
safeSendToClient<TResult = any>(identity: string, method: string, params: Record<string, any>, options?: CallOptions): Promise<TResult | undefined>;
|
|
18
|
+
close(options?: CloseOptions): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { BaseOcppContext as B };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { IncomingMessage, Server } from 'node:http';
|
|
2
|
+
import { O as OCPPServer, a as OCPPServerClient, b as OCPPServerStats, c as OCPPProtocol, A as AllMethodNames, d as OCPPRequestType, C as CallOptions, e as OCPPResponseType, f as CloseOptions } from './types-xFfIgIuS.mjs';
|
|
3
|
+
import 'ws';
|
|
4
|
+
import 'node:https';
|
|
5
|
+
import 'node:events';
|
|
6
|
+
import 'node:stream';
|
|
7
|
+
import 'node:tls';
|
|
8
|
+
import 'voltlog-io';
|
|
9
|
+
import 'ajv';
|
|
10
|
+
|
|
11
|
+
interface OcppExpressContext {
|
|
12
|
+
readonly server: OCPPServer;
|
|
13
|
+
readonly clients: ReadonlySet<OCPPServerClient>;
|
|
14
|
+
stats(): OCPPServerStats;
|
|
15
|
+
getClient(identity: string): OCPPServerClient | undefined;
|
|
16
|
+
getLocalClient(identity: string): OCPPServerClient | undefined;
|
|
17
|
+
hasLocalClient(identity: string): boolean;
|
|
18
|
+
hasClient(identity: string): Promise<boolean>;
|
|
19
|
+
sendToClient<V extends OCPPProtocol, M extends AllMethodNames<V>>(identity: string, version: V, method: M, params: OCPPRequestType<V, M>, options?: CallOptions): Promise<OCPPResponseType<V, M> | undefined>;
|
|
20
|
+
sendToClient<M extends AllMethodNames<any>>(identity: string, method: M, params: OCPPRequestType<any, M>, options?: CallOptions): Promise<OCPPResponseType<any, M> | undefined>;
|
|
21
|
+
sendToClient<TResult = any>(identity: string, method: string, params: Record<string, any>, options?: CallOptions): Promise<TResult | undefined>;
|
|
22
|
+
safeSendToClient<V extends OCPPProtocol, M extends AllMethodNames<V>>(identity: string, version: V, method: M, params: OCPPRequestType<V, M>, options?: CallOptions): Promise<OCPPResponseType<V, M> | undefined>;
|
|
23
|
+
safeSendToClient<M extends AllMethodNames<any>>(identity: string, method: M, params: OCPPRequestType<any, M>, options?: CallOptions): Promise<OCPPResponseType<any, M> | undefined>;
|
|
24
|
+
safeSendToClient<TResult = any>(identity: string, method: string, params: Record<string, any>, options?: CallOptions): Promise<TResult | undefined>;
|
|
25
|
+
close(options?: CloseOptions): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
interface OcppExpressRequest {
|
|
28
|
+
ocpp?: OcppExpressContext;
|
|
29
|
+
}
|
|
30
|
+
type OcppExpressNextFunction = (error?: unknown) => void;
|
|
31
|
+
type OcppExpressMiddleware = (req: OcppExpressRequest, res: unknown, next: OcppExpressNextFunction) => void;
|
|
32
|
+
interface AttachOcppExpressOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Only pass matching upgrade requests to OCPP.
|
|
35
|
+
* Example: "/ocpp" handles "/ocpp/CP-001"; "/ocpp/*" does the same.
|
|
36
|
+
*/
|
|
37
|
+
upgradePathPrefix?: string | string[];
|
|
38
|
+
/**
|
|
39
|
+
* Advanced upgrade filter. Return true to let OCPP handle the request.
|
|
40
|
+
*/
|
|
41
|
+
upgradeFilter?: (pathname: string, req: IncomingMessage) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Also close the owning HTTP server when binding.close() is called.
|
|
44
|
+
* Defaults to false because Express usually owns the HTTP server lifecycle.
|
|
45
|
+
*/
|
|
46
|
+
closeHttpServer?: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface OcppExpressBinding {
|
|
49
|
+
readonly server: OCPPServer;
|
|
50
|
+
readonly httpServer: Server;
|
|
51
|
+
readonly context: OcppExpressContext;
|
|
52
|
+
dispose(): void;
|
|
53
|
+
close(options?: CloseOptions): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
declare global {
|
|
56
|
+
namespace Express {
|
|
57
|
+
interface Request {
|
|
58
|
+
ocpp: OcppExpressContext;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare function attachOcppExpress(httpServer: Server, server: OCPPServer, options?: AttachOcppExpressOptions): OcppExpressBinding;
|
|
64
|
+
|
|
65
|
+
declare function createOcppExpressContext(server: OCPPServer): OcppExpressContext;
|
|
66
|
+
|
|
67
|
+
declare function ocppMiddleware(context: OcppExpressContext): OcppExpressMiddleware;
|
|
68
|
+
declare function ocppMiddleware(server: OCPPServer): OcppExpressMiddleware;
|
|
69
|
+
|
|
70
|
+
export { type AttachOcppExpressOptions, type OcppExpressBinding, type OcppExpressContext, type OcppExpressMiddleware, type OcppExpressNextFunction, type OcppExpressRequest, attachOcppExpress, createOcppExpressContext, ocppMiddleware };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { IncomingMessage, Server } from 'node:http';
|
|
2
|
+
import { O as OCPPServer, a as OCPPServerClient, b as OCPPServerStats, c as OCPPProtocol, A as AllMethodNames, d as OCPPRequestType, C as CallOptions, e as OCPPResponseType, f as CloseOptions } from './types-xFfIgIuS.js';
|
|
3
|
+
import 'ws';
|
|
4
|
+
import 'node:https';
|
|
5
|
+
import 'node:events';
|
|
6
|
+
import 'node:stream';
|
|
7
|
+
import 'node:tls';
|
|
8
|
+
import 'voltlog-io';
|
|
9
|
+
import 'ajv';
|
|
10
|
+
|
|
11
|
+
interface OcppExpressContext {
|
|
12
|
+
readonly server: OCPPServer;
|
|
13
|
+
readonly clients: ReadonlySet<OCPPServerClient>;
|
|
14
|
+
stats(): OCPPServerStats;
|
|
15
|
+
getClient(identity: string): OCPPServerClient | undefined;
|
|
16
|
+
getLocalClient(identity: string): OCPPServerClient | undefined;
|
|
17
|
+
hasLocalClient(identity: string): boolean;
|
|
18
|
+
hasClient(identity: string): Promise<boolean>;
|
|
19
|
+
sendToClient<V extends OCPPProtocol, M extends AllMethodNames<V>>(identity: string, version: V, method: M, params: OCPPRequestType<V, M>, options?: CallOptions): Promise<OCPPResponseType<V, M> | undefined>;
|
|
20
|
+
sendToClient<M extends AllMethodNames<any>>(identity: string, method: M, params: OCPPRequestType<any, M>, options?: CallOptions): Promise<OCPPResponseType<any, M> | undefined>;
|
|
21
|
+
sendToClient<TResult = any>(identity: string, method: string, params: Record<string, any>, options?: CallOptions): Promise<TResult | undefined>;
|
|
22
|
+
safeSendToClient<V extends OCPPProtocol, M extends AllMethodNames<V>>(identity: string, version: V, method: M, params: OCPPRequestType<V, M>, options?: CallOptions): Promise<OCPPResponseType<V, M> | undefined>;
|
|
23
|
+
safeSendToClient<M extends AllMethodNames<any>>(identity: string, method: M, params: OCPPRequestType<any, M>, options?: CallOptions): Promise<OCPPResponseType<any, M> | undefined>;
|
|
24
|
+
safeSendToClient<TResult = any>(identity: string, method: string, params: Record<string, any>, options?: CallOptions): Promise<TResult | undefined>;
|
|
25
|
+
close(options?: CloseOptions): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
interface OcppExpressRequest {
|
|
28
|
+
ocpp?: OcppExpressContext;
|
|
29
|
+
}
|
|
30
|
+
type OcppExpressNextFunction = (error?: unknown) => void;
|
|
31
|
+
type OcppExpressMiddleware = (req: OcppExpressRequest, res: unknown, next: OcppExpressNextFunction) => void;
|
|
32
|
+
interface AttachOcppExpressOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Only pass matching upgrade requests to OCPP.
|
|
35
|
+
* Example: "/ocpp" handles "/ocpp/CP-001"; "/ocpp/*" does the same.
|
|
36
|
+
*/
|
|
37
|
+
upgradePathPrefix?: string | string[];
|
|
38
|
+
/**
|
|
39
|
+
* Advanced upgrade filter. Return true to let OCPP handle the request.
|
|
40
|
+
*/
|
|
41
|
+
upgradeFilter?: (pathname: string, req: IncomingMessage) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Also close the owning HTTP server when binding.close() is called.
|
|
44
|
+
* Defaults to false because Express usually owns the HTTP server lifecycle.
|
|
45
|
+
*/
|
|
46
|
+
closeHttpServer?: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface OcppExpressBinding {
|
|
49
|
+
readonly server: OCPPServer;
|
|
50
|
+
readonly httpServer: Server;
|
|
51
|
+
readonly context: OcppExpressContext;
|
|
52
|
+
dispose(): void;
|
|
53
|
+
close(options?: CloseOptions): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
declare global {
|
|
56
|
+
namespace Express {
|
|
57
|
+
interface Request {
|
|
58
|
+
ocpp: OcppExpressContext;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare function attachOcppExpress(httpServer: Server, server: OCPPServer, options?: AttachOcppExpressOptions): OcppExpressBinding;
|
|
64
|
+
|
|
65
|
+
declare function createOcppExpressContext(server: OCPPServer): OcppExpressContext;
|
|
66
|
+
|
|
67
|
+
declare function ocppMiddleware(context: OcppExpressContext): OcppExpressMiddleware;
|
|
68
|
+
declare function ocppMiddleware(server: OCPPServer): OcppExpressMiddleware;
|
|
69
|
+
|
|
70
|
+
export { type AttachOcppExpressOptions, type OcppExpressBinding, type OcppExpressContext, type OcppExpressMiddleware, type OcppExpressNextFunction, type OcppExpressRequest, attachOcppExpress, createOcppExpressContext, ocppMiddleware };
|
package/dist/express.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';function m(e,t){if(e.headers.upgrade?.toLowerCase()!=="websocket")return false;let s=O(e);if(!s)return false;if(t.upgradeFilter)return t.upgradeFilter(s,e);let o=u(t.upgradePathPrefix);return o.length===0?true:o.some(n=>y(n,s))}function O(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 y(e,t){let s=e.endsWith("/*")?e.slice(0,-2):e;return s===""||s==="/"?true:t===s||t.startsWith(`${s}/`)}var p=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)}};var d=class extends p{};function a(e){return new d(e)}function E(e,t,s={}){let o=a(t),n=false,P=(i,l,C)=>{m(i,s)&&t.handleUpgrade(i,l,C);};e.on("upgrade",P);let c=()=>{n||(e.removeListener("upgrade",P),n=true);};return {server:t,httpServer:e,context:o,dispose:c,async close(i){c(),await t.close(i),s.closeHttpServer&&e.listening&&await new Promise(l=>e.close(()=>l()));}}}function q(e){let t="server"in e?e:a(e);return (s,o,n)=>{s.ocpp=t,n();}}
|
|
2
|
+
exports.attachOcppExpress=E;exports.createOcppExpressContext=a;exports.ocppMiddleware=q;
|
package/dist/express.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function C(e,t){if(e.headers.upgrade?.toLowerCase()!=="websocket")return false;let s=u(e);if(!s)return false;if(t.upgradeFilter)return t.upgradeFilter(s,e);let i=y(t.upgradePathPrefix);return i.length===0?true:i.some(n=>x(n,s))}function u(e){try{return new URL(e.url??"/",`http://${e.headers.host??"localhost"}`).pathname}catch{return}}function y(e){return e?(Array.isArray(e)?e:[e]).filter(Boolean):[]}function x(e,t){let s=e.endsWith("/*")?e.slice(0,-2):e;return s===""||s==="/"?true:t===s||t.startsWith(`${s}/`)}var a=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)}};var P=class extends a{};function l(e){return new P(e)}function V(e,t,s={}){let i=l(t),n=false,c=(p,d,O)=>{C(p,s)&&t.handleUpgrade(p,d,O);};e.on("upgrade",c);let m=()=>{n||(e.removeListener("upgrade",c),n=true);};return {server:t,httpServer:e,context:i,dispose:m,async close(p){m(),await t.close(p),s.closeHttpServer&&e.listening&&await new Promise(d=>e.close(()=>d()));}}}function N(e){let t="server"in e?e:l(e);return (s,i,n)=>{s.ocpp=t,n();}}
|
|
2
|
+
export{V as attachOcppExpress,l as createOcppExpressContext,N as ocppMiddleware};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FastifyPluginAsync } from 'fastify';
|
|
2
|
+
import { O as OCPPServer } from './types-xFfIgIuS.mjs';
|
|
3
|
+
import { IncomingMessage } from 'node:http';
|
|
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 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 };
|
|
@@ -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';
|