diff --git a/striker-ui-api/src/lib/accessModule.ts b/striker-ui-api/src/lib/accessModule.ts index 03f644d6..6ddecddd 100644 --- a/striker-ui-api/src/lib/accessModule.ts +++ b/striker-ui-api/src/lib/accessModule.ts @@ -13,10 +13,6 @@ import { uuid, } from './shell'; -type AccessStartOptions = { - args?: readonly string[]; -} & SpawnOptions; - class Access extends EventEmitter { private ps: ChildProcess; private queue: string[] = []; @@ -184,7 +180,7 @@ const insertOrUpdateJob = async ({ job_progress = 0, line = 0, ...rest -}: DBJobParams) => { +}: JobParams) => { const [uuid]: [string] = await subroutine('insert_or_update_jobs', { params: [{ job_progress, line, ...rest }], }); @@ -192,7 +188,7 @@ const insertOrUpdateJob = async ({ return uuid; }; -const insertOrUpdateVariable: DBInsertOrUpdateVariableFunction = async ( +const insertOrUpdateVariable: InsertOrUpdateVariableFunction = async ( params, ) => { const [uuid]: [string] = await subroutine('insert_or_update_variables', { @@ -207,9 +203,9 @@ const anvilSyncShared = ( jobData: string, jobTitle: string, jobDescription: string, - { jobHostUUID }: DBJobAnvilSyncSharedOptions = { jobHostUUID: undefined }, + { jobHostUUID }: JobAnvilSyncSharedOptions = { jobHostUUID: undefined }, ) => { - const subParams: DBJobParams = { + const subParams: JobParams = { file: __filename, job_command: SERVER_PATHS.usr.sbin['anvil-sync-shared'].self, job_data: jobData, diff --git a/striker-ui-api/src/lib/request_handlers/command/buildHostPowerHandler.ts b/striker-ui-api/src/lib/request_handlers/command/buildHostPowerHandler.ts index e66b57cd..842f0d51 100644 --- a/striker-ui-api/src/lib/request_handlers/command/buildHostPowerHandler.ts +++ b/striker-ui-api/src/lib/request_handlers/command/buildHostPowerHandler.ts @@ -5,14 +5,14 @@ import SERVER_PATHS from '../../consts/SERVER_PATHS'; import { job } from '../../accessModule'; import { stderr } from '../../shell'; -type DistinctDBJobParams = Omit< - DBJobParams, +type DistinctJobParams = Omit< + JobParams, 'file' | 'line' | 'job_data' | 'job_progress' >; const MANAGE_HOST_POWER_JOB_PARAMS: { - poweroff: DistinctDBJobParams; - reboot: DistinctDBJobParams; + poweroff: DistinctJobParams; + reboot: DistinctJobParams; } = { poweroff: { job_command: `${SERVER_PATHS.usr.sbin['anvil-manage-power'].self} --poweroff -y`, @@ -33,7 +33,7 @@ export const buildHostPowerHandler: ( ) => RequestHandler = (task = 'reboot') => async (request, response) => { - const subParams: DBJobParams = { + const subParams: JobParams = { file: __filename, ...MANAGE_HOST_POWER_JOB_PARAMS[task], diff --git a/striker-ui-api/src/lib/request_handlers/command/runManifest.ts b/striker-ui-api/src/lib/request_handlers/command/runManifest.ts index cc5ba341..e6f52447 100644 --- a/striker-ui-api/src/lib/request_handlers/command/runManifest.ts +++ b/striker-ui-api/src/lib/request_handlers/command/runManifest.ts @@ -114,7 +114,7 @@ export const runManifest: RequestHandler< } = rawManifestListData; const { hosts: { by_uuid: mapToHostNameData = {} } = {} } = rawSysData; - const joinAnJobs: DBJobParams[] = []; + const joinAnJobs: JobParams[] = []; let anParams: Record; diff --git a/striker-ui-api/src/types/AccessModule.d.ts b/striker-ui-api/src/types/AccessModule.d.ts index c95732e6..2825647d 100644 --- a/striker-ui-api/src/types/AccessModule.d.ts +++ b/striker-ui-api/src/types/AccessModule.d.ts @@ -1,30 +1,12 @@ -type AsyncAnvilAccessModuleCloseArgs = { - ecode: number | null; - signal: NodeJS.Signals | null; - stderr: string; - stdout: unknown; -}; - -type AsyncDatabaseWriteCloseArgs = AsyncAnvilAccessModuleCloseArgs & { - wcode: number | null; -}; - -type AsyncAnvilAccessModuleCloseHandler = ( - args: AsyncAnvilAccessModuleCloseArgs, -) => void; - -type AsyncDatabaseWriteCloseHandler = ( - args: AsyncDatabaseWriteCloseArgs, -) => void; +type AccessStartOptions = { + args?: readonly string[]; +} & import('child_process').SpawnOptions; -type AsyncAnvilAccessModuleOptions = import('child_process').SpawnOptions & { - onClose?: AsyncAnvilAccessModuleCloseHandler; - onError?: (err: Error) => void; +type SubroutineCommonParams = { + debug?: number; }; -type AsyncDatabaseWriteOptions = Omit< - AsyncAnvilAccessModuleOptions, - 'onClose' -> & { - onClose?: AsyncDatabaseWriteCloseHandler; +type InsertOrUpdateFunctionCommonParams = SubroutineCommonParams & { + file: string; + line?: number; }; diff --git a/striker-ui-api/src/types/AnvilSyncSharedFunction.d.ts b/striker-ui-api/src/types/AnvilSyncSharedFunction.d.ts new file mode 100644 index 00000000..12bd12d5 --- /dev/null +++ b/striker-ui-api/src/types/AnvilSyncSharedFunction.d.ts @@ -0,0 +1,3 @@ +type JobAnvilSyncSharedOptions = { + jobHostUUID?: string; +}; diff --git a/striker-ui-api/src/types/BuildGetRequestHandlerOptions.d.ts b/striker-ui-api/src/types/BuildGetRequestHandlerFunction.d.ts similarity index 100% rename from striker-ui-api/src/types/BuildGetRequestHandlerOptions.d.ts rename to striker-ui-api/src/types/BuildGetRequestHandlerFunction.d.ts diff --git a/striker-ui-api/src/types/CallOptions.d.ts b/striker-ui-api/src/types/CallFunction.d.ts similarity index 100% rename from striker-ui-api/src/types/CallOptions.d.ts rename to striker-ui-api/src/types/CallFunction.d.ts diff --git a/striker-ui-api/src/types/DBInsertOrUpdateFunctionCommon.d.ts b/striker-ui-api/src/types/DBInsertOrUpdateFunctionCommon.d.ts deleted file mode 100644 index 20e39370..00000000 --- a/striker-ui-api/src/types/DBInsertOrUpdateFunctionCommon.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -type DBInsertOrUpdateFunctionCommonParams = ModuleSubroutineCommonParams & { - file: string; - line?: number; -}; diff --git a/striker-ui-api/src/types/DBJobAnvilSyncSharedOptions.d.ts b/striker-ui-api/src/types/DBJobAnvilSyncSharedOptions.d.ts deleted file mode 100644 index e0251591..00000000 --- a/striker-ui-api/src/types/DBJobAnvilSyncSharedOptions.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -type DBJobAnvilSyncSharedOptions = { - jobHostUUID?: string; -}; diff --git a/striker-ui-api/src/types/ExecModuleSubroutineFunction.d.ts b/striker-ui-api/src/types/ExecModuleSubroutineFunction.d.ts deleted file mode 100644 index c151524e..00000000 --- a/striker-ui-api/src/types/ExecModuleSubroutineFunction.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -type ExecModuleSubroutineOptions = { - spawnSyncOptions?: import('child_process').SpawnSyncOptions; - subModuleName?: string; - subParams?: Record; -}; diff --git a/striker-ui-api/src/types/GetPeerDataFunction.d.ts b/striker-ui-api/src/types/GetPeerDataFunction.d.ts index 62a32791..76c16d6e 100644 --- a/striker-ui-api/src/types/GetPeerDataFunction.d.ts +++ b/striker-ui-api/src/types/GetPeerDataFunction.d.ts @@ -6,7 +6,7 @@ type PeerDataHash = { os_registered: string; }; -type GetPeerDataOptions = ModuleSubroutineCommonParams & { +type GetPeerDataOptions = SubroutineCommonParams & { password?: string; port?: number; }; diff --git a/striker-ui-api/src/types/DBInsertOrUpdateJobFunction.d.ts b/striker-ui-api/src/types/InsertOrUpdateJobFunction.d.ts similarity index 73% rename from striker-ui-api/src/types/DBInsertOrUpdateJobFunction.d.ts rename to striker-ui-api/src/types/InsertOrUpdateJobFunction.d.ts index 60f05a23..580a7a5a 100644 --- a/striker-ui-api/src/types/DBInsertOrUpdateJobFunction.d.ts +++ b/striker-ui-api/src/types/InsertOrUpdateJobFunction.d.ts @@ -1,4 +1,4 @@ -type DBJobParams = DBInsertOrUpdateFunctionCommonParams & { +type JobParams = InsertOrUpdateFunctionCommonParams & { job_command: string; job_data?: string; job_name: string; diff --git a/striker-ui-api/src/types/DBInsertOrUpdateVariableFunction.d.ts b/striker-ui-api/src/types/InsertOrUpdateVariableFunction.d.ts similarity index 69% rename from striker-ui-api/src/types/DBInsertOrUpdateVariableFunction.d.ts rename to striker-ui-api/src/types/InsertOrUpdateVariableFunction.d.ts index bce32c5d..83e5c59c 100644 --- a/striker-ui-api/src/types/DBInsertOrUpdateVariableFunction.d.ts +++ b/striker-ui-api/src/types/InsertOrUpdateVariableFunction.d.ts @@ -1,4 +1,4 @@ -type DBVariableParams = DBInsertOrUpdateFunctionCommonParams & { +type VariableParams = InsertOrUpdateFunctionCommonParams & { update_value_only?: 0 | 1; variable_default?: string; varaible_description?: string; @@ -10,6 +10,6 @@ type DBVariableParams = DBInsertOrUpdateFunctionCommonParams & { variable_value?: number | string; }; -type DBInsertOrUpdateVariableFunction = ( - params: DBVariableParams, +type InsertOrUpdateVariableFunction = ( + params: VariableParams, ) => Promise; diff --git a/striker-ui-api/src/types/ModuleSubroutineCommonParams.d.ts b/striker-ui-api/src/types/ModuleSubroutineCommonParams.d.ts deleted file mode 100644 index 368b28f5..00000000 --- a/striker-ui-api/src/types/ModuleSubroutineCommonParams.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -type ModuleSubroutineCommonParams = { - debug?: number; -};