@meowpanel/api 0.3.0 → 0.4.0
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/esm/mod.d.ts +37 -16
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +25 -7
- package/esm/src/client.d.ts +48 -11
- package/esm/src/client.d.ts.map +1 -1
- package/esm/src/client.js +53 -12
- package/esm/src/http.d.ts +2 -2
- package/esm/src/http.d.ts.map +1 -1
- package/esm/src/http.js +5 -2
- package/esm/src/namespace.d.ts +1 -1
- package/esm/src/namespace.js +1 -1
- package/esm/src/resources/account.d.ts +50 -19
- package/esm/src/resources/account.d.ts.map +1 -1
- package/esm/src/resources/account.js +51 -13
- package/esm/src/resources/api-keys.d.ts +16 -24
- package/esm/src/resources/api-keys.d.ts.map +1 -1
- package/esm/src/resources/api-keys.js +16 -20
- package/esm/src/resources/auth.d.ts +70 -4
- package/esm/src/resources/auth.d.ts.map +1 -1
- package/esm/src/resources/auth.js +47 -4
- package/esm/src/resources/eggs.d.ts +261 -22
- package/esm/src/resources/eggs.d.ts.map +1 -1
- package/esm/src/resources/eggs.js +261 -25
- package/esm/src/resources/features.d.ts +35 -0
- package/esm/src/resources/features.d.ts.map +1 -0
- package/esm/src/resources/features.js +21 -0
- package/esm/src/resources/hosts.d.ts +143 -18
- package/esm/src/resources/hosts.d.ts.map +1 -1
- package/esm/src/resources/hosts.js +145 -10
- package/esm/src/resources/logs.d.ts +39 -0
- package/esm/src/resources/logs.d.ts.map +1 -0
- package/esm/src/resources/logs.js +38 -0
- package/esm/src/resources/nodes.d.ts +92 -17
- package/esm/src/resources/nodes.d.ts.map +1 -1
- package/esm/src/resources/nodes.js +108 -16
- package/esm/src/resources/permissions.d.ts +45 -0
- package/esm/src/resources/permissions.d.ts.map +1 -0
- package/esm/src/resources/permissions.js +26 -0
- package/esm/src/resources/request-logs.d.ts +91 -0
- package/esm/src/resources/request-logs.d.ts.map +1 -0
- package/esm/src/resources/request-logs.js +70 -0
- package/esm/src/resources/roles.d.ts +128 -0
- package/esm/src/resources/roles.d.ts.map +1 -0
- package/esm/src/resources/roles.js +142 -0
- package/esm/src/resources/server-groups.d.ts +141 -7
- package/esm/src/resources/server-groups.d.ts.map +1 -1
- package/esm/src/resources/server-groups.js +157 -8
- package/esm/src/resources/servers/activity.d.ts +50 -8
- package/esm/src/resources/servers/activity.d.ts.map +1 -1
- package/esm/src/resources/servers/activity.js +54 -13
- package/esm/src/resources/servers/allocations.d.ts +3 -3
- package/esm/src/resources/servers/allocations.d.ts.map +1 -1
- package/esm/src/resources/servers/allocations.js +7 -7
- package/esm/src/resources/servers/backups.d.ts +46 -0
- package/esm/src/resources/servers/backups.d.ts.map +1 -0
- package/esm/src/resources/servers/backups.js +43 -0
- package/esm/src/resources/servers/connection.d.ts +27 -7
- package/esm/src/resources/servers/connection.d.ts.map +1 -1
- package/esm/src/resources/servers/connection.js +28 -7
- package/esm/src/resources/servers/features.d.ts +81 -0
- package/esm/src/resources/servers/features.d.ts.map +1 -0
- package/esm/src/resources/servers/features.js +60 -0
- package/esm/src/resources/servers/files.d.ts +41 -53
- package/esm/src/resources/servers/files.d.ts.map +1 -1
- package/esm/src/resources/servers/files.js +74 -116
- package/esm/src/resources/servers/index.d.ts +46 -27
- package/esm/src/resources/servers/index.d.ts.map +1 -1
- package/esm/src/resources/servers/index.js +26 -12
- package/esm/src/resources/servers/jobs.d.ts +88 -0
- package/esm/src/resources/servers/jobs.d.ts.map +1 -0
- package/esm/src/resources/servers/jobs.js +115 -0
- package/esm/src/resources/servers/node-client.d.ts +33 -0
- package/esm/src/resources/servers/node-client.d.ts.map +1 -0
- package/esm/src/resources/servers/node-client.js +61 -0
- package/esm/src/resources/servers/profiles.d.ts +45 -1
- package/esm/src/resources/servers/profiles.d.ts.map +1 -1
- package/esm/src/resources/servers/profiles.js +55 -2
- package/esm/src/resources/servers/server.d.ts +10 -25
- package/esm/src/resources/servers/server.d.ts.map +1 -1
- package/esm/src/resources/servers/server.js +18 -34
- package/esm/src/resources/servers/sftp.d.ts +12 -19
- package/esm/src/resources/servers/sftp.d.ts.map +1 -1
- package/esm/src/resources/servers/sftp.js +10 -14
- package/esm/src/resources/servers/sub-users.d.ts +99 -0
- package/esm/src/resources/servers/sub-users.d.ts.map +1 -0
- package/esm/src/resources/servers/sub-users.js +94 -0
- package/esm/src/resources/servers/types.d.ts +27 -25
- package/esm/src/resources/servers/types.d.ts.map +1 -1
- package/esm/src/resources/systems.d.ts +124 -0
- package/esm/src/resources/systems.d.ts.map +1 -0
- package/esm/src/resources/systems.js +139 -0
- package/esm/src/resources/users.d.ts +330 -0
- package/esm/src/resources/users.d.ts.map +1 -0
- package/esm/src/resources/users.js +280 -0
- package/esm/src/types.d.ts +18 -1
- package/esm/src/types.d.ts.map +1 -1
- package/esm/src/types.js +11 -0
- package/package.json +1 -1
- package/script/mod.d.ts +37 -16
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +50 -5
- package/script/src/client.d.ts +48 -11
- package/script/src/client.d.ts.map +1 -1
- package/script/src/client.js +53 -12
- package/script/src/http.d.ts +2 -2
- package/script/src/http.d.ts.map +1 -1
- package/script/src/http.js +5 -2
- package/script/src/namespace.d.ts +1 -1
- package/script/src/namespace.js +1 -1
- package/script/src/resources/account.d.ts +50 -19
- package/script/src/resources/account.d.ts.map +1 -1
- package/script/src/resources/account.js +50 -12
- package/script/src/resources/api-keys.d.ts +16 -24
- package/script/src/resources/api-keys.d.ts.map +1 -1
- package/script/src/resources/api-keys.js +15 -19
- package/script/src/resources/auth.d.ts +70 -4
- package/script/src/resources/auth.d.ts.map +1 -1
- package/script/src/resources/auth.js +47 -4
- package/script/src/resources/eggs.d.ts +261 -22
- package/script/src/resources/eggs.d.ts.map +1 -1
- package/script/src/resources/eggs.js +267 -26
- package/script/src/resources/features.d.ts +35 -0
- package/script/src/resources/features.d.ts.map +1 -0
- package/script/src/resources/features.js +25 -0
- package/script/src/resources/hosts.d.ts +143 -18
- package/script/src/resources/hosts.d.ts.map +1 -1
- package/script/src/resources/hosts.js +146 -10
- package/script/src/resources/logs.d.ts +39 -0
- package/script/src/resources/logs.d.ts.map +1 -0
- package/script/src/resources/logs.js +42 -0
- package/script/src/resources/nodes.d.ts +92 -17
- package/script/src/resources/nodes.d.ts.map +1 -1
- package/script/src/resources/nodes.js +109 -16
- package/script/src/resources/permissions.d.ts +45 -0
- package/script/src/resources/permissions.d.ts.map +1 -0
- package/script/src/resources/permissions.js +31 -0
- package/script/src/resources/request-logs.d.ts +91 -0
- package/script/src/resources/request-logs.d.ts.map +1 -0
- package/script/src/resources/request-logs.js +75 -0
- package/script/src/resources/roles.d.ts +128 -0
- package/script/src/resources/roles.d.ts.map +1 -0
- package/script/src/resources/roles.js +148 -0
- package/script/src/resources/server-groups.d.ts +141 -7
- package/script/src/resources/server-groups.d.ts.map +1 -1
- package/script/src/resources/server-groups.js +158 -8
- package/script/src/resources/servers/activity.d.ts +50 -8
- package/script/src/resources/servers/activity.d.ts.map +1 -1
- package/script/src/resources/servers/activity.js +54 -12
- package/script/src/resources/servers/allocations.d.ts +3 -3
- package/script/src/resources/servers/allocations.d.ts.map +1 -1
- package/script/src/resources/servers/allocations.js +7 -7
- package/script/src/resources/servers/backups.d.ts +46 -0
- package/script/src/resources/servers/backups.d.ts.map +1 -0
- package/script/src/resources/servers/backups.js +47 -0
- package/script/src/resources/servers/connection.d.ts +27 -7
- package/script/src/resources/servers/connection.d.ts.map +1 -1
- package/script/src/resources/servers/connection.js +28 -7
- package/script/src/resources/servers/features.d.ts +81 -0
- package/script/src/resources/servers/features.d.ts.map +1 -0
- package/script/src/resources/servers/features.js +64 -0
- package/script/src/resources/servers/files.d.ts +41 -53
- package/script/src/resources/servers/files.d.ts.map +1 -1
- package/script/src/resources/servers/files.js +74 -116
- package/script/src/resources/servers/index.d.ts +46 -27
- package/script/src/resources/servers/index.d.ts.map +1 -1
- package/script/src/resources/servers/index.js +26 -12
- package/script/src/resources/servers/jobs.d.ts +88 -0
- package/script/src/resources/servers/jobs.d.ts.map +1 -0
- package/script/src/resources/servers/jobs.js +120 -0
- package/script/src/resources/servers/node-client.d.ts +33 -0
- package/script/src/resources/servers/node-client.d.ts.map +1 -0
- package/script/src/resources/servers/node-client.js +65 -0
- package/script/src/resources/servers/profiles.d.ts +45 -1
- package/script/src/resources/servers/profiles.d.ts.map +1 -1
- package/script/src/resources/servers/profiles.js +55 -2
- package/script/src/resources/servers/server.d.ts +10 -25
- package/script/src/resources/servers/server.d.ts.map +1 -1
- package/script/src/resources/servers/server.js +18 -34
- package/script/src/resources/servers/sftp.d.ts +12 -19
- package/script/src/resources/servers/sftp.d.ts.map +1 -1
- package/script/src/resources/servers/sftp.js +10 -14
- package/script/src/resources/servers/sub-users.d.ts +99 -0
- package/script/src/resources/servers/sub-users.d.ts.map +1 -0
- package/script/src/resources/servers/sub-users.js +99 -0
- package/script/src/resources/servers/types.d.ts +27 -25
- package/script/src/resources/servers/types.d.ts.map +1 -1
- package/script/src/resources/systems.d.ts +124 -0
- package/script/src/resources/systems.d.ts.map +1 -0
- package/script/src/resources/systems.js +145 -0
- package/script/src/resources/users.d.ts +330 -0
- package/script/src/resources/users.d.ts.map +1 -0
- package/script/src/resources/users.js +287 -0
- package/script/src/types.d.ts +18 -1
- package/script/src/types.d.ts.map +1 -1
- package/script/src/types.js +12 -0
- package/esm/src/resources/members.d.ts +0 -138
- package/esm/src/resources/members.d.ts.map +0 -1
- package/esm/src/resources/members.js +0 -122
- package/script/src/resources/members.d.ts +0 -138
- package/script/src/resources/members.d.ts.map +0 -1
- package/script/src/resources/members.js +0 -127
|
@@ -2,10 +2,9 @@ import type { HttpClient } from '../../http.js';
|
|
|
2
2
|
import { ResourceNamespace } from '../../namespace.js';
|
|
3
3
|
import type { IncludeOptions, ListOptions, NanoID, Paginated } from '../../types.js';
|
|
4
4
|
import type { ResourceWith } from '../../types.js';
|
|
5
|
-
import type { ServerBuild,
|
|
5
|
+
import type { ServerBuild, ServerStatus } from './server.js';
|
|
6
6
|
import { Server } from './server.js';
|
|
7
7
|
import type { ServerAllocationsData, ServerProfileData, UpdateServerPayload } from './types.js';
|
|
8
|
-
import type { Egg } from '../eggs.js';
|
|
9
8
|
import type { ServerGroup } from '../server-groups.js';
|
|
10
9
|
export type { UpdateServerPayload };
|
|
11
10
|
/**
|
|
@@ -15,7 +14,7 @@ export type { UpdateServerPayload };
|
|
|
15
14
|
* When an include is requested, the corresponding field on {@link Server} is guaranteed
|
|
16
15
|
* to be populated (non-undefined).
|
|
17
16
|
*/
|
|
18
|
-
export type ServerInclude = 'group' | '
|
|
17
|
+
export type ServerInclude = 'group' | 'status' | 'build' | 'allocations' | 'profiles';
|
|
19
18
|
/**
|
|
20
19
|
* Maps each {@link ServerInclude} key to the field(s) it guarantees on the {@link Server} instance.
|
|
21
20
|
*
|
|
@@ -25,18 +24,12 @@ interface ServerIncludeMap {
|
|
|
25
24
|
group: {
|
|
26
25
|
group: ServerGroup;
|
|
27
26
|
};
|
|
28
|
-
egg: {
|
|
29
|
-
egg: Egg;
|
|
30
|
-
};
|
|
31
27
|
status: {
|
|
32
28
|
status: ServerStatus;
|
|
33
29
|
};
|
|
34
30
|
build: {
|
|
35
31
|
build: ServerBuild;
|
|
36
32
|
};
|
|
37
|
-
startup: {
|
|
38
|
-
startup: ServerStartup;
|
|
39
|
-
};
|
|
40
33
|
allocations: {
|
|
41
34
|
allocationPorts: ServerAllocationsData;
|
|
42
35
|
};
|
|
@@ -54,32 +47,49 @@ interface ServerIncludeMap {
|
|
|
54
47
|
* ```
|
|
55
48
|
*/
|
|
56
49
|
export type ServerWith<I extends readonly ServerInclude[] = []> = ResourceWith<Server, ServerIncludeMap, I>;
|
|
57
|
-
/**
|
|
50
|
+
/** Resource limits for a server or server group. */
|
|
51
|
+
export interface ServerLimits {
|
|
52
|
+
ramMb: number;
|
|
53
|
+
swapMb: number;
|
|
54
|
+
storageMb: number;
|
|
55
|
+
/** IO weight (1–1000). */
|
|
56
|
+
weightIo: number;
|
|
57
|
+
cpuPercent: number;
|
|
58
|
+
cpuThreads?: string;
|
|
59
|
+
backup?: number;
|
|
60
|
+
database?: number;
|
|
61
|
+
allocation?: number;
|
|
62
|
+
}
|
|
63
|
+
/** The initial profile (egg binding) created alongside a server. */
|
|
64
|
+
export interface CreateServerProfile {
|
|
65
|
+
name: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
notes?: string;
|
|
68
|
+
eggId: NanoID;
|
|
69
|
+
eggImageId: NanoID;
|
|
70
|
+
eggImageOverride?: string;
|
|
71
|
+
startupCommandOverride?: string;
|
|
72
|
+
skipInstallScripts?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/** Payload for creating a new server (also creates its server group). */
|
|
58
75
|
export interface CreateServerPayload {
|
|
59
76
|
name: string;
|
|
60
77
|
nodeId: NanoID;
|
|
78
|
+
/** Owner issuer reference, e.g. `"user:<id>"` or a bare id. Defaults to the caller. */
|
|
79
|
+
ownerId?: string;
|
|
61
80
|
description?: string;
|
|
62
81
|
notes?: string;
|
|
63
|
-
limits:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
weightIo: number;
|
|
69
|
-
cpuPercent: number;
|
|
70
|
-
cpuThreads?: string;
|
|
71
|
-
backup?: number;
|
|
72
|
-
database?: number;
|
|
73
|
-
allocation?: number;
|
|
82
|
+
limits: ServerLimits;
|
|
83
|
+
/** Primary allocation to bind, by IP and port. */
|
|
84
|
+
allocation: {
|
|
85
|
+
ip: string;
|
|
86
|
+
port: number;
|
|
74
87
|
};
|
|
75
|
-
eggId: NanoID;
|
|
76
|
-
allocationPrimaryId: NanoID;
|
|
77
|
-
imageOverride?: string;
|
|
78
88
|
forceOutgoingIp?: boolean;
|
|
79
89
|
oomType?: 'docker';
|
|
80
|
-
shouldSkipEggScripts?: boolean;
|
|
81
|
-
startupCommandOverride?: string;
|
|
82
90
|
expiresAt?: Date;
|
|
91
|
+
/** The server's initial profile. Omit to create the server without one. */
|
|
92
|
+
profile?: CreateServerProfile;
|
|
83
93
|
}
|
|
84
94
|
export interface ServerEvents {
|
|
85
95
|
created: Server;
|
|
@@ -120,7 +130,16 @@ export declare class ServersNamespace extends ResourceNamespace<Server, ServerEv
|
|
|
120
130
|
get<const I extends readonly ServerInclude[] = []>(id: NanoID, opts?: IncludeOptions<ServerInclude, I>): Promise<ServerWith<I>>;
|
|
121
131
|
/** Create a new server (also creates its server group). */
|
|
122
132
|
create(payload: CreateServerPayload): Promise<Server>;
|
|
123
|
-
/** Update a server's details
|
|
133
|
+
/** Update a server's details or primary allocation. */
|
|
124
134
|
update(id: NanoID, payload: UpdateServerPayload): Promise<Server>;
|
|
135
|
+
/**
|
|
136
|
+
* Delete a server.
|
|
137
|
+
*
|
|
138
|
+
* @param id The server's NanoID.
|
|
139
|
+
* @param opts `force: true` deletes even when the node cannot be reached to clean up.
|
|
140
|
+
*/
|
|
141
|
+
delete(id: NanoID, opts?: {
|
|
142
|
+
force?: boolean;
|
|
143
|
+
}): Promise<void>;
|
|
125
144
|
}
|
|
126
145
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO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;GAoBG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,MAAM,EAAE,YAAY,CAAC;IAC5E,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAE1D,gBAAgB;gBACG,IAAI,EAAE,UAAU;IAInC,2EAA2E;IAC3E,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,UAAU;IAMlB,yCAAyC;IAC5B,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,EAAE,EAC9D,IAAI,GAAE,WAAW,GAAG,cAAc,CAAC,aAAa,EAAE,CAAC,CAAwD,GACzG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAWpC,mCAAmC;IACtB,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,EAAE,EAC7D,EAAE,EAAE,MAAM,EACV,IAAI,GAAE,cAAc,CAAC,aAAa,EAAE,CAAC,CAAM,GACzC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAQzB,2DAA2D;IAC9C,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IA0ClE,uDAAuD;IAC1C,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB9E;;;;;OAKG;IACU,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAK9E"}
|
|
@@ -77,6 +77,7 @@ class ServersNamespace extends namespace_js_1.ResourceNamespace {
|
|
|
77
77
|
const body = {
|
|
78
78
|
name: payload.name,
|
|
79
79
|
node_id: payload.nodeId,
|
|
80
|
+
owner_id: payload.ownerId,
|
|
80
81
|
description: payload.description,
|
|
81
82
|
notes: payload.notes,
|
|
82
83
|
limits: {
|
|
@@ -90,22 +91,30 @@ class ServersNamespace extends namespace_js_1.ResourceNamespace {
|
|
|
90
91
|
database: payload.limits.database,
|
|
91
92
|
allocation: payload.limits.allocation,
|
|
92
93
|
},
|
|
93
|
-
|
|
94
|
-
allocation_primary_id: payload.allocationPrimaryId,
|
|
95
|
-
image_override: payload.imageOverride,
|
|
94
|
+
allocation: payload.allocation,
|
|
96
95
|
force_outgoing_ip: payload.forceOutgoingIp,
|
|
97
96
|
oom_type: payload.oomType,
|
|
98
|
-
should_skip_egg_scripts: payload.shouldSkipEggScripts,
|
|
99
|
-
startup_command_override: payload.startupCommandOverride,
|
|
100
97
|
expires_at: payload.expiresAt,
|
|
101
98
|
};
|
|
99
|
+
if (payload.profile) {
|
|
100
|
+
body['profile'] = {
|
|
101
|
+
name: payload.profile.name,
|
|
102
|
+
description: payload.profile.description,
|
|
103
|
+
notes: payload.profile.notes,
|
|
104
|
+
egg_id: payload.profile.eggId,
|
|
105
|
+
egg_image_id: payload.profile.eggImageId,
|
|
106
|
+
egg_image_override: payload.profile.eggImageOverride,
|
|
107
|
+
startup_command_override: payload.profile.startupCommandOverride,
|
|
108
|
+
skip_install_scripts: payload.profile.skipInstallScripts,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
102
111
|
const data = await this.http.post('/servers', body);
|
|
103
112
|
const server = this.makeServer(data);
|
|
104
113
|
this.addToCache(server);
|
|
105
114
|
this.emit('created', server);
|
|
106
115
|
return server;
|
|
107
116
|
}
|
|
108
|
-
/** Update a server's details
|
|
117
|
+
/** Update a server's details or primary allocation. */
|
|
109
118
|
async update(id, payload) {
|
|
110
119
|
const body = {};
|
|
111
120
|
if (payload.name !== undefined)
|
|
@@ -116,12 +125,6 @@ class ServersNamespace extends namespace_js_1.ResourceNamespace {
|
|
|
116
125
|
body['notes'] = payload.notes;
|
|
117
126
|
if (payload.allocationPrimary)
|
|
118
127
|
body['allocation_primary'] = payload.allocationPrimary;
|
|
119
|
-
if (payload.startup) {
|
|
120
|
-
body['startup'] = {
|
|
121
|
-
command: payload.startup.command,
|
|
122
|
-
variables: payload.startup.variables,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
128
|
const data = await this.http.patch(`/servers/${id}`, body);
|
|
126
129
|
const existing = this.cache.find((s) => s.id === id);
|
|
127
130
|
if (existing) {
|
|
@@ -135,5 +138,16 @@ class ServersNamespace extends namespace_js_1.ResourceNamespace {
|
|
|
135
138
|
this.emit('updated', server);
|
|
136
139
|
return server;
|
|
137
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Delete a server.
|
|
143
|
+
*
|
|
144
|
+
* @param id The server's NanoID.
|
|
145
|
+
* @param opts `force: true` deletes even when the node cannot be reached to clean up.
|
|
146
|
+
*/
|
|
147
|
+
async delete(id, opts = {}) {
|
|
148
|
+
await this.http.delete(`/servers/${id}`, opts.force ? { params: { force: 'true' } } : {});
|
|
149
|
+
this.removeFromCache(id);
|
|
150
|
+
this.emit('deleted', id);
|
|
151
|
+
}
|
|
138
152
|
}
|
|
139
153
|
exports.ServersNamespace = ServersNamespace;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ISODate } from '../../types.js';
|
|
2
|
+
import type { NodeClient } from './node-client.js';
|
|
3
|
+
/** Lifecycle state of a daemon job. */
|
|
4
|
+
export type JobStatus = 'running' | 'completed' | 'failed' | 'canceled';
|
|
5
|
+
/** Raw job shape returned by the daemon. @internal */
|
|
6
|
+
export interface JobData {
|
|
7
|
+
id: string;
|
|
8
|
+
server_id: string;
|
|
9
|
+
type: string;
|
|
10
|
+
status: JobStatus;
|
|
11
|
+
progress: number;
|
|
12
|
+
message: string;
|
|
13
|
+
error?: string;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
created_at: ISODate;
|
|
16
|
+
updated_at: ISODate;
|
|
17
|
+
}
|
|
18
|
+
/** Options for {@link ServerJob.wait}. */
|
|
19
|
+
export interface JobWaitOptions {
|
|
20
|
+
/** Poll interval in milliseconds. Defaults to 1000. */
|
|
21
|
+
intervalMs?: number;
|
|
22
|
+
/** Reject after this many milliseconds. Unlimited by default. */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
/** Abort the wait early. */
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A tracked long-running operation on a server's node daemon (compress, decompress,
|
|
29
|
+
* backup, restore, install).
|
|
30
|
+
*
|
|
31
|
+
* Returned by the async file/backup operations (on the `202` path) and by
|
|
32
|
+
* {@link ServerJobsManager}. Note the daemon only reports `message`, not fine-grained
|
|
33
|
+
* `progress`, for these ops, so `progress` stays `0` until completion. Poll on
|
|
34
|
+
* {@link status} via {@link wait}, not on `progress`.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ServerJob {
|
|
37
|
+
private readonly node;
|
|
38
|
+
readonly id: string;
|
|
39
|
+
type: string;
|
|
40
|
+
status: JobStatus;
|
|
41
|
+
progress: number;
|
|
42
|
+
message: string;
|
|
43
|
+
/** Populated when {@link status} is `failed`. */
|
|
44
|
+
error: string | undefined;
|
|
45
|
+
metadata: Record<string, unknown> | undefined;
|
|
46
|
+
createdAt: Date | undefined;
|
|
47
|
+
updatedAt: Date | undefined;
|
|
48
|
+
/** @internal */
|
|
49
|
+
constructor(data: JobData | {
|
|
50
|
+
id: string;
|
|
51
|
+
}, node: NodeClient);
|
|
52
|
+
private apply;
|
|
53
|
+
/** `true` once the job has left the `running` state. */
|
|
54
|
+
get isDone(): boolean;
|
|
55
|
+
/** Re-fetch this job's current state from the daemon. */
|
|
56
|
+
refresh(): Promise<this>;
|
|
57
|
+
/** Fetch the job's stored log output as plain text. */
|
|
58
|
+
getLog(): Promise<string>;
|
|
59
|
+
/** Request cancellation. Resolves even if the job has already finished. */
|
|
60
|
+
cancel(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Poll until the job leaves the `running` state. Resolves with this job; inspect
|
|
63
|
+
* {@link status} and {@link error} to tell completion from failure/cancellation.
|
|
64
|
+
*/
|
|
65
|
+
wait(opts?: JobWaitOptions): Promise<this>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Lists and tracks a server's daemon jobs.
|
|
69
|
+
*
|
|
70
|
+
* Access via `server.jobs`.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts ignore
|
|
74
|
+
* const jobs = await server.jobs.list();
|
|
75
|
+
* const job = await server.jobs.get(id);
|
|
76
|
+
* await job.wait();
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare class ServerJobsManager {
|
|
80
|
+
private readonly node;
|
|
81
|
+
/** @internal */
|
|
82
|
+
constructor(node: NodeClient);
|
|
83
|
+
/** List the server's jobs, most recent first (includes finished history). */
|
|
84
|
+
list(): Promise<ServerJob[]>;
|
|
85
|
+
/** Fetch a single job by id. */
|
|
86
|
+
get(id: string): Promise<ServerJob>;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=jobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/jobs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,uCAAuC;AACvC,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;AAExE,sDAAsD;AACtD,MAAM,WAAW,OAAO;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,O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,gBAAgB;gBACoB,IAAI,EAAE,UAAU;IAEpD,6EAA6E;IAChE,IAAI,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAMzC,gCAAgC;IACnB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAIhD"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServerJobsManager = exports.ServerJob = void 0;
|
|
4
|
+
const errors_js_1 = require("../../errors.js");
|
|
5
|
+
/**
|
|
6
|
+
* A tracked long-running operation on a server's node daemon (compress, decompress,
|
|
7
|
+
* backup, restore, install).
|
|
8
|
+
*
|
|
9
|
+
* Returned by the async file/backup operations (on the `202` path) and by
|
|
10
|
+
* {@link ServerJobsManager}. Note the daemon only reports `message`, not fine-grained
|
|
11
|
+
* `progress`, for these ops, so `progress` stays `0` until completion. Poll on
|
|
12
|
+
* {@link status} via {@link wait}, not on `progress`.
|
|
13
|
+
*/
|
|
14
|
+
class ServerJob {
|
|
15
|
+
node;
|
|
16
|
+
id;
|
|
17
|
+
type = '';
|
|
18
|
+
status = 'running';
|
|
19
|
+
progress = 0;
|
|
20
|
+
message = '';
|
|
21
|
+
/** Populated when {@link status} is `failed`. */
|
|
22
|
+
error;
|
|
23
|
+
metadata;
|
|
24
|
+
createdAt;
|
|
25
|
+
updatedAt;
|
|
26
|
+
/** @internal */
|
|
27
|
+
constructor(data, node) {
|
|
28
|
+
this.node = node;
|
|
29
|
+
this.id = data.id;
|
|
30
|
+
if ('status' in data)
|
|
31
|
+
this.apply(data);
|
|
32
|
+
}
|
|
33
|
+
apply(data) {
|
|
34
|
+
this.type = data.type;
|
|
35
|
+
this.status = data.status;
|
|
36
|
+
this.progress = data.progress;
|
|
37
|
+
this.message = data.message;
|
|
38
|
+
this.error = data.error;
|
|
39
|
+
this.metadata = data.metadata;
|
|
40
|
+
this.createdAt = new Date(data.created_at);
|
|
41
|
+
this.updatedAt = new Date(data.updated_at);
|
|
42
|
+
}
|
|
43
|
+
/** `true` once the job has left the `running` state. */
|
|
44
|
+
get isDone() {
|
|
45
|
+
return this.status !== 'running';
|
|
46
|
+
}
|
|
47
|
+
/** Re-fetch this job's current state from the daemon. */
|
|
48
|
+
async refresh() {
|
|
49
|
+
const res = await this.node.fetch(`/jobs/${this.id}`);
|
|
50
|
+
this.apply(await res.json());
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/** Fetch the job's stored log output as plain text. */
|
|
54
|
+
async getLog() {
|
|
55
|
+
const res = await this.node.fetch(`/jobs/${this.id}/log`);
|
|
56
|
+
return res.text();
|
|
57
|
+
}
|
|
58
|
+
/** Request cancellation. Resolves even if the job has already finished. */
|
|
59
|
+
async cancel() {
|
|
60
|
+
try {
|
|
61
|
+
await this.node.fetch(`/jobs/${this.id}`, { method: 'DELETE' });
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
// 409 means the job is no longer running, which is the state we wanted.
|
|
65
|
+
if (err instanceof errors_js_1.ApiError && err.status === 409)
|
|
66
|
+
return;
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Poll until the job leaves the `running` state. Resolves with this job; inspect
|
|
72
|
+
* {@link status} and {@link error} to tell completion from failure/cancellation.
|
|
73
|
+
*/
|
|
74
|
+
async wait(opts = {}) {
|
|
75
|
+
const interval = opts.intervalMs ?? 1000;
|
|
76
|
+
const deadline = opts.timeoutMs !== undefined ? Date.now() + opts.timeoutMs : undefined;
|
|
77
|
+
while (this.status === 'running') {
|
|
78
|
+
if (opts.signal?.aborted)
|
|
79
|
+
throw new DOMException('Job wait aborted', 'AbortError');
|
|
80
|
+
if (deadline !== undefined && Date.now() >= deadline) {
|
|
81
|
+
throw new Error(`Timed out waiting for job ${this.id}`);
|
|
82
|
+
}
|
|
83
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
84
|
+
await this.refresh();
|
|
85
|
+
}
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.ServerJob = ServerJob;
|
|
90
|
+
/**
|
|
91
|
+
* Lists and tracks a server's daemon jobs.
|
|
92
|
+
*
|
|
93
|
+
* Access via `server.jobs`.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts ignore
|
|
97
|
+
* const jobs = await server.jobs.list();
|
|
98
|
+
* const job = await server.jobs.get(id);
|
|
99
|
+
* await job.wait();
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
class ServerJobsManager {
|
|
103
|
+
node;
|
|
104
|
+
/** @internal */
|
|
105
|
+
constructor(node) {
|
|
106
|
+
this.node = node;
|
|
107
|
+
}
|
|
108
|
+
/** List the server's jobs, most recent first (includes finished history). */
|
|
109
|
+
async list() {
|
|
110
|
+
const res = await this.node.fetch('/jobs');
|
|
111
|
+
const data = await res.json();
|
|
112
|
+
return data.map((d) => new ServerJob(d, this.node));
|
|
113
|
+
}
|
|
114
|
+
/** Fetch a single job by id. */
|
|
115
|
+
async get(id) {
|
|
116
|
+
const res = await this.node.fetch(`/jobs/${id}`);
|
|
117
|
+
return new ServerJob(await res.json(), this.node);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.ServerJobsManager = ServerJobsManager;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { NanoID } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Transport for direct calls to a server's Whisker node daemon.
|
|
4
|
+
*
|
|
5
|
+
* File operations, backups, jobs, and the live connection all bypass Nexus and talk
|
|
6
|
+
* to the node that hosts the server. The node URL is resolved lazily on first use and
|
|
7
|
+
* cached. All requests carry the scoped bearer token and throw {@link ApiError} on
|
|
8
|
+
* non-2xx responses.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare class NodeClient {
|
|
13
|
+
private readonly serverId;
|
|
14
|
+
private readonly token;
|
|
15
|
+
private readonly resolveNodeUrl;
|
|
16
|
+
private nodeUrl?;
|
|
17
|
+
constructor(serverId: NanoID, token: string, resolveNodeUrl: () => Promise<string>);
|
|
18
|
+
/** Base URL for this server on its node, e.g. `https://node:8080/api/servers/<id>`. */
|
|
19
|
+
private base;
|
|
20
|
+
/**
|
|
21
|
+
* Perform a request against the server's node daemon.
|
|
22
|
+
*
|
|
23
|
+
* @param endpoint Path under the server base, e.g. `/files/compress` or `/jobs`.
|
|
24
|
+
* @param init Standard `RequestInit`; the bearer header is added automatically.
|
|
25
|
+
*/
|
|
26
|
+
fetch(endpoint: string, init?: RequestInit): Promise<Response>;
|
|
27
|
+
/** Shorthand for a JSON POST that returns the parsed body. */
|
|
28
|
+
postJson<T>(endpoint: string, body: unknown): Promise<{
|
|
29
|
+
status: number;
|
|
30
|
+
data: T;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=node-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/node-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;;;GASG;AACH,qBAAa,UAAU;IAIrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,cAAc;IALhC,OAAO,CAAC,OAAO,CAAC,CAAS;gBAGP,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC;IAGvD,uFAAuF;YACzE,IAAI;IAKlB;;;;;OAKG;IACU,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiB/E,8DAA8D;IACjD,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC;CAQ/F"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeClient = void 0;
|
|
4
|
+
const errors_js_1 = require("../../errors.js");
|
|
5
|
+
/**
|
|
6
|
+
* Transport for direct calls to a server's Whisker node daemon.
|
|
7
|
+
*
|
|
8
|
+
* File operations, backups, jobs, and the live connection all bypass Nexus and talk
|
|
9
|
+
* to the node that hosts the server. The node URL is resolved lazily on first use and
|
|
10
|
+
* cached. All requests carry the scoped bearer token and throw {@link ApiError} on
|
|
11
|
+
* non-2xx responses.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
class NodeClient {
|
|
16
|
+
serverId;
|
|
17
|
+
token;
|
|
18
|
+
resolveNodeUrl;
|
|
19
|
+
nodeUrl;
|
|
20
|
+
constructor(serverId, token, resolveNodeUrl) {
|
|
21
|
+
this.serverId = serverId;
|
|
22
|
+
this.token = token;
|
|
23
|
+
this.resolveNodeUrl = resolveNodeUrl;
|
|
24
|
+
}
|
|
25
|
+
/** Base URL for this server on its node, e.g. `https://node:8080/api/servers/<id>`. */
|
|
26
|
+
async base() {
|
|
27
|
+
if (!this.nodeUrl)
|
|
28
|
+
this.nodeUrl = await this.resolveNodeUrl();
|
|
29
|
+
return `${this.nodeUrl}/api/servers/${this.serverId}`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Perform a request against the server's node daemon.
|
|
33
|
+
*
|
|
34
|
+
* @param endpoint Path under the server base, e.g. `/files/compress` or `/jobs`.
|
|
35
|
+
* @param init Standard `RequestInit`; the bearer header is added automatically.
|
|
36
|
+
*/
|
|
37
|
+
async fetch(endpoint, init = {}) {
|
|
38
|
+
const url = (await this.base()) + endpoint;
|
|
39
|
+
const res = await globalThis.fetch(url, {
|
|
40
|
+
...init,
|
|
41
|
+
headers: { 'Authorization': `Bearer ${this.token}`, ...init.headers },
|
|
42
|
+
});
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
let message = `HTTP ${res.status}`;
|
|
45
|
+
try {
|
|
46
|
+
const body = await res.json();
|
|
47
|
+
if (typeof body.error === 'string')
|
|
48
|
+
message = body.error;
|
|
49
|
+
}
|
|
50
|
+
catch { /* ignore non-JSON error bodies */ }
|
|
51
|
+
throw new errors_js_1.ApiError({ message, status: res.status });
|
|
52
|
+
}
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
55
|
+
/** Shorthand for a JSON POST that returns the parsed body. */
|
|
56
|
+
async postJson(endpoint, body) {
|
|
57
|
+
const res = await this.fetch(endpoint, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
body: JSON.stringify(body),
|
|
60
|
+
headers: { 'Content-Type': 'application/json' },
|
|
61
|
+
});
|
|
62
|
+
return { status: res.status, data: (res.status === 204 ? undefined : await res.json()) };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.NodeClient = NodeClient;
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import type { HttpClient } from '../../http.js';
|
|
2
2
|
import { ReactiveResource } from '../../reactive.js';
|
|
3
3
|
import type { ListOptions, NanoID, Paginated } from '../../types.js';
|
|
4
|
+
import { Egg } from '../eggs.js';
|
|
4
5
|
import type { ServerProfileData } from './types.js';
|
|
6
|
+
/** An egg environment variable configured for a profile. */
|
|
7
|
+
export interface StartupVariable {
|
|
8
|
+
key: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
value: string;
|
|
12
|
+
default: string;
|
|
13
|
+
/** Laravel validation rules, e.g. `"required|numeric|min:1"`. */
|
|
14
|
+
rules: string;
|
|
15
|
+
}
|
|
16
|
+
/** Startup command and egg variables. Populated via `include=startup`. */
|
|
17
|
+
export interface ServerStartup {
|
|
18
|
+
command: string;
|
|
19
|
+
variables: Record<string, StartupVariable>;
|
|
20
|
+
}
|
|
5
21
|
/**
|
|
6
22
|
* A named configuration profile for a server.
|
|
7
23
|
*
|
|
@@ -21,6 +37,18 @@ export declare class ServerProfile extends ReactiveResource {
|
|
|
21
37
|
description: string | null;
|
|
22
38
|
/** Internal notes for this profile. */
|
|
23
39
|
notes: string | null | undefined;
|
|
40
|
+
/** The egg this profile runs. Requires `server.egg.read`. */
|
|
41
|
+
eggId: NanoID | undefined;
|
|
42
|
+
/** Populated with `include=egg`. */
|
|
43
|
+
egg: Egg | undefined;
|
|
44
|
+
/** The egg image (Docker image) id this profile uses. */
|
|
45
|
+
eggImageId: NanoID | undefined;
|
|
46
|
+
/** A custom Docker image overriding the egg's default. */
|
|
47
|
+
eggImageOverride: string | null | undefined;
|
|
48
|
+
/** Whether the egg install scripts are skipped for this profile. */
|
|
49
|
+
skipInstallScripts: boolean | undefined;
|
|
50
|
+
/** Startup command and variables. Populated with `include=startup`. */
|
|
51
|
+
startup: ServerStartup | undefined;
|
|
24
52
|
/** The folder name used to store this profile's files on disk. */
|
|
25
53
|
folder: string | null | undefined;
|
|
26
54
|
/** `true` if this is the currently active profile for the server. */
|
|
@@ -100,7 +128,7 @@ export declare class ServerProfilesManager {
|
|
|
100
128
|
*/
|
|
101
129
|
get(profileId: NanoID): Promise<ServerProfile>;
|
|
102
130
|
/**
|
|
103
|
-
* Create a new profile for this server.
|
|
131
|
+
* Create a new profile for this server. A profile binds an egg and image.
|
|
104
132
|
*
|
|
105
133
|
* @param payload Profile creation parameters.
|
|
106
134
|
*/
|
|
@@ -108,6 +136,22 @@ export declare class ServerProfilesManager {
|
|
|
108
136
|
name: string;
|
|
109
137
|
description?: string;
|
|
110
138
|
notes?: string;
|
|
139
|
+
eggId: NanoID;
|
|
140
|
+
eggImageId: NanoID;
|
|
141
|
+
eggImageOverride?: string;
|
|
142
|
+
startupCommandOverride?: string;
|
|
143
|
+
skipInstallScripts?: boolean;
|
|
144
|
+
}): Promise<ServerProfile>;
|
|
145
|
+
/**
|
|
146
|
+
* Change a profile's egg, reselecting a valid image and re-basing its variables.
|
|
147
|
+
*
|
|
148
|
+
* @param profileId The profile's NanoID.
|
|
149
|
+
* @param eggId The egg to switch to.
|
|
150
|
+
* @param opts `keep: true` carries over all compatible variable overrides;
|
|
151
|
+
* an array keeps only the named variables.
|
|
152
|
+
*/
|
|
153
|
+
changeEgg(profileId: NanoID, eggId: NanoID, opts?: {
|
|
154
|
+
keep?: boolean | string[];
|
|
111
155
|
}): Promise<ServerProfile>;
|
|
112
156
|
/**
|
|
113
157
|
* Update a profile's name, description, or notes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,YAAY,CAAC;AAEzE,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC/B,GA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