refactor(striker-ui-api): organize types after complete migrate to access interact

main
Tsu-ba-me 2 years ago
parent d8cc7d9979
commit 82f4bdff04
  1. 12
      striker-ui-api/src/lib/accessModule.ts
  2. 10
      striker-ui-api/src/lib/request_handlers/command/buildHostPowerHandler.ts
  3. 2
      striker-ui-api/src/lib/request_handlers/command/runManifest.ts
  4. 34
      striker-ui-api/src/types/AccessModule.d.ts
  5. 3
      striker-ui-api/src/types/AnvilSyncSharedFunction.d.ts
  6. 0
      striker-ui-api/src/types/BuildGetRequestHandlerFunction.d.ts
  7. 0
      striker-ui-api/src/types/CallFunction.d.ts
  8. 4
      striker-ui-api/src/types/DBInsertOrUpdateFunctionCommon.d.ts
  9. 3
      striker-ui-api/src/types/DBJobAnvilSyncSharedOptions.d.ts
  10. 5
      striker-ui-api/src/types/ExecModuleSubroutineFunction.d.ts
  11. 2
      striker-ui-api/src/types/GetPeerDataFunction.d.ts
  12. 2
      striker-ui-api/src/types/InsertOrUpdateJobFunction.d.ts
  13. 6
      striker-ui-api/src/types/InsertOrUpdateVariableFunction.d.ts
  14. 3
      striker-ui-api/src/types/ModuleSubroutineCommonParams.d.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,

@ -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],

@ -114,7 +114,7 @@ export const runManifest: RequestHandler<
} = rawManifestListData;
const { hosts: { by_uuid: mapToHostNameData = {} } = {} } = rawSysData;
const joinAnJobs: DBJobParams[] = [];
const joinAnJobs: JobParams[] = [];
let anParams: Record<string, string>;

@ -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;
};

@ -0,0 +1,3 @@
type JobAnvilSyncSharedOptions = {
jobHostUUID?: string;
};

@ -1,4 +0,0 @@
type DBInsertOrUpdateFunctionCommonParams = ModuleSubroutineCommonParams & {
file: string;
line?: number;
};

@ -1,3 +0,0 @@
type DBJobAnvilSyncSharedOptions = {
jobHostUUID?: string;
};

@ -1,5 +0,0 @@
type ExecModuleSubroutineOptions = {
spawnSyncOptions?: import('child_process').SpawnSyncOptions;
subModuleName?: string;
subParams?: Record<string, unknown>;
};

@ -6,7 +6,7 @@ type PeerDataHash = {
os_registered: string;
};
type GetPeerDataOptions = ModuleSubroutineCommonParams & {
type GetPeerDataOptions = SubroutineCommonParams & {
password?: string;
port?: number;
};

@ -1,4 +1,4 @@
type DBJobParams = DBInsertOrUpdateFunctionCommonParams & {
type JobParams = InsertOrUpdateFunctionCommonParams & {
job_command: string;
job_data?: string;
job_name: string;

@ -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<string>;

@ -1,3 +0,0 @@
type ModuleSubroutineCommonParams = {
debug?: number;
};
Loading…
Cancel
Save