@meowpanel/api 0.2.0 → 0.4.0
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.
- package/esm/mod.d.ts +39 -18
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +26 -8
- package/esm/src/client.d.ts +48 -11
- package/esm/src/client.d.ts.map +1 -1
- package/esm/src/client.js +53 -12
- package/esm/src/errors.d.ts +8 -0
- package/esm/src/errors.d.ts.map +1 -1
- package/esm/src/errors.js +10 -0
- package/esm/src/http.d.ts +2 -2
- package/esm/src/http.d.ts.map +1 -1
- package/esm/src/http.js +5 -2
- package/esm/src/namespace.d.ts +1 -1
- package/esm/src/namespace.js +1 -1
- package/esm/src/resources/account.d.ts +104 -19
- package/esm/src/resources/account.d.ts.map +1 -1
- package/esm/src/resources/account.js +112 -13
- package/esm/src/resources/api-keys.d.ts +16 -24
- package/esm/src/resources/api-keys.d.ts.map +1 -1
- package/esm/src/resources/api-keys.js +16 -20
- package/esm/src/resources/auth.d.ts +70 -4
- package/esm/src/resources/auth.d.ts.map +1 -1
- package/esm/src/resources/auth.js +47 -4
- package/esm/src/resources/eggs.d.ts +261 -22
- package/esm/src/resources/eggs.d.ts.map +1 -1
- package/esm/src/resources/eggs.js +261 -25
- package/esm/src/resources/features.d.ts +35 -0
- package/esm/src/resources/features.d.ts.map +1 -0
- package/esm/src/resources/features.js +21 -0
- package/esm/src/resources/hosts.d.ts +143 -18
- package/esm/src/resources/hosts.d.ts.map +1 -1
- package/esm/src/resources/hosts.js +145 -10
- package/esm/src/resources/logs.d.ts +39 -0
- package/esm/src/resources/logs.d.ts.map +1 -0
- package/esm/src/resources/logs.js +38 -0
- package/esm/src/resources/nodes.d.ts +106 -41
- package/esm/src/resources/nodes.d.ts.map +1 -1
- package/esm/src/resources/nodes.js +121 -28
- package/esm/src/resources/permissions.d.ts +45 -0
- package/esm/src/resources/permissions.d.ts.map +1 -0
- package/esm/src/resources/permissions.js +26 -0
- package/esm/src/resources/request-logs.d.ts +91 -0
- package/esm/src/resources/request-logs.d.ts.map +1 -0
- package/esm/src/resources/request-logs.js +70 -0
- package/esm/src/resources/roles.d.ts +128 -0
- package/esm/src/resources/roles.d.ts.map +1 -0
- package/esm/src/resources/roles.js +142 -0
- package/esm/src/resources/server-groups.d.ts +141 -7
- package/esm/src/resources/server-groups.d.ts.map +1 -1
- package/esm/src/resources/server-groups.js +157 -8
- package/esm/src/resources/servers/activity.d.ts +50 -8
- package/esm/src/resources/servers/activity.d.ts.map +1 -1
- package/esm/src/resources/servers/activity.js +54 -13
- package/esm/src/resources/servers/allocations.d.ts +3 -3
- package/esm/src/resources/servers/allocations.d.ts.map +1 -1
- package/esm/src/resources/servers/allocations.js +7 -7
- package/esm/src/resources/servers/backups.d.ts +46 -0
- package/esm/src/resources/servers/backups.d.ts.map +1 -0
- package/esm/src/resources/servers/backups.js +43 -0
- package/esm/src/resources/servers/connection.d.ts +27 -7
- package/esm/src/resources/servers/connection.d.ts.map +1 -1
- package/esm/src/resources/servers/connection.js +28 -7
- package/esm/src/resources/servers/features.d.ts +81 -0
- package/esm/src/resources/servers/features.d.ts.map +1 -0
- package/esm/src/resources/servers/features.js +60 -0
- package/esm/src/resources/servers/files.d.ts +41 -53
- package/esm/src/resources/servers/files.d.ts.map +1 -1
- package/esm/src/resources/servers/files.js +74 -116
- package/esm/src/resources/servers/index.d.ts +46 -27
- package/esm/src/resources/servers/index.d.ts.map +1 -1
- package/esm/src/resources/servers/index.js +26 -12
- package/esm/src/resources/servers/jobs.d.ts +88 -0
- package/esm/src/resources/servers/jobs.d.ts.map +1 -0
- package/esm/src/resources/servers/jobs.js +115 -0
- package/esm/src/resources/servers/node-client.d.ts +33 -0
- package/esm/src/resources/servers/node-client.d.ts.map +1 -0
- package/esm/src/resources/servers/node-client.js +61 -0
- package/esm/src/resources/servers/profiles.d.ts +45 -1
- package/esm/src/resources/servers/profiles.d.ts.map +1 -1
- package/esm/src/resources/servers/profiles.js +55 -2
- package/esm/src/resources/servers/server.d.ts +10 -25
- package/esm/src/resources/servers/server.d.ts.map +1 -1
- package/esm/src/resources/servers/server.js +18 -34
- package/esm/src/resources/servers/sftp.d.ts +21 -19
- package/esm/src/resources/servers/sftp.d.ts.map +1 -1
- package/esm/src/resources/servers/sftp.js +22 -14
- package/esm/src/resources/servers/sub-users.d.ts +99 -0
- package/esm/src/resources/servers/sub-users.d.ts.map +1 -0
- package/esm/src/resources/servers/sub-users.js +94 -0
- package/esm/src/resources/servers/types.d.ts +27 -25
- package/esm/src/resources/servers/types.d.ts.map +1 -1
- package/esm/src/resources/systems.d.ts +124 -0
- package/esm/src/resources/systems.d.ts.map +1 -0
- package/esm/src/resources/systems.js +139 -0
- package/esm/src/resources/users.d.ts +330 -0
- package/esm/src/resources/users.d.ts.map +1 -0
- package/esm/src/resources/users.js +280 -0
- package/esm/src/types.d.ts +18 -1
- package/esm/src/types.d.ts.map +1 -1
- package/esm/src/types.js +11 -0
- package/package.json +1 -1
- package/script/mod.d.ts +39 -18
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +52 -5
- package/script/src/client.d.ts +48 -11
- package/script/src/client.d.ts.map +1 -1
- package/script/src/client.js +53 -12
- package/script/src/errors.d.ts +8 -0
- package/script/src/errors.d.ts.map +1 -1
- package/script/src/errors.js +10 -0
- package/script/src/http.d.ts +2 -2
- package/script/src/http.d.ts.map +1 -1
- package/script/src/http.js +5 -2
- package/script/src/namespace.d.ts +1 -1
- package/script/src/namespace.js +1 -1
- package/script/src/resources/account.d.ts +104 -19
- package/script/src/resources/account.d.ts.map +1 -1
- package/script/src/resources/account.js +114 -13
- package/script/src/resources/api-keys.d.ts +16 -24
- package/script/src/resources/api-keys.d.ts.map +1 -1
- package/script/src/resources/api-keys.js +15 -19
- package/script/src/resources/auth.d.ts +70 -4
- package/script/src/resources/auth.d.ts.map +1 -1
- package/script/src/resources/auth.js +47 -4
- package/script/src/resources/eggs.d.ts +261 -22
- package/script/src/resources/eggs.d.ts.map +1 -1
- package/script/src/resources/eggs.js +267 -26
- package/script/src/resources/features.d.ts +35 -0
- package/script/src/resources/features.d.ts.map +1 -0
- package/script/src/resources/features.js +25 -0
- package/script/src/resources/hosts.d.ts +143 -18
- package/script/src/resources/hosts.d.ts.map +1 -1
- package/script/src/resources/hosts.js +146 -10
- package/script/src/resources/logs.d.ts +39 -0
- package/script/src/resources/logs.d.ts.map +1 -0
- package/script/src/resources/logs.js +42 -0
- package/script/src/resources/nodes.d.ts +106 -41
- package/script/src/resources/nodes.d.ts.map +1 -1
- package/script/src/resources/nodes.js +122 -28
- package/script/src/resources/permissions.d.ts +45 -0
- package/script/src/resources/permissions.d.ts.map +1 -0
- package/script/src/resources/permissions.js +31 -0
- package/script/src/resources/request-logs.d.ts +91 -0
- package/script/src/resources/request-logs.d.ts.map +1 -0
- package/script/src/resources/request-logs.js +75 -0
- package/script/src/resources/roles.d.ts +128 -0
- package/script/src/resources/roles.d.ts.map +1 -0
- package/script/src/resources/roles.js +148 -0
- package/script/src/resources/server-groups.d.ts +141 -7
- package/script/src/resources/server-groups.d.ts.map +1 -1
- package/script/src/resources/server-groups.js +158 -8
- package/script/src/resources/servers/activity.d.ts +50 -8
- package/script/src/resources/servers/activity.d.ts.map +1 -1
- package/script/src/resources/servers/activity.js +54 -12
- package/script/src/resources/servers/allocations.d.ts +3 -3
- package/script/src/resources/servers/allocations.d.ts.map +1 -1
- package/script/src/resources/servers/allocations.js +7 -7
- package/script/src/resources/servers/backups.d.ts +46 -0
- package/script/src/resources/servers/backups.d.ts.map +1 -0
- package/script/src/resources/servers/backups.js +47 -0
- package/script/src/resources/servers/connection.d.ts +27 -7
- package/script/src/resources/servers/connection.d.ts.map +1 -1
- package/script/src/resources/servers/connection.js +28 -7
- package/script/src/resources/servers/features.d.ts +81 -0
- package/script/src/resources/servers/features.d.ts.map +1 -0
- package/script/src/resources/servers/features.js +64 -0
- package/script/src/resources/servers/files.d.ts +41 -53
- package/script/src/resources/servers/files.d.ts.map +1 -1
- package/script/src/resources/servers/files.js +74 -116
- package/script/src/resources/servers/index.d.ts +46 -27
- package/script/src/resources/servers/index.d.ts.map +1 -1
- package/script/src/resources/servers/index.js +26 -12
- package/script/src/resources/servers/jobs.d.ts +88 -0
- package/script/src/resources/servers/jobs.d.ts.map +1 -0
- package/script/src/resources/servers/jobs.js +120 -0
- package/script/src/resources/servers/node-client.d.ts +33 -0
- package/script/src/resources/servers/node-client.d.ts.map +1 -0
- package/script/src/resources/servers/node-client.js +65 -0
- package/script/src/resources/servers/profiles.d.ts +45 -1
- package/script/src/resources/servers/profiles.d.ts.map +1 -1
- package/script/src/resources/servers/profiles.js +55 -2
- package/script/src/resources/servers/server.d.ts +10 -25
- package/script/src/resources/servers/server.d.ts.map +1 -1
- package/script/src/resources/servers/server.js +18 -34
- package/script/src/resources/servers/sftp.d.ts +21 -19
- package/script/src/resources/servers/sftp.d.ts.map +1 -1
- package/script/src/resources/servers/sftp.js +22 -14
- package/script/src/resources/servers/sub-users.d.ts +99 -0
- package/script/src/resources/servers/sub-users.d.ts.map +1 -0
- package/script/src/resources/servers/sub-users.js +99 -0
- package/script/src/resources/servers/types.d.ts +27 -25
- package/script/src/resources/servers/types.d.ts.map +1 -1
- package/script/src/resources/systems.d.ts +124 -0
- package/script/src/resources/systems.d.ts.map +1 -0
- package/script/src/resources/systems.js +145 -0
- package/script/src/resources/users.d.ts +330 -0
- package/script/src/resources/users.d.ts.map +1 -0
- package/script/src/resources/users.js +287 -0
- package/script/src/types.d.ts +18 -1
- package/script/src/types.d.ts.map +1 -1
- package/script/src/types.js +12 -0
- package/esm/src/resources/members.d.ts +0 -138
- package/esm/src/resources/members.d.ts.map +0 -1
- package/esm/src/resources/members.js +0 -122
- package/script/src/resources/members.d.ts +0 -138
- package/script/src/resources/members.d.ts.map +0 -1
- package/script/src/resources/members.js +0 -127
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { HttpClient } from '../../http.js';
|
|
2
2
|
import { ReactiveResource } from '../../reactive.js';
|
|
3
3
|
import type { ListOptions, NanoID, Paginated } from '../../types.js';
|
|
4
|
-
import {
|
|
4
|
+
import { User } from '../users.js';
|
|
5
5
|
import type { ActivityJobData, ActivityJobLogData, ActivityLogData } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* A single log entry within an {@link ActivityJob}.
|
|
8
8
|
*/
|
|
9
9
|
export declare class ActivityJobLog {
|
|
10
|
-
/** The type
|
|
11
|
-
readonly
|
|
10
|
+
/** The event type identifier, e.g. `"server.power.start"`. */
|
|
11
|
+
readonly event: string;
|
|
12
12
|
/** Structured metadata about this log event. */
|
|
13
13
|
readonly metadata: Record<string, unknown>;
|
|
14
14
|
/** When this log entry was created. */
|
|
@@ -59,10 +59,22 @@ export declare class ActivityLog extends ReactiveResource {
|
|
|
59
59
|
serverId: NanoID | null;
|
|
60
60
|
/** NanoID of the node this activity is associated with, if any. */
|
|
61
61
|
nodeId: NanoID | null;
|
|
62
|
-
/** NanoID of the
|
|
62
|
+
/** NanoID of the server group this activity is associated with, if any. */
|
|
63
|
+
groupId: NanoID | null;
|
|
64
|
+
/** NanoID of the host this activity is associated with, if any. */
|
|
65
|
+
hostId: NanoID | null;
|
|
66
|
+
/** The issuer's bare NanoID (parsed from the namespaced `issuer_id`), or `null`. */
|
|
63
67
|
issuerId: NanoID | null;
|
|
64
|
-
/** The
|
|
65
|
-
|
|
68
|
+
/** The issuer's type, e.g. `'user'`, `'node'`, `'system'`, or `null`. */
|
|
69
|
+
issuerType: string | null;
|
|
70
|
+
/** The issuer who triggered this activity. */
|
|
71
|
+
issuer: User | null | undefined;
|
|
72
|
+
/** The subject's bare NanoID (parsed from the namespaced `subject_id`), or `null`. */
|
|
73
|
+
subjectId: NanoID | null;
|
|
74
|
+
/** The subject's type, or `null`. */
|
|
75
|
+
subjectType: string | null;
|
|
76
|
+
/** The subject this action was performed on. */
|
|
77
|
+
subject: User | null | undefined;
|
|
66
78
|
/** The IP address the action was performed from, if available. */
|
|
67
79
|
ip: string | null | undefined;
|
|
68
80
|
/** Structured metadata about this activity (content depends on the event type). */
|
|
@@ -76,6 +88,36 @@ export declare class ActivityLog extends ReactiveResource {
|
|
|
76
88
|
/** @internal */
|
|
77
89
|
constructor(data: ActivityLogData);
|
|
78
90
|
}
|
|
91
|
+
/** Query options for an activity-log feed. */
|
|
92
|
+
export interface ActivityFeedOptions {
|
|
93
|
+
page?: number;
|
|
94
|
+
perPage?: number;
|
|
95
|
+
/** Sort order by creation time. Defaults to oldest-first. */
|
|
96
|
+
sort?: 'created_at_asc' | 'created_at_desc';
|
|
97
|
+
/** Filter by event type, e.g. `"server.power.start"`. */
|
|
98
|
+
type?: string;
|
|
99
|
+
/** Filter by source IP. */
|
|
100
|
+
ip?: string;
|
|
101
|
+
/** Filter by the issuer's auth-issuer id. */
|
|
102
|
+
issuerId?: string;
|
|
103
|
+
/** Filter by the subject user's NanoID. */
|
|
104
|
+
subjectUserId?: NanoID;
|
|
105
|
+
/** Filter by server. */
|
|
106
|
+
serverId?: NanoID;
|
|
107
|
+
/** Filter by server group. */
|
|
108
|
+
groupId?: NanoID;
|
|
109
|
+
/** Filter by node. */
|
|
110
|
+
nodeId?: NanoID;
|
|
111
|
+
/** Filter by host. */
|
|
112
|
+
hostId?: NanoID;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Fetch an activity-log feed and map the entries to {@link ActivityLog} instances.
|
|
116
|
+
*
|
|
117
|
+
* @param extra Endpoint-specific query params (e.g. `scope`).
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
export declare function listActivities(http: HttpClient, path: string, opts?: ActivityFeedOptions, extra?: Record<string, string | undefined>): Promise<Paginated<ActivityLog>>;
|
|
79
121
|
/**
|
|
80
122
|
* Manages activity logs and async jobs for a specific server.
|
|
81
123
|
*
|
|
@@ -95,9 +137,9 @@ export declare class ServerActivityManager {
|
|
|
95
137
|
/**
|
|
96
138
|
* Fetch a paginated list of activity log entries for this server.
|
|
97
139
|
*
|
|
98
|
-
* @param opts Pagination options.
|
|
140
|
+
* @param opts Pagination and filter options.
|
|
99
141
|
*/
|
|
100
|
-
list(opts?:
|
|
142
|
+
list(opts?: ActivityFeedOptions): Promise<Paginated<ActivityLog>>;
|
|
101
143
|
/**
|
|
102
144
|
* Fetch a single activity log entry.
|
|
103
145
|
*
|
|
@@ -1 +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,
|
|
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,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEvF;;GAEG;AACH,qBAAa,cAAc;IAC1B,8DAA8D;IAC9D,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,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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WAAW,CAAC,CAAC,CAejC;AAED;;;;;;;;;;GAUG;AACH,qBAAa,qBAAqB;IAGhC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHtB,gBAAgB;gBAEE,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU;IAGlC;;;;OAIG;IACI,IAAI,CAAC,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAI5E;;;;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"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { ReactiveResource } from '../../reactive.js';
|
|
2
|
-
import { toNanoID } from '../../types.js';
|
|
3
|
-
import {
|
|
2
|
+
import { parseIssuerRef, toNanoID } from '../../types.js';
|
|
3
|
+
import { User } from '../users.js';
|
|
4
4
|
/**
|
|
5
5
|
* A single log entry within an {@link ActivityJob}.
|
|
6
6
|
*/
|
|
7
7
|
export class ActivityJobLog {
|
|
8
|
-
/** The type
|
|
9
|
-
|
|
8
|
+
/** The event type identifier, e.g. `"server.power.start"`. */
|
|
9
|
+
event;
|
|
10
10
|
/** Structured metadata about this log event. */
|
|
11
11
|
metadata;
|
|
12
12
|
/** When this log entry was created. */
|
|
13
13
|
createdAt;
|
|
14
14
|
/** @internal */
|
|
15
15
|
constructor(data) {
|
|
16
|
-
this.
|
|
16
|
+
this.event = data.event;
|
|
17
17
|
this.metadata = data.metadata;
|
|
18
18
|
this.createdAt = new Date(data.created_at);
|
|
19
19
|
}
|
|
@@ -75,10 +75,22 @@ export class ActivityLog extends ReactiveResource {
|
|
|
75
75
|
serverId;
|
|
76
76
|
/** NanoID of the node this activity is associated with, if any. */
|
|
77
77
|
nodeId;
|
|
78
|
-
/** NanoID of the
|
|
78
|
+
/** NanoID of the server group this activity is associated with, if any. */
|
|
79
|
+
groupId;
|
|
80
|
+
/** NanoID of the host this activity is associated with, if any. */
|
|
81
|
+
hostId;
|
|
82
|
+
/** The issuer's bare NanoID (parsed from the namespaced `issuer_id`), or `null`. */
|
|
79
83
|
issuerId;
|
|
80
|
-
/** The
|
|
84
|
+
/** The issuer's type, e.g. `'user'`, `'node'`, `'system'`, or `null`. */
|
|
85
|
+
issuerType;
|
|
86
|
+
/** The issuer who triggered this activity. */
|
|
81
87
|
issuer;
|
|
88
|
+
/** The subject's bare NanoID (parsed from the namespaced `subject_id`), or `null`. */
|
|
89
|
+
subjectId;
|
|
90
|
+
/** The subject's type, or `null`. */
|
|
91
|
+
subjectType;
|
|
92
|
+
/** The subject this action was performed on. */
|
|
93
|
+
subject;
|
|
82
94
|
/** The IP address the action was performed from, if available. */
|
|
83
95
|
ip;
|
|
84
96
|
/** Structured metadata about this activity (content depends on the event type). */
|
|
@@ -96,8 +108,16 @@ export class ActivityLog extends ReactiveResource {
|
|
|
96
108
|
this.event = data.event;
|
|
97
109
|
this.serverId = data.server_id ? toNanoID(data.server_id) : null;
|
|
98
110
|
this.nodeId = data.node_id ? toNanoID(data.node_id) : null;
|
|
99
|
-
this.
|
|
100
|
-
this.
|
|
111
|
+
this.groupId = data.group_id ? toNanoID(data.group_id) : null;
|
|
112
|
+
this.hostId = data.host_id ? toNanoID(data.host_id) : null;
|
|
113
|
+
const issuer = data.issuer_id ? parseIssuerRef(data.issuer_id) : null;
|
|
114
|
+
this.issuerId = issuer ? issuer.id : null;
|
|
115
|
+
this.issuerType = issuer ? issuer.type : null;
|
|
116
|
+
this.issuer = data.issuer ? new User(data.issuer) : data.issuer;
|
|
117
|
+
const subject = data.subject_id ? parseIssuerRef(data.subject_id) : null;
|
|
118
|
+
this.subjectId = subject ? subject.id : null;
|
|
119
|
+
this.subjectType = subject ? subject.type : null;
|
|
120
|
+
this.subject = data.subject ? new User(data.subject) : data.subject;
|
|
101
121
|
this.ip = data.ip;
|
|
102
122
|
this.metadata = data.metadata;
|
|
103
123
|
this.jobId = data.job_id ? toNanoID(data.job_id) : null;
|
|
@@ -105,6 +125,28 @@ export class ActivityLog extends ReactiveResource {
|
|
|
105
125
|
this.createdAt = new Date(data.created_at);
|
|
106
126
|
}
|
|
107
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Fetch an activity-log feed and map the entries to {@link ActivityLog} instances.
|
|
130
|
+
*
|
|
131
|
+
* @param extra Endpoint-specific query params (e.g. `scope`).
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
export async function listActivities(http, path, opts = {}, extra = {}) {
|
|
135
|
+
const params = {
|
|
136
|
+
sort: opts.sort,
|
|
137
|
+
type: opts.type,
|
|
138
|
+
ip: opts.ip,
|
|
139
|
+
issuer_id: opts.issuerId,
|
|
140
|
+
subject_user_id: opts.subjectUserId,
|
|
141
|
+
server_id: opts.serverId,
|
|
142
|
+
group_id: opts.groupId,
|
|
143
|
+
node_id: opts.nodeId,
|
|
144
|
+
host_id: opts.hostId,
|
|
145
|
+
...extra,
|
|
146
|
+
};
|
|
147
|
+
const result = await http.list(path, { page: opts.page, perPage: opts.perPage }, params);
|
|
148
|
+
return { ...result, data: result.data.map((d) => new ActivityLog(d)) };
|
|
149
|
+
}
|
|
108
150
|
/**
|
|
109
151
|
* Manages activity logs and async jobs for a specific server.
|
|
110
152
|
*
|
|
@@ -127,11 +169,10 @@ export class ServerActivityManager {
|
|
|
127
169
|
/**
|
|
128
170
|
* Fetch a paginated list of activity log entries for this server.
|
|
129
171
|
*
|
|
130
|
-
* @param opts Pagination options.
|
|
172
|
+
* @param opts Pagination and filter options.
|
|
131
173
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return { ...result, data: result.data.map((d) => new ActivityLog(d)) };
|
|
174
|
+
list(opts = {}) {
|
|
175
|
+
return listActivities(this.http, `/servers/${this.serverId}/activities`, opts);
|
|
135
176
|
}
|
|
136
177
|
/**
|
|
137
178
|
* Fetch a single activity log entry.
|
|
@@ -37,8 +37,8 @@ export declare class ServerAllocationPort extends ReactiveResource {
|
|
|
37
37
|
/** Optional human-readable description for this allocation, e.g. `"Voice Chat"`. */
|
|
38
38
|
description: string | null;
|
|
39
39
|
/** NanoID of the underlying port record. */
|
|
40
|
-
|
|
41
|
-
/** Full metadata about the underlying port. */
|
|
40
|
+
metaId: NanoID | undefined;
|
|
41
|
+
/** Full metadata about the underlying port. Requires `?include=meta` (sent automatically). */
|
|
42
42
|
meta: AllocationPortMeta | null | undefined;
|
|
43
43
|
/** `true` if this is the server's primary allocation. */
|
|
44
44
|
isPrimary: boolean;
|
|
@@ -73,7 +73,7 @@ export type AddAllocationEntry = {
|
|
|
73
73
|
* ```ts ignore
|
|
74
74
|
* const ports = await server.allocations.list();
|
|
75
75
|
* const primary = await server.allocations.primary();
|
|
76
|
-
* await server.allocations.update(
|
|
76
|
+
* await server.allocations.update(allocationId, { description: 'Game port', isPrimary: true });
|
|
77
77
|
* await server.allocations.add([{ ip: '1.2.3.4', port: 25566 }]);
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allocations.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/allocations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,0DAA0D;IAC1D,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,oCAAoC;IACpC,SAAS,EAAE,IAAI,CAAC;IAChB,uCAAuC;IACvC,SAAS,EAAE,IAAI,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACzD,oDAAoD;IACpD,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,oFAAoF;IAC7E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,4CAA4C;IACrC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC
|
|
1
|
+
{"version":3,"file":"allocations.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/allocations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,0DAA0D;IAC1D,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB;IACtB,KAAK,E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AIG;IACU,IAAI,CAChB,IAAI,GAAE,WAAgB,GACpB,OAAO,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAY3C;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAQrD;;;;OAIG;IACU,GAAG,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQrE;;;;;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"}
|
|
@@ -14,8 +14,8 @@ export class ServerAllocationPort extends ReactiveResource {
|
|
|
14
14
|
/** Optional human-readable description for this allocation, e.g. `"Voice Chat"`. */
|
|
15
15
|
description;
|
|
16
16
|
/** NanoID of the underlying port record. */
|
|
17
|
-
|
|
18
|
-
/** Full metadata about the underlying port. */
|
|
17
|
+
metaId;
|
|
18
|
+
/** Full metadata about the underlying port. Requires `?include=meta` (sent automatically). */
|
|
19
19
|
meta;
|
|
20
20
|
/** `true` if this is the server's primary allocation. */
|
|
21
21
|
isPrimary;
|
|
@@ -42,7 +42,7 @@ export class ServerAllocationPort extends ReactiveResource {
|
|
|
42
42
|
super();
|
|
43
43
|
this.id = toNanoID(data.id);
|
|
44
44
|
this.description = data.description ?? null;
|
|
45
|
-
this.
|
|
45
|
+
this.metaId = data.meta_id ? toNanoID(data.meta_id) : undefined;
|
|
46
46
|
this.meta = data.meta
|
|
47
47
|
? {
|
|
48
48
|
id: toNanoID(data.meta.id),
|
|
@@ -69,7 +69,7 @@ export class ServerAllocationPort extends ReactiveResource {
|
|
|
69
69
|
* ```ts ignore
|
|
70
70
|
* const ports = await server.allocations.list();
|
|
71
71
|
* const primary = await server.allocations.primary();
|
|
72
|
-
* await server.allocations.update(
|
|
72
|
+
* await server.allocations.update(allocationId, { description: 'Game port', isPrimary: true });
|
|
73
73
|
* await server.allocations.add([{ ip: '1.2.3.4', port: 25566 }]);
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
@@ -87,7 +87,7 @@ export class ServerAllocationsManager {
|
|
|
87
87
|
* @param opts Pagination options.
|
|
88
88
|
*/
|
|
89
89
|
async list(opts = {}) {
|
|
90
|
-
const result = await this.http.list(`/servers/${this.serverId}/allocations`, opts);
|
|
90
|
+
const result = await this.http.list(`/servers/${this.serverId}/allocations`, opts, { include: 'meta' });
|
|
91
91
|
return {
|
|
92
92
|
...result,
|
|
93
93
|
data: result.data.map((d) => new ServerAllocationPort(d)),
|
|
@@ -99,7 +99,7 @@ export class ServerAllocationsManager {
|
|
|
99
99
|
* @throws {@link ApiError} with `isNotFound === true` if no primary allocation is set.
|
|
100
100
|
*/
|
|
101
101
|
async primary() {
|
|
102
|
-
const data = await this.http.get(`/servers/${this.serverId}/allocations/primary
|
|
102
|
+
const data = await this.http.get(`/servers/${this.serverId}/allocations/primary`, { params: { include: 'meta' } });
|
|
103
103
|
return new ServerAllocationPort(data);
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
@@ -108,7 +108,7 @@ export class ServerAllocationsManager {
|
|
|
108
108
|
* @param allocationId The allocation record's NanoID.
|
|
109
109
|
*/
|
|
110
110
|
async get(allocationId) {
|
|
111
|
-
const data = await this.http.get(`/servers/${this.serverId}/allocations/${allocationId}
|
|
111
|
+
const data = await this.http.get(`/servers/${this.serverId}/allocations/${allocationId}`, { params: { include: 'meta' } });
|
|
112
112
|
return new ServerAllocationPort(data);
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ServerJob } from './jobs.js';
|
|
2
|
+
import type { NodeClient } from './node-client.js';
|
|
3
|
+
/** Backup storage adapter. `whisker` is local node storage; `s3` is remote. */
|
|
4
|
+
export type BackupAdapter = 'whisker' | 's3';
|
|
5
|
+
/** Options for creating a backup. */
|
|
6
|
+
export interface CreateBackupOptions {
|
|
7
|
+
/** Storage adapter to write the backup to. */
|
|
8
|
+
adapter: BackupAdapter;
|
|
9
|
+
/** Client-chosen UUID identifying the backup. */
|
|
10
|
+
uuid: string;
|
|
11
|
+
/** Newline- or glob-separated ignore patterns. */
|
|
12
|
+
ignore?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Options for restoring a backup. */
|
|
15
|
+
export interface RestoreBackupOptions {
|
|
16
|
+
/** Storage adapter the backup lives on. */
|
|
17
|
+
adapter: BackupAdapter;
|
|
18
|
+
/** Wipe the server's data directory before restoring. */
|
|
19
|
+
truncateDirectory?: boolean;
|
|
20
|
+
/** Download URL for the archive. Required for the `s3` adapter. */
|
|
21
|
+
downloadUrl?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create, restore, and delete backups on a server's node daemon.
|
|
25
|
+
*
|
|
26
|
+
* Create and restore run as daemon jobs, both return a {@link ServerJob} to track to
|
|
27
|
+
* completion. Access via `server.backups`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts ignore
|
|
31
|
+
* const job = await server.backups.create({ adapter: 'whisker', uuid });
|
|
32
|
+
* await job.wait();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class ServerBackupsManager {
|
|
36
|
+
private readonly node;
|
|
37
|
+
/** @internal */
|
|
38
|
+
constructor(node: NodeClient);
|
|
39
|
+
/** Start a backup. Returns the job to track. */
|
|
40
|
+
create(opts: CreateBackupOptions): Promise<ServerJob>;
|
|
41
|
+
/** Restore a backup by its UUID. Returns the job to track. */
|
|
42
|
+
restore(backupUuid: string, opts: RestoreBackupOptions): Promise<ServerJob>;
|
|
43
|
+
/** Delete a backup by its UUID. Treats an already-missing backup as success. */
|
|
44
|
+
delete(backupUuid: string): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=backups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backups.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/backups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC;AAE7C,qCAAqC;AACrC,MAAM,WAAW,mBAAmB;IACnC,8CAA8C;IAC9C,OAAO,EAAE,aAAa,CAAC;IACvB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,sCAAsC;AACtC,MAAM,WAAW,oBAAoB;IACpC,2CAA2C;IAC3C,OAAO,EAAE,aAAa,CAAC;IACvB,yDAAyD;IACzD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,oBAAoB;IAEb,OAAO,CAAC,QAAQ,CAAC,IAAI;IADxC,gBAAgB;gBACoB,IAAI,EAAE,UAAU;IAEpD,gDAAgD;IACnC,MAAM,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC;IASlE,8DAA8D;IACjD,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC;IASxF,gFAAgF;IACnE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ServerJob } from './jobs.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create, restore, and delete backups on a server's node daemon.
|
|
4
|
+
*
|
|
5
|
+
* Create and restore run as daemon jobs, both return a {@link ServerJob} to track to
|
|
6
|
+
* completion. Access via `server.backups`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts ignore
|
|
10
|
+
* const job = await server.backups.create({ adapter: 'whisker', uuid });
|
|
11
|
+
* await job.wait();
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export class ServerBackupsManager {
|
|
15
|
+
node;
|
|
16
|
+
/** @internal */
|
|
17
|
+
constructor(node) {
|
|
18
|
+
this.node = node;
|
|
19
|
+
}
|
|
20
|
+
/** Start a backup. Returns the job to track. */
|
|
21
|
+
async create(opts) {
|
|
22
|
+
const { data } = await this.node.postJson('/backup', {
|
|
23
|
+
adapter: opts.adapter,
|
|
24
|
+
uuid: opts.uuid,
|
|
25
|
+
ignore: opts.ignore ?? '',
|
|
26
|
+
});
|
|
27
|
+
return new ServerJob({ id: data.job_id }, this.node);
|
|
28
|
+
}
|
|
29
|
+
/** Restore a backup by its UUID. Returns the job to track. */
|
|
30
|
+
async restore(backupUuid, opts) {
|
|
31
|
+
const body = { adapter: opts.adapter };
|
|
32
|
+
if (opts.truncateDirectory !== undefined)
|
|
33
|
+
body['truncate_directory'] = opts.truncateDirectory;
|
|
34
|
+
if (opts.downloadUrl !== undefined)
|
|
35
|
+
body['download_url'] = opts.downloadUrl;
|
|
36
|
+
const { data } = await this.node.postJson(`/backup/${backupUuid}/restore`, body);
|
|
37
|
+
return new ServerJob({ id: data.job_id }, this.node);
|
|
38
|
+
}
|
|
39
|
+
/** Delete a backup by its UUID. Treats an already-missing backup as success. */
|
|
40
|
+
async delete(backupUuid) {
|
|
41
|
+
await this.node.fetch(`/backup/${backupUuid}`, { method: 'DELETE' });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactiveResource } from '../../reactive.js';
|
|
2
2
|
import type { NanoID, PowerState } from '../../types.js';
|
|
3
|
+
import type { JobStatus } from './jobs.js';
|
|
3
4
|
/** Real-time resource utilization reported by the node. */
|
|
4
5
|
export interface ServerUtilization {
|
|
5
6
|
/** CPU usage as an absolute percentage (0–100+). */
|
|
@@ -17,6 +18,21 @@ export interface ServerUtilization {
|
|
|
17
18
|
/** Server uptime in milliseconds. */
|
|
18
19
|
uptimeMs: number;
|
|
19
20
|
}
|
|
21
|
+
/** Live progress update for a daemon job (compress, decompress, backup, restore). */
|
|
22
|
+
export interface JobProgressEvent {
|
|
23
|
+
jobId: string;
|
|
24
|
+
type: string;
|
|
25
|
+
status: JobStatus;
|
|
26
|
+
progress: number;
|
|
27
|
+
message: string;
|
|
28
|
+
}
|
|
29
|
+
/** A single log line emitted by a daemon job. */
|
|
30
|
+
export interface JobLogEvent {
|
|
31
|
+
jobId: string;
|
|
32
|
+
type: string;
|
|
33
|
+
group: string;
|
|
34
|
+
message: string;
|
|
35
|
+
}
|
|
20
36
|
/** Typed events emitted by {@link ServerConnection}. */
|
|
21
37
|
export interface ServerConnectionEvents {
|
|
22
38
|
/** A line of console output from the server process. */
|
|
@@ -25,6 +41,10 @@ export interface ServerConnectionEvents {
|
|
|
25
41
|
status: PowerState;
|
|
26
42
|
/** New resource utilization stats are available. */
|
|
27
43
|
stats: ServerUtilization;
|
|
44
|
+
/** A daemon job advanced (progress, status, or message changed). */
|
|
45
|
+
job_progress: JobProgressEvent;
|
|
46
|
+
/** A daemon job emitted a log line. */
|
|
47
|
+
job_log: JobLogEvent;
|
|
28
48
|
}
|
|
29
49
|
/**
|
|
30
50
|
* A real-time SSE connection to a specific server on its Whisker node daemon.
|
|
@@ -33,22 +53,22 @@ export interface ServerConnectionEvents {
|
|
|
33
53
|
* Also maintains a rolling buffer of console output lines in {@link output}, pre-populated
|
|
34
54
|
* with recent history fetched from the node on {@link connect}.
|
|
35
55
|
*
|
|
36
|
-
* Obtain a connection via
|
|
56
|
+
* Obtain a connection via `Server.createConnection`.
|
|
37
57
|
*
|
|
38
58
|
* @example
|
|
39
59
|
* ```ts ignore
|
|
40
|
-
* const conn = await server.
|
|
60
|
+
* const conn = await server.createConnection();
|
|
41
61
|
*
|
|
42
62
|
* conn.on('status', (state) => console.log('Power state:', state));
|
|
43
63
|
* conn.on('stats', (stats) => console.log('CPU:', stats.cpuAbsolute + '%'));
|
|
44
64
|
*
|
|
45
|
-
* await conn.
|
|
65
|
+
* await conn.open();
|
|
46
66
|
*
|
|
47
67
|
* // Reactive: $conn.output is the full rolling buffer of console lines
|
|
48
68
|
* // Live lines are appended automatically as they arrive over SSE
|
|
49
69
|
*
|
|
50
70
|
* // Later...
|
|
51
|
-
* conn.
|
|
71
|
+
* conn.close();
|
|
52
72
|
* ```
|
|
53
73
|
*/
|
|
54
74
|
export declare class ServerConnection extends ReactiveResource {
|
|
@@ -61,9 +81,9 @@ export declare class ServerConnection extends ReactiveResource {
|
|
|
61
81
|
private sse?;
|
|
62
82
|
private connected;
|
|
63
83
|
/**
|
|
64
|
-
* Rolling buffer of console output lines, capped at {@link
|
|
84
|
+
* Rolling buffer of console output lines, capped at {@link ServerConnection.maxOutputLines}.
|
|
65
85
|
*
|
|
66
|
-
* Pre-populated with recent history from the node when {@link
|
|
86
|
+
* Pre-populated with recent history from the node when {@link open} is called,
|
|
67
87
|
* then appended to live as `console_output` SSE events arrive.
|
|
68
88
|
*
|
|
69
89
|
* Use as a reactive store: `$conn.output`.
|
|
@@ -79,7 +99,7 @@ export declare class ServerConnection extends ReactiveResource {
|
|
|
79
99
|
* Populates {@link output} with recent history from the node, then begins streaming
|
|
80
100
|
* live events.
|
|
81
101
|
*
|
|
82
|
-
*
|
|
102
|
+
* Only one stream is maintained at a time.
|
|
83
103
|
*
|
|
84
104
|
* @param onError Optional callback invoked if the connection drops unexpectedly.
|
|
85
105
|
*/
|
|
@@ -1 +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,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
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,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,2DAA2D;AAC3D,MAAM,WAAW,iBAAiB;IACjC,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,cAAc,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,qFAAqF;AACrF,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,wDAAwD;AACxD,MAAM,WAAW,sBAAsB;IACtC,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,MAAM,EAAE,UAAU,CAAC;IACnB,oDAAoD;IACpD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AAkB,IAAI,IAAI;IAIjC,iEAAiE;IACjE,OAAO,CAAC,QAAQ;CA0DhB"}
|
|
@@ -7,22 +7,22 @@ import { SseConnection } from '../../sse.js';
|
|
|
7
7
|
* Also maintains a rolling buffer of console output lines in {@link output}, pre-populated
|
|
8
8
|
* with recent history fetched from the node on {@link connect}.
|
|
9
9
|
*
|
|
10
|
-
* Obtain a connection via
|
|
10
|
+
* Obtain a connection via `Server.createConnection`.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts ignore
|
|
14
|
-
* const conn = await server.
|
|
14
|
+
* const conn = await server.createConnection();
|
|
15
15
|
*
|
|
16
16
|
* conn.on('status', (state) => console.log('Power state:', state));
|
|
17
17
|
* conn.on('stats', (stats) => console.log('CPU:', stats.cpuAbsolute + '%'));
|
|
18
18
|
*
|
|
19
|
-
* await conn.
|
|
19
|
+
* await conn.open();
|
|
20
20
|
*
|
|
21
21
|
* // Reactive: $conn.output is the full rolling buffer of console lines
|
|
22
22
|
* // Live lines are appended automatically as they arrive over SSE
|
|
23
23
|
*
|
|
24
24
|
* // Later...
|
|
25
|
-
* conn.
|
|
25
|
+
* conn.close();
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export class ServerConnection extends ReactiveResource {
|
|
@@ -35,9 +35,9 @@ export class ServerConnection extends ReactiveResource {
|
|
|
35
35
|
sse;
|
|
36
36
|
connected = false;
|
|
37
37
|
/**
|
|
38
|
-
* Rolling buffer of console output lines, capped at {@link
|
|
38
|
+
* Rolling buffer of console output lines, capped at {@link ServerConnection.maxOutputLines}.
|
|
39
39
|
*
|
|
40
|
-
* Pre-populated with recent history from the node when {@link
|
|
40
|
+
* Pre-populated with recent history from the node when {@link open} is called,
|
|
41
41
|
* then appended to live as `console_output` SSE events arrive.
|
|
42
42
|
*
|
|
43
43
|
* Use as a reactive store: `$conn.output`.
|
|
@@ -60,7 +60,7 @@ export class ServerConnection extends ReactiveResource {
|
|
|
60
60
|
* Populates {@link output} with recent history from the node, then begins streaming
|
|
61
61
|
* live events.
|
|
62
62
|
*
|
|
63
|
-
*
|
|
63
|
+
* Only one stream is maintained at a time.
|
|
64
64
|
*
|
|
65
65
|
* @param onError Optional callback invoked if the connection drops unexpectedly.
|
|
66
66
|
*/
|
|
@@ -156,6 +156,27 @@ export class ServerConnection extends ReactiveResource {
|
|
|
156
156
|
uptimeMs: parsed.uptime_ms,
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
+
else if (event === 'job_progress') {
|
|
160
|
+
if (typeof parsed?.job_id !== 'string')
|
|
161
|
+
return;
|
|
162
|
+
payload = {
|
|
163
|
+
jobId: parsed.job_id,
|
|
164
|
+
type: parsed.type,
|
|
165
|
+
status: parsed.status,
|
|
166
|
+
progress: parsed.progress,
|
|
167
|
+
message: parsed.message,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
else if (event === 'job_log') {
|
|
171
|
+
if (typeof parsed?.job_id !== 'string')
|
|
172
|
+
return;
|
|
173
|
+
payload = {
|
|
174
|
+
jobId: parsed.job_id,
|
|
175
|
+
type: parsed.type,
|
|
176
|
+
group: parsed.group,
|
|
177
|
+
message: parsed.message,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
159
180
|
else {
|
|
160
181
|
return;
|
|
161
182
|
}
|