Skip to content

Commit c2d83e6

Browse files
committed
feat: add RunCommand
1 parent 74892fb commit c2d83e6

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@ export type {
4747
VerifyAuthenticationTokenRequest,
4848
VerifyAuthenticationTokenResponse,
4949
WrongPasswordErrorResponse,
50+
RunCommandRequest,
51+
RunCommandResponse,
52+
RunCommandResponseData,
5053
} from "./v1/index.js";

src/v1/RunCommand.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { ApiRequest, ApiSuccessResponse } from "./common.js";
2+
import { buildApiRequest } from "./common.js";
3+
4+
export type RunCommandRequest = ApiRequest<
5+
"RunCommand",
6+
{
7+
/**
8+
* Command Line to run on the Dedicated Server.
9+
*/
10+
command: string;
11+
}
12+
>;
13+
14+
export type RunCommandResponseData = {
15+
/**
16+
* Output of the command executed, with \n used as line separator.
17+
*/
18+
commandResult: string;
19+
};
20+
21+
export type RunCommandResponse = ApiSuccessResponse<RunCommandResponseData>;
22+
23+
export const buildRunCommand = buildApiRequest<
24+
RunCommandRequest,
25+
RunCommandResponse
26+
>("v1", {
27+
function: "RunCommand",
28+
});

src/v1/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { buildPasswordlessLogin } from "./PasswordlessLogin.js";
88
import { buildPasswordLogin } from "./PasswordLogin.js";
99
import { buildQueryServerState } from "./QueryServerState.js";
1010
import { buildRenameServer } from "./RenameServer.js";
11+
import { buildRunCommand } from "./RunCommand.js";
1112
import { buildSetAdminPassword } from "./SetAdminPassword.js";
1213
import { buildSetAutoLoadSessionName } from "./SetAutoLoadSessionName.js";
1314
import { buildSetClientPassword } from "./SetClientPassword.js";
@@ -109,6 +110,12 @@ export function buildV1(options: InternalClientOptions) {
109110
* Function does not return any data on success.
110111
*/
111112
SetAutoLoadSessionName: buildSetAutoLoadSessionName(options),
113+
/**
114+
* Runs the given Console Command on the Dedicated Server, and returns it's output to the Console.
115+
*
116+
* Requires Admin privileges.
117+
*/
118+
RunCommand: buildRunCommand(options),
112119
};
113120
}
114121

@@ -123,6 +130,7 @@ export type * from "./PasswordlessLogin.js";
123130
export type * from "./PasswordLogin.js";
124131
export type * from "./QueryServerState.js";
125132
export type * from "./RenameServer.js";
133+
export type * from "./RunCommand.js";
126134
export type * from "./SetAdminPassword.js";
127135
export type * from "./SetAutoLoadSessionName.js";
128136
export type * from "./SetClientPassword.js";

0 commit comments

Comments
 (0)