@inweb/client 25.6.2 → 25.6.3
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/dist/client.js +59 -30
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +27 -2
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Client.d.ts +12 -12
- package/lib/Api/Job.d.ts +2 -2
- package/lib/Api/User.d.ts +28 -14
- package/package.json +2 -2
- package/src/Api/Client.ts +12 -12
- package/src/Api/Job.ts +2 -2
- package/src/Api/User.ts +42 -14
package/lib/Api/Client.d.ts
CHANGED
|
@@ -127,8 +127,8 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
127
127
|
/**
|
|
128
128
|
* Change server settings.
|
|
129
129
|
*
|
|
130
|
-
* Only
|
|
131
|
-
* administrator
|
|
130
|
+
* Only administrators can change server settings, if the current logged in user is not an
|
|
131
|
+
* administrator, an exception will be thrown.
|
|
132
132
|
*
|
|
133
133
|
* @async
|
|
134
134
|
*/
|
|
@@ -136,8 +136,8 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
136
136
|
/**
|
|
137
137
|
* Returns a list of server users.
|
|
138
138
|
*
|
|
139
|
-
* Only
|
|
140
|
-
* administrator
|
|
139
|
+
* Only administrators can get a list of users, if the current logged in user is not an
|
|
140
|
+
* administrator, an exception will be thrown.
|
|
141
141
|
*
|
|
142
142
|
* @async
|
|
143
143
|
*/
|
|
@@ -145,8 +145,8 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
145
145
|
/**
|
|
146
146
|
* Returns the user information.
|
|
147
147
|
*
|
|
148
|
-
* Only
|
|
149
|
-
*
|
|
148
|
+
* Only administrators can get other users, if the currently logged in user is not an
|
|
149
|
+
* administrator, they can only get themselves, otherwise an exception will be thrown.
|
|
150
150
|
*
|
|
151
151
|
* @async
|
|
152
152
|
* @param userId - User ID.
|
|
@@ -155,8 +155,8 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
155
155
|
/**
|
|
156
156
|
* Create a new user.
|
|
157
157
|
*
|
|
158
|
-
* Only
|
|
159
|
-
*
|
|
158
|
+
* Only administrators can create users, if the current logged in user is not an
|
|
159
|
+
* administrator, an exception will be thrown.
|
|
160
160
|
*
|
|
161
161
|
* @async
|
|
162
162
|
* @param email - User email. Cannot be empty.
|
|
@@ -184,11 +184,11 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
184
184
|
/**
|
|
185
185
|
* Delete a user from the server.
|
|
186
186
|
*
|
|
187
|
-
* Only
|
|
188
|
-
*
|
|
187
|
+
* Only administrators can delete users, if the current logged in user is not an
|
|
188
|
+
* administrator, an exception will be thrown.
|
|
189
189
|
*
|
|
190
|
-
*
|
|
191
|
-
* not the last administrator.
|
|
190
|
+
* Administrators can delete themselves or other administrators. An administrator can only
|
|
191
|
+
* delete themself if they is not the last administrator.
|
|
192
192
|
*
|
|
193
193
|
* You need to re-login to continue working after deleting the current logged in user.
|
|
194
194
|
*
|
package/lib/Api/Job.d.ts
CHANGED
|
@@ -106,8 +106,8 @@ export declare class Job {
|
|
|
106
106
|
/**
|
|
107
107
|
* Update job data on the server.
|
|
108
108
|
*
|
|
109
|
-
* Only
|
|
110
|
-
*
|
|
109
|
+
* Only administrators can update job data, if the current logged in user is not an
|
|
110
|
+
* administrator, an exception will be thrown.
|
|
111
111
|
*
|
|
112
112
|
* @async
|
|
113
113
|
* @param data - Raw job data.
|
package/lib/Api/User.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export declare class User {
|
|
|
75
75
|
*/
|
|
76
76
|
get initials(): string;
|
|
77
77
|
/**
|
|
78
|
-
* `true` if user is
|
|
78
|
+
* `true` if user is an administrator.
|
|
79
79
|
*/
|
|
80
80
|
get isAdmin(): boolean;
|
|
81
81
|
/**
|
|
@@ -123,15 +123,15 @@ export declare class User {
|
|
|
123
123
|
/**
|
|
124
124
|
* Refresh user data.
|
|
125
125
|
*
|
|
126
|
-
* Only
|
|
127
|
-
* administrator
|
|
126
|
+
* Only administrators can checkout other users, if the current logged in user is not an
|
|
127
|
+
* administrator, they can only checkout themselves, otherwise an exception will be thrown.
|
|
128
128
|
*/
|
|
129
129
|
checkout(): Promise<this>;
|
|
130
130
|
/**
|
|
131
131
|
* Update user data on the server.
|
|
132
132
|
*
|
|
133
|
-
* Only
|
|
134
|
-
* administrator
|
|
133
|
+
* Only administrators can update other users, if the current logged in user is not an
|
|
134
|
+
* administrator, they can only update themself, otherwise an exception will be thrown.
|
|
135
135
|
*
|
|
136
136
|
* @async
|
|
137
137
|
* @param data - Raw user data.
|
|
@@ -140,11 +140,11 @@ export declare class User {
|
|
|
140
140
|
/**
|
|
141
141
|
* Delete a user from the server.
|
|
142
142
|
*
|
|
143
|
-
* Only
|
|
144
|
-
*
|
|
143
|
+
* Only administrators can delete users, if the current logged in user is not an
|
|
144
|
+
* administrator, an exception will be thrown.
|
|
145
145
|
*
|
|
146
|
-
*
|
|
147
|
-
* not the last administrator.
|
|
146
|
+
* Administrators can delete themselves or other administrators. An administrator can only
|
|
147
|
+
* delete themself if they is not the last administrator.
|
|
148
148
|
*
|
|
149
149
|
* You need to re-login to continue working after deleting the current logged in user.
|
|
150
150
|
*
|
|
@@ -162,8 +162,8 @@ export declare class User {
|
|
|
162
162
|
/**
|
|
163
163
|
* Set or remove the user avatar.
|
|
164
164
|
*
|
|
165
|
-
* Only
|
|
166
|
-
* administrator
|
|
165
|
+
* Only administrators can set the avatar of other users, if the current logged in user is
|
|
166
|
+
* not an administrator, they can only set their avatar, otherwise an exception will be thrown.
|
|
167
167
|
*
|
|
168
168
|
* @async
|
|
169
169
|
* @param image - Avatar image. Can be a
|
|
@@ -178,11 +178,25 @@ export declare class User {
|
|
|
178
178
|
/**
|
|
179
179
|
* Remove the user avatar.
|
|
180
180
|
*
|
|
181
|
-
* Only
|
|
182
|
-
*
|
|
183
|
-
* will be thrown.
|
|
181
|
+
* Only administrators can remove the avatar of other users, if the current logged in user is
|
|
182
|
+
* not an administrator, they can only remove their avatar, otherwise an exception will be thrown.
|
|
184
183
|
*
|
|
185
184
|
* @async
|
|
186
185
|
*/
|
|
187
186
|
deleteAvatar(): Promise<this>;
|
|
187
|
+
/**
|
|
188
|
+
* Change the user password.
|
|
189
|
+
*
|
|
190
|
+
* Only administrators can change the passwords of other users, if the current logged in user
|
|
191
|
+
* is not an administrator, they can only change their password, otherwise an exception will
|
|
192
|
+
* be thrown.
|
|
193
|
+
*
|
|
194
|
+
* To change their password, non-administrator users must provide their old password.
|
|
195
|
+
*
|
|
196
|
+
* @async
|
|
197
|
+
* @param newPassword - New user password.
|
|
198
|
+
* @param oldPassword - Old user password. Only required for non-administrator users to
|
|
199
|
+
* change their password.
|
|
200
|
+
*/
|
|
201
|
+
changePassword(newPassword: string, oldPassword?: string): Promise<this>;
|
|
188
202
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/client",
|
|
3
|
-
"version": "25.6.
|
|
3
|
+
"version": "25.6.3",
|
|
4
4
|
"description": "JavaScript REST API client for the Open Cloud Server",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"ts-docs": "typedoc"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@inweb/eventemitter2": "~25.6.
|
|
29
|
+
"@inweb/eventemitter2": "~25.6.3"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/Api/Client.ts
CHANGED
|
@@ -271,8 +271,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
271
271
|
/**
|
|
272
272
|
* Change server settings.
|
|
273
273
|
*
|
|
274
|
-
* Only
|
|
275
|
-
* administrator
|
|
274
|
+
* Only administrators can change server settings, if the current logged in user is not an
|
|
275
|
+
* administrator, an exception will be thrown.
|
|
276
276
|
*
|
|
277
277
|
* @async
|
|
278
278
|
*/
|
|
@@ -283,8 +283,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
283
283
|
/**
|
|
284
284
|
* Returns a list of server users.
|
|
285
285
|
*
|
|
286
|
-
* Only
|
|
287
|
-
* administrator
|
|
286
|
+
* Only administrators can get a list of users, if the current logged in user is not an
|
|
287
|
+
* administrator, an exception will be thrown.
|
|
288
288
|
*
|
|
289
289
|
* @async
|
|
290
290
|
*/
|
|
@@ -299,8 +299,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
299
299
|
/**
|
|
300
300
|
* Returns the user information.
|
|
301
301
|
*
|
|
302
|
-
* Only
|
|
303
|
-
*
|
|
302
|
+
* Only administrators can get other users, if the currently logged in user is not an
|
|
303
|
+
* administrator, they can only get themselves, otherwise an exception will be thrown.
|
|
304
304
|
*
|
|
305
305
|
* @async
|
|
306
306
|
* @param userId - User ID.
|
|
@@ -326,8 +326,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
326
326
|
/**
|
|
327
327
|
* Create a new user.
|
|
328
328
|
*
|
|
329
|
-
* Only
|
|
330
|
-
*
|
|
329
|
+
* Only administrators can create users, if the current logged in user is not an
|
|
330
|
+
* administrator, an exception will be thrown.
|
|
331
331
|
*
|
|
332
332
|
* @async
|
|
333
333
|
* @param email - User email. Cannot be empty.
|
|
@@ -375,11 +375,11 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
375
375
|
/**
|
|
376
376
|
* Delete a user from the server.
|
|
377
377
|
*
|
|
378
|
-
* Only
|
|
379
|
-
*
|
|
378
|
+
* Only administrators can delete users, if the current logged in user is not an
|
|
379
|
+
* administrator, an exception will be thrown.
|
|
380
380
|
*
|
|
381
|
-
*
|
|
382
|
-
* not the last administrator.
|
|
381
|
+
* Administrators can delete themselves or other administrators. An administrator can only
|
|
382
|
+
* delete themself if they is not the last administrator.
|
|
383
383
|
*
|
|
384
384
|
* You need to re-login to continue working after deleting the current logged in user.
|
|
385
385
|
*
|
package/src/Api/Job.ts
CHANGED
|
@@ -192,8 +192,8 @@ export class Job {
|
|
|
192
192
|
/**
|
|
193
193
|
* Update job data on the server.
|
|
194
194
|
*
|
|
195
|
-
* Only
|
|
196
|
-
*
|
|
195
|
+
* Only administrators can update job data, if the current logged in user is not an
|
|
196
|
+
* administrator, an exception will be thrown.
|
|
197
197
|
*
|
|
198
198
|
* @async
|
|
199
199
|
* @param data - Raw job data.
|
package/src/Api/User.ts
CHANGED
|
@@ -152,7 +152,7 @@ export class User {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
|
-
* `true` if user is
|
|
155
|
+
* `true` if user is an administrator.
|
|
156
156
|
*/
|
|
157
157
|
get isAdmin(): boolean {
|
|
158
158
|
return this.data.isAdmin;
|
|
@@ -233,8 +233,8 @@ export class User {
|
|
|
233
233
|
/**
|
|
234
234
|
* Refresh user data.
|
|
235
235
|
*
|
|
236
|
-
* Only
|
|
237
|
-
* administrator
|
|
236
|
+
* Only administrators can checkout other users, if the current logged in user is not an
|
|
237
|
+
* administrator, they can only checkout themselves, otherwise an exception will be thrown.
|
|
238
238
|
*/
|
|
239
239
|
async checkout(): Promise<this> {
|
|
240
240
|
if (this.httpClient.signInUserIsAdmin) {
|
|
@@ -254,8 +254,8 @@ export class User {
|
|
|
254
254
|
/**
|
|
255
255
|
* Update user data on the server.
|
|
256
256
|
*
|
|
257
|
-
* Only
|
|
258
|
-
* administrator
|
|
257
|
+
* Only administrators can update other users, if the current logged in user is not an
|
|
258
|
+
* administrator, they can only update themself, otherwise an exception will be thrown.
|
|
259
259
|
*
|
|
260
260
|
* @async
|
|
261
261
|
* @param data - Raw user data.
|
|
@@ -278,11 +278,11 @@ export class User {
|
|
|
278
278
|
/**
|
|
279
279
|
* Delete a user from the server.
|
|
280
280
|
*
|
|
281
|
-
* Only
|
|
282
|
-
*
|
|
281
|
+
* Only administrators can delete users, if the current logged in user is not an
|
|
282
|
+
* administrator, an exception will be thrown.
|
|
283
283
|
*
|
|
284
|
-
*
|
|
285
|
-
* not the last administrator.
|
|
284
|
+
* Administrators can delete themselves or other administrators. An administrator can only
|
|
285
|
+
* delete themself if they is not the last administrator.
|
|
286
286
|
*
|
|
287
287
|
* You need to re-login to continue working after deleting the current logged in user.
|
|
288
288
|
*
|
|
@@ -320,8 +320,8 @@ export class User {
|
|
|
320
320
|
/**
|
|
321
321
|
* Set or remove the user avatar.
|
|
322
322
|
*
|
|
323
|
-
* Only
|
|
324
|
-
* administrator
|
|
323
|
+
* Only administrators can set the avatar of other users, if the current logged in user is
|
|
324
|
+
* not an administrator, they can only set their avatar, otherwise an exception will be thrown.
|
|
325
325
|
*
|
|
326
326
|
* @async
|
|
327
327
|
* @param image - Avatar image. Can be a
|
|
@@ -352,9 +352,8 @@ export class User {
|
|
|
352
352
|
/**
|
|
353
353
|
* Remove the user avatar.
|
|
354
354
|
*
|
|
355
|
-
* Only
|
|
356
|
-
*
|
|
357
|
-
* will be thrown.
|
|
355
|
+
* Only administrators can remove the avatar of other users, if the current logged in user is
|
|
356
|
+
* not an administrator, they can only remove their avatar, otherwise an exception will be thrown.
|
|
358
357
|
*
|
|
359
358
|
* @async
|
|
360
359
|
*/
|
|
@@ -372,4 +371,33 @@ export class User {
|
|
|
372
371
|
}
|
|
373
372
|
return this;
|
|
374
373
|
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Change the user password.
|
|
377
|
+
*
|
|
378
|
+
* Only administrators can change the passwords of other users, if the current logged in user
|
|
379
|
+
* is not an administrator, they can only change their password, otherwise an exception will
|
|
380
|
+
* be thrown.
|
|
381
|
+
*
|
|
382
|
+
* To change their password, non-administrator users must provide their old password.
|
|
383
|
+
*
|
|
384
|
+
* @async
|
|
385
|
+
* @param newPassword - New user password.
|
|
386
|
+
* @param oldPassword - Old user password. Only required for non-administrator users to
|
|
387
|
+
* change their password.
|
|
388
|
+
*/
|
|
389
|
+
async changePassword(newPassword: string, oldPassword?: string): Promise<this> {
|
|
390
|
+
if (this.httpClient.signInUserIsAdmin) {
|
|
391
|
+
const response = await this.httpClient.put(`/users/${this.id}/password`, { new: newPassword });
|
|
392
|
+
const data = await response.json();
|
|
393
|
+
this.data = { id: data.id, ...data.userBrief };
|
|
394
|
+
} else if (this.id === this.httpClient.signInUserId) {
|
|
395
|
+
const response = await this.httpClient.put("/user/password", { old: oldPassword, new: newPassword });
|
|
396
|
+
const data = await response.json();
|
|
397
|
+
this.data = { id: this.id, ...data };
|
|
398
|
+
} else {
|
|
399
|
+
return Promise.reject(new FetchError(403));
|
|
400
|
+
}
|
|
401
|
+
return this;
|
|
402
|
+
}
|
|
375
403
|
}
|