cheshirecat-typescript-client 1.7.10 → 1.7.11
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.
|
@@ -1,54 +1,7 @@
|
|
|
1
1
|
import { AbstractEndpoint } from "./abstract";
|
|
2
|
-
import { AdminOutput } from "../models/api/admins";
|
|
3
2
|
import { PluginCollectionOutput, PluginToggleOutput } from "../models/api/plugins";
|
|
4
3
|
export declare class AdminsEndpoint extends AbstractEndpoint {
|
|
5
4
|
protected prefix: string;
|
|
6
|
-
/**
|
|
7
|
-
* This endpoint is used to create a new admin user in the system.
|
|
8
|
-
*
|
|
9
|
-
* @param username The username of the new admin user.
|
|
10
|
-
* @param password The password of the new admin user.
|
|
11
|
-
* @param permissions The permissions of the new admin user.
|
|
12
|
-
*
|
|
13
|
-
* @returns The new admin user.
|
|
14
|
-
*/
|
|
15
|
-
postAdmin(username: string, password: string, permissions?: Record<string, string[]> | null): Promise<AdminOutput>;
|
|
16
|
-
/**
|
|
17
|
-
* This endpoint is used to get a list of admin users in the system.
|
|
18
|
-
*
|
|
19
|
-
* @param limit The maximum number of admin users to return.
|
|
20
|
-
* @param skip The number of admin users to skip.
|
|
21
|
-
*
|
|
22
|
-
* @returns A list of admin users.
|
|
23
|
-
*/
|
|
24
|
-
getAdmins(limit?: number | null, skip?: number | null): Promise<AdminOutput[]>;
|
|
25
|
-
/**
|
|
26
|
-
* This endpoint is used to get a specific admin user in the system.
|
|
27
|
-
*
|
|
28
|
-
* @param adminId The ID of the admin user.
|
|
29
|
-
*
|
|
30
|
-
* @returns The admin user.
|
|
31
|
-
*/
|
|
32
|
-
getAdmin(adminId: string): Promise<AdminOutput>;
|
|
33
|
-
/**
|
|
34
|
-
* This endpoint is used to update an admin user in the system.
|
|
35
|
-
*
|
|
36
|
-
* @param adminId The ID of the admin user.
|
|
37
|
-
* @param username The new username of the admin user.
|
|
38
|
-
* @param password The new password of the admin user.
|
|
39
|
-
* @param permissions The new permissions of the admin user.
|
|
40
|
-
*
|
|
41
|
-
* @returns The updated admin user.
|
|
42
|
-
*/
|
|
43
|
-
putAdmin(adminId: string, username?: string | null, password?: string | null, permissions?: Record<string, string[]> | null): Promise<AdminOutput>;
|
|
44
|
-
/**
|
|
45
|
-
* This endpoint is used to delete an admin user in the system.
|
|
46
|
-
*
|
|
47
|
-
* @param adminId The ID of the admin user.
|
|
48
|
-
*
|
|
49
|
-
* @returns The deleted admin user.
|
|
50
|
-
*/
|
|
51
|
-
deleteAdmin(adminId: string): Promise<AdminOutput>;
|
|
52
5
|
/**
|
|
53
6
|
* This endpoint returns the available plugins, at a system level.
|
|
54
7
|
*
|
package/dist/endpoints/admins.js
CHANGED
|
@@ -44,84 +44,7 @@ const mime = __importStar(require("mime-types"));
|
|
|
44
44
|
const abstract_1 = require("./abstract");
|
|
45
45
|
const plugins_1 = require("../models/api/plugins");
|
|
46
46
|
class AdminsEndpoint extends abstract_1.AbstractEndpoint {
|
|
47
|
-
prefix = "/
|
|
48
|
-
/**
|
|
49
|
-
* This endpoint is used to create a new admin user in the system.
|
|
50
|
-
*
|
|
51
|
-
* @param username The username of the new admin user.
|
|
52
|
-
* @param password The password of the new admin user.
|
|
53
|
-
* @param permissions The permissions of the new admin user.
|
|
54
|
-
*
|
|
55
|
-
* @returns The new admin user.
|
|
56
|
-
*/
|
|
57
|
-
async postAdmin(username, password, permissions) {
|
|
58
|
-
const payload = { username, password };
|
|
59
|
-
if (permissions) {
|
|
60
|
-
payload.permissions = permissions;
|
|
61
|
-
}
|
|
62
|
-
return this.post(this.formatUrl("/users"), this.systemId, payload);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* This endpoint is used to get a list of admin users in the system.
|
|
66
|
-
*
|
|
67
|
-
* @param limit The maximum number of admin users to return.
|
|
68
|
-
* @param skip The number of admin users to skip.
|
|
69
|
-
*
|
|
70
|
-
* @returns A list of admin users.
|
|
71
|
-
*/
|
|
72
|
-
async getAdmins(limit, skip) {
|
|
73
|
-
const query = {};
|
|
74
|
-
if (limit)
|
|
75
|
-
query.limit = limit;
|
|
76
|
-
if (skip)
|
|
77
|
-
query.skip = skip;
|
|
78
|
-
const endpoint = this.formatUrl("/users");
|
|
79
|
-
const response = await this.getHttpClient(this.systemId).get(endpoint, query ? { params: query } : undefined);
|
|
80
|
-
if (response.status !== 200) {
|
|
81
|
-
throw new Error(`Failed to fetch data from ${endpoint}: ${response.statusText}`);
|
|
82
|
-
}
|
|
83
|
-
return response.data.map((item) => this.deserialize(JSON.stringify(item)));
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* This endpoint is used to get a specific admin user in the system.
|
|
87
|
-
*
|
|
88
|
-
* @param adminId The ID of the admin user.
|
|
89
|
-
*
|
|
90
|
-
* @returns The admin user.
|
|
91
|
-
*/
|
|
92
|
-
async getAdmin(adminId) {
|
|
93
|
-
return this.get(this.formatUrl(`/users/${adminId}`), this.systemId);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* This endpoint is used to update an admin user in the system.
|
|
97
|
-
*
|
|
98
|
-
* @param adminId The ID of the admin user.
|
|
99
|
-
* @param username The new username of the admin user.
|
|
100
|
-
* @param password The new password of the admin user.
|
|
101
|
-
* @param permissions The new permissions of the admin user.
|
|
102
|
-
*
|
|
103
|
-
* @returns The updated admin user.
|
|
104
|
-
*/
|
|
105
|
-
async putAdmin(adminId, username, password, permissions) {
|
|
106
|
-
const payload = {};
|
|
107
|
-
if (username)
|
|
108
|
-
payload.username = username;
|
|
109
|
-
if (password)
|
|
110
|
-
payload.password = password;
|
|
111
|
-
if (permissions)
|
|
112
|
-
payload.permissions = permissions;
|
|
113
|
-
return this.put(this.formatUrl(`/users/${adminId}`), this.systemId, payload);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* This endpoint is used to delete an admin user in the system.
|
|
117
|
-
*
|
|
118
|
-
* @param adminId The ID of the admin user.
|
|
119
|
-
*
|
|
120
|
-
* @returns The deleted admin user.
|
|
121
|
-
*/
|
|
122
|
-
async deleteAdmin(adminId) {
|
|
123
|
-
return this.delete(this.formatUrl(`/users/${adminId}`), this.systemId);
|
|
124
|
-
}
|
|
47
|
+
prefix = "/plugins";
|
|
125
48
|
/**
|
|
126
49
|
* This endpoint returns the available plugins, at a system level.
|
|
127
50
|
*
|
|
@@ -130,7 +53,7 @@ class AdminsEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
130
53
|
* @returns The available plugins.
|
|
131
54
|
*/
|
|
132
55
|
async getAvailablePlugins(pluginName) {
|
|
133
|
-
const result = await this.get(this.formatUrl("/
|
|
56
|
+
const result = await this.get(this.formatUrl("/installed"), this.systemId, undefined, pluginName ? { query: pluginName } : undefined);
|
|
134
57
|
return plugins_1.PluginCollectionOutput.convertTags(result);
|
|
135
58
|
}
|
|
136
59
|
// create a function to open a file and pass the file contents to postMultipart
|
|
@@ -148,7 +71,7 @@ class AdminsEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
148
71
|
filename: path_1.default.basename(pathZip),
|
|
149
72
|
contentType: mime.contentType(pathZip) || "application/octet-stream"
|
|
150
73
|
});
|
|
151
|
-
const endpoint = this.formatUrl("/
|
|
74
|
+
const endpoint = this.formatUrl("/install/upload");
|
|
152
75
|
const response = await this.getHttpClient(this.systemId).post(endpoint, form, {
|
|
153
76
|
headers: {
|
|
154
77
|
...form.getHeaders(),
|
|
@@ -169,7 +92,7 @@ class AdminsEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
169
92
|
* @returns The output of the plugin installation.
|
|
170
93
|
*/
|
|
171
94
|
async postInstallPluginFromRegistry(url) {
|
|
172
|
-
const result = await this.post(this.formatUrl("/
|
|
95
|
+
const result = await this.post(this.formatUrl("/install/registry"), this.systemId, { url });
|
|
173
96
|
return plugins_1.PluginCollectionOutput.convertTags(result);
|
|
174
97
|
}
|
|
175
98
|
/**
|
|
@@ -178,7 +101,7 @@ class AdminsEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
178
101
|
* @returns The plugins settings.
|
|
179
102
|
*/
|
|
180
103
|
async getPluginsSettings() {
|
|
181
|
-
const result = await this.get(this.formatUrl("/
|
|
104
|
+
const result = await this.get(this.formatUrl("/system/settings"), this.systemId);
|
|
182
105
|
return plugins_1.PluginCollectionOutput.convertTags(result);
|
|
183
106
|
}
|
|
184
107
|
/**
|
|
@@ -189,7 +112,7 @@ class AdminsEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
189
112
|
* @returns The plugin settings.
|
|
190
113
|
*/
|
|
191
114
|
async getPluginSettings(pluginId) {
|
|
192
|
-
const result = await this.get(this.formatUrl(`/
|
|
115
|
+
const result = await this.get(this.formatUrl(`/system/settings/${pluginId}`), this.systemId);
|
|
193
116
|
return plugins_1.PluginCollectionOutput.convertTags(result);
|
|
194
117
|
}
|
|
195
118
|
/**
|
|
@@ -200,7 +123,7 @@ class AdminsEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
200
123
|
* @returns The plugin details.
|
|
201
124
|
*/
|
|
202
125
|
async getPluginDetails(pluginId) {
|
|
203
|
-
const result = await this.get(this.formatUrl(`/
|
|
126
|
+
const result = await this.get(this.formatUrl(`/system/details/${pluginId}`), this.systemId);
|
|
204
127
|
return plugins_1.PluginCollectionOutput.convertTags(result);
|
|
205
128
|
}
|
|
206
129
|
/**
|
|
@@ -211,7 +134,7 @@ class AdminsEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
211
134
|
* @returns The output of the plugin deletion.
|
|
212
135
|
*/
|
|
213
136
|
async deletePlugin(pluginId) {
|
|
214
|
-
const result = await this.delete(this.formatUrl(`/
|
|
137
|
+
const result = await this.delete(this.formatUrl(`/uninstall/${pluginId}`), this.systemId);
|
|
215
138
|
return plugins_1.PluginCollectionOutput.convertTags(result);
|
|
216
139
|
}
|
|
217
140
|
/**
|
|
@@ -222,7 +145,7 @@ class AdminsEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
222
145
|
* @returns The plugin toggle output.
|
|
223
146
|
*/
|
|
224
147
|
async putTogglePlugin(pluginId) {
|
|
225
|
-
return this.put(this.formatUrl(`/
|
|
148
|
+
return this.put(this.formatUrl(`/system/toggle/${pluginId}`), this.systemId);
|
|
226
149
|
}
|
|
227
150
|
}
|
|
228
151
|
exports.AdminsEndpoint = AdminsEndpoint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admins.js","sourceRoot":"","sources":["../../src/endpoints/admins.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAuC;AACvC,0DAAiC;AACjC,gDAAwB;AACxB,iDAAmC;AACnC,yCAA4C;
|
|
1
|
+
{"version":3,"file":"admins.js","sourceRoot":"","sources":["../../src/endpoints/admins.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAuC;AACvC,0DAAiC;AACjC,gDAAwB;AACxB,iDAAmC;AACnC,yCAA4C;AAC5C,mDAAiF;AAEjF,MAAa,cAAe,SAAQ,2BAAgB;IACtC,MAAM,GAAG,UAAU,CAAC;IAE9B;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB,CAAC,UAA0B;QAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CACzB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAC5B,IAAI,CAAC,QAAQ,EACb,SAAS,EACT,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CACjD,CAAC;QAEF,OAAO,gCAAsB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED,+EAA+E;IAE/E;;;;;;OAMG;IACH,KAAK,CAAC,wBAAwB,CAAC,OAAe;QAC1C,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;QAE5B,MAAM,UAAU,GAAG,MAAM,IAAA,mBAAQ,EAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,MAA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