@zetra/citrineos-evdriver 1.8.3-fork.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.
@@ -0,0 +1,5 @@
1
+ export { EVDriverOcpp201Api } from './module/2.0.1/MessageApi.js';
2
+ export { EVDriverOcpp16Api } from './module/1.6/MessageApi.js';
3
+ export { EVDriverDataApi } from './module/DataApi.js';
4
+ export type { IEVDriverModuleApi } from './module/interface.js';
5
+ export { EVDriverModule } from './module/module.js';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ // SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ export { EVDriverOcpp201Api } from './module/2.0.1/MessageApi.js';
5
+ export { EVDriverOcpp16Api } from './module/1.6/MessageApi.js';
6
+ export { EVDriverDataApi } from './module/DataApi.js';
7
+ export { EVDriverModule } from './module/module.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,sCAAsC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { ILogObj } from 'tslog';
3
+ import { Logger } from 'tslog';
4
+ import type { IEVDriverModuleApi } from '../interface.js';
5
+ import { EVDriverModule } from '../module.js';
6
+ import type { CallAction, IMessageConfirmation } from '@citrineos/base';
7
+ import { AbstractModuleApi, OCPP1_6 } from '@citrineos/base';
8
+ export declare class EVDriverOcpp16Api extends AbstractModuleApi<EVDriverModule> implements IEVDriverModuleApi {
9
+ /**
10
+ * Constructs a new instance of the class.
11
+ *
12
+ * @param {EVDriverModule} evDriverModule - The EVDriver module.
13
+ * @param {FastifyInstance} server - The Fastify server instance.
14
+ * @param {Logger<ILogObj>} [logger] - The logger for logging.
15
+ */
16
+ constructor(evDriverModule: EVDriverModule, server: FastifyInstance, logger?: Logger<ILogObj>);
17
+ remoteStartTransaction(identifier: string[], request: OCPP1_6.RemoteStartTransactionRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
18
+ remoteStopTransaction(identifier: string[], request: OCPP1_6.RemoteStopTransactionRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
19
+ unlockConnector(identifier: string[], request: OCPP1_6.UnlockConnectorRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
20
+ clearCache(identifier: string[], request: OCPP1_6.ClearCacheRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
21
+ /**
22
+ * Overrides superclass method to generate the URL path based on the input {@link CallAction}
23
+ * and the module's endpoint prefix configuration.
24
+ *
25
+ * @param {CallAction} input - The input {@link CallAction}.
26
+ * @return {string} - The generated URL path.
27
+ */
28
+ protected _toMessagePath(input: CallAction): string;
29
+ }
@@ -0,0 +1,79 @@
1
+ // SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ };
10
+ var __metadata = (this && this.__metadata) || function (k, v) {
11
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12
+ };
13
+ import { Logger } from 'tslog';
14
+ import { EVDriverModule } from '../module.js';
15
+ import { AbstractModuleApi, AsMessageEndpoint, DEFAULT_TENANT_ID, OCPP1_6, OCPP1_6_CallAction, OCPPVersion, } from '@citrineos/base';
16
+ export class EVDriverOcpp16Api extends AbstractModuleApi {
17
+ /**
18
+ * Constructs a new instance of the class.
19
+ *
20
+ * @param {EVDriverModule} evDriverModule - The EVDriver module.
21
+ * @param {FastifyInstance} server - The Fastify server instance.
22
+ * @param {Logger<ILogObj>} [logger] - The logger for logging.
23
+ */
24
+ constructor(evDriverModule, server, logger) {
25
+ super(evDriverModule, server, OCPPVersion.OCPP1_6, logger);
26
+ }
27
+ async remoteStartTransaction(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
28
+ const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP1_6, OCPP1_6_CallAction.RemoteStartTransaction, request, callbackUrl));
29
+ return Promise.all(results);
30
+ }
31
+ async remoteStopTransaction(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
32
+ const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP1_6, OCPP1_6_CallAction.RemoteStopTransaction, request, callbackUrl));
33
+ return Promise.all(results);
34
+ }
35
+ async unlockConnector(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
36
+ const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP1_6, OCPP1_6_CallAction.UnlockConnector, request, callbackUrl));
37
+ return Promise.all(results);
38
+ }
39
+ async clearCache(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
40
+ const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP1_6, OCPP1_6_CallAction.ClearCache, request, callbackUrl));
41
+ return Promise.all(results);
42
+ }
43
+ /**
44
+ * Overrides superclass method to generate the URL path based on the input {@link CallAction}
45
+ * and the module's endpoint prefix configuration.
46
+ *
47
+ * @param {CallAction} input - The input {@link CallAction}.
48
+ * @return {string} - The generated URL path.
49
+ */
50
+ _toMessagePath(input) {
51
+ const endpointPrefix = this._module.config.modules.evdriver.endpointPrefix;
52
+ return super._toMessagePath(input, endpointPrefix);
53
+ }
54
+ }
55
+ __decorate([
56
+ AsMessageEndpoint(OCPP1_6_CallAction.RemoteStartTransaction, OCPP1_6.RemoteStartTransactionRequestSchema),
57
+ __metadata("design:type", Function),
58
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
59
+ __metadata("design:returntype", Promise)
60
+ ], EVDriverOcpp16Api.prototype, "remoteStartTransaction", null);
61
+ __decorate([
62
+ AsMessageEndpoint(OCPP1_6_CallAction.RemoteStopTransaction, OCPP1_6.RemoteStopTransactionRequestSchema),
63
+ __metadata("design:type", Function),
64
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
65
+ __metadata("design:returntype", Promise)
66
+ ], EVDriverOcpp16Api.prototype, "remoteStopTransaction", null);
67
+ __decorate([
68
+ AsMessageEndpoint(OCPP1_6_CallAction.UnlockConnector, OCPP1_6.UnlockConnectorRequestSchema),
69
+ __metadata("design:type", Function),
70
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
71
+ __metadata("design:returntype", Promise)
72
+ ], EVDriverOcpp16Api.prototype, "unlockConnector", null);
73
+ __decorate([
74
+ AsMessageEndpoint(OCPP1_6_CallAction.ClearCache, OCPP1_6.ClearCacheRequestSchema),
75
+ __metadata("design:type", Function),
76
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
77
+ __metadata("design:returntype", Promise)
78
+ ], EVDriverOcpp16Api.prototype, "clearCache", null);
79
+ //# sourceMappingURL=MessageApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageApi.js","sourceRoot":"","sources":["../../../src/module/1.6/MessageApi.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,sCAAsC;;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wDAkB3F;AAGK;IADL,iBAAiB,CAAC,kBAAkB,CAAC,UAAU,EAAE,OAAO,CAAC,uBAAuB,CAAC;;;;mDAkBjF"}
@@ -0,0 +1,33 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { ILogObj } from 'tslog';
3
+ import { Logger } from 'tslog';
4
+ import type { IEVDriverModuleApi } from '../interface.js';
5
+ import { EVDriverModule } from '../module.js';
6
+ import type { CallAction, IMessageConfirmation } from '@citrineos/base';
7
+ import { AbstractModuleApi, OCPP2_0_1 } from '@citrineos/base';
8
+ export declare class EVDriverOcpp201Api extends AbstractModuleApi<EVDriverModule> implements IEVDriverModuleApi {
9
+ /**
10
+ * Constructs a new instance of the class.
11
+ *
12
+ * @param {EVDriverModule} evDriverModule - The EVDriver module.
13
+ * @param {FastifyInstance} server - The Fastify server instance.
14
+ * @param {Logger<ILogObj>} [logger] - The logger for logging.
15
+ */
16
+ constructor(evDriverModule: EVDriverModule, server: FastifyInstance, logger?: Logger<ILogObj>);
17
+ requestStartTransaction(identifier: string[], request: OCPP2_0_1.RequestStartTransactionRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
18
+ requestStopTransaction(identifier: string[], request: OCPP2_0_1.RequestStopTransactionRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
19
+ cancelReservation(identifiers: string[], request: OCPP2_0_1.CancelReservationRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
20
+ reserveNow(identifier: string[], request: OCPP2_0_1.ReserveNowRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
21
+ unlockConnector(identifier: string[], request: OCPP2_0_1.UnlockConnectorRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
22
+ clearCache(identifier: string[], request: OCPP2_0_1.ClearCacheRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
23
+ sendLocalList(identifier: string[], request: OCPP2_0_1.SendLocalListRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
24
+ getLocalListVersion(identifier: string[], request: OCPP2_0_1.GetLocalListVersionRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
25
+ /**
26
+ * Overrides superclass method to generate the URL path based on the input {@link CallAction}
27
+ * and the module's endpoint prefix configuration.
28
+ *
29
+ * @param {CallAction} input - The input {@link CallAction}.
30
+ * @return {string} - The generated URL path.
31
+ */
32
+ protected _toMessagePath(input: CallAction): string;
33
+ }
@@ -0,0 +1,246 @@
1
+ // SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ };
10
+ var __metadata = (this && this.__metadata) || function (k, v) {
11
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12
+ };
13
+ import { Logger } from 'tslog';
14
+ import { EVDriverModule } from '../module.js';
15
+ import { AbstractModuleApi, AsMessageEndpoint, DEFAULT_TENANT_ID, OCPP2_0_1, OCPP2_0_1_CallAction, OCPPVersion, } from '@citrineos/base';
16
+ import { validateChargingProfileType } from '@citrineos/util';
17
+ import { OCPP2_0_1_Mapper } from '@citrineos/data';
18
+ import { v4 as uuidv4 } from 'uuid';
19
+ export class EVDriverOcpp201Api extends AbstractModuleApi {
20
+ /**
21
+ * Constructs a new instance of the class.
22
+ *
23
+ * @param {EVDriverModule} evDriverModule - The EVDriver module.
24
+ * @param {FastifyInstance} server - The Fastify server instance.
25
+ * @param {Logger<ILogObj>} [logger] - The logger for logging.
26
+ */
27
+ constructor(evDriverModule, server, logger) {
28
+ super(evDriverModule, server, OCPPVersion.OCPP2_0_1, logger);
29
+ }
30
+ async requestStartTransaction(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
31
+ const results = [];
32
+ for (const i of identifier) {
33
+ let payloadMessage;
34
+ // If a Charging Profile is provided, do additional validations
35
+ if (request.chargingProfile) {
36
+ const chargingProfile = { ...request.chargingProfile };
37
+ // In OCPP 2.0.1, the Purpose of the charging profile for a transaction MUST be TxProfile.
38
+ if (chargingProfile.chargingProfilePurpose !==
39
+ OCPP2_0_1.ChargingProfilePurposeEnumType.TxProfile) {
40
+ results.push({
41
+ success: false,
42
+ payload: 'The Purpose of the ChargingProfile SHALL always be TxProfile.',
43
+ });
44
+ continue;
45
+ }
46
+ // It's not valid to supply a transactionId in the charging profile for a new transaction
47
+ if (chargingProfile.transactionId) {
48
+ chargingProfile.transactionId = undefined;
49
+ this._logger.warn(`A transactionId cannot be provided in the ChargingProfile for station: ${i}`);
50
+ }
51
+ // Attempt to validate and possibly store the charging profile
52
+ try {
53
+ await validateChargingProfileType(chargingProfile, tenantId, i, this._module.deviceModelRepository, this._module.chargingProfileRepository, this._module.transactionEventRepository, this._logger, request.evseId);
54
+ const smartChargingEnabled = await this._module.deviceModelRepository.readAllByQuerystring(tenantId, {
55
+ component_name: 'SmartChargingCtrlr',
56
+ variable_name: 'Enabled',
57
+ tenantId,
58
+ stationId: i,
59
+ });
60
+ if (smartChargingEnabled.length > 0 && smartChargingEnabled[0].value === 'false') {
61
+ payloadMessage = `SmartCharging is not enabled on charger ${i}. The charging profile will be ignored.`;
62
+ this._logger.warn(payloadMessage);
63
+ }
64
+ else {
65
+ await this._module.chargingProfileRepository.createOrUpdateChargingProfile(tenantId, OCPP2_0_1_Mapper.ChargingProfileMapper.fromChargingProfileType(chargingProfile), i, request.evseId);
66
+ }
67
+ }
68
+ catch (error) {
69
+ results.push({
70
+ success: false,
71
+ payload: error instanceof Error ? error.message : JSON.stringify(error),
72
+ });
73
+ continue;
74
+ }
75
+ }
76
+ // Send the call to the station
77
+ try {
78
+ const confirmation = await this._module.sendCall(i, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.RequestStartTransaction, request, callbackUrl);
79
+ if (payloadMessage) {
80
+ // We have a valid confirmation, plus a warning message
81
+ results.push({
82
+ success: true,
83
+ payload: payloadMessage,
84
+ });
85
+ }
86
+ else {
87
+ results.push(confirmation);
88
+ }
89
+ }
90
+ catch (error) {
91
+ results.push({
92
+ success: false,
93
+ payload: error instanceof Error ? error.message : JSON.stringify(error),
94
+ });
95
+ }
96
+ }
97
+ return results;
98
+ }
99
+ async requestStopTransaction(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
100
+ const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.RequestStopTransaction, request, callbackUrl));
101
+ return Promise.all(results);
102
+ }
103
+ async cancelReservation(identifiers, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
104
+ try {
105
+ // Attempt to load the reservations for each station ID
106
+ const reservations = await Promise.all(identifiers.map((identifier) => this._module.reservationRepository.readOnlyOneByQuery(tenantId, {
107
+ where: {
108
+ id: request.reservationId,
109
+ stationId: identifier,
110
+ tenantId,
111
+ },
112
+ })));
113
+ // Identify any stations that did not have the reservation
114
+ const missingReservations = identifiers.filter((identifier, index) => !reservations[index]);
115
+ if (missingReservations.length > 0) {
116
+ throw new Error(`Reservation ${request.reservationId} not found for station IDs: ${missingReservations.join(', ')}.`);
117
+ }
118
+ // Send the CancelReservation call for each station
119
+ const results = await Promise.all(identifiers.map(async (identifier, _index) => this._module.sendCall(identifier, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.CancelReservation, request, callbackUrl)));
120
+ return results;
121
+ }
122
+ catch (error) {
123
+ this._logger.error(`CancelReservation request failed: ${error instanceof Error ? error.message : JSON.stringify(error)}`);
124
+ // Return a failure for each requested station
125
+ return identifiers.map(() => ({
126
+ success: false,
127
+ payload: error instanceof Error ? error.message : JSON.stringify(error),
128
+ }));
129
+ }
130
+ }
131
+ async reserveNow(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
132
+ const results = [];
133
+ for (const i of identifier) {
134
+ try {
135
+ const storedReservation = await this._module.reservationRepository.createOrUpdateReservation(tenantId, request, i, false);
136
+ if (!storedReservation) {
137
+ results.push({
138
+ success: false,
139
+ payload: `Reservation could not be stored for station: ${i}.`,
140
+ });
141
+ continue;
142
+ }
143
+ // Send the ReserveNow call
144
+ const confirmation = await this._module.sendCall(i, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.ReserveNow, request, callbackUrl);
145
+ results.push(confirmation);
146
+ }
147
+ catch (error) {
148
+ results.push({
149
+ success: false,
150
+ payload: error instanceof Error ? error.message : JSON.stringify(error),
151
+ });
152
+ }
153
+ }
154
+ return results;
155
+ }
156
+ unlockConnector(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
157
+ const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.UnlockConnector, request, callbackUrl));
158
+ return Promise.all(results);
159
+ }
160
+ clearCache(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
161
+ const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.ClearCache, request, callbackUrl));
162
+ return Promise.all(results);
163
+ }
164
+ async sendLocalList(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
165
+ const results = [];
166
+ for (const i of identifier) {
167
+ try {
168
+ const correlationId = uuidv4();
169
+ await this._module.localAuthListService.persistSendLocalListForStationIdAndCorrelationIdAndSendLocalListRequest(tenantId, i, correlationId, request);
170
+ const confirmation = await this._module.sendCall(i, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.SendLocalList, request, callbackUrl, correlationId);
171
+ results.push(confirmation);
172
+ }
173
+ catch (error) {
174
+ results.push({
175
+ success: false,
176
+ payload: error instanceof Error ? error.message : JSON.stringify(error),
177
+ });
178
+ }
179
+ }
180
+ return results;
181
+ }
182
+ getLocalListVersion(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
183
+ const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.GetLocalListVersion, request, callbackUrl));
184
+ return Promise.all(results);
185
+ }
186
+ /**
187
+ * Overrides superclass method to generate the URL path based on the input {@link CallAction}
188
+ * and the module's endpoint prefix configuration.
189
+ *
190
+ * @param {CallAction} input - The input {@link CallAction}.
191
+ * @return {string} - The generated URL path.
192
+ */
193
+ _toMessagePath(input) {
194
+ const endpointPrefix = this._module.config.modules.evdriver.endpointPrefix;
195
+ return super._toMessagePath(input, endpointPrefix);
196
+ }
197
+ }
198
+ __decorate([
199
+ AsMessageEndpoint(OCPP2_0_1_CallAction.RequestStartTransaction, OCPP2_0_1.RequestStartTransactionRequestSchema),
200
+ __metadata("design:type", Function),
201
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
202
+ __metadata("design:returntype", Promise)
203
+ ], EVDriverOcpp201Api.prototype, "requestStartTransaction", null);
204
+ __decorate([
205
+ AsMessageEndpoint(OCPP2_0_1_CallAction.RequestStopTransaction, OCPP2_0_1.RequestStopTransactionRequestSchema),
206
+ __metadata("design:type", Function),
207
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
208
+ __metadata("design:returntype", Promise)
209
+ ], EVDriverOcpp201Api.prototype, "requestStopTransaction", null);
210
+ __decorate([
211
+ AsMessageEndpoint(OCPP2_0_1_CallAction.CancelReservation, OCPP2_0_1.CancelReservationRequestSchema),
212
+ __metadata("design:type", Function),
213
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
214
+ __metadata("design:returntype", Promise)
215
+ ], EVDriverOcpp201Api.prototype, "cancelReservation", null);
216
+ __decorate([
217
+ AsMessageEndpoint(OCPP2_0_1_CallAction.ReserveNow, OCPP2_0_1.ReserveNowRequestSchema),
218
+ __metadata("design:type", Function),
219
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
220
+ __metadata("design:returntype", Promise)
221
+ ], EVDriverOcpp201Api.prototype, "reserveNow", null);
222
+ __decorate([
223
+ AsMessageEndpoint(OCPP2_0_1_CallAction.UnlockConnector, OCPP2_0_1.UnlockConnectorRequestSchema),
224
+ __metadata("design:type", Function),
225
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
226
+ __metadata("design:returntype", Promise)
227
+ ], EVDriverOcpp201Api.prototype, "unlockConnector", null);
228
+ __decorate([
229
+ AsMessageEndpoint(OCPP2_0_1_CallAction.ClearCache, OCPP2_0_1.ClearCacheRequestSchema),
230
+ __metadata("design:type", Function),
231
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
232
+ __metadata("design:returntype", Promise)
233
+ ], EVDriverOcpp201Api.prototype, "clearCache", null);
234
+ __decorate([
235
+ AsMessageEndpoint(OCPP2_0_1_CallAction.SendLocalList, OCPP2_0_1.SendLocalListRequestSchema),
236
+ __metadata("design:type", Function),
237
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
238
+ __metadata("design:returntype", Promise)
239
+ ], EVDriverOcpp201Api.prototype, "sendLocalList", null);
240
+ __decorate([
241
+ AsMessageEndpoint(OCPP2_0_1_CallAction.GetLocalListVersion, OCPP2_0_1.GetLocalListVersionRequestSchema),
242
+ __metadata("design:type", Function),
243
+ __metadata("design:paramtypes", [Array, Object, String, Number]),
244
+ __metadata("design:returntype", Promise)
245
+ ], EVDriverOcpp201Api.prototype, "getLocalListVersion", null);
246
+ //# sourceMappingURL=MessageApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageApi.js","sourceRoot":"","sources":["../../../src/module/2.0.1/MessageApi.ts"],"names":[],"mappings":"AAAA,qEAAq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EA0GA;AAMK;IAJL,iBAAiB,CAChB,oBAAoB,CAAC,sBAAsB,EAC3C,SAAS,CAAC,mCAAmC,CAC9C;;;;gEAkBA;AAMK;IAJL,iBAAiB,CAChB,oBAAoB,CAAC,iBAAiB,EACtC,SAAS,CAAC,8BAA8B,CACzC;;;;2DA0DA;AAGK;IADL,iBAAiB,CAAC,oBAAoB,CAAC,UAAU,EAAE,SAAS,CAAC,uBAAuB,CAAC;;;;oDA+CrF;AAGD;IADC,iBAAiB,CAAC,oBAAoB,CAAC,eAAe,EAAE,SAAS,CAAC,4BAA4B,CAAC;;;;yDAkB/F;AAGD;IADC,iBAAiB,CAAC,oBAAoB,CAAC,UAAU,EAAE,SAAS,CAAC,uBAAuB,CAAC;;;;oDAkBrF;AAGK;IADL,iBAAiB,CAAC,oBAAoB,CAAC,aAAa,EAAE,SAAS,CAAC,0BAA0B,CAAC;;;;uDAwC3F;AAMD;IAJC,iBAAiB,CAChB,oBAAoB,CAAC,mBAAmB,EACxC,SAAS,CAAC,gCAAgC,CAC3C;;;;6DAkBA"}
@@ -0,0 +1,29 @@
1
+ import type { FastifyInstance, FastifyRequest } from 'fastify';
2
+ import type { ILogObj } from 'tslog';
3
+ import { Logger } from 'tslog';
4
+ import type { IEVDriverModuleApi } from './interface.js';
5
+ import { EVDriverModule } from './module.js';
6
+ import { AbstractModuleApi, Namespace, OCPP1_6_Namespace, OCPP2_0_1_Namespace } from '@citrineos/base';
7
+ import type { ChargingStationKeyQuerystring } from '@citrineos/data';
8
+ import { LocalListVersion } from '@citrineos/data';
9
+ export declare class EVDriverDataApi extends AbstractModuleApi<EVDriverModule> implements IEVDriverModuleApi {
10
+ /**
11
+ * Constructs a new instance of the class.
12
+ *
13
+ * @param {EVDriverModule} evDriverModule - The EVDriver module.
14
+ * @param {FastifyInstance} server - The Fastify server instance.
15
+ * @param {Logger<ILogObj>} [logger] - The logger for logging.
16
+ */
17
+ constructor(evDriverModule: EVDriverModule, server: FastifyInstance, logger?: Logger<ILogObj>);
18
+ getLocalAuthorizationListVersion(request: FastifyRequest<{
19
+ Querystring: ChargingStationKeyQuerystring;
20
+ }>): Promise<LocalListVersion | undefined>;
21
+ /**
22
+ * Overrides superclass method to generate the URL path based on the input {@link Namespace}
23
+ * and the module's endpoint prefix configuration.
24
+ *
25
+ * @param {Namespace} input - The input {@link Namespace}.
26
+ * @return {string} - The generated URL path.
27
+ */
28
+ protected _toDataPath(input: OCPP2_0_1_Namespace | OCPP1_6_Namespace | Namespace): string;
29
+ }
@@ -0,0 +1,53 @@
1
+ // SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ };
10
+ var __metadata = (this && this.__metadata) || function (k, v) {
11
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12
+ };
13
+ import { Logger } from 'tslog';
14
+ import { EVDriverModule } from './module.js';
15
+ import { AbstractModuleApi, AsDataEndpoint, HttpMethod, Namespace, OCPP1_6_Namespace, OCPP2_0_1_Namespace, } from '@citrineos/base';
16
+ import { ChargingStationKeyQuerySchema, LocalListVersion } from '@citrineos/data';
17
+ export class EVDriverDataApi extends AbstractModuleApi {
18
+ /**
19
+ * Constructs a new instance of the class.
20
+ *
21
+ * @param {EVDriverModule} evDriverModule - The EVDriver module.
22
+ * @param {FastifyInstance} server - The Fastify server instance.
23
+ * @param {Logger<ILogObj>} [logger] - The logger for logging.
24
+ */
25
+ constructor(evDriverModule, server, logger) {
26
+ super(evDriverModule, server, null, logger);
27
+ }
28
+ async getLocalAuthorizationListVersion(request) {
29
+ const tenantId = request.query.tenantId;
30
+ return await this._module.localAuthListRepository.readOnlyOneByQuery(tenantId, {
31
+ tenantId: tenantId,
32
+ stationId: request.query.stationId,
33
+ });
34
+ }
35
+ /**
36
+ * Overrides superclass method to generate the URL path based on the input {@link Namespace}
37
+ * and the module's endpoint prefix configuration.
38
+ *
39
+ * @param {Namespace} input - The input {@link Namespace}.
40
+ * @return {string} - The generated URL path.
41
+ */
42
+ _toDataPath(input) {
43
+ const endpointPrefix = this._module.config.modules.evdriver.endpointPrefix;
44
+ return super._toDataPath(input, endpointPrefix);
45
+ }
46
+ }
47
+ __decorate([
48
+ AsDataEndpoint(OCPP2_0_1_Namespace.LocalListVersion, HttpMethod.Get, ChargingStationKeyQuerySchema),
49
+ __metadata("design:type", Function),
50
+ __metadata("design:paramtypes", [Object]),
51
+ __metadata("design:returntype", Promise)
52
+ ], EVDriverDataApi.prototype, "getLocalAuthorizationListVersion", null);
53
+ //# sourceMappingURL=DataApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataApi.js","sourceRoot":"","sources":["../../src/module/DataApi.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,sCAAsC;;;;;;;;;;AAItC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElF,MAAM,OAAO,eACX,SAAQ,iBAAiC;IAGzC;;;;;;OAMG;IACH,YAAY,cAA8B,EAAE,MAAuB,EAAE,MAAwB;QAC3F,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IAOK,AAAN,KAAK,CAAC,gCAAgC,CACpC,OAAuE;QAEvE,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;QACxC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,QAAQ,EAAE;YAC7E,QAAQ,EAAE,QAAQ;YAClB,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS;SACnC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACO,WAAW,CAAC,KAA0D;QAC9E,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC3E,OAAO,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAClD,CAAC;CACF;AArBO;IALL,cAAc,CACb,mBAAmB,CAAC,gBAAgB,EACpC,UAAU,CAAC,GAAG,EACd,6BAA6B,CAC9B;;;;uEASA"}
@@ -0,0 +1,21 @@
1
+ import { OCPP2_0_1 } from '@citrineos/base';
2
+ import type { IDeviceModelRepository, ILocalAuthListRepository } from '@citrineos/data';
3
+ import { SendLocalList } from '@citrineos/data';
4
+ export declare class LocalAuthListService {
5
+ protected _localAuthListRepository: ILocalAuthListRepository;
6
+ protected _deviceModelRepository: IDeviceModelRepository;
7
+ constructor(localAuthListRepository: ILocalAuthListRepository, deviceModelRepository: IDeviceModelRepository);
8
+ /**
9
+ * Validates a SendLocalListRequest and persists it, then returns the correlation Id.
10
+ *
11
+ * @param {string} stationId - The ID of the station to which the SendLocalListRequest belongs.
12
+ * @param {string} correlationId - The correlation Id that will be used for the SendLocalListRequest.
13
+ * @param {SendLocalListRequest} sendLocalListRequest - The SendLocalListRequest to validate and persist.
14
+ * @return {SendLocalList} The persisted SendLocalList.
15
+ */
16
+ persistSendLocalListForStationIdAndCorrelationIdAndSendLocalListRequest(tenantId: number, stationId: string, correlationId: string, sendLocalListRequest: OCPP2_0_1.SendLocalListRequest): Promise<SendLocalList>;
17
+ private createSendLocalListFromStationIdAndRequestAndCurrentVersion;
18
+ private countUpdatedAuthListFromRequestAndCurrentVersion;
19
+ private getItemsPerMessageSendLocalListByStationId;
20
+ private getMaxLocalAuthListEntries;
21
+ }