repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
citrineos-core
github_2023
citrineos
typescript
LocalAuthListService.persistSendLocalListForStationIdAndCorrelationIdAndSendLocalListRequest
async persistSendLocalListForStationIdAndCorrelationIdAndSendLocalListRequest( stationId: string, correlationId: string, sendLocalListRequest: SendLocalListRequest, ): Promise<SendLocalList> { const localListVersion = await this._localAuthListRepository.readOnlyOneByQuery({ where: { ...
/** * Validates a SendLocalListRequest and persists it, then returns the correlation Id. * * @param {string} stationId - The ID of the station to which the SendLocalListRequest belongs. * @param {string} correlationId - The correlation Id that will be used for the SendLocalListRequest. * @param {SendLoca...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/EVDriver/src/module/LocalAuthListService.ts#L40-L95
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
EVDriverModuleApi.constructor
constructor( evDriverModule: EVDriverModule, server: FastifyInstance, logger?: Logger<ILogObj>, ) { super(evDriverModule, server, logger); }
/** * Constructs a new instance of the class. * * @param {EVDriverModule} evDriverModule - The EVDriver module. * @param {FastifyInstance} server - The Fastify server instance. * @param {Logger<ILogObj>} [logger] - The logger for logging. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/EVDriver/src/module/api.ts#L65-L71
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
EVDriverModuleApi._toMessagePath
protected _toMessagePath(input: CallAction): string { const endpointPrefix = this._module.config.modules.evdriver.endpointPrefix; return super._toMessagePath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link CallAction} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link CallAction}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/EVDriver/src/module/api.ts#L428-L431
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
EVDriverModuleApi._toDataPath
protected _toDataPath(input: Namespace): string { const endpointPrefix = this._module.config.modules.evdriver.endpointPrefix; return super._toDataPath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link Namespace} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link Namespace}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/EVDriver/src/module/api.ts#L439-L442
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
EVDriverModule.constructor
constructor( config: SystemConfig, cache: ICache, sender?: IMessageSender, handler?: IMessageHandler, logger?: Logger<ILogObj>, authorizeRepository?: IAuthorizationRepository, localAuthListRepository?: ILocalAuthListRepository, deviceModelRepository?: IDeviceModelRepository, tariffRe...
/** * This is the constructor function that initializes the {@link EVDriverModule}. * * @param {SystemConfig} config - The `config` contains configuration settings for the module. * * @param {ICache} [cache] - The cache instance which is shared among the modules & Central System to pass information such ...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/EVDriver/src/module/module.ts#L168-L247
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MonitoringModuleApi.constructor
constructor( monitoringModule: MonitoringModule, server: FastifyInstance, logger?: Logger<ILogObj>, ) { super(monitoringModule, server, logger); }
/** * Constructor for the class. * * @param {MonitoringModule} monitoringModule - The monitoring module. * @param {FastifyInstance} server - The server instance. * @param {Logger<ILogObj>} [logger] - The logger instance. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Monitoring/src/module/api.ts#L68-L74
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MonitoringModuleApi._toMessagePath
protected _toMessagePath(input: CallAction): string { const endpointPrefix = this._module.config.modules.monitoring.endpointPrefix; return super._toMessagePath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link CallAction} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link CallAction}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Monitoring/src/module/api.ts#L531-L535
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MonitoringModuleApi._toDataPath
protected _toDataPath(input: Namespace): string { const endpointPrefix = this._module.config.modules.monitoring.endpointPrefix; return super._toDataPath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link Namespace} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link Namespace}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Monitoring/src/module/api.ts#L543-L547
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MonitoringModule.constructor
constructor( config: SystemConfig, cache: ICache, sender?: IMessageSender, handler?: IMessageHandler, logger?: Logger<ILogObj>, deviceModelRepository?: IDeviceModelRepository, variableMonitoringRepository?: IVariableMonitoringRepository, idGenerator?: IdGenerator, ) { super( ...
/** * This is the constructor function that initializes the {@link MonitoringModule}. * * @param {SystemConfig} config - The `config` contains configuration settings for the module. * * @param {ICache} [cache] - The cache instance which is shared among the modules & Central System to pass information suc...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Monitoring/src/module/module.ts#L101-L151
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
DeviceModelService.getItemsPerMessageByComponentAndVariableInstanceAndStationId
async getItemsPerMessageByComponentAndVariableInstanceAndStationId( componentName: string, variableInstance: string, stationId: string, ): Promise<number | null> { const itemsPerMessageAttributes: VariableAttribute[] = await this._deviceModelRepository.readAllByQuerystring({ stationId: s...
/** * Fetches the ItemsPerMessage attribute from the device model. * Returns null if no such attribute exists. * It is possible for there to be multiple ItemsPerMessage attributes if component instances or evses * are associated with alternate options. That structure is not supported by this logic, and that...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Monitoring/src/module/services.ts#L25-L46
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
DeviceModelService.getBytesPerMessageByComponentAndVariableInstanceAndStationId
async getBytesPerMessageByComponentAndVariableInstanceAndStationId( componentName: string, variableInstance: string, stationId: string, ): Promise<number | null> { const bytesPerMessageAttributes: VariableAttribute[] = await this._deviceModelRepository.readAllByQuerystring({ stationId: s...
/** * Fetches the BytesPerMessage attribute from the device model. * Returns null if no such attribute exists. * It is possible for there to be multiple BytesPerMessage attributes if component instances or evses * are associated with alternate options. That structure is not supported by this logic, and that...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Monitoring/src/module/services.ts#L58-L79
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
AdminApi.constructor
constructor( ocppRouter: MessageRouterImpl, server: FastifyInstance, logger?: Logger<ILogObj>, ) { super(ocppRouter, server, logger); }
/** * Constructs a new instance of the class. * * @param {MessageRouterImpl} ocppRouter - The OcppRouter module. * @param {FastifyInstance} server - The Fastify server instance. * @param {Logger<ILogObj>} [logger] - The logger instance. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/api.ts#L44-L50
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
AdminApi._toMessagePath
protected _toMessagePath(input: CallAction): string { const endpointPrefix = '/ocpprouter'; return super._toMessagePath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link CallAction} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link CallAction}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/api.ts#L152-L155
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
AdminApi._toDataPath
protected _toDataPath(input: Namespace): string { const endpointPrefix = '/ocpprouter'; return super._toDataPath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link Namespace} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link Namespace}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/api.ts#L163-L166
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl.constructor
constructor( config: SystemConfig, cache: ICache, sender: IMessageSender, handler: IMessageHandler, dispatcher: WebhookDispatcher, networkHook: (identifier: string, message: string) => Promise<boolean>, logger?: Logger<ILogObj>, ajv?: Ajv, locationRepository?: ILocationRepository, ...
/** * Constructor for the class. * * @param {SystemConfig} config - the system configuration * @param {ICache} cache - the cache object * @param {IMessageSender} [sender] - the message sender * @param {IMessageHandler} [handler] - the message handler * @param {WebhookDispatcher} [dispatcher] - the ...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L81-L106
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl.registerConnection
async registerConnection(connectionIdentifier: string): Promise<boolean> { const dispatcherRegistration = this._webhookDispatcher.register(connectionIdentifier); const requestSubscription = this._handler.subscribe( connectionIdentifier, undefined, { stationId: connectionIdentifi...
// TODO: Below method should lock these tables so that a rapid connect-disconnect cannot result in race condition.
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L109-L148
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl.onMessage
async onMessage( identifier: string, message: string, timestamp: Date, ): Promise<boolean> { this._webhookDispatcher.dispatchMessageReceived(identifier, message); let rpcMessage: any; let messageTypeId: MessageTypeId | undefined = undefined; let messageId: string = '-1'; // OCPP 2.0.1 part...
// find way to include tenantId here
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L161-L221
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl.sendCall
async sendCall( identifier: string, tenantId: string, action: CallAction, payload: OcppRequest, correlationId = uuidv4(), origin?: MessageOrigin, ): Promise<IMessageConfirmation> { const message: Call = [MessageTypeId.Call, correlationId, action, payload]; if (await this._sendCallIsAll...
/** * Sends a Call message to a charging station with given identifier. * * @param {string} identifier - The identifier of the charging station. * @param {Call} message - The Call message to send. * @return {Promise<boolean>} A promise that resolves to a boolean indicating if the call was sent successful...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L230-L268
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl.sendCallResult
async sendCallResult( correlationId: string, identifier: string, tenantId: string, action: CallAction, payload: OcppResponse, origin?: MessageOrigin, ): Promise<IMessageConfirmation> { const message: CallResult = [ MessageTypeId.CallResult, correlationId, payload, ]; ...
/** * Sends the CallResult to a charging station with given identifier. * * @param {string} identifier - The identifier of the charging station. * @param {CallResult} message - The CallResult message to send. * @return {Promise<boolean>} A promise that resolves to true if the call result was sent success...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L277-L320
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl.sendCallError
async sendCallError( correlationId: string, identifier: string, tenantId: string, action: CallAction, error: OcppError, origin?: MessageOrigin | undefined, ): Promise<IMessageConfirmation> { const message: CallError = error.asCallError(); const cachedActionMessageId = await this._cache...
/** * Sends a CallError message to a charging station with given identifier. * * @param {string} identifier - The identifier of the charging station. * @param {CallError} message - The CallError message to send. * @return {Promise<boolean>} - A promise that resolves to true if the message was sent succes...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L329-L368
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl._onCall
async _onCall( identifier: string, message: Call, timestamp: Date, ): Promise<void> { const messageId = message[1]; const action = message[2] as CallAction; try { const isAllowed = await this._onCallIsAllowed(action, identifier); if (!isAllowed) { throw new OcppError( ...
/** * Handles an incoming Call message from a client connection. * * @param {string} identifier - The client identifier. * @param {Call} message - The Call message received. * @param {Date} timestamp Time at which the message was received from the charger. * @return {void} */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L387-L480
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl._onCallResult
_onCallResult( identifier: string, message: CallResult, timestamp: Date, ): void { const messageId = message[1]; const payload = message[2]; this._logger.debug('Process CallResult', identifier, messageId, payload); this._cache .get<string>(identifier, CacheNamespace.Transactions) ...
/** * Handles a CallResult made by the client. * * @param {string} identifier - The client identifier that made the call. * @param {CallResult} message - The OCPP CallResult message. * @param {Date} timestamp Time at which the message was received from the charger. * @return {void} */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L490-L556
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl._onCallError
_onCallError(identifier: string, message: CallError, timestamp: Date): void { const messageId = message[1]; this._logger.debug('Process CallError', identifier, message); this._cache .get<string>(identifier, CacheNamespace.Transactions) .then((cachedActionMessageId) => { this._cache.rem...
/** * Handles the CallError that may have occured during a Call exchange. * * @param {string} identifier - The client identifier. * @param {CallError} message - The error message. * @param {Date} timestamp Time at which the message was received from the charger. * @return {void} This function doesn't ...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L566-L606
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
MessageRouterImpl._onCallIsAllowed
private _onCallIsAllowed( action: CallAction, identifier: string, ): Promise<boolean> { return this._cache .exists(action, identifier) .then((blacklisted) => !blacklisted); }
/** * Determine if the given action for identifier is allowed. * * @param {CallAction} action - The action to be checked. * @param {string} identifier - The identifier to be checked. * @return {Promise<boolean>} A promise that resolves to a boolean indicating if the action and identifier are allowed. ...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/router.ts#L615-L622
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
WebhookDispatcher._loadSubscriptionsForConnection
private async _loadSubscriptionsForConnection(connectionIdentifier: string) { const onConnectionCallbacks: OnConnectionCallback[] = []; const onCloseCallbacks: OnCloseCallback[] = []; const onMessageCallbacks: OnMessageCallback[] = []; const sentMessageCallbacks: OnSentMessageCallback[] = []; const...
/** * Loads all subscriptions for a given connection into memory * * @param {string} connectionIdentifier - the identifier of the connection * @return {Promise<void>} a promise that resolves once all subscriptions are loaded */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/webhook.dispatcher.ts#L129-L174
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
WebhookDispatcher._subscriptionCallback
private async _subscriptionCallback( requestBody: { stationId: string; event: string; origin?: MessageOrigin; message?: string; error?: any; info?: Map<string, string>; }, url: string, ): Promise<boolean> { try { const response = await fetch(url, { met...
/** * Sends a message to a given URL that has been subscribed to a station connection event * * @param {Object} requestBody - request body containing stationId, event, origin, message, error, and info * @param {string} url - the URL to fetch data from * @return {Promise<boolean>} a Promise that resolves ...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/OcppRouter/src/module/webhook.dispatcher.ts#L250-L285
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
ReportingModuleApi.constructor
constructor( reportingModule: ReportingModule, server: FastifyInstance, logger?: Logger<ILogObj>, ) { super(reportingModule, server, logger); }
/** * Constructs a new instance of the class. * * @param {ReportingModule} ReportingModule - The Reporting module. * @param {FastifyInstance} server - The Fastify server instance. * @param {Logger<ILogObj>} [logger] - The logger instance. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Reporting/src/module/api.ts#L47-L53
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
ReportingModuleApi._toMessagePath
protected _toMessagePath(input: CallAction): string { const endpointPrefix = this._module.config.modules.reporting.endpointPrefix; return super._toMessagePath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link CallAction} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link CallAction}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Reporting/src/module/api.ts#L274-L277
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
ReportingModuleApi._toDataPath
protected _toDataPath(input: Namespace): string { const endpointPrefix = this._module.config.modules.reporting.endpointPrefix; return super._toDataPath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link Namespace} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link Namespace}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Reporting/src/module/api.ts#L285-L288
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
ReportingModule.constructor
constructor( config: SystemConfig, cache: ICache, sender?: IMessageSender, handler?: IMessageHandler, logger?: Logger<ILogObj>, deviceModelRepository?: IDeviceModelRepository, securityEventRepository?: ISecurityEventRepository, variableMonitoringRepository?: IVariableMonitoringRepository...
/** * This is the constructor function that initializes the {@link ReportingModule}. * * @param {SystemConfig} config - The `config` contains configuration settings for the module. * * @param {ICache} [cache] - The cache instance which is shared among the modules & Central System to pass information such...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Reporting/src/module/module.ts#L116-L158
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
DeviceModelService.getItemsPerMessageByComponentAndVariableInstanceAndStationId
async getItemsPerMessageByComponentAndVariableInstanceAndStationId( componentName: string, variableInstance: string, stationId: string, ): Promise<number | null> { const itemsPerMessageAttributes: VariableAttribute[] = await this._deviceModelRepository.readAllByQuerystring({ stationId: s...
/** * Fetches the ItemsPerMessage attribute from the device model. * Returns null if no such attribute exists. * @param stationId Charging station identifier. * @returns ItemsPerMessage as a number or null if no such attribute exists. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Reporting/src/module/services.ts#L21-L42
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
DeviceModelService.getBytesPerMessageByComponentAndVariableInstanceAndStationId
async getBytesPerMessageByComponentAndVariableInstanceAndStationId( componentName: string, variableInstance: string, stationId: string, ): Promise<number | null> { const bytesPerMessageAttributes: VariableAttribute[] = await this._deviceModelRepository.readAllByQuerystring({ stationId: s...
/** * Fetches the BytesPerMessage attribute from the device model. * Returns null if no such attribute exists. * It is possible for there to be multiple BytesPerMessage attributes if component instances or evses * are associated with alternate options. That structure is not supported by this logic, and that...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Reporting/src/module/services.ts#L54-L75
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
SmartChargingModuleApi.constructor
constructor( smartChargingModule: SmartChargingModule, server: FastifyInstance, logger?: Logger<ILogObj>, ) { super(smartChargingModule, server, logger); }
/** * Constructs a new instance of the class. * * @param {SmartChargingModule} smartChargingModule - The SmartCharging module. * @param {FastifyInstance} server - The Fastify server instance. * @param {Logger<ILogObj>} [logger] - The logger instance. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/SmartCharging/src/module/api.ts#L50-L56
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
SmartChargingModuleApi._toMessagePath
protected _toMessagePath(input: CallAction): string { const endpointPrefix = this._module.config.modules.smartcharging?.endpointPrefix; return super._toMessagePath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link CallAction} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link CallAction}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/SmartCharging/src/module/api.ts#L588-L592
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
SmartChargingModuleApi._toDataPath
protected _toDataPath(input: Namespace): string { const endpointPrefix = this._module.config.modules.smartcharging?.endpointPrefix; return super._toDataPath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link Namespace} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link Namespace}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/SmartCharging/src/module/api.ts#L600-L604
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
SmartChargingModule.constructor
constructor( config: SystemConfig, cache: ICache, sender?: IMessageSender, handler?: IMessageHandler, logger?: Logger<ILogObj>, transactionEventRepository?: ITransactionEventRepository, deviceModelRepository?: IDeviceModelRepository, chargingProfileRepository?: IChargingProfileRepository...
/** * This is the constructor function that initializes the {@link SmartChargingModule}. * * @param {SystemConfig} config - The `config` contains configuration settings for the module. * * @param {ICache} [cache] - The cache instance which is shared among the modules & Central System to pass information ...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/SmartCharging/src/module/module.ts#L132-L183
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
SmartChargingModule._generateSetChargingProfileRequest
private async _generateSetChargingProfileRequest( request: NotifyEVChargingScheduleRequest, transaction: Transaction, stationId: string, ): Promise<SetChargingProfileRequest> { const { chargingSchedule, evseId } = request; const purpose = ChargingProfilePurposeEnumType.TxProfile; chargingSche...
/** * Generates a `SetChargingProfileRequest` from the given `NotifyEVChargingScheduleRequest`. * * This method creates a charging profile based on the EV's charging schedule. * * @param request - The `NotifyEVChargingScheduleRequest` containing EV's charging schedule. * @param transaction - The trans...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/SmartCharging/src/module/module.ts#L573-L605
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
InternalSmartCharging.calculateChargingProfile
async calculateChargingProfile( request: NotifyEVChargingNeedsRequest, transaction: Transaction, stationId: string, ): Promise<ChargingProfileType> { const { chargingNeeds } = request; const acParams = chargingNeeds.acChargingParameters; const dcParams = chargingNeeds.dcChargingParameters; ...
/** * Generates a `ChargingProfileType` from the given `NotifyEVChargingNeedsRequest`. * * This method creates a charging profile based on the EV's charging needs and the specified energy transfer mode. * The profile includes the necessary parameters to set up a charging schedule for the EV. * * @para...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/SmartCharging/src/module/smartCharging/InternalSmartCharging.ts#L48-L157
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
TenantModuleApi.constructor
constructor( tenantModule: TenantModule, server: FastifyInstance, logger?: Logger<ILogObj>, ) { super(tenantModule, server, logger); }
/** * * Constructs a new instance of the class. * * @param {TenantModule} tenantModule - The Tenant module. * @param {FastifyInstance} server - The Fastify server instance. * @param {Logger<ILogObj>} [logger] - The logger instance. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Tenant/src/module/api.ts#L27-L33
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
TenantModuleApi._toMessagePath
protected _toMessagePath(input: CallAction): string { const endpointPrefix = this._module.config.modules.tenant.endpointPrefix; return super._toMessagePath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link CallAction} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link CallAction}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Tenant/src/module/api.ts#L41-L44
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
TenantModuleApi._toDataPath
protected _toDataPath(input: Namespace): string { const endpointPrefix = this._module.config.modules.tenant.endpointPrefix; return super._toDataPath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link Namespace} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link Namespace}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Tenant/src/module/api.ts#L52-L55
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
TenantModule.constructor
constructor( config: SystemConfig, cache: ICache, sender?: IMessageSender, handler?: IMessageHandler, logger?: Logger<ILogObj>, ) { super( config, cache, handler || new RabbitMqReceiver(config, logger), sender || new RabbitMqSender(config, logger), EventGroup.Tena...
/** * This is the constructor function that initializes the {@link TenantModule}. * * @param {SystemConfig} config - The `config` contains configuration settings for the module. * * @param {ICache} [cache] - The cache instance which is shared among the modules & Central System to pass information such as...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Tenant/src/module/module.ts#L49-L75
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
CostCalculator.calculateTotalCost
async calculateTotalCost( stationId: string, transactionDbId: number, totalKwh?: number | null, ): Promise<number> { if (totalKwh === undefined || totalKwh === null) { const kwh = await this._transactionService.recalculateTotalKwh(transactionDbId); return this._calculateTotalCost(s...
/** * Calculates the total cost for a transaction. * * Computes the cost based on `stationId` and `totalKwh`. * If `totalKwh` is not provided, it is calculated for given transaction. * * @param stationId - The identifier of the station. * @param transactionDbId - The identifier of the transaction. ...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Transactions/src/module/CostCalculator.ts#L36-L47
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
CostNotifier.notifyWhileActive
notifyWhileActive( stationId: string, transactionId: string, tenantId: string, intervalSeconds: number, ): void { this._logger.debug( `Scheduling periodic cost notifications for ${stationId} station, ${transactionId} transaction, ${tenantId} tenant`, ); this.schedule( this._key...
/** * Repeatedly sends a CostUpdated call for an ongoing transaction based on the intervalSeconds. * Stops sending requests once the transaction becomes inactive. * * @param {string} stationId - The identifier of the client connection. * @param {string} transactionId - The identifier of the transaction. ...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Transactions/src/module/CostNotifier.ts#L34-L48
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
StatusNotificationService.processStatusNotification
async processStatusNotification( stationId: string, statusNotificationRequest: StatusNotificationRequest, ) { const chargingStation = await this._locationRepository.readChargingStationByStationId(stationId); if (chargingStation) { await this._locationRepository.addStatusNotificationToCharg...
/** * Stores an internal record of the incoming status, then updates the device model for the updated connector. * * @param {string} stationId - The Charging Station sending the status notification request * @param {StatusNotificationRequest} statusNotificationRequest */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Transactions/src/module/StatusNotificationService.ts#L41-L99
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
TransactionsModuleApi.constructor
constructor( transactionModule: TransactionsModule, server: FastifyInstance, logger?: Logger<ILogObj>, ) { super(transactionModule, server, logger); }
/** * Constructor for the class. * * @param {TransactionModule} transactionModule - The transaction module. * @param {FastifyInstance} server - The server instance. * @param {Logger<ILogObj>} [logger] - Optional logger. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Transactions/src/module/api.ts#L49-L55
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
TransactionsModuleApi._toMessagePath
protected _toMessagePath(input: CallAction): string { const endpointPrefix = this._module.config.modules.transactions.endpointPrefix; return super._toMessagePath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link CallAction} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link CallAction}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Transactions/src/module/api.ts#L151-L155
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
TransactionsModuleApi._toDataPath
protected _toDataPath(input: Namespace): string { const endpointPrefix = this._module.config.modules.transactions.endpointPrefix; return super._toDataPath(input, endpointPrefix); }
/** * Overrides superclass method to generate the URL path based on the input {@link Namespace} and the module's endpoint prefix configuration. * * @param {CallAction} input - The input {@link Namespace}. * @return {string} - The generated URL path. */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Transactions/src/module/api.ts#L163-L167
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
TransactionsModuleApi.buildTariff
private buildTariff(request: UpsertTariffRequest): Tariff { return Tariff.newInstance({ id: request.id, currency: request.currency, pricePerKwh: request.pricePerKwh, pricePerMin: request.pricePerMin, pricePerSession: request.pricePerSession, taxRate: request.taxRate, author...
// TODO: move to service layer
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Transactions/src/module/api.ts#L170-L181
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
TransactionsModule.constructor
constructor( config: SystemConfig, cache: ICache, fileAccess: IFileAccess, sender?: IMessageSender, handler?: IMessageHandler, logger?: Logger<ILogObj>, transactionEventRepository?: ITransactionEventRepository, authorizeRepository?: IAuthorizationRepository, deviceModelRepository?: I...
/** * This is the constructor function that initializes the {@link TransactionsModule}. * * @param {SystemConfig} config - The `config` contains configuration settings for the module. * * @param {ICache} [cache] - The cache instance which is shared among the modules & Central System to pass information s...
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/03_Modules/Transactions/src/module/module.ts#L154-L252
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
CitrineOSServer.constructor
constructor( appName: string, config: SystemConfig, server?: FastifyInstance, ajv?: Ajv, cache?: ICache, fileAccess?: IFileAccess, ) { // Set system config // TODO: Create and export config schemas for each util module, such as amqp, redis, kafka, etc, to avoid passing them possibly in...
// todo rename event group to type
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/Server/src/index.ts#L120-L194
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
fastifySchemaCompiler
const fastifySchemaCompiler: FastifySchemaCompiler<any> = ( routeSchema: FastifyRouteSchemaDef<any>, ) => this._ajv?.compile(routeSchema.schema) as FastifyValidationResult;
// todo type schema instead of any
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/Server/src/index.ts#L335-L337
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
CitrineOSServer.constructor
constructor( config: SystemConfig, server?: FastifyInstance, ajv?: Ajv, cache?: ICache, ) { // Set system config // TODO: Create and export config schemas for each util module, such as amqp, redis, kafka, etc, to avoid passing them possibly invalid configuration if (!config.util.messageBro...
/** * Constructor for the class. * * @param {FastifyInstance} server - optional Fastify server instance * @param {Ajv} ajv - optional Ajv JSON schema validator instance */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/Swarm/src/index.ts#L80-L201
462a009d9b7a2dabb8e9a55442654cdb39e672eb
citrineos-core
github_2023
citrineos
typescript
ModuleService.constructor
constructor( config: SystemConfig, appName: string, server?: FastifyInstance, ajv?: Ajv, cache?: ICache, ) { // Set system config // TODO: Create and export config schemas for each util module, such as amqp, redis, kafka, etc, to avoid passing them possibly invalid configuration if (!c...
/** * Constructor for the class. * * @param {FastifyInstance} server - optional Fastify server instance * @param {Ajv} ajv - optional Ajv JSON schema validator instance */
https://github.com/citrineos/citrineos-core/blob/462a009d9b7a2dabb8e9a55442654cdb39e672eb/Swarm/src/index.ts#L265-L509
462a009d9b7a2dabb8e9a55442654cdb39e672eb
himalaya-ui
github_2023
red-ninjas
typescript
getScaleAmount
const getScaleAmount = (orignalSize: number, scaleAmount: number) => { return `${parseInt(String(orignalSize * scaleAmount))}px`; };
/** * Calculates amount to scale cursor in px3 * @param {number} orignalSize - starting size * @param {number} scaleAmount - Amount to scale * @returns {String} Scale amount in px */
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/animated-cursor/animated-cursor.tsx#L130-L132
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
fetchData
const fetchData = async () => { if (searchFunction == undefined) { return []; } const data = await searchFunction(input); setResults(data); setPreventHover(true); itemsRef.current?.scrollTo(0, 0); return data; };
// declare the data fetching function
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/search/search.tsx#L90-L100
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
hue2rgb
const hue2rgb = (p: number, q: number, t: number) => { if (t < 0) { t += 1; } if (t > 1) { t -= 1; } if (t < 1 / 6) { return p + (q - p) * 6 * t; } if (t < 1 / 2) { return q; } if (t < 2 / 3) { return p + (q - p) * (2 / 3 - t) * 6; } return p; ...
// tslint:disable-next-line:no-shadowed-variable
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/themes/utils/color.ts#L53-L70
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
ChartWidget._applyAutoSizeOptions
private _applyAutoSizeOptions(options: DeepPartial<ChartOptionsInternal<HorzScaleItem>>): void { if (options.autoSize === undefined && this._observer && (options.width !== undefined || options.height !== undefined)) { warn(`You should turn autoSize off explicitly before specifying sizes; try adding options.au...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/gui/chart-widget.ts#L315-L332
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
ChartWidget._traverseLayout
private _traverseLayout(ctx: CanvasRenderingContext2D | null): Size { let totalWidth = 0; let totalHeight = 0; const firstPane = this._paneWidgets[0]; const drawPriceAxises = (position: 'left' | 'right', targetX: number) => { let targetY = 0; for (let paneIndex = 0; paneIndex < this._paneW...
/** * Traverses the widget's layout (pane and axis child widgets), * draws the screenshot (if rendering context is passed) and returns the screenshot bitmap size * * @param ctx - if passed, used to draw the screenshot of widget * @returns screenshot bitmap size */
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/gui/chart-widget.ts#L341-L431
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
ChartWidget._adjustSizeImpl
private _adjustSizeImpl(): void { let totalStretch = 0; let leftPriceAxisWidth = 0; let rightPriceAxisWidth = 0; for (const paneWidget of this._paneWidgets) { if (this._isLeftAxisVisible()) { leftPriceAxisWidth = Math.max( leftPriceAxisWidth, ensureNotNull(paneWidget.l...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/gui/chart-widget.ts#L434-L520
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
ChartWidget._syncGuiWithModel
private _syncGuiWithModel(): void { const panes = this._model.panes(); const targetPaneWidgetsCount = panes.length; const actualPaneWidgetsCount = this._paneWidgets.length; // Remove (if needed) pane widgets and separators for (let i = targetPaneWidgetsCount; i < actualPaneWidgetsCount; i++) { ...
// }
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/gui/chart-widget.ts#L694-L744
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
MouseEventHandler._onMobileSafariDoubleClick
private _onFirefoxOutsideMouseUp = (mouseUpEvent: MouseEvent) => { this._mouseUpHandler(mouseUpEvent); }
/** * Safari doesn't fire touchstart/mousedown events on double tap since iOS 13. * There are two possible solutions: * 1) Call preventDefault in touchEnd handler. But it also prevents click event from firing. * 2) Add listener on dblclick event that fires with the preceding mousedown/mouseup. * https://...
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/gui/mouse-event-handler.ts
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
MouseEventHandler._touchEndHandler
private _touchEndHandler(touchEndEvent: TouchEvent): void { let touch = touchWithId(touchEndEvent.changedTouches, ensureNotNull(this._activeTouchId)); if (touch === null && touchEndEvent.touches.length === 0) { // something went wrong, somehow we missed the required touchend event // probably the br...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/gui/mouse-event-handler.ts#L387-L445
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
comparePrimitiveZOrder
function comparePrimitiveZOrder(item: SeriesPrimitivePaneViewZOrder, reference?: SeriesPrimitivePaneViewZOrder): boolean { return !reference || (item === 'top' && reference !== 'top') || (item === 'normal' && reference === 'bottom'); }
// returns true if item is above reference
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/gui/pane-hit-test.ts#L26-L28
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
hitTestPaneView
function hitTestPaneView(paneViews: readonly IPaneView[], x: Coordinate, y: Coordinate): HitTestPaneViewResult | null { for (const paneView of paneViews) { const renderer = paneView.renderer(); if (renderer !== null && renderer.hitTest) { const result = renderer.hitTest(x, y); if (result !== null)...
/** * Performs a hit test on a collection of pane views to determine which view and object * is located at a given coordinate (x, y) and returns the matching pane view and * hit-tested result object, or null if no match is found. */
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/gui/pane-hit-test.ts#L66-L81
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
PaneWidget._pressedMouseTouchMoveEvent
private _pressedMouseTouchMoveEvent(event: TouchMouseEvent): void { if (this._state === null) { return; } const model = this._model(); const timeScale = model.timeScale(); if (timeScale.isEmpty()) { return; } const chartOptions = this._chart.options(); const scrollOptions ...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/gui/pane-widget.ts#L714-L784
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
ChartModel.zoomTime
public zoomTime(pointX: Coordinate, scale: number): void { const timeScale = this.timeScale(); if (timeScale.isEmpty() || scale === 0) { return; } const timeScaleWidth = timeScale.width(); pointX = Math.max(1, Math.min(pointX, timeScaleWidth)) as Coordinate; timeScale.zoom(pointX, scale)...
/** * Zoom in/out the chart (depends on scale value). * * @param pointX - X coordinate of the point to apply the zoom (the point which should stay on its place) * @param scale - Zoom value. Negative value means zoom out, positive - zoom in. */
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/chart-model.ts#L680-L692
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
DataLayer._replaceTimeScalePoints
private _replaceTimeScalePoints(newTimePoints: InternalTimeScalePoint[]): number { let firstChangedPointIndex = -1; // search the first different point and "syncing" time weight by the way for (let index = 0; index < this._sortedTimePoints.length && index < newTimePoints.length; ++index) { const oldP...
/** * Sets new time scale and make indexes valid for all series * * @returns The index of the first changed point or `-1` if there is no change. */
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/data-layer.ts#L379-L420
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
PlotList.last
public last(): PlotRowType | null { return this.size() > 0 ? this._items[this._items.length - 1] : null; }
// @returns Last row
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/plot-list.ts#L46-L48
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
PriceScale.setMode
public setMode(newMode: Partial<PriceScaleState>): void { const oldMode = this.mode(); let priceRange: PriceRangeImpl | null = null; if (newMode.autoScale !== undefined) { this._options.autoScale = newMode.autoScale; } if (newMode.mode !== undefined) { this._options.mode = newMode.mode...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/price-scale.ts#L314-L368
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
PriceScale._formatterSource
private _formatterSource(): IPriceDataSource | null { return this._dataSources[0] || null; }
/** * @returns The {@link IPriceDataSource} that will be used as the "formatter source" (take minMove for formatter). */
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/price-scale.ts#L834-L836
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
PriceScale._recalculatePriceRangeImpl
private _recalculatePriceRangeImpl(): void { const visibleBars = this._invalidatedForRange.visibleBars; if (visibleBars === null) { return; } let priceRange: PriceRangeImpl | null = null; const sources = this.sourcesForAutoScale(); let marginAbove = 0; let marginBelow = 0; for (...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/price-scale.ts#L892-L997
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
TimeScale.visibleStrictRange
public visibleStrictRange(): RangeImpl<TimePointIndex> | null { this._updateVisibleRange(); return this._visibleRange.strictRange(); }
// strict range: integer indices of the bars in the visible range rounded in more wide direction
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/time-scale.ts#L343-L346
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
TimeScale.marks
public marks(): TimeMark[] | null { if (this.isEmpty()) { return null; } if (this._timeMarksCache !== null) { return this._timeMarksCache; } const spacing = this._barSpacing; const fontSize = this._model.options().layout.fontSize; const pixelsPer8Characters = (fontSize + 4) * ...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/time-scale.ts#L490-L563
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
TimeScale.zoom
public zoom(zoomPoint: Coordinate, scale: number): void { const floatIndexAtZoomPoint = this._coordinateToFloatIndex(zoomPoint); const barSpacing = this.barSpacing(); const newBarSpacing = barSpacing + scale * (barSpacing / 10); // zoom in/out bar spacing this.setBarSpacing(newBarSpacing); if...
/** * Zoom in/out the scale around a `zoomPoint` on `scale` value. * * @param zoomPoint - X coordinate of the point to apply the zoom. * If `rightBarStaysOnScroll` option is disabled, then will be used to restore right offset. * @param scale - Zoom value (in 1/10 parts of current bar spacing). * Negat...
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/time-scale.ts#L588-L601
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
weightToTickMarkType
function weightToTickMarkType(weight: TickMarkWeight, timeVisible: boolean, secondsVisible: boolean): TickMarkType { switch (weight) { case TickMarkWeight.LessThanSecond: case TickMarkWeight.Second: return timeVisible ? (secondsVisible ? TickMarkType.TimeWithSeconds : TickMarkType.Time) : TickMarkType.D...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/model/horz-scale-behavior-time/horz-scale-behavior-time.ts#L132-L156
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
PaneRendererBars._drawImpl
protected override _drawImpl({ context: ctx, horizontalPixelRatio, verticalPixelRatio }: BitmapCoordinatesRenderingScope): void { if (this._data === null || this._data.bars.length === 0 || this._data.visibleRange === null) { return; } this._barWidth = this._calcBarWidth(horizontalPixelRatio); //...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/renderers/bars-renderer.ts#L35-L108
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
PaneRendererHistogram._fillPrecalculatedCache
private _fillPrecalculatedCache(pixelRatio: number): void { if (this._data === null || this._data.items.length === 0 || this._data.visibleRange === null) { this._precalculatedCache = []; return; } const spacing = Math.ceil(this._data.barSpacing * pixelRatio) <= showSpacingMinimalBarWidth ? 0 : M...
// eslint-disable-next-line complexity
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/renderers/histogram-renderer.ts#L76-L155
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
SeriesHorizontalBaseLinePaneView.constructor
public constructor(series: ISeries<SeriesType>) { super(series); }
// eslint-disable-next-line no-useless-constructor
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/views/pane/series-horizontal-base-line-pane-view.ts#L9-L11
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
fillSizeAndY
function fillSizeAndY( rendererItem: SeriesMarkerRendererDataItem, marker: InternalSeriesMarker<TimePointIndex>, seriesData: BarPrices | BarPrice, offsets: Offsets, textHeight: number, shapeMargin: number, priceScale: PriceScale, timeScale: ITimeScale, firstValue: number, ): void { const inBarPrice ...
// eslint-disable-next-line max-params
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/views/pane/series-markers-pane-view.ts#L30-L78
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
SeriesPriceLinePaneView.constructor
public constructor(series: ISeries<SeriesType>) { super(series); }
// eslint-disable-next-line no-useless-constructor
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/use-charts/views/pane/series-price-line-pane-view.ts#L8-L10
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
himalaya-ui
github_2023
red-ninjas
typescript
update
const update: ContextHandlerWhere<S> = (_key, _next) => {};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/red-ninjas/himalaya-ui/blob/84a7de5ee37e1ebfc43c892461dba8518a27b9fc/src/components/utils/use-context-state/create-ui-context.tsx#L16-L16
84a7de5ee37e1ebfc43c892461dba8518a27b9fc
dockge
github_2023
louislam
typescript
AgentManager.add
async add(url : string, username : string, password : string) : Promise<Agent> { let bean = R.dispense("agent") as Agent; bean.url = url; bean.username = username; bean.password = password; await R.store(bean); return bean; }
/** * * @param url * @param username * @param password */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/agent-manager.ts#L80-L87
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
AgentManager.remove
async remove(url : string) { let bean = await R.findOne("agent", " url = ? ", [ url, ]); if (bean) { await R.trash(bean); let endpoint = bean.endpoint; this.disconnect(endpoint); this.sendAgentList(); delete this.agentSocke...
/** * * @param url */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/agent-manager.ts#L93-L107
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
Database.readDBConfig
static readDBConfig() : DBConfig { const dbConfigString = fs.readFileSync(path.join(this.server.config.dataDir, "db-config.json")).toString("utf-8"); const dbConfig = JSON.parse(dbConfigString); if (typeof dbConfig !== "object") { throw new Error("Invalid db-config.json, it must be ...
/** * Read the database config * @throws {Error} If the config is invalid * @typedef {string|undefined} envString * @returns {{type: "sqlite"} | {type:envString, hostname:envString, port:envString, database:envString, username:envString, password:envString}} Database config */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/database.ts#L60-L72
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
Database.writeDBConfig
static writeDBConfig(dbConfig : DBConfig) { fs.writeFileSync(path.join(this.server.config.dataDir, "db-config.json"), JSON.stringify(dbConfig, null, 4)); }
/** * @typedef {string|undefined} envString * @param dbConfig the database configuration that should be written * @returns {void} */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/database.ts#L79-L81
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
Database.connect
static async connect(autoloadModels = true) { const acquireConnectionTimeout = 120 * 1000; let dbConfig : DBConfig; try { dbConfig = this.readDBConfig(); Database.dbConfig = dbConfig; } catch (err) { if (err instanceof Error) { log.warn...
/** * Connect to the database * @param {boolean} autoloadModels Should models be automatically loaded? * @param {boolean} noLog Should logs not be output? * @returns {Promise<void>} */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/database.ts#L89-L152
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
Database.initSQLite
static async initSQLite() { await R.exec("PRAGMA foreign_keys = ON"); // Change to WAL await R.exec("PRAGMA journal_mode = WAL"); await R.exec("PRAGMA cache_size = -12000"); await R.exec("PRAGMA auto_vacuum = INCREMENTAL"); // This ensures that an operating system crash ...
/** @returns {Promise<void>} */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/database.ts#L157-L173
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
Database.patch
static async patch() { // Using knex migrations // https://knexjs.org/guide/migrations.html // https://gist.github.com/NigelEarle/70db130cc040cc2868555b29a0278261 try { await R.knex.migrate.latest({ directory: Database.knexMigrationsPath, }); ...
/** * Patch the database * @returns {void} */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/database.ts#L179-L199
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
Database.close
static async close() { const listener = () => { Database.noReject = false; }; process.addListener("unhandledRejection", listener); log.info("db", "Closing the database"); // Flush WAL to main database if (Database.dbConfig.type === "sqlite") { aw...
/** * Special handle, because tarn.js throw a promise reject that cannot be caught * @returns {Promise<void>} */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/database.ts#L205-L232
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
Database.getSize
static getSize() { if (Database.dbConfig.type === "sqlite") { log.debug("db", "Database.getSize()"); const stats = fs.statSync(Database.sqlitePath); log.debug("db", stats); return stats.size; } return 0; }
/** * Get the size of the database (SQLite only) * @returns {number} Size of database */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/database.ts#L238-L246
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
Database.shrink
static async shrink() { if (Database.dbConfig.type === "sqlite") { await R.exec("VACUUM"); } }
/** * Shrink the database * @returns {Promise<void>} */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/database.ts#L252-L256
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
DockgeServer.constructor
constructor() { // Catch unexpected errors here let unexpectedErrorHandler = (error : unknown) => { console.trace(error); console.error("If you keep encountering errors, please report to https://github.com/louislam/dockge"); }; process.addListener("unhandledReject...
/** * */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/dockge-server.ts#L86-L322
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
unexpectedErrorHandler
let unexpectedErrorHandler = (error : unknown) => { console.trace(error); console.error("If you keep encountering errors, please report to https://github.com/louislam/dockge"); };
// Catch unexpected errors here
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/dockge-server.ts#L88-L91
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
DockgeServer.serve
async serve() { // Create all the necessary directories this.initDataDir(); // Connect to database try { await Database.init(this); } catch (e) { if (e instanceof Error) { log.error("server", "Failed to prepare your database: " + e.message...
/** * */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/dockge-server.ts#L345-L412
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
DockgeServer.sendInfo
async sendInfo(socket : Socket, hideVersion = false) { let versionProperty; let latestVersionProperty; let isContainer; if (!hideVersion) { versionProperty = packageJSON.version; latestVersionProperty = checkVersion.latestVersion; isContainer = (proce...
/** * Emits the version information to the client. * @param socket Socket.io socket instance * @param hideVersion Should we hide the version information in the response? * @returns */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/dockge-server.ts#L420-L439
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
DockgeServer.getClientIP
async getClientIP(socket : Socket) : Promise<string> { let clientIP = socket.client.conn.remoteAddress; if (clientIP === undefined) { clientIP = ""; } if (await Settings.get("trustProxy")) { const forwardedFor = socket.client.conn.request.headers["x-forwarded-fo...
/** * Get the IP of the client connected to the socket * @param {Socket} socket Socket to query * @returns IP of client */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/dockge-server.ts#L446-L463
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
DockgeServer.getTimezone
async getTimezone() { // From process.env.TZ try { if (process.env.TZ) { this.checkTimezone(process.env.TZ); return process.env.TZ; } } catch (e) { if (e instanceof Error) { log.warn("timezone", e.message + " in ...
/** * Attempt to get the current server timezone * If this fails, fall back to environment variables and then make a * guess. * @returns {Promise<string>} Current timezone */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/dockge-server.ts#L471-L514
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
DockgeServer.getTimezoneOffset
getTimezoneOffset() { return dayjs().format("Z"); }
/** * Get the current offset * @returns {string} Time offset */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/dockge-server.ts#L520-L522
d451e06e8428f1bf987595bf51d65f82241294cd
dockge
github_2023
louislam
typescript
DockgeServer.checkTimezone
checkTimezone(timezone : string) { try { dayjs.utc("2013-11-18 11:55").tz(timezone).format(); } catch (e) { throw new Error("Invalid timezone:" + timezone); } }
/** * Throw an error if the timezone is invalid * @param {string} timezone Timezone to test * @returns {void} * @throws The timezone is invalid */
https://github.com/louislam/dockge/blob/d451e06e8428f1bf987595bf51d65f82241294cd/backend/dockge-server.ts#L530-L536
d451e06e8428f1bf987595bf51d65f82241294cd