@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
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import { ResourceNamespace } from '../namespace.js';
|
|
3
|
+
import { ReactiveResource } from '../reactive.js';
|
|
4
|
+
import type { IncludeOptions, ResourceWith } from '../types.js';
|
|
5
|
+
import { type ISODate, type NanoID, type Paginated } from '../types.js';
|
|
6
|
+
/** Raw API shape for an egg nest (category). @internal */
|
|
7
|
+
export interface EggNestData {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
/** Raw API shape for an egg installer. @internal */
|
|
12
|
+
export interface EggInstallerData {
|
|
13
|
+
image: string | null;
|
|
14
|
+
entry_command: string | null;
|
|
15
|
+
script: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** Raw API shape for an egg image. @internal */
|
|
18
|
+
export interface EggImageData {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
image: string;
|
|
22
|
+
created_at: ISODate;
|
|
23
|
+
updated_at: ISODate;
|
|
24
|
+
}
|
|
25
|
+
/** Raw API shape for egg process configuration. @internal */
|
|
26
|
+
interface EggProcessData {
|
|
27
|
+
startup: Record<string, unknown>;
|
|
28
|
+
stop: {
|
|
29
|
+
type: 'signal' | 'command';
|
|
30
|
+
value: string;
|
|
31
|
+
};
|
|
32
|
+
logs: Record<string, unknown>;
|
|
33
|
+
files: unknown[];
|
|
34
|
+
file_blacklist_regex: string;
|
|
35
|
+
}
|
|
36
|
+
/** Raw API shape for an egg. @internal */
|
|
37
|
+
export interface EggData {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string | null;
|
|
41
|
+
nest?: EggNestData | null;
|
|
42
|
+
startup_command: string;
|
|
43
|
+
stop_command: string;
|
|
44
|
+
force_outgoing_ip: boolean;
|
|
45
|
+
installer?: EggInstallerData | null;
|
|
46
|
+
process?: EggProcessData | null;
|
|
47
|
+
images?: EggImageData[];
|
|
48
|
+
created_at: ISODate;
|
|
49
|
+
updated_at: ISODate;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A category (nest) that groups related eggs.
|
|
53
|
+
*/
|
|
54
|
+
export declare class EggNest extends ReactiveResource {
|
|
55
|
+
/** Unique NanoID of this nest. */
|
|
56
|
+
readonly id: NanoID;
|
|
57
|
+
/** Display name of the nest, e.g. `"Minecraft"`. */
|
|
58
|
+
name: string;
|
|
59
|
+
/** @internal */
|
|
60
|
+
constructor(data: EggNestData);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* An egg image (Docker image variant) associated with an egg.
|
|
64
|
+
*/
|
|
65
|
+
export interface EggImage {
|
|
66
|
+
/** The egg image's unique NanoID. */
|
|
67
|
+
id: NanoID;
|
|
68
|
+
/** Display name of this image variant. */
|
|
69
|
+
name: string;
|
|
70
|
+
/** Docker image reference, e.g. `"ghcr.io/parkervcp/yolks:java_21"`. */
|
|
71
|
+
image: string;
|
|
72
|
+
/** When this image was created. */
|
|
73
|
+
createdAt: Date;
|
|
74
|
+
/** When this image was last updated. */
|
|
75
|
+
updatedAt: Date;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Process configuration for an egg (startup, stop, logging).
|
|
79
|
+
*/
|
|
80
|
+
export interface EggProcess {
|
|
81
|
+
/** Startup configuration. */
|
|
82
|
+
startup: Record<string, unknown>;
|
|
83
|
+
/** Stop configuration. */
|
|
84
|
+
stop: {
|
|
85
|
+
type: 'signal' | 'command';
|
|
86
|
+
value: string;
|
|
87
|
+
};
|
|
88
|
+
/** Log configuration. */
|
|
89
|
+
logs: Record<string, unknown>;
|
|
90
|
+
/** File configuration. */
|
|
91
|
+
files: unknown[];
|
|
92
|
+
/** Regex pattern for blacklisted files. */
|
|
93
|
+
fileBlacklistRegex: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The installation script configuration for an egg.
|
|
97
|
+
*/
|
|
98
|
+
export interface EggInstaller {
|
|
99
|
+
/** Docker image used to run the installer script. */
|
|
100
|
+
image: string | null;
|
|
101
|
+
/** Entry command for the installer container. */
|
|
102
|
+
entryCommand: string | null;
|
|
103
|
+
/** The install script content. */
|
|
104
|
+
script: string | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* An egg - a game or application configuration template that defines how a server
|
|
108
|
+
* is installed, started, and stopped.
|
|
109
|
+
*
|
|
110
|
+
* Retrieved via {@link EggsNamespace.get} or {@link EggsNamespace.list}.
|
|
111
|
+
*/
|
|
112
|
+
export declare class Egg extends ReactiveResource {
|
|
113
|
+
/** The egg's unique NanoID. */
|
|
114
|
+
readonly id: NanoID;
|
|
115
|
+
/** Display name of the egg, e.g. `"Vanilla Minecraft"`. */
|
|
116
|
+
name: string;
|
|
117
|
+
/** Description of the egg. */
|
|
118
|
+
description: string | null;
|
|
119
|
+
/** The nest (category) this egg belongs to. */
|
|
120
|
+
nest: EggNest | null | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* The startup command template, e.g.
|
|
123
|
+
* `"java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}"`.
|
|
124
|
+
*/
|
|
125
|
+
startupCommand: string;
|
|
126
|
+
/**
|
|
127
|
+
* The stop command sent to the server to shut it down gracefully,
|
|
128
|
+
* e.g. `"stop"` or `"^C"`.
|
|
129
|
+
*/
|
|
130
|
+
stopCommand: string;
|
|
131
|
+
/** When `true`, the server's outgoing IP is forced to match the allocation IP. */
|
|
132
|
+
forceOutgoingIp: boolean;
|
|
133
|
+
/** Installer configuration for this egg. */
|
|
134
|
+
installer: EggInstaller | null | undefined;
|
|
135
|
+
/** Process configuration (startup, stop, logging). */
|
|
136
|
+
process: EggProcess | null | undefined;
|
|
137
|
+
/** Docker image variants for this egg. */
|
|
138
|
+
images: EggImage[] | undefined;
|
|
139
|
+
/** When this egg was created. */
|
|
140
|
+
createdAt: Date;
|
|
141
|
+
/** When this egg was last updated. */
|
|
142
|
+
updatedAt: Date;
|
|
143
|
+
/** @internal */
|
|
144
|
+
constructor(data: EggData);
|
|
145
|
+
}
|
|
146
|
+
/** Fields that can be updated on an egg. All fields are optional. */
|
|
147
|
+
export interface UpdateEggPayload {
|
|
148
|
+
/** New display name. */
|
|
149
|
+
name?: string;
|
|
150
|
+
/** New description. */
|
|
151
|
+
description?: string;
|
|
152
|
+
/** NanoID of a different nest to move the egg to. */
|
|
153
|
+
nestId?: NanoID;
|
|
154
|
+
/** New startup command template. */
|
|
155
|
+
startupCommand?: string;
|
|
156
|
+
/** New stop command. */
|
|
157
|
+
stopCommand?: string;
|
|
158
|
+
/** Update `force_outgoing_ip` setting. */
|
|
159
|
+
forceOutgoingIp?: boolean;
|
|
160
|
+
/** Installer configuration updates. */
|
|
161
|
+
installer?: {
|
|
162
|
+
image?: string;
|
|
163
|
+
entryCommand?: string;
|
|
164
|
+
script?: string;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/** Valid include keys for egg endpoints. */
|
|
168
|
+
export type EggInclude = 'installer' | 'process' | 'images';
|
|
169
|
+
/** Maps each {@link EggInclude} key to the field(s) it guarantees on the {@link Egg} instance. */
|
|
170
|
+
interface EggIncludeMap {
|
|
171
|
+
installer: {
|
|
172
|
+
installer: EggInstaller | null;
|
|
173
|
+
};
|
|
174
|
+
process: {
|
|
175
|
+
process: EggProcess | null;
|
|
176
|
+
};
|
|
177
|
+
images: {
|
|
178
|
+
images: EggImageData[];
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/** A {@link Egg} with specific include fields guaranteed to be populated. */
|
|
182
|
+
export type EggWith<I extends readonly EggInclude[] = []> = ResourceWith<Egg, EggIncludeMap, I>;
|
|
183
|
+
/** Typed events emitted by {@link EggsNamespace}. */
|
|
184
|
+
export interface EggEvents {
|
|
185
|
+
/** Fired after an egg is successfully updated. */
|
|
186
|
+
updated: Egg;
|
|
187
|
+
/** Fired after an egg is deleted. Payload is the deleted egg's NanoID. */
|
|
188
|
+
deleted: NanoID;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Namespace for egg management.
|
|
192
|
+
*
|
|
193
|
+
* Access via `api.eggs`.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts ignore
|
|
197
|
+
* const eggs = await api.eggs.list();
|
|
198
|
+
* const egg = await api.eggs.get(id);
|
|
199
|
+
* await api.eggs.update(id, { name: 'Paper Minecraft' });
|
|
200
|
+
* await api.eggs.delete(id);
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export declare class EggsNamespace extends ResourceNamespace<Egg, EggEvents> {
|
|
204
|
+
/** @internal */
|
|
205
|
+
constructor(http: HttpClient);
|
|
206
|
+
/**
|
|
207
|
+
* Fetch a paginated list of eggs.
|
|
208
|
+
*
|
|
209
|
+
* @param opts Pagination, search, and include options.
|
|
210
|
+
*/
|
|
211
|
+
list<const I extends readonly EggInclude[] = []>(opts?: {
|
|
212
|
+
page?: number;
|
|
213
|
+
perPage?: number;
|
|
214
|
+
search?: string;
|
|
215
|
+
} & IncludeOptions<EggInclude, I>): Promise<Paginated<EggWith<I>>>;
|
|
216
|
+
/**
|
|
217
|
+
* Fetch a single egg by ID.
|
|
218
|
+
*
|
|
219
|
+
* @param id The egg's NanoID.
|
|
220
|
+
* @param opts Include options.
|
|
221
|
+
*/
|
|
222
|
+
get<const I extends readonly EggInclude[] = []>(id: NanoID, opts?: IncludeOptions<EggInclude, I>): Promise<EggWith<I>>;
|
|
223
|
+
/**
|
|
224
|
+
* Update an egg's configuration.
|
|
225
|
+
*
|
|
226
|
+
* @param id The egg's NanoID.
|
|
227
|
+
* @param payload The fields to update.
|
|
228
|
+
*/
|
|
229
|
+
update(id: NanoID, payload: UpdateEggPayload): Promise<Egg>;
|
|
230
|
+
/**
|
|
231
|
+
* Delete an egg permanently.
|
|
232
|
+
*
|
|
233
|
+
* @param id The egg's NanoID.
|
|
234
|
+
*/
|
|
235
|
+
delete(id: NanoID): Promise<void>;
|
|
236
|
+
}
|
|
237
|
+
export {};
|
|
238
|
+
//# sourceMappingURL=eggs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eggs.d.ts","sourceRoot":"","sources":["../../../src/src/resources/eggs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,KAAK,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,SAAS,EAAY,MAAM,aAAa,CAAC;AAEhG,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,M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AAG,OAAO,CAAC,GAAG,CAAC;IA+BxE;;;;OAIG;IACU,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAK9C"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { ResourceNamespace } from '../namespace.js';
|
|
2
|
+
import { ReactiveResource } from '../reactive.js';
|
|
3
|
+
import { joinIncludes, toNanoID } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* A category (nest) that groups related eggs.
|
|
6
|
+
*/
|
|
7
|
+
export class EggNest extends ReactiveResource {
|
|
8
|
+
/** Unique NanoID of this nest. */
|
|
9
|
+
id;
|
|
10
|
+
/** Display name of the nest, e.g. `"Minecraft"`. */
|
|
11
|
+
name;
|
|
12
|
+
/** @internal */
|
|
13
|
+
constructor(data) {
|
|
14
|
+
super();
|
|
15
|
+
this.id = toNanoID(data.id);
|
|
16
|
+
this.name = data.name;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An egg - a game or application configuration template that defines how a server
|
|
21
|
+
* is installed, started, and stopped.
|
|
22
|
+
*
|
|
23
|
+
* Retrieved via {@link EggsNamespace.get} or {@link EggsNamespace.list}.
|
|
24
|
+
*/
|
|
25
|
+
export class Egg extends ReactiveResource {
|
|
26
|
+
/** The egg's unique NanoID. */
|
|
27
|
+
id;
|
|
28
|
+
/** Display name of the egg, e.g. `"Vanilla Minecraft"`. */
|
|
29
|
+
name;
|
|
30
|
+
/** Description of the egg. */
|
|
31
|
+
description;
|
|
32
|
+
/** The nest (category) this egg belongs to. */
|
|
33
|
+
nest;
|
|
34
|
+
/**
|
|
35
|
+
* The startup command template, e.g.
|
|
36
|
+
* `"java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}"`.
|
|
37
|
+
*/
|
|
38
|
+
startupCommand;
|
|
39
|
+
/**
|
|
40
|
+
* The stop command sent to the server to shut it down gracefully,
|
|
41
|
+
* e.g. `"stop"` or `"^C"`.
|
|
42
|
+
*/
|
|
43
|
+
stopCommand;
|
|
44
|
+
/** When `true`, the server's outgoing IP is forced to match the allocation IP. */
|
|
45
|
+
forceOutgoingIp;
|
|
46
|
+
/** Installer configuration for this egg. */
|
|
47
|
+
installer;
|
|
48
|
+
/** Process configuration (startup, stop, logging). */
|
|
49
|
+
process;
|
|
50
|
+
/** Docker image variants for this egg. */
|
|
51
|
+
images;
|
|
52
|
+
/** When this egg was created. */
|
|
53
|
+
createdAt;
|
|
54
|
+
/** When this egg was last updated. */
|
|
55
|
+
updatedAt;
|
|
56
|
+
/** @internal */
|
|
57
|
+
constructor(data) {
|
|
58
|
+
super();
|
|
59
|
+
this.id = toNanoID(data.id);
|
|
60
|
+
this.name = data.name;
|
|
61
|
+
this.description = data.description;
|
|
62
|
+
this.nest = data.nest ? new EggNest(data.nest) : data.nest;
|
|
63
|
+
this.startupCommand = data.startup_command;
|
|
64
|
+
this.stopCommand = data.stop_command;
|
|
65
|
+
this.forceOutgoingIp = data.force_outgoing_ip;
|
|
66
|
+
this.installer = data.installer
|
|
67
|
+
? {
|
|
68
|
+
image: data.installer.image,
|
|
69
|
+
entryCommand: data.installer.entry_command,
|
|
70
|
+
script: data.installer.script,
|
|
71
|
+
}
|
|
72
|
+
: data.installer;
|
|
73
|
+
this.process = data.process
|
|
74
|
+
? {
|
|
75
|
+
startup: data.process.startup,
|
|
76
|
+
stop: data.process.stop,
|
|
77
|
+
logs: data.process.logs,
|
|
78
|
+
files: data.process.files,
|
|
79
|
+
fileBlacklistRegex: data.process.file_blacklist_regex,
|
|
80
|
+
}
|
|
81
|
+
: data.process;
|
|
82
|
+
this.images = data.images?.map((img) => ({
|
|
83
|
+
id: toNanoID(img.id),
|
|
84
|
+
name: img.name,
|
|
85
|
+
image: img.image,
|
|
86
|
+
createdAt: new Date(img.created_at),
|
|
87
|
+
updatedAt: new Date(img.updated_at),
|
|
88
|
+
}));
|
|
89
|
+
this.createdAt = new Date(data.created_at);
|
|
90
|
+
this.updatedAt = new Date(data.updated_at);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Namespace for egg management.
|
|
95
|
+
*
|
|
96
|
+
* Access via `api.eggs`.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts ignore
|
|
100
|
+
* const eggs = await api.eggs.list();
|
|
101
|
+
* const egg = await api.eggs.get(id);
|
|
102
|
+
* await api.eggs.update(id, { name: 'Paper Minecraft' });
|
|
103
|
+
* await api.eggs.delete(id);
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export class EggsNamespace extends ResourceNamespace {
|
|
107
|
+
/** @internal */
|
|
108
|
+
constructor(http) {
|
|
109
|
+
super(http);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Fetch a paginated list of eggs.
|
|
113
|
+
*
|
|
114
|
+
* @param opts Pagination, search, and include options.
|
|
115
|
+
*/
|
|
116
|
+
async list(opts = {}) {
|
|
117
|
+
const extra = {};
|
|
118
|
+
const include = joinIncludes(opts);
|
|
119
|
+
if (include)
|
|
120
|
+
extra['include'] = include;
|
|
121
|
+
const result = await this.http.list('/eggs', opts, extra);
|
|
122
|
+
const eggs = result.data.map((d) => new Egg(d));
|
|
123
|
+
this.setCache(eggs);
|
|
124
|
+
return { ...result, data: eggs };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Fetch a single egg by ID.
|
|
128
|
+
*
|
|
129
|
+
* @param id The egg's NanoID.
|
|
130
|
+
* @param opts Include options.
|
|
131
|
+
*/
|
|
132
|
+
async get(id, opts = {}) {
|
|
133
|
+
const params = {};
|
|
134
|
+
const include = joinIncludes(opts);
|
|
135
|
+
if (include)
|
|
136
|
+
params['include'] = include;
|
|
137
|
+
const data = await this.http.get(`/eggs/${id}`, { params });
|
|
138
|
+
return new Egg(data);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Update an egg's configuration.
|
|
142
|
+
*
|
|
143
|
+
* @param id The egg's NanoID.
|
|
144
|
+
* @param payload The fields to update.
|
|
145
|
+
*/
|
|
146
|
+
async update(id, payload) {
|
|
147
|
+
const body = {};
|
|
148
|
+
if (payload.name !== undefined)
|
|
149
|
+
body['name'] = payload.name;
|
|
150
|
+
if (payload.description !== undefined) {
|
|
151
|
+
body['description'] = payload.description;
|
|
152
|
+
}
|
|
153
|
+
if (payload.nestId !== undefined)
|
|
154
|
+
body['nest_id'] = payload.nestId;
|
|
155
|
+
if (payload.startupCommand !== undefined) {
|
|
156
|
+
body['startup_command'] = payload.startupCommand;
|
|
157
|
+
}
|
|
158
|
+
if (payload.stopCommand !== undefined) {
|
|
159
|
+
body['stop_command'] = payload.stopCommand;
|
|
160
|
+
}
|
|
161
|
+
if (payload.forceOutgoingIp !== undefined) {
|
|
162
|
+
body['force_outgoing_ip'] = payload.forceOutgoingIp;
|
|
163
|
+
}
|
|
164
|
+
if (payload.installer) {
|
|
165
|
+
body['installer'] = {
|
|
166
|
+
image: payload.installer.image,
|
|
167
|
+
entry_command: payload.installer.entryCommand,
|
|
168
|
+
script: payload.installer.script,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const data = await this.http.patch(`/eggs/${id}`, body);
|
|
172
|
+
const egg = new Egg(data);
|
|
173
|
+
this.upsertCache(egg);
|
|
174
|
+
this.emit('updated', egg);
|
|
175
|
+
return egg;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Delete an egg permanently.
|
|
179
|
+
*
|
|
180
|
+
* @param id The egg's NanoID.
|
|
181
|
+
*/
|
|
182
|
+
async delete(id) {
|
|
183
|
+
await this.http.delete(`/eggs/${id}`);
|
|
184
|
+
this.removeFromCache(id);
|
|
185
|
+
this.emit('deleted', id);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import { ResourceNamespace } from '../namespace.js';
|
|
3
|
+
import { ReactiveResource } from '../reactive.js';
|
|
4
|
+
import { type ISODate, type NanoID, type Paginated } from '../types.js';
|
|
5
|
+
/** Raw API shape for a physical host. @internal */
|
|
6
|
+
export interface HostData {
|
|
7
|
+
id: string;
|
|
8
|
+
hostname: string;
|
|
9
|
+
name?: string | null;
|
|
10
|
+
color?: string | null;
|
|
11
|
+
notes?: string | null;
|
|
12
|
+
created_at: ISODate;
|
|
13
|
+
updated_at: ISODate;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A physical host machine on which nodes are deployed.
|
|
17
|
+
*
|
|
18
|
+
* Retrieved via {@link HostsNamespace.list}.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Host extends ReactiveResource {
|
|
21
|
+
/** The host's unique NanoID. */
|
|
22
|
+
readonly id: NanoID;
|
|
23
|
+
/** The host's hostname, e.g. `"host.example.com"`. */
|
|
24
|
+
hostname: string;
|
|
25
|
+
/** Optional display name for the host. */
|
|
26
|
+
name: string | null | undefined;
|
|
27
|
+
/** Optional color used in the UI for grouping. */
|
|
28
|
+
color: string | null | undefined;
|
|
29
|
+
/** Internal notes. */
|
|
30
|
+
notes: string | null | undefined;
|
|
31
|
+
/** When this host was registered. */
|
|
32
|
+
createdAt: Date;
|
|
33
|
+
/** When this host was last updated. */
|
|
34
|
+
updatedAt: Date;
|
|
35
|
+
/** @internal */
|
|
36
|
+
constructor(data: HostData);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Namespace for host management.
|
|
40
|
+
*
|
|
41
|
+
* Access via `api.hosts`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts ignore
|
|
45
|
+
* const hosts = await api.hosts.list();
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class HostsNamespace extends ResourceNamespace<Host> {
|
|
49
|
+
/** @internal */
|
|
50
|
+
constructor(http: HttpClient);
|
|
51
|
+
/**
|
|
52
|
+
* Fetch a paginated list of physical hosts.
|
|
53
|
+
*
|
|
54
|
+
* @param opts Pagination and search options.
|
|
55
|
+
*/
|
|
56
|
+
list(opts?: {
|
|
57
|
+
page?: number;
|
|
58
|
+
perPage?: number;
|
|
59
|
+
search?: string;
|
|
60
|
+
}): Promise<Paginated<Host>>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=hosts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosts.d.ts","sourceRoot":"","sources":["../../../src/src/resources/hosts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAY,MAAM,aAAa,CAAC;AAElF,mDAAmD;AACnD,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,qBAAa,IAAK,SAAQ,gBAAgB;IACzC,gCAAgC;IAChC,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACxB,0CAA0C;IACnC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACvC,kDAAkD;IAC3C,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,sBAAsB;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,qCAAqC;IAC9B,SAAS,EAAE,IAAI,CAAC;IACvB,uCAAuC;IAChC,SAAS,EAAE,IAAI,CAAC;IAEvB,gBAAgB;gBACG,IAAI,EAAE,QAAQ;CAUjC;AAED;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,iBAAiB,CAAC,IAAI,CAAC;IAC1D,gBAAgB;gBACG,IAAI,EAAE,UAAU;IAInC;;;;OAIG;IACU,IAAI,CAAC,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;CAM5G"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ResourceNamespace } from '../namespace.js';
|
|
2
|
+
import { ReactiveResource } from '../reactive.js';
|
|
3
|
+
import { toNanoID } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* A physical host machine on which nodes are deployed.
|
|
6
|
+
*
|
|
7
|
+
* Retrieved via {@link HostsNamespace.list}.
|
|
8
|
+
*/
|
|
9
|
+
export class Host extends ReactiveResource {
|
|
10
|
+
/** The host's unique NanoID. */
|
|
11
|
+
id;
|
|
12
|
+
/** The host's hostname, e.g. `"host.example.com"`. */
|
|
13
|
+
hostname;
|
|
14
|
+
/** Optional display name for the host. */
|
|
15
|
+
name;
|
|
16
|
+
/** Optional color used in the UI for grouping. */
|
|
17
|
+
color;
|
|
18
|
+
/** Internal notes. */
|
|
19
|
+
notes;
|
|
20
|
+
/** When this host was registered. */
|
|
21
|
+
createdAt;
|
|
22
|
+
/** When this host was last updated. */
|
|
23
|
+
updatedAt;
|
|
24
|
+
/** @internal */
|
|
25
|
+
constructor(data) {
|
|
26
|
+
super();
|
|
27
|
+
this.id = toNanoID(data.id);
|
|
28
|
+
this.hostname = data.hostname;
|
|
29
|
+
this.name = data.name;
|
|
30
|
+
this.color = data.color;
|
|
31
|
+
this.notes = data.notes;
|
|
32
|
+
this.createdAt = new Date(data.created_at);
|
|
33
|
+
this.updatedAt = new Date(data.updated_at);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Namespace for host management.
|
|
38
|
+
*
|
|
39
|
+
* Access via `api.hosts`.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts ignore
|
|
43
|
+
* const hosts = await api.hosts.list();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export class HostsNamespace extends ResourceNamespace {
|
|
47
|
+
/** @internal */
|
|
48
|
+
constructor(http) {
|
|
49
|
+
super(http);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Fetch a paginated list of physical hosts.
|
|
53
|
+
*
|
|
54
|
+
* @param opts Pagination and search options.
|
|
55
|
+
*/
|
|
56
|
+
async list(opts = {}) {
|
|
57
|
+
const result = await this.http.list('/hosts', opts);
|
|
58
|
+
const hosts = result.data.map((d) => new Host(d));
|
|
59
|
+
this.setCache(hosts);
|
|
60
|
+
return { ...result, data: hosts };
|
|
61
|
+
}
|
|
62
|
+
}
|