@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,120 @@
1
+ import type { HttpClient } from '../../http.js';
2
+ import { ReactiveResource } from '../../reactive.js';
3
+ import type { ListOptions, NanoID, Paginated } from '../../types.js';
4
+ import { Member } from '../members.js';
5
+ import type { ActivityJobData, ActivityJobLogData, ActivityLogData } from './types.js';
6
+ /**
7
+ * A single log entry within an {@link ActivityJob}.
8
+ */
9
+ export declare class ActivityJobLog {
10
+ /** The type of log event, e.g. `"info"`, `"error"`. */
11
+ readonly type: string;
12
+ /** Structured metadata about this log event. */
13
+ readonly metadata: Record<string, unknown>;
14
+ /** When this log entry was created. */
15
+ readonly createdAt: Date;
16
+ /** @internal */
17
+ constructor(data: ActivityJobLogData);
18
+ }
19
+ /**
20
+ * An asynchronous background job associated with a server activity.
21
+ *
22
+ * Jobs represent long-running operations (e.g. installing a server, restoring a backup)
23
+ * and may contain multiple {@link ActivityJobLog} entries.
24
+ */
25
+ export declare class ActivityJob extends ReactiveResource {
26
+ /** The job's unique NanoID. */
27
+ readonly id: NanoID;
28
+ /** Current job status. */
29
+ status: 'in_progress' | 'completed' | 'failed';
30
+ /** Log entries produced by this job, in chronological order. */
31
+ logs: ActivityJobLog[];
32
+ /** When the job completed (or failed), or `null` if still in progress. */
33
+ completedAt: Date | null;
34
+ /** When this job was created. */
35
+ createdAt: Date;
36
+ /** When this job was last updated. */
37
+ updatedAt: Date;
38
+ /** @internal */
39
+ constructor(data: ActivityJobData);
40
+ /** `true` if the job is still running. */
41
+ get isInProgress(): boolean;
42
+ /** `true` if the job finished successfully. */
43
+ get isCompleted(): boolean;
44
+ /** `true` if the job encountered an error. */
45
+ get isFailed(): boolean;
46
+ }
47
+ /**
48
+ * An audit log entry recording an action performed on a server.
49
+ *
50
+ * Activities track all significant operations (power signals, file edits, permission changes, etc.)
51
+ * and optionally reference an async {@link ActivityJob}.
52
+ */
53
+ export declare class ActivityLog extends ReactiveResource {
54
+ /** The activity log entry's unique NanoID. */
55
+ readonly id: NanoID;
56
+ /** The event type identifier, e.g. `"server.power.start"`. */
57
+ event: string;
58
+ /** NanoID of the server this activity is associated with, if any. */
59
+ serverId: NanoID | null;
60
+ /** NanoID of the node this activity is associated with, if any. */
61
+ nodeId: NanoID | null;
62
+ /** NanoID of the issuer (user or API key) who triggered this activity, or `null` for system. */
63
+ issuerId: NanoID | null;
64
+ /** The member who triggered this activity. */
65
+ issuer: Member | null | undefined;
66
+ /** The IP address the action was performed from, if available. */
67
+ ip: string | null | undefined;
68
+ /** Structured metadata about this activity (content depends on the event type). */
69
+ metadata: Record<string, unknown>;
70
+ /** NanoID of the associated async job, or `null` if none. */
71
+ jobId: NanoID | null;
72
+ /** The associated async job. */
73
+ job: ActivityJob | null | undefined;
74
+ /** When this activity occurred. */
75
+ createdAt: Date;
76
+ /** @internal */
77
+ constructor(data: ActivityLogData);
78
+ }
79
+ /**
80
+ * Manages activity logs and async jobs for a specific server.
81
+ *
82
+ * Access via `server.activity`.
83
+ *
84
+ * @example
85
+ * ```ts ignore
86
+ * const logs = await server.activity.list();
87
+ * const job = await server.activity.getJob(jobId);
88
+ * ```
89
+ */
90
+ export declare class ServerActivityManager {
91
+ private readonly serverId;
92
+ private readonly http;
93
+ /** @internal */
94
+ constructor(serverId: NanoID, http: HttpClient);
95
+ /**
96
+ * Fetch a paginated list of activity log entries for this server.
97
+ *
98
+ * @param opts Pagination options.
99
+ */
100
+ list(opts?: ListOptions): Promise<Paginated<ActivityLog>>;
101
+ /**
102
+ * Fetch a single activity log entry.
103
+ *
104
+ * @param activityId The activity log entry's NanoID.
105
+ */
106
+ get(activityId: NanoID): Promise<ActivityLog>;
107
+ /**
108
+ * Fetch a paginated list of async activity jobs for this server.
109
+ *
110
+ * @param opts Pagination options.
111
+ */
112
+ listJobs(opts?: ListOptions): Promise<Paginated<ActivityJob>>;
113
+ /**
114
+ * Fetch a single async activity job.
115
+ *
116
+ * @param jobId The activity job's NanoID.
117
+ */
118
+ getJob(jobId: NanoID): Promise<ActivityJob>;
119
+ }
120
+ //# sourceMappingURL=activity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/activity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEvF;;GAEG;AACH,qBAAa,cAAc;IAC1B,uDAAuD;IACvD,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,gDAAgD;IAChD,SAAgB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,uCAAuC;IACvC,SAAgB,SAAS,EAAE,IAAI,CAAC;IAEhC,gBAAgB;gBACG,IAAI,EAAE,kBAAkB;CAK3C;AAED;;;;;GAKG;AACH,qBAAa,WAAY,SAAQ,gBAAgB;IAChD,+BAA+B;IAC/B,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,0BAA0B;IACnB,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtD,gEAAgE;IACzD,IAAI,EAAE,cAAc,EAAE,CAAC;IAC9B,0EAA0E;IACnE,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAChC,iCAAiC;IAC1B,SAAS,EAAE,IAAI,CAAC;IACvB,sCAAs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AgB,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAK1E;;;;OAIG;IACU,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAK1D;;;;OAIG;IACU,QAAQ,CAAC,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAK9E;;;;OAIG;IACU,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAIxD"}
@@ -0,0 +1,163 @@
1
+ import { ReactiveResource } from '../../reactive.js';
2
+ import { toNanoID } from '../../types.js';
3
+ import { Member } from '../members.js';
4
+ /**
5
+ * A single log entry within an {@link ActivityJob}.
6
+ */
7
+ export class ActivityJobLog {
8
+ /** The type of log event, e.g. `"info"`, `"error"`. */
9
+ type;
10
+ /** Structured metadata about this log event. */
11
+ metadata;
12
+ /** When this log entry was created. */
13
+ createdAt;
14
+ /** @internal */
15
+ constructor(data) {
16
+ this.type = data.type;
17
+ this.metadata = data.metadata;
18
+ this.createdAt = new Date(data.created_at);
19
+ }
20
+ }
21
+ /**
22
+ * An asynchronous background job associated with a server activity.
23
+ *
24
+ * Jobs represent long-running operations (e.g. installing a server, restoring a backup)
25
+ * and may contain multiple {@link ActivityJobLog} entries.
26
+ */
27
+ export class ActivityJob extends ReactiveResource {
28
+ /** The job's unique NanoID. */
29
+ id;
30
+ /** Current job status. */
31
+ status;
32
+ /** Log entries produced by this job, in chronological order. */
33
+ logs;
34
+ /** When the job completed (or failed), or `null` if still in progress. */
35
+ completedAt;
36
+ /** When this job was created. */
37
+ createdAt;
38
+ /** When this job was last updated. */
39
+ updatedAt;
40
+ /** @internal */
41
+ constructor(data) {
42
+ super();
43
+ this.id = toNanoID(data.id);
44
+ this.status = data.status;
45
+ this.logs = data.logs.map((l) => new ActivityJobLog(l));
46
+ this.completedAt = data.completed_at ? new Date(data.completed_at) : null;
47
+ this.createdAt = new Date(data.created_at);
48
+ this.updatedAt = new Date(data.updated_at);
49
+ }
50
+ /** `true` if the job is still running. */
51
+ get isInProgress() {
52
+ return this.status === 'in_progress';
53
+ }
54
+ /** `true` if the job finished successfully. */
55
+ get isCompleted() {
56
+ return this.status === 'completed';
57
+ }
58
+ /** `true` if the job encountered an error. */
59
+ get isFailed() {
60
+ return this.status === 'failed';
61
+ }
62
+ }
63
+ /**
64
+ * An audit log entry recording an action performed on a server.
65
+ *
66
+ * Activities track all significant operations (power signals, file edits, permission changes, etc.)
67
+ * and optionally reference an async {@link ActivityJob}.
68
+ */
69
+ export class ActivityLog extends ReactiveResource {
70
+ /** The activity log entry's unique NanoID. */
71
+ id;
72
+ /** The event type identifier, e.g. `"server.power.start"`. */
73
+ event;
74
+ /** NanoID of the server this activity is associated with, if any. */
75
+ serverId;
76
+ /** NanoID of the node this activity is associated with, if any. */
77
+ nodeId;
78
+ /** NanoID of the issuer (user or API key) who triggered this activity, or `null` for system. */
79
+ issuerId;
80
+ /** The member who triggered this activity. */
81
+ issuer;
82
+ /** The IP address the action was performed from, if available. */
83
+ ip;
84
+ /** Structured metadata about this activity (content depends on the event type). */
85
+ metadata;
86
+ /** NanoID of the associated async job, or `null` if none. */
87
+ jobId;
88
+ /** The associated async job. */
89
+ job;
90
+ /** When this activity occurred. */
91
+ createdAt;
92
+ /** @internal */
93
+ constructor(data) {
94
+ super();
95
+ this.id = toNanoID(data.id);
96
+ this.event = data.event;
97
+ this.serverId = data.server_id ? toNanoID(data.server_id) : null;
98
+ this.nodeId = data.node_id ? toNanoID(data.node_id) : null;
99
+ this.issuerId = data.issuer_id ? toNanoID(data.issuer_id) : null;
100
+ this.issuer = data.issuer ? new Member(data.issuer) : data.issuer;
101
+ this.ip = data.ip;
102
+ this.metadata = data.metadata;
103
+ this.jobId = data.job_id ? toNanoID(data.job_id) : null;
104
+ this.job = data.job ? new ActivityJob(data.job) : data.job;
105
+ this.createdAt = new Date(data.created_at);
106
+ }
107
+ }
108
+ /**
109
+ * Manages activity logs and async jobs for a specific server.
110
+ *
111
+ * Access via `server.activity`.
112
+ *
113
+ * @example
114
+ * ```ts ignore
115
+ * const logs = await server.activity.list();
116
+ * const job = await server.activity.getJob(jobId);
117
+ * ```
118
+ */
119
+ export class ServerActivityManager {
120
+ serverId;
121
+ http;
122
+ /** @internal */
123
+ constructor(serverId, http) {
124
+ this.serverId = serverId;
125
+ this.http = http;
126
+ }
127
+ /**
128
+ * Fetch a paginated list of activity log entries for this server.
129
+ *
130
+ * @param opts Pagination options.
131
+ */
132
+ async list(opts = {}) {
133
+ const result = await this.http.list(`/servers/${this.serverId}/activities`, opts);
134
+ return { ...result, data: result.data.map((d) => new ActivityLog(d)) };
135
+ }
136
+ /**
137
+ * Fetch a single activity log entry.
138
+ *
139
+ * @param activityId The activity log entry's NanoID.
140
+ */
141
+ async get(activityId) {
142
+ const data = await this.http.get(`/servers/${this.serverId}/activities/${activityId}`);
143
+ return new ActivityLog(data);
144
+ }
145
+ /**
146
+ * Fetch a paginated list of async activity jobs for this server.
147
+ *
148
+ * @param opts Pagination options.
149
+ */
150
+ async listJobs(opts = {}) {
151
+ const result = await this.http.list(`/servers/${this.serverId}/activities/jobs`, opts);
152
+ return { ...result, data: result.data.map((d) => new ActivityJob(d)) };
153
+ }
154
+ /**
155
+ * Fetch a single async activity job.
156
+ *
157
+ * @param jobId The activity job's NanoID.
158
+ */
159
+ async getJob(jobId) {
160
+ const data = await this.http.get(`/servers/${this.serverId}/activities/jobs/${jobId}`);
161
+ return new ActivityJob(data);
162
+ }
163
+ }
@@ -0,0 +1,125 @@
1
+ import type { HttpClient } from '../../http.js';
2
+ import { ReactiveResource } from '../../reactive.js';
3
+ import type { ListOptions, NanoID, Paginated } from '../../types.js';
4
+ import type { ServerAllocationPortData } from './types.js';
5
+ /**
6
+ * Metadata about the underlying port allocation (IP and port number) from the node.
7
+ */
8
+ export interface AllocationPortMeta {
9
+ /** Unique NanoID of this port record. */
10
+ id: NanoID;
11
+ /** IP address this port is bound to, e.g. `"1.2.3.4"`. */
12
+ ip: string;
13
+ /** Port number, e.g. `25565`. */
14
+ port: number;
15
+ /** Protocols this port is ready for, e.g. `["tcp", "udp"]`. */
16
+ readyProtocols: string[];
17
+ /** `true` if this port is currently assigned to a server. */
18
+ isInUse: boolean;
19
+ /** Internal notes. */
20
+ notes: string | null | undefined;
21
+ /** When this port was allocated. */
22
+ createdAt: Date;
23
+ /** When this port was last updated. */
24
+ updatedAt: Date;
25
+ }
26
+ /**
27
+ * A port allocation assigned to a server.
28
+ *
29
+ * Ports are the network endpoints (IP:port combinations) that game servers listen on.
30
+ * One port per server is the primary allocation; additional ports are extra.
31
+ *
32
+ * Retrieved via {@link ServerAllocationsManager.list} or {@link ServerAllocationsManager.primary}.
33
+ */
34
+ export declare class ServerAllocationPort extends ReactiveResource {
35
+ /** The server allocation record's unique NanoID. */
36
+ readonly id: NanoID;
37
+ /** Optional human-readable description for this allocation, e.g. `"Voice Chat"`. */
38
+ description: string | null;
39
+ /** NanoID of the underlying port record. */
40
+ portId: NanoID | undefined;
41
+ /** Full metadata about the underlying port. */
42
+ meta: AllocationPortMeta | null | undefined;
43
+ /** `true` if this is the server's primary allocation. */
44
+ isPrimary: boolean;
45
+ /** When this allocation was assigned to the server. */
46
+ createdAt: Date;
47
+ /** When this allocation was last updated. */
48
+ updatedAt: Date;
49
+ /** Shorthand: the IP address this port is bound to (from meta). */
50
+ get ip(): string | undefined;
51
+ /** Shorthand: the port number (from meta). */
52
+ get port(): number | undefined;
53
+ /** Shorthand: formatted `ip:port` string, e.g. `"1.2.3.4:25565"`. */
54
+ get address(): string | undefined;
55
+ /** @internal */
56
+ constructor(data: ServerAllocationPortData);
57
+ }
58
+ /** One entry in the array passed to {@link ServerAllocationsManager.add}. */
59
+ export type AddAllocationEntry = {
60
+ id: NanoID;
61
+ } | {
62
+ ip: string;
63
+ port: number;
64
+ } | {
65
+ ip: `${string}:${number}`;
66
+ };
67
+ /**
68
+ * Manages port allocations for a specific server.
69
+ *
70
+ * Access via `server.allocations`.
71
+ *
72
+ * @example
73
+ * ```ts ignore
74
+ * const ports = await server.allocations.list();
75
+ * const primary = await server.allocations.primary();
76
+ * await server.allocations.update(portId, { description: 'Game port', isPrimary: true });
77
+ * await server.allocations.add([{ ip: '1.2.3.4', port: 25566 }]);
78
+ * ```
79
+ */
80
+ export declare class ServerAllocationsManager {
81
+ private readonly serverId;
82
+ private readonly http;
83
+ /** @internal */
84
+ constructor(serverId: NanoID, http: HttpClient);
85
+ /**
86
+ * Fetch a paginated list of all port allocations for this server.
87
+ *
88
+ * @param opts Pagination options.
89
+ */
90
+ list(opts?: ListOptions): Promise<Paginated<ServerAllocationPort>>;
91
+ /**
92
+ * Fetch the primary port allocation for this server.
93
+ *
94
+ * @throws {@link ApiError} with `isNotFound === true` if no primary allocation is set.
95
+ */
96
+ primary(): Promise<ServerAllocationPort>;
97
+ /**
98
+ * Fetch a single allocation by its record ID.
99
+ *
100
+ * @param allocationId The allocation record's NanoID.
101
+ */
102
+ get(allocationId: NanoID): Promise<ServerAllocationPort>;
103
+ /**
104
+ * Update an allocation's description or promote it to primary.
105
+ *
106
+ * @param allocationId The allocation record's NanoID.
107
+ * @param payload Update fields.
108
+ */
109
+ update(allocationId: NanoID, payload: {
110
+ description?: string;
111
+ isPrimary?: boolean;
112
+ }): Promise<ServerAllocationPort>;
113
+ /**
114
+ * Add one or more port allocations to this server.
115
+ *
116
+ * Each entry can be specified as:
117
+ * - `{ id: NanoID }` - an existing allocation port record ID
118
+ * - `{ ip: string, port: number }` - by IP and port number
119
+ * - `{ ip: 'ip:port' }` - colon-separated IP:port string
120
+ *
121
+ * @param entries The allocations to add.
122
+ */
123
+ add(entries: AddAllocationEntry[]): Promise<void>;
124
+ }
125
+ //# sourceMappingURL=allocations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allocations.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/allocations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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OAAO,IAAI,MAAM,GAAG,SAAS,CAGvC;IAED,gBAAgB;gBACG,IAAI,EAAE,wBAAwB;CAqBjD;AAED,6EAA6E;AAC7E,MAAM,MAAM,kBAAkB,GAC3B;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GACd;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,EAAE,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,CAAA;CAAE,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAwB;IAGnC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHtB,gBAAgB;gBAEE,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU;IAGlC;;;;OAIG;IACU,IAAI,CAChB,IAAI,GAAE,WAAgB,GACpB,OAAO,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAW3C;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAOrD;;;;OAIG;IACU,GAAG,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAOrE;;;;;OAKG;IACU,MAAM,CAClB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GACpD,OAAO,CAAC,oBAAoB,CAAC;IAQhC;;;;;;;;;OASG;IACU,GAAG,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAM9D"}
@@ -0,0 +1,137 @@
1
+ import { ReactiveResource } from '../../reactive.js';
2
+ import { toNanoID } from '../../types.js';
3
+ /**
4
+ * A port allocation assigned to a server.
5
+ *
6
+ * Ports are the network endpoints (IP:port combinations) that game servers listen on.
7
+ * One port per server is the primary allocation; additional ports are extra.
8
+ *
9
+ * Retrieved via {@link ServerAllocationsManager.list} or {@link ServerAllocationsManager.primary}.
10
+ */
11
+ export class ServerAllocationPort extends ReactiveResource {
12
+ /** The server allocation record's unique NanoID. */
13
+ id;
14
+ /** Optional human-readable description for this allocation, e.g. `"Voice Chat"`. */
15
+ description;
16
+ /** NanoID of the underlying port record. */
17
+ portId;
18
+ /** Full metadata about the underlying port. */
19
+ meta;
20
+ /** `true` if this is the server's primary allocation. */
21
+ isPrimary;
22
+ /** When this allocation was assigned to the server. */
23
+ createdAt;
24
+ /** When this allocation was last updated. */
25
+ updatedAt;
26
+ /** Shorthand: the IP address this port is bound to (from meta). */
27
+ get ip() {
28
+ return this.meta?.ip;
29
+ }
30
+ /** Shorthand: the port number (from meta). */
31
+ get port() {
32
+ return this.meta?.port;
33
+ }
34
+ /** Shorthand: formatted `ip:port` string, e.g. `"1.2.3.4:25565"`. */
35
+ get address() {
36
+ if (!this.meta)
37
+ return undefined;
38
+ return `${this.meta.ip}:${this.meta.port}`;
39
+ }
40
+ /** @internal */
41
+ constructor(data) {
42
+ super();
43
+ this.id = toNanoID(data.id);
44
+ this.description = data.description ?? null;
45
+ this.portId = data.port_id ? toNanoID(data.port_id) : undefined;
46
+ this.meta = data.meta
47
+ ? {
48
+ id: toNanoID(data.meta.id),
49
+ ip: data.meta.ip,
50
+ port: data.meta.port,
51
+ readyProtocols: data.meta.ready_protocols ?? [],
52
+ isInUse: data.meta.is_in_use ?? false,
53
+ notes: data.meta.notes,
54
+ createdAt: new Date(data.meta.created_at),
55
+ updatedAt: new Date(data.meta.updated_at),
56
+ }
57
+ : data.meta;
58
+ this.isPrimary = data.is_primary;
59
+ this.createdAt = new Date(data.created_at);
60
+ this.updatedAt = new Date(data.updated_at);
61
+ }
62
+ }
63
+ /**
64
+ * Manages port allocations for a specific server.
65
+ *
66
+ * Access via `server.allocations`.
67
+ *
68
+ * @example
69
+ * ```ts ignore
70
+ * const ports = await server.allocations.list();
71
+ * const primary = await server.allocations.primary();
72
+ * await server.allocations.update(portId, { description: 'Game port', isPrimary: true });
73
+ * await server.allocations.add([{ ip: '1.2.3.4', port: 25566 }]);
74
+ * ```
75
+ */
76
+ export class ServerAllocationsManager {
77
+ serverId;
78
+ http;
79
+ /** @internal */
80
+ constructor(serverId, http) {
81
+ this.serverId = serverId;
82
+ this.http = http;
83
+ }
84
+ /**
85
+ * Fetch a paginated list of all port allocations for this server.
86
+ *
87
+ * @param opts Pagination options.
88
+ */
89
+ async list(opts = {}) {
90
+ const result = await this.http.list(`/servers/${this.serverId}/allocations`, opts);
91
+ return {
92
+ ...result,
93
+ data: result.data.map((d) => new ServerAllocationPort(d)),
94
+ };
95
+ }
96
+ /**
97
+ * Fetch the primary port allocation for this server.
98
+ *
99
+ * @throws {@link ApiError} with `isNotFound === true` if no primary allocation is set.
100
+ */
101
+ async primary() {
102
+ const data = await this.http.get(`/servers/${this.serverId}/allocations/primary`);
103
+ return new ServerAllocationPort(data);
104
+ }
105
+ /**
106
+ * Fetch a single allocation by its record ID.
107
+ *
108
+ * @param allocationId The allocation record's NanoID.
109
+ */
110
+ async get(allocationId) {
111
+ const data = await this.http.get(`/servers/${this.serverId}/allocations/${allocationId}`);
112
+ return new ServerAllocationPort(data);
113
+ }
114
+ /**
115
+ * Update an allocation's description or promote it to primary.
116
+ *
117
+ * @param allocationId The allocation record's NanoID.
118
+ * @param payload Update fields.
119
+ */
120
+ async update(allocationId, payload) {
121
+ const data = await this.http.patch(`/servers/${this.serverId}/allocations/${allocationId}`, { description: payload.description, is_primary: payload.isPrimary });
122
+ return new ServerAllocationPort(data);
123
+ }
124
+ /**
125
+ * Add one or more port allocations to this server.
126
+ *
127
+ * Each entry can be specified as:
128
+ * - `{ id: NanoID }` - an existing allocation port record ID
129
+ * - `{ ip: string, port: number }` - by IP and port number
130
+ * - `{ ip: 'ip:port' }` - colon-separated IP:port string
131
+ *
132
+ * @param entries The allocations to add.
133
+ */
134
+ async add(entries) {
135
+ await this.http.post(`/servers/${this.serverId}/allocations`, entries);
136
+ }
137
+ }
@@ -0,0 +1,108 @@
1
+ import { ReactiveResource } from '../../reactive.js';
2
+ import type { NanoID, PowerState } from '../../types.js';
3
+ /** Real-time resource utilization reported by the node. */
4
+ export interface ServerUtilization {
5
+ /** CPU usage as an absolute percentage (0–100+). */
6
+ cpuAbsolute: number;
7
+ /** Memory usage in bytes. */
8
+ memoryBytes: number;
9
+ /** Memory limit in bytes. */
10
+ memoryLimitBytes: number;
11
+ /** Disk usage in bytes. */
12
+ diskBytes: number;
13
+ /** Network received bytes (cumulative since start). */
14
+ networkRxBytes: number;
15
+ /** Network transmitted bytes (cumulative since start). */
16
+ networkTxBytes: number;
17
+ /** Server uptime in seconds. */
18
+ uptimeSeconds: number;
19
+ }
20
+ /** Typed events emitted by {@link ServerConnection}. */
21
+ export interface ServerConnectionEvents {
22
+ /** A line of console output from the server process. */
23
+ console_output: string;
24
+ /** The server's power state changed. */
25
+ status: PowerState;
26
+ /** New resource utilization stats are available. */
27
+ stats: ServerUtilization;
28
+ }
29
+ /**
30
+ * A real-time SSE connection to a specific server on its Whisker node daemon.
31
+ *
32
+ * Emits typed events for console output, power state changes, and resource utilization.
33
+ * Also maintains a rolling buffer of console output lines in {@link output}, pre-populated
34
+ * with recent history fetched from the node on {@link connect}.
35
+ *
36
+ * Obtain a connection via {@link import('./server.ts').Server.connect}.
37
+ *
38
+ * @example
39
+ * ```ts ignore
40
+ * const conn = await server.connect();
41
+ *
42
+ * conn.on('status', (state) => console.log('Power state:', state));
43
+ * conn.on('stats', (stats) => console.log('CPU:', stats.cpuAbsolute + '%'));
44
+ *
45
+ * await conn.connect();
46
+ *
47
+ * // Reactive: $conn.output is the full rolling buffer of console lines
48
+ * // Live lines are appended automatically as they arrive over SSE
49
+ *
50
+ * // Later...
51
+ * conn.disconnect();
52
+ * ```
53
+ */
54
+ export declare class ServerConnection extends ReactiveResource {
55
+ private readonly serverId;
56
+ private readonly nodeUrl;
57
+ private readonly token;
58
+ /** Maximum number of console output lines retained in {@link ServerConnection.output}. */
59
+ private static readonly maxOutputLines;
60
+ private readonly listeners;
61
+ private sse;
62
+ private connected;
63
+ /**
64
+ * Rolling buffer of console output lines, capped at {@link MAX_OUTPUT_LINES}.
65
+ *
66
+ * Pre-populated with recent history from the node when {@link connect} is called,
67
+ * then appended to live as `console_output` SSE events arrive.
68
+ *
69
+ * Use as a reactive store: `$conn.output`.
70
+ */
71
+ output: string[];
72
+ /** @internal */
73
+ constructor(serverId: NanoID, nodeUrl: string, token: string);
74
+ /** `true` if the SSE connection is currently open. */
75
+ get isConnected(): boolean;
76
+ /**
77
+ * Fetch console history and open the SSE stream.
78
+ *
79
+ * Populates {@link output} with recent history from the node, then begins streaming
80
+ * live events.
81
+ *
82
+ * Maintains only one instances of the stream.
83
+ *
84
+ * @param onError Optional callback invoked if the connection drops unexpectedly.
85
+ */
86
+ open(onError?: (error: Error) => void): Promise<void>;
87
+ /** Close the SSE stream and stop receiving events. */
88
+ close(): void;
89
+ /**
90
+ * Register a handler for a typed server event.
91
+ *
92
+ * @param event The event name.
93
+ * @param handler The callback to invoke when the event is received.
94
+ */
95
+ on<K extends keyof ServerConnectionEvents>(event: K, handler: (payload: ServerConnectionEvents[K]) => void): void;
96
+ /**
97
+ * Unregister a previously registered event handler.
98
+ *
99
+ * @param event The event name.
100
+ * @param handler The exact handler reference passed to {@link on}.
101
+ */
102
+ off<K extends keyof ServerConnectionEvents>(event: K, handler: (payload: ServerConnectionEvents[K]) => void): void;
103
+ /** Remove all event handlers for all event types. */
104
+ removeAllListeners(): void;
105
+ /** Parse and dispatch a raw SSE event to registered handlers. */
106
+ private dispatch;
107
+ }
108
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,UAA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