@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.
- package/LICENSE +1 -1
- package/README.md +40 -0
- package/esm/mod.d.ts +87 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +85 -1
- package/esm/src/client.d.ts +248 -0
- package/esm/src/client.d.ts.map +1 -0
- package/esm/src/client.js +235 -0
- package/esm/src/emitter.d.ts +53 -0
- package/esm/src/emitter.d.ts.map +1 -0
- package/esm/src/emitter.js +55 -0
- package/esm/src/errors.d.ts +42 -0
- package/esm/src/errors.d.ts.map +1 -0
- package/esm/src/errors.js +45 -0
- package/esm/src/http.d.ts +157 -0
- package/esm/src/http.d.ts.map +1 -0
- package/esm/src/http.js +317 -0
- package/esm/src/namespace.d.ts +59 -0
- package/esm/src/namespace.d.ts.map +1 -0
- package/esm/src/namespace.js +79 -0
- package/esm/src/reactive.d.ts +29 -0
- package/esm/src/reactive.d.ts.map +1 -0
- package/esm/src/reactive.js +35 -0
- package/esm/src/resources/account.d.ts +125 -0
- package/esm/src/resources/account.d.ts.map +1 -0
- package/esm/src/resources/account.js +151 -0
- package/esm/src/resources/api-keys.d.ts +116 -0
- package/esm/src/resources/api-keys.d.ts.map +1 -0
- package/esm/src/resources/api-keys.js +105 -0
- package/esm/src/resources/auth.d.ts +57 -0
- package/esm/src/resources/auth.d.ts.map +1 -0
- package/esm/src/resources/auth.js +39 -0
- package/esm/src/resources/eggs.d.ts +238 -0
- package/esm/src/resources/eggs.d.ts.map +1 -0
- package/esm/src/resources/eggs.js +187 -0
- package/esm/src/resources/hosts.d.ts +62 -0
- package/esm/src/resources/hosts.d.ts.map +1 -0
- package/esm/src/resources/hosts.js +62 -0
- package/esm/src/resources/members.d.ts +138 -0
- package/esm/src/resources/members.d.ts.map +1 -0
- package/esm/src/resources/members.js +122 -0
- package/esm/src/resources/nodes.d.ts +397 -0
- package/esm/src/resources/nodes.d.ts.map +1 -0
- package/esm/src/resources/nodes.js +352 -0
- package/esm/src/resources/server-groups.d.ts +150 -0
- package/esm/src/resources/server-groups.d.ts.map +1 -0
- package/esm/src/resources/server-groups.js +111 -0
- package/esm/src/resources/servers/activity.d.ts +120 -0
- package/esm/src/resources/servers/activity.d.ts.map +1 -0
- package/esm/src/resources/servers/activity.js +163 -0
- package/esm/src/resources/servers/allocations.d.ts +125 -0
- package/esm/src/resources/servers/allocations.d.ts.map +1 -0
- package/esm/src/resources/servers/allocations.js +137 -0
- package/esm/src/resources/servers/connection.d.ts +108 -0
- package/esm/src/resources/servers/connection.d.ts.map +1 -0
- package/esm/src/resources/servers/connection.js +169 -0
- package/esm/src/resources/servers/files.d.ts +164 -0
- package/esm/src/resources/servers/files.d.ts.map +1 -0
- package/esm/src/resources/servers/files.js +281 -0
- package/esm/src/resources/servers/index.d.ts +126 -0
- package/esm/src/resources/servers/index.d.ts.map +1 -0
- package/esm/src/resources/servers/index.js +135 -0
- package/esm/src/resources/servers/profiles.d.ts +138 -0
- package/esm/src/resources/servers/profiles.d.ts.map +1 -0
- package/esm/src/resources/servers/profiles.js +177 -0
- package/esm/src/resources/servers/server.d.ts +136 -0
- package/esm/src/resources/servers/server.d.ts.map +1 -0
- package/esm/src/resources/servers/server.js +202 -0
- package/esm/src/resources/servers/sftp.d.ts +147 -0
- package/esm/src/resources/servers/sftp.d.ts.map +1 -0
- package/esm/src/resources/servers/sftp.js +153 -0
- package/esm/src/resources/servers/types.d.ts +199 -0
- package/esm/src/resources/servers/types.d.ts.map +1 -0
- package/esm/src/resources/servers/types.js +1 -0
- package/esm/src/sse.d.ts +53 -0
- package/esm/src/sse.d.ts.map +1 -0
- package/esm/src/sse.js +133 -0
- package/esm/src/types.d.ts +126 -0
- package/esm/src/types.d.ts.map +1 -0
- package/esm/src/types.js +21 -0
- package/package.json +4 -92
- package/script/mod.d.ts +87 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +132 -3
- package/script/src/client.d.ts +248 -0
- package/script/src/client.d.ts.map +1 -0
- package/script/src/client.js +239 -0
- package/script/src/emitter.d.ts +53 -0
- package/script/src/emitter.d.ts.map +1 -0
- package/script/src/emitter.js +59 -0
- package/script/src/errors.d.ts +42 -0
- package/script/src/errors.d.ts.map +1 -0
- package/script/src/errors.js +49 -0
- package/script/src/http.d.ts +157 -0
- package/script/src/http.d.ts.map +1 -0
- package/script/src/http.js +321 -0
- package/script/src/namespace.d.ts +59 -0
- package/script/src/namespace.d.ts.map +1 -0
- package/script/src/namespace.js +83 -0
- package/script/src/reactive.d.ts +29 -0
- package/script/src/reactive.d.ts.map +1 -0
- package/script/src/reactive.js +39 -0
- package/script/src/resources/account.d.ts +125 -0
- package/script/src/resources/account.d.ts.map +1 -0
- package/script/src/resources/account.js +158 -0
- package/script/src/resources/api-keys.d.ts +116 -0
- package/script/src/resources/api-keys.d.ts.map +1 -0
- package/script/src/resources/api-keys.js +110 -0
- package/script/src/resources/auth.d.ts +57 -0
- package/script/src/resources/auth.d.ts.map +1 -0
- package/script/src/resources/auth.js +43 -0
- package/script/src/resources/eggs.d.ts +238 -0
- package/script/src/resources/eggs.d.ts.map +1 -0
- package/script/src/resources/eggs.js +193 -0
- package/script/src/resources/hosts.d.ts +62 -0
- package/script/src/resources/hosts.d.ts.map +1 -0
- package/script/src/resources/hosts.js +67 -0
- package/script/src/resources/members.d.ts +138 -0
- package/script/src/resources/members.d.ts.map +1 -0
- package/script/src/resources/members.js +127 -0
- package/script/src/resources/nodes.d.ts +397 -0
- package/script/src/resources/nodes.d.ts.map +1 -0
- package/script/src/resources/nodes.js +362 -0
- package/script/src/resources/server-groups.d.ts +150 -0
- package/script/src/resources/server-groups.d.ts.map +1 -0
- package/script/src/resources/server-groups.js +116 -0
- package/script/src/resources/servers/activity.d.ts +120 -0
- package/script/src/resources/servers/activity.d.ts.map +1 -0
- package/script/src/resources/servers/activity.js +170 -0
- package/script/src/resources/servers/allocations.d.ts +125 -0
- package/script/src/resources/servers/allocations.d.ts.map +1 -0
- package/script/src/resources/servers/allocations.js +142 -0
- package/script/src/resources/servers/connection.d.ts +108 -0
- package/script/src/resources/servers/connection.d.ts.map +1 -0
- package/script/src/resources/servers/connection.js +173 -0
- package/script/src/resources/servers/files.d.ts +164 -0
- package/script/src/resources/servers/files.d.ts.map +1 -0
- package/script/src/resources/servers/files.js +286 -0
- package/script/src/resources/servers/index.d.ts +126 -0
- package/script/src/resources/servers/index.d.ts.map +1 -0
- package/script/src/resources/servers/index.js +139 -0
- package/script/src/resources/servers/profiles.d.ts +138 -0
- package/script/src/resources/servers/profiles.d.ts.map +1 -0
- package/script/src/resources/servers/profiles.js +182 -0
- package/script/src/resources/servers/server.d.ts +136 -0
- package/script/src/resources/servers/server.d.ts.map +1 -0
- package/script/src/resources/servers/server.js +206 -0
- package/script/src/resources/servers/sftp.d.ts +147 -0
- package/script/src/resources/servers/sftp.d.ts.map +1 -0
- package/script/src/resources/servers/sftp.js +158 -0
- package/script/src/resources/servers/types.d.ts +199 -0
- package/script/src/resources/servers/types.d.ts.map +1 -0
- package/script/src/resources/servers/types.js +2 -0
- package/script/src/sse.d.ts +53 -0
- package/script/src/sse.d.ts.map +1 -0
- package/script/src/sse.js +137 -0
- package/script/src/types.d.ts +126 -0
- package/script/src/types.d.ts.map +1 -0
- package/script/src/types.js +25 -0
- package/esm/api.d.ts +0 -76
- package/esm/api.d.ts.map +0 -1
- package/esm/api.js +0 -187
- package/esm/components/auth.d.ts +0 -15
- package/esm/components/auth.d.ts.map +0 -1
- package/esm/components/auth.js +0 -13
- package/esm/components/connection/abstract.d.ts +0 -23
- package/esm/components/connection/abstract.d.ts.map +0 -1
- package/esm/components/connection/abstract.js +0 -43
- package/esm/components/connection/sse.d.ts +0 -20
- package/esm/components/connection/sse.d.ts.map +0 -1
- package/esm/components/connection/sse.js +0 -65
- package/esm/components/egg/egg.d.ts +0 -32
- package/esm/components/egg/egg.d.ts.map +0 -1
- package/esm/components/egg/egg.js +0 -70
- package/esm/components/group.d.ts +0 -14
- package/esm/components/group.d.ts.map +0 -1
- package/esm/components/group.js +0 -33
- package/esm/components/member_2.d.ts +0 -69
- package/esm/components/member_2.d.ts.map +0 -1
- package/esm/components/member_2.js +0 -140
- package/esm/components/node.d.ts +0 -78
- package/esm/components/node.d.ts.map +0 -1
- package/esm/components/node.js +0 -342
- package/esm/components/server/activity.d.ts +0 -45
- package/esm/components/server/activity.d.ts.map +0 -1
- package/esm/components/server/activity.js +0 -158
- package/esm/components/server/allocations.d.ts +0 -45
- package/esm/components/server/allocations.d.ts.map +0 -1
- package/esm/components/server/allocations.js +0 -146
- package/esm/components/server/files.d.ts +0 -50
- package/esm/components/server/files.d.ts.map +0 -1
- package/esm/components/server/files.js +0 -90
- package/esm/components/server/power.d.ts +0 -21
- package/esm/components/server/power.d.ts.map +0 -1
- package/esm/components/server/power.js +0 -43
- package/esm/components/server/profiles.d.ts +0 -63
- package/esm/components/server/profiles.d.ts.map +0 -1
- package/esm/components/server/profiles.js +0 -163
- package/esm/components/server/server.d.ts +0 -141
- package/esm/components/server/server.d.ts.map +0 -1
- package/esm/components/server/server.js +0 -358
- package/esm/components/server/sftp.d.ts +0 -31
- package/esm/components/server/sftp.d.ts.map +0 -1
- package/esm/components/server/sftp.js +0 -84
- package/esm/components/server/startup.d.ts +0 -17
- package/esm/components/server/startup.d.ts.map +0 -1
- package/esm/components/server/startup.js +0 -21
- package/esm/components/server/stats.d.ts +0 -19
- package/esm/components/server/stats.d.ts.map +0 -1
- package/esm/components/server/stats.js +0 -46
- package/esm/utils/cache.d.ts +0 -20
- package/esm/utils/cache.d.ts.map +0 -1
- package/esm/utils/cache.js +0 -66
- package/esm/utils/event.d.ts +0 -38
- package/esm/utils/event.d.ts.map +0 -1
- package/esm/utils/event.js +0 -71
- package/esm/utils/object.d.ts +0 -58
- package/esm/utils/object.d.ts.map +0 -1
- package/esm/utils/object.js +0 -86
- package/esm/utils/subscribe.d.ts +0 -37
- package/esm/utils/subscribe.d.ts.map +0 -1
- package/esm/utils/subscribe.js +0 -29
- package/esm/utils/timer.d.ts +0 -13
- package/esm/utils/timer.d.ts.map +0 -1
- package/esm/utils/timer.js +0 -32
- package/esm/utils/units.d.ts +0 -18
- package/esm/utils/units.d.ts.map +0 -1
- package/esm/utils/units.js +0 -82
- package/script/api.d.ts +0 -76
- package/script/api.d.ts.map +0 -1
- package/script/api.js +0 -192
- package/script/components/auth.d.ts +0 -15
- package/script/components/auth.d.ts.map +0 -1
- package/script/components/auth.js +0 -17
- package/script/components/connection/abstract.d.ts +0 -23
- package/script/components/connection/abstract.d.ts.map +0 -1
- package/script/components/connection/abstract.js +0 -47
- package/script/components/connection/sse.d.ts +0 -20
- package/script/components/connection/sse.d.ts.map +0 -1
- package/script/components/connection/sse.js +0 -69
- package/script/components/egg/egg.d.ts +0 -32
- package/script/components/egg/egg.d.ts.map +0 -1
- package/script/components/egg/egg.js +0 -74
- package/script/components/group.d.ts +0 -14
- package/script/components/group.d.ts.map +0 -1
- package/script/components/group.js +0 -37
- package/script/components/member_2.d.ts +0 -69
- package/script/components/member_2.d.ts.map +0 -1
- package/script/components/member_2.js +0 -146
- package/script/components/node.d.ts +0 -78
- package/script/components/node.d.ts.map +0 -1
- package/script/components/node.js +0 -349
- package/script/components/server/activity.d.ts +0 -45
- package/script/components/server/activity.d.ts.map +0 -1
- package/script/components/server/activity.js +0 -164
- package/script/components/server/allocations.d.ts +0 -45
- package/script/components/server/allocations.d.ts.map +0 -1
- package/script/components/server/allocations.js +0 -152
- package/script/components/server/files.d.ts +0 -50
- package/script/components/server/files.d.ts.map +0 -1
- package/script/components/server/files.js +0 -94
- package/script/components/server/power.d.ts +0 -21
- package/script/components/server/power.d.ts.map +0 -1
- package/script/components/server/power.js +0 -47
- package/script/components/server/profiles.d.ts +0 -63
- package/script/components/server/profiles.d.ts.map +0 -1
- package/script/components/server/profiles.js +0 -168
- package/script/components/server/server.d.ts +0 -141
- package/script/components/server/server.d.ts.map +0 -1
- package/script/components/server/server.js +0 -362
- package/script/components/server/sftp.d.ts +0 -31
- package/script/components/server/sftp.d.ts.map +0 -1
- package/script/components/server/sftp.js +0 -88
- package/script/components/server/startup.d.ts +0 -17
- package/script/components/server/startup.d.ts.map +0 -1
- package/script/components/server/startup.js +0 -25
- package/script/components/server/stats.d.ts +0 -19
- package/script/components/server/stats.d.ts.map +0 -1
- package/script/components/server/stats.js +0 -50
- package/script/utils/cache.d.ts +0 -20
- package/script/utils/cache.d.ts.map +0 -1
- package/script/utils/cache.js +0 -70
- package/script/utils/event.d.ts +0 -38
- package/script/utils/event.d.ts.map +0 -1
- package/script/utils/event.js +0 -75
- package/script/utils/object.d.ts +0 -58
- package/script/utils/object.d.ts.map +0 -1
- package/script/utils/object.js +0 -90
- package/script/utils/subscribe.d.ts +0 -37
- package/script/utils/subscribe.d.ts.map +0 -1
- package/script/utils/subscribe.js +0 -32
- package/script/utils/timer.d.ts +0 -13
- package/script/utils/timer.d.ts.map +0 -1
- package/script/utils/timer.js +0 -36
- package/script/utils/units.d.ts +0 -18
- package/script/utils/units.d.ts.map +0 -1
- package/script/utils/units.js +0 -86
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AllocationPort = exports.ServerAllocationPort = exports.ServerAllocations = void 0;
|
|
4
|
-
const cache_js_1 = require("../../utils/cache.js");
|
|
5
|
-
class ServerAllocations {
|
|
6
|
-
static async getPaged(api, server, page) {
|
|
7
|
-
const response = await api.request('GET', `/v1/servers/${server.id}/allocations`, {
|
|
8
|
-
pagination: { page },
|
|
9
|
-
});
|
|
10
|
-
return {
|
|
11
|
-
groups: response.data.map((data) => new ServerAllocations(api, server, data)),
|
|
12
|
-
page: response.page,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
static async get(api, server, id) {
|
|
16
|
-
const response = await api.request('GET', `/v1/servers/${server.id}/allocations/${id}`);
|
|
17
|
-
return new ServerAllocations(api, server, response.data);
|
|
18
|
-
}
|
|
19
|
-
constructor(api, server, response) {
|
|
20
|
-
Object.defineProperty(this, "api", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: api
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(this, "server", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
value: server
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(this, "response", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
value: response
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(this, "ports", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: void 0
|
|
43
|
-
});
|
|
44
|
-
this.ports = this.response.ports.map((v) => new ServerAllocationPort(this.api, this.server, v));
|
|
45
|
-
}
|
|
46
|
-
get forceOutgoingIp() {
|
|
47
|
-
return this.response.force_outgoing_ip;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.ServerAllocations = ServerAllocations;
|
|
51
|
-
class ServerAllocationPort {
|
|
52
|
-
constructor(api, server, response) {
|
|
53
|
-
Object.defineProperty(this, "api", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: api
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "server", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: server
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(this, "response", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: response
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(this, "meta", {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
configurable: true,
|
|
74
|
-
writable: true,
|
|
75
|
-
value: void 0
|
|
76
|
-
});
|
|
77
|
-
this.meta = new cache_js_1.CachedRelation(async () => {
|
|
78
|
-
const response = await this.api.request('GET', `/v1/servers/${this.server.id}/allocations/${this.id}`, { params: { include: 'meta' } });
|
|
79
|
-
return new AllocationPort(this.api, this.server, response.data.meta);
|
|
80
|
-
});
|
|
81
|
-
response.meta &&
|
|
82
|
-
this.meta.setCache(new AllocationPort(this.api, this.server, response.meta));
|
|
83
|
-
}
|
|
84
|
-
updateDescription(description) {
|
|
85
|
-
return this.api.request('PATCH', `/v1/servers/${this.server.id}/allocations/${this.id}`, {
|
|
86
|
-
body: { description },
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
get id() {
|
|
90
|
-
return this.response.id;
|
|
91
|
-
}
|
|
92
|
-
get description() {
|
|
93
|
-
return this.response.description;
|
|
94
|
-
}
|
|
95
|
-
get isPrimary() {
|
|
96
|
-
return this.response.is_primary;
|
|
97
|
-
}
|
|
98
|
-
get createdAt() {
|
|
99
|
-
return this.response.created_at;
|
|
100
|
-
}
|
|
101
|
-
get updatedAt() {
|
|
102
|
-
return this.response.updated_at;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.ServerAllocationPort = ServerAllocationPort;
|
|
106
|
-
class AllocationPort {
|
|
107
|
-
constructor(ctx, server, response) {
|
|
108
|
-
Object.defineProperty(this, "ctx", {
|
|
109
|
-
enumerable: true,
|
|
110
|
-
configurable: true,
|
|
111
|
-
writable: true,
|
|
112
|
-
value: ctx
|
|
113
|
-
});
|
|
114
|
-
Object.defineProperty(this, "server", {
|
|
115
|
-
enumerable: true,
|
|
116
|
-
configurable: true,
|
|
117
|
-
writable: true,
|
|
118
|
-
value: server
|
|
119
|
-
});
|
|
120
|
-
Object.defineProperty(this, "response", {
|
|
121
|
-
enumerable: true,
|
|
122
|
-
configurable: true,
|
|
123
|
-
writable: true,
|
|
124
|
-
value: response
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
get id() {
|
|
128
|
-
return this.response.id;
|
|
129
|
-
}
|
|
130
|
-
get ip() {
|
|
131
|
-
return this.response.ip;
|
|
132
|
-
}
|
|
133
|
-
get port() {
|
|
134
|
-
return this.response.port;
|
|
135
|
-
}
|
|
136
|
-
get readyProtocols() {
|
|
137
|
-
return this.response.ready_protocols;
|
|
138
|
-
}
|
|
139
|
-
get is_in_use() {
|
|
140
|
-
return this.response.is_in_use;
|
|
141
|
-
}
|
|
142
|
-
get notes() {
|
|
143
|
-
return this.response.notes;
|
|
144
|
-
}
|
|
145
|
-
get createdAt() {
|
|
146
|
-
return this.response.created_at;
|
|
147
|
-
}
|
|
148
|
-
get updatedAt() {
|
|
149
|
-
return this.response.updated_at;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
exports.AllocationPort = AllocationPort;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { MeowPanelApi } from '../../mod.js';
|
|
2
|
-
import type { DirectoryResponse } from './server_2';
|
|
3
|
-
import type { Server } from './server.js';
|
|
4
|
-
export interface FileEntry {
|
|
5
|
-
type: 'file';
|
|
6
|
-
mime: {
|
|
7
|
-
type: string;
|
|
8
|
-
subtype: string;
|
|
9
|
-
};
|
|
10
|
-
data: ArrayBuffer | null;
|
|
11
|
-
}
|
|
12
|
-
export type DirectoryEntry = DirectoryResponse;
|
|
13
|
-
export interface DirectoryEntries {
|
|
14
|
-
type: 'directory';
|
|
15
|
-
entries: DirectoryEntry[];
|
|
16
|
-
}
|
|
17
|
-
export type ListEntry = FileEntry | DirectoryEntries;
|
|
18
|
-
export interface GetEntryOptions {
|
|
19
|
-
/**
|
|
20
|
-
* What mime types are allowed to be returned as content data. Otherwise returns `null` as its data without reading the content.
|
|
21
|
-
*/
|
|
22
|
-
mimeTypes?: string[];
|
|
23
|
-
/**
|
|
24
|
-
* The maximum size of the file in megabytes. Otherwise returns `null` as its data without reading the content.
|
|
25
|
-
*/
|
|
26
|
-
maxSizeMb?: number;
|
|
27
|
-
}
|
|
28
|
-
export declare class ServerFileManager {
|
|
29
|
-
protected readonly api: MeowPanelApi;
|
|
30
|
-
protected readonly server: Server;
|
|
31
|
-
private static readonly mimeHeaderName;
|
|
32
|
-
private static readonly mimeDirectory;
|
|
33
|
-
constructor(api: MeowPanelApi, server: Server);
|
|
34
|
-
private static removeFirstSlash;
|
|
35
|
-
getEntry(path: string, options?: GetEntryOptions): Promise<ListEntry>;
|
|
36
|
-
putContent(path: string, content: ArrayBuffer | string): Promise<void>;
|
|
37
|
-
delete(path: string): Promise<void>;
|
|
38
|
-
move(root: string, paths: Record<string, string>): Promise<void>;
|
|
39
|
-
copy(root: string, paths: Record<string, string>): Promise<void>;
|
|
40
|
-
create(root: string, paths: Record<string, {
|
|
41
|
-
type: 'file' | 'directory';
|
|
42
|
-
}>): Promise<void>;
|
|
43
|
-
compress(root: string, paths: string[]): Promise<void>;
|
|
44
|
-
decompress(root: string, path: string): Promise<void>;
|
|
45
|
-
chmod(root: string, paths: Record<string, {
|
|
46
|
-
mode: number;
|
|
47
|
-
}>): Promise<void>;
|
|
48
|
-
upload(folderPath: string, ...files: File[]): Promise<void>;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=files.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/components/server/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,IAAI,EAAE,WAAW,GAA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E,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAQtC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAQrC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAQ3D,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE;CAaxD"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerFileManager = void 0;
|
|
4
|
-
class ServerFileManager {
|
|
5
|
-
constructor(api, server) {
|
|
6
|
-
Object.defineProperty(this, "api", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true,
|
|
10
|
-
value: api
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(this, "server", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true,
|
|
16
|
-
value: server
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
static removeFirstSlash(path) {
|
|
20
|
-
return path.replace(/^\//, '');
|
|
21
|
-
}
|
|
22
|
-
// TODO: this could return classes/additional objects to interact with the returned files/directories
|
|
23
|
-
async getEntry(path, options) {
|
|
24
|
-
const response = await this.server.requestNodeApi('GET', `/files/${ServerFileManager.removeFirstSlash(path)}`, {
|
|
25
|
-
params: {
|
|
26
|
-
mime_types: options?.mimeTypes?.join(','),
|
|
27
|
-
max_size_mb: options?.maxSizeMb?.toString(),
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
const mime = response.headers.get(ServerFileManager.mimeHeaderName);
|
|
31
|
-
if (!mime)
|
|
32
|
-
throw new Error('File has no mime type');
|
|
33
|
-
if (mime === ServerFileManager.mimeDirectory) {
|
|
34
|
-
const data = await response.json();
|
|
35
|
-
return {
|
|
36
|
-
type: 'directory',
|
|
37
|
-
entries: data,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const [type, subtype] = mime.split(';');
|
|
41
|
-
return {
|
|
42
|
-
type: 'file',
|
|
43
|
-
mime: {
|
|
44
|
-
type,
|
|
45
|
-
subtype,
|
|
46
|
-
},
|
|
47
|
-
data: response.status === 200 ? await response.arrayBuffer() : null,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
async putContent(path, content) {
|
|
51
|
-
await this.server.requestNodeApi('PUT', `/files/${ServerFileManager.removeFirstSlash(path)}`, { body: content });
|
|
52
|
-
}
|
|
53
|
-
async delete(path) {
|
|
54
|
-
await this.server.requestNodeApi('DELETE', `/files/${ServerFileManager.removeFirstSlash(path)}`);
|
|
55
|
-
}
|
|
56
|
-
async move(root, paths) {
|
|
57
|
-
await this.server.requestNodeApi('POST', '/files/move', { body: { root, paths } });
|
|
58
|
-
}
|
|
59
|
-
async copy(root, paths) {
|
|
60
|
-
await this.server.requestNodeApi('POST', '/files/copy', { body: { root, paths } });
|
|
61
|
-
}
|
|
62
|
-
async create(root, paths) {
|
|
63
|
-
await this.server.requestNodeApi('POST', '/files/create', { body: { root, paths } });
|
|
64
|
-
}
|
|
65
|
-
async compress(root, paths) {
|
|
66
|
-
await this.server.requestNodeApi('POST', '/files/compress', { body: { root, paths } });
|
|
67
|
-
}
|
|
68
|
-
async decompress(root, path) {
|
|
69
|
-
await this.server.requestNodeApi('POST', '/files/decompress', { body: { root, path } });
|
|
70
|
-
}
|
|
71
|
-
async chmod(root, paths) {
|
|
72
|
-
await this.server.requestNodeApi('POST', '/files/chmod', { body: { root, paths } });
|
|
73
|
-
}
|
|
74
|
-
async upload(folderPath, ...files) {
|
|
75
|
-
const formData = new FormData();
|
|
76
|
-
for (const file of files) {
|
|
77
|
-
formData.append('files', file);
|
|
78
|
-
}
|
|
79
|
-
await this.server.requestNodeApi('POST', '/files/upload', { body: formData, params: { directory: folderPath } });
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.ServerFileManager = ServerFileManager;
|
|
83
|
-
Object.defineProperty(ServerFileManager, "mimeHeaderName", {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
configurable: true,
|
|
86
|
-
writable: true,
|
|
87
|
-
value: 'X-Mime-Type'
|
|
88
|
-
});
|
|
89
|
-
Object.defineProperty(ServerFileManager, "mimeDirectory", {
|
|
90
|
-
enumerable: true,
|
|
91
|
-
configurable: true,
|
|
92
|
-
writable: true,
|
|
93
|
-
value: 'inode/directory'
|
|
94
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type PowerState = 'online' | 'offline' | 'starting' | 'stopping' | 'error' | 'connecting';
|
|
2
|
-
export declare class PowerStateEvent {
|
|
3
|
-
private readonly value;
|
|
4
|
-
constructor(value: PowerState);
|
|
5
|
-
/**
|
|
6
|
-
* @returns true if the server is powered
|
|
7
|
-
*/
|
|
8
|
-
get isPowered(): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* @returns true if the connection is established successfully
|
|
11
|
-
*/
|
|
12
|
-
get connected(): boolean;
|
|
13
|
-
get isConnecting(): boolean;
|
|
14
|
-
get isOnline(): boolean;
|
|
15
|
-
get isOffline(): boolean;
|
|
16
|
-
get isStarting(): boolean;
|
|
17
|
-
get isStopping(): boolean;
|
|
18
|
-
get errored(): boolean;
|
|
19
|
-
toString(): PowerState;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=power.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../../src/components/server/power.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GACnB,QAAQ,GACR,SAAS,GACT,UAAU,GACV,UAAU,GACV,OAAO,GACP,YAAY,CAAC;AAEhB,qBAAa,eAAe;IACR,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,UAAU;IAErD;;OAEG;IACH,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED,IAAW,YAAY,IAAI,OAAO,CAEjC;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED,IAAW,OAAO,IAAI,OAAO,CAE5B;IAEM,QAAQ,IAAI,UAAU;CAG7B"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PowerStateEvent = void 0;
|
|
4
|
-
class PowerStateEvent {
|
|
5
|
-
constructor(value) {
|
|
6
|
-
Object.defineProperty(this, "value", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true,
|
|
10
|
-
value: value
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @returns true if the server is powered
|
|
15
|
-
*/
|
|
16
|
-
get isPowered() {
|
|
17
|
-
return ['online', 'starting', 'stopping'].includes(this.value);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* @returns true if the connection is established successfully
|
|
21
|
-
*/
|
|
22
|
-
get connected() {
|
|
23
|
-
return !['error', 'connecting'].includes(this.value);
|
|
24
|
-
}
|
|
25
|
-
get isConnecting() {
|
|
26
|
-
return this.value === 'connecting';
|
|
27
|
-
}
|
|
28
|
-
get isOnline() {
|
|
29
|
-
return this.value === 'online';
|
|
30
|
-
}
|
|
31
|
-
get isOffline() {
|
|
32
|
-
return this.value === 'offline';
|
|
33
|
-
}
|
|
34
|
-
get isStarting() {
|
|
35
|
-
return this.value === 'starting';
|
|
36
|
-
}
|
|
37
|
-
get isStopping() {
|
|
38
|
-
return this.value === 'stopping';
|
|
39
|
-
}
|
|
40
|
-
get errored() {
|
|
41
|
-
return this.value === 'error';
|
|
42
|
-
}
|
|
43
|
-
toString() {
|
|
44
|
-
return this.value;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.PowerStateEvent = PowerStateEvent;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { Page } from '../../api.js';
|
|
2
|
-
import type { MeowPanelApi } from '../../mod.js';
|
|
3
|
-
import { CachedRelation } from '../../utils/cache.js';
|
|
4
|
-
import { type EventFunction, EventManager, type EventManagerListener } from '../../utils/event.js';
|
|
5
|
-
import { UpdatableObject } from '../../utils/object.js';
|
|
6
|
-
import type { Subscription } from '../../utils/subscribe.js';
|
|
7
|
-
import type { Extended } from '../../utils/types';
|
|
8
|
-
import type { ProfileResponse } from './server_2';
|
|
9
|
-
import type { Server } from './server.js';
|
|
10
|
-
export declare class ServerProfileManager {
|
|
11
|
-
protected readonly api: MeowPanelApi;
|
|
12
|
-
protected readonly server: Server;
|
|
13
|
-
private readonly profiles;
|
|
14
|
-
private activeProfile;
|
|
15
|
-
constructor(api: MeowPanelApi, server: Server);
|
|
16
|
-
addCached(profile: ProfileResponse[]): void;
|
|
17
|
-
getPaged(page: number): Promise<{
|
|
18
|
-
profiles: ProfileResponse[];
|
|
19
|
-
page: Page;
|
|
20
|
-
}>;
|
|
21
|
-
geAll(): Promise<ServerProfile[]>;
|
|
22
|
-
get(id: string): ServerProfile;
|
|
23
|
-
getActiveProfile(): ServerProfile | null;
|
|
24
|
-
setActiveProfile(profile: ServerProfile): Promise<void>;
|
|
25
|
-
create(data: {
|
|
26
|
-
name: string;
|
|
27
|
-
description?: string | null;
|
|
28
|
-
notes?: string | null;
|
|
29
|
-
}): Promise<ServerProfile>;
|
|
30
|
-
}
|
|
31
|
-
export declare class ServerProfile extends UpdatableObject<ProfileResponse, {
|
|
32
|
-
folder: CachedRelation<string | undefined>;
|
|
33
|
-
}, 'folder'> implements EventManagerListener<ServerProfileEvents>, Subscription<ServerProfile> {
|
|
34
|
-
protected readonly manager: ServerProfileManager;
|
|
35
|
-
constructor(api: MeowPanelApi, server: Server, manager: ServerProfileManager, response: ProfileResponse);
|
|
36
|
-
protected readonly eventManager: EventManager<ServerProfileEvents>;
|
|
37
|
-
on<K extends keyof ServerProfileEvents>(event: K, func: EventFunction<ServerProfileEvents, K>): number;
|
|
38
|
-
off<K extends keyof ServerProfileEvents>(event: K | number, func?: number | EventFunction<ServerProfileEvents, K>): boolean;
|
|
39
|
-
subscribe(fn: (value: ServerProfile) => void): () => void;
|
|
40
|
-
protected applyResponse(oldData: Extended<ProfileResponse, {
|
|
41
|
-
folder: CachedRelation<string>;
|
|
42
|
-
}> | undefined, _newData: ProfileResponse): {
|
|
43
|
-
folder: CachedRelation<string | undefined>;
|
|
44
|
-
};
|
|
45
|
-
get id(): string;
|
|
46
|
-
get name(): string;
|
|
47
|
-
get description(): string | null;
|
|
48
|
-
get notes(): string | null | undefined;
|
|
49
|
-
isActive: boolean;
|
|
50
|
-
get folder(): CachedRelation<string | undefined>;
|
|
51
|
-
updateDetails(details: {
|
|
52
|
-
name?: string;
|
|
53
|
-
description?: string | null;
|
|
54
|
-
notes?: string | null;
|
|
55
|
-
}): Promise<void>;
|
|
56
|
-
setAsActive(): Promise<void>;
|
|
57
|
-
_update(): void;
|
|
58
|
-
}
|
|
59
|
-
interface ServerProfileEvents {
|
|
60
|
-
active: ServerProfile;
|
|
61
|
-
}
|
|
62
|
-
export {};
|
|
63
|
-
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../src/components/server/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,aAAa,EAAE,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EtD;IAEY,aAAa,CAAC,OAAO,EAAE;QACnC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB;IAQY,WAAW;IAMjB,OAAO;CAId;AAED,UAAU,mBAAmB;IAC5B,MAAM,EAAE,aAAa,CAAC;CACtB"}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerProfile = exports.ServerProfileManager = void 0;
|
|
4
|
-
const cache_js_1 = require("../../utils/cache.js");
|
|
5
|
-
const event_js_1 = require("../../utils/event.js");
|
|
6
|
-
const object_js_1 = require("../../utils/object.js");
|
|
7
|
-
// TODO: ServerProfile support 'folder' include
|
|
8
|
-
class ServerProfileManager {
|
|
9
|
-
constructor(api, server) {
|
|
10
|
-
Object.defineProperty(this, "api", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
value: api
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(this, "server", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true,
|
|
20
|
-
value: server
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(this, "profiles", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true,
|
|
26
|
-
value: {}
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(this, "activeProfile", {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
configurable: true,
|
|
31
|
-
writable: true,
|
|
32
|
-
value: null
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
addCached(profile) {
|
|
36
|
-
for (const p of profile) {
|
|
37
|
-
this.profiles[p.id] = new ServerProfile(this.api, this.server, this, p);
|
|
38
|
-
if (p.is_active) {
|
|
39
|
-
this.activeProfile = this.profiles[p.id];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async getPaged(page) {
|
|
44
|
-
const response = await this.api.request('GET', `/v1/servers/${this.server.id}/profiles`, { pagination: { page } });
|
|
45
|
-
this.addCached(response.data);
|
|
46
|
-
return {
|
|
47
|
-
profiles: response.data,
|
|
48
|
-
page: response.page,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
async geAll() {
|
|
52
|
-
this.activeProfile = null;
|
|
53
|
-
for (const p of Object.values(this.profiles)) {
|
|
54
|
-
delete this.profiles[p.id];
|
|
55
|
-
}
|
|
56
|
-
let page;
|
|
57
|
-
let current = 1;
|
|
58
|
-
do {
|
|
59
|
-
const response = await this.getPaged(current++);
|
|
60
|
-
page = response.page;
|
|
61
|
-
} while (page.total > page.from && current < 5);
|
|
62
|
-
for (const p of Object.values(this.profiles)) {
|
|
63
|
-
p._update();
|
|
64
|
-
}
|
|
65
|
-
return Object.values(this.profiles);
|
|
66
|
-
}
|
|
67
|
-
get(id) {
|
|
68
|
-
return this.profiles[id];
|
|
69
|
-
}
|
|
70
|
-
getActiveProfile() {
|
|
71
|
-
return this.activeProfile;
|
|
72
|
-
}
|
|
73
|
-
async setActiveProfile(profile) {
|
|
74
|
-
await this.api.request('PATCH', `/v1/servers/${this.server.id}/profiles/active`, {
|
|
75
|
-
body: { id: profile.id },
|
|
76
|
-
});
|
|
77
|
-
this.activeProfile = profile;
|
|
78
|
-
for (const p of Object.values(this.profiles)) {
|
|
79
|
-
p._update();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
async create(data) {
|
|
83
|
-
const response = await this.api.request('POST', `/v1/servers/${this.server.id}/profiles`, {
|
|
84
|
-
body: data,
|
|
85
|
-
});
|
|
86
|
-
this.profiles[response.data.id] = new ServerProfile(this.api, this.server, this, response.data);
|
|
87
|
-
return this.profiles[response.data.id];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.ServerProfileManager = ServerProfileManager;
|
|
91
|
-
class ServerProfile extends object_js_1.UpdatableObject {
|
|
92
|
-
constructor(api, server, manager, response) {
|
|
93
|
-
super(api, response, `/v1/servers/${server.id}/profiles/${response.id}`);
|
|
94
|
-
Object.defineProperty(this, "manager", {
|
|
95
|
-
enumerable: true,
|
|
96
|
-
configurable: true,
|
|
97
|
-
writable: true,
|
|
98
|
-
value: manager
|
|
99
|
-
});
|
|
100
|
-
Object.defineProperty(this, "eventManager", {
|
|
101
|
-
enumerable: true,
|
|
102
|
-
configurable: true,
|
|
103
|
-
writable: true,
|
|
104
|
-
value: new event_js_1.EventManager()
|
|
105
|
-
});
|
|
106
|
-
Object.defineProperty(this, "isActive", {
|
|
107
|
-
enumerable: true,
|
|
108
|
-
configurable: true,
|
|
109
|
-
writable: true,
|
|
110
|
-
value: false
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
on(event, func) {
|
|
114
|
-
return this.eventManager.on(event, func);
|
|
115
|
-
}
|
|
116
|
-
off(event, func) {
|
|
117
|
-
return this.eventManager.off(event, func);
|
|
118
|
-
}
|
|
119
|
-
subscribe(fn) {
|
|
120
|
-
const ids = [];
|
|
121
|
-
const update = () => fn(this);
|
|
122
|
-
update();
|
|
123
|
-
ids.push(this.eventManager.on('active', update));
|
|
124
|
-
return () => {
|
|
125
|
-
ids.forEach(this.eventManager.off.bind(this.eventManager));
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
applyResponse(oldData, _newData) {
|
|
129
|
-
return {
|
|
130
|
-
folder: oldData?.folder ?? new cache_js_1.CachedRelation(async () => {
|
|
131
|
-
const response = await this.fetchSelf(['folder']);
|
|
132
|
-
return response.folder;
|
|
133
|
-
}),
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
get id() {
|
|
137
|
-
return this.response.id;
|
|
138
|
-
}
|
|
139
|
-
get name() {
|
|
140
|
-
return this.response.name;
|
|
141
|
-
}
|
|
142
|
-
get description() {
|
|
143
|
-
return this.response.description;
|
|
144
|
-
}
|
|
145
|
-
get notes() {
|
|
146
|
-
return this.response.notes;
|
|
147
|
-
}
|
|
148
|
-
get folder() {
|
|
149
|
-
return this.response.folder;
|
|
150
|
-
}
|
|
151
|
-
async updateDetails(details) {
|
|
152
|
-
await this.callPatch({
|
|
153
|
-
name: details.name,
|
|
154
|
-
description: details.description,
|
|
155
|
-
notes: details.notes,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
async setAsActive() {
|
|
159
|
-
await this.manager.setActiveProfile(this);
|
|
160
|
-
this.response.is_active = true;
|
|
161
|
-
}
|
|
162
|
-
// TODO: remove this method and replace with better Object management
|
|
163
|
-
_update() {
|
|
164
|
-
this.isActive = this.manager.getActiveProfile()?.id === this.id;
|
|
165
|
-
this.eventManager.dispatch('active', this);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
exports.ServerProfile = ServerProfile;
|