@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
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ServerProfilesManager = exports.ServerProfile = void 0;
|
|
4
4
|
const reactive_js_1 = require("../../reactive.js");
|
|
5
5
|
const types_js_1 = require("../../types.js");
|
|
6
|
+
const eggs_js_1 = require("../eggs.js");
|
|
6
7
|
/**
|
|
7
8
|
* A named configuration profile for a server.
|
|
8
9
|
*
|
|
@@ -22,6 +23,18 @@ class ServerProfile extends reactive_js_1.ReactiveResource {
|
|
|
22
23
|
description;
|
|
23
24
|
/** Internal notes for this profile. */
|
|
24
25
|
notes;
|
|
26
|
+
/** The egg this profile runs. Requires `server.egg.read`. */
|
|
27
|
+
eggId;
|
|
28
|
+
/** Populated with `include=egg`. */
|
|
29
|
+
egg;
|
|
30
|
+
/** The egg image (Docker image) id this profile uses. */
|
|
31
|
+
eggImageId;
|
|
32
|
+
/** A custom Docker image overriding the egg's default. */
|
|
33
|
+
eggImageOverride;
|
|
34
|
+
/** Whether the egg install scripts are skipped for this profile. */
|
|
35
|
+
skipInstallScripts;
|
|
36
|
+
/** Startup command and variables. Populated with `include=startup`. */
|
|
37
|
+
startup;
|
|
25
38
|
/** The folder name used to store this profile's files on disk. */
|
|
26
39
|
folder;
|
|
27
40
|
/** `true` if this is the currently active profile for the server. */
|
|
@@ -50,6 +63,20 @@ class ServerProfile extends reactive_js_1.ReactiveResource {
|
|
|
50
63
|
this.name = data.name;
|
|
51
64
|
this.description = data.description ?? null;
|
|
52
65
|
this.notes = data.notes;
|
|
66
|
+
this.eggId = data.egg_id ? (0, types_js_1.toNanoID)(data.egg_id) : undefined;
|
|
67
|
+
this.eggImageId = data.egg_image_id ? (0, types_js_1.toNanoID)(data.egg_image_id) : undefined;
|
|
68
|
+
this.eggImageOverride = data.egg_image_override;
|
|
69
|
+
this.skipInstallScripts = data.skip_install_scripts;
|
|
70
|
+
if (data.egg)
|
|
71
|
+
this.egg = new eggs_js_1.Egg(data.egg);
|
|
72
|
+
if (data.startup !== undefined) {
|
|
73
|
+
this.startup = data.startup
|
|
74
|
+
? {
|
|
75
|
+
command: data.startup.command,
|
|
76
|
+
variables: Object.fromEntries(Object.entries(data.startup.variables).map(([key, v]) => [key, { key, ...v }])),
|
|
77
|
+
}
|
|
78
|
+
: undefined;
|
|
79
|
+
}
|
|
53
80
|
this.folder = data.folder;
|
|
54
81
|
this.isActive = data.is_active;
|
|
55
82
|
this.updatedAt = new Date(data.updated_at);
|
|
@@ -135,12 +162,38 @@ class ServerProfilesManager {
|
|
|
135
162
|
return this.makeProfile(data);
|
|
136
163
|
}
|
|
137
164
|
/**
|
|
138
|
-
* Create a new profile for this server.
|
|
165
|
+
* Create a new profile for this server. A profile binds an egg and image.
|
|
139
166
|
*
|
|
140
167
|
* @param payload Profile creation parameters.
|
|
141
168
|
*/
|
|
142
169
|
async create(payload) {
|
|
143
|
-
const data = await this.http.post(`/servers/${this.serverId}/profiles`,
|
|
170
|
+
const data = await this.http.post(`/servers/${this.serverId}/profiles`, {
|
|
171
|
+
name: payload.name,
|
|
172
|
+
description: payload.description,
|
|
173
|
+
notes: payload.notes,
|
|
174
|
+
egg_id: payload.eggId,
|
|
175
|
+
egg_image_id: payload.eggImageId,
|
|
176
|
+
egg_image_override: payload.eggImageOverride,
|
|
177
|
+
startup_command_override: payload.startupCommandOverride,
|
|
178
|
+
skip_install_scripts: payload.skipInstallScripts,
|
|
179
|
+
});
|
|
180
|
+
return this.makeProfile(data);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Change a profile's egg, reselecting a valid image and re-basing its variables.
|
|
184
|
+
*
|
|
185
|
+
* @param profileId The profile's NanoID.
|
|
186
|
+
* @param eggId The egg to switch to.
|
|
187
|
+
* @param opts `keep: true` carries over all compatible variable overrides;
|
|
188
|
+
* an array keeps only the named variables.
|
|
189
|
+
*/
|
|
190
|
+
async changeEgg(profileId, eggId, opts = {}) {
|
|
191
|
+
const params = {};
|
|
192
|
+
if (opts.keep === true)
|
|
193
|
+
params['keep'] = 'true';
|
|
194
|
+
else if (Array.isArray(opts.keep))
|
|
195
|
+
params['keep'] = opts.keep.join(',');
|
|
196
|
+
const data = await this.http.put(`/servers/${this.serverId}/profiles/${profileId}/egg`, JSON.stringify({ egg_id: eggId }), 'application/json', { params });
|
|
144
197
|
return this.makeProfile(data);
|
|
145
198
|
}
|
|
146
199
|
/**
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
import type { HttpClient } from '../../http.js';
|
|
2
2
|
import { ReactiveResource } from '../../reactive.js';
|
|
3
3
|
import type { NanoID, PowerAction, PowerState, ServerRestrictedState } from '../../types.js';
|
|
4
|
-
import { Egg } from '../eggs.js';
|
|
5
4
|
import { ServerGroup } from '../server-groups.js';
|
|
6
5
|
import { ServerActivityManager } from './activity.js';
|
|
7
6
|
import { ServerAllocationsManager } from './allocations.js';
|
|
7
|
+
import { ServerBackupsManager } from './backups.js';
|
|
8
8
|
import { ServerConnection } from './connection.js';
|
|
9
|
+
import { ServerFeaturesManager } from './features.js';
|
|
9
10
|
import { ServerFilesManager } from './files.js';
|
|
11
|
+
import { ServerJobsManager } from './jobs.js';
|
|
10
12
|
import { ServerProfilesManager } from './profiles.js';
|
|
11
13
|
import { ServerSftpManager } from './sftp.js';
|
|
14
|
+
import { ServerUserManager } from './sub-users.js';
|
|
12
15
|
import type { ServerAllocationsData, ServerData, UpdateServerPayload } from './types.js';
|
|
13
|
-
/** An egg environment variable configured for a server. */
|
|
14
|
-
export interface StartupVariable {
|
|
15
|
-
key: string;
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
value: string;
|
|
19
|
-
default: string;
|
|
20
|
-
/** Laravel validation rules, e.g. `"required|numeric|min:1"`. */
|
|
21
|
-
rules: string;
|
|
22
|
-
}
|
|
23
16
|
/** Real-time power state and utilization. Populated via `include=status`. */
|
|
24
17
|
export interface ServerStatus {
|
|
25
18
|
state: PowerState;
|
|
@@ -52,17 +45,12 @@ export interface ServerBuild {
|
|
|
52
45
|
backup: number | null | undefined;
|
|
53
46
|
} | null | undefined;
|
|
54
47
|
}
|
|
55
|
-
/** Startup command and egg variables. Populated via `include=startup`. */
|
|
56
|
-
export interface ServerStartup {
|
|
57
|
-
command: string;
|
|
58
|
-
variables: Record<string, StartupVariable>;
|
|
59
|
-
}
|
|
60
48
|
/**
|
|
61
49
|
* A MeowPanel game server.
|
|
62
50
|
*
|
|
63
51
|
* @example
|
|
64
52
|
* ```ts ignore
|
|
65
|
-
* const server = await api.servers.get(id, { include: ['status'
|
|
53
|
+
* const server = await api.servers.get(id, { include: ['status'] });
|
|
66
54
|
* server.status; // ServerStatus (guaranteed by include)
|
|
67
55
|
*
|
|
68
56
|
* await server.sendPower('start');
|
|
@@ -85,19 +73,12 @@ export declare class Server extends ReactiveResource {
|
|
|
85
73
|
/** When non-null, overrides the node's reported power state for display. */
|
|
86
74
|
restrictedState: ServerRestrictedState;
|
|
87
75
|
readonly groupId: NanoID;
|
|
88
|
-
readonly eggId: NanoID;
|
|
89
|
-
eggImageId: NanoID | undefined;
|
|
90
76
|
/** Populated with `include=group`. */
|
|
91
77
|
group: ServerGroup | undefined;
|
|
92
|
-
/** Populated with `include=egg`. */
|
|
93
|
-
egg: Egg | undefined;
|
|
94
|
-
eggImageOverride: string | null | undefined;
|
|
95
78
|
/** Populated with `include=status`. Use {@link getStatus} to fetch on demand. */
|
|
96
79
|
status: ServerStatus | undefined;
|
|
97
80
|
/** Populated with `include=build`. */
|
|
98
81
|
build: ServerBuild | undefined;
|
|
99
|
-
/** Populated with `include=startup`. */
|
|
100
|
-
startup: ServerStartup | undefined;
|
|
101
82
|
/** Populated with `include=allocations`. */
|
|
102
83
|
allocationPorts: ServerAllocationsData | undefined;
|
|
103
84
|
createdAt: Date;
|
|
@@ -107,11 +88,15 @@ export declare class Server extends ReactiveResource {
|
|
|
107
88
|
readonly profiles: ServerProfilesManager;
|
|
108
89
|
readonly activity: ServerActivityManager;
|
|
109
90
|
readonly files: ServerFilesManager;
|
|
91
|
+
readonly backups: ServerBackupsManager;
|
|
92
|
+
readonly jobs: ServerJobsManager;
|
|
93
|
+
readonly subUsers: ServerUserManager;
|
|
94
|
+
readonly features: ServerFeaturesManager;
|
|
110
95
|
/** @internal */
|
|
111
96
|
constructor(data: ServerData, http: HttpClient, resolveNodeUrl: () => Promise<string>, onMutated: () => void);
|
|
112
97
|
/** Apply raw API data, updating all mutable fields. */
|
|
113
98
|
applyData(data: ServerData): void;
|
|
114
|
-
/** Update this server's details
|
|
99
|
+
/** Update this server's details or primary allocation. */
|
|
115
100
|
update(payload: UpdateServerPayload): Promise<void>;
|
|
116
101
|
/** Fetch current power state and utilization from the node. */
|
|
117
102
|
getStatus(): Promise<ServerStatus>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE7F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE7F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM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AAE,UAAU,EAChB,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACrC,SAAS,EAAE,MAAM,IAAI;IAqBvC,uDAAuD;IAChD,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAuBxC,0DAA0D;IAC7C,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBhE,+DAA+D;IAClD,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;IAO/C,yCAAyC;IAC5B,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D,yCAAyC;IAC5B,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnE;;;;;;;;;;;OAWG;IACU,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAI1D"}
|
|
@@ -3,20 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Server = void 0;
|
|
4
4
|
const reactive_js_1 = require("../../reactive.js");
|
|
5
5
|
const types_js_1 = require("../../types.js");
|
|
6
|
-
const eggs_js_1 = require("../eggs.js");
|
|
7
6
|
const server_groups_js_1 = require("../server-groups.js");
|
|
8
7
|
const activity_js_1 = require("./activity.js");
|
|
9
8
|
const allocations_js_1 = require("./allocations.js");
|
|
9
|
+
const backups_js_1 = require("./backups.js");
|
|
10
10
|
const connection_js_1 = require("./connection.js");
|
|
11
|
+
const features_js_1 = require("./features.js");
|
|
11
12
|
const files_js_1 = require("./files.js");
|
|
13
|
+
const jobs_js_1 = require("./jobs.js");
|
|
14
|
+
const node_client_js_1 = require("./node-client.js");
|
|
12
15
|
const profiles_js_1 = require("./profiles.js");
|
|
13
16
|
const sftp_js_1 = require("./sftp.js");
|
|
17
|
+
const sub_users_js_1 = require("./sub-users.js");
|
|
14
18
|
/**
|
|
15
19
|
* A MeowPanel game server.
|
|
16
20
|
*
|
|
17
21
|
* @example
|
|
18
22
|
* ```ts ignore
|
|
19
|
-
* const server = await api.servers.get(id, { include: ['status'
|
|
23
|
+
* const server = await api.servers.get(id, { include: ['status'] });
|
|
20
24
|
* server.status; // ServerStatus (guaranteed by include)
|
|
21
25
|
*
|
|
22
26
|
* await server.sendPower('start');
|
|
@@ -39,19 +43,12 @@ class Server extends reactive_js_1.ReactiveResource {
|
|
|
39
43
|
/** When non-null, overrides the node's reported power state for display. */
|
|
40
44
|
restrictedState;
|
|
41
45
|
groupId;
|
|
42
|
-
eggId;
|
|
43
|
-
eggImageId;
|
|
44
46
|
/** Populated with `include=group`. */
|
|
45
47
|
group;
|
|
46
|
-
/** Populated with `include=egg`. */
|
|
47
|
-
egg;
|
|
48
|
-
eggImageOverride;
|
|
49
48
|
/** Populated with `include=status`. Use {@link getStatus} to fetch on demand. */
|
|
50
49
|
status;
|
|
51
50
|
/** Populated with `include=build`. */
|
|
52
51
|
build;
|
|
53
|
-
/** Populated with `include=startup`. */
|
|
54
|
-
startup;
|
|
55
52
|
/** Populated with `include=allocations`. */
|
|
56
53
|
allocationPorts;
|
|
57
54
|
createdAt;
|
|
@@ -61,6 +58,10 @@ class Server extends reactive_js_1.ReactiveResource {
|
|
|
61
58
|
profiles;
|
|
62
59
|
activity;
|
|
63
60
|
files;
|
|
61
|
+
backups;
|
|
62
|
+
jobs;
|
|
63
|
+
subUsers;
|
|
64
|
+
features;
|
|
64
65
|
/** @internal */
|
|
65
66
|
constructor(data, http, resolveNodeUrl, onMutated) {
|
|
66
67
|
super();
|
|
@@ -69,12 +70,16 @@ class Server extends reactive_js_1.ReactiveResource {
|
|
|
69
70
|
this.onMutated = onMutated;
|
|
70
71
|
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
71
72
|
this.groupId = (0, types_js_1.toNanoID)(data.group_id);
|
|
72
|
-
this.eggId = (0, types_js_1.toNanoID)(data.egg_id);
|
|
73
73
|
this.allocations = new allocations_js_1.ServerAllocationsManager(this.id, http);
|
|
74
74
|
this.sftp = new sftp_js_1.ServerSftpManager(this.id, http);
|
|
75
75
|
this.profiles = new profiles_js_1.ServerProfilesManager(this.id, http);
|
|
76
76
|
this.activity = new activity_js_1.ServerActivityManager(this.id, http);
|
|
77
|
-
this.
|
|
77
|
+
this.subUsers = new sub_users_js_1.ServerUserManager(`/servers/${this.id}`, http);
|
|
78
|
+
this.features = new features_js_1.ServerFeaturesManager(this.id, http);
|
|
79
|
+
const node = new node_client_js_1.NodeClient(this.id, http.getToken(), resolveNodeUrl);
|
|
80
|
+
this.files = new files_js_1.ServerFilesManager(node);
|
|
81
|
+
this.backups = new backups_js_1.ServerBackupsManager(node);
|
|
82
|
+
this.jobs = new jobs_js_1.ServerJobsManager(node);
|
|
78
83
|
this.applyData(data);
|
|
79
84
|
}
|
|
80
85
|
/** Apply raw API data, updating all mutable fields. */
|
|
@@ -83,30 +88,15 @@ class Server extends reactive_js_1.ReactiveResource {
|
|
|
83
88
|
this.description = data.description;
|
|
84
89
|
this.notes = data.notes;
|
|
85
90
|
this.restrictedState = data.restricted_state;
|
|
86
|
-
this.eggImageId = data.egg_image_id ? (0, types_js_1.toNanoID)(data.egg_image_id) : undefined;
|
|
87
|
-
this.eggImageOverride = data.egg_image_override;
|
|
88
91
|
// Include-gated fields: only overwrite if present in response
|
|
89
92
|
if (data.group)
|
|
90
93
|
this.group = new server_groups_js_1.ServerGroup(data.group);
|
|
91
|
-
if (data.egg)
|
|
92
|
-
this.egg = new eggs_js_1.Egg(data.egg);
|
|
93
94
|
if (data.status !== undefined) {
|
|
94
95
|
this.status = data.status ? parseStatus(data.status) : undefined;
|
|
95
96
|
}
|
|
96
97
|
if (data.build !== undefined) {
|
|
97
98
|
this.build = data.build ? parseBuild(data.build) : undefined;
|
|
98
99
|
}
|
|
99
|
-
if (data.startup !== undefined) {
|
|
100
|
-
this.startup = data.startup
|
|
101
|
-
? {
|
|
102
|
-
command: data.startup.command,
|
|
103
|
-
variables: Object.fromEntries(Object.entries(data.startup.variables).map(([k, v]) => [
|
|
104
|
-
k,
|
|
105
|
-
{ key: k, ...v, default: v.default },
|
|
106
|
-
])),
|
|
107
|
-
}
|
|
108
|
-
: undefined;
|
|
109
|
-
}
|
|
110
100
|
if (data.allocations !== undefined) {
|
|
111
101
|
this.allocationPorts = data.allocations ?? undefined;
|
|
112
102
|
}
|
|
@@ -114,7 +104,7 @@ class Server extends reactive_js_1.ReactiveResource {
|
|
|
114
104
|
this.updatedAt = new Date(data.updated_at);
|
|
115
105
|
this.notify();
|
|
116
106
|
}
|
|
117
|
-
/** Update this server's details
|
|
107
|
+
/** Update this server's details or primary allocation. */
|
|
118
108
|
async update(payload) {
|
|
119
109
|
const body = {};
|
|
120
110
|
if (payload.name !== undefined)
|
|
@@ -127,12 +117,6 @@ class Server extends reactive_js_1.ReactiveResource {
|
|
|
127
117
|
if (payload.allocationPrimary) {
|
|
128
118
|
body['allocation_primary'] = payload.allocationPrimary;
|
|
129
119
|
}
|
|
130
|
-
if (payload.startup) {
|
|
131
|
-
body['startup'] = {
|
|
132
|
-
command: payload.startup.command,
|
|
133
|
-
variables: payload.startup.variables,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
120
|
const data = await this.http.patch(`/servers/${this.id}`, body);
|
|
137
121
|
this.applyData(data);
|
|
138
122
|
this.onMutated();
|
|
@@ -179,7 +163,7 @@ function parseStatus(data) {
|
|
|
179
163
|
cpuAbsolute: data.utilization.cpu_absolute,
|
|
180
164
|
networkRxBytes: data.utilization.network.rx_bytes,
|
|
181
165
|
networkTxBytes: data.utilization.network.tx_bytes,
|
|
182
|
-
uptimeMs: data.utilization.
|
|
166
|
+
uptimeMs: data.utilization.uptime,
|
|
183
167
|
diskBytes: data.utilization.disk_bytes,
|
|
184
168
|
}
|
|
185
169
|
: null,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HttpClient } from '../../http.js';
|
|
2
2
|
import { ReactiveResource } from '../../reactive.js';
|
|
3
3
|
import type { IncludeOptions, ListOptions, NanoID, Paginated, ResourceWith, SftpPermission } from '../../types.js';
|
|
4
|
-
import {
|
|
4
|
+
import { User } from '../users.js';
|
|
5
5
|
import type { SftpUserData } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Connection details for the SFTP server on a node.
|
|
@@ -19,8 +19,8 @@ export interface SftpConnection {
|
|
|
19
19
|
*
|
|
20
20
|
* Retrieved via {@link ServerSftpManager.list} or {@link ServerSftpManager.create}.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* The plaintext password is returned only when the user is created or its password
|
|
23
|
+
* is reset. It is never retrievable afterward.
|
|
24
24
|
*/
|
|
25
25
|
export declare class SftpUser extends ReactiveResource {
|
|
26
26
|
/** The SFTP user's unique NanoID. */
|
|
@@ -29,11 +29,7 @@ export declare class SftpUser extends ReactiveResource {
|
|
|
29
29
|
name: string;
|
|
30
30
|
/** The SFTP login username (typically prefixed with the server ID). */
|
|
31
31
|
username: string;
|
|
32
|
-
/**
|
|
33
|
-
* The plaintext password.
|
|
34
|
-
*
|
|
35
|
-
* Automatically included on creation. Requires `include=password` on subsequent fetches.
|
|
36
|
-
*/
|
|
32
|
+
/** The plaintext password. Present only in the creation response. */
|
|
37
33
|
password: string | undefined;
|
|
38
34
|
/**
|
|
39
35
|
* A map of path glob patterns to the set of permissions granted for that path.
|
|
@@ -44,8 +40,8 @@ export declare class SftpUser extends ReactiveResource {
|
|
|
44
40
|
paths: Record<string, SftpPermission[]>;
|
|
45
41
|
/** NanoID of the member who owns this SFTP user. */
|
|
46
42
|
ownerId: NanoID;
|
|
47
|
-
/** The owner
|
|
48
|
-
owner:
|
|
43
|
+
/** The owner. */
|
|
44
|
+
owner: User | null | undefined;
|
|
49
45
|
/** When this SFTP user last logged in, or `null` if never. */
|
|
50
46
|
lastLoginAt: Date | null;
|
|
51
47
|
/** When this SFTP user was created. */
|
|
@@ -56,14 +52,11 @@ export declare class SftpUser extends ReactiveResource {
|
|
|
56
52
|
constructor(data: SftpUserData);
|
|
57
53
|
}
|
|
58
54
|
/** Valid include keys for SFTP user endpoints. */
|
|
59
|
-
export type SftpUserInclude = '
|
|
55
|
+
export type SftpUserInclude = 'owner';
|
|
60
56
|
/** Maps each {@link SftpUserInclude} key to the field(s) it guarantees on the {@link SftpUser} instance. */
|
|
61
57
|
interface SftpUserIncludeMap {
|
|
62
|
-
password: {
|
|
63
|
-
password: string;
|
|
64
|
-
};
|
|
65
58
|
owner: {
|
|
66
|
-
owner:
|
|
59
|
+
owner: User;
|
|
67
60
|
};
|
|
68
61
|
}
|
|
69
62
|
/** A {@link SftpUser} with specific include fields guaranteed to be populated. */
|
|
@@ -88,8 +81,8 @@ export interface SftpDetails {
|
|
|
88
81
|
* console.log(`Connect to: ${details.connection.url}`);
|
|
89
82
|
*
|
|
90
83
|
* const user = await server.sftp.create('deploy', {
|
|
91
|
-
* '/': ['
|
|
92
|
-
* '/logs': ['
|
|
84
|
+
* '/': ['server.file.list', 'server.file.read'],
|
|
85
|
+
* '/logs': ['server.file.list', 'server.file.read', 'server.file.delete'],
|
|
93
86
|
* });
|
|
94
87
|
* console.log(user.password); // Save this!
|
|
95
88
|
* ```
|
|
@@ -119,8 +112,8 @@ export declare class ServerSftpManager {
|
|
|
119
112
|
/**
|
|
120
113
|
* Create a new SFTP user for this server.
|
|
121
114
|
*
|
|
122
|
-
* The returned {@link SftpUser}
|
|
123
|
-
*
|
|
115
|
+
* The returned {@link SftpUser} carries the one-time `password`. It is never
|
|
116
|
+
* retrievable afterward, so store it now.
|
|
124
117
|
*
|
|
125
118
|
* @param name Display name for the SFTP user.
|
|
126
119
|
* @param paths A map of path glob patterns to an array of {@link SftpPermission} scopes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sftp.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/sftp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB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C,eAAe,EAAE,CAAC,CAAM,GAC3C,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAW3B;;;;;;;;;OASG;IACU,MAAM,CAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,GACrC,OAAO,CAAC,QAAQ,CAAC;IAQpB;;;;;;;OAOG;IACU,MAAM,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;KACzC,GACC,OAAO,CAAC,QAAQ,CAAC;IAQpB;;;;OAIG;IACU,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;;;;;;OAOG;IACU,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAM3D"}
|
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ServerSftpManager = exports.SftpUser = void 0;
|
|
4
4
|
const reactive_js_1 = require("../../reactive.js");
|
|
5
5
|
const types_js_1 = require("../../types.js");
|
|
6
|
-
const
|
|
6
|
+
const users_js_1 = require("../users.js");
|
|
7
7
|
/**
|
|
8
8
|
* An SFTP user credential scoped to a specific server with path-level permissions.
|
|
9
9
|
*
|
|
10
10
|
* Retrieved via {@link ServerSftpManager.list} or {@link ServerSftpManager.create}.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* The plaintext password is returned only when the user is created or its password
|
|
13
|
+
* is reset. It is never retrievable afterward.
|
|
14
14
|
*/
|
|
15
15
|
class SftpUser extends reactive_js_1.ReactiveResource {
|
|
16
16
|
/** The SFTP user's unique NanoID. */
|
|
@@ -19,11 +19,7 @@ class SftpUser extends reactive_js_1.ReactiveResource {
|
|
|
19
19
|
name;
|
|
20
20
|
/** The SFTP login username (typically prefixed with the server ID). */
|
|
21
21
|
username;
|
|
22
|
-
/**
|
|
23
|
-
* The plaintext password.
|
|
24
|
-
*
|
|
25
|
-
* Automatically included on creation. Requires `include=password` on subsequent fetches.
|
|
26
|
-
*/
|
|
22
|
+
/** The plaintext password. Present only in the creation response. */
|
|
27
23
|
password;
|
|
28
24
|
/**
|
|
29
25
|
* A map of path glob patterns to the set of permissions granted for that path.
|
|
@@ -34,7 +30,7 @@ class SftpUser extends reactive_js_1.ReactiveResource {
|
|
|
34
30
|
paths;
|
|
35
31
|
/** NanoID of the member who owns this SFTP user. */
|
|
36
32
|
ownerId;
|
|
37
|
-
/** The owner
|
|
33
|
+
/** The owner. */
|
|
38
34
|
owner;
|
|
39
35
|
/** When this SFTP user last logged in, or `null` if never. */
|
|
40
36
|
lastLoginAt;
|
|
@@ -51,7 +47,7 @@ class SftpUser extends reactive_js_1.ReactiveResource {
|
|
|
51
47
|
this.password = data.password;
|
|
52
48
|
this.paths = data.paths;
|
|
53
49
|
this.ownerId = (0, types_js_1.toNanoID)(data.owner_id);
|
|
54
|
-
this.owner = data.owner ? new
|
|
50
|
+
this.owner = data.owner ? new users_js_1.User(data.owner) : data.owner;
|
|
55
51
|
this.lastLoginAt = data.last_login_at ? new Date(data.last_login_at) : null;
|
|
56
52
|
this.createdAt = new Date(data.created_at);
|
|
57
53
|
this.updatedAt = new Date(data.updated_at);
|
|
@@ -69,8 +65,8 @@ exports.SftpUser = SftpUser;
|
|
|
69
65
|
* console.log(`Connect to: ${details.connection.url}`);
|
|
70
66
|
*
|
|
71
67
|
* const user = await server.sftp.create('deploy', {
|
|
72
|
-
* '/': ['
|
|
73
|
-
* '/logs': ['
|
|
68
|
+
* '/': ['server.file.list', 'server.file.read'],
|
|
69
|
+
* '/logs': ['server.file.list', 'server.file.read', 'server.file.delete'],
|
|
74
70
|
* });
|
|
75
71
|
* console.log(user.password); // Save this!
|
|
76
72
|
* ```
|
|
@@ -123,8 +119,8 @@ class ServerSftpManager {
|
|
|
123
119
|
/**
|
|
124
120
|
* Create a new SFTP user for this server.
|
|
125
121
|
*
|
|
126
|
-
* The returned {@link SftpUser}
|
|
127
|
-
*
|
|
122
|
+
* The returned {@link SftpUser} carries the one-time `password`. It is never
|
|
123
|
+
* retrievable afterward, so store it now.
|
|
128
124
|
*
|
|
129
125
|
* @param name Display name for the SFTP user.
|
|
130
126
|
* @param paths A map of path glob patterns to an array of {@link SftpPermission} scopes.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { HttpClient } from '../../http.js';
|
|
2
|
+
import type { ISODate, NanoID } from '../../types.js';
|
|
3
|
+
import { User, type UserData } from '../users.js';
|
|
4
|
+
/**
|
|
5
|
+
* How a sub-user is attached to the resource.
|
|
6
|
+
*
|
|
7
|
+
* - `owner`: the resource owner (implicit, read-only, no grants).
|
|
8
|
+
* - `direct`: granted at this resource's own scope.
|
|
9
|
+
* - `inherited`: granted at the parent group's scope.
|
|
10
|
+
*/
|
|
11
|
+
export type ServerUserKind = 'owner' | 'direct' | 'inherited';
|
|
12
|
+
/** Raw API shape for a sub-user's scoped grant. @internal */
|
|
13
|
+
interface ServerUserGrantData {
|
|
14
|
+
name: string;
|
|
15
|
+
granted_at: ISODate;
|
|
16
|
+
expires_at: ISODate | null;
|
|
17
|
+
}
|
|
18
|
+
/** Raw API shape for a sub-user entry. @internal */
|
|
19
|
+
export interface ServerUserData {
|
|
20
|
+
user: UserData;
|
|
21
|
+
permissions: ServerUserGrantData[];
|
|
22
|
+
kind: ServerUserKind;
|
|
23
|
+
}
|
|
24
|
+
/** A permission granted to a sub-user at the resource scope. */
|
|
25
|
+
export interface ServerUserGrant {
|
|
26
|
+
/** The permission name, e.g. `"server.file.read"`. */
|
|
27
|
+
name: string;
|
|
28
|
+
/** When the grant was created. */
|
|
29
|
+
grantedAt: Date;
|
|
30
|
+
/** When the grant expires, or `null` if it never expires. */
|
|
31
|
+
expiresAt: Date | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A user granted access to a server (or server group), with their scoped grants.
|
|
35
|
+
*
|
|
36
|
+
* Retrieved via {@link ServerUserManager.list} or {@link ServerUserManager.get}.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ServerUser {
|
|
39
|
+
/** The underlying user. */
|
|
40
|
+
readonly user: User;
|
|
41
|
+
/** The permissions granted to this user at the resource scope. */
|
|
42
|
+
readonly permissions: ServerUserGrant[];
|
|
43
|
+
/** How this user is attached. See {@link ServerUserKind}. */
|
|
44
|
+
readonly kind: ServerUserKind;
|
|
45
|
+
/** @internal */
|
|
46
|
+
constructor(data: ServerUserData);
|
|
47
|
+
}
|
|
48
|
+
/** Parameters for adding a sub-user, by existing user id or by email (which may invite a new user). */
|
|
49
|
+
export type AddServerUserInput = {
|
|
50
|
+
userId: NanoID;
|
|
51
|
+
permissions: string[];
|
|
52
|
+
expiresAt?: Date | null;
|
|
53
|
+
} | {
|
|
54
|
+
email: string;
|
|
55
|
+
permissions: string[];
|
|
56
|
+
expiresAt?: Date | null;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Manages the sub-users of a server or server group.
|
|
60
|
+
*
|
|
61
|
+
* Access via `server.subUsers`.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts ignore
|
|
65
|
+
* await server.subUsers.add({ email: 'teammate@example.com', permissions: ['server.console.read'] });
|
|
66
|
+
* const subUsers = await server.subUsers.list();
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare class ServerUserManager {
|
|
70
|
+
private readonly basePath;
|
|
71
|
+
private readonly http;
|
|
72
|
+
/** @internal */
|
|
73
|
+
constructor(basePath: string, http: HttpClient);
|
|
74
|
+
/** List the resource's sub-users. */
|
|
75
|
+
list(): Promise<ServerUser[]>;
|
|
76
|
+
/** Fetch a single sub-user by user ID. */
|
|
77
|
+
get(userId: NanoID): Promise<ServerUser>;
|
|
78
|
+
/**
|
|
79
|
+
* Add a sub-user, or add permissions to an existing one.
|
|
80
|
+
*
|
|
81
|
+
* Identify the user by `userId`, or by `email` (an unknown email invites a new user,
|
|
82
|
+
* which requires `user.manage` and a configured email transport). Existing grants are kept.
|
|
83
|
+
*/
|
|
84
|
+
add(input: AddServerUserInput): Promise<ServerUser>;
|
|
85
|
+
/**
|
|
86
|
+
* Replace a sub-user's permission set. Grants not listed are revoked.
|
|
87
|
+
*
|
|
88
|
+
* @param userId The sub-user's NanoID.
|
|
89
|
+
* @param payload The exact permission set to grant, and an optional expiry.
|
|
90
|
+
*/
|
|
91
|
+
update(userId: NanoID, payload: {
|
|
92
|
+
permissions: string[];
|
|
93
|
+
expiresAt?: Date | null;
|
|
94
|
+
}): Promise<ServerUser>;
|
|
95
|
+
/** Remove a sub-user, revoking all their grants at the resource scope. */
|
|
96
|
+
remove(userId: NanoID): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=sub-users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sub-users.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/sub-users.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE9D,6DAA6D;AAC7D,UAAU,mBAAmB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3B;AAED,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,E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