@meowpanel/api 0.3.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 +37 -16
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +25 -7
- 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/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 +50 -19
- package/esm/src/resources/account.d.ts.map +1 -1
- package/esm/src/resources/account.js +51 -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 +92 -17
- package/esm/src/resources/nodes.d.ts.map +1 -1
- package/esm/src/resources/nodes.js +108 -16
- 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 +12 -19
- package/esm/src/resources/servers/sftp.d.ts.map +1 -1
- package/esm/src/resources/servers/sftp.js +10 -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 +37 -16
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +50 -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/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 +50 -19
- package/script/src/resources/account.d.ts.map +1 -1
- package/script/src/resources/account.js +50 -12
- 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 +92 -17
- package/script/src/resources/nodes.d.ts.map +1 -1
- package/script/src/resources/nodes.js +109 -16
- 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 +12 -19
- package/script/src/resources/servers/sftp.d.ts.map +1 -1
- package/script/src/resources/servers/sftp.js +10 -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,gBAAgB;IAChD,+BAA+B;IAC/B,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,0BAA0B;IACnB,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtD,gEAAg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HtB,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,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ServerActivityManager = exports.ActivityLog = exports.ActivityJob = exports.ActivityJobLog = void 0;
|
|
4
|
+
exports.listActivities = listActivities;
|
|
4
5
|
const reactive_js_1 = require("../../reactive.js");
|
|
5
6
|
const types_js_1 = require("../../types.js");
|
|
6
|
-
const
|
|
7
|
+
const users_js_1 = require("../users.js");
|
|
7
8
|
/**
|
|
8
9
|
* A single log entry within an {@link ActivityJob}.
|
|
9
10
|
*/
|
|
10
11
|
class ActivityJobLog {
|
|
11
|
-
/** The type
|
|
12
|
-
|
|
12
|
+
/** The event type identifier, e.g. `"server.power.start"`. */
|
|
13
|
+
event;
|
|
13
14
|
/** Structured metadata about this log event. */
|
|
14
15
|
metadata;
|
|
15
16
|
/** When this log entry was created. */
|
|
16
17
|
createdAt;
|
|
17
18
|
/** @internal */
|
|
18
19
|
constructor(data) {
|
|
19
|
-
this.
|
|
20
|
+
this.event = data.event;
|
|
20
21
|
this.metadata = data.metadata;
|
|
21
22
|
this.createdAt = new Date(data.created_at);
|
|
22
23
|
}
|
|
@@ -80,10 +81,22 @@ class ActivityLog extends reactive_js_1.ReactiveResource {
|
|
|
80
81
|
serverId;
|
|
81
82
|
/** NanoID of the node this activity is associated with, if any. */
|
|
82
83
|
nodeId;
|
|
83
|
-
/** NanoID of the
|
|
84
|
+
/** NanoID of the server group this activity is associated with, if any. */
|
|
85
|
+
groupId;
|
|
86
|
+
/** NanoID of the host this activity is associated with, if any. */
|
|
87
|
+
hostId;
|
|
88
|
+
/** The issuer's bare NanoID (parsed from the namespaced `issuer_id`), or `null`. */
|
|
84
89
|
issuerId;
|
|
85
|
-
/** The
|
|
90
|
+
/** The issuer's type, e.g. `'user'`, `'node'`, `'system'`, or `null`. */
|
|
91
|
+
issuerType;
|
|
92
|
+
/** The issuer who triggered this activity. */
|
|
86
93
|
issuer;
|
|
94
|
+
/** The subject's bare NanoID (parsed from the namespaced `subject_id`), or `null`. */
|
|
95
|
+
subjectId;
|
|
96
|
+
/** The subject's type, or `null`. */
|
|
97
|
+
subjectType;
|
|
98
|
+
/** The subject this action was performed on. */
|
|
99
|
+
subject;
|
|
87
100
|
/** The IP address the action was performed from, if available. */
|
|
88
101
|
ip;
|
|
89
102
|
/** Structured metadata about this activity (content depends on the event type). */
|
|
@@ -101,8 +114,16 @@ class ActivityLog extends reactive_js_1.ReactiveResource {
|
|
|
101
114
|
this.event = data.event;
|
|
102
115
|
this.serverId = data.server_id ? (0, types_js_1.toNanoID)(data.server_id) : null;
|
|
103
116
|
this.nodeId = data.node_id ? (0, types_js_1.toNanoID)(data.node_id) : null;
|
|
104
|
-
this.
|
|
105
|
-
this.
|
|
117
|
+
this.groupId = data.group_id ? (0, types_js_1.toNanoID)(data.group_id) : null;
|
|
118
|
+
this.hostId = data.host_id ? (0, types_js_1.toNanoID)(data.host_id) : null;
|
|
119
|
+
const issuer = data.issuer_id ? (0, types_js_1.parseIssuerRef)(data.issuer_id) : null;
|
|
120
|
+
this.issuerId = issuer ? issuer.id : null;
|
|
121
|
+
this.issuerType = issuer ? issuer.type : null;
|
|
122
|
+
this.issuer = data.issuer ? new users_js_1.User(data.issuer) : data.issuer;
|
|
123
|
+
const subject = data.subject_id ? (0, types_js_1.parseIssuerRef)(data.subject_id) : null;
|
|
124
|
+
this.subjectId = subject ? subject.id : null;
|
|
125
|
+
this.subjectType = subject ? subject.type : null;
|
|
126
|
+
this.subject = data.subject ? new users_js_1.User(data.subject) : data.subject;
|
|
106
127
|
this.ip = data.ip;
|
|
107
128
|
this.metadata = data.metadata;
|
|
108
129
|
this.jobId = data.job_id ? (0, types_js_1.toNanoID)(data.job_id) : null;
|
|
@@ -111,6 +132,28 @@ class ActivityLog extends reactive_js_1.ReactiveResource {
|
|
|
111
132
|
}
|
|
112
133
|
}
|
|
113
134
|
exports.ActivityLog = ActivityLog;
|
|
135
|
+
/**
|
|
136
|
+
* Fetch an activity-log feed and map the entries to {@link ActivityLog} instances.
|
|
137
|
+
*
|
|
138
|
+
* @param extra Endpoint-specific query params (e.g. `scope`).
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
async function listActivities(http, path, opts = {}, extra = {}) {
|
|
142
|
+
const params = {
|
|
143
|
+
sort: opts.sort,
|
|
144
|
+
type: opts.type,
|
|
145
|
+
ip: opts.ip,
|
|
146
|
+
issuer_id: opts.issuerId,
|
|
147
|
+
subject_user_id: opts.subjectUserId,
|
|
148
|
+
server_id: opts.serverId,
|
|
149
|
+
group_id: opts.groupId,
|
|
150
|
+
node_id: opts.nodeId,
|
|
151
|
+
host_id: opts.hostId,
|
|
152
|
+
...extra,
|
|
153
|
+
};
|
|
154
|
+
const result = await http.list(path, { page: opts.page, perPage: opts.perPage }, params);
|
|
155
|
+
return { ...result, data: result.data.map((d) => new ActivityLog(d)) };
|
|
156
|
+
}
|
|
114
157
|
/**
|
|
115
158
|
* Manages activity logs and async jobs for a specific server.
|
|
116
159
|
*
|
|
@@ -133,11 +176,10 @@ class ServerActivityManager {
|
|
|
133
176
|
/**
|
|
134
177
|
* Fetch a paginated list of activity log entries for this server.
|
|
135
178
|
*
|
|
136
|
-
* @param opts Pagination options.
|
|
179
|
+
* @param opts Pagination and filter options.
|
|
137
180
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return { ...result, data: result.data.map((d) => new ActivityLog(d)) };
|
|
181
|
+
list(opts = {}) {
|
|
182
|
+
return listActivities(this.http, `/servers/${this.serverId}/activities`, opts);
|
|
141
183
|
}
|
|
142
184
|
/**
|
|
143
185
|
* 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,EA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AQ,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;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"}
|
|
@@ -17,8 +17,8 @@ class ServerAllocationPort extends reactive_js_1.ReactiveResource {
|
|
|
17
17
|
/** Optional human-readable description for this allocation, e.g. `"Voice Chat"`. */
|
|
18
18
|
description;
|
|
19
19
|
/** NanoID of the underlying port record. */
|
|
20
|
-
|
|
21
|
-
/** Full metadata about the underlying port. */
|
|
20
|
+
metaId;
|
|
21
|
+
/** Full metadata about the underlying port. Requires `?include=meta` (sent automatically). */
|
|
22
22
|
meta;
|
|
23
23
|
/** `true` if this is the server's primary allocation. */
|
|
24
24
|
isPrimary;
|
|
@@ -45,7 +45,7 @@ class ServerAllocationPort extends reactive_js_1.ReactiveResource {
|
|
|
45
45
|
super();
|
|
46
46
|
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
47
47
|
this.description = data.description ?? null;
|
|
48
|
-
this.
|
|
48
|
+
this.metaId = data.meta_id ? (0, types_js_1.toNanoID)(data.meta_id) : undefined;
|
|
49
49
|
this.meta = data.meta
|
|
50
50
|
? {
|
|
51
51
|
id: (0, types_js_1.toNanoID)(data.meta.id),
|
|
@@ -73,7 +73,7 @@ exports.ServerAllocationPort = ServerAllocationPort;
|
|
|
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
|
*/
|
|
@@ -91,7 +91,7 @@ class ServerAllocationsManager {
|
|
|
91
91
|
* @param opts Pagination options.
|
|
92
92
|
*/
|
|
93
93
|
async list(opts = {}) {
|
|
94
|
-
const result = await this.http.list(`/servers/${this.serverId}/allocations`, opts);
|
|
94
|
+
const result = await this.http.list(`/servers/${this.serverId}/allocations`, opts, { include: 'meta' });
|
|
95
95
|
return {
|
|
96
96
|
...result,
|
|
97
97
|
data: result.data.map((d) => new ServerAllocationPort(d)),
|
|
@@ -103,7 +103,7 @@ class ServerAllocationsManager {
|
|
|
103
103
|
* @throws {@link ApiError} with `isNotFound === true` if no primary allocation is set.
|
|
104
104
|
*/
|
|
105
105
|
async primary() {
|
|
106
|
-
const data = await this.http.get(`/servers/${this.serverId}/allocations/primary
|
|
106
|
+
const data = await this.http.get(`/servers/${this.serverId}/allocations/primary`, { params: { include: 'meta' } });
|
|
107
107
|
return new ServerAllocationPort(data);
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
@@ -112,7 +112,7 @@ class ServerAllocationsManager {
|
|
|
112
112
|
* @param allocationId The allocation record's NanoID.
|
|
113
113
|
*/
|
|
114
114
|
async get(allocationId) {
|
|
115
|
-
const data = await this.http.get(`/servers/${this.serverId}/allocations/${allocationId}
|
|
115
|
+
const data = await this.http.get(`/servers/${this.serverId}/allocations/${allocationId}`, { params: { include: 'meta' } });
|
|
116
116
|
return new ServerAllocationPort(data);
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
@@ -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,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServerBackupsManager = void 0;
|
|
4
|
+
const jobs_js_1 = require("./jobs.js");
|
|
5
|
+
/**
|
|
6
|
+
* Create, restore, and delete backups on a server's node daemon.
|
|
7
|
+
*
|
|
8
|
+
* Create and restore run as daemon jobs, both return a {@link ServerJob} to track to
|
|
9
|
+
* completion. Access via `server.backups`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts ignore
|
|
13
|
+
* const job = await server.backups.create({ adapter: 'whisker', uuid });
|
|
14
|
+
* await job.wait();
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
class ServerBackupsManager {
|
|
18
|
+
node;
|
|
19
|
+
/** @internal */
|
|
20
|
+
constructor(node) {
|
|
21
|
+
this.node = node;
|
|
22
|
+
}
|
|
23
|
+
/** Start a backup. Returns the job to track. */
|
|
24
|
+
async create(opts) {
|
|
25
|
+
const { data } = await this.node.postJson('/backup', {
|
|
26
|
+
adapter: opts.adapter,
|
|
27
|
+
uuid: opts.uuid,
|
|
28
|
+
ignore: opts.ignore ?? '',
|
|
29
|
+
});
|
|
30
|
+
return new jobs_js_1.ServerJob({ id: data.job_id }, this.node);
|
|
31
|
+
}
|
|
32
|
+
/** Restore a backup by its UUID. Returns the job to track. */
|
|
33
|
+
async restore(backupUuid, opts) {
|
|
34
|
+
const body = { adapter: opts.adapter };
|
|
35
|
+
if (opts.truncateDirectory !== undefined)
|
|
36
|
+
body['truncate_directory'] = opts.truncateDirectory;
|
|
37
|
+
if (opts.downloadUrl !== undefined)
|
|
38
|
+
body['download_url'] = opts.downloadUrl;
|
|
39
|
+
const { data } = await this.node.postJson(`/backup/${backupUuid}/restore`, body);
|
|
40
|
+
return new jobs_js_1.ServerJob({ id: data.job_id }, this.node);
|
|
41
|
+
}
|
|
42
|
+
/** Delete a backup by its UUID. Treats an already-missing backup as success. */
|
|
43
|
+
async delete(backupUuid) {
|
|
44
|
+
await this.node.fetch(`/backup/${backupUuid}`, { method: 'DELETE' });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.ServerBackupsManager = ServerBackupsManager;
|
|
@@ -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,i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AC/C,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,IAAI,GACnD,IAAI;IAWP;;;;;OAKG;IACI,GAAG,CAAC,CAAC,SAAS,MAAM,sBAAsB,EAChD,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,IAAI,GACnD,IAAI;IAUP,qDAAqD;IAC9C,kBAAkB,IAAI,IAAI;IAIjC,iEAAiE;IACjE,OAAO,CAAC,QAAQ;CA0DhB"}
|
|
@@ -10,22 +10,22 @@ const sse_js_1 = require("../../sse.js");
|
|
|
10
10
|
* Also maintains a rolling buffer of console output lines in {@link output}, pre-populated
|
|
11
11
|
* with recent history fetched from the node on {@link connect}.
|
|
12
12
|
*
|
|
13
|
-
* Obtain a connection via
|
|
13
|
+
* Obtain a connection via `Server.createConnection`.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts ignore
|
|
17
|
-
* const conn = await server.
|
|
17
|
+
* const conn = await server.createConnection();
|
|
18
18
|
*
|
|
19
19
|
* conn.on('status', (state) => console.log('Power state:', state));
|
|
20
20
|
* conn.on('stats', (stats) => console.log('CPU:', stats.cpuAbsolute + '%'));
|
|
21
21
|
*
|
|
22
|
-
* await conn.
|
|
22
|
+
* await conn.open();
|
|
23
23
|
*
|
|
24
24
|
* // Reactive: $conn.output is the full rolling buffer of console lines
|
|
25
25
|
* // Live lines are appended automatically as they arrive over SSE
|
|
26
26
|
*
|
|
27
27
|
* // Later...
|
|
28
|
-
* conn.
|
|
28
|
+
* conn.close();
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
class ServerConnection extends reactive_js_1.ReactiveResource {
|
|
@@ -38,9 +38,9 @@ class ServerConnection extends reactive_js_1.ReactiveResource {
|
|
|
38
38
|
sse;
|
|
39
39
|
connected = false;
|
|
40
40
|
/**
|
|
41
|
-
* Rolling buffer of console output lines, capped at {@link
|
|
41
|
+
* Rolling buffer of console output lines, capped at {@link ServerConnection.maxOutputLines}.
|
|
42
42
|
*
|
|
43
|
-
* Pre-populated with recent history from the node when {@link
|
|
43
|
+
* Pre-populated with recent history from the node when {@link open} is called,
|
|
44
44
|
* then appended to live as `console_output` SSE events arrive.
|
|
45
45
|
*
|
|
46
46
|
* Use as a reactive store: `$conn.output`.
|
|
@@ -63,7 +63,7 @@ class ServerConnection extends reactive_js_1.ReactiveResource {
|
|
|
63
63
|
* Populates {@link output} with recent history from the node, then begins streaming
|
|
64
64
|
* live events.
|
|
65
65
|
*
|
|
66
|
-
*
|
|
66
|
+
* Only one stream is maintained at a time.
|
|
67
67
|
*
|
|
68
68
|
* @param onError Optional callback invoked if the connection drops unexpectedly.
|
|
69
69
|
*/
|
|
@@ -159,6 +159,27 @@ class ServerConnection extends reactive_js_1.ReactiveResource {
|
|
|
159
159
|
uptimeMs: parsed.uptime_ms,
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
+
else if (event === 'job_progress') {
|
|
163
|
+
if (typeof parsed?.job_id !== 'string')
|
|
164
|
+
return;
|
|
165
|
+
payload = {
|
|
166
|
+
jobId: parsed.job_id,
|
|
167
|
+
type: parsed.type,
|
|
168
|
+
status: parsed.status,
|
|
169
|
+
progress: parsed.progress,
|
|
170
|
+
message: parsed.message,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
else if (event === 'job_log') {
|
|
174
|
+
if (typeof parsed?.job_id !== 'string')
|
|
175
|
+
return;
|
|
176
|
+
payload = {
|
|
177
|
+
jobId: parsed.job_id,
|
|
178
|
+
type: parsed.type,
|
|
179
|
+
group: parsed.group,
|
|
180
|
+
message: parsed.message,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
162
183
|
else {
|
|
163
184
|
return;
|
|
164
185
|
}
|