@meowpanel/api 0.1.0-alpha.10 → 1.0.0-beta.1

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.

Potentially problematic release.


This version of @meowpanel/api might be problematic. Click here for more details.

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 +233 -0
  7. package/esm/src/client.d.ts.map +1 -0
  8. package/esm/src/client.js +216 -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 +144 -0
  16. package/esm/src/http.d.ts.map +1 -0
  17. package/esm/src/http.js +246 -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 +39 -0
  31. package/esm/src/resources/auth.d.ts.map +1 -0
  32. package/esm/src/resources/auth.js +27 -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 +51 -0
  76. package/esm/src/sse.d.ts.map +1 -0
  77. package/esm/src/sse.js +129 -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 +233 -0
  86. package/script/src/client.d.ts.map +1 -0
  87. package/script/src/client.js +220 -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 +144 -0
  95. package/script/src/http.d.ts.map +1 -0
  96. package/script/src/http.js +250 -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 +39 -0
  110. package/script/src/resources/auth.d.ts.map +1 -0
  111. package/script/src/resources/auth.js +31 -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 +51 -0
  155. package/script/src/sse.d.ts.map +1 -0
  156. package/script/src/sse.js +133 -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,151 @@
1
+ import { ReactiveResource } from '../reactive.js';
2
+ import { joinIncludes, toNanoID } from '../types.js';
3
+ /**
4
+ * Base class for the authenticated account.
5
+ *
6
+ * Use {@link isUser} / {@link isApiKey} to narrow to the specific subclass.
7
+ */
8
+ export class Account extends ReactiveResource {
9
+ http;
10
+ id;
11
+ permissions;
12
+ createdAt;
13
+ updatedAt;
14
+ /** @internal */
15
+ constructor(data, http) {
16
+ super();
17
+ this.http = http;
18
+ this.id = toNanoID(data.id);
19
+ this.permissions = data.permissions;
20
+ this.createdAt = new Date(data.created_at);
21
+ this.updatedAt = new Date(data.updated_at);
22
+ }
23
+ isUser() {
24
+ return this.issuerType === 'user';
25
+ }
26
+ isApiKey() {
27
+ return this.issuerType === 'api_key';
28
+ }
29
+ /** @internal */
30
+ static create(data, http) {
31
+ switch (data.issuer_type) {
32
+ case 'user':
33
+ return new UserAccount(data, http);
34
+ case 'api_key':
35
+ return new ApiKeyAccount(data, http);
36
+ default:
37
+ throw new Error(`Unknown account issuer type: ${data.issuer_type}`);
38
+ }
39
+ }
40
+ }
41
+ /** A human user account. */
42
+ export class UserAccount extends Account {
43
+ issuerType = 'user';
44
+ email;
45
+ nickname;
46
+ avatarUri;
47
+ /**
48
+ * Display preferences. Populated with `include=display`.
49
+ * Requires `member.display.read` permission or being the account owner.
50
+ */
51
+ display;
52
+ /** @internal */
53
+ constructor(data, http) {
54
+ super(data, http);
55
+ this.email = data.email;
56
+ this.nickname = data.nickname;
57
+ this.avatarUri = data.avatar_uri;
58
+ this.display = data.display ?? undefined;
59
+ }
60
+ /** Update this user account in place. */
61
+ async update(payload) {
62
+ await this.http.patch('/account', payload);
63
+ const data = await this.http.get('/account');
64
+ this.email = data.email;
65
+ this.nickname = data.nickname;
66
+ this.avatarUri = data.avatar_uri;
67
+ this.display = data.display ?? undefined;
68
+ this.permissions = data.permissions;
69
+ this.createdAt = new Date(data.created_at);
70
+ this.updatedAt = new Date(data.updated_at);
71
+ this.notify();
72
+ }
73
+ /** Fetch the avatar image as a Blob. */
74
+ async fetchAvatar() {
75
+ const res = await this.http.fetch('/account/avatar', { method: 'GET' });
76
+ return await res.blob();
77
+ }
78
+ }
79
+ /** An API key credential. */
80
+ export class ApiKeyAccount extends Account {
81
+ issuerType = 'api_key';
82
+ name;
83
+ description;
84
+ ownerId;
85
+ /** The owner user. */
86
+ owner;
87
+ /** @internal */
88
+ constructor(data, http) {
89
+ super(data, http);
90
+ this.name = data.name;
91
+ this.description = data.description;
92
+ this.ownerId = toNanoID(data.owner_id);
93
+ this.owner = data.owner ? new UserAccount(data.owner, http) : undefined;
94
+ }
95
+ }
96
+ /**
97
+ * Resource for the currently authenticated account.
98
+ *
99
+ * Access via `api.account`.
100
+ *
101
+ * @example
102
+ * ```ts ignore
103
+ * const me = await api.account.get();
104
+ * if (me.isUser()) {
105
+ * console.log(me.nickname, me.email);
106
+ * await me.update({ display: { theme: 'dark' } });
107
+ * } else {
108
+ * console.log('API key:', me.name, 'owner:', me.ownerId);
109
+ * }
110
+ * ```
111
+ */
112
+ export class AccountResource {
113
+ http;
114
+ /** @internal */
115
+ constructor(http) {
116
+ this.http = http;
117
+ }
118
+ /** Fetch the currently authenticated account. */
119
+ async get(opts = {}) {
120
+ const params = {};
121
+ const include = joinIncludes(opts);
122
+ if (include)
123
+ params['include'] = include;
124
+ const data = await this.http.get('/account', { params });
125
+ return Account.create(data, this.http);
126
+ }
127
+ /** Update the current user account. Only works for user accounts. */
128
+ async update(payload) {
129
+ await this.http.patch('/account', payload);
130
+ const data = await this.http.get('/account');
131
+ return new UserAccount(data, this.http);
132
+ }
133
+ /** Upload a new avatar image. Only works for user accounts. */
134
+ async uploadAvatar(image, contentType) {
135
+ const body = image instanceof Blob ? image : new Blob([image], { type: contentType });
136
+ await this.http.fetch('/account/avatar', {
137
+ method: 'POST',
138
+ body,
139
+ headers: { 'Content-Type': contentType },
140
+ });
141
+ }
142
+ /** Fetch the current account avatar image. */
143
+ async fetchAvatar() {
144
+ const res = await this.http.fetch('/account/avatar', { method: 'GET' });
145
+ return await res.blob();
146
+ }
147
+ /** Fetch the permission scopes available to the current account. */
148
+ scopes() {
149
+ return this.http.get('/account/scopes');
150
+ }
151
+ }
@@ -0,0 +1,116 @@
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 an API key. @internal */
6
+ interface ApiKeyData {
7
+ id: string;
8
+ name: string;
9
+ description?: string | null;
10
+ /** Only returned once, at creation time. */
11
+ token?: string;
12
+ last_used_at?: ISODate | null;
13
+ created_at: ISODate;
14
+ updated_at?: ISODate;
15
+ }
16
+ /**
17
+ * An API key credential for authenticating programmatic access to the MeowPanel API.
18
+ *
19
+ * Retrieved via {@link ApiKeysNamespace.list} or {@link ApiKeysNamespace.create}.
20
+ *
21
+ * > **Note:** The `token` field is only populated when the key is first created.
22
+ * > It cannot be retrieved again after that. Store it securely.
23
+ */
24
+ export declare class ApiKey extends ReactiveResource {
25
+ /** The API key's unique NanoID. */
26
+ readonly id: NanoID;
27
+ /** Display name for this API key. */
28
+ name: string;
29
+ /** Optional description for this API key. */
30
+ description: string | null | undefined;
31
+ /**
32
+ * The bearer token value.
33
+ *
34
+ * Only populated immediately after creation via {@link ApiKeysNamespace.create}.
35
+ * `undefined` on all subsequent fetches - store it securely when first received.
36
+ */
37
+ token: string | undefined;
38
+ /** When this key was last used to authenticate a request, or `null` if never used. */
39
+ lastUsedAt: Date | null;
40
+ /** When this API key was created. */
41
+ createdAt: Date;
42
+ /** When this API key was last updated. */
43
+ updatedAt: Date | undefined;
44
+ /** @internal */
45
+ constructor(data: ApiKeyData);
46
+ }
47
+ /** Payload for creating an API key. */
48
+ export interface CreateApiKeyPayload {
49
+ /** Display name for the key. */
50
+ name: string;
51
+ /** Optional description visible in the panel. */
52
+ description?: string;
53
+ /** Permissions granted to the key. */
54
+ permissions: string[];
55
+ }
56
+ /** Result returned when creating a new API key. */
57
+ export interface CreateApiKeyResult {
58
+ /** The newly issued bearer token. Returned only once. */
59
+ token: string;
60
+ /**
61
+ * Best-effort lookup of the created key metadata from the API.
62
+ *
63
+ * This can be `null` because the create endpoint currently returns only the token,
64
+ * not the full resource representation.
65
+ */
66
+ apiKey: ApiKey | null;
67
+ }
68
+ /** Typed events emitted by {@link ApiKeysNamespace}. */
69
+ export interface ApiKeyEvents {
70
+ /** Fired after a new API key is created. Payload includes the one-time token. */
71
+ created: CreateApiKeyResult;
72
+ }
73
+ /**
74
+ * Namespace for API key management.
75
+ *
76
+ * Access via `api.apiKeys`.
77
+ *
78
+ * @example
79
+ * ```ts ignore
80
+ * // List existing API keys
81
+ * const keys = await api.apiKeys.list();
82
+ *
83
+ * // Create a new API key
84
+ * const created = await api.apiKeys.create({
85
+ * name: 'My Integration',
86
+ * permissions: ['server.read'],
87
+ * });
88
+ * console.log(created.token); // Save this - it won't be shown again!
89
+ * ```
90
+ */
91
+ export declare class ApiKeysNamespace extends ResourceNamespace<ApiKey, ApiKeyEvents> {
92
+ /** @internal */
93
+ constructor(http: HttpClient);
94
+ /**
95
+ * Fetch a paginated list of API keys for the current account.
96
+ *
97
+ * Note: the `token` field is not included in list responses.
98
+ *
99
+ * @param opts Pagination options.
100
+ */
101
+ list(opts?: {
102
+ page?: number;
103
+ perPage?: number;
104
+ }): Promise<Paginated<ApiKey>>;
105
+ /**
106
+ * Create a new API key.
107
+ *
108
+ * The returned {@link ApiKey} contains the `token` field with the full bearer token value.
109
+ * This is the **only** time the token is returned by the API - store it securely.
110
+ *
111
+ * @param name A descriptive name for the key, e.g. `"CI/CD Pipeline"`.
112
+ */
113
+ create(payload: CreateApiKeyPayload): Promise<CreateApiKeyResult>;
114
+ }
115
+ export {};
116
+ //# sourceMappingURL=api-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../../src/src/resources/api-keys.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,8CAA8C;AAC9C,UAAU,UAAU;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAQD;;;;;;;GAOG;AACH,qBAAa,MAAO,SAAQ,gBAAgB;IAC3C,mCAAmC;IACnC,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,qCAAqC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACpB,6CAA6C;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C;;;;;OAKG;IACI,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,sFAAsF;IAC/E,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,qCAAqC;IAC9B,SAAS,EAAE,IAAI,CAAC;IACvB,0CAA0C;IACnC,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IAEnC,gBAAgB;gBACG,IAAI,EAAE,UAAU;CAUnC;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IACnC,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,mDAAmD;AACnD,MAAM,WAAW,kBAAkB;IAClC,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC5B,iFAAiF;IACjF,OAAO,EAAE,kBAAkB,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,MAAM,EAAE,YAAY,CAAC;IAC5E,gBAAgB;gBACG,IAAI,EAAE,UAAU;IAInC;;;;;;OAMG;IACU,IAAI,CAChB,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAO,GAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAO7B;;;;;;;OAOG;IACU,MAAM,CAClB,OAAO,EAAE,mBAAmB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;CAuB9B"}
@@ -0,0 +1,105 @@
1
+ import { ResourceNamespace } from '../namespace.js';
2
+ import { ReactiveResource } from '../reactive.js';
3
+ import { toNanoID } from '../types.js';
4
+ /**
5
+ * An API key credential for authenticating programmatic access to the MeowPanel API.
6
+ *
7
+ * Retrieved via {@link ApiKeysNamespace.list} or {@link ApiKeysNamespace.create}.
8
+ *
9
+ * > **Note:** The `token` field is only populated when the key is first created.
10
+ * > It cannot be retrieved again after that. Store it securely.
11
+ */
12
+ export class ApiKey extends ReactiveResource {
13
+ /** The API key's unique NanoID. */
14
+ id;
15
+ /** Display name for this API key. */
16
+ name;
17
+ /** Optional description for this API key. */
18
+ description;
19
+ /**
20
+ * The bearer token value.
21
+ *
22
+ * Only populated immediately after creation via {@link ApiKeysNamespace.create}.
23
+ * `undefined` on all subsequent fetches - store it securely when first received.
24
+ */
25
+ token;
26
+ /** When this key was last used to authenticate a request, or `null` if never used. */
27
+ lastUsedAt;
28
+ /** When this API key was created. */
29
+ createdAt;
30
+ /** When this API key was last updated. */
31
+ updatedAt;
32
+ /** @internal */
33
+ constructor(data) {
34
+ super();
35
+ this.id = toNanoID(data.id);
36
+ this.name = data.name;
37
+ this.description = data.description;
38
+ this.token = data.token;
39
+ this.lastUsedAt = data.last_used_at ? new Date(data.last_used_at) : null;
40
+ this.createdAt = new Date(data.created_at);
41
+ this.updatedAt = data.updated_at ? new Date(data.updated_at) : undefined;
42
+ }
43
+ }
44
+ /**
45
+ * Namespace for API key management.
46
+ *
47
+ * Access via `api.apiKeys`.
48
+ *
49
+ * @example
50
+ * ```ts ignore
51
+ * // List existing API keys
52
+ * const keys = await api.apiKeys.list();
53
+ *
54
+ * // Create a new API key
55
+ * const created = await api.apiKeys.create({
56
+ * name: 'My Integration',
57
+ * permissions: ['server.read'],
58
+ * });
59
+ * console.log(created.token); // Save this - it won't be shown again!
60
+ * ```
61
+ */
62
+ export class ApiKeysNamespace extends ResourceNamespace {
63
+ /** @internal */
64
+ constructor(http) {
65
+ super(http);
66
+ }
67
+ /**
68
+ * Fetch a paginated list of API keys for the current account.
69
+ *
70
+ * Note: the `token` field is not included in list responses.
71
+ *
72
+ * @param opts Pagination options.
73
+ */
74
+ async list(opts = {}) {
75
+ const result = await this.http.list('/api-keys', opts);
76
+ const keys = result.data.map((d) => new ApiKey(d));
77
+ this.setCache(keys);
78
+ return { ...result, data: keys };
79
+ }
80
+ /**
81
+ * Create a new API key.
82
+ *
83
+ * The returned {@link ApiKey} contains the `token` field with the full bearer token value.
84
+ * This is the **only** time the token is returned by the API - store it securely.
85
+ *
86
+ * @param name A descriptive name for the key, e.g. `"CI/CD Pipeline"`.
87
+ */
88
+ async create(payload) {
89
+ const data = await this.http.post('/api-keys', payload);
90
+ // The create endpoint returns only the one-time token, not the full resource.
91
+ // We re-list and match by name to hydrate the ApiKey instance. This is best-effort:
92
+ // if matching is ambiguous (multiple keys with the same name), `apiKey` may be wrong.
93
+ const listed = await this.list({ perPage: 100 });
94
+ const apiKey = [...listed.data]
95
+ .filter((key) => key.name === payload.name)
96
+ .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())[0] ??
97
+ null;
98
+ const created = {
99
+ token: data.key,
100
+ apiKey,
101
+ };
102
+ this.emit('created', created);
103
+ return created;
104
+ }
105
+ }
@@ -0,0 +1,39 @@
1
+ import type { HttpClient } from '../http.js';
2
+ /**
3
+ * A single authentication provider and its display configuration.
4
+ */
5
+ export interface AuthProvider {
6
+ /** Provider-specific display fields, e.g. `{ display_name: 'WHMCS' }`. */
7
+ fields: Record<string, string>;
8
+ }
9
+ /**
10
+ * Metadata about the panel's authentication configuration.
11
+ */
12
+ export interface AuthMeta {
13
+ /** Available auth providers keyed by provider ID (e.g. `'email'`, `'whmcs'`). */
14
+ providers: Record<string, AuthProvider>;
15
+ }
16
+ /**
17
+ * Resource for authentication configuration.
18
+ *
19
+ * Access via `api.auth`.
20
+ *
21
+ * @example
22
+ * ```ts ignore
23
+ * const { providers } = await api.auth.getMeta();
24
+ * if (providers.email) console.log('Email login available');
25
+ * if (providers.whmcs) console.log('WHMCS:', providers.whmcs.fields.display_name);
26
+ * ```
27
+ */
28
+ export declare class AuthResource {
29
+ private readonly http;
30
+ /** @internal */
31
+ constructor(http: HttpClient);
32
+ /**
33
+ * Fetch the panel's authentication configuration.
34
+ *
35
+ * Returns the available login providers and their display fields.
36
+ */
37
+ getMeta(): Promise<AuthMeta>;
38
+ }
39
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/src/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS7C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;IAEL,OAAO,CAAC,QAAQ,CAAC,IAAI;IADxC,gBAAgB;gBACoB,IAAI,EAAE,UAAU;IAEpD;;;;OAIG;IACI,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;CAGnC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Resource for authentication configuration.
3
+ *
4
+ * Access via `api.auth`.
5
+ *
6
+ * @example
7
+ * ```ts ignore
8
+ * const { providers } = await api.auth.getMeta();
9
+ * if (providers.email) console.log('Email login available');
10
+ * if (providers.whmcs) console.log('WHMCS:', providers.whmcs.fields.display_name);
11
+ * ```
12
+ */
13
+ export class AuthResource {
14
+ http;
15
+ /** @internal */
16
+ constructor(http) {
17
+ this.http = http;
18
+ }
19
+ /**
20
+ * Fetch the panel's authentication configuration.
21
+ *
22
+ * Returns the available login providers and their display fields.
23
+ */
24
+ getMeta() {
25
+ return this.http.get('/auth');
26
+ }
27
+ }
@@ -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