@meowpanel/api 0.1.0-alpha.11 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +40 -0
- package/esm/mod.d.ts +87 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +85 -1
- package/esm/src/client.d.ts +248 -0
- package/esm/src/client.d.ts.map +1 -0
- package/esm/src/client.js +235 -0
- package/esm/src/emitter.d.ts +53 -0
- package/esm/src/emitter.d.ts.map +1 -0
- package/esm/src/emitter.js +55 -0
- package/esm/src/errors.d.ts +42 -0
- package/esm/src/errors.d.ts.map +1 -0
- package/esm/src/errors.js +45 -0
- package/esm/src/http.d.ts +157 -0
- package/esm/src/http.d.ts.map +1 -0
- package/esm/src/http.js +317 -0
- package/esm/src/namespace.d.ts +59 -0
- package/esm/src/namespace.d.ts.map +1 -0
- package/esm/src/namespace.js +79 -0
- package/esm/src/reactive.d.ts +29 -0
- package/esm/src/reactive.d.ts.map +1 -0
- package/esm/src/reactive.js +35 -0
- package/esm/src/resources/account.d.ts +125 -0
- package/esm/src/resources/account.d.ts.map +1 -0
- package/esm/src/resources/account.js +151 -0
- package/esm/src/resources/api-keys.d.ts +116 -0
- package/esm/src/resources/api-keys.d.ts.map +1 -0
- package/esm/src/resources/api-keys.js +105 -0
- package/esm/src/resources/auth.d.ts +57 -0
- package/esm/src/resources/auth.d.ts.map +1 -0
- package/esm/src/resources/auth.js +39 -0
- package/esm/src/resources/eggs.d.ts +238 -0
- package/esm/src/resources/eggs.d.ts.map +1 -0
- package/esm/src/resources/eggs.js +187 -0
- package/esm/src/resources/hosts.d.ts +62 -0
- package/esm/src/resources/hosts.d.ts.map +1 -0
- package/esm/src/resources/hosts.js +62 -0
- package/esm/src/resources/members.d.ts +138 -0
- package/esm/src/resources/members.d.ts.map +1 -0
- package/esm/src/resources/members.js +122 -0
- package/esm/src/resources/nodes.d.ts +397 -0
- package/esm/src/resources/nodes.d.ts.map +1 -0
- package/esm/src/resources/nodes.js +352 -0
- package/esm/src/resources/server-groups.d.ts +150 -0
- package/esm/src/resources/server-groups.d.ts.map +1 -0
- package/esm/src/resources/server-groups.js +111 -0
- package/esm/src/resources/servers/activity.d.ts +120 -0
- package/esm/src/resources/servers/activity.d.ts.map +1 -0
- package/esm/src/resources/servers/activity.js +163 -0
- package/esm/src/resources/servers/allocations.d.ts +125 -0
- package/esm/src/resources/servers/allocations.d.ts.map +1 -0
- package/esm/src/resources/servers/allocations.js +137 -0
- package/esm/src/resources/servers/connection.d.ts +108 -0
- package/esm/src/resources/servers/connection.d.ts.map +1 -0
- package/esm/src/resources/servers/connection.js +169 -0
- package/esm/src/resources/servers/files.d.ts +164 -0
- package/esm/src/resources/servers/files.d.ts.map +1 -0
- package/esm/src/resources/servers/files.js +281 -0
- package/esm/src/resources/servers/index.d.ts +126 -0
- package/esm/src/resources/servers/index.d.ts.map +1 -0
- package/esm/src/resources/servers/index.js +135 -0
- package/esm/src/resources/servers/profiles.d.ts +138 -0
- package/esm/src/resources/servers/profiles.d.ts.map +1 -0
- package/esm/src/resources/servers/profiles.js +177 -0
- package/esm/src/resources/servers/server.d.ts +136 -0
- package/esm/src/resources/servers/server.d.ts.map +1 -0
- package/esm/src/resources/servers/server.js +202 -0
- package/esm/src/resources/servers/sftp.d.ts +147 -0
- package/esm/src/resources/servers/sftp.d.ts.map +1 -0
- package/esm/src/resources/servers/sftp.js +153 -0
- package/esm/src/resources/servers/types.d.ts +199 -0
- package/esm/src/resources/servers/types.d.ts.map +1 -0
- package/esm/src/resources/servers/types.js +1 -0
- package/esm/src/sse.d.ts +53 -0
- package/esm/src/sse.d.ts.map +1 -0
- package/esm/src/sse.js +133 -0
- package/esm/src/types.d.ts +126 -0
- package/esm/src/types.d.ts.map +1 -0
- package/esm/src/types.js +21 -0
- package/package.json +4 -92
- package/script/mod.d.ts +87 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +132 -3
- package/script/src/client.d.ts +248 -0
- package/script/src/client.d.ts.map +1 -0
- package/script/src/client.js +239 -0
- package/script/src/emitter.d.ts +53 -0
- package/script/src/emitter.d.ts.map +1 -0
- package/script/src/emitter.js +59 -0
- package/script/src/errors.d.ts +42 -0
- package/script/src/errors.d.ts.map +1 -0
- package/script/src/errors.js +49 -0
- package/script/src/http.d.ts +157 -0
- package/script/src/http.d.ts.map +1 -0
- package/script/src/http.js +321 -0
- package/script/src/namespace.d.ts +59 -0
- package/script/src/namespace.d.ts.map +1 -0
- package/script/src/namespace.js +83 -0
- package/script/src/reactive.d.ts +29 -0
- package/script/src/reactive.d.ts.map +1 -0
- package/script/src/reactive.js +39 -0
- package/script/src/resources/account.d.ts +125 -0
- package/script/src/resources/account.d.ts.map +1 -0
- package/script/src/resources/account.js +158 -0
- package/script/src/resources/api-keys.d.ts +116 -0
- package/script/src/resources/api-keys.d.ts.map +1 -0
- package/script/src/resources/api-keys.js +110 -0
- package/script/src/resources/auth.d.ts +57 -0
- package/script/src/resources/auth.d.ts.map +1 -0
- package/script/src/resources/auth.js +43 -0
- package/script/src/resources/eggs.d.ts +238 -0
- package/script/src/resources/eggs.d.ts.map +1 -0
- package/script/src/resources/eggs.js +193 -0
- package/script/src/resources/hosts.d.ts +62 -0
- package/script/src/resources/hosts.d.ts.map +1 -0
- package/script/src/resources/hosts.js +67 -0
- package/script/src/resources/members.d.ts +138 -0
- package/script/src/resources/members.d.ts.map +1 -0
- package/script/src/resources/members.js +127 -0
- package/script/src/resources/nodes.d.ts +397 -0
- package/script/src/resources/nodes.d.ts.map +1 -0
- package/script/src/resources/nodes.js +362 -0
- package/script/src/resources/server-groups.d.ts +150 -0
- package/script/src/resources/server-groups.d.ts.map +1 -0
- package/script/src/resources/server-groups.js +116 -0
- package/script/src/resources/servers/activity.d.ts +120 -0
- package/script/src/resources/servers/activity.d.ts.map +1 -0
- package/script/src/resources/servers/activity.js +170 -0
- package/script/src/resources/servers/allocations.d.ts +125 -0
- package/script/src/resources/servers/allocations.d.ts.map +1 -0
- package/script/src/resources/servers/allocations.js +142 -0
- package/script/src/resources/servers/connection.d.ts +108 -0
- package/script/src/resources/servers/connection.d.ts.map +1 -0
- package/script/src/resources/servers/connection.js +173 -0
- package/script/src/resources/servers/files.d.ts +164 -0
- package/script/src/resources/servers/files.d.ts.map +1 -0
- package/script/src/resources/servers/files.js +286 -0
- package/script/src/resources/servers/index.d.ts +126 -0
- package/script/src/resources/servers/index.d.ts.map +1 -0
- package/script/src/resources/servers/index.js +139 -0
- package/script/src/resources/servers/profiles.d.ts +138 -0
- package/script/src/resources/servers/profiles.d.ts.map +1 -0
- package/script/src/resources/servers/profiles.js +182 -0
- package/script/src/resources/servers/server.d.ts +136 -0
- package/script/src/resources/servers/server.d.ts.map +1 -0
- package/script/src/resources/servers/server.js +206 -0
- package/script/src/resources/servers/sftp.d.ts +147 -0
- package/script/src/resources/servers/sftp.d.ts.map +1 -0
- package/script/src/resources/servers/sftp.js +158 -0
- package/script/src/resources/servers/types.d.ts +199 -0
- package/script/src/resources/servers/types.d.ts.map +1 -0
- package/script/src/resources/servers/types.js +2 -0
- package/script/src/sse.d.ts +53 -0
- package/script/src/sse.d.ts.map +1 -0
- package/script/src/sse.js +137 -0
- package/script/src/types.d.ts +126 -0
- package/script/src/types.d.ts.map +1 -0
- package/script/src/types.js +25 -0
- package/esm/api.d.ts +0 -76
- package/esm/api.d.ts.map +0 -1
- package/esm/api.js +0 -187
- package/esm/components/auth.d.ts +0 -15
- package/esm/components/auth.d.ts.map +0 -1
- package/esm/components/auth.js +0 -13
- package/esm/components/connection/abstract.d.ts +0 -23
- package/esm/components/connection/abstract.d.ts.map +0 -1
- package/esm/components/connection/abstract.js +0 -43
- package/esm/components/connection/sse.d.ts +0 -20
- package/esm/components/connection/sse.d.ts.map +0 -1
- package/esm/components/connection/sse.js +0 -65
- package/esm/components/egg/egg.d.ts +0 -32
- package/esm/components/egg/egg.d.ts.map +0 -1
- package/esm/components/egg/egg.js +0 -70
- package/esm/components/group.d.ts +0 -14
- package/esm/components/group.d.ts.map +0 -1
- package/esm/components/group.js +0 -33
- package/esm/components/member_2.d.ts +0 -69
- package/esm/components/member_2.d.ts.map +0 -1
- package/esm/components/member_2.js +0 -140
- package/esm/components/node.d.ts +0 -78
- package/esm/components/node.d.ts.map +0 -1
- package/esm/components/node.js +0 -342
- package/esm/components/server/activity.d.ts +0 -45
- package/esm/components/server/activity.d.ts.map +0 -1
- package/esm/components/server/activity.js +0 -158
- package/esm/components/server/allocations.d.ts +0 -45
- package/esm/components/server/allocations.d.ts.map +0 -1
- package/esm/components/server/allocations.js +0 -146
- package/esm/components/server/files.d.ts +0 -50
- package/esm/components/server/files.d.ts.map +0 -1
- package/esm/components/server/files.js +0 -90
- package/esm/components/server/power.d.ts +0 -21
- package/esm/components/server/power.d.ts.map +0 -1
- package/esm/components/server/power.js +0 -43
- package/esm/components/server/profiles.d.ts +0 -63
- package/esm/components/server/profiles.d.ts.map +0 -1
- package/esm/components/server/profiles.js +0 -163
- package/esm/components/server/server.d.ts +0 -141
- package/esm/components/server/server.d.ts.map +0 -1
- package/esm/components/server/server.js +0 -358
- package/esm/components/server/sftp.d.ts +0 -31
- package/esm/components/server/sftp.d.ts.map +0 -1
- package/esm/components/server/sftp.js +0 -84
- package/esm/components/server/startup.d.ts +0 -17
- package/esm/components/server/startup.d.ts.map +0 -1
- package/esm/components/server/startup.js +0 -21
- package/esm/components/server/stats.d.ts +0 -19
- package/esm/components/server/stats.d.ts.map +0 -1
- package/esm/components/server/stats.js +0 -46
- package/esm/utils/cache.d.ts +0 -20
- package/esm/utils/cache.d.ts.map +0 -1
- package/esm/utils/cache.js +0 -66
- package/esm/utils/event.d.ts +0 -38
- package/esm/utils/event.d.ts.map +0 -1
- package/esm/utils/event.js +0 -71
- package/esm/utils/object.d.ts +0 -58
- package/esm/utils/object.d.ts.map +0 -1
- package/esm/utils/object.js +0 -86
- package/esm/utils/subscribe.d.ts +0 -37
- package/esm/utils/subscribe.d.ts.map +0 -1
- package/esm/utils/subscribe.js +0 -29
- package/esm/utils/timer.d.ts +0 -13
- package/esm/utils/timer.d.ts.map +0 -1
- package/esm/utils/timer.js +0 -32
- package/esm/utils/units.d.ts +0 -18
- package/esm/utils/units.d.ts.map +0 -1
- package/esm/utils/units.js +0 -82
- package/script/api.d.ts +0 -76
- package/script/api.d.ts.map +0 -1
- package/script/api.js +0 -192
- package/script/components/auth.d.ts +0 -15
- package/script/components/auth.d.ts.map +0 -1
- package/script/components/auth.js +0 -17
- package/script/components/connection/abstract.d.ts +0 -23
- package/script/components/connection/abstract.d.ts.map +0 -1
- package/script/components/connection/abstract.js +0 -47
- package/script/components/connection/sse.d.ts +0 -20
- package/script/components/connection/sse.d.ts.map +0 -1
- package/script/components/connection/sse.js +0 -69
- package/script/components/egg/egg.d.ts +0 -32
- package/script/components/egg/egg.d.ts.map +0 -1
- package/script/components/egg/egg.js +0 -74
- package/script/components/group.d.ts +0 -14
- package/script/components/group.d.ts.map +0 -1
- package/script/components/group.js +0 -37
- package/script/components/member_2.d.ts +0 -69
- package/script/components/member_2.d.ts.map +0 -1
- package/script/components/member_2.js +0 -146
- package/script/components/node.d.ts +0 -78
- package/script/components/node.d.ts.map +0 -1
- package/script/components/node.js +0 -349
- package/script/components/server/activity.d.ts +0 -45
- package/script/components/server/activity.d.ts.map +0 -1
- package/script/components/server/activity.js +0 -164
- package/script/components/server/allocations.d.ts +0 -45
- package/script/components/server/allocations.d.ts.map +0 -1
- package/script/components/server/allocations.js +0 -152
- package/script/components/server/files.d.ts +0 -50
- package/script/components/server/files.d.ts.map +0 -1
- package/script/components/server/files.js +0 -94
- package/script/components/server/power.d.ts +0 -21
- package/script/components/server/power.d.ts.map +0 -1
- package/script/components/server/power.js +0 -47
- package/script/components/server/profiles.d.ts +0 -63
- package/script/components/server/profiles.d.ts.map +0 -1
- package/script/components/server/profiles.js +0 -168
- package/script/components/server/server.d.ts +0 -141
- package/script/components/server/server.d.ts.map +0 -1
- package/script/components/server/server.js +0 -362
- package/script/components/server/sftp.d.ts +0 -31
- package/script/components/server/sftp.d.ts.map +0 -1
- package/script/components/server/sftp.js +0 -88
- package/script/components/server/startup.d.ts +0 -17
- package/script/components/server/startup.d.ts.map +0 -1
- package/script/components/server/startup.js +0 -25
- package/script/components/server/stats.d.ts +0 -19
- package/script/components/server/stats.d.ts.map +0 -1
- package/script/components/server/stats.js +0 -50
- package/script/utils/cache.d.ts +0 -20
- package/script/utils/cache.d.ts.map +0 -1
- package/script/utils/cache.js +0 -70
- package/script/utils/event.d.ts +0 -38
- package/script/utils/event.d.ts.map +0 -1
- package/script/utils/event.js +0 -75
- package/script/utils/object.d.ts +0 -58
- package/script/utils/object.d.ts.map +0 -1
- package/script/utils/object.js +0 -90
- package/script/utils/subscribe.d.ts +0 -37
- package/script/utils/subscribe.d.ts.map +0 -1
- package/script/utils/subscribe.js +0 -32
- package/script/utils/timer.d.ts +0 -13
- package/script/utils/timer.d.ts.map +0 -1
- package/script/utils/timer.js +0 -36
- package/script/utils/units.d.ts +0 -18
- package/script/utils/units.d.ts.map +0 -1
- package/script/utils/units.js +0 -86
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import type { MeowPanelApi, MeowPanelApiRequestData, Page, Pagination } from '../../api.js';
|
|
2
|
-
import { CachedRelation } from '../../utils/cache.js';
|
|
3
|
-
import { type EventFunction, EventManager, type EventManagerListener } from '../../utils/event.js';
|
|
4
|
-
import { UpdatableObject } from '../../utils/object.js';
|
|
5
|
-
import { type Subscription } from '../../utils/subscribe.js';
|
|
6
|
-
import type { Extended } from '../../utils/types';
|
|
7
|
-
import type { Logger } from '../connection/abstract.js';
|
|
8
|
-
import { Egg, type EggInclude } from '../egg/egg.js';
|
|
9
|
-
import { ServerGroup } from '../group.js';
|
|
10
|
-
import type { Node } from '../node.js';
|
|
11
|
-
import { ServerActivityJob, ServerActivityLog } from './activity.js';
|
|
12
|
-
import { ServerAllocationPort, ServerAllocations } from './allocations.js';
|
|
13
|
-
import { ServerFileManager } from './files.js';
|
|
14
|
-
import { type PowerState, PowerStateEvent } from './power.js';
|
|
15
|
-
import { ServerProfileManager } from './profiles.js';
|
|
16
|
-
import type { ServerBuildResponse, ServerResponse, ServerRestrictedState, SftpResponse } from './server_2';
|
|
17
|
-
import { SftpUser } from './sftp.js';
|
|
18
|
-
import { StartupParameters } from './startup.js';
|
|
19
|
-
import { ServerStatsEvent } from './stats.js';
|
|
20
|
-
export type ServerInclude = 'status' | 'group' | 'startup' | 'egg' | EggInclude | 'group' | 'build' | 'profiles';
|
|
21
|
-
interface Modified {
|
|
22
|
-
group: CachedRelation<ServerGroup>;
|
|
23
|
-
egg: CachedRelation<Egg>;
|
|
24
|
-
status: ServerStatsEvent;
|
|
25
|
-
startup: CachedRelation<StartupParameters>;
|
|
26
|
-
allocations: CachedRelation<ServerAllocations>;
|
|
27
|
-
build: CachedRelation<ServerBuildResponse>;
|
|
28
|
-
}
|
|
29
|
-
type PowerStateResponse = {
|
|
30
|
-
state: PowerState;
|
|
31
|
-
utilization: {
|
|
32
|
-
memory_bytes: 0;
|
|
33
|
-
memory_limit_bytes: 0;
|
|
34
|
-
cpu_absolute: 0;
|
|
35
|
-
network: {
|
|
36
|
-
rx_bytes: 0;
|
|
37
|
-
tx_bytes: 0;
|
|
38
|
-
};
|
|
39
|
-
uptime: 0;
|
|
40
|
-
state: PowerState;
|
|
41
|
-
disk_bytes: 0;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export declare class Server extends UpdatableObject<ServerResponse, Modified, ServerInclude> implements EventManagerListener<ServerEvents>, Subscription<Server> {
|
|
45
|
-
static getPaged(api: MeowPanelApi, page: number, include?: ServerInclude[], query?: string): Promise<{
|
|
46
|
-
servers: Server[];
|
|
47
|
-
page: Page;
|
|
48
|
-
}>;
|
|
49
|
-
static get(api: MeowPanelApi, id: string, include?: ServerInclude[]): Promise<Server>;
|
|
50
|
-
constructor(api: MeowPanelApi, data: ServerResponse);
|
|
51
|
-
protected applyResponse(oldData: Extended<ServerResponse, Modified> | undefined, newData: ServerResponse): Modified;
|
|
52
|
-
protected readonly eventManager: EventManager<ServerEvents>;
|
|
53
|
-
on<K extends keyof ServerEvents>(event: K, func: EventFunction<ServerEvents, K>): number;
|
|
54
|
-
off<K extends keyof ServerEvents>(event: K | number, func?: number | EventFunction<ServerEvents, K>): boolean;
|
|
55
|
-
subscribe(fn: (value: Server) => void): () => void;
|
|
56
|
-
readonly consoleHistory: Subscription<string[]>;
|
|
57
|
-
private connection;
|
|
58
|
-
private readonly ids;
|
|
59
|
-
connect(options?: Partial<{
|
|
60
|
-
logger: Logger;
|
|
61
|
-
resetEventListeners: boolean;
|
|
62
|
-
}>): Promise<void>;
|
|
63
|
-
disconnect(): Promise<void>;
|
|
64
|
-
get isConnected(): boolean | undefined;
|
|
65
|
-
getNode(): Promise<Node>;
|
|
66
|
-
requestNodeApi(method: string, path: `/${string}`, data?: MeowPanelApiRequestData): Promise<Response>;
|
|
67
|
-
updateDetails(details: {
|
|
68
|
-
name?: string;
|
|
69
|
-
description?: string | null;
|
|
70
|
-
notes?: string | null;
|
|
71
|
-
}): Promise<void>;
|
|
72
|
-
updateStartup(startup: {
|
|
73
|
-
command?: string;
|
|
74
|
-
variables?: Record<string, string>;
|
|
75
|
-
}): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Get the status of the server such as its power state status and utilization.
|
|
78
|
-
*
|
|
79
|
-
* Calling this will also update the current power status subscription of the server.
|
|
80
|
-
*/
|
|
81
|
-
getStatus(): Promise<PowerStateResponse>;
|
|
82
|
-
/**
|
|
83
|
-
* Get the current power status state of the server.
|
|
84
|
-
*
|
|
85
|
-
* This function is an alias for the `getStatus` function.
|
|
86
|
-
*/
|
|
87
|
-
getPowerState(): Promise<PowerState>;
|
|
88
|
-
/**
|
|
89
|
-
* Send a power signal to the server.
|
|
90
|
-
*/
|
|
91
|
-
sendPowerSignal(state: 'start' | 'restart' | 'stop' | 'kill'): Promise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* Send one or multiple commands to the server.
|
|
94
|
-
*
|
|
95
|
-
* The server must be in the running state for this to work.
|
|
96
|
-
*/
|
|
97
|
-
sendCommand(command: string | string[]): Promise<void>;
|
|
98
|
-
getActivityLogs(pagination: Pagination, include?: Array<'jobs' | 'server' | 'node'>, query?: string): Promise<{
|
|
99
|
-
logs: ServerActivityLog[];
|
|
100
|
-
page: Page;
|
|
101
|
-
}>;
|
|
102
|
-
getActivityLog(id: string): Promise<ServerActivityLog>;
|
|
103
|
-
getActivityJobs(pagination: Pagination, include?: Array<'server' | 'node'>, query?: string): Promise<{
|
|
104
|
-
jobs: ServerActivityJob[];
|
|
105
|
-
page: Page;
|
|
106
|
-
}>;
|
|
107
|
-
getActivityJob(id: string): Promise<ServerActivityJob>;
|
|
108
|
-
getSftpDetails(): Promise<SftpResponse['connection']>;
|
|
109
|
-
getSftpUsers(pagination: Pagination, include?: Array<'password' | 'owner'>, query?: string): Promise<{
|
|
110
|
-
users: SftpUser[];
|
|
111
|
-
page: Page;
|
|
112
|
-
}>;
|
|
113
|
-
getAllocations(pagination: Pagination, include?: Array<'meta'>, query?: string): Promise<{
|
|
114
|
-
allocations: ServerAllocationPort[];
|
|
115
|
-
page: Page;
|
|
116
|
-
}>;
|
|
117
|
-
readonly profiles: ServerProfileManager;
|
|
118
|
-
readonly files: ServerFileManager;
|
|
119
|
-
get id(): string;
|
|
120
|
-
get name(): string;
|
|
121
|
-
get description(): string;
|
|
122
|
-
get notes(): string | null | undefined;
|
|
123
|
-
get group(): CachedRelation<ServerGroup>;
|
|
124
|
-
get restrictedState(): ServerRestrictedState;
|
|
125
|
-
get egg(): CachedRelation<Egg>;
|
|
126
|
-
get build(): CachedRelation<ServerBuildResponse>;
|
|
127
|
-
get allocations(): CachedRelation<ServerAllocations>;
|
|
128
|
-
get status(): ServerStatsEvent;
|
|
129
|
-
get startup(): CachedRelation<StartupParameters>;
|
|
130
|
-
get createdAt(): string;
|
|
131
|
-
get updatedAt(): string;
|
|
132
|
-
}
|
|
133
|
-
interface ServerEvents {
|
|
134
|
-
power: PowerStateEvent;
|
|
135
|
-
stats: ServerStatsEvent;
|
|
136
|
-
console_output: string;
|
|
137
|
-
meta_details: Server;
|
|
138
|
-
startup_details: StartupParameters;
|
|
139
|
-
}
|
|
140
|
-
export {};
|
|
141
|
-
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/components/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,2BAA2B,CAAC;AAE1E,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,KAAK,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,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CAAC,CAEpC;IAED,IAAW,KAAK,IAAI,cAAc,CAAC,mBAAmB,CAAC,CAEtD;IAED,IAAW,WAAW,IAAI,cAAc,CAAC,iBAAiB,CAAC,CAE1D;IAED,IAAW,MAAM,IAAI,gBAAgB,CAEpC;IAOD,IAAW,OAAO,IAAI,cAAc,CAAC,iBAAiB,CAAC,CAEtD;IAED,IAAW,SAAS,IAAI,MAAM,CAE7B;IACD,IAAW,SAAS,IAAI,MAAM,CAE7B;CACD;AAED,UAAU,YAAY;IACrB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,gBAAgB,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,iBAAiB,CAAC;CACnC"}
|
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Server = void 0;
|
|
4
|
-
const cache_js_1 = require("../../utils/cache.js");
|
|
5
|
-
const event_js_1 = require("../../utils/event.js");
|
|
6
|
-
const object_js_1 = require("../../utils/object.js");
|
|
7
|
-
const subscribe_js_1 = require("../../utils/subscribe.js");
|
|
8
|
-
const sse_js_1 = require("../connection/sse.js");
|
|
9
|
-
const egg_js_1 = require("../egg/egg.js");
|
|
10
|
-
const group_js_1 = require("../group.js");
|
|
11
|
-
const activity_js_1 = require("./activity.js");
|
|
12
|
-
const allocations_js_1 = require("./allocations.js");
|
|
13
|
-
const files_js_1 = require("./files.js");
|
|
14
|
-
const power_js_1 = require("./power.js");
|
|
15
|
-
const profiles_js_1 = require("./profiles.js");
|
|
16
|
-
const sftp_js_1 = require("./sftp.js");
|
|
17
|
-
const startup_js_1 = require("./startup.js");
|
|
18
|
-
const stats_js_1 = require("./stats.js");
|
|
19
|
-
class Server extends object_js_1.UpdatableObject {
|
|
20
|
-
static async getPaged(api, page, include, query) {
|
|
21
|
-
const response = await api.request('GET', `/v1/servers`, {
|
|
22
|
-
pagination: { page },
|
|
23
|
-
params: {
|
|
24
|
-
include: include?.join(','),
|
|
25
|
-
query,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
servers: response.data.map((data) => new Server(api, data)),
|
|
30
|
-
page: response.page,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
static async get(api, id, include) {
|
|
34
|
-
const response = await api.request('GET', `/v1/servers/${id}`, {
|
|
35
|
-
params: {
|
|
36
|
-
include: include?.join(','),
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
return new Server(api, response.data);
|
|
40
|
-
}
|
|
41
|
-
constructor(api, data) {
|
|
42
|
-
super(api, data, `/v1/servers/${data.id}`);
|
|
43
|
-
Object.defineProperty(this, "eventManager", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
writable: true,
|
|
47
|
-
value: new event_js_1.EventManager()
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(this, "consoleHistory", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
configurable: true,
|
|
52
|
-
writable: true,
|
|
53
|
-
value: (0, subscribe_js_1.createSubscription)([], (_, update) => {
|
|
54
|
-
function updateHistory(message) {
|
|
55
|
-
update((history) => {
|
|
56
|
-
history.push(message);
|
|
57
|
-
if (history.length > 1024) {
|
|
58
|
-
history.shift();
|
|
59
|
-
}
|
|
60
|
-
return history;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
this.eventManager.on('console_output', updateHistory);
|
|
64
|
-
return () => this.eventManager.off('console_output', updateHistory);
|
|
65
|
-
})
|
|
66
|
-
});
|
|
67
|
-
Object.defineProperty(this, "connection", {
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
writable: true,
|
|
71
|
-
value: void 0
|
|
72
|
-
});
|
|
73
|
-
Object.defineProperty(this, "ids", {
|
|
74
|
-
enumerable: true,
|
|
75
|
-
configurable: true,
|
|
76
|
-
writable: true,
|
|
77
|
-
value: []
|
|
78
|
-
});
|
|
79
|
-
Object.defineProperty(this, "profiles", {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
configurable: true,
|
|
82
|
-
writable: true,
|
|
83
|
-
value: new profiles_js_1.ServerProfileManager(this.api, this)
|
|
84
|
-
});
|
|
85
|
-
Object.defineProperty(this, "files", {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
configurable: true,
|
|
88
|
-
writable: true,
|
|
89
|
-
value: new files_js_1.ServerFileManager(this.api, this)
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
applyResponse(oldData, newData) {
|
|
93
|
-
const response = {
|
|
94
|
-
group: oldData?.group ??
|
|
95
|
-
new cache_js_1.CachedRelation(() => group_js_1.ServerGroup.get(this.api, newData.group_id)),
|
|
96
|
-
egg: oldData?.egg ??
|
|
97
|
-
new cache_js_1.CachedRelation(() => egg_js_1.Egg.get(this.api, newData.egg_id)),
|
|
98
|
-
status: oldData?.status ?? new stats_js_1.ServerStatsEvent(this, newData.status),
|
|
99
|
-
startup: oldData?.startup ??
|
|
100
|
-
new cache_js_1.CachedRelation(async () => {
|
|
101
|
-
const response = await this.fetchSelf(['startup']);
|
|
102
|
-
return new startup_js_1.StartupParameters(response.startup);
|
|
103
|
-
}),
|
|
104
|
-
allocations: oldData?.allocations ??
|
|
105
|
-
new cache_js_1.CachedRelation(() => allocations_js_1.ServerAllocations.get(this.api, this, newData.id)),
|
|
106
|
-
build: oldData?.build ??
|
|
107
|
-
new cache_js_1.CachedRelation(() => this.fetchSelf(['build']).then((v) => v.build)),
|
|
108
|
-
};
|
|
109
|
-
newData.group &&
|
|
110
|
-
response.group.setCache(new group_js_1.ServerGroup(this.api, newData.group));
|
|
111
|
-
newData.status &&
|
|
112
|
-
this.eventManager?.dispatch('power', new power_js_1.PowerStateEvent(newData.status.state));
|
|
113
|
-
newData.startup &&
|
|
114
|
-
response.startup.setCache(new startup_js_1.StartupParameters(newData.startup));
|
|
115
|
-
newData.allocations &&
|
|
116
|
-
response.allocations.setCache(new allocations_js_1.ServerAllocations(this.api, this, newData.allocations));
|
|
117
|
-
newData.build && response.build.setCache(newData.build);
|
|
118
|
-
newData.profiles && this.profiles.addCached(newData.profiles);
|
|
119
|
-
return response;
|
|
120
|
-
}
|
|
121
|
-
on(event, func) {
|
|
122
|
-
return this.eventManager.on(event, func);
|
|
123
|
-
}
|
|
124
|
-
off(event, func) {
|
|
125
|
-
return this.eventManager.off(event, func);
|
|
126
|
-
}
|
|
127
|
-
subscribe(fn) {
|
|
128
|
-
const ids = [];
|
|
129
|
-
const update = () => fn(this);
|
|
130
|
-
update();
|
|
131
|
-
ids.push(this.eventManager.on('stats', (event) => {
|
|
132
|
-
this.response.status = event; // received from node
|
|
133
|
-
update();
|
|
134
|
-
}));
|
|
135
|
-
ids.push(this.eventManager.on('meta_details', update));
|
|
136
|
-
ids.push(this.eventManager.on('startup_details', update));
|
|
137
|
-
return () => {
|
|
138
|
-
ids.forEach(this.eventManager.off.bind(this.eventManager));
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
async connect(options) {
|
|
142
|
-
if (this.connection?.isConnected)
|
|
143
|
-
return;
|
|
144
|
-
// TODO: Support for Websocket connections
|
|
145
|
-
// Have auto-adjustment to connect to WebSocket first and SSE as fallback
|
|
146
|
-
// Manually adjustable in the panel settings
|
|
147
|
-
this.connection = new sse_js_1.SseServerConnection(this);
|
|
148
|
-
if (options?.logger)
|
|
149
|
-
this.connection.logger = options.logger;
|
|
150
|
-
this.ids.push(this.connection.on('console_output', (event) => {
|
|
151
|
-
this.eventManager.dispatch('console_output', event.join('\n'));
|
|
152
|
-
}));
|
|
153
|
-
this.ids.push(this.connection.on('status', (event) => {
|
|
154
|
-
this.eventManager.dispatch('power', new power_js_1.PowerStateEvent(event[0]));
|
|
155
|
-
}));
|
|
156
|
-
this.ids.push(this.connection.on('stats', (event) => {
|
|
157
|
-
const data = JSON.parse(event[0]);
|
|
158
|
-
const stats = new stats_js_1.ServerStatsEvent(this, {
|
|
159
|
-
state: data.state,
|
|
160
|
-
utilization: {
|
|
161
|
-
cpu_absolute: data.cpu_absolute,
|
|
162
|
-
disk_bytes: data.disk_bytes,
|
|
163
|
-
memory_bytes: data.memory_bytes,
|
|
164
|
-
memory_limit_bytes: data.memory_limit_bytes,
|
|
165
|
-
network: data.network,
|
|
166
|
-
uptime: data.uptime,
|
|
167
|
-
state: data.state,
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
this.eventManager.dispatch('stats', stats);
|
|
171
|
-
}));
|
|
172
|
-
await this.connection.connect();
|
|
173
|
-
}
|
|
174
|
-
async disconnect() {
|
|
175
|
-
if (!this.connection)
|
|
176
|
-
return;
|
|
177
|
-
await this.connection.disconnect();
|
|
178
|
-
this.ids.forEach(this.connection.off.bind(this.connection));
|
|
179
|
-
this.ids.length = 0;
|
|
180
|
-
this.connection = undefined;
|
|
181
|
-
}
|
|
182
|
-
get isConnected() {
|
|
183
|
-
return this.connection?.isConnected;
|
|
184
|
-
}
|
|
185
|
-
async getNode() {
|
|
186
|
-
return await this.group.get().then((v) => v.node.get());
|
|
187
|
-
}
|
|
188
|
-
async requestNodeApi(method, path, data = {}) {
|
|
189
|
-
const node = await this.getNode();
|
|
190
|
-
const { connection } = node;
|
|
191
|
-
if (!connection)
|
|
192
|
-
throw new Error('No permission to connect to server');
|
|
193
|
-
const url = new URL(connection.url);
|
|
194
|
-
url.pathname = `/api/servers/${this.id}${path}`;
|
|
195
|
-
return this.api.requestUrl(method, url, data);
|
|
196
|
-
}
|
|
197
|
-
async updateDetails(details) {
|
|
198
|
-
const response = await this.callPatch(details);
|
|
199
|
-
this.response.name = response.name;
|
|
200
|
-
this.response.description = response.description;
|
|
201
|
-
this.response.notes = response.notes;
|
|
202
|
-
this.eventManager.dispatch('meta_details', this);
|
|
203
|
-
}
|
|
204
|
-
async updateStartup(startup) {
|
|
205
|
-
const response = await this.callPatch({ startup });
|
|
206
|
-
const startupParameters = new startup_js_1.StartupParameters(response.startup);
|
|
207
|
-
this.response.startup.setCache(startupParameters);
|
|
208
|
-
this.eventManager.dispatch('startup_details', startupParameters);
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Get the status of the server such as its power state status and utilization.
|
|
212
|
-
*
|
|
213
|
-
* Calling this will also update the current power status subscription of the server.
|
|
214
|
-
*/
|
|
215
|
-
async getStatus() {
|
|
216
|
-
const response = await this.api.request('GET', `/v1/servers/${this.id}/status`);
|
|
217
|
-
this.eventManager.dispatch('power', new power_js_1.PowerStateEvent(response.data.state));
|
|
218
|
-
return response.data;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Get the current power status state of the server.
|
|
222
|
-
*
|
|
223
|
-
* This function is an alias for the `getStatus` function.
|
|
224
|
-
*/
|
|
225
|
-
async getPowerState() {
|
|
226
|
-
const status = await this.getStatus();
|
|
227
|
-
return status.state;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Send a power signal to the server.
|
|
231
|
-
*/
|
|
232
|
-
async sendPowerSignal(state) {
|
|
233
|
-
await this.requestNodeApi('POST', '/power', { body: { action: state } });
|
|
234
|
-
await this.getPowerState();
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Send one or multiple commands to the server.
|
|
238
|
-
*
|
|
239
|
-
* The server must be in the running state for this to work.
|
|
240
|
-
*/
|
|
241
|
-
async sendCommand(command) {
|
|
242
|
-
const commands = typeof command === 'string' ? [command] : command;
|
|
243
|
-
await this.requestNodeApi('POST', '/commands', { body: { commands } });
|
|
244
|
-
}
|
|
245
|
-
async getActivityLogs(pagination, include, query) {
|
|
246
|
-
return await this.api
|
|
247
|
-
.request('GET', `/v1/servers/${this.id}/activities`, {
|
|
248
|
-
pagination,
|
|
249
|
-
params: {
|
|
250
|
-
include: include?.join(','),
|
|
251
|
-
query,
|
|
252
|
-
},
|
|
253
|
-
})
|
|
254
|
-
.then((v) => ({
|
|
255
|
-
logs: v.data.map((v) => new activity_js_1.ServerActivityLog(this.api, this, v)),
|
|
256
|
-
page: v.page,
|
|
257
|
-
}));
|
|
258
|
-
}
|
|
259
|
-
async getActivityLog(id) {
|
|
260
|
-
return await this.api
|
|
261
|
-
.request('GET', `/v1/servers/${this.id}/activities/${id}`)
|
|
262
|
-
.then((v) => new activity_js_1.ServerActivityLog(this.api, this, v.data));
|
|
263
|
-
}
|
|
264
|
-
// TODO: standardize search functions into one argument
|
|
265
|
-
async getActivityJobs(pagination, include, query) {
|
|
266
|
-
return await this.api
|
|
267
|
-
.request('GET', `/v1/servers/${this.id}/activities/jobs`, {
|
|
268
|
-
pagination,
|
|
269
|
-
params: {
|
|
270
|
-
include: include?.join(','),
|
|
271
|
-
query,
|
|
272
|
-
},
|
|
273
|
-
})
|
|
274
|
-
.then((v) => ({
|
|
275
|
-
jobs: v.data.map((v) => new activity_js_1.ServerActivityJob(this.api, this, v)),
|
|
276
|
-
page: v.page,
|
|
277
|
-
}));
|
|
278
|
-
}
|
|
279
|
-
async getActivityJob(id) {
|
|
280
|
-
return await this.api
|
|
281
|
-
.request('GET', `/v1/servers/${this.id}/activities/jobs/${id}`)
|
|
282
|
-
.then((v) => new activity_js_1.ServerActivityJob(this.api, this, v.data));
|
|
283
|
-
}
|
|
284
|
-
async getSftpDetails() {
|
|
285
|
-
return await this.api
|
|
286
|
-
.request('GET', `/v1/servers/${this.id}/sftp`)
|
|
287
|
-
.then((v) => v.data.connection);
|
|
288
|
-
}
|
|
289
|
-
async getSftpUsers(pagination, include, query) {
|
|
290
|
-
return await this.api
|
|
291
|
-
.request('GET', `/v1/servers/${this.id}/sftp/users`, {
|
|
292
|
-
pagination,
|
|
293
|
-
params: {
|
|
294
|
-
include: include?.join(','),
|
|
295
|
-
query,
|
|
296
|
-
},
|
|
297
|
-
})
|
|
298
|
-
.then((v) => ({
|
|
299
|
-
users: v.data.map((v) => new sftp_js_1.SftpUser(this.api, this, v)),
|
|
300
|
-
page: v.page,
|
|
301
|
-
}));
|
|
302
|
-
}
|
|
303
|
-
async getAllocations(pagination, include, query) {
|
|
304
|
-
return await this.api
|
|
305
|
-
.request('GET', `/v1/servers/${this.id}/allocations`, {
|
|
306
|
-
pagination,
|
|
307
|
-
params: {
|
|
308
|
-
include: include?.join(','),
|
|
309
|
-
query,
|
|
310
|
-
},
|
|
311
|
-
})
|
|
312
|
-
.then((v) => ({
|
|
313
|
-
allocations: v.data.map((v) => new allocations_js_1.ServerAllocationPort(this.api, this, v)),
|
|
314
|
-
page: v.page,
|
|
315
|
-
}));
|
|
316
|
-
}
|
|
317
|
-
//> Accessors
|
|
318
|
-
get id() {
|
|
319
|
-
return this.response.id;
|
|
320
|
-
}
|
|
321
|
-
get name() {
|
|
322
|
-
return this.response.name;
|
|
323
|
-
}
|
|
324
|
-
get description() {
|
|
325
|
-
return this.response.description;
|
|
326
|
-
}
|
|
327
|
-
get notes() {
|
|
328
|
-
return this.response.notes;
|
|
329
|
-
}
|
|
330
|
-
get group() {
|
|
331
|
-
return this.response.group;
|
|
332
|
-
}
|
|
333
|
-
get restrictedState() {
|
|
334
|
-
return this.response.restricted_state;
|
|
335
|
-
}
|
|
336
|
-
get egg() {
|
|
337
|
-
return this.response.egg;
|
|
338
|
-
}
|
|
339
|
-
get build() {
|
|
340
|
-
return this.response.build;
|
|
341
|
-
}
|
|
342
|
-
get allocations() {
|
|
343
|
-
return this.response.allocations;
|
|
344
|
-
}
|
|
345
|
-
get status() {
|
|
346
|
-
return this.response.status;
|
|
347
|
-
}
|
|
348
|
-
// TODO: Add SFTP Credentials
|
|
349
|
-
// public get sftp() {
|
|
350
|
-
// return this.updatable.sftp;
|
|
351
|
-
// }
|
|
352
|
-
get startup() {
|
|
353
|
-
return this.response.startup;
|
|
354
|
-
}
|
|
355
|
-
get createdAt() {
|
|
356
|
-
return this.response.created_at;
|
|
357
|
-
}
|
|
358
|
-
get updatedAt() {
|
|
359
|
-
return this.response.updated_at;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
exports.Server = Server;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { MeowPanelApi } from '../../api.js';
|
|
2
|
-
import { CachedRelation } from '../../utils/cache.js';
|
|
3
|
-
import { Member } from '../member_2.js';
|
|
4
|
-
import type { SftpPermissions, SftpUserResponse } from './server_2';
|
|
5
|
-
import type { Server } from './server.js';
|
|
6
|
-
export declare class SftpUser {
|
|
7
|
-
protected readonly api: MeowPanelApi;
|
|
8
|
-
protected readonly server: Server;
|
|
9
|
-
protected readonly response: SftpUserResponse;
|
|
10
|
-
constructor(api: MeowPanelApi, server: Server, response: SftpUserResponse);
|
|
11
|
-
get id(): string;
|
|
12
|
-
get name(): string;
|
|
13
|
-
get username(): string;
|
|
14
|
-
readonly password: CachedRelation<string>;
|
|
15
|
-
/**
|
|
16
|
-
* List of permissions for each file path pattern that this SFTP user has access to.
|
|
17
|
-
*/
|
|
18
|
-
get paths(): Record<string, SftpPermissions[]>;
|
|
19
|
-
readonly owner: CachedRelation<Member>;
|
|
20
|
-
get lastLoginAt(): Date | null;
|
|
21
|
-
get createdAt(): Date;
|
|
22
|
-
get updatedAt(): Date;
|
|
23
|
-
/**
|
|
24
|
-
* Delete this SFTP user.
|
|
25
|
-
*
|
|
26
|
-
* Calling additional calls to this object may throw an error.
|
|
27
|
-
*/
|
|
28
|
-
delete(): Promise<void>;
|
|
29
|
-
setPathPermissions(path: string, permissions: SftpPermissions[]): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=sftp.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sftp.d.ts","sourceRoot":"","sources":["../../../src/components/server/sftp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,QAAQ;IAEnB,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY;IACpC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACjC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB;gBAF1B,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB;IAQ9C,IAAW,EAAE,IAAI,MAAM,CAEtB;IAED,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,SAAgB,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,CAU9C;IAEF;;OAEG;IACH,IAAW,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAEpD;IAED,SAAgB,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,CAE3C;IAEF,IAAW,WAAW,IAAI,IAAI,GAAG,IAAI,CAEpC;IAED,IAAW,SAAS,IAAI,IAAI,CAE3B;IAED,IAAW,SAAS,IAAI,IAAI,CAE3B;IAED;;;;OAIG;IACU,MAAM;IAQN,kBAAkB,CAC9B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,eAAe,EAAE;CAY/B"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SftpUser = void 0;
|
|
4
|
-
const cache_js_1 = require("../../utils/cache.js");
|
|
5
|
-
const member_2_js_1 = require("../member_2.js");
|
|
6
|
-
class SftpUser {
|
|
7
|
-
constructor(api, server, response) {
|
|
8
|
-
Object.defineProperty(this, "api", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: api
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "server", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: server
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "response", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: response
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(this, "password", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
value: new cache_js_1.CachedRelation(() => this.api
|
|
31
|
-
.request('GET', `/v1/servers/${this.server.id}/sftp/users/${this.id}`, {
|
|
32
|
-
params: { include: 'password' },
|
|
33
|
-
})
|
|
34
|
-
.then((v) => v.data.password))
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(this, "owner", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true,
|
|
40
|
-
value: new cache_js_1.CachedRelation(() => this.api.members.get(this.response.owner_id))
|
|
41
|
-
});
|
|
42
|
-
if (response.owner) {
|
|
43
|
-
this.owner.setCache(new member_2_js_1.Member(this.api, response.owner));
|
|
44
|
-
}
|
|
45
|
-
if (response.password)
|
|
46
|
-
this.password.setCache(response.password);
|
|
47
|
-
}
|
|
48
|
-
get id() {
|
|
49
|
-
return this.response.id;
|
|
50
|
-
}
|
|
51
|
-
get name() {
|
|
52
|
-
return this.response.name;
|
|
53
|
-
}
|
|
54
|
-
get username() {
|
|
55
|
-
return this.response.username;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* List of permissions for each file path pattern that this SFTP user has access to.
|
|
59
|
-
*/
|
|
60
|
-
get paths() {
|
|
61
|
-
return this.response.paths;
|
|
62
|
-
}
|
|
63
|
-
get lastLoginAt() {
|
|
64
|
-
return this.response.last_login_at ? new Date(this.response.last_login_at) : null;
|
|
65
|
-
}
|
|
66
|
-
get createdAt() {
|
|
67
|
-
return new Date(this.response.created_at);
|
|
68
|
-
}
|
|
69
|
-
get updatedAt() {
|
|
70
|
-
return new Date(this.response.updated_at);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Delete this SFTP user.
|
|
74
|
-
*
|
|
75
|
-
* Calling additional calls to this object may throw an error.
|
|
76
|
-
*/
|
|
77
|
-
async delete() {
|
|
78
|
-
await this.api.requestUrl('DELETE', `/v1/servers/${this.server.id}/sftp/users/${this.id}`, {});
|
|
79
|
-
}
|
|
80
|
-
async setPathPermissions(path, permissions) {
|
|
81
|
-
await this.api.requestUrl('PATCH', `/v1/servers/${this.server.id}/sftp/users/${this.id}`, {
|
|
82
|
-
body: {
|
|
83
|
-
paths: { [path]: permissions },
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.SftpUser = SftpUser;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ServerResponse } from './server_2';
|
|
2
|
-
type ServerStartup = Readonly<ServerResponse['startup'] & object>;
|
|
3
|
-
export declare class StartupParameters {
|
|
4
|
-
constructor(data: ServerStartup);
|
|
5
|
-
readonly command: string;
|
|
6
|
-
readonly variables: Record<Uppercase<string>, CommandVariable>;
|
|
7
|
-
}
|
|
8
|
-
export interface CommandVariable {
|
|
9
|
-
readonly key: string;
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
value: string;
|
|
13
|
-
default: string;
|
|
14
|
-
rules: string;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=startup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"startup.d.ts","sourceRoot":"","sources":["../../../src/components/server/startup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,KAAK,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC;AAElE,qBAAa,iBAAiB;gBACV,IAAI,EAAE,aAAa;IAQtC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACd"}
|