@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.
Files changed (297) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +40 -0
  3. package/esm/mod.d.ts +87 -1
  4. package/esm/mod.d.ts.map +1 -1
  5. package/esm/mod.js +85 -1
  6. package/esm/src/client.d.ts +248 -0
  7. package/esm/src/client.d.ts.map +1 -0
  8. package/esm/src/client.js +235 -0
  9. package/esm/src/emitter.d.ts +53 -0
  10. package/esm/src/emitter.d.ts.map +1 -0
  11. package/esm/src/emitter.js +55 -0
  12. package/esm/src/errors.d.ts +42 -0
  13. package/esm/src/errors.d.ts.map +1 -0
  14. package/esm/src/errors.js +45 -0
  15. package/esm/src/http.d.ts +157 -0
  16. package/esm/src/http.d.ts.map +1 -0
  17. package/esm/src/http.js +317 -0
  18. package/esm/src/namespace.d.ts +59 -0
  19. package/esm/src/namespace.d.ts.map +1 -0
  20. package/esm/src/namespace.js +79 -0
  21. package/esm/src/reactive.d.ts +29 -0
  22. package/esm/src/reactive.d.ts.map +1 -0
  23. package/esm/src/reactive.js +35 -0
  24. package/esm/src/resources/account.d.ts +125 -0
  25. package/esm/src/resources/account.d.ts.map +1 -0
  26. package/esm/src/resources/account.js +151 -0
  27. package/esm/src/resources/api-keys.d.ts +116 -0
  28. package/esm/src/resources/api-keys.d.ts.map +1 -0
  29. package/esm/src/resources/api-keys.js +105 -0
  30. package/esm/src/resources/auth.d.ts +57 -0
  31. package/esm/src/resources/auth.d.ts.map +1 -0
  32. package/esm/src/resources/auth.js +39 -0
  33. package/esm/src/resources/eggs.d.ts +238 -0
  34. package/esm/src/resources/eggs.d.ts.map +1 -0
  35. package/esm/src/resources/eggs.js +187 -0
  36. package/esm/src/resources/hosts.d.ts +62 -0
  37. package/esm/src/resources/hosts.d.ts.map +1 -0
  38. package/esm/src/resources/hosts.js +62 -0
  39. package/esm/src/resources/members.d.ts +138 -0
  40. package/esm/src/resources/members.d.ts.map +1 -0
  41. package/esm/src/resources/members.js +122 -0
  42. package/esm/src/resources/nodes.d.ts +397 -0
  43. package/esm/src/resources/nodes.d.ts.map +1 -0
  44. package/esm/src/resources/nodes.js +352 -0
  45. package/esm/src/resources/server-groups.d.ts +150 -0
  46. package/esm/src/resources/server-groups.d.ts.map +1 -0
  47. package/esm/src/resources/server-groups.js +111 -0
  48. package/esm/src/resources/servers/activity.d.ts +120 -0
  49. package/esm/src/resources/servers/activity.d.ts.map +1 -0
  50. package/esm/src/resources/servers/activity.js +163 -0
  51. package/esm/src/resources/servers/allocations.d.ts +125 -0
  52. package/esm/src/resources/servers/allocations.d.ts.map +1 -0
  53. package/esm/src/resources/servers/allocations.js +137 -0
  54. package/esm/src/resources/servers/connection.d.ts +108 -0
  55. package/esm/src/resources/servers/connection.d.ts.map +1 -0
  56. package/esm/src/resources/servers/connection.js +169 -0
  57. package/esm/src/resources/servers/files.d.ts +164 -0
  58. package/esm/src/resources/servers/files.d.ts.map +1 -0
  59. package/esm/src/resources/servers/files.js +281 -0
  60. package/esm/src/resources/servers/index.d.ts +126 -0
  61. package/esm/src/resources/servers/index.d.ts.map +1 -0
  62. package/esm/src/resources/servers/index.js +135 -0
  63. package/esm/src/resources/servers/profiles.d.ts +138 -0
  64. package/esm/src/resources/servers/profiles.d.ts.map +1 -0
  65. package/esm/src/resources/servers/profiles.js +177 -0
  66. package/esm/src/resources/servers/server.d.ts +136 -0
  67. package/esm/src/resources/servers/server.d.ts.map +1 -0
  68. package/esm/src/resources/servers/server.js +202 -0
  69. package/esm/src/resources/servers/sftp.d.ts +147 -0
  70. package/esm/src/resources/servers/sftp.d.ts.map +1 -0
  71. package/esm/src/resources/servers/sftp.js +153 -0
  72. package/esm/src/resources/servers/types.d.ts +199 -0
  73. package/esm/src/resources/servers/types.d.ts.map +1 -0
  74. package/esm/src/resources/servers/types.js +1 -0
  75. package/esm/src/sse.d.ts +53 -0
  76. package/esm/src/sse.d.ts.map +1 -0
  77. package/esm/src/sse.js +133 -0
  78. package/esm/src/types.d.ts +126 -0
  79. package/esm/src/types.d.ts.map +1 -0
  80. package/esm/src/types.js +21 -0
  81. package/package.json +4 -92
  82. package/script/mod.d.ts +87 -1
  83. package/script/mod.d.ts.map +1 -1
  84. package/script/mod.js +132 -3
  85. package/script/src/client.d.ts +248 -0
  86. package/script/src/client.d.ts.map +1 -0
  87. package/script/src/client.js +239 -0
  88. package/script/src/emitter.d.ts +53 -0
  89. package/script/src/emitter.d.ts.map +1 -0
  90. package/script/src/emitter.js +59 -0
  91. package/script/src/errors.d.ts +42 -0
  92. package/script/src/errors.d.ts.map +1 -0
  93. package/script/src/errors.js +49 -0
  94. package/script/src/http.d.ts +157 -0
  95. package/script/src/http.d.ts.map +1 -0
  96. package/script/src/http.js +321 -0
  97. package/script/src/namespace.d.ts +59 -0
  98. package/script/src/namespace.d.ts.map +1 -0
  99. package/script/src/namespace.js +83 -0
  100. package/script/src/reactive.d.ts +29 -0
  101. package/script/src/reactive.d.ts.map +1 -0
  102. package/script/src/reactive.js +39 -0
  103. package/script/src/resources/account.d.ts +125 -0
  104. package/script/src/resources/account.d.ts.map +1 -0
  105. package/script/src/resources/account.js +158 -0
  106. package/script/src/resources/api-keys.d.ts +116 -0
  107. package/script/src/resources/api-keys.d.ts.map +1 -0
  108. package/script/src/resources/api-keys.js +110 -0
  109. package/script/src/resources/auth.d.ts +57 -0
  110. package/script/src/resources/auth.d.ts.map +1 -0
  111. package/script/src/resources/auth.js +43 -0
  112. package/script/src/resources/eggs.d.ts +238 -0
  113. package/script/src/resources/eggs.d.ts.map +1 -0
  114. package/script/src/resources/eggs.js +193 -0
  115. package/script/src/resources/hosts.d.ts +62 -0
  116. package/script/src/resources/hosts.d.ts.map +1 -0
  117. package/script/src/resources/hosts.js +67 -0
  118. package/script/src/resources/members.d.ts +138 -0
  119. package/script/src/resources/members.d.ts.map +1 -0
  120. package/script/src/resources/members.js +127 -0
  121. package/script/src/resources/nodes.d.ts +397 -0
  122. package/script/src/resources/nodes.d.ts.map +1 -0
  123. package/script/src/resources/nodes.js +362 -0
  124. package/script/src/resources/server-groups.d.ts +150 -0
  125. package/script/src/resources/server-groups.d.ts.map +1 -0
  126. package/script/src/resources/server-groups.js +116 -0
  127. package/script/src/resources/servers/activity.d.ts +120 -0
  128. package/script/src/resources/servers/activity.d.ts.map +1 -0
  129. package/script/src/resources/servers/activity.js +170 -0
  130. package/script/src/resources/servers/allocations.d.ts +125 -0
  131. package/script/src/resources/servers/allocations.d.ts.map +1 -0
  132. package/script/src/resources/servers/allocations.js +142 -0
  133. package/script/src/resources/servers/connection.d.ts +108 -0
  134. package/script/src/resources/servers/connection.d.ts.map +1 -0
  135. package/script/src/resources/servers/connection.js +173 -0
  136. package/script/src/resources/servers/files.d.ts +164 -0
  137. package/script/src/resources/servers/files.d.ts.map +1 -0
  138. package/script/src/resources/servers/files.js +286 -0
  139. package/script/src/resources/servers/index.d.ts +126 -0
  140. package/script/src/resources/servers/index.d.ts.map +1 -0
  141. package/script/src/resources/servers/index.js +139 -0
  142. package/script/src/resources/servers/profiles.d.ts +138 -0
  143. package/script/src/resources/servers/profiles.d.ts.map +1 -0
  144. package/script/src/resources/servers/profiles.js +182 -0
  145. package/script/src/resources/servers/server.d.ts +136 -0
  146. package/script/src/resources/servers/server.d.ts.map +1 -0
  147. package/script/src/resources/servers/server.js +206 -0
  148. package/script/src/resources/servers/sftp.d.ts +147 -0
  149. package/script/src/resources/servers/sftp.d.ts.map +1 -0
  150. package/script/src/resources/servers/sftp.js +158 -0
  151. package/script/src/resources/servers/types.d.ts +199 -0
  152. package/script/src/resources/servers/types.d.ts.map +1 -0
  153. package/script/src/resources/servers/types.js +2 -0
  154. package/script/src/sse.d.ts +53 -0
  155. package/script/src/sse.d.ts.map +1 -0
  156. package/script/src/sse.js +137 -0
  157. package/script/src/types.d.ts +126 -0
  158. package/script/src/types.d.ts.map +1 -0
  159. package/script/src/types.js +25 -0
  160. package/esm/api.d.ts +0 -76
  161. package/esm/api.d.ts.map +0 -1
  162. package/esm/api.js +0 -187
  163. package/esm/components/auth.d.ts +0 -15
  164. package/esm/components/auth.d.ts.map +0 -1
  165. package/esm/components/auth.js +0 -13
  166. package/esm/components/connection/abstract.d.ts +0 -23
  167. package/esm/components/connection/abstract.d.ts.map +0 -1
  168. package/esm/components/connection/abstract.js +0 -43
  169. package/esm/components/connection/sse.d.ts +0 -20
  170. package/esm/components/connection/sse.d.ts.map +0 -1
  171. package/esm/components/connection/sse.js +0 -65
  172. package/esm/components/egg/egg.d.ts +0 -32
  173. package/esm/components/egg/egg.d.ts.map +0 -1
  174. package/esm/components/egg/egg.js +0 -70
  175. package/esm/components/group.d.ts +0 -14
  176. package/esm/components/group.d.ts.map +0 -1
  177. package/esm/components/group.js +0 -33
  178. package/esm/components/member_2.d.ts +0 -69
  179. package/esm/components/member_2.d.ts.map +0 -1
  180. package/esm/components/member_2.js +0 -140
  181. package/esm/components/node.d.ts +0 -78
  182. package/esm/components/node.d.ts.map +0 -1
  183. package/esm/components/node.js +0 -342
  184. package/esm/components/server/activity.d.ts +0 -45
  185. package/esm/components/server/activity.d.ts.map +0 -1
  186. package/esm/components/server/activity.js +0 -158
  187. package/esm/components/server/allocations.d.ts +0 -45
  188. package/esm/components/server/allocations.d.ts.map +0 -1
  189. package/esm/components/server/allocations.js +0 -146
  190. package/esm/components/server/files.d.ts +0 -50
  191. package/esm/components/server/files.d.ts.map +0 -1
  192. package/esm/components/server/files.js +0 -90
  193. package/esm/components/server/power.d.ts +0 -21
  194. package/esm/components/server/power.d.ts.map +0 -1
  195. package/esm/components/server/power.js +0 -43
  196. package/esm/components/server/profiles.d.ts +0 -63
  197. package/esm/components/server/profiles.d.ts.map +0 -1
  198. package/esm/components/server/profiles.js +0 -163
  199. package/esm/components/server/server.d.ts +0 -141
  200. package/esm/components/server/server.d.ts.map +0 -1
  201. package/esm/components/server/server.js +0 -358
  202. package/esm/components/server/sftp.d.ts +0 -31
  203. package/esm/components/server/sftp.d.ts.map +0 -1
  204. package/esm/components/server/sftp.js +0 -84
  205. package/esm/components/server/startup.d.ts +0 -17
  206. package/esm/components/server/startup.d.ts.map +0 -1
  207. package/esm/components/server/startup.js +0 -21
  208. package/esm/components/server/stats.d.ts +0 -19
  209. package/esm/components/server/stats.d.ts.map +0 -1
  210. package/esm/components/server/stats.js +0 -46
  211. package/esm/utils/cache.d.ts +0 -20
  212. package/esm/utils/cache.d.ts.map +0 -1
  213. package/esm/utils/cache.js +0 -66
  214. package/esm/utils/event.d.ts +0 -38
  215. package/esm/utils/event.d.ts.map +0 -1
  216. package/esm/utils/event.js +0 -71
  217. package/esm/utils/object.d.ts +0 -58
  218. package/esm/utils/object.d.ts.map +0 -1
  219. package/esm/utils/object.js +0 -86
  220. package/esm/utils/subscribe.d.ts +0 -37
  221. package/esm/utils/subscribe.d.ts.map +0 -1
  222. package/esm/utils/subscribe.js +0 -29
  223. package/esm/utils/timer.d.ts +0 -13
  224. package/esm/utils/timer.d.ts.map +0 -1
  225. package/esm/utils/timer.js +0 -32
  226. package/esm/utils/units.d.ts +0 -18
  227. package/esm/utils/units.d.ts.map +0 -1
  228. package/esm/utils/units.js +0 -82
  229. package/script/api.d.ts +0 -76
  230. package/script/api.d.ts.map +0 -1
  231. package/script/api.js +0 -192
  232. package/script/components/auth.d.ts +0 -15
  233. package/script/components/auth.d.ts.map +0 -1
  234. package/script/components/auth.js +0 -17
  235. package/script/components/connection/abstract.d.ts +0 -23
  236. package/script/components/connection/abstract.d.ts.map +0 -1
  237. package/script/components/connection/abstract.js +0 -47
  238. package/script/components/connection/sse.d.ts +0 -20
  239. package/script/components/connection/sse.d.ts.map +0 -1
  240. package/script/components/connection/sse.js +0 -69
  241. package/script/components/egg/egg.d.ts +0 -32
  242. package/script/components/egg/egg.d.ts.map +0 -1
  243. package/script/components/egg/egg.js +0 -74
  244. package/script/components/group.d.ts +0 -14
  245. package/script/components/group.d.ts.map +0 -1
  246. package/script/components/group.js +0 -37
  247. package/script/components/member_2.d.ts +0 -69
  248. package/script/components/member_2.d.ts.map +0 -1
  249. package/script/components/member_2.js +0 -146
  250. package/script/components/node.d.ts +0 -78
  251. package/script/components/node.d.ts.map +0 -1
  252. package/script/components/node.js +0 -349
  253. package/script/components/server/activity.d.ts +0 -45
  254. package/script/components/server/activity.d.ts.map +0 -1
  255. package/script/components/server/activity.js +0 -164
  256. package/script/components/server/allocations.d.ts +0 -45
  257. package/script/components/server/allocations.d.ts.map +0 -1
  258. package/script/components/server/allocations.js +0 -152
  259. package/script/components/server/files.d.ts +0 -50
  260. package/script/components/server/files.d.ts.map +0 -1
  261. package/script/components/server/files.js +0 -94
  262. package/script/components/server/power.d.ts +0 -21
  263. package/script/components/server/power.d.ts.map +0 -1
  264. package/script/components/server/power.js +0 -47
  265. package/script/components/server/profiles.d.ts +0 -63
  266. package/script/components/server/profiles.d.ts.map +0 -1
  267. package/script/components/server/profiles.js +0 -168
  268. package/script/components/server/server.d.ts +0 -141
  269. package/script/components/server/server.d.ts.map +0 -1
  270. package/script/components/server/server.js +0 -362
  271. package/script/components/server/sftp.d.ts +0 -31
  272. package/script/components/server/sftp.d.ts.map +0 -1
  273. package/script/components/server/sftp.js +0 -88
  274. package/script/components/server/startup.d.ts +0 -17
  275. package/script/components/server/startup.d.ts.map +0 -1
  276. package/script/components/server/startup.js +0 -25
  277. package/script/components/server/stats.d.ts +0 -19
  278. package/script/components/server/stats.d.ts.map +0 -1
  279. package/script/components/server/stats.js +0 -50
  280. package/script/utils/cache.d.ts +0 -20
  281. package/script/utils/cache.d.ts.map +0 -1
  282. package/script/utils/cache.js +0 -70
  283. package/script/utils/event.d.ts +0 -38
  284. package/script/utils/event.d.ts.map +0 -1
  285. package/script/utils/event.js +0 -75
  286. package/script/utils/object.d.ts +0 -58
  287. package/script/utils/object.d.ts.map +0 -1
  288. package/script/utils/object.js +0 -90
  289. package/script/utils/subscribe.d.ts +0 -37
  290. package/script/utils/subscribe.d.ts.map +0 -1
  291. package/script/utils/subscribe.js +0 -32
  292. package/script/utils/timer.d.ts +0 -13
  293. package/script/utils/timer.d.ts.map +0 -1
  294. package/script/utils/timer.js +0 -36
  295. package/script/utils/units.d.ts +0 -18
  296. package/script/utils/units.d.ts.map +0 -1
  297. package/script/utils/units.js +0 -86
@@ -0,0 +1,126 @@
1
+ import type { HttpClient } from '../../http.js';
2
+ import { ResourceNamespace } from '../../namespace.js';
3
+ import type { IncludeOptions, ListOptions, NanoID, Paginated } from '../../types.js';
4
+ import type { ResourceWith } from '../../types.js';
5
+ import type { ServerBuild, ServerStartup, ServerStatus } from './server.js';
6
+ import { Server } from './server.js';
7
+ import type { ServerAllocationsData, ServerProfileData, UpdateServerPayload } from './types.js';
8
+ import type { Egg } from '../eggs.js';
9
+ import type { ServerGroup } from '../server-groups.js';
10
+ export type { UpdateServerPayload };
11
+ /**
12
+ * Valid include keys for server endpoints.
13
+ *
14
+ * Each include adds extra data to the response (at a small performance cost).
15
+ * When an include is requested, the corresponding field on {@link Server} is guaranteed
16
+ * to be populated (non-undefined).
17
+ */
18
+ export type ServerInclude = 'group' | 'egg' | 'status' | 'build' | 'startup' | 'allocations' | 'profiles';
19
+ /**
20
+ * Maps each {@link ServerInclude} key to the field(s) it guarantees on the {@link Server} instance.
21
+ *
22
+ * Used by {@link ServerWith} to narrow the return type based on the requested includes.
23
+ */
24
+ interface ServerIncludeMap {
25
+ group: {
26
+ group: ServerGroup;
27
+ };
28
+ egg: {
29
+ egg: Egg;
30
+ };
31
+ status: {
32
+ status: ServerStatus;
33
+ };
34
+ build: {
35
+ build: ServerBuild;
36
+ };
37
+ startup: {
38
+ startup: ServerStartup;
39
+ };
40
+ allocations: {
41
+ allocationPorts: ServerAllocationsData;
42
+ };
43
+ profiles: {
44
+ profiles: ServerProfileData[];
45
+ };
46
+ }
47
+ /**
48
+ * A {@link Server} with specific include fields guaranteed to be populated.
49
+ *
50
+ * @example
51
+ * ```ts ignore
52
+ * // server.group is `ServerGroup`, not `ServerGroup | undefined`
53
+ * type S = ServerWith<['group', 'status']>;
54
+ * ```
55
+ */
56
+ export type ServerWith<I extends readonly ServerInclude[] = []> = ResourceWith<Server, ServerIncludeMap, I>;
57
+ /** Payload for creating a new server. */
58
+ export interface CreateServerPayload {
59
+ name: string;
60
+ nodeId: NanoID;
61
+ description?: string;
62
+ notes?: string;
63
+ limits: {
64
+ ramMb: number;
65
+ swapMb: number;
66
+ storageMb: number;
67
+ /** IO weight (1–1000). */
68
+ weightIo: number;
69
+ cpuPercent: number;
70
+ cpuThreads?: string;
71
+ backup?: number;
72
+ database?: number;
73
+ allocation?: number;
74
+ };
75
+ eggId: NanoID;
76
+ allocationPrimaryId: NanoID;
77
+ imageOverride?: string;
78
+ forceOutgoingIp?: boolean;
79
+ oomType?: 'docker';
80
+ shouldSkipEggScripts?: boolean;
81
+ startupCommandOverride?: string;
82
+ expiresAt?: Date;
83
+ }
84
+ export interface ServerEvents {
85
+ created: Server;
86
+ updated: Server;
87
+ deleted: NanoID;
88
+ }
89
+ /**
90
+ * Namespace for server management.
91
+ *
92
+ * Access via `api.servers`.
93
+ *
94
+ * @example
95
+ * ```ts ignore
96
+ * // Type-safe includes: group and status are guaranteed on the result
97
+ * const servers = await api.servers.list({ include: ['group', 'status'] });
98
+ * servers.data[0].group; // ServerGroup (not undefined)
99
+ * servers.data[0].status; // ServerStatus (not undefined)
100
+ *
101
+ * // Without includes: include-gated fields are undefined
102
+ * const bare = await api.servers.list();
103
+ * bare.data[0].groupId; // NanoID (always present)
104
+ * bare.data[0].group; // ServerGroup | undefined
105
+ *
106
+ * // Events
107
+ * api.servers.on('created', (server) => console.log('New server:', server.name));
108
+ * ```
109
+ */
110
+ export declare class ServersNamespace extends ResourceNamespace<Server, ServerEvents> {
111
+ private readonly nodeUrlCache;
112
+ /** @internal */
113
+ constructor(http: HttpClient);
114
+ /** Resolve the node daemon URL: groupId → nodeId → node connection URL. */
115
+ private resolveNodeUrl;
116
+ private makeServer;
117
+ /** Fetch a paginated list of servers. */
118
+ list<const I extends readonly ServerInclude[] = []>(opts?: ListOptions & IncludeOptions<ServerInclude, I>): Promise<Paginated<ServerWith<I>>>;
119
+ /** Fetch a single server by ID. */
120
+ get<const I extends readonly ServerInclude[] = []>(id: NanoID, opts?: IncludeOptions<ServerInclude, I>): Promise<ServerWith<I>>;
121
+ /** Create a new server (also creates its server group). */
122
+ create(payload: CreateServerPayload): Promise<Server>;
123
+ /** Update a server's details, startup config, or primary allocation. */
124
+ update(id: NanoID, payload: UpdateServerPayload): Promise<Server>;
125
+ }
126
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,qBAAqB,EAAc,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;AAE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@@
1
+ import { ResourceNamespace } from '../../namespace.js';
2
+ import { joinIncludes, toNanoID } from '../../types.js';
3
+ import { Server } from './server.js';
4
+ /**
5
+ * Namespace for server management.
6
+ *
7
+ * Access via `api.servers`.
8
+ *
9
+ * @example
10
+ * ```ts ignore
11
+ * // Type-safe includes: group and status are guaranteed on the result
12
+ * const servers = await api.servers.list({ include: ['group', 'status'] });
13
+ * servers.data[0].group; // ServerGroup (not undefined)
14
+ * servers.data[0].status; // ServerStatus (not undefined)
15
+ *
16
+ * // Without includes: include-gated fields are undefined
17
+ * const bare = await api.servers.list();
18
+ * bare.data[0].groupId; // NanoID (always present)
19
+ * bare.data[0].group; // ServerGroup | undefined
20
+ *
21
+ * // Events
22
+ * api.servers.on('created', (server) => console.log('New server:', server.name));
23
+ * ```
24
+ */
25
+ export class ServersNamespace extends ResourceNamespace {
26
+ nodeUrlCache = new Map();
27
+ /** @internal */
28
+ constructor(http) {
29
+ super(http);
30
+ }
31
+ /** Resolve the node daemon URL: groupId → nodeId → node connection URL. */
32
+ resolveNodeUrl(serverId, groupId) {
33
+ return async () => {
34
+ if (this.nodeUrlCache.has(serverId))
35
+ return this.nodeUrlCache.get(serverId);
36
+ // Fetch the group to get the nodeId, then the node connection URL
37
+ const groupData = await this.http.get(`/servers/groups/${groupId}`);
38
+ const nodeId = toNanoID(groupData.node_id);
39
+ const nodeData = await this.http.get(`/nodes/${nodeId}`, { params: { include: 'connection' } });
40
+ const url = nodeData.connection?.url;
41
+ if (!url)
42
+ throw new Error(`Node connection URL is not available for server ${serverId}`);
43
+ this.nodeUrlCache.set(serverId, url);
44
+ return url;
45
+ };
46
+ }
47
+ makeServer(data) {
48
+ const id = toNanoID(data.id);
49
+ const groupId = toNanoID(data.group_id);
50
+ return new Server(data, this.http, this.resolveNodeUrl(id, groupId), () => this.notifySubs());
51
+ }
52
+ /** Fetch a paginated list of servers. */
53
+ async list(opts = {}) {
54
+ const extra = {};
55
+ const include = joinIncludes(opts);
56
+ if (include)
57
+ extra['include'] = include;
58
+ const result = await this.http.list('/servers', opts, extra);
59
+ const servers = result.data.map((d) => this.makeServer(d));
60
+ this.setCache(servers);
61
+ return { ...result, data: servers };
62
+ }
63
+ /** Fetch a single server by ID. */
64
+ async get(id, opts = {}) {
65
+ const params = {};
66
+ const include = joinIncludes(opts);
67
+ if (include)
68
+ params['include'] = include;
69
+ const data = await this.http.get(`/servers/${id}`, { params });
70
+ return this.makeServer(data);
71
+ }
72
+ /** Create a new server (also creates its server group). */
73
+ async create(payload) {
74
+ const body = {
75
+ name: payload.name,
76
+ node_id: payload.nodeId,
77
+ description: payload.description,
78
+ notes: payload.notes,
79
+ limits: {
80
+ ram_mb: payload.limits.ramMb,
81
+ swap_mb: payload.limits.swapMb,
82
+ storage_mb: payload.limits.storageMb,
83
+ weight_io: payload.limits.weightIo,
84
+ cpu_percent: payload.limits.cpuPercent,
85
+ cpu_threads: payload.limits.cpuThreads,
86
+ backup: payload.limits.backup,
87
+ database: payload.limits.database,
88
+ allocation: payload.limits.allocation,
89
+ },
90
+ egg_id: payload.eggId,
91
+ allocation_primary_id: payload.allocationPrimaryId,
92
+ image_override: payload.imageOverride,
93
+ force_outgoing_ip: payload.forceOutgoingIp,
94
+ oom_type: payload.oomType,
95
+ should_skip_egg_scripts: payload.shouldSkipEggScripts,
96
+ startup_command_override: payload.startupCommandOverride,
97
+ expires_at: payload.expiresAt,
98
+ };
99
+ const data = await this.http.post('/servers', body);
100
+ const server = this.makeServer(data);
101
+ this.addToCache(server);
102
+ this.emit('created', server);
103
+ return server;
104
+ }
105
+ /** Update a server's details, startup config, or primary allocation. */
106
+ async update(id, payload) {
107
+ const body = {};
108
+ if (payload.name !== undefined)
109
+ body['name'] = payload.name;
110
+ if (payload.description !== undefined)
111
+ body['description'] = payload.description;
112
+ if (payload.notes !== undefined)
113
+ body['notes'] = payload.notes;
114
+ if (payload.allocationPrimary)
115
+ body['allocation_primary'] = payload.allocationPrimary;
116
+ if (payload.startup) {
117
+ body['startup'] = {
118
+ command: payload.startup.command,
119
+ variables: payload.startup.variables,
120
+ };
121
+ }
122
+ const data = await this.http.patch(`/servers/${id}`, body);
123
+ const existing = this.cache.find((s) => s.id === id);
124
+ if (existing) {
125
+ existing.applyData(data);
126
+ this.upsertCache(existing);
127
+ this.emit('updated', existing);
128
+ return existing;
129
+ }
130
+ const server = this.makeServer(data);
131
+ this.upsertCache(server);
132
+ this.emit('updated', server);
133
+ return server;
134
+ }
135
+ }
@@ -0,0 +1,138 @@
1
+ import type { HttpClient } from '../../http.js';
2
+ import { ReactiveResource } from '../../reactive.js';
3
+ import type { ListOptions, NanoID, Paginated } from '../../types.js';
4
+ import type { ServerProfileData } from './types.js';
5
+ /**
6
+ * A named configuration profile for a server.
7
+ *
8
+ * Profiles allow a server to switch between different file sets (e.g. different
9
+ * game versions or configurations) stored in separate folders.
10
+ *
11
+ * Retrieved via {@link ServerProfilesManager.list} or {@link ServerProfilesManager.get}.
12
+ */
13
+ export declare class ServerProfile extends ReactiveResource {
14
+ private readonly serverId;
15
+ private readonly http;
16
+ /** The profile's unique NanoID. */
17
+ readonly id: NanoID;
18
+ /** Display name for this profile, e.g. `"1.20.4 Vanilla"`. */
19
+ name: string;
20
+ /** Optional description of this profile. */
21
+ description: string | null;
22
+ /** Internal notes for this profile. */
23
+ notes: string | null | undefined;
24
+ /** The folder name used to store this profile's files on disk. */
25
+ folder: string | null | undefined;
26
+ /** `true` if this is the currently active profile for the server. */
27
+ isActive: boolean;
28
+ /** When this profile was created. */
29
+ readonly createdAt: Date;
30
+ /** When this profile was last updated. */
31
+ updatedAt: Date;
32
+ /** @internal */
33
+ constructor(data: ServerProfileData, serverId: NanoID, http: HttpClient);
34
+ /**
35
+ * Apply raw API data to this profile instance, updating all mutable fields.
36
+ *
37
+ * Called by the constructor and by instance methods after server responses.
38
+ *
39
+ * @param data The raw API response data.
40
+ */
41
+ applyData(data: ServerProfileData): void;
42
+ /**
43
+ * Set this profile as the active profile for the server.
44
+ *
45
+ * Triggers the node to sync the server's container to this profile's folder.
46
+ */
47
+ setAsActive(): Promise<void>;
48
+ /**
49
+ * Update this profile's name, description, or notes.
50
+ *
51
+ * @param payload Fields to update.
52
+ */
53
+ update(payload: {
54
+ name?: string;
55
+ description?: string | null;
56
+ notes?: string | null;
57
+ }): Promise<void>;
58
+ /**
59
+ * Delete this profile permanently.
60
+ */
61
+ delete(): Promise<void>;
62
+ }
63
+ /**
64
+ * Manages configuration profiles for a specific server.
65
+ *
66
+ * Access via `server.profiles`.
67
+ *
68
+ * @example
69
+ * ```ts ignore
70
+ * const profiles = await server.profiles.list();
71
+ * const active = await server.profiles.getActive();
72
+ *
73
+ * const profile = await server.profiles.create({ name: '1.20.4', description: 'Latest stable' });
74
+ * await server.profiles.setActive(profile.id);
75
+ * ```
76
+ */
77
+ export declare class ServerProfilesManager {
78
+ private readonly serverId;
79
+ private readonly http;
80
+ /** @internal */
81
+ constructor(serverId: NanoID, http: HttpClient);
82
+ /** Create a {@link ServerProfile} with the correct server context wired in. @internal */
83
+ private makeProfile;
84
+ /**
85
+ * Fetch all profiles for this server.
86
+ *
87
+ * @param opts Pagination options.
88
+ */
89
+ list(opts?: ListOptions): Promise<Paginated<ServerProfile>>;
90
+ /**
91
+ * Fetch the currently active profile.
92
+ *
93
+ * @throws {@link ApiError} with `isNotFound === true` if no profile is active.
94
+ */
95
+ getActive(): Promise<ServerProfile>;
96
+ /**
97
+ * Fetch a single profile by ID.
98
+ *
99
+ * @param profileId The profile's NanoID.
100
+ */
101
+ get(profileId: NanoID): Promise<ServerProfile>;
102
+ /**
103
+ * Create a new profile for this server.
104
+ *
105
+ * @param payload Profile creation parameters.
106
+ */
107
+ create(payload: {
108
+ name: string;
109
+ description?: string;
110
+ notes?: string;
111
+ }): Promise<ServerProfile>;
112
+ /**
113
+ * Update a profile's name, description, or notes.
114
+ *
115
+ * @param profileId The profile's NanoID.
116
+ * @param payload Fields to update.
117
+ */
118
+ update(profileId: NanoID, payload: {
119
+ name?: string;
120
+ description?: string;
121
+ notes?: string;
122
+ }): Promise<ServerProfile>;
123
+ /**
124
+ * Set a profile as the active profile for this server.
125
+ *
126
+ * Triggers the node to sync the server's container to the new profile folder.
127
+ *
128
+ * @param profileId The profile's NanoID, or `null` to clear the active profile.
129
+ */
130
+ setActive(profileId: NanoID | null): Promise<ServerProfile | null>;
131
+ /**
132
+ * Delete a profile permanently.
133
+ *
134
+ * @param profileId The profile's NanoID.
135
+ */
136
+ delete(profileId: NanoID): Promise<void>;
137
+ }
138
+ //# sourceMappingURL=profiles.d.ts.map
@@ -0,0 +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,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAqBjD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IArBtB,mCAAmC;IACnC,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,8DAA8D;IACvD,IAAI,EAAG,MAAM,CAAC;IACrB,4CAA4C;IACrC,WAAW,EAAG,MAAM,GAAG,IAAI,CAAC;IACnC,uCAAuC;IAChC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,kEAAkE;IAC3D,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,qEAAqE;IAC9D,QAAQ,EAAG,OAAO,CAAC;IAC1B,qCAAqC;IACrC,SAAgB,SAAS,EAAE,IAAI,CAAC;IAChC,0CAA0C;IACnC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AO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9D,OAAO,CAAC,aAAa,CAAC;IAKzB;;;;;;OAMG;IACU,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAW/E;;;;OAIG;IACU,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrD"}
@@ -0,0 +1,177 @@
1
+ import { ReactiveResource } from '../../reactive.js';
2
+ import { toNanoID } from '../../types.js';
3
+ /**
4
+ * A named configuration profile for a server.
5
+ *
6
+ * Profiles allow a server to switch between different file sets (e.g. different
7
+ * game versions or configurations) stored in separate folders.
8
+ *
9
+ * Retrieved via {@link ServerProfilesManager.list} or {@link ServerProfilesManager.get}.
10
+ */
11
+ export class ServerProfile extends ReactiveResource {
12
+ serverId;
13
+ http;
14
+ /** The profile's unique NanoID. */
15
+ id;
16
+ /** Display name for this profile, e.g. `"1.20.4 Vanilla"`. */
17
+ name;
18
+ /** Optional description of this profile. */
19
+ description;
20
+ /** Internal notes for this profile. */
21
+ notes;
22
+ /** The folder name used to store this profile's files on disk. */
23
+ folder;
24
+ /** `true` if this is the currently active profile for the server. */
25
+ isActive;
26
+ /** When this profile was created. */
27
+ createdAt;
28
+ /** When this profile was last updated. */
29
+ updatedAt;
30
+ /** @internal */
31
+ constructor(data, serverId, http) {
32
+ super();
33
+ this.serverId = serverId;
34
+ this.http = http;
35
+ this.id = toNanoID(data.id);
36
+ this.createdAt = new Date(data.created_at);
37
+ this.applyData(data);
38
+ }
39
+ /**
40
+ * Apply raw API data to this profile instance, updating all mutable fields.
41
+ *
42
+ * Called by the constructor and by instance methods after server responses.
43
+ *
44
+ * @param data The raw API response data.
45
+ */
46
+ applyData(data) {
47
+ this.name = data.name;
48
+ this.description = data.description ?? null;
49
+ this.notes = data.notes;
50
+ this.folder = data.folder;
51
+ this.isActive = data.is_active;
52
+ this.updatedAt = new Date(data.updated_at);
53
+ this.notify();
54
+ }
55
+ /**
56
+ * Set this profile as the active profile for the server.
57
+ *
58
+ * Triggers the node to sync the server's container to this profile's folder.
59
+ */
60
+ async setAsActive() {
61
+ const data = await this.http.patch(`/servers/${this.serverId}/profiles/active`, { id: this.id });
62
+ this.applyData(data);
63
+ }
64
+ /**
65
+ * Update this profile's name, description, or notes.
66
+ *
67
+ * @param payload Fields to update.
68
+ */
69
+ async update(payload) {
70
+ const data = await this.http.patch(`/servers/${this.serverId}/profiles/${this.id}`, payload);
71
+ this.applyData(data);
72
+ }
73
+ /**
74
+ * Delete this profile permanently.
75
+ */
76
+ async delete() {
77
+ await this.http.delete(`/servers/${this.serverId}/profiles/${this.id}`);
78
+ }
79
+ }
80
+ /**
81
+ * Manages configuration profiles for a specific server.
82
+ *
83
+ * Access via `server.profiles`.
84
+ *
85
+ * @example
86
+ * ```ts ignore
87
+ * const profiles = await server.profiles.list();
88
+ * const active = await server.profiles.getActive();
89
+ *
90
+ * const profile = await server.profiles.create({ name: '1.20.4', description: 'Latest stable' });
91
+ * await server.profiles.setActive(profile.id);
92
+ * ```
93
+ */
94
+ export class ServerProfilesManager {
95
+ serverId;
96
+ http;
97
+ /** @internal */
98
+ constructor(serverId, http) {
99
+ this.serverId = serverId;
100
+ this.http = http;
101
+ }
102
+ /** Create a {@link ServerProfile} with the correct server context wired in. @internal */
103
+ makeProfile(data) {
104
+ return new ServerProfile(data, this.serverId, this.http);
105
+ }
106
+ /**
107
+ * Fetch all profiles for this server.
108
+ *
109
+ * @param opts Pagination options.
110
+ */
111
+ async list(opts = {}) {
112
+ const result = await this.http.list(`/servers/${this.serverId}/profiles`, opts);
113
+ return { ...result, data: result.data.map((d) => this.makeProfile(d)) };
114
+ }
115
+ /**
116
+ * Fetch the currently active profile.
117
+ *
118
+ * @throws {@link ApiError} with `isNotFound === true` if no profile is active.
119
+ */
120
+ async getActive() {
121
+ const data = await this.http.get(`/servers/${this.serverId}/profiles/active`);
122
+ return this.makeProfile(data);
123
+ }
124
+ /**
125
+ * Fetch a single profile by ID.
126
+ *
127
+ * @param profileId The profile's NanoID.
128
+ */
129
+ async get(profileId) {
130
+ const data = await this.http.get(`/servers/${this.serverId}/profiles/${profileId}`);
131
+ return this.makeProfile(data);
132
+ }
133
+ /**
134
+ * Create a new profile for this server.
135
+ *
136
+ * @param payload Profile creation parameters.
137
+ */
138
+ async create(payload) {
139
+ const data = await this.http.post(`/servers/${this.serverId}/profiles`, payload);
140
+ return this.makeProfile(data);
141
+ }
142
+ /**
143
+ * Update a profile's name, description, or notes.
144
+ *
145
+ * @param profileId The profile's NanoID.
146
+ * @param payload Fields to update.
147
+ */
148
+ async update(profileId, payload) {
149
+ const data = await this.http.patch(`/servers/${this.serverId}/profiles/${profileId}`, payload);
150
+ return this.makeProfile(data);
151
+ }
152
+ /**
153
+ * Set a profile as the active profile for this server.
154
+ *
155
+ * Triggers the node to sync the server's container to the new profile folder.
156
+ *
157
+ * @param profileId The profile's NanoID, or `null` to clear the active profile.
158
+ */
159
+ async setActive(profileId) {
160
+ if (profileId === null) {
161
+ await this.http.delete(`/servers/${this.serverId}/profiles/active`);
162
+ return null;
163
+ }
164
+ const data = await this.http.patch(`/servers/${this.serverId}/profiles/active`, {
165
+ id: profileId,
166
+ });
167
+ return this.makeProfile(data);
168
+ }
169
+ /**
170
+ * Delete a profile permanently.
171
+ *
172
+ * @param profileId The profile's NanoID.
173
+ */
174
+ async delete(profileId) {
175
+ await this.http.delete(`/servers/${this.serverId}/profiles/${profileId}`);
176
+ }
177
+ }