@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,352 @@
1
+ import { ResourceNamespace } from '../namespace.js';
2
+ import { ReactiveResource } from '../reactive.js';
3
+ import { joinIncludes, toNanoID } from '../types.js';
4
+ import { Member } from './members.js';
5
+ import { ActivityLog } from './servers/activity.js';
6
+ /**
7
+ * A geographic location associated with one or more nodes.
8
+ */
9
+ export class NodeLocation extends ReactiveResource {
10
+ /** Unique NanoID of this location. */
11
+ id;
12
+ /** Full display name of the location, e.g. `"US East"`. */
13
+ name;
14
+ /** Short code used in node name generation, e.g. `"use"`. */
15
+ short;
16
+ /** Internal notes. */
17
+ notes;
18
+ /** Owner of this location record. */
19
+ owner;
20
+ /** When this location was created. */
21
+ createdAt;
22
+ /** When this location was last updated. */
23
+ updatedAt;
24
+ /** @internal */
25
+ constructor(data) {
26
+ super();
27
+ this.id = toNanoID(data.id);
28
+ this.name = data.name;
29
+ this.short = data.short;
30
+ this.notes = data.notes;
31
+ this.owner = data.owner ? new Member(data.owner) : undefined;
32
+ this.createdAt = new Date(data.created_at);
33
+ this.updatedAt = new Date(data.updated_at);
34
+ }
35
+ }
36
+ /**
37
+ * A classification type for nodes (e.g. `"Apex"`, `"Shared"`).
38
+ */
39
+ export class NodeType extends ReactiveResource {
40
+ /** Unique NanoID of this node type. */
41
+ id;
42
+ /** Full display name of the node type, e.g. `"Apex"`. */
43
+ name;
44
+ /** Short code used in node name generation, e.g. `"a"`. */
45
+ short;
46
+ /** Internal notes. */
47
+ notes;
48
+ /** Owner of this type record. */
49
+ owner;
50
+ /** When this type was created. */
51
+ createdAt;
52
+ /** When this type was last updated. */
53
+ updatedAt;
54
+ /** @internal */
55
+ constructor(data) {
56
+ super();
57
+ this.id = toNanoID(data.id);
58
+ this.name = data.name;
59
+ this.short = data.short;
60
+ this.notes = data.notes;
61
+ this.owner = data.owner ? new Member(data.owner) : undefined;
62
+ this.createdAt = new Date(data.created_at);
63
+ this.updatedAt = new Date(data.updated_at);
64
+ }
65
+ }
66
+ /**
67
+ * A single port on a node allocation IP.
68
+ */
69
+ export class NodeAllocationPort extends ReactiveResource {
70
+ id;
71
+ ip;
72
+ port;
73
+ readyProtocols;
74
+ isInUse;
75
+ notes;
76
+ createdAt;
77
+ updatedAt;
78
+ /** @internal */
79
+ constructor(data) {
80
+ super();
81
+ this.id = toNanoID(data.id);
82
+ this.ip = data.ip;
83
+ this.port = data.port;
84
+ this.readyProtocols = data.ready_protocols;
85
+ this.isInUse = data.is_in_use;
86
+ this.notes = data.notes;
87
+ this.createdAt = new Date(data.created_at);
88
+ this.updatedAt = new Date(data.updated_at);
89
+ }
90
+ }
91
+ /**
92
+ * An allocation IP assigned to a node, including its available ports.
93
+ */
94
+ export class NodeAllocationIp extends ReactiveResource {
95
+ id;
96
+ ip;
97
+ ipAlias;
98
+ ports;
99
+ node;
100
+ notes;
101
+ createdAt;
102
+ updatedAt;
103
+ /** @internal */
104
+ constructor(data) {
105
+ super();
106
+ this.id = toNanoID(data.id);
107
+ this.ip = data.ip;
108
+ this.ipAlias = data.ipAlias;
109
+ this.ports = data.ports.map((port) => new NodeAllocationPort(port));
110
+ this.node = new Node(data.node);
111
+ this.notes = data.notes;
112
+ this.createdAt = new Date(data.created_at);
113
+ this.updatedAt = new Date(data.updated_at);
114
+ }
115
+ }
116
+ /**
117
+ * A MeowPanel daemon node (physical or virtual server hosting game servers).
118
+ *
119
+ * Retrieved via {@link NodesNamespace.get} or {@link NodesNamespace.list}.
120
+ */
121
+ export class Node extends ReactiveResource {
122
+ /** The node's unique NanoID. */
123
+ id;
124
+ /**
125
+ * Auto-generated display name in the format `{type}{num}{location}.{hostname}`,
126
+ * e.g. `"a001use.host.example.com"`.
127
+ */
128
+ name;
129
+ /** Optional description of the node. */
130
+ description;
131
+ /** Owner of this node record. */
132
+ owner;
133
+ /** Geographic location of this node. */
134
+ location;
135
+ /** Classification type of this node. */
136
+ type;
137
+ /** Sequential number of this node within its type and location. */
138
+ num;
139
+ /** Resource limits configured for this node. */
140
+ limits;
141
+ /**
142
+ /** Direct connection details for the node daemon API. */
143
+ connection;
144
+ /** `true` when the node is in maintenance mode (no new servers will be started). */
145
+ isMaintenanceMode;
146
+ /** `true` when the node can be auto-deployed to. */
147
+ canAutoDeploy;
148
+ /** `true` when the node is behind a reverse proxy. */
149
+ isBehindProxy;
150
+ /** Internal notes visible to administrators. */
151
+ notes;
152
+ /** When this node was registered. */
153
+ createdAt;
154
+ /** When this node was last updated. */
155
+ updatedAt;
156
+ /** @internal */
157
+ constructor(data) {
158
+ super();
159
+ this.id = toNanoID(data.id);
160
+ this.name = data.name;
161
+ this.description = data.description;
162
+ this.owner = data.owner ? new Member(data.owner) : undefined;
163
+ this.location = new NodeLocation(data.location);
164
+ this.type = new NodeType(data.type);
165
+ this.num = data.num;
166
+ this.limits = {
167
+ memoryMb: data.limits.memory_mb,
168
+ memoryOverallocateMb: data.limits.memory_overallocate_mb,
169
+ diskMb: data.limits.disk_mb,
170
+ diskOverallocateMb: data.limits.disk_overallocate_mb,
171
+ uploadSizeMb: data.limits.upload_size_mb,
172
+ };
173
+ this.connection = data.connection ?? undefined;
174
+ this.isMaintenanceMode = data.is_maintenance_mode;
175
+ this.canAutoDeploy = data.can_auto_deploy;
176
+ this.isBehindProxy = data.is_behind_proxy;
177
+ this.notes = data.notes;
178
+ this.createdAt = new Date(data.created_at);
179
+ this.updatedAt = new Date(data.updated_at);
180
+ }
181
+ }
182
+ /**
183
+ * Manage allocation IPs and ports on a specific node.
184
+ */
185
+ export class NodeAllocationsManager {
186
+ nodeId;
187
+ http;
188
+ /** @internal */
189
+ constructor(nodeId, http) {
190
+ this.nodeId = nodeId;
191
+ this.http = http;
192
+ }
193
+ async list() {
194
+ const data = await this.http.get(`/nodes/${this.nodeId}/allocations`);
195
+ return data.map((allocation) => new NodeAllocationIp(allocation));
196
+ }
197
+ async get(allocationIp) {
198
+ const data = await this.http.get(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}`);
199
+ return new NodeAllocationIp(data);
200
+ }
201
+ async create(payload) {
202
+ const data = await this.http.post(`/nodes/${this.nodeId}/allocations`, {
203
+ ip: payload.ip,
204
+ ip_alias: payload.ipAlias,
205
+ notes: payload.notes,
206
+ });
207
+ return new NodeAllocationIp(data);
208
+ }
209
+ async update(allocationIp, payload) {
210
+ const data = await this.http.patch(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}`, {
211
+ ip_alias: payload.ipAlias,
212
+ notes: payload.notes,
213
+ });
214
+ return new NodeAllocationIp(data);
215
+ }
216
+ async delete(allocationIp) {
217
+ await this.http.delete(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}`);
218
+ }
219
+ async createPorts(allocationIp, payload) {
220
+ const data = await this.http.post(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}/ports`, payload);
221
+ return new NodeAllocationIp(data);
222
+ }
223
+ async updatePort(allocationIp, port, payload) {
224
+ const data = await this.http.patch(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}/ports/${port}`, payload);
225
+ return new NodeAllocationIp(data);
226
+ }
227
+ async deletePort(allocationIp, port) {
228
+ await this.http.delete(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}/ports/${port}`);
229
+ }
230
+ }
231
+ /**
232
+ * Namespace for node management.
233
+ *
234
+ * Access via `api.nodes`.
235
+ *
236
+ * @example
237
+ * ```ts ignore
238
+ * const nodes = await api.nodes.list();
239
+ * const node = await api.nodes.get(id, { includeConnection: true });
240
+ * console.log(node.connection?.url); // "http://1.2.3.4:8080"
241
+ * ```
242
+ */
243
+ export class NodesNamespace extends ResourceNamespace {
244
+ /** @internal */
245
+ constructor(http) {
246
+ super(http);
247
+ }
248
+ /**
249
+ * Fetch a paginated list of nodes.
250
+ *
251
+ * @param opts Pagination, search, and include options.
252
+ */
253
+ async list(opts = {}) {
254
+ const extra = {};
255
+ const include = joinIncludes(opts);
256
+ if (include)
257
+ extra['include'] = include;
258
+ const result = await this.http.list('/nodes', opts, extra);
259
+ const nodes = result.data.map((d) => new Node(d));
260
+ this.setCache(nodes);
261
+ return { ...result, data: nodes };
262
+ }
263
+ /**
264
+ * Fetch a single node by ID.
265
+ *
266
+ * @param id The node's NanoID.
267
+ * @param opts Include options (e.g. `{ include: ['connection'] }`).
268
+ */
269
+ async get(id, opts = {}) {
270
+ const params = {};
271
+ const include = joinIncludes(opts);
272
+ if (include)
273
+ params['include'] = include;
274
+ const data = await this.http.get(`/nodes/${id}`, { params });
275
+ return new Node(data);
276
+ }
277
+ /**
278
+ * Create a new node.
279
+ *
280
+ * @param payload Node creation parameters.
281
+ */
282
+ async create(payload) {
283
+ const body = {
284
+ fqdn: payload.fqdn,
285
+ scheme: payload.scheme,
286
+ api_port: payload.apiPort,
287
+ sftp_port: payload.sftpPort,
288
+ host_id: payload.hostId,
289
+ location_id: payload.locationId,
290
+ type_id: payload.typeId,
291
+ description: payload.description,
292
+ notes: payload.notes,
293
+ num: payload.num,
294
+ is_maintenance_mode: payload.isMaintenanceMode,
295
+ can_auto_deploy: payload.canAutoDeploy,
296
+ is_behind_proxy: payload.isBehindProxy,
297
+ limits: {
298
+ memory_mb: payload.limits.memoryMb,
299
+ memory_overallocate_mb: payload.limits.memoryOverallocateMb,
300
+ disk_mb: payload.limits.diskMb,
301
+ disk_overallocate_mb: payload.limits.diskOverallocateMb,
302
+ upload_size_mb: payload.limits.uploadSizeMb,
303
+ },
304
+ };
305
+ const data = await this.http.post('/nodes', body);
306
+ const node = new Node(data);
307
+ this.addToCache(node);
308
+ this.emit('created', node);
309
+ return node;
310
+ }
311
+ /**
312
+ * Fetch all servers deployed on a specific node.
313
+ *
314
+ * @param id The node's NanoID.
315
+ * @returns An array of minimal server data. Use `api.servers.get()` to fetch full server details.
316
+ */
317
+ async servers(id) {
318
+ const data = await this.http.get(`/nodes/${id}/servers`);
319
+ return data.map((s) => ({ id: toNanoID(s.id) }));
320
+ }
321
+ /**
322
+ * Access allocation management for a specific node.
323
+ */
324
+ allocations(id) {
325
+ return new NodeAllocationsManager(id, this.http);
326
+ }
327
+ /**
328
+ * Log activity on behalf of a node daemon.
329
+ *
330
+ * This endpoint is intended for node-authenticated clients.
331
+ */
332
+ async logActivity(entries) {
333
+ await this.http.post('/nodes/activity', {
334
+ data: entries.map((entry) => ({
335
+ user_id: entry.userId,
336
+ server_id: entry.serverId,
337
+ event: entry.event,
338
+ metadata: entry.metadata,
339
+ ip: entry.ip,
340
+ timestamp: entry.timestamp instanceof Date ? entry.timestamp.toISOString() : entry.timestamp,
341
+ })),
342
+ });
343
+ }
344
+ /**
345
+ * Create an activity log model from a raw payload.
346
+ *
347
+ * Useful when consuming activity data returned from other endpoints.
348
+ */
349
+ toActivityLog(data) {
350
+ return new ActivityLog(data);
351
+ }
352
+ }
@@ -0,0 +1,150 @@
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
+ import type { NodeData } from './nodes.js';
6
+ import { Node } from './nodes.js';
7
+ /** Resource limit values for a server group. @internal */
8
+ export interface ServerGroupLimitsData {
9
+ cpu_percent?: number | null;
10
+ ram_mb?: number | null;
11
+ swap_mb?: number | null;
12
+ storage_mb?: number | null;
13
+ backup?: number | null;
14
+ database?: number | null;
15
+ allocation?: number | null;
16
+ }
17
+ /** Raw API shape for a server group. @internal */
18
+ export interface ServerGroupData {
19
+ id: string;
20
+ /** Always present. */
21
+ node_id: string;
22
+ /** @see NodeData */
23
+ node?: NodeData;
24
+ build?: {
25
+ cpu_threads?: number | null;
26
+ io_weight?: number | null;
27
+ } | null;
28
+ limits?: ServerGroupLimitsData | null;
29
+ created_at: ISODate;
30
+ updated_at: ISODate;
31
+ }
32
+ /**
33
+ * Resource allocation limits for a server group.
34
+ *
35
+ * Each field is the maximum value allowed for all servers in the group combined.
36
+ * `null` means unlimited.
37
+ */
38
+ export interface ServerGroupLimits {
39
+ /** Maximum CPU usage percentage across all servers. */
40
+ cpuPercent: number | null | undefined;
41
+ /** Maximum RAM in megabytes across all servers. */
42
+ ramMb: number | null | undefined;
43
+ /** Maximum swap in megabytes across all servers. */
44
+ swapMb: number | null | undefined;
45
+ /** Maximum storage in megabytes across all servers. */
46
+ storageMb: number | null | undefined;
47
+ /** Maximum number of backups across all servers. */
48
+ backup: number | null | undefined;
49
+ /** Maximum number of databases across all servers. */
50
+ database: number | null | undefined;
51
+ /** Maximum number of port allocations across all servers. */
52
+ allocation: number | null | undefined;
53
+ }
54
+ /**
55
+ * A server group that ties one or more servers to a specific node with shared resource limits.
56
+ *
57
+ * Retrieved via {@link ServerGroupsNamespace.get} or {@link ServerGroupsNamespace.list}.
58
+ */
59
+ export declare class ServerGroup extends ReactiveResource {
60
+ /** The server group's unique NanoID. */
61
+ readonly id: NanoID;
62
+ /** The ID of the node this group is deployed on. Always present. */
63
+ readonly nodeId: NanoID;
64
+ /** The full node object. */
65
+ node: Node | undefined;
66
+ /** Build settings inherited by all servers in this group. */
67
+ build: {
68
+ cpuThreads: number | null | undefined;
69
+ ioWeight: number | null | undefined;
70
+ } | undefined;
71
+ /** Resource limits that apply to this group as a whole. */
72
+ limits: ServerGroupLimits | undefined;
73
+ /** When this server group was created. */
74
+ createdAt: Date;
75
+ /** When this server group was last updated. */
76
+ updatedAt: Date;
77
+ /** @internal */
78
+ constructor(data: ServerGroupData);
79
+ }
80
+ /** Payload for creating a new server group. */
81
+ export interface CreateServerGroupPayload {
82
+ /** NanoID of the node to deploy this group on. */
83
+ nodeId: NanoID;
84
+ /** Optional expiry date for the group. */
85
+ expiresAt?: Date;
86
+ /** Resource limits for this group. */
87
+ limits: {
88
+ /** Maximum RAM in megabytes. */
89
+ ramMb: number;
90
+ /** Maximum swap in megabytes. */
91
+ swapMb: number;
92
+ /** Maximum storage in megabytes. */
93
+ storageMb: number;
94
+ /** IO weight (1–1000). */
95
+ weightIo: number;
96
+ /** Maximum CPU usage percentage. */
97
+ cpuPercent: number;
98
+ /** CPU thread pinning, or `undefined` for no restriction. */
99
+ cpuThreads?: string;
100
+ /** Maximum number of backups. */
101
+ backup?: number;
102
+ /** Maximum number of databases. */
103
+ database?: number;
104
+ /** Maximum number of port allocations. */
105
+ allocation?: number;
106
+ };
107
+ }
108
+ /** Typed events emitted by {@link ServerGroupsNamespace}. */
109
+ export interface ServerGroupEvents {
110
+ /** Fired after a server group is created. */
111
+ created: ServerGroup;
112
+ }
113
+ /**
114
+ * Namespace for server group management.
115
+ *
116
+ * Access via `api.serverGroups`.
117
+ *
118
+ * @example
119
+ * ```ts ignore
120
+ * const groups = await api.serverGroups.list();
121
+ * const group = await api.serverGroups.get(id);
122
+ * const newGroup = await api.serverGroups.create({ nodeId, limits: { ramMb: 1024 } });
123
+ * ```
124
+ */
125
+ export declare class ServerGroupsNamespace extends ResourceNamespace<ServerGroup, ServerGroupEvents> {
126
+ /** @internal */
127
+ constructor(http: HttpClient);
128
+ /**
129
+ * Fetch a paginated list of server groups.
130
+ *
131
+ * @param opts Pagination and search options.
132
+ */
133
+ list(opts?: {
134
+ page?: number;
135
+ perPage?: number;
136
+ }): Promise<Paginated<ServerGroup>>;
137
+ /**
138
+ * Fetch a single server group by ID.
139
+ *
140
+ * @param id The server group's NanoID.
141
+ */
142
+ get(id: NanoID): Promise<ServerGroup>;
143
+ /**
144
+ * Create a new server group.
145
+ *
146
+ * @param payload Server group creation parameters.
147
+ */
148
+ create(payload: CreateServerGroupPayload): Promise<ServerGroup>;
149
+ }
150
+ //# sourceMappingURL=server-groups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-groups.d.ts","sourceRoot":"","sources":["../../../src/src/resources/server-groups.ts"],"names":[],"mappings":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KAAK,EAAE,MAAM,CAAC;QACd,iCAAiC;QACjC,MAAM,EAAE,MAAM,CAAC;QACf,oCAAoC;QACpC,SAAS,EAAE,MAAM,CAAC;QAClB,0BAA0B;QAC1B,QAAQ,EAAE,MAAM,CAAC;QACjB,oCAAoC;QACpC,UAAU,EAAE,MAAM,CAAC;QACnB,6DAA6D;QAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iCAAiC;QACjC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,mCAAmC;QACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,0CAA0C;QAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACF;AAED,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IACjC,6CAA6C;IAC7C,OAAO,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAsB,SAAQ,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAC3F,gBAAgB;gBACG,IAAI,EAAE,UAAU;IAInC;;;;OAIG;IACU,IAAI,CAAC,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAOlG;;;;OAIG;IACU,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAKlD;;;;OAIG;IACU,MAAM,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;CAsB5E"}
@@ -0,0 +1,111 @@
1
+ import { ResourceNamespace } from '../namespace.js';
2
+ import { ReactiveResource } from '../reactive.js';
3
+ import { toNanoID } from '../types.js';
4
+ import { Node } from './nodes.js';
5
+ /**
6
+ * A server group that ties one or more servers to a specific node with shared resource limits.
7
+ *
8
+ * Retrieved via {@link ServerGroupsNamespace.get} or {@link ServerGroupsNamespace.list}.
9
+ */
10
+ export class ServerGroup extends ReactiveResource {
11
+ /** The server group's unique NanoID. */
12
+ id;
13
+ /** The ID of the node this group is deployed on. Always present. */
14
+ nodeId;
15
+ /** The full node object. */
16
+ node;
17
+ /** Build settings inherited by all servers in this group. */
18
+ build;
19
+ /** Resource limits that apply to this group as a whole. */
20
+ limits;
21
+ /** When this server group was created. */
22
+ createdAt;
23
+ /** When this server group was last updated. */
24
+ updatedAt;
25
+ /** @internal */
26
+ constructor(data) {
27
+ super();
28
+ this.id = toNanoID(data.id);
29
+ this.nodeId = toNanoID(data.node_id);
30
+ this.node = data.node ? new Node(data.node) : undefined;
31
+ this.build = data.build ? { cpuThreads: data.build.cpu_threads, ioWeight: data.build.io_weight } : undefined;
32
+ this.limits = data.limits
33
+ ? {
34
+ cpuPercent: data.limits.cpu_percent,
35
+ ramMb: data.limits.ram_mb,
36
+ swapMb: data.limits.swap_mb,
37
+ storageMb: data.limits.storage_mb,
38
+ backup: data.limits.backup,
39
+ database: data.limits.database,
40
+ allocation: data.limits.allocation,
41
+ }
42
+ : undefined;
43
+ this.createdAt = new Date(data.created_at);
44
+ this.updatedAt = new Date(data.updated_at);
45
+ }
46
+ }
47
+ /**
48
+ * Namespace for server group management.
49
+ *
50
+ * Access via `api.serverGroups`.
51
+ *
52
+ * @example
53
+ * ```ts ignore
54
+ * const groups = await api.serverGroups.list();
55
+ * const group = await api.serverGroups.get(id);
56
+ * const newGroup = await api.serverGroups.create({ nodeId, limits: { ramMb: 1024 } });
57
+ * ```
58
+ */
59
+ export class ServerGroupsNamespace extends ResourceNamespace {
60
+ /** @internal */
61
+ constructor(http) {
62
+ super(http);
63
+ }
64
+ /**
65
+ * Fetch a paginated list of server groups.
66
+ *
67
+ * @param opts Pagination and search options.
68
+ */
69
+ async list(opts = {}) {
70
+ const result = await this.http.list('/servers/groups', opts);
71
+ const groups = result.data.map((d) => new ServerGroup(d));
72
+ this.setCache(groups);
73
+ return { ...result, data: groups };
74
+ }
75
+ /**
76
+ * Fetch a single server group by ID.
77
+ *
78
+ * @param id The server group's NanoID.
79
+ */
80
+ async get(id) {
81
+ const data = await this.http.get(`/servers/groups/${id}`);
82
+ return new ServerGroup(data);
83
+ }
84
+ /**
85
+ * Create a new server group.
86
+ *
87
+ * @param payload Server group creation parameters.
88
+ */
89
+ async create(payload) {
90
+ const body = {
91
+ node_id: payload.nodeId,
92
+ expires_at: payload.expiresAt,
93
+ limits: {
94
+ ram_mb: payload.limits.ramMb,
95
+ swap_mb: payload.limits.swapMb,
96
+ storage_mb: payload.limits.storageMb,
97
+ weight_io: payload.limits.weightIo,
98
+ cpu_percent: payload.limits.cpuPercent,
99
+ cpu_threads: payload.limits.cpuThreads,
100
+ backup: payload.limits.backup,
101
+ database: payload.limits.database,
102
+ allocation: payload.limits.allocation,
103
+ },
104
+ };
105
+ const data = await this.http.post('/servers/groups', body);
106
+ const group = new ServerGroup(data);
107
+ this.addToCache(group);
108
+ this.emit('created', group);
109
+ return group;
110
+ }
111
+ }