1 // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
4 import path from
'path';
5 import { URL
, fileURLToPath
} from
'url';
7 import type { JSONSchemaType
} from
'ajv';
8 import { Client
, type FTPResponse
} from
'basic-ftp';
11 import OCPPError from
'../../../exception/OCPPError';
12 import type { JsonObject
, JsonType
} from
'../../../types/JsonType';
13 import { OCPP16ChargePointErrorCode
} from
'../../../types/ocpp/1.6/ChargePointErrorCode';
14 import { OCPP16ChargePointStatus
} from
'../../../types/ocpp/1.6/ChargePointStatus';
16 ChargingProfilePurposeType
,
17 type OCPP16ChargingProfile
,
18 } from
'../../../types/ocpp/1.6/ChargingProfile';
20 OCPP16StandardParametersKey
,
21 OCPP16SupportedFeatureProfiles
,
22 } from
'../../../types/ocpp/1.6/Configuration';
23 import { OCPP16DiagnosticsStatus
} from
'../../../types/ocpp/1.6/DiagnosticsStatus';
25 type ChangeAvailabilityRequest
,
26 type ChangeConfigurationRequest
,
27 type ClearChargingProfileRequest
,
28 type GetConfigurationRequest
,
29 type GetDiagnosticsRequest
,
30 OCPP16AvailabilityType
,
31 type OCPP16BootNotificationRequest
,
32 type OCPP16ClearCacheRequest
,
33 type OCPP16DataTransferRequest
,
34 OCPP16DataTransferVendorId
,
35 type OCPP16DiagnosticsStatusNotificationRequest
,
37 type OCPP16FirmwareStatusNotificationRequest
,
38 type OCPP16HeartbeatRequest
,
39 OCPP16IncomingRequestCommand
,
42 type OCPP16StatusNotificationRequest
,
43 type OCPP16TriggerMessageRequest
,
44 type OCPP16UpdateFirmwareRequest
,
45 type RemoteStartTransactionRequest
,
46 type RemoteStopTransactionRequest
,
48 type SetChargingProfileRequest
,
49 type UnlockConnectorRequest
,
50 } from
'../../../types/ocpp/1.6/Requests';
52 type ChangeAvailabilityResponse
,
53 type ChangeConfigurationResponse
,
54 type ClearChargingProfileResponse
,
55 type GetConfigurationResponse
,
56 type GetDiagnosticsResponse
,
57 type OCPP16BootNotificationResponse
,
58 type OCPP16DataTransferResponse
,
59 OCPP16DataTransferStatus
,
60 type OCPP16DiagnosticsStatusNotificationResponse
,
61 type OCPP16FirmwareStatusNotificationResponse
,
62 type OCPP16HeartbeatResponse
,
63 type OCPP16StatusNotificationResponse
,
64 type OCPP16TriggerMessageResponse
,
65 type OCPP16UpdateFirmwareResponse
,
66 type SetChargingProfileResponse
,
67 type UnlockConnectorResponse
,
68 } from
'../../../types/ocpp/1.6/Responses';
70 OCPP16AuthorizationStatus
,
71 type OCPP16AuthorizeRequest
,
72 type OCPP16AuthorizeResponse
,
73 type OCPP16StartTransactionRequest
,
74 type OCPP16StartTransactionResponse
,
75 OCPP16StopTransactionReason
,
76 } from
'../../../types/ocpp/1.6/Transaction';
77 import type { OCPPConfigurationKey
} from
'../../../types/ocpp/Configuration';
78 import { ErrorType
} from
'../../../types/ocpp/ErrorType';
79 import { OCPPVersion
} from
'../../../types/ocpp/OCPPVersion';
80 import type { IncomingRequestHandler
} from
'../../../types/ocpp/Requests';
81 import type { GenericResponse
} from
'../../../types/ocpp/Responses';
82 import Constants from
'../../../utils/Constants';
83 import logger from
'../../../utils/Logger';
84 import Utils from
'../../../utils/Utils';
85 import type ChargingStation from
'../../ChargingStation';
86 import { ChargingStationConfigurationUtils
} from
'../../ChargingStationConfigurationUtils';
87 import { ChargingStationUtils
} from
'../../ChargingStationUtils';
88 import OCPPConstants from
'../OCPPConstants';
89 import OCPPIncomingRequestService from
'../OCPPIncomingRequestService';
90 import { OCPP16ServiceUtils
} from
'./OCPP16ServiceUtils';
92 const moduleName
= 'OCPP16IncomingRequestService';
94 export default class OCPP16IncomingRequestService
extends OCPPIncomingRequestService
{
95 protected jsonSchemas
: Map
<OCPP16IncomingRequestCommand
, JSONSchemaType
<JsonObject
>>;
96 private incomingRequestHandlers
: Map
<OCPP16IncomingRequestCommand
, IncomingRequestHandler
>;
98 public constructor() {
99 if (new.target
?.name
=== moduleName
) {
100 throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
102 super(OCPPVersion
.VERSION_16
);
103 this.incomingRequestHandlers
= new Map
<OCPP16IncomingRequestCommand
, IncomingRequestHandler
>([
104 [OCPP16IncomingRequestCommand
.RESET
, this.handleRequestReset
.bind(this)],
105 [OCPP16IncomingRequestCommand
.CLEAR_CACHE
, this.handleRequestClearCache
.bind(this)],
106 [OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
, this.handleRequestUnlockConnector
.bind(this)],
108 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
109 this.handleRequestGetConfiguration
.bind(this),
112 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
113 this.handleRequestChangeConfiguration
.bind(this),
116 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
117 this.handleRequestSetChargingProfile
.bind(this),
120 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
121 this.handleRequestClearChargingProfile
.bind(this),
124 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
125 this.handleRequestChangeAvailability
.bind(this),
128 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
129 this.handleRequestRemoteStartTransaction
.bind(this),
132 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
133 this.handleRequestRemoteStopTransaction
.bind(this),
135 [OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
, this.handleRequestGetDiagnostics
.bind(this)],
136 [OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
, this.handleRequestTriggerMessage
.bind(this)],
137 [OCPP16IncomingRequestCommand
.DATA_TRANSFER
, this.handleRequestDataTransfer
.bind(this)],
138 [OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
, this.handleRequestUpdateFirmware
.bind(this)],
140 this.jsonSchemas
= new Map
<OCPP16IncomingRequestCommand
, JSONSchemaType
<JsonObject
>>([
142 OCPP16IncomingRequestCommand
.RESET
,
143 this.parseJsonSchemaFile
<ResetRequest
>('../../../assets/json-schemas/ocpp/1.6/Reset.json'),
146 OCPP16IncomingRequestCommand
.CLEAR_CACHE
,
147 this.parseJsonSchemaFile
<OCPP16ClearCacheRequest
>(
148 '../../../assets/json-schemas/ocpp/1.6/ClearCache.json'
152 OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
,
153 this.parseJsonSchemaFile
<UnlockConnectorRequest
>(
154 '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json'
158 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
159 this.parseJsonSchemaFile
<GetConfigurationRequest
>(
160 '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json'
164 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
165 this.parseJsonSchemaFile
<ChangeConfigurationRequest
>(
166 '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json'
170 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
171 this.parseJsonSchemaFile
<GetDiagnosticsRequest
>(
172 '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json'
176 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
177 this.parseJsonSchemaFile
<SetChargingProfileRequest
>(
178 '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json'
182 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
183 this.parseJsonSchemaFile
<ClearChargingProfileRequest
>(
184 '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json'
188 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
189 this.parseJsonSchemaFile
<ChangeAvailabilityRequest
>(
190 '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json'
194 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
195 this.parseJsonSchemaFile
<RemoteStartTransactionRequest
>(
196 '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json'
200 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
201 this.parseJsonSchemaFile
<RemoteStopTransactionRequest
>(
202 '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json'
206 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
207 this.parseJsonSchemaFile
<OCPP16TriggerMessageRequest
>(
208 '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json'
212 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
213 this.parseJsonSchemaFile
<OCPP16DataTransferRequest
>(
214 '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json'
218 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
,
219 this.parseJsonSchemaFile
<OCPP16UpdateFirmwareRequest
>(
220 '../../../assets/json-schemas/ocpp/1.6/UpdateFirmware.json'
224 this.validatePayload
.bind(this);
227 public async incomingRequestHandler(
228 chargingStation
: ChargingStation
,
230 commandName
: OCPP16IncomingRequestCommand
,
231 commandPayload
: JsonType
233 let response
: JsonType
;
235 chargingStation
.getOcppStrictCompliance() === true &&
236 chargingStation
.isInPendingState() === true &&
237 (commandName
=== OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
||
238 commandName
=== OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
)
241 ErrorType
.SECURITY_ERROR
,
242 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
246 )} while the charging station is in pending state on the central server`,
252 chargingStation
.isRegistered() === true ||
253 (chargingStation
.getOcppStrictCompliance() === false &&
254 chargingStation
.isInUnknownState() === true)
257 this.incomingRequestHandlers
.has(commandName
) === true &&
258 OCPP16ServiceUtils
.isIncomingRequestCommandSupported(chargingStation
, commandName
) === true
261 this.validatePayload(chargingStation
, commandName
, commandPayload
);
262 // Call the method to build the response
263 response
= await this.incomingRequestHandlers
.get(commandName
)(
270 `${chargingStation.logPrefix()} ${moduleName}.incomingRequestHandler: Handle incoming request error:`,
278 ErrorType
.NOT_IMPLEMENTED
,
279 `${commandName} is not implemented to handle request PDU ${JSON.stringify(
290 ErrorType
.SECURITY_ERROR
,
291 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
295 )} while the charging station is not registered on the central server.`,
300 // Send the built response
301 await chargingStation
.ocppRequestService
.sendResponse(
309 private validatePayload(
310 chargingStation
: ChargingStation
,
311 commandName
: OCPP16IncomingRequestCommand
,
312 commandPayload
: JsonType
314 if (this.jsonSchemas
.has(commandName
) === true) {
315 return this.validateIncomingRequestPayload(
318 this.jsonSchemas
.get(commandName
),
323 `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command '${commandName}' PDU validation`
328 // Simulate charging station restart
329 private handleRequestReset(
330 chargingStation
: ChargingStation
,
331 commandPayload
: ResetRequest
335 chargingStation
.reset
.bind(chargingStation
) as (
336 this: ChargingStation
,
340 (commandPayload
.type + 'Reset') as OCPP16StopTransactionReason
343 /* This is intentional */
346 `${chargingStation.logPrefix()} ${
348 } reset command received, simulating it. The station will be back online in ${Utils.formatDurationMilliSeconds(
349 chargingStation.stationInfo.resetTime
352 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
355 private async handleRequestUnlockConnector(
356 chargingStation
: ChargingStation
,
357 commandPayload
: UnlockConnectorRequest
358 ): Promise
<UnlockConnectorResponse
> {
359 const connectorId
= commandPayload
.connectorId
;
360 if (chargingStation
.connectors
.has(connectorId
) === false) {
362 `${chargingStation.logPrefix()} Trying to unlock a non existing connector Id ${connectorId.toString()}`
364 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
366 if (connectorId
=== 0) {
368 chargingStation
.logPrefix() + ' Trying to unlock connector Id ' + connectorId
.toString()
370 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
372 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
373 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
375 OCPP16StopTransactionReason
.UNLOCK_COMMAND
377 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
378 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
380 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_FAILED
;
382 await chargingStation
.ocppRequestService
.requestHandler
<
383 OCPP16StatusNotificationRequest
,
384 OCPP16StatusNotificationResponse
385 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
387 status: OCPP16ChargePointStatus
.AVAILABLE
,
388 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
390 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
391 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
394 private handleRequestGetConfiguration(
395 chargingStation
: ChargingStation
,
396 commandPayload
: GetConfigurationRequest
397 ): GetConfigurationResponse
{
398 const configurationKey
: OCPPConfigurationKey
[] = [];
399 const unknownKey
: string[] = [];
400 if (Utils
.isEmptyArray(commandPayload
.key
) === true) {
401 for (const configuration
of chargingStation
.ocppConfiguration
.configurationKey
) {
402 if (Utils
.isUndefined(configuration
.visible
) === true) {
403 configuration
.visible
= true;
405 if (configuration
.visible
=== false) {
408 configurationKey
.push({
409 key
: configuration
.key
,
410 readonly: configuration
.readonly,
411 value
: configuration
.value
,
415 for (const key
of commandPayload
.key
) {
416 const keyFound
= ChargingStationConfigurationUtils
.getConfigurationKey(
421 if (Utils
.isUndefined(keyFound
.visible
) === true) {
422 keyFound
.visible
= true;
424 if (keyFound
.visible
=== false) {
427 configurationKey
.push({
429 readonly: keyFound
.readonly,
430 value
: keyFound
.value
,
433 unknownKey
.push(key
);
443 private handleRequestChangeConfiguration(
444 chargingStation
: ChargingStation
,
445 commandPayload
: ChangeConfigurationRequest
446 ): ChangeConfigurationResponse
{
447 const keyToChange
= ChargingStationConfigurationUtils
.getConfigurationKey(
453 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED
;
454 } else if (keyToChange
&& keyToChange
.readonly) {
455 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REJECTED
;
456 } else if (keyToChange
&& !keyToChange
.readonly) {
457 let valueChanged
= false;
458 if (keyToChange
.value
!== commandPayload
.value
) {
459 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
462 commandPayload
.value
,
467 let triggerHeartbeatRestart
= false;
468 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartBeatInterval
&& valueChanged
) {
469 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
471 OCPP16StandardParametersKey
.HeartbeatInterval
,
474 triggerHeartbeatRestart
= true;
476 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartbeatInterval
&& valueChanged
) {
477 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
479 OCPP16StandardParametersKey
.HeartBeatInterval
,
482 triggerHeartbeatRestart
= true;
484 if (triggerHeartbeatRestart
) {
485 chargingStation
.restartHeartbeat();
487 if (keyToChange
.key
=== OCPP16StandardParametersKey
.WebSocketPingInterval
&& valueChanged
) {
488 chargingStation
.restartWebSocketPing();
490 if (keyToChange
.reboot
) {
491 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED
;
493 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_ACCEPTED
;
497 private handleRequestSetChargingProfile(
498 chargingStation
: ChargingStation
,
499 commandPayload
: SetChargingProfileRequest
500 ): SetChargingProfileResponse
{
502 OCPP16ServiceUtils
.checkFeatureProfile(
504 OCPP16SupportedFeatureProfiles
.SmartCharging
,
505 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
508 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED
;
510 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
512 `${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector Id ${
513 commandPayload.connectorId
516 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
519 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
520 ChargingProfilePurposeType
.CHARGE_POINT_MAX_PROFILE
&&
521 commandPayload
.connectorId
!== 0
523 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
526 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
527 ChargingProfilePurposeType
.TX_PROFILE
&&
528 (commandPayload
.connectorId
=== 0 ||
529 chargingStation
.getConnectorStatus(commandPayload
.connectorId
)?.transactionStarted
===
533 `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${
534 commandPayload.connectorId
535 } without a started transaction`
537 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
539 OCPP16ServiceUtils
.setChargingProfile(
541 commandPayload
.connectorId
,
542 commandPayload
.csChargingProfiles
545 `${chargingStation.logPrefix()} Charging profile(s) set on connector id ${
546 commandPayload.connectorId
547 }, dump their stack: %j`,
548 chargingStation
.getConnectorStatus(commandPayload
.connectorId
).chargingProfiles
550 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
553 private handleRequestClearChargingProfile(
554 chargingStation
: ChargingStation
,
555 commandPayload
: ClearChargingProfileRequest
556 ): ClearChargingProfileResponse
{
558 OCPP16ServiceUtils
.checkFeatureProfile(
560 OCPP16SupportedFeatureProfiles
.SmartCharging
,
561 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
564 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
566 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
568 `${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector Id ${
569 commandPayload.connectorId
572 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
574 const connectorStatus
= chargingStation
.getConnectorStatus(commandPayload
.connectorId
);
575 if (commandPayload
.connectorId
&& !Utils
.isEmptyArray(connectorStatus
.chargingProfiles
)) {
576 connectorStatus
.chargingProfiles
= [];
578 `${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${
579 commandPayload.connectorId
580 }, dump their stack: %j`,
581 connectorStatus
.chargingProfiles
583 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
585 if (!commandPayload
.connectorId
) {
586 let clearedCP
= false;
587 for (const connectorId
of chargingStation
.connectors
.keys()) {
588 if (!Utils
.isEmptyArray(chargingStation
.getConnectorStatus(connectorId
).chargingProfiles
)) {
590 .getConnectorStatus(connectorId
)
591 .chargingProfiles
?.forEach((chargingProfile
: OCPP16ChargingProfile
, index
: number) => {
592 let clearCurrentCP
= false;
593 if (chargingProfile
.chargingProfileId
=== commandPayload
.id
) {
594 clearCurrentCP
= true;
597 !commandPayload
.chargingProfilePurpose
&&
598 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
600 clearCurrentCP
= true;
603 !chargingProfile
.stackLevel
&&
604 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
606 clearCurrentCP
= true;
609 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
&&
610 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
612 clearCurrentCP
= true;
614 if (clearCurrentCP
) {
615 connectorStatus
.chargingProfiles
.splice(index
, 1);
617 `${chargingStation.logPrefix()} Matching charging profile(s) cleared on connector id ${
618 commandPayload.connectorId
619 }, dump their stack: %j`,
620 connectorStatus
.chargingProfiles
628 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
631 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
634 private async handleRequestChangeAvailability(
635 chargingStation
: ChargingStation
,
636 commandPayload
: ChangeAvailabilityRequest
637 ): Promise
<ChangeAvailabilityResponse
> {
638 const connectorId
: number = commandPayload
.connectorId
;
639 if (chargingStation
.connectors
.has(connectorId
) === false) {
641 `${chargingStation.logPrefix()} Trying to change the availability of a non existing connector Id ${connectorId.toString()}`
643 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
645 const chargePointStatus
: OCPP16ChargePointStatus
=
646 commandPayload
.type === OCPP16AvailabilityType
.OPERATIVE
647 ? OCPP16ChargePointStatus
.AVAILABLE
648 : OCPP16ChargePointStatus
.UNAVAILABLE
;
649 if (connectorId
=== 0) {
650 let response
: ChangeAvailabilityResponse
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
651 for (const id
of chargingStation
.connectors
.keys()) {
652 if (chargingStation
.getConnectorStatus(id
)?.transactionStarted
=== true) {
653 response
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
655 chargingStation
.getConnectorStatus(id
).availability
= commandPayload
.type;
656 if (response
=== OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
) {
657 await chargingStation
.ocppRequestService
.requestHandler
<
658 OCPP16StatusNotificationRequest
,
659 OCPP16StatusNotificationResponse
660 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
662 status: chargePointStatus
,
663 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
665 chargingStation
.getConnectorStatus(id
).status = chargePointStatus
;
671 (chargingStation
.isChargingStationAvailable() === true ||
672 (chargingStation
.isChargingStationAvailable() === false &&
673 commandPayload
.type === OCPP16AvailabilityType
.INOPERATIVE
))
675 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
676 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
677 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
679 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
680 await chargingStation
.ocppRequestService
.requestHandler
<
681 OCPP16StatusNotificationRequest
,
682 OCPP16StatusNotificationResponse
683 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
685 status: chargePointStatus
,
686 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
688 chargingStation
.getConnectorStatus(connectorId
).status = chargePointStatus
;
689 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
691 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
694 private async handleRequestRemoteStartTransaction(
695 chargingStation
: ChargingStation
,
696 commandPayload
: RemoteStartTransactionRequest
697 ): Promise
<GenericResponse
> {
698 const transactionConnectorId
= commandPayload
.connectorId
;
699 if (chargingStation
.connectors
.has(transactionConnectorId
) === true) {
700 const remoteStartTransactionLogMsg
=
701 chargingStation
.logPrefix() +
702 ' Transaction remotely STARTED on ' +
703 chargingStation
.stationInfo
.chargingStationId
+
705 transactionConnectorId
.toString() +
707 commandPayload
.idTag
+
709 await chargingStation
.ocppRequestService
.requestHandler
<
710 OCPP16StatusNotificationRequest
,
711 OCPP16StatusNotificationResponse
712 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
713 connectorId
: transactionConnectorId
,
714 status: OCPP16ChargePointStatus
.PREPARING
,
715 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
717 const connectorStatus
= chargingStation
.getConnectorStatus(transactionConnectorId
);
718 connectorStatus
.status = OCPP16ChargePointStatus
.PREPARING
;
719 if (chargingStation
.isChargingStationAvailable() === true) {
720 // Check if authorized
721 if (chargingStation
.getAuthorizeRemoteTxRequests() === true) {
722 let authorized
= false;
724 chargingStation
.getLocalAuthListEnabled() === true &&
725 chargingStation
.hasAuthorizedTags() === true &&
726 chargingStation
.authorizedTagsCache
728 ChargingStationUtils
.getAuthorizationFile(chargingStation
.stationInfo
)
730 .find((idTag
) => idTag
=== commandPayload
.idTag
)
732 connectorStatus
.localAuthorizeIdTag
= commandPayload
.idTag
;
733 connectorStatus
.idTagLocalAuthorized
= true;
735 } else if (chargingStation
.getMustAuthorizeAtRemoteStart() === true) {
736 connectorStatus
.authorizeIdTag
= commandPayload
.idTag
;
737 const authorizeResponse
: OCPP16AuthorizeResponse
=
738 await chargingStation
.ocppRequestService
.requestHandler
<
739 OCPP16AuthorizeRequest
,
740 OCPP16AuthorizeResponse
741 >(chargingStation
, OCPP16RequestCommand
.AUTHORIZE
, {
742 idTag
: commandPayload
.idTag
,
744 if (authorizeResponse
?.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
749 `${chargingStation.logPrefix()} The charging station configuration expects authorize at remote start transaction but local authorization or authorize isn't enabled`
752 if (authorized
=== true) {
753 // Authorization successful, start transaction
755 this.setRemoteStartTransactionChargingProfile(
757 transactionConnectorId
,
758 commandPayload
.chargingProfile
761 connectorStatus
.transactionRemoteStarted
= true;
764 await chargingStation
.ocppRequestService
.requestHandler
<
765 OCPP16StartTransactionRequest
,
766 OCPP16StartTransactionResponse
767 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
768 connectorId
: transactionConnectorId
,
769 idTag
: commandPayload
.idTag
,
771 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
773 logger
.debug(remoteStartTransactionLogMsg
);
774 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
776 return this.notifyRemoteStartTransactionRejected(
778 transactionConnectorId
,
782 return this.notifyRemoteStartTransactionRejected(
784 transactionConnectorId
,
788 return this.notifyRemoteStartTransactionRejected(
790 transactionConnectorId
,
794 // No authorization check required, start transaction
796 this.setRemoteStartTransactionChargingProfile(
798 transactionConnectorId
,
799 commandPayload
.chargingProfile
802 connectorStatus
.transactionRemoteStarted
= true;
805 await chargingStation
.ocppRequestService
.requestHandler
<
806 OCPP16StartTransactionRequest
,
807 OCPP16StartTransactionResponse
808 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
809 connectorId
: transactionConnectorId
,
810 idTag
: commandPayload
.idTag
,
812 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
814 logger
.debug(remoteStartTransactionLogMsg
);
815 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
817 return this.notifyRemoteStartTransactionRejected(
819 transactionConnectorId
,
823 return this.notifyRemoteStartTransactionRejected(
825 transactionConnectorId
,
829 return this.notifyRemoteStartTransactionRejected(
831 transactionConnectorId
,
835 return this.notifyRemoteStartTransactionRejected(
837 transactionConnectorId
,
842 private async notifyRemoteStartTransactionRejected(
843 chargingStation
: ChargingStation
,
846 ): Promise
<GenericResponse
> {
848 chargingStation
.getConnectorStatus(connectorId
).status !== OCPP16ChargePointStatus
.AVAILABLE
850 await chargingStation
.ocppRequestService
.requestHandler
<
851 OCPP16StatusNotificationRequest
,
852 OCPP16StatusNotificationResponse
853 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
855 status: OCPP16ChargePointStatus
.AVAILABLE
,
856 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
858 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
861 chargingStation
.logPrefix() +
862 ' Remote starting transaction REJECTED on connector Id ' +
863 connectorId
.toString() +
866 "', availability '" +
867 chargingStation
.getConnectorStatus(connectorId
).availability
+
869 chargingStation
.getConnectorStatus(connectorId
).status +
872 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
875 private setRemoteStartTransactionChargingProfile(
876 chargingStation
: ChargingStation
,
878 cp
: OCPP16ChargingProfile
880 if (cp
&& cp
.chargingProfilePurpose
=== ChargingProfilePurposeType
.TX_PROFILE
) {
881 OCPP16ServiceUtils
.setChargingProfile(chargingStation
, connectorId
, cp
);
883 `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}, dump their stack: %j`,
884 chargingStation
.getConnectorStatus(connectorId
).chargingProfiles
887 } else if (cp
&& cp
.chargingProfilePurpose
!== ChargingProfilePurposeType
.TX_PROFILE
) {
889 `${chargingStation.logPrefix()} Not allowed to set ${
890 cp.chargingProfilePurpose
891 } charging profile(s) at remote start transaction`
899 private async handleRequestRemoteStopTransaction(
900 chargingStation
: ChargingStation
,
901 commandPayload
: RemoteStopTransactionRequest
902 ): Promise
<GenericResponse
> {
903 const transactionId
= commandPayload
.transactionId
;
904 for (const connectorId
of chargingStation
.connectors
.keys()) {
907 chargingStation
.getConnectorStatus(connectorId
)?.transactionId
=== transactionId
909 await chargingStation
.ocppRequestService
.requestHandler
<
910 OCPP16StatusNotificationRequest
,
911 OCPP16StatusNotificationResponse
912 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
914 status: OCPP16ChargePointStatus
.FINISHING
,
915 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
917 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.FINISHING
;
918 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
920 OCPP16StopTransactionReason
.REMOTE
922 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
923 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
925 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
929 chargingStation
.logPrefix() +
930 ' Trying to remote stop a non existing transaction ' +
931 transactionId
.toString()
933 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
936 private handleRequestUpdateFirmware(
937 chargingStation
: ChargingStation
,
938 commandPayload
: OCPP16UpdateFirmwareRequest
939 ): OCPP16UpdateFirmwareResponse
{
941 OCPP16ServiceUtils
.checkFeatureProfile(
943 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
944 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
947 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
949 const retrieveDate
= Utils
.convertToDate(commandPayload
.retrieveDate
);
950 if (retrieveDate
.getTime() <= Date.now()) {
953 this.updateFirmware
.bind(this) as (
954 this: OCPP16IncomingRequestService
,
961 /* This is intentional */
965 this.updateFirmware(chargingStation
).catch(() => {
968 }, retrieveDate
.getTime() - Date.now());
970 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
973 private async updateFirmware(
974 chargingStation
: ChargingStation
,
978 chargingStation
.stopAutomaticTransactionGenerator();
979 for (const connectorId
of chargingStation
.connectors
.keys()) {
982 chargingStation
.getConnectorStatus(connectorId
).transactionStarted
=== false
984 await chargingStation
.ocppRequestService
.requestHandler
<
985 OCPP16StatusNotificationRequest
,
986 OCPP16StatusNotificationResponse
987 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
989 status: OCPP16ChargePointStatus
.UNAVAILABLE
,
990 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
992 chargingStation
.getConnectorStatus(connectorId
).status =
993 OCPP16ChargePointStatus
.UNAVAILABLE
;
996 await chargingStation
.ocppRequestService
.requestHandler
<
997 OCPP16FirmwareStatusNotificationRequest
,
998 OCPP16FirmwareStatusNotificationResponse
999 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1000 status: OCPP16FirmwareStatus
.Downloading
,
1002 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloading
;
1003 await Utils
.sleep(Utils
.getRandomInteger(minDelay
, maxDelay
) * 1000);
1004 await chargingStation
.ocppRequestService
.requestHandler
<
1005 OCPP16FirmwareStatusNotificationRequest
,
1006 OCPP16FirmwareStatusNotificationResponse
1007 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1008 status: OCPP16FirmwareStatus
.Downloaded
,
1010 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloaded
;
1011 await Utils
.sleep(Utils
.getRandomInteger(minDelay
, maxDelay
) * 1000);
1012 await chargingStation
.ocppRequestService
.requestHandler
<
1013 OCPP16FirmwareStatusNotificationRequest
,
1014 OCPP16FirmwareStatusNotificationResponse
1015 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1016 status: OCPP16FirmwareStatus
.Installing
,
1018 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Installing
;
1019 await Utils
.sleep(Utils
.getRandomInteger(minDelay
, maxDelay
) * 1000);
1020 await chargingStation
.reset(OCPP16StopTransactionReason
.REBOOT
);
1023 private async handleRequestGetDiagnostics(
1024 chargingStation
: ChargingStation
,
1025 commandPayload
: GetDiagnosticsRequest
1026 ): Promise
<GetDiagnosticsResponse
> {
1028 OCPP16ServiceUtils
.checkFeatureProfile(
1030 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
1031 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1034 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1036 const uri
= new URL(commandPayload
.location
);
1037 if (uri
.protocol
.startsWith('ftp:')) {
1038 let ftpClient
: Client
;
1041 .readdirSync(path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'))
1042 .filter((file
) => file
.endsWith('.log'))
1043 .map((file
) => path
.join('./', file
));
1044 const diagnosticsArchive
= chargingStation
.stationInfo
.chargingStationId
+ '_logs.tar.gz';
1045 tar
.create({ gzip
: true }, logFiles
).pipe(fs
.createWriteStream(diagnosticsArchive
));
1046 ftpClient
= new Client();
1047 const accessResponse
= await ftpClient
.access({
1049 ...(!Utils
.isEmptyString(uri
.port
) && { port
: Utils
.convertToInt(uri
.port
) }),
1050 ...(!Utils
.isEmptyString(uri
.username
) && { user
: uri
.username
}),
1051 ...(!Utils
.isEmptyString(uri
.password
) && { password
: uri
.password
}),
1053 let uploadResponse
: FTPResponse
;
1054 if (accessResponse
.code
=== 220) {
1055 // eslint-disable-next-line @typescript-eslint/no-misused-promises
1056 ftpClient
.trackProgress(async (info
) => {
1058 `${chargingStation.logPrefix()} ${
1060 } bytes transferred from diagnostics archive ${info.name}`
1062 await chargingStation
.ocppRequestService
.requestHandler
<
1063 OCPP16DiagnosticsStatusNotificationRequest
,
1064 OCPP16DiagnosticsStatusNotificationResponse
1065 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1066 status: OCPP16DiagnosticsStatus
.Uploading
,
1069 uploadResponse
= await ftpClient
.uploadFrom(
1071 path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'),
1074 uri
.pathname
+ diagnosticsArchive
1076 if (uploadResponse
.code
=== 226) {
1077 await chargingStation
.ocppRequestService
.requestHandler
<
1078 OCPP16DiagnosticsStatusNotificationRequest
,
1079 OCPP16DiagnosticsStatusNotificationResponse
1080 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1081 status: OCPP16DiagnosticsStatus
.Uploaded
,
1086 return { fileName
: diagnosticsArchive
};
1088 throw new OCPPError(
1089 ErrorType
.GENERIC_ERROR
,
1090 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1091 uploadResponse?.code && '|' + uploadResponse?.code.toString()
1093 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1096 throw new OCPPError(
1097 ErrorType
.GENERIC_ERROR
,
1098 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1099 uploadResponse?.code && '|' + uploadResponse?.code.toString()
1101 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1104 await chargingStation
.ocppRequestService
.requestHandler
<
1105 OCPP16DiagnosticsStatusNotificationRequest
,
1106 OCPP16DiagnosticsStatusNotificationResponse
1107 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1108 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1113 return this.handleIncomingRequestError(
1115 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
1117 { errorResponse
: OCPPConstants
.OCPP_RESPONSE_EMPTY
}
1122 `${chargingStation.logPrefix()} Unsupported protocol ${
1124 } to transfer the diagnostic logs archive`
1126 await chargingStation
.ocppRequestService
.requestHandler
<
1127 OCPP16DiagnosticsStatusNotificationRequest
,
1128 OCPP16DiagnosticsStatusNotificationResponse
1129 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1130 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1132 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1136 private handleRequestTriggerMessage(
1137 chargingStation
: ChargingStation
,
1138 commandPayload
: OCPP16TriggerMessageRequest
1139 ): OCPP16TriggerMessageResponse
{
1141 !OCPP16ServiceUtils
.checkFeatureProfile(
1143 OCPP16SupportedFeatureProfiles
.RemoteTrigger
,
1144 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
1146 !OCPP16ServiceUtils
.isMessageTriggerSupported(
1148 commandPayload
.requestedMessage
1151 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1154 !OCPP16ServiceUtils
.isConnectorIdValid(
1156 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1157 commandPayload
.connectorId
1160 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
;
1163 switch (commandPayload
.requestedMessage
) {
1164 case OCPP16MessageTrigger
.BootNotification
:
1166 chargingStation
.ocppRequestService
1167 .requestHandler
<OCPP16BootNotificationRequest
, OCPP16BootNotificationResponse
>(
1169 OCPP16RequestCommand
.BOOT_NOTIFICATION
,
1170 chargingStation
.bootNotificationRequest
,
1171 { skipBufferingOnError
: true, triggerMessage
: true }
1173 .then((response
) => {
1174 chargingStation
.bootNotificationResponse
= response
;
1177 /* This is intentional */
1179 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1180 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1181 case OCPP16MessageTrigger
.Heartbeat
:
1183 chargingStation
.ocppRequestService
1184 .requestHandler
<OCPP16HeartbeatRequest
, OCPP16HeartbeatResponse
>(
1186 OCPP16RequestCommand
.HEARTBEAT
,
1189 triggerMessage
: true,
1193 /* This is intentional */
1195 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1196 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1197 case OCPP16MessageTrigger
.StatusNotification
:
1199 if (commandPayload
?.connectorId
) {
1200 chargingStation
.ocppRequestService
1201 .requestHandler
<OCPP16StatusNotificationRequest
, OCPP16StatusNotificationResponse
>(
1203 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1205 connectorId
: commandPayload
.connectorId
,
1206 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1207 status: chargingStation
.getConnectorStatus(commandPayload
.connectorId
).status,
1210 triggerMessage
: true,
1214 /* This is intentional */
1217 for (const connectorId
of chargingStation
.connectors
.keys()) {
1218 chargingStation
.ocppRequestService
1220 OCPP16StatusNotificationRequest
,
1221 OCPP16StatusNotificationResponse
1224 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1227 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1228 status: chargingStation
.getConnectorStatus(connectorId
).status,
1231 triggerMessage
: true,
1235 /* This is intentional */
1239 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1240 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1242 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1245 return this.handleIncomingRequestError(
1247 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1249 { errorResponse
: OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
}
1254 private handleRequestDataTransfer(
1255 chargingStation
: ChargingStation
,
1256 commandPayload
: OCPP16DataTransferRequest
1257 ): OCPP16DataTransferResponse
{
1259 if (Object.values(OCPP16DataTransferVendorId
).includes(commandPayload
.vendorId
)) {
1261 status: OCPP16DataTransferStatus
.ACCEPTED
,
1265 status: OCPP16DataTransferStatus
.UNKNOWN_VENDOR_ID
,
1268 return this.handleIncomingRequestError(
1270 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
1272 { errorResponse
: OCPPConstants
.OCPP_DATA_TRANSFER_RESPONSE_REJECTED
}
1277 private parseJsonSchemaFile
<T
extends JsonType
>(relativePath
: string): JSONSchemaType
<T
> {
1280 path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), relativePath
),
1283 ) as JSONSchemaType
<T
>;