evnex-sdk 1.0.0 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +155 -7
- package/package.json +1 -1
- package/dist/dist/index.d.ts +0 -41
- package/dist/index.js +0 -44187
- package/dist/src/api.d.ts +0 -67
- package/dist/src/errors.d.ts +0 -3
- package/dist/src/index.d.ts +0 -2
- package/dist/src/logger.d.ts +0 -9
- package/dist/src/models.d.ts +0 -10
- package/dist/src/schema/charge_points.d.ts +0 -183
- package/dist/src/schema/commands.d.ts +0 -4
- package/dist/src/schema/cost.d.ts +0 -4
- package/dist/src/schema/org.d.ts +0 -38
- package/dist/src/schema/user.d.ts +0 -13
- package/dist/src/schema/v3/charge_points.d.ts +0 -99
- package/dist/src/schema/v3/commands.d.ts +0 -4
- package/dist/src/schema/v3/cost.d.ts +0 -16
- package/dist/src/schema/v3/generic.d.ts +0 -16
- package/dist/src/schema/v3/relationships.d.ts +0 -12
- package/dist/src/status.d.ts +0 -13
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ben Lawrence
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,13 +1,161 @@
|
|
|
1
|
-
#
|
|
1
|
+
# evnex-sdk
|
|
2
2
|
|
|
3
|
-
TypeScript
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
A TypeScript library for interacting with the [Evnex](https://www.evnex.com) EV charger API. Supports authentication, charge point management, session history, load management, and more.
|
|
4
|
+
|
|
5
|
+
> This project is not affiliated with Evnex. Based upon [python-evnex](https://github.com/hardbyte/python-evnex).
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install evnex-sdk
|
|
11
|
+
# or
|
|
12
|
+
bun add evnex-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { Evnex } from "evnex-sdk";
|
|
19
|
+
|
|
20
|
+
const evnex = new Evnex("your@email.com", "yourpassword");
|
|
21
|
+
|
|
22
|
+
await evnex.authenticate();
|
|
23
|
+
|
|
24
|
+
// Fetch user details and set the default org
|
|
25
|
+
const user = await evnex.getUserDetail();
|
|
26
|
+
console.log(user.organisations);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Authentication
|
|
30
|
+
|
|
31
|
+
The `Evnex` constructor accepts your Evnex account credentials. Call `authenticate()` once to retrieve tokens. Tokens are refreshed automatically on expiry.
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const evnex = new Evnex("your@email.com", "yourpassword");
|
|
35
|
+
await evnex.authenticate();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If you already have tokens from a previous session, you can pass them in to skip the initial login:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import type { EvnexTokens } from "evnex-sdk";
|
|
42
|
+
|
|
43
|
+
const tokens: EvnexTokens = {
|
|
44
|
+
idToken: "...",
|
|
45
|
+
accessToken: "...",
|
|
46
|
+
refreshToken: "...",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const evnex = new Evnex("your@email.com", "yourpassword", tokens);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## API Reference
|
|
53
|
+
|
|
54
|
+
### User
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
// Get user details (also sets the default org ID)
|
|
58
|
+
const user = await evnex.getUserDetail();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Organisation
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// List all charge points in an org
|
|
65
|
+
const chargePoints = await evnex.getOrgChargePoints(orgId);
|
|
66
|
+
|
|
67
|
+
// Get a summary of org charger statuses
|
|
68
|
+
const summary = await evnex.getOrgSummaryStatus(orgId);
|
|
69
|
+
|
|
70
|
+
// Get daily energy insights for the past N days
|
|
71
|
+
const insights = await evnex.getOrgInsight(7, orgId);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Charge Points
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Get full charge point details (v3)
|
|
78
|
+
const detail = await evnex.getChargePointDetailV3(chargePointId);
|
|
79
|
+
console.log(detail.data.attributes.networkStatus); // "ONLINE" | "OFFLINE"
|
|
80
|
+
|
|
81
|
+
// Get current connector status
|
|
82
|
+
const status = await evnex.getChargePointStatus(chargePointId);
|
|
83
|
+
|
|
84
|
+
// Get session history
|
|
85
|
+
const sessions = await evnex.getChargePointSessions(chargePointId);
|
|
86
|
+
|
|
87
|
+
// Get solar config
|
|
88
|
+
const solar = await evnex.getChargePointSolarConfig(chargePointId);
|
|
89
|
+
|
|
90
|
+
// Get override config
|
|
91
|
+
const override = await evnex.getChargePointOverride(chargePointId);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Commands
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// Stop an active charging session
|
|
98
|
+
await evnex.stopChargePoint(chargePointId);
|
|
99
|
+
|
|
100
|
+
// Enable or disable a charger connector
|
|
101
|
+
await evnex.enableCharger(orgId, chargePointId);
|
|
102
|
+
await evnex.disableCharger(orgId, chargePointId);
|
|
103
|
+
|
|
104
|
+
// Set charge now override on/off
|
|
105
|
+
await evnex.setChargePointOverride(chargePointId, true);
|
|
106
|
+
|
|
107
|
+
// Unlock a connector
|
|
108
|
+
await evnex.unlockCharger(chargePointId);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Load Management
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// Apply a load management profile (limits current by time of day)
|
|
115
|
+
await evnex.setChargerLoadProfile(chargePointId, [
|
|
116
|
+
{ start: 0, limit: 6 }, // 12am: 6A
|
|
117
|
+
{ start: 25200, limit: 16 }, // 7am: 16A
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
// Apply a charge schedule
|
|
121
|
+
await evnex.setChargePointSchedule(chargePointId, [
|
|
122
|
+
{ start: 0, limit: 0 }, // off overnight
|
|
123
|
+
{ start: 25200, limit: 16 }, // on from 7am
|
|
124
|
+
]);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Configuration
|
|
128
|
+
|
|
129
|
+
You can override default API and Cognito settings via the optional `config` parameter:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
const evnex = new Evnex("email", "password", undefined, {
|
|
133
|
+
baseUrl: "https://client-api.evnex.io", // default
|
|
134
|
+
cognitoRegion: "ap-southeast-2", // default
|
|
135
|
+
cognitoUserPoolId: "...",
|
|
136
|
+
cognitoClientId: "...",
|
|
137
|
+
orgId: "your-default-org-id", // skips getUserDetail() for org resolution
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Error Handling
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { NotAuthorizedException } from "evnex-sdk";
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
await evnex.authenticate();
|
|
148
|
+
} catch (err) {
|
|
149
|
+
if (err instanceof NotAuthorizedException) {
|
|
150
|
+
console.error("Invalid credentials");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
9
154
|
|
|
10
155
|
## Examples
|
|
11
|
-
`evnex` is intended as a library, but a few example scripts are provided in the `examples` folder
|
|
12
156
|
|
|
13
|
-
|
|
157
|
+
A few example scripts are provided in the `examples/` folder.
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT
|
package/package.json
CHANGED
package/dist/dist/index.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export class Evnex {
|
|
2
|
-
constructor(username: any, password: any, tokens: any, config?: {});
|
|
3
|
-
client: any;
|
|
4
|
-
tokens: any;
|
|
5
|
-
orgId: any;
|
|
6
|
-
username: any;
|
|
7
|
-
password: any;
|
|
8
|
-
clientId: any;
|
|
9
|
-
cognito: any;
|
|
10
|
-
authenticate(): Promise<void>;
|
|
11
|
-
refreshTokens(): Promise<void>;
|
|
12
|
-
get accessToken(): any;
|
|
13
|
-
get idToken(): any;
|
|
14
|
-
get refreshToken(): any;
|
|
15
|
-
get commonHeaders(): {
|
|
16
|
-
Accept: string;
|
|
17
|
-
"Content-Type": string;
|
|
18
|
-
Authorization: any;
|
|
19
|
-
"User-Agent": string;
|
|
20
|
-
};
|
|
21
|
-
checkApiResponse(response: any): Promise<any>;
|
|
22
|
-
getUserDetail(): Promise<any>;
|
|
23
|
-
getOrgChargePoints(orgId: any): Promise<any>;
|
|
24
|
-
getOrgInsight(days: any, orgId: any, tzOffset?: number): Promise<any>;
|
|
25
|
-
getOrgSummaryStatus(orgId: any): Promise<any>;
|
|
26
|
-
getChargePointDetail(chargePointId: any): Promise<any>;
|
|
27
|
-
getChargePointDetailV3(chargePointId: any): Promise<any>;
|
|
28
|
-
getChargePointSolarConfig(chargePointId: any): Promise<any>;
|
|
29
|
-
getChargePointOverride(chargePointId: any): Promise<any>;
|
|
30
|
-
setChargePointOverride(chargePointId: any, chargeNow: any, connectorId?: number): Promise<boolean>;
|
|
31
|
-
getChargePointStatus(chargePointId: any): Promise<any>;
|
|
32
|
-
getChargePointTransactions(chargePointId: any): Promise<any>;
|
|
33
|
-
getChargePointSessions(chargePointId: any): Promise<any>;
|
|
34
|
-
stopChargePoint(chargePointId: any, orgId: any, connectorId?: string, timeout?: number): Promise<any>;
|
|
35
|
-
enableCharger(orgId: any, chargePointId: any, connectorId?: number): Promise<any>;
|
|
36
|
-
disableCharger(orgId: any, chargePointId: any, connectorId?: number): Promise<any>;
|
|
37
|
-
setChargerAvailability(orgId: any, chargePointId: any, available?: boolean, connectorId?: number, timeout?: number): Promise<any>;
|
|
38
|
-
unlockCharger(chargePointId: any, available?: boolean, connectorId?: string, timeout?: number): Promise<any>;
|
|
39
|
-
setChargerLoadProfile(chargePointId: any, chargingProfilePeriods: any, enabled?: boolean, duration?: number, units?: string, timeout?: number): Promise<any>;
|
|
40
|
-
setChargePointSchedule(chargePointId: any, chargingProfilePeriods: any, enabled?: boolean, duration?: number, timeout?: number): Promise<any>;
|
|
41
|
-
}
|