@zetra/citrineos-transactions 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.
Files changed (34) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.js +7 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/module/2.0.1/MessageApi.d.ts +30 -0
  5. package/dist/module/2.0.1/MessageApi.js +62 -0
  6. package/dist/module/2.0.1/MessageApi.js.map +1 -0
  7. package/dist/module/CostCalculator.d.ts +24 -0
  8. package/dist/module/CostCalculator.js +52 -0
  9. package/dist/module/CostCalculator.js.map +1 -0
  10. package/dist/module/CostNotifier.d.ts +27 -0
  11. package/dist/module/CostNotifier.js +60 -0
  12. package/dist/module/CostNotifier.js.map +1 -0
  13. package/dist/module/DataApi.d.ts +43 -0
  14. package/dist/module/DataApi.js +94 -0
  15. package/dist/module/DataApi.js.map +1 -0
  16. package/dist/module/Scheduler.d.ts +12 -0
  17. package/dist/module/Scheduler.js +33 -0
  18. package/dist/module/Scheduler.js.map +1 -0
  19. package/dist/module/StatusNotificationService.d.ts +19 -0
  20. package/dist/module/StatusNotificationService.js +137 -0
  21. package/dist/module/StatusNotificationService.js.map +1 -0
  22. package/dist/module/TransactionService.d.ts +25 -0
  23. package/dist/module/TransactionService.js +246 -0
  24. package/dist/module/TransactionService.js.map +1 -0
  25. package/dist/module/interface.d.ts +5 -0
  26. package/dist/module/interface.js +5 -0
  27. package/dist/module/interface.js.map +1 -0
  28. package/dist/module/model/tariffs.d.ts +10 -0
  29. package/dist/module/model/tariffs.js +14 -0
  30. package/dist/module/model/tariffs.js.map +1 -0
  31. package/dist/module/module.d.ts +122 -0
  32. package/dist/module/module.js +500 -0
  33. package/dist/module/module.js.map +1 -0
  34. package/package.json +25 -0
@@ -0,0 +1,500 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { AbstractModule, AsHandler, AuthorizationStatusEnum, CrudRepository, ErrorCode, EventGroup, OCPP1_6, OCPP1_6_CallAction, OCPP2_0_1, OCPP2_0_1_CallAction, OcppError, OCPPValidator, OCPPVersion, } from '@citrineos/base';
11
+ import { Authorization, Component, OCPP1_6_Mapper, sequelize, SequelizeOCPPMessageRepository, SequelizeRepository, StartTransaction, Transaction, VariableAttribute, } from '@citrineos/data';
12
+ import { RabbitMqReceiver, RabbitMqSender, RealTimeAuthorizer, SignedMeterValuesUtil, } from '@citrineos/util';
13
+ import { Logger } from 'tslog';
14
+ import { CostCalculator } from './CostCalculator.js';
15
+ import { CostNotifier } from './CostNotifier.js';
16
+ import { StatusNotificationService } from './StatusNotificationService.js';
17
+ import { TransactionService } from './TransactionService.js';
18
+ /**
19
+ * Component that handles transaction related messages.
20
+ */
21
+ export class TransactionsModule extends AbstractModule {
22
+ _requests = [];
23
+ _responses = [];
24
+ _transactionEventRepository;
25
+ _authorizeRepository;
26
+ _deviceModelRepository;
27
+ _componentRepository;
28
+ _locationRepository;
29
+ _tariffRepository;
30
+ _reservationRepository;
31
+ _ocppMessageRepository;
32
+ _transactionService;
33
+ _statusNotificationService;
34
+ _fileStorage;
35
+ _authorizers;
36
+ _realTimeAuthorizer;
37
+ _signedMeterValuesUtil;
38
+ _costNotifier;
39
+ _costCalculator;
40
+ _sendCostUpdatedOnMeterValue;
41
+ _costUpdatedInterval;
42
+ /**
43
+ * This is the constructor function that initializes the {@link TransactionsModule}.
44
+ *
45
+ * @param {BootstrapConfig & SystemConfig} config - The `config` contains configuration settings for the module.
46
+ *
47
+ * @param {ICache} [cache] - The cache instance which is shared among the modules & Central System to pass information such as blacklisted actions or boot status.
48
+ *
49
+ * @param {IFileStorage} [fileStorage] - The `fileStorage` allows access to the configured file storage.
50
+ *
51
+ * @param {IMessageSender} [sender] - The `sender` parameter is an optional parameter that represents an instance of the {@link IMessageSender} interface.
52
+ * It is used to send messages from the central system to external systems or devices. If no `sender` is provided, a default {@link RabbitMqSender} instance is created and used.
53
+ *
54
+ * @param {IMessageHandler} [handler] - The `handler` parameter is an optional parameter that represents an instance of the {@link IMessageHandler} interface.
55
+ * It is used to handle incoming messages and dispatch them to the appropriate methods or functions. If no `handler` is provided, a default {@link RabbitMqReceiver} instance is created and used.
56
+ *
57
+ * @param {Logger<ILogObj>} [logger] - The `logger` parameter is an optional parameter that represents an instance of {@link Logger<ILogObj>}.
58
+ * It is used to propagate system-wide logger settings and will serve as the parent logger for any sub-component logging. If no `logger` is provided, a default {@link Logger<ILogObj>} instance is created and used.
59
+ *
60
+ * @param {ITransactionEventRepository} [transactionEventRepository] - An optional parameter of type {@link ITransactionEventRepository} which represents a repository for accessing and manipulating transaction event data.
61
+ * If no `transactionEventRepository` is provided, a default {@link sequelize:transactionEventRepository} instance
62
+ * is created and used.
63
+ *
64
+ * @param {IAuthorizationRepository} [authorizeRepository] - An optional parameter of type {@link IAuthorizationRepository} which represents a repository for accessing and manipulating authorization data.
65
+ * If no `authorizeRepository` is provided, a default {@link sequelize:authorizeRepository} instance is
66
+ * created and used.
67
+ *
68
+ * @param {IDeviceModelRepository} [deviceModelRepository] - An optional parameter of type {@link IDeviceModelRepository} which represents a repository for accessing and manipulating variable attribute data.
69
+ * If no `deviceModelRepository` is provided, a default {@link sequelize:deviceModelRepository} instance is
70
+ * created and used.
71
+ *
72
+ * @param {CrudRepository<Component>} [componentRepository] - An optional parameter of type {@link CrudRepository<Component>} which represents a repository for accessing and manipulating component data.
73
+ * If no `componentRepository` is provided, a default {@link sequelize:componentRepository} instance is
74
+ * created and used.
75
+ *
76
+ * @param {ILocationRepository} [locationRepository] - An optional parameter of type {@link ILocationRepository} which represents a repository for accessing and manipulating location and charging station data.
77
+ * If no `locationRepository` is provided, a default {@link sequelize:locationRepository} instance is
78
+ * created and used.
79
+ *
80
+ * @param {CrudRepository<Component>} [componentRepository] - An optional parameter of type {@link CrudRepository<Component>} which represents a repository for accessing and manipulating component data.
81
+ * If no `componentRepository` is provided, a default {@link sequelize:componentRepository} instance is
82
+ * created and used.
83
+ *
84
+ * @param {ILocationRepository} [locationRepository] - An optional parameter of type {@link ILocationRepository} which represents a repository for accessing and manipulating location and charging station data.
85
+ * If no `locationRepository` is provided, a default {@link sequelize:locationRepository} instance is
86
+ * created and used.
87
+ *
88
+ * @param {ITariffRepository} [tariffRepository] - An optional parameter of type {@link ITariffRepository} which
89
+ * represents a repository for accessing and manipulating tariff data.
90
+ * If no `tariffRepository` is provided, a default {@link sequelize:tariffRepository} instance is
91
+ * created and used.
92
+ *
93
+ * @param {IReservationRepository} [reservationRepository] - An optional parameter of type {@link IReservationRepository}
94
+ * which represents a repository for accessing and manipulating reservation data.
95
+ * If no `reservationRepository` is provided, a default {@link sequelize:reservationRepository} instance is created and used.
96
+ *
97
+ * @param {IOCPPMessageRepository} [ocppMessageRepository] - An optional parameter of type {@link IOCPPMessageRepository}
98
+ * which represents a repository for accessing and manipulating OCPP Message data.
99
+ * If no `ocppMessageRepository` is provided, a default {@link sequelize:ocppMessageRepository} instance is created and used.
100
+ *
101
+ * @param {IAuthorizer[]} [authorizers] - An optional parameter of type {@link IAuthorizer[]} which represents
102
+ * a list of authorizers that can be used to authorize requests.
103
+ *
104
+ * @param {IAuthorizer} [realTimeAuthorizer] - An optional parameter of type {@link IAuthorizer} which represents
105
+ * a real-time authorizer that can be used to authorize real-time requests.
106
+ */
107
+ constructor(config, cache, fileStorage, sender, handler, logger, ocppValidator, transactionEventRepository, authorizeRepository, deviceModelRepository, componentRepository, locationRepository, tariffRepository, reservationRepository, ocppMessageRepository, realTimeAuthorizer, authorizers) {
108
+ super(config, cache, handler || new RabbitMqReceiver(config, logger), sender || new RabbitMqSender(config, logger), EventGroup.Transactions, logger, ocppValidator);
109
+ this._requests = config.modules.transactions.requests;
110
+ this._responses = config.modules.transactions.responses;
111
+ this._fileStorage = fileStorage;
112
+ this._transactionEventRepository =
113
+ transactionEventRepository ||
114
+ new sequelize.SequelizeTransactionEventRepository(config, logger);
115
+ this._authorizeRepository =
116
+ authorizeRepository || new sequelize.SequelizeAuthorizationRepository(config, logger);
117
+ this._deviceModelRepository =
118
+ deviceModelRepository || new sequelize.SequelizeDeviceModelRepository(config, logger);
119
+ this._componentRepository =
120
+ componentRepository ||
121
+ new SequelizeRepository(config, Component.MODEL_NAME, logger);
122
+ this._locationRepository =
123
+ locationRepository || new sequelize.SequelizeLocationRepository(config, logger);
124
+ this._tariffRepository =
125
+ tariffRepository || new sequelize.SequelizeTariffRepository(config, logger);
126
+ this._reservationRepository =
127
+ reservationRepository || new sequelize.SequelizeReservationRepository(config, logger);
128
+ this._ocppMessageRepository =
129
+ ocppMessageRepository || new SequelizeOCPPMessageRepository(config, this._logger);
130
+ this._authorizers = authorizers || [];
131
+ this._realTimeAuthorizer =
132
+ realTimeAuthorizer ||
133
+ new RealTimeAuthorizer(this._locationRepository, this.config, this._logger);
134
+ this._signedMeterValuesUtil = new SignedMeterValuesUtil(fileStorage, config, this._logger);
135
+ this._sendCostUpdatedOnMeterValue = config.modules.transactions.sendCostUpdatedOnMeterValue;
136
+ this._costUpdatedInterval = config.modules.transactions.costUpdatedInterval;
137
+ this._transactionService = new TransactionService(this._transactionEventRepository, this._authorizeRepository, this._locationRepository, this._reservationRepository, this._ocppMessageRepository, this._realTimeAuthorizer, this._authorizers, this._logger);
138
+ this._statusNotificationService = new StatusNotificationService(this._componentRepository, this._deviceModelRepository, this._locationRepository, this._logger);
139
+ this._costCalculator = new CostCalculator(this._tariffRepository, this._transactionService, this._logger);
140
+ this._costNotifier = new CostNotifier(this, this._transactionEventRepository, this._costCalculator, this._logger);
141
+ }
142
+ get transactionEventRepository() {
143
+ return this._transactionEventRepository;
144
+ }
145
+ get authorizeRepository() {
146
+ return this._authorizeRepository;
147
+ }
148
+ get deviceModelRepository() {
149
+ return this._deviceModelRepository;
150
+ }
151
+ get tariffRepository() {
152
+ return this._tariffRepository;
153
+ }
154
+ get ocppMessageRepository() {
155
+ return this._ocppMessageRepository;
156
+ }
157
+ /**
158
+ * Handle OCPP 2.0.1 requests
159
+ */
160
+ async _handleTransactionEvent(message, props) {
161
+ this._logger.debug('Transaction event received:', message, props);
162
+ const tenantId = message.context.tenantId;
163
+ const stationId = message.context.stationId;
164
+ const transactionEvent = message.payload;
165
+ const transactionId = transactionEvent.transactionInfo.transactionId;
166
+ let response = undefined;
167
+ let transaction = undefined;
168
+ if (transactionEvent.idToken) {
169
+ response = await this._transactionService.authorizeOcpp201IdToken(tenantId, transactionEvent, message.context);
170
+ }
171
+ try {
172
+ transaction =
173
+ await this._transactionEventRepository.createOrUpdateTransactionByTransactionEventAndStationId(tenantId, message.payload, stationId);
174
+ }
175
+ catch (error) {
176
+ if (error.name === 'SequelizeForeignKeyConstraintError') {
177
+ await this.sendCallErrorWithMessage(message, new OcppError(message.context.correlationId, ErrorCode.PropertyConstraintViolation, 'Referenced entity does not exist.'));
178
+ return;
179
+ }
180
+ throw error;
181
+ }
182
+ if (message.payload.reservationId) {
183
+ await this._transactionService.deactivateReservation(tenantId, transactionId, message.payload.reservationId, stationId);
184
+ }
185
+ if (response) {
186
+ const messageConfirmation = await this.sendCallResultWithMessage(message, response);
187
+ this._logger.debug('Transaction response sent: ', messageConfirmation);
188
+ // If the transaction is accepted and interval is set, start the cost update
189
+ if (transactionEvent.eventType === OCPP2_0_1.TransactionEventEnumType.Started &&
190
+ response.idTokenInfo?.status === OCPP2_0_1.AuthorizationStatusEnumType.Accepted &&
191
+ this._costUpdatedInterval) {
192
+ this._costNotifier.notifyWhileActive(stationId, transactionId, message.context.tenantId, this._costUpdatedInterval);
193
+ }
194
+ }
195
+ else {
196
+ const response = {
197
+ // TODO determine how to set chargingPriority and updatedPersonalMessage for anonymous users
198
+ };
199
+ if (message.payload.eventType === OCPP2_0_1.TransactionEventEnumType.Updated) {
200
+ // I02 - Show EV Driver Running Total Cost During Charging
201
+ if (transaction &&
202
+ transaction.isActive &&
203
+ transaction.totalKwh &&
204
+ this._sendCostUpdatedOnMeterValue) {
205
+ response.totalCost = await this._costCalculator.calculateTotalCost(tenantId, stationId, transaction.totalKwh);
206
+ }
207
+ // I06 - Update Tariff Information During Transaction
208
+ const tariffAvailableAttributes = await this._deviceModelRepository.readAllByQuerystring(tenantId, {
209
+ tenantId,
210
+ stationId: stationId,
211
+ component_name: 'TariffCostCtrlr',
212
+ variable_instance: 'Tariff',
213
+ variable_name: 'Available',
214
+ type: OCPP2_0_1.AttributeEnumType.Actual,
215
+ });
216
+ const supportTariff = tariffAvailableAttributes.length !== 0 && Boolean(tariffAvailableAttributes[0].value);
217
+ if (supportTariff && transaction && transaction.isActive) {
218
+ this._logger.debug(`Checking if updated tariff information is available for traction ${transaction.transactionId}`);
219
+ // TODO: checks if there is updated tariff information available and set it in the PersonalMessage field.
220
+ }
221
+ }
222
+ if (message.payload.eventType === OCPP2_0_1.TransactionEventEnumType.Ended &&
223
+ transaction.totalKwh) {
224
+ response.totalCost = await this._costCalculator.calculateTotalCost(tenantId, stationId, transaction.totalKwh);
225
+ }
226
+ // Store total cost in db
227
+ if (response.totalCost && transaction) {
228
+ await this._transactionEventRepository.updateTransactionTotalCostById(tenantId, response.totalCost, transaction.id);
229
+ }
230
+ if (transactionEvent.meterValue) {
231
+ const meterValuesValid = await this._signedMeterValuesUtil.validateMeterValues(tenantId, stationId, transactionEvent.meterValue);
232
+ if (!meterValuesValid) {
233
+ this._logger.warn('One or more MeterValues in this TransactionEvent have an invalid signature.');
234
+ }
235
+ }
236
+ const messageConfirmation = await this.sendCallResultWithMessage(message, response);
237
+ this._logger.debug('Transaction response sent: ', messageConfirmation);
238
+ }
239
+ }
240
+ async _handleMeterValues(message, props) {
241
+ this._logger.debug('MeterValues received:', message, props);
242
+ // TODO: Meter values can be triggered. Ideally, it should be sent to the callbackUrl from the message api that sent the trigger message
243
+ const meterValues = message.payload.meterValue;
244
+ const tenantId = message.context.tenantId;
245
+ const stationId = message.context.stationId;
246
+ const evseId = message.payload.evseId;
247
+ // When evseId is 0, the MeterValuesRequest message SHALL be associated with the entire Charging Station.
248
+ if (this._sendCostUpdatedOnMeterValue && evseId !== 0) {
249
+ const activeTransaction = await this.transactionEventRepository.getActiveTransactionByStationIdAndEvseId(tenantId, stationId, evseId);
250
+ if (!activeTransaction) {
251
+ this._logger.error('Active Transaction not found on charging station {} evse {}', stationId, evseId);
252
+ }
253
+ const meterValuesCreated = await this._transactionService.createMeterValues(tenantId, meterValues, activeTransaction?.id, activeTransaction?.transactionId, activeTransaction?.tariffId);
254
+ if (activeTransaction) {
255
+ await this._transactionService.recalculateTotalKwh(activeTransaction, meterValuesCreated);
256
+ await this._costNotifier.calculateCostAndNotify(activeTransaction, message.context.tenantId);
257
+ }
258
+ }
259
+ else {
260
+ await this._transactionService.createMeterValues(tenantId, meterValues);
261
+ }
262
+ const meterValuesValid = await this._signedMeterValuesUtil.validateMeterValues(tenantId, stationId, meterValues);
263
+ if (!meterValuesValid) {
264
+ throw new OcppError(message.context.correlationId, ErrorCode.SecurityError, 'One or more MeterValues have an invalid signature.');
265
+ }
266
+ const response = {
267
+ // TODO determine how to set chargingPriority and updatedPersonalMessage for anonymous users
268
+ };
269
+ const messageConfirmation = await this.sendCallResultWithMessage(message, response);
270
+ this._logger.debug('MeterValues response sent: ', messageConfirmation);
271
+ }
272
+ async _handleStatusNotification(message, props) {
273
+ this._logger.debug('StatusNotification received:', message, props);
274
+ this._statusNotificationService
275
+ .processStatusNotification(message.context.tenantId, message.context.stationId, message.payload)
276
+ .catch((error) => {
277
+ this._logger.error('Failed to process status notification', error);
278
+ });
279
+ // Create response
280
+ const response = {};
281
+ const messageConfirmation = await this.sendCallResultWithMessage(message, response);
282
+ this._logger.debug('StatusNotification response sent: ', messageConfirmation);
283
+ }
284
+ /**
285
+ * Handle OCPP 2.0.1 responses
286
+ */
287
+ _handleCostUpdated(message, props) {
288
+ this._logger.debug('CostUpdated response received:', message, props);
289
+ }
290
+ async _handleGetTransactionStatus(message, props) {
291
+ this._logger.debug('GetTransactionStatus response received:', message, props);
292
+ const response = message.payload;
293
+ if (response.ongoingIndicator !== null && response.ongoingIndicator !== undefined) {
294
+ await this._transactionService.updateTransactionStatus(message.context.tenantId, message.context.stationId, message.context.correlationId, response.ongoingIndicator);
295
+ }
296
+ }
297
+ /**
298
+ * Handle OCPP 1.6 requests
299
+ */
300
+ async _handleOcpp16StatusNotification(message, props) {
301
+ this._logger.debug('StatusNotification request received:', message, props);
302
+ await this._statusNotificationService.processOcpp16StatusNotification(message.context.tenantId, message.context.stationId, message.payload);
303
+ // Create response
304
+ const response = {};
305
+ const messageConfirmation = await this.sendCallResultWithMessage(message, response);
306
+ this._logger.debug('StatusNotification response sent: ', messageConfirmation);
307
+ }
308
+ async _handleOcpp16MeterValues(message, props) {
309
+ this._logger.debug('MeterValues request received:', message, props);
310
+ const tenantId = message.context.tenantId;
311
+ const stationId = message.context.stationId;
312
+ const connectorId = message.payload.connectorId;
313
+ const transactionId = message.payload.transactionId;
314
+ const meterValues = message.payload.meterValue;
315
+ if (connectorId !== 0 && transactionId && meterValues.length > 0) {
316
+ try {
317
+ const meterValueEntities = [];
318
+ for (const meterValue of meterValues) {
319
+ if (meterValue.sampledValue && meterValue.sampledValue.length > 0) {
320
+ const meterValueEntity = OCPP1_6_Mapper.MeterValueMapper.fromMeterValueType(meterValue);
321
+ meterValueEntity.tenantId = tenantId;
322
+ meterValueEntity.connectorId = connectorId;
323
+ meterValueEntities.push(meterValueEntity);
324
+ }
325
+ }
326
+ if (meterValueEntities.length > 0) {
327
+ await this._transactionEventRepository.updateTransactionByMeterValues(tenantId, meterValueEntities, stationId, transactionId);
328
+ }
329
+ }
330
+ catch (e) {
331
+ this._logger.error(`Failed to process MeterValues.`, e);
332
+ }
333
+ }
334
+ await this.sendCallResultWithMessage(message, {});
335
+ }
336
+ async _handleOcpp16StartTransaction(message, props) {
337
+ this._logger.debug('OCPP 1.6 StartTransaction request received:', message, props);
338
+ const tenantId = message.context.tenantId;
339
+ const stationId = message.context.stationId;
340
+ const request = message.payload;
341
+ // Authorize
342
+ const response = await this._transactionService.authorizeOcpp16IdToken(message.context, request.idTag, request.connectorId);
343
+ // Send response to charger
344
+ if (response.idTagInfo.status !== OCPP1_6.StartTransactionResponseStatus.Accepted) {
345
+ await this.sendCallResultWithMessage(message, response);
346
+ }
347
+ else {
348
+ try {
349
+ // Create transaction
350
+ const newTransaction = await this._transactionEventRepository.createTransactionByStartTransaction(tenantId, request, stationId);
351
+ response.transactionId = parseInt(newTransaction.transactionId);
352
+ }
353
+ catch (error) {
354
+ const errorMessage = error.message || '';
355
+ if (errorMessage.includes('Charging station') && errorMessage.includes('does not exist')) {
356
+ this._logger.error(`Charging station ${stationId} does not exist for idTag ${request.idTag}`);
357
+ }
358
+ else {
359
+ this._logger.error(`Failed to create transaction for idTag ${request.idTag}`, error);
360
+ }
361
+ response.idTagInfo = {
362
+ status: OCPP1_6.StartTransactionResponseStatus.Invalid,
363
+ };
364
+ }
365
+ await this.sendCallResultWithMessage(message, response);
366
+ }
367
+ // Deactivate reservation
368
+ if (request.reservationId) {
369
+ await this._transactionService.deactivateReservation(tenantId, response.transactionId.toString(), request.reservationId, stationId);
370
+ }
371
+ }
372
+ async _handleOcpp16StopTransaction(message, props) {
373
+ this._logger.debug('OCPP 1.6 StopTransaction request received:', message, props);
374
+ const tenantId = message.context.tenantId;
375
+ const stationId = message.context.stationId;
376
+ const request = message.payload;
377
+ const authorization = request.idTag
378
+ ? await this._authorizeRepository.readOnlyOneByQuerystring(tenantId, {
379
+ idToken: request.idTag,
380
+ })
381
+ : undefined;
382
+ let idTokenInfoStatus = authorization?.status;
383
+ if (authorization === undefined && request.idTag) {
384
+ // Unknown idTag, fallback to Invalid
385
+ idTokenInfoStatus = 'Invalid';
386
+ }
387
+ switch (idTokenInfoStatus) {
388
+ case AuthorizationStatusEnum.Accepted:
389
+ case AuthorizationStatusEnum.Blocked:
390
+ case AuthorizationStatusEnum.Expired:
391
+ case AuthorizationStatusEnum.ConcurrentTx:
392
+ case AuthorizationStatusEnum.Invalid:
393
+ break;
394
+ default: // Other OCPP 2.0.1 statuses default to Invalid for OCPP 1.6
395
+ idTokenInfoStatus = AuthorizationStatusEnum.Invalid;
396
+ }
397
+ let parentIdTag = undefined;
398
+ if (authorization?.groupAuthorizationId) {
399
+ const parentAuth = await this._authorizeRepository.readOnlyOneByQuery(tenantId, {
400
+ where: { id: authorization.groupAuthorizationId },
401
+ });
402
+ if (parentAuth) {
403
+ parentIdTag = parentAuth.idToken;
404
+ }
405
+ }
406
+ const stopTransactionResponse = {
407
+ ...(request.idTag
408
+ ? {
409
+ idTagInfo: {
410
+ expiryDate: authorization?.cacheExpiryDateTime,
411
+ parentIdTag,
412
+ status: idTokenInfoStatus,
413
+ },
414
+ }
415
+ : {}),
416
+ };
417
+ await this.sendCallResultWithMessage(message, stopTransactionResponse);
418
+ const transaction = await Transaction.findOne({
419
+ where: {
420
+ stationId,
421
+ transactionId: request.transactionId.toString(),
422
+ },
423
+ include: [StartTransaction],
424
+ });
425
+ if (!transaction) {
426
+ this._logger.error(`Transaction ${request.transactionId} not found.`);
427
+ return;
428
+ }
429
+ const stopTransaction = await this._transactionEventRepository.createStopTransaction(tenantId, transaction.id, stationId, request.meterStop, new Date(request.timestamp), request.transactionData?.map((data) => OCPP1_6_Mapper.MeterValueMapper.fromMeterValueType(data)) || [], request.reason || (request.idTag ? 'Remote' : 'Local'), authorization?.id);
430
+ if (!stopTransaction) {
431
+ this._logger.error(`Failed to create StopTransaction record for transaction ${request.transactionId}`);
432
+ }
433
+ if (transaction.startTransaction) {
434
+ transaction.totalKwh = (request.meterStop - transaction.startTransaction.meterStart) / 1000; // Convert from Wh to kWh
435
+ }
436
+ else {
437
+ this._logger.warn(`StartTransaction record not found at station ${stationId} for transactionId ${request.transactionId}.
438
+ Cannot calculate totalKwh.`);
439
+ }
440
+ transaction.isActive = false;
441
+ transaction.stoppedReason = request.reason;
442
+ transaction.endTime = request.timestamp;
443
+ await transaction.save();
444
+ }
445
+ }
446
+ __decorate([
447
+ AsHandler(OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.TransactionEvent),
448
+ __metadata("design:type", Function),
449
+ __metadata("design:paramtypes", [Object, Object]),
450
+ __metadata("design:returntype", Promise)
451
+ ], TransactionsModule.prototype, "_handleTransactionEvent", null);
452
+ __decorate([
453
+ AsHandler(OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.MeterValues),
454
+ __metadata("design:type", Function),
455
+ __metadata("design:paramtypes", [Object, Object]),
456
+ __metadata("design:returntype", Promise)
457
+ ], TransactionsModule.prototype, "_handleMeterValues", null);
458
+ __decorate([
459
+ AsHandler(OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.StatusNotification),
460
+ __metadata("design:type", Function),
461
+ __metadata("design:paramtypes", [Object, Object]),
462
+ __metadata("design:returntype", Promise)
463
+ ], TransactionsModule.prototype, "_handleStatusNotification", null);
464
+ __decorate([
465
+ AsHandler(OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.CostUpdated),
466
+ __metadata("design:type", Function),
467
+ __metadata("design:paramtypes", [Object, Object]),
468
+ __metadata("design:returntype", void 0)
469
+ ], TransactionsModule.prototype, "_handleCostUpdated", null);
470
+ __decorate([
471
+ AsHandler(OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.GetTransactionStatus),
472
+ __metadata("design:type", Function),
473
+ __metadata("design:paramtypes", [Object, Object]),
474
+ __metadata("design:returntype", Promise)
475
+ ], TransactionsModule.prototype, "_handleGetTransactionStatus", null);
476
+ __decorate([
477
+ AsHandler(OCPPVersion.OCPP1_6, OCPP1_6_CallAction.StatusNotification),
478
+ __metadata("design:type", Function),
479
+ __metadata("design:paramtypes", [Object, Object]),
480
+ __metadata("design:returntype", Promise)
481
+ ], TransactionsModule.prototype, "_handleOcpp16StatusNotification", null);
482
+ __decorate([
483
+ AsHandler(OCPPVersion.OCPP1_6, OCPP1_6_CallAction.MeterValues),
484
+ __metadata("design:type", Function),
485
+ __metadata("design:paramtypes", [Object, Object]),
486
+ __metadata("design:returntype", Promise)
487
+ ], TransactionsModule.prototype, "_handleOcpp16MeterValues", null);
488
+ __decorate([
489
+ AsHandler(OCPPVersion.OCPP1_6, OCPP1_6_CallAction.StartTransaction),
490
+ __metadata("design:type", Function),
491
+ __metadata("design:paramtypes", [Object, Object]),
492
+ __metadata("design:returntype", Promise)
493
+ ], TransactionsModule.prototype, "_handleOcpp16StartTransaction", null);
494
+ __decorate([
495
+ AsHandler(OCPPVersion.OCPP1_6, OCPP1_6_CallAction.StopTransaction),
496
+ __metadata("design:type", Function),
497
+ __metadata("design:paramtypes", [Object, Object]),
498
+ __metadata("design:returntype", Promise)
499
+ ], TransactionsModule.prototype, "_handleOcpp16StopTransaction", null);
500
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module/module.ts"],"names":[],"mappings":";;;;;;;;;AAgBA,OAAO,EACL,cAAc,EACd,SAAS,EACT,uBAAuB,EACvB,cAAc,EACd,SAAS,EACT,UAAU,EACV,OAAO,EACP,kBAAkB,EAClB,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EACL,aAAa,EACb,SAAS,EACT,cAAc,EACd,SAAS,EACT,8BAA8B,EAC9B,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GAClB,MAAM,iBAAi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C,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,WAAW,CAAC;;;;kEAsC9D;AAGe;IADf,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,gBAAgB,CAAC;;;;uEAuDnE;AAGe;IADf,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,eAAe,CAAC;;;;sEAuGlE"}
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@zetra/citrineos-transactions",
3
+ "version": "1.8.3-fork.1",
4
+ "type": "module",
5
+ "description": "The transactions module for OCPP v2.0.1. This module is not intended to be used directly, but rather as a dependency for other modules.",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "prepublish": "npx eslint",
13
+ "test": "vitest run"
14
+ },
15
+ "keywords": [
16
+ "ocpp",
17
+ "ocpp_v201"
18
+ ],
19
+ "license": "Apache-2.0",
20
+ "dependencies": {
21
+ "@zetra/citrineos-base": "1.8.3-fork.1",
22
+ "@zetra/citrineos-data": "1.8.3-fork.1",
23
+ "@zetra/citrineos-util": "1.8.3-fork.1"
24
+ }
25
+ }