From b4caec0644d5f95b52b0123caaa0d9571ba2c65a Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Fri, 24 Jan 2025 17:03:34 +0100 Subject: [PATCH] refactor: use type imports --- apps/server/src/adapters/OscAdapter.ts | 2 +- apps/server/src/adapters/WebsocketAdapter.ts | 2 +- apps/server/src/api-data/automation/automation.validation.ts | 2 +- .../src/api-data/custom-fields/customFields.validation.ts | 2 +- apps/server/src/api-data/db/db.middleware.ts | 4 ++-- apps/server/src/api-data/db/db.validation.ts | 4 ++-- apps/server/src/api-data/excel/excel.controller.ts | 2 +- apps/server/src/api-data/excel/excel.middleware.ts | 4 ++-- apps/server/src/api-data/excel/excel.service.ts | 2 +- apps/server/src/api-data/excel/excel.validation.ts | 2 +- apps/server/src/api-data/rundown/rundown.controller.ts | 2 +- apps/server/src/api-data/rundown/rundown.validation.ts | 2 +- apps/server/src/api-data/settings/settings.validation.ts | 2 +- apps/server/src/app.ts | 2 +- apps/server/src/services/__tests__/timerUtils.test.ts | 2 +- apps/server/src/services/runtime-service/RuntimeService.ts | 2 +- apps/server/src/services/sheet-service/SheetService.ts | 2 +- apps/server/src/services/sheet-service/sheetUtils.ts | 2 +- apps/server/src/services/timerUtils.ts | 2 +- apps/server/src/stores/__mocks__/runtimeState.mocks.ts | 2 +- apps/server/src/stores/__tests__/runtimeState.test.ts | 2 +- apps/server/src/stores/runtimeState.ts | 2 +- apps/server/src/utils/network.ts | 2 +- apps/server/src/utils/oscArgParser.ts | 2 +- apps/server/src/utils/routerUtils.ts | 2 +- 25 files changed, 28 insertions(+), 28 deletions(-) diff --git a/apps/server/src/adapters/OscAdapter.ts b/apps/server/src/adapters/OscAdapter.ts index b98780147c..044a586e43 100644 --- a/apps/server/src/adapters/OscAdapter.ts +++ b/apps/server/src/adapters/OscAdapter.ts @@ -3,7 +3,7 @@ import { LogOrigin } from 'ontime-types'; import { fromBuffer } from 'osc-min'; import * as dgram from 'node:dgram'; -import { IAdapter } from './IAdapter.js'; +import type { IAdapter } from './IAdapter.js'; import { logger } from '../classes/Logger.js'; import { integrationPayloadFromPath } from './utils/parse.js'; import { dispatchFromAdapter } from '../api-integration/integration.controller.js'; diff --git a/apps/server/src/adapters/WebsocketAdapter.ts b/apps/server/src/adapters/WebsocketAdapter.ts index f90a8f22ec..958dd74540 100644 --- a/apps/server/src/adapters/WebsocketAdapter.ts +++ b/apps/server/src/adapters/WebsocketAdapter.ts @@ -20,7 +20,7 @@ import { WebSocket, WebSocketServer } from 'ws'; import type { Server } from 'http'; import getRandomName from '../utils/getRandomName.js'; -import { IAdapter } from './IAdapter.js'; +import type { IAdapter } from './IAdapter.js'; import { eventStore } from '../stores/EventStore.js'; import { logger } from '../classes/Logger.js'; import { dispatchFromAdapter } from '../api-integration/integration.controller.js'; diff --git a/apps/server/src/api-data/automation/automation.validation.ts b/apps/server/src/api-data/automation/automation.validation.ts index f29665d98a..4b2e946ad7 100644 --- a/apps/server/src/api-data/automation/automation.validation.ts +++ b/apps/server/src/api-data/automation/automation.validation.ts @@ -7,7 +7,7 @@ import { timerLifecycleValues, } from 'ontime-types'; -import { Request, Response, NextFunction } from 'express'; +import type { Request, Response, NextFunction } from 'express'; import { body, oneOf, param, validationResult } from 'express-validator'; import * as assert from '../../utils/assert.js'; diff --git a/apps/server/src/api-data/custom-fields/customFields.validation.ts b/apps/server/src/api-data/custom-fields/customFields.validation.ts index 2c67503e31..ff3f05bdfa 100644 --- a/apps/server/src/api-data/custom-fields/customFields.validation.ts +++ b/apps/server/src/api-data/custom-fields/customFields.validation.ts @@ -1,6 +1,6 @@ import { isAlphanumericWithSpace } from 'ontime-utils'; -import { Request, Response, NextFunction } from 'express'; +import type { Request, Response, NextFunction } from 'express'; import { body, param, validationResult } from 'express-validator'; export const validateCustomField = [ diff --git a/apps/server/src/api-data/db/db.middleware.ts b/apps/server/src/api-data/db/db.middleware.ts index e81709c5b2..26afef0008 100644 --- a/apps/server/src/api-data/db/db.middleware.ts +++ b/apps/server/src/api-data/db/db.middleware.ts @@ -1,5 +1,5 @@ -import { Request } from 'express'; -import multer, { FileFilterCallback } from 'multer'; +import type { Request } from 'express'; +import multer, { type FileFilterCallback } from 'multer'; import { JSON_MIME } from '../../utils/parser.js'; import { storage } from '../../utils/upload.js'; diff --git a/apps/server/src/api-data/db/db.validation.ts b/apps/server/src/api-data/db/db.validation.ts index 8687f96521..63e31054be 100644 --- a/apps/server/src/api-data/db/db.validation.ts +++ b/apps/server/src/api-data/db/db.validation.ts @@ -1,7 +1,7 @@ -import { Request, Response, NextFunction } from 'express'; +import type { Request, Response, NextFunction } from 'express'; import { body, param, validationResult } from 'express-validator'; -import { ensureJsonExtension } from '../../utils/fileManagement.js'; import sanitize from 'sanitize-filename'; +import { ensureJsonExtension } from '../../utils/fileManagement.js'; /** * @description Validates request for a new project. diff --git a/apps/server/src/api-data/excel/excel.controller.ts b/apps/server/src/api-data/excel/excel.controller.ts index 1e107e3e17..e47bcf1b91 100644 --- a/apps/server/src/api-data/excel/excel.controller.ts +++ b/apps/server/src/api-data/excel/excel.controller.ts @@ -3,7 +3,7 @@ * Google Sheets */ -import { Request, Response } from 'express'; +import type { Request, Response } from 'express'; import { generateRundownPreview, listWorksheets, saveExcelFile } from './excel.service.js'; export async function postExcel(req: Request, res: Response) { diff --git a/apps/server/src/api-data/excel/excel.middleware.ts b/apps/server/src/api-data/excel/excel.middleware.ts index 914e4a74dd..68f252b316 100644 --- a/apps/server/src/api-data/excel/excel.middleware.ts +++ b/apps/server/src/api-data/excel/excel.middleware.ts @@ -1,5 +1,5 @@ -import { Request } from 'express'; -import multer, { FileFilterCallback } from 'multer'; +import type { Request } from 'express'; +import multer, { type FileFilterCallback } from 'multer'; import { EXCEL_MIME } from '../../utils/parser.js'; import { storage } from '../../utils/upload.js'; diff --git a/apps/server/src/api-data/excel/excel.service.ts b/apps/server/src/api-data/excel/excel.service.ts index e571302d0c..70d32e280c 100644 --- a/apps/server/src/api-data/excel/excel.service.ts +++ b/apps/server/src/api-data/excel/excel.service.ts @@ -4,7 +4,7 @@ */ import { CustomFields, OntimeRundown } from 'ontime-types'; -import { ImportMap } from 'ontime-utils'; +import type { ImportMap } from 'ontime-utils'; import { extname } from 'path'; import { existsSync } from 'fs'; diff --git a/apps/server/src/api-data/excel/excel.validation.ts b/apps/server/src/api-data/excel/excel.validation.ts index de6c6cd8ba..107de72bc6 100644 --- a/apps/server/src/api-data/excel/excel.validation.ts +++ b/apps/server/src/api-data/excel/excel.validation.ts @@ -1,7 +1,7 @@ import { isImportMap } from 'ontime-utils'; import { body, validationResult } from 'express-validator'; -import { NextFunction, Request, Response } from 'express'; +import type { NextFunction, Request, Response } from 'express'; export const validateFileExists = [ (req: Request, res: Response, next: NextFunction) => { diff --git a/apps/server/src/api-data/rundown/rundown.controller.ts b/apps/server/src/api-data/rundown/rundown.controller.ts index 0c196fc551..3575ebc510 100644 --- a/apps/server/src/api-data/rundown/rundown.controller.ts +++ b/apps/server/src/api-data/rundown/rundown.controller.ts @@ -8,7 +8,7 @@ import { } from 'ontime-types'; import { getErrorMessage } from 'ontime-utils'; -import { Request, Response } from 'express'; +import type { Request, Response } from 'express'; import { failEmptyObjects } from '../../utils/routerUtils.js'; import { diff --git a/apps/server/src/api-data/rundown/rundown.validation.ts b/apps/server/src/api-data/rundown/rundown.validation.ts index c0b020e8ce..d815bb5766 100644 --- a/apps/server/src/api-data/rundown/rundown.validation.ts +++ b/apps/server/src/api-data/rundown/rundown.validation.ts @@ -1,5 +1,5 @@ import { body, param, query, validationResult } from 'express-validator'; -import { Request, Response, NextFunction } from 'express'; +import type { Request, Response, NextFunction } from 'express'; export const rundownPostValidator = [ body('type').isString().exists().isIn(['event', 'delay', 'block']), diff --git a/apps/server/src/api-data/settings/settings.validation.ts b/apps/server/src/api-data/settings/settings.validation.ts index 218fe8a532..6cc8063779 100644 --- a/apps/server/src/api-data/settings/settings.validation.ts +++ b/apps/server/src/api-data/settings/settings.validation.ts @@ -1,5 +1,5 @@ import { body, validationResult } from 'express-validator'; -import { Request, Response, NextFunction } from 'express'; +import type { Request, Response, NextFunction } from 'express'; /** * @description Validates object for POST /ontime/settings/welcomedialog diff --git a/apps/server/src/app.ts b/apps/server/src/app.ts index 9a7d9cf76e..9102d78eac 100644 --- a/apps/server/src/app.ts +++ b/apps/server/src/app.ts @@ -2,7 +2,7 @@ import { LogOrigin, Playback, runtimeStorePlaceholder, SimpleDirection, SimplePl import 'dotenv/config'; import express from 'express'; -import http, { Server } from 'http'; +import http, { type Server } from 'http'; import cors from 'cors'; import serverTiming from 'server-timing'; import cookieParser from 'cookie-parser'; diff --git a/apps/server/src/services/__tests__/timerUtils.test.ts b/apps/server/src/services/__tests__/timerUtils.test.ts index 7ce4093694..a418e7fd3f 100644 --- a/apps/server/src/services/__tests__/timerUtils.test.ts +++ b/apps/server/src/services/__tests__/timerUtils.test.ts @@ -9,7 +9,7 @@ import { normaliseEndTime, skippedOutOfEvent, } from '../timerUtils.js'; -import { RuntimeState } from '../../stores/runtimeState.js'; +import type { RuntimeState } from '../../stores/runtimeState.js'; describe('getExpectedFinish()', () => { it('is null if we havent started', () => { diff --git a/apps/server/src/services/runtime-service/RuntimeService.ts b/apps/server/src/services/runtime-service/RuntimeService.ts index c9e79dcdb7..a43ef29803 100644 --- a/apps/server/src/services/runtime-service/RuntimeService.ts +++ b/apps/server/src/services/runtime-service/RuntimeService.ts @@ -22,7 +22,7 @@ import { timerConfig } from '../../config/config.js'; import { eventStore } from '../../stores/EventStore.js'; import { EventTimer } from '../EventTimer.js'; -import { RestorePoint, restoreService } from '../RestoreService.js'; +import { type RestorePoint, restoreService } from '../RestoreService.js'; import { findNext, findPrevious, diff --git a/apps/server/src/services/sheet-service/SheetService.ts b/apps/server/src/services/sheet-service/SheetService.ts index edff169e36..5f55203b7c 100644 --- a/apps/server/src/services/sheet-service/SheetService.ts +++ b/apps/server/src/services/sheet-service/SheetService.ts @@ -7,7 +7,7 @@ import { AuthenticationStatus, CustomFields, LogOrigin, MaybeString, OntimeRundown } from 'ontime-types'; import { ImportMap, getErrorMessage } from 'ontime-utils'; -import { sheets, sheets_v4 } from '@googleapis/sheets'; +import { sheets, type sheets_v4 } from '@googleapis/sheets'; import { Credentials, OAuth2Client } from 'google-auth-library'; import got from 'got'; diff --git a/apps/server/src/services/sheet-service/sheetUtils.ts b/apps/server/src/services/sheet-service/sheetUtils.ts index e15110bef7..8e7742f74e 100644 --- a/apps/server/src/services/sheet-service/sheetUtils.ts +++ b/apps/server/src/services/sheet-service/sheetUtils.ts @@ -1,7 +1,7 @@ import { isOntimeBlock, isOntimeEvent, OntimeEvent, OntimeRundownEntry } from 'ontime-types'; import { millisToString } from 'ontime-utils'; -import { sheets_v4 } from '@googleapis/sheets'; +import type { sheets_v4 } from '@googleapis/sheets'; import { isObject } from '../../utils/assert.js'; // we expect client secret file to contain the following keys diff --git a/apps/server/src/services/timerUtils.ts b/apps/server/src/services/timerUtils.ts index 8fd93a76f9..2cc59c4ea1 100644 --- a/apps/server/src/services/timerUtils.ts +++ b/apps/server/src/services/timerUtils.ts @@ -1,6 +1,6 @@ import { MaybeNumber, TimerPhase } from 'ontime-types'; import { dayInMs, isPlaybackActive } from 'ontime-utils'; -import { RuntimeState } from '../stores/runtimeState.js'; +import type { RuntimeState } from '../stores/runtimeState.js'; /** * handle events that span over midnight diff --git a/apps/server/src/stores/__mocks__/runtimeState.mocks.ts b/apps/server/src/stores/__mocks__/runtimeState.mocks.ts index 379e1449da..7c4d968395 100644 --- a/apps/server/src/stores/__mocks__/runtimeState.mocks.ts +++ b/apps/server/src/stores/__mocks__/runtimeState.mocks.ts @@ -1,6 +1,6 @@ import { TimerPhase, Playback } from 'ontime-types'; import { deepmerge } from 'ontime-utils'; -import { RuntimeState } from '../runtimeState.js'; +import type { RuntimeState } from '../runtimeState.js'; const baseState: RuntimeState = { clock: 0, diff --git a/apps/server/src/stores/__tests__/runtimeState.test.ts b/apps/server/src/stores/__tests__/runtimeState.test.ts index adf309731f..f607ddcb03 100644 --- a/apps/server/src/stores/__tests__/runtimeState.test.ts +++ b/apps/server/src/stores/__tests__/runtimeState.test.ts @@ -1,7 +1,7 @@ import { PlayableEvent, Playback, TimerPhase } from 'ontime-types'; import { deepmerge } from 'ontime-utils'; -import { RuntimeState, addTime, clear, getState, load, pause, roll, start, stop } from '../runtimeState.js'; +import { type RuntimeState, addTime, clear, getState, load, pause, roll, start, stop } from '../runtimeState.js'; import { initRundown } from '../../services/rundown-service/RundownService.js'; const mockEvent = { diff --git a/apps/server/src/stores/runtimeState.ts b/apps/server/src/stores/runtimeState.ts index 55b0eba37c..0df5c805e2 100644 --- a/apps/server/src/stores/runtimeState.ts +++ b/apps/server/src/stores/runtimeState.ts @@ -21,7 +21,7 @@ import { } from 'ontime-utils'; import { clock } from '../services/Clock.js'; -import { RestorePoint } from '../services/RestoreService.js'; +import type { RestorePoint } from '../services/RestoreService.js'; import { getCurrent, getExpectedEnd, diff --git a/apps/server/src/utils/network.ts b/apps/server/src/utils/network.ts index a020135aee..96d6fcb9bf 100644 --- a/apps/server/src/utils/network.ts +++ b/apps/server/src/utils/network.ts @@ -2,7 +2,7 @@ import { LogOrigin } from 'ontime-types'; import type { Server } from 'http'; import { networkInterfaces } from 'os'; -import { AddressInfo } from 'net'; +import type { AddressInfo } from 'net'; import { isDocker, isProduction } from '../externals.js'; import { logger } from '../classes/Logger.js'; diff --git a/apps/server/src/utils/oscArgParser.ts b/apps/server/src/utils/oscArgParser.ts index 0283a129cb..2bc6f65d4c 100644 --- a/apps/server/src/utils/oscArgParser.ts +++ b/apps/server/src/utils/oscArgParser.ts @@ -1,4 +1,4 @@ -import { Argument } from 'node-osc'; +import type { Argument } from 'node-osc'; import { splitWhitespace } from 'ontime-utils'; export function stringToOSCArgs(argsString: string | undefined): Argument[] { diff --git a/apps/server/src/utils/routerUtils.ts b/apps/server/src/utils/routerUtils.ts index 1ba9da45e4..77b9871691 100644 --- a/apps/server/src/utils/routerUtils.ts +++ b/apps/server/src/utils/routerUtils.ts @@ -1,4 +1,4 @@ -import { Response } from 'express'; +import type { Response } from 'express'; import { isEmptyObject } from './parserUtils.js';