From 01f4001e733ebc61423d3023d87b1399b6afa215 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 14 Feb 2023 01:10:53 +0100 Subject: [PATCH] refactor(simulator): sort exports, switch to node: import syntax for internal librairies MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- rollup.config.mjs | 8 ++++---- src/charging-station/AutomaticTransactionGenerator.ts | 2 +- src/charging-station/Bootstrap.ts | 2 +- src/charging-station/ChargingStation.ts | 2 +- src/charging-station/ChargingStationWorker.ts | 2 +- src/charging-station/WorkerBroadcastChannel.ts | 2 +- .../ocpp/OCPPIncomingRequestService.ts | 2 +- src/charging-station/ocpp/index.ts | 10 +++++----- src/charging-station/ui-server/AbstractUIServer.ts | 2 +- src/charging-station/ui-server/UIHttpServer.ts | 2 +- src/charging-station/ui-server/UIServerUtils.ts | 2 +- src/charging-station/ui-server/UIWebSocketServer.ts | 4 ++-- src/performance/PerformanceStatistics.ts | 4 ++-- src/utils/index.ts | 8 ++++---- src/worker/WorkerDynamicPool.ts | 2 +- src/worker/WorkerFactory.ts | 2 +- src/worker/WorkerSet.ts | 2 +- src/worker/WorkerStaticPool.ts | 2 +- src/worker/WorkerTypes.ts | 2 +- src/worker/index.ts | 4 ++-- 20 files changed, 33 insertions(+), 33 deletions(-) diff --git a/rollup.config.mjs b/rollup.config.mjs index b97343c8..87825d87 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -36,29 +36,29 @@ export default { '@mikro-orm/reflection', 'ajv', 'ajv-formats', - 'async_hooks', 'basic-ftp', 'chalk', - 'http', 'http-status-codes', 'just-clone', 'just-merge', 'mnemonist/lru-map-with-delete', 'moment', 'mongodb', + 'node:async_hooks', 'node:crypto', 'node:fs', + 'node:http', 'node:path', + 'node:perf_hooks', 'node:url', 'node:util', - 'perf_hooks', + 'node:worker_threads', 'poolifier', 'proper-lockfile', 'tar', 'winston', 'winston-daily-rotate-file', 'winston/lib/winston/transports', - 'worker_threads', 'ws', ], plugins: [ diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 16fa839d..26b3a2a2 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -1,6 +1,6 @@ // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. -import { AsyncResource } from 'async_hooks'; +import { AsyncResource } from 'node:async_hooks'; import { type ChargingStation, ChargingStationUtils } from './internal'; import { BaseError } from '../exception'; diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 9ed17131..5f20e74b 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -2,7 +2,7 @@ import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import { type Worker, isMainThread } from 'worker_threads'; +import { type Worker, isMainThread } from 'node:worker_threads'; import chalk from 'chalk'; diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index dd266cac..ef2c3a14 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -4,7 +4,7 @@ import crypto from 'node:crypto'; import fs from 'node:fs'; import path from 'node:path'; import { URL } from 'node:url'; -import { parentPort } from 'worker_threads'; +import { parentPort } from 'node:worker_threads'; import merge from 'just-merge'; import WebSocket, { type RawData } from 'ws'; diff --git a/src/charging-station/ChargingStationWorker.ts b/src/charging-station/ChargingStationWorker.ts index 11d7cb0e..b4325dbe 100644 --- a/src/charging-station/ChargingStationWorker.ts +++ b/src/charging-station/ChargingStationWorker.ts @@ -1,6 +1,6 @@ // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. -import { parentPort, workerData } from 'worker_threads'; +import { parentPort, workerData } from 'node:worker_threads'; import { ThreadWorker } from 'poolifier'; diff --git a/src/charging-station/WorkerBroadcastChannel.ts b/src/charging-station/WorkerBroadcastChannel.ts index a5a3c40f..f3c168bd 100644 --- a/src/charging-station/WorkerBroadcastChannel.ts +++ b/src/charging-station/WorkerBroadcastChannel.ts @@ -1,4 +1,4 @@ -import { BroadcastChannel } from 'worker_threads'; +import { BroadcastChannel } from 'node:worker_threads'; import type { BroadcastChannelRequest, diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index ccb7e98a..bca4809e 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -1,4 +1,4 @@ -import { AsyncResource } from 'async_hooks'; +import { AsyncResource } from 'node:async_hooks'; import Ajv, { type JSONSchemaType } from 'ajv'; import ajvFormats from 'ajv-formats'; diff --git a/src/charging-station/ocpp/index.ts b/src/charging-station/ocpp/index.ts index a7681be6..059c3f70 100644 --- a/src/charging-station/ocpp/index.ts +++ b/src/charging-station/ocpp/index.ts @@ -1,13 +1,13 @@ export { - OCPP20ResponseService, - OCPP20RequestService, OCPP20IncomingRequestService, + OCPP20RequestService, + OCPP20ResponseService, + OCPP16IncomingRequestService, + OCPP16RequestService, + OCPP16ResponseService, // FIXME: shall not be exported OCPP16ServiceUtils, OCPPIncomingRequestService, - OCPP16ResponseService, OCPPRequestService, OCPPServiceUtils, - OCPP16IncomingRequestService, - OCPP16RequestService, } from './internal'; diff --git a/src/charging-station/ui-server/AbstractUIServer.ts b/src/charging-station/ui-server/AbstractUIServer.ts index 840d558c..ca53d558 100644 --- a/src/charging-station/ui-server/AbstractUIServer.ts +++ b/src/charging-station/ui-server/AbstractUIServer.ts @@ -1,4 +1,4 @@ -import { type IncomingMessage, Server, type ServerResponse } from 'http'; +import { type IncomingMessage, Server, type ServerResponse } from 'node:http'; import type { WebSocket } from 'ws'; diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index 4a7e30b8..b52df572 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -1,4 +1,4 @@ -import type { IncomingMessage, RequestListener, ServerResponse } from 'http'; +import type { IncomingMessage, RequestListener, ServerResponse } from 'node:http'; import { StatusCodes } from 'http-status-codes'; diff --git a/src/charging-station/ui-server/UIServerUtils.ts b/src/charging-station/ui-server/UIServerUtils.ts index b5905949..056d31fa 100644 --- a/src/charging-station/ui-server/UIServerUtils.ts +++ b/src/charging-station/ui-server/UIServerUtils.ts @@ -1,4 +1,4 @@ -import type { IncomingMessage } from 'http'; +import type { IncomingMessage } from 'node:http'; import { Protocol, ProtocolVersion } from '../../types'; import { Utils, logger } from '../../utils'; diff --git a/src/charging-station/ui-server/UIWebSocketServer.ts b/src/charging-station/ui-server/UIWebSocketServer.ts index 5017b746..291e9263 100644 --- a/src/charging-station/ui-server/UIWebSocketServer.ts +++ b/src/charging-station/ui-server/UIWebSocketServer.ts @@ -1,5 +1,5 @@ -import type { IncomingMessage } from 'http'; -import type { Duplex } from 'stream'; +import type { IncomingMessage } from 'node:http'; +import type { Duplex } from 'node:stream'; import { StatusCodes } from 'http-status-codes'; import WebSocket, { type RawData, WebSocketServer } from 'ws'; diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index 3ec06587..909f6345 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -1,8 +1,8 @@ // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. +import { type PerformanceEntry, PerformanceObserver, performance } from 'node:perf_hooks'; import type { URL } from 'node:url'; -import { PerformanceEntry, PerformanceObserver, performance } from 'perf_hooks'; -import { parentPort } from 'worker_threads'; +import { parentPort } from 'node:worker_threads'; import { MessageChannelUtils } from '../charging-station'; import { diff --git a/src/utils/index.ts b/src/utils/index.ts index d7ae66b8..ff5de5a1 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,10 +1,10 @@ export { - Constants, - FileUtils, + ACElectricUtils, CircularArray, Configuration, - ACElectricUtils, + Constants, DCElectricUtils, - logger, + FileUtils, Utils, + logger, } from './internal'; diff --git a/src/worker/WorkerDynamicPool.ts b/src/worker/WorkerDynamicPool.ts index 889ae457..8a7e6e55 100644 --- a/src/worker/WorkerDynamicPool.ts +++ b/src/worker/WorkerDynamicPool.ts @@ -1,4 +1,4 @@ -import type { Worker } from 'worker_threads'; +import type { Worker } from 'node:worker_threads'; import { DynamicThreadPool, type ErrorHandler, type ExitHandler } from 'poolifier'; diff --git a/src/worker/WorkerFactory.ts b/src/worker/WorkerFactory.ts index fb9a26f1..e590ad14 100644 --- a/src/worker/WorkerFactory.ts +++ b/src/worker/WorkerFactory.ts @@ -1,4 +1,4 @@ -import { type Worker, isMainThread } from 'worker_threads'; +import { type Worker, isMainThread } from 'node:worker_threads'; import type { PoolOptions } from 'poolifier'; diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index a79db16e..a8a06a39 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -1,6 +1,6 @@ // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. -import { Worker } from 'worker_threads'; +import { Worker } from 'node:worker_threads'; import { WorkerAbstract } from './WorkerAbstract'; import { diff --git a/src/worker/WorkerStaticPool.ts b/src/worker/WorkerStaticPool.ts index 58e4c65a..8a717ad8 100644 --- a/src/worker/WorkerStaticPool.ts +++ b/src/worker/WorkerStaticPool.ts @@ -1,4 +1,4 @@ -import type { Worker } from 'worker_threads'; +import type { Worker } from 'node:worker_threads'; import { type ErrorHandler, type ExitHandler, FixedThreadPool } from 'poolifier'; diff --git a/src/worker/WorkerTypes.ts b/src/worker/WorkerTypes.ts index 9204eadc..f79be0b2 100644 --- a/src/worker/WorkerTypes.ts +++ b/src/worker/WorkerTypes.ts @@ -1,4 +1,4 @@ -import type { Worker } from 'worker_threads'; +import type { Worker } from 'node:worker_threads'; import type { PoolOptions } from 'poolifier'; diff --git a/src/worker/index.ts b/src/worker/index.ts index 036ddaf1..2ad6671b 100644 --- a/src/worker/index.ts +++ b/src/worker/index.ts @@ -2,9 +2,9 @@ export type { WorkerAbstract } from './WorkerAbstract'; export { WorkerConstants } from './WorkerConstants'; export { WorkerFactory } from './WorkerFactory'; export { - WorkerProcessType, + type MessageHandler, type WorkerData, type WorkerMessage, WorkerMessageEvents, - type MessageHandler, + WorkerProcessType, } from './WorkerTypes'; -- 2.34.1