@carbonhost/typescript
Version:
[](LICENSE) [](https://www.typescriptlang.org/) [ • 12.8 kB
TypeScript
import * as axios from 'axios';
import { AxiosInstance } from 'axios';
type Backup = {
_id: string;
uuid: string;
starId: string;
name: string;
description?: string;
starType: string;
starVersion?: string;
bytes: number;
checksum: string;
ignoredFiles: string[];
locked: boolean;
successful: boolean;
completedAt: Date | null;
createdAt: Date;
};
type CreateBackup = {
name: string;
description?: string;
ignored?: string[];
isLocked?: boolean;
};
declare class BackupManager {
private star;
private axios;
private controllerAxios;
constructor(star: CarbonStar, axios: AxiosInstance, controllerAxios: AxiosInstance);
getBackups(): Promise<Backup[]>;
getBackup(backupId: string): Promise<Backup>;
deleteBackup(backupId: string): Promise<any>;
downloadBackup(backupId: string): Promise<{
url: string;
}>;
createBackup(backup: CreateBackup): Promise<Backup>;
restoreBackup(backupId: string): Promise<{
status: string;
message: string;
}>;
}
type FileInfo = {
name: string;
mode: string;
modeBits: string;
size: number;
isFile: boolean;
isSymlink: boolean;
mimetype: string;
createdAt: string;
modifiedAt: string;
};
type ChmodOptions = {
path: string;
files: {
file: string;
mode: string;
}[];
};
declare class FileManager {
private star;
private axios;
constructor(star: CarbonStar, axios: AxiosInstance);
private fetchFiles;
getFiles(directory: string): Promise<FileInfo[]>;
getFile(path: string): Promise<{
content?: string;
imageSrc?: string;
}>;
saveFile(path: string, content: string): Promise<axios.AxiosResponse<any, any>>;
chmod(options: ChmodOptions): Promise<axios.AxiosResponse<any, any>>;
moveFiles(path: string, files: {
from: string;
to: string;
}[]): Promise<axios.AxiosResponse<any, any>>;
renameFile(path: string, name: string): Promise<axios.AxiosResponse<any, any>>;
duplicateFile(path: string): Promise<axios.AxiosResponse<any, any>>;
downloadFile(path: string): Promise<axios.AxiosResponse<any, any>>;
deleteFile(params: {
path?: string;
paths?: string[];
}): Promise<axios.AxiosResponse<any, any>>;
createFile(parentDirectory: string, fileName: string): Promise<axios.AxiosResponse<any, any>>;
createDirectory(parentDirectory: string, folderName: string): Promise<axios.AxiosResponse<any, any>>;
decompressFile(root: string, file: string): Promise<axios.AxiosResponse<any, any>>;
compressFiles(root: string, files: string[]): Promise<axios.AxiosResponse<any, any>>;
uploadFile(path: string, file: File): Promise<axios.AxiosResponse<any, any>>;
}
interface CarbonPluginCommandResponse {
pagination: {
limit: number;
offset: number;
};
data: string[];
}
interface Pagination {
limit: number;
offset: number;
}
interface CarbonStarStats {
onlinePlayers: number;
ramUsage: number;
cpuUsage: number;
timestamp: Date;
}
interface CarbonPluginInfo {
tps: number;
mspt: number;
resources: {
ramUsage: number;
ramTotal: number;
cpuUsage: number;
cpuCores: number;
};
playerCountInfo: {
onlinePlayers: number;
maxPlayers: number;
};
}
interface CarbonPluginPlayerInfo {
name: string;
uuid: string;
firstPlayed: number;
lastSeen: number;
lastLogin: number;
isOp: boolean;
idleDuration: number;
ping: number;
location: {
x: number;
y: number;
z: number;
world: string;
};
}
interface CarbonPluginPlayersResponse {
pagination: Pagination;
data: {
players: CarbonPluginPlayerInfo[];
countInfo: {
onlinePlayers: number;
maxPlayers: number;
};
};
}
declare class MinecraftManager {
private star;
private axios;
constructor(star: CarbonStar, axios: AxiosInstance);
getCommands(query: string): Promise<CarbonPluginCommandResponse>;
getInfo(): Promise<CarbonPluginInfo>;
getPlayers(limit?: number, offset?: number): Promise<CarbonPluginPlayersResponse>;
installCarbonPlugin(port: number): Promise<any>;
}
declare class StatManager {
private star;
private axios;
constructor(star: CarbonStar, axios: AxiosInstance);
getRecentStats(): Promise<CarbonStarStats>;
}
type Port = {
id: number;
ip: string;
port: number;
notes: string | null;
isDefault: boolean;
};
type SFTPDetails = {
host: string;
port: number;
username: string;
password?: string;
};
type SFTPAccountDetails = {
username: string;
password: string;
};
declare class NetworkManager {
private star;
private axios;
constructor(star: CarbonStar, axios: AxiosInstance);
getPorts(): Promise<Port[]>;
deletePort(portId: string): Promise<any>;
createPort(notes: string): Promise<Port>;
getSFTPDetails(): Promise<SFTPDetails>;
resetSFTPPassword(): Promise<SFTPAccountDetails>;
}
type Invite = {
_id: string;
starId: string;
starName: string;
inviteeEmail: string;
invitedById: string;
invitedByEmail: string;
};
declare class UserManager {
private star;
private axios;
private controllerAxios;
constructor(star: CarbonStar, axios: AxiosInstance);
inviteUser(email: string): Promise<{
success: boolean;
}>;
getInvites(): Promise<Invite[]>;
cancelInvite(inviteId: string): Promise<any>;
removeUser(userId: string): Promise<any>;
}
type StarType = "VANILLA" | "PAPER" | "PUFFERFISH" | "SPIGOT" | "FOLIA" | "PURPUR" | "WATERFALL" | "VELOCITY" | "FABRIC" | "BUNGEECORD" | "QUILT" | "FORGE" | "NEOFORGE" | "MOHIST" | "ARCLIGHT" | "SPONGE" | "LEAVES" | "CANVAS" | "ASPAPER" | "LEGACY_FABRIC" | "LOOHP_LIMBO" | "NANOLIMBO" | "CUSTOM";
type JavaVersion = "8" | "11" | "16" | "17" | "19" | "21" | "22" | "23";
type AdvancedConfig = {
billingCycle?: "monthly" | "hourly" | "trial";
maximumRamPercentage?: number;
startupCommand?: string;
additionalFlags?: "None" | "Aikar's Flags" | "Velocity Flags";
minehutSupport?: "None" | "Velocity" | "Waterfall" | "Bukkit";
javaAgent?: string;
overrideStartup?: boolean;
automaticUpdating?: boolean;
simdOperations?: boolean;
removeUpdateWarnings?: boolean;
malwareScan?: boolean;
acceptEula?: boolean;
};
type CreateStarType = {
name: string;
type: StarType;
version?: string;
build?: string;
javaVersion: JavaVersion;
serverJarName?: string;
customJarURL?: string;
resources: {
memory: number;
};
advanced?: AdvancedConfig;
};
type UpdateStarType = Partial<CreateStarType>;
type CarbonSubdomainType = {
_id: string;
url: string;
};
type CarbonStarType = {
_id: string;
ownerId: string;
name: string;
config: {
type: string;
version: string;
javaVersion: JavaVersion;
customJar?: string;
startupCommand?: string;
maximumRamPercentage: number;
additionalFlags: "None" | "Aikar's Flags" | "Velocity Flags";
minehutSupport: "None" | "Velocity" | "Waterfall" | "Bukkit";
overrideStartup: boolean;
automaticUpdating: boolean;
simdOperations: boolean;
removeUpdateWarnings: boolean;
malwareScan: boolean;
acceptEula: boolean;
};
clientId: string;
serverId: number;
galaxyId: number;
ip: string;
subdomain?: CarbonSubdomainType;
subUsers: {
_id: string;
clerkId: string;
email: string;
minecraftUUID?: string;
}[];
resources: {
storage: number;
memory: number;
vCPU: number;
};
suspended: boolean;
lastBilled?: Date;
billingCycle: "monthly" | "hourly" | "trial";
billingEnabled: boolean;
billingStoppedAt?: Date;
billingStoppedReason?: string;
createdAt: Date;
};
type StarStatus = {
status: string;
};
type StarResources = {
currentState: string;
isSuspended: boolean;
resources: {
memoryBytes: number;
cpuAbsolute: number;
diskBytes: number;
networkRxBytes: number;
networkTxBytes: number;
uptime: number;
};
};
declare class CarbonStar {
carbonClient: Carbon;
private axios;
_id: string;
ownerId: string;
name: string;
config: {
type: string;
version: string;
javaVersion: JavaVersion;
customJar?: string;
startupCommand?: string;
maximumRamPercentage: number;
additionalFlags: "None" | "Aikar's Flags" | "Velocity Flags";
minehutSupport: "None" | "Velocity" | "Waterfall" | "Bukkit";
overrideStartup: boolean;
automaticUpdating: boolean;
simdOperations: boolean;
removeUpdateWarnings: boolean;
malwareScan: boolean;
acceptEula: boolean;
};
serverId: number;
clientId: string;
galaxyId: number;
ip: string;
subdomain?: CarbonSubdomainType;
subUsers: {
_id: string;
clerkId: string;
email: string;
minecraftUUID?: string;
}[];
resources: {
storage: number;
memory: number;
vCPU: number;
};
suspended: boolean;
createdAt: Date;
lastBilled?: Date;
billingCycle: "monthly" | "hourly" | "trial";
billingEnabled: boolean;
billingStoppedAt?: Date;
billingStoppedReason?: string;
constructor(carbonClient: Carbon, carbonStar: CarbonStarType);
get users(): UserManager;
get minecraft(): MinecraftManager;
get files(): FileManager;
get stats(): StatManager;
get backups(): BackupManager;
get network(): NetworkManager;
delete(): Promise<any>;
update(request: UpdateStarType): Promise<any>;
rename(name: string): Promise<any>;
stopBilling(reason: string): Promise<any>;
enableBilling(): Promise<any>;
getResources(): Promise<StarResources>;
setPower(action: "start" | "stop" | "restart" | "kill"): Promise<any>;
executeCommand(command: string): Promise<any>;
}
interface UserInfo {
clerkId: string;
stripeId: string | null;
email: string;
minecraftUUID?: string;
plan: "pro" | "enterprise" | null;
credits: number;
redeemedGifts: string[];
limits: {
storage: number;
memory: number;
cpu: number;
starCount: number;
starPortLimit: number;
};
createdAt: number;
}
type CreateAPIKeyType = {
name: string;
description?: string;
type: "api-key" | "account-key";
};
type CreateAPIKeyResponseType = {
identifier: string;
token: string;
};
type APIKeyType = {
_id: string;
userId: string;
name: string;
description?: string;
type: "api-key" | "account-key";
expiresAt: Date;
createdAt: Date;
};
type VerifyAPIKeyResponseType = {
user: UserInfo;
clerkId: string;
};
declare class APIKeyManager {
private axios;
constructor(axios: AxiosInstance);
getAPIKey(apiKeyId: string): Promise<APIKeyType>;
getAPIKeys(): Promise<APIKeyType[]>;
verifyAPIKey(apiKey: string): Promise<VerifyAPIKeyResponseType>;
deleteAPIKey(apiKeyId: string): Promise<{
message: string;
}>;
}
declare class InviteManager {
private axios;
constructor(axios: AxiosInstance);
getInvite(inviteId: string): Promise<Invite>;
acceptInvite(inviteId: string): Promise<{
success: boolean;
}>;
}
declare class Carbon {
private axios;
private apiKey;
constructor({ apiKey, url }: {
apiKey: string;
url?: string;
});
getMe(forceRefresh?: boolean): Promise<UserInfo>;
createAPIKey({ name, description, type }: CreateAPIKeyType): Promise<CreateAPIKeyResponseType>;
get apiKeys(): APIKeyManager;
get inviteManager(): InviteManager;
private fetchStars;
private fetchStar;
getStars(saveToCache?: boolean): Promise<CarbonStar[]>;
getStar(id: string): Promise<CarbonStar>;
createStar(body: CreateStarType): Promise<any>;
getAxios(): AxiosInstance;
}
export { type AdvancedConfig, type Backup, Carbon, type CarbonPluginCommandResponse, type CarbonPluginInfo, type CarbonPluginPlayerInfo, type CarbonPluginPlayersResponse, CarbonStar, type CarbonStarStats, type CarbonStarType, type CarbonSubdomainType, type ChmodOptions, type CreateBackup, type CreateStarType, type FileInfo, type Invite, type JavaVersion, type Pagination, type Port, type SFTPAccountDetails, type SFTPDetails, type StarResources, type StarStatus, type StarType, type UpdateStarType, type UserInfo };