@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,199 @@
1
+ import type { ISODate, NanoID, PowerState, ServerRestrictedState, SftpPermission } from '../../types.js';
2
+ import type { EggData } from '../eggs.js';
3
+ import type { MemberData } from '../members.js';
4
+ import type { ServerGroupData } from '../server-groups.js';
5
+ /** A single egg environment variable and its value for a server. @internal */
6
+ export interface StartupVariableData {
7
+ name: string;
8
+ description: string;
9
+ value: string;
10
+ default: string;
11
+ /** Laravel validation rules string. */
12
+ rules: string;
13
+ }
14
+ /** Raw API shape for server status/utilization from the node. @internal */
15
+ export interface ServerStatusData {
16
+ state: PowerState;
17
+ utilization?: {
18
+ memory_bytes: number;
19
+ memory_limit_bytes: number;
20
+ cpu_absolute: number;
21
+ network: {
22
+ rx_bytes: number;
23
+ tx_bytes: number;
24
+ };
25
+ uptime: number;
26
+ disk_bytes: number;
27
+ } | null;
28
+ }
29
+ /** Raw API shape for server build configuration. @internal */
30
+ export interface ServerBuildData {
31
+ cpu_threads?: number | null;
32
+ io_weight?: number | null;
33
+ oom_type?: string | null;
34
+ skip_install_scripts?: boolean;
35
+ limits?: {
36
+ cpu_percent?: number | null;
37
+ ram_mb?: number | null;
38
+ swap_mb?: number | null;
39
+ storage_mb?: number | null;
40
+ allocation?: number | null;
41
+ database?: number | null;
42
+ backup?: number | null;
43
+ } | null;
44
+ }
45
+ /** Raw API shape for a single allocation port record. @internal */
46
+ export interface ServerAllocationPortData {
47
+ id: string;
48
+ description?: string | null;
49
+ port_id?: string;
50
+ meta?: {
51
+ id: string;
52
+ ip: string;
53
+ port: number;
54
+ ready_protocols?: string[];
55
+ is_in_use?: boolean;
56
+ notes?: string | null;
57
+ created_at: ISODate;
58
+ updated_at: ISODate;
59
+ } | null;
60
+ is_primary: boolean;
61
+ created_at: ISODate;
62
+ updated_at: ISODate;
63
+ }
64
+ /** Raw API shape for the full allocations block. @internal */
65
+ export interface ServerAllocationsData {
66
+ force_outgoing_ip?: boolean;
67
+ primary_id?: string | null;
68
+ ports: ServerAllocationPortData[];
69
+ }
70
+ /** Raw API shape for a server profile. @internal */
71
+ export interface ServerProfileData {
72
+ id: string;
73
+ name: string;
74
+ description?: string | null;
75
+ notes?: string | null;
76
+ folder?: string | null;
77
+ is_active: boolean;
78
+ created_at: ISODate;
79
+ updated_at: ISODate;
80
+ }
81
+ /** Raw API shape for an activity log job log entry. @internal */
82
+ export interface ActivityJobLogData {
83
+ type: string;
84
+ metadata: Record<string, unknown>;
85
+ created_at: ISODate;
86
+ }
87
+ /** Raw API shape for an activity job. @internal */
88
+ export interface ActivityJobData {
89
+ id: string;
90
+ status: 'in_progress' | 'completed' | 'failed';
91
+ logs: ActivityJobLogData[];
92
+ completed_at: ISODate | null;
93
+ created_at: ISODate;
94
+ updated_at: ISODate;
95
+ }
96
+ /** Raw API shape for an activity log entry. @internal */
97
+ export interface ActivityLogData {
98
+ id: string;
99
+ event: string;
100
+ server_id?: string | null;
101
+ node_id?: string | null;
102
+ issuer_id?: string | null;
103
+ issuer?: MemberData | null;
104
+ ip?: string | null;
105
+ metadata: Record<string, unknown>;
106
+ job_id?: string | null;
107
+ job?: ActivityJobData | null;
108
+ created_at: ISODate;
109
+ }
110
+ /** Raw API shape for an SFTP user. @internal */
111
+ export interface SftpUserData {
112
+ id: string;
113
+ name: string;
114
+ username: string;
115
+ /** Only returned once at creation time. */
116
+ password?: string;
117
+ paths: Record<string, SftpPermission[]>;
118
+ owner_id: string;
119
+ owner?: MemberData | null;
120
+ last_login_at: ISODate | null;
121
+ created_at: ISODate;
122
+ updated_at: ISODate;
123
+ }
124
+ /** Raw API shape for the SFTP connection + users block. @internal */
125
+ export interface SftpDetailsData {
126
+ connection: {
127
+ url: string;
128
+ fqdn: string;
129
+ port: number;
130
+ };
131
+ users: SftpUserData[];
132
+ }
133
+ /** Raw API shape for a file or directory entry from the Whisker node. @internal */
134
+ export interface FileEntryData {
135
+ name: string;
136
+ created: ISODate;
137
+ modified: ISODate;
138
+ mode: string;
139
+ mode_bits: string;
140
+ size: number;
141
+ type: 'file' | 'directory';
142
+ symlink: boolean;
143
+ mime: string;
144
+ }
145
+ /** Raw API shape for a directory listing from the Whisker node. @internal */
146
+ export interface DirectoryListingData {
147
+ entries: FileEntryData[];
148
+ }
149
+ /** Raw API shape for a server. @internal */
150
+ export interface ServerData {
151
+ id: string;
152
+ name: string;
153
+ description: string | null;
154
+ notes?: string | null;
155
+ restricted_state: ServerRestrictedState;
156
+ group_id: string;
157
+ group?: ServerGroupData;
158
+ egg_id: string;
159
+ egg?: EggData;
160
+ egg_image_id?: string;
161
+ egg_image?: {
162
+ id: string;
163
+ image: string;
164
+ };
165
+ egg_image_override?: string | null;
166
+ status?: ServerStatusData | null;
167
+ build?: ServerBuildData | null;
168
+ startup?: {
169
+ command: string;
170
+ variables: Record<string, StartupVariableData>;
171
+ } | null;
172
+ allocations?: ServerAllocationsData | null;
173
+ profiles?: ServerProfileData[] | null;
174
+ created_at: ISODate;
175
+ updated_at: ISODate;
176
+ }
177
+ /** Payload for updating an existing server. All fields are optional. */
178
+ export interface UpdateServerPayload {
179
+ /** New display name. */
180
+ name?: string;
181
+ /** New description, or `null` to clear. */
182
+ description?: string | null;
183
+ /** New internal notes, or `null` to clear. */
184
+ notes?: string | null;
185
+ /** Reassign the primary port allocation. */
186
+ allocationPrimary?: {
187
+ ip: string;
188
+ port: number;
189
+ };
190
+ /** Update startup command and/or environment variables. */
191
+ startup?: {
192
+ /** New startup command override, or `null` to reset to the egg default. */
193
+ command?: string | null;
194
+ /** Map of env variable keys to new values (or `null` to reset to default). */
195
+ variables?: Record<string, string | null>;
196
+ };
197
+ }
198
+ export type { ISODate, NanoID, PowerState, ServerRestrictedState, SftpPermission };
199
+ //# sourceMappingURL=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C1C,CAAC;CACF;AAED,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,53 @@
1
+ /** State of an {@link SseConnection}. */
2
+ export type SseState = 'disconnected' | 'connecting' | 'connected' | 'error';
3
+ /**
4
+ * A generic, `fetch`-based Server-Sent Events client.
5
+ *
6
+ * Unlike the browser's native `EventSource`, this implementation sends an `Authorization`
7
+ * header, making it compatible with bearer token auth in all environments
8
+ * (browser, Deno, Node.js).
9
+ *
10
+ * @example
11
+ * ```ts ignore
12
+ * const sse = new SseConnection('https://panel.example.com/v1/sse', token);
13
+ * sse.connect(
14
+ * (event, data) => console.log(event, data),
15
+ * (err) => console.error('SSE error:', err),
16
+ * );
17
+ * // Later...
18
+ * sse.disconnect();
19
+ * ```
20
+ */
21
+ export declare class SseConnection {
22
+ private readonly url;
23
+ private token;
24
+ private abortController?;
25
+ private _state;
26
+ /**
27
+ * @param url The full URL to connect to.
28
+ * @param token Bearer token used in the `Authorization` header.
29
+ */
30
+ constructor(url: string, token: string);
31
+ /** Update the bearer token for subsequent reconnections. */
32
+ updateToken(token: string): void;
33
+ /** Current connection state. */
34
+ get state(): SseState;
35
+ /** `true` when the connection is actively open. */
36
+ get isConnected(): boolean;
37
+ /**
38
+ * Open the SSE connection and begin streaming events.
39
+ *
40
+ * This method is **non-blocking**: it starts the connection and returns immediately
41
+ * after the HTTP response headers are received. Events are delivered asynchronously
42
+ * via the `onEvent` callback.
43
+ *
44
+ * @param onEvent Callback invoked for each received SSE event, with the event name and raw data string.
45
+ * @param onError Optional callback invoked if the connection fails or is lost (not called on intentional disconnect).
46
+ */
47
+ connect(onEvent: (event: string, data: string) => void, onError?: (error: Error) => void): void;
48
+ /** Close the SSE connection and stop receiving events. */
49
+ disconnect(): void;
50
+ /** Parse the raw `ReadableStream` body into SSE frames, calling `onEvent` for each complete frame. */
51
+ private readStream;
52
+ }
53
+ //# sourceMappingURL=sse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/src/sse.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAE7E;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAa;IASxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,KAAK;IATd,OAAO,CAAC,eAAe,CAAC,CAAkB;IAC1C,OAAO,CAAC,MAAM,CAA4B;IAE1C;;;OAGG;gBAEe,GAAG,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM;IAGtB,4DAA4D;IACrD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIvC,gCAAgC;IAChC,IAAW,KAAK,IAAI,QAAQ,CAE3B;IAED,mDAAmD;IACnD,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED;;;;;;;;;OASG;IACI,OAAO,CACb,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,EAC9C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAC9B,IAAI;IAyCP,0DAA0D;IACnD,UAAU,IAAI,IAAI;IAMzB,sGAAsG;YACxF,UAAU;CAmCxB"}
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SseConnection = void 0;
4
+ /**
5
+ * A generic, `fetch`-based Server-Sent Events client.
6
+ *
7
+ * Unlike the browser's native `EventSource`, this implementation sends an `Authorization`
8
+ * header, making it compatible with bearer token auth in all environments
9
+ * (browser, Deno, Node.js).
10
+ *
11
+ * @example
12
+ * ```ts ignore
13
+ * const sse = new SseConnection('https://panel.example.com/v1/sse', token);
14
+ * sse.connect(
15
+ * (event, data) => console.log(event, data),
16
+ * (err) => console.error('SSE error:', err),
17
+ * );
18
+ * // Later...
19
+ * sse.disconnect();
20
+ * ```
21
+ */
22
+ class SseConnection {
23
+ url;
24
+ token;
25
+ abortController;
26
+ _state = 'disconnected';
27
+ /**
28
+ * @param url The full URL to connect to.
29
+ * @param token Bearer token used in the `Authorization` header.
30
+ */
31
+ constructor(url, token) {
32
+ this.url = url;
33
+ this.token = token;
34
+ }
35
+ /** Update the bearer token for subsequent reconnections. */
36
+ updateToken(token) {
37
+ this.token = token;
38
+ }
39
+ /** Current connection state. */
40
+ get state() {
41
+ return this._state;
42
+ }
43
+ /** `true` when the connection is actively open. */
44
+ get isConnected() {
45
+ return this._state === 'connected';
46
+ }
47
+ /**
48
+ * Open the SSE connection and begin streaming events.
49
+ *
50
+ * This method is **non-blocking**: it starts the connection and returns immediately
51
+ * after the HTTP response headers are received. Events are delivered asynchronously
52
+ * via the `onEvent` callback.
53
+ *
54
+ * @param onEvent Callback invoked for each received SSE event, with the event name and raw data string.
55
+ * @param onError Optional callback invoked if the connection fails or is lost (not called on intentional disconnect).
56
+ */
57
+ connect(onEvent, onError) {
58
+ this.disconnect();
59
+ this._state = 'connecting';
60
+ const controller = new AbortController();
61
+ this.abortController = controller;
62
+ (async () => {
63
+ try {
64
+ const response = await globalThis.fetch(this.url, {
65
+ headers: {
66
+ 'Authorization': `Bearer ${this.token}`,
67
+ 'Accept': 'text/event-stream',
68
+ 'Cache-Control': 'no-cache',
69
+ },
70
+ signal: controller.signal,
71
+ });
72
+ // Guard against a concurrent connect() that replaced our controller.
73
+ if (this.abortController !== controller)
74
+ return;
75
+ if (!response.ok || !response.body) {
76
+ throw new Error(`SSE connection failed: HTTP ${response.status}`);
77
+ }
78
+ this._state = 'connected';
79
+ await this.readStream(response.body, onEvent);
80
+ }
81
+ catch (err) {
82
+ if (err.name !== 'AbortError') {
83
+ // Only update state if this is still the active connection.
84
+ if (this.abortController !== controller)
85
+ return;
86
+ this._state = 'error';
87
+ onError?.(err instanceof Error ? err : new Error(String(err)));
88
+ return;
89
+ }
90
+ }
91
+ if (this.abortController === controller) {
92
+ this._state = 'disconnected';
93
+ }
94
+ })();
95
+ }
96
+ /** Close the SSE connection and stop receiving events. */
97
+ disconnect() {
98
+ this.abortController?.abort();
99
+ this.abortController = undefined;
100
+ this._state = 'disconnected';
101
+ }
102
+ /** Parse the raw `ReadableStream` body into SSE frames, calling `onEvent` for each complete frame. */
103
+ async readStream(body, onEvent) {
104
+ const reader = body.getReader();
105
+ const decoder = new TextDecoder();
106
+ let buffer = '';
107
+ let eventName = 'message';
108
+ let eventData = '';
109
+ try {
110
+ while (true) {
111
+ const { done, value } = await reader.read();
112
+ if (done)
113
+ break;
114
+ buffer += decoder.decode(value, { stream: true });
115
+ const lines = buffer.split('\n');
116
+ buffer = lines.pop() ?? '';
117
+ for (const line of lines) {
118
+ if (line.startsWith('event:')) {
119
+ eventName = line.slice(6).trim();
120
+ }
121
+ else if (line.startsWith('data:')) {
122
+ eventData += (eventData ? '\n' : '') + line.slice(5).trim();
123
+ }
124
+ else if (line === '' && eventData) {
125
+ onEvent(eventName, eventData);
126
+ eventName = 'message';
127
+ eventData = '';
128
+ }
129
+ }
130
+ }
131
+ }
132
+ finally {
133
+ reader.releaseLock();
134
+ }
135
+ }
136
+ }
137
+ exports.SseConnection = SseConnection;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * A 12-character NanoID string used as the primary identifier for all MeowPanel resources.
3
+ *
4
+ * Branded to prevent accidental assignment of arbitrary strings where typed IDs are expected.
5
+ *
6
+ * @example
7
+ * ```ts ignore
8
+ * const id: NanoID = toNanoID('abc123def456');
9
+ * ```
10
+ */
11
+ export type NanoID = string & {
12
+ readonly __nanoid: unique symbol;
13
+ };
14
+ /**
15
+ * Cast a raw string from the API to a {@link NanoID}.
16
+ *
17
+ * Only use this when you can guarantee the string is a valid NanoID
18
+ * (i.e., it came directly from an API response).
19
+ *
20
+ * @param raw The raw ID string from an API response.
21
+ */
22
+ export declare function toNanoID(raw: string): NanoID;
23
+ /** ISO 8601 date-time string as returned by the MeowPanel API, e.g. `"2024-01-15T12:00:00.000Z"`. */
24
+ export type ISODate = string;
25
+ /** Options for paginated list requests. */
26
+ export interface ListOptions {
27
+ /** Page number (1-based). Defaults to 1. */
28
+ page?: number;
29
+ /** Number of items per page. Defaults to the server default. */
30
+ perPage?: number;
31
+ /** Full-text search or filter string. */
32
+ search?: string;
33
+ }
34
+ /**
35
+ * A paginated list of resources returned by a list endpoint.
36
+ *
37
+ * @template T The resource type returned in the list.
38
+ */
39
+ export interface Paginated<T> {
40
+ /** Resources on the current page. */
41
+ data: T[];
42
+ /** Total number of resources matching the query across all pages. */
43
+ total: number;
44
+ /** Current page number (1-based). */
45
+ page: number;
46
+ /** Number of items per page. */
47
+ perPage: number;
48
+ }
49
+ /** Helper: merge a union of object types into a single intersection. */
50
+ export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
51
+ /**
52
+ * Narrows a resource type `T` by intersecting it with the guaranteed fields
53
+ * from `IncludeMap` for each requested include key.
54
+ *
55
+ * @typeParam T - The base resource type.
56
+ * @typeParam IncludeMap - Maps each include key to the fields it guarantees.
57
+ * @typeParam I - Tuple of requested include keys.
58
+ *
59
+ * @example
60
+ * ```ts ignore
61
+ * type ServerWith<I> = ResourceWith<Server, ServerIncludeMap, I>;
62
+ * ```
63
+ */
64
+ export type ResourceWith<T, IncludeMap, I extends readonly (keyof IncludeMap)[] = []> = T & UnionToIntersection<I[number] extends infer K ? K extends keyof IncludeMap ? IncludeMap[K] : never : never>;
65
+ /**
66
+ * Options for selecting which related data to include in a resource response.
67
+ *
68
+ * @typeParam Include - The union of valid type-safe include keys for the resource.
69
+ * @typeParam I - Tuple of requested include keys (inferred from usage).
70
+ */
71
+ export interface IncludeOptions<Include extends string, I extends readonly Include[] = []> {
72
+ /**
73
+ * Type-safe include keys. Each key guarantees the corresponding field
74
+ * on the returned resource is populated (non-undefined).
75
+ */
76
+ include?: I;
77
+ /**
78
+ * Additional include keys forwarded to the API without type narrowing.
79
+ *
80
+ * Use this for nested or less common includes that the type system doesn't
81
+ * track. The fields will be populated by the API but typed as optional.
82
+ */
83
+ rawInclude?: string[];
84
+ }
85
+ /**
86
+ * Joins the `include` and `rawInclude` arrays into a single comma-separated string
87
+ * suitable for the `?include=` query parameter.
88
+ *
89
+ * @returns The joined string, or `undefined` if there are no includes.
90
+ */
91
+ export declare function joinIncludes(opts: {
92
+ include?: readonly string[];
93
+ rawInclude?: string[];
94
+ }): string | undefined;
95
+ /**
96
+ * A power control signal that can be sent to a server.
97
+ *
98
+ * - `start` – Start the server process.
99
+ * - `stop` – Send the configured stop command to the server.
100
+ * - `restart` – Stop and then start the server.
101
+ * - `kill` – Forcefully terminate the server process immediately.
102
+ */
103
+ export type PowerSignal = 'start' | 'stop' | 'restart' | 'kill';
104
+ /**
105
+ * The real-time operational power state of a server, as reported by its host node.
106
+ *
107
+ * - `online` – Server is running normally.
108
+ * - `offline` – Server is stopped.
109
+ * - `starting` – Server is in the process of starting.
110
+ * - `stopping` – Server is in the process of stopping.
111
+ * - `error` – Server encountered an error state.
112
+ * - `connecting` – The client is establishing a connection to the node.
113
+ */
114
+ export type PowerState = 'online' | 'offline' | 'starting' | 'stopping' | 'error' | 'connecting';
115
+ /**
116
+ * The restricted/operation state of a server as tracked by Nexus.
117
+ *
118
+ * When set, this overrides the node power state for display purposes.
119
+ * `null` means the server is in a normal operational state.
120
+ */
121
+ export type ServerRestrictedState = 'installing' | 'install_failed' | 'restoring_backup' | 'maintenance' | 'transferring' | 'restricted' | 'expired' | 'overdue' | null;
122
+ /**
123
+ * An SFTP permission scope that can be assigned to a path pattern for an SFTP user.
124
+ */
125
+ export type SftpPermission = 'sftp.content.list' | 'sftp.content.read' | 'sftp.content.create' | 'sftp.content.manage' | 'sftp.content.delete';
126
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+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AAU,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,CACtF,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE;IACxF;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,MAAM,GAAG,SAAS,CAG7G;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhE;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,YAAY,CAAC;AAEjG;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAC9B,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,aAAa,GACb,cAAc,GACd,YAAY,GACZ,SAAS,GACT,SAAS,GACT,IAAI,CAAC;AAER;;GAEG;AACH,MAAM,MAAM,cAAc,GACvB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,GACrB,qBAAqB,GACrB,qBAAqB,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toNanoID = toNanoID;
4
+ exports.joinIncludes = joinIncludes;
5
+ /**
6
+ * Cast a raw string from the API to a {@link NanoID}.
7
+ *
8
+ * Only use this when you can guarantee the string is a valid NanoID
9
+ * (i.e., it came directly from an API response).
10
+ *
11
+ * @param raw The raw ID string from an API response.
12
+ */
13
+ function toNanoID(raw) {
14
+ return raw;
15
+ }
16
+ /**
17
+ * Joins the `include` and `rawInclude` arrays into a single comma-separated string
18
+ * suitable for the `?include=` query parameter.
19
+ *
20
+ * @returns The joined string, or `undefined` if there are no includes.
21
+ */
22
+ function joinIncludes(opts) {
23
+ const parts = [...(opts.include ?? []), ...(opts.rawInclude ?? [])];
24
+ return parts.length ? parts.join(',') : undefined;
25
+ }
package/esm/api.d.ts DELETED
@@ -1,76 +0,0 @@
1
- import { AuthApi } from './components/auth.js';
2
- import { ServerGroup } from './components/group.js';
3
- import { Member, type MemberInclude } from './components/member_2.js';
4
- import { Node, type NodeInclude } from './components/node.js';
5
- import { Server, type ServerInclude } from './components/server/server.js';
6
- import { type EventFunction, EventManager, type EventManagerListener } from './utils/event.js';
7
- export declare class ApiError extends Error {
8
- readonly error: string;
9
- readonly status: number;
10
- constructor(response: Response, error: string);
11
- }
12
- export interface MainEvents {
13
- error: ApiError;
14
- }
15
- export interface MeowPanelApiRequestData {
16
- body?: Record<string, unknown> | FormData | ArrayBuffer | string;
17
- params?: Record<string, string | undefined>;
18
- }
19
- export declare class MeowPanelApi implements EventManagerListener<MainEvents> {
20
- private static isPlainJson;
21
- protected readonly url: string | URL;
22
- protected readonly token: string | undefined;
23
- protected readonly fetch: typeof fetch;
24
- protected readonly eventManager: EventManager<MainEvents>;
25
- on<K extends keyof MainEvents>(event: K, func: EventFunction<MainEvents, K>): number;
26
- off<K extends keyof MainEvents>(event: K, func: number | EventFunction<MainEvents, K>): boolean;
27
- requestUrl(method: string, url: URL | string, data?: MeowPanelApiRequestData): Promise<Response>;
28
- request<T>(method: string, endpoint: `/${string}`, init?: {
29
- body?: Record<string, unknown>;
30
- pagination?: Pagination;
31
- params?: Record<string, string | undefined>;
32
- }): Promise<ApiResponse<T>>;
33
- constructor(options: Options);
34
- /**
35
- * Fetches the current logged in account
36
- */
37
- me(include?: MemberInclude[]): Promise<Member>;
38
- readonly members: {
39
- list: (pagination: Pagination) => Promise<{
40
- data: Member[];
41
- page: Page | undefined;
42
- }>;
43
- get: (id: string) => Promise<Member>;
44
- };
45
- readonly getNode: (id: string, include?: NodeInclude[]) => Promise<Node>;
46
- readonly getServers: (page: number, include?: ServerInclude[], query?: string) => Promise<{
47
- servers: Server[];
48
- page: Page;
49
- }>;
50
- readonly getServer: (id: string, include?: ServerInclude[]) => Promise<Server>;
51
- readonly getServerGroups: (page: number) => Promise<{
52
- groups: ServerGroup[];
53
- page: Page;
54
- }>;
55
- readonly getServerGroup: (id: string) => Promise<ServerGroup>;
56
- readonly auth: AuthApi;
57
- }
58
- export interface Options {
59
- url: string | URL;
60
- token?: string;
61
- fetch?: typeof fetch;
62
- }
63
- export interface ApiResponse<T> {
64
- data: T;
65
- page?: Page;
66
- }
67
- export interface Pagination {
68
- page: number;
69
- perPage?: number;
70
- }
71
- export interface Page {
72
- total: number;
73
- from: number;
74
- to: number;
75
- }
76
- //# sourceMappingURL=api.d.ts.map
package/esm/api.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE/F,qBAAa,QAAS,SAAQ,KAAK;aAKjB,KAAK,EAAE,MAAM;IAJ9B,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAG9B,QAAQ,EAAE,QAAQ,EACF,KAAK,EAAE,MAAM;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